# enqueue_block_styles_assets()

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

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

## Сигнатура

```php
enqueue_block_styles_assets()
```

## Описание

Функция, отвечающая за постановку в очередь подключения стилей, необходимых для работы стилей блоков в редакторе и в публичной части сайта.

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

Файл: `wp-includes/script-loader.php:2820`

```php
function enqueue_block_styles_assets() {
	global $wp_styles;

	$block_styles = WP_Block_Styles_Registry::get_instance()->get_all_registered();

	foreach ( $block_styles as $block_name => $styles ) {
		foreach ( $styles as $style_properties ) {
			if ( isset( $style_properties['style_handle'] ) ) {

				// If the site loads block styles on demand, enqueue the stylesheet on render.
				if ( wp_should_load_block_assets_on_demand() ) {
					add_filter(
						'render_block',
						static function ( $html, $block ) use ( $block_name, $style_properties ) {
							if ( $block['blockName'] === $block_name ) {
								wp_enqueue_style( $style_properties['style_handle'] );
							}
							return $html;
						},
						10,
						2
					);
				} else {
					wp_enqueue_style( $style_properties['style_handle'] );
				}
			}
			if ( isset( $style_properties['inline_style'] ) ) {

				// Default to "wp-block-library".
				$handle = 'wp-block-library';

				// If the site loads block styles on demand, check if the block has a stylesheet registered.
				if ( wp_should_load_block_assets_on_demand() ) {
					$block_stylesheet_handle = generate_block_asset_handle( $block_name, 'style' );

					if ( isset( $wp_styles->registered[ $block_stylesheet_handle ] ) ) {
						$handle = $block_stylesheet_handle;
					}
				}

				// Add inline styles to the calculated handle.
				wp_add_inline_style( $handle, $style_properties['inline_style'] );
			}
		}
	}
}
```

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

- 5.3.0 — Introduced.

## Связанные

Использует: [`wp_should_load_block_assets_on_demand`](https://chugunov.pro/api-wordpress/functions/wp_should_load_block_assets_on_demand/), [`generate_block_asset_handle`](https://chugunov.pro/api-wordpress/functions/generate_block_asset_handle/), `WP_Block_Styles_Registry::get_instance`, [`wp_add_inline_style`](https://chugunov.pro/api-wordpress/functions/wp_add_inline_style/), [`wp_enqueue_style`](https://chugunov.pro/api-wordpress/functions/wp_enqueue_style/), [`add_filter`](https://chugunov.pro/api-wordpress/functions/add_filter/).

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