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.

git-svn-id: http://svn.automattic.com/wordpress/trunk@20276 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
koopersmith 2012-03-24 01:02:29 +00:00
parent 6f9ff90e86
commit cca689308c
4 changed files with 21 additions and 16 deletions

View File

@ -14,6 +14,7 @@ class WP_Customize_Setting {
public $section = '';
public $label = '';
public $control = 'text';
public $control_params = array();
public $type = 'theme_mod';
public $choices = array();
public $capability = 'edit_theme_options';

View File

@ -538,6 +538,9 @@ final class WP_Customize {
'section' => 'header',
'control' => 'upload',
'default' => get_theme_support( 'custom-header', 'default-image' ),
'control_params' => array(
'context' => 'custom-header',
),
) );
/* Custom Background */
@ -562,6 +565,9 @@ final class WP_Customize {
'section' => 'background',
'control' => 'upload',
'default' => get_theme_support( 'custom-background', 'default-image' ),
'control_params' => array(
'context' => 'custom-background',
),
) );
$this->add_setting( 'background_repeat', array(

View File

@ -103,6 +103,7 @@ do_action( 'customize_controls_print_scripts' );
$settings['controls'][ $id ] = array(
'value' => $setting->value(),
'control' => $setting->control,
'params' => $setting->control_params,
);
if ( $setting->visibility ) {

View File

@ -10,6 +10,7 @@
initialize: function( id, value, options ) {
var name = '[name="' + api.settings.prefix + id + '"]';
this.params = {};
api.Value.prototype.initialize.call( this, value, options );
this.id = id;
@ -90,6 +91,9 @@
});
this.bind( this.removerVisibility );
if ( this.params.context )
control.uploader.param( 'post_data[context]', this.params.context );
},
removerVisibility: function( on ) {
this.remover.toggle( !! on );
@ -240,6 +244,7 @@
control;
control = api.add( id, new constructor( id, data.value, {
params: data.params,
previewer: previewer
} ) );
@ -274,14 +279,6 @@
api( 'background_color', function( control ) {
control.method = 'postMessage';
});
api( 'background_image', function( control ) {
control.uploader.param( 'post_data[context]', 'custom-background' );
});
api( 'header_image', function( control ) {
control.uploader.param( 'post_data[context]', 'custom-header' );
});
});
})( wp, jQuery );