# _wp_array_get()

URL: https://chugunov.pro/api-wordpress/functions/_wp_array_get/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 5.6.0.

## Сигнатура

```php
_wp_array_get( array $input_array, array $path, mixed $default_value = null ): mixed
```

## Описание

Это PHP-эквивалент функции lodash.get() из JavaScript, и её повторение может помочь другим компонентам сохранять симметрию между клиентской и серверной реализациями.
Пример использования:
$input_array = array(
'a' => array(
'b' => array(
'c' => 1,
),
),
);
_wp_array_get( $input_array, array( 'a', 'b', 'c' ) );

## Параметры

- `$input_array` `array` — обязательный. Массив, из которого требуется извлечь некоторые данные.
- `$path` `array` — обязательный. Массив ключей, описывающий путь, по которому извлекаются данные.
- `$default_value` `mixed` — необязательный, по умолчанию `null`. Возвращаемое значение, если путь не существует в массиве или если $input_array либо $path не являются массивами.

## Возвращаемое значение

`mixed`

## Исходный код

Файл: `wp-includes/functions.php:5096`

```php
function _wp_array_get( $input_array, $path, $default_value = null ) {
	// Confirm $path is valid.
	if ( ! is_array( $path ) || 0 === count( $path ) ) {
		return $default_value;
	}

	foreach ( $path as $path_element ) {
		if ( ! is_array( $input_array ) ) {
			return $default_value;
		}

		if ( is_string( $path_element )
			|| is_integer( $path_element )
			|| null === $path_element
		) {
			/*
			 * Check if the path element exists in the input array.
			 * We check with `isset()` first, as it is a lot faster
			 * than `array_key_exists()`.
			 */
			if ( isset( $path_element, $input_array[ $path_element ] ) ) {
				$input_array = $input_array[ $path_element ];
				continue;
			}

			/*
			 * If `isset()` returns false, we check with `array_key_exists()`,
			 * which also checks for `null` values.
			 */
			if ( isset( $path_element ) && array_key_exists( $path_element, $input_array ) ) {
				$input_array = $input_array[ $path_element ];
				continue;
			}
		}

		return $default_value;
	}

	return $input_array;
}
```

## История изменений

- 5.6.0 — Introduced.

## Связанные

Используется в: `WP_Theme_JSON::preserve_valid_typed_settings`, [`_block_bindings_pattern_overrides_get_value`](https://chugunov.pro/api-wordpress/functions/_block_bindings_pattern_overrides_get_value/), [`wp_get_block_css_selector`](https://chugunov.pro/api-wordpress/functions/wp_get_block_css_selector/), `WP_Duotone::get_all_global_style_block_names`, `WP_Theme_JSON::remove_indirect_properties`, [`wp_typography_get_css_variable_inline_style`](https://chugunov.pro/api-wordpress/functions/wp_typography_get_css_variable_inline_style/), `WP_Theme_JSON::get_styles_for_block`, `WP_Theme_JSON::get_layout_styles`, `WP_Style_Engine::parse_block_styles`, `WP_Style_Engine::get_individual_property_css_declarations`, `WP_Theme_JSON::get_data`, `WP_Theme_JSON::get_metadata_boolean`, `WP_Theme_JSON::get_svg_filters`, [`wp_get_global_settings`](https://chugunov.pro/api-wordpress/functions/wp_get_global_settings/), [`wp_get_global_styles`](https://chugunov.pro/api-wordpress/functions/wp_get_global_styles/), `WP_Theme_JSON_Schema::rename_settings`, `WP_Theme_JSON::should_override_preset`, `WP_Theme_JSON::get_default_slugs`, `WP_Theme_JSON::get_name_from_defaults`, `WP_Theme_JSON::remove_insecure_properties`, `WP_Theme_JSON::remove_insecure_settings`, `WP_Theme_JSON::remove_insecure_styles`, `WP_Theme_JSON::get_preset_classes`, `WP_Theme_JSON::get_settings_values_by_slug`, `WP_Theme_JSON::get_settings_slugs`, `WP_Theme_JSON::do_opt_in_into_settings`, `WP_Theme_JSON::get_property_value`, `WP_Theme_JSON::merge`, `WP_Theme_JSON::__construct`, `WP_Theme_JSON::get_stylesheet`, `WP_Theme_JSON::get_css_variables`, [`block_has_support`](https://chugunov.pro/api-wordpress/functions/block_has_support/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/_wp_array_get/
