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
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
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
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
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
- 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
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
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
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.
Built from https://develop.svn.wordpress.org/trunk@51378
git-svn-id: http://core.svn.wordpress.org/trunk@50989 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
Built from https://develop.svn.wordpress.org/trunk@51375
git-svn-id: http://core.svn.wordpress.org/trunk@50986 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
Built from https://develop.svn.wordpress.org/trunk@51348
git-svn-id: http://core.svn.wordpress.org/trunk@50957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
Built from https://develop.svn.wordpress.org/trunk@51267
git-svn-id: http://core.svn.wordpress.org/trunk@50876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
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.
Built from https://develop.svn.wordpress.org/trunk@51262
git-svn-id: http://core.svn.wordpress.org/trunk@50871 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This fixes an issue where block stylesheets were being loaded even if they did not exist, causing 404 errors. The issue presented itself when the site was choosing to load block assets individually through the `should_load_separate_core_block_assets` filter hook.
This also fixes an issue where non-Core blocks would only be registered if they actually had asset files. This prevents developers from adding additional information to a style handle, such as inline styles through `wp_add_inline_style()`.
Props walbo, jorbin, aristath, desrosj, hellofromTonya.
Fixes#53375.
Built from https://develop.svn.wordpress.org/trunk@51254
git-svn-id: http://core.svn.wordpress.org/trunk@50863 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This replaces a stray instance of `gutenberg_experimental_set()` with the WordPress Core version of this function, `_wp_array_set()`.
A stray `gutenberg` text domain is also removed from a `__()` call.
Props walbo, chaion07, JeffPaul.
Fixes#53369.
Built from https://develop.svn.wordpress.org/trunk@51148
git-svn-id: http://core.svn.wordpress.org/trunk@50757 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Since the function only checks the raw, non-parsed post content, reusable blocks are just a `core/block` type and nothing more at that point.
In order to also check reusable blocks, the content needs to be parsed using `parse_blocks()` first.
Props vyskoczilova, peterwilsoncc.
Fixes#53140.
Built from https://develop.svn.wordpress.org/trunk@51046
git-svn-id: http://core.svn.wordpress.org/trunk@50655 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
Rather than using two distinct methods to register block types in WordPress core, let's make `register_block_type` the canonical method to deal with all use cases. In practice, the patch proposed extends its usage to work as a proxy to `register_block_type_from_metadata`. It should remove some confusion that we observed and let us be more explicit what's the latest recommendation.
Props matveb, mcsf.
Fixes#53233.
Built from https://develop.svn.wordpress.org/trunk@50927
git-svn-id: http://core.svn.wordpress.org/trunk@50536 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds styles for individual core blocks to make it possible to render only styles for those blocks that are rendered on the page (frontend). This is optinal functionality for start that can be controlled with the new `separate_core_block_assets` filter.
In addition to that, styles can be inlined when `path` is passed when registering an individual styles. This functionality can be changed with the new `styles_inline_size_limit` filter. The maximum size of inlined styles in bytes defaults to 20 000.
Props aristath, aduth, westonruter, mcsf.
Fixes#50328, #52620.
Built from https://develop.svn.wordpress.org/trunk@50836
git-svn-id: http://core.svn.wordpress.org/trunk@50445 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In `unregister_block_style`, the `$block_name` parameter was documented as an array. This change corrects the type to `string`, as that's what is expected in `WP_Block_Styles_Registry->unregister`.
Props kraftner.
Fixes#52795.
Built from https://develop.svn.wordpress.org/trunk@50528
git-svn-id: http://core.svn.wordpress.org/trunk@50141 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Add a reference to `WP_Block_Type::__construct()` for information on accepted arguments in `register_block_type()`.
Synchronize the documentation between several places, use `WP_Block_Type::__construct()` as the canonical source.
Props ediamin, audrasjb, peterwilsoncc.
Fixes#48640.
Built from https://develop.svn.wordpress.org/trunk@50419
git-svn-id: http://core.svn.wordpress.org/trunk@50030 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds 2 new hooks in `register_block_type_from_metadata`:
- Named `block_type_metadata` to filter the content of metadata read from `block.json`
- Named `block_type_metadata_settings` to filter the settings object determined from the metadata that is passed to `register_block_type` call
Props swissspidy.
Fixes#52138.
Built from https://develop.svn.wordpress.org/trunk@49948
git-svn-id: http://core.svn.wordpress.org/trunk@49647 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Related Gutenberg PR: https://github.com/WordPress/gutenberg/pull/25220.
It aligns with the latest changes added by aristath to the Gutenberg project. As part of styles splitting for core blocks, there was a special pattern introduced for how style handles are named. Ideally, we would apply it to all blocks but there might be some backward compatibility considerations so I left the handling for non-core blocks unchanged.
Props aristath.
See #50328.
Built from https://develop.svn.wordpress.org/trunk@49850
git-svn-id: http://core.svn.wordpress.org/trunk@49569 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Move the pre_render_block, render_block_data, and render_block_context
filters from render_block() to WP_Block. This ensures that they are
called for all blocks, including nested blocks, not just top-level
blocks.
Fixes#51612.
Props gaambo, gziolo, TimothyBlynJacobs.
Built from https://develop.svn.wordpress.org/trunk@49608
git-svn-id: http://core.svn.wordpress.org/trunk@49346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When using WordPress trunk with Gutenberg master, there's an incompatibility causing
the dynamic block generated classes to be omitted.
This commit refactors the block supports to fix that problem.
Props nosolosw.
Fixes#51606.
Built from https://develop.svn.wordpress.org/trunk@49310
git-svn-id: http://core.svn.wordpress.org/trunk@49072 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
The new block editor included in 5.6 introduces an api_version property
that indicates which block API version the block is using.
This commits makes this property available on the block type and the endpoint.
Props TimothyBlynJacobs, gziolo.
Fixes#51529.
Built from https://develop.svn.wordpress.org/trunk@49224
git-svn-id: http://core.svn.wordpress.org/trunk@48986 1a063a9b-81f0-0310-95a4-ce76da25c4cd
As it already was not possible to pass the required parameters without also passing the optional one anyway, removing the default value for the (not so) optional parameters should not affect backward compatibility.
This change affects three functions in core:
* `get_comment_delimited_block_content()`
* `do_enclose()`
* `_wp_delete_tax_menu_item()`
Props jrf, ayeshrajans, desrosj.
Fixes#50343.
Built from https://develop.svn.wordpress.org/trunk@48794
git-svn-id: http://core.svn.wordpress.org/trunk@48556 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The filter is the callback function added with `add_filter()`, therefore the hook passes a value to the filter, and the filter returns a value to change its behaviour.
The documentation is referring to the latter.
Props johnbillion.
See #49572, #16557.
Built from https://develop.svn.wordpress.org/trunk@48185
git-svn-id: http://core.svn.wordpress.org/trunk@47954 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When `do_blocks()` is run, it sets up some special handling of the `wpautop` filter, as we don't want `wpautop` to run on block content, but we do want it to be available for subsequent runs of `the_content`, which may be happening on non-block content.
As we set this up before rendering dynamic blocks, however, a dynamic block choosing to run `the_content` will cause unintentially structural deficiences in this particular recursive block tower.
Moving this handling to after dynamic blocks are rendered makes our tower lean a little less.
Props aldavigdis, pento.
Fixes#45495.
Built from https://develop.svn.wordpress.org/trunk@45139
git-svn-id: http://core.svn.wordpress.org/trunk@44948 1a063a9b-81f0-0310-95a4-ce76da25c4cd
At the start of `render_block()`, the `pre_render_block` filter allows the function to be short-circuited, and the `render_block_data` filter is applied to the `$block` parameter before it's processed.
Props kkarpieszuk, pento.
Fixes#45451.
Built from https://develop.svn.wordpress.org/trunk@44553
git-svn-id: http://core.svn.wordpress.org/trunk@44384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In RTL languages, WordPress adds `style-editor-rtl.css` editor styles to the global `$editor_styles`.
This patch ignores handling these styles if the file is not preset.
Also, clarify the docs for the return value of the `block_version` function.
Props mostafa.s1990, desrosj, mukesh27.
Merges [43923] and [43924] to trunk.
Fixes#45288, #45342.
Built from https://develop.svn.wordpress.org/trunk@44270
git-svn-id: http://core.svn.wordpress.org/trunk@44100 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Changes of note:
- Includes the new Annotations API package.
- `wp-polyfill-ecmascript.js` is renamed to `wp-polyfill.js`.
- `strip_dynamic_blocks()` has been removed in favor of `excerpt_remove_blocks()`.
- The PHP block parser is now syncing from the `block-serialization-default-parser` package.
- `do_blocks()` uses the new parser.
- The `do_block` filter has been removed from `do_blocks()`, in favor of a `render_block` filter in `render_block()`.
Also, a little cleanup to `render_block()`. Always normalize `$block['attrs’]` to array in `’render_block’` filter.
Props pento, azaozz.
Merges [43884] and [43888] to trunk.
See #45145, #45190, #45264, #45282.
Built from https://develop.svn.wordpress.org/trunk@44261
git-svn-id: http://core.svn.wordpress.org/trunk@44091 1a063a9b-81f0-0310-95a4-ce76da25c4cd
As `do_blocks()` is run before `wpautop()` in the_content filter, we can remove in a Just In Time fashion, before that filter is run.
After `wpautop()`s original priority has passed, we can re-add it in a Just Too Late fashion, to ensure it's available if `the_content` filter is run multiple times on a page load.
Merges [43879] and [43881] from the 5.0 branch to trunk.
Props pento, nerrad.
Fixes#45290.
Built from https://develop.svn.wordpress.org/trunk@44226
git-svn-id: http://core.svn.wordpress.org/trunk@44056 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `block_version` denotes which version of Blocks the `post_content` contains. Introduces new `block_version()` function for versioning Blocks.
Merges [43770] from the 5.0 branch to trunk.
Props danielbachhuber, birgire.
Fixes#43887.
Built from https://develop.svn.wordpress.org/trunk@44127
git-svn-id: http://core.svn.wordpress.org/trunk@43957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `WP_Block_Parser` class, and the accompanying `parse_blocks()` helper function, can be used to parse an array of blocks out of a content string.
`WP_Block_Parser` is copied from the `@wordpress/block-serialization-default-parser` package. To ensure it stays in sync with the JavaScript parser, changes should be implemented in the package first, then the package version should be upgraded to include the changes.
Props pento.
Merges [43751] to trunk.
See #45109.
Built from https://develop.svn.wordpress.org/trunk@44116
git-svn-id: http://core.svn.wordpress.org/trunk@43946 1a063a9b-81f0-0310-95a4-ce76da25c4cd