WP_Customize_Setting::multidimensional( $root, $keys, bool $create = false )
Multidimensional helper function.
Description Description
Parameters Parameters
- $root
-
(Required)
- $keys
-
(Required)
- $create
-
(bool) (Optional) Default is false.
Default value: false
Return Return
(array|void) Keys are 'root', 'node', and 'key'.
Source Source
File: wp-includes/class-wp-customize-setting.php
final protected function multidimensional( &$root, $keys, $create = false ) { if ( $create && empty( $root ) ) { $root = array(); } if ( ! isset( $root ) || empty( $keys ) ) { return; } $last = array_pop( $keys ); $node = &$root; foreach ( $keys as $key ) { if ( $create && ! isset( $node[ $key ] ) ) { $node[ $key ] = array(); } if ( ! is_array( $node ) || ! isset( $node[ $key ] ) ) { return; } $node = &$node[ $key ]; } if ( $create ) { if ( ! is_array( $node ) ) { // account for an array overriding a string or object value $node = array(); } if ( ! isset( $node[ $last ] ) ) { $node[ $last ] = array(); } } if ( ! isset( $node[ $last ] ) ) { return; } return array( 'root' => &$root, 'node' => &$node, 'key' => $last, ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
3.4.0 | Introduced. |