Skip to content

Commit

Permalink
Merge branch '000000-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Feb 22, 2016
2 parents d424f41 + f7a8e0d commit 2565686
Show file tree
Hide file tree
Showing 27 changed files with 1,495 additions and 1,335 deletions.
48 changes: 48 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

31 changes: 29 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
$GLOBALS['wp_php_rv'] = '5.3.2'; //php-required-version// // Leaving this at v5.3.2 so that we can have more control over Dashboard messages below.

if (require(dirname(__FILE__).'/src/vendor/websharks/wp-php-rv/src/includes/check.php')) {
if (!empty($_REQUEST['zencache_mbstring_deprecated_warning_bypass']) && is_admin()) {
update_site_option('zencache_mbstring_deprecated_warning_bypass', time());
}

${__FILE__}['apc_enabled'] = (extension_loaded('apc') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN) && stripos((string)ini_get('apc.filters'), 'zencache') === false) ? true : false;

if ((!version_compare(PHP_VERSION, '5.4', '>=') || ${__FILE__}['apc_enabled'])) {
if ((!version_compare(PHP_VERSION, '5.4', '>=') || ${__FILE__}['apc_enabled'])) { // If PHP <= 5.4 or APC is enabled

if (!version_compare(PHP_VERSION, '5.4', '>=') && is_admin()) {
${__FILE__}['php54_notice'] = '<h3 style="margin:.5em 0 .25em 0;">'.__('<strong>NOTICE: ZenCache Minimum PHP Version</strong></h3>', 'zencache');
Expand Down Expand Up @@ -56,7 +60,30 @@
)
);
}
} else {
} else { // Load the plugin

if (!extension_loaded('mbstring') && !get_site_option('zencache_mbstring_deprecated_warning_bypass') && is_admin()) {
${__FILE__}['mbstring_deprecated_warning'] = '<h3 style="margin:.5em 0 .25em 0;">'.__('<strong>NOTICE: ZenCache Will Require the PHP <code>mbstring</code> Extension</strong></h3>', 'zencache');
${__FILE__}['mbstring_deprecated_warning'] .= '<p style="margin-top:0;">'.sprintf(__('<strong>After March 1st, 2016 ZenCache will require PHP Multibyte String support.</strong> It appears that your site is currently running PHP v%1$s <strong>without</strong> the <code>mbstring</code> extension enabled. You will need to contact your web hosting company and have them enable the PHP <code>mbstring</code> extension if you want to run the next version of ZenCache.', 'zencache'), esc_html(PHP_VERSION)).'</p>';
${__FILE__}['mbstring_deprecated_warning'] .= '<p style="margin-top:0;">'.__('The <code>mbstring</code> extension provides Multibyte String support to PHP and is required to properly handle UTF-8 characters, which many sites now use. Without Multibyte String support, ZenCache will be unstable. For that reason we are requiring the <code>mbstring</code> extension to improve reliability when caching and to prevent your site from experiencing unforeseen issues in the future.', 'zencache').'</p>';
${__FILE__}['mbstring_deprecated_warning'] .= '<p style="margin-bottom:.5em;">'.__('<a href="'.esc_attr(add_query_arg('zencache_mbstring_deprecated_warning_bypass', '1')).'" onclick="if(!confirm(\'Are you sure? Press OK to continue, or Cancel to stop and read carefully.\')) return false;">Dismiss this notice.</a>', 'zencache').'</p>';

add_action(
'all_admin_notices', create_function(
'', 'if(!current_user_can(\'activate_plugins\'))'.
' return;'."\n".// User missing capability.

'echo \''.// Wrap `$notice` inside a WordPress error.

'<div class="notice notice-warning">'.
' '.str_replace("'", "\\'", ${__FILE__}['mbstring_deprecated_warning']).
'</div>'.

'\';'
)
);
}

require_once dirname(__FILE__).'/src/includes/plugin.php';
}
} else {
Expand Down
198 changes: 47 additions & 151 deletions readme.txt

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

Binary file modified src/client-s/images/options-lite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 28 additions & 3 deletions src/includes/classes/MenuPageOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,33 @@ public function __construct()
echo ' <div class="plugin-menu-page-upsells">'."\n";
if (IS_PRO && current_user_can($this->plugin->update_cap)) {
echo '<a href="'.esc_attr(add_query_arg(urlencode_deep(array('page' => GLOBAL_NS.'-pro-updater')), self_admin_url('/admin.php'))).'"><i class="si si-magic"></i> '.__('Pro Updater', 'zencache').'</a>'."\n";
echo '<a href="'.esc_attr('http://zencache.com/r/zencache-subscribe/').'" target="_blank"><i class="si si-envelope"></i> '.__('Newsletter', 'zencache').'</a>'."\n";
echo '<a href="'.esc_attr('http://zencache.com/r/zencache-beta-testers-list/').'" target="_blank"><i class="si si-envelope"></i> '.__('Beta Testers', 'zencache').'</a>'."\n";
}
if (!IS_PRO) {
echo ' <a href="'.esc_attr(add_query_arg(urlencode_deep(array('page' => GLOBAL_NS, GLOBAL_NS.'_pro_preview' => '1')), self_admin_url('/admin.php'))).'"><i class="si si-eye"></i> '.__('Preview Pro Features', 'zencache').'</a>'."\n";
echo ' <a href="'.esc_attr('http://zencache.com/prices/').'" target="_blank"><i class="si si-heart-o"></i> '.__('Pro Upgrade', 'zencache').'</a>'."\n";
}
echo ' <a href="'.esc_attr('http://zencache.com/r/zencache-subscribe/').'" target="_blank"><i class="si si-envelope"></i> '.__('Newsletter', 'zencache').'</a>'."\n";
echo ' <a href="'.esc_attr('http://zencache.com/r/zencache-beta-testers-list/').'" target="_blank"><i class="si si-envelope"></i> '.__('Beta Testers', 'zencache').'</a>'."\n";
echo ' </div>'."\n";

echo ' <div class="plugin-menu-page-support-links">'."\n";
if (IS_PRO) {
echo ' <a href="'.esc_attr('http://zencache.com/support/').'" target="_blank"><i class="si si-life-bouy"></i> '.__('Support', 'zencache').'</a>'."\n";
}
if (!IS_PRO) {
echo ' <a href="'.esc_attr('https://wordpress.org/support/plugin/zencache').'" target="_blank"><i class="si si-comment"></i> '.__('Community Forum', 'zencache').'</a>'."\n";
}
echo ' <a href="'.esc_attr('http://zencache.com/kb/').'" target="_blank"><i class="si si-book"></i> '.__('Knowledge Base', 'zencache').'</a>'."\n";
echo ' <a href="'.esc_attr('http://zencache.com/blog/').'" target="_blank"><i class="si si-rss-square"></i> '.__('Blog', 'zencache').'</a>'."\n";
echo ' </div>'."\n";

if (!IS_PRO) { // We show these with the Pro Updater above in the Pro version
echo ' <div class="plugin-menu-page-mailing-list-links">'."\n";
echo ' <a href="'.esc_attr('http://zencache.com/r/zencache-subscribe/').'" target="_blank"><i class="si si-envelope"></i> '.__('Newsletter', 'zencache').'</a>'."\n";
echo ' <a href="'.esc_attr('http://zencache.com/r/zencache-beta-testers-list/').'" target="_blank"><i class="si si-envelope"></i> '.__('Beta Testers', 'zencache').'</a>'."\n";
echo ' </div>'."\n";
}

if (IS_PRO) {
echo '<div class="plugin-menu-page-version">'."\n";
echo ' '.sprintf(__('%1$s&trade; Pro v%2$s', 'zencache'), esc_html(NAME), esc_html(VERSION))."\n";
Expand All @@ -79,9 +97,11 @@ public function __construct()
echo '</div>'."\n";
}
echo ' <img src="'.$this->plugin->url('/src/client-s/images/options-'.(IS_PRO ? 'pro' : 'lite').'.png').'" alt="'.esc_attr(__('Plugin Options', 'zencache')).'" />'."\n";

echo '<div style="clear:both;"></div>'."\n";
echo '</div>'."\n";

echo '<div class="plugin-menu-page-notice warning"><p>'.sprintf(__('<strong>Important %1$s Announcement:</strong> %1$s is changing its name to <a href="https://cometcache.com/r/announcing-comet-cache-formerly-zencache/" target="_blank"><strong>Comet Cache</a></strong>! Learn more about this upcoming change <a href="https://cometcache.com/r/announcing-comet-cache-formerly-zencache/" target="_blank">here</a>.', 'zencache'), esc_html(NAME)).'</p></div>'."\n";

/* ----------------------------------------------------------------------------------------- */

echo '<hr />'."\n";
Expand Down Expand Up @@ -835,6 +855,11 @@ public function __construct()
echo ' <p>'.__('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 <code>&lt;script src=&quot;&quot;&gt;</code> value, and also against the contents of any inline <code>&lt;script&gt;</code> tags (caSe insensitive). A wildcard <code>*</code> character can also be used when necessary; e.g., <code>xy*-framework</code> (where <code>*</code> = 0 or more characters that are NOT a slash <code>/</code>). Other special characters include: <code>**</code> = 0 or more characters of any kind, including <code>/</code> slashes; <code>^</code> = beginning of the string; <code>$</code> = end of the string. To learn more about this syntax, please see <a href ="http://zencache.com/r/watered-down-regex-syntax/" target="_blank">this KB article</a>.', 'zencache').'</p>'."\n";
echo ' <p><textarea name="'.esc_attr(GLOBAL_NS).'[saveOptions][htmlc_js_exclusions]" rows="5" spellcheck="false" class="monospace">'.format_to_edit($this->plugin->options['htmlc_js_exclusions']).'</textarea></p>'."\n";
echo ' <p class="info" style="display:block;">'.__('<strong>Note:</strong> please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'zencache').'</p>'."\n";
echo ' <h3>'.__('URI Exclusions for HTML Compressor?', 'zencache').'</h3>'."\n";
echo ' <p>'.__('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 <a href="https://gist.github.com/jaswsinc/338b6eb03a36c048c26f" target="_blank" style="text-decoration:none;"><code>REQUEST_URI</code></a>; i.e., <code>/path/?query</code> (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 <code>*</code> character can also be used when necessary; e.g., <code>/category/abc-followed-by-*</code> (where <code>*</code> = 0 or more characters that are NOT a slash <code>/</code>). Other special characters include: <code>**</code> = 0 or more characters of any kind, including <code>/</code> slashes; <code>^</code> = beginning of the string; <code>$</code> = end of the string. To learn more about this syntax, please see <a href ="http://zencache.com/r/watered-down-regex-syntax/" target="_blank">this KB article</a>.', 'zencache').'</p>'."\n";
echo ' <p><textarea name="'.esc_attr(GLOBAL_NS).'[saveOptions][htmlc_uri_exclusions]" rows="5" spellcheck="false" class="monospace">'.format_to_edit($this->plugin->options['htmlc_uri_exclusions']).'</textarea></p>'."\n";
echo ' <p class="info">'.__('<strong>Tip:</strong> let\'s use this example URL: <code>http://www.example.com/post/example-post-123</code>. To exclude this URL, you would put this line into the field above: <code>/post/example-post-123</code>. Or, you could also just put in a small fragment, like: <code>example</code> or <code>example-*-123</code> and that would exclude any URI containing that word fragment.', 'zencache').'</p>'."\n";
echo ' <p class="info">'.__('<strong>Note:</strong> please remember that your entries here should be formatted as a line-delimited list; e.g., one exclusion pattern per line.', 'zencache').'</p>'."\n";
echo ' <hr />'."\n";
echo ' <h3>'.__('HTML Compression Cache Expiration', 'zencache').'</h3>'."\n";
echo ' <p><input type="text" name="'.esc_attr(GLOBAL_NS).'[saveOptions][htmlc_cache_expiration_time]" value="'.esc_attr($this->plugin->options['htmlc_cache_expiration_time']).'" /></p>'."\n";
Expand Down
7 changes: 5 additions & 2 deletions src/includes/classes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public function setup()
'htmlc_enable',
'htmlc_css_exclusions',
'htmlc_js_exclusions',
'htmlc_uri_exclusions',
'htmlc_cache_expiration_time',
'htmlc_compress_combine_head_body_css',
'htmlc_compress_combine_head_js',
Expand Down Expand Up @@ -218,8 +219,9 @@ public function setup()
$this->default_options = array(
/* Core/systematic plugin options. */

'version' => VERSION,
'welcomed' => '0', // `0|1` welcomed yet?
'version' => VERSION,
'welcomed' => '0', // `0|1` welcomed yet?
'comet_cache_notice1_enqueued' => '0', // `0|1` announced Comet Cache yet?
'crons_setup' => '0', // A timestamp when last set up.
'crons_setup_on_namespace' => '', // The namespace on which they were set up.
Expand Down Expand Up @@ -299,6 +301,7 @@ public function setup()
'htmlc_enable' => '0', // Enable HTML compression?
'htmlc_css_exclusions' => '', // Empty string or line-delimited patterns.
'htmlc_js_exclusions' => '.php?', // Empty string or line-delimited patterns.
'htmlc_uri_exclusions' => '', // Empty string or line-delimited patterns.
'htmlc_cache_expiration_time' => '14 days', // `strtotime()` compatible.

'htmlc_compress_combine_head_body_css' => '1', // `0|1`.
Expand Down
7 changes: 6 additions & 1 deletion src/includes/closures/Plugin/InstallUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

if (!$self->options['welcomed'] && !$self->options['enable']) {
$settings_url = add_query_arg(urlencode_deep(array('page' => GLOBAL_NS)), network_admin_url('/admin.php'));
$self->enqueueMainNotice(sprintf(__('<strong>%1$s</strong> successfully installed! :-) <strong>Please <a href="%2$s">enable caching and review options</a>.</strong>', 'zencache'), esc_html(NAME), esc_attr($settings_url), array('push_to_top' => true)));
$self->enqueueMainNotice(sprintf(__('<strong>%1$s</strong> successfully installed! :-) <strong>Please <a href="%2$s">enable caching and review options</a>.</strong>', 'zencache'), esc_html(NAME), esc_attr($settings_url)), array('push_to_top' => true));
$self->updateOptions(array('welcomed' => '1'));
}

Expand All @@ -36,6 +36,11 @@
* @attaches-to `admin_init` hook.
*/
$self->checkVersion = function () use ($self) {
if (!$self->options['comet_cache_notice1_enqueued']) {
$self->enqueueMainNotice(sprintf(__('<strong>Important %1$s Announcement:</strong> %1$s is changing its name to <a href="https://cometcache.com/r/announcing-comet-cache-formerly-zencache/" target="_blank"><strong>Comet Cache</a></strong>! Learn more about this upcoming change <a href="https://cometcache.com/r/announcing-comet-cache-formerly-zencache/" target="_blank">here</a>.', 'zencache'), esc_html(NAME)), array('push_to_top' => true, 'class'=>'notice notice-warning', 'persistent_key'=>'comet_cache_notice1'));
$self->updateOptions(array('comet_cache_notice1_enqueued' => '1'));
} // This notice MUST go above the version check to show up on new installs.

$prev_version = $self->options['version'];
if (version_compare($prev_version, VERSION, '>=')) {
return; // Nothing to do; up-to-date.
Expand Down
4 changes: 4 additions & 0 deletions src/includes/closures/Plugin/MenuPageUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
* @return array Revised array of links.
*/
$self->addSettingsLink = function ($links) use ($self) {
if (is_multisite() && !is_network_admin()) {
return $links;
}

$links[] = '<a href="'.esc_attr(add_query_arg(urlencode_deep(array('page' => GLOBAL_NS)), self_admin_url('/admin.php'))).'">'.__('Settings', 'zencache').'</a>';
if (!IS_PRO) {
$links[] = '<br/><a href="'.esc_attr(add_query_arg(urlencode_deep(array('page' => GLOBAL_NS, GLOBAL_NS.'_pro_preview' => '1')), self_admin_url('/admin.php'))).'">'.__('Preview Pro Features', 'zencache').'</a>';
Expand Down
2 changes: 1 addition & 1 deletion src/includes/closures/Shared/CachePathUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
$host = 'doesnt-matter.foo.bar';
$host_url = rtrim('http://'.$host, '/');
$host_cache_path = $self->buildCachePath($host_url, '', '', $flags);
$uri_patterns = array_unique(preg_split('/['."\r\n".']+/', $uris, null, PREG_SPLIT_NO_EMPTY));
$uri_patterns = array_unique(preg_split('/['."\r\n".']+/', $uris, -1, PREG_SPLIT_NO_EMPTY));

foreach ($uri_patterns as $_key => &$_uri_pattern) {
if (($_uri_pattern = trim($_uri_pattern, '^$'))) {
Expand Down
37 changes: 34 additions & 3 deletions src/includes/closures/Shared/ConditionalUtils.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
<?php
namespace WebSharks\ZenCache;

/**
* PHP's language constructs.
*
* @type array PHP's language constructs.
* Keys are currently unimportant. Subject to change.
*
* @since 160222 First documented version.
*/
$self->php_constructs = [
'die' => 'die',
'echo' => 'echo',
'empty' => 'empty',
'exit' => 'exit',
'eval' => 'eval',
'include' => 'include',
'include_once' => 'include_once',
'isset' => 'isset',
'list' => 'list',
'require' => 'require',
'require_once' => 'require_once',
'return' => 'return',
'print' => 'print',
'unset' => 'unset',
'__halt_compiler' => '__halt_compiler',
];

/*
* Is AdvancedCache class?
*
Expand Down Expand Up @@ -311,14 +337,19 @@
$disabled_functions = array(); // Initialize disabled/blacklisted functions.

if (($disable_functions = trim(ini_get('disable_functions')))) {
$disabled_functions = array_merge($disabled_functions, preg_split('/[\s;,]+/', strtolower($disable_functions), null, PREG_SPLIT_NO_EMPTY));
$disabled_functions = array_merge($disabled_functions, preg_split('/[\s;,]+/', strtolower($disable_functions), -1, PREG_SPLIT_NO_EMPTY));
}
if (($blacklist_functions = trim(ini_get('suhosin.executor.func.blacklist')))) {
$disabled_functions = array_merge($disabled_functions, preg_split('/[\s;,]+/', strtolower($blacklist_functions), null, PREG_SPLIT_NO_EMPTY));
$disabled_functions = array_merge($disabled_functions, preg_split('/[\s;,]+/', strtolower($blacklist_functions), -1, PREG_SPLIT_NO_EMPTY));
}
if(filter_var(ini_get('suhosin.executor.disable_eval'), FILTER_VALIDATE_BOOLEAN)) {
$disabled_functions = array_merge($disabled_functions, array('eval'));
}
}
if (!function_exists($function) || !is_callable($function)) {
return ($is = false); // Not possible.
if(!in_array($function, $self->php_constructs, true)) { // A language construct
return ($is = false); // Not possible.
}
}
if ($disabled_functions && in_array(strtolower($function), $disabled_functions, true)) {
return ($is = false); // Not possible.
Expand Down
2 changes: 1 addition & 1 deletion src/includes/closures/Shared/IpAddrUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
if (!($list_of_possible_ips = trim($list_of_possible_ips))) {
return ''; // Not possible; i.e., empty string.
}
foreach (preg_split('/[\s;,]+/', $list_of_possible_ips, null, PREG_SPLIT_NO_EMPTY) as $_key => $_possible_ip) {
foreach (preg_split('/[\s;,]+/', $list_of_possible_ips, -1, PREG_SPLIT_NO_EMPTY) as $_key => $_possible_ip) {
if (($_valid_public_ip = filter_var(strtolower($_possible_ip), FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))) {
return $_valid_public_ip; // A valid public IPv4 or IPv6 address.
}
Expand Down
2 changes: 1 addition & 1 deletion src/includes/closures/Shared/PatternUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$regex = ''; // Initialize list of regex patterns.
$patterns = (string) $patterns;

if (($patterns = preg_split('/['."\r\n".']+/', $patterns, null, PREG_SPLIT_NO_EMPTY))) {
if (($patterns = preg_split('/['."\r\n".']+/', $patterns, -1, PREG_SPLIT_NO_EMPTY))) {
$regex = '/(?:'.implode('|', array_map($self->wdRegexToActualRegexFrag, $patterns)).')/i';
}
return $regex;
Expand Down
2 changes: 1 addition & 1 deletion src/includes/stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
require_once dirname(dirname(__FILE__)).'/vendor/autoload.php';
require_once dirname(__FILE__).'/functions/i18n-utils.php';

${__FILE__}['version'] = '160120-RC'; //version//
${__FILE__}['version'] = '160222'; //version//
${__FILE__}['plugin'] = dirname(dirname(dirname(__FILE__)));
${__FILE__}['plugin'] .= '/'.basename(${__FILE__}['plugin']).'.php';
${__FILE__}['ns_path'] = str_replace('\\', '/', __NAMESPACE__); // To dir/path.
Expand Down
Loading

0 comments on commit 2565686

Please sign in to comment.