Make WordPress Core


Ignore:
Timestamp:
06/15/2020 11:04:27 PM (5 years ago)
Author:
whyisjake
Message:

Comments: Don't display edit links to trashed post comments.

If a post is in the trash, the comments bubble won't link to the comments list.

Fixes: #37826.
Props: swissspidy, helen, FolioVision, DrewAPicture, stevenlinx, donmhico, birgire, garrett-eclipse, andraganescu, johnbillion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/comment.php

    r47785 r48050  
    3535        $action = 'trash';
    3636    }
     37}
     38
     39// Prevent actions on a comment associated with a trashed post.
     40$comment_id = absint( $_GET['c'] );
     41$comment = get_comment( $comment_id );
     42
     43if ( 'trash' === get_post_status( $comment->comment_post_ID ) ) {
     44    wp_die(
     45        __( 'You can’t edit this comment because the associated post is in the Trash. Please restore the post first, then try again.' )
     46    );
    3747}
    3848
     
    6171        require_once ABSPATH . 'wp-admin/admin-header.php';
    6272
    63         $comment_id = absint( $_GET['c'] );
    64 
    65         $comment = get_comment( $comment_id );
    6673        if ( ! $comment ) {
    6774            comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'javascript:history.go(-1)' ) );
     
    8895        $title = __( 'Moderate Comment' );
    8996
    90         $comment_id = absint( $_GET['c'] );
    91 
    92         $comment = get_comment( $comment_id );
    9397        if ( ! $comment ) {
    9498            wp_redirect( admin_url( 'edit-comments.php?error=1' ) );
Note: See TracChangeset for help on using the changeset viewer.