WC_Admin_Webhooks_Table_List::get_views
Table list views.
Method of the class: WC_Admin_Webhooks_Table_List{}
No Hooks.
Returns
Array.
Usage
// protected - for code of main (parent) or child class $result = $this->get_views();
WC_Admin_Webhooks_Table_List::get_views() WC Admin Webhooks Table List::get views code WC 10.8.1
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&tab=advanced&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&tab=advanced&section=webhooks&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&tab=advanced&section=webhooks&legacy=true'$class>" . sprintf( translate_nooped_plural( $label, $legacy_webhooks_count ), number_format_i18n( $legacy_webhooks_count ) ) . '</a>';
}
return $status_links;
}