[wp-trac] [WordPress Trac] #61312: Add section styling via extended block style variations

WordPress Trac noreply at wordpress.org
Mon Jun 17 16:22:32 UTC 2024


#61312: Add section styling via extended block style variations
-------------------------------------------------+-------------------------
 Reporter:  aaronrobertshaw                      |       Owner:
                                                 |  aaronrobertshaw
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.6
Component:  Editor                               |     Version:  trunk
 Severity:  normal                               |  Resolution:
 Keywords:  gutenberg-merge has-unit-tests       |     Focuses:
  needs-patch                                    |  performance
-------------------------------------------------+-------------------------

Comment (by oandregal):

 > Why is this query done on init on every page load? Can this lazy loaded
 instead and only in the relevant areas?

 In https://github.com/WordPress/wordpress-develop/pull/6844 I shared more
 context about this:

 > Initially, this feature worked by registering the block style variations
 using the `wp_theme_json_data_*` filters, see
 https://core.trac.wordpress.org/changeset/58264. This approach proved
 problematic for this flow: the user updates the styles of any of them via
 the global styles sidebar.
 >
 > This feature was updated to use the `init` hook at
 https://core.trac.wordpress.org/changeset/58394 The rationale was that
 this hook is what themes currently do to register the block styles
 variations via the `functions.php` (example from TwentyTwentyFour:
 https://github.com/WordPress/wordpress-
 develop/blob/99bc097e5eb1d751b472b1f6da97548ec3b067c2/src/wp-
 content/themes/twentytwentyfour/functions.php#L147). This approach raised
 issues: the `init` hook is called during installation, hence the database
 is not set up — which this feature requires, as it retrieves the existing
 global styles for user data.
 >
 > The approach in this PR is similar to how it initially worked, but with
 a couple of tweaks:
 >
 > - It doesn't use the `wp_theme_json_data_*` filters. Instead, this
 registers the variations directly in the `WP_Theme_JSON_Resolver`, saving
 the extra processing required by the filters.
 > - It also registers the block style variations in the global styles
 endpoint, so user updates are reflected immediately in the UI without
 requiring a page reload.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61312#comment:32>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list