Make WordPress Core


Ignore:
Timestamp:
05/12/2010 08:45:18 PM (14 years ago)
Author:
nacin
Message:

Move post type object capabilities to a 'cap' object. Allow them to be initialized via the 'capabilities' key (an array) when registering support for the post type. Caps are now referred to by the name of the cap as if it was a post, i.e. ->cap->edit_post. see #13358.

File:
1 edited

Legend:

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

    r14580 r14585  
    4747    $ptype = get_post_type_object( $post_data['post_type'] );
    4848    if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) {
    49         if ( !current_user_can( $ptype->edit_others_cap ) ) {
     49        if ( !current_user_can( $ptype->cap->edit_other_posts ) ) {
    5050            if ( 'page' == $post_data['post_type'] ) {
    5151                return new WP_Error( 'edit_others_pages', $update ?
     
    8282    // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
    8383    // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
    84     if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->publish_cap )) )
     84    if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) )
    8585        if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) )
    8686            $post_data['post_status'] = 'pending';
     
    139139
    140140    $ptype = get_post_type_object($post_data['post_type']);
    141     if ( !current_user_can( $ptype->edit_cap, $post_ID ) ) {
     141    if ( !current_user_can( $ptype->cap->edit_post, $post_ID ) ) {
    142142        if ( 'page' == $post_data['post_type'] )
    143143            wp_die( __('You are not allowed to edit this page.' ));
     
    238238        $ptype = get_post_type_object('post');
    239239
    240     if ( !current_user_can( $ptype->edit_type_cap ) ) {
     240    if ( !current_user_can( $ptype->cap->edit_posts ) ) {
    241241        if ( 'page' == $ptype->name )
    242242            wp_die( __('You are not allowed to edit pages.'));
     
    495495        $ptype = get_post_type_object('post');
    496496
    497     if ( !current_user_can( $ptype->edit_type_cap ) ) {
     497    if ( !current_user_can( $ptype->cap->edit_posts ) ) {
    498498        if ( 'page' == $ptype->name )
    499499            return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
Note: See TracChangeset for help on using the changeset viewer.