Make WordPress Core

Ticket #42804: 42804-update1.patch

File 42804-update1.patch, 6.2 KB (added by sasiddiqui, 7 years ago)
  • wp-includes/class.wp-scripts.php

     
    123123        public $default_dirs;
    124124
    125125        /**
     126         * Holds a string which contains the type attribute for script If
     127         * HTML5 support is available then it is initializes as empty string.
     128         *
     129         * @since 4.9.2
     130         * @var string
     131         */
     132        private $type_attr = " type='text/javascript'";
     133
     134        /**
    126135         * Constructor.
    127136         *
    128137         * @since 2.6.0
     
    130139        public function __construct() {
    131140                $this->init();
    132141                add_action( 'init', array( $this, 'init' ), 0 );
     142
     143                if ( current_theme_supports( 'html5', 'script' ) ) {
     144                        $this->type_attr = '';
     145                }
    133146        }
    134147
    135148        /**
     
    204217                        return $output;
    205218                }
    206219
    207                 echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5
     220                echo "<script{$this->type_attr}>\n"; // CDATA and type='text/javascript' is not needed for HTML 5
    208221                echo "/* <![CDATA[ */\n";
    209222                echo "$output\n";
    210223                echo "/* ]]> */\n";
     
    264277                $after_handle  = $this->print_inline_script( $handle, 'after', false );
    265278
    266279                if ( $before_handle ) {
    267                         $before_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $before_handle );
     280                        $before_handle = sprintf( "<script%s>\n%s\n</script>\n", $this->type_attr, $before_handle );
    268281                }
    269282
    270283                if ( $after_handle ) {
    271                         $after_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $after_handle );
     284                        $after_handle = sprintf( "<script%s>\n%s\n</script>\n", $this->type_attr, $after_handle );
    272285                }
    273286
    274287                if ( $this->do_concat ) {
     
    331344                        return true;
    332345                }
    333346
    334                 $tag = "{$cond_before}{$before_handle}<script type='text/javascript' src='$src'></script>\n{$after_handle}{$cond_after}";
     347                $tag = "{$cond_before}{$before_handle}<script{$this->type_attr} src='$src'></script>\n{$after_handle}{$cond_after}";
    335348
    336349                /**
    337350                 * Filters the HTML script tag of an enqueued script.
     
    401414                $output = trim( implode( "\n", $output ), "\n" );
    402415
    403416                if ( $echo ) {
    404                         printf( "<script type='text/javascript'>\n%s\n</script>\n", $output );
     417                        printf( "<script%s>\n%s\n</script>\n", $this->type_attr, $output );
    405418                }
    406419
    407420                return $output;
  • wp-includes/class.wp-styles.php

     
    101101        public $default_dirs;
    102102
    103103        /**
     104         * Holds a string which contains the type attribute for style If
     105         * HTML5 support is available then it is initializes as empty string.
     106         *
     107         * @since 4.9.2
     108         * @var string
     109         */
     110        private $type_attr = " type='text/css'";
     111
     112        /**
    104113         * Constructor.
    105114         *
    106115         * @since 2.6.0
     
    114123                 * @param WP_Styles $this WP_Styles instance (passed by reference).
    115124                 */
    116125                do_action_ref_array( 'wp_default_styles', array( &$this ) );
     126
     127                if ( current_theme_supports( 'html5', 'style' ) ) {
     128                        $this->type_attr = '';
     129                }
    117130        }
    118131
    119132        /**
     
    162175                // A single item may alias a set of items, by having dependencies, but no source.
    163176                if ( ! $obj->src ) {
    164177                        if ( $inline_style = $this->print_inline_style( $handle, false ) ) {
    165                                 $inline_style = sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style );
     178                                $inline_style = sprintf( "<style id='%s-inline-css'%s>\n%s\n</style>\n", esc_attr( $handle ), $this->type_attr, $inline_style );
    166179                                if ( $this->do_concat ) {
    167180                                        $this->print_html .= $inline_style;
    168181                                } else {
     
    221234                        $this->print_html .= $conditional_pre;
    222235                        $this->print_html .= $tag;
    223236                        if ( $inline_style = $this->print_inline_style( $handle, false ) ) {
    224                                 $this->print_html .= sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style );
     237                                $this->print_html .= sprintf( "<style id='%s-inline-css'%s>\n%s\n</style>\n", esc_attr( $handle ), $this->type_attr, $inline_style );
    225238                        }
    226239                        $this->print_html .= $conditional_post;
    227240                } else {
     
    281294                        return $output;
    282295                }
    283296
    284                 printf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $output );
     297                printf( "<style id='%s-inline-css'%s>\n%s\n</style>\n", esc_attr( $handle ), $this->type_attr, $output );
    285298
    286299                return true;
    287300        }
  • wp-includes/embed.php

     
    877877 * @since 4.4.0
    878878 */
    879879function print_embed_styles() {
     880        $type_attr = " type='text/css'";
     881        if ( current_theme_supports( 'html5', 'style' ) ) {
     882                $type_attr = '';
     883        }
    880884        ?>
    881         <style type="text/css">
     885        <style<?php echo $type_attr; ?>>
    882886        <?php
    883887        if ( SCRIPT_DEBUG ) {
    884888                readfile( ABSPATH . WPINC . '/css/wp-embed-template.css' );
  • wp-includes/formatting.php

     
    52715271        }
    52725272
    52735273        $printed = true;
     5274
     5275        $type_attr = " type='text/css'";
     5276        if ( current_theme_supports( 'html5', 'style' ) ) {
     5277                $type_attr = '';
     5278        }
    52745279?>
    5275 <style type="text/css">
     5280<style<?php echo $type_attr; ?>>
    52765281img.wp-smiley,
    52775282img.emoji {
    52785283        display: inline !important;
  • wp-includes/widgets/class-wp-widget-recent-comments.php

     
    5353                        || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) {
    5454                        return;
    5555                }
    56                 ?>
    57                 <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>
    58                 <?php
     56                if ( current_theme_supports( 'html5', 'style' ) ) {
     57                        echo "<style>.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>";
     58                } else {
     59                        echo "<style type='text/css'>.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>";
     60                }
    5961        }
    6062
    6163        /**