WC_Admin_Webhooks_Table_List::get_views()protectedWC 1.0

Table list views.

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

Хуков нет.

Возвращает

Массив.

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

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

Код WC_Admin_Webhooks_Table_List::get_views() WC 8.7.0

protected function get_views() {
	$status_links   = array();
	$data_store     = WC_Data_Store::load( 'webhook' );
	$num_webhooks   = $data_store->get_count_webhooks_by_status();
	$total_webhooks = array_sum( (array) $num_webhooks );
	$statuses       = array_keys( wc_get_webhook_statuses() );
	// phpcs:ignore WordPress.Security.NonceVerification.Recommended
	$class = empty( $_REQUEST['status'] ) && empty( $_REQUEST['legacy'] ) ? ' class="current"' : '';

	/* translators: %s: count */
	$status_links['all'] = "<a href='admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_webhooks, 'posts', 'woocommerce' ), number_format_i18n( $total_webhooks ) ) . '</a>';

	foreach ( $statuses as $status_name ) {
		$class = '';

		if ( empty( $num_webhooks[ $status_name ] ) ) {
			continue;
		}

		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
		if ( isset( $_REQUEST['status'] ) && sanitize_key( wp_unslash( $_REQUEST['status'] ) ) === $status_name ) {
			$class = ' class="current"';
		}

		$label = $this->get_status_label( $status_name, $num_webhooks[ $status_name ] );

		$status_links[ $status_name ] = "<a href='admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks&amp;status=$status_name'$class>" . sprintf( translate_nooped_plural( $label, $num_webhooks[ $status_name ] ), number_format_i18n( $num_webhooks[ $status_name ] ) ) . '</a>';
	}

	$legacy_webhooks_count = wc_get_container()->get( WebhookUtil::class )->get_legacy_webhooks_count();
	if ( $legacy_webhooks_count > 0 ) {
		$class = '';

		// phpcs:ignore WordPress.Security.NonceVerification.Recommended
		if ( 'true' === sanitize_key( wp_unslash( $_REQUEST['legacy'] ?? '' ) ) ) {
			$class = ' class="current"';
		}

		$label = $this->get_status_label( __( 'Legacy', 'woocommerce' ), $legacy_webhooks_count );

		$status_links['legacy'] = "<a href='admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks&amp;legacy=true'$class>" . sprintf( translate_nooped_plural( $label, $legacy_webhooks_count ), number_format_i18n( $legacy_webhooks_count ) ) . '</a>';
	}

	return $status_links;
}