12.7. 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.28 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.28 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.29 shows an action command. An action command performs an action, as its name suggests. The command shown in Fig. 12.29 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.28 and Fig. 12.29, 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.28, the command should work with an element’s value. Likewise, in Fig. 12.29, 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.28 as “if an element’s value exists” and the command in Fig. 12.29 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.28, 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.29, 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.7.1. Command Subjects
- 12.7.2. Subject Properties
- 12.7.2.1. Value
- 12.7.2.2. Character length
- 12.7.2.3. Word length
- 12.7.2.4. Numeric value
- 12.7.2.5. Element attribute value
- 12.7.2.6. Element numeric attribute value
- 12.7.2.7. Count
- 12.7.2.8. Attribute value
- 12.7.2.9. Numeric attribute value
- 12.7.2.10. HTML
- 12.7.2.11. Text
- 12.7.2.12. Numeric text
- 12.7.2.13. Tag name
- 12.7.2.14. Error
- 12.7.2.15. HTTP status code
- 12.7.3. Condition Commands
- 12.7.3.1. Greater than
- 12.7.3.2. Less than
- 12.7.3.3. Greater than or equal to
- 12.7.3.4. Less than or equal to
- 12.7.3.5. Equal to
- 12.7.3.6. Not equal to
- 12.7.3.7. Starts with
- 12.7.3.8. Does not start with
- 12.7.3.9. Ends with
- 12.7.3.10. Does not end with
- 12.7.3.11. Contains
- 12.7.3.12. Does not contain
- 12.7.3.13. Is uppercase
- 12.7.3.14. Is not uppercase
- 12.7.3.15. Is lowercase
- 12.7.3.16. Is not lowercase
- 12.7.3.17. Matches regex
- 12.7.3.18. Does not match regex
- 12.7.3.19. Exists
- 12.7.3.20. Does not exist
- 12.7.3.21. Is older than
- 12.7.3.22. Is older than fixed date
- 12.7.3.23. Is newer than
- 12.7.3.24. Is newer than fixed date
- 12.7.3.25. Is crawling
- 12.7.3.26. Is recrawling
- 12.7.3.27. Is first page
- 12.7.3.28. Is error
- 12.7.3.29. Is HTML error
- 12.7.3.30. Is request error
- 12.7.4. Action Commands
- 12.7.4.1. Clear
- 12.7.4.2. Find and replace
- 12.7.4.3. Make upper case
- 12.7.4.4. Make lower case
- 12.7.4.5. Make title case
- 12.7.4.6. Make snake case
- 12.7.4.7. Make kebab case
- 12.7.4.8. Make camel case
- 12.7.4.9. Make studly case
- 12.7.4.10. Make first letter upper case
- 12.7.4.11. Make slug
- 12.7.4.12. Limit words
- 12.7.4.13. Limit characters
- 12.7.4.14. Remove empty HTML elements
- 12.7.4.15. Remove links
- 12.7.4.16. Template
- 12.7.4.17. Exchange attributes
- 12.7.4.18. Remove
- 12.7.4.19. Remove attributes
- 12.7.4.20. Clone
- 12.7.4.21. Calculate
- 12.7.4.22. Send email notification
- 12.7.4.23. Stop
- 12.7.4.24. Stop and delete the post
- 12.7.4.25. Set author
- 12.7.4.26. Set featured image
- 12.7.4.27. Set post status
- 12.7.4.28. Add tags
- 12.7.4.29. Add categories