version 0.6 alpha
git-svn-id: http://plugins.svn.wordpress.org/wp-ffpc/trunk@677505 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
parent
5ca0120085
commit
e054f5870b
4 changed files with 107 additions and 57 deletions
|
@ -11,6 +11,14 @@ if ( !WP_CACHE )
|
|||
if (!isset($wp_ffpc_config))
|
||||
return false;
|
||||
|
||||
/* check if config is network active or active for this very site */
|
||||
if (!empty ( $wp_ffpc_config['network'] ) )
|
||||
$wp_ffpc_config = $wp_ffpc_config['network'];
|
||||
elseif ( !empty ( $wp_ffpc_config[ $_SERVER['HTTP_HOST' ] ] ) )
|
||||
$wp_ffpc_config = $wp_ffpc_config[ $_SERVER['HTTP_HOST' ] ];
|
||||
else
|
||||
return false;
|
||||
|
||||
/* request uri */
|
||||
$wp_ffpc_uri = $_SERVER['REQUEST_URI'];
|
||||
/* query string */
|
||||
|
|
|
@ -28,7 +28,7 @@ WP-FFPC is a full page cache plugin for WordPress. Supports memcached server or
|
|||
|
||||
(1) pingback hostname will always be generated from the accessed domain, otherwise speed would get highly compromised
|
||||
|
||||
(2) If enabled as network-wide plugin in a WordPress Network, the configuration will only be available for network admins at the network admin panel, will be system-wide and will be applied for every blog.
|
||||
(2) Plugin is capable of either Network wide or per site settings, meaning if not network-wide enabled, settings could vary from site to site, plugin could be turned off and on without interfering other sites.
|
||||
|
||||
(3) nginx compatility means that if used with PHP Memcache or PHP Memcached extension, the created memcached entries can be read and served directly from nginx.
|
||||
If used with APC, this feature is not available (no APC module for nginx).
|
||||
|
@ -56,6 +56,13 @@ You have to remove the default yum package, named `php-pecl-memcache` and instal
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 0.6 =
|
||||
*development branch*
|
||||
|
||||
* true WordPress Network support:
|
||||
* if enabled network-wide, settings will be the same for every site
|
||||
* if enabled only per site settings could vary from site to site and cache could be active or disabled on a per site basis without interfering other sites
|
||||
|
||||
= 0.5.1 =
|
||||
*2013.03.07*
|
||||
|
||||
|
|
|
@ -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_WARNING );
|
||||
/* define log ending message */
|
||||
define ('WP_FFPC_LOG_TYPE_MSG' , '; cache type: '. $wp_ffpc_config['cache_type'] );
|
||||
|
||||
|
|
131
wp-ffpc.php
131
wp-ffpc.php
|
@ -67,6 +67,10 @@ 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' );
|
||||
define ( 'WP_FFPC_FILE' , plugin_basename(__FILE__) );
|
||||
define ( 'WP_FFPC_PLUGIN' , 'wp-ffpc/wp-ffpc.php' );
|
||||
|
||||
if ( ! function_exists( 'is_plugin_active_for_network' ) )
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
|
||||
/* get the common functions */
|
||||
include_once (WP_FFPC_DIR .'/wp-ffpc-common.php');
|
||||
|
@ -81,6 +85,10 @@ if (!class_exists('WPFFPC')) {
|
|||
|
||||
/* for options array */
|
||||
var $options = array();
|
||||
/* stores options for all sites & all data */
|
||||
var $all_options = array();
|
||||
/* key for current options array */
|
||||
var $options_key = '';
|
||||
/* for default options array */
|
||||
var $defaults = array();
|
||||
/* memcached server object */
|
||||
|
@ -545,17 +553,19 @@ if (!class_exists('WPFFPC')) {
|
|||
*
|
||||
*/
|
||||
function check_for_network( ) {
|
||||
if ( is_multisite() )
|
||||
{
|
||||
$plugins = get_site_option( 'active_sitewide_plugins');
|
||||
/* see if plugins is active */
|
||||
if ( isset($plugins['wp-ffpc/wp-ffpc.php']) )
|
||||
|
||||
$this->options_key = $_SERVER['HTTP_HOST'];
|
||||
|
||||
if ( is_plugin_active_for_network ( WP_FFPC_PLUGIN ) )
|
||||
{
|
||||
/* set active for network */
|
||||
$this->network = true;
|
||||
/* replace settings link */
|
||||
$this->settingslink = str_replace( 'options-general.php' , 'settings.php' , $this->settingslink );
|
||||
/* set options key */
|
||||
$this->options_key = 'network';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -563,8 +573,10 @@ if (!class_exists('WPFFPC')) {
|
|||
*
|
||||
*/
|
||||
function deactivate ( ) {
|
||||
if (@file_exists (WP_FFPC_ACACHE_MAIN_FILE))
|
||||
@unlink (WP_FFPC_ACACHE_MAIN_FILE);
|
||||
//if (@file_exists (WP_FFPC_ACACHE_MAIN_FILE))
|
||||
// @unlink (WP_FFPC_ACACHE_MAIN_FILE);
|
||||
$this->save_settings( false, true );
|
||||
//$this->generate_config ( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -602,7 +614,10 @@ if (!class_exists('WPFFPC')) {
|
|||
}
|
||||
|
||||
/**
|
||||
* generates main advanced-cache system-wide config file
|
||||
* generates main advanced-cache config file
|
||||
*
|
||||
* @param $delete_current
|
||||
* deletes current config settings on deactivation
|
||||
*
|
||||
*/
|
||||
function generate_config( ) {
|
||||
|
@ -616,10 +631,15 @@ if (!class_exists('WPFFPC')) {
|
|||
if ( @file_exists( $acache ))
|
||||
return false;
|
||||
|
||||
/* if no config left, don't create empty config */
|
||||
if ( empty ( $this->all_options ) )
|
||||
return false;
|
||||
|
||||
//if ( is_plugin_active_for_network ( WP_FFPC_PLUGIN ) && !is_plugin_active ( WP_FFPC_PLUGIN ) )
|
||||
// return false;
|
||||
|
||||
$string = '<?php'. "\n" . 'global '. WP_FFPC_CONFIG_VAR .";\n";
|
||||
|
||||
$string .= WP_FFPC_CONFIG_VAR .' = ' .var_export( $this->options , true ) . ';';
|
||||
|
||||
$string .= WP_FFPC_CONFIG_VAR .' = ' .var_export( $this->all_options , true ) . ';';
|
||||
$string .= "\n\ninclude_once ('" . WP_FFPC_ACACHE_COMMON_FILE . "');\ninclude_once ('" . WP_FFPC_ACACHE_INC_FILE . "');\n";
|
||||
|
||||
file_put_contents($acache, $string);
|
||||
|
@ -661,7 +681,14 @@ if (!class_exists('WPFFPC')) {
|
|||
$this->defaults = $defaults;
|
||||
|
||||
/* maps saved options and defaults */
|
||||
$this->options = get_site_option( WP_FFPC_PARAM , $defaults, false );
|
||||
//$this->options = get_site_option( WP_FFPC_PARAM , $defaults, false );
|
||||
|
||||
$this->all_options = get_site_option( WP_FFPC_PARAM );
|
||||
|
||||
if ( ! empty ( $this->all_options[ $this->options_key ] ) )
|
||||
$this->options = array_merge ( $defaults, $this->all_options[ $this->options_key ] );
|
||||
else
|
||||
$this->options = $defaults;
|
||||
|
||||
}
|
||||
|
||||
|
@ -736,43 +763,15 @@ if (!class_exists('WPFFPC')) {
|
|||
* boolean: true if the function is called on plugin activation
|
||||
*
|
||||
*/
|
||||
function save_settings ( $firstrun = false ) {
|
||||
function save_settings ( $firstrun = false, $delete_current = false ) {
|
||||
|
||||
$options = $this->defaults;
|
||||
|
||||
/* only try to update defaults if it's not first run and $_POST is not empty */
|
||||
if ( !$firstrun && !empty ( $_POST ) )
|
||||
{
|
||||
foreach ( $options as $key => $default )
|
||||
{
|
||||
/* $_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;
|
||||
}
|
||||
/* 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();
|
||||
if ( $delete_current )
|
||||
unset ( $this->all_options[ $this->options_key ] );
|
||||
else
|
||||
$this->update_settings( $firstrun );
|
||||
|
||||
/* save options */
|
||||
update_site_option( WP_FFPC_PARAM , $this->options );
|
||||
update_site_option( WP_FFPC_PARAM , $this->all_options );
|
||||
|
||||
/* invalidate cache, this is neccessary */
|
||||
$this->invalidate('system_flush');
|
||||
|
@ -783,7 +782,6 @@ if (!class_exists('WPFFPC')) {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -830,6 +828,43 @@ if (!class_exists('WPFFPC')) {
|
|||
wp_ffpc_log ( "plugin uninstalled ");
|
||||
}
|
||||
|
||||
|
||||
function update_settings ( $firstrun = false ) {
|
||||
$options = $this->defaults;
|
||||
|
||||
/* only try to update defaults if it's not first run and $_POST is not empty */
|
||||
if ( !$firstrun && !empty ( $_POST ) )
|
||||
{
|
||||
foreach ( $options as $key => $default )
|
||||
{
|
||||
/* $_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;
|
||||
}
|
||||
/* 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();
|
||||
|
||||
$this->all_options[ $this->options_key ] = $this->options;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue