Edit File by line
/home/zeestwma/redstone.../wp-inclu...
File: class-wp-customize-setting.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WordPress Customize Setting classes
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Customize
[5] Fix | Delete
* @since 3.4.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
// Don't load directly.
[9] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[10] Fix | Delete
die( '-1' );
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Customize Setting class.
[15] Fix | Delete
*
[16] Fix | Delete
* Handles saving and sanitizing of settings.
[17] Fix | Delete
*
[18] Fix | Delete
* @since 3.4.0
[19] Fix | Delete
*
[20] Fix | Delete
* @see WP_Customize_Manager
[21] Fix | Delete
* @link https://developer.wordpress.org/themes/customize-api
[22] Fix | Delete
*/
[23] Fix | Delete
#[AllowDynamicProperties]
[24] Fix | Delete
class WP_Customize_Setting {
[25] Fix | Delete
/**
[26] Fix | Delete
* Customizer bootstrap instance.
[27] Fix | Delete
*
[28] Fix | Delete
* @since 3.4.0
[29] Fix | Delete
* @var WP_Customize_Manager
[30] Fix | Delete
*/
[31] Fix | Delete
public $manager;
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Unique string identifier for the setting.
[35] Fix | Delete
*
[36] Fix | Delete
* @since 3.4.0
[37] Fix | Delete
* @var string
[38] Fix | Delete
*/
[39] Fix | Delete
public $id;
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Type of customize settings.
[43] Fix | Delete
*
[44] Fix | Delete
* @since 3.4.0
[45] Fix | Delete
* @var string
[46] Fix | Delete
*/
[47] Fix | Delete
public $type = 'theme_mod';
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Capability required to edit this setting.
[51] Fix | Delete
*
[52] Fix | Delete
* @since 3.4.0
[53] Fix | Delete
* @var string|array
[54] Fix | Delete
*/
[55] Fix | Delete
public $capability = 'edit_theme_options';
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Theme features required to support the setting.
[59] Fix | Delete
*
[60] Fix | Delete
* @since 3.4.0
[61] Fix | Delete
* @var string|string[]
[62] Fix | Delete
*/
[63] Fix | Delete
public $theme_supports = '';
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* The default value for the setting.
[67] Fix | Delete
*
[68] Fix | Delete
* @since 3.4.0
[69] Fix | Delete
* @var string
[70] Fix | Delete
*/
[71] Fix | Delete
public $default = '';
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Options for rendering the live preview of changes in Customizer.
[75] Fix | Delete
*
[76] Fix | Delete
* Set this value to 'postMessage' to enable a custom JavaScript handler to render changes to this setting
[77] Fix | Delete
* as opposed to reloading the whole page.
[78] Fix | Delete
*
[79] Fix | Delete
* @since 3.4.0
[80] Fix | Delete
* @var string
[81] Fix | Delete
*/
[82] Fix | Delete
public $transport = 'refresh';
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Server-side validation callback for the setting's value.
[86] Fix | Delete
*
[87] Fix | Delete
* @since 4.6.0
[88] Fix | Delete
* @var callable
[89] Fix | Delete
*/
[90] Fix | Delete
public $validate_callback = '';
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Callback to filter a Customize setting value in un-slashed form.
[94] Fix | Delete
*
[95] Fix | Delete
* @since 3.4.0
[96] Fix | Delete
* @var callable
[97] Fix | Delete
*/
[98] Fix | Delete
public $sanitize_callback = '';
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Callback to convert a Customize PHP setting value to a value that is JSON serializable.
[102] Fix | Delete
*
[103] Fix | Delete
* @since 3.4.0
[104] Fix | Delete
* @var callable
[105] Fix | Delete
*/
[106] Fix | Delete
public $sanitize_js_callback = '';
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Whether or not the setting is initially dirty when created.
[110] Fix | Delete
*
[111] Fix | Delete
* This is used to ensure that a setting will be sent from the pane to the
[112] Fix | Delete
* preview when loading the Customizer. Normally a setting only is synced to
[113] Fix | Delete
* the preview if it has been changed. This allows the setting to be sent
[114] Fix | Delete
* from the start.
[115] Fix | Delete
*
[116] Fix | Delete
* @since 4.2.0
[117] Fix | Delete
* @var bool
[118] Fix | Delete
*/
[119] Fix | Delete
public $dirty = false;
[120] Fix | Delete
[121] Fix | Delete
/**
[122] Fix | Delete
* ID Data.
[123] Fix | Delete
*
[124] Fix | Delete
* @since 3.4.0
[125] Fix | Delete
* @var array
[126] Fix | Delete
*/
[127] Fix | Delete
protected $id_data = array();
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* Whether or not preview() was called.
[131] Fix | Delete
*
[132] Fix | Delete
* @since 4.4.0
[133] Fix | Delete
* @var bool
[134] Fix | Delete
*/
[135] Fix | Delete
protected $is_previewed = false;
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* Cache of multidimensional values to improve performance.
[139] Fix | Delete
*
[140] Fix | Delete
* @since 4.4.0
[141] Fix | Delete
* @var array
[142] Fix | Delete
*/
[143] Fix | Delete
protected static $aggregated_multidimensionals = array();
[144] Fix | Delete
[145] Fix | Delete
/**
[146] Fix | Delete
* Whether the multidimensional setting is aggregated.
[147] Fix | Delete
*
[148] Fix | Delete
* @since 4.4.0
[149] Fix | Delete
* @var bool
[150] Fix | Delete
*/
[151] Fix | Delete
protected $is_multidimensional_aggregated = false;
[152] Fix | Delete
[153] Fix | Delete
/**
[154] Fix | Delete
* Constructor.
[155] Fix | Delete
*
[156] Fix | Delete
* Any supplied $args override class property defaults.
[157] Fix | Delete
*
[158] Fix | Delete
* @since 3.4.0
[159] Fix | Delete
*
[160] Fix | Delete
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
[161] Fix | Delete
* @param string $id A specific ID of the setting.
[162] Fix | Delete
* Can be a theme mod or option name.
[163] Fix | Delete
* @param array $args {
[164] Fix | Delete
* Optional. Array of properties for the new Setting object. Default empty array.
[165] Fix | Delete
*
[166] Fix | Delete
* @type string $type Type of the setting. Default 'theme_mod'.
[167] Fix | Delete
* @type string $capability Capability required for the setting. Default 'edit_theme_options'
[168] Fix | Delete
* @type string|string[] $theme_supports Theme features required to support the panel. Default is none.
[169] Fix | Delete
* @type string $default Default value for the setting. Default is empty string.
[170] Fix | Delete
* @type string $transport Options for rendering the live preview of changes in Customizer.
[171] Fix | Delete
* Using 'refresh' makes the change visible by reloading the whole preview.
[172] Fix | Delete
* Using 'postMessage' allows a custom JavaScript to handle live changes.
[173] Fix | Delete
* Default is 'refresh'.
[174] Fix | Delete
* @type callable $validate_callback Server-side validation callback for the setting's value.
[175] Fix | Delete
* @type callable $sanitize_callback Callback to filter a Customize setting value in un-slashed form.
[176] Fix | Delete
* @type callable $sanitize_js_callback Callback to convert a Customize PHP setting value to a value that is
[177] Fix | Delete
* JSON serializable.
[178] Fix | Delete
* @type bool $dirty Whether or not the setting is initially dirty when created.
[179] Fix | Delete
* }
[180] Fix | Delete
*/
[181] Fix | Delete
public function __construct( $manager, $id, $args = array() ) {
[182] Fix | Delete
$keys = array_keys( get_object_vars( $this ) );
[183] Fix | Delete
foreach ( $keys as $key ) {
[184] Fix | Delete
if ( isset( $args[ $key ] ) ) {
[185] Fix | Delete
$this->$key = $args[ $key ];
[186] Fix | Delete
}
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
$this->manager = $manager;
[190] Fix | Delete
$this->id = $id;
[191] Fix | Delete
[192] Fix | Delete
// Parse the ID for array keys.
[193] Fix | Delete
$this->id_data['keys'] = preg_split( '/\[/', str_replace( ']', '', $this->id ) );
[194] Fix | Delete
$this->id_data['base'] = array_shift( $this->id_data['keys'] );
[195] Fix | Delete
[196] Fix | Delete
// Rebuild the ID.
[197] Fix | Delete
$this->id = $this->id_data['base'];
[198] Fix | Delete
if ( ! empty( $this->id_data['keys'] ) ) {
[199] Fix | Delete
$this->id .= '[' . implode( '][', $this->id_data['keys'] ) . ']';
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
if ( $this->validate_callback ) {
[203] Fix | Delete
add_filter( "customize_validate_{$this->id}", $this->validate_callback, 10, 3 );
[204] Fix | Delete
}
[205] Fix | Delete
if ( $this->sanitize_callback ) {
[206] Fix | Delete
add_filter( "customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2 );
[207] Fix | Delete
}
[208] Fix | Delete
if ( $this->sanitize_js_callback ) {
[209] Fix | Delete
add_filter( "customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2 );
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
if ( 'option' === $this->type || 'theme_mod' === $this->type ) {
[213] Fix | Delete
// Other setting types can opt-in to aggregate multidimensional explicitly.
[214] Fix | Delete
$this->aggregate_multidimensional();
[215] Fix | Delete
[216] Fix | Delete
// Allow option settings to indicate whether they should be autoloaded.
[217] Fix | Delete
if ( 'option' === $this->type && isset( $args['autoload'] ) ) {
[218] Fix | Delete
self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] = $args['autoload'];
[219] Fix | Delete
}
[220] Fix | Delete
}
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
/**
[224] Fix | Delete
* Get parsed ID data for multidimensional setting.
[225] Fix | Delete
*
[226] Fix | Delete
* @since 4.4.0
[227] Fix | Delete
*
[228] Fix | Delete
* @return array {
[229] Fix | Delete
* ID data for multidimensional setting.
[230] Fix | Delete
*
[231] Fix | Delete
* @type string $base ID base
[232] Fix | Delete
* @type array $keys Keys for multidimensional array.
[233] Fix | Delete
* }
[234] Fix | Delete
*/
[235] Fix | Delete
final public function id_data() {
[236] Fix | Delete
return $this->id_data;
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
/**
[240] Fix | Delete
* Set up the setting for aggregated multidimensional values.
[241] Fix | Delete
*
[242] Fix | Delete
* When a multidimensional setting gets aggregated, all of its preview and update
[243] Fix | Delete
* calls get combined into one call, greatly improving performance.
[244] Fix | Delete
*
[245] Fix | Delete
* @since 4.4.0
[246] Fix | Delete
*/
[247] Fix | Delete
protected function aggregate_multidimensional() {
[248] Fix | Delete
$id_base = $this->id_data['base'];
[249] Fix | Delete
if ( ! isset( self::$aggregated_multidimensionals[ $this->type ] ) ) {
[250] Fix | Delete
self::$aggregated_multidimensionals[ $this->type ] = array();
[251] Fix | Delete
}
[252] Fix | Delete
if ( ! isset( self::$aggregated_multidimensionals[ $this->type ][ $id_base ] ) ) {
[253] Fix | Delete
self::$aggregated_multidimensionals[ $this->type ][ $id_base ] = array(
[254] Fix | Delete
'previewed_instances' => array(), // Calling preview() will add the $setting to the array.
[255] Fix | Delete
'preview_applied_instances' => array(), // Flags for which settings have had their values applied.
[256] Fix | Delete
'root_value' => $this->get_root_value( array() ), // Root value for initial state, manipulated by preview and update calls.
[257] Fix | Delete
);
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
if ( ! empty( $this->id_data['keys'] ) ) {
[261] Fix | Delete
// Note the preview-applied flag is cleared at priority 9 to ensure it is cleared before a deferred-preview runs.
[262] Fix | Delete
add_action( "customize_post_value_set_{$this->id}", array( $this, '_clear_aggregated_multidimensional_preview_applied_flag' ), 9 );
[263] Fix | Delete
$this->is_multidimensional_aggregated = true;
[264] Fix | Delete
}
[265] Fix | Delete
}
[266] Fix | Delete
[267] Fix | Delete
/**
[268] Fix | Delete
* Reset `$aggregated_multidimensionals` static variable.
[269] Fix | Delete
*
[270] Fix | Delete
* This is intended only for use by unit tests.
[271] Fix | Delete
*
[272] Fix | Delete
* @since 4.5.0
[273] Fix | Delete
* @ignore
[274] Fix | Delete
*/
[275] Fix | Delete
public static function reset_aggregated_multidimensionals() {
[276] Fix | Delete
self::$aggregated_multidimensionals = array();
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
/**
[280] Fix | Delete
* The ID for the current site when the preview() method was called.
[281] Fix | Delete
*
[282] Fix | Delete
* @since 4.2.0
[283] Fix | Delete
* @var int
[284] Fix | Delete
*/
[285] Fix | Delete
protected $_previewed_blog_id;
[286] Fix | Delete
[287] Fix | Delete
/**
[288] Fix | Delete
* Return true if the current site is not the same as the previewed site.
[289] Fix | Delete
*
[290] Fix | Delete
* @since 4.2.0
[291] Fix | Delete
*
[292] Fix | Delete
* @return bool If preview() has been called.
[293] Fix | Delete
*/
[294] Fix | Delete
public function is_current_blog_previewed() {
[295] Fix | Delete
if ( ! isset( $this->_previewed_blog_id ) ) {
[296] Fix | Delete
return false;
[297] Fix | Delete
}
[298] Fix | Delete
return ( get_current_blog_id() === $this->_previewed_blog_id );
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
/**
[302] Fix | Delete
* Original non-previewed value stored by the preview method.
[303] Fix | Delete
*
[304] Fix | Delete
* @see WP_Customize_Setting::preview()
[305] Fix | Delete
* @since 4.1.1
[306] Fix | Delete
* @var mixed
[307] Fix | Delete
*/
[308] Fix | Delete
protected $_original_value;
[309] Fix | Delete
[310] Fix | Delete
/**
[311] Fix | Delete
* Add filters to supply the setting's value when accessed.
[312] Fix | Delete
*
[313] Fix | Delete
* If the setting already has a pre-existing value and there is no incoming
[314] Fix | Delete
* post value for the setting, then this method will short-circuit since
[315] Fix | Delete
* there is no change to preview.
[316] Fix | Delete
*
[317] Fix | Delete
* @since 3.4.0
[318] Fix | Delete
* @since 4.4.0 Added boolean return value.
[319] Fix | Delete
*
[320] Fix | Delete
* @return bool False when preview short-circuits due no change needing to be previewed.
[321] Fix | Delete
*/
[322] Fix | Delete
public function preview() {
[323] Fix | Delete
if ( ! isset( $this->_previewed_blog_id ) ) {
[324] Fix | Delete
$this->_previewed_blog_id = get_current_blog_id();
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
// Prevent re-previewing an already-previewed setting.
[328] Fix | Delete
if ( $this->is_previewed ) {
[329] Fix | Delete
return true;
[330] Fix | Delete
}
[331] Fix | Delete
[332] Fix | Delete
$id_base = $this->id_data['base'];
[333] Fix | Delete
$is_multidimensional = ! empty( $this->id_data['keys'] );
[334] Fix | Delete
$multidimensional_filter = array( $this, '_multidimensional_preview_filter' );
[335] Fix | Delete
[336] Fix | Delete
/*
[337] Fix | Delete
* Check if the setting has a pre-existing value (an isset check),
[338] Fix | Delete
* and if doesn't have any incoming post value. If both checks are true,
[339] Fix | Delete
* then the preview short-circuits because there is nothing that needs
[340] Fix | Delete
* to be previewed.
[341] Fix | Delete
*/
[342] Fix | Delete
$undefined = new stdClass();
[343] Fix | Delete
$needs_preview = ( $undefined !== $this->post_value( $undefined ) );
[344] Fix | Delete
$value = null;
[345] Fix | Delete
[346] Fix | Delete
// Since no post value was defined, check if we have an initial value set.
[347] Fix | Delete
if ( ! $needs_preview ) {
[348] Fix | Delete
if ( $this->is_multidimensional_aggregated ) {
[349] Fix | Delete
$root = self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'];
[350] Fix | Delete
$value = $this->multidimensional_get( $root, $this->id_data['keys'], $undefined );
[351] Fix | Delete
} else {
[352] Fix | Delete
$default = $this->default;
[353] Fix | Delete
$this->default = $undefined; // Temporarily set default to undefined so we can detect if existing value is set.
[354] Fix | Delete
$value = $this->value();
[355] Fix | Delete
$this->default = $default;
[356] Fix | Delete
}
[357] Fix | Delete
$needs_preview = ( $undefined === $value ); // Because the default needs to be supplied.
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
// If the setting does not need previewing now, defer to when it has a value to preview.
[361] Fix | Delete
if ( ! $needs_preview ) {
[362] Fix | Delete
if ( ! has_action( "customize_post_value_set_{$this->id}", array( $this, 'preview' ) ) ) {
[363] Fix | Delete
add_action( "customize_post_value_set_{$this->id}", array( $this, 'preview' ) );
[364] Fix | Delete
}
[365] Fix | Delete
return false;
[366] Fix | Delete
}
[367] Fix | Delete
[368] Fix | Delete
switch ( $this->type ) {
[369] Fix | Delete
case 'theme_mod':
[370] Fix | Delete
if ( ! $is_multidimensional ) {
[371] Fix | Delete
add_filter( "theme_mod_{$id_base}", array( $this, '_preview_filter' ) );
[372] Fix | Delete
} else {
[373] Fix | Delete
if ( empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] ) ) {
[374] Fix | Delete
// Only add this filter once for this ID base.
[375] Fix | Delete
add_filter( "theme_mod_{$id_base}", $multidimensional_filter );
[376] Fix | Delete
}
[377] Fix | Delete
self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'][ $this->id ] = $this;
[378] Fix | Delete
}
[379] Fix | Delete
break;
[380] Fix | Delete
case 'option':
[381] Fix | Delete
if ( ! $is_multidimensional ) {
[382] Fix | Delete
add_filter( "pre_option_{$id_base}", array( $this, '_preview_filter' ) );
[383] Fix | Delete
} else {
[384] Fix | Delete
if ( empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] ) ) {
[385] Fix | Delete
// Only add these filters once for this ID base.
[386] Fix | Delete
add_filter( "option_{$id_base}", $multidimensional_filter );
[387] Fix | Delete
add_filter( "default_option_{$id_base}", $multidimensional_filter );
[388] Fix | Delete
}
[389] Fix | Delete
self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'][ $this->id ] = $this;
[390] Fix | Delete
}
[391] Fix | Delete
break;
[392] Fix | Delete
default:
[393] Fix | Delete
/**
[394] Fix | Delete
* Fires when the WP_Customize_Setting::preview() method is called for settings
[395] Fix | Delete
* not handled as theme_mods or options.
[396] Fix | Delete
*
[397] Fix | Delete
* The dynamic portion of the hook name, `$this->id`, refers to the setting ID.
[398] Fix | Delete
*
[399] Fix | Delete
* @since 3.4.0
[400] Fix | Delete
*
[401] Fix | Delete
* @param WP_Customize_Setting $setting WP_Customize_Setting instance.
[402] Fix | Delete
*/
[403] Fix | Delete
do_action( "customize_preview_{$this->id}", $this );
[404] Fix | Delete
[405] Fix | Delete
/**
[406] Fix | Delete
* Fires when the WP_Customize_Setting::preview() method is called for settings
[407] Fix | Delete
* not handled as theme_mods or options.
[408] Fix | Delete
*
[409] Fix | Delete
* The dynamic portion of the hook name, `$this->type`, refers to the setting type.
[410] Fix | Delete
*
[411] Fix | Delete
* @since 4.1.0
[412] Fix | Delete
*
[413] Fix | Delete
* @param WP_Customize_Setting $setting WP_Customize_Setting instance.
[414] Fix | Delete
*/
[415] Fix | Delete
do_action( "customize_preview_{$this->type}", $this );
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
$this->is_previewed = true;
[419] Fix | Delete
[420] Fix | Delete
return true;
[421] Fix | Delete
}
[422] Fix | Delete
[423] Fix | Delete
/**
[424] Fix | Delete
* Clear out the previewed-applied flag for a multidimensional-aggregated value whenever its post value is updated.
[425] Fix | Delete
*
[426] Fix | Delete
* This ensures that the new value will get sanitized and used the next time
[427] Fix | Delete
* that `WP_Customize_Setting::_multidimensional_preview_filter()`
[428] Fix | Delete
* is called for this setting.
[429] Fix | Delete
*
[430] Fix | Delete
* @since 4.4.0
[431] Fix | Delete
*
[432] Fix | Delete
* @see WP_Customize_Manager::set_post_value()
[433] Fix | Delete
* @see WP_Customize_Setting::_multidimensional_preview_filter()
[434] Fix | Delete
*/
[435] Fix | Delete
final public function _clear_aggregated_multidimensional_preview_applied_flag() {
[436] Fix | Delete
unset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['preview_applied_instances'][ $this->id ] );
[437] Fix | Delete
}
[438] Fix | Delete
[439] Fix | Delete
/**
[440] Fix | Delete
* Callback function to filter non-multidimensional theme mods and options.
[441] Fix | Delete
*
[442] Fix | Delete
* If switch_to_blog() was called after the preview() method, and the current
[443] Fix | Delete
* site is now not the same site, then this method does a no-op and returns
[444] Fix | Delete
* the original value.
[445] Fix | Delete
*
[446] Fix | Delete
* @since 3.4.0
[447] Fix | Delete
*
[448] Fix | Delete
* @param mixed $original Old value.
[449] Fix | Delete
* @return mixed New or old value.
[450] Fix | Delete
*/
[451] Fix | Delete
public function _preview_filter( $original ) {
[452] Fix | Delete
if ( ! $this->is_current_blog_previewed() ) {
[453] Fix | Delete
return $original;
[454] Fix | Delete
}
[455] Fix | Delete
[456] Fix | Delete
$undefined = new stdClass(); // Symbol hack.
[457] Fix | Delete
$post_value = $this->post_value( $undefined );
[458] Fix | Delete
if ( $undefined !== $post_value ) {
[459] Fix | Delete
$value = $post_value;
[460] Fix | Delete
} else {
[461] Fix | Delete
/*
[462] Fix | Delete
* Note that we don't use $original here because preview() will
[463] Fix | Delete
* not add the filter in the first place if it has an initial value
[464] Fix | Delete
* and there is no post value.
[465] Fix | Delete
*/
[466] Fix | Delete
$value = $this->default;
[467] Fix | Delete
}
[468] Fix | Delete
return $value;
[469] Fix | Delete
}
[470] Fix | Delete
[471] Fix | Delete
/**
[472] Fix | Delete
* Callback function to filter multidimensional theme mods and options.
[473] Fix | Delete
*
[474] Fix | Delete
* For all multidimensional settings of a given type, the preview filter for
[475] Fix | Delete
* the first setting previewed will be used to apply the values for the others.
[476] Fix | Delete
*
[477] Fix | Delete
* @since 4.4.0
[478] Fix | Delete
*
[479] Fix | Delete
* @see WP_Customize_Setting::$aggregated_multidimensionals
[480] Fix | Delete
* @param mixed $original Original root value.
[481] Fix | Delete
* @return mixed New or old value.
[482] Fix | Delete
*/
[483] Fix | Delete
final public function _multidimensional_preview_filter( $original ) {
[484] Fix | Delete
if ( ! $this->is_current_blog_previewed() ) {
[485] Fix | Delete
return $original;
[486] Fix | Delete
}
[487] Fix | Delete
[488] Fix | Delete
$id_base = $this->id_data['base'];
[489] Fix | Delete
[490] Fix | Delete
// If no settings have been previewed yet (which should not be the case, since $this is), just pass through the original value.
[491] Fix | Delete
if ( empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] ) ) {
[492] Fix | Delete
return $original;
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
foreach ( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] as $previewed_setting ) {
[496] Fix | Delete
// Skip applying previewed value for any settings that have already been applied.
[497] Fix | Delete
if ( ! empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['preview_applied_instances'][ $previewed_setting->id ] ) ) {
[498] Fix | Delete
continue;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function