Skip to content

Commit aa7852c

Browse files
committed
Use HTML Tag Processor to produce WP_Styles style tags
1 parent e793caa commit aa7852c

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
@@ -178,12 +178,11 @@ public function do_item( $handle, $group = false ) {
178178
$inline_style = $this->print_inline_style( $handle, false );
179179

180180
if ( $inline_style ) {
181-
$inline_style_tag = sprintf(
182-
"<style id='%s-inline-css'%s>\n%s\n</style>\n",
183-
esc_attr( $handle ),
184-
$this->type_attr,
185-
$inline_style
186-
);
181+
$processor = new WP_HTML_Tag_Processor( "<style{$this->type_attr}></style>\n" );
182+
$processor->next_tag();
183+
$processor->set_attribute( 'id', "{$handle}-inline-css" );
184+
$processor->set_modifiable_text( "\n{$inline_style}\n" );
185+
$inline_style_tag = $processor->get_updated_html();
187186
} else {
188187
$inline_style_tag = '';
189188
}
@@ -359,12 +358,11 @@ public function print_inline_style( $handle, $display = true ) {
359358
return $output;
360359
}
361360

362-
printf(
363-
"<style id='%s-inline-css'%s>\n%s\n</style>\n",
364-
esc_attr( $handle ),
365-
$this->type_attr,
366-
$output
367-
);
361+
$processor = new WP_HTML_Tag_Processor( "<style{$this->type_attr}></style>\n" );
362+
$processor->next_tag();
363+
$processor->set_attribute( 'id', "{$handle}-inline-css" );
364+
$processor->set_modifiable_text( "\n{$output}\n" );
365+
echo $processor->get_updated_html();
368366

369367
return true;
370368
}

0 commit comments

Comments
 (0)