Skip to content

Commit

Permalink
Dim additional options for Logged-In Users when feature is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed May 17, 2016
1 parent e099423 commit 9789252
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/client-s/js/menu-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),

Expand Down
2 changes: 1 addition & 1 deletion src/client-s/js/menu-pages.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 18 additions & 17 deletions src/includes/classes/MenuPageOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ public function __construct()
echo ' <p>'.__('This should almost ALWAYS be set to <code>No</code>. 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).'</p>'."\n";
echo ' <i class="si si-sitemap si-4x" style="float:right; margin: 0 0 0 25px;"></i>'."\n";
echo ' <p>'.sprintf(__('<strong>Exception (Membership Sites):</strong> If you run a site with many users and the majority of your traffic comes from users who ARE logged-in, please choose: <code>Yes (maintain separate cache)</code>. %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 <a href="http://codex.wordpress.org/Function_Reference/update_user_option" target="_blank">option</a>|<a href="http://codex.wordpress.org/Function_Reference/update_user_meta" target="_blank">meta</a> additions, updates &amp; 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)).'</p>'."\n";
echo ' <p><select name="'.esc_attr(GLOBAL_NS).'[saveOptions][when_logged_in]">'."\n";
echo ' <p><select name="'.esc_attr(GLOBAL_NS).'[saveOptions][when_logged_in]" data-enabled-strings="1,postload" data-target=".-logged-in-users-options">'."\n";
echo ' <option value="0"'.selected($this->plugin->options['when_logged_in'], '0', false).'>'.__('No, do NOT cache; or serve a cache file when a user is logged-in (safest option).', SLUG_TD).'</option>'."\n";
echo ' <option value="postload"'.selected($this->plugin->options['when_logged_in'], 'postload', false).'>'.__('Yes, and maintain a separate cache for each user (recommended for membership sites).', SLUG_TD).'</option>'."\n";
if ($this->plugin->options['when_logged_in'] === '1' || get_site_option(GLOBAL_NS.'_when_logged_in_was_1')) {
Expand All @@ -608,22 +608,23 @@ public function __construct()
echo ' <p class="info">'.__('<strong>Note:</strong> 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).'</p>'."\n";
echo ' <p class="info">'.sprintf(__('<strong>Note:</strong> 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)).'</p>'."\n";
echo ' <hr />'."\n";
echo ' <h3>'.__('Static CDN Filters Enabled for Logged-In Users &amp; Comment Authors?', SLUG_TD).'</h3>'."\n";
echo ' <p>'.__('While this defaults to a value of <code>No</code>, it should almost always be set to <code>Yes</code>. This value defaults to <code>No</code> only because Logged-In User caching (see above) defaults to <code>No</code> and setting this value to <code>Yes</code> 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 <code>Yes</code> in the dropdown below. If you are not using Static CDN Filters, the value below is ignored.', SLUG_TD).'</p>'."\n";
echo ' <p><select name="'.esc_attr(GLOBAL_NS).'[saveOptions][cdn_when_logged_in]">'."\n";
echo ' <option value="0"'.selected($this->plugin->options['cdn_when_logged_in'], '0', false).'>'.__('No, disable Static CDN Filters when a user is logged-in.', SLUG_TD).'</option>'."\n";
echo ' <option value="postload"'.selected($this->plugin->options['cdn_when_logged_in'], 'postload', false).'>'.__('Yes, enable Static CDN Filters for logged-in users (recommended) .', SLUG_TD).'</option>'."\n";
echo ' </select></p>'."\n";
echo ' <p class="info">'.__('<strong>Note:</strong> Static CDN Filters serve <em>static</em> 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 <code>No</code>, and we ask that you set it to <code>Yes</code> 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).'</p>'."\n";
echo ' <hr />'."\n";
echo ' <h3>'.__('Disable the Admin Toolbar for Logged-In Users &amp; Comment Authors?', SLUG_TD).'</h3>'."\n";
echo ' <p>'.__('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).'</p>'."\n";
echo ' <p><select name="'.esc_attr(GLOBAL_NS).'[saveOptions][when_logged_in_admin_bar]">'."\n";
echo ' <option value="0"'.selected($this->plugin->options['when_logged_in_admin_bar'], '0', false).'>'.__('Yes, disable the Admin Toolbar for all logged-in users (recommended option).', SLUG_TD).'</option>'."\n";
echo ' <option value="1"'.selected($this->plugin->options['when_logged_in_admin_bar'], '1', false).'>'.__('No, don\'t disable the Admin Toolbar for logged-in users.', SLUG_TD).'</option>'."\n";
echo ' </select></p>'."\n";

echo ' <p class="info">'.__('<strong>Note:</strong> 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 <a href="https://cometcache.com/r/kb-article-what-are-wordpress-nonces-and-why-are-they-not-cache-compatible/" target="_blank">this article</a> for details.', SLUG_TD).'</p>'."\n";
echo ' <div class="plugin-menu-page-panel-if-enabled -logged-in-users-options">'."\n";
echo ' <h3>'.__('Static CDN Filters Enabled for Logged-In Users &amp; Comment Authors?', SLUG_TD).'</h3>'."\n";
echo ' <p>'.__('While this defaults to a value of <code>No</code>, it should almost always be set to <code>Yes</code>. This value defaults to <code>No</code> only because Logged-In User caching (see above) defaults to <code>No</code> and setting this value to <code>Yes</code> 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 <code>Yes</code> in the dropdown below. If you are not using Static CDN Filters, the value below is ignored.', SLUG_TD).'</p>'."\n";
echo ' <p><select name="'.esc_attr(GLOBAL_NS).'[saveOptions][cdn_when_logged_in]">'."\n";
echo ' <option value="0"'.selected($this->plugin->options['cdn_when_logged_in'], '0', false).'>'.__('No, disable Static CDN Filters when a user is logged-in.', SLUG_TD).'</option>'."\n";
echo ' <option value="postload"'.selected($this->plugin->options['cdn_when_logged_in'], 'postload', false).'>'.__('Yes, enable Static CDN Filters for logged-in users (recommended) .', SLUG_TD).'</option>'."\n";
echo ' </select></p>'."\n";
echo ' <p class="info">'.__('<strong>Note:</strong> Static CDN Filters serve <em>static</em> 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 <code>No</code>, and we ask that you set it to <code>Yes</code> 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).'</p>'."\n";
echo ' <hr />'."\n";
echo ' <h3>'.__('Disable the Admin Toolbar for Logged-In Users &amp; Comment Authors?', SLUG_TD).'</h3>'."\n";
echo ' <p>'.__('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).'</p>'."\n";
echo ' <p><select name="'.esc_attr(GLOBAL_NS).'[saveOptions][when_logged_in_admin_bar]">'."\n";
echo ' <option value="0"'.selected($this->plugin->options['when_logged_in_admin_bar'], '0', false).'>'.__('Yes, disable the Admin Toolbar for all logged-in users (recommended option).', SLUG_TD).'</option>'."\n";
echo ' <option value="1"'.selected($this->plugin->options['when_logged_in_admin_bar'], '1', false).'>'.__('No, don\'t disable the Admin Toolbar for logged-in users.', SLUG_TD).'</option>'."\n";
echo ' </select></p>'."\n";
echo ' <p class="info">'.__('<strong>Note:</strong> 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 <a href="https://cometcache.com/r/kb-article-what-are-wordpress-nonces-and-why-are-they-not-cache-compatible/" target="_blank">this article</a> for details.', SLUG_TD).'</p>'."\n";
echo ' </div>'."\n";
echo ' </div>'."\n";

echo '</div>'."\n";
Expand Down

0 comments on commit 9789252

Please sign in to comment.