Cachify - Version 2.3.1

Version Description

Download this release

Release Info

Developer pluginkollektiv
Plugin Icon 128x128 Cachify
Version 2.3.1
Comparing to
See all releases

Code changes from version 2.3.0 to 2.3.1

CHANGELOG.md CHANGED
@@ -1,18 +1,28 @@
1
  # Changelog
2
  All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
3
 
4
- ## [2.3.0]
5
- * New: WP-CLI integration, see #165, props derweili
 
 
 
 
 
6
  * New: `cachify_flush_cache_hooks` filter added to modify all hooks that flush the cache
7
  * New: Flush cache when a user is created / updated / deleted
8
- * New: Flush cache when a term is created / updated / deleted, see #169, props derweili
9
- * New: Cache behavior after post modification is now configurable in plugin settings
10
- * Enhance: Cache exceptions/User-Agents translation, see #52, props timse201
11
- * Enhance: Readme FAQ, see #51, props timse201
12
- * Enhance: sizeable exclusion boxes + placeholder, see #53, props timse201
13
- * Enhance: FAQ and Support links, see #55, props timse201
14
  * Enhance: Add text caption to "flush cache" button
15
- * Security: Tabnabbing prevention, see #55, props timse201
 
 
 
 
 
16
 
17
  ## 2.2.4
18
  * Fixes caching for mixed HTTPS and HTTP setups
1
  # Changelog
2
  All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
3
 
4
+ ## 2.3.1
5
+ * Fix: clean up unused parameter evaluation after publishing a post to prevent PHP notice (#187) (#188)
6
+ * Fix: correct minor spelling mistakes (#193, props timse201)
7
+ * Fix: update support links (#194, props timse201)
8
+
9
+ ## 2.3.0
10
+ * New: WP-CLI integration (#165, props derweili)
11
  * New: `cachify_flush_cache_hooks` filter added to modify all hooks that flush the cache
12
  * New: Flush cache when a user is created / updated / deleted
13
+ * New: Flush cache when a term is created / updated / deleted (#169, props derweili)
14
+ * New: Cache behavior after post modification is now configurable in plugin settings (#176)
15
+ * Enhance: Cache exceptions/User-Agents translation (#52, props timse201)
16
+ * Enhance: Readme FAQ (#51, props timse201)
17
+ * Enhance: sizeable exclusion boxes + placeholder (#53, props timse201)
18
+ * Enhance: FAQ and Support links (#55, props timse201)
19
  * Enhance: Add text caption to "flush cache" button
20
+ * Enhance: Icon font converted to SVG (#64)
21
+ * Enhance: Improved HDD cache invalidation for hierarchical post types (#71, props Syberspace)
22
+ * Enhance: Unified and shortened HTML signature across all caching methods (#108) (#109)
23
+ * Security: Tabnabbing prevention (#55, props timse201)
24
+ * Maintenance: Tested up to WordPress 5.4
25
+
26
 
27
  ## 2.2.4
28
  * Fixes caching for mixed HTTPS and HTTP setups
README.md DELETED
@@ -1,55 +0,0 @@
1
- # Cachify #
2
- Smart, efficient cache solution for WordPress. Use DB, HDD, APC or Memcached for storing your blog pages. Make WordPress faster!
3
-
4
- ## Description ##
5
- *Cachify* optimizes your page loads by caching posts, pages and custom post types as static content. You can choose between caching via database, on the web server’s hard drive (HDD), Memcached (only on Nginx) or — thanks to APC (Alternative PHP Cache) — directly in the web server’s system cache. Whenever a page or post is loaded, it can be pulled directly from the cache. The amount of database queries and PHP requests will dramatically decrease towards zero, depending on the caching method you chose.
6
-
7
- ### Features ###
8
- * Works with custom post types.
9
- * Caching methods: DB, HDD, APC and Memcached.
10
- * “Flush Cache” button in the WordPress toolbar.
11
- * Ready for WordPress Multisite.
12
- * Optional compression of HTML markup.
13
- * White lists for posts and user agents.
14
- * Manual and automatic cache reset.
15
- * Automatic cache management.
16
- * Dashboard widget for cached objects.
17
- * Settings for Apache and Nginx servers.
18
- * Extendability via hooks/filters.
19
-
20
- ### Support ###
21
- * Community support via the [support forums on wordpress.org](https://wordpress.org/support/plugin/cachify)
22
- * We don’t handle support via e-mail, Twitter, GitHub issues etc.
23
-
24
- ### Contribute ###
25
- * Active development of this plugin is handled [on GitHub](https://github.com/pluginkollektiv/cachify).
26
- * Pull requests for documented bugs are highly appreciated.
27
- * If you think you’ve found a bug (e.g. you’re experiencing unexpected behavior), please post at the [support forums](https://wordpress.org/support/plugin/cachify) first.
28
- * If you want to help us translate this plugin you can do so [on WordPress Translate](https://translate.wordpress.org/projects/wp-plugins/cachify).
29
-
30
- ### Donate
31
- [Donate to us via Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW)
32
-
33
- ### Credits ###
34
- * Author: [Sergej Müller](https://sergejmueller.github.io/)
35
- * Maintainers: [pluginkollektiv](http://pluginkollektiv.org)
36
-
37
-
38
- ## Installation ##
39
- * If you don’t know how to install a plugin for WordPress, [here’s how](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
40
-
41
- ### Requirements ###
42
- * PHP 5.2.4 or greater
43
- * WordPress 4.4 or greater
44
- * APC 3.1.4 or greater (optional)
45
- * Memcached in Nginx (optional)
46
-
47
-
48
- ## Frequently Asked Questions ##
49
- Please have a look [in the FAQ pages](https://cachify.pluginkollektiv.org/documentation#faq).
50
-
51
- A complete documentation is available in the [online handbook](https://cachify.pluginkollektiv.org/documentation/).
52
-
53
-
54
- ## Changelog ##
55
- [Changelog](./CHANGELOG.md).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
apc/proxy.php CHANGED
@@ -1,4 +1,9 @@
1
  <?php
 
 
 
 
 
2
 
3
  if ( ! empty( $_COOKIE ) ) {
4
  foreach ( $_COOKIE as $k => $v ) {
@@ -18,7 +23,8 @@ if ( ! empty( $_COOKIE ) ) {
18
  */
19
  function cachify_is_ssl() {
20
  if ( isset( $_SERVER['HTTPS'] ) ) {
21
- if ( 'on' === strtolower( $_SERVER['HTTPS'] ) ) {
 
22
  return true;
23
  }
24
 
@@ -34,19 +40,26 @@ function cachify_is_ssl() {
34
 
35
  if (
36
  empty( $_cachify_logged_in )
 
37
  && ( strpos( filter_input( INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING ), '/wp-admin/' ) === false )
38
  && ( strpos( filter_input( INPUT_SERVER, 'HTTP_ACCEPT_ENCODING', FILTER_SANITIZE_STRING ), 'gzip' ) !== false )
39
- && extension_loaded( 'apc' )
40
- && ( $cache = apc_fetch( md5( ( cachify_is_ssl() ? 'https-' : '' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) . '.cachify' ) )
41
  ) {
42
- ini_set( 'zlib.output_compression', 'Off' );
 
 
 
 
 
 
 
43
 
44
- header( 'Vary: Accept-Encoding' );
45
- header( 'X-Powered-By: Cachify' );
46
- header( 'Content-Encoding: gzip' );
47
- header( 'Content-Length: ' . strlen( $cache ) );
48
- header( 'Content-Type: text/html; charset=utf-8' );
49
 
50
- echo $cache;
51
- exit;
 
52
  }
1
  <?php
2
+ /**
3
+ * Proxy for APC based caching.
4
+ *
5
+ * @package Cachify
6
+ */
7
 
8
  if ( ! empty( $_COOKIE ) ) {
9
  foreach ( $_COOKIE as $k => $v ) {
23
  */
24
  function cachify_is_ssl() {
25
  if ( isset( $_SERVER['HTTPS'] ) ) {
26
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
27
+ if ( 'on' === strtolower( wp_unslash( $_SERVER['HTTPS'] ) ) ) {
28
  return true;
29
  }
30
 
40
 
41
  if (
42
  empty( $_cachify_logged_in )
43
+ && extension_loaded( 'apc' )
44
  && ( strpos( filter_input( INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING ), '/wp-admin/' ) === false )
45
  && ( strpos( filter_input( INPUT_SERVER, 'HTTP_ACCEPT_ENCODING', FILTER_SANITIZE_STRING ), 'gzip' ) !== false )
 
 
46
  ) {
47
+ $prefix = cachify_is_ssl() ? 'https-' : '';
48
+ $cache = apc_fetch(
49
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
50
+ md5( $prefix . wp_unslash( $_SERVER['HTTP_HOST'] ) . wp_unslash( $_SERVER['REQUEST_URI'] ) )
51
+ . '.cachify'
52
+ );
53
+ if ( $cache ) {
54
+ ini_set( 'zlib.output_compression', 'Off' );
55
 
56
+ header( 'Vary: Accept-Encoding' );
57
+ header( 'X-Powered-By: Cachify' );
58
+ header( 'Content-Encoding: gzip' );
59
+ header( 'Content-Length: ' . strlen( $cache ) );
60
+ header( 'Content-Type: text/html; charset=utf-8' );
61
 
62
+ echo $cache; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
63
+ exit;
64
+ }
65
  }
cachify.php CHANGED
@@ -1,16 +1,17 @@
1
  <?php
2
- /*
3
- Plugin Name: Cachify
4
- Description: Easy to use WordPress caching plugin. Serving static blog pages from database, disk, Memcached or APC.
5
- Author: pluginkollektiv
6
- Author URI: https://pluginkollektiv.org
7
- Plugin URI: https://cachify.pluginkollektiv.org/
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
- Version: 2.3.0
11
- Text Domain: cachify
12
- Domain Path: /lang
13
- */
 
14
 
15
  /*
16
  Copyright (C) 2011-2015 Sergej Müller
@@ -74,24 +75,28 @@ register_uninstall_hook(
74
 
75
  /* WP-CLI */
76
  add_action(
77
- 'cli_init',
78
- array(
79
- 'Cachify_CLI',
80
- 'add_commands'
81
- )
82
  );
83
 
84
  /* Autoload Init */
85
  spl_autoload_register( 'cachify_autoload' );
86
 
87
- /* Autoload function */
 
 
 
 
88
  function cachify_autoload( $class ) {
89
  if ( in_array( $class, array( 'Cachify', 'Cachify_APC', 'Cachify_DB', 'Cachify_HDD', 'Cachify_MEMCACHED', 'Cachify_CLI' ) ) ) {
90
  require_once(
91
  sprintf(
92
- '%s/inc/%s.class.php',
93
  CACHIFY_DIR,
94
- strtolower( $class )
95
  )
96
  );
97
  }
1
  <?php
2
+ /**
3
+ * Plugin Name: Cachify
4
+ * Description: Easy to use WordPress caching plugin. Serving static blog pages from database, disk, Memcached or APC.
5
+ * Author: pluginkollektiv
6
+ * Author URI: https://pluginkollektiv.org
7
+ * Plugin URI: https://cachify.pluginkollektiv.org
8
+ * License: GPLv2 or later
9
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+ * Version: 2.3.1
11
+ * Text Domain: cachify
12
+ *
13
+ * @package Cachify
14
+ */
15
 
16
  /*
17
  Copyright (C) 2011-2015 Sergej Müller
75
 
76
  /* WP-CLI */
77
  add_action(
78
+ 'cli_init',
79
+ array(
80
+ 'Cachify_CLI',
81
+ 'add_commands',
82
+ )
83
  );
84
 
85
  /* Autoload Init */
86
  spl_autoload_register( 'cachify_autoload' );
87
 
88
+ /**
89
+ * Autoload the class.
90
+ *
91
+ * @param string $class the class name.
92
+ */
93
  function cachify_autoload( $class ) {
94
  if ( in_array( $class, array( 'Cachify', 'Cachify_APC', 'Cachify_DB', 'Cachify_HDD', 'Cachify_MEMCACHED', 'Cachify_CLI' ) ) ) {
95
  require_once(
96
  sprintf(
97
+ '%s/inc/class-%s.php',
98
  CACHIFY_DIR,
99
+ strtolower( str_replace( '_', '-', $class ) )
100
  )
101
  );
102
  }
css/dashboard.css CHANGED
@@ -1,11 +1,11 @@
1
  /* @group Dashboard */
2
- #dashboard_right_now .cachify-icon{
3
  width: 19px;
4
  height: 13px;
5
  fill: #606a73;
6
  }
7
 
8
- #dashboard_right_now li a.cachify-glance::before{
9
  content: "";
10
  padding: 0;
11
  }/* @end group */
1
  /* @group Dashboard */
2
+ #dashboard_right_now .cachify-icon {
3
  width: 19px;
4
  height: 13px;
5
  fill: #606a73;
6
  }
7
 
8
+ #dashboard_right_now li a.cachify-glance::before {
9
  content: "";
10
  padding: 0;
11
  }/* @end group */
css/dashboard.min.css CHANGED
@@ -1 +1 @@
1
- #dashboard_right_now .cachify-icon{width:19px;height:13px;fill:#606a73}#dashboard_right_now li a.cachify-glance::before{content:"";padding:0}
1
+ #dashboard_right_now .cachify-icon{width:19px;height:13px;fill:#606a73}#dashboard_right_now li a.cachify-glance::before{content:"";padding:0}
css/settings.css CHANGED
@@ -1,28 +1,28 @@
1
  .wp-core-ui .button-flush {
2
- background: #dd823b;
3
- border-color: #c36922 #ad5d1e #ad5d1e;
4
- color: #fff;
5
- box-shadow: 0 1px 0 #ad5d1e;
6
- text-shadow: 0 -1px 1px #ad5d1e,1px 0 1px #ad5d1e,0 1px 1px #ad5d1e,-1px 0 1px #ad5d1e
7
  }
8
 
9
  .wp-core-ui .button-flush:focus,
10
  .wp-core-ui .button-flush:hover {
11
- background: #df8a48;
12
- border-color: #ad5d1e;
13
- color: #fff;
14
- box-shadow: 0 1px 0 #ad5d1e
15
  }
16
 
17
  .wp-core-ui .button-flush:focus {
18
- box-shadow: inset 0 1px 0 #c36922,0 0 2px 1px #33b3db
19
  }
20
 
21
  .wp-core-ui .button-flush.active,
22
  .wp-core-ui .button-flush.active:focus,
23
  .wp-core-ui .button-flush.active:hover,
24
  .wp-core-ui .button-flush:active {
25
- background: #c36922;
26
- border-color: #ad5d1e;
27
- box-shadow: inset 0 2px 0 #ad5d1e
28
- }
1
  .wp-core-ui .button-flush {
2
+ background: #dd823b;
3
+ border-color: #c36922 #ad5d1e #ad5d1e;
4
+ color: #fff;
5
+ box-shadow: 0 1px 0 #ad5d1e;
6
+ text-shadow: 0 -1px 1px #ad5d1e, 1px 0 1px #ad5d1e, 0 1px 1px #ad5d1e, -1px 0 1px #ad5d1e;
7
  }
8
 
9
  .wp-core-ui .button-flush:focus,
10
  .wp-core-ui .button-flush:hover {
11
+ background: #df8a48;
12
+ border-color: #ad5d1e;
13
+ color: #fff;
14
+ box-shadow: 0 1px 0 #ad5d1e;
15
  }
16
 
17
  .wp-core-ui .button-flush:focus {
18
+ box-shadow: inset 0 1px 0 #c36922, 0 0 2px 1px #33b3db;
19
  }
20
 
21
  .wp-core-ui .button-flush.active,
22
  .wp-core-ui .button-flush.active:focus,
23
  .wp-core-ui .button-flush.active:hover,
24
  .wp-core-ui .button-flush:active {
25
+ background: #c36922;
26
+ border-color: #ad5d1e;
27
+ box-shadow: inset 0 2px 0 #ad5d1e;
28
+ }
docker_tag ADDED
@@ -0,0 +1 @@
 
1
+ docker.pkg.github.com/pluginkollektiv/cachify/php-actions_composer_cachify:php-latest-build2
inc/{cachify.settings_footer.php → cachify.settings-footer.php} RENAMED
@@ -1,11 +1,17 @@
1
  <?php
 
 
 
 
 
 
2
  /* Quit */
3
  defined( 'ABSPATH' ) || exit;
4
  ?>
5
 
6
  <p>
7
- <a href="<?php echo esc_url( __( 'https://cachify.pluginkollektiv.org/documentation#faq', 'cachify' ), 'https' ); ?>" rel="noopener noreferrer"><?php esc_html_e( 'FAQ', 'cachify' ); ?></a>
8
  &bull; <a href="https://cachify.pluginkollektiv.org/documentation/" rel="noopener noreferrer"><?php esc_html_e( 'Manual', 'cachify' ); ?></a>
9
- &bull; <a href="https://wordpress.org/support/plugin/cachify" rel="noopener noreferrer"><?php esc_html_e( 'Support', 'cachify' ); ?></a>
10
  &bull; <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Donate', 'cachify' ); ?></a>
11
  </p>
1
  <?php
2
+ /**
3
+ * Footer line of the settings page.
4
+ *
5
+ * @package Cachify
6
+ */
7
+
8
  /* Quit */
9
  defined( 'ABSPATH' ) || exit;
10
  ?>
11
 
12
  <p>
13
+ <a href="<?php echo esc_url( __( 'https://cachify.pluginkollektiv.org/documentation/faq/', 'cachify' ), 'https' ); ?>" rel="noopener noreferrer"><?php esc_html_e( 'FAQ', 'cachify' ); ?></a>
14
  &bull; <a href="https://cachify.pluginkollektiv.org/documentation/" rel="noopener noreferrer"><?php esc_html_e( 'Manual', 'cachify' ); ?></a>
15
+ &bull; <a href="https://wordpress.org/support/plugin/cachify/" rel="noopener noreferrer"><?php esc_html_e( 'Support', 'cachify' ); ?></a>
16
  &bull; <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Donate', 'cachify' ); ?></a>
17
  </p>
inc/cachify.settings.php CHANGED
@@ -1,10 +1,16 @@
1
  <?php
 
 
 
 
 
 
2
  /* Quit */
3
  defined( 'ABSPATH' ) || exit;
4
  ?>
5
 
6
  <form method="post" action="options.php">
7
- <?php settings_fields( 'cachify' ) ?>
8
  <table class="form-table">
9
  <tr>
10
  <th scope="row">
@@ -13,7 +19,7 @@ defined( 'ABSPATH' ) || exit;
13
  <td>
14
  <select name="cachify[use_apc]" id="cachify_cache_method">
15
  <?php foreach ( self::_method_select() as $k => $v ) { ?>
16
- <option value="<?php echo esc_attr( $k ) ?>" <?php selected( $options['use_apc'], $k ); ?>><?php echo esc_html( $v ) ?></option>
17
  <?php } ?>
18
  </select>
19
  </td>
@@ -21,26 +27,37 @@ defined( 'ABSPATH' ) || exit;
21
 
22
  <tr>
23
  <th scope="row">
24
- <label for="cachify_cache_expires"><?php esc_html_e( 'Cache expiration', 'cachify' ) ?></label>
25
  </th>
26
  <td>
27
  <?php if ( self::METHOD_HDD === $options['use_apc'] ) : ?>
28
- <input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="" disabled="disabled" class="small-text" /> Hours
 
29
  <p class="description"><?php esc_html_e( 'HDD cache will only expire as you update posts or flush it yourself.', 'cachify' ); ?></p>
30
  <?php else : ?>
31
- <input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="<?php echo esc_attr( $options['cache_expires'] ) ?>" class="small-text" />
32
  <?php esc_html_e( 'Hours', 'cachify' ); ?>
33
  <?php endif; ?>
34
 
35
  <p class="description">
36
- <?php printf(
 
37
  /* translators: Placeholder is the trash icon itself as dashicon */
38
  esc_html__( 'Flush the cache by clicking the button below or the %1$s icon in the admin bar.', 'cachify' ),
39
  '<span class="dashicons dashicons-trash" aria-hidden="true"></span><span class="screen-reader-text">"' . esc_html__( 'Flush the cachify cache', 'cachify' ) . '"</span>'
40
- ); ?>
 
41
  </p>
42
 
43
- <p><a class="button button-flush" href="<?php echo wp_nonce_url( add_query_arg( '_cachify', 'flush' ), '_cachify__flush_nonce' ); ?>"><?php esc_html_e( 'Flush cache now', 'cachify' ) ?></a></p>
 
 
 
 
 
 
 
 
44
  </td>
45
  </tr>
46
 
@@ -85,15 +102,15 @@ defined( 'ABSPATH' ) || exit;
85
  <td>
86
  <fieldset>
87
  <label for="cachify_without_ids">
88
- <input type="text" name="cachify[without_ids]" id="cachify_without_ids" placeholder="<?php esc_attr_e( 'e.g. 1, 2, 3', 'cachify' ); ?>" value="<?php echo esc_attr( $options['without_ids'] ) ?>" />
89
- <?php esc_html_e( 'Post/Pages-IDs', 'cachify' ); ?>
90
  </label>
91
 
92
  <br />
93
 
94
  <label for="cachify_without_agents">
95
- <input type="text" name="cachify[without_agents]" id="cachify_without_agents" placeholder="<?php esc_attr_e( 'e.g. MSIE 6, Opera', 'cachify' ); ?>" value="<?php echo esc_attr( $options['without_agents'] ) ?>" />
96
- <?php esc_html_e( 'Browser User-Agents', 'cachify' ); ?>
97
  </label>
98
  </fieldset>
99
  </td>
@@ -106,8 +123,8 @@ defined( 'ABSPATH' ) || exit;
106
  <td>
107
  <select name="cachify[compress_html]" id="cachify_compress_html">
108
  <?php foreach ( self::_minify_select() as $k => $v ) { ?>
109
- <option value="<?php echo esc_attr( $k ) ?>" <?php selected( $options['compress_html'], $k ); ?>>
110
- <?php echo esc_html( $v ) ?>
111
  </option>
112
  <?php } ?>
113
  </select>
@@ -125,5 +142,5 @@ defined( 'ABSPATH' ) || exit;
125
  </tr>
126
  </table>
127
 
128
- <?php submit_button() ?>
129
  </form>
1
  <?php
2
+ /**
3
+ * Settings page.
4
+ *
5
+ * @package Cachify
6
+ */
7
+
8
  /* Quit */
9
  defined( 'ABSPATH' ) || exit;
10
  ?>
11
 
12
  <form method="post" action="options.php">
13
+ <?php settings_fields( 'cachify' ); ?>
14
  <table class="form-table">
15
  <tr>
16
  <th scope="row">
19
  <td>
20
  <select name="cachify[use_apc]" id="cachify_cache_method">
21
  <?php foreach ( self::_method_select() as $k => $v ) { ?>
22
+ <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $options['use_apc'], $k ); ?>><?php echo esc_html( $v ); ?></option>
23
  <?php } ?>
24
  </select>
25
  </td>
27
 
28
  <tr>
29
  <th scope="row">
30
+ <label for="cachify_cache_expires"><?php esc_html_e( 'Cache expiration', 'cachify' ); ?></label>
31
  </th>
32
  <td>
33
  <?php if ( self::METHOD_HDD === $options['use_apc'] ) : ?>
34
+ <input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="" disabled="disabled" class="small-text" />
35
+ <?php esc_html_e( 'Hours', 'cachify' ); ?>
36
  <p class="description"><?php esc_html_e( 'HDD cache will only expire as you update posts or flush it yourself.', 'cachify' ); ?></p>
37
  <?php else : ?>
38
+ <input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="<?php echo esc_attr( $options['cache_expires'] ); ?>" class="small-text" />
39
  <?php esc_html_e( 'Hours', 'cachify' ); ?>
40
  <?php endif; ?>
41
 
42
  <p class="description">
43
+ <?php
44
+ printf(
45
  /* translators: Placeholder is the trash icon itself as dashicon */
46
  esc_html__( 'Flush the cache by clicking the button below or the %1$s icon in the admin bar.', 'cachify' ),
47
  '<span class="dashicons dashicons-trash" aria-hidden="true"></span><span class="screen-reader-text">"' . esc_html__( 'Flush the cachify cache', 'cachify' ) . '"</span>'
48
+ );
49
+ ?>
50
  </p>
51
 
52
+ <?php
53
+ $flush_cache_url = wp_nonce_url( add_query_arg( '_cachify', 'flush' ), '_cachify__flush_nonce' );
54
+ ?>
55
+
56
+ <p>
57
+ <a class="button button-flush" href="<?php echo esc_url( $flush_cache_url ); ?>">
58
+ <?php esc_html_e( 'Flush cache now', 'cachify' ); ?>
59
+ </a>
60
+ </p>
61
  </td>
62
  </tr>
63
 
102
  <td>
103
  <fieldset>
104
  <label for="cachify_without_ids">
105
+ <input type="text" name="cachify[without_ids]" id="cachify_without_ids" placeholder="<?php esc_attr_e( 'e.g. 1, 2, 3', 'cachify' ); ?>" value="<?php echo esc_attr( $options['without_ids'] ); ?>" />
106
+ <?php esc_html_e( 'Post/Page IDs', 'cachify' ); ?>
107
  </label>
108
 
109
  <br />
110
 
111
  <label for="cachify_without_agents">
112
+ <input type="text" name="cachify[without_agents]" id="cachify_without_agents" placeholder="<?php esc_attr_e( 'e.g. MSIE 6, Opera', 'cachify' ); ?>" value="<?php echo esc_attr( $options['without_agents'] ); ?>" />
113
+ <?php esc_html_e( 'Browser User Agents', 'cachify' ); ?>
114
  </label>
115
  </fieldset>
116
  </td>
123
  <td>
124
  <select name="cachify[compress_html]" id="cachify_compress_html">
125
  <?php foreach ( self::_minify_select() as $k => $v ) { ?>
126
+ <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $options['compress_html'], $k ); ?>>
127
+ <?php echo esc_html( $v ); ?>
128
  </option>
129
  <?php } ?>
130
  </select>
142
  </tr>
143
  </table>
144
 
145
+ <?php submit_button(); ?>
146
  </form>
inc/{cachify_apc.class.php → class-cachify-apc.php} RENAMED
@@ -1,8 +1,13 @@
1
  <?php
 
 
 
 
 
2
 
3
  /**
4
- * Cachify_APC
5
- */
6
  final class Cachify_APC {
7
 
8
  /**
@@ -43,7 +48,7 @@ final class Cachify_APC {
43
  public static function store_item( $hash, $data, $lifetime, $sig_detail ) {
44
  /* Do not store empty data. */
45
  if ( empty( $data ) ) {
46
- trigger_error( __METHOD__ . ": Empty input.", E_USER_WARNING );
47
  return;
48
  }
49
 
1
  <?php
2
+ /**
3
+ * Class for APC based caching.
4
+ *
5
+ * @package Cachify
6
+ */
7
 
8
  /**
9
+ * Cachify_APC
10
+ */
11
  final class Cachify_APC {
12
 
13
  /**
48
  public static function store_item( $hash, $data, $lifetime, $sig_detail ) {
49
  /* Do not store empty data. */
50
  if ( empty( $data ) ) {
51
+ trigger_error( __METHOD__ . ': Empty input.', E_USER_WARNING );
52
  return;
53
  }
54
 
inc/{cachify_cli.class.php → class-cachify-cli.php} RENAMED
@@ -1,8 +1,13 @@
1
  <?php
 
 
 
 
 
2
 
3
  /**
4
- * Cachify_CLI
5
- */
6
  final class Cachify_CLI {
7
 
8
  /**
@@ -11,22 +16,20 @@ final class Cachify_CLI {
11
  * @since 2.3.0
12
  * @change 2.3.0
13
  *
14
- * @param array $args
15
- * @param array $assoc_args
16
  */
17
  public static function flush_cache( $args, $assoc_args ) {
18
-
19
- // set default args
20
  $assoc_args = wp_parse_args( $assoc_args, array( 'all-methods' => false ) );
21
 
22
  Cachify::flush_total_cache( $assoc_args['all-methods'] );
23
 
24
  if ( $assoc_args['all-methods'] ) {
25
- WP_CLI::success( "All Cachify caches flushed" );
26
  } else {
27
- WP_CLI::success( "Cachify cache flushed" );
28
  }
29
-
30
  }
31
 
32
  /**
@@ -35,25 +38,22 @@ final class Cachify_CLI {
35
  * @since 2.3.0
36
  * @change 2.3.0
37
  *
38
- * @param array $args
39
- * @param array $assoc_args
40
  */
41
  public static function get_cache_size( $args, $assoc_args ) {
42
-
43
- // set default args
44
  $assoc_args = wp_parse_args( $assoc_args, array( 'raw' => false ) );
45
 
46
- // get cache size
47
  $cache_size = Cachify::get_cache_size();
48
 
49
- if ( $assoc_args["raw"] ) {
50
  $message = $cache_size;
51
  } else {
52
  $message = "The cache size is $cache_size bytes";
53
  }
54
 
55
  WP_CLI::line( $message );
56
-
57
  }
58
 
59
  /**
@@ -63,10 +63,7 @@ final class Cachify_CLI {
63
  * @change 2.3.0
64
  */
65
  public static function add_commands() {
66
-
67
- /*
68
- * Add flush command
69
- */
70
  WP_CLI::add_command(
71
  'cachify flush',
72
  array(
@@ -81,14 +78,12 @@ final class Cachify_CLI {
81
  'name' => 'all-methods',
82
  'description' => 'Flush all caching methods',
83
  'optional' => true,
84
- )
85
  ),
86
  )
87
  );
88
 
89
- /*
90
- * Add cache-size command
91
- */
92
  WP_CLI::add_command(
93
  'cachify cache-size',
94
  array(
1
  <?php
2
+ /**
3
+ * Class for the command line interface (WP CLI commands).
4
+ *
5
+ * @package Cachify
6
+ */
7
 
8
  /**
9
+ * Cachify_CLI
10
+ */
11
  final class Cachify_CLI {
12
 
13
  /**
16
  * @since 2.3.0
17
  * @change 2.3.0
18
  *
19
+ * @param array $args the CLI arguments as array.
20
+ * @param array $assoc_args the CLI arguments as associative array.
21
  */
22
  public static function flush_cache( $args, $assoc_args ) {
23
+ // Set default arguments.
 
24
  $assoc_args = wp_parse_args( $assoc_args, array( 'all-methods' => false ) );
25
 
26
  Cachify::flush_total_cache( $assoc_args['all-methods'] );
27
 
28
  if ( $assoc_args['all-methods'] ) {
29
+ WP_CLI::success( 'All Cachify caches flushed' );
30
  } else {
31
+ WP_CLI::success( 'Cachify cache flushed' );
32
  }
 
33
  }
34
 
35
  /**
38
  * @since 2.3.0
39
  * @change 2.3.0
40
  *
41
+ * @param array $args the CLI arguments as array.
42
+ * @param array $assoc_args the CLI arguments as associative array.
43
  */
44
  public static function get_cache_size( $args, $assoc_args ) {
45
+ // Set default arguments.
 
46
  $assoc_args = wp_parse_args( $assoc_args, array( 'raw' => false ) );
47
 
 
48
  $cache_size = Cachify::get_cache_size();
49
 
50
+ if ( $assoc_args['raw'] ) {
51
  $message = $cache_size;
52
  } else {
53
  $message = "The cache size is $cache_size bytes";
54
  }
55
 
56
  WP_CLI::line( $message );
 
57
  }
58
 
59
  /**
63
  * @change 2.3.0
64
  */
65
  public static function add_commands() {
66
+ // Add flush command.
 
 
 
67
  WP_CLI::add_command(
68
  'cachify flush',
69
  array(
78
  'name' => 'all-methods',
79
  'description' => 'Flush all caching methods',
80
  'optional' => true,
81
+ ),
82
  ),
83
  )
84
  );
85
 
86
+ // Add cache-size command.
 
 
87
  WP_CLI::add_command(
88
  'cachify cache-size',
89
  array(
inc/{cachify_db.class.php → class-cachify-db.php} RENAMED
@@ -1,8 +1,13 @@
1
  <?php
 
 
 
 
 
2
 
3
  /**
4
- * Cachify_DB
5
- */
6
  final class Cachify_DB {
7
 
8
  /**
@@ -42,7 +47,7 @@ final class Cachify_DB {
42
  public static function store_item( $hash, $data, $lifetime ) {
43
  /* Do not store empty data. */
44
  if ( empty( $data ) ) {
45
- trigger_error( __METHOD__ . ": Empty input.", E_USER_WARNING );
46
  return;
47
  }
48
 
@@ -53,9 +58,9 @@ final class Cachify_DB {
53
  'data' => $data,
54
  'meta' => array(
55
  'queries' => self::_page_queries(),
56
- 'timer' => self::_page_timer(),
57
  'memory' => self::_page_memory(),
58
- 'time' => current_time( 'timestamp' ),
59
  ),
60
  ),
61
  $lifetime
@@ -118,10 +123,11 @@ final class Cachify_DB {
118
  }
119
 
120
  /* Content */
121
- echo $cache['data'];
122
 
123
  /* Signature - might contain runtime information, so it's generated at this point */
124
  if ( isset( $cache['meta'] ) ) {
 
125
  echo self::_cache_signature( $sig_detail, $cache['meta'] );
126
  }
127
 
1
  <?php
2
+ /**
3
+ * Class for database based caching.
4
+ *
5
+ * @package Cachify
6
+ */
7
 
8
  /**
9
+ * Cachify_DB
10
+ */
11
  final class Cachify_DB {
12
 
13
  /**
47
  public static function store_item( $hash, $data, $lifetime ) {
48
  /* Do not store empty data. */
49
  if ( empty( $data ) ) {
50
+ trigger_error( __METHOD__ . ': Empty input.', E_USER_WARNING );
51
  return;
52
  }
53
 
58
  'data' => $data,
59
  'meta' => array(
60
  'queries' => self::_page_queries(),
61
+ 'timer' => self::_page_timer(),
62
  'memory' => self::_page_memory(),
63
+ 'time' => current_time( 'timestamp' ),
64
  ),
65
  ),
66
  $lifetime
123
  }
124
 
125
  /* Content */
126
+ echo $cache['data']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
127
 
128
  /* Signature - might contain runtime information, so it's generated at this point */
129
  if ( isset( $cache['meta'] ) ) {
130
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
131
  echo self::_cache_signature( $sig_detail, $cache['meta'] );
132
  }
133
 
inc/{cachify_hdd.class.php → class-cachify-hdd.php} RENAMED
@@ -1,8 +1,13 @@
1
  <?php
 
 
 
 
 
2
 
3
  /**
4
- * Cachify_HDD
5
- */
6
  final class Cachify_HDD {
7
 
8
  /**
@@ -44,7 +49,7 @@ final class Cachify_HDD {
44
  public static function store_item( $hash, $data, $lifetime, $sig_detail ) {
45
  /* Do not store empty data. */
46
  if ( empty( $data ) ) {
47
- trigger_error( __METHOD__ . ": Empty input.", E_USER_WARNING );
48
  return;
49
  }
50
 
@@ -105,7 +110,7 @@ final class Cachify_HDD {
105
  public static function print_cache() {
106
  $filename = self::_file_html();
107
  $size = is_readable( $filename ) ? readfile( $filename ) : false;
108
- if ( ! empty ( $size ) ) {
109
  /* Ok, cache file has been sent to output. */
110
  exit;
111
  }
@@ -157,7 +162,7 @@ final class Cachify_HDD {
157
 
158
  /* Create directory */
159
  if ( ! wp_mkdir_p( $file_path ) ) {
160
- trigger_error( __METHOD__ . ": Unable to create directory {$file_path}.", E_USER_WARNING );
161
  return;
162
  }
163
 
@@ -177,8 +182,9 @@ final class Cachify_HDD {
177
  */
178
  private static function _create_file( $file, $data ) {
179
  /* Writable? */
180
- if ( ! $handle = @fopen( $file, 'wb' ) ) {
181
- trigger_error( __METHOD__ . ": Could not write file {$file}.", E_USER_WARNING );
 
182
  return;
183
  }
184
 
@@ -202,7 +208,7 @@ final class Cachify_HDD {
202
  * @change 2.0.5
203
  *
204
  * @param string $dir Directory path.
205
- * @param boolean $recursive Clear subdirectories?
206
  */
207
  private static function _clear_dir( $dir, $recursive = false ) {
208
  /* Remote training slash */
@@ -307,14 +313,16 @@ final class Cachify_HDD {
307
  private static function _file_path( $path = null ) {
308
  $prefix = is_ssl() ? 'https-' : '';
309
 
310
- $path_parts = wp_parse_url( $path ? $path : $_SERVER['REQUEST_URI'] );
 
311
 
312
  $path = sprintf(
313
  '%s%s%s%s%s',
314
  CACHIFY_CACHE_DIR,
315
  DIRECTORY_SEPARATOR,
316
  $prefix,
317
- strtolower( $_SERVER['HTTP_HOST'] ),
 
318
  $path_parts['path']
319
  );
320
 
@@ -348,18 +356,17 @@ final class Cachify_HDD {
348
  * @return string Path to GZIP file
349
  */
350
  private static function _file_gzip( $file_path = '' ) {
351
- return ( empty( $file_path ) ? self::_file_path() : $file_path ) . 'index.html.gz';
352
  }
353
 
354
  /**
355
  * Does the user has the right to delete this file?
356
  *
357
- * @param string $file
358
  *
359
  * @return bool
360
  */
361
  private static function _user_can_delete( $file ) {
362
-
363
  if ( ! is_file( $file ) && ! is_dir( $file ) ) {
364
  return false;
365
  }
@@ -386,26 +393,26 @@ final class Cachify_HDD {
386
  return false;
387
  }
388
 
389
- // We are on a subdirectory installation and the current blog is in a subdirectory
390
  if ( '/' !== $current_blog->path ) {
391
  return true;
392
  }
393
 
394
- // If we are on the root blog in a subdirectory multisite we check if the current dir is the root dir
395
  $root_site_dir = CACHIFY_CACHE_DIR . DIRECTORY_SEPARATOR . $ssl_prefix . DOMAIN_CURRENT_SITE . DIRECTORY_SEPARATOR;
396
- if ( $root_site_dir === $file ) {
397
  return false;
398
  }
399
 
400
- // If we are on the root blog in a subdirectory multisite, we check, if the current file
401
- // is part of another blog.
402
  global $wpdb;
403
- $sql = $wpdb->prepare(
404
- 'select path from ' . $wpdb->base_prefix . 'blogs where domain = %s && blog_id != %d',
405
- $current_blog->domain,
406
- $current_blog->blog_id
 
 
407
  );
408
- $results = $wpdb->get_col( $sql );
409
  foreach ( $results as $site ) {
410
  $forbidden_path = CACHIFY_CACHE_DIR . DIRECTORY_SEPARATOR . $ssl_prefix . $current_blog->domain . $site;
411
  if ( 0 === strpos( $file, $forbidden_path ) ) {
1
  <?php
2
+ /**
3
+ * Class for HDD based caching.
4
+ *
5
+ * @package Cachify
6
+ */
7
 
8
  /**
9
+ * Cachify_HDD
10
+ */
11
  final class Cachify_HDD {
12
 
13
  /**
49
  public static function store_item( $hash, $data, $lifetime, $sig_detail ) {
50
  /* Do not store empty data. */
51
  if ( empty( $data ) ) {
52
+ trigger_error( __METHOD__ . ': Empty input.', E_USER_WARNING );
53
  return;
54
  }
55
 
110
  public static function print_cache() {
111
  $filename = self::_file_html();
112
  $size = is_readable( $filename ) ? readfile( $filename ) : false;
113
+ if ( ! empty( $size ) ) {
114
  /* Ok, cache file has been sent to output. */
115
  exit;
116
  }
162
 
163
  /* Create directory */
164
  if ( ! wp_mkdir_p( $file_path ) ) {
165
+ trigger_error( esc_html( __METHOD__ . ": Unable to create directory {$file_path}.", E_USER_WARNING ) );
166
  return;
167
  }
168
 
182
  */
183
  private static function _create_file( $file, $data ) {
184
  /* Writable? */
185
+ $handle = @fopen( $file, 'wb' );
186
+ if ( ! $handle ) {
187
+ trigger_error( esc_html( __METHOD__ . ": Could not write file {$file}.", E_USER_WARNING ) );
188
  return;
189
  }
190
 
208
  * @change 2.0.5
209
  *
210
  * @param string $dir Directory path.
211
+ * @param boolean $recursive true for clearing subdirectories as well.
212
  */
213
  private static function _clear_dir( $dir, $recursive = false ) {
214
  /* Remote training slash */
313
  private static function _file_path( $path = null ) {
314
  $prefix = is_ssl() ? 'https-' : '';
315
 
316
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
317
+ $path_parts = wp_parse_url( $path ? $path : wp_unslash( $_SERVER['REQUEST_URI'] ) );
318
 
319
  $path = sprintf(
320
  '%s%s%s%s%s',
321
  CACHIFY_CACHE_DIR,
322
  DIRECTORY_SEPARATOR,
323
  $prefix,
324
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
325
+ strtolower( wp_unslash( $_SERVER['HTTP_HOST'] ) ),
326
  $path_parts['path']
327
  );
328
 
356
  * @return string Path to GZIP file
357
  */
358
  private static function _file_gzip( $file_path = '' ) {
359
+ return ( empty( $file_path ) ? self::_file_path() : $file_path ) . 'index.html.gz';
360
  }
361
 
362
  /**
363
  * Does the user has the right to delete this file?
364
  *
365
+ * @param string $file the file name.
366
  *
367
  * @return bool
368
  */
369
  private static function _user_can_delete( $file ) {
 
370
  if ( ! is_file( $file ) && ! is_dir( $file ) ) {
371
  return false;
372
  }
393
  return false;
394
  }
395
 
396
+ // We are on a subdirectory installation and the current blog is in a subdirectory.
397
  if ( '/' !== $current_blog->path ) {
398
  return true;
399
  }
400
 
401
+ // If we are on the root blog in a subdirectory multisite, we check if the current dir is the root dir.
402
  $root_site_dir = CACHIFY_CACHE_DIR . DIRECTORY_SEPARATOR . $ssl_prefix . DOMAIN_CURRENT_SITE . DIRECTORY_SEPARATOR;
403
+ if ( $root_site_dir === $file ) {
404
  return false;
405
  }
406
 
407
+ // If we are on the root blog in a subdirectory multisite, we check, if the current file is part of another blog.
 
408
  global $wpdb;
409
+ $results = $wpdb->get_col(
410
+ $wpdb->prepare(
411
+ 'select path from ' . $wpdb->base_prefix . 'blogs where domain = %s && blog_id != %d',
412
+ $current_blog->domain,
413
+ $current_blog->blog_id
414
+ )
415
  );
 
416
  foreach ( $results as $site ) {
417
  $forbidden_path = CACHIFY_CACHE_DIR . DIRECTORY_SEPARATOR . $ssl_prefix . $current_blog->domain . $site;
418
  if ( 0 === strpos( $file, $forbidden_path ) ) {
inc/{cachify_memcached.class.php → class-cachify-memcached.php} RENAMED
@@ -1,8 +1,13 @@
1
  <?php
 
 
 
 
 
2
 
3
  /**
4
- * Cachify_MEMCACHED
5
- */
6
  final class Cachify_MEMCACHED {
7
 
8
  /**
@@ -11,7 +16,6 @@ final class Cachify_MEMCACHED {
11
  * @since 2.0.7
12
  * @var object
13
  */
14
-
15
  private static $_memcached;
16
 
17
  /**
@@ -23,7 +27,9 @@ final class Cachify_MEMCACHED {
23
  * @return boolean true/false TRUE when installed
24
  */
25
  public static function is_available() {
26
- return class_exists( 'Memcached' ) && isset( $_SERVER['SERVER_SOFTWARE'] ) && strpos( strtolower( $_SERVER['SERVER_SOFTWARE'] ), 'nginx' ) !== false;
 
 
27
  }
28
 
29
  /**
@@ -41,18 +47,18 @@ final class Cachify_MEMCACHED {
41
  /**
42
  * Store item in cache
43
  *
44
- * @since 2.0.7
45
- * @change 2.3.0
46
- *
47
  * @param string $hash Hash of the entry [ignored].
48
  * @param string $data Content of the entry.
49
  * @param integer $lifetime Lifetime of the entry.
50
- * @param bool $sigDetail Show details in signature.
 
 
 
51
  */
52
- public static function store_item( $hash, $data, $lifetime, $sigDetail ) {
53
  /* Do not store empty data. */
54
  if ( empty( $data ) ) {
55
- trigger_error( __METHOD__ . ": Empty input.", E_USER_WARNING );
56
  return;
57
  }
58
 
@@ -64,7 +70,7 @@ final class Cachify_MEMCACHED {
64
  /* Add item */
65
  self::$_memcached->set(
66
  self::_file_path(),
67
- $data . self::_cache_signature( $sigDetail ),
68
  $lifetime
69
  );
70
  }
@@ -201,12 +207,14 @@ final class Cachify_MEMCACHED {
201
  * @return string Path to cache file
202
  */
203
  private static function _file_path( $path = null ) {
204
- $path_parts = wp_parse_url( $path ? $path : $_SERVER['REQUEST_URI'] );
 
205
 
206
  return trailingslashit(
207
  sprintf(
208
  '%s%s',
209
- $_SERVER['HTTP_HOST'],
 
210
  $path_parts['path']
211
  )
212
  );
1
  <?php
2
+ /**
3
+ * Class for Memcached based caching.
4
+ *
5
+ * @package Cachify
6
+ */
7
 
8
  /**
9
+ * Cachify_MEMCACHED
10
+ */
11
  final class Cachify_MEMCACHED {
12
 
13
  /**
16
  * @since 2.0.7
17
  * @var object
18
  */
 
19
  private static $_memcached;
20
 
21
  /**
27
  * @return boolean true/false TRUE when installed
28
  */
29
  public static function is_available() {
30
+ return class_exists( 'Memcached' )
31
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
32
+ && isset( $_SERVER['SERVER_SOFTWARE'] ) && strpos( strtolower( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ), 'nginx' ) !== false;
33
  }
34
 
35
  /**
47
  /**
48
  * Store item in cache
49
  *
 
 
 
50
  * @param string $hash Hash of the entry [ignored].
51
  * @param string $data Content of the entry.
52
  * @param integer $lifetime Lifetime of the entry.
53
+ * @param bool $sig_detail Show details in signature.
54
+ *
55
+ * @since 2.0.7
56
+ * @change 2.3.0
57
  */
58
+ public static function store_item( $hash, $data, $lifetime, $sig_detail ) {
59
  /* Do not store empty data. */
60
  if ( empty( $data ) ) {
61
+ trigger_error( __METHOD__ . ': Empty input.', E_USER_WARNING );
62
  return;
63
  }
64
 
70
  /* Add item */
71
  self::$_memcached->set(
72
  self::_file_path(),
73
+ $data . self::_cache_signature( $sig_detail ),
74
  $lifetime
75
  );
76
  }
207
  * @return string Path to cache file
208
  */
209
  private static function _file_path( $path = null ) {
210
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
211
+ $path_parts = wp_parse_url( $path ? $path : wp_unslash( $_SERVER['REQUEST_URI'] ) );
212
 
213
  return trailingslashit(
214
  sprintf(
215
  '%s%s',
216
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
217
+ wp_unslash( $_SERVER['HTTP_HOST'] ),
218
  $path_parts['path']
219
  )
220
  );
inc/{cachify.class.php → class-cachify.php} RENAMED
@@ -1,8 +1,13 @@
1
  <?php
 
 
 
 
 
2
 
3
  /**
4
- * Cachify
5
- */
6
  final class Cachify {
7
 
8
  /**
@@ -66,7 +71,6 @@ final class Cachify {
66
  * @since 1.0.0
67
  * @change 2.2.2
68
  *
69
- * @param void
70
  * @return void
71
  */
72
  public function __construct() {
@@ -187,7 +191,7 @@ final class Cachify {
187
  'doing_dark_mode',
188
  array(
189
  __CLASS__,
190
- 'admin_dashboard_dark_mode_styles'
191
  )
192
  );
193
 
@@ -428,19 +432,19 @@ final class Cachify {
428
 
429
  /* APC */
430
  if ( self::METHOD_APC === self::$options['use_apc'] && Cachify_APC::is_available() ) {
431
- self::$method = new Cachify_APC;
432
 
433
  /* HDD */
434
  } elseif ( self::METHOD_HDD === self::$options['use_apc'] && Cachify_HDD::is_available() ) {
435
- self::$method = new Cachify_HDD;
436
 
437
  /* MEMCACHED */
438
  } elseif ( self::METHOD_MMC === self::$options['use_apc'] && Cachify_MEMCACHED::is_available() ) {
439
- self::$method = new Cachify_MEMCACHED;
440
 
441
  /* DB */
442
  } else {
443
- self::$method = new Cachify_DB;
444
  }
445
  }
446
 
@@ -456,12 +460,12 @@ final class Cachify {
456
  return wp_parse_args(
457
  get_option( 'cachify' ),
458
  array(
459
- 'only_guests' => 1,
460
- 'compress_html' => self::MINIFY_DISABLED,
461
- 'cache_expires' => 12,
462
- 'without_ids' => '',
463
- 'without_agents' => '',
464
- 'use_apc' => self::METHOD_DB,
465
  'reset_on_post' => 1,
466
  'reset_on_comment' => 0,
467
  'sig_detail' => 0,
@@ -524,7 +528,7 @@ final class Cachify {
524
  admin_url( 'options-general.php' )
525
  ),
526
  esc_html__( 'Settings', 'cachify' )
527
- )
528
  )
529
  );
530
  }
@@ -620,7 +624,8 @@ final class Cachify {
620
  * @return integer Cache size in bytes.
621
  */
622
  public static function get_cache_size() {
623
- if ( ! $size = get_transient( 'cachify_cache_size' ) ) {
 
624
  /* Read */
625
  $size = (int) call_user_func(
626
  array(
@@ -662,10 +667,10 @@ final class Cachify {
662
  /* Add menu item */
663
  $wp_admin_bar->add_menu(
664
  array(
665
- 'id' => 'cachify',
666
  'href' => wp_nonce_url( add_query_arg( '_cachify', 'flush' ), '_cachify__flush_nonce' ), // esc_url in /wp-includes/class-wp-admin-bar.php#L438.
667
  'parent' => 'top-secondary',
668
- 'title' => '<span class="ab-icon dashicons"></span>' .
669
  '<span class="ab-label">' .
670
  __(
671
  'Flush site cache',
@@ -696,7 +701,7 @@ final class Cachify {
696
  }
697
 
698
  /* Check nonce */
699
- if ( empty( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], '_cachify__flush_nonce' ) ) {
700
  return;
701
  }
702
 
@@ -850,7 +855,6 @@ final class Cachify {
850
  * @since 2.1.7 Make the function public
851
  * @since 2.0.3
852
  *
853
- * @param void
854
  * @return void
855
  */
856
  public static function register_publish_hooks() {
@@ -912,16 +916,6 @@ final class Cachify {
912
  return;
913
  }
914
 
915
- /* Save as var */
916
- $remove_post_type_cache = (int) $_POST['_cachify_remove_post_type_cache_on_update'];
917
-
918
- /* Save as user meta */
919
- update_user_meta(
920
- get_current_user_id(),
921
- '_cachify_remove_post_type_cache_on_update',
922
- $remove_post_type_cache
923
- );
924
-
925
  /* Remove cache OR flush */
926
  if ( 1 !== self::$options['reset_on_post'] ) {
927
  self::remove_page_cache_by_post_id( $post_id );
@@ -939,15 +933,12 @@ final class Cachify {
939
  * @param integer $post_id Post ID.
940
  */
941
  public static function remove_page_cache_by_post_id( $post_id ) {
942
- /* Value check */
943
- if ( ! $post_id = (int) $post_id ) {
944
  return;
945
  }
946
 
947
- /* Remove page by url */
948
- self::remove_page_cache_by_url(
949
- get_permalink( $post_id )
950
- );
951
  }
952
 
953
  /**
@@ -959,8 +950,8 @@ final class Cachify {
959
  * @param string $url Page URL.
960
  */
961
  public static function remove_page_cache_by_url( $url ) {
962
- /* Value check */
963
- if ( ! $url = (string) $url ) {
964
  return;
965
  }
966
 
@@ -994,7 +985,7 @@ final class Cachify {
994
  * @return bool Show details in signature.
995
  */
996
  private static function _signature_details() {
997
- return self::$options['sig_detail'] === 1;
998
  }
999
 
1000
  /**
@@ -1009,9 +1000,15 @@ final class Cachify {
1009
  private static function _cache_hash( $url = '' ) {
1010
  $prefix = is_ssl() ? 'https-' : '';
1011
  $url_parts = wp_parse_url( $url );
1012
- return md5(
1013
- empty( $url ) ? ( $prefix . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) : ( $prefix . $url_parts['host'] . $url_parts['path'] )
1014
- ) . '.cachify';
 
 
 
 
 
 
1015
  }
1016
 
1017
  /**
@@ -1036,7 +1033,8 @@ final class Cachify {
1036
  * @return boolean TRUE if index
1037
  */
1038
  private static function _is_index() {
1039
- return basename( $_SERVER['SCRIPT_NAME'] ) === 'index.php';
 
1040
  }
1041
 
1042
  /**
@@ -1085,12 +1083,8 @@ final class Cachify {
1085
  * Register all hooks to flush the total cache
1086
  *
1087
  * @since 2.4.0
1088
- *
1089
- * @param void
1090
- * @return void
1091
  */
1092
  public static function register_flush_cache_hooks() {
1093
-
1094
  /* Define all default flush cache hooks */
1095
  $flush_cache_hooks = array(
1096
  'cachify_flush_cache' => 10,
@@ -1103,7 +1097,7 @@ final class Cachify {
1103
  'edit_terms' => 10,
1104
  'user_register' => 10,
1105
  'edit_user_profile_update' => 10,
1106
- 'delete_user' => 10
1107
  );
1108
 
1109
  $flush_cache_hooks = apply_filters( 'cachify_flush_cache_hooks', $flush_cache_hooks );
@@ -1139,7 +1133,10 @@ final class Cachify {
1139
  $options = self::$options;
1140
 
1141
  /* Request vars */
1142
- if ( ! empty( $_POST ) || ( ! empty( $_GET ) && get_option( 'permalink_structure' ) ) ) {
 
 
 
1143
  return true;
1144
  }
1145
 
@@ -1185,7 +1182,8 @@ final class Cachify {
1185
  if ( $options['without_agents'] && isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
1186
  $user_agent_strings = self::_preg_split( $options['without_agents'] );
1187
  foreach ( $user_agent_strings as $user_agent_string ) {
1188
- if ( strpos( $_SERVER["HTTP_USER_AGENT"], $user_agent_string ) !== false ) {
 
1189
  return true;
1190
  }
1191
  }
@@ -1402,7 +1400,7 @@ final class Cachify {
1402
  array(),
1403
  $plugin_data['Version']
1404
  );
1405
- break;
1406
 
1407
  case 'settings_page_cachify':
1408
  wp_enqueue_style(
@@ -1411,10 +1409,10 @@ final class Cachify {
1411
  array(),
1412
  $plugin_data['Version']
1413
  );
1414
- break;
1415
 
1416
  default:
1417
- break;
1418
  }
1419
 
1420
  }
@@ -1466,7 +1464,6 @@ final class Cachify {
1466
  * @since 2.0.0
1467
  * @change 2.1.3
1468
  *
1469
- * @param array $methods Array of all available methods.
1470
  * @return array Array of actually available methods.
1471
  */
1472
  private static function _method_select() {
@@ -1555,7 +1552,7 @@ final class Cachify {
1555
  public static function validate_options( $data ) {
1556
  /* Empty data? */
1557
  if ( empty( $data ) ) {
1558
- return;
1559
  }
1560
 
1561
  /* Flush cache */
@@ -1573,15 +1570,15 @@ final class Cachify {
1573
 
1574
  /* Return */
1575
  return array(
1576
- 'only_guests' => (int) ( ! empty( $data['only_guests'] )),
1577
  'compress_html' => (int) $data['compress_html'],
1578
  'cache_expires' => (int) ( isset( $data['cache_expires'] ) ? $data['cache_expires'] : self::$options['cache_expires'] ),
1579
  'without_ids' => (string) isset( $data['without_ids'] ) ? sanitize_text_field( $data['without_ids'] ) : '',
1580
  'without_agents' => (string) isset( $data['without_agents'] ) ? sanitize_text_field( $data['without_agents'] ) : '',
1581
  'use_apc' => (int) $data['use_apc'],
1582
  'reset_on_post' => (int) ( ! empty( $data['reset_on_post'] ) ),
1583
- 'reset_on_comment' => (int) ( ! empty( $data['reset_on_comment'] )),
1584
- 'sig_detail' => (int) ( ! empty( $data['sig_detail'] )),
1585
  );
1586
  }
1587
 
@@ -1594,37 +1591,45 @@ final class Cachify {
1594
  public static function options_page() {
1595
  $options = self::_get_options();
1596
  $cachify_tabs = self::_get_tabs( $options );
1597
- $current_tab = isset( $_GET['cachify_tab'] ) && isset( $cachify_tabs[ $_GET['cachify_tab'] ] ) ? $_GET['cachify_tab'] : 'settings';
1598
- ?>
 
 
1599
 
1600
  <div class="wrap" id="cachify_settings">
1601
  <h1>Cachify</h1>
1602
 
1603
  <?php
1604
- /* Add a navbar if necessary */
1605
- if ( count( $cachify_tabs ) > 1 ) {
1606
- echo '<h2 class="nav-tab-wrapper">';
1607
- foreach ( $cachify_tabs as $tab_key => $tab_data ) {
1608
- printf(
1609
- '<a class="nav-tab %s" href="%s">%s</a>',
1610
- $tab_key === $current_tab ? 'nav-tab-active' : '',
 
1611
  add_query_arg(
1612
- array( 'page' => 'cachify', 'cachify_tab' => $tab_key ),
 
 
 
1613
  admin_url( 'options-general.php' )
1614
- ),
1615
- esc_html( $tab_data['name'] )
1616
- );
1617
- }
1618
- echo '</h2>';
1619
  }
 
 
1620
 
1621
  /* Include current tab */
1622
  include $cachify_tabs[ $current_tab ]['page'];
1623
 
1624
  /* Include common footer */
1625
- include 'cachify.settings_footer.php';
1626
  ?>
1627
- </div><?php
 
1628
  }
1629
 
1630
  /**
@@ -1633,7 +1638,7 @@ final class Cachify {
1633
  * @since 2.3.0
1634
  * @change 2.3.0
1635
  *
1636
- * @param array $options
1637
  * @return array
1638
  */
1639
  private static function _get_tabs( $options ) {
1
  <?php
2
+ /**
3
+ * Class for initializing the hooks and actions.
4
+ *
5
+ * @package Cachify
6
+ */
7
 
8
  /**
9
+ * Cachify
10
+ */
11
  final class Cachify {
12
 
13
  /**
71
  * @since 1.0.0
72
  * @change 2.2.2
73
  *
 
74
  * @return void
75
  */
76
  public function __construct() {
191
  'doing_dark_mode',
192
  array(
193
  __CLASS__,
194
+ 'admin_dashboard_dark_mode_styles',
195
  )
196
  );
197
 
432
 
433
  /* APC */
434
  if ( self::METHOD_APC === self::$options['use_apc'] && Cachify_APC::is_available() ) {
435
+ self::$method = new Cachify_APC();
436
 
437
  /* HDD */
438
  } elseif ( self::METHOD_HDD === self::$options['use_apc'] && Cachify_HDD::is_available() ) {
439
+ self::$method = new Cachify_HDD();
440
 
441
  /* MEMCACHED */
442
  } elseif ( self::METHOD_MMC === self::$options['use_apc'] && Cachify_MEMCACHED::is_available() ) {
443
+ self::$method = new Cachify_MEMCACHED();
444
 
445
  /* DB */
446
  } else {
447
+ self::$method = new Cachify_DB();
448
  }
449
  }
450
 
460
  return wp_parse_args(
461
  get_option( 'cachify' ),
462
  array(
463
+ 'only_guests' => 1,
464
+ 'compress_html' => self::MINIFY_DISABLED,
465
+ 'cache_expires' => 12,
466
+ 'without_ids' => '',
467
+ 'without_agents' => '',
468
+ 'use_apc' => self::METHOD_DB,
469
  'reset_on_post' => 1,
470
  'reset_on_comment' => 0,
471
  'sig_detail' => 0,
528
  admin_url( 'options-general.php' )
529
  ),
530
  esc_html__( 'Settings', 'cachify' )
531
+ ),
532
  )
533
  );
534
  }
624
  * @return integer Cache size in bytes.
625
  */
626
  public static function get_cache_size() {
627
+ $size = get_transient( 'cachify_cache_size' );
628
+ if ( ! $size ) {
629
  /* Read */
630
  $size = (int) call_user_func(
631
  array(
667
  /* Add menu item */
668
  $wp_admin_bar->add_menu(
669
  array(
670
+ 'id' => 'cachify',
671
  'href' => wp_nonce_url( add_query_arg( '_cachify', 'flush' ), '_cachify__flush_nonce' ), // esc_url in /wp-includes/class-wp-admin-bar.php#L438.
672
  'parent' => 'top-secondary',
673
+ 'title' => '<span class="ab-icon dashicons"></span>' .
674
  '<span class="ab-label">' .
675
  __(
676
  'Flush site cache',
701
  }
702
 
703
  /* Check nonce */
704
+ if ( empty( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), '_cachify__flush_nonce' ) ) {
705
  return;
706
  }
707
 
855
  * @since 2.1.7 Make the function public
856
  * @since 2.0.3
857
  *
 
858
  * @return void
859
  */
860
  public static function register_publish_hooks() {
916
  return;
917
  }
918
 
 
 
 
 
 
 
 
 
 
 
919
  /* Remove cache OR flush */
920
  if ( 1 !== self::$options['reset_on_post'] ) {
921
  self::remove_page_cache_by_post_id( $post_id );
933
  * @param integer $post_id Post ID.
934
  */
935
  public static function remove_page_cache_by_post_id( $post_id ) {
936
+ $post_id = (int) $post_id;
937
+ if ( ! $post_id ) {
938
  return;
939
  }
940
 
941
+ self::remove_page_cache_by_url( get_permalink( $post_id ) );
 
 
 
942
  }
943
 
944
  /**
950
  * @param string $url Page URL.
951
  */
952
  public static function remove_page_cache_by_url( $url ) {
953
+ $url = (string) $url;
954
+ if ( ! $url ) {
955
  return;
956
  }
957
 
985
  * @return bool Show details in signature.
986
  */
987
  private static function _signature_details() {
988
+ return 1 === self::$options['sig_detail'];
989
  }
990
 
991
  /**
1000
  private static function _cache_hash( $url = '' ) {
1001
  $prefix = is_ssl() ? 'https-' : '';
1002
  $url_parts = wp_parse_url( $url );
1003
+
1004
+ if ( empty( $url ) ) {
1005
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
1006
+ $hash_key = $prefix . wp_unslash( $_SERVER['HTTP_HOST'] ) . wp_unslash( $_SERVER['REQUEST_URI'] );
1007
+ } else {
1008
+ $hash_key = $prefix . $url_parts['host'] . $url_parts['path'];
1009
+ }
1010
+
1011
+ return md5( $hash_key ) . '.cachify';
1012
  }
1013
 
1014
  /**
1033
  * @return boolean TRUE if index
1034
  */
1035
  private static function _is_index() {
1036
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
1037
+ return basename( wp_unslash( $_SERVER['SCRIPT_NAME'] ) ) === 'index.php';
1038
  }
1039
 
1040
  /**
1083
  * Register all hooks to flush the total cache
1084
  *
1085
  * @since 2.4.0
 
 
 
1086
  */
1087
  public static function register_flush_cache_hooks() {
 
1088
  /* Define all default flush cache hooks */
1089
  $flush_cache_hooks = array(
1090
  'cachify_flush_cache' => 10,
1097
  'edit_terms' => 10,
1098
  'user_register' => 10,
1099
  'edit_user_profile_update' => 10,
1100
+ 'delete_user' => 10,
1101
  );
1102
 
1103
  $flush_cache_hooks = apply_filters( 'cachify_flush_cache_hooks', $flush_cache_hooks );
1133
  $options = self::$options;
1134
 
1135
  /* Request vars */
1136
+ if ( ! empty( $_POST ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1137
+ return true;
1138
+ }
1139
+ if ( ! empty( $_GET ) && get_option( 'permalink_structure' ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1140
  return true;
1141
  }
1142
 
1182
  if ( $options['without_agents'] && isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
1183
  $user_agent_strings = self::_preg_split( $options['without_agents'] );
1184
  foreach ( $user_agent_strings as $user_agent_string ) {
1185
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1186
+ if ( strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), $user_agent_string ) !== false ) {
1187
  return true;
1188
  }
1189
  }
1400
  array(),
1401
  $plugin_data['Version']
1402
  );
1403
+ break;
1404
 
1405
  case 'settings_page_cachify':
1406
  wp_enqueue_style(
1409
  array(),
1410
  $plugin_data['Version']
1411
  );
1412
+ break;
1413
 
1414
  default:
1415
+ break;
1416
  }
1417
 
1418
  }
1464
  * @since 2.0.0
1465
  * @change 2.1.3
1466
  *
 
1467
  * @return array Array of actually available methods.
1468
  */
1469
  private static function _method_select() {
1552
  public static function validate_options( $data ) {
1553
  /* Empty data? */
1554
  if ( empty( $data ) ) {
1555
+ return array();
1556
  }
1557
 
1558
  /* Flush cache */
1570
 
1571
  /* Return */
1572
  return array(
1573
+ 'only_guests' => (int) ( ! empty( $data['only_guests'] ) ),
1574
  'compress_html' => (int) $data['compress_html'],
1575
  'cache_expires' => (int) ( isset( $data['cache_expires'] ) ? $data['cache_expires'] : self::$options['cache_expires'] ),
1576
  'without_ids' => (string) isset( $data['without_ids'] ) ? sanitize_text_field( $data['without_ids'] ) : '',
1577
  'without_agents' => (string) isset( $data['without_agents'] ) ? sanitize_text_field( $data['without_agents'] ) : '',
1578
  'use_apc' => (int) $data['use_apc'],
1579
  'reset_on_post' => (int) ( ! empty( $data['reset_on_post'] ) ),
1580
+ 'reset_on_comment' => (int) ( ! empty( $data['reset_on_comment'] ) ),
1581
+ 'sig_detail' => (int) ( ! empty( $data['sig_detail'] ) ),
1582
  );
1583
  }
1584
 
1591
  public static function options_page() {
1592
  $options = self::_get_options();
1593
  $cachify_tabs = self::_get_tabs( $options );
1594
+ $current_tab = isset( $_GET['cachify_tab'] ) && isset( $cachify_tabs[ $_GET['cachify_tab'] ] )
1595
+ ? sanitize_text_field( wp_unslash( $_GET['cachify_tab'] ) )
1596
+ : 'settings';
1597
+ ?>
1598
 
1599
  <div class="wrap" id="cachify_settings">
1600
  <h1>Cachify</h1>
1601
 
1602
  <?php
1603
+ // Add a navbar if necessary.
1604
+ if ( count( $cachify_tabs ) > 1 ) {
1605
+ echo '<h2 class="nav-tab-wrapper">';
1606
+ foreach ( $cachify_tabs as $tab_key => $tab_data ) {
1607
+ printf(
1608
+ '<a class="nav-tab %s" href="%s">%s</a>',
1609
+ esc_attr( $tab_key === $current_tab ? 'nav-tab-active' : '' ),
1610
+ esc_url(
1611
  add_query_arg(
1612
+ array(
1613
+ 'page' => 'cachify',
1614
+ 'cachify_tab' => $tab_key,
1615
+ ),
1616
  admin_url( 'options-general.php' )
1617
+ )
1618
+ ),
1619
+ esc_html( $tab_data['name'] )
1620
+ );
 
1621
  }
1622
+ echo '</h2>';
1623
+ }
1624
 
1625
  /* Include current tab */
1626
  include $cachify_tabs[ $current_tab ]['page'];
1627
 
1628
  /* Include common footer */
1629
+ include 'cachify.settings-footer.php';
1630
  ?>
1631
+ </div>
1632
+ <?php
1633
  }
1634
 
1635
  /**
1638
  * @since 2.3.0
1639
  * @change 2.3.0
1640
  *
1641
+ * @param array $options the options.
1642
  * @return array
1643
  */
1644
  private static function _get_tabs( $options ) {
inc/setup/cachify.apc.htaccess.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
  /* Quit */
3
  defined( 'ABSPATH' ) || exit;
4
 
@@ -24,8 +30,14 @@ $ending = '/cachify/apc/proxy.php
24
  </table>
25
 
26
  <div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
27
- <pre style="white-space: pre-wrap"><?php echo sprintf( '%s%s%s',
28
- $beginning,
29
- WP_PLUGIN_DIR,
30
- $ending ); ?></pre>
 
 
 
 
 
 
31
  </div>
1
  <?php
2
+ /**
3
+ * Setup for APC on Apache server.
4
+ *
5
+ * @package Cachify
6
+ */
7
+
8
  /* Quit */
9
  defined( 'ABSPATH' ) || exit;
10
 
30
  </table>
31
 
32
  <div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
33
+ <pre style="white-space: pre-wrap">
34
+ <?php
35
+ echo sprintf(
36
+ '%s%s%s',
37
+ esc_html( $beginning ),
38
+ esc_html( WP_PLUGIN_DIR ),
39
+ esc_html( $ending )
40
+ );
41
+ ?>
42
+ </pre>
43
  </div>
inc/setup/cachify.apc.nginx.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
  /* Quit */
3
  defined( 'ABSPATH' ) || exit;
4
 
@@ -32,10 +38,16 @@ $ending = '/cachify/apc/proxy.php</strong>;
32
  </table>
33
 
34
  <div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
35
- <pre style="white-space: pre-wrap"><?php echo sprintf( '%s%s%s',
36
- $beginning,
37
- WP_PLUGIN_DIR,
38
- $ending ); ?></pre>
 
 
 
 
 
 
39
  </div>
40
 
41
  <small>(<?php esc_html_e( 'You might need to adjust the non-highlighted lines to your needs.', 'cachify' ); ?>)</small>
1
  <?php
2
+ /**
3
+ * Setup for APC on nginx server.
4
+ *
5
+ * @package Cachify
6
+ */
7
+
8
  /* Quit */
9
  defined( 'ABSPATH' ) || exit;
10
 
38
  </table>
39
 
40
  <div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
41
+ <pre style="white-space: pre-wrap">
42
+ <?php
43
+ echo sprintf(
44
+ '%s%s%s',
45
+ esc_html( $beginning ),
46
+ esc_html( WP_PLUGIN_DIR ),
47
+ esc_html( $ending )
48
+ );
49
+ ?>
50
+ </pre>
51
  </div>
52
 
53
  <small>(<?php esc_html_e( 'You might need to adjust the non-highlighted lines to your needs.', 'cachify' ); ?>)</small>
inc/setup/cachify.hdd.htaccess.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
  /* Quit */
3
  defined( 'ABSPATH' ) || exit;
4
 
@@ -77,10 +83,16 @@ $ending = '/cache/cachify/%{ENV:CACHIFY_HOST}%{ENV:CACHIFY_DIR}index.html%{ENV:C
77
  </table>
78
 
79
  <div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
80
- <pre style="white-space: pre-wrap"><?php echo sprintf( '%s%s%s%s%s',
81
- $beginning,
82
- WP_CONTENT_DIR,
83
- $middle,
84
- wp_make_link_relative( content_url() ),
85
- $ending ); ?></pre>
 
 
 
 
 
 
86
  </div>
1
  <?php
2
+ /**
3
+ * Setup for HDD on Apache server.
4
+ *
5
+ * @package Cachify
6
+ */
7
+
8
  /* Quit */
9
  defined( 'ABSPATH' ) || exit;
10
 
83
  </table>
84
 
85
  <div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
86
+ <pre style="white-space: pre-wrap">
87
+ <?php
88
+ echo sprintf(
89
+ '%s%s%s%s%s',
90
+ esc_html( $beginning ),
91
+ esc_html( WP_CONTENT_DIR ),
92
+ esc_html( $middle ),
93
+ esc_html( wp_make_link_relative( content_url() ) ),
94
+ esc_html( $ending )
95
+ );
96
+ ?>
97
+ </pre>
98
  </div>
inc/setup/cachify.hdd.nginx.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
  /* Quit */
3
  defined( 'ABSPATH' ) || exit;
4
  ?>
@@ -22,11 +28,14 @@ defined( 'ABSPATH' ) || exit;
22
  <td>
23
  <ul style="list-style-type:circle">
24
  <li>
25
- <?php echo sprintf(
26
- esc_html__( 'For domains with FQDN, the variable %s must be used instead of %s.', 'cachify' ),
 
 
27
  '<code>${http_host}</code>',
28
  '<code>${host}</code>'
29
- ); ?>
 
30
  </li>
31
  </ul>
32
  </td>
@@ -43,16 +52,16 @@ charset utf-8;
43
  ## INDEX LOCATION
44
  location / {
45
  if ( $query_string ) {
46
- return 405;
47
  }
48
  if ( $request_method = POST ) {
49
- return 405;
50
  }
51
  if ( $request_uri ~ /wp-admin/ ) {
52
- return 405;
53
  }
54
  if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
55
- return 405;
56
  }
57
 
58
  error_page 405 = @nocache;
@@ -71,4 +80,4 @@ location ~ /wp-content/cache {
71
  }
72
  </pre></div>
73
 
74
- <small>(<?php esc_html_e( 'You might need to adjust the location directives to your needs.', 'cachify' ); ?>)</small>
1
  <?php
2
+ /**
3
+ * Setup for HDD on nginx server.
4
+ *
5
+ * @package Cachify
6
+ */
7
+
8
  /* Quit */
9
  defined( 'ABSPATH' ) || exit;
10
  ?>
28
  <td>
29
  <ul style="list-style-type:circle">
30
  <li>
31
+ <?php
32
+ echo sprintf(
33
+ /* translators: variable names*/
34
+ esc_html__( 'For domains with FQDN, the variable %1$s must be used instead of %2$s.', 'cachify' ),
35
  '<code>${http_host}</code>',
36
  '<code>${host}</code>'
37
+ );
38
+ ?>
39
  </li>
40
  </ul>
41
  </td>
52
  ## INDEX LOCATION
53
  location / {
54
  if ( $query_string ) {
55
+ return 405;
56
  }
57
  if ( $request_method = POST ) {
58
+ return 405;
59
  }
60
  if ( $request_uri ~ /wp-admin/ ) {
61
+ return 405;
62
  }
63
  if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
64
+ return 405;
65
  }
66
 
67
  error_page 405 = @nocache;
80
  }
81
  </pre></div>
82
 
83
+ <small>(<?php esc_html_e( 'You might need to adjust the location directives to your needs.', 'cachify' ); ?>)</small>
inc/setup/cachify.memcached.nginx.php CHANGED
@@ -1,4 +1,10 @@
1
  <?php
 
 
 
 
 
 
2
  /* Quit */
3
  defined( 'ABSPATH' ) || exit;
4
  ?>
@@ -22,18 +28,24 @@ defined( 'ABSPATH' ) || exit;
22
  <td>
23
  <ul style="list-style-type:circle">
24
  <li>
25
- <?php echo sprintf(
26
- esc_html__( 'For domains with FQDN, the variable %s must be used instead of %s.', 'cachify' ),
 
 
27
  '<code>${http_host}</code>',
28
  '<code>${host}</code>'
29
- ); ?>
 
30
  </li>
31
  <li>
32
- <?php echo sprintf(
 
 
33
  esc_html__( 'If you have errors please try to change %1$s to %2$s This forces IPv4 because some servers that allow IPv4 and IPv6 are configured to bind memcached to IPv4 only.', 'cachify' ),
34
  '<code>memcached_pass localhost:11211;</code>',
35
  '<code>memcached_pass 127.0.0.1:11211;</code>'
36
- ); ?>
 
37
  </li>
38
  </ul>
39
  </td>
@@ -52,16 +64,16 @@ location / {
52
  error_page 404 405 = @nocache;
53
 
54
  if ( $query_string ) {
55
- return 405;
56
  }
57
  if ( $request_method = POST ) {
58
- return 405;
59
  }
60
  if ( $request_uri ~ "/wp-" ) {
61
- return 405;
62
  }
63
  if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
64
- return 405;
65
  }
66
 
67
  default_type text/html;
1
  <?php
2
+ /**
3
+ * Setup for Memcached.
4
+ *
5
+ * @package Cachify
6
+ */
7
+
8
  /* Quit */
9
  defined( 'ABSPATH' ) || exit;
10
  ?>
28
  <td>
29
  <ul style="list-style-type:circle">
30
  <li>
31
+ <?php
32
+ echo sprintf(
33
+ /* translators: variable names*/
34
+ esc_html__( 'For domains with FQDN, the variable %1$s must be used instead of %2$s.', 'cachify' ),
35
  '<code>${http_host}</code>',
36
  '<code>${host}</code>'
37
+ );
38
+ ?>
39
  </li>
40
  <li>
41
+ <?php
42
+ echo sprintf(
43
+ /* translators: code */
44
  esc_html__( 'If you have errors please try to change %1$s to %2$s This forces IPv4 because some servers that allow IPv4 and IPv6 are configured to bind memcached to IPv4 only.', 'cachify' ),
45
  '<code>memcached_pass localhost:11211;</code>',
46
  '<code>memcached_pass 127.0.0.1:11211;</code>'
47
+ );
48
+ ?>
49
  </li>
50
  </ul>
51
  </td>
64
  error_page 404 405 = @nocache;
65
 
66
  if ( $query_string ) {
67
+ return 405;
68
  }
69
  if ( $request_method = POST ) {
70
+ return 405;
71
  }
72
  if ( $request_uri ~ "/wp-" ) {
73
+ return 405;
74
  }
75
  if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
76
+ return 405;
77
  }
78
 
79
  default_type text/html;
output.log ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Running php-build composer
2
+ WARNING! Your password will be stored unencrypted in /home/runner/.docker/config.json.
3
+ Configure a credential helper to remove this warning. See
4
+ https://docs.docker.com/engine/reference/commandline/login/#credentials-store
5
+
6
+ Login Succeeded
7
+ Pulling docker.pkg.github.com/pluginkollektiv/cachify/php-actions_composer_cachify:php-latest-build2
8
+ WARNING: ⚠️ Failed to pull manifest by the resolved digest. This registry does not
9
+ appear to conform to the distribution registry specification; falling back to
10
+ pull by tag. This fallback is DEPRECATED, and will be removed in a future
11
+ release. Please contact admins of https://docker.pkg.github.com. ⚠️
12
+
13
+ php-latest-build2: Pulling from pluginkollektiv/cachify/php-actions_composer_cachify
14
+ ba3557a56b15: Pulling fs layer
15
+ 743181516422: Pulling fs layer
16
+ 6c307b60e377: Pulling fs layer
17
+ e2d5b4330891: Pulling fs layer
18
+ 0baf29266ab7: Pulling fs layer
19
+ dfa723e4109b: Pulling fs layer
20
+ 7e9fbc8e5c1a: Pulling fs layer
21
+ 510d7725cdd5: Pulling fs layer
22
+ 5fdc925b16f5: Pulling fs layer
23
+ ced63f1f690d: Pulling fs layer
24
+ dfa723e4109b: Waiting
25
+ 7e9fbc8e5c1a: Waiting
26
+ 510d7725cdd5: Waiting
27
+ 5fdc925b16f5: Waiting
28
+ ced63f1f690d: Waiting
29
+ e2d5b4330891: Waiting
30
+ 0baf29266ab7: Waiting
31
+ 6c307b60e377: Verifying Checksum
32
+ 6c307b60e377: Download complete
33
+ 743181516422: Verifying Checksum
34
+ 743181516422: Download complete
35
+ e2d5b4330891: Verifying Checksum
36
+ e2d5b4330891: Download complete
37
+ dfa723e4109b: Verifying Checksum
38
+ dfa723e4109b: Download complete
39
+ ba3557a56b15: Verifying Checksum
40
+ ba3557a56b15: Pull complete
41
+ 743181516422: Pull complete
42
+ 0baf29266ab7: Verifying Checksum
43
+ 0baf29266ab7: Download complete
44
+ 510d7725cdd5: Verifying Checksum
45
+ 510d7725cdd5: Download complete
46
+ 6c307b60e377: Pull complete
47
+ e2d5b4330891: Pull complete
48
+ 0baf29266ab7: Pull complete
49
+ 5fdc925b16f5: Verifying Checksum
50
+ 5fdc925b16f5: Download complete
51
+ dfa723e4109b: Pull complete
52
+ 7e9fbc8e5c1a: Verifying Checksum
53
+ 7e9fbc8e5c1a: Download complete
54
+ ced63f1f690d: Verifying Checksum
55
+ ced63f1f690d: Download complete
56
+ 7e9fbc8e5c1a: Pull complete
57
+ 510d7725cdd5: Pull complete
58
+ 5fdc925b16f5: Pull complete
59
+ ced63f1f690d: Pull complete
60
+ Digest: sha256:874ddb5e4ab22a569dc8333257cac4b025fb6f68bc943cebcd438f105a984417
61
+ Status: Downloaded newer image for docker.pkg.github.com/pluginkollektiv/cachify/php-actions_composer_cachify:php-latest-build2
62
+ docker.pkg.github.com/pluginkollektiv/cachify/php-actions_composer_cachify:php-latest-build2
63
+ Docker tag: docker.pkg.github.com/pluginkollektiv/cachify/php-actions_composer_cachify:php-latest-build2
64
+ No private keys supplied
65
+ Command: composer install --no-progress --no-interaction
readme.txt CHANGED
@@ -2,9 +2,10 @@
2
  * Contributors: pluginkollektiv
3
  * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW
4
  * Tags: acceleration, apc, cache, caching, compress, database cache, db-cache, disk cache, disk caching, google, hdd, html compression, memcached, minify, minimize, optimize, page cache, performance, quick cache, speed
5
- * Stable tag: 2.3.0
6
  * Requires at least: 4.4
7
- * Tested up to: 5.4
 
 
8
  * License: GPLv2 or later
9
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -27,22 +28,22 @@ Smart, efficient cache solution for WordPress. Use DB, HDD, APC or Memcached for
27
  * Extendability via hooks/filters.
28
 
29
  ### Support ###
30
- * Community support via the [support forums on wordpress.org](https://wordpress.org/support/plugin/cachify)
31
  * We don’t handle support via e-mail, Twitter, GitHub issues etc.
32
 
33
  ### Contribute ###
34
  * Active development of this plugin is handled [on GitHub](https://github.com/pluginkollektiv/cachify).
35
  * Pull requests for documented bugs are highly appreciated.
36
- * If you think you’ve found a bug (e.g. you’re experiencing unexpected behavior), please post at the [support forums](https://wordpress.org/support/plugin/cachify) first.
37
- * If you want to help us translate this plugin you can do so [on WordPress Translate](https://translate.wordpress.org/projects/wp-plugins/cachify).
38
 
39
  ### Credits ###
40
- * Author: [Sergej Müller](https://sergejmueller.github.io/)
41
- * Maintainers: [pluginkollektiv](http://pluginkollektiv.org)
42
 
43
 
44
  ## Installation ##
45
- * If you don’t know how to install a plugin for WordPress, [here’s how](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
46
 
47
  ### Requirements ###
48
  * PHP 5.2.4 or greater
@@ -60,7 +61,7 @@ The cache expiration can not be considered due to technical reasons. If the cach
60
  This error message may occur after commissioning the caching plug-in. The hint appears because there are no cache files on the HDD for output. This is probably due to the fact that Cachify could not store files in the cache folder. Please check the write-permissions for the cache folder (found in the WordPress directory *wp-content*) and set them if necessary.
61
 
62
  ### My Website looks in some parts broken after activating Cachify! ###
63
- Please make sure there is no issue that caused by the Cache minify feature. Just deactivate it or use HTML only. If the issue still exist please feel free to report it at the [support forums](https://wordpress.org/support/plugin/cachify). With this feature any unnecessary characters such as breaks and HTML comments are removed from the source code.
64
 
65
  ### Cachify HDD: Character encoding does not work correctly ###
66
  If you use Cachify to store the cache on HDD there is no PHP to run. In the case of misconfigured servers, this can lead to incorrect display of the special characters on web pages. The error can be corrected by an extension of the system file .htaccess: *AddDefaultCharset UTF-8*
@@ -91,16 +92,38 @@ Compared to APC (Alternative PHP Cache), PHP OPCache is not able to contain cont
91
  * Error pages
92
 
93
  ### The cache folder is indexed by search engines! ###
94
- To ensure that Google and other search engines do not index the static contents of the cache folder (otherwise there could be duplicate content), the robots.txt file which is located in the main directory of a WordPress installation should be expanded by disabling the path to the cache file (disallow ). This issue should only happen if you use a *static robots.txt* or you changed the *wp-content* location. And so might look a robots.txt:
95
 
96
  `User-agent: *
97
- Disallow: /wp-content/cache/cachify/
98
  Allow: /`
99
 
100
  A complete documentation is available in the [GitHub repository Wiki](https://github.com/pluginkollektiv/cachify/wiki).
101
 
102
  ## Changelog ##
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  ### 2.2.4 ###
105
  * Fixes caching for mixed HTTPS and HTTP setups
106
  * Fixes an issue with the icon styling in the admin toolbar
@@ -128,6 +151,9 @@ For the complete changelog, check out our [GitHub repository](https://github.com
128
 
129
  ## Upgrade Notice ##
130
 
 
 
 
131
  ### 2.3.0 ###
132
  To improve Cachify and make use of new core functions, we decided to drop support for WordPress 4.3 and older. Please make sure your WordPress is always up to date.
133
 
2
  * Contributors: pluginkollektiv
3
  * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW
4
  * Tags: acceleration, apc, cache, caching, compress, database cache, db-cache, disk cache, disk caching, google, hdd, html compression, memcached, minify, minimize, optimize, page cache, performance, quick cache, speed
 
5
  * Requires at least: 4.4
6
+ * Tested up to: 5.7
7
+ * Requires PHP: 5.2.4
8
+ * Stable tag: 2.3.1
9
  * License: GPLv2 or later
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
28
  * Extendability via hooks/filters.
29
 
30
  ### Support ###
31
+ * Community support via the [support forums on wordpress.org](https://wordpress.org/support/plugin/cachify/)
32
  * We don’t handle support via e-mail, Twitter, GitHub issues etc.
33
 
34
  ### Contribute ###
35
  * Active development of this plugin is handled [on GitHub](https://github.com/pluginkollektiv/cachify).
36
  * Pull requests for documented bugs are highly appreciated.
37
+ * If you think you’ve found a bug (e.g. you’re experiencing unexpected behavior), please post at the [support forums](https://wordpress.org/support/plugin/cachify/) first.
38
+ * If you want to help us translate this plugin you can do so [on WordPress Translate](https://translate.wordpress.org/projects/wp-plugins/cachify/).
39
 
40
  ### Credits ###
41
+ * Author: [Sergej Müller](https://sergejmueller.github.io)
42
+ * Maintainers: [pluginkollektiv](https://pluginkollektiv.org)
43
 
44
 
45
  ## Installation ##
46
+ * If you don’t know how to install a plugin for WordPress, [here’s how](https://wordpress.org/support/article/managing-plugins/#installing-plugins).
47
 
48
  ### Requirements ###
49
  * PHP 5.2.4 or greater
61
  This error message may occur after commissioning the caching plug-in. The hint appears because there are no cache files on the HDD for output. This is probably due to the fact that Cachify could not store files in the cache folder. Please check the write-permissions for the cache folder (found in the WordPress directory *wp-content*) and set them if necessary.
62
 
63
  ### My Website looks in some parts broken after activating Cachify! ###
64
+ Please make sure there is no issue that caused by the Cache minify feature. Just deactivate it or use HTML only. If the issue still exist please feel free to report it at the [support forums](https://wordpress.org/support/plugin/cachify/). With this feature any unnecessary characters such as breaks and HTML comments are removed from the source code.
65
 
66
  ### Cachify HDD: Character encoding does not work correctly ###
67
  If you use Cachify to store the cache on HDD there is no PHP to run. In the case of misconfigured servers, this can lead to incorrect display of the special characters on web pages. The error can be corrected by an extension of the system file .htaccess: *AddDefaultCharset UTF-8*
92
  * Error pages
93
 
94
  ### The cache folder is indexed by search engines! ###
95
+ To ensure that Google and other search engines do not index the static contents of the cache folder (otherwise there could be duplicate content), the robots.txt file which is located in the main directory of a WordPress installation should be expanded by disabling the path to the cache file (disallow). This issue should only happen if you use a *static robots.txt* or you changed the *wp-content* location. And so might look a robots.txt:
96
 
97
  `User-agent: *
98
+ Disallow: */cache/cachify/
99
  Allow: /`
100
 
101
  A complete documentation is available in the [GitHub repository Wiki](https://github.com/pluginkollektiv/cachify/wiki).
102
 
103
  ## Changelog ##
104
 
105
+ ### 2.3.1 ###
106
+ * Fix: clean up unused parameter evaluation after publishing a post to prevent PHP notice (#187) (#188)
107
+ * Fix: correct minor spelling mistakes (#193, props timse201)
108
+ * Fix: update support links (#194, props timse201)
109
+
110
+ ### 2.3.0 ###
111
+ * New: WP-CLI integration (#165, props derweili)
112
+ * New: `cachify_flush_cache_hooks` filter added to modify all hooks that flush the cache
113
+ * New: Flush cache when a user is created / updated / deleted
114
+ * New: Flush cache when a term is created / updated / deleted (#169, props derweili)
115
+ * New: Cache behavior after post modification is now configurable in plugin settings (#176)
116
+ * Enhance: Cache exceptions/User-Agents translation (#52, props timse201)
117
+ * Enhance: Readme FAQ (#51, props timse201)
118
+ * Enhance: sizeable exclusion boxes + placeholder (#53, props timse201)
119
+ * Enhance: FAQ and Support links (#55, props timse201)
120
+ * Enhance: Add text caption to "flush cache" button
121
+ * Enhance: Icon font converted to SVG (#64)
122
+ * Enhance: Improved HDD cache invalidation for hierarchical post types (#71, props Syberspace)
123
+ * Enhance: Unified and shortened HTML signature across all caching methods (#108) (#109)
124
+ * Security: Tabnabbing prevention (#55, props timse201)
125
+ * Maintenance: Tested up to WordPress 5.4
126
+
127
  ### 2.2.4 ###
128
  * Fixes caching for mixed HTTPS and HTTP setups
129
  * Fixes an issue with the icon styling in the admin toolbar
151
 
152
  ## Upgrade Notice ##
153
 
154
+ ### 2.3.1 ###
155
+ This is a minor bug fix release that prevents PHP warnings introduced in 2.3.0. It is recommended for all users.
156
+
157
  ### 2.3.0 ###
158
  To improve Cachify and make use of new core functions, we decided to drop support for WordPress 4.3 and older. Please make sure your WordPress is always up to date.
159