@@ 198-212 (lines=15) @@ | ||
195 | * @param string $controller Optional, controller class for route. If not set "WP_REST_Posts_Controller" is |
|
196 | * used. |
|
197 | */ |
|
198 | public static function post_type_rest_support( $post_type_name, $rest_base = false, $controller = 'WP_REST_Posts_Controller' ) { |
|
199 | ||
200 | global $wp_post_types; |
|
201 | ||
202 | if ( isset( $wp_post_types[ $post_type_name ] ) ) { |
|
203 | if ( ! $rest_base ) { |
|
204 | $rest_base = $post_type_name; |
|
205 | } |
|
206 | ||
207 | $wp_post_types[ $post_type_name ]->show_in_rest = true; |
|
208 | $wp_post_types[ $post_type_name ]->rest_base = $rest_base; |
|
209 | $wp_post_types[ $post_type_name ]->rest_controller_class = $controller; |
|
210 | } |
|
211 | ||
212 | } |
|
213 | ||
214 | /** |
|
215 | * Add REST API support to an already registered taxonomy. |
|
@@ 224-238 (lines=15) @@ | ||
221 | * @param string $controller Optional, controller class for route. If not set "WP_REST_Terms_Controller" is |
|
222 | * used. |
|
223 | */ |
|
224 | public static function taxonomy_rest_support( $taxonomy_name, $rest_base = false, $controller = 'WP_REST_Terms_Controller' ) { |
|
225 | ||
226 | global $wp_taxonomies; |
|
227 | ||
228 | if ( isset( $wp_taxonomies[ $taxonomy_name ] ) ) { |
|
229 | if ( ! $rest_base ) { |
|
230 | $rest_base = $taxonomy_name; |
|
231 | } |
|
232 | ||
233 | $wp_taxonomies[ $taxonomy_name ]->show_in_rest = true; |
|
234 | $wp_taxonomies[ $taxonomy_name ]->rest_base = $rest_base; |
|
235 | $wp_taxonomies[ $taxonomy_name ]->rest_controller_class = $controller; |
|
236 | } |
|
237 | ||
238 | } |
|
239 | ||
240 | /** |
|
241 | * Check if a Pod supports extending core REST response. |