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
|
<?php
|
||||||
/**
|
|
||||||
* backend driver for WordPress plugin WP-FFPC
|
|
||||||
*
|
|
||||||
* supported storages:
|
|
||||||
* - APC
|
|
||||||
* - Memcached
|
|
||||||
* - Memcache
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!class_exists('WP_FFPC_Backend')) {
|
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; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
include_once ( 'wp-common/plugin_utils.php');
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var string $plugin_constant Namespace of the plugin
|
* @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_' );
|
$this->cookies = array ( 'comment_author_' , 'wordpressuser_' , 'wp-postpass_', 'wordpress_logged_in_' );
|
||||||
|
|
||||||
/* make utilities singleton */
|
/* make utilities singleton */
|
||||||
$this->utilities = WP_Plugins_Utilities_v1::Utility();
|
$this->utilities = PluginUtils::S();
|
||||||
|
|
||||||
/* map the key with the predefined schemes */
|
/* map the key with the predefined schemes */
|
||||||
$ruser = isset ( $_SERVER['REMOTE_USER'] ) ? $_SERVER['REMOTE_USER'] : '';
|
$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 ));
|
$this->log ( __translate__("checking server statuses", $this->plugin_constant ));
|
||||||
/* get servers statistic from connection */
|
/* get servers statistic from connection */
|
||||||
foreach ( $this->options['servers'] as $server_id => $server ) {
|
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'] );
|
$this->status[$server_id] = $this->connection->getServerStatus( $server['host'], $server['port'] );
|
||||||
if ( $this->status[$server_id] == 0 )
|
if ( $this->status[$server_id] == 0 )
|
||||||
$this->log ( sprintf( __translate__( '%s server is down', $this->plugin_constant ), $server_id ) );
|
$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
|
<?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*/
|
/* 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*/
|
/* get the common functions class*/
|
||||||
include_once ( 'wp-ffpc-backend.php' );
|
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
|
* @var array $shell_possibilities List of possible precache worker callers
|
||||||
[TODO] finish list of vars
|
[TODO] finish list of vars
|
||||||
*/
|
*/
|
||||||
class WP_FFPC extends WP_Plugins_Abstract_v3 {
|
class WP_FFPC extends PluginAbstract {
|
||||||
const host_separator = ',';
|
const host_separator = ',';
|
||||||
const port_separator = ':';
|
const port_separator = ':';
|
||||||
const donation_id_key = 'hosted_button_id=';
|
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
|
* 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 */
|
/* advanced cache "worker" file */
|
||||||
$this->acache_worker = $this->plugin_dir . $this->plugin_constant . '-acache.php';
|
$this->acache_worker = $this->plugin_dir . $this->plugin_constant . '-acache.php';
|
||||||
/* WordPress advanced-cache.php file location */
|
/* WordPress advanced-cache.php file location */
|
||||||
|
@ -164,7 +156,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
||||||
* additional init, steps that needs the plugin options
|
* additional init, steps that needs the plugin options
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function plugin_setup () {
|
public function plugin_post_init () {
|
||||||
|
|
||||||
/* initiate backend */
|
/* initiate backend */
|
||||||
$this->backend = new WP_FFPC_Backend ( $this->options, $this->network );
|
$this->backend = new WP_FFPC_Backend ( $this->options, $this->network );
|
||||||
|
@ -241,11 +233,9 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* display errors globally */
|
foreach ( $this->errors as $e => $msg ) {
|
||||||
if ( $this->network )
|
$this->utils->alert ( $msg, 'error', $this->network );
|
||||||
add_action( 'network_admin_notices', array( &$this, 'display_errors') );
|
}
|
||||||
else
|
|
||||||
add_action( 'admin_notices', array( &$this, 'display_errors') );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -280,7 +270,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
||||||
* extending admin init
|
* extending admin init
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function plugin_hook_admin_init () {
|
public function plugin_extend_admin_init () {
|
||||||
/* save parameter updates, if there are any */
|
/* save parameter updates, if there are any */
|
||||||
if ( isset( $_POST[ $this->button_flush ] ) ) {
|
if ( isset( $_POST[ $this->button_flush ] ) ) {
|
||||||
|
|
||||||
|
@ -431,7 +421,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
||||||
?></p><?php
|
?></p><?php
|
||||||
} ?>
|
} ?>
|
||||||
</div>
|
</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">
|
<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>
|
<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>
|
<label for="authuser"><?php _e('Authentication: username', $this->plugin_constant); ?></label>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<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">
|
<span class="description">
|
||||||
<?php _e('Username for authentication with memcached backends', $this->plugin_constant); ?></span>
|
<?php _e('Username for authentication with memcached backends', $this->plugin_constant); ?></span>
|
||||||
</dd>
|
</dd>
|
||||||
|
@ -651,7 +641,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
||||||
<label for="authpass"><?php _e('Authentication: password', $this->plugin_constant); ?></label>
|
<label for="authpass"><?php _e('Authentication: password', $this->plugin_constant); ?></label>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<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">
|
<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>
|
<?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>
|
</dd>
|
||||||
|
@ -679,8 +669,8 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$gentime = $this->_get_option( self::precache_timestamp );
|
$gentime = $this->utils->_get_option( self::precache_timestamp, $this->network );
|
||||||
$log = $this->_get_option( self::precache_log );
|
$log = $this->utils->_get_option( self::precache_log, $this->network );
|
||||||
|
|
||||||
if ( @file_exists ( $this->precache_logfile ) ) {
|
if ( @file_exists ( $this->precache_logfile ) ) {
|
||||||
$logtime = filemtime ( $this->precache_logfile );
|
$logtime = filemtime ( $this->precache_logfile );
|
||||||
|
@ -688,8 +678,8 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
||||||
/* update precache log in DB if needed */
|
/* update precache log in DB if needed */
|
||||||
if ( $logtime > $gentime ) {
|
if ( $logtime > $gentime ) {
|
||||||
$log = file ( $this->precache_logfile );
|
$log = file ( $this->precache_logfile );
|
||||||
$this->_update_option( self::precache_log , $log );
|
$this->utils->_update_option( self::precache_log , $log, $this->network );
|
||||||
$this->_update_option( self::precache_timestamp , $logtime );
|
$this->utils->_update_option( self::precache_timestamp , $logtime, $this->network );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -780,7 +770,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
||||||
* extending options_save
|
* extending options_save
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function plugin_hook_options_save( $activating ) {
|
public function plugin_extend_options_save( $activating ) {
|
||||||
|
|
||||||
/* schedule cron if posted */
|
/* schedule cron if posted */
|
||||||
$schedule = wp_get_schedule( self::precache_id );
|
$schedule = wp_get_schedule( self::precache_id );
|
||||||
|
@ -811,7 +801,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
|
||||||
/**
|
/**
|
||||||
* read hook; needs to be implemented
|
* 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 */
|
/* read the global options, network compatibility */
|
||||||
$this->global_config = get_site_option( $this->global_option );
|
$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
|
* 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 );
|
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
|
* 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;
|
$migrated = false;
|
||||||
|
|
||||||
if ( version_compare ( $options['version'] , $this->plugin_version , '<' ) ) {
|
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 ( ) {
|
public function log ( $message, $log_level = LOG_WARNING ) {
|
||||||
if ( empty ( $this->errors )) {
|
if ( !isset ( $this->options['log'] ) || $this->options['log'] != 1 )
|
||||||
$r = false;
|
return false;
|
||||||
}
|
else
|
||||||
else {
|
$this->utils->log ( $this->plugin_constant, $message, $log_level );
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
endif;
|
||||||
|
|
|
@ -53,6 +53,6 @@ $wp_ffpc_defaults = array (
|
||||||
'comments_invalidate' => true,
|
'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