array(), 'total' => 0, 'active' => 0, 'recent_failures' => 0, 'error' => 'woocommerce_not_active' ); } $store = \WC_Data_Store::load( 'webhook' ); $ids = method_exists( $store, 'get_webhooks_ids' ) ? (array) $store->get_webhooks_ids() : array(); $out = array(); $active = 0; $failures = 0; foreach ( array_slice( $ids, 0, 100 ) as $id ) { $wh = wc_get_webhook( (int) $id ); if ( ! $wh ) { continue; } $host = (string) wp_parse_url( (string) $wh->get_delivery_url(), PHP_URL_HOST ); $fc = (int) $wh->get_failure_count(); $failures += $fc; if ( $wh->get_status() === 'active' ) { $active++; } $out[] = array( 'id' => (int) $id, 'name' => substr( (string) $wh->get_name(), 0, 120 ), 'topic' => (string) $wh->get_topic(), 'status' => (string) $wh->get_status(), 'delivery_host' => $host, 'failure_count' => $fc, 'api_version' => (int) $wh->get_api_version() ); } return array( 'webhooks' => $out, 'total' => count( $out ), 'active' => $active, 'recent_failures' => $failures ); } }