Commit Graph

117 Commits

Author SHA1 Message Date
Jb Audras
da50ef9aed 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@53799 602fd350-edb4-49c9-b593-d223f7449a82
2022-07-30 14:07:55 +00:00
Greg Ziółkowski
41475f336e 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.




git-svn-id: https://develop.svn.wordpress.org/trunk@53718 602fd350-edb4-49c9-b593-d223f7449a82
2022-07-19 13:22:31 +00:00
Tonya Mork
6dab53e93b 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53336 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-03 14:31:12 +00:00
Jb Audras
9e6e4b5893 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@53332 602fd350-edb4-49c9-b593-d223f7449a82
2022-05-02 13:30:47 +00:00
John Blackbourn
1cffa3f82b Docs: Various docblock corrections and improvements for changes introduced in 6.0.
See #54729


git-svn-id: https://develop.svn.wordpress.org/trunk@53302 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-28 09:57:51 +00:00
Peter Wilson
832429e9b2 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@53298 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-28 01:16:18 +00:00
Jb Audras
c63de7818e 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@53235 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-20 14:07:53 +00:00
Jb Audras
84f3b34e2d 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@53234 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-20 13:51:21 +00:00
Greg Ziółkowski
c755258903 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].




git-svn-id: https://develop.svn.wordpress.org/trunk@53214 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-19 12:37:53 +00:00
Greg Ziółkowski
87dc304715 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@53211 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-19 09:56:02 +00:00
Sergey Biryukov
dd06c4767f 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53197 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-17 15:05:10 +00:00
Greg Ziółkowski
a807e86391 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.




git-svn-id: https://develop.svn.wordpress.org/trunk@53152 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-12 09:24:51 +00:00
Greg Ziółkowski
cab6fec683 Editor: Update build_comment_query_vars_from_block from Gutenberg
Follow-up for [53138].
See #55505.



git-svn-id: https://develop.svn.wordpress.org/trunk@53142 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-11 16:33:51 +00:00
Greg Ziółkowski
067d1667f2 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@53138 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-11 15:20:13 +00:00
Greg Ziółkowski
9a7a11a74f 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@53091 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-07 11:57:16 +00:00
Greg Ziółkowski
573581f43f 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.




git-svn-id: https://develop.svn.wordpress.org/trunk@52939 602fd350-edb4-49c9-b593-d223f7449a82
2022-03-16 10:20:12 +00:00
Jb Audras
44e308c12e Docs: Correct return type for get_block_metadata_i18n_schema().
Props jeremyfelt.
Fixes #55243.
See #54729.


git-svn-id: https://develop.svn.wordpress.org/trunk@52793 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-24 08:25:25 +00:00
Jorge Costa
8ec1cb83e3 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52743 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-16 22:18:33 +00:00
Jorge Costa
43a8631882 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52741 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-16 17:26:46 +00:00
Greg Ziółkowski
af07f6af4b 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@52699 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-11 12:12:56 +00:00
Sergey Biryukov
94d6cee2e2 Docs: Fix typos in some DocBlocks.
Props kebbet.
See #54729.

git-svn-id: https://develop.svn.wordpress.org/trunk@52597 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-18 20:27:39 +00:00
David Baumwald
f44030b140 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52558 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-11 17:14:54 +00:00
Tonya Mork
1e7d559444 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52556 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-11 15:57:09 +00:00
Jb Audras
1b541a7e52 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52354 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-11 11:14:17 +00:00
Jb Audras
7c8bed0be2 Coding Standards: Correct alignment in blocks.php and class-wp-rest-templates-controller.
See #53359.


git-svn-id: https://develop.svn.wordpress.org/trunk@52345 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-07 22:48:54 +00:00
Jb Audras
d9dc716cff Editor: Avoid a JS console error on the Navigation block view.
Props mkaz, sabernhardt, costdev.
Fixes #54456.


git-svn-id: https://develop.svn.wordpress.org/trunk@52291 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-30 20:00:09 +00:00
Robert Anderson
f034bc832e 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52069 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-09 02:15:23 +00:00
Robert Anderson
39e33bed83 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52062 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-08 23:09:53 +00:00
Jorge Costa
0f0735a888 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52057 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-08 22:30:41 +00:00
Greg Ziółkowski
6857e69549 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@52012 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-04 16:02:42 +00:00
Sergey Biryukov
eda09eccfb 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51895 602fd350-edb4-49c9-b593-d223f7449a82
2021-10-07 13:14:43 +00:00
Andrew Ozz
ed9f437fc0 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51894 602fd350-edb4-49c9-b593-d223f7449a82
2021-10-06 18:47:09 +00:00
Tonya Mork
374adaafe6 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51888 602fd350-edb4-49c9-b593-d223f7449a82
2021-10-05 16:51:15 +00:00
Jonathan Desrosiers
44180691e6 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51674 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-26 19:09:16 +00:00
Greg Ziółkowski
d9599addd1 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@51599 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-11 09:06:31 +00:00
gziolo
ad976addb3 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@51501 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-28 10:05:01 +00:00
John Blackbourn
0871a0ddc2 Docs: Miscellaneous docblock corrections and improvements.
See #53399


git-svn-id: https://develop.svn.wordpress.org/trunk@51477 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-22 16:53:59 +00:00
Aaron Jorbin
61759be775 Fix merge info.
[51378] contained merge info it shouldn't and accidentally a line of code from one of those commits that another one had changed.

See #53604.
Unprops jorbin.



