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,6 +1,7 @@
<?php
class PluginWonderfulWidget extends WP_Widget {
if (class_exists('WP_Widget')) {
class PluginWonderfulWidget extends WP_Widget {
function PluginWonderfulWidget() {
$widget_options = array(
'classname' => 'plugin-wonderful',
@ -54,6 +55,7 @@ class PluginWonderfulWidget extends WP_Widget {
if (!isset($instance['center'])) { $instance['center'] = 0; }
return $instance;
}
}
}
?>

View File

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