Created
April 16, 2019 17:35
-
-
Save jas8522/72aacf1e0a8c2b2f6d3a821bc8bf19b8 to your computer and use it in GitHub Desktop.
woof by_text extention modification to support plurals and re-ordering of words
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
if (isset($WOOF->settings['by_text']['search_by_full_word'])) { | |
$search_by_full_word = (int) $WOOF->settings['by_text']['search_by_full_word']; | |
} | |
/* | |
if ($search_by_full_word) { | |
$woof_text = '[[:<:]]' . $woof_text . '[[:>:]]'; | |
} | |
*/ | |
/** ADDED APR 1, 2019 by websavers (+above comment out) **/ | |
/* Handle Plurals */ | |
if (!$search_by_full_word) { /* trimming "s" chars only works if search by full word is disabled */ | |
$text_array = explode(' ', $woof_text); //make array | |
foreach($text_array as &$text ){ | |
$text = rtrim($text, 's'); | |
} | |
$woof_text = implode(' ', $text_array); | |
} | |
/* Handle order of words returning diff results */ | |
$text_array = explode(" ", $woof_text); | |
$woof_t = str_replace(' ', '|', $woof_text); | |
$woof_text=""; | |
foreach($text_array as $text ){ | |
if ($search_by_full_word) { | |
$woof_text.= '([[:<:]]'.$woof_t . '[[:>:]])+(.*)'; | |
} | |
else{ | |
$woof_text.= '('.$woof_t . ')+(.*)'; | |
} | |
} | |
/** END CHANGES APR 1, 2019 **/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment