protected static function _fetchPage($pageID, $apply_shortcodes = false) { try { $client = new Zend\XmlRpc\Client(self::$wp_root . '/xmlrpc.php'); $c = (object) $client->getProxy(self::$namespace)->callWpMethod(self::$wp_login, self::$wp_password, 'get_page_by_path', array($pageID)); $c->post_content = $client->getProxy(self::$namespace)->callWpMethod(self::$wp_login, self::$wp_password, 'wpautop', array($c->post_content)); if ($apply_shortcodes) { $c->post_content = $client->getProxy(self::$namespace)->callWpMethod(self::$wp_login, self::$wp_password, 'do_shortcode', array($c->post_content)); } } catch (Exception $e) { $c = new Stdclass(); } return $c; }
/** * [setInstance description] * @param DBInstance $instance [description] * @param ConfigInterface $config [description] */ public function sendRequest() { if ($this->getError()->hasError() && !$this->inProgress) { return; } if (class_exists($this->dispatcher)) { $dispatcherClass = $this->dispatcher; $dispatcher = new $dispatcherClass($this->instance->getQuery()); if ($dispatcher instanceof AbstractDispatcher) { $this->inProgress = true; try { $client = new \Zend\XmlRpc\Client($this->getUrl()); $config = $this->config->getRawConfig(); $sql = $this->instance->getQuery()->toString(); $limit = $this->instance->getQuery()->getLimit(); $offset = $this->instance->getQuery()->getOffset(); $di = $client->getProxy('DBInstance'); if ($this->method == 'getAvailableDrivers') { $this->availableDrivers = $di->getAvailableDrivers(); } elseif ($this->method == 'getServerVersion') { $res = $di->getServerVersion(); $this->serverVersion = isset($res['version']) ? $res['version'] : null; } else { $response = $di->getResult($config, $sql, $limit, $offset, $this->instance->getQuery()->isSingle(), $this->getKey(), 'array'); $dispatcher->dispatch($response); } $this->inProgress = false; } catch (\Zend\XmlRpc\Client\Exception\HttpException $e) { $this->getError()->setMessage($e->getMessage()); $this->inProgress = false; } catch (\Zend\XmlRpc\Client\Exception\FaultException $e) { $this->getError()->setMessage($e->getMessage()); $this->inProgress = false; } catch (\Exception $e) { $this->getError()->setMessage('Error server response'); $this->inProgress = false; } } else { $this->getError()->setMessage(sprintf('Dispatcher class must be instance of %s, %s given', AbstractDispatcher::class, (string) $this->dispatcher)); } } else { $this->getError()->setMessage(sprintf('Class %s not found', (string) $this->dispatcher)); } }