Fixed webhook initial test delivery ping

Part of #12439
This commit is contained in:
Claudio Sanches 2017-12-01 14:04:59 -02:00
parent 4e2e64ad2e
commit f5cddc4f36
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();
}