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 Remove Arabic Diacritics | |
Description: Removes all kind of إعراب-signs as well as تشكيل-signs for the use of SearchWP Wordpress plugin. | |
Author: Gerald Drissner | |
Note: This is a fork and extension of https://gist.github.com/BrElio/bd84d8035278adf834b29ec5e1187567 and Relevannsi's code snippet regarding foreign languages. | |
Version: 1.0.0 | |
Last update: 2022-10-20 | |
*/ |
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 | |
// wpDataTables compatibility with SearchWP. Retrieve entire data table | |
// if the indexer is running (regardless of wpDataTables settings) to ensure | |
// all wpDataTables Shortcode content is indexed when parsing Shortcodes. | |
add_filter( 'wpdatatables_filter_table_metadata', function( $data, $table_id ) { | |
if ( did_action( 'searchwp\indexer\batch' ) ) { | |
$data->pagination = false; | |
$data->showAllRows = true; | |
$data->server_side = 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 | |
// Sort SearchWP WP_Post Results alphabetically by Title in ascending order. | |
add_filter( 'searchwp\query\mods', function( $mods ) { | |
$mod = new \SearchWP\Mod( \SearchWP\Utils::get_post_type_source_name( 'post' ) ); | |
$mod->order_by( function( $mod ) { | |
return $mod->get_local_table_alias() . '.post_title'; | |
}, 'ASC', 9 ); | |
$mods[] = $mod; |
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 | |
/** | |
* Search results are contained within a div.searchwp-live-search-results | |
* which you can style accordingly as you would any other element on your site | |
* | |
* Some base styles are output in wp_footer that do nothing but position the | |
* results container and apply a default transition, you can disable that by | |
* adding the following to your theme's functions.php: | |
* | |
* add_filter( 'searchwp_live_search_base_styles', '__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 | |
// Randomize SearchWP search results. | |
add_filter( 'searchwp\query\mods', function( $mods ) { | |
$mod = new \SearchWP\Mod(); | |
$mod->order_by( 'random', null, 1 ); | |
$mods[] = $mod; | |
return $mods; | |
} ); |
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 | |
// Limit SearchWP results to Posts and Pages. | |
add_filter( 'searchwp\query\mods', function( $mods, $query ) { | |
$mod = new \SearchWP\Mod(); | |
$mod->set_where( [ [ | |
'column' => 'source', | |
'value' => [ | |
\SearchWP\Utils::get_post_type_source_name( 'post' ), |
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 process shortcodes | |
add_filter( 'searchwp_do_shortcode', '__return_true' ); | |
// if the SearchWP indexer is running prevent returning the | |
// content between [searchwp_no_index] and [/searchwp_no_index] | |
function shortcode_searchwp_no_index( $atts, $content = null ) { | |
// if the searchwp_indexer_running action fired, the indexer is running so don't return anything | |
return did_action( 'searchwp_indexer_running' ) ? '' : $content; |
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/documentation/knowledge-base/add-woocommerce-product-variations-to-products/ | |
// When using SearchWP it's necessary to disable WooCommerce's insistance on | |
// automatically redirecting to a single search result without showing the | |
// search results page, when that happens this hook doesn't run! | |
// Willing to bet this can be edited to accommodate, tips are welcome! | |
add_filter( 'woocommerce_redirect_single_search_result', '__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 | |
//Add extra weight to specific post types | |
add_filter( 'searchwp\query\mods', function( $mods ) { | |
$source_extra_weight = [ | |
\SearchWP\Utils::get_post_type_source_name( 'post') => 100000, | |
\SearchWP\Utils::get_post_type_source_name( 'page') => 1000, | |
]; |
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' ); | |
// Grab the "Did you mean?" arguments to use later. |
NewerOlder