wp_should_load_separate_core_block_assets()
Checks whether separate styles should be loaded for core blocks.
When this function returns true, other functions ensure that core blocks use their own separate stylesheets. When this function returns false, all core blocks will use the single combined 'wp-block-library' stylesheet.
As a side effect, the return value will by default result in block assets to be loaded on demand, via the wp_should_load_block_assets_on_demand() function. This behavior can be separately altered via that function.
This only affects front end and not the block editor screens.
Hooks from the function
Returns
true|false
. Whether separate core block assets will be loaded.
Usage
wp_should_load_separate_core_block_assets();
Notes
- See: @see wp_should_load_block_assets_on_demand()
- See: wp_enqueue_registered_block_scripts_and_styles()
- See: register_block_style_handle()
Changelog
Since 5.8.0 | Introduced. |
wp_should_load_separate_core_block_assets() wp should load separate core block assets code WP 6.8.1
function wp_should_load_separate_core_block_assets() { if ( is_admin() || is_feed() || wp_is_rest_endpoint() ) { return false; } /** * Filters whether block styles should be loaded separately. * * Returning false loads all core block assets, regardless of whether they are rendered * in a page or not. Returning true loads core block assets only when they are rendered. * * @since 5.8.0 * * @param bool $load_separate_assets Whether separate assets will be loaded. * Default false (all block assets are loaded, even when not used). */ return apply_filters( 'should_load_separate_core_block_assets', false ); }