Skip to content

Commit 3c1ab39

Browse files
committed
Docs: Further Improve documentation for wp_should_load_separate_core_block_assets().
In [51256], the documentation was improved, this further improves it. As scripts are not yet a part of what this function does, they are not mentioned explicitly. Assets is used so that the docs don't need a lot of improvements when scripts do come into play.. Props desrosj, SergeyBiryukov, Jorbin. See #53505. git-svn-id: https://develop.svn.wordpress.org/trunk@51263 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5673442 commit 3c1ab39

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/wp-includes/script-loader.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,16 +2326,16 @@ function wp_should_load_block_editor_scripts_and_styles() {
23262326
}
23272327

23282328
/**
2329-
* Checks whether separate assets should be loaded for core blocks on-render.
2329+
* Checks whether separate styles should be loaded for core blocks on-render.
23302330
*
23312331
* When this function returns true, other functions ensure that core blocks
2332-
* only load their styles on-render, and each block loads its own, individual
2333-
* stylesheet. Third-party blocks only load their styles when rendered.
2332+
* only load their assets on-render, and each block loads its own, individual
2333+
* assets. Third-party blocks only load their assets when rendered.
23342334
*
2335-
* When this function returns false, all core block styles are loaded regardless
2335+
* When this function returns false, all core block assets are loaded regardless
23362336
* of whether they are rendered in a page or not, because they are all part of
2337-
* the `block-library/style.css` file. Third-party blocks always get enqueued
2338-
* regardless of whether they are rendered or not.
2337+
* the `block-library/style.css` file. Assets for third-party blocks are always
2338+
* enqueued regardless of whether they are rendered or not.
23392339
*
23402340
* This only affects front end and not the block editor screens.
23412341
*
@@ -2352,13 +2352,15 @@ function wp_should_load_separate_core_block_assets() {
23522352
}
23532353

23542354
/**
2355-
* Filters the flag that decides whether separate scripts and styles
2356-
* will be loaded for core blocks on-render.
2355+
* Filters whether block styles should be loaded separately.
2356+
*
2357+
* Returning false loads all core block assets, regardless of whether they are rendered
2358+
* in a page or not. Returning true loads core block assets only when they are rendered.
23572359
*
23582360
* @since 5.8.0
23592361
*
23602362
* @param bool $load_separate_assets Whether separate assets will be loaded.
2361-
* Default false.
2363+
* Default false (all block assets are loaded, even when not used).
23622364
*/
23632365
return apply_filters( 'should_load_separate_core_block_assets', false );
23642366
}

0 commit comments

Comments
 (0)