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:
parent
4641b2b4e0
commit
b6e48e5d81
|
@ -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;"';
|
||||||
|
|
|
@ -564,6 +564,46 @@ final class WP_Customize {
|
||||||
'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 */
|
||||||
|
|
|
@ -106,11 +106,19 @@ do_action( 'customize_controls_print_scripts' );
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $setting->visibility ) {
|
if ( $setting->visibility ) {
|
||||||
|
if ( is_string( $setting->visibility ) ) {
|
||||||
|
$settings['controls'][ $id ]['visibility'] = array(
|
||||||
|
'id' => $setting->visibility,
|
||||||
|
'value' => true,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
$settings['controls'][ $id ]['visibility'] = array(
|
$settings['controls'][ $id ]['visibility'] = array(
|
||||||
'id' => $setting->visibility[0],
|
'id' => $setting->visibility[0],
|
||||||
'value' => isset( $setting->visibility[1] ) ? $setting->visibility[1] : true,
|
'value' => $setting->visibility[1],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -245,9 +245,15 @@
|
||||||
|
|
||||||
if ( data.visibility ) {
|
if ( data.visibility ) {
|
||||||
api( data.visibility.id, function( other ) {
|
api( data.visibility.id, function( other ) {
|
||||||
|
if ( 'boolean' === typeof data.visibility.value ) {
|
||||||
|
other.bind( function( to ) {
|
||||||
|
control.container.toggle( !! to == data.visibility.value );
|
||||||
|
});
|
||||||
|
} else {
|
||||||
other.bind( function( to ) {
|
other.bind( function( to ) {
|
||||||
control.container.toggle( to == data.visibility.value );
|
control.container.toggle( to == data.visibility.value );
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue