mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-04 04:34:31 +00:00
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:
@@ -2465,11 +2465,12 @@ function _print_scripts() {
|
||||
$zip = 'gzip';
|
||||
}
|
||||
|
||||
$concat = trim( $wp_scripts->concat, ', ' );
|
||||
$concat = trim( $wp_scripts->concat, ', ' );
|
||||
$type_attr = current_theme_supports( 'html5', 'script' ) ? '' : " type='text/javascript'";
|
||||
|
||||
if ( $concat ) {
|
||||
if ( ! empty( $wp_scripts->print_code ) ) {
|
||||
echo "\n<script type='text/javascript'>\n";
|
||||
echo "\n<script{$type_attr}>\n";
|
||||
echo "/* <![CDATA[ */\n"; // not needed in HTML 5
|
||||
echo $wp_scripts->print_code;
|
||||
echo "/* ]]> */\n";
|
||||
@@ -2484,7 +2485,7 @@ function _print_scripts() {
|
||||
}
|
||||
|
||||
$src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version;
|
||||
echo "<script type='text/javascript' src='" . esc_attr( $src ) . "'></script>\n";
|
||||
echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n";
|
||||
}
|
||||
|
||||
if ( ! empty( $wp_scripts->print_html ) ) {
|
||||
@@ -2646,7 +2647,8 @@ function _print_styles() {
|
||||
$zip = 'gzip';
|
||||
}
|
||||
|
||||
$concat = trim( $wp_styles->concat, ', ' );
|
||||
$concat = trim( $wp_styles->concat, ', ' );
|
||||
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
|
||||
|
||||
if ( $concat ) {
|
||||
$dir = $wp_styles->text_direction;
|
||||
@@ -2660,10 +2662,10 @@ function _print_styles() {
|
||||
}
|
||||
|
||||
$href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver;
|
||||
echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "' type='text/css' media='all' />\n";
|
||||
echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n";
|
||||
|
||||
if ( ! empty( $wp_styles->print_code ) ) {
|
||||
echo "<style type='text/css'>\n";
|
||||
echo "<style{$type_attr}>\n";
|
||||
echo $wp_styles->print_code;
|
||||
echo "\n</style>\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user