diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php
index c16ffc99a1..19d668c633 100644
--- a/src/wp-includes/admin-bar.php
+++ b/src/wp-includes/admin-bar.php
@@ -1117,8 +1117,9 @@ function wp_admin_bar_add_secondary_groups( $wp_admin_bar ) {
* @since 3.1.0
*/
function wp_admin_bar_header() {
+ $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
?>
-
+
-\n", esc_attr( $handle ), $inline_style );
+ $inline_style_tag = sprintf(
+ "\n",
+ esc_attr( $handle ),
+ $this->type_attr,
+ $inline_style
+ );
} else {
$inline_style_tag = '';
}
@@ -197,9 +217,17 @@ class WP_Styles extends WP_Dependencies {
}
$rel = isset( $obj->extra['alt'] ) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
- $title = isset( $obj->extra['title'] ) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : '';
+ $title = isset( $obj->extra['title'] ) ? sprintf( "title='%s'", esc_attr( $obj->extra['title'] ) ) : '';
- $tag = "\n";
+ $tag = sprintf(
+ "\n",
+ $rel,
+ $handle,
+ $title,
+ $href,
+ $this->type_attr,
+ $media
+ );
/**
* Filters the HTML link tag of an enqueued style.
@@ -223,7 +251,16 @@ class WP_Styles extends WP_Dependencies {
$rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" );
}
- $rtl_tag = "\n";
+ $rtl_tag = sprintf(
+ "\n",
+ $rel,
+ $handle,
+ $title,
+ $rtl_href,
+ $this->type_attr,
+ $media
+ );
+
/** This filter is documented in wp-includes/class.wp-styles.php */
$rtl_tag = apply_filters( 'style_loader_tag', $rtl_tag, $handle, $rtl_href, $media );
@@ -298,7 +335,12 @@ class WP_Styles extends WP_Dependencies {
return $output;
}
- printf( "\n", esc_attr( $handle ), $output );
+ printf(
+ "\n",
+ esc_attr( $handle ),
+ $this->type_attr,
+ $output
+ );
return true;
}
diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php
index 2872c29bdd..4301a4ef46 100644
--- a/src/wp-includes/embed.php
+++ b/src/wp-includes/embed.php
@@ -1000,8 +1000,9 @@ function enqueue_embed_scripts() {
* @since 4.4.0
*/
function print_embed_styles() {
+ $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
?>
- \n";
}
diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php
index 730ff902d6..e4cc8802f5 100644
--- a/src/wp-includes/theme.php
+++ b/src/wp-includes/theme.php
@@ -702,7 +702,14 @@ function locale_stylesheet() {
if ( empty( $stylesheet ) ) {
return;
}
- echo '';
+
+ $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
+
+ printf(
+ '',
+ $stylesheet,
+ $type_attr
+ );
}
/**
@@ -1641,7 +1648,8 @@ function _custom_background_cb() {
if ( ! $background && ! $color ) {
if ( is_customize_preview() ) {
- echo '';
+ $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
+ printf( '', $type_attr );
}
return;
}
@@ -1693,9 +1701,11 @@ function _custom_background_cb() {
$attachment = " background-attachment: $attachment;";
$style .= $image . $position . $size . $repeat . $attachment;
+
+ $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
}
?>
-
}
function wp_custom_css_cb() {
$styles = wp_get_custom_css();
if ( $styles || is_customize_preview() ) :
+ $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
?>
-
-
- .recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}',
+ $type_attr
+ );
}
/**
diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php
index f0638a7176..d55b41b01b 100644
--- a/tests/phpunit/tests/dependencies/scripts.php
+++ b/tests/phpunit/tests/dependencies/scripts.php
@@ -44,6 +44,7 @@ JS;
wp_enqueue_script( 'empty-deps-no-version', 'example.com' );
wp_enqueue_script( 'empty-deps-version', 'example.com', array(), 1.2 );
wp_enqueue_script( 'empty-deps-null-version', 'example.com', array(), null );
+
$ver = get_bloginfo( 'version' );
$expected = "\n";
$expected .= "\n";
@@ -56,6 +57,23 @@ JS;
$this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
}
+ /**
+ * @ticket 42804
+ */
+ function test_wp_enqueue_script_with_html5_support_does_not_contain_type_attribute() {
+ add_theme_support( 'html5', array( 'script' ) );
+
+ $GLOBALS['wp_scripts'] = new WP_Scripts();
+ $GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' );
+
+ wp_enqueue_script( 'empty-deps-no-version', 'example.com' );
+
+ $ver = get_bloginfo( 'version' );
+ $expected = "\n";
+
+ $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
+ }
+
/**
* Test the different protocol references in wp_enqueue_script
*
diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php
index 30ed7799ce..3908ed7af8 100644
--- a/tests/phpunit/tests/dependencies/styles.php
+++ b/tests/phpunit/tests/dependencies/styles.php
@@ -56,6 +56,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
wp_enqueue_style( 'no-deps-version', 'example.com', array(), 1.2 );
wp_enqueue_style( 'no-deps-null-version', 'example.com', array(), null );
wp_enqueue_style( 'no-deps-null-version-print-media', 'example.com', array(), null, 'print' );
+
$ver = get_bloginfo( 'version' );
$expected = "\n";
$expected .= "\n";
@@ -68,6 +69,23 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
$this->assertEquals( '', get_echo( 'wp_print_styles' ) );
}
+ /**
+ * @ticket 42804
+ */
+ function test_wp_enqueue_style_with_html5_support_does_not_contain_type_attribute() {
+ add_theme_support( 'html5', array( 'style' ) );
+
+ $GLOBALS['wp_styles'] = new WP_Styles();
+ $GLOBALS['wp_styles']->default_version = get_bloginfo( 'version' );
+
+ wp_enqueue_style( 'no-deps-no-version', 'example.com' );
+
+ $ver = get_bloginfo( 'version' );
+ $expected = "\n";
+
+ $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
+ }
+
/**
* Test the different protocol references in wp_enqueue_style
*