Make WordPress Core

Changeset 48050


Ignore:
Timestamp:
06/15/2020 11:04:27 PM (4 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.

Location:
trunk/src/wp-admin
Files:
3 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' ) );
  • trunk/src/wp-admin/css/list-tables.css

    r47879 r48050  
    7676}
    7777
    78 .column-response .post-com-count-approved:hover .comment-count-approved,
    79 .column-response .post-com-count-approved:focus .comment-count-approved,
    80 .column-comments .post-com-count-approved:hover .comment-count-approved,
    81 .column-comments .post-com-count-approved:focus .comment-count-approved {
     78.column-response a.post-com-count-approved:hover .comment-count-approved,
     79.column-response a.post-com-count-approved:focus .comment-count-approved,
     80.column-comments a.post-com-count-approved:hover .comment-count-approved,
     81.column-comments a.post-com-count-approved:focus .comment-count-approved {
    8282    background: #0073aa;
    8383}
    8484
    85 .column-response .post-com-count-approved:hover:after,
    86 .column-response .post-com-count-approved:focus:after,
    87 .column-comments .post-com-count-approved:hover:after,
    88 .column-comments .post-com-count-approved:focus:after {
     85.column-response a.post-com-count-approved:hover:after,
     86.column-response a.post-com-count-approved:focus:after,
     87.column-comments a.post-com-count-approved:hover:after,
     88.column-comments a.post-com-count-approved:focus:after {
    8989    border-top-color: #0073aa;
    9090}
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r47915 r48050  
    683683        );
    684684
    685         // No comments at all.
    686685        if ( ! $approved_comments && ! $pending_comments ) {
     686            // No comments at all.
    687687            printf(
    688688                '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
    689689                __( 'No comments' )
    690690            );
    691             // Approved comments have different display depending on some conditions.
     691        } elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) {
     692            // Don't link the comment bubble for a trashed post.
     693            printf(
     694                '<span class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
     695                $approved_comments_number,
     696                $pending_comments ? $approved_phrase : $approved_only_phrase
     697            );
    692698        } elseif ( $approved_comments ) {
     699            // Link the comment bubble to approved comments.
    693700            printf(
    694701                '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
     
    706713            );
    707714        } else {
     715            // Don't link the comment bubble when there are no approved comments.
    708716            printf(
    709717                '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
Note: See TracChangeset for help on using the changeset viewer.