/** * @inheritdoc */ public function init() { parent::init(); // Validate given parameters $className = self::className(); $urlValidator = new UrlValidator(['enableIDN' => extension_loaded('intl')]); if (empty($this->endpoint) || !$urlValidator->validate($this->endpoint)) { throw new InvalidConfigException("Class \"{$className}\" requires a valid URL to Wordpress XML-RPC API endpoint to be set in \"\$endpoint\" attribute."); } if (empty($this->username) || empty($this->password)) { throw new InvalidConfigException("Class \"{$className}\" requires a valid Wordpress credentials to be set in \"\$username\" and \"\$password\" attributes."); } if (!is_array($this->proxyConfig)) { throw new InvalidConfigException("Class \"{$className}\" requires \"\$proxyConfig\" to be given in array format."); } if (!is_array($this->httpAuthConfig)) { throw new InvalidConfigException("Class \"{$className}\" requires \"\$httpAuthConfig\" to be given in array format."); } // Create API client $this->_clientInstance = new WordpressClient($this->endpoint, $this->username, $this->password); $this->_clientInstance->setProxy($this->proxyConfig); $this->_clientInstance->setAuth($this->httpAuthConfig); }