GC_Customize_Setting::_multidimensional_preview_filter()
最后更新于:2021-11-27 08:47:09
GC_Customize_Setting::_multidimensional_preview_filter( mixed$original)Callback function to filter multidimensional theme mods and options.
参数
- $original
-
(mixed) (Required) Original root value.
响应
(mixed) New or old value.
源文件
文件: gc-includes/class-gc-customize-setting.php
final public function _multidimensional_preview_filter( $original ) {
if ( ! $this->is_current_blog_previewed() ) {
return $original;
}
$id_base = $this->id_data['base'];
// If no settings have been previewed yet (which should not be the case, since $this is), just pass through the original value.
if ( empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] ) ) {
return $original;
}
foreach ( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['previewed_instances'] as $previewed_setting ) {
// Skip applying previewed value for any settings that have already been applied.
if ( ! empty( self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['preview_applied_instances'][ $previewed_setting->id ] ) ) {
continue;
}
// Do the replacements of the posted/default sub value into the root value.
$value = $previewed_setting->post_value( $previewed_setting->default );
$root = self::$aggregated_multidimensionals[ $previewed_setting->type ][ $id_base ]['root_value'];
$root = $previewed_setting->multidimensional_replace( $root, $previewed_setting->id_data['keys'], $value );
self::$aggregated_multidimensionals[ $previewed_setting->type ][ $id_base ]['root_value'] = $root;
// Mark this setting having been applied so that it will be skipped when the filter is called again.
self::$aggregated_multidimensionals[ $previewed_setting->type ][ $id_base ]['preview_applied_instances'][ $previewed_setting->id ] = true;
}
return self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'];
}