YouTube Channel - Version 3.0.8.8

Version Description

  • Fix: Link to channel enabled in Widget not shown if related link ID has not set in Widget (ignored general settings).
  • Fix: Undefined notices
Download this release

Release Info

Developer urkekg
Plugin Icon YouTube Channel
Version 3.0.8.8
Comparing to
See all releases

Code changes from version 3.0.8.7 to 3.0.8.8

Files changed (3) hide show
  1. inc/widget.php +137 -135
  2. readme.txt +11 -1
  3. youtube-channel.php +28 -9
inc/widget.php CHANGED
@@ -13,7 +13,7 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
13
  'description' => __(
14
  'Serve YouTube videos from channel or playlist right to widget area',
15
  'youtube-channel'
16
- )
17
  )
18
  );
19
  }
@@ -23,230 +23,232 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
23
  // outputs the content of the widget
24
  extract( $args );
25
 
26
- $title = apply_filters('widget_title', $instance['title']);
27
 
28
  $output = array();
29
  $output[] = $before_widget;
30
- if ( $title ) $output[] = $before_title . $title . $after_title;
31
- $output[] = implode($WPAU_YOUTUBE_CHANNEL->output($instance));
 
 
32
  $output[] = $after_widget;
33
 
34
- echo implode('', array_values($output));
35
  }
36
 
