Skip to content

Commit

Permalink
bump 21.01.01
Browse files Browse the repository at this point in the history
- Fixed Tweaks::woocommerce_cart_fragments_remove() -> check if "wc-cart-fragments" script exists.
- Fixed WP_Object_Cache::dc_precache_set -> ignore transient, site-transient.
- Added Configuration Options -> Runtime Options.
- Added Configuration Actions -> Config reset.
- Added Configuration Actions -> Cleanup Post revisions, auto drafts, trash bin.
- Added WP-CLI command -> runtime:install, runtime:reset.
  • Loading branch information
nawawi committed Feb 3, 2021
1 parent 18b26de commit c10f4c4
Show file tree
Hide file tree
Showing 30 changed files with 1,577 additions and 260 deletions.
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
= v21.01.01 (2021-02-03)

- Fixed Tweaks::woocommerce_cart_fragments_remove() -> check if "wc-cart-fragments" script exists.
- Fixed WP_Object_Cache::dc_precache_set -> ignore transient, site-transient.
- Added Configuration -> Runtime Options.
- Added Configuration -> Config reset.
- Added WP-CLI command -> runtime:install, runtime:reset.

= v20.12.04 (2021-01-16)

- Fixed Limit WP-Admin HTTP Requests -> invalid variable pagenow.
Expand Down
4 changes: 2 additions & 2 deletions docket-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* @wordpress-plugin
* Plugin Name: Docket Cache
* Plugin URI: https://docketcache.com/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash
* Version: 20.12.04
* VerPrev: 20.12.03
* Version: 21.01.01
* VerPrev: 20.12.04
* Description: A persistent object cache stored as a plain PHP code, accelerates caching with OPcache backend.
* GitHub Plugin URI: https://github.com/nawawi/docket-cache
* Author: Nawawi Jamili
Expand Down
101 changes: 101 additions & 0 deletions includes/admin/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,107 @@
<?php echo $this->config_select_bool('limithttprequest'); ?>
</td>
</tr>
<tr>
<td colspan="2" class="stitle">
<?php esc_html_e('Runtime Options', 'docket-cache'); ?>
</td>
</tr>
<tr id="rtpostautosave">
<th><?php echo esc_html__('Auto Save Interval', 'docket-cache').$this->tooltip('rtpostautosave'); ?></th>
<td>
<?php
echo $this->config_select_set(
'rtpostautosave',
[
'default' => __('Default', 'docket-cache'),
'1' => __('Every Minute', 'docket-cache'),
'5' => __('Every 5 Minutes', 'docket-cache'),
'15' => __('Every 15 Minutes', 'docket-cache'),
'off' => __('Disable', 'docket-cache'),
]
);
?>
</td>
</tr>
<tr id="rtpostrevision">
<th><?php echo esc_html__('Post Revisions', 'docket-cache').$this->tooltip('rtpostrevision'); ?></th>
<td>
<?php
echo $this->config_select_set(
'rtpostrevision',
[
'default' => __('Default', 'docket-cache'),
'3' => __('Limit to 3 Revisions', 'docket-cache'),
'5' => __('Limit to 5 Revisions', 'docket-cache'),
'on' => __('Enable', 'docket-cache'),
'off' => __('Disable', 'docket-cache'),
]
);
?>
</td>
</tr>
<tr id="rtpostemptytrash">
<th><?php echo esc_html__('Trash Bin', 'docket-cache').$this->tooltip('rtpostemptytrash'); ?></th>
<td>
<?php
echo $this->config_select_set(
'rtpostemptytrash',
[
'default' => __('Default', 'docket-cache'),
'7' => __('Empty In 7 Days', 'docket-cache'),
'14' => __('Empty In 14 Days', 'docket-cache'),
'30' => __('Empty In 30 Days', 'docket-cache'),
'off' => __('Disable', 'docket-cache'),
]
);
?>
</td>
</tr>
<tr id="rtimageoverwrite">
<th><?php echo esc_html__('Cleanup Image Edits', 'docket-cache').$this->tooltip('rtimageoverwrite'); ?></th>
<td>
<?php
echo $this->config_select_set(
'rtimageoverwrite',
[
'default' => __('Default', 'docket-cache'),
'on' => __('Enable', 'docket-cache'),
'off' => __('Disable', 'docket-cache'),
]
);
?>
</td>
</tr>
<tr id="rtpluginthemeeditor">
<th><?php echo esc_html__('Deactivate Plugin / Theme Editor', 'docket-cache').$this->tooltip('rtpluginthemeeditor'); ?></th>
<td>
<?php
echo $this->config_select_set(
'rtpluginthemeeditor',
[
'default' => __('Default', 'docket-cache'),
'on' => __('Enable', 'docket-cache'),
'off' => __('Disable', 'docket-cache'),
]
);
?>
</td>
</tr>
<tr id="rtpluginthemeinstall">
<th><?php echo esc_html__('Deactivate Plugin / Theme Update and Installation', 'docket-cache').$this->tooltip('rtpluginthemeinstall'); ?></th>
<td>
<?php
echo $this->config_select_set(
'rtpluginthemeinstall',
[
'default' => __('WP Default', 'docket-cache'),
'on' => __('Enable', 'docket-cache'),
'off' => __('Disable', 'docket-cache'),
]
);
?>
</td>
</tr>
<tr>
<td colspan="2" class="stitle">
<?php esc_html_e('Admin Interface', 'docket-cache'); ?>
Expand Down
1 change: 1 addition & 0 deletions includes/admin/docket.css
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ body {
#docket-cache .flex-container .postbox .inside .bt-cx {
margin-top: 10px;
margin-bottom: 10px;
width: 100%;
display: table;
}

