Plugin Directory

Changeset 3160589


Ignore:
Timestamp:
10/01/2024 10:44:17 AM (18 months ago)
Author:
poweredcache
Message:

Update to version 3.5.2 from GitHub

Location:
powered-cache
Files:
2 added
34 edited
1 copied

Legend:

Unmodified
Added
Removed
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/MatthiasMullie/Minify/CSS.php

    r2940671 r3160589  
    107107     * Combine CSS from import statements.
    108108     *
    109      * Import statements will be loaded and their content merged into the original
    110      * file, to save HTTP requests.
     109     * \@import's will be loaded and their content merged into the original file,
     110     * to save HTTP requests.
    111111     *
    112112     * @param string   $source  The file to combine imports for
     
    317317
    318318            $css = $this->stripWhitespace($css);
    319             $css = $this->shortenColors($css);
     319            $css = $this->convertLegacyColors($css);
     320            $css = $this->cleanupModernColors($css);
     321            $css = $this->shortenHEXColors($css);
    320322            $css = $this->shortenZeroes($css);
    321323            $css = $this->shortenFontWeights($css);
     
    481483
    482484    /**
    483      * Shorthand hex color codes.
    484      * #FF0000 -> #F00.
    485      *
    486      * @param string $content The CSS content to shorten the hex color codes for
    487      *
    488      * @return string
    489      */
    490     protected function shortenColors($content)
    491     {
    492         $content = preg_replace('/(?<=[: ])#([0-9a-z])\\1([0-9a-z])\\2([0-9a-z])\\3(?:([0-9a-z])\\4)?(?=[; }])/i', '#$1$2$3$4', $content);
    493 
    494         // remove alpha channel if it's pointless...
    495         $content = preg_replace('/(?<=[: ])#([0-9a-z]{6})ff?(?=[; }])/i', '#$1', $content);
    496         $content = preg_replace('/(?<=[: ])#([0-9a-z]{3})f?(?=[; }])/i', '#$1', $content);
     485     * Shorthand HEX color codes.
     486     * #FF0000FF -> #f00 -> red
     487     * #FF00FF00 -> transparent.
     488     *
     489     * @param string $content The CSS content to shorten the HEX color codes for
     490     *
     491     * @return string
     492     */
     493    protected function shortenHexColors($content)
     494    {
     495        // shorten repeating patterns within HEX ..
     496        $content = preg_replace('/(?<=[: ])#([0-9a-f])\\1([0-9a-f])\\2([0-9a-f])\\3(?:([0-9a-f])\\4)?(?=[; }])/i', '#$1$2$3$4', $content);
     497
     498        // remove alpha channel if it's pointless ..
     499        $content = preg_replace('/(?<=[: ])#([0-9a-f]{6})ff(?=[; }])/i', '#$1', $content);
     500        $content = preg_replace('/(?<=[: ])#([0-9a-f]{3})f(?=[; }])/i', '#$1', $content);
     501
     502        // replace `transparent` with shortcut ..
     503        $content = preg_replace('/(?<=[: ])#[0-9a-f]{6}00(?=[; }])/i', '#fff0', $content);
    497504
    498505        $colors = array(
     506            // make these more readable
     507            '#00f' => 'blue',
     508            '#dc143c' => 'crimson',
     509            '#0ff' => 'cyan',
     510            '#8b0000' => 'darkred',
     511            '#696969' => 'dimgray',
     512            '#ff69b4' => 'hotpink',
     513            '#0f0' => 'lime',
     514            '#fdf5e6' => 'oldlace',
     515            '#87ceeb' => 'skyblue',
     516            '#d8bfd8' => 'thistle',
    499517            // we can shorten some even more by replacing them with their color name
    500             '#F0FFFF' => 'azure',
    501             '#F5F5DC' => 'beige',
    502             '#A52A2A' => 'brown',
    503             '#FF7F50' => 'coral',
    504             '#FFD700' => 'gold',
     518            '#f0ffff' => 'azure',
     519            '#f5f5dc' => 'beige',
     520            '#ffe4c4' => 'bisque',
     521            '#a52a2a' => 'brown',
     522            '#ff7f50' => 'coral',
     523            '#ffd700' => 'gold',
    505524            '#808080' => 'gray',
    506525            '#008000' => 'green',
    507             '#4B0082' => 'indigo',
    508             '#FFFFF0' => 'ivory',
    509             '#F0E68C' => 'khaki',
    510             '#FAF0E6' => 'linen',
     526            '#4b0082' => 'indigo',
     527            '#fffff0' => 'ivory',
     528            '#f0e68c' => 'khaki',
     529            '#faf0e6' => 'linen',
    511530            '#800000' => 'maroon',
    512531            '#000080' => 'navy',
    513532            '#808000' => 'olive',
    514             '#CD853F' => 'peru',
    515             '#FFC0CB' => 'pink',
    516             '#DDA0DD' => 'plum',
     533            '#ffa500' => 'orange',
     534            '#da70d6' => 'orchid',
     535            '#cd853f' => 'peru',
     536            '#ffc0cb' => 'pink',
     537            '#dda0dd' => 'plum',
    517538            '#800080' => 'purple',
    518             '#F00' => 'red',
    519             '#FA8072' => 'salmon',
    520             '#A0522D' => 'sienna',
    521             '#C0C0C0' => 'silver',
    522             '#FFFAFA' => 'snow',
    523             '#D2B48C' => 'tan',
    524             '#FF6347' => 'tomato',
    525             '#EE82EE' => 'violet',
    526             '#F5DEB3' => 'wheat',
     539            '#f00' => 'red',
     540            '#fa8072' => 'salmon',
     541            '#a0522d' => 'sienna',
     542            '#c0c0c0' => 'silver',
     543            '#fffafa' => 'snow',
     544            '#d2b48c' => 'tan',
     545            '#008080' => 'teal',
     546            '#ff6347' => 'tomato',
     547            '#ee82ee' => 'violet',
     548            '#f5deb3' => 'wheat',
    527549            // or the other way around
    528             'WHITE' => '#fff',
    529             'BLACK' => '#000',
     550            'black' => '#000',
     551            'fuchsia' => '#f0f',
     552            'magenta' => '#f0f',
     553            'white' => '#fff',
     554            'yellow' => '#ff0',
     555            // and also `transparent`
     556            'transparent' => '#fff0',
    530557        );
    531558
     
    533560            '/(?<=[: ])(' . implode('|', array_keys($colors)) . ')(?=[; }])/i',
    534561            function ($match) use ($colors) {
    535                 return $colors[strtoupper($match[0])];
     562                return $colors[strtolower($match[0])];
    536563            },
    537564            $content
    538565        );
     566    }
     567
     568    /**
     569     * Convert RGB|HSL color codes.
     570     * rgb(255,0,0,.5) -> rgb(255 0 0 / .5).
     571     * rgb(255,0,0) -> #f00.
     572     *
     573     * @param string $content The CSS content to shorten the RGB color codes for
     574     *
     575     * @return string
     576     */
     577    protected function convertLegacyColors($content)
     578    {
     579        /*
     580          https://drafts.csswg.org/css-color/#color-syntax-legacy
     581          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb
     582          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl
     583        */
     584
     585        // convert legacy color syntax
     586        $content = preg_replace('/(rgb)a?\(\s*([0-9]{1,3}%?)\s*,\s*([0-9]{1,3}%?)\s*,\s*([0-9]{1,3}%?)\s*,\s*([0,1]?(?:\.[0-9]*)?)\s*\)/i', '$1($2 $3 $4 / $5)', $content);
     587        $content = preg_replace('/(rgb)a?\(\s*([0-9]{1,3}%?)\s*,\s*([0-9]{1,3}%?)\s*,\s*([0-9]{1,3}%?)\s*\)/i', '$1($2 $3 $4)', $content);
     588        $content = preg_replace('/(hsl)a?\(\s*([0-9]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9]{1,3}%)\s*,\s*([0-9]{1,3}%)\s*,\s*([0,1]?(?:\.[0-9]*)?)\s*\)/i', '$1($2 $3 $4 / $5)', $content);
     589        $content = preg_replace('/(hsl)a?\(\s*([0-9]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9]{1,3}%)\s*,\s*([0-9]{1,3}%)\s*\)/i', '$1($2 $3 $4)', $content);
     590
     591        // convert `rgb` to `hex`
     592        $dec = '([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])';
     593        return preg_replace_callback(
     594            "/rgb\($dec $dec $dec\)/i",
     595            function ($match) {
     596                return sprintf('#%02x%02x%02x', $match[1], $match[2], $match[3]);
     597            },
     598            $content
     599        );
     600    }
     601
     602    /**
     603     * Cleanup RGB|HSL|HWB|LCH|LAB
     604     * rgb(255 0 0 / 1) -> rgb(255 0 0).
     605     * rgb(255 0 0 / 0) -> transparent.
     606     *
     607     * @param string $content The CSS content to cleanup HSL|HWB|LCH|LAB
     608     *
     609     * @return string
     610     */
     611    protected function cleanupModernColors($content)
     612    {
     613        /*
     614          https://drafts.csswg.org/css-color/#color-syntax-modern
     615          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hwb
     616          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch
     617          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lab
     618          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch
     619          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklab
     620        */
     621        $tag = '(rgb|hsl|hwb|(?:(?:ok)?(?:lch|lab)))';
     622
     623        // remove alpha channel if it's pointless ..
     624        $content = preg_replace('/' . $tag . '\(\s*([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+\/\s+1(?:(?:\.\d?)*|00%)?\s*\)/i', '$1($2 $3 $4)', $content);
     625
     626        // replace `transparent` with shortcut ..
     627        $content = preg_replace('/' . $tag . '\(\s*[^\s]+\s+[^\s]+\s+[^\s]+\s+\/\s+0(?:[\.0%]*)?\s*\)/i', '#fff0', $content);
     628
     629        return $content;
    539630    }
    540631
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/MatthiasMullie/Minify/JS.php

    r2940671 r3160589  
    123123    protected $operatorsAfter = array();
    124124
    125     /**
    126      * {@inheritdoc}
    127      */
    128125    public function __construct()
    129126    {
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/MatthiasMullie/Minify/Minify.php

    r2940671 r3160589  
    271271        $callback = function ($match) use ($minifier) {
    272272            $count = count($minifier->extracted);
    273             $placeholder = '/*'.$count.'*/';
     273            $placeholder = '/*' . $count . '*/';
    274274            $minifier->extracted[$placeholder] = $match[0];
    275275
     
    495495        if (
    496496            // file is elsewhere
    497             isset($parsed['host']) ||
     497            isset($parsed['host'])
    498498            // file responds to queries (may change, or need to bypass cache)
    499             isset($parsed['query'])
     499            || isset($parsed['query'])
    500500        ) {
    501501            return false;
    502502        }
    503503
    504         return strlen($path) < PHP_MAXPATHLEN && @is_file($path) && is_readable($path);
     504        try {
     505            return strlen($path) < PHP_MAXPATHLEN && @is_file($path) && is_readable($path);
     506        }
     507        // catch openbasedir exceptions which are not caught by @ on is_file()
     508        catch (\Exception $e) {
     509            return false;
     510        }
    505511    }
    506512
     
    535541    {
    536542        if (
    537             !is_resource($handler) ||
    538             ($result = @fwrite($handler, $content)) === false ||
    539             ($result < strlen($content))
     543            !is_resource($handler)
     544            || ($result = @fwrite($handler, $content)) === false
     545            || ($result < strlen($content))
    540546        ) {
    541547            throw new IOException('The file "' . $path . '" could not be written to. Check your disk space and file permissions.');
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/voku/helper/AbstractDomParser.php

    r2912480 r3160589  
    498498
    499499        if (\strpos($html, 'http') !== false) {
    500 
    501500            // regEx for e.g.: [https://www.domain.de/foo.php?foobar=1&email=lars%40moelleken.org&guid=test1233312&{{foo}}#foo]
    502501            $regExUrl = '/(\[?\bhttps?:\/\/[^\s<>]+(?:\(\w+\)|[^[:punct:]\s]|\/|}|]))/i';
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/voku/helper/AbstractSimpleHtmlDom.php

    r2912480 r3160589  
    2222        'innerhtml'    => 'innerHtml',
    2323        'innerhtmlkeep'    => 'innerHtmlKeep',
     24    ];
     25
     26    /**
     27     * @var string[]
     28     */
     29    protected static $stringDomNodes = [
     30        'id',
     31        'prefix',
     32        'content'
    2433    ];
    2534
     
    168177                if ($this->node && \property_exists($this->node, $nameOrig)) {
    169178                    // INFO: Cannot assign null to property DOMNode::* of type string
    170                     if ($nameOrig === 'prefix' || $nameOrig === 'textContent') {
     179                    if (in_array($nameOrig, self::$stringDomNodes)) {
    171180                        $value = (string)$value;
    172181                    }
    173182
    174                     return $this->node->{$nameOrig} = $value;
     183                    if (!is_null($value)) {
     184                        return $this->node->{$nameOrig} = $value;
     185                    }
    175186                }
    176187
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/voku/helper/HtmlDomHelper.php

    r2912480 r3160589  
    77final class HtmlDomHelper
    88{
    9 
    109    /**
    1110     * @param string $html
     
    6665
    6766        foreach ($attributes as $attributeName => $attributeValue) {
    68             $domElement->setAttribute($attributeName, $attributeValue);
     67            $domElement->setAttribute($attributeName, $attributeValue, true);
    6968        }
    7069
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/voku/helper/HtmlDomParser.php

    r2912480 r3160589  
    7676     * protected $specialScriptTags = [
    7777     *     'text/html',
     78     *     'text/template',
    7879     *     'text/x-custom-template',
    7980     *     'text/x-handlebars-template'
     
    8586    protected $specialScriptTags = [
    8687        'text/html',
     88        'text/template',
    8789        'text/x-custom-template',
    8890        'text/x-handlebars-template',
     
    479481
    480482        if ($documentFound === false) {
    481 
    482483            // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251
    483484            $xmlHackUsed = false;
     
    11251126            '/(?<start>(<script [^>]*type=["\']?(?:' . $tags . ')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',
    11261127            function ($matches) {
    1127 
    11281128                // Check for logic in special script tags, like [<% _.each(tierPrices, function(item, key) { %>],
    11291129                // because often this looks like non-valid html in the template itself.
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/voku/helper/HtmlMin.php

    r2912480 r3160589  
    16521652
    16531653        foreach ($dom->findMulti('*') as $element) {
    1654 
    16551654            // -------------------------------------------------------------------------
    16561655            // Remove whitespace around tags. [protected html is still protected]
     
    17151714            }
    17161715
    1717             $this->protectedChildNodes[$this->protected_tags_counter] = $element->parentNode()->innerHtml();
    1718             $parentNode = $element->getNode()->parentNode;
    1719             if ($parentNode !== null) {
     1716            $parentNode = $element->parentNode();
     1717            if ($parentNode->nodeValue !== null) {
     1718                $this->protectedChildNodes[$this->protected_tags_counter] = $parentNode->innerHtml();
    17201719                $parentNode->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>';
    17211720            }
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/voku/helper/HtmlMinDomObserverOptimizeAttributes.php

    r3074892 r3160589  
    5959        $attrs = [];
    6060        foreach ((array) $attributes as $attrName => $attrValue) {
    61 
    6261            // -------------------------------------------------------------------------
    6362            // Remove local domains from attributes.
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/voku/helper/SimpleHtmlDom.php

    r2912480 r3160589  
    685685     * Returns the parent of node.
    686686     *
    687      * @return SimpleHtmlDomInterface
    688      */
    689     public function parentNode(): SimpleHtmlDomInterface
    690     {
    691         return new static($this->node->parentNode);
     687     * @return SimpleHtmlDomInterface|null
     688     */
     689    public function parentNode(): ?SimpleHtmlDomInterface
     690    {
     691        if ($node = $this->node->parentNode) {
     692            return new static($node);
     693        }
     694
     695        return null;
    692696    }
    693697
     
    832836            $newDocument->getIsDOMDocumentCreatedWithoutHtmlWrapper()
    833837        ) {
    834 
    835838            // Remove doc-type node.
    836839            if ($newDocument->getDocument()->doctype !== null) {
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/voku/helper/SimpleHtmlDomBlank.php

    r2912480 r3160589  
    403403     * Returns the parent of node.
    404404     *
    405      * @return SimpleHtmlDomInterface
    406      */
    407     public function parentNode(): SimpleHtmlDomInterface
     405     * @return SimpleHtmlDomInterface|null
     406     */
     407    public function parentNode(): ?SimpleHtmlDomInterface
    408408    {
    409409        return new static();
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/voku/helper/SimpleHtmlDomInterface.php

    r2912480 r3160589  
    325325     * Returns the parent of node.
    326326     *
    327      * @return SimpleHtmlDomInterface
    328      */
    329     public function parentNode(): self;
     327     * @return SimpleHtmlDomInterface|null
     328     */
     329    public function parentNode(): ?self;
    330330
    331331    /**
  • powered-cache/tags/3.5.2/includes/classes/Dependencies/voku/helper/XmlDomParser.php

    r2912480 r3160589  
    205205
    206206        if ($documentFound === false) {
    207 
    208207            // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251
    209208            $xmlHackUsed = false;
  • powered-cache/tags/3.5.2/includes/compat/loader.php

    r3038477 r3160589  
    2121    require_once POWERED_CACHE_COMPAT_DIR . 'plugins/autoptimize.php';
    2222    require_once POWERED_CACHE_COMPAT_DIR . 'plugins/bj-lazy-load.php';
     23    require_once POWERED_CACHE_COMPAT_DIR . 'plugins/clear-cache-for-widgets.php';
    2324    require_once POWERED_CACHE_COMPAT_DIR . 'plugins/lazy-load.php';
    2425    require_once POWERED_CACHE_COMPAT_DIR . 'plugins/rocket-lazy-load.php';
  • powered-cache/tags/3.5.2/languages/powered-cache.pot

    r3135643 r3160589  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Powered Cache 3.5.1\n"
     5"Project-Id-Version: Powered Cache 3.5.2\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/powered-cache\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2024-08-14T14:56:13+00:00\n"
     12"POT-Creation-Date: 2024-10-01T10:33:24+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.10.0\n"
     
    16011601
    16021602#. translators: %1$s plugin name,  %2$s conflicted feature name (Eg lazyload)
    1603 #: includes/compat/loader.php:68
     1603#: includes/compat/loader.php:69
    16041604msgid "It seems %1$s is activated on your site. Powered Cache works perfectly fine with %1$s but you cannot use %2$s functionalities that conflic with %1$s plugin unless you deactivate it."
    16051605msgstr ""
  • powered-cache/tags/3.5.2/powered-cache.php

    r3135643 r3160589  
    44 * Plugin URI:        https://poweredcache.com
    55 * Description:       Powered Cache is the most powerful caching and performance suite for WordPress, designed to easily improve your PageSpeed and Web Vitals Score.
    6  * Version:           3.5.1
     6 * Version:           3.5.2
    77 * Requires at least: 5.7
    88 * Requires PHP:      7.2.5
     
    2626
    2727// Useful global constants.
    28 define( 'POWERED_CACHE_VERSION', '3.5.1' );
     28define( 'POWERED_CACHE_VERSION', '3.5.2' );
    2929define( 'POWERED_CACHE_DB_VERSION', '3.4' );
    3030define( 'POWERED_CACHE_PLUGIN_FILE', __FILE__ );
  • powered-cache/tags/3.5.2/readme.txt

    r3135643 r3160589  
    44Requires at least:  5.7
    55Tested up to:  6.6
    6 Stable tag:  3.5.1
     6Stable tag:  3.5.2
    77License: GPLv2 (or later)
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    171171
    172172== Changelog ==
     173
     174= 3.5.2 (October 01, 2024) =
     175- [Added] Clear Cache for Me compatibility.
     176- [Updated] Minifier libraries.
     177- Various dependency updates.
    173178
    174179= 3.5.1 (August 14, 2024) =
  • powered-cache/trunk/includes/classes/Dependencies/MatthiasMullie/Minify/CSS.php

    r2940671 r3160589  
    107107     * Combine CSS from import statements.
    108108     *
    109      * Import statements will be loaded and their content merged into the original
    110      * file, to save HTTP requests.
     109     * \@import's will be loaded and their content merged into the original file,
     110     * to save HTTP requests.
    111111     *
    112112     * @param string   $source  The file to combine imports for
     
    317317
    318318            $css = $this->stripWhitespace($css);
    319             $css = $this->shortenColors($css);
     319            $css = $this->convertLegacyColors($css);
     320            $css = $this->cleanupModernColors($css);
     321            $css = $this->shortenHEXColors($css);
    320322            $css = $this->shortenZeroes($css);
    321323            $css = $this->shortenFontWeights($css);
     
    481483
    482484    /**
    483      * Shorthand hex color codes.
    484      * #FF0000 -> #F00.
    485      *
    486      * @param string $content The CSS content to shorten the hex color codes for
    487      *
    488      * @return string
    489      */
    490     protected function shortenColors($content)
    491     {
    492         $content = preg_replace('/(?<=[: ])#([0-9a-z])\\1([0-9a-z])\\2([0-9a-z])\\3(?:([0-9a-z])\\4)?(?=[; }])/i', '#$1$2$3$4', $content);
    493 
    494         // remove alpha channel if it's pointless...
    495         $content = preg_replace('/(?<=[: ])#([0-9a-z]{6})ff?(?=[; }])/i', '#$1', $content);
    496         $content = preg_replace('/(?<=[: ])#([0-9a-z]{3})f?(?=[; }])/i', '#$1', $content);
     485     * Shorthand HEX color codes.
     486     * #FF0000FF -> #f00 -> red
     487     * #FF00FF00 -> transparent.
     488     *
     489     * @param string $content The CSS content to shorten the HEX color codes for
     490     *
     491     * @return string
     492     */
     493    protected function shortenHexColors($content)
     494    {
     495        // shorten repeating patterns within HEX ..
     496        $content = preg_replace('/(?<=[: ])#([0-9a-f])\\1([0-9a-f])\\2([0-9a-f])\\3(?:([0-9a-f])\\4)?(?=[; }])/i', '#$1$2$3$4', $content);
     497
     498        // remove alpha channel if it's pointless ..
     499        $content = preg_replace('/(?<=[: ])#([0-9a-f]{6})ff(?=[; }])/i', '#$1', $content);
     500        $content = preg_replace('/(?<=[: ])#([0-9a-f]{3})f(?=[; }])/i', '#$1', $content);
     501
     502        // replace `transparent` with shortcut ..
     503        $content = preg_replace('/(?<=[: ])#[0-9a-f]{6}00(?=[; }])/i', '#fff0', $content);
    497504
    498505        $colors = array(
     506            // make these more readable
     507            '#00f' => 'blue',
     508            '#dc143c' => 'crimson',
     509            '#0ff' => 'cyan',
     510            '#8b0000' => 'darkred',
     511            '#696969' => 'dimgray',
     512            '#ff69b4' => 'hotpink',
     513            '#0f0' => 'lime',
     514            '#fdf5e6' => 'oldlace',
     515            '#87ceeb' => 'skyblue',
     516            '#d8bfd8' => 'thistle',
    499517            // we can shorten some even more by replacing them with their color name
    500             '#F0FFFF' => 'azure',
    501             '#F5F5DC' => 'beige',
    502             '#A52A2A' => 'brown',
    503             '#FF7F50' => 'coral',
    504             '#FFD700' => 'gold',
     518            '#f0ffff' => 'azure',
     519            '#f5f5dc' => 'beige',
     520            '#ffe4c4' => 'bisque',
     521            '#a52a2a' => 'brown',
     522            '#ff7f50' => 'coral',
     523            '#ffd700' => 'gold',
    505524            '#808080' => 'gray',
    506525            '#008000' => 'green',
    507             '#4B0082' => 'indigo',
    508             '#FFFFF0' => 'ivory',
    509             '#F0E68C' => 'khaki',
    510             '#FAF0E6' => 'linen',
     526            '#4b0082' => 'indigo',
     527            '#fffff0' => 'ivory',
     528            '#f0e68c' => 'khaki',
     529            '#faf0e6' => 'linen',
    511530            '#800000' => 'maroon',
    512531            '#000080' => 'navy',
    513532            '#808000' => 'olive',
    514             '#CD853F' => 'peru',
    515             '#FFC0CB' => 'pink',
    516             '#DDA0DD' => 'plum',
     533            '#ffa500' => 'orange',
     534            '#da70d6' => 'orchid',
     535            '#cd853f' => 'peru',
     536            '#ffc0cb' => 'pink',
     537            '#dda0dd' => 'plum',
    517538            '#800080' => 'purple',
    518             '#F00' => 'red',
    519             '#FA8072' => 'salmon',
    520             '#A0522D' => 'sienna',
    521             '#C0C0C0' => 'silver',
    522             '#FFFAFA' => 'snow',
    523             '#D2B48C' => 'tan',
    524             '#FF6347' => 'tomato',
    525             '#EE82EE' => 'violet',
    526             '#F5DEB3' => 'wheat',
     539            '#f00' => 'red',
     540            '#fa8072' => 'salmon',
     541            '#a0522d' => 'sienna',
     542            '#c0c0c0' => 'silver',
     543            '#fffafa' => 'snow',
     544            '#d2b48c' => 'tan',
     545            '#008080' => 'teal',
     546            '#ff6347' => 'tomato',
     547            '#ee82ee' => 'violet',
     548            '#f5deb3' => 'wheat',
    527549            // or the other way around
    528             'WHITE' => '#fff',
    529             'BLACK' => '#000',
     550            'black' => '#000',
     551            'fuchsia' => '#f0f',
     552            'magenta' => '#f0f',
     553            'white' => '#fff',
     554            'yellow' => '#ff0',
     555            // and also `transparent`
     556            'transparent' => '#fff0',
    530557        );
    531558
     
    533560            '/(?<=[: ])(' . implode('|', array_keys($colors)) . ')(?=[; }])/i',
    534561            function ($match) use ($colors) {
    535                 return $colors[strtoupper($match[0])];
     562                return $colors[strtolower($match[0])];
    536563            },
    537564            $content
    538565        );
     566    }
     567
     568    /**
     569     * Convert RGB|HSL color codes.
     570     * rgb(255,0,0,.5) -> rgb(255 0 0 / .5).
     571     * rgb(255,0,0) -> #f00.
     572     *
     573     * @param string $content The CSS content to shorten the RGB color codes for
     574     *
     575     * @return string
     576     */
     577    protected function convertLegacyColors($content)
     578    {
     579        /*
     580          https://drafts.csswg.org/css-color/#color-syntax-legacy
     581          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb
     582          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl
     583        */
     584
     585        // convert legacy color syntax
     586        $content = preg_replace('/(rgb)a?\(\s*([0-9]{1,3}%?)\s*,\s*([0-9]{1,3}%?)\s*,\s*([0-9]{1,3}%?)\s*,\s*([0,1]?(?:\.[0-9]*)?)\s*\)/i', '$1($2 $3 $4 / $5)', $content);
     587        $content = preg_replace('/(rgb)a?\(\s*([0-9]{1,3}%?)\s*,\s*([0-9]{1,3}%?)\s*,\s*([0-9]{1,3}%?)\s*\)/i', '$1($2 $3 $4)', $content);
     588        $content = preg_replace('/(hsl)a?\(\s*([0-9]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9]{1,3}%)\s*,\s*([0-9]{1,3}%)\s*,\s*([0,1]?(?:\.[0-9]*)?)\s*\)/i', '$1($2 $3 $4 / $5)', $content);
     589        $content = preg_replace('/(hsl)a?\(\s*([0-9]+(?:deg|grad|rad|turn)?)\s*,\s*([0-9]{1,3}%)\s*,\s*([0-9]{1,3}%)\s*\)/i', '$1($2 $3 $4)', $content);
     590
     591        // convert `rgb` to `hex`
     592        $dec = '([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])';
     593        return preg_replace_callback(
     594            "/rgb\($dec $dec $dec\)/i",
     595            function ($match) {
     596                return sprintf('#%02x%02x%02x', $match[1], $match[2], $match[3]);
     597            },
     598            $content
     599        );
     600    }
     601
     602    /**
     603     * Cleanup RGB|HSL|HWB|LCH|LAB
     604     * rgb(255 0 0 / 1) -> rgb(255 0 0).
     605     * rgb(255 0 0 / 0) -> transparent.
     606     *
     607     * @param string $content The CSS content to cleanup HSL|HWB|LCH|LAB
     608     *
     609     * @return string
     610     */
     611    protected function cleanupModernColors($content)
     612    {
     613        /*
     614          https://drafts.csswg.org/css-color/#color-syntax-modern
     615          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hwb
     616          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch
     617          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lab
     618          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch
     619          https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklab
     620        */
     621        $tag = '(rgb|hsl|hwb|(?:(?:ok)?(?:lch|lab)))';
     622
     623        // remove alpha channel if it's pointless ..
     624        $content = preg_replace('/' . $tag . '\(\s*([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+\/\s+1(?:(?:\.\d?)*|00%)?\s*\)/i', '$1($2 $3 $4)', $content);
     625
     626        // replace `transparent` with shortcut ..
     627        $content = preg_replace('/' . $tag . '\(\s*[^\s]+\s+[^\s]+\s+[^\s]+\s+\/\s+0(?:[\.0%]*)?\s*\)/i', '#fff0', $content);
     628
     629        return $content;
    539630    }
    540631
  • powered-cache/trunk/includes/classes/Dependencies/MatthiasMullie/Minify/JS.php

    r2940671 r3160589  
    123123    protected $operatorsAfter = array();
    124124
    125     /**
    126      * {@inheritdoc}
    127      */
    128125    public function __construct()
    129126    {
  • powered-cache/trunk/includes/classes/Dependencies/MatthiasMullie/Minify/Minify.php

    r2940671 r3160589  
    271271        $callback = function ($match) use ($minifier) {
    272272            $count = count($minifier->extracted);
    273             $placeholder = '/*'.$count.'*/';
     273            $placeholder = '/*' . $count . '*/';
    274274            $minifier->extracted[$placeholder] = $match[0];
    275275
     
    495495        if (
    496496            // file is elsewhere
    497             isset($parsed['host']) ||
     497            isset($parsed['host'])
    498498            // file responds to queries (may change, or need to bypass cache)
    499             isset($parsed['query'])
     499            || isset($parsed['query'])
    500500        ) {
    501501            return false;
    502502        }
    503503
    504         return strlen($path) < PHP_MAXPATHLEN && @is_file($path) && is_readable($path);
     504        try {
     505            return strlen($path) < PHP_MAXPATHLEN && @is_file($path) && is_readable($path);
     506        }
     507        // catch openbasedir exceptions which are not caught by @ on is_file()
     508        catch (\Exception $e) {
     509            return false;
     510        }
    505511    }
    506512
     
    535541    {
    536542        if (
    537             !is_resource($handler) ||
    538             ($result = @fwrite($handler, $content)) === false ||
    539             ($result < strlen($content))
     543            !is_resource($handler)
     544            || ($result = @fwrite($handler, $content)) === false
     545            || ($result < strlen($content))
    540546        ) {
    541547            throw new IOException('The file "' . $path . '" could not be written to. Check your disk space and file permissions.');
  • powered-cache/trunk/includes/classes/Dependencies/voku/helper/AbstractDomParser.php

    r2912480 r3160589  
    498498
    499499        if (\strpos($html, 'http') !== false) {
    500 
    501500            // regEx for e.g.: [https://www.domain.de/foo.php?foobar=1&email=lars%40moelleken.org&guid=test1233312&{{foo}}#foo]
    502501            $regExUrl = '/(\[?\bhttps?:\/\/[^\s<>]+(?:\(\w+\)|[^[:punct:]\s]|\/|}|]))/i';
  • powered-cache/trunk/includes/classes/Dependencies/voku/helper/AbstractSimpleHtmlDom.php

    r2912480 r3160589  
    2222        'innerhtml'    => 'innerHtml',
    2323        'innerhtmlkeep'    => 'innerHtmlKeep',
     24    ];
     25
     26    /**
     27     * @var string[]
     28     */
     29    protected static $stringDomNodes = [
     30        'id',
     31        'prefix',
     32        'content'
    2433    ];
    2534
     
    168177                if ($this->node && \property_exists($this->node, $nameOrig)) {
    169178                    // INFO: Cannot assign null to property DOMNode::* of type string
    170                     if ($nameOrig === 'prefix' || $nameOrig === 'textContent') {
     179                    if (in_array($nameOrig, self::$stringDomNodes)) {
    171180                        $value = (string)$value;
    172181                    }
    173182
    174                     return $this->node->{$nameOrig} = $value;
     183                    if (!is_null($value)) {
     184                        return $this->node->{$nameOrig} = $value;
     185                    }
    175186                }
    176187
  • powered-cache/trunk/includes/classes/Dependencies/voku/helper/HtmlDomHelper.php

    r2912480 r3160589  
    77final class HtmlDomHelper
    88{
    9 
    109    /**
    1110     * @param string $html
     
    6665
    6766        foreach ($attributes as $attributeName => $attributeValue) {
    68             $domElement->setAttribute($attributeName, $attributeValue);
     67            $domElement->setAttribute($attributeName, $attributeValue, true);
    6968        }
    7069
  • powered-cache/trunk/includes/classes/Dependencies/voku/helper/HtmlDomParser.php

    r2912480 r3160589  
    7676     * protected $specialScriptTags = [
    7777     *     'text/html',
     78     *     'text/template',
    7879     *     'text/x-custom-template',
    7980     *     'text/x-handlebars-template'
     
    8586    protected $specialScriptTags = [
    8687        'text/html',
     88        'text/template',
    8789        'text/x-custom-template',
    8890        'text/x-handlebars-template',
     
    479481
    480482        if ($documentFound === false) {
    481 
    482483            // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251
    483484            $xmlHackUsed = false;
     
    11251126            '/(?<start>(<script [^>]*type=["\']?(?:' . $tags . ')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',
    11261127            function ($matches) {
    1127 
    11281128                // Check for logic in special script tags, like [<% _.each(tierPrices, function(item, key) { %>],
    11291129                // because often this looks like non-valid html in the template itself.
  • powered-cache/trunk/includes/classes/Dependencies/voku/helper/HtmlMin.php

    r2912480 r3160589  
    16521652
    16531653        foreach ($dom->findMulti('*') as $element) {
    1654 
    16551654            // -------------------------------------------------------------------------
    16561655            // Remove whitespace around tags. [protected html is still protected]
     
    17151714            }
    17161715
    1717             $this->protectedChildNodes[$this->protected_tags_counter] = $element->parentNode()->innerHtml();
    1718             $parentNode = $element->getNode()->parentNode;
    1719             if ($parentNode !== null) {
     1716            $parentNode = $element->parentNode();
     1717            if ($parentNode->nodeValue !== null) {
     1718                $this->protectedChildNodes[$this->protected_tags_counter] = $parentNode->innerHtml();
    17201719                $parentNode->nodeValue = '<' . $this->protectedChildNodesHelper . ' data-' . $this->protectedChildNodesHelper . '="' . $this->protected_tags_counter . '"></' . $this->protectedChildNodesHelper . '>';
    17211720            }
  • powered-cache/trunk/includes/classes/Dependencies/voku/helper/HtmlMinDomObserverOptimizeAttributes.php

    r3074892 r3160589  
    5959        $attrs = [];
    6060        foreach ((array) $attributes as $attrName => $attrValue) {
    61 
    6261            // -------------------------------------------------------------------------
    6362            // Remove local domains from attributes.
  • powered-cache/trunk/includes/classes/Dependencies/voku/helper/SimpleHtmlDom.php

    r2912480 r3160589  
    685685     * Returns the parent of node.
    686686     *
    687      * @return SimpleHtmlDomInterface
    688      */
    689     public function parentNode(): SimpleHtmlDomInterface
    690     {
    691         return new static($this->node->parentNode);
     687     * @return SimpleHtmlDomInterface|null
     688     */
     689    public function parentNode(): ?SimpleHtmlDomInterface
     690    {
     691        if ($node = $this->node->parentNode) {
     692            return new static($node);
     693        }
     694
     695        return null;
    692696    }
    693697
     
    832836            $newDocument->getIsDOMDocumentCreatedWithoutHtmlWrapper()
    833837        ) {
    834 
    835838            // Remove doc-type node.
    836839            if ($newDocument->getDocument()->doctype !== null) {
  • powered-cache/trunk/includes/classes/Dependencies/voku/helper/SimpleHtmlDomBlank.php

    r2912480 r3160589  
    403403     * Returns the parent of node.
    404404     *
    405      * @return SimpleHtmlDomInterface
    406      */
    407     public function parentNode(): SimpleHtmlDomInterface
     405     * @return SimpleHtmlDomInterface|null
     406     */
     407    public function parentNode(): ?SimpleHtmlDomInterface
    408408    {
    409409        return new static();
  • powered-cache/trunk/includes/classes/Dependencies/voku/helper/SimpleHtmlDomInterface.php

    r2912480 r3160589  
    325325     * Returns the parent of node.
    326326     *
    327      * @return SimpleHtmlDomInterface
    328      */
    329     public function parentNode(): self;
     327     * @return SimpleHtmlDomInterface|null
     328     */
     329    public function parentNode(): ?self;
    330330
    331331    /**
  • powered-cache/trunk/includes/classes/Dependencies/voku/helper/XmlDomParser.php

    r2912480 r3160589  
    205205
    206206        if ($documentFound === false) {
    207 
    208207            // UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251
    209208            $xmlHackUsed = false;
  • powered-cache/trunk/includes/compat/loader.php

    r3038477 r3160589  
    2121    require_once POWERED_CACHE_COMPAT_DIR . 'plugins/autoptimize.php';
    2222    require_once POWERED_CACHE_COMPAT_DIR . 'plugins/bj-lazy-load.php';
     23    require_once POWERED_CACHE_COMPAT_DIR . 'plugins/clear-cache-for-widgets.php';
    2324    require_once POWERED_CACHE_COMPAT_DIR . 'plugins/lazy-load.php';
    2425    require_once POWERED_CACHE_COMPAT_DIR . 'plugins/rocket-lazy-load.php';
  • powered-cache/trunk/languages/powered-cache.pot

    r3135643 r3160589  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Powered Cache 3.5.1\n"
     5"Project-Id-Version: Powered Cache 3.5.2\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/powered-cache\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2024-08-14T14:56:13+00:00\n"
     12"POT-Creation-Date: 2024-10-01T10:33:24+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.10.0\n"
     
    16011601
    16021602#. translators: %1$s plugin name,  %2$s conflicted feature name (Eg lazyload)
    1603 #: includes/compat/loader.php:68
     1603#: includes/compat/loader.php:69
    16041604msgid "It seems %1$s is activated on your site. Powered Cache works perfectly fine with %1$s but you cannot use %2$s functionalities that conflic with %1$s plugin unless you deactivate it."
    16051605msgstr ""
  • powered-cache/trunk/powered-cache.php

    r3135643 r3160589  
    44 * Plugin URI:        https://poweredcache.com
    55 * Description:       Powered Cache is the most powerful caching and performance suite for WordPress, designed to easily improve your PageSpeed and Web Vitals Score.
    6  * Version:           3.5.1
     6 * Version:           3.5.2
    77 * Requires at least: 5.7
    88 * Requires PHP:      7.2.5
     
    2626
    2727// Useful global constants.
    28 define( 'POWERED_CACHE_VERSION', '3.5.1' );
     28define( 'POWERED_CACHE_VERSION', '3.5.2' );
    2929define( 'POWERED_CACHE_DB_VERSION', '3.4' );
    3030define( 'POWERED_CACHE_PLUGIN_FILE', __FILE__ );
  • powered-cache/trunk/readme.txt

    r3135643 r3160589  
    44Requires at least:  5.7
    55Tested up to:  6.6
    6 Stable tag:  3.5.1
     6Stable tag:  3.5.2
    77License: GPLv2 (or later)
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    171171
    172172== Changelog ==
     173
     174= 3.5.2 (October 01, 2024) =
     175- [Added] Clear Cache for Me compatibility.
     176- [Updated] Minifier libraries.
     177- Various dependency updates.
    173178
    174179= 3.5.1 (August 14, 2024) =
Note: See TracChangeset for help on using the changeset viewer.