[wp-trac] [WordPress Trac] #49927: Editor: Introduce block context
WordPress Trac
noreply at wordpress.org
Thu Apr 16 19:53:38 UTC 2020
#49927: Editor: Introduce block context
-------------------------+-----------------------------
Reporter: aduth | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
Related: https://github.com/WordPress/gutenberg/pull/21467
Related (blocked by): #49926
The Gutenberg project is currently exploring the introduction of a new
[https://github.com/WordPress/gutenberg/issues/19685 block context
feature]. The purpose of this feature is to be able to establish values in
a block hierarchy which can be consumed by blocks anywhere lower in the
same hierarchy. These values can be established either by the framework,
or by other blocks which provide these values.
See documentation:
https://github.com/WordPress/gutenberg/blob/29c6a1b/docs/designers-
developers/developers/block-api/block-context.md
This is planned to be used for:
- Site blocks, to derive values from site settings
- Post template blocks, to derive values from the "current" post
- Navigation block, to derive values from the "current" menu
Many of these use-cases are related to the current full-site editing
efforts, currently slated for WordPress 5.5:
https://make.wordpress.org/updates/2020/03/06/update-progress-on-goals/
Prior art: Just as many of the full-site editing post blocks are intended
to map to [https://developer.wordpress.org/themes/references/list-of-
template-tags/#post-tags corresponding theme post tags], the role of block
context can serve the role of
[https://developer.wordpress.org/themes/basics/the-loop/ The Loop] in
preparing the post for blocks within to consume from.
Proposed tasks:
- For making context available to blocks for `render_callback`, this
relies on the proposal at #49926. There are earlier iterations of
[https://github.com/WordPress/gutenberg/pull/21467 Gutenberg#21467] which
assigned this context as a global variable and expected blocks to consume
from the global, similar to the `$post` global. The changes introducing
`WP_Block` sought to avoid these globals, but it is an alternative option
if #49926 is not viable.
- Introduce block context mechanism based on registered block settings for
providing and consuming context. See implementation from
[https://github.com/WordPress/gutenberg/pull/21467 Gutenberg#21467] for
initial reference.
-
[https://developer.wordpress.org/reference/functions/get_block_editor_server_block_settings/
`get_block_editor_server_block_settings`] should be updated to pick the
new `providesContext` and `context` keys from the registered block's
settings, in order to share these values between the server and client.
- Optionally, the `$keys_to_pick` array within this implementation
could be considered to be made filterable. It's not explicitly needed for
core introduction, but is a challenge for external extensibility, like in
the case of [https://github.com/WordPress/gutenberg/pull/21467
Gutenberg#21467].
Feedback welcome: While the above can be considered a proposal of tasks,
this is all very much subject to change.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49927>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list