From f5cddc4f36e33e6c73c44fd5325811b23b4864ad Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Fri, 1 Dec 2017 14:04:59 -0200 Subject: [PATCH] Fixed webhook initial test delivery ping Part of #12439 --- includes/data-stores/class-wc-webhook-data-store.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/data-stores/class-wc-webhook-data-store.php b/includes/data-stores/class-wc-webhook-data-store.php index 47ca70e6345..1eb961f6316 100644 --- a/includes/data-stores/class-wc-webhook-data-store.php +++ b/includes/data-stores/class-wc-webhook-data-store.php @@ -36,6 +36,11 @@ class WC_Webhook_Data_Store implements WC_Webhook_Data_Store_Interface { $webhook->set_date_created( $date_created ); } + // Pending delivery by default if not set while creating a new webhook. + if ( ! isset( $changes['pending_delivery'] ) ) { + $webhook->set_pending_delivery( true ); + } + $data = array( 'status' => $webhook->get_status( 'edit' ), 'name' => $webhook->get_name( 'edit' ), @@ -150,7 +155,7 @@ class WC_Webhook_Data_Store implements WC_Webhook_Data_Store_Interface { wp_cache_delete( $webhook->get_id(), 'webhooks' ); WC_Cache_Helper::incr_cache_prefix( 'webhooks' ); - if ( $trigger || $webhook->get_pending_delivery() ) { + if ( 'active' === $webhook->get_status() && ( $trigger || $webhook->get_pending_delivery() ) ) { $webhook->deliver_ping(); }