Skip to content

Commit 606539e

Browse files
committed
Use HTML Tag Processor to produce WP_Styles style tags
1 parent 33f9616 commit 606539e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/wp-includes/class-wp-styles.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,11 @@ public function do_item( $handle, $group = false ) {
183183
$inline_style = $this->print_inline_style( $handle, false );
184184

185185
if ( $inline_style ) {
186-
$inline_style_tag = sprintf(
187-
"<style id='%s-inline-css'%s>\n%s\n</style>\n",
188-
esc_attr( $handle ),
189-
$this->type_attr,
190-
$inline_style
191-
);
186+
$processor = new WP_HTML_Tag_Processor( "<style{$this->type_attr}></style>\n" );
187+
$processor->next_tag();
188+
$processor->set_attribute( 'id', "{$handle}-inline-css" );
189+
$processor->set_modifiable_text( "\n{$inline_style}\n" );
190+
$inline_style_tag = $processor->get_updated_html();
192191
} else {
193192
$inline_style_tag = '';
194193
}
@@ -364,12 +363,11 @@ public function print_inline_style( $handle, $display = true ) {
364363
return $output;
365364
}
366365

367-
printf(
368-
"<style id='%s-inline-css'%s>\n%s\n</style>\n",
369-
esc_attr( $handle ),
370-
$this->type_attr,
371-
$output
372-
);
366+
$processor = new WP_HTML_Tag_Processor( "<style{$this->type_attr}></style>\n" );
367+
$processor->next_tag();
368+
$processor->set_attribute( 'id', "{$handle}-inline-css" );
369+
$processor->set_modifiable_text( "\n{$output}\n" );
370+
echo $processor->get_updated_html();
373371

374372
return true;
375373
}

0 commit comments

Comments
 (0)