From 2174c1a180ae1632caa8d860d959a47441d7b09e Mon Sep 17 00:00:00 2001 From: Ravi Chandra Date: Fri, 18 Jan 2019 16:40:23 +0530 Subject: [PATCH 1/4] Fix featured image delete push issue --- includes/classes/API/SubscriptionsController.php | 3 +++ includes/rest-api.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/includes/classes/API/SubscriptionsController.php b/includes/classes/API/SubscriptionsController.php index 10234df00..d3341db05 100644 --- a/includes/classes/API/SubscriptionsController.php +++ b/includes/classes/API/SubscriptionsController.php @@ -280,6 +280,9 @@ public function receive_item( $request ) { if ( ! empty( $request['post_data']['distributor_media'] ) ) { \Distributor\Utils\set_media( $request['post_id'], $request['post_data']['distributor_media'] ); + } else { + // remove any previously set featured image + delete_post_meta( $post->ID, '_thumbnail_id' ); } $response = new \WP_REST_Response(); diff --git a/includes/rest-api.php b/includes/rest-api.php index cb36cee3b..3e5531f50 100644 --- a/includes/rest-api.php +++ b/includes/rest-api.php @@ -113,6 +113,9 @@ function process_distributor_attributes( $post, $request, $update ) { if ( isset( $request['distributor_media'] ) ) { \Distributor\Utils\set_media( $post->ID, $request['distributor_media'] ); + } else { + // remove any previously set featured image + delete_post_meta( $post->ID, '_thumbnail_id' ); } /** From 5fc8da90a782a1def6eb6baa0316a834fc2cd109 Mon Sep 17 00:00:00 2001 From: Ravi Chandra Date: Fri, 18 Jan 2019 16:47:57 +0530 Subject: [PATCH 2/4] Use correct post_id property --- includes/classes/API/SubscriptionsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/classes/API/SubscriptionsController.php b/includes/classes/API/SubscriptionsController.php index d3341db05..8f44e5c28 100644 --- a/includes/classes/API/SubscriptionsController.php +++ b/includes/classes/API/SubscriptionsController.php @@ -282,7 +282,7 @@ public function receive_item( $request ) { \Distributor\Utils\set_media( $request['post_id'], $request['post_data']['distributor_media'] ); } else { // remove any previously set featured image - delete_post_meta( $post->ID, '_thumbnail_id' ); + delete_post_meta( (int) $request['post_id'], '_thumbnail_id' ); } $response = new \WP_REST_Response(); From 8ee42ea317c763f0b5cbe7e055b7197e88a174f6 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Thu, 31 Aug 2023 08:53:24 -0500 Subject: [PATCH 3/4] Update includes/classes/API/SubscriptionsController.php Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> --- includes/classes/API/SubscriptionsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/classes/API/SubscriptionsController.php b/includes/classes/API/SubscriptionsController.php index f87eb2bb6..01813cf6d 100644 --- a/includes/classes/API/SubscriptionsController.php +++ b/includes/classes/API/SubscriptionsController.php @@ -288,7 +288,7 @@ public function receive_item( $request ) { if ( ! empty( $request['post_data']['distributor_media'] ) ) { \Distributor\Utils\set_media( $request['post_id'], $request['post_data']['distributor_media'] ); } else { - // remove any previously set featured image + // Remove any previously set featured image. delete_post_meta( (int) $request['post_id'], '_thumbnail_id' ); } From 37e7a8852736053649839cdf767d5720488a9fb8 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Thu, 31 Aug 2023 08:53:34 -0500 Subject: [PATCH 4/4] Update includes/rest-api.php Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> --- includes/rest-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/rest-api.php b/includes/rest-api.php index 7298d2747..67abdc838 100644 --- a/includes/rest-api.php +++ b/includes/rest-api.php @@ -118,7 +118,7 @@ function process_distributor_attributes( $post, $request, $update ) { if ( isset( $request['distributor_media'] ) ) { \Distributor\Utils\set_media( $post->ID, $request['distributor_media'] ); } else { - // remove any previously set featured image + // Remove any previously set featured image. delete_post_meta( $post->ID, '_thumbnail_id' ); }