WordPress.org

Make WordPress Core

Changeset 21054


Ignore:
Timestamp:
06/11/12 21:25:05 (5 years ago)
Author:
nacin
Message:

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.

Location:
trunk/wp-includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-customize-manager.php

    r21053 r21054  
    338338            'values'  => array(), 
    339339            'channel' => esc_js( $_POST['customize_messenger_channel'] ), 
    340             'backgroundImageHasDefault' => current_theme_supports( 'custom-background', 'default-image' ), 
    341340        ); 
    342341 
  • trunk/wp-includes/js/customize-preview.dev.js

    r21013 r21054  
    110110 
    111111            update = function() { 
    112                 var css = '', 
    113                     hasDefault = api.settings.backgroundImageHasDefault; 
     112                var css = ''; 
    114113 
    115114                // The body will support custom backgrounds if either 
     
    117116                // 
    118117                // See get_body_class() in /wp-includes/post-template.php 
    119                 body.toggleClass( 'custom-background', !! ( color() || image() || hasDefault ) ); 
     118                body.toggleClass( 'custom-background', !! ( color() || image() ) ); 
    120119 
    121120                if ( color() ) 
     
    127126                    css += 'background-repeat: ' + repeat() + ';'; 
    128127                    css += 'background-position: top ' + attachment() + ';'; 
    129                 } else if ( hasDefault ) { 
    130                     css += 'background-image: none;'; 
    131128                } 
    132129 
  • trunk/wp-includes/post-template.php

    r21001 r21054  
    502502        $classes[] = 'admin-bar'; 
    503503 
    504     if ( get_background_color() || get_theme_mod( 'background_image' ) || get_theme_support( 'custom-background', 'default-image' ) ) 
     504    if ( get_theme_mod( 'background_color' ) || get_background_image() ) 
    505505        $classes[] = 'custom-background'; 
    506506 
  • trunk/wp-includes/theme.php

    r21016 r21054  
    11101110    $color = get_theme_mod( 'background_color' ); 
    11111111 
    1112     if ( ! $background && ! $color && ! get_theme_support( 'custom-background', 'default-image' ) ) 
     1112    if ( ! $background && ! $color ) 
    11131113        return; 
    11141114 
     
    11341134 
    11351135        $style .= $image . $repeat . $position . $attachment; 
    1136     } elseif ( get_theme_support( 'custom-background', 'default-image' ) ) { 
    1137         // If there is not a $background, but there is a default, then the default was 
    1138         // removed and an empty value was saved. Remove it: 
    1139         $style .= " background-image: none;"; 
    11401136    } 
    11411137?> 
Note: See TracChangeset for help on using the changeset viewer.