Changeset 46164 for trunk/src/wp-includes/class.wp-scripts.php
- Timestamp:
- 09/18/2019 02:49:30 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.