WP_Customize_Setting::aggregate_multidimensional
Set up the setting for aggregated multidimensional values.
When a multidimensional setting gets aggregated, all of its preview and update calls get combined into one call, greatly improving performance.
Method of the class: WP_Customize_Setting{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->aggregate_multidimensional();
Changelog
| Since 4.4.0 | Introduced. |
WP_Customize_Setting::aggregate_multidimensional() WP Customize Setting::aggregate multidimensional code WP 6.9.1
protected function aggregate_multidimensional() {
$id_base = $this->id_data['base'];
if ( ! isset( self::$aggregated_multidimensionals[ $this->type ] ) ) {
self::$aggregated_multidimensionals[ $this->type ] = array();
}
if ( ! isset( self::$aggregated_multidimensionals[ $this->type ][ $id_base ] ) ) {
self::$aggregated_multidimensionals[ $this->type ][ $id_base ] = array(
'previewed_instances' => array(), // Calling preview() will add the $setting to the array.
'preview_applied_instances' => array(), // Flags for which settings have had their values applied.
'root_value' => $this->get_root_value( array() ), // Root value for initial state, manipulated by preview and update calls.
);
}
if ( ! empty( $this->id_data['keys'] ) ) {
// Note the preview-applied flag is cleared at priority 9 to ensure it is cleared before a deferred-preview runs.
add_action( "customize_post_value_set_{$this->id}", array( $this, '_clear_aggregated_multidimensional_preview_applied_flag' ), 9 );
$this->is_multidimensional_aggregated = true;
}
}