prevent widget loading if WP_Widget does not exist

This commit is contained in:
John Bintz 2009-06-29 07:09:37 -04:00
parent ce0559649c
commit 07d1e4949d
2 changed files with 56 additions and 52 deletions

View File

@ -1,5 +1,6 @@
<?php <?php
if (class_exists('WP_Widget')) {
class PluginWonderfulWidget extends WP_Widget { class PluginWonderfulWidget extends WP_Widget {
function PluginWonderfulWidget() { function PluginWonderfulWidget() {
$widget_options = array( $widget_options = array(
@ -55,5 +56,6 @@ class PluginWonderfulWidget extends WP_Widget {
return $instance; return $instance;
} }
} }
}
?> ?>

View File

@ -34,8 +34,10 @@ define('PLUGIN_WONDERFUL_UPDATE_TIME', 60 * 60 * 12); // every 12 hours
$plugin_wonderful = new PluginWonderful(); $plugin_wonderful = new PluginWonderful();
function __plugin_wonderful_load_widgets() { function __plugin_wonderful_load_widgets() {
if (class_exists('WP_Widget')) {
register_widget('PluginWonderfulWidget'); register_widget('PluginWonderfulWidget');
} }
}
add_action('admin_menu', array($plugin_wonderful, 'set_up_menu')); add_action('admin_menu', array($plugin_wonderful, 'set_up_menu'));
add_action('init', array($plugin_wonderful, 'init')); add_action('init', array($plugin_wonderful, 'init'));