Changeset 3708055
- Timestamp:
- 09/22/2026 08:30:39 PM (5 weeks ago)
- Location:
- optimazz
- Files:
-
- 2 added
- 18 edited
- 1 copied
-
tags/1.0.22 (copied) (copied from optimazz/trunk )
-
tags/1.0.22/includes/Admin/Admin.php (modified) (1 diff)
-
tags/1.0.22/includes/Admin/RestController.php (modified) (2 diffs)
-
tags/1.0.22/includes/Core/Guard.php (added)
-
tags/1.0.22/includes/Core/Lifecycle.php (modified) (2 diffs)
-
tags/1.0.22/includes/Core/Plugin.php (modified) (1 diff)
-
tags/1.0.22/includes/Modules/Css/CssModule.php (modified) (2 diffs)
-
tags/1.0.22/optimazz.php (modified) (2 diffs)
-
tags/1.0.22/optimazz.pot (modified) (1 diff)
-
tags/1.0.22/readme.txt (modified) (2 diffs)
-
tags/1.0.22/uninstall.php (modified) (1 diff)
-
trunk/includes/Admin/Admin.php (modified) (1 diff)
-
trunk/includes/Admin/RestController.php (modified) (2 diffs)
-
trunk/includes/Core/Guard.php (added)
-
trunk/includes/Core/Lifecycle.php (modified) (2 diffs)
-
trunk/includes/Core/Plugin.php (modified) (1 diff)
-
trunk/includes/Modules/Css/CssModule.php (modified) (2 diffs)
-
trunk/optimazz.php (modified) (2 diffs)
-
trunk/optimazz.pot (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
optimazz/tags/1.0.22/includes/Admin/Admin.php
r3692106 r3708055 206 206 return; 207 207 } 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 208 226 // Never emit a WordPress notice on the Optimazz screen — the React app 209 227 // shows these as branded toasts. (Guards against notice relocation and -
optimazz/tags/1.0.22/includes/Admin/RestController.php
r3692106 r3708055 289 289 if ( $purged ) { 290 290 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 ); 291 302 } 292 303 … … 617 628 $cache = $this->settings->for_module( 'cache' ); 618 629 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/'; 621 633 $css_files = 0; 622 634 $css_bytes = 0; -
optimazz/tags/1.0.22/includes/Core/Lifecycle.php
r3704576 r3708055 78 78 \Optimazz\Modules\Cache\Manager::sync( $cache ); 79 79 \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 } 80 87 } 81 88 … … 97 104 wp_clear_scheduled_hook( 'optimazz_purge_expired' ); 98 105 wp_clear_scheduled_hook( 'optimazz_db_cleanup' ); 106 wp_clear_scheduled_hook( 'optimazz_health_check' ); 99 107 } 100 108 } -
optimazz/tags/1.0.22/includes/Core/Plugin.php
r3704576 r3708055 91 91 $this->loader->boot(); 92 92 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 93 97 // One-time reconciliation after a version change (update). Clears cached 94 98 // 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 24 24 25 25 /** 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). 29 39 */ 30 40 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). 38 49 */ 39 50 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; 41 76 } 42 77 … … 527 562 if ( ! is_dir( $dir ) ) { 528 563 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 } 529 568 } 530 569 $file = $dir . $key . '.css'; -
optimazz/tags/1.0.22/optimazz.php
r3704576 r3708055 4 4 * Plugin URI: https://wordpress.org/plugins/optimazz/ 5 5 * Description: All-in-one WordPress performance optimization — page caching, JS delay, and CSS optimization. 6 * Version: 1.0.2 16 * Version: 1.0.22 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 26 26 } 27 27 28 define( 'OPTIMAZZ_VERSION', '1.0.2 1' );28 define( 'OPTIMAZZ_VERSION', '1.0.22' ); 29 29 define( 'OPTIMAZZ_FILE', __FILE__ ); 30 30 define( 'OPTIMAZZ_DIR', plugin_dir_path( __FILE__ ) ); -
optimazz/tags/1.0.22/optimazz.pot
r3704576 r3708055 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Optimazz – Website Optimization and Speedup 1.0.2 1\n"5 "Project-Id-Version: Optimazz – Website Optimization and Speedup 1.0.22\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/optimazz\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -
optimazz/tags/1.0.22/readme.txt
r3704576 r3708055 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.0.2 17 Stable tag: 1.0.22 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 99 99 == Changelog == 100 100 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 101 105 = 1.0.21 = 102 106 * 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 98 98 if ( ! empty( $uploads['basedir'] ) ) { 99 99 $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' ); 100 102 } -
optimazz/trunk/includes/Admin/Admin.php
r3692106 r3708055 206 206 return; 207 207 } 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 208 226 // Never emit a WordPress notice on the Optimazz screen — the React app 209 227 // shows these as branded toasts. (Guards against notice relocation and -
optimazz/trunk/includes/Admin/RestController.php
r3692106 r3708055 289 289 if ( $purged ) { 290 290 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 ); 291 302 } 292 303 … … 617 628 $cache = $this->settings->for_module( 'cache' ); 618 629 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/'; 621 633 $css_files = 0; 622 634 $css_bytes = 0; -
optimazz/trunk/includes/Core/Lifecycle.php
r3704576 r3708055 78 78 \Optimazz\Modules\Cache\Manager::sync( $cache ); 79 79 \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 } 80 87 } 81 88 … … 97 104 wp_clear_scheduled_hook( 'optimazz_purge_expired' ); 98 105 wp_clear_scheduled_hook( 'optimazz_db_cleanup' ); 106 wp_clear_scheduled_hook( 'optimazz_health_check' ); 99 107 } 100 108 } -
optimazz/trunk/includes/Core/Plugin.php
r3704576 r3708055 91 91 $this->loader->boot(); 92 92 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 93 97 // One-time reconciliation after a version change (update). Clears cached 94 98 // HTML left by an older version so pages never load unstyled post-update. -
optimazz/trunk/includes/Modules/Css/CssModule.php
r3692106 r3708055 24 24 25 25 /** 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). 29 39 */ 30 40 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). 38 49 */ 39 50 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; 41 76 } 42 77 … … 527 562 if ( ! is_dir( $dir ) ) { 528 563 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 } 529 568 } 530 569 $file = $dir . $key . '.css'; -
optimazz/trunk/optimazz.php
r3704576 r3708055 4 4 * Plugin URI: https://wordpress.org/plugins/optimazz/ 5 5 * Description: All-in-one WordPress performance optimization — page caching, JS delay, and CSS optimization. 6 * Version: 1.0.2 16 * Version: 1.0.22 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 26 26 } 27 27 28 define( 'OPTIMAZZ_VERSION', '1.0.2 1' );28 define( 'OPTIMAZZ_VERSION', '1.0.22' ); 29 29 define( 'OPTIMAZZ_FILE', __FILE__ ); 30 30 define( 'OPTIMAZZ_DIR', plugin_dir_path( __FILE__ ) ); -
optimazz/trunk/optimazz.pot
r3704576 r3708055 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Optimazz – Website Optimization and Speedup 1.0.2 1\n"5 "Project-Id-Version: Optimazz – Website Optimization and Speedup 1.0.22\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/optimazz\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -
optimazz/trunk/readme.txt
r3704576 r3708055 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 1.0.2 17 Stable tag: 1.0.22 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 99 99 == Changelog == 100 100 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 101 105 = 1.0.21 = 102 106 * 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 98 98 if ( ! empty( $uploads['basedir'] ) ) { 99 99 $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' ); 100 102 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)