WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/29/2012 06:35:54 AM (8 years ago)
Author:
koopersmith
Message:

Theme Customizer: Move upload and image controls to subclasses. see #19910.

Instead of grouping together every control parameter into a single array and passing them all to the JS, use subclasses with custom parameters to implement additional PHP functionality and the parameter to send only the necessary variables to the JavaScript control.

Replaces WP_Customize_Control->control_params with WP_Customize_Control->json and WP_Customize_Control->to_json(). The to_json() method refreshes the json array passed to the JavaScript control (set to control.param by default).

Creates WP_Customize_Upload_Control and WP_Customize_Image_Control.

File:
1 edited

Legend:

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

    r20295 r20319  
    108108
    109109    foreach ( $this->controls as $id => $control ) {
    110         $settings['controls'][ $id ] = $control->json();
    111 
    112         if ( $control->visibility ) {
    113             if ( is_string( $control->visibility ) ) {
    114                 $settings['controls'][ $id ]['visibility'] = array(
    115                     'id'    => $control->visibility,
    116                     'value' => true,
    117                 );
    118             } else {
    119                 $settings['controls'][ $id ]['visibility'] = array(
    120                     'id'    => $control->visibility[0],
    121                     'value' => $control->visibility[1],
    122                 );
    123             }
    124 
    125         }
     110        $control->to_json();
     111        $settings['controls'][ $id ] = $control->json;
    126112    }
    127113
Note: See TracChangeset for help on using the changeset viewer.