wpfts_irules_after (Filter)
The wpfts_irules_after
filter in WP Fast Total Search allows developers to add their own indexing rules after custom rules defined through the plugin’s interface or other add-ons, and after the base rules. This provides the ability to modify or supplement the standard indexing process at the very last stage.
When to Use
This filter is useful when you need to add indexing rules that should be executed after all other rules. For example:
- Perform final processing of data collected by other rules.
- Add data to the index that depends on the results of other rules.
- Override or supplement existing rules.
Arguments
$irules_final
(array): An array of final indexing rules. Initially, this array is empty.
Return Value
$irules_final
(array): The modified array of indexing rules.
Example (Adding a Rule for Logging Indexed Data)
add_filter('wpfts_irules_after', 'add_logging_rule');
function add_logging_rule($irules_final) {
$irules_final[] = array(
'filter' => array(
0 => 'AND', // Filter condition (in this case - all posts)
'post_type' => 'post',
),
'actions' => array(
array(
'call' => 'log_indexed_data', // Call the logging function.
),
),
'ident' => 'logging_rule', // Unique rule identifier.
'name' => 'Logging Rule', // Rule name.
'description' => 'Logs the indexed data.', // Rule description.
'ver' => '1.0', // Rule version.
'defined_by' => 'My Plugin/Theme Name',
'ord' => 1000, // Execution order.
);
return $irules_final;
}
// Callback function
function log_indexed_data($chunks, $post, $props, $rule) {
// Log the indexed data.
error_log(print_r($chunks, true));
return $chunks;
}
Important Notes
- The
wpfts_irules_after
filter is called after all other filters for indexing rules. - Be cautious when overriding existing rules, as this can lead to unexpected consequences.
The wpfts_irules_after
filter provides developers with maximum flexibility in modifying the WP Fast Total Search indexing process. It allows adding custom rules that will be executed at the very end, making it possible to consider the results of other rules.