From d53020374b4d3a4452e3b52f43ef0e1b99419cd6 Mon Sep 17 00:00:00 2001 From: Moustafa Gouda Date: Mon, 26 Aug 2024 19:34:41 +0300 Subject: [PATCH] Add Compatibility with Default Tags Metadata --- app/PccSyncManager.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/PccSyncManager.php b/app/PccSyncManager.php index a0b7e9a..913d3b3 100644 --- a/app/PccSyncManager.php +++ b/app/PccSyncManager.php @@ -116,14 +116,29 @@ private function createOrUpdatePost($postId, Article $article, bool $isDraft = f if (!$postId) { $postId = wp_insert_post($data); update_post_meta($postId, PCC_CONTENT_META_KEY, $article->id); + $this->updatePostTags($postId, $article); return $postId; } $data['ID'] = $postId; wp_update_post($data); + $this->updatePostTags($postId, $article); return $postId; } + /** + * Update post tags. + * + * @param $postId + * @param Article $article + */ + private function updatePostTags($postId, Article $article): void + { + if (isset($article->tags) && is_array($article->tags)) { + wp_set_post_terms($postId, $article->tags, 'post_tag', false); + } + } + /** * Get selected integration post type. *