mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-02 11:21:57 +01:00
Theme Customizer: For clarity, wp.customize.Setting.method to wp.customize.Setting.transport. Add WP_Customize_Setting->transport to allow setting the transport method via PHP. see #19910.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20585 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f9ac486930
commit
863a458165
@ -16,6 +16,7 @@ class WP_Customize_Setting {
|
|||||||
public $theme_supports = '';
|
public $theme_supports = '';
|
||||||
public $default = '';
|
public $default = '';
|
||||||
public $sanitize_callback = '';
|
public $sanitize_callback = '';
|
||||||
|
public $transport = 'refresh';
|
||||||
|
|
||||||
protected $id_data = array();
|
protected $id_data = array();
|
||||||
private $_post_value; // Cached, sanitized $_POST value.
|
private $_post_value; // Cached, sanitized $_POST value.
|
||||||
|
@ -580,6 +580,7 @@ final class WP_Customize {
|
|||||||
'default' => get_theme_support( 'custom-background', 'default-color' ),
|
'default' => get_theme_support( 'custom-background', 'default-color' ),
|
||||||
'sanitize_callback' => 'sanitize_hexcolor',
|
'sanitize_callback' => 'sanitize_hexcolor',
|
||||||
'theme_supports' => 'custom-background',
|
'theme_supports' => 'custom-background',
|
||||||
|
'transport' => 'postMessage',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$this->add_control( 'background_color', array(
|
$this->add_control( 'background_color', array(
|
||||||
|
@ -104,7 +104,8 @@ do_action( 'customize_controls_print_scripts' );
|
|||||||
|
|
||||||
foreach ( $this->settings as $id => $setting ) {
|
foreach ( $this->settings as $id => $setting ) {
|
||||||
$settings['settings'][ $id ] = array(
|
$settings['settings'][ $id ] = array(
|
||||||
'value' => $setting->value(),
|
'value' => $setting->value(),
|
||||||
|
'transport' => $setting->transport,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
/*
|
/*
|
||||||
* @param options
|
* @param options
|
||||||
* - previewer - The Previewer instance to sync with.
|
* - previewer - The Previewer instance to sync with.
|
||||||
* - method - The method to use for previewing. Supports 'refresh' and 'postMessage'.
|
* - transport - The transport to use for previewing. Supports 'refresh' and 'postMessage'.
|
||||||
*/
|
*/
|
||||||
api.Setting = api.Value.extend({
|
api.Setting = api.Value.extend({
|
||||||
initialize: function( id, value, options ) {
|
initialize: function( id, value, options ) {
|
||||||
@ -13,7 +13,7 @@
|
|||||||
api.Value.prototype.initialize.call( this, value, options );
|
api.Value.prototype.initialize.call( this, value, options );
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.method = this.method || 'refresh';
|
this.transport = this.transport || 'refresh';
|
||||||
|
|
||||||
element = $( '<input />', {
|
element = $( '<input />', {
|
||||||
type: 'hidden',
|
type: 'hidden',
|
||||||
@ -28,7 +28,7 @@
|
|||||||
this.bind( this.preview );
|
this.bind( this.preview );
|
||||||
},
|
},
|
||||||
preview: function() {
|
preview: function() {
|
||||||
switch ( this.method ) {
|
switch ( this.transport ) {
|
||||||
case 'refresh':
|
case 'refresh':
|
||||||
return this.previewer.refresh();
|
return this.previewer.refresh();
|
||||||
case 'postMessage':
|
case 'postMessage':
|
||||||
@ -403,6 +403,7 @@
|
|||||||
|
|
||||||
$.each( api.settings.settings, function( id, data ) {
|
$.each( api.settings.settings, function( id, data ) {
|
||||||
api.set( id, id, data.value, {
|
api.set( id, id, data.value, {
|
||||||
|
transport: data.transport,
|
||||||
previewer: previewer
|
previewer: previewer
|
||||||
} );
|
} );
|
||||||
});
|
});
|
||||||
@ -434,11 +435,6 @@
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Background color uses postMessage by default
|
|
||||||
api( 'background_color', function( setting ) {
|
|
||||||
setting.method = 'postMessage';
|
|
||||||
});
|
|
||||||
|
|
||||||
// Control visibility for default controls
|
// Control visibility for default controls
|
||||||
$.each({
|
$.each({
|
||||||
'background_image': {
|
'background_image': {
|
||||||
|
Loading…
Reference in New Issue
Block a user