Make WordPress Core


Ignore:
Timestamp:
02/02/2010 05:37:03 PM (15 years ago)
Author:
ryan
Message:

Allow customizing capabilities for custom post types. Always check caps against those in the post type object instead of contructing them manually. see #9674

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit.php

    r12819 r12927  
    2828
    2929$post_type_object = get_post_type_object($post_type);
    30 $post_type_cap = $post_type_object->capability_type;
    3130
    3231if ( 'post' != $post_type ) {
     
    7372            $trashed = 0;
    7473            foreach( (array) $post_ids as $post_id ) {
    75                 if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
     74                if ( !current_user_can($post_type_object->delete_cap, $post_id) )
    7675                    wp_die( __('You are not allowed to move this item to the trash.') );
    7776
     
    8685            $untrashed = 0;
    8786            foreach( (array) $post_ids as $post_id ) {
    88                 if ( !current_user_can('delete_' . $post_type_cap, $post_id) )
     87                if ( !current_user_can($post_type_object->delete_cap, $post_id) )
    8988                    wp_die( __('You are not allowed to restore this item from the trash.') );
    9089
     
    101100                $post_del = & get_post($post_id);
    102101
    103                 if ( !current_user_can('delete_' .  $post_type_cap, $post_id) )
     102                if ( !current_user_can($post_type_object->delete_cap, $post_id) )
    104103                    wp_die( __('You are not allowed to delete this item.') );
    105104
     
    142141
    143142$user_posts = false;
    144 if ( !current_user_can('edit_others_' . $post_type_cap . 's') ) {
     143if ( !current_user_can($post_type_object->edit_others_cap) ) {
    145144    $user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status != 'trash' AND post_author = %d", $post_type, $current_user->ID) );
    146145    $user_posts = true;
     
    342341<?php }
    343342
    344 if ( $is_trash && current_user_can('edit_others_' . $post_type_cap .'s') ) { ?>
     343if ( $is_trash && current_user_can($post_type_object->edit_others_cap) ) { ?>
    345344<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    346345<?php } ?>
     
    389388</select>
    390389<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
    391 <?php if ( $is_trash && current_user_can('edit_others_' . $post_type_cap . 's') ) { ?>
     390<?php if ( $is_trash && current_user_can($post_type_object->edit_others_cap) ) { ?>
    392391<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    393392<?php } ?>
Note: See TracChangeset for help on using the changeset viewer.