diff --git a/README.md b/README.md index fad018c971527dce2838e9d7acead7b77e23deb1..d1457a1ad3b44d26ed2e199d3fb7580e349a2e58 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ Cache Wordpress using Redis, the fastest way to date to cache Wordpress. ### Requirements ------ -[Wordpress](http://wordpress.org) - CMS framework/blogging system -[Redis](http://redis.io/) - Key Value in memory caching -[Predis](https://github.com/nrk/predis) - PHP api for Redis +* [Wordpress](http://wordpress.org) - CMS framework/blogging system +* [Redis](http://redis.io/) - Key Value in memory caching +* [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: ```bash @@ -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. 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 -Change the `index.php` to: +Move the `index-wp-redis.php` to the root/base Wordpress directory. + +Move the `index.php` to the root/base Wordpress directory. Or manually change the `index.php` to: + ```php <?php require('index-wp-redis.php'); diff --git a/index-wp-redis.php b/index-wp-redis.php index 25d63ab55e408542b59d28248fb0f881d7acdaea..5eb527b9b70fac2103cc2f858a33dd1de2187c00 100644 --- a/index-wp-redis.php +++ b/index-wp-redis.php @@ -1,8 +1,8 @@ <?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 -$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 */ @@ -24,7 +24,6 @@ $current_url = str_replace("?refresh=$secret_string", '', $current_url); //clea $current_url = str_replace("&refresh=$secret_string", '', $current_url); $redis_key = md5($current_url); - //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)) { diff --git a/wp-redis-cache/index.php b/wp-redis-cache/index.php deleted file mode 100644 index 3dcb4e6e1e5edd812cfb324ea5fef9fd0952e16f..0000000000000000000000000000000000000000 --- a/wp-redis-cache/index.php +++ /dev/null @@ -1,74 +0,0 @@ -<?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 diff --git a/wp-redis-cache/options.php b/wp-redis-cache/options.php index 2bf57f49e2d7fceec5a02607be0a2995bf10c4e4..2a1fd8ebf92542ecdf1d39b7c11a0d172ec84d98 100644 --- a/wp-redis-cache/options.php +++ b/wp-redis-cache/options.php @@ -2,7 +2,7 @@ /* Plugin Name: 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 Author: Benjamin Adams Author URI: http://dudelol.com @@ -36,16 +36,15 @@ function edit_redis_options() { <h2>Wp-Redis Options</h2> <form method="post" action="options.php"> <?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 /> 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> - <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>