Skip to content

Commit

Permalink
Read from get_post_type_capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Dec 11, 2024
1 parent ddc54f4 commit 4f6dbe1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/compat/wordpress-6.7/block-bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ function gutenberg_add_edit_block_binding_capability( $caps, $cap, $user_id, $ar
if ( empty( $object_subtype ) ) {
return array( 'do_not_allow' );
}
$capability_type = get_post_type_object( $object_subtype )->capability_type;
$caps = map_meta_cap( "edit_{$capability_type}", $user_id, $object_id );
$post_type_object = get_post_type_object( $object_subtype );
// Initialize empty array if it doesn't exist.
if ( ! isset( $post_type_object->capabilities ) ) {
$post_type_object->capabilities = array();
}
$post_type_capabilities = get_post_type_capabilities( $post_type_object );
$caps = map_meta_cap( $post_type_capabilities->edit_post, $user_id, $object_id );
}
}
return $caps;
Expand Down

0 comments on commit 4f6dbe1

Please sign in to comment.