Ticket #2257: edit_pages_fix.diff

File edit_pages_fix.diff, 4.5 KB (added by markjaquith, 6 years ago)

Fix for edit_pages cap

  • inline-uploading.php

     
    22 
    33require_once('admin.php'); 
    44 
    5 if (!current_user_can('edit_posts')) 
     5if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) 
    66        die(__('You do not have permission to edit posts.')); 
    77 
    88$wpvarstoreset = array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'attachment'); 
  • menu.php

     
    55// The minimum level the user needs to access the item: between 0 and 10 
    66// The URL of the item's file 
    77$menu[0] = array(__('Dashboard'), 'read', 'index.php'); 
    8 $menu[5] = array(__('Write'), 'edit_posts', 'post.php'); 
    9 $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php'); 
     8if ( current_user_can('edit_posts') ) { 
     9        $menu[5] = array(__('Write'), 'edit_posts', 'post.php'); 
     10        $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php'); 
     11} else { 
     12        $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php'); 
     13        $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php'); 
     14} 
    1015$menu[20] = array(__('Links'), 'manage_links', 'link-manager.php'); 
    1116$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php'); 
    1217$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); 
     
    1722$menu[40] = array(__('Options'), 'manage_options', 'options-general.php'); 
    1823$menu[45] = array(__('Import'), 'import', 'import.php'); 
    1924 
    20 $submenu['post.php'][5] = array(__('Write Post'), 'edit_posts', 'post.php'); 
    21 $submenu['post.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php'); 
     25if ( current_user_can('edit_posts') ) { 
     26        $submenu['post.php'][5] = array(__('Write Post'), 'edit_posts', 'post.php'); 
     27        $submenu['post.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php'); 
     28        $submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php'); 
     29        $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php'); 
     30} else { 
     31        $submenu['page-new.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php'); 
     32        $submenu['edit-pages.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php'); 
     33} 
    2234 
    23 $submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php'); 
    24 $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php'); 
    2535$submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php'); 
    2636$submenu['edit.php'][20] = array(__('Comments'), 'edit_posts', 'edit-comments.php'); 
    2737$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'"); 
  • post.php

     
    3030 
    3131switch($action) { 
    3232case 'post': 
     33        if ( !current_user_can('edit_posts') && current_user_can('edit_pages') ) 
     34                $parent_file = 'page-new.php'; 
    3335 
    3436        $post_ID = write_post(); 
    3537 
     
    6163        break; 
    6264 
    6365case 'edit': 
     66        if ( !current_user_can('edit_posts') ) 
     67                $parent_file = 'page-new.php'; 
    6468        $title = __('Edit'); 
    6569 
    6670        require_once('admin-header.php'); 
  • admin-functions.php

     
    44function write_post() { 
    55        global $user_ID; 
    66 
    7         if (!current_user_can('edit_posts')) 
     7        if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) 
    88                die(__('You are not allowed to create posts or drafts on this blog.')); 
    99 
    1010        // Rename. 
  • page-new.php

     
    11<?php 
    22require_once('admin.php'); 
    33$title = __('New Page'); 
    4 $parent_file = 'post.php'; 
     4if ( current_user_can('edit_posts') ) 
     5        $parent_file = 'post.php'; 
     6else 
     7        $parent_file = 'page-new.php'; 
    58$editing = true; 
    69require_once('admin-header.php'); 
    710?> 
  • edit-pages.php

     
    11<?php 
    22require_once('admin.php'); 
    33$title = __('Pages'); 
    4 $parent_file = 'edit.php'; 
     4if ( current_user_can('edit_posts') ) 
     5        $parent_file = 'edit.php'; 
     6else 
     7        $parent_file = 'edit-pages.php'; 
    58require_once('admin-header.php'); 
    69?> 
    710