@@ 279-293 (lines=15) @@ | ||
276 | * @param string $controller Optional, controller class for route. If not set "WP_REST_Posts_Controller" is |
|
277 | * used. |
|
278 | */ |
|
279 | public static function post_type_rest_support( $post_type_name, $rest_base = false, $controller = 'WP_REST_Posts_Controller' ) { |
|
280 | ||
281 | global $wp_post_types; |
|
282 | ||
283 | if ( isset( $wp_post_types[ $post_type_name ] ) ) { |
|
284 | if ( ! $rest_base ) { |
|
285 | $rest_base = $post_type_name; |
|
286 | } |
|
287 | ||
288 | $wp_post_types[ $post_type_name ]->show_in_rest = true; |
|
289 | $wp_post_types[ $post_type_name ]->rest_base = $rest_base; |
|
290 | $wp_post_types[ $post_type_name ]->rest_controller_class = $controller; |
|
291 | } |
|
292 | ||
293 | } |
|
294 | ||
295 | /** |
|
296 | * Add REST API support to an already registered taxonomy. |
|
@@ 305-319 (lines=15) @@ | ||
302 | * @param string $controller Optional, controller class for route. If not set "WP_REST_Terms_Controller" is |
|
303 | * used. |
|
304 | */ |
|
305 | public static function taxonomy_rest_support( $taxonomy_name, $rest_base = false, $controller = 'WP_REST_Terms_Controller' ) { |
|
306 | ||
307 | global $wp_taxonomies; |
|
308 | ||
309 | if ( isset( $wp_taxonomies[ $taxonomy_name ] ) ) { |
|
310 | if ( ! $rest_base ) { |
|
311 | $rest_base = $taxonomy_name; |
|
312 | } |
|
313 | ||
314 | $wp_taxonomies[ $taxonomy_name ]->show_in_rest = true; |
|
315 | $wp_taxonomies[ $taxonomy_name ]->rest_base = $rest_base; |
|
316 | $wp_taxonomies[ $taxonomy_name ]->rest_controller_class = $controller; |
|
317 | } |
|
318 | ||
319 | } |
|
320 | ||
321 | /** |
|
322 | * Check if a Pod supports extending core REST response. |