HEX
Server: Apache/2.4.49 (FreeBSD) OpenSSL/1.0.2s-freebsd PHP/5.6.36
System: FreeBSD hosting.icon.bg 11.3-RELEASE-p13 FreeBSD 11.3-RELEASE-p13 #0: Tue Sep 1 06:56:51 UTC 2020 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
User: ftpuser (1002)
PHP: 5.6.36
Disabled: NONE
Upload Files
File: /hosting/kak.bg/web/wp-content/themes/fp_santiago/framework/widgets/widget_adsingle.php
<?php
/**
 * Plugin Name: FairPixels: Single Ad Widget
 * Plugin URI: http://fairpixels.com
 * Description: Widget to display 300x300px ads in the sidebar of the theme.
 * Version: 1.0
 * Author: FairPixels
 * Author URI: http://fairpixels.com
 *
 */
 
 /**
 * Add function to widgets_init that'll load our widget.
 */
add_action('widgets_init','fairpixels_adsingle_widgets');

function fairpixels_adsingle_widgets(){
	register_widget("fairpixels_adsingle_widget");
}

/**
 * This class handles everything that needs to be handled with the widget:
 * the settings, form, display, and update.  Nice!
 *
 */
class fairpixels_adsingle_widget extends WP_widget{
	
	/**
	 * Widget setup.
	 */
	function fairpixels_adsingle_widget(){
		
		/* Widget settings. */
		$widget_ops = array('classname' => 'widget_adsingle', 'description' => 'Displays Single full size ad in the sidebar.');
		
		/* Create the widget. */
		$this->WP_Widget('fairpixels_adsingle_widget', 'FairPixels: 300x300px Ad', $widget_ops);		
	}
	
	/**
	 *display the widget on the screen.
	 */
	function widget($args,$instance){
		extract($args);
			$title = apply_filters('widget_title', $instance['title'] );
			$link = $instance['link'];
			$image = $instance['image'];
			
			echo $before_widget;
			
			if ( $title )
			echo $before_title . $title . $after_title;
			
			if($image) { ?>	
				<div class="outer-wrap">
					<div class="in-wrap">
						<a href="<?php echo $link; ?>"><img src="<?php echo $image; ?>" /></a>
					</div>
				</div>
	  <?php }
			echo $after_widget;
	}
	
	/**
	 * update widget settings
	 */
	function update($new_instance, $old_instance){
		$instance = $old_instance;
		$instance['title'] = strip_tags( $new_instance['title'] );
		$instance['link'] = $new_instance['link'];
		$instance['image'] = $new_instance['image'];
		
		return $instance;
	}
	
	/**
	 * Displays the widget settings controls on the widget panel.
	 * Make use of the get_field_id() and get_field_name() function
	 * when creating your form elements. This handles the confusing stuff.
	 */
	function form($instance){
		$defaults = array('title' => 'Sponsor', 'link' => '#', 'image' => get_template_directory_uri().'/images/ad.jpg');
		$instance = wp_parse_args((array) $instance, $defaults);
		?>	
		
		<p>			
			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'fairpixels') ?></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>
			<label for="<?php echo $this->get_field_id('link'); ?>"><?php _e('Link Url:', 'fairpixels') ?></label>
			<input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" value="<?php echo $instance['link']; ?>" />
		</p>
		
		<p>
			<label for="<?php echo $this->get_field_id('image'); ?>"><?php _e('Image URL:', 'fairpixels') ?></label>
			<input class="widefat" id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" value="<?php echo $instance['image']; ?>" />
		</p>
		<?php
	}
}
?>