Make WordPress Core


Ignore:
Timestamp:
03/29/2012 06:35:54 AM (13 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/class-wp-customize.php

    r20306 r20319  
    586586        ) );
    587587
    588         $this->add_control( 'header_image', array(
     588        $this->add_control( new WP_Customize_Image_Control( $this, 'header_image', array(
    589589            'label'          => 'Header Image',
    590590            'section'        => 'header',
    591             'type'           => 'image',
    592             'control_params' => array(
    593                 'context'        => 'custom-header',
    594                 'removed'        => 'remove-header',
    595                 'get_url'        => 'get_header_image',
    596                 'tabs'           => array(
    597                     array( 'uploaded', __('Uploaded'), 'wp_customize_print_uploaded_headers' ),
    598                     array( 'included', __('Included'), 'wp_customize_print_included_headers' ),
    599                 ),
     591            'context'        => 'custom-header',
     592            'removed'        => 'remove-header',
     593            'get_url'        => 'get_header_image',
     594            'tabs'           => array(
     595                array( 'uploaded', __('Uploaded'), 'wp_customize_print_uploaded_headers' ),
     596                array( 'included', __('Included'), 'wp_customize_print_included_headers' ),
    600597            ),
    601         ) );
     598        ) ) );
    602599
    603600        /* Custom Background */
     
    628625        ) );
    629626
    630         $this->add_control( 'background_image', array(
     627        $this->add_control( new WP_Customize_Upload_Control( $this, 'background_image', array(
    631628            'label'          => __( 'Background Image' ),
    632629            'section'        => 'background',
    633630            'type'           => 'upload',
    634             'control_params' => array(
    635                 'context'        => 'custom-background',
    636             ),
    637         ) );
     631            'context'        => 'custom-background',
     632        ) ) );
    638633
    639634        $this->add_setting( 'background_repeat', array(
Note: See TracChangeset for help on using the changeset viewer.