YouTube Channel - Version 3.0.11.7

Version Description

(20180906) = * Add: Global option sslverify to disable SSL Verification * Add: Global option js_ev_listener to enable Event Listener DOMContentLoaded * (20180826) Add: Override video block template by 3rd party theme or plugin with filter ytc_print_video * Add: Customizable timeout for wp_remote_get() * Improvement: Disable LastPass altering settings fields

Download this release

Release Info

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

Code changes from version 3.0.11.6 to 3.0.11.7

Files changed (4) hide show
  1. inc/settings.php +66 -13
  2. readme.txt +70 -2
  3. update.php +41 -0
  4. youtube-channel.php +21 -12
inc/settings.php CHANGED
@@ -253,6 +253,56 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
253
  'std' => 1,
254
  ) // args
255
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  // Enhanced privacy
257
  add_settings_field(
258
  $this->option_name . 'privacy', // id
@@ -861,7 +911,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
861
  public function settings_field_input_text( $args ) {
862
 
863
  printf(
864
- '<input type="text" name="%1$s" id="%1$s" value="%2$s" class="%3$s" /><p class="description">%4$s</p>',
865
  $args['field'],
866
  $args['value'],
867
  $args['class'],
@@ -876,7 +926,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
876
  public function settings_field_input_password( $args ) {
877
 
878
  printf(
879
- '<input type="password" name="%1$s" id="%1$s" value="%2$s" class="%3$s" /><p class="description">%4$s</p>',
880
  $args['field'],
881
  $args['value'],
882
  $args['class'],
@@ -1034,17 +1084,20 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
1034
  // --- General ---
1035
  case 'ytc_general':
1036
  $apikey = ( defined( 'YOUTUBE_DATA_API_KEY' ) ) ? YOUTUBE_DATA_API_KEY : '';
1037
- $sanitized['apikey'] = ( ! empty( $options['apikey'] ) ) ? trim( $options['apikey'] ) : $apikey;
1038
- $sanitized['channel'] = ( ! empty( $options['channel'] ) ) ? trim( $options['channel'] ) : '';
1039
- $sanitized['vanity'] = ( ! empty( $options['vanity'] ) ) ? trim( $options['vanity'] ) : '';
1040
- $sanitized['username'] = ( ! empty( $options['username'] ) ) ? trim( $options['username'] ) : '';
1041
- $sanitized['playlist'] = ( ! empty( $options['playlist'] ) ) ? trim( $options['playlist'] ) : '';
1042
- $sanitized['resource'] = ( isset( $options['resource'] ) ) ? intval( $options['resource'] ) : $this->defaults['resource'];
1043
- $sanitized['cache'] = ( isset( $options['cache'] ) ) ? intval( $options['cache'] ) : $this->defaults['cache'];
1044
- $sanitized['fetch'] = ( ! empty( $options['fetch'] ) ) ? intval( $options['fetch'] ) : $this->defaults['fetch'];
1045
- $sanitized['num'] = ( ! empty( $options['num'] ) ) ? intval( $options['num'] ) : $this->defaults['num'];
1046
- $sanitized['privacy'] = ( ! empty( $options['privacy'] ) && $options['privacy'] ) ? 1 : 0;
1047
- $sanitized['tinymce'] = ( ! empty( $options['tinymce'] ) && $options['tinymce'] ) ? 1 : 0;
 
 
 
1048
  break; // General
1049
 
1050
  // --- Video ---
253
  'std' => 1,
254
  ) // args
255
  );
256
+ // Timeout
257
+ add_settings_field(
258
+ $this->option_name . 'timeout', // id
259
+ __( 'Timeout', 'youtube-channel' ), // Title
260
+ array( &$this, 'settings_field_input_number' ), // Callback
261
+ $this->slug . '_general', // Page
262
+ 'ytc_general', // section
263
+ array(
264
+ 'field' => $this->option_name . '[timeout]',
265
+ 'description' => __( 'Time in seconds, before the connection with YouTube DATA Api is dropped and an error is returned', 'youtube-channel' ),
266
+ 'class' => 'timeout',
267
+ 'value' => isset( $this->defaults['timeout'] ) ? $this->defaults['timeout'] : 5,
268
+ 'min' => 5,
269
+ 'max' => 360,
270
+ 'std' => 5,
271
+ ) // args
272
+ );
273
+
274
+ // SSL Verify
275
+ add_settings_field(
276
+ $this->option_name . 'sslverify', // id
277
+ __( 'SSL Verify', 'youtube-channel' ), // Title
278
+ array( &$this, 'settings_field_checkbox' ), // Callback
279
+ $this->slug . '_general', // Page
280
+ 'ytc_general', // section
281
+ array(
282
+ 'field' => $this->option_name . '[sslverify]',
283
+ 'label' => __( 'Enable', 'youtube-channel' ),
284
+ 'description' => __( 'If your website host fail to verify SSL Certificate for GoogleApis.com server (if you see in YTC Error keywords cURL and SSL), disable this option.', 'youtube-channel' ),
285
+ 'class' => 'checkbox',
286
+ 'value' => isset( $this->defaults['sslverify'] ) ? $this->defaults['sslverify'] : '0',
287
+ ) // args
288
+ );
289
+
290
+ // Event Listener
291
+ add_settings_field(
292
+ $this->option_name . 'js_ev_listener', // id
293
+ __( 'Event Listener', 'youtube-channel' ), // Title
294
+ array( &$this, 'settings_field_checkbox' ), // Callback
295
+ $this->slug . '_general', // Page
296
+ 'ytc_general', // section
297
+ array(
298
+ 'field' => $this->option_name . '[js_ev_listener]',
299
+ 'label' => __( 'Enable', 'youtube-channel' ),
300
+ 'description' => __( 'If YTC block fail to render on your website because of async/defer loading of java script, try to enable this option to wrap YTC code within DOMContentLoaded event listener', 'youtube-channel' ),
301
+ 'class' => 'checkbox',
302
+ 'value' => isset( $this->defaults['js_ev_listener'] ) ? $this->defaults['js_ev_listener'] : '0',
303
+ ) // args
304
+ );
305
+
306
  // Enhanced privacy
307
  add_settings_field(
308
  $this->option_name . 'privacy', // id
911
  public function settings_field_input_text( $args ) {
912
 
913
  printf(
914
+ '<input type="text" name="%1$s" id="%1$s" value="%2$s" class="%3$s" data-lpignore="true" /><p class="description">%4$s</p>',
915
  $args['field'],
916
  $args['value'],
917
  $args['class'],
926
  public function settings_field_input_password( $args ) {
927
 
928
  printf(
929
+ '<input type="password" name="%1$s" id="%1$s" value="%2$s" class="%3$s" data-lpignore="true" /><p class="description">%4$s</p>',
930
  $args['field'],
931
  $args['value'],
932
  $args['class'],
1084
  // --- General ---
1085
  case 'ytc_general':
1086
  $apikey = ( defined( 'YOUTUBE_DATA_API_KEY' ) ) ? YOUTUBE_DATA_API_KEY : '';
1087
+ $sanitized['apikey'] = ( ! empty( $options['apikey'] ) ) ? trim( $options['apikey'] ) : $apikey;
1088
+ $sanitized['channel'] = ( ! empty( $options['channel'] ) ) ? trim( $options['channel'] ) : '';
1089
+ $sanitized['vanity'] = ( ! empty( $options['vanity'] ) ) ? trim( $options['vanity'] ) : '';
1090
+ $sanitized['username'] = ( ! empty( $options['username'] ) ) ? trim( $options['username'] ) : '';
1091
+ $sanitized['playlist'] = ( ! empty( $options['playlist'] ) ) ? trim( $options['playlist'] ) : '';
1092
+ $sanitized['resource'] = ( isset( $options['resource'] ) ) ? intval( $options['resource'] ) : $this->defaults['resource'];
1093
+ $sanitized['cache'] = ( isset( $options['cache'] ) ) ? intval( $options['cache'] ) : $this->defaults['cache'];
1094
+ $sanitized['fetch'] = ( ! empty( $options['fetch'] ) ) ? intval( $options['fetch'] ) : $this->defaults['fetch'];
1095
+ $sanitized['num'] = ( ! empty( $options['num'] ) ) ? intval( $options['num'] ) : $this->defaults['num'];
1096
+ $sanitized['privacy'] = ( ! empty( $options['privacy'] ) && $options['privacy'] ) ? 1 : 0;
1097
+ $sanitized['tinymce'] = ( ! empty( $options['tinymce'] ) && $options['tinymce'] ) ? 1 : 0;
1098
+ $sanitized['sslverify'] = ( ! empty( $options['sslverify'] ) && $options['sslverify'] ) ? 1 : 0;
1099
+ $sanitized['js_ev_listener'] = ( ! empty( $options['js_ev_listener'] ) && $options['js_ev_listener'] ) ? 1 : 0;
1100
+ $sanitized['timeout'] = ( ! empty( $options['timeout'] ) ) ? intval( $options['timeout'] ) : $this->defaults['timeout'];
1101
  break; // General
1102
 
1103
  // --- Video ---
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://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: 4.0
6
  Tested up to: 4.9.8
7
- Stable tag: 3.0.11.6
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -163,6 +163,67 @@ Along to Widget, you can add YouTube Channel block inline by using shortcode `[y
163
 
164
  *Please note, to enhance plugin functionality, we can change some shortcode parameters in future.*
165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  == Installation ==
167
 
168
  You can use the built in installer and upgrader, or you can install the plugin manually.
@@ -205,7 +266,7 @@ You can get **Channel ID** from page [Account Advanced](https://www.youtube.com/
205
 
206
  == Frequently Asked Questions ==
207
 
208
- Please note, latest FAQ you can find [on our website](https://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.
209
 
210
  = How to get that YouTube Data API Key? =
211
 
@@ -379,6 +440,13 @@ If you really need that missing feature ASAP, feel free to [contact me](urosevic
379
  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] ...**
380
 
381
  == Changelog ==
 
 
 
 
 
 
 
382
  = 3.0.11.6 (20180826) =
383
  * Add compatibility with async/defer optimization (thanks to @lordbass)
384
 
4
  Tags: youtube, channel, playlist, single, widget, widgets, youtube player, feed, video, thumbnail, embed, sidebar, iframe, html5, responsive
5
  Requires at least: 4.0
6
  Tested up to: 4.9.8
7
+ Stable tag: 3.0.11.7
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
163
 
164
  *Please note, to enhance plugin functionality, we can change some shortcode parameters in future.*
165
 
166
+ == Filter hooks ==
167
+
168
+ You can modify final output of video block by hooking to filter `ytc_print_video`.
169
+
170
+ Four parameters are provided:
171
+ * `video_content` - HTML of original video block
172
+ * `item` - YouTube video object which contains:
173
+ * `snippet->publishedAt` - date of publishing YouTube video
174
+ * `shippet->title` - YouTube video title
175
+ * `shippet->description` - YouTube video description
176
+ * `snippet->resourceId->videoId` -> YouTube video ID
177
+ * `instance` - Current YouTUbe Channel Block parameters, including global settings:
178
+ * `vanity`
179
+ * `channel`
180
+ * `username`
181
+ * `playlist`
182
+ * `resource`
183
+ * `cache`
184
+ * `fetch`
185
+ * `num`
186
+ * `privacy`
187
+ * `ratio`
188
+ * `width`
189
+ * `responsive`
190
+ * `display`
191
+ * `themelight`
192
+ * `fullscreen`
193
+ * `controls`
194
+ * `autoplay`
195
+ * `autoplay_mute`
196
+ * `norel`
197
+ * `playsinline`
198
+ * `showtitle`
199
+ * `titletag`
200
+ * `showdesc`
201
+ * `desclen`
202
+ * `modestbranding`
203
+ * `hideanno`
204
+ * `hideinfo`
205
+ * `goto_txt`
206
+ * `popup_goto`
207
+ * `link_to`
208
+ * `tinymce`
209
+ * `nolightbox`
210
+ * `apikey`
211
+ * `thumb_quality`
212
+ * `timeout`
213
+ * `random`
214
+ * `no_thumb_title`
215
+ * `class`
216
+ * `target`
217
+ * `y` - order number of video (`1` for first, `2` for second, etc)
218
+
219
+ Example:
220
+ `add_filter( 'ytc_print_video', 'customized_ytc_print_video', 10, 4 );
221
+ function customized_ytc_print_video( $video_block, $item, $instance, $y ) {
222
+ // Do whatever you wish to do
223
+ // ...
224
+ return $video_block;
225
+ }`
226
+
227
  == Installation ==
228
 
229
  You can use the built in installer and upgrader, or you can install the plugin manually.
266
 
267
  == Frequently Asked Questions ==
268
 
269
+ 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.
270
 
271
  = How to get that YouTube Data API Key? =
272
 
440
  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] ...**
441
 
442
  == Changelog ==
443
+ = 3.0.11.7 (20180906) =
444
+ * Add: Global option `sslverify` to disable SSL Verification
445
+ * Add: Global option `js_ev_listener` to enable Event Listener DOMContentLoaded
446
+ * (20180826) Add: Override video block template by 3rd party theme or plugin with filter `ytc_print_video`
447
+ * Add: Customizable timeout for wp_remote_get()
448
+ * Improvement: Disable LastPass altering settings fields
449
+
450
  = 3.0.11.6 (20180826) =
451
  * Add compatibility with async/defer optimization (thanks to @lordbass)
452
 
update.php CHANGED
@@ -493,3 +493,44 @@ function au_youtube_channel_update_routine_20() {
493
  }
494
 
495
  } // END function au_youtube_channel_update_routine_20()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
493
  }
494
 
495
  } // END function au_youtube_channel_update_routine_20()
496
+
497
+ /**
498
+ * Add default value for new global option timeout
499
+ */
500
+ function au_youtube_channel_update_routine_21() {
501
+
502
+ // get options from DB
503
+ $defaults = get_option( 'youtube_channel_defaults' );
504
+
505
+ if ( ! isset( $defaults['timeout'] ) ) {
506
+ $defaults['timeout'] = 5;
507
+ }
508
+
509
+ if ( isset( $defaults ) ) {
510
+ update_option( 'youtube_channel_defaults', $defaults );
511
+ unset( $defaults );
512
+ }
513
+
514
+ } // END function au_youtube_channel_update_routine_21()
515
+
516
+ /**
517
+ * Add default value for new global options sslverify and js_ev_listener
518
+ */
519
+ function au_youtube_channel_update_routine_22() {
520
+
521
+ // get options from DB
522
+ $defaults = get_option( 'youtube_channel_defaults' );
523
+
524
+ if ( ! isset( $defaults['sslverify'] ) ) {
525
+ $defaults['sslverify'] = true;
526
+ }
527
+ if ( ! isset( $defaults['js_ev_listener'] ) ) {
528
+ $defaults['js_ev_listener'] = false;
529
+ }
530
+
531
+ if ( isset( $defaults ) ) {
532
+ update_option( 'youtube_channel_defaults', $defaults );
533
+ unset( $defaults );
534
+ }
535
+
536
+ } // END function au_youtube_channel_update_routine_22()
youtube-channel.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: YouTube Channel
4
  Plugin URI: https://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.11.6
7
  Author: Aleksandar Urošević
8
  Author URI: https://urosevic.net/
9
  Text Domain: youtube-channel
@@ -17,14 +17,15 @@ if ( ! defined( 'ABSPATH' ) ) {
17
  if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
18
  class WPAU_YOUTUBE_CHANNEL {
19
 
20
- const DB_VER = 20;
21
- const VER = '3.0.11.6';
22
 
23
  public $plugin_name = 'YouTube Channel';
24
  public $plugin_slug = 'youtube-channel';
25
  public $plugin_option = 'youtube_channel_defaults';
26
  public $plugin_url;
27
  public $ytc_html5_js = '';
 
28
 
29
  /**
30
  * Construct class
@@ -136,6 +137,9 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
136
  'link_to' => 'none', // 0 legacy username, 1 channel, 2 vanity
137
  'tinymce' => 1, // show TinyMCE button by default
138
  'nolightbox' => 0, // do not use lightbox global setting
 
 
 
139
  );
140
 
141
  add_option( 'youtube_channel_version', self::VER, '', 'no' );
@@ -456,14 +460,14 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
456
  } // END if ( empty($this->defaults['nolightbox']) )
457
 
458
  if ( ! empty( $js ) ) {
459
- $js = "
460
  <!-- YouTube Channel 3 -->
461
- <script type=\"text/javascript\">
462
- window.addEventListener('DOMContentLoaded', function() {
463
- $js
464
- });
465
- </script>\n
466
- ";
467
 
468
  if ( WP_DEBUG ) {
469
  // Uncompressed code if WP debug is enabled
@@ -886,7 +890,11 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
886
  }
887
 
888
  // Generate single video block
889
- $output .= $this->ytc_print_video( $item, $instance, $y );
 
 
 
 
890
  }
891
  // Free some memory
892
  unset( $random_used, $random_item, $json );
@@ -925,7 +933,8 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
925
  $feed_url .= "&key={$this->defaults['apikey']}";
926
 
927
  $wparg = array(
928
- 'timeout' => 5, // five seconds only
 
929
  );
930
 
931
  $response = wp_remote_get( $feed_url, $wparg );
3
  Plugin Name: YouTube Channel
4
  Plugin URI: https://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.11.7
7
  Author: Aleksandar Urošević
8
  Author URI: https://urosevic.net/
9
  Text Domain: youtube-channel
17
  if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
18
  class WPAU_YOUTUBE_CHANNEL {
19
 
20
+ const DB_VER = 22;
21
+ const VER = '3.0.11.7';
22
 
23
  public $plugin_name = 'YouTube Channel';
24
  public $plugin_slug = 'youtube-channel';
25
  public $plugin_option = 'youtube_channel_defaults';
26
  public $plugin_url;
27
  public $ytc_html5_js = '';
28
+ public $defaults;
29
 
30
  /**
31
  * Construct class
137
  'link_to' => 'none', // 0 legacy username, 1 channel, 2 vanity
138
  'tinymce' => 1, // show TinyMCE button by default
139
  'nolightbox' => 0, // do not use lightbox global setting
140
+ 'timeout' => 5, // timeout for wp_remote_get()
141
+ 'sslverify' => true,
142
+ 'js_ev_listener' => false,
143
  );
144
 
145
  add_option( 'youtube_channel_version', self::VER, '', 'no' );
460
  } // END if ( empty($this->defaults['nolightbox']) )
461
 
462
  if ( ! empty( $js ) ) {
463
+ $js = sprintf('
464
  <!-- YouTube Channel 3 -->
465
+ <script type="text/javascript">%2$s%1$s%3$s</script>
466
+ ',
467
+ $js,
468
+ $this->defaults['js_ev_listener'] ? "window.addEventListener('DOMContentLoaded', function() {" : '',
469
+ $this->defaults['js_ev_listener'] ? "});" : ''
470
+ );
471
 
472
  if ( WP_DEBUG ) {
473
  // Uncompressed code if WP debug is enabled
890
  }
891
 
892
  // Generate single video block
893
+ $video_block = $this->ytc_print_video( $item, $instance, $y );
894
+ // Allow plugins/themes to override the default video block template.
895
+ $video_block = apply_filters( 'ytc_print_video', $video_block, $item, $instance, $y );
896
+ // Append video block to final output
897
+ $output .= $video_block;
898
  }
899
  // Free some memory
900
  unset( $random_used, $random_item, $json );
933
  $feed_url .= "&key={$this->defaults['apikey']}";
934
 
935
  $wparg = array(
936
+ 'timeout' => $this->defaults['timeout'],
937
+ 'sslverify' => $this->defaults['sslverify'] ? true : false,
938
  );
939
 
940
  $response = wp_remote_get( $feed_url, $wparg );