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