1 | <?php |
||
11 | class Router { |
||
12 | |||
13 | /** |
||
14 | * Carbon Fields routes |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $routes = array( |
||
19 | 'post_meta' => array( |
||
20 | 'path' => '/posts/(?P<id>\d+)', |
||
21 | 'callback' => 'get_post_meta', |
||
22 | 'permission_callback' => 'allow_access', |
||
23 | 'methods' => 'GET', |
||
24 | ), |
||
25 | 'term_meta' => array( |
||
26 | 'path' => '/terms/(?P<id>\d+)', |
||
27 | 'callback' => 'get_term_meta', |
||
28 | 'permission_callback' => 'allow_access', |
||
29 | 'methods' => 'GET', |
||
30 | ), |
||
31 | 'user_meta' => array( |
||
32 | 'path' => '/users/(?P<id>\d+)', |
||
33 | 'callback' => 'get_user_meta', |
||
34 | 'permission_callback' => 'allow_access', |
||
35 | 'methods' => 'GET', |
||
36 | ), |
||
37 | 'comment_meta' => array( |
||
38 | 'path' => '/comments/(?P<id>\d+)', |
||
39 | 'callback' => 'get_comment_meta', |
||
40 | 'permission_callback' => 'allow_access', |
||
41 | 'methods' => 'GET', |
||
42 | ), |
||
43 | 'theme_options' => array( |
||
44 | 'path' => '/options/', |
||
45 | 'callback' => 'options_accessor', |
||
46 | 'permission_callback' => 'options_permission', |
||
47 | 'methods' => array( 'GET', 'POST' ), |
||
48 | ), |
||
49 | ); |
||
50 | |||
51 | /** |
||
52 | * Version of the API |
||
53 | * |
||
54 | * @see set_version() |
||
55 | * @see get_version() |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $version = '1'; |
||
59 | |||
60 | /** |
||
61 | * Vendor slug for the API |
||
62 | * |
||
63 | * @see set_vendor() |
||
64 | * @see get_vendor() |
||
65 | * @var string |
||
66 | */ |
||
67 | protected $vendor = 'carbon-fields'; |
||
68 | |||
69 | /** |
||
70 | * ContainerRepository instance |
||
71 | * |
||
72 | * @var ContainerRepository |
||
73 | */ |
||
74 | protected $container_repository; |
||
75 | |||
76 | /** |
||
77 | * @param ContainerRepository $container_repository |
||
78 | */ |
||
79 | public function __construct( ContainerRepository $container_repository ) { |
||
82 | |||
83 | /** |
||
84 | * Boot up functionality |
||
85 | */ |
||
86 | public function boot() { |
||
89 | |||
90 | /** |
||
91 | * Set routes |
||
92 | */ |
||
93 | public function set_routes( $routes ) { |
||
96 | |||
97 | /** |
||
98 | * Return routes |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | public function get_routes() { |
||
105 | |||
106 | /** |
||
107 | * Set version |
||
108 | */ |
||
109 | public function set_version( $version ) { |
||
112 | |||
113 | /** |
||
114 | * Return version |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | public function get_version() { |
||
121 | |||
122 | /** |
||
123 | * Set vendor |
||
124 | */ |
||
125 | public function set_vendor( $vendor ) { |
||
128 | |||
129 | /** |
||
130 | * Return vendor |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | public function get_vendor() { |
||
137 | |||
138 | /** |
||
139 | * Allow access to an endpoint |
||
140 | * |
||
141 | * @return bool |
||
142 | */ |
||
143 | public function allow_access() { |
||
146 | |||
147 | /** |
||
148 | * Register custom routes |
||
149 | * |
||
150 | * @see register_route() |
||
151 | */ |
||
152 | public function register_routes() { |
||
157 | |||
158 | /** |
||
159 | * Register a custom REST route |
||
160 | * |
||
161 | * @param array $route |
||
162 | */ |
||
163 | protected function register_route( $route ) { |
||
170 | |||
171 | /** |
||
172 | * Proxy method for handling get/set for theme options |
||
173 | * |
||
174 | * @param WP_REST_Request $request |
||
175 | * @return array|WP_REST_Response |
||
176 | */ |
||
177 | public function options_accessor( $request ) { |
||
186 | |||
187 | /** |
||
188 | * Proxy method for handling theme options permissions |
||
189 | * |
||
190 | * @param WP_REST_Request $request |
||
191 | * @return bool |
||
192 | */ |
||
193 | public function options_permission( $request ) { |
||
202 | |||
203 | /** |
||
204 | * Wrapper method used for retrieving data from Data_Manager |
||
205 | * |
||
206 | * @param string $container_type |
||
207 | * @param string $id |
||
|
|||
208 | * @return array |
||
209 | */ |
||
210 | protected function get_all_field_values( $container_type, $object_id = null ) { |
||
229 | |||
230 | /** |
||
231 | * Get Carbon Fields post meta values |
||
232 | * |
||
233 | * @param array $data |
||
234 | * @return array |
||
235 | */ |
||
236 | public function get_post_meta( $data ) { |
||
240 | |||
241 | /** |
||
242 | * Get Carbon Fields user meta values |
||
243 | * |
||
244 | * @param array $data |
||
245 | * @return array |
||
246 | */ |
||
247 | public function get_user_meta( $data ) { |
||
251 | |||
252 | /** |
||
253 | * Get Carbon Fields term meta values |
||
254 | * |
||
255 | * @param array $data |
||
256 | * @return array |
||
257 | */ |
||
258 | public function get_term_meta( $data ) { |
||
262 | |||
263 | /** |
||
264 | * Get Carbon Fields comment meta values |
||
265 | * |
||
266 | * @param array $data |
||
267 | * @return array |
||
268 | */ |
||
269 | public function get_comment_meta( $data ) { |
||
273 | |||
274 | /** |
||
275 | * Retrieve Carbon theme options |
||
276 | * |
||
277 | * @return array |
||
278 | */ |
||
279 | protected function get_options() { |
||
283 | |||
284 | /** |
||
285 | * Set Carbon theme options |
||
286 | * |
||
287 | * @param WP_REST_Request $request Full data about the request. |
||
288 | * @return WP_Error|WP_REST_Response |
||
289 | */ |
||
290 | protected function set_options( $request ) { |
||
310 | } |
||
311 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.