Changeset 42343 for trunk/src/wp-admin/edit-comments.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/edit-comments.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/edit-comments.php
r42228 r42343 17 17 } 18 18 19 $wp_list_table = _get_list_table( 'WP_Comments_List_Table');20 $pagenum = $wp_list_table->get_pagenum();19 $wp_list_table = _get_list_table( 'WP_Comments_List_Table' ); 20 $pagenum = $wp_list_table->get_pagenum(); 21 21 22 22 $doaction = $wp_list_table->current_action(); … … 25 25 check_admin_referer( 'bulk-comments' ); 26 26 27 if ( 'delete_all' == $doaction && ! empty( $_REQUEST['pagegen_timestamp'] ) ) {27 if ( 'delete_all' == $doaction && ! empty( $_REQUEST['pagegen_timestamp'] ) ) { 28 28 $comment_status = wp_unslash( $_REQUEST['comment_status'] ); 29 $delete_time = wp_unslash( $_REQUEST['pagegen_timestamp'] );30 $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 ) );31 $doaction = 'delete';29 $delete_time = wp_unslash( $_REQUEST['pagegen_timestamp'] ); 30 $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 ) ); 31 $doaction = 'delete'; 32 32 } elseif ( isset( $_REQUEST['delete_comments'] ) ) { 33 33 $comment_ids = $_REQUEST['delete_comments']; 34 $doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];34 $doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2']; 35 35 } elseif ( isset( $_REQUEST['ids'] ) ) { 36 36 $comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) ); … … 48 48 49 49 foreach ( $comment_ids as $comment_id ) { // Check the permissions on each 50 if ( ! current_user_can( 'edit_comment', $comment_id ) )50 if ( ! current_user_can( 'edit_comment', $comment_id ) ) { 51 51 continue; 52 } 52 53 53 54 switch ( $doaction ) { 54 case 'approve' :55 case 'approve': 55 56 wp_set_comment_status( $comment_id, 'approve' ); 56 57 $approved++; 57 58 break; 58 case 'unapprove' :59 case 'unapprove': 59 60 wp_set_comment_status( $comment_id, 'hold' ); 60 61 $unapproved++; 61 62 break; 62 case 'spam' :63 case 'spam': 63 64 wp_spam_comment( $comment_id ); 64 65 $spammed++; 65 66 break; 66 case 'unspam' :67 case 'unspam': 67 68 wp_unspam_comment( $comment_id ); 68 69 $unspammed++; 69 70 break; 70 case 'trash' :71 case 'trash': 71 72 wp_trash_comment( $comment_id ); 72 73 $trashed++; 73 74 break; 74 case 'untrash' :75 case 'untrash': 75 76 wp_untrash_comment( $comment_id ); 76 77 $untrashed++; 77 78 break; 78 case 'delete' :79 case 'delete': 79 80 wp_delete_comment( $comment_id ); 80 81 $deleted++; … … 105 106 wp_defer_comment_counting( false ); 106 107 107 if ( $approved ) 108 if ( $approved ) { 108 109 $redirect_to = add_query_arg( 'approved', $approved, $redirect_to ); 109 if ( $unapproved ) 110 } 111 if ( $unapproved ) { 110 112 $redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to ); 111 if ( $spammed ) 113 } 114 if ( $spammed ) { 112 115 $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to ); 113 if ( $unspammed ) 116 } 117 if ( $unspammed ) { 114 118 $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to ); 115 if ( $trashed ) 119 } 120 if ( $trashed ) { 116 121 $redirect_to = add_query_arg( 'trashed', $trashed, $redirect_to ); 117 if ( $untrashed ) 122 } 123 if ( $untrashed ) { 118 124 $redirect_to = add_query_arg( 'untrashed', $untrashed, $redirect_to ); 119 if ( $deleted ) 125 } 126 if ( $deleted ) { 120 127 $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); 121 if ( $trashed || $spammed ) 128 } 129 if ( $trashed || $spammed ) { 122 130 $redirect_to = add_query_arg( 'ids', join( ',', $comment_ids ), $redirect_to ); 131 } 123 132 124 133 wp_safe_redirect( $redirect_to ); … … 131 140 $wp_list_table->prepare_items(); 132 141 133 wp_enqueue_script( 'admin-comments');142 wp_enqueue_script( 'admin-comments' ); 134 143 enqueue_comment_hotkeys_js(); 135 144 136 145 if ( $post_id ) { 137 $comments_count = wp_count_comments( $post_id );146 $comments_count = wp_count_comments( $post_id ); 138 147 $draft_or_post_title = wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ); 139 148 if ( $comments_count->moderated > 0 ) { 140 149 /* translators: 1: comments count 2: post title */ 141 $title = sprintf( __( 'Comments (%1$s) on “%2$s”' ), 150 $title = sprintf( 151 __( 'Comments (%1$s) on “%2$s”' ), 142 152 number_format_i18n( $comments_count->moderated ), 143 153 $draft_or_post_title … … 145 155 } else { 146 156 /* translators: %s: post title */ 147 $title = sprintf( __( 'Comments on “%s”' ), 157 $title = sprintf( 158 __( 'Comments on “%s”' ), 148 159 $draft_or_post_title 149 160 ); … … 153 164 if ( $comments_count->moderated > 0 ) { 154 165 /* translators: %s: comments count */ 155 $title = sprintf( __( 'Comments (%s)' ), 166 $title = sprintf( 167 __( 'Comments (%s)' ), 156 168 number_format_i18n( $comments_count->moderated ) 157 169 ); … … 163 175 add_screen_option( 'per_page' ); 164 176 165 get_current_screen()->add_help_tab( array( 166 'id' => 'overview', 167 'title' => __('Overview'), 168 'content' => 169 '<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>' 170 ) ); 171 get_current_screen()->add_help_tab( array( 172 'id' => 'moderating-comments', 173 'title' => __('Moderating Comments'), 174 'content' => 175 '<p>' . __( 'A red bar on the left means the comment is waiting for you to moderate it.' ) . '</p>' . 176 '<p>' . __( 'In the <strong>Author</strong> column, in addition to the author’s name, email address, and blog URL, the commenter’s IP address is shown. Clicking on this link will show you all the comments made from this IP address.' ) . '</p>' . 177 '<p>' . __( 'In the <strong>Comment</strong> column, hovering over any comment gives you options to approve, reply (and approve), quick edit, edit, spam mark, or trash that comment.' ) . '</p>' . 178 '<p>' . __( 'In the <strong>In Response To</strong> column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The View Post link leads to that post on your live site. The small bubble with the number in it shows the number of approved comments that post has received. If there are pending comments, a red notification circle with the number of pending comments is displayed. Clicking the notification circle will filter the comments screen to show only pending comments on that post.' ) . '</p>' . 179 '<p>' . __( 'In the <strong>Submitted On</strong> column, the date and time the comment was left on your site appears. Clicking on the date/time link will take you to that comment on your live site.' ) . '</p>' . 180 '<p>' . __( 'Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link to the side to learn more.' ) . '</p>' 181 ) ); 177 get_current_screen()->add_help_tab( 178 array( 179 'id' => 'overview', 180 'title' => __( 'Overview' ), 181 'content' => 182 '<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>', 183 ) 184 ); 185 get_current_screen()->add_help_tab( 186 array( 187 'id' => 'moderating-comments', 188 'title' => __( 'Moderating Comments' ), 189 'content' => 190 '<p>' . __( 'A red bar on the left means the comment is waiting for you to moderate it.' ) . '</p>' . 191 '<p>' . __( 'In the <strong>Author</strong> column, in addition to the author’s name, email address, and blog URL, the commenter’s IP address is shown. Clicking on this link will show you all the comments made from this IP address.' ) . '</p>' . 192 '<p>' . __( 'In the <strong>Comment</strong> column, hovering over any comment gives you options to approve, reply (and approve), quick edit, edit, spam mark, or trash that comment.' ) . '</p>' . 193 '<p>' . __( 'In the <strong>In Response To</strong> column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The View Post link leads to that post on your live site. The small bubble with the number in it shows the number of approved comments that post has received. If there are pending comments, a red notification circle with the number of pending comments is displayed. Clicking the notification circle will filter the comments screen to show only pending comments on that post.' ) . '</p>' . 194 '<p>' . __( 'In the <strong>Submitted On</strong> column, the date and time the comment was left on your site appears. Clicking on the date/time link will take you to that comment on your live site.' ) . '</p>' . 195 '<p>' . __( 'Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link to the side to learn more.' ) . '</p>', 196 ) 197 ); 182 198 183 199 get_current_screen()->set_help_sidebar( … … 189 205 ); 190 206 191 get_current_screen()->set_screen_reader_content( array( 192 'heading_views' => __( 'Filter comments list' ), 193 'heading_pagination' => __( 'Comments list navigation' ), 194 'heading_list' => __( 'Comments list' ), 195 ) ); 207 get_current_screen()->set_screen_reader_content( 208 array( 209 'heading_views' => __( 'Filter comments list' ), 210 'heading_pagination' => __( 'Comments list navigation' ), 211 'heading_list' => __( 'Comments list' ), 212 ) 213 ); 196 214 197 215 require_once( ABSPATH . 'wp-admin/admin-header.php' ); … … 199 217 200 218 <div class="wrap"> 201 <h1 class="wp-heading-inline"><?php 219 <h1 class="wp-heading-inline"> 220 <?php 202 221 if ( $post_id ) { 203 222 /* translators: %s: link to post */ 204 printf( __( 'Comments on “%s”' ), 205 sprintf( '<a href="%1$s">%2$s</a>', 223 printf( 224 __( 'Comments on “%s”' ), 225 sprintf( 226 '<a href="%1$s">%2$s</a>', 206 227 get_edit_post_link( $post_id ), 207 228 wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ) … … 211 232 _e( 'Comments' ); 212 233 } 213 ?></h1> 214 215 <?php 216 if ( isset($_REQUEST['s']) && strlen( $_REQUEST['s'] ) ) { 234 ?> 235 </h1> 236 237 <?php 238 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { 217 239 echo '<span class="subtitle">'; 218 240 /* translators: %s: search keywords */ 219 printf( __( 'Search results for “%s”' ), 241 printf( 242 __( 'Search results for “%s”' ), 220 243 wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '…' ) 221 244 ); … … 228 251 <?php 229 252 if ( isset( $_REQUEST['error'] ) ) { 230 $error = (int) $_REQUEST['error'];253 $error = (int) $_REQUEST['error']; 231 254 $error_msg = ''; 232 255 switch ( $error ) { 233 case 1 :256 case 1: 234 257 $error_msg = __( 'Invalid comment ID.' ); 235 258 break; 236 case 2 :259 case 2: 237 260 $error_msg = __( 'Sorry, you are not allowed to edit comments on this post.' ); 238 261 break; 239 262 } 240 if ( $error_msg ) 263 if ( $error_msg ) { 241 264 echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>'; 242 } 243 244 if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) || isset($_REQUEST['spammed']) || isset($_REQUEST['unspammed']) || isset($_REQUEST['same']) ) { 245 $approved = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0; 246 $deleted = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; 247 $trashed = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0; 265 } 266 } 267 268 if ( isset( $_REQUEST['approved'] ) || isset( $_REQUEST['deleted'] ) || isset( $_REQUEST['trashed'] ) || isset( $_REQUEST['untrashed'] ) || isset( $_REQUEST['spammed'] ) || isset( $_REQUEST['unspammed'] ) || isset( $_REQUEST['same'] ) ) { 269 $approved = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0; 270 $deleted = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; 271 $trashed = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0; 248 272 $untrashed = isset( $_REQUEST['untrashed'] ) ? (int) $_REQUEST['untrashed'] : 0; 249 $spammed = isset( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed']: 0;273 $spammed = isset( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0; 250 274 $unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; 251 $same = isset( $_REQUEST['same'] ) ? (int) $_REQUEST['same']: 0;275 $same = isset( $_REQUEST['same'] ) ? (int) $_REQUEST['same'] : 0; 252 276 253 277 if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) { … … 258 282 259 283 if ( $spammed > 0 ) { 260 $ids = isset( $_REQUEST['ids']) ? $_REQUEST['ids'] : 0;284 $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0; 261 285 /* translators: %s: number of comments marked as spam */ 262 $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 />';286 $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 />'; 263 287 } 264 288 … … 269 293 270 294 if ( $trashed > 0 ) { 271 $ids = isset( $_REQUEST['ids']) ? $_REQUEST['ids'] : 0;295 $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0; 272 296 /* translators: %s: number of comments moved to the Trash */ 273 $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 />';297 $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 />'; 274 298 } 275 299 … … 286 310 if ( $same > 0 && $comment = get_comment( $same ) ) { 287 311 switch ( $comment->comment_approved ) { 288 case '1' :289 $messages[] = __( 'This comment is already approved.') . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';312 case '1': 313 $messages[] = __( 'This comment is already approved.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>'; 290 314 break; 291 case 'trash' :315 case 'trash': 292 316 $messages[] = __( 'This comment is already in the Trash.' ) . ' <a href="' . esc_url( admin_url( 'edit-comments.php?comment_status=trash' ) ) . '"> ' . __( 'View Trash' ) . '</a>'; 293 317 break; 294 case 'spam' :318 case 'spam': 295 319 $messages[] = __( 'This comment is already marked as spam.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>'; 296 320 break; … … 312 336 <input type="hidden" name="p" value="<?php echo esc_attr( intval( $post_id ) ); ?>" /> 313 337 <?php endif; ?> 314 <input type="hidden" name="comment_status" value="<?php echo esc_attr( $comment_status); ?>" />315 <input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr( current_time('mysql', 1)); ?>" />316 317 <input type="hidden" name="_total" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg( 'total_items') ); ?>" />318 <input type="hidden" name="_per_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg( 'per_page') ); ?>" />319 <input type="hidden" name="_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg( 'page') ); ?>" />320 321 <?php if ( isset( $_REQUEST['paged']) ) { ?>338 <input type="hidden" name="comment_status" value="<?php echo esc_attr( $comment_status ); ?>" /> 339 <input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr( current_time( 'mysql', 1 ) ); ?>" /> 340 341 <input type="hidden" name="_total" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg( 'total_items' ) ); ?>" /> 342 <input type="hidden" name="_per_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg( 'per_page' ) ); ?>" /> 343 <input type="hidden" name="_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg( 'page' ) ); ?>" /> 344 345 <?php if ( isset( $_REQUEST['paged'] ) ) { ?> 322 346 <input type="hidden" name="paged" value="<?php echo esc_attr( absint( $_REQUEST['paged'] ) ); ?>" /> 323 347 <?php } ?> … … 330 354 331 355 <?php 332 wp_comment_reply( '-1', true, 'detail');356 wp_comment_reply( '-1', true, 'detail' ); 333 357 wp_comment_trashnotice(); 334 358 include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
Note: See TracChangeset
for help on using the changeset viewer.