Merge pull request #12466 from woocommerce/fix/webhook-resource-delete

[2.6] Fixed when should deliver wp_trash_post
This commit is contained in:
Claudio Sanches 2016-11-25 12:03:11 -02:00 committed by GitHub
commit 2e76eff151
1 changed files with 9 additions and 5 deletions

View File

@ -137,11 +137,16 @@ class WC_Webhook {
// only active webhooks can be delivered
if ( 'active' != $this->get_status() ) {
$should_deliver = false;
} elseif ( in_array( $current_action, array( 'delete_post', 'wp_trash_post' ), true ) ) {
// Only deliver deleted event for coupons, orders, and products.
if ( ! in_array( $GLOBALS['post_type'], array( 'shop_coupon', 'shop_order', 'product' ) ) ) {
$should_deliver = false;
}
// only deliver deleted event for coupons, orders, and products
} elseif ( 'delete_post' === $current_action && ! in_array( $GLOBALS['post_type'], array( 'shop_coupon', 'shop_order', 'product' ) ) ) {
$should_deliver = false;
// Check if is delivering for the correct resource.
if ( str_replace( 'shop_', '', $GLOBALS['post_type'] ) !== $this->get_resource() ) {
$should_deliver = false;
}
} elseif ( 'delete_user' == $current_action ) {
$user = get_userdata( absint( $arg ) );
@ -187,7 +192,6 @@ class WC_Webhook {
* @param mixed $arg First hook argument.
*/
public function deliver( $arg ) {
$payload = $this->build_payload( $arg );
// Setup request args.