Message info
 
To:wp-svn@lists.automattic.com From:m@wordpress.org Subject:[wp-svn] [20973] trunk: Custom background fixes: Date:Fri, 1 Jun 2012 20:31:50 +0000 (UTC)
 

Revision
20973
Author
ryan
Date
2012-06-01 20:31:50 +0000 (Fri, 01 Jun 2012)

Log Message

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

Modified Paths

Diff

Modified: trunk/wp-content/themes/twentyeleven/functions.php (20972 => 20973)


--- trunk/wp-content/themes/twentyeleven/functions.php	2012-06-01 19:05:30 UTC (rev 20972)
+++ trunk/wp-content/themes/twentyeleven/functions.php	2012-06-01 20:31:50 UTC (rev 20973)
@@ -97,8 +97,18 @@
 	// 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' );

Modified: trunk/wp-content/themes/twentyten/functions.php (20972 => 20973)


--- trunk/wp-content/themes/twentyten/functions.php	2012-06-01 19:05:30 UTC (rev 20972)
+++ trunk/wp-content/themes/twentyten/functions.php	2012-06-01 20:31:50 UTC (rev 20973)
@@ -94,7 +94,10 @@
 	) );
 
 	// 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.
 

Modified: trunk/wp-includes/post-template.php (20972 => 20973)


--- trunk/wp-includes/post-template.php	2012-06-01 19:05:30 UTC (rev 20972)
+++ trunk/wp-includes/post-template.php	2012-06-01 20:31:50 UTC (rev 20973)
@@ -501,7 +501,10 @@
 	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' );

Modified: trunk/wp-includes/theme.php (20972 => 20973)


--- trunk/wp-includes/theme.php	2012-06-01 19:05:30 UTC (rev 20972)
+++ trunk/wp-includes/theme.php	2012-06-01 20:31:50 UTC (rev 20973)
@@ -1102,8 +1102,9 @@
  * @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;