<?php 

add_action('widgets_init','ad_full');

function ad_full() {
	register_widget('ad_full');
	
	}

class ad_full extends WP_Widget {
	function ad_full() {
			
		$widget_ops = array('classname' => 'ad_full','description' => 'مربع جانبى لعرض إعلان 250 × 250');
		$this->WP_Widget('ad_full','يرامجي - اعلانات 250 × 250',$widget_ops);

		}
		
	function widget( $args, $instance ) {
		extract( $args );
		/* User-selected settings. */
		$title = apply_filters('widget_title', $instance['title'] );
		$img1 = $instance['img1'];
		$link1 = $instance['link1'];

		/* Before widget (defined by themes). */
		echo $before_widget;

		/* Title of widget (before and after defined by themes). */
		if ( $title )
			echo $before_title . $title . $after_title;
?>
		   	    <div class="big_ad">
        			  <?php if($img1!='') { ?>
			   <a href="<?php echo $link1 ?>"><img src="<?php echo $img1 ?>" alt="" /></a>
				<?php } ?>
			  </div><!-- big_ad -->

			
<?php 
		/* After widget (defined by themes). */
		echo $after_widget;
	}
	
	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['link1'] = $new_instance['link1'];
		$instance['img1'] = $new_instance['img1'];
		$instance['link2'] = $new_instance['link2'];

		return $instance;
	}
	
function form( $instance ) {

		/* Set up some default widget settings. */
		$defaults = array( 'title' => 'إعلانات', 
			'img1' => SalahElimam_IMG.'/big_ad.png', 
			'link1' => '#'
 			);
		$instance = wp_parse_args( (array) $instance, $defaults ); ?>
	
    	<p>
		<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('العنوان :', 'salahelimam') ?></label>
		<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>"  class="widefat" />
		</p>

		<p>
		<label for="<?php echo $this->get_field_id( 'img1' ); ?>"><?php _e('صورة :', 'salahelimam') ?></label>
		<input id="<?php echo $this->get_field_id( 'img1' ); ?>" name="<?php echo $this->get_field_name( 'img1' ); ?>" value="<?php echo $instance['img1']; ?>" class="widefat" />
		</p>
        
		<p>
		<label for="<?php echo $this->get_field_id( 'link1' ); ?>"><?php _e('رابط :', 'salahelimam') ?></label>
		<input id="<?php echo $this->get_field_id( 'link1' ); ?>" name="<?php echo $this->get_field_name( 'link1' ); ?>" value="<?php echo $instance['link1']; ?>" class="widefat" />
		</p>

        
   <?php 
}
	} //end class