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/edit.php

    r14571 r14585  
    2020$post_type_object = get_post_type_object($post_type);
    2121
    22 if ( !current_user_can($post_type_object->edit_type_cap) )
     22if ( !current_user_can($post_type_object->cap->edit_posts) )
    2323    wp_die(__('Cheatin’ uh?'));
    2424
     
    7474            $trashed = 0;
    7575            foreach( (array) $post_ids as $post_id ) {
    76                 if ( !current_user_can($post_type_object->delete_cap, $post_id) )
     76                if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    7777                    wp_die( __('You are not allowed to move this item to the Trash.') );
    7878
     
    8787            $untrashed = 0;
    8888            foreach( (array) $post_ids as $post_id ) {
    89                 if ( !current_user_can($post_type_object->delete_cap, $post_id) )
     89                if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    9090                    wp_die( __('You are not allowed to restore this item from the Trash.') );
    9191
     
    102102                $post_del = & get_post($post_id);
    103103
    104                 if ( !current_user_can($post_type_object->delete_cap, $post_id) )
     104                if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
    105105                    wp_die( __('You are not allowed to delete this item.') );
    106106
     
    141141
    142142$user_posts = false;
    143 if ( !current_user_can($post_type_object->edit_others_cap) ) {
     143if ( !current_user_can($post_type_object->cap->edit_other_posts) ) {
    144144    $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status NOT IN ('trash', 'auto-draft') AND post_author = %d", $post_type, $current_user->ID) );
    145145    $user_posts = true;
     
    346346<?php }
    347347
    348 if ( $is_trash && current_user_can($post_type_object->edit_others_cap) ) { ?>
     348if ( $is_trash && current_user_can($post_type_object->cap->edit_other_posts) ) { ?>
    349349<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    350350<?php } ?>
     
    397397</select>
    398398<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
    399 <?php if ( $is_trash && current_user_can($post_type_object->edit_others_cap) ) { ?>
     399<?php if ( $is_trash && current_user_can($post_type_object->cap->edit_other_posts) ) { ?>
    400400<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    401401<?php } ?>
Note: See TracChangeset for help on using the changeset viewer.