WordPress.org

Make WordPress Core

Ticket #16024: 16024.2.diff

File 16024.2.diff, 1.5 KB (added by aaroncampbell, 4 years ago)

Conditionals that play nice with concat

  • wp-includes/class.wp-scripts.php

     
    100100 
    101101                $src = $this->registered[$handle]->src; 
    102102 
    103                 if ( $this->do_concat ) { 
     103                if ( $this->do_concat && ( !isset($this->registered[$handle]->extra['conditional']) || !$this->registered[$handle]->extra['conditional'] ) ) { 
    104104                        $srce = apply_filters( 'script_loader_src', $src, $handle ); 
    105105                        if ( $this->in_default_dir($srce) ) { 
    106106                                $this->print_code .= $this->print_scripts_l10n( $handle, false ); 
     
    122122                        $src = add_query_arg('ver', $ver, $src); 
    123123                $src = esc_url(apply_filters( 'script_loader_src', $src, $handle )); 
    124124 
    125                 if ( $this->do_concat ) 
     125                if ( $this->do_concat && ( !isset($this->registered[$handle]->extra['conditional']) || !$this->registered[$handle]->extra['conditional'] ) ) { 
    126126                        $this->print_html .= "<script type='text/javascript' src='$src'></script>\n"; 
    127                 else 
    128                         echo "<script type='text/javascript' src='$src'></script>\n"; 
     127                } else { 
     128                        $start_cond = $end_cond = ''; 
     129                        if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) { 
     130                                $start_cond = "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n"; 
     131                                $end_cond = "<![endif]-->\n"; 
     132                        } 
     133                        echo "{$start_cond}<script type='text/javascript' src='$src'></script>\n{$end_cond}"; 
     134                } 
    129135 
    130136                return true; 
    131137        }