+if ( isset( $_REQUEST['error'] ) ) {
+ $error = (int) $_REQUEST['error'];
+ $error_msg = '';
+ switch ( $error ) {
+ case 1 :
+ $error_msg = __( 'Invalid comment ID.' );
+ break;
+ case 2 :
+ $error_msg = __( 'Sorry, you are not allowed to edit comments on this post.' );
+ break;
+ }
+ if ( $error_msg )
+ echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>';
+}
+
+if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) || isset($_REQUEST['spammed']) || isset($_REQUEST['unspammed']) || isset($_REQUEST['same']) ) {
+ $approved = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0;
+ $deleted = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
+ $trashed = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0;
+ $untrashed = isset( $_REQUEST['untrashed'] ) ? (int) $_REQUEST['untrashed'] : 0;
+ $spammed = isset( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0;
+ $unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0;
+ $same = isset( $_REQUEST['same'] ) ? (int) $_REQUEST['same'] : 0;
+
+ if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) {
+ if ( $approved > 0 ) {
+ /* translators: %s: number of comments approved */
+ $messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
+ }
+
+ if ( $spammed > 0 ) {
+ $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
+ /* translators: %s: number of comments marked as spam */
+ $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 />';
+ }
+
+ if ( $unspammed > 0 ) {
+ /* translators: %s: number of comments restored from the spam */
+ $messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );
+ }
+
+ if ( $trashed > 0 ) {
+ $ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
+ /* translators: %s: number of comments moved to the Trash */
+ $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 />';
+ }
+
+ if ( $untrashed > 0 ) {
+ /* translators: %s: number of comments restored from the Trash */
+ $messages[] = sprintf( _n( '%s comment restored from the Trash', '%s comments restored from the Trash', $untrashed ), $untrashed );
+ }
+
+ if ( $deleted > 0 ) {
+ /* translators: %s: number of comments permanently deleted */
+ $messages[] = sprintf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
+ }
+
+ if ( $same > 0 && $comment = get_comment( $same ) ) {
+ switch ( $comment->comment_approved ) {
+ case '1' :
+ $messages[] = __('This comment is already approved.') . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
+ break;
+ case 'trash' :
+ $messages[] = __( 'This comment is already in the Trash.' ) . ' <a href="' . esc_url( admin_url( 'edit-comments.php?comment_status=trash' ) ) . '"> ' . __( 'View Trash' ) . '</a>';
+ break;
+ case 'spam' :
+ $messages[] = __( 'This comment is already marked as spam.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
+ break;
+ }
+ }
+
+ echo '<div id="moderated" class="updated notice is-dismissible"><p>' . implode( "<br/>\n", $messages ) . '</p></div>';
+ }