Make WordPress Core


Ignore:
Timestamp:
03/28/2012 04:14:09 AM (13 years ago)
Author:
koopersmith
Message:

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/customize-controls.php

    r20276 r20295  
    9696    $settings = array(
    9797        'preview'  => esc_url( home_url( '/', $scheme ) ),
     98        'settings' => array(),
    9899        'controls' => array(),
    99100        'prefix'   => WP_Customize_Setting::name_prefix,
     
    101102
    102103    foreach ( $this->settings as $id => $setting ) {
    103         $settings['controls'][ $id ] = array(
     104        $settings['settings'][ $id ] = array(
    104105            'value'   => $setting->value(),
    105             'control' => $setting->control,
    106             'params'  => $setting->control_params,
    107106        );
     107    }
    108108
    109         if ( $setting->visibility ) {
    110             if ( is_string( $setting->visibility ) ) {
     109    foreach ( $this->controls as $id => $control ) {
     110        $settings['controls'][ $id ] = $control->json();
     111
     112        if ( $control->visibility ) {
     113            if ( is_string( $control->visibility ) ) {
    111114                $settings['controls'][ $id ]['visibility'] = array(
    112                     'id'    => $setting->visibility,
     115                    'id'    => $control->visibility,
    113116                    'value' => true,
    114117                );
    115118            } else {
    116119                $settings['controls'][ $id ]['visibility'] = array(
    117                     'id'    => $setting->visibility[0],
    118                     'value' => $setting->visibility[1],
     120                    'id'    => $control->visibility[0],
     121                    'value' => $control->visibility[1],
    119122                );
    120123            }
Note: See TracChangeset for help on using the changeset viewer.