From 3c193b2523e2b8f0cd23fb7ba18e4e820d514ace Mon Sep 17 00:00:00 2001 From: cadeyrn Date: Fri, 8 Mar 2013 09:35:08 +0000 Subject: [PATCH] settings delete button git-svn-id: http://plugins.svn.wordpress.org/wp-ffpc/trunk@677978 b8457f37-d9ea-0310-8a92-e5e31aec5664 --- wp-ffpc.php | 48 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/wp-ffpc.php b/wp-ffpc.php index 616c2fd..6d554c9 100644 --- a/wp-ffpc.php +++ b/wp-ffpc.php @@ -11,8 +11,6 @@ License: GPL2 /* Copyright 2010-2013 Peter Molnar (email : hello@petermolnar.eu ) - Many thanks to contributor Mark Costlow - 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 published by the Free Software Foundation. @@ -68,6 +66,7 @@ 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' ); +define ( 'WP_FFPC_VERSION' , '0.5' ); if ( ! function_exists( 'is_plugin_active_for_network' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); @@ -191,6 +190,14 @@ if (!class_exists('WPFFPC')) { header( "Location: ". $this->settingslink ."&saved=true" ); } + + /* save parameter updates, if there are any */ + if ( isset($_POST[WP_FFPC_PARAM . '-delete']) ) + { + $this->delete_options(); + $this->status = 2; + header( "Location: ". $this->settingslink ."&deleted=true" ); + } if ( $this->network ) $optionspage = 'settings.php'; @@ -221,6 +228,13 @@ if (!class_exists('WPFFPC')) {

Settings saved.

status == 2) : ?> +

Plugin options deleted.

+ -

+

+ + +

save_settings( false, true ); //$this->generate_config ( true ); } + + /** + * delete options from database + * + */ + function delete_options () { + delete_site_option( WP_FFPC_PARAM ); + wp_ffpc_log ( "plugin options deleted "); + } /** * invalidate cache @@ -690,6 +716,20 @@ if (!class_exists('WPFFPC')) { else $this->options = $defaults; + /* check for version number, if none, we're upgrading from 0.5, therefore we need to copy the settings and remove them after + this will run once only at all + */ + if ( empty ( $this->all_options['version'] ) ) + { + foreach ( array_keys( $defaults ) as $key ) { + if ( isset ( $this->all_options[$key] ) ) + { + $this->options[$key] = $this->all_options[$key]; + unset ( $this->all_options[$key] ); + } + } + } + } /** @@ -770,6 +810,8 @@ if (!class_exists('WPFFPC')) { else $this->update_settings( $firstrun ); + $this->all_options['version'] = WP_FFPC_VERSION; + /* save options */ update_site_option( WP_FFPC_PARAM , $this->all_options );