Skip to content

Instantly share code, notes, and snippets.

@nikola0203
Forked from gagimilicevic/functions.php
Created July 13, 2017 08:23
Show Gist options
  • Save nikola0203/20838c1a34db448b4fcbaac88280db39 to your computer and use it in GitHub Desktop.
Save nikola0203/20838c1a34db448b4fcbaac88280db39 to your computer and use it in GitHub Desktop.
Detect RTL on website
function wp_is_rtl( $locale = '' ) {
static $rtl_locales = array(
'ar' => 'Arabic',
'ary' => 'Moroccan Arabic',
'azb' => 'South Azerbaijani',
'fa_IR' => 'Persian',
'haz' => 'Hazaragi',
'he_IL' => 'Hebrew',
'ps' => 'Pashto',
'ug_CN' => 'Uighur',
);
if ( empty( $locale ) && function_exists( 'is_rtl' ) ) {
return is_rtl();
}
if ( empty( $locale ) ) {
$locale = get_locale();
}
return isset( $rtl_locales[$locale] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment