Completed
Push — fix/normalize-www-in-site-url-... ( e67e76 )
by
unknown
13:13 queued 02:59
created

class.wpcom-json-api-get-taxonomy-endpoint.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
class WPCOM_JSON_API_Get_Taxonomy_Endpoint extends WPCOM_JSON_API_Taxonomy_Endpoint {
3
	// /sites/%s/tags/slug:%s       -> $blog_id, $tag_id
4
	// /sites/%s/categories/slug:%s -> $blog_id, $tag_id
5
	function callback( $path = '', $blog_id = 0, $taxonomy_id = 0 ) {
6
		$blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) );
0 ignored issues
show
Consider using a different name than the parameter $blog_id. This often makes code more readable.
Loading history...
7
		if ( is_wp_error( $blog_id ) ) {
8
			return $blog_id;
9
		}
10
11
		$args = $this->query_args();
12
		if ( preg_match( '#/tags/#i', $path ) ) {
13
			$taxonomy_type = "post_tag";
14
		} else {
15
			$taxonomy_type = "category";
16
		}
17
18
		$return = $this->get_taxonomy( $taxonomy_id, $taxonomy_type, $args['context'] );
19
		if ( !$return || is_wp_error( $return ) ) {
20
			return $return;
21
		}
22
23
		/** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */
24
		do_action( 'wpcom_json_api_objects', 'taxonomies' );
25
26
		return $return;
27
	}
28
}
29