37
  public function form($instance) {
38
  global $WPAU_YOUTUBE_CHANNEL;
39
- $defaults = get_option('youtube_channel_defaults');
40
 
41
  // outputs the options form for widget settings
42
  // General Options
43
- $title = (!empty($instance['title'])) ? esc_attr($instance['title']) : '';
44
- $class = (!empty($instance['class'])) ? esc_attr($instance['class']) : '';
45
- $vanity = (!empty($instance['vanity']) ) ? esc_attr($instance['vanity']) : '';
46
- $channel = (!empty($instance['channel'])) ? esc_attr($instance['channel']) : '';
47
- $username = (!empty($instance['username'])) ? esc_attr($instance['username']) : '';
48
- $playlist = (!empty($instance['playlist'])) ? esc_attr($instance['playlist']) : '';
49
 
50
- $resource = (!empty($instance['resource'])) ? esc_attr($instance['resource']) : 0; // resource to use: channel, favorites, playlist
51
 
52
- $cache = (!empty($instance['cache'])) ? esc_attr($instance['cache']) : trim($defaults['cache']);
53
 
54
- $fetch = (!empty($instance['fetch'])) ? esc_attr($instance['fetch']) : trim($defaults['fetch']); // items to fetch
55
- $num = (!empty($instance['num'])) ? esc_attr($instance['num']) : trim($defaults['num']); // number of items to show
56
 
57
- $privacy = (!empty($instance['privacy'])) ? esc_attr($instance['privacy']) : 0;
58
- $random = (!empty($instance['random'])) ? esc_attr($instance['random']) : 0;
59
 
60
  // Video Settings
61
- $ratio = (!empty($instance['ratio'])) ? esc_attr($instance['ratio']) : trim($defaults['ratio']);
62
- $width = (!empty($instance['width'])) ? esc_attr($instance['width']) : trim($defaults['width']);
63
- $responsive = (isset($instance['responsive'])) ? esc_attr($instance['responsive']) : 1;
64
 
65
- $display = (!empty($instance['display'])) ? esc_attr($instance['display']) : trim($defaults['display']);
66
- $no_thumb_title = (!empty($instance['no_thumb_title'])) ? esc_attr($instance['no_thumb_title']) : 0;
67
 
68
- $themelight = (!empty($instance['themelight'])) ? esc_attr($instance['themelight']) : '';
69
- $controls = (!empty($instance['controls'])) ? esc_attr($instance['controls']) : '';
70
- $autoplay = (!empty($instance['autoplay'])) ? esc_attr($instance['autoplay']) : '';
71
- $autoplay_mute = (!empty($instance['autoplay_mute'])) ? esc_attr($instance['autoplay_mute']) : '';
72
- $norel = (!empty($instance['norel'])) ? esc_attr($instance['norel']) : '';
73
 
74
  // Content Layout
75
- $showtitle = (!empty($instance['showtitle'])) ? esc_attr($instance['showtitle']) : 'none';
76
- $showdesc = (!empty($instance['showdesc'])) ? esc_attr($instance['showdesc']) : '';
77
- $modestbranding = (!empty($instance['modestbranding'])) ? esc_attr($instance['modestbranding']) : '';
78
- $desclen = (!empty($instance['desclen'])) ? esc_attr($instance['desclen']) : 0;
79
 
80
- $hideanno = (!empty($instance['hideanno'])) ? esc_attr($instance['hideanno']) : '';
81
- $hideinfo = (!empty($instance['hideinfo'])) ? esc_attr($instance['hideinfo']) : '';
82
 
83
  // Link to Channel
84
- $link_to = (!empty($instance['link_to'])) ? esc_attr($instance['link_to']) : 'none';
85
- $goto_txt = (!empty($instance['goto_txt'])) ? esc_attr($instance['goto_txt']) : '';
86
- $popup_goto = (!empty($instance['popup_goto'])) ? esc_attr($instance['popup_goto']) : '';
87
  ?>
88
 
89
  <p>
90
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title', 'youtube-channel'); ?>
91
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" title="<?php _e('Title for widget', 'youtube-channel'); ?>" />
92
  </label>
93
  </p>
94
  <p>
95
- <label for="<?php echo $this->get_field_id('class'); ?>"><?php _e('Custom CSS Class', 'youtube-channel'); ?>
96
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('class'); ?>" name="<?php echo $this->get_field_name('class'); ?>" value="<?php echo $class; ?>" title="<?php _e('Enter custom class for YTC block, if you wish to target block styling', 'youtube-channel'); ?>" />
97
  </label>
98
  </p>
99
  <p><?php
100
  printf(
101
  wp_kses(
102
  __(
103
- 'Get your %1$s and %2$s from <a href="%3$s" target="_blank">here</a>.',
104
- 'youtube-channel'
105
- ),
106
  array( 'a' => array( 'href' => array() ) )
107
  ),
108
- __('Channel ID', 'youtube-channel'),
109
- __('Custom ID', 'youtube-channel'),
110
  'https://www.youtube.com/account_advanced'
111
  );
112
  ?></p>
113
  <p class="half left glue-top">
114
- <label for="<?php echo $this->get_field_id('vanity'); ?>"><?php _e('Vanity/Custom ID', 'youtube-channel'); ?>
115
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('vanity'); ?>" name="<?php echo $this->get_field_name('vanity'); ?>" value="<?php echo $vanity; ?>" title="<?php _e('YouTube Vanity/Custom ID from URL (part after /c/)', 'youtube-channel'); ?>" />
116
  </label>
117
  </p>
118
  <p class="half right glue-top">
119
- <label for="<?php echo $this->get_field_id('channel'); ?>"><?php _e('Channel ID', 'youtube-channel'); ?>
120
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('channel'); ?>" name="<?php echo $this->get_field_name('channel'); ?>" value="<?php echo $channel; ?>" title="<?php _e('Find Channel ID behind My Channel menu item in YouTube (ID have UC at the beginning)', 'youtube-channel'); ?>" />
121
  </label>
122
  </p>
123
  <p class="half left glue-top">
124
- <label for="<?php echo $this->get_field_id('username'); ?>"><?php _e('Legacy Username', 'youtube-channel'); ?>
125
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('username'); ?>" name="<?php echo $this->get_field_name('username'); ?>" value="<?php echo $username; ?>" title="<?php _e('Legacy YouTube username located behind /user/ part of channel URL (available only on old YouTube accounts)', 'youtube-channel'); ?>" />
126
  </label>
127
  </p>
128
  <p class="half right glue-top">
129
- <label for="<?php echo $this->get_field_id('playlist'); ?>"><?php _e('Playlist ID', 'youtube-channel'); ?>
130
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('playlist'); ?>" name="<?php echo $this->get_field_name('playlist'); ?>" value="<?php echo $playlist; ?>" title="<?php _e('Find Playlist ID in your playlists (ID have PL at the beginning)', 'youtube-channel'); ?>" />
131
  </label>
132
  </p>
133
  <p class="half left glue-top">
134
- <label for="<?php echo $this->get_field_id('resource'); ?>"><?php _e('Resource to use', 'youtube-channel'); ?>
135
  <select class="widefat" id="<?php echo $this->get_field_id( 'resource' ); ?>" name="<?php echo $this->get_field_name( 'resource' ); ?>">
136
- <option value="0"<?php selected( $resource, 0 ); ?>><?php _e('Channel (User Uploads)', 'youtube-channel'); ?></option>
137
- <option value="1"<?php selected( $resource, 1 ); ?>><?php _e('Favourites', 'youtube-channel'); ?></option>
138
- <option value="3"<?php selected( $resource, 3 ); ?>><?php _e('Liked Videos', 'youtube-channel'); ?></option>
139
- <option value="2"<?php selected( $resource, 2 ); ?>><?php _e('Playlist', 'youtube-channel'); ?></option>
140
  </select>
141
  </label>
142
  </p>
143
  <p class="half right glue-top">
144
- <label for="<?php echo $this->get_field_id('cache'); ?>"><?php _e('Cache feed', 'youtube-channel'); ?>
145
  <select class="widefat" id="<?php echo $this->get_field_id( 'cache' ); ?>" name="<?php echo $this->get_field_name( 'cache' ); ?>">
146
- <option value="0"<?php selected( $cache, 0 ); ?>><?php _e('Do not cache', 'youtube-channel'); ?></option>
147
- <?php echo $WPAU_YOUTUBE_CHANNEL->cache_time($cache); ?>
148
  </select>
149
  </label>
150
  </p>
151
  <p class="half left glue-top">
152
- <label for="<?php echo $this->get_field_id('fetch'); ?>"><?php _e('Fetch', 'youtube-channel'); ?> <input class="small-text" id="<?php echo $this->get_field_id('fetch'); ?>" name="<?php echo $this->get_field_name('fetch'); ?>" type="number" min="2" value="<?php echo $fetch; ?>" title="<?php _e('Number of videos that will be used for random pick (min 2, max 50, default 25)', 'youtube-channel'); ?>" /> <?php _e('video(s)', 'youtube-channel'); ?></label>
153
  </p>
154
  <p class="half right glue-top">
155
- <label for="<?php echo $this->get_field_id('num'); ?>"><?php _e('Show', 'youtube-channel'); ?></label> <input class="small-text" id="<?php echo $this->get_field_id('num'); ?>" name="<?php echo $this->get_field_name('num'); ?>" type="number" min="1" value="<?php echo ( $num ) ? $num : '1'; ?>" title="<?php _e('Number of videos to display', 'youtube-channel'); ?>" /> <?php _e('video(s)', 'youtube-channel'); ?>
156
  </p>
157
  <p>
158
- <input class="checkbox" type="checkbox" <?php checked( (bool) $privacy, true ); ?> id="<?php echo $this->get_field_id( 'privacy' ); ?>" name="<?php echo $this->get_field_name( 'privacy' ); ?>" title="<?php _e('Enable this option to protect your visitors privacy', 'youtube-channel'); ?>" /> <label for="<?php echo $this->get_field_id( 'privacy' ); ?>"><?php printf(__('Enable <a href="%s" target="_blank">privacy-enhanced mode</a>', 'youtube-channel'), 'http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780'); ?></label>
159
  <br />
160
- <input class="checkbox" type="checkbox" <?php checked( (bool) $random, true ); ?> id="<?php echo $this->get_field_id( 'random' ); ?>" name="<?php echo $this->get_field_name( 'random' ); ?>" title="<?php _e('Get random videos of all fetched from channel or playlist', 'youtube-channel'); ?>" /> <label for="<?php echo $this->get_field_id( 'random' ); ?>"><?php _e('Show random video from resource <small>(Have no effect if "What to show?" has been set to "Embedded Playlist")</small>', 'youtube-channel'); ?></label>
161
  </p>
162
 
163
- <h4><?php _e('Video Settings', 'youtube-channel'); ?></h4>
164
- <p><label for="<?php echo $this->get_field_id('ratio'); ?>"><?php _e('Aspect ratio', 'youtube-channel'); ?></label>
165
  <select class="widefat" id="<?php echo $this->get_field_id( 'ratio' ); ?>" name="<?php echo $this->get_field_name( 'ratio' ); ?>">
166
  <option value="3"<?php selected( $ratio, 3 ); ?>>16:9</option>
167
  <option value="1"<?php selected( $ratio, 1 ); ?>>4:3</option>
168
  </select><br />
169
- <input class="checkbox" type="checkbox" <?php checked( (bool) $responsive, true ); ?> id="<?php echo $this->get_field_id( 'responsive' ); ?>" name="<?php echo $this->get_field_name( 'responsive' ); ?>" /> <label for="<?php echo $this->get_field_id( 'responsive' ); ?>"><?php _e('Responsive video <small>(distribute one full width item per row)</small>', 'youtube-channel'); ?></label>
170
  </p>
171
  <p>
172
- <label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Initial width', 'youtube-channel'); ?></label> <input class="small-text" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="number" min="32" value="<?php echo $width; ?>" title="<?php _e('Set video width in pixels', 'youtube-channel'); ?>" /> px (<?php _e('default', 'youtube-channel'); ?> 306)
173
  </p>
174
  <p>
175
- <label for="<?php echo $this->get_field_id('display'); ?>">
176
- <?php _e('What to display?', 'youtube-channel'); ?>
177
  </label>
178
  <select class="widefat" id="<?php echo $this->get_field_id( 'display' ); ?>" name="<?php echo $this->get_field_name( 'display' ); ?>">
179
- <option value="thumbnail"<?php selected( $display, 'thumbnail' ); ?>><?php _e('Thumbnail', 'youtube-channel'); ?></option>
180
- <option value="iframe"<?php selected( $display, 'iframe' ); ?>><?php _e('HTML5 (iframe)', 'youtube-channel'); ?></option>
181
- <option value="iframe2"<?php selected( $display, 'iframe2' ); ?>><?php _e('HTML5 (iframe) Asynchronous', 'youtube-channel'); ?></option>
182
- <option value="playlist"<?php selected( $display, 'playlist' ); ?>><?php _e('Embedded Playlist', 'youtube-channel'); ?></option>
183
  </select>
184
- <input class="checkbox" type="checkbox" <?php checked( (bool) $no_thumb_title, true ); ?> id="<?php echo $this->get_field_id( 'no_thumb_title' ); ?>" name="<?php echo $this->get_field_name( 'no_thumb_title' ); ?>" /> <label for="<?php echo $this->get_field_id( 'no_thumb_title' ); ?>"><?php _e('Hide thumbnail tooltip', 'youtube-channel'); ?></label><br />
185
- <input class="checkbox" type="checkbox" <?php checked( (bool) $themelight, true ); ?> id="<?php echo $this->get_field_id( 'themelight' ); ?>" name="<?php echo $this->get_field_name( 'themelight' ); ?>" /> <label for="<?php echo $this->get_field_id( 'themelight' ); ?>"><?php _e('Use light theme (default is dark)', 'youtube-channel'); ?></label><br />
186
- <input class="checkbox" type="checkbox" <?php checked( (bool) $controls, true ); ?> id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" /> <label for="<?php echo $this->get_field_id( 'controls' ); ?>"><?php _e('Hide player controls', 'youtube-channel'); ?></label><br />
187
- <input class="checkbox" type="checkbox" <?php checked( (bool) $autoplay, true ); ?> id="<?php echo $this->get_field_id( 'autoplay' ); ?>" name="<?php echo $this->get_field_name( 'autoplay' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay' ); ?>"><?php _e('Autoplay video or playlist', 'youtube-channel'); ?></label><br />
188
- <input class="checkbox" type="checkbox" <?php checked( (bool) $autoplay_mute, true ); ?> id="<?php echo $this->get_field_id( 'autoplay_mute' ); ?>" name="<?php echo $this->get_field_name( 'autoplay_mute' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay_mute' ); ?>"><?php _e('Mute video on autoplay', 'youtube-channel'); ?></label><br />
189
- <input class="checkbox" type="checkbox" <?php checked( (bool) $norel, true ); ?> id="<?php echo $this->get_field_id( 'norel' ); ?>" name="<?php echo $this->get_field_name( 'norel' ); ?>" /> <label for="<?php echo $this->get_field_id( 'norel' ); ?>"><?php _e('Hide related videos', 'youtube-channel'); ?></label><br />
190
- <input class="checkbox" type="checkbox" <?php checked( (bool) $modestbranding, true ); ?> id="<?php echo $this->get_field_id( 'modestbranding' ); ?>" name="<?php echo $this->get_field_name( 'modestbranding' ); ?>" /> <label for="<?php echo $this->get_field_id( 'modestbranding' ); ?>"><?php _e('Hide YT Logo (does not work for all videos)', 'youtube-channel'); ?></label><br />
191
  </p>
192
 
193
- <h4><?php _e('Content Layout', 'youtube-channel'); ?></h4>
194
  <p>
195
  <label for="<?php echo $this->get_field_id( 'showtitle' ); ?>">
196
- <?php _e('Show video title', 'youtube-channel'); ?>
197
  </label>
198
  <select class="widefat" id="<?php echo $this->get_field_id( 'showtitle' ); ?>" name="<?php echo $this->get_field_name( 'showtitle' ); ?>">
199
- <option value="none"<?php selected( $showtitle, 'none' ); ?>><?php _e('Hide title', 'youtube-channel'); ?></option>
200
- <option value="above"<?php selected( $showtitle, 'above' ); ?>><?php _e('Above video/thumbnail', 'youtube-channel'); ?></option>
201
- <option value="below"<?php selected( $showtitle, 'below' ); ?>><?php _e('Below video/thumbnail', 'youtube-channel'); ?></option>
202
  </select><br />
203
  <label for="<?php echo $this->get_field_id( 'showdesc' ); ?>">
204
- <input class="checkbox" type="checkbox" <?php checked( (bool) $showdesc, true ); ?> id="<?php echo $this->get_field_id('showdesc'); ?>" name="<?php echo $this->get_field_name( 'showdesc' ); ?>" /> <?php _e('Show video description', 'youtube-channel'); ?>
205
  </label><br />
206
- <label for="<?php echo $this->get_field_id('desclen'); ?>"><?php _e('Description length', 'youtube-channel'); ?>
207
- <input class="small-text" id="<?php echo $this->get_field_id('desclen'); ?>" name="<?php echo $this->get_field_name('desclen'); ?>" type="number" value="<?php echo $desclen; ?>" title="<?php _e('Set number of characters to cut down video description to (0 means full length)', 'youtube-channel');?>" /> (0 = full)
208
  </label><br />
209
  <label for="<?php echo $this->get_field_id( 'hideanno' ); ?>">
210
- <input class="checkbox" type="checkbox" <?php checked( (bool) $hideanno, true ); ?> id="<?php echo $this->get_field_id('hideanno'); ?>" name="<?php echo $this->get_field_name( 'hideanno' ); ?>" /> <?php _e('Hide annotations from video', 'youtube-channel'); ?>
211
  </label><br />
212
- <label for="<?php echo $this->get_field_id( 'hideinfo' ); ?>" title="<?php _e('Enabling this option causes the player to not display information like the video title and uploader before the video starts playing.'); ?>">
213
- <input class="checkbox" type="checkbox" <?php checked( (bool) $hideinfo, true ); ?> id="<?php echo $this->get_field_id('hideinfo'); ?>" name="<?php echo $this->get_field_name( 'hideinfo' ); ?>" /> <?php _e('Hide video info', 'youtube-channel'); ?>
214
  </label>
215
  </p>
216
 
217
- <h4><?php _e('Link to Channel', 'youtube-channel'); ?></h4>
218
  <p class="glue-top">
219
- <input class="widefat" id="<?php echo $this->get_field_id('goto_txt'); ?>" name="<?php echo $this->get_field_name('goto_txt'); ?>" type="text" value="<?php echo $goto_txt; ?>" title="<?php _e('Default: Visit our YouTube channel. You can use placeholders %vanity%, %channel% and %username%.', 'youtube-channel'); ?>" placeholder="<?php _e('Visit our YouTube channel', 'youtube-channel'); ?>" />
220
  </p>
221
  <p class="half left glue-top">
222
  <select class="widefat" id="<?php echo $this->get_field_id( 'link_to' ); ?>" name="<?php echo $this->get_field_name( 'link_to' ); ?>">
223
- <option value="none"<?php selected( $link_to, 'none' ); ?>><?php _e('Hide link', 'youtube-channel'); ?></option>
224
- <option value="vanity"<?php selected( $link_to, 'vanity' ); ?>><?php _e('Link to Vanity customized URL', 'youtube-channel'); ?></option>
225
- <option value="channel"<?php selected( $link_to, 'channel' ); ?>><?php _e('Link to Channel page URL', 'youtube-channel'); ?></option>
226
- <option value="legacy"<?php selected( $link_to, 'legacy' ); ?>><?php _e('Link to Legacy username page', 'youtube-channel'); ?></option>
227
  </select>
228
  </p>
229
  <p class="half right glue-top">
230
  <select class="widefat" id="<?php echo $this->get_field_id( 'popup_goto' ); ?>" name="<?php echo $this->get_field_name( 'popup_goto' ); ?>">
231
- <option value="0"<?php selected( $popup_goto, 0 ); ?>><?php _e('Open link in same window', 'youtube-channel'); ?></option>
232
- <option value="1"<?php selected( $popup_goto, 1 ); ?>><?php _e('Open link in new window (JavaScript)', 'youtube-channel'); ?></option>
233
- <option value="2"<?php selected( $popup_goto, 2 ); ?>><?php _e('Open link in new window (target="blank")', 'youtube-channel'); ?></option>
234
  </select>
235
  </p>
236
 
237
- <h4><?php _e('Does not work?', 'youtube-channel'); ?></h4>
238
  <p>
239
  <small><?php
240
  printf(
241
  wp_kses(
242
  __(
243
- 'Carefully read <a href="%1$s" target="_faq">%2$s</a> before you contact us. If that does not help, <a href="%3$s" target="_blank">get JSON file</a> and send it to <a href="%4$s" target="_support">support forum</a> along with other details noted in <a href="%5$s" target=_blank">this article</a>.',
244
- 'youtube-channel'
245
  ),
246
- array( 'a' => array( 'href' => array() ) )
247
  ),
248
  'https://wordpress.org/plugins/youtube-channel/faq/',
249
- __('FAQ', 'youtube-channel'),
250
  "?ytc_debug_json_for={$this->number}",
251
  'http://wordpress.org/support/plugin/youtube-channel',
252
  'https://wordpress.org/support/topic/ytc3-read-before-you-post-support-question-or-report-bug'
@@ -259,41 +261,41 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
259
  public function update($new_instance, $old_instance) {
260
  // processes widget options to be saved
261
  $instance = $old_instance;
262
- $instance['title'] = strip_tags($new_instance['title']);
263
- $instance['class'] = strip_tags($new_instance['class']);
264
- $instance['channel'] = strip_tags($new_instance['channel']);
265
- $instance['username'] = strip_tags($new_instance['username']);
266
- $instance['playlist'] = strip_tags($new_instance['playlist']);
267
- $instance['vanity'] = strip_tags($new_instance['vanity']);
268
  $instance['num'] = $new_instance['num'];
269
  $instance['resource'] = $new_instance['resource'];
270
  $instance['cache'] = $new_instance['cache'];
271
- $instance['random'] = (isset($new_instance['random'])) ? $new_instance['random'] : false;
272
  $instance['fetch'] = $new_instance['fetch'];
273
 
274
- $instance['goto_txt'] = strip_tags($new_instance['goto_txt']);
275
  $instance['popup_goto'] = $new_instance['popup_goto'];
276
  $instance['link_to'] = $new_instance['link_to'];
277
 
278
- $instance['showtitle'] = (isset($new_instance['showtitle'])) ? $new_instance['showtitle'] : 'none';
279
- $instance['showdesc'] = (isset($new_instance['showdesc'])) ? $new_instance['showdesc'] : false;
280
- $instance['desclen'] = strip_tags($new_instance['desclen']);
281
- $instance['width'] = strip_tags($new_instance['width']);
282
- $instance['responsive'] = (isset($new_instance['responsive'])) ? $new_instance['responsive'] : '';
283
-
284
- $instance['display'] = strip_tags($new_instance['display']);
285
- $instance['no_thumb_title'] = (isset($new_instance['no_thumb_title'])) ? $new_instance['no_thumb_title'] : false;
286
- $instance['autoplay'] = (isset($new_instance['autoplay'])) ? $new_instance['autoplay'] : false;
287
- $instance['autoplay_mute'] = (isset($new_instance['autoplay_mute'])) ? $new_instance['autoplay_mute'] : false;
288
- $instance['norel'] = (isset($new_instance['norel'])) ? $new_instance['norel'] : false;
289
- $instance['modestbranding'] = (isset($new_instance['modestbranding'])) ? $new_instance['modestbranding'] : false;
290
-
291
- $instance['controls'] = (isset($new_instance['controls'])) ? $new_instance['controls'] : false;
292
- $instance['ratio'] = strip_tags($new_instance['ratio']);
293
- $instance['hideinfo'] = (isset($new_instance['hideinfo'])) ? $new_instance['hideinfo'] : '';
294
- $instance['hideanno'] = (isset($new_instance['hideanno'])) ? $new_instance['hideanno'] : '';
295
- $instance['themelight'] = (isset($new_instance['themelight'])) ? $new_instance['themelight'] : '';
296
- $instance['privacy'] = (isset($new_instance['privacy'])) ? $new_instance['privacy'] : '';
297
 
298
  return $instance;
299
  }
13
  'description' => __(
14
  'Serve YouTube videos from channel or playlist right to widget area',
15
  'youtube-channel'
16
+ ),
17
  )
18
  );
19
  }
23
  // outputs the content of the widget
24
  extract( $args );
25
 
26
+ $title = ( ! empty( $instance['title'] ) ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
27
 
28
  $output = array();
29
  $output[] = $before_widget;
30
+ if ( $title ) {
31
+ $output[] = $before_title . $title . $after_title;
32
+ }
33
+ $output[] = implode( $WPAU_YOUTUBE_CHANNEL->output( $instance ) );
34
  $output[] = $after_widget;
35
 
36
+ echo implode( '', array_values( $output ) );
37
  }
38
 
39
  public function form($instance) {
40
  global $WPAU_YOUTUBE_CHANNEL;
41
+ $defaults = get_option( 'youtube_channel_defaults' );
42
 
43
  // outputs the options form for widget settings
44
  // General Options
45
+ $title = ( ! empty( $instance['title'] ) ) ? esc_attr( $instance['title'] ) : '';
46
+ $class = ( ! empty( $instance['class'] ) ) ? esc_attr( $instance['class'] ) : '';
47
+ $vanity = ( ! empty( $instance['vanity'] ) ) ? esc_attr( $instance['vanity'] ) : '';
48
+ $channel = ( ! empty( $instance['channel'] ) ) ? esc_attr( $instance['channel'] ) : '';
49
+ $username = ( ! empty( $instance['username'] ) ) ? esc_attr( $instance['username'] ) : '';
50
+ $playlist = ( ! empty( $instance['playlist'] ) ) ? esc_attr( $instance['playlist'] ) : '';
51
 
52
+ $resource = ( ! empty( $instance['resource'] ) ) ? esc_attr( $instance['resource'] ) : 0; // resource to use: channel, favorites, playlist
53
 
54
+ $cache = ( ! empty( $instance['cache'] ) ) ? esc_attr( $instance['cache'] ) : trim( $defaults['cache'] );
55
 
56
+ $fetch = ( ! empty( $instance['fetch'] ) ) ? esc_attr( $instance['fetch'] ) : trim( $defaults['fetch'] ); // items to fetch
57
+ $num = ( ! empty( $instance['num'] ) ) ? esc_attr( $instance['num'] ) : trim( $defaults['num'] ); // number of items to show
58
 
59
+ $privacy = ( ! empty( $instance['privacy'] ) ) ? esc_attr( $instance['privacy'] ) : 0;
60
+ $random = ( ! empty( $instance['random'] ) ) ? esc_attr( $instance['random'] ) : 0;
61
 
62
  // Video Settings
63
+ $ratio = ( ! empty( $instance['ratio'] ) ) ? esc_attr( $instance['ratio'] ) : trim( $defaults['ratio'] );
64
+ $width = ( ! empty( $instance['width'] ) ) ? esc_attr( $instance['width'] ) : trim( $defaults['width'] );
65
+ $responsive = ( isset( $instance['responsive'] ) ) ? esc_attr( $instance['responsive'] ) : 1;
66
 
67
+ $display = ( ! empty( $instance['display'] ) ) ? esc_attr( $instance['display'] ) : trim( $defaults['display'] );
68
+ $no_thumb_title = ( ! empty( $instance['no_thumb_title'] ) ) ? esc_attr( $instance['no_thumb_title'] ) : 0;
69
 
70
+ $themelight = ( ! empty( $instance['themelight'] ) ) ? esc_attr( $instance['themelight'] ) : '';
71
+ $controls = ( ! empty( $instance['controls'] ) ) ? esc_attr( $instance['controls'] ) : '';
72
+ $autoplay = ( ! empty( $instance['autoplay'] ) ) ? esc_attr( $instance['autoplay'] ) : '';
73
+ $autoplay_mute = ( ! empty( $instance['autoplay_mute'] ) ) ? esc_attr( $instance['autoplay_mute'] ) : '';
74
+ $norel = ( ! empty( $instance['norel'] ) ) ? esc_attr( $instance['norel'] ) : '';
75
 
76
  // Content Layout
77
+ $showtitle = ( ! empty( $instance['showtitle'] ) ) ? esc_attr( $instance['showtitle'] ) : 'none';
78
+ $showdesc = ( ! empty( $instance['showdesc'] ) ) ? esc_attr( $instance['showdesc'] ) : '';
79
+ $modestbranding = ( ! empty( $instance['modestbranding'] ) ) ? esc_attr( $instance['modestbranding'] ) : '';
80
+ $desclen = ( ! empty( $instance['desclen'] ) ) ? esc_attr( $instance['desclen'] ) : 0;
81
 
82
+ $hideanno = ( ! empty( $instance['hideanno'] ) ) ? esc_attr( $instance['hideanno'] ) : '';
83
+ $hideinfo = ( ! empty( $instance['hideinfo'] ) ) ? esc_attr( $instance['hideinfo'] ) : '';
84
 
85
  // Link to Channel
86
+ $link_to = ( ! empty( $instance['link_to'] ) ) ? esc_attr( $instance['link_to'] ) : 'none';
87
+ $goto_txt = ( ! empty( $instance['goto_txt'] ) ) ? esc_attr( $instance['goto_txt'] ) : '';
88
+ $popup_goto = ( ! empty( $instance['popup_goto'] ) ) ? esc_attr( $instance['popup_goto'] ) : '';
89
  ?>
90
 
91
  <p>
92
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Widget Title', 'youtube-channel' ); ?>
93
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $title; ?>" title="<?php _e( 'Title for widget', 'youtube-channel' ); ?>" />
94
  </label>
95
  </p>
96
  <p>
97
+ <label for="<?php echo $this->get_field_id( 'class' ); ?>"><?php _e( 'Custom CSS Class', 'youtube-channel' ); ?>
98
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'class' ); ?>" name="<?php echo $this->get_field_name( 'class' ); ?>" value="<?php echo $class; ?>" title="<?php _e( 'Enter custom class for YTC block, if you wish to target block styling', 'youtube-channel' ); ?>" />
99
  </label>
