| Server IP : 213.186.33.4 / Your IP : 216.73.216.222 Web Server : Apache System : Linux webm005.cluster103.gra.hosting.ovh.net 6.18.39-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Tue Jul 21 12:03:15 CEST 2026 x86_64 User : karinebmkh ( 644538) PHP Version : 8.4.22 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/karinebmkh/www2/wp-content/themes/thevoux-wp/inc/widgets/ |
Upload File : |
<?php
// thb Featured Video
class widget_thbfeaturedvideo extends WP_Widget {
function __construct() {
$widget_ops = array(
'classname' => 'widget_featured_video',
'description' => __('Display an embeded video on your sidebar','thevoux')
);
parent::__construct(
'thb_featuredvideo_widget',
__( 'Fuel Themes - Featured Video' , 'thevoux' ),
$widget_ops
);
$this->defaults = array( 'title' => 'Featured Video', 'embed' => '', 'video_title' => '' );
}
function widget($args, $instance) {
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$video_title = $instance['video_title'];
$embed = $instance['embed'];
global $wp_embed;
// Output
echo $before_widget;
echo ($title ? $before_title . $title . $after_title : '');
if ($video_title) {
echo '<h6>'.esc_attr($video_title).'</h6>';
}
echo $wp_embed->run_shortcode('[embed]'.$embed.'[/embed]');
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['video_title'] = strip_tags( $new_instance['video_title'] );
$instance['embed'] = strip_tags( $new_instance['embed'] );
return $instance;
}
// Settings form
function form($instance) {
$defaults = $this->defaults;
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e('Widget Title:', 'thevoux'); ?></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( 'video_title' ); ?>"><?php esc_html_e('Video Title:', 'thevoux'); ?></label>
<input id="<?php echo $this->get_field_id( 'video_title' ); ?>" name="<?php echo $this->get_field_name( 'video_title' ); ?>" value="<?php echo $instance['video_title']; ?>" style="width:100%;" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'embed' ); ?>"><?php esc_html_e('Video URL:', 'thevoux'); ?></label>
<input id="<?php echo $this->get_field_id( 'embed' ); ?>" name="<?php echo $this->get_field_name( 'embed' ); ?>" value="<?php echo $instance['embed']; ?>" class="widefat" />
</p>
<?php
}
}
function widget_thbfeaturedvideo_init()
{
register_widget('widget_thbfeaturedvideo');
}
add_action('widgets_init', 'widget_thbfeaturedvideo_init');