Skip to content

Commit

Permalink
Merge branch 'feature/635-traits' into 000000-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Mar 2, 2016
2 parents d8d0f16 + b16561e commit 6d03dae
Show file tree
Hide file tree
Showing 177 changed files with 10,586 additions and 9,762 deletions.
2 changes: 1 addition & 1 deletion .gitchange
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1450911210
1456622716
2 changes: 1 addition & 1 deletion comet-cache-pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
if (!defined('WPINC')) {
exit('Do NOT access this file directly: '.basename(__FILE__));
}
require_once dirname(__FILE__).'/plugin.php';
require_once __DIR__.'/plugin.php';
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@

"autoload": {
"psr-4": {
"WebSharks\\CometCache\\Pro\\": "src/includes/classes/"
"WebSharks\\CometCache\\Pro\\Classes\\": "src/includes/classes/",
"WebSharks\\CometCache\\Pro\\Traits\\": "src/includes/traits/",
"WebSharks\\CometCache\\Pro\\Interfaces\\": "src/includes/interfaces/"
}
},
"config": {
Expand Down
4 changes: 2 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}
$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 (require(__DIR__.'/src/vendor/websharks/wp-php-rv/src/includes/check.php')) {
if (!empty($_REQUEST['comet_cache_mbstring_deprecated_warning_bypass']) && is_admin()) {
update_site_option('comet_cache_mbstring_deprecated_warning_bypass', time());
}
Expand Down Expand Up @@ -80,7 +80,7 @@
);
}

require_once dirname(__FILE__).'/src/includes/plugin.php';
require_once __DIR__.'/src/includes/plugin.php';
}
} else {
wp_php_rv_notice('Comet Cache');
Expand Down
6 changes: 4 additions & 2 deletions src/includes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
*/
namespace WebSharks\CometCache\Pro;

use WebSharks\CometCache\Pro\Classes;

if (!defined('WPINC')) {
exit('Do NOT access this file directly: '.basename(__FILE__));
}
class_alias(__NAMESPACE__.'\\ApiBase', GLOBAL_NS);
class_alias(__NAMESPACE__.'\\Classes\\ApiBase', GLOBAL_NS);

if (!class_exists('zencache')) {
class_alias(__NAMESPACE__.'\\ApiBase', 'zencache');
class_alias(__NAMESPACE__.'\\Classes\\ApiBase', 'zencache');
}
2 changes: 1 addition & 1 deletion src/includes/classes/AbsBase.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* Abstract Base.
Expand Down
39 changes: 27 additions & 12 deletions src/includes/classes/AbsBaseAp.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
<?php
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

use WebSharks\CometCache\Pro\Traits;

use WebSharks\CometCache\Pro\Interfaces;

/**
* Abstract Base for Advanced Cache and Plugin.
*
* @since 150422 Rewrite.
*/
abstract class AbsBaseAp extends AbsBase
abstract class AbsBaseAp extends AbsBase implements Interfaces\Shared\NcDebugConsts, Interfaces\Shared\CachePathConsts
{
use Traits\Shared\BlogUtils;
use Traits\Shared\CacheDirUtils;
use Traits\Shared\CacheLockUtils;
use Traits\Shared\CachePathUtils;
use Traits\Shared\ConditionalUtils;
use Traits\Shared\DomainMappingUtils;
use Traits\Shared\EscapeUtils;
use Traits\Shared\FsUtils;
use Traits\Shared\HookUtils;
use Traits\Shared\HttpUtils;
use Traits\Shared\I18nUtils;
use Traits\Shared\IpAddrUtils;
use Traits\Shared\PatternUtils;
use Traits\Shared\ReplaceUtils;
use Traits\Shared\ServerUtils;
use Traits\Shared\StringUtils;
use Traits\Shared\SysUtils;
use Traits\Shared\TokenUtils;
use Traits\Shared\TrimUtils;
use Traits\Shared\UrlUtils;

/**
* Class constructor.
*
Expand All @@ -16,16 +41,6 @@ abstract class AbsBaseAp extends AbsBase
public function __construct()
{
parent::__construct();

$closures_dir = dirname(dirname(__FILE__)).'/closures/Shared';
$self = $this; // Reference for closures.

foreach (scandir($closures_dir) as $_closure) {
if (substr($_closure, -4) === '.php') {
require $closures_dir.'/'.$_closure;
}
}
unset($_closure); // Housekeeping.
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/includes/classes/Actions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* Actions.
Expand Down
2 changes: 1 addition & 1 deletion src/includes/classes/AdvCacheBackCompat.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* AC back compat.
Expand Down
23 changes: 12 additions & 11 deletions src/includes/classes/AdvancedCache.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

use WebSharks\CometCache\Pro\Traits;

/**
* Advanced cache.
Expand All @@ -8,6 +10,15 @@
*/
class AdvancedCache extends AbsBaseAp
{
use Traits\Ac\AbortUtils;
use Traits\Ac\AcPluginUtils;
use Traits\Ac\BrowserUtils;
use Traits\Ac\HtmlCUtils;
use Traits\Ac\NcDebugUtils;
use Traits\Ac\ObUtils;
use Traits\Ac\PostloadUtils;
use Traits\Ac\ShutdownUtils;

/**
* Flagged as `TRUE` if running.
*
Expand Down Expand Up @@ -35,16 +46,6 @@ public function __construct()
{
parent::__construct();

$closures_dir = dirname(dirname(__FILE__)).'/closures/Ac';
$self = $this; // Reference for closures.

foreach (scandir($closures_dir) as $_closure) {
if (substr($_closure, -4) === '.php') {
require $closures_dir.'/'.$_closure;
}
}
unset($_closure); // Housekeeping.

if (!defined('WP_CACHE') || !WP_CACHE || !COMET_CACHE_ENABLE) {
return; // Not enabled.
}
Expand Down
2 changes: 1 addition & 1 deletion src/includes/classes/ApiBase.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* API Base Class.
Expand Down
2 changes: 1 addition & 1 deletion src/includes/classes/AutoCache.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*[pro strip-from="lite"]*/
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* Auto-Cache Engine.
Expand Down
16 changes: 7 additions & 9 deletions src/includes/classes/CdnFilters.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*[pro strip-from="lite"]*/
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* CDN Filters.
Expand Down Expand Up @@ -243,14 +243,13 @@ protected function maybeSetupFilters()
if (!$this->cdn_when_logged_in && $this->plugin->isLikeUserLoggedIn()) {
return; // Disable in this case.
}
$_this = $this; // Needed for closures below.

add_action('wp_head', function () use ($_this) {
$_this->completed_wp_head_action_hook = true;
add_action('wp_head', function () {
$this->completed_wp_head_action_hook = true;
}, PHP_INT_MAX); // The very last hook, ideally.

add_action('wp_footer', function () use ($_this) {
$_this->started_wp_footer_action_hook = true;
add_action('wp_footer', function () {
$this->started_wp_footer_action_hook = true;
}, -PHP_INT_MAX); // The very first hook, ideally.

add_filter('home_url', array($this, 'urlFilter'), PHP_INT_MAX - 10, 4);
Expand Down Expand Up @@ -340,7 +339,6 @@ public function contentFilter($string)
if (strpos($string, '<') === false) {
return $string; // Nothing to do.
}
$_this = $this; // Reference needed by closures below.

$regex_url_attrs = '/'.// HTML attributes containing a URL.

Expand All @@ -361,9 +359,9 @@ public function contentFilter($string)
'/i'; // End regex pattern; case insensitive.

$orig_string = $string; // In case of regex errors.
$string = preg_replace_callback($regex_url_attrs, function ($m) use ($_this) {
$string = preg_replace_callback($regex_url_attrs, function ($m) {
unset($m[0]); // Discard full match.
$m[6] = $_this->filterUrl($m[6], null, true, null);
$m[6] = $this->filterUrl($m[6], null, true, null);
return implode('', $m); // Concatenate all parts.
}, $string); // End content filter.

Expand Down
2 changes: 1 addition & 1 deletion src/includes/classes/Conflicts.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* Conflicts.
Expand Down
4 changes: 2 additions & 2 deletions src/includes/classes/DirStats.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*[pro strip-from="lite"]*/
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* Cache directory stats.
Expand Down Expand Up @@ -562,7 +562,7 @@ public function forHostCache(

foreach (array('http', 'https') as $_host_scheme) {
$_host_url = $_host_scheme.'://'.$host_token.$host_base_dir_tokens;
$_host_cache_path_flags = CACHE_PATH_NO_PATH_INDEX | CACHE_PATH_NO_QUV | CACHE_PATH_NO_EXT;
$_host_cache_path_flags = $this::CACHE_PATH_NO_PATH_INDEX | $this::CACHE_PATH_NO_QUV | $this::CACHE_PATH_NO_EXT;
$_host_cache_path = $this->plugin->buildCachePath($_host_url, '', '', $_host_cache_path_flags);
$_host_cache_dir = $this->plugin->nDirSeps($cache_dir.'/'.$_host_cache_path); // Normalize path.
$_check_disk_stats = $___considering_domain_mapping || isset($stats->disk_total_space) ? false : true;
Expand Down
8 changes: 4 additions & 4 deletions src/includes/classes/FeedUtils.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* Feed Utils.
Expand Down Expand Up @@ -229,8 +229,8 @@ public function convertVariationsToHostCachePathRegexFrags(array $variations)
$regex_frags = array();
$is_multisite = is_multisite();
$can_consider_domain_mapping = $is_multisite && $this->plugin->canConsiderDomainMapping();
$flags = CACHE_PATH_NO_SCHEME | CACHE_PATH_NO_HOST // Default flags.
| CACHE_PATH_NO_USER | CACHE_PATH_NO_VSALT | CACHE_PATH_NO_EXT;
$flags = $this::CACHE_PATH_NO_SCHEME | $this::CACHE_PATH_NO_HOST // Default flags.
| $this::CACHE_PATH_NO_USER | $this::CACHE_PATH_NO_VSALT | $this::CACHE_PATH_NO_EXT;
// Flags: note that we DO allow for query string data in these regex fragments.

foreach ($variations as $_key => $_url) {
Expand All @@ -252,7 +252,7 @@ public function convertVariationsToHostCachePathRegexFrags(array $variations)

if (is_string($_key) && strpos($_key, '::') !== false && strpos($_url, '*') !== false) {
list($_feed_type, $_wildcard_regex) = explode('::', $_key, 2); // This regex replaces wildcards.
$_cache_path = $this->plugin->buildCachePath($_url, '', '', $flags | CACHE_PATH_ALLOW_WILDCARDS);
$_cache_path = $this->plugin->buildCachePath($_url, '', '', $flags | $this::CACHE_PATH_ALLOW_WILDCARDS);
$_relative_cache_path = preg_replace('/^'.preg_quote($_host_cache_path, '/').'(?:\/|$)/i', '', $_cache_path);
$_relative_cache_path_regex = preg_replace('/\\\\\*/', $_wildcard_regex, preg_quote($_relative_cache_path, '/'));
} else {
Expand Down
10 changes: 6 additions & 4 deletions src/includes/classes/MenuPage.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

use WebSharks\CometCache\Pro\Classes;

/**
* Menu Page.
Expand All @@ -22,18 +24,18 @@ public function __construct($menu_page = '')
if ($menu_page) {
switch ($menu_page) {
case 'options':
new MenuPageOptions();
new Classes\MenuPageOptions();
break;

/*[pro strip-from="lite"]*/
case 'stats':
new MenuPageStats();
new Classes\MenuPageStats();
break;
/*[/pro]*/

/*[pro strip-from="lite"]*/
case 'pro-updater':
new MenuPageProUpdater();
new Classes\MenuPageProUpdater();
break;
/*[/pro]*/
}
Expand Down
4 changes: 2 additions & 2 deletions src/includes/classes/MenuPageOptions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* Options Page.
Expand Down Expand Up @@ -891,7 +891,7 @@ public function __construct()
echo ' <p>'.__('You don\'t have to use an <code>.htaccess</code> file to enjoy the performance enhancements provided by this plugin; caching is handled automatically by WordPress/PHP alone. That being said, if you want to take advantage of the additional speed enhancements associated w/ GZIP compression (and we do recommend this), then you WILL need an <code>.htaccess</code> file to accomplish that part.', SLUG_TD).'</p>'."\n";
echo ' <p>'.sprintf(__('%1$s fully supports GZIP compression on its output. However, it does not handle GZIP compression directly. We purposely left GZIP compression out of this plugin, because GZIP compression is something that should really be enabled at the Apache level or inside your <code>php.ini</code> file. GZIP compression can be used for things like JavaScript and CSS files as well, so why bother turning it on for only WordPress-generated pages when you can enable GZIP at the server level and cover all the bases!', SLUG_TD), esc_html(NAME)).'</p>'."\n";
echo ' <p>'.__('If you want to enable GZIP, create an <code>.htaccess</code> file in your WordPress® installation directory, and put the following few lines in it. Alternatively, if you already have an <code>.htaccess</code> file, just add these lines to it, and that is all there is to it. GZIP is now enabled in the recommended way! See also: <a href="https://developers.google.com/speed/articles/gzip" target="_blank"><i class="si si-youtube-play"></i> video about GZIP Compression</a>.', SLUG_TD).'</p>'."\n";
echo ' <pre class="code"><code>'.esc_html(file_get_contents(dirname(dirname(__FILE__)).'/templates/gzip-htaccess.txt')).'</code></pre>'."\n";
echo ' <pre class="code"><code>'.esc_html(file_get_contents(dirname(__DIR__).'/templates/gzip-htaccess.txt')).'</code></pre>'."\n";
echo ' <hr />'."\n";
echo ' <p class="info" style="display:block;"><strong>Or</strong>, if your server is missing <code>mod_deflate</code>/<code>mod_filter</code>; open your <strong>php.ini</strong> file and add this line: <a href="http://php.net/manual/en/zlib.configuration.php" target="_blank" style="text-decoration:none;"><code>zlib.output_compression = on</code></a></p>'."\n";
echo ' </div>'."\n";
Expand Down
4 changes: 1 addition & 3 deletions src/includes/classes/MenuPageProUpdater.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*[pro strip-from="lite"]*/
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* Pro Updater Page.
Expand Down Expand Up @@ -35,8 +35,6 @@ public function __construct()
echo ' <div class="plugin-menu-page-upsells">'."\n";
if (current_user_can($this->plugin->cap)) {
echo ' <a href="'.esc_attr(add_query_arg(urlencode_deep(array('page' => GLOBAL_NS)), self_admin_url('/admin.php'))).'"><i class="si si-cogs"></i> '.__('Options', SLUG_TD).'</a>'."\n";
echo ' <a href="'.esc_attr('http://zencache.com/r/zencache-subscribe/').'" target="_blank"><i class="si si-envelope"></i> '.__('Newsletter', SLUG_TD).'</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', SLUG_TD).'</a>'."\n";
}
if (IS_PRO) { // We show these below in the Lite version
echo ' <a href="'.esc_attr('http://cometcache.com/r/comet-cache-subscribe/').'" target="_blank"><i class="si si-envelope"></i> '.__('Newsletter', SLUG_TD).'</a>'."\n";
Expand Down
2 changes: 1 addition & 1 deletion src/includes/classes/MenuPageStats.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*[pro strip-from="lite"]*/
namespace WebSharks\CometCache\Pro;
namespace WebSharks\CometCache\Pro\Classes;

/**
* Stats Page.
Expand Down
Loading

0 comments on commit 6d03dae

Please sign in to comment.