WordPress.org

Make WordPress Core

Ticket #16024: 16024.6.diff

File 16024.6.diff, 4.6 KB (added by azaozz, 5 years ago)
  • src/wp-content/themes/twentytwelve/functions.php

     
    133133        global $wp_styles;
    134134
    135135        /*
     136         * Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions.
     137         */
     138        wp_enqueue_script( 'twentytwelve-html5', get_template_directory_uri() . '/js/html5.js', array(), '1.0' );
     139        wp_script_add_data( 'twentytwelve-html5', 'conditional', 'lt IE 9' );
     140
     141        /*
    136142         * Adds JavaScript to pages with the comment form to support
    137143         * sites with threaded comments (when in use).
    138144         */
     
    151157
    152158        // Loads the Internet Explorer specific stylesheet.
    153159        wp_enqueue_style( 'twentytwelve-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentytwelve-style' ), '20121010' );
    154         $wp_styles->add_data( 'twentytwelve-ie', 'conditional', 'lt IE 9' );
     160        wp_style_add_data( 'twentytwelve-ie', 'conditional', 'lt IE 9' );
    155161}
    156162add_action( 'wp_enqueue_scripts', 'twentytwelve_scripts_styles' );
    157163
  • src/wp-content/themes/twentytwelve/header.php

     
    2424<title><?php wp_title( '|', true, 'right' ); ?></title>
    2525<link rel="profile" href="http://gmpg.org/xfn/11" />
    2626<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    27 <?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
    28 <!--[if lt IE 9]>
    29 <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
    30 <![endif]-->
    3127<?php wp_head(); ?>
    3228</head>
    3329
  • src/wp-includes/class.wp-scripts.php

     
    9595                if ( false === $group && in_array($handle, $this->in_footer, true) )
    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 = '';
    100102                else
    101                         $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
     103                        $ver = $obj->ver ? $obj->ver : $this->default_version;
    102104
    103105                if ( isset($this->args[$handle]) )
    104106                        $ver = $ver ? $ver . '&amp;' . $this->args[$handle] : $this->args[$handle];
    105107
    106                 $src = $this->registered[$handle]->src;
     108                $src = $obj->src;
     109                $cond_before = $cond_after = '';
     110                $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : '';
    107111
     112                if ( $conditional ) {
     113                        $cond_before = "<!--[if {$conditional}]>\n";
     114                        $cond_after = "\n<![endif]-->";
     115                }
     116
    108117                if ( $this->do_concat ) {
    109118                        /**
    110119                         * Filter the script loader source.
     
    115124                         * @param string $handle Script handle.
    116125                         */
    117126                        $srce = apply_filters( 'script_loader_src', $src, $handle );
    118                         if ( $this->in_default_dir($srce) ) {
     127                        if ( $this->in_default_dir( $srce ) && ! $conditional ) {
    119128                                $this->print_code .= $this->print_extra_script( $handle, false );
    120129                                $this->concat .= "$handle,";
    121130                                $this->concat_version .= "$handle$ver";
     
    140149                if ( ! $src )
    141150                        return true;
    142151
    143                 $tag = "<script type='text/javascript' src='$src'></script>\n";
     152                $tag = "{$cond_before}<script type='text/javascript' src='$src'></script>{$cond_after}\n";
    144153
    145154                /**
    146155                 * Filter the HTML script tag of an enqueued script.
  • src/wp-includes/functions.wp-scripts.php

     
    258258
    259259        return (bool) $wp_scripts->query( $handle, $list );
    260260}
     261
     262
     263/**
     264 * Add metadata to a script.
     265 *
     266 * Works only if the script has already been added.
     267 *
     268 * Possible values for $key and $value:
     269 * 'conditional' string Comments for IE 6, lte IE 7, etc.
     270 *
     271 * @see WP_Dependency::add_data()
     272 *
     273 * @since 4.2.0
     274 *
     275 * @param string $handle Name of the script.
     276 * @param string $key    Name of data point for which we're storing a value.
     277 * @param mixed  $value  String containing the data to be added.
     278 * @return bool True on success, false on failure.
     279 */
     280function wp_script_add_data( $handle, $key, $value ){
     281        global $wp_scripts;
     282        return $wp_scripts->add_data( $handle, $key, $value );
     283}