Make WordPress Core

Changeset 14360


Ignore:
Timestamp:
05/03/2010 05:49:19 AM (16 years ago)
Author:
nacin
Message:

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.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/plugins/hello.php

    r13377 r14360  
    6363function dolly_css() {
    6464        // This makes sure that the posinioning is also good for right-to-left languages
    65         $x = ( 'rtl' == get_bloginfo( 'text_direction' ) ) ? 'left' : 'right';
     65        $x = ( is_rtl() ) ? 'left' : 'right';
    6666
    6767        echo "
  • trunk/wp-includes/functions.php

    r14344 r14360  
    26062606 */
    26072607function _default_wp_die_handler( $message, $title = '', $args = array() ) {
    2608         global $wp_locale;
    2609 
    26102608        $defaults = array( 'response' => 500 );
    26112609        $r = wp_parse_args($args, $defaults);
     
    26622660        if ( isset($r['text_direction']) && 'rtl' == $r['text_direction'] )
    26632661                $text_direction = 'rtl';
    2664         elseif ( isset($wp_locale ) && 'rtl' == $wp_locale->text_direction )
     2662        elseif ( function_exists( 'is_rtl' ) && is_rtl() )
    26652663                $text_direction = 'rtl';
    26662664?>
     
    27442742 */
    27452743function _mce_set_direction( $input ) {
    2746         global $wp_locale;
    2747 
    2748         if ( 'rtl' == $wp_locale->text_direction ) {
     2744        if ( is_rtl() ) {
    27492745                $input['directionality'] = 'rtl';
    27502746                $input['plugins'] .= ',directionality';
  • trunk/wp-includes/general-template.php

    r14347 r14360  
    399399                case 'home' : // DEPRECATED
    400400                case 'siteurl' : // DEPRECATED
    401                         _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' ) );
     401                        _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' ) );
    402402                case 'url' :
    403403                        $output = home_url();
     
    459459                        break;
    460460                case 'text_direction':
    461                         global $wp_locale;
    462                         if ( isset( $wp_locale ) )
    463                                 $output = $wp_locale->text_direction;
    464                         else
    465                                 $output = 'ltr';
     461                        //_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()'  ) );
     462                        return function_exists( 'is_rtl' ) ? is_rtl() : 'ltr';
    466463                        break;
    467464                case 'name':
     
    18751872        $output = '';
    18761873
    1877         if ( $dir = get_bloginfo('text_direction') )
    1878                 $attributes[] = "dir=\"$dir\"";
     1874        if ( function_exists( 'is_rtl' ) )
     1875                $attributes[] = 'dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"';
    18791876
    18801877        if ( $lang = get_bloginfo('language') ) {
     
    21132110
    21142111        echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . wp_admin_css_uri( $file ) . "' type='text/css' />\n", $file );
    2115         if ( 'rtl' == get_bloginfo( 'text_direction' ) )
     2112        if ( is_rtl() )
    21162113                echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . wp_admin_css_uri( "$file-rtl" ) . "' type='text/css' />\n", "$file-rtl" );
    21172114}
  • trunk/wp-includes/js/tinymce/wp-mce-help.php

    r12789 r14360  
    129129        }
    130130</style>
    131 <?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
     131<?php if ( is_rtl() ) : ?>
    132132<style type="text/css">
    133133        #wphead, #tabs {
  • trunk/wp-includes/locale.php

    r14190 r14360  
    327327                $this->register_globals();
    328328        }
     329        /**
     330         * Checks if current locale is RTL.
     331         *
     332         * @since 3.0.0
     333         * @return bool Whether locale is RTL.
     334         */
     335         function is_rtl() {
     336                return 'rtl' == $this->text_direction;
     337         }
    329338}
    330339
     340/**
     341 * Checks if current locale is RTL.
     342 *
     343 * @since 3.0.0
     344 * @return bool Whether locale is RTL.
     345 */
     346function is_rtl() {
     347        global $wp_locale;
     348        return $wp_locale->is_rtl();
     349}
     350
    331351?>
  • trunk/wp-includes/media.php

    r14151 r14360  
    782782        $columns = intval($columns);
    783783        $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
    784         $float = $wp_locale->text_direction == 'rtl' ? 'right' : 'left';
     784        $float = is_rtl() ? 'right' : 'left';
    785785
    786786        $selector = "gallery-{$instance}";
  • trunk/wp-includes/post-template.php

    r13861 r14360  
    373373        $classes = array();
    374374
    375         if ( 'rtl' == get_bloginfo( 'text_direction' ) )
     375        if ( is_rtl() )
    376376                $classes[] = 'rtl';
    377377
  • trunk/wp-includes/script-loader.php

    r14353 r14360  
    434434        $styles->content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
    435435        $styles->default_version = get_bloginfo( 'version' );
    436         $styles->text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr';
     436        $styles->text_direction = function_exists( 'is_rtl' ) && is_rtl() ? 'rtl' : 'ltr';
    437437        $styles->default_dirs = array('/wp-admin/');
    438438
  • trunk/wp-includes/theme.php

    r14276 r14360  
    15811581        $editor_styles = (array) $editor_styles;
    15821582        $stylesheet    = (array) $stylesheet;
    1583         if ('rtl' == get_bloginfo('text_direction') ) {
     1583        if ( is_rtl() ) {
    15841584                $rtl_stylesheet = str_replace('.css', '-rtl.css', $stylesheet[0]);
    15851585                $stylesheet[] = $rtl_stylesheet;
Note: See TracChangeset for help on using the changeset viewer.