Code Duplication    Length = 12-12 lines in 2 locations

class.json-api-endpoints.php 2 locations

@@ 1792-1803 (lines=12) @@
1789
			$this->api->trap_wp_die( 'upload_error' );
1790
			foreach ( $media_files as $media_item ) {
1791
				$_FILES['.api.media.item.'] = $media_item;
1792
				if ( ! $user_can_upload_files ) {
1793
					$media_id = new WP_Error( 'unauthorized', 'User cannot upload media.', 403 );
1794
				} else {
1795
					if ( $force_parent_id ) {
1796
						$parent_id = absint( $force_parent_id );
1797
					} elseif ( ! empty( $media_attrs[ $i ] ) && ! empty( $media_attrs[ $i ]['parent_id'] ) ) {
1798
						$parent_id = absint( $media_attrs[ $i ]['parent_id'] );
1799
					} else {
1800
						$parent_id = 0;
1801
					}
1802
					$media_id = media_handle_upload( '.api.media.item.', $parent_id );
1803
				}
1804
				if ( is_wp_error( $media_id ) ) {
1805
					$errors[ $i ]['file']    = $media_item['name'];
1806
					$errors[ $i ]['error']   = $media_id->get_error_code();
@@ 1820-1831 (lines=12) @@
1817
1818
		if ( ! empty( $media_urls ) ) {
1819
			foreach ( $media_urls as $url ) {
1820
				if ( ! $user_can_upload_files ) {
1821
					$media_id = new WP_Error( 'unauthorized', 'User cannot upload media.', 403 );
1822
				} else {
1823
					if ( $force_parent_id ) {
1824
						$parent_id = absint( $force_parent_id );
1825
					} elseif ( ! empty( $media_attrs[ $i ] ) && ! empty( $media_attrs[ $i ]['parent_id'] ) ) {
1826
						$parent_id = absint( $media_attrs[ $i ]['parent_id'] );
1827
					} else {
1828
						$parent_id = 0;
1829
					}
1830
					$media_id = $this->handle_media_sideload( $url, $parent_id );
1831
				}
1832
				if ( is_wp_error( $media_id ) ) {
1833
					$errors[ $i ] = array(
1834
						'file'    => $url,