Remove 'visibility' parameter from WP_Customize_Control. Handle control visibility in JS instead. see #19910.

* Have the header text color picker display only when header_textcolor != 'blank'



git-svn-id: https://develop.svn.wordpress.org/trunk@20506 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Daryl Koopersmith 2012-04-18 17:13:31 +00:00
parent d4e2dfabd0
commit ae95c22e27
3 changed files with 31 additions and 52 deletions

View File

@ -22,8 +22,6 @@ class WP_Customize_Control {
public $json = array();
public $visibility;
public $type = 'text';
@ -102,21 +100,6 @@ class WP_Customize_Control {
}
$this->json['type'] = $this->type;
if ( $this->visibility ) {
if ( is_string( $this->visibility ) ) {
$this->json['visibility'] = array(
'id' => $this->visibility,
'value' => true,
);
} else {
$this->json['visibility'] = array(
'id' => $this->visibility[0],
'value' => $this->visibility[1],
);
}
}
}
/**
@ -163,22 +146,7 @@ class WP_Customize_Control {
$id = 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) );
$class = 'customize-control customize-control-' . $this->type;
$style = '';
if ( $this->visibility ) {
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;"';
}
?><li id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>" <?php echo $style; ?>>
?><li id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>">
<?php $this->render_content(); ?>
</li><?php
}

View File

@ -591,7 +591,6 @@ final class WP_Customize {
$this->add_control( 'background_repeat', array(
'label' => __( 'Background Repeat' ),
'section' => 'background',
'visibility' => 'background_image',
'type' => 'radio',
'choices' => array(
'no-repeat' => __('No Repeat'),
@ -609,7 +608,6 @@ final class WP_Customize {
$this->add_control( 'background_position_x', array(
'label' => __( 'Background Position' ),
'section' => 'background',
'visibility' => 'background_image',
'type' => 'radio',
'choices' => array(
'left' => __('Left'),
@ -626,7 +624,6 @@ final class WP_Customize {
$this->add_control( 'background_attachment', array(
'label' => __( 'Background Attachment' ),
'section' => 'background',
'visibility' => 'background_image',
'type' => 'radio',
'choices' => array(
'fixed' => __('Fixed'),
@ -708,7 +705,6 @@ final class WP_Customize {
'label' => __( 'Front page' ),
'section' => 'static_front_page',
'type' => 'dropdown-pages',
'visibility' => array( 'show_on_front', 'page' ),
) );
$this->add_setting( 'page_for_posts', array(
@ -721,7 +717,6 @@ final class WP_Customize {
'label' => __( 'Posts page' ),
'section' => 'static_front_page',
'type' => 'dropdown-pages',
'visibility' => array( 'show_on_front', 'page' ),
) );
/* Site Title & Tagline */

View File

@ -377,20 +377,6 @@
params: data,
previewer: previewer
} ) );
if ( data.visibility ) {
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 ) {
control.container.toggle( to == data.visibility.value );
});
}
});
}
});
// Temporary accordion code.
@ -415,6 +401,36 @@
setting.method = 'postMessage';
});
// Control visibility for default controls
$.each({
'background_image': {
controls: [ 'background_repeat', 'background_position_x', 'background_attachment' ],
callback: function( to ) { return !! to }
},
'show_on_front': {
controls: [ 'page_on_front', 'page_for_posts' ],
callback: function( to ) { return 'page' === to }
},
'header_textcolor': {
controls: [ 'header_textcolor' ],
callback: function( to ) { return 'blank' !== to }
}
}, function( settingId, o ) {
api( settingId, function( setting ) {
$.each( o.controls, function( i, controlId ) {
api.control( controlId, function( control ) {
var visibility = function( to ) {
control.container.toggle( o.callback( to ) );
};
visibility( setting.get() );
setting.bind( visibility );
});
});
});
});
// Juggle the two controls that use header_textcolor
api.control( 'display_header_text', function( control ) {
var last = '';