Theme Customizer: Correctly use custom-background class in theme preview. See #19910.

git-svn-id: http://core.svn.wordpress.org/trunk@20919 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
koopersmith 2012-05-25 22:43:11 +00:00
parent 69c970a4a1
commit 3c044eba6f
1 changed files with 15 additions and 2 deletions

View File

@ -81,15 +81,28 @@
});
api.when.apply( api, bg ).done( function( color, image, position_x, repeat, attachment ) {
var style = $('#custom-background-css'),
var body = $(document.body),
style = $('#custom-background-css'),
update;
if ( ! style.length )
// If custom backgrounds are active and we can't find the
// default output, bail.
if ( body.hasClass('custom-background') && ! style.length )
return;
// Create the CSS container if it doesn't already exist.
if ( ! style.length )
style = $('<style type="text/css" id="custom-background-css" />').appendTo('head');
update = function() {
var css = '';
// The body will support custom backgrounds if either
// the color or image are set.
//
// See get_body_class() in /wp-includes/post-template.php
body.toggleClass( 'custom-background', !! ( color() || image() ) );
if ( color() )
css += 'background-color: #' + color() + ';';