WordPress/wp-includes/block-supports
spacedmonkey 748bb7d73a Editor: Lazily load Duotone settings only when needed.
Introduced in [56101] the `WP_Duotone` class, hooks into the `wp_loaded` action to load duotone style data from global styles. Hooking in early in the bootstrap process caused a number of problems. This hook, triggered an error on installing, as this lookup for global styles, would result in a global post trying to be created, even before the table existed. Additionally, this implementation caused a severe performance regression, as duotone styling data was loaded unnecessarily for requests that did not require such data, such as REST API calls or actions within the wp-admin interface.

In this change, refactor the `WP_Duotone` to lazily load the global styles and theme.json data, only when a block that supports duotone is encountered. The method `render_duotone_support` was change to take a third parameter to reuse the existing `WP_Block_Type` object passed to the filter, to save it being looked up again. The code has also got improved type checking and the use of the util function  `block_has_support`. Furthermore, the code's readability has been improved, along with enhancements to the documentation blocks.

Props Chouby, spacedmonkey, SergeyBiryukov, swissspidy, costdev, joemcgill, flixos90, mukesh27, nazmul111, ajlende, isabel_brison.
Fixes #58673.
Built from https://develop.svn.wordpress.org/trunk@56226


git-svn-id: http://core.svn.wordpress.org/trunk@55738 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-13 11:34:28 +00:00
..
align.php Docs: Miscellaneous Docblock corrections in several `/block-supports` files. 2021-12-01 23:16:04 +00:00
border.php Editor: Backport block supports (border, color, elements, spacing) from Gutenberg to WP 6.1. 2022-09-19 20:14:10 +00:00
colors.php Docs: Use third-person singular verbs for Block Supports related function descriptions, as per docblocks standards. 2022-11-24 22:36:11 +00:00
custom-classname.php Docs: Use third-person singular verbs for Block Supports related function descriptions, as per docblocks standards. 2022-11-24 22:36:11 +00:00
dimensions.php Editor: Introduce minimum height dimensions block support. 2023-02-01 16:15:15 +00:00
duotone.php Editor: Lazily load Duotone settings only when needed. 2023-07-13 11:34:28 +00:00
elements.php Editor: add support for block-level link hover colors. 2023-06-26 01:15:21 +00:00
generated-classname.php Docs: Various docblock fixes in Block Supports related functions. 2022-11-24 22:52:11 +00:00
layout.php Editor: stabilise layout and refactor definitions. 2023-06-27 07:25:22 +00:00
position.php Editor: `svn add` new files missed in [55285]. 2023-02-07 18:11:18 +00:00
settings.php Editor: fix comment indentation. 2023-07-06 04:41:23 +00:00
shadow.php Editor: add box shadow support to blocks. 2023-06-26 23:44:29 +00:00
spacing.php Docs: Various docblock fixes in Block Supports related functions. 2022-11-24 22:52:11 +00:00
typography.php Editor: add text columns to typography support. 2023-06-22 08:18:19 +00:00
utils.php Editor: Backport block support changes from the Gutenberg plugin 2022-04-05 12:08:02 +00:00