new abstact & utils layout
This commit is contained in:
parent
9804bc515e
commit
b6f8bf157d
4 changed files with 2063 additions and 2101 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 2749265f11b2c2e9d34cc35aa74aca55b2b1b93b
|
||||
Subproject commit d12b345560c77634b25fc8ee7571c19730794c69
|
|
@ -1,28 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* backend driver for WordPress plugin WP-FFPC
|
||||
*
|
||||
* supported storages:
|
||||
* - APC
|
||||
* - Memcached
|
||||
* - Memcache
|
||||
*
|
||||
*/
|
||||
|
||||
if (!class_exists('WP_FFPC_Backend')) {
|
||||
|
||||
/* get the plugin abstract class*/
|
||||
include_once ( 'wp-common/wp-plugin-utilities.php');
|
||||
|
||||
|
||||
/* __ only availabe if we're running from the inside of wordpress, not in advanced-cache.php phase */
|
||||
if ( function_exists ( '__' ) ) {
|
||||
function __translate__ ( $text, $domain ) { return __($text, $domain); }
|
||||
}
|
||||
else {
|
||||
function __translate__ ( $text, $domain ) { return $text; }
|
||||
}
|
||||
if (!class_exists('WP_FFPC_Backend')) :
|
||||
|
||||
include_once ( 'wp-common/plugin_utils.php');
|
||||
/**
|
||||
*
|
||||
* @var string $plugin_constant Namespace of the plugin
|
||||
|
@ -77,7 +57,7 @@ if (!class_exists('WP_FFPC_Backend')) {
|
|||
$this->cookies = array ( 'comment_author_' , 'wordpressuser_' , 'wp-postpass_', 'wordpress_logged_in_' );
|
||||
|
||||
/* make utilities singleton */
|
||||
$this->utilities = WP_Plugins_Utilities_v1::Utility();
|
||||
$this->utilities = PluginUtils::S();
|
||||
|
||||
/* map the key with the predefined schemes */
|
||||
$ruser = isset ( $_SERVER['REMOTE_USER'] ) ? $_SERVER['REMOTE_USER'] : '';
|
||||
|
@ -922,6 +902,9 @@ if (!class_exists('WP_FFPC_Backend')) {
|
|||
$this->log ( __translate__("checking server statuses", $this->plugin_constant ));
|
||||
/* get servers statistic from connection */
|
||||
foreach ( $this->options['servers'] as $server_id => $server ) {
|
||||
if ( $server['port'] === 0 )
|
||||
$this->status[$server_id] = $this->connection->getServerStatus( $server['host'] );
|
||||
else
|
||||
$this->status[$server_id] = $this->connection->getServerStatus( $server['host'], $server['port'] );
|
||||
if ( $this->status[$server_id] == 0 )
|
||||
$this->log ( sprintf( __translate__( '%s server is down', $this->plugin_constant ), $server_id ) );
|
||||
|
@ -987,6 +970,4 @@ if (!class_exists('WP_FFPC_Backend')) {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
endif; ?>
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* main class for WordPress plugin WP-FFPC
|
||||
*
|
||||
* supported storages:
|
||||
* - APC
|
||||
* - Memcached
|
||||
* - Memcache
|
||||
*
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'WP_FFPC' ) ) {
|
||||
if ( ! class_exists( 'WP_FFPC' ) ) :
|
||||
|
||||
/* get the plugin abstract class*/
|
||||
include_once ( 'wp-common/wp-plugin-abstract.php' );
|
||||
include_once ( 'wp-common/plugin_abstract.php' );
|
||||
/* get the common functions class*/
|
||||
include_once ( 'wp-ffpc-backend.php' );
|
||||
|
||||
|
@ -30,7 +22,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
* @var array $shell_possibilities List of possible precache worker callers
|
||||
[TODO] finish list of vars
|
||||
*/
|
||||
class WP_FFPC extends WP_Plugins_Abstract_v3 {
|
||||
class WP_FFPC extends PluginAbstract {
|
||||
const host_separator = ',';
|
||||
const port_separator = ':';
|
||||
const donation_id_key = 'hosted_button_id=';
|
||||
|
@ -74,7 +66,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
/**
|
||||
* init hook function runs before admin panel hook, themeing and options read
|
||||
*/
|
||||
public function plugin_init() {
|
||||
public function plugin_pre_init() {
|
||||
/* advanced cache "worker" file */
|
||||
$this->acache_worker = $this->plugin_dir . $this->plugin_constant . '-acache.php';
|
||||
/* WordPress advanced-cache.php file location */
|
||||
|
@ -164,7 +156,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
* additional init, steps that needs the plugin options
|
||||
*
|
||||
*/
|
||||
public function plugin_setup () {
|
||||
public function plugin_post_init () {
|
||||
|
||||
/* initiate backend */
|
||||
$this->backend = new WP_FFPC_Backend ( $this->options, $this->network );
|
||||
|
@ -241,11 +233,9 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
}
|
||||
}
|
||||
|
||||
/* display errors globally */
|
||||
if ( $this->network )
|
||||
add_action( 'network_admin_notices', array( &$this, 'display_errors') );
|
||||
else
|
||||
add_action( 'admin_notices', array( &$this, 'display_errors') );
|
||||
foreach ( $this->errors as $e => $msg ) {
|
||||
$this->utils->alert ( $msg, 'error', $this->network );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,7 +270,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
* extending admin init
|
||||
*
|
||||
*/
|
||||
public function plugin_hook_admin_init () {
|
||||
public function plugin_extend_admin_init () {
|
||||
/* save parameter updates, if there are any */
|
||||
if ( isset( $_POST[ $this->button_flush ] ) ) {
|
||||
|
||||
|
@ -431,7 +421,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
?></p><?php
|
||||
} ?>
|
||||
</div>
|
||||
<form method="post" action="#" id="<?php echo $this->plugin_constant ?>-settings" class="plugin-admin">
|
||||
<form autocomplete="off" method="post" action="#" id="<?php echo $this->plugin_constant ?>-settings" class="plugin-admin">
|
||||
|
||||
<ul class="tabs">
|
||||
<li><a href="#<?php echo $this->plugin_constant ?>-type" class="wp-switch-editor"><?php _e( 'Cache type', $this->plugin_constant ); ?></a></li>
|
||||
|
@ -642,7 +632,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
<label for="authuser"><?php _e('Authentication: username', $this->plugin_constant); ?></label>
|
||||
</dt>
|
||||
<dd>
|
||||
<input type="text" name="authuser" id="authuser" value="<?php echo $this->options['authuser']; ?>" />
|
||||
<input type="text" autocomplete="off" name="authuser" id="authuser" value="<?php echo $this->options['authuser']; ?>" />
|
||||
<span class="description">
|
||||
<?php _e('Username for authentication with memcached backends', $this->plugin_constant); ?></span>
|
||||
</dd>
|
||||
|
@ -651,7 +641,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
<label for="authpass"><?php _e('Authentication: password', $this->plugin_constant); ?></label>
|
||||
</dt>
|
||||
<dd>
|
||||
<input type="password" name="authpass" id="authpass" value="<?php echo $this->options['authpass']; ?>" />
|
||||
<input type="password" autocomplete="off" name="authpass" id="authpass" value="<?php echo $this->options['authpass']; ?>" />
|
||||
<span class="description">
|
||||
<?php _e('Password for authentication with memcached backends - WARNING, the password will be stored plain-text since it needs to be used!', $this->plugin_constant); ?></span>
|
||||
</dd>
|
||||
|
@ -679,8 +669,8 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
|
||||
<?php
|
||||
|
||||
$gentime = $this->_get_option( self::precache_timestamp );
|
||||
$log = $this->_get_option( self::precache_log );
|
||||
$gentime = $this->utils->_get_option( self::precache_timestamp, $this->network );
|
||||
$log = $this->utils->_get_option( self::precache_log, $this->network );
|
||||
|
||||
if ( @file_exists ( $this->precache_logfile ) ) {
|
||||
$logtime = filemtime ( $this->precache_logfile );
|
||||
|
@ -688,8 +678,8 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
/* update precache log in DB if needed */
|
||||
if ( $logtime > $gentime ) {
|
||||
$log = file ( $this->precache_logfile );
|
||||
$this->_update_option( self::precache_log , $log );
|
||||
$this->_update_option( self::precache_timestamp , $logtime );
|
||||
$this->utils->_update_option( self::precache_log , $log, $this->network );
|
||||
$this->utils->_update_option( self::precache_timestamp , $logtime, $this->network );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -780,7 +770,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
* extending options_save
|
||||
*
|
||||
*/
|
||||
public function plugin_hook_options_save( $activating ) {
|
||||
public function plugin_extend_options_save( $activating ) {
|
||||
|
||||
/* schedule cron if posted */
|
||||
$schedule = wp_get_schedule( self::precache_id );
|
||||
|
@ -811,7 +801,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
/**
|
||||
* read hook; needs to be implemented
|
||||
*/
|
||||
public function plugin_hook_options_read( &$options ) {
|
||||
public function plugin_extend_options_read( &$options ) {
|
||||
/* read the global options, network compatibility */
|
||||
$this->global_config = get_site_option( $this->global_option );
|
||||
|
||||
|
@ -825,7 +815,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
/**
|
||||
* options delete hook; needs to be implemented
|
||||
*/
|
||||
public function plugin_hook_options_delete( ) {
|
||||
public function plugin_extend_options_delete( ) {
|
||||
delete_site_option ( $this->global_option );
|
||||
}
|
||||
|
||||
|
@ -833,7 +823,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
* need to do migrations from previous versions of the plugin
|
||||
*
|
||||
*/
|
||||
public function plugin_hook_options_migrate( &$options ) {
|
||||
public function plugin_options_migrate( &$options ) {
|
||||
$migrated = false;
|
||||
|
||||
if ( version_compare ( $options['version'] , $this->plugin_version , '<' ) ) {
|
||||
|
@ -1178,25 +1168,16 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
|||
}
|
||||
|
||||
/**
|
||||
* print errors, called by global errors hook
|
||||
* log wrapper to include options
|
||||
*
|
||||
*/
|
||||
public function display_errors ( ) {
|
||||
if ( empty ( $this->errors )) {
|
||||
$r = false;
|
||||
}
|
||||
else {
|
||||
$r = '<div class="error"><strong>'. __('WP-FFPC found errors, please correct them!', $this->plugin_constant ) .'</strong><ol>';
|
||||
foreach ( $this->errors as $eid => $message ) {
|
||||
$r .= '<li>' . $message . '</li>';
|
||||
}
|
||||
$r.= '</ol></div>';
|
||||
}
|
||||
|
||||
echo $r;
|
||||
public function log ( $message, $log_level = LOG_WARNING ) {
|
||||
if ( !isset ( $this->options['log'] ) || $this->options['log'] != 1 )
|
||||
return false;
|
||||
else
|
||||
$this->utils->log ( $this->plugin_constant, $message, $log_level );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
endif;
|
||||
|
|
|
@ -53,6 +53,6 @@ $wp_ffpc_defaults = array (
|
|||
'comments_invalidate' => true,
|
||||
);
|
||||
|
||||
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.6.0', 'WP-FFPC', $wp_ffpc_defaults, 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC' );
|
||||
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.6.0', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' );
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue