Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Admin

Table::render_views()publicWC 1.0

Displays the list of views available on this table.

Метод класса: Table{}

No Hooks.

Return

null. Nothing.

Usage

$Table = new Table();
$Table->render_views();

Code of Table::render_views() WC 7.1.0

public function render_views() {
	$register = wc_get_container()->get( Register::class );

	$enabled_count  = $register->count( true );
	$disabled_count = $register->count( false );
	$all_count      = $enabled_count + $disabled_count;
	// phpcs:ignore WordPress.Security.NonceVerification.Recommended
	$selected_view = isset( $_REQUEST['view'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['view'] ) ) : 'all';

	$all_url   = esc_url( add_query_arg( 'view', 'all', $this->get_base_url() ) );
	$all_class = 'all' === $selected_view ? 'class="current"' : '';
	$all_text  = sprintf(
		/* translators: %s is the count of approved directory list entries. */
		_nx(
			'All <span class="count">(%s)</span>',
			'All <span class="count">(%s)</span>',
			$all_count,
			'Approved product download directory views',
			'woocommerce'
		),
		$all_count
	);

	$enabled_url   = esc_url( add_query_arg( 'view', 'enabled', $this->get_base_url() ) );
	$enabled_class = 'enabled' === $selected_view ? 'class="current"' : '';
	$enabled_text  = sprintf(
		/* translators: %s is the count of enabled approved directory list entries. */
		_nx(
			'Enabled <span class="count">(%s)</span>',
			'Enabled <span class="count">(%s)</span>',
			$enabled_count,
			'Approved product download directory views',
			'woocommerce'
		),
		$enabled_count
	);

	$disabled_url   = esc_url( add_query_arg( 'view', 'disabled', $this->get_base_url() ) );
	$disabled_class = 'disabled' === $selected_view ? 'class="current"' : '';
	$disabled_text  = sprintf(
		/* translators: %s is the count of disabled directory list entries. */
		_nx(
			'Disabled <span class="count">(%s)</span>',
			'Disabled <span class="count">(%s)</span>',
			$disabled_count,
			'Approved product download directory views',
			'woocommerce'
		),
		$disabled_count
	);

	$views = array(
		'all'      => "<a href='{$all_url}' {$all_class}>{$all_text}</a>",
		'enabled'  => "<a href='{$enabled_url}' {$enabled_class}>{$enabled_text}</a>",
		'disabled' => "<a href='{$disabled_url}' {$disabled_class}>{$disabled_text}</a>",
	);

	$this->screen->render_screen_reader_content( 'heading_views' );

	echo '<ul class="subsubsub list-table-filters">';
	foreach ( $views as $slug => $view ) {
		$views[ $slug ] = "<li class='{$slug}'>{$view}";
	}
	// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
	echo implode( ' | </li>', $views ) . "</li>\n";
	echo '</ul>';
}