YouTube Channel - Version 3.0.8.5

Version Description

  • Enhanced: Settings page made compliant to WordPress Core Coding Standard
  • Fix: Wrong links to external resources on Settings page
  • Fix: Opening external resources links on Settings page in new tab
  • Change: Replace PayPal donation links to prevent account limitations if plugin is used on website that violates PayPal's Acceptable Use Policy
Download this release

Release Info

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

Code changes from version 3.0.8.4 to 3.0.8.5

Files changed (4) hide show
  1. inc/settings.php +350 -322
  2. inc/settings_template.php +1 -2
  3. readme.txt +8 -2
  4. youtube-channel.php +2 -2
inc/settings.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
4
 
5
  class WPAU_YOUTUBE_CHANNEL_SETTINGS {
6
 
@@ -21,8 +21,8 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
21
  $this->defaults = get_option( $this->option_name );
22
 
23
  // register actions
24
- add_action( 'admin_init', array(&$this, 'register_settings') );
25
- add_action( 'admin_menu', array(&$this, 'add_menu') );
26
 
27
  } // END public function __construct
28
 
@@ -35,37 +35,38 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
35
  // --- Add settings section General so we can add fields to it ---
36
  add_settings_section(
37
  'ytc_general', // Section Name
38
- __('General', 'youtube-channel'), // Section Title
39
- array(&$this, 'settings_general_section_description'), // Section Callback Function
40
  $this->slug . '_general' // Page Name
41
  );
42
  // --- Add Fields to General section ---
43
  // YouTube Data API Key
