| Conditions | 9 |
| Paths | 7 |
| Total Lines | 27 |
| Code Lines | 16 |
| Lines | 4 |
| Ratio | 14.81 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 11 | function callback( $path = '', $blog_id = 0, $taxonomy = 'category', $slug = 0 ) { |
||
| 12 | $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); |
||
| 13 | if ( is_wp_error( $blog_id ) ) { |
||
| 14 | return $blog_id; |
||
| 15 | } |
||
| 16 | |||
| 17 | if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
||
| 18 | $this->load_theme_functions(); |
||
| 19 | } |
||
| 20 | |||
| 21 | $taxonomy_meta = get_taxonomy( $taxonomy ); |
||
| 22 | View Code Duplication | if ( false === $taxonomy_meta || ( ! $taxonomy_meta->public && |
|
| 23 | ! current_user_can( $taxonomy_meta->cap->assign_terms ) ) ) { |
||
| 24 | return new WP_Error( 'invalid_taxonomy', 'The taxonomy does not exist', 400 ); |
||
| 25 | } |
||
| 26 | |||
| 27 | $args = $this->query_args(); |
||
| 28 | $term = $this->get_taxonomy( $slug, $taxonomy, $args['context'] ); |
||
| 29 | if ( ! $term || is_wp_error( $term ) ) { |
||
| 30 | return $term; |
||
| 31 | } |
||
| 32 | |||
| 33 | /** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */ |
||
| 34 | do_action( 'wpcom_json_api_objects', 'terms' ); |
||
| 35 | |||
| 36 | return $term; |
||
| 37 | } |
||
| 38 | } |
||
| 39 |