@@ 216-230 (lines=15) @@ | ||
213 | * @param string $controller Optional, controller class for route. If not set "WP_REST_Posts_Controller" is |
|
214 | * used. |
|
215 | */ |
|
216 | public static function post_type_rest_support( $post_type_name, $rest_base = false, $controller = 'WP_REST_Posts_Controller' ) { |
|
217 | ||
218 | global $wp_post_types; |
|
219 | ||
220 | if ( isset( $wp_post_types[ $post_type_name ] ) ) { |
|
221 | if ( ! $rest_base ) { |
|
222 | $rest_base = $post_type_name; |
|
223 | } |
|
224 | ||
225 | $wp_post_types[ $post_type_name ]->show_in_rest = true; |
|
226 | $wp_post_types[ $post_type_name ]->rest_base = $rest_base; |
|
227 | $wp_post_types[ $post_type_name ]->rest_controller_class = $controller; |
|
228 | } |
|
229 | ||
230 | } |
|
231 | ||
232 | /** |
|
233 | * Add REST API support to an already registered taxonomy. |
|
@@ 242-256 (lines=15) @@ | ||
239 | * @param string $controller Optional, controller class for route. If not set "WP_REST_Terms_Controller" is |
|
240 | * used. |
|
241 | */ |
|
242 | public static function taxonomy_rest_support( $taxonomy_name, $rest_base = false, $controller = 'WP_REST_Terms_Controller' ) { |
|
243 | ||
244 | global $wp_taxonomies; |
|
245 | ||
246 | if ( isset( $wp_taxonomies[ $taxonomy_name ] ) ) { |
|
247 | if ( ! $rest_base ) { |
|
248 | $rest_base = $taxonomy_name; |
|
249 | } |
|
250 | ||
251 | $wp_taxonomies[ $taxonomy_name ]->show_in_rest = true; |
|
252 | $wp_taxonomies[ $taxonomy_name ]->rest_base = $rest_base; |
|
253 | $wp_taxonomies[ $taxonomy_name ]->rest_controller_class = $controller; |
|
254 | } |
|
255 | ||
256 | } |
|
257 | ||
258 | /** |
|
259 | * Check if a Pod supports extending core REST response. |