| Total Complexity | 3 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | class API extends WP_REST_Controller { |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Register the routes for the objects of the controller. |
||
| 25 | * |
||
| 26 | 1 | * @since 1.0.0 |
|
| 27 | 1 | */ |
|
| 28 | 1 | public function register_routes() { |
|
| 29 | 1 | $version = '1'; |
|
| 30 | $namespace = 'wp-site-monitor/v' . $version; |
||
| 31 | 1 | $endpoint = 'wp-version'; |
|
| 32 | 1 | ||
| 33 | register_rest_route( |
||
| 34 | 1 | $namespace, '/' . $endpoint, array( |
|
| 35 | 1 | array( |
|
| 36 | 1 | 'methods' => WP_REST_Server::READABLE, |
|
| 37 | 1 | 'callback' => array( $this, 'get_wp_version' ), |
|
| 38 | 1 | 'permission_callback' => array( $this, 'check_permissions' ), |
|
| 39 | ), |
||
| 40 | 1 | ) |
|
| 41 | 1 | ); |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Get the current WordPress version number. |
||
| 46 | * |
||
| 47 | * @return string |
||
| 48 | * @since 1.0.0 |
||
| 49 | */ |
||
| 50 | public function get_wp_version() { |
||
| 51 | global $wp_version; |
||
| 52 | |||
| 53 | return $wp_version; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Check if the authenticated user has permission to use an endpoint. |
||
| 58 | * |
||
| 59 | * @return boolean |
||
| 60 | * @since 1.0.0 |
||
| 61 | */ |
||
| 62 | public function check_permissions() { |
||
| 64 | } |
||
| 65 | } |
||
| 66 |