release of version 0.5

git-svn-id: http://plugins.svn.wordpress.org/wp-ffpc/tags/0.5@677016 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
cadeyrn 2013-03-06 19:03:30 +00:00
parent 35fca7f41a
commit 0e39dd8162
5 changed files with 90 additions and 41 deletions

View file

@ -216,6 +216,7 @@ function wp_ffpc_callback($buffer) {
/* check if caching is disabled for page type */
$nocache_key = 'nocache_'. $wp_ffpc_meta['type'];
/* don't cache if prevented by rule, also, log it */
if ( $wp_ffpc_config[$nocache_key] == 1 ) {
wp_ffpc_log ( "not caching, prevented by settings for no-cache: " . $nocache_key );
return $buffer;

View file

@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: cache, APC, memcached, full page cache
Requires at least: 3.0
Tested up to: 3.5.1
Stable tag: 0.4.3
Stable tag: 0.5
Fast Full Page Cache, backend can be memcached or APC
@ -44,8 +44,8 @@ Parts are based on [Hyper Cache](http://wordpress.org/extend/plugins/hyper-cache
1. Upload contents of `wp-ffpc.zip` to the `/wp-content/plugins/` directory
2. Enable WordPress cache by adding `define('WP_CACHE',true);` in wp-config.php
3. Activate the plugin through the `Plugins` menu in WordPress (please use network wide activation if used in a WordPress Network)
4. Fine tune the settings in `Settings` -> `wp-ffpc` menu in WordPress.
For WordPress Network, please visit the Network Admin panel, the options will be available under Network Admin Settings page, in WP-FFPC menu entry.
4. Check the settings in `Settings` -> `wp-ffpc` menu in WordPress. For WordPress Network, please visit the Network Admin panel, the options will be available under Network Admin Settings page, in WP-FFPC menu entry.
5. Save the settings. THIS STEP IS MANDATORY: without saving the settings, there will be no activated caching!
== Frequently Asked Questions ==
@ -60,18 +60,21 @@ You have to remove the default yum package, named `php-pecl-memcache` and instal
== Changelog ==
= 0.5 =
2013.03.04
2013.03.06
WARNING, MAJOR CHANGES!
* long-running %3C really fixed ( version 0.4.3 was dead end ) by the help of Mark Costlow <cheeks@swcp.com>
* UI cleanup, introducing tabbed interface
* default values bug ( causing %3C bug ) really fixed by the help of Mark Costlow <cheeks@swcp.com>
* UI cleanup, new tabbed layout
* WP-FFPC options moved from global menu to under Settings in both Site and Network Admin interfaces
* added 'persistent' checkbox for memcached connections
* added support for multiple memcached servers, feature request from ivan.buttinoni ( ivanbuttinoni @ WordPress.org forum )
* case-sensitive string checks replaced with case-insensitives, contribution of Mark Costlow <cheeks@swcp.com>
* refactored settings saving mechanism
* additional syslog informations
* additional comments on the code
* lots of minor fixes
* donation link on the top
= 0.4.3 =
2013.03.03

View file

@ -13,7 +13,7 @@ global $wp_nmc_redirect;
if (!defined('WP_FFPC_PARAM'))
define ( 'WP_FFPC_PARAM' , 'wp-ffpc' );
/* log level */
define ('WP_FFPC_LOG_LEVEL' , LOG_INFO);
define ('WP_FFPC_LOG_LEVEL' , LOG_INFO );
/* define log ending message */
define ('WP_FFPC_LOG_TYPE_MSG' , '; cache type: '. $wp_ffpc_config['cache_type'] );
@ -103,7 +103,8 @@ function wp_ffpc_init( $wp_ffpc_config ) {
default:
return false;
}
return $wp_ffpc_backend_status;
return ( empty ( $wp_ffpc_backend_status ) ? false : $wp_ffpc_backend_status );
}
/**

View file

@ -9,7 +9,9 @@ Author URI: http://petermolnar.eu/
License: GPL2
*/
/* Copyright 2010-2011 Peter Molnar (email : hello@petermolnar.eu )
/* Copyright 2010-2013 Peter Molnar (email : hello@petermolnar.eu )
Many thanks to contributor Mark Costlow <cheeks@swcp.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
@ -63,7 +65,9 @@ define ( 'WP_FFPC_ACACHE_COMMON_FILE' , WP_FFPC_DIR. '/wp-ffpc-common.php' );
define ( 'WP_FFPC_CONFIG_VAR' , '$wp_ffpc_config' );
define ( 'WP_FFPC_SERVER_LIST_SEPARATOR' , ',' );
define ( 'WP_FFPC_SERVER_SEPARATOR', ':' );
define ( 'WP_FFPC_DONATION_LINK', 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC' );
/* get the common functions */
include_once (WP_FFPC_DIR .'/wp-ffpc-common.php');
if (!class_exists('WPFFPC')) {
@ -85,6 +89,7 @@ if (!class_exists('WPFFPC')) {
/* status, 0 = nothing happened*/
var $status = 0;
/* stores information if plugin is network active or not */
var $network = false;
/**
@ -101,7 +106,7 @@ if (!class_exists('WPFFPC')) {
$alive = wp_ffpc_init( $this->options );
/* don't register hooks if backend is dead */
if ($alive)
if (!$alive)
{
/* init inactivation hooks */
add_action('switch_theme', array( $this , 'invalidate'), 0);
@ -120,7 +125,7 @@ if (!class_exists('WPFFPC')) {
if( is_admin() )
{
wp_enqueue_script ( "jquery-ui-tabs" );
wp_enqueue_style( WP_FFPC_PARAM . '.admin.css' , WP_FFPC_URL . '/css/'. WP_FFPC_PARAM .'.admin.css', false, '0.1');
wp_enqueue_style( WP_FFPC_PARAM . '.admin.css' , WP_FFPC_URL . '/' . WP_FFPC_PARAM .'.admin.css', false, '0.1');
}
/* on activation */
@ -132,7 +137,6 @@ if (!class_exists('WPFFPC')) {
/* on uninstall */
register_uninstall_hook(__FILE__ , array( $this , 'uninstall') );
/* init plugin in the admin section */
/* if multisite, admin page will be on network admin section */
if ( $this->network )
@ -147,6 +151,10 @@ if (!class_exists('WPFFPC')) {
*
*/
function activate ( ) {
/* register options for first time */
add_site_option( WP_FFPC_PARAM, $this->options , '' , 'yes');
$this->save_settings( true );
}
@ -155,9 +163,6 @@ if (!class_exists('WPFFPC')) {
*
*/
function admin_init () {
/* register options */
add_site_option( WP_FFPC_PARAM, $this->options , '' , 'no');
/* save parameter updates, if there are any */
if ( isset($_POST[WP_FFPC_PARAM . '-save']) )
{
@ -166,8 +171,8 @@ if (!class_exists('WPFFPC')) {
header("Location: admin.php?page=" . WP_FFPC_OPTIONS_PAGE . "&saved=true");
}
/* we use settings menu, no need for highest level menu */
add_submenu_page('settings.php', 'Edit WP-FFPC options', __('WP-FFPC', WP_FFPC_PARAM ), 10, WP_FFPC_OPTIONS_PAGE , array ( $this , 'admin_panel' ) );
//add_menu_page('Edit WP-FFPC options', __('WP-FFPC', WP_FFPC_PARAM ), 10, WP_FFPC_OPTIONS_PAGE , array ( $this , 'admin_panel' ) );
}
/**
@ -203,27 +208,36 @@ if (!class_exists('WPFFPC')) {
<div class="wrap">
<h4>This plugin helped your business? <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC">Buy me a coffee for having it :)</a></h4>
<h4>This plugin helped your business? <a href="<?php echo WP_FFPC_DONATION_LINK; ?>">Buy me a coffee for having it, please :)</a></h4>
<?php if ( !WP_CACHE ) : ?>
<div class="updated settings-error"><p><strong><?php _e("WARNING: WP_CACHE is disabled, plugin will not work that way. Please add define( 'WP_CACHE', true ); into the beginning of wp-config.php", WP_FFPC_PARAM); ?></strong></p></div>
<div class="error"><p><strong><?php _e("WARNING: WP_CACHE is disabled, plugin will not work that way. Please add define( 'WP_CACHE', true ); into the beginning of wp-config.php", WP_FFPC_PARAM); ?></strong></p></div>
<?php endif; ?>
<?php if ( !class_exists('Memcache') && !class_exists('Memcached') ) : ?>
<div class="updated settings-error"><p><strong><?php _e('No PHP memcached extension was found. To use memcached, you need PHP Memcache or PHP Memcached extension.', WP_FFPC_PARAM); ?></strong></p></div>
<?php if ( ! file_exists ( WP_FFPC_ACACHE_MAIN_FILE ) ): ?>
<div class="error"><p><strong><?php _e("WARNING: advanced cache file is yet to be generated, please save settings!", WP_FFPC_PARAM); ?></strong></p></div>
<?php endif; ?>
<?php if ( $this->options['cache_type'] == 'memcached' && !class_exists('Memcached') ) : ?>
<div class="error"><p><strong><?php _e('ERROR: Memcached cache backend activated but no PHP memcached extension was found.', WP_FFPC_PARAM); ?></strong></p></div>
<?php endif; ?>
<?php if ( $this->options['cache_type'] == 'memcache' && !class_exists('Memcache') ) : ?>
<div class="error"><p><strong><?php _e('ERROR: Memcache cache backend activated but no PHP memcache extension was found.', WP_FFPC_PARAM); ?></strong></p></div>
<?php endif; ?>
<?php
/* get the current runtime configuration for memcache in PHP */
$memcached_settings = ini_get_all( 'memcache' );
$memcached_protocol = strtolower($memcached_settings['memcache.protocol']['local_value']);
?>
<?php if ( $this->options['cache_type'] == 'memcached' && $memcached_protocol == 'binary' ) : ?>
<div class="updated settings-error"><p><strong><?php _e('WARNING: Memcache extension is configured to use binary mode. This is very buggy and the plugin will most probably not work. Please consider to change either to ascii mode or to Mecached extension.', WP_FFPC_PARAM); ?></strong></p></div>
<?php if ( $this->options['cache_type'] == 'memcache' && $memcached_protocol == 'binary' ) : ?>
<div class="error"><p><strong><?php _e('WARNING: Memcache extension is configured to use binary mode. This is very buggy and the plugin will most probably not work. Please consider to change either to ascii mode or to Mecached extension.', WP_FFPC_PARAM); ?></strong></p></div>
<?php endif; ?>
<?php if ( $this->options['cache_type'] == 'memcached' || $this->options['cache_type'] == 'memcache' ) : ?>
<div class="updated settings-error">
<div class="updated">
<p><strong>
<?php
_e ( 'Driver: ' , WP_FFPC_PARAM);
@ -234,6 +248,7 @@ if (!class_exists('WPFFPC')) {
<?php
_e( '<strong>Backend status:</strong><br />', WP_FFPC_PARAM );
$init = wp_ffpc_init( $this->options);
/* we need to go through all servers */
foreach ( $this->options['servers'] as $server_string => $server ) {
echo $server['host'] . ":" . $server['port'] ." => ";
$server_status = ( empty($init) || $init[$server_string] == 0 ) ? '<span class="error-msg">down</span>' : '<span class="ok-msg">up & running</span>' ;
@ -531,6 +546,9 @@ if (!class_exists('WPFFPC')) {
/**
* invalidate cache
*
* @param $post_id
* id of post to be removed from cache entries
*/
function invalidate ( $post_id ) {
wp_ffpc_clear ( $post_id );
@ -619,10 +637,9 @@ if (!class_exists('WPFFPC')) {
$this->defaults = $defaults;
/* maps saved options and defaults */
$this->options = get_site_option( WP_FFPC_PARAM , $defaults, false );
$this->split_hosts();
}
/**
@ -675,6 +692,13 @@ if (!class_exists('WPFFPC')) {
/**
* function to be able to store redirects
*
* @param $redirect_url
* url of required wordpress redirect
*
* @param $requested_url
* currently unused
*
*/
function redirect_canonical($redirect_url, $requested_url) {
global $wp_nmc_redirect;
@ -685,43 +709,62 @@ if (!class_exists('WPFFPC')) {
/**
* save settings function
*
* @param firstrun
* boolean: true if the function is called on plugin activation
*
*/
function save_settings ( $firstrun = false ) {
$defaults = $this->defaults;
$options = $this->defaults;
foreach ( $defaults as $key => $default )
/* only try to update defaults if it's not first run and $_POST is not empty */
if ( !$firstrun && !empty ( $_POST ) )
{
if (!empty($_POST[$key]))
foreach ( $options as $key => $default )
{
$update = $_POST[$key];
if ( strlen( $update ) !=0 && !is_numeric($update) )
$update = stripslashes($update);
}
elseif ( ( empty( $_POST[$name] ) && is_bool ( $default ) ) || is_int( $default ) )
{
$update = 0;
}
else
{
$update = $this->options[$key];
}
/* $_POST element is available */
if (!empty($_POST[$key]))
{
$update = $_POST[$key];
/* get rid of slashed */
if ( strlen( $update ) !=0 &&!is_numeric($update) )
$update = stripslashes($update);
$options[$key] = $update;
$options[$key] = $update;
}
/* empty $_POST element: when HTML form posted, empty checkboxes a 0 values will not be
part of the $_POST array, thus we need to check if this is the situation by
checking the types of the elements, since a missing value could mean update from 1 to 0
*/
elseif ( empty( $_POST[$key] ) && ( is_bool ( $default ) || is_int( $default ) ) )
{
$options[$key] = 0;
}
}
}
$this->options = $options;
/* set up server array from hosts config var */
$this->split_hosts();
/* save options */
update_site_option( WP_FFPC_PARAM , $this->options );
/* invalidate cache, this is neccessary */
$this->invalidate('system_flush');
/* if it's not for the first run, generate the config file */
if ( ! $firstrun )
$this->generate_config();
}
/**
* splits config parameter "hosts" into an array of server string, host and port
* to be used in later config
*
*/
function split_hosts ( ) {
$servers = explode( WP_FFPC_SERVER_LIST_SEPARATOR , $this->options['hosts']);
@ -750,6 +793,7 @@ if (!class_exists('WPFFPC')) {
*/
function uninstall ( ) {
delete_site_option( WP_FFPC_PARAM );
wp_ffpc_log ( "plugin uninstalled ");
}
}