Plugin Directory

Changeset 2254079


Ignore:
Timestamp:
03/04/2020 08:55:21 AM (6 years ago)
Author:
upress
Message:

v1.4.1

Location:
ezcache
Files:
101 added
12 edited

Legend:

Unmodified
Added
Removed
  • ezcache/trunk/changelog.txt

    r2247507 r2254079  
     1= 1.4.1 =
     2- FIX: Reverted minified CSS position
     3- FIX: Translation will now load correctly
     4- FIX: CSS minification optimization
     5- ADD: WebP now supports <style> tags
     6
    17= 1.4 =
    28- FIX: Clearing cache will delete cache for all languages on a multi language or multisite website
  • ezcache/trunk/ezcache.php

    r2247507 r2254079  
    44    Description: EzCache is an easy and innovative cache plugin that will help you significantly improve your site speed.
    55    Plugin URI: https://ezcache.app
    6     Version: 1.4
     6    Version: 1.4.1
    77    Author: uPress
    88    Author URI: https://www.upress.io
     
    3636    define( 'EZCACHE_URL', plugin_dir_url( __FILE__ ) );
    3737    define( 'EZCACHE_BASEBANE', basename( __FILE__ ) );
    38     define( 'EZCACHE_VERSION', '1.4' );
     38    define( 'EZCACHE_VERSION', '1.4.1' );
    3939    define( 'EZCACHE_SETTINGS_KEY', 'ezcache' );
    4040
     
    106106
    107107            add_action( 'init', [ $this, 'load_translation' ] );
    108             add_action( 'edit_post', [ $this, 'maybe_clear_cache_on_post_update' ], 10, 2 );
    109108            add_filter( 'cron_schedules', [ $this, 'add_cron_schedules' ] );
    110             add_filter( 'show_admin_bar', [ $this, 'maybe_show_admin_bar' ], 100 );
    111109
    112110            new RestApi($this);
     
    117115
    118116        function load_translation() {
    119             load_plugin_textdomain( 'ezcache', false, basename( dirname( EZCACHE_FILE ) ) . '/languages' );
     117            $locale = apply_filters( 'plugin_locale', get_locale(), 'ezcache' );
     118            load_textdomain( 'ezcache', EZCACHE_DIR . "/languages/ezcache-{$locale}.mo" );
    120119        }
    121120
     
    139138            }
    140139
    141             file_put_contents( $path, $contents );
     140            @file_put_contents( $path, $contents );
    142141
    143142            // if the user currently has an advanced-cache file rename it as a backup
     
    164163            }
    165164
    166             file_put_contents( $path, $contents );
     165            @file_put_contents( $path, $contents );
    167166
    168167            // delete advanced-cache
     
    182181
    183182            $this->ezcache->clear_cache();
    184         }
    185 
    186         /**
    187          * Runs when a post is created, updated, or a comment is left on it
    188          * @param int $post_id
    189          * @param WP_Post $post
    190          */
    191         function maybe_clear_cache_on_post_update( $post_id, $post ) {
    192             $settings = Settings::get_settings();
    193 
    194             if ( ! $settings->cache_clear_on_post_edit ) {
    195                 return;
    196             }
    197 
    198             $this->ezcache->clear_cache_single( $post_id );
    199183        }
    200184
     
    239223            return $schedules;
    240224        }
    241 
    242         function maybe_show_admin_bar( $show_admin_bar ) {
    243             $settings = Settings::get_settings();
    244 
    245             if ( ! $settings->no_cache_known_users ) {
    246                 return false;
    247             }
    248 
    249             return $show_admin_bar;
    250         }
    251225    }
    252226
  • ezcache/trunk/includes/Admin.php

    r2247507 r2254079  
    2525        $this->plugin = $plugin;
    2626
    27         // skip any admin related stuff when doing ajax, cron or rest
    28         if ( (defined( 'DOING_AJAX' ) && DOING_AJAX) || (defined( 'DOING_CRON' ) && DOING_CRON) || (defined( 'REST_REQUEST' ) && REST_REQUEST) ) {
    29             return;
    30         }
    31 
    32         add_action( 'admin_init', [ $this, 'start_session' ] );
    33         add_action( 'admin_init', [ $this, 'register_settings' ] );
     27        add_filter( 'show_admin_bar', [ $this, 'maybe_show_admin_bar' ], 100 );
     28        add_action( 'admin_init', [ $this, 'admin_init' ] );
    3429        add_action( 'admin_menu', [ $this, 'register_menu' ] );
    3530        add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
     
    4237        add_action( 'admin_bar_menu', [ $this, 'add_admin_bar_button' ], 999 );
    4338        add_action( 'admin_post_wpb_clear_cache', [ $this, 'admin_clear_cache' ] );
    44         add_action( 'admin_post_nopriv_wpb_clear_cache', [ $this, 'admin_clear_cache' ] );
    4539        add_action( 'delete_attachment', [ $this, 'delete_webp_image' ] );
    46         add_action( 'admin_init', [ $this, 'maybe_repair_installation' ] );
    4740
    4841        add_action( 'init', [ $this, 'register_post_meta' ] );
    4942        add_action( 'add_meta_boxes', [ $this, 'post_cache_metabox' ] );
    5043        add_action( 'save_post', [ $this, 'save_post_cache_metabox' ] );
     44        add_action( 'edit_post', [ $this, 'maybe_clear_cache_on_post_update' ], 10, 2 );
    5145    }
    5246
     
    185179
    186180    /**
     181     * Runs when a post is created, updated, or a comment is left on it
     182     * @param int $post_id
     183     * @param WP_Post $post
     184     */
     185    function maybe_clear_cache_on_post_update( $post_id, $post ) {
     186        $settings = Settings::get_settings();
     187
     188        if ( ! $settings->cache_clear_on_post_edit ) {
     189            return;
     190        }
     191
     192        $this->ezcache->clear_cache_single( $post_id );
     193    }
     194
     195    /**
    187196     * Add settings link to the plugin action links
    188197     *
     
    235244    }
    236245
    237     /**
    238      * Make sure we have a session
    239      */
    240     function start_session() {
     246    function admin_init() {
     247        // Make sure we have a session
    241248        if ( session_status() == PHP_SESSION_NONE ) {
    242249            session_start();
    243250        }
    244     }
    245 
    246     /**
    247      * Register settings for the plugin
    248      */
    249     function register_settings() {
     251
     252        // Register settings for the plugin
    250253        register_setting( $this->plugin->plugin_settings_key . '_group', $this->plugin->plugin_settings_key );
     254
     255        $this->maybe_repair_installation();
    251256    }
    252257
     
    677682        $_SESSION['EZCACHE_REPAIRED'] = true;
    678683    }
     684
     685    function maybe_show_admin_bar( $show_admin_bar ) {
     686        $settings = Settings::get_settings();
     687
     688        if ( ! $settings->no_cache_known_users ) {
     689            return false;
     690        }
     691
     692        return $show_admin_bar;
     693    }
    679694}
  • ezcache/trunk/includes/Cache.php

    r2247507 r2254079  
    764764    public function do_frontend_optimizations() {
    765765        if ( ! $this->should_serve_cached_data() ) {
    766             return false;
     766            return;
    767767        }
    768768
     
    782782        }
    783783
    784         // PHP_INT_MAX to make sure these placeholders are the last script at the end of their respective locations
    785         add_action( 'wp_head', [ $this, 'cache_placeholder_wp_head' ], PHP_INT_MAX );
    786         add_action( 'wp_footer', [ $this, 'cache_placeholder_wp_footer' ], PHP_INT_MAX );
    787784
    788785        if ( ! empty( $settings->critical_css ) ) {
    789786            add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_critical_css' ], PHP_INT_MAX );
    790787        }
    791     }
    792 
    793     public function cache_placeholder_wp_head() {
    794         echo "\n".static::PLACEHOLDER_HEAD."\n";
    795     }
    796 
    797     public function cache_placeholder_wp_footer() {
    798         echo  "\n".static::PLACEHOLDER_FOOTER."\n";
    799788    }
    800789
     
    870859
    871860        if ( $settings->minify_html ) {
     861            wp_raise_memory_limit( 'image' );
     862
    872863            $buffer = Minify_HTML::minify( $buffer, [
    873864                'htmlCleanComments' => $settings->minify_html_comments,
     
    879870
    880871                    $minifier = new CSS( $css );
     872                    $minifier->setMaxImportSize(0);
     873                    $minifier->setImportExtensions([]);
    881874                    return $minifier->minify();
    882875                },
  • ezcache/trunk/includes/FileOptimizer/CssCombiner.php

    r2247507 r2254079  
    7373
    7474        if ( $this->minify_footer ) {
    75             $minify_location_placeholder = false !== stripos( $html, Cache::PLACEHOLDER_FOOTER ) ? Cache::PLACEHOLDER_FOOTER : '</body>';
     75            $html = str_replace( '</body>', "{$minify_link_tag}\n</body>", $html );
    7676        } else {
    77             $minify_location_placeholder = false !== stripos( $html, Cache::PLACEHOLDER_HEAD ) ? Cache::PLACEHOLDER_HEAD : '</head>';
     77            $html = str_replace( '</title>', "</title>\n{$minify_link_tag}", $html );
    7878        }
    79 
    80         $html = str_replace( $minify_location_placeholder, "{$minify_link_tag}\n{$minify_location_placeholder}", $html );
    8179
    8280        $styles = array_filter( $styles );
  • ezcache/trunk/includes/FileOptimizer/JsCombiner.php

    r2247507 r2254079  
    8282        }
    8383
    84         $minify_script_tag = '<script src="' . esc_url( $minify_url ) . '" data-minify="1"></script></head>';
     84        $minify_script_tag = '<script src="' . esc_url( $minify_url ) . '" data-minify="1"></script>';
    8585
    8686        if ( 'head' === $this->in_location ) {
    87             $minify_location_placeholder = false !== stripos( $html, Cache::PLACEHOLDER_HEAD ) ? Cache::PLACEHOLDER_HEAD : '</head>';
     87            $html = str_replace( '</head>', "{$minify_script_tag}\n</head>", $html );
    8888        } else {
    89             $minify_location_placeholder = false !== stripos( $html, Cache::PLACEHOLDER_FOOTER ) ? Cache::PLACEHOLDER_FOOTER : '</body>';
    90         }
    91 
    92         $html = str_replace( $minify_location_placeholder, "{$minify_script_tag}\n{$minify_location_placeholder}", $html );
    93 
     89            $html = str_replace( '</body>', "{$minify_script_tag}\n</body>", $html );
     90        }
    9491
    9592        $combine_scripts = array_filter( $combine_scripts );
  • ezcache/trunk/includes/FileOptimizer/WebpConverter.php

    r2247507 r2254079  
    3838         * <div style="background: url(elva-480w-close-portrait.jpg);">
    3939         * <div style="background-image: url(elva-480w-close-portrait.jpg);">
     40         * <style>.foo { background-image: url(elva-480w-close-portrait.jpg); }</style>
    4041         */
    4142        $img_tags    = $this->find( '<img\s+([^>]+[\s"\'])?src\s*=\s*[\'"]\s*?([^\'"]+(?:\?[^\'"]*)?)\s*?[\'"]([^>]+)?\/?>', $html );
    42         $bg_images = $this->find( 'style=([\'"]).+:\s*url\s*\(\s*([\'"]?)(.+)\2?\s*\).+\1', $html );
     43        $bg_images = $this->find( 'background(?:-image)\s*:.*url\s*\(\s*([\'"]?)([^\'"]+)\1\s*\)', $html );
    4344
    4445        if ( ! $img_tags ) {
     
    7071        // for bg images grab the url part
    7172        foreach ( $bg_images as $img ) {
    72             $images[] = trim( $img[3], ' \t\n\r\0\x0B\'"' );
     73            $images[] = trim( $img[2], ' \t\n\r\0\x0B\'"' );
    7374        }
    7475
  • ezcache/trunk/readme.txt

    r2247507 r2254079  
    3535
    3636== Changelog ==
     37= 1.4.1 =
     38- FIX: Reverted minified CSS position
     39- FIX: Translation will now load correctly
     40- FIX: CSS minification optimization
     41- ADD: WebP now supports <style> tags
     42
    3743= 1.4 =
    3844- FIX: Clearing cache will delete cache for all languages on a multi language or multisite website
  • ezcache/trunk/vendor/composer/installed.json

    r2149447 r2254079  
    4040    {
    4141        "name": "matthiasmullie/minify",
    42         "version": "1.3.61",
    43         "version_normalized": "1.3.61.0",
     42        "version": "1.3.63",
     43        "version_normalized": "1.3.63.0",
    4444        "source": {
    4545            "type": "git",
    4646            "url": "https://github.com/matthiasmullie/minify.git",
    47             "reference": "d5acb8ce5b6acb7d11bafe97cecc533f6e4fd751"
     47            "reference": "9ba1b459828adc13430f4dd6c49dae4950dc4117"
    4848        },
    4949        "dist": {
    5050            "type": "zip",
    51             "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/d5acb8ce5b6acb7d11bafe97cecc533f6e4fd751",
    52             "reference": "d5acb8ce5b6acb7d11bafe97cecc533f6e4fd751",
     51            "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/9ba1b459828adc13430f4dd6c49dae4950dc4117",
     52            "reference": "9ba1b459828adc13430f4dd6c49dae4950dc4117",
    5353            "shasum": ""
    5454        },
     
    6666            "psr/cache-implementation": "Cache implementation to use with Minify::cache"
    6767        },
    68         "time": "2018-11-26T23:10:39+00:00",
     68        "time": "2020-01-21T20:21:08+00:00",
    6969        "bin": [
    7070            "bin/minifycss",
     
    102102    {
    103103        "name": "matthiasmullie/path-converter",
    104         "version": "1.1.2",
    105         "version_normalized": "1.1.2.0",
     104        "version": "1.1.3",
     105        "version_normalized": "1.1.3.0",
    106106        "source": {
    107107            "type": "git",
    108108            "url": "https://github.com/matthiasmullie/path-converter.git",
    109             "reference": "5e4b121c8b9f97c80835c1d878b0812ba1d607c9"
     109            "reference": "e7d13b2c7e2f2268e1424aaed02085518afa02d9"
    110110        },
    111111        "dist": {
    112112            "type": "zip",
    113             "url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/5e4b121c8b9f97c80835c1d878b0812ba1d607c9",
    114             "reference": "5e4b121c8b9f97c80835c1d878b0812ba1d607c9",
     113            "url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/e7d13b2c7e2f2268e1424aaed02085518afa02d9",
     114            "reference": "e7d13b2c7e2f2268e1424aaed02085518afa02d9",
    115115            "shasum": ""
    116116        },
     
    122122            "phpunit/phpunit": "~4.8"
    123123        },
    124         "time": "2018-10-25T15:19:41+00:00",
     124        "time": "2019-02-05T23:41:09+00:00",
    125125        "type": "library",
    126126        "installation-source": "dist",
  • ezcache/trunk/vendor/matthiasmullie/minify/src/CSS.php

    r2149447 r2254079  
    526526
    527527        return preg_replace_callback(
    528             '/(?<=[: ])('.implode(array_keys($colors), '|').')(?=[; }])/i',
     528            '/(?<=[: ])('.implode('|', array_keys($colors)).')(?=[; }])/i',
    529529            function ($match) use ($colors) {
    530530                return $colors[strtoupper($match[0])];
     
    709709        };
    710710
    711         $this->registerPattern('/calc(\(.+?)(?=$|;|calc\()/', $callback);
     711        $this->registerPattern('/calc(\(.+?)(?=$|;|}|calc\()/', $callback);
     712        $this->registerPattern('/calc(\(.+?)(?=$|;|}|calc\()/m', $callback);
    712713    }
    713714
  • ezcache/trunk/vendor/matthiasmullie/minify/src/Minify.php

    r2149447 r2254079  
    9595            // store data
    9696            $this->data[$key] = $value;
     97        }
     98
     99        return $this;
     100    }
     101
     102    /**
     103     * Add a file to be minified.
     104     *
     105     * @param string|string[] $data
     106     *
     107     * @return static
     108     *
     109     * @throws IOException
     110     */
     111    public function addFile($data /* $data = null, ... */)
     112    {
     113        // bogus "usage" of parameter $data: scrutinizer warns this variable is
     114        // not used (we're using func_get_args instead to support overloading),
     115        // but it still needs to be defined because it makes no sense to have
     116        // this function without argument :)
     117        $args = array($data) + func_get_args();
     118
     119        // this method can be overloaded
     120        foreach ($args as $path) {
     121            if (is_array($path)) {
     122                call_user_func_array(array($this, 'addFile'), $path);
     123                continue;
     124            }
     125
     126            // redefine var
     127            $path = (string) $path;
     128
     129            // check if we can read the file
     130            if (!$this->canImportFile($path)) {
     131                throw new IOException('The file "'.$path.'" could not be opened for reading. Check if PHP has enough permissions.');
     132            }
     133
     134            $this->add($path);
    97135        }
    98136
  • ezcache/trunk/vendor/matthiasmullie/path-converter/src/Converter.php

    r2149447 r2254079  
    7272        $path = rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $path), '/');
    7373
     74        // remove leading current directory.
     75        if (substr($path, 0, 2) === './') {
     76            $path = substr($path, 2);
     77        }
     78
     79        // remove references to current directory in the path.
     80        $path = str_replace('/./', '/', $path);
     81
    7482        /*
    7583         * Example:
Note: See TracChangeset for help on using the changeset viewer.