wp/wp-admin/includes/class-wp-comments-list-table.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Comments and Post Comments List Table classes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage List_Table
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 * Comments List Table class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 * @subpackage List_Table
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
class WP_Comments_List_Table extends WP_List_Table {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    20
	public $checkbox = true;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    21
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    22
	public $pending_count = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    24
	public $extra_items;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
	private $user_can;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
	 * Constructor.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    31
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    32
	 * @access public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    33
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    34
	 * @see WP_List_Table::__construct() for more information on default arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    35
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    36
	 * @param array $args An associative array of arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    37
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    38
	public function __construct( $args = array() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
		global $post_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
		$post_id = isset( $_REQUEST['p'] ) ? absint( $_REQUEST['p'] ) : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
		if ( get_option('show_avatars') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
			add_filter( 'comment_author', 'floated_admin_avatar' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
		parent::__construct( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
			'plural' => 'comments',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
			'singular' => 'comment',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
			'ajax' => true,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
			'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    54
	public function ajax_user_can() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
		return current_user_can('edit_posts');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    58
	public function prepare_items() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
		global $post_id, $comment_status, $search, $comment_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
		$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
		if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
			$comment_status = 'all';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
		$comment_type = !empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
		$search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
		$post_type = ( isset( $_REQUEST['post_type'] ) ) ? sanitize_key( $_REQUEST['post_type'] ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
		$user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
		$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
		$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
		$comments_per_page = $this->get_per_page( $comment_status );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
		$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
		if ( isset( $_REQUEST['number'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
			$number = (int) $_REQUEST['number'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
		else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
			$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
		$page = $this->get_pagenum();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
		if ( isset( $_REQUEST['start'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
			$start = $_REQUEST['start'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
			$start = ( $page - 1 ) * $comments_per_page;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
		if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
			$start += $_REQUEST['offset'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
		$status_map = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
			'moderated' => 'hold',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
			'approved' => 'approve',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
			'all' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
		$args = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
			'status' => isset( $status_map[$comment_status] ) ? $status_map[$comment_status] : $comment_status,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
			'search' => $search,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
			'user_id' => $user_id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
			'offset' => $start,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
			'number' => $number,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
			'post_id' => $post_id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
			'type' => $comment_type,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
			'orderby' => $orderby,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
			'order' => $order,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			'post_type' => $post_type,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
		$_comments = get_comments( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
		update_comment_cache( $_comments );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
		$this->items = array_slice( $_comments, 0, $comments_per_page );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
		$this->extra_items = array_slice( $_comments, $comments_per_page );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
		$total_comments = get_comments( array_merge( $args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
		$_comment_post_ids = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
		foreach ( $_comments as $_c ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
			$_comment_post_ids[] = $_c->comment_post_ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
		$_comment_post_ids = array_unique( $_comment_post_ids );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
		$this->pending_count = get_pending_comments_num( $_comment_post_ids );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
		$this->set_pagination_args( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
			'total_items' => $total_comments,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
			'per_page' => $comments_per_page,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   142
	public function get_per_page( $comment_status = 'all' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
		$comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   144
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   145
		 * Filter the number of comments listed per page in the comments list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   146
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   147
		 * @since 2.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   148
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   149
		 * @param int    $comments_per_page The number of comments to list per page.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   150
		 * @param string $comment_status    The comment status name. Default 'All'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   151
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
		$comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
		return $comments_per_page;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   156
	public function no_items() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
		global $comment_status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
		if ( 'moderated' == $comment_status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
			_e( 'No comments awaiting moderation.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
			_e( 'No comments found.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   165
	protected function get_views() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
		global $post_id, $comment_status, $comment_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
		$status_links = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
		$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
		//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
		//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
		$stati = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
				'all' => _nx_noop('All', 'All', 'comments'), // singular not used
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
				'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>'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
				'approved' => _n_noop('Approved', 'Approved'), // singular not used
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
				'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>'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
				'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>')
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
		if ( !EMPTY_TRASH_DAYS )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
			unset($stati['trash']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
		$link = 'edit-comments.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
		if ( !empty($comment_type) && 'all' != $comment_type )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
			$link = add_query_arg( 'comment_type', $comment_type, $link );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
		foreach ( $stati as $status => $label ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
			$class = ( $status == $comment_status ) ? ' class="current"' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
			if ( !isset( $num_comments->$status ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
				$num_comments->$status = 10;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
			$link = add_query_arg( 'comment_status', $status, $link );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
			if ( $post_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
				$link = add_query_arg( 'p', absint( $post_id ), $link );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
			/*
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
			// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
			if ( !empty( $_REQUEST['s'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
				$link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
			*/
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
			$status_links[$status] = "<a href='$link'$class>" . sprintf(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
				translate_nooped_plural( $label, $num_comments->$status ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
				number_format_i18n( $num_comments->$status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
			) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   206
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   207
		 * Filter the comment status links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   208
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   209
		 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   210
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   211
		 * @param array $status_links An array of fully-formed status links. Default 'All'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   212
		 *                            Accepts 'All', 'Pending', 'Approved', 'Spam', and 'Trash'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   213
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
		$status_links = apply_filters( 'comment_status_links', $status_links );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
		return $status_links;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   218
	protected function get_bulk_actions() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
		global $comment_status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
		$actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
		if ( in_array( $comment_status, array( 'all', 'approved' ) ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
			$actions['unapprove'] = __( 'Unapprove' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
		if ( in_array( $comment_status, array( 'all', 'moderated' ) ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
			$actions['approve'] = __( 'Approve' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   226
		if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ) ) )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
			$actions['spam'] = _x( 'Mark as Spam', 'comment' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
		if ( 'trash' == $comment_status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
			$actions['untrash'] = __( 'Restore' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
		elseif ( 'spam' == $comment_status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
			$actions['unspam'] = _x( 'Not Spam', 'comment' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
		if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || !EMPTY_TRASH_DAYS )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
			$actions['delete'] = __( 'Delete Permanently' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
			$actions['trash'] = __( 'Move to Trash' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
		return $actions;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   242
	protected function extra_tablenav( $which ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
		global $comment_status, $comment_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
		<div class="alignleft actions">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
		if ( 'top' == $which ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   249
			<label class="screen-reader-text" for="filter-by-comment-type"><?php _e( 'Filter by comment type' ); ?></label>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   250
			<select id="filter-by-comment-type" name="comment_type">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   251
				<option value=""><?php _e( 'All comment types' ); ?></option>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
<?php
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   253
				/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   254
				 * Filter the comment types dropdown menu.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   255
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   256
				 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   257
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   258
				 * @param array $comment_types An array of comment types. Accepts 'Comments', 'Pings'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   259
				 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
				$comment_types = apply_filters( 'admin_comment_types_dropdown', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
					'comment' => __( 'Comments' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
					'pings' => __( 'Pings' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
				) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
				foreach ( $comment_types as $type => $label )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   266
					echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
			?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
			</select>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
<?php
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   270
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   271
			 * Fires just before the Filter submit button for comment types.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   272
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   273
			 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   274
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
			do_action( 'restrict_manage_comments' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   276
			submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
		if ( ( 'spam' == $comment_status || 'trash' == $comment_status ) && current_user_can( 'moderate_comments' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
			wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
			$title = ( 'spam' == $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
			submit_button( $title, 'apply', 'delete_all', false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   284
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   285
		 * Fires after the Filter submit button for comment types.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   286
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   287
		 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   288
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   289
		 * @param string $comment_status The comment status name. Default 'All'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   290
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
		do_action( 'manage_comments_nav', $comment_status );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
		echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   295
	public function current_action() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
			return 'delete_all';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
		return parent::current_action();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   302
	public function get_columns() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
		global $post_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
		$columns = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
		if ( $this->checkbox )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
			$columns['cb'] = '<input type="checkbox" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
		$columns['author'] = __( 'Author' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
		$columns['comment'] = _x( 'Comment', 'column name' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
		if ( !$post_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
			$columns['response'] = _x( 'In Response To', 'column name' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
		return $columns;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   319
	protected function get_sortable_columns() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
		return array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
			'author'   => 'comment_author',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
			'response' => 'comment_post_ID'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   326
	public function display() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
		wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
		$this->display_tablenav( 'top' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   332
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
	<thead>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
	<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
		<?php $this->print_column_headers(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
	</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
	</thead>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
	<tbody id="the-comment-list" data-wp-lists="list:comment">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
		<?php $this->display_rows_or_placeholder(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
	</tbody>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
	<tbody id="the-extra-comment-list" data-wp-lists="list:comment" style="display: none;">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
		<?php $this->items = $this->extra_items; $this->display_rows(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
	</tbody>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   346
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   347
	<tfoot>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   348
	<tr>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   349
		<?php $this->print_column_headers( false ); ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   350
	</tr>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   351
	</tfoot>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   352
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
		$this->display_tablenav( 'bottom' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   359
	public function single_row( $a_comment ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
		global $post, $comment;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
		$comment = $a_comment;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   363
		$the_comment_class = wp_get_comment_status( $comment->comment_ID );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   364
		if ( ! $the_comment_class ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   365
			$the_comment_class = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   366
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   367
		$the_comment_class = join( ' ', get_comment_class( $the_comment_class, $comment->comment_ID, $comment->comment_post_ID ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
		$post = get_post( $comment->comment_post_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
		$this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
		echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
		$this->single_row_columns( $comment );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
		echo "</tr>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   378
	public function column_cb( $comment ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
		if ( $this->user_can ) { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
		<label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
		<input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   386
	public function column_comment( $comment ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
		global $comment_status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
		$post = get_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
		$comment_url = esc_url( get_comment_link( $comment->comment_ID ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
		$the_comment_status = wp_get_comment_status( $comment->comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   393
		if ( $this->user_can ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
			$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
			$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
			$url = "comment.php?c=$comment->comment_ID";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
			$approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
			$unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
			$spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
			$unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
			$trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
			$untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
			$delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   408
		echo '<div class="comment-author">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   409
			$this->column_author( $comment );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   410
		echo '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   411
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
		echo '<div class="submitted-on">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
		/* translators: 2: comment date, 3: comment time */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
		printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
			/* translators: comment date format. See http://php.net/date */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
			get_comment_date( __( 'Y/m/d' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
			get_comment_date( get_option( 'time_format' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
		if ( $comment->comment_parent ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
			$parent = get_comment( $comment->comment_parent );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
			$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
			$name = get_comment_author( $parent->comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
			printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
		echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
		comment_text();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   429
		if ( $this->user_can ) { ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
		<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   431
		<textarea class="comment" rows="1" cols="1"><?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   432
			/** This filter is documented in wp-admin/includes/comment.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   433
			echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   434
		?></textarea>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
		<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
		<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
		<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
		<div class="comment_status"><?php echo $comment->comment_approved; ?></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   443
		if ( $this->user_can ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   444
			// Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
			$actions = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
				'approve' => '', 'unapprove' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
				'reply' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
				'quickedit' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
				'edit' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
				'spam' => '', 'unspam' => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
				'trash' => '', 'untrash' => '', 'delete' => ''
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   454
			// Not looking at all comments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   455
			if ( $comment_status && 'all' != $comment_status ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   456
				if ( 'approved' == $the_comment_status ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
					$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved' class='vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   458
				} elseif ( 'unapproved' == $the_comment_status ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
					$actions['approve'] = "<a href='$approve_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved' class='vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   460
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
				$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
				$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   466
			if ( 'spam' != $the_comment_status ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
				$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
			} elseif ( 'spam' == $the_comment_status ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
				$actions['unspam'] = "<a href='$unspam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1' class='vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   470
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   471
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   472
			if ( 'trash' == $the_comment_status ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
				$actions['untrash'] = "<a href='$untrash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1' class='vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
			if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
				$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::delete=1' class='delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
				$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
			if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
				$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   484
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   485
				$format = '<a data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s" title="%s" href="#">%s</a>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   486
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   487
				$actions['quickedit'] = sprintf( $format, $comment->comment_ID, $post->ID, 'edit', 'vim-q comment-inline',esc_attr__( 'Edit this item inline' ), __( 'Quick&nbsp;Edit' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   488
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   489
				$actions['reply'] = sprintf( $format, $comment->comment_ID, $post->ID, 'replyto', 'vim-r comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   492
			/** This filter is documented in wp-admin/includes/dashboard.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
			$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
			$i = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
			echo '<div class="row-actions">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
			foreach ( $actions as $action => $link ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
				++$i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
				( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
				// Reply and quickedit need a hide-if-no-js span when not added with ajax
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
				if ( ( 'reply' == $action || 'quickedit' == $action ) && ! defined('DOING_AJAX') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
					$action .= ' hide-if-no-js';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
				elseif ( ( $action == 'untrash' && $the_comment_status == 'trash' ) || ( $action == 'unspam' && $the_comment_status == 'spam' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
					if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
						$action .= ' approve';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
					else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
						$action .= ' unapprove';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
				echo "<span class='$action'>$sep$link</span>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
			echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   517
	public function column_author( $comment ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
		global $comment_status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
		$author_url = get_comment_author_url();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
		if ( 'http://' == $author_url )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
			$author_url = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
		$author_url_display = preg_replace( '|http://(www\.)?|i', '', $author_url );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
		if ( strlen( $author_url_display ) > 50 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
			$author_url_display = substr( $author_url_display, 0, 49 ) . '&hellip;';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
		echo "<strong>"; comment_author(); echo '</strong><br />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
		if ( !empty( $author_url ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
			echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
		if ( $this->user_can ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
			if ( !empty( $comment->comment_author_email ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
				comment_author_email_link();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
				echo '<br />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
			}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   536
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   537
			$author_ip = get_comment_author_IP();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   538
			if ( $author_ip ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   539
				$author_ip_url = add_query_arg( array( 's' => $author_ip, 'mode' => 'detail' ), 'edit-comments.php' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   540
				if ( 'spam' == $comment_status ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   541
					$author_ip_url = add_query_arg( 'comment_status', 'spam', $author_ip_url );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   542
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   543
				printf( '<a href="%s">%s</a>', esc_url( $author_ip_url ), $author_ip );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   544
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   548
	public function column_date() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   549
		return get_comment_date( __( 'Y/m/d \a\t g:i a' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   552
	public function column_response() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
		$post = get_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
		if ( isset( $this->pending_count[$post->ID] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
			$pending_comments = $this->pending_count[$post->ID];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
			$_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
			$pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
		if ( current_user_can( 'edit_post', $post->ID ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
			$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "'>";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   564
			$post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
		} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   566
			$post_link = esc_html( get_the_title( $post->ID ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
		echo '<div class="response-links"><span class="post-com-count-wrapper">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
		echo $post_link . '<br />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
		$this->comments_bubble( $post->ID, $pending_comments );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
		echo '</span> ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
		$post_type_object = get_post_type_object( $post->post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
		echo "<a href='" . get_permalink( $post->ID ) . "'>" . $post_type_object->labels->view_item . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
		echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
		if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
			echo $thumb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   580
	public function column_default( $comment, $column_name ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   581
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   582
		 * Fires when the default column output is displayed for a single row.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   583
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   584
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   585
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   586
		 * @param string $column_name         The custom column's name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   587
		 * @param int    $comment->comment_ID The custom column's unique ID number.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   588
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   589
		do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   591
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   592
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   593
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   594
 * Post Comments List Table class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   596
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
 * @subpackage List_Table
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   598
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   599
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   600
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   601
 * @see WP_Comments_Table
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   603
class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   604
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   605
	protected function get_column_info() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   606
		return array(
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
			array(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   608
				'author'   => __( 'Author' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   609
				'comment'  => _x( 'Comment', 'column name' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
			),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
			array(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
			array(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   613
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   616
	protected function get_table_classes() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
		$classes = parent::get_table_classes();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   618
		$classes[] = 'comments-box';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
		return $classes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   620
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   622
	public function display( $output_empty = false ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   623
		$singular = $this->_args['singular'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
		wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   627
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" style="display:none;">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   628
	<tbody id="the-comment-list"<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   629
		if ( $singular ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   630
			echo " data-wp-lists='list:$singular'";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   631
		} ?>>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   632
		<?php if ( ! $output_empty ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   633
			$this->display_rows_or_placeholder();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   634
		} ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   635
	</tbody>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   636
</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   638
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   640
	public function get_per_page( $comment_status = false ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
		return 10;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
}