Make WordPress Core

Ticket #3136: rtl.diff

File rtl.diff, 3.6 KB (added by ryan, 19 years ago)

Support loading of locale specific CSS.

  • wp-includes/default-filters.php

     
    144144
    145145// Actions
    146146add_action('wp_head', 'rsd_link');
     147add_action('wp_head', 'locale_stylesheet');
    147148add_action('publish_future_post', 'wp_publish_post', 10, 1);
    148149add_action('wp_head', 'noindex', 1);
    149150add_action('wp_head', 'wp_print_scripts');
  • wp-includes/locale.php

     
    1212
    1313        var $meridiem;
    1414
     15        var $text_direction = '';
     16        var $locale_vars = array('text_direction');
     17
    1518        function init() {
    1619                // The Weekdays
    1720                $this->weekday[0] = __('Sunday');
     
    8386                $this->meridiem['pm'] = __('pm');
    8487                $this->meridiem['AM'] = __('AM');
    8588                $this->meridiem['PM'] = __('PM');
     89
     90                $this->_load_locale_data();
    8691        }
    8792
     93        function _load_locale_data() {
     94                $locale = get_locale();
     95                $locale_file = ABSPATH . "wp-includes/languages/$locale.php";
     96                if ( !file_exists($locale_file) )
     97                        return;
     98
     99                include($locale_file);
     100
     101                foreach ( $this->locale_vars as $var ) {
     102                        $this->$var = $$var;   
     103                }
     104        }
     105
    88106        function get_weekday($weekday_number) {
    89107                return $this->weekday[$weekday_number];
    90108        }
  • wp-includes/theme.php

     
    2525        return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
    2626}
    2727
     28function get_locale_stylesheet_uri() {
     29        global $wp_locale;
     30        $stylesheet_dir_uri = get_stylesheet_directory_uri();
     31        $dir = get_stylesheet_directory();
     32        $locale = get_locale();
     33        if ( file_exists("$dir/$locale.css") )
     34                $stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
     35        else if ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") )
     36                $stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
     37        else
     38                $stylesheet_uri = '';
     39        return apply_filters('locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
     40}
     41
    2842function get_template() {
    2943        return apply_filters('template', get_option('template'));
    3044}
     
    369383        require_once($file);
    370384}
    371385
     386function locale_stylesheet() {
     387        $stylesheet = get_locale_stylesheet_uri();
     388        if ( empty($stylesheet) )
     389                return;
     390        echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';
     391}
     392
    372393function validate_current_theme() {
    373394        // Don't validate during an install/upgrade.
    374395        if ( defined('WP_INSTALLING') )
  • wp-admin/admin-header.php

     
    1818<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
    1919<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
    2020<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     21<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
     22<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     23<?php endif; ?>
    2124<script type="text/javascript">
    2225//<![CDATA[
    2326function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}