Skip to content

Commit

Permalink
Merge pull request #29 from JasWSInc/000000-dev
Browse files Browse the repository at this point in the history
Releasing v131206.
  • Loading branch information
Jason Caldwell committed Dec 7, 2013
2 parents 0b83c27 + eb12eb9 commit 3e1067e
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 32 deletions.
10 changes: 8 additions & 2 deletions quick-cache/includes/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public function save_options($args)
|| strpos(basename(plugin()->options['cache_dir']), 'wp-') === 0 // Reserved name?
) plugin()->options['cache_dir'] = plugin()->default_options['cache_dir'];

update_option(__NAMESPACE__.'_options', $args);
update_option(__NAMESPACE__.'_options', $args); // Blog-specific.
if(is_multisite()) update_site_option(__NAMESPACE__.'_options', $args);

$redirect_to = self_admin_url('/admin.php'); // Redirect preparations.
$query_args = array('page' => __NAMESPACE__, __NAMESPACE__.'__updated' => '1');
Expand All @@ -61,6 +62,8 @@ public function save_options($args)
$query_args[__NAMESPACE__.'__advanced_cache_add_failure']
= ($add_advanced_cache === NULL)
? 'qc-advanced-cache' : '1';

plugin()->update_blog_paths();
}
else // We need to disable Quick Cache in this case.
{
Expand All @@ -83,7 +86,8 @@ public function restore_default_options($args)
if(empty($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce']))
return; // Unauthenticated POST data.

delete_option(__NAMESPACE__.'_options');
delete_option(__NAMESPACE__.'_options'); // Blog-specific.
if(is_multisite()) delete_site_option(__NAMESPACE__.'_options');

$redirect_to = self_admin_url('/admin.php'); // Redirect preparations.
$query_args = array('page' => __NAMESPACE__, __NAMESPACE__.'__restored' => '1');
Expand All @@ -99,6 +103,8 @@ public function restore_default_options($args)
$query_args[__NAMESPACE__.'__advanced_cache_add_failure']
= ($add_advanced_cache === NULL)
? 'qc-advanced-cache' : '1';

plugin()->update_blog_paths();
}
else // We need to disable Quick Cache in this case.
{
Expand Down
19 changes: 12 additions & 7 deletions quick-cache/includes/advanced-cache.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,21 @@ public function maybe_start_output_buffering()

if(!QUICK_CACHE_GET_REQUESTS && $this->is_get_request_w_query() && empty($_GET['qcAC'])) return;

$protocol = $this->is_ssl() ? 'https://' : 'http://';
$http_host_nps = preg_replace('/\:[0-9]+$/', '', $_SERVER['HTTP_HOST']);
$protocol = $this->is_ssl() ? 'https://' : 'http://';
$http_host_nps = preg_replace('/\:[0-9]+$/', '', $_SERVER['HTTP_HOST']);
$host_dir_token = '/'; // Assume NOT multisite; or running it's own domain.

if(is_multisite() && (!defined('SUBDOMAIN_INSTALL') || !SUBDOMAIN_INSTALL) && (!defined('VHOST') || !VHOST))
{ // Multisite w/ sub-directories; need sub-directory. We MUST validate against blog paths too.

if(is_multisite() && (!defined('SUBDOMAIN_INSTALL') || !SUBDOMAIN_INSTALL))
{ // Multisite w/ sub-directories; need first sub-directory.
list($host_dir_token) = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
$host_dir_token = (strlen($host_dir_token)) ? '/'.$host_dir_token.'/' : '/';
}
else $host_dir_token = '/'; // Not multisite; or running it's own domain.
$host_dir_token = (isset($host_dir_token[0])) ? '/'.$host_dir_token.'/' : '/';

if($host_dir_token !== '/' // Perhaps NOT the main site?
&& (!is_file(QUICK_CACHE_DIR.'/qc-blog-paths') // NOT a read/valid blog path?
|| !in_array($host_dir_token, unserialize(file_get_contents(QUICK_CACHE_DIR.'/qc-blog-paths')), TRUE))
) $host_dir_token = '/'; // Main site; e.g. this is NOT a real/valid child blog path.
}
$version_salt // Give advanced cache plugins a chance.
= $this->apply_filters(__CLASS__.'__version_salt', '');

Expand Down
24 changes: 14 additions & 10 deletions quick-cache/includes/menu-pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,34 +153,38 @@ public function options()
echo ' <p>'.__('Once Quick Cache is enabled, you will find this new option in your WordPress Admin Bar (see 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).', plugin()->text_domain).'</p>'."\n";
echo ' <p>'.__('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. Quick Cache 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).', plugin()->text_domain).'</p>'."\n";
echo ' <p><select name="'.esc_attr(__NAMESPACE__).'[save_options][admin_bar_enable]">'."\n";
echo ' <option value="1"'.selected(plugin()->options['admin_bar_enable'], '1', FALSE).'>'.__('Yes, enable &quot;Clear Cache&quot; button in the WordPress admin bar.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="0"'.selected(plugin()->options['admin_bar_enable'], '0', FALSE).'>'.__('No, I don\'t intend to clear the cache manually; exclude from admin bar.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="1" selected="selected">'.__('Yes, enable the &quot;Clear Cache&quot; button in the WordPress admin bar.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="0">'.__('No, I don\'t intend to clear the cache manually; exclude from admin bar.', plugin()->text_domain).'</option>'."\n";
echo ' </select></p>'."\n";
echo ' <h3>'.__('Running the <a href="http://www.websharks-inc.com/product/s2clean/" target="_blank">s2Clean Theme</a> by WebSharks?', plugin()->text_domain).'</h3>'."\n";
echo ' <p>'.__('If s2Clean is installed, Quick Cache can be configured to clear the Markdown cache too (if you\'ve enabled Markdown processing with s2Clean). The s2Clean Markdown cache is only cleared when you manually clear the cache (with Quick Cache); and only if you enable this option here. Note: s2Clean\'s Markdown cache is extremely dynamic. Just like the rest of your site, s2Clean caches do NOT need to be cleared away at all, as this happens automatically when your content changes. However, some developers find this feature useful while developing their site; just to force a refresh.', plugin()->text_domain).'</p>'."\n";
echo ' <p><select name="'.esc_attr(__NAMESPACE__).'[save_options][cache_clear_s2clean_enable]">'."\n";
echo ' <option value="1"'.selected(plugin()->options['cache_clear_s2clean_enable'], '1', FALSE).'>'.__('Yes, if the s2Clean theme is installed; also clear s2Clean-related caches.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="0"'.selected(plugin()->options['cache_clear_s2clean_enable'], '0', FALSE).'>'.__('No, I don\'t use s2Clean; or, I don\'t want s2Clean-related caches cleared.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="1">'.__('Yes, if the s2Clean theme is installed; also clear s2Clean-related caches.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="0" selected="selected">'.__('No, I don\'t use s2Clean; or, I don\'t want s2Clean-related caches cleared.', plugin()->text_domain).'</option>'."\n";
echo ' </select></p>'."\n";
echo ' <h3>'.__('Process Other Custom PHP Code?', plugin()->text_domain).'</h3>'."\n";
echo ' <p>'.__('If you have other custom routines you\'d like to process when the cache is cleared manually, please type your custom PHP code here. The PHP code that you provide is only evaluated when you manually clear the cache (with Quick Cache); and only if the field below contains PHP code. Note: if your PHP code outputs a message (e.g. if you have <code>echo \'&lt;p&gt;My message&lt;/p&gt;\';</code>); your message will be displayed along with any other notes from Quick Cache itself. This could be useful to developers that need to clear server caches too (such as <a href="http://www.php.net/manual/en/function.apc-clear-cache.php" target="_blank">APC</a> or <a href="http://www.php.net/manual/en/memcache.flush.php" target="_blank">memcache</a>).', plugin()->text_domain).'</p>'."\n";
echo ' <p style="margin-bottom:0;"><textarea name="'.esc_attr(__NAMESPACE__).'[save_options][cache_clear_eval_code]" rows="5" spellcheck="false" class="monospace"></textarea></p>'."\n";
echo ' <p class="info" style="margin-top:0;">'.__('<strong>Example:</strong> <code>&lt;?php apc_clear_cache(); echo \'&lt;p&gt;Also cleared APC cache.&lt;/p&gt;\'; ?&gt;</code>', plugin()->text_domain).'</p>'."\n";
echo ' <hr />'."\n";
echo ' <h3>'.__('Purging the Cache (Automatically)', plugin()->text_domain).'</h3>'."\n";
echo ' <img src="'.esc_attr(plugin()->url('/client-s/images/ap-screenshot.png')).'" class="screenshot" />'."\n";
echo ' <p>'.__('This is built into the Quick Cache plugin; e.g. this functionality is "always on". If you edit a Post/Page (or delete one), Quick Cache will automatically purge 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 Quick Cache will notify you of these as they occur. Quick Cache monitors changes to Posts (of any kind, including Pages), Categories, Tags, Links, Themes (even Users); and more. Notifications in the Dashboard regarding these detections can be enabled/disabled below.', plugin()->text_domain).'</p>'."\n";
echo ' <p><select name="'.esc_attr(__NAMESPACE__).'[save_options][change_notifications_enable]">'."\n";
echo ' <option value="1"'.selected(plugin()->options['change_notifications_enable'], '1', FALSE).'>'.__('Yes, enable Quick Cache notifications in the Dashboard when changes are detected &amp; one or more cache files are purged automatically.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="0"'.selected(plugin()->options['change_notifications_enable'], '0', FALSE).'>'.__('No, I don\'t want to know (don\'t really care) what Quick Cache is doing behind-the-scene.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="1" selected="selected">'.__('Yes, enable Quick Cache notifications in the Dashboard when changes are detected &amp; one or more cache files are purged automatically.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="0">'.__('No, I don\'t want to know (don\'t really care) what Quick Cache is doing behind-the-scene.', plugin()->text_domain).'</option>'."\n";
echo ' </select></p>'."\n";
echo ' <h3>'.__('Auto-Purge Designated "Home Page" Too?', plugin()->text_domain).'</h3>'."\n";
echo ' <p>'.__('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 Quick Cache purges/resets the cache for a single Post/Page, would you like Quick Cache to also purge any existing cache files for the "Home Page"?', plugin()->text_domain).'</p>'."\n";
echo ' <p><select name="'.esc_attr(__NAMESPACE__).'[save_options][cache_purge_home_page_enable]">'."\n";
echo ' <option value="1"'.selected(plugin()->options['cache_purge_home_page_enable'], '1', FALSE).'>'.__('Yes, if any single Post/Page is purged/reset; also purge the "Home Page".', plugin()->text_domain).'</option>'."\n";
echo ' <option value="0"'.selected(plugin()->options['cache_purge_home_page_enable'], '0', FALSE).'>'.__('No, my Home Page does not provide a list of Posts/Pages; e.g. this is not necessary.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="1" selected="selected">'.__('Yes, if any single Post/Page is purged/reset; also purge the "Home Page".', plugin()->text_domain).'</option>'."\n";
echo ' <option value="0">'.__('No, my Home Page does not provide a list of Posts/Pages; e.g. this is not necessary.', plugin()->text_domain).'</option>'."\n";
echo ' </select></p>'."\n";
echo ' <h3>'.__('Auto-Purge Designated "Posts Page" Too?', plugin()->text_domain).'</h3>'."\n";
echo ' <p>'.__('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 Quick Cache purges/resets the cache for a single Post/Page, would you like Quick Cache to also purge any existing cache files for the "Posts Page"?', plugin()->text_domain).'</p>'."\n";
echo ' <p><select name="'.esc_attr(__NAMESPACE__).'[save_options][cache_purge_posts_page_enable]">'."\n";
echo ' <option value="1"'.selected(plugin()->options['cache_purge_posts_page_enable'], '1', FALSE).'>'.__('Yes, if any single Post/Page is purged/reset; also purge the "Posts Page".', plugin()->text_domain).'</option>'."\n";
echo ' <option value="0"'.selected(plugin()->options['cache_purge_posts_page_enable'], '0', FALSE).'>'.__('No, I don\'t use a separate Posts Page; e.g. my Home Page IS my Posts Page.', plugin()->text_domain).'</option>'."\n";
echo ' <option value="1" selected="selected">'.__('Yes, if any single Post/Page is purged/reset; also purge the "Posts Page".', plugin()->text_domain).'</option>'."\n";
echo ' <option value="0">'.__('No, I don\'t use a separate Posts Page; e.g. my Home Page IS my Posts Page.', plugin()->text_domain).'</option>'."\n";
echo ' </select></p>'."\n";
echo ' </div>'."\n";

Expand Down
Loading

0 comments on commit 3e1067e

Please sign in to comment.