From c68aefb847b09daa0697de7684d3451e2e68ce1e Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 09 Jul 2026 23:10:23 +0000
Subject: [PATCH] =Refactor of Integrations.php to be a bit more useful with a suite of methods for create, update, delete back and forths for integrations where sharing is enabled. Also considering a single instance with a connect method to connect as the site (no user) vs connecting as an individual user - rather than recreating instances for every user.
---
inc/integrations/Instagram.php | 23 +++++++++++------------
1 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/inc/integrations/Instagram.php b/inc/integrations/Instagram.php
index 77abcf0..3968e45 100644
--- a/inc/integrations/Instagram.php
+++ b/inc/integrations/Instagram.php
@@ -6,6 +6,7 @@
namespace JVBase\integrations;
use JVBase\integrations\Integrations;
+use JVBase\meta\Meta;
use WP_Error;
use WP_REST_Request;
use WP_REST_Response;
@@ -261,24 +262,22 @@
*/
public function handleTheSavePost(int $postID, \WP_Post $post, bool $update, array $settings): void
{
- // Check if post has featured image (Instagram requirement)
+
+ if (!$this->hasOAuthCredentials()) {
+ error_log('OAuth Not set up for '.$this->service_name);
+ return;
+ }
if (!has_post_thumbnail($postID)) {
- $this->logError('Cannot post to Instagram without featured image', [
- 'post_id' => $postID
- ]);
return;
}
- // Queue the Instagram post creation
- $this->queueOperation('create_post', [
- 'post_id' => $postID,
- 'type' => get_post_type($postID)
+ $this->queueOperation(self::$syncTo, [
+ 'items' => [$postID],
+ 'user' => user_can($post->post_author, 'manage_options') ? null : $post->post_author
], [
- 'priority' => 'normal',
- 'delay' => 60 // Wait 1 minute to ensure all metadata is saved
+ 'delay' => 60
]);
-
- update_post_meta($postID, BASE . '_instagram_sync_status', 'queued');
+ Meta::forPost($postID)->set('_'.$this->service_name.'_sync_status', 'queued');
}
/**
--
Gitblit v1.10.0