WordPress.org

Make WordPress Core

Changeset 13841


Ignore:
Timestamp:
03/27/10 06:40:59 (5 years ago)
Author:
dd32
Message:

Use $ptype_obj->edit_type_cap instead of 'edit_posts' for custom post_type menu's & edit.php access. Allows for a user to have the capability to edit a post_type irrespective of their Posts access. Props rovo89. Fixes #12691

Location:
trunk/wp-admin
Files:
2 edited

Legend:

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

    r13770 r13841  
    99/** WordPress Administration Bootstrap */ 
    1010require_once('admin.php'); 
    11  
    12 if ( !current_user_can('edit_posts') ) 
    13     wp_die(__('Cheatin’ uh?')); 
    14  
    15 // Back-compat for viewing comments of an entry 
    16 if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) { 
    17     wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) ); 
    18     exit; 
    19 } else { 
    20     unset( $_redirect ); 
    21 } 
    2211 
    2312if ( !isset($_GET['post_type']) ) 
     
    3019 
    3120$post_type_object = get_post_type_object($post_type); 
     21 
     22if ( !current_user_can($post_type_object->edit_type_cap) ) 
     23    wp_die(__('Cheatin’ uh?')); 
     24 
     25// Back-compat for viewing comments of an entry 
     26if ( $_redirect = intval( max( @$_GET['p'], @$_GET['attachment_id'], @$_GET['page_id'] ) ) ) { 
     27    wp_redirect( admin_url('edit-comments.php?p=' . $_redirect ) ); 
     28    exit; 
     29} else { 
     30    unset( $_redirect ); 
     31} 
    3232 
    3333if ( 'post' != $post_type ) { 
  • trunk/wp-admin/menu.php

    r13783 r13841  
    119119 
    120120    $menu[$_wp_last_object_menu] = array(esc_attr($ptype_obj->label), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-posts', 'menu-' . sanitize_html_class($ptype), 'div'); 
    121     $submenu["edit.php?post_type=$ptype"][5]  = array( __('Edit'), 'edit_posts',  "edit.php?post_type=$ptype"); 
     121    $submenu["edit.php?post_type=$ptype"][5]  = array( __('Edit'), $ptype_obj->edit_type_cap,  "edit.php?post_type=$ptype"); 
    122122    /* translators: add new custom post type */ 
    123     $submenu["edit.php?post_type=$ptype"][10]  = array( _x('Add New', 'post'), 'edit_posts', "post-new.php?post_type=$ptype" ); 
     123    $submenu["edit.php?post_type=$ptype"][10]  = array( _x('Add New', 'post'), $ptype_obj->edit_type_cap, "post-new.php?post_type=$ptype" ); 
    124124 
    125125    $i = 15; 
Note: See TracChangeset for help on using the changeset viewer.