Last active
February 26, 2017 04:10
-
-
Save msaari/b6ae63960ce683c0aa3b8cdf23dfc43b to your computer and use it in GitHub Desktop.
Relevanssi part number checker
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
function rlv_is_a_pn($candidate) { | |
$array = str_split($candidate); | |
$has_letters = false; | |
$has_numbers = false; | |
foreach ($array as $letter) { | |
if (is_numeric($letter)) { | |
$has_numbers = true; | |
} | |
else { | |
$has_letters = true; | |
} | |
if ($has_numbers && $has_letters) return true; | |
} | |
return $false; | |
} | |
add_filter('relevanssi_remove_punctuation', 'cut_search_to_6', 11); | |
function cut_search_to_6($a) { | |
if (rlv_is_a_pn($a)) { | |
$a = substr($a, 0, 6); | |
} | |
return $a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment