Last active
November 10, 2017 01:39
-
-
Save MxAshUp/bac1da32c2d6c66c3b453f30f8dba7c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class WP_REST_Posts_Controller_StringTerms extends WP_REST_Posts_Controller { | |
/** | |
* Retrieves the post's schema, conforming to JSON Schema. | |
* | |
* @return array Item schema data. | |
*/ | |
public function get_item_schema() { | |
$schema = parent::get_item_schema(); | |
$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) ); | |
foreach ( $taxonomies as $taxonomy ) { | |
$base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; | |
if(!array_key_exists( $base, $schema['properties'] )) { | |
continue; | |
} | |
$schema['properties'][ $base ][ 'items' ][ 'type'] = 'string'; | |
} | |
return $schema; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment