?AlkantarClanX12

Your IP : 216.73.217.134


Current Path : /home/rankinh/reunionmag/wp-content/plugins/rubik-extension/widgets/
Upload File :
Current File : /home/rankinh/reunionmag/wp-content/plugins/rubik-extension/widgets/widget_youtube.php

<?php
/**
 * Add function to widgets_init that'll load our widget.
 */
add_action('widgets_init', 'bk_register_youtube_widget');

function bk_register_youtube_widget(){
	register_widget('bk_youtube_widget');
}

class bk_youtube_widget extends WP_Widget {
            
/**
 * Widget setup.
 */
	function __construct() {
		/* Widget settings. */
		$widget_ops = array( 'classname' => 'widget-youtube', 'description' => esc_html__('Displays Youtube Video in a Widget Holder.', 'rubik') );

		/* Create the widget. */
		parent::__construct('widget-youtube', esc_html__('BK: Youtube', 'rubik'), $widget_ops );
	}

	function widget( $args, $instance ) {
		extract($args);
		$title = apply_filters('widget_title', $instance['title'] );
		echo $before_widget;
        if ( $title ) {?>
            <div class="widget-title-wrap">
                <?php echo $before_title . esc_html($title) . $after_title;?>
            </div>
        <?php }
		$video_id = rubik_core::parse_youtube(esc_url( $instance['youtube_url'] ));
        ?>
            <div class="rubik-video-wrap">
                <iframe width="100%" src="http://www.youtube.com/embed/<?php echo esc_attr($video_id);?>" allowFullScreen ></iframe>
            </div>
		<?php

		echo $after_widget;
	}

	function update( $new_instance, $old_instance ) {
		$instance = $old_instance;
		$new_instance = wp_parse_args( (array) $new_instance, $this->default );
        $instance['title'] = strip_tags($new_instance['title']);
		$instance['youtube_url'] = strip_tags( $new_instance['youtube_url'] );

		return $instance;
	}

	function form( $instance ) {
        $defaults = array('title' => esc_html__('','rubik'), 'youtube_url' => 'http://');
		$instance = wp_parse_args((array) $instance, $defaults);
		$youtube_url = strip_tags( $instance['youtube_url'] );
?>
		<!-- Ads Image URL -->
        <p>
			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><strong><?php esc_html_e('Title:', 'rubik'); ?></strong></label>
			<input type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
		</p>
        
		<p>
			<label for="<?php echo $this->get_field_id('youtube_url'); ?>"><?php esc_html_e('Youtube Url:','rubik'); ?></label>
			<input class="widefat" id="<?php echo $this->get_field_id('youtube_url'); ?>" name="<?php echo $this->get_field_name('youtube_url'); ?>" type="text" value="<?php echo esc_attr($youtube_url); ?>" />
		</p>
<?php
	}
}