| @@ -792,9 +792,9 @@ | ||
| 792 | 792 | } |
| 793 | 793 | $inline_css_hash = md5(implode('', $inline_css_group)); |
| 794 | 794 | $hash = hash('adler32', $handle_str . $inline_css_hash . $last_modified_str); |
| 795 | 795 | } else { |
| 796 | - $hash = $handle_str . $last_modified_str; | |
| 796 | + $hash = sanitize_file_name($handle_str . $last_modified_str); | |
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | // static cache file info |
| 800 | 800 | $file_name = 'wpo-minify-header-'.$hash.($minify_css ? '.min' : ''); |
| @@ -1068,9 +1068,9 @@ | ||
| 1068 | 1068 | if ($merge_js) { |
| 1069 | 1069 | // Change the hash based on last modified timestamp |
| 1070 | 1070 | $hash = hash('adler32', $handles_str . $last_modified_str); |
| 1071 | 1071 | } else { |
| 1072 | - $hash = $handles_str . $last_modified_str; | |
| 1072 | + $hash = sanitize_file_name($handles_str . $last_modified_str); | |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | // static cache file info |
| 1076 | 1076 | $file_name = 'wpo-minify-footer-'.$hash.($minify_js ? '.min' : ''); |
| @@ -1424,9 +1424,9 @@ | ||
| 1424 | 1424 | |
| 1425 | 1425 | if ($merge_js) { |
| 1426 | 1426 | $hash = hash('adler32', $handles_str . $last_modified_str); |
| 1427 | 1427 | } else { |
| 1428 | - $hash = $handles_str . $last_modified_str; | |
| 1428 | + $hash = sanitize_file_name($handles_str . $last_modified_str); | |
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | 1431 | // static cache file info |
| 1432 | 1432 | $file_name = 'wpo-minify-header-'.$hash.($minify_js ? '.min' : ''); |
| @@ -1888,9 +1888,9 @@ | ||
| 1888 | 1888 | } |
| 1889 | 1889 | $inline_css_hash = md5(implode('', $inline_css_group)); |
| 1890 | 1890 | $hash = hash('adler32', $handles_str . $inline_css_hash . $last_modified_str); |
| 1891 | 1891 | } else { |
| 1892 | - $hash = $handles_str . $last_modified_str; | |
| 1892 | + $hash = sanitize_file_name($handles_str . $last_modified_str); | |
| 1893 | 1893 | } |
| 1894 | 1894 | |
| 1895 | 1895 | // static cache file info |
| 1896 | 1896 | $file_name = 'wpo-minify-footer-'.$hash.($minify_css ? '.min' : ''); |
| @@ -2066,8 +2066,17 @@ | ||
| 2066 | 2066 | if ("module" !== $script['type']) continue; |
| 2067 | 2067 | |
| 2068 | 2068 | $href = WP_Optimize_Minify_Functions::get_hurl($script['url']); |
| 2069 | 2069 | if (WP_Optimize_Minify_Functions::is_minified_css_js_filename($href)) continue; |
| 2070 | + | |
| 2071 | + $asset_content = WP_Optimize_Minify_Functions::get_asset_content($href); | |
| 2072 | + $code = $asset_content['content']; | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + if (WP_Optimize_Minify_Functions::has_js_import_statements($code)) { | |
| 2076 | + // If the module script contains import statements, we cannot safely minify or cache it, so skip it. | |
| 2077 | + continue; | |
| 2078 | + } | |
| 2070 | 2079 | |
| 2071 | 2080 | $last_modified = WP_Optimize_Minify_Functions::get_modification_time($script['url']); |
| 2072 | 2081 | $handle = $script['handle']; |
| 2073 | 2082 | $version = $script['version']; |