prevent widget loading if WP_Widget does not exist
This commit is contained in:
parent
ce0559649c
commit
07d1e4949d
@ -1,58 +1,60 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class PluginWonderfulWidget extends WP_Widget {
|
if (class_exists('WP_Widget')) {
|
||||||
function PluginWonderfulWidget() {
|
class PluginWonderfulWidget extends WP_Widget {
|
||||||
$widget_options = array(
|
function PluginWonderfulWidget() {
|
||||||
'classname' => 'plugin-wonderful',
|
$widget_options = array(
|
||||||
'description' => __('A widget for adding your Project Wonderful advertisements', 'plugin-wonderful')
|
'classname' => '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 '<p>';
|
|
||||||
echo 'Select an adbox:<br />';
|
|
||||||
foreach ($plugin_wonderful->publisher_info->adboxes as $box) {
|
|
||||||
echo '<label>';
|
|
||||||
echo '<input type="radio" name="'
|
|
||||||
. $this->get_field_name('adboxid')
|
|
||||||
. '" value="'
|
|
||||||
. $box->adboxid
|
|
||||||
. '" '
|
|
||||||
. (($instance['adboxid'] == $box->adboxid) ? 'checked="checked"' : "")
|
|
||||||
. ' />';
|
|
||||||
echo $box->adtype . " " . $box->dimensions . " (" . $box->adboxid . ")";
|
|
||||||
echo "</label>";
|
|
||||||
echo "<br />";
|
|
||||||
}
|
|
||||||
echo '</p>';
|
|
||||||
|
|
||||||
echo '<p>';
|
$control_options = array(
|
||||||
echo '<label>';
|
'id_base' => 'plugin-wonderful'
|
||||||
echo '<input type="checkbox" value="1" name="' . $this->get_field_name('center') . '" ' . (($instance['center'] == 1) ? 'checked="checked"' : "") . ' /> ';
|
);
|
||||||
echo 'Wrap ad in <center> tags';
|
|
||||||
echo '</label>';
|
$this->WP_Widget('plugin-wonderful', __('Plugin Wonderful', 'plugin-wonderful'), $widget_options, $control_options);
|
||||||
echo '</p>';
|
}
|
||||||
|
|
||||||
|
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 '<p>';
|
||||||
|
echo 'Select an adbox:<br />';
|
||||||
|
foreach ($plugin_wonderful->publisher_info->adboxes as $box) {
|
||||||
|
echo '<label>';
|
||||||
|
echo '<input type="radio" name="'
|
||||||
|
. $this->get_field_name('adboxid')
|
||||||
|
. '" value="'
|
||||||
|
. $box->adboxid
|
||||||
|
. '" '
|
||||||
|
. (($instance['adboxid'] == $box->adboxid) ? 'checked="checked"' : "")
|
||||||
|
. ' />';
|
||||||
|
echo $box->adtype . " " . $box->dimensions . " (" . $box->adboxid . ")";
|
||||||
|
echo "</label>";
|
||||||
|
echo "<br />";
|
||||||
|
}
|
||||||
|
echo '</p>';
|
||||||
|
|
||||||
|
echo '<p>';
|
||||||
|
echo '<label>';
|
||||||
|
echo '<input type="checkbox" value="1" name="' . $this->get_field_name('center') . '" ' . (($instance['center'] == 1) ? 'checked="checked"' : "") . ' /> ';
|
||||||
|
echo 'Wrap ad in <center> tags';
|
||||||
|
echo '</label>';
|
||||||
|
echo '</p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,9 @@ 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() {
|
||||||
register_widget('PluginWonderfulWidget');
|
if (class_exists('WP_Widget')) {
|
||||||
|
register_widget('PluginWonderfulWidget');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('admin_menu', array($plugin_wonderful, 'set_up_menu'));
|
add_action('admin_menu', array($plugin_wonderful, 'set_up_menu'));
|
||||||
|
Loading…
Reference in New Issue
Block a user