Skip to content

Commit 0f3c1d1

Browse files
committed
Use the tag processor to correctly set script tag contents
1 parent 92dfaa9 commit 0f3c1d1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/wp-includes/script-loader.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,12 @@ function wp_get_inline_script_tag( $data, $attributes = array() ) {
29872987
*/
29882988
$attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $data );
29892989

2990+
$script_tag = sprintf( '<script%s></script>', wp_sanitize_script_attributes( $attributes ) );
2991+
$processor = new WP_HTML_Tag_Processor( $script_tag );
2992+
if ( $processor->next_tag( 'SCRIPT' ) && $processor->set_modifiable_text( $data ) ) {
2993+
return $processor->get_updated_html() . "\n";
2994+
}
2995+
29902996
return sprintf( "<script%s>%s</script>\n", wp_sanitize_script_attributes( $attributes ), $data );
29912997
}
29922998

0 commit comments

Comments
 (0)