[wp-trac] [WordPress Trac] #61958: Rename `wp_should_load_separate_core_block_assets()` to clarify its purpose

WordPress Trac noreply at wordpress.org
Thu Aug 29 16:42:08 UTC 2024


#61958: Rename `wp_should_load_separate_core_block_assets()` to clarify its purpose
-------------------------+-------------------------
 Reporter:  flixos90     |      Owner:  flixos90
     Type:  enhancement  |     Status:  assigned
 Priority:  normal       |  Milestone:  6.7
Component:  Editor       |    Version:
 Severity:  normal       |   Keywords:  2nd-opinion
  Focuses:  template     |
-------------------------+-------------------------
 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].

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61958>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list