WordPress.org

Make WordPress Core

Ticket #12691: 12691.diff

File 12691.diff, 2.2 KB (added by rovo89, 4 years ago)
  • wp-admin/menu.php

     
    118118        $ptype_obj = get_post_type_object($ptype); 
    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; 
    126126        foreach ( $wp_taxonomies as $tax ) { 
  • wp-admin/edit.php

     
    99/** WordPress Administration Bootstrap */ 
    1010require_once('admin.php'); 
    1111 
    12 if ( !current_user_can('edit_posts') ) 
     12if ( !isset($_GET['post_type']) ) 
     13        $post_type = 'post'; 
     14elseif ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) ) 
     15        $post_type = $_GET['post_type']; 
     16else 
     17        wp_die( __('Invalid post type') ); 
     18$_GET['post_type'] = $post_type; 
     19 
     20$post_type_object = get_post_type_object($post_type); 
     21 
     22if ( !current_user_can($post_type_object->edit_type_cap) ) 
    1323        wp_die(__('Cheatin’ uh?')); 
    1424 
    1525// Back-compat for viewing comments of an entry 
     
    2030        unset( $_redirect ); 
    2131} 
    2232 
    23 if ( !isset($_GET['post_type']) ) 
    24         $post_type = 'post'; 
    25 elseif ( in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) ) 
    26         $post_type = $_GET['post_type']; 
    27 else 
    28         wp_die( __('Invalid post type') ); 
    29 $_GET['post_type'] = $post_type; 
    30  
    31 $post_type_object = get_post_type_object($post_type); 
    32  
    3333if ( 'post' != $post_type ) { 
    3434        $parent_file = "edit.php?post_type=$post_type"; 
    3535        $submenu_file = "edit.php?post_type=$post_type";