Create WP_Customize_Control to separate the process of rendering a control from fetching, previewing, and saving its values. see #19910.

Many-to-many mapping between settings and controls.
* Settings and controls have been separated in both the PHP (WP_Customize_Setting, WP_Customize_Control) and the JS (wp.customize.Setting, wp.customize.Control).
* While most settings are tied to a single control, some require multiple controls. The 'header_textcolor' control is a good example: to hide the header text, header_textcolor is set to 'blank'.

Add 'Display Header Text' control.

A handful of miscellaneous bugfixes along the way.

Notes:
* Controls should be separated out a bit more; juggling type-specific arguments in the switch statement is rather inelegant.
* Page dropdowns are currently inactive and need to be re-linked.

git-svn-id: https://develop.svn.wordpress.org/trunk@20295 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Daryl Koopersmith
2012-03-28 04:14:09 +00:00
parent 4337bd15e7
commit 2ca07cdf2a
8 changed files with 653 additions and 386 deletions

View File

@@ -95,27 +95,30 @@ do_action( 'customize_controls_print_scripts' );
$scheme = is_ssl() ? 'https' : 'http';
$settings = array(
'preview' => esc_url( home_url( '/', $scheme ) ),
'settings' => array(),
'controls' => array(),
'prefix' => WP_Customize_Setting::name_prefix,
);
foreach ( $this->settings as $id => $setting ) {
$settings['controls'][ $id ] = array(
$settings['settings'][ $id ] = array(
'value' => $setting->value(),
'control' => $setting->control,
'params' => $setting->control_params,
);
}
if ( $setting->visibility ) {
if ( is_string( $setting->visibility ) ) {
foreach ( $this->controls as $id => $control ) {
$settings['controls'][ $id ] = $control->json();
if ( $control->visibility ) {
if ( is_string( $control->visibility ) ) {
$settings['controls'][ $id ]['visibility'] = array(
'id' => $setting->visibility,
'id' => $control->visibility,
'value' => true,
);
} else {
$settings['controls'][ $id ]['visibility'] = array(
'id' => $setting->visibility[0],
'value' => $setting->visibility[1],
'id' => $control->visibility[0],
'value' => $control->visibility[1],
);
}