12.3. Filter Commands
This section explains the commands defined in a Filter. Each command is composed of a subject, a property, and options. There are two types of commands, which are a condition command and an action command.
Fig. 12.9 shows a condition command. A condition command checks a condition and
results in either true
or false
. With a condition command, you check if something is
true
. If it is true
, then we say that the condition is met. The command shown in
Fig. 12.9 checks if an element exists in the page. You simply give one or more
CSS selectors to the command. If the command can find an element with the given CSS selectors, then
it meets the condition. If it cannot, then it does not meet the condition.
Fig. 12.10 shows an action command. An action command performs an action, as its name suggests. The command shown in Fig. 12.10 finds something in the post’s title and replaces it with something. You simply define what to find and with what to replace in the title, and the command does that.
As it can be seen in Fig. 12.9 and Fig. 12.10, regardless of its type, a command needs to have a subject and a property. A subject simply defines what the command should work with. A property defines what part of the subject the command should work with. For example, in Fig. 12.9, the command should work with an element’s value. Likewise, in Fig. 12.10, the command should work with the post title’s value, meaning that the command should find something in the post’s title and replace it with something else. You can read the command in Fig. 12.9 as “if an element’s value exists” and the command in Fig. 12.10 as “find and replace something in the title’s value”. When these two commands form a Filter together, you can read the filter as “if an element’s value exists, then find and replace something in the title’s value”.
When you select a subject and its property, you will see the suitable commands for the
subject-property combination. So, not every command is suitable for every subject-property
combination. For example, you cannot check if apple
word is greater than 20
, since one of
them is a text while the other one is a number. You do not need to worry about this, because the
plugin will show only the suitable commands for you.
In Fig. 12.9, there is a checkbox named as Stop after first match
. This
comes in handy when the selected subject has many items in it. When this checkbox is checked, the
execution of the condition command is stopped when it finds a single item that meets the condition.
For example, let’s say there are 20 post tags, and you want to check if one of them contains
Mars
in it. Let’s also say that the first tag contains Mars
in it. When you check this
checkbox, the command stops checking if the remaining 19 tags contain the word. So, the command does
less work, takes less time, and spends less resources. If you do not check this checkbox, then the
command checks all the 20 tags in this hypothetical case. If you check this checkbox, and the 20th
item also contains Mars
, then the 20th item will not be considered as a matched subject. So, if
you work with the matched subjects in an action command, only the 1st match will be available.
Please keep reading to learn how to work with the matched subjects in an action command.
In Fig. 12.10, there is a checkbox named as Only the items matched by
conditions
. When you check this checkbox, the action command will be executed only for the items
matched by the conditions. This means that, if there is a true
condition having the same subject
as the action command’s, the action command is executed only for the items matched by the
condition(s). When checked, if no condition has the same subject, then the action command is
definitely executed without any limitations. For example, let’s say there are three post tags as
product price
, product color
, and size
, and you want to add product
before a tag
if it does not start with product
. To do this, you first add a condition command that checks if
a tag’s value starts with product
. Then, you add an action command that also targets the tags’
values with template
command, and check Only the items matched by conditions
checkbox. In
this case, the action command will be executed only for the size
tag.
Note
The following video tutorial explains what the filters are and how they are used.
The plugin contains many condition and action commands, as well as many subjects and properties. You can find out about these in the sections below.
- 12.3.1. Command Subjects
- 12.3.2. Subject Properties
- 12.3.2.1. Value
- 12.3.2.2. Character length
- 12.3.2.3. Word length
- 12.3.2.4. Numeric value
- 12.3.2.5. Element attribute value
- 12.3.2.6. Element numeric attribute value
- 12.3.2.7. Count
- 12.3.2.8. Attribute value
- 12.3.2.9. Numeric attribute value
- 12.3.2.10. HTML
- 12.3.2.11. Text
- 12.3.2.12. Numeric text
- 12.3.2.13. Tag name
- 12.3.2.14. Attribute value as JSON
- 12.3.2.15. Text as JSON
- 12.3.2.16. JSON attribute’s text value
- 12.3.2.17. JSON attribute’s numeric value
- 12.3.2.18. JSON attribute’s date value
- 12.3.2.19. Error
- 12.3.2.20. HTTP status code
- 12.3.2.21. Error text
- 12.3.3. Condition Commands
- 12.3.3.1. Greater than
- 12.3.3.2. Less than
- 12.3.3.3. Greater than or equal to
- 12.3.3.4. Less than or equal to
- 12.3.3.5. Equal to
- 12.3.3.6. Not equal to
- 12.3.3.7. Starts with
- 12.3.3.8. Does not start with
- 12.3.3.9. Ends with
- 12.3.3.10. Does not end with
- 12.3.3.11. Contains
- 12.3.3.12. Does not contain
- 12.3.3.13. Is uppercase
- 12.3.3.14. Is not uppercase
- 12.3.3.15. Is lowercase
- 12.3.3.16. Is not lowercase
- 12.3.3.17. Matches regex
- 12.3.3.18. Does not match regex
- 12.3.3.19. Exists
- 12.3.3.20. Does not exist
- 12.3.3.21. Is older than
- 12.3.3.22. Is older than fixed date
- 12.3.3.23. Is newer than
- 12.3.3.24. Is newer than fixed date
- 12.3.3.25. Is crawling
- 12.3.3.26. Is recrawling
- 12.3.3.27. Is first page
- 12.3.3.28. Is error
- 12.3.3.29. Is HTML error
- 12.3.3.30. Is request error
- 12.3.3.31. Exists (for errors)
- 12.3.3.32. Does not exist (for errors)
- 12.3.4. Action Commands
- 12.3.4.1. Assign
- 12.3.4.2. Clear
- 12.3.4.3. Find and replace
- 12.3.4.4. Make upper case
- 12.3.4.5. Make lower case
- 12.3.4.6. Make title case
- 12.3.4.7. Make snake case
- 12.3.4.8. Make kebab case
- 12.3.4.9. Make camel case
- 12.3.4.10. Make studly case
- 12.3.4.11. Make first letter upper case
- 12.3.4.12. Make slug
- 12.3.4.13. Limit words
- 12.3.4.14. Limit characters
- 12.3.4.15. Remove empty HTML elements
- 12.3.4.16. Remove links
- 12.3.4.17. Template
- 12.3.4.18. Exchange attributes
- 12.3.4.19. Remove
- 12.3.4.20. Remove attributes
- 12.3.4.21. Remove data attributes
- 12.3.4.22. Simplify
- 12.3.4.23. Clone
- 12.3.4.24. Create
- 12.3.4.25. Move
- 12.3.4.26. Unwrap
- 12.3.4.27. Calculate
- 12.3.4.28. Add minutes
- 12.3.4.29. Set to fixed date
- 12.3.4.30. Set to now
- 12.3.4.31. Set scheduling
- 12.3.4.32. Set recrawling
- 12.3.4.33. Set post deleting
- 12.3.4.34. Send email notification
- 12.3.4.35. Stop
- 12.3.4.36. Stop and delete the post
- 12.3.4.37. Wait
- 12.3.4.38. Set author
- 12.3.4.39. Set featured image
- 12.3.4.40. Set post status
- 12.3.4.41. Add tags
- 12.3.4.42. Add categories
- 12.3.4.43. Field template
- 12.3.4.44. Translate
- 12.3.4.45. Add post URLs
- 12.3.4.46. Translate element attributes
- 12.3.4.47. Convert to HTML
- 12.3.4.48. Convert to HTML automatically
- 12.3.4.49. Make
- 12.3.4.50. Remove