WPCOM_JSON_API_Get_Term_Endpoint

The WordPress Core WPCOM JSON API Get Term Endpoint class.

Defined (1)

The class is defined in the following location(s).

/json-endpoints/class.wpcom-json-api-get-term-endpoint.php  
  1. class WPCOM_JSON_API_Get_Term_Endpoint extends WPCOM_JSON_API_Endpoint { 
  2. // /sites/%s/taxonomies/%s/terms/slug:%s -> $blog_id, $taxonomy, $slug 
  3. function callback( $path = '', $blog_id = 0, $taxonomy = 'category', $slug = 0 ) { 
  4. $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); 
  5. if ( is_wp_error( $blog_id ) ) { 
  6. return $blog_id; 
  7.  
  8. if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { 
  9. $this->load_theme_functions(); 
  10.  
  11. $taxonomy_meta = get_taxonomy( $taxonomy ); 
  12. if ( false === $taxonomy_meta || ( ! $taxonomy_meta->public &&  
  13. ! current_user_can( $taxonomy_meta->cap->assign_terms ) ) ) { 
  14. return new WP_Error( 'invalid_taxonomy', 'The taxonomy does not exist', 400 ); 
  15.  
  16. $args = $this->query_args(); 
  17. $term = $this->get_taxonomy( $slug, $taxonomy, $args['context'] ); 
  18. if ( ! $term || is_wp_error( $term ) ) { 
  19. return $term; 
  20.  
  21. /** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */ 
  22. do_action( 'wpcom_json_api_objects', 'terms' ); 
  23.  
  24. return $term;