wppaste
WordPress

WP_List_Table::comments_bubble( int $post_id, int $pending_comments )

Since
3.1.0
Source
wp-admin/includes/class-wp-list-table.php:843
Displays a comment count bubble.

Parameters

$post_idint
The post ID.
$pending_commentsint
Number of pending comments.

Uses · 11

Source

	protected function comments_bubble( $post_id, $pending_comments ) {		$post_object   = get_post( $post_id );		$edit_post_cap = $post_object ? 'edit_post' : 'edit_posts'; 		if ( ! current_user_can( $edit_post_cap, $post_id )			&& ( post_password_required( $post_id )				|| ! current_user_can( 'read_post', $post_id ) )		) {			// The user has no access to the post and thus cannot see the comments.			return false;		} 		$approved_comments = get_comments_number(); 		$approved_comments_number = number_format_i18n( $approved_comments );		$pending_comments_number  = number_format_i18n( $pending_comments ); 		$approved_only_phrase = sprintf(			/* translators: %s: Number of comments. */			_n( '%s comment', '%s comments', $approved_comments ),			$approved_comments_number		); 		$approved_phrase = sprintf(			/* translators: %s: Number of comments. */			_n( '%s approved comment', '%s approved comments', $approved_comments ),			$approved_comments_number		); 		$pending_phrase = sprintf(			/* translators: %s: Number of comments. */			_n( '%s pending comment', '%s pending comments', $pending_comments ),			$pending_comments_number		); 		if ( ! $approved_comments && ! $pending_comments ) {			// No comments at all.			printf(				'<span aria-hidden="true">&#8212;</span>' .				'<span class="screen-reader-text">%s</span>',				__( 'No comments' )			);		} elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) {			// Don't link the comment bubble for a trashed post.			printf(				'<span class="post-com-count post-com-count-approved">' .					'<span class="comment-count-approved" aria-hidden="true">%s</span>' .					'<span class="screen-reader-text">%s</span>' .				'</span>',				$approved_comments_number,				$pending_comments ? $approved_phrase : $approved_only_phrase			);		} elseif ( $approved_comments ) {			// Link the comment bubble to approved comments.			printf(				'<a href="%s" class="post-com-count post-com-count-approved">' .					'<span class="comment-count-approved" aria-hidden="true">%s</span>' .					'<span class="screen-reader-text">%s</span>' .				'</a>',				esc_url(					add_query_arg(						array(							'p'              => $post_id,							'comment_status' => 'approved',						),						admin_url( 'edit-comments.php' )					)				),				$approved_comments_number,				$pending_comments ? $approved_phrase : $approved_only_phrase			);		} else {			// Don't link the comment bubble when there are no approved comments.			printf(				'<span class="post-com-count post-com-count-no-comments">' .					'<span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span>' .					'<span class="screen-reader-text">%s</span>' .				'</span>',				$approved_comments_number,				$pending_comments ?

History

Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-admin/includes/class-wp-list-table.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.