<?php

add_action('widgets_init','abdllah_ads294');

function abdllah_ads294() {
register_widget('abdllah_ads294');

}

class abdllah_ads294 extends WP_Widget {
function abdllah_ads294() {

$widget_ops = array('classname' => 'ads294','description' => __('Widget display 294 x 158 Ads','abdllah'));
$this->WP_Widget( 'abdllah_ads294',themename .' - Ads 294 x 158', $widget_ops, '');

}

function widget( $args, $instance ) {
extract( $args );
/* User-selected settings. */
$title = apply_filters('widget_title', $instance['title'] );
$show_bg = $instance['show_bg'];
$img = $instance['img'];
$link = $instance['link'];
$titletip = $instance['titletip'];
$code = $instance['code'];
?>
<script charset="UTF-8" type="text/javascript">SETTINGS_HOST ="//www.travelpayouts.com";window.TP_FORM_SETTINGS = window.TP_FORM_SETTINGS || {};window.TP_FORM_SETTINGS["51d1915821c3df776b00001e"] = {};(function(){var code = ['<div class="aviasales_inlineable">',"<div style='visibility: hidden' data-widget-id='51d1915821c3df776b00001e' data-widgets-forms-inlineable='" + '{"link":"/widgets/51d1915821c3df776b00001e.json","forms":["search"],"widget_id":"51d1915821c3df776b00001e"}' + "'>",'<div class="nano_form_tabs_wp ultra_narrow_tabs">','<div class="nano_form_tabs" data-widgets-forms-inlineable-tabs="">','</div></div></div></div>'],loader_url = SETTINGS_HOST + '/assets/nano_ui/widgets/partners/loader_en.js?v=2&no_cache=' + (+new Date());if(!window.NANO){code.push('<' + 'script src="' + loader_url + '">' + '<' +'/script>');}document.write(code.join(''));})();</script>
<?php
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;

/* Strip tags (if needed) and update the widget settings. */
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['show_bg'] = $new_instance['show_bg'];
$instance['link'] = $new_instance['link'];
$instance['titletip'] = $new_instance['titletip'];
$instance['img'] = $new_instance['img'];
$instance['code'] = $new_instance['code'];
return $instance;
}

function form( $instance ) {

/* Set up some default widget settings. */
$defaults = array( 'title' =>__( 'advertisement' , 'abdllah'),
'titletip' => __( 'Ads294x289' , 'abdllah'),
'img' => BD_IMG.'ads160.png',
'link' => '#',
);


$instance = wp_parse_args( (array) $instance, $defaults ); ?>
<p>
  <label for="<?php echo $this->get_field_id( 'title' ); ?>">
    <?php _e('Title:', 'abdllah') ?>
  </label>
  <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
</p>
<p>
  <input class="checkbox" type="checkbox" <?php if(isset($instance['show_bg'])){ checked( $instance['show_bg'], 'on' ); } ?> id="<?php echo $this->get_field_id( 'show_bg' ); ?>" name="<?php echo $this->get_field_name( 'show_bg' ); ?>" />
  <label for="<?php echo $this->get_field_id( 'show_bg' ); ?>">
    <?php _e('transparent background', 'abdllah'); ?>
  </label>
</p>
<h3>
  <?php _e('First Ads', 'abdllah') ?>
</h3>
<p>
  <label for="<?php echo $this->get_field_id( 'img' ); ?>">
    <?php _e('image:', 'abdllah') ?>
  </label>
  <input id="<?php echo $this->get_field_id( 'img' ); ?>" name="<?php echo $this->get_field_name( 'img' ); ?>" value="<?php if(isset($instance['img'])){ echo $instance['img']; } ?>" class="widefat" />
</p>
<p>
  <label for="<?php echo $this->get_field_id( 'link' ); ?>">
    <?php _e('Link :', 'abdllah') ?>
  </label>
  <input id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" value="<?php if(isset($instance['link'])){ echo $instance['link']; } ?>" class="widefat" />
</p>
<p>
  <label for="<?php echo $this->get_field_id( 'titletip' ); ?>">
    <?php _e('titletip :', 'abdllah') ?>
  </label>
  <input id="<?php echo $this->get_field_id( 'titletip' ); ?>" name="<?php echo $this->get_field_name( 'titletip' ); ?>" value="<?php if(isset($instance['titletip'])){ echo $instance['titletip']; } ?>" class="widefat" />
</p>
<p>
  <label for="<?php echo $this->get_field_id( 'code' ); ?>">
    <?php _e('ad code :', 'abdllah') ?>
  </label>
  <textarea id="<?php echo $this->get_field_id( 'code' ); ?>" name="<?php echo $this->get_field_name( 'code' ); ?>" class="widefat"  ><?php if(isset($instance['code'])){ echo $instance['code']; } ?></textarea>
</p>
<?php
}
} //end class
