Introduce is_rtl(). Use it in core. It only becomes defined when locale is loaded, so it's impossible to use it too early. Deprecate the get_bloginfo('text_direction') call. fixes #13206.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2764e19bc5
commit
4d7c88f4a4
|
@ -62,7 +62,7 @@ add_action('admin_footer', 'hello_dolly');
|
||||||
// We need some CSS to position the paragraph
|
// We need some CSS to position the paragraph
|
||||||
function dolly_css() {
|
function dolly_css() {
|
||||||
// This makes sure that the posinioning is also good for right-to-left languages
|
// This makes sure that the posinioning is also good for right-to-left languages
|
||||||
$x = ( 'rtl' == get_bloginfo( 'text_direction' ) ) ? 'left' : 'right';
|
$x = ( is_rtl() ) ? 'left' : 'right';
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
<style type='text/css'>
|
<style type='text/css'>
|
||||||
|
|
|
@ -2605,8 +2605,6 @@ function wp_die( $message, $title = '', $args = array() ) {
|
||||||
* @param string|array $args Optional arguements to control behaviour.
|
* @param string|array $args Optional arguements to control behaviour.
|
||||||
*/
|
*/
|
||||||
function _default_wp_die_handler( $message, $title = '', $args = array() ) {
|
function _default_wp_die_handler( $message, $title = '', $args = array() ) {
|
||||||
global $wp_locale;
|
|
||||||
|
|
||||||
$defaults = array( 'response' => 500 );
|
$defaults = array( 'response' => 500 );
|
||||||
$r = wp_parse_args($args, $defaults);
|
$r = wp_parse_args($args, $defaults);
|
||||||
|
|
||||||
|
@ -2661,7 +2659,7 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) {
|
||||||
$text_direction = 'ltr';
|
$text_direction = 'ltr';
|
||||||
if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
|
if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
|
||||||
$text_direction = 'rtl';
|
$text_direction = 'rtl';
|
||||||
elseif ( isset($wp_locale ) && 'rtl' == $wp_locale->text_direction )
|
elseif ( function_exists( 'is_rtl' ) && is_rtl() )
|
||||||
$text_direction = 'rtl';
|
$text_direction = 'rtl';
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
@ -2743,9 +2741,7 @@ function _config_wp_siteurl( $url = '' ) {
|
||||||
* @return array Direction set for 'rtl', if needed by locale.
|
* @return array Direction set for 'rtl', if needed by locale.
|
||||||
*/
|
*/
|
||||||
function _mce_set_direction( $input ) {
|
function _mce_set_direction( $input ) {
|
||||||
global $wp_locale;
|
if ( is_rtl() ) {
|
||||||
|
|
||||||
if ( 'rtl' == $wp_locale->text_direction ) {
|
|
||||||
$input['directionality'] = 'rtl';
|
$input['directionality'] = 'rtl';
|
||||||
$input['plugins'] .= ',directionality';
|
$input['plugins'] .= ',directionality';
|
||||||
$input['theme_advanced_buttons1'] .= ',ltr';
|
$input['theme_advanced_buttons1'] .= ',ltr';
|
||||||
|
|
|
@ -398,7 +398,7 @@ function get_bloginfo( $show = '', $filter = 'raw' ) {
|
||||||
switch( $show ) {
|
switch( $show ) {
|
||||||
case 'home' : // DEPRECATED
|
case 'home' : // DEPRECATED
|
||||||
case 'siteurl' : // DEPRECATED
|
case 'siteurl' : // DEPRECATED
|
||||||
_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%1$s</code> option is deprecated for the family of <code>bloginfo()</code> functions. Use the <code>%2$s</code> option instead.'), $show, 'url' ) );
|
_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> option instead.' ), 'url' ) );
|
||||||
case 'url' :
|
case 'url' :
|
||||||
$output = home_url();
|
$output = home_url();
|
||||||
break;
|
break;
|
||||||
|
@ -458,11 +458,8 @@ function get_bloginfo( $show = '', $filter = 'raw' ) {
|
||||||
$output = str_replace('_', '-', $output);
|
$output = str_replace('_', '-', $output);
|
||||||
break;
|
break;
|
||||||
case 'text_direction':
|
case 'text_direction':
|
||||||
global $wp_locale;
|
//_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> function instead.' ), 'is_rtl()' ) );
|
||||||
if ( isset( $wp_locale ) )
|
return function_exists( 'is_rtl' ) ? is_rtl() : 'ltr';
|
||||||
$output = $wp_locale->text_direction;
|
|
||||||
else
|
|
||||||
$output = 'ltr';
|
|
||||||
break;
|
break;
|
||||||
case 'name':
|
case 'name':
|
||||||
default:
|
default:
|
||||||
|
@ -1874,8 +1871,8 @@ function language_attributes($doctype = 'html') {
|
||||||
$attributes = array();
|
$attributes = array();
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
if ( $dir = get_bloginfo('text_direction') )
|
if ( function_exists( 'is_rtl' ) )
|
||||||
$attributes[] = "dir=\"$dir\"";
|
$attributes[] = 'dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"';
|
||||||
|
|
||||||
if ( $lang = get_bloginfo('language') ) {
|
if ( $lang = get_bloginfo('language') ) {
|
||||||
if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
|
if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
|
||||||
|
@ -2112,7 +2109,7 @@ function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . wp_admin_css_uri( $file ) . "' type='text/css' />\n", $file );
|
echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . wp_admin_css_uri( $file ) . "' type='text/css' />\n", $file );
|
||||||
if ( 'rtl' == get_bloginfo( 'text_direction' ) )
|
if ( is_rtl() )
|
||||||
echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . wp_admin_css_uri( "$file-rtl" ) . "' type='text/css' />\n", "$file-rtl" );
|
echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . wp_admin_css_uri( "$file-rtl" ) . "' type='text/css' />\n", "$file-rtl" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ wp_admin_css( 'wp-admin', true );
|
||||||
border-bottom: 0px;
|
border-bottom: 0px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
|
<?php if ( is_rtl() ) : ?>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#wphead, #tabs {
|
#wphead, #tabs {
|
||||||
padding-left: auto;
|
padding-left: auto;
|
||||||
|
|
|
@ -326,6 +326,26 @@ class WP_Locale {
|
||||||
$this->init();
|
$this->init();
|
||||||
$this->register_globals();
|
$this->register_globals();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Checks if current locale is RTL.
|
||||||
|
*
|
||||||
|
* @since 3.0.0
|
||||||
|
* @return bool Whether locale is RTL.
|
||||||
|
*/
|
||||||
|
function is_rtl() {
|
||||||
|
return 'rtl' == $this->text_direction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if current locale is RTL.
|
||||||
|
*
|
||||||
|
* @since 3.0.0
|
||||||
|
* @return bool Whether locale is RTL.
|
||||||
|
*/
|
||||||
|
function is_rtl() {
|
||||||
|
global $wp_locale;
|
||||||
|
return $wp_locale->is_rtl();
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -781,7 +781,7 @@ function gallery_shortcode($attr) {
|
||||||
$captiontag = tag_escape($captiontag);
|
$captiontag = tag_escape($captiontag);
|
||||||
$columns = intval($columns);
|
$columns = intval($columns);
|
||||||
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
|
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
|
||||||
$float = $wp_locale->text_direction == 'rtl' ? 'right' : 'left';
|
$float = is_rtl() ? 'right' : 'left';
|
||||||
|
|
||||||
$selector = "gallery-{$instance}";
|
$selector = "gallery-{$instance}";
|
||||||
|
|
||||||
|
|
|
@ -372,7 +372,7 @@ function get_body_class( $class = '' ) {
|
||||||
|
|
||||||
$classes = array();
|
$classes = array();
|
||||||
|
|
||||||
if ( 'rtl' == get_bloginfo( 'text_direction' ) )
|
if ( is_rtl() )
|
||||||
$classes[] = 'rtl';
|
$classes[] = 'rtl';
|
||||||
|
|
||||||
if ( is_front_page() )
|
if ( is_front_page() )
|
||||||
|
|
|
@ -433,7 +433,7 @@ function wp_default_styles( &$styles ) {
|
||||||
$styles->base_url = $guessurl;
|
$styles->base_url = $guessurl;
|
||||||
$styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
|
$styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
|
||||||
$styles->default_version = get_bloginfo( 'version' );
|
$styles->default_version = get_bloginfo( 'version' );
|
||||||
$styles->text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr';
|
$styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
|
||||||
$styles->default_dirs = array('/wp-admin/');
|
$styles->default_dirs = array('/wp-admin/');
|
||||||
|
|
||||||
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
|
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
|
||||||
|
|
|
@ -1580,7 +1580,7 @@ function add_editor_style( $stylesheet = 'editor-style.css' ) {
|
||||||
global $editor_styles;
|
global $editor_styles;
|
||||||
$editor_styles = (array) $editor_styles;
|
$editor_styles = (array) $editor_styles;
|
||||||
$stylesheet = (array) $stylesheet;
|
$stylesheet = (array) $stylesheet;
|
||||||
if ('rtl' == get_bloginfo('text_direction') ) {
|
if ( is_rtl() ) {
|
||||||
$rtl_stylesheet = str_replace('.css', '-rtl.css', $stylesheet[0]);
|
$rtl_stylesheet = str_replace('.css', '-rtl.css', $stylesheet[0]);
|
||||||
$stylesheet[] = $rtl_stylesheet;
|
$stylesheet[] = $rtl_stylesheet;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue