Plugin Directory

Changeset 3263100


Ignore:
Timestamp:
03/27/2025 08:12:12 PM (12 months ago)
Author:
marknokes
Message:

Version 2.8.5

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

Legend:

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

    r3261720 r3263100  
    11<?php
     2
     3namespace CUGZ;
    24
    35/*
    46 * Plugin Name: Cache Using Gzip
    5  * Version: 2.8.4
     7 * Version: 2.8.5
    68 * Description: Creates gzip files on your server to immensly improve page speed for site visitors
    79 * Author: Cache Using Gzip
     
    1921}
    2022
    21 use CUGZ\GzipCache;
    22 use CUGZ\GzipCacheEnterprise;
    23 use CUGZ\GzipCachePluginExtras;
    24 
    2523require_once 'autoload.php';
    2624
     
    3533$GzipCache = new GzipCache();
    3634
    37 if (!extension_loaded('zlib')) {
    38     $GzipCache->zlib_enabled = false;
    39 
    40     add_action('admin_notices', function () use ($GzipCache) {
    41         $GzipCache->cugz_notice('Zlib extension is not enabled. You must enable the zlib extension in order to use the <strong>'.esc_html($GzipCache->plugin_name).'</strong> plugin.', 'warning');
    42     });
    43 }
    44 
    45 $GzipCache->GzipCachePluginExtras = CUGZ_PLUGIN_EXTRAS ? new GzipCachePluginExtras() : null;
     35$GzipCachePluginExtras = CUGZ_PLUGIN_EXTRAS ? new GzipCachePluginExtras() : null;
    4636
    4737register_activation_hook(CUGZ_PLUGIN_PATH, [$GzipCache, 'cugz_plugin_activation']);
  • cache-using-gzip/trunk/classes/CUGZ/class-cugz-gzip-cache.php

    r3259429 r3263100  
    171171
    172172    /**
    173      * GzipCachePluginExtras class if exists.
    174      *
    175      * @var object
    176      */
    177     public $GzipCachePluginExtras;
    178 
    179     /**
    180173     * Constructor for the class.
    181174     * Initializes class variables and sets up action hooks for option updates.
     
    183176    public function __construct()
    184177    {
    185         foreach (self::$options as $option => $array) {
    186             if (self::cugz_skip_option($array)) {
    187                 continue;
    188             }
    189 
    190             $this->{$option} = self::cugz_get_option($option);
    191 
    192             add_action("update_option_{$option}", [$this, 'cugz_clear_option_cache'], 10, 3);
    193         }
    194 
    195178        $plugin_data = get_file_data(CUGZ_PLUGIN_PATH, [
    196179            'Version' => 'Version',
     
    209192
    210193        $this->settings_url = admin_url(self::$options_page_url);
     194
     195        $this->cugz_set_props_from_options();
     196
     197        $this->cugz_zlib_check();
    211198    }
    212199
     
    594581    public function cugz_get_links($post = null)
    595582    {
     583        global $GzipCachePluginExtras;
     584
    596585        $is_preload = null === $post;
    597586
     
    614603        }
    615604
    616         if (isset($this->GzipCachePluginExtras)) {
    617             $links = $this->GzipCachePluginExtras->get_archive_links($links, $term_ids, $cat_ids);
     605        if (isset($GzipCachePluginExtras)) {
     606            $links = $GzipCachePluginExtras->get_archive_links($links, $term_ids, $cat_ids);
    618607        }
    619608
     
    630619    public function cugz_create_folder_structure_from_url($url)
    631620    {
    632         if (isset($this->GzipCachePluginExtras) && $this->GzipCachePluginExtras->cugz_never_cache($url)) {
     621        global $GzipCachePluginExtras;
     622
     623        if (isset($GzipCachePluginExtras) && $GzipCachePluginExtras->cugz_never_cache($url)) {
    633624            return false;
    634625        }
     
    884875
    885876    /**
     877     * Sets class properties using self::$options and adds an update_option_{option_name} hook for each one.
     878     */
     879    protected function cugz_set_props_from_options()
     880    {
     881        foreach (self::$options as $option => $array) {
     882            if (self::cugz_skip_option($array)) {
     883                continue;
     884            }
     885
     886            $this->{$option} = self::cugz_get_option($option);
     887
     888            add_action("update_option_{$option}", [$this, 'cugz_clear_option_cache'], 10, 3);
     889        }
     890    }
     891
     892    /**
     893     * Check if the zlib extension is enabled and display an admin notice if not.
     894     */
     895    protected function cugz_zlib_check()
     896    {
     897        if (!extension_loaded('zlib')) {
     898            $this->zlib_enabled = false;
     899
     900            set_transient('cugz_notice', [
     901                'message' => 'Zlib extension is not enabled. You must enable the zlib extension in order to use the <strong>'.esc_html($this->plugin_name).'</strong> plugin.',
     902                'type' => 'warning',
     903            ], 3600);
     904        }
     905    }
     906
     907    /**
    886908     * Checks if the given array contains the necessary information to skip a certain option.
    887909     *
  • cache-using-gzip/trunk/readme.txt

    r3261720 r3263100  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 2.8.4
     7Stable tag: 2.8.5
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5858
    5959== Changelog ==
     60
     61= 2.8.5 =
     62Improvement: remove superfluous import statements
     63Improvement: minor refactor
    6064
    6165= 2.8.4 =
Note: See TracChangeset for help on using the changeset viewer.