100
  </p>
101
  <p><?php
102
  printf(
103
  wp_kses(
104
  __(
105
+ 'Get your %1$s and %2$s from <a href="%3$s" target="_blank">here</a>.',
106
+ 'youtube-channel'
107
+ ),
108
  array( 'a' => array( 'href' => array() ) )
109
  ),
110
+ __( 'Channel ID', 'youtube-channel' ),
111
+ __( 'Custom ID', 'youtube-channel' ),
112
  'https://www.youtube.com/account_advanced'
113
  );
114
  ?></p>
115
  <p class="half left glue-top">
116
+ <label for="<?php echo $this->get_field_id( 'vanity' ); ?>"><?php _e( 'Vanity/Custom ID', 'youtube-channel' ); ?>
117
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'vanity' ); ?>" name="<?php echo $this->get_field_name( 'vanity' ); ?>" value="<?php echo $vanity; ?>" title="<?php _e( 'YouTube Vanity/Custom ID from URL (part after /c/)', 'youtube-channel' ); ?>" />
118
  </label>
119
  </p>
120
  <p class="half right glue-top">
121
+ <label for="<?php echo $this->get_field_id( 'channel' ); ?>"><?php _e( 'Channel ID', 'youtube-channel' ); ?>
122
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'channel' ); ?>" name="<?php echo $this->get_field_name( 'channel' ); ?>" value="<?php echo $channel; ?>" title="<?php _e( 'Find Channel ID behind My Channel menu item in YouTube (ID have UC at the beginning)', 'youtube-channel' ); ?>" />
123
  </label>
