Commit Graph

104 Commits

Author SHA1 Message Date
audrasjb ddd50e3782 Editor: Add a `description` key to `theme.json` style variations.
This changeset adds `description` to `VALID_TOP_LEVEL_KEYS` in `class-wp-theme-json.php` to allow for accessibility improvements. The description is added to 
the ARIA label of the style variation container. If the style variation has no description, only the title is used. One purpose is to use the text description 
to improve the style variation preview in the WordPress.org theme directory.

See https://github.com/WordPress/gutenberg/pull/45242.

Props ramonopoly, poena.
Fixes #58614.

 --Cette ligne, et les suivantes ci-dessous, seront ignorées--

M    trunk/src/wp-includes/class-wp-theme-json.php

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


git-svn-id: http://core.svn.wordpress.org/trunk@55553 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-26 18:15:22 +00:00
Weston Ruter 33f71c4662 Editor: Use static closures to avoid memory leaks.
Backports Gutenberg changes from https://github.com/WordPress/gutenberg/pull/50723.

Amends [55822].

Fixes #58323.
Props westonruter, spacedmonkey, flixos90. 

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


git-svn-id: http://core.svn.wordpress.org/trunk@55550 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-26 17:00:25 +00:00
isabel_brison 2fbd7aeb8f Editor: add support for block-level link hover colors.
Adds the ability to set link hover colors for individual blocks from the block inspector color panel.

Props @youknowriad, @peterwilsoncc, @kebbet.
Fixes #58575.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55540 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-26 01:15:21 +00:00
Sergey Biryukov b916b71dde Code Modernization: Use `str_starts_with()` in `WP_Theme_JSON` class methods.
This aims to make the code more readable and consistent, as the function is already used extensively in core files.

WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.

Follow-up to [55703], [55959].

Props spacedmonkey.
Fixes #58012.
Built from https://develop.svn.wordpress.org/trunk@55987


git-svn-id: http://core.svn.wordpress.org/trunk@55499 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 14:14:25 +00:00
oandregal f3ea3c57cb `wp_get_global_styles`: allow transforming the CSS Custom Properties into the values they represent.
Props samnajian, ramonopoly, isabel_brison.
Fixes #58588.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55498 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 08:44:26 +00:00
isabel_brison 2183172222 Editor: add text columns to typography support.
Adds a text columns feature to the typography block support that uses CSS `column-count` for multi-column text.

Props ramonopoly, aaronrobertshaw.
Fixes #58549.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55497 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 08:18:19 +00:00
isabel_brison cf320a85d3 Editor: add grid layout type
Add a new `grid` type to the layout block support.

Props andrewserong, costdev, ramonopoly.
Fixes #58554.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55487 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 04:06:26 +00:00
oandregal 99715f5751 `wp_get_global_styles`: return the standard format for CSS Custom Properties.
Props samnajian, hellofromtonya, isabel_brison.
Fixes #58467.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55471 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-21 07:56:18 +00:00
isabel_brison 06beef84d5 Editor: revert add grid layout type
Reverting the previous commit because it causes e2e to fail on trunk.

See #58554.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55470 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-21 06:58:18 +00:00
isabel_brison 03f5a6e91d Editor: add grid layout type
Add a new `grid` type to the layout block support.

Props andrewserong, costdev, ramonopoly.
Fixes #58554.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55469 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-21 05:56:21 +00:00
isabel_brison 49aa42f3b6 Editor: update layout classnames and specificity.
Adds a compound layout classname and reduces layout spacing rule specificity.

Props ramonopoly, andrewserong, poena.
Fixes #58548.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55468 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-21 05:32:19 +00:00
Felix Arntz ae515caebf Editor: Introduce `WP_Theme_JSON::prepend_to_selector()` to improve code quality and performance.
The `WP_Theme_JSON::append_to_selector()` method was previously used for both appending and prepending which violated the single responsibility principle. It resulted in additional conditionals which also came at a performance cost, particularly because the method is called over 1,000 times during a regular WordPress request.

With the new `WP_Theme_JSON::prepend_to_selector()` method, there are now two distinct methods for the two distinct purposes. The now useless third parameter on `WP_Theme_JSON::append_to_selector()` has been removed (rather than deprecated), which is acceptable given that it is a protected method on a class that is not intended for extensions.

Props bor0, costdev, flixos90, isabel_brison, oandregal, spacedmonkey.
Fixes #58193.
See #58457.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55462 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 17:54:19 +00:00
isabel_brison ae884fdc62 General: fix `overridden` typos.
Fixes two typos in `class-wp-theme-json`.

Props Aristath, nihar007, kapilpaul, oandregal, krupalpanchal.
Fixes #58464.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55457 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 04:59:18 +00:00
oandregal ddc2c454be Fix lint issues in WP_Theme_JSON::sanitize method.
Add @since tag and indent the parameter properly.

Props mukesh27.
Fixes #58462.


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


git-svn-id: http://core.svn.wordpress.org/trunk@55427 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-14 10:46:19 +00:00
oandregal 86bad3cdf6 Ignore unregistered block style variations from `theme.json`.
This PR makes sure unregistered block style variations declared via `theme.json` are ignored. It fixes an issue by style variations don't work in the editor and CSS rules without a selector are output to the front-end.

Props isabel_brison.
Fixes #58462.


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


git-svn-id: http://core.svn.wordpress.org/trunk@55424 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-14 07:42:19 +00:00
spacedmonkey a56a09c4ba Editor: Improve the append_to_selector method.
Improve `append_to_selector` method in `WP_Theme_JSON` by checking to see if string contains a common before imploding / exploding string, which improves performance. 

Originally developed and tested in [WordPress/gutenberg#47833 Gutenberg PR 47833].

Props spacedmonkey, flixos90, mukesh27, joemcgill, wildworks, oandregal, mamaduka.
Fixes #58231.
Built from https://develop.svn.wordpress.org/trunk@55907


git-svn-id: http://core.svn.wordpress.org/trunk@55419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-12 11:22:23 +00:00
Sergey Biryukov 2ffb7ef083 Docs: Update code examples formatting in `WP_HTML_Tag_Processor` documentation.
Per the [https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#description documentation standards], code samples should be created by indenting every line of the code by 4 spaces, with a blank line before and after. This matches the format used by the rest of core.

Follow-up to [55203], [55304], [55718], [55724].

Props juanmaguitar, coffee2code, azaozz, costdev, dmsnell, johnbillion, SergeyBiryukov.
Fixes #58028.
Built from https://develop.svn.wordpress.org/trunk@55727


git-svn-id: http://core.svn.wordpress.org/trunk@55239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-08 17:32:24 +00:00
John Blackbourn b155956792 Docs: Miscellaneous formatting corrections to inline docs and whitespace.
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55224 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 19:46:21 +00:00
John Blackbourn c83f4cb97a Docs: Corrections and improvements to docblocks for global styles, global settings, theme.json parsing, and shortcodes.
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55223 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 18:48:22 +00:00
audrasjb 0bccdce442 Docs: Use correct 6.2.0 @since version in multiple docblocks.
Props kebbet, audrasjb, mukesh27.
See #56792.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-15 22:56:20 +00:00
Peter Wilson 5deb3698e5 Editor: Prevent KSES stripping global layout style properties.
Layout style properties are stored using indirect values, rather than direct CSS properties. 

Allow users without the `unfiltered_html` capability to modify global styles using the indirect block spacing properties `contentSize`, `wideSize`, and `blockGap`, using a mapping of the eventual CSS property to the indirect property stored in `theme.json`. The mapped CSS property is then used for CSS validation.

Props andrewserong, costdev, hellofromtonya, mamaduka, mmtr86.
Fixes #57321.



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


git-svn-id: http://core.svn.wordpress.org/trunk@54878 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-15 03:57:17 +00:00
davidbaumwald f5d681f4bd Editor: Introduce sticky position block support.
In the Gutenberg plugin, a position block support feature was introduced last year, that allows a Group block to be set to a "sticky" position, meaning that when the page scrolls, the block will stick to the top of the window.

This change merges the "sticky" position feature for blocks introduced in Gutenberg 15.0.

Props andrewserong, flixos90, mukesh27.
Fixes #57618.
Built from https://develop.svn.wordpress.org/trunk@55285


git-svn-id: http://core.svn.wordpress.org/trunk@54818 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 18:01:20 +00:00
jorgefilipecosta bd2eae6719 Block editor: Add frontend block-level settings to the core.
This commit adds block-level settings in the core. Block level settings allow a block to define the preset settings of its nested blocks using the same shape as theme.json.

Props oandregal, Mamaduka, jorgefilipecosta, dmsnell, adamziel.
57651 #57651.
Built from https://develop.svn.wordpress.org/trunk@55255


git-svn-id: http://core.svn.wordpress.org/trunk@54788 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:42:20 +00:00
Felix Arntz 1856b98771 Editor: Add missing `WP_Theme_JSON::process_blocks_custom_css()` method.
Follow up to [55192].

Props aristath, mamaduka, mukesh27, hellofromtonya.
Fixes #57621.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54749 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 18:25:22 +00:00
Felix Arntz 5b4af6125a Editor: Add support for custom CSS in global styles.
This changeset introduces functions `wp_get_global_styles_custom_css()` and `wp_enqueue_global_styles_custom_css()`, which allow accessing and enqueuing custom CSS added via global styles.

Custom CSS via global styles is handled separately from custom CSS via the Customizer. If a site uses both features, the custom CSS from both sources will be loaded. The global styles custom CSS is then loaded after the Customizer custom CSS, so if there are any conflicts between the rules, the global styles take precedence.

Similarly to e.g. [55185], the result is cached in a non-persistent cache, except when `WP_DEBUG` is on to avoid interrupting the theme developer's workflow.

Props glendaviesnz, oandregal, ntsekouras, mamaduka, davidbaumwald, hellofromtonya, flixos90.
Fixes #57536.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54725 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 18:52:17 +00:00
hellofromTonya 263ef5505d Themes: Add shadow presets support for theme.json.
Adds shadow presets support for `theme.json` within the `WP_Theme_JSON` by 

* Adding it to presets metadata and valid settings.
* Defining the default shadow presets in Core's `theme.json`.

Includes PHPUnit tests. 

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

Follow-up to [54162], [52049], [50973].

Props madhudollu, mamaduka, oandregal, scruffian, hellofromTonya.
Fixes #57559.
Built from https://develop.svn.wordpress.org/trunk@55176


git-svn-id: http://core.svn.wordpress.org/trunk@54709 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 18:07:12 +00:00
hellofromTonya 048b304deb Editor: Introduce minimum height dimensions block support.
This changeset adds the new dimension feature's PHP code for supporting minimum height in the block editor inspector and in global styles. Minimum height is quite useful for defining the minimum vertical dimensions of a block, while allowing it to expand beyond that size. 

In this changeset:

* Adds support in `theme.json`.
* Adds support in the style engine.
* Adds support in `wp_apply_dimensions_support()`.
* Renames the setting from `'__experimentalDimensions'` to `dimensions` in `wp_register_dimensions_support()`.
* Adds PHPUnit tests.

Is renaming `'__experimentalDimensions'` a backwards-compatibility (BC) break?

Though the setting has been in the code since 5.9.0, it was never wired to anything, ie it did not expose any controls or styles. Notice in `wp_register_dimensions_support()` and `wp_apply_dimensions_support()` prior to this changeset, there are inline comments as placeholders for height and width support, but no code.

If a developer opted in to use it, it had no effect.

A search in wp.org's plugin and themes repo showed no instances of this experimental setting.

Given there was no functionality attached to it (until this changeset), no change in behavior or effect from removing it, and no usage found in the plugins and themes repository, it does appear to be a BC break.

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

Follow-up to [53076], [52069].

Props andrewserong, aaronrobertshaw , costdev, hellofromTonya, isabel_brison, joen, paaljoachim, mukesh27, ntsekouras, oandregal, ramonopoly.
Fixes #57582.
Built from https://develop.svn.wordpress.org/trunk@55175


git-svn-id: http://core.svn.wordpress.org/trunk@54708 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 16:15:15 +00:00
hellofromTonya cafd7544c2 Editor: Add support for editing block style variations in global styles.
To allow editing of block style variations in global styles, this changeset adds the following for server side support:

* building of block style schema into `WP_Theme_JSON::sanitize()`.
* appending of style variation selectors to block metadata in `WP_Theme_JSON::get_blocks_metadata()`.
* building of selectors and variations for nodes in `WP_Theme_JSON::get_block_nodes()`.

Tests for happy and unhappy paths are included.

Reference:
* [https://github.com/WordPress/gutenberg/pull/46343 Gutenberg PR 46343]

Follow-up to [54118], [50973], [50959].

Props isabel_brison, 
Fixes #57583.
Built from https://develop.svn.wordpress.org/trunk@55172


git-svn-id: http://core.svn.wordpress.org/trunk@54705 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-01 13:43:18 +00:00
Felix Arntz d0e699bb2c Editor: Fix undefined variable following [54805].
Props mamaduka, costdev, mukesh27.
See #56974, #57067.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-25 22:09:13 +00:00
Sergey Biryukov eda80ba004 Code Modernization: Rename parameters that use reserved keywords in `wp-includes/class-wp-theme-json.php`.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit renames the `$default` parameter to `$default_value` in `WP_Theme_JSON::get_metadata_boolean()`.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965], [54969], [54970], [54971], [54972], [54996], [55000], [55011], [55013], [55014], [55015], [55016], [55017], [55020], [55021], [55023], [55027], [55028], [55034], [55036], [55037], [55038], [55039], [55049], [55050], [55060], [55062], [55064], [55065], [55076], [55077], [55078], [55081], [55090], [55100], [55104], [55112], [55115], [55116], [55117], [55119], [55120], [55126], [55127].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55129


git-svn-id: http://core.svn.wordpress.org/trunk@54662 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-24 15:45:11 +00:00
audrasjb 0939d89ded Themes: Support additional link related pseudo classes in `theme.json`.
This changeset adds support for `:link` and `:any-link` in `theme.json`, using the `VALID_ELEMENT_PSEUDO_SELECTORS` array. `:link` can be used to style unvisited links and `:any-link` can be used to style any link containing an `href` attribute.

Props peterwilsoncc, whaze, audrasjb, costdev, mukesh27.
Fixes #57053.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-24 08:11:15 +00:00
Sergey Biryukov 9dfc9375da Themes: Alphabetize the properties list in `WP_Theme_JSON::VALID_STYLES` for consistency.
Follow-up to [53129], [54253], [55008].

See #57354.
Built from https://develop.svn.wordpress.org/trunk@55009


git-svn-id: http://core.svn.wordpress.org/trunk@54542 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-20 13:57:15 +00:00
hellofromTonya 3ddfa88245 Themes: Adds outline CSS properties support in theme.json.
Adds the ability to define outline CSS properties for elements and blocks within `theme.json` to render `outline-color`, `outline-offset`, `outline-style`, and `outline-width` styles.

Originally developed and tested in [https://github.com/WordPress/gutenberg/pull/43526 Gutenberg PR 43526].

Props onemaggie, hellofromTonya, audrasjb, ironprogrammer.
Fixes #57354.
Built from https://develop.svn.wordpress.org/trunk@55008


git-svn-id: http://core.svn.wordpress.org/trunk@54541 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-19 20:55:13 +00:00
Sergey Biryukov cede832fb1 Docs: Fix typo in the `WP_Theme_JSON::PRESETS_METADATA` constant description.
Follow-up to [53129].

Props kebbet, mukesh27.
See #56792.
Built from https://develop.svn.wordpress.org/trunk@54853


git-svn-id: http://core.svn.wordpress.org/trunk@54405 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-17 16:58:20 +00:00
desrosj 39f1141e78 Editor: Correctly style separator blocks when only a `background-color` is defined.
When separator blocks are configured using only a `background-color`, they are shown correctly within the editor but not on the front end.

This changes `WP_Theme_JSON` to detect this scenario and move the `background-color` value to just `color` when both `color` and `border-color` are missing.

Props cbravobernal, flixos90, davidbaumwald, hellofromTonya, desrosj, andrewserong, czapla, glendaviesnz, wildworks.
Fixes #56903.
Built from https://develop.svn.wordpress.org/trunk@54821


git-svn-id: http://core.svn.wordpress.org/trunk@54373 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-11 17:11:10 +00:00
Felix Arntz 702344e383 Editor: Improve performance of `WP_Theme_JSON` class by reducing usage of expensive array functions.
In many scenarios array functions are more expensive than using simpler `for` or `foreach` loops.

This changeset results in roughly 4% faster `wp_head` execution time for both block themes and classic themes. While this may seem like a small win, it is a worthwhile enhancement and only one part of several other little performance tweaks which are being worked on to improve performance of `theme.json` parsing further.

Props aristath, desrosj, jrf, spacedmonkey.
Fixes #56974.
See #57067.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54356 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-11 01:50:11 +00:00
Felix Arntz 2a57dd7f86 Editor: Avoid running certain logic around `theme.json` parsing unnecessarily for classic themes.
Here's what it does:
* Do not load and parse `theme-i18n.json` schema if the theme does not have a `theme.json` file.
* Fix the variable caching layer around the theme's `theme.json` parsing so that a parent's theme `theme.json` is cached as well.
* Do not run a `WP_Query` for global styles for a user when the theme does not have a `theme.json`.

In a basic WordPress setup, this changeset improves `wp_head` execution time for classic themes by 10%, and overall response time for both block themes and classic themes by 4%. This may seem like a small win, but 4% reduced overall response time is actually quite a bit for one change, and it is worth mentioning that this is just one of several other little performance tweaks which are being worked on to improve performance of `theme.json` parsing further.

Props flixos90, manuilov, oandregal, peterwilsoncc, spacedmonkey.
Fixes #56945.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54351 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-10 22:16:15 +00:00
Peter Wilson 63f944e831 Themes: Re-order valid link pseudo classes.
Re-order the link pseudo classes to follow the long term LoVe (F)HA rule when set via `theme.json`.

In order that the CSS cascade behaves in a predictable manner, it's recommended that the selectors follow the order `:visited`, `:focus`/`:hover`, `:active`. As order affects the specificity, this ensures the interaction states override the visited states. CSS specificity is really quite beautiful, although complex.

Props mikachan, sabernhardt, davidbaumwald, mukesh27, Mamaduka, desrosj.
Fixes #56928.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-09 04:08:16 +00:00
hellofromTonya 88cee0d359 Editor: Rename new `theme_json_{$context}` filters.
The newly introduced filters are renamed to use the `wp_theme_json_data{$context}` structure:

* `theme_json_default` renamed to `wp_theme_json_data_default`
* `theme_json_theme` renamed to `wp_theme_json_data_theme`
* `theme_json_blocks` renamed to `wp_theme_json_data_blocks`
* `theme_json_user` renamed to `wp_theme_json_data_user`

The following new filter gets the `wp_` prefix added:
* `theme_json_get_style_nodes` renamed to `wp_theme_json_get_style_nodes`

Follow-up to [56467], [54183], [54118].

Props kebbet, desrosj, mukesh27, ocean90, sergeybiryukov, davidbaumwald, hellofromTonya.
Fixes #56796.
Built from https://develop.svn.wordpress.org/trunk@54501


git-svn-id: http://core.svn.wordpress.org/trunk@54060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-11 20:08:12 +00:00
davidbaumwald b0a8a8b46e Editor: Merge latest fluid typography bugfixes for 6.1 Release Candidate 1.
Merges the following:
* [https://github.com/WordPress/gutenberg/pull/44761 Gutenberg PR 44761] - Fluid Typography: Fix bug in global styles where fluid `clamp()` rules were not calculated for custom values
* [https://github.com/WordPress/gutenberg/pull/44762 Gutenberg PR 44762] - Fluid Typography: Convert server-side block support values
* [https://github.com/WordPress/gutenberg/pull/44764 Gutenberg PR 44764] - Fluid Typography: Convert font size inline style attributes to fluid values
* [https://github.com/WordPress/gutenberg/pull/44807 Gutenberg PR 44807] - Fluid Typography: Covert font size number values to pixels
* [https://github.com/WordPress/gutenberg/pull/44847 Gutenberg PR 44847] - Fluid Typography: ensure font sizes are strings or integers

Follow-up to [54280].

Props andrewserong, isabel_brison, ramonopoly.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54497


git-svn-id: http://core.svn.wordpress.org/trunk@54056 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-11 18:44:13 +00:00
audrasjb cd0a4ee190 Docs: Various docblock fixes in `WP_Theme_JSON` class, as per documentation standards.
Follow-up to [54408].

See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53970 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-07 12:01:13 +00:00
jorgefilipecosta 148049329d Fix: cite styles declared via theme.json not working.
Fixes an issue where cite elements declared on theme.json are not being output on the front end of the website.

Props oandregal, carolinan, scruffian.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54409


git-svn-id: http://core.svn.wordpress.org/trunk@53968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-07 09:46:13 +00:00
audrasjb ae50e2c014 Editor: Add missing `blocks` origin to `theme.json`.
This changeset updates the blocks origin name from core to blocks and adds it to the list of valid origins for `theme.json`.
(See the original fix in [https://github.com//pull/3319 Gutenberg's PR 44363]).

Why?

- This new origin was missing from the list.
- The `core` name is not reflective of what it does, as this data origin is related to block styles, whether they come with WordPress or third-party blocks.
- The existing filter for this piece of data is called `theme_json_blocks`, to reflect it filters "block" data.
- Though `core` origin was used in the past for `default`, this commit reverts it. Why? It was confusing. The goal is to use names that communicate what part of the pipeline are processing (`default > blocks > theme > custom`).

How?

- Renames the string, from `core` to `blocks`.
- Adds `blocks` to the list of valid origins.
- Verifies that the `$theme_json->get_stylesheet()` call uses the proper `$origins` at all times.

Follow-up to [54162], [54251].

Props oandregal, czapla, jorgefilipecosta, scruffian, bernhard-reiter hellofromTonya.
See #56467.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53967 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-07 09:40:13 +00:00
Sergey Biryukov 4943dbf577 Themes: Replace `array_map()` usage in `WP_Theme_JSON::get_default_slugs()`.
When loading a page on the frontend using Xdebug & Webgrind, with the Twenty Twenty-Three theme and no plugins activated, the biggest performance bottleneck currently (on the PHP side) is `WP_Theme_JSON::merge()`. Analysing the data a bit more, it became evident that `WP_Theme_JSON::get_default_slugs()` is the part of that method which takes most of the resources and time.

Further analysis of the method revealed that `array_map()` was the call that slowed it down.

This commit replaces the `array_map()` call with a simple `foreach` loop, improving page load speed significantly.

Follow-up to [52275], [52364].

Props aristath.
Fixes #56745.
Built from https://develop.svn.wordpress.org/trunk@54398


git-svn-id: http://core.svn.wordpress.org/trunk@53957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-06 15:27:13 +00:00
davidbaumwald 335ecfdca9 Editor: Invalidate blocks metadata cache when needed in `WP_Theme_JSON::get_blocks_metadata()`.
This change ensures that user-supplied global styles settings for blocks aren't lost due to sanitization.  This could previously occur due to outdated blocks metadata that did not include all registered blocks.

Props jorgefilipecosta, andrewserong, oandregal, talldanwp, cbravobernal, bernhard-reiter, hellofromTonya.
Fixes #56644.
Built from https://develop.svn.wordpress.org/trunk@54385


git-svn-id: http://core.svn.wordpress.org/trunk@53944 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-04 15:50:12 +00:00
davidbaumwald 9b493706ef Editor: Cast `theme.json` values to `string` on theme export.
Props glendaviesnz.
See #56684.
Built from https://develop.svn.wordpress.org/trunk@54363


git-svn-id: http://core.svn.wordpress.org/trunk@53922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-30 14:48:12 +00:00
Sergey Biryukov 35fb05f30d Code Modernization: Fix null to non-nullable deprecation in `WP_Theme_JSON::get_property_value()`.
This commit aims to fix errors caused by incorrect usage of the `strncmp()` function inside the `WP_Theme_JSON::get_property_value()` method on PHP 8.1 and above.

Some history of the affected code:
* [50973] introduced the `WP_Theme_JSON::get_property_value()` method.
* [54162] removed the `$default` parameter from the `_wp_array_get()` call in the method.

With the latter change, the default value that is returned if the path does not exist within the array, or if `$array` or `$path` are not arrays, became `null` instead of an empty string. Since `null` would then be unintentionally passed to the `strncmp()` function further in the code, this caused ~35 errors in the test suite along the lines of:
{{{
1) Tests_Blocks_Editor::test_get_block_editor_settings_theme_json_settings
strncmp(): Passing null to parameter #1 ($string1) of type string is deprecated

/var/www/src/wp-includes/class-wp-theme-json.php:1754
/var/www/src/wp-includes/class-wp-theme-json.php:1641
/var/www/src/wp-includes/class-wp-theme-json.php:2066
/var/www/src/wp-includes/class-wp-theme-json.php:1002
/var/www/src/wp-includes/class-wp-theme-json.php:898
/var/www/src/wp-includes/global-styles-and-settings.php:140
/var/www/src/wp-includes/block-editor.php:421
/var/www/tests/phpunit/tests/blocks/editor.php:388
/var/www/vendor/bin/phpunit:123
}}}

This commit includes:
* Restoring the `$default` value for `_wp_array_get()` call.
* Adding an early return if the value is an empty string or `null`.
* Adding a dedicated unit test to ensure that the method returns a string for invalid paths or `null` values.

Follow-up to [50973], [54162].

Props antonvlasenko, jrf, imadarshakshat, SergeyBiryukov.
Fixes #56620.
Built from https://develop.svn.wordpress.org/trunk@54362


git-svn-id: http://core.svn.wordpress.org/trunk@53921 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-30 00:40:11 +00:00
davidbaumwald 0296dc6d98 Editor: Ensure settings for fluid typography and `spacingScale` are not lost on theme export.
This change adds fluid typography as a valid setting and removes `spacingScale` from the array of presets.

Props glendaviesnz, ramonopoly, tellthemachines.
See #55646.
Built from https://develop.svn.wordpress.org/trunk@54360


git-svn-id: http://core.svn.wordpress.org/trunk@53919 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-29 19:45:09 +00:00
jorgefilipecosta 5e32e7de29 Fix: Revert [54305].
This commit caused an incompatibility with the latest released Gutenberg version.

Props bernhard-reiter.
Built from https://develop.svn.wordpress.org/trunk@54306


git-svn-id: http://core.svn.wordpress.org/trunk@53865 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-26 10:17:11 +00:00
jorgefilipecosta 7882623807 Editor: Fix missing frontend section presets output.
Backports PHP changes in WordPress/gutenberg#42124 to the core. Adds the missing mechanism to output frontend styles of block level presets to the core.

Props mcsf, oandregal, dmsnell, draganescu.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54305


git-svn-id: http://core.svn.wordpress.org/trunk@53864 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-26 09:08:21 +00:00