Plugin Directory

Changeset 3315193


Ignore:
Timestamp:
06/20/2025 11:29:39 AM (10 months ago)
Author:
marknokes
Message:

Version 2.8.8

Location:
cache-using-gzip
Files:
20 added
4 edited

Legend:

Unmodified
Added
Removed
  • cache-using-gzip/trunk/cache-using-gzip.php

    r3303203 r3315193  
    55/*
    66 * Plugin Name: Cache Using Gzip
    7  * Version: 2.8.7
     7 * Version: 2.8.8
    88 * Description: Creates gzip files on your server to immensly improve page speed for site visitors
    99 * Author: Cache Using Gzip
  • cache-using-gzip/trunk/classes/CUGZ/class-cugz-gzip-cache.php

    r3303203 r3315193  
    264264        add_action('cugz_cron_auto_preload', [$this, 'cugz_preload_cache']);
    265265
     266        add_action('cugz_options_page_next_auto_preload', [$this, 'cugz_options_page_next_auto_preload']);
     267
    266268        if ($this->zlib_enabled) {
    267269            add_action('admin_menu', [$this, 'cugz_register_options_page']);
     
    293295
    294296        add_filter('plugin_row_meta', [$this, 'cugz_plugin_row_meta'], 10, 2);
     297    }
     298
     299    /**
     300     * Displays a message on the options page with the next scheduled auto preload, if applicable.
     301     */
     302    public function cugz_options_page_next_auto_preload()
     303    {
     304        if ($cugz_cron_auto_preload = wp_next_scheduled('cugz_cron_auto_preload')) {
     305            $dt = new \DateTime("@{$cugz_cron_auto_preload}");
     306            $dt->setTimezone(wp_timezone());
     307            echo '<strong>Next auto preload:</strong> <code>'.esc_html($dt->format('F j, Y, g:i a')).'</code>';
     308        }
    295309    }
    296310
     
    10641078
    10651079    /**
     1080     * Accepts a string of CSS and replaces relative URL's with absolute ULR's.
     1081     *
     1082     * @param string $css     CSS content
     1083     * @param string $css_url URL to css file
     1084     *
     1085     * @return string returns CSS with corrected URL's before minifying and placing inline
     1086     */
     1087    protected function fix_css_urls($css, $css_url)
     1088    {
     1089        return preg_replace_callback('/url\((["\']?)(?!data:|https?:|\/\/)([^"\')]+)(["\']?)\)/i', function ($matches) use ($css_url) {
     1090            $quote = $matches[1];
     1091            $relative_path = $matches[2];
     1092            $parsed_url = wp_parse_url($css_url);
     1093            $base_url = $parsed_url['scheme'].'://'.$parsed_url['host'];
     1094
     1095            if (!empty($parsed_url['port'])) {
     1096                $base_url .= ':'.$parsed_url['port'];
     1097            }
     1098
     1099            $base_path = rtrim(dirname($parsed_url['path']), '/').'/';
     1100            $full_path = $base_path.$relative_path;
     1101            $normalized_path = [];
     1102            $parts = explode('/', $full_path);
     1103
     1104            foreach ($parts as $part) {
     1105                if ('..' === $part) {
     1106                    array_pop($normalized_path);
     1107                } elseif ('.' !== $part && '' !== $part) {
     1108                    $normalized_path[] = $part;
     1109                }
     1110            }
     1111
     1112            $final_path = '/'.implode('/', $normalized_path);
     1113
     1114            return 'url('.$quote.$base_url.$final_path.$quote.')';
     1115        }, $css);
     1116    }
     1117
     1118    /**
    10661119     * Accepts a string on unminified CSS and removes spaces and comments.
    10671120     *
     
    11361189                    error_log('Error: Unable to retrieve css content from '.$css_link);
    11371190                }
     1191
     1192                $css_content = $this->fix_css_urls($css_content, $css_link);
    11381193
    11391194                $html = preg_replace('/<link[^>]+rel\s*=\s*[\'"]?stylesheet[\'"]?[^>]+href\s*=\s*[\'"]?'.preg_quote($css_link, '/').'[\'"]?[^>]*>/i', '<style>'.$this->cugz_minify_css($css_content).'</style>', $html);
  • cache-using-gzip/trunk/readme.txt

    r3303203 r3315193  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 2.8.7
     7Stable tag: 2.8.8
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8484
    8585== Changelog ==
     86
     87= 2.8.8 =
     88Bugfix: when move css/js inline chosen relative url's in minified css files break
     89Improvement: add message to options page with next auto preload date and time
    8690
    8791= 2.8.7 =
  • cache-using-gzip/trunk/templates/options-page.php

    r3303203 r3315193  
    140140                            <p id="complete" class="cache-status">&#10004; Preloaded</p>
    141141                            <p id="clean" class="cache-status">&#45; Not preloaded</p>
     142                            <p><?php do_action('cugz_options_page_next_auto_preload'); ?></p>
    142143                        </td>
    143144                    </tr>
Note: See TracChangeset for help on using the changeset viewer.