php - How to strip/replace a slanted double quotes ″ with " in wordpress search query?
I'm trying to replace slanted double quotes ″ with regular double quotes " in wordpress (woocomerce) search query because the first example returns no products.
Example search:
CUBE ACID SIC PURE 28″ RILink (no results)
CUBE ACID SIC PURE 28" RILink (correct result)
I tried to replace the ″ characted with this code usingget_search_query
filter:
add_filter('get_search_query', 'my_search_query');
function my_search_query( $s ) {
$characters = '″'; // Replace this
$replace_with = '"'; // with this
if ( is_array($s) ) {
if ( isset($s['s']) && !$s['_ajax_search'] )
$s['s'] = str_replace(str_split($characters), $replace_with, $s['s']);
} else {
$s = str_replace(str_split($characters), $replace_with, $s);
}
return $s;
}
but that only changed the search results text to CUBE ACID SIC PURE 28""" RILink and the search query url stayed the same ?s=CUBE+ACID+SIC+PURE+28″+RILink&post_type=product with the incorrect double quote character.
What is the correct way to replace quotes in search query url so the search returns results as expected?