Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Endpoint/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Categories extends AbstractWpEndpoint
*/
protected function getEndpoint()
{
return '/wp-json/wp/v2/categories';
return '/wp/v2/categories';
}
}
2 changes: 1 addition & 1 deletion src/Endpoint/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Comments extends AbstractWpEndpoint
*/
protected function getEndpoint()
{
return '/wp-json/wp/v2/comments';
return '/wp/v2/comments';
}
}
2 changes: 1 addition & 1 deletion src/Endpoint/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Media extends AbstractWpEndpoint
*/
protected function getEndpoint()
{
return '/wp-json/wp/v2/media';
return '/wp/v2/media';
}
}
2 changes: 1 addition & 1 deletion src/Endpoint/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Pages extends AbstractWpEndpoint
*/
protected function getEndpoint()
{
return '/wp-json/wp/v2/pages';
return '/wp/v2/pages';
}
}
2 changes: 1 addition & 1 deletion src/Endpoint/PostStatuses.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class PostStatuses extends AbstractWpEndpoint
*/
protected function getEndpoint()
{
return '/wp-json/wp/v2/statuses';
return '/wp/v2/statuses';
}
}
2 changes: 1 addition & 1 deletion src/Endpoint/PostTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class PostTypes extends AbstractWpEndpoint
*/
protected function getEndpoint()
{
return '/wp-json/wp/v2/types';
return '/wp/v2/types';
}
}
2 changes: 1 addition & 1 deletion src/Endpoint/Posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Posts extends AbstractWpEndpoint
*/
protected function getEndpoint()
{
return '/wp-json/wp/v2/posts';
return '/wp/v2/posts';
}
}
2 changes: 1 addition & 1 deletion src/Endpoint/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Tags extends AbstractWpEndpoint
*/
protected function getEndpoint()
{
return '/wp-json/wp/v2/tags';
return '/wp/v2/tags';
}
}
2 changes: 1 addition & 1 deletion src/Endpoint/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Users extends AbstractWpEndpoint
*/
protected function getEndpoint()
{
return '/wp-json/wp/v2/users';
return '/wp/v2/users';
}
}
19 changes: 17 additions & 2 deletions src/WpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class WpClient
*/
private $wordpressUrl;

/**
* @var string
*/
private $restApiPrefix;

/**
* @var array
*/
Expand All @@ -49,11 +54,13 @@ class WpClient
* WpClient constructor.
* @param ClientInterface $httpClient
* @param string $wordpressUrl
* @param string $restApiPrefix
*/
public function __construct(ClientInterface $httpClient, $wordpressUrl = '')
public function __construct(ClientInterface $httpClient, $wordpressUrl = '', $restApiPrefix = 'wp-json')
{
$this->httpClient = $httpClient;
$this->wordpressUrl = $wordpressUrl;
$this->restApiPrefix = $restApiPrefix;
}

/**
Expand All @@ -64,6 +71,14 @@ public function setWordpressUrl($wordpressUrl)
$this->wordpressUrl = $wordpressUrl;
}

/**
* @param $restApiPrefix
*/
public function setRestApiPrefix($restApiPrefix)
{
$this->restApiPrefix = $restApiPrefix;
}

/**
* @param AuthInterface $auth
*/
Expand Down Expand Up @@ -102,7 +117,7 @@ public function send(RequestInterface $request)
}

$request = $request->withUri(
$this->httpClient->makeUri($this->wordpressUrl . $request->getUri())
$this->httpClient->makeUri($this->wordpressUrl . "/{$this->restApiPrefix}" . $request->getUri())
);

return $this->httpClient->send($request);
Expand Down