From 64b9b4f9404c2e814b326663bfa46929c0fbcdc2 Mon Sep 17 00:00:00 2001 From: nacin Date: Mon, 11 Jun 2012 21:25:05 +0000 Subject: [PATCH] Do not specify background-image: none when a user removes a custom background on a theme that has a default background image. The onus is on the theme to omit the default background-image from style.css, to allow the user to remove the default background image. Or, the theme can specify a background-image for the body selector, as long as they then zero it out for body.custom-background, like so: {{{ body { background-image: url( ... ); } body.custom-background { background-image: none; } }}} This allows the theme to be compatible with the custom background feature but also gracefully degrade if the background feature is disabled. This is the same behavior as 3.3; setting a default image has simply been made more prominent in 3.4. Reverts [21013], also parts of [21001]. see #20448 for change and discussion history. see #20132, which will now be marked as invalid. Also, per previous changes in #20448, the custom-background class should not be shown when only a default color is in use. fixes #20448. git-svn-id: http://core.svn.wordpress.org/trunk@21054 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-manager.php | 1 - wp-includes/js/customize-preview.dev.js | 7 ++----- wp-includes/post-template.php | 2 +- wp-includes/theme.php | 6 +----- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index cb2430054b..a73654e060 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -337,7 +337,6 @@ final class WP_Customize_Manager { $settings = array( 'values' => array(), 'channel' => esc_js( $_POST['customize_messenger_channel'] ), - 'backgroundImageHasDefault' => current_theme_supports( 'custom-background', 'default-image' ), ); foreach ( $this->settings as $id => $setting ) { diff --git a/wp-includes/js/customize-preview.dev.js b/wp-includes/js/customize-preview.dev.js index 15ffc3c542..28af66b8dd 100644 --- a/wp-includes/js/customize-preview.dev.js +++ b/wp-includes/js/customize-preview.dev.js @@ -109,14 +109,13 @@ return; update = function() { - var css = '', - hasDefault = api.settings.backgroundImageHasDefault; + 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() || hasDefault ) ); + body.toggleClass( 'custom-background', !! ( color() || image() ) ); if ( color() ) css += 'background-color: ' + color() + ';'; @@ -126,8 +125,6 @@ css += 'background-position: top ' + position_x() + ';'; css += 'background-repeat: ' + repeat() + ';'; css += 'background-position: top ' + attachment() + ';'; - } else if ( hasDefault ) { - css += 'background-image: none;'; } // Refresh the stylesheet by removing and recreating it. diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index e42ac46a7a..5a414eaf5a 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -501,7 +501,7 @@ function get_body_class( $class = '' ) { if ( is_admin_bar_showing() ) $classes[] = 'admin-bar'; - if ( get_background_color() || get_theme_mod( 'background_image' ) || get_theme_support( 'custom-background', 'default-image' ) ) + if ( get_theme_mod( 'background_color' ) || get_background_image() ) $classes[] = 'custom-background'; $page = $wp_query->get( 'page' ); diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 6c1bfc2be7..d71ed4443c 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1109,7 +1109,7 @@ function _custom_background_cb() { // A default has to be specified in style.css. It will not be printed here. $color = get_theme_mod( 'background_color' ); - if ( ! $background && ! $color && ! get_theme_support( 'custom-background', 'default-image' ) ) + if ( ! $background && ! $color ) return; $style = $color ? "background-color: #$color;" : ''; @@ -1133,10 +1133,6 @@ function _custom_background_cb() { $attachment = " background-attachment: $attachment;"; $style .= $image . $repeat . $position . $attachment; - } elseif ( get_theme_support( 'custom-background', 'default-image' ) ) { - // If there is not a $background, but there is a default, then the default was - // removed and an empty value was saved. Remove it: - $style .= " background-image: none;"; } ?>