// custom sidebar 125x125 ads widget
class AppThemes_Widget_125_Ads extends WP_Widget {
function AppThemes_Widget_125_Ads() {
$widget_ops = array( 'description' => __( 'Places an ad space in the sidebar for 125x125 ads', APP_TD ) );
$control_ops = array('width' => 500, 'height' => 350);
$this->WP_Widget( 'cp_125_ads', __( 'CP 125x125 Ads', APP_TD ), $widget_ops, $control_ops );
}
function widget( $args, $instance ) {
extract($args);
$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Sponsored Ads', APP_TD ) : $instance['title'] );
$newin = isset( $instance['newin'] ) ? $instance['newin'] : false;
if (isset($instance['ads'])) :
// separate the ad line items into an array
$ads = explode("\n", $instance['ads']);
if (sizeof($ads)>0) :
echo $before_widget;
if ($title) echo $before_title . $title . $after_title;
[B][U]if ($newin) $newin = 'target="_blank"';[/U][/B]
?>
<ul class="ads">
<?php
$alt = 1;
foreach ($ads as $ad) :
if ($ad && strstr($ad, '|')) {
$alt = $alt*-1;
$this_ad = explode('|', $ad);
echo '<li class="';
if ($alt==1) echo 'alt';
echo '"><a href="'.$this_ad[0].'" rel="'.$this_ad[3].'" '.$newin.'><img src="'.$this_ad[1].'" width="125" height="125" alt="'.$this_ad[2].'" /></a></li>';
}
endforeach;
?>
</ul>
<?php
echo $after_widget;
endif;
endif;
}
There are currently 1 users browsing this thread. (0 members and 1 guests)