Expand Down
34 changes: 16 additions & 18 deletions includes/admin/resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@

\defined('ABSPATH') || exit;
?>
<?php $this->tab_title(esc_html__('Actions', 'docket-cache')); ?>
<div class="qact">
<div class="cmd">
<h4><?php esc_html_e('Config Reset', 'docket-cache'); ?></h4>
<p>
<?php esc_html_e('Reset all configuration to default.', 'docket-cache'); ?>
</p>
<a href="<?php echo $this->pt->action_query('configreset', ['idx' => 'config']); ?>" class="button button-primary button-large btx-spinner"><?php esc_html_e('Reset to default', 'docket-cache'); ?></a>
<hr>
<h4><?php esc_html_e('Cleanup Post', 'docket-cache'); ?></h4>
<p>
<?php esc_html_e('Cleanup Revisions, Auto Draft, Trash Bin.', 'docket-cache'); ?>
</p>
<a href="<?php echo $this->pt->action_query('cleanuppost', ['idx' => 'config']); ?>" class="button button-primary button-large btx-spinner"><?php esc_html_e('Cleanup Post', 'docket-cache'); ?></a>
</div>
</div>
<?php $this->tab_title(esc_html__('Resources', 'docket-cache')); ?>
<div class="postbox">
<div class="inside">
Expand All @@ -21,24 +37,6 @@
<?php esc_html_e('To adjust the plugin behaviour and manage through a command line, please refer to the documentation page for details.', 'docket-cache'); ?>
<a href="https://docs.docketcache.com/" class="button button-secondary button-small bt-cx" rel="noopener" target="new"><?php esc_html_e('Dcoumenation', 'docket-cache'); ?></a>
</p>
<hr>
<p>
<strong><?php esc_html_e('CRONBOT', 'docket-cache'); ?></strong><br class="break">
<?php
/* translators: %s: external service */
printf(esc_html__('The Cronbot is an %s that pings your website every hour to keep WordPress Cron running actively. Only site Timezone, URL and version are involved when enabling this service.', 'docket-cache'), '<a href="https://cronbot.docketcache.com" rel="noopener" target="new">external service</a>');
?>
</p>
<hr>
<p>
<strong><?php esc_html_e('CACHE LOG', 'docket-cache'); ?></strong><br class="break">
<?php esc_html_e('The cache log intends to provide information on how the cache works. For performance and security concerns, deactivate if no longer needed.', 'docket-cache'); ?>
</p>
<hr>
<p>
<strong><?php esc_html_e('CHECK VERSION', 'docket-cache'); ?></strong><br class="break">
<?php esc_html_e('The Check Critical Version allows Docket Cache to check any critical future version that requires removing cache files after doing the updates, purposely to avoid error-prone.', 'docket-cache'); ?>
</p>
<?php if (!apply_filters('docketcache/filter/view/nosponsor', false)) : ?>
<hr>
<p>
Expand Down
4 changes: 4 additions & 0 deletions includes/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,10 @@ private function dc_precache_set($hash)
continue;
}

if ('transient' === $cache_group || 'site-transient' === $cache_group) {
continue;
}

if ($this->is_non_persistent_groups($cache_group)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @wordpress-plugin
* Plugin Name: Docket Cache Drop-in
* Plugin URI: https://wordpress.org/plugins/docket-cache/
* Version: 20.12.04
* Version: 21.01.01
* Description: A persistent object cache stored as a plain PHP code, accelerates caching with OPcache backend.
* Author: Nawawi Jamili
* Author URI: https://docketcache.com
Expand Down
5 changes: 5 additions & 0 deletions includes/src/Bepart.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,9 @@ public function get_timezone_name()
$this->get_utc_offset()
);
}

public function normalize_content($content)
{
return str_replace(["\r\n", "\n\r", "\r", "\n"], "\n", $content);
}
}
33 changes: 33 additions & 0 deletions includes/src/Canopt.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ public function keys($key = false)
'objectcacheoff' => esc_html__('Suspend Object Cache', 'docket-cache'),
'opcshutdown' => esc_html__('Flush OPcache During Deactivation', 'docket-cache'),
'limithttprequest' => esc_html__('Limit WP-Admin HTTP requests', 'docket-cache'),
'rtpostautosave' => esc_html__('Auto Save Interval', 'docket-cache'),
'rtpostrevision' => esc_html__('Post Revisions', 'docket-cache'),
'rtpostemptytrash' => esc_html__('Trash Bin', 'docket-cache'),
'rtpluginthemeeditor' => esc_html__('Deactivate Plugin / Theme Editor', 'docket-cache'),
'rtpluginthemeinstall' => esc_html__('Deactivate Plugin / Theme Update and Installation', 'docket-cache'),
'rtimageoverwrite' => esc_html__('Cleanup Image Edits', 'docket-cache'),
];

$data = apply_filters('docketcache/filter/optionkeys', $data);
Expand Down Expand Up @@ -383,4 +389,31 @@ public function lookup_delete($key)

return $this->unlock($fkey);
}

public function reset()
{
$this->clear_lock();

$parts = [
'options',
'runtime',
'pings',
'cronbot',
'checkversion',
'cachestats',
'gc',
];

$ok = true;
foreach ($parts as $part) {
$file = $this->path.'/'.$part.'.php';
if (@is_file($file) && is_writable($file)) {
if (!@unlink($file)) {
$ok = false;
}
}
}

return $ok;
}
}
48 changes: 48 additions & 0 deletions includes/src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,54 @@ public function reset_cron()
$this->halt_success(__('Cron event has been reset.', 'docket-cache'));
}

/**
* Removes the Docket Cache runtime code.
*
* Remove runtime code.
*
* ## EXAMPLES
*
* wp cache runtime:remove
*
* @subcommand runtime:remove
*/
public function runtime_remove()
{
if (WpConfig::is_bedrock()) {
WP_CLI::line(__('This command does not support Bedrock. Please manually remove the runtime code.', 'docket-cache'));
WP_CLI::halt(1);
}

if (WpConfig::runtime_remove()) {
$this->halt_success(__('The runtime code has been removed.', 'docket-cache'));
}
$this->halt_error(__('Failed to remove runtime code.', 'docket-cache'));
}

/**
* Install the Docket Cache runtime code.
*
* Install runtime code in wp-config file.
*
* ## EXAMPLES
*
* wp cache runtime:install
*
* @subcommand runtime:install
*/
public function runtime_install()
{
if (WpConfig::is_bedrock()) {
WP_CLI::line(__('This command does not support Bedrock. Please manually install the runtime code.', 'docket-cache'));
WP_CLI::halt(1);
}

if (WpConfig::runtime_install()) {
$this->halt_success(__('Updating wp-config.php file successful', 'docket-cache'));
}
$this->halt_error(__('Failed to update wp-config.php file.', 'docket-cache'));
}

/**
* Flushes the precaching files.
*
Expand Down
18 changes: 18 additions & 0 deletions includes/src/Constans.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,24 @@ public function register_default()
// limit http request from uncommon page.
$this->maybe_define($this->px('LIMITHTTPREQUEST'), false);

// @private: auto save interval.
$this->maybe_define($this->px('RTPOSTAUTOSAVE'), 1);

// @private: post revision.
$this->maybe_define($this->px('RTPOSTREVISION'), 'on');

// @private: empty trash.
$this->maybe_define($this->px('RTPOSTEMPTYTRASH'), 30);

// @private: plugin / theme editor.
$this->maybe_define($this->px('RTPLUGINTHEMEEDITOR'), 'off');

// @private: plugin / theme install.
$this->maybe_define($this->px('RTPLUGINTHEMEINSTALL'), 'off');

// @private: plugin / theme install.
$this->maybe_define($this->px('RTIMAGEOVERWRITE'), 'off');

// @private
// capture fatal error rarely incase non-throwable
// set true for debugging only
Expand Down
19 changes: 17 additions & 2 deletions includes/src/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

final class Crawler
{
private static $version = '20.12.04';
private static $version = '21.01.01';
public static $send_cookie = false;

private static function default_args($param = [])
Expand Down Expand Up @@ -72,7 +72,8 @@ public static function fetch_home($param = [])
{
self::$send_cookie = true;
$param['timeout'] = 3;
self::fetch(home_url('/'), $param);

return self::fetch(home_url('/'), $param);
}

public static function fetch($url, $param = [])
Expand All @@ -88,4 +89,18 @@ public static function post($url, $param = [])

return wp_remote_post($url, $args);
}

public static function fetch_home_nocache($param = [])
{
self::$send_cookie = true;
$param['timeout'] = 3;
$param['headers'] = [
'REFERER' => site_url(),
'Cache-Control' => 'no-cache',
];

$path = '/?nocache='.time();

return self::fetch(home_url($path), $param);
}
}
Loading

0 comments on commit c10f4c4

Please sign in to comment.