-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Block Hooks: Add field to block registration, REST API #5203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3186d24
27fcdc5
42166c8
99ab6c7
67135e3
49bf14e
ad879ca
8fd46e9
e71e581
6de2dc3
f3a04cb
72de120
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,6 +290,7 @@ public function prepare_item_for_response( $item, $request ) { | |
| 'editor_style_handles', | ||
| 'style_handles', | ||
| 'variations', | ||
| 'block_hooks', | ||
| ), | ||
| $deprecated_fields | ||
| ); | ||
|
|
@@ -705,6 +706,19 @@ public function get_item_schema() { | |
| ), | ||
| 'keywords' => $keywords_definition, | ||
| 'example' => $example_definition, | ||
| 'block_hooks' => array( | ||
| 'description' => __( 'This block is automatically inserted near any occurence of the block types used as keys of this map, into a relative position given by the corresponding value.' ), | ||
| 'type' => 'object', | ||
| 'patternProperties' => array( | ||
| '^[a-zA-Z0-9-]+/[a-zA-Z0-9-]+$' => array( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ockham How something like this.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noting that there might be hundreds of registered blocks, but the block author might still list the block type name that isn't present on the site and we would consider it valid. What's the reasoning behind listing all available blocks? |
||
| 'type' => 'string', | ||
| 'enum' => array( 'before', 'after', 'first_child', 'last_child' ), | ||
| ), | ||
| ), | ||
| 'default' => array(), | ||
| 'context' => array( 'embed', 'view', 'edit' ), | ||
| 'readonly' => true, | ||
| ), | ||
|
Comment on lines
+709
to
+721
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated this based on https://github.com/WordPress/gutenberg/blob/8c5dbabe5361e94f18e4a55070db9a54d3c59d0b/lib/compat/wordpress-6.4/block-hooks.php#L341-L351. Hope that makes sense!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that is correct and should changed in gutenberg. This pattern is not needed and make it extremely hard to read.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my other comment 😄 |
||
| ), | ||
| ); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.