Skip to content

Commit 93cddc3

Browse files
committed
Use HTML Tag Processor for STYLE tags in theme.php
1 parent aa7852c commit 93cddc3

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/wp-includes/theme.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,11 +1953,13 @@ function _custom_background_cb() {
19531953

19541954
$style .= $image . $position . $size . $repeat . $attachment;
19551955
}
1956-
?>
1957-
<style<?php echo $type_attr; ?> id="custom-background-css">
1958-
body.custom-background { <?php echo trim( $style ); ?> }
1959-
</style>
1960-
<?php
1956+
1957+
$processor = new WP_HTML_Tag_Processor( "<style{$type_attr} id=\"custom-background-css\"></style>" );
1958+
$processor->next_tag();
1959+
1960+
$style_tag_content = 'body.custom-background { ' . trim( $style ) . ' }';
1961+
$processor->set_modifiable_text( "\n{$style_tag_content}\n" );
1962+
echo $processor->get_updated_html();
19611963
}
19621964

19631965
/**
@@ -1967,7 +1969,7 @@ function _custom_background_cb() {
19671969
*/
19681970
function wp_custom_css_cb() {
19691971
$styles = wp_get_custom_css();
1970-
if ( ! $styles || ! is_customize_preview() ) {
1972+
if ( ! $styles && ! is_customize_preview() ) {
19711973
return;
19721974
}
19731975

0 commit comments

Comments
 (0)