124
  </p>
125
  <p class="half left glue-top">
126
+ <label for="<?php echo $this->get_field_id( 'username' ); ?>"><?php _e( 'Legacy Username', 'youtube-channel' ); ?>
127
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'username' ); ?>" name="<?php echo $this->get_field_name( 'username' ); ?>" value="<?php echo $username; ?>" title="<?php _e( 'Legacy YouTube username located behind /user/ part of channel URL (available only on old YouTube accounts)', 'youtube-channel' ); ?>" />
128
  </label>
129
  </p>
130
  <p class="half right glue-top">
131
+ <label for="<?php echo $this->get_field_id( 'playlist' ); ?>"><?php _e( 'Playlist ID', 'youtube-channel' ); ?>
132
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'playlist' ); ?>" name="<?php echo $this->get_field_name( 'playlist' ); ?>" value="<?php echo $playlist; ?>" title="<?php _e( 'Find Playlist ID in your playlists (ID have PL at the beginning)', 'youtube-channel' ); ?>" />
133
  </label>
134
  </p>
135
  <p class="half left glue-top">
136
+ <label for="<?php echo $this->get_field_id( 'resource' ); ?>"><?php _e( 'Resource to use', 'youtube-channel' ); ?>
137
  <select class="widefat" id="<?php echo $this->get_field_id( 'resource' ); ?>" name="<?php echo $this->get_field_name( 'resource' ); ?>">
138
+ <option value="0"<?php selected( $resource, 0 ); ?>><?php _e( 'Channel (User Uploads)', 'youtube-channel' ); ?></option>
139
+ <option value="1"<?php selected( $resource, 1 ); ?>><?php _e( 'Favourites', 'youtube-channel' ); ?></option>
140
+ <option value="3"<?php selected( $resource, 3 ); ?>><?php _e( 'Liked Videos', 'youtube-channel' ); ?></option>
141
+ <option value="2"<?php selected( $resource, 2 ); ?>><?php _e( 'Playlist', 'youtube-channel' ); ?></option>
142
  </select>
143
  </label>
144
  </p>
145
  <p class="half right glue-top">
146
+ <label for="<?php echo $this->get_field_id( 'cache' ); ?>"><?php _e( 'Cache feed', 'youtube-channel' ); ?>
147
  <select class="widefat" id="<?php echo $this->get_field_id( 'cache' ); ?>" name="<?php echo $this->get_field_name( 'cache' ); ?>">
148
+ <option value="0"<?php selected( $cache, 0 ); ?>><?php _e( 'Do not cache', 'youtube-channel' ); ?></option>
149
+ <?php echo $WPAU_YOUTUBE_CHANNEL->cache_time( $cache ); ?>
150
  </select>
151
  </label>
152
  </p>
153
  <p class="half left glue-top">
154
+ <label for="<?php echo $this->get_field_id( 'fetch' ); ?>"><?php _e( 'Fetch', 'youtube-channel' ); ?> <input class="small-text" id="<?php echo $this->get_field_id( 'fetch' ); ?>" name="<?php echo $this->get_field_name( 'fetch' ); ?>" type="number" min="2" value="<?php echo $fetch; ?>" title="<?php _e( 'Number of videos that will be used for random pick (min 2, max 50, default 25)', 'youtube-channel' ); ?>" /> <?php _e( 'video(s)', 'youtube-channel' ); ?></label>
155
  </p>
156
  <p class="half right glue-top">
157
+ <label for="<?php echo $this->get_field_id( 'num' ); ?>"><?php _e( 'Show', 'youtube-channel' ); ?></label> <input class="small-text" id="<?php echo $this->get_field_id( 'num' ); ?>" name="<?php echo $this->get_field_name( 'num' ); ?>" type="number" min="1" value="<?php echo ( $num ) ? $num : '1'; ?>" title="<?php _e( 'Number of videos to display', 'youtube-channel' ); ?>" /> <?php _e( 'video(s)', 'youtube-channel' ); ?>
158
  </p>
159
  <p>
160
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $privacy, true ); ?> id="<?php echo $this->get_field_id( 'privacy' ); ?>" name="<?php echo $this->get_field_name( 'privacy' ); ?>" title="<?php _e( 'Enable this option to protect your visitors privacy', 'youtube-channel' ); ?>" /> <label for="<?php echo $this->get_field_id( 'privacy' ); ?>"><?php printf( __( 'Enable <a href="%s" target="_blank">privacy-enhanced mode</a>', 'youtube-channel' ), 'http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780' ); ?></label>
161
  <br />
162
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $random, true ); ?> id="<?php echo $this->get_field_id( 'random' ); ?>" name="<?php echo $this->get_field_name( 'random' ); ?>" title="<?php _e( 'Get random videos of all fetched from channel or playlist', 'youtube-channel' ); ?>" /> <label for="<?php echo $this->get_field_id( 'random' ); ?>"><?php _e( 'Show random video from resource <small>(Have no effect if "What to show?" has been set to "Embedded Playlist")</small>', 'youtube-channel' ); ?></label>
163
  </p>
164
 
165
+ <h4><?php _e( 'Video Settings', 'youtube-channel' ); ?></h4>
166
+ <p><label for="<?php echo $this->get_field_id( 'ratio' ); ?>"><?php _e( 'Aspect ratio', 'youtube-channel' ); ?></label>
167
  <select class="widefat" id="<?php echo $this->get_field_id( 'ratio' ); ?>" name="<?php echo $this->get_field_name( 'ratio' ); ?>">
168
  <option value="3"<?php selected( $ratio, 3 ); ?>>16:9</option>
169
  <option value="1"<?php selected( $ratio, 1 ); ?>>4:3</option>
170
  </select><br />
171
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $responsive, true ); ?> id="<?php echo $this->get_field_id( 'responsive' ); ?>" name="<?php echo $this->get_field_name( 'responsive' ); ?>" /> <label for="<?php echo $this->get_field_id( 'responsive' ); ?>"><?php _e( 'Responsive video <small>(distribute one full width item per row)</small>', 'youtube-channel' ); ?></label>
172
  </p>
173
  <p>
174
+ <label for="<?php echo $this->get_field_id( 'width' ); ?>"><?php _e( 'Initial width', 'youtube-channel' ); ?></label> <input class="small-text" id="<?php echo $this->get_field_id( 'width' ); ?>" name="<?php echo $this->get_field_name( 'width' ); ?>" type="number" min="32" value="<?php echo $width; ?>" title="<?php _e( 'Set video width in pixels', 'youtube-channel' ); ?>" /> px (<?php _e( 'default', 'youtube-channel' ); ?> 306)
175
  </p>
176
  <p>
177
+ <label for="<?php echo $this->get_field_id( 'display' ); ?>">
178
+ <?php _e( 'What to display?', 'youtube-channel' ); ?>
179
  </label>
180
  <select class="widefat" id="<?php echo $this->get_field_id( 'display' ); ?>" name="<?php echo $this->get_field_name( 'display' ); ?>">
181
+ <option value="thumbnail"<?php selected( $display, 'thumbnail' ); ?>><?php _e( 'Thumbnail', 'youtube-channel' ); ?></option>
182
+ <option value="iframe"<?php selected( $display, 'iframe' ); ?>><?php _e( 'HTML5 (iframe)', 'youtube-channel' ); ?></option>
183
+ <option value="iframe2"<?php selected( $display, 'iframe2' ); ?>><?php _e( 'HTML5 (iframe) Asynchronous', 'youtube-channel' ); ?></option>
184
+ <option value="playlist"<?php selected( $display, 'playlist' ); ?>><?php _e( 'Embedded Playlist', 'youtube-channel' ); ?></option>
185
  </select>
