WP_Theme_JSON sanitization is now able to sanitize data contained on indexed arrays.
So certain data from theme.json, for example, settings.typography.fontFamilies which is a JSON array will be sanitized.
Props mmaattiiaass, mukesh27.
Fixes#60360.
git-svn-id: https://develop.svn.wordpress.org/trunk@57496 602fd350-edb4-49c9-b593-d223f7449a82
Adds front end rendering logic for the `dimensions.aspectRatio` block support as well as the required logic in `WP_Theme_JSON` and the style engine.
Props andrewserong.
Fixes#60365.
git-svn-id: https://develop.svn.wordpress.org/trunk@57491 602fd350-edb4-49c9-b593-d223f7449a82
Theme.json stylesheets attempting to use a custom root selector are generated with in correct styles.
Props aaronrobertshaw, get_dave, mukesh27.
Fixes#60343.
git-svn-id: https://develop.svn.wordpress.org/trunk@57352 602fd350-edb4-49c9-b593-d223f7449a82
In PHP it is a good practice to unset $value if it was created by reference in a foreach loop, as the reference is still valid outside the loop, and this avoids accidental bugs.
Props get_dave.
Fixes#60326.
git-svn-id: https://develop.svn.wordpress.org/trunk@57340 602fd350-edb4-49c9-b593-d223f7449a82
Adds background size and background repeat style processing to the background image block support and `WP_Style_Engine` definitions.
Props andrewserong, mukesh27.
Fixes#60175.
git-svn-id: https://develop.svn.wordpress.org/trunk@57254 602fd350-edb4-49c9-b593-d223f7449a82
Adds support for an `allowCustomContentAndWideSize` setting in `WP_Theme_JSON` valid settings.
Props andrewserong.
Fixes#60133.
git-svn-id: https://develop.svn.wordpress.org/trunk@57247 602fd350-edb4-49c9-b593-d223f7449a82
`_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.
git-svn-id: https://develop.svn.wordpress.org/trunk@56709 602fd350-edb4-49c9-b593-d223f7449a82
Adds lightbox as a valid setting to `WP_Theme_JSON` class and as an image block setting in theme.json.
Props czapla, costdev, desrosj.
Fixes#59393.
git-svn-id: https://develop.svn.wordpress.org/trunk@56643 602fd350-edb4-49c9-b593-d223f7449a82
Adjusts root padding for synced patterns in the editor to avoid discrepancies with the front end view.
Props aaronrobertshaw, mukesh27.
Fixes #59359.
git-svn-id: https://develop.svn.wordpress.org/trunk@56615 602fd350-edb4-49c9-b593-d223f7449a82
Adds a new background block support with the ability to set a background image on blocks that opt into it.
Props andrewserong, mukesh27.
Fixes#59357.
git-svn-id: https://develop.svn.wordpress.org/trunk@56614 602fd350-edb4-49c9-b593-d223f7449a82
Adds a new text orientation option to the typography block support, implemented with CSS writing-mode.
Props poena.
Fixes#59306.
git-svn-id: https://develop.svn.wordpress.org/trunk@56605 602fd350-edb4-49c9-b593-d223f7449a82
Removes root padding from children of flex and grid layout blocks when root padding aware alignments are set.
Props andrewserong, ramonopoly.
Fixes#59295.
git-svn-id: https://develop.svn.wordpress.org/trunk@56546 602fd350-edb4-49c9-b593-d223f7449a82
Removes unnecessary sanitisation of hardcoded strings and avoids looping over style presets without classes or variables.
Props flixos90.
Fixes#59304.
git-svn-id: https://develop.svn.wordpress.org/trunk@56545 602fd350-edb4-49c9-b593-d223f7449a82
Adds the ability to disable layout controls on a per-block level from theme.json.
Props mukesh27.
Fixes#59294.
git-svn-id: https://develop.svn.wordpress.org/trunk@56534 602fd350-edb4-49c9-b593-d223f7449a82
Adds the ability to process block style variations to the `remove_insecure_properties` function of theme json class.
Props dsas, ramonopoly.
Fixes#59108.
git-svn-id: https://develop.svn.wordpress.org/trunk@56502 602fd350-edb4-49c9-b593-d223f7449a82
Most block feature checks are for a single feature string, and for such cases it is not intuitive to require an array for the `$feature` parameter of the `block_has_support()` function.
This changeset brings it in line with other functions like `post_type_supports()`, allowing to pass a string for the `$feature`. An array is still supported for more complex cases where support for sub-features needs to be determined. This change furthermore includes a very minor performance tweak by avoiding calls to the `_wp_array_get()` function if a single feature string is being checked for.
Props thekt12, nihar007, mukesh27, swissspidy.
Fixes#58532.
git-svn-id: https://develop.svn.wordpress.org/trunk@56382 602fd350-edb4-49c9-b593-d223f7449a82
With the minimum PHP version requirement raised to 7.0, we can now use `isset` on constants that are arrays. Since `isset` is slightly faster than `array_key_exists` (and the different handling of `null` values is irrelevant for the updates here), remaining instances of `array_key_exists` in the `WP_Theme_JSON` class are replaced in this changeset.
Props soean.
Fixes#57067.
git-svn-id: https://develop.svn.wordpress.org/trunk@56345 602fd350-edb4-49c9-b593-d223f7449a82
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@56101 602fd350-edb4-49c9-b593-d223f7449a82
Restructures the block.json selectors API by moving `__experimentalSelector` props into their own config, stabilizing the selectors API, and enabling more flexible styling options.
Props ramonopoly, spacedmonkey, aaronrobertshaw, onemaggie.
Fixes#58586.
git-svn-id: https://develop.svn.wordpress.org/trunk@56058 602fd350-edb4-49c9-b593-d223f7449a82
Marks the layout support stable and moves layout definitions from `theme.json` into `wp-includes/block-supports/layout.php`.
Props andrewserong, poena, ramonopoly, peterwilsoncc.
Fixes#58550.
git-svn-id: https://develop.svn.wordpress.org/trunk@56055 602fd350-edb4-49c9-b593-d223f7449a82
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
git-svn-id: https://develop.svn.wordpress.org/trunk@56041 602fd350-edb4-49c9-b593-d223f7449a82
Adds the ability to set link hover colors for individual blocks from the block inspector color panel.
Props @youknowriad, @peterwilsoncc, @kebbet.
Fixes#58575.
git-svn-id: https://develop.svn.wordpress.org/trunk@56028 602fd350-edb4-49c9-b593-d223f7449a82
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@55987 602fd350-edb4-49c9-b593-d223f7449a82
Adds a text columns feature to the typography block support that uses CSS `column-count` for multi-column text.
Props ramonopoly, aaronrobertshaw.
Fixes#58549.
git-svn-id: https://develop.svn.wordpress.org/trunk@55985 602fd350-edb4-49c9-b593-d223f7449a82
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@55950 602fd350-edb4-49c9-b593-d223f7449a82
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@55912 602fd350-edb4-49c9-b593-d223f7449a82
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.
git-svn-id: https://develop.svn.wordpress.org/trunk@55907 602fd350-edb4-49c9-b593-d223f7449a82