Created
December 28, 2023 21:47
-
-
Save andrasguseo/fb4641b0b07124963e10c40c4dfa9dfc to your computer and use it in GitHub Desktop.
TEC > Transform all single quotes and apostrophes to straight single quotes in 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 | |
/** | |
* Transform all single quotes and apostrophes to straight single quotes in search string. | |
* | |
* Usage: Add the snippet to your functions.php file or with a plugin like Code Snippets | |
* | |
* Plugins required: The Events Calendar | |
* Author: Andras Guseo | |
* Created: December 28, 2023 | |
*/ | |
function tec_search_filter_transform_single_quotes( $query ) { | |
// Bail if not search or on admin. | |
if ( ! $query->is_search || is_admin() ) { | |
return $query; | |
} | |
if ( $query->get( 'post_type' ) == 'tribe_events' ) { | |
$search_phrase = $query->get( 's' ); | |
$search_phrase = str_replace( [ "'", "‘", "’", "‛" ], "'", $search_phrase ); | |
$query->set( 's', $search_phrase ); | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment