|
@@ 207-221 (lines=15) @@
|
| 204 |
|
* @param string $controller Optional, controller class for route. If not set "WP_REST_Posts_Controller" is |
| 205 |
|
* used. |
| 206 |
|
*/ |
| 207 |
|
public static function post_type_rest_support( $post_type_name, $rest_base = false, $controller = 'WP_REST_Posts_Controller' ) { |
| 208 |
|
|
| 209 |
|
global $wp_post_types; |
| 210 |
|
|
| 211 |
|
if ( isset( $wp_post_types[ $post_type_name ] ) ) { |
| 212 |
|
if ( ! $rest_base ) { |
| 213 |
|
$rest_base = $post_type_name; |
| 214 |
|
} |
| 215 |
|
|
| 216 |
|
$wp_post_types[ $post_type_name ]->show_in_rest = true; |
| 217 |
|
$wp_post_types[ $post_type_name ]->rest_base = $rest_base; |
| 218 |
|
$wp_post_types[ $post_type_name ]->rest_controller_class = $controller; |
| 219 |
|
} |
| 220 |
|
|
| 221 |
|
} |
| 222 |
|
|
| 223 |
|
/** |
| 224 |
|
* Add REST API support to an already registered taxonomy. |
|
@@ 233-247 (lines=15) @@
|
| 230 |
|
* @param string $controller Optional, controller class for route. If not set "WP_REST_Terms_Controller" is |
| 231 |
|
* used. |
| 232 |
|
*/ |
| 233 |
|
public static function taxonomy_rest_support( $taxonomy_name, $rest_base = false, $controller = 'WP_REST_Terms_Controller' ) { |
| 234 |
|
|
| 235 |
|
global $wp_taxonomies; |
| 236 |
|
|
| 237 |
|
if ( isset( $wp_taxonomies[ $taxonomy_name ] ) ) { |
| 238 |
|
if ( ! $rest_base ) { |
| 239 |
|
$rest_base = $taxonomy_name; |
| 240 |
|
} |
| 241 |
|
|
| 242 |
|
$wp_taxonomies[ $taxonomy_name ]->show_in_rest = true; |
| 243 |
|
$wp_taxonomies[ $taxonomy_name ]->rest_base = $rest_base; |
| 244 |
|
$wp_taxonomies[ $taxonomy_name ]->rest_controller_class = $controller; |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
} |
| 248 |
|
|
| 249 |
|
/** |
| 250 |
|
* Check if a Pod supports extending core REST response. |