Last active
May 27, 2025 10:20
-
-
Save ihslimn/ac83d4c2bb51b85a0fb3d3051d5ee0d2 to your computer and use it in GitHub Desktop.
JetSmartFilters Extend Search
This file contains hidden or 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 | |
| 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