Theme Customizer: Add background repeat, position, and attachment settings. Change visibility parameter to accept a string or array( , ). see #19910.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20263 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
koopersmith 2012-03-22 08:07:44 +00:00
parent 4641b2b4e0
commit b6e48e5d81
4 changed files with 72 additions and 12 deletions

View File

@ -308,8 +308,14 @@ class WP_Customize_Setting {
$style = ''; $style = '';
if ( $this->visibility ) { if ( $this->visibility ) {
$visibility_setting = $this->manager->get_setting( $this->visibility[0] ); if ( is_string( $this->visibility ) ) {
$visibility_value = isset( $this->visibility[1] ) ? $this->visibility[1] : true; $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() ) if ( $visibility_setting && $visibility_value != $visibility_setting->value() )
$style = 'style="display:none;"'; $style = 'style="display:none;"';

View File

@ -561,9 +561,49 @@ final class WP_Customize {
) ); ) );
$this->add_setting( 'background_image', array( $this->add_setting( 'background_image', array(
'label' => 'Background Image', 'label' => 'Background Image',
'section' => 'background', 'section' => 'background',
'control' => 'upload', '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 */ /* Nav Menus */

View File

@ -106,10 +106,18 @@ do_action( 'customize_controls_print_scripts' );
); );
if ( $setting->visibility ) { if ( $setting->visibility ) {
$settings['controls'][ $id ]['visibility'] = array( if ( is_string( $setting->visibility ) ) {
'id' => $setting->visibility[0], $settings['controls'][ $id ]['visibility'] = array(
'value' => isset( $setting->visibility[1] ) ? $setting->visibility[1] : true, 'id' => $setting->visibility,
); 'value' => true,
);
} else {
$settings['controls'][ $id ]['visibility'] = array(
'id' => $setting->visibility[0],
'value' => $setting->visibility[1],
);
}
} }
} }

View File

@ -245,9 +245,15 @@
if ( data.visibility ) { if ( data.visibility ) {
api( data.visibility.id, function( other ) { api( data.visibility.id, function( other ) {
other.bind( function( to ) { if ( 'boolean' === typeof data.visibility.value ) {
control.container.toggle( to == 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 );
});
}
}); });
} }
}); });