From 2f0825a56b430d2011124945c9775d1b08c35fcf Mon Sep 17 00:00:00 2001 From: renzms Date: Mon, 18 Apr 2016 23:21:45 +0800 Subject: [PATCH 1/8] Add UI to enable Admin Bar while Logged-In User caching is enabled; see: websharks/comet-cache#690 --- src/includes/classes/MenuPageOptions.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/includes/classes/MenuPageOptions.php b/src/includes/classes/MenuPageOptions.php index 03d896c9..b3857d5c 100644 --- a/src/includes/classes/MenuPageOptions.php +++ b/src/includes/classes/MenuPageOptions.php @@ -615,8 +615,23 @@ public function __construct() echo ' '."\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 '

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

'."\n"; + echo '

'.__('When Logged-In User caching is enabled, Comet Cache will automatically disable the WordPress Admin Bar for logged-in users (on the front-end of the site). This option allows you to override this and turn back on the Admin Bar when Logged-In User caching is enabled.).', SLUG_TD).'

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

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

'.__('Note: If you are enabling the WordPress Admin Bar for logged-in users, and are allowing Nonce caching using COMET_CACHE_CACHE_NONCE_VALUES_WHEN_LOGGED_IN;, please see this article.', SLUG_TD).'

'."\n"; echo ' '."\n"; + echo ''."\n"; } /* ----------------------------------------------------------------------------------------- */ From 2ef529bfe65a278ab8800fa470966e5b066b36a7 Mon Sep 17 00:00:00 2001 From: renzms Date: Sun, 24 Apr 2016 01:52:01 +0800 Subject: [PATCH 2/8] Updates for Adding UI to enable Admin Bar while logged-in; see websharks/comet-cache#690 --- src/includes/classes/MenuPageOptions.php | 15 ++++++--------- src/includes/classes/Plugin.php | 4 ++++ src/includes/templates/advanced-cache.txt | 12 ++++++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/includes/classes/MenuPageOptions.php b/src/includes/classes/MenuPageOptions.php index b3857d5c..93647525 100644 --- a/src/includes/classes/MenuPageOptions.php +++ b/src/includes/classes/MenuPageOptions.php @@ -618,15 +618,12 @@ public function __construct() echo '
'."\n"; echo '

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

'."\n"; echo '

'.__('When Logged-In User caching is enabled, Comet Cache will automatically disable the WordPress Admin Bar for logged-in users (on the front-end of the site). This option allows you to override this and turn back on the Admin Bar when Logged-In User caching is enabled.).', SLUG_TD).'

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

'."\n"; + echo '

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

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

'."\n"; - if ($this->plugin->options['when_logged_in_admin_bar'] === '0' && $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.', SLUG_TD), esc_html(NAME)).'

'."\n"; - } echo '

'.__('Note: If you are enabling the WordPress Admin Bar for logged-in users, and are allowing Nonce caching using COMET_CACHE_CACHE_NONCE_VALUES_WHEN_LOGGED_IN;, please see this article.', SLUG_TD).'

