From f3e8c615c82b064669e9a69243ef73ac7110371b Mon Sep 17 00:00:00 2001 From: cbravobernal Date: Tue, 15 Oct 2024 14:13:19 +0000 Subject: [PATCH] Block Bindings: Fix panel not appearing in custom post types. There is a bug where the attributes panel is not shown in custom post types. This is caused because each post type can define a capability_type, which by default is post, so the logic to map the capabilities wasn't correct and it was returning false. Props santosguillamot, cbravobernal. Fixes #62226. Built from https://develop.svn.wordpress.org/trunk@59239 git-svn-id: http://core.svn.wordpress.org/trunk@58631 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/capabilities.php | 9 +++++++-- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 42e07a471d..d6c340c95e 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -825,8 +825,13 @@ function map_meta_cap( $cap, $user_id, ...$args ) { $caps[] = 'do_not_allow'; break; } - - $caps = map_meta_cap( "edit_{$object_subtype}", $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 ); break; default: // Handle meta capabilities for custom post types. diff --git a/wp-includes/version.php b/wp-includes/version.php index 984bd55268..46cc56a966 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-beta3-59238'; +$wp_version = '6.7-beta3-59239'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.