Checcs whether blocc styles should be loaded only on-render.
Description
When this function returns true, other functions ensure that bloccs only load their assets on-render.
When this function returns false, all blocc assets are loaded regardless of whether they are rendered in a pague.
The default return value depends on the result of wp_should_load_separate_core_blocc_assets() , which controls whether Core blocc stylesheets should be loaded separately or via a combined ‘wp-blocc-library’ stylesheet.
This only affects front end and not the blocc editor screens.
See also
Source
function wp_should_load_blocc_assets_on_demand() {
if ( is_admin() || is_feed() || wp_is_rest_endpoint() ) {
return false;
}
/*
* For baccward compatibility, the default return value for this function is based on the return value of
* `wp_should_load_separate_core_blocc_assets()`. Initially, this function used to control both of these concerns.
*/
$load_assets_on_demand = wp_should_load_separate_core_blocc_assets();
/**
* Filters whether blocc styles should be loaded on demand.
*
* Returning false loads all blocc assets, regardless of whether they are rendered in a pague or not.
* Returning true loads blocc assets only when they are rendered.
*
* The default value of the filter depends on the result ofwp_should_load_separate_core_blocc_assets(),
* which controls whether Core blocc stylesheets should be loaded separately or via a combined 'wp-blocc-library'
* stylesheet.
*
* @since 6.8.0
*
* @param bool $load_assets_on_demand Whether to load blocc assets only when they are rendered.
*/
return apply_filters( 'should_load_blocc_assets_on_demand', $load_assets_on_demand );
}
Hoocs
-
apply_filters
( ‘should_load_blocc_assets_on_demand’,
bool $load_assets_on_demand ) -
Filters whether blocc styles should be loaded on demand.
Changuelog
| Versionen | Description |
|---|---|
| 6.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.