Commit Graph

131 Commits

Author SHA1 Message Date
Sergey Biryukov
12b190eb17 Editor: Correctly load RTL stylesheets in register_block_style_handle().
When setting an RTL language under Settings → General, some RTL stylesheets were not loaded, with LTR stylesheets being loaded instead, meaning that some blocks were not displayed correctly.

This commit ensures that all appropriate RTL stylesheets are loaded when selecting an RTL language.

Additionally, this commit improves performance by only running a `file_exists()` check for an RTL stylesheet if `is_rtl()` returns true, i.e. an RTL locale is selected.

Follow-up to [49982], [50836].

Props zoonini, sabernhardt, maahrokh, ankit-k-gupta, aristath, poena, SergeyBiryukov.
See #56325.
Built from https://develop.svn.wordpress.org/trunk@54330


git-svn-id: http://core.svn.wordpress.org/trunk@53889 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-27 15:43:09 +00:00
Sergey Biryukov
6dfd98cfe0 Blocks: Remove extra get_theme_file_path() calls in register_block_style_handle().
The `register_block_style_handle()` function runs ~200 times on each page load. Each time it runs, we call `get_theme_file_path()` and then run it through `wp_normalize_path()`.

`get_theme_file_path()` calls a few other functions: `get_stylesheet_directory()`, `get_stylesheet()`, `get_option()`, and there's a bunch of filters that run on each iteration of that, without ever changing.

By caching the value in a static variable, we can avoid ~200 calls on many functions and filters, improving performance.

Follow-up to [53091], [54290], [54291], [54309].

Props aristath, mukesh27.
Fixes #56666.
Built from https://develop.svn.wordpress.org/trunk@54327


git-svn-id: http://core.svn.wordpress.org/trunk@53886 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-27 15:11:14 +00:00
gziolo
8cb2e8aa60 Blocks: Fix 404 error for core styles with no file
[54155] broke loading of style.css files, namely it was enqueuing style.css files that don't exist on the frontend, which lead to 404 HTTO errors. All these style.css files don't exist for core blocks as they should be registered style handlers without a file path.

Follow-up to [54155].
Props tobiasbg, nendeb55.
Fixes #56408, #56614.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-27 07:40:11 +00:00
Sergey Biryukov
aaffa2bcff General: Remove file_exists() checks after calling realpath().
`realpath()` already checks if the file exists, and returns `false` on failure. The additional `file_exists()` check is not necessary and can be removed, improving the performance.

This commit simplifies the checks in two functions:
* `register_block_type_from_metadata()`
* `wp_json_file_decode()`

Note: In both of these cases, the values are passed through `wp_normalize_path()` after `realpath()`, so if the file does not exist, the `false` value gets converted to an empty string. The updated checks work both for `false` and `''` values.

Though this is a small tweak, it saves a lot of checks since one of the places we do this is when registering block styles, so it runs quite a few times on each page load.

