Adrotate Code for Multiple Widgets
You no longer need to hack Adrotate as the latest version allows for multiple widgets.
To get more then the 2 widgets that are enabled with Adrotate you need to modify the following files.
adrotate.php
adrotate-widget.php
After making a back up just in case!! .Do the following.
For adrotate.php add the following code after
For adrotate-widget.php copy and paste the follwoing code
Purpose: Widget for the sidebar
Receive: -none-
Return: -none-
————————————————————-*/
function adrotate_widget_init_2() {
if ( !function_exists(‘register_sidebar_widget’) )
return;
if ( !function_exists(‘adrotate_banner’) )
return;
function adrotate_widget_2($args) {
$options = get_option(‘widget_adrotate_2′);
extract($args);
echo $before_widget . $before_title . $options['title'] . $after_title;
echo ‘<ul><li>’;
echo adrotate_banner($options['group'], $options['banner'], $options['block'], false);
echo ‘</li></ul>’;
echo $after_widget;
}
function adrotate_widget_control_2() {
$options = $newoptions = get_option(‘widget_adrotate_2′);
if ( $_POST['adrotate-submit-2'] ) {
$newoptions['title'] = strip_tags(stripslashes($_POST['adrotate-title-2']));
$newoptions['group'] = strip_tags(stripslashes($_POST['adrotate-group-2']));
$newoptions['block'] = strip_tags(stripslashes($_POST['adrotate-block-2']));
$newoptions['banner'] = strip_tags(stripslashes($_POST['adrotate-banner-2']));
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option(‘widget_adrotate_2′, $options);
}
$title = attribute_escape($options['title']);
$group = attribute_escape($options['group']);
$block = attribute_escape($options['block']);
$banner = attribute_escape($options['banner']);
?>
<p>
<label for=”adrotate-title”>Title: <input class=”widefat” id=”adrotate-title” name=”adrotate-title-2″ type=”text” value=”<?php echo $title; ?>” /></label>
<br />
<small>HTML will be stripped out.</small>
</p>
<p>
<label for=”adrotate-group”>Group: <input class=”widefat” id=”adrotate-group” name=”adrotate-group-2″ type=”text” value=”<?php echo $group; ?>” /></label>
<br />
<small>Group IDs. If multiple, separate them with commas (ie. 2,3,12,5).</small>
</p>
<p>
<label for=”adrotate-block”>Block (Optional): <input class=”widefat” id=”adrotate-block” name=”adrotate-block-2″ type=”text” value=”<?php echo $block; ?>” /></label>
<br />
<small>Sets the amount of banners in a block.</small>
</p>
<p>
<label for=”adrotate-banner”>Banner (Optional): <input class=”widefat” id=”adrotate-banner” name=”adrotate-banner-2″ type=”text” value=”<?php echo $banner; ?>” /></label>
<br />
<small>Leave empty for multiple groups or when using a block! Do NOT enter multiple numbers here!</small>
</p>
<input type=”hidden” id=”adrotate-submit” name=”adrotate-submit-2″ value=”1″ />
<?php
}
?
$widget_ops_2 = array(‘classname’ => ‘adrotate_widget_2′, ‘description’ => “Add banners in the sidebar.” );
wp_register_sidebar_widget(‘AdRotate_2′, ‘AdRotate 2′, ‘adrotate_widget_2′, $widget_ops_2);
wp_register_widget_control(‘AdRotate_2′, ‘AdRotate 2′, ‘adrotate_widget_control_2′ );
}
Change all references to the number 2 to a unique number that matchs the changes you made to adrotate .php.
The above changes to both adrotate.php and adrotate-widget.php needs to be done for each extra widget you require.
Upload your changes to the Adrotate folder and now you have extra AD widgets.








I edited the files, it made my whole dashboard display codes only.
There was an error locating the main database table for AdRotate. Please deactivate and re-activate AdRotate from the plugin page!!
If this does not solve the issue please seek support at http://forum.at.meandmymac.net
I can email you the edited files if you want to take a look at them.
But in the mean time I guess I’ll be using 2 banners only.
Thanks!