44
  add_settings_field(
45
  $this->option_name . 'apikey', // Setting Slug
46
- __('YouTube Data API Key', 'youtube-channel'), // Title
47
- array(&$this, 'settings_field_input_password'), // Callback
48
  $this->slug . '_general', // Page Name
49
  'ytc_general', // Section Name
50
  array(
51
  'field' => $this->option_name . '[apikey]',
52
  'description' => sprintf(
53
- "<strong>[%s]</strong> %s",
54
- __('Required', 'youtube-channel'),
55
  sprintf(
56
  wp_kses(
57
  __(
58
- 'Your YouTube Data API Key (get it from <a href="%s" target="_blank">%s</a>)',
59
  'youtube-channel'
60
  ),
61
  array(
62
  'a' => array(
63
- 'href' => array()
64
- )
 
65
  )
66
  ),
67
  esc_url( 'https://console.developers.google.com/project' ),
68
- __('Google Developers Console', 'youtube-channel')
69
  )
70
  ),
71
  'class' => 'regular-text password',
@@ -75,29 +76,30 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
75
  // Channel ID
76
  add_settings_field(
77
  $this->option_name . 'channel', // Setting Slug
78
- __('YouTube Channel ID', 'youtube-channel'), // Title
79
- array(&$this, 'settings_field_input_text'), // Callback
80
  $this->slug . '_general', // Page Name
81
  'ytc_general', // Section Name
82
  array(
83
  'field' => $this->option_name . '[channel]',
84
  'description' => sprintf(
85
- "<strong>[%s]</strong> %s",
86
- __('Required', 'youtube-channel'),
87
  sprintf(
88
  wp_kses(
89
  __(
90
- 'Your YouTube Channel ID (get it from <a href="%s" target="_blank">%s</a>)',
91
  'youtube-channel'
92
  ),
93
  array(
94
  'a' => array(
95
- 'href' => array()
96
- )
 
97
  )
98
  ),
99
  esc_url( 'https://www.youtube.com/account_advanced' ),
100
- __('YouTube Account Overview', 'youtube-channel')
101
  )
102
  ),
103
  'class' => 'regular-text',
@@ -107,31 +109,33 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
107
  // Vanity
108
  add_settings_field(
109
  $this->option_name . 'vanity', // id
110
- __('YouTube Vanity Name', 'youtube-channel'), // Title
111
- array(&$this, 'settings_field_input_text'), // Callback
112
  $this->slug . '_general', // Page
113
  'ytc_general', // section
114
  array(
115
- 'field' => $this->option_name . "[vanity]",
116
  'description' => sprintf(
117
- "[%s] %s",
118
- __('Optional', 'youtube-channel'),
119
- sprintf(
120
- wp_kses(
121
- __(
122
- 'Your YouTube Custom Name (get only part after www.youtube.com/c/ instead whole URL from <a href="%s" target="_blank">%s</a>)',
123
- 'youtube-channel'
124
- ),
125
- array(
126
- 'a' => array(
127
- 'href' => array()
128
- )
129
- )
130
  ),
131
- esc_url( 'https://www.youtube.com/account_advanced'),
132
- __('YouTube Account Overview', 'youtube-channel')
133
- )
134
- ),
 
 
 
 
 
 
 
 
135
  'class' => 'regular-text',
136
  'value' => $this->defaults['vanity'],
137
  ) // args
@@ -139,16 +143,16 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
139
  // Username
140
  add_settings_field(
141
  $this->option_name . 'username', // id
142
- __('Legacy YouTube Username', 'youtube-channel'), // Title
143
- array(&$this, 'settings_field_input_text'), // Callback
144
  $this->slug . '_general', // Page
145
  'ytc_general', // section
146
  array(
147
- 'field' => $this->option_name . "[username]",
148
  'description' => sprintf(
149
- "[%s] %s",
150
- __('Optional', 'youtube-channel'),
151
- __('Your YouTube legacy username', 'youtube-channel')
152
  ),
153
  'class' => 'regular-text',
154
  'value' => $this->defaults['username'],
@@ -157,17 +161,17 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
157
  // Default Playlist
158
  add_settings_field(
159
  $this->option_name . 'playlist', // id
160
- __('Default Playlist ID', 'youtube-channel'), // Title
161
- array(&$this, 'settings_field_input_text'), // Callback
162
  $this->slug . '_general', // Page
163
  'ytc_general', // section
164
  array(
165
- 'field' => $this->option_name . "[playlist]",
166
  'description' => sprintf(
167
- "[%s] %s",
168
- __('Optional', 'youtube-channel'),
169
- __('Enter default playlist ID (not playlist name)', 'youtube-channel')
170
- ),
171
  'class' => 'regular-text',
172
  'value' => $this->defaults['playlist'],
173
  ) // args
@@ -175,118 +179,119 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
175
  // Resource
176
  add_settings_field(
177
  $this->option_name . 'resource', // id
178
- __('Resource to use', 'youtube-channel'), // Title
179
- array(&$this, 'settings_field_select'), // Callback
180
  $this->slug . '_general', // Page
181
  'ytc_general', // section
182
  array(
183
- 'field' => $this->option_name . "[resource]",
184
- 'label' => __('Resource:', 'youtube-channel'),
185
- 'description' => __('What to use as resource for feeds', 'youtube-channel'),
186
  'class' => 'regular-text',
187
  'value' => $this->defaults['resource'],
188
  'items' => array(
189
- '0' => __('Channel', 'youtube-channel'),
190
- '1' => __('Favourites', 'youtube-channel'),
191
- '3' => __('Liked Video', 'youtube-channel'),
192
- '2' => __('Playlist', 'youtube-channel')
193
- )
194
  ) // args
195
  );
196
  // Cache
197
  add_settings_field(
198
  $this->option_name . 'cache', // id
199
- __('Cache Timeout','youtube-channel'),
200
- array(&$this, 'settings_field_select'),
201
  $this->slug . '_general',
202
  'ytc_general',
203
  array(
204
- 'field' => $this->option_name . "[cache]",
205
- 'description' => __('Define caching timeout for YouTube feeds, in seconds', 'youtube-channel'),
206
  'class' => 'wide-text',
207
  'value' => $this->defaults['cache'],
208
  'items' => array(
209
- '0' => __('Do not chache', 'youtube-channel'),
210
- '60' => __('1 minute', 'youtube-channel'),
211
- '300' => __('5 minutes', 'youtube-channel'),
212
- '900' => __('15 minutes', 'youtube-channel'),
213
- '1800' => __('30 minutes', 'youtube-channel'),
214
- '3600' => __('1 hour', 'youtube-channel'),
215
- '7200' => __('2 hours', 'youtube-channel'),
216
- '18000' => __('5 hours', 'youtube-channel'),
217
- '36000' => __('10 hours', 'youtube-channel'),
218
- '43200' => __('12 hours', 'youtube-channel'),
219
- '64800' => __('18 hours', 'youtube-channel'),
220
- '86400' => __('1 day', 'youtube-channel'),
221
- '172800' => __('2 days', 'youtube-channel'),
222
- '259200' => __('3 days', 'youtube-channel'),
223
- '345600' => __('4 days', 'youtube-channel'),
224
- '432000' => __('5 days', 'youtube-channel'),
225
- '518400' => __('6 days', 'youtube-channel'),
226
- '604800' => __('1 week', 'youtube-channel'),
227
- '1209600' => __('2 weeks', 'youtube-channel'),
228
- '1814400' => __('3 weeks', 'youtube-channel'),
229
- '2419200' => __('1 month', 'youtube-channel')
230
- )
231
  )
232
  );
233
  // Fetch
234
  add_settings_field(
235
  $this->option_name . 'fetch', // id
236
- __('Fetch', 'youtube-channel'), // Title
237
- array(&$this, 'settings_field_input_number'), // Callback
238
  $this->slug . '_general', // Page
239
  'ytc_general', // section
240
  array(
241
- 'field' => $this->option_name . "[fetch]",
242
- 'description' => __('Number of videos that will be used for random pick (min 2, max 50, default 25)', 'youtube-channel'),
243
  'class' => 'num',
244
  'value' => $this->defaults['fetch'],
245
  'min' => 1,
246
  'max' => 50,
247
- 'std' => 25
248
  ) // args
249
  );
250
  // Show
251
  add_settings_field(
252
  $this->option_name . 'num', // id
253
- __('Show', 'youtube-channel'), // Title
254
- array(&$this, 'settings_field_input_number'), // Callback
255
  $this->slug . '_general', // Page
256
  'ytc_general', // section
257
  array(
258
- 'field' => $this->option_name . "[num]",
259
- 'description' => __('Number of videos to display', 'youtube-channel'),
260
  'class' => 'num',
261
  'value' => $this->defaults['num'],
262
  'min' => 1,
263
  'max' => 50,
264
- 'std' => 1
265
  ) // args
266
  );
267
  // Enhanced privacy
268
  add_settings_field(
269
  $this->option_name . 'privacy', // id
270
- __('Use Enhanced privacy', 'youtube-channel'), // Title
271
- array(&$this, 'settings_field_checkbox'), // Callback
272
  $this->slug . '_general', // Page
273
  'ytc_general', // section
274
  array(
275
- 'field' => $this->option_name . "[privacy]",
276
  'description' => sprintf(
277
  wp_kses(
278
  __(
279
- 'Enable this option to protect your visitors privacy. <a href="%s" target="_blank">%s</a>',
280
  'youtube-channel'
281
  ),
282
  array(
283
  'a' => array(
284
- 'href' => array()
285
- )
 
286
  )
287
  ),
288
- esc_url('http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780'),
289
- __('Learn more here', 'youtube-channel')
290
  ),
291
  'class' => 'checkbox',
292
  'value' => $this->defaults['privacy'],
@@ -295,15 +300,15 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
295
  // TinyMCE icon
296
  add_settings_field(
297
  $this->option_name . 'tinymce', // id
298
- __('Enable TinyMCE button', 'youtube-channel'), // Title
299
- array(&$this, 'settings_field_checkbox'), // Callback
300
  $this->slug . '_general', // Page
301
  'ytc_general', // section
302
  array(
303
- 'field' => $this->option_name . "[tinymce]",
304
  'description' => sprintf(
305
- __('Disable this option to hide %s button from TinyMCE toolbar on post and page editor.', 'youtube-channel'),
306
- __('YouTube Channel', 'youtube-channel')
307
  ),
308
  'class' => 'checkbox',
309
  'value' => $this->defaults['tinymce'],
@@ -313,85 +318,84 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
313
  register_setting(
314
  'ytc_general', // Setting group
315
  $this->option_name, // option name
316
- array($this, 'sanitize_options')
317
  );
318
 
319
  // =========================== VIDEO ===========================
320
  // --- Add settings section Video so we can add fields to it ---
321
  add_settings_section(
322
  'ytc_video', // Section Name
323
- __('Video Tweaks', 'youtube-channel'), // Section Title
324
- array(&$this, 'settings_video_section_description'), // Section Callback Function
325
  $this->slug . '_video' // Page Name
326
  );
327
  // --- Add Fields to video section ---
328
  // Width
329
  add_settings_field(
330
  $this->option_name . 'width', // id
331
- __('Initial Width', 'youtube-channel'), // Title
332
- array(&$this, 'settings_field_input_number'), // Callback
333
  $this->slug . '_video', // Page
334
  'ytc_video', // section
335
  array(
336
- 'field' => $this->option_name . "[width]",
337
- 'description' => __('Set default width for displayed video, in pixels', 'youtube-channel'),
338
  'class' => 'num',
339
  'value' => $this->defaults['width'],
340
  'min' => 120,
341
  'max' => 1980,
342
- 'std' => 306
343
  ) // args
344
  );
345
  // Aspect Ratio
346
  add_settings_field(
347
  $this->option_name . 'ratio', // id
348
- __('Aspect ratio', 'youtube-channel'), // Title
349
- array(&$this, 'settings_field_select'), // Callback
350
  $this->slug . '_video', // Page
351
  'ytc_video', // section
352
  array(
353
- 'field' => $this->option_name . "[ratio]",
354
- // 'label' => __('Ratio:', 'youtube-channel'),
355
- 'description' => __('Select aspect ratio for displayed video', 'youtube-channel'),
356
  'class' => 'regular-text',
357
  'value' => $this->defaults['ratio'],
358
  'items' => array(
359
  '3' => '16:9',
360
- '1' => '4:3'
361
- )
362
  ) // args
363
  );
364
  // Display
365
  add_settings_field(
366
  $this->option_name . 'display', // id
367
- __('What to show?', 'youtube-channel'), // Title
368
- array(&$this, 'settings_field_select'), // Callback
369
  $this->slug . '_video', // Page
370
  'ytc_video', // section
371
  array(
372
- 'field' => $this->option_name . "[display]",
373
- 'description' => __('Choose how to embed video block', 'youtube-channel'),
374
  'class' => 'regular-text',
375
  'value' => $this->defaults['display'],
376
  'items' => array(
377
- 'thumbnail' => __('Thumbnail', 'youtube-channel'),
378
- 'iframe' => __('HTML5 (iframe)', 'youtube-channel'),
379
- 'iframe2' => __('HTML5 (iframe) Asynchronous', 'youtube-channel'),
380
- 'playlist' => __('Embedded Playlist', 'youtube-channel'),
381
  // 'gallery' => 'Gallery'
382
- )
383
  ) // args
384
  );
385
  // Responsive
386
  add_settings_field(
387
  $this->option_name . 'responsive', // id
388
- __('Enable Responsive', 'youtube-channel'), // Title
389
- array(&$this, 'settings_field_checkbox'), // Callback
390
  $this->slug . '_video', // Page
391
  'ytc_video', // section
392
  array(
393
- 'field' => $this->option_name . "[responsive]",
394
- 'description' => __("Enable this option to make YTC videos and thumbnails responsive by default. Please note, this option will set videos and thumbnail to full width relative to parent container, and disable more than one video per row.", 'youtube-channel'),
395
  'class' => 'checkbox',
396
  'value' => $this->defaults['responsive'],
397
  ) // args
@@ -400,47 +404,56 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
400
  // Plays Inline
401
  add_settings_field(
402
  $this->option_name . 'playsinline', // id
403
- __('Play inline on iOS', 'youtube-channel'), // Title
404
- array(&$this, 'settings_field_checkbox'), // Callback
405
  $this->slug . '_video', // Page
406
  'ytc_video', // section
407
  array(
408
- 'field' => $this->option_name . "[playsinline]",
409
  'description' => sprintf(
410
- __(
411
- 'Enable this option to override fullscreen playback on iOS, and force inline playback on page and in lightbox. Learn more <a href="%s">here</a>.',
412
- 'https://developers.google.com/youtube/player_parameters#playsinline'
 
 
 
 
 
 
 
 
413
  ),
414
- 'youtube-channel'
 
415
  ),
416
  'class' => 'checkbox',
417
- 'value' => ( isset($this->defaults['playsinline']) ) ? $this->defaults['playsinline'] : '',
418
  ) // args
419
  );
420
  // No Lightbox
421
  add_settings_field(
422
  $this->option_name . 'nolightbox', // id
423
- __('Disable Lightbox', 'youtube-channel'), // Title
424
- array(&$this, 'settings_field_checkbox'), // Callback
425
  $this->slug . '_video', // Page
426
  'ytc_video', // section
427
  array(
428
- 'field' => $this->option_name . "[nolightbox]",
429
- 'description' => __("Enable this option to disable built-in lightbox for thumbnails (in case that you have youtube links lightbox trigger in theme or other plugin).", 'youtube-channel'),
430
  'class' => 'checkbox',
431
- 'value' => ( isset($this->defaults['nolightbox']) ) ? $this->defaults['nolightbox'] : '',
432
  ) // args
433
  );
434
  // Full Screen
435
  add_settings_field(
436
  $this->option_name . 'fullscreen', // id
437
- __('Enable Full Screen', 'youtube-channel'), // Title
438
- array(&$this, 'settings_field_checkbox'), // Callback
439
  $this->slug . '_video', // Page
440
  'ytc_video', // section
441
  array(
442
- 'field' => $this->option_name . "[fullscreen]",
443
- 'description' => __("Enable this option to make available Full Screen button for embedded playlists.", 'youtube-channel'),
444
  'class' => 'checkbox',
445
  'value' => $this->defaults['fullscreen'],
446
  ) // args
@@ -449,13 +462,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
449
  // Light Theme
450
  add_settings_field(
451
  $this->option_name . 'themelight', // id
452
- __('Light Theme', 'youtube-channel'), // Title
453
- array(&$this, 'settings_field_checkbox'), // Callback
454
  $this->slug . '_video', // Page
455
  'ytc_video', // section
456
  array(
457
- 'field' => $this->option_name . "[themelight]",
458
- 'description' => __("Enable this option to use light theme for playback controls instead dark.", 'youtube-channel'),
459
  'class' => 'checkbox',
460
  'value' => $this->defaults['themelight'],
461
  ) // args
@@ -463,13 +476,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
463
  // No Player Controls
464
  add_settings_field(
465
  $this->option_name . 'controls', // id
466
- __('Hide Player Controls', 'youtube-channel'), // Title
467
- array(&$this, 'settings_field_checkbox'), // Callback
468
  $this->slug . '_video', // Page
469
  'ytc_video', // section
470
  array(
471
- 'field' => $this->option_name . "[controls]",
472
- 'description' => __("Enable this option to hide playback controls", 'youtube-channel'),
473
  'class' => 'checkbox',
474
  'value' => $this->defaults['controls'],
475
  ) // args
@@ -478,13 +491,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
478
  // Autoplay
479
  add_settings_field(
480
  $this->option_name . 'autoplay', // id
481
- __('Autoplay video or playlist', 'youtube-channel'), // Title
482
- array(&$this, 'settings_field_checkbox'), // Callback
483
  $this->slug . '_video', // Page
484
  'ytc_video', // section
485
  array(
486
- 'field' => $this->option_name . "[autoplay]",
487
- 'description' => __("Enable this option to start video playback right after block is rendered", 'youtube-channel'),
488
  'class' => 'checkbox',
489
  'value' => $this->defaults['autoplay'],
490
  ) // args
@@ -492,13 +505,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
492
  // Mute on autoplay
493
  add_settings_field(
494
  $this->option_name . 'autoplay_mute', // id
495
- __('Mute video on autoplay', 'youtube-channel'), // Title
496
- array(&$this, 'settings_field_checkbox'), // Callback
497
  $this->slug . '_video', // Page
498
  'ytc_video', // section
499
  array(
500
- 'field' => $this->option_name . "[autoplay_mute]",
501
- 'description' => __("Enable this option to mute video when start autoplay", 'youtube-channel'),
502
  'class' => 'checkbox',
503
  'value' => $this->defaults['autoplay_mute'],
504
  ) // args
@@ -506,13 +519,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
506
  // No related videos
507
  add_settings_field(
508
  $this->option_name . 'norel', // id
509
- __('Hide related videos', 'youtube-channel'), // Title
510
- array(&$this, 'settings_field_checkbox'), // Callback
511
  $this->slug . '_video', // Page
512
  'ytc_video', // section
513
  array(
514
- 'field' => $this->option_name . "[norel]",
515
- 'description' => __("Enable this option to hide related videos after finished playback", 'youtube-channel'),
516
  'class' => 'checkbox',
517
  'value' => $this->defaults['norel'],
518
  ) // args
@@ -520,13 +533,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
520
  // Hide YT logo
521
  add_settings_field(
522
  $this->option_name . 'modestbranding', // id
523
- __('Hide YT logo', 'youtube-channel'), // Title
524
- array(&$this, 'settings_field_checkbox'), // Callback
525
  $this->slug . '_video', // Page
526
  'ytc_video', // section
527
  array(
528
- 'field' => $this->option_name . "[modestbranding]",
529
- 'description' => __("Enable this option to hide YouTube logo from playback control bar. Does not work for all videos.", 'youtube-channel'),
530
  'class' => 'checkbox',
531
  'value' => $this->defaults['modestbranding'],
532
  ) // args
@@ -534,13 +547,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
534
  // Hide Annotations
535
  add_settings_field(
536
  $this->option_name . 'hideanno', // id
537
- __('Hide video annotations', 'youtube-channel'), // Title
538
- array(&$this, 'settings_field_checkbox'), // Callback
539
  $this->slug . '_video', // Page
540
  'ytc_video', // section
541
  array(
542
- 'field' => $this->option_name . "[hideanno]",
543
- 'description' => __("Enable this option to hide video annotations (custom text set by uploader over video during playback)", 'youtube-channel'),
544
  'class' => 'checkbox',
545
  'value' => $this->defaults['hideanno'],
546
  ) // args
@@ -548,13 +561,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
548
  // Hide Video Info
549
  add_settings_field(
550
  $this->option_name . 'hideinfo', // id
551
- __('Hide video info', 'youtube-channel'), // Title
552
- array(&$this, 'settings_field_checkbox'), // Callback
553
  $this->slug . '_video', // Page
554
  'ytc_video', // section
555
  array(
556
- 'field' => $this->option_name . "[hideinfo]",
557
- 'description' => __("Enable this option to hide informations about video before play start (video title and uploader in overlay)", 'youtube-channel'),
558
  'class' => 'checkbox',
559
  'value' => $this->defaults['hideinfo'],
560
  ) // args
@@ -563,47 +576,47 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
563
  register_setting(
564
  'ytc_video', // Setting group
565
  $this->option_name, // option name
566
- array($this, 'sanitize_options')
567
  );
568
 
569
  // =========================== CONTENT ===========================
570
  // --- Add settings section Content so we can add fields to it ---
571
  add_settings_section(
572
  'ytc_content', // Section Name
573
- __('Content Tweaks', 'youtube-channel'), // Section Title
574
- array(&$this, 'settings_content_section_description'), // Section Callback Function
575
  $this->slug . '_content' // Page Name
576
  );
577
  // --- Add Fields to video section ---
578
  // Video Title
579
  add_settings_field(
580
  $this->option_name . 'showtitle', // id
581
- __('Show video title', 'youtube-channel'), // Title
582
- array(&$this, 'settings_field_select'), // Callback
583
  $this->slug . '_content', // Page
584
  'ytc_content', // section
585
  array(
586
- 'field' => $this->option_name . "[showtitle]",
587
- 'description' => __("Select should we and where display title of video", 'youtube-channel'),
588
  'class' => 'regular-text',
589
  'value' => $this->defaults['showtitle'],
590
  'items' => array(
591
- 'none' => __('Hide title', 'youtube-channel'),
592
- 'above' => __('Above video/thumbnail', 'youtube-channel'),
593
- 'below' => __('Below video/thumbnail', 'youtube-channel'),
594
- )
595
  ) // args
596
  );
597
  // Video Description
598
  add_settings_field(
599
  $this->option_name . 'showdesc', // id
600
- __('Show video description', 'youtube-channel'), // Title
601
- array(&$this, 'settings_field_checkbox'), // Callback
602
  $this->slug . '_content', // Page
603
  'ytc_content', // section
604
  array(
605
- 'field' => $this->option_name . "[showdesc]",
606
- 'description' => __("Enable this option to display description for video", 'youtube-channel'),
607
  'class' => 'checkbox',
608
  'value' => $this->defaults['showdesc'],
609
  ) // args
@@ -611,18 +624,18 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
611
  // Description length
612
  add_settings_field(
613
  $this->option_name . 'desclen', // id
614
- __('Description length', 'youtube-channel'), // Title
615
- array(&$this, 'settings_field_input_number'), // Callback
616
  $this->slug . '_content', // Page
617
  'ytc_content', // section
618
  array(
619
- 'field' => $this->option_name . "[desclen]",
620
- 'description' => __('Enter length for video description in characters (0 for full length)', 'youtube-channel'),
621
  'class' => 'num',
622
  'value' => $this->defaults['desclen'],
623
  'min' => 0,
624
  'max' => 2500,
625
- 'std' => 0
626
  ) // args
627
  );
628
 
@@ -630,70 +643,70 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
630
  register_setting(
631
  'ytc_content', // Setting group
632
  $this->option_name, // option name
633
- array($this, 'sanitize_options')
634
  );
635
 
636
  // =========================== LINK ===========================
637
  // --- Add settings section Link to Channel so we can add fields to it ---
638
  add_settings_section(
639
  'ytc_link', // Section Name
640
- __('Link to Channel', 'youtube-channel'), // Section Title
641
- array(&$this, 'settings_link_section_description'), // Section Callback Function
642
  $this->slug . '_link' // Page Name
643
  );
644
  // --- Add Fields to video section ---
645
  // Link to...
646
  add_settings_field(
647
  $this->option_name . 'link_to', // id
648
- __('Link to...', 'youtube-channel'), // Title
649
- array(&$this, 'settings_field_select'), // Callback
650
  $this->slug . '_link', // Page
651
  'ytc_link', // section
652
  array(
653
- 'field' => $this->option_name . "[link_to]",
654
- // 'label' => __('Ratio:', 'youtube-channel'),
655
- 'description' => __('Set where link will lead visitors', 'youtube-channel'),
656
  'class' => 'regular-text',
657
  'value' => $this->defaults['link_to'],
658
  'items' => array(
659
- 'none' => __('Hide link', 'youtube-channel'),
660
- 'vanity' => __('Vanity custom URL', 'youtube-channel'),
661
- 'channel' => __('Channel page URL', 'youtube-channel'),
662
- 'legacy' => __('Legacy username page', 'youtube-channel')
663
- )
664
  ) // args
665
  );
666
  // Open in...
667
  add_settings_field(
668
  $this->option_name . 'popup_goto', // id
669
- __('Open link in...', 'youtube-channel'), // Title
670
- array(&$this, 'settings_field_select'), // Callback
671
  $this->slug . '_link', // Page
672
  'ytc_link', // section
673
  array(
674
- 'field' => $this->option_name . "[popup_goto]",
675
- // 'label' => __('Ratio:', 'youtube-channel'),
676
- 'description' => __('Set where link will be opened', 'youtube-channel'),
677
  'class' => 'regular-text',
678
  'value' => $this->defaults['popup_goto'],
679
  'items' => array(
680
- '0' => __('same window', 'youtube-channel'),
681
- '1' => __('new window (JavaScript)', 'youtube-channel'),
682
- '2' => __('new window (target="_blank")', 'youtube-channel')
683
- )
684
  ) // args
685
  );
686
  // Visit channel text
687
  add_settings_field(
688
  $this->option_name . 'goto_txt', // id
689
- __('Text for Visit channel link', 'youtube-channel'), // Title
690
- array(&$this, 'settings_field_input_text'), // Callback
691
  $this->slug . '_link', // Page
692
  'ytc_link', // section
693
  array(
694
- 'field' => $this->option_name . "[goto_txt]",
695
  'class' => 'regular-text',
696
- 'description' => __('Set default title for link', 'youtube-channel'),
697
  'value' => $this->defaults['goto_txt'],
698
  ) // args
699
  );
@@ -702,7 +715,7 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
702
  register_setting(
703
  'ytc_link', // Setting group
704
  $this->option_name, // option name
705
- array($this, 'sanitize_options')
706
  );
707
 
708
  } // eom register_settings()
@@ -714,11 +727,11 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
714
 
715
  // Add a page to manage this plugin's settings
716
  add_options_page(
717
- __('YouTube Channel', 'youtube-channel'),
718
- __('YouTube Channel','youtube-channel'),
719
  'manage_options',
720
  $this->slug,
721
- array(&$this, 'plugin_settings_page')
722
  );
723
 
724
  } // eom add_menu()
@@ -737,16 +750,16 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
737
  ),
738
  array(
739
  'a' => array(
740
- 'href' => array(),
741
- 'target' => array('_blank')
742
- )
743
  )
744
  ),
745
- __('YouTube Channel', 'youtube-channel'),
746
- __('Channel ID', 'youtube-channel'),
747
- __('Vanity URL', 'youtube-channel'),
748
  esc_url( 'https://www.youtube.com/account_advanced' ),
749
- __('YouTube Account Overview', 'youtube-channel')
750
  )
751
  ?></p>
752
  <?php
@@ -755,8 +768,8 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
755
  ?>
756
  <p><?php
757
  printf(
758
- __('Configure video specific defaults for %s used as fallback options in widget or shortcodes.', 'youtube-channel'),
759
- __('YouTube Channel', 'youtube-channel')
760
  );
761
  ?></p>
762
  <?php
@@ -765,8 +778,8 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
765
  ?>
766
  <p><?php
767
  printf(
768
- __('Configure defaults of content around and over videos for %s used as fallback options in widget or shortcodes.', 'youtube-channel'),
769
- __('YouTube Channel', 'youtube-channel')
770
  );
771
  ?></p>
772
  <?php
@@ -775,8 +788,8 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
775
  ?>
776
  <p><?php
777
  printf(
778
- __('Configure defaults for link to channel below %s block used as fallback options in widget or shortcodes.', 'youtube-channel'),
779
- __('YouTube Channel', 'youtube-channel')
780
  );
781
  ?></p>
782
  <?php
@@ -785,7 +798,7 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
785
  /**
786
  * This function provides separator for settings fields
787
  */
788
- public function settings_field_separator($args=null) {
789
  echo '<hr>';
790
  } // eom settings_field_input_text()
791
 
@@ -796,7 +809,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
796
 
797
  extract( $args );
798
 
799
- echo sprintf('<input type="text" name="%s" id="%s" value="%s" class="%s" /><p class="description">%s</p>', $field, $field, $value, $class, $description);
 
 
 
 
 
 
800
 
801
  } // eom settings_field_input_text()
802
 
@@ -807,7 +826,13 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
807
 
808
  extract( $args );
809
 
810
- echo sprintf('<input type="password" name="%s" id="%s" value="%s" class="%s" /><p class="description">%s</p>', $field, $field, $value, $class, $description);
 
 
 
 
 
 
811
 
812
  } // eom settings_field_input_text()
813
 
@@ -818,7 +843,15 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
818
 
819
  extract( $args );
820
 
821
- echo sprintf('<input type="number" name="%s" id="%s" value="%s" min="%s" max="%s" class="%s" /><p class="description">%s</p>', $field, $field, $value, $min, $max, $class, $description);
 
 
 
 
 
 
 
 
822
 
823
  } // eom settings_field_input_text()
824
 
@@ -831,13 +864,12 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
831
 
832
  $html = '';
833
  // $html .= sprintf('<label for="%s">%s</label><br>', $field, $label);
834
- $html .= sprintf('<select id="%s" name="%s">', $field, $field);
835
- foreach ($items as $key=>$val)
836
- {
837
- $selected = ($value==$key) ? 'selected="selected"' : '';
838
- $html .= sprintf('<option %s value="%s">%s</option>',$selected,$key,$val);
839
  }
840
- $html .= sprintf('</select><p class="description">%s</p>',$description);
841
 
842
  echo $html;
843
 
@@ -850,8 +882,14 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
850
 
851
  extract( $args );
852
 
853
- $checked = ( !empty($args['value']) ) ? 'checked="checked"' : '';
854
- echo sprintf('<label for="%s"><input type="checkbox" name="%s" id="%s" value="1" class="%s" %s />%s</label>', $field, $field, $field, $class, $checked, $description);
 
 
 
 
 
 
855
 
856
  } // eom settings_field_checkbox()
857
 
@@ -868,22 +906,14 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
868
  foreach ( $items as $key => $label ) {
869
 
870
  $checked = '';
871
- if ( ! empty($value) ) {
872
- $checked = ( in_array($key, $value) ) ? 'checked="checked"' : '';
873
  }
874
 
875
  $out .= sprintf(
876
- '<label for="%s_%s"><input type="checkbox" name="%s[]" id="%s_%s" value="%s" class="%s" %s />%s</label><br>',
877
  $field,
878
  $key,
879
-
880
- $field,
881
-
882
- $field,
883
- $key,
884
-
885
- $key,
886
-
887
  $class,
888
  $checked,
889
  $label
@@ -891,7 +921,7 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
891
  }
892
 
893
  $out .= '</fieldset>';
894
- $out .= sprintf('<p class="description">%s</p>' , $description);
895
 
896
  echo $out;
897
 
@@ -906,17 +936,16 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
906
 
907
  $html = '';
908
 
909
- if ( ! empty($prescription) )
910
- $html .= sprintf('<p class="prescription">%s</p>', $prescription);
 
911
 
912
- foreach ($items as $key=>$val) {
913
 
914
- $checked = ($value==$key) ? 'checked="checked"' : '';
915
  $html .= sprintf(
916
- '<label for="%s_%s"><input type="radio" name="%s" id="%s_%s" value="%s" %s>%s</label><br />',
917
- $field, $key,
918
  $field,
919
- $field, $key,
920
  $key,
921
  $checked,
922
  $val
@@ -924,7 +953,7 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
924
 
925
  } // foreach $items
926
 
927
- $html .= sprintf('<p class="description">%s</p>',$description);
928
 
929
  echo $html;
930
 
@@ -935,12 +964,12 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
935
  */
936
  public function plugin_settings_page() {
937
 
938
- if ( ! current_user_can('manage_options') ) {
939
- wp_die(__('You do not have sufficient permissions to access this page.'));
940
  }
941
 
942
  // Render the settings template
943
- require_once('settings_template.php');
944
 
945
  } // eom plugin_settings_page()
946
 
@@ -956,52 +985,51 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
956
 
957
  // --- General ---
958
  case 'ytc_general':
959
- $apikey = ( defined('YOUTUBE_DATA_API_KEY') ) ? YOUTUBE_DATA_API_KEY : '';
960
- $sanitized['apikey'] = ( ! empty($options['apikey']) ) ? trim($options['apikey']) : $apikey;
961
- $sanitized['channel'] = ( ! empty($options['channel']) ) ? trim($options['channel']) : ''; //$this->defaults['channel'];
962
- $sanitized['vanity'] = ( ! empty($options['vanity']) ) ? trim($options['vanity']) : ''; //$this->defaults['vanity'];
963
- $sanitized['username'] = ( ! empty($options['username']) ) ? trim($options['username']) : ''; //$this->defaults['username'];
964
- $sanitized['playlist'] = ( ! empty($options['playlist']) ) ? trim($options['playlist']) : ''; //$this->defaults['playlist'];
965
- $sanitized['resource'] = ( isset($options['resource']) ) ? intval($options['resource']) : $this->defaults['resource'];
966
- $sanitized['cache'] = ( isset($options['cache']) ) ? intval($options['cache']) : $this->defaults['cache'];
967
- $sanitized['fetch'] = ( ! empty($options['fetch']) ) ? intval($options['fetch']) : $this->defaults['fetch'];
968
- $sanitized['num'] = ( ! empty($options['num']) ) ? intval($options['num']) : $this->defaults['num'];
969
- $sanitized['privacy'] = ( ! empty($options['privacy']) && $options['privacy'] ) ? 1 : 0;
970
- $sanitized['tinymce'] = ( ! empty($options['tinymce']) && $options['tinymce'] ) ? 1 : 0;
971
  break; // General
972
 
973
  // --- Video ---
974
  case 'ytc_video':
975
- $sanitized['width'] = ( ! empty($options['width']) ) ? intval($options['width']) : $this->defaults['width'];
976
- $sanitized['ratio'] = ( isset($options['ratio']) ) ? intval($options['ratio']) : $this->defaults['ratio'];
977
- $sanitized['display'] = ( ! empty($options['display']) ) ? trim($options['display']) : $this->defaults['display'];
978
- $sanitized['responsive'] = ( ! empty($options['responsive']) && $options['responsive'] ) ? 1 : 0;
979
- $sanitized['playsinline'] = ( ! empty($options['playsinline']) && $options['playsinline'] ) ? 1 : 0;
980
- $sanitized['nolightbox'] = ( ! empty($options['nolightbox']) && $options['nolightbox'] ) ? 1 : 0;
981
- $sanitized['fullscreen'] = ( ! empty($options['fullscreen']) && $options['fullscreen'] ) ? 1 : 0;
982
-
983
- $sanitized['themelight'] = ( ! empty($options['themelight']) && $options['themelight'] ) ? 1 : 0;
984
- $sanitized['controls'] = ( ! empty($options['controls']) && $options['controls'] ) ? 1 : 0;
985
- $sanitized['autoplay'] = ( ! empty($options['autoplay']) && $options['autoplay'] ) ? 1 : 0;
986
- $sanitized['autoplay_mute'] = ( ! empty($options['autoplay_mute']) && $options['autoplay_mute'] ) ? 1 : 0;
987
- $sanitized['norel'] = ( ! empty($options['norel']) && $options['norel'] ) ? 1 : 0;
988
- $sanitized['modestbranding'] = ( ! empty($options['modestbranding']) && $options['modestbranding'] ) ? 1 : 0;
989
- $sanitized['hideanno'] = ( ! empty($options['hideanno']) && $options['hideanno'] ) ? 1 : 0;
990
- $sanitized['hideinfo'] = ( ! empty($options['hideinfo']) && $options['hideinfo'] ) ? 1 : 0;
991
  break; // Video
992
 
993
  // --- Content ---
994
  case 'ytc_content':
995
- $sanitized['showtitle'] = ( ! empty($options['showtitle']) ) ? $options['showtitle'] : $this->defaults['showtitle'];
996
- $sanitized['showdesc'] = ( ! empty($options['showdesc']) && $options['showdesc'] ) ? 1 : 0;
997
- $sanitized['desclen'] = ( ! empty($options['desclen']) ) ? intval($options['desclen']) : $this->defaults['desclen'];
998
  break; // Content
999
 
1000
  // --- Link to Channel ---
1001
  case 'ytc_link':
1002
- $sanitized['link_to'] = ( isset($options['link_to']) ) ? intval($options['link_to']) : $this->defaults['link_to'];
1003
- $sanitized['goto_txt'] = ( ! empty($options['goto_txt']) ) ? $options['goto_txt'] : $this->defaults['goto_txt'];
1004
- $sanitized['popup_goto'] = ( isset($options['popup_goto']) ) ? intval($options['popup_goto']) : $this->defaults['popup_goto'];
1005
  break; // Link to Channel
1006
 
1007
  } // switch
1
  <?php
2
 
3
+ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
4
 
5
  class WPAU_YOUTUBE_CHANNEL_SETTINGS {
6
 
21
  $this->defaults = get_option( $this->option_name );
22
 
23
  // register actions
24
+ add_action( 'admin_init', array( &$this, 'register_settings' ) );
25
+ add_action( 'admin_menu', array( &$this, 'add_menu' ) );
26
 
27
  } // END public function __construct
28
 
35
  // --- Add settings section General so we can add fields to it ---
36
  add_settings_section(
37
  'ytc_general', // Section Name
38
+ __( 'General', 'youtube-channel' ), // Section Title
39
+ array( &$this, 'settings_general_section_description' ), // Section Callback Function
40
  $this->slug . '_general' // Page Name
41
  );
42
  // --- Add Fields to General section ---
43
  // YouTube Data API Key
44
  add_settings_field(
45
  $this->option_name . 'apikey', // Setting Slug
46
+ __( 'YouTube Data API Key', 'youtube-channel' ), // Title
47
+ array( &$this, 'settings_field_input_password' ), // Callback
48
  $this->slug . '_general', // Page Name
49
  'ytc_general', // Section Name
50
  array(
51
  'field' => $this->option_name . '[apikey]',
52
  'description' => sprintf(
53
+ '<strong>[%s]</strong> %s',
54
+ __( 'Required', 'youtube-channel' ),
55
  sprintf(
56
  wp_kses(
57
  __(
58
+ 'Your YouTube Data API Key (get it from <a href="%1$s" target="_blank">%2$s</a>)',
59
  'youtube-channel'
60
  ),
61
  array(
62
  'a' => array(
63
+ 'href' => array(),
64
+ 'target' => array( '_blank' ),
65
+ ),
66
  )
67
  ),
68
  esc_url( 'https://console.developers.google.com/project' ),
69
+ __( 'Google Developers Console', 'youtube-channel' )
70
  )
71
  ),
72
  'class' => 'regular-text password',
76
  // Channel ID
77
  add_settings_field(
78
  $this->option_name . 'channel', // Setting Slug
79
+ __( 'YouTube Channel ID', 'youtube-channel' ), // Title
80
+ array( &$this, 'settings_field_input_text' ), // Callback
81
  $this->slug . '_general', // Page Name
82
  'ytc_general', // Section Name
83
  array(
84
  'field' => $this->option_name . '[channel]',
85
  'description' => sprintf(
86
+ '<strong>[%s]</strong> %s',
87
+ __( 'Required', 'youtube-channel' ),
88
  sprintf(
89
  wp_kses(
90
  __(
91
+ 'Your YouTube Channel ID (get it from <a href="%1$s" target="_blank">%2$s</a>)',
92
  'youtube-channel'
93
  ),
94
  array(
95
  'a' => array(
96
+ 'href' => array(),
97
+ 'target' => array( '_blank' ),
98
+ ),
99
  )
100
  ),
101
  esc_url( 'https://www.youtube.com/account_advanced' ),
102
+ __( 'YouTube Account Overview', 'youtube-channel' )
103
  )
104
  ),
105
  'class' => 'regular-text',
109
  // Vanity
110
  add_settings_field(
111
  $this->option_name . 'vanity', // id
112
+ __( 'YouTube Vanity Name', 'youtube-channel' ), // Title
113
+ array( &$this, 'settings_field_input_text' ), // Callback
114
  $this->slug . '_general', // Page
115
  'ytc_general', // section
116
  array(
117
+ 'field' => $this->option_name . '[vanity]',
118
  'description' => sprintf(
119
+ '[%s] %s',
120
+ __( 'Optional', 'youtube-channel' ),
121
+ sprintf(
122
+ wp_kses(
123
+ __(
124
+ 'Your YouTube Custom Name (get only part after %1$s instead whole URL from <a href="%2$s" target="_blank">%3$s</a>)',
125
+ 'youtube-channel'
 
 
 
 
 
 
126
  ),
127
+ array(
128
+ 'a' => array(
129
+ 'href' => array(),
130
+ 'target' => array( '_blank' ),
131
+ ),
132
+ )
133
+ ),
134
+ 'www.youtube.com/c/',
135
+ esc_url( 'https://www.youtube.com/account_advanced' ),
136
+ __( 'YouTube Account Overview', 'youtube-channel' )
137
+ )
138
+ ),
139
  'class' => 'regular-text',
140
  'value' => $this->defaults['vanity'],
141
  ) // args
143
  // Username
144
  add_settings_field(
145
  $this->option_name . 'username', // id
146
+ __( 'Legacy YouTube Username', 'youtube-channel' ), // Title
147
+ array( &$this, 'settings_field_input_text' ), // Callback
148
  $this->slug . '_general', // Page
149
  'ytc_general', // section
150
  array(
151
+ 'field' => $this->option_name . '[username]',
152
  'description' => sprintf(
153
+ '[%s] %s',
154
+ __( 'Optional', 'youtube-channel' ),
155
+ __( 'Your YouTube legacy username', 'youtube-channel' )
156
  ),
157
  'class' => 'regular-text',
158
  'value' => $this->defaults['username'],
161
  // Default Playlist
162
  add_settings_field(
163
  $this->option_name . 'playlist', // id
164
+ __( 'Default Playlist ID', 'youtube-channel' ), // Title
165
+ array( &$this, 'settings_field_input_text' ), // Callback
166
  $this->slug . '_general', // Page
167
  'ytc_general', // section
168
  array(
169
+ 'field' => $this->option_name . '[playlist]',
170
  'description' => sprintf(
171
+ '[%s] %s',
172
+ __( 'Optional', 'youtube-channel' ),
173
+ __( 'Enter default playlist ID (not playlist name)', 'youtube-channel' )
174
+ ),
175
  'class' => 'regular-text',
176
  'value' => $this->defaults['playlist'],
177
  ) // args
179
  // Resource
180
  add_settings_field(
181
  $this->option_name . 'resource', // id
182
+ __( 'Resource to use', 'youtube-channel' ), // Title
183
+ array( &$this, 'settings_field_select' ), // Callback
184
  $this->slug . '_general', // Page
185
  'ytc_general', // section
186
  array(
187
+ 'field' => $this->option_name . '[resource]',
188
+ 'label' => __( 'Resource:', 'youtube-channel' ),
189
+ 'description' => __( 'What to use as resource for feeds', 'youtube-channel' ),
190
  'class' => 'regular-text',
191
  'value' => $this->defaults['resource'],
192
  'items' => array(
193
+ '0' => __( 'Channel', 'youtube-channel' ),
194
+ '1' => __( 'Favourites', 'youtube-channel' ),
195
+ '3' => __( 'Liked Video', 'youtube-channel' ),
196
+ '2' => __( 'Playlist', 'youtube-channel' ),
197
+ ),
198
  ) // args
199
  );
200
  // Cache
201
  add_settings_field(
202
  $this->option_name . 'cache', // id
203
+ __( 'Cache Timeout','youtube-channel' ),
204
+ array( &$this, 'settings_field_select' ),
205
  $this->slug . '_general',
206
  'ytc_general',
207
  array(
208
+ 'field' => $this->option_name . '[cache]',
209
+ 'description' => __( 'Define caching timeout for YouTube feeds, in seconds', 'youtube-channel' ),
210
  'class' => 'wide-text',
211
  'value' => $this->defaults['cache'],
212
  'items' => array(
213
+ '0' => __( 'Do not chache', 'youtube-channel' ),
214
+ '60' => __( '1 minute', 'youtube-channel' ),
215
+ '300' => __( '5 minutes', 'youtube-channel' ),
216
+ '900' => __( '15 minutes', 'youtube-channel' ),
217
+ '1800' => __( '30 minutes', 'youtube-channel' ),
218
+ '3600' => __( '1 hour', 'youtube-channel' ),
219
+ '7200' => __( '2 hours', 'youtube-channel' ),
220
+ '18000' => __( '5 hours', 'youtube-channel' ),
221
+ '36000' => __( '10 hours', 'youtube-channel' ),
222
+ '43200' => __( '12 hours', 'youtube-channel' ),
223
+ '64800' => __( '18 hours', 'youtube-channel' ),
224
+ '86400' => __( '1 day', 'youtube-channel' ),
225
+ '172800' => __( '2 days', 'youtube-channel' ),
226
+ '259200' => __( '3 days', 'youtube-channel' ),
227
+ '345600' => __( '4 days', 'youtube-channel' ),
228
+ '432000' => __( '5 days', 'youtube-channel' ),
229
+ '518400' => __( '6 days', 'youtube-channel' ),
230
+ '604800' => __( '1 week', 'youtube-channel' ),
231
+ '1209600' => __( '2 weeks', 'youtube-channel' ),
232
+ '1814400' => __( '3 weeks', 'youtube-channel' ),
233
+ '2419200' => __( '1 month', 'youtube-channel' ),
234
+ ),
235
  )
236
  );
237
  // Fetch
238
  add_settings_field(
239
  $this->option_name . 'fetch', // id
240
+ __( 'Fetch', 'youtube-channel' ), // Title
241
+ array( &$this, 'settings_field_input_number' ), // Callback
242
  $this->slug . '_general', // Page
243
  'ytc_general', // section
244
  array(
245
+ 'field' => $this->option_name . '[fetch]',
246
+ 'description' => __( 'Number of videos that will be used for random pick (min 2, max 50, default 25)', 'youtube-channel' ),
247
  'class' => 'num',
248
  'value' => $this->defaults['fetch'],
249
  'min' => 1,
250
  'max' => 50,
251
+ 'std' => 25,
252
  ) // args
253
  );
254
  // Show
255
  add_settings_field(
256
  $this->option_name . 'num', // id
257
+ __( 'Show', 'youtube-channel' ), // Title
258
+ array( &$this, 'settings_field_input_number' ), // Callback
259
  $this->slug . '_general', // Page
260
  'ytc_general', // section
261
  array(
262
+ 'field' => $this->option_name . '[num]',
263
+ 'description' => __( 'Number of videos to display', 'youtube-channel' ),
264
  'class' => 'num',
265
  'value' => $this->defaults['num'],
266
  'min' => 1,
267
  'max' => 50,
268
+ 'std' => 1,
269
  ) // args
270
  );
271
  // Enhanced privacy
272
  add_settings_field(
273
  $this->option_name . 'privacy', // id
274
+ __( 'Use Enhanced privacy', 'youtube-channel' ), // Title
275
+ array( &$this, 'settings_field_checkbox' ), // Callback
276
  $this->slug . '_general', // Page
277
  'ytc_general', // section
278
  array(
279
+ 'field' => $this->option_name . '[privacy]',
280
  'description' => sprintf(
281
  wp_kses(
282
  __(
283
+ 'Enable this option to protect your visitors privacy. <a href="%1$s" target="_blank">%2$s</a>',
284
  'youtube-channel'
285
  ),
286
  array(
287
  'a' => array(
288
+ 'href' => array(),
289
+ 'target' => array( '_blank' ),
290
+ ),
291
  )
292
  ),
293
+ esc_url( 'http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780' ),
294
+ __( 'Learn more here', 'youtube-channel' )
295
  ),
296
  'class' => 'checkbox',
297
  'value' => $this->defaults['privacy'],
300
  // TinyMCE icon
301
  add_settings_field(
302
  $this->option_name . 'tinymce', // id
303
+ __( 'Enable TinyMCE button', 'youtube-channel' ), // Title
304
+ array( &$this, 'settings_field_checkbox' ), // Callback
305
  $this->slug . '_general', // Page
306
  'ytc_general', // section
307
  array(
308
+ 'field' => $this->option_name . '[tinymce]',
309
  'description' => sprintf(
310
+ __( 'Disable this option to hide %s button from TinyMCE toolbar on post and page editor.', 'youtube-channel' ),
311
+ __( 'YouTube Channel', 'youtube-channel' )
312
  ),
313
  'class' => 'checkbox',
314
  'value' => $this->defaults['tinymce'],
318
  register_setting(
319
  'ytc_general', // Setting group
320
  $this->option_name, // option name
321
+ array( $this, 'sanitize_options' )
322
  );
323
 
324
  // =========================== VIDEO ===========================
325
  // --- Add settings section Video so we can add fields to it ---
326
  add_settings_section(
327
  'ytc_video', // Section Name
328
+ __( 'Video Tweaks', 'youtube-channel' ), // Section Title
329
+ array( &$this, 'settings_video_section_description' ), // Section Callback Function
330
  $this->slug . '_video' // Page Name
331
  );
332
  // --- Add Fields to video section ---
333
  // Width
334
  add_settings_field(
335
  $this->option_name . 'width', // id
336
+ __( 'Initial Width', 'youtube-channel' ), // Title
337
+ array( &$this, 'settings_field_input_number' ), // Callback
338
  $this->slug . '_video', // Page
339
  'ytc_video', // section
340
  array(
341
+ 'field' => $this->option_name . '[width]',
342
+ 'description' => __( 'Set default width for displayed video, in pixels', 'youtube-channel' ),
343
  'class' => 'num',
344
  'value' => $this->defaults['width'],
345
  'min' => 120,
346
  'max' => 1980,
347
+ 'std' => 306,
348
  ) // args
349
  );
350
  // Aspect Ratio
351
  add_settings_field(
352
  $this->option_name . 'ratio', // id
353
+ __( 'Aspect ratio', 'youtube-channel' ), // Title
354
+ array( &$this, 'settings_field_select' ), // Callback
355
  $this->slug . '_video', // Page
356
  'ytc_video', // section
357
  array(
358
+ 'field' => $this->option_name . '[ratio]',
359
+ 'description' => __( 'Select aspect ratio for displayed video', 'youtube-channel' ),
 
360
  'class' => 'regular-text',
361
  'value' => $this->defaults['ratio'],
362
  'items' => array(
363
  '3' => '16:9',
364
+ '1' => '4:3',
365
+ ),
366
  ) // args
367
  );
368
  // Display
369
  add_settings_field(
370
  $this->option_name . 'display', // id
371
+ __( 'What to show?', 'youtube-channel' ), // Title
372
+ array( &$this, 'settings_field_select' ), // Callback
373
  $this->slug . '_video', // Page
374
  'ytc_video', // section
375
  array(
376
+ 'field' => $this->option_name . '[display]',
377
+ 'description' => __( 'Choose how to embed video block', 'youtube-channel' ),
378
  'class' => 'regular-text',
379
  'value' => $this->defaults['display'],
380
  'items' => array(
381
+ 'thumbnail' => __( 'Thumbnail', 'youtube-channel' ),
382
+ 'iframe' => __( 'HTML5 (iframe)', 'youtube-channel' ),
383
+ 'iframe2' => __( 'HTML5 (iframe) Asynchronous', 'youtube-channel' ),
384
+ 'playlist' => __( 'Embedded Playlist', 'youtube-channel' ),
385
  // 'gallery' => 'Gallery'
386
+ ),
387
  ) // args
388
  );
389
  // Responsive
390
  add_settings_field(
391
  $this->option_name . 'responsive', // id
392
+ __( 'Enable Responsive', 'youtube-channel' ), // Title
393
+ array( &$this, 'settings_field_checkbox' ), // Callback
394
  $this->slug . '_video', // Page
395
  'ytc_video', // section
396
  array(
397
+ 'field' => $this->option_name . '[responsive]',
398
+ 'description' => __( 'Enable this option to make YTC videos and thumbnails responsive by default. Please note, this option will set videos and thumbnail to full width relative to parent container, and disable more than one video per row.', 'youtube-channel' ),
399
  'class' => 'checkbox',
400
  'value' => $this->defaults['responsive'],
401
  ) // args
404
  // Plays Inline
405
  add_settings_field(
406
  $this->option_name . 'playsinline', // id
407
+ __( 'Play inline on iOS', 'youtube-channel' ), // Title
408
+ array( &$this, 'settings_field_checkbox' ), // Callback
409
  $this->slug . '_video', // Page
410
  'ytc_video', // section
411
  array(
412
+ 'field' => $this->option_name . '[playsinline]',
413
  'description' => sprintf(
414
+ wp_kses(
415
+ __(
416
+ 'Enable this option to override fullscreen playback on iOS, and force inline playback on page and in lightbox. <a href="%1$s" target="_blank">%2$s</a>',
417
+ 'youtube-channel'
418
+ ),
419
+ array(
420
+ 'a' => array(
421
+ 'href' => array(),
422
+ 'target' => array( '_blank' ),
423
+ ),
424
+ )
425
  ),
426
+ esc_url( 'https://developers.google.com/youtube/player_parameters#playsinline' ),
427
+ __( 'Learn more here', 'youtube-channel' )
428
  ),
429
  'class' => 'checkbox',
430
+ 'value' => ( isset( $this->defaults['playsinline'] ) ) ? $this->defaults['playsinline'] : '',
431
  ) // args
432
  );
433
  // No Lightbox
434
  add_settings_field(
435
  $this->option_name . 'nolightbox', // id
436
+ __( 'Disable Lightbox', 'youtube-channel' ), // Title
437
+ array( &$this, 'settings_field_checkbox' ), // Callback
438
  $this->slug . '_video', // Page
439
  'ytc_video', // section
440
  array(
441
+ 'field' => $this->option_name . '[nolightbox]',
442
+ 'description' => __( 'Enable this option to disable built-in lightbox for thumbnails (in case that you have youtube links lightbox trigger in theme or other plugin).', 'youtube-channel' ),
443
  'class' => 'checkbox',
444
+ 'value' => ( isset( $this->defaults['nolightbox'] ) ) ? $this->defaults['nolightbox'] : '',
445
  ) // args
446
  );
447
  // Full Screen
448
  add_settings_field(
449
  $this->option_name . 'fullscreen', // id
450
+ __( 'Enable Full Screen', 'youtube-channel' ), // Title
451
+ array( &$this, 'settings_field_checkbox' ), // Callback
452
  $this->slug . '_video', // Page
453
  'ytc_video', // section
454
  array(
455
+ 'field' => $this->option_name . '[fullscreen]',
456
+ 'description' => __( 'Enable this option to make available Full Screen button for embedded playlists.', 'youtube-channel' ),
457
  'class' => 'checkbox',
458
  'value' => $this->defaults['fullscreen'],
459
  ) // args
462
  // Light Theme
463
  add_settings_field(
464
  $this->option_name . 'themelight', // id
465
+ __( 'Light Theme', 'youtube-channel' ), // Title
466
+ array( &$this, 'settings_field_checkbox' ), // Callback
467
  $this->slug . '_video', // Page
468
  'ytc_video', // section
469
  array(
470
+ 'field' => $this->option_name . '[themelight]',
471
+ 'description' => __( 'Enable this option to use light theme for playback controls instead dark.', 'youtube-channel' ),
472
  'class' => 'checkbox',
473
  'value' => $this->defaults['themelight'],
474
  ) // args
476
  // No Player Controls
477
  add_settings_field(
478
  $this->option_name . 'controls', // id
479
+ __( 'Hide Player Controls', 'youtube-channel' ), // Title
480
+ array( &$this, 'settings_field_checkbox' ), // Callback
481
  $this->slug . '_video', // Page
482
  'ytc_video', // section
483
  array(
484
+ 'field' => $this->option_name . '[controls]',
485
+ 'description' => __( 'Enable this option to hide playback controls', 'youtube-channel' ),
486
  'class' => 'checkbox',
487
  'value' => $this->defaults['controls'],
488
  ) // args
491
  // Autoplay
492
  add_settings_field(
493
  $this->option_name . 'autoplay', // id
494
+ __( 'Autoplay video or playlist', 'youtube-channel' ), // Title
495
+ array( &$this, 'settings_field_checkbox' ), // Callback
496
  $this->slug . '_video', // Page
497
  'ytc_video', // section
498
  array(
499
+ 'field' => $this->option_name . '[autoplay]',
500
+ 'description' => __( 'Enable this option to start video playback right after block is rendered', 'youtube-channel' ),
501
  'class' => 'checkbox',
502
  'value' => $this->defaults['autoplay'],
503
  ) // args
505
  // Mute on autoplay
506
  add_settings_field(
507
  $this->option_name . 'autoplay_mute', // id
508
+ __( 'Mute video on autoplay', 'youtube-channel' ), // Title
509
+ array( &$this, 'settings_field_checkbox' ), // Callback
510
  $this->slug . '_video', // Page
511
  'ytc_video', // section
512
  array(
513
+ 'field' => $this->option_name . '[autoplay_mute]',
514
+ 'description' => __( 'Enable this option to mute video when start autoplay', 'youtube-channel' ),
515
  'class' => 'checkbox',
516
  'value' => $this->defaults['autoplay_mute'],
517
  ) // args
519
  // No related videos
520
  add_settings_field(
521
  $this->option_name . 'norel', // id
522
+ __( 'Hide related videos', 'youtube-channel' ), // Title
523
+ array( &$this, 'settings_field_checkbox' ), // Callback
524
  $this->slug . '_video', // Page
525
  'ytc_video', // section
526
  array(
527
+ 'field' => $this->option_name . '[norel]',
528
+ 'description' => __( 'Enable this option to hide related videos after finished playback', 'youtube-channel' ),
529
  'class' => 'checkbox',
530
  'value' => $this->defaults['norel'],
531
  ) // args
533
  // Hide YT logo
534
  add_settings_field(
535
  $this->option_name . 'modestbranding', // id
536
+ __( 'Hide YT logo', 'youtube-channel' ), // Title
537
+ array( &$this, 'settings_field_checkbox' ), // Callback
538
  $this->slug . '_video', // Page
539
  'ytc_video', // section
540
  array(
541
+ 'field' => $this->option_name . '[modestbranding]',
542
+ 'description' => __( 'Enable this option to hide YouTube logo from playback control bar. Does not work for all videos.', 'youtube-channel' ),
543
  'class' => 'checkbox',
544
  'value' => $this->defaults['modestbranding'],
545
  ) // args
547
  // Hide Annotations
548
  add_settings_field(
549
  $this->option_name . 'hideanno', // id
550
+ __( 'Hide video annotations', 'youtube-channel' ), // Title
551
+ array( &$this, 'settings_field_checkbox' ), // Callback
552
  $this->slug . '_video', // Page
553
  'ytc_video', // section
554
  array(
555
+ 'field' => $this->option_name . '[hideanno]',
556
+ 'description' => __( 'Enable this option to hide video annotations (custom text set by uploader over video during playback)', 'youtube-channel' ),
557
  'class' => 'checkbox',
558
  'value' => $this->defaults['hideanno'],
559
  ) // args
561
  // Hide Video Info
562
  add_settings_field(
563
  $this->option_name . 'hideinfo', // id
564
+ __( 'Hide video info', 'youtube-channel' ), // Title
565
+ array( &$this, 'settings_field_checkbox' ), // Callback
566
  $this->slug . '_video', // Page
567
  'ytc_video', // section
568
  array(
569
+ 'field' => $this->option_name . '[hideinfo]',
570
+ 'description' => __( 'Enable this option to hide informations about video before play start (video title and uploader in overlay)', 'youtube-channel' ),
571
  'class' => 'checkbox',
572
  'value' => $this->defaults['hideinfo'],
573
  ) // args
576
  register_setting(
577
  'ytc_video', // Setting group
578
  $this->option_name, // option name
579
+ array( $this, 'sanitize_options' )
580
  );
581
 
582
  // =========================== CONTENT ===========================
583
  // --- Add settings section Content so we can add fields to it ---
584
  add_settings_section(
585
  'ytc_content', // Section Name
586
+ __( 'Content Tweaks', 'youtube-channel' ), // Section Title
587
+ array( &$this, 'settings_content_section_description' ), // Section Callback Function
588
  $this->slug . '_content' // Page Name
589
  );
590
  // --- Add Fields to video section ---
591
  // Video Title
592
  add_settings_field(
593
  $this->option_name . 'showtitle', // id
594
+ __( 'Show video title', 'youtube-channel' ), // Title
595
+ array( &$this, 'settings_field_select' ), // Callback
596
  $this->slug . '_content', // Page
597
  'ytc_content', // section
598
  array(
599
+ 'field' => $this->option_name . '[showtitle]',
600
+ 'description' => __( 'Select should we and where display title of video', 'youtube-channel' ),
601
  'class' => 'regular-text',
602
  'value' => $this->defaults['showtitle'],
603
  'items' => array(
604
+ 'none' => __( 'Hide title', 'youtube-channel' ),
605
+ 'above' => __( 'Above video/thumbnail', 'youtube-channel' ),
606
+ 'below' => __( 'Below video/thumbnail', 'youtube-channel' ),
607
+ ),
608
  ) // args
609
  );
610
  // Video Description
611
  add_settings_field(
612
  $this->option_name . 'showdesc', // id
613
+ __( 'Show video description', 'youtube-channel' ), // Title
614
+ array( &$this, 'settings_field_checkbox' ), // Callback
615
  $this->slug . '_content', // Page
616
  'ytc_content', // section
617
  array(
618
+ 'field' => $this->option_name . '[showdesc]',
619
+ 'description' => __( 'Enable this option to display description for video', 'youtube-channel' ),
620
  'class' => 'checkbox',
621
  'value' => $this->defaults['showdesc'],
622
  ) // args
624
  // Description length
625
  add_settings_field(
626
  $this->option_name . 'desclen', // id
627
+ __( 'Description length', 'youtube-channel' ), // Title
628
+ array( &$this, 'settings_field_input_number' ), // Callback
629
  $this->slug . '_content', // Page
630
  'ytc_content', // section
631
  array(
632
+ 'field' => $this->option_name . '[desclen]',
633
+ 'description' => __( 'Enter length for video description in characters (0 for full length)', 'youtube-channel' ),
634
  'class' => 'num',
635
  'value' => $this->defaults['desclen'],
636
  'min' => 0,
637
  'max' => 2500,
638
+ 'std' => 0,
639
  ) // args
640
  );
641
 
643
  register_setting(
644
  'ytc_content', // Setting group
645
  $this->option_name, // option name
646
+ array( $this, 'sanitize_options' )
647
  );
648
 
649
  // =========================== LINK ===========================
650
  // --- Add settings section Link to Channel so we can add fields to it ---
651
  add_settings_section(
652
  'ytc_link', // Section Name
653
+ __( 'Link to Channel', 'youtube-channel' ), // Section Title
654
+ array( &$this, 'settings_link_section_description' ), // Section Callback Function
655
  $this->slug . '_link' // Page Name
656
  );
657
  // --- Add Fields to video section ---
658
  // Link to...
659
  add_settings_field(
660
  $this->option_name . 'link_to', // id
661
+ __( 'Link to...', 'youtube-channel' ), // Title
662
+ array( &$this, 'settings_field_select' ), // Callback
663
  $this->slug . '_link', // Page
664
  'ytc_link', // section
665
  array(
666
+ 'field' => $this->option_name . '[link_to]',
667
+ // 'label' => __('Ratio:', 'youtube-channel' ),
668
+ 'description' => __( 'Set where link will lead visitors', 'youtube-channel' ),
669
  'class' => 'regular-text',
670
  'value' => $this->defaults['link_to'],
671
  'items' => array(
672
+ 'none' => __( 'Hide link', 'youtube-channel' ),
673
+ 'vanity' => __( 'Vanity custom URL', 'youtube-channel' ),
674
+ 'channel' => __( 'Channel page URL', 'youtube-channel' ),
675
+ 'legacy' => __( 'Legacy username page', 'youtube-channel' ),
676
+ ),
677
  ) // args
678
  );
679
  // Open in...
680
  add_settings_field(
681
  $this->option_name . 'popup_goto', // id
682
+ __( 'Open link in...', 'youtube-channel' ), // Title
683
+ array( &$this, 'settings_field_select' ), // Callback
684
  $this->slug . '_link', // Page
685
  'ytc_link', // section
686
  array(
687
+ 'field' => $this->option_name . '[popup_goto]',
688
+ // 'label' => __('Ratio:', 'youtube-channel' ),
689
+ 'description' => __( 'Set where link will be opened', 'youtube-channel' ),
690
  'class' => 'regular-text',
691
  'value' => $this->defaults['popup_goto'],
692
  'items' => array(
693
+ '0' => __( 'same window', 'youtube-channel' ),
694
+ '1' => __( 'new window (JavaScript)', 'youtube-channel' ),
695
+ '2' => __( 'new window (target="_blank")', 'youtube-channel' ),
696
+ ),
697
  ) // args
698
  );
699
  // Visit channel text
700
  add_settings_field(
701
  $this->option_name . 'goto_txt', // id
702
+ __( 'Text for Visit channel link', 'youtube-channel' ), // Title
703
+ array( &$this, 'settings_field_input_text' ), // Callback
704
  $this->slug . '_link', // Page
705
  'ytc_link', // section
706
  array(
707
+ 'field' => $this->option_name . '[goto_txt]',
708
  'class' => 'regular-text',
709
+ 'description' => __( 'Set default title for link', 'youtube-channel' ),
710
  'value' => $this->defaults['goto_txt'],
711
  ) // args
712
  );
715
  register_setting(
716
  'ytc_link', // Setting group
717
  $this->option_name, // option name
718
+ array( $this, 'sanitize_options' )
719
  );
720
 
721
  } // eom register_settings()
727
 
728
  // Add a page to manage this plugin's settings
729
  add_options_page(
730
+ __( 'YouTube Channel', 'youtube-channel' ),
731
+ __( 'YouTube Channel','youtube-channel' ),
732
  'manage_options',
733
  $this->slug,
734
+ array( &$this, 'plugin_settings_page' )
735
  );
736
 
737
  } // eom add_menu()
750
  ),
751
  array(
752
  'a' => array(
753
+ 'href' => array(),
754
+ 'target' => array( '_blank' ),
755
+ ),
756
  )
757
  ),
758
+ __( 'YouTube Channel', 'youtube-channel' ),
759
+ __( 'Channel ID', 'youtube-channel' ),
760
+ __( 'Vanity URL', 'youtube-channel' ),
761
  esc_url( 'https://www.youtube.com/account_advanced' ),
762
+ __( 'YouTube Account Overview', 'youtube-channel' )
763
  )
764
  ?></p>
765
  <?php
768
  ?>
769
  <p><?php
770
  printf(
771
+ __( 'Configure video specific defaults for %s used as fallback options in widget or shortcodes.', 'youtube-channel' ),
772
+ __( 'YouTube Channel', 'youtube-channel' )
773
  );
774
  ?></p>
775
  <?php
778
  ?>
779
  <p><?php
780
  printf(
781
+ __( 'Configure defaults of content around and over videos for %s used as fallback options in widget or shortcodes.', 'youtube-channel' ),
782
+ __( 'YouTube Channel', 'youtube-channel' )
783
  );
784
  ?></p>
785
  <?php
788
  ?>
789
  <p><?php
790
  printf(
791
+ __( 'Configure defaults for link to channel below %s block used as fallback options in widget or shortcodes.', 'youtube-channel' ),
792
+ __( 'YouTube Channel', 'youtube-channel' )
793
  );
794
  ?></p>
795
  <?php
798
  /**
799
  * This function provides separator for settings fields
800
  */
801
+ public function settings_field_separator( $args = null ) {
802
  echo '<hr>';
803
  } // eom settings_field_input_text()
804
 
809
 
810
  extract( $args );
811
 
812
+ printf(
813
+ '<input type="text" name="%1$s" id="%1$s" value="%2$s" class="%3$s" /><p class="description">%4$s</p>',
814
+ $field,
815
+ $value,
816
+ $class,
817
+ $description
818
+ );
819
 
820
  } // eom settings_field_input_text()
821
 
826
 
827
  extract( $args );
828
 
829
+ printf(
830
+ '<input type="password" name="%1$s" id="%1$s" value="%2$s" class="%3$s" /><p class="description">%4$s</p>',
831
+ $field,
832
+ $value,
833
+ $class,
834
+ $description
835
+ );
836
 
837
  } // eom settings_field_input_text()
838
 
843
 
844
  extract( $args );
845
 
846
+ printf(
847
+ '<input type="number" name="%1$s" id="%1$s" value="%2$s" min="%3$s" max="%4$s" class="%5$s" /><p class="description">%6$s</p>',
848
+ $field,
849
+ $value,
850
+ $min,
851
+ $max,
852
+ $class,
853
+ $description
854
+ );
855
 
856
  } // eom settings_field_input_text()
857
 
864
 
865
  $html = '';
866
  // $html .= sprintf('<label for="%s">%s</label><br>', $field, $label);
867
+ $html .= sprintf( '<select id="%1$s" name="%1$s">', $field );
868
+ foreach ( $items as $key => $val ) {
869
+ $selected = ( $value == $key ) ? 'selected="selected"' : '';
870
+ $html .= sprintf( '<option %1$s value="%2$s">%3$s</option>', $selected, $key, $val );
 
871
  }
872
+ $html .= sprintf( '</select><p class="description">%s</p>', $description );
873
 
874
  echo $html;
875
 
882
 
883
  extract( $args );
884
 
885
+ $checked = ( ! empty( $args['value'] ) ) ? 'checked="checked"' : '';
886
+ printf(
887
+ '<label for="%1$s"><input type="checkbox" name="%1$s" id="%1$s" value="1" class="%2$s" %3$s />%4$s</label>',
888
+ $field,
889
+ $class,
890
+ $checked,
891
+ $description
892
+ );
893
 
894
  } // eom settings_field_checkbox()
895
 
906
  foreach ( $items as $key => $label ) {
907
 
908
  $checked = '';
909
+ if ( ! empty( $value ) ) {
910
+ $checked = ( in_array( $key, $value ) ) ? 'checked="checked"' : '';
911
  }
912
 
913
  $out .= sprintf(
914
+ '<label for="%1$s_%2$s"><input type="checkbox" name="%1$s[]" id="%1$s_%2$s" value="%2$s" class="%3$s" %4$s />%5$s</label><br>',
915
  $field,
916
  $key,
 
 
 
 
 
 
 
 
917
  $class,
918
  $checked,
919
  $label
921
  }
922
 
923
  $out .= '</fieldset>';
924
+ $out .= sprintf( '<p class="description">%s</p>' , $description );
925
 
926
  echo $out;
927
 
936
 
937
  $html = '';
938
 
939
+ if ( ! empty( $prescription ) ) {
940
+ $html .= sprintf( '<p class="prescription">%s</p>', $prescription );
941
+ }
942
 
943
+ foreach ( $items as $key => $val ) {
944
 
945
+ $checked = ( $value == $key ) ? 'checked="checked"' : '';
946
  $html .= sprintf(
947
+ '<label for="%1$s_%2$s"><input type="radio" name="%1$s" id="%1$s_%2$s" value="%2$s" %3$s>%4$s</label><br />',
 
948
  $field,
 
949
  $key,
950
  $checked,
951
  $val
953
 
954
  } // foreach $items
955
 
956
+ $html .= sprintf( '<p class="description">%s</p>', $description );
957
 
958
  echo $html;
959
 
964
  */
965
  public function plugin_settings_page() {
966
 
967
+ if ( ! current_user_can( 'manage_options' ) ) {
968
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
969
  }
970
 
971
  // Render the settings template
972
+ require_once( 'settings_template.php' );
973
 
974
  } // eom plugin_settings_page()
975
 
985
 
986
  // --- General ---
987
  case 'ytc_general':
988
+ $apikey = ( defined( 'YOUTUBE_DATA_API_KEY' ) ) ? YOUTUBE_DATA_API_KEY : '';
989
+ $sanitized['apikey'] = ( ! empty( $options['apikey'] ) ) ? trim( $options['apikey'] ) : $apikey;
990
+ $sanitized['channel'] = ( ! empty( $options['channel'] ) ) ? trim( $options['channel'] ) : '';
991
+ $sanitized['vanity'] = ( ! empty( $options['vanity'] ) ) ? trim( $options['vanity'] ) : '';
992
+ $sanitized['username'] = ( ! empty( $options['username'] ) ) ? trim( $options['username'] ) : '';
993
+ $sanitized['playlist'] = ( ! empty( $options['playlist'] ) ) ? trim( $options['playlist'] ) : '';
994
+ $sanitized['resource'] = ( isset( $options['resource'] ) ) ? intval( $options['resource'] ) : $this->defaults['resource'];
995
+ $sanitized['cache'] = ( isset( $options['cache'] ) ) ? intval( $options['cache'] ) : $this->defaults['cache'];
996
+ $sanitized['fetch'] = ( ! empty( $options['fetch'] ) ) ? intval( $options['fetch'] ) : $this->defaults['fetch'];
997
+ $sanitized['num'] = ( ! empty( $options['num'] ) ) ? intval( $options['num'] ) : $this->defaults['num'];
998
+ $sanitized['privacy'] = ( ! empty( $options['privacy'] ) && $options['privacy'] ) ? 1 : 0;
999
+ $sanitized['tinymce'] = ( ! empty( $options['tinymce'] ) && $options['tinymce'] ) ? 1 : 0;
1000
  break; // General
1001
 
1002
  // --- Video ---
1003
  case 'ytc_video':
1004
+ $sanitized['width'] = ( ! empty( $options['width'] ) ) ? intval( $options['width'] ) : $this->defaults['width'];
1005
+ $sanitized['ratio'] = ( isset( $options['ratio'] ) ) ? intval( $options['ratio'] ) : $this->defaults['ratio'];
1006
+ $sanitized['display'] = ( ! empty( $options['display'] ) ) ? trim( $options['display'] ) : $this->defaults['display'];
1007
+ $sanitized['responsive'] = ( ! empty( $options['responsive'] ) && $options['responsive'] ) ? 1 : 0;
1008
+ $sanitized['playsinline'] = ( ! empty( $options['playsinline'] ) && $options['playsinline'] ) ? 1 : 0;
1009
+ $sanitized['nolightbox'] = ( ! empty( $options['nolightbox'] ) && $options['nolightbox'] ) ? 1 : 0;
1010
+ $sanitized['fullscreen'] = ( ! empty( $options['fullscreen'] ) && $options['fullscreen'] ) ? 1 : 0;
1011
+ $sanitized['themelight'] = ( ! empty( $options['themelight'] ) && $options['themelight'] ) ? 1 : 0;
1012
+ $sanitized['controls'] = ( ! empty( $options['controls'] ) && $options['controls'] ) ? 1 : 0;
1013
+ $sanitized['autoplay'] = ( ! empty( $options['autoplay'] ) && $options['autoplay'] ) ? 1 : 0;
1014
+ $sanitized['autoplay_mute'] = ( ! empty( $options['autoplay_mute'] ) && $options['autoplay_mute'] ) ? 1 : 0;
1015
+ $sanitized['norel'] = ( ! empty( $options['norel'] ) && $options['norel'] ) ? 1 : 0;
1016
+ $sanitized['modestbranding'] = ( ! empty( $options['modestbranding'] ) && $options['modestbranding'] ) ? 1 : 0;
1017
+ $sanitized['hideanno'] = ( ! empty( $options['hideanno'] ) && $options['hideanno'] ) ? 1 : 0;
1018
+ $sanitized['hideinfo'] = ( ! empty( $options['hideinfo'] ) && $options['hideinfo'] ) ? 1 : 0;
 
1019
  break; // Video
1020
 
1021
  // --- Content ---
1022
  case 'ytc_content':
1023
+ $sanitized['showtitle'] = ( ! empty( $options['showtitle'] ) ) ? $options['showtitle'] : $this->defaults['showtitle'];
1024
+ $sanitized['showdesc'] = ( ! empty( $options['showdesc'] ) && $options['showdesc'] ) ? 1 : 0;
1025
+ $sanitized['desclen'] = ( ! empty( $options['desclen'] ) ) ? intval( $options['desclen'] ) : $this->defaults['desclen'];
1026
  break; // Content
1027
 
1028
  // --- Link to Channel ---
1029
  case 'ytc_link':
1030
+ $sanitized['link_to'] = ( isset( $options['link_to'] ) ) ? intval( $options['link_to'] ) : $this->defaults['link_to'];
1031
+ $sanitized['goto_txt'] = ( ! empty( $options['goto_txt'] ) ) ? $options['goto_txt'] : $this->defaults['goto_txt'];
1032
+ $sanitized['popup_goto'] = ( isset( $options['popup_goto'] ) ) ? intval( $options['popup_goto'] ) : $this->defaults['popup_goto'];
1033
  break; // Link to Channel
1034
 
1035
  } // switch
inc/settings_template.php CHANGED
@@ -2,13 +2,12 @@
2
  global $WPAU_YOUTUBE_CHANNEL;
3
  ?>
4
  <div class="wrap" id="youtube_channel_settings">
5
- <p style="float:right;text-align:center;"><small>Support YTC developer</small><br><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6" target="_blank" title="Donate via PayPal - The safer, easier way to pay online!"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" style="width:147px;height:47px;border:0" alt="PayPal - The safer, easier way to pay online!"></a></p>
6
  <h2><?php _e( $WPAU_YOUTUBE_CHANNEL->plugin_name . ' Settings', 'youtube-channel' ); ?></h2>
7
  <?php
8
 
9
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
10
 
11
-
12
  // define available tabs
13
  $tabs = array(
14
  'general' => __('General', 'youtube-channel'),
2
  global $WPAU_YOUTUBE_CHANNEL;
3
  ?>
4
  <div class="wrap" id="youtube_channel_settings">
5
+ <p style="float:right;text-align:center;"><small>Support YTC developer</small><br><a href="http://urosevic.net/wordpress/donate/?donate_for=youtube-channel" target="_blank">Donate via PayPal</a></p>
6
  <h2><?php _e( $WPAU_YOUTUBE_CHANNEL->plugin_name . ' Settings', 'youtube-channel' ); ?></h2>
7
  <?php
8
 
9
  $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
10
 
 
11
  // define available tabs
12
  $tabs = array(
13
  'general' => __('General', 'youtube-channel'),
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === YouTube Channel ===
2
  Contributors: urkekg
3
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6
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
7
- Stable tag: 3.0.8.4
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -345,6 +345,12 @@ If you really need that missing feature ASAP, feel free to [contact me](urosevic
345
  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] ...**
346
 
347
  == Changelog ==
 
 
 
 
 
 
348
  = 3.0.8.4 (2015-06-10/16/17/18/19-07/10) =
349
  * Fix: (6/19) Undefined notice for apikey
350
  * Fix: (6/18) Wrong name of widgets page on Help tab
1
  === YouTube Channel ===
2
  Contributors: urkekg
3
+ 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
7
+ Stable tag: 3.0.8.5
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
345
  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] ...**
346
 
347
  == Changelog ==
348
+ = 3.0.8.5 =
349
+ * Enhanced: Settings page made compliant to WordPress Core Coding Standard
350
+ * Fix: Wrong links to external resources on Settings page
351
+ * Fix: Opening external resources links on Settings page in new tab
352
+ * Change: Replace PayPal donation links to prevent account limitations if plugin is used on website that violates PayPal's Acceptable Use Policy
353
+
354
  = 3.0.8.4 (2015-06-10/16/17/18/19-07/10) =
355
  * Fix: (6/19) Undefined notice for apikey
356
  * Fix: (6/18) Wrong name of widgets page on Help tab
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.4
7
  Author: Aleksandar Urošević
8
  Author URI: http://urosevic.net/
9
  Text Domain: youtube-channel
@@ -18,7 +18,7 @@ if ( ! class_exists('WPAU_YOUTUBE_CHANNEL') )
18
  {
19
 
20
  const DB_VER = 14;
21
- const VER = '3.0.8.4';
22
 
23
  public $plugin_name = "YouTube Channel";
24
  public $plugin_slug = "youtube-channel";
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.5
7
  Author: Aleksandar Urošević
8
  Author URI: http://urosevic.net/
9
  Text Domain: youtube-channel
18
  {
19
 
20
  const DB_VER = 14;
21
+ const VER = '3.0.8.5';
22
 
23
  public $plugin_name = "YouTube Channel";
24
  public $plugin_slug = "youtube-channel";