wp plugin refacotr

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-01 06:57:54 +00:00
parent 7357846527
commit 50af3501ac
8 changed files with 602 additions and 55 deletions

View File

@@ -594,20 +594,30 @@ class Igny8RestAPI {
}
// Create WordPress post
$post_id = igny8_create_wordpress_post_from_task($content_data);
$result = igny8_create_wordpress_post_from_task($content_data);
if (is_wp_error($post_id)) {
if (is_wp_error($result)) {
return $this->build_unified_response(
false,
null,
'Failed to create WordPress post: ' . $post_id->get_error_message(),
'Failed to create WordPress post: ' . $result->get_error_message(),
'post_creation_failed',
null,
500
);
}
// Return success response
// Handle new return format (array with post_id and term_ids)
if (is_array($result) && isset($result['post_id'])) {
$post_id = $result['post_id'];
$term_ids = $result['term_ids'] ?? array();
} else {
// Legacy format (just post_id)
$post_id = $result;
$term_ids = array();
}
// Return success response with term_ids
return $this->build_unified_response(
true,
array(
@@ -615,7 +625,8 @@ class Igny8RestAPI {
'post_url' => get_permalink($post_id),
'post_status' => get_post_status($post_id),
'content_id' => $content_id,
'task_id' => $task_id
'task_id' => $task_id,
'term_ids' => $term_ids
),
'Content successfully published to WordPress',
null,