WordPress at Your Fingertips
function is not described

WP_List_Table::comments_bubble() protected WP 3.1.0

Displays a comment count bubble.

{} It's a method of the class: WP_List_Table{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->comments_bubble( $post_id, $pending_comments );
$post_id(int) (required)
The post ID.
$pending_comments(int) (required)
Number of pending comments.

Changelog

Since 3.1.0 Introduced.

Code of WP_List_Table::comments_bubble() WP 5.8.1

protected function comments_bubble( $post_id, $pending_comments ) {
	$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 ? __( 'No approved comments' ) : __( 'No comments' )
		);
	}

	if ( $pending_comments ) {
		printf(
			'<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
			esc_url(
				add_query_arg(
					array(
						'p'              => $post_id,
						'comment_status' => 'moderated',
					),
					admin_url( 'edit-comments.php' )
				)
			),
			$pending_comments_number,
			$pending_phrase
		);
	} else {
		printf(
			'<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
			$pending_comments_number,
			$approved_comments ? __( 'No pending comments' ) : __( 'No comments' )
		);
	}
}