| @@ 116-143 (lines=28) @@ | ||
| 113 | ); |
|
| 114 | } |
|
| 115 | ||
| 116 | private function register_accept_route() { |
|
| 117 | register_rest_route( |
|
| 118 | Api_Config::REST_NAMESPACE, |
|
| 119 | '/entity/accept', |
|
| 120 | array( |
|
| 121 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 122 | 'callback' => array( $this, 'accept_entity' ), |
|
| 123 | //@todo : review the permission level |
|
| 124 | 'permission_callback' => function () { |
|
| 125 | return current_user_can( 'manage_options' ); |
|
| 126 | }, |
|
| 127 | 'args' => array( |
|
| 128 | 'term_id' => array( |
|
| 129 | 'validate_callback' => function ( $param, $request, $key ) { |
|
| 130 | return is_numeric( $param ) && $param; |
|
| 131 | }, |
|
| 132 | 'required' => true, |
|
| 133 | ), |
|
| 134 | 'entity' => array( |
|
| 135 | 'validate_callback' => function ( $param, $request, $key ) { |
|
| 136 | return is_array( $param ); |
|
| 137 | }, |
|
| 138 | 'required' => true, |
|
| 139 | ), |
|
| 140 | ), |
|
| 141 | ) |
|
| 142 | ); |
|
| 143 | } |
|
| 144 | ||
| 145 | private function register_nomatch_route() { |
|
| 146 | register_rest_route( |
|
| @@ 37-64 (lines=28) @@ | ||
| 34 | public function register_routes() { |
|
| 35 | $that = $this; |
|
| 36 | add_action( 'rest_api_init', |
|
| 37 | function () use ( $that ) { |
|
| 38 | register_rest_route( |
|
| 39 | Api_Config::REST_NAMESPACE, |
|
| 40 | '/tags', |
|
| 41 | array( |
|
| 42 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 43 | 'callback' => array( $that, 'get_tags' ), |
|
| 44 | //@todo : review the permission level |
|
| 45 | 'permission_callback' => function () { |
|
| 46 | return current_user_can( 'manage_options' ); |
|
| 47 | }, |
|
| 48 | 'args' => array( |
|
| 49 | 'limit' => array( |
|
| 50 | 'validate_callback' => function ( $param, $request, $key ) { |
|
| 51 | return is_numeric( $param ) && $param; |
|
| 52 | }, |
|
| 53 | 'required' => true, |
|
| 54 | ), |
|
| 55 | 'offset' => array( |
|
| 56 | 'validate_callback' => function ( $param, $request, $key ) { |
|
| 57 | return is_numeric( $param ); |
|
| 58 | }, |
|
| 59 | 'required' => true, |
|
| 60 | ), |
|
| 61 | ), |
|
| 62 | ) |
|
| 63 | ); |
|
| 64 | } ); |
|
| 65 | ||
| 66 | ||
| 67 | } |
|