Make WordPress Core

Ticket #17909: admin-ajax.diff

File admin-ajax.diff, 1.6 KB (added by ejdanderson, 15 years ago)

Replaces edit_post capability with edit_comment. I believe the 'edit_post' capability is appropriate in the 'get-comments' and 'replyto-comment' cases.

  • admin-ajax.php

     
    321321case 'delete-comment' : // On success, die with time() instead of 1
    322322        if ( !$comment = get_comment( $id ) )
    323323                die( (string) time() );
    324         if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) )
     324        if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
    325325                die('-1');
    326326
    327327        check_ajax_referer( "delete-comment_$id" );
     
    457457                $x->send();
    458458        }
    459459
    460         if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) && !current_user_can( 'moderate_comments' ) )
     460        if ( !current_user_can( 'edit_comment', $comment->comment_ID ) && !current_user_can( 'moderate_comments' ) )
    461461                die('-1');
    462462
    463463        $current = wp_get_comment_status( $comment->comment_ID );
     
    612612        $x = new WP_Ajax_Response();
    613613        ob_start();
    614614        foreach ( $wp_list_table->items as $comment ) {
     615                if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
     616                        continue;
    615617                get_comment( $comment );
    616618                $wp_list_table->single_row( $comment );
    617619        }
     
    714716
    715717        set_current_screen( 'edit-comments' );
    716718
    717         $comment_post_ID = (int) $_POST['comment_post_ID'];
    718         if ( ! current_user_can( 'edit_post', $comment_post_ID ) )
     719        $comment_id = (int) $_POST['comment_ID'];
     720        if ( ! current_user_can( 'edit_comment', $comment_id ) )
    719721                die('-1');
    720722
    721723        if ( '' == $_POST['content'] )
    722724                die( __('Error: please type a comment.') );
    723725
    724         $comment_id = (int) $_POST['comment_ID'];
    725726        $_POST['comment_status'] = $_POST['status'];
    726727        edit_comment();
    727728