Skip to content

Commit deebd54

Browse files
committed
Use the tag processor for all the inline script tags
1 parent 27c6371 commit deebd54

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/wp-includes/script-loader.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,13 +3026,15 @@ function wp_get_inline_script_tag( $data, $attributes = array() ) {
30263026
*/
30273027
$attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $data );
30283028

3029-
$script_tag = sprintf( '<script%s></script>', wp_sanitize_script_attributes( $attributes ) );
3030-
$processor = new WP_HTML_Tag_Processor( $script_tag );
3031-
if ( $processor->next_tag( 'SCRIPT' ) && $processor->set_modifiable_text( $data ) ) {
3032-
return $processor->get_updated_html() . "\n";
3029+
$processor = new WP_HTML_Tag_Processor( "<script></script>\n" );
3030+
$processor->next_tag();
3031+
foreach ( $attributes as $name => $value ) {
3032+
if ( is_string( $value ) || true === $value ) {
3033+
assert( $processor->set_attribute( $name, $value ) );
3034+
}
30333035
}
3034-
3035-
return sprintf( "<script%s>%s</script>\n", wp_sanitize_script_attributes( $attributes ), $data );
3036+
assert( $processor->set_modifiable_text( $data ) );
3037+
return $processor->get_updated_html();
30363038
}
30373039

30383040
/**

0 commit comments

Comments
 (0)