Merge pull request #17986 from woocommerce/fix/12439-pending-delivery

Fixed webhook initial test delivery ping
This commit is contained in:
Claudiu Lodromanean 2017-12-01 10:31:46 -08:00 committed by GitHub
commit 224fa43fe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -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();
}