Skip to content

Commit e793caa

Browse files
committed
Use HTML API for style tags in script-loader
1 parent f3a1716 commit e793caa

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/wp-includes/script-loader.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,10 +2417,12 @@ function _print_styles() {
24172417
echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n";
24182418

24192419
if ( ! empty( $wp_styles->print_code ) ) {
2420-
echo "<style{$type_attr}>\n";
2421-
echo $wp_styles->print_code;
2422-
echo sprintf( "\n/*# sourceURL=%s */", rawurlencode( $concat_source_url ) );
2423-
echo "\n</style>\n";
2420+
$processor = new WP_HTML_Tag_Processor( "<style{$type_attr}></style>" );
2421+
$processor->next_tag();
2422+
$style_tag_contents = "\n{$wp_styles->print_code}\n"
2423+
. sprintf( "/*# sourceURL=%s */\n", rawurlencode( $concat_source_url ) );
2424+
$processor->set_modifiable_text( $style_tag_contents );
2425+
echo $processor->get_updated_html();
24242426
}
24252427
}
24262428

@@ -3217,7 +3219,10 @@ function wp_enqueue_block_support_styles( $style, $priority = 10 ) {
32173219
add_action(
32183220
$action_hook_name,
32193221
static function () use ( $style ) {
3220-
echo "<style>$style</style>\n";
3222+
$processor = new WP_HTML_Tag_Processor( "<style></style>\n" );
3223+
$processor->next_tag();
3224+
$processor->set_modifiable_text( $style );
3225+
echo $processor->get_updated_html();
32213226
},
32223227
$priority
32233228
);

0 commit comments

Comments
 (0)