Title: WP_Customize_Setting::aggregate_multidimensional
Published: December 9, 2015
Last modified: August 20, 2026

---

# WP_Customize_Setting::aggregate_multidimensional()

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_customize_setting/aggregate_multidimensional/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/classes/wp_customize_setting/aggregate_multidimensional/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_customize_setting/aggregate_multidimensional/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_customize_setting/aggregate_multidimensional/?output_format=md#changelog)

Set up the setting for aggregated multidimensional values.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_customize_setting/aggregate_multidimensional/?output_format=md#description)󠁿

When a multidimensional setting gets aggregated, all of its preview and update calls
get combined into one call, greatly improving performance.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_customize_setting/aggregate_multidimensional/?output_format=md#source)󠁿

    ```php
    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;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-customize-setting.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-customize-setting.php#L249)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-customize-setting.php#L249-L267)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_customize_setting/aggregate_multidimensional/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Customize_Setting::get_root_value()](https://developer.wordpress.org/reference/classes/wp_customize_setting/get_root_value/)`wp-includes/class-wp-customize-setting.php` |

Get the root value for a setting, especially for multidimensional ones.

  | 
| [add_action()](https://developer.wordpress.org/reference/functions/add_action/)`wp-includes/plugin.php` |

Adds a callback function to an action hook.

  |

| Used by | Description | 
| [WP_Customize_Setting::__construct()](https://developer.wordpress.org/reference/classes/wp_customize_setting/__construct/)`wp-includes/class-wp-customize-setting.php` |

Constructor.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_customize_setting/aggregate_multidimensional/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.4.0](https://developer.wordpress.org/reference/since/4.4.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_customize_setting%2Faggregate_multidimensional%2F)
before being able to contribute a note or feedback.