web/wp-admin/edit-comments.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
child 204 09a1c134465b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
     1 <?php
     1 <?php
     2 /**
     2 /**
     3  * Edit Comments Administration Panel.
     3  * Edit Comments Administration Screen.
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
     9 /** WordPress Administration Bootstrap */
     9 /** WordPress Administration Bootstrap */
    10 require_once('admin.php');
    10 require_once('./admin.php');
    11 
       
    12 if ( !current_user_can('edit_posts') )
    11 if ( !current_user_can('edit_posts') )
    13 	wp_die(__('Cheatin&#8217; uh?'));
    12 	wp_die(__('Cheatin&#8217; uh?'));
    14 
    13 
    15 wp_enqueue_script('admin-comments');
    14 $wp_list_table = _get_list_table('WP_Comments_List_Table');
    16 enqueue_comment_hotkeys_js();
    15 $pagenum = $wp_list_table->get_pagenum();
    17 
    16 
    18 $post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
    17 $doaction = $wp_list_table->current_action();
    19 
    18 
    20 if ( isset($_REQUEST['doaction']) ||  isset($_REQUEST['doaction2']) || isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) {
    19 if ( $doaction ) {
    21 	check_admin_referer('bulk-comments');
    20 	check_admin_referer( 'bulk-comments' );
    22 
    21 
    23 	if ( (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) && !empty($_REQUEST['pagegen_timestamp']) ) {
    22 	if ( 'delete_all' == $doaction && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
    24 		$comment_status = $wpdb->escape($_REQUEST['comment_status']);
    23 		$comment_status = $wpdb->escape( $_REQUEST['comment_status'] );
    25 		$delete_time = $wpdb->escape($_REQUEST['pagegen_timestamp']);
    24 		$delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] );
    26 		$comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" );
    25 		$comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" );
    27 		$doaction = 'delete';
    26 		$doaction = 'delete';
    28 	} elseif ( ($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments']) ) {
    27 	} elseif ( isset( $_REQUEST['delete_comments'] ) ) {
    29 		$comment_ids = $_REQUEST['delete_comments'];
    28 		$comment_ids = $_REQUEST['delete_comments'];
    30 		$doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2'];
    29 		$doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
    31 	} elseif ( $_REQUEST['doaction'] == 'undo' && isset($_REQUEST['ids']) ) {
    30 	} elseif ( isset( $_REQUEST['ids'] ) ) {
    32 		$comment_ids = array_map( 'absint', explode(',', $_REQUEST['ids']) );
    31 		$comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
    33 		$doaction = $_REQUEST['action'];
    32 	} elseif ( wp_get_referer() ) {
    34 	} else {
    33 		wp_safe_redirect( wp_get_referer() );
    35 		wp_redirect($_SERVER['HTTP_REFERER']);
    34 		exit;
    36 	}
    35 	}
    37 
    36 
    38 	$approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0;
    37 	$approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0;
    39 
    38 
    40 	foreach ($comment_ids as $comment_id) { // Check the permissions on each
    39 	$redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() );
    41 		$_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
    40 	$redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to );
    42 
    41 
    43 		if ( !current_user_can('edit_post', $_post_id) )
    42 	foreach ( $comment_ids as $comment_id ) { // Check the permissions on each
       
    43 		if ( !current_user_can( 'edit_comment', $comment_id ) )
    44 			continue;
    44 			continue;
    45 
    45 
    46 		switch( $doaction ) {
    46 		switch ( $doaction ) {
    47 			case 'approve' :
    47 			case 'approve' :
    48 				wp_set_comment_status($comment_id, 'approve');
    48 				wp_set_comment_status( $comment_id, 'approve' );
    49 				$approved++;
    49 				$approved++;
    50 				break;
    50 				break;
    51 			case 'unapprove' :
    51 			case 'unapprove' :
    52 				wp_set_comment_status($comment_id, 'hold');
    52 				wp_set_comment_status( $comment_id, 'hold' );
    53 				$unapproved++;
    53 				$unapproved++;
    54 				break;
    54 				break;
    55 			case 'spam' :
    55 			case 'spam' :
    56 				wp_spam_comment($comment_id);
    56 				wp_spam_comment( $comment_id );
    57 				$spammed++;
    57 				$spammed++;
    58 				break;
    58 				break;
    59 			case 'unspam' :
    59 			case 'unspam' :
    60 				wp_unspam_comment($comment_id);
    60 				wp_unspam_comment( $comment_id );
    61 				$unspammed++;
    61 				$unspammed++;
    62 				break;
    62 				break;
    63 			case 'trash' :
    63 			case 'trash' :
    64 				wp_trash_comment($comment_id);
    64 				wp_trash_comment( $comment_id );
    65 				$trashed++;
    65 				$trashed++;
    66 				break;
    66 				break;
    67 			case 'untrash' :
    67 			case 'untrash' :
    68 				wp_untrash_comment($comment_id);
    68 				wp_untrash_comment( $comment_id );
    69 				$untrashed++;
    69 				$untrashed++;
    70 				break;
    70 				break;
    71 			case 'delete' :
    71 			case 'delete' :
    72 				wp_delete_comment($comment_id);
    72 				wp_delete_comment( $comment_id );
    73 				$deleted++;
    73 				$deleted++;
    74 				break;
    74 				break;
    75 		}
    75 		}
    76 	}
    76 	}
    77 
       
    78 	$redirect_to = 'edit-comments.php';
       
    79 
    77 
    80 	if ( $approved )
    78 	if ( $approved )
    81 		$redirect_to = add_query_arg( 'approved', $approved, $redirect_to );
    79 		$redirect_to = add_query_arg( 'approved', $approved, $redirect_to );
    82 	if ( $unapproved )
    80 	if ( $unapproved )
    83 		$redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to );
    81 		$redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to );
    90 	if ( $untrashed )
    88 	if ( $untrashed )
    91 		$redirect_to = add_query_arg( 'untrashed', $untrashed, $redirect_to );
    89 		$redirect_to = add_query_arg( 'untrashed', $untrashed, $redirect_to );
    92 	if ( $deleted )
    90 	if ( $deleted )
    93 		$redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
    91 		$redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
    94 	if ( $trashed || $spammed )
    92 	if ( $trashed || $spammed )
    95 		$redirect_to = add_query_arg( 'ids', join(',', $comment_ids), $redirect_to );
    93 		$redirect_to = add_query_arg( 'ids', join( ',', $comment_ids ), $redirect_to );
    96 
    94 
    97 	if ( $post_id )
    95 	wp_safe_redirect( $redirect_to );
    98 		$redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
    96 	exit;
    99 	if ( isset($_REQUEST['apage']) )
    97 } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
   100 		$redirect_to = add_query_arg( 'apage', absint($_REQUEST['apage']), $redirect_to );
    98 	 wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
   101 	if ( !empty($_REQUEST['mode']) )
       
   102 		$redirect_to = add_query_arg('mode', $_REQUEST['mode'], $redirect_to);
       
   103 	if ( !empty($_REQUEST['comment_status']) )
       
   104 		$redirect_to = add_query_arg('comment_status', $_REQUEST['comment_status'], $redirect_to);
       
   105 	if ( !empty($_REQUEST['s']) )
       
   106 		$redirect_to = add_query_arg('s', $_REQUEST['s'], $redirect_to);
       
   107 	wp_redirect( $redirect_to );
       
   108 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
       
   109 	 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
       
   110 	 exit;
    99 	 exit;
   111 }
   100 }
   112 
   101 
       
   102 $wp_list_table->prepare_items();
       
   103 
       
   104 wp_enqueue_script('admin-comments');
       
   105 enqueue_comment_hotkeys_js();
       
   106 
   113 if ( $post_id )
   107 if ( $post_id )
   114 	$title = sprintf(__('Edit Comments on &#8220;%s&#8221;'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
   108 	$title = sprintf(__('Comments on &#8220;%s&#8221;'), wp_html_excerpt(_draft_or_post_title($post_id), 50));
   115 else
   109 else
   116 	$title = __('Edit Comments');
   110 	$title = __('Comments');
   117 
   111 
   118 require_once('admin-header.php');
   112 add_screen_option( 'per_page', array('label' => _x( 'Comments', 'comments per page (screen options)' )) );
   119 
   113 
   120 $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']);
   114 get_current_screen()->add_help_tab( array(
   121 
   115 'id'		=> 'overview',
   122 $comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all';
   116 'title'		=> __('Overview'),
   123 if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'trash')) )
   117 'content'	=>
   124 	$comment_status = 'all';
   118 	'<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>'
   125 
   119 ) );
   126 $comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : '';
   120 get_current_screen()->add_help_tab( array(
   127 
   121 'id'		=> 'moderating-comments',
   128 $search_dirty = ( isset($_GET['s']) ) ? $_GET['s'] : '';
   122 'title'		=> __('Moderating Comments'),
   129 $search = esc_attr( $search_dirty ); ?>
   123 'content'	=>
       
   124 		'<p>' . __( 'A yellow row means the comment is waiting for you to moderate it.' ) . '</p>' .
       
   125 		'<p>' . __( 'In the <strong>Author</strong> column, in addition to the author&#8217;s name, email address, and blog URL, the commenter&#8217;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 &#8220;Submitted on,&#8221; 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>' .
       
   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 how many 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>' .
       
   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>'
       
   129 ) );
       
   130 
       
   131 get_current_screen()->set_help_sidebar(
       
   132 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
       
   133 	'<p>' . __( '<a href="http://codex.wordpress.org/Administration_Screens#Comments" target="_blank">Documentation on Comments</a>' ) . '</p>' .
       
   134 	'<p>' . __( '<a href="http://codex.wordpress.org/Comment_Spam" target="_blank">Documentation on Comment Spam</a>' ) . '</p>' .
       
   135 	'<p>' . __( '<a href="http://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">Documentation on Keyboard Shortcuts</a>' ) . '</p>' .
       
   136 	'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
       
   137 );
       
   138 
       
   139 require_once('./admin-header.php');
       
   140 ?>
   130 
   141 
   131 <div class="wrap">
   142 <div class="wrap">
   132 <?php screen_icon(); ?>
   143 <?php screen_icon(); ?>
   133 <h2><?php echo esc_html( $title );
   144 <h2><?php
   134 if ( isset($_GET['s']) && $_GET['s'] )
   145 if ( $post_id )
   135 	printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( stripslashes( $_GET['s'] ) ), 50 ) ) . '</span>' ); ?>
   146 	echo sprintf(__('Comments on &#8220;%s&#8221;'),
       
   147 		sprintf('<a href="%s">%s</a>',
       
   148 			get_edit_post_link($post_id),
       
   149 			wp_html_excerpt(_draft_or_post_title($post_id), 50)
       
   150 		)
       
   151 	);
       
   152 else
       
   153 	echo __('Comments');
       
   154 
       
   155 if ( isset($_REQUEST['s']) && $_REQUEST['s'] )
       
   156 	printf( '<span class="subtitle">' . sprintf( __( 'Search results for &#8220;%s&#8221;' ), wp_html_excerpt( esc_html( stripslashes( $_REQUEST['s'] ) ), 50 ) ) . '</span>' ); ?>
   136 </h2>
   157 </h2>
   137 
   158 
   138 <?php
   159 <?php
   139 if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed']) ) {
   160 if ( isset( $_REQUEST['error'] ) ) {
   140 	$approved = isset($_GET['approved']) ? (int) $_GET['approved'] : 0;
   161 	$error = (int) $_REQUEST['error'];
   141 	$deleted = isset($_GET['deleted']) ? (int) $_GET['deleted'] : 0;
   162 	$error_msg = '';
   142 	$trashed = isset($_GET['trashed']) ? (int) $_GET['trashed'] : 0;
   163 	switch ( $error ) {
   143 	$untrashed = isset($_GET['untrashed']) ? (int) $_GET['untrashed'] : 0;
   164 		case 1 :
   144 	$spammed = isset($_GET['spammed']) ? (int) $_GET['spammed'] : 0;
   165 			$error_msg = __( 'Oops, no comment with this ID.' );
   145 	$unspammed = isset($_GET['unspammed']) ? (int) $_GET['unspammed'] : 0;
   166 			break;
   146 
   167 		case 2 :
   147 	if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 ) {
   168 			$error_msg = __( 'You are not allowed to edit comments on this post.' );
   148 		echo '<div id="moderated" class="updated fade"><p>';
   169 			break;
   149 
   170 	}
   150 		if ( $approved > 0 ) {
   171 	if ( $error_msg )
   151 			printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
   172 		echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>';
   152 			echo '<br />';
   173 }
   153 		}
   174 
       
   175 if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQUEST['trashed']) || isset($_REQUEST['untrashed']) || isset($_REQUEST['spammed']) || isset($_REQUEST['unspammed']) || isset($_REQUEST['same']) ) {
       
   176 	$approved  = isset( $_REQUEST['approved']  ) ? (int) $_REQUEST['approved']  : 0;
       
   177 	$deleted   = isset( $_REQUEST['deleted']   ) ? (int) $_REQUEST['deleted']   : 0;
       
   178 	$trashed   = isset( $_REQUEST['trashed']   ) ? (int) $_REQUEST['trashed']   : 0;
       
   179 	$untrashed = isset( $_REQUEST['untrashed'] ) ? (int) $_REQUEST['untrashed'] : 0;
       
   180 	$spammed   = isset( $_REQUEST['spammed']   ) ? (int) $_REQUEST['spammed']   : 0;
       
   181 	$unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0;
       
   182 	$same      = isset( $_REQUEST['same'] )      ? (int) $_REQUEST['same']      : 0;
       
   183 
       
   184 	if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) {
       
   185 		if ( $approved > 0 )
       
   186 			$messages[] = sprintf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
       
   187 
   154 		if ( $spammed > 0 ) {
   188 		if ( $spammed > 0 ) {
   155 			printf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed );
   189 			$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
   156 			$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
   190 			$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 />';
   157 			echo ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
   191 		}
   158 		}
   192 
   159 		if ( $unspammed > 0 ) {
   193 		if ( $unspammed > 0 )
   160 			printf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );
   194 			$messages[] = sprintf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );
   161 			echo '<br />';
   195 
   162 		}
       
   163 		if ( $trashed > 0 ) {
   196 		if ( $trashed > 0 ) {
   164 			printf( _n( '%s comment moved to the trash.', '%s comments moved to the trash.', $trashed ), $trashed );
   197 			$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 0;
   165 			$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
   198 			$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 />';
   166 			echo ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
   199 		}
   167 		}
   200 
   168 		if ( $untrashed > 0 ) {
   201 		if ( $untrashed > 0 )
   169 			printf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed );
   202 			$messages[] = sprintf( _n( '%s comment restored from the Trash', '%s comments restored from the Trash', $untrashed ), $untrashed );
   170 			echo '<br />';
   203 
   171 		}
   204 		if ( $deleted > 0 )
   172 		if ( $deleted > 0 ) {
   205 			$messages[] = sprintf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
   173 			printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $deleted ), $deleted );
   206 
   174 			echo '<br />';
   207 		if ( $same > 0 && $comment = get_comment( $same ) ) {
   175 		}
   208 			switch ( $comment->comment_approved ) {
   176 
   209 				case '1' :
   177 		echo '</p></div>';
   210 					$messages[] = __('This comment is already approved.') . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
       
   211 					break;
       
   212 				case 'trash' :
       
   213 					$messages[] = __( 'This comment is already in the Trash.' ) . ' <a href="' . esc_url( admin_url( 'edit-comments.php?comment_status=trash' ) ) . '"> ' . __( 'View Trash' ) . '</a>';
       
   214 					break;
       
   215 				case 'spam' :
       
   216 					$messages[] = __( 'This comment is already marked as spam.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
       
   217 					break;
       
   218 			}
       
   219 		}
       
   220 
       
   221 		echo '<div id="moderated" class="updated"><p>' . implode( "<br/>\n", $messages ) . '</p></div>';
   178 	}
   222 	}
   179 }
   223 }
   180 ?>
   224 ?>
   181 
   225 
       
   226 <?php $wp_list_table->views(); ?>
       
   227 
   182 <form id="comments-form" action="" method="get">
   228 <form id="comments-form" action="" method="get">
   183 <ul class="subsubsub">
   229 
   184 <?php
   230 <?php $wp_list_table->search_box( __( 'Search Comments' ), 'comment' ); ?>
   185 $status_links = array();
   231 
   186 $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
       
   187 //, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
       
   188 //, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
       
   189 $stati = array(
       
   190 		'all' => _n_noop('All', 'All'), // singular not used
       
   191 		'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'),
       
   192 		'approved' => _n_noop('Approved', 'Approved'), // singular not used
       
   193 		'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'),
       
   194 		'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>')
       
   195 	);
       
   196 
       
   197 if ( !EMPTY_TRASH_DAYS )
       
   198 	unset($stati['trash']);
       
   199 
       
   200 $link = 'edit-comments.php';
       
   201 if ( !empty($comment_type) && 'all' != $comment_type )
       
   202 	$link = add_query_arg( 'comment_type', $comment_type, $link );
       
   203 
       
   204 foreach ( $stati as $status => $label ) {
       
   205 	$class = '';
       
   206 
       
   207 	if ( $status == $comment_status )
       
   208 		$class = ' class="current"';
       
   209 	if ( !isset( $num_comments->$status ) )
       
   210 		$num_comments->$status = 10;
       
   211 	$link = add_query_arg( 'comment_status', $status, $link );
       
   212 	if ( $post_id )
       
   213 		$link = add_query_arg( 'p', absint( $post_id ), $link );
       
   214 	/*
       
   215 	// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
       
   216 	if ( !empty( $_GET['s'] ) )
       
   217 		$link = add_query_arg( 's', esc_attr( stripslashes( $_GET['s'] ) ), $link );
       
   218 	*/
       
   219 	$status_links[] = "<li class='$status'><a href='$link'$class>" . sprintf(
       
   220 		_n( $label[0], $label[1], $num_comments->$status ),
       
   221 		number_format_i18n( $num_comments->$status )
       
   222 	) . '</a>';
       
   223 }
       
   224 
       
   225 $status_links = apply_filters( 'comment_status_links', $status_links );
       
   226 
       
   227 echo implode( " |</li>\n", $status_links) . '</li>';
       
   228 unset($status_links);
       
   229 ?>
       
   230 </ul>
       
   231 
       
   232 <p class="search-box">
       
   233 	<label class="screen-reader-text" for="comment-search-input"><?php _e( 'Search Comments' ); ?>:</label>
       
   234 	<input type="text" id="comment-search-input" name="s" value="<?php _admin_search_query(); ?>" />
       
   235 	<input type="submit" value="<?php esc_attr_e( 'Search Comments' ); ?>" class="button" />
       
   236 </p>
       
   237 
       
   238 <?php
       
   239 $comments_per_page = (int) get_user_option( 'edit_comments_per_page', 0, false );
       
   240 if ( empty( $comments_per_page ) || $comments_per_page < 1 )
       
   241 	$comments_per_page = 20;
       
   242 $comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
       
   243 
       
   244 if ( isset( $_GET['apage'] ) )
       
   245 	$page = abs( (int) $_GET['apage'] );
       
   246 else
       
   247 	$page = 1;
       
   248 
       
   249 $start = $offset = ( $page - 1 ) * $comments_per_page;
       
   250 
       
   251 list($_comments, $total) = _wp_get_comment_list( $comment_status, $search_dirty, $start, $comments_per_page + 8, $post_id, $comment_type ); // Grab a few extra
       
   252 
       
   253 $_comment_post_ids = array();
       
   254 foreach ( $_comments as $_c ) {
       
   255 	$_comment_post_ids[] = $_c->comment_post_ID;
       
   256 }
       
   257 $_comment_pending_count_temp = (array) get_pending_comments_num($_comment_post_ids);
       
   258 foreach ( (array) $_comment_post_ids as $_cpid )
       
   259 	$_comment_pending_count[$_cpid] = isset( $_comment_pending_count_temp[$_cpid] ) ? $_comment_pending_count_temp[$_cpid] : 0;
       
   260 if ( empty($_comment_pending_count) )
       
   261 	$_comment_pending_count = array();
       
   262 
       
   263 $comments = array_slice($_comments, 0, $comments_per_page);
       
   264 $extra_comments = array_slice($_comments, $comments_per_page);
       
   265 
       
   266 $page_links = paginate_links( array(
       
   267 	'base' => add_query_arg( 'apage', '%#%' ),
       
   268 	'format' => '',
       
   269 	'prev_text' => __('&laquo;'),
       
   270 	'next_text' => __('&raquo;'),
       
   271 	'total' => ceil($total / $comments_per_page),
       
   272 	'current' => $page
       
   273 ));
       
   274 
       
   275 ?>
       
   276 
       
   277 <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
       
   278 <?php if ( $post_id ) : ?>
   232 <?php if ( $post_id ) : ?>
   279 <input type="hidden" name="p" value="<?php echo esc_attr( intval( $post_id ) ); ?>" />
   233 <input type="hidden" name="p" value="<?php echo esc_attr( intval( $post_id ) ); ?>" />
   280 <?php endif; ?>
   234 <?php endif; ?>
   281 <input type="hidden" name="comment_status" value="<?php echo esc_attr($comment_status); ?>" />
   235 <input type="hidden" name="comment_status" value="<?php echo esc_attr($comment_status); ?>" />
   282 <input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr(current_time('mysql', 1)); ?>" />
   236 <input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr(current_time('mysql', 1)); ?>" />
   283 
   237 
   284 <div class="tablenav">
   238 <input type="hidden" name="_total" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('total_items') ); ?>" />
   285 
   239 <input type="hidden" name="_per_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('per_page') ); ?>" />
   286 <?php if ( $page_links ) : ?>
   240 <input type="hidden" name="_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('page') ); ?>" />
   287 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
   241 
   288 	number_format_i18n( $start + 1 ),
   242 <?php if ( isset($_REQUEST['paged']) ) { ?>
   289 	number_format_i18n( min( $page * $comments_per_page, $total ) ),
   243 	<input type="hidden" name="paged" value="<?php echo esc_attr( absint( $_REQUEST['paged'] ) ); ?>" />
   290 	'<span class="total-type-count">' . number_format_i18n( $total ) . '</span>',
   244 <?php } ?>
   291 	$page_links
   245 
   292 ); echo $page_links_text; ?></div>
   246 <?php $wp_list_table->display(); ?>
   293 <input type="hidden" name="_total" value="<?php echo esc_attr($total); ?>" />
   247 </form>
   294 <input type="hidden" name="_per_page" value="<?php echo esc_attr($comments_per_page); ?>" />
       
   295 <input type="hidden" name="_page" value="<?php echo esc_attr($page); ?>" />
       
   296 <?php endif; ?>
       
   297 
       
   298 <div class="alignleft actions">
       
   299 <select name="action">
       
   300 <option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option>
       
   301 <?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
       
   302 <option value="unapprove"><?php _e('Unapprove'); ?></option>
       
   303 <?php endif; ?>
       
   304 <?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
       
   305 <option value="approve"><?php _e('Approve'); ?></option>
       
   306 <?php endif; ?>
       
   307 <?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
       
   308 <option value="spam"><?php _e('Mark as Spam'); ?></option>
       
   309 <?php endif; ?>
       
   310 <?php if ( 'trash' == $comment_status ): ?>
       
   311 <option value="untrash"><?php _e('Restore'); ?></option>
       
   312 <?php elseif ( 'spam' == $comment_status ): ?>
       
   313 <option value="unspam"><?php _e('Not Spam'); ?></option>
       
   314 <?php endif; ?>
       
   315 <?php if ( 'trash' == $comment_status || 'spam' == $comment_status || !EMPTY_TRASH_DAYS ): ?>
       
   316 <option value="delete"><?php _e('Delete Permanently'); ?></option>
       
   317 <?php else: ?>
       
   318 <option value="trash"><?php _e('Move to Trash'); ?></option>
       
   319 <?php endif; ?>
       
   320 </select>
       
   321 <input type="submit" name="doaction" id="doaction" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
       
   322 <?php wp_nonce_field('bulk-comments'); ?>
       
   323 
       
   324 <select name="comment_type">
       
   325 	<option value="all"><?php _e('Show all comment types'); ?></option>
       
   326 <?php
       
   327 	$comment_types = apply_filters( 'admin_comment_types_dropdown', array(
       
   328 		'comment' => __('Comments'),
       
   329 		'pings' => __('Pings'),
       
   330 	) );
       
   331 
       
   332 	foreach ( $comment_types as $type => $label ) {
       
   333 		echo "	<option value='" . esc_attr($type) . "'";
       
   334 		selected( $comment_type, $type );
       
   335 		echo ">$label</option>\n";
       
   336 	}
       
   337 ?>
       
   338 </select>
       
   339 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
       
   340 
       
   341 <?php if ( isset($_GET['apage']) ) { ?>
       
   342 	<input type="hidden" name="apage" value="<?php echo esc_attr( absint( $_GET['apage'] ) ); ?>" />
       
   343 <?php }
       
   344 
       
   345 if ( ( 'spam' == $comment_status || 'trash' == $comment_status) && current_user_can ('moderate_comments') ) {
       
   346 	wp_nonce_field('bulk-destroy', '_destroy_nonce');
       
   347     if ( 'spam' == $comment_status && current_user_can('moderate_comments') ) { ?>
       
   348 		<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
       
   349 <?php } elseif ( 'trash' == $comment_status && current_user_can('moderate_comments') ) { ?>
       
   350 		<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
       
   351 <?php }
       
   352 } ?>
       
   353 <?php do_action('manage_comments_nav', $comment_status); ?>
       
   354 </div>
   248 </div>
   355 
   249 
   356 <br class="clear" />
       
   357 
       
   358 </div>
       
   359 
       
   360 <div class="clear"></div>
       
   361 
       
   362 <?php if ( $comments ) { ?>
       
   363 <table class="widefat comments fixed" cellspacing="0">
       
   364 <thead>
       
   365 	<tr>
       
   366 <?php print_column_headers('edit-comments'); ?>
       
   367 	</tr>
       
   368 </thead>
       
   369 
       
   370 <tfoot>
       
   371 	<tr>
       
   372 <?php print_column_headers('edit-comments', false); ?>
       
   373 	</tr>
       
   374 </tfoot>
       
   375 
       
   376 <tbody id="the-comment-list" class="list:comment">
       
   377 <?php
       
   378 	foreach ($comments as $comment)
       
   379 		_wp_comment_row( $comment->comment_ID, $mode, $comment_status );
       
   380 ?>
       
   381 </tbody>
       
   382 <tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
       
   383 <?php
       
   384 	foreach ($extra_comments as $comment)
       
   385 		_wp_comment_row( $comment->comment_ID, $mode, $comment_status );
       
   386 ?>
       
   387 </tbody>
       
   388 </table>
       
   389 
       
   390 <div class="tablenav">
       
   391 <?php
       
   392 if ( $page_links )
       
   393 	echo "<div class='tablenav-pages'>$page_links_text</div>";
       
   394 ?>
       
   395 
       
   396 <div class="alignleft actions">
       
   397 <select name="action2">
       
   398 <option value="-1" selected="selected"><?php _e('Bulk Actions') ?></option>
       
   399 <?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
       
   400 <option value="unapprove"><?php _e('Unapprove'); ?></option>
       
   401 <?php endif; ?>
       
   402 <?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
       
   403 <option value="approve"><?php _e('Approve'); ?></option>
       
   404 <?php endif; ?>
       
   405 <?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
       
   406 <option value="spam"><?php _e('Mark as Spam'); ?></option>
       
   407 <?php endif; ?>
       
   408 <?php if ( 'trash' == $comment_status ): ?>
       
   409 <option value="untrash"><?php _e('Restore'); ?></option>
       
   410 <?php endif; ?>
       
   411 <?php if ( 'trash' == $comment_status || 'spam' == $comment_status || !EMPTY_TRASH_DAYS ): ?>
       
   412 <option value="delete"><?php _e('Delete Permanently'); ?></option>
       
   413 <?php elseif ( 'spam' == $comment_status ): ?>
       
   414 <option value="unspam"><?php _e('Not Spam'); ?></option>
       
   415 <?php else: ?>
       
   416 <option value="trash"><?php _e('Move to Trash'); ?></option>
       
   417 <?php endif; ?>
       
   418 </select>
       
   419 <input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
       
   420 
       
   421 <?php if ( 'spam' == $comment_status && current_user_can('moderate_comments') ) { ?>
       
   422 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Spam'); ?>" class="button-secondary apply" />
       
   423 <?php } elseif ( 'trash' == $comment_status && current_user_can('moderate_comments') ) { ?>
       
   424 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
       
   425 <?php } ?>
       
   426 <?php do_action('manage_comments_nav', $comment_status); ?>
       
   427 </div>
       
   428 
       
   429 <br class="clear" />
       
   430 </div>
       
   431 
       
   432 </form>
       
   433 
       
   434 <form id="get-extra-comments" method="post" action="" class="add:the-extra-comment-list:" style="display: none;">
       
   435 	<input type="hidden" name="s" value="<?php echo esc_attr($search); ?>" />
       
   436 	<input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
       
   437 	<input type="hidden" name="comment_status" value="<?php echo esc_attr($comment_status); ?>" />
       
   438 	<input type="hidden" name="page" value="<?php echo esc_attr($page); ?>" />
       
   439 	<input type="hidden" name="per_page" value="<?php echo esc_attr($comments_per_page); ?>" />
       
   440 	<input type="hidden" name="p" value="<?php echo esc_attr( $post_id ); ?>" />
       
   441 	<input type="hidden" name="comment_type" value="<?php echo esc_attr( $comment_type ); ?>" />
       
   442 	<?php wp_nonce_field( 'add-comment', '_ajax_nonce', false ); ?>
       
   443 </form>
       
   444 
       
   445 <div id="ajax-response"></div>
   250 <div id="ajax-response"></div>
   446 
       
   447 <?php } elseif ( 'moderated' == $comment_status ) { ?>
       
   448 <p><?php _e('No comments awaiting moderation&hellip; yet.') ?></p>
       
   449 </form>
       
   450 
       
   451 <?php } else { ?>
       
   452 <p><?php _e('No results found.') ?></p>
       
   453 </form>
       
   454 
       
   455 <?php } ?>
       
   456 </div>
       
   457 
   251 
   458 <?php
   252 <?php
   459 wp_comment_reply('-1', true, 'detail');
   253 wp_comment_reply('-1', true, 'detail');
   460 wp_comment_trashnotice();
   254 wp_comment_trashnotice();
   461 include('admin-footer.php'); ?>
   255 include('./admin-footer.php'); ?>