Make WordPress Core

Changeset 15892


Ignore:
Timestamp:
10/21/2010 03:05:10 PM (14 years ago)
Author:
nacin
Message:

Clean up get_post_type_capabilities. Don't bother with new capabilities for edit_others_posts and delete_others_posts if the post type does not support authors.

File:
1 edited

Legend:

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

    r15890 r15892  
    990990 */
    991991function get_post_type_capabilities( $args ) {
    992     global $_post_type_meta_capabilities;
    993 
    994992    $default_capabilities = array(
    995993        // Meta capabilities are generally mapped to primitive capabilities depending on the context
     
    10041002        'read_private_posts' => 'read_private_' . $args->capability_type . 's',
    10051003    );
     1004
    10061005    // Primitive capabilities that are used within map_meta_cap():
    10071006    if ( $args->map_meta_cap ) {
     
    10101009            'delete_posts'           => 'delete_'           . $args->capability_type . 's',
    10111010            'delete_private_posts'   => 'delete_private_'   . $args->capability_type . 's',
    1012             'delete_published_posts' => 'delete_published_' . $args->capability_type . 's', 
     1011            'delete_published_posts' => 'delete_published_' . $args->capability_type . 's',
    10131012            'delete_others_posts'    => 'delete_others_'    . $args->capability_type . 's',
    10141013            'edit_private_posts'     => 'edit_private_'     . $args->capability_type . 's',
     
    10171016        $default_capabilities = array_merge( $default_capabilities, $default_capabilities_for_mapping );
    10181017    }
     1018
     1019    if ( ! post_type_supports( $args->name, 'author' ) ) {
     1020        // While these may be checked in core, users/roles shouldn't need to be granted these.
     1021        $default_capabilities['edit_others_posts']   = $default_capabilities['edit_posts'];
     1022        $default_capabilities['delete_others_posts'] = $default_capabilities['delete_posts'];
     1023    }
     1024
    10191025    $capabilities = array_merge( $default_capabilities, $args->capabilities );
     1026
     1027    // Remember meta capabilities for future reference.
    10201028    if ( $args->map_meta_cap )
    10211029        _post_type_meta_capabilities( $capabilities );
     1030
    10221031    return (object) $capabilities;
    10231032}
Note: See TracChangeset for help on using the changeset viewer.