fbpx

Actions and Filters (Hooks)

2589 views October 11, 2016 June 21, 2019 admin 1

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;

add_action( 'after_setup_theme', function () {
... declare your WPSOLR actions or filters here
} );

or in


use wpsolr\core\classes\WPSOLR_Events;

add_action( 'admin_init', function () {
... declare your WPSOLR actions or filters here
} );

Was this helpful?

Join Our weekly Newsletter

Receive our latest news once a week, each Thursday afternoon.
Your email is kept 100% private, and you will not receive other stuff in your mailbox.

We keep your data private and share your data only with third parties that make this service possible. Read our Privacy Policy.