Skip to content

Instantly share code, notes, and snippets.

@abachuk
Created April 13, 2012 03:36
Show Gist options
  • Save abachuk/2373454 to your computer and use it in GitHub Desktop.
Save abachuk/2373454 to your computer and use it in GitHub Desktop.
Widget
<?php class slider_widget extends WP_Widget {
function slider_widget() {
$widget_options = array(
'classname' => 'slider',
'description' => 'add promo slider'
);
parent::WP_Widget(false, 'Promotional Slider', $widget_options);
}
/** @see WP_Widget::widget -- do not rename this */
function widget($args, $instance) {
extract( $args );
$title = apply_filters('widget_title', $instance['slider-title']);
$message = $instance['slider-message'];
?>
<?php echo $before_widget; ?>
<?php /// get values from theme options ////
$img1 = of_get_option('promo_img1');
$img2 = of_get_option('promo_img2');
$img3 = of_get_option('promo_img3');
$img4 = of_get_option('promo_img4');
$img5 = of_get_option('promo_img5');
$img6 = of_get_option('promo_img6');
$img1url = of_get_option('promo_img1_url');
$img2url = of_get_option('promo_img2_url');
$img3url = of_get_option('promo_img3_url');
$img4url = of_get_option('promo_img4_url');
$img5url = of_get_option('promo_img5_url');
$img6url = of_get_option('promo_img6_url');
?>
<article class="one-third last ad-slider">
<div id="slider">
<?php if ( !empty($img1) ) { ?><a href="<?php echo $img1url; ?>"><img src="<?php echo $img1; ?>" alt="" /></a><?php } ?>
<?php if ( !empty($img2) ) { ?><a href="<?php echo $img2url; ?>"><img src="<?php echo $img2; ?>" alt="" /></a><?php } ?>
<?php if ( !empty($img3) ) { ?><a href="<?php echo $img3url; ?>"><img src="<?php echo $img3; ?>" alt="" /></a><?php } ?>
<?php if ( !empty($img4) ) { ?><a href="<?php echo $img4url; ?>"><img src="<?php echo $img4; ?>" alt="" /></a><?php } ?>
<?php if ( !empty($img5) ) { ?><a href="<?php echo $img5url; ?>"><img src="<?php echo $img5; ?>" alt="" /></a><?php } ?>
<?php if ( !empty($img6) ) { ?><a href="<?php echo $img6url; ?>"><img src="<?php echo $img6; ?>" alt="" /></a><?php } ?>
</div>
</article>
<?php echo $after_widget; ?>
<?php
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['slider-title'] = strip_tags($new_instance['slider-title']);
$instance['slider-message'] = strip_tags($new_instance['slider-message']);
return $instance;
}
/** @see WP_Widget::form -- do not rename this */
function form($instance) {
$title = esc_attr($instance['slider-title']);
$message = esc_attr($instance['slider-message']);
}
} // end class jackpot_widget
add_action('widgets_init', create_function('', 'return register_widget("slider_widget");')); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment