<?php 

add_action('widgets_init','ads100');

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

class ads100 extends WP_Widget {
	function ads100() {
			
		$widget_ops = array('classname' => 'ads100','description' => 'مربع جانبى لعرض اعلانات مقاس 100 × 100 بكسل');
		$this->WP_Widget('ads125','الوان الويب - اعلانات 100 × 100',$widget_ops);

		}
		
	function widget( $args, $instance ) {
		extract( $args );
		/* User-selected settings. */
		$title = apply_filters('widget_title', $instance['title'] );
		$img1 = $instance['img1'];
		$link1 = $instance['link1'];
		$img2 = $instance['img2'];
		$link2 = $instance['link2'];
		$img3 = $instance['img3'];
		$link3 = $instance['link3'];
		$img4 = $instance['img4'];
		$link4 = $instance['link4'];
		$img5 = $instance['img5'];
		$link5 = $instance['link5'];
		$img6 = $instance['img6'];
		$link6 = $instance['link6'];
		$img7 = $instance['img7'];
		$link7 = $instance['link7'];
		$img8 = $instance['img8'];
		$link8 = $instance['link8'];
		echo $before_widget;

		if ( $title )
			echo $before_title . $title . $after_title;
?>
		   	    <div class="ads100">
        			  <?php if($img1!='') { ?>
			   <a href="<?php echo $link1 ?>"><img src="<?php echo $img1 ?>" alt="" /></a>
				<?php } ?>
			  <?php if($img2!='') { ?>
			   <a href="<?php echo $link2 ?>"><img src="<?php echo $img2 ?>" alt="" /></a>
				<?php } ?>
			  <?php if($img3!='') { ?>
			   <a href="<?php echo $link3 ?>"><img src="<?php echo $img3 ?>" alt="" /></a>
				<?php } ?>
			  <?php if($img4!='') { ?>
			   <a href="<?php echo $link4 ?>"><img src="<?php echo $img4 ?>" alt="" /></a>
				<?php } ?>
			  <?php if($img5!='') { ?>
               <a href="<?php echo $link5 ?>"><img src="<?php echo $img5 ?>" alt="" /></a>
				<?php } ?>
			  <?php if($img6!='') { ?>
			   <a href="<?php echo $link6 ?>"><img src="<?php echo $img6 ?>" alt="" /></a>
				<?php } ?>
			  <?php if($img7!='') { ?>
			   <a href="<?php echo $link7 ?>"><img src="<?php echo $img7 ?>" alt="" /></a>
				<?php } ?>
			  <?php if($img8!='') { ?>
			   <a href="<?php echo $link8 ?>"><img src="<?php echo $img8 ?>" alt="" /></a>
				<?php } ?>
  </div><!-- ads125 -->

			
<?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'];
		$instance['img2'] = $new_instance['img2'];
		$instance['link3'] = $new_instance['link3'];
		$instance['img3'] = $new_instance['img3'];
		$instance['link4'] = $new_instance['link4'];
		$instance['img4'] = $new_instance['img4'];
		$instance['link5'] = $new_instance['link5'];
		$instance['img5'] = $new_instance['img5'];
		$instance['link6'] = $new_instance['link6'];
		$instance['img6'] = $new_instance['img6'];
		$instance['link7'] = $new_instance['link7'];
		$instance['img7'] = $new_instance['img7'];
		$instance['link8'] = $new_instance['link8'];
		$instance['img8'] = $new_instance['img8'];

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

		/* Set up some default widget settings. */
		$defaults = array( 'title' => 'إعلانات', 
			'img1' => SalahElimam_IMG.'/ad100.png', 
			'link1' => '#',
			'img2' => SalahElimam_IMG.'/ad100.png', 
			'link2' => '#',
			'img3' => SalahElimam_IMG.'/ad100.png', 
			'link3' => '#',
			'img4' => SalahElimam_IMG.'/ad100.png', 
			'link4' => '#',
 			);
		$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('#1 صورة  : ', '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('#1 رابط : ', '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>

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

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

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

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

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

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

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



        
   <?php 
}
	} //end class