<?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' => 'مربع جانبى لعرض إعلان 225 × 225');
		$this->WP_Widget('ad_full','الوان الويب - اعلانات 225 × 225',$widget_ops);

		}
		
	function widget( $args, $instance ) {
		extract( $args );

		$title = apply_filters('widget_title', $instance['title'] );
		$img1 = $instance['img1'];
		$link1 = $instance['link1'];


		echo $before_widget;

		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 

		echo $after_widget;
	}
	
	function update( $new_instance, $old_instance ) {
		$instance = $old_instance;


		$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.'/ad225.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