From 39589da6c07fc25a9e9da72d50a1c1165d2c0469 Mon Sep 17 00:00:00 2001 From: Raam Dev Date: Tue, 8 Aug 2017 13:11:06 -0400 Subject: [PATCH] Phing release of v170808-RC with the following changes: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - **New Feature: Memcached / RAM** (Pro): Comet Cache Pro now includes support for Memcached / AWS ElastiCache to serve the cache directly from RAM. This allows for a faster cache delivery than what is possible when serving the cache via disk. Memcached / AWS ElastiCache can be configured from **Dashboard → Comet Cache Pro → Plugin Options → RAM / Memcached**. See [Issue #47](https://github.com/websharks/comet-cache/issues/47) - **Enhancement**: Added `Referrer-Policy` to whitelist for cachable HTTP headers. See [Issue #892](https://github.com/websharks/comet-cache/issues/892). - **Bug Fix** (Pro): The Cache Statistics feature was broken when the PHP `disk_total_space()` and/or `disk_free_space()` functions were disabled by the PHP configuration. Comet Cache now handles this scenario gracefully by hiding disk-related stats when those functions are not allowed. See [Issue #775](https://github.com/websharks/comet-cache/issues/775) - **Bug Fix** (Pro): The HTML Compressor was returning an empty string upon encountering an invalid UTF-8 sequence. See [Issue #871](https://github.com/websharks/comet-cache/issues/871) reported by a Comet Cache user. - **Compatibility** (Pro): Many improvements to the Pro software update system, including changes to the API Endpoints and the Proxy Fallback endpoint. See [Issue #879](https://github.com/websharks/comet-cache/issues/879) and [Issue #315](https://github.com/websharks/comet-cache-pro/pull/315) for full details. - **Compatibility**: Fixed a WooCommerce compatibility issue that was generating a "Notice: id was called incorrectly. Product properties should not be accessed directly." Props @vestaxpdx. See [Issue #896](https://github.com/websharks/comet-cache/issues/896). --- .gitattributes | 185 +-- .gitchange | 7 +- .gitignore | 61 +- CHANGELOG.md | 11 +- comet-cache.php | 2 +- composer.json | 32 +- composer.lock | 4 +- readme.txt | 117 +- src/includes/classes/AdvCacheBackCompat.php | 72 +- src/includes/classes/AdvancedCache.php | 1 + src/includes/classes/MenuPage.php | 14 +- .../MenuPage/Options/ApacheOptimizations.php | 123 ++ .../MenuPage/Options/AutoCacheEngine.php | 75 + .../MenuPage/Options/AutomaticClearing.php | 143 ++ .../classes/MenuPage/Options/ClientSide.php | 54 + .../classes/MenuPage/Options/Developers.php | 40 + .../classes/MenuPage/Options/Directory.php | 36 + .../classes/MenuPage/Options/Enable.php | 47 + .../classes/MenuPage/Options/Expiration.php | 68 + .../classes/MenuPage/Options/FeedRequests.php | 41 + .../classes/MenuPage/Options/GetRequests.php | 53 + .../classes/MenuPage/Options/Heading.php | 95 ++ .../MenuPage/Options/HostExclusions.php | 45 + .../MenuPage/Options/HtmlCompressor.php | 104 ++ .../classes/MenuPage/Options/ImportExport.php | 45 + .../MenuPage/Options/ManualClearing.php | 95 ++ .../classes/MenuPage/Options/Memcached.php | 51 + .../classes/MenuPage/Options/MobileMode.php | 66 + .../MenuPage/Options/Nf404Requests.php | 42 + .../classes/MenuPage/Options/Notices.php | 102 ++ .../classes/MenuPage/Options/ProUpdater.php | 67 + .../MenuPage/Options/RefererExclusions.php | 38 + .../classes/MenuPage/Options/Safeguards.php | 40 + .../MenuPage/Options/StaticCdnFilters.php | 123 ++ .../classes/MenuPage/Options/Statistics.php | 70 + .../MenuPage/Options/UriExclusions.php | 42 + .../MenuPage/Options/UserAgentExclusions.php | 38 + .../classes/MenuPage/Options/UserRequests.php | 79 + .../classes/MenuPage/Options/VersionSalt.php | 48 + src/includes/classes/MenuPageOptions.php | 1288 +---------------- src/includes/classes/Plugin.php | 9 + .../interfaces/Shared/WcpEventConsts.php | 248 ++++ src/includes/stub.php | 8 +- src/includes/templates/advanced-cache.x-php | 2 + src/includes/traits/Ac/CacheIoUtils.php | 167 +++ src/includes/traits/Ac/ObUtils.php | 328 ++--- src/includes/traits/Ac/PostloadUtils.php | 1 - .../traits/Plugin/WcpWooCommerceUtils.php | 2 +- src/includes/traits/Shared/CacheDirUtils.php | 21 +- src/includes/traits/Shared/FsUtils.php | 9 +- src/includes/traits/Shared/HttpUtils.php | 3 +- 51 files changed, 2640 insertions(+), 1822 deletions(-) create mode 100644 src/includes/classes/MenuPage/Options/ApacheOptimizations.php create mode 100644 src/includes/classes/MenuPage/Options/AutoCacheEngine.php create mode 100644 src/includes/classes/MenuPage/Options/AutomaticClearing.php create mode 100644 src/includes/classes/MenuPage/Options/ClientSide.php create mode 100644 src/includes/classes/MenuPage/Options/Developers.php create mode 100644 src/includes/classes/MenuPage/Options/Directory.php create mode 100644 src/includes/classes/MenuPage/Options/Enable.php create mode 100644 src/includes/classes/MenuPage/Options/Expiration.php create mode 100644 src/includes/classes/MenuPage/Options/FeedRequests.php create mode 100644 src/includes/classes/MenuPage/Options/GetRequests.php create mode 100644 src/includes/classes/MenuPage/Options/Heading.php create mode 100644 src/includes/classes/MenuPage/Options/HostExclusions.php create mode 100644 src/includes/classes/MenuPage/Options/HtmlCompressor.php create mode 100644 src/includes/classes/MenuPage/Options/ImportExport.php create mode 100644 src/includes/classes/MenuPage/Options/ManualClearing.php create mode 100644 src/includes/classes/MenuPage/Options/Memcached.php create mode 100644 src/includes/classes/MenuPage/Options/MobileMode.php create mode 100644 src/includes/classes/MenuPage/Options/Nf404Requests.php create mode 100644 src/includes/classes/MenuPage/Options/Notices.php create mode 100644 src/includes/classes/MenuPage/Options/ProUpdater.php create mode 100644 src/includes/classes/MenuPage/Options/RefererExclusions.php create mode 100644 src/includes/classes/MenuPage/Options/Safeguards.php create mode 100644 src/includes/classes/MenuPage/Options/StaticCdnFilters.php create mode 100644 src/includes/classes/MenuPage/Options/Statistics.php create mode 100644 src/includes/classes/MenuPage/Options/UriExclusions.php create mode 100644 src/includes/classes/MenuPage/Options/UserAgentExclusions.php create mode 100644 src/includes/classes/MenuPage/Options/UserRequests.php create mode 100644 src/includes/classes/MenuPage/Options/VersionSalt.php create mode 100644 src/includes/interfaces/Shared/WcpEventConsts.php create mode 100644 src/includes/traits/Ac/CacheIoUtils.php diff --git a/.gitattributes b/.gitattributes index f208fb7..a8422be 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,5 @@ +# Text/Binary ---------------------------------------------------------------------------------------------------------- + # Default * text=auto @@ -14,6 +16,7 @@ # YAML *.yml +*.yaml # Properties. @@ -44,13 +47,23 @@ *.htpasswd text *.ini text -# CSS/JS +# CSS *.css text -*.js text +*.sass text +*.scss text +*.less text *.css.map text -*.js.map text + +# JavaScript + +*.js text +*.ts text +*.jsx text +*.tsx text *.json text +*.json5 text +*.js.map text # Applescript @@ -94,6 +107,7 @@ # Documents *.csv text +*.tsv text *.doc binary *.docx binary *.odt binary @@ -112,6 +126,7 @@ *.jpeg binary *.jpg binary *.png binary +*.webp binary *.psd binary *.svg text *.tif binary @@ -174,17 +189,16 @@ *.dll binary *.exe binary *.sh text +*.pem text *.so binary -# Export Ignore -------------------------------------------------------------------------------------------------------- -# This follows `.gitignore` almost exactly. - -# NOTE: `/**` does not exclude the directory itself like in Phing. -# Use only a trailing `/` to achieve that here. +# Export Ignore — this follows `.gitignore` almost exactly. ------------------------------------------------------------ +# The only exceptions are that we don't ignore `node_modules/`, `bower_components/` or `vendor/`. # Local .~* export-ignore +._* export-ignore # Logs @@ -195,18 +209,13 @@ *~ export-ignore *.bak export-ignore -# Vendor -# NOT excluded here. - -# vendor/ export-ignore +# Vagrant -# Node +.vagrant/ export-ignore -node_modules/ export-ignore +# TypeScript -# SASS - -.sass-cache/ export-ignore +typings/ export-ignore # IntelliJ @@ -214,13 +223,21 @@ node_modules/ export-ignore # Sublime -*.sublime-workspace export-ignore *.sublime-project export-ignore +*.sublime-workspace export-ignore -# CTags +# SASS + +.sass-cache/ export-ignore + +# Elastic Beanstalk + +.elasticbeanstalk/ export-ignore + +# CTAGs -*.tags export-ignore *.ctags export-ignore +*.tags export-ignore # VCS @@ -268,138 +285,18 @@ Icon? export-ignore Icons -export-ignore ._* export-ignore -# AWS - -.elasticbeanstalk/ export-ignore - -# Vagrant - -.vagrant/ export-ignore - -# Export Ignore (More) ------------------------------------------------------------------------------------------------- -# These are in addition to what we have in `.gitignore`. - -# SASS - -*.scss export-ignore -*.css.map export-ignore - -/src/client-s/**/bourbon/ export-ignore -/src/vendor/websharks/*/src/client-s/**/bourbon/ export-ignore - -# Git - -/.gitignore export-ignore -/src/vendor/*/*/.gitignore export-ignore - -/.gitattributes export-ignore -/src/vendor/*/*/.gitattributes export-ignore - -/.gitmodules export-ignore -/src/vendor/*/*/.gitmodules export-ignore - -/.gitchange export-ignore -/src/vendor/websharks/*/.gitchange export-ignore - -# GitHub - -/.github/ export-ignore -/src/vendor/*/*/.github/ export-ignore - -/CONTRIBUTING.md export-ignore -/src/vendor/*/*/CONTRIBUTING.md export-ignore - -/ISSUE_TEMPLATE.md export-ignore -/src/vendor/*/*/ISSUE_TEMPLATE.md export-ignore - -/PULL_REQUEST_TEMPLATE.md export-ignore -/src/vendor/*/*/PULL_REQUEST_TEMPLATE.md export-ignore +# Export Ignore — in addition to what we have in `.gitignore`. --------------------------------------------------------- # Assets /assets/ export-ignore -/src/vendor/websharks/*/assets/ export-ignore - -# Build Files - -/phings/ export-ignore -/src/vendor/*/*/phing/ export-ignore -/src/vendor/*/*/phings/ export-ignore - -/.build.props export-ignore -/src/vendor/*/*/.build.props export-ignore - -/build.xml export-ignore -/src/vendor/*/*/build.xml export-ignore - -/build-*.xml export-ignore -/src/vendor/*/*/build-*.xml export-ignore - -# Dot Build Files - -/.build.php export-ignore -/src/vendor/websharks/*/.build.php export-ignore - -/.build.*.php export-ignore -/src/vendor/websharks/*/.build.*.php export-ignore - -/src/.build.php export-ignore -/src/vendor/websharks/*/src/.build.php export-ignore - -/src/.build.*.php export-ignore -/src/vendor/websharks/*/src/.build.*.php export-ignore - -/src/client-s/**/.build.php export-ignore -/src/vendor/websharks/*/src/client-s/**/.build.php export-ignore - -/src/client-s/**/.build.*.php export-ignore -/src/vendor/websharks/*/src/client-s/**/.build.*.php export-ignore - -/src/includes/**/.build.php export-ignore -/src/vendor/websharks/*/src/includes/**/.build.php export-ignore - -/src/includes/**/.build.*.php export-ignore -/src/vendor/websharks/*/src/includes/**/.build.*.php export-ignore - -# Tests - -/tests/ export-ignore -/src/vendor/*/*/test/ export-ignore -/src/vendor/*/*/tests/ export-ignore - -# Drone - -/.drone.* export-ignore -/src/vendor/*/*/.drone.* export-ignore - -# Travis - -/.travis.* export-ignore -/src/vendor/*/*/.travis.* export-ignore - -# Coverage - -/.coveralls.* export-ignore -/src/vendor/*/*/.coveralls.* export-ignore - -/.scrutinizer.* export-ignore -/src/vendor/*/*/.scrutinizer.* export-ignore - -# Post-Receive - -/post-receive export-ignore -/src/vendor/websharks/*/post-receive export-ignore - -# PHAR Stub - -/src/includes/phar-stub.php export-ignore -/src/vendor/websharks/*/src/includes/phar-stub.php export-ignore # LFS Storage (Assets) ------------------------------------------------------------------------------------------------- -# NOTE: Here we need to match all assets explictly; i.e., requires `/**` /assets/** filter=lfs diff=lfs merge=lfs -text # ---------------------------------------------------------------------------------------------------------------------- -# Custom code reinserted here via [custom] marker. Add your comment markers here please. +# +# Put your rules in custom comment markers. +# diff --git a/.gitchange b/.gitchange index 455151c..2cd489e 100644 --- a/.gitchange +++ b/.gitchange @@ -1,4 +1,3 @@ -1460135613 -49dd4154d8f5d3b70691c8e3f52a063a49137fb7:57be33556df067.43016776 -853d9120b42cf4f2eabe2f35ea18a6ace7170ea6:588bb5682f4739.12912408 -d0e05c36184f81b133761b71ca6ee0136be67409:58ab78802b0522.43963767 +1491589996 +2ea258a033ce686450ef6bccbc0f66efdba74ac1:58ffb9673670b6.69941207 +d0e05c36184f81b133761b71ca6ee0136be67409:5989f0aa6ba0d1.65531153 diff --git a/.gitignore b/.gitignore index 4751655..87c4980 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,9 @@ -# NOTE: It is not absolutely required (but highly recommended) that you have: `ignorecase = true` -# in your `.gitconfig` file to maximize compatibility with some of these exclusion patterns. - -# NOTE: `/**` does not exclude the directory itself like in Phing. -# Use only a trailing `/` to achieve that here. +# Ignore --------------------------------------------------------------------------------------------------------------- # Local .~* +._* # Logs @@ -17,31 +14,47 @@ *~ *.bak +# Vagrant + +.vagrant/ + +# TypeScript + +typings/ + +# IntelliJ + +.idea/ + +# Sublime + +*.sublime-project +*.sublime-workspace + # Vendor vendor/ -# Node +# NodeJS node_modules/ -# SASS +# Bower -.sass-cache/ +bower_components/ -# IntelliJ +# SASS -.idea/ +.sass-cache/ -# Sublime +# Elastic Beanstalk -*.sublime-workspace -*.sublime-project +.elasticbeanstalk/ -# CTags +# CTAGs -*.tags *.ctags +*.tags # VCS @@ -89,18 +102,8 @@ Icon? !Icons ._* -# AWS - -.elasticbeanstalk/ - -# Vagrant - -.vagrant/ - -# For shell glob patterns. This includes Git files too. We simply maintain this list together with `.gitignore`. -# *~;*.log;*.bak;node_modules;.idea;*.sublime-workspace;*.sublime-project;.git;.gitignore;.gitattributes;.gitmodules;.gitchange;.svn;_svn;CVS;.cvsignore;.bzr;.bzrignore;.hg;.hgignore;SCCS;RCS;$RECYCLE.BIN;Desktop.ini;Thumbs.db;ehthumbs.db;.AppleDB;.AppleDouble;.AppleDesktop;.com.apple.timemachine.donotpresent;Network Trash Folder;Temporary Items;.LSOverride;.Spotlight-V100;.VolumeIcon.icns;.TemporaryItems;.fseventsdv.DS_Store;.Trashes;.apdisk;._*;.elasticbeanstalk;.vagrant - -# This list is for IntelliJ IDEA / PhpStorm `File Types` configuration. Some files we actually WANT to work with as part of a project. -# .sass-cache;.idea;*.sublime-workspace;*.sublime-project;.git;.svn;_svn;CVS;.bzr;.hg;SCCS;RCS;$RECYCLE.BIN;Desktop.ini;Thumbs.db;ehthumbs.db;.AppleDB;.AppleDouble;.AppleDesktop;.com.apple.timemachine.donotpresent;Network Trash Folder;Temporary Items;.LSOverride;.Spotlight-V100;.VolumeIcon.icns;.TemporaryItems;.fseventsdv.DS_Store;.Trashes;.apdisk;._*;.vagrant +# ---------------------------------------------------------------------------------------------------------------------- -# Custom code reinserted here via [custom] marker. Add your comment markers here please. +# +# Put your rules in custom comment markers. +# diff --git a/CHANGELOG.md b/CHANGELOG.md index 9765412..aaff6e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ += v170808-RC = + +- **New Feature: Memcached / RAM** (Pro): Comet Cache Pro now includes support for Memcached / AWS ElastiCache to serve the cache directly from RAM. This allows for a faster cache delivery than what is possible when serving the cache via disk. Memcached / AWS ElastiCache can be configured from **Dashboard → Comet Cache Pro → Plugin Options → RAM / Memcached**. See [Issue #47](https://github.com/websharks/comet-cache/issues/47) +- **Enhancement**: Added `Referrer-Policy` to whitelist for cachable HTTP headers. See [Issue #892](https://github.com/websharks/comet-cache/issues/892). +- **Bug Fix** (Pro): The Cache Statistics feature was broken when the PHP `disk_total_space()` and/or `disk_free_space()` functions were disabled by the PHP configuration. Comet Cache now handles this scenario gracefully by hiding disk-related stats when those functions are not allowed. See [Issue #775](https://github.com/websharks/comet-cache/issues/775) +- **Bug Fix** (Pro): The HTML Compressor was returning an empty string upon encountering an invalid UTF-8 sequence. See [Issue #871](https://github.com/websharks/comet-cache/issues/871) reported by a Comet Cache user. +- **Compatibility** (Pro): Many improvements to the Pro software update system, including changes to the API Endpoints and the Proxy Fallback endpoint. See [Issue #879](https://github.com/websharks/comet-cache/issues/879) and [Issue #315](https://github.com/websharks/comet-cache-pro/pull/315) for full details. +- **Compatibility**: Fixed a WooCommerce compatibility issue that was generating a "Notice: id was called incorrectly. Product properties should not be accessed directly." Props @vestaxpdx. See [Issue #896](https://github.com/websharks/comet-cache/issues/896). + = v170220 = - **New Feature:** Comet Cache can now be configured to automatically clear the cache for date-based archive views whenever any single post is cleared due to changes in content, title, etc. See: **Dashboard → Comet Cache → Plugin Options → Automatic Cache Clearing → Auto-Clear "Date-Based Archives" Too?**. See also: [Issue #724](https://github.com/websharks/comet-cache/issues/724). @@ -5,7 +14,7 @@ - **Bug Fix:** Apache detection sometimes inaccurate. So instead of using default WP core globals for server detection, Comet Cache now uses it's own set of Apache/Nginx/IIS detection functions. And, this release enhances our Apache and Nginx detection routines; making them smart enough to catch additional edge cases; i.e., to further reduce the likelihood of there being a false-positive. See [Issue #748](https://github.com/websharks/comet-cache/issues/748). - **Bug Fix:** Some XML-RPC and REST API requests were being cached inadvertently. See [Issue #855](https://github.com/websharks/comet-cache/issues/855). - **Bug Fix:** Broken textarea field due to `white-space:nowrap` in Firefox. See [Issue #866](https://github.com/websharks/comet-cache/issues/866). -- **Bug Fix:** This release resolves empty directories being left in the cache folder, in some scenarios. See [Thread #866](https://forums.wpsharks.com/t/cache-folders-not-removed-during-clean-up-process/866). +- **Bug Fix:** This release resolves empty directories being left in the cache folder, in some scenarios. See [Issue #868](https://github.com/websharks/comet-cache/issues/868) and [Thread #866](https://forums.wpsharks.com/t/cache-folders-not-removed-during-clean-up-process/866). - **Bug Fix** (Pro): Some REST requests were being redirected incorrectly whenever Apache Optimizations were enabled. See [Issue #855](https://github.com/websharks/comet-cache/issues/855). - **Compatibility Bug Fix:** Some Jetpack API calls were being cached inadvertently. See [Issue #855](https://github.com/websharks/comet-cache/issues/855). - **Enhancement:** Notes in HTML source now indicate fully functional on first load for improved clarity. See [Issue #860](https://github.com/websharks/comet-cache/issues/860). diff --git a/comet-cache.php b/comet-cache.php index fe53205..8d3852b 100644 --- a/comet-cache.php +++ b/comet-cache.php @@ -1,6 +1,6 @@ =5.4", - "websharks/wp-php-rv": "160824.6416", - "websharks/sharkicons": "160221" + "websharks/sharkicons": "160221", + "websharks/wp-php-rv": "160824.6416" }, "require-dev": { "package/bourbon": "4.2.3", "websharks/wp-i18n-tools": "dev-master" }, - "minimum-stability": "dev", - "prefer-stable": true, "autoload": { "psr-4": { @@ -51,6 +53,8 @@ "vendor-dir": "src/vendor", "preferred-install": "dist" }, + "minimum-stability": "dev", + "prefer-stable": true, "repositories": [{ "type": "package", diff --git a/composer.lock b/composer.lock index e367221..ae2ef64 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "d3a2752db4632ed86095a52bafb51993", - "content-hash": "32c7193a6b217ec3955e3a3cf9d1c800", + "hash": "c99b8a8fa1edbfaa42aea5fc1a5dadb8", + "content-hash": "00db94e4f823f342be06a1a6942a80e0", "packages": [ { "name": "websharks/sharkicons", diff --git a/readme.txt b/readme.txt index df7e029..fdfcadc 100644 --- a/readme.txt +++ b/readme.txt @@ -1,8 +1,8 @@ === Comet Cache === -Stable tag: 170220 +Stable tag: 170808-RC Requires at least: 4.2 -Tested up to: 4.8-alpha +Tested up to: 4.9-alpha Text Domain: comet-cache License: GPLv2 or later @@ -16,7 +16,7 @@ Comet Cache is an advanced WordPress caching plugin inspired by simplicity. Spee == Description == -If you care about the speed of your site, Comet Cache is one of those plugins that you absolutely MUST have installed :-) Comet Cache takes a real-time snapshot (building a cache) of every Page, Post, Category, Link, etc. These snapshots are then stored (cached) intuitively, so they can be referenced later, in order to save all of that processing time that has been dragging your site down and costing you money. +If you care about the speed of your site, Comet Cache is one of those plugins that you absolutely MUST have installed. :-) Comet Cache takes a real-time snapshot (building a cache) of every Page, Post, Category, Link, etc. These snapshots are then stored (cached) intuitively, so they can be referenced later, in order to save all of that processing time that has been dragging your site down and costing you money. The Comet Cache plugin uses configuration options that you select from the options panel. See: **Comet Cache -› Options** in your Dashboard. Once a file has been cached, Comet Cache uses advanced techniques that allow it to recognize when it should and should not serve a cached version of the file. By default, Comet Cache does not serve cached pages to users who are logged in, or to users who have left comments recently. Comet Cache also excludes administrative pages, login pages, POST/PUT/DELETE/GET(w/ query string) requests and/or CLI processes. @@ -85,7 +85,7 @@ TIP: you can preview Pro features in the free version by clicking the "Preview P == Installation == -**Quick Tip:** WordPress® can only deal with one cache plugin being activated at a time. Please uninstall any existing cache plugins that you've tried in the past. In other words, if you've installed W3 Total Cache, WP Super Cache, DB Cache Reloaded, or any other caching plugin, uninstall them all before installing Comet Cache. One way to check, is to make sure this file: `wp-content/advanced-cache.php` and/or `wp-content/object-cache.php` are NOT present; and if they are, delete these files BEFORE installing Comet Cache. Those files will only be present if you have a caching plugin already installed. If you don't see them, you're ready to install Comet Cache :-). +**Quick Tip:** WordPress® can only deal with one cache plugin being activated at a time. Please uninstall any existing cache plugins that you've tried in the past. In other words, if you've installed W3 Total Cache, WP Super Cache, DB Cache Reloaded, or any other caching plugin, uninstall them all before installing Comet Cache. One way to check, is to make sure this file: `wp-content/advanced-cache.php` and/or `wp-content/object-cache.php` are NOT present; and if they are, delete these files BEFORE installing Comet Cache. Those files will only be present if you have a caching plugin already installed. If you've previously installed another caching plugin, you may also want to review your `.htaccess` file to make sure there are no rewrite rules related to the old caching plugin—some caching plugins don't completely clean up after themselves when uninstalled. If you don't see anything related to the old caching plugin, you're ready to install Comet Cache. :-) **A note for existing ZenCache users:** Comet Cache is the successor to ZenCache and will automatically detect any existing ZenCache options and migrate that options over to Comet Cache. For further details, please see the [migration FAQ](https://cometcache.com/r/zencache-migration-faq/). @@ -99,7 +99,7 @@ TIP: you can preview Pro features in the free version by clicking the "Preview P First of all, make sure that you've enabled Comet Cache. After you activate the plugin in WordPress, go to the Comet Cache options panel and enable caching (you can't miss the big yellow checkbox). Then scroll to the bottom and click Save All Changes. All of the other options on that page are already pre-configured for typical usage. Skip them all for now. You can go back through all of these later and fine-tune things the way you like them. -Once Comet Cache has been enabled, **you'll need to log out** (and/or clear browser cookies). Cache files are NOT served to visitors who are logged in, and that includes you too :-) Cache files are NOT served to recent commenters either. If you've commented (or replied to a comment lately); please clear your browser cookies before testing. +Once Comet Cache has been enabled, **you'll need to log out** (and/or clear browser cookies). Cache files are NOT served to visitors who are logged in, and that includes you too. :-) Cache files are NOT served to recent commenters either. If you've commented (or replied to a comment lately); please clear your browser cookies before testing. **To verify that Comet Cache is working**, navigate your site like a normal visitor would. Right-click on any page (choose View Source), then scroll to the very bottom of the document. At the bottom, you'll find comments that show Comet Cache stats and information. You should also notice that page-to-page navigation is lightning fast compared to what you experienced prior to installing Comet Cache. @@ -116,19 +116,15 @@ Ordinarily you can just deactivate Comet Cache from the plugins menu in WordPres 3. Delete this directory: `/wp-content/plugins/comet-cache/` 4. Remove this line from your `/wp-config.php` file: `define('WP_CACHE', TRUE);` -Comet Cache is now completely uninstalled and you can start fresh :-) +Comet Cache is now completely uninstalled and you can start fresh. :-) == Frequently Asked Questions == -= I already have ZenCache installed; how do I install Comet Cache? = - -Comet Cache is the successor to ZenCache and will automatically detect any existing ZenCache options and migrate those options over to Comet Cache. For further details, please see the [migration FAQ](https://cometcache.com/r/zencache-migration-faq/). - -= How do I know that Comet Cache is working the way it should be? = += How do I know that Comet Cache is working? = First of all, make sure that you've enabled Comet Cache. After you activate the plugin, go to the Comet Cache options panel and enable it, then scroll to the bottom and click Save All Changes. All of the other options on that page are already pre-configured for typical usage. Skip them all for now. You can go back through all of them later and fine-tune things the way you like them. -Once Comet Cache has been enabled, **you'll need to log out** (and/or clear browser cookies). Cache files are NOT served to visitors who are logged in, and that includes you too :-) Cache files are NOT served to recent commenters either. If you've commented (or replied to a comment lately); please clear your browser cookies before testing. +Once Comet Cache has been enabled, **you'll need to log out** (and/or clear browser cookies). Cache files are NOT served to visitors who are logged in, and that includes you too. :-) Cache files are NOT served to recent commenters either. If you've commented (or replied to a comment lately); please clear your browser cookies before testing. **To verify that Comet Cache is working**, navigate your site like a normal visitor would. Right-click on any page (choose View Source), then scroll to the very bottom of the document. At the bottom, you'll find comments that show Comet Cache stats and information. You should also notice that page-to-page navigation is lightning fast compared to what you experienced prior to installing Comet Cache. @@ -179,6 +175,8 @@ If your installation of Apache does not have `mod_deflate` installed. You can al = I'm a plugin developer. How can I prevent certain files from being cached? = +You can conditionally set the `COMET_CACHE_ALLOWED` PHP constant to `FALSE` to tell Comet Cache not to cache a given page. Comet Cache also supports the industry standard `DONOTCACHEPAGE` constant that all other WordPress caching plugins support. + Comet Cache -> Apache Optimizations -> Enable GZIP Compression?**; or to enable GZIP compression manually create an `.htaccess` file in your WordPress® installation directory (or edit the one that's already there) and put the following few lines in it. That is all there is to it. GZIP is now enabled! - - - - AddOutputFilterByType DEFLATE text/plain text/html - AddOutputFilterByType DEFLATE text/xml application/xml application/xhtml+xml application/xml-dtd - AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml image/svg+xml - AddOutputFilterByType DEFLATE text/css text/javascript application/javascript application/x-javascript - AddOutputFilterByType DEFLATE font/otf font/opentype application/font-otf application/x-font-otf - AddOutputFilterByType DEFLATE font/ttf font/truetype application/font-ttf application/x-font-ttf - - - -If your installation of Apache does not have `mod_deflate` installed. You can also enable GZIP compression using PHP configuration alone. In your `php.ini` file, you can simply add the following line anywhere: `zlib.output_compression = on` - -= EMERGENCY: If All Else Fails (How-To Remove Comet Cache) = - -Ordinarily you can just deactivate Comet Cache from the plugins menu in WordPress. However, if you're having a more serious issue, please follow the instructions here. - -1. Log into your site via FTP; perhaps using [FileZilla](http://www.youtube.com/watch?v=joXUMhr8PhU). -2. Delete this file: `/wp-content/advanced-cache.php` -3. Delete this directory: `/wp-content/plugins/comet-cache/` -4. Remove this line from your `/wp-config.php` file: `define('WP_CACHE', TRUE);` - -Comet Cache is now completely uninstalled and you can start fresh :-) - -== Pro Features == - -= Comet Cache Pro Features = - -- The ability to cache logged-in users too! (VERY powerful, particularly for membership sites). -- A new improved "Clear Cache" button in the admin bar (along with an option to enable/disable this feature). -- Options for Automatic and Intelligent Cache Clearing of Posts, Pages, Custom Post Types, Categories, Tags, Links, Themes, Users, and more. -- The ability to disable Dashboard notifications related to automatic clearing/purging on change detections. -- The ability to clear Markdown-related cache files generated by the s2Clean theme for WordPress (if installed). -- The ability to run custom PHP code whenever the cache is cleared. -- The ability to Auto-Clear a List of Custom URLs. -- Clear Cache User Permissions to give other users permission to clear the cache by specifying a list of Roles and/or Capabilities. -- Cache Statistics to help you gain insight into the status of your site cache. -- Import/Export functionality for Comet Cache configuration files. -- A Dynamic Version Salt (customize the caching engine). -- Multisite Host Exclusion Patterns to exclude specific child blogs from being cached in a Multisite Network. -- Mobile Mode that supports creating multiple versions of the cache for sites with adaptive designs. -- HTML Compressor to automatically combine and compresses CSS/JS/HTML code. -- Auto-Cache Engine to pre-cache your site at 15-minute intervals. -- Static CDN Filters to serve some and/or ALL static files on your site from a CDN of your choosing, including support for Multiple CDN Host Names, Domain Sharding, and WordPress Multisite Networks. -- Domain Sharding / Multiple CDN Hosts to work around concurrency limits and make it possible for browsers to download more resources simultaneously. -- Server Load Monitoring to avoid regenerating the cache while the server is very busy by specifying a maximum server load average. -- Cache Statistics and Charts to analyze statistics about the page cache, HTML Compressor cache, PHP OPCache, and server health. -- Apache Optimizations to enable web server GZIP Compression, Leverage Browser Caching, Enforce Canonical URLs, and more. -- An Automatic Updater to update Comet Cache Pro from your WordPress Dashboard. -- Rockstar support for all Comet Cache features. - -**TIP:** you can preview Pro features in the free version by clicking the "**Preview Pro Features**" link at the top of your Comet Cache options. - -== Pro Installation == - -Comet Cache Pro is a wholly contained plugin that _does not_ require Comet Cache Lite to be installed. To install Comet Cache Pro, - -1. Deactivate and delete Comet Cache Lite, if it is currently installed -1. Download Comet Cache Pro from your account at CometCache.com -1. From your WordPress Dashboard, go to **Dashboard -> Plugins -> Add New** and then click on the **Upload Plugin** button at the top -1. Select the Comet Cache Pro zip file you downloaded in step 2 and click "Install Now" -1. After the plugin finishes installing, click the "Activate Plugin" link - -Once the plugin is active, you can go to **Dashboard -> Comet Cache -> Plugin Options -> Enable/Disable** and Enable Comet Cache. - -Also, to stay updated with the latest version of Comet Cache Pro, be sure to also configure **Dashboard -> Comet Cache -> Plugin Updater**. +WordPress® Multisite Networking is a special consideration in WordPress®. If Comet Cache is installed under a Multisite Network installation, it will be enabled for ALL blogs the same way. The centralized config options for Comet Cache can only be modified by a Super Administrator operating on the main site. Comet Cache has internal processing routines that prevent configuration changes, including menu displays; for anyone other than a Super Administrator operating on the main site. == Software Requirements == @@ -313,7 +242,7 @@ In addition to the [WordPress Requirements](http://wordpress.org/about/requireme == License == -Copyright: © 2016 [WebSharks, Inc.](http://www.websharks-inc.com/bizdev/) (coded in the USA) +Copyright: © 2017 [WebSharks, Inc.](http://www.websharks-inc.com/bizdev/) (coded in the USA) Released under the terms of the [GNU General Public License](http://www.gnu.org/licenses/gpl-2.0.html). @@ -347,7 +276,7 @@ Requires WordPress v4.2+. - **Bug Fix:** Apache detection sometimes inaccurate. So instead of using default WP core globals for server detection, Comet Cache now uses it's own set of Apache/Nginx/IIS detection functions. And, this release enhances our Apache and Nginx detection routines; making them smart enough to catch additional edge cases; i.e., to further reduce the likelihood of there being a false-positive. See [Issue #748](https://github.com/websharks/comet-cache/issues/748). - **Bug Fix:** Some XML-RPC and REST API requests were being cached inadvertently. See [Issue #855](https://github.com/websharks/comet-cache/issues/855). - **Bug Fix:** Broken textarea field due to `white-space:nowrap` in Firefox. See [Issue #866](https://github.com/websharks/comet-cache/issues/866). -- **Bug Fix:** This release resolves empty directories being left in the cache folder, in some scenarios. See [Thread #866](https://forums.wpsharks.com/t/cache-folders-not-removed-during-clean-up-process/866). +- **Bug Fix:** This release resolves empty directories being left in the cache folder, in some scenarios. See [Issue #868](https://github.com/websharks/comet-cache/issues/868) and [Thread #866](https://forums.wpsharks.com/t/cache-folders-not-removed-during-clean-up-process/866). - **Bug Fix** (Pro): Some REST requests were being redirected incorrectly whenever Apache Optimizations were enabled. See [Issue #855](https://github.com/websharks/comet-cache/issues/855). - **Compatibility Bug Fix:** Some Jetpack API calls were being cached inadvertently. See [Issue #855](https://github.com/websharks/comet-cache/issues/855). - **Enhancement:** Notes in HTML source now indicate fully functional on first load for improved clarity. See [Issue #860](https://github.com/websharks/comet-cache/issues/860). diff --git a/src/includes/classes/AdvCacheBackCompat.php b/src/includes/classes/AdvCacheBackCompat.php index 13aab88..0d5f6ea 100644 --- a/src/includes/classes/AdvCacheBackCompat.php +++ b/src/includes/classes/AdvCacheBackCompat.php @@ -9,42 +9,50 @@ class AdvCacheBackCompat { /** - * Back compat. with `zcAC` and `zcABC`. + * Back compat with `zc` vars. * * @since 150422 Rewrite. + * @since 17xxxx Polishing a little. + * @since 17xxxx Making this more dynamic. */ public static function zcRequestVars() { - $super_gs = [ + $super_globals = [ '_GET' => &$_GET, '_REQUEST' => &$_REQUEST, ]; - $zc_suffixes = ['AC', 'ABC']; + $key_suffixes = ['AC', 'ABC']; + $lc_short_name = mb_strtolower(SHORT_NAME); - foreach ($super_gs as $_super_g_key => &$_super_g_value) { - foreach ($zc_suffixes as $_zc_suffix) { - if (array_key_exists('zc'.$_zc_suffix, $_super_g_value)) { - if ($_super_g_key === '_GET' && !isset($_GET['cc'.$_zc_suffix])) { - $_GET['cc'.$_zc_suffix] = $_super_g_value['zc'.$_zc_suffix]; - } - foreach ($super_gs as $__super_g_key => &$__super_g_value) { - unset($__super_g_value['zc'.$_zc_suffix]); - } - unset($__super_g_key, $__super_g_value); // Housekeeping. + foreach ($super_globals as $_key => &$_array) { + foreach ($key_suffixes as $_suffix) { + if (!array_key_exists('zc'.$_suffix, $_array)) { + continue; // No relevant key in array. } - } - } - unset($_super_g_key, $_super_g_value, $_zc_suffix); + if ($_key === '_GET' && !isset($_GET[$lc_short_name.$_suffix])) { + $_GET[$lc_short_name.$_suffix] = $_array['zc'.$_suffix]; + } // This sets the new key with the value from the old key. + + foreach ($super_globals as $__key => &$__array) { + unset($__array['zc'.$_suffix]); // Purge old key. + } // Must unset temporary vars by reference. + unset($__key, $__array); // Housekeeping. + // + } // unset($_suffix); // Housekeeping. + } // Must unset temporary vars by reference. + unset($_key, $_array); } /** * Back compat. with `ZENCACHE_` constants. * * @since 150422 Rewrite. + * @since 17xxxx Polishing a little. + * @since 17xxxx Making this more dynamic. */ public static function zenCacheConstants() { - $_global_ns = mb_strtoupper(GLOBAL_NS); + $uc_global_ns = mb_strtoupper(GLOBAL_NS); if (!($constants = get_defined_constants(true)) || empty($constants['user'])) { return; // Nothing to do; i.e. no user-defined constants. @@ -52,32 +60,32 @@ public static function zenCacheConstants() foreach ($constants['user'] as $_constant => $_value) { if (mb_stripos($_constant, 'ZENCACHE_') !== 0) { continue; // Nothing to do here. - } - if (!($_constant_sub_name = mb_substr($_constant, 9))) { + } elseif (!($_constant_sub_name = mb_substr($_constant, 9))) { continue; // Nothing to do here. } - if (!defined($_global_ns.'_'.$_constant_sub_name)) { - define($_global_ns.'_'.$_constant_sub_name, $_value); - } - } - if (isset($_SERVER['ZENCACHE_ALLOWED']) && !isset($_SERVER[$_global_ns.'_ALLOWED'])) { - $_SERVER[$_global_ns.'_ALLOWED'] = $_SERVER['ZENCACHE_ALLOWED']; - } + if (!defined($uc_global_ns.'_'.$_constant_sub_name)) { + define($uc_global_ns.'_'.$_constant_sub_name, $_value); + } // Sets new const with the value from the old const. + } // unset($_constant, $_value); // Just a little housekeeping. - unset($_constant, $_value, $_global_ns); // Housekeeping. + if (isset($_SERVER['ZENCACHE_ALLOWED']) && !isset($_SERVER[$uc_global_ns.'_ALLOWED'])) { + $_SERVER[$uc_global_ns.'_ALLOWED'] = $_SERVER['ZENCACHE_ALLOWED']; + } // Sets new super-global with the value from the old super-global key. } /** - * Back compat. with `COMET_CACHE_ALLOW_BROWSER_CACHE` constants. + * Back compat. with constants. * - * @since 160706 Renaming COMET_CACHE_ALLOW_BROWSER_CACHE to COMET_CACHE_ALLOW_CLIENT_SIDE_CACHE + * @since 160706 Renaming `*_ALLOW_BROWSER_CACHE` to `*_ALLOW_CLIENT_SIDE_CACHE`. + * @since 17xxxx Polishing things up a little. + * @since 17xxxx Making this more dynamic. */ public static function browserCacheConstant() { - $_global_ns = mb_strtoupper(GLOBAL_NS); + $uc_global_ns = mb_strtoupper(GLOBAL_NS); - if (defined('COMET_CACHE_ALLOW_BROWSER_CACHE')) { - define($_global_ns.'_ALLOW_CLIENT_SIDE_CACHE', COMET_CACHE_ALLOW_BROWSER_CACHE); + if (defined($uc_global_ns.'_ALLOW_BROWSER_CACHE')) { + define($uc_global_ns.'_ALLOW_CLIENT_SIDE_CACHE', constant($uc_global_ns.'_ALLOW_BROWSER_CACHE')); } } } diff --git a/src/includes/classes/AdvancedCache.php b/src/includes/classes/AdvancedCache.php index 4372649..f421f4e 100644 --- a/src/includes/classes/AdvancedCache.php +++ b/src/includes/classes/AdvancedCache.php @@ -13,6 +13,7 @@ class AdvancedCache extends AbsBaseAp /*[.build.php-auto-generate-use-Traits]*/ use Traits\Ac\AbortUtils; use Traits\Ac\AcPluginUtils; + use Traits\Ac\CacheIoUtils; use Traits\Ac\ClientSideUtils; use Traits\Ac\NcDebugUtils; use Traits\Ac\ObUtils; diff --git a/src/includes/classes/MenuPage.php b/src/includes/classes/MenuPage.php index a780eb5..2cb84e3 100644 --- a/src/includes/classes/MenuPage.php +++ b/src/includes/classes/MenuPage.php @@ -1,8 +1,6 @@ plugin->isApache() || $this->plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Apache Optimizations', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Apache Performance Tuning (Optional; Highly Recommended)', 'comet-cache').'

'."\n"; + echo '

'.__('You don\'t need to use an .htaccess file to enjoy the performance enhancements provided by this plugin; caching is handled automatically by WordPress/PHP alone. That being said, if you want to take advantage of additional speed enhancements by optimizing the Apache web server to achieve maximize performance (and we do recommend this), then you WILL need an .htaccess file to accomplish that part.', 'comet-cache').'

'."\n"; + echo '

'.__('WordPress itself uses the .htaccess file to create Apache rewrite rules when you enable fancy Permalinks, so there\'s a good chance you already have an .htaccess file. The options below allow for additional performance tuning using recommendations provided by Comet Cache.', 'comet-cache').'

'."\n"; + echo '

'.__('When you enable one of the options below, Comet Cache will attempt to automatically insert the appropriate configuration into your .htaccess file (or remove it automatically if you are disabling an option). If Comet Cache is unable to update the file, or if you would prefer to add the configuration yourself, the recommended configuration to add to the file can be viewed at the bottom of each option.', 'comet-cache').'

'."\n"; + echo '

'.__('Note: The .htaccess file is parsed by the web server directly, before WordPress is even loaded. For that reason, if something goes wrong in the file you can end up with a broken site. We recommend creating a backup of your current .htaccess file before making any modifications.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + echo '

'.__('Enable GZIP Compression?', 'comet-cache').'

'."\n"; + echo '

'.__('GZIP compression is highly recommended. It\'s not uncommon to achieve compression rates as high as 70-90%, which is a huge savings in the amount of data that needs to be transferred with each visit to your site.', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('%1$s fully supports GZIP compression on its output. However, it does not handle GZIP compression directly like some caching plugins. We purposely left GZIP compression out of this plugin because GZIP compression is something that should really be enabled at the Apache level or inside your php.ini file. GZIP compression can be used for things like JavaScript and CSS files as well, so why bother turning it on for only WordPress-generated pages when you can enable GZIP at the server level and cover all the bases!', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.__('Or, you can update your configuration manually: [ .htaccess configuration ]', 'comet-cache').'

'."\n"; + echo ' '."\n"; + + if ((!IS_PRO && $this->plugin->isApache()) && !$this->plugin->isProPreview()) { + echo '
'."\n"; + echo '

'.sprintf(__('Enable the Pro Preview to see Leverage Browser Caching, Enforce Canonical URLs, and more!', 'comet-cache'), esc_attr(add_query_arg(urlencode_deep(['page' => GLOBAL_NS, GLOBAL_NS.'_pro_preview' => '1']), self_admin_url('/admin.php')))).'

'."\n"; + } + if (IS_PRO || $this->plugin->isProPreview()) { + echo '
'."\n"; + echo '

'.__('Leverage Browser Caching?', 'comet-cache').'

'."\n"; + echo '

'.__('Browser Caching is highly recommended. When loading a single page, downloading all of the resources for that page may require multiple roundtrips between the browser and server, which delays processing and may block rendering of page content. This also incurs data costs for the visitor. With browser caching, your server tells the visitor\'s browser that it is allowed to cache static resources for a certain amount of time (Google recommends 1 week and that\'s what Comet Cache uses).', 'comet-cache').'

'."\n"; + echo '

'.__('In WordPress, \'Page Caching\' is all about server-side performance (reducing the amount of time it takes the server to generate the page content). With Comet Cache installed, you\'re drastically reducing page generation time. However, you can make a visitor\'s experience ​even faster​ when you leverage browser caching too. When this option is enabled, the visitor\'s browser will cache static resources from each page and reuse those cached resources on subsequent page loads. In this way, future visits to the same page will not require additional connections to your site to download static resources that the visitor\'s browser has already cached.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Or, you can update your configuration manually: [ .htaccess configuration ]', 'comet-cache').'

'."\n"; + echo ' '."\n"; + } + if (IS_PRO || $this->plugin->isProPreview()) { + echo '
'."\n"; + echo '

'.__('Enforce an Exact Hostname?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('By enforcing an exact hostname you avoid duplicate cache files, which saves disk space and improves cache performance. For example, if a bot or crawler accesses your site using your server\'s IP address instead of using your domain name (e.g., http://123.456.789/path), this results in duplicate cache files, because the host was an IP address. The \'host\' being an important factor in any cache storage system. The same would be true if a visitor attempted to access your site using a made-up sub-domain; e.g., http://foo.bar.%1$s/path. This sort of thing can be avoided by explicitly enforcing an exact hostname in the request. One that matches exactly what you\'ve configured in WordPress Settings → General.', 'comet-cache'), esc_html(parse_url(network_home_url(), PHP_URL_HOST))).'

'."\n"; + echo '

'."\n"; + echo '

'.__('Or, you can update your configuration manually: [ .htaccess configuration ]', 'comet-cache').'

'."\n"; + echo ' '."\n"; + } + if ((IS_PRO && !empty($GLOBALS['wp_rewrite']->permalink_structure)) || $this->plugin->isProPreview()) { + echo '
'."\n"; + echo '

'.__('Enforce Canonical URLs?', 'comet-cache').'

'."\n"; + echo '

'.__('Permalinks (URLs) leading to Posts/Pages on your site (based on your WordPress Permalink Settings) '.($GLOBALS['wp_rewrite']->use_trailing_slashes ? 'require a .../trailing-slash/' : 'do not require a .../trailing-slash').'. Ordinarily, WordPress enforces this by redirecting a request for '.($GLOBALS['wp_rewrite']->use_trailing_slashes ? '.../something' : '.../something/').', to '.($GLOBALS['wp_rewrite']->use_trailing_slashes ? '.../something/' : '.../something').', thereby forcing the final location to match your Permalink configuration. However, whenever you install a plugin like Comet Cache, much of WordPress (including this automatic redirection) is out of the picture when the cached copy of a page is being served. So enabling this option will add rules to your .htaccess file that make Apache aware of your WordPess Permalink configuration. Apache can do what WordPress normally would, only much more efficiently.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Or, you can update your configuration manually: [ .htaccess configuration ]', 'comet-cache').'

'."\n"; + echo ' '."\n"; + } + if ((IS_PRO && $this->plugin->options['cdn_enable']) || $this->plugin->isProPreview()) { + echo '
'."\n"; + echo '

'.__('Send Access-Control-Allow-Origin Header?', 'comet-cache').'

'."\n"; + if ($this->plugin->options['cdn_enable'] && !$this->plugin->options['htaccess_access_control_allow_origin']) { + echo '

'.__('Warning: Send Access-Control-Allow-Origin Header has been disabled below but Comet Cache → Plugin Options → Static CDN Filters are enabled. We recommend configuring your server to send the Access-Control-Allow-Origin header to avoid CORS errors when a CDN is configured.', 'comet-cache').'

'."\n"; + } + echo '

'.__('If you are using Static CDN Filters to load resources for your site from another domain, it\'s important that your server sends an Access-Control-Allow-Origin header to prevent Cross Origin Resource Sharing (CORS) errors. This option is enabled automatically when you enable Static CDN Filters. For more information, see this article.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Or, you can update your configuration manually: [ .htaccess configuration ]', 'comet-cache').'

'."\n"; + echo ' '."\n"; + } + echo '
'."\n"; + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/AutoCacheEngine.php b/src/includes/classes/MenuPage/Options/AutoCacheEngine.php new file mode 100644 index 0000000..8b6202b --- /dev/null +++ b/src/includes/classes/MenuPage/Options/AutoCacheEngine.php @@ -0,0 +1,75 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Auto-Cache Engine', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Enable the Auto-Cache Engine?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('After using %1$s for awhile (or any other page caching plugin, for that matter); it becomes obvious that at some point (based on your configured Expiration Time) %1$s has to refresh itself. It does this by ditching its cached version of a page, reloading the database-driven content, and then recreating the cache with the latest data. This is a never ending regeneration cycle that is based entirely on your configured Expiration Time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.__('Understanding this, you can see that 99% of your visitors are going to receive a lightning fast response from your server. However, there will always be around 1% of your visitors that land on a page for the very first time (before it\'s been cached), or land on a page that needs to have its cache regenerated, because the existing cache has become outdated. We refer to this as a First-Come Slow-Load Issue. Not a huge problem, but if you\'re optimizing your site for every ounce of speed possible, the Auto-Cache Engine can help with this. The Auto-Cache Engine has been designed to combat this issue by taking on the responsibility of being that first visitor to a page that has not yet been cached, or has an expired cache. The Auto-Cache Engine is powered, in part, by WP-Cron (already built into WordPress). The Auto-Cache Engine runs at 15-minute intervals via WP-Cron. It also uses the WP_Http class, which is also built into WordPress already.', 'comet-cache').'

'."\n"; + echo '

'.__('The Auto-Cache Engine obtains its list of URLs to auto-cache, from two different sources. It can read an XML Sitemap and/or a list of specific URLs that you supply. If you supply both sources, it will use both sources collectively. The Auto-Cache Engine takes ALL of your other configuration options into consideration too, including your Expiration Time, as well as any cache exclusion rules.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + + echo '
'."\n"; + + echo '
'."\n"; + echo '

'.__('XML Sitemap URL (or an XML Sitemap Index)', 'comet-cache').'

'."\n"; + echo '
'.esc_html(home_url('/')).'
'."\n"; + if (is_multisite()) { + echo '

'."\n"; + echo '

'.sprintf(__(' If enabled here, each child blog can be auto-cached too. %1$s will dynamically change the leading %2$s as necessary; for each child blog in the network. %1$s supports both sub-directory & sub-domain networks, including domain mapping plugins. For more information about how the Auto-Cache Engine caches child blogs, see this article.', 'comet-cache'), esc_html(NAME), esc_html(home_url('/'))).'

'."\n"; + } + echo '
'."\n"; + + echo '

'.__('And/Or; a List of URLs to Auto-Cache (One Per Line)', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Note: Wildcards are NOT supported here. If you are going to supply a list of URLs above, each line must contain one full URL for the Auto-Cache Engine to auto-cache. If you have many URLs, we recommend using an XML Sitemap.', 'comet-cache').'

'."\n"; + + echo '
'."\n"; + + echo '

'.__('Auto-Cache Delay Timer (in Milliseconds)', 'comet-cache').'

'."\n"; + echo '

'.__('As the Auto-Cache Engine runs through each URL, you can tell it to wait X number of milliseconds between each connection that it makes. It is strongly suggested that you DO have some small delay here. Otherwise, you run the risk of hammering your own web server with multiple repeated connections whenever the Auto-Cache Engine is running. This is especially true on very large sites; where there is the potential for hundreds of repeated connections as the Auto-Cache Engine goes through a long list of URLs. Adding a delay between each connection will prevent the Auto-Cache Engine from placing a heavy load on the processor that powers your web server. A value of 500 milliseconds is suggested here (half a second). If you experience problems, you can bump this up a little at a time, in increments of 500 milliseconds; until you find a happy place for your server. Please note that 1000 milliseconds = 1 full second.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + + echo '
'."\n"; + + echo '

'.__('Auto-Cache User-Agent String', 'comet-cache').'

'."\n"; + echo '
; '.esc_html(GLOBAL_NS.' '.VERSION).'
'."\n"; + echo '

'.__('This is how the Auto-Cache Engine identifies itself when connecting to URLs. See User Agent in the Wikipedia.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/AutomaticClearing.php b/src/includes/classes/MenuPage/Options/AutomaticClearing.php new file mode 100644 index 0000000..8c2f9d8 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/AutomaticClearing.php @@ -0,0 +1,143 @@ +plugin->isProPreview() ? ' pro-preview' : '').'">'."\n"; + + echo ' '."\n"; + echo ' '.__('Automatic Cache Clearing', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + + echo '

'.__('Clearing the Cache Automatically', 'comet-cache').'

'."\n"; + echo ' '."\n"; + echo '

'.sprintf(__('This is built into the %1$s plugin; i.e., this functionality is "always on". If you edit a Post/Page (or delete one), %1$s will automatically clear the cache file(s) associated with that content. This way a new updated version of the cache will be created automatically the next time this content is accessed. Simple updates like this occur each time you make changes in the Dashboard, and %1$s will notify you of these as they occur. %1$s monitors changes to Posts (of any kind, including Pages), Categories, Tags, Links, Themes (even Users), and more.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + if (IS_PRO || $this->plugin->isProPreview()) { + echo '
'."\n"; + echo '

'."\n"; + echo '
'."\n"; + } + echo '
'."\n"; + echo '

'.__('Primary Page Options', 'comet-cache').'

'."\n"; + + echo '

'.__('Auto-Clear Designated "Home Page" Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('On many sites, the Home Page (aka: the Front Page) offers an archive view of all Posts (or even Pages). Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the "Home Page"?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.__('Auto-Clear Designated "Posts Page" Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('On many sites, the Posts Page (aka: the Blog Page) offers an archive view of all Posts (or even Pages). Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the "Posts Page"?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + + echo '
'."\n"; + echo '

'.__('Author, Archive, and Tag/Term Options', 'comet-cache').'

'."\n"; + + echo '

'.__('Auto-Clear "Author Page" Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('On many sites, each author has a related "Author Page" that offers an archive view of all posts associated with that author. Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the related "Author Page"?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + + echo '

'.__('Auto-Clear "Category Archives" Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('On many sites, each post is associated with at least one Category. Each category then has an archive view that contains all the posts within that category. Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the associated Category archive views?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + + echo '

'.__('Auto-Clear "Tag Archives" Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('On many sites, each post may be associated with at least one Tag. Each tag then has an archive view that contains all the posts assigned that tag. Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the associated Tag archive views?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + + echo '

'.__('Auto-Clear "Date-Based Archives" Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Date-Based Archives allow visitors to browse Posts by the year, month, or day they were originally published. If a single Post (of any type) is changed in some way; and %1$s clears/resets the cache for that Post, would you like %1$s to also clear any existing cache files for Dated-Based Archives that match the publication time?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + + echo '

'.__('Auto-Clear "Custom Term Archives" Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Most sites do not use any custom Terms so it should be safe to leave this disabled. However, if your site uses custom Terms and they have their own Term archive views, you may want to clear those when the associated post is cleared. Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the associated Tag archive views?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + + echo '

'.__('Auto-Clear "Custom Post Type Archives" Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Most sites do not use any Custom Post Types so it should be safe to disable this option. However, if your site uses Custom Post Types and they have their own Custom Post Type archive views, you may want to clear those when any associated post is cleared. Therefore, if a single Post with a Custom Post Type is changed in some way; and %1$s clears/resets the cache for that post, would you like %1$s to also clear any existing cache files for the associated Custom Post Type archive views?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + + echo '
'."\n"; + echo '

'.__('Feed-Related Options', 'comet-cache').'

'."\n"; + + echo '

'.__('Auto-Clear "RSS/RDF/ATOM Feeds" Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If you enable Feed Caching (below), this can be quite handy. If enabled, when you update a Post/Page, approve a Comment, or make other changes where %1$s can detect that certain types of Feeds should be cleared to keep your site up-to-date, then %1$s will do this for you automatically. For instance, the blog\'s master feed, the blog\'s master comments feed, feeds associated with comments on a Post/Page, term-related feeds (including mixed term-related feeds), author-related feeds, etc. Under various circumstances (i.e., as you work in the Dashboard) these can be cleared automatically to keep your site up-to-date.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + + echo '
'."\n"; + echo '

'.__('Sitemap-Related Options', 'comet-cache').'

'."\n"; + + echo '

'.__('Auto-Clear "XML Sitemaps" Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If you\'re generating XML Sitemaps with a plugin like Google XML Sitemaps, you can tell %1$s to automatically clear the cache of any XML Sitemaps whenever it clears a Post/Page. Note: This does NOT clear the XML Sitemap itself of course, only the cache. The point being, to clear the cache and allow changes to a Post/Page to be reflected by a fresh copy of your XML Sitemap; sooner rather than later.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '
'."\n"; + echo '

'.__('XML Sitemap Patterns (one per line): A default value of /sitemap**.xml covers all XML Sitemaps for most installations. However, you may customize this further if you deem necessary. Please list one pattern per line. XML Sitemap Pattern searches are performed against the REQUEST_URI. A wildcard ** (double asterisk) can be used when necessary; e.g., /sitemap**.xml. Note that ** = 0 or more characters of any kind, including / slashes. * (a single asterisk) means 0 or more characters that are NOT a slash /. Your patterns must match from beginning to end; i.e., the special chars: ^ (beginning of string) and $ (end of the string) are always on for these patterns (i.e., applied internally). For that reason, if you want to match part of a URI, use ** to match anything before and/or after the fragment you\'re searching for. For example, **/sitemap**.xml will match any URI containing /sitemap (anywhere), so long as the URI also ends with .xml. On the other hand, /sitemap*.xml will only match URIs that begin with /sitemap, and it will only match URIs ending in .xml in that immediate directory — bypassing any inside nested sub-directories. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + if (is_multisite()) { + echo '

'.__('In a Multisite Network, each child blog (whether it be a sub-domain, a sub-directory, or a mapped domain); will automatically change the leading http://[sub.]domain/[sub-directory] used in pattern matching. In short, there is no need to add sub-domains or sub-directories for each child blog in these patterns. Please include only the REQUEST_URI (i.e., the path) which leads to the XML Sitemap on all child blogs in the network.', 'comet-cache').'

'."\n"; + } + echo '
'."\n"; + + if (IS_PRO || $this->plugin->isProPreview()) { + echo '
'."\n"; + echo '

'.__('Misc. Auto-Clear Options', 'comet-cache').'

'."\n"; + echo '

'.__('Auto-Clear Custom URL Patterns Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Auto-Clear Custom URL Patterns (one per line): When you update a Post/Page, approve a Comment, etc., %1$s will detect that a Post/Page cache should be cleared to keep your site up-to-date. When this occurs, %1$s can also clear a list of custom URLs that you enter here. Please list one URL per line. A wildcard * character can be used when necessary; e.g., https://example.com/category/abc/**. Note that ** (double asterisk) means 0 or more characters of any kind, including / slashes. * (a single asterisk) means 0 or more characters that are NOT a slash /. Your patterns must match from beginning to end; i.e., the special chars: ^ (beginning of string) and $ (end of the string) are always on for these patterns (i.e., applied internally). For that reason, if you want to match part of a URL, use ** to match anything before and/or after the fragment you\'re searching for. For example, https://**/category/abc/** will find all URLs containing /category/abc/ (anywhere); whereas https://*/category/abc/* will match URLs on any domain, but the path must then begin with /category/abc/ and the pattern will only match paths in that immediate directory — bypassing any additional paths in sub-directories. To learn more about this syntax, please see this KB article.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.__('Note: Relative URLs (e.g., /name-of-post) should NOT be used. Each entry above should start with http:// or https:// and include a fully qualified domain name (or wildcard characters in your pattern that will match the domain).', 'comet-cache').'

'."\n"; + } + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/ClientSide.php b/src/includes/classes/MenuPage/Options/ClientSide.php new file mode 100644 index 0000000..222a4ef --- /dev/null +++ b/src/includes/classes/MenuPage/Options/ClientSide.php @@ -0,0 +1,54 @@ +'."\n"; + + echo ' '."\n"; + echo ' '.__('Client-Side Cache', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Allow Double-Caching In The Client-Side Browser?', 'comet-cache').'

'."\n"; + echo '

'.__('Recommended setting: No (for membership sites, very important). Otherwise, Yes would be better (if users do NOT log in/out of your site).', 'comet-cache').'

'."\n"; + echo '

'.__('This option is NOT the same as "Leverage Browser Caching", which refers to the caching of static resources in the browser (e.g., images, CSS, JS). This Client-Side Cache option is different in that it controls the caching of page content in the browser, i.e., the caching of HTML content generated by PHP itself, which is generally NOT static. If you\'re looking to Leverage Browser Caching for static resources (highly recommended), see the Apache Optimizations panel below.', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('%1$s handles content delivery through its ability to communicate with a browser using PHP. If you allow a browser to (cache) the caching system itself, you are momentarily losing some control; and this can have a negative impact on users that see more than one version of your site; e.g., one version while logged-in, and another while NOT logged-in. For instance, a user may log out of your site, but upon logging out they report seeing pages on the site which indicate they are STILL logged in (even though they\'re not — that\'s bad). This can happen if you allow a client-side cache, because their browser may cache web pages they visited while logged into your site which persist even after logging out. Sending no-cache headers will work to prevent this issue.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.__('All of that being said, if all you care about is blazing fast speed and users don\'t log in/out of your site (only you do); you can safely set this to Yes (recommended in this case). Allowing a client-side browser cache will improve speed and reduce outgoing bandwidth when this option is feasible.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Tip: Setting this to No is highly recommended when running a membership plugin like s2Member (as one example). In fact, many plugins like s2Member will send nocache_headers() on their own, so your configuration here will likely be overwritten when you run such plugins (which is better anyway). In short, if you run a membership plugin, you should NOT allow a client-side browser cache.', 'comet-cache').'

'."\n"; + echo '

'.__('Tip: Setting this to No will NOT impact static content; e.g., CSS, JS, images, or other media. This setting pertains only to dynamic PHP scripts which produce content generated by WordPress.', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Advanced Tip: if you have this set to No, but you DO want to allow a few special URLs to be cached by the browser; you can add this parameter to your URL ?%2$sABC=1. This tells %1$s that it\'s OK for the browser to cache that particular URL. In other words, the %2$sABC=1 parameter tells %1$s NOT to send no-cache headers to the browser.', 'comet-cache'), esc_html(NAME), esc_html(mb_strtolower(SHORT_NAME))).'

'."\n"; + echo '
'."\n"; + echo '
'."\n"; + echo '

'.__('Exclusion Patterns for Client-Side Caching', 'comet-cache').'

'."\n"; + echo '

'.__('When you enable Client-Side Caching above, you may want to prevent certain pages on your site from being cached by a client-side browser. This is where you will enter those if you need to (one per line). Searches are performed against the REQUEST_URI; i.e., /path/?query (caSe insensitive). So, don\'t put in full URLs here, just word fragments found in the file path (or query string) is all you need, excluding the http:// and domain name. A wildcard * character can also be used when necessary; e.g., /category/abc-followed-by-* (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Tip: let\'s use this example URL: http://www.example.com/post/example-post-123. To exclude this URL, you would put this line into the field above: /post/example-post-123. Or, you could also just put in a small fragment, like: example or example-*-123 and that would exclude any URI containing that word fragment.', 'comet-cache').'

'."\n"; + echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/Developers.php b/src/includes/classes/MenuPage/Options/Developers.php new file mode 100644 index 0000000..8aa1462 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/Developers.php @@ -0,0 +1,40 @@ +'."\n"; + + echo ' '."\n"; + echo ' '.__('Theme/Plugin Developers', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Developing a Theme or Plugin for WordPress?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Tip: %1$s can be disabled temporarily. If you\'re a theme/plugin developer, you can set a flag within your PHP code to disable the cache engine at runtime. Perhaps on a specific page, or in a specific scenario. In your PHP script, set: $_SERVER[\'COMET_CACHE_ALLOWED\'] = FALSE; or define(\'COMET_CACHE_ALLOWED\', FALSE). %1$s is also compatible with: define(\'DONOTCACHEPAGE\', TRUE). It does\'t matter where or when you define one of these, because %1$s is the last thing to run before script execution ends.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'."\n"; + echo '

'.sprintf(__('Writing "Advanced Cache" Plugins Specifically for %1$s', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('Theme/plugin developers can take advantage of the %1$s plugin architecture by creating PHP files inside this special directory: /wp-content/ac-plugins/. There is an example plugin file @ GitHub (please review it carefully and ask questions). If you develop a plugin for %1$s, please share it with the community by publishing it in the plugins respository at WordPress.org.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('Why does %1$s have it\'s own plugin architecture? WordPress loads the advanced-cache.php drop-in file (for caching purposes) very early-on; before any other plugins or a theme. For this reason, %1$s implements it\'s own watered-down version of functions like add_action(), do_action(), add_filter(), apply_filters().', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/Directory.php b/src/includes/classes/MenuPage/Options/Directory.php new file mode 100644 index 0000000..040eeff --- /dev/null +++ b/src/includes/classes/MenuPage/Options/Directory.php @@ -0,0 +1,36 @@ +'."\n"; + + echo ' '."\n"; + echo ' '.__('Cache Directory', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo '

'.__('Base Cache Directory (Must be Writable; i.e., Permissions 755 or Higher)', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('This is where %1$s will store the cached version of your site. If you\'re not sure how to deal with directory permissions, don\'t worry too much about this. If there is a problem, %1$s will let you know about it. By default, this directory is created by %1$s and the permissions are setup automatically. In most cases there is nothing more you need to do.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'.esc_html(WP_CONTENT_DIR).'//
'."\n"; + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/Enable.php b/src/includes/classes/MenuPage/Options/Enable.php new file mode 100644 index 0000000..b91fa41 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/Enable.php @@ -0,0 +1,47 @@ +'."\n"; + + echo ' '."\n"; + echo ' '.__('Enable/Disable', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo '

'.sprintf(__('%1$s™ = SPEED!!', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

   

'."\n"; + echo '

'.sprintf(__('HUGE Time-Saver: Approx. 95%% of all WordPress sites running %1$s, simply enable it here; and that\'s it :-) No further configuration is necessary (really). All of the other options (down below) are already tuned for the BEST performance on a typical WordPress installation. Simply enable %1$s here and click "Save All Changes". If you get any warnings please follow the instructions given. Otherwise, you\'re good . This plugin is designed to run just fine like it is. Take it for a spin right away; you can always fine-tune things later if you deem necessary.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'."\n"; + echo ' '."\n"; + echo '

'.sprintf(__('How Can I Tell %1$s is Working?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('First of all, please make sure that you\'ve enabled %1$s here; then scroll down to the bottom of this page and click "Save All Changes". All of the other options (below) are already pre-configured for typical usage. Feel free to skip them all for now. You can go back through all of these later and fine-tune things the way you like them.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('Once %1$s has been enabled, you\'ll need to log out (and/or clear browser cookies). By default, cache files are NOT served to visitors who are logged-in, and that includes you too ;-) Cache files are NOT served to recent comment authors either. If you\'ve commented (or replied to a comment lately); please clear your browser cookies before testing.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('To verify that %1$s is working, navigate your site like a normal visitor would. Right-click on any page (choose View Source), then scroll to the very bottom of the document. At the bottom, you\'ll find comments that show %1$s stats and information. You should also notice that page-to-page navigation is lightning fast now that %1$s is running; and it gets faster over time!', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/Expiration.php b/src/includes/classes/MenuPage/Options/Expiration.php new file mode 100644 index 0000000..8cc78ac --- /dev/null +++ b/src/includes/classes/MenuPage/Options/Expiration.php @@ -0,0 +1,68 @@ +plugin->isProPreview() ? ' pro-preview' : '').'">'."\n"; + + echo ' '."\n"; + echo ' '.__('Cache Expiration Time', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Automatic Expiration Time (Max Age)', 'comet-cache').'

'."\n"; + echo '

'.__('If you don\'t update your site much, you could set this to 6 months and optimize everything even further. The longer the Cache Expiration Time is, the greater your performance gain. Alternatively, the shorter the Expiration Time, the fresher everything will remain on your site. A default value of 7 days (recommended); is a good conservative middle-ground.', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Keep in mind that your Expiration Time is only one part of the big picture. %1$s will also clear the cache automatically as changes are made to the site (i.e., you edit a post, someone comments on a post, you change your theme, you add a new navigation menu item, etc., etc.). Thus, your Expiration Time is really just a fallback; e.g., the maximum amount of time that a cache file could ever possibly live.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('All of that being said, you could set this to just 60 seconds and you would still see huge differences in speed and performance. If you\'re just starting out with %1$s (perhaps a bit nervous about old cache files being served to your visitors); you could set this to something like 30 minutes and experiment with it while you build confidence in %1$s. It\'s not necessary to do so, but many site owners have reported this makes them feel like they\'re more-in-control when the cache has a short expiration time. All-in-all, it\'s a matter of preference .', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.__('Tip: the value that you specify here MUST be compatible with PHP\'s strtotime() function. Examples: 30 seconds, 2 hours, 7 days, 6 months, 1 year.', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Note: %1$s will never serve a cache file that is older than what you specify here (even if one exists in your cache directory; stale cache files are never used). In addition, a WP Cron job will automatically cleanup your cache directory (once per hour); purging expired cache files periodically. This prevents a HUGE cache from building up over time, creating a potential storage issue.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + + echo '
'."\n"; + + echo '

'.__('Cache Cleanup Schedule', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If you have an extremely large site and you lower the default Cache Expiration Time of 7 days, expired cache files can build up more quickly. By default, %1$s cleans up expired cache files via WP Cron at an hourly interval, but you can tell %1$s to use a custom Cache Cleanup Schedule below to run the cleanup process more or less frequently, depending on your specific needs.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + + if (IS_PRO || $this->plugin->isProPreview()) { + $_sys_getloadavg_unavailable = ($this->plugin->isProPreview() ? false : !$this->plugin->sysLoadAverages()); + echo '
'."\n"; + echo '
'."\n"; + echo '

'.__('Disable Cache Expiration If Server Load Average is High?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If you have high traffic at certain times of the day, %1$s can be told to check the current load average via sys_getloadavg(). If your server\'s load average has been high in the last 15 minutes or so, cache expiration is disabled automatically to help reduce stress on the server; i.e., to avoid generating a new version of the cache while the server is very busy.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('To enable this functionality you should first determine what a high load average is for your server. If you log into your machine via SSH you can run the top command to get a feel for what a high load average looks like. Once you know the number, you can enter it in the field below; e.g., 1.05 might be a high load average for a server with one CPU. See also: Understanding Load Average', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + if ($_sys_getloadavg_unavailable && mb_stripos(PHP_OS, 'win') === 0) { // See: + echo '

'.__('Note: It appears that your server is running Windows. The sys_getloadavg() function has not been implemented in PHP for Windows servers yet.', 'comet-cache').'

'."\n"; + } elseif ($_sys_getloadavg_unavailable && mb_stripos(PHP_OS, 'win') !== 0) { + echo '

'.__('Note: sys_getloadavg() has been disabled by your web hosting company or is not available on your server.', 'comet-cache').'

'."\n"; + } + echo '
'."\n"; + } + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/FeedRequests.php b/src/includes/classes/MenuPage/Options/FeedRequests.php new file mode 100644 index 0000000..a615f24 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/FeedRequests.php @@ -0,0 +1,41 @@ +'."\n"; + + echo ' '."\n"; + echo ' '.__('Feed Caching', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Caching Enabled for RSS, RDF, Atom Feeds?', 'comet-cache').'

'."\n"; + echo '

'.__('This should almost ALWAYS be set to No. UNLESS, you\'re sure that you want to cache your feeds. If you use a web feed management provider like Google® Feedburner and you set this option to Yes, you may experience delays in the detection of new posts. NOTE: If you do enable this, it is highly recommended that you also enable automatic Feed Clearing too. Please see the section above: "Automatic Cache Clearing". Find the sub-section titled: "Auto-Clear RSS/RDF/ATOM Feeds".', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Note: This option affects all feeds served by WordPress, including the site feed, the site comment feed, post-specific comment feeds, author feeds, search feeds, and category and tag feeds. See also: WordPress Feeds.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/GetRequests.php b/src/includes/classes/MenuPage/Options/GetRequests.php new file mode 100644 index 0000000..6420ce5 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/GetRequests.php @@ -0,0 +1,53 @@ +plugin->isProPreview() ? ' pro-preview' : '').'">'."\n"; + + echo ' '."\n"; + echo ' '.__('GET Requests', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + + echo ' '."\n"; + echo '

'.__('Caching Enabled for GET (Query String) Requests?', 'comet-cache').'

'."\n"; + echo '

'.__('This should almost always be set to No. UNLESS, you\'re using unfriendly Permalinks; i.e., if all of your URLs contain a query string (like ?p=123). In such a case, you should set this option to Yes. However, it\'s better to update your Permalink options and use friendly Permalinks, which also optimizes your site for search engines. Again, if you\'re using friendly Permalinks (recommended) you can leave this at the default value of No.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('Advanced Tip: If you are not caching GET requests (recommended), but you do want to allow some special URLs that include query string parameters to be cached, you can add this special parameter to any URL ?%2$sAC=1. This tells %1$s that it\'s OK to cache that particular URL, even though it contains query string arguments. If you are caching GET requests and you want to force %1$s to not cache a specific request, you can add this special parameter to any URL ?%2$sAC=0.', 'comet-cache'), esc_html(NAME), esc_html(mb_strtolower(SHORT_NAME))).'

'."\n"; + echo '

'.__('Other Request Types: POST requests (i.e., forms with method="post") are always excluded from the cache, which is the way it should be. Any POST/PUT/DELETE request should never, ever be cached. CLI and self-serve requests are also excluded from the cache automatically. A CLI request is one that comes from the command line; commonly used by CRON jobs and other automated routines. A self-serve request is an HTTP connection established from your site, to your site. For instance, a WP Cron job, or any other HTTP request that is spawned not by a user, but by the server itself.', 'comet-cache').'

'."\n"; + + if (IS_PRO || $this->plugin->isProPreview()) { + echo '
'."\n"; + echo '
'."\n"; + echo '

'.__('List of GET Variable Names to Ignore', 'comet-cache').'

'."\n"; + echo '

'.__('You can enter one variable name per line. Each of the variable names that you list here will be ignored entirely; i.e., not considered when caching any given page, and not considered when serving any page that is already cached. For example, many sites use Google Analytics and there are GET request variables used by Google Analytics, which are read by client-side JavaScript only. Those GET variables can be ignored altogether when it comes to the cache algorithm — speeding up your site even further.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('A wildcard * character can also be used when necessary; e.g., utm_* (where * = 0 or more characters that are NOT a slash /). To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + } + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/Heading.php b/src/includes/classes/MenuPage/Options/Heading.php new file mode 100644 index 0000000..a5eea63 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/Heading.php @@ -0,0 +1,95 @@ +'."\n"; + + if (is_multisite()) { + echo ''."\n"; + } + echo ' '."\n"; + + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo ' '."\n"; + echo '
'."\n"; + + echo '
'."\n"; + if (IS_PRO && current_user_can($this->plugin->update_cap)) { + echo ' '.__('Newsletter', 'comet-cache').''."\n"; + echo ' '.__('Beta Testers', 'comet-cache').''."\n"; + } + if (!IS_PRO) { + echo ' '.__('Preview Pro Features', 'comet-cache').''."\n"; + echo ' '.__('Pro Upgrade', 'comet-cache').''."\n"; + } + echo '
'."\n"; + + echo ' '."\n"; + + echo ' '."\n"; + + if (IS_PRO) { + echo '
'."\n"; + echo sprintf(__('%1$s™ Pro v%2$s', 'comet-cache'), esc_html(NAME), esc_html(VERSION))."\n"; + echo '('.__('changelog', 'comet-cache').')'."\n"; + echo '
'."\n"; + } else { // For the lite version (default behavior). + echo '
'."\n"; + echo sprintf(__('%1$s™ v%2$s', 'comet-cache'), esc_html(NAME), esc_html(VERSION))."\n"; + echo '('.__('changelog', 'comet-cache').')'."\n"; + echo '
'."\n"; + } + echo ' '.esc_attr(__('Plugin Options', 'comet-cache')).''."\n"; + + echo '
'."\n"; + + echo ''."\n"; + + echo '
'."\n"; + + new Notices(); + } +} diff --git a/src/includes/classes/MenuPage/Options/HostExclusions.php b/src/includes/classes/MenuPage/Options/HostExclusions.php new file mode 100644 index 0000000..d0adec5 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/HostExclusions.php @@ -0,0 +1,45 @@ +plugin->canConsiderDomainMapping()); + + if ($this->plugin->applyWpFilters(GLOBAL_NS.'_exclude_hosts_option_enable', $exclude_hosts_option_enable)) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Host Exclusions', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo '

'.__('Don\'t Cache These Special Host Exclusion Patterns?', 'comet-cache').'

'."\n"; + echo '

'.__('If there are specific domains that should not be cached, you can enter them here so they are excluded automatically. The easiest way to exclude a host is to enter the full domain name on a line of it\'s own in the field below, e.g., site1.example.com.', 'comet-cache').'

'."\n"; + echo '

'.__('This field also supports Watered-Down Regex syntax, which means that you can also exclude a pattern like: *.example.com or *.example.*. So for instance, if you wanted to exclude all child sites and only cache pages on the Main Site of a Network installation, you could exclude all sub-domains using: *.mynetwork.com. That excludes all sub-domains, but not mynetwork.com by itself.', 'comet-cache').'

'."\n"; + + echo '

'."\n"; + + echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; + + echo '
'."\n"; + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/HtmlCompressor.php b/src/includes/classes/MenuPage/Options/HtmlCompressor.php new file mode 100644 index 0000000..c797477 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/HtmlCompressor.php @@ -0,0 +1,104 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('HTML Compression', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Enable WebSharks™ HTML Compression?', 'comet-cache').'

'."\n"; + if (is_plugin_active('autoptimize/autoptimize.php')) { + echo '

'.__('Autoptimize + Comet Cache: Comet Cache has detected that you are running the Autoptimize plugin. Autoptimize and the HTML Compressor feature of Comet Cache are both designed to compress HTML, CSS, and JavaScript. Enabling the HTML Compressor alongside Autoptimize may result in unexpected behavior. If you\'re happy with Autoptimize, you can leave the HTML Compressor disabled. All other Comet Cache features run great alongside Autoptimize.', 'comet-cache').'

'; + } + echo '

'."\n"; + echo '
'."\n"; + echo '
'."\n"; + echo '

'.__('HTML Compression Options', 'comet-cache').'

'."\n"; + echo '

'.__('You can learn more about all of these options here.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'."\n"; + echo '

'."\n"; + echo '

'."\n"; + echo '

'."\n"; + echo '

'."\n"; + echo '

'."\n"; + echo '

'."\n"; + echo '

'."\n"; + echo '
'."\n"; + echo '

'.__('CSS Exclusion Patterns?', 'comet-cache').'

'."\n"; + echo '

'.__('Sometimes there are special cases when a particular CSS file should NOT be consolidated or compressed in any way. This is where you will enter those if you need to (one per line). Searches are performed against the <link href=""> value, and also against the contents of any inline <style> tags (caSe insensitive). A wildcard * character can also be used when necessary; e.g., xy*-framework (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; + echo '

'.__('JavaScript Exclusion Patterns?', 'comet-cache').'

'."\n"; + echo '

'.__('Sometimes there are special cases when a particular JS file should NOT be consolidated or compressed in any way. This is where you will enter those if you need to (one per line). Searches are performed against the <script src=""> value, and also against the contents of any inline <script> tags (caSe insensitive). A wildcard * character can also be used when necessary; e.g., xy*-framework (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; + echo '

'.__('URI Exclusions for HTML Compressor?', 'comet-cache').'

'."\n"; + echo '

'.__('When you enable HTML Compression above, you may want to prevent certain pages on your site from being cached by the HTML Compressor. This is where you will enter those if you need to (one per line). Searches are performed against the REQUEST_URI; i.e., /path/?query (caSe insensitive). So, don\'t put in full URLs here, just word fragments found in the file path (or query string) is all you need, excluding the http:// and domain name. A wildcard * character can also be used when necessary; e.g., /category/abc-followed-by-* (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Tip: let\'s use this example URL: http://www.example.com/post/example-post-123. To exclude this URL, you would put this line into the field above: /post/example-post-123. Or, you could also just put in a small fragment, like: example or example-*-123 and that would exclude any URI containing that word fragment.', 'comet-cache').'

'."\n"; + echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + echo '

'.__('HTML Compression Cache Expiration', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Tip: the value that you specify here MUST be compatible with PHP\'s strtotime() function. Examples: 2 hours, 7 days, 6 months, 1 year.', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Note: This does NOT impact the overall cache expiration time that you configure with %1$s. It only impacts the sub-routines provided by the HTML Compressor. In fact, this expiration time is mostly irrelevant. The HTML Compressor uses an internal checksum, and it also checks filemtime() before using an existing cache file. The HTML Compressor class also handles the automatic cleanup of your cache directories to keep it from growing too large over time. Therefore, unless you have VERY little disk space there is no reason to set this to a lower value (even if your site changes dynamically quite often). If anything, you might like to increase this value which could help to further reduce server load. You can learn more here. We recommend setting this value to at least double that of your overall %1$s expiration time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/ImportExport.php b/src/includes/classes/MenuPage/Options/ImportExport.php new file mode 100644 index 0000000..261fab1 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/ImportExport.php @@ -0,0 +1,45 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Import/Export Options', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.sprintf(__('Import Options from Another %1$s Installation?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('Upload your %1$s-options.json file and click "Save All Changes" below. The options provided by your import file will override any that exist currently.', 'comet-cache'), GLOBAL_NS).'

'."\n"; + echo '

'."\n"; + echo '
'."\n"; + echo '

'.sprintf(__('Export Existing Options from this %1$s Installation?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo ' '."\n"; + echo '

'.sprintf(__('Download your existing options and import them all into another %1$s installation; saves time on future installs.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/ManualClearing.php b/src/includes/classes/MenuPage/Options/ManualClearing.php new file mode 100644 index 0000000..85260e0 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/ManualClearing.php @@ -0,0 +1,95 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Manual Cache Clearing', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo '

'.__('Clearing the Cache Manually', 'comet-cache').'

'."\n"; + echo ' '."\n"; + echo '

'.sprintf(__('Once %1$s is enabled, you will find this new option in your WordPress Admin Bar (screenshot on right). Clicking this button will clear the cache and you can start fresh at anytime (e.g., you can do this manually; and as often as you wish).', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('Depending on the structure of your site, there could be many reasons to clear the cache. However, the most common reasons are related to Post/Page edits or deletions, Category/Tag edits or deletions, and Theme changes. %1$s handles most scenarios all by itself. However, many site owners like to clear the cache manually; for a variety of reasons (just to force a refresh).', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'."\n"; + + if (is_multisite()) { + echo '
'."\n"; + echo '

'.__('Also allow Child Sites in a Network to clear the cache from their Admin Bar?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('In a Multisite Network, each child site can clear its own cache. If you want child sites to see the "Clear Cache" button in their WordPress Admin Bar, you can specify a comma-delimited list of Roles and/or Capabilities that are allowed. For example, if I want Administrators to be capable of clearing the cache from their Admin Bar, I could enter administrator here. If I also want to allow Editors, I can use a comma-delimited list: administrator,editor. Or, I could use a single Capability of: edit_others_posts; which covers both Administrators & Editors at the same time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('Note: As a security measure, in addition to the Role(s) and/or Capabilities that you list here, each child site owner must also have the ability to %1$s.', 'comet-cache'), esc_html(IS_PRO ? $this->plugin->clear_min_cap : 'edit_posts')).'

'."\n"; + echo '
'."\n"; + } else { + echo '
'."\n"; + echo '

'.__('Also allow others to clear the cache from their Admin Bar?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If you want others to see the "Clear Cache" button in their WordPress Admin Bar, you can specify a comma-delimited list of Roles and/or Capabilities that are allowed. For example, if I want Editors to be capable of clearing the cache from their Admin Bar, I could enter editor here. If I also want to allow Authors, I can use a comma-delimited list: editor,author. Or, I could use a single Capability of: publish_posts; which covers both Editors & Authors at the same time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('Note: As a security measure, in addition to the Role(s) and/or Capabilities that you list here, each user must also have the ability to %1$s.', 'comet-cache'), esc_html(IS_PRO ? $this->plugin->clear_min_cap : 'edit_posts')).'

'."\n"; + echo '
'."\n"; + } + if ($this->plugin->functionIsPossible('opcache_reset')) { + echo '
'."\n"; + echo '

'.__('Clear the PHP OPcache Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If you clear the cache manually, do you want %1$s to clear the PHP OPcache too? This is not necessary, but if you want a truly clean start, this will clear all PHP files in the server\'s opcode cache also. Note: If you don\'t already know what the PHP OPcache is, it is suggested that you leave this disabled. It really is not necessary. This is just an added feature for advanced users.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + } + if ($this->plugin->functionIsPossible('s2clean')) { + echo '
'."\n"; + echo '

'.__('Clear the s2Clean Cache Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If the s2Clean theme is installed, and you clear the cache manually, %1$s can clear the s2Clean Markdown cache too (if you\'ve enabled Markdown processing with s2Clean).', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + } + echo '
'."\n"; + echo '

'.__('Evaluate Custom PHP Code when Clearing the Cache?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If you have any custom routines you\'d like to process when the cache is cleared manually, please enter PHP code here. If your PHP code outputs a message, it will be displayed along with any other notes from %1$s itself. This feature is intended for developers, and it may come in handy if you need to clear any system caches not already covered by %1$s configuration options.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.__('Example: <?php apc_clear_cache(); echo \'<p>Also cleared APC cache.</p>\'; ?>', 'comet-cache').'

'."\n"; + + echo '
'."\n"; + echo '

'.__('Clear the CDN Cache Too?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If you clear the cache manually, do you want %1$s to automatically bump the CDN invalidation counter too? i.e., automatically increment the ?%2$s=[counter] in all static CDN URLs?', 'comet-cache'), esc_html(NAME), esc_html($this->plugin->options['cdn_invalidation_var'])).'

'."\n"; + echo '

'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/Memcached.php b/src/includes/classes/MenuPage/Options/Memcached.php new file mode 100644 index 0000000..f254fe2 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/Memcached.php @@ -0,0 +1,51 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('RAM / Memcached', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Enable Memcached for a Faster RAM-Based Cache?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('This requires a server with Memcached enabled, or a service like AWS ElastiCache that you pay for. Memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load & disk I/O. In the context of %1$s, Memcached is an effective tool that can be used to avoid repeated disk reads. By adding a Memcached server to your %1$s configuration, %1$s is able to store the cached copy of each page in RAM, and then serve the cache to future visitors in a faster, more efficient, and less CPU-intensive way — while still obeying your cache expiration time and other configuration options. In short, Memcached makes your site even faster. Over time (i.e., as RAM is used to store cache entries) it will also reduce load on your server.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.__('Logged-In Users: User-specific cache entries for logged-in users are not stored in RAM. At this time, Memcached works to enhance speed for non-logged-in users only.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + + echo '

'."\n"; + echo '

'.__('Memcached Server Pool', 'comet-cache').'

'."\n"; + echo '

'.__('You can enter one or more Memcached servers in line-delimited format. Note that one line (one Memcached server) is adequate for most sites. Each line must contain a colon-delimited server hostname (or IP address), the port number, and then an arbitrary priority that allows you to give weight to one server over another. As an example, 127.0.0.1:11211:1 (just one line) would work for a VPS that runs a self-hosted Memcached server locally on the 127.0.0.1 loopback address.', 'comet-cache').'

'."\n"; + echo '

'.__('We recommend a Memcached server with a minimum of 512MB of RAM available and generally no more than 5GB is necessary. That said, Memcached is very resilient and it will automatically evict older cache entries when it runs out of space. Having a smaller Memcached server just means you have a smaller capacity to hold all possible cache entries. In other words, you never have to worry about your Memcached server running out of space as your cache usage increases. This is because Memached never really runs out of space. Instead, it shifts things around automatically so it can hold as much as possible in RAM (given the memory available to it) at any given time. The larger your Memcached server is, the better, but size is never a strict requirement when it comes to Memcached.', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Note that %1$s auto-prefixes all of its Memcached cache keys internally with a software-specific namespace. So while you may want to use a dedicated Memcached instance for %1$s, that\'s not absolutely necessary. If you already have a Memcached instance running for another purpose, %1$s can easily take advantage of that instance, even if other processes are using it also.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '
'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/MobileMode.php b/src/includes/classes/MenuPage/Options/MobileMode.php new file mode 100644 index 0000000..fe9d3e4 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/MobileMode.php @@ -0,0 +1,66 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Mobile Mode', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo '

'.__(' Enable Mobile-Adaptive Mode?', 'comet-cache').'

'."\n"; + echo '

'.__('Tip: Generally speaking, you should only enable this if your WordPress theme uses an \'Adaptive\' design, as opposed to a design that\'s \'Responsive\'—the way most WordPress themes are built.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + + if (!version_compare(PHP_VERSION, '5.6', '>=')) { + echo '

'.sprintf(__('PHP Version: This feature requires PHP v5.6 (or higher). You\'re currently running PHP v%1$s. Please contact your web hosting company for assistance.', 'comet-cache'), esc_html(PHP_VERSION)).'

'."\n"; + } + + echo '

'.__('What\'s the Difference Between Responsive and Adaptive?', 'comet-cache').'

'."\n"; + echo '

'.__('Responsive and Adaptive designs both attempt to optimize the user experience across different devices, adjusting for different viewport sizes, resolutions, usage contexts, control mechanisms, and so on. Responsive design (common for WordPress sites) works on the principle of flexibility — a single fluid website that can look good on any device. Responsive websites use media queries, flexible grids, and responsive images to create a user experience that flexes and changes based on a multitude of factors. If you have a Responsive theme, you probably do NOT need to enable Mobile-Adaptive Mode.', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Adaptive design detects the device and other features, and then it provides the appropriate feature and layout based on a predefined set of viewport sizes and other characteristics. Adaptive themes generally decide what to display based on a visitor\'s User-Agent (i.e., OS, device, browser, version). Since this design choice results in multiple versions of a page being served to visitors, based on the device they access the site with, it then becomes important to cache each of those variations separately. That way a visitor on an iPhone isn\'t accidentally shown the cached copy of a page that was originally viewed by another visitor who was on a desktop computer. If your theme uses an Adaptive design, you probably DO want to enable Mobile-Adaptive Mode in %1$s.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + + echo '

'."\n"; + echo '

'.__('Mobile-Adaptive Tokens', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('When %1$s runs in Mobile-Adaptive Mode and it detects that a device is Mobile (e.g., a phone, tablet), it needs to know which factors you\'d like to consider. Mobile-Adaptive Tokens make this easy. In the field below, please configure a list of Mobile-Adaptive Tokens that establish the important factors on your site. Each token must be separated by a + sign. You can use just one, or use them all. However, it\'s IMPORTANT to note: With each new token, you add additional permutations that can fragment the cache and eat up a lot of disk space. Enable and monitor Cache Statistics so you can keep an eye on this. See: %1$s → Plugin Options → Cache-Related Statistics', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.__('The available Tokens are as follows:', 'comet-cache').'

'."\n"; + echo '
    '."\n"; + echo '
  • '.__('os.name This token is replaced automatically with: iOS, Android, etc.', 'comet-cache').'
  • '."\n"; + echo '
  • '.__('device.type This token is replaced with: Tablet, Mobile Device, Mobile Phone, etc.', 'comet-cache').'
  • '."\n"; + echo '
  • '.__('browser.name This token is replaced with: Safari, Mobile Safari UIWebView, Chrome, etc.', 'comet-cache').'
  • '."\n"; + echo '
  • '.__('browser.version Major & minor version. Not recommended, many permutations. Replaced with: 55.0, 1.3, 9383242.2392, etc.', 'comet-cache').'
  • '."\n"; + echo '
  • '.__('browser.version.major Major version only. More feasible, fewer permutations. Replaced with: 55, 1, 9383242, etc.', 'comet-cache').'
  • '."\n"; + echo '
'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('The suggested default value is: %2$s
However, just: os.name + device.type is better, if that will do.', 'comet-cache'), esc_html(NAME), esc_html($this->plugin->default_options['mobile_adaptive_salt'])).'

'."\n"; + echo '

'.__('The special token: device.is_mobile (i.e., any mobile device, including tablets, excluding laptops) can be used by itself. For example, if you simply want to break the cache down into mobile vs. NOT mobile.', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Note: The underlying logic behind mobile detection is accomplished using a faster, precompiled version of Browscap Lite, and Browcap data is automatically updated (and recompiled) whenever you save %1$s options and/or when upgrading %1$s to a new version.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/Nf404Requests.php b/src/includes/classes/MenuPage/Options/Nf404Requests.php new file mode 100644 index 0000000..6f1541b --- /dev/null +++ b/src/includes/classes/MenuPage/Options/Nf404Requests.php @@ -0,0 +1,42 @@ +'."\n"; + + echo ' '."\n"; + echo ' '.__('404 Requests', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Caching Enabled for 404 Requests?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('When this is set to No, %1$s will ignore all 404 requests and no cache file will be served. While this is fine for most site owners, caching the 404 page on a high-traffic site may further reduce server load. When this is set to Yes, %1$s will cache the 404 page (see Creating an Error 404 Page) and then serve that single cache file to all future 404 requests.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('How does %1$s cache 404 requests? %1$s will create a special cache file (----404----.html, see Advanced Tip below) for the first 404 request and then symlink future 404 requests to this special cache file. That way you don\'t end up with lots of 404 cache files that all contain the same thing (the contents of the 404 page). Instead, you\'ll have one 404 cache file and then several symlinks (i.e., references) to that 404 cache file.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.__('Advanced Tip: The default 404 cache filename (----404----.html) is designed to minimize the chance of a collision with a cache file for a real page with the same name. However, if you want to override this default and define your own 404 cache filename, you can do so by adding define(\'COMET_CACHE_404_CACHE_FILENAME\', \'your-404-cache-filename\'); to your wp-config.php file (note that the .html extension should be excluded when defining a new filename).', 'comet-cache').'

'."\n"; + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/Notices.php b/src/includes/classes/MenuPage/Options/Notices.php new file mode 100644 index 0000000..7beab1f --- /dev/null +++ b/src/includes/classes/MenuPage/Options/Notices.php @@ -0,0 +1,102 @@ +'."\n"; + echo ' '.__('Options updated successfully.', 'comet-cache')."\n"; + echo ''."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_restored'])) { + echo '
'."\n"; + echo ' '.__('Default options successfully restored.', 'comet-cache')."\n"; + echo '
'."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_cache_wiped'])) { + echo '
'."\n"; + echo ' '.__('Cache wiped across all sites; re-creation will occur automatically over time.', 'comet-cache')."\n"; + echo '
'."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_cache_cleared'])) { + echo '
'."\n"; + if (is_multisite() && is_main_site()) { + echo ' '.__('Cache cleared for main site; re-creation will occur automatically over time.', 'comet-cache')."\n"; + } else { + echo ' '.__('Cache cleared for this site; re-creation will occur automatically over time.', 'comet-cache')."\n"; + } + echo '
'."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_wp_htaccess_add_failure'])) { + echo '
'."\n"; + echo ' '.sprintf(__('Failed to update your /.htaccess file automatically. Most likely a permissions error. Please make sure it has permissions 644 or higher (perhaps 666). Once you\'ve done this, please try saving the %1$s options again.', 'comet-cache'), esc_html(NAME))."\n"; + echo '
'."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_wp_htaccess_remove_failure'])) { + echo '
'."\n"; + echo ' '.sprintf(__('Failed to update your /.htaccess file automatically. Most likely a permissions error. Please make sure it has permissions 644 or higher (perhaps 666). Once you\'ve done this, please try saving the %1$s options again.', 'comet-cache'), esc_html(NAME))."\n"; + echo '
'."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_wp_htaccess_nginx_notice'])) { + echo '
'."\n"; + echo ' '.__('It appears that your server is running NGINX and does not support .htaccess rules. Please update your server configuration manually. If you\'ve already updated your NGINX configuration, you can safely ignore this message.', 'comet-cache')."\n"; + echo '
'."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_wp_config_wp_cache_add_failure'])) { + echo '
'."\n"; + echo ' '.__('Failed to update your /wp-config.php file automatically. Please add the following line to your /wp-config.php file (right after the opening <?php tag; on it\'s own line).
define( \'WP_CACHE\', true );
', 'comet-cache')."\n"; + echo '
'."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_wp_config_wp_cache_remove_failure'])) { + echo '
'."\n"; + echo ' '.__('Failed to update your /wp-config.php file automatically. Please remove the following line from your /wp-config.php file, or set WP_CACHE to a FALSE value.
define( \'WP_CACHE\', true );
', 'comet-cache')."\n"; + echo '
'."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_advanced_cache_add_failure'])) { + echo '
'."\n"; + if ($_REQUEST[GLOBAL_NS.'_advanced_cache_add_failure'] === 'advanced-cache') { + echo ' '.sprintf(__('Failed to update your /wp-content/advanced-cache.php file. Cannot write file: %1$s/%2$s-advanced-cache. Please be sure this directory exists (and that it\'s writable): %1$s. Please use directory permissions 755 or higher (perhaps 777). Once you\'ve done this, please try again.', 'comet-cache'), esc_html($this->plugin->cacheDir()), esc_html(mb_strtolower(SHORT_NAME)))."\n"; + } else { + echo ' '.__('Failed to update your /wp-content/advanced-cache.php file. Most likely a permissions error. Please create an empty file here: /wp-content/advanced-cache.php (just an empty PHP file, with nothing in it); give it permissions 644 or higher (perhaps 666). Once you\'ve done this, please try again.', 'comet-cache')."\n"; + } + echo '
'."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_advanced_cache_remove_failure'])) { + echo '
'."\n"; + echo ' '.__('Failed to remove your /wp-content/advanced-cache.php file. Most likely a permissions error. Please delete (or empty the contents of) this file: /wp-content/advanced-cache.php.', 'comet-cache')."\n"; + echo '
'."\n"; + } + if (!empty($_REQUEST[GLOBAL_NS.'_ua_info_dir_population_failure'])) { + echo '
'."\n"; + echo ' '.sprintf(__('Failed to populate User-Agent detection files for Mobile-Adaptive Mode. User-Agent detection files are pulled from a remote location so you\'ll always have the most up-to-date information needed for accurate detection. However, it appears the remote source of this information is currently unvailable. Please wait 15 minutes, then try saving your %1$s options again.', 'comet-cache'), esc_html(NAME))."\n"; + echo '
'."\n"; + } + if (!IS_PRO && $this->plugin->isProPreview()) { + echo '
'."\n"; + echo ''.__('close', 'comet-cache').' '."\n"; + echo ' '.sprintf(__('Pro Features (Preview) ~ New option panels below. Please explore before upgrading .
NOTE: the free version of %1$s (this lite version) is more-than-adequate for most sites. Please upgrade only if you desire advanced features or would like to support the developer.', 'comet-cache'), esc_html(NAME))."\n"; + echo '
'."\n"; + } + if (!$this->plugin->options['enable']) { + echo '
'."\n"; + echo ' '.sprintf(__('%1$s is currently disabled; please review options below.', 'comet-cache'), esc_html(NAME))."\n"; + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/ProUpdater.php b/src/includes/classes/MenuPage/Options/ProUpdater.php new file mode 100644 index 0000000..513798f --- /dev/null +++ b/src/includes/classes/MenuPage/Options/ProUpdater.php @@ -0,0 +1,67 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Update Credentials', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + + echo ' '."\n"; + + echo '

'.__('Authentication for Automatic Updates', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('%1$s Pro is a premium product available for purchase @ cometcache.com. In order to connect with our update servers, you must supply your License Key. Your License Key is located under "My Account" when you log in @ cometcache.com. This will authenticate your copy of %1$s Pro; providing you with access to the latest version. You only need to enter these credentials once. %1$s Pro will save them in your WordPress database; making future upgrades even easier. If you prefer to upgrade manually, see this article.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'."\n"; + + echo '

'.sprintf(__('Username', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('License Key', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + + if ((!defined('DISALLOW_FILE_MODS') || !DISALLOW_FILE_MODS) && !apply_filters('automatic_updater_disabled', defined('AUTOMATIC_UPDATER_DISABLED') && AUTOMATIC_UPDATER_DISABLED)) { + // See: and note that `automatic_updater_disabled` is a core filter. + echo '
'."\n"; + echo '

'.__('Automatic Background Updates', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Enable this if you\'d like %1$s to download and install bug fixes and security updates automatically in the background. Requires a valid license key in the field above.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + } + echo '
'."\n"; + echo '

'.__('Beta Program', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If you would like to participate in our beta program and receive new features and bug fixes before they are released to the public, %1$s can include Release Candidates when checking for automatic updates. Release Candidates are almost-ready-for-production and have already been through many internal test runs. Our team runs the latest Release Candidate on all of our production sites, but that doesn\'t mean you\'ll want to do the same. :-) Please report any issues with Release Candidates on GitHub.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.__('How will I know that I\'m running a Release Candidate?
If you\'re running a Release Candidate, the version ends with -RC, e.g., Comet Cache™ Pro v151201-RC.', 'comet-cache').'

'."\n"; + echo '

'.__('Email Alternative: Instead, if you\'d just like to receive updates about Release Candidates (via email), including a Release Candidate changelog, please sign up for the beta testers mailing list.', 'comet-cache').'

'."\n"; + + echo '
'."\n"; + + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/RefererExclusions.php b/src/includes/classes/MenuPage/Options/RefererExclusions.php new file mode 100644 index 0000000..f386558 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/RefererExclusions.php @@ -0,0 +1,38 @@ +'."\n"; + + echo ' '."\n"; + echo ' '.__('HTTP Referrer Exclusions', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo '

'.__('Don\'t Cache These Special HTTP Referrer Exclusion Patterns?', 'comet-cache').'

'."\n"; + echo '

'.__('Sometimes there are special cases where a particular referring URL (or referring domain) that sends you traffic; or even a particular group of referring URLs or domains that send you traffic; should result in a page being loaded on your site that is NOT from the cache (and that resulting page should never be cached). This is where you will enter those if you need to (one per line). Searches are performed against the HTTP_REFERER (caSe insensitive). A wildcard * character can also be used when necessary; e.g., *.domain.com (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Tip: let\'s use this example URL: http://www.referring-domain.com/search/?q=search+terms. To exclude this referring URL, you could put this line into the field above: www.referring-domain.com. Or, you could also just put in a small fragment, like: /search/ or q=*; and that would exclude any referrer containing that word fragment.', 'comet-cache').'

'."\n"; + echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/Safeguards.php b/src/includes/classes/MenuPage/Options/Safeguards.php new file mode 100644 index 0000000..b35ad78 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/Safeguards.php @@ -0,0 +1,40 @@ +'."\n"; + + echo ' '."\n"; + echo ' '.__('Plugin Deletion Safeguards', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Uninstall on Plugin Deletion; or Safeguard Options?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Tip: By default, if you delete %1$s using the plugins menu in WordPress, nothing is lost. However, if you want to completely uninstall %1$s you should set this to Yes and THEN deactivate & delete %1$s from the plugins menu in WordPress. This way %1$s will erase your options for the plugin, erase directories/files created by the plugin, remove the advanced-cache.php file, terminate CRON jobs, etc. It erases itself from existence completely.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/StaticCdnFilters.php b/src/includes/classes/MenuPage/Options/StaticCdnFilters.php new file mode 100644 index 0000000..e3d588b --- /dev/null +++ b/src/includes/classes/MenuPage/Options/StaticCdnFilters.php @@ -0,0 +1,123 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Static CDN Filters', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Enable Static CDN Filters (e.g., MaxCDN/CloudFront)?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('This feature allows you to serve some and/or ALL static files on your site from a CDN of your choosing. This is made possible through content/URL filters exposed by WordPress and implemented by %1$s. All it requires is that you setup a CDN hostname sourced by your WordPress installation domain. You enter that CDN hostname below and %1$s will do the rest! Super easy, and it doesn\'t require any DNS changes either. :-) Please click here for a general set of instructions.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.__('What\'s a CDN? It\'s a Content Delivery Network (i.e., a network of optimized servers) designed to cache static resources served from your site (e.g., JS/CSS/images and other static files) onto it\'s own servers, which are located strategically in various geographic areas around the world. Integrating a CDN for static files can dramatically improve the speed and performance of your site, lower the burden on your own server, and reduce latency associated with visitors attempting to access your site from geographic areas of the world that might be very far away from the primary location of your own web servers.', 'comet-cache').'

'."\n"; + if ($this->plugin->isNginx() && $this->plugin->applyWpFilters(GLOBAL_NS.'_wp_htaccess_nginx_notice', true) && (!isset($_SERVER['WP_NGINX_CONFIG']) || $_SERVER['WP_NGINX_CONFIG'] !== 'done')) { + echo '
'."\n"; + echo ' '.__('It appears that your server is running NGINX and does not support .htaccess rules. Please update your server configuration manually. Note that updating your NGINX server configuration before enabling Static CDN Filters is recommended to prevent any CORS errors with your CDN. If you\'ve already updated your NGINX configuration, you can safely ignore this message.', 'comet-cache')."\n"; + echo '
'."\n"; + } + echo '

'."\n"; + if ($this->plugin->isApache() && $this->plugin->options['cdn_enable'] && !$this->plugin->options['htaccess_access_control_allow_origin']) { + echo '

'.__('Warning: Static CDN Filters are enabled above but the Comet Cache → Plugin Options → Apache Optimizations → Send Access-Control-Allow-Origin Header option has been disabled. We recommend sending the Access-Control-Allow-Origin header to avoid CORS errors when a CDN is configured.', 'comet-cache').'

'."\n"; + } + echo '
'."\n"; + + echo '
'."\n"; + + echo '

'.__('CDN Hostname (Required)', 'comet-cache').'

'."\n"; + + echo '

'.// This note includes three graphics. One for MaxCDN; another for CloudFront, and another for KeyCDN. + ' '. + ' '. + ' '. + ' '.__('This field is really all that\'s necessary to get Static CDN Filters working! However, it does requires a little bit of work on your part. You need to setup and configure a CDN before you can fill in this field. Once you configure a CDN, you\'ll receive a hostname (provided by your CDN), which you\'ll enter here; e.g., js9dgjsl4llqpp.cloudfront.net. We recommend MaxCDN, Amazon CloudFront, KeyCDN, and/or CDN77 but this should work with many of the most popular CDNs. Please read this article for a general set of instructions. We also have a MaxCDN tutorial, CloudFront tutorial, KeyCDN tutorial, and a CDN77 tutorial to walk you through the process.', 'comet-cache').'

'."\n"; + echo '

plugin->options['cdn_hosts'] ? ' disabled="disabled"' : '').' />

'."\n"; + + echo '
'."\n"; + + echo '

'.__('Multiple CDN Hostnames for Domain Sharding and Multisite Networks (Optional)', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('%1$s also supports multiple CDN Hostnames for any given domain. Using multiple CDN Hostnames (instead of just one, as seen above) is referred to as Domain Sharding (click here to learn more). If you configure multiple CDN Hostnames (i.e., if you implement Domain Sharding), %1$s will use the first one that you list for static resources loaded in the HTML <head> section, the last one for static resources loaded in the footer, and it will choose one at random for all other static resource locations. Configuring multiple CDN Hostnames can improve speed! This is a way for advanced site owners to work around concurrency limits in popular browsers; i.e., making it possible for browsers to download many more resources simultaneously, resulting in a faster overall completion time. In short, this tells the browser that your website will not be overloaded by concurrent requests, because static resources are in fact being served by a content-delivery network (i.e., multiple CDN hostnames). If you use this functionality for Domain Sharding, we suggest that you setup one CDN Distribution (aka: Pull Zone), and then create multiple CNAME records pointing to that distribution. You can enter each of your CNAMES in the field below, as instructed.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('On WordPress Multisite Network installations, this field also allows you to configure different CDN Hostnames for each domain (or sub-domain) that you run from a single installation of WordPress. For more information about configuring Static CDN Filters on a WordPress Multisite Network, see this tutorial: Static CDN Filters for WordPress Multisite Networks.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('↑ Syntax: This is a line-delimited list of domain mappings. Each line should start with your WordPress domain name (e.g., %1$s), followed by an = sign, followed by a comma-delimited list of CDN Hostnames associated with the domain in that line. If you\'re running a Multisite Network installation of WordPress, you might have multiple configuration lines. Otherwise, you should only need one line to configure multiple CDN Hostnames for a standard WordPress installation.', 'comet-cache'), esc_html($this->plugin->hostToken(false, true))).'

'."\n"; + + echo '
'."\n"; + + echo '

'.__('CDN Supports HTTPS Connections?', 'comet-cache').'

'."\n"; + echo '

'."\n"; + + echo '
'."\n"; + + echo '

'. + ''. + ' '.__('Additional Options (For Advanced Users)', 'comet-cache').' '. + ''. + '

'."\n"; + + echo '
'."\n"; + echo '

'.__('Everything else below is 100% completely optional; i.e., not required to enjoy the benefits of Static CDN Filters.', 'comet-cache').'

'."\n"; + + echo '
'."\n"; + + echo '

'.__('Whitelisted File Extensions (Optional; Comma-Delimited)', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('If you leave this empty a default set of extensions are taken from WordPress itself. The default set of whitelisted file extensions includes everything supported by the WordPress media library.', 'comet-cache').(IS_PRO ? ' '.__('This includes the following: '.esc_html(implode(',', Classes\CdnFilters::defaultWhitelistedExtensions())).'', 'comet-cache') : '').'

'."\n"; + + echo '

'.__('Blacklisted File Extensions (Optional; Comma-Delimited)', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('With or without a whitelist, you can force exclusions by explicitly blacklisting certain file extensions of your choosing. Please note, the php extension will never be considered a static resource; i.e., it is automatically blacklisted at all times.', 'comet-cache').'

'."\n"; + + echo '
'."\n"; + + echo '

'.__('Whitelisted URI Inclusion Patterns (Optional; One Per Line)', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one inclusion pattern per line.', 'comet-cache').'

'."\n"; + echo '

'.__('If provided, only local URIs matching one of the patterns you list here will be served from your CDN Hostname. URI patterns are caSe-insensitive. A wildcard * will match zero or more characters in any of your patterns. A caret ^ symbol will match zero or more characters that are NOT the / character. For instance, */wp-content/* here would indicate that you only want to filter URLs that lead to files located inside the wp-content directory. Adding an additional line with */wp-includes/* would filter URLs in the wp-includes directory also. If you leave this empty, ALL files matching a static file extension will be served from your CDN; i.e., the default behavior.', 'comet-cache').'

'."\n"; + echo '

'.__('Please note that URI patterns are tested against a file\'s path (i.e., a file\'s URI, and NOT its full URL). A URI always starts with a leading /. To clarify, a URI is the portion of the URL which comes after the hostname. For instance, given the following URL: http://example.com/path/to/style.css?ver=3, the URI you are matching against would be: /path/to/style.css?ver=3. To whitelist this URI, you could use a line that contains something like this: /path/to/*.css*', 'comet-cache').'

'."\n"; + + echo '

'.__('Blacklisted URI Exclusion Patterns (Optional; One Per Line)', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('With or without a whitelist, you can force exclusions by explicitly blacklisting certain URI patterns. URI patterns are caSe-insensitive. A wildcard * will match zero or more characters in any of your patterns. A caret ^ symbol will match zero or more characters that are NOT the / character. For instance, */wp-content/*/dynamic.pdf* would exclude a file with the name dynamic.pdf located anywhere inside a sub-directory of wp-content.', 'comet-cache').'

'."\n"; + echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; + + echo '
'."\n"; + + echo '

'.__('Query String Invalidation Variable Name', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('Each filtered URL (which then leads to your CDN) will include this query string variable as an easy way to invalidate the CDN cache at any time. Invalidating the CDN cache is simply a matter of changing the global invalidation counter (i.e., the value assigned to this query string variable). %1$s manages invalidations automatically; i.e., %1$s will automatically bump an internal counter each time you upgrade a WordPress component (e.g., a plugin, theme, or WP itself). Or, if you ask %1$s to invalidate the CDN cache (e.g., a manual clearing of the CDN cache); the internal counter is bumped then too. In short, %1$s handles cache invalidations for you reliably. This option simply allows you to customize the query string variable name which makes cache invalidations possible. Please note, the default value is adequate for most sites. You can change this if you like, but it\'s not necessary.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('Tip: You can also tell %1$s to automatically bump the CDN Invalidation Counter whenever you clear the cache manually. See: %1$s → Manual Cache Clearing → Clear the CDN Cache Too?', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.sprintf(__('Note: If you empty this field, it will effectively disable the %1$s invalidation system for Static CDN Filters; i.e., the query string variable will NOT be included if you do not supply a variable name.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'."\n"; + echo '
'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/Statistics.php b/src/includes/classes/MenuPage/Options/Statistics.php new file mode 100644 index 0000000..2bead58 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/Statistics.php @@ -0,0 +1,70 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Cache-Related Statistics', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + if ($this->plugin->isProPreview()) { + echo ' '; + } + echo ' '."\n"; + echo '

'.__('Enable Cache-Related Stats & Charts?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('%1$s can collect and display cache-related statistics (including charts). Stats are displayed in the WordPress Admin Bar, and also in your Dashboard under: %1$s → Stats/Charts. Cache-related stats provide you with a quick look at what\'s happening behind-the-scenes. Your site grows faster and faster as the cache grows larger in size.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('Note: %1$s does a great job of collecting stats, in ways that don\'t cause a performance issue. In addition, as your cache grows larger than several hundred files in total size, statistics are collected less often and at longer intervals. All of that being said, if you run a VERY large site (e.g., more than 20K posts), you might want to disable stats collection in favor of blazing fast speeds not impeded by any directory scans needed to collect stats.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + echo '

'.__('Show Stats in the WordPress Admin Bar?', 'comet-cache').'

'."\n"; + echo '

'."\n"; + if (is_multisite()) { + echo '
'."\n"; + echo '

'.__('Allow Child Sites in a Network to See Stats in Admin Bar?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('In a Multisite Network, each child site has stats of its own. If you want child sites to see cache-related stats in their WordPress Admin Bar, you can specify a comma-delimited list of Roles and/or Capabilities that are allowed to see stats. For example, if I want the Administrator to see stats in their Admin Bar, I could enter administrator here. If I also want to show stats to Editors, I can use a comma-delimited list: administrator,editor. Or, I could use a single Capability of: edit_others_posts; which covers both Administrators & Editors at the same time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('Note: As a security measure, in addition to the Role(s) and/or Capabilities that you list here, each child site owner must also have the ability to %1$s.', 'comet-cache'), esc_html(IS_PRO ? $this->plugin->stats_min_cap : 'edit_posts')).'

'."\n"; + echo '
'."\n"; + } else { + echo '
'."\n"; + echo '

'.__('Allow Others to See Stats in Admin Bar?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('If you want others to see cache-related stats in their WordPress Admin Bar, you can specify a comma-delimited list of Roles and/or Capabilities that are allowed to see stats. For example, if I want Editors to see stats in their Admin Bar, I could enter editor here. If I also want to show stats to Authors, I can use a comma-delimited list: editor,author. Or, I could use a single Capability of: publish_posts; which covers both Editors & Authors at the same time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('Note: As a security measure, in addition to the Role(s) and/or Capabilities that you list here, each user must also have the ability to %1$s.', 'comet-cache'), esc_html(IS_PRO ? $this->plugin->stats_min_cap : 'edit_posts')).'

'."\n"; + echo '
'."\n"; + } + echo '
'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/UriExclusions.php b/src/includes/classes/MenuPage/Options/UriExclusions.php new file mode 100644 index 0000000..c0e1d15 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/UriExclusions.php @@ -0,0 +1,42 @@ +'."\n"; + + echo ' '."\n"; + echo ' '.__('URI Exclusions', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo '

'.__('Don\'t Cache These Special URI Exclusion Patterns?', 'comet-cache').'

'."\n"; + echo '

'.__('Sometimes there are certain cases where a particular file, or a particular group of files, should never be cached. This is where you will enter those if you need to (one per line). Searches are performed against the REQUEST_URI; i.e., /path/?query (caSe insensitive). So, don\'t put in full URLs here, just word fragments found in the file path (or query string) is all you need, excluding the http:// and domain name. A wildcard * character can also be used when necessary; e.g., /category/abc-followed-by-* (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + + echo '

'.__('Tip: let\'s use this example URL: http://www.example.com/post/example-post-123. To exclude this URL, you would put this line into the field above: /post/example-post-123. Or, you could also just put in a small fragment, like: example or example-*-123 and that would exclude any URI containing that word fragment.', 'comet-cache').'

'."\n"; + echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; + if (is_multisite() && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL) { + echo '

'.__('Multisite Network w/ Sub-Directories: You can also use URI Exclusion Patterns to exclude specific sites from being cached, e.g., /site1/*.', 'comet-cache').'

'."\n"; + } + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/UserAgentExclusions.php b/src/includes/classes/MenuPage/Options/UserAgentExclusions.php new file mode 100644 index 0000000..23d218e --- /dev/null +++ b/src/includes/classes/MenuPage/Options/UserAgentExclusions.php @@ -0,0 +1,38 @@ +'."\n"; + + echo ' '."\n"; + echo ' '.__('User-Agent Exclusions', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo '

'.__('Don\'t Cache These Special User-Agent Exclusion Patterns?', 'comet-cache').'

'."\n"; + echo '

'.__('Sometimes there are special cases when a particular user-agent (e.g., a specific browser or a specific type of device); should be shown a page on your site that is NOT from the cache (and that resulting page should never be cached). This is where you will enter those if you need to (one per line). Searches are performed against the HTTP_USER_AGENT (caSe insensitive). A wildcard * character can also be used when necessary; e.g., Android *; Chrome/* Mobile (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('Tip: if you wanted to exclude iPhones put this line into the field above: iPhone;*AppleWebKit. Or, you could also just put in a small fragment, like: iphone; and that would exclude any user-agent containing that word fragment. Note, this is just an example. With a default installation of %1$s, there is no compelling reason to exclude iOS devices (or any mobile device for that matter).', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + + echo ''."\n"; + } +} diff --git a/src/includes/classes/MenuPage/Options/UserRequests.php b/src/includes/classes/MenuPage/Options/UserRequests.php new file mode 100644 index 0000000..64c21b7 --- /dev/null +++ b/src/includes/classes/MenuPage/Options/UserRequests.php @@ -0,0 +1,79 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Logged-In Users', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__('Caching Enabled for Logged-In Users & Comment Authors?', 'comet-cache').'

'."\n"; + echo '

'.__('This should almost always be set to No. Most sites don\'t cache content generated while a user is logged-in. Doing so could result in a cache of dynamic content generated specifically for a particular user, where the content being cached may contain details that pertain only to the user that was logged-in when the cache was generated. In short, don\'t turn this on unless you know what you\'re doing. Note also that most sites get most (sometimes all) of their traffic from users who are not logged-in. When a user is logged-in, disabling the cache is generally a good idea because a logged-in user has a session open with your site. The content they view should remain very dynamic in this scenario.', 'comet-cache').'

'."\n"; + echo ' '."\n"; + echo '

'.sprintf(__('Exception (Membership Sites): If you run a site with many users and the majority of your traffic comes from users who are logged-in, choose: Yes (maintain separate cache). %1$s will operate normally, but when a user is logged-in the cache is user-specific. %1$s will intelligently refresh the cache when/if a user submits a form on your site with the GET or POST method. Or, if you make changes to their account (or another plugin makes changes to their account); including user option|meta additions, updates & deletions too. However, please note that enabling this feature (i.e., user-specific cache entries) will eat up much more disk space. That being said, the benefits of this feature for most sites will outweigh the disk overhead; i.e., it\'s not an issue in most cases. In other words, unless you\'re short on disk space, or you have thousands of users, the disk overhead is neglible.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + if ($this->plugin->options['when_logged_in'] === '1' && $this->plugin->applyWpFilters(GLOBAL_NS.'_when_logged_in_no_admin_bar', true)) { + echo '

'.sprintf(__('Warning: Whenever you enable caching for logged-in users (without a separate cache for each user), the WordPress Admin Bar must be disabled to prevent one user from seeing another user\'s details in the Admin Bar. Given your current configuration, %1$s will automatically hide the WordPress Admin Bar on the front-end of your site.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + } + echo '

'.sprintf(__('Note: %1$s includes comment authors as part of it\'s logged-in user check. This way comment authors will be able to see updates to comment threads immediately. And, so that any dynamically-generated messages displayed by your theme will work as intended. In short, %1$s thinks of a comment author as a logged-in user, even though technically they are not. Users who gain access to password-protected Posts/Pages are also considered by the logged-in user check.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + + echo '
'."\n"; + + echo '
'."\n"; + echo '

'.__('Cache Pages Containing Nonce Values in Markup?', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('This should almost always be set to Yes. WordPress injects Nonces (numbers used once) into the markup on any given page that a logged-in user lands on. These Nonce values are generally used to improve security when actions are taken by a user; e.g., posting a form or clicking a link that performs an action. If you set this to No, any page containing an Nonce will bypass the cache and be served dynamically (a performance hit). Even the Admin Bar in WordPress injects Nonce values. That\'s reason enough to leave this at the default value of Yes; i.e., so Nonce values in the markup don\'t result in a cache bypass. In short, don\'t set this to No unless you know what you\'re doing.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'."\n"; + echo '

'.sprintf(__('Note: Nonce values in WordPress have a limited lifetime. They can expire just 12 hours after they were first generated. For this reason, %1$s will automatically force cache files containing Nonce values to expire once they are 12+ hours old; i.e., a new request for an expired page containing Nonce values will be rebuilt automatically, generating new Nonces that will continue to operate as expected. This rule is enforced no matter what your overall Cache Expiration Time is set to.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
'."\n"; + echo '

'.__('Static CDN Filters Enabled for Logged-In Users & Comment Authors?', 'comet-cache').'

'."\n"; + echo '

'.__('While this defaults to a value of No, it should almost always be set to Yes. This value defaults to No only because Logged-In User caching (see above) defaults to No and setting this value to Yes by default can cause confusion for some site owners. Once you understand that Static CDN Filters can be applied safely for all visitors (logged-in or not logged-in), please choose Yes in the dropdown below. If you are not using Static CDN Filters, the value below is ignored.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '

'.__('Note: Static CDN Filters serve static resources. Static resources, are, simply put, static. Thus, it is not a problem to cache these resources for any visitor (logged-in or not logged-in). To avoid confusion, this defaults to a value of No, and we ask that you set it to Yes on your own so that you\'ll know to expect this behavior; i.e., that static resources will always be served from the CDN (logged-in or not logged-in) even though Logged-In User caching may be disabled above.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + echo '

'.__('Enable HTML Compression for Logged-In Users?', 'comet-cache').'

'."\n"; + echo '

'.__('Disabled by default. This setting is only applicable when HTML Compression is enabled. HTML Compression should remain disabled for logged-in users because the user-specific cache has a much shorter Time To Live (TTL) which means their cache is likely to expire more quickly than a normal visitor. Rebuilding the HTML Compressor cache is time-consuming and doing it too frequently will actually slow things down for them. For example, if you\'re logged into the site as a user and you submit a form, that triggers a clearing of the cache for that user, including the HTML Compressor cache. Lots of little actions you take can result in a clearing of the cache. This shorter TTL is not ideal when running the HTML Compressor because it does a deep analysis of the page content and the associated resources in order to intelligently compress things. For logged-in users, it is better to skip that extra work and just cache the HTML source as-is, avoiding that extra overhead. In short, do NOT turn this on unless you know what you\'re doing.', 'comet-cache').'

'."\n"; + echo '

'."\n"; + echo '
'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPage/Options/VersionSalt.php b/src/includes/classes/MenuPage/Options/VersionSalt.php new file mode 100644 index 0000000..1c0608f --- /dev/null +++ b/src/includes/classes/MenuPage/Options/VersionSalt.php @@ -0,0 +1,48 @@ +plugin->isProPreview()) { + echo '
'."\n"; + + echo ' '."\n"; + echo ' '.__('Dynamic Version Salt', 'comet-cache')."\n"; + echo ' '."\n"; + + echo '
'."\n"; + echo ' '."\n"; + echo '

'.__(' GEEK ALERT This is for VERY advanced users only...', 'comet-cache').'

'."\n"; + echo '

'.sprintf(__('Note: Understanding the %1$s Branched Cache Structure is a prerequisite to understanding how Dynamic Version Salts are added to the mix.', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '

'.__('A Version Salt gives you the ability to dynamically create multiple variations of the cache, and those dynamic variations will be served on subsequent visits; e.g., if a visitor has a specific cookie (of a certain value) they will see pages which were cached with that version (i.e., w/ that Version Salt: the value of the cookie). A Version Salt can really be anything.', 'comet-cache').'

'."\n"; + echo '

'.__('A Version Salt can be a single variable like $_COOKIE[\'my_cookie\'], or it can be a combination of multiple variables, like $_COOKIE[\'my_cookie\'].$_COOKIE[\'my_other_cookie\']. (When using multiple variables, please separate them with a dot, as shown in the example.)', 'comet-cache').'

'."\n"; + echo '

'.__('Experts could even use PHP ternary expressions that evaluate into something. For example: ((preg_match(\'/iPhone/i\', $_SERVER[\'HTTP_USER_AGENT\'])) ? \'iPhones\' : \'\'). This would force a separate version of the cache to be created for iPhones (e.g., PROTOCOL.HOST.URI[...]v/iPhones.html).', 'comet-cache').'

'."\n"; + echo '

'.__('For more documentation, please see Dynamic Version Salts.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + echo '

'.sprintf(__('Create a Dynamic Version Salt For %1$s?       150%% OPTIONAL', 'comet-cache'), esc_html(NAME)).'

'."\n"; + echo '
PROTOCOL.HOST.URI.v.
'."\n"; + echo '

'.__('Super Globals work here; $GLOBALS[\'table_prefix\'] is a popular one.
Or, perhaps a PHP Constant defined in /wp-config.php; such as WPLANG or DB_HOST.', 'comet-cache').'

'."\n"; + echo '

'.__('Important: your Version Salt is scanned for PHP syntax errors via phpCodeChecker.com. If errors are found, you\'ll receive a notice in the Dashboard.', 'comet-cache').'

'."\n"; + echo '

'.__('If you\'ve enabled a separate cache for each user (optional) that\'s perfectly OK. A Version Salt works with user caching too.', 'comet-cache').'

'."\n"; + echo '
'."\n"; + + echo '
'."\n"; + } + } +} diff --git a/src/includes/classes/MenuPageOptions.php b/src/includes/classes/MenuPageOptions.php index e716fb3..c609a46 100644 --- a/src/includes/classes/MenuPageOptions.php +++ b/src/includes/classes/MenuPageOptions.php @@ -6,12 +6,13 @@ * * @since 150422 Rewrite. */ -class MenuPageOptions extends MenuPage +class MenuPageOptions extends AbsBase { /** * Constructor. * * @since 150422 Rewrite. + * @since 17xxxx Refactor (breaking apart). */ public function __construct() { @@ -20,162 +21,8 @@ public function __construct() echo '
'."\n"; - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - if (is_multisite()) { - echo ''."\n"; - } - echo ' '."\n"; - - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo '
'."\n"; - - echo '
'."\n"; - if (IS_PRO && current_user_can($this->plugin->update_cap)) { - echo ' '.__('Newsletter', 'comet-cache').''."\n"; - echo ' '.__('Beta Testers', 'comet-cache').''."\n"; - } - if (!IS_PRO) { - echo ' '.__('Preview Pro Features', 'comet-cache').''."\n"; - echo ' '.__('Pro Upgrade', 'comet-cache').''."\n"; - } - echo '
'."\n"; - - echo ' '."\n"; - - echo ' '."\n"; - - if (IS_PRO) { - echo '
'."\n"; - echo sprintf(__('%1$s™ Pro v%2$s', 'comet-cache'), esc_html(NAME), esc_html(VERSION))."\n"; - echo '('.__('changelog', 'comet-cache').')'."\n"; - echo '
'."\n"; - } else { // For the lite version (default behavior). - echo '
'."\n"; - echo sprintf(__('%1$s™ v%2$s', 'comet-cache'), esc_html(NAME), esc_html(VERSION))."\n"; - echo '('.__('changelog', 'comet-cache').')'."\n"; - echo '
'."\n"; - } - echo ' '.esc_attr(__('Plugin Options', 'comet-cache')).''."\n"; - - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ + new MenuPage\Options\Heading(); - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - if (!empty($_REQUEST[GLOBAL_NS.'_updated'])) { - echo '
'."\n"; - echo ' '.__('Options updated successfully.', 'comet-cache')."\n"; - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_restored'])) { - echo '
'."\n"; - echo ' '.__('Default options successfully restored.', 'comet-cache')."\n"; - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_cache_wiped'])) { - echo '
'."\n"; - echo ' '.__('Cache wiped across all sites; re-creation will occur automatically over time.', 'comet-cache')."\n"; - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_cache_cleared'])) { - echo '
'."\n"; - if (is_multisite() && is_main_site()) { - echo ' '.__('Cache cleared for main site; re-creation will occur automatically over time.', 'comet-cache')."\n"; - } else { - echo ' '.__('Cache cleared for this site; re-creation will occur automatically over time.', 'comet-cache')."\n"; - } - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_wp_htaccess_add_failure'])) { - echo '
'."\n"; - echo ' '.sprintf(__('Failed to update your /.htaccess file automatically. Most likely a permissions error. Please make sure it has permissions 644 or higher (perhaps 666). Once you\'ve done this, please try saving the %1$s options again.', 'comet-cache'), esc_html(NAME))."\n"; - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_wp_htaccess_remove_failure'])) { - echo '
'."\n"; - echo ' '.sprintf(__('Failed to update your /.htaccess file automatically. Most likely a permissions error. Please make sure it has permissions 644 or higher (perhaps 666). Once you\'ve done this, please try saving the %1$s options again.', 'comet-cache'), esc_html(NAME))."\n"; - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_wp_htaccess_nginx_notice'])) { - echo '
'."\n"; - echo ' '.__('It appears that your server is running NGINX and does not support .htaccess rules. Please update your server configuration manually. If you\'ve already updated your NGINX configuration, you can safely ignore this message.', 'comet-cache')."\n"; - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_wp_config_wp_cache_add_failure'])) { - echo '
'."\n"; - echo ' '.__('Failed to update your /wp-config.php file automatically. Please add the following line to your /wp-config.php file (right after the opening <?php tag; on it\'s own line).
define( \'WP_CACHE\', true );
', 'comet-cache')."\n"; - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_wp_config_wp_cache_remove_failure'])) { - echo '
'."\n"; - echo ' '.__('Failed to update your /wp-config.php file automatically. Please remove the following line from your /wp-config.php file, or set WP_CACHE to a FALSE value.
define( \'WP_CACHE\', true );
', 'comet-cache')."\n"; - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_advanced_cache_add_failure'])) { - echo '
'."\n"; - if ($_REQUEST[GLOBAL_NS.'_advanced_cache_add_failure'] === 'advanced-cache') { - echo ' '.sprintf(__('Failed to update your /wp-content/advanced-cache.php file. Cannot write file: %1$s/%2$s-advanced-cache. Please be sure this directory exists (and that it\'s writable): %1$s. Please use directory permissions 755 or higher (perhaps 777). Once you\'ve done this, please try again.', 'comet-cache'), esc_html($this->plugin->cacheDir()), esc_html(mb_strtolower(SHORT_NAME)))."\n"; - } else { - echo ' '.__('Failed to update your /wp-content/advanced-cache.php file. Most likely a permissions error. Please create an empty file here: /wp-content/advanced-cache.php (just an empty PHP file, with nothing in it); give it permissions 644 or higher (perhaps 666). Once you\'ve done this, please try again.', 'comet-cache')."\n"; - } - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_advanced_cache_remove_failure'])) { - echo '
'."\n"; - echo ' '.__('Failed to remove your /wp-content/advanced-cache.php file. Most likely a permissions error. Please delete (or empty the contents of) this file: /wp-content/advanced-cache.php.', 'comet-cache')."\n"; - echo '
'."\n"; - } - if (!empty($_REQUEST[GLOBAL_NS.'_ua_info_dir_population_failure'])) { - echo '
'."\n"; - echo ' '.sprintf(__('Failed to populate User-Agent detection files for Mobile-Adaptive Mode. User-Agent detection files are pulled from a remote location so you\'ll always have the most up-to-date information needed for accurate detection. However, it appears the remote source of this information is currently unvailable. Please wait 15 minutes, then try saving your %1$s options again.', 'comet-cache'), esc_html(NAME))."\n"; - echo '
'."\n"; - } - if (!IS_PRO && $this->plugin->isProPreview()) { - echo '
'."\n"; - echo ''.__('close', 'comet-cache').' '."\n"; - echo ' '.sprintf(__('Pro Features (Preview) ~ New option panels below. Please explore before upgrading .
NOTE: the free version of %1$s (this lite version) is more-than-adequate for most sites. Please upgrade only if you desire advanced features or would like to support the developer.', 'comet-cache'), esc_html(NAME))."\n"; - echo '
'."\n"; - } - if (!$this->plugin->options['enable']) { - echo '
'."\n"; - echo ' '.sprintf(__('%1$s is currently disabled; please review options below.', 'comet-cache'), esc_html(NAME))."\n"; - echo '
'."\n"; - } /* ----------------------------------------------------------------------------------------- */ echo '
'."\n"; @@ -187,98 +34,9 @@ public function __construct() ' '.sprintf(__('Review these basic options and %1$s™ will be ready-to-go!', 'comet-cache'), esc_html(NAME)).''. ''; - /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Enable/Disable', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo '

'.sprintf(__('%1$s™ = SPEED!!', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

   

'."\n"; - echo '

'.sprintf(__('HUGE Time-Saver: Approx. 95%% of all WordPress sites running %1$s, simply enable it here; and that\'s it :-) No further configuration is necessary (really). All of the other options (down below) are already tuned for the BEST performance on a typical WordPress installation. Simply enable %1$s here and click "Save All Changes". If you get any warnings please follow the instructions given. Otherwise, you\'re good . This plugin is designed to run just fine like it is. Take it for a spin right away; you can always fine-tune things later if you deem necessary.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'."\n"; - echo ' '."\n"; - echo '

'.sprintf(__('How Can I Tell %1$s is Working?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('First of all, please make sure that you\'ve enabled %1$s here; then scroll down to the bottom of this page and click "Save All Changes". All of the other options (below) are already pre-configured for typical usage. Feel free to skip them all for now. You can go back through all of these later and fine-tune things the way you like them.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('Once %1$s has been enabled, you\'ll need to log out (and/or clear browser cookies). By default, cache files are NOT served to visitors who are logged-in, and that includes you too ;-) Cache files are NOT served to recent comment authors either. If you\'ve commented (or replied to a comment lately); please clear your browser cookies before testing.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('To verify that %1$s is working, navigate your site like a normal visitor would. Right-click on any page (choose View Source), then scroll to the very bottom of the document. At the bottom, you\'ll find comments that show %1$s stats and information. You should also notice that page-to-page navigation is lightning fast now that %1$s is running; and it gets faster over time!', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Update Credentials', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - - echo ' '."\n"; - - echo '

'.__('Authentication for Automatic Updates', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('%1$s Pro is a premium product available for purchase @ cometcache.com. In order to connect with our update servers, you must supply your License Key. Your License Key is located under "My Account" when you log in @ cometcache.com. This will authenticate your copy of %1$s Pro; providing you with access to the latest version. You only need to enter these credentials once. %1$s Pro will save them in your WordPress database; making future upgrades even easier. If you prefer to upgrade manually, see this article.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'."\n"; - - echo '

'.sprintf(__('Username', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('License Key', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - - if ((!defined('DISALLOW_FILE_MODS') || !DISALLOW_FILE_MODS) && !apply_filters('automatic_updater_disabled', defined('AUTOMATIC_UPDATER_DISABLED') && AUTOMATIC_UPDATER_DISABLED)) { - // See: and note that `automatic_updater_disabled` is a core filter. - echo '
'."\n"; - echo '

'.__('Automatic Background Updates', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Enable this if you\'d like %1$s to download and install bug fixes and security updates automatically in the background. Requires a valid license key in the field above.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - } - echo '
'."\n"; - echo '

'.__('Beta Program', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If you would like to participate in our beta program and receive new features and bug fixes before they are released to the public, %1$s can include Release Candidates when checking for automatic updates. Release Candidates are almost-ready-for-production and have already been through many internal test runs. Our team runs the latest Release Candidate on all of our production sites, but that doesn\'t mean you\'ll want to do the same. :-) Please report any issues with Release Candidates on GitHub.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.__('How will I know that I\'m running a Release Candidate?
If you\'re running a Release Candidate, the version ends with -RC, e.g., Comet Cache™ Pro v151201-RC.', 'comet-cache').'

'."\n"; - echo '

'.__('Email Alternative: Instead, if you\'d just like to receive updates about Release Candidates (via email), including a Release Candidate changelog, please sign up for the beta testers mailing list.', 'comet-cache').'

'."\n"; - - echo '
'."\n"; - - echo '
'."\n"; - } - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Plugin Deletion Safeguards', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Uninstall on Plugin Deletion; or Safeguard Options?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Tip: By default, if you delete %1$s using the plugins menu in WordPress, nothing is lost. However, if you want to completely uninstall %1$s you should set this to Yes and THEN deactivate & delete %1$s from the plugins menu in WordPress. This way %1$s will erase your options for the plugin, erase directories/files created by the plugin, remove the advanced-cache.php file, terminate CRON jobs, etc. It erases itself from existence completely.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; + new MenuPage\Options\Enable(); + new MenuPage\Options\ProUpdater(); + new MenuPage\Options\Safeguards(); /* ----------------------------------------------------------------------------------------- */ @@ -287,1024 +45,36 @@ public function __construct() ' '.__('Recommended for advanced site owners only; already pre-configured for most WP installs.', 'comet-cache').''. ''; - /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Manual Cache Clearing', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo '

'.__('Clearing the Cache Manually', 'comet-cache').'

'."\n"; - echo ' '."\n"; - echo '

'.sprintf(__('Once %1$s is enabled, you will find this new option in your WordPress Admin Bar (screenshot on right). Clicking this button will clear the cache and you can start fresh at anytime (e.g., you can do this manually; and as often as you wish).', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('Depending on the structure of your site, there could be many reasons to clear the cache. However, the most common reasons are related to Post/Page edits or deletions, Category/Tag edits or deletions, and Theme changes. %1$s handles most scenarios all by itself. However, many site owners like to clear the cache manually; for a variety of reasons (just to force a refresh).', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'."\n"; - - if (is_multisite()) { - echo '
'."\n"; - echo '

'.__('Also allow Child Sites in a Network to clear the cache from their Admin Bar?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('In a Multisite Network, each child site can clear its own cache. If you want child sites to see the "Clear Cache" button in their WordPress Admin Bar, you can specify a comma-delimited list of Roles and/or Capabilities that are allowed. For example, if I want Administrators to be capable of clearing the cache from their Admin Bar, I could enter administrator here. If I also want to allow Editors, I can use a comma-delimited list: administrator,editor. Or, I could use a single Capability of: edit_others_posts; which covers both Administrators & Editors at the same time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('Note: As a security measure, in addition to the Role(s) and/or Capabilities that you list here, each child site owner must also have the ability to %1$s.', 'comet-cache'), esc_html(IS_PRO ? $this->plugin->clear_min_cap : 'edit_posts')).'

'."\n"; - echo '
'."\n"; - } else { - echo '
'."\n"; - echo '

'.__('Also allow others to clear the cache from their Admin Bar?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If you want others to see the "Clear Cache" button in their WordPress Admin Bar, you can specify a comma-delimited list of Roles and/or Capabilities that are allowed. For example, if I want Editors to be capable of clearing the cache from their Admin Bar, I could enter editor here. If I also want to allow Authors, I can use a comma-delimited list: editor,author. Or, I could use a single Capability of: publish_posts; which covers both Editors & Authors at the same time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('Note: As a security measure, in addition to the Role(s) and/or Capabilities that you list here, each user must also have the ability to %1$s.', 'comet-cache'), esc_html(IS_PRO ? $this->plugin->clear_min_cap : 'edit_posts')).'

'."\n"; - echo '
'."\n"; - } - if ($this->plugin->functionIsPossible('opcache_reset')) { - echo '
'."\n"; - echo '

'.__('Clear the PHP OPcache Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If you clear the cache manually, do you want %1$s to clear the PHP OPcache too? This is not necessary, but if you want a truly clean start, this will clear all PHP files in the server\'s opcode cache also. Note: If you don\'t already know what the PHP OPcache is, it is suggested that you leave this disabled. It really is not necessary. This is just an added feature for advanced users.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - } - if ($this->plugin->functionIsPossible('s2clean')) { - echo '
'."\n"; - echo '

'.__('Clear the s2Clean Cache Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If the s2Clean theme is installed, and you clear the cache manually, %1$s can clear the s2Clean Markdown cache too (if you\'ve enabled Markdown processing with s2Clean).', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - } - echo '
'."\n"; - echo '

'.__('Evaluate Custom PHP Code when Clearing the Cache?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If you have any custom routines you\'d like to process when the cache is cleared manually, please enter PHP code here. If your PHP code outputs a message, it will be displayed along with any other notes from %1$s itself. This feature is intended for developers, and it may come in handy if you need to clear any system caches not already covered by %1$s configuration options.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.__('Example: <?php apc_clear_cache(); echo \'<p>Also cleared APC cache.</p>\'; ?>', 'comet-cache').'

'."\n"; - - echo '
'."\n"; - echo '

'.__('Clear the CDN Cache Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If you clear the cache manually, do you want %1$s to automatically bump the CDN invalidation counter too? i.e., automatically increment the ?%2$s=[counter] in all static CDN URLs?', 'comet-cache'), esc_html(NAME), esc_html($this->plugin->options['cdn_invalidation_var'])).'

'."\n"; - echo '

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - } - /* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Automatic Cache Clearing', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - - echo '

'.__('Clearing the Cache Automatically', 'comet-cache').'

'."\n"; - echo ' '."\n"; - echo '

'.sprintf(__('This is built into the %1$s plugin; i.e., this functionality is "always on". If you edit a Post/Page (or delete one), %1$s will automatically clear the cache file(s) associated with that content. This way a new updated version of the cache will be created automatically the next time this content is accessed. Simple updates like this occur each time you make changes in the Dashboard, and %1$s will notify you of these as they occur. %1$s monitors changes to Posts (of any kind, including Pages), Categories, Tags, Links, Themes (even Users), and more.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - echo '

'."\n"; - echo '
'."\n"; - } - echo '
'."\n"; - echo '

'.__('Primary Page Options', 'comet-cache').'

'."\n"; - - echo '

'.__('Auto-Clear Designated "Home Page" Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('On many sites, the Home Page (aka: the Front Page) offers an archive view of all Posts (or even Pages). Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the "Home Page"?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.__('Auto-Clear Designated "Posts Page" Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('On many sites, the Posts Page (aka: the Blog Page) offers an archive view of all Posts (or even Pages). Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the "Posts Page"?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - - echo '
'."\n"; - echo '

'.__('Author, Archive, and Tag/Term Options', 'comet-cache').'

'."\n"; - - echo '

'.__('Auto-Clear "Author Page" Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('On many sites, each author has a related "Author Page" that offers an archive view of all posts associated with that author. Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the related "Author Page"?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - - echo '

'.__('Auto-Clear "Category Archives" Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('On many sites, each post is associated with at least one Category. Each category then has an archive view that contains all the posts within that category. Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the associated Category archive views?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - - echo '

'.__('Auto-Clear "Tag Archives" Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('On many sites, each post may be associated with at least one Tag. Each tag then has an archive view that contains all the posts assigned that tag. Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the associated Tag archive views?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - - echo '

'.__('Auto-Clear "Date-Based Archives" Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Date-Based Archives allow visitors to browse Posts by the year, month, or day they were originally published. If a single Post (of any type) is changed in some way; and %1$s clears/resets the cache for that Post, would you like %1$s to also clear any existing cache files for Dated-Based Archives that match the publication time?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; + new MenuPage\Options\ManualClearing(); + new MenuPage\Options\AutomaticClearing(); - echo '

'.__('Auto-Clear "Custom Term Archives" Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Most sites do not use any custom Terms so it should be safe to leave this disabled. However, if your site uses custom Terms and they have their own Term archive views, you may want to clear those when the associated post is cleared. Therefore, if a single Post/Page is changed in some way; and %1$s clears/resets the cache for a single Post/Page, would you like %1$s to also clear any existing cache files for the associated Tag archive views?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; + new MenuPage\Options\Statistics(); + new MenuPage\Options\Directory(); + new MenuPage\Options\Memcached(); + new MenuPage\Options\Expiration(); - echo '

'.__('Auto-Clear "Custom Post Type Archives" Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Most sites do not use any Custom Post Types so it should be safe to disable this option. However, if your site uses Custom Post Types and they have their own Custom Post Type archive views, you may want to clear those when any associated post is cleared. Therefore, if a single Post with a Custom Post Type is changed in some way; and %1$s clears/resets the cache for that post, would you like %1$s to also clear any existing cache files for the associated Custom Post Type archive views?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - - echo '
'."\n"; - echo '

'.__('Feed-Related Options', 'comet-cache').'

'."\n"; - - echo '

'.__('Auto-Clear "RSS/RDF/ATOM Feeds" Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If you enable Feed Caching (below), this can be quite handy. If enabled, when you update a Post/Page, approve a Comment, or make other changes where %1$s can detect that certain types of Feeds should be cleared to keep your site up-to-date, then %1$s will do this for you automatically. For instance, the blog\'s master feed, the blog\'s master comments feed, feeds associated with comments on a Post/Page, term-related feeds (including mixed term-related feeds), author-related feeds, etc. Under various circumstances (i.e., as you work in the Dashboard) these can be cleared automatically to keep your site up-to-date.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - - echo '
'."\n"; - echo '

'.__('Sitemap-Related Options', 'comet-cache').'

'."\n"; - - echo '

'.__('Auto-Clear "XML Sitemaps" Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If you\'re generating XML Sitemaps with a plugin like Google XML Sitemaps, you can tell %1$s to automatically clear the cache of any XML Sitemaps whenever it clears a Post/Page. Note: This does NOT clear the XML Sitemap itself of course, only the cache. The point being, to clear the cache and allow changes to a Post/Page to be reflected by a fresh copy of your XML Sitemap; sooner rather than later.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '
'."\n"; - echo '

'.__('XML Sitemap Patterns (one per line): A default value of /sitemap**.xml covers all XML Sitemaps for most installations. However, you may customize this further if you deem necessary. Please list one pattern per line. XML Sitemap Pattern searches are performed against the REQUEST_URI. A wildcard ** (double asterisk) can be used when necessary; e.g., /sitemap**.xml. Note that ** = 0 or more characters of any kind, including / slashes. * (a single asterisk) means 0 or more characters that are NOT a slash /. Your patterns must match from beginning to end; i.e., the special chars: ^ (beginning of string) and $ (end of the string) are always on for these patterns (i.e., applied internally). For that reason, if you want to match part of a URI, use ** to match anything before and/or after the fragment you\'re searching for. For example, **/sitemap**.xml will match any URI containing /sitemap (anywhere), so long as the URI also ends with .xml. On the other hand, /sitemap*.xml will only match URIs that begin with /sitemap, and it will only match URIs ending in .xml in that immediate directory — bypassing any inside nested sub-directories. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - if (is_multisite()) { - echo '

'.__('In a Multisite Network, each child blog (whether it be a sub-domain, a sub-directory, or a mapped domain); will automatically change the leading http://[sub.]domain/[sub-directory] used in pattern matching. In short, there is no need to add sub-domains or sub-directories for each child blog in these patterns. Please include only the REQUEST_URI (i.e., the path) which leads to the XML Sitemap on all child blogs in the network.', 'comet-cache').'

'."\n"; - } - echo '
'."\n"; - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - echo '

'.__('Misc. Auto-Clear Options', 'comet-cache').'

'."\n"; - echo '

'.__('Auto-Clear Custom URL Patterns Too?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Auto-Clear Custom URL Patterns (one per line): When you update a Post/Page, approve a Comment, etc., %1$s will detect that a Post/Page cache should be cleared to keep your site up-to-date. When this occurs, %1$s can also clear a list of custom URLs that you enter here. Please list one URL per line. A wildcard * character can be used when necessary; e.g., https://example.com/category/abc/**. Note that ** (double asterisk) means 0 or more characters of any kind, including / slashes. * (a single asterisk) means 0 or more characters that are NOT a slash /. Your patterns must match from beginning to end; i.e., the special chars: ^ (beginning of string) and $ (end of the string) are always on for these patterns (i.e., applied internally). For that reason, if you want to match part of a URL, use ** to match anything before and/or after the fragment you\'re searching for. For example, https://**/category/abc/** will find all URLs containing /category/abc/ (anywhere); whereas https://*/category/abc/* will match URLs on any domain, but the path must then begin with /category/abc/ and the pattern will only match paths in that immediate directory — bypassing any additional paths in sub-directories. To learn more about this syntax, please see this KB article.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.__('Note: Relative URLs (e.g., /name-of-post) should NOT be used. Each entry above should start with http:// or https:// and include a fully qualified domain name (or wildcard characters in your pattern that will match the domain).', 'comet-cache').'

'."\n"; - } - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Cache-Related Statistics', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - if ($this->plugin->isProPreview()) { - echo ' '; - } - echo ' '."\n"; - echo '

'.__('Enable Cache-Related Stats & Charts?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('%1$s can collect and display cache-related statistics (including charts). Stats are displayed in the WordPress Admin Bar, and also in your Dashboard under: %1$s → Stats/Charts. Cache-related stats provide you with a quick look at what\'s happening behind-the-scenes. Your site grows faster and faster as the cache grows larger in size.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('Note: %1$s does a great job of collecting stats, in ways that don\'t cause a performance issue. In addition, as your cache grows larger than several hundred files in total size, statistics are collected less often and at longer intervals. All of that being said, if you run a VERY large site (e.g., more than 20K posts), you might want to disable stats collection in favor of blazing fast speeds not impeded by any directory scans needed to collect stats.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - echo '

'.__('Show Stats in the WordPress Admin Bar?', 'comet-cache').'

'."\n"; - echo '

'."\n"; - if (is_multisite()) { - echo '
'."\n"; - echo '

'.__('Allow Child Sites in a Network to See Stats in Admin Bar?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('In a Multisite Network, each child site has stats of its own. If you want child sites to see cache-related stats in their WordPress Admin Bar, you can specify a comma-delimited list of Roles and/or Capabilities that are allowed to see stats. For example, if I want the Administrator to see stats in their Admin Bar, I could enter administrator here. If I also want to show stats to Editors, I can use a comma-delimited list: administrator,editor. Or, I could use a single Capability of: edit_others_posts; which covers both Administrators & Editors at the same time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('Note: As a security measure, in addition to the Role(s) and/or Capabilities that you list here, each child site owner must also have the ability to %1$s.', 'comet-cache'), esc_html(IS_PRO ? $this->plugin->stats_min_cap : 'edit_posts')).'

'."\n"; - echo '
'."\n"; - } else { - echo '
'."\n"; - echo '

'.__('Allow Others to See Stats in Admin Bar?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If you want others to see cache-related stats in their WordPress Admin Bar, you can specify a comma-delimited list of Roles and/or Capabilities that are allowed to see stats. For example, if I want Editors to see stats in their Admin Bar, I could enter editor here. If I also want to show stats to Authors, I can use a comma-delimited list: editor,author. Or, I could use a single Capability of: publish_posts; which covers both Editors & Authors at the same time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('Note: As a security measure, in addition to the Role(s) and/or Capabilities that you list here, each user must also have the ability to %1$s.', 'comet-cache'), esc_html(IS_PRO ? $this->plugin->stats_min_cap : 'edit_posts')).'

'."\n"; - echo '
'."\n"; - } - echo '
'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - } - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Cache Directory', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo '

'.__('Base Cache Directory (Must be Writable; i.e., Permissions 755 or Higher)', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('This is where %1$s will store the cached version of your site. If you\'re not sure how to deal with directory permissions, don\'t worry too much about this. If there is a problem, %1$s will let you know about it. By default, this directory is created by %1$s and the permissions are setup automatically. In most cases there is nothing more you need to do.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'.esc_html(WP_CONTENT_DIR).'//
'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Cache Expiration Time', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Automatic Expiration Time (Max Age)', 'comet-cache').'

'."\n"; - echo '

'.__('If you don\'t update your site much, you could set this to 6 months and optimize everything even further. The longer the Cache Expiration Time is, the greater your performance gain. Alternatively, the shorter the Expiration Time, the fresher everything will remain on your site. A default value of 7 days (recommended); is a good conservative middle-ground.', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Keep in mind that your Expiration Time is only one part of the big picture. %1$s will also clear the cache automatically as changes are made to the site (i.e., you edit a post, someone comments on a post, you change your theme, you add a new navigation menu item, etc., etc.). Thus, your Expiration Time is really just a fallback; e.g., the maximum amount of time that a cache file could ever possibly live.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('All of that being said, you could set this to just 60 seconds and you would still see huge differences in speed and performance. If you\'re just starting out with %1$s (perhaps a bit nervous about old cache files being served to your visitors); you could set this to something like 30 minutes and experiment with it while you build confidence in %1$s. It\'s not necessary to do so, but many site owners have reported this makes them feel like they\'re more-in-control when the cache has a short expiration time. All-in-all, it\'s a matter of preference .', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.__('Tip: the value that you specify here MUST be compatible with PHP\'s strtotime() function. Examples: 30 seconds, 2 hours, 7 days, 6 months, 1 year.', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Note: %1$s will never serve a cache file that is older than what you specify here (even if one exists in your cache directory; stale cache files are never used). In addition, a WP Cron job will automatically cleanup your cache directory (once per hour); purging expired cache files periodically. This prevents a HUGE cache from building up over time, creating a potential storage issue.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - - echo '
'."\n"; - - echo '

'.__('Cache Cleanup Schedule', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If you have an extremely large site and you lower the default Cache Expiration Time of 7 days, expired cache files can build up more quickly. By default, %1$s cleans up expired cache files via WP Cron at an hourly interval, but you can tell %1$s to use a custom Cache Cleanup Schedule below to run the cleanup process more or less frequently, depending on your specific needs.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - - if (IS_PRO || $this->plugin->isProPreview()) { - $_sys_getloadavg_unavailable = ($this->plugin->isProPreview() ? false : !$this->plugin->sysLoadAverages()); - echo '
'."\n"; - echo '
'."\n"; - echo '

'.__('Disable Cache Expiration If Server Load Average is High?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('If you have high traffic at certain times of the day, %1$s can be told to check the current load average via sys_getloadavg(). If your server\'s load average has been high in the last 15 minutes or so, cache expiration is disabled automatically to help reduce stress on the server; i.e., to avoid generating a new version of the cache while the server is very busy.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('To enable this functionality you should first determine what a high load average is for your server. If you log into your machine via SSH you can run the top command to get a feel for what a high load average looks like. Once you know the number, you can enter it in the field below; e.g., 1.05 might be a high load average for a server with one CPU. See also: Understanding Load Average', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - if ($_sys_getloadavg_unavailable && mb_stripos(PHP_OS, 'win') === 0) { // See: - echo '

'.__('Note: It appears that your server is running Windows. The sys_getloadavg() function has not been implemented in PHP for Windows servers yet.', 'comet-cache').'

'."\n"; - } elseif ($_sys_getloadavg_unavailable && mb_stripos(PHP_OS, 'win') !== 0) { - echo '

'.__('Note: sys_getloadavg() has been disabled by your web hosting company or is not available on your server.', 'comet-cache').'

'."\n"; - } - echo '
'."\n"; - } - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Client-Side Cache', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Allow Double-Caching In The Client-Side Browser?', 'comet-cache').'

'."\n"; - echo '

'.__('Recommended setting: No (for membership sites, very important). Otherwise, Yes would be better (if users do NOT log in/out of your site).', 'comet-cache').'

'."\n"; - echo '

'.__('This option is NOT the same as "Leverage Browser Caching", which refers to the caching of static resources in the browser (e.g., images, CSS, JS). This Client-Side Cache option is different in that it controls the caching of page content in the browser, i.e., the caching of HTML content generated by PHP itself, which is generally NOT static. If you\'re looking to Leverage Browser Caching for static resources (highly recommended), see the Apache Optimizations panel below.', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('%1$s handles content delivery through its ability to communicate with a browser using PHP. If you allow a browser to (cache) the caching system itself, you are momentarily losing some control; and this can have a negative impact on users that see more than one version of your site; e.g., one version while logged-in, and another while NOT logged-in. For instance, a user may log out of your site, but upon logging out they report seeing pages on the site which indicate they are STILL logged in (even though they\'re not — that\'s bad). This can happen if you allow a client-side cache, because their browser may cache web pages they visited while logged into your site which persist even after logging out. Sending no-cache headers will work to prevent this issue.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.__('All of that being said, if all you care about is blazing fast speed and users don\'t log in/out of your site (only you do); you can safely set this to Yes (recommended in this case). Allowing a client-side browser cache will improve speed and reduce outgoing bandwidth when this option is feasible.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Tip: Setting this to No is highly recommended when running a membership plugin like s2Member (as one example). In fact, many plugins like s2Member will send nocache_headers() on their own, so your configuration here will likely be overwritten when you run such plugins (which is better anyway). In short, if you run a membership plugin, you should NOT allow a client-side browser cache.', 'comet-cache').'

'."\n"; - echo '

'.__('Tip: Setting this to No will NOT impact static content; e.g., CSS, JS, images, or other media. This setting pertains only to dynamic PHP scripts which produce content generated by WordPress.', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Advanced Tip: if you have this set to No, but you DO want to allow a few special URLs to be cached by the browser; you can add this parameter to your URL ?%2$sABC=1. This tells %1$s that it\'s OK for the browser to cache that particular URL. In other words, the %2$sABC=1 parameter tells %1$s NOT to send no-cache headers to the browser.', 'comet-cache'), esc_html(NAME), esc_html(mb_strtolower(SHORT_NAME))).'

'."\n"; - echo '
'."\n"; - echo '
'."\n"; - echo '

'.__('Exclusion Patterns for Client-Side Caching', 'comet-cache').'

'."\n"; - echo '

'.__('When you enable Client-Side Caching above, you may want to prevent certain pages on your site from being cached by a client-side browser. This is where you will enter those if you need to (one per line). Searches are performed against the REQUEST_URI; i.e., /path/?query (caSe insensitive). So, don\'t put in full URLs here, just word fragments found in the file path (or query string) is all you need, excluding the http:// and domain name. A wildcard * character can also be used when necessary; e.g., /category/abc-followed-by-* (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Tip: let\'s use this example URL: http://www.example.com/post/example-post-123. To exclude this URL, you would put this line into the field above: /post/example-post-123. Or, you could also just put in a small fragment, like: example or example-*-123 and that would exclude any URI containing that word fragment.', 'comet-cache').'

'."\n"; - echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Logged-In Users', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Caching Enabled for Logged-In Users & Comment Authors?', 'comet-cache').'

'."\n"; - echo '

'.__('This should almost always be set to No. Most sites don\'t cache content generated while a user is logged-in. Doing so could result in a cache of dynamic content generated specifically for a particular user, where the content being cached may contain details that pertain only to the user that was logged-in when the cache was generated. In short, don\'t turn this on unless you know what you\'re doing. Note also that most sites get most (sometimes all) of their traffic from users who are not logged-in. When a user is logged-in, disabling the cache is generally a good idea because a logged-in user has a session open with your site. The content they view should remain very dynamic in this scenario.', 'comet-cache').'

'."\n"; - echo ' '."\n"; - echo '

'.sprintf(__('Exception (Membership Sites): If you run a site with many users and the majority of your traffic comes from users who are logged-in, choose: Yes (maintain separate cache). %1$s will operate normally, but when a user is logged-in the cache is user-specific. %1$s will intelligently refresh the cache when/if a user submits a form on your site with the GET or POST method. Or, if you make changes to their account (or another plugin makes changes to their account); including user option|meta additions, updates & deletions too. However, please note that enabling this feature (i.e., user-specific cache entries) will eat up much more disk space. That being said, the benefits of this feature for most sites will outweigh the disk overhead; i.e., it\'s not an issue in most cases. In other words, unless you\'re short on disk space, or you have thousands of users, the disk overhead is neglible.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - if ($this->plugin->options['when_logged_in'] === '1' && $this->plugin->applyWpFilters(GLOBAL_NS.'_when_logged_in_no_admin_bar', true)) { - echo '

'.sprintf(__('Warning: Whenever you enable caching for logged-in users (without a separate cache for each user), the WordPress Admin Bar must be disabled to prevent one user from seeing another user\'s details in the Admin Bar. Given your current configuration, %1$s will automatically hide the WordPress Admin Bar on the front-end of your site.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - } - echo '

'.sprintf(__('Note: %1$s includes comment authors as part of it\'s logged-in user check. This way comment authors will be able to see updates to comment threads immediately. And, so that any dynamically-generated messages displayed by your theme will work as intended. In short, %1$s thinks of a comment author as a logged-in user, even though technically they are not. Users who gain access to password-protected Posts/Pages are also considered by the logged-in user check.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - - echo '
'."\n"; - - echo '
'."\n"; - echo '

'.__('Cache Pages Containing Nonce Values in Markup?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('This should almost always be set to Yes. WordPress injects Nonces (numbers used once) into the markup on any given page that a logged-in user lands on. These Nonce values are generally used to improve security when actions are taken by a user; e.g., posting a form or clicking a link that performs an action. If you set this to No, any page containing an Nonce will bypass the cache and be served dynamically (a performance hit). Even the Admin Bar in WordPress injects Nonce values. That\'s reason enough to leave this at the default value of Yes; i.e., so Nonce values in the markup don\'t result in a cache bypass. In short, don\'t set this to No unless you know what you\'re doing.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('Note: Nonce values in WordPress have a limited lifetime. They can expire just 12 hours after they were first generated. For this reason, %1$s will automatically force cache files containing Nonce values to expire once they are 12+ hours old; i.e., a new request for an expired page containing Nonce values will be rebuilt automatically, generating new Nonces that will continue to operate as expected. This rule is enforced no matter what your overall Cache Expiration Time is set to.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'."\n"; - echo '

'.__('Static CDN Filters Enabled for Logged-In Users & Comment Authors?', 'comet-cache').'

'."\n"; - echo '

'.__('While this defaults to a value of No, it should almost always be set to Yes. This value defaults to No only because Logged-In User caching (see above) defaults to No and setting this value to Yes by default can cause confusion for some site owners. Once you understand that Static CDN Filters can be applied safely for all visitors (logged-in or not logged-in), please choose Yes in the dropdown below. If you are not using Static CDN Filters, the value below is ignored.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Note: Static CDN Filters serve static resources. Static resources, are, simply put, static. Thus, it is not a problem to cache these resources for any visitor (logged-in or not logged-in). To avoid confusion, this defaults to a value of No, and we ask that you set it to Yes on your own so that you\'ll know to expect this behavior; i.e., that static resources will always be served from the CDN (logged-in or not logged-in) even though Logged-In User caching may be disabled above.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - echo '

'.__('Enable HTML Compression for Logged-In Users?', 'comet-cache').'

'."\n"; - echo '

'.__('Disabled by default. This setting is only applicable when HTML Compression is enabled. HTML Compression should remain disabled for logged-in users because the user-specific cache has a much shorter Time To Live (TTL) which means their cache is likely to expire more quickly than a normal visitor. Rebuilding the HTML Compressor cache is time-consuming and doing it too frequently will actually slow things down for them. For example, if you\'re logged into the site as a user and you submit a form, that triggers a clearing of the cache for that user, including the HTML Compressor cache. Lots of little actions you take can result in a clearing of the cache. This shorter TTL is not ideal when running the HTML Compressor because it does a deep analysis of the page content and the associated resources in order to intelligently compress things. For logged-in users, it is better to skip that extra work and just cache the HTML source as-is, avoiding that extra overhead. In short, do NOT turn this on unless you know what you\'re doing.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '
'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - } - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('GET Requests', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - - echo ' '."\n"; - echo '

'.__('Caching Enabled for GET (Query String) Requests?', 'comet-cache').'

'."\n"; - echo '

'.__('This should almost always be set to No. UNLESS, you\'re using unfriendly Permalinks; i.e., if all of your URLs contain a query string (like ?p=123). In such a case, you should set this option to Yes. However, it\'s better to update your Permalink options and use friendly Permalinks, which also optimizes your site for search engines. Again, if you\'re using friendly Permalinks (recommended) you can leave this at the default value of No.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('Advanced Tip: If you are not caching GET requests (recommended), but you do want to allow some special URLs that include query string parameters to be cached, you can add this special parameter to any URL ?%2$sAC=1. This tells %1$s that it\'s OK to cache that particular URL, even though it contains query string arguments. If you are caching GET requests and you want to force %1$s to not cache a specific request, you can add this special parameter to any URL ?%2$sAC=0.', 'comet-cache'), esc_html(NAME), esc_html(mb_strtolower(SHORT_NAME))).'

'."\n"; - echo '

'.__('Other Request Types: POST requests (i.e., forms with method="post") are always excluded from the cache, which is the way it should be. Any POST/PUT/DELETE request should never, ever be cached. CLI and self-serve requests are also excluded from the cache automatically. A CLI request is one that comes from the command line; commonly used by CRON jobs and other automated routines. A self-serve request is an HTTP connection established from your site, to your site. For instance, a WP Cron job, or any other HTTP request that is spawned not by a user, but by the server itself.', 'comet-cache').'

'."\n"; - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - echo '
'."\n"; - echo '

'.__('List of GET Variable Names to Ignore', 'comet-cache').'

'."\n"; - echo '

'.__('You can enter one variable name per line. Each of the variable names that you list here will be ignored entirely; i.e., not considered when caching any given page, and not considered when serving any page that is already cached. For example, many sites use Google Analytics and there are GET request variables used by Google Analytics, which are read by client-side JavaScript only. Those GET variables can be ignored altogether when it comes to the cache algorithm — speeding up your site even further.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('A wildcard * character can also be used when necessary; e.g., utm_* (where * = 0 or more characters that are NOT a slash /). To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - } - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ + new MenuPage\Options\ClientSide(); + new MenuPage\Options\UserRequests(); + new MenuPage\Options\GetRequests(); + new MenuPage\Options\Nf404Requests(); + new MenuPage\Options\FeedRequests(); - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('404 Requests', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Caching Enabled for 404 Requests?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('When this is set to No, %1$s will ignore all 404 requests and no cache file will be served. While this is fine for most site owners, caching the 404 page on a high-traffic site may further reduce server load. When this is set to Yes, %1$s will cache the 404 page (see Creating an Error 404 Page) and then serve that single cache file to all future 404 requests.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('How does %1$s cache 404 requests? %1$s will create a special cache file (----404----.html, see Advanced Tip below) for the first 404 request and then symlink future 404 requests to this special cache file. That way you don\'t end up with lots of 404 cache files that all contain the same thing (the contents of the 404 page). Instead, you\'ll have one 404 cache file and then several symlinks (i.e., references) to that 404 cache file.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.__('Advanced Tip: The default 404 cache filename (----404----.html) is designed to minimize the chance of a collision with a cache file for a real page with the same name. However, if you want to override this default and define your own 404 cache filename, you can do so by adding define(\'COMET_CACHE_404_CACHE_FILENAME\', \'your-404-cache-filename\'); to your wp-config.php file (note that the .html extension should be excluded when defining a new filename).', 'comet-cache').'

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Feed Caching', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Caching Enabled for RSS, RDF, Atom Feeds?', 'comet-cache').'

'."\n"; - echo '

'.__('This should almost ALWAYS be set to No. UNLESS, you\'re sure that you want to cache your feeds. If you use a web feed management provider like Google® Feedburner and you set this option to Yes, you may experience delays in the detection of new posts. NOTE: If you do enable this, it is highly recommended that you also enable automatic Feed Clearing too. Please see the section above: "Automatic Cache Clearing". Find the sub-section titled: "Auto-Clear RSS/RDF/ATOM Feeds".', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Note: This option affects all feeds served by WordPress, including the site feed, the site comment feed, post-specific comment feeds, author feeds, search feeds, and category and tag feeds. See also: WordPress Feeds.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - $exclude_hosts_option_enable = is_multisite() && - ((defined('SUBDOMAIN_INSTALL') && SUBDOMAIN_INSTALL) || $this->plugin->canConsiderDomainMapping()); - - if ($this->plugin->applyWpFilters(GLOBAL_NS.'_exclude_hosts_option_enable', $exclude_hosts_option_enable)) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Host Exclusions', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo '

'.__('Don\'t Cache These Special Host Exclusion Patterns?', 'comet-cache').'

'."\n"; - echo '

'.__('If there are specific domains that should not be cached, you can enter them here so they are excluded automatically. The easiest way to exclude a host is to enter the full domain name on a line of it\'s own in the field below, e.g., site1.example.com.', 'comet-cache').'

'."\n"; - echo '

'.__('This field also supports Watered-Down Regex syntax, which means that you can also exclude a pattern like: *.example.com or *.example.*. So for instance, if you wanted to exclude all child sites and only cache pages on the Main Site of a Network installation, you could exclude all sub-domains using: *.mynetwork.com. That excludes all sub-domains, but not mynetwork.com by itself.', 'comet-cache').'

'."\n"; - - echo '

'."\n"; - - echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; - - echo '
'."\n"; - echo '
'."\n"; - } - - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('URI Exclusions', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo '

'.__('Don\'t Cache These Special URI Exclusion Patterns?', 'comet-cache').'

'."\n"; - echo '

'.__('Sometimes there are certain cases where a particular file, or a particular group of files, should never be cached. This is where you will enter those if you need to (one per line). Searches are performed against the REQUEST_URI; i.e., /path/?query (caSe insensitive). So, don\'t put in full URLs here, just word fragments found in the file path (or query string) is all you need, excluding the http:// and domain name. A wildcard * character can also be used when necessary; e.g., /category/abc-followed-by-* (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - - echo '

'.__('Tip: let\'s use this example URL: http://www.example.com/post/example-post-123. To exclude this URL, you would put this line into the field above: /post/example-post-123. Or, you could also just put in a small fragment, like: example or example-*-123 and that would exclude any URI containing that word fragment.', 'comet-cache').'

'."\n"; - echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; - if (is_multisite() && defined('SUBDOMAIN_INSTALL') && !SUBDOMAIN_INSTALL) { - echo '

'.__('Multisite Network w/ Sub-Directories: You can also use URI Exclusion Patterns to exclude specific sites from being cached, e.g., /site1/*.', 'comet-cache').'

'."\n"; - } - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('HTTP Referrer Exclusions', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo '

'.__('Don\'t Cache These Special HTTP Referrer Exclusion Patterns?', 'comet-cache').'

'."\n"; - echo '

'.__('Sometimes there are special cases where a particular referring URL (or referring domain) that sends you traffic; or even a particular group of referring URLs or domains that send you traffic; should result in a page being loaded on your site that is NOT from the cache (and that resulting page should never be cached). This is where you will enter those if you need to (one per line). Searches are performed against the HTTP_REFERER (caSe insensitive). A wildcard * character can also be used when necessary; e.g., *.domain.com (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Tip: let\'s use this example URL: http://www.referring-domain.com/search/?q=search+terms. To exclude this referring URL, you could put this line into the field above: www.referring-domain.com. Or, you could also just put in a small fragment, like: /search/ or q=*; and that would exclude any referrer containing that word fragment.', 'comet-cache').'

'."\n"; - echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('User-Agent Exclusions', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo '

'.__('Don\'t Cache These Special User-Agent Exclusion Patterns?', 'comet-cache').'

'."\n"; - echo '

'.__('Sometimes there are special cases when a particular user-agent (e.g., a specific browser or a specific type of device); should be shown a page on your site that is NOT from the cache (and that resulting page should never be cached). This is where you will enter those if you need to (one per line). Searches are performed against the HTTP_USER_AGENT (caSe insensitive). A wildcard * character can also be used when necessary; e.g., Android *; Chrome/* Mobile (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('Tip: if you wanted to exclude iPhones put this line into the field above: iPhone;*AppleWebKit. Or, you could also just put in a small fragment, like: iphone; and that would exclude any user-agent containing that word fragment. Note, this is just an example. With a default installation of %1$s, there is no compelling reason to exclude iOS devices (or any mobile device for that matter).', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Auto-Cache Engine', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Enable the Auto-Cache Engine?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('After using %1$s for awhile (or any other page caching plugin, for that matter); it becomes obvious that at some point (based on your configured Expiration Time) %1$s has to refresh itself. It does this by ditching its cached version of a page, reloading the database-driven content, and then recreating the cache with the latest data. This is a never ending regeneration cycle that is based entirely on your configured Expiration Time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.__('Understanding this, you can see that 99% of your visitors are going to receive a lightning fast response from your server. However, there will always be around 1% of your visitors that land on a page for the very first time (before it\'s been cached), or land on a page that needs to have its cache regenerated, because the existing cache has become outdated. We refer to this as a First-Come Slow-Load Issue. Not a huge problem, but if you\'re optimizing your site for every ounce of speed possible, the Auto-Cache Engine can help with this. The Auto-Cache Engine has been designed to combat this issue by taking on the responsibility of being that first visitor to a page that has not yet been cached, or has an expired cache. The Auto-Cache Engine is powered, in part, by WP-Cron (already built into WordPress). The Auto-Cache Engine runs at 15-minute intervals via WP-Cron. It also uses the WP_Http class, which is also built into WordPress already.', 'comet-cache').'

'."\n"; - echo '

'.__('The Auto-Cache Engine obtains its list of URLs to auto-cache, from two different sources. It can read an XML Sitemap and/or a list of specific URLs that you supply. If you supply both sources, it will use both sources collectively. The Auto-Cache Engine takes ALL of your other configuration options into consideration too, including your Expiration Time, as well as any cache exclusion rules.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - - echo '
'."\n"; - - echo '
'."\n"; - echo '

'.__('XML Sitemap URL (or an XML Sitemap Index)', 'comet-cache').'

'."\n"; - echo '
'.esc_html(home_url('/')).'
'."\n"; - if (is_multisite()) { - echo '

'."\n"; - echo '

'.sprintf(__(' If enabled here, each child blog can be auto-cached too. %1$s will dynamically change the leading %2$s as necessary; for each child blog in the network. %1$s supports both sub-directory & sub-domain networks, including domain mapping plugins. For more information about how the Auto-Cache Engine caches child blogs, see this article.', 'comet-cache'), esc_html(NAME), esc_html(home_url('/'))).'

'."\n"; - } - echo '
'."\n"; - - echo '

'.__('And/Or; a List of URLs to Auto-Cache (One Per Line)', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Note: Wildcards are NOT supported here. If you are going to supply a list of URLs above, each line must contain one full URL for the Auto-Cache Engine to auto-cache. If you have many URLs, we recommend using an XML Sitemap.', 'comet-cache').'

'."\n"; - - echo '
'."\n"; - - echo '

'.__('Auto-Cache Delay Timer (in Milliseconds)', 'comet-cache').'

'."\n"; - echo '

'.__('As the Auto-Cache Engine runs through each URL, you can tell it to wait X number of milliseconds between each connection that it makes. It is strongly suggested that you DO have some small delay here. Otherwise, you run the risk of hammering your own web server with multiple repeated connections whenever the Auto-Cache Engine is running. This is especially true on very large sites; where there is the potential for hundreds of repeated connections as the Auto-Cache Engine goes through a long list of URLs. Adding a delay between each connection will prevent the Auto-Cache Engine from placing a heavy load on the processor that powers your web server. A value of 500 milliseconds is suggested here (half a second). If you experience problems, you can bump this up a little at a time, in increments of 500 milliseconds; until you find a happy place for your server. Please note that 1000 milliseconds = 1 full second.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - - echo '
'."\n"; - - echo '

'.__('Auto-Cache User-Agent String', 'comet-cache').'

'."\n"; - echo '
; '.esc_html(GLOBAL_NS.' '.VERSION).'
'."\n"; - echo '

'.__('This is how the Auto-Cache Engine identifies itself when connecting to URLs. See User Agent in the Wikipedia.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - } - /* ----------------------------------------------------------------------------------------- */ - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('HTML Compression', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Enable WebSharks™ HTML Compression?', 'comet-cache').'

'."\n"; - if (is_plugin_active('autoptimize/autoptimize.php')) { - echo '

'.__('Autoptimize + Comet Cache: Comet Cache has detected that you are running the Autoptimize plugin. Autoptimize and the HTML Compressor feature of Comet Cache are both designed to compress HTML, CSS, and JavaScript. Enabling the HTML Compressor alongside Autoptimize may result in unexpected behavior. If you\'re happy with Autoptimize, you can leave the HTML Compressor disabled. All other Comet Cache features run great alongside Autoptimize.', 'comet-cache').'

'; - } - echo '

'."\n"; - echo '
'."\n"; - echo '
'."\n"; - echo '

'.__('HTML Compression Options', 'comet-cache').'

'."\n"; - echo '

'.__('You can learn more about all of these options here.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'."\n"; - echo '

'."\n"; - echo '

'."\n"; - echo '

'."\n"; - echo '

'."\n"; - echo '

'."\n"; - echo '

'."\n"; - echo '

'."\n"; - echo '
'."\n"; - echo '

'.__('CSS Exclusion Patterns?', 'comet-cache').'

'."\n"; - echo '

'.__('Sometimes there are special cases when a particular CSS file should NOT be consolidated or compressed in any way. This is where you will enter those if you need to (one per line). Searches are performed against the <link href=""> value, and also against the contents of any inline <style> tags (caSe insensitive). A wildcard * character can also be used when necessary; e.g., xy*-framework (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; - echo '

'.__('JavaScript Exclusion Patterns?', 'comet-cache').'

'."\n"; - echo '

'.__('Sometimes there are special cases when a particular JS file should NOT be consolidated or compressed in any way. This is where you will enter those if you need to (one per line). Searches are performed against the <script src=""> value, and also against the contents of any inline <script> tags (caSe insensitive). A wildcard * character can also be used when necessary; e.g., xy*-framework (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; - echo '

'.__('URI Exclusions for HTML Compressor?', 'comet-cache').'

'."\n"; - echo '

'.__('When you enable HTML Compression above, you may want to prevent certain pages on your site from being cached by the HTML Compressor. This is where you will enter those if you need to (one per line). Searches are performed against the REQUEST_URI; i.e., /path/?query (caSe insensitive). So, don\'t put in full URLs here, just word fragments found in the file path (or query string) is all you need, excluding the http:// and domain name. A wildcard * character can also be used when necessary; e.g., /category/abc-followed-by-* (where * = 0 or more characters that are NOT a slash /). Other special characters include: ** = 0 or more characters of any kind, including / slashes; ^ = beginning of the string; $ = end of the string. To learn more about this syntax, please see this KB article.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Tip: let\'s use this example URL: http://www.example.com/post/example-post-123. To exclude this URL, you would put this line into the field above: /post/example-post-123. Or, you could also just put in a small fragment, like: example or example-*-123 and that would exclude any URI containing that word fragment.', 'comet-cache').'

'."\n"; - echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - echo '

'.__('HTML Compression Cache Expiration', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Tip: the value that you specify here MUST be compatible with PHP\'s strtotime() function. Examples: 2 hours, 7 days, 6 months, 1 year.', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Note: This does NOT impact the overall cache expiration time that you configure with %1$s. It only impacts the sub-routines provided by the HTML Compressor. In fact, this expiration time is mostly irrelevant. The HTML Compressor uses an internal checksum, and it also checks filemtime() before using an existing cache file. The HTML Compressor class also handles the automatic cleanup of your cache directories to keep it from growing too large over time. Therefore, unless you have VERY little disk space there is no reason to set this to a lower value (even if your site changes dynamically quite often). If anything, you might like to increase this value which could help to further reduce server load. You can learn more here. We recommend setting this value to at least double that of your overall %1$s expiration time.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - } - /* ----------------------------------------------------------------------------------------- */ - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Static CDN Filters', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Enable Static CDN Filters (e.g., MaxCDN/CloudFront)?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('This feature allows you to serve some and/or ALL static files on your site from a CDN of your choosing. This is made possible through content/URL filters exposed by WordPress and implemented by %1$s. All it requires is that you setup a CDN hostname sourced by your WordPress installation domain. You enter that CDN hostname below and %1$s will do the rest! Super easy, and it doesn\'t require any DNS changes either. :-) Please click here for a general set of instructions.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.__('What\'s a CDN? It\'s a Content Delivery Network (i.e., a network of optimized servers) designed to cache static resources served from your site (e.g., JS/CSS/images and other static files) onto it\'s own servers, which are located strategically in various geographic areas around the world. Integrating a CDN for static files can dramatically improve the speed and performance of your site, lower the burden on your own server, and reduce latency associated with visitors attempting to access your site from geographic areas of the world that might be very far away from the primary location of your own web servers.', 'comet-cache').'

'."\n"; - if ($this->plugin->isNginx() && $this->plugin->applyWpFilters(GLOBAL_NS.'_wp_htaccess_nginx_notice', true) && (!isset($_SERVER['WP_NGINX_CONFIG']) || $_SERVER['WP_NGINX_CONFIG'] !== 'done')) { - echo '
'."\n"; - echo ' '.__('It appears that your server is running NGINX and does not support .htaccess rules. Please update your server configuration manually. Note that updating your NGINX server configuration before enabling Static CDN Filters is recommended to prevent any CORS errors with your CDN. If you\'ve already updated your NGINX configuration, you can safely ignore this message.', 'comet-cache')."\n"; - echo '
'."\n"; - } - echo '

'."\n"; - if ($this->plugin->isApache() && $this->plugin->options['cdn_enable'] && !$this->plugin->options['htaccess_access_control_allow_origin']) { - echo '

'.__('Warning: Static CDN Filters are enabled above but the Comet Cache → Plugin Options → Apache Optimizations → Send Access-Control-Allow-Origin Header option has been disabled. We recommend sending the Access-Control-Allow-Origin header to avoid CORS errors when a CDN is configured.', 'comet-cache').'

'."\n"; - } - echo '
'."\n"; - - echo '
'."\n"; - - echo '

'.__('CDN Hostname (Required)', 'comet-cache').'

'."\n"; - - echo '

'.// This note includes three graphics. One for MaxCDN; another for CloudFront, and another for KeyCDN. - ' '. - ' '. - ' '. - ' '.__('This field is really all that\'s necessary to get Static CDN Filters working! However, it does requires a little bit of work on your part. You need to setup and configure a CDN before you can fill in this field. Once you configure a CDN, you\'ll receive a hostname (provided by your CDN), which you\'ll enter here; e.g., js9dgjsl4llqpp.cloudfront.net. We recommend MaxCDN, Amazon CloudFront, KeyCDN, and/or CDN77 but this should work with many of the most popular CDNs. Please read this article for a general set of instructions. We also have a MaxCDN tutorial, CloudFront tutorial, KeyCDN tutorial, and a CDN77 tutorial to walk you through the process.', 'comet-cache').'

'."\n"; - echo '

plugin->options['cdn_hosts'] ? ' disabled="disabled"' : '').' />

'."\n"; - - echo '
'."\n"; - - echo '

'.__('Multiple CDN Hostnames for Domain Sharding and Multisite Networks (Optional)', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('%1$s also supports multiple CDN Hostnames for any given domain. Using multiple CDN Hostnames (instead of just one, as seen above) is referred to as Domain Sharding (click here to learn more). If you configure multiple CDN Hostnames (i.e., if you implement Domain Sharding), %1$s will use the first one that you list for static resources loaded in the HTML <head> section, the last one for static resources loaded in the footer, and it will choose one at random for all other static resource locations. Configuring multiple CDN Hostnames can improve speed! This is a way for advanced site owners to work around concurrency limits in popular browsers; i.e., making it possible for browsers to download many more resources simultaneously, resulting in a faster overall completion time. In short, this tells the browser that your website will not be overloaded by concurrent requests, because static resources are in fact being served by a content-delivery network (i.e., multiple CDN hostnames). If you use this functionality for Domain Sharding, we suggest that you setup one CDN Distribution (aka: Pull Zone), and then create multiple CNAME records pointing to that distribution. You can enter each of your CNAMES in the field below, as instructed.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('On WordPress Multisite Network installations, this field also allows you to configure different CDN Hostnames for each domain (or sub-domain) that you run from a single installation of WordPress. For more information about configuring Static CDN Filters on a WordPress Multisite Network, see this tutorial: Static CDN Filters for WordPress Multisite Networks.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('↑ Syntax: This is a line-delimited list of domain mappings. Each line should start with your WordPress domain name (e.g., %1$s), followed by an = sign, followed by a comma-delimited list of CDN Hostnames associated with the domain in that line. If you\'re running a Multisite Network installation of WordPress, you might have multiple configuration lines. Otherwise, you should only need one line to configure multiple CDN Hostnames for a standard WordPress installation.', 'comet-cache'), esc_html($this->plugin->hostToken(false, true))).'

'."\n"; - - echo '
'."\n"; - - echo '

'.__('CDN Supports HTTPS Connections?', 'comet-cache').'

'."\n"; - echo '

'."\n"; - - echo '
'."\n"; - - echo '

'. - ''. - ' '.__('Additional Options (For Advanced Users)', 'comet-cache').' '. - ''. - '

'."\n"; - - echo '
'."\n"; - echo '

'.__('Everything else below is 100% completely optional; i.e., not required to enjoy the benefits of Static CDN Filters.', 'comet-cache').'

'."\n"; - - echo '
'."\n"; - - echo '

'.__('Whitelisted File Extensions (Optional; Comma-Delimited)', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('If you leave this empty a default set of extensions are taken from WordPress itself. The default set of whitelisted file extensions includes everything supported by the WordPress media library.', 'comet-cache').(IS_PRO ? ' '.__('This includes the following: '.esc_html(implode(',', CdnFilters::defaultWhitelistedExtensions())).'', 'comet-cache') : '').'

'."\n"; - - echo '

'.__('Blacklisted File Extensions (Optional; Comma-Delimited)', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('With or without a whitelist, you can force exclusions by explicitly blacklisting certain file extensions of your choosing. Please note, the php extension will never be considered a static resource; i.e., it is automatically blacklisted at all times.', 'comet-cache').'

'."\n"; - - echo '
'."\n"; - - echo '

'.__('Whitelisted URI Inclusion Patterns (Optional; One Per Line)', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one inclusion pattern per line.', 'comet-cache').'

'."\n"; - echo '

