This guide is all about the WordPress actions and WordPress filters (also name hooks) available in the plugin.
Each action or filter is detailed in its own document, with:
- Name
- Schematic
- Parameters
- Description
- php code to call it
- php code to catch it
- php code to use it
General
All actions and filters are defined as constants, in the class WpSolrFilters, in the file /wpsolr-search -engine/classes/wpsolr-filters.php.
We recommend that you use the constant, rather than it’s string value.
For instance, in your php code, use
use wpsolr\core\classes\WPSOLR_Events;
WPSOLR_Events::WPSOLR_FILTER_POST_CUSTOM_FIELDS
rather than
'wpsolr_filter_post_custom_fields'
Your declaration of the hook containing a reference to the php class WPSOLR_Events, it must be executed after the WPSOLR plugin is loaded.
For instance, in:
use wpsolr\core\classes\WPSOLR_Events; if ( defined( 'WPSOLR_PLUGIN_SHORT_NAME' ) ) { add_action( 'after_setup_theme', function () { ... declare your WPSOLR actions or filters here } ); }
or in
use wpsolr\core\classes\WPSOLR_Events; if ( defined( 'WPSOLR_PLUGIN_SHORT_NAME' ) ) { add_action( 'admin_init', function () { ... declare your WPSOLR actions or filters here } ); }