186
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $no_thumb_title, true ); ?> id="<?php echo $this->get_field_id( 'no_thumb_title' ); ?>" name="<?php echo $this->get_field_name( 'no_thumb_title' ); ?>" /> <label for="<?php echo $this->get_field_id( 'no_thumb_title' ); ?>"><?php _e( 'Hide thumbnail tooltip', 'youtube-channel' ); ?></label><br />
187
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $themelight, true ); ?> id="<?php echo $this->get_field_id( 'themelight' ); ?>" name="<?php echo $this->get_field_name( 'themelight' ); ?>" /> <label for="<?php echo $this->get_field_id( 'themelight' ); ?>"><?php _e( 'Use light theme (default is dark)', 'youtube-channel' ); ?></label><br />
188
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $controls, true ); ?> id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" /> <label for="<?php echo $this->get_field_id( 'controls' ); ?>"><?php _e( 'Hide player controls', 'youtube-channel' ); ?></label><br />
189
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $autoplay, true ); ?> id="<?php echo $this->get_field_id( 'autoplay' ); ?>" name="<?php echo $this->get_field_name( 'autoplay' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay' ); ?>"><?php _e( 'Autoplay video or playlist', 'youtube-channel' ); ?></label><br />
190
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $autoplay_mute, true ); ?> id="<?php echo $this->get_field_id( 'autoplay_mute' ); ?>" name="<?php echo $this->get_field_name( 'autoplay_mute' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay_mute' ); ?>"><?php _e( 'Mute video on autoplay', 'youtube-channel' ); ?></label><br />
191
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $norel, true ); ?> id="<?php echo $this->get_field_id( 'norel' ); ?>" name="<?php echo $this->get_field_name( 'norel' ); ?>" /> <label for="<?php echo $this->get_field_id( 'norel' ); ?>"><?php _e( 'Hide related videos', 'youtube-channel' ); ?></label><br />
192
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $modestbranding, true ); ?> id="<?php echo $this->get_field_id( 'modestbranding' ); ?>" name="<?php echo $this->get_field_name( 'modestbranding' ); ?>" /> <label for="<?php echo $this->get_field_id( 'modestbranding' ); ?>"><?php _e( 'Hide YT Logo (does not work for all videos)', 'youtube-channel' ); ?></label><br />
193
  </p>
194
 
195
+ <h4><?php _e( 'Content Layout', 'youtube-channel' ); ?></h4>
196
  <p>
197
  <label for="<?php echo $this->get_field_id( 'showtitle' ); ?>">
198
+ <?php _e( 'Show video title', 'youtube-channel' ); ?>
199
  </label>
200
  <select class="widefat" id="<?php echo $this->get_field_id( 'showtitle' ); ?>" name="<?php echo $this->get_field_name( 'showtitle' ); ?>">
201
+ <option value="none"<?php selected( $showtitle, 'none' ); ?>><?php _e( 'Hide title', 'youtube-channel' ); ?></option>
202
+ <option value="above"<?php selected( $showtitle, 'above' ); ?>><?php _e( 'Above video/thumbnail', 'youtube-channel' ); ?></option>
203
+ <option value="below"<?php selected( $showtitle, 'below' ); ?>><?php _e( 'Below video/thumbnail', 'youtube-channel' ); ?></option>
204
  </select><br />
205
  <label for="<?php echo $this->get_field_id( 'showdesc' ); ?>">
206
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $showdesc, true ); ?> id="<?php echo $this->get_field_id( 'showdesc' ); ?>" name="<?php echo $this->get_field_name( 'showdesc' ); ?>" /> <?php _e( 'Show video description', 'youtube-channel' ); ?>
207
  </label><br />
208
+ <label for="<?php echo $this->get_field_id( 'desclen' ); ?>"><?php _e( 'Description length', 'youtube-channel' ); ?>
209
+ <input class="small-text" id="<?php echo $this->get_field_id( 'desclen' ); ?>" name="<?php echo $this->get_field_name( 'desclen' ); ?>" type="number" value="<?php echo $desclen; ?>" title="<?php _e( 'Set number of characters to cut down video description to (0 means full length)', 'youtube-channel' );?>" /> (0 = full)
210
  </label><br />
211
  <label for="<?php echo $this->get_field_id( 'hideanno' ); ?>">
212
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $hideanno, true ); ?> id="<?php echo $this->get_field_id( 'hideanno' ); ?>" name="<?php echo $this->get_field_name( 'hideanno' ); ?>" /> <?php _e( 'Hide annotations from video', 'youtube-channel' ); ?>
213
  </label><br />
214
+ <label for="<?php echo $this->get_field_id( 'hideinfo' ); ?>" title="<?php _e( 'Enabling this option causes the player to not display information like the video title and uploader before the video starts playing.' ); ?>">
215
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $hideinfo, true ); ?> id="<?php echo $this->get_field_id( 'hideinfo' ); ?>" name="<?php echo $this->get_field_name( 'hideinfo' ); ?>" /> <?php _e( 'Hide video info', 'youtube-channel' ); ?>
216
  </label>
217
  </p>
218
 
219
+ <h4><?php _e( 'Link to Channel', 'youtube-channel' ); ?></h4>
220
  <p class="glue-top">
221
+ <input class="widefat" id="<?php echo $this->get_field_id( 'goto_txt' ); ?>" name="<?php echo $this->get_field_name( 'goto_txt' ); ?>" type="text" value="<?php echo $goto_txt; ?>" title="<?php _e( 'Default: Visit our YouTube channel. You can use placeholders %vanity%, %channel% and %username%.', 'youtube-channel' ); ?>" placeholder="<?php _e( 'Visit our YouTube channel', 'youtube-channel' ); ?>" />
222
  </p>
223
  <p class="half left glue-top">
224
  <select class="widefat" id="<?php echo $this->get_field_id( 'link_to' ); ?>" name="<?php echo $this->get_field_name( 'link_to' ); ?>">
225
+ <option value="none"<?php selected( $link_to, 'none' ); ?>><?php _e( 'Hide link', 'youtube-channel' ); ?></option>
226
+ <option value="vanity"<?php selected( $link_to, 'vanity' ); ?>><?php _e( 'Link to Vanity customized URL', 'youtube-channel' ); ?></option>
227
+ <option value="channel"<?php selected( $link_to, 'channel' ); ?>><?php _e( 'Link to Channel page URL', 'youtube-channel' ); ?></option>
228
+ <option value="legacy"<?php selected( $link_to, 'legacy' ); ?>><?php _e( 'Link to Legacy username page', 'youtube-channel' ); ?></option>
229
  </select>
230
  </p>
231
  <p class="half right glue-top">
232
  <select class="widefat" id="<?php echo $this->get_field_id( 'popup_goto' ); ?>" name="<?php echo $this->get_field_name( 'popup_goto' ); ?>">
233
+ <option value="0"<?php selected( $popup_goto, 0 ); ?>><?php _e( 'Open link in same window', 'youtube-channel' ); ?></option>
234
+ <option value="1"<?php selected( $popup_goto, 1 ); ?>><?php _e( 'Open link in new window (JavaScript)', 'youtube-channel' ); ?></option>
235
+ <option value="2"<?php selected( $popup_goto, 2 ); ?>><?php _e( 'Open link in new window (target="blank")', 'youtube-channel' ); ?></option>
236
  </select>
237
  </p>
238
 
239
+ <h4><?php _e( 'Does not work?', 'youtube-channel' ); ?></h4>
240
  <p>
241
  <small><?php
