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.

git-svn-id: https://develop.svn.wordpress.org/trunk@46164 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2019-09-18 14:49:30 +00:00
parent 0dbd752500
commit 5fdf48c0ec
13 changed files with 173 additions and 47 deletions

View File

@@ -5435,8 +5435,10 @@ function print_emoji_styles() {
}
$printed = true;
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
?>
<style type="text/css">
<style<?php echo $type_attr; ?>>
img.wp-smiley,
img.emoji {
display: inline !important;
@@ -5517,7 +5519,8 @@ function _print_emoji_detection_script() {
'svgExt' => apply_filters( 'emoji_svg_ext', '.svg' ),
);
$version = 'ver=' . get_bloginfo( 'version' );
$version = 'ver=' . get_bloginfo( 'version' );
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/javascript"';
if ( SCRIPT_DEBUG ) {
$settings['source'] = array(
@@ -5528,7 +5531,7 @@ function _print_emoji_detection_script() {
);
?>
<script type="text/javascript">
<script<?php echo $type_attr; ?>>
window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>;
<?php readfile( ABSPATH . WPINC . '/js/wp-emoji-loader.js' ); ?>
</script>
@@ -5550,7 +5553,7 @@ function _print_emoji_detection_script() {
* and edit wp-emoji-loader.js directly.
*/
?>
<script type="text/javascript">
<script<?php echo $type_attr; ?>>
window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>;
include "js/wp-emoji-loader.min.js"
</script>