12.3.4. Action Commands
The available action commands are explained below. You can see Filter Commands to learn what commands are and how they are used.
12.3.4.1. Assign
This command assigns the value of the text by retrieving it via CSS selectors.
- Options
Value selectors: Enter one or more selectors that will be used to find the new value. You can write text
,html
, or the name of another HTML attribute for the attribute input.text
will get the text content of the element, whilehtml
will get the HTML of the element.
12.3.4.2. Clear
This command clears the text. In other words, it replaces the subject value with an empty text.
12.3.4.3. Find and replace
This command finds something in the subject value and replaces it with something.
- Options
Find and replace: See Find and Replace Setting
12.3.4.4. Make upper case
This command makes all the letters of the subject value uppercase. For example, if the subject value
is NASA lands Perseverance on Mars
, then it will become NASA LANDS PERSEVERANCE ON MARS
.
- Options
Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well.
12.3.4.5. Make lower case
This command makes all the letters of the subject value lowercase. For example, if the subject value
is NASA lands Perseverance on Mars
, then it will become nasa lands perseverance on mars
.
- Options
Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well.
12.3.4.6. Make title case
This command makes the first letters of the words in the subject value uppercase. For example, if
the subject value is NASA lands Perseverance on Mars
, then it will become Nasa Lands
Perseverance On Mars
.
- Options
Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well.
12.3.4.7. Make snake case
This command makes the letters of the subject value lowercase, replaces spaces with underscore
character, and puts an underscore character between two adjacent uppercase letters. For example, if
the subject value is NASA lands Perseverance on Mars
, then it will become
n_a_s_a_lands_perseverance_on_mars
.
- Options
Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well.
12.3.4.8. Make kebab case
This command makes the letters of the subject value lowercase, replaces spaces with dash character,
and puts a dash character between two adjacent uppercase letters. For example, if the subject value
is NASA lands Perseverance on Mars
, then it will become n-a-s-a-lands-perseverance-on-mars
.
- Options
Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well.
12.3.4.9. Make camel case
This command makes the first letter of the subject value lowercase, makes the first letter of the
words (other than the first word) uppercase, and removes the spaces. For example, if the subject
value is NASA lands Perseverance on Mars
, then it will become nASALandsPerseveranceOnMars
.
- Options
Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well.
12.3.4.10. Make studly case
This command makes the first letters of the words uppercase and removes the spaces. For example, if
the subject value is NASA lands Perseverance on Mars
, then it will become
NASALandsPerseveranceOnMars
.
- Options
Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well.
12.3.4.11. Make first letter upper case
This command makes the first letter of the subject value uppercase. For example, if the subject
value is nasa lands Perseverance on Mars
, then it will become Nasa lands Perseverance on Mars
.
- Options
Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well.
12.3.4.12. Make slug
This command makes the subject value a slug. A slug is a URL-friendly text that does not contain
characters not suitable for a URL, that is lowercase, and whose space characters are replaced with
dash characters. For example, if the subject value is #NASA lands Perseverance _on_ Mars!!!
,
then it will become nasa-lands-perseverance-on-mars
.
- Options
Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well.
12.3.4.13. Limit words
This command removes the excessive words from the subject value and, optionally, put a text at the end of the subject value if its words are cut.
- Options
Maximum word count: Enter how many words the subject value can contain at maximum End text: If you want to add a text at the end of the cut subject values, enter that text here. The text will be added to the end of the subject value only if its words are cut. Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well. - Example 1
Subject value: NASA lands Perseverance on Mars
Max word count: 3 End text: ...
Result: NASA lands Perseverance...
- Example 2
Subject value: NASA lands Perseverance on Mars
Max word count: 3 End text: Empty Result: NASA lands Perseverance
- Example 3
Subject value: NASA lands Perseverance on Mars
Max word count: 10 End text: ...
Result: NASA lands Perseverance on Mars
12.3.4.14. Limit characters
This command removes the excessive characters from the subject value and, optionally, put a text at the end of the subject value if its characters are cut.
- Options
Maximum character count: Enter how many characters the subject value can contain at maximum End text: If you want to add a text at the end of the cut subject values, enter that text here. The text will be added to the end of the subject value only if its characters are cut. Treat as HTML?: Check this if the subject’s value is HTML, and you want to work with the texts of the elements. If you do not check this in that case, then the HTML code will be considered as well. - Example 1
Subject value: NASA lands Perseverance on Mars
Max char count: 20 End text: ...
Result: NASA lands Persevera...
- Example 2
Subject value: NASA lands Perseverance on Mars
Max char count: 20 End text: Empty Result: NASA lands Persevera
- Example 3
Subject value: NASA lands Perseverance on Mars
Max char count: 100 End text: ...
Result: NASA lands Perseverance on Mars
12.3.4.15. Remove empty HTML elements
This command removes empty HTML elements and HTML comments from the subject value. The HTML tags
that do not have a content are excluded, such as img
tag.
- Options
Remove comments?: Check this checkbox if you want to remove HTML comments from the subject value. Excluded tag names: Enter the HTML tag names that must not be removed even if they do not have content in them. You should separate the tags by commas. The HTML tags that do not have a content are already excluded, such as img
tag.- Example 1
Subject value: <!-- Comment -->NASA lands Perseverance on Mars<p></p>
Remove comments?: checked
Excluded tag names: Empty Result: NASA lands Perseverance on Mars
- Example 2
Subject value: <!-- Comment -->NASA lands Perseverance on Mars<p></p>
Remove comments?: unchecked
Excluded tag names: Empty Result: <!-- Comment -->NASA lands Perseverance on Mars
- Example 3
Subject value: <!-- Comment -->NASA lands <a></a>Perseverance <i></i><b>on</b> Mars <p></p>
Remove comments?: checked
Excluded tag names: p, a
Result: NASA lands <a></a>Perseverance <b>on</b> Mars <p></p>
12.3.4.16. Remove links
This command removes the links that target specific domains from the subject value. This command can be configured in two ways. The first one is to define rules for the blocked domains. Only the links targeting one of those domains will be removed. The second one is to configure allowed domains. In that case, all the links that do not target one of the allowed domains will be removed.
- Options
Blocked domains: Enter the blocked domain rules. The links targeting one of the given domains will be removed. You can use *
to indicate the variable parts. For example,domain.com
rule does not matchsub.domain.com
, but*.domain.com
does.Allowed domains: Enter the allowed domain rules. The links targeting a domain outside of the given domains will be removed. You can use *
to indicate the variable parts. For example,domain.com
rule does not matchsub.domain.com
, but*.domain.com
does.
The following examples’ subject value is this:
<a href="https://domain1.com">Link 1</a>
<a href="https://domain2.com">Link 2</a>
<a href="https://sub.domain1.com">Link 3</a>
- Example 1
Blocked domains: Empty
Allowed domains: domain1.com
Result: <a href="https://domain1.com">Link 1</a> Link 2 Link 3
- Example 2
Blocked domains: domain1.com
Allowed domains: Empty
Result: Link 1 <a href="https://domain2.com">Link 2</a> <a href="https://sub.domain1.com">Link 3</a>
- Example 3
Blocked domains: domain1.com
and*.domain1.com
Allowed domains: Empty
Result: Link 1 <a href="https://domain2.com">Link 2</a> Link 3
- Example 4
Blocked domains: domain2.com
Allowed domains: domain2.com
Result: Link 1 Link 2 Link 3
- Example 5
Blocked domains: Empty
Allowed domains: Empty
Result: <a href="https://domain1.com">Link 1</a> <a href="https://domain2.com">Link 2</a> <a href="https://sub.domain1.com">Link 3</a>
12.3.4.17. Template
This command allows you to add a text before or after the subject value or replace it with a different value.
- Options
Template: Define the new value. You can add [wcc-item]
shortcode anywhere in the template to include the original subject value.- Example 1
Subject value: Mars Rover
Template: Incredible [wcc-item]
Result: Incredible Mars Rover
- Example 2
Subject value: Mars Rover
Template: [wcc-item], [wcc-item], the incredible [wcc-item]
Result: Mars Rover, Mars Rover, the incredible Mars Rover
- Example 3
Subject value: Mars Rover
Template: Perseverance
Result: Perseverance
12.3.4.18. Exchange attributes
This command exchanges the values of two attributes of the same element.
- Options:
Attribute names: Enter the names of the attributes whose values will be exchanged with each other. If the value of Attribute 2
does not exist, the values will not be exchanged.- Example 1
Subject value: <img src="placeholder.jpg" data-src="real-image.jpg">
Attribute 1: src
Attribute 2: data-src
Result: <img src="real-image.jpg" data-src="placeholder.jpg">
- Example 2
Subject value: <img src="image.jpg">
Attribute 1: src
Attribute 2: data-src
Result: <img src="image.jpg">
- Example 3
Subject value: <img src="image.jpg" data-src="">
Attribute 1: src
Attribute 2: data-src
Result: <img src="image.jpg" data-src="">
12.3.4.19. Remove
This command removes the element provided as the subject value from the HTML. If the element has elements inside, they will be removed as well.
12.3.4.20. Remove attributes
This command removes the specified attributes from the subject elements.
- Options
Attribute names: Define the names of the attributes that will be removed from the element. To enter multiple attributes, separate them with commas. For example, attribute1
defines only one attribute, whileattribute1, attribute2
defines two attributes. The order of the attributes is not important.- Example 1
Subject value: <img src="real-image.jpg" data-src="placeholder.jpg" data-size="large">
Attribute names: data-src
Result: <img src="real-image.jpg" data-size="large">
- Example 2
Subject value: <img src="real-image.jpg" data-src="placeholder.jpg" data-size="large">
Attribute names: data-size, data-src
Result: <img src="real-image.jpg">
12.3.4.21. Remove data attributes
This command removes all the attributes whose name starts with data-
from the subject element and all the elements
in it.
- Example 1
Subject value: <div class="target" data-data="data"> <div data-a="a" data-b="b"> <div data-c> <b data-x="x"></b> </div> </div> <div datatest="test"> <p>Hi!</p> </div> </div>
Result: <div class="target"> <div> <div> <b></b> </div> </div> <div datatest="test"> <p>Hi!</p> </div> </div>
12.3.4.22. Simplify
This command unwraps the elements that have only one child element.
- Options
Only tags: Names of the HTML tags that can be unwrapped. If no tag is provided, it means all the tags can be unwrapped. For example, if you write div
, only the eligiblediv
elements will be unwrapped.Skip tags: Names of the HTML tags that must not be unwrapped. For example, if you write p
, thep
elements will be skipped, even if they are eligible to be unwrapped.- Example 1
Subject value: <div class="target"> <div> <div> <div> <p>Hi!</p> </div> </div> </div> </div>
Only tags: Empty
Skip tags: Empty
Result: <div class="target"> <p>Hi!</p> </div>
- Example 2
Subject value: <div class="target"> <a> <b> <div> <p>Hi!</p> </div> </b> </a> </div>
Only tags: Empty
Skip tags: a
andb
Result: <div class="target"> <a> <b> <p>Hi!</p> </b> </a> </div>
- Example 3
Subject value: <div class="target"> <a> <b> <div> <p>Hi!</p> </div> </b> </a> </div>
Only tags: a
andb
Skip tags: Empty
Result: <div class="target"> <div> <p>Hi!</p> </div> </div>
12.3.4.23. Clone
This command clones the element provided as the subject value. The cloned element will be placed as the next sibling to the original element and given the ID you specified. Entering an ID is mandatory for this command, because it might be hard to interact with the cloned element if it does not have an ID. This command assumes that you want to interact with the cloned element.
- Options
Clone all found elements?: Check this if all the elements found by the provided CSS selectors must be cloned. If this is not checked, only the first one in the found elements will be cloned. Element ID: Enter the ID that will be assigned to the cloned element. You can use this ID to interact with the cloned element later. An ID attribute cannot have a space character in it, according to the specifications. However, if you enter a space-separated list, it will be considered as multiple IDs. In case of cloning multiple elements, the given ID(s) will be suffixed a number for each cloned element. For example, if the given ID is my-element my-clone
, and there are three cloned elements, while the first clone will havemy-element my-clone
as its ID, the second and third ones will havemy-element2 my-clone2
andmy-element3 my-clone3
as their IDs.
12.3.4.24. Create
This command is used to create one more HTML elements and insert them into the target page relative to a specific element defined by its CSS selector. If there are multiple target elements, a new HTML element will be created and inserted for each of them.
- Options
Location: Select the location of the new HTML element relative to the target element, which is the element specified via its CSS selector. For example, “After” means that the new HTML element should be inserted just after the target element, as a sibling. “Inside Top” means that the new HTML element should be inserted inside the target element as the first child. Use local custom short codes?: Check this if the local custom short codes must be used in this command. When this is checked, all the short codes used in the template option will be applied immediately. Otherwise, the short codes used in the template will be applied when the created element is used in a setting whose short codes are applied. Local custom short codes: Define custom short codes that can be used in the template. This option is only available when the “Use local custom short codes?” option is selected. Short codes: Short codes that can be used in the code of the new HTML element. You can hover over the short codes to see what they do. You can click to the short code buttons to copy the short codes. Then, you can paste the short codes into the new HTML element’s code to include them. They will be replaced with their actual values. New element’s HTML code: Define your HTML element. The code you enter here must be a valid HTML code. If it is not valid, you might get unexpected results. Otherwise, your element will be created and inserted into the specified location. - Example 1
Subject value: <div> <h1>Title</h1> </div>
Location: After
New element’s HTML code: <div>My element</div>
Result: <div> <h1>Title</h1> </div> <div>My element</div>
- Example 2
Subject value: <div> <h1>Title</h1> </div>
Location: Before
New element’s HTML code: <div>My element</div>
Result: <div>My element</div> <div> <h1>Title</h1> </div>
- Example 3
Subject value: <div> <h1>Title</h1> </div>
Location: Inside Top
New element’s HTML code: <div>My element</div>
Result: <div> <div>My element</div> <h1>Title</h1> </div>
- Example 4
Subject value: <div> <h1>Title</h1> </div>
Location: Inside Bottom
New element’s HTML code: <div>My element</div>
Result: <div> <h1>Title</h1> <div>My element</div> </div>
12.3.4.25. Move
This command moves the target element relative to the specified reference element.
- Options
Reference selectors: Enter one or more selectors that will be used to find the reference element. If multiple elements are found, the first one will be used. Location: Select the location of the new HTML element relative to the target element, which is the element specified via its CSS selector. For example, “After” means that the new HTML element should be inserted just after the target element, as a sibling. “Inside Top” means that the new HTML element should be inserted inside the target element as the first child. - Example 1
Page HTML: <div id="container"> <p> <h1>Title</h1> </p> </div>
Selectors: h1
(This option is available for the subject of the command)Reference selectors: #container
Location: Inside Top
New page HTML: <div id="container"> <h1>Title</h1> <p></p> </div>
Please see Create for more examples related to the location.
12.3.4.26. Unwrap
This command removes an element’s tags, while keeping its content.
- Example 1
Subject value: <div> <h1>Title</h1> </div>
Result: <h1>Title</h1>
- Example 2
Subject value: <h1><span>My</span> Title</h1>
Result: <span>My</span> Title
12.3.4.27. Calculate
This command calculates a value by using the subject value and replaces the subject value with the result of the calculation.
Important
Although this command lets you assign a thousands separator and use ,
as the
decimal separator, the result will not be a valid number when you do these. For the command to be
able to result in a number when the subject value is a number, you must use .
as the decimal
separator, and you must not use a thousands separator.
- Options
Decimal separator: Select the decimal separator to be used in the resultant number. The one that is not selected will be used as the thousands separator. Use thousands separator?: Check this if you want to use thousands separator in the result. Precision: Enter how many digits at max there can be after the decimal separator. Default: 0
Local custom short codes: Define custom short codes that can be used in the formula. The formula is evaluated after the short codes are replaced. Short codes: Short codes that can be used in the formula. You can hover over the short codes to see what they do. You can click to the short code buttons to copy the short codes. Then, you can paste the short codes into the template to include them. They will be replaced with their actual values. Formula: Enter formulas that will be used to create the new value. If you enter more than one, a random one will be used. Use x
orX
to include the original value. For example, you can writex * 3^2
to multiply the number by9
. You can use the following operators:*
,+
,/
,-
,^
12.3.4.28. Add minutes
This command adds minutes to the subject date.
- Options
Minutes to add: How many minutes should be added to the subject date. You can enter negative numbers too. Also, you can enter a comma-separated list of numbers, so that one of those values can be used randomly. Examples: 10
,-5
,-1, 3, 2, 8, 1440, -1440
12.3.4.29. Set to fixed date
Assigns the subject date’s value as the specified fixed date.
- Options
New date: The date that will be assigned as the new value. Enter a date formatted as Y-m-d H:i:s
, i.e.(year)-(month)-(day) (hour):(minute):(second)
. For example:2020-05-27 13:37:15
. You can also enter any time value supported by DateTime. If the date is not a fixed date, then the time of your server is used as now, not the time of WordPress. It is recommended to enter a fixed date for reliability.
12.3.4.30. Set to now
Sets the subject date’s value as the current time. The current time is retrieved from WordPress. So, your WordPress installation’s date and time settings will be used.
12.3.4.31. Set scheduling
This command is used to enable or disable the Active for scheduling? setting. The setting is not updated while testing, such as running a CSS selector test or a general test in the Tester Page page.
- Options
Enabled?: Check this if the setting must be changed to “enabled”. Otherwise, the setting will be changed to “disabled”.
12.3.4.32. Set recrawling
This command is used to enable or disable the Active for recrawling? setting. The setting is not updated while testing, such as running a CSS selector test or a general test in the Tester Page page.
- Options
Enabled?: Check this if the setting must be changed to “enabled”. Otherwise, the setting will be changed to “disabled”.
12.3.4.33. Set post deleting
This command is used to enable or disable the Active for post deleting? setting. The setting is not updated while testing, such as running a CSS selector test or a general test in the Tester Page page.
- Options
Enabled?: Check this if the setting must be changed to “enabled”. Otherwise, the setting will be changed to “disabled”.
12.3.4.34. Send email notification
This command sends an email to the email addresses specified in Email addresses setting. Also, the notifications must be activated via Notifications are active? setting. If the notifications are not active, or there are no email addresses defined, this command does not send an email notification.
- Options
Title: Title of the notification. You can use the short codes shown at the top of the command container to include certain information into the template. If you leave this empty, a default template will be used. However, the default template will not include specific information that you can use to differentiate notifications. Hence, it is recommended that you enter a descriptive value. Message: Enter the message that will be sent as a notification. You can use the short codes shown at the top of the command container to include certain information into the template. If you leave this empty, a default template will be used. However, the default template will not include specific information that you can use to differentiate notifications. Hence, it is recommended that you enter a descriptive value. Notification identifier: A text that will be used to identify this notification to limit the number of same-type notifications to be sent. Getting numerous notifications about the same thing will probably bother you. To prevent this, just enter a text so that the plugin can reduce the number of notifications. If you leave this empty, the notifications will not be limited. You can use the same identifier for other notification commands as well. For example, you can enter notification-about-low-price
. When a notification is sent, the date of the notification will be stored for this identifier. The date will be checked before sending another notification.Notification interval (in minutes): This defines the minimum duration between two notifications, in minutes. For example, if you enter 30
, you will not get more than one notification within30
minutes. For this to work, you have to define the notification identifier as well. If you leave this empty, the default value will be used, which is30
.- Short codes
[wcc-request-url]
:URL of the page being crawled [wcc-status-code]
:HTTP status code of the response of the crawl request. E.g. 400
,403
,200
,500
, etc.[wcc-site-name]
:Name of the site, defined by you [wcc-site-id]
:ID of the site [wcc-site-edit-url]
:The URL that displays the site edit page [wcc-current-time]
:Current date and time, e.g. 2021-02-24 09:25:52
12.3.4.35. Stop
This command stops the execution of the crawling operation immediately. If there is a post that is
already saved for the current URL, it will not be deleted. If this is executed during the crawling
of a multi-page post, the status of the post will remain as draft
.
- Options
Reason: A short explanation about why the crawling should be stopped. This will be added to the log message and to the information messages that you will see when this command is run. This is optional. If you define this, you will be able to understand why this command is run when it is run.
12.3.4.36. Stop and delete the post
This command stops the execution of the crawling operation immediately. Then, deletes the post created in your site for the current URL (the URL being crawled), if the post exists.
- Options
Reason: A short explanation about why the crawling should be stopped and the post should be deleted. This will be added to the log message and to the information messages that you will see when this command is run. This is optional. If you define this, you will be able to understand why this command is run when it is run. Delete URL?: Check this if the URL of the post should be deleted from the database. When the URL is deleted, the plugin will be able to save the URL to the database again, if the URL is found in a category page. This means that the post can be saved again. If the URL is not deleted, the post will not be saved again.
12.3.4.37. Wait
This command pauses the execution for the specified amount of time. This might be handy when you make requests to an API that has rate limits, such as 2 requests every 30 seconds. After you make two requests to this API, you can use this command to wait for 30 seconds before making the next request.
- Options
Duration (seconds): Specify the duration for which the script execution should wait, in seconds. For instance, you can enter 30
to wait for 30 seconds. Decimal values are also accepted. For example, to wait for 100 milliseconds, you can enter0.1
.
12.3.4.38. Set author
This command assigns the author of the post.
- Options
Author: Select the author that will be assigned to the crawled post.
12.3.4.39. Set featured image
This command assigns the featured image of the post.
- Options
Featured image IDs: Define the ID of an image that will be used as the featured image of the post. If you define multiple image IDs, one of them will be used randomly.
12.3.4.40. Set post status
This command assigns the status of the post, such as Draft
or Pending
.
- Options
Post status: Select the status that will be assigned to the crawled post.
12.3.4.41. Add tags
This command adds tags to the crawled post. It can also delete the existing tags.
- Options
Tags: Define the tags that will be added to the tags of the post. To enter multiple tags, separate them with commas. For example, my tag
defines only one tag, whilemy, tag
defines two tags.Delete other tags?: Check this if you want to delete other existing tags, if any exists.
12.3.4.42. Add categories
This command adds the crawled post under the given categories. It can also delete the existing categories.
Important
If you want the defined categories not to be added under the main category selected in Category URLs setting, you must enable Do not add the category defined in the category URLs? setting.
- Options
Categories: Enter the categories. Add a new item for each top-level category. You can add child categories to the top-level category by separating them with >
character. For example,Cities
puts the post under that category, whileCities > Metropolitan > Chicago
puts it under the last category after creating its parent categories.Delete other categories?: Check this if you want to delete other existing categories, if any exists. This does not delete the categories from WordPress. This just removes the post from those categories.
12.3.4.43. Field template
This command is used to apply a template to multiple fields of the post. For example, if you want to prepend a text to the title, content, and tags, you can use this command to prepend that text to all these fields.
- Options
Fields: Select the fields that will be changed by using the template. If there is no field selected, no field value will be changed. Short codes: Short codes that can be used in the template. You can hover over the short codes to see what they do. You can click to the short code buttons to copy the short codes. Then, you can paste the short codes into the template to include them. They will be replaced with their actual values. Template: Enter your template. What you define here will be used as the new value of the specified fields. The original value will be replaced with this template. - Example 1
Subjects: Title: My title Slug: my-post-slug Content: <div>My content</div>
Tags: tag1, tag2 Fields: Title
,Content
,Tags
Template: My prefix - [wcc-item]
Result: Title: My prefix - My title Slug: my-post-slug Content: My prefix - <div>My content</div>
Tags: My prefix - tag1, My prefix - tag2
12.3.4.44. Translate
This command is used to translate one or more fields of the post, such as post title and content.
- Options
Fields: Select the fields that will be translated. If no fields are selected, all the fields will be translated. Translate with: Select the translation service that will be used to translate the attributes of the elements. Languages: Select the languages. For each language pair, the first language is the current language of the content, while the second language is the language the content will be translated to. You can enter many language pairs to translate the content multiple times. The translations will be applied in the specified order. Note: If no languages are available for selection, you need to load the translation languages from the general settings and then reload the site settings page.
12.3.4.45. Add post URLs
This command makes it possible to add post URLs conditionally in a category page.
- Options
Post URL Selectors: Enter one or more selectors that will be used to find the post URLs. You can write text
,html
, or the name of another HTML attribute for the attribute input.text
will get the text content of the element, whilehtml
will get the HTML of the element.
12.3.4.46. Translate element attributes
This command is used to translate attributes of the elements. Translation services might not translate element
attributes that contain texts. In that case, this command is useful to translate those texts stored in element
attributes, such as alt
and title
attributes of img
elements.
- Options
Target attribute selectors: Enter one or more selector-attribute rules that will be used to find the target element attributes that will be translated. You can enter many attribute names by using a comma as a separator. All the found attribute values will be translated. For example, to translate alt
andtitle
attributes ofimg
elements, you can enterimg
as the CSS selector andalt, title
into the attribute input.Translate with: Select the translation service that will be used to translate the attributes of the elements. Languages: Select the languages. For each language pair, the first language is the current language of the content, while the second language is the language the content will be translated to. You can enter many language pairs to translate the content multiple times. The translations will be applied in the specified order. Note: If no languages are available for selection, you need to load the translation languages from the general settings and then reload the site settings page.
12.3.4.47. Convert to HTML
This command is used to convert JSON to HTML via an HTML template.
- Options
HTML template: Define the template to be used to convert data to HTML code. For more information and examples, please see Converting JSON to HTML via a template.
12.3.4.48. Convert to HTML automatically
This command is used to convert JSON to HTML automatically. For more information, please see Converting JSON to HTML automatically.
- Options
Only field paths: Enter the paths of fields that should be the only fields in the data. The unspecified paths will be considered as unnecessary and removed before converting the data to HTML. To learn what a path is, please see JSON path. Unnecessary field paths: Enter the paths of fields that should be removed from the data before converting the data to HTML. To learn what a path is, please see JSON path. - Example 1
Subject: { "data": { "ids": ["id-1", "id-2", "id-3"], "relatedItems": [ {"name": "Related item 1"}, {"name": "Related item 2"} ], "post": { "title": "My title", "content": "Content of the post..." } } }
Only field paths: Empty
Unnecessary field paths: Empty
Result: <div class="wpcc-converted-json wpcc-generated-container"> <div class="data" data-key="data"> <div class="ids" data-key="ids"> <div data-index="0">id-1</div> <div data-index="1">id-2</div> <div data-index="2">id-3</div> </div> <div class="relatedItems" data-key="relatedItems"> <div data-index="0"> <div class="name" data-key="name">Related item 1</div> </div> <div data-index="1"> <div class="name" data-key="name">Related item 2</div> </div> </div> <div class="post" data-key="post"> <div class="title" data-key="title">My title</div> <div class="content" data-key="content">Content of the post...</div> </div> </div> </div>
- Example 2
Subject: { "data": { "ids": ["id-1", "id-2", "id-3"], "relatedItems": [ {"name": "Related item 1"}, {"name": "Related item 2"} ], "post": { "title": "My title", "content": "Content of the post..." } } }
Only field paths: data.post
Unnecessary field paths: Empty
Result: <div class="wpcc-converted-json wpcc-generated-container"> <div class="data" data-key="data"> <div class="post" data-key="post"> <div class="title" data-key="title">My title</div> <div class="content" data-key="content">Content of the post...</div> </div> </div> </div>
- Example 3
Subject: { "data": { "ids": ["id-1", "id-2", "id-3"], "relatedItems": [ {"name": "Related item 1"}, {"name": "Related item 2"} ], "post": { "title": "My title", "content": "Content of the post..." } } }
Only field paths: Empty
Unnecessary field paths: data.ids
data.post
Result: <div class="wpcc-converted-json wpcc-generated-container"> <div class="data" data-key="data"> <div class="relatedItems" data-key="relatedItems"> <div data-index="0"> <div class="name" data-key="name">Related item 1</div> </div> <div data-index="1"> <div class="name" data-key="name">Related item 2</div> </div> </div> </div> </div>
12.3.4.49. Make
This command makes a request to each URL found in the target page via defined CSS selectors and appends their response to the page. This is useful for manually making AJAX requests. Moreover, you can use this command to make requests to APIs. If the API responses are in JSON, you can process them by using Convert to HTML and Convert to HTML automatically commands.
- Options
Request URL selectors: Enter one or more selectors that will be used to find the URL to which a request will be made. This is a type of Selector and Attribute Setting. Method: Select the method [1] that will be used when making the request. Container element ID: Enter the ID that will be assigned to the new element that will contain the response content. You can use this ID to interact with the response content later. An ID attribute cannot have a space character in it, according to the specifications. However, if you enter a space-separated list, it will be considered as multiple IDs. In case of making multiple requests, the given ID(s) will be suffixed a number for each request. For example, if the given ID is my-element my-response
, and there are three requests, while the first element will havemy-element my-response
as its ID, the second and third ones will havemy-element2 my-response2
andmy-element3 my-response3
as their IDs.Find and replace in raw response: Find and replace anything in the raw response content. This is a Find and Replace Setting. Extra cookies: Enter the extra cookies that will be sent with the request. See Cookies for more information. Extra request headers: Enter the extra headers that will be sent with the request. See Headers for more information. Don’t resolve relative URLs?: Check this if the relative URLs in the response must not be turned into absolute URLs. - Options for the
POST
[2] method These options are shown only when the request method is selected as
POST
[2].POST body custom short codes: Define custom short codes that can be used in the POST
body template to create the finalPOST
body. See Custom Short Code Selectors for more information.POST body short codes: Short codes that can be used in the POST
body. You can hover over the short codes to see what they do. You can click to the short code buttons to copy the short codes. Then, you can paste the short codes into the template to include them. They will be replaced with their actual values.POST body template: Define the body of the POST
request
The response container that is created and added to the target page’s source code always has a wpcc-response
class.
Also, this container element contains an element having a wpcc-response-head
class as its direct child which
contains the elements of the head
element of the response when the response is HTML.
- Example 1 (Making a
GET
request to an API URL) In this example, we assume that the page contains a URL to which you want to make a request. We use the URL of a free weather info API just as an example. If the target page does not contain the desired URL, you can use Create command to create an
a
element that has the desired URL in itshref
attribute and select that element in this command’s Request URL selectors option.Target page’s source code before request: <body> <div> <h1>Title</h1> <div>Content</div> <a href="https://api.open-meteo.com/v1/forecast?latitude=41.89&longitude=12.49¤t=temperature_2m" id="api-url"> API URL </a> </div> </body>
Request URL selectors: Selector: #api-url
Attribute: href
Method: GET
Container element ID: weather-info
Result: <body> <div> <h1>Title</h1> <div>Content</div> <a href="https://api.open-meteo.com/v1/forecast?latitude=41.89&longitude=12.49¤t=temperature_2m" id="api-url"> API URL </a> </div> <div id="weather-info" class="wpcc-response"> <div class="wpcc-response-head"></div> <p> { "latitude": 41.89, "longitude": 12.49, "generationtime_ms": 0.12099742889404297, "utc_offset_seconds": 0, "timezone": "GMT", "timezone_abbreviation": "GMT", "elevation": 32.0, "current_units": { "time": "iso8601", "interval": "seconds", "temperature_2m": "°C" }, "current": { "time": "2023-10-13T09:00", "interval": 900, "temperature_2m": 23.4 } } </p> </div> </body>
As it can be seen in the result, the API response is in an element that has
weather-info
ID, which was specified in the command’s Container element ID option. You can use this ID in other CSS selector options of the plugin to retrieve the values from the response.
12.3.4.50. Remove
This command removes the specified errors of the Error subjects. After an error is removed, it will no longer be available for use in the condition and action commands. For example, if there are 3 file-saving errors, and you remove one of them via this command, the count of the file-saving errors will be 2 when you check the count via a condition command.
Footnotes
[1] | https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods |
[2] | (1, 2) https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST |