Code Duplication    Length = 12-12 lines in 2 locations

class.json-api-endpoints.php 2 locations

@@ 1765-1776 (lines=12) @@
1762
			$this->api->trap_wp_die( 'upload_error' );
1763
			foreach ( $media_files as $media_item ) {
1764
				$_FILES['.api.media.item.'] = $media_item;
1765
				if ( ! $user_can_upload_files ) {
1766
					$media_id = new WP_Error( 'unauthorized', 'User cannot upload media.', 403 );
1767
				} else {
1768
					if ( $force_parent_id ) {
1769
						$parent_id = absint( $force_parent_id );
1770
					} elseif ( ! empty( $media_attrs[$i] ) && ! empty( $media_attrs[$i]['parent_id'] ) ) {
1771
						$parent_id = absint( $media_attrs[$i]['parent_id'] );
1772
					} else {
1773
						$parent_id = 0;
1774
					}
1775
					$media_id = media_handle_upload( '.api.media.item.', $parent_id );
1776
				}
1777
				if ( is_wp_error( $media_id ) ) {
1778
					$errors[$i]['file']   = $media_item['name'];
1779
					$errors[$i]['error']   = $media_id->get_error_code();
@@ 1793-1804 (lines=12) @@
1790
1791
		if ( ! empty( $media_urls ) ) {
1792
			foreach ( $media_urls as $url ) {
1793
				if ( ! $user_can_upload_files ) {
1794
					$media_id = new WP_Error( 'unauthorized', 'User cannot upload media.', 403 );
1795
				} else {
1796
					if ( $force_parent_id ) {
1797
						$parent_id = absint( $force_parent_id );
1798
					} else if ( ! empty( $media_attrs[$i] ) && ! empty( $media_attrs[$i]['parent_id'] ) ) {
1799
						$parent_id = absint( $media_attrs[$i]['parent_id'] );
1800
					} else {
1801
						$parent_id = 0;
1802
					}
1803
					$media_id = $this->handle_media_sideload( $url, $parent_id );
1804
				}
1805
				if ( is_wp_error( $media_id ) ) {
1806
					$errors[$i] = array(
1807
						'file'    => $url,