Commit Graph

26 Commits

Author SHA1 Message Date
John Blackbourn
1d4e72c798 Docs: Correct and improve the documented types for various functions and hooks.
See #55646

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


git-svn-id: http://core.svn.wordpress.org/trunk@53436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 14:03:09 +00:00
gziolo
1dabd8df68 Editor: Register 'lock' attribute for every block on the server
Backports changes from https://github.com/WordPress/gutenberg/pull/40468.

The lock attribute needs to be supported by every block, but currently, it is only done on the client site. As a result, it was causing block rendered API requests to fail when blocks are locked.

Props mamaduka, peterwilsoncc.
See #55567.



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


git-svn-id: http://core.svn.wordpress.org/trunk@52857 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-26 09:50:12 +00:00
gziolo
a9008e6cc5 Editor: Make block type aware of the ancestor field
The `ancestor` field was recently added to the `block.json` schema in Gutenberg. See: https://github.com/WordPress/gutenberg/pull/39894.

Props darerodz.
Fixes #55531.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-06 09:47:09 +00:00
John Blackbourn
ecc08a41f6 Docs: Increase the specificity of types in various inline documentation.
See #54729

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


git-svn-id: http://core.svn.wordpress.org/trunk@52241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-30 19:25:03 +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
desrosj
8c3e1e9aa8 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.
Built from https://develop.svn.wordpress.org/trunk@51268


git-svn-id: http://core.svn.wordpress.org/trunk@50877 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-30 02:14:56 +00:00
desrosj
d5cf36000b Docs: Correct @since annotation for WP_Block_Type->view_script.
Follow up to [51259].

Props swissspidy.
See #53397.
Built from https://develop.svn.wordpress.org/trunk@51260


git-svn-id: http://core.svn.wordpress.org/trunk@50869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-29 15:47:58 +00:00
youknowriad
8e08c569c5 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.

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


git-svn-id: http://core.svn.wordpress.org/trunk@50868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-29 15:09:58 +00:00
Sergey Biryukov
bf3ebaf60f Docs: Document api_version and variations properties in WP_Block_Type::__construct().
Add `@since` tags for all properties added in WordPress 5.5, 5.6, and 5.8.

Follow-up to [47875], [48117], [49224], [50297], [50419], [50527].

Props mbabker.
Fixes #53518.
Built from https://develop.svn.wordpress.org/trunk@51244


git-svn-id: http://core.svn.wordpress.org/trunk@50853 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-06-26 11:13:56 +00:00
Sergey Biryukov
cb55990e50 Docs: Add missing @since tags for item_link and item_link_description post type and taxonomy labels.
Follow-up to [50527].

See #52688.
Built from https://develop.svn.wordpress.org/trunk@50529


git-svn-id: http://core.svn.wordpress.org/trunk@50142 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-13 10:25:06 +00:00
gziolo
f27c179afc Editor: Make block type aware of variations
Currently block variations are only defined on the client. In some cases, creating block variations on the server can be very useful, especially when needed data is not exposed in the REST APIs.

Related to https://github.com/WordPress/gutenberg/pull/29095.

Props: gwwar, timothyblynjacobs.
Fixes: #52688.


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


git-svn-id: http://core.svn.wordpress.org/trunk@50140 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-12 13:35:09 +00:00
Sergey Biryukov
5fd4f8e993 Docs: Improve documentation for WP_Block_Type properties.
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
2021-02-23 19:18:02 +00:00
youknowriad
8fbbd54c40 Block Editor: Expose api_version in the block type and the REST endpoint.
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
2020-10-20 07:54:10 +00:00
John Blackbourn
905460bd5e Docs: Standardise the type name for booleans and integers.
This brings these docs inline with the documentation standards.

Props ravipatel, justinahinon

Fixes #51426

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


git-svn-id: http://core.svn.wordpress.org/trunk@48882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-10 20:02:05 +00:00
Helen Hou-Sandí
4e5211a691 REST API: Include attribute name in schema validation error message.
Props bobbingwide.
Fixes #51231.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48731 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-10 16:34:11 +00:00
Sergey Biryukov
ec571bdcf6 Docs: Spell "falsey" in a consistent way.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48275


git-svn-id: http://core.svn.wordpress.org/trunk@48044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-02 11:30:02 +00:00
gziolo
9a9352da00 Editor: Support filtering arguments in block type registration
Adds possibility to filter the settings of a block type during its registration.

