102 $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $comment_ids ); |
103 $redirect_to = apply_filters( "handle_bulk_actions-{$screen}", $redirect_to, $doaction, $comment_ids ); |
103 } |
104 } |
104 |
105 |
105 wp_defer_comment_counting( false ); |
106 wp_defer_comment_counting( false ); |
106 |
107 |
107 if ( $approved ) |
108 if ( $approved ) { |
108 $redirect_to = add_query_arg( 'approved', $approved, $redirect_to ); |
109 $redirect_to = add_query_arg( 'approved', $approved, $redirect_to ); |
109 if ( $unapproved ) |
110 } |
|
111 if ( $unapproved ) { |
110 $redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to ); |
112 $redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to ); |
111 if ( $spammed ) |
113 } |
|
114 if ( $spammed ) { |
112 $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to ); |
115 $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to ); |
113 if ( $unspammed ) |
116 } |
|
117 if ( $unspammed ) { |
114 $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to ); |
118 $redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to ); |
115 if ( $trashed ) |
119 } |
|
120 if ( $trashed ) { |
116 $redirect_to = add_query_arg( 'trashed', $trashed, $redirect_to ); |
121 $redirect_to = add_query_arg( 'trashed', $trashed, $redirect_to ); |
117 if ( $untrashed ) |
122 } |
|
123 if ( $untrashed ) { |
118 $redirect_to = add_query_arg( 'untrashed', $untrashed, $redirect_to ); |
124 $redirect_to = add_query_arg( 'untrashed', $untrashed, $redirect_to ); |
119 if ( $deleted ) |
125 } |
|
126 if ( $deleted ) { |
120 $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); |
127 $redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to ); |
121 if ( $trashed || $spammed ) |
128 } |
|
129 if ( $trashed || $spammed ) { |
122 $redirect_to = add_query_arg( 'ids', join( ',', $comment_ids ), $redirect_to ); |
130 $redirect_to = add_query_arg( 'ids', join( ',', $comment_ids ), $redirect_to ); |
|
131 } |
123 |
132 |
124 wp_safe_redirect( $redirect_to ); |
133 wp_safe_redirect( $redirect_to ); |
125 exit; |
134 exit; |
126 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { |
135 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { |
127 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
136 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
128 exit; |
137 exit; |
129 } |
138 } |
130 |
139 |
131 $wp_list_table->prepare_items(); |
140 $wp_list_table->prepare_items(); |
132 |
141 |
133 wp_enqueue_script('admin-comments'); |
142 wp_enqueue_script( 'admin-comments' ); |
134 enqueue_comment_hotkeys_js(); |
143 enqueue_comment_hotkeys_js(); |
135 |
144 |
136 if ( $post_id ) { |
145 if ( $post_id ) { |
137 $comments_count = wp_count_comments( $post_id ); |
146 $comments_count = wp_count_comments( $post_id ); |
138 $draft_or_post_title = wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ); |
147 $draft_or_post_title = wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ); |
139 if ( $comments_count->moderated > 0 ) { |
148 if ( $comments_count->moderated > 0 ) { |
140 /* translators: 1: comments count 2: post title */ |
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 number_format_i18n( $comments_count->moderated ), |
152 number_format_i18n( $comments_count->moderated ), |
143 $draft_or_post_title |
153 $draft_or_post_title |
144 ); |
154 ); |
145 } else { |
155 } else { |
146 /* translators: %s: post title */ |
156 /* translators: %s: post title */ |
147 $title = sprintf( __( 'Comments on “%s”' ), |
157 $title = sprintf( |
|
158 __( 'Comments on “%s”' ), |
148 $draft_or_post_title |
159 $draft_or_post_title |
149 ); |
160 ); |
150 } |
161 } |
151 } else { |
162 } else { |
152 $comments_count = wp_count_comments(); |
163 $comments_count = wp_count_comments(); |
153 if ( $comments_count->moderated > 0 ) { |
164 if ( $comments_count->moderated > 0 ) { |
154 /* translators: %s: comments count */ |
165 /* translators: %s: comments count */ |
155 $title = sprintf( __( 'Comments (%s)' ), |
166 $title = sprintf( |
|
167 __( 'Comments (%s)' ), |
156 number_format_i18n( $comments_count->moderated ) |
168 number_format_i18n( $comments_count->moderated ) |
157 ); |
169 ); |
158 } else { |
170 } else { |
159 $title = __( 'Comments' ); |
171 $title = __( 'Comments' ); |
160 } |
172 } |
161 } |
173 } |
162 |
174 |
163 add_screen_option( 'per_page' ); |
175 add_screen_option( 'per_page' ); |
164 |
176 |
165 get_current_screen()->add_help_tab( array( |
177 get_current_screen()->add_help_tab( |
166 'id' => 'overview', |
178 array( |
167 'title' => __('Overview'), |
179 'id' => 'overview', |
168 'content' => |
180 'title' => __( 'Overview' ), |
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>' |
181 'content' => |
170 ) ); |
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>', |
171 get_current_screen()->add_help_tab( array( |
183 ) |
172 'id' => 'moderating-comments', |
184 ); |
173 'title' => __('Moderating Comments'), |
185 get_current_screen()->add_help_tab( |
174 'content' => |
186 array( |
175 '<p>' . __( 'A red bar on the left means the comment is waiting for you to moderate it.' ) . '</p>' . |
187 'id' => 'moderating-comments', |
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>' . |
188 'title' => __( 'Moderating Comments' ), |
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>' . |
189 'content' => |
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>' . |
190 '<p>' . __( 'A red bar on the left means the comment is waiting for you to moderate it.' ) . '</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>' . |
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>' . |
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>' |
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>' . |
181 ) ); |
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 get_current_screen()->set_help_sidebar( |
199 get_current_screen()->set_help_sidebar( |
184 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
200 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
185 '<p>' . __( '<a href="https://codex.wordpress.org/Administration_Screens#Comments">Documentation on Comments</a>' ) . '</p>' . |
201 '<p>' . __( '<a href="https://codex.wordpress.org/Administration_Screens#Comments">Documentation on Comments</a>' ) . '</p>' . |
186 '<p>' . __( '<a href="https://codex.wordpress.org/Comment_Spam">Documentation on Comment Spam</a>' ) . '</p>' . |
202 '<p>' . __( '<a href="https://codex.wordpress.org/Comment_Spam">Documentation on Comment Spam</a>' ) . '</p>' . |
187 '<p>' . __( '<a href="https://codex.wordpress.org/Keyboard_Shortcuts">Documentation on Keyboard Shortcuts</a>' ) . '</p>' . |
203 '<p>' . __( '<a href="https://codex.wordpress.org/Keyboard_Shortcuts">Documentation on Keyboard Shortcuts</a>' ) . '</p>' . |
188 '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' |
204 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
189 ); |
205 ); |
190 |
206 |
191 get_current_screen()->set_screen_reader_content( array( |
207 get_current_screen()->set_screen_reader_content( |
192 'heading_views' => __( 'Filter comments list' ), |
208 array( |
193 'heading_pagination' => __( 'Comments list navigation' ), |
209 'heading_views' => __( 'Filter comments list' ), |
194 'heading_list' => __( 'Comments list' ), |
210 'heading_pagination' => __( 'Comments list navigation' ), |
195 ) ); |
211 'heading_list' => __( 'Comments list' ), |
|
212 ) |
|
213 ); |
196 |
214 |
197 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
215 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
198 ?> |
216 ?> |
199 |
217 |
200 <div class="wrap"> |
218 <div class="wrap"> |
201 <h1 class="wp-heading-inline"><?php |
219 <h1 class="wp-heading-inline"> |
|
220 <?php |
202 if ( $post_id ) { |
221 if ( $post_id ) { |
203 /* translators: %s: link to post */ |
222 /* translators: %s: link to post */ |
204 printf( __( 'Comments on “%s”' ), |
223 printf( |
205 sprintf( '<a href="%1$s">%2$s</a>', |
224 __( 'Comments on “%s”' ), |
|
225 sprintf( |
|
226 '<a href="%1$s">%2$s</a>', |
206 get_edit_post_link( $post_id ), |
227 get_edit_post_link( $post_id ), |
207 wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ) |
228 wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' ) |
208 ) |
229 ) |
209 ); |
230 ); |
210 } else { |
231 } else { |
211 _e( 'Comments' ); |
232 _e( 'Comments' ); |
212 } |
233 } |
213 ?></h1> |
234 ?> |
214 |
235 </h1> |
215 <?php |
236 |
216 if ( isset($_REQUEST['s']) && strlen( $_REQUEST['s'] ) ) { |
237 <?php |
|
238 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
217 echo '<span class="subtitle">'; |
239 echo '<span class="subtitle">'; |
218 /* translators: %s: search keywords */ |
240 /* translators: %s: search keywords */ |
219 printf( __( 'Search results for “%s”' ), |
241 printf( |
|
242 __( 'Search results for “%s”' ), |
220 wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '…' ) |
243 wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '…' ) |
221 ); |
244 ); |
222 echo '</span>'; |
245 echo '</span>'; |
223 } |
246 } |
224 ?> |
247 ?> |
225 |
248 |
226 <hr class="wp-header-end"> |
249 <hr class="wp-header-end"> |
227 |
250 |
228 <?php |
251 <?php |
229 if ( isset( $_REQUEST['error'] ) ) { |
252 if ( isset( $_REQUEST['error'] ) ) { |
230 $error = (int) $_REQUEST['error']; |
253 $error = (int) $_REQUEST['error']; |
231 $error_msg = ''; |
254 $error_msg = ''; |
232 switch ( $error ) { |
255 switch ( $error ) { |
233 case 1 : |
256 case 1: |
234 $error_msg = __( 'Invalid comment ID.' ); |
257 $error_msg = __( 'Invalid comment ID.' ); |
235 break; |
258 break; |
236 case 2 : |
259 case 2: |
237 $error_msg = __( 'Sorry, you are not allowed to edit comments on this post.' ); |
260 $error_msg = __( 'Sorry, you are not allowed to edit comments on this post.' ); |
238 break; |
261 break; |
239 } |
262 } |
240 if ( $error_msg ) |
263 if ( $error_msg ) { |
241 echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>'; |
264 echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>'; |
242 } |
265 } |
243 |
266 } |
244 if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) || isset($_REQUEST['spammed']) || isset($_REQUEST['unspammed']) || isset($_REQUEST['same']) ) { |
267 |
245 $approved = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0; |
268 if ( isset( $_REQUEST['approved'] ) || isset( $_REQUEST['deleted'] ) || isset( $_REQUEST['trashed'] ) || isset( $_REQUEST['untrashed'] ) || isset( $_REQUEST['spammed'] ) || isset( $_REQUEST['unspammed'] ) || isset( $_REQUEST['same'] ) ) { |
246 $deleted = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; |
269 $approved = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0; |
247 $trashed = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0; |
270 $deleted = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0; |
|
271 $trashed = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0; |
248 $untrashed = isset( $_REQUEST['untrashed'] ) ? (int) $_REQUEST['untrashed'] : 0; |
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 $unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0; |
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 if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) { |
277 if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) { |
254 if ( $approved > 0 ) { |
278 if ( $approved > 0 ) { |
255 /* translators: %s: number of comments approved */ |
279 /* translators: %s: number of comments approved */ |
256 $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); |
280 $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); |
257 } |
281 } |
258 |
282 |
259 if ( $spammed > 0 ) { |
283 if ( $spammed > 0 ) { |
260 $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; |
284 $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0; |
261 /* translators: %s: number of comments marked as spam */ |
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 |
265 if ( $unspammed > 0 ) { |
289 if ( $unspammed > 0 ) { |
266 /* translators: %s: number of comments restored from the spam */ |
290 /* translators: %s: number of comments restored from the spam */ |
267 $messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed ); |
291 $messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed ); |
268 } |
292 } |
269 |
293 |
270 if ( $trashed > 0 ) { |
294 if ( $trashed > 0 ) { |
271 $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0; |
295 $ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0; |
272 /* translators: %s: number of comments moved to the Trash */ |
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 |
276 if ( $untrashed > 0 ) { |
300 if ( $untrashed > 0 ) { |
277 /* translators: %s: number of comments restored from the Trash */ |
301 /* translators: %s: number of comments restored from the Trash */ |
278 $messages[] = sprintf( _n( '%s comment restored from the Trash', '%s comments restored from the Trash', $untrashed ), $untrashed ); |
302 $messages[] = sprintf( _n( '%s comment restored from the Trash', '%s comments restored from the Trash', $untrashed ), $untrashed ); |