git-svn-id: https://develop.svn.wordpress.org/trunk@51379 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-07 22:46:40 +00:00
Aaron Jorbin
2de2287240 Posts: Fix Spelling in inline docs.
A warpper is the traditional home of a neditor. They generally are optimized for supporting the good quality content that a neditor requires to survive. Some warppers feel like they have been around forever but have laid a foundation for newer warppers. A specific Russian warppers is known for having a wide footprint and touching almost everything. Warppers were originally only found subversioned underground, but they have been able to GIT above ground in the last few years.

The number of warpers in the world is small, but without them the neditor would never survive.

See [23105], [51375], #53604.
Props SergeyBiryukov.



git-svn-id: https://develop.svn.wordpress.org/trunk@51378 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-07 22:38:44 +00:00
Jonathan Desrosiers
8c413885bd Posts: Allow the list of wrapper blocks to be filtered.
This introduces the `excerpt_allowed_wrapper_blocks` filter for controlling which blocks should be considered wrapper blocks.

Wrapper blocks and their nested contents are not stripped by `excerpt_remove_blocks()`, allowing their contents to appear in generated excerpts.

Follow up to [51348].

Props aristath, jorbin.
See #53604.

git-svn-id: https://develop.svn.wordpress.org/trunk@51375 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-07 19:09:41 +00:00
Peter Wilson
b1f0971ee3 Block Editor: Update packages with latest fixes for 5.8 RC2
Includes the following fixes:

- Query Block: Type validation of `WP_Query` parameters.

Props ntsekouras, stevehenty, peterwilsoncc, desrosj.
Fixes #53397.



git-svn-id: https://develop.svn.wordpress.org/trunk@51362 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-06 23:55:44 +00:00
Jonathan Desrosiers
0690170556 Posts: Prevent an empty excerpt when groups and nested column blocks are present.
This improves the logic within `excerpt_remove_blocks()` to better handle `innerBlocks`. This prevents an empty excerpt from being returned when `core/columns`, `core/column`, and `core/group` blocks are present.

This issue has been surfaced in the Query Loop block, where excerpts can be set to display. 

Props aristath.
Fixes #53604.

git-svn-id: https://develop.svn.wordpress.org/trunk@51348 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-06 15:31:48 +00:00
John Blackbourn
28ea7b18cf Docs: Corrections and improvements to types used in docblocks for symbols, properties, and filters.
See #53399


git-svn-id: https://develop.svn.wordpress.org/trunk@51298 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-01 21:01:17 +00:00
Jonathan Desrosiers
a7804f73e1 Script Loader: Revert [51267].
This was missed in [51268] when reverting [51259-51260,51265].

Props pbiron.
See #53397.

git-svn-id: https://develop.svn.wordpress.org/trunk@51288 602fd350-edb4-49c9-b593-d223f7449a82
2021-06-30 18:24:39 +00:00
Sergey Biryukov
7041541417 Docs: Improve documentation for optional parameters in WP_Theme_JSON_Resolver methods per the documentation standards.
Move `add_action()` call to `wp-includes/default-filters.php`.

Follow-up to [50959], [51221].

See #52628, #53461.

git-svn-id: https://develop.svn.wordpress.org/trunk@51284 602fd350-edb4-49c9-b593-d223f7449a82
2021-06-30 17:19:59 +00:00
Jonathan Desrosiers
36012064f6 Build/Test Tools: Revert [51259-51256,51265].
[51259] introduced a PHP notice that was not actually fixed by [51265]. Reverting these changes in order to investigate further.

See #53397.

git-svn-id: https://develop.svn.wordpress.org/trunk@51268 602fd350-edb4-49c9-b593-d223f7449a82
2021-06-30 02:13:30 +00:00
Jonathan Desrosiers
9488d3dc7f Script Loader: Fix PHP notice caused by the viewScript for the core/file block.
This fixes a PHP notice caused by the `viewScript` for the `core/file` block having `.min.js` instead of just `.js`.

`register_block_script_handle()` was incorrectly looking for `view.min.asset.php`, which does not exist, and caused the `_doing_it_wrong()` notice.

This adds a check for `.min.js` in the `viewScript` field of `block.json` and corrects it to `.js` in order to match the expected pattern of `view.asset.php` until a more permanent fix can be created.

Follow up to [51259].

Props ipstenu, pbiron, peterwilsoncc.
See #53397.

git-svn-id: https://develop.svn.wordpress.org/trunk@51267 602fd350-edb4-49c9-b593-d223f7449a82
2021-06-30 01:45:10 +00:00
Jonathan Desrosiers
5673442b68 Script Loader: Use the provided block version when registering styles.
This updates `register_block_style_handle()` to use the `version` value provided in the `$metadata` parameter for non-Core blocks (when present). This removes the requirement to use `filemtime()` to generate a unique version.

When `version` is not defined within `$metadata`, the script version will fallback to using the current version of WordPress.

The block version should be considered similar to the one specified by plugin developers within the header of the main plugin file.

Props hellofromTonya, gziolo, jorbin, desrosj, walbo, aristath.
Fixes #53507.

git-svn-id: https://develop.svn.wordpress.org/trunk@51262 602fd350-edb4-49c9-b593-d223f7449a82
2021-06-29 18:23:30 +00:00
Riad Benguella
51cbe7eeb7 Build: Split packages and blocks to their webpack configs.
This also adds support for the viewScript for blocks fixing 
the PDF preview for file blocks.

Props desrosj, gziolo.
See #53397.


git-svn-id: https://develop.svn.wordpress.org/trunk@51259 602fd350-edb4-49c9-b593-d223f7449a82
2021-06-29 15:08:16 +00:00
Jonathan Desrosiers
81e1c2d58b Coding Standards: Apply an alignment fix after composer format.
Follow up to [51254].

See #53375.

git-svn-id: https://develop.svn.wordpress.org/trunk@51255 602fd350-edb4-49c9-b593-d223f7449a82
2021-06-29 00:39:00 +00:00