Changeset 56687 for trunk/src/wp-includes/class-wp-scripts.php
- Timestamp:
- 09/25/2023 09:03:19 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-scripts.php
r56273 r56687 124 124 125 125 /** 126 * Holds a string which contains the type attribute for script tag.127 *128 * If the active theme does not declare HTML5 support for 'script',129 * then it initializes as `type='text/javascript'`.130 *131 * @since 5.3.0132 * @var string133 */134 private $type_attr = '';135 136 /**137 126 * Holds a mapping of dependents (as handles) for a given script handle. 138 127 * Used to optimize recursive dependency tree checks. … … 168 157 */ 169 158 public function init() { 170 if (171 function_exists( 'is_admin' ) && ! is_admin()172 &&173 function_exists( 'current_theme_supports' ) && ! current_theme_supports( 'html5', 'script' )174 ) {175 $this->type_attr = " type='text/javascript'";176 }177 178 159 /** 179 160 * Fires when the WP_Scripts instance is initialized. … … 246 227 } 247 228 248 printf( "<script%s id='%s-js-extra'>\n", $this->type_attr, esc_attr( $handle ) ); 249 250 // CDATA is not needed for HTML 5. 251 if ( $this->type_attr ) { 252 echo "/* <![CDATA[ */\n"; 253 } 254 255 echo "$output\n"; 256 257 if ( $this->type_attr ) { 258 echo "/* ]]> */\n"; 259 } 260 261 echo "</script>\n"; 229 wp_print_inline_script_tag( $output, array( 'id' => "{$handle}-js-extra" ) ); 262 230 263 231 return true; … … 336 304 $translations = $this->print_translations( $handle, false ); 337 305 if ( $translations ) { 338 $translations = sprintf( "<script%s id='%s-js-translations'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $translations);306 $translations = wp_get_inline_script_tag( $translations, array( 'id' => "{$handle}-js-translations" ) ); 339 307 } 340 308 … … 404 372 405 373 /** This filter is documented in wp-includes/class-wp-scripts.php */ 406 $src = esc_url ( apply_filters( 'script_loader_src', $src, $handle ) );374 $src = esc_url_raw( apply_filters( 'script_loader_src', $src, $handle ) ); 407 375 408 376 if ( ! $src ) { … … 410 378 } 411 379 380 $attr = array( 381 'src' => $src, 382 'id' => "{$handle}-js", 383 ); 384 if ( $strategy ) { 385 $attr[ $strategy ] = true; 386 } 387 if ( $intended_strategy ) { 388 $attr['data-wp-strategy'] = $intended_strategy; 389 } 412 390 $tag = $translations . $cond_before . $before_script; 413 $tag .= sprintf( 414 "<script%s src='%s' id='%s-js'%s%s></script>\n", 415 $this->type_attr, 416 $src, // Value is escaped above. 417 esc_attr( $handle ), 418 $strategy ? " {$strategy}" : '', 419 $intended_strategy ? " data-wp-strategy='{$intended_strategy}'" : '' 420 ); 391 $tag .= wp_get_script_tag( $attr ); 421 392 $tag .= $after_script . $cond_after; 422 393 … … 721 692 722 693 if ( $display ) { 723 printf( "<script%s id='%s-js-translations'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $output);694 wp_print_inline_script_tag( $output, array( 'id' => "{$handle}-js-translations" ) ); 724 695 } 725 696
Note: See TracChangeset
for help on using the changeset viewer.