PluginProbe
WooCommerce / 11.0.1
WooCommerce v11.0.1
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / vendor / wordpress / abilities-api / includes / rest-api / class-wp-rest-abilities-init.php
class-wp-rest-abilities-init.php
61 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * REST API initialization for Abilities API.
4 *
5 * @package WordPress
6 * @subpackage Abilities_API
7 * @since 0.1.0
8 */
9
10 declare( strict_types = 1 );
11
12 /**
13 * Handles initialization of Abilities REST API endpoints.
14 *
15 * @since 0.1.0
16 */
17 class WP_REST_Abilities_Init {
18
19 /**
20 * Registers the REST API routes for abilities.
21 *
22 * @since 0.1.0
23 *
24 * @param WP_REST_Server|null $rest_server Optional. The REST server to register routes with. Default null, which
25 * will use the main REST server instance.
26 */
27 public static function register_routes( $rest_server = null ): void {
28 if ( ! $rest_server instanceof WP_REST_Server ) {
29 $rest_server = rest_get_server();
30 }
31
32 $routes = $rest_server->get_routes();
33
34 if ( ! isset( $routes['/wp-abilities/v1/categories'] ) ) {
35 if ( ! class_exists( 'WP_REST_Abilities_V1_Categories_Controller' ) ) {
36 require_once __DIR__ . '/endpoints/class-wp-rest-abilities-v1-categories-controller.php';
37 }
38 $categories_controller = new WP_REST_Abilities_V1_Categories_Controller();
39 $categories_controller->register_routes();
40 }
41
42 if ( ! isset( $routes['/wp-abilities/v1/abilities/(?P<name>[a-zA-Z0-9\\-\\/]+?)/run'] ) ) {
43 if ( ! class_exists( 'WP_REST_Abilities_V1_Run_Controller' ) ) {
44 require_once __DIR__ . '/endpoints/class-wp-rest-abilities-v1-run-controller.php';
45 }
46 $run_controller = new WP_REST_Abilities_V1_Run_Controller();
47 $run_controller->register_routes();
48 }
49
50 if ( isset( $routes['/wp-abilities/v1/abilities'] ) ) {
51 return;
52 }
53
54 if ( ! class_exists( 'WP_REST_Abilities_V1_List_Controller' ) ) {
55 require_once __DIR__ . '/endpoints/class-wp-rest-abilities-v1-list-controller.php';
56 }
57 $list_controller = new WP_REST_Abilities_V1_List_Controller();
58 $list_controller->register_routes();
59 }
60 }
61