From 2598ed919d3ba39f815c8e8a16e87c96ad972b59 Mon Sep 17 00:00:00 2001 From: cadeyrn Date: Tue, 19 Mar 2013 18:08:34 +0000 Subject: [PATCH] RC2 cleanup git-svn-id: http://plugins.svn.wordpress.org/wp-ffpc/trunk@684358 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- readme.txt | 1 + wp-ffpc-abstract.php | 33 +++++++++++++++++---------------- wp-ffpc-acache.php | 18 ++++++------------ wp-ffpc-admin.css | 3 +-- wp-ffpc-backend.php | 16 ++++++++-------- wp-ffpc-class.php | 6 +++--- 6 files changed, 36 insertions(+), 41 deletions(-) diff --git a/readme.txt b/readme.txt index 4b4ae5d..651346f 100644 --- a/readme.txt +++ b/readme.txt @@ -81,6 +81,7 @@ and **at least one** of the following for storage backend: = 1.0 = *in RC state* +* plugin development using [GitHub repository](https://github.com/petermolnar/wp-ffpc "GitHub repository") from this version; WordPress SVN only for releases * Software licence change from GPLv2 to GPLv3 * backend code completely replaced ( object-based backend, improved readability & better structure, lot less global vars, etc. ) * added proper uninstall ( uninstall hook was not removing options from DB, uninstall.php will ) diff --git a/wp-ffpc-abstract.php b/wp-ffpc-abstract.php index b615918..2c58953 100644 --- a/wp-ffpc-abstract.php +++ b/wp-ffpc-abstract.php @@ -44,6 +44,11 @@ if (!class_exists('WP_Plugins_Abstract')) { */ abstract class WP_Plugins_Abstract { + const slug_save = '&saved=true'; + const slug_delete = '&deleted=true'; + const broadcast_url = 'http://petermolnar.eu/broadcast/'; + const donation_business_id = 'FA3NT7XDVHPWU'; + protected $plugin_constant; protected $options = array(); protected $defaults = array(); @@ -60,11 +65,7 @@ if (!class_exists('WP_Plugins_Abstract')) { protected $donation_link; protected $button_save; protected $button_delete; - public $capability = 10; - const slug_save = '&saved=true'; - const slug_delete = '&deleted=true'; - const broadcast_url = 'http://petermolnar.eu/broadcast/'; - const donation_business_id = 'FA3NT7XDVHPWU'; + protected $capability = 10; protected $donation_business_name; protected $donation_item_name; protected $broadcast_message; @@ -181,14 +182,13 @@ if (!class_exists('WP_Plugins_Abstract')) { */ abstract function plugin_setup(); - /** * admin panel, the HTML usually */ abstract function plugin_admin_panel(); /** - * admin init: save/delete setting, add admin panel call hook + * admin init called by WordPress add_action, needs to be public */ public function plugin_admin_init() { @@ -283,15 +283,15 @@ if (!class_exists('WP_Plugins_Abstract')) { } /** - * hook to add functionality into plugin_options_read - */ - abstract function plugin_hook_options_read ( &$options ); - - /** - * hook for parameter migration + * hook for parameter migration, runs right after options read from DB */ abstract function plugin_hook_options_migrate( &$options ); + /** + * hook to add functionality into plugin_options_read, runs after defaults check + */ + abstract function plugin_hook_options_read ( &$options ); + /** * used on update and to save current options to database * @@ -482,8 +482,10 @@ if (!class_exists('WP_Plugins_Abstract')) { return $opt; } - - + /** + * creates PayPal donation form based on plugin details & hardcoded business ID + * + */ protected function plugin_donation_form () { ?> @@ -504,7 +506,6 @@ if (!class_exists('WP_Plugins_Abstract')) { slider.slider( "value", this.selectedIndex + 1 ); }); }); - }); diff --git a/wp-ffpc-acache.php b/wp-ffpc-acache.php index bcc3a4d..cd2f6d2 100644 --- a/wp-ffpc-acache.php +++ b/wp-ffpc-acache.php @@ -76,13 +76,11 @@ $wp_ffpc_values = array(); foreach ( $wp_ffpc_keys as $key ) { $value = $wp_ffpc_backend->get ( $wp_ffpc_backend->key ( $key ) ); - if ( ! $value ) - { + if ( ! $value ) { wp_ffpc_start(); return; } - else - { + else { $wp_ffpc_values[ $key ] = $value; } } @@ -230,14 +228,12 @@ function wp_ffpc_callback( $buffer ) { if made with archieve, last listed post can make this go bad */ global $post; - if ( !empty($post) && ( $meta['type'] == 'single' || $meta['type'] == 'page' ) && !empty ( $post->post_modified_gmt ) ) - { + if ( !empty($post) && ( $meta['type'] == 'single' || $meta['type'] == 'page' ) && !empty ( $post->post_modified_gmt ) ) { /* get last modification data */ $meta['lastmodified'] = strtotime ( $post->post_modified_gmt ); /* get shortlink, if possible */ - if (function_exists('wp_get_shortlink')) - { + if (function_exists('wp_get_shortlink')) { $shortlink = wp_get_shortlink( ); if (!empty ( $shortlink ) ) $meta['shortlink'] = $shortlink; @@ -254,13 +250,11 @@ function wp_ffpc_callback( $buffer ) { if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) $_SERVER['HTTPS'] = 'on'; - if ( isset($_SERVER['HTTPS']) && ( ( strtolower($_SERVER['HTTPS']) == 'on' ) || ( $_SERVER['HTTPS'] == '1' ) ) ) - { + if ( isset($_SERVER['HTTPS']) && ( ( strtolower($_SERVER['HTTPS']) == 'on' ) || ( $_SERVER['HTTPS'] == '1' ) ) ) { $sync_from = 'http://' . $_SERVER['SERVER_NAME']; $sync_to = 'https://' . $_SERVER['SERVER_NAME']; } - else - { + else { $sync_from = 'https://' . $_SERVER['SERVER_NAME']; $sync_to = 'http://' . $_SERVER['SERVER_NAME']; } diff --git a/wp-ffpc-admin.css b/wp-ffpc-admin.css index 08ee5a5..6ebafcb 100644 --- a/wp-ffpc-admin.css +++ b/wp-ffpc-admin.css @@ -120,7 +120,7 @@ background: #f1f1f1; } -.ui-slider .ui-slider-handle { +.wp-ffpc-donation .ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; @@ -137,5 +137,4 @@ background-image: -o-linear-gradient(bottom,#ececec,#f9f9f9); background-image: linear-gradient(to top,#ececec,#f9f9f9); outline: none; - } diff --git a/wp-ffpc-backend.php b/wp-ffpc-backend.php index d84c3b7..dc3e684 100644 --- a/wp-ffpc-backend.php +++ b/wp-ffpc-backend.php @@ -36,12 +36,12 @@ if (!class_exists('WP_FFPC_Backend')) { const prefix = 'prefix-'; const host_separator = ','; const port_separator = ':'; - private $key_prefixes = array ( 'meta', 'data' ); + private $key_prefixes = array ( 'meta', 'data' ); private $connection = NULL; private $options; private $alive = false; - public $status; + private $status; /** * constructor @@ -192,11 +192,13 @@ if (!class_exists('WP_FFPC_Backend')) { else $protocol = 'http://'; + /* elements to clear */ $to_clear = array ( $this->options['prefix-meta'] . $protocol . $path, $this->options['prefix-data'] . $protocol . $path, ); + /* delete entries */ $internal = $this->proxy ( 'clear' ); $this->$internal ( $to_clear ); } @@ -299,7 +301,7 @@ if (!class_exists('WP_FFPC_Backend')) { if ( function_exists( 'syslog' ) ) syslog( $log_level , self::plugin_constant . " with " . $this->options['cache_type'] . ' ' . $message ); /* error level is real problem, needs to be displayed on the admin panel */ - throw new Exception ( $message ); + //throw new Exception ( $message ); break; default: if ( function_exists( 'syslog' ) && $this->options['debug'] ) @@ -423,7 +425,7 @@ if (!class_exists('WP_FFPC_Backend')) { /* use binary and not compressed format, good for nginx and still fast */ $this->connection->setOption( Memcached::OPT_COMPRESSION , false ); - //$this->connection->setOption( Memcached::OPT_BINARY_PROTOCOL , true ); + $this->connection->setOption( Memcached::OPT_BINARY_PROTOCOL , true ); } /* check if initialization was success or not */ @@ -652,12 +654,10 @@ if (!class_exists('WP_FFPC_Backend')) { foreach ( $keys as $key ) { $kresult = $this->connection->delete( $key ); - if ( $kresult === false ) - { + if ( $kresult === false ) { $this->log ( __translate__('unable to delete entry ', self::plugin_constant ) . $key ); } - else - { + else { $this->log ( __translate__( 'entry deleted: ', self::plugin_constant ) . $key ); } } diff --git a/wp-ffpc-class.php b/wp-ffpc-class.php index 7c0f758..f4e29d5 100644 --- a/wp-ffpc-class.php +++ b/wp-ffpc-class.php @@ -511,7 +511,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) { /* create advanced cache file, needed only once or on activation, because there could be lefover advanced-cache.php from different plugins */ if ( !$activating ) - $this->deploy_acache(); + $this->deploy_advanced_cache(); } @@ -574,7 +574,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) { * advanced-cache.php creator function * */ - private function deploy_acache( ) { + private function deploy_advanced_cache( ) { /* in case advanced-cache.php was already there, remove it */ if ( @file_exists( $this->acache )) @@ -651,7 +651,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) { } /* deploy advanced-cache.php */ - $this->deploy_acache (); + $this->deploy_advanced_cache (); /* save options to database */ update_site_option( $this->global_option , $this->global_config );