12.3.2. Subject Properties

A property simply defines what part of the subject you want. There are many properties that can be selected in Property select. The available properties are given below.

Important

Not all the properties are available for all the subjects. The plugin will display the properties that are suitable for the selected subject.

12.3.2.1. Value

This property uses the subject’s value directly. Selecting this is the same as not selecting a property at all.

12.3.2.2. Character length

This property counts the number of characters in the selected subject’s value.

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.2.3. Word length

This property counts the number of words in the selected subject’s value.

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.2.4. Numeric value

This property parses the selected subject’s value to a number so that you can use the commands that can work with numbers. If the subject value is not numeric, this property will skip its value. For example, if one of the post’s tags is numeric, and you select this property, then only the one numeric tag will be used by the command.

12.3.2.5. Element attribute value

This property parses the subject into an HTML document and retrieves the value of the specified elements’ specified attributes.

Options
Selectors:Define the CSS selectors that find the target elements in the subject’s value.
Attribute name:Enter the name of the attribute whose value will be retrieved from the HTML elements found by the specified CSS selectors.

12.3.2.6. Element numeric attribute value

This property does the same thing as Element attribute value and then parses the value into a number, so that you can use the commands that work with the numbers. For this to work, the value of the specified elements’ specified attribute must be a number.

Options
Selectors:Define the CSS selectors that find the target elements in the subject’s value.
Attribute name:Enter the name of the attribute whose value will be retrieved from the HTML elements found by the specified CSS selectors.

12.3.2.7. Count

This property counts the number of items in the specified subject. For example, if the subject is post tags, and there 20 post tags, then the property’s value is 20.

12.3.2.8. Attribute value

This is available for the element subject only. This retrieves the value of the specified attribute of the subject element.

Options
Attribute name:Enter the name of the attribute whose value will be retrieved from the HTML elements found by the specified CSS selectors.
Create attribute?:
 Check this if the attribute value should be considered as empty text in case that the attribute does not exist.

12.3.2.9. Numeric attribute value

This is available for the element subject only. This property does the same thing as Attribute value and then parses the value into a number, so that you can use the commands that work with the numbers. For this to work, the value of the specified elements’ specified attribute must be a number.

Options
Attribute name:Enter the name of the attribute whose value will be retrieved from the HTML elements found by the specified CSS selectors.

12.3.2.10. HTML

This is available for the element subject only. This retrieves the HTML code of the specified elements.

12.3.2.11. Text

This is available for the element subject only. This retrieves the text inside the specified elements. For example, if the element’s HTML is

<div class="item">This is a text.</div>

Then the output of this property will be This is a text..

12.3.2.12. Numeric text

This is available for the element subject only. This does the same thing as Text and then parses the value into a number, so that you can use the commands that work with the numbers. For this to work, the value of the specified elements’ text must be a number.

12.3.2.13. Tag name

This is available for the element subject only. This retrieves the specified elements’ tag name. For example, if the specified element is <span>Item</span>, then the tag name is span.

12.3.2.14. Attribute value as JSON

This is available for the element subject only. This retrieves the value of an element’s attribute and parses it as JSON. By this way, you can work on the JSON data. For example, you can convert the JSON data to HTML. Basically, if an element’s attribute contains JSON data that you want to retrieve data from, you can use this attribute.

Options
Attribute name:Enter the name of the attribute whose value will be retrieved from the HTML elements found by the specified CSS selectors.

12.3.2.15. Text as JSON

This is available for the element subject only. This retrieves the text of an element and parses it as JSON. By this way, you can work on the JSON data. For example, you can convert the JSON data to HTML. Basically, if an element’s text contains JSON data that you want to retrieve data from, you can use this attribute.

12.3.2.16. JSON attribute’s text value

This is available for the element subject only. This property is used to extract a text value from JSON data that is stored in an attribute or text of an element. By this way, you can use text-related commands, such as checking the length of the text or whether it contains a certain keyword or not.

Options
Attribute name:Enter the name of the attribute whose value will be retrieved from the HTML elements found by the specified CSS selectors. You can enter text to retrieve the text of the element.
JSON path:Enter the path to the JSON field that stores the desired value. See JSON path for more information.

12.3.2.17. JSON attribute’s numeric value

This is available for the element subject only. This property is used to extract a numeric value from JSON data that is stored in an attribute or text of an element. By this way, you can use number-related commands, such as checking if it is greater than a number.

Options
Attribute name:Enter the name of the attribute whose value will be retrieved from the HTML elements found by the specified CSS selectors. You can enter text to retrieve the text of the element.
JSON path:Enter the path to the JSON field that stores the desired value. See JSON path for more information.

12.3.2.18. JSON attribute’s date value

This is available for the element subject only. This property is used to extract a date value from JSON data that is stored in an attribute or text of an element. By this way, you can use date-related commands, such as checking if the date is older than another date.

Options
Attribute name:Enter the name of the attribute whose value will be retrieved from the HTML elements found by the specified CSS selectors. You can enter text to retrieve the text of the element.
JSON path:Enter the path to the JSON field that stores the desired value. See JSON path for more information.

12.3.2.19. Error

This is available for the request subject only. This retrieves the error from a request, if there is any.

12.3.2.20. HTTP status code

This is available for the request subject only. This retrieves the HTTP status code from the response of the request made to the target web page. For example, 404 is for not-found pages. Please note that the target web page might not be sending a standard status code. For example, instead of sending 404 response code for a not-found page, the target web page may choose to redirect the page to another, non-related page and send 200 response. Which status code the target site sends depends on the target site.

12.3.2.21. Error text

This is available for the Error subjects only. This retrieves the error’s text content. The text content includes the error message and the exception stack trace, if there was an exception that caused the error. Additionally, if there are any details about the error, they will be in the error text as well. The error text is actually the same text that is added to WordPress’s debug.log file by the plugin. So, you can check out your debug.log file to understand what is in the error text. Once you know what is in the error text, you can use this property to do certain things when a specific error occurs.

Here is an example error text, which is for an OpenAI API error:

WPCC (error): Completion cannot be retrieved. [Prompt: "Say hi"] (Details: Client error: `POST https://api.openai.com/v1/completions` resulted in a `401 Unauthorized` response:
{
    "error": {
        "message": "Incorrect API key provided: 1-DUMMY-***-KEY. You can find your API key at https://p (truncated...)
)
(Exception: #0 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/guzzle/src/Middleware.php(72): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), NULL, Array, NULL)
#1 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/promises/src/Promise.php(209): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/promises/src/Promise.php(158): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
#3 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Promise\TaskQueue->run(true)
#5 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn()
#6 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending()
#7 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList()
#8 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Promise\Promise->wait()
#10 /var/www/html/wp-content/plugins/wp-content-crawler/app/vendor/guzzlehttp/guzzle/src/ClientTrait.php(95): GuzzleHttp\Client->request('POST', 'completions', Array)
#11 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/Api/OpenAi/OpenAiClient.php(293): GuzzleHttp\Client->post('completions', Array)
#12 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/Api/OpenAi/ShortCode/OpenAiGptShortCode.php(743): WPCCrawler\Objects\Api\OpenAi\OpenAiClient->postCompletion('text-ada-001', 'Say hi', 1, NULL, NULL)
#13 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/Api/OpenAi/ShortCode/OpenAiGptShortCode.php(582): WPCCrawler\Objects\Api\OpenAi\ShortCode\OpenAiGptShortCode->applyCompletion()
#14 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/Api/OpenAi/ShortCode/OpenAiGptShortCode.php(563): WPCCrawler\Objects\Api\OpenAi\ShortCode\OpenAiGptShortCode->onApply()
#15 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/Api/OpenAi/ShortCode/OpenAiGptShortCodeApplier.php(74): WPCCrawler\Objects\Api\OpenAi\ShortCode\OpenAiGptShortCode->apply()
#16 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/Api/OpenAi/ShortCode/OpenAiGptShortCodeApplier.php(43): WPCCrawler\Objects\Api\OpenAi\ShortCode\OpenAiGptShortCodeApplier->applySingle(Array)
#17 [internal function]: WPCCrawler\Objects\Api\OpenAi\ShortCode\OpenAiGptShortCodeApplier->WPCCrawler\Objects\Api\OpenAi\ShortCode\{closure}(Array)
#18 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/ShortCode/ShortCodeUtils.php(85): preg_replace_callback('/\\[(\\[?)(openai...', Object(Closure), '[openai-gpt des...')
#19 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/ShortCode/AbstractCustomShortCodeApplier.php(138): WPCCrawler\Objects\ShortCode\ShortCodeUtils->applyWithCallback('openai-gpt', '[openai-gpt des...', Object(Closure))
#20 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/Api/OpenAi/ShortCode/OpenAiGptShortCodeApplier.php(44): WPCCrawler\Objects\ShortCode\AbstractCustomShortCodeApplier->doApplyWithCallback('[openai-gpt des...', Object(Closure))
#21 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/ShortCode/AbstractCustomShortCodeApplier.php(39): WPCCrawler\Objects\Api\OpenAi\ShortCode\OpenAiGptShortCodeApplier->onApply('[openai-gpt des...')
#22 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/ShortCode/ShortCodeApplier.php(415): WPCCrawler\Objects\ShortCode\AbstractCustomShortCodeApplier->apply('[openai-gpt des...')
#23 /var/www/html/wp-content/plugins/wp-content-crawler/app/Objects/ShortCode/ShortCodeApplier.php(211): WPCCrawler\Objects\ShortCode\ShortCodeApplier->maybeApplyCustomAppliers('[openai-gpt des...')
#24 /var/www/html/wp-content/plugins/wp-content-crawler/app/Test/Tests/OpenAiGptShortCodeTest.php(78): WPCCrawler\Objects\ShortCode\ShortCodeApplier->apply('[openai-gpt des...')
#25 /var/www/html/wp-content/plugins/wp-content-crawler/app/Test/Base/AbstractTest.php(114): WPCCrawler\Test\Tests\OpenAiGptShortCodeTest->createResults(Object(WPCCrawler\Test\Data\TestData))
#26 /var/www/html/wp-content/plugins/wp-content-crawler/app/Test/Test.php(197): WPCCrawler\Test\Base\AbstractTest->run()
#27 /var/www/html/wp-content/plugins/wp-content-crawler/app/Services/PostService.php(146): WPCCrawler\Test\Test::respondToTestRequest(Array)
#28 /var/www/html/wp-includes/class-wp-hook.php(324): WPCCrawler\Services\PostService->WPCCrawler\Services\{closure}('')
#29 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#30 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#31 /var/www/html/wp-admin/admin-ajax.php(192): do_action('wp_ajax_wcc_tes...')
#32 {main})