mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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:
parent
6f9ff90e86
commit
cca689308c
@ -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';
|
||||
|
@ -534,10 +534,13 @@ final class WP_Customize {
|
||||
// Input type: checkbox
|
||||
// With custom value
|
||||
$this->add_setting( 'header_image', array(
|
||||
'label' => 'Header Image',
|
||||
'section' => 'header',
|
||||
'control' => 'upload',
|
||||
'default' => get_theme_support( 'custom-header', 'default-image' ),
|
||||
'label' => 'Header Image',
|
||||
'section' => 'header',
|
||||
'control' => 'upload',
|
||||
'default' => get_theme_support( 'custom-header', 'default-image' ),
|
||||
'control_params' => array(
|
||||
'context' => 'custom-header',
|
||||
),
|
||||
) );
|
||||
|
||||
/* Custom Background */
|
||||
@ -558,10 +561,13 @@ final class WP_Customize {
|
||||
) );
|
||||
|
||||
$this->add_setting( 'background_image', array(
|
||||
'label' => 'Background Image',
|
||||
'section' => 'background',
|
||||
'control' => 'upload',
|
||||
'default' => get_theme_support( 'custom-background', 'default-image' ),
|
||||
'label' => 'Background Image',
|
||||
'section' => 'background',
|
||||
'control' => 'upload',
|
||||
'default' => get_theme_support( 'custom-background', 'default-image' ),
|
||||
'control_params' => array(
|
||||
'context' => 'custom-background',
|
||||
),
|
||||
) );
|
||||
|
||||
$this->add_setting( 'background_repeat', array(
|
||||
|
@ -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 ) {
|
||||
|
@ -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 );
|
Loading…
Reference in New Issue
Block a user