Props aduth, azaozz.
Fixes #49615.


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


git-svn-id: http://core.svn.wordpress.org/trunk@48032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-01 13:10:02 +00:00
gziolo
85c5bca472 Editor: Remove default "layout" block attribute from WP_Block_Type::get_attributes
The merging behavior which assigns the `layout` attribute in `WP_Block_Type` gets removed.

Props aduth, TimothyBlynJacobs.
Fixes #50257.


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


git-svn-id: http://core.svn.wordpress.org/trunk@47887 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-22 12:22:08 +00:00
gziolo
29ffb31cb3 Blocks: Add context fields to WP_Block_Type
New block context related fields were added as part of https://github.com/WordPress/gutenberg/pull/22686. This changest backports them to WP_Block_Type class.

Props aduth, spacedmonkey, mcsf, epiqueras.
Fixes #47656.  


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


git-svn-id: http://core.svn.wordpress.org/trunk@47886 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-22 10:26:14 +00:00
Sergey Biryukov
be16bb9fba Docs: Remove extra spaces from @param tags.
Per the documentation standards, `@param` tags should be aligned with each other, but not with the `@return` tag.

See #49572.
Built from https://develop.svn.wordpress.org/trunk@48110


git-svn-id: http://core.svn.wordpress.org/trunk@47879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-20 12:58:10 +00:00
Sergey Biryukov
0eaae8ebbf Docs: Update type for WP_Block_Type::$style property.
Follow-up to [47907].

See #48529.
Built from https://develop.svn.wordpress.org/trunk@47908


git-svn-id: http://core.svn.wordpress.org/trunk@47682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-04 10:44:10 +00:00
gziolo
eec4c743fa Blocks: Update default value for some fields in WP_Block_Type
Related to the issue with default values for the blocks registered on the server. By using null for some fields we can treat them as undefined on the client.

See: WordPress/gutenberg#22849.
Props aduth.
Fixes #48529. 


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


git-svn-id: http://core.svn.wordpress.org/trunk@47681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-04 06:07:13 +00:00
Dominik Schilling
7152c73f6a Editor: Fix code style for constructor arguments added in [47875].
Also revert unintended changes to `WP_Block_Type::__construct()` DocBlock.

See #48529.
Built from https://develop.svn.wordpress.org/trunk@47876


git-svn-id: http://core.svn.wordpress.org/trunk@47650 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-01 16:27:15 +00:00
gziolo
c704057e0d Add fields to WP_Block_Type
As part of #47620 and the RFC for block registeration. Server registered blocks are missing some fields. These changeset includes them.

Props spacedmonkey, aduth.

Fixes #48529.


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


git-svn-id: http://core.svn.wordpress.org/trunk@47649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-01 12:27:08 +00:00
desrosj
bc9dfcfeb1 REST API: Preserve unknown, respect null in server-side block rendering.
- Skips validation where there is no attribute definition, but keeps the attribute value. Previously, the attribute would be omitted from the attributes passed to `render_callback`. Notably, this resolves an issue where `render_callback` cannot receive a block's `align` and `customClassName` attribute values, since these are defined as a client-side filter.
- Validates `null` as a proper value in its own right. Previously, a client implementation of a block could track `{“attribute":null}` as an explicitly empty value, and the server would wrongly initiate defaulting behavior. The new behavior will now only populate a default value if the attribute is not defined at all, including when unset in its being invalid per the attribute schema. 

Props aduth, noisysocks, youknowriad, danielbachhuber.

Merges [43918] to trunk.

See #45145 for the patch, #45098 for the original ticket.
Built from https://develop.svn.wordpress.org/trunk@44269


git-svn-id: http://core.svn.wordpress.org/trunk@44099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-17 18:00:52 +00:00
Gary Pendergast
2d3f734847 Blocks: Introduce WP_Block_Type and WP_Block_Type_Registry classes.
These are the foundational classes allowing blocks to be registered and used throughout WordPress.

This commit also includes the `has_block()` and `has_blocks()` functions, which are required for unit testing these classes.

Merges [43742] from the 5.0 branch to trunk.

Props adamsilverstein, danielbachhuber, desrosj.
Fixes #45097.
See #45109.

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


git-svn-id: http://core.svn.wordpress.org/trunk@43938 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-13 09:44:23 +00:00