Plugin Directory

Changeset 3708055


Ignore:
Timestamp:
09/22/2026 08:30:39 PM (5 weeks ago)
Author:
shiponkarmakar
Message:

Release v1.0.22

Location:
optimazz
Files:
2 added
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • optimazz/tags/1.0.22/includes/Admin/Admin.php

    r3692106 r3708055  
    206206                        return;
    207207                }
     208
     209                // Update safety guard — shown on every admin screen (including Optimazz's
     210                // own), because "your site was breaking and we protected it" is important
     211                // enough to surface wherever the admin happens to be.
     212                $guard = \Optimazz\Core\Guard::state();
     213                if ( $guard && isset( $guard['status'] ) ) {
     214                        $tools_url = admin_url( 'admin.php?page=' . self::MENU_SLUG . '&view=tools' );
     215                        if ( 'protected' === $guard['status'] ) {
     216                                echo '<div class="notice notice-warning"><p><strong>' . esc_html__( 'Optimazz Safe Mode is on.', 'optimazz' ) . '</strong> '
     217                                        . esc_html__( 'After the last update, some pages were loading without styling — their optimized CSS could not be found, usually because an external server or CDN cache was still serving old pages. Optimazz paused advanced CSS/JS optimization to keep your site working. Clear any server/CDN cache, then', 'optimazz' )
     218                                        . ' <a href="' . esc_url( $tools_url ) . '">' . esc_html__( 'open Tools to re-check and switch Safe Mode off', 'optimazz' ) . '</a>.</p></div>';
     219                        } elseif ( 'recovered' === $guard['status'] ) {
     220                                echo '<div class="notice notice-success is-dismissible"><p><strong>Optimazz:</strong> '
     221                                        . esc_html__( 'Your pages are loading correctly again — you can switch Safe Mode off in', 'optimazz' )
     222                                        . ' <a href="' . esc_url( $tools_url ) . '">' . esc_html__( 'Tools', 'optimazz' ) . '</a>.</p></div>';
     223                        }
     224                }
     225
    208226                // Never emit a WordPress notice on the Optimazz screen — the React app
    209227                // shows these as branded toasts. (Guards against notice relocation and
  • optimazz/tags/1.0.22/includes/Admin/RestController.php

    r3692106 r3708055  
    289289                if ( $purged ) {
    290290                        Manager::storage()->purge_all();
     291                }
     292
     293                // If the admin is switching Safe Mode OFF, clear any guard notice but
     294                // schedule a fresh health check shortly after: if the generated CSS still
     295                // 404s (e.g. an external cache is not yet cleared), the guard re-protects
     296                // the site automatically instead of leaving it broken.
     297                $was_safe = ! empty( $before['tools']['safe_mode'] );
     298                $now_safe = ! empty( $saved['tools']['safe_mode'] );
     299                if ( $was_safe && ! $now_safe && class_exists( '\Optimazz\Core\Guard' ) ) {
     300                        \Optimazz\Core\Guard::clear();
     301                        \Optimazz\Core\Guard::schedule( 20 );
    291302                }
    292303
    … …  
    617628                $cache = $this->settings->for_module( 'cache' );
    618629
    619                 // Optimized CSS cache footprint.
    620                 $css_dir   = WP_CONTENT_DIR . '/cache/optimazz/css/';
     630                // Optimized CSS footprint (generated CSS lives under uploads/, not cache/).
     631                $uploads   = wp_upload_dir( null, false );
     632                $css_dir   = ( isset( $uploads['basedir'] ) ? trailingslashit( $uploads['basedir'] ) : trailingslashit( WP_CONTENT_DIR . '/uploads' ) ) . 'optimazz/css/';
    621633                $css_files = 0;
    622634                $css_bytes = 0;
  • optimazz/tags/1.0.22/includes/Core/Lifecycle.php

    r3704576 r3708055  
    7878                \Optimazz\Modules\Cache\Manager::sync( $cache );
    7979                \Optimazz\Modules\Cache\Manager::storage()->purge_all();
     80
     81                // Schedule the safety self-check: shortly after the cache re-warms, Guard
     82                // verifies the front page's CSS actually loads and, if not, protects the
     83                // site by pausing the risky transforms (Safe Mode) automatically.
     84                if ( class_exists( '\Optimazz\Core\Guard' ) ) {
     85                        Guard::schedule();
     86                }
    8087        }
    8188
    … …  
    97104                wp_clear_scheduled_hook( 'optimazz_purge_expired' );
    98105                wp_clear_scheduled_hook( 'optimazz_db_cleanup' );
     106                wp_clear_scheduled_hook( 'optimazz_health_check' );
    99107        }
    100108}
  • optimazz/tags/1.0.22/includes/Core/Plugin.php

    r3704576 r3708055  
    9191                $this->loader->boot();
    9292
     93                // Update safety guard — the scheduled self-check that auto-enables Safe
     94                // Mode if a post-update front page renders unstyled.
     95                Guard::register();
     96
    9397                // One-time reconciliation after a version change (update). Clears cached
    9498                // HTML left by an older version so pages never load unstyled post-update.
  • optimazz/tags/1.0.22/includes/Modules/Css/CssModule.php

    r3692106 r3708055  
    2424
    2525        /**
    26          * Cache directory for generated CSS.
    27          *
    28          * @return string
     26         * Generated CSS lives under the uploads directory, NOT wp-content/cache/.
     27         *
     28         * These files are referenced by name in the page HTML, so they must be
     29         * served reliably and never wiped out from under a cached page. The
     30         * wp-content/cache/ directory fails both tests on many hosts: it is the
     31         * conventional "safe to delete" location that servers (LiteSpeed), hosts and
     32         * cleanup tools purge on their own, and some servers/WAFs don't serve static
     33         * files from it at all (returning 404 — which renders every page unstyled).
     34         * The uploads directory is always publicly served and is persistent, so the
     35         * generated stylesheets behave like any other asset (the same place page
     36         * builders write their generated CSS).
     37         *
     38         * @return string Filesystem path (with trailing slash).
    2939         */
    3040        private function cache_dir() {
    31                 return WP_CONTENT_DIR . '/cache/optimazz/css/';
    32         }
    33 
    34         /**
    35          * Public URL base for generated CSS.
    36          *
    37          * @return string
     41                $dirs = self::upload_dirs();
     42                return $dirs['basedir'] . 'optimazz/css/';
     43        }
     44
     45        /**
     46         * Public URL base for generated CSS (matches cache_dir()).
     47         *
     48         * @return string URL (with trailing slash).
    3849         */
    3950        private function cache_url() {
    40                 return content_url( '/cache/optimazz/css/' );
     51                $dirs = self::upload_dirs();
     52                return $dirs['baseurl'] . 'optimazz/css/';
     53        }
     54
     55        /**
     56         * Resolve (and memoize) the uploads base dir + URL. The URL is forced to the
     57         * request scheme so an https page never references an http stylesheet.
     58         *
     59         * @return array{basedir:string,baseurl:string}
     60         */
     61        private static function upload_dirs() {
     62                static $cache = null;
     63                if ( null === $cache ) {
     64                        $u       = wp_upload_dir( null, false );
     65                        $basedir = isset( $u['basedir'] ) ? trailingslashit( $u['basedir'] ) : trailingslashit( WP_CONTENT_DIR . '/uploads' );
     66                        $baseurl = isset( $u['baseurl'] ) ? trailingslashit( $u['baseurl'] ) : trailingslashit( content_url( '/uploads' ) );
     67                        if ( function_exists( 'set_url_scheme' ) ) {
     68                                $baseurl = set_url_scheme( $baseurl );
     69                        }
     70                        $cache = array(
     71                                'basedir' => $basedir,
     72                                'baseurl' => $baseurl,
     73                        );
     74                }
     75                return $cache;
    4176        }
    4277
    … …  
    527562                if ( ! is_dir( $dir ) ) {
    528563                        wp_mkdir_p( $dir );
     564                        // Prevent directory listing of the generated-CSS folder in uploads.
     565                        if ( is_dir( $dir ) && ! file_exists( $dir . 'index.html' ) ) {
     566                                @file_put_contents( $dir . 'index.html', '' ); // phpcs:ignore WordPress.WP.AlternativeFunctions,WordPress.PHP.NoSilencedErrors
     567                        }
    529568                }
    530569                $file = $dir . $key . '.css';
  • optimazz/tags/1.0.22/optimazz.php

    r3704576 r3708055  
    44 * Plugin URI:        https://wordpress.org/plugins/optimazz/
    55 * Description:        All-in-one WordPress performance optimization — page caching, JS delay, and CSS optimization.
    6  * Version:           1.0.21
     6 * Version:           1.0.22
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
    … …  
    2626}
    2727
    28 define( 'OPTIMAZZ_VERSION', '1.0.21' );
     28define( 'OPTIMAZZ_VERSION', '1.0.22' );
    2929define( 'OPTIMAZZ_FILE', __FILE__ );
    3030define( 'OPTIMAZZ_DIR', plugin_dir_path( __FILE__ ) );
  • optimazz/tags/1.0.22/optimazz.pot

    r3704576 r3708055  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Optimazz – Website Optimization and Speedup 1.0.21\n"
     5"Project-Id-Version: Optimazz – Website Optimization and Speedup 1.0.22\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/optimazz\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
  • optimazz/tags/1.0.22/readme.txt

    r3704576 r3708055  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.21
     7Stable tag: 1.0.22
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    9999== Changelog ==
    100100
     101= 1.0.22 =
     102* Fixed: on some hosts (certain LiteSpeed/WAF setups and managed hosts) pages loaded unstyled because the server does not serve — or routinely deletes — files under `wp-content/cache/`, which is where Optimazz kept its generated CSS. Since the page HTML references those files by name, a page that could not load them rendered without styling. Optimazz now stores generated CSS under `wp-content/uploads/optimazz/` instead — the standard, always-served, persistent location page builders also use — so the stylesheets load reliably and are never wiped out from under a cached page. On update the page cache is refreshed automatically so pages pick up the new location with no manual step.
     103* New: update safety guard. Shortly after the plugin updates, Optimazz quietly checks its own front page to confirm the optimized CSS actually loads. If it finds pages rendering unstyled — their generated stylesheets returning 404, usually because an external server or CDN cache is still serving old pages — it automatically switches on Safe Mode to keep the site working (pausing the risky CSS/JS transforms without changing your saved settings, so pages fall back to their original stylesheets) and shows an admin notice explaining what happened. After you clear your server/CDN cache and switch Safe Mode off from Tools, Optimazz re-checks and re-protects the site if anything is still broken — so an update can no longer leave a site visibly broken.
     104
    101105= 1.0.21 =
    102106* Fixed: after updating, a site whose page cache was already populated could keep serving pages that loaded unstyled, until the cache was purged by hand. A plugin update never clears the page cache, so any HTML cached by an earlier version — still pointing at combined CSS/JS files that an older purge had removed — stayed in place and rendered without styling. Optimazz now clears the page cache automatically once, the first time it runs after an update, and re-aligns its caching drop-in; the generated CSS/JS assets are kept, so pages come back fully styled on the next visit with no manual purge needed. This completes the 1.0.20 fix for existing installs.
  • optimazz/tags/1.0.22/uninstall.php

    r3692106 r3708055  
    9898if ( ! empty( $uploads['basedir'] ) ) {
    9999        $optimazz_rrmdir( trailingslashit( $uploads['basedir'] ) . 'optimazz-backup' );
     100        // Generated CSS now lives under uploads/optimazz (moved out of cache/).
     101        $optimazz_rrmdir( trailingslashit( $uploads['basedir'] ) . 'optimazz' );
    100102}
  • optimazz/trunk/includes/Admin/Admin.php

    r3692106 r3708055  
    206206                        return;
    207207                }
     208
     209                // Update safety guard — shown on every admin screen (including Optimazz's
     210                // own), because "your site was breaking and we protected it" is important
     211                // enough to surface wherever the admin happens to be.
     212                $guard = \Optimazz\Core\Guard::state();
     213                if ( $guard && isset( $guard['status'] ) ) {
     214                        $tools_url = admin_url( 'admin.php?page=' . self::MENU_SLUG . '&view=tools' );
     215                        if ( 'protected' === $guard['status'] ) {
     216                                echo '<div class="notice notice-warning"><p><strong>' . esc_html__( 'Optimazz Safe Mode is on.', 'optimazz' ) . '</strong> '
     217                                        . esc_html__( 'After the last update, some pages were loading without styling — their optimized CSS could not be found, usually because an external server or CDN cache was still serving old pages. Optimazz paused advanced CSS/JS optimization to keep your site working. Clear any server/CDN cache, then', 'optimazz' )
     218                                        . ' <a href="' . esc_url( $tools_url ) . '">' . esc_html__( 'open Tools to re-check and switch Safe Mode off', 'optimazz' ) . '</a>.</p></div>';
     219                        } elseif ( 'recovered' === $guard['status'] ) {
     220                                echo '<div class="notice notice-success is-dismissible"><p><strong>Optimazz:</strong> '
     221                                        . esc_html__( 'Your pages are loading correctly again — you can switch Safe Mode off in', 'optimazz' )
     222                                        . ' <a href="' . esc_url( $tools_url ) . '">' . esc_html__( 'Tools', 'optimazz' ) . '</a>.</p></div>';
     223                        }
     224                }
     225
    208226                // Never emit a WordPress notice on the Optimazz screen — the React app
    209227                // shows these as branded toasts. (Guards against notice relocation and
  • optimazz/trunk/includes/Admin/RestController.php

    r3692106 r3708055  
    289289                if ( $purged ) {
    290290                        Manager::storage()->purge_all();
     291                }
     292
     293                // If the admin is switching Safe Mode OFF, clear any guard notice but
     294                // schedule a fresh health check shortly after: if the generated CSS still
     295                // 404s (e.g. an external cache is not yet cleared), the guard re-protects
     296                // the site automatically instead of leaving it broken.
     297                $was_safe = ! empty( $before['tools']['safe_mode'] );
     298                $now_safe = ! empty( $saved['tools']['safe_mode'] );
     299                if ( $was_safe && ! $now_safe && class_exists( '\Optimazz\Core\Guard' ) ) {
     300                        \Optimazz\Core\Guard::clear();
     301                        \Optimazz\Core\Guard::schedule( 20 );
    291302                }
    292303
    … …  
    617628                $cache = $this->settings->for_module( 'cache' );
    618629
    619                 // Optimized CSS cache footprint.
    620                 $css_dir   = WP_CONTENT_DIR . '/cache/optimazz/css/';
     630                // Optimized CSS footprint (generated CSS lives under uploads/, not cache/).
     631                $uploads   = wp_upload_dir( null, false );
     632                $css_dir   = ( isset( $uploads['basedir'] ) ? trailingslashit( $uploads['basedir'] ) : trailingslashit( WP_CONTENT_DIR . '/uploads' ) ) . 'optimazz/css/';
    621633                $css_files = 0;
    622634                $css_bytes = 0;
  • optimazz/trunk/includes/Core/Lifecycle.php

    r3704576 r3708055  
    7878                \Optimazz\Modules\Cache\Manager::sync( $cache );
    7979                \Optimazz\Modules\Cache\Manager::storage()->purge_all();
     80
     81                // Schedule the safety self-check: shortly after the cache re-warms, Guard
     82                // verifies the front page's CSS actually loads and, if not, protects the
     83                // site by pausing the risky transforms (Safe Mode) automatically.
     84                if ( class_exists( '\Optimazz\Core\Guard' ) ) {
     85                        Guard::schedule();
     86                }
    8087        }
    8188
    … …  
    97104                wp_clear_scheduled_hook( 'optimazz_purge_expired' );
    98105                wp_clear_scheduled_hook( 'optimazz_db_cleanup' );
     106                wp_clear_scheduled_hook( 'optimazz_health_check' );
    99107        }
    100108}
  • optimazz/trunk/includes/Core/Plugin.php

    r3704576 r3708055  
    9191                $this->loader->boot();
    9292
     93                // Update safety guard — the scheduled self-check that auto-enables Safe
     94                // Mode if a post-update front page renders unstyled.
     95                Guard::register();
     96
    9397                // One-time reconciliation after a version change (update). Clears cached
    9498                // HTML left by an older version so pages never load unstyled post-update.
  • optimazz/trunk/includes/Modules/Css/CssModule.php

    r3692106 r3708055  
    2424
    2525        /**
    26          * Cache directory for generated CSS.
    27          *
    28          * @return string
     26         * Generated CSS lives under the uploads directory, NOT wp-content/cache/.
     27         *
     28         * These files are referenced by name in the page HTML, so they must be
     29         * served reliably and never wiped out from under a cached page. The
     30         * wp-content/cache/ directory fails both tests on many hosts: it is the
     31         * conventional "safe to delete" location that servers (LiteSpeed), hosts and
     32         * cleanup tools purge on their own, and some servers/WAFs don't serve static
     33         * files from it at all (returning 404 — which renders every page unstyled).
     34         * The uploads directory is always publicly served and is persistent, so the
     35         * generated stylesheets behave like any other asset (the same place page
     36         * builders write their generated CSS).
     37         *
     38         * @return string Filesystem path (with trailing slash).
    2939         */
    3040        private function cache_dir() {
    31                 return WP_CONTENT_DIR . '/cache/optimazz/css/';
    32         }
    33 
    34         /**
    35          * Public URL base for generated CSS.
    36          *
    37          * @return string
     41                $dirs = self::upload_dirs();
     42                return $dirs['basedir'] . 'optimazz/css/';
     43        }
     44
     45        /**
     46         * Public URL base for generated CSS (matches cache_dir()).
     47         *
     48         * @return string URL (with trailing slash).
    3849         */
    3950        private function cache_url() {
    40                 return content_url( '/cache/optimazz/css/' );
     51                $dirs = self::upload_dirs();
     52                return $dirs['baseurl'] . 'optimazz/css/';
     53        }
     54
     55        /**
     56         * Resolve (and memoize) the uploads base dir + URL. The URL is forced to the
     57         * request scheme so an https page never references an http stylesheet.
     58         *
     59         * @return array{basedir:string,baseurl:string}
     60         */
     61        private static function upload_dirs() {
     62                static $cache = null;
     63                if ( null === $cache ) {
     64                        $u       = wp_upload_dir( null, false );
     65                        $basedir = isset( $u['basedir'] ) ? trailingslashit( $u['basedir'] ) : trailingslashit( WP_CONTENT_DIR . '/uploads' );
     66                        $baseurl = isset( $u['baseurl'] ) ? trailingslashit( $u['baseurl'] ) : trailingslashit( content_url( '/uploads' ) );
     67                        if ( function_exists( 'set_url_scheme' ) ) {
     68                                $baseurl = set_url_scheme( $baseurl );
     69                        }
     70                        $cache = array(
     71                                'basedir' => $basedir,
     72                                'baseurl' => $baseurl,
     73                        );
     74                }
     75                return $cache;
    4176        }
    4277
    … …  
    527562                if ( ! is_dir( $dir ) ) {
    528563                        wp_mkdir_p( $dir );
     564                        // Prevent directory listing of the generated-CSS folder in uploads.
     565                        if ( is_dir( $dir ) && ! file_exists( $dir . 'index.html' ) ) {
     566                                @file_put_contents( $dir . 'index.html', '' ); // phpcs:ignore WordPress.WP.AlternativeFunctions,WordPress.PHP.NoSilencedErrors
     567                        }
    529568                }
    530569                $file = $dir . $key . '.css';
  • optimazz/trunk/optimazz.php

    r3704576 r3708055  
    44 * Plugin URI:        https://wordpress.org/plugins/optimazz/
    55 * Description:        All-in-one WordPress performance optimization — page caching, JS delay, and CSS optimization.
    6  * Version:           1.0.21
     6 * Version:           1.0.22
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
    … …  
    2626}
    2727
    28 define( 'OPTIMAZZ_VERSION', '1.0.21' );
     28define( 'OPTIMAZZ_VERSION', '1.0.22' );
    2929define( 'OPTIMAZZ_FILE', __FILE__ );
    3030define( 'OPTIMAZZ_DIR', plugin_dir_path( __FILE__ ) );
  • optimazz/trunk/optimazz.pot

    r3704576 r3708055  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Optimazz – Website Optimization and Speedup 1.0.21\n"
     5"Project-Id-Version: Optimazz – Website Optimization and Speedup 1.0.22\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/optimazz\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
  • optimazz/trunk/readme.txt

    r3704576 r3708055  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.21
     7Stable tag: 1.0.22
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    9999== Changelog ==
    100100
     101= 1.0.22 =
     102* Fixed: on some hosts (certain LiteSpeed/WAF setups and managed hosts) pages loaded unstyled because the server does not serve — or routinely deletes — files under `wp-content/cache/`, which is where Optimazz kept its generated CSS. Since the page HTML references those files by name, a page that could not load them rendered without styling. Optimazz now stores generated CSS under `wp-content/uploads/optimazz/` instead — the standard, always-served, persistent location page builders also use — so the stylesheets load reliably and are never wiped out from under a cached page. On update the page cache is refreshed automatically so pages pick up the new location with no manual step.
     103* New: update safety guard. Shortly after the plugin updates, Optimazz quietly checks its own front page to confirm the optimized CSS actually loads. If it finds pages rendering unstyled — their generated stylesheets returning 404, usually because an external server or CDN cache is still serving old pages — it automatically switches on Safe Mode to keep the site working (pausing the risky CSS/JS transforms without changing your saved settings, so pages fall back to their original stylesheets) and shows an admin notice explaining what happened. After you clear your server/CDN cache and switch Safe Mode off from Tools, Optimazz re-checks and re-protects the site if anything is still broken — so an update can no longer leave a site visibly broken.
     104
    101105= 1.0.21 =
    102106* Fixed: after updating, a site whose page cache was already populated could keep serving pages that loaded unstyled, until the cache was purged by hand. A plugin update never clears the page cache, so any HTML cached by an earlier version — still pointing at combined CSS/JS files that an older purge had removed — stayed in place and rendered without styling. Optimazz now clears the page cache automatically once, the first time it runs after an update, and re-aligns its caching drop-in; the generated CSS/JS assets are kept, so pages come back fully styled on the next visit with no manual purge needed. This completes the 1.0.20 fix for existing installs.
  • optimazz/trunk/uninstall.php

    r3692106 r3708055  
    9898if ( ! empty( $uploads['basedir'] ) ) {
    9999        $optimazz_rrmdir( trailingslashit( $uploads['basedir'] ) . 'optimazz-backup' );
     100        // Generated CSS now lives under uploads/optimazz (moved out of cache/).
     101        $optimazz_rrmdir( trailingslashit( $uploads['basedir'] ) . 'optimazz' );
    100102}
Note: See TracChangeset for help on using the changeset viewer.