From 0f1f59b0927acddd2a8001948d94e0bb5c9c06d0 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 1 Jun 2012 20:31:50 +0000 Subject: [PATCH] Custom background fixes: * Specify default background colors for the bundled themes. * Change the default custom background callback to only operate on saved values, rather than default values. * Prevent an unsaved default value from overriding a manually modified style.css file. Props nacin, kobenland fixes #20448 git-svn-id: http://core.svn.wordpress.org/trunk@20973 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/twentyeleven/functions.php | 12 +++++++++++- wp-content/themes/twentyten/functions.php | 5 ++++- wp-includes/post-template.php | 5 ++++- wp-includes/theme.php | 5 +++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/wp-content/themes/twentyeleven/functions.php b/wp-content/themes/twentyeleven/functions.php index eeef9aedc..b598d2acf 100644 --- a/wp-content/themes/twentyeleven/functions.php +++ b/wp-content/themes/twentyeleven/functions.php @@ -97,8 +97,18 @@ function twentyeleven_setup() { // Add support for a variety of post formats add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) ); + $theme_options = twentyeleven_get_theme_options(); + if ( 'dark' == $theme_options['color_scheme'] ) + $default_background_color = '1d1d1d'; + else + $default_background_color = 'f1f1f1'; + // Add support for custom backgrounds. - add_theme_support( 'custom-background' ); + add_theme_support( 'custom-background', array( + // Let WordPress know what our default background color is. + // This is dependent on our current color scheme. + 'default-color' => $default_background_color, + ) ); // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images add_theme_support( 'post-thumbnails' ); diff --git a/wp-content/themes/twentyten/functions.php b/wp-content/themes/twentyten/functions.php index f2dde3d8b..51596292f 100644 --- a/wp-content/themes/twentyten/functions.php +++ b/wp-content/themes/twentyten/functions.php @@ -94,7 +94,10 @@ function twentyten_setup() { ) ); // This theme allows users to set a custom background. - add_theme_support( 'custom-background' ); + add_theme_support( 'custom-background', array( + // Let WordPress know what our default background color is. + 'default-color' => 'f1f1f1', + ) ); // The custom header business starts here. diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 11b9f093f..e242c2211 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -501,7 +501,10 @@ function get_body_class( $class = '' ) { if ( is_admin_bar_showing() ) $classes[] = 'admin-bar'; - if ( get_background_image() || get_background_color() ) + 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' ) ) ) ) $classes[] = 'custom-background'; $page = $wp_query->get( 'page' ); diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 004a5281d..f0c932dc9 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1102,8 +1102,9 @@ function background_color() { * @access protected */ function _custom_background_cb() { - $background = get_background_image(); - $color = get_background_color(); + $background = get_theme_mod( 'background_image' ); + $color = get_theme_mod( 'background_color' ); + if ( ! $background && ! $color ) return;