Skip to content

Commit

Permalink
General: Add allowed_blocks field to block registration and REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Jan 31, 2024
1 parent 6dd00b1 commit 9e5ecc2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/wp-admin/includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,7 @@ function get_block_editor_server_block_settings() {
'keywords' => 'keywords',
'example' => 'example',
'variations' => 'variations',
'allowed_blocks' => 'allowedBlocks',
);

foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
'styles' => 'styles',
'variations' => 'variations',
'example' => 'example',
'allowedBlocks' => 'allowed_blocks',
);
$textdomain = ! empty( $metadata['textdomain'] ) ? $metadata['textdomain'] : null;
$i18n_schema = get_block_metadata_i18n_schema();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ public function prepare_item_for_response( $item, $request ) {
'view_style_handles',
'variations',
'block_hooks',
'allowed_blocks',
),
$deprecated_fields
);
Expand Down Expand Up @@ -738,6 +739,17 @@ public function get_item_schema() {
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
),
'allowed_blocks' => array(
'description' => __( 'Allowed child block types.' ),
'type' => array( 'array', 'null' ),
'items' => array(
'type' => 'string',
'pattern' => self::NAME_PATTERN,
),
'default' => null,
'context' => array( 'embed', 'view', 'edit' ),
'readonly' => true,
)

Check failure on line 752 in src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

There should be a comma after the last array item in a multi-line array.
),
);

Expand Down

0 comments on commit 9e5ecc2

Please sign in to comment.