class-plugin-route.php
1 month ago
class-preset-route.php
1 month ago
class-search-route.php
1 month ago
class-settings-route.php
1 month ago
class-source-route.php
1 month ago
class-plugin-route.php
37 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SearchRegex\Api\Route; |
| 4 | |
| 5 | use SearchRegex\Api; |
| 6 | use WP_REST_Request; |
| 7 | |
| 8 | /** |
| 9 | * 'Plugin' functions for Search Regex |
| 10 | */ |
| 11 | class Plugin_Route extends Api\Route { |
| 12 | /** |
| 13 | * Plugin API endpoint constructor |
| 14 | * |
| 15 | * @param non-falsy-string $namespace Namespace. |
| 16 | */ |
| 17 | public function __construct( $namespace ) { |
| 18 | register_rest_route( |
| 19 | $namespace, '/plugin/test', [ |
| 20 | $this->get_route( \WP_REST_Server::ALLMETHODS, 'route_test', [ $this, 'permission_callback' ] ), |
| 21 | ] |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Test the API |
| 27 | * |
| 28 | * @param WP_REST_Request<array<string, mixed>> $_request Request. |
| 29 | * @return array{success: bool} |
| 30 | */ |
| 31 | public function route_test( WP_REST_Request $_request ) { |
| 32 | return [ |
| 33 | 'success' => true, |
| 34 | ]; |
| 35 | } |
| 36 | } |
| 37 |