Skip to content

Instantly share code, notes, and snippets.

@ihslimn
Last active May 27, 2025 10:20
Show Gist options
  • Select an option

  • Save ihslimn/ac83d4c2bb51b85a0fb3d3051d5ee0d2 to your computer and use it in GitHub Desktop.

Select an option

Save ihslimn/ac83d4c2bb51b85a0fb3d3051d5ee0d2 to your computer and use it in GitHub Desktop.
JetSmartFilters Extend Search
<?php
class JSF_Extend_Search {
public function __construct() {
add_filter( 'jet-smart-filters/query/request', array( $this, 'modify_request' ), 0, 2 );
}
public function modify_request( $request, $manager ) {
$ajax = $manager->is_ajax_filter();
if ( $ajax ) {
$data = isset( $request['query'] ) ? $request['query'] : array();
} else {
$data = $request;
}
foreach ( $data as $key => $value ) {
if ( false !== strpos( $key, '|search' ) ) {
$value = str_replace( ' ', '%', $value );
$data[ $key ] = $value;
}
}
if ( $ajax ) {
$request['query'] = $data;
} else {
$request = $data;
}
return $request;
}
}
new JSF_Extend_Search();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment