WordPress.org

Make WordPress Core

Ticket #12104: 12104.2.diff

File 12104.2.diff, 2.4 KB (added by Kau-Boy, 3 years ago)
  • wp-admin/edit-comments.php

    diff --git wp-admin/edit-comments.php wp-admin/edit-comments.php
    index f5448ab..8b5fbaa 100644
     
    88
    99/** WordPress Administration Bootstrap */
    1010require_once( dirname( __FILE__ ) . '/admin.php' );
    11 if ( ! current_user_can( 'edit_posts' ) ) {
     11if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_comments' ) && ! current_user_can( 'moderate_comments' ) ) {
    1212        wp_die(
    1313                '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
    1414                '<p>' . __( 'You are not allowed to edit comments.' ) . '</p>',
  • wp-admin/menu.php

    diff --git wp-admin/menu.php wp-admin/menu.php
    index f85ebd3..e69e5a9 100644
    $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-to 
    6767
    6868// $menu[20] = Pages
    6969
    70 // Avoid the comment count query for users who cannot edit_posts.
    71 if ( current_user_can( 'edit_posts' ) ) {
     70// Avoid the comment count query for users who cannot moderate_comments.
     71if ( current_user_can( 'moderate_comments' ) ) {
    7272        $awaiting_mod = wp_count_comments();
    7373        $awaiting_mod = $awaiting_mod->moderated;
    74         $menu[25] = array(
    75                 sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count">' . number_format_i18n( $awaiting_mod ) . '</span></span>' ),
    76                 'edit_posts',
    77                 'edit-comments.php',
    78                 '',
    79                 'menu-top menu-icon-comments',
    80                 'menu-comments',
    81                 'dashicons-admin-comments',
    82         );
    83         unset( $awaiting_mod );
     74        $label = sprintf( __( 'Comments %s' ), '<span class="awaiting-mod count-' . absint( $awaiting_mod ) . '"><span class="pending-count">' . number_format_i18n( $awaiting_mod ) . '</span></span>' );
     75} else {
     76        $label = __( 'Comments' );
     77}
     78
     79if ( current_user_can( 'moderate_comments' ) ) {
     80        $cap = 'moderate_comments';
     81} elseif ( current_user_can( 'edit_comments' ) ) {
     82        $cap = 'edit_comments';
     83} else {
     84        $cap = 'edit_posts';
    8485}
    8586
    86 $submenu[ 'edit-comments.php' ][0] = array( __('All Comments'), 'edit_posts', 'edit-comments.php' );
     87$menu[25] = array(
     88        $label,
     89        $cap,
     90        'edit-comments.php',
     91        '',
     92        'menu-top menu-icon-comments',
     93        'menu-comments',
     94        'dashicons-admin-comments',
     95);
     96        $submenu[ 'edit-comments.php' ][0] = array( __('All Comments'), $cap, 'edit-comments.php' );
     97unset( $awaiting_mod, $label, $cap );
     98
    8799
    88100$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group
    89101