Thanks, now it is working.
Looks like I found the solution for you. Please use following code snippet
add_filter( 'aws_search_terms', 'my_aws_search_terms' );
function my_aws_search_terms( $terms ) {
$new_terms = array();
foreach ( $terms as $term ) {
$new_terms[] = aws_italian_singulars($term);
}
return $new_terms;
}
add_filter( 'aws_extracted_terms', 'my_aws_extracted_terms' );
function my_aws_extracted_terms( $terms ) {
$new_terms = array();
foreach( $terms as $str_item_term => $str_item_num ) {
$str_item_term_new = aws_italian_singulars($str_item_term);
$new_terms[$str_item_term_new] = $str_item_num;
}
return $new_terms;
}
function aws_italian_singulars( $term ) {
$patterns = array(
'/i$/i' => 'o',
'/e$/i' => 'a',
'/chi$/i' => 'co',
'/ghi$/i' => 'go',
'/ci$/i' => 'ca',
'/gi$/i' => 'ga',
'/ie$/i' => 'io',
'/uomini$/i' => 'uomo',
'/dei$/i' => 'dio'
);
foreach ($patterns as $pattern => $replacement) {
if (preg_match($pattern, $term)) {
return preg_replace($pattern, $replacement, $term);
}
}
return $term;
}
You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.
Also, after adding this code, you need to re-index the plugin table.