| @@ 1287-1300 (lines=14) @@ | ||
| 1284 | ||
| 1285 | 	function format_taxonomy( $taxonomy, $taxonomy_type, $context ) { | |
| 1286 | // Permissions | |
| 1287 | 		switch ( $context ) { | |
| 1288 | case 'edit' : | |
| 1289 | $tax = get_taxonomy( $taxonomy_type ); | |
| 1290 | if ( !current_user_can( $tax->cap->edit_terms ) ) | |
| 1291 | return new WP_Error( 'unauthorized', 'User cannot edit taxonomy', 403 ); | |
| 1292 | break; | |
| 1293 | case 'display' : | |
| 1294 | 			if ( -1 == get_option( 'blog_public' ) && ! current_user_can( 'read' ) ) { | |
| 1295 | return new WP_Error( 'unauthorized', 'User cannot view taxonomy', 403 ); | |
| 1296 | } | |
| 1297 | break; | |
| 1298 | default : | |
| 1299 | return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 ); | |
| 1300 | } | |
| 1301 | ||
| 1302 | $response = array(); | |
| 1303 | $response['ID'] = (int) $taxonomy->term_id; | |
| @@ 491-504 (lines=14) @@ | ||
| 488 | ||
| 489 | 	private function format_taxonomy( $taxonomy, $taxonomy_type, $context ) { | |
| 490 | // Permissions | |
| 491 | 		switch ( $context ) { | |
| 492 | case 'edit' : | |
| 493 | $tax = get_taxonomy( $taxonomy_type ); | |
| 494 | if ( !current_user_can( $tax->cap->edit_terms ) ) | |
| 495 | return new WP_Error( 'unauthorized', 'User cannot edit taxonomy', 403 ); | |
| 496 | break; | |
| 497 | case 'display' : | |
| 498 | 			if ( -1 == get_option( 'blog_public' ) && ! current_user_can( 'read' ) ) { | |
| 499 | return new WP_Error( 'unauthorized', 'User cannot view taxonomy', 403 ); | |
| 500 | } | |
| 501 | break; | |
| 502 | default : | |
| 503 | return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 ); | |
| 504 | } | |
| 505 | ||
| 506 | $response = array(); | |
| 507 | $response['ID'] = (int) $taxonomy->term_id; | |