Jake Vanderwerf
2026-02-04 2127b1bdd73ecd2423e443992da4b442f5a3c1a3
inc/integrations/Integrations.php
@@ -2,9 +2,9 @@
namespace JVBase\integrations;
use Exception;
use JVBase\managers\CacheManager;
use JVBase\managers\UploadManager;
use JVBase\meta\MetaManager;
use JVBase\managers\Cache;
use JVBase\meta\Form;
use JVBase\meta\Meta;
use JVBase\managers\ErrorHandler;
use WP_Error;
use WP_Post;
@@ -96,7 +96,7 @@
    * Caching Configuration
    */
   protected ?string $cacheName = null;
   protected CacheManager $cache;
   protected Cache $cache;
   protected array $cacheStrategy = [
      'aggressive' => 3600,  // 1 hour for stable data (e.g., profile info)
      'moderate' => 300,     // 5 minutes for semi-dynamic data (e.g., posts)
@@ -167,7 +167,7 @@
   {
      $this->cacheName = $this->cacheName ?: $this->service_name;
      $this->userID = $userID;
      $this->cache = CacheManager::for('integrations_' . $this->cacheName, $this->ttl);
      $this->cache = Cache::for('integrations_' . $this->cacheName, $this->ttl);
      // Load error stats from cache
      $this->loadErrorStats();
@@ -669,7 +669,7 @@
   protected function clearCache():array
   {
      $success = $this->cache->clear();
      $success = $this->cache->flush();
      return [
         'success'   => $success,
      ];
@@ -1626,10 +1626,7 @@
         $params = $this->addOAuthParams($params);
      }
      $auth_url = $this->oauth['authorize'] . '?' . http_build_query($params);
      return $auth_url;
      return $this->oauth['authorize'] . '?' . http_build_query($params);
   }
   /**
@@ -2084,20 +2081,11 @@
    */
   protected function mapFieldsToService(int $postID, array $mapping): array
   {
      $meta_manager = new MetaManager($postID, 'post');
      $post = get_post($postID);
      $meta_manager = Meta::forPost($postID);
      $service_data = [];
      foreach ($mapping as $wp_field => $service_field) {
         $value = null;
         // Check if it's a post field
         if (property_exists($post, $wp_field)) {
            $value = $post->$wp_field;
         } else {
            // It's a meta field
            $value = $meta_manager->getValue($wp_field);
         }
         $value = $meta_manager->get($wp_field);
         if ($value !== null && $value !== '') {
            $this->setNestedValue($service_data, $service_field, $value);
@@ -2172,7 +2160,7 @@
   protected function getSyncFields(int $postID, string $type, array $additional = []):array
   {
      $meta = new MetaManager($postID, $type);
      $meta = new Meta($postID, $type);
      $fieldsToCheck = [
         'share_to_' . $this->service_name,
         '_keep_synced_' . $this->service_name,
@@ -2933,7 +2921,7 @@
         return '';
      }
      $meta = new MetaManager($this->userID, 'integrations');
      $meta = Meta::forOptions($this->userID.'_integrations');
      $is_connected = $this->isSetUp();
      $credentials = $this->getCredentials();
@@ -3010,7 +2998,7 @@
                  $config['value'] = $credentials[$name]??'';
                  $config['autocomplete'] = 'off';
                  $config['base'] = $this->service_name.'_';
                  $meta->render('form', $name, $config);
                  Form::render($name, null, $config);
               }
            }
            if ($this->handleWebhooks) {
@@ -3041,7 +3029,7 @@
                     $config['value'] = $credentials[$name]??'';
                     $config['base'] = $this->service_name.'_';
                     $config['autocomplete'] = 'off';
                     $meta->render('form', $name, $config);
                     Form::render($name,null, $config);
                  }
                  ?>
               </details>
@@ -3280,7 +3268,7 @@
      if (empty($types)) {
         return;
      }
      $meta = new MetaManager($this->userID, 'integrations');
      $meta = Meta::forOptions($this->userID.'_integrations');
      ?>
      <form>
         <h1><?= $this->title?> Defaults:</h1>
@@ -3292,7 +3280,7 @@
            $config['base'] = $this->service_name.'_';
            $config['autocomplete'] = 'off';
            $meta->render('form', $name, $config);
            echo Form::render($name, null, $config);
         }
         foreach ($this->syncPostTypes as $type) {
            $config = JVB_CONTENT[$type];
@@ -3312,7 +3300,7 @@
                     $c['hint'] = $c['description'];
                     unset($c['description']);
                  }
                  $meta->render('form', $name, $c);
                  echo Form::render($name, null, $c);
               }
               ?>
            </details>