Make WordPress Core

Changeset 20276


Ignore:
Timestamp:
03/24/2012 01:02:29 AM (13 years ago)
Author:
koopersmith
Message:

Theme Customizer: Add WP_Customizer_Setting->control_params, and wp.customize.Control.params to allow settings to pass arbitrary parameters to controls. Add the 'context' parameter to wp.customize.UploadControl. see #19910.

Location:
trunk/wp-includes
Files:
4 edited

Legend:

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

    r20263 r20276  
    1515    public $label             = '';
    1616    public $control           = 'text';
     17    public $control_params    = array();
    1718    public $type              = 'theme_mod';
    1819    public $choices           = array();
  • trunk/wp-includes/class-wp-customize.php

    r20274 r20276  
    535535        // With custom value
    536536        $this->add_setting( 'header_image', array(
    537             'label'   => 'Header Image',
    538             'section' => 'header',
    539             'control' => 'upload',
    540             'default' => get_theme_support( 'custom-header', 'default-image' ),
     537            'label'          => 'Header Image',
     538            'section'        => 'header',
     539            'control'        => 'upload',
     540            'default'        => get_theme_support( 'custom-header', 'default-image' ),
     541            'control_params' => array(
     542                'context'        => 'custom-header',
     543            ),
    541544        ) );
    542545
     
    559562
    560563        $this->add_setting( 'background_image', array(
    561             'label'   => 'Background Image',
    562             'section' => 'background',
    563             'control' => 'upload',
    564             'default' => get_theme_support( 'custom-background', 'default-image' ),
     564            'label'          => 'Background Image',
     565            'section'        => 'background',
     566            'control'        => 'upload',
     567            'default'        => get_theme_support( 'custom-background', 'default-image' ),
     568            'control_params' => array(
     569                'context'        => 'custom-background',
     570            ),
    565571        ) );
    566572
  • trunk/wp-includes/customize-controls.php

    r20266 r20276  
    104104            'value'   => $setting->value(),
    105105            'control' => $setting->control,
     106            'params'  => $setting->control_params,
    106107        );
    107108
  • trunk/wp-includes/js/customize-controls.dev.js

    r20274 r20276  
    1111            var name = '[name="' + api.settings.prefix + id + '"]';
    1212
     13            this.params = {};
    1314            api.Value.prototype.initialize.call( this, value, options );
    1415
     
    9192
    9293            this.bind( this.removerVisibility );
     94
     95            if ( this.params.context )
     96                control.uploader.param( 'post_data[context]', this.params.context );
    9397        },
    9498        removerVisibility: function( on ) {
     
    241245
    242246            control = api.add( id, new constructor( id, data.value, {
     247                params: data.params,
    243248                previewer: previewer
    244249            } ) );
     
    275280            control.method = 'postMessage';
    276281        });
    277 
    278         api( 'background_image', function( control ) {
    279             control.uploader.param( 'post_data[context]', 'custom-background' );
    280         });
    281 
    282         api( 'header_image', function( control ) {
    283             control.uploader.param( 'post_data[context]', 'custom-header' );
    284         });
    285282    });
    286283
Note: See TracChangeset for help on using the changeset viewer.