Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /* |
||
| 3 | * WARNING: This file is distributed verbatim in Jetpack. |
||
| 4 | * There should be nothing WordPress.com specific in this file. |
||
| 5 | * |
||
| 6 | * @hide-in-jetpack |
||
| 7 | */ |
||
| 8 | |||
| 9 | class WPCOM_JSON_API_Get_Term_Endpoint extends WPCOM_JSON_API_Endpoint { |
||
| 10 | // /sites/%s/taxonomies/%s/terms/slug:%s -> $blog_id, $taxonomy, $slug |
||
| 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 ) ); |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 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 |