$row Row from Webhooks::row(). * @var \SmartWP\AdminPowerups\Modules\WebhookHealth\Module $this Module. */ use SmartWP\AdminPowerups\Admin\Components; use SmartWP\AdminPowerups\Admin\Icons; use SmartWP\AdminPowerups\Support\DevGuard; defined( 'ABSPATH' ) || exit; $apwc_id = (int) $row['id']; $apwc_name = '' !== (string) $row['name'] ? (string) $row['name'] : __( '(no name)', 'admin-powerups-for-woocommerce' ); $apwc_statuses = function_exists( 'wc_get_webhook_statuses' ) ? (array) wc_get_webhook_statuses() : array(); $apwc_status = (string) $row['status']; $apwc_health = (string) $row['health']; $apwc_disable = (int) $row['max'] + 2; // WooCommerce disables it on the failure after max + 1 in a row. $apwc_note = wp_unique_id( 'apwc-wh-note-' ); switch ( $apwc_health ) { case 'disabled': $apwc_label = __( 'Disabled', 'admin-powerups-for-woocommerce' ); $apwc_detail = $row['auto_disabled'] ? __( 'After repeated failures.', 'admin-powerups-for-woocommerce' ) : __( 'Turned off in WooCommerce.', 'admin-powerups-for-woocommerce' ); break; case 'owner-missing': $apwc_label = __( 'Owner missing', 'admin-powerups-for-woocommerce' ); $apwc_detail = __( 'The user it runs as no longer exists. Pick a user in WooCommerce.', 'admin-powerups-for-woocommerce' ); break; case 'owner-access': $apwc_things = array( 'order' => __( 'orders', 'admin-powerups-for-woocommerce' ), 'product' => __( 'products', 'admin-powerups-for-woocommerce' ), 'coupon' => __( 'coupons', 'admin-powerups-for-woocommerce' ), 'customer' => __( 'customers', 'admin-powerups-for-woocommerce' ), ); $apwc_label = isset( $apwc_things[ (string) $row['resource'] ] ) /* translators: %s: what the webhook sends, e.g. "orders". */ ? sprintf( __( 'Owner can’t read %s', 'admin-powerups-for-woocommerce' ), $apwc_things[ (string) $row['resource'] ] ) : __( 'Owner can’t use this site', 'admin-powerups-for-woocommerce' ); $apwc_detail = __( 'WooCommerce builds each delivery as this user, so deliveries hold an error. Pick another user in WooCommerce.', 'admin-powerups-for-woocommerce' ); break; case 'failing': /* translators: %s: number of failed deliveries in a row. */ $apwc_label = sprintf( _n( 'Failing: %s in a row', 'Failing: %s in a row', (int) $row['failures'], 'admin-powerups-for-woocommerce' ), number_format_i18n( (int) $row['failures'] ) ); /* translators: %s: number of failures. */ $apwc_detail = sprintf( __( 'WooCommerce disables it after %s failures in a row.', 'admin-powerups-for-woocommerce' ), number_format_i18n( $apwc_disable ) ); break; case 'paused': $apwc_label = __( 'Paused', 'admin-powerups-for-woocommerce' ); $apwc_detail = __( 'Not delivering until it’s active again in WooCommerce.', 'admin-powerups-for-woocommerce' ); break; case 'waiting': $apwc_label = __( 'No successful ping yet', 'admin-powerups-for-woocommerce' ); $apwc_detail = __( 'WooCommerce’s test ping hasn’t had a 200 answer yet.', 'admin-powerups-for-woocommerce' ); break; default: $apwc_label = __( 'Healthy', 'admin-powerups-for-woocommerce' ); $apwc_detail = ''; } ?>