WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Comments_List_Table::get_views() protected WP 1.0

Это метод класса: WP_Comments_List_Table{}

Хуки из метода
Возвращает

Null. Ничего.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_views();

Заметки

  • Global. Число. $post_id
  • Global. Строка. $comment_status
  • Global. Строка. $comment_type

Код WP_Comments_List_Table::get_views() WP 5.5.1

wp-admin/includes/class-wp-comments-list-table.php
<?php
protected function get_views() {
	global $post_id, $comment_status, $comment_type;

	$status_links = array();
	$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();

	$stati = array(
		/* translators: %s: Number of comments. */
		'all'       => _nx_noop(
			'All <span class="count">(%s)</span>',
			'All <span class="count">(%s)</span>',
			'comments'
		), // Singular not used.

		/* translators: %s: Number of comments. */
		'mine'      => _nx_noop(
			'Mine <span class="count">(%s)</span>',
			'Mine <span class="count">(%s)</span>',
			'comments'
		),

		/* translators: %s: Number of comments. */
		'moderated' => _nx_noop(
			'Pending <span class="count">(%s)</span>',
			'Pending <span class="count">(%s)</span>',
			'comments'
		),

		/* translators: %s: Number of comments. */
		'approved'  => _nx_noop(
			'Approved <span class="count">(%s)</span>',
			'Approved <span class="count">(%s)</span>',
			'comments'
		),

		/* translators: %s: Number of comments. */
		'spam'      => _nx_noop(
			'Spam <span class="count">(%s)</span>',
			'Spam <span class="count">(%s)</span>',
			'comments'
		),

		/* translators: %s: Number of comments. */
		'trash'     => _nx_noop(
			'Trash <span class="count">(%s)</span>',
			'Trash <span class="count">(%s)</span>',
			'comments'
		),
	);

	if ( ! EMPTY_TRASH_DAYS ) {
		unset( $stati['trash'] );
	}

	$link = admin_url( 'edit-comments.php' );
	if ( ! empty( $comment_type ) && 'all' !== $comment_type ) {
		$link = add_query_arg( 'comment_type', $comment_type, $link );
	}

	foreach ( $stati as $status => $label ) {
		$current_link_attributes = '';

		if ( $status === $comment_status ) {
			$current_link_attributes = ' class="current" aria-current="page"';
		}

		if ( 'mine' === $status ) {
			$current_user_id    = get_current_user_id();
			$num_comments->mine = get_comments(
				array(
					'post_id' => $post_id ? $post_id : 0,
					'user_id' => $current_user_id,
					'count'   => true,
				)
			);
			$link               = add_query_arg( 'user_id', $current_user_id, $link );
		} else {
			$link = remove_query_arg( 'user_id', $link );
		}

		if ( ! isset( $num_comments->$status ) ) {
			$num_comments->$status = 10;
		}
		$link = add_query_arg( 'comment_status', $status, $link );
		if ( $post_id ) {
			$link = add_query_arg( 'p', absint( $post_id ), $link );
		}
		/*
		// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
		if ( !empty( $_REQUEST['s'] ) )
			$link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link );
		*/
		$status_links[ $status ] = "<a href='$link'$current_link_attributes>" . sprintf(
			translate_nooped_plural( $label, $num_comments->$status ),
			sprintf(
				'<span class="%s-count">%s</span>',
				( 'moderated' === $status ) ? 'pending' : $status,
				number_format_i18n( $num_comments->$status )
			)
		) . '</a>';
	}

	/**
	 * Filters the comment status links.
	 *
	 * @since 2.5.0
	 * @since 5.1.0 The 'Mine' link was added.
	 *
	 * @param string[] $status_links An associative array of fully-formed comment status links. Includes 'All', 'Mine',
	 *                              'Pending', 'Approved', 'Spam', and 'Trash'.
	 */
	return apply_filters( 'comment_status_links', $status_links );
}