Make WordPress Core


Ignore:
Timestamp:
11/12/2013 09:18:45 PM (11 years ago)
Author:
nacin
Message:

Use CSSJanus via a Grunt task to generate right-to-left CSS.

RTL files are now created on build for core CSS files. These files replace the LTR file completely, rather than being in addition to the existing LTR file.

Benefits:

  • For the user: less CSS is served in RTL, less HTTP requests on the frontend, and less work for the browser.
  • For the core developer: Let the tools do the work.

Notes for core development:

  • The file generation task is grunt rtl.
  • grunt watch now handles generating RTL files in /build when a CSS file in /src is saved.
  • /src is now locked to LTR. RTL testing must occur via /build. When attempting to run an RTL text direction with /src, an admin notice will display.

Expect RTL bugs. Please report them.

props yoavf.
see #24977.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class.wp-styles.php

    r25786 r26107  
    6666        $title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : '';
    6767
    68         $end_cond = $tag = '';
    69         if ( isset($obj->extra['conditional']) && $obj->extra['conditional'] ) {
    70             $tag .= "<!--[if {$obj->extra['conditional']}]>\n";
    71             $end_cond = "<![endif]-->\n";
    72         }
    73 
    74         $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle );
     68        $tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle );
    7569        if ( 'rtl' === $this->text_direction && isset($obj->extra['rtl']) && $obj->extra['rtl'] ) {
    76             if ( is_bool( $obj->extra['rtl'] ) ) {
     70            if ( is_bool( $obj->extra['rtl'] ) || 'replace' === $obj->extra['rtl'] ) {
    7771                $suffix = isset( $obj->extra['suffix'] ) ? $obj->extra['suffix'] : '';
    7872                $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $obj->src , $ver, "$handle-rtl" ));
     
    8175            }
    8276
    83             $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle );
     77            $rtl_tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle );
     78
     79            if ( $obj->extra['rtl'] === 'replace' ) {
     80                $tag = $rtl_tag;
     81            } else {
     82                $tag .= $rtl_tag;
     83            }
    8484        }
    8585
    86         $tag .= $end_cond;
     86        if ( isset($obj->extra['conditional']) && $obj->extra['conditional'] ) {
     87            $tag = "<!--[if {$obj->extra['conditional']}]>\n" . $tag . "<![endif]-->\n";
     88        }
    8789
    8890        if ( $this->do_concat ) {
Note: See TracChangeset for help on using the changeset viewer.