Plugin Hack: AdsenseDeluxe
One of the plugins I use is AdsenseDeluxe. This plugin allows you to easily add Adsense content to posts as well as to your sidebar. To add it to your Sidebar you are required to edit your template files. To make this compatible with the Sidebar Widgets Plug in I added the following code to the Adsense source code:
function adsense_deluxe_widget($args) {
extract($args);
$options = get_option(’widget_adsense_deluxe’);
$title = $options[’title’];
$name = empty($options[’name’]) ? ’sidebar’ : $options[’name’];
echo $before_widget;
echo $before_title. $title . $after_title;
$options = get_option(ADSDEL_OPTIONS_ID);
if (($options[’ads’][$name][’enabled’]==1) && $options[’all_enabled’]) {
echo ‘<div class=”adsense”>’;
adsense_deluxe_ads($name);
echo ‘</div>’;
}
echo $after_widget;
}
function adsense_deluxe_widget_control() {
$options = $newoptions = get_option(’widget_adsense_deluxe’);
if ( $_POST[’adsense_deluxe-submit’] ) {
$newoptions[’title’] = strip_tags(stripslashes($_POST[’adsense_deluxe-title’]));
$newoptions[’name’] = strip_tags(stripslashes($_POST[’adsense_deluxe-name’]));
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option(’widget_adsense_deluxe’, $options);
}
$title = wp_specialchars($options[’title’]);
$name = empty($options[’name’]) ? ’sidebar’ : $options[’name’];
?>
<p><label for=”adsense_deluxe-title”><?php _e(’Title:’); ?> <input style=”width: 250px;” id=”adsense_deluxe-title” name=”adsense_deluxe-title” type=”text” value=”<?php echo $title; ?>” /></label></p>
<p><label for=”adsense_deluxe-name”><?php _e(’Name:’); ?> <input style=”width: 250px;” id=”adsense_deluxe-name” name=”adsense_deluxe-name” type=”text” value=”” /></label></p>
<input type=”hidden” id=”adsense_deluxe-submit” name=”adsense_deluxe-submit” value=”1″ />
<?php
}
function adsense_deluxe_widget_init() {
if(function_exists(’register_sidebar_widget’)) {
register_sidebar_widget(’Adsense Deluxe’, ‘adsense_deluxe_widget’);
register_widget_control(’Adsense Deluxe’, ‘adsense_deluxe_widget_control’, 300, 120);
}
}
if( function_exists(’add_action’) )
add_action(’plugins_loaded’, ‘adsense_deluxe_widget_init’);
Once added you can then create an Adsense block called for example “sidebar” and then activate it on the Widgets Configuration page.
Rodney

Leave a comment