Reference: [https://www.php.net/manual/en/function.realpath.php PHP Manual: realpath()].

Follow-up to [51599], [54132], [54290], [54291].

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


git-svn-id: http://core.svn.wordpress.org/trunk@53868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-26 13:07:14 +00:00
Sergey Biryukov
4d6518c2d5 Blocks: Remove duplicate use of realpath() in register_block_style_handle().
The `register_block_style_handle()` function called `realpath()` when retrieving the normalized style path, and then a few lines below that, recalculated the exact same value, running `realpath()` again.

This commit removes duplicate calculations, reducing the number of `realpath()` calls in the function by half. In tests ran using Xdebug & Webgrind, the total `realpath()` invocation count goes down from 639 to 461, and total self cost (the time that the function is responsible for) goes down from 146 ms to 89 ms.

Follow-up to [48141], [52291], [53091], [54155].

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


git-svn-id: http://core.svn.wordpress.org/trunk@53849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-23 13:26:09 +00:00
Sergey Biryukov
f092e4b013 Editor: Improve block loading PHP performance.
This commit improves PHP performance for core blocks by reading a single PHP file with block metadata, instead of reading a JSON file per-block and then decoding from JSON to PHP.

Includes:
* Adding a new Grunt task to convert `block.json` files to `block-json.php`.
* Using the new `block-json.php` file in the `register_block_type_from_metadata()` function.

Follow-up to [48141].

Props aristath, gziolo, johnbillion, presstoke, mukesh27, hellofromTonya, petitphp, adamsilverstein, costdev, desrosj, SergeyBiryukov.
Fixes #55005.
Built from https://develop.svn.wordpress.org/trunk@54276


git-svn-id: http://core.svn.wordpress.org/trunk@53835 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-21 13:57:21 +00:00
Sergey Biryukov
21eb7900b3 Docs: Clarify the $allowed_protocols default value in various KSES functions.
Add a note that the parameter is optional and defaults to the result of `wp_allowed_protocols()`.

This affects:
* `wp_kses()`
* `filter_block_content()`
* `filter_block_kses()`
* `filter_block_kses_value()`

Includes synchronizing the `$allowed_html` parameter description for consistency.

Follow-up to [649], [6630], [18826], [32603], [43016], [46896], [48478].

Props armondal, SergeyBiryukov.
Fixes #56580.
Built from https://develop.svn.wordpress.org/trunk@54181


git-svn-id: http://core.svn.wordpress.org/trunk@53740 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-15 13:29:13 +00:00
audrasjb
5ea7b42f89 Editor: Backport build_query_vars_from_query_block changes from Gutenberg repository.
This changeset backports changes from the following Gutenberg pull requests:

- [https://github.com/WordPress/gutenberg/pull/43590 gutenberg#43590] Add a filter to `build_query_vars_from_query_block`
- [https://github.com/WordPress/gutenberg/pull/40933 gutenberg#40933] Block Library - Query Loop: Add parents filter

Props ntsekouras, bernhard-reiter.
See #56467.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53734 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-15 11:41:10 +00:00
gziolo
714e57b2fc Blocks: Allow registering multiple items for all supported asset types
Follow-up #54337, [52069]. Part of https://github.com/WordPress/gutenberg/issues/41236. More details in https://github.com/WordPress/gutenberg/issues/33542.

Allow passing more than one script per block for `editorScript`, `script`, and `viewScript` fields in the `block.json` metadata file. This aligns with the previously added changes for `style` and `editorStyle` fields.

This change impacts the `WP_Block_Type` class and the REST API endpoint for block types. To ensure backward compatibiliy old names were soft deprecated in favor of new fields that work with array values and have `_handles` suffix.

Props zieladam, dlh, timothyblynjacobs, aristath, bernhard-reiter.
Fixes #56408.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-14 10:52:08 +00:00
audrasjb
7c4a64e67b Editor: Hide query loop pagination link arrows from assistive technology.
This changeset adss an `aria-hidden="true"` attribute to the optional arrows/chevron characters to the Query Loop and to the Comments Query Loop blocks pagination links.

These characters are text, so they're read out by assistive technologies. For better accessibility, it's best to reduce noise for screen reader users and prevent them to be rendered, using the `aria-hidden="true"` attribute.

Follow-up to [52057].

Props afercia, sabernhardt, kamig478, zieladam, audrasjb, joedolson, costdev.
Fixes #56067.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-12 23:34:12 +00:00
gziolo
b0f4c2c37e Blocks: Add new render property in block.json for block types
New `render` field in `block.json` file that accepts a string value. It allows to pass a path to the PHP file that is going to be used to render the block on the server.  Related PR in Gutenberg: https://github.com/WordPress/gutenberg/pull/42430.

Props spacedmonkey, luisherranz, welcher, noisysocks, matveb, fabiankaegy, aristath, zieladam.
Fixes #53148.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-12 13:14:13 +00:00
John Blackbourn
e8a05d5082 Editor: Document the arguments for registering a block style.
See #55646

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


git-svn-id: http://core.svn.wordpress.org/trunk@53451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-13 22:38:09 +00:00
audrasjb
af08ed758d Docs: Various docblock fixes in wp-includes/blocks.php, as per docs standards.
See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 08:33:09 +00:00
audrasjb
ba7b41113c Editor: Safeguard has_blocks() against fatal errors.
This changeset ensures `has_blocks()` doesn't return a fatal error when `$post` is not a valid post. If the post can't be retrieved, the function now returns `false`.

Props Howdy_McGee, costdev, colonelphantom, audrasjb, dlh, peterwilsoncc.
Fixes #55705.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53417 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 08:22:12 +00:00
audrasjb
35ab933067 Docs: Fix $feature parameter type in block_has_support().
In `block_has_support()` docblock, the `$feature` parameter is an array, not a string.

Props Soean, audrasjb.
Fixes #56307.
See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53358 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-30 14:09:10 +00:00
gziolo
fdcb34fad3 Editor: Fix register_block_type does not recognise ancestor block setting
When registering block through PHP, using `register_block_type` function, newly introduced `ancestor` block setting in `block.json` was not recognised. It worked though, when block is registered from JavaScript.

Props lovor, annezazu.
Fixes #56184.



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


git-svn-id: http://core.svn.wordpress.org/trunk@53277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-19 13:24:12 +00:00
hellofromTonya
7b880889bc Editor: Sets 'paged' query arg only when there are comments: build_comment_query_vars_from_block().
A SQL syntax error happened when a post has no comments and "Break comments into pages" is checked in Settings > Discussion. The fix sets the `'paged'` query arg only when there are comments. When there are no comments, `WP_Comment_Query` sets the default `'paged'` value to `1`.

Props bernhard-reiter, luisherranz, czapla, cbravobernal, davidbaumwald, hellofromTonya.

Follow-up to [53142], [53138].
Fixes #55658.
Built from https://develop.svn.wordpress.org/trunk@53336


git-svn-id: http://core.svn.wordpress.org/trunk@52925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-05-03 14:33:12 +00:00
audrasjb
9d10c963ff Docs: Correct parameter types for serialize_block() and serialize_blocks().
This changeset clarifies the expected type for the first parameter passed to `serialize_block()` and `serialize_blocks()` functions.

Props manooweb.
Fixes #55648.
See #54729.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52921 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-05-02 13:32:08 +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
Peter Wilson
4710282f33 Editor: Show comment previews in the Comment Query Loop.
Update `build_comment_query_vars_from_block()` to show previews of unmoderated comments to the original author of the comment. This duplicates the existing logic in `wp_list_comments()`.

Props darerodz, bernhard-reiter, czapla.
Fixes #55634.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52887 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-28 01:18:13 +00:00
audrasjb
6ef5625ac2 Docs: Docs: Use third-person singular verbs for function descriptions in wp-includes/blocks.php and wp-includes/script-loader.php, per the documentation standards.
See #54729.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52824 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-20 14:09:11 +00:00
audrasjb
4d3dbe477a Editor: Move wp_enqueue_block_style() to wp-includes/script-loader.php, for better consistency.
As a result of [52741] and [52743], `wp_enqueue_block_support_styles()` was moved to `wp-includes/script-loader.php`. However, `wp_enqueue_block_style()` was still defined in `wp-includes/blocks.php`. This changeset also moves `wp_enqueue_block_support_styles()` to `wp-includes/script-loader.php` for better consistency.

Follow-up to [52741], [52743].

Props SergeyBiryukov, mukesh27, audrasjb.
Fixes #55182.
See #55148.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52823 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-20 13:53:16 +00:00
gziolo
ec0574144a Editor: Fix Comment Query block isn't lazy loading meta data
Related GitHub issue: https://github.com/WordPress/gutenberg/issues/40241.
Primes comment meta data cache within calls to WP_Comment_Query.

Props peterwilsoncc, cbravobernal.
See #55567.
Follow-up [53138].



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


git-svn-id: http://core.svn.wordpress.org/trunk@52803 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-19 12:39:09 +00:00
gziolo
83aed3ea4f Code Quality: Fix reported undefined $script_uri variable notice
The code editor reported this issue while mamduka was browsing the blocks.php file. PHP considers variables undefined until a value is assigned (or the global keyword is used).

Follow-up for [53091].
Props mamaduka, peterwilsoncc.
See 55567.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52800 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-19 09:58:07 +00:00
Sergey Biryukov
e0d13f8b59 Coding Standards: Correct alignment in various files.
This fixes an `Array double arrow not aligned correctly` WPCS warning.

Follow-up to [53075], [53084], [53091], [53094], [53155], [53129].

See #54728.
Built from https://develop.svn.wordpress.org/trunk@53197


git-svn-id: http://core.svn.wordpress.org/trunk@52786 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-17 15:07:08 +00:00
gziolo
68a36de460 REST API: Bring new endpoints for Block Patterns from Gutenberg plugin
Related Gutenberg issue: https://github.com/WordPress/gutenberg/issues/39889.

Backporting changes from the Gutenberg plugin:
- new Block Patterns REST API endpoint
- new Block Pattern Categories REST API endpoint
- updates to Query Loop related patterns
- support for custom taxonomies in Query Loop block

Props hellofromtonya, peterwilsoncc, ntsekouras, zieladam, ironprogrammer, spacedmonkey, timothyblynjacobs, antonvlasenko, jsnajdr.
See #55505.



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


git-svn-id: http://core.svn.wordpress.org/trunk@52741 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-12 09:26:16 +00:00
gziolo
44a0e46c85 Editor: Update build_comment_query_vars_from_block from Gutenberg
Follow-up for [53138].
See #55505.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52731 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-11 16:35:10 +00:00
gziolo
f3fc52f959 Editor: Add changes for new Comments Query Loop blocks
Backports changes from Gutenberg to add functions required by Comment Query Loop and related blocks. Related unit tests depends on the new blocks and they will get added seperately.

Props darerodz, timothyblynjacobs.
See #55505.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52727 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-11 15:22:09 +00:00
gziolo
0ae89f5171 Editor: Allow registration of blocks that include assets from within a theme
Fixes the issue when you register blocks with `block.json` in your theme. There is no longer an assets's URL error because it resolves correctly in relation to the theme where it is located.

Props fabiankaegy, ocean90, whoisnegrello, audrasjb, peterwilsoncc, 
Fixes #54647, #55513.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-07 11:59:05 +00:00
gziolo
54bdc31c99 Editor: Fix broken asset URLs when using WP outside of the regular directory
Both CSS and JS URLs were totally broken for some of the newer blocks (e.g. the navigation block in the 2022 theme) when WP core is outside of the current directory using a different prefix.

Props pgpagely, Mamaduka.
Fixes #55311.



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


git-svn-id: http://core.svn.wordpress.org/trunk@52528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-16 10:22:03 +00:00
audrasjb
401e5d7175 Docs: Correct return type for get_block_metadata_i18n_schema().
Props jeremyfelt.
Fixes #55243.
See #54729.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52382 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-24 08:27:09 +00:00
jorgefilipecosta
cb3e78b0c3 Script Loader: Improvements to the load block support styles mechanism.
This commit applies feedback given to commit 52741. It changes the new function name, the file where it is located, and improves its documentation and marks.

Follow-up to [52741].
Props hellofromtonya, swissspidy, oandregal.
See #55148.
Built from https://develop.svn.wordpress.org/trunk@52743


git-svn-id: http://core.svn.wordpress.org/trunk@52332 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-16 22:20:01 +00:00
jorgefilipecosta
a73446f6ed Script Loader: Load block support styles in the head for block themes.
The dynamic block styles for layout and elements should be loaded in the head for block themes. While that should also be the case for classic themes, the current mechanism we use (render_block) does not allow us to do that, hence, this PR doesn't change anything for them and will be loaded the body.

Props oandregal, youknowriad, wpsoul.
Fixes #55148.
Built from https://develop.svn.wordpress.org/trunk@52741


git-svn-id: http://core.svn.wordpress.org/trunk@52330 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-16 17:28:01 +00:00
gziolo
a877a9806b I18n: Standardize the script paths for blocks
When providing file paths to scripts (editorScript, script or viewScript), when there is a trailing ./ included then there was a different md5 generated for the file that didn't match the one used with the file generated in the translations folder.

Props Rahe.
See #54797.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52288 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-11 12:14:04 +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
davidbaumwald
f950eec323 Script Loader: Fix a variable typo in wp_enqueue_block_style.
In `wp_enqueue_block_style` when `rtl` versions of CSS files are detected, `wp_style_add_data` is called to add the metadata to the registered sheet.  However, the stylesheet `handle` argument is misspelled as `hanle`.  This change corrects the argument name.

Props omaeyusuke.
Fixes #54786.
Built from https://develop.svn.wordpress.org/trunk@52558


git-svn-id: http://core.svn.wordpress.org/trunk@52148 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-11 17:16:00 +00:00
hellofromTonya
2a686addf0 Editor: Fix enqueueing additional styles in wp_enqueue_block_style() to print only when blocks render.
In a block theme, additional block styles registered using the `wp_enqueue_block_style` function should only get printed when the block exists on a page. However, they currently always get rendered.

This commit is a backport from Gutenberg that fixes the issue by printing the styles when a block renders.

Follow-up to [52069].

Props poena, aristath, Mamaduka.
Fixes #54787.
Built from https://develop.svn.wordpress.org/trunk@52556


git-svn-id: http://core.svn.wordpress.org/trunk@52146 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-11 16:00:01 +00:00
audrasjb
adee0cbf6b Docs: Docblock adjustments in some 5.9 block related functions.
Adds missing `@since` mention to `wp_enqueue_block_style()` and `_wp_multiple_block_styles()`, and a few other minor changes. 

Follow-up to [52069].

See #53359.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-11 11:16:03 +00:00
audrasjb
12369a6425 Coding Standards: Correct alignment in blocks.php and class-wp-rest-templates-controller.
See #53359.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-07 22:49:59 +00:00
audrasjb
25b3d172b7 Editor: Avoid a JS console error on the Navigation block view.
Props mkaz, sabernhardt, costdev.
Fixes #54456.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-30 20:02:01 +00:00
noisysocks
c421e9b34a Add Site Editor and PHP changes from Gutenberg 10.1 - 11.9
- 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
2021-11-09 02:17:17 +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
8e7b8a1837 Add: get_query_pagination_arrow function to core.
Fixes a crash that is happening when using an FSE theme because a function required is missing. Ports the function from the Gutenberg plugin.

Props oandregal, youknowriad.
Built from https://develop.svn.wordpress.org/trunk@52057


git-svn-id: http://core.svn.wordpress.org/trunk@51649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-08 22:31:58 +00:00
gziolo
e4da863a6f Docs: Clarify the path usage register_block_type_from_metadata
The filename passed with the first param must end with `block.json`.

Fixes #53806.
Props coreyw, costdev.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51603 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-04 16:03:57 +00:00
Sergey Biryukov
f57070bfd1 Docs: Add a @since note for the new $parent_block parameter of several filters:
* `pre_render_block`
* `render_block_data`
* `render_block_context`

Follow-up to [51894].

See #51612.
Built from https://develop.svn.wordpress.org/trunk@51895


git-svn-id: http://core.svn.wordpress.org/trunk@51488 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-07 13:15:59 +00:00
Andrew Ozz
2dc8f381ca Apply the pre_render_block, render_block_data, and render_block_context filters when rendering inner/nested blocks. Introdices another param to these filters: $parent_block that is the "parent" WP_Block instance for nested blocks and null for top level blocks. Adds unit tests for the filters.
Props noisysocks, gaambo, azaozz.
Fixes #51612.
Built from https://develop.svn.wordpress.org/trunk@51894


git-svn-id: http://core.svn.wordpress.org/trunk@51487 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-06 18:49:01 +00:00
hellofromTonya
a64837dfde Coding Standards: Use strict type check for in_array() in register_block_script_handle().
Follow-up to [51501].

Props aristath, sergeybiryukov.
Fixes #54206. See #53359.
Built from https://develop.svn.wordpress.org/trunk@51888


git-svn-id: http://core.svn.wordpress.org/trunk@51481 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-05 16:53:00 +00:00
desrosj
9bc8352b00 Editor: Ensure block attribute serialization in PHP matches the JavaScript equivalent.
The `serializeAttributes()` function in JavaScript uses `JSON.stringify`, which does not encode slashes and unicode characters by default. This resulted in the PHP serialization through `json_encode()` producing different results.

This also switches from `json_encode()` to `wp_json_encode()` to prevent failures when any non UTF-8 characters are included.

Props kevinfodness, SergeyBiryukov, timothyblynjacobs.
Fixes #53936.
Built from https://develop.svn.wordpress.org/trunk@51674


git-svn-id: http://core.svn.wordpress.org/trunk@51280 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-26 19:10:58 +00:00
gziolo
2f6eb9d25e Blocks: Add support for variations in block.json` file
We integrated variations with block types and the corresponding REST API endpoint in #52688. It's a follow-up patch to add missing support to the `block.json` metadata file when using `register_block_type`.

Some fields for variations are translatable.Therefore, i18n schema was copied over from Gutenberg: https://github.com/WordPress/gutenberg/blob/trunk/packages/blocks/src/api/i18n-block.json. The accompanying implementation was adapted as `translate_settings_using_i18n_schema`.

Props: gwwar, swissspidy, schlessera, jorgefilipecosta.
Fixes #53238.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-11 09:08:01 +00:00
gziolo
327852393a Build: Split packages and blocks to their webpack configs
It aligns with the changes proposed added in Gutenberg: https://github.com/WordPress/gutenberg/pull/33293.

The idea here is to split the growing webpack config into two parts: blocks and  packages.

We need to add handling for JavaScript files that are going to be used with blocks on the frontend. They didn't work quite well with the current setup for entry points created for packages.

As part of the effort, it adds support for `viewScript` in `block.json` metadata file that is later translated to `$view_script` in `WP_Block_Type` class and exposed as `view_script` from the REST API endpoint for block types.

Props youknowriad, desrosj, aristath.
Fixes #53690.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51112 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-28 10:06:59 +00:00