Skip to content
Snippets Groups Projects
Commit 2235fc0f authored by Benjamin Adams's avatar Benjamin Adams
Browse files

Updated docs

parent 692ef430
No related branches found
No related tags found
No related merge requests found
...@@ -4,11 +4,11 @@ Cache Wordpress using Redis, the fastest way to date to cache Wordpress. ...@@ -4,11 +4,11 @@ Cache Wordpress using Redis, the fastest way to date to cache Wordpress.
### Requirements ### Requirements
------ ------
[Wordpress](http://wordpress.org) - CMS framework/blogging system * [Wordpress](http://wordpress.org) - CMS framework/blogging system
[Redis](http://redis.io/) - Key Value in memory caching * [Redis](http://redis.io/) - Key Value in memory caching
[Predis](https://github.com/nrk/predis) - PHP api for Redis * [Predis](https://github.com/nrk/predis) - PHP api for Redis
### Setup == Installation ==
------ ------
Install Redis, must have root access to your machine. On debian it's as simple as: Install Redis, must have root access to your machine. On debian it's as simple as:
```bash ```bash
...@@ -19,8 +19,10 @@ On other systems please refer to the [Redis website](http://redis.io/). ...@@ -19,8 +19,10 @@ On other systems please refer to the [Redis website](http://redis.io/).
Move the folder wp-redis-cache to the plugin directory and activate the plugin. In the admin section you can set how long you will cache the post for. By default it will cache the post for 12 hours. Move the folder wp-redis-cache to the plugin directory and activate the plugin. In the admin section you can set how long you will cache the post for. By default it will cache the post for 12 hours.
Note: This plugin is optional and is used to refresh the cache after you update a post/page Note: This plugin is optional and is used to refresh the cache after you update a post/page
Move the `index-wp-redis.php` to the root/base Wordpress directory Move the `index-wp-redis.php` to the root/base Wordpress directory.
Change the `index.php` to:
Move the `index.php` to the root/base Wordpress directory. Or manually change the `index.php` to:
```php ```php
<?php <?php
require('index-wp-redis.php'); require('index-wp-redis.php');
......
<?php <?php
$seconds_cache_redis = 60*60*12; // 12 hours by default $seconds_cache_redis = 60*60*12; // 12 hours by default, you can change in this in wp-admin options page
$ip_of_your_website = '64.90.38.145'; //You must set this to the IP of your website $ip_of_your_website = '64.90.38.145'; //You must set this to the IP of your website
$secret_string = "changeme"; /*This must be the same as in the wp-admin section if you want to manually refresh the cache $secret_string = "changeme"; /*This is if you want to manually refresh the cache
ex: http://example.com/sample-post?refresh=changeme */ ex: http://example.com/sample-post?refresh=changeme */
...@@ -24,7 +24,6 @@ $current_url = str_replace("?refresh=$secret_string", '', $current_url); //clea ...@@ -24,7 +24,6 @@ $current_url = str_replace("?refresh=$secret_string", '', $current_url); //clea
$current_url = str_replace("&refresh=$secret_string", '', $current_url); $current_url = str_replace("&refresh=$secret_string", '', $current_url);
$redis_key = md5($current_url); $redis_key = md5($current_url);
//Either manual refresh cache by adding ?refresh=secret_string after the URL or somebody posting a comment //Either manual refresh cache by adding ?refresh=secret_string after the URL or somebody posting a comment
if (isset($_GET['refresh']) || $_GET['refresh']==$secret_string || ($_SERVER['HTTP_REFERER'] == $current_url && $_SERVER['REQUEST_URI'] != '/' && $_SERVER['REMOTE_ADDR'] != $ip_of_your_website)) { if (isset($_GET['refresh']) || $_GET['refresh']==$secret_string || ($_SERVER['HTTP_REFERER'] == $current_url && $_SERVER['REQUEST_URI'] != '/' && $_SERVER['REMOTE_ADDR'] != $ip_of_your_website)) {
......
<?php
class wctest{
public function __construct(){
if(is_admin()){
add_action('admin_menu', array($this, 'add_plugin_page'));
add_action('admin_init', array($this, 'page_init'));
}
}
public function add_plugin_page(){
// This page will be under "Settings"
add_options_page('Settings Admin', 'Settings', 'manage_options', 'test-setting-admin', array($this, 'create_admin_page'));
}
public function create_admin_page(){
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>Settings</h2>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields('test_option_group');
do_settings_sections('test-setting-admin');
?>
<?php submit_button(); ?>
</form>
</div>
<?php
}
public function page_init(){
register_setting('test_option_group', 'array_key', array($this, 'check_ID'));
add_settings_section(
'setting_section_id',
'Setting',
array($this, 'print_section_info'),
'test-setting-admin'
);
add_settings_field(
'some_id',
'Some ID(Title)',
array($this, 'create_an_id_field'),
'test-setting-admin',
'setting_section_id'
);
}
public function check_ID($input){
if(is_numeric($input['some_id'])){
$mid = $input['some_id'];
if(get_option('test_some_id') === FALSE){
add_option('test_some_id', $mid);
}else{
update_option('test_some_id', $mid);
}
}else{
$mid = '';
}
return $mid;
}
public function print_section_info(){
print 'Enter your setting below:';
}
public function create_an_id_field(){
?><input type="text" id="input_whatever_unique_id_I_want" name="array_key[some_id]" value="<?=get_option('test_some_id');?>" /><?php
}
}
$wctest = new wctest();
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* /*
Plugin Name: Wp Redis Cache Plugin Name: Wp Redis Cache
Plugin URI: https://github.com/BenjaminAdams/wp-redis-cache Plugin URI: https://github.com/BenjaminAdams/wp-redis-cache
Description: Cache Wordpress with redis Description: Cache Wordpress using Redis, the fastest way to date to cache Wordpress.
Version: 1.0 Version: 1.0
Author: Benjamin Adams Author: Benjamin Adams
Author URI: http://dudelol.com Author URI: http://dudelol.com
...@@ -36,16 +36,15 @@ function edit_redis_options() { ...@@ -36,16 +36,15 @@ function edit_redis_options() {
<h2>Wp-Redis Options</h2> <h2>Wp-Redis Options</h2>
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?> <?php wp_nonce_field('update-options') ?>
<p>This plugin does not work out of the box and requires additional steps. Please follow these install instructions: <a target='_blank' href='https://github.com/BenjaminAdams/wp-redis-cache'>https://github.com/BenjaminAdams/wp-redis-cache</a></p>
<p>If you do not have Redis installed on your machine this will NOT work! </p>
<p><strong>Seconds of Caching:</strong><br /> <p><strong>Seconds of Caching:</strong><br />
How many seconds would you like to cache? *Recommended 12 hours or 43200 seconds <br /> How many seconds would you like to cache? *Recommended 12 hours or 43200 seconds <br />
<input type="text" name="wp-redis-cache-seconds" size="45" value="<?php echo get_option('wp-redis-cache-seconds'); ?>" /></p> <input type="text" name="wp-redis-cache-seconds" size="45" value="<?php echo get_option('wp-redis-cache-seconds'); ?>" /></p>
<p><strong>Secret String:</strong><br />
To refresh the cache of your post manually you will need to set a secret string so do can refresh manually like so:
<br /> http://example.com/post_name?refresh=secret_string. <br />
<br />Important! You must change this in the index-wp-redis.php file<br />
<input type="text" name="wp-redis-secret" size="45" value="<?php echo get_option('wp-redis-secret'); ?>" /></p>
<p><input type="submit" name="Submit" value="Update Options" /></p> <p><input type="submit" name="Submit" value="Update Options" /></p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment