| @@ 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; |
|
| @@ 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; |
|