Skip to content

Instantly share code, notes, and snippets.

@gagimilicevic
Created July 7, 2017 09:53
Show Gist options
  • Save gagimilicevic/d76173fac39c9c26ee61208f71bc0adf to your computer and use it in GitHub Desktop.
Save gagimilicevic/d76173fac39c9c26ee61208f71bc0adf 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