Replace calls to `property_exists` with `instanceof WP_Block_Type` in block related functions. This change not only improves type safety but also enhances performance.
Follow on from [56678] and [56677].
Props gziolo, aristath, aaronrobertshaw, spacedmonkey.
Fixes#59453
Built from https://develop.svn.wordpress.org/trunk@56742
git-svn-id: http://core.svn.wordpress.org/trunk@56254 1a063a9b-81f0-0310-95a4-ce76da25c4cd
`_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
- Where no fluid max values are set (e.g., single or custom font size values), the "size" value will act as the maximum value in a `clamp()` function.
- In the absence of any fluid `min`/`max` values, the lower bound rule of `>16px` will be enforced. This applies to custom values from the editor or single-value `theme.json` styles. Font sizes below this will not be clamped.
- In a preset, if a `fluid.min` value has been specified, the lower bound rule of `>16px` won't be enforced on this value. Presets with a fluid object therefore, give precedence to theme author's values.
- In a preset, if there is NOT a `fluid.max` but there is `fluid.min`, use the incoming "size" value as the `max`.
- In a preset, if there is NOT a `fluid.min` but there is a `fluid.max`, use `size * min_size_factor` as the `min`. The lower bound rule of `>16px` is enforced here, because the block editor is computing the `min` value. This is consistent with the way minimum sizes are calculated for single or custom values.
Props ramonopoly, mamaduka, andrewserong, aristath, joen, desrosj.
Fixes#57075.
Built from https://develop.svn.wordpress.org/trunk@54823
git-svn-id: http://core.svn.wordpress.org/trunk@54375 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit:
* Adds default minimum font size limits so that min font size, where provided, does not become smaller than `14px`/`0.875rem`/`0.875em`.
* For font sizes of `< 14px` that have no defined minimum sizes, uses the font size to set the floor of the `clamp()` value.
This bugfix prevents converting existing small font sizes to clamp values that will reduce their font size even further in narrow widths. It therefore improves backward compatibility and accessibility.
Original PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/44993#44993 Fluid typography: add font size constraints]
Follow-up to [54260], [54360], [54497], [54500].
Props ramonopoly, andrewserong, isabel_brison, Joen, bernhard-reiter.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54646
git-svn-id: http://core.svn.wordpress.org/trunk@54198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Ensures the `fontFamily` attribute is registered for block types on the server side. This change resolves a `400` error when attempting to change the font family for a server-side rendered block in the editor.
Props aaronrobertshaw, mamaduka, wildworks, upadalavipul.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54387
git-svn-id: http://core.svn.wordpress.org/trunk@53946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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
Migrate spacing, border, color, dimensions, elements and typography and associated tests for block supports in the block editor.
Related changes in Gutenberg:
- Include individual serialization changes from 6de16981c7
- Skip Style Engine integration from 44925a947f%60
Props ramonopoly, aaronrobertshaw.
See #55505.
Built from https://develop.svn.wordpress.org/trunk@53076
git-svn-id: http://core.svn.wordpress.org/trunk@52665 1a063a9b-81f0-0310-95a4-ce76da25c4cd
- First pass at adding the site editor from the Gutenberg plugin to
wp-admin/site-editor.php.
- Adds miscellaneous PHP changes from Gutenberg 10.1 - 11.9.
Follows [52042].
See #54337.
Props youknowriad, aristath, hellofromtonya, gziolo.
Built from https://develop.svn.wordpress.org/trunk@52069
git-svn-id: http://core.svn.wordpress.org/trunk@51661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This also includes:
- The removal of the Post Author block.
- Renaming build_query_vars_from_query_block function.
- Update the block supports.
Props gziolo.
See #52991.
-This line, and those below, will be ignored--
M package-lock.json
M package.json
M src/wp-includes/assets/script-loader-packages.php
M src/wp-includes/block-supports/colors.php
AM src/wp-includes/block-supports/elements.php
D src/wp-includes/block-supports/padding.php
AM src/wp-includes/block-supports/spacing.php
M src/wp-includes/block-supports/typography.php
M src/wp-includes/blocks/column/block.json
M src/wp-includes/blocks/index.php
D src/wp-includes/blocks/post-author
D src/wp-includes/blocks/post-author.php
M src/wp-includes/blocks/post-content.php
M src/wp-includes/blocks/post-featured-image.php
M src/wp-includes/blocks/query/block.json
M src/wp-includes/blocks/query-loop/block.json
M src/wp-includes/blocks/query-loop.php
M src/wp-includes/blocks/query-pagination/block.json
M src/wp-includes/blocks/query-pagination-next.php
M src/wp-includes/blocks/query-pagination-numbers.php
M src/wp-includes/blocks/site-tagline/block.json
M src/wp-includes/blocks/site-title/block.json
M src/wp-includes/blocks.php
M src/wp-settings.php
M tests/phpunit/tests/blocks/block.php
M tools/webpack/packages.js
Built from https://develop.svn.wordpress.org/trunk@50945
git-svn-id: http://core.svn.wordpress.org/trunk@50554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
It contains several changes in addition to regular update to WordPress packages:
- All newly exposed blocks are now registered on the server.
- Dutone block support was added.
- Border block support was updated.
- New shared function `construct_wp_query_args` was added for the family of Query blocks - it might need some further work.
Props youknowriad.
See #52991.
Built from https://develop.svn.wordpress.org/trunk@50929
git-svn-id: http://core.svn.wordpress.org/trunk@50538 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This includes the packages that match the Gutenberg 9.2 Release.
It is going to be the last block-editor features update for WordPress 5.6.
It also updates the block-supports code base to the latest APIs.
Props isabel_brison, noisysocks, desrosj.
Fixes#51570.
Built from https://develop.svn.wordpress.org/trunk@49226
git-svn-id: http://core.svn.wordpress.org/trunk@48988 1a063a9b-81f0-0310-95a4-ce76da25c4cd