[wp-trac] [WordPress Trac] #61958: Rename `wp_should_load_separate_core_block_assets()` to clarify its purpose
WordPress Trac
noreply at wordpress.org
Thu Jan 30 23:11:10 UTC 2025
#61958: Rename `wp_should_load_separate_core_block_assets()` to clarify its purpose
-----------------------------------+-----------------------------
Reporter: flixos90 | Owner: (none)
Type: enhancement | Status: assigned
Priority: normal | Milestone: Future Release
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: 2nd-opinion has-patch | Focuses: template
-----------------------------------+-----------------------------
Changes (by flixos90):
* owner: flixos90 => (none)
* milestone: 6.8 => Future Release
Old description:
> The `wp_should_load_separate_core_block_assets()` function and the
> `should_load_separate_core_block_assets` filter were introduced in
> WordPress 5.8 (see [50836] and
> [https://make.wordpress.org/core/2021/07/01/block-styles-loading-
> enhancements-in-wordpress-5-8/ dev note]).
>
> While initially the function's and filter's purpose was to determine
> whether to load individual block stylesheets for core blocks (vs the one
> large `wp-block-library` stylesheet), this purpose has notably changed
> over time: Today, this function is called to determine whether or not to
> load block assets on demand (vs unconditionally throughout the entire
> site). In other words, it also covers third-party blocks, but the entire
> purpose is different. It still ''also'' controls whether to use
> individual stylesheets for the core blocks, but at this point that is
> mostly a side effect of loading block assets on demand.
>
> The function name, filter name, and their documentation is confusing. Not
> only does it not explain what it actually does today, it is also
> inconsistent in itself in that it sometimes refers to "core block types",
> while other times it refers to "block types" (in general).
> [https://wordpress.slack.com/archives/C02QB2JS7/p1724755636404209 This
> Slack thread] is an example of how the current naming and documentation
> leads to confusion.
>
> This ticket proposes renaming the function and filter and updating the
> documentation to clarify the purpose. Of course, technically we can't
> just rename things, so this will mean deprecating the current function
> and filter in favor of a new function and filter.
>
> Potentially a good name would be `wp_should_load_block_assets_on_demand`.
> This could work for both the function and the filter. The documentation
> should then focus on this primary purpose, while additionally explaining
> that this will furthermore lead to individual core blocks stylesheets
> being used instead of `wp-block-library` (which still makes sense in this
> context, because loading `wp-block-library` is anything but on demand
> 🙃).
>
> For additional context, see
> [https://wordpress.slack.com/archives/C02QB2JS7/p1724866722880979 this
> Slack thread, which is based on the other thread above].
New description:
The `wp_should_load_separate_core_block_assets()` function and the
`should_load_separate_core_block_assets` filter were introduced in
WordPress 5.8 (see [50836] and [https://make.wordpress.org/core/2021/07/01
/block-styles-loading-enhancements-in-wordpress-5-8/ dev note]).
While initially the function's and filter's purpose was to determine
whether to load individual block stylesheets for core blocks (vs the one
large `wp-block-library` stylesheet), this purpose has notably expanded
over time: Today, this function also determines whether or not to load
block assets on demand (vs unconditionally throughout the entire site).
More importantly though, it also covers third-party blocks, so its name
containing `core_blocks` is confusing and should rather use simply
`blocks`.
The function name, filter name, and their documentation is confusing. Not
only does it not explain what it actually does today, it is also
inconsistent in itself in that it sometimes refers to "core block types",
while other times it refers to "block types" (in general).
[https://wordpress.slack.com/archives/C02QB2JS7/p1724755636404209 This
Slack thread] is an example of how the current naming and documentation
leads to confusion.
This ticket proposes renaming the function and filter and updating the
documentation to clarify the purpose. Of course, technically we can't just
rename things, so this will mean deprecating the current function and
filter in favor of a new function and filter.
Potentially a good name would be `wp_should_load_separate_block_assets()`.
This could work for both the function and the filter. The documentation
should then focus on this primary purpose, while additionally explaining
that this will furthermore lead to individual core blocks stylesheets
being used instead of `wp-block-library` (which still makes sense in this
context, because loading `wp-block-library` is anything but on demand 🙃).
If we decide that renaming the function is too disruptive, at a minimum we
should improve its documentation to clarify those behaviors.
--
Comment:
Based on https://core.trac.wordpress.org/ticket/61965#comment:6, this
ticket is still relevant but no longer crucial to facilitate the other
ticket. Since renaming this function would be disruptive, I'm going to
move it to a future release for now.
I'm updating the description to clarify the new proposed change.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61958#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list