From fd14a5df716531325bb927d8331adb9daba2130f Mon Sep 17 00:00:00 2001 From: Jon Cave Date: Sun, 24 Nov 2013 14:05:10 +0000 Subject: [PATCH] Allow customisation of theme mod defaults via custom-background theme support. Give the power to theme authors to select defaults when registering custom-background support. Props obenland. Fixes #20816. Built from https://develop.svn.wordpress.org/trunk@26352 git-svn-id: http://core.svn.wordpress.org/trunk@26253 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/custom-background.php | 26 +++++++++++++------------- wp-includes/theme.php | 17 ++++++++++------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/wp-admin/custom-background.php b/wp-admin/custom-background.php index 97656089ca..ba74dfc48d 100644 --- a/wp-admin/custom-background.php +++ b/wp-admin/custom-background.php @@ -206,8 +206,8 @@ if ( get_background_image() ) { $background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', get_background_image() ) ) ) ); // background-image URL must be single quote, see below $background_styles .= ' background-image: url(\'' . $background_image_thumb . '\');' - . ' background-repeat: ' . get_theme_mod('background_repeat', 'repeat') . ';' - . ' background-position: top ' . get_theme_mod('background_position_x', 'left'); + . ' background-repeat: ' . get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'background-repeat' ) ) . ';' + . ' background-position: top ' . get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'background-position' ) ); } ?>
@@ -277,15 +277,15 @@ if ( get_background_image() ) {
@@ -294,10 +294,10 @@ if ( get_background_image() ) {
- - - - + + + +
@@ -305,12 +305,12 @@ if ( get_background_image() ) {
diff --git a/wp-includes/theme.php b/wp-includes/theme.php index e12ac74dfb..0f25c069ee 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1171,17 +1171,17 @@ function _custom_background_cb() { if ( $background ) { $image = " background-image: url('$background');"; - $repeat = get_theme_mod( 'background_repeat', 'repeat' ); + $repeat = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'background-repeat' ) ); if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) ) $repeat = 'repeat'; $repeat = " background-repeat: $repeat;"; - $position = get_theme_mod( 'background_position_x', 'left' ); + $position = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'background-position' ) ); if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) ) $position = 'left'; $position = " background-position: top $position;"; - $attachment = get_theme_mod( 'background_attachment', 'scroll' ); + $attachment = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'background-attachment' ) ); if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) ) $attachment = 'scroll'; $attachment = " background-attachment: $attachment;"; @@ -1373,10 +1373,13 @@ function add_theme_support( $feature ) { $args = array( 0 => array() ); $defaults = array( - 'default-image' => '', - 'default-color' => '', - 'wp-head-callback' => '_custom_background_cb', - 'admin-head-callback' => '', + 'default-image' => '', + 'background-repeat' => 'repeat', + 'background-position' => 'left', + 'background-attachment' => 'scroll', + 'default-color' => '', + 'wp-head-callback' => '_custom_background_cb', + 'admin-head-callback' => '', 'admin-preview-callback' => '', );