wp/wp-admin/includes/class-wp-comments-list-table.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    53 				'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
    53 				'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
    54 			)
    54 			)
    55 		);
    55 		);
    56 	}
    56 	}
    57 
    57 
       
    58 	/**
       
    59 	 * Adds avatars to comment author names.
       
    60 	 *
       
    61 	 * @since 3.1.0
       
    62 	 *
       
    63 	 * @param string $name       Comment author name.
       
    64 	 * @param int    $comment_ID Comment ID.
       
    65 	 * @return string Avatar with the user name.
       
    66 	 */
    58 	public function floated_admin_avatar( $name, $comment_ID ) {
    67 	public function floated_admin_avatar( $name, $comment_ID ) {
    59 		$comment = get_comment( $comment_ID );
    68 		$comment = get_comment( $comment_ID );
    60 		$avatar  = get_avatar( $comment, 32, 'mystery' );
    69 		$avatar  = get_avatar( $comment, 32, 'mystery' );
    61 		return "$avatar $name";
    70 		return "$avatar $name";
    62 	}
    71 	}
    67 	public function ajax_user_can() {
    76 	public function ajax_user_can() {
    68 		return current_user_can( 'edit_posts' );
    77 		return current_user_can( 'edit_posts' );
    69 	}
    78 	}
    70 
    79 
    71 	/**
    80 	/**
       
    81 	 * @global string $mode           List table view mode.
    72 	 * @global int    $post_id
    82 	 * @global int    $post_id
    73 	 * @global string $comment_status
    83 	 * @global string $comment_status
       
    84 	 * @global string $comment_type
    74 	 * @global string $search
    85 	 * @global string $search
    75 	 * @global string $comment_type
       
    76 	 */
    86 	 */
    77 	public function prepare_items() {
    87 	public function prepare_items() {
    78 		global $post_id, $comment_status, $search, $comment_type;
    88 		global $mode, $post_id, $comment_status, $comment_type, $search;
       
    89 
       
    90 		if ( ! empty( $_REQUEST['mode'] ) ) {
       
    91 			$mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
       
    92 			set_user_setting( 'posts_list_mode', $mode );
       
    93 		} else {
       
    94 			$mode = get_user_setting( 'posts_list_mode', 'list' );
       
    95 		}
    79 
    96 
    80 		$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
    97 		$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
    81 		if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ) ) ) {
    98 		if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ), true ) ) {
    82 			$comment_status = 'all';
    99 			$comment_status = 'all';
    83 		}
   100 		}
    84 
   101 
    85 		$comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
   102 		$comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
    86 
   103 
    98 		$doing_ajax = wp_doing_ajax();
   115 		$doing_ajax = wp_doing_ajax();
    99 
   116 
   100 		if ( isset( $_REQUEST['number'] ) ) {
   117 		if ( isset( $_REQUEST['number'] ) ) {
   101 			$number = (int) $_REQUEST['number'];
   118 			$number = (int) $_REQUEST['number'];
   102 		} else {
   119 		} else {
   103 			$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra
   120 			$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra.
   104 		}
   121 		}
   105 
   122 
   106 		$page = $this->get_pagenum();
   123 		$page = $this->get_pagenum();
   107 
   124 
   108 		if ( isset( $_REQUEST['start'] ) ) {
   125 		if ( isset( $_REQUEST['start'] ) ) {
   198 	public function no_items() {
   215 	public function no_items() {
   199 		global $comment_status;
   216 		global $comment_status;
   200 
   217 
   201 		if ( 'moderated' === $comment_status ) {
   218 		if ( 'moderated' === $comment_status ) {
   202 			_e( 'No comments awaiting moderation.' );
   219 			_e( 'No comments awaiting moderation.' );
       
   220 		} elseif ( 'trash' === $comment_status ) {
       
   221 			_e( 'No comments found in Trash.' );
   203 		} else {
   222 		} else {
   204 			_e( 'No comments found.' );
   223 			_e( 'No comments found.' );
   205 		}
   224 		}
   206 	}
   225 	}
   207 
   226 
   215 
   234 
   216 		$status_links = array();
   235 		$status_links = array();
   217 		$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
   236 		$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
   218 
   237 
   219 		$stati = array(
   238 		$stati = array(
   220 			/* translators: %s: all comments count */
   239 			/* translators: %s: Number of comments. */
   221 			'all'       => _nx_noop(
   240 			'all'       => _nx_noop(
   222 				'All <span class="count">(%s)</span>',
   241 				'All <span class="count">(%s)</span>',
   223 				'All <span class="count">(%s)</span>',
   242 				'All <span class="count">(%s)</span>',
   224 				'comments'
   243 				'comments'
   225 			), // singular not used
   244 			), // Singular not used.
   226 
   245 
   227 			/* translators: %s: current user's comments count */
   246 			/* translators: %s: Number of comments. */
   228 			'mine'      => _nx_noop(
   247 			'mine'      => _nx_noop(
   229 				'Mine <span class="count">(%s)</span>',
   248 				'Mine <span class="count">(%s)</span>',
   230 				'Mine <span class="count">(%s)</span>',
   249 				'Mine <span class="count">(%s)</span>',
   231 				'comments'
   250 				'comments'
   232 			),
   251 			),
   233 
   252 
   234 			/* translators: %s: pending comments count */
   253 			/* translators: %s: Number of comments. */
   235 			'moderated' => _nx_noop(
   254 			'moderated' => _nx_noop(
   236 				'Pending <span class="count">(%s)</span>',
   255 				'Pending <span class="count">(%s)</span>',
   237 				'Pending <span class="count">(%s)</span>',
   256 				'Pending <span class="count">(%s)</span>',
   238 				'comments'
   257 				'comments'
   239 			),
   258 			),
   240 
   259 
   241 			/* translators: %s: approved comments count */
   260 			/* translators: %s: Number of comments. */
   242 			'approved'  => _nx_noop(
   261 			'approved'  => _nx_noop(
   243 				'Approved <span class="count">(%s)</span>',
   262 				'Approved <span class="count">(%s)</span>',
   244 				'Approved <span class="count">(%s)</span>',
   263 				'Approved <span class="count">(%s)</span>',
   245 				'comments'
   264 				'comments'
   246 			),
   265 			),
   247 
   266 
   248 			/* translators: %s: spam comments count */
   267 			/* translators: %s: Number of comments. */
   249 			'spam'      => _nx_noop(
   268 			'spam'      => _nx_noop(
   250 				'Spam <span class="count">(%s)</span>',
   269 				'Spam <span class="count">(%s)</span>',
   251 				'Spam <span class="count">(%s)</span>',
   270 				'Spam <span class="count">(%s)</span>',
   252 				'comments'
   271 				'comments'
   253 			),
   272 			),
   254 
   273 
   255 			/* translators: %s: trashed comments count */
   274 			/* translators: %s: Number of comments. */
   256 			'trash'     => _nx_noop(
   275 			'trash'     => _nx_noop(
   257 				'Trash <span class="count">(%s)</span>',
   276 				'Trash <span class="count">(%s)</span>',
   258 				'Trash <span class="count">(%s)</span>',
   277 				'Trash <span class="count">(%s)</span>',
   259 				'comments'
   278 				'comments'
   260 			),
   279 			),
   263 		if ( ! EMPTY_TRASH_DAYS ) {
   282 		if ( ! EMPTY_TRASH_DAYS ) {
   264 			unset( $stati['trash'] );
   283 			unset( $stati['trash'] );
   265 		}
   284 		}
   266 
   285 
   267 		$link = admin_url( 'edit-comments.php' );
   286 		$link = admin_url( 'edit-comments.php' );
   268 		if ( ! empty( $comment_type ) && 'all' != $comment_type ) {
   287 		if ( ! empty( $comment_type ) && 'all' !== $comment_type ) {
   269 			$link = add_query_arg( 'comment_type', $comment_type, $link );
   288 			$link = add_query_arg( 'comment_type', $comment_type, $link );
   270 		}
   289 		}
   271 
   290 
   272 		foreach ( $stati as $status => $label ) {
   291 		foreach ( $stati as $status => $label ) {
   273 			$current_link_attributes = '';
   292 			$current_link_attributes = '';
   331 	 */
   350 	 */
   332 	protected function get_bulk_actions() {
   351 	protected function get_bulk_actions() {
   333 		global $comment_status;
   352 		global $comment_status;
   334 
   353 
   335 		$actions = array();
   354 		$actions = array();
   336 		if ( in_array( $comment_status, array( 'all', 'approved' ) ) ) {
   355 		if ( in_array( $comment_status, array( 'all', 'approved' ), true ) ) {
   337 			$actions['unapprove'] = __( 'Unapprove' );
   356 			$actions['unapprove'] = __( 'Unapprove' );
   338 		}
   357 		}
   339 		if ( in_array( $comment_status, array( 'all', 'moderated' ) ) ) {
   358 		if ( in_array( $comment_status, array( 'all', 'moderated' ), true ) ) {
   340 			$actions['approve'] = __( 'Approve' );
   359 			$actions['approve'] = __( 'Approve' );
   341 		}
   360 		}
   342 		if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ) ) ) {
   361 		if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ), true ) ) {
   343 			$actions['spam'] = _x( 'Mark as Spam', 'comment' );
   362 			$actions['spam'] = _x( 'Mark as spam', 'comment' );
   344 		}
   363 		}
   345 
   364 
   346 		if ( 'trash' === $comment_status ) {
   365 		if ( 'trash' === $comment_status ) {
   347 			$actions['untrash'] = __( 'Restore' );
   366 			$actions['untrash'] = __( 'Restore' );
   348 		} elseif ( 'spam' === $comment_status ) {
   367 		} elseif ( 'spam' === $comment_status ) {
   349 			$actions['unspam'] = _x( 'Not Spam', 'comment' );
   368 			$actions['unspam'] = _x( 'Not spam', 'comment' );
   350 		}
   369 		}
   351 
   370 
   352 		if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || ! EMPTY_TRASH_DAYS ) {
   371 		if ( in_array( $comment_status, array( 'trash', 'spam' ), true ) || ! EMPTY_TRASH_DAYS ) {
   353 			$actions['delete'] = __( 'Delete Permanently' );
   372 			$actions['delete'] = __( 'Delete permanently' );
   354 		} else {
   373 		} else {
   355 			$actions['trash'] = __( 'Move to Trash' );
   374 			$actions['trash'] = __( 'Move to Trash' );
   356 		}
   375 		}
   357 
   376 
   358 		return $actions;
   377 		return $actions;
   369 		static $has_items;
   388 		static $has_items;
   370 
   389 
   371 		if ( ! isset( $has_items ) ) {
   390 		if ( ! isset( $has_items ) ) {
   372 			$has_items = $this->has_items();
   391 			$has_items = $this->has_items();
   373 		}
   392 		}
   374 		?>
   393 		echo '<div class="alignleft actions">';
   375 		<div class="alignleft actions">
       
   376 		<?php
       
   377 		if ( 'top' === $which ) {
   394 		if ( 'top' === $which ) {
   378 			?>
   395 			ob_start();
   379 	<label class="screen-reader-text" for="filter-by-comment-type"><?php _e( 'Filter by comment type' ); ?></label>
   396 
   380 	<select id="filter-by-comment-type" name="comment_type">
   397 			$this->comment_status_dropdown( $comment_type );
   381 		<option value=""><?php _e( 'All comment types' ); ?></option>
       
   382 			<?php
       
   383 				/**
       
   384 				 * Filters the comment types dropdown menu.
       
   385 				 *
       
   386 				 * @since 2.7.0
       
   387 				 *
       
   388 				 * @param string[] $comment_types An array of comment types. Accepts 'Comments', 'Pings'.
       
   389 				 */
       
   390 				$comment_types = apply_filters(
       
   391 					'admin_comment_types_dropdown',
       
   392 					array(
       
   393 						'comment' => __( 'Comments' ),
       
   394 						'pings'   => __( 'Pings' ),
       
   395 					)
       
   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 			}
       
   401 			?>
       
   402 	</select>
       
   403 			<?php
       
   404 			/**
   398 			/**
   405 			 * Fires just before the Filter submit button for comment types.
   399 			 * Fires just before the Filter submit button for comment types.
   406 			 *
   400 			 *
   407 			 * @since 3.5.0
   401 			 * @since 3.5.0
   408 			 */
   402 			 */
   409 			do_action( 'restrict_manage_comments' );
   403 			do_action( 'restrict_manage_comments' );
   410 			submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
   404 
       
   405 			$output = ob_get_clean();
       
   406 
       
   407 			if ( ! empty( $output ) && $this->has_items() ) {
       
   408 				echo $output;
       
   409 				submit_button( esc_html__( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
       
   410 			}
   411 		}
   411 		}
   412 
   412 
   413 		if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_user_can( 'moderate_comments' ) && $has_items ) {
   413 		if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_user_can( 'moderate_comments' ) && $has_items ) {
   414 			wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
   414 			wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
   415 			$title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
   415 			$title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
   453 
   453 
   454 		$columns['author']  = __( 'Author' );
   454 		$columns['author']  = __( 'Author' );
   455 		$columns['comment'] = _x( 'Comment', 'column name' );
   455 		$columns['comment'] = _x( 'Comment', 'column name' );
   456 
   456 
   457 		if ( ! $post_id ) {
   457 		if ( ! $post_id ) {
   458 			/* translators: column name or table row header */
   458 			/* translators: Column name or table row header. */
   459 			$columns['response'] = __( 'In Response To' );
   459 			$columns['response'] = __( 'In response to' );
   460 		}
   460 		}
   461 
   461 
   462 		$columns['date'] = _x( 'Submitted On', 'column name' );
   462 		$columns['date'] = _x( 'Submitted on', 'column name' );
   463 
   463 
   464 		return $columns;
   464 		return $columns;
       
   465 	}
       
   466 
       
   467 	/**
       
   468 	 * Displays a comment status drop-down for filtering on the Comments list table.
       
   469 	 *
       
   470 	 * @since 5.5.0
       
   471 	 *
       
   472 	 * @param string $comment_type The current comment type slug.
       
   473 	 */
       
   474 	protected function comment_status_dropdown( $comment_type ) {
       
   475 		/**
       
   476 		 * Filters the comment types dropdown menu.
       
   477 		 *
       
   478 		 * @since 2.7.0
       
   479 		 *
       
   480 		 * @param array $comment_types An array of comment types. Accepts 'Comments', 'Pings'.
       
   481 		 */
       
   482 		$comment_types = apply_filters(
       
   483 			'admin_comment_types_dropdown',
       
   484 			array(
       
   485 				'comment' => esc_html__( 'Comments' ),
       
   486 				'pings'   => esc_html__( 'Pings' ),
       
   487 			)
       
   488 		);
       
   489 
       
   490 		if ( $comment_types && is_array( $comment_types ) ) {
       
   491 			printf( '<label class="screen-reader-text" for="filter-by-comment-type">%s</label>', esc_html__( 'Filter by comment type' ) );
       
   492 
       
   493 			echo '<select id="filter-by-comment-type" name="comment_type">';
       
   494 
       
   495 			printf( "\t<option value=''>%s</option>", esc_html__( 'All comment types' ) );
       
   496 
       
   497 			foreach ( $comment_types as $type => $label ) {
       
   498 				if ( get_comments(
       
   499 					array(
       
   500 						'number' => 1,
       
   501 						'type'   => $type,
       
   502 					)
       
   503 				) ) {
       
   504 					printf(
       
   505 						"\t<option value='%s'%s>%s</option>\n",
       
   506 						esc_attr( $type ),
       
   507 						selected( $comment_type, $type, false ),
       
   508 						esc_html( $label )
       
   509 					);
       
   510 				}
       
   511 			}
       
   512 				echo '</select>';
       
   513 		}
   465 	}
   514 	}
   466 
   515 
   467 	/**
   516 	/**
   468 	 * @return array
   517 	 * @return array
   469 	 */
   518 	 */
   485 	protected function get_default_primary_column_name() {
   534 	protected function get_default_primary_column_name() {
   486 		return 'comment';
   535 		return 'comment';
   487 	}
   536 	}
   488 
   537 
   489 	/**
   538 	/**
       
   539 	 * Displays the comments table.
       
   540 	 *
       
   541 	 * Overrides the parent display() method to render extra comments.
       
   542 	 *
       
   543 	 * @since 3.1.0
   490 	 */
   544 	 */
   491 	public function display() {
   545 	public function display() {
   492 		wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
   546 		wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
   493 
   547 		static $has_items;
   494 		$this->display_tablenav( 'top' );
   548 
       
   549 		if ( ! isset( $has_items ) ) {
       
   550 			$has_items = $this->has_items();
       
   551 			if ( $has_items ) {
       
   552 				$this->display_tablenav( 'top' );
       
   553 			}
       
   554 		}
   495 
   555 
   496 		$this->screen->render_screen_reader_content( 'heading_list' );
   556 		$this->screen->render_screen_reader_content( 'heading_list' );
   497 
   557 
   498 		?>
   558 		?>
   499 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
   559 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
   531 
   591 
   532 		$this->display_tablenav( 'bottom' );
   592 		$this->display_tablenav( 'bottom' );
   533 	}
   593 	}
   534 
   594 
   535 	/**
   595 	/**
   536 	 * @global WP_Post    $post
   596 	 * @global WP_Post    $post    Global post object.
   537 	 * @global WP_Comment $comment
   597 	 * @global WP_Comment $comment Global comment object.
   538 	 *
   598 	 *
   539 	 * @param WP_Comment $item
   599 	 * @param WP_Comment $item
   540 	 */
   600 	 */
   541 	public function single_row( $item ) {
   601 	public function single_row( $item ) {
   542 		global $post, $comment;
   602 		global $post, $comment;
   569 	 * @global string $comment_status Status for the current listed comments.
   629 	 * @global string $comment_status Status for the current listed comments.
   570 	 *
   630 	 *
   571 	 * @param WP_Comment $comment     The comment object.
   631 	 * @param WP_Comment $comment     The comment object.
   572 	 * @param string     $column_name Current column name.
   632 	 * @param string     $column_name Current column name.
   573 	 * @param string     $primary     Primary column name.
   633 	 * @param string     $primary     Primary column name.
   574 	 * @return string|void Comment row actions output.
   634 	 * @return string Row actions output for comments. An empty string
       
   635 	 *                if the current column is not the primary column,
       
   636 	 *                or if the current user cannot edit the comment.
   575 	 */
   637 	 */
   576 	protected function handle_row_actions( $comment, $column_name, $primary ) {
   638 	protected function handle_row_actions( $comment, $column_name, $primary ) {
   577 		global $comment_status;
   639 		global $comment_status;
   578 
   640 
   579 		if ( $primary !== $column_name ) {
   641 		if ( $primary !== $column_name ) {
   580 			return '';
   642 			return '';
   581 		}
   643 		}
   582 
   644 
   583 		if ( ! $this->user_can ) {
   645 		if ( ! $this->user_can ) {
   584 			return;
   646 			return '';
   585 		}
   647 		}
   586 
   648 
   587 		$the_comment_status = wp_get_comment_status( $comment );
   649 		$the_comment_status = wp_get_comment_status( $comment );
   588 
   650 
   589 		$out = '';
   651 		$out = '';
   614 			'untrash'   => '',
   676 			'untrash'   => '',
   615 			'delete'    => '',
   677 			'delete'    => '',
   616 		);
   678 		);
   617 
   679 
   618 		// Not looking at all comments.
   680 		// Not looking at all comments.
   619 		if ( $comment_status && 'all' != $comment_status ) {
   681 		if ( $comment_status && 'all' !== $comment_status ) {
   620 			if ( 'approved' === $the_comment_status ) {
   682 			if ( 'approved' === $the_comment_status ) {
   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>';
   683 				$actions['unapprove'] = sprintf(
       
   684 					'<a href="%s" data-wp-lists="%s" class="vim-u vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
       
   685 					$unapprove_url,
       
   686 					"delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&amp;new=unapproved",
       
   687 					esc_attr__( 'Unapprove this comment' ),
       
   688 					__( 'Unapprove' )
       
   689 				);
   622 			} elseif ( 'unapproved' === $the_comment_status ) {
   690 			} elseif ( 'unapproved' === $the_comment_status ) {
   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>';
   691 				$actions['approve'] = sprintf(
       
   692 					'<a href="%s" data-wp-lists="%s" class="vim-a vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
       
   693 					$approve_url,
       
   694 					"delete:the-comment-list:comment-{$comment->comment_ID}:e7e7d3:action=dim-comment&amp;new=approved",
       
   695 					esc_attr__( 'Approve this comment' ),
       
   696 					__( 'Approve' )
       
   697 				);
   624 			}
   698 			}
   625 		} else {
   699 		} else {
   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>';
   700 			$actions['approve'] = sprintf(
   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>';
   701 				'<a href="%s" data-wp-lists="%s" class="vim-a aria-button-if-js" aria-label="%s">%s</a>',
       
   702 				$approve_url,
       
   703 				"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=approved",
       
   704 				esc_attr__( 'Approve this comment' ),
       
   705 				__( 'Approve' )
       
   706 			);
       
   707 
       
   708 			$actions['unapprove'] = sprintf(
       
   709 				'<a href="%s" data-wp-lists="%s" class="vim-u aria-button-if-js" aria-label="%s">%s</a>',
       
   710 				$unapprove_url,
       
   711 				"dim:the-comment-list:comment-{$comment->comment_ID}:unapproved:e7e7d3:e7e7d3:new=unapproved",
       
   712 				esc_attr__( 'Unapprove this comment' ),
       
   713 				__( 'Unapprove' )
       
   714 			);
   628 		}
   715 		}
   629 
   716 
   630 		if ( 'spam' !== $the_comment_status ) {
   717 		if ( 'spam' !== $the_comment_status ) {
   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>';
   718 			$actions['spam'] = sprintf(
       
   719 				'<a href="%s" data-wp-lists="%s" class="vim-s vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
       
   720 				$spam_url,
       
   721 				"delete:the-comment-list:comment-{$comment->comment_ID}::spam=1",
       
   722 				esc_attr__( 'Mark this comment as spam' ),
       
   723 				/* translators: "Mark as spam" link. */
       
   724 				_x( 'Spam', 'verb' )
       
   725 			);
   632 		} elseif ( 'spam' === $the_comment_status ) {
   726 		} elseif ( 'spam' === $the_comment_status ) {
   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>';
   727 			$actions['unspam'] = sprintf(
       
   728 				'<a href="%s" data-wp-lists="%s" class="vim-z vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
       
   729 				$unspam_url,
       
   730 				"delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:unspam=1",
       
   731 				esc_attr__( 'Restore this comment from the spam' ),
       
   732 				_x( 'Not Spam', 'comment' )
       
   733 			);
   634 		}
   734 		}
   635 
   735 
   636 		if ( 'trash' === $the_comment_status ) {
   736 		if ( 'trash' === $the_comment_status ) {
   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>';
   737 			$actions['untrash'] = sprintf(
       
   738 				'<a href="%s" data-wp-lists="%s" class="vim-z vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
       
   739 				$untrash_url,
       
   740 				"delete:the-comment-list:comment-{$comment->comment_ID}:66cc66:untrash=1",
       
   741 				esc_attr__( 'Restore this comment from the Trash' ),
       
   742 				__( 'Restore' )
       
   743 			);
   638 		}
   744 		}
   639 
   745 
   640 		if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) {
   746 		if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) {
   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>';
   747 			$actions['delete'] = sprintf(
       
   748 				'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
       
   749 				$delete_url,
       
   750 				"delete:the-comment-list:comment-{$comment->comment_ID}::delete=1",
       
   751 				esc_attr__( 'Delete this comment permanently' ),
       
   752 				__( 'Delete Permanently' )
       
   753 			);
   642 		} else {
   754 		} else {
   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>';
   755 			$actions['trash'] = sprintf(
       
   756 				'<a href="%s" data-wp-lists="%s" class="delete vim-d vim-destructive aria-button-if-js" aria-label="%s">%s</a>',
       
   757 				$trash_url,
       
   758 				"delete:the-comment-list:comment-{$comment->comment_ID}::trash=1",
       
   759 				esc_attr__( 'Move this comment to the Trash' ),
       
   760 				_x( 'Trash', 'verb' )
       
   761 			);
   644 		}
   762 		}
   645 
   763 
   646 		if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) {
   764 		if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) {
   647 			$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>';
   765 			$actions['edit'] = sprintf(
       
   766 				'<a href="%s" aria-label="%s">%s</a>',
       
   767 				"comment.php?action=editcomment&amp;c={$comment->comment_ID}",
       
   768 				esc_attr__( 'Edit this comment' ),
       
   769 				__( 'Edit' )
       
   770 			);
   648 
   771 
   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>';
   772 			$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>';
   650 
   773 
   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' ) );
   774 			$actions['quickedit'] = sprintf(
   652 
   775 				$format,
   653 			$actions['reply'] = sprintf( $format, $comment->comment_ID, $comment->comment_post_ID, 'replyto', 'vim-r comment-inline', esc_attr__( 'Reply to this comment' ), __( 'Reply' ) );
   776 				$comment->comment_ID,
       
   777 				$comment->comment_post_ID,
       
   778 				'edit',
       
   779 				'vim-q comment-inline',
       
   780 				esc_attr__( 'Quick edit this comment inline' ),
       
   781 				__( 'Quick&nbsp;Edit' )
       
   782 			);
       
   783 
       
   784 			$actions['reply'] = sprintf(
       
   785 				$format,
       
   786 				$comment->comment_ID,
       
   787 				$comment->comment_post_ID,
       
   788 				'replyto',
       
   789 				'vim-r comment-inline',
       
   790 				esc_attr__( 'Reply to this comment' ),
       
   791 				__( 'Reply' )
       
   792 			);
   654 		}
   793 		}
   655 
   794 
   656 		/** This filter is documented in wp-admin/includes/dashboard.php */
   795 		/** This filter is documented in wp-admin/includes/dashboard.php */
   657 		$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
   796 		$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
   658 
   797 
   659 		$i    = 0;
   798 		$always_visible = false;
   660 		$out .= '<div class="row-actions">';
   799 
       
   800 		$mode = get_user_setting( 'posts_list_mode', 'list' );
       
   801 
       
   802 		if ( 'excerpt' === $mode ) {
       
   803 			$always_visible = true;
       
   804 		}
       
   805 
       
   806 		$out .= '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
       
   807 
       
   808 		$i = 0;
       
   809 
   661 		foreach ( $actions as $action => $link ) {
   810 		foreach ( $actions as $action => $link ) {
   662 			++$i;
   811 			++$i;
   663 			( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
   812 
   664 
   813 			if ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i )
   665 			// Reply and quickedit need a hide-if-no-js span when not added with ajax
   814 				|| 1 === $i
       
   815 			) {
       
   816 				$sep = '';
       
   817 			} else {
       
   818 				$sep = ' | ';
       
   819 			}
       
   820 
       
   821 			// Reply and quickedit need a hide-if-no-js span when not added with Ajax.
   666 			if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) {
   822 			if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) {
   667 				$action .= ' hide-if-no-js';
   823 				$action .= ' hide-if-no-js';
   668 			} elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) {
   824 			} elseif ( ( 'untrash' === $action && 'trash' === $the_comment_status )
       
   825 				|| ( 'unspam' === $action && 'spam' === $the_comment_status )
       
   826 			) {
   669 				if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) {
   827 				if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) {
   670 					$action .= ' approve';
   828 					$action .= ' approve';
   671 				} else {
   829 				} else {
   672 					$action .= ' unapprove';
   830 					$action .= ' unapprove';
   673 				}
   831 				}
   674 			}
   832 			}
   675 
   833 
   676 			$out .= "<span class='$action'>$sep$link</span>";
   834 			$out .= "<span class='$action'>$sep$link</span>";
   677 		}
   835 		}
       
   836 
   678 		$out .= '</div>';
   837 		$out .= '</div>';
   679 
   838 
   680 		$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>';
   839 		$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>';
   681 
   840 
   682 		return $out;
   841 		return $out;
   706 			$parent = get_comment( $comment->comment_parent );
   865 			$parent = get_comment( $comment->comment_parent );
   707 			if ( $parent ) {
   866 			if ( $parent ) {
   708 				$parent_link = esc_url( get_comment_link( $parent ) );
   867 				$parent_link = esc_url( get_comment_link( $parent ) );
   709 				$name        = get_comment_author( $parent );
   868 				$name        = get_comment_author( $parent );
   710 				printf(
   869 				printf(
   711 					/* translators: %s: comment link */
   870 					/* translators: %s: Comment link. */
   712 					__( 'In reply to %s.' ),
   871 					__( 'In reply to %s.' ),
   713 					'<a href="' . $parent_link . '">' . $name . '</a>'
   872 					'<a href="' . $parent_link . '">' . $name . '</a>'
   714 				);
   873 				);
   715 			}
   874 			}
   716 		}
   875 		}
   783 
   942 
   784 	/**
   943 	/**
   785 	 * @param WP_Comment $comment The comment object.
   944 	 * @param WP_Comment $comment The comment object.
   786 	 */
   945 	 */
   787 	public function column_date( $comment ) {
   946 	public function column_date( $comment ) {
   788 		/* translators: 1: comment date, 2: comment time */
       
   789 		$submitted = sprintf(
   947 		$submitted = sprintf(
       
   948 			/* translators: 1: Comment date, 2: Comment time. */
   790 			__( '%1$s at %2$s' ),
   949 			__( '%1$s at %2$s' ),
   791 			/* translators: comment date format. See https://secure.php.net/date */
   950 			/* translators: Comment date format. See https://www.php.net/date */
   792 			get_comment_date( __( 'Y/m/d' ), $comment ),
   951 			get_comment_date( __( 'Y/m/d' ), $comment ),
       
   952 			/* translators: Comment time format. See https://www.php.net/date */
   793 			get_comment_date( __( 'g:i a' ), $comment )
   953 			get_comment_date( __( 'g:i a' ), $comment )
   794 		);
   954 		);
   795 
   955 
   796 		echo '<div class="submitted-on">';
   956 		echo '<div class="submitted-on">';
   797 		if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
   957 		if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
   817 		}
   977 		}
   818 
   978 
   819 		if ( isset( $this->pending_count[ $post->ID ] ) ) {
   979 		if ( isset( $this->pending_count[ $post->ID ] ) ) {
   820 			$pending_comments = $this->pending_count[ $post->ID ];
   980 			$pending_comments = $this->pending_count[ $post->ID ];
   821 		} else {
   981 		} else {
   822 			$_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
   982 			$_pending_count_temp              = get_pending_comments_num( array( $post->ID ) );
   823 			$pending_comments    = $this->pending_count[ $post->ID ] = $_pending_count_temp[ $post->ID ];
   983 			$pending_comments                 = $_pending_count_temp[ $post->ID ];
       
   984 			$this->pending_count[ $post->ID ] = $pending_comments;
   824 		}
   985 		}
   825 
   986 
   826 		if ( current_user_can( 'edit_post', $post->ID ) ) {
   987 		if ( current_user_can( 'edit_post', $post->ID ) ) {
   827 			$post_link  = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>";
   988 			$post_link  = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>";
   828 			$post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>';
   989 			$post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>';
   829 		} else {
   990 		} else {
   830 			$post_link = esc_html( get_the_title( $post->ID ) );
   991 			$post_link = esc_html( get_the_title( $post->ID ) );
   831 		}
   992 		}
   832 
   993 
   833 		echo '<div class="response-links">';
   994 		echo '<div class="response-links">';
   834 		if ( 'attachment' === $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) ) {
   995 		if ( 'attachment' === $post->post_type ) {
   835 			echo $thumb;
   996 			$thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true );
       
   997 			if ( $thumb ) {
       
   998 				echo $thumb;
       
   999 			}
   836 		}
  1000 		}
   837 		echo $post_link;
  1001 		echo $post_link;
   838 		$post_type_object = get_post_type_object( $post->post_type );
  1002 		$post_type_object = get_post_type_object( $post->post_type );
   839 		echo "<a href='" . get_permalink( $post->ID ) . "' class='comments-view-item-link'>" . $post_type_object->labels->view_item . '</a>';
  1003 		echo "<a href='" . get_permalink( $post->ID ) . "' class='comments-view-item-link'>" . $post_type_object->labels->view_item . '</a>';
   840 		echo '<span class="post-com-count-wrapper post-com-count-', $post->ID, '">';
  1004 		echo '<span class="post-com-count-wrapper post-com-count-', $post->ID, '">';
   851 		/**
  1015 		/**
   852 		 * Fires when the default column output is displayed for a single row.
  1016 		 * Fires when the default column output is displayed for a single row.
   853 		 *
  1017 		 *
   854 		 * @since 2.8.0
  1018 		 * @since 2.8.0
   855 		 *
  1019 		 *
   856 		 * @param string $column_name         The custom column's name.
  1020 		 * @param string $column_name The custom column's name.
   857 		 * @param int    $comment->comment_ID The custom column's unique ID number.
  1021 		 * @param int    $comment_ID  The custom column's unique ID number.
   858 		 */
  1022 		 */
   859 		do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
  1023 		do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
   860 	}
  1024 	}
   861 }
  1025 }