Fix removing the default background image for themes that hard-code the default in css. Honor the default background image for themes that do not provide a fallback in css.

* <style> will appear if there is a default image registered. This is the same as 3.3.
* If only a default color is registered, it still assumes it is in the stylesheet, and no <style> will appear. This is a change from 3.3.
* <style> will continue to appear as before if there is a custom background color or image. This is the same as 3.3.
* This then allows for a default background image with background-image: none, overriding style.css. This is new.

Props nacin
see #20448


git-svn-id: https://develop.svn.wordpress.org/trunk@21001 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2012-06-05 18:35:31 +00:00
parent cbc3a81ee0
commit 2dbb51b71f
2 changed files with 5 additions and 6 deletions

View File

@ -501,10 +501,7 @@ function get_body_class( $class = '' ) {
if ( is_admin_bar_showing() )
$classes[] = 'admin-bar';
if ( get_theme_mod( 'background_image' ) || get_theme_mod( 'background_color' ) ||
( '_custom_background_cb' != get_theme_support( 'custom-background', 'wp-head-callback' )
&& ( get_theme_support( 'custom-background', 'default-image' ) ||
get_theme_support( 'custom-background', 'default-color' ) ) ) )
if ( get_background_color() || get_theme_mod( 'background_image' ) || get_theme_support( 'custom-background', 'default-image' ) )
$classes[] = 'custom-background';
$page = $wp_query->get( 'page' );

View File

@ -1102,10 +1102,10 @@ function background_color() {
* @access protected
*/
function _custom_background_cb() {
$background = get_theme_mod( 'background_image' );
$background = get_background_image();
$color = get_theme_mod( 'background_color' );
if ( ! $background && ! $color )
if ( ! $background && ! $color && ! get_theme_support( 'custom-background', 'default-image' ) )
return;
$style = $color ? "background-color: #$color;" : '';
@ -1129,6 +1129,8 @@ function _custom_background_cb() {
$attachment = " background-attachment: $attachment;";
$style .= $image . $repeat . $position . $attachment;
} elseif ( get_theme_support( 'custom-background', 'default-image' ) ) {
$style .= " background-image: none;";
}
?>
<style type="text/css" id="custom-background-css">