Make WordPress Core


Ignore:
Timestamp:
04/06/2023 04:42:40 PM (22 months ago)
Author:
SergeyBiryukov
Message:

I18N: Correct translator comments placement in wp-admin/edit-comments.php.

This ensures that the translator comments are displayed for the strings they refer to, e.g. to explain placeholders in comment action messages, and are not displayed for unrelated strings, e.g. "Undo", to avoid confusion.

Includes minor code layout fixes and wrapping a few long lines for better readability.

Follow-up to [35549], [45926], [45932].

Props afercia.
See #57839.

File:
1 edited

Legend:

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

    r55414 r55630  
    3333        $comment_status = wp_unslash( $_REQUEST['comment_status'] );
    3434        $delete_time    = wp_unslash( $_REQUEST['pagegen_timestamp'] );
    35         $comment_ids    = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s AND %s > comment_date_gmt", $comment_status, $delete_time ) );
     35        $comment_ids    = $wpdb->get_col(
     36            $wpdb->prepare(
     37                "SELECT comment_ID FROM $wpdb->comments
     38                WHERE comment_approved = %s AND %s > comment_date_gmt",
     39                $comment_status,
     40                $delete_time
     41            )
     42        );
    3643        $doaction       = 'delete';
    3744    } elseif ( isset( $_REQUEST['delete_comments'] ) ) {
     
    5360    $deleted    = 0;
    5461
    55     $redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() );
     62    $redirect_to = remove_query_arg(
     63        array(
     64            'trashed',
     65            'untrashed',
     66            'deleted',
     67            'spammed',
     68            'unspammed',
     69            'approved',
     70            'unapproved',
     71            'ids',
     72        ),
     73        wp_get_referer()
     74    );
    5675    $redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to );
    5776
     
    287306}
    288307
    289 if ( isset( $_REQUEST['approved'] ) || isset( $_REQUEST['deleted'] ) || isset( $_REQUEST['trashed'] ) || isset( $_REQUEST['untrashed'] ) || isset( $_REQUEST['spammed'] ) || isset( $_REQUEST['unspammed'] ) || isset( $_REQUEST['same'] ) ) {
     308if ( isset( $_REQUEST['approved'] )
     309    || isset( $_REQUEST['deleted'] )
     310    || isset( $_REQUEST['trashed'] )
     311    || isset( $_REQUEST['untrashed'] )
     312    || isset( $_REQUEST['spammed'] )
     313    || isset( $_REQUEST['unspammed'] )
     314    || isset( $_REQUEST['same'] )
     315) {
    290316    $approved  = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0;
    291317    $deleted   = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
     
    298324    if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) {
    299325        if ( $approved > 0 ) {
    300             /* translators: %s: Number of comments. */
    301             $messages[] = sprintf( _n( '%s comment approved.', '%s comments approved.', $approved ), $approved );
     326            $messages[] = sprintf(
     327                /* translators: %s: Number of comments. */
     328                _n( '%s comment approved.', '%s comments approved.', $approved ),
     329                $approved
     330            );
    302331        }
    303332
    304333        if ( $spammed > 0 ) {
    305334            $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0;
    306             /* translators: %s: Number of comments. */
    307             $messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", 'bulk-comments' ) ) . '">' . __( 'Undo' ) . '</a><br />';
     335
     336            $messages[] = sprintf(
     337                /* translators: %s: Number of comments. */
     338                _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ),
     339                $spammed
     340            ) . sprintf(
     341                ' <a href="%1$s">%2$s</a><br />',
     342                esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", 'bulk-comments' ) ),
     343                __( 'Undo' )
     344            );
    308345        }
    309346
    310347        if ( $unspammed > 0 ) {
    311             /* translators: %s: Number of comments. */
    312             $messages[] = sprintf( _n( '%s comment restored from the spam.', '%s comments restored from the spam.', $unspammed ), $unspammed );
     348            $messages[] = sprintf(
     349                /* translators: %s: Number of comments. */
     350                _n( '%s comment restored from the spam.', '%s comments restored from the spam.', $unspammed ),
     351                $unspammed
     352            );
    313353        }
    314354
    315355        if ( $trashed > 0 ) {
    316356            $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0;
    317             /* translators: %s: Number of comments. */
    318             $messages[] = sprintf( _n( '%s comment moved to the Trash.', '%s comments moved to the Trash.', $trashed ), $trashed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", 'bulk-comments' ) ) . '">' . __( 'Undo' ) . '</a><br />';
     357
     358            $messages[] = sprintf(
     359                /* translators: %s: Number of comments. */
     360                _n( '%s comment moved to the Trash.', '%s comments moved to the Trash.', $trashed ),
     361                $trashed
     362            ) . sprintf(
     363                ' <a href="%1$s">%2$s</a><br />',
     364                esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", 'bulk-comments' ) ),
     365                __( 'Undo' )
     366            );
    319367        }
    320368
    321369        if ( $untrashed > 0 ) {
    322             /* translators: %s: Number of comments. */
    323             $messages[] = sprintf( _n( '%s comment restored from the Trash.', '%s comments restored from the Trash.', $untrashed ), $untrashed );
     370            $messages[] = sprintf(
     371                /* translators: %s: Number of comments. */
     372                _n( '%s comment restored from the Trash.', '%s comments restored from the Trash.', $untrashed ),
     373                $untrashed
     374            );
    324375        }
    325376
    326377        if ( $deleted > 0 ) {
    327             /* translators: %s: Number of comments. */
    328             $messages[] = sprintf( _n( '%s comment permanently deleted.', '%s comments permanently deleted.', $deleted ), $deleted );
     378            $messages[] = sprintf(
     379                /* translators: %s: Number of comments. */
     380                _n( '%s comment permanently deleted.', '%s comments permanently deleted.', $deleted ),
     381                $deleted
     382            );
    329383        }
    330384
     
    334388                switch ( $comment->comment_approved ) {
    335389                    case '1':
    336                         $messages[] = __( 'This comment is already approved.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
     390                        $messages[] = __( 'This comment is already approved.' ) . sprintf(
     391                            ' <a href="%1$s">%2$s</a>',
     392                            esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ),
     393                            __( 'Edit comment' )
     394                        );
    337395                        break;
    338396                    case 'trash':
    339                         $messages[] = __( 'This comment is already in the Trash.' ) . ' <a href="' . esc_url( admin_url( 'edit-comments.php?comment_status=trash' ) ) . '"> ' . __( 'View Trash' ) . '</a>';
     397                        $messages[] = __( 'This comment is already in the Trash.' ) . sprintf(
     398                            ' <a href="%1$s">%2$s</a>',
     399                            esc_url( admin_url( 'edit-comments.php?comment_status=trash' ) ),
     400                            __( 'View Trash' )
     401                        );
    340402                        break;
    341403                    case 'spam':
    342                         $messages[] = __( 'This comment is already marked as spam.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
     404                        $messages[] = __( 'This comment is already marked as spam.' ) . sprintf(
     405                            ' <a href="%1$s">%2$s</a>',
     406                            esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ),
     407                            __( 'Edit comment' )
     408                        );
    343409                        break;
    344410                }
     
    346412        }
    347413
    348         echo '<div id="moderated" class="updated notice is-dismissible"><p>' . implode( "<br />\n", $messages ) . '</p></div>';
     414        printf(
     415            '<div id="moderated" class="updated notice is-dismissible"><p>%s</p></div>',
     416            implode( "<br />\n", $messages )
     417        );
    349418    }
    350419}
Note: See TracChangeset for help on using the changeset viewer.