'.__('If provided, only local URIs matching one of the patterns you list here will be served from your CDN Hostname. URI patterns are caSe-insensitive. A wildcard * will match zero or more characters in any of your patterns. A caret ^ symbol will match zero or more characters that are NOT the / character. For instance, */wp-content/* here would indicate that you only want to filter URLs that lead to files located inside the wp-content directory. Adding an additional line with */wp-includes/* would filter URLs in the wp-includes directory also. If you leave this empty, ALL files matching a static file extension will be served from your CDN; i.e., the default behavior.', 'comet-cache').'

'."\n"; - echo '

'.__('Please note that URI patterns are tested against a file\'s path (i.e., a file\'s URI, and NOT its full URL). A URI always starts with a leading /. To clarify, a URI is the portion of the URL which comes after the hostname. For instance, given the following URL: http://example.com/path/to/style.css?ver=3, the URI you are matching against would be: /path/to/style.css?ver=3. To whitelist this URI, you could use a line that contains something like this: /path/to/*.css*', 'comet-cache').'

'."\n"; - - echo '

'.__('Blacklisted URI Exclusion Patterns (Optional; One Per Line)', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('With or without a whitelist, you can force exclusions by explicitly blacklisting certain URI patterns. URI patterns are caSe-insensitive. A wildcard * will match zero or more characters in any of your patterns. A caret ^ symbol will match zero or more characters that are NOT the / character. For instance, */wp-content/*/dynamic.pdf* would exclude a file with the name dynamic.pdf located anywhere inside a sub-directory of wp-content.', 'comet-cache').'

'."\n"; - echo '

'.__('Note: please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'comet-cache').'

'."\n"; - - echo '
'."\n"; - - echo '

'.__('Query String Invalidation Variable Name', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('Each filtered URL (which then leads to your CDN) will include this query string variable as an easy way to invalidate the CDN cache at any time. Invalidating the CDN cache is simply a matter of changing the global invalidation counter (i.e., the value assigned to this query string variable). %1$s manages invalidations automatically; i.e., %1$s will automatically bump an internal counter each time you upgrade a WordPress component (e.g., a plugin, theme, or WP itself). Or, if you ask %1$s to invalidate the CDN cache (e.g., a manual clearing of the CDN cache); the internal counter is bumped then too. In short, %1$s handles cache invalidations for you reliably. This option simply allows you to customize the query string variable name which makes cache invalidations possible. Please note, the default value is adequate for most sites. You can change this if you like, but it\'s not necessary.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('Tip: You can also tell %1$s to automatically bump the CDN Invalidation Counter whenever you clear the cache manually. See: %1$s → Manual Cache Clearing → Clear the CDN Cache Too?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('Note: If you empty this field, it will effectively disable the %1$s invalidation system for Static CDN Filters; i.e., the query string variable will NOT be included if you do not supply a variable name.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'."\n"; - echo '
'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - } - /* ----------------------------------------------------------------------------------------- */ - - if ($this->plugin->isApache() || $this->plugin->isProPreview()) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Apache Optimizations', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Apache Performance Tuning (Optional; Highly Recommended)', 'comet-cache').'

'."\n"; - echo '

'.__('You don\'t need to use an .htaccess file to enjoy the performance enhancements provided by this plugin; caching is handled automatically by WordPress/PHP alone. That being said, if you want to take advantage of additional speed enhancements by optimizing the Apache web server to achieve maximize performance (and we do recommend this), then you WILL need an .htaccess file to accomplish that part.', 'comet-cache').'

'."\n"; - echo '

'.__('WordPress itself uses the .htaccess file to create Apache rewrite rules when you enable fancy Permalinks, so there\'s a good chance you already have an .htaccess file. The options below allow for additional performance tuning using recommendations provided by Comet Cache.', 'comet-cache').'

'."\n"; - echo '

'.__('When you enable one of the options below, Comet Cache will attempt to automatically insert the appropriate configuration into your .htaccess file (or remove it automatically if you are disabling an option). If Comet Cache is unable to update the file, or if you would prefer to add the configuration yourself, the recommended configuration to add to the file can be viewed at the bottom of each option.', 'comet-cache').'

'."\n"; - echo '

'.__('Note: The .htaccess file is parsed by the web server directly, before WordPress is even loaded. For that reason, if something goes wrong in the file you can end up with a broken site. We recommend creating a backup of your current .htaccess file before making any modifications.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - echo '

'.__('Enable GZIP Compression?', 'comet-cache').'

'."\n"; - echo '

'.__('GZIP compression is highly recommended. It\'s not uncommon to achieve compression rates as high as 70-90%, which is a huge savings in the amount of data that needs to be transferred with each visit to your site.', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('%1$s fully supports GZIP compression on its output. However, it does not handle GZIP compression directly like some caching plugins. We purposely left GZIP compression out of this plugin because GZIP compression is something that should really be enabled at the Apache level or inside your php.ini file. GZIP compression can be used for things like JavaScript and CSS files as well, so why bother turning it on for only WordPress-generated pages when you can enable GZIP at the server level and cover all the bases!', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; - echo '

'.__('Or, you can update your configuration manually: [ .htaccess configuration ]', 'comet-cache').'

'."\n"; - echo ' '."\n"; - - if ((!IS_PRO && $this->plugin->isApache()) && !$this->plugin->isProPreview()) { - echo '
'."\n"; - echo '

'.sprintf(__('Enable the Pro Preview to see Leverage Browser Caching, Enforce Canonical URLs, and more!', 'comet-cache'), esc_attr(add_query_arg(urlencode_deep(['page' => GLOBAL_NS, GLOBAL_NS.'_pro_preview' => '1']), self_admin_url('/admin.php')))).'

'."\n"; - } - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - echo '

'.__('Leverage Browser Caching?', 'comet-cache').'

'."\n"; - echo '

'.__('Browser Caching is highly recommended. When loading a single page, downloading all of the resources for that page may require multiple roundtrips between the browser and server, which delays processing and may block rendering of page content. This also incurs data costs for the visitor. With browser caching, your server tells the visitor\'s browser that it is allowed to cache static resources for a certain amount of time (Google recommends 1 week and that\'s what Comet Cache uses).', 'comet-cache').'

'."\n"; - echo '

'.__('In WordPress, \'Page Caching\' is all about server-side performance (reducing the amount of time it takes the server to generate the page content). With Comet Cache installed, you\'re drastically reducing page generation time. However, you can make a visitor\'s experience ​even faster​ when you leverage browser caching too. When this option is enabled, the visitor\'s browser will cache static resources from each page and reuse those cached resources on subsequent page loads. In this way, future visits to the same page will not require additional connections to your site to download static resources that the visitor\'s browser has already cached.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Or, you can update your configuration manually: [ .htaccess configuration ]', 'comet-cache').'

'."\n"; - echo ' '."\n"; - } - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - echo '

'.__('Enforce an Exact Hostname?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('By enforcing an exact hostname you avoid duplicate cache files, which saves disk space and improves cache performance. For example, if a bot or crawler accesses your site using your server\'s IP address instead of using your domain name (e.g., http://123.456.789/path), this results in duplicate cache files, because the host was an IP address. The \'host\' being an important factor in any cache storage system. The same would be true if a visitor attempted to access your site using a made-up sub-domain; e.g., http://foo.bar.%1$s/path. This sort of thing can be avoided by explicitly enforcing an exact hostname in the request. One that matches exactly what you\'ve configured in WordPress Settings → General.', 'comet-cache'), esc_html(parse_url(network_home_url(), PHP_URL_HOST))).'

'."\n"; - echo '

'."\n"; - echo '

'.__('Or, you can update your configuration manually: [ .htaccess configuration ]', 'comet-cache').'

'."\n"; - echo ' '."\n"; - } - if ((IS_PRO && !empty($GLOBALS['wp_rewrite']->permalink_structure)) || $this->plugin->isProPreview()) { - echo '
'."\n"; - echo '

'.__('Enforce Canonical URLs?', 'comet-cache').'

'."\n"; - echo '

'.__('Permalinks (URLs) leading to Posts/Pages on your site (based on your WordPress Permalink Settings) '.($GLOBALS['wp_rewrite']->use_trailing_slashes ? 'require a .../trailing-slash/' : 'do not require a .../trailing-slash').'. Ordinarily, WordPress enforces this by redirecting a request for '.($GLOBALS['wp_rewrite']->use_trailing_slashes ? '.../something' : '.../something/').', to '.($GLOBALS['wp_rewrite']->use_trailing_slashes ? '.../something/' : '.../something').', thereby forcing the final location to match your Permalink configuration. However, whenever you install a plugin like Comet Cache, much of WordPress (including this automatic redirection) is out of the picture when the cached copy of a page is being served. So enabling this option will add rules to your .htaccess file that make Apache aware of your WordPess Permalink configuration. Apache can do what WordPress normally would, only much more efficiently.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Or, you can update your configuration manually: [ .htaccess configuration ]', 'comet-cache').'

'."\n"; - echo ' '."\n"; - } - if ((IS_PRO && $this->plugin->options['cdn_enable']) || $this->plugin->isProPreview()) { - echo '
'."\n"; - echo '

'.__('Send Access-Control-Allow-Origin Header?', 'comet-cache').'

'."\n"; - if ($this->plugin->options['cdn_enable'] && !$this->plugin->options['htaccess_access_control_allow_origin']) { - echo '

'.__('Warning: Send Access-Control-Allow-Origin Header has been disabled below but Comet Cache → Plugin Options → Static CDN Filters are enabled. We recommend configuring your server to send the Access-Control-Allow-Origin header to avoid CORS errors when a CDN is configured.', 'comet-cache').'

'."\n"; - } - echo '

'.__('If you are using Static CDN Filters to load resources for your site from another domain, it\'s important that your server sends an Access-Control-Allow-Origin header to prevent Cross Origin Resource Sharing (CORS) errors. This option is enabled automatically when you enable Static CDN Filters. For more information, see this article.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - echo '

'.__('Or, you can update your configuration manually: [ .htaccess configuration ]', 'comet-cache').'

'."\n"; - echo ' '."\n"; - } - echo '
'."\n"; - echo '
'."\n"; - } - /* ----------------------------------------------------------------------------------------- */ - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Mobile Mode', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo '

'.__(' Enable Mobile-Adaptive Mode?', 'comet-cache').'

'."\n"; - echo '

'.__('Tip: Generally speaking, you should only enable this if your WordPress theme uses an \'Adaptive\' design, as opposed to a design that\'s \'Responsive\'—the way most WordPress themes are built.', 'comet-cache').'

'."\n"; - echo '

'."\n"; - - if (!version_compare(PHP_VERSION, '5.6', '>=')) { - echo '

'.sprintf(__('PHP Version: This feature requires PHP v5.6 (or higher). You\'re currently running PHP v%1$s. Please contact your web hosting company for assistance.', 'comet-cache'), esc_html(PHP_VERSION)).'

'."\n"; - } - - echo '

'.__('What\'s the Difference Between Responsive and Adaptive?', 'comet-cache').'

'."\n"; - echo '

'.__('Responsive and Adaptive designs both attempt to optimize the user experience across different devices, adjusting for different viewport sizes, resolutions, usage contexts, control mechanisms, and so on. Responsive design (common for WordPress sites) works on the principle of flexibility — a single fluid website that can look good on any device. Responsive websites use media queries, flexible grids, and responsive images to create a user experience that flexes and changes based on a multitude of factors. If you have a Responsive theme, you probably do NOT need to enable Mobile-Adaptive Mode.', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Adaptive design detects the device and other features, and then it provides the appropriate feature and layout based on a predefined set of viewport sizes and other characteristics. Adaptive themes generally decide what to display based on a visitor\'s User-Agent (i.e., OS, device, browser, version). Since this design choice results in multiple versions of a page being served to visitors, based on the device they access the site with, it then becomes important to cache each of those variations separately. That way a visitor on an iPhone isn\'t accidentally shown the cached copy of a page that was originally viewed by another visitor who was on a desktop computer. If your theme uses an Adaptive design, you probably DO want to enable Mobile-Adaptive Mode in %1$s.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - - echo '

'."\n"; - echo '

'.__('Mobile-Adaptive Tokens', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('When %1$s runs in Mobile-Adaptive Mode and it detects that a device is Mobile (e.g., a phone, tablet), it needs to know which factors you\'d like to consider. Mobile-Adaptive Tokens make this easy. In the field below, please configure a list of Mobile-Adaptive Tokens that establish the important factors on your site. Each token must be separated by a + sign. You can use just one, or use them all. However, it\'s IMPORTANT to note: With each new token, you add additional permutations that can fragment the cache and eat up a lot of disk space. Enable and monitor Cache Statistics so you can keep an eye on this. See: %1$s → Plugin Options → Cache-Related Statistics', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.__('The available Tokens are as follows:', 'comet-cache').'

'."\n"; - echo '
    '."\n"; - echo '
  • '.__('os.name This token is replaced automatically with: iOS, Android, etc.', 'comet-cache').'
  • '."\n"; - echo '
  • '.__('device.type This token is replaced with: Tablet, Mobile Device, Mobile Phone, etc.', 'comet-cache').'
  • '."\n"; - echo '
  • '.__('browser.name This token is replaced with: Safari, Mobile Safari UIWebView, Chrome, etc.', 'comet-cache').'
  • '."\n"; - echo '
  • '.__('browser.version Major & minor version. Not recommended, many permutations. Replaced with: 55.0, 1.3, 9383242.2392, etc.', 'comet-cache').'
  • '."\n"; - echo '
  • '.__('browser.version.major Major version only. More feasible, fewer permutations. Replaced with: 55, 1, 9383242, etc.', 'comet-cache').'
  • '."\n"; - echo '
'."\n"; - echo '

'."\n"; - echo '

'.sprintf(__('The suggested default value is: %2$s
However, just: os.name + device.type is better, if that will do.', 'comet-cache'), esc_html(NAME), esc_html($this->plugin->default_options['mobile_adaptive_salt'])).'

'."\n"; - echo '

'.__('The special token: device.is_mobile (i.e., any mobile device, including tablets, excluding laptops) can be used by itself. For example, if you simply want to break the cache down into mobile vs. NOT mobile.', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Note: The underlying logic behind mobile detection is accomplished using a faster, precompiled version of Browscap Lite, and Browcap data is automatically updated (and recompiled) whenever you save %1$s options and/or when upgrading %1$s to a new version.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - echo '
'."\n"; - } - /* ----------------------------------------------------------------------------------------- */ - - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Dynamic Version Salt', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__(' GEEK ALERT This is for VERY advanced users only...', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Note: Understanding the %1$s Branched Cache Structure is a prerequisite to understanding how Dynamic Version Salts are added to the mix.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.__('A Version Salt gives you the ability to dynamically create multiple variations of the cache, and those dynamic variations will be served on subsequent visits; e.g., if a visitor has a specific cookie (of a certain value) they will see pages which were cached with that version (i.e., w/ that Version Salt: the value of the cookie). A Version Salt can really be anything.', 'comet-cache').'

'."\n"; - echo '

'.__('A Version Salt can be a single variable like $_COOKIE[\'my_cookie\'], or it can be a combination of multiple variables, like $_COOKIE[\'my_cookie\'].$_COOKIE[\'my_other_cookie\']. (When using multiple variables, please separate them with a dot, as shown in the example.)', 'comet-cache').'

'."\n"; - echo '

'.__('Experts could even use PHP ternary expressions that evaluate into something. For example: ((preg_match(\'/iPhone/i\', $_SERVER[\'HTTP_USER_AGENT\'])) ? \'iPhones\' : \'\'). This would force a separate version of the cache to be created for iPhones (e.g., PROTOCOL.HOST.URI[...]v/iPhones.html).', 'comet-cache').'

'."\n"; - echo '

'.__('For more documentation, please see Dynamic Version Salts.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - echo '

'.sprintf(__('Create a Dynamic Version Salt For %1$s?       150%% OPTIONAL', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
PROTOCOL.HOST.URI.v.
'."\n"; - echo '

'.__('Super Globals work here; $GLOBALS[\'table_prefix\'] is a popular one.
Or, perhaps a PHP Constant defined in /wp-config.php; such as WPLANG or DB_HOST.', 'comet-cache').'

'."\n"; - echo '

'.__('Important: your Version Salt is scanned for PHP syntax errors via phpCodeChecker.com. If errors are found, you\'ll receive a notice in the Dashboard.', 'comet-cache').'

'."\n"; - echo '

'.__('If you\'ve enabled a separate cache for each user (optional) that\'s perfectly OK. A Version Salt works with user caching too.', 'comet-cache').'

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - } - /* ----------------------------------------------------------------------------------------- */ - - echo '
'."\n"; - - echo ' '."\n"; - echo ' '.__('Theme/Plugin Developers', 'comet-cache')."\n"; - echo ' '."\n"; - - echo '
'."\n"; - echo ' '."\n"; - echo '

'.__('Developing a Theme or Plugin for WordPress?', 'comet-cache').'

'."\n"; - echo '

'.sprintf(__('Tip: %1$s can be disabled temporarily. If you\'re a theme/plugin developer, you can set a flag within your PHP code to disable the cache engine at runtime. Perhaps on a specific page, or in a specific scenario. In your PHP script, set: $_SERVER[\'COMET_CACHE_ALLOWED\'] = FALSE; or define(\'COMET_CACHE_ALLOWED\', FALSE). %1$s is also compatible with: define(\'DONOTCACHEPAGE\', TRUE). It does\'t matter where or when you define one of these, because %1$s is the last thing to run before script execution ends.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'."\n"; - echo '

'.sprintf(__('Writing "Advanced Cache" Plugins Specifically for %1$s', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('Theme/plugin developers can take advantage of the %1$s plugin architecture by creating PHP files inside this special directory: /wp-content/ac-plugins/. There is an example plugin file @ GitHub (please review it carefully and ask questions). If you develop a plugin for %1$s, please share it with the community by publishing it in the plugins respository at WordPress.org.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('Why does %1$s have it\'s own plugin architecture? WordPress loads the advanced-cache.php drop-in file (for caching purposes) very early-on; before any other plugins or a theme. For this reason, %1$s implements it\'s own watered-down version of functions like add_action(), do_action(), add_filter(), apply_filters().', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'."\n"; - - echo '
'."\n"; - - /* ----------------------------------------------------------------------------------------- */ + new MenuPage\Options\HostExclusions(); + new MenuPage\Options\UriExclusions(); + new MenuPage\Options\RefererExclusions(); + new MenuPage\Options\UserAgentExclusions(); - if (IS_PRO || $this->plugin->isProPreview()) { - echo '
'."\n"; + new MenuPage\Options\AutoCacheEngine(); + new MenuPage\Options\HtmlCompressor(); + new MenuPage\Options\StaticCdnFilters(); + new MenuPage\Options\ApacheOptimizations(); - echo ' '."\n"; - echo ' '.__('Import/Export Options', 'comet-cache')."\n"; - echo ' '."\n"; + new MenuPage\Options\MobileMode(); + new MenuPage\Options\VersionSalt(); - echo '
'."\n"; - echo ' '."\n"; - echo '

'.sprintf(__('Import Options from Another %1$s Installation?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '

'.sprintf(__('Upload your %1$s-options.json file and click "Save All Changes" below. The options provided by your import file will override any that exist currently.', 'comet-cache'), GLOBAL_NS).'

'."\n"; - echo '

'."\n"; - echo '
'."\n"; - echo '

'.sprintf(__('Export Existing Options from this %1$s Installation?', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo ' '."\n"; - echo '

'.sprintf(__('Download your existing options and import them all into another %1$s installation; saves time on future installs.', 'comet-cache'), esc_html(NAME)).'

'."\n"; - echo '
'."\n"; + new MenuPage\Options\Developers(); + new MenuPage\Options\ImportExport(); - echo '
'."\n"; - } /* ----------------------------------------------------------------------------------------- */ echo '
'."\n"; diff --git a/src/includes/classes/Plugin.php b/src/includes/classes/Plugin.php index acfaf55..8cb0512 100644 --- a/src/includes/classes/Plugin.php +++ b/src/includes/classes/Plugin.php @@ -243,6 +243,9 @@ public function setup() 'cdn_whitelisted_uri_patterns', 'cdn_blacklisted_uri_patterns', + 'memcached_enable', + 'memcached_servers', + 'stats_enable', 'stats_admin_bar_enable', 'stats_admin_bar_roles_caps', @@ -425,6 +428,12 @@ public function setup() 'cdn_blacklisted_uri_patterns' => '', // A line-delimited list of exclusion patterns. // Wildcards `*` are supported here. Matched against local file URIs. + /* Related to Memcached. */ + + 'memcached_enable' => '0', // `0|1`; enable Memcached? + 'memcached_servers' => '', // Line-delimited list of servers; e.g., [host]:[port]:[priority] + // If empty, this defaults to localhost running on port `11211` w/ no special priority. + /* Related to statistics/charts. */ 'stats_enable' => is_multisite() && wp_is_large_network() ? '0' : '1', diff --git a/src/includes/interfaces/Shared/WcpEventConsts.php b/src/includes/interfaces/Shared/WcpEventConsts.php new file mode 100644 index 0000000..7ab5fc2 --- /dev/null +++ b/src/includes/interfaces/Shared/WcpEventConsts.php @@ -0,0 +1,248 @@ + [], 'output' => '', 'via' => '']` + */ + public function cacheRead() + { + # Validation. + + if (!$this->cache_file) { + return []; // Not possible. + } + # Check memory first, if applicable. + # This avoids repeated disk reads in favor of RAM. + + + + # Check the filesystem next; slightly more expensive. + # This requires repeated disk reads; on a busy site it can add up. + + if (is_file($this->cache_file) && ($this->cache_max_age_disabled || filemtime($this->cache_file) >= $this->cache_max_age)) { + list($headers, $output) = explode('', (string) file_get_contents($this->cache_file), 2); + $headers = (array) unserialize($headers); + $via = 'filesystem'; + + // NOTE: There is no need to look at `$nonce_expires_early` when reading from RAM above. + // This is because an early expiration of nonce data is already baked into the memory cache entry. + $nonce_expires_early = !COMET_CACHE_CACHE_NONCE_VALUES && filemtime($this->cache_file) < $this->nonce_cache_max_age && preg_match('/\b(?:_wpnonce|akismet_comment_nonce)\b/u', $output); + + if ($nonce_expires_early) { // Ignoring `cache_max_age_disabled` in favor of better security. + return []; // This refuses to read a cache file that contains possibly expired nonce tokens. + } + return compact('headers', 'output', 'via'); + } + # Otherwise, failure. + + return []; // Not possible. + } + + /** + * Cache write. + * + * @since 17xxxx IO utils. + * + * @param string $output Output buffer. + * + * @throws \Exception on write failure. + * + * @return string|false Output or `false` = no change. + */ + public function cacheWrite($output) + { + # Validation. + + if (!($output = (string) $output)) { + return false; // Not possible. + } elseif (!$this->cache_file) { + return false; // Not possible. + } + # Initialize vars. + # Also locks the cache. + + $time = time(); + $lock = $this->cacheLock(); + $dir = dirname($this->cache_file); + $tmp = $this->addTmpSuffix($this->cache_file); + $nonce_expires_early = !COMET_CACHE_CACHE_NONCE_VALUES && preg_match('/\b(?:_wpnonce|akismet_comment_nonce)\b/u', $output); + + # Cache directory checks. + # Auto-creates cache directories. + + if (!is_dir(COMET_CACHE_DIR)) { + if (mkdir(COMET_CACHE_DIR, 0775, true) && !is_file(COMET_CACHE_DIR.'/.htaccess')) { + file_put_contents(COMET_CACHE_DIR.'/.htaccess', $this->htaccess_deny); + } // ↑ Creates & secures the cache directory. + } + if (!is_dir($dir)) { // New file dir. + $dir_writable = mkdir($dir, 0775, true); + } + if (empty($dir_writable) && !is_writable($dir)) { + throw new \Exception(sprintf(__('Cache directory not writable. %1$s needs this directory please: `%2$s`. Set permissions to `755` or higher; `777` might be needed in some cases.', 'comet-cache'), NAME, $dir)); + } + # If it's a 404 error and the main 404 error file already exists, we can save time w/ just a symlink. + # Note: This being the first time a 404 error has occurred for this specific location not found by WordPress. + + if ($this->is_404 && is_file($this->cache_file_404)) { + if (!(symlink($this->cache_file_404, $tmp) && rename($tmp, $this->cache_file))) { + throw new \Exception(sprintf(__('Unable to create symlink: `%1$s` » `%2$s`. Possible permissions issue (or race condition), please check your cache directory: `%3$s`.', 'comet-cache'), $this->cache_file, $this->cache_file_404, COMET_CACHE_DIR)); + } + $this->cacheUnlock($lock); + $this->maybeSetDebugInfo($this::NC_DEBUG_1ST_TIME_404_SYMLINK); + return false; // No change in output buffer. + } + # Otherwise, construct & store a new cache file. + # Also compresses HTML (if applicable) and adds debug notes. + + + + if (COMET_CACHE_DEBUGGING_ENABLE && $this->isHtmlXmlDoc($output)) { + $total_time = number_format(microtime(true) - $this->timer, 5, '.', ''); + + $DebugNotes = new Classes\Notes(); + $DebugNotes->addAsciiArt(sprintf(__('%1$s is Fully Functional', 'comet-cache'), NAME)); + $DebugNotes->addLineBreak(); + + if (IS_PRO && COMET_CACHE_WHEN_LOGGED_IN && $this->user_token) { + $DebugNotes->add(__('Cache File User Token', 'comet-cache'), $this->user_token); + } + if (IS_PRO && COMET_CACHE_MOBILE_ADAPTIVE_SALT_ENABLE && COMET_CACHE_MOBILE_ADAPTIVE_SALT && $this->mobile_adaptive_salt) { + // Note: Not using `$this->mobile_adaptive_salt` here. Instead, generating a human readable variation. + $DebugNotes->add(__('Cache File for Mobile Device', 'comet-cache'), $this->fillUaTokens(COMET_CACHE_MOBILE_ADAPTIVE_SALT, false)); + } + $DebugNotes->add(__('Cache File Version Salt', 'comet-cache'), $this->version_salt ? $this->version_salt : __('n/a', 'comet-cache')); + + $DebugNotes->addLineBreak(); + + $DebugNotes->add(__('Cache File URL', 'comet-cache'), $this->is_404 ? __('404 [error document]', 'comet-cache') : $this->protocol.$this->host_token.$_SERVER['REQUEST_URI']); + $DebugNotes->add(__('Cache File Path', 'comet-cache'), str_replace(WP_CONTENT_DIR, '', $this->is_404 ? $this->cache_file_404 : $this->cache_file)); + + $DebugNotes->addLineBreak(); + + $DebugNotes->add(__('Cache File Generated Via', 'comet-cache'), IS_PRO && $this->isAutoCacheEngine() ? __('Auto-Cache Engine', 'comet-cache') : __('HTTP request', 'comet-cache')); + $DebugNotes->add(__('Cache File Generated On', 'comet-cache'), date('M jS, Y @ g:i a T')); + $DebugNotes->add(__('Cache File Generated In', 'comet-cache'), sprintf(__('%1$s seconds', 'comet-cache'), $total_time)); + + $DebugNotes->addLineBreak(); + + if ($nonce_expires_early) { // Expires early? + $DebugNotes->add(__('Cache File Expires Early', 'comet-cache'), __('yes, due to nonce in markup', 'comet-cache')); + $DebugNotes->add(__('Cache File Expires On', 'comet-cache'), date('M jS, Y @ g:i a T', $time + ($time - $this->nonce_cache_max_age))); + $DebugNotes->add(__('Cache File Auto-Rebuild On', 'comet-cache'), date('M jS, Y @ g:i a T', $time + ($time - $this->nonce_cache_max_age))); + } else { + $DebugNotes->add(__('Cache File Expires On', 'comet-cache'), date('M jS, Y @ g:i a T', $time + ($time - $this->cache_max_age))); + $DebugNotes->add(__('Cache File Auto-Rebuild On', 'comet-cache'), date('M jS, Y @ g:i a T', $time + ($time - $this->cache_max_age))); + } + $output .= "\n".$DebugNotes->asHtmlComments(); + } + $cache = serialize($this->cacheableHeadersList()); + $cache .= ''; // Headers separator. + $cache .= $output; // Compressed output w/ debug notes. + + if ($this->is_404) { // Create main 404 error file w/ cache contents. + if (file_put_contents($tmp, $cache) && rename($tmp, $this->cache_file_404)) { + if (!(symlink($this->cache_file_404, $tmp) && rename($tmp, $this->cache_file))) { + throw new \Exception(sprintf(__('Unable to create symlink: `%1$s` » `%2$s`. Possible permissions issue (or race condition), please check your cache directory: `%3$s`.', 'comet-cache'), $this->cache_file, $this->cache_file_404, COMET_CACHE_DIR)); + } + $this->cacheUnlock($lock); + return $output; + } + } elseif (file_put_contents($tmp, $cache) && rename($tmp, $this->cache_file)) { + + $this->cacheUnlock($lock); + return $output; + } + @unlink($tmp); // Clean this up (if it exists); and throw an exception with information for the site owner. + throw new \Exception(sprintf(__('%1$s: failed to write cache file for: `%2$s`; possible permissions issue (or race condition), please check your cache directory: `%3$s`.', 'comet-cache'), NAME, $_SERVER['REQUEST_URI'], COMET_CACHE_DIR)); + } +} diff --git a/src/includes/traits/Ac/ObUtils.php b/src/includes/traits/Ac/ObUtils.php index 32a464a..d0d2773 100644 --- a/src/includes/traits/Ac/ObUtils.php +++ b/src/includes/traits/Ac/ObUtils.php @@ -120,92 +120,84 @@ trait ObUtils * * @since 150422 Rewrite. * @since 170220 Adding API request constants. - * - * @note This is a vital part of Comet Cache. - * This method serves existing (fresh) cache files. It is also responsible - * for beginning the process of collecting the output buffer. + * @since 17xxxx Condense using `elseif` chains. + * @since 17xxxx Polishing a little. */ public function maybeStartOutputBuffering() { + $lc_short_name = mb_strtolower(SHORT_NAME); + if (strcasecmp(PHP_SAPI, 'cli') === 0) { return $this->maybeSetDebugInfo($this::NC_DEBUG_PHP_SAPI_CLI); - } - if (empty($_SERVER['HTTP_HOST']) || !$this->hostToken()) { + // + } elseif (empty($_SERVER['HTTP_HOST']) || !$this->hostToken()) { return $this->maybeSetDebugInfo($this::NC_DEBUG_NO_SERVER_HTTP_HOST); - } - if (empty($_SERVER['REQUEST_URI'])) { + // + } elseif (empty($_SERVER['REQUEST_URI'])) { return $this->maybeSetDebugInfo($this::NC_DEBUG_NO_SERVER_REQUEST_URI); - } - if (defined('COMET_CACHE_ALLOWED') && !COMET_CACHE_ALLOWED) { + // + } elseif (defined('COMET_CACHE_ALLOWED') && !COMET_CACHE_ALLOWED) { return $this->maybeSetDebugInfo($this::NC_DEBUG_COMET_CACHE_ALLOWED_CONSTANT); - } - if (isset($_SERVER['COMET_CACHE_ALLOWED']) && !$_SERVER['COMET_CACHE_ALLOWED']) { + // + } elseif (isset($_SERVER['COMET_CACHE_ALLOWED']) && !$_SERVER['COMET_CACHE_ALLOWED']) { return $this->maybeSetDebugInfo($this::NC_DEBUG_COMET_CACHE_ALLOWED_SERVER_VAR); - } - if (defined('DONOTCACHEPAGE')) { // Common to most WP cache plugins. + // + } elseif (defined('DONOTCACHEPAGE')) { // Common to most WP cache plugins. return $this->maybeSetDebugInfo($this::NC_DEBUG_DONOTCACHEPAGE_CONSTANT); - } - if (isset($_SERVER['DONOTCACHEPAGE'])) { + // + } elseif (isset($_SERVER['DONOTCACHEPAGE'])) { return $this->maybeSetDebugInfo($this::NC_DEBUG_DONOTCACHEPAGE_SERVER_VAR); - } - if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) { + // + } elseif (isset($_GET[$lc_short_name.'AC']) && !filter_var($_GET[$lc_short_name.'AC'], FILTER_VALIDATE_BOOLEAN)) { + return $this->maybeSetDebugInfo($this::NC_DEBUG_AC_GET_VAR); + // + } elseif (!empty($_REQUEST['preview'])) { // Don't cache previews. + return $this->maybeSetDebugInfo($this::NC_DEBUG_PREVIEW); + // + } elseif (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) { return $this->maybeSetDebugInfo($this::NC_DEBUG_XMLRPC_REQUEST_CONSTANT); - } - if (defined('REST_REQUEST') && REST_REQUEST) { + // + } elseif (defined('REST_REQUEST') && REST_REQUEST) { return $this->maybeSetDebugInfo($this::NC_DEBUG_REST_REQUEST_CONSTANT); - } - if (isset($_GET[mb_strtolower(SHORT_NAME).'AC']) && !filter_var($_GET[mb_strtolower(SHORT_NAME).'AC'], FILTER_VALIDATE_BOOLEAN)) { - return $this->maybeSetDebugInfo($this::NC_DEBUG_AC_GET_VAR); - } - if ($this->isUncacheableRequestMethod()) { + // + } elseif ($this->isUncacheableRequestMethod()) { return $this->maybeSetDebugInfo($this::NC_DEBUG_UNCACHEABLE_REQUEST); - } - if (isset($_SERVER['SERVER_ADDR']) && $this->currentIp() === $_SERVER['SERVER_ADDR']) { - if ((!IS_PRO || !$this->isAutoCacheEngine()) && !$this->isLocalhost()) { - return $this->maybeSetDebugInfo($this::NC_DEBUG_SELF_SERVE_REQUEST); - } // Don't trip on requests by the auto-cache engine. - } - if (!COMET_CACHE_FEEDS_ENABLE && $this->isFeed()) { + // + } elseif (!COMET_CACHE_FEEDS_ENABLE && $this->isFeed()) { return $this->maybeSetDebugInfo($this::NC_DEBUG_FEED_REQUEST); - } - if (preg_match('/\/(?:wp\-[^\/]+|xmlrpc)\.php(?:[?]|$)/ui', $_SERVER['REQUEST_URI'])) { + // + } elseif (preg_match('/\/(?:wp\-[^\/]+|xmlrpc)\.php(?:[?]|$)/ui', $_SERVER['REQUEST_URI'])) { return $this->maybeSetDebugInfo($this::NC_DEBUG_WP_SYSTEMATICS); - } - if (is_admin() || preg_match('/\/wp-admin(?:[\/?]|$)/ui', $_SERVER['REQUEST_URI'])) { + // + } elseif (is_admin() || preg_match('/\/wp-admin(?:[\/?]|$)/ui', $_SERVER['REQUEST_URI'])) { return $this->maybeSetDebugInfo($this::NC_DEBUG_WP_ADMIN); - } - if (is_multisite() && preg_match('/\/files(?:[\/?]|$)/ui', $_SERVER['REQUEST_URI'])) { + // + } elseif (is_multisite() && preg_match('/\/files(?:[\/?]|$)/ui', $_SERVER['REQUEST_URI'])) { return $this->maybeSetDebugInfo($this::NC_DEBUG_MS_FILES); - } - if ((!IS_PRO || !COMET_CACHE_WHEN_LOGGED_IN) && $this->isLikeUserLoggedIn()) { + // + } elseif ((!IS_PRO || !COMET_CACHE_WHEN_LOGGED_IN) && $this->isLikeUserLoggedIn()) { return $this->maybeSetDebugInfo($this::NC_DEBUG_IS_LIKE_LOGGED_IN_USER); - } - if (!COMET_CACHE_GET_REQUESTS && $this->requestContainsUncacheableQueryVars()) { + // + } elseif (!COMET_CACHE_GET_REQUESTS && $this->requestContainsUncacheableQueryVars()) { return $this->maybeSetDebugInfo($this::NC_DEBUG_GET_REQUEST_QUERIES); - } - if (!empty($_REQUEST['preview'])) { // Don't cache previews under any circumstance. - return $this->maybeSetDebugInfo($this::NC_DEBUG_PREVIEW); - } - if (COMET_CACHE_EXCLUDE_HOSTS && preg_match(COMET_CACHE_EXCLUDE_HOSTS, $_SERVER['HTTP_HOST'])) { + // + } elseif (COMET_CACHE_EXCLUDE_HOSTS && preg_match(COMET_CACHE_EXCLUDE_HOSTS, $_SERVER['HTTP_HOST'])) { return $this->maybeSetDebugInfo($this::NC_DEBUG_EXCLUDED_HOSTS); - } - if (COMET_CACHE_EXCLUDE_URIS && preg_match(COMET_CACHE_EXCLUDE_URIS, $_SERVER['REQUEST_URI'])) { + // + } elseif (COMET_CACHE_EXCLUDE_URIS && preg_match(COMET_CACHE_EXCLUDE_URIS, $_SERVER['REQUEST_URI'])) { return $this->maybeSetDebugInfo($this::NC_DEBUG_EXCLUDED_URIS); - } - if (COMET_CACHE_EXCLUDE_AGENTS && !empty($_SERVER['HTTP_USER_AGENT']) && (!IS_PRO || !$this->isAutoCacheEngine())) { - if (preg_match(COMET_CACHE_EXCLUDE_AGENTS, $_SERVER['HTTP_USER_AGENT'])) { - return $this->maybeSetDebugInfo($this::NC_DEBUG_EXCLUDED_AGENTS); - } // Don't trip on requests by the auto-cache engine. - } - if (COMET_CACHE_EXCLUDE_REFS && !empty($_REQUEST['_wp_http_referer'])) { - if (preg_match(COMET_CACHE_EXCLUDE_REFS, stripslashes($_REQUEST['_wp_http_referer']))) { - return $this->maybeSetDebugInfo($this::NC_DEBUG_EXCLUDED_REFS); - } // This variable is set by WordPress core in some cases. - } - if (COMET_CACHE_EXCLUDE_REFS && !empty($_SERVER['HTTP_REFERER'])) { - if (preg_match(COMET_CACHE_EXCLUDE_REFS, $_SERVER['HTTP_REFERER'])) { - return $this->maybeSetDebugInfo($this::NC_DEBUG_EXCLUDED_REFS); - } // Based on the HTTP referrer in this case. + // + } elseif (isset($_SERVER['SERVER_ADDR']) && $this->currentIp() === $_SERVER['SERVER_ADDR'] && (!IS_PRO || !$this->isAutoCacheEngine()) && !$this->isLocalhost()) { + return $this->maybeSetDebugInfo($this::NC_DEBUG_SELF_SERVE_REQUEST); + // + } elseif (COMET_CACHE_EXCLUDE_AGENTS && !empty($_SERVER['HTTP_USER_AGENT']) && (!IS_PRO || !$this->isAutoCacheEngine()) && preg_match(COMET_CACHE_EXCLUDE_AGENTS, $_SERVER['HTTP_USER_AGENT'])) { + return $this->maybeSetDebugInfo($this::NC_DEBUG_EXCLUDED_AGENTS); + // + } elseif (COMET_CACHE_EXCLUDE_REFS && !empty($_REQUEST['_wp_http_referer']) && preg_match(COMET_CACHE_EXCLUDE_REFS, stripslashes($_REQUEST['_wp_http_referer']))) { + return $this->maybeSetDebugInfo($this::NC_DEBUG_EXCLUDED_REFS); + // + } elseif (COMET_CACHE_EXCLUDE_REFS && !empty($_SERVER['HTTP_REFERER']) && preg_match(COMET_CACHE_EXCLUDE_REFS, $_SERVER['HTTP_REFERER'])) { + return $this->maybeSetDebugInfo($this::NC_DEBUG_EXCLUDED_REFS); } $this->host_token = $this->hostToken(); $this->host_base_dir_tokens = $this->hostBaseDirTokens(); @@ -233,28 +225,28 @@ public function maybeStartOutputBuffering() if (IS_PRO && COMET_CACHE_WHEN_LOGGED_IN === 'postload' && $this->isLikeUserLoggedIn()) { $this->postload['when_logged_in'] = true; // Enable postload check. - } elseif (is_file($this->cache_file) && ($this->cache_max_age_disabled || filemtime($this->cache_file) >= $this->cache_max_age)) { - list($headers, $cache) = explode('', file_get_contents($this->cache_file), 2); - - $headers_list = $this->headersList(); // Headers that are enqueued already. + // + } elseif (extract($this->cacheRead())) { // `['headers' => [], 'output' => '', 'via' => '']` + $headers_list = $this->headersList(); // Headers enqueued already. - foreach (unserialize($headers) as $_header) { - if (!in_array($_header, $headers_list, true) && mb_stripos($_header, 'Last-Modified:') !== 0) { + foreach ($headers as $_header) { // Only send nonexistent headers. + if (!in_array($_header, $headers_list, true) && mb_stripos($_header, 'last-modified:') !== 0) { header($_header); // Only cacheable/safe headers are stored in the cache. } } // unset($_header); // Just a little housekeeping. - if (COMET_CACHE_DEBUGGING_ENABLE && $this->isHtmlXmlDoc($cache)) { + if (COMET_CACHE_DEBUGGING_ENABLE && $this->isHtmlXmlDoc($output)) { $total_time = number_format(microtime(true) - $this->timer, 5, '.', ''); $DebugNotes = new Classes\Notes(); - $DebugNotes->add(__('Loaded via Cache On', 'comet-cache'), date('M jS, Y @ g:i a T')); - $DebugNotes->add(__('Loaded via Cache In', 'comet-cache'), sprintf(__('%1$s seconds', 'comet-cache'), $total_time)); + $DebugNotes->add(__('Loaded From Cache', 'comet-cache'), 'via '.$via); + $DebugNotes->add(__('Loaded From Cache On', 'comet-cache'), date('M jS, Y @ g:i a T')); + $DebugNotes->add(__('Loaded From Cache In', 'comet-cache'), sprintf(__('%1$s seconds', 'comet-cache'), $total_time)); - $cache .= "\n\n".$DebugNotes->asHtmlComments(); + $output .= "\n\n".$DebugNotes->asHtmlComments(); } - exit($cache); // Exit with cache contents. + exit($output); // Exit with output contents. } else { ob_start([$this, 'outputBufferCallbackHandler']); } @@ -266,59 +258,78 @@ public function maybeStartOutputBuffering() * * @since 150422 Rewrite. * @since 170220 Adding API request constants. + * @since 17xxxx Implementing `cacheWrite()` utility. + * @since 17xxxx Condense using `elseif` chains. + * @since 17xxxx Polishing a little. + * + * @attaches-to {@link \ob_start()} * * @param string $buffer The buffer from {@link \ob_start()}. * @param int $phase A set of bitmask flags. * - * @throws \Exception If unable to handle output buffering for any reason. + * @throws \Exception If unable to handle output buffering. * - * @return string|bool The output buffer, or `FALSE` to indicate no change. + * @return string|bool The output buffer, or `false` to indicate no change. * - * @note We CANNOT depend on any WP functionality here; it will cause problems. + * @note Cannot depend on WP functionality here; it will cause problems. * Anything we need from WP should be saved in the postload phase as a scalar value. - * - * @attaches-to {@link \ob_start()} */ public function outputBufferCallbackHandler($buffer, $phase) { - if (!($phase & PHP_OUTPUT_HANDLER_END)) { - throw new \Exception(sprintf(__('Unexpected OB phase: `%1$s`.', 'comet-cache'), $phase)); - } Classes\AdvCacheBackCompat::zenCacheConstants(); - $cache = trim((string) $buffer); - - if (!isset($cache[0])) { - return false; // Don't cache an empty buffer. + if (!($phase & PHP_OUTPUT_HANDLER_END)) { + throw new \Exception('Unexpected OB phase.'); } - if (!isset($GLOBALS[GLOBAL_NS.'_shutdown_flag'])) { + if (!($output = trim((string) $buffer))) { + return false; // Empty buffer. + // + } elseif (!isset($GLOBALS[GLOBAL_NS.'_shutdown_flag'])) { return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_EARLY_BUFFER_TERMINATION); - } - if (defined('COMET_CACHE_ALLOWED') && !COMET_CACHE_ALLOWED) { + // + } elseif (defined('COMET_CACHE_ALLOWED') && !COMET_CACHE_ALLOWED) { return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_COMET_CACHE_ALLOWED_CONSTANT); - } - if (isset($_SERVER['COMET_CACHE_ALLOWED']) && !$_SERVER['COMET_CACHE_ALLOWED']) { + // + } elseif (isset($_SERVER['COMET_CACHE_ALLOWED']) && !$_SERVER['COMET_CACHE_ALLOWED']) { return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_COMET_CACHE_ALLOWED_SERVER_VAR); - } - if (defined('DONOTCACHEPAGE')) { + // + } elseif (defined('DONOTCACHEPAGE')) { return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_DONOTCACHEPAGE_CONSTANT); - } - if (isset($_SERVER['DONOTCACHEPAGE'])) { + // + } elseif (isset($_SERVER['DONOTCACHEPAGE'])) { return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_DONOTCACHEPAGE_SERVER_VAR); - } - if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) { + // + } elseif ($this->is_maintenance) { + return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_MAINTENANCE_PLUGIN); + // + } elseif (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) { return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_XMLRPC_REQUEST_CONSTANT); - } - if (defined('REST_REQUEST') && REST_REQUEST) { + // + } elseif (defined('REST_REQUEST') && REST_REQUEST) { return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_REST_REQUEST_CONSTANT); - } - if ((!IS_PRO || !COMET_CACHE_WHEN_LOGGED_IN) && $this->is_user_logged_in) { + // + } elseif ((!IS_PRO || !COMET_CACHE_WHEN_LOGGED_IN) && $this->is_user_logged_in) { return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_IS_LOGGED_IN_USER); - } - if ((!IS_PRO || !COMET_CACHE_WHEN_LOGGED_IN) && $this->isLikeUserLoggedIn()) { + // + } elseif ((!IS_PRO || !COMET_CACHE_WHEN_LOGGED_IN) && $this->isLikeUserLoggedIn()) { return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_IS_LIKE_LOGGED_IN_USER); + // + } elseif ($this->is_404 && !COMET_CACHE_CACHE_404_REQUESTS) { + return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_404_REQUEST); + // + } elseif (mb_stripos($output, '') !== false) { + return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_WP_ERROR_PAGE); + // + } elseif (!$this->hasACacheableContentType()) { + return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_UNCACHEABLE_CONTENT_TYPE); + // + } elseif (!$this->hasACacheableStatus()) { + return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_UNCACHEABLE_STATUS); + // + } elseif ($this->functionIsPossible('zlib_get_coding_type') && zlib_get_coding_type() && (!($zlib_oc = ini_get('zlib.output_compression')) || !filter_var($zlib_oc, FILTER_VALIDATE_BOOLEAN))) { + return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_OB_ZLIB_CODING_TYPE); } - if (!COMET_CACHE_CACHE_NONCE_VALUES && preg_match('/\b(?:_wpnonce|akismet_comment_nonce)\b/u', $cache)) { + if (!COMET_CACHE_CACHE_NONCE_VALUES && preg_match('/\b(?:_wpnonce|akismet_comment_nonce)\b/u', $output)) { if (IS_PRO && COMET_CACHE_WHEN_LOGGED_IN && $this->isLikeUserLoggedIn()) { if (!COMET_CACHE_CACHE_NONCE_VALUES_WHEN_LOGGED_IN) { return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_IS_LOGGED_IN_USER_NONCE); @@ -327,111 +338,6 @@ public function outputBufferCallbackHandler($buffer, $phase) return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_PAGE_CONTAINS_NONCE); } // An nonce makes the page dynamic; i.e., NOT cache compatible. } - if ($this->is_404 && !COMET_CACHE_CACHE_404_REQUESTS) { - return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_404_REQUEST); - } - if (mb_stripos($cache, '') !== false) { - return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_WP_ERROR_PAGE); - } - if (!$this->hasACacheableContentType()) { - return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_UNCACHEABLE_CONTENT_TYPE); - } - if (!$this->hasACacheableStatus()) { - return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_UNCACHEABLE_STATUS); - } - if ($this->is_maintenance) { - return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_MAINTENANCE_PLUGIN); - } - if ($this->functionIsPossible('zlib_get_coding_type') && zlib_get_coding_type() - && (!($zlib_oc = ini_get('zlib.output_compression')) || !filter_var($zlib_oc, FILTER_VALIDATE_BOOLEAN)) - ) { - return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_OB_ZLIB_CODING_TYPE); - } - # Lock the cache directory while writes take place here. - - $cache_lock = $this->cacheLock(); // Lock cache directory. - - # Construct a temp file for atomic cache writes. - - $cache_file_tmp = $this->addTmpSuffix($this->cache_file); - - # Cache directory checks. The cache file directory is created here if necessary. - - if (!is_dir(COMET_CACHE_DIR) && mkdir(COMET_CACHE_DIR, 0775, true) && !is_file(COMET_CACHE_DIR.'/.htaccess')) { - file_put_contents(COMET_CACHE_DIR.'/.htaccess', $this->htaccess_deny); - } - if (!is_dir($cache_file_dir = dirname($this->cache_file))) { - $cache_file_dir_writable = mkdir($cache_file_dir, 0775, true); - } - if (empty($cache_file_dir_writable) && !is_writable($cache_file_dir)) { - throw new \Exception(sprintf(__('Cache directory not writable. %1$s needs this directory please: `%2$s`. Set permissions to `755` or higher; `777` might be needed in some cases.', 'comet-cache'), NAME, $cache_file_dir)); - } - # This is where a new 404 request might be detected for the first time. - - if ($this->is_404 && is_file($this->cache_file_404)) { - if (!(symlink($this->cache_file_404, $cache_file_tmp) && rename($cache_file_tmp, $this->cache_file))) { - throw new \Exception(sprintf(__('Unable to create symlink: `%1$s` » `%2$s`. Possible permissions issue (or race condition), please check your cache directory: `%3$s`.', 'comet-cache'), $this->cache_file, $this->cache_file_404, COMET_CACHE_DIR)); - } - $this->cacheUnlock($cache_lock); // Release. - return (bool) $this->maybeSetDebugInfo($this::NC_DEBUG_1ST_TIME_404_SYMLINK); - } - /* ------- Otherwise, we need to construct & store a new cache file. ----------------------------------------------- */ - - - - if (COMET_CACHE_DEBUGGING_ENABLE && $this->isHtmlXmlDoc($cache)) { - $total_time = number_format(microtime(true) - $this->timer, 5, '.', ''); - $time = time(); // Needed below for expiration calculation. - - $DebugNotes = new Classes\Notes(); - $DebugNotes->addAsciiArt(sprintf(__('%1$s is Fully Functional', 'comet-cache'), NAME)); - $DebugNotes->addLineBreak(); - - if (IS_PRO && COMET_CACHE_WHEN_LOGGED_IN && $this->user_token) { - $DebugNotes->add(__('Cache File User Token', 'comet-cache'), $this->user_token); - } - if (IS_PRO && COMET_CACHE_MOBILE_ADAPTIVE_SALT_ENABLE && COMET_CACHE_MOBILE_ADAPTIVE_SALT && $this->mobile_adaptive_salt) { - // Note: Not using `$this->mobile_adaptive_salt` here. Instead, generating a human readable variation. - $DebugNotes->add(__('Cache File for Mobile Device', 'comet-cache'), $this->fillUaTokens(COMET_CACHE_MOBILE_ADAPTIVE_SALT, false)); - } - $DebugNotes->add(__('Cache File Version Salt', 'comet-cache'), $this->version_salt ? $this->version_salt : __('n/a', 'comet-cache')); - - $DebugNotes->addLineBreak(); - - $DebugNotes->add(__('Cache File URL', 'comet-cache'), $this->is_404 ? __('404 [error document]', 'comet-cache') : $this->protocol.$this->host_token.$_SERVER['REQUEST_URI']); - $DebugNotes->add(__('Cache File Path', 'comet-cache'), str_replace(WP_CONTENT_DIR, '', $this->is_404 ? $this->cache_file_404 : $this->cache_file)); - - $DebugNotes->addLineBreak(); - - $DebugNotes->add(__('Cache File Generated Via', 'comet-cache'), IS_PRO && $this->isAutoCacheEngine() ? __('Auto-Cache Engine', 'comet-cache') : __('HTTP request', 'comet-cache')); - $DebugNotes->add(__('Cache File Generated On', 'comet-cache'), date('M jS, Y @ g:i a T')); - $DebugNotes->add(__('Cache File Generated In', 'comet-cache'), sprintf(__('%1$s seconds', 'comet-cache'), $total_time)); - - $DebugNotes->addLineBreak(); - - if (IS_PRO && COMET_CACHE_WHEN_LOGGED_IN && $this->cache_max_age < $this->nonce_cache_max_age && preg_match('/\b(?:_wpnonce|akismet_comment_nonce)\b/u', $cache)) { - $DebugNotes->add(__('Cache File Expires Early', 'comet-cache'), __('yes, due to nonce in markup', 'comet-cache')); - $DebugNotes->add(__('Cache File Expires On', 'comet-cache'), date('M jS, Y @ g:i a T', $time + ($time - $this->nonce_cache_max_age))); - $DebugNotes->add(__('Cache File Auto-Rebuild On', 'comet-cache'), date('M jS, Y @ g:i a T', $time + ($time - $this->nonce_cache_max_age))); - } else { - $DebugNotes->add(__('Cache File Expires On', 'comet-cache'), date('M jS, Y @ g:i a T', $time + ($time - $this->cache_max_age))); - $DebugNotes->add(__('Cache File Auto-Rebuild On', 'comet-cache'), date('M jS, Y @ g:i a T', $time + ($time - $this->cache_max_age))); - } - $cache .= "\n".$DebugNotes->asHtmlComments(); - } - if ($this->is_404) { - if (file_put_contents($cache_file_tmp, serialize($this->cacheableHeadersList()).''.$cache) && rename($cache_file_tmp, $this->cache_file_404)) { - if (!(symlink($this->cache_file_404, $cache_file_tmp) && rename($cache_file_tmp, $this->cache_file))) { - throw new \Exception(sprintf(__('Unable to create symlink: `%1$s` » `%2$s`. Possible permissions issue (or race condition), please check your cache directory: `%3$s`.', 'comet-cache'), $this->cache_file, $this->cache_file_404, COMET_CACHE_DIR)); - } - $this->cacheUnlock($cache_lock); // Release. - return $cache; // Return the newly built cache; with possible debug info. - } - } elseif (file_put_contents($cache_file_tmp, serialize($this->cacheableHeadersList()).''.$cache) && rename($cache_file_tmp, $this->cache_file)) { - $this->cacheUnlock($cache_lock); // Release. - return $cache; // Return the newly built cache; with possible debug info. - } - @unlink($cache_file_tmp); // Clean this up (if it exists); and throw an exception with information for the site owner. - throw new \Exception(sprintf(__('%1$s: failed to write cache file for: `%2$s`; possible permissions issue (or race condition), please check your cache directory: `%3$s`.', 'comet-cache'), NAME, $_SERVER['REQUEST_URI'], COMET_CACHE_DIR)); + return $this->cacheWrite($output); } } diff --git a/src/includes/traits/Ac/PostloadUtils.php b/src/includes/traits/Ac/PostloadUtils.php index 6ba9753..62ce623 100644 --- a/src/includes/traits/Ac/PostloadUtils.php +++ b/src/includes/traits/Ac/PostloadUtils.php @@ -114,7 +114,6 @@ public function maybeFilterStatusHeaderPostload() if (empty($this->postload['filter_status_header'])) { return; // Nothing to do in this case. } - add_filter( 'status_header', function ($status_header, $status_code) { diff --git a/src/includes/traits/Plugin/WcpWooCommerceUtils.php b/src/includes/traits/Plugin/WcpWooCommerceUtils.php index e944e9e..4815580 100644 --- a/src/includes/traits/Plugin/WcpWooCommerceUtils.php +++ b/src/includes/traits/Plugin/WcpWooCommerceUtils.php @@ -24,7 +24,7 @@ public function autoClearPostCacheOnWooCommerceSetStock($product) $done = true; // Flag as having been done. if (class_exists('\\WooCommerce')) { - $counter += $this->autoClearPostCache($product->id); + $counter += $this->autoClearPostCache($product->get_id()); } } diff --git a/src/includes/traits/Shared/CacheDirUtils.php b/src/includes/traits/Shared/CacheDirUtils.php index 7227564..7883e92 100644 --- a/src/includes/traits/Shared/CacheDirUtils.php +++ b/src/includes/traits/Shared/CacheDirUtils.php @@ -109,7 +109,6 @@ public function purgeFilesFromHostCacheDir($regex) * * @return int Total files deleted by this routine (if any). * - * * @TODO Optimize this for multisite networks w/ a LOT of child blogs. * @TODO Optimize this for extremely large sites. A LOT of files here could slow things down. * This class member is currently used in wiping and purging for a network. So there is the potential for a LOT of files in a single scan. @@ -119,6 +118,8 @@ public function deleteFilesFromCacheDir($regex, $check_max_age = false) { $counter = 0; // Initialize. + + if (!($regex = (string) $regex)) { return $counter; // Nothing to do. } @@ -168,7 +169,6 @@ public function deleteFilesFromCacheDir($regex, $check_max_age = false) } switch ($_resource_type) {// Based on type; i.e., `link`, `file`, `dir`. case 'link': // Symbolic links; i.e., 404 errors. - if ($check_max_age && !empty($max_age) && is_file($_resource->getLinkTarget())) { if (($_lstat = lstat($_path_name)) && !empty($_lstat['mtime'])) { if ($_lstat['mtime'] >= $max_age) { @@ -185,7 +185,6 @@ public function deleteFilesFromCacheDir($regex, $check_max_age = false) break; // Break switch handler. case 'file': // Regular files; i.e., not symlinks. - if ($check_max_age && !empty($max_age)) { if ($_resource->getMTime() >= $max_age) { break; // Break switch. @@ -200,7 +199,6 @@ public function deleteFilesFromCacheDir($regex, $check_max_age = false) break; // Break switch handler. case 'dir': // A regular directory; i.e., not a symlink. - if (!in_array(rtrim(str_replace(['^', '$'], '', $regex), 'ui'), ['/.*/', '/.+/'], true)) { break; // Not deleting everything. } @@ -263,6 +261,8 @@ public function deleteFilesFromHostCacheDir( ) { $counter = 0; // Initialize. + + if (!($regex = (string) $regex)) { return $counter; // Nothing to do. } @@ -350,7 +350,6 @@ public function deleteFilesFromHostCacheDir( } switch ($_resource_type) {// Based on type; i.e., `link`, `file`, `dir`. case 'link': // Symbolic links; i.e., 404 errors. - if ($check_max_age && !empty($max_age) && is_file($_resource->getLinkTarget())) { if (($_lstat = lstat($_path_name)) && !empty($_lstat['mtime'])) { if ($_lstat['mtime'] >= $max_age) { @@ -367,7 +366,6 @@ public function deleteFilesFromHostCacheDir( break; // Break switch handler. case 'file': // Regular files; i.e., not symlinks. - if ($check_max_age && !empty($max_age)) { if ($_resource->getMTime() >= $max_age) { break; // Break switch handler. @@ -382,7 +380,6 @@ public function deleteFilesFromHostCacheDir( break; // Break switch handler. case 'dir': // A regular directory; i.e., not a symlink. - if (!in_array(rtrim(str_replace(['^', '$'], '', $regex), 'ui'), ['/.*/', '/.+/'], true)) { break; // Not deleting everything. } @@ -466,6 +463,8 @@ public function deleteAllFilesDirsIn($dir, $delete_dir_too = false) { $counter = 0; // Initialize. + + if (!($dir = trim((string) $dir)) || !is_dir($dir)) { return $counter; // Nothing to do. } @@ -496,7 +495,6 @@ public function deleteAllFilesDirsIn($dir, $delete_dir_too = false) switch ($_resource_type) {// Based on type; i.e., `link`, `file`, `dir`. case 'link': // Symbolic links; i.e., 404 errors. - if (!unlink($_path_name)) { $this->tryErasingAllFilesDirsIn($dir_temp, true); // Cleanup if possible. throw new \Exception(sprintf(__('Unable to delete symlink: `%1$s`.', 'comet-cache'), $_path_name)); @@ -506,7 +504,6 @@ public function deleteAllFilesDirsIn($dir, $delete_dir_too = false) break; // Break switch handler. case 'file': // Regular files; i.e., not symlinks. - if (!unlink($_path_name)) { $this->tryErasingAllFilesDirsIn($dir_temp, true); // Cleanup if possible. throw new \Exception(sprintf(__('Unable to delete file: `%1$s`.', 'comet-cache'), $_path_name)); @@ -516,7 +513,6 @@ public function deleteAllFilesDirsIn($dir, $delete_dir_too = false) break; // Break switch handler. case 'dir': // A regular directory; i.e., not a symlink. - if (!rmdir($_path_name)) { $this->tryErasingAllFilesDirsIn($dir_temp, true); // Cleanup if possible. throw new \Exception(sprintf(__('Unable to delete dir: `%1$s`.', 'comet-cache'), $_path_name)); @@ -572,6 +568,8 @@ public function eraseAllFilesDirsIn($dir, $erase_dir_too = false) { $counter = 0; // Initialize. + + if (!($dir = trim((string) $dir)) || !is_dir($dir)) { return $counter; // Nothing to do. } @@ -594,7 +592,6 @@ public function eraseAllFilesDirsIn($dir, $erase_dir_too = false) switch ($_resource_type) {// Based on type; i.e., `link`, `file`, `dir`. case 'link': // Symbolic links; i.e., 404 errors. - if (!unlink($_path_name)) { throw new \Exception(sprintf(__('Unable to erase symlink: `%1$s`.', 'comet-cache'), $_path_name)); } @@ -603,7 +600,6 @@ public function eraseAllFilesDirsIn($dir, $erase_dir_too = false) break; // Break switch handler. case 'file': // Regular files; i.e., not symlinks. - if (!unlink($_path_name)) { throw new \Exception(sprintf(__('Unable to erase file: `%1$s`.', 'comet-cache'), $_path_name)); } @@ -612,7 +608,6 @@ public function eraseAllFilesDirsIn($dir, $erase_dir_too = false) break; // Break switch handler. case 'dir': // A regular directory; i.e., not a symlink. - if (!rmdir($_path_name)) { throw new \Exception(sprintf(__('Unable to erase dir: `%1$s`.', 'comet-cache'), $_path_name)); } diff --git a/src/includes/traits/Shared/FsUtils.php b/src/includes/traits/Shared/FsUtils.php index 49f745e..a65c8c2 100644 --- a/src/includes/traits/Shared/FsUtils.php +++ b/src/includes/traits/Shared/FsUtils.php @@ -317,9 +317,14 @@ public function getDirRegexStats($dir, $regex = '', $include_paths = false, $che unset($_resource, $_resource_sub_path, $_resource_basename); // Housekeeping. if ($check_disk) { // Check disk also? - $stats['disk_total_space'] = disk_total_space($dir); - $stats['disk_free_space'] = disk_free_space($dir); + if ($this->functionIsPossible('disk_total_space')) { + $stats['disk_total_space'] = disk_total_space($dir); + } + if ($this->functionIsPossible('disk_free_space')) { + $stats['disk_free_space'] = disk_free_space($dir); + } } + return $stats; } diff --git a/src/includes/traits/Shared/HttpUtils.php b/src/includes/traits/Shared/HttpUtils.php index 0dda455..f161b04 100644 --- a/src/includes/traits/Shared/HttpUtils.php +++ b/src/includes/traits/Shared/HttpUtils.php @@ -89,6 +89,7 @@ public function cacheableHeadersList() 'Pragma', 'Proxy-Authenticate', 'Refresh', + 'Referrer-Policy', 'Retry-After', 'Server', 'Status', @@ -123,7 +124,7 @@ public function cacheableHeadersList() if (($status = (string) $this->httpStatus())) { array_unshift($headers, $this->httpProtocol().' '.$status); } - return $headers; + return apply_filters(GLOBAL_NS.'_cacheable_headers', $headers); } /**