Endpoints
4 months ago
Validator
4 months ago
Main.php
4 months ago
Messages.php
4 months ago
Post_Repository.php
4 months ago
Service_Provider.php
4 months ago
Main.php
102 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Pods\REST\V1; |
| 4 | |
| 5 | // Don't load directly. |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | die( '-1' ); |
| 8 | } |
| 9 | |
| 10 | use Pods\REST\Abstracts\Main_Abstract; |
| 11 | |
| 12 | /** |
| 13 | * Class Main |
| 14 | * |
| 15 | * The main entry point for the REST API. |
| 16 | * |
| 17 | * This class should not contain business logic and merely set up and start the REST API support. |
| 18 | * |
| 19 | * @since 2.8.0 |
| 20 | */ |
| 21 | class Main extends Main_Abstract { |
| 22 | |
| 23 | /** |
| 24 | * REST API URL prefix. |
| 25 | * |
| 26 | * This prefix is appended to the REST API URL ones. |
| 27 | * |
| 28 | * @var string |
| 29 | */ |
| 30 | protected $url_prefix = '/pods/v1'; |
| 31 | |
| 32 | /** |
| 33 | * REST API URL prefix. |
| 34 | * |
| 35 | * This prefix is appended to the REST API URL ones. |
| 36 | * |
| 37 | * @var string |
| 38 | */ |
| 39 | protected $namespace = 'pods'; |
| 40 | |
| 41 | /** |
| 42 | * @var array |
| 43 | */ |
| 44 | protected $registered_endpoints = []; |
| 45 | |
| 46 | /** |
| 47 | * Returns the semantic version for REST API |
| 48 | * |
| 49 | * @since 2.8.0 |
| 50 | * |
| 51 | * @return string |
| 52 | */ |
| 53 | public function get_semantic_version() { |
| 54 | return '1.0.0'; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Returns the string indicating the REST API version. |
| 59 | * |
| 60 | * @since 2.8.0 |
| 61 | * |
| 62 | * @return string |
| 63 | */ |
| 64 | public function get_version() { |
| 65 | return 'v1'; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Returns the Pods REST API namespace string that should be used to register a route. |
| 70 | * |
| 71 | * @since 2.8.0 |
| 72 | * |
| 73 | * @return string |
| 74 | */ |
| 75 | public function get_pods_route_namespace() { |
| 76 | return $this->get_namespace() . '/' . $this->get_version(); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Returns the REST API URL prefix that will be appended to the namespace. |
| 81 | * |
| 82 | * The prefix should be in the `/some/path` format. |
| 83 | * |
| 84 | * @since 2.8.0 |
| 85 | * |
| 86 | * @return string |
| 87 | */ |
| 88 | protected function url_prefix() { |
| 89 | return $this->url_prefix; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * {@inheritDoc} |
| 94 | * |
| 95 | * @since 2.8.0 |
| 96 | */ |
| 97 | public function get_reference_url() { |
| 98 | return esc_url( 'https://docs.pods.io/' ); |
| 99 | } |
| 100 | |
| 101 | } |
| 102 |