WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/04/2010 04:58:43 PM (10 years ago)
Author:
ryan
Message:

More custom post type support. Props scribu. see #9674

File:
1 edited

Legend:

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

    r12585 r12597  
    780780        //echo "post ID: {$args[0]}<br />";
    781781        $post = get_post( $args[0] );
    782         if ( 'page' == $post->post_type ) {
    783             $args = array_merge( array( 'delete_page', $user_id ), $args );
     782        $post_type = get_post_type_object( $post->post_type );
     783        if ( $post_type && 'post' != $post_type->capability_type ) {
     784            $args = array_merge( array( 'delete_' . $post_type->capability_type, $user_id ), $args );
    784785            return call_user_func_array( 'map_meta_cap', $args );
    785786        }
     
    856857        //echo "post ID: {$args[0]}<br />";
    857858        $post = get_post( $args[0] );
    858         if ( 'page' == $post->post_type ) {
    859             $args = array_merge( array( 'edit_page', $user_id ), $args );
     859        $post_type = get_post_type_object( $post->post_type );
     860        if ( $post_type && 'post' != $post_type->capability_type ) {
     861            $args = array_merge( array( 'edit_' . $post_type->capability_type, $user_id ), $args );
    860862            return call_user_func_array( 'map_meta_cap', $args );
    861863        }
     
    914916    case 'read_post':
    915917        $post = get_post( $args[0] );
    916         if ( 'page' == $post->post_type ) {
    917             $args = array_merge( array( 'read_page', $user_id ), $args );
     918        $post_type = get_post_type_object( $post->post_type );
     919        if ( $post_type && 'post' != $post_type->capability_type ) {
     920            $args = array_merge( array( 'read_' . $post_type->capability_type, $user_id ), $args );
    918921            return call_user_func_array( 'map_meta_cap', $args );
    919922        }
Note: See TracChangeset for help on using the changeset viewer.