Changeset 46164
- Timestamp:
- 09/18/2019 02:49:30 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/admin-bar.php
r45932 r46164 1118 1118 */ 1119 1119 function wp_admin_bar_header() { 1120 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 1120 1121 ?> 1121 <style type="text/css"media="print">#wpadminbar { display:none; }</style>1122 <style<?php echo $type_attr; ?> media="print">#wpadminbar { display:none; }</style> 1122 1123 <?php 1123 1124 } … … 1129 1130 */ 1130 1131 function _admin_bar_bump_cb() { 1131 1132 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 1132 1133 ?> 1133 <style type="text/css"media="screen">1134 <style<?php echo $type_attr; ?> media="screen"> 1134 1135 html { margin-top: 32px !important; } 1135 1136 * html body { margin-top: 32px !important; } -
trunk/src/wp-includes/class.wp-scripts.php
r45590 r46164 124 124 125 125 /** 126 * Holds a string which contains the type attribute for script tag. 127 * 128 * If the current theme does not declare HTML5 support for 'script', 129 * then it initializes as `type='text/javascript'`. 130 * 131 * @since 5.3.0 132 * @var string 133 */ 134 private $type_attr = ''; 135 136 /** 126 137 * Constructor. 127 138 * … … 131 142 $this->init(); 132 143 add_action( 'init', array( $this, 'init' ), 0 ); 144 145 if ( ! current_theme_supports( 'html5', 'script' ) ) { 146 $this->type_attr = " type='text/javascript'"; 147 } 133 148 } 134 149 … … 206 221 } 207 222 208 echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript'is not needed for HTML 5.223 echo "<script{$this->type_attr}>\n"; // CDATA and type="text/javascript" is not needed for HTML 5. 209 224 echo "/* <![CDATA[ */\n"; 210 225 echo "$output\n"; … … 267 282 268 283 if ( $before_handle ) { 269 $before_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $before_handle );284 $before_handle = sprintf( "<script%s>\n%s\n</script>\n", $this->type_attr, $before_handle ); 270 285 } 271 286 272 287 if ( $after_handle ) { 273 $after_handle = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $after_handle );288 $after_handle = sprintf( "<script%s>\n%s\n</script>\n", $this->type_attr, $after_handle ); 274 289 } 275 290 276 291 if ( $before_handle || $after_handle ) { 277 $inline_script_tag = "{$cond_before}{$before_handle}{$after_handle}{$cond_after}";292 $inline_script_tag = $cond_before . $before_handle . $after_handle . $cond_after; 278 293 } else { 279 294 $inline_script_tag = ''; … … 335 350 $translations = $this->print_translations( $handle, false ); 336 351 if ( $translations ) { 337 $translations = sprintf( "<script type='text/javascript'>\n%s\n</script>\n", $translations );352 $translations = sprintf( "<script%s>\n%s\n</script>\n", $this->type_attr, $translations ); 338 353 } 339 354 … … 353 368 } 354 369 355 $tag = "{$translations}{$cond_before}{$before_handle}<script type='text/javascript' src='$src'></script>\n{$after_handle}{$cond_after}"; 370 $tag = $translations . $cond_before . $before_handle; 371 $tag .= sprintf( "<script%s src='%s'></script>\n", $this->type_attr, $src ); 372 $tag .= $after_handle . $cond_after; 356 373 357 374 /** … … 423 440 424 441 if ( $echo ) { 425 printf( "<script type='text/javascript'>\n%s\n</script>\n", $output );442 printf( "<script%s>\n%s\n</script>\n", $this->type_attr, $output ); 426 443 } 427 444 … … 558 575 559 576 if ( $echo ) { 560 printf( "<script type='text/javascript'>\n%s\n</script>\n", $output );577 printf( "<script%s>\n%s\n</script>\n", $this->type_attr, $output ); 561 578 } 562 579 -
trunk/src/wp-includes/class.wp-styles.php
r46088 r46164 102 102 103 103 /** 104 * Holds a string which contains the type attribute for style tag. 105 * 106 * If the current theme does not declare HTML5 support for 'style', 107 * then it initializes as `type='text/css'`. 108 * 109 * @since 5.3.0 110 * @var string 111 */ 112 private $type_attr = ''; 113 114 /** 104 115 * Constructor. 105 116 * … … 115 126 */ 116 127 do_action_ref_array( 'wp_default_styles', array( &$this ) ); 128 129 if ( ! current_theme_supports( 'html5', 'style' ) ) { 130 $this->type_attr = " type='text/css'"; 131 } 117 132 } 118 133 … … 157 172 158 173 if ( $inline_style ) { 159 $inline_style_tag = sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style ); 174 $inline_style_tag = sprintf( 175 "<style id='%s-inline-css'%s>\n%s\n</style>\n", 176 esc_attr( $handle ), 177 $this->type_attr, 178 $inline_style 179 ); 160 180 } else { 161 181 $inline_style_tag = ''; … … 198 218 199 219 $rel = isset( $obj->extra['alt'] ) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; 200 $title = isset( $obj->extra['title'] ) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : ''; 201 202 $tag = "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n"; 220 $title = isset( $obj->extra['title'] ) ? sprintf( "title='%s'", esc_attr( $obj->extra['title'] ) ) : ''; 221 222 $tag = sprintf( 223 "<link rel='%s' id='%s-css' %s href='%s'%s media='%s' />\n", 224 $rel, 225 $handle, 226 $title, 227 $href, 228 $this->type_attr, 229 $media 230 ); 203 231 204 232 /** … … 224 252 } 225 253 226 $rtl_tag = "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n"; 254 $rtl_tag = sprintf( 255 "<link rel='%s' id='%s-rtl-css' %s href='%s'%s media='%s' />\n", 256 $rel, 257 $handle, 258 $title, 259 $rtl_href, 260 $this->type_attr, 261 $media 262 ); 263 227 264 /** This filter is documented in wp-includes/class.wp-styles.php */ 228 265 $rtl_tag = apply_filters( 'style_loader_tag', $rtl_tag, $handle, $rtl_href, $media ); … … 299 336 } 300 337 301 printf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $output ); 338 printf( 339 "<style id='%s-inline-css'%s>\n%s\n</style>\n", 340 esc_attr( $handle ), 341 $this->type_attr, 342 $output 343 ); 302 344 303 345 return true; -
trunk/src/wp-includes/embed.php
r45932 r46164 1001 1001 */ 1002 1002 function print_embed_styles() { 1003 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 1003 1004 ?> 1004 <style type="text/css">1005 <style<?php echo $type_attr; ?>> 1005 1006 <?php 1006 1007 if ( SCRIPT_DEBUG ) { … … 1032 1033 */ 1033 1034 function print_embed_scripts() { 1035 $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"'; 1034 1036 ?> 1035 <script type="text/javascript">1037 <script<?php echo $type_attr; ?>> 1036 1038 <?php 1037 1039 if ( SCRIPT_DEBUG ) { -
trunk/src/wp-includes/formatting.php
r46128 r46164 5436 5436 5437 5437 $printed = true; 5438 5439 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 5438 5440 ?> 5439 <style type="text/css">5441 <style<?php echo $type_attr; ?>> 5440 5442 img.wp-smiley, 5441 5443 img.emoji { … … 5518 5520 ); 5519 5521 5520 $version = 'ver=' . get_bloginfo( 'version' ); 5522 $version = 'ver=' . get_bloginfo( 'version' ); 5523 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/javascript"'; 5521 5524 5522 5525 if ( SCRIPT_DEBUG ) { … … 5529 5532 5530 5533 ?> 5531 <script type="text/javascript">5534 <script<?php echo $type_attr; ?>> 5532 5535 window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; 5533 5536 <?php readfile( ABSPATH . WPINC . '/js/wp-emoji-loader.js' ); ?> … … 5551 5554 */ 5552 5555 ?> 5553 <script type="text/javascript">5556 <script<?php echo $type_attr; ?>> 5554 5557 window._wpemojiSettings = <?php echo wp_json_encode( $settings ); ?>; 5555 5558 include "js/wp-emoji-loader.min.js" -
trunk/src/wp-includes/media.php
r46078 r46164 1945 1945 */ 1946 1946 if ( apply_filters( 'use_default_gallery_style', ! $html5 ) ) { 1947 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 1948 1947 1949 $gallery_style = " 1948 <style type='text/css'>1950 <style{$type_attr}> 1949 1951 #{$selector} { 1950 1952 margin: auto; -
trunk/src/wp-includes/script-loader.php
r46157 r46164 2466 2466 } 2467 2467 2468 $concat = trim( $wp_scripts->concat, ', ' ); 2468 $concat = trim( $wp_scripts->concat, ', ' ); 2469 $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : " type='text/javascript'"; 2469 2470 2470 2471 if ( $concat ) { 2471 2472 if ( ! empty( $wp_scripts->print_code ) ) { 2472 echo "\n<script type='text/javascript'>\n";2473 echo "\n<script{$type_attr}>\n"; 2473 2474 echo "/* <![CDATA[ */\n"; // not needed in HTML 5 2474 2475 echo $wp_scripts->print_code; … … 2485 2486 2486 2487 $src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version; 2487 echo "<script type='text/javascript'src='" . esc_attr( $src ) . "'></script>\n";2488 echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n"; 2488 2489 } 2489 2490 … … 2647 2648 } 2648 2649 2649 $concat = trim( $wp_styles->concat, ', ' ); 2650 $concat = trim( $wp_styles->concat, ', ' ); 2651 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 2650 2652 2651 2653 if ( $concat ) { … … 2661 2663 2662 2664 $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver; 2663 echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "' type='text/css'media='all' />\n";2665 echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n"; 2664 2666 2665 2667 if ( ! empty( $wp_styles->print_code ) ) { 2666 echo "<style type='text/css'>\n";2668 echo "<style{$type_attr}>\n"; 2667 2669 echo $wp_styles->print_code; 2668 2670 echo "\n</style>\n"; -
trunk/src/wp-includes/theme.php
r45926 r46164 703 703 return; 704 704 } 705 echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />'; 705 706 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 707 708 printf( 709 '<link rel="stylesheet" href="%s"%s media="screen" />', 710 $stylesheet, 711 $type_attr 712 ); 706 713 } 707 714 … … 1642 1649 if ( ! $background && ! $color ) { 1643 1650 if ( is_customize_preview() ) { 1644 echo '<style type="text/css" id="custom-background-css"></style>'; 1651 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 1652 printf( '<style%s id="custom-background-css"></style>', $type_attr ); 1645 1653 } 1646 1654 return; … … 1694 1702 1695 1703 $style .= $image . $position . $size . $repeat . $attachment; 1704 1705 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 1696 1706 } 1697 1707 ?> 1698 <style type="text/css"id="custom-background-css">1708 <style<?php echo $type_attr; ?> id="custom-background-css"> 1699 1709 body.custom-background { <?php echo trim( $style ); ?> } 1700 1710 </style> … … 1710 1720 $styles = wp_get_custom_css(); 1711 1721 if ( $styles || is_customize_preview() ) : 1722 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 1712 1723 ?> 1713 <style type="text/css"id="wp-custom-css">1724 <style<?php echo $type_attr; ?> id="wp-custom-css"> 1714 1725 <?php echo strip_tags( $styles ); // Note that esc_html() cannot be used because `div > span` is not interpreted properly. ?> 1715 1726 </style> … … 2336 2347 * 2337 2348 * @since 2.9.0 2338 * @since 3.6.0 The `html5` feature was added 2339 * @since 3.9.0 The `html5` feature now also accepts 'gallery' and 'caption' 2340 * @since 4.1.0 The `title-tag` feature was added 2341 * @since 4.5.0 The `customize-selective-refresh-widgets` feature was added 2342 * @since 4.7.0 The `starter-content` feature was added 2349 * @since 3.6.0 The `html5` feature was added. 2350 * @since 3.9.0 The `html5` feature now also accepts 'gallery' and 'caption'. 2351 * @since 4.1.0 The `title-tag` feature was added. 2352 * @since 4.5.0 The `customize-selective-refresh-widgets` feature was added. 2353 * @since 4.7.0 The `starter-content` feature was added. 2343 2354 * @since 5.0.0 The `responsive-embeds`, `align-wide`, `dark-editor-style`, `disable-custom-colors`, 2344 2355 * `disable-custom-font-sizes`, `editor-color-palette`, `editor-font-sizes`, 2345 2356 * `editor-styles`, and `wp-block-styles` features were added. 2357 * @since 5.3.0 The `html5` feature now also accepts 'script' and 'style'. 2346 2358 * 2347 2359 * @global array $_wp_theme_features … … 2636 2648 $classes = '.' . implode( ', .', $classes ); 2637 2649 2650 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 2638 2651 ?> 2639 2652 <!-- Custom Logo: hide header text --> 2640 <style id="custom-logo-css" type="text/css">2653 <style id="custom-logo-css"<?php echo $type_attr; ?>> 2641 2654 <?php echo $classes; ?> { 2642 2655 position: absolute; … … 3197 3210 $home_origin = parse_url( home_url() ); 3198 3211 $cross_domain = ( strtolower( $admin_origin['host'] ) != strtolower( $home_origin['host'] ) ); 3199 3212 $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"'; 3200 3213 ?> 3201 3214 <!--[if lte IE 8]> 3202 <script type="text/javascript">3215 <script<?php echo $type_attr; ?>> 3203 3216 document.body.className = document.body.className.replace( /(^|\s)(no-)?customize-support(?=\s|$)/, '' ) + ' no-customize-support'; 3204 3217 </script> 3205 3218 <![endif]--> 3206 3219 <!--[if gte IE 9]><!--> 3207 <script type="text/javascript">3220 <script<?php echo $type_attr; ?>> 3208 3221 (function() { 3209 3222 var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)'); -
trunk/src/wp-includes/widgets/class-wp-widget-archives.php
r44897 r46164 99 99 break; 100 100 } 101 102 $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"'; 101 103 ?> 102 104 … … 106 108 </select> 107 109 108 <script type='text/javascript'>110 <script<?php echo $type_attr; ?>> 109 111 /* <![CDATA[ */ 110 112 (function() { -
trunk/src/wp-includes/widgets/class-wp-widget-categories.php
r44589 r46164 90 90 91 91 echo '</form>'; 92 93 $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"'; 92 94 ?> 93 95 94 <script type='text/javascript'>96 <script<?php echo $type_attr; ?>> 95 97 /* <![CDATA[ */ 96 98 (function() { -
trunk/src/wp-includes/widgets/class-wp-widget-recent-comments.php
r45932 r46164 54 54 return; 55 55 } 56 ?> 57 <style type="text/css">.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style> 58 <?php 56 57 $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; 58 59 printf( 60 '<style%s>.recentcomments a{display:inline !important;padding:0 !important;margin:0 !important;}</style>', 61 $type_attr 62 ); 59 63 } 60 64 -
trunk/tests/phpunit/tests/dependencies/scripts.php
r45979 r46164 45 45 wp_enqueue_script( 'empty-deps-version', 'example.com', array(), 1.2 ); 46 46 wp_enqueue_script( 'empty-deps-null-version', 'example.com', array(), null ); 47 47 48 $ver = get_bloginfo( 'version' ); 48 49 $expected = "<script type='text/javascript' src='http://example.com?ver=$ver'></script>\n"; … … 55 56 // No scripts left to print 56 57 $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); 58 } 59 60 /** 61 * @ticket 42804 62 */ 63 function test_wp_enqueue_script_with_html5_support_does_not_contain_type_attribute() { 64 add_theme_support( 'html5', array( 'script' ) ); 65 66 $GLOBALS['wp_scripts'] = new WP_Scripts(); 67 $GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' ); 68 69 wp_enqueue_script( 'empty-deps-no-version', 'example.com' ); 70 71 $ver = get_bloginfo( 'version' ); 72 $expected = "<script src='http://example.com?ver=$ver'></script>\n"; 73 74 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 57 75 } 58 76 -
trunk/tests/phpunit/tests/dependencies/styles.php
r44157 r46164 57 57 wp_enqueue_style( 'no-deps-null-version', 'example.com', array(), null ); 58 58 wp_enqueue_style( 'no-deps-null-version-print-media', 'example.com', array(), null, 'print' ); 59 59 60 $ver = get_bloginfo( 'version' ); 60 61 $expected = "<link rel='stylesheet' id='no-deps-no-version-css' href='http://example.com?ver=$ver' type='text/css' media='all' />\n"; … … 67 68 // No styles left to print 68 69 $this->assertEquals( '', get_echo( 'wp_print_styles' ) ); 70 } 71 72 /** 73 * @ticket 42804 74 */ 75 function test_wp_enqueue_style_with_html5_support_does_not_contain_type_attribute() { 76 add_theme_support( 'html5', array( 'style' ) ); 77 78 $GLOBALS['wp_styles'] = new WP_Styles(); 79 $GLOBALS['wp_styles']->default_version = get_bloginfo( 'version' ); 80 81 wp_enqueue_style( 'no-deps-no-version', 'example.com' ); 82 83 $ver = get_bloginfo( 'version' ); 84 $expected = "<link rel='stylesheet' id='no-deps-no-version-css' href='http://example.com?ver=$ver' media='all' />\n"; 85 86 $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); 69 87 } 70 88
Note: See TracChangeset
for help on using the changeset viewer.