Redis Object Cache - Version 1.2

Version Description

  • Added Multisite support
    • Moved admin menu under Settings menu
    • Fixed PHP notice in get_redis_client_name()
Download this release

Release Info

Developer tillkruess
Plugin Icon 128x128 Redis Object Cache
Version 1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.2

includes/admin-page.php CHANGED
@@ -76,14 +76,14 @@
76
  <p class="submit">
77
 
78
  <?php if ( strcasecmp( 'connected', $this->get_redis_status() ) === 0 ) : ?>
79
- <a href="<?php echo wp_nonce_url( admin_url( add_query_arg( 'action', 'flush-cache', $this->admin_page ) ), 'flush-cache' ); ?>" class="button button-primary button-large"><?php _e( 'Flush Cache', 'redis-cache' ); ?></a>
80
  &nbsp;
81
  <?php endif; ?>
82
 
83
  <?php if ( ! $this->object_cache_dropin_exists() ) : ?>
84
- <a href="<?php echo wp_nonce_url( admin_url( add_query_arg( 'action', 'enable-cache', $this->admin_page ) ), 'enable-cache' ); ?>" class="button button-primary button-large"><?php _e( 'Enable Object Cache', 'redis-cache' ); ?></a>
85
  <?php elseif ( $this->validate_object_cache_dropin() ) : ?>
86
- <a href="<?php echo wp_nonce_url( admin_url( add_query_arg( 'action', 'disable-cache', $this->admin_page ) ), 'disable-cache' ); ?>" class="button button-secondary button-large delete"><?php _e( 'Disable Object Cache', 'redis-cache' ); ?></a>
87
  <?php endif; ?>
88
 
89
  </p>
76
  <p class="submit">
77
 
78
  <?php if ( strcasecmp( 'connected', $this->get_redis_status() ) === 0 ) : ?>
79
+ <a href="<?php echo wp_nonce_url( network_admin_url( add_query_arg( 'action', 'flush-cache', $this->page ) ), 'flush-cache' ); ?>" class="button button-primary button-large"><?php _e( 'Flush Cache', 'redis-cache' ); ?></a>
80
  &nbsp;
81
  <?php endif; ?>
82
 
83
  <?php if ( ! $this->object_cache_dropin_exists() ) : ?>
84
+ <a href="<?php echo wp_nonce_url( network_admin_url( add_query_arg( 'action', 'enable-cache', $this->page ) ), 'enable-cache' ); ?>" class="button button-primary button-large"><?php _e( 'Enable Object Cache', 'redis-cache' ); ?></a>
85
  <?php elseif ( $this->validate_object_cache_dropin() ) : ?>
86
+ <a href="<?php echo wp_nonce_url( network_admin_url( add_query_arg( 'action', 'disable-cache', $this->page ) ), 'disable-cache' ); ?>" class="button button-secondary button-large delete"><?php _e( 'Disable Object Cache', 'redis-cache' ); ?></a>
87
  <?php endif; ?>
88
 
89
  </p>
languages/redis-cache.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the Redis Object Cache package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Redis Object Cache 1.1\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/redis-cache\n"
7
- "POT-Creation-Date: 2015-03-21 08:52:49+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -12,9 +12,9 @@ msgstr ""
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
- #. #-#-#-#-# plugin.pot (Redis Object Cache 1.1) #-#-#-#-#
16
  #. Plugin Name of the plugin/theme
17
- #: includes/admin-page.php:6 redis-cache.php:42
18
  msgid "Redis Object Cache"
19
  msgstr ""
20
 
@@ -74,70 +74,70 @@ msgstr ""
74
  msgid "Disable Object Cache"
75
  msgstr ""
76
 
77
- #: redis-cache.php:43
78
  msgid "Redis"
79
  msgstr ""
80
 
81
- #: redis-cache.php:149
82
  msgid "Not installed"
83
  msgstr ""
84
 
85
- #: redis-cache.php:153
86
  msgid "Connected"
87
  msgstr ""
88
 
89
- #: redis-cache.php:153
90
  msgid "Not connected"
91
  msgstr ""
92
 
93
- #: redis-cache.php:156
94
  msgid "Unknown"
95
  msgstr ""
96
 
97
- #: redis-cache.php:178
98
  msgid ""
99
  "The Redis object cache drop-in is outdated. <a href=\"%s\">Update it now</a>."
100
  msgstr ""
101
 
102
- #: redis-cache.php:184
103
  msgid ""
104
  "Another object cache drop-in is already active. To use Redis, <a href=\"%s"
105
  "\">please replace it now</a>."
106
  msgstr ""
107
 
108
- #: redis-cache.php:200
109
  msgid "This plugin requires PHP 5.4 or greater."
110
  msgstr ""
111
 
112
- #: redis-cache.php:209
113
  msgid "Object Cache enabled."
114
  msgstr ""
115
 
116
- #: redis-cache.php:212
117
  msgid "Object Cache could not be enabled."
118
  msgstr ""
119
 
120
- #: redis-cache.php:215
121
  msgid "Object Cache disabled."
122
  msgstr ""
123
 
124
- #: redis-cache.php:218
125
  msgid "Object Cache could not be disabled."
126
  msgstr ""
127
 
128
- #: redis-cache.php:221
129
  msgid "Object Cache flushed."
130
  msgstr ""
131
 
132
- #: redis-cache.php:224
133
  msgid "Object Cache could not be flushed."
134
  msgstr ""
135
 
136
- #: redis-cache.php:227
137
  msgid "Drop-in updated."
138
  msgstr ""
139
 
140
- #: redis-cache.php:230
141
  msgid "Drop-in could not be updated."
142
  msgstr ""
143
 
2
  # This file is distributed under the same license as the Redis Object Cache package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Redis Object Cache 1.2\n"
6
+ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/redis-cache\n"
7
+ "POT-Creation-Date: 2015-06-16 09:42:28+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
+ #. #-#-#-#-# plugin.pot (Redis Object Cache 1.2) #-#-#-#-#
16
  #. Plugin Name of the plugin/theme
17
+ #: includes/admin-page.php:6 redis-cache.php:48
18
  msgid "Redis Object Cache"
19
  msgstr ""
20
 
74
  msgid "Disable Object Cache"
75
  msgstr ""
76
 
77
+ #: redis-cache.php:49
78
  msgid "Redis"
79
  msgstr ""
80
 
81
+ #: redis-cache.php:155
82
  msgid "Not installed"
83
  msgstr ""
84
 
85
+ #: redis-cache.php:159
86
  msgid "Connected"
87
  msgstr ""
88
 
89
+ #: redis-cache.php:159
90
  msgid "Not connected"
91
  msgstr ""
92
 
93
+ #: redis-cache.php:162
94
  msgid "Unknown"
95
  msgstr ""
96
 
97
+ #: redis-cache.php:184
98
  msgid ""
99
  "The Redis object cache drop-in is outdated. <a href=\"%s\">Update it now</a>."
100
  msgstr ""
101
 
102
+ #: redis-cache.php:190
103
  msgid ""
104
  "Another object cache drop-in is already active. To use Redis, <a href=\"%s"
105
  "\">please replace it now</a>."
106
  msgstr ""
107
 
108
+ #: redis-cache.php:206
109
  msgid "This plugin requires PHP 5.4 or greater."
110
  msgstr ""
111
 
112
+ #: redis-cache.php:215
113
  msgid "Object Cache enabled."
114
  msgstr ""
115
 
116
+ #: redis-cache.php:218
117
  msgid "Object Cache could not be enabled."
118
  msgstr ""
119
 
120
+ #: redis-cache.php:221
121
  msgid "Object Cache disabled."
122
  msgstr ""
123
 
124
+ #: redis-cache.php:224
125
  msgid "Object Cache could not be disabled."
126
  msgstr ""
127
 
128
+ #: redis-cache.php:227
129
  msgid "Object Cache flushed."
130
  msgstr ""
131
 
132
+ #: redis-cache.php:230
133
  msgid "Object Cache could not be flushed."
134
  msgstr ""
135
 
136
+ #: redis-cache.php:233
137
  msgid "Drop-in updated."
138
  msgstr ""
139
 
140
+ #: redis-cache.php:236
141
  msgid "Drop-in could not be updated."
142
  msgstr ""
143
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: tillkruess
3
  Donate link: http://till.kruss.me/donations/
4
  Tags: redis, predis, hhvm, pecl, caching, cache, object cache, wp object cache, server, performance, optimize, speed, load
5
  Requires at least: 3.3
6
- Tested up to: 4.2
7
- Stable tag: 1.1.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -83,6 +83,12 @@ Users with setups where multiple installs share a common `wp-config.php` or `$ta
83
 
84
  == Changelog ==
85
 
 
 
 
 
 
 
86
  = 1.1.1 =
87
 
88
  * Call `select()` and optionally `auth()` if HHVM extension is used
3
  Donate link: http://till.kruss.me/donations/
4
  Tags: redis, predis, hhvm, pecl, caching, cache, object cache, wp object cache, server, performance, optimize, speed, load
5
  Requires at least: 3.3
6
+ Tested up to: 4.3
7
+ Stable tag: 1.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
83
 
84
  == Changelog ==
85
 
86
+ = 1.2 =
87
+
88
+ * Added Multisite support
89
+ * Moved admin menu under _Settings_ menu
90
+ * Fixed PHP notice in `get_redis_client_name()`
91
+
92
  = 1.1.1 =
93
 
94
  * Call `select()` and optionally `auth()` if HHVM extension is used
redis-cache.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Redis Object Cache
4
  Plugin URI: http://wordpress.org/plugins/redis-cache/
5
  Description: A Redis backend for the WordPress Object Cache based on the Predis client library for PHP.
6
- Version: 1.1.1
7
  Text Domain: redis-cache
8
  Domain Path: /languages
9
  Author: Till Krüss
@@ -16,32 +16,38 @@ if ( ! defined( 'ABSPATH' ) ) exit;
16
 
17
  class RedisObjectCache {
18
 
19
- private $screen = 'tools_page_redis-cache';
20
- private $capability = 'manage_options';
21
- private $admin_page = 'tools.php?page=redis-cache';
22
- private $admin_actions = array( 'enable-cache', 'disable-cache', 'flush-cache', 'update-dropin' );
23
 
24
  public function __construct() {
25
 
26
  load_plugin_textdomain( 'redis-cache', false, 'redis-cache/languages' );
27
 
28
- add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_plugin_actions_links' ) );
29
 
 
30
  add_action( 'admin_notices', array( $this, 'show_admin_notices' ) );
31
- add_action( 'admin_menu', array( $this, 'add_admin_menu_page' ) );
32
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
33
  add_action( 'load-' . $this->screen, array( $this, 'do_admin_actions' ) );
34
  add_action( 'load-' . $this->screen, array( $this, 'add_admin_page_notices' ) );
35
 
 
 
 
 
 
 
36
  }
37
 
38
  public function add_admin_menu_page() {
39
 
40
- // add "Tools" sub-page
41
- add_management_page(
 
42
  __( 'Redis Object Cache', 'redis-cache'),
43
  __( 'Redis', 'redis-cache'),
44
- $this->capability,
45
  'redis-cache',
46
  array( $this, 'show_admin_page' )
47
  );
@@ -55,12 +61,12 @@ class RedisObjectCache {
55
 
56
  $action = $_GET[ 'action' ];
57
 
58
- foreach ( $this->admin_actions as $name ) {
59
 
60
  // verify nonce
61
  if ( $action === $name && wp_verify_nonce( $_GET[ '_wpnonce' ], $action ) ) {
62
 
63
- $url = wp_nonce_url( admin_url( add_query_arg( 'action', $action, $this->admin_page ) ), $action );
64
 
65
  if ( $this->initialize_filesystem( $url ) === false ) {
66
  return; // request filesystem credentials
@@ -81,7 +87,7 @@ class RedisObjectCache {
81
 
82
  // add settings link to plugin actions
83
  return array_merge(
84
- array( '<a href="' . admin_url( $this->admin_page ) . '">Settings</a>' ),
85
  $links
86
  );
87
 
@@ -106,7 +112,7 @@ class RedisObjectCache {
106
 
107
  public function get_redis_client_name() {
108
  global $wp_object_cache;
109
- return $wp_object_cache->redis_client;
110
  }
111
 
112
  public function get_redis_scheme() {
@@ -160,13 +166,13 @@ class RedisObjectCache {
160
  public function show_admin_notices() {
161
 
162
  // only show admin notices to users with the right capability
163
- if ( ! current_user_can( $this->capability ) ) {
164
  return;
165
  }
166
 
167
  if ( $this->object_cache_dropin_exists() ) {
168
 
169
- $url = wp_nonce_url( admin_url( add_query_arg( 'action', 'update-dropin', $this->admin_page ) ), 'update-dropin' );
170
 
171
  if ( $this->validate_object_cache_dropin() ) {
172
 
@@ -247,15 +253,15 @@ class RedisObjectCache {
247
  $action = $_GET[ 'action' ];
248
 
249
  // verify nonce
250
- foreach ( $this->admin_actions as $name ) {
251
  if ( $action === $name && ! wp_verify_nonce( $_GET[ '_wpnonce' ], $action ) ) {
252
  return;
253
  }
254
  }
255
 
256
- if ( in_array( $action, $this->admin_actions ) ) {
257
 
258
- $url = wp_nonce_url( admin_url( add_query_arg( 'action', $action, $this->admin_page ) ), $action );
259
 
260
  if ( $action === 'flush-cache' ) {
261
  $message = wp_cache_flush() ? 'cache-flushed' : 'flush-cache-failed';
@@ -287,7 +293,7 @@ class RedisObjectCache {
287
 
288
  // redirect if status `$message` was set
289
  if ( isset( $message ) ) {
290
- wp_safe_redirect( admin_url( add_query_arg( 'message', $message, $this->admin_page ) ) );
291
  exit;
292
  }
293
 
3
  Plugin Name: Redis Object Cache
4
  Plugin URI: http://wordpress.org/plugins/redis-cache/
5
  Description: A Redis backend for the WordPress Object Cache based on the Predis client library for PHP.
6
+ Version: 1.2
7
  Text Domain: redis-cache
8
  Domain Path: /languages
9
  Author: Till Krüss
16
 
17
  class RedisObjectCache {
18
 
19
+ private $page;
20
+ private $screen = 'settings_page_redis-cache';
21
+ private $actions = array( 'enable-cache', 'disable-cache', 'flush-cache', 'update-dropin' );
 
22
 
23
  public function __construct() {
24
 
25
  load_plugin_textdomain( 'redis-cache', false, 'redis-cache/languages' );
26
 
27
+ $this->page = is_multisite() ? 'settings.php?page=redis-cache' : 'options-general.php?page=redis-cache';
28
 
29
+ add_action( is_multisite() ? 'network_admin_menu' : 'admin_menu', array( $this, 'add_admin_menu_page' ) );
30
  add_action( 'admin_notices', array( $this, 'show_admin_notices' ) );
 
31
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
32
  add_action( 'load-' . $this->screen, array( $this, 'do_admin_actions' ) );
33
  add_action( 'load-' . $this->screen, array( $this, 'add_admin_page_notices' ) );
34
 
35
+ add_filter( sprintf(
36
+ '%splugin_action_links_%s',
37
+ is_multisite() ? 'network_admin_' : '',
38
+ plugin_basename( __FILE__ )
39
+ ), array( $this, 'add_plugin_actions_links' ) );
40
+
41
  }
42
 
43
  public function add_admin_menu_page() {
44
 
45
+ // add sub-page to "Settings"
46
+ add_submenu_page(
47
+ is_multisite() ? 'settings.php' : 'options-general.php',
48
  __( 'Redis Object Cache', 'redis-cache'),
49
  __( 'Redis', 'redis-cache'),
50
+ is_multisite() ? 'manage_network_options' : 'manage_options',
51
  'redis-cache',
52
  array( $this, 'show_admin_page' )
53
  );
61
 
62
  $action = $_GET[ 'action' ];
63
 
64
+ foreach ( $this->actions as $name ) {
65
 
66
  // verify nonce
67
  if ( $action === $name && wp_verify_nonce( $_GET[ '_wpnonce' ], $action ) ) {
68
 
69
+ $url = wp_nonce_url( network_admin_url( add_query_arg( 'action', $action, $this->page ) ), $action );
70
 
71
  if ( $this->initialize_filesystem( $url ) === false ) {
72
  return; // request filesystem credentials
87
 
88
  // add settings link to plugin actions
89
  return array_merge(
90
+ array( sprintf( '<a href="%s">Settings</a>', network_admin_url( $this->page ) ) ),
91
  $links
92
  );
93
 
112
 
113
  public function get_redis_client_name() {
114
  global $wp_object_cache;
115
+ return isset( $wp_object_cache->redis_client ) ? $wp_object_cache->redis_client : null;
116
  }
117
 
118
  public function get_redis_scheme() {
166
  public function show_admin_notices() {
167
 
168
  // only show admin notices to users with the right capability
169
+ if ( ! current_user_can( is_multisite() ? 'manage_network_options' : 'manage_options' ) ) {
170
  return;
171
  }
172
 
173
  if ( $this->object_cache_dropin_exists() ) {
174
 
175
+ $url = wp_nonce_url( network_admin_url( add_query_arg( 'action', 'update-dropin', $this->page ) ), 'update-dropin' );
176
 
177
  if ( $this->validate_object_cache_dropin() ) {
178
 
253
  $action = $_GET[ 'action' ];
254
 
255
  // verify nonce
256
+ foreach ( $this->actions as $name ) {
257
  if ( $action === $name && ! wp_verify_nonce( $_GET[ '_wpnonce' ], $action ) ) {
258
  return;
259
  }
260
  }
261
 
262
+ if ( in_array( $action, $this->actions ) ) {
263
 
264
+ $url = wp_nonce_url( network_admin_url( add_query_arg( 'action', $action, $this->page ) ), $action );
265
 
266
  if ( $action === 'flush-cache' ) {
267
  $message = wp_cache_flush() ? 'cache-flushed' : 'flush-cache-failed';
293
 
294
  // redirect if status `$message` was set
295
  if ( isset( $message ) ) {
296
+ wp_safe_redirect( network_admin_url( add_query_arg( 'message', $message, $this->page ) ) );
297
  exit;
298
  }
299