From 06af670dbfccf99220c9fe76a8eae5a98ee5929b Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 1 Jul 2009 00:01:48 -0400 Subject: [PATCH] finalize pre 2.8 widget stuff --- classes/PluginWonderful.php | 14 +++++++++++--- test/PluginWonderfulTest.php | 4 ---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/classes/PluginWonderful.php b/classes/PluginWonderful.php index 47f506c..78b07df 100644 --- a/classes/PluginWonderful.php +++ b/classes/PluginWonderful.php @@ -165,7 +165,7 @@ class PluginWonderful { function handle_action() { if (!empty($_POST['_pw_nonce'])) { if (wp_verify_nonce($_POST['_pw_nonce'], 'plugin-wonderful')) { - $action = "handle_action_" . str_replace("-", "_", preg_replace('#[^a-z\-]#', '', strtolower($_POST['_pw_action']))); + $action = "handle_action_" . str_replace("-", "_", preg_replace('#[^a-z0-9\-]#', '', strtolower($_POST['_pw_action']))); if (method_exists($this, $action)) { call_user_func(array($this, $action)); } } } @@ -372,13 +372,15 @@ class PluginWonderful { } } - function _normalize_pre28_option() { + function _normalize_pre28_option($data = null) { $instance = array( 'adboxid' => false, 'center' => 0 ); - $data = get_option('plugin-wonderful-pre28-widget-info'); + if (!is_array($data)) { + $data = get_option('plugin-wonderful-pre28-widget-info'); + } if (is_array($data)) { foreach ($data as $field => $value) { if (isset($instance[$field])) { @@ -400,6 +402,12 @@ class PluginWonderful { echo ''; $this->_render_adbox_admin($instance, array('adboxid' => 'pw[adboxid]', 'center' => 'pw[center]')); } + + function handle_action_update_pre28_widget() { + if (isset($_POST['pw'])) { + $this->_normalize_pre28_option($_POST['pw']); + } + } } function the_project_wonderful_ad($adboxid) { diff --git a/test/PluginWonderfulTest.php b/test/PluginWonderfulTest.php index 0474ea4..f87a29d 100644 --- a/test/PluginWonderfulTest.php +++ b/test/PluginWonderfulTest.php @@ -556,10 +556,6 @@ class PluginWonderfulTest extends PHPUnit_Framework_TestCase { $this->assertEquals($expected_result, $this->pw->_normalize_pre28_option()); $this->assertEquals($expected_result, get_option('plugin-wonderful-pre28-widget-info')); } - - function testHandlePre28WidgetUpdate() { - $this->markTestIncomplete(); - } } ?>