Plugin Directory

Changeset 3372990


Ignore:
Timestamp:
10/05/2025 02:01:30 AM (6 months ago)
Author:
Alignak
Message:

v3.5.0

Location:
fast-velocity-minify/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fast-velocity-minify/trunk/fvm.php

    r3241155 r3372990  
    44 * Plugin URI: https://www.upwork.com/fl/raulpeixoto
    55 * Description: Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by merging and minifying CSS and JavaScript files into groups, compressing HTML and other speed optimizations.
    6  * Version: 3.4.3
     6 * Version: 3.5.0
    77 * Author: Raul Peixoto
    88 * Author URI: https://www.upwork.com/fl/raulpeixoto
  • fast-velocity-minify/trunk/inc/common.php

    r3241155 r3372990  
    355355    }
    356356
     357    # Purge CLP Varnish Cache (cloudpanel.io)
     358    if ( class_exists('ClpVarnishCacheManager') ) {
     359        try {
     360            $clp_varnish = new ClpVarnishCacheManager();
     361            if ( method_exists($clp_varnish, 'is_enabled') && $clp_varnish->is_enabled() ) {
     362                if ( method_exists($clp_varnish, 'purge_host') ) {
     363                    $host = parse_url( home_url(), PHP_URL_HOST );
     364                    if ( !empty($host) ) {
     365                        $clp_varnish->purge_host( $host );
     366                        return __( 'All caches on <strong>CLP Varnish Cache</strong> have been purged.', 'fast-velocity-minify' );
     367                    }
     368                }
     369            }
     370        } catch (\Exception $e) {
     371            return __( 'CLP Varnish Cache purge failed: ' . $e->getMessage(), 'fast-velocity-minify' );
     372        }
     373    }
     374
    357375    # bigscoots.com
    358376    if(has_action('bs_cache_purge_cache')) {
     
    543561           
    544562            # php
    545             if(!file_exists($file) || (file_exists($file) && filemtime($file) < $tvers)) { file_put_contents($file, $code); }
     563            if(!file_exists($file) || (file_exists($file) && filemtime($file) < $tvers)) {
     564                # add @charset "UTF-8"; for CSS files only
     565                if ($type == 'css' && !empty($code)) {
     566                    $code = '@charset "UTF-8";' . PHP_EOL . $code;
     567                }
     568                file_put_contents($file, $code);
     569            }
    546570            if(file_exists($file)) { return $public; }
    547571           
     
    9931017               
    9941018                    # get minification settings for files
     1019                    $enable_css_minification = false;
    9951020                    if(isset($fvm_settings['css']['css_enable_min_files'])) {
    9961021                        $enable_css_minification = $fvm_settings['css']['css_enable_min_files'];
     
    17031728# ensure that string is utf8   
    17041729function fvm_ensure_utf8($str) {
     1730
     1731    # remove UTF-8 BOM if present
     1732    $bom = pack('H*','EFBBBF');
     1733    if (strpos($str, $bom) === 0) {
     1734        $str = substr($str, 3);
     1735    }
     1736
     1737    # FIRST: check if it's already valid UTF-8 - if yes, return unchanged
     1738    # This prevents double-encoding issues with files that contain valid UTF-8 characters
     1739    # (e.g., icon fonts with literal Unicode characters in private use areas)
     1740    if (mb_check_encoding($str, 'UTF-8')) {
     1741        return $str; // already valid UTF-8, no conversion needed
     1742    }
     1743
     1744    # NOT valid UTF-8, so try to detect the actual encoding and convert
    17051745    $encodings = [ "UTF-32", "UTF-32BE", "UTF-32LE", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8", "ASCII", "EUC-JP", "SJIS", "eucJP-win", "SJIS-win", "JIS", "ISO-2022-JP", "Windows-1252", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "ISO-8859-13", "ISO-8859-14", "ISO-8859-15", "EUC-CN", "CP936", "EUC-TW", "BIG-5", "EUC-KR", "UHC", "ISO-2022-KR", "Windows-1251", "KOI8-R" ];
    17061746    $enc = mb_detect_encoding($str, $encodings, true);
    1707     if ($enc === false){
    1708         return mb_convert_encoding($str, "UTF-8", "UTF-8"); // could not detect encoding, so try as utf-8
     1747
     1748    if ($enc === false) {
     1749        # Could not detect - try assuming Windows-1252 (common for mis-encoded files)
     1750        $converted = @mb_convert_encoding($str, "UTF-8", "Windows-1252");
     1751        if ($converted !== false && mb_check_encoding($converted, 'UTF-8')) {
     1752            return $converted;
     1753        }
     1754        # Last resort: force UTF-8 interpretation
     1755        return mb_convert_encoding($str, "UTF-8", "UTF-8");
    17091756    } else if ($enc !== "UTF-8") {
    17101757        return mb_convert_encoding($str, "UTF-8", $enc); // converted to utf8
    1711     } else {
    1712         return $str; // already utf8
    1713     }
    1714    
    1715     # fail
    1716     return false;
     1758    }
     1759
     1760    # fallback
     1761    return $str;
    17171762}
    17181763
  • fast-velocity-minify/trunk/readme.txt

    r3241155 r3372990  
    44Requires at least: 5.6
    55Requires PHP: 7.2
    6 Stable tag: 3.4.3
    7 Tested up to: 6.7.3
     6Stable tag: 3.5.0
     7Tested up to: 6.8.3
    88Text Domain: fast-velocity-minify
    99License: GPLv3 or later
     
    4949
    5050== Changelog ==
     51
     52= 3.5.0 [2025.10.05] =
     53* Fixed UTF-8 encoding issues with CSS minification that caused icon fonts to display incorrectly
     54* Added @charset "UTF-8" declaration to all minified CSS files for proper encoding
     55* Fixed undefined variable warnings for $enable_css_minification
     56* Improved encoding detection to prevent double-encoding of valid UTF-8 content
     57* Enhanced compatibility with icon fonts using literal Unicode characters
     58* Added support for CLP Varnish Cache (cloudpanel.io) integration for automatic cache purging
    5159
    5260= 3.4.3 [2025.02.15] =
Note: See TracChangeset for help on using the changeset viewer.