From 280b298f12a157144b858a7f6d00b6496408ab69 Mon Sep 17 00:00:00 2001 From: Renato Alves <19148962+renatonascalves@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:08:11 -0300 Subject: [PATCH] Adding CR suggestions. Props @kingkool68. --- admin/apple-actions/class-api-action.php | 2 +- admin/apple-actions/index/class-delete.php | 2 +- admin/apple-actions/index/class-get.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/admin/apple-actions/class-api-action.php b/admin/apple-actions/class-api-action.php index 11b309a4..fce96fbe 100644 --- a/admin/apple-actions/class-api-action.php +++ b/admin/apple-actions/class-api-action.php @@ -94,7 +94,7 @@ protected function is_api_configuration_valid() { * * @param int $post_id The post ID to reset. */ - protected function reset_meta( $post_id ): void { + protected function delete_post_meta( $post_id ): void { delete_post_meta( $post_id, 'apple_news_api_id' ); delete_post_meta( $post_id, 'apple_news_api_revision' ); delete_post_meta( $post_id, 'apple_news_api_created_at' ); diff --git a/admin/apple-actions/index/class-delete.php b/admin/apple-actions/index/class-delete.php index 9ef06cc3..688e2419 100644 --- a/admin/apple-actions/index/class-delete.php +++ b/admin/apple-actions/index/class-delete.php @@ -83,7 +83,7 @@ private function delete() { $this->get_api()->delete_article( $remote_id ); // Delete the API references and mark as deleted. - $this->reset_meta( $this->id ); + $this->delete_post_meta( $this->id ); update_post_meta( $this->id, 'apple_news_api_deleted', time() ); // Clear the cache for post status. diff --git a/admin/apple-actions/index/class-get.php b/admin/apple-actions/index/class-get.php index 5204e222..e1c64895 100644 --- a/admin/apple-actions/index/class-get.php +++ b/admin/apple-actions/index/class-get.php @@ -56,11 +56,11 @@ public function perform() { $article = $this->get_api()->get_article( $apple_id ); } catch ( \Apple_Push_API\Request\Request_Exception $e ) { $article = $e->getMessage(); - } - // Reset the API postmeta if the article is not present in Apple News. - if ( is_string( $article ) && str_contains( $article, 'NOT_FOUND (keyPath articleId)' ) ) { - $this->reset_meta( $this->id ); + // Reset the API postmeta if the article is deleted in Apple News. + if ( is_string( $article ) && str_contains( $article, 'NOT_FOUND (keyPath articleId)' ) ) { + $this->delete_post_meta( $this->id ); + } } if ( empty( $article->data ) ) {