'."\n"; echo ' '."\n"; - echo ''."\n"; } /* ----------------------------------------------------------------------------------------- */ diff --git a/src/includes/classes/Plugin.php b/src/includes/classes/Plugin.php index f8be133a..6e9f86ec 100644 --- a/src/includes/classes/Plugin.php +++ b/src/includes/classes/Plugin.php @@ -575,7 +575,7 @@ public function setup() } /*[pro strip-from="lite"]*/ - if ($this->options['when_logged_in'] === '1' && $this->applyWpFilters(GLOBAL_NS.'_when_logged_in_no_admin_bar', true)) { + if ($this->options['when_logged_in'] && $this->applyWpFilters(GLOBAL_NS.'_when_logged_in_no_admin_bar', true)) { show_admin_bar(false); // Prevent admin bar from being cached. } /*[/pro]*/ From e88f3284c988287a476fd962ad9ca27f0ffdee96 Mon Sep 17 00:00:00 2001 From: Raam Dev Date: Fri, 13 May 2016 18:06:15 -0400 Subject: [PATCH 6/8] Remove COMET_CACHE_WHEN_LOGGED_IN_ADMIN_BAR from advanced-cache.txt This is not used and not necessary. See websharks/comet-cache#690 --- src/includes/templates/advanced-cache.txt | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/includes/templates/advanced-cache.txt b/src/includes/templates/advanced-cache.txt index 9581f164..4489feaa 100644 --- a/src/includes/templates/advanced-cache.txt +++ b/src/includes/templates/advanced-cache.txt @@ -143,18 +143,6 @@ if (!defined('COMET_CACHE_WHEN_LOGGED_IN')) { define('COMET_CACHE_WHEN_LOGGED_IN', '%%COMET_CACHE_WHEN_LOGGED_IN%%'); } /*[/pro]*/ -/*[pro strip-from="lite"]*/ -if (!defined('COMET_CACHE_WHEN_LOGGED_IN_ADMIN_BAR')) { - /** - * Enable Admin Bar when caching for logged-in users is enabled? - * - * @since 160xxx First documented version. - * - * @var string|integer|boolean A boolean-ish value; e.g. `1` or `0`. - */ - define('COMET_CACHE_WHEN_LOGGED_IN_ADMIN_BAR', '%%COMET_CACHE_WHEN_LOGGED_IN_ADMIN_BAR%%'); -} -/*[/pro]*/ if (!defined('COMET_CACHE_DIR')) { /** * Directory used to store cache files; relative to `WP_CONTENT_DIR`. From 45205d71d47f67247ceb981e95ddf487cee1e270 Mon Sep 17 00:00:00 2001 From: Raam Dev Date: Fri, 13 May 2016 18:07:03 -0400 Subject: [PATCH 7/8] Disable the admin bar by default when logged-in user caching enabled Disabled is the recommended setting, so we should default to disabled. See websharks/comet-cache#690 --- src/includes/classes/Plugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/includes/classes/Plugin.php b/src/includes/classes/Plugin.php index 6e9f86ec..6980ea3d 100644 --- a/src/includes/classes/Plugin.php +++ b/src/includes/classes/Plugin.php @@ -392,7 +392,7 @@ public function setup() 'htmlc_when_logged_in' => '0', // `0|1`; enable when logged in? /* Related to Logged-In User Caching */ - 'when_logged_in_admin_bar' => '1', // `0|1`; enable when logged in? + 'when_logged_in_admin_bar' => '0', // `0|1`; enable when logged in? /* Related to auto-cache engine. */ @@ -575,7 +575,7 @@ public function setup() } /*[pro strip-from="lite"]*/ - if ($this->options['when_logged_in'] && $this->applyWpFilters(GLOBAL_NS.'_when_logged_in_no_admin_bar', true)) { + if ($this->options['when_logged_in'] && !$this->options['when_logged_in_admin_bar'] && $this->applyWpFilters(GLOBAL_NS.'_when_logged_in_no_admin_bar', true)) { show_admin_bar(false); // Prevent admin bar from being cached. } /*[/pro]*/ From 12e27feea330a7199fbf0169658652c6463511bb Mon Sep 17 00:00:00 2001 From: Raam Dev Date: Fri, 13 May 2016 18:16:47 -0400 Subject: [PATCH 8/8] Improve wording for new Admin Toolbar option for Logged-In User Caching See websharks/comet-cache#690 --- src/includes/classes/MenuPageOptions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/includes/classes/MenuPageOptions.php b/src/includes/classes/MenuPageOptions.php index 47fae7d3..7430cab7 100644 --- a/src/includes/classes/MenuPageOptions.php +++ b/src/includes/classes/MenuPageOptions.php @@ -616,14 +616,14 @@ public function __construct() 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 '

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

'."\n"; - echo '

'.__('When Logged-In User caching is enabled, Comet Cache will automatically disable the WordPress Admin Bar for logged-in users (on the front-end of the site). This option allows you to override this and turn back on the Admin Bar when Logged-In User caching is enabled.).', SLUG_TD).'

'."\n"; + echo '

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

'."\n"; + echo '

'.__('When Logged-In User caching is enabled above, Comet Cache will automatically 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 to enable the Toolbar for logged-in users anyway, you can do that below.', SLUG_TD).'

'."\n"; echo '

'."\n"; - echo '

'.__('Note: If you are enabling the WordPress Admin Bar for logged-in users, and are allowing Nonce caching using COMET_CACHE_CACHE_NONCE_VALUES_WHEN_LOGGED_IN;, please see this article.', SLUG_TD).'

'."\n"; + echo '

'.__('Note: Enabling the Toolbar for logged-in users 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 ''."\n";