wp/wp-admin/includes/class-wp-comments-list-table.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    43 
    43 
    44 		if ( get_option( 'show_avatars' ) ) {
    44 		if ( get_option( 'show_avatars' ) ) {
    45 			add_filter( 'comment_author', array( $this, 'floated_admin_avatar' ), 10, 2 );
    45 			add_filter( 'comment_author', array( $this, 'floated_admin_avatar' ), 10, 2 );
    46 		}
    46 		}
    47 
    47 
    48 		parent::__construct( array(
    48 		parent::__construct(
    49 			'plural' => 'comments',
    49 			array(
    50 			'singular' => 'comment',
    50 				'plural'   => 'comments',
    51 			'ajax' => true,
    51 				'singular' => 'comment',
    52 			'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
    52 				'ajax'     => true,
    53 		) );
    53 				'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
       
    54 			)
       
    55 		);
    54 	}
    56 	}
    55 
    57 
    56 	public function floated_admin_avatar( $name, $comment_ID ) {
    58 	public function floated_admin_avatar( $name, $comment_ID ) {
    57 		$comment = get_comment( $comment_ID );
    59 		$comment = get_comment( $comment_ID );
    58 		$avatar = get_avatar( $comment, 32, 'mystery' );
    60 		$avatar  = get_avatar( $comment, 32, 'mystery' );
    59 		return "$avatar $name";
    61 		return "$avatar $name";
    60 	}
    62 	}
    61 
    63 
    62 	/**
    64 	/**
    63 	 * @return bool
    65 	 * @return bool
    64 	 */
    66 	 */
    65 	public function ajax_user_can() {
    67 	public function ajax_user_can() {
    66 		return current_user_can('edit_posts');
    68 		return current_user_can( 'edit_posts' );
    67 	}
    69 	}
    68 
    70 
    69 	/**
    71 	/**
    70 	 *
       
    71 	 * @global int    $post_id
    72 	 * @global int    $post_id
    72 	 * @global string $comment_status
    73 	 * @global string $comment_status
    73 	 * @global string $search
    74 	 * @global string $search
    74 	 * @global string $comment_type
    75 	 * @global string $comment_type
    75 	 */
    76 	 */
    76 	public function prepare_items() {
    77 	public function prepare_items() {
    77 		global $post_id, $comment_status, $search, $comment_type;
    78 		global $post_id, $comment_status, $search, $comment_type;
    78 
    79 
    79 		$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
    80 		$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
    80 		if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) )
    81 		if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ) ) ) {
    81 			$comment_status = 'all';
    82 			$comment_status = 'all';
    82 
    83 		}
    83 		$comment_type = !empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
    84 
       
    85 		$comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
    84 
    86 
    85 		$search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
    87 		$search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
    86 
    88 
    87 		$post_type = ( isset( $_REQUEST['post_type'] ) ) ? sanitize_key( $_REQUEST['post_type'] ) : '';
    89 		$post_type = ( isset( $_REQUEST['post_type'] ) ) ? sanitize_key( $_REQUEST['post_type'] ) : '';
    88 
    90 
    89 		$user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : '';
    91 		$user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : '';
    90 
    92 
    91 		$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : '';
    93 		$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : '';
    92 		$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : '';
    94 		$order   = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : '';
    93 
    95 
    94 		$comments_per_page = $this->get_per_page( $comment_status );
    96 		$comments_per_page = $this->get_per_page( $comment_status );
    95 
    97 
    96 		$doing_ajax = wp_doing_ajax();
    98 		$doing_ajax = wp_doing_ajax();
    97 
    99 
    98 		if ( isset( $_REQUEST['number'] ) ) {
   100 		if ( isset( $_REQUEST['number'] ) ) {
    99 			$number = (int) $_REQUEST['number'];
   101 			$number = (int) $_REQUEST['number'];
   100 		}
   102 		} else {
   101 		else {
       
   102 			$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra
   103 			$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra
   103 		}
   104 		}
   104 
   105 
   105 		$page = $this->get_pagenum();
   106 		$page = $this->get_pagenum();
   106 
   107 
   113 		if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) {
   114 		if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) {
   114 			$start += $_REQUEST['offset'];
   115 			$start += $_REQUEST['offset'];
   115 		}
   116 		}
   116 
   117 
   117 		$status_map = array(
   118 		$status_map = array(
       
   119 			'mine'      => '',
   118 			'moderated' => 'hold',
   120 			'moderated' => 'hold',
   119 			'approved' => 'approve',
   121 			'approved'  => 'approve',
   120 			'all' => '',
   122 			'all'       => '',
   121 		);
   123 		);
   122 
   124 
   123 		$args = array(
   125 		$args = array(
   124 			'status' => isset( $status_map[$comment_status] ) ? $status_map[$comment_status] : $comment_status,
   126 			'status'    => isset( $status_map[ $comment_status ] ) ? $status_map[ $comment_status ] : $comment_status,
   125 			'search' => $search,
   127 			'search'    => $search,
   126 			'user_id' => $user_id,
   128 			'user_id'   => $user_id,
   127 			'offset' => $start,
   129 			'offset'    => $start,
   128 			'number' => $number,
   130 			'number'    => $number,
   129 			'post_id' => $post_id,
   131 			'post_id'   => $post_id,
   130 			'type' => $comment_type,
   132 			'type'      => $comment_type,
   131 			'orderby' => $orderby,
   133 			'orderby'   => $orderby,
   132 			'order' => $order,
   134 			'order'     => $order,
   133 			'post_type' => $post_type,
   135 			'post_type' => $post_type,
   134 		);
   136 		);
       
   137 
       
   138 		/**
       
   139 		 * Filters the arguments for the comment query in the comments list table.
       
   140 		 *
       
   141 		 * @since 5.1.0
       
   142 		 *
       
   143 		 * @param array $args An array of get_comments() arguments.
       
   144 		 */
       
   145 		$args = apply_filters( 'comments_list_table_query_args', $args );
   135 
   146 
   136 		$_comments = get_comments( $args );
   147 		$_comments = get_comments( $args );
   137 		if ( is_array( $_comments ) ) {
   148 		if ( is_array( $_comments ) ) {
   138 			update_comment_cache( $_comments );
   149 			update_comment_cache( $_comments );
   139 
   150 
   140 			$this->items = array_slice( $_comments, 0, $comments_per_page );
   151 			$this->items       = array_slice( $_comments, 0, $comments_per_page );
   141 			$this->extra_items = array_slice( $_comments, $comments_per_page );
   152 			$this->extra_items = array_slice( $_comments, $comments_per_page );
   142 
   153 
   143 			$_comment_post_ids = array_unique( wp_list_pluck( $_comments, 'comment_post_ID' ) );
   154 			$_comment_post_ids = array_unique( wp_list_pluck( $_comments, 'comment_post_ID' ) );
   144 
   155 
   145 			$this->pending_count = get_pending_comments_num( $_comment_post_ids );
   156 			$this->pending_count = get_pending_comments_num( $_comment_post_ids );
   146 		}
   157 		}
   147 
   158 
   148 		$total_comments = get_comments( array_merge( $args, array(
   159 		$total_comments = get_comments(
   149 			'count' => true,
   160 			array_merge(
   150 			'offset' => 0,
   161 				$args,
   151 			'number' => 0
   162 				array(
   152 		) ) );
   163 					'count'  => true,
   153 
   164 					'offset' => 0,
   154 		$this->set_pagination_args( array(
   165 					'number' => 0,
   155 			'total_items' => $total_comments,
   166 				)
   156 			'per_page' => $comments_per_page,
   167 			)
   157 		) );
   168 		);
   158 	}
   169 
   159 
   170 		$this->set_pagination_args(
   160 	/**
   171 			array(
   161 	 *
   172 				'total_items' => $total_comments,
       
   173 				'per_page'    => $comments_per_page,
       
   174 			)
       
   175 		);
       
   176 	}
       
   177 
       
   178 	/**
   162 	 * @param string $comment_status
   179 	 * @param string $comment_status
   163 	 * @return int
   180 	 * @return int
   164 	 */
   181 	 */
   165 	public function get_per_page( $comment_status = 'all' ) {
   182 	public function get_per_page( $comment_status = 'all' ) {
   166 		$comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' );
   183 		$comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' );
   174 		 */
   191 		 */
   175 		return apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
   192 		return apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
   176 	}
   193 	}
   177 
   194 
   178 	/**
   195 	/**
   179 	 *
       
   180 	 * @global string $comment_status
   196 	 * @global string $comment_status
   181 	 */
   197 	 */
   182 	public function no_items() {
   198 	public function no_items() {
   183 		global $comment_status;
   199 		global $comment_status;
   184 
   200 
   188 			_e( 'No comments found.' );
   204 			_e( 'No comments found.' );
   189 		}
   205 		}
   190 	}
   206 	}
   191 
   207 
   192 	/**
   208 	/**
   193 	 *
       
   194 	 * @global int $post_id
   209 	 * @global int $post_id
   195 	 * @global string $comment_status
   210 	 * @global string $comment_status
   196 	 * @global string $comment_type
   211 	 * @global string $comment_type
   197 	 */
   212 	 */
   198 	protected function get_views() {
   213 	protected function get_views() {
   201 		$status_links = array();
   216 		$status_links = array();
   202 		$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
   217 		$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
   203 
   218 
   204 		$stati = array(
   219 		$stati = array(
   205 			/* translators: %s: all comments count */
   220 			/* translators: %s: all comments count */
   206 			'all' => _nx_noop(
   221 			'all'       => _nx_noop(
   207 				'All <span class="count">(%s)</span>',
   222 				'All <span class="count">(%s)</span>',
   208 				'All <span class="count">(%s)</span>',
   223 				'All <span class="count">(%s)</span>',
   209 				'comments'
   224 				'comments'
   210 			), // singular not used
   225 			), // singular not used
       
   226 
       
   227 			/* translators: %s: current user's comments count */
       
   228 			'mine'      => _nx_noop(
       
   229 				'Mine <span class="count">(%s)</span>',
       
   230 				'Mine <span class="count">(%s)</span>',
       
   231 				'comments'
       
   232 			),
   211 
   233 
   212 			/* translators: %s: pending comments count */
   234 			/* translators: %s: pending comments count */
   213 			'moderated' => _nx_noop(
   235 			'moderated' => _nx_noop(
   214 				'Pending <span class="count">(%s)</span>',
   236 				'Pending <span class="count">(%s)</span>',
   215 				'Pending <span class="count">(%s)</span>',
   237 				'Pending <span class="count">(%s)</span>',
   216 				'comments'
   238 				'comments'
   217 			),
   239 			),
   218 
   240 
   219 			/* translators: %s: approved comments count */
   241 			/* translators: %s: approved comments count */
   220 			'approved' => _nx_noop(
   242 			'approved'  => _nx_noop(
   221 				'Approved <span class="count">(%s)</span>',
   243 				'Approved <span class="count">(%s)</span>',
   222 				'Approved <span class="count">(%s)</span>',
   244 				'Approved <span class="count">(%s)</span>',
   223 				'comments'
   245 				'comments'
   224 			),
   246 			),
   225 
   247 
   226 			/* translators: %s: spam comments count */
   248 			/* translators: %s: spam comments count */
   227 			'spam' => _nx_noop(
   249 			'spam'      => _nx_noop(
   228 				'Spam <span class="count">(%s)</span>',
   250 				'Spam <span class="count">(%s)</span>',
   229 				'Spam <span class="count">(%s)</span>',
   251 				'Spam <span class="count">(%s)</span>',
   230 				'comments'
   252 				'comments'
   231 			),
   253 			),
   232 
   254 
   233 			/* translators: %s: trashed comments count */
   255 			/* translators: %s: trashed comments count */
   234 			'trash' => _nx_noop(
   256 			'trash'     => _nx_noop(
   235 				'Trash <span class="count">(%s)</span>',
   257 				'Trash <span class="count">(%s)</span>',
   236 				'Trash <span class="count">(%s)</span>',
   258 				'Trash <span class="count">(%s)</span>',
   237 				'comments'
   259 				'comments'
   238 			)
   260 			),
   239 		);
   261 		);
   240 
   262 
   241 		if ( !EMPTY_TRASH_DAYS )
   263 		if ( ! EMPTY_TRASH_DAYS ) {
   242 			unset($stati['trash']);
   264 			unset( $stati['trash'] );
       
   265 		}
   243 
   266 
   244 		$link = admin_url( 'edit-comments.php' );
   267 		$link = admin_url( 'edit-comments.php' );
   245 		if ( !empty($comment_type) && 'all' != $comment_type )
   268 		if ( ! empty( $comment_type ) && 'all' != $comment_type ) {
   246 			$link = add_query_arg( 'comment_type', $comment_type, $link );
   269 			$link = add_query_arg( 'comment_type', $comment_type, $link );
       
   270 		}
   247 
   271 
   248 		foreach ( $stati as $status => $label ) {
   272 		foreach ( $stati as $status => $label ) {
   249 			$current_link_attributes = '';
   273 			$current_link_attributes = '';
   250 
   274 
   251 			if ( $status === $comment_status ) {
   275 			if ( $status === $comment_status ) {
   252 				$current_link_attributes = ' class="current" aria-current="page"';
   276 				$current_link_attributes = ' class="current" aria-current="page"';
   253 			}
   277 			}
   254 
   278 
   255 			if ( !isset( $num_comments->$status ) )
   279 			if ( 'mine' === $status ) {
       
   280 				$current_user_id    = get_current_user_id();
       
   281 				$num_comments->mine = get_comments(
       
   282 					array(
       
   283 						'post_id' => $post_id ? $post_id : 0,
       
   284 						'user_id' => $current_user_id,
       
   285 						'count'   => true,
       
   286 					)
       
   287 				);
       
   288 				$link               = add_query_arg( 'user_id', $current_user_id, $link );
       
   289 			} else {
       
   290 				$link = remove_query_arg( 'user_id', $link );
       
   291 			}
       
   292 
       
   293 			if ( ! isset( $num_comments->$status ) ) {
   256 				$num_comments->$status = 10;
   294 				$num_comments->$status = 10;
       
   295 			}
   257 			$link = add_query_arg( 'comment_status', $status, $link );
   296 			$link = add_query_arg( 'comment_status', $status, $link );
   258 			if ( $post_id )
   297 			if ( $post_id ) {
   259 				$link = add_query_arg( 'p', absint( $post_id ), $link );
   298 				$link = add_query_arg( 'p', absint( $post_id ), $link );
       
   299 			}
   260 			/*
   300 			/*
   261 			// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
   301 			// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
   262 			if ( !empty( $_REQUEST['s'] ) )
   302 			if ( !empty( $_REQUEST['s'] ) )
   263 				$link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link );
   303 				$link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link );
   264 			*/
   304 			*/
   265 			$status_links[ $status ] = "<a href='$link'$current_link_attributes>" . sprintf(
   305 			$status_links[ $status ] = "<a href='$link'$current_link_attributes>" . sprintf(
   266 				translate_nooped_plural( $label, $num_comments->$status ),
   306 				translate_nooped_plural( $label, $num_comments->$status ),
   267 				sprintf( '<span class="%s-count">%s</span>',
   307 				sprintf(
       
   308 					'<span class="%s-count">%s</span>',
   268 					( 'moderated' === $status ) ? 'pending' : $status,
   309 					( 'moderated' === $status ) ? 'pending' : $status,
   269 					number_format_i18n( $num_comments->$status )
   310 					number_format_i18n( $num_comments->$status )
   270 				)
   311 				)
   271 			) . '</a>';
   312 			) . '</a>';
   272 		}
   313 		}
   273 
   314 
   274 		/**
   315 		/**
   275 		 * Filters the comment status links.
   316 		 * Filters the comment status links.
   276 		 *
   317 		 *
   277 		 * @since 2.5.0
   318 		 * @since 2.5.0
   278 		 *
   319 		 * @since 5.1.0 The 'Mine' link was added.
   279 		 * @param array $status_links An array of fully-formed status links. Default 'All'.
   320 		 *
   280 		 *                            Accepts 'All', 'Pending', 'Approved', 'Spam', and 'Trash'.
   321 		 * @param string[] $status_links An associative array of fully-formed comment status links. Includes 'All', 'Mine',
       
   322 		 *                              'Pending', 'Approved', 'Spam', and 'Trash'.
   281 		 */
   323 		 */
   282 		return apply_filters( 'comment_status_links', $status_links );
   324 		return apply_filters( 'comment_status_links', $status_links );
   283 	}
   325 	}
   284 
   326 
   285 	/**
   327 	/**
   286 	 *
       
   287 	 * @global string $comment_status
   328 	 * @global string $comment_status
   288 	 *
   329 	 *
   289 	 * @return array
   330 	 * @return array
   290 	 */
   331 	 */
   291 	protected function get_bulk_actions() {
   332 	protected function get_bulk_actions() {
   292 		global $comment_status;
   333 		global $comment_status;
   293 
   334 
   294 		$actions = array();
   335 		$actions = array();
   295 		if ( in_array( $comment_status, array( 'all', 'approved' ) ) )
   336 		if ( in_array( $comment_status, array( 'all', 'approved' ) ) ) {
   296 			$actions['unapprove'] = __( 'Unapprove' );
   337 			$actions['unapprove'] = __( 'Unapprove' );
   297 		if ( in_array( $comment_status, array( 'all', 'moderated' ) ) )
   338 		}
       
   339 		if ( in_array( $comment_status, array( 'all', 'moderated' ) ) ) {
   298 			$actions['approve'] = __( 'Approve' );
   340 			$actions['approve'] = __( 'Approve' );
   299 		if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ) ) )
   341 		}
       
   342 		if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ) ) ) {
   300 			$actions['spam'] = _x( 'Mark as Spam', 'comment' );
   343 			$actions['spam'] = _x( 'Mark as Spam', 'comment' );
       
   344 		}
   301 
   345 
   302 		if ( 'trash' === $comment_status ) {
   346 		if ( 'trash' === $comment_status ) {
   303 			$actions['untrash'] = __( 'Restore' );
   347 			$actions['untrash'] = __( 'Restore' );
   304 		} elseif ( 'spam' === $comment_status ) {
   348 		} elseif ( 'spam' === $comment_status ) {
   305 			$actions['unspam'] = _x( 'Not Spam', 'comment' );
   349 			$actions['unspam'] = _x( 'Not Spam', 'comment' );
   306 		}
   350 		}
   307 
   351 
   308 		if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || !EMPTY_TRASH_DAYS )
   352 		if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || ! EMPTY_TRASH_DAYS ) {
   309 			$actions['delete'] = __( 'Delete Permanently' );
   353 			$actions['delete'] = __( 'Delete Permanently' );
   310 		else
   354 		} else {
   311 			$actions['trash'] = __( 'Move to Trash' );
   355 			$actions['trash'] = __( 'Move to Trash' );
       
   356 		}
   312 
   357 
   313 		return $actions;
   358 		return $actions;
   314 	}
   359 	}
   315 
   360 
   316 	/**
   361 	/**
   317 	 *
       
   318 	 * @global string $comment_status
   362 	 * @global string $comment_status
   319 	 * @global string $comment_type
   363 	 * @global string $comment_type
   320 	 *
   364 	 *
   321 	 * @param string $which
   365 	 * @param string $which
   322 	 */
   366 	 */
   325 		static $has_items;
   369 		static $has_items;
   326 
   370 
   327 		if ( ! isset( $has_items ) ) {
   371 		if ( ! isset( $has_items ) ) {
   328 			$has_items = $this->has_items();
   372 			$has_items = $this->has_items();
   329 		}
   373 		}
   330 ?>
   374 		?>
   331 		<div class="alignleft actions">
   375 		<div class="alignleft actions">
   332 <?php
   376 		<?php
   333 		if ( 'top' === $which ) {
   377 		if ( 'top' === $which ) {
   334 ?>
   378 			?>
   335 			<label class="screen-reader-text" for="filter-by-comment-type"><?php _e( 'Filter by comment type' ); ?></label>
   379 	<label class="screen-reader-text" for="filter-by-comment-type"><?php _e( 'Filter by comment type' ); ?></label>
   336 			<select id="filter-by-comment-type" name="comment_type">
   380 	<select id="filter-by-comment-type" name="comment_type">
   337 				<option value=""><?php _e( 'All comment types' ); ?></option>
   381 		<option value=""><?php _e( 'All comment types' ); ?></option>
   338 <?php
   382 			<?php
   339 				/**
   383 				/**
   340 				 * Filters the comment types dropdown menu.
   384 				 * Filters the comment types dropdown menu.
   341 				 *
   385 				 *
   342 				 * @since 2.7.0
   386 				 * @since 2.7.0
   343 				 *
   387 				 *
   344 				 * @param array $comment_types An array of comment types. Accepts 'Comments', 'Pings'.
   388 				 * @param string[] $comment_types An array of comment types. Accepts 'Comments', 'Pings'.
   345 				 */
   389 				 */
   346 				$comment_types = apply_filters( 'admin_comment_types_dropdown', array(
   390 				$comment_types = apply_filters(
   347 					'comment' => __( 'Comments' ),
   391 					'admin_comment_types_dropdown',
   348 					'pings' => __( 'Pings' ),
   392 					array(
   349 				) );
   393 						'comment' => __( 'Comments' ),
   350 
   394 						'pings'   => __( 'Pings' ),
   351 				foreach ( $comment_types as $type => $label )
   395 					)
   352 					echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n";
   396 				);
       
   397 
       
   398 			foreach ( $comment_types as $type => $label ) {
       
   399 				echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n";
       
   400 			}
   353 			?>
   401 			?>
   354 			</select>
   402 	</select>
   355 <?php
   403 			<?php
   356 			/**
   404 			/**
   357 			 * Fires just before the Filter submit button for comment types.
   405 			 * Fires just before the Filter submit button for comment types.
   358 			 *
   406 			 *
   359 			 * @since 3.5.0
   407 			 * @since 3.5.0
   360 			 */
   408 			 */
   380 
   428 
   381 	/**
   429 	/**
   382 	 * @return string|false
   430 	 * @return string|false
   383 	 */
   431 	 */
   384 	public function current_action() {
   432 	public function current_action() {
   385 		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
   433 		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
   386 			return 'delete_all';
   434 			return 'delete_all';
       
   435 		}
   387 
   436 
   388 		return parent::current_action();
   437 		return parent::current_action();
   389 	}
   438 	}
   390 
   439 
   391 	/**
   440 	/**
   392 	 *
       
   393 	 * @global int $post_id
   441 	 * @global int $post_id
   394 	 *
   442 	 *
   395 	 * @return array
   443 	 * @return array
   396 	 */
   444 	 */
   397 	public function get_columns() {
   445 	public function get_columns() {
   398 		global $post_id;
   446 		global $post_id;
   399 
   447 
   400 		$columns = array();
   448 		$columns = array();
   401 
   449 
   402 		if ( $this->checkbox )
   450 		if ( $this->checkbox ) {
   403 			$columns['cb'] = '<input type="checkbox" />';
   451 			$columns['cb'] = '<input type="checkbox" />';
   404 
   452 		}
   405 		$columns['author'] = __( 'Author' );
   453 
       
   454 		$columns['author']  = __( 'Author' );
   406 		$columns['comment'] = _x( 'Comment', 'column name' );
   455 		$columns['comment'] = _x( 'Comment', 'column name' );
   407 
   456 
   408 		if ( ! $post_id ) {
   457 		if ( ! $post_id ) {
   409 			/* translators: column name or table row header */
   458 			/* translators: column name or table row header */
   410 			$columns['response'] = __( 'In Response To' );
   459 			$columns['response'] = __( 'In Response To' );
   414 
   463 
   415 		return $columns;
   464 		return $columns;
   416 	}
   465 	}
   417 
   466 
   418 	/**
   467 	/**
   419 	 *
       
   420 	 * @return array
   468 	 * @return array
   421 	 */
   469 	 */
   422 	protected function get_sortable_columns() {
   470 	protected function get_sortable_columns() {
   423 		return array(
   471 		return array(
   424 			'author'   => 'comment_author',
   472 			'author'   => 'comment_author',
   425 			'response' => 'comment_post_ID',
   473 			'response' => 'comment_post_ID',
   426 			'date'     => 'comment_date'
   474 			'date'     => 'comment_date',
   427 		);
   475 		);
   428 	}
   476 	}
   429 
   477 
   430 	/**
   478 	/**
   431 	 * Get the name of the default primary column.
   479 	 * Get the name of the default primary column.
   439 	}
   487 	}
   440 
   488 
   441 	/**
   489 	/**
   442 	 */
   490 	 */
   443 	public function display() {
   491 	public function display() {
   444 		wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
   492 		wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
   445 
   493 
   446 		$this->display_tablenav( 'top' );
   494 		$this->display_tablenav( 'top' );
   447 
   495 
   448 		$this->screen->render_screen_reader_content( 'heading_list' );
   496 		$this->screen->render_screen_reader_content( 'heading_list' );
   449 
   497 
   450 ?>
   498 		?>
   451 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
   499 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
   452 	<thead>
   500 	<thead>
   453 	<tr>
   501 	<tr>
   454 		<?php $this->print_column_headers(); ?>
   502 		<?php $this->print_column_headers(); ?>
   455 	</tr>
   503 	</tr>
   459 		<?php $this->display_rows_or_placeholder(); ?>
   507 		<?php $this->display_rows_or_placeholder(); ?>
   460 	</tbody>
   508 	</tbody>
   461 
   509 
   462 	<tbody id="the-extra-comment-list" data-wp-lists="list:comment" style="display: none;">
   510 	<tbody id="the-extra-comment-list" data-wp-lists="list:comment" style="display: none;">
   463 		<?php
   511 		<?php
       
   512 			/*
       
   513 			 * Back up the items to restore after printing the extra items markup.
       
   514 			 * The extra items may be empty, which will prevent the table nav from displaying later.
       
   515 			 */
       
   516 			$items       = $this->items;
   464 			$this->items = $this->extra_items;
   517 			$this->items = $this->extra_items;
   465 			$this->display_rows_or_placeholder();
   518 			$this->display_rows_or_placeholder();
       
   519 			$this->items = $items;
   466 		?>
   520 		?>
   467 	</tbody>
   521 	</tbody>
   468 
   522 
   469 	<tfoot>
   523 	<tfoot>
   470 	<tr>
   524 	<tr>
   471 		<?php $this->print_column_headers( false ); ?>
   525 		<?php $this->print_column_headers( false ); ?>
   472 	</tr>
   526 	</tr>
   473 	</tfoot>
   527 	</tfoot>
   474 
   528 
   475 </table>
   529 </table>
   476 <?php
   530 		<?php
   477 
   531 
   478 		$this->display_tablenav( 'bottom' );
   532 		$this->display_tablenav( 'bottom' );
   479 	}
   533 	}
   480 
   534 
   481 	/**
   535 	/**
   505 		echo "</tr>\n";
   559 		echo "</tr>\n";
   506 
   560 
   507 		unset( $GLOBALS['post'], $GLOBALS['comment'] );
   561 		unset( $GLOBALS['post'], $GLOBALS['comment'] );
   508 	}
   562 	}
   509 
   563 
   510  	/**
   564 	/**
   511  	 * Generate and display row actions links.
   565 	 * Generate and display row actions links.
   512  	 *
   566 	 *
   513  	 * @since 4.3.0
   567 	 * @since 4.3.0
   514  	 *
   568 	 *
   515  	 * @global string $comment_status Status for the current listed comments.
   569 	 * @global string $comment_status Status for the current listed comments.
   516  	 *
   570 	 *
   517  	 * @param WP_Comment $comment     The comment object.
   571 	 * @param WP_Comment $comment     The comment object.
   518  	 * @param string     $column_name Current column name.
   572 	 * @param string     $column_name Current column name.
   519  	 * @param string     $primary     Primary column name.
   573 	 * @param string     $primary     Primary column name.
   520  	 * @return string|void Comment row actions output.
   574 	 * @return string|void Comment row actions output.
   521  	 */
   575 	 */
   522  	protected function handle_row_actions( $comment, $column_name, $primary ) {
   576 	protected function handle_row_actions( $comment, $column_name, $primary ) {
   523  		global $comment_status;
   577 		global $comment_status;
   524 
   578 
   525 		if ( $primary !== $column_name ) {
   579 		if ( $primary !== $column_name ) {
   526 			return '';
   580 			return '';
   527 		}
   581 		}
   528 
   582 
   529  		if ( ! $this->user_can ) {
   583 		if ( ! $this->user_can ) {
   530  			return;
   584 			return;
   531 		}
   585 		}
   532 
   586 
   533 		$the_comment_status = wp_get_comment_status( $comment );
   587 		$the_comment_status = wp_get_comment_status( $comment );
   534 
   588 
   535 		$out = '';
   589 		$out = '';
   536 
   590 
   537 		$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
   591 		$del_nonce     = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
   538 		$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
   592 		$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
   539 
   593 
   540 		$url = "comment.php?c=$comment->comment_ID";
   594 		$url = "comment.php?c=$comment->comment_ID";
   541 
   595 
   542 		$approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
   596 		$approve_url   = esc_url( $url . "&action=approvecomment&$approve_nonce" );
   543 		$unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
   597 		$unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
   544 		$spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
   598 		$spam_url      = esc_url( $url . "&action=spamcomment&$del_nonce" );
   545 		$unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
   599 		$unspam_url    = esc_url( $url . "&action=unspamcomment&$del_nonce" );
   546 		$trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
   600 		$trash_url     = esc_url( $url . "&action=trashcomment&$del_nonce" );
   547 		$untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
   601 		$untrash_url   = esc_url( $url . "&action=untrashcomment&$del_nonce" );
   548 		$delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
   602 		$delete_url    = esc_url( $url . "&action=deletecomment&$del_nonce" );
   549 
   603 
   550 		// Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.
   604 		// Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.
   551 		$actions = array(
   605 		$actions = array(
   552 			'approve' => '', 'unapprove' => '',
   606 			'approve'   => '',
   553 			'reply' => '',
   607 			'unapprove' => '',
       
   608 			'reply'     => '',
   554 			'quickedit' => '',
   609 			'quickedit' => '',
   555 			'edit' => '',
   610 			'edit'      => '',
   556 			'spam' => '', 'unspam' => '',
   611 			'spam'      => '',
   557 			'trash' => '', 'untrash' => '', 'delete' => ''
   612 			'unspam'    => '',
       
   613 			'trash'     => '',
       
   614 			'untrash'   => '',
       
   615 			'delete'    => '',
   558 		);
   616 		);
   559 
   617 
   560 		// Not looking at all comments.
   618 		// Not looking at all comments.
   561 		if ( $comment_status && 'all' != $comment_status ) {
   619 		if ( $comment_status && 'all' != $comment_status ) {
   562 			if ( 'approved' === $the_comment_status ) {
   620 			if ( 'approved' === $the_comment_status ) {
   563 				$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' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
   621 				$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 aria-button-if-js' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
   564 			} elseif ( 'unapproved' === $the_comment_status ) {
   622 			} elseif ( 'unapproved' === $the_comment_status ) {
   565 				$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' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
   623 				$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 aria-button-if-js' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
   566 			}
   624 			}
   567 		} else {
   625 		} else {
   568 			$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' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
   626 			$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 aria-button-if-js' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
   569 			$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' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
   627 			$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 aria-button-if-js' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
   570 		}
   628 		}
   571 
   629 
   572 		if ( 'spam' !== $the_comment_status ) {
   630 		if ( 'spam' !== $the_comment_status ) {
   573 			$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
   631 			$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive aria-button-if-js' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
   574 		} elseif ( 'spam' === $the_comment_status ) {
   632 		} elseif ( 'spam' === $the_comment_status ) {
   575 			$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' aria-label='" . esc_attr__( 'Restore this comment from the spam' ) . "'>" . _x( 'Not Spam', 'comment' ) . '</a>';
   633 			$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 aria-button-if-js' aria-label='" . esc_attr__( 'Restore this comment from the spam' ) . "'>" . _x( 'Not Spam', 'comment' ) . '</a>';
   576 		}
   634 		}
   577 
   635 
   578 		if ( 'trash' === $the_comment_status ) {
   636 		if ( 'trash' === $the_comment_status ) {
   579 			$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' aria-label='" . esc_attr__( 'Restore this comment from the Trash' ) . "'>" . __( 'Restore' ) . '</a>';
   637 			$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 aria-button-if-js' aria-label='" . esc_attr__( 'Restore this comment from the Trash' ) . "'>" . __( 'Restore' ) . '</a>';
   580 		}
   638 		}
   581 
   639 
   582 		if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || !EMPTY_TRASH_DAYS ) {
   640 		if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) {
   583 			$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' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
   641 			$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 aria-button-if-js' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
   584 		} else {
   642 		} else {
   585 			$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' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
   643 			$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 aria-button-if-js' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
   586 		}
   644 		}
   587 
   645 
   588 		if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) {
   646 		if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) {
   589 			$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>". __( 'Edit' ) . '</a>';
   647 			$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>';
   590 
   648 
   591 			$format = '<a data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s" aria-label="%s" href="#">%s</a>';
   649 			$format = '<button type="button" data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s button-link" aria-expanded="false" aria-label="%s">%s</button>';
   592 
   650 
   593 			$actions['quickedit'] = sprintf( $format, $comment->comment_ID, $comment->comment_post_ID, 'edit', 'vim-q comment-inline', esc_attr__( 'Quick edit this comment inline' ), __( 'Quick&nbsp;Edit' ) );
   651 			$actions['quickedit'] = sprintf( $format, $comment->comment_ID, $comment->comment_post_ID, 'edit', 'vim-q comment-inline', esc_attr__( 'Quick edit this comment inline' ), __( 'Quick&nbsp;Edit' ) );
   594 
   652 
   595 			$actions['reply'] = sprintf( $format, $comment->comment_ID, $comment->comment_post_ID, 'replyto', 'vim-r comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) );
   653 			$actions['reply'] = sprintf( $format, $comment->comment_ID, $comment->comment_post_ID, 'replyto', 'vim-r comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) );
   596 		}
   654 		}
   597 
   655 
   598 		/** This filter is documented in wp-admin/includes/dashboard.php */
   656 		/** This filter is documented in wp-admin/includes/dashboard.php */
   599 		$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
   657 		$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
   600 
   658 
   601 		$i = 0;
   659 		$i    = 0;
   602 		$out .= '<div class="row-actions">';
   660 		$out .= '<div class="row-actions">';
   603 		foreach ( $actions as $action => $link ) {
   661 		foreach ( $actions as $action => $link ) {
   604 			++$i;
   662 			++$i;
   605 			( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
   663 			( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
   606 
   664 
   607 			// Reply and quickedit need a hide-if-no-js span when not added with ajax
   665 			// Reply and quickedit need a hide-if-no-js span when not added with ajax
   608 			if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() )
   666 			if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) {
   609 				$action .= ' hide-if-no-js';
   667 				$action .= ' hide-if-no-js';
   610 			elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) {
   668 			} elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) {
   611 				if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
   669 				if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) {
   612 					$action .= ' approve';
   670 					$action .= ' approve';
   613 				else
   671 				} else {
   614 					$action .= ' unapprove';
   672 					$action .= ' unapprove';
       
   673 				}
   615 			}
   674 			}
   616 
   675 
   617 			$out .= "<span class='$action'>$sep$link</span>";
   676 			$out .= "<span class='$action'>$sep$link</span>";
   618 		}
   677 		}
   619 		$out .= '</div>';
   678 		$out .= '</div>';
   622 
   681 
   623 		return $out;
   682 		return $out;
   624 	}
   683 	}
   625 
   684 
   626 	/**
   685 	/**
   627 	 *
       
   628 	 * @param WP_Comment $comment The comment object.
   686 	 * @param WP_Comment $comment The comment object.
   629 	 */
   687 	 */
   630 	public function column_cb( $comment ) {
   688 	public function column_cb( $comment ) {
   631 		if ( $this->user_can ) { ?>
   689 		if ( $this->user_can ) {
       
   690 			?>
   632 		<label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label>
   691 		<label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label>
   633 		<input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
   692 		<input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
   634 		<?php
   693 			<?php
   635 		}
   694 		}
   636 	}
   695 	}
   637 
   696 
   638 	/**
   697 	/**
   639 	 * @param WP_Comment $comment The comment object.
   698 	 * @param WP_Comment $comment The comment object.
   645 
   704 
   646 		if ( $comment->comment_parent ) {
   705 		if ( $comment->comment_parent ) {
   647 			$parent = get_comment( $comment->comment_parent );
   706 			$parent = get_comment( $comment->comment_parent );
   648 			if ( $parent ) {
   707 			if ( $parent ) {
   649 				$parent_link = esc_url( get_comment_link( $parent ) );
   708 				$parent_link = esc_url( get_comment_link( $parent ) );
   650 				$name = get_comment_author( $parent );
   709 				$name        = get_comment_author( $parent );
   651 				printf(
   710 				printf(
   652 					/* translators: %s: comment link */
   711 					/* translators: %s: comment link */
   653 					__( 'In reply to %s.' ),
   712 					__( 'In reply to %s.' ),
   654 					'<a href="' . $parent_link . '">' . $name . '</a>'
   713 					'<a href="' . $parent_link . '">' . $name . '</a>'
   655 				);
   714 				);
   656 			}
   715 			}
   657 		}
   716 		}
   658 
   717 
   659 		comment_text( $comment );
   718 		comment_text( $comment );
   660 		if ( $this->user_can ) { ?>
   719 
       
   720 		if ( $this->user_can ) {
       
   721 			/** This filter is documented in wp-admin/includes/comment.php */
       
   722 			$comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content );
       
   723 			?>
   661 		<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
   724 		<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
   662 		<textarea class="comment" rows="1" cols="1"><?php
   725 			<textarea class="comment" rows="1" cols="1"><?php echo esc_textarea( $comment_content ); ?></textarea>
   663 			/** This filter is documented in wp-admin/includes/comment.php */
   726 			<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
   664 			echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) );
   727 			<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
   665 		?></textarea>
   728 			<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
   666 		<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
   729 			<div class="comment_status"><?php echo $comment->comment_approved; ?></div>
   667 		<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
       
   668 		<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
       
   669 		<div class="comment_status"><?php echo $comment->comment_approved; ?></div>
       
   670 		</div>
   730 		</div>
   671 		<?php
   731 			<?php
   672 		}
   732 		}
   673 	}
   733 	}
   674 
   734 
   675 	/**
   735 	/**
   676 	 *
       
   677 	 * @global string $comment_status
   736 	 * @global string $comment_status
   678 	 *
   737 	 *
   679 	 * @param WP_Comment $comment The comment object.
   738 	 * @param WP_Comment $comment The comment object.
   680 	 */
   739 	 */
   681 	public function column_author( $comment ) {
   740 	public function column_author( $comment ) {
   686 		$author_url_display = untrailingslashit( preg_replace( '|^http(s)?://(www\.)?|i', '', $author_url ) );
   745 		$author_url_display = untrailingslashit( preg_replace( '|^http(s)?://(www\.)?|i', '', $author_url ) );
   687 		if ( strlen( $author_url_display ) > 50 ) {
   746 		if ( strlen( $author_url_display ) > 50 ) {
   688 			$author_url_display = wp_html_excerpt( $author_url_display, 49, '&hellip;' );
   747 			$author_url_display = wp_html_excerpt( $author_url_display, 49, '&hellip;' );
   689 		}
   748 		}
   690 
   749 
   691 		echo "<strong>"; comment_author( $comment ); echo '</strong><br />';
   750 		echo '<strong>';
       
   751 		comment_author( $comment );
       
   752 		echo '</strong><br />';
   692 		if ( ! empty( $author_url_display ) ) {
   753 		if ( ! empty( $author_url_display ) ) {
   693 			printf( '<a href="%s">%s</a><br />', esc_url( $author_url ), esc_html( $author_url_display ) );
   754 			printf( '<a href="%s">%s</a><br />', esc_url( $author_url ), esc_html( $author_url_display ) );
   694 		}
   755 		}
   695 
   756 
   696 		if ( $this->user_can ) {
   757 		if ( $this->user_can ) {
   703 				}
   764 				}
   704 			}
   765 			}
   705 
   766 
   706 			$author_ip = get_comment_author_IP( $comment );
   767 			$author_ip = get_comment_author_IP( $comment );
   707 			if ( $author_ip ) {
   768 			if ( $author_ip ) {
   708 				$author_ip_url = add_query_arg( array( 's' => $author_ip, 'mode' => 'detail' ), admin_url( 'edit-comments.php' ) );
   769 				$author_ip_url = add_query_arg(
       
   770 					array(
       
   771 						's'    => $author_ip,
       
   772 						'mode' => 'detail',
       
   773 					),
       
   774 					admin_url( 'edit-comments.php' )
       
   775 				);
   709 				if ( 'spam' === $comment_status ) {
   776 				if ( 'spam' === $comment_status ) {
   710 					$author_ip_url = add_query_arg( 'comment_status', 'spam', $author_ip_url );
   777 					$author_ip_url = add_query_arg( 'comment_status', 'spam', $author_ip_url );
   711 				}
   778 				}
   712 				printf( '<a href="%1$s">%2$s</a>', esc_url( $author_ip_url ), esc_html( $author_ip ) );
   779 				printf( '<a href="%1$s">%2$s</a>', esc_url( $author_ip_url ), esc_html( $author_ip ) );
   713 			}
   780 			}
   714 		}
   781 		}
   715 	}
   782 	}
   716 
   783 
   717 	/**
   784 	/**
   718 	 *
       
   719 	 * @param WP_Comment $comment The comment object.
   785 	 * @param WP_Comment $comment The comment object.
   720 	 */
   786 	 */
   721 	public function column_date( $comment ) {
   787 	public function column_date( $comment ) {
   722 		/* translators: 1: comment date, 2: comment time */
   788 		/* translators: 1: comment date, 2: comment time */
   723 		$submitted = sprintf( __( '%1$s at %2$s' ),
   789 		$submitted = sprintf(
       
   790 			__( '%1$s at %2$s' ),
   724 			/* translators: comment date format. See https://secure.php.net/date */
   791 			/* translators: comment date format. See https://secure.php.net/date */
   725 			get_comment_date( __( 'Y/m/d' ), $comment ),
   792 			get_comment_date( __( 'Y/m/d' ), $comment ),
   726 			get_comment_date( __( 'g:i a' ), $comment )
   793 			get_comment_date( __( 'g:i a' ), $comment )
   727 		);
   794 		);
   728 
   795 
   729 		echo '<div class="submitted-on">';
   796 		echo '<div class="submitted-on">';
   730 		if ( 'approved' === wp_get_comment_status( $comment ) && ! empty ( $comment->comment_post_ID ) ) {
   797 		if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
   731 			printf(
   798 			printf(
   732 				'<a href="%s">%s</a>',
   799 				'<a href="%s">%s</a>',
   733 				esc_url( get_comment_link( $comment ) ),
   800 				esc_url( get_comment_link( $comment ) ),
   734 				$submitted
   801 				$submitted
   735 			);
   802 			);
   738 		}
   805 		}
   739 		echo '</div>';
   806 		echo '</div>';
   740 	}
   807 	}
   741 
   808 
   742 	/**
   809 	/**
   743 	 *
       
   744 	 * @param WP_Comment $comment The comment object.
   810 	 * @param WP_Comment $comment The comment object.
   745 	 */
   811 	 */
   746 	public function column_response( $comment ) {
   812 	public function column_response( $comment ) {
   747 		$post = get_post();
   813 		$post = get_post();
   748 
   814 
   749 		if ( ! $post ) {
   815 		if ( ! $post ) {
   750 			return;
   816 			return;
   751 		}
   817 		}
   752 
   818 
   753 		if ( isset( $this->pending_count[$post->ID] ) ) {
   819 		if ( isset( $this->pending_count[ $post->ID ] ) ) {
   754 			$pending_comments = $this->pending_count[$post->ID];
   820 			$pending_comments = $this->pending_count[ $post->ID ];
   755 		} else {
   821 		} else {
   756 			$_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
   822 			$_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
   757 			$pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID];
   823 			$pending_comments    = $this->pending_count[ $post->ID ] = $_pending_count_temp[ $post->ID ];
   758 		}
   824 		}
   759 
   825 
   760 		if ( current_user_can( 'edit_post', $post->ID ) ) {
   826 		if ( current_user_can( 'edit_post', $post->ID ) ) {
   761 			$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>";
   827 			$post_link  = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>";
   762 			$post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>';
   828 			$post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>';
   763 		} else {
   829 		} else {
   764 			$post_link = esc_html( get_the_title( $post->ID ) );
   830 			$post_link = esc_html( get_the_title( $post->ID ) );
   765 		}
   831 		}
   766 
   832 
   776 		echo '</span> ';
   842 		echo '</span> ';
   777 		echo '</div>';
   843 		echo '</div>';
   778 	}
   844 	}
   779 
   845 
   780 	/**
   846 	/**
   781 	 *
       
   782 	 * @param WP_Comment $comment     The comment object.
   847 	 * @param WP_Comment $comment     The comment object.
   783 	 * @param string     $column_name The custom column's name.
   848 	 * @param string     $column_name The custom column's name.
   784 	 */
   849 	 */
   785 	public function column_default( $comment, $column_name ) {
   850 	public function column_default( $comment, $column_name ) {
   786 		/**
   851 		/**