wpfts_index_post_start (Action)

The wpfts_index_post_start hook in WP Fast Total Search is called at the very beginning of the process of indexing a single post. This happens before the plugin starts extracting data from the post for addition to the index.

When Used

This hook can be useful for performing the following actions:

  • Initializing variables or resources needed to process post data before indexing.
  • Performing preliminary checks and deciding whether to index the given post.
  • Modifying the $post object before data extraction.
  • Logging or debugging the indexing process.

Arguments

  • $wpfts_core (object): The plugin core object WPFTS_Core. Provides access to all plugin methods and properties.
  • $post (object): The WP_Post object representing the post being indexed.
  • $is_refresh_raw_cache (bool): A flag indicating whether a forced refresh of the post’s raw data cache is being performed.

Return Value

  • The wpfts_index_post_start hook should not return any value.

Example

/**
 * Sets a flag for debugging the indexing of specific posts.
 */
add_action('wpfts_index_post_start', 'my_wpfts_index_post_start_handler', 10, 3);
function my_wpfts_index_post_start_handler($wpfts_core, $post, $is_refresh_raw_cache) {
 
    if ($post->ID == 123) { // Post ID for which to enable debugging.
        $wpfts_core->_dev_debug = true; // Enables debug mode in the plugin core.
	}
}

Important Notes

  • Changes made to the $post object inside the handler of this hook may affect the further indexing process.
  • This hook is called for each indexed post, so the code inside the handler should be efficient to avoid slowing down the indexing process.

The wpfts_index_post_start hook provides developers with an entry point at the very beginning of post indexing, allowing them to perform necessary actions before data extraction.