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 $default = '';
|
||||
public $sanitize_callback = '';
|
||||
public $transport = 'refresh';
|
||||
|
||||
protected $id_data = array();
|
||||
private $_post_value; // Cached, sanitized $_POST value.
|
||||
|
|
|
@ -580,6 +580,7 @@ final class WP_Customize {
|
|||
'default' => get_theme_support( 'custom-background', 'default-color' ),
|
||||
'sanitize_callback' => 'sanitize_hexcolor',
|
||||
'theme_supports' => 'custom-background',
|
||||
'transport' => 'postMessage',
|
||||
) );
|
||||
|
||||
$this->add_control( 'background_color', array(
|
||||
|
|
|
@ -105,6 +105,7 @@ do_action( 'customize_controls_print_scripts' );
|
|||
foreach ( $this->settings as $id => $setting ) {
|
||||
$settings['settings'][ $id ] = array(
|
||||
'value' => $setting->value(),
|
||||
'transport' => $setting->transport,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/*
|
||||
* @param options
|
||||
* - 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({
|
||||
initialize: function( id, value, options ) {
|
||||
|
@ -13,7 +13,7 @@
|
|||
api.Value.prototype.initialize.call( this, value, options );
|
||||
|
||||
this.id = id;
|
||||
this.method = this.method || 'refresh';
|
||||
this.transport = this.transport || 'refresh';
|
||||
|
||||
element = $( '<input />', {
|
||||
type: 'hidden',
|
||||
|
@ -28,7 +28,7 @@
|
|||
this.bind( this.preview );
|
||||
},
|
||||
preview: function() {
|
||||
switch ( this.method ) {
|
||||
switch ( this.transport ) {
|
||||
case 'refresh':
|
||||
return this.previewer.refresh();
|
||||
case 'postMessage':
|
||||
|
@ -403,6 +403,7 @@
|
|||
|
||||
$.each( api.settings.settings, function( id, data ) {
|
||||
api.set( id, id, data.value, {
|
||||
transport: data.transport,
|
||||
previewer: previewer
|
||||
} );
|
||||
});
|
||||
|
@ -434,11 +435,6 @@
|
|||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Background color uses postMessage by default
|
||||
api( 'background_color', function( setting ) {
|
||||
setting.method = 'postMessage';
|
||||
});
|
||||
|
||||
// Control visibility for default controls
|
||||
$.each({
|
||||
'background_image': {
|
||||
|
|
Loading…
Reference in New Issue