| | |
| | | <?php |
| | | namespace JVBase\integrations; |
| | | |
| | | use JVBase\managers\queue\Queue; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | |
| | |
| | | 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; |
| | |
| | | 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 |
| | |
| | | } |
| | | public function handleDeleteTerm(int $termID, string $taxonomy):void |
| | | { |
| | | if (!$this->isSetUp()) { |
| | | return; |
| | | } |
| | | if (!$this->canSync['delete']) { |
| | | return; |
| | | } |
| | |
| | | if (empty($fields["_{$this->service_name}_item_id"])) { |
| | | return; |
| | | } |
| | | JVB()->queue()->add( |
| | | Queue::getInstance()->add( |
| | | self::$deleteFrom, |
| | | 0, |
| | | [ |