37 $approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0; |
42 $approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0; |
38 |
43 |
39 $redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() ); |
44 $redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() ); |
40 $redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to ); |
45 $redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to ); |
41 |
46 |
|
47 wp_defer_comment_counting( true ); |
|
48 |
42 foreach ( $comment_ids as $comment_id ) { // Check the permissions on each |
49 foreach ( $comment_ids as $comment_id ) { // Check the permissions on each |
43 if ( !current_user_can( 'edit_comment', $comment_id ) ) |
50 if ( !current_user_can( 'edit_comment', $comment_id ) ) |
44 continue; |
51 continue; |
45 |
52 |
46 switch ( $doaction ) { |
53 switch ( $doaction ) { |
72 wp_delete_comment( $comment_id ); |
79 wp_delete_comment( $comment_id ); |
73 $deleted++; |
80 $deleted++; |
74 break; |
81 break; |
75 } |
82 } |
76 } |
83 } |
|
84 |
|
85 if ( ! in_array( $doaction, array( 'approve', 'unapprove', 'spam', 'unspam', 'trash', 'delete' ), true ) ) { |
|
86 $screen = get_current_screen()->id; |
|
87 |
|
88 /** |
|
89 * Fires when a custom bulk action should be handled. |
|
90 * |
|
91 * The redirect link should be modified with success or failure feedback |
|
92 * from the action to be used to display feedback to the user. |
|
93 * |
|
94 * The dynamic portion of the hook name, `$screen`, refers to the current screen ID. |
|
95 * |
|
96 * @since 4.7.0 |
|
97 * |
|
98 * @param string $redirect_url The redirect URL. |
|
99 * @param string $doaction The action being taken. |
|
100 * @param array $items The items to take the action on. |
|
101 */ |
|
102 $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $comment_ids ); |
|
103 } |
|
104 |
|
105 wp_defer_comment_counting( false ); |
77 |
106 |
78 if ( $approved ) |
107 if ( $approved ) |
79 $redirect_to = add_query_arg( 'approved', $approved, $redirect_to ); |
108 $redirect_to = add_query_arg( 'approved', $approved, $redirect_to ); |
80 if ( $unapproved ) |
109 if ( $unapproved ) |
81 $redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to ); |
110 $redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to ); |
102 $wp_list_table->prepare_items(); |
131 $wp_list_table->prepare_items(); |
103 |
132 |
104 wp_enqueue_script('admin-comments'); |
133 wp_enqueue_script('admin-comments'); |
105 enqueue_comment_hotkeys_js(); |
134 enqueue_comment_hotkeys_js(); |
106 |
135 |
107 if ( $post_id ) |
136 if ( $post_id ) { |
108 $title = sprintf( __( 'Comments on “%s”' ), wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ) ); |
137 $comments_count = wp_count_comments( $post_id ); |
109 else |
138 $draft_or_post_title = wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ); |
110 $title = __('Comments'); |
139 if ( $comments_count->moderated > 0 ) { |
|
140 /* translators: 1: comments count 2: post title */ |
|
141 $title = sprintf( __( 'Comments (%1$s) on “%2$s”' ), |
|
142 number_format_i18n( $comments_count->moderated ), |
|
143 $draft_or_post_title |
|
144 ); |
|
145 } else { |
|
146 /* translators: %s: post title */ |
|
147 $title = sprintf( __( 'Comments on “%s”' ), |
|
148 $draft_or_post_title |
|
149 ); |
|
150 } |
|
151 } else { |
|
152 $comments_count = wp_count_comments(); |
|
153 if ( $comments_count->moderated > 0 ) { |
|
154 /* translators: %s: comments count */ |
|
155 $title = sprintf( __( 'Comments (%s)' ), |
|
156 number_format_i18n( $comments_count->moderated ) |
|
157 ); |
|
158 } else { |
|
159 $title = __( 'Comments' ); |
|
160 } |
|
161 } |
111 |
162 |
112 add_screen_option( 'per_page' ); |
163 add_screen_option( 'per_page' ); |
113 |
164 |
114 get_current_screen()->add_help_tab( array( |
165 get_current_screen()->add_help_tab( array( |
115 'id' => 'overview', |
166 'id' => 'overview', |
121 'id' => 'moderating-comments', |
172 'id' => 'moderating-comments', |
122 'title' => __('Moderating Comments'), |
173 'title' => __('Moderating Comments'), |
123 'content' => |
174 'content' => |
124 '<p>' . __( 'A red bar on the left means the comment is waiting for you to moderate it.' ) . '</p>' . |
175 '<p>' . __( 'A red bar on the left means the comment is waiting for you to moderate it.' ) . '</p>' . |
125 '<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>' . |
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>' . |
126 '<p>' . __( 'In the <strong>Comment</strong> column, above each comment it says “Submitted on,” followed by the date and time the comment was left on your site. Clicking on the date/time link will take you to that comment on your live site. Hovering over any comment gives you options to approve, reply (and approve), quick edit, edit, spam mark, or trash that comment.' ) . '</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>' . |
127 '<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 the bubble is gray, you have moderated all comments for that post. If it is blue, there are pending comments. Clicking the bubble will filter the comments screen to show only comments on that post.' ) . '</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>' . |
128 '<p>' . __( 'Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link to the side to learn more.' ) . '</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>' |
129 ) ); |
181 ) ); |
130 |
182 |
131 get_current_screen()->set_help_sidebar( |
183 get_current_screen()->set_help_sidebar( |
132 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
184 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
133 '<p>' . __( '<a href="https://codex.wordpress.org/Administration_Screens#Comments" target="_blank">Documentation on Comments</a>' ) . '</p>' . |
185 '<p>' . __( '<a href="https://codex.wordpress.org/Administration_Screens#Comments">Documentation on Comments</a>' ) . '</p>' . |
134 '<p>' . __( '<a href="https://codex.wordpress.org/Comment_Spam" target="_blank">Documentation on Comment Spam</a>' ) . '</p>' . |
186 '<p>' . __( '<a href="https://codex.wordpress.org/Comment_Spam">Documentation on Comment Spam</a>' ) . '</p>' . |
135 '<p>' . __( '<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">Documentation on Keyboard Shortcuts</a>' ) . '</p>' . |
187 '<p>' . __( '<a href="https://codex.wordpress.org/Keyboard_Shortcuts">Documentation on Keyboard Shortcuts</a>' ) . '</p>' . |
136 '<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' |
188 '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' |
137 ); |
189 ); |
|
190 |
|
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 ) ); |
138 |
196 |
139 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
197 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
140 ?> |
198 ?> |
141 |
199 |
142 <div class="wrap"> |
200 <div class="wrap"> |
143 <h2><?php |
201 <h1 class="wp-heading-inline"><?php |
144 if ( $post_id ) |
202 if ( $post_id ) { |
145 echo sprintf( __( 'Comments on “%s”' ), |
203 /* translators: %s: link to post */ |
146 sprintf( '<a href="%s">%s</a>', |
204 printf( __( 'Comments on “%s”' ), |
|
205 sprintf( '<a href="%1$s">%2$s</a>', |
147 get_edit_post_link( $post_id ), |
206 get_edit_post_link( $post_id ), |
148 wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ) |
207 wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ) |
149 ) |
208 ) |
150 ); |
209 ); |
151 else |
210 } else { |
152 echo __('Comments'); |
211 _e( 'Comments' ); |
153 |
212 } |
154 if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) |
213 ?></h1> |
155 echo '<span class="subtitle">' . sprintf( __( 'Search results for “%s”' ), wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '…' ) ) . '</span>'; ?> |
214 |
156 </h2> |
215 <?php |
|
216 if ( isset($_REQUEST['s']) && strlen( $_REQUEST['s'] ) ) { |
|
217 echo '<span class="subtitle">'; |
|
218 /* translators: %s: search keywords */ |
|
219 printf( __( 'Search results for “%s”' ), |
|
220 wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '…' ) |
|
221 ); |
|
222 echo '</span>'; |
|
223 } |
|
224 ?> |
|
225 |
|
226 <hr class="wp-header-end"> |
157 |
227 |
158 <?php |
228 <?php |
159 if ( isset( $_REQUEST['error'] ) ) { |
229 if ( isset( $_REQUEST['error'] ) ) { |
160 $error = (int) $_REQUEST['error']; |
230 $error = (int) $_REQUEST['error']; |
161 $error_msg = ''; |
231 $error_msg = ''; |
162 switch ( $error ) { |
232 switch ( $error ) { |
163 case 1 : |
233 case 1 : |
164 $error_msg = __( 'Oops, no comment with this ID.' ); |
234 $error_msg = __( 'Invalid comment ID.' ); |
165 break; |
235 break; |
166 case 2 : |
236 case 2 : |
167 $error_msg = __( 'You are not allowed to edit comments on this post.' ); |
237 $error_msg = __( 'Sorry, you are not allowed to edit comments on this post.' ); |
168 break; |
238 break; |
169 } |
239 } |
170 if ( $error_msg ) |
240 if ( $error_msg ) |
171 echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>'; |
241 echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>'; |
172 } |
242 } |
179 $spammed = isset( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0; |
249 $spammed = isset( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0; |
180 $unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; |
250 $unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; |
181 $same = isset( $_REQUEST['same'] ) ? (int) $_REQUEST['same'] : 0; |
251 $same = isset( $_REQUEST['same'] ) ? (int) $_REQUEST['same'] : 0; |
182 |
252 |
183 if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) { |
253 if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) { |
184 if ( $approved > 0 ) |
254 if ( $approved > 0 ) { |
|
255 /* translators: %s: number of comments approved */ |
185 $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); |
256 $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); |
|
257 } |
186 |
258 |
187 if ( $spammed > 0 ) { |
259 if ( $spammed > 0 ) { |
188 $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; |
260 $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; |
|
261 /* translators: %s: number of comments marked as spam */ |
189 $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 />'; |
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 />'; |
190 } |
263 } |
191 |
264 |
192 if ( $unspammed > 0 ) |
265 if ( $unspammed > 0 ) { |
|
266 /* translators: %s: number of comments restored from the spam */ |
193 $messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed ); |
267 $messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed ); |
|
268 } |
194 |
269 |
195 if ( $trashed > 0 ) { |
270 if ( $trashed > 0 ) { |
196 $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; |
271 $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; |
|
272 /* translators: %s: number of comments moved to the Trash */ |
197 $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 />'; |
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 />'; |
198 } |
274 } |
199 |
275 |
200 if ( $untrashed > 0 ) |
276 if ( $untrashed > 0 ) { |
|
277 /* translators: %s: number of comments restored from the Trash */ |
201 $messages[] = sprintf( _n( '%s comment restored from the Trash', '%s comments restored from the Trash', $untrashed ), $untrashed ); |
278 $messages[] = sprintf( _n( '%s comment restored from the Trash', '%s comments restored from the Trash', $untrashed ), $untrashed ); |
202 |
279 } |
203 if ( $deleted > 0 ) |
280 |
|
281 if ( $deleted > 0 ) { |
|
282 /* translators: %s: number of comments permanently deleted */ |
204 $messages[] = sprintf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted ); |
283 $messages[] = sprintf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted ); |
|
284 } |
205 |
285 |
206 if ( $same > 0 && $comment = get_comment( $same ) ) { |
286 if ( $same > 0 && $comment = get_comment( $same ) ) { |
207 switch ( $comment->comment_approved ) { |
287 switch ( $comment->comment_approved ) { |
208 case '1' : |
288 case '1' : |
209 $messages[] = __('This comment is already approved.') . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>'; |
289 $messages[] = __('This comment is already approved.') . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>'; |