WordPress.org

Make WordPress Core

Ticket #37826: 37826.4.diff

File 37826.4.diff, 3.1 KB (added by donmhico, 2 years ago)

Refreshed the patch.

  • src/wp-admin/comment.php

    diff --git src/wp-admin/comment.php src/wp-admin/comment.php
    index 9980bd181b..3b1e74d2ea 100644
    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 operate on 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 src/wp-admin/includes/class-wp-list-table.php src/wp-admin/includes/class-wp-list-table.php
    index 6923da55bc..f6e2ce8c14 100644
    class WP_List_Table { 
    666666                $pending_phrase       = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );
    667667
    668668                // No comments at all.
    669                 if ( ! $approved_comments && ! $pending_comments ) {
    670                         printf(
    671                                 '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
    672                                 __( 'No comments' )
     669        if (! $approved_comments && ! $pending_comments) {
     670            printf(
     671                '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
     672                __('No comments')
     673            );
     674                }
     675                /**
     676                 * Remove link in the comment bubble for 'trash' post.
     677                 *
     678                 * @since 5.3.0
     679                 *
     680                 * @link https://core.trac.wordpress.org/ticket/37826
     681                 */
     682                elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) {
     683                        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>',
     684                                $approved_comments_number,
     685                                $pending_comments ? $approved_phrase : $approved_only_phrase
    673686                        );
    674                         // Approved comments have different display depending on some conditions.
    675                 } elseif ( $approved_comments ) {
     687                }
     688                // Approved comments have different display depending on some conditions.
     689                elseif ( $approved_comments ) {
    676690                        printf(
    677691                                '<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>',
    678692                                esc_url(