@@ 31-51 (lines=21) @@ | ||
28 | * |
|
29 | * @since 2.2.0 |
|
30 | */ |
|
31 | public function register_routes() { |
|
32 | // Returns all boxes data. |
|
33 | register_rest_route( CMB2_REST::BASE, '/boxes/', array( |
|
34 | array( |
|
35 | 'methods' => WP_REST_Server::READABLE, |
|
36 | 'callback' => array( $this, 'get_items' ), |
|
37 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
38 | ), |
|
39 | 'schema' => array( $this, 'get_item_schema' ), |
|
40 | ) ); |
|
41 | ||
42 | // Returns specific box's data. |
|
43 | register_rest_route( CMB2_REST::BASE, '/boxes/(?P<cmb_id>[\w-]+)', array( |
|
44 | array( |
|
45 | 'methods' => WP_REST_Server::READABLE, |
|
46 | 'callback' => array( $this, 'get_item' ), |
|
47 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
48 | ), |
|
49 | 'schema' => array( $this, 'get_item_schema' ), |
|
50 | ) ); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * Get all public fields |
@@ 31-51 (lines=21) @@ | ||
28 | * |
|
29 | * @since 2.2.0 |
|
30 | */ |
|
31 | public function register_routes() { |
|
32 | // Returns specific box's fields. |
|
33 | register_rest_route( CMB2_REST::BASE, '/boxes/(?P<cmb_id>[\w-]+)/fields/', array( |
|
34 | array( |
|
35 | 'methods' => WP_REST_Server::READABLE, |
|
36 | 'callback' => array( $this, 'get_items' ), |
|
37 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
38 | ), |
|
39 | 'schema' => array( $this, 'get_item_schema' ), |
|
40 | ) ); |
|
41 | ||
42 | // Returns specific field data. |
|
43 | register_rest_route( CMB2_REST::BASE, '/boxes/(?P<cmb_id>[\w-]+)/fields/(?P<field_id>[\w-]+)', array( |
|
44 | array( |
|
45 | 'methods' => WP_REST_Server::READABLE, |
|
46 | 'callback' => array( $this, 'get_item' ), |
|
47 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
48 | ), |
|
49 | 'schema' => array( $this, 'get_item_schema' ), |
|
50 | ) ); |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * Get all box fields |