Make WordPress Core

Changeset 31223

Timestamp:
01/17/2015 01:36:55 AM (10 years ago)
Author:
azaozz
Message:

Add support for IE conditional comments for WP_Scripts to match the functionality of WP_Styles, including unit tests. Props filosofo, aaroncampbell, ethitter, georgestephanis, valendesigns. Fixes #16024.

Location:
trunk
Files:
3 edited

Legend:

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

    r31189 r31223  
    9696            $this->in_footer = array_diff( $this->in_footer, (array) $handle );
    9797
    98         if ( null === $this->registered[$handle]->ver )
     98        $obj = $this->registered[$handle];
     99
     100        if ( null === $obj->ver ) {
    99101            $ver = '';
    100         else
    101             $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
     102        } else {
     103            $ver = $obj->ver ? $obj->ver : $this->default_version;
     104        }
    102105
    103106        if ( isset($this->args[$handle]) )
    104107            $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle];
    105108
    106         $src = $this->registered[$handle]->src;
     109        $src = $obj->src;
     110        $cond_before = $cond_after = '';
     111        $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
     112
     113        if ( $conditional ) {
     114            $cond_before = "<!--[if {$conditional}]>\n";
     115            $cond_after = "<![endif]-->\n";
     116        }
    107117
    108118        if ( $this->do_concat ) {
     
    116126             */
    117127            $srce = apply_filters( 'script_loader_src', $src, $handle );
    118             if ( $this->in_default_dir($srce) ) {
     128            if ( $this->in_default_dir( ) {
    119129                $this->print_code .= $this->print_extra_script( $handle, false );
    120130                $this->concat .= "$handle,";
     
    127137        }
    128138
     139
     140
     141
     142
     143
     144
    129145        $this->print_extra_script( $handle );
    130         if ( !preg_match('|^(https?:)?//|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
     146
     147        if ( $has_conditional_data ) {
     148            echo $cond_after;
     149        }
     150
     151        if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) ) ) {
    131152            $src = $this->base_url . $src;
    132153        }
    133154
    134         if ( !empty($ver) )
    135             $src = add_query_arg('ver', $ver, $src);
     155        if ( !) )
     156            $src = add_query_arg();
    136157
    137158        /** This filter is documented in wp-includes/class.wp-scripts.php */
     
    141162            return true;
    142163
    143         $tag = "<script type='text/javascript' src='$src'></script>\n";
     164        $tag = "";
    144165
    145166        /**
  • trunk/src/wp-includes/functions.wp-scripts.php

    r31202 r31223  
    272272    return (bool) wp_scripts()->query( $handle, $list );
    273273}
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
  • trunk/tests/phpunit/tests/dependencies/scripts.php

    r30517 r31223  
    8585        $wp_scripts->base_url = $base_url_backup;
    8686    }
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
    87122}
Note: See TracChangeset for help on using the changeset viewer.