Skip to content

Commit 5f8f378

Browse files
Coding Standards: Bring some consistency to setting up comment moderation links.
Follow-up to [7082], [7175], [9103], [10102], [11749], [12008], [12286], [32516]. Props kebbet. See #61607. git-svn-id: https://develop.svn.wordpress.org/trunk@58888 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 802e069 commit 5f8f378

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

src/wp-admin/includes/class-wp-comments-list-table.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -705,18 +705,18 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
705705

706706
$output = '';
707707

708-
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
709-
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
708+
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'approve-comment_' . $comment->comment_ID ) );
709+
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'delete-comment_' . $comment->comment_ID ) );
710710

711-
$url = "comment.php?c=$comment->comment_ID";
711+
$action_string = 'comment.php?action=%s&c=' . $comment->comment_ID . '&%s';
712712

713-
$approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
714-
$unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
715-
$spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
716-
$unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
717-
$trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
718-
$untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
719-
$delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
713+
$approve_url = sprintf( $action_string, 'approvecomment', $approve_nonce );
714+
$unapprove_url = sprintf( $action_string, 'unapprovecomment', $approve_nonce );
715+
$spam_url = sprintf( $action_string, 'spamcomment', $del_nonce );
716+
$unspam_url = sprintf( $action_string, 'unspamcomment', $del_nonce );
717+
$trash_url = sprintf( $action_string, 'trashcomment', $del_nonce );
718+
$untrash_url = sprintf( $action_string, 'untrashcomment', $del_nonce );
719+
$delete_url = sprintf( $action_string, 'deletecomment', $del_nonce );
720720

721721
// Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.
722722
$actions = array(
@@ -737,15 +737,15 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
737737
if ( 'approved' === $the_comment_status ) {
738738
$actions['unapprove'] = sprintf(
739739
'<a href="%s" data-wp-lists="%s" class="vim-u vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
740-
$unapprove_url,
740+
esc_url( $unapprove_url ),
741741
"delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&amp;new=unapproved",
742742
esc_attr__( 'Unapprove this comment' ),
743743
__( 'Unapprove' )
744744
);
745745
} elseif ( 'unapproved' === $the_comment_status ) {
746746
$actions['approve'] = sprintf(
747747
'<a href="%s" data-wp-lists="%s" class="vim-a vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
748-
$approve_url,
748+
esc_url( $approve_url ),
749749
"delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&amp;new=approved",
750750
esc_attr__( 'Approve this comment' ),
751751
__( 'Approve' )
@@ -754,15 +754,15 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
754754
} else {
755755
$actions['approve'] = sprintf(
756756
'<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>',
757-
$approve_url,
757+
esc_url( $approve_url ),
758758
"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved",
759759
esc_attr__( 'Approve this comment' ),
760760
__( 'Approve' )
761761
);
762762

763763
$actions['unapprove'] = sprintf(
764764
'<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>',
765-
$unapprove_url,
765+
esc_url( $unapprove_url ),
766766
"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved",
767767
esc_attr__( 'Unapprove this comment' ),
768768
__( 'Unapprove' )
@@ -772,7 +772,7 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
772772
if ( 'spam' !== $the_comment_status ) {
773773
$actions['spam'] = sprintf(
774774
'<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
775-
$spam_url,
775+
esc_url( $spam_url ),
776776
"delete:the-comment-list:comment-{$comment->comment_ID}::spam=1",
777777
esc_attr__( 'Mark this comment as spam' ),
778778
/* translators: "Mark as spam" link. */
@@ -781,7 +781,7 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
781781
} elseif ( 'spam' === $the_comment_status ) {
782782
$actions['unspam'] = sprintf(
783783
'<a href="%s" data-wp-lists="%s" class="vim-z vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
784-
$unspam_url,
784+
esc_url( $unspam_url ),
785785
"delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:unspam=1",
786786
esc_attr__( 'Restore this comment from the spam' ),
787787
_x( 'Not Spam', 'comment' )
@@ -791,7 +791,7 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
791791
if ( 'trash' === $the_comment_status ) {
792792
$actions['untrash'] = sprintf(
793793
'<a href="%s" data-wp-lists="%s" class="vim-z vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
794-
$untrash_url,
794+
esc_url( $untrash_url ),
795795
"delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:untrash=1",
796796
esc_attr__( 'Restore this comment from the Trash' ),
797797
__( 'Restore' )
@@ -801,15 +801,15 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
801801
if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) {
802802
$actions['delete'] = sprintf(
803803
'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
804-
$delete_url,
804+
esc_url( $delete_url ),
805805
"delete:the-comment-list:comment-{$comment->comment_ID}::delete=1",
806806
esc_attr__( 'Delete this comment permanently' ),
807807
__( 'Delete Permanently' )
808808
);
809809
} else {
810810
$actions['trash'] = sprintf(
811811
'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
812-
$trash_url,
812+
esc_url( $trash_url ),
813813
"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
814814
esc_attr__( 'Move this comment to the Trash' ),
815815
_x( 'Trash', 'verb' )

src/wp-admin/includes/dashboard.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -726,26 +726,28 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
726726
'view' => '',
727727
);
728728

729-
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
730-
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
729+
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'approve-comment_' . $comment->comment_ID ) );
730+
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( 'delete-comment_' . $comment->comment_ID ) );
731731

732-
$approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
733-
$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
734-
$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
735-
$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
736-
$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
732+
$action_string = 'comment.php?action=%s&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID . '&%s';
733+
734+
$approve_url = sprintf( $action_string, 'approvecomment', $approve_nonce );
735+
$unapprove_url = sprintf( $action_string, 'unapprovecomment', $approve_nonce );
736+
$spam_url = sprintf( $action_string, 'spamcomment', $del_nonce );
737+
$trash_url = sprintf( $action_string, 'trashcomment', $del_nonce );
738+
$delete_url = sprintf( $action_string, 'deletecomment', $del_nonce );
737739

738740
$actions['approve'] = sprintf(
739741
'<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>',
740-
$approve_url,
742+
esc_url( $approve_url ),
741743
"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved",
742744
esc_attr__( 'Approve this comment' ),
743745
__( 'Approve' )
744746
);
745747

746748
$actions['unapprove'] = sprintf(
747749
'<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>',
748-
$unapprove_url,
750+
esc_url( $unapprove_url ),
749751
"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved",
750752
esc_attr__( 'Unapprove this comment' ),
751753
__( 'Unapprove' )
@@ -768,7 +770,7 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
768770

769771
$actions['spam'] = sprintf(
770772
'<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
771-
$spam_url,
773+
esc_url( $spam_url ),
772774
"delete:the-comment-list:comment-{$comment->comment_ID}::spam=1",
773775
esc_attr__( 'Mark this comment as spam' ),
774776
/* translators: "Mark as spam" link. */
@@ -778,15 +780,15 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
778780
if ( ! EMPTY_TRASH_DAYS ) {
779781
$actions['delete'] = sprintf(
780782
'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
781-
$delete_url,
783+
esc_url( $delete_url ),
782784
"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
783785
esc_attr__( 'Delete this comment permanently' ),
784786
__( 'Delete Permanently' )
785787
);
786788
} else {
787789
$actions['trash'] = sprintf(
788790
'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
789-
$trash_url,
791+
esc_url( $trash_url ),
790792
"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
791793
esc_attr__( 'Move this comment to the Trash' ),
792794
_x( 'Trash', 'verb' )

0 commit comments

Comments
 (0)