242
  printf(
243
  wp_kses(
244
  __(
245
+ 'Carefully read <a href="%1$s" target="_faq">%2$s</a> before you contact us. If that does not help, <a href="%3$s" target="_blank">get JSON file</a> and send it to <a href="%4$s" target="_support">support forum</a> along with other details noted in <a href="%5$s" target=_blank">this article</a>.',
246
+ 'youtube-channel'
247
  ),
248
+ array( 'a' => array( 'href' => array() ) )
249
  ),
250
  'https://wordpress.org/plugins/youtube-channel/faq/',
251
+ __( 'FAQ', 'youtube-channel' ),
252
  "?ytc_debug_json_for={$this->number}",
253
  'http://wordpress.org/support/plugin/youtube-channel',
254
  'https://wordpress.org/support/topic/ytc3-read-before-you-post-support-question-or-report-bug'
261
  public function update($new_instance, $old_instance) {
262
  // processes widget options to be saved
263
  $instance = $old_instance;
264
+ $instance['title'] = strip_tags( $new_instance['title'] );
265
+ $instance['class'] = strip_tags( $new_instance['class'] );
266
+ $instance['channel'] = strip_tags( $new_instance['channel'] );
267
+ $instance['username'] = strip_tags( $new_instance['username'] );
268
+ $instance['playlist'] = strip_tags( $new_instance['playlist'] );
269
+ $instance['vanity'] = strip_tags( $new_instance['vanity'] );
270
  $instance['num'] = $new_instance['num'];
271
  $instance['resource'] = $new_instance['resource'];
272
  $instance['cache'] = $new_instance['cache'];
273
+ $instance['random'] = ( isset( $new_instance['random'] ) ) ? $new_instance['random'] : false;
274
  $instance['fetch'] = $new_instance['fetch'];
275
 
276
+ $instance['goto_txt'] = strip_tags( $new_instance['goto_txt'] );
277
  $instance['popup_goto'] = $new_instance['popup_goto'];
278
  $instance['link_to'] = $new_instance['link_to'];
279
 
280
+ $instance['showtitle'] = ( isset( $new_instance['showtitle'] ) ) ? $new_instance['showtitle'] : 'none';
281
+ $instance['showdesc'] = ( isset( $new_instance['showdesc'] ) ) ? $new_instance['showdesc'] : false;
282
+ $instance['desclen'] = strip_tags( $new_instance['desclen'] );
283
+ $instance['width'] = strip_tags( $new_instance['width'] );
284
+ $instance['responsive'] = ( isset( $new_instance['responsive'] ) ) ? $new_instance['responsive'] : '';
285
+
286
+ $instance['display'] = strip_tags( $new_instance['display'] );
287
+ $instance['no_thumb_title'] = ( isset( $new_instance['no_thumb_title'] ) ) ? $new_instance['no_thumb_title'] : false;
288
+ $instance['autoplay'] = ( isset( $new_instance['autoplay'] ) ) ? $new_instance['autoplay'] : false;
289
+ $instance['autoplay_mute'] = ( isset( $new_instance['autoplay_mute'] ) ) ? $new_instance['autoplay_mute'] : false;
290
+ $instance['norel'] = ( isset( $new_instance['norel'] ) ) ? $new_instance['norel'] : false;
291
+ $instance['modestbranding'] = ( isset( $new_instance['modestbranding'] ) ) ? $new_instance['modestbranding'] : false;
292
+
293
+ $instance['controls'] = ( isset( $new_instance['controls'] ) ) ? $new_instance['controls'] : false;
294
+ $instance['ratio'] = strip_tags( $new_instance['ratio'] );
295
+ $instance['hideinfo'] = ( isset( $new_instance['hideinfo'] ) ) ? $new_instance['hideinfo'] : '';
296
+ $instance['hideanno'] = ( isset( $new_instance['hideanno'] ) ) ? $new_instance['hideanno'] : '';
297
+ $instance['themelight'] = ( isset( $new_instance['themelight'] ) ) ? $new_instance['themelight'] : '';
298
+ $instance['privacy'] = ( isset( $new_instance['privacy'] ) ) ? $new_instance['privacy'] : '';
299
 
300
  return $instance;
301
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://urosevic.net/wordpress/donate/?donate_for=youtube-channel
4
  Tags: youtube, channel, playlist, single, widget, widgets, youtube player, feed, video, thumbnail, embed, sidebar, iframe, html5, responsive
5
  Requires at least: 3.9.0
6
  Tested up to: 4.3.2
7
- Stable tag: 3.0.8.7
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -182,6 +182,12 @@ When you generate your own YouTube Data API Key, from your **Dashboard** go to *
182
  Also, do not forget to check and update **Channel ID** in plugin's General settings, Widgets and/or shortcodes.
183
  You can get **Channel ID** from page [Account Advanced](https://www.youtube.com/account_advanced) while you're loagged in to your YouTube account.
184
 
 
 
 
 
 
 
185
  == Frequently Asked Questions ==
186
 
187
  Please note, latest FAQ you can find [on our website](http://urosevic.net/wordpress/plugins/youtube-channel/faq/). This section on WordPress.org has been updated only on plugin version release, so questions answered between releases are not visible here.
@@ -347,6 +353,10 @@ If you really need that missing feature ASAP, feel free to [contact me](urosevic
347
  If you don't wish to pay for enhancements (then you don't care would that be implemented in a week, month, year or so), then send new [Support topic](https://wordpress.org/support/plugin/youtube-channel) with *Topic title* in format **[Feature Request] ...**
348
 
349
  == Changelog ==
 
 
 
 
350
  = 3.0.8.7 =
351
  * Enhance: Merge two improvements for MagnificPopupAU fork from core library (commit 60d5aa4 and 1d0f697)
352
  * Fix: TinyMCE button does not have icon when new post/page is created
4
  Tags: youtube, channel, playlist, single, widget, widgets, youtube player, feed, video, thumbnail, embed, sidebar, iframe, html5, responsive
5
  Requires at least: 3.9.0
6
  Tested up to: 4.3.2
7
+ Stable tag: 3.0.8.8
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
182
  Also, do not forget to check and update **Channel ID** in plugin's General settings, Widgets and/or shortcodes.
183
  You can get **Channel ID** from page [Account Advanced](https://www.youtube.com/account_advanced) while you're loagged in to your YouTube account.
184
 
185
+ [youtube http://www.youtube.com/watch?v=wOqkfkNhOUE]
186
+
187
+ [youtube http://www.youtube.com/watch?v=qaLqWi4-9jI]
188
+
189
+ [youtube http://www.youtube.com/watch?v=u5TnGBVoG9c]
190
+
191
  == Frequently Asked Questions ==
192
 
193
  Please note, latest FAQ you can find [on our website](http://urosevic.net/wordpress/plugins/youtube-channel/faq/). This section on WordPress.org has been updated only on plugin version release, so questions answered between releases are not visible here.
353
  If you don't wish to pay for enhancements (then you don't care would that be implemented in a week, month, year or so), then send new [Support topic](https://wordpress.org/support/plugin/youtube-channel) with *Topic title* in format **[Feature Request] ...**
354
 
355
  == Changelog ==
356
+ = 3.0.8.8 =
357
+ * Fix: Link to channel enabled in Widget not shown if related link ID has not set in Widget (ignored general settings).
358
+ * Fix: Undefined notices
359
+
360
  = 3.0.8.7 =
361
  * Enhance: Merge two improvements for MagnificPopupAU fork from core library (commit 60d5aa4 and 1d0f697)
362
  * Fix: TinyMCE button does not have icon when new post/page is created
youtube-channel.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: YouTube Channel
4
  Plugin URI: http://urosevic.net/wordpress/plugins/youtube-channel/
5
  Description: Quick and easy embed latest or random videos from YouTube channel (user uploads, liked or favourited videos) or playlist. Use <a href="widgets.php">widget</a> for sidebar or shortcode for content. Works with <em>YouTube Data API v3</em>.
6
- Version: 3.0.8.7
7
  Author: Aleksandar Urošević
8
  Author URI: http://urosevic.net/
9
  Text Domain: youtube-channel
@@ -19,7 +19,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
19
  {
20
 
21
  const DB_VER = 14;
22
- const VER = '3.0.8.7';
23
 
24
  public $plugin_name = 'YouTube Channel';
25
  public $plugin_slug = 'youtube-channel';
@@ -625,6 +625,9 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
625
  // 1) Get resource from widget/shortcode
626
  // 2) If not set, get global default
627
  // 3) if no global, get plugin's default
 
 
 
628
  $resource = intval( $instance['resource'] );
629
  if ( empty( $resource ) && 0 !== $resource ) {
630
  $resource = intval( $this->defaults['resource'] );
@@ -682,7 +685,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
682
  /* OK, we have required resource (Playlist or Channel ID), so we can proceed to real job */
683
 
684
  // Set custom class and responsive if needed
685
- $class = $instance['class'] ? $instance['class'] : 'default';
686
  if ( ! empty( $instance['responsive'] ) ) {
687
  $class .= ' responsive';
688
  }
@@ -713,6 +716,9 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
713
 
714
  $output[] = "<div class=\"youtube_channel {$class}\">";
715
 
 
 
 
716
  if ( 'playlist' == $instance['display'] ) { // Insert as Embedded playlist
717
 
718
  $output = array_merge( $output, self::embed_playlist( $resource_id, $instance ) );
@@ -720,7 +726,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
720
  } else { // Individual videos from channel, favourites, liked or playlist
721
 
722
  // Get max items for random video
723
- $fetch = $instance['fetch'];
724
  if ( $fetch < 1 ) { $fetch = 10; } // default 10
725
  elseif ( $fetch > 50 ) { $fetch = 50; } // max 50
726
 
@@ -730,7 +736,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
730
  $cache_key_fallback = 'ytc_' . md5( $resource_key ) . '_fallback';
731
 
732
  // Do cache magic
733
- if ( $instance['cache'] > 0 ) {
734
 
735
  // generate feed cache key for caching time
736
  $cache_key = 'ytc_' . md5( $resource_key ) . '_' . $instance['cache'];
@@ -800,7 +806,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
800
  // Sort by date uploaded
801
  $json_entry = $json_output->items;
802
 
803
- $num = $instance['num'];
804
  if ( $num > $fetch ) { $fetch = $num; }
805
  $max_items = ( $fetch > sizeof( $json_entry ) ) ? sizeof( $json_entry ) : $fetch;
806
 
@@ -1011,7 +1017,11 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
1011
  case 'vanity':
1012
  $vanity = trim( $instance['vanity'] );
1013
  if ( empty( $vanity ) ) {
1014
- return array( '<!-- YTC ERROR: Selected Vanity custom URL to be linked but no Vanity Name provided! -->' );
 
 
 
 
1015
  }
1016
  // sanity vanity content (strip all in front of last slash to cleanup vanity ID only)
1017
  if ( ! empty( $vanity ) && false !== strpos( $vanity, 'youtube.com' ) ) {
@@ -1023,7 +1033,10 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
1023
  case 'legacy':
1024
  $username = trim( $instance['username'] );
1025
  if ( empty( $username ) ) {
1026
- return array( '<!-- YTC ERROR: Selected Legacy username to be linked but no Legacy username provided! -->' );
 
 
 
1027
  }
1028
  $goto_url .= "user/$username";
1029
  break;
@@ -1031,7 +1044,10 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
1031
  case 'channel':
1032
  $channel = trim( $instance['channel'] );
1033
  if ( empty( $channel ) ) {
1034
- return array( '<!-- YTC ERROR: Selected Channel page to be linked but no Channel ID provided! -->' );
 
 
 
1035
  }
1036
  $goto_url .= "channel/$channel";
1037
  break;
@@ -1079,6 +1095,9 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
1079
  if ( empty( $instance['width'] ) ) {
1080
  $instance['width'] = $this->defaults['width'];
1081
  }
 
 
 
1082
  $height = $this->height_ratio( $instance['width'], $instance['ratio'] );
1083
 
1084
  // How to display videos?
3
  Plugin Name: YouTube Channel
4
  Plugin URI: http://urosevic.net/wordpress/plugins/youtube-channel/
5
  Description: Quick and easy embed latest or random videos from YouTube channel (user uploads, liked or favourited videos) or playlist. Use <a href="widgets.php">widget</a> for sidebar or shortcode for content. Works with <em>YouTube Data API v3</em>.
6
+ Version: 3.0.8.8
7
  Author: Aleksandar Urošević
8
  Author URI: http://urosevic.net/
9
  Text Domain: youtube-channel
19
  {
20
 
21
  const DB_VER = 14;
22
+ const VER = '3.0.8.8';
23
 
24
  public $plugin_name = 'YouTube Channel';
25
  public $plugin_slug = 'youtube-channel';
625
  // 1) Get resource from widget/shortcode
626
  // 2) If not set, get global default
627
  // 3) if no global, get plugin's default
628
+ if ( empty( $instance['resource'] ) ) {
629
+ $instance['resource'] = $this->defaults['resource'];
630
+ }
631
  $resource = intval( $instance['resource'] );
632
  if ( empty( $resource ) && 0 !== $resource ) {
633
  $resource = intval( $this->defaults['resource'] );
685
  /* OK, we have required resource (Playlist or Channel ID), so we can proceed to real job */
686
 
687
  // Set custom class and responsive if needed
688
+ $class = ( ! empty( $instance['class'] ) ) ? $instance['class'] : 'default';
689
  if ( ! empty( $instance['responsive'] ) ) {
690
  $class .= ' responsive';
691
  }
716
 
717
  $output[] = "<div class=\"youtube_channel {$class}\">";
718
 
719
+ if ( empty( $instance['display'] ) ) {
720
+ $instance['display'] = $this->defaults['display'];
721
+ }
722
  if ( 'playlist' == $instance['display'] ) { // Insert as Embedded playlist
723
 
724
  $output = array_merge( $output, self::embed_playlist( $resource_id, $instance ) );
726
  } else { // Individual videos from channel, favourites, liked or playlist
727
 
728
  // Get max items for random video
729
+ $fetch = ( empty( $instance['fetch'] ) ) ? $this->defaults['fetch'] : $instance['fetch'];
730
  if ( $fetch < 1 ) { $fetch = 10; } // default 10
731
  elseif ( $fetch > 50 ) { $fetch = 50; } // max 50
732
 
736
  $cache_key_fallback = 'ytc_' . md5( $resource_key ) . '_fallback';
737
 
738
  // Do cache magic
739
+ if ( ! empty( $instance['cache'] ) && $instance['cache'] > 0 ) {
740
 
741
  // generate feed cache key for caching time
742
  $cache_key = 'ytc_' . md5( $resource_key ) . '_' . $instance['cache'];
806
  // Sort by date uploaded
807
  $json_entry = $json_output->items;
808
 
809
+ $num = ( empty( $instance['num'] ) ) ? $this->defaults['num'] : $instance['num'];
810
  if ( $num > $fetch ) { $fetch = $num; }
811
  $max_items = ( $fetch > sizeof( $json_entry ) ) ? sizeof( $json_entry ) : $fetch;
812
 
1017
  case 'vanity':
1018
  $vanity = trim( $instance['vanity'] );
1019
  if ( empty( $vanity ) ) {
1020
+ if ( empty( $this->defaults['vanity'] ) ) {
1021
+ return array( '<!-- YTC ERROR: Selected Vanity custom URL to be linked but no Vanity Name provided! -->' );
1022
+ }
1023
+ // Get vanity from defaults if not set in instance
1024
+ $vanity = $this->defaults['vanity'];
1025
  }
1026
  // sanity vanity content (strip all in front of last slash to cleanup vanity ID only)
1027
  if ( ! empty( $vanity ) && false !== strpos( $vanity, 'youtube.com' ) ) {
1033
  case 'legacy':
1034
  $username = trim( $instance['username'] );
1035
  if ( empty( $username ) ) {
1036
+ if ( empty( $this->defaults['username'] ) ) {
1037
+ return array( '<!-- YTC ERROR: Selected Legacy username to be linked but no Legacy username provided! -->' );
1038
+ }
1039
+ $username = $this->defaults['username'];
1040
  }
1041
  $goto_url .= "user/$username";
1042
  break;
1044
  case 'channel':
1045
  $channel = trim( $instance['channel'] );
1046
  if ( empty( $channel ) ) {
1047
+ if ( empty( $this->defaults['channel'] ) ) {
1048
+ return array( '<!-- YTC ERROR: Selected Channel page to be linked but no Channel ID provided! -->' );
1049
+ }
1050
+ $channel = $this->defaults['channel'];
1051
  }
1052
  $goto_url .= "channel/$channel";
1053
  break;
1095
  if ( empty( $instance['width'] ) ) {
1096
  $instance['width'] = $this->defaults['width'];
1097
  }
1098
+ if ( empty( $instance['ratio'] ) ) {
1099
+ $instance['ratio'] = $this->defaults['ratio'];
1100
+ }
1101
  $height = $this->height_ratio( $instance['width'], $instance['ratio'] );
1102
 
1103
  // How to display videos?