| @@ 47-68 (lines=22) @@ | ||
| 44 | * |
|
| 45 | * @since 2.2.4 |
|
| 46 | */ |
|
| 47 | public function register_routes() { |
|
| 48 | ||
| 49 | // Returns all boxes data. |
|
| 50 | register_rest_route( $this->namespace, '/' . $this->rest_base, array( |
|
| 51 | array( |
|
| 52 | 'methods' => WP_REST_Server::READABLE, |
|
| 53 | 'callback' => array( $this, 'get_items' ), |
|
| 54 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 55 | ), |
|
| 56 | 'schema' => array( $this, 'get_item_schema' ), |
|
| 57 | ) ); |
|
| 58 | ||
| 59 | // Returns specific box's data. |
|
| 60 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<cmb_id>[\w-]+)', array( |
|
| 61 | array( |
|
| 62 | 'methods' => WP_REST_Server::READABLE, |
|
| 63 | 'callback' => array( $this, 'get_item' ), |
|
| 64 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 65 | ), |
|
| 66 | 'schema' => array( $this, 'get_item_schema' ), |
|
| 67 | ) ); |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * Get all public CMB2 boxes. |
|
| @@ 24-45 (lines=22) @@ | ||
| 21 | * |
|
| 22 | * @since 2.2.4 |
|
| 23 | */ |
|
| 24 | public function register_routes() { |
|
| 25 | ||
| 26 | // Returns specific box's fields. |
|
| 27 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<cmb_id>[\w-]+)/fields/', array( |
|
| 28 | array( |
|
| 29 | 'methods' => WP_REST_Server::READABLE, |
|
| 30 | 'callback' => array( $this, 'get_items' ), |
|
| 31 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 32 | ), |
|
| 33 | 'schema' => array( $this, 'get_item_schema' ), |
|
| 34 | ) ); |
|
| 35 | ||
| 36 | // Returns specific field data. |
|
| 37 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<cmb_id>[\w-]+)/fields/(?P<field_id>[\w-]+)', array( |
|
| 38 | array( |
|
| 39 | 'methods' => WP_REST_Server::READABLE, |
|
| 40 | 'callback' => array( $this, 'get_item' ), |
|
| 41 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 42 | ), |
|
| 43 | 'schema' => array( $this, 'get_item_schema' ), |
|
| 44 | ) ); |
|
| 45 | } |
|
| 46 | ||
| 47 | /** |
|
| 48 | * Get all public CMB2 box fields. |
|