Make WordPress Core

Ticket #37826: 37826.5.diff

File 37826.5.diff, 2.8 KB (added by stevenlinx, 5 years ago)

update for v5.4

  • src/wp-admin/comment.php

    diff --git a/src/wp-admin/comment.php b/src/wp-admin/comment.php
    index ee7a514be4..bfdccd6adb 100644
    a b if ( isset( $_GET['dt'] ) ) { 
    3636        }
    3737}
    3838
     39/**
     40* Prevent actions in a comment associated with `Trashed` post.
     41*
     42* @since 5.3.0
     43*
     44* @link https://core.trac.wordpress.org/ticket/37826
     45*/
     46$comment_id = absint( $_GET['c'] );
     47$comment = get_comment( $comment_id );
     48
     49if ( 'trash' === get_post_status( $comment->comment_post_ID ) ) {
     50        wp_die( __( 'You can’t edit this comment because the associated post is in the Trash. Please restore the post first, then try again.' ) );
     51}
     52
    3953switch ( $action ) {
    4054
    4155        case 'editcomment':
    switch ( $action ) { 
    6074                wp_enqueue_script( 'comment' );
    6175                require_once( ABSPATH . 'wp-admin/admin-header.php' );
    6276
    63                 $comment_id = absint( $_GET['c'] );
    64 
    65                 $comment = get_comment( $comment_id );
    6677                if ( ! $comment ) {
    6778                        comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'javascript:history.go(-1)' ) );
    6879                }
    switch ( $action ) { 
    8798        case 'spam':
    8899                $title = __( 'Moderate Comment' );
    89100
    90                 $comment_id = absint( $_GET['c'] );
    91 
    92                 $comment = get_comment( $comment_id );
    93101                if ( ! $comment ) {
    94102                        wp_redirect( admin_url( 'edit-comments.php?error=1' ) );
    95103                        die();
  • src/wp-admin/includes/class-wp-list-table.php

    diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php
    index 3faaec691d..7c44e56e38 100644
    a b class WP_List_Table { 
    680680                );
    681681
    682682                // No comments at all.
    683                 if ( ! $approved_comments && ! $pending_comments ) {
     683                if (! $approved_comments && ! $pending_comments) {
    684684                        printf(
    685685                                '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
    686                                 __( 'No comments' )
     686                                __('No comments')
    687687                        );
    688                         // Approved comments have different display depending on some conditions.
     688                /**
     689                * Remove link in the comment bubble for 'trash' post.
     690                *
     691                * @since 5.4.0
     692                *
     693                * @link https://core.trac.wordpress.org/ticket/37826
     694                */
     695                } elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) {
     696                        printf( '<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>',
     697                                $approved_comments_number,
     698                                $pending_comments ? $approved_phrase : $approved_only_phrase
     699                        );
     700                // Approved comments have different display depending on some conditions.
    689701                } elseif ( $approved_comments ) {
    690702                        printf(
    691703                                '<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>',