Code Duplication    Length = 14-14 lines in 2 locations

class.json-api-endpoints.php 1 location

@@ 1424-1437 (lines=14) @@
1421
1422
	function format_taxonomy( $taxonomy, $taxonomy_type, $context ) {
1423
		// Permissions
1424
		switch ( $context ) {
1425
		case 'edit' :
1426
			$tax = get_taxonomy( $taxonomy_type );
1427
			if ( !current_user_can( $tax->cap->edit_terms ) )
1428
				return new WP_Error( 'unauthorized', 'User cannot edit taxonomy', 403 );
1429
			break;
1430
		case 'display' :
1431
			if ( -1 == get_option( 'blog_public' ) && ! current_user_can( 'read' ) ) {
1432
				return new WP_Error( 'unauthorized', 'User cannot view taxonomy', 403 );
1433
			}
1434
			break;
1435
		default :
1436
			return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 );
1437
		}
1438
1439
		$response                = array();
1440
		$response['ID']          = (int) $taxonomy->term_id;

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

@@ 525-538 (lines=14) @@
522
523
	private function format_taxonomy( $taxonomy, $taxonomy_type, $context ) {
524
		// Permissions
525
		switch ( $context ) {
526
		case 'edit' :
527
			$tax = get_taxonomy( $taxonomy_type );
528
			if ( !current_user_can( $tax->cap->edit_terms ) )
529
				return new WP_Error( 'unauthorized', 'User cannot edit taxonomy', 403 );
530
			break;
531
		case 'display' :
532
			if ( -1 == get_option( 'blog_public' ) && ! current_user_can( 'read' ) ) {
533
				return new WP_Error( 'unauthorized', 'User cannot view taxonomy', 403 );
534
			}
535
			break;
536
		default :
537
			return new WP_Error( 'invalid_context', 'Invalid API CONTEXT', 400 );
538
		}
539
540
		$response                = array();
541
		$response['ID']          = (int) $taxonomy->term_id;