# _block_bindings_post_meta_get_value()

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

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

## Сигнатура

```php
_block_bindings_post_meta_get_value( array $source_args, WP_Block $block_instance ): mixed
```

## Описание

Получает значение для источника Post Meta.

## Параметры

- `$source_args` `array` — обязательный. Массив с аргументами источника, используемыми для поиска переопределяющего значения.
  
  Пример: array( "key" => "foo" ).
- `$block_instance` `WP_Block` — обязательный. Экземпляр блока.

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

`mixed`

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

Файл: `wp-includes/block-bindings/post-meta.php:21`

```php
function _block_bindings_post_meta_get_value( array $source_args, $block_instance ) {
	if ( empty( $source_args['key'] ) ) {
		return null;
	}

	if ( empty( $block_instance->context['postId'] ) ) {
		return null;
	}
	$post_id = $block_instance->context['postId'];

	// If a post isn't public, we need to prevent unauthorized users from accessing the post meta.
	$post = get_post( $post_id );
	if ( ( ! is_post_publicly_viewable( $post ) && ! current_user_can( 'read_post', $post_id ) ) || post_password_required( $post ) ) {
		return null;
	}

	// Check if the meta field is protected.
	if ( is_protected_meta( $source_args['key'], 'post' ) ) {
		return null;
	}

	// Check if the meta field is registered to be shown in REST.
	$meta_keys = get_registered_meta_keys( 'post', $block_instance->context['postType'] );
	// Add fields registered for all subtypes.
	$meta_keys = array_merge( $meta_keys, get_registered_meta_keys( 'post', '' ) );
	if ( empty( $meta_keys[ $source_args['key'] ]['show_in_rest'] ) ) {
		return null;
	}

	return get_post_meta( $post_id, $source_args['key'], true );
}
```

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

- 6.5.0 — Introduced.

## Связанные

Использует: [`is_post_publicly_viewable`](https://chugunov.pro/api-wordpress/functions/is_post_publicly_viewable/), [`get_registered_meta_keys`](https://chugunov.pro/api-wordpress/functions/get_registered_meta_keys/), [`post_password_required`](https://chugunov.pro/api-wordpress/functions/post_password_required/), [`is_protected_meta`](https://chugunov.pro/api-wordpress/functions/is_protected_meta/), [`current_user_can`](https://chugunov.pro/api-wordpress/functions/current_user_can/), [`get_post_meta`](https://chugunov.pro/api-wordpress/functions/get_post_meta/), [`get_post`](https://chugunov.pro/api-wordpress/functions/get_post/).

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