Skip to content

Commit

Permalink
Address changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Sep 26, 2024
1 parent ae3b1be commit a6a8d21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/wp-includes/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
}
}

$editor_settings['canUpdateBlockBindings'] = current_user_can( 'edit_block_binding', $block_editor_context->post->ID );
$editor_settings['canUpdateBlockBindings'] = current_user_can( 'edit_block_binding', $block_editor_context );

/**
* Filters the settings to pass to the block editor for all editor type.
Expand Down
12 changes: 7 additions & 5 deletions src/wp-includes/capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,22 +802,24 @@ function map_meta_cap( $cap, $user_id, ...$args ) {
$caps = map_meta_cap( 'edit_user', $user_id, $args[0] );
break;
case 'edit_block_binding':
$block_editor_context = $args[0];
if ( isset( $block_editor_context ) && isset( $block_editor_context->post ) ) {
$object_id = $block_editor_context->post->ID;
}
/*
* If the post ID is null, check if the context is the site editor.
* Fall back to the edit_theme_options in that case.
*/
if ( ! isset( $args[0] ) ) {
$screen = get_current_screen();
if ( ! isset( $screen->id ) || 'site-editor' !== $screen->id ) {
if ( ! isset( $object_id ) ) {
if ( ! isset( $block_editor_context->name ) || 'core/edit-site' !== $block_editor_context->name ) {
$caps[] = 'do_not_allow';
break;
}
$caps = map_meta_cap( 'edit_theme_options', $user_id );
break;
}

$object_id = (int) $args[0];
$object_subtype = get_object_subtype( 'post', $object_id );
$object_subtype = get_object_subtype( 'post', (int) $object_id );
if ( empty( $object_subtype ) ) {
$caps[] = 'do_not_allow';
break;
Expand Down

0 comments on commit a6a8d21

Please sign in to comment.