public function prepare_item_for_response( $item,
$request ) { // Restores the more descriptive, specific name for use within this method.
$post_type =
$item;
$taxonomies =
wp_list_filter( get_object_taxonomies( $post_type->name, 'objects'
), array
( 'show_in_rest' => true
) );
$taxonomies =
wp_list_pluck( $taxonomies, 'name'
);
$base = !
empty( $post_type->rest_base
) ?
$post_type->rest_base :
$post_type->name;
$namespace = !
empty( $post_type->rest_namespace
) ?
$post_type->rest_namespace : 'wp/v2';
$supports =
get_all_post_type_supports( $post_type->name
);
$fields =
$this->
get_fields_for_response( $request );
$data = array
();
if ( rest_is_field_included( 'capabilities',
$fields ) ) { $data['capabilities'
] =
$post_type->cap;
} if ( rest_is_field_included( 'description',
$fields ) ) { $data['description'
] =
$post_type->description;
}