Make WordPress Core

Ticket #14520: edit_comment.diff

File edit_comment.diff, 2.8 KB (added by scribu, 13 years ago)
  • wp-includes/link-template.php

     
    874874 * @return string
    875875 */
    876876function get_edit_comment_link( $comment_id = 0 ) {
    877         $comment = &get_comment( $comment_id );
    878         $post = &get_post( $comment->comment_post_ID );
     877        if ( !current_user_can('edit_comment', $comment_id) )
     878                return;
    879879
    880         if ( $post->post_type == 'page' ) {
    881                 if ( !current_user_can( 'edit_page', $post->ID ) )
    882                         return;
    883         } else {
    884                 if ( !current_user_can( 'edit_post', $post->ID ) )
    885                         return;
    886         }
    887 
    888         $location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID;
     880        $location = admin_url('comment.php?action=editcomment&c=') . $comment_id;
    889881        return apply_filters( 'get_edit_comment_link', $location );
    890882}
    891883
     
    900892 * @return string|null HTML content, if $echo is set to false.
    901893 */
    902894function edit_comment_link( $link = null, $before = '', $after = '' ) {
    903         global $comment, $post;
     895        global $comment;
    904896
    905         if ( $post->post_type == 'page' ) {
    906                 if ( !current_user_can( 'edit_page', $post->ID ) )
    907                         return;
    908         } else {
    909                 if ( !current_user_can( 'edit_post', $post->ID ) )
    910                         return;
    911         }
     897        if ( !current_user_can('edit_comment', $comment->comment_ID) )
     898                return;
    912899
    913900        if ( null === $link )
    914901                $link = __('Edit This');
  • wp-includes/capabilities.php

     
    990990                else
    991991                        $caps[] = 'read_private_pages';
    992992                break;
     993        case 'edit_comment':
     994                $caps[] = 'edit_published_posts';
     995
     996                $comment = get_comment( $args[0] );
     997
     998                if ( $comment->user_id != $user_id )
     999                        $caps[] = 'moderate_comments';
     1000                break;
    9931001        case 'unfiltered_upload':
    9941002                if ( defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && ( !is_multisite() || is_super_admin( $user_id ) )  )
    9951003                        $caps[] = $cap;
  • wp-admin/comment.php

     
    6060        if ( !$comment = get_comment( $comment_id ) )
    6161                comment_footer_die( __('Oops, no comment with this ID.') . sprintf(' <a href="%s">'.__('Go back').'</a>!', 'javascript:history.go(-1)') );
    6262
    63         if ( !current_user_can('edit_post', $comment->comment_post_ID) )
    64                 comment_footer_die( __('You are not allowed to edit comments on this post.') );
     63        if ( !current_user_can('edit_comment', $comment_id) )
     64                comment_footer_die( __('You are not allowed to edit this comment.') );
    6565
    6666        if ( 'trash' == $comment->comment_approved )
    6767                comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') );