WP_Customize_Setting::multidimensional() protected WP 3.4.0
Multidimensional helper function.
{} Это метод класса: WP_Customize_Setting{}
Хуков нет.
Возвращает
Массив/null
. Keys are 'root', 'node', and 'key'.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->multidimensional( $root, $keys, $create );
- $root(массив) (обязательный)
- -
- $keys(массив) (обязательный)
- -
- $create(true|false)
- Default false.
Список изменений
С версии 3.4.0 | Введена. |
Код WP_Customize_Setting::multidimensional() WP Customize Setting::multidimensional WP 5.7.1
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,
);
}