@@ 1443-1456 (lines=14) @@ | ||
1440 | ||
1441 | function format_taxonomy( $taxonomy, $taxonomy_type, $context ) { |
|
1442 | // Permissions |
|
1443 | switch ( $context ) { |
|
1444 | case 'edit' : |
|
1445 | $tax = get_taxonomy( $taxonomy_type ); |
|
1446 | if ( !current_user_can( $tax->cap->edit_terms ) ) |
|
1447 | return new WP_Error( 'unauthorized', 'User cannot edit taxonomy', 403 ); |
|
1448 | break; |
|
1449 | case 'display' : |
|
1450 | if ( -1 == get_option( 'blog_public' ) && ! current_user_can( 'read' ) ) { |
|
1451 | return new WP_Error( 'unauthorized', 'User cannot view taxonomy', 403 ); |
|
1452 | } |
|
1453 | break; |
|
1454 | default : |
|
1455 | return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 ); |
|
1456 | } |
|
1457 | ||
1458 | $response = array(); |
|
1459 | $response['ID'] = (int) $taxonomy->term_id; |
@@ 522-535 (lines=14) @@ | ||
519 | ||
520 | private function format_taxonomy( $taxonomy, $taxonomy_type, $context ) { |
|
521 | // Permissions |
|
522 | switch ( $context ) { |
|
523 | case 'edit' : |
|
524 | $tax = get_taxonomy( $taxonomy_type ); |
|
525 | if ( !current_user_can( $tax->cap->edit_terms ) ) |
|
526 | return new WP_Error( 'unauthorized', 'User cannot edit taxonomy', 403 ); |
|
527 | break; |
|
528 | case 'display' : |
|
529 | if ( -1 == get_option( 'blog_public' ) && ! current_user_can( 'read' ) ) { |
|
530 | return new WP_Error( 'unauthorized', 'User cannot view taxonomy', 403 ); |
|
531 | } |
|
532 | break; |
|
533 | default : |
|
534 | return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 ); |
|
535 | } |
|
536 | ||
537 | $response = array(); |
|
538 | $response['ID'] = (int) $taxonomy->term_id; |