From f7958f2b209e5f7e035b51a4d9cc34bc781a6346 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 12 Aug 2016 11:53:40 +0100 Subject: [PATCH] [2.6] Drafts don't have post_date_gmt Fixes #11686 @claudiosmweb @justinshreve --- includes/class-wc-webhook.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-webhook.php b/includes/class-wc-webhook.php index 4d9891dac9b..2efd9e32a9d 100644 --- a/includes/class-wc-webhook.php +++ b/includes/class-wc-webhook.php @@ -160,8 +160,11 @@ class WC_Webhook { // creation date to determine the actual event $resource = get_post( absint( $arg ) ); + // Drafts don't have post_date_gmt so calculate it here + $gmt_date = get_gmt_from_date( $resource->post_date ); + // a resource is considered created when the hook is executed within 10 seconds of the post creation date - $resource_created = ( ( time() - 10 ) <= strtotime( $resource->post_date_gmt ) ); + $resource_created = ( ( time() - 10 ) <= strtotime( $gmt_date ) ); if ( 'created' == $this->get_event() && ! $resource_created ) { $should_deliver = false;