finalize pre 2.8 widget stuff

This commit is contained in:
John Bintz 2009-07-01 00:01:48 -04:00
parent 8ad3163afc
commit 06af670dbf
2 changed files with 11 additions and 7 deletions

View File

@ -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 '<input type="hidden" name="_pw_action" value="update-pre28-widget" />';
$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) {

View File

@ -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();
}
}
?>