Version Description
- Load plugin translations
- Hide global admin notices from non-admin users
- Prevent direct file access to
redis-cache.php
andadmin-page.php
- Colorize "Disable Object Cache" button
- Call
Predis\Client->connect()
to avoid potential uncaughtPredis\Connection\ConnectionException
Download this release
Release Info
Developer | tillkruess |
Plugin | Redis Object Cache |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.0.1
- includes/admin-page.css +31 -0
- includes/admin-page.php +3 -1
- includes/object-cache.php +1 -1
- languages/redis-cache.pot +132 -0
- readme.txt +24 -4
- redis-cache.php +32 -11
includes/admin-page.css
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
.wrap .button.delete {
|
3 |
+
background: #d54e21;
|
4 |
+
border-color: #a83d1a;
|
5 |
+
color: white;
|
6 |
+
-webkit-box-shadow: inset 0 1px 0 #e68260, 0 1px 0 rgba(0, 0, 0, 0.15);
|
7 |
+
box-shadow: inset 0 1px 0 #e68260, 0 1px 0 rgba(0, 0, 0, 0.15);
|
8 |
+
}
|
9 |
+
|
10 |
+
.wrap .button.delete:hover,
|
11 |
+
.wrap .button.delete:focus {
|
12 |
+
background: #be461d;
|
13 |
+
border-color: #923517;
|
14 |
+
color: white;
|
15 |
+
box-shadow: inset 0 1px 0 #e3704a;
|
16 |
+
}
|
17 |
+
|
18 |
+
.wrap .button.delete:focus {
|
19 |
+
box-shadow: inset 0 1px 0 #e3704a,
|
20 |
+
0 0 0 1px #d54e21,
|
21 |
+
0 0 2px 1px rgba( 30, 140, 190, .8 );
|
22 |
+
}
|
23 |
+
|
24 |
+
.wrap .button.delete:active {
|
25 |
+
background: #a83d1a;
|
26 |
+
border-color: #923517;
|
27 |
+
color: white;
|
28 |
+
box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ),
|
29 |
+
0 0 0 1px #d54e21,
|
30 |
+
0 0 2px 1px rgba( 30, 140, 190, .8 );
|
31 |
+
}
|
includes/admin-page.php
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
|
|
|
|
|
2 |
<div class="wrap">
|
3 |
|
4 |
<h2><?php _e( 'Redis Object Cache', 'redis-cache' ); ?></h2>
|
@@ -33,7 +35,7 @@
|
|
33 |
<?php if ( ! $this->object_cache_dropin_exists() ) : ?>
|
34 |
<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>
|
35 |
<?php elseif ( $this->validate_object_cache_dropin() ) : ?>
|
36 |
-
<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"><?php _e( 'Disable Object Cache', 'redis-cache' ); ?></a>
|
37 |
<?php endif; ?>
|
38 |
</p>
|
39 |
|
1 |
|
2 |
+
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
3 |
+
|
4 |
<div class="wrap">
|
5 |
|
6 |
<h2><?php _e( 'Redis Object Cache', 'redis-cache' ); ?></h2>
|
35 |
<?php if ( ! $this->object_cache_dropin_exists() ) : ?>
|
36 |
<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>
|
37 |
<?php elseif ( $this->validate_object_cache_dropin() ) : ?>
|
38 |
+
<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>
|
39 |
<?php endif; ?>
|
40 |
</p>
|
41 |
|
includes/object-cache.php
CHANGED
@@ -11,7 +11,6 @@ License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
|
11 |
|
12 |
Based on Eric Mann's and Erick Hitter's Redis Object Cache:
|
13 |
https://github.com/ericmann/Redis-Object-Cache
|
14 |
-
|
15 |
*/
|
16 |
|
17 |
/**
|
@@ -359,6 +358,7 @@ class WP_Object_Cache {
|
|
359 |
Predis\Autoloader::register();
|
360 |
|
361 |
$this->redis = new Predis\Client( $redis );
|
|
|
362 |
$this->redis_connected = true;
|
363 |
|
364 |
} catch ( Exception $exception ) {
|
11 |
|
12 |
Based on Eric Mann's and Erick Hitter's Redis Object Cache:
|
13 |
https://github.com/ericmann/Redis-Object-Cache
|
|
|
14 |
*/
|
15 |
|
16 |
/**
|
358 |
Predis\Autoloader::register();
|
359 |
|
360 |
$this->redis = new Predis\Client( $redis );
|
361 |
+
$this->redis->connect();
|
362 |
$this->redis_connected = true;
|
363 |
|
364 |
} catch ( Exception $exception ) {
|
languages/redis-cache.pot
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2014 Redis Object Cache
|
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.0.1\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/redis-cache\n"
|
7 |
+
"POT-Creation-Date: 2014-11-19 12:27:42+00:00\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\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.0.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 |
+
|
21 |
+
#: includes/admin-page.php:13
|
22 |
+
msgid "Object Cache Status"
|
23 |
+
msgstr ""
|
24 |
+
|
25 |
+
#: includes/admin-page.php:18
|
26 |
+
msgid "Connection Parameters"
|
27 |
+
msgstr ""
|
28 |
+
|
29 |
+
#: includes/admin-page.php:21
|
30 |
+
msgid "Protocol:"
|
31 |
+
msgstr ""
|
32 |
+
|
33 |
+
#: includes/admin-page.php:22
|
34 |
+
msgid "Host:"
|
35 |
+
msgstr ""
|
36 |
+
|
37 |
+
#: includes/admin-page.php:23
|
38 |
+
msgid "Port:"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: includes/admin-page.php:24
|
42 |
+
msgid "Database:"
|
43 |
+
msgstr ""
|
44 |
+
|
45 |
+
#: includes/admin-page.php:26
|
46 |
+
msgid "Password:"
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#: includes/admin-page.php:36
|
50 |
+
msgid "Enable Object Cache"
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: includes/admin-page.php:38
|
54 |
+
msgid "Disable Object Cache"
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: redis-cache.php:43
|
58 |
+
msgid "Redis"
|
59 |
+
msgstr ""
|
60 |
+
|
61 |
+
#: redis-cache.php:132
|
62 |
+
msgid "No drop-in found"
|
63 |
+
msgstr ""
|
64 |
+
|
65 |
+
#: redis-cache.php:136
|
66 |
+
msgid "Connected"
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: redis-cache.php:136
|
70 |
+
msgid "Not connected"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: redis-cache.php:139
|
74 |
+
msgid "Unknown"
|
75 |
+
msgstr ""
|
76 |
+
|
77 |
+
#: redis-cache.php:161
|
78 |
+
msgid ""
|
79 |
+
"The Redis object cache drop-in is outdated. <a href=\"%s\">Update it now</a>."
|
80 |
+
msgstr ""
|
81 |
+
|
82 |
+
#: redis-cache.php:167
|
83 |
+
msgid ""
|
84 |
+
"Another object cache drop-in is already active. To use Redis, <a href=\"%s"
|
85 |
+
"\">please replace it now</a>."
|
86 |
+
msgstr ""
|
87 |
+
|
88 |
+
#: redis-cache.php:183
|
89 |
+
msgid "This plugin requires PHP 5.4 or greater."
|
90 |
+
msgstr ""
|
91 |
+
|
92 |
+
#: redis-cache.php:192
|
93 |
+
msgid "Object Cache enabled."
|
94 |
+
msgstr ""
|
95 |
+
|
96 |
+
#: redis-cache.php:195
|
97 |
+
msgid "Object Cache could not be enabled."
|
98 |
+
msgstr ""
|
99 |
+
|
100 |
+
#: redis-cache.php:198
|
101 |
+
msgid "Object Cache disabled."
|
102 |
+
msgstr ""
|
103 |
+
|
104 |
+
#: redis-cache.php:201
|
105 |
+
msgid "Object Cache could not be disabled."
|
106 |
+
msgstr ""
|
107 |
+
|
108 |
+
#: redis-cache.php:204
|
109 |
+
msgid "Drop-in updated."
|
110 |
+
msgstr ""
|
111 |
+
|
112 |
+
#: redis-cache.php:207
|
113 |
+
msgid "Drop-in could not be updated."
|
114 |
+
msgstr ""
|
115 |
+
|
116 |
+
#. Plugin URI of the plugin/theme
|
117 |
+
msgid "http://wordpress.org/plugins/redis-cache/"
|
118 |
+
msgstr ""
|
119 |
+
|
120 |
+
#. Description of the plugin/theme
|
121 |
+
msgid ""
|
122 |
+
"A Redis backend for the WordPress Object Cache based on the Predis client "
|
123 |
+
"library for PHP."
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#. Author of the plugin/theme
|
127 |
+
msgid "Till Krüss"
|
128 |
+
msgstr ""
|
129 |
+
|
130 |
+
#. Author URI of the plugin/theme
|
131 |
+
msgid "http://till.kruss.me/"
|
132 |
+
msgstr ""
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Redis Object Cache ===
|
2 |
Contributors: tillkruess
|
3 |
Donate link: http://till.kruss.me/donations/
|
4 |
-
Tags: redis, predis, cache, object cache, wp object cache, server, performance, speed, load
|
5 |
Requires at least: 3.3
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.0
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -66,8 +66,28 @@ The `WP_CACHE_KEY_SALT` constant is provided to add a prefix to all cache keys.
|
|
66 |
Users with setups where multiple installs share a common `wp-config.php` or `$table_prefix` can use this constant to guarantee uniqueness for the keys generated by this object cache.
|
67 |
|
68 |
|
|
|
|
|
|
|
|
|
|
|
69 |
== Changelog ==
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
= 1.0 =
|
72 |
|
73 |
-
* Initial release
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
=== Redis Object Cache ===
|
2 |
Contributors: tillkruess
|
3 |
Donate link: http://till.kruss.me/donations/
|
4 |
+
Tags: redis, predis, caching, cache, object cache, wp object cache, server, performance, optimize, speed, load
|
5 |
Requires at least: 3.3
|
6 |
+
Tested up to: 4.1
|
7 |
+
Stable tag: 1.0.1
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
66 |
Users with setups where multiple installs share a common `wp-config.php` or `$table_prefix` can use this constant to guarantee uniqueness for the keys generated by this object cache.
|
67 |
|
68 |
|
69 |
+
== Screenshots ==
|
70 |
+
|
71 |
+
1. Plugin settings page.
|
72 |
+
|
73 |
+
|
74 |
== Changelog ==
|
75 |
|
76 |
+
= 1.0.1 =
|
77 |
+
|
78 |
+
* Load plugin translations
|
79 |
+
* Hide global admin notices from non-admin users
|
80 |
+
* Prevent direct file access to `redis-cache.php` and `admin-page.php`
|
81 |
+
* Colorize "Disable Object Cache" button
|
82 |
+
* Call `Predis\Client->connect()` to avoid potential uncaught `Predis\Connection\ConnectionException`
|
83 |
+
|
84 |
= 1.0 =
|
85 |
|
86 |
+
* Initial release
|
87 |
+
|
88 |
+
|
89 |
+
== Upgrade Notice ==
|
90 |
+
|
91 |
+
= 1.0.1 =
|
92 |
+
|
93 |
+
This update includes several security, user interface and general code improvements.
|
redis-cache.php
CHANGED
@@ -3,25 +3,35 @@
|
|
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.0
|
|
|
|
|
7 |
Author: Till Krüss
|
8 |
Author URI: http://till.kruss.me/
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
*/
|
12 |
|
|
|
|
|
13 |
class RedisObjectCache {
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
17 |
|
18 |
public function __construct() {
|
19 |
|
|
|
|
|
|
|
|
|
20 |
add_action( 'admin_notices', array( $this, 'show_admin_notices' ) );
|
21 |
add_action( 'admin_menu', array( $this, 'add_admin_menu_page' ) );
|
22 |
-
add_action( '
|
23 |
-
add_action( 'load-
|
24 |
-
|
25 |
|
26 |
}
|
27 |
|
@@ -31,7 +41,7 @@ class RedisObjectCache {
|
|
31 |
add_management_page(
|
32 |
__( 'Redis Object Cache', 'redis-cache'),
|
33 |
__( 'Redis', 'redis-cache'),
|
34 |
-
|
35 |
'redis-cache',
|
36 |
array( $this, 'show_admin_page' )
|
37 |
);
|
@@ -67,7 +77,7 @@ class RedisObjectCache {
|
|
67 |
|
68 |
}
|
69 |
|
70 |
-
public function
|
71 |
|
72 |
// add settings link to plugin actions
|
73 |
return array_merge(
|
@@ -77,13 +87,21 @@ class RedisObjectCache {
|
|
77 |
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
public function object_cache_dropin_exists() {
|
81 |
return file_exists( WP_CONTENT_DIR . '/object-cache.php' );
|
82 |
}
|
83 |
|
84 |
public function validate_object_cache_dropin() {
|
85 |
-
|
86 |
-
return $this->object_cache_dropin_exists() && method_exists( $wp_object_cache, 'redis_status' );
|
87 |
}
|
88 |
|
89 |
public function get_redis_scheme() {
|
@@ -124,7 +142,10 @@ class RedisObjectCache {
|
|
124 |
|
125 |
public function show_admin_notices() {
|
126 |
|
127 |
-
|
|
|
|
|
|
|
128 |
|
129 |
if ( $this->object_cache_dropin_exists() ) {
|
130 |
|
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.0.1
|
7 |
+
Text Domain: redis-cache
|
8 |
+
Domain Path: /languages
|
9 |
Author: Till Krüss
|
10 |
Author URI: http://till.kruss.me/
|
11 |
License: GPLv3
|
12 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
13 |
*/
|
14 |
|
15 |
+
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', '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 |
|
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 |
);
|
77 |
|
78 |
}
|
79 |
|
80 |
+
public function add_plugin_actions_links( $links ) {
|
81 |
|
82 |
// add settings link to plugin actions
|
83 |
return array_merge(
|
87 |
|
88 |
}
|
89 |
|
90 |
+
public function enqueue_admin_styles( $hook_suffix ) {
|
91 |
+
|
92 |
+
if ( $hook_suffix === $this->screen ) {
|
93 |
+
$plugin = get_plugin_data( __FILE__ );
|
94 |
+
wp_enqueue_style( 'redis-cache', plugin_dir_url( __FILE__ ) . 'includes/admin-page.css', null, $plugin[ 'Version' ] );
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
public function object_cache_dropin_exists() {
|
100 |
return file_exists( WP_CONTENT_DIR . '/object-cache.php' );
|
101 |
}
|
102 |
|
103 |
public function validate_object_cache_dropin() {
|
104 |
+
return $this->object_cache_dropin_exists() && method_exists( $GLOBALS[ 'wp_object_cache' ], 'redis_status' );
|
|
|
105 |
}
|
106 |
|
107 |
public function get_redis_scheme() {
|
142 |
|
143 |
public function show_admin_notices() {
|
144 |
|
145 |
+
// only show admin notices to users with the right capability
|
146 |
+
if ( ! current_user_can( $this->capability ) ) {
|
147 |
+
return;
|
148 |
+
}
|
149 |
|
150 |
if ( $this->object_cache_dropin_exists() ) {
|
151 |
|