Code Duplication    Length = 11-11 lines in 2 locations

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

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

includes/wc-rest-functions.php 1 location

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