[Proof of Concept] Optimize how shared block style variations are processed#6868
[Proof of Concept] Optimize how shared block style variations are processed#6868oandregal wants to merge 2 commits intoWordPress:trunkfrom
Conversation
|
This is just a proof of concept, but I wanted to share the approach as soon as possible to gather feedback and gauge the impact on performance (not much so far, as far as I see). What works:
What doesn't:
Viability of the PoC:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
I like the idea of trying to move this processing directly into the parsing of a I ran some initial profiles on this PR compared with the parent commit (c1c8d30) and can confirm that it currently has very little impact, but that is mostly because the processing being skipped,
Looking further into the profiling data, it looks like when
|
|
#6873 takes the ideas from this PR and does a few other things. |
|
#6873 implements this Proof of concept so this can be closed. |


Trac ticket https://core.trac.wordpress.org/ticket/61451
Follow-up work for https://core.trac.wordpress.org/ticket/61312
What
This PR tries to optimize the data flow for operating with section styles.
Why
It has proven less optimized than we wanted.
How
At some point, the code transforms the following:
{ "styles": { "blocks": { "variations": { "myVariation": { "title": "My variation", "blockTypes": [ "core/paragraph", "core/group" ], "color": { "background": "yellow" } } } } } }into:
{ "styles": { "blocks": { "core/paragraph": { "color": { "background": "yellow" } }, "core/group": { "color": { "background": "yellow" } } } } }The existing code executes that transformation using the
wp_theme_json_data_*filters – having to recreate theWP_Theme_JSONstructures a few times.The optimization proposed in this PR explores moving that transform into the
WP_Theme_JSONconstructor directly, following what we do withappearanceToolssettings.Test
TBD.