diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
index bb892b5..81cde99 100644
|
|
final class WP_Customize_Manager { |
1829 | 1829 | 'theme' => array( |
1830 | 1830 | 'stylesheet' => $this->get_stylesheet(), |
1831 | 1831 | 'active' => $this->is_theme_active(), |
| 1832 | 'bgElement' => tag_escape( get_theme_support( 'custom-background', 'background-element' ) ), |
| 1833 | 'bgClass' => sanitize_html_class( get_theme_support( 'custom-background', 'background-class' ) ), |
| 1834 | 'bgSelector' => get_theme_support( 'custom-background', 'background-selector' ), |
1832 | 1835 | ), |
1833 | 1836 | 'url' => array( |
1834 | 1837 | 'preview' => esc_url_raw( $this->get_preview_url() ), |
… |
… |
final class WP_Customize_Manager { |
1852 | 1855 | 'previewableDevices' => $this->get_previewable_devices(), |
1853 | 1856 | ); |
1854 | 1857 | |
| 1858 | $settings['theme']['bgSelector'] = sprintf( $settings['theme']['bgSelector'], $settings['theme']['bgElement'], $settings['theme']['bgClass'] ); |
| 1859 | |
1855 | 1860 | // Prepare Customize Section objects to pass to JavaScript. |
1856 | 1861 | foreach ( $this->sections() as $id => $section ) { |
1857 | 1862 | if ( $section->check_capabilities() ) { |
diff --git src/wp-includes/js/customize-preview.js src/wp-includes/js/customize-preview.js
index 1d61ba3..4e8143a 100644
|
|
|
212 | 212 | }); |
213 | 213 | |
214 | 214 | api.when.apply( api, bg ).done( function( color, image, position_x, repeat, attachment ) { |
215 | | var body = $(document.body), |
| 215 | var element = $(window.parent._wpCustomizeSettings.theme.bgElement), |
216 | 216 | head = $('head'), |
217 | 217 | style = $('#custom-background-css'), |
218 | 218 | update; |
219 | 219 | |
220 | 220 | update = function() { |
221 | 221 | var css = ''; |
| 222 | var selector = window.parent._wpCustomizeSettings.theme.bgSelector; |
222 | 223 | |
223 | 224 | // The body will support custom backgrounds if either |
224 | 225 | // the color or image are set. |
225 | 226 | // |
226 | 227 | // See get_body_class() in /wp-includes/post-template.php |
227 | | body.toggleClass( 'custom-background', !! ( color() || image() ) ); |
| 228 | element.toggleClass( 'custom-background', !! ( color() || image() ) ); |
228 | 229 | |
229 | 230 | if ( color() ) |
230 | 231 | css += 'background-color: ' + color() + ';'; |
… |
… |
|
238 | 239 | |
239 | 240 | // Refresh the stylesheet by removing and recreating it. |
240 | 241 | style.remove(); |
241 | | style = $('<style type="text/css" id="custom-background-css">body.custom-background { ' + css + ' }</style>').appendTo( head ); |
| 242 | style = $('<style type="text/css" id="custom-background-css">' + selector + ' { ' + css + ' }</style>').appendTo( head ); |
242 | 243 | }; |
243 | 244 | |
244 | 245 | $.each( arguments, function() { |
diff --git src/wp-includes/post-template.php src/wp-includes/post-template.php
index 1214129..fd592a1 100644
|
|
function get_body_class( $class = '' ) { |
712 | 712 | } |
713 | 713 | |
714 | 714 | if ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() ) |
715 | | $classes[] = 'custom-background'; |
| 715 | $classes[] = sanitize_html_class( get_theme_support( 'custom-background', 'background-class' ) ); |
716 | 716 | |
717 | 717 | if ( has_custom_logo() ) { |
718 | 718 | $classes[] = 'wp-custom-logo'; |
diff --git src/wp-includes/theme.php src/wp-includes/theme.php
index c8cf03f..27bac56 100644
|
|
function _custom_background_cb() { |
1393 | 1393 | |
1394 | 1394 | $style .= $image . $repeat . $position . $attachment; |
1395 | 1395 | } |
| 1396 | |
| 1397 | $element = tag_escape( get_theme_support( 'custom-background', 'background-element' ) ); |
| 1398 | $class = sanitize_html_class( get_theme_support( 'custom-background', 'background-class' ) ); |
| 1399 | $selector = get_theme_support( 'custom-background', 'background-selector' ); |
| 1400 | |
| 1401 | $selector = sprintf( $selector, $element, $class ); |
1396 | 1402 | ?> |
1397 | 1403 | <style type="text/css" id="custom-background-css"> |
1398 | | body.custom-background { <?php echo trim( $style ); ?> } |
| 1404 | <?php echo $selector; ?> { <?php echo trim( $style ); ?> } |
1399 | 1405 | </style> |
1400 | 1406 | <?php |
1401 | 1407 | } |
… |
… |
function add_theme_support( $feature ) { |
1696 | 1702 | 'wp-head-callback' => '_custom_background_cb', |
1697 | 1703 | 'admin-head-callback' => '', |
1698 | 1704 | 'admin-preview-callback' => '', |
| 1705 | 'background-element' => 'body', |
| 1706 | 'background-class' => 'custom-background', |
| 1707 | 'background-selector' => '%1$s.%2$s', |
1699 | 1708 | ); |
1700 | 1709 | |
1701 | 1710 | $jit = isset( $args[0]['__jit'] ); |