Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter to remove search weighting engine #2522

Merged
merged 8 commits into from
Jan 7, 2022
Prev Previous commit
Next Next commit
Add filter to Weighting class instead
  • Loading branch information
rebeccahum committed Jan 4, 2022
commit 5707fe1bedbb1c48851e6b6ddaf15aeb4420dfb4
8 changes: 3 additions & 5 deletions includes/classes/Feature/Search/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ public function setup() {
add_action( 'init', [ $this, 'search_setup' ] );
add_filter( 'ep_sanitize_feature_settings', [ $this, 'sanitize_highlighting_settings' ] );

if ( apply_filters( 'ep_load_search_weighting', true ) ) {
// Set up weighting sub-module
$this->weighting = new Weighting();
$this->weighting->setup();
}
// Set up weighting sub-module
$this->weighting = new Weighting();
$this->weighting->setup();

$this->synonyms = new Synonyms();
$this->synonyms->setup();
Expand Down
12 changes: 12 additions & 0 deletions includes/classes/Feature/Search/Weighting.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ class Weighting {
* Sets up the weighting module
*/
public function setup() {
/**
* Filter to disable loading of Search weighting engine.
*
* @hook ep_disable_search_weighting
* @since 4.0
* @param bool Whether to disable search weighting engine. Defaults to false.
* @return bool Whether to disable search weighting engine.
*/
if ( apply_filters( 'ep_disable_search_weighting', false ) ) {
return;
}

add_action( 'admin_menu', [ $this, 'add_weighting_submenu_page' ], 15 );
add_action( 'admin_post_ep-weighting', [ $this, 'handle_save' ] );
add_filter( 'ep_formatted_args', [ $this, 'do_weighting' ], 20, 2 ); // After date decay, etc are injected
Expand Down