diff --git a/src/client-s/js/menu-pages.js b/src/client-s/js/menu-pages.js index 63fa8a6d..9e32c4f1 100644 --- a/src/client-s/js/menu-pages.js +++ b/src/client-s/js/menu-pages.js @@ -22,7 +22,7 @@ $('[data-action]', plugin.$menuPage).on('click', plugin.doDataAction); $('[data-toggle-target]', plugin.$menuPage).on('click', plugin.doDataToggleTarget); - $('select[name$="_enable\\]"]', plugin.$menuPage).not('.-no-if-enabled').on('change', plugin.enableDisable).trigger('change'); + $('select[name$="_enable\\]"], select[data-toggle~="enable-disable"]', plugin.$menuPage).not('.-no-if-enabled').on('change', plugin.enableDisable).trigger('change'); /*![pro strip-from='lite']*/ $('textarea[name$="\[cdn_hosts\]"]', plugin.$menuPage).on('input propertychange', plugin.handleCdnHostsChange); @@ -75,7 +75,8 @@ var $this = $(this), thisValue = $this.val(), thisName = $this.attr('name'), - enabled = Number(thisValue) >= 1, + thisEnabledStrings = String($this.data('enabledStrings') || '1,2,3,4,5').split(/,+/), + enabled = $.inArray(thisValue, thisEnabledStrings) !== -1, $thisPanelBody = $this.closest('.plugin-menu-page-panel-body'), diff --git a/src/client-s/js/menu-pages.min.js b/src/client-s/js/menu-pages.min.js index 7ace61c8..96670854 100644 --- a/src/client-s/js/menu-pages.min.js +++ b/src/client-s/js/menu-pages.min.js @@ -2,7 +2,7 @@ /*![pro strip-from='lite']*/ ;a.statsData=null;a.statsRunning=false; /*![/pro]*/ -;a.$menuPage=b("#plugin-menu-page");a.vars=window[a.namespace+"_menu_page_vars"];b(".plugin-menu-page-panel-heading",a.$menuPage).on("click",a.togglePanel);b(".plugin-menu-page-panels-open",a.$menuPage).on("click",a.toggleAllPanelsOpen);b(".plugin-menu-page-panels-close",a.$menuPage).on("click",a.toggleAllPanelsClose);b("[data-action]",a.$menuPage).on("click",a.doDataAction);b("[data-toggle-target]",a.$menuPage).on("click",a.doDataToggleTarget);b('select[name$="_enable\\]"]',a.$menuPage).not(".-no-if-enabled").on("change",a.enableDisable).trigger("change"); +;a.$menuPage=b("#plugin-menu-page");a.vars=window[a.namespace+"_menu_page_vars"];b(".plugin-menu-page-panel-heading",a.$menuPage).on("click",a.togglePanel);b(".plugin-menu-page-panels-open",a.$menuPage).on("click",a.toggleAllPanelsOpen);b(".plugin-menu-page-panels-close",a.$menuPage).on("click",a.toggleAllPanelsClose);b("[data-action]",a.$menuPage).on("click",a.doDataAction);b("[data-toggle-target]",a.$menuPage).on("click",a.doDataToggleTarget);b('select[name$="_enable\\]"], select[data-toggle~="enable-disable"]',a.$menuPage).not(".-no-if-enabled").on("change",a.enableDisable).trigger("change"); /*![pro strip-from='lite']*/ ;b('textarea[name$="[cdn_hosts]"]',a.$menuPage).on("input propertychange",a.handleCdnHostsChange);b(".plugin-menu-page-clear-cdn-cache",a.$menuPage).on("click",a.clearCdnCacheViaAjax); /*![pro strip-from='lite']*/ @@ -10,7 +10,7 @@ /*![pro strip-from='lite']*/ ;if(b(".plugin-menu-page-stats",a.$menuPage).length){b(".plugin-menu-page-stats-button").on("click",a.statsRefresh);a.stats()} /*![/pro]*/ -};a.toggleAllPanelsOpen=function(e){a.preventDefault(e);b(".plugin-menu-page-panel-heading",a.$menuPage).addClass("open").next(".plugin-menu-page-panel-body").addClass("open")};a.toggleAllPanelsClose=function(e){a.preventDefault(e);b(".plugin-menu-page-panel-heading",a.$menuPage).removeClass("open").next(".plugin-menu-page-panel-body").removeClass("open")};a.togglePanel=function(e){a.preventDefault(e);b(this).toggleClass("open").next(".plugin-menu-page-panel-body").toggleClass("open")};a.doDataAction=function(e){a.preventDefault(e);var g=b(this),f=g.data();if(typeof f.confirmation!=="string"||confirm(f.confirmation)){location.href=f.action}};a.enableDisable=function(e){var m=b(this),g=m.val(),f=m.attr("name"),l=Number(g)>=1,i=m.closest(".plugin-menu-page-panel-body"),n=m.data("target"),h=n?b(n,i).filter(".plugin-menu-page-panel-if-enabled"):null,k=m.closest(".plugin-menu-page-panel-if-enabled"),j=k.find("> .plugin-menu-page-panel-if-enabled"),o=i.find("> .plugin-menu-page-panel-if-enabled");if(l){if(n){h.css("opacity",1).find(":input").removeAttr("readonly")}else{if(k.length){j.css("opacity",1).find(":input").removeAttr("readonly")}else{o.css("opacity",1).find(":input").removeAttr("readonly")}}}else{if(n){h.css("opacity",0.4).find(":input").attr("readonly","readonly")}else{if(k.length){j.css("opacity",0.4).find(":input").attr("readonly","readonly")}else{o.css("opacity",0.4).find(":input").attr("readonly","readonly")}}}};a.doDataToggleTarget=function(f){a.preventDefault(f);var g=b(this),e=b(g.data("toggleTarget"));if(e.is(":visible")){e.hide();g.find(".si").removeClass("si-eye-slash").addClass("si-eye")}else{e.show();g.find(".si").removeClass("si-eye").addClass("si-eye-slash")}};a.handleCacheClearAdminBarOpsChange=function(g){var f=b(this),h=f.val(),e=b(".-clear-cache-ops-ss",a.$menuPage);e.attr("src",e.attr("src").replace(/ops[0-9]\-ss\.png$/,"ops"+h+"-ss.png"))};a.handleCdnHostsChange=function(f){var g=b(this),e=b('input[name$="[cdn_host]"]',a.$menuPage);if(b.trim(g.val())){if(e.val()){e.data("hiddenValue",e.val())}e.attr("disabled","disabled").val("")}else{if(!e.val()){e.val(e.data("hiddenValue"))}e.removeAttr("disabled");g.val("")}}; +};a.toggleAllPanelsOpen=function(e){a.preventDefault(e);b(".plugin-menu-page-panel-heading",a.$menuPage).addClass("open").next(".plugin-menu-page-panel-body").addClass("open")};a.toggleAllPanelsClose=function(e){a.preventDefault(e);b(".plugin-menu-page-panel-heading",a.$menuPage).removeClass("open").next(".plugin-menu-page-panel-body").removeClass("open")};a.togglePanel=function(e){a.preventDefault(e);b(this).toggleClass("open").next(".plugin-menu-page-panel-body").toggleClass("open")};a.doDataAction=function(e){a.preventDefault(e);var g=b(this),f=g.data();if(typeof f.confirmation!=="string"||confirm(f.confirmation)){location.href=f.action}};a.enableDisable=function(e){var m=b(this),g=m.val(),f=m.attr("name"),o=String(m.data("enabledStrings")||"1,2,3,4,5").split(/,+/),l=b.inArray(g,o)!==-1,i=m.closest(".plugin-menu-page-panel-body"),n=m.data("target"),h=n?b(n,i).filter(".plugin-menu-page-panel-if-enabled"):null,k=m.closest(".plugin-menu-page-panel-if-enabled"),j=k.find("> .plugin-menu-page-panel-if-enabled"),p=i.find("> .plugin-menu-page-panel-if-enabled");if(l){if(n){h.css("opacity",1).find(":input").removeAttr("readonly")}else{if(k.length){j.css("opacity",1).find(":input").removeAttr("readonly")}else{p.css("opacity",1).find(":input").removeAttr("readonly")}}}else{if(n){h.css("opacity",0.4).find(":input").attr("readonly","readonly")}else{if(k.length){j.css("opacity",0.4).find(":input").attr("readonly","readonly")}else{p.css("opacity",0.4).find(":input").attr("readonly","readonly")}}}};a.doDataToggleTarget=function(f){a.preventDefault(f);var g=b(this),e=b(g.data("toggleTarget"));if(e.is(":visible")){e.hide();g.find(".si").removeClass("si-eye-slash").addClass("si-eye")}else{e.show();g.find(".si").removeClass("si-eye").addClass("si-eye-slash")}};a.handleCacheClearAdminBarOpsChange=function(g){var f=b(this),h=f.val(),e=b(".-clear-cache-ops-ss",a.$menuPage);e.attr("src",e.attr("src").replace(/ops[0-9]\-ss\.png$/,"ops"+h+"-ss.png"))};a.handleCdnHostsChange=function(f){var g=b(this),e=b('input[name$="[cdn_host]"]',a.$menuPage);if(b.trim(g.val())){if(e.val()){e.data("hiddenValue",e.val())}e.attr("disabled","disabled").val("")}else{if(!e.val()){e.val(e.data("hiddenValue"))}e.removeAttr("disabled");g.val("")}}; /*![pro strip-from='lite']*/ ;a.clearCdnCacheViaAjax=function(f){a.preventDefault(f);var g=b(this),e={_wpnonce:a.vars._wpnonce};e[a.namespace]={ajaxClearCdnCache:"1"};g.attr("disabled","disabled");b.post(a.vars.ajaxURL,e,function(h){alert(b(h.replace(/\<\/p\>\/gi,"

")).text());g.removeAttr("disabled")})}; /*![pro strip-from='lite']*/ diff --git a/src/includes/classes/MenuPageOptions.php b/src/includes/classes/MenuPageOptions.php index 8c644a05..104fd852 100644 --- a/src/includes/classes/MenuPageOptions.php +++ b/src/includes/classes/MenuPageOptions.php @@ -567,18 +567,21 @@ public function __construct() echo '

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

'."\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.', SLUG_TD), 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.', SLUG_TD).'

'."\n"; - echo '

'."\n"; echo ' '."\n"; echo ' '."\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.', SLUG_TD).'

'."\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.', SLUG_TD).'

'."\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.', SLUG_TD), esc_html(NAME), esc_html(strtolower(SHORT_NAME))).'

'."\n"; - echo '

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

'."\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.', SLUG_TD).'

'."\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.', SLUG_TD).'

'."\n"; - echo '

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

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

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

'."\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.', SLUG_TD).'

'."\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.', SLUG_TD).'

'."\n"; + echo '

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

'."\n"; + echo '
'."\n"; echo ' '."\n"; echo ''."\n"; @@ -598,9 +601,9 @@ public function __construct() echo '

'.__('This should almost ALWAYS be set to No. Most sites will NOT want to 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. Imagine visiting a website that says you\'re logged-in as Billy Bob (but you\'re not Billy Bob; NOT good). In short, do NOT turn this on unless you know what you\'re doing.', SLUG_TD).'

'."\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, please 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 (e.g., 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 (e.g., it\'s NOT an issue in most cases). Unless you are short on disk space (or you have MANY thousands of users), the disk overhead is neglible.', SLUG_TD), esc_html(NAME)).'

'."\n"; - echo '

'."\n"; + echo ' '."\n"; + echo ' '."\n"; if ($this->plugin->options['when_logged_in'] === '1' || get_site_option(GLOBAL_NS.'_when_logged_in_was_1')) { update_site_option(GLOBAL_NS.'_when_logged_in_was_1', '1'); echo ' '."\n"; @@ -612,22 +615,30 @@ public function __construct() echo '

'.__('Note: For most sites, the majority of their traffic (if not all of their traffic) comes from visitors who are not logged in, so disabling the cache for logged-in users is NOT ordinarily a performance issue. When a user IS logged-in, disabling the cache is considered ideal, because a logged-in user has a session open with your site; and the content they view should remain very dynamic in this scenario.', SLUG_TD).'

'."\n"; echo '

'.sprintf(__('Note: This setting includes some users who AREN\'T actually logged into the system, but who HAVE authored comments recently. %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 the comment thread 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 included.', SLUG_TD), esc_html(NAME)).'

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

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

'."\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 users. 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.', SLUG_TD).'

'."\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.', SLUG_TD).'

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

'.__('Disable the Admin Toolbar for Logged-In Users & Comment Authors?', SLUG_TD).'

'."\n"; - echo '

'.__('When Logged-In User caching is enabled above, it is recommended that you disable the WordPress Admin Toolbar for logged-in users (on the front-end of the site) because the Toolbar is generally NOT cache-compatible. If you want Comet Cache to automatically disable the Toolbar for logged-in users, you can choose that option below. Or, if you use another plugin to control the Admin Toolbar you can leave this option disabled.', SLUG_TD).'

'."\n"; - echo '

'."\n"; - - echo '

'.__('Note: If you don\'t disable the Admin Toolbar for logged-in users that will cause WordPress Nonce values to appear in the page source; nonce values are generally NOT cache-compatible. Please see this article for details.', SLUG_TD).'

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

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

'."\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 users. 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.', SLUG_TD).'

'."\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.', SLUG_TD).'

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

'.__('Disable the Admin Toolbar for Logged-In Users & Comment Authors?', SLUG_TD).'

'."\n"; + echo '

'.__('When Logged-In User caching is enabled above, it is recommended that you disable the WordPress Admin Toolbar for logged-in users (on the front-end of the site) because the Toolbar is generally NOT cache-compatible. If you want Comet Cache to automatically disable the Toolbar for logged-in users, you can choose that option below. Or, if you use another plugin to control the Admin Toolbar you can leave this option disabled.', SLUG_TD).'

'."\n"; + echo '

'."\n"; + echo '

'.__('Note: If you don\'t disable the Admin Toolbar for logged-in users that will cause WordPress Nonce values to appear in the page source; nonce values are generally NOT cache-compatible. Please see this article for details.', SLUG_TD).'

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

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

'."\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.', SLUG_TD).'

'."\n"; + echo '

'."\n"; + echo '
'."\n"; echo ' '."\n"; echo ''."\n"; @@ -905,13 +916,6 @@ public function __construct() 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.', SLUG_TD).'

'."\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.', SLUG_TD), esc_html(NAME)).'

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

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

'."\n"; - echo '

'.__('Disabled by default. This setting is only applicable when caching for Logged-In Users is enabled. This 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 (when Logged-In User caching is enabled). 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.', SLUG_TD).'

'."\n"; - echo '

'."\n"; echo ' '."\n"; echo ' '."\n"; diff --git a/src/includes/traits/Ac/BrowserUtils.php b/src/includes/traits/Ac/BrowserUtils.php index 2953a96c..aa64c2e9 100644 --- a/src/includes/traits/Ac/BrowserUtils.php +++ b/src/includes/traits/Ac/BrowserUtils.php @@ -21,7 +21,7 @@ public function maybeStopBrowserCaching() return $this->sendNoCacheHeaders(); // Disallow. } // Else, allow client-side caching; because `ABC` is a true-ish value. // ↑ Note that exclusion patterns are ignored in this case, in favor of `ABC`. - } elseif (COMET_CACHE_EXCLUDE_CLIENT_SIDE_URIS && preg_match(COMET_CACHE_EXCLUDE_CLIENT_SIDE_URIS, $_SERVER['REQUEST_URI'])) { + } elseif (COMET_CACHE_EXCLUDE_CLIENT_SIDE_URIS && (empty($_SERVER['REQUEST_URI']) || preg_match(COMET_CACHE_EXCLUDE_CLIENT_SIDE_URIS, $_SERVER['REQUEST_URI']))) { return $this->sendNoCacheHeaders(); // Disallow. } return; // Allow browser caching; default behavior in this mode. diff --git a/src/includes/traits/Plugin/DirUtils.php b/src/includes/traits/Plugin/DirUtils.php index 9dbef834..3c2b223c 100644 --- a/src/includes/traits/Plugin/DirUtils.php +++ b/src/includes/traits/Plugin/DirUtils.php @@ -74,7 +74,7 @@ public function wpHomePath() { $home = set_url_scheme(get_option('home'), 'http'); $siteurl = set_url_scheme(get_option('siteurl'), 'http'); - if (!empty($home) && 0 !== strcasecmp($home, $siteurl)) { + if (!empty($home) && 0 !== strcasecmp($home, $siteurl) && !empty($_SERVER['SCRIPT_FILENAME'])) { $wp_path_rel_to_home = str_ireplace($home, '', $siteurl); /* $siteurl - $home */ $pos = strripos(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']), trailingslashit($wp_path_rel_to_home)); $home_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos); diff --git a/src/includes/traits/Plugin/NoticeUtils.php b/src/includes/traits/Plugin/NoticeUtils.php index 76f98732..d0cd7b50 100644 --- a/src/includes/traits/Plugin/NoticeUtils.php +++ b/src/includes/traits/Plugin/NoticeUtils.php @@ -151,7 +151,7 @@ public function allAdminNotices() } # Current URI matches a limited scope/context for this notice? - if ($_notice['only_on_uris'] && !@preg_match($_notice['only_on_uris'], $_SERVER['REQUEST_URI'])) { + if ($_notice['only_on_uris'] && (empty($_SERVER['REQUEST_URI']) || !@preg_match($_notice['only_on_uris'], $_SERVER['REQUEST_URI']))) { continue; // Not in the right context at the moment; i.e., does not regex. } # If persistent, allow a site owner to dismiss. diff --git a/src/includes/traits/Shared/TokenUtils.php b/src/includes/traits/Shared/TokenUtils.php index 3dc452c8..19fa069d 100644 --- a/src/includes/traits/Shared/TokenUtils.php +++ b/src/includes/traits/Shared/TokenUtils.php @@ -38,19 +38,22 @@ public function hostToken($dashify = false, $consider_domain_mapping = false, $c $token = ''; // Initialize token value. if (!is_multisite() || $this->isAdvancedCache()) { - $token = (string) $_SERVER['HTTP_HOST']; + $token = !empty($_SERVER['HTTP_HOST']) ? (string) $_SERVER['HTTP_HOST'] : ''; } elseif ($consider_domain_mapping && $this->canConsiderDomainMapping()) { if (($consider_domain_mapping_domain = trim((string) $consider_domain_mapping_domain))) { $token = $consider_domain_mapping_domain; } elseif ($this->isDomainMapping()) { - $token = (string) $_SERVER['HTTP_HOST']; + $token = !empty($_SERVER['HTTP_HOST']) ? (string) $_SERVER['HTTP_HOST'] : ''; } else { // For the current blog ID. $token = $this->domainMappingUrlFilter($this->currentUrl()); $token = $this->parseUrl($token, PHP_URL_HOST); } } if (!$token) { // Use default? - $token = (string) $_SERVER['HTTP_HOST']; + $token = !empty($_SERVER['HTTP_HOST']) ? (string) $_SERVER['HTTP_HOST'] : ''; + } + if (!$token && $this->isPlugin()) { + $token = (string) parse_url(home_url(), PHP_URL_HOST); } if ($token) { // Have token? $token = strtolower($token); diff --git a/src/includes/traits/Shared/UrlUtils.php b/src/includes/traits/Shared/UrlUtils.php index 71262e6c..499388a9 100644 --- a/src/includes/traits/Shared/UrlUtils.php +++ b/src/includes/traits/Shared/UrlUtils.php @@ -135,6 +135,9 @@ public function isSsl() */ public function currentUrl() { + if (empty($_SERVER['HTTP_HOST']) || empty($_SERVER['REQUEST_URI'])) { + return ''; // Not possible. + } return ($this->isSsl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; } }