Code Duplication    Length = 11-11 lines in 2 locations

includes/cli/class-wc-cli-product.php 1 location

@@ 2028-2038 (lines=11) @@
2025
		}
2026
2027
		// Ensure we have a file name and type
2028
		if ( ! $wp_filetype['type'] ) {
2029
			$headers = wp_remote_retrieve_headers( $response );
2030
			if ( isset( $headers['content-disposition'] ) && strstr( $headers['content-disposition'], 'filename=' ) ) {
2031
				$disposition = end( explode( 'filename=', $headers['content-disposition'] ) );
2032
				$disposition = sanitize_file_name( $disposition );
2033
				$file_name   = $disposition;
2034
			} elseif ( isset( $headers['content-type'] ) && strstr( $headers['content-type'], 'image/' ) ) {
2035
				$file_name = 'image.' . str_replace( 'image/', '', $headers['content-type'] );
2036
			}
2037
			unset( $headers );
2038
		}
2039
2040
		// Upload the file.
2041
		$upload = wp_upload_bits( $file_name, '', wp_remote_retrieve_body( $response ) );

includes/wc-rest-functions.php 1 location

@@ 74-84 (lines=11) @@
71
	}
72
73
	// Ensure we have a file name and type.
74
	if ( ! $wp_filetype['type'] ) {
75
		$headers = wp_remote_retrieve_headers( $response );
76
		if ( isset( $headers['content-disposition'] ) && strstr( $headers['content-disposition'], 'filename=' ) ) {
77
			$disposition = end( explode( 'filename=', $headers['content-disposition'] ) );
78
			$disposition = sanitize_file_name( $disposition );
79
			$file_name   = $disposition;
80
		} elseif ( isset( $headers['content-type'] ) && strstr( $headers['content-type'], 'image/' ) ) {
81
			$file_name = 'image.' . str_replace( 'image/', '', $headers['content-type'] );
82
		}
83
		unset( $headers );
84
	}
85
86
	// Upload the file.
87
	$upload = wp_upload_bits( $file_name, '', wp_remote_retrieve_body( $response ) );