diff --git a/classes/PluginWonderfulWidget.php b/classes/PluginWonderfulWidget.php index 42d9436..60bb1d7 100644 --- a/classes/PluginWonderfulWidget.php +++ b/classes/PluginWonderfulWidget.php @@ -1,58 +1,60 @@ 'plugin-wonderful', - 'description' => __('A widget for adding your Project Wonderful advertisements', 'plugin-wonderful') - ); - - $control_options = array( - 'id_base' => 'plugin-wonderful' - ); - - $this->WP_Widget('plugin-wonderful', __('Plugin Wonderful', 'plugin-wonderful'), $widget_options, $control_options); - } - - function widget($args, $instance) { - global $plugin_wonderful; - $plugin_wonderful->_render_adbox($instance['adboxid'], $instance['center']); - } - - function form($instance) { - global $plugin_wonderful; - - if ($plugin_wonderful->publisher_info !== false) { - echo '

'; - echo 'Select an adbox:
'; - foreach ($plugin_wonderful->publisher_info->adboxes as $box) { - echo '"; - echo "
"; - } - echo '

'; +if (class_exists('WP_Widget')) { + class PluginWonderfulWidget extends WP_Widget { + function PluginWonderfulWidget() { + $widget_options = array( + 'classname' => 'plugin-wonderful', + 'description' => __('A widget for adding your Project Wonderful advertisements', 'plugin-wonderful') + ); - echo '

'; - echo ''; - echo '

'; + $control_options = array( + 'id_base' => 'plugin-wonderful' + ); + + $this->WP_Widget('plugin-wonderful', __('Plugin Wonderful', 'plugin-wonderful'), $widget_options, $control_options); + } + + function widget($args, $instance) { + global $plugin_wonderful; + $plugin_wonderful->_render_adbox($instance['adboxid'], $instance['center']); + } + + function form($instance) { + global $plugin_wonderful; + + if ($plugin_wonderful->publisher_info !== false) { + echo '

'; + echo 'Select an adbox:
'; + foreach ($plugin_wonderful->publisher_info->adboxes as $box) { + echo '"; + echo "
"; + } + echo '

'; + + echo '

'; + echo ''; + echo '

'; + } + } + + function update($new_instance, $old_instance) { + $instance = $new_instance; + if (!isset($instance['center'])) { $instance['center'] = 0; } + return $instance; } - } - - function update($new_instance, $old_instance) { - $instance = $new_instance; - if (!isset($instance['center'])) { $instance['center'] = 0; } - return $instance; } } diff --git a/plugin-wonderful.php b/plugin-wonderful.php index cf7693f..8fdd19f 100644 --- a/plugin-wonderful.php +++ b/plugin-wonderful.php @@ -34,7 +34,9 @@ define('PLUGIN_WONDERFUL_UPDATE_TIME', 60 * 60 * 12); // every 12 hours $plugin_wonderful = new PluginWonderful(); function __plugin_wonderful_load_widgets() { - register_widget('PluginWonderfulWidget'); + if (class_exists('WP_Widget')) { + register_widget('PluginWonderfulWidget'); + } } add_action('admin_menu', array($plugin_wonderful, 'set_up_menu'));