[wp-trac] [WordPress Trac] #59969: Conditional loading `build_template_part_block_variations` for performance improvement
WordPress Trac
noreply at wordpress.org
Fri Jan 19 20:52:22 UTC 2024
#59969: Conditional loading `build_template_part_block_variations` for performance
improvement
------------------------------+--------------------------
Reporter: thekt12 | Owner: joemcgill
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.5
Component: General | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch commit | Focuses: performance
------------------------------+--------------------------
Changes (by joemcgill):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"57315" 57315]:
{{{
#!CommitTicketReference repository="" revision="57315"
Editor: Support deferred block variation initialization on the server.
When registering blocks on the server using `register_block_type()` or
similar functions, a set of block type variations can also be registered.
However, in some cases building this variation data during block
registration can be an expensive process, which is not needed in most
contexts.
To address this problem, this adds support to the `WP_Block_Type` object
for a new property, `variation_callback`, which can be used to register a
callback for building variation data only when the block variations data
is needed. The `WP_Block_Type::variations` property has been changed to a
private property that is now accessed through the magic `__get()` method.
The magic getter makes use of a new public method,
`WP_Block_Type::get_variations` which will build variations from a
registered callback if variations have not already been built.
Props spacedmonkey, thekt12, Mamaduka, gaambo, gziolo, mukesh27,
joemcgill.
Fixes #59969.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59969#comment:39>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list