Jake Vanderwerf
2026-09-14 7935d26cd16a4f8f69a59a44e27a7263b60e54bf
inc/integrations/SyncToTerm.php
@@ -1,6 +1,7 @@
<?php
namespace JVBase\integrations;
use JVBase\managers\queue\Queue;
use JVBase\meta\Meta;
use JVBase\registrar\Registrar;
@@ -25,10 +26,13 @@
      if (empty($this->syncTaxonomies)) {
         return;
      }
      remove_action('saved_term', [$this, 'handleSaveTerm'], 20, 3);
      remove_action('saved_term', [$this, 'handleSaveTerm'], 20);
   }
   protected function handleSaveTerm(int $termID, int $tt_id, string $taxonomy, bool $update, array $args):void
   {
      if (isset(self::$syncing['terms'][$termID])) {
         return;
      }
      $tax = jvbNoBase($taxonomy);
      if (!in_array($tax, $this->syncTaxonomies)) {
         return;
@@ -53,19 +57,25 @@
      if ($isShared && $update && !$fields['_keep_synced_'.$this->service_name]) {
         return;
      }
      self::$syncing['terms'][$termID] = true;
      $this->removeSaveTerm();
      $this->handleTheSaveTerm($termID, $update, $taxonomy, $settings);
      $this->addSaveTerm();
      unset(self::$syncing['terms'][$termID]);
   }
   /**
    * @param int $termID
    * @param bool $update
    * @param string $taxonomy
    * @param array $settings
    * @return void
    */
   protected function handleTheSaveTerm(int $termID, bool $update, string $taxonomy, array $settings):void
   {
      if (!$this->isSetUp()) {
         return;
      }
      error_log('==== ['.$this->title.']::handleTheSaveTerm ====');
      //TODO: Figure out some sort of permissions for if the user can share this term, particularly for content types
      //TODO: If this is a content type, it likely has its own integration. This is an edmonton.ink problem, so I'm offloading it for now
@@ -91,6 +101,9 @@
   }
   public function handleDeleteTerm(int $termID, string $taxonomy):void
   {
      if (!$this->isSetUp()) {
         return;
      }
      if (!$this->canSync['delete']) {
         return;
      }
@@ -102,7 +115,7 @@
      if (empty($fields["_{$this->service_name}_item_id"])) {
         return;
      }
      JVB()->queue()->add(
      Queue::getInstance()->add(
         self::$deleteFrom,
         0,
         [