diff --git a/wp-includes/class-wp-customize-setting.php b/wp-includes/class-wp-customize-setting.php index b52ec981ae..1fa0f7c6b7 100644 --- a/wp-includes/class-wp-customize-setting.php +++ b/wp-includes/class-wp-customize-setting.php @@ -308,8 +308,14 @@ class WP_Customize_Setting { $style = ''; if ( $this->visibility ) { - $visibility_setting = $this->manager->get_setting( $this->visibility[0] ); - $visibility_value = isset( $this->visibility[1] ) ? $this->visibility[1] : true; + if ( is_string( $this->visibility ) ) { + $visibility_id = $this->visibility; + $visibility_value = true; + } else { + $visibility_id = $this->visibility[0]; + $visibility_value = $this->visibility[1]; + } + $visibility_setting = $this->manager->get_setting( $visibility_id ); if ( $visibility_setting && $visibility_value != $visibility_setting->value() ) $style = 'style="display:none;"'; diff --git a/wp-includes/class-wp-customize.php b/wp-includes/class-wp-customize.php index 2bba95663e..2a345c87b3 100644 --- a/wp-includes/class-wp-customize.php +++ b/wp-includes/class-wp-customize.php @@ -561,9 +561,49 @@ final class WP_Customize { ) ); $this->add_setting( 'background_image', array( - 'label' => 'Background Image', - 'section' => 'background', - 'control' => 'upload', + 'label' => 'Background Image', + 'section' => 'background', + 'control' => 'upload', + 'default' => get_theme_support( 'custom-background', 'default-image' ), + ) ); + + $this->add_setting( 'background_repeat', array( + 'label' => 'Background Repeat', + 'section' => 'background', + 'visibility' => 'background_image', + 'control' => 'radio', + 'choices' => array( + 'no-repeat' => __('No Repeat'), + 'repeat' => __('Tile'), + 'repeat-x' => __('Tile Horizontally'), + 'repeat-y' => __('Tile Vertically'), + ), + 'default' => 'repeat', + ) ); + + $this->add_setting( 'background_position_x', array( + 'label' => 'Background Position', + 'section' => 'background', + 'visibility' => 'background_image', + 'control' => 'radio', + 'choices' => array( + 'left' => __('Left'), + 'center' => __('Center'), + 'right' => __('Right'), + ), + 'default' => 'left', + ) ); + + $this->add_setting( 'background_attachment', array( + 'label' => 'Background Attachment', + 'section' => 'background', + 'visibility' => 'background_image', + 'control' => 'radio', + 'choices' => array( + 'fixed' => __('Fixed'), + 'scroll' => __('Scroll'), + ), + 'default' => 'fixed', ) ); /* Nav Menus */ diff --git a/wp-includes/customize-controls.php b/wp-includes/customize-controls.php index 8de52be33f..4ce2127b68 100644 --- a/wp-includes/customize-controls.php +++ b/wp-includes/customize-controls.php @@ -106,10 +106,18 @@ do_action( 'customize_controls_print_scripts' ); ); if ( $setting->visibility ) { - $settings['controls'][ $id ]['visibility'] = array( - 'id' => $setting->visibility[0], - 'value' => isset( $setting->visibility[1] ) ? $setting->visibility[1] : true, - ); + if ( is_string( $setting->visibility ) ) { + $settings['controls'][ $id ]['visibility'] = array( + 'id' => $setting->visibility, + 'value' => true, + ); + } else { + $settings['controls'][ $id ]['visibility'] = array( + 'id' => $setting->visibility[0], + 'value' => $setting->visibility[1], + ); + } + } } diff --git a/wp-includes/js/customize-controls.dev.js b/wp-includes/js/customize-controls.dev.js index e645794968..315211ec9e 100644 --- a/wp-includes/js/customize-controls.dev.js +++ b/wp-includes/js/customize-controls.dev.js @@ -245,9 +245,15 @@ if ( data.visibility ) { api( data.visibility.id, function( other ) { - other.bind( function( to ) { - control.container.toggle( to == data.visibility.value ); - }); + if ( 'boolean' === typeof data.visibility.value ) { + other.bind( function( to ) { + control.container.toggle( !! to == data.visibility.value ); + }); + } else { + other.bind( function( to ) { + control.container.toggle( to == data.visibility.value ); + }); + } }); } });