WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/18/2019 02:49:30 PM (8 months ago)
Author:
SergeyBiryukov
Message:

Script Loader: Introduce HTML5 support for scripts and styles.

When a theme declares HTML5 support for script and styles via add_theme_support( 'html5', array( 'script', 'style' ) ), the type="text/javascript" and type="text/css" attributes are omitted.

These attributes are unnecessary in HTML5 and cause warnings in the W3C Markup Validation Service.

Props sasiddiqui, swissspidy, knutsp, SergeyBiryukov.
See #42804.

File:
1 edited

Legend:

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

    r46128 r46164  
    54365436
    54375437    $printed = true;
     5438
     5439    $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
    54385440    ?>
    5439 <style type="text/css">
     5441<style<?php echo $type_attr; ?>>
    54405442img.wp-smiley,
    54415443img.emoji {
     
    55185520    );
    55195521
    5520     $version = 'ver=' . get_bloginfo( 'version' );
     5522    $version   = 'ver=' . get_bloginfo( 'version' );
     5523    $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/javascript"';
    55215524
    55225525    if ( SCRIPT_DEBUG ) {
     
    55295532
    55305533        ?>
    5531         <script type="text/javascript">
     5534        <script<?php echo $type_attr; ?>>
    55325535            window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>;
    55335536            <?php readfile( ABSPATH . WPINC . '/js/wp-emoji-loader.js' ); ?>
     
    55515554         */
    55525555        ?>
    5553         <script type="text/javascript">
     5556        <script<?php echo $type_attr; ?>>
    55545557            window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>;
    55555558            include "js/wp-emoji-loader.min.js"
Note: See TracChangeset for help on using the changeset viewer.