0
|
1 |
<?php |
|
2 |
/* |
|
3 |
|
|
4 |
Plugin Name: Video Widget |
|
5 |
Description: Plugin is used for playing videos. |
|
6 |
Author: |
|
7 |
Version: 1.0 |
|
8 |
Author URI: |
|
9 |
|
|
10 |
*/ |
|
11 |
|
|
12 |
class video_widget extends WP_Widget { |
|
13 |
|
|
14 |
|
|
15 |
/*-----------------------------------------------------------------------------------*/ |
|
16 |
/* Widget Setup |
|
17 |
/*-----------------------------------------------------------------------------------*/ |
|
18 |
|
16
|
19 |
function __construct() { |
0
|
20 |
|
|
21 |
$widget_options = array( |
|
22 |
'classname' => 'video_widget', |
|
23 |
'description' => 'Custom video widget.'); |
|
24 |
|
|
25 |
$control_options = array( //dodama svoje incializirane mere |
|
26 |
'width' => 200, |
|
27 |
'height' => 400, |
|
28 |
'id_base' => 'video_widget' |
|
29 |
); |
|
30 |
|
16
|
31 |
parent::__construct( 'video_widget', 'Video Widget', $widget_options, $control_options ); |
0
|
32 |
|
|
33 |
} |
|
34 |
|
|
35 |
|
|
36 |
function widget( $args, $instance ) { |
|
37 |
|
|
38 |
extract( $args ); |
|
39 |
$title = apply_filters('widget_title', $instance['title'] ); |
|
40 |
$embed_code = $instance['embed_code']; |
|
41 |
$description = $instance['description']; |
|
42 |
|
|
43 |
echo $before_widget; |
|
44 |
|
|
45 |
if ( $title ) |
|
46 |
{ |
|
47 |
echo $before_title; |
|
48 |
echo $title; |
|
49 |
echo $after_title; |
|
50 |
} |
|
51 |
?> |
|
52 |
<?php echo '<figure>'.$embed_code.'<figure/>'; |
|
53 |
|
|
54 |
if($description != '') |
|
55 |
{ |
|
56 |
echo '<div class="video_description">'.$description.'</div>'; |
|
57 |
} ?> |
|
58 |
<?php |
|
59 |
echo $after_widget; |
|
60 |
|
|
61 |
} |
|
62 |
function form( $instance ) { |
|
63 |
|
|
64 |
/* Set the default values */ |
|
65 |
$defaults = array( |
|
66 |
'title' => 'My video', |
|
67 |
'embed_code' => '<iframe src="http://player.vimeo.com/video/22556709?title=0&byline=0&portrait=0" width="170" height="96" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>', |
|
68 |
'description' => 'Opis videa', |
|
69 |
); |
|
70 |
$instance = wp_parse_args( (array) $instance, $defaults ); |
|
71 |
|
|
72 |
?> |
|
73 |
|
|
74 |
<label for="<?php echo $this->get_field_id( 'title' ); ?>"> |
|
75 |
<?php _e('Title:','pego_tr'); ?> |
|
76 |
<input class="widefat" type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" |
|
77 |
name="<?php echo $this->get_field_name( 'title' ); ?>" |
|
78 |
value="<?php echo $instance['title']; ?>" /> |
|
79 |
</label> |
|
80 |
|
|
81 |
|
|
82 |
<label for="<?php echo $this->get_field_id( 'embed_code' ); ?>"> |
|
83 |
<?php _e('Embed code:','pego_tr'); ?> |
|
84 |
<textarea class="widefat" type="text" id="<?php echo $this->get_field_id( 'embed_code' ); ?>" |
|
85 |
name="<?php echo $this->get_field_name( 'embed_code' ); ?>"><?php echo $instance['embed_code']; ?></textarea> |
|
86 |
</label> |
|
87 |
|
|
88 |
|
|
89 |
<label for="<?php echo $this->get_field_id( 'description' ); ?>"> |
|
90 |
<?php _e('Optional description:','pego_tr'); ?> |
|
91 |
<input class="widefat" type="text" id="<?php echo $this->get_field_id( 'description' ); ?>" |
|
92 |
name="<?php echo $this->get_field_name( 'description' ); ?>" |
|
93 |
value="<?php echo $instance['description']; ?>" /> |
|
94 |
</label> |
|
95 |
|
|
96 |
|
|
97 |
<?php |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
|
|
102 |
/* Adding widget to widgets_init and registering video widget */ |
|
103 |
add_action( 'widgets_init', 'video_widgets' ); |
|
104 |
|
|
105 |
function video_widgets() { |
|
106 |
register_widget( 'video_Widget' ); |
|
107 |
} |
|
108 |
?> |