Skip to content

Commit 3e5caf5

Browse files
committed
Enable Custom & Search Endpoint
1 parent 8152c02 commit 3e5caf5

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

app/Endpoint/AbstractWpEndpoint.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function __construct(Wordpress $client)
2929
$this->client = $client;
3030
}
3131

32+
3233
abstract protected function getEndpoint();
3334

3435
/**
@@ -59,11 +60,7 @@ public function get($id = null, array $params = null)
5960
$response->hasHeader('Content-Type')
6061
&& substr($response->getHeader('Content-Type')[0], 0, 16) === 'application/json'
6162
) {
62-
$dataRespon = [
63-
'body' => json_decode($response->getBody()->getContents(), true),
64-
'total' => $response->getHeader('X-WP-Total'),
65-
'totalpages' => $response->getHeader('X-WP-TotalPages'),
66-
];
63+
$dataRespon = json_decode($response->getBody()->getContents(), true);
6764

6865
return $dataRespon;
6966
}

app/Endpoint/Custom.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Reactmore\WordpressClient\Endpoint;
4+
5+
/**
6+
* Class Posts
7+
* @package Reactmore\WordpressClient\Endpoint
8+
*/
9+
class Custom extends AbstractWpEndpoint
10+
{
11+
/**
12+
* {@inheritdoc}
13+
*/
14+
protected function getEndpoint()
15+
{
16+
return '/wp-json/custom/v1/all-posts';
17+
}
18+
}

app/Endpoint/Search.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Reactmore\WordpressClient\Endpoint;
4+
5+
/**
6+
* Class Posts
7+
* @package Reactmore\WordpressClient\Endpoint
8+
*/
9+
class Search extends AbstractWpEndpoint
10+
{
11+
/**
12+
* {@inheritdoc}
13+
*/
14+
protected function getEndpoint()
15+
{
16+
return '/wp-json/wp/v2/search';
17+
}
18+
}

0 commit comments

Comments
 (0)