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
This commit is contained in:
ryan 2012-06-01 20:31:50 +00:00
parent eaa419dba3
commit 0f1f59b092
4 changed files with 22 additions and 5 deletions

View File

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

View File

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

View File

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

View File

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