Skip to content

Instantly share code, notes, and snippets.

@msaari
Created May 3, 2020 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msaari/cc0a3f3d4a810bb96eefdea49f7eff29 to your computer and use it in GitHub Desktop.
Save msaari/cc0a3f3d4a810bb96eefdea49f7eff29 to your computer and use it in GitHub Desktop.
Relevanssi Arabic support
<?php
add_filter( 'relevanssi_remove_punctuation', 'rlv_arabic_remap', 9 );
function rlv_arabic_remap( $a ) {
$remap = array(
'إ' => 'ا',
'آ' => 'ا',
'أ' => 'ا',
'ئ' => 'ى',
'ة' => 'ه',
'ؤ' => 'و',
'ـ' => '',
'آ' => 'ا',
);
$diacritics = array(
'~[\x{0600}-\x{061F}]~u',
'~[\x{063B}-\x{063F}]~u',
'~[\x{064B}-\x{065E}]~u',
'~[\x{066A}-\x{06FF}]~u',
);
$a = preg_replace( $diacritics, '', $a );
$a = str_replace( array_keys( $remap ), array_values( $remap ), $a );
return $a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment