Make WordPress Core

Changeset 59239


Ignore:
Timestamp:
10/15/2024 02:11:12 PM (2 years ago)
Author:
cbravobernal
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/capabilities.php

    r59198 r59239  
    826826                                break;
    827827                        }
    828 
    829                         $caps = map_meta_cap( "edit_{$object_subtype}", $user_id, $object_id );
     828                        $post_type_object = get_post_type_object( $object_subtype );
     829                        // Initialize empty array if it doesn't exist.
     830                        if ( ! isset( $post_type_object->capabilities ) ) {
     831                                $post_type_object->capabilities = array();
     832                        }
     833                        $post_type_capabilities = get_post_type_capabilities( $post_type_object );
     834                        $caps                   = map_meta_cap( $post_type_capabilities->edit_post, $user_id, $object_id );
    830835                        break;
    831836                default:
Note: See TracChangeset for help on using the changeset viewer.