mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-13 15:20:06 +01:00
Block bindings: Add canUpdateBlockBindings editor setting.
Adds a `canUpdateBlockBindings` editor setting that allows to decide if the user is able to create and modify bindings through the UI. By default, only admin users can do it, but it can be overridden with `block_editor_settings_all` filter. Props santosguillamot, gziolo, jorbin, noisysocks, matveb, cbravobernal, youknowriad, mamaduka, timothyblynjacobs, peterwilsoncc, drivingralle. Fixes #61945. Built from https://develop.svn.wordpress.org/trunk@59122 git-svn-id: http://core.svn.wordpress.org/trunk@58518 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
76afc20e4e
commit
81a6eddf77
@ -665,6 +665,8 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
|
||||
}
|
||||
}
|
||||
|
||||
$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.
|
||||
*
|
||||
|
@ -801,6 +801,32 @@ function map_meta_cap( $cap, $user_id, ...$args ) {
|
||||
case 'delete_app_password':
|
||||
$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->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( $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_subtype = get_object_subtype( 'post', (int) $object_id );
|
||||
if ( empty( $object_subtype ) ) {
|
||||
$caps[] = 'do_not_allow';
|
||||
break;
|
||||
}
|
||||
|
||||
$caps = map_meta_cap( "edit_{$object_subtype}", $user_id, $object_id );
|
||||
break;
|
||||
default:
|
||||
// Handle meta capabilities for custom post types.
|
||||
global $post_type_meta_caps;
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.7-alpha-59121';
|
||||
$wp_version = '6.7-alpha-59122';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user