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
This commit is contained in:
nacin 2012-06-11 21:25:05 +00:00
parent 2d07cd3fc5
commit 64b9b4f940
4 changed files with 4 additions and 12 deletions

View File

@ -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 ) {

View File

@ -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.

View File

@ -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' );

View File

@ -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;";
}
?>
<style type="text/css" id="custom-background-css">