| | |
| | | * These properties define how the integration connects to external services |
| | | */ |
| | | protected string|array $apiBase = ''; // Base URL(s) for API endpoints. Array format: ['base' => '', 'auth' => ''] |
| | | /** |
| | | * @var array<APIEndpoint> An array of endpoints objects, with optional create, update, delete, batch<x>, and batchImport |
| | | */ |
| | | protected array $apiEndpoints = []; // Valid endpoint paths for this service |
| | | |
| | | protected int $refresh_interval = 0; //seconds before expiry to refresh tokens. 0 to disable |
| | |
| | | $this->userID = $userID; |
| | | $this->cache = Cache::for('integrations_' . $this->cacheName); |
| | | |
| | | |
| | | $this->getPostTypes(); |
| | | $this->getTaxonomies(); |
| | | $this->getUsers(); |
| | |
| | | } |
| | | |
| | | try { |
| | | if ($this->isOAuthService && !$this->hasOAuthCredentials()){ |
| | | if (!$this->hasOAuthCredentials()){ |
| | | //If this is an OAuth service, we might only be saving the app credentials first |
| | | $result = true; |
| | | } else { |
| | |
| | | |
| | | |
| | | if (!empty($this->syncPostTypes)) { |
| | | $this->addSavePost(); |
| | | if (method_exists($this, 'addSavePost')) { |
| | | $this->addSavePost(); |
| | | } |
| | | |
| | | add_action('transition_post_status', [$this, 'handlePostStatusTransition'], 10, 3); |
| | | |
| | | if ($this->canSync['delete']) { |
| | |
| | | |
| | | public function hasOAuthCredentials(?int $userID = null): bool |
| | | { |
| | | if ($userID !== $this->userID) { |
| | | $this->switchUser($userID); |
| | | } |
| | | return $this->hasOAuth && $this->hasValidOAuth(); |
| | | return false; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | public static function hasExtraOptions():bool |
| | | { |
| | | return static::getInstance()::$hasExtraOptions; |
| | | return self::$hasExtraOptions; |
| | | } |
| | | |
| | | /** |