<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[14360] trunk: Introduce is_rtl().</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/14360">14360</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-05-03 05:49:19 +0000 (Mon, 03 May 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 <a href="http://trac.wordpress.org/ticket/13206">#13206</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpcontentpluginshellophp">trunk/wp-content/plugins/hello.php</a></li>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
<li><a href="#trunkwpincludesgeneraltemplatephp">trunk/wp-includes/general-template.php</a></li>
<li><a href="#trunkwpincludesjstinymcewpmcehelpphp">trunk/wp-includes/js/tinymce/wp-mce-help.php</a></li>
<li><a href="#trunkwpincludeslocalephp">trunk/wp-includes/locale.php</a></li>
<li><a href="#trunkwpincludesmediaphp">trunk/wp-includes/media.php</a></li>
<li><a href="#trunkwpincludesposttemplatephp">trunk/wp-includes/post-template.php</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
<li><a href="#trunkwpincludesthemephp">trunk/wp-includes/theme.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpcontentpluginshellophp"></a>
<div class="modfile"><h4>Modified: trunk/wp-content/plugins/hello.php (14359 => 14360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-content/plugins/hello.php        2010-05-03 04:21:35 UTC (rev 14359)
+++ trunk/wp-content/plugins/hello.php        2010-05-03 05:49:19 UTC (rev 14360)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx"> // We need some CSS to position the paragraph
</span><span class="cx"> function dolly_css() {
</span><span class="cx">         // This makes sure that the posinioning is also good for right-to-left languages
</span><del>-        $x = ( 'rtl' == get_bloginfo( 'text_direction' ) ) ? 'left' : 'right';
</del><ins>+        $x = ( is_rtl() ) ? 'left' : 'right';
</ins><span class="cx"> 
</span><span class="cx">         echo &quot;
</span><span class="cx">         &lt;style type='text/css'&gt;
</span></span></pre></div>
<a id="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (14359 => 14360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2010-05-03 04:21:35 UTC (rev 14359)
+++ trunk/wp-includes/functions.php        2010-05-03 05:49:19 UTC (rev 14360)
</span><span class="lines">@@ -2605,8 +2605,6 @@
</span><span class="cx">  * @param string|array $args Optional arguements to control behaviour.
</span><span class="cx">  */
</span><span class="cx"> function _default_wp_die_handler( $message, $title = '', $args = array() ) {
</span><del>-        global $wp_locale;
-
</del><span class="cx">         $defaults = array( 'response' =&gt; 500 );
</span><span class="cx">         $r = wp_parse_args($args, $defaults);
</span><span class="cx"> 
</span><span class="lines">@@ -2661,7 +2659,7 @@
</span><span class="cx">         $text_direction = 'ltr';
</span><span class="cx">         if ( isset($r['text_direction']) &amp;&amp; 'rtl' == $r['text_direction'] )
</span><span class="cx">                 $text_direction = 'rtl';
</span><del>-        elseif ( isset($wp_locale ) &amp;&amp; 'rtl' == $wp_locale-&gt;text_direction )
</del><ins>+        elseif ( function_exists( 'is_rtl' ) &amp;&amp; is_rtl() )
</ins><span class="cx">                 $text_direction = 'rtl';
</span><span class="cx"> ?&gt;
</span><span class="cx"> &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
</span><span class="lines">@@ -2743,9 +2741,7 @@
</span><span class="cx">  * @return array Direction set for 'rtl', if needed by locale.
</span><span class="cx">  */
</span><span class="cx"> function _mce_set_direction( $input ) {
</span><del>-        global $wp_locale;
-
-        if ( 'rtl' == $wp_locale-&gt;text_direction ) {
</del><ins>+        if ( is_rtl() ) {
</ins><span class="cx">                 $input['directionality'] = 'rtl';
</span><span class="cx">                 $input['plugins'] .= ',directionality';
</span><span class="cx">                 $input['theme_advanced_buttons1'] .= ',ltr';
</span></span></pre></div>
<a id="trunkwpincludesgeneraltemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/general-template.php (14359 => 14360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/general-template.php        2010-05-03 04:21:35 UTC (rev 14359)
+++ trunk/wp-includes/general-template.php        2010-05-03 05:49:19 UTC (rev 14360)
</span><span class="lines">@@ -398,7 +398,7 @@
</span><span class="cx">         switch( $show ) {
</span><span class="cx">                 case 'home' : // DEPRECATED
</span><span class="cx">                 case 'siteurl' : // DEPRECATED
</span><del>-                        _deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The &lt;code&gt;%1$s&lt;/code&gt; option is deprecated for the family of &lt;code&gt;bloginfo()&lt;/code&gt; functions. Use the &lt;code&gt;%2$s&lt;/code&gt; option instead.'), $show, 'url' ) );
</del><ins>+                        _deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The &lt;code&gt;%s&lt;/code&gt; option is deprecated for the family of &lt;code&gt;bloginfo()&lt;/code&gt; functions.' ), $show ) . ' ' . sprintf( __( 'Use the &lt;code&gt;%s&lt;/code&gt; option instead.' ), 'url'  ) );
</ins><span class="cx">                 case 'url' :
</span><span class="cx">                         $output = home_url();
</span><span class="cx">                         break;
</span><span class="lines">@@ -458,11 +458,8 @@
</span><span class="cx">                         $output = str_replace('_', '-', $output);
</span><span class="cx">                         break;
</span><span class="cx">                 case 'text_direction':
</span><del>-                        global $wp_locale;
-                        if ( isset( $wp_locale ) )
-                                $output = $wp_locale-&gt;text_direction;
-                        else
-                                $output = 'ltr';
</del><ins>+                        //_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The &lt;code&gt;%s&lt;/code&gt; option is deprecated for the family of &lt;code&gt;bloginfo()&lt;/code&gt; functions.' ), $show ) . ' ' . sprintf( __( 'Use the &lt;code&gt;%s&lt;/code&gt; function instead.' ), 'is_rtl()'  ) );
+                        return function_exists( 'is_rtl' ) ? is_rtl() : 'ltr';
</ins><span class="cx">                         break;
</span><span class="cx">                 case 'name':
</span><span class="cx">                 default:
</span><span class="lines">@@ -1874,8 +1871,8 @@
</span><span class="cx">         $attributes = array();
</span><span class="cx">         $output = '';
</span><span class="cx"> 
</span><del>-        if ( $dir = get_bloginfo('text_direction') )
-                $attributes[] = &quot;dir=\&quot;$dir\&quot;&quot;;
</del><ins>+        if ( function_exists( 'is_rtl' ) )
+                $attributes[] = 'dir=&quot;' . ( is_rtl() ? 'rtl' : 'ltr' ) . '&quot;';
</ins><span class="cx"> 
</span><span class="cx">         if ( $lang = get_bloginfo('language') ) {
</span><span class="cx">                 if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
</span><span class="lines">@@ -2112,7 +2109,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         echo apply_filters( 'wp_admin_css', &quot;&lt;link rel='stylesheet' href='&quot; . wp_admin_css_uri( $file ) . &quot;' type='text/css' /&gt;\n&quot;, $file );
</span><del>-        if ( 'rtl' == get_bloginfo( 'text_direction' ) )
</del><ins>+        if ( is_rtl() )
</ins><span class="cx">                 echo apply_filters( 'wp_admin_css', &quot;&lt;link rel='stylesheet' href='&quot; . wp_admin_css_uri( &quot;$file-rtl&quot; ) . &quot;' type='text/css' /&gt;\n&quot;, &quot;$file-rtl&quot; );
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesjstinymcewpmcehelpphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/wp-mce-help.php (14359 => 14360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/wp-mce-help.php        2010-05-03 04:21:35 UTC (rev 14359)
+++ trunk/wp-includes/js/tinymce/wp-mce-help.php        2010-05-03 05:49:19 UTC (rev 14360)
</span><span class="lines">@@ -128,7 +128,7 @@
</span><span class="cx">                 border-bottom: 0px;
</span><span class="cx">         }
</span><span class="cx"> &lt;/style&gt;
</span><del>-&lt;?php if ( ('rtl' == $wp_locale-&gt;text_direction) ) : ?&gt;
</del><ins>+&lt;?php if ( is_rtl() ) : ?&gt;
</ins><span class="cx"> &lt;style type=&quot;text/css&quot;&gt;
</span><span class="cx">         #wphead, #tabs {
</span><span class="cx">                 padding-left: auto;
</span></span></pre></div>
<a id="trunkwpincludeslocalephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/locale.php (14359 => 14360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/locale.php        2010-05-03 04:21:35 UTC (rev 14359)
+++ trunk/wp-includes/locale.php        2010-05-03 05:49:19 UTC (rev 14360)
</span><span class="lines">@@ -326,6 +326,26 @@
</span><span class="cx">                 $this-&gt;init();
</span><span class="cx">                 $this-&gt;register_globals();
</span><span class="cx">         }
</span><ins>+        /**
+         * Checks if current locale is RTL.
+         *
+         * @since 3.0.0
+         * @return bool Whether locale is RTL.
+         */
+         function is_rtl() {
+                 return 'rtl' == $this-&gt;text_direction;
+         }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * 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-&gt;is_rtl();
+}
+
</ins><span class="cx"> ?&gt;
</span></span></pre></div>
<a id="trunkwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/media.php (14359 => 14360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/media.php        2010-05-03 04:21:35 UTC (rev 14359)
+++ trunk/wp-includes/media.php        2010-05-03 05:49:19 UTC (rev 14360)
</span><span class="lines">@@ -781,7 +781,7 @@
</span><span class="cx">         $captiontag = tag_escape($captiontag);
</span><span class="cx">         $columns = intval($columns);
</span><span class="cx">         $itemwidth = $columns &gt; 0 ? floor(100/$columns) : 100;
</span><del>-        $float = $wp_locale-&gt;text_direction == 'rtl' ? 'right' : 'left';
</del><ins>+        $float = is_rtl() ? 'right' : 'left';
</ins><span class="cx"> 
</span><span class="cx">         $selector = &quot;gallery-{$instance}&quot;;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesposttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post-template.php (14359 => 14360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-template.php        2010-05-03 04:21:35 UTC (rev 14359)
+++ trunk/wp-includes/post-template.php        2010-05-03 05:49:19 UTC (rev 14360)
</span><span class="lines">@@ -372,7 +372,7 @@
</span><span class="cx"> 
</span><span class="cx">         $classes = array();
</span><span class="cx"> 
</span><del>-        if ( 'rtl' == get_bloginfo( 'text_direction' ) )
</del><ins>+        if ( is_rtl() )
</ins><span class="cx">                 $classes[] = 'rtl';
</span><span class="cx"> 
</span><span class="cx">         if ( is_front_page() )
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (14359 => 14360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2010-05-03 04:21:35 UTC (rev 14359)
+++ trunk/wp-includes/script-loader.php        2010-05-03 05:49:19 UTC (rev 14360)
</span><span class="lines">@@ -433,7 +433,7 @@
</span><span class="cx">         $styles-&gt;base_url = $guessurl;
</span><span class="cx">         $styles-&gt;content_url = defined('WP_CONTENT_URL')? WP_CONTENT_URL : '';
</span><span class="cx">         $styles-&gt;default_version = get_bloginfo( 'version' );
</span><del>-        $styles-&gt;text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr';
</del><ins>+        $styles-&gt;text_direction = function_exists( 'is_rtl' ) &amp;&amp; is_rtl() ? 'rtl' : 'ltr';
</ins><span class="cx">         $styles-&gt;default_dirs = array('/wp-admin/');
</span><span class="cx"> 
</span><span class="cx">         $suffix = defined('SCRIPT_DEBUG') &amp;&amp; SCRIPT_DEBUG ? '.dev' : '';
</span></span></pre></div>
<a id="trunkwpincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme.php (14359 => 14360)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2010-05-03 04:21:35 UTC (rev 14359)
+++ trunk/wp-includes/theme.php        2010-05-03 05:49:19 UTC (rev 14360)
</span><span class="lines">@@ -1580,7 +1580,7 @@
</span><span class="cx">         global $editor_styles;
</span><span class="cx">         $editor_styles = (array) $editor_styles;
</span><span class="cx">         $stylesheet    = (array) $stylesheet;
</span><del>-        if ('rtl' == get_bloginfo('text_direction') ) {
</del><ins>+        if ( is_rtl() ) {
</ins><span class="cx">                 $rtl_stylesheet = str_replace('.css', '-rtl.css', $stylesheet[0]);
</span><span class="cx">                 $stylesheet[] = $rtl_stylesheet;
</span><span class="cx">         }
</span></span></pre>
</div>
</div>

</body>
</html>