Commit Graph

8 Commits

Author SHA1 Message Date
isabel_brison 00b440c27d Editor: move global CSS custom properties to `:root` selector.
Changes the rules outputting global styles CSS custom properties to use `:root` instead of `body`, and cleans up some unused variables.

Props ramonopoly, isabel_brison.
Fixes #61135.

Built from https://develop.svn.wordpress.org/trunk@58123


git-svn-id: http://core.svn.wordpress.org/trunk@57588 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-05-09 04:09:13 +00:00
Pascal Birchler 0f6fc935fe Editor: Prevent PHP warning when parsing duotone hue values.
Props jacobcassidy, rahmohn, mukesh27.
Fixes #59496.
Built from https://develop.svn.wordpress.org/trunk@57652


git-svn-id: http://core.svn.wordpress.org/trunk@57153 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-02-18 14:59:07 +00:00
Sergey Biryukov 25a147845b I18N: Move code out of translatable strings in a few error messages.
Follow-up to [54272], [56101].

Props rabmalin, Presskopp.
Fixes #59563.
Built from https://develop.svn.wordpress.org/trunk@57135


git-svn-id: http://core.svn.wordpress.org/trunk@56646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-11-25 21:19:30 +00:00
hellofromTonya ab9c4659ae Editor: Fix render_duotone_support() to be compatible with enhanced pagination.
Some blocks do not have content. For duotone support, blocks without content still need to run through the `render_duotone_support()` to render their duotone CSS.

This fix makes the duotone compatible with the enhanced pagination (introduced in 6.4.0) by making sure that the CSS is always on the page, even when the posts have no featured image. It also prevents the duotone from interfering with other blocks using `wp_unique_id()`.


References:
* [https://github.com/WordPress/gutenberg/pull/55415 Gutenberg PR 55415]

Follow-up to [56226].

Props cbravobernal, luisherranz, hellofromTonya, isabel_brison, jorbin.
Fixes #59694.
Built from https://develop.svn.wordpress.org/trunk@56991


git-svn-id: http://core.svn.wordpress.org/trunk@56502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-10-23 23:39:20 +00:00
Sergey Biryukov 9bf6faff7c Editor: Reduce the use of the `_wp_array_get()` function to improve performance.
`_wp_array_get()` is an expensive function, and it's called thousands of times on each page view on the front end. While the function performance was slightly improved in #58376, it is still called more times than it should be.

This commit aims to further optimize its usage:
* In many cases, `_wp_array_get()` can be replaced with a much simpler and faster `isset()` check.
* The `isset()` function is capable of checking nested arrays, so `isset( $foo['a']['b']['c'] )` will return false even if `$foo['a']` is unset, without throwing any errors or warnings.
* When `_wp_array_get()` cannot be directly replaced with `isset()`, it would be good practice to wrap it in an `isset()` function so that `_wp_array_get()` only runs when it needs to.

Original PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/51116 #51116 Performance improvement: Reduce the use of the _wp_array_get() function]

Follow-up to [55851], [56382].

Props aristath, jrf, spacedmonkey, mukesh27, swissspidy, hellofromTonya.
Fixes #59405.
Built from https://develop.svn.wordpress.org/trunk@56709


git-svn-id: http://core.svn.wordpress.org/trunk@56221 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-26 13:47:20 +00:00
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
isabel_brison 059ce00442 Editor: fix duotone filters in classic themes.
Makes sure duotone block styles are output in the front end on classic themes.

Props ajlende, jeryj, spacedmonkey, vivekawsm, sabernhardt, costdev, mrinal013.
Fixes #58734.

Built from https://develop.svn.wordpress.org/trunk@56225


git-svn-id: http://core.svn.wordpress.org/trunk@55737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-13 04:16:26 +00:00
isabel_brison 3de83926d6 Editor: update duotone support.
Updates duotone support after stabilisation of selectors API and adds a few small code quality and UI improvements.

Props onemaggie, peterwilsoncc, ajlende, audrasjb, mikeschroder, ramonopoly.
Fixes #58555.

Built from https://develop.svn.wordpress.org/trunk@56101


git-svn-id: http://core.svn.wordpress.org/trunk@55613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-29 06:21:28 +00:00