Code Duplication    Length = 14-14 lines in 2 locations

sal/class.json-api-post-base.php 1 location

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

class.json-api-endpoints.php 1 location

@@ 1483-1496 (lines=14) @@
1480
1481
	function format_taxonomy( $taxonomy, $taxonomy_type, $context ) {
1482
		// Permissions
1483
		switch ( $context ) {
1484
			case 'edit':
1485
				$tax = get_taxonomy( $taxonomy_type );
1486
				if ( ! current_user_can( $tax->cap->edit_terms ) ) {
1487
					return new WP_Error( 'unauthorized', 'User cannot edit taxonomy', 403 );
1488
				}
1489
				break;
1490
			case 'display':
1491
				if ( -1 == get_option( 'blog_public' ) && ! current_user_can( 'read' ) ) {
1492
					return new WP_Error( 'unauthorized', 'User cannot view taxonomy', 403 );
1493
				}
1494
				break;
1495
			default:
1496
				return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 );
1497
		}
1498
1499
		$response                = array();