This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Instance of the batch processing job. | |
$job = MyBatchJob(); | |
// How many failed attempts do you want to process. | |
$batch_max_attempts = 3; | |
add_action( 'action_scheduler_failed_execution', 'maybe_retry_failed_batch' ); | |
add_action( 'action_scheduler_failed_action', 'maybe_retry_failed_batch' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// @link https://searchwp.com/v3/docs/kb/using-elementor-for-supplemental-engines/ | |
// We need to flag the search form. | |
add_action( 'elementor_pro/search_form/after_input', function( $form ) { | |
// Check to see if this is the right Search Form. | |
$settings = $form->get_data( 'settings' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Tell SearchWP to exclude password protected results. | |
add_filter( 'searchwp\query\mods', function( $mods ) { | |
global $wpdb; | |
$mod = new \SearchWP\Mod(); | |
$mod->set_local_table( $wpdb->posts ); | |
$mod->on( 'ID', [ 'column' => 'id' ] ); | |
$mod->raw_where_sql( function( $runtime ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Execute a search using our supplemental SearchWP Engine. | |
$search_query = isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : null; | |
$search_results = []; | |
if ( ! empty( $search_query ) && class_exists( '\\SearchWP\\Query' ) ) { | |
$searchwp_query = new \SearchWP\Query( $search_query, [ | |
'engine' => 'supplemental', // The Engine name. | |
'fields' => 'all', // Load proper native objects of each result. | |
] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Override SearchWP's "Did you mean?" output. | |
class MySearchwpDidYouMean { | |
private $args; | |
function __construct() { | |
// Prevent SearchWP's automatic "Did you mean?" output. | |
add_filter( 'searchwp_auto_output_revised_search_query', '__return_false' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: SearchWP Customizations | |
Plugin URI: | |
Description: | |
Version: | |
Author: Jonathan Christopher | |
Author URI: | |
License: | |
License URI: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Customize SearchWP stopwords per Engine. | |
*/ | |
// Optional: remove all Stopwords so you can add only unique Stopwords per Engine. | |
add_filter( 'searchwp\stopwords', '__return_empty_array' ); | |
// Add unique stopword(s) for a single SearchWP Engine. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Force multiple word searches to use quoted search logic if quotes are not added. | |
// NOTE: Quoted search must be enabled (checkbox on the Advanced tab) | |
add_filter( | |
'searchwp\query\search_string', | |
function( $search_string, $query ) { | |
// If there are already quotes, bail out. | |
if ( false !== strpos( $search_string, '"' ) ) { | |
return $search_string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Prevents JetSmartFilters from overriding SearchWP's results. | |
// @link https://searchwp.com/v3/docs/kb/compatibility-with-jetsmartfilters-for-elementor/ | |
add_action( 'init', function() { | |
add_filter( 'elementor/theme/posts_archive/query_posts/query_vars', function( $query ) { | |
if ( is_search() && is_main_query() ) { | |
remove_all_filters( 'elementor/theme/posts_archive/query_posts/query_vars' ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Integrate SearchWP with JetSmartFilters search using | |
// JetEngine Listing Grid to display results. | |
add_action( 'pre_get_posts', function( $wp_query ) { | |
if ( | |
! isset( $wp_query->query['jet_smart_filters' ] ) | |
|| empty( $wp_query->query['s'] ) | |
) { | |
return; |
NewerOlder