Commit Graph

64 Commits

Author SHA1 Message Date
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
audrasjb
325e60a744 Editor: Introduce spacing presets in global style properties.
This changeset is part of the Gutenberg changes merged into WP 6.1. It adds spacing presets support in global style properties.

Follow-up to [54211].

Props glendaviesnz, andrewserong, costdev, audrasjb, mukesh27.
See #56467.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53831 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-21 11:43:13 +00:00
hellofromTonya
b29bbddb5f Editor: Introduces fluid typography and uses Style Engine.
This commit introduces fluid typography block supports and switches to use the Style Engine for typography and colors.

The motivation for fluid typography block supports:
>"Fluid typography" describes how a site's font sizes adapt to every change in screen size, for example, growing larger as the viewport width increases, or smaller as it decreases.
>
>Font sizes can smoothly scale between minimum and maximum viewport widths.

Typography changes introduced from Gutenberg:

* Uses the Style Engine to generate the CSS and classnames in `wp_apply_typography_support()`.
* Introduces `wp_typography_get_preset_inline_style_value()` for backwards-compatibility.
* Introduces a private internal function called `wp_get_typography_value_and_unit()`, for checking and getting typography unit and value.
* Introduces a private internal function called  `wp_get_computed_fluid_typography_value()`, for an internal implementation of CSS `clamp()`.
* Deprecates `wp_typography_get_css_variable_inline_style()`.

References:
* [https://github.com/WordPress/gutenberg/pull/40332 WordPress/gutenberg PR 40332] Style Engine: add typography and color to backend
* [https://github.com/WordPress/gutenberg/pull/39529 WordPress/gutenberg PR 39529] Block supports: add fluid typography

Follow-up to [53076], [52302], [52069], [51089], [50761], [49226].

Props ramonopoly, youknowriad, aristath, oandregal, aaronrobertshaw, cbirdsong, jorgefilipecosta, ironprogrammer, hellofromTonya.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54260


git-svn-id: http://core.svn.wordpress.org/trunk@53819 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 15:47:09 +00:00
desrosj
62f77df49a Editor: Add box-shadow support for blocks through theme.json files.
This makes it possible to add `box-shadow` to specific blocks (such as buttons or groups), allowing this to be configured in block themes without custom CSS.

Props andrewserong, cbravobernal, madhudollu, scruffian, onemaggie.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54253


git-svn-id: http://core.svn.wordpress.org/trunk@53812 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 13:50:09 +00:00
Sergey Biryukov
335203e971 Editor: Finalize the theme_json_get_style_nodes hook name.
This consolidates the name of a filter introduced earlier in the 6.1 cycle, renaming it from `get_style_nodes` to `theme_json_get_style_nodes` as to be more coherent with the other hooks introduced in 6.1 as well.

This commit backports the original PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/44189 #44189 Use prefix 'theme_json_' in hooks related to theme.json]

Reference: [https://github.com/WordPress/wordpress-develop/pull/3247 #3247 Add hooks to filter theme.json data].

Follow-up to [54118].

Props oandregal, scruffian, bernhard-reiter.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54183


git-svn-id: http://core.svn.wordpress.org/trunk@53742 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-15 20:28:18 +00:00
hellofromTonya
bfcd054304 Editor: Backport foundation for Layout block support refactor (part 1).
Backports the following changes from the Gutenberg repository:

* [WordPress/gutenberg/40875 gutenberg/40875] Layout: Use semantic classnames, centralize layout definitions, reduce duplication, and fix blockGap in theme.json
* [WordPress/gutenberg/42544 gutenberg/42544] Layout: Add a disable-layout-styles theme supports flag to opt out of all layout styles gutenberg/42544
* [WordPress/gutenberg/42087 gutenberg/42087] Theme.json: Add block support feature level selectors for blocks gutenberg/42087
* [WordPress/gutenberg/43792 gutenberg/43792] Global Styles: Split root layout rules into a different function gutenberg/43792
* [WordPress/gutenberg/42544 gutenberg/42544] Layout: Add a disable-layout-styles theme supports flag to opt out of all layout styles gutenberg/42544
* [WordPress/gutenberg/42665 gutenberg/42665] Layout: Reduce specificity of fallback blockGap styles gutenberg/42665
* [WordPress/gutenberg/42085 gutenberg/42085] Core CSS support for root padding and alignfull blocks gutenberg/42085

Notes:
* It doesn't entirely port over PR 40875 — the remaining PHP changes for that PR will be explored in a separate PR targeting `layout.php`.
* [54159] was reverted in [54160] due to PHPUnit test failures for tests added by the commit. Later, tests passed when applied on top of `trunk`. There were various outages today of upstream `wp-env` dependencies, which likely were the root cause of the earlier failures. For historical tracking and to make sure, recommitting [54159] but instead on top of current `trunk`. See PR 3205 for more details.
* Giving additional props for those who did a deep dive investigation into the failed tests.

Follow-up to [54160], [54159].

Props andrewserong, aaronrobertshaw, isabel_brison, bernhard-reiter, hellofromTonya.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54162


git-svn-id: http://core.svn.wordpress.org/trunk@53721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-14 18:44:09 +00:00
hellofromTonya
d5c8952218 Editor: Revert [54159].
Reverting changeset due to failing PHPUnit tests. Tests pass without changeset [54156], but fail with it. Reverting to explore why in the original PR after rebasing.

See #56467.
Built from https://develop.svn.wordpress.org/trunk@54160


git-svn-id: http://core.svn.wordpress.org/trunk@53719 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-14 15:52:11 +00:00
audrasjb
c2ff10f1c1 Editor: Backport foundation for Layout block support refactor (part 1).
This change backports the following changes from Gutenberg repository:

- [WordPress/gutenberg#40875 gutenberg#40875] Layout: Use semantic classnames, centralize layout definitions, reduce duplication, and fix blockGap in theme.json
- [WordPress/gutenberg#42544 gutenberg#42544] Layout: Add a disable-layout-styles theme supports flag to opt out of all layout styles gutenberg#42544
- [WordPress/gutenberg#42087 gutenberg#42087] Theme.json: Add block support feature level selectors for blocks gutenberg#42087
- [WordPress/gutenberg#43792 gutenberg#43792] Global Styles: Split root layout rules into a different function gutenberg#43792
- [WordPress/gutenberg#42544 gutenberg#42544] Layout: Add a disable-layout-styles theme supports flag to opt out of all layout styles gutenberg#42544
- [WordPress/gutenberg#42665 gutenberg#42665] Layout: Reduce specificity of fallback blockGap styles gutenberg#42665
- [WordPress/gutenberg#42085 gutenberg#42085] Core CSS support for root padding and alignfull blocks gutenberg#42085

Note that it doesn't entirely port over PR40875 — the remaining PHP changes for that PR will be explored in a separate PR targeting `layout.php`.

Props andrewserong, aaronrobertshaw, isabel_brison.
See #56467.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53718 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-14 14:21:22 +00:00
Sergey Biryukov
c03305852e Code Modernization: Add AllowDynamicProperties attribute to all (parent) classes.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

There are a number of ways to mitigate this:
* If it is an accidental typo for a declared property: fix the typo.
* For known properties: declare them on the class.
* For unknown properties: add the magic `__get()`, `__set()`, et al. methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods built in.
* For unknown ''use'' of dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes.

Trac ticket #56034 is open to investigate and handle the third and fourth type of situations, however it has become clear this will need more time and will not be ready in time for WP 6.1.

To reduce “noise” in the meantime, both in the error logs of WP users moving onto PHP 8.2, in the test run logs of WP itself, in test runs of plugins and themes, as well as to prevent duplicate tickets from being opened for the same issue, this commit adds the `#[AllowDynamicProperties]` attribute to all “parent” classes in WP.

The logic used for this commit is as follows:
* If a class already has the attribute: no action needed.
* If a class does not `extend`: add the attribute.
* If a class does `extend`:
 - If it extends `stdClass`: no action needed (as `stdClass` supports dynamic properties).
 - If it extends a PHP native class: add the attribute.
 - If it extends a class from one of WP's external dependencies: add the attribute.
* In all other cases: no action — the attribute should not be needed as child classes inherit from the parent.

Whether or not a class contains magic methods has not been taken into account, as a review of the currently existing magic methods has shown that those are generally not sturdy enough and often even set dynamic properties (which they should not). See the [https://www.youtube.com/watch?v=vDZWepDQQVE live stream from August 16, 2022] for more details.

This commit only affects classes in the `src` directory of WordPress core.
* Tests should not get this attribute, but should be fixed to not use dynamic properties instead. Patches for this are already being committed under ticket #56033.
* While a number bundled themes (2014, 2019, 2020, 2021) contain classes, they are not a part of this commit and may be updated separately.

Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].

Follow-up to [53922].

Props jrf, hellofromTonya, markjaquith, peterwilsoncc, costdev, knutsp, aristath.
See #56513, #56034.
Built from https://develop.svn.wordpress.org/trunk@54133


git-svn-id: http://core.svn.wordpress.org/trunk@53692 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-12 15:47:14 +00:00
Sergey Biryukov
70c0f6f0e1 Editor: Backport Elements API updates.
This commit backports the original PRs from Gutenberg repository:

* [https://github.com/WordPress/gutenberg/pull/40260 #40260 Add support for button elements to theme.json]
* [https://github.com/WordPress/gutenberg/pull/40889 #40889 Theme Json: Don't output double selectors for elements inside blocks]
* [https://github.com/WordPress/gutenberg/pull/41140 #41140 Global Styles: Add support for caption elements]
* [https://github.com/WordPress/gutenberg/pull/41160 #41160 Global Styles: Load block CSS conditionally]
* [https://github.com/WordPress/gutenberg/pull/41240 #41240 Global Styles: Button Element: update button element selector]
* [https://github.com/WordPress/gutenberg/pull/41335 #41335 Duotone: Fix CSS Selectors rendered by theme.json duotone/filter settings for blocks on public pages]
* [https://github.com/WordPress/gutenberg/pull/41446 #41446 Block styles: Account for style block nodes that have no name]
* [https://github.com/WordPress/gutenberg/pull/41696 #41696 Global Styles: Allow references to values in other locations in the tree]
* [https://github.com/WordPress/gutenberg/pull/41753 #41753 Elements: Add an API make it easier to get class names]
* [https://github.com/WordPress/gutenberg/pull/41786 #41786 Support pseudo selectors on elements in theme json]
* [https://github.com/WordPress/gutenberg/pull/41822 #41822 Elements: Button - Fix element selectors]
* [https://github.com/WordPress/gutenberg/pull/41981 #41981 Global Styles: Add support for heading elements]
* [https://github.com/WordPress/gutenberg/pull/42072 #42072 Fix link element hover bleeding into button element default styles]
* [https://github.com/WordPress/gutenberg/pull/42096 #42096 Add visited to link element allowed pseudo selector list]
* [https://github.com/WordPress/gutenberg/pull/42669 #42669 Link elements: Add a :where selector to the :not to lower specificity]
* [https://github.com/WordPress/gutenberg/pull/42776 #42776 Theme JSON: Add a static $blocks_metadata data definition to the Gutenberg instance of WP_Theme_JSON]
* [https://github.com/WordPress/gutenberg/pull/43088 #43088 Pseudo elements supports on button elements]
* [https://github.com/WordPress/gutenberg/pull/43167 #43167 Theme_JSON: Use existing append_to_selector for pseudo elements]
* [https://github.com/WordPress/gutenberg/pull/43988 #43988 Styles API: Fixed selectors for nested elements]

Props onemaggie, bernhard-reiter, cbravobernal, mmaattiiaass, scruffian, andraganescu, dpcalhoun, get_dave, Mamaduka, SergeyBiryukov.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54118


git-svn-id: http://core.svn.wordpress.org/trunk@53677 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-10 12:38:12 +00:00
Sergey Biryukov
ee5b219070 Global Styles: Add support for heading, button, and caption elements.
This enables themes to:
* Set style rules for all heading elements together rather than having to do it individually.
* Style captions in `theme.json` by adding this into your `theme.json` file:
{{{
{
	"styles": {
		"elements": {
			"caption": {
				"color": {
					"background": "red",
					"text": "yellow"
				}
			}
		}
	}
}
}}}

This commit backports the original PRs from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/41981 #41981: Global Styles: Add support for heading elements]
* [https://github.com/WordPress/gutenberg/pull/41140 #41140: Global Styles: Add support for caption elements]

Follow-up to [50973].

Props cbravobernal, scruffian, madhudollu, mikachan, zieladam, bph, poena, andraganescu, ndiego, bgardner.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54105


git-svn-id: http://core.svn.wordpress.org/trunk@53664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 16:44:11 +00:00
John Blackbourn
c6dbcf8576 Docs: Various docblock corrections and improvements for changes introduced in 6.0.
See #54729

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


git-svn-id: http://core.svn.wordpress.org/trunk@52891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-28 09:59:13 +00:00
gziolo
9e3c5a4215 Editor: Add functionality required for theme export in the site editor
This bring across changes to theme export functionality, and related code, and tests. Relates issue in Gutenberg: https://github.com/WordPress/gutenberg/issues/39889.

Props scruffian, timothyblynjacobs, oandregal, ajlende, zieleadam.
See #55505.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52718 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-11 10:38:00 +00:00
audrasjb
4237c0a88b Themes: Avoid undefined variable warning on get_svg_filters().
This change fixes an undefined variable warning thrown when `duotone` color setting was set to null` in Block Themes `theme.json` file.

Follow-up to [52768].

Props aliakseyenkaihar, audrasjb, rafiahmedd.
Fixes #55241.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52380 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-23 23:17:01 +00:00
hellofromTonya
2b94ffdbc9 Editor: Adds an additional check to guard against incompete presets.
Adds an additional guard to ensure the value of `$preset_metadata['value_key']` actually exists as a key in the `$preset` array. Fixes `Warning: Undefined array key` error. 

Intentionally adds the check into the existing `isset()` as it's native to PHP, more efficient, and a good pattern.

Follow-up [52049].

Props jeherve, swissspidy, sergeybiryukov, jrf.
Fixes #55161.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-17 18:47:02 +00:00
audrasjb
26667ab0e1 Editor: Backport Duotone fixes for 5.9.1.
This changeset is a backport for the following Gutenberg PRs:

- Fix duotone theme cache gutenberg#36236
- Fix duotone render in non-fse themes gutenberg#37954
- Duotone: Allow users to specify custom filters gutenberg#38442

Props oandregal, scruffian, Mamaduka.
See #55179.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-17 16:18:03 +00:00
audrasjb
ab2c6d696b Themes: Allow extending WP_Theme_JSON and WP_Theme_JSON_Resolver classes.
This change updates methods visibility from `private` to `protected` and adds late static binding.

Original PRs from Gutenberg repository:
- https://github.com/WordPress/gutenberg/pull/38625
- https://github.com/WordPress/gutenberg/pull/38671

Props oandregal, Mamaduka, kapilpaul.
Fixes #55178.
See #55179.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52333 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-17 09:04:05 +00:00
audrasjb
2b8f6781bb Docs: Typo correction in class-wp-theme-json docblocks.
Props kebbet.
See #54729.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52281 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-08 16:11:03 +00:00
audrasjb
99bac7e17c Docs: Replace "Current theme" with "Active theme" in various DocBlocks.
This change replaces "Current theme" with "Active theme" in various DocBlocks for better consistency with user-facing strings.

Follow-up to [52580].

Props Presskopp, audrasjb, costdev.
Fixes #54831.
See #54770.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-20 23:53:05 +00:00
Sergey Biryukov
ef5a994a3c Docs: Fix typos in some DocBlocks.
Props kebbet.
See #54729.
Built from https://develop.svn.wordpress.org/trunk@52597


git-svn-id: http://core.svn.wordpress.org/trunk@52185 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-18 20:29:06 +00:00
noisysocks
28a12c8bce Update @wordpress packages
Update packages to include these bug fixes from Gutenberg:

- Site Logo: Add option to set site icon from Site Logo block
- Navigation: Enable even more compact setup state.
- Remove template parts from post content inserter an __unstable filter
- Template Editor Mode: Hide editor mode switcher
- Avoid using CSS variables for block gap styles
- Try to fix auto resizing in template part focus mode
- Lower the specificity of font size CSS Custom Properties in the editor
- Site icon: Fix site icon styling to display non-square site icons within a square button
- [Site Editor]: Register block editor shortcuts
- Update regex to handle 404 template slug
- Site Editor: Remove dead code
- [Block Editor]: Restrict delete multi selected blocks shortcut
- Fix: Gradients are not being applied by class
- Update: Make the global styles subtitles font smaller
- Post Content/Title: Reflect changes when previewing post
- ServerSideRender: Fix loading state
- [Block Library]: Fix editable post blocks in Query Loop with zero queryId
- Post Excerpt: Fix previews
- WP59: Contextualize "Export" string to differentiate it from other occurrences in WP Core
- Tools Panel: Fix race conditions caused by conditionally displayed ToolsPanelItems
- ToolsPanel: Allow items to register when panelId is null
- Font Size Picker: Allow non-integers as simple CSS values and in hints
- [Components - FontSizePicker]: Use incremental sequence of numbers as labels for the available font-sizes at the segmented control (conditionally)

See #54487.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52026 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-04 05:39:28 +00:00
Sergey Biryukov
e6b9b96130 Docs: Improve the @since 5.9.0 note for WP_Theme_JSON::PRESETS_METADATA.
Follow-up to [52320], [52401].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@52403


git-svn-id: http://core.svn.wordpress.org/trunk@51995 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-21 10:20:04 +00:00
isabel_brison
4939393799 Update @wordpress packages for Beta 4
Update packages with these bug fixes from Gutenberg:

Navigation: Remove hardcoded typography units
Handle parsed request
Navigation: Refactor modal padding to be simpler and more flexible
Show notice on save in site editor
Add aria-pressed true/false to Toggle navigation button based on state
Components FontSizePicker: Use incremental sequence of numbers
Custom keys from theme.json: fix kebabCase conversion
Template Part: Fix 'isMissing' condition check
Multi-Entity Saving: Decode HTML entities in item titles
Font sizes: update default values
Query Loop: Add useBlockPreview, fix Query Loop wide alignment
Only add dialog role to navigation when modal is open
Fix navigation appender
Show a UI warning when user does not have permission to update/edit a Navigation block
Block editor: Fix Enter handling for nested blocks
Update: Use subtitle styles for the palette names
Allow publishing a post while not saving changes to non-post entities
Update: Block top level useSetting paths
Fix Site Logo block alignment issues
Editor: when Toggle navigation receives state false, focus
ToolsPanel: Allow items to register when panelId is null
Block Support Panels - Make block support tools panels compatible
Gallery: Fix block registration hook priority
Navigation: Fix page list issues in overlay
Ensure the overlay menu works when inserting navigation block pattern
Restrict Navigation permissions and show UI warning if cannot create
Add block gap support for group blocks
Try cascading nav styles through classnames
Fix: Impossible to edit theme and default colors
Fix: Color editor discards colors with default name
Site Editor: Fix template author avatar check
Template Editing Mode: Fix options dropdown
Avoid undo issues when reset parent blocks for controlled blocks
Add comment-form and comment-list to html5 theme support and fix comment layout

Props hellofromtonya.
See #54487.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51994 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-21 07:02:34 +00:00
hellofromTonya
af941fc10c Editor: Add support for nameless font sizes in WP_Theme_JSON.
With nameless font sizes support, themes use the defaults by not declaring the `"name"` setting for their `fontSizes` in `theme.json`.

Backport from Gutenberg https://github.com/WordPress/gutenberg/pull/37410.

Follow-up to [50973], [52049], [52275], [52320].

Props ntsekouras, costdev, hellofromTonya.
Fixes #54640. See #54487.
Built from https://develop.svn.wordpress.org/trunk@52401


git-svn-id: http://core.svn.wordpress.org/trunk@51993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-21 06:02:06 +00:00
noisysocks
935058d178 Update @wordpress packages
Update packages to include these bug fixes from Gutenberg:

- Image block: Set image display to grid when no alignment sent to properly align caption on resize
- Update and align template descriptions
- Site Editor - prevent loading state from showing the admin menu.
- Add client side routing for Site Editor
- Navigation: Add clearance for appender in submenus.
- Fix CSS Custom Properties for presets in the site editor
- Add/navigation blocks post processing after migration from menu items
- Allow selector ordering to ensure theme.json root selector margin takes precedence 
- Do not remove theme presets if defaults are hidden
- Format library: fix unsetting highlight color
- FSE: Fix template resolution to give precedence to child theme PHP templates over parent theme block templates with equal specificity
- ColorPalette: Improving accessibility and visibility
- Update: Make the color popover on the gradient picker appear as expected
- Site Editor: Display a notice if export fails
- Fix docs and function naming for gallery block registration in PHP
- Switch to addEventListener for load event in the navigation block view script
- Fix mistake in _remove_theme_attribute_in_block_template_content
- Better synchronisation between Gutenberg and Core code
- Move the block page templates hook into compat/5.9 folder
- Moves to the template loader hooks and functions into lib/compat folder
- Refactor the gutenberg_is_fse_theme function to use wp_is_block_theme
- Site Editor: Update support doc URL in Welcome Guide
- Global Styles: Add Welcome Guide toggle
- Hide remove control point when removing would break gradient control
- Don't request the deprecated navigation areas endpoint outside of the Gutenberg plugin
- Image: Fix resizer controls being hidden in Safari when switching between alignments
- Remove Navigation Menus from WP Admin sidebar
- Site Editor: Hide the block appender in the Template Part editor
- Site Editor: Use server definition for the Template Areas
- Synchronize wp_is_block_theme and block-templates block support with Core
- E2E: Retry login again after a bad nonce request to prevent intermittent test failures 
- Fix theme requirement validation with WP 5.8
- Fix WP 5.9 check for conditionally running code
- Fix post comment form input width
- Border Style Control: Update styling for consistency with border width control
- Fix form-submit styles by adding button classes to the submit-button in post-comments block
- Site Editor: Fix edit template part link in header dropdown
- Move duotone palette to the bottom of global styles gradients
- Fix how appearanceTools works
- Move WP 5.9 wp-admin menus compatibility code to lib/compat folder
- Revert "Site Editor: Set the <title> on the list page to be same as the CPT name"
- Site Editor: Document Actions: add SR text to heading 1
- Do not register global styles CPT in WordPress 5.9
- Global Styles: Move the 'Edit colors' button to a standard menu item
- Fix styles for previews and patterns
- Site Editor: Fix failing E2E test
- Templates: Search for old template names in the parent theme too
- Remove 4 instances of 'gutenberg' text domain from WordPress core
- Fix content loss when ungrouping template parts or reusable blocks
- Simplify the RESET_BLOCK action to fix template part focus mode content loss
- [Global Styles]: Make Blocks section more distinguishable
- Only use block markup for comment form button when using a block theme
- Navigation: Fix vertical alignment of page list in modal.
- Fix: ToggleGroupControl active state
- Remove gutenberg_ prefix from @wordpress/block-library

Props ocean90, oandregal, hellofromtonya, youknowriad.
See #54487.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-14 01:57:26 +00:00
hellofromTonya
2e2829904b Editor: Allow theme.json to take precedence in setting the root level element's reset margin value.
Any margin added to the root element via `theme.json` is overwritten by a CSS reset margin value provided by the Gutenberg Plugin.

This commit makes `theme.json` setting take precedence by generating the global styles body reset prior to processing the theme.json.

Follow-up to [52049].

Props get_dave, hellofromTonya.
Fixes #54550.
Built from https://develop.svn.wordpress.org/trunk@52329


git-svn-id: http://core.svn.wordpress.org/trunk@51921 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-06 22:42:00 +00:00
Sergey Biryukov
6b84ae03ad Docs: Further update some @since notes in WP_Theme_JSON methods for clarity.
Follow-up to [52049], [52306], [52320].

See #53399, #54336.
Built from https://develop.svn.wordpress.org/trunk@52321


git-svn-id: http://core.svn.wordpress.org/trunk@51913 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-04 15:57:01 +00:00
Sergey Biryukov
7f9d7a5905 Docs: Some documentation improvements for WP_Theme_JSON and WP_Theme_JSON_Resolver classes:
* Make the `@since 5.9.0` notes more specific. When mentioning that parameters or values have been added or changed, it is generally also helpful to include their exact names and the nature of changes for future reference.
* Update some DocBlocks per the documentation standards.

Follow-up to [52049], [52306].

See #53399, #54336.
Built from https://develop.svn.wordpress.org/trunk@52320


git-svn-id: http://core.svn.wordpress.org/trunk@51912 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-04 12:58:01 +00:00
noisysocks
e4b553a201 Update @wordpress packages
Update packages to include these bug fixes from Gutenberg:

- Update Pattern block category and add documentation
- Fix non existent menu handling in nav block
- Make Reusable blocks available in the Site Editor
- Add caching to WP_Theme_JSON_Resolver_Gutenberg::get_user_data_from_custom_post_type()
- theme.json: add appearanceTools flag to opt-in into appearance UI controls
- Update the block theme folders to templates and parts
- Remove reference to gutenberg_, swap with wp_
- Use table layout in templates list screen
- Update featured image placeholder graphic.
- [Inserter]: Adjust order of theme blocks and reorder inserter items
- Implement suitable fallback for Nav block on front end of site when no menu selected
- Toggle Group Control: add tooltip
- Use first non-empty Nav post as primary fallback for Nav block
- Change .nvmrc and documentation for Node.js version (LTS to 14.18.1)
- Update: Migrate global styles user database data on the rest endpoint
- Update global styles public API
- Update: Rename user preset origin to custom
- Try always generating navigation post title
- Show all templates and template parts on the site editor list screens
- Highlight "Site" in the navigation panel
- Fix template part slug generation when creating through the block placeholder
- [Block Library - Post Title]: Fix render error when setting Page to homepage
- Add 'Clear customizations' button to template list page
- Gallery v1: Allow clicks within replace media placeholder state
- Site Editor: Set the <title> on the list page to be same as the CPT name
- Gallery: Fix stuck image size options loader
- Cover: Fix undo trap
- Add success and error snackbars to the templates list page
- Fix: theme colors cannot override defaults
- Fix: Color palette is not being stored
- Add elements support to the typography panel in global styles
- Make links plural in global styles
- Add: Gradient palette editor
- Update some small style regressions in the template list
- Add: Transparency support on global styles colors
- Fix: apply by slug on all origins
- Render empty Nav block if no fallback block can be utilised
- Allow filtering of Nav block fallback
- Fix Nav block fallback DB query to match on full block grammar start tag
- Remove unstable max pages attribute from Nav block
- DateTimePicker: set PM hours correctly
- Update delete template button
- Site Editor: Template list add rename action
- Fix Nav block editing wrong entity on creation of new Menu
- [REST] Restore the missing double slash in the ID received by /templates
- Add icons to navigation sidebar items
- Update function names for the public global styles API functions
- Templates Controller: Add missing 'is_custom' prop
- Rename gutenberg_ to wp_ for some functions that land in WordPress 5.9
- [Block Library - Template Part]:Remove support for conversion to Reusable block
- Global Styles: Call "palettes" and not "color palettes" on panel label
- Add button text when no colors found
- Update: Global Styes: Count all color palette origins on the palette counter
- Rename navigationMenuId to ref
- Offset the parent iframe when computing Popover position 
- Fix: Failing PHPUnit test
- Show theme, plugin or author in Added By column with appropriate icon or avatar
- Add origin and author to template rest api

See #54487.
Props talldanwp, mamaduka, oandregal.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51867 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-30 00:24:27 +00:00
noisysocks
121c824ccd Update @wordpress packages
Update packages to include these bug fixes from Gutenberg:

- FSE: Add welcome guide
- Update theme styles for the code block
- Add feature flag to toggle the new site editor sidebar
- Add templates list page for site editor
- Cover Block: Fix default background dim
- E2E: Add more Cover block tests
- Cover Block: Fix regressions
- Post Comments Form: ensure typography styles are applied to child elements
- Navigation: Fix space-between
- Fix background colours in nested submenus.
- Fix duplicate custom classnames in navigation submenu block
- Fix colour rendering in Navigation overlay
- Fix: Add ability to opt out of Core color palette V2
- Change @package to WordPress in block-library
- Make the core color palette opt-in for themes with not theme.json
- Remove textdomain from calendar block
- Page List block: fix space before href attribute
- Try: Let Featured Image block inherit dimensions, look like a placeholder
- [Global Styles]: Add block icon next to blocks list
- Page List: Use core entities instead of direct apiFetch
- Site Editor: Stabilize export endpoint
- Fix mobile horizontal scrollbar.
- Multi-entity save: Only set site entity to pending if really saving
- Add page list to navigation direct insert conditions
- Implement "Add New" for templates list in Site Editor
- Post Featured Image: Remove withNotices HOC
- Fix page list missing button styles when set to open on click.
- Make appender fixed position to avoid jumps in the UI
- Color UI component: reorder palettes and update names (core by defaults, user by custom)
- Remove the Styles link in Site Editor
- GlobalStyles sidebar: do not show default palette if theme opts-out
- Only render the site editor canvas when the global styles are ready.
- Global Styles: rename core origin key to default for presets
- Clarify i18n context for PostTemplateActions's "New" label
- Revert erroneous native editor package version bumps
- Try: Hide the columns inserter in pattern previews.
- Fix site editor region navigation
- Update navigation sidebar responsiveness
- Add _wp_array_set and _wp_to_kebab_case to 5.8 compat
- Make user able to change all color palette origins
- Site Editor: Update hrefs to not specifically refer to themes.php?page=gutenberg-edit-site
- Site Editor: Validate the postType query argument
- Navigation: Scale submenu icon.
- Move the theme editor under tools for FSE themes
- Deprecate navigation areas

See #54487.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51824 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-23 05:40:38 +00:00
noisysocks
f05f235042 Editor: Add block theme infrastructure
Adds the required infrastructure to render block-based themes. This is sourced
from the Gutenberg plugin.

Fixes #54335.
Props bernhard-reiter, youknowriad, ntsekouras, hellofromtonya.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-08 23:10:59 +00:00
jorgefilipecosta
065c639a2a Update theme.json classes for WordPress 5.9.
This commit ports to core the changes to the classes that deal with theme.json code.

See #54336.
Props oandregal, spacedmonkey, noisysocks, hellofromtonya, youknowriad.
Built from https://develop.svn.wordpress.org/trunk@52049


git-svn-id: http://core.svn.wordpress.org/trunk@51641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-08 19:19:58 +00:00
hellofromTonya
c7d3e267b8 Coding Standards: Use static closures when not using $this.
When a closure does not use `$this`, it can be made `static` for improved performance.

Static closures are supported in PHP since PHP 5.4. ​

Props jrf, hellofromTonya, swissspidy, SergeyBiryukov.
See #53359.
Built from https://develop.svn.wordpress.org/trunk@51657


git-svn-id: http://core.svn.wordpress.org/trunk@51263 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 12:59:02 +00:00
jorgefilipecosta
eff1c81de6 Block Editor: Add missing border setting on button block.
This commit fixes a regression on WordPress 5.8 that made the border radius setting on the buttons block disappear.

Props Mamaduka, daisyo, priethor, desrosj, mikeschroder.
Fixes #53702.
Built from https://develop.svn.wordpress.org/trunk@51538


git-svn-id: http://core.svn.wordpress.org/trunk@51149 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-03 18:14:58 +00:00
youknowriad
e76d4e1bcd Block Editor: Backport fixes targetted for WordPress 5.8 RC4.
This includes:

 - Suggestion List: Check if a node exists to scroll into view.
 - Autocomplete: reset state for empty text.
 - Adds auxiliary class names for editor styles in the widgets editor.
 - Extract snackbars into a separate component.
 - Rich text: run input rules after composition end.
 - iframe: load inline styles.
 - Multi select: select all: restore ref callback.
 - Writing flow: allow select all from empty selection.
 - Post Excerpt: Fix excerpt_more filter conflict and remove wordCount attribute.
 - Add the percent unit to the default units in Core.

Props desrosj.
See #53397.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51054 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-15 18:55:29 +00:00
youknowriad
e270f4f0f3 Block Editor: Include the fixes targetted for WordPress 5.8 RC3.
This includes the following fixes:
 - Safari: see if compositing layer size is more reasonable when position fixed divs are not inserted into content.
 - Site Logo Block: update Site Logo block UI and option syncing.
 - Fix moving inner blocks in the Widgets Customizer.
 - Allow themes to provide empty values for color.duotone and spacing.units
 - Update getTermsInfo() to workaround parsing issue for translatable strings.
 - Specify what settings can be part of settings.layout.
 - Update conditions to hide duotone panel.
 - Prevent entering invalid values in the Query Loop block config.
 - Prevent color panel from showing as empty.
 - Avoid calling gutenberg_ functions within code shipped through WordPress Core.

Props desrosj.
See #53397.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-13 16:41:28 +00:00
jorgefilipecosta
d05e5232b7 Block Editor: Fix for theme.json: color.duotone and spacing.units should allow empty sets.
This commit fixes an issue with the color.duotone & spacing.units in which empty values didn't override previous origins, resulting in that a theme couldn't provide an empty set for this via its theme.json.

Props nosolosw, youknowriad, aristath.
See #53175.
Built from https://develop.svn.wordpress.org/trunk@51383


git-svn-id: http://core.svn.wordpress.org/trunk@50994 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-08 19:31:57 +00:00
desrosj
5ce4f59f07 Themes: Remove inline comment that is not relevant in WordPress Core.
This removes an inline comment block that was added when importing the `WP_Theme_JSON` class in [50959]. The comment is relevant to the code only when viewed within the context of the Gutenberg plugin.

Props nosolosw, jorbin.
Fixes #53576.
Built from https://develop.svn.wordpress.org/trunk@51352


git-svn-id: http://core.svn.wordpress.org/trunk@50961 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-06 18:14:57 +00:00
desrosj
433448f1d8 Editor: Remove the experimental experimental-link-color feature.
This has been plugin only so far and should remain so.

Follow up to [50959].

Props nosolosw.
Fixes #53175.
Built from https://develop.svn.wordpress.org/trunk@51306


git-svn-id: http://core.svn.wordpress.org/trunk@50915 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-02 13:02:58 +00:00
John Blackbourn
79685db062 Docs: Corrections and improvements to types used in docblocks for symbols, properties, and filters.
See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@50907 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-01 21:02:57 +00:00
Sergey Biryukov
d999568ae4 Docs: Improve documentation for optional parameters in WP_Theme_JSON methods per the documentation standards.
Additionally:
* Remove an empty line between `@param` and `@return` tags.
* Correct alignment of `@param` tags.

Follow-up to [50959], [50973], [51149], [51284], [51289].

See #52628, #53461.
Built from https://develop.svn.wordpress.org/trunk@51292


git-svn-id: http://core.svn.wordpress.org/trunk@50901 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-30 19:00:58 +00:00