PluginProbe
Embed Plus for YouTube Gallery, Livestream and Lazy Loading with Facades / trunk
Embed Plus for YouTube Gallery, Livestream and Lazy Loading with Facades vtrunk
trunk 1.0 1.1 10.0 10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 11.0 11.0.1 11.1 11.2 11.3 11.3.1 11.4 11.5 11.6 11.7 11.7.1 11.8 All 143 releases
← All changes | youtube.php +6122 -3134 10.1trunk View file →
@@ -1,3134 +1,6122 @@
1 -<?php
2 -/*
3 - Plugin Name: YouTube
4 - Plugin URI: http://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx
5 - Description: YouTube embed plugin with basic features and convenient defaults. Upgrade now to add tracking, instant video SEO tags, and much more!
6 - Version: 10.1
7 - Author: EmbedPlus Team
8 - Author URI: http://www.embedplus.com
9 - */
10 -
11 -/*
12 - YouTube
13 - Copyright (C) 2015 EmbedPlus.com
14 -
15 - This program is free software: you can redistribute it and/or modify
16 - it under the terms of the GNU General Public License as published by
17 - the Free Software Foundation, either version 3 of the License, or
18 - (at your option) any later version.
19 -
20 - This program is distributed in the hope that it will be useful,
21 - but WITHOUT ANY WARRANTY; without even the implied warranty of
22 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 - GNU General Public License for more details.
24 -
25 - You should have received a copy of the GNU General Public License
26 - along with this program. If not, see <http://www.gnu.org/licenses/>.
27 -
28 - */
29 -
30 -//define('WP_DEBUG', true);
31 -
32 -class YouTubePrefs
33 -{
34 -
35 - public static $version = '10.1';
36 - public static $opt_version = 'version';
37 - public static $optembedwidth = null;
38 - public static $optembedheight = null;
39 - public static $defaultheight = null;
40 - public static $defaultwidth = null;
41 - public static $oembeddata = null;
42 - public static $opt_center = 'centervid';
43 - public static $opt_glance = 'glance';
44 - public static $opt_autoplay = 'autoplay';
45 - public static $opt_cc_load_policy = 'cc_load_policy';
46 - public static $opt_iv_load_policy = 'iv_load_policy';
47 - public static $opt_loop = 'loop';
48 - public static $opt_modestbranding = 'modestbranding';
49 - public static $opt_rel = 'rel';
50 - public static $opt_showinfo = 'showinfo';
51 - public static $opt_playsinline = 'playsinline';
52 - public static $opt_autohide = 'autohide';
53 - public static $opt_controls = 'controls';
54 - public static $opt_theme = 'theme';
55 - public static $opt_color = 'color';
56 - public static $opt_listType = 'listType';
57 - public static $opt_wmode = 'wmode';
58 - public static $opt_vq = 'vq';
59 - public static $opt_html5 = 'html5';
60 - public static $opt_dohl = 'dohl';
61 - public static $opt_hl = 'hl';
62 - public static $opt_ssl = 'ssl';
63 - public static $opt_ogvideo = 'ogvideo';
64 - public static $opt_nocookie = 'nocookie';
65 - public static $opt_acctitle = 'acctitle';
66 - public static $opt_pro = 'pro';
67 - public static $opt_oldspacing = 'oldspacing';
68 - public static $opt_responsive = 'responsive';
69 - public static $opt_origin = 'origin';
70 - public static $opt_widgetfit = 'widgetfit';
71 - public static $opt_defaultdims = 'defaultdims';
72 - public static $opt_defaultwidth = 'width';
73 - public static $opt_defaultheight = 'height';
74 - public static $opt_defaultvol = 'defaultvol';
75 - public static $opt_vol = 'vol';
76 - public static $opt_apikey = 'apikey';
77 - public static $opt_schemaorg = 'schemaorg';
78 - public static $opt_ftpostimg = 'ftpostimg';
79 - public static $opt_spdc = 'spdc';
80 - public static $opt_spdcexp = 'spdcexp';
81 - public static $opt_migrate = 'migrate';
82 - public static $opt_migrate_youtube = 'migrate_youtube';
83 - public static $spdcprefix = 'ytpref';
84 - public static $spdcall = 'youtubeprefs_spdcall';
85 - public static $opt_dynload = 'dynload';
86 - public static $opt_dyntype = 'dyntype';
87 - public static $opt_alloptions = 'youtubeprefs_alloptions';
88 - public static $alloptions = null;
89 - public static $yt_options = array();
90 - //public static $epbase = 'http://localhost:2346';
91 - public static $epbase = '//www.embedplus.com';
92 - public static $double_plugin = false;
93 - public static $scriptsprinted = 0;
94 - public static $badentities = array('&#215;', '×', '&#8211;', '–', '&amp;');
95 - public static $goodliterals = array('x', 'x', '--', '--', '&');
96 -
97 - /*
98 - listType
99 - */
100 - ///////////////////////////////////////////////////////////////////////////////////////////////////
101 - ///////////////////////////////////////////////////////////////////////////////////////////////////
102 - ///////////////////////////////////////////////////////////////////////////////////////////////////
103 - ///////////////////////////////////////////////////////////////////////////////////////////////////
104 - ///////////////////////////////////////////////////////////////////////////////////////////////////
105 - //public static $ytregex = '@^[\r\n]{0,1}[[:blank:]]*https?://(?:www\.)?(?:(?:youtube.com/watch\?)|(?:youtu.be/))([^\s"]+)[[:blank:]]*[\r\n]{0,1}$@im';
106 - public static $oldytregex = '@^\s*https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed))/{0,1}\?)|(?:youtu.be/))([^\s"]+)\s*$@im';
107 - public static $ytregex = '@^[\r\t ]*https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed))/{0,1}\?)|(?:youtu.be/))([^\s"]+)[\r\t ]*$@im';
108 - public static $justurlregex = '@https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed))/{0,1}\?)|(?:youtu.be/))([^\[\s"]+)@i';
109 -
110 - ///////////////////////////////////////////////////////////////////////////////////////////////////
111 - ///////////////////////////////////////////////////////////////////////////////////////////////////
112 - ///////////////////////////////////////////////////////////////////////////////////////////////////
113 - ///////////////////////////////////////////////////////////////////////////////////////////////////
114 - ///////////////////////////////////////////////////////////////////////////////////////////////////
115 - ///////////////////////////////////////////////////////////////////////////////////////////////////
116 -
117 - public function __construct()
118 - {
119 - add_action('admin_init', array("YouTubePrefs", 'check_double_plugin_warning'));
120 -
121 - self::$alloptions = get_option(self::$opt_alloptions);
122 - if (self::$alloptions == false || version_compare(self::$alloptions[self::$opt_version], self::$version, '<'))
123 - {
124 - self::initoptions();
125 - }
126 -
127 - if (self::$alloptions[self::$opt_oldspacing] == 1)
128 - {
129 - self::$ytregex = self::$oldytregex;
130 - }
131 -
132 - self::$optembedwidth = intval(get_option('embed_size_w'));
133 - self::$optembedheight = intval(get_option('embed_size_h'));
134 -
135 - self::$yt_options = array(
136 - self::$opt_autoplay,
137 - self::$opt_cc_load_policy,
138 - self::$opt_iv_load_policy,
139 - self::$opt_loop,
140 - self::$opt_modestbranding,
141 - self::$opt_rel,
142 - self::$opt_showinfo,
143 - self::$opt_playsinline,
144 - self::$opt_autohide,
145 - self::$opt_controls,
146 - self::$opt_html5,
147 - self::$opt_hl,
148 - self::$opt_theme,
149 - self::$opt_color,
150 - self::$opt_listType,
151 - self::$opt_wmode,
152 - self::$opt_vq,
153 - 'list',
154 - 'start',
155 - 'end'
156 - );
157 -
158 - add_action('media_buttons', 'YouTubePrefs::media_button_wizard', 11);
159 -
160 -
161 -
162 - //$embedplusmce_wiz = new Add_new_tinymce_btn_Youtubeprefs('|', 'embedplus_youtubeprefs_wiz', plugins_url() . '/youtube-embed-plus/scripts/embedplus_mce_wiz.js');
163 - //$embedplusmce_prefs = new Add_new_tinymce_btn_Youtubeprefs('|', 'embedplus_youtubeprefs', plugins_url() . '/youtube-embed-plus/scripts/embedplus_mce_prefs.js');
164 - //$epstatsmce_youtubeprefs = new Add_new_tinymce_btn_Youtubeprefs('|', 'embedplusstats_youtubeprefs', plugins_url() . '/youtube-embed-plus/scripts/embedplusstats_mce.js');
165 -
166 - self::do_ytprefs();
167 - add_action('admin_menu', 'YouTubePrefs::ytprefs_plugin_menu');
168 - if (!is_admin())
169 - {
170 - add_action('wp_print_scripts', array('YouTubePrefs', 'jsvars'));
171 - add_action('wp_enqueue_scripts', array('YouTubePrefs', 'fitvids'));
172 - if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_ogvideo] == 1)
173 - {
174 - add_action('wp_head', array('YouTubePrefs', 'do_ogvideo'));
175 - }
176 - }
177 - }
178 -
179 - public static function show_glance_list()
180 - {
181 - $glancehref = self::show_glance();
182 - $cnt = self::get_glance_count();
183 -
184 - //display via list
185 - return
186 - '<li class="page-count">
187 - <a href="' . $glancehref . '" class="thickbox ytprefs_glance_button" id="ytprefs_glance_button" title="YouTube Embeds At a Glance">
188 - ' . number_format_i18n($cnt) . ' With YouTube
189 - </a>
190 - </li>';
191 - }
192 -
193 - public static function show_glance_table()
194 - {
195 - $glancehref = self::show_glance();
196 - $cnt = self::get_glance_count();
197 - return
198 - '<tr>
199 - <td class="first b"><a title="YouTube Embeds At a Glance" href="' . $glancehref . '" class="thickbox ytprefs_glance_button">' . number_format_i18n($cnt) . '</a></td>
200 - <td class="t"><a title="YouTube Embeds At a Glance" href="' . $glancehref . '" id="ytprefs_glance_button" class="thickbox ytprefs_glance_button">With YouTube</a></td>
201 - </tr>';
202 - }
203 -
204 - public static function get_glance_count()
205 - {
206 - global $wpdb;
207 - $query_sql = "
208 - SELECT count(*) as mytotal
209 - FROM $wpdb->posts
210 - WHERE (post_content LIKE '%youtube.com/%' OR post_content LIKE '%youtu.be/%')
211 - AND post_status = 'publish'";
212 -
213 - $query_result = $wpdb->get_results($query_sql, OBJECT);
214 -
215 - return intval($query_result[0]->mytotal);
216 - }
217 -
218 - public static function show_glance()
219 - {
220 - $glancehref = admin_url('admin.php?page=youtube-ep-glance') . '&random=' . rand(1, 1000) . '&TB_iframe=true&width=780&height=800';
221 - return $glancehref;
222 - }
223 -
224 - public static function glance_page()
225 - {
226 - ?>
227 - <div class="wrap">
228 - <style type="text/css">
229 - #wphead {display:none;}
230 - #wpbody{margin-left: 0px;}
231 - .wrap {font-family: Arial; padding: 0px 10px 0px 10px; line-height: 180%;}
232 - .bold {font-weight: bold;}
233 - .orange {color: #f85d00;}
234 - #adminmenuback {display: none;}
235 - #adminmenu, adminmenuwrap {display: none;}
236 - #wpcontent, .auto-fold #wpcontent {margin-left: 0px;}
237 - #wpadminbar {display:none;}
238 - html.wp-toolbar {padding: 0px;}
239 - #footer, #wpfooter, .auto-fold #wpfooter {display: none;}
240 - .acctitle {background-color: #dddddd; border-radius: 5px; padding: 7px 15px 7px 15px; cursor: pointer; margin: 10px; font-weight: bold; font-size: 12px;}
241 - .acctitle:hover {background-color: #cccccc;}
242 - .accbox {display: none; position: relative; margin: 5px 8px 30px 15px; clear: both; line-height: 180%;}
243 - .accclose {position: absolute; top: -38px; right: 5px; cursor: pointer; width: 24px; height: 24px;}
244 - .accloader {padding-right: 20px;}
245 - .accthumb {display: block; width: 300px; float: left; margin-right: 25px;}
246 - .accinfo {width: 300px; float: left;}
247 - .accvidtitle {font-weight: bold; font-size: 16px;}
248 - .accthumb img {width: 300px; height: auto; display: block;}
249 - .clearboth {clear: both;}
250 - .pad20 {padding: 20px;}
251 - .center {text-align: center;}
252 - </style>
253 - <script type="text/javascript">
254 - function accclose(ele)
255 - {
256 - jQuery(ele).parent('.accbox').hide(400);
257 - }
258 -
259 - (function($j)
260 - {
261 - $j(document).ready(function() {
262 -
263 -
264 - $j('.acctitle').click(function() {
265 - var $acctitle = $j(this);
266 - var $accbox = $j(this).parent().children('.accbox');
267 - var pid = $accbox.attr("data-postid");
268 -
269 - $acctitle.prepend('<img class="accloader" src="<?php echo plugins_url('images/ajax-loader.gif', __FILE__) ?>" />');
270 - jQuery.ajax({
271 - type: "post",
272 - dataType: "json",
273 - timeout: 30000,
274 - url: wpajaxurl,
275 - data: {action: 'my_embedplus_glance_vids', postid: pid},
276 - success: function(response) {
277 - if (response.type == "success") {
278 - $accbox.html(response.data),
279 - $accbox.show(400);
280 - }
281 - else {
282 - }
283 - },
284 - error: function(xhr, ajaxOptions, thrownError) {
285 -
286 - },
287 - complete: function() {
288 - $acctitle.children('.accloader').remove();
289 - }
290 -
291 - });
292 -
293 -
294 - });
295 - });
296 - })(jQuery);
297 -
298 -
299 - </script>
300 - <?php
301 - global $wpdb;
302 - $query_sql = "
303 - SELECT SQL_CALC_FOUND_ROWS *
304 - FROM $wpdb->posts
305 - WHERE (post_content LIKE '%youtube.com/%' OR post_content LIKE '%youtu.be/%')
306 - AND post_status = 'publish'
307 - order by post_date DESC LIMIT 0, 10";
308 -
309 - $query_result = $wpdb->get_results($query_sql, OBJECT);
310 -
311 - if ($query_result !== null)
312 - {
313 - $total = $wpdb->get_var("SELECT FOUND_ROWS();");
314 - global $post;
315 - echo '<h2><img src="' . plugins_url('images/youtubeicon16.png', __FILE__) . '" /> 10 Latest Posts/Pages with YouTube Videos (' . $total . ' Total)</h2>';
316 - ?>
317 -
318 - We recommend using this page as an easy way to check the results of the global default settings you make (e.g. hide annotations) on your recent embeds. Or, simply use it as an index to jump right to your posts that contain YouTube embeds.
319 -
320 - <?php
321 - if ($total > 0)
322 - {
323 - echo '<ul class="accord">';
324 - foreach ($query_result as $post)
325 - {
326 - echo '<li>';
327 - setup_postdata($post);
328 - the_title('<div class="acctitle">', ' &raquo;</div>');
329 - echo '<div class="accbox" data-postid="' . $post->ID . '"></div><div class="clearboth"></div></li>';
330 - }
331 - echo '</ul>';
332 - }
333 - else
334 - {
335 - echo '<p class="center bold orange">You currently do not have any YouTube embeds yet.</p>';
336 - }
337 - }
338 -
339 - wp_reset_postdata();
340 - ?>
341 - To remove this feature from your dashboard, simply uncheck <i>Show "At a Glance" Embed Links</i> in the <a target="_blank" href="<?php echo admin_url('admin.php?page=youtube-my-preferences#jumpdefaults') ?>">plugin settings page &raquo;</a>.
342 -
343 - </div>
344 - <?php
345 - }
346 -
347 - public static function my_embedplus_glance_vids()
348 - {
349 - $result = array();
350 - if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
351 - {
352 - $postid = intval($_REQUEST['postid']);
353 - $currpost = get_post($postid);
354 -
355 - $thehtml = '<img class="accclose" onclick="accclose(this)" src="' . plugins_url('images/accclose.png', __FILE__) . '" />';
356 -
357 - $matches = Array();
358 - $ismatch = preg_match_all(self::$justurlregex, $currpost->post_content, $matches);
359 -
360 - if ($ismatch)
361 - {
362 - foreach ($matches[0] as $match)
363 - {
364 - $link = trim(preg_replace('/&amp;/i', '&', $match));
365 - $link = preg_replace('/\s/', '', $link);
366 - $link = trim(str_replace(self::$badentities, self::$goodliterals, $link));
367 -
368 - $linkparamstemp = explode('?', $link);
369 -
370 - $linkparams = array();
371 - if (count($linkparamstemp) > 1)
372 - {
373 - $linkparams = self::keyvalue($linkparamstemp[1], true);
374 - }
375 - if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
376 - {
377 - $vtemp = explode('/', $linkparamstemp[0]);
378 - $linkparams['v'] = array_pop($vtemp);
379 - }
380 -
381 - $vidid = $linkparams['v'];
382 -
383 - if ($vidid != null)
384 - {
385 - try
386 - {
387 - $odata = self::get_oembed('http://youtube.com/watch?v=' . $vidid, 1920, 1280);
388 - $postlink = get_permalink($postid);
389 - if ($odata != null && !is_wp_error($odata))
390 - {
391 - $_name = esc_attr(sanitize_text_field($odata->title));
392 - $_description = esc_attr(sanitize_text_field($odata->author_name));
393 - $_thumbnailUrl = esc_url("//i.ytimg.com/vi/" . $vidid . "/0.jpg");
394 -
395 - $thehtml .= '<a target="_blank" href="' . $postlink . '" class="accthumb"><img src="' . $_thumbnailUrl . '" /></a>';
396 - $thehtml .= '<div class="accinfo">';
397 - $thehtml .= '<a target="_blank" href="' . $postlink . '" class="accvidtitle">' . $_name . '</a>';
398 - $thehtml .= '<div class="accdesc">' . (strlen($_description) > 400 ? substr($_description, 0, 400) . "..." : $_description) . '</div>';
399 - $thehtml .= '</div>';
400 - $thehtml .= '<div class="clearboth pad20"></div>';
401 - }
402 - else
403 - {
404 - $thehtml .= '<p class="center bold orange">This <a target="_blank" href="' . $postlink . '">post/page</a> contains a video that has been removed from YouTube.';
405 -
406 - if (!(self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0))
407 - {
408 - $thehtml .='<br><a target="_blank" href="https://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx">Activate delete video tracking to catch these cases &raquo;</a>';
409 - }
410 - $thehtml .= '</strong>';
411 - }
412 - }
413 - catch (Exception $ex)
414 - {
415 -
416 - }
417 - }
418 - else if (false) // if playlist
419 - {
420 -
421 - }
422 - }
423 - }
424 -
425 -
426 -
427 - if ($currpost != null)
428 - {
429 - $result['type'] = 'success';
430 - $result['data'] = $thehtml;
431 - }
432 - else
433 - {
434 - $result['type'] = 'error';
435 - }
436 - echo json_encode($result);
437 - }
438 - else
439 - {
440 - $result['type'] = 'error';
441 - header("Location: " . $_SERVER["HTTP_REFERER"]);
442 - }
443 - die();
444 - }
445 -
446 - public static function my_embedplus_glance_count()
447 - {
448 - $result = array();
449 - if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
450 - {
451 - $thehtml = '';
452 -
453 - try
454 - {
455 - if (version_compare(get_bloginfo('version'), '3.8', '>='))
456 - {
457 - $result['container'] = '#dashboard_right_now ul';
458 - $thehtml .= self::show_glance_list();
459 - }
460 - else
461 - {
462 - $result['container'] = '#dashboard_right_now .table_content table tbody';
463 - $thehtml .= self::show_glance_table();
464 - }
465 - $result['type'] = 'success';
466 - $result['data'] = $thehtml;
467 - }
468 - catch (Exception $e)
469 - {
470 - $result['type'] = 'error';
471 - }
472 -
473 - echo json_encode($result);
474 - }
475 - else
476 - {
477 - $result['type'] = 'error';
478 - header("Location: " . $_SERVER["HTTP_REFERER"]);
479 - }
480 - die();
481 - }
482 -
483 - public static function media_button_wizard()
484 - {
485 - add_thickbox();
486 -
487 - $wizhref = self::$epbase . '/wpembedcode-simple-search.aspx?pluginversion=' . YouTubePrefs::$version .
488 - '&wpversion=' . get_bloginfo('version') .
489 - '&settingsurl=' . urlencode(admin_url('admin.php?page=youtube-my-preferences#jumpdefaults')) .
490 - '&dashurl=' . urlencode(admin_url('admin.php?page=youtube-ep-analytics-dashboard')) .
491 - '&blogwidth=' . YouTubePrefs::get_blogwidth() .
492 - '&domain=' . urlencode(site_url()) .
493 - '&prokey=' . urlencode(YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro]) .
494 - '&myytdefaults=' . urlencode(http_build_query(YouTubePrefs::$alloptions)) .
495 - '&random=' . rand(1, 1000) .
496 - '&TB_iframe=true&width=950&height=800';
497 - ?>
498 - <script type="text/javascript">
499 - function widen_ytprefs_wiz() {
500 - setTimeout(function() {
501 - jQuery("#TB_window").animate({marginLeft: '-' + parseInt((950 / 2), 10) + 'px', width: '950px'}, 300);
502 - jQuery("#TB_window iframe").animate({width: '950px'}, 300);
503 - }, 15);
504 - }
505 - jQuery(document).ready(function() {
506 - jQuery("#ytprefs_wiz_button").click(widen_ytprefs_wiz);
507 - jQuery(window).resize(widen_ytprefs_wiz);
508 - });
509 - </script>
510 - <a href="<?php echo $wizhref; ?>" class="thickbox button ytprefs_media_link" id="ytprefs_wiz_button" title="Visual YouTube Search Tool and Wizard - An easier embedding option"><span></span> YouTube</a>
511 - <?php
512 - }
513 -
514 - public static function check_double_plugin_warning()
515 - {
516 - if (is_plugin_active('embedplus-for-wordpress/embedplus.php'))
517 - {
518 - add_action('admin_notices', array("YouTubePrefs", "double_plugin_warning"));
519 - //self::$double_plugin = true;
520 - }
521 - }
522 -
523 - public static function double_plugin_warning()
524 - {
525 - global $pagenow;
526 - $user_id = get_current_user_id();
527 - if ($pagenow != 'plugins.php' || get_user_meta($user_id, 'embedplus_double_plugin_warning', true) != 1)
528 - {
529 - //echo '<div class="error">' . $_SERVER['QUERY_STRING'] .'</div>';
530 - if ($pagenow == 'plugins.php' || strpos($_SERVER['QUERY_STRING'], 'youtube-my-preferences') !== false ||
531 - strpos($_SERVER['QUERY_STRING'], 'embedplus-video-analytics-dashboard') !== false ||
532 - strpos($_SERVER['QUERY_STRING'], 'youtube-ep-analytics-dashboard') !== false ||
533 - strpos($_SERVER['QUERY_STRING'], 'embedplus-official-options') !== false)
534 - {
535 - ?>
536 - <style type="text/css">
537 - .embedpluswarning img
538 - {
539 - vertical-align: text-bottom;
540 - }
541 - div.bgyellow {background-color: #FCFC94; position: relative;}
542 - a.epxout, a.epxout:hover {font-weight: bold; color: #ffffff; background-color: #ff8888; text-decoration: none;
543 - border-radius: 20px; font-size: 15px; position: absolute; top: 3px; right: 3px;
544 - line-height: 20px; text-align: center; width: 20px; height: 20px; display: block; cursor: pointer;}
545 - </style>
546 - <div class="error bgyellow embedpluswarningbox">
547 - <p class="embedpluswarning">
548 - <?php
549 - if ($pagenow == 'plugins.php')
550 - {
551 - echo '<a class="epxout">&times;</a>';
552 - }
553 - ?>
554 - Seems like you have two different YouTube plugins by the EmbedPlus Team installed: <b><img src="<?php echo plugins_url('images/youtubeicon16.png', __FILE__) ?>" /> YouTube</b> and <b><img src="<?php echo plugins_url('images/btn_embedpluswiz.png', __FILE__) ?>" /> Advanced YouTube Embed.</b> We strongly suggest keeping only the one you prefer, so that they don't conflict with each other while trying to create your embeds.</p>
555 - </div>
556 - <iframe allowTransparency="true" src="<?php echo self::$epbase . '/both-plugins-conflict.aspx' ?>" style="width:2px; height: 2px;" ></iframe>
557 - <script type="text/javascript">
558 - (function($) {
559 - $(document).ready(function() {
560 - $('.epxout').click(function() {
561 - $.ajax({
562 - type: "post",
563 - dataType: "json",
564 - timeout: 30000,
565 - url: wpajaxurl,
566 - data: {action: 'my_embedplus_dismiss_double_plugin_warning'},
567 - success: function(response) {
568 - if (response.type == "success") {
569 - $(".embedpluswarningbox").hide();
570 - }
571 - },
572 - error: function(xhr, ajaxOptions, thrownError) {
573 - },
574 - complete: function() {
575 - }
576 - });
577 - });
578 -
579 - });
580 - })(jQuery);
581 - </script>
582 - <?php
583 - }
584 - }
585 - }
586 -
587 - public static function my_embedplus_dismiss_double_plugin_warning()
588 - {
589 - $result = array();
590 - if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
591 - {
592 - $user_id = get_current_user_id();
593 - update_user_meta($user_id, 'embedplus_double_plugin_warning', 1);
594 - $result['type'] = 'success';
595 - echo json_encode($result);
596 - }
597 - else
598 - {
599 - $result['type'] = 'error';
600 - header("Location: " . $_SERVER["HTTP_REFERER"]);
601 - }
602 - die();
603 - }
604 -
605 - public static function jsvars()
606 - {
607 - $responsiveselector = '[]';
608 - if (self::$alloptions[self::$opt_widgetfit] == 1)
609 - {
610 - $responsiveselector = '["iframe.__youtube_prefs_widget__"]';
611 - }
612 - if (self::$alloptions[self::$opt_responsive] == 1)
613 - {
614 - $responsiveselector = '["iframe[src*=\'youtube.com\']","iframe[src*=\'youtube-nocookie.com\']","iframe[data-ep-src*=\'youtube.com\']","iframe[data-ep-src*=\'youtube-nocookie.com\']"]';
615 - }
616 - ?>
617 - <script type="text/javascript">
618 - var eppathtoscripts = "<?php echo plugins_url('scripts/', __FILE__); ?>";
619 - var epresponsiveselector = <?php echo $responsiveselector; ?>;
620 - var epdovol = true; //<?php echo (self::$alloptions[self::$opt_defaultvol] == 1 ? 'true' : 'false') ?>;
621 - </script>
622 - <?php
623 - }
624 -
625 - public static function fitvids()
626 - {
627 - wp_enqueue_script('__ytprefsfitvids__', plugins_url('scripts/fitvids.min.js', __FILE__), false, false, true);
628 - }
629 -
630 - public static function initoptions()
631 - {
632 - //vanilla defaults
633 - $_center = 0;
634 - $_glance = 1;
635 - $_autoplay = get_option('youtubeprefs_autoplay', 0);
636 - $_cc_load_policy = get_option('youtubeprefs_cc_load_policy', 0);
637 - $_iv_load_policy = get_option('youtubeprefs_iv_load_policy', 1);
638 - $_loop = get_option('youtubeprefs_loop', 0);
639 - $_modestbranding = get_option('youtubeprefs_modestbranding', 0);
640 - $_rel = get_option('youtubeprefs_rel', 1);
641 - $_showinfo = get_option('youtubeprefs_showinfo', 1);
642 - $_html5 = get_option('youtubeprefs_html5', 0);
643 - $_theme = get_option('youtubeprefs_theme', 'dark');
644 - $_color = get_option('youtubeprefs_color', 'red');
645 - $_vq = get_option('youtubeprefs_vq', '');
646 - $_autohide = 2;
647 - $_pro = '';
648 - $_ssl = 0;
649 - $_nocookie = 0;
650 - $_acctitle = 0;
651 - $_ogvideo = 0;
652 - $_migrate = 0;
653 - $_migrate_youtube = 0;
654 - $_controls = 2;
655 - $_oldspacing = 1;
656 - $_responsive = 0;
657 - $_widgetfit = 1;
658 - $_schemaorg = 0;
659 - $_ftpostimg = 0;
660 - $_spdc = 0;
661 - $_spdcexp = 24;
662 - $_dynload = 0;
663 - $_dyntype = '';
664 - $_wmode = 'opaque';
665 - $_defaultdims = 0;
666 - $_defaultwidth = '';
667 - $_defaultheight = '';
668 - $_playsinline = 0;
669 - $_origin = 0;
670 - $_defaultvol = 0;
671 - $_vol = '';
672 - $_apikey = '';
673 - $_hl = '';
674 - $_dohl = 0;
675 -
676 - $arroptions = get_option(self::$opt_alloptions);
677 -
678 - //update vanilla to previous settings if exists
679 - if ($arroptions !== false)
680 - {
681 - $_center = self::tryget($arroptions, self::$opt_center, 0);
682 - $_glance = self::tryget($arroptions, self::$opt_glance, 1);
683 - $_autoplay = self::tryget($arroptions, self::$opt_autoplay, 0);
684 - $_cc_load_policy = self::tryget($arroptions, self::$opt_cc_load_policy, 0);
685 - $_iv_load_policy = self::tryget($arroptions, self::$opt_iv_load_policy, 1);
686 - $_loop = self::tryget($arroptions, self::$opt_loop, 0);
687 - $_modestbranding = self::tryget($arroptions, self::$opt_modestbranding, 0);
688 - $_rel = self::tryget($arroptions, self::$opt_rel, 1);
689 - $_showinfo = self::tryget($arroptions, self::$opt_showinfo, 1);
690 - $_playsinline = self::tryget($arroptions, self::$opt_playsinline, 0);
691 - $_origin = self::tryget($arroptions, self::$opt_origin, 0);
692 - $_html5 = self::tryget($arroptions, self::$opt_html5, 0);
693 - $_hl = self::tryget($arroptions, self::$opt_hl, '');
694 - $_dohl = self::tryget($arroptions, self::$opt_dohl, 0);
695 - $_theme = self::tryget($arroptions, self::$opt_theme, 'dark');
696 - $_color = self::tryget($arroptions, self::$opt_color, 'red');
697 - $_wmode = self::tryget($arroptions, self::$opt_wmode, 'opaque');
698 - $_vq = self::tryget($arroptions, self::$opt_vq, '');
699 - $_pro = self::tryget($arroptions, self::$opt_pro, '');
700 - $_ssl = self::tryget($arroptions, self::$opt_ssl, 0);
701 - $_nocookie = self::tryget($arroptions, self::$opt_nocookie, 0);
702 - $_acctitle = self::tryget($arroptions, self::$opt_acctitle, 0);
703 - $_ogvideo = self::tryget($arroptions, self::$opt_ogvideo, 0);
704 - $_migrate = self::tryget($arroptions, self::$opt_migrate, 0);
705 - $_migrate_youtube = self::tryget($arroptions, self::$opt_migrate_youtube, 0);
706 - $_controls = self::tryget($arroptions, self::$opt_controls, 2);
707 - $_autohide = self::tryget($arroptions, self::$opt_autohide, 2);
708 - $_oldspacing = self::tryget($arroptions, self::$opt_oldspacing, 1);
709 - $_responsive = self::tryget($arroptions, self::$opt_responsive, 0);
710 - $_widgetfit = self::tryget($arroptions, self::$opt_widgetfit, 1);
711 - $_schemaorg = self::tryget($arroptions, self::$opt_schemaorg, 0);
712 - $_ftpostimg = self::tryget($arroptions, self::$opt_ftpostimg, 0);
713 - $_spdc = self::tryget($arroptions, self::$opt_spdc, 0);
714 - $_spdcexp = self::tryget($arroptions, self::$opt_spdcexp, 24);
715 - $_dynload = self::tryget($arroptions, self::$opt_dynload, 0);
716 - $_dyntype = self::tryget($arroptions, self::$opt_dyntype, '');
717 - $_defaultdims = self::tryget($arroptions, self::$opt_defaultdims, 0);
718 - $_defaultwidth = self::tryget($arroptions, self::$opt_defaultwidth, '');
719 - $_defaultheight = self::tryget($arroptions, self::$opt_defaultheight, '');
720 - $_defaultvol = self::tryget($arroptions, self::$opt_defaultvol, 0);
721 - $_vol = self::tryget($arroptions, self::$opt_vol, '');
722 - $_apikey = self::tryget($arroptions, self::$opt_apikey, '');
723 - }
724 - else
725 - {
726 - $_oldspacing = 0;
727 - }
728 -
729 - $all = array(
730 - self::$opt_version => self::$version,
731 - self::$opt_center => $_center,
732 - self::$opt_glance => $_glance,
733 - self::$opt_autoplay => $_autoplay,
734 - self::$opt_cc_load_policy => $_cc_load_policy,
735 - self::$opt_iv_load_policy => $_iv_load_policy,
736 - self::$opt_loop => $_loop,
737 - self::$opt_modestbranding => $_modestbranding,
738 - self::$opt_rel => $_rel,
739 - self::$opt_showinfo => $_showinfo,
740 - self::$opt_playsinline => $_playsinline,
741 - self::$opt_origin => $_origin,
742 - self::$opt_autohide => $_autohide,
743 - self::$opt_html5 => $_html5,
744 - self::$opt_hl => $_hl,
745 - self::$opt_dohl => $_dohl,
746 - self::$opt_theme => $_theme,
747 - self::$opt_color => $_color,
748 - self::$opt_wmode => $_wmode,
749 - self::$opt_vq => $_vq,
750 - self::$opt_pro => $_pro,
751 - self::$opt_ssl => $_ssl,
752 - self::$opt_nocookie => $_nocookie,
753 - self::$opt_acctitle => $_acctitle,
754 - self::$opt_ogvideo => $_ogvideo,
755 - self::$opt_migrate => $_migrate,
756 - self::$opt_migrate_youtube => $_migrate_youtube,
757 - self::$opt_controls => $_controls,
758 - self::$opt_oldspacing => $_oldspacing,
759 - self::$opt_responsive => $_responsive,
760 - self::$opt_widgetfit => $_widgetfit,
761 - self::$opt_schemaorg => $_schemaorg,
762 - self::$opt_ftpostimg => $_ftpostimg,
763 - self::$opt_spdc => $_spdc,
764 - self::$opt_spdcexp => $_spdcexp,
765 - self::$opt_dynload => $_dynload,
766 - self::$opt_dyntype => $_dyntype,
767 - self::$opt_defaultdims => $_defaultdims,
768 - self::$opt_defaultwidth => $_defaultwidth,
769 - self::$opt_defaultheight => $_defaultheight,
770 - self::$opt_defaultvol => $_defaultvol,
771 - self::$opt_vol => $_vol,
772 - self::$opt_apikey => $_apikey
773 - );
774 -
775 - update_option(self::$opt_alloptions, $all);
776 - update_option('embed_autourls', 1);
777 - self::$alloptions = get_option(self::$opt_alloptions);
778 - }
779 -
780 - public static function tryget($array, $key, $default = null)
781 - {
782 - return isset($array[$key]) ? $array[$key] : $default;
783 - }
784 -
785 - public static function wp_above_version($ver)
786 - {
787 - global $wp_version;
788 - if (version_compare($wp_version, $ver, '>='))
789 - {
790 - return true;
791 - }
792 - return false;
793 - }
794 -
795 - public static function do_ytprefs()
796 - {
797 - if (!is_admin())
798 - {
799 - add_filter('the_content', 'YouTubePrefs::apply_prefs_content', 1);
800 - add_filter('widget_text', 'YouTubePrefs::apply_prefs_widget', 1);
801 - add_shortcode('embedyt', array('YouTubePrefs', 'apply_prefs_shortcode'));
802 - if (self::$alloptions[self::$opt_migrate] == 1)
803 - {
804 - if (self::$alloptions[self::$opt_migrate_youtube] == 1)
805 - {
806 - add_shortcode('youtube', array('YouTubePrefs', 'apply_prefs_shortcode_youtube'));
807 - add_shortcode('youtube_video', array('YouTubePrefs', 'apply_prefs_shortcode_youtube'));
808 - }
809 -
810 - }
811 - }
812 - else
813 - {
814 - if (self::$alloptions[self::$opt_ftpostimg] == 1 && self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
815 - {
816 - add_action('save_post', array('YouTubePrefs', 'doftpostimg'), 110, 3);
817 - }
818 - }
819 - }
820 -
821 - public static function apply_prefs_shortcode($atts, $content = null)
822 - {
823 - $content = trim($content);
824 - $currfilter = current_filter();
825 - if (preg_match(self::$justurlregex, $content))
826 - {
827 - return self::get_html(array($content), $currfilter == 'widget_text' ? false : true);
828 - }
829 - return '';
830 - }
831 -
832 - public static function apply_prefs_shortcode_youtube($atts, $content = null)
833 - {
834 - $content = 'http://www.youtube.com/watch?v=' . trim($content);
835 - $currfilter = current_filter();
836 - if (preg_match(self::$justurlregex, $content))
837 - {
838 - return self::get_html(array($content), $currfilter == 'widget_text' ? false : true);
839 - }
840 - return '';
841 - }
842 -
843 -
844 - public static function apply_prefs_content($content)
845 - {
846 - $content = preg_replace_callback(self::$ytregex, "YouTubePrefs::get_html_content", $content);
847 - return $content;
848 - }
849 -
850 - public static function apply_prefs_widget($content)
851 - {
852 - $content = preg_replace_callback(self::$ytregex, "YouTubePrefs::get_html_widget", $content);
853 - return $content;
854 - }
855 -
856 - public static function get_html_content($m)
857 - {
858 - return self::get_html($m, true);
859 - }
860 -
861 - public static function get_html_widget($m)
862 - {
863 - return self::get_html($m, false);
864 - }
865 -
866 - public static function get_html($m, $iscontent)
867 - {
868 - //$time_start = microtime(true);
869 -
870 - $link = trim(str_replace(self::$badentities, self::$goodliterals, $m[0]));
871 -
872 - $link = preg_replace('/\s/', '', $link);
873 - $linkparamstemp = explode('?', $link);
874 -
875 - $linkparams = array();
876 - if (count($linkparamstemp) > 1)
877 - {
878 - $linkparams = self::keyvalue($linkparamstemp[1], true);
879 - }
880 - if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
881 - {
882 - $vtemp = explode('/', $linkparamstemp[0]);
883 - $linkparams['v'] = array_pop($vtemp);
884 - }
885 -
886 - //$linkscheme = 'http';
887 - $youtubebaseurl = 'youtube';
888 - $schemaorgoutput = '';
889 - $voloutput = '';
890 - $dynsrc = '';
891 - $dyntype = '';
892 - $acctitle = '';
893 -
894 - $finalparams = $linkparams + self::$alloptions;
895 -
896 - $spdckey = '';
897 - if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_spdc] == 1)
898 - {
899 - try
900 - {
901 - $kparams = $finalparams;
902 - ksort($kparams);
903 - $jparams = json_encode($kparams);
904 - $spdckey = self::$spdcprefix . '_' . md5($jparams);
905 - $spdcval = get_transient($spdckey);
906 - if (!empty($spdcval))
907 - {
908 - //self::debuglog((microtime(true) - $time_start) . "\t" . $spdckey . "\t" . $spdcval . "\r\n");
909 - return $spdcval;
910 - }
911 - }
912 - catch (Exception $ex)
913 - {
914 -
915 - }
916 - }
917 -
918 - self::init_dimensions($link, $linkparams, $finalparams);
919 -
920 - if (self::$alloptions[self::$opt_nocookie] == 1)
921 - {
922 - $youtubebaseurl = 'youtube-nocookie';
923 - }
924 -
925 -
926 -// if (self::$alloptions[self::$opt_ssl] == 1)
927 -// {
928 -// $linkscheme = 'https';
929 -// }
930 -
931 - if (self::$alloptions[self::$opt_defaultvol] == 1)
932 - {
933 - $voloutput = ' data-vol="' . self::$alloptions[self::$opt_vol] . '" ';
934 - }
935 -
936 -
937 -// if (!(self::$alloptions[self::$opt_dohl] == 1 && isset($finalparams[self::$opt_hl]) && strlen($finalparams[self::$opt_hl]) == 2))
938 -// {
939 -// unset($finalparams[self::$opt_hl]);
940 -// }
941 - if (self::$alloptions[self::$opt_dohl] == 1)
942 - {
943 - $locale = get_locale();
944 - $finalparams[self::$opt_hl] = $locale;
945 - }
946 - else
947 - {
948 - unset($finalparams[self::$opt_hl]);
949 - }
950 -
951 - if (isset($finalparams[self::$opt_html5]) && $finalparams[self::$opt_html5] == 0)
952 - {
953 - unset($finalparams[self::$opt_html5]);
954 - }
955 -
956 - if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
957 - {
958 -
959 - if (self::$alloptions[self::$opt_schemaorg] == 1 && isset($finalparams['v']))
960 - {
961 - $schemaorgoutput = self::getschemaorgoutput($finalparams['v']);
962 - }
963 -
964 -
965 -
966 - if (self::$alloptions[self::$opt_dynload] == 1
967 - //&& $finalparams[self::$opt_autoplay] != 1
968 - )
969 - {
970 - $dynsrc = 'data-ep-';
971 - $dyntype = ' data-ep-a="' . self::$alloptions[self::$opt_dyntype] . '" ';
972 - }
973 -
974 - if (isset($linkparams[self::$opt_vol]) && is_numeric(trim($linkparams[self::$opt_vol])))
975 - {
976 - $voloutput = ' data-vol="' . $linkparams[self::$opt_vol] . '" ';
977 - }
978 - }
979 - else
980 - {
981 - if (isset($finalparams[self::$opt_vol]))
982 - {
983 - unset($finalparams[self::$opt_vol]);
984 - }
985 - }
986 -
987 - $centercode = '';
988 - if ($finalparams[self::$opt_center] == 1)
989 - {
990 - $centercode = ' style="display: block; margin: 0px auto;" ';
991 - }
992 -
993 - if (self::$alloptions[self::$opt_acctitle] == 1)
994 - {
995 - try
996 - {
997 - //attr escape
998 - if (self::$oembeddata)
999 - {
1000 - $acctitle = self::$oembeddata->title;
1001 - }
1002 - else
1003 - {
1004 - $odata = self::get_oembed('http://youtube.com/watch?v=' . $linkparams['v'], 1920, 1280);
1005 - $acctitle = $odata->title;
1006 - }
1007 -
1008 - if ($acctitle)
1009 - {
1010 - $acctitle = ' title="' . esc_attr($acctitle) . '" ';
1011 - }
1012 - }
1013 - catch (Exception $e)
1014 - {
1015 -
1016 - }
1017 - }
1018 -
1019 - $code1 = '<iframe ' . $dyntype . $centercode . ' id="_ytid_' . rand(10000, 99999) . '" width="' . self::$defaultwidth . '" height="' . self::$defaultheight .
1020 - '" ' . $dynsrc . 'src="//www.' . $youtubebaseurl . '.com/embed/' . (isset($linkparams['v']) ? $linkparams['v'] : '') . '?';
1021 - $code2 = '" frameborder="0" type="text/html" class="__youtube_prefs__' . ($iscontent ? '' : ' __youtube_prefs_widget__') .
1022 - '"' . $voloutput . $acctitle . ' allowfullscreen webkitallowfullscreen mozallowfullscreen ></iframe>' . $schemaorgoutput;
1023 -
1024 - $origin = '';
1025 -
1026 - try
1027 - {
1028 - if (self::$alloptions[self::$opt_origin] == 1)
1029 - {
1030 - $url_parts = parse_url(site_url());
1031 - $origin = 'origin=' . $url_parts['scheme'] . '://' . $url_parts['host'] . '&';
1032 - }
1033 - }
1034 - catch (Exception $e)
1035 - {
1036 - $origin = '';
1037 - }
1038 - $finalsrc = 'enablejsapi=1&' . $origin;
1039 -
1040 - if (count($finalparams) > 1)
1041 - {
1042 - foreach ($finalparams as $key => $value)
1043 - {
1044 - if (in_array($key, self::$yt_options))
1045 - {
1046 - $finalsrc .= htmlspecialchars($key) . '=' . htmlspecialchars($value) . '&';
1047 - if ($key == 'loop' && $value == 1 && !isset($finalparams['list']))
1048 - {
1049 - $finalsrc .= 'playlist=' . $finalparams['v'] . '&';
1050 - }
1051 - }
1052 - }
1053 - }
1054 -
1055 - $code = $code1 . $finalsrc . $code2; //. '<!--' . $m[0] . '-->';
1056 - // reset static vals for next embed
1057 - self::$defaultheight = null;
1058 - self::$defaultwidth = null;
1059 - self::$oembeddata = null;
1060 -
1061 - if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_spdc] == 1)
1062 - {
1063 - $daysecs = self::$alloptions[self::$opt_spdcexp] * 60 * 60;
1064 - set_transient($spdckey, $code, $daysecs);
1065 - $allk = get_option(self::$spdcall, array());
1066 - $allk[] = $spdckey;
1067 - update_option(self::$spdcall, $allk);
1068 -
1069 - //self::debuglog((microtime(true) - $time_start) . "\t" . $spdckey . "\t" . $code . "\r\n");
1070 - }
1071 - return $code;
1072 - }
1073 -
1074 - public static function debuglog($str)
1075 - {
1076 - $handle = fopen(__DIR__ . "\\debug.txt", "a+");
1077 - fwrite($handle, $str);
1078 - fclose($handle);
1079 - }
1080 -
1081 - public static function spdcpurge()
1082 - {
1083 - $allk = get_option(self::$spdcall);
1084 - foreach ($allk as $t)
1085 - {
1086 - $success = delete_transient($t);
1087 - }
1088 - update_option(self::$spdcall, array());
1089 - }
1090 -
1091 - public static function keyvalue($qry, $includev)
1092 - {
1093 - $ytvars = explode('&', $qry);
1094 - $ytkvp = array();
1095 - foreach ($ytvars as $k => $v)
1096 - {
1097 - $kvp = explode('=', $v);
1098 - if (count($kvp) == 2 && ($includev || strtolower($kvp[0]) != 'v'))
1099 - {
1100 - $ytkvp[$kvp[0]] = $kvp[1];
1101 - }
1102 - }
1103 -
1104 - return $ytkvp;
1105 - }
1106 -
1107 - public static function getschemaorgoutput($vidid)
1108 - {
1109 - $schemaorgcode = '';
1110 - try
1111 - {
1112 - $ytapilink = 'https://www.googleapis.com/youtube/v3/videos?id=' . $vidid . '&part=contentDetails,snippet&key=' . self::$alloptions[self::$opt_apikey];
1113 -
1114 -
1115 - $apidata = wp_remote_get($ytapilink);
1116 - if (!is_wp_error($apidata))
1117 - {
1118 - $raw = wp_remote_retrieve_body($apidata);
1119 - if (!empty($raw))
1120 - {
1121 - $json = json_decode($raw, true);
1122 - if (is_array($json))
1123 - {
1124 - $_name = esc_attr(sanitize_text_field(str_replace("@", "&#64;", $json['items'][0]['snippet']['title'])));
1125 - $_description = esc_attr(sanitize_text_field(str_replace("@", "&#64;", $json['items'][0]['snippet']['description'])));
1126 - $_thumbnailUrl = esc_url("http://i.ytimg.com/vi/" . $vidid . "/0.jpg");
1127 - $_duration = $json['items'][0]['contentDetails']['duration']; // "T0H9M35S" "PT9M35S"
1128 - $_uploadDate = sanitize_text_field($json['items'][0]['snippet']['publishedAt']); // "2014-10-03T15:30:12.000Z"
1129 -
1130 - $schemaorgcode = '<span itemprop="video" itemscope itemtype="http://schema.org/VideoObject">';
1131 - $schemaorgcode .= '<meta itemprop="embedURL" content="http://www.youtube.com/embed/' . $vidid . '">';
1132 - $schemaorgcode .= '<meta itemprop="name" content="' . $_name . '">';
1133 - $schemaorgcode .= '<meta itemprop="description" content="' . $_description . '">';
1134 - $schemaorgcode .= '<meta itemprop="thumbnailUrl" content="' . $_thumbnailUrl . '">';
1135 - $schemaorgcode .= '<meta itemprop="duration" content="' . $_duration . '">';
1136 - $schemaorgcode .= '<meta itemprop="uploadDate" content="' . $_uploadDate . '">';
1137 - $schemaorgcode .= '</span>';
1138 - }
1139 - }
1140 - }
1141 - }
1142 - catch (Exception $ex)
1143 - {
1144 -
1145 - }
1146 - return $schemaorgcode;
1147 - }
1148 -
1149 - public static function secondsToDuration($seconds)
1150 - {
1151 - $remaining = $seconds;
1152 - $parts = array();
1153 - $multipliers = array(
1154 - 'hours' => 3600,
1155 - 'minutes' => 60,
1156 - 'seconds' => 1
1157 - );
1158 -
1159 - foreach ($multipliers as $type => $m)
1160 - {
1161 - $parts[$type] = (int) ($remaining / $m);
1162 - $remaining -= ($parts[$type] * $m);
1163 - }
1164 -
1165 - return $parts;
1166 - }
1167 -
1168 - public static function formatDuration($parts)
1169 - {
1170 - $default = array(
1171 - 'hours' => 0,
1172 - 'minutes' => 0,
1173 - 'seconds' => 0
1174 - );
1175 -
1176 - extract(array_merge($default, $parts));
1177 -
1178 - return "T{$hours}H{$minutes}M{$seconds}S";
1179 - }
1180 -
1181 - public static function init_dimensions($url, $urlkvp, $finalparams)
1182 - {
1183 - // get default dimensions; try embed size in settings, then try theme's content width, then just 480px
1184 - if (self::$defaultwidth == null)
1185 - {
1186 - global $content_width;
1187 - if (empty($content_width))
1188 - {
1189 - $content_width = $GLOBALS['content_width'];
1190 - }
1191 -
1192 - if (isset($urlkvp['width']) && is_numeric($urlkvp['width']))
1193 - {
1194 - self::$defaultwidth = $urlkvp['width'];
1195 - }
1196 - else if (self::$alloptions[self::$opt_defaultdims] == 1 && (isset(self::$alloptions[self::$opt_defaultwidth]) && is_numeric(self::$alloptions[self::$opt_defaultwidth])))
1197 - {
1198 - self::$defaultwidth = self::$alloptions[self::$opt_defaultwidth];
1199 - }
1200 - else if (self::$optembedwidth)
1201 - {
1202 - self::$defaultwidth = self::$optembedwidth;
1203 - }
1204 - else if ($content_width)
1205 - {
1206 - self::$defaultwidth = $content_width;
1207 - }
1208 - else
1209 - {
1210 - self::$defaultwidth = 480;
1211 - }
1212 -
1213 -
1214 -
1215 - if (isset($urlkvp['height']) && is_numeric($urlkvp['height']))
1216 - {
1217 - self::$defaultheight = $urlkvp['height'];
1218 - }
1219 - else if (self::$alloptions[self::$opt_defaultdims] == 1 && (isset(self::$alloptions[self::$opt_defaultheight]) && is_numeric(self::$alloptions[self::$opt_defaultheight])))
1220 - {
1221 - self::$defaultheight = self::$alloptions[self::$opt_defaultheight];
1222 - }
1223 - else
1224 - {
1225 - self::$defaultheight = self::get_aspect_height($url, $urlkvp, $finalparams);
1226 - }
1227 - }
1228 - }
1229 -
1230 - public static function get_oembed($url, $height, $width)
1231 - {
1232 - require_once( ABSPATH . WPINC . '/class-oembed.php' );
1233 - $oembed = _wp_oembed_get_object();
1234 - $args = array();
1235 - $args['width'] = $width;
1236 - $args['height'] = $height;
1237 - $args['discover'] = false;
1238 - self::$oembeddata = $oembed->fetch('https://www.youtube.com/oembed', $url, $args);
1239 - return self::$oembeddata;
1240 - }
1241 -
1242 - public static function get_aspect_height($url, $urlkvp, $finalparams)
1243 - {
1244 -
1245 - // attempt to get aspect ratio correct height from oEmbed
1246 - $aspectheight = round((self::$defaultwidth * 9) / 16, 0);
1247 -
1248 -
1249 - if ($url)
1250 - {
1251 - $odata = self::get_oembed($url, self::$defaultwidth, self::$defaultwidth);
1252 -
1253 - if ($odata)
1254 - {
1255 - $aspectheight = $odata->height;
1256 - }
1257 - }
1258 -
1259 - if ($finalparams[self::$opt_controls] != 0 && $finalparams[self::$opt_autohide] != 1)
1260 - {
1261 - //add 28 for YouTube's own bar
1262 - $aspectheight += 28;
1263 - }
1264 - return $aspectheight;
1265 - }
1266 -
1267 - public static function doftpostimg($postid, $post, $update)
1268 - {
1269 - if (current_user_can('edit_posts') && current_user_can('edit_pages'))
1270 - {
1271 - if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || !in_array($post->post_status, array('publish', 'pending', 'draft', 'future', 'private')))
1272 - {
1273 - return;
1274 - }
1275 - try
1276 - {
1277 - self::doftpostimgfor($post);
1278 - }
1279 - catch (Exception $ex)
1280 - {
1281 - // display error message
1282 - }
1283 - }
1284 - }
1285 -
1286 - public static function doftpostimgfor($post)
1287 - {
1288 - $search_content = isset($post->post_content) ? $post->post_content : '';
1289 - $search_content = substr($search_content, 0, 1500);
1290 -
1291 - $search_content = apply_filters('youtube_embedplus_video_content', $search_content);
1292 -
1293 - $vid_match = null;
1294 - if ($search_content && $post->ID && !has_post_thumbnail($post->ID) && preg_match(self::$justurlregex, $search_content, $vid_match)
1295 - )
1296 - {
1297 -
1298 - $first_vid_link = trim(str_replace(self::$badentities, self::$goodliterals, $vid_match[0]));
1299 -
1300 - $first_vid_link = preg_replace('/\s/', '', $first_vid_link);
1301 - $linkparamstemp = explode('?', $first_vid_link);
1302 -
1303 - $linkparams = array();
1304 - if (count($linkparamstemp) > 1)
1305 - {
1306 - $linkparams = self::keyvalue($linkparamstemp[1], true);
1307 - }
1308 - if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
1309 - {
1310 - $vtemp = explode('/', $linkparamstemp[0]);
1311 - $linkparams['v'] = array_pop($vtemp);
1312 - }
1313 -
1314 -
1315 -
1316 - $just_id = $linkparams['v'];
1317 - $ftimgurl = null;
1318 - if ($just_id)
1319 - {
1320 - require_once( ABSPATH . WPINC . '/class-oembed.php' );
1321 - $oembed = _wp_oembed_get_object();
1322 - $args = array();
1323 - $args['width'] = 1920;
1324 - $args['height'] = 1080;
1325 - $args['discover'] = false;
1326 - $odata = $oembed->fetch('https://www.youtube.com/oembed', 'http://youtube.com/watch?v=' . $just_id, $args);
1327 -
1328 - if ($odata)
1329 - {
1330 - $ftimgurl = $odata->thumbnail_url;
1331 - }
1332 - }
1333 -
1334 - $ftimgid = $ftimgurl && !is_wp_error($ftimgurl) ? self::media_sideload($ftimgurl, $post->ID, sanitize_title(preg_replace("/[^a-zA-Z0-9\s]/", "-", $post->title))) : 0;
1335 -
1336 - if (!$ftimgid)
1337 - {
1338 - return;
1339 - }
1340 -
1341 - set_post_thumbnail($post->ID, $ftimgid);
1342 - }
1343 - }
1344 -
1345 - public static function media_sideload($url, $post_id, $filename = null)
1346 - {
1347 - if (!$url || !$post_id)
1348 - {
1349 - return new WP_Error('missing', __('Please provide a valid URL and post ID', ''));
1350 - }
1351 -
1352 - $post_title = get_the_title($post_id);
1353 -
1354 - require_once(ABSPATH . 'wp-admin/includes/file.php');
1355 - $tmp = download_url($url);
1356 -
1357 - if (is_wp_error($tmp))
1358 - {
1359 - @unlink($file_array['tmp_name']);
1360 - $file_array['tmp_name'] = '';
1361 - return $tmp;
1362 - }
1363 -
1364 - preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches);
1365 - $url_filename = basename($matches[0]);
1366 - $url_type = wp_check_filetype($url_filename);
1367 -
1368 - if (!empty($filename))
1369 - {
1370 - $filename = sanitize_file_name($filename);
1371 - $tmppath = pathinfo($tmp);
1372 - $new = $tmppath['dirname'] . '/' . $filename . '.' . $tmppath['extension'];
1373 - rename($tmp, $new);
1374 - $tmp = $new;
1375 - }
1376 -
1377 - $file_array['tmp_name'] = $tmp;
1378 - if (!empty($filename))
1379 - {
1380 - $file_array['name'] = $filename . '.' . $url_type['ext'];
1381 - }
1382 - else
1383 - {
1384 - $file_array['name'] = $url_filename;
1385 - }
1386 -
1387 - $post_data = array(
1388 - 'post_title' => $post_title,
1389 - 'post_parent' => $post_id,
1390 - );
1391 -
1392 - require_once( ABSPATH . 'wp-admin/includes/file.php' );
1393 - require_once( ABSPATH . 'wp-admin/includes/media.php' );
1394 - require_once( ABSPATH . 'wp-admin/includes/image.php' );
1395 -
1396 - $att_id = media_handle_sideload($file_array, $post_id, null, $post_data);
1397 -
1398 - if (is_wp_error($att_id))
1399 - {
1400 - @unlink($file_array['tmp_name']);
1401 - return $att_id;
1402 - }
1403 -
1404 - return $att_id;
1405 - }
1406 -
1407 - public static function do_ogvideo()
1408 - {
1409 - global $wp_query;
1410 - $the_content = $wp_query->post->post_content;
1411 - $matches = Array();
1412 - $ismatch = preg_match_all(self::$justurlregex, $the_content, $matches);
1413 -
1414 - if ($ismatch)
1415 - {
1416 - $match = $matches[0][0];
1417 -
1418 - $link = trim(preg_replace('/&amp;/i', '&', $match));
1419 - $link = preg_replace('/\s/', '', $link);
1420 - $link = trim(str_replace(self::$badentities, self::$goodliterals, $link));
1421 -
1422 - $linkparamstemp = explode('?', $link);
1423 -
1424 - $linkparams = array();
1425 - if (count($linkparamstemp) > 1)
1426 - {
1427 - $linkparams = self::keyvalue($linkparamstemp[1], true);
1428 - }
1429 - if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
1430 - {
1431 - $vtemp = explode('/', $linkparamstemp[0]);
1432 - $linkparams['v'] = array_pop($vtemp);
1433 - }
1434 - ?>
1435 - <meta property="og:type" content="video">
1436 - <meta property="og:video" content="https://www.youtube.com/v/<?php echo $linkparams['v']; ?>?autohide=1&amp;version=3">
1437 - <meta property="og:video:type" content="application/x-shockwave-flash">
1438 - <meta property="og:video:width" content="480">
1439 - <meta property="og:video:height" content="360">
1440 - <meta property="og:image" content="https://img.youtube.com/vi/<?php echo $linkparams['v']; ?>/0.jpg">
1441 - <?php
1442 - }
1443 - }
1444 -
1445 - public static function ytprefs_plugin_menu()
1446 - {
1447 - //add_menu_page('YouTube Settings', 'YouTube', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options', plugins_url('images/youtubeicon16.png', __FILE__), '10.00392854349');
1448 -
1449 - if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
1450 - {
1451 - add_menu_page('YouTube Settings', 'YouTube PRO', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options', plugins_url('images/youtubeicon16.png', __FILE__), '10.000392854349');
1452 - //add_menu_page('YouTube Analytics Dashboard', 'PRO Analytics', 'manage_options', 'youtube-ep-analytics-dashboard', 'YouTubePrefs::epstats_show_options', plugins_url('images/epstats16.png', __FILE__), '10.000492884349');
1453 - add_submenu_page('youtube-my-preferences', '', '', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options');
1454 - add_submenu_page('youtube-my-preferences', 'YouTube Analytics Dashboard', '<img style="width: 16px; height: 16px; vertical-align: text-top;" src="' . plugins_url('images/epstats16.png', __FILE__) . '" />&nbsp;&nbsp;PRO Analytics', 'manage_options', 'youtube-ep-analytics-dashboard', 'YouTubePrefs::epstats_show_options');
1455 - }
1456 - else
1457 - {
1458 - add_menu_page('YouTube Settings', 'YouTube Free', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options', plugins_url('images/youtubeicon16.png', __FILE__), '10.000392854349');
1459 - add_submenu_page('youtube-my-preferences', '', '', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options');
1460 - add_submenu_page('youtube-my-preferences', 'YouTube PRO', '<img style="width: 16px; height: 16px; vertical-align: text-top;" src="' . plugins_url('images/iconwizard.png', __FILE__) . '" />&nbsp;&nbsp;YouTube PRO', 'manage_options', 'youtube-ep-analytics-dashboard', 'YouTubePrefs::epstats_show_options');
1461 - }
1462 - add_submenu_page(null, 'YouTube Posts', 'YouTube Posts', 'manage_options', 'youtube-ep-glance', 'YouTubePrefs::glance_page');
1463 - }
1464 -
1465 - public static function epstats_show_options()
1466 - {
1467 -
1468 - if (!current_user_can('manage_options'))
1469 - {
1470 - wp_die(__('You do not have sufficient permissions to access this page.'));
1471 - }
1472 -
1473 - if (self::$double_plugin)
1474 - {
1475 - //add_action('admin_notices', array("YouTubePrefs", "double_plugin_warning"));
1476 - self::double_plugin_warning();
1477 - }
1478 -
1479 -
1480 - // Now display the settings editing screen
1481 - ?>
1482 - <div class="wrap">
1483 - <style type="text/css">
1484 - .wrap {font-family: Arial;}
1485 - .epicon { width: 20px; height: 20px; vertical-align: middle; padding-right: 5px;}
1486 - .epindent {padding-left: 25px;}
1487 - iframe.shadow {-webkit-box-shadow: 0px 0px 20px 0px #000000; box-shadow: 0px 0px 20px 0px #000000;}
1488 - .bold {font-weight: bold;}
1489 - .orange {color: #f85d00;}
1490 - </style>
1491 - <br>
1492 - <?php
1493 - $thishost = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "");
1494 - $thiskey = self::$alloptions[self::$opt_pro];
1495 -
1496 - $dashurl = self::$epbase . "/dashboard/pro-easy-video-analytics.aspx?ref=protab&domain=" . $thishost . "&prokey=" . $thiskey;
1497 -
1498 - if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
1499 - {
1500 - //// header
1501 - echo "<h2>" . '<img src="' . plugins_url('images/epstats16.png', __FILE__) . '" /> ' . __('YouTube Analytics Dashboard') . "</h2>";
1502 - echo '<p><i>Logging you in below... (You can also <a class="button-primary" target="_blank" href="' . $dashurl . '">click here</a> to launch your dashboard in a new tab)</i></p>';
1503 - }
1504 - else
1505 - {
1506 - //// header
1507 - echo "<h2>" . '<img style="vertical-align: text-bottom;" src="' . plugins_url('images/iconwizard.png', __FILE__) . '" /> ' . __('YouTube Plugin PRO') . "</h2><p class='bold orange'>This tab is here to provide direct access to analytics. Graphs and other data about your site will show below after you activate PRO.</p><br>";
1508 - }
1509 - ?>
1510 - <iframe class="shadow" src="<?php echo $dashurl ?>" width="1060" height="2700" scrolling="auto"/>
1511 - </div>
1512 - <?php
1513 - }
1514 -
1515 - public static function my_embedplus_pro_record()
1516 - {
1517 - $result = array();
1518 - if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
1519 - {
1520 - $tmppro = preg_replace('/[^A-Za-z0-9-]/i', '', $_REQUEST[self::$opt_pro]);
1521 - $new_options = array();
1522 - $new_options[self::$opt_pro] = $tmppro;
1523 - $all = get_option(self::$opt_alloptions);
1524 - $all = $new_options + $all;
1525 - update_option(self::$opt_alloptions, $all);
1526 -
1527 - if (strlen($tmppro) > 0)
1528 - {
1529 - $result['type'] = 'success';
1530 - }
1531 - else
1532 - {
1533 - $result['type'] = 'error';
1534 - }
1535 - echo json_encode($result);
1536 - }
1537 - else
1538 - {
1539 - $result['type'] = 'error';
1540 - header("Location: " . $_SERVER["HTTP_REFERER"]);
1541 - }
1542 - die();
1543 - }
1544 -
1545 - public static function my_embedplus_clearspdc()
1546 - {
1547 - $result = array();
1548 - if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
1549 - {
1550 - try
1551 - {
1552 - self::spdcpurge();
1553 - $result['type'] = 'success';
1554 - }
1555 - catch (Exception $ex)
1556 - {
1557 - $result['type'] = 'error';
1558 - }
1559 - echo json_encode($result);
1560 - }
1561 - else
1562 - {
1563 - $result['type'] = 'error';
1564 - header("Location: " . $_SERVER["HTTP_REFERER"]);
1565 - }
1566 - die();
1567 - }
1568 -
1569 - public static function custom_admin_pointers_check()
1570 - {
1571 - //return false; // ooopointer shut all off;
1572 - $admin_pointers = self::custom_admin_pointers();
1573 - foreach ($admin_pointers as $pointer => $array)
1574 - {
1575 - if ($array['active'])
1576 - return true;
1577 - }
1578 - }
1579 -
1580 - public static function glance_script()
1581 - {
1582 - add_thickbox();
1583 - ?>
1584 - <script type="text/javascript">
1585 - function widen_ytprefs_glance() {
1586 - setTimeout(function() {
1587 - jQuery("#TB_window").animate({marginLeft: '-' + parseInt((780 / 2), 10) + 'px', width: '780px'}, 300);
1588 - jQuery("#TB_window iframe").animate({width: '780px'}, 300);
1589 - }, 15);
1590 - }
1591 -
1592 - (function($j)
1593 - {
1594 - $j(document).ready(function() {
1595 -
1596 - $j.ajax({
1597 - type: "post",
1598 - dataType: "json",
1599 - timeout: 30000,
1600 - url: wpajaxurl,
1601 - data: {action: 'my_embedplus_glance_count'},
1602 - success: function(response) {
1603 - if (response.type == "success") {
1604 - $j(response.container).append(response.data);
1605 - $j(".ytprefs_glance_button").click(widen_ytprefs_glance);
1606 - $j(window).resize(widen_ytprefs_glance);
1607 - if (typeof ep_do_pointers == 'function')
1608 - {
1609 - //ep_do_pointers($j);
1610 - }
1611 - }
1612 - else {
1613 - }
1614 - },
1615 - error: function(xhr, ajaxOptions, thrownError) {
1616 -
1617 - },
1618 - complete: function() {
1619 - }
1620 - });
1621 -
1622 - });
1623 -
1624 - })(jQuery);
1625 - </script>
1626 - <?php
1627 - }
1628 -
1629 - public static function custom_admin_pointers_footer()
1630 - {
1631 - $admin_pointers = self::custom_admin_pointers();
1632 - ?>
1633 - <script type="text/javascript">
1634 - /* <![CDATA[ */
1635 - function ep_do_pointers($)
1636 - {
1637 - <?php
1638 - foreach ($admin_pointers as $pointer => $array)
1639 - {
1640 - if ($array['active'])
1641 - {
1642 - ?>
1643 - $('<?php echo $array['anchor_id']; ?>').pointer({
1644 - content: '<?php echo $array['content']; ?>',
1645 - position: {
1646 - edge: '<?php echo $array['edge']; ?>',
1647 - align: '<?php echo $array['align']; ?>'
1648 - },
1649 - close: function() {
1650 - $.post(wpajaxurl, {
1651 - pointer: '<?php echo $pointer; ?>',
1652 - action: 'dismiss-wp-pointer'
1653 - });
1654 - }
1655 - }).pointer('open');
1656 - <?php
1657 - }
1658 - }
1659 - ?>
1660 - }
1661 -
1662 - ep_do_pointers(jQuery); // switch off all pointers via js ooopointer
1663 - /* ]]> */
1664 - </script>
1665 - <?php
1666 - }
1667 -
1668 - public static function custom_admin_pointers()
1669 - {
1670 - $dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
1671 - $version = str_replace('.', '_', self::$version); // replace all periods in version with an underscore
1672 - $prefix = 'custom_admin_pointers' . $version . '_';
1673 -
1674 - $new_pointer_content = '<h3>' . __('New Update') . '</h3>'; // ooopointer
1675 -
1676 - $new_pointer_content .= '<p>'; // ooopointer
1677 - if (!(self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0))
1678 - {
1679 -
1680 - $new_pointer_content .= __('(1) Adds the ability to automatically migrate from another plugin shortcode, for FREE and <a href="' . self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=frompointer" target="_blank">PRO</a> versions. (2) Adds a new caching parameter and caching tips for <a href="' . self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=frompointer" target="_blank">PRO users &raquo;</a>.');
1681 - }
1682 - else
1683 - {
1684 - $new_pointer_content .= __('(1) Adds the ability to automatically migrate from another plugin shortcode, for FREE and PRO versions. (2) Adds a new caching parameter and caching tips for PRO users.');
1685 - }
1686 - $new_pointer_content .= '</p>';
1687 -
1688 - return array(
1689 - $prefix . 'new_items' => array(
1690 - 'content' => $new_pointer_content,
1691 - 'anchor_id' => 'a.toplevel_page_youtube-my-preferences', //'#ytprefs_glance_button',
1692 - 'edge' => 'top',
1693 - 'align' => 'left',
1694 - 'active' => (!in_array($prefix . 'new_items', $dismissed) )
1695 - ),
1696 - );
1697 - }
1698 -
1699 - public static function postchecked($idx)
1700 - {
1701 - return isset($_POST[$idx]) && $_POST[$idx] == (true || 'on');
1702 - }
1703 -
1704 - public static function ytprefs_show_options()
1705 - {
1706 -
1707 - if (!current_user_can('manage_options'))
1708 - {
1709 - wp_die(__('You do not have sufficient permissions to access this page.'));
1710 - }
1711 -
1712 - if (self::$double_plugin)
1713 - {
1714 - //add_action('admin_notices', array("YouTubePrefs", "double_plugin_warning"));
1715 - self::double_plugin_warning();
1716 - }
1717 -
1718 -
1719 - // variables for the field and option names
1720 - $ytprefs_submitted = 'ytprefs_submitted';
1721 -
1722 - // Read in existing option values from database
1723 -
1724 - $all = get_option(self::$opt_alloptions);
1725 -
1726 - // See if the user has posted us some information
1727 - // If they did, this hidden field will be set to 'Y'
1728 - if (isset($_POST[$ytprefs_submitted]) && $_POST[$ytprefs_submitted] == 'Y')
1729 - {
1730 - // Read their posted values
1731 -
1732 - $new_options = array();
1733 - $new_options[self::$opt_center] = self::postchecked(self::$opt_center) ? 1 : 0;
1734 - $new_options[self::$opt_glance] = self::postchecked(self::$opt_glance) ? 1 : 0;
1735 - $new_options[self::$opt_autoplay] = self::postchecked(self::$opt_autoplay) ? 1 : 0;
1736 - $new_options[self::$opt_cc_load_policy] = self::postchecked(self::$opt_cc_load_policy) ? 1 : 0;
1737 - $new_options[self::$opt_iv_load_policy] = self::postchecked(self::$opt_iv_load_policy) ? 1 : 3;
1738 - $new_options[self::$opt_loop] = self::postchecked(self::$opt_loop) ? 1 : 0;
1739 - $new_options[self::$opt_modestbranding] = self::postchecked(self::$opt_modestbranding) ? 1 : 0;
1740 - $new_options[self::$opt_rel] = self::postchecked(self::$opt_rel) ? 1 : 0;
1741 - $new_options[self::$opt_showinfo] = self::postchecked(self::$opt_showinfo) ? 1 : 0;
1742 - $new_options[self::$opt_playsinline] = self::postchecked(self::$opt_playsinline) ? 1 : 0;
1743 - $new_options[self::$opt_origin] = self::postchecked(self::$opt_origin) ? 1 : 0;
1744 - $new_options[self::$opt_controls] = self::postchecked(self::$opt_controls) ? 2 : 0;
1745 - $new_options[self::$opt_autohide] = self::postchecked(self::$opt_autohide) ? 1 : 2;
1746 - $new_options[self::$opt_html5] = self::postchecked(self::$opt_html5) ? 1 : 0;
1747 - $new_options[self::$opt_theme] = self::postchecked(self::$opt_theme) ? 'dark' : 'light';
1748 - $new_options[self::$opt_color] = self::postchecked(self::$opt_color) ? 'red' : 'white';
1749 - $new_options[self::$opt_wmode] = self::postchecked(self::$opt_wmode) ? 'opaque' : 'transparent';
1750 - $new_options[self::$opt_vq] = self::postchecked(self::$opt_vq) ? 'hd720' : '';
1751 - $new_options[self::$opt_nocookie] = self::postchecked(self::$opt_nocookie) ? 1 : 0;
1752 - $new_options[self::$opt_acctitle] = self::postchecked(self::$opt_acctitle) ? 1 : 0;
1753 - $new_options[self::$opt_ogvideo] = self::postchecked(self::$opt_ogvideo) ? 1 : 0;
1754 - $new_options[self::$opt_migrate] = self::postchecked(self::$opt_migrate) ? 1 : 0;
1755 - $new_options[self::$opt_migrate_youtube] = self::postchecked(self::$opt_migrate_youtube) ? 1 : 0;
1756 - //$new_options[self::$opt_ssl] = self::postchecked(self::$opt_ssl) ? 1 : 0;
1757 - $new_options[self::$opt_oldspacing] = self::postchecked(self::$opt_oldspacing) ? 1 : 0;
1758 - $new_options[self::$opt_responsive] = self::postchecked(self::$opt_responsive) ? 1 : 0;
1759 - $new_options[self::$opt_widgetfit] = self::postchecked(self::$opt_widgetfit) ? 1 : 0;
1760 - $new_options[self::$opt_schemaorg] = self::postchecked(self::$opt_schemaorg) ? 1 : 0;
1761 - $new_options[self::$opt_ftpostimg] = self::postchecked(self::$opt_ftpostimg) ? 1 : 0;
1762 - $new_options[self::$opt_spdc] = self::postchecked(self::$opt_spdc) ? 1 : 0;
1763 - $new_options[self::$opt_dynload] = self::postchecked(self::$opt_dynload) ? 1 : 0;
1764 - $new_options[self::$opt_defaultdims] = self::postchecked(self::$opt_defaultdims) ? 1 : 0;
1765 - $new_options[self::$opt_defaultvol] = self::postchecked(self::$opt_defaultvol) ? 1 : 0;
1766 - $new_options[self::$opt_dohl] = self::postchecked(self::$opt_dohl) ? 1 : 0;
1767 -
1768 - $_defaultwidth = '';
1769 - try
1770 - {
1771 - $_defaultwidth = is_numeric(trim($_POST[self::$opt_defaultwidth])) ? intval(trim($_POST[self::$opt_defaultwidth])) : $_defaultwidth;
1772 - }
1773 - catch (Exception $ex)
1774 - {
1775 -
1776 - }
1777 - $new_options[self::$opt_defaultwidth] = $_defaultwidth;
1778 -
1779 - $_defaultheight = '';
1780 - try
1781 - {
1782 - $_defaultheight = is_numeric(trim($_POST[self::$opt_defaultheight])) ? intval(trim($_POST[self::$opt_defaultheight])) : $_defaultheight;
1783 - }
1784 - catch (Exception $ex)
1785 - {
1786 -
1787 - }
1788 - $new_options[self::$opt_defaultheight] = $_defaultheight;
1789 -
1790 - $_vol = '';
1791 - try
1792 - {
1793 - $_vol = is_numeric(trim($_POST[self::$opt_vol])) ? intval(trim($_POST[self::$opt_vol])) : $_vol;
1794 - }
1795 - catch (Exception $ex)
1796 - {
1797 -
1798 - }
1799 - $new_options[self::$opt_vol] = $_vol;
1800 -
1801 -
1802 - $_apikey = '';
1803 - try
1804 - {
1805 - $_apikey = trim(str_replace(array(' ', "'", '"'), array('', '', ''), strip_tags($_POST[self::$opt_apikey])));
1806 - }
1807 - catch (Exception $ex)
1808 - {
1809 - $_apikey = '';
1810 - }
1811 - $new_options[self::$opt_apikey] = $_apikey;
1812 -
1813 - $_hl = '';
1814 - try
1815 - {
1816 - $temphl = strtolower(trim($_POST[self::$opt_hl]));
1817 - $_hl = preg_match('/^[a-z][a-z]$/i', $temphl) ? $temphl : '';
1818 - }
1819 - catch (Exception $ex)
1820 - {
1821 -
1822 - }
1823 - $new_options[self::$opt_hl] = $_hl;
1824 -
1825 - $_dyntype = '';
1826 - try
1827 - {
1828 - $tempdyntype = trim($_POST[self::$opt_dyntype]);
1829 - $_dyntype = preg_match('/^[a-zA-Z-]+$/i', $tempdyntype) ? $tempdyntype : '';
1830 - }
1831 - catch (Exception $ex)
1832 - {
1833 -
1834 - }
1835 - $new_options[self::$opt_dyntype] = $_dyntype;
1836 -
1837 - $_spdcexp = 24;
1838 - try
1839 - {
1840 - $_spdcexp = is_numeric(trim($_POST[self::$opt_spdcexp])) ? intval(trim($_POST[self::$opt_spdcexp])) : $_spdcexp;
1841 - }
1842 - catch (Exception $ex)
1843 - {
1844 -
1845 - }
1846 - $new_options[self::$opt_spdcexp] = $_spdcexp;
1847 -
1848 -
1849 -
1850 - $all = $new_options + $all;
1851 -
1852 - update_option(self::$opt_alloptions, $all);
1853 -
1854 - try
1855 - {
1856 - self::spdcpurge();
1857 - if ($all[self::$opt_spdc] == 1)
1858 - {
1859 - wp_remote_get(site_url());
1860 - }
1861 - }
1862 - catch (Exception $ex)
1863 - {
1864 -
1865 - }
1866 - ?>
1867 - <div class="updated"><p><strong><?php _e('Settings saved.'); ?></strong></p></div>
1868 - <?php
1869 - }
1870 -
1871 -
1872 - // Now display the settings editing screen
1873 -
1874 - echo '<div class="wrap" style="max-width: 1000px;">';
1875 -
1876 - // header
1877 -
1878 - echo "<h2>" . '<img src="' . plugins_url('images/youtubeicon16.png', __FILE__) . '" /> ' . __('YouTube Settings') . "</h2>";
1879 -
1880 - // settings form
1881 - ?>
1882 -
1883 - <style type="text/css">
1884 - .wrap {font-family: Arial; color: #000000;}
1885 - #ytform p { line-height: 20px; margin-bottom: 11px; }
1886 - #ytform ul li {margin-left: 30px; list-style: disc outside none;}
1887 - .ytindent {padding: 0px 0px 0px 20px; font-size: 11px;}
1888 - .ytindent ul, .ytindent p {font-size: 11px;}
1889 - .shadow {-webkit-box-shadow: 0px 0px 20px 0px #000000; box-shadow: 0px 0px 20px 0px #000000;}
1890 - .gopro {margin: 0px;}
1891 - .gopro img {vertical-align: middle;
1892 - width: 19px;
1893 - height: 19px;
1894 - padding-bottom: 4px;}
1895 - .gopro li {margin-bottom: 0px;}
1896 - .orange {color: #f85d00;}
1897 - .bold {font-weight: bold;}
1898 - .grey{color: #888888;}
1899 - #goprobox {border-radius: 15px; padding: 10px 15px 15px 15px; margin-top: 15px; border: 3px solid #CCE5EC; position: relative;}
1900 - #salenote {position: absolute; right: 10px; top: 10px; width: 75px; height: 30px;}
1901 - #nonprosupport {border-radius: 15px; padding: 10px 15px 20px 15px; border: 3px solid #ff6655;}
1902 - .pronon {font-weight: bold; color: #f85d00;}
1903 - ul.reglist li {margin: 0px 0px 0px 30px; list-style: disc outside none;}
1904 - .procol {width: 475px; float: left;}
1905 - .smallnote {font-style: italic; font-size: 10px;}
1906 - .italic {font-style: italic;}
1907 - .ytindent h3 {font-size: 15px; line-height: 22px; margin: 5px 0px 10px 0px;}
1908 - #wizleftlink {float: left; display: block; width: 240px; font-style: italic; text-align: center; text-decoration: none;}
1909 - .button-primary {font-weight: bold; white-space: nowrap;}
1910 - .wp-core-ui p.submit .button-primary {font-size: 20px; height: 50px; padding: 0 20px 1px;
1911 - background: #2ea2cc; /* Old browsers */
1912 - background: -moz-linear-gradient(top, #2ea2cc 0%, #007396 98%); /* FF3.6+ */
1913 - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2ea2cc), color-stop(98%,#007396)); /* Chrome,Safari4+ */
1914 - background: -webkit-linear-gradient(top, #2ea2cc 0%,#007396 98%); /* Chrome10+,Safari5.1+ */
1915 - background: -o-linear-gradient(top, #2ea2cc 0%,#007396 98%); /* Opera 11.10+ */
1916 - background: -ms-linear-gradient(top, #2ea2cc 0%,#007396 98%); /* IE10+ */
1917 - background: linear-gradient(to bottom, #2ea2cc 0%,#007396 98%); /* W3C */
1918 - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2ea2cc', endColorstr='#007396',GradientType=0 ); /* IE6-9 */
1919 - }
1920 - p.submit em {display: inline-block; padding-left: 20px; vertical-align: middle; width: 220px; margin-top: -6px;}
1921 - #opt_pro {box-shadow: 0px 0px 5px 0px #1870D5; width: 320px;vertical-align: top;}
1922 - #goprobox h3 {font-size: 13px;}
1923 - .chx p {margin: 0px 0px 5px 0px;}
1924 - .cuz {background-image: linear-gradient(to bottom,#4983FF,#0C5597) !important; color: #ffffff;}
1925 - .brightpro {background-image: linear-gradient(to bottom,#ff5500,#cc2200) !important; color: #ffffff;}
1926 - #boxdefaultdims {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_defaultdims] ? '' : 'display: none;' ?>}
1927 - .textinput {border-width: 2px !important;}
1928 - h3.sect {border-radius: 10px; background-color: #D9E9F7; padding: 5px 5px 5px 10px; position: relative; font-weight: bold;}
1929 - h3.sect a {text-decoration: none; color: #E20000;}
1930 - h3.sect a.button-primary {color: #ffffff;}
1931 - .ytnav {margin-bottom: 15px;}
1932 - .ytnav a {font-weight: bold; display: inline-block; padding: 5px 10px; margin: 0px 20px 0px 0px; border: 1px solid #cccccc; border-radius: 6px;
1933 - text-decoration: none; background-color: #ffffff;}
1934 - .jumper {height: 25px;}
1935 - .ssschema {float: right; width: 350px; height: auto; margin-right: 10px;}
1936 - .ssfb {float: right; height: auto; margin-right: 10px; margin-left: 15px; margin-bottom: 10px;}
1937 - .totop {position: absolute; right: 20px; top: 5px; color: #444444; font-size: 10px;}
1938 - input[type=checkbox] {border: 1px solid #000000;}
1939 - .chktitle {display: inline-block; padding: 1px 3px 1px 3px; border-radius: 3px; background-color: #ffffff; border: 1px solid #dddddd;}
1940 - b, strong {font-weight: bold;}
1941 - input.checkbox[disabled] {border: 1px dashed #444444;}
1942 - .pad10 {padding: 10px;}
1943 - #boxdohl {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_dohl] ? '' : 'display: none;' ?>}
1944 - #boxdyn {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_dynload] ? '' : 'display: none;' ?>}
1945 - #boxspdc {padding: 0px 10px; <?php echo $all[self::$opt_spdc] ? '' : 'display: none;' ?>}
1946 - #boxdefaultvol {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_defaultvol] ? '' : 'display: none;' ?>}
1947 - .vol-output {display: none; width: 30px; color: #008800;}
1948 - .vol-range {background-color: #dddddd; border-radius: 3px; cursor: pointer;}
1949 - input#vol {vertical-align: middle;}
1950 - .vol-seeslider {display: none;}
1951 - input#spdcexp {width: 70px;}
1952 - .indent-option {margin-left: 25px;}
1953 - #boxschemaorg {font-weight: bold; padding: 7px 0; <?php echo $all[self::$opt_schemaorg] ? 'display: block;' : 'display: none;' ?>}
1954 - #boxmigratelist { <?php echo $all[self::$opt_migrate] ? '' : 'display: none;' ?>}
1955 - .apikey-msg {display: inline-block; width: 45%; vertical-align: top;}
1956 - .apikey-video{margin-left: 3%; display: inline-block; width: 50%; position: relative; padding-top: 29%}
1957 - .apikey-video iframe{display: block; width: 100%; height: 100%; position: absolute; top: 0; left: 0;}
1958 - #boxnocookie {display: inline-block; border-radius: 3px; padding: 2px 4px 2px 4px; color: red; background-color: yellow; font-weight: bold; <?php echo $all[self::$opt_nocookie] ? '' : 'display: none;' ?>}
1959 - .strike {text-decoration: line-through;}
1960 - .upgchecks { padding: 20px; border-radius: 15px; border: 1px dotted #777777; background-color: #fcfcfc; }
1961 - .clearboth {clear: both;}
1962 - div.hr {clear: both; border-bottom: 1px dotted #A8BDD8; margin: 20px 0 20px 0;}
1963 - .wp-pointer-buttons a.close {margin-top: 0 !important;}
1964 - .pad20{padding: 20px 0 20px 0;}
1965 - </style>
1966 - <div class="ytindent">
1967 - <br>
1968 - <div id="jumphowto"></div>
1969 - <div class="ytnav">
1970 - <a href="#jumphowto">How To Embed</a>
1971 - <a href="#jumpwiz">Visual YouTube Wizard</a>
1972 - <a href="#jumpdefaults">Set Defaults</a>
1973 - <a href="#jumpoverride">How To Override Defaults</a>
1974 - <a target="_blank" href="<?php echo self::$epbase . "/dashboard/pro-easy-video-analytics.aspx?ref=protab" ?>" style="border-color: #888888;">Why Upgrade?</a>
1975 - <a href="#jumpsupport">Support</a>
1976 - </div>
1977 -
1978 - <form name="form1" method="post" action="" id="ytform">
1979 - <input type="hidden" name="<?php echo $ytprefs_submitted; ?>" value="Y">
1980 -
1981 - <h3 class="sect">
1982 - <?php _e("How to Insert a YouTube Video or Playlist") ?> <!--<span class="pronon">(For Free and <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" target="_blank">PRO Users &raquo;</a>)</span>-->
1983 - </h3>
1984 - <p>
1985 - <b>For videos:</b> <i>Method 1 - </i> Do you already have a URL to the video you want to embed in a post, page, or even a widget? All you have to do is paste it on its own line, as shown below (including the http:// part). Easy, eh?<br>
1986 - <i>Method 2 - </i> If you want to do some formatting (e.g. add HTML to center a video) or have two or more videos next to each other on the same line, wrap each link with the <code>[embedyt]...[/embedyt]</code> shortcode. <b>Tip for embedding videos on the same line:</b> As shown in the example image below, decrease the size of each video so that they fit together on the same line (See the "How To Override Defaults" section for height and width instructions).
1987 - </p>
1988 - <p>
1989 - <b>For playlists:</b> Go to the page for the playlist that lists all of its videos (<a target="_blank" href="http://www.youtube.com/playlist?list=PL70DEC2B0568B5469">Example &raquo;</a>). Click on the video that you want the playlist to start with. Copy and paste that browser URL into your blog on its own line. If you want to have two or more playlists next to each other on the same line, wrap each link with the <code>[embedyt]...[/embedyt]</code> shortcode.
1990 - </p>
1991 - <p>
1992 - <b>For channel playlists:</b> At your editor, click on the <img style="vertical-align: text-bottom;" src="<?php echo plugins_url('images/wizbuttonbig.png', __FILE__) ?>"> wizard button and choose the option <i>Search for a video or channel to insert in my editor.</i> Then, click on the <i>channel playlist</i> option there (instead of <i>single video</i>). Search for the channel username and follow the rest of the directions there.
1993 - </p>
1994 - <p>
1995 - <b>Examples:</b><br><br>
1996 - <img style="width: 900px; height: auto;" class="shadow" src="<?php echo plugins_url('images/sshowto.png', __FILE__) ?>" />
1997 - </p>
1998 - <p>
1999 - Always follow these rules for any URL:
2000 - </p>
2001 - <ul class="reglist">
2002 - <li>Make sure the URL is really on its own line by itself. Or, if you need multiple videos on the same line, make sure each URL is wrapped properly with the shortcode (Example: <code>[embedyt]http://www.youtube.com/watch?v=ABCDEFGHIJK&width=400&height=250[/embedyt]</code>)</li>
2003 - <li>Make sure the URL is <strong>not</strong> an active hyperlink (i.e., it should just be plain text). Otherwise, highlight the URL and click the "unlink" button in your editor: <img src="<?php echo plugins_url('images/unlink.png', __FILE__) ?>"/></li>
2004 - <li>Make sure you did <strong>not</strong> format or align the URL in any way. If your URL still appears in your actual post instead of a video, highlight it and click the "remove formatting" button (formatting can be invisible sometimes): <img src="<?php echo plugins_url('images/erase.png', __FILE__) ?>"/></li>
2005 - <li>If you really want to align the video, try wrapping the link with the shortcode first. For example: <code>[embedyt]http://www.youtube.com/watch?v=ABCDEFGHIJK[/embedyt]</code> Using the shortcode also allows you to have two or more videos next to each other on the same line. Just put the shortcoded links together on the same line. For example:<br>
2006 - <code>[embedyt]http://www.youtube.com/watch?v=ABCDEF[/embedyt] [embedyt]http://www.youtube.com/watch?v=GHIJK[/embedyt]</code>
2007 - </ul>
2008 -
2009 - <div class="jumper" id="jumpwiz"></div>
2010 - <h3 class="sect">Visual YouTube Wizard <a href="#top" class="totop">&#9650; top</a></h3>
2011 -
2012 - <p>
2013 - Let's say you don't know the exact URL of the video you wish to embed. Well, we've made the ability to directly search YouTube and insert videos right from your editor tab as a free feature to all users.
2014 - Simply click the <img style="vertical-align: text-bottom;" src="<?php echo plugins_url('images/wizbuttonbig.png', __FILE__) ?>"> wizard button found above
2015 - your editor to start the wizard (see image above to locate this button). There, you'll be given the option to enter your search terms.
2016 - Click the "Search" button to view the results. Each result will have an <span class="button-primary cuz">&#9660; Insert Into Editor</span> button that
2017 - you can click to directly embed the desired video link to your post without having to copy and paste.
2018 - </p>
2019 - <p>
2020 - The ability to read the latest Internet discussions about the videos you want to embed is now free to all users.
2021 - </p>
2022 - <p>
2023 - <b class="orange">Even more options are available to PRO users!</b> Simply click the <a href="<?php echo self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=protab' ?>" target="_blank" class="button-primary cuz">&#9658; Customize</a> button on the wizard to further personalize your embeds without having to enter special codes yourself.
2024 - <br>
2025 - <br>
2026 -
2027 - <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" target="_blank" style="text-decoration: none;"><img style="width: 500px; margin: 0 auto; display: block;" src="<?php echo plugins_url('images/ssprowizard.png', __FILE__) ?>" ></a>
2028 -
2029 - </p>
2030 - <div class="jumper" id="jumpdefaults"></div>
2031 - <h3 class="sect">
2032 - <?php _e("Default YouTube Options") ?> <a href="#top" class="totop">&#9650; top</a>
2033 - </h3>
2034 - <p>
2035 - <?php _e("One of the benefits of using this plugin is that you can set site-wide default options for all your videos (click \"Save Changes\" when finished). However, you can also override them (and more) on a per-video basis. Directions on how to do that are in the next section.") ?>
2036 - </p>
2037 - <p class="submit">
2038 - <input type="submit" onclick="return savevalidate();" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
2039 - <em>If you're using a separate caching plugin and you do not see your changes after saving, you might want to reset your cache.</em>
2040 - </p>
2041 -
2042 - <div class="ytindent chx">
2043 - <p>
2044 - <input name="<?php echo self::$opt_glance; ?>" id="<?php echo self::$opt_glance; ?>" <?php checked($all[self::$opt_glance], 1); ?> type="checkbox" class="checkbox">
2045 - <label for="<?php echo self::$opt_glance; ?>"><?php _e('<b class="chktitle">At a glance:</b> Show "At a Glance" Embed Links') ?></label>
2046 - </p>
2047 - <p>
2048 - <input name="<?php echo self::$opt_center; ?>" id="<?php echo self::$opt_center; ?>" <?php checked($all[self::$opt_center], 1); ?> type="checkbox" class="checkbox">
2049 - <label for="<?php echo self::$opt_center; ?>"><?php _e('<b class="chktitle">Centering:</b> Automatically center all your videos (not necessary if all your videos span the whole width of your blog).') ?></label>
2050 - </p>
2051 - <p>
2052 - <input name="<?php echo self::$opt_autoplay; ?>" id="<?php echo self::$opt_autoplay; ?>" <?php checked($all[self::$opt_autoplay], 1); ?> type="checkbox" class="checkbox">
2053 - <label for="<?php echo self::$opt_autoplay; ?>"><?php _e('<b class="chktitle">Autoplay:</b> Automatically start playing your videos.') ?></label>
2054 - </p>
2055 - <p>
2056 - <input name="<?php echo self::$opt_iv_load_policy; ?>" id="<?php echo self::$opt_iv_load_policy; ?>" <?php checked($all[self::$opt_iv_load_policy], 1); ?> type="checkbox" class="checkbox">
2057 - <label for="<?php echo self::$opt_iv_load_policy; ?>"><?php _e('<b class="chktitle">Annotations:</b> Show annotations by default.') ?></label>
2058 - </p>
2059 - <p>
2060 - <input name="<?php echo self::$opt_loop; ?>" id="<?php echo self::$opt_loop; ?>" <?php checked($all[self::$opt_loop], 1); ?> type="checkbox" class="checkbox">
2061 - <label for="<?php echo self::$opt_loop; ?>"><?php _e('<b class="chktitle">Looping:</b> Loop all your videos.') ?></label>
2062 - </p>
2063 - <p>
2064 - <input name="<?php echo self::$opt_modestbranding; ?>" id="<?php echo self::$opt_modestbranding; ?>" <?php checked($all[self::$opt_modestbranding], 1); ?> type="checkbox" class="checkbox">
2065 - <label for="<?php echo self::$opt_modestbranding; ?>"><?php _e('<b class="chktitle">Modest Branding:</b> No YouTube logo will be shown on the control bar. Instead, the logo will only show as a watermark when the video is paused/stopped.') ?></label>
2066 - </p>
2067 - <p>
2068 - <input name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>" <?php checked($all[self::$opt_rel], 1); ?> type="checkbox" class="checkbox">
2069 - <label for="<?php echo self::$opt_rel; ?>"><?php _e('<b class="chktitle">Related Videos:</b> Show related videos at the end.') ?></label>
2070 - </p>
2071 - <p>
2072 - <input name="<?php echo self::$opt_showinfo; ?>" id="<?php echo self::$opt_showinfo; ?>" <?php checked($all[self::$opt_showinfo], 1); ?> type="checkbox" class="checkbox">
2073 - <label for="<?php echo self::$opt_showinfo; ?>"><?php _e('<b class="chktitle">Show Title:</b> Show the video title and other info.') ?></label>
2074 - </p>
2075 - <p>
2076 - <input name="<?php echo self::$opt_acctitle; ?>" id="<?php echo self::$opt_acctitle; ?>" <?php checked($all[self::$opt_acctitle], 1); ?> type="checkbox" class="checkbox">
2077 - <label for="<?php echo self::$opt_acctitle; ?>"><b class="chktitle">Accessible Title Attributes: <sup class="orange">NEW</sup></b> Improve accessibility by using title attributes for screen reader support. It should help your site pass functional accessibility evaluations (FAE). </label>
2078 - </p>
2079 - <p>
2080 - <input name="<?php echo self::$opt_theme; ?>" id="<?php echo self::$opt_theme; ?>" <?php checked($all[self::$opt_theme], 'dark'); ?> type="checkbox" class="checkbox">
2081 - <label for="<?php echo self::$opt_theme; ?>"><?php _e('<b class="chktitle">Dark Theme:</b> Use the dark theme (uncheck to use light theme).') ?></label>
2082 - </p>
2083 - <p>
2084 - <input name="<?php echo self::$opt_color; ?>" id="<?php echo self::$opt_color; ?>" <?php checked($all[self::$opt_color], 'red'); ?> type="checkbox" class="checkbox">
2085 - <label for="<?php echo self::$opt_color; ?>"><?php _e('<b class="chktitle">Red Progress Bar:</b> Use the red progress bar (uncheck to use a white progress bar). Note: Using white will disable the modestbranding option.') ?></label>
2086 - </p>
2087 - <p>
2088 - <input name="<?php echo self::$opt_vq; ?>" id="<?php echo self::$opt_vq; ?>" <?php checked($all[self::$opt_vq], 'hd720'); ?> type="checkbox" class="checkbox">
2089 - <label for="<?php echo self::$opt_vq; ?>"><?php _e('<b class="chktitle">HD Quality:</b> Force HD quality when available. <b>NOTE: YouTube is deprecating this unofficially supported option.</b>') ?> </label>
2090 - </p>
2091 - <p>
2092 - <input name="<?php echo self::$opt_wmode; ?>" id="<?php echo self::$opt_wmode; ?>" <?php checked($all[self::$opt_wmode], 'opaque'); ?> type="checkbox" class="checkbox">
2093 - <label for="<?php echo self::$opt_wmode; ?>"><?php _e('<b class="chktitle">Wmode:</b> Use "opaque" wmode (uncheck to use "transparent"). Opaque may have higher performance.') ?></label>
2094 - </p>
2095 - <p>
2096 - <input name="<?php echo self::$opt_defaultdims; ?>" id="<?php echo self::$opt_defaultdims; ?>" <?php checked($all[self::$opt_defaultdims], 1); ?> type="checkbox" class="checkbox">
2097 - <span id="boxdefaultdims">
2098 - Width: <input type="text" name="<?php echo self::$opt_defaultwidth; ?>" id="<?php echo self::$opt_defaultwidth; ?>" value="<?php echo trim($all[self::$opt_defaultwidth]); ?>" class="textinput" style="width: 50px;"> &nbsp;
2099 - Height: <input type="text" name="<?php echo self::$opt_defaultheight; ?>" id="<?php echo self::$opt_defaultheight; ?>" value="<?php echo trim($all[self::$opt_defaultheight]); ?>" class="textinput" style="width: 50px;">
2100 - </span>
2101 -
2102 - <label for="<?php echo self::$opt_defaultdims; ?>"><?php _e('<b class="chktitle">Default Dimensions:</b> Make your videos have a default size. (NOTE: Checking the responsive option will override this size setting) ') ?></label>
2103 - </p>
2104 - <p>
2105 - <input name="<?php echo self::$opt_responsive; ?>" id="<?php echo self::$opt_responsive; ?>" <?php checked($all[self::$opt_responsive], 1); ?> type="checkbox" class="checkbox">
2106 - <label for="<?php echo self::$opt_responsive; ?>"><?php _e('<b class="chktitle">Responsive Video Sizing:</b> Make your videos responsive so that they dynamically fit in all screen sizes (smart phone, PC and tablet). NOTE: While this is checked, any custom hardcoded widths and heights you may have set will dynamically change too. <b>Do not check this if your theme already handles responsive video sizing.</b>') ?></label>
2107 - </p>
2108 - <p>
2109 - <input name="<?php echo self::$opt_widgetfit; ?>" id="<?php echo self::$opt_widgetfit; ?>" <?php checked($all[self::$opt_widgetfit], 1); ?> type="checkbox" class="checkbox">
2110 - <label for="<?php echo self::$opt_widgetfit; ?>"><?php _e('<b class="chktitle">Autofit Widget Videos:</b> Make each video that you embed in a widget area automatically fit the width of its container.</b>') ?></label>
2111 - </p>
2112 - <p>
2113 - <input name="<?php echo self::$opt_playsinline; ?>" id="<?php echo self::$opt_playsinline; ?>" <?php checked($all[self::$opt_playsinline], 1); ?> type="checkbox" class="checkbox">
2114 - <label for="<?php echo self::$opt_playsinline; ?>"><?php _e('<b class="chktitle">iOS Playback:</b> Check this to allow your embeds to play inline within your page when viewed on iOS (iPhone and iPad) browsers. Uncheck it to have iOS launch your embeds in fullscreen instead.') ?></label>
2115 - </p>
2116 - <p>
2117 - <input name="<?php echo self::$opt_origin; ?>" id="<?php echo self::$opt_origin; ?>" <?php checked($all[self::$opt_origin], 1); ?> type="checkbox" class="checkbox">
2118 - <label for="<?php echo self::$opt_origin; ?>"><b class="chktitle">Extra Player Security: </b>
2119 - Add site origin information with each embed code as an extra security measure. In YouTube's/Google's own words, checking this option "protects against malicious third-party JavaScript being injected into your page and hijacking control of your YouTube player." We especially recommend checking it as it adds higher security than the built-in YouTube embedding method that comes with the current version of WordPress (i.e. oembed).
2120 - </label>
2121 - </p>
2122 - <p>
2123 - <input name="<?php echo self::$opt_nocookie; ?>" id="<?php echo self::$opt_nocookie; ?>" <?php checked($all[self::$opt_nocookie], 1); ?> type="checkbox" class="checkbox">
2124 - <span id="boxnocookie">
2125 - Reminder: If you see errors while testing your playlist embeds or watching your videos on mobile, please uncheck this option.
2126 - </span>
2127 - <label for="<?php echo self::$opt_nocookie; ?>">
2128 - <b class="chktitle">No Cookies:</b> Prevent YouTube from leaving tracking cookies on your visitors browsers unless they actual play the videos. This is coded to apply this behavior on links in your past post as well. <b>NOTE: Research shows that YouTube's support of Do Not Track can be error-prone. </b>
2129 - </label>
2130 - </p>
2131 - <p>
2132 - <input name="<?php echo self::$opt_controls; ?>" id="<?php echo self::$opt_controls; ?>" <?php checked($all[self::$opt_controls], 2); ?> type="checkbox" class="checkbox">
2133 - <label for="<?php echo self::$opt_controls; ?>"><b class="chktitle">Show Controls:</b> Show the player's control bar. Unchecking this option creates a cleaner look but limits what your viewers can control (play position, volume, etc.).</label>
2134 - </p>
2135 - <p>
2136 - <input name="<?php echo self::$opt_autohide; ?>" id="<?php echo self::$opt_autohide; ?>" <?php checked($all[self::$opt_autohide], 1); ?> type="checkbox" class="checkbox">
2137 - <label for="<?php echo self::$opt_autohide; ?>"><b class="chktitle">Autohide Controls:</b> Slide away the control bar after the video starts playing. It will automatically slide back in again if you mouse over the video. If you unchecked "Show Controls" above, then what you select for Autohide does not matter since there are no controls to even hide.</label>
2138 - </p>
2139 - <p>
2140 - <input name="<?php echo self::$opt_oldspacing; ?>" id="<?php echo self::$opt_oldspacing; ?>" <?php checked($all[self::$opt_oldspacing], 1); ?> type="checkbox" class="checkbox">
2141 - <label for="<?php echo self::$opt_oldspacing; ?>">
2142 - <b class="chktitle">Legacy Spacing:</b> Continue the spacing style from version 4.0 and older. Those versions required you to manually add spacing above and below your video. Unchecking this will automatically add the spacing.
2143 - </label>
2144 - </p>
2145 - <!-- <p>
2146 - <input name="<?php echo self::$opt_ssl; ?>" id="<?php echo self::$opt_ssl; ?>" <?php checked($all[self::$opt_ssl], 1); ?> type="checkbox" class="checkbox">
2147 - <label for="<?php echo self::$opt_ssl; ?>">
2148 - <b class="chktitle">HTTPS/SSL Player:</b> Do you have a website that uses HTTPS? Check this to use the secure YouTube player for all of your embeds.
2149 - This will go back and also secure your past embeds as they are loaded on their pages. Most web browsers will warn users when they access web pages via HTTPS that contain embedded content loaded via HTTP. If your main site is currently accessed via HTTPS, using HTTPS URLs for your YouTube embeds will prevent your users from running into that warning. If you're not currently supporting HTTPS/SSL, <a href="http://embedplus.com/convert-old-youtube-embeds-to-https-ssl.aspx" target="_blank">here's some motivation from Google &raquo;</a>
2150 - </label>
2151 - </p>-->
2152 - <p>
2153 - <input name="<?php echo self::$opt_defaultvol; ?>" id="<?php echo self::$opt_defaultvol; ?>" <?php checked($all[self::$opt_defaultvol], 1); ?> type="checkbox" class="checkbox">
2154 - <span id="boxdefaultvol">
2155 - Volume: <span class="vol-output"></span> <input min="0" max="100" step="1" type="text" name="<?php echo self::$opt_vol; ?>" id="<?php echo self::$opt_vol; ?>" value="<?php echo trim($all[self::$opt_vol]); ?>" >
2156 - </span>
2157 - <label for="<?php echo self::$opt_defaultvol; ?>">
2158 - <b class="chktitle">Volume Initialization: </b>
2159 - Set an initial volume level for all of your embedded videos. Check this and you'll see a <span class="vol-seeslider">slider</span> <span class="vol-seetextbox">textbox</span> for setting the start volume to a value between 0 (mute) and 100 (max) percent. Leaving it unchecked means you want the visitor's default behavior. This feature is experimental and is less predictable on a page with more than one embed. Read more about why you might want to <a href="<?php echo self::$epbase ?>/mute-volume-youtube-wordpress.aspx" target="_blank">initialize YouTube embed volume here &raquo;</a>
2160 - </label>
2161 - </p>
2162 -
2163 - <p>
2164 - <input name="<?php echo self::$opt_cc_load_policy; ?>" id="<?php echo self::$opt_cc_load_policy; ?>" <?php checked($all[self::$opt_cc_load_policy], 1); ?> type="checkbox" class="checkbox">
2165 - <label for="<?php echo self::$opt_cc_load_policy; ?>"><?php _e('<b class="chktitle">Closed Captions:</b> Turn on closed captions by default.') ?></label>
2166 - </p>
2167 - <p>
2168 - <input name="<?php echo self::$opt_dohl; ?>" id="<?php echo self::$opt_dohl; ?>" <?php checked($all[self::$opt_dohl], 1); ?> type="checkbox" class="checkbox">
2169 - <!-- <span id="boxdohl">
2170 - Language: <input type="text" name="<?php echo self::$opt_hl; ?>" id="<?php echo self::$opt_hl; ?>" value="<?php echo trim($all[self::$opt_hl]); ?>" class="textinput" style="width: 50px;" maxlength="2">
2171 - </span>-->
2172 - <label for="<?php echo self::$opt_dohl; ?>"><b class="chktitle">Player Localization / Internationalization: </b>
2173 - Automatically detect your site's default language (using get_locale) and set your YouTube embeds interface language so that it matches. Specifically, this will set the player's tooltips and caption track if your language is natively supported by YouTube. We suggest checking this if English is not your site's default language. <a href="<?php echo self::$epbase ?>/youtube-iso-639-1-language-codes.aspx" target="_blank">See here for more details &raquo;</a></label>
2174 - </p>
2175 - <p>
2176 - <input name="<?php echo self::$opt_html5; ?>" id="<?php echo self::$opt_html5; ?>" <?php checked($all[self::$opt_html5], 1); ?> type="checkbox" class="checkbox">
2177 - <label for="<?php echo self::$opt_html5; ?>">
2178 - <b class="chktitle strike">HTML5 First:</b>
2179 - As of January 2015, YouTube began serving the HTML5 player by default; therefore, this plugin no longer needs a special HTML5 setting. This option is simply kept here as a notice.
2180 - </label>
2181 - </p>
2182 -
2183 - <p>
2184 - <input name="<?php echo self::$opt_migrate; ?>" id="<?php echo self::$opt_migrate; ?>" <?php checked($all[self::$opt_migrate], 1); ?> type="checkbox" class="checkbox">
2185 - <label for="<?php echo self::$opt_migrate; ?>">
2186 - <b class="chktitle">Migrate Shortcodes: <sup class="orange bold">NEW</sup></b> Inherit other shortcodes.
2187 - </label>
2188 - <div id="boxmigratelist">
2189 - <ul>
2190 - <li><input name="<?php echo self::$opt_migrate_youtube; ?>" id="<?php echo self::$opt_migrate_youtube; ?>" <?php checked($all[self::$opt_migrate_youtube], 1); ?> type="checkbox" class="checkbox"><label for="<?php echo self::$opt_migrate_youtube; ?>">"Youtube Embed" : <code>youtube</code> and <code>youtube_video</code> shortcodes</label></li>
2191 - <li class="smallnote orange" style="list-style: none;">This feature is beta. More shortcodes coming.</li>
2192 - </ul>
2193 -
2194 - </div>
2195 - </p>
2196 -
2197 - <div class="upgchecks">
2198 - <?php
2199 - if ($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0)
2200 - {
2201 - ?>
2202 - <p class="smallnote orange">Below are PRO features for enhanced SEO and performance (works for even past embed links). </p>
2203 -
2204 - <p>
2205 - <input name="<?php echo self::$opt_spdc; ?>" id="<?php echo self::$opt_spdc; ?>" <?php checked($all[self::$opt_spdc], 1); ?> type="checkbox" class="checkbox">
2206 - <label for="<?php echo self::$opt_spdc; ?>">
2207 - <b>(PRO)</b> <b class="chktitle">Faster Page Loads (Caching): <sup class="orange">NEW</sup></b>
2208 - Use embed caching to speed up your page loads. By default, WordPress needs to request information from YouTube.com's servers for every video you embed, every time a page is loaded. These data requests can add time to your total page load time. Turn on this feature to cache that data (instead of having to request for the same information every time you load a page). This should then make your pages that have videos load faster. It's been noted that even small speed ups in page load can help increase visitor engagement, retention, and conversions.
2209 - </label>
2210 - <div class="indent-option">
2211 - <div id="boxspdc">
2212 - <label>
2213 - <b class="chktitle">Cache Liftime (hours): <sup class="orange">NEW</sup></b>
2214 - <input name="<?php echo self::$opt_spdcexp; ?>" id="<?php echo self::$opt_spdcexp; ?>" value="<?php echo trim($all[self::$opt_spdcexp]); ?>" type="number" min="1"/>
2215 - </label>
2216 - Tip: If your pages rarely change, you may wish to set this to a much higher value than 24 hours.
2217 -
2218 - <div class="pad20">
2219 - <input type="button" class="button button-primary" value="Click to clear YouTube cache"/>
2220 - <span style="display: none;" id="clearspdcloading" class="orange bold">Clearing...</span>
2221 - <span class="orange bold" style="display: none;" id="clearspdcsuccess">Finished clearing YouTube cache.</span>
2222 - <span class="orange bold" style="display: none;" id="clearspdcfailed">Sorry, there seemed to be a problem clearing the cache.</span>
2223 - </div>
2224 - </div>
2225 - </div>
2226 - </p>
2227 - <div class="hr"></div>
2228 - <p>
2229 - <input name="<?php echo self::$opt_schemaorg; ?>" id="<?php echo self::$opt_schemaorg; ?>" <?php checked($all[self::$opt_schemaorg], 1); ?> type="checkbox" class="checkbox">
2230 - <label for="<?php echo self::$opt_schemaorg; ?>">
2231 - <b>(PRO)</b> <b class="chktitle">Video SEO Tags:</b> Update your YouTube embeds with Google, Bing, and Yahoo friendly video SEO markup.
2232 - </label>
2233 - <span id="boxschemaorg">
2234 - <span class="apikey-msg">
2235 - The video SEO tags include data like the title, description, and thumbnail information of each video you embed. This plugin automatically extracts this data directly from YouTube using the version 3 API,
2236 - which will soon replace the version 2 API. This particular API version requires that you obtain an API key so that YouTube can authenticate the requests. Don't worry, it's an easy process.
2237 - Just <a href="https://developers.google.com/youtube/registering_an_application" target="_blank">click this link &raquo;</a> and follow the video to the right to get your API key. Then paste it in the box below, and click the "Save Changes" button:
2238 - <br>
2239 - <span style="vertical-align: middle; display: inline-block;">
2240 - YouTube API Key: <input type="text" name="<?php echo self::$opt_apikey; ?>" id="<?php echo self::$opt_apikey; ?>" value="<?php echo trim($all[self::$opt_apikey]); ?>" class="textinput" style="width: 200px;">
2241 - </span>
2242 - </span>
2243 - <span class="apikey-video">
2244 - <iframe width="384" height="216" src="https://www.youtube.com/embed/2vmBACVETf4?rel=0" frameborder="0" allowfullscreen></iframe>
2245 - </span>
2246 - </span>
2247 - </p>
2248 - <div class="hr"></div>
2249 - <p>
2250 - <input name="<?php echo self::$opt_dynload; ?>" id="<?php echo self::$opt_dynload; ?>" <?php checked($all[self::$opt_dynload], 1); ?> type="checkbox" class="checkbox">
2251 - <span id="boxdyn">
2252 - Animation:
2253 - <?php $cleandyn = trim($all[self::$opt_dyntype]); ?>
2254 - <select name="<?php echo self::$opt_dyntype; ?>" id="<?php echo self::$opt_dyntype; ?>" >
2255 - <option value="">Select type</option>
2256 - <option value="rotateIn" <?php echo 'rotateIn' === $cleandyn ? 'selected' : '' ?> >rotate in</option>
2257 - <option value="slideInRight" <?php echo 'slideInRight' === $cleandyn ? 'selected' : '' ?> >slide from right</option>
2258 - <option value="slideInLeft" <?php echo 'slideInLeft' === $cleandyn ? 'selected' : '' ?> >slide from left</option>
2259 - <option value="bounceIn" <?php echo 'bounceIn' === $cleandyn ? 'selected' : '' ?> >bounce in</option>
2260 - <option value="flipInX" <?php echo 'flipInX' === $cleandyn ? 'selected' : '' ?> >flip up/down</option>
2261 - <option value="flipInY" <?php echo 'flipInY' === $cleandyn ? 'selected' : '' ?> >flip left/right</option>
2262 - <option value="pulse" <?php echo 'pulse' === $cleandyn ? 'selected' : '' ?> >pulse</option>
2263 - <option value="tada" <?php echo 'tada' === $cleandyn ? 'selected' : '' ?> >jiggle</option>
2264 - <option value="fadeInDown" <?php echo 'fadeInDown' === $cleandyn ? 'selected' : '' ?> >fade in downward</option>
2265 - <option value="fadeInUp" <?php echo 'fadeInUp' === $cleandyn ? 'selected' : '' ?> >fade in upward</option>
2266 - <option value="zoomInDown" <?php echo 'zoomInDown' === $cleandyn ? 'selected' : '' ?> >zoom in downward</option>
2267 - <option value="zoomInUp" <?php echo 'zoomInUp' === $cleandyn ? 'selected' : '' ?> >zoom in upward</option>
2268 - </select>
2269 - </span>
2270 - <label for="<?php echo self::$opt_dynload; ?>">
2271 - <b>(PRO)</b> <b class="chktitle">Special Loading Effects:</b>
2272 - Add eye-catching special effects that will make your YouTube embeds bounce, flip, pulse, or slide as they load on the screen. Check this box to select your desired effect. <a target="_blank" href="<?php echo self::$epbase ?>/add-special-effects-to-youtube-embeds-in-wordpress.aspx">Read more here &raquo;</a>
2273 - </label>
2274 - </p>
2275 - <div class="hr"></div>
2276 - <p>
2277 - <img class="ssfb" src="<?php echo plugins_url('images/ssfb.jpg', __FILE__) ?>" />
2278 - <input name="<?php echo self::$opt_ogvideo; ?>" id="<?php echo self::$opt_ogvideo; ?>" <?php checked($all[self::$opt_ogvideo], 1); ?> type="checkbox" class="checkbox">
2279 - <label for="<?php echo self::$opt_ogvideo; ?>">
2280 - <b>(PRO)</b> <b class="chktitle">Facebook Open Graph Markup:</b> Update YouTube embeds on your pages with Open Graph markup to enhance Facebook sharing and discovery of the pages. Your shared pages, for example, will also display embedded video thumbnails on Facebook Timelines.
2281 - </label>
2282 - </p>
2283 - <div class="hr"></div>
2284 - <p>
2285 - <img class="ssfb" src="<?php echo plugins_url('images/youtube_thumbnail_sample.jpg', __FILE__) ?>" />
2286 - <input name="<?php echo self::$opt_ftpostimg; ?>" id="<?php echo self::$opt_ftpostimg; ?>" <?php checked($all[self::$opt_ftpostimg], 1); ?> type="checkbox" class="checkbox">
2287 - <label for="<?php echo self::$opt_ftpostimg; ?>">
2288 - <b>(PRO)</b> <b class="chktitle">Automatic Video Thumbnails: <sup class="orange">NEW</sup></b>
2289 - Automatically grab the thumbnail image of the first video embedded in each post or page, and use it as the featured image. If your theme can display featured images of posts on your blog home, you’ll see the thumbnails there as shown in the picture on the right. All you have to do is click Update on a post or page and the plugin does the rest!
2290 - (Example shown on the right) <a target="_blank" href="<?php echo self::$epbase ?>/add-youtube-video-thumbnails-featured-image-wordpress.aspx">Watch example here &raquo;</a>
2291 - </label>
2292 - </p>
2293 -
2294 - <?php
2295 - }
2296 - else
2297 - {
2298 - ?>
2299 - <p class="smallnote orange">Below are PRO features for enhanced SEO and performance (works for even past embed links). </p>
2300 - <p>
2301 - <input disabled type="checkbox" class="checkbox">
2302 - <label>
2303 - <b class="chktitle">Faster Page Loads (Caching): <sup class="orange">NEW</sup></b> <span class="pronon">(PRO Users)</span>
2304 - Use embed caching to speed up your page loads. By default, WordPress needs to request information from YouTube.com's servers for every video you embed, every time a page is loaded. These data requests can add time to your total page load time. Turn on this feature to cache that data (instead of having to request for the same information every time you load a page). This should then make your pages that have videos load faster. It's been noted that even small speed ups in page load can help increase visitor engagement, retention, and conversions.
2305 - </label>
2306 - <div class="indent-option">
2307 - <label>
2308 - <b class="chktitle">Cache Liftime (hours): <sup class="orange">NEW</sup></b>
2309 - <input id="spdcexp" disabled value="24" type="number">
2310 - Tip: If your pages rarely change, you may wish to set this to a much higher value than 24 hours.
2311 - </label>
2312 - </div>
2313 - </p>
2314 - <div class="hr"></div>
2315 -
2316 - <p>
2317 - <input disabled type="checkbox" class="checkbox">
2318 - <label>
2319 - <b class="chktitle">Video SEO Tags:</b> <span class="pronon">(PRO Users)</span> Update your YouTube embeds with Google, Bing, and Yahoo friendly video SEO markup.
2320 - </label>
2321 - </p>
2322 - <div class="hr"></div>
2323 - <p>
2324 - <input disabled type="checkbox" class="checkbox">
2325 - <label>
2326 - <b class="chktitle">Special Loading Effects:</b> <span class="pronon">(PRO Users)</span>
2327 - Add eye-catching special effects that will make your YouTube embeds bounce, flip, pulse, or slide as they load on the screen. Check this box to select your desired effect. <a target="_blank" href="<?php echo self::$epbase ?>/add-special-effects-to-youtube-embeds-in-wordpress.aspx">Read more here &raquo;</a>
2328 - </label>
2329 - </p>
2330 - <div class="hr"></div>
2331 - <p>
2332 - <img class="ssfb" src="<?php echo plugins_url('images/ssfb.jpg', __FILE__) ?>" />
2333 - <input disabled type="checkbox" class="checkbox">
2334 - <label>
2335 - <b class="chktitle">Facebook Open Graph Markup:</b> <span class="pronon">(PRO Users)</span> Update YouTube embeds on your pages with Open Graph markup to enhance Facebook sharing and discovery of the pages. Your shared pages, for example, will also display embedded video thumbnails on Facebook Timelines.
2336 - </label>
2337 - </p>
2338 - <div class="hr"></div>
2339 - <p>
2340 - <img class="ssfb" src="<?php echo plugins_url('images/youtube_thumbnail_sample.jpg', __FILE__) ?>" />
2341 - <input disabled type="checkbox" class="checkbox">
2342 - <label>
2343 - <b class="chktitle">Automatic Video Thumbnails: <sup class="orange">NEW</sup></b> <span class="pronon">(PRO Users)</span>
2344 - Automatically grab the thumbnail image of the first video embedded in each post or page, and use it as the featured image.
2345 - All you have to do is click Update on a post or page and the plugin does the rest!
2346 - (Example shown on the right) <a target="_blank" href="<?php echo self::$epbase ?>/add-youtube-video-thumbnails-featured-image-wordpress.aspx">Read more here &raquo;</a>
2347 - </label>
2348 - </p>
2349 - <div class="hr"></div>
2350 - <p>
2351 - <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" target="_blank">Activate the above and several other features &raquo;</a>
2352 - </p>
2353 - <?php
2354 - }
2355 - ?>
2356 - <div class="clearboth"></div>
2357 - </div>
2358 - <p class="submit">
2359 - <br>
2360 - <input type="submit" onclick="return savevalidate();" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
2361 - <em>If you're using a separate caching plugin and you do not see your changes after saving, you might want to reset your cache.</em>
2362 - </p>
2363 -
2364 - <hr>
2365 -
2366 - </div>
2367 - <div class="jumper" id="jumpoverride"></div>
2368 -
2369 - <h3 class="sect">
2370 - <?php _e("How To Override Defaults / Other Options") ?> <a href="#top" class="totop">&#9650; top</a>
2371 - </h3>
2372 - <p>Suppose you have a few videos that need to be different from the above defaults. You can add options to the end of a link as displayed below to override the above defaults. Each option should begin with '&'.
2373 - <br><span class="smallnote orange">PRO users: You can use the <a href="<?php echo self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=protab' ?>" target="_blank" class="button-primary cuz">&#9658; Customize</a> button that you will see inside the wizard, instead of memorizing the following.</span>
2374 - <?php
2375 - _e('<ul>');
2376 - _e("<li><strong>width</strong> - Sets the width of your player. If omitted, the default width will be the width of your theme's content.<em> Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&width=500</strong>&height=350</em></li>");
2377 - _e("<li><strong>height</strong> - Sets the height of your player. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA&width=500<strong>&height=350</strong></em> </li>");
2378 - _e("<li><strong>autoplay</strong> - Set this to 1 to autoplay the video (or 0 to play the video once). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&autoplay=1</strong></em> </li>");
2379 - _e("<li><strong>cc_load_policy</strong> - Set this to 1 to turn on closed captioning (or 0 to leave them off). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&cc_load_policy=1</strong></em> </li>");
2380 - _e("<li><strong>iv_load_policy</strong> - Set this to 3 to turn off annotations (or 1 to show them). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&iv_load_policy=3</strong></em> </li>");
2381 - _e("<li><strong>loop</strong> - Set this to 1 to loop the video (or 0 to not loop). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&loop=1</strong></em> </li>");
2382 - _e("<li><strong>modestbranding</strong> - Set this to 1 to remove the YouTube logo while playing (or 0 to show the logo). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&modestbranding=1</strong></em> </li>");
2383 - _e("<li><strong>rel</strong> - Set this to 0 to not show related videos at the end of playing (or 1 to show them). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&rel=0</strong></em> </li>");
2384 - _e("<li><strong>showinfo</strong> - Set this to 0 to hide the video title and other info (or 1 to show it). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&showinfo=0</strong></em> </li>");
2385 - _e("<li><strong>theme</strong> - Set this to 'light' to make the player have the light-colored theme (or 'dark' for the dark theme). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&theme=light</strong></em> </li>");
2386 - _e("<li><strong>color</strong> - Set this to 'white' to make the player have a white progress bar (or 'red' for a red progress bar). Note: Using white will disable the modestbranding option. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&color=white</strong></em> </li>");
2387 - _e("<li><strong>vq</strong> - Set this to 'hd720' or 'hd1080' to force the video to have HD quality. Leave blank to let YouTube decide. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&vq=hd720</strong></em> </li>");
2388 - _e("<li><strong>controls</strong> - Set this to 0 to completely hide the video controls (or 2 to show it). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&controls=0</strong></em> </li>");
2389 - _e("<li><strong>autohide</strong> - Set this to 1 to slide away the control bar after the video starts playing. It will automatically slide back in again if you mouse over the video. (Set to 2 to always show it). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&autohide=1</strong></em> </li>");
2390 - _e("<li><strong>playsinline</strong> - Set this to 1 to allow videos play inline with the page on iOS browsers. (Set to 0 to have iOS launch videos in fullscreen instead). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&playsinline=1</strong></em> </li>");
2391 - _e("<li><strong>origin</strong> - Set this to 1 to add the 'origin' parameter for extra JavaScript security. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&origin=1</strong></em> </li>");
2392 - _e('</ul>');
2393 -
2394 - _e("<p>You can also start and end each individual video at particular times. Like the above, each option should begin with '&'</p>");
2395 - _e('<ul>');
2396 - _e("<li><strong>start</strong> - Sets the time (in seconds) to start the video. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350<strong>&start=20</strong></em> </li>");
2397 - _e("<li><strong>end</strong> - Sets the time (in seconds) to stop the video. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350<strong>&end=100</strong></em> </li>");
2398 - _e('</ul>');
2399 - ?>
2400 -
2401 - </form>
2402 - <div class="jumper" id="jumppro"></div>
2403 - <div id="goprobox">
2404 - <?php
2405 - if ($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0)
2406 - {
2407 - echo "<h3>" . __('Thank you for going PRO.');
2408 - echo ' &nbsp;<input type="submit" name="showkey" class="button-primary" style="vertical-align: 15%;" id="showprokey" value="View my PRO key" />';
2409 - echo "</h3>";
2410 - ?>
2411 - <?php
2412 - }
2413 - else
2414 - {
2415 - ?>
2416 -
2417 - <h3 class="sect">
2418 - <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" class="button-primary" target="_blank">Want to go PRO? (Low Prices) &raquo;</a> &nbsp;
2419 - PRO users help keep new features coming and our coffee cups filled. Go PRO and get these perks in return:
2420 - </h3>
2421 - <div class="procol">
2422 - <ul class="gopro">
2423 - <li>
2424 - <img src="<?php echo plugins_url('images/iconcache.png', __FILE__) ?>">
2425 - Faster Page Loads (Caching)
2426 - </li>
2427 - <li>
2428 - <img src="<?php echo plugins_url('images/iconwizard.png', __FILE__) ?>">
2429 - Full Visual Embedding Wizard (Easily customize embeds without memorizing codes)
2430 - </li>
2431 - <li>
2432 - <img src="<?php echo plugins_url('images/vseo.png', __FILE__) ?>">
2433 - Automatic tagging for video SEO (will even work for your old embeds)
2434 - </li>
2435 - <li>
2436 - <img src="<?php echo plugins_url('images/iconfx.png', __FILE__) ?>">
2437 - Add eye-catching special effects as your videos load
2438 - </li>
2439 - <li>
2440 - <img src="<?php echo plugins_url('images/deletechecker.png', __FILE__) ?>">
2441 - Deleted Video Checker (alerts you if YouTube deletes videos you embedded)
2442 - </li>
2443 - <li>
2444 - <img src="<?php echo plugins_url('images/globe.png', __FILE__) ?>">
2445 - Alerts when visitors from different countries are blocked from viewing your embeds
2446 - </li>
2447 - <li>
2448 - <img src="<?php echo plugins_url('images/mobilecompat.png', __FILE__) ?>">
2449 - Check if your embeds have restrictions that can block mobile viewing
2450 - </li>
2451 -
2452 - </ul>
2453 - </div>
2454 - <div class="procol" style="max-width: 465px;">
2455 - <ul class="gopro">
2456 - <li>
2457 - <img src="<?php echo plugins_url('images/videothumbs.png', __FILE__) ?>">
2458 - Automatic video thumbnail images (just click 'Update') <sup class="orange bold">NEW</sup>
2459 - </li>
2460 - <li>
2461 - <img src="<?php echo plugins_url('images/prioritysupport.png', __FILE__) ?>">
2462 - Priority support (Puts your request in front)
2463 - </li>
2464 - <li>
2465 - <img src="<?php echo plugins_url('images/bulletgraph45.png', __FILE__) ?>">
2466 - User-friendly video analytics dashboard
2467 - </li>
2468 -
2469 - <li id="fbstuff">
2470 - <img src="<?php echo plugins_url('images/iconfb.png', __FILE__) ?>">
2471 - Automatic Open Graph tagging for Facebook
2472 - </li>
2473 - <li>
2474 - <img src="<?php echo plugins_url('images/iconythealth.png', __FILE__) ?>">
2475 - Instant YouTube embed diagnostic reports
2476 - </li>
2477 - <li>
2478 - <img src="<?php echo plugins_url('images/iconvolume.png', __FILE__) ?>">
2479 - Fine-Grained Volume Initialization – Individual video volume settings in the wizard
2480 - </li>
2481 -
2482 - <li>
2483 - <img src="<?php echo plugins_url('images/infinity.png', __FILE__) ?>">
2484 - Unlimited PRO upgrades and downloads
2485 - </li>
2486 - <!-- <li>
2487 - <img src="<?php echo plugins_url('images/questionsale.png', __FILE__) ?>">
2488 - What else? You tell us!
2489 - </li> -->
2490 - </ul>
2491 - </div>
2492 - <div style="clear: both;"></div>
2493 - <br>
2494 - <h3 class="bold">Enter and save your PRO key (emailed to you):</h3>
2495 - <?php } ?>
2496 - <form name="form2" method="post" action="" id="epform2" class="submitpro" <?php
2497 - if ($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0)
2498 - {
2499 - echo 'style="display: none;"';
2500 - }
2501 - ?>>
2502 -
2503 - <input name="<?php echo self::$opt_pro; ?>" id="opt_pro" value="<?php echo $all[self::$opt_pro]; ?>" type="text">
2504 - <input type="submit" name="Submit" class="button-primary" id="prokeysubmit" value="<?php _e('Save Key') ?>" />
2505 - <?php
2506 - if (!($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0))
2507 - {
2508 - ?>
2509 - &nbsp; &nbsp; &nbsp; <span style="font-size: 25px; color: #cccccc;">|</span> &nbsp; &nbsp; &nbsp; <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" class="button-primary brightpro" target="_blank">Click here to go PRO &raquo;</a>
2510 - <?php
2511 - }
2512 - ?>
2513 - <br>
2514 - <span style="display: none;" id="prokeyloading" class="orange bold">Verifying...</span>
2515 - <span class="orange bold" style="display: none;" id="prokeysuccess">Success! Please refresh this page.</span>
2516 - <span class="orange bold" style="display: none;" id="prokeyfailed">Sorry, that seems to be an invalid key, or it has been used already.</span>
2517 -
2518 - </form>
2519 -
2520 - </div>
2521 - <div class="smallnote">
2522 - <!--&nbsp; *Upcoming: We've started developing a feature that will recommend YouTube embeds that you might want to include in a post while you're actually<br>
2523 - writing/editing. It will apply some experimental artificial intelligence techniques on your post content for these recommendations, all at the click of a button.
2524 - -->
2525 - </div>
2526 - <div class="jumper" id="jumpsupport"></div>
2527 - <div id="nonprosupport">
2528 - <h3 class="bold">Support tips for all users (Free and PRO)</h3>
2529 - We've found that a common support request has been from users that are pasting video links on single lines, as required, but are not seeing the video embed show up. One of these suggestions is usually the fix:
2530 - <ul class="reglist">
2531 - <li>Make sure the URL is really on its own line by itself. Or, if you need multiple videos on the same line, make sure each URL is wrapped properly with the shortcode (Example: <code>[embedyt]http://www.youtube.com/watch?v=ABCDEFGHIJK&width=400&height=250[/embedyt]</code>)</li>
2532 - <li>Make sure the URL is not an active hyperlink (i.e., it should just be plain text). Otherwise, highlight the URL and click the "unlink" button in your editor: <img src="<?php echo plugins_url('images/unlink.png', __FILE__) ?>"/>.</li>
2533 - <li>Make sure you did <strong>not</strong> format or align the URL in any way. If your URL still appears in your actual post instead of a video, highlight it and click the "remove formatting" button (formatting can be invisible sometimes): <img src="<?php echo plugins_url('images/erase.png', __FILE__) ?>"/></li>
2534 - <li>Try wrapping the URL with the <code>[embedyt]...[/embedyt]</code> shortcode. For example: <code>[embedyt]http://www.youtube.com/watch?v=ABCDEFGHIJK[/embedyt]</code> Using the shortcode also allows you to have two or more videos next to each other on the same line. Just put the shortcoded links together on the same line. For example:<br>
2535 - <code>[embedyt]http://www.youtube.com/watch?v=ABCDEF&width=400&height=250[/embedyt] [embedyt]http://www.youtube.com/watch?v=GHIJK&width=400&height=250[/embedyt]</code>
2536 - <br> TIP: As shown above, decrease the size of each video so that they fit together on the same line (See the "How To Override Defaults" section for height and width instructions)
2537 - </li>
2538 - <li>Finally, there's a slight chance your custom theme is the issue, if you have one. To know for sure, we suggest temporarily switching to one of the default WordPress themes (e.g., "Twenty Fourteen") just to see if your video does appear. If it suddenly works, then your custom theme is the issue. You can switch back when done testing.</li>
2539 - <li>If your videos always appear full size, try turning off "Responsive video sizing."</li>
2540 - <li>If none of the above work, you can contact us here if you still have issues: ext@embedplus.com. We'll try to respond within a week. PRO users should use the priority form below for faster replies.</li>
2541 - </ul>
2542 - <p>
2543 - Deactivating the No Cookies option has also been proven to solve player errors.
2544 - </p>
2545 - <p>
2546 - We also have a YouTube channel. We use it to provide users with some helper videos and a way to keep updated on new features as they are introduced. <a href="https://www.youtube.com/subscription_center?add_user=EmbedPlus" target="_blank">Subscribe for tips and updates here &raquo;</a>
2547 - </p>
2548 - </div>
2549 - <br>
2550 - <h3 class="sect">
2551 - Priority Support <span class="pronon">(<a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" target="_blank">PRO Users &raquo;</a>)</span><a href="#top" class="totop">&#9650; top</a>
2552 - </h3>
2553 - <p>
2554 - <strong>PRO users:</strong> Below, We've enabled the ability to have priority support with our team. Use this to get one-on-one help with any issues you might have or to send us suggestions for future features. We typically respond within minutes during normal work hours. We're always happy to accept any testimonials you might have as well.
2555 - </p>
2556 -
2557 -
2558 - <iframe src="<?php echo self::$epbase ?>/dashboard/prosupport.aspx?simple=1&prokey=<?php echo $all[self::$opt_pro]; ?>&domain=<?php echo site_url(); ?>" width="500" height="<?php echo ($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0) ? "500" : "140"; ?>"></iframe>
2559 -
2560 - <?php
2561 - if (!($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0))
2562 - {
2563 - ?>
2564 - <br>
2565 - <br>
2566 - <iframe src="<?php echo self::$epbase ?>/dashboard/likecoupon.aspx" width="600" height="500"></iframe>
2567 - <?php }
2568 - ?>
2569 - <div class="ytnav">
2570 - <a href="#jumphowto">How To Embed</a>
2571 - <a href="#jumpwiz">Visual YouTube Wizard</a>
2572 - <a href="#jumpdefaults">Set Defaults</a>
2573 - <a href="#jumpoverride">How To Override Defaults</a>
2574 - <a target="_blank" href="<?php echo self::$epbase . "/dashboard/pro-easy-video-analytics.aspx?ref=protab" ?>" style="border-color: #888888;">Why Upgrade?</a>
2575 - <a href="#jumpsupport">Support</a>
2576 - </div>
2577 -
2578 -
2579 - <script type="text/javascript">
2580 -
2581 - function savevalidate()
2582 - {
2583 - var valid = true;
2584 - var alertmessage = '';
2585 - if (jQuery("#<?php echo self::$opt_defaultdims; ?>").is(":checked"))
2586 - {
2587 - if (!(jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_defaultwidth; ?>").val())) &&
2588 - jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_defaultheight; ?>").val()))))
2589 - {
2590 - alertmessage += "Please enter valid numbers for default height and width, or uncheck the option.";
2591 - jQuery("#boxdefaultdims input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
2592 - valid = false;
2593 - }
2594 - }
2595 -
2596 - if (jQuery("#<?php echo self::$opt_defaultvol; ?>").is(":checked"))
2597 - {
2598 - if (!(jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_vol; ?>").val()))))
2599 - {
2600 - alertmessage += "Please enter a number between 0 and 100 for the default volume, or uncheck the option.";
2601 - jQuery("#boxdefaultvol input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
2602 - valid = false;
2603 - }
2604 - }
2605 -
2606 - if (jQuery("#<?php echo self::$opt_spdc; ?>").is(":checked"))
2607 - {
2608 - if (!(jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_spdcexp; ?>").val()))))
2609 - {
2610 - alertmessage += "Please enter a valid number of hours (greater than 0) for the cache lifetime, or uncheck the option.";
2611 - jQuery("#boxspdc input[type=number], #boxspdc input[type=text]").css("background-color", "#ffcccc").css("border", "2px solid #000000");
2612 - valid = false;
2613 - }
2614 - }
2615 -
2616 -
2617 -
2618 - if (jQuery("#<?php echo self::$opt_schemaorg; ?>").is(":checked"))
2619 - {
2620 - if (!(jQuery.trim(jQuery("#<?php echo self::$opt_apikey; ?>").val()).length > 0))
2621 - {
2622 - alertmessage += "Please enter a valid YouTube API key, or uncheck the 'Video SEO Tags' option.";
2623 - jQuery("#boxschemaorg input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
2624 - valid = false;
2625 - }
2626 - }
2627 -
2628 -
2629 -
2630 - if (jQuery("#<?php echo self::$opt_dynload; ?>").is(":checked"))
2631 - {
2632 - if (!(/^[A-Za-z-]+$/.test(jQuery.trim(jQuery("#<?php echo self::$opt_dyntype; ?>").val()))))
2633 - {
2634 - alertmessage += "Please select an animation, or uncheck the option.";
2635 - jQuery("#boxdyn select").css("background-color", "#ffcccc").css("border", "2px solid #000000");
2636 - valid = false;
2637 - }
2638 - }
2639 -
2640 -
2641 -
2642 -
2643 - // if (jQuery("#<?php echo self::$opt_dohl; ?>").is(":checked"))
2644 - // {
2645 - // if (!(/^[A-Za-z][A-Za-z]$/.test(jQuery.trim(jQuery("#<?php echo self::$opt_hl; ?>").val()))))
2646 - // {
2647 - // alertmessage += "Please enter a valid 2-letter language code.";
2648 - // jQuery("#boxdohl input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
2649 - // valid = false;
2650 - // }
2651 - // }
2652 -
2653 - if (!valid)
2654 - {
2655 - alert(alertmessage);
2656 - }
2657 - return valid;
2658 - }
2659 -
2660 - var prokeyval;
2661 - var mydomain = escape("http://" + window.location.host.toString());
2662 -
2663 - jQuery(document).ready(function($) {
2664 - jQuery('#<?php echo self::$opt_defaultdims; ?>').change(function()
2665 - {
2666 - if (jQuery(this).is(":checked"))
2667 - {
2668 - jQuery("#boxdefaultdims").show(500);
2669 - }
2670 - else
2671 - {
2672 - jQuery("#boxdefaultdims").hide(500);
2673 - }
2674 -
2675 - });
2676 -
2677 - jQuery('#<?php echo self::$opt_dynload; ?>').change(function()
2678 - {
2679 - if (jQuery(this).is(":checked"))
2680 - {
2681 - jQuery("#boxdyn").show(500);
2682 - }
2683 - else
2684 - {
2685 - jQuery("#boxdyn").hide(500);
2686 - }
2687 -
2688 - });
2689 -
2690 - jQuery('#<?php echo self::$opt_spdc; ?>').change(function()
2691 - {
2692 - if (jQuery(this).is(":checked"))
2693 - {
2694 - jQuery("#boxspdc").show(500);
2695 - }
2696 - else
2697 - {
2698 - jQuery("#boxspdc").hide(500);
2699 - }
2700 - });
2701 -
2702 -
2703 - jQuery('#<?php echo self::$opt_migrate; ?>').change(function()
2704 - {
2705 - if (jQuery(this).is(":checked"))
2706 - {
2707 - jQuery("#boxmigratelist").show(500);
2708 - }
2709 - else
2710 - {
2711 - jQuery("#boxmigratelist").hide(500);
2712 - }
2713 - });
2714 -
2715 -
2716 -
2717 - jQuery('#<?php echo self::$opt_nocookie; ?>').change(function()
2718 - {
2719 - if (jQuery(this).is(":checked"))
2720 - {
2721 - jQuery("#boxnocookie").show(500);
2722 - }
2723 - else
2724 - {
2725 - jQuery("#boxnocookie").hide(500);
2726 - }
2727 -
2728 - });
2729 -
2730 - jQuery('#<?php echo self::$opt_schemaorg; ?>').change(function()
2731 - {
2732 - if (jQuery(this).is(":checked"))
2733 - {
2734 - jQuery("#boxschemaorg").show(500);
2735 - }
2736 - else
2737 - {
2738 - jQuery("#boxschemaorg").hide(500);
2739 - }
2740 - });
2741 -
2742 -
2743 - // jQuery('#<?php echo self::$opt_dohl; ?>').change(function()
2744 - // {
2745 - // if (jQuery(this).is(":checked"))
2746 - // {
2747 - // jQuery("#boxdohl").show(500);
2748 - // }
2749 - // else
2750 - // {
2751 - // jQuery("#boxdohl").hide(500);
2752 - // }
2753 - //
2754 - // });
2755 -
2756 -
2757 -
2758 - jQuery('#<?php echo self::$opt_defaultvol; ?>').change(function()
2759 - {
2760 - if (jQuery(this).is(":checked"))
2761 - {
2762 - jQuery("#boxdefaultvol").show(500);
2763 - }
2764 - else
2765 - {
2766 - jQuery("#boxdefaultvol").hide(500);
2767 - }
2768 -
2769 - });
2770 -
2771 - var rangedetect = document.createElement("input");
2772 - rangedetect.setAttribute("type", "range");
2773 - var canrange = rangedetect.type !== "text";
2774 - //canrange = false;
2775 - if (canrange)
2776 - {
2777 - $("input#vol").prop("type", "range").addClass("vol-range").on("input change", function() {
2778 - $('.vol-output').text($(this).val() > 0 ? $(this).val() + '%' : 'Mute');
2779 - });
2780 - $('.vol-output').css("display", "inline-block").text($("input#vol").val() > 0 ? $("input#vol").val() + '%' : 'Mute');
2781 - $('.vol-seeslider').show();
2782 - $('.vol-seetextbox').hide();
2783 - }
2784 - else
2785 - {
2786 - $("input#vol").width(40);
2787 - }
2788 -
2789 -
2790 - jQuery('#boxspdc input.button').click(function() {
2791 - jQuery('#clearspdcloading').show();
2792 - jQuery('#clearspdcfailed').hide();
2793 - jQuery('#clearspdcsuccess').hide();
2794 -
2795 - $clearbutton = jQuery(this);
2796 - $clearbutton.attr('disabled', 'disabled');
2797 -
2798 - jQuery.ajax({
2799 - type: "post",
2800 - dataType: "json",
2801 - timeout: 30000,
2802 - url: wpajaxurl,
2803 - data: {action: 'my_embedplus_clearspdc'},
2804 - success: function(response) {
2805 - if (response.type == "success") {
2806 - jQuery("#clearspdcsuccess").show();
2807 - }
2808 - else {
2809 - jQuery("#clearspdcfailed").show();
2810 - }
2811 - },
2812 - error: function(xhr, ajaxOptions, thrownError) {
2813 - jQuery("#clearspdcfailed").show();
2814 - },
2815 - complete: function() {
2816 - jQuery('#clearspdcloading').hide();
2817 - $clearbutton.removeAttr('disabled');
2818 - }
2819 -
2820 - });
2821 -
2822 - });
2823 -
2824 -
2825 -
2826 -
2827 - jQuery("#showcase-validate").click(function() {
2828 - window.open("<?php echo self::$epbase . "/showcase-validate.aspx?prokey=" . self::$alloptions[self::$opt_pro] ?>" + "&domain=" + mydomain);
2829 - });
2830 -
2831 - jQuery('#showprokey').click(function() {
2832 - jQuery('.submitpro').show(500);
2833 - return false;
2834 - });
2835 -
2836 - jQuery('#prokeysubmit').click(function() {
2837 - jQuery(this).attr('disabled', 'disabled');
2838 - jQuery('#prokeyfailed').hide();
2839 - jQuery('#prokeysuccess').hide();
2840 - jQuery('#prokeyloading').show();
2841 - prokeyval = jQuery('#opt_pro').val();
2842 -
2843 - var tempscript = document.createElement("script");
2844 - tempscript.src = "//www.embedplus.com/dashboard/wordpress-pro-validatejp.aspx?simple=1&prokey=" + prokeyval + "&domain=" + mydomain;
2845 - var n = document.getElementsByTagName("head")[0].appendChild(tempscript);
2846 - setTimeout(function() {
2847 - n.parentNode.removeChild(n);
2848 - }, 500);
2849 - return false;
2850 - });
2851 -
2852 - window.embedplus_record_prokey = function(good) {
2853 -
2854 - jQuery.ajax({
2855 - type: "post",
2856 - dataType: "json",
2857 - timeout: 30000,
2858 - url: wpajaxurl,
2859 - data: {action: 'my_embedplus_pro_record', <?php echo self::$opt_pro; ?>: (good ? prokeyval : "")},
2860 - success: function(response) {
2861 - if (response.type == "success") {
2862 - jQuery("#prokeysuccess").show();
2863 - }
2864 - else {
2865 - jQuery("#prokeyfailed").show();
2866 - }
2867 - },
2868 - error: function(xhr, ajaxOptions, thrownError) {
2869 - jQuery('#prokeyfailed').show();
2870 - },
2871 - complete: function() {
2872 - jQuery('#prokeyloading').hide();
2873 - jQuery('#prokeysubmit').removeAttr('disabled');
2874 - }
2875 -
2876 - });
2877 -
2878 - };
2879 -
2880 - });
2881 - </script>
2882 - <?php
2883 - if (function_exists('add_thickbox'))
2884 - {
2885 - add_thickbox();
2886 - }
2887 - ?>
2888 -
2889 - <?php
2890 - }
2891 -
2892 - public static function ytprefsscript()
2893 - {
2894 - wp_enqueue_script('__ytprefs__', plugins_url('scripts/ytprefs.min.js', __FILE__));
2895 -
2896 -
2897 - if (!is_admin() && (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0) && self::$alloptions[self::$opt_dynload] == 1)
2898 - {
2899 - wp_enqueue_style('__dyntype__', plugins_url('scripts/embdyn.min.css', __FILE__));
2900 - wp_enqueue_script('__dynload__', plugins_url('scripts/embdyn.min.js', __FILE__), array('jquery'), false, false, true);
2901 - }
2902 - }
2903 -
2904 - public static function get_blogwidth()
2905 - {
2906 - $blogwidth = null;
2907 - try
2908 - {
2909 - $embed_size_w = intval(get_option('embed_size_w'));
2910 -
2911 - global $content_width;
2912 - if (empty($content_width))
2913 - {
2914 - $content_width = $GLOBALS['content_width'];
2915 - }
2916 -
2917 - $blogwidth = $embed_size_w ? $embed_size_w : ($content_width ? $content_width : 450);
2918 - }
2919 - catch (Exception $ex)
2920 - {
2921 -
2922 - }
2923 -
2924 - $blogwidth = preg_replace('/\D/', '', $blogwidth); //may have px
2925 -
2926 - return $blogwidth;
2927 - }
2928 -
2929 - }
2930 -
2931 -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2932 -//class start
2933 - class Add_new_tinymce_btn_Youtubeprefs
2934 - {
2935 -
2936 - public $btn_arr;
2937 - public $js_file;
2938 -
2939 - /*
2940 - * call the constructor and set class variables
2941 - * From the constructor call the functions via wordpress action/filter
2942 - */
2943 -
2944 - function __construct($seperator, $btn_name, $javascrip_location)
2945 - {
2946 - $this->btn_arr = array("Seperator" => $seperator, "Name" => $btn_name);
2947 - $this->js_file = $javascrip_location;
2948 - add_action('init', array($this, 'add_tinymce_button'));
2949 - add_filter('tiny_mce_version', array($this, 'refresh_mce_version'));
2950 - }
2951 -
2952 - /*
2953 - * create the buttons only if the user has editing privs.
2954 - * If so we create the button and add it to the tinymce button array
2955 - */
2956 -
2957 - function add_tinymce_button()
2958 - {
2959 - if (!current_user_can('edit_posts') && !current_user_can('edit_pages'))
2960 - return;
2961 - if (get_user_option('rich_editing') == 'true')
2962 - {
2963 - //the function that adds the javascript
2964 - add_filter('mce_external_plugins', array($this, 'add_new_tinymce_plugin'));
2965 - //adds the button to the tinymce button array
2966 - add_filter('mce_buttons', array($this, 'register_new_button'));
2967 - }
2968 - }
2969 -
2970 - /*
2971 - * add the new button to the tinymce array
2972 - */
2973 -
2974 - function register_new_button($buttons)
2975 - {
2976 - array_push($buttons, $this->btn_arr["Seperator"], $this->btn_arr["Name"]);
2977 - return $buttons;
2978 - }
2979 -
2980 - /*
2981 - * Call the javascript file that loads the
2982 - * instructions for the new button
2983 - */
2984 -
2985 - function add_new_tinymce_plugin($plugin_array)
2986 - {
2987 - $plugin_array[$this->btn_arr['Name']] = $this->js_file;
2988 - return $plugin_array;
2989 - }
2990 -
2991 - /*
2992 - * This function tricks tinymce in thinking
2993 - * it needs to refresh the buttons
2994 - */
2995 -
2996 - function refresh_mce_version($ver)
2997 - {
2998 - $ver += 3;
2999 - return $ver;
3000 - }
3001 -
3002 - }
3003 -
3004 -//class end
3005 -
3006 -
3007 - register_activation_hook(__FILE__, array('YouTubePrefs', 'initoptions'));
3008 - $youtubeplgplus = new YouTubePrefs();
3009 -
3010 -
3011 - add_action('wp_enqueue_scripts', array('YouTubePrefs', 'ytprefsscript'), 100);
3012 - add_action("wp_ajax_my_embedplus_pro_record", array('YouTubePrefs', 'my_embedplus_pro_record'));
3013 - add_action("wp_ajax_my_embedplus_clearspdc", array('YouTubePrefs', 'my_embedplus_clearspdc'));
3014 - add_action("wp_ajax_my_embedplus_glance_vids", array('YouTubePrefs', 'my_embedplus_glance_vids'));
3015 - add_action("wp_ajax_my_embedplus_glance_count", array('YouTubePrefs', 'my_embedplus_glance_count'));
3016 - add_action("wp_ajax_my_embedplus_dismiss_double_plugin_warning", array('YouTubePrefs', 'my_embedplus_dismiss_double_plugin_warning'));
3017 -
3018 - add_action('admin_enqueue_scripts', 'youtubeprefs_admin_enqueue_scripts');
3019 -
3020 - function youtubeprefs_admin_enqueue_scripts()
3021 - {
3022 - wp_enqueue_style('embedplusyoutube', plugins_url() . '/youtube-embed-plus/scripts/embedplus_mce.css');
3023 - add_action('wp_print_scripts', 'youtubeprefs_output_scriptvars');
3024 -
3025 - if (
3026 - //(!(isset(YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro]) && strlen(trim(YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro])) > 0)) && // display only if not pro ooopointer
3027 - (get_bloginfo('version') >= '3.3') && YouTubePrefs::custom_admin_pointers_check()
3028 - )
3029 - {
3030 - add_action('admin_print_footer_scripts', 'YouTubePrefs::custom_admin_pointers_footer');
3031 -
3032 - wp_enqueue_script('wp-pointer');
3033 - wp_enqueue_style('wp-pointer');
3034 - }
3035 -
3036 - if (YouTubePrefs::$alloptions['glance'] == 1)
3037 - {
3038 - add_action('admin_print_footer_scripts', 'YouTubePrefs::glance_script');
3039 - }
3040 - }
3041 -
3042 - function youtubeprefs_output_scriptvars()
3043 - {
3044 - YouTubePrefs::$scriptsprinted++;
3045 - if (YouTubePrefs::$scriptsprinted == 1)
3046 - {
3047 - $blogwidth = YouTubePrefs::get_blogwidth();
3048 - $epprokey = YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro];
3049 - $myytdefaults = http_build_query(YouTubePrefs::$alloptions);
3050 - ?>
3051 - <script type="text/javascript">
3052 - var wpajaxurl = "<?php echo admin_url('admin-ajax.php') ?>";
3053 - if (window.location.toString().indexOf('https://') == 0)
3054 - {
3055 - wpajaxurl = wpajaxurl.replace("http://", "https://");
3056 - }
3057 -
3058 - var epblogwidth = <?php echo $blogwidth; ?>;
3059 - var epprokey = '<?php echo $epprokey; ?>';
3060 - var epbasesite = '<?php echo YouTubePrefs::$epbase; ?>';
3061 - var epversion = '<?php echo YouTubePrefs::$version; ?>';
3062 - var myytdefaults = '<?php echo $myytdefaults; ?>';
3063 - var eppluginadminurl = '<?php echo admin_url('admin.php?page=youtube-my-preferences'); ?>';
3064 -
3065 - // Create IE + others compatible event handler
3066 - var epeventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
3067 - var epeventer = window[epeventMethod];
3068 - var epmessageEvent = epeventMethod == "attachEvent" ? "onmessage" : "message";
3069 -
3070 - // Listen to message from child window
3071 - epeventer(epmessageEvent, function(e)
3072 - {
3073 - var embedcode = "";
3074 - try
3075 - {
3076 - if (e.data.indexOf("youtubeembedplus") == 0)
3077 - {
3078 -
3079 - embedcode = e.data.split("|")[1];
3080 - if (embedcode.indexOf("[") !== 0)
3081 - {
3082 - embedcode = "<p>" + embedcode + "</p>";
3083 - }
3084 -
3085 - if (window.tinyMCE !== null && window.tinyMCE.activeEditor !== null && !window.tinyMCE.activeEditor.isHidden())
3086 - {
3087 - if (typeof window.tinyMCE.execInstanceCommand !== 'undefined')
3088 - {
3089 - window.tinyMCE.execInstanceCommand(
3090 - window.tinyMCE.activeEditor.id,
3091 - 'mceInsertContent',
3092 - false,
3093 - embedcode);
3094 - }
3095 - else
3096 - {
3097 - send_to_editor(embedcode);
3098 - }
3099 - }
3100 - else
3101 - {
3102 - embedcode = embedcode.replace('<p>', '\n').replace('</p>', '\n');
3103 - if (typeof QTags.insertContent === 'function')
3104 - {
3105 - QTags.insertContent(embedcode);
3106 - }
3107 - else
3108 - {
3109 - send_to_editor(embedcode);
3110 - }
3111 - }
3112 - tb_remove();
3113 -
3114 - }
3115 - }
3116 - catch (err)
3117 - {
3118 - if (typeof console !== 'undefined')
3119 - console.log(err.message);
3120 - }
3121 -
3122 -
3123 - }, false);
3124 -
3125 -
3126 -
3127 -
3128 -
3129 -
3130 - </script>
3131 - <?php
3132 - }
3133 - }
3134 -
1 +<?php
2 +/*
3 + Plugin Name: Embed Plus for YouTube Gallery, Livestream and Lazy Loading with Facades
4 + Plugin URI: https://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx?ref=plugin
5 + Description: A multi-featured plugin to embed YouTube in WordPress. Embed a video, YouTube channel gallery, playlist, or YouTube livestream. Defer JavaScript too!
6 + Version: 14.2.6.1
7 + Author: Embed Plus for YouTube Plugin Team
8 + Author URI: https://www.embedplus.com
9 + Requires at least: 4.5
10 + */
11 +
12 +/*
13 + Embed Plus for YouTube Gallery, Livestream and Lazy Loading with Facades
14 + Copyright (C) 2026 EmbedPlus.com
15 +
16 + This program is free software: you can redistribute it and/or modify
17 + it under the terms of the GNU General Public License as published by
18 + the Free Software Foundation, either version 3 of the License, or
19 + (at your option) any later version.
20 +
21 + This program is distributed in the hope that it will be useful,
22 + but WITHOUT ANY WARRANTY; without even the implied warranty of
23 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 + GNU General Public License for more details.
25 +
26 + You should have received a copy of the GNU General Public License
27 + along with this program. If not, see <http://www.gnu.org/licenses/>.
28 +
29 + */
30 +
31 +//define('WP_DEBUG', true);
32 +
33 +class YouTubePrefs
34 +{
35 +
36 + public static $folder_name = 'youtube-embed-plus';
37 + public static $curltimeout = 30;
38 + public static $version = '14.2.6.1';
39 + public static $opt_version = 'version';
40 + public static $optembedwidth = null;
41 + public static $optembedheight = null;
42 + public static $defaultheight = null;
43 + public static $defaultwidth = null;
44 + public static $oembeddata = null;
45 + public static $opt_center = 'centervid';
46 + public static $opt_glance = 'glance';
47 + public static $opt_autoplay = 'autoplay';
48 + public static $opt_debugmode = 'debugmode';
49 + public static $opt_uninstall_data = 'uninstall_data';
50 + public static $opt_old_script_method = 'old_script_method';
51 + public static $opt_cc_load_policy = 'cc_load_policy';
52 + public static $opt_cc_lang_pref = 'cc_lang_pref';
53 + public static $opt_iv_load_policy = 'iv_load_policy';
54 + public static $opt_loop = 'loop';
55 + public static $opt_rel = 'rel';
56 + public static $opt_fs = 'fs';
57 + public static $opt_playsinline = 'playsinline';
58 + public static $opt_autohide = 'autohide';
59 + public static $opt_controls = 'controls';
60 + public static $opt_disablekb = 'disablekb';
61 + public static $opt_theme = 'theme';
62 + public static $opt_color = 'color';
63 + public static $opt_listType = 'listType';
64 + public static $opt_dohl = 'dohl';
65 + public static $opt_hl = 'hl';
66 + public static $opt_nocookie = 'nocookie';
67 + public static $opt_gb_compat = 'gb_compat';
68 + public static $opt_facade_mode = 'facade_mode';
69 + public static $opt_facade_autoplay = 'facade_autoplay';
70 + public static $opt_gdpr_consent = 'gdpr_consent';
71 + public static $opt_gdpr_consent_message = 'gdpr_consent_message';
72 + public static $opt_gdpr_consent_button = 'gdpr_consent_button';
73 + public static $gdpr_cookie_name = 'ytprefs_gdpr_consent';
74 + public static $opt_playlistorder = 'playlistorder';
75 + public static $opt_acctitle = 'acctitle';
76 + public static $opt_pro = 'pro';
77 + public static $opt_oldspacing = 'oldspacing';
78 + public static $opt_frontend_only = 'frontend_only';
79 + public static $opt_responsive = 'responsive';
80 + public static $opt_responsive_all = 'responsive_all';
81 + public static $opt_origin = 'origin';
82 + public static $opt_widgetfit = 'widgetfit';
83 + public static $opt_evselector_light = 'evselector_light';
84 + public static $opt_stop_mobile_buffer = 'stop_mobile_buffer';
85 + public static $opt_restrict_wizard = 'restrict_wizard';
86 + public static $opt_restrict_wizard_roles = 'restrict_wizard_roles';
87 + public static $opt_ajax_compat = 'ajax_compat';
88 + public static $opt_maxres_facade = 'maxres_facade';
89 + public static $opt_ytapi_load = 'ytapi_load';
90 + public static $opt_defaultdims = 'defaultdims';
91 + public static $opt_defaultwidth = 'width';
92 + public static $opt_defaultheight = 'height';
93 + public static $opt_pause_others = 'pause_others';
94 + public static $opt_defaultvol = 'defaultvol';
95 + public static $opt_vol = 'vol';
96 + public static $opt_apikey = 'apikey';
97 + public static $opt_migrate = 'migrate';
98 + public static $opt_migrate_youtube = 'migrate_youtube';
99 + public static $opt_migrate_embedplusvideo = 'migrate_embedplusvideo';
100 + public static $opt_gallery_pagesize = 'gallery_pagesize';
101 + public static $opt_gallery_columns = 'gallery_columns';
102 + public static $opt_gallery_collapse_grid = 'gallery_collapse_grid';
103 + public static $opt_gallery_collapse_grid_breaks = 'gallery_collapse_grid_breaks';
104 + public static $opt_gallery_scrolloffset = 'gallery_scrolloffset';
105 + public static $opt_gallery_hideprivate = 'gallery_hideprivate';
106 + public static $opt_gallery_showtitle = 'gallery_showtitle';
107 + public static $opt_gallery_showpaging = 'gallery_showpaging';
108 + public static $opt_gallery_thumbplay = 'gallery_thumbplay';
109 + public static $opt_gallery_autonext = 'gallery_autonext';
110 + public static $opt_gallery_channelsub = 'gallery_channelsub';
111 + public static $opt_gallery_channelsublink = 'gallery_channelsublink';
112 + public static $opt_gallery_channelsubtext = 'gallery_channelsubtext';
113 + public static $opt_gallery_customarrows = 'gallery_customarrows';
114 + public static $opt_gallery_customprev = 'gallery_customprev';
115 + public static $opt_gallery_customnext = 'gallery_customnext';
116 + public static $opt_not_live_content = 'not_live_content';
117 + public static $opt_not_live_on = 'not_live_on';
118 + public static $opt_not_live_on_channel = 'not_live_on_channel';
119 + public static $opt_admin_off_scripts = 'admin_off_scripts';
120 + public static $opt_defer_js = 'defer_js';
121 + public static $opt_defer_jquery = 'defer_jquery';
122 + public static $opt_ajax_save = 'ajax_save';
123 + public static $opt_onboarded = 'onboarded';
124 + public static $opt_show_pointer = 'show_pointer';
125 + public static $opt_alloptions = 'youtubeprefs_alloptions';
126 + public static $alloptions = null;
127 + public static $yt_options = array();
128 + public static $dft_bpts = array(array('bp' => array('min' => 0, 'max' => 767), 'cols' => 1));
129 + public static $dft_roles = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
130 + public static $epbase = 'https://www.embedplus.com';
131 + public static $double_plugin = false;
132 + public static $scriptsprinted = 0;
133 + public static $min = '.min';
134 + public static $badentities = array('&#215;', '×', '&#8211;', '–', '&amp;', '&#038;', '&#38;');
135 + public static $goodliterals = array('x', 'x', '--', '--', '&', '&', '&');
136 + public static $wizard_hook = '';
137 + public static $onboarding_hook = '';
138 + public static $admin_page_hooks = array();
139 + public static $the_content_filters = array(
140 + 'wptexturize',
141 + 'wpautop',
142 + 'shortcode_unautop',
143 + 'prepend_attachment',
144 + 'wp_make_content_images_responsive',
145 + 'wp_filter_content_tags',
146 + 'do_shortcode',
147 + 'convert_smilies'
148 + );
149 + public static $get_api_key_msg = 'The ### feature now requires a (free) YouTube API key from Google. Please follow the easy steps <a href="https://www.youtube.com/watch?v=ZCfrNvu6nMc" target="_blank">in this video</a> to create and save your API key.';
150 + public static $boilerplate_api_error_message = ' Please make sure you performed the <a href="https://www.youtube.com/watch?v=ZCfrNvu6nMc" target="_blank">steps in this video</a> to create and save a proper server API key.';
151 + public static $dft_gdpr_consent_message = '<p><strong>Please accept YouTube cookies to play this video.</strong> By accepting you will be accessing content from YouTube, a service provided by an external third party.</p><p><a href="https://policies.google.com/privacy" target="_blank">YouTube privacy policy</a></p><p>If you accept this notice, your choice will be saved and the page will refresh.</p>';
152 + ///////////////////////////////////////////////////////////////////////////////////////////////////
153 + ///////////////////////////////////////////////////////////////////////////////////////////////////
154 + ///////////////////////////////////////////////////////////////////////////////////////////////////
155 + ///////////////////////////////////////////////////////////////////////////////////////////////////
156 +
157 + public static $oldytregex = '@^\s*https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))(?:/live_stream){0,1}/{0,1}\?)|(?:youtu.be/))([^\s"]+)\s*$@im';
158 + public static $ytregex = '@^[\r\t ]*https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))(?:/live_stream){0,1}/{0,1}\?)|(?:youtu.be/))([^\s"]+)[\r\t ]*$@im';
159 + public static $justurlregex = '@https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))(?:/live_stream){0,1}/{0,1}\?)|(?:youtu.be/))([^\[\s"]+)@i';
160 +
161 + ///////////////////////////////////////////////////////////////////////////////////////////////////
162 + ///////////////////////////////////////////////////////////////////////////////////////////////////
163 + ///////////////////////////////////////////////////////////////////////////////////////////////////
164 +
165 + public function __construct()
166 + {
167 + if (defined('EMBEDPLUS_BASE_URL'))
168 + {
169 + self::$epbase = EMBEDPLUS_BASE_URL;
170 + }
171 + register_deactivation_hook(__FILE__, array(self::class, 'on_deactivation'));
172 + add_action('admin_init', array(self::class, 'check_double_plugin_warning'));
173 + add_action('admin_notices', array(self::class, 'separate_version_message'));
174 +
175 + self::$alloptions = get_option(self::$opt_alloptions);
176 + if (self::$alloptions == false || version_compare(self::$alloptions[self::$opt_version], self::$version, '<'))
177 + {
178 + self::initoptions();
179 + }
180 +
181 + if ((defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) || self::$alloptions[self::$opt_debugmode] == 1)
182 + {
183 + self::$min = '';
184 + }
185 +
186 +
187 + if (self::$alloptions[self::$opt_oldspacing] == 1)
188 + {
189 + self::$ytregex = self::$oldytregex;
190 + }
191 +
192 + self::$optembedwidth = intval(get_option('embed_size_w'));
193 + self::$optembedheight = intval(get_option('embed_size_h'));
194 +
195 + self::$yt_options = array(
196 + self::$opt_autoplay,
197 + self::$opt_cc_load_policy,
198 + self::$opt_cc_lang_pref,
199 + self::$opt_iv_load_policy,
200 + self::$opt_loop,
201 + self::$opt_rel,
202 + self::$opt_fs,
203 + self::$opt_playsinline,
204 + self::$opt_autohide,
205 + self::$opt_controls,
206 + self::$opt_disablekb,
207 + self::$opt_hl,
208 + self::$opt_theme,
209 + self::$opt_color,
210 + self::$opt_listType,
211 + 'index',
212 + 'list',
213 + 'start',
214 + 'end',
215 + 'channel'
216 + );
217 +
218 + add_action('media_buttons', array(self::class, 'media_button_wizard'), 11);
219 +
220 +
221 + self::do_ytprefs();
222 + add_action('admin_menu', array(self::class, 'ytprefs_plugin_menu'));
223 + add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(self::class, 'my_plugin_action_links'));
224 +
225 + if (!is_admin())
226 + {
227 + if (self::$alloptions[self::$opt_old_script_method] == 1)
228 + {
229 + add_action('wp_print_scripts', array(self::class, 'jsvars'));
230 + add_action('wp_enqueue_scripts', array(self::class, 'jsvars'));
231 + }
232 +
233 + add_action('wp_enqueue_scripts', array(self::class, 'ytprefsscript'), 100);
234 + add_action('wp_enqueue_scripts', array(self::class, 'fitvids'), 101);
235 + }
236 +
237 + add_filter('ytprefs_filter_the_content_light', array(self::class, 'filter_the_content_light'));
238 +
239 + add_action("wp_ajax_my_embedplus_onboarding_save_ajax", array(self::class, 'onboarding_save_ajax'));
240 + add_action("wp_ajax_my_embedplus_settings_save_ajax", array(self::class, 'settings_save_ajax'));
241 + add_action("wp_ajax_my_embedplus_onboarding_save_apikey_ajax", array(self::class, 'onboarding_save_apikey_ajax'));
242 + add_action("wp_ajax_my_embedplus_glance_vids", array(self::class, 'my_embedplus_glance_vids'));
243 + add_action("wp_ajax_my_embedplus_glance_count", array(self::class, 'my_embedplus_glance_count'));
244 + add_action("wp_ajax_my_embedplus_dismiss_double_plugin_warning", array(self::class, 'my_embedplus_dismiss_double_plugin_warning'));
245 + add_action("wp_ajax_my_embedplus_gallery_page", array(self::class, 'my_embedplus_gallery_page'));
246 + add_action("wp_ajax_nopriv_my_embedplus_gallery_page", array(self::class, 'my_embedplus_gallery_page'));
247 + add_action('admin_enqueue_scripts', array(self::class, 'admin_enqueue_scripts'), 10, 1);
248 +
249 + if (!empty(self::$alloptions[self::$opt_not_live_on_channel]))
250 + {
251 + add_action("wp_footer", array(self::class, 'live_fallback_template'));
252 + }
253 + /////////////////////////////////////
254 + include_once(EPYTGB_INCLUDES_PATH . 'gutenberg_hooks.php');
255 + }
256 +
257 + public static function separate_version_message()
258 + {
259 + if (current_user_can('manage_options') && self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 10)
260 + {
261 + $class = 'notice notice-error is-dismissible';
262 + $message = 'Important message to Pro users: From version 11.7 onward, you must <a href="https://www.embedplus.com/youtube-pro/download/?prokey=' . esc_attr(self::$alloptions[self::$opt_pro]) . '" target="_blank">download the separate plugin here</a> to regain your Pro features. All your settings will automatically migrate after installing the separate Pro download. Thank you for your support and patience during this transition.';
263 +
264 + printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), wp_kses_post($message));
265 + }
266 + }
267 +
268 + public static function live_fallback_template()
269 + {
270 + echo '<script type="text/x-template" id="epyt-live-fallback">' . base64_encode(apply_filters('ytprefs_filter_the_content_light', wp_kses_post(self::$alloptions[self::$opt_not_live_content]))) . '</script>';
271 + }
272 +
273 + public static function defer_scripts($tag, $handle, $src)
274 + {
275 + $defer = array(
276 + '__dispload__',
277 + '__ytprefs__',
278 + '__dynload__',
279 + '__ytprefs__bar',
280 + '__ytprefsfitvids__',
281 + '__jquery_cookie__'
282 + );
283 +
284 + if (self::$alloptions[self::$opt_defer_jquery] == 1 && !is_admin())
285 + {
286 + array_push($defer, 'jquery', 'jquery-core', 'jquery-migrate');
287 + }
288 +
289 + if (in_array($handle, $defer) && stripos($tag, ' defer') === false)
290 + {
291 + $tag = str_replace(' src', ' defer src', $tag);
292 + }
293 +
294 + return $tag;
295 + }
296 +
297 + public static function my_plugin_action_links($links)
298 + {
299 + if (is_array($links))
300 + {
301 + $links[] = '<a href="' . esc_url(admin_url('admin.php?page=youtube-my-preferences')) . '">Settings</a>';
302 + $links[] = '<a href="https://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx?ref=actionlinks" target="_blank">Pro Version</a>';
303 + }
304 + return $links;
305 + }
306 +
307 + public static function show_glance_list()
308 + {
309 + $glancehref = self::show_glance();
310 + $cnt = self::get_glance_count();
311 +
312 + //display via list
313 + return '<li class="page-count">
314 + <a href="' . $glancehref . '" class="thickbox ytprefs_glance_button" id="ytprefs_glance_button" title="YouTube Embeds At a Glance">' . number_format_i18n($cnt) . ' With YouTube</a>
315 + </li>';
316 + }
317 +
318 + public static function show_glance_table()
319 + {
320 + $glancehref = self::show_glance();
321 + $cnt = self::get_glance_count();
322 + return
323 + '<tr>
324 + <td class="first b"><a title="YouTube Embeds At a Glance" href="' . $glancehref . '" class="thickbox ytprefs_glance_button">' . number_format_i18n($cnt) . '</a></td>
325 + <td class="t"><a title="YouTube Embeds At a Glance" href="' . $glancehref . '" id="ytprefs_glance_button" class="thickbox ytprefs_glance_button">With YouTube</a></td>
326 + </tr>';
327 + }
328 +
329 + public static function get_glance_count()
330 + {
331 + global $wpdb;
332 + $query_sql = "
333 + SELECT count(*) as mytotal
334 + FROM $wpdb->posts
335 + WHERE (post_content LIKE '%youtube.com/%' OR post_content LIKE '%youtu.be/%')
336 + AND post_status = 'publish'";
337 +
338 + $query_result = $wpdb->get_results($query_sql, OBJECT);
339 +
340 + return intval($query_result[0]->mytotal);
341 + }
342 +
343 + public static function show_glance()
344 + {
345 + $glancehref = admin_url('admin.php?page=youtube-ep-glance') . '&random=' . rand(1, 1000) . '&TB_iframe=true&width=780&height=800';
346 + return $glancehref;
347 + }
348 +
349 + public static function glance_page()
350 + {
351 + ?>
352 + <div class="wrap">
353 + <style type="text/css">
354 + #wphead {display:none;}
355 + #wpbody{margin-left: 0px;}
356 + .wrap {font-family: Arial; padding: 0px 10px 0px 10px; line-height: 180%;}
357 + .bold {font-weight: bold;}
358 + .orange {color: #f85d00;}
359 + sup.orange {text-transform: lowercase; font-weight: bold; color: #f85d00;}
360 + #adminmenuback {display: none;}
361 + #adminmenu, adminmenuwrap {display: none;}
362 + #wpcontent, .auto-fold #wpcontent {margin-left: 0px;}
363 + #wpadminbar {display:none;}
364 + html.wp-toolbar {padding: 0px;}
365 + #footer, #wpfooter, .auto-fold #wpfooter {display: none;}
366 + #wpfooter {clear: both}
367 + .acctitle {background-color: #dddddd; border-radius: 5px; padding: 7px 15px 7px 15px; cursor: pointer; margin: 10px; font-weight: bold; font-size: 12px;}
368 + .acctitle:hover {background-color: #cccccc;}
369 + .accbox {display: none; position: relative; margin: 5px 8px 30px 15px; clear: both; line-height: 180%;}
370 + .accclose {position: absolute; top: -38px; right: 5px; cursor: pointer; width: 24px; height: 24px;}
371 + .accloader {padding-right: 20px;}
372 + .accthumb {display: block; width: 300px; float: left; margin-right: 25px;}
373 + .accinfo {width: 300px; float: left;}
374 + .accvidtitle {font-weight: bold; font-size: 16px;}
375 + .accthumb img {width: 300px; height: auto; display: block;}
376 + .clearboth {clear: both;}
377 + .pad20 {padding: 20px;}
378 + .center {text-align: center;}
379 + #screen-meta-links {display: none;}
380 + </style>
381 + <script type="text/javascript">
382 + function accclose(ele)
383 + {
384 + jQuery(ele).parent('.accbox').hide(400);
385 + }
386 +
387 + (function ($j)
388 + {
389 + $j(document).ready(function ()
390 + {
391 +
392 +
393 + $j('.acctitle').on('click', function ()
394 + {
395 + var $acctitle = $j(this);
396 + var $accbox = $j(this).parent().children('.accbox');
397 + var pid = $accbox.attr("data-postid");
398 + $acctitle.prepend('<img alt="loading" class="accloader" src="<?php echo plugins_url('images/ajax-loader.gif', __FILE__) ?>" />');
399 + jQuery.ajax({
400 + type: "post",
401 + dataType: "json",
402 + timeout: 30000,
403 + url: window._EPYTA_ ? window._EPYTA_.wpajaxurl : ajaxurl,
404 + data: {action: 'my_embedplus_glance_vids', postid: pid},
405 + success: function (response)
406 + {
407 + if (response.type === "success")
408 + {
409 + $accbox.html(response.data),
410 + $accbox.show(400);
411 + }
412 + else
413 + {
414 + }
415 + },
416 + error: function (xhr, ajaxOptions, thrownError)
417 + {
418 +
419 + },
420 + complete: function ()
421 + {
422 + $acctitle.children('.accloader').remove();
423 + }
424 +
425 + });
426 + });
427 + });
428 + })(jQuery);</script>
429 + <?php
430 + global $wpdb;
431 + $query_sql = "
432 + SELECT SQL_CALC_FOUND_ROWS *
433 + FROM $wpdb->posts
434 + WHERE (post_content LIKE '%youtube.com/%' OR post_content LIKE '%youtu.be/%')
435 + AND post_status = 'publish'
436 + order by post_date DESC LIMIT 0, 10";
437 +
438 + $query_result = $wpdb->get_results($query_sql, OBJECT);
439 +
440 + if ($query_result !== null)
441 + {
442 + $total = $wpdb->get_var("SELECT FOUND_ROWS();");
443 + global $post;
444 + echo '<h2>10 Latest Posts/Pages with YouTube Videos (' . intval($total) . ' Total)</h2>';
445 + ?>
446 +
447 + We recommend using this page as an easy way to check the results of the global default settings you make (e.g. hide annotations) on your recent embeds. Or, simply use it as an index to jump right to your posts that contain YouTube embeds.
448 +
449 + <?php
450 + if ($total > 0)
451 + {
452 + echo '<ul class="accord">';
453 + foreach ($query_result as $post)
454 + {
455 + echo '<li>';
456 + setup_postdata($post);
457 + the_title('<div class="acctitle">', ' &raquo;</div>');
458 + echo '<div class="accbox" data-postid="' . $post->ID . '"></div><div class="clearboth"></div></li>';
459 + }
460 + echo '</ul>';
461 + }
462 + else
463 + {
464 + echo '<p class="center bold orange">You currently do not have any YouTube embeds yet.</p>';
465 + }
466 + }
467 +
468 + wp_reset_postdata();
469 + ?>
470 + To remove this feature from your dashboard, simply uncheck <i>Show "At a Glance" Embed Links</i> in the <a target="_blank" href="<?php echo admin_url('admin.php?page=youtube-my-preferences#jumpdefaults') ?>">plugin settings page &raquo;</a>.
471 +
472 + </div>
473 + <?php
474 + }
475 +
476 + public static function is_ajax()
477 + {
478 + $requested_with = filter_input(INPUT_SERVER, 'HTTP_X_REQUESTED_WITH');
479 + $is_ajax = (function_exists('wp_doing_ajax') && wp_doing_ajax() || (!empty($requested_with) && strtolower($requested_with) == 'xmlhttprequest') || (defined('DOING_AJAX') && DOING_AJAX));
480 + if ($is_ajax)
481 + {
482 + header('HTTP/1.1 200 OK');
483 + }
484 + return $is_ajax;
485 + }
486 +
487 + public static function my_embedplus_glance_vids()
488 + {
489 + $result = array();
490 + if (self::is_ajax())
491 + {
492 + if (!current_user_can('edit_posts'))
493 + {
494 + wp_send_json_error('Unauthorized');
495 + die();
496 + }
497 + $postid = intval($_REQUEST['postid']);
498 + $currpost = get_post($postid);
499 +
500 + $thehtml = '<img alt="close" class="accclose" onclick="accclose(this)" src="' . plugins_url('images/accclose.png', __FILE__) . '" />';
501 +
502 + $matches = array();
503 + $ismatch = preg_match_all(self::$justurlregex, $currpost->post_content, $matches);
504 +
505 + if ($ismatch)
506 + {
507 + foreach ($matches[0] as $match)
508 + {
509 + $link = trim(preg_replace('/&amp;/i', '&', $match));
510 + $link = preg_replace('/\s/', '', $link);
511 + $link = trim(str_replace(self::$badentities, self::$goodliterals, $link));
512 +
513 + $linkparamstemp = explode('?', $link);
514 +
515 + $linkparams = array();
516 + if (count($linkparamstemp) > 1)
517 + {
518 + $linkparams = self::keyvalue($linkparamstemp[1], true);
519 + }
520 + if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
521 + {
522 + $vtemp = explode('/', $linkparamstemp[0]);
523 + $linkparams['v'] = array_pop($vtemp);
524 + }
525 +
526 + $vidid = $linkparams['v'];
527 +
528 + if ($vidid != null)
529 + {
530 + try
531 + {
532 + $odata = self::get_oembed('https://youtube.com/watch?v=' . $vidid, 1920, 1280);
533 + $postlink = get_permalink($postid);
534 + if ($odata != null && !is_wp_error($odata))
535 + {
536 + $_name = esc_attr(sanitize_text_field($odata->title));
537 + $_description = esc_attr(sanitize_text_field($odata->author_name));
538 + $_thumbnailUrl = esc_url("https://i.ytimg.com/vi/" . $vidid . "/0.jpg");
539 +
540 + $thehtml .= '<a target="_blank" href="' . $postlink . '" class="accthumb"><img alt="YouTube Video" src="' . $_thumbnailUrl . '" /></a>';
541 + $thehtml .= '<div class="accinfo">';
542 + $thehtml .= '<a target="_blank" href="' . $postlink . '" class="accvidtitle">' . $_name . '</a>';
543 + $thehtml .= '<div class="accdesc">' . (strlen($_description) > 400 ? substr($_description, 0, 400) . "..." : $_description) . '</div>';
544 + $thehtml .= '</div>';
545 + $thehtml .= '<div class="clearboth pad20"></div>';
546 + }
547 + else
548 + {
549 + $thehtml .= '<p class="center bold orange">This <a target="_blank" href="' . $postlink . '">post/page</a> contains a video that has been removed from YouTube.';
550 + $thehtml .= '<br><a target="_blank" href="https://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx?ref=glancevids">Activate delete video tracking to catch these cases &raquo;</a>';
551 + $thehtml .= '</strong>';
552 + }
553 + }
554 + catch (Exception $ex)
555 + {
556 +
557 + }
558 + }
559 + else if (isset($linkparams['list']))
560 + {
561 + // if playlist
562 + try
563 + {
564 + $odata = self::get_oembed('https://youtube.com/playlist?list=' . $linkparams['list'], 1920, 1280);
565 + $postlink = get_permalink($postid);
566 + if ($odata != null && !is_wp_error($odata))
567 + {
568 + $_name = esc_attr(sanitize_text_field($odata->title));
569 + $_description = esc_attr(sanitize_text_field($odata->author_name));
570 + $_thumbnailUrl = esc_url($odata->thumbnail_url);
571 +
572 + $thehtml .= '<a target="_blank" href="' . $postlink . '" class="accthumb"><img alt="YouTube Video" src="' . $_thumbnailUrl . '" /></a>';
573 + $thehtml .= '<div class="accinfo">';
574 + $thehtml .= '<a target="_blank" href="' . $postlink . '" class="accvidtitle">' . $_name . '</a>';
575 + $thehtml .= '<div class="accdesc">' . (strlen($_description) > 400 ? substr($_description, 0, 400) . "..." : $_description) . '</div>';
576 + $thehtml .= '</div>';
577 + $thehtml .= '<div class="clearboth pad20"></div>';
578 + }
579 + else
580 + {
581 + $thehtml .= '<p class="center bold orange">This <a target="_blank" href="' . $postlink . '">post/page</a> contains a video that has been removed from YouTube.';
582 + $thehtml .= '<br><a target="_blank" href="https://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx?ref=glancevids">Activate delete video tracking to catch these cases &raquo;</a>';
583 + $thehtml .= '</strong>';
584 + }
585 + }
586 + catch (Exception $ex)
587 + {
588 +
589 + }
590 + }
591 + }
592 + }
593 +
594 +
595 +
596 + if ($currpost != null)
597 + {
598 + $result['type'] = 'success';
599 + $result['data'] = $thehtml;
600 + }
601 + else
602 + {
603 + $result['type'] = 'error';
604 + }
605 + echo json_encode($result);
606 + }
607 + else
608 + {
609 + $result['type'] = 'error';
610 + header("Location: " . $_SERVER["HTTP_REFERER"]);
611 + }
612 + die();
613 + }
614 +
615 + public static function my_embedplus_glance_count()
616 + {
617 + $result = array();
618 + if (self::is_ajax())
619 + {
620 + if (!current_user_can('edit_posts'))
621 + {
622 + wp_send_json_error('Unauthorized');
623 + die();
624 + }
625 + $thehtml = '';
626 +
627 + try
628 + {
629 + if (version_compare(get_bloginfo('version'), '3.8', '>='))
630 + {
631 + $result['container'] = '#dashboard_right_now ul';
632 + $thehtml .= self::show_glance_list();
633 + }
634 + else
635 + {
636 + $result['container'] = '#dashboard_right_now .table_content table tbody';
637 + $thehtml .= self::show_glance_table();
638 + }
639 + $result['type'] = 'success';
640 + $result['data'] = $thehtml;
641 + }
642 + catch (Exception $e)
643 + {
644 + $result['type'] = 'error';
645 + }
646 +
647 + echo json_encode($result);
648 + }
649 + else
650 + {
651 + $result['type'] = 'error';
652 + header("Location: " . $_SERVER["HTTP_REFERER"]);
653 + }
654 + die();
655 + }
656 +
657 + public static function try_get_ytid($url)
658 + {
659 + $theytid = null;
660 + if (strpos($url, 'v=') !== false)
661 + {
662 + $url_params = explode('?', $url);
663 + $kvp = self::keyvalue($url_params[1], true);
664 + $theytid = $kvp['v'];
665 + }
666 + else if (strpos($url, "youtu.be") !== false)
667 + {
668 + $shortpath = explode('/', parse_url($url, PHP_URL_PATH));
669 + $theytid = $shortpath[1];
670 + }
671 + return $theytid;
672 + }
673 +
674 + public static function wizard()
675 + {
676 + ?>
677 + <div class="wrap" id="epyt_wiz_wrap">
678 + <div class="smallnote center"> Please periodically check the YouTube plugin tab on your admin panel to review the latest options. </div>
679 +
680 + <?php
681 + $form_valid = true;
682 + $acc_expand = '';
683 + $get_pro_link = self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=wizard';
684 +
685 +
686 +
687 + $step1_api_error_msg = ' Please confirm that the link works in your browser, and that <em>the owner of the video allowed embed sharing permissions (otherwise, contact the owner of the video to allow embedding)</em>. Then copy that full link in your address bar to paste here. If you are sure your link is correct, then (1) your API key may be too restrictive (<a target="_blank" href="https://console.developers.google.com/apis/credentials">check here</a>) or (2) you have reached your Google quota (<a href="https://console.developers.google.com/apis/dashboard" target="_blank">check here</a>). You can apply to Google for a <a href="https://services.google.com/fb/forms/ytapiquotarequest/" target="_blank">quota increase here</a>.';
688 + $step1_video_errors = '';
689 + $step1_video_error_invalid = 'Sorry, that does not seem to be a link to an existing video. Please confirm that the link works in your browser, and that <em>the owner of the video allowed embed sharing permissions (otherwise, contact the owner of the video to allow embedding)</em>. Then copy that full link in your address bar to paste here.';
690 + $step1_playlist_errors = '';
691 + $step1_playlist_error_invalid = 'Sorry, that does not seem to be a link to an existing playlist. Please confirm that the link works in your browser, and that <em>the owner of the playlist allowed embed sharing permissions (otherwise, contact the owner of the video to allow embedding)</em>. Then copy that full link in your address bar to paste here.';
692 + $step1_channel_errors = '';
693 + $step1_channel_error_invalid = 'Sorry, that does not seem to be a link to an existing video. ' . $step1_api_error_msg;
694 + $step1_live_errors = '';
695 + $step1_live_error_invalid = 'Sorry, that does not seem to be a valid link to an existing live video. ' . $step1_api_error_msg;
696 + $step1_livechannel_errors = '';
697 + $step1_livechannel_error_invalid = __('Sorry, that does not seem to be a link to an existing channel. Note: the custom channel name will not work. Please enter either a) the official channel format shown above, or b) any any single video belonging to the channel and the plugin can retrieve the official channel format for you.', 'text_domain');
698 +
699 + $if_live_preview = false;
700 +
701 + $theytid = null;
702 + $theplaylistid = null;
703 + $submit_type = null;
704 +
705 + if (isset($_POST['wizform_submit']))
706 + {
707 + check_admin_referer('_epyt_wiz', '_epyt_nonce');
708 +
709 + $submit_type = sanitize_text_field($_POST['wizform_submit']);
710 + if ($submit_type === 'step1_video')
711 + {
712 + // validate
713 + $search = sanitize_text_field(trim($_POST['txtUrl']));
714 +
715 + try
716 + {
717 + if (empty($search))
718 + {
719 + throw new Exception();
720 + }
721 + else
722 + {
723 + // cleanup
724 + $search = str_replace('/shorts/', '/watch?v=', $search);
725 + }
726 + if (preg_match(self::$justurlregex, $search))
727 + {
728 + //$search = esc_url($search);
729 +
730 + try
731 + {
732 + $theytid = self::try_get_ytid($search);
733 +
734 + if ($theytid == null)
735 + {
736 + $form_valid = false;
737 + $step1_video_errors = $step1_video_error_invalid;
738 + $acc_expand = 'h3_video';
739 + }
740 + else
741 + {
742 +
743 + $odata = self::get_oembed('http://youtube.com/watch?v=' . $theytid, 1920, 1280);
744 + if (is_object($odata))
745 + {
746 + ?>
747 +
748 + <div id="step2_video" class="center">
749 +
750 + <h2>
751 + <?php
752 + if (isset($odata->title))
753 + {
754 + echo sanitize_text_field($odata->title);
755 + }
756 + ?>
757 + </h2>
758 + <p class="center">
759 + <a class="ui-button ui-widget ui-corner-all" href="<?php echo $get_pro_link; ?>" target="_blank"><span class="ui-icon ui-icon-gear"></span> Customize (PRO)</a>
760 + &nbsp; <a class="ui-button ui-widget ui-corner-all inserttopost" rel="[embedyt] https://www.youtube.com/watch?v=<?php echo esc_attr($theytid) ?>[/embedyt]"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span> Insert Into Editor</a>
761 + </p>
762 + &nbsp; Or Copy Code:
763 + <span class="copycode">[embedyt] https://www.youtube.com/watch?v=<?php echo esc_attr($theytid) ?>[/embedyt]</span>
764 + <div class="clearboth" style="height: 10px;">
765 + </div>
766 + <div class="ep-wizard-preview-video-wrapper">
767 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/<?php echo esc_attr($theytid) ?>?rel=0" allowfullscreen="" frameborder="0"></iframe>
768 + </div>
769 +
770 + </div>
771 + <?php
772 + }
773 + else
774 + {
775 + $form_valid = false;
776 + $step1_video_errors = $step1_video_error_invalid;
777 + $acc_expand = 'h3_video';
778 + }
779 + }
780 + }
781 + catch (Exception $ex)
782 + {
783 + $form_valid = false;
784 + $step1_video_errors = $step1_video_error_invalid;
785 + $acc_expand = 'h3_video';
786 + }
787 + }
788 + else
789 + {
790 + $search_options = new stdClass();
791 + $search_options->q = $search;
792 + $search_options->pageToken = null;
793 + ?>
794 + <div id="step2_video_search" class="center">
795 + <h2>You searched for: <em class="orange"><?php echo sanitize_text_field($search); ?></em> </h2>
796 +
797 + <?php
798 + $search_page = self::get_search_page($search_options);
799 + echo $search_page->html;
800 + ?>
801 + </div>
802 + <?php
803 + }
804 +
805 + // // if valid, set and display next step
806 + // if not,form_valid = false and set accordion expander and error messages
807 + }
808 + catch (Exception $ex)
809 + {
810 + $form_valid = false;
811 + $step1_video_errors = $step1_video_error_invalid;
812 + $acc_expand = 'h3_video';
813 + }
814 + }
815 + else if ($submit_type === 'step1_playlist')
816 + {
817 + $search = sanitize_text_field(trim($_POST['txtUrlPlaylist']));
818 + try
819 + {
820 + if (empty($search))
821 + {
822 + throw new Exception();
823 + }
824 + if (preg_match(self::$justurlregex, $search))
825 + {
826 + try
827 + {
828 + $theytid = null;
829 + try
830 + {
831 + $theytid = self::try_get_ytid($search);
832 + }
833 + catch (Exception $ex)
834 + {
835 +
836 + }
837 +
838 + $urlparams = explode('?', $search);
839 + $qvars = array();
840 + parse_str($urlparams[1], $qvars);
841 + $theplaylistid = $qvars["list"];
842 +
843 + $odata = self::get_oembed('https://youtube.com/playlist?list=' . $theplaylistid, 1920, 1280);
844 +
845 + if (is_object($odata))
846 + {
847 + $rel = 'https://www.youtube.com/embed?listType=playlist&list=' . (esc_attr($theplaylistid) . (empty($theytid) ? '' : '&v=' . esc_attr($theytid)));
848 + ?>
849 +
850 + <div id="step2_playlist" class="center">
851 +
852 + <h2>
853 + <?php
854 + if (isset($odata->title))
855 + {
856 + echo 'Playlist: ' . sanitize_text_field($odata->title);
857 + }
858 + ?>
859 + </h2>
860 + <p class="center">
861 + <a class="ui-button ui-widget ui-corner-all inserttopost" rel="[embedyt] <?php echo $rel; ?>[/embedyt]"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span> Insert as Playlist</a>
862 + &nbsp; <a class="ui-button ui-widget ui-corner-all inserttopost" rel="[embedyt] <?php echo $rel . '&layout=gallery'; ?>[/embedyt]"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span> Insert as Gallery</a>
863 + &nbsp; <a class="ui-button ui-widget ui-corner-all" href="<?php echo $get_pro_link; ?>" target="_blank"><span class="ui-icon ui-icon-gear"></span> Customize (PRO)</a>
864 + </p>
865 + <p>
866 + Or Copy Code:
867 + </p>
868 + <p>
869 + Playlist Layout: <span class="copycode">[embedyt] <?php echo $rel; ?>[/embedyt]</span>
870 + </p>
871 + <p>
872 + Gallery Layout: <span class="copycode">[embedyt] <?php echo $rel . '&layout=gallery'; ?>[/embedyt]</span>
873 + </p>
874 + <div class="clearboth" style="height: 10px;">
875 + </div>
876 + <div class="ep-wizard-preview-video-wrapper">
877 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="<?php echo $rel; ?>" allowfullscreen="" frameborder="0"></iframe>
878 + </div>
879 + </div>
880 + <?php
881 + }
882 + else
883 + {
884 + $form_valid = false;
885 + $step1_playlist_errors = $step1_playlist_error_invalid;
886 + $acc_expand = 'h3_playlist';
887 + }
888 + }
889 + catch (Exception $ex)
890 + {
891 + $form_valid = false;
892 + $step1_playlist_errors = $step1_playlist_error_invalid;
893 + $acc_expand = 'h3_playlist';
894 + }
895 + }
896 + }
897 + catch (Exception $ex)
898 + {
899 + $form_valid = false;
900 + $step1_playlist_errors = $step1_playlist_error_invalid;
901 + $acc_expand = 'h3_playlist';
902 + }
903 + }
904 + else if ($submit_type === 'step1_channel')
905 + {
906 + $search = sanitize_text_field(trim($_POST['txtUrlChannel']));
907 + try
908 + {
909 + if (empty($search))
910 + {
911 + throw new Exception();
912 + }
913 + if (preg_match(self::$justurlregex, $search) || preg_match('@/channel/(.+)@', $search))
914 + {
915 + try
916 + {
917 + $thechannel = null;
918 + if (preg_match(self::$justurlregex, $search))
919 + {
920 + // single id
921 + $theytid = null;
922 + try
923 + {
924 + $theytid = self::try_get_ytid($search);
925 + }
926 + catch (Exception $ex)
927 + {
928 +
929 + }
930 + $chanvid = null;
931 + if ($theytid)
932 + {
933 + $chanvid = self::get_video_snippet($theytid);
934 + }
935 + if ($chanvid)
936 + {
937 + $thechannel = self::get_channel_snippet($chanvid->snippet->channelId);
938 + }
939 + }
940 + else
941 + {
942 + // channel id
943 + $chanmatch = array();
944 + preg_match('@/channel/(.+)@', $search, $chanmatch);
945 + if (!empty($chanmatch))
946 + {
947 + $thechannel = self::get_channel_snippet($chanmatch[1]);
948 + }
949 + }
950 + if ($thechannel)
951 + {
952 + $theplaylistid = $thechannel->contentDetails->relatedPlaylists->uploads;
953 + $rel = 'https://www.youtube.com/embed?listType=playlist&list=' . (esc_attr($theplaylistid));
954 + ?>
955 +
956 + <div id="step2_channel" class="center">
957 +
958 + <h2>
959 + <?php
960 + echo 'Channel: ' . sanitize_text_field($thechannel->snippet->title);
961 + ?>
962 + </h2>
963 + <p class="center">
964 + <a class="ui-button ui-widget ui-corner-all inserttopost" rel="[embedyt] <?php echo $rel; ?>[/embedyt]"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span> Insert as Playlist</a>
965 + &nbsp; <a class="ui-button ui-widget ui-corner-all inserttopost" rel="[embedyt] <?php echo $rel . '&layout=gallery'; ?>[/embedyt]"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span> Insert as Gallery</a>
966 + &nbsp; <a class="ui-button ui-widget ui-corner-all" href="<?php echo $get_pro_link; ?>" target="_blank"><span class="ui-icon ui-icon-gear"></span> Customize (PRO)</a>
967 + </p>
968 + <p>
969 + Or Copy Code:
970 + </p>
971 + <p>
972 + Playlist Layout: <span class="copycode">[embedyt] <?php echo $rel; ?>[/embedyt]</span>
973 + </p>
974 + <p>
975 + Gallery Layout: <span class="copycode">[embedyt] <?php echo $rel . '&layout=gallery'; ?>[/embedyt]</span>
976 + </p>
977 + <div class="clearboth" style="height: 10px;">
978 + </div>
979 + <div class="ep-wizard-preview-video-wrapper">
980 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="<?php echo $rel; ?>" allowfullscreen="" frameborder="0"></iframe>
981 + </div>
982 + </div>
983 + <?php
984 + }
985 + else
986 + {
987 + $form_valid = false;
988 + $step1_channel_errors = $step1_channel_error_invalid;
989 + $acc_expand = 'h3_channel';
990 + }
991 + }
992 + catch (Exception $ex)
993 + {
994 + $form_valid = false;
995 + $step1_channel_errors = $step1_channel_error_invalid;
996 + $acc_expand = 'h3_channel';
997 + }
998 + }
999 + }
1000 + catch (Exception $ex)
1001 + {
1002 + $form_valid = false;
1003 + $step1_channel_errors = $step1_channel_error_invalid;
1004 + $acc_expand = 'h3_channel';
1005 + }
1006 + }
1007 + else if ($submit_type === 'step1_livechannel')
1008 + {
1009 + $search = sanitize_text_field(trim($_POST['txtUrlLiveChannel']));
1010 + try
1011 + {
1012 + if (empty($search))
1013 + {
1014 + throw new Exception();
1015 + }
1016 + if (preg_match(self::$justurlregex, $search) || preg_match('@/channel/(.+)@', $search))
1017 + {
1018 + try
1019 + {
1020 + $thechannelid = null;
1021 + if (preg_match(self::$justurlregex, $search))
1022 + {
1023 + // single id
1024 + $theytid = null;
1025 + try
1026 + {
1027 + $theytid = self::try_get_ytid($search);
1028 + }
1029 + catch (Exception $ex)
1030 + {
1031 +
1032 + }
1033 + $chanvid = null;
1034 + if ($theytid)
1035 + {
1036 + $chanvid = self::get_video_snippet($theytid);
1037 + }
1038 + if ($chanvid)
1039 + {
1040 + $thechannelid = $chanvid->snippet->channelId;
1041 + }
1042 + }
1043 + else
1044 + {
1045 + // channel id
1046 + $chanmatch = array();
1047 + preg_match('@/channel/(.+)@', $search, $chanmatch);
1048 + if (!empty($chanmatch))
1049 + {
1050 + $thechannelid = $chanmatch[1];
1051 + }
1052 + }
1053 + if (!empty($thechannelid))
1054 + {
1055 + $rel = 'https://www.youtube.com/embed/live_stream?channel=' . (esc_attr($thechannelid));
1056 +
1057 + $final_title = esc_url('https://www.youtube.com/channel/' . $thechannelid);
1058 + $final_title_prefix = 'Live stream from channel';
1059 + $doing_live = true;
1060 + ?>
1061 +
1062 + <div id="step2_livechannel" class="center">
1063 + <h2>
1064 + <?php
1065 + echo 'Live stream from channel: ' . esc_url('https://www.youtube.com/channel/' . $thechannelid);
1066 + ?>
1067 + </h2>
1068 + <p class="center">
1069 + <a class="ui-button ui-widget ui-corner-all inserttopost" rel="[embedyt] https://www.youtube.com/embed/live_stream?channel=<?php echo esc_attr($thechannelid) ?>[/embedyt]"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span> Insert Into Editor</a>
1070 + &nbsp;
1071 + <a class="ui-button ui-widget ui-corner-all" href="<?php echo $get_pro_link; ?>" target="_blank"><span class="ui-icon ui-icon-gear"></span> Customize (PRO)</a>
1072 + </p>
1073 + &nbsp; Or Copy Code:
1074 + <span class="copycode">[embedyt] https://www.youtube.com/embed/live_stream?channel=<?php echo esc_attr($thechannelid) ?>[/embedyt]</span>
1075 + <div class="clearboth" style="height: 10px;">
1076 + </div>
1077 + <p>
1078 + <?php _e('If you see a black/empty YouTube player, then it likely means that you do not have any currently running or future live streams that are scheduled in your channel, so the plugin isn\'t getting any data from the YouTube API to show. If you want to continue to use the channel based live stream embedding method, we suggest regularly scheduling one or more live streams, or using the live stream fallback content feature, so the player is not black/empty.', 'text_domain'); ?>
1079 + </p>
1080 + <div class="ep-wizard-preview-video-wrapper">
1081 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/live_stream?channel=<?php echo esc_attr($thechannelid) ?>" allowfullscreen="" frameborder="0"></iframe>
1082 + </div>
1083 + </div>
1084 + <?php
1085 + }
1086 + else
1087 + {
1088 + $form_valid = false;
1089 + $step1_livechannel_errors = $step1_livechannel_error_invalid;
1090 + $acc_expand = 'h3_live';
1091 + }
1092 + }
1093 + catch (Exception $ex)
1094 + {
1095 + $form_valid = false;
1096 + $step1_livechannel_errors = $step1_livechannel_error_invalid;
1097 + $acc_expand = 'h3_live';
1098 + }
1099 + }
1100 + else
1101 + {
1102 + $form_valid = false;
1103 + $step1_livechannel_errors = $step1_livechannel_error_invalid;
1104 + $acc_expand = 'h3_live';
1105 + }
1106 + }
1107 + catch (Exception $ex)
1108 + {
1109 + $form_valid = false;
1110 + $step1_livechannel_errors = $step1_livechannel_error_invalid;
1111 + $acc_expand = 'h3_live';
1112 + }
1113 + }
1114 + else if ($submit_type === 'step1_live')
1115 + {
1116 + $search = sanitize_text_field(trim($_POST['txtUrlLive']));
1117 + try
1118 + {
1119 + if (empty($search))
1120 + {
1121 + throw new Exception();
1122 + }
1123 +
1124 + try
1125 + {
1126 + $theytid = null;
1127 + try
1128 + {
1129 + $theytid = self::try_get_ytid($search);
1130 + }
1131 + catch (Exception $ex)
1132 + {
1133 +
1134 + }
1135 + $live_attempt = self::get_video_snippet($theytid);
1136 + if ($live_attempt)
1137 + {
1138 + $if_live_preview = $live_attempt->id;
1139 + $final_title = sanitize_text_field($live_attempt->snippet->title);
1140 + $final_title_prefix = 'Live Stream';
1141 + }
1142 + $rel = 'https://www.youtube.com/watch?v=' . (esc_attr($theytid)) . '&live=1';
1143 + $doing_live = true;
1144 + ?>
1145 + <div id="step2_live" class="center">
1146 +
1147 + <h2>
1148 + <?php
1149 + echo 'Live Stream (or Premiere): ' . sanitize_text_field($live_attempt->snippet->title);
1150 + ?>
1151 + </h2>
1152 + <p class="center">
1153 + <a class="ui-button ui-widget ui-corner-all inserttopost" rel="[embedyt] <?php echo $rel; ?>[/embedyt]"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span> Insert Into Editor</a>
1154 + &nbsp; <a class="ui-button ui-widget ui-corner-all" href="<?php echo $get_pro_link; ?>" target="_blank"><span class="ui-icon ui-icon-gear"></span> Customize (PRO)</a>
1155 + </p>
1156 + <p>
1157 + Or Copy Code:
1158 + </p>
1159 + <p>
1160 + <span class="copycode">[embedyt] <?php echo $rel; ?>[/embedyt]</span>
1161 + </p>
1162 + <div class="clearboth" style="height: 10px;">
1163 + </div>
1164 + <?php
1165 + if ($if_live_preview)
1166 + {
1167 + ?>
1168 + <div class="ep-wizard-preview-video-wrapper">
1169 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/<?php echo esc_attr($if_live_preview) ?>?rel=0" allowfullscreen="" frameborder="0"></iframe>
1170 + </div>
1171 + <?php
1172 + }
1173 + ?>
1174 + <p>
1175 + <?php _e('<strong>Is your live stream not working?</strong> Read more here: <a href="https://support.google.com/youtube/answer/2474026?hl=en" target="_blank">https://support.google.com/youtube/answer/2474026?hl=en</a>', 'text_domain'); ?>
1176 + </p>
1177 + </div>
1178 + <?php
1179 + }
1180 + catch (Exception $ex)
1181 + {
1182 + $form_valid = false;
1183 + $step1_live_errors = $step1_live_error_invalid;
1184 + $acc_expand = 'h3_live';
1185 + }
1186 + }
1187 + catch (Exception $ex)
1188 + {
1189 + $form_valid = false;
1190 + $step1_live_errors = $step1_live_error_invalid;
1191 + $acc_expand = 'h3_live';
1192 + }
1193 + }
1194 + else
1195 + {
1196 + $form_valid = false;
1197 + $acc_expand = 'h3none';
1198 + }
1199 + }
1200 +
1201 + if (!isset($_POST['wizform_submit']) || ($form_valid === false))
1202 + {
1203 + if ($form_valid === false)
1204 + {
1205 + ?>
1206 + <script type="text/javascript">
1207 + var _EPYTWIZ_ = _EPYTWIZ_ || {};
1208 + _EPYTWIZ_.acc_expand = '<?php echo sanitize_key($acc_expand) ?>';</script>
1209 + <?php
1210 + }
1211 + ?>
1212 +
1213 + <div class="wiz-accordion">
1214 + <h3 class="header-go"> <a href="<?php echo admin_url('admin.php?page=youtube-my-preferences#jumpdefaults'); ?>">Check my general YouTube embedding instructions and settings. </a></h3>
1215 + <div class="header-go-content"></div>
1216 + <h3 id="h3_video"> <a href="#"><?php _e('Embed a single video, or YouTube short.', 'text_domain'); ?></a></h3>
1217 + <div>
1218 + <h4 class="center">Single video directions</h4>
1219 + <p>
1220 + <?php _e('Paste the url of a single video below (examples: <em>https://www.youtube.com/watch?v=YVvn8dpSAt0</em> or <em>https://www.youtube.com/shorts/J38Yq85ZoyY</em>)', 'text_domain'); ?>
1221 + </p>
1222 + <form name="wizform_video" method="post" action="" class="wizform" id="wizform_video">
1223 + <?php wp_nonce_field('_epyt_wiz', '_epyt_nonce', true); ?>
1224 + <div class="center txt-button-align">
1225 + <input name="txtUrl" maxlength="200" id="txtUrl" class="txturlpastecustom ui-widget ui-widget-content ui-corner-all" placeholder="Paste URL here" type="text"> <button name="wizform_submit" class="ui-button ui-widget ui-corner-all" type="submit" value="step1_video">Submit</button>
1226 + </div>
1227 + <p class="badpaste orange bold" style="display: none;">
1228 + Please do not paste full embedcode above, only simple links to the YouTube video.
1229 + <br />
1230 + We have attempted to correct it above, but please doublecheck!
1231 + </p>
1232 + </form>
1233 + <?php echo $step1_video_errors ? '<p class="orange bold">' . $step1_video_errors . '</p>' : ''; ?>
1234 + <p><em>Note: You can also search YouTube videos by title in the text box above (example: <em>TED talks</em>). However, searching will use a significant amount of your YouTube API quota.</em></p>
1235 + </div>
1236 + <h3 id="h3_playlist"> <a href="#">Embed a playlist. </a></h3>
1237 + <div>
1238 + <h4 class="center">Playlist directions</h4>
1239 + <div class="playlist-tabs">
1240 + <ul>
1241 + <li><a href="#ptabs-1">Self-contained layout directions</a></li>
1242 + <li><a href="#ptabs-2">Gallery layout directions</a></li>
1243 + </ul>
1244 + <div id="ptabs-1">
1245 + <img src="<?php echo plugins_url('/images/icon-playlist-self.jpg', __FILE__) ?>" class="icon-playlist" />
1246 + <ol>
1247 + <li>Go to the page for the playlist that lists all of its videos (<a href="https://www.youtube.com/playlist?list=PL70DEC2B0568B5469" target="_blank">Example &raquo;</a>). </li>
1248 + <li>You may then click on the video that you want the playlist to start with (this step only applies to self-contained playlists. You cannot pick a starter for gallery layout directions).</li>
1249 + <li>Copy the URL in your browser and paste it in the textbox below. You'll notice that a playlist URL contains the playlist ID (e.g. "PL...")</li>
1250 + <li>Click "Get Playlist" to continue.</li>
1251 + </ol>
1252 + <div class="clearboth">
1253 + </div>
1254 + </div>
1255 + <div id="ptabs-2">
1256 + <img src="<?php echo plugins_url('/images/icon-playlist-gallery.jpg', __FILE__) ?>" class="icon-playlist" />
1257 + <ol>
1258 + <li>Go to the page for the playlist that lists all of its videos (<a href="https://www.youtube.com/playlist?list=PL70DEC2B0568B5469" target="_blank">Example &raquo;</a>). </li>
1259 + <li>Copy the URL in your browser and paste it in the textbox below. You'll notice that a playlist URL contains the playlist ID (e.g. "PL...")</li>
1260 + <li>Click "Get Playlist" to continue.</li>
1261 + </ol>
1262 + <div class="clearboth">
1263 + </div>
1264 + </div>
1265 + </div>
1266 +
1267 + <form name="wizform_playlist" method="post" action="" class="wizform" id="wizform_playlist">
1268 + <?php wp_nonce_field('_epyt_wiz', '_epyt_nonce', true); ?>
1269 + <div class="center txt-button-align">
1270 + <input name="txtUrlPlaylist" maxlength="200" id="txtUrlPlaylist" class="txturlpastecustom ui-widget ui-widget-content ui-corner-all" placeholder="Paste the playlist link here" type="text">
1271 + <button name="wizform_submit" class="ui-button ui-widget ui-corner-all" type="submit" value="step1_playlist">Get Playlist</button>
1272 + </div>
1273 + </form>
1274 + <?php echo $step1_playlist_errors ? '<p class="orange bold">' . $step1_playlist_errors . '</p>' : ''; ?>
1275 + </div>
1276 + <h3 id="h3_channel"> <a href="#">Embed a channel. </a></h3>
1277 + <div>
1278 + <h4 class="center">Channel directions</h4>
1279 + <?php
1280 + if (!self::has_api_key())
1281 + {
1282 + echo str_replace('###', '"search for channel"', self::$get_api_key_msg);
1283 + }
1284 + else
1285 + {
1286 + ?>
1287 + <p>
1288 + <?php _e('If you already know the direct link to the channel ID, enter it below. <br>Example: https://www.youtube.com<strong>/channel/</strong>UCnM5iMGiKsZg-iOlIO2ZkdQ <p class="error-channel-format smallnote">Note: the following format will not work: https://www.youtube.com<strong>/c/</strong>customchannelname If you cannot locate the proper channel ID format above, then try the other method below.</p> ', 'text_domain'); ?>
1289 + </p>
1290 + <p>
1291 + Or, simply enter a link to any single video that belongs to the user's channel, and the plugin will find the channel for you.<br>Example: https://www.youtube.com/watch?v=YVvn8dpSAt0
1292 + </p>
1293 + <form name="wizform_channel" method="post" action="" class="wizform" id="wizform_channel">
1294 + <?php wp_nonce_field('_epyt_wiz', '_epyt_nonce', true); ?>
1295 + <div class="center txt-button-align">
1296 + <input name="txtUrlChannel" maxlength="200" id="txtUrlChannel" class="txturlpastecustom ui-widget ui-widget-content ui-corner-all" placeholder="Paste YouTube link here" type="text"> <button name="wizform_submit" class="ui-button ui-widget ui-corner-all" type="submit" value="step1_channel">Get Channel</button>
1297 + </div>
1298 + <p class="badpaste orange bold" style="display: none;">
1299 + Please do not paste full embedcode above, only simple links to the YouTube video.
1300 + <br />
1301 + We have attempted to correct it above, but please doublecheck!
1302 + </p>
1303 + </form>
1304 + <?php echo $step1_channel_errors ? '<p class="orange bold">' . $step1_channel_errors . '</p>' : ''; ?>
1305 + <?php
1306 + }
1307 + ?>
1308 + </div>
1309 + <h3 id="h3_live"> <a href="#">Embed a live stream or premiere video. </a></h3>
1310 + <div>
1311 + <h4 class="center">Live stream or premiere directions</h4>
1312 + <?php
1313 + if (!self::has_api_key())
1314 + {
1315 + echo str_replace('###', 'live stream', self::$get_api_key_msg);
1316 + }
1317 + else
1318 + {
1319 + ?>
1320 + <div class="livestream-tabs">
1321 + <ul>
1322 + <li><a href="#livestream-tabs-2">Channel-based livestream (upgrade required)</a></li>
1323 + <li><a href="#livestream-tabs-1">Direct link to livestream or premiere video</a></li>
1324 + </ul>
1325 + <div id="livestream-tabs-1">
1326 + <p>
1327 + This will embed a specific live stream or premiere video.
1328 + </p>
1329 + <ol>
1330 + <li>
1331 + Paste in the direct URL of the live stream or premiere below and click Submit. <br> Example: https://www.youtube.com/watch?v=<strong>5qap5aO4i9A</strong>
1332 + </li>
1333 + <li>
1334 + On the next screen, customize or insert your video.
1335 + </li>
1336 + </ol>
1337 + <form name="wizform_live" method="post" action="" class="wizform" id="wizform_live">
1338 + <?php wp_nonce_field('_epyt_wiz', '_epyt_nonce', true); ?>
1339 + <div class="center txt-button-align">
1340 + <input name="txtUrlLive" maxlength="200" id="txtUrlLive" class="ui-widget ui-widget-content ui-corner-all" placeholder="Paste YouTube link here" type="text"> <button name="wizform_submit" class="ui-button ui-widget ui-corner-all" type="submit" value="step1_live">Submit</button>
1341 + </div>
1342 + </form>
1343 + <?php echo $step1_live_errors ? '<p class="orange bold">' . $step1_live_errors . '</p>' : ''; ?>
1344 + </div>
1345 + <div id="livestream-tabs-2">
1346 + <div class="alert">
1347 + <p>
1348 + Unfortunately, Google has recently removed their YouTube API feature that used to support automatic channel-based live streams. It appears they won't change things back. However, you do have a couple of choices:
1349 + </p>
1350 + <ol>
1351 + <li>Use "Direct link" live streams, as explained in the other tab. The trade-off is that you will have to manually post and take down your future live streams every time they start and when they end, respectively.</li>
1352 + <li>Or <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" target="_blank">upgrade to Pro</a>, which has a solution that brings back all the "set it and forget it" features of channel-based embeds. We spent a significant amount of time developing a stable, long-term solution around YouTube's limitations, so we are releasing this effort exclusively to our Pro customers.</li>
1353 + </ol>
1354 +
1355 + </div>
1356 + <?php echo $step1_livechannel_errors ? '<p class="orange bold">' . $step1_livechannel_errors . '</p>' : ''; ?>
1357 + </div>
1358 + </div>
1359 + <?php
1360 + }
1361 + ?>
1362 + </div>
1363 + <h3 class="header-go"> <a href="<?php echo self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=wizardacc'; ?>">Check my performance, blocked countries, deleted videos, etc. (PRO) </a></h3>
1364 + <div class="header-go-content"></div>
1365 + </div>
1366 + <?php
1367 + }
1368 + ?>
1369 + </div>
1370 + <?php
1371 + }
1372 +
1373 + public static function has_api_key()
1374 + {
1375 + if (isset(self::$alloptions[self::$opt_apikey]) && strlen(trim(self::$alloptions[self::$opt_apikey])) > 0)
1376 + {
1377 + return true;
1378 + }
1379 +
1380 + return false;
1381 + }
1382 +
1383 + public static function get_live_snippet($channel)
1384 + {
1385 + $apiEndpoint = 'https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&maxResults=1&type=video&eventType=live&safeSearch=none&videoEmbeddable=true&key=' . self::$alloptions[self::$opt_apikey]
1386 + . '&channelId=' . urlencode($channel);
1387 + $apiResult = wp_remote_get($apiEndpoint, array('timeout' => self::$curltimeout, 'headers' => array('referer' => site_url())));
1388 +
1389 + if (is_wp_error($apiResult))
1390 + {
1391 + return false;
1392 + }
1393 +
1394 + $jsonResult = json_decode($apiResult['body']);
1395 +
1396 + if (isset($jsonResult->error))
1397 + {
1398 + return false;
1399 + }
1400 +
1401 + if (isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items) && count($jsonResult->items))
1402 + {
1403 + return $jsonResult->items[0];
1404 + }
1405 +
1406 + return false;
1407 + }
1408 +
1409 + public static function get_video_snippet($vid)
1410 + {
1411 + $apiEndpoint = 'https://www.googleapis.com/youtube/v3/videos?part=snippet&maxResults=1&key=' . self::$alloptions[self::$opt_apikey]
1412 + . '&id=' . urlencode($vid);
1413 + $apiResult = wp_remote_get($apiEndpoint, array('timeout' => self::$curltimeout, 'headers' => array('referer' => site_url())));
1414 +
1415 + if (is_wp_error($apiResult))
1416 + {
1417 + return false;
1418 + }
1419 +
1420 + $jsonResult = json_decode($apiResult['body']);
1421 +
1422 + if (isset($jsonResult->error))
1423 + {
1424 + return false;
1425 + }
1426 +
1427 + if (isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items) && count($jsonResult->items))
1428 + {
1429 + return $jsonResult->items[0];
1430 + }
1431 +
1432 + return false;
1433 + }
1434 +
1435 + public static function get_channel_snippet($channid)
1436 + {
1437 + $apiEndpoint = 'https://www.googleapis.com/youtube/v3/channels?part=contentDetails,snippet&key=' . self::$alloptions[self::$opt_apikey]
1438 + . '&id=' . urlencode($channid);
1439 + $apiResult = wp_remote_get($apiEndpoint, array('timeout' => self::$curltimeout, 'headers' => array('referer' => site_url())));
1440 +
1441 + if (is_wp_error($apiResult))
1442 + {
1443 + return false;
1444 + }
1445 +
1446 + $jsonResult = json_decode($apiResult['body']);
1447 +
1448 + if (isset($jsonResult->error))
1449 + {
1450 + return false;
1451 + }
1452 +
1453 + if (isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items) && count($jsonResult->items))
1454 + {
1455 + return $jsonResult->items[0];
1456 + }
1457 +
1458 + return false;
1459 + }
1460 +
1461 + public static function clean_api_error($raw_message)
1462 + {
1463 + return htmlspecialchars(strip_tags(preg_replace('@&key=[^& ]+@i', '&key=*******', $raw_message)), ENT_QUOTES, 'UTF-8');
1464 + }
1465 +
1466 + public static function clean_api_error_html($raw_message, $add_boilerplate)
1467 + {
1468 + $clean_html = '<div>Sorry, there was a YouTube error.</div>';
1469 + if (current_user_can('manage_options'))
1470 + {
1471 + $clean_html = '<div>Sorry, there was a YouTube API error: <em>' . self::clean_api_error($raw_message) . '</em>' .
1472 + ( $add_boilerplate ? self::$boilerplate_api_error_message : '' ) .
1473 + '</div>';
1474 + }
1475 + return $clean_html;
1476 + }
1477 +
1478 + public static function get_search_page($options)
1479 + {
1480 + $gallobj = new stdClass();
1481 + $pageSize = 30;
1482 +
1483 + if (!self::has_api_key())
1484 + {
1485 + $gallobj->html = '<div>' . str_replace('###', 'search', self::$get_api_key_msg) . '</div>';
1486 + return $gallobj;
1487 + }
1488 +
1489 + $apiEndpoint = 'https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=' . $pageSize . '&type=video&safeSearch=none&videoEmbeddable=true&key=' . self::$alloptions[self::$opt_apikey]
1490 + . '&q=' . urlencode($options->q);
1491 + if (!empty($options->pageToken))
1492 + {
1493 + $apiEndpoint .= '&pageToken=' . $options->pageToken;
1494 + }
1495 +
1496 + $code = '';
1497 + $apiResult = wp_remote_get($apiEndpoint, array('timeout' => self::$curltimeout, 'headers' => array('referer' => site_url())));
1498 +
1499 + if (is_wp_error($apiResult))
1500 + {
1501 + $gallobj->html = self::clean_api_error_html($apiResult->get_error_message(), true);
1502 + return $gallobj;
1503 + }
1504 +
1505 + $jsonResult = json_decode($apiResult['body']);
1506 +
1507 + if (isset($jsonResult->error))
1508 + {
1509 + if (isset($jsonResult->error->message))
1510 + {
1511 + $gallobj->html = self::clean_api_error_html($jsonResult->error->message, true);
1512 + return $gallobj;
1513 + }
1514 + $gallobj->html = '<div>Sorry, there may be an issue with your YouTube API key. ' . self::$boilerplate_api_error_message . '</div>';
1515 + return $gallobj;
1516 + }
1517 +
1518 + $totalResults = $jsonResult->pageInfo->totalResults;
1519 +
1520 + $nextPageToken = '';
1521 + $prevPageToken = '';
1522 + if (isset($jsonResult->nextPageToken))
1523 + {
1524 + $nextPageToken = $jsonResult->nextPageToken;
1525 + }
1526 +
1527 + if (isset($jsonResult->prevPageToken))
1528 + {
1529 + $prevPageToken = $jsonResult->prevPageToken;
1530 + }
1531 +
1532 + $cnt = 0;
1533 +
1534 + $code .= '<div class="epyt-search-results">';
1535 +
1536 + if (isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items))
1537 + {
1538 + foreach ($jsonResult->items as $item)
1539 + {
1540 +
1541 + $thumb = new stdClass();
1542 +
1543 + $thumb->id = isset($item->snippet->resourceId->videoId) ? $item->snippet->resourceId->videoId : null;
1544 + $thumb->id = $thumb->id ? $thumb->id : (isset($item->id->videoId) ? $item->id->videoId : null);
1545 +
1546 + if ($thumb->id)
1547 + {
1548 + $thumb->title = $item->snippet->title;
1549 +
1550 + if (isset($item->snippet->thumbnails->high->url))
1551 + {
1552 + $thumb->img = $item->snippet->thumbnails->high->url;
1553 + $thumb->quality = 'high';
1554 + }
1555 + elseif (isset($item->snippet->thumbnails->default->url))
1556 + {
1557 + $thumb->img = $item->snippet->thumbnails->default->url;
1558 + $thumb->quality = 'default';
1559 + }
1560 + elseif (isset($item->snippet->thumbnails->medium->url))
1561 + {
1562 + $thumb->img = $item->snippet->thumbnails->medium->url;
1563 + $thumb->quality = 'medium';
1564 + }
1565 + else
1566 + {
1567 + $thumb->img = plugins_url('/images/deleted-video-thumb.png', __FILE__);
1568 + $thumb->quality = 'medium';
1569 + }
1570 +
1571 + $code .= self::get_search_result_html($thumb, $options);
1572 + $cnt++;
1573 + $code .= '<div class="clear-both"></div>';
1574 + }
1575 + }
1576 + }
1577 +
1578 + $code .= '<div class="clear-both"></div></div>';
1579 +
1580 + $totalPages = ceil($totalResults / $pageSize);
1581 + $pagination = '<div class="epyt-pagination">';
1582 +
1583 + $txtprev = self::$alloptions[self::$opt_gallery_customarrows] ? self::$alloptions[self::$opt_gallery_customprev] : _('Prev');
1584 + $pagination .= '<div tabindex="0" role="button" class="epyt-pagebutton epyt-prev ' . (empty($prevPageToken) ? ' hide ' : '') . '" data-q="' . esc_attr($options->q)
1585 + . '" data-pagetoken="' . esc_attr($prevPageToken)
1586 + . '"><div class="epyt-arrow">&laquo;</div> <div>' . $txtprev . '</div></div>';
1587 +
1588 +
1589 + $pagination .= '<div class="epyt-pagenumbers ' . ($totalPages > 1 ? '' : 'hide') . '">';
1590 + $pagination .= '<div class="epyt-current">1</div><div class="epyt-pageseparator"> / </div><div class="epyt-totalpages">' . $totalPages . '</div>';
1591 + $pagination .= '</div>';
1592 +
1593 + $txtnext = self::$alloptions[self::$opt_gallery_customarrows] ? self::$alloptions[self::$opt_gallery_customnext] : _('Next');
1594 + $pagination .= '<div tabindex="0" role="button" class="epyt-pagebutton epyt-next' . (empty($nextPageToken) ? ' hide ' : '') . '" data-q="' . esc_attr($options->q)
1595 + . '" data-pagetoken="' . esc_attr($nextPageToken)
1596 + . '"><div>' . $txtnext . '</div> <div class="epyt-arrow">&raquo;</div></div>';
1597 +
1598 + $pagination .= '<div class="epyt-loader"><img alt="loading" width="16" height="11" src="' . plugins_url('images/gallery-page-loader.gif', __FILE__) . '"></div>';
1599 + $pagination .= '</div>';
1600 +
1601 + $code = $pagination . $code . $pagination;
1602 + $gallobj->html = $code;
1603 + return $gallobj;
1604 + }
1605 +
1606 + public static function get_search_result_html($thumb, $options)
1607 + {
1608 + $get_pro_link = self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=searchresult';
1609 + $escId = esc_attr($thumb->id);
1610 + $code = '';
1611 +
1612 + $code .= '<div class="resultdiv" data-vid="' . $escId . '">
1613 + <div class="resultinfo">
1614 + <a class="pointer thumb load-movie" style="background-image: url(' . esc_url($thumb->img) . ')"></a>
1615 + <a class="resulttitle pointer load-movie"><span class="ui-icon ui-icon-circle-triangle-e"></span> ' . sanitize_text_field($thumb->title) . '</a>
1616 + <br>
1617 + <span style="display: block;" id="scrollwatch' . $escId . '"></span>
1618 + <div class="resultsubinfo">
1619 + <p>
1620 + <a class="ui-button ui-widget ui-corner-all" href="' . $get_pro_link . '" target="_blank"><span class="ui-icon ui-icon-gear"></span> Customize (PRO)</a>
1621 + &nbsp; <a class="ui-button ui-widget ui-corner-all inserttopost" rel="[embedyt] https://www.youtube.com/watch?v=' . $escId . '[/embedyt]"><span class="ui-icon ui-icon-arrowthickstop-1-s"></span> Insert Into Editor</a>
1622 + </p>
1623 + &nbsp; Or Copy Code:
1624 + <span class="copycode">[embedyt] https://www.youtube.com/watch?v=' . $escId . '[/embedyt]</span>
1625 + </div>
1626 + </div>
1627 + <div class="clearboth"></div>
1628 + </div>
1629 + <div id="moviecontainer' . $escId . '" class="center moviecontainer relative" style="display: none;">
1630 + Preview: <a id="closeme' . $escId . '" class="closeme" data-vid="' . $escId . '">
1631 + &times;
1632 + </a>
1633 + <div id="watch' . $escId . '">
1634 + </div>
1635 + </div>';
1636 +
1637 + return $code;
1638 + }
1639 +
1640 + public static function user_in_roles_any($user, $roles)
1641 + {
1642 + foreach ($user->roles as $idx => $r)
1643 + {
1644 + if (in_array($r, $roles))
1645 + {
1646 + return true;
1647 + }
1648 + }
1649 + return false;
1650 + }
1651 +
1652 + public static function is_restrict_wizard()
1653 + {
1654 + $curr_user = wp_get_current_user();
1655 + if (
1656 + $curr_user->ID // logged in
1657 + && isset(self::$alloptions[self::$opt_restrict_wizard]) && self::$alloptions[self::$opt_restrict_wizard] == 1 // restricting
1658 + && is_array(self::$alloptions[self::$opt_restrict_wizard_roles]) && !self::user_in_roles_any($curr_user, self::$alloptions[self::$opt_restrict_wizard_roles])
1659 + )
1660 + {
1661 + return true;
1662 + }
1663 + return false;
1664 + }
1665 +
1666 + public static function media_button_wizard()
1667 + {
1668 + if (self::is_restrict_wizard())
1669 + {
1670 + return;
1671 + }
1672 +
1673 + add_thickbox();
1674 +
1675 + $wizhref = admin_url('admin.php?page=youtube-ep-wizard') .
1676 + '&random=' . rand(1, 1000) .
1677 + '&TB_iframe=true&width=950&height=800';
1678 + ?>
1679 + <a href="<?php echo esc_attr($wizhref); ?>" class="thickbox button ytprefs_media_link" id="ytprefs_wiz_button" title="Visual YouTube Search Tool and Wizard - For easier embedding"><span></span> YouTube</a>
1680 + <?php
1681 + }
1682 +
1683 + public static function check_double_plugin_warning()
1684 + {
1685 + if (is_plugin_active('embedplus-for-wordpress/embedplus.php'))
1686 + {
1687 + add_action('admin_notices', array(self::class, "double_plugin_warning"));
1688 + }
1689 + }
1690 +
1691 + public static function double_plugin_warning()
1692 + {
1693 + global $pagenow;
1694 + $user_id = get_current_user_id();
1695 + if ($pagenow != 'plugins.php' || get_user_meta($user_id, 'embedplus_double_plugin_warning', true) != 1)
1696 + {
1697 + //echo '<div class="error">' . $_SERVER['QUERY_STRING'] .'</div>';
1698 + if ($pagenow == 'plugins.php' || strpos($_SERVER['QUERY_STRING'], 'youtube-my-preferences') !== false ||
1699 + strpos($_SERVER['QUERY_STRING'], 'embedplus-video-analytics-dashboard') !== false ||
1700 + strpos($_SERVER['QUERY_STRING'], 'youtube-ep-analytics-dashboard') !== false ||
1701 + strpos($_SERVER['QUERY_STRING'], 'embedplus-official-options') !== false)
1702 + {
1703 + ?>
1704 + <style type="text/css">
1705 + .embedpluswarning img
1706 + {
1707 + vertical-align: text-bottom;
1708 + }
1709 + div.bgyellow {background-color: #FCFC94; position: relative;}
1710 + a.epxout, a.epxout:hover {font-weight: bold; color: #ffffff; background-color: #ff8888; text-decoration: none;
1711 + border-radius: 20px; font-size: 15px; position: absolute; top: 3px; right: 3px;
1712 + line-height: 20px; text-align: center; width: 20px; height: 20px; display: block; cursor: pointer;}
1713 + </style>
1714 + <div class="error bgyellow embedpluswarningbox">
1715 + <p class="embedpluswarning">
1716 + <?php
1717 + if ($pagenow == 'plugins.php')
1718 + {
1719 + echo '<a class="epxout">&times;</a>';
1720 + }
1721 + ?>
1722 + Seems like you have two different YouTube plugins by the EmbedPlus Team installed; this one and <b>Advanced YouTube Embed.</b> We strongly suggest keeping only the one you prefer, so that they don't conflict with each other while trying to create your embeds.
1723 + </p>
1724 + </div>
1725 +
1726 + <script type="text/javascript">
1727 + (function ($)
1728 + {
1729 + $(document).ready(function ()
1730 + {
1731 + $('.epxout').on('click', function ()
1732 + {
1733 + $.ajax({
1734 + type: "post",
1735 + dataType: "json",
1736 + timeout: 30000,
1737 + url: window._EPYTA_ ? window._EPYTA_.wpajaxurl : ajaxurl,
1738 + data: {action: 'my_embedplus_dismiss_double_plugin_warning'},
1739 + success: function (response)
1740 + {
1741 + if (response.type === "success")
1742 + {
1743 + $(".embedpluswarningbox").hide();
1744 + }
1745 + },
1746 + error: function (xhr, ajaxOptions, thrownError)
1747 + {
1748 + },
1749 + complete: function ()
1750 + {
1751 + }
1752 + });
1753 + });
1754 + });
1755 + })(jQuery);</script>
1756 + <?php
1757 + }
1758 + }
1759 + }
1760 +
1761 + public static function my_embedplus_dismiss_double_plugin_warning()
1762 + {
1763 + $result = array();
1764 + if (self::is_ajax())
1765 + {
1766 + if (!current_user_can('manage_options'))
1767 + {
1768 + wp_send_json_error('Unauthorized');
1769 + die();
1770 + }
1771 + $user_id = get_current_user_id();
1772 + update_user_meta($user_id, 'embedplus_double_plugin_warning', 1);
1773 + $result['type'] = 'success';
1774 + echo json_encode($result);
1775 + }
1776 + else
1777 + {
1778 + $result['type'] = 'error';
1779 + header("Location: " . $_SERVER["HTTP_REFERER"]);
1780 + }
1781 + die();
1782 + }
1783 +
1784 + public static function jsvars()
1785 + {
1786 + $loggedin = current_user_can('edit_posts');
1787 + if (!($loggedin && self::$alloptions[self::$opt_admin_off_scripts]))
1788 + {
1789 + ?>
1790 + <script data-cfasync="false">
1791 + window._EPYT_ = window._EPYT_ || {
1792 + ajaxurl: "<?php echo admin_url('admin-ajax.php'); ?>",
1793 + security: "<?php echo wp_create_nonce('embedplus-nonce'); ?>",
1794 + gallery_scrolloffset: <?php echo intval(self::$alloptions[self::$opt_gallery_scrolloffset]) ?>,
1795 + eppathtoscripts: "<?php echo plugins_url('scripts/', __FILE__); ?>",
1796 + eppath: "<?php echo plugins_url('/', __FILE__); ?>",
1797 + epresponsiveselector: <?php echo self::get_responsiveselector(); ?>,
1798 + version: "<?php echo esc_attr(self::$alloptions[self::$opt_version]) ?>",
1799 + epdovol: true,
1800 + evselector: '<?php echo self::get_evselector(); ?>',
1801 + ajax_compat: <?php echo self::$alloptions[self::$opt_ajax_compat] == '1' ? 'true' : 'false' ?>,
1802 + maxres_facade: '<?php echo esc_attr(self::$alloptions[self::$opt_maxres_facade]) ?>',
1803 + ytapi_load: '<?php echo esc_attr(self::$alloptions[self::$opt_ytapi_load]) ?>',
1804 + pause_others: <?php echo self::$alloptions[self::$opt_pause_others] == '1' ? 'true' : 'false' ?>,
1805 + facade_mode: <?php echo self::$alloptions[self::$opt_facade_mode] == '1' ? 'true' : 'false' ?>,
1806 + not_live_on_channel: <?php echo self::$alloptions[self::$opt_not_live_on_channel] == '1' ? 'true' : 'false' ?>,
1807 + stopMobileBuffer: <?php echo self::$alloptions[self::$opt_stop_mobile_buffer] == '1' ? 'true' : 'false' ?>
1808 + };</script>
1809 + <?php
1810 + }
1811 + }
1812 +
1813 + public static function fitvids()
1814 + {
1815 + $loggedin = current_user_can('edit_posts');
1816 + if (!($loggedin && self::$alloptions[self::$opt_admin_off_scripts]) && (self::$alloptions[self::$opt_responsive] || self::$alloptions[self::$opt_widgetfit]))
1817 + {
1818 + wp_enqueue_script('__ytprefsfitvids__', plugins_url('scripts/fitvids' . self::$min . '.js', __FILE__), array('__ytprefs__'), self::$version, true);
1819 + }
1820 + }
1821 +
1822 + public static function initoptions()
1823 + {
1824 + global $wpdb;
1825 + $arroptions = get_option(self::$opt_alloptions);
1826 + if ($arroptions !== false)
1827 + {
1828 + $bak = str_replace('.', '_', $arroptions[self::$opt_version]);
1829 + add_option(self::$opt_alloptions . '_backup_' . $bak, $arroptions, '', 'no');
1830 + $sql = "update " . $wpdb->options . " set autoload = 'no' where option_name like '" . self::$opt_alloptions . "\_backup\_%'";
1831 + $wpdb->query($sql);
1832 + }
1833 +
1834 + // backup settings for migration
1835 + if (isset($arroptions[self::$opt_pro]) && strlen(trim($arroptions[self::$opt_pro])) > 10)
1836 + {
1837 + add_option(self::$opt_alloptions . '_migrate', $arroptions);
1838 + }
1839 +
1840 + //vanilla defaults
1841 + $_center = 0;
1842 + $_glance = 0;
1843 + $_autoplay = 0;
1844 + $_cc_load_policy = 0;
1845 + $_cc_lang_pref = '';
1846 + $_iv_load_policy = 1;
1847 + $_loop = 0;
1848 + $_rel = 1;
1849 + $_fs = 1;
1850 + $_theme = 'dark';
1851 + $_color = 'red';
1852 + $_autohide = 2;
1853 + $_pro = '';
1854 + $_nocookie = 0;
1855 + $_gb_compat = 1;
1856 + $_facade_mode = 0;
1857 + $_facade_autoplay = 1;
1858 + $_gdpr_consent = 0;
1859 + $_gdpr_consent_message = self::$dft_gdpr_consent_message;
1860 + $_gdpr_consent_button = 'Accept YouTube Content';
1861 + $_playlistorder = 0;
1862 + $_acctitle = 0;
1863 + $_migrate = 0;
1864 + $_migrate_youtube = 0;
1865 + $_migrate_embedplusvideo = 0;
1866 + $_controls = 1;
1867 + $_disablekb = 0;
1868 + $_oldspacing = 1;
1869 + $_frontend_only = 1;
1870 + $_responsive = 0;
1871 + $_responsive_all = 1;
1872 + $_widgetfit = 1;
1873 + $_evselector_light = 0;
1874 + $_stop_mobile_buffer = 1;
1875 + $_restrict_wizard = 0;
1876 + $_restrict_wizard_roles = self::$dft_roles;
1877 + $_ajax_compat = 0;
1878 + $_maxres_facade = 'eager';
1879 + $_ytapi_load = 'light';
1880 + $_defaultdims = 1;
1881 + $_defaultwidth = isset($GLOBALS['content_width']) && is_numeric($GLOBALS['content_width']) ? intval($GLOBALS['content_width']) : 800;
1882 + $_defaultheight = intval($_defaultwidth * 9.0 / 16.0);
1883 + $_playsinline = 0;
1884 + $_origin = 0;
1885 + $_pause_others = 0;
1886 + $_defaultvol = 0;
1887 + $_vol = '';
1888 + $_apikey = '';
1889 + $_hl = '';
1890 + $_dohl = 0;
1891 + $_gallery_columns = 3;
1892 + $_gallery_collapse_grid = 0;
1893 + $_gallery_collapse_grid_breaks = self::$dft_bpts;
1894 + $_gallery_scrolloffset = 20;
1895 + $_gallery_hideprivate = 1;
1896 + $_gallery_showtitle = 1;
1897 + $_gallery_showpaging = 1;
1898 + $_gallery_autonext = 0;
1899 + $_gallery_thumbplay = 1;
1900 + $_gallery_channelsub = 0;
1901 + $_gallery_channelsublink = '';
1902 + $_gallery_channelsubtext = 'Subscribe to my channel';
1903 + $_gallery_customarrows = 0;
1904 + $_gallery_customprev = 'Prev';
1905 + $_gallery_customnext = 'Next';
1906 + $_gallery_pagesize = 15;
1907 + $_not_live_content = '';
1908 + $_not_live_on = 0;
1909 + $_not_live_on_channel = 0;
1910 + $_debugmode = 0;
1911 + $_uninstall_data = 0;
1912 + $_admin_off_scripts = 0;
1913 + $_defer_js = 0;
1914 + $_defer_jquery = 0;
1915 + $_ajax_save = 1;
1916 + $_show_pointer = 1;
1917 + $_onboarded = 0;
1918 + $_old_script_method = 0;
1919 +
1920 + //update vanilla to previous settings if exists
1921 + if ($arroptions !== false)
1922 + {
1923 + $_center = self::tryget($arroptions, self::$opt_center, 0);
1924 + $_glance = self::tryget($arroptions, self::$opt_glance, $_glance);
1925 + $_autoplay = self::tryget($arroptions, self::$opt_autoplay, 0);
1926 + $_debugmode = self::tryget($arroptions, self::$opt_debugmode, 0);
1927 + $_uninstall_data = self::tryget($arroptions, self::$opt_uninstall_data, 0);
1928 + $_old_script_method = self::tryget($arroptions, self::$opt_old_script_method, 0);
1929 + $_cc_load_policy = self::tryget($arroptions, self::$opt_cc_load_policy, 0);
1930 + $_cc_lang_pref = self::tryget($arroptions, self::$opt_cc_lang_pref, $_cc_lang_pref);
1931 + $_iv_load_policy = self::tryget($arroptions, self::$opt_iv_load_policy, 1);
1932 + $_loop = self::tryget($arroptions, self::$opt_loop, 0);
1933 + $_rel = self::tryget($arroptions, self::$opt_rel, 1);
1934 + $_fs = self::tryget($arroptions, self::$opt_fs, 1);
1935 + $_playsinline = self::tryget($arroptions, self::$opt_playsinline, 0);
1936 + $_origin = self::tryget($arroptions, self::$opt_origin, 1);
1937 + $_hl = self::tryget($arroptions, self::$opt_hl, '');
1938 + $_dohl = self::tryget($arroptions, self::$opt_dohl, 0);
1939 + $_theme = self::tryget($arroptions, self::$opt_theme, 'dark');
1940 + $_color = self::tryget($arroptions, self::$opt_color, 'red');
1941 + $_autohide = self::tryget($arroptions, self::$opt_autohide, 2);
1942 + $_pro = self::tryget($arroptions, self::$opt_pro, '');
1943 + $_nocookie = self::tryget($arroptions, self::$opt_nocookie, 0);
1944 + $_gb_compat = self::tryget($arroptions, self::$opt_gb_compat, $_gb_compat);
1945 + $_facade_mode = self::tryget($arroptions, self::$opt_facade_mode, $_facade_mode);
1946 + $_facade_autoplay = self::tryget($arroptions, self::$opt_facade_autoplay, $_facade_autoplay);
1947 + $_gdpr_consent = self::tryget($arroptions, self::$opt_gdpr_consent, $_gdpr_consent);
1948 + $_gdpr_consent_message = self::tryget($arroptions, self::$opt_gdpr_consent_message, $_gdpr_consent_message);
1949 + $_gdpr_consent_button = self::tryget($arroptions, self::$opt_gdpr_consent_button, $_gdpr_consent_button);
1950 + $_playlistorder = self::tryget($arroptions, self::$opt_playlistorder, 0);
1951 + $_acctitle = self::tryget($arroptions, self::$opt_acctitle, 0);
1952 + $_migrate = self::tryget($arroptions, self::$opt_migrate, 0);
1953 + $_migrate_youtube = self::tryget($arroptions, self::$opt_migrate_youtube, 0);
1954 + $_migrate_embedplusvideo = self::tryget($arroptions, self::$opt_migrate_embedplusvideo, 0);
1955 + $_controls = self::tryget($arroptions, self::$opt_controls, 1);
1956 + $_controls = $_controls == 2 ? 1 : $_controls;
1957 + $_disablekb = self::tryget($arroptions, self::$opt_disablekb, 0);
1958 + $_oldspacing = self::tryget($arroptions, self::$opt_oldspacing, 1);
1959 + $_frontend_only = self::tryget($arroptions, self::$opt_frontend_only, $_frontend_only);
1960 + $_responsive = self::tryget($arroptions, self::$opt_responsive, $_responsive);
1961 + $_responsive_all = self::tryget($arroptions, self::$opt_responsive_all, $_responsive_all);
1962 + $_widgetfit = self::tryget($arroptions, self::$opt_widgetfit, 1);
1963 + $_evselector_light = self::tryget($arroptions, self::$opt_evselector_light, 0);
1964 + $_stop_mobile_buffer = self::tryget($arroptions, self::$opt_stop_mobile_buffer, 1);
1965 + $_restrict_wizard = self::tryget($arroptions, self::$opt_restrict_wizard, 0);
1966 + $_restrict_wizard_roles = self::tryget($arroptions, self::$opt_restrict_wizard_roles, self::$dft_roles);
1967 + $_ajax_compat = self::tryget($arroptions, self::$opt_ajax_compat, 0);
1968 + $_maxres_facade = self::tryget($arroptions, self::$opt_maxres_facade, $_maxres_facade);
1969 + $_ytapi_load = self::tryget($arroptions, self::$opt_ytapi_load, $_ytapi_load);
1970 + $_defaultdims = self::tryget($arroptions, self::$opt_defaultdims, $_defaultdims);
1971 + $_defaultwidth = self::tryget($arroptions, self::$opt_defaultwidth, $_defaultwidth);
1972 + $_defaultheight = self::tryget($arroptions, self::$opt_defaultheight, $_defaultheight);
1973 + $_pause_others = self::tryget($arroptions, self::$opt_pause_others, $_pause_others);
1974 + $_defaultvol = self::tryget($arroptions, self::$opt_defaultvol, 0);
1975 + $_vol = self::tryget($arroptions, self::$opt_vol, '');
1976 + $_apikey = self::tryget($arroptions, self::$opt_apikey, '');
1977 + $_gallery_pagesize = self::tryget($arroptions, self::$opt_gallery_pagesize, 15);
1978 + $_gallery_columns = self::tryget($arroptions, self::$opt_gallery_columns, 3);
1979 + $_gallery_collapse_grid = self::tryget($arroptions, self::$opt_gallery_collapse_grid, 0);
1980 + $_gallery_collapse_grid_breaks = self::tryget($arroptions, self::$opt_gallery_collapse_grid_breaks, self::$dft_bpts);
1981 + $_gallery_scrolloffset = self::tryget($arroptions, self::$opt_gallery_scrolloffset, 20);
1982 + $_gallery_hideprivate = self::tryget($arroptions, self::$opt_gallery_hideprivate, $_gallery_hideprivate);
1983 + $_gallery_showtitle = self::tryget($arroptions, self::$opt_gallery_showtitle, 1);
1984 + $_gallery_showpaging = self::tryget($arroptions, self::$opt_gallery_showpaging, 1);
1985 + $_gallery_autonext = self::tryget($arroptions, self::$opt_gallery_autonext, 0);
1986 + $_gallery_thumbplay = self::tryget($arroptions, self::$opt_gallery_thumbplay, 1);
1987 + $_gallery_channelsub = self::tryget($arroptions, self::$opt_gallery_channelsub, $_gallery_channelsub);
1988 + $_gallery_channelsublink = self::tryget($arroptions, self::$opt_gallery_channelsublink, $_gallery_channelsublink);
1989 + $_gallery_channelsubtext = self::tryget($arroptions, self::$opt_gallery_channelsubtext, $_gallery_channelsubtext);
1990 + $_gallery_customarrows = self::tryget($arroptions, self::$opt_gallery_customarrows, $_gallery_customarrows);
1991 + $_gallery_customnext = self::tryget($arroptions, self::$opt_gallery_customnext, $_gallery_customnext);
1992 + $_gallery_customprev = self::tryget($arroptions, self::$opt_gallery_customprev, $_gallery_customprev);
1993 + $_not_live_content = self::tryget($arroptions, self::$opt_not_live_content, $_not_live_content);
1994 + $_not_live_content = empty($_not_live_content) ? $_not_live_content : trim($_not_live_content);
1995 + $_not_live_on = self::tryget($arroptions, self::$opt_not_live_on, empty($_not_live_content) ? 0 : $_not_live_on);
1996 + $_not_live_on_channel = self::tryget($arroptions, self::$opt_not_live_on_channel, $_not_live_on_channel);
1997 + $_admin_off_scripts = self::tryget($arroptions, self::$opt_admin_off_scripts, $_admin_off_scripts);
1998 + $_defer_js = self::tryget($arroptions, self::$opt_defer_js, $_defer_js);
1999 + $_defer_jquery = self::tryget($arroptions, self::$opt_defer_jquery, $_defer_jquery);
2000 + $_ajax_save = self::tryget($arroptions, self::$opt_ajax_save, $_ajax_save);
2001 + $_show_pointer = self::tryget($arroptions, self::$opt_show_pointer, $_show_pointer);
2002 + $_onboarded = 0; // self::tryget($arroptions, self::$opt_onboarded, $_onboarded);
2003 + }
2004 + else
2005 + {
2006 + $_oldspacing = 0;
2007 + }
2008 +
2009 + $all = array(
2010 + self::$opt_version => self::$version,
2011 + self::$opt_center => $_center,
2012 + self::$opt_glance => $_glance,
2013 + self::$opt_autoplay => $_autoplay,
2014 + self::$opt_cc_load_policy => $_cc_load_policy,
2015 + self::$opt_cc_lang_pref => $_cc_lang_pref,
2016 + self::$opt_iv_load_policy => $_iv_load_policy,
2017 + self::$opt_loop => $_loop,
2018 + self::$opt_rel => $_rel,
2019 + self::$opt_fs => $_fs,
2020 + self::$opt_playsinline => $_playsinline,
2021 + self::$opt_origin => $_origin,
2022 + self::$opt_autohide => $_autohide,
2023 + self::$opt_hl => $_hl,
2024 + self::$opt_dohl => $_dohl,
2025 + self::$opt_theme => $_theme,
2026 + self::$opt_color => $_color,
2027 + self::$opt_pro => $_pro,
2028 + self::$opt_nocookie => $_nocookie,
2029 + self::$opt_gb_compat => $_gb_compat,
2030 + self::$opt_facade_mode => $_facade_mode,
2031 + self::$opt_facade_autoplay => $_facade_autoplay,
2032 + self::$opt_gdpr_consent => $_gdpr_consent,
2033 + self::$opt_gdpr_consent_message => $_gdpr_consent_message,
2034 + self::$opt_gdpr_consent_button => $_gdpr_consent_button,
2035 + self::$opt_playlistorder => $_playlistorder,
2036 + self::$opt_acctitle => $_acctitle,
2037 + self::$opt_migrate => $_migrate,
2038 + self::$opt_migrate_youtube => $_migrate_youtube,
2039 + self::$opt_migrate_embedplusvideo => $_migrate_embedplusvideo,
2040 + self::$opt_controls => $_controls,
2041 + self::$opt_disablekb => $_disablekb,
2042 + self::$opt_oldspacing => $_oldspacing,
2043 + self::$opt_frontend_only => $_frontend_only,
2044 + self::$opt_responsive => $_responsive,
2045 + self::$opt_responsive_all => $_responsive_all,
2046 + self::$opt_widgetfit => $_widgetfit,
2047 + self::$opt_evselector_light => $_evselector_light,
2048 + self::$opt_stop_mobile_buffer => $_stop_mobile_buffer,
2049 + self::$opt_restrict_wizard => $_restrict_wizard,
2050 + self::$opt_restrict_wizard_roles => $_restrict_wizard_roles,
2051 + self::$opt_ajax_compat => $_ajax_compat,
2052 + self::$opt_maxres_facade => $_maxres_facade,
2053 + self::$opt_ytapi_load => $_ytapi_load,
2054 + self::$opt_defaultdims => $_defaultdims,
2055 + self::$opt_defaultwidth => $_defaultwidth,
2056 + self::$opt_defaultheight => $_defaultheight,
2057 + self::$opt_pause_others => $_pause_others,
2058 + self::$opt_defaultvol => $_defaultvol,
2059 + self::$opt_vol => $_vol,
2060 + self::$opt_apikey => $_apikey,
2061 + self::$opt_gallery_columns => $_gallery_columns,
2062 + self::$opt_gallery_collapse_grid => $_gallery_collapse_grid,
2063 + self::$opt_gallery_collapse_grid_breaks => $_gallery_collapse_grid_breaks,
2064 + self::$opt_gallery_scrolloffset => $_gallery_scrolloffset,
2065 + self::$opt_gallery_hideprivate => $_gallery_hideprivate,
2066 + self::$opt_gallery_showtitle => $_gallery_showtitle,
2067 + self::$opt_gallery_showpaging => $_gallery_showpaging,
2068 + self::$opt_gallery_autonext => $_gallery_autonext,
2069 + self::$opt_gallery_thumbplay => $_gallery_thumbplay,
2070 + self::$opt_gallery_channelsub => $_gallery_channelsub,
2071 + self::$opt_gallery_channelsublink => $_gallery_channelsublink,
2072 + self::$opt_gallery_channelsubtext => $_gallery_channelsubtext,
2073 + self::$opt_gallery_customarrows => $_gallery_customarrows,
2074 + self::$opt_gallery_customnext => $_gallery_customnext,
2075 + self::$opt_gallery_customprev => $_gallery_customprev,
2076 + self::$opt_gallery_pagesize => $_gallery_pagesize,
2077 + self::$opt_not_live_content => $_not_live_content,
2078 + self::$opt_not_live_on => $_not_live_on,
2079 + self::$opt_not_live_on_channel => $_not_live_on_channel,
2080 + self::$opt_debugmode => $_debugmode,
2081 + self::$opt_uninstall_data => $_uninstall_data,
2082 + self::$opt_admin_off_scripts => $_admin_off_scripts,
2083 + self::$opt_defer_js => $_defer_js,
2084 + self::$opt_defer_jquery => $_defer_jquery,
2085 + self::$opt_ajax_save => $_ajax_save,
2086 + self::$opt_show_pointer => $_show_pointer,
2087 + self::$opt_onboarded => $_onboarded,
2088 + self::$opt_old_script_method => $_old_script_method
2089 + );
2090 +
2091 + update_option(self::$opt_alloptions, $all);
2092 + update_option('embed_autourls', 1);
2093 + self::$alloptions = get_option(self::$opt_alloptions);
2094 + }
2095 +
2096 + public static function tryget($array, $key, $default = null)
2097 + {
2098 + return isset($array[$key]) ? $array[$key] : $default;
2099 + }
2100 +
2101 + public static function wp_above_version($ver)
2102 + {
2103 + global $wp_version;
2104 + if (version_compare($wp_version, $ver, '>='))
2105 + {
2106 + return true;
2107 + }
2108 + return false;
2109 + }
2110 +
2111 + public static function do_ytprefs()
2112 + {
2113 + //add_filter('autoptimize_filter_js_exclude', array(self::class, 'ao_override_jsexclude'), 10, 1);
2114 + if (
2115 + !is_admin() || (self::$alloptions[self::$opt_frontend_only] != 1)
2116 + //|| (function_exists('wp_doing_ajax') && wp_doing_ajax())
2117 + )
2118 + {
2119 + add_filter('the_content', array(self::class, 'apply_prefs_content'), 1);
2120 + add_filter('widget_text', array(self::class, 'apply_prefs_widget'), 1);
2121 + //add_filter('bjll/skip_classes', array(self::class, 'bjll_skip_classes'), 10, 2);
2122 +
2123 + add_filter('sgo_lazy_load_exclude_classes', array(self::class, 'exclude_lazy_sgo'));
2124 +
2125 + add_shortcode('embedyt', array(self::class, 'apply_prefs_shortcode'));
2126 + if (self::$alloptions[self::$opt_migrate] == 1)
2127 + {
2128 + if (self::$alloptions[self::$opt_migrate_youtube] == 1)
2129 + {
2130 + add_shortcode('youtube', array(self::class, 'apply_prefs_shortcode_youtube'));
2131 + add_shortcode('youtube_video', array(self::class, 'apply_prefs_shortcode_youtube'));
2132 + }
2133 + if (self::$alloptions[self::$opt_migrate_embedplusvideo] == 1)
2134 + {
2135 + add_shortcode('embedplusvideo', array(self::class, 'apply_prefs_shortcode_embedplusvideo'));
2136 + }
2137 + }
2138 + }
2139 +
2140 + if (self::$alloptions[self::$opt_defer_js] == 1)
2141 + {
2142 + add_filter('script_loader_tag', array(self::class, 'defer_scripts'), 10, 3);
2143 + }
2144 + }
2145 +
2146 + public static function ao_override_jsexclude($exclude)
2147 + {
2148 + if (strpos($exclude, 'ytprefs' . self::$min . '.js') === false)
2149 + {
2150 + return $exclude . ',ytprefs' . self::$min . '.js,__ytprefs__';
2151 + }
2152 + return $exclude;
2153 + }
2154 +
2155 + public static function exclude_lazy_sgo($classes)
2156 + {
2157 + $classes[] = '__youtube_prefs__';
2158 + return $classes;
2159 + }
2160 +
2161 + public static function apply_prefs_shortcode($atts, $content = null)
2162 + {
2163 + $content = trim($content);
2164 + $currfilter = current_filter();
2165 + if (preg_match(self::$justurlregex, $content))
2166 + {
2167 + return self::get_html(array($content), strpos($currfilter, 'widget_text') === 0 ? false : true, false);
2168 + }
2169 + return '';
2170 + }
2171 +
2172 + public static function apply_prefs_shortcode_youtube($atts, $content = null)
2173 + {
2174 + $content = 'https://www.youtube.com/watch?v=' . trim($content);
2175 + $currfilter = current_filter();
2176 + if (preg_match(self::$justurlregex, $content))
2177 + {
2178 + return self::get_html(array($content), $currfilter == 'widget_text' ? false : true, false);
2179 + }
2180 + return '';
2181 + }
2182 +
2183 + public static function apply_prefs_shortcode_embedplusvideo($atts, $content = null)
2184 + {
2185 + $atts = shortcode_atts(array(
2186 + "height" => self::$defaultheight,
2187 + "width" => self::$defaultwidth,
2188 + "vars" => "",
2189 + "standard" => "",
2190 + "id" => "ep" . rand(10000, 99999)
2191 + ), $atts);
2192 +
2193 + $epvars = $atts['vars'];
2194 + $epvars = preg_replace('/\s/', '', $epvars);
2195 + $epvars = preg_replace('/¬/', '&not', $epvars);
2196 + $epvars = str_replace('&amp;', '&', $epvars);
2197 +
2198 + $epparams = self::keyvalue($epvars, true);
2199 +
2200 + if (isset($epparams) && isset($epparams['ytid']))
2201 + {
2202 + $start = isset($epparams['start']) && is_numeric($epparams['start']) ? '&start=' . intval($epparams['start']) : '';
2203 + $end = isset($epparams['end']) && is_numeric($epparams['end']) ? '&end=' . intval($epparams['end']) : '';
2204 + $end = isset($epparams['stop']) && is_numeric($epparams['stop']) ? '&end=' . intval($epparams['stop']) : '';
2205 +
2206 + $url = 'https://www.youtube.com/watch?v=' . trim($epparams['ytid']) . $start . $end;
2207 +
2208 + $currfilter = current_filter();
2209 + if (preg_match(self::$justurlregex, $url))
2210 + {
2211 + return self::get_html(array($url), $currfilter == 'widget_text' ? false : true, false);
2212 + }
2213 + }
2214 + return '';
2215 + }
2216 +
2217 + public static function apply_prefs_content($content)
2218 + {
2219 + $content = preg_replace_callback(self::$ytregex, array(self::class, "get_html_content"), $content);
2220 + return $content;
2221 + }
2222 +
2223 + public static function apply_prefs_widget($content)
2224 + {
2225 + $content = preg_replace_callback(self::$ytregex, array(self::class, "get_html_widget"), $content);
2226 + return $content;
2227 + }
2228 +
2229 + public static function get_html_content($m)
2230 + {
2231 + return self::get_html($m, true, true);
2232 + }
2233 +
2234 + public static function get_html_widget($m)
2235 + {
2236 + return self::get_html($m, false, true);
2237 + }
2238 +
2239 + public static function get_gallery_page($options)
2240 + {
2241 + $gallobj = new stdClass();
2242 +
2243 + $options->pageSize = min(intval($options->pageSize), 50);
2244 + $options->columns = intval($options->columns) == 0 ? 3 : intval($options->columns);
2245 + $options->showTitle = intval($options->showTitle);
2246 + $options->showPaging = intval($options->showPaging);
2247 + $options->autonext = intval($options->autonext);
2248 + $options->thumbplay = intval($options->thumbplay);
2249 +
2250 + if (empty($options->apiKey))
2251 + {
2252 + $gallobj->html = '<div>Please enter your YouTube API key to embed galleries.</div>';
2253 + return $gallobj;
2254 + }
2255 +
2256 + $apiEndpoint = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,status&playlistId=' . $options->playlistId
2257 + . '&maxResults=' . $options->pageSize
2258 + . '&key=' . $options->apiKey;
2259 + if ($options->pageToken != null)
2260 + {
2261 + $apiEndpoint .= '&pageToken=' . $options->pageToken;
2262 + }
2263 +
2264 + $code = '';
2265 + $init_id = null;
2266 +
2267 + $apiResult = wp_remote_get($apiEndpoint, array('timeout' => self::$curltimeout, 'headers' => array('referer' => site_url())));
2268 +
2269 + if (is_wp_error($apiResult))
2270 + {
2271 + $gallobj->html = self::clean_api_error_html($apiResult->get_error_message(), true);
2272 + return $gallobj;
2273 + }
2274 +
2275 + if (self::$alloptions[self::$opt_debugmode] == 1 && current_user_can('manage_options'))
2276 + {
2277 + $redactedEndpoint = preg_replace('@&key=[^&]+@i', '&key=PRIVATE', $apiEndpoint);
2278 + $active_plugins = get_option('active_plugins');
2279 + $gallobj->html = '<pre onclick="_EPADashboard_.selectText(this);" class="epyt-debug">CLICK this debug text to auto-select all. Then, COPY the selection.' . "\n\n" .
2280 + 'THIS IS DEBUG MODE OUTPUT. UNCHECK THE OPTION IN THE SETTINGS PAGE ONCE YOU ARE DONE DEBUGGING TO PUT THINGS BACK TO NORMAL.' . "\n\n" . $redactedEndpoint . "\n\n" . print_r($apiResult, true) . "\n\nActive Plugins\n\n" . print_r($active_plugins, true) . '</pre>';
2281 + return $gallobj;
2282 + }
2283 +
2284 + $jsonResult = json_decode($apiResult['body']);
2285 +
2286 + if (isset($jsonResult->error))
2287 + {
2288 + if (isset($jsonResult->error->message))
2289 + {
2290 + $gallobj->html = self::clean_api_error_html($jsonResult->error->message, true);
2291 + return $gallobj;
2292 + }
2293 + $gallobj->html = '<div>Sorry, there may be an issue with your YouTube API key. ' . self::$boilerplate_api_error_message . '</div>';
2294 + return $gallobj;
2295 + }
2296 +
2297 +
2298 +
2299 + $resultsPerPage = $options->pageSize; // $jsonResult->pageInfo->resultsPerPage;
2300 + $totalResults = $jsonResult->pageInfo->totalResults;
2301 +
2302 + $nextPageToken = '';
2303 + $prevPageToken = '';
2304 + if (isset($jsonResult->nextPageToken))
2305 + {
2306 + $nextPageToken = $jsonResult->nextPageToken;
2307 + }
2308 +
2309 + if (isset($jsonResult->prevPageToken))
2310 + {
2311 + $prevPageToken = $jsonResult->prevPageToken;
2312 + }
2313 +
2314 + $cnt = 0;
2315 + $colclass = ' epyt-cols-' . $options->columns . ' ';
2316 + $code .= '<div class="epyt-gallery-allthumbs ' . $colclass . '">';
2317 +
2318 + if (isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items))
2319 + {
2320 + if (strpos($options->playlistId, 'UU') === 0)
2321 + {
2322 + // sort only channels
2323 + usort($jsonResult->items, array(self::class, 'compare_vid_date')); // sorts in place
2324 + }
2325 +
2326 + foreach ($jsonResult->items as $item)
2327 + {
2328 +
2329 + $thumb = new stdClass();
2330 +
2331 + $thumb->id = isset($item->snippet->resourceId->videoId) ? $item->snippet->resourceId->videoId : null;
2332 + $thumb->id = $thumb->id ? $thumb->id : $item->id->videoId;
2333 + $thumb->title = $options->showTitle ? $item->snippet->title : '';
2334 + $thumb->privacyStatus = isset($item->status->privacyStatus) ? $item->status->privacyStatus : null;
2335 +
2336 + if ($thumb->privacyStatus == 'private' && self::$alloptions[self::$opt_gallery_hideprivate] == 1)
2337 + {
2338 + continue;
2339 + }
2340 +
2341 + if ($cnt == 0 && $options->pageToken == null)
2342 + {
2343 + $init_id = $thumb->id;
2344 + }
2345 +
2346 + if ($thumb->privacyStatus == 'private')
2347 + {
2348 + $thumb->img = plugins_url('/images/private.png', __FILE__);
2349 + $thumb->quality = 'medium';
2350 + }
2351 + else
2352 + {
2353 + if (isset($item->snippet->thumbnails->high->url))
2354 + {
2355 + $thumb->img = $item->snippet->thumbnails->high->url;
2356 + $thumb->quality = 'high';
2357 + }
2358 + elseif (isset($item->snippet->thumbnails->default->url))
2359 + {
2360 + $thumb->img = $item->snippet->thumbnails->default->url;
2361 + $thumb->quality = 'default';
2362 + }
2363 + elseif (isset($item->snippet->thumbnails->medium->url))
2364 + {
2365 + $thumb->img = $item->snippet->thumbnails->medium->url;
2366 + $thumb->quality = 'medium';
2367 + }
2368 + else
2369 + {
2370 + $thumb->img = plugins_url('/images/deleted-video-thumb.png', __FILE__);
2371 + $thumb->quality = 'medium';
2372 + }
2373 + }
2374 +
2375 + $code .= self::get_thumbnail_html($thumb, $options);
2376 + $cnt++;
2377 +
2378 + if ($cnt % $options->columns === 0)
2379 + {
2380 + $code .= '<div class="epyt-gallery-rowbreak"></div>';
2381 + }
2382 + }
2383 + }
2384 +
2385 + $code .= '<div class="epyt-gallery-clear"></div></div>';
2386 +
2387 + $totalPages = ceil($totalResults / $resultsPerPage);
2388 + $pagination = '<div class="epyt-pagination ' . ($options->showPaging == 0 ? 'epyt-hide-pagination' : '') . '">';
2389 +
2390 + $txtprev = self::$alloptions[self::$opt_gallery_customarrows] ? self::$alloptions[self::$opt_gallery_customprev] : _('Prev');
2391 + $pagination .= '<div tabindex="0" role="button" class="epyt-pagebutton epyt-prev ' . (empty($prevPageToken) ? ' hide ' : '') . '" data-playlistid="' . esc_attr($options->playlistId)
2392 + . '" data-pagesize="' . intval($options->pageSize)
2393 + . '" data-pagetoken="' . esc_attr($prevPageToken)
2394 + . '" data-epcolumns="' . intval($options->columns)
2395 + . '" data-showtitle="' . intval($options->showTitle)
2396 + . '" data-showpaging="' . intval($options->showPaging)
2397 + . '" data-autonext="' . intval($options->autonext)
2398 + . '" data-thumbplay="' . intval($options->thumbplay)
2399 + . '"><div class="epyt-arrow">&laquo;</div> <div>' . $txtprev . '</div></div>';
2400 +
2401 +
2402 + $pagination .= '<div class="epyt-pagenumbers ' . ($totalPages > 1 ? '' : 'hide') . '">';
2403 + $pagination .= '<div class="epyt-current">1</div><div class="epyt-pageseparator"> / </div><div class="epyt-totalpages">' . $totalPages . '</div>';
2404 + $pagination .= '</div>';
2405 +
2406 + $txtnext = self::$alloptions[self::$opt_gallery_customarrows] ? self::$alloptions[self::$opt_gallery_customnext] : _('Next');
2407 + $pagination .= '<div tabindex="0" role="button" class="epyt-pagebutton epyt-next' . (empty($nextPageToken) ? ' hide ' : '') . '" data-playlistid="' . esc_attr($options->playlistId)
2408 + . '" data-pagesize="' . intval($options->pageSize)
2409 + . '" data-pagetoken="' . esc_attr($nextPageToken)
2410 + . '" data-epcolumns="' . intval($options->columns)
2411 + . '" data-showtitle="' . intval($options->showTitle)
2412 + . '" data-showpaging="' . intval($options->showPaging)
2413 + . '" data-autonext="' . intval($options->autonext)
2414 + . '" data-thumbplay="' . intval($options->thumbplay)
2415 + . '"><div>' . $txtnext . '</div> <div class="epyt-arrow">&raquo;</div></div>';
2416 +
2417 + $pagination .= '<div class="epyt-loader"><img alt="loading" width="16" height="11" src="' . plugins_url('images/gallery-page-loader.gif', __FILE__) . '"></div>';
2418 + $pagination .= '</div>';
2419 +
2420 +// if ($options->showPaging == 0)
2421 +// {
2422 +// $pagination = '<div class="epyt-pagination"></div>';
2423 +// }
2424 + $code = $pagination . $code . $pagination;
2425 + $gallobj->html = $code;
2426 + $gallobj->init_id = $init_id;
2427 + return $gallobj;
2428 + }
2429 +
2430 + public static function compare_vid_date($a, $b)
2431 + {
2432 + if ($a->snippet->publishedAt == $b->snippet->publishedAt)
2433 + {
2434 + return 0;
2435 + }
2436 + return ($a->snippet->publishedAt > $b->snippet->publishedAt) ? -1 : 1;
2437 + }
2438 +
2439 + public static function get_thumbnail_html($thumb, $options)
2440 + {
2441 + $escId = esc_attr($thumb->id);
2442 + $code = '';
2443 + $code .= '<div tabindex="0" role="button" data-videoid="' . $escId . '" class="epyt-gallery-thumb">';
2444 +
2445 + $code .= (self::gdpr_mode() ? '<div class="epyt-gallery-img-box"><div class="epyt-gallery-img epyt-gallery-img-gdpr">' :
2446 + '<div class="epyt-gallery-img-box"><div class="epyt-gallery-img" style="background-image: url(' . esc_attr($thumb->img) . ')">') .
2447 + '<div class="epyt-gallery-playhover"><img alt="play" class="epyt-play-img" width="30" height="23" src="' . plugins_url('images/playhover.png', __FILE__) . '" data-no-lazy="1" data-skipgform_ajax_framebjll="" /><div class="epyt-gallery-playcrutch"></div></div>' .
2448 + '</div></div>';
2449 +
2450 +
2451 + if (!empty($thumb->title))
2452 + {
2453 + $code .= '<div class="epyt-gallery-title">' . esc_html($thumb->title) . '</div>';
2454 + }
2455 + else
2456 + {
2457 + $code .= '<div class="epyt-gallery-notitle"><span>' . esc_html($thumb->title) . '</span></div>';
2458 + }
2459 + $code .= '</div>';
2460 + return $code;
2461 + }
2462 +
2463 + public static function my_embedplus_gallery_page()
2464 + {
2465 + if (self::is_ajax())
2466 + {
2467 + //check_ajax_referer('embedplus-nonce', 'security');
2468 + $options = (object) $_POST['options'];
2469 + $options->apiKey = self::$alloptions[self::$opt_apikey];
2470 + echo self::get_gallery_page($options)->html;
2471 + die();
2472 + }
2473 + }
2474 +
2475 + public static function get_html($m, $iscontent, $isoverride)
2476 + {
2477 + //$time_start = microtime(true);
2478 +
2479 + $link = trim(str_replace(self::$badentities, self::$goodliterals, $m[0]));
2480 +
2481 + $link = preg_replace('/\s/', '', $link);
2482 + $linkparamstemp = explode('?', $link);
2483 +
2484 + $linkparams = array();
2485 + if (count($linkparamstemp) > 1)
2486 + {
2487 + $linkparams = self::keyvalue($linkparamstemp[1], true);
2488 + }
2489 + if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
2490 + {
2491 + $vtemp = explode('/', $linkparamstemp[0]);
2492 + $linkparams['v'] = array_pop($vtemp);
2493 + }
2494 +
2495 + if (isset($linkparams['live']) && $linkparams['live'] == '1')
2496 + {
2497 + $live_error_msg = ' To embed live videos, please make sure you performed the <a href="https://www.youtube.com/watch?v=ZCfrNvu6nMc" target="_blank">steps in this video</a> to create and save a proper server API key.';
2498 + if (isset(self::$alloptions[self::$opt_apikey]))
2499 + {
2500 + if (isset($linkparams['channel']))
2501 + {
2502 + $linkparams['live_stream'] = 1;
2503 + if (false) // takes up too much quota;
2504 + {
2505 + try
2506 + {
2507 + $ytapilink_live = 'https://www.googleapis.com/youtube/v3/search?order=date&maxResults=1&type=video&eventType=live&safeSearch=none&videoEmbeddable=true&channelId=' . $linkparams['channel'] . '&part=snippet&key=' . self::$alloptions[self::$opt_apikey];
2508 + $apidata_live = wp_remote_get($ytapilink_live, array('timeout' => self::$curltimeout, 'headers' => array('referer' => site_url())));
2509 + if (!is_wp_error($apidata_live))
2510 + {
2511 + $raw = wp_remote_retrieve_body($apidata_live);
2512 + if (!empty($raw))
2513 + {
2514 + $json = json_decode($raw, true);
2515 + if (!isset($json['error']) && is_array($json) && count($json['items']))
2516 + {
2517 + $linkparams['v'] = $json['items'][0]['id']['videoId'];
2518 + }
2519 + else if (isset($json['error']))
2520 + {
2521 + return $live_error_msg; // . ' <em>(Error code ' . $json['error']->code . ': ' . $json['error']->message . ')</em>';
2522 + }
2523 + }
2524 + }
2525 + }
2526 + catch (Exception $ex)
2527 + {
2528 + return $live_error_msg;
2529 + }
2530 + }
2531 + }
2532 + else if (isset($linkparams['v']))
2533 + {
2534 + ////////////////////// process single video live stream
2535 + try
2536 + {
2537 + if (self::$alloptions[self::$opt_not_live_on])
2538 + {
2539 + // if not_live_content isn't being used, just process as a normal single video. otherwise: if not currently live (nor upcoming?), unset $linkparams['v']
2540 + $not_live_content = trim(htmlspecialchars_decode(wp_strip_all_tags(self::$alloptions[self::$opt_not_live_content], true), ENT_QUOTES));
2541 + if (!empty($not_live_content))
2542 + {
2543 + $ytapilink_live = 'https://www.googleapis.com/youtube/v3/videos?id=' . $linkparams['v'] . '&part=snippet&key=' . self::$alloptions[self::$opt_apikey];
2544 + $apidata_live = wp_remote_get($ytapilink_live, array('timeout' => self::$curltimeout, 'headers' => array('referer' => site_url())));
2545 + if (!is_wp_error($apidata_live))
2546 + {
2547 + $raw = wp_remote_retrieve_body($apidata_live);
2548 + if (!empty($raw))
2549 + {
2550 + $json = json_decode($raw, true);
2551 + if (!isset($json['error']) && is_array($json) && count($json['items']))
2552 + {
2553 + if (isset($json['items'][0]['snippet']['liveBroadcastContent']) && $json['items'][0]['snippet']['liveBroadcastContent'] != 'live')
2554 + {
2555 + unset($linkparams['v']);
2556 + }
2557 + }
2558 + else if (isset($json['error']))
2559 + {
2560 + return $live_error_msg; // . ' <em>(Error code ' . $json['error']->code . ': ' . $json['error']->message . ')</em>';
2561 + }
2562 + }
2563 + }
2564 + }
2565 + }
2566 + }
2567 + catch (Exception $ex)
2568 + {
2569 + return $live_error_msg;
2570 + }
2571 + }
2572 + }
2573 + else
2574 + {
2575 + return $live_error_msg;
2576 + }
2577 +
2578 + if (!isset($linkparams['v']) && !isset($linkparams['live_stream']))
2579 + {
2580 + return apply_filters('ytprefs_filter_the_content_light', wp_kses_post(self::$alloptions[self::$opt_not_live_content]));
2581 + }
2582 + }
2583 +
2584 + if (stripos($linkparamstemp[0], 'live_stream') !== false)
2585 + {
2586 + $linkparams['live_stream'] = 1;
2587 + }
2588 +
2589 + $youtubebaseurl = 'youtube';
2590 + $voloutput = '';
2591 + $acctitle = '';
2592 + $relstop = '';
2593 +
2594 + $finalparams = $linkparams + self::$alloptions;
2595 +
2596 + self::init_dimensions($link, $linkparams, $finalparams);
2597 +
2598 + if (self::$alloptions[self::$opt_nocookie] == 1)
2599 + {
2600 + $youtubebaseurl = 'youtube-nocookie';
2601 + }
2602 +
2603 + if (self::$alloptions[self::$opt_defaultvol] == 1)
2604 + {
2605 + $voloutput = ' data-vol="' . self::$alloptions[self::$opt_vol] . '" ';
2606 + }
2607 +
2608 + if (is_numeric(self::$alloptions[self::$opt_rel]) && intval(self::$alloptions[self::$opt_rel]) === -1)
2609 + {
2610 + $relstop = ' data-relstop="1" ';
2611 + }
2612 +
2613 + if (!empty($finalparams[self::$opt_loop]))
2614 + {
2615 + $relstop = '';
2616 + }
2617 +
2618 + if (self::$alloptions[self::$opt_dohl] == 1)
2619 + {
2620 + $locale = get_locale();
2621 + $finalparams[self::$opt_hl] = $locale;
2622 + }
2623 + else
2624 + {
2625 + unset($finalparams[self::$opt_hl]);
2626 + }
2627 +
2628 + $centercode = '';
2629 + if ($finalparams[self::$opt_center] == 1)
2630 + {
2631 + $centercode = ' style="display: block; margin: 0px auto;" ';
2632 + }
2633 +
2634 + if (self::$alloptions[self::$opt_acctitle] == 1)
2635 + {
2636 + try
2637 + {
2638 + //attr escape
2639 + if (self::$oembeddata)
2640 + {
2641 + $acctitle = self::$oembeddata->title;
2642 + }
2643 + else
2644 + {
2645 +
2646 + if (isset($linkparams['list']))
2647 + {
2648 + $odata = self::get_oembed('https://youtube.com/playlist?list=' . $linkparams['list'], 1920, 1280);
2649 + if (is_object($odata) && isset($odata->title))
2650 + {
2651 + $acctitle = $odata->title;
2652 + }
2653 + }
2654 + else if (isset($linkparams['v']))
2655 + {
2656 + $odata = self::get_oembed('https://youtube.com/watch?v=' . $linkparams['v'], 1920, 1280);
2657 + if (is_object($odata) && isset($odata->title))
2658 + {
2659 + $acctitle = $odata->title;
2660 + }
2661 + }
2662 + }
2663 +
2664 + if ($acctitle)
2665 + {
2666 + $acctitle = ' title="' . esc_attr($acctitle) . '" ';
2667 + }
2668 + else
2669 + {
2670 + $acctitle = ' title="YouTube player" ';
2671 + }
2672 + }
2673 + catch (Exception $e)
2674 + {
2675 +
2676 + }
2677 + }
2678 + else
2679 + {
2680 + $acctitle = ' title="YouTube player" ';
2681 + }
2682 +
2683 + // playlist cleanup
2684 + $videoidoutput = isset($linkparams['v']) ? $linkparams['v'] : '';
2685 +
2686 + if ((self::$alloptions[self::$opt_playlistorder] == 1 || isset($finalparams['plindex'])) && isset($finalparams['list']))
2687 + {
2688 + try
2689 + {
2690 + $videoidoutput = '';
2691 + if (isset($finalparams['plindex']))
2692 + {
2693 + $finalparams['index'] = intval($finalparams['plindex']);
2694 + }
2695 + }
2696 + catch (Exception $ex)
2697 + {
2698 +
2699 + }
2700 + }
2701 +
2702 + $galleryWrapper1 = '';
2703 + $galleryWrapper2 = '';
2704 + $galleryCode = '';
2705 + $galleryid_ifm_data = '';
2706 + if (isset($finalparams['layout']) && strtolower($finalparams['layout']) == 'gallery' && isset($finalparams['list']))
2707 + {
2708 + $gallery_options = new stdClass();
2709 + $gallery_options->playlistId = $finalparams['list'];
2710 + $gallery_options->pageToken = null;
2711 + $gallery_options->pageSize = $finalparams[self::$opt_gallery_pagesize];
2712 + $gallery_options->columns = intval($finalparams[self::$opt_gallery_columns]);
2713 + $gallery_options->showTitle = intval($finalparams[self::$opt_gallery_showtitle]);
2714 + $gallery_options->showPaging = intval($finalparams[self::$opt_gallery_showpaging]);
2715 + $gallery_options->autonext = intval($finalparams[self::$opt_gallery_autonext]);
2716 + $gallery_options->thumbplay = intval($finalparams[self::$opt_gallery_thumbplay]);
2717 + $gallery_options->apiKey = self::$alloptions[self::$opt_apikey];
2718 +
2719 + $galleryid = 'epyt_gallery_' . rand(10000, 99999);
2720 + $galleryid_ifm_data = ' data-epytgalleryid="' . $galleryid . '" ';
2721 +
2722 + $subbutton = '';
2723 + if (isset($finalparams[self::$opt_gallery_channelsub]) && $finalparams[self::$opt_gallery_channelsub] == 1)
2724 + {
2725 + $subbutton = '<div class="epyt-gallery-subscribe"><a target="_blank" class="epyt-gallery-subbutton" href="' .
2726 + esc_url(self::$alloptions[self::$opt_gallery_channelsublink]) . '?sub_confirmation=1"><img alt="subscribe" src="' . plugins_url('images/play-subscribe.png', __FILE__) . '" />' .
2727 + htmlspecialchars(self::$alloptions[self::$opt_gallery_channelsubtext], ENT_QUOTES, 'UTF-8') . '</a></div>';
2728 + }
2729 +
2730 + $gallery_page_obj = self::get_gallery_page($gallery_options);
2731 +
2732 + $galleryWrapper1 = '<div class="epyt-gallery" data-currpage="1" id="' . $galleryid . '">';
2733 + $galleryWrapper2 = '</div>';
2734 + $galleryCode = $subbutton . '<div class="epyt-gallery-list">' . $gallery_page_obj->html . '</div>';
2735 + $videoidoutput = isset($gallery_page_obj->init_id) ? $gallery_page_obj->init_id : '';
2736 + }
2737 +
2738 + if (!empty($voloutput) && isset($finalparams['autoplay']) && $finalparams['autoplay'] == 1)
2739 + {
2740 + $voloutput .= ' data-epautoplay="1" ';
2741 + $finalparams['autoplay'] = 0;
2742 + }
2743 +
2744 + if (!empty($relstop) && isset($finalparams['rel']) && intval($finalparams['rel']) === -1)
2745 + {
2746 + $finalparams['rel'] = 0;
2747 + }
2748 +
2749 + if (!empty($finalparams['live_stream']))
2750 + {
2751 + $videoidoutput = 'live_stream';
2752 + }
2753 +
2754 + $begin_responsive = '';
2755 + $end_responsive = '';
2756 + $dim_attrs = ' width="' . self::$defaultwidth . '" height="' . self::$defaultheight . '" ';
2757 + if ($finalparams[self::$opt_responsive] == 1)
2758 + {
2759 + $begin_responsive = '<div class="epyt-video-wrapper">';
2760 + $end_responsive = '</div>';
2761 + }
2762 +
2763 + $begin_gb_wrapper = '';
2764 + $end_gb_wrapper = '';
2765 + if ($iscontent && !$isoverride && $finalparams[self::$opt_gb_compat] == 1 && current_theme_supports('responsive-embeds'))// self::using_gutenberg())
2766 + {
2767 + // don't do the following if: overriding default YT, is widget
2768 + $begin_gb_wrapper = '<figure class="wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure"><div class="wp-block-embed__wrapper">';
2769 + //wp-block-embed-youtube is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio
2770 + $end_gb_wrapper = '</div></figure>';
2771 + }
2772 + $iframe_id = rand(10000, 99999);
2773 +
2774 + $code1 = $begin_gb_wrapper . $begin_responsive;
2775 + $code_iframe1 = $code_iframe2 = '';
2776 + if ($videoidoutput != 'live_stream' && $finalparams[self::$opt_facade_mode] == 1)
2777 + {
2778 + $facade_img_src = '';
2779 + if (!empty($videoidoutput))
2780 + {
2781 + $facade_img_src = ' src="https://i.ytimg.com/vi/' . $videoidoutput . ($finalparams[self::$opt_maxres_facade] == 'eager' ? '/maxresdefault.jpg' : '/hqdefault.jpg') . '" ';
2782 + }
2783 + else if (isset($finalparams['list']))
2784 + {
2785 + $facade_img_src = ' data-facadeoembed="playlist?list=' . $finalparams['list'] . '" ';
2786 + }
2787 + $acctitle = str_replace('title="', 'alt="', $acctitle);
2788 + $facade_autoplay = $finalparams[self::$opt_facade_autoplay] == 1 ? ' data-epautoplay="1" ' : '';
2789 + $code_iframe1 = '<div ' . $centercode . ' id="_ytid_' . $iframe_id . '" ' . $dim_attrs . ' data-origwidth="' . self::$defaultwidth . '" data-origheight="' . self::$defaultheight . '" ' . $relstop .
2790 + 'data-facadesrc="https://www.' . $youtubebaseurl . '.com/embed/' . $videoidoutput . '?';
2791 + $code_iframe2 = '" class="__youtube_prefs__ epyt-facade' . (!empty($finalparams['live_stream']) ? ' epyt-live-channel ' : '') . ($iscontent ? '' : ' __youtube_prefs_widget__ ') . ($isoverride ? ' epyt-is-override ' : '') . ' no-lazyload"' .
2792 + $voloutput . $galleryid_ifm_data . $facade_autoplay . '><img data-spai-excluded="true" class="epyt-facade-poster skip-lazy" loading="lazy" ' . $acctitle . $facade_img_src . ' />' .
2793 + '<button class="epyt-facade-play" aria-label="Play"><svg data-no-lazy="1" height="100%" version="1.1" viewBox="0 0 68 48" width="100%"><path class="ytp-large-play-button-bg" d="M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.55 C3.97,2.33,2.27,4.81,1.48,7.74C0.06,13.05,0,24,0,24s0.06,10.95,1.48,16.26c0.78,2.93,2.49,5.41,5.42,6.19 C12.21,47.87,34,48,34,48s21.79-0.13,27.1-1.55c2.93-0.78,4.64-3.26,5.42-6.19C67.94,34.95,68,24,68,24S67.94,13.05,66.52,7.74z" fill="#f00"></path><path d="M 45,24 27,14 27,34" fill="#fff"></path></svg></button>' .
2794 + '</div>';
2795 + }
2796 + else
2797 + {
2798 + $code_iframe1 = '<iframe ' . $centercode . ' id="_ytid_' . $iframe_id . '" ' . $dim_attrs . ' data-origwidth="' . self::$defaultwidth . '" data-origheight="' . self::$defaultheight . '" ' . $relstop .
2799 + 'src="https://www.' . $youtubebaseurl . '.com/embed/' . $videoidoutput . '?';
2800 + $code_iframe2 = '" class="__youtube_prefs__ ' . (!empty($finalparams['live_stream']) ? ' epyt-live-channel ' : '') . ($iscontent ? '' : ' __youtube_prefs_widget__ ') . ($isoverride ? ' epyt-is-override ' : '') . ' no-lazyload"' .
2801 + $voloutput . $acctitle . $galleryid_ifm_data . ' allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen data-no-lazy="1" data-skipgform_ajax_framebjll=""></iframe>';
2802 + }
2803 +
2804 + $code2 = $end_responsive . $end_gb_wrapper;
2805 +
2806 + $code1 .= $code_iframe1;
2807 + $code2 = $code_iframe2 . $code2;
2808 +
2809 + $origin = '';
2810 +
2811 + try
2812 + {
2813 + if (self::$alloptions[self::$opt_origin] == 1)
2814 + {
2815 + $url_parts = parse_url(site_url());
2816 + $origin = 'origin=' . $url_parts['scheme'] . '://' . $url_parts['host'] . '&';
2817 + }
2818 + }
2819 + catch (Exception $e)
2820 + {
2821 + $origin = '';
2822 + }
2823 + $finalsrc = (self::$alloptions[self::$opt_ytapi_load] == 'never' ? '' : 'enablejsapi=1&') . $origin;
2824 +
2825 + if (count($finalparams) > 1)
2826 + {
2827 + foreach ($finalparams as $key => $value)
2828 + {
2829 + if (in_array($key, self::$yt_options))
2830 + {
2831 + if (!empty($galleryCode) && ($key == 'listType' || $key == 'list'))
2832 + {
2833 +
2834 + }
2835 + else
2836 + {
2837 + if (!((isset($finalparams['live']) || isset($finalparams['live_stream'])) && $key == 'loop')) // don't add loop for channel streaming
2838 + {
2839 + $finalsrc .= htmlspecialchars($key, ENT_QUOTES, 'UTF-8') . '=' . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '&';
2840 + if ($key == 'loop' && $value == 1 && !isset($finalparams['list']))
2841 + {
2842 + $finalsrc .= 'playlist=' . $finalparams['v'] . '&';
2843 + }
2844 + }
2845 + }
2846 + }
2847 + }
2848 + }
2849 +
2850 + if (self::gdpr_mode())
2851 + {
2852 + $code1 = '<div ' . $centercode . ' id="_ytid_' . rand(10000, 99999) . '"'; //'" width="' . self::$defaultwidth . '" height="' . self::$defaultheight . '" ';
2853 + $code2 = ' class="__youtube_prefs__ __youtube_prefs_gdpr__ ' . ($iscontent ? '' : ' __youtube_prefs_widget__') . ($isoverride ? ' epyt-is-override ' : '') . '" allowfullscreen data-no-lazy="1" data-skipgform_ajax_framebjll="">' .
2854 + apply_filters('ytprefs_filter_the_content_light', wp_kses_post(self::$alloptions[self::$opt_gdpr_consent_message])) .
2855 + '<button type="button" class="__youtube_prefs_gdpr__">' . trim(sanitize_text_field(self::$alloptions[self::$opt_gdpr_consent_button])) .
2856 + '<img src="' . plugins_url('images/icon-check.png', __FILE__) . '" alt="accept" data-no-lazy="1" data-skipgform_ajax_framebjll="" /></button>' .
2857 + '</div>';
2858 + $finalsrc = '';
2859 + }
2860 +
2861 + $code = $galleryWrapper1 . $code1 . $finalsrc . $code2 . $galleryCode . $galleryWrapper2;
2862 + //. '<!--' . $m[0] . '-->';
2863 + self::$defaultheight = null;
2864 + self::$defaultwidth = null;
2865 + self::$oembeddata = null;
2866 +
2867 + return $code;
2868 + }
2869 +
2870 + public static function using_gutenberg()
2871 + {
2872 + global $wp_version;
2873 + if ((version_compare($wp_version, '5.0', '>=') && !is_plugin_active('classic-editor/classic-editor.php')) || is_plugin_active('gutenberg/gutenberg.php'))
2874 + {
2875 + return true;
2876 + }
2877 + return false;
2878 + }
2879 +
2880 + public static function gdpr_mode()
2881 + {
2882 + return (bool) self::$alloptions[self::$opt_gdpr_consent] && filter_input(INPUT_COOKIE, self::$gdpr_cookie_name, FILTER_SANITIZE_NUMBER_INT) != 1;
2883 + }
2884 +
2885 + public static function filter_the_content_light($content)
2886 + {
2887 + //global $wp_filter;
2888 + //$the_content_filters_current = $wp_filter['the_content']->callbacks;
2889 +
2890 + for ($i = 0; $i < count(self::$the_content_filters); $i++)
2891 + {
2892 + if (function_exists(self::$the_content_filters[$i]) && !(self::wp_above_version('5.5') && self::$the_content_filters[$i] === 'wp_make_content_images_responsive'))
2893 + {
2894 + $content = call_user_func(self::$the_content_filters[$i], $content);
2895 + }
2896 + }
2897 + return $content;
2898 + }
2899 +
2900 + public static function debuglog($str)
2901 + {
2902 + $handle = fopen(__DIR__ . "\\debug.txt", "a+");
2903 + fwrite($handle, $str);
2904 + fclose($handle);
2905 + }
2906 +
2907 + public static function keyvalue($qry, $includev)
2908 + {
2909 + $ytvars = explode('&', $qry);
2910 + $ytkvp = array();
2911 + foreach ($ytvars as $k => $v)
2912 + {
2913 + $kvp = explode('=', $v);
2914 + if (count($kvp) == 2 && ($includev || strtolower($kvp[0]) != 'v'))
2915 + {
2916 + $ytkvp[$kvp[0]] = $kvp[1];
2917 + }
2918 + }
2919 +
2920 + return $ytkvp;
2921 + }
2922 +
2923 + public static function secondsToDuration($seconds)
2924 + {
2925 + $remaining = $seconds;
2926 + $parts = array();
2927 + $multipliers = array(
2928 + 'hours' => 3600,
2929 + 'minutes' => 60,
2930 + 'seconds' => 1
2931 + );
2932 +
2933 + foreach ($multipliers as $type => $m)
2934 + {
2935 + $parts[$type] = (int) ($remaining / $m);
2936 + $remaining -= ($parts[$type] * $m);
2937 + }
2938 +
2939 + return $parts;
2940 + }
2941 +
2942 + public static function formatDuration($parts)
2943 + {
2944 + $default = array(
2945 + 'hours' => 0,
2946 + 'minutes' => 0,
2947 + 'seconds' => 0
2948 + );
2949 +
2950 + extract(array_merge($default, $parts));
2951 +
2952 + return "T{$hours}H{$minutes}M{$seconds}S";
2953 + }
2954 +
2955 + public static function init_dimensions($url, $urlkvp, $finalparams)
2956 + {
2957 + // get default dimensions; try embed size in settings, then try theme's content width, then just 480px
2958 + if (self::$defaultwidth == null)
2959 + {
2960 + global $content_width;
2961 + if (empty($content_width))
2962 + {
2963 + $content_width = $GLOBALS['content_width'];
2964 + }
2965 +
2966 + if (isset($urlkvp['width']) && is_numeric($urlkvp['width']))
2967 + {
2968 + self::$defaultwidth = $urlkvp['width'];
2969 + }
2970 + else if (self::$alloptions[self::$opt_defaultdims] == 1 && (isset(self::$alloptions[self::$opt_defaultwidth]) && is_numeric(self::$alloptions[self::$opt_defaultwidth])))
2971 + {
2972 + self::$defaultwidth = self::$alloptions[self::$opt_defaultwidth];
2973 + }
2974 + else if (self::$optembedwidth)
2975 + {
2976 + self::$defaultwidth = self::$optembedwidth;
2977 + }
2978 + else if ($content_width)
2979 + {
2980 + self::$defaultwidth = $content_width;
2981 + }
2982 + else
2983 + {
2984 + self::$defaultwidth = 480;
2985 + }
2986 +
2987 +
2988 +
2989 + if (isset($urlkvp['height']) && is_numeric($urlkvp['height']))
2990 + {
2991 + self::$defaultheight = $urlkvp['height'];
2992 + }
2993 + else if (self::$alloptions[self::$opt_defaultdims] == 1 && (isset(self::$alloptions[self::$opt_defaultheight]) && is_numeric(self::$alloptions[self::$opt_defaultheight])))
2994 + {
2995 + self::$defaultheight = self::$alloptions[self::$opt_defaultheight];
2996 + }
2997 + else
2998 + {
2999 + self::$defaultheight = self::get_aspect_height($url, self::$defaultwidth);
3000 + }
3001 + }
3002 + }
3003 +
3004 + public static function get_oembed($url, $height, $width)
3005 + {
3006 + if (stripos($url, 'listType=playlist') !== false && stripos($url, '/embed') !== false)
3007 + {
3008 + $url = str_replace('/embed', '/playlist', $url);
3009 + }
3010 + if (file_exists(ABSPATH . WPINC . '/class-wp-oembed.php'))
3011 + {
3012 + require_once(ABSPATH . WPINC . '/class-wp-oembed.php');
3013 + }
3014 + else
3015 + {
3016 + require_once(ABSPATH . WPINC . '/class-oembed.php');
3017 + }
3018 + $oembed = _wp_oembed_get_object();
3019 + $args = array();
3020 + $args['width'] = $width;
3021 + $args['height'] = $height;
3022 + $args['discover'] = false;
3023 + self::$oembeddata = $oembed->fetch('https://www.youtube.com/oembed', $url, $args);
3024 + return self::$oembeddata;
3025 + }
3026 +
3027 + public static function get_aspect_height($url, $widthbox)
3028 + {
3029 + // attempt to get aspect ratio correct height from oEmbed
3030 + $aspectheight = round(($widthbox * 9) / 16, 0);
3031 +
3032 + if ($url)
3033 + {
3034 + $odata = self::get_oembed($url, $widthbox, $widthbox);
3035 +
3036 + if ($odata)
3037 + {
3038 + $aspectheight = $odata->height;
3039 + }
3040 + }
3041 +
3042 + return $aspectheight;
3043 + }
3044 +
3045 + public static function ytprefs_plugin_menu()
3046 + {
3047 + self::$admin_page_hooks[] = add_menu_page('EmbedPlus for YouTube Settings', 'EmbedPlus for YouTube', 'manage_options', 'youtube-my-preferences', array(self::class, 'ytprefs_show_options'), 'dashicons-video-alt3', '10.000392854349');
3048 + self::$admin_page_hooks[] = add_submenu_page('youtube-my-preferences', '', '', 'manage_options', 'youtube-my-preferences', array(self::class, 'ytprefs_show_options'));
3049 +
3050 + self::$admin_page_hooks[] = add_submenu_page('youtube-my-preferences_nomenu', 'YouTube Posts', 'YouTube Posts', 'manage_options', 'youtube-ep-glance', array(self::class, 'glance_page'));
3051 + self::$admin_page_hooks[] = self::$wizard_hook = add_submenu_page('youtube-my-preferences_nomenu', 'EmbedPlus for YouTube Wizard', 'Wizard', 'edit_posts', 'youtube-ep-wizard', array(self::class, 'wizard'));
3052 + self::$admin_page_hooks[] = self::$onboarding_hook = add_submenu_page('youtube-my-preferences_nomenu', 'EmbedPlus for YouTube Setup', 'Setup', 'manage_options', 'youtube-ep-onboarding', array(self::class, 'ytprefs_show_onboarding'));
3053 + }
3054 +
3055 + public static function custom_admin_pointers_check()
3056 + {
3057 + if (!self::$alloptions[self::$opt_show_pointer])
3058 + {
3059 + return false;
3060 + }
3061 + $admin_pointers = self::custom_admin_pointers();
3062 + foreach ($admin_pointers as $pointer => $array)
3063 + {
3064 + if ($array['active'])
3065 + {
3066 + return true;
3067 + }
3068 + }
3069 + }
3070 +
3071 + public static function glance_script()
3072 + {
3073 + add_thickbox();
3074 + ?>
3075 + <script type="text/javascript">
3076 + function widen_ytprefs_glance()
3077 + {
3078 + setTimeout(function ()
3079 + {
3080 + jQuery("#TB_window").animate({marginLeft: '-' + parseInt((780 / 2), 10) + 'px', width: '780px'}, 300);
3081 + jQuery("#TB_window iframe").animate({width: '780px'}, 300);
3082 + }, 15);
3083 + }
3084 +
3085 + (function ($j)
3086 + {
3087 + $j(document).ready(function ()
3088 + {
3089 +
3090 + $j.ajax({
3091 + type: "post",
3092 + dataType: "json",
3093 + timeout: 30000,
3094 + url: window._EPYTA_ ? window._EPYTA_.wpajaxurl : ajaxurl,
3095 + data: {action: 'my_embedplus_glance_count'},
3096 + success: function (response)
3097 + {
3098 + if (response.type === "success")
3099 + {
3100 + $j(response.container).append(response.data);
3101 + $j(".ytprefs_glance_button").on('click', widen_ytprefs_glance);
3102 + $j(window).on('resize', widen_ytprefs_glance);
3103 + if (typeof ep_do_pointers === 'function')
3104 + {
3105 + //ep_do_pointers($j);
3106 + }
3107 + }
3108 + else
3109 + {
3110 + }
3111 + },
3112 + error: function (xhr, ajaxOptions, thrownError)
3113 + {
3114 +
3115 + },
3116 + complete: function ()
3117 + {
3118 + }
3119 + });
3120 + });
3121 + })(jQuery);</script>
3122 + <?php
3123 + }
3124 +
3125 + public static function custom_admin_pointers_footer()
3126 + {
3127 + $admin_pointers = self::custom_admin_pointers();
3128 + ?>
3129 + <script type="text/javascript">
3130 + /* <![CDATA[ */
3131 + function ep_do_pointers($)
3132 + {
3133 + <?php
3134 + foreach ($admin_pointers as $pointer => $array)
3135 + {
3136 + if ($array['active'])
3137 + {
3138 + ?>
3139 + $('<?php echo $array['anchor_id']; ?>').pointer({
3140 + pointerClass: 'wp-pointer ytprefs-pointer',
3141 + content: '<?php echo $array['content']; ?>',
3142 + position: {
3143 + edge: '<?php echo $array['edge']; ?>',
3144 + align: '<?php echo $array['align']; ?>'
3145 + },
3146 + close: function ()
3147 + {
3148 + $.post(window._EPYTA_ ? window._EPYTA_.wpajaxurl : ajaxurl, {
3149 + pointer: '<?php echo $pointer; ?>',
3150 + action: 'dismiss-wp-pointer'
3151 + });
3152 + }
3153 + }).pointer('open');
3154 + <?php
3155 + }
3156 + }
3157 + ?>
3158 + }
3159 +
3160 + ep_do_pointers(jQuery); // switch off all pointers via js ooopointer
3161 + /* ]]> */
3162 + </script>
3163 + <?php
3164 + }
3165 +
3166 + public static function custom_admin_pointers()
3167 + {
3168 + $dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
3169 + $version = str_replace('.', '_', self::$version); // replace all periods in version with an underscore
3170 + $prefix = 'custom_admin_pointers' . $version . '_';
3171 +
3172 + $new_pointer_content = '<h3>' . __('New Update') . '</h3>'; // ooopointer
3173 +
3174 + $new_pointer_content .= '<p>'; // ooopointer
3175 + $new_pointer_content .= 'This version improves compatibility with WordPress 7.1 for both free and <a target=_blank href="' . self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=frompointer">Pro</a> plugins, and optimizes the caching feature for the Pro plugin.';
3176 + if (!empty(self::$alloptions[self::$opt_pro]) && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
3177 + {
3178 + $new_pointer_content .= ' <strong>Important message to Pro users</strong>: From version 11.7 onward, you must <a href="https://www.embedplus.com/youtube-pro/download/?prokey=' . esc_attr(self::$alloptions[self::$opt_pro]) . '" target="_blank">download the separate plugin here</a> to regain your Pro features. All your settings will automatically migrate after installing the separate Pro download. Thank you for your support and patience during this transition.';
3179 + }
3180 +
3181 + $new_pointer_content .= '</p>';
3182 +
3183 + return array(
3184 + $prefix . 'new_items' => array(
3185 + 'content' => $new_pointer_content,
3186 + 'anchor_id' => 'a.toplevel_page_youtube-my-preferences', //'#ytprefs_glance_button',
3187 + 'edge' => 'top',
3188 + 'align' => 'left',
3189 + 'active' => (!in_array($prefix . 'new_items', $dismissed))
3190 + ),
3191 + );
3192 + }
3193 +
3194 + public static function postchecked($idx)
3195 + {
3196 + return isset($_POST[$idx]) && $_POST[$idx] == (true || 'on');
3197 + }
3198 +
3199 + public static function settings_nav()
3200 + {
3201 + ?>
3202 +
3203 + <h3 class="nav-tab-wrapper">
3204 + <a class="nav-tab nav-tab-active" href="#jumpdefaults">Defaults</a>
3205 + <a class="nav-tab" href="#jumpapikey">API Key</a>
3206 + <a class="nav-tab" href="#jumpwiz">Wizard</a>
3207 + <a class="nav-tab" href="#jumpgallery">Galleries</a>
3208 + <a class="nav-tab href-link" style="background-color: #daebf1;" target="_blank" href="<?php echo self::$epbase . "/dashboard/pro-easy-video-analytics.aspx?ref=protab" ?>">Upgrade?</a>
3209 + <a class="nav-tab" href="#jumpperformance">Performance</a>
3210 + <a class="nav-tab" href="#jumpcompat">Compatibility</a>
3211 + <a class="nav-tab" href="#jumpprivacy">Security & Privacy</a>
3212 + <a class="nav-tab" href="#jumphowto">Embed Manually</a>
3213 + <a class="nav-tab" href="#jumpsupport">Support</a>
3214 + </h3>
3215 + <?php
3216 + }
3217 +
3218 + public static function ytprefs_show_options()
3219 + {
3220 + if (!current_user_can('manage_options'))
3221 + {
3222 + wp_die(__('You do not have sufficient permissions to access this page.'));
3223 + }
3224 +
3225 + if (self::$double_plugin)
3226 + {
3227 + self::double_plugin_warning();
3228 + }
3229 +
3230 + $ytprefs_submitted = 'ytprefs_submitted';
3231 +
3232 + // Read in existing option values from database
3233 +
3234 + $all = get_option(self::$opt_alloptions);
3235 +
3236 + // See if the user has posted us some information
3237 + // If they did, this hidden field will be set to 'Y'
3238 + if (isset($_POST[$ytprefs_submitted]) && $_POST[$ytprefs_submitted] == 'Y' && check_admin_referer('_epyt_save', '_epyt_nonce'))
3239 + {
3240 + $result = self::settings_save($all);
3241 + $all = get_option(self::$opt_alloptions);
3242 + ?>
3243 + <div class="updated"><p><strong><?php echo wp_kses_post($result['message']) ?></strong></p></div>
3244 + <?php
3245 + }
3246 + ?>
3247 +
3248 + <style type="text/css">
3249 + .wrap {font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",Arial,sans-serif; color: #000000;}
3250 + .wrap-ytprefs {max-width: 1064px;}
3251 + h1 span {vertical-align: middle;}
3252 + #ytform p, #ytform .p { line-height: 20px; margin: 18px 0; }
3253 + .ytindent {padding: 0px 0px 0px 20px; font-size: 13px; margin-bottom: 100px;}
3254 + .ytindent ul, .ytindent p {font-size: 13px;}
3255 + .shadow {-webkit-box-shadow: 0px 0px 20px 0px #000000; box-shadow: 0px 0px 20px 0px #000000;}
3256 + .gopro {margin: 0px;}
3257 + .gopro img {vertical-align: middle;
3258 + width: 19px;
3259 + height: 19px;
3260 + padding-bottom: 4px;}
3261 + .gopro li {margin-bottom: 0px;}
3262 + .orange {color: #f85d00;}
3263 + .bold {font-weight: bold;}
3264 + .grey{color: #888888;}
3265 + #goprobox {border-radius: 15px; padding: 10px 15px 15px 15px; border: 3px solid #CCE5EC; position: relative;}
3266 + .pronon {font-weight: bold; color: #f85d00;}
3267 + ul.reglist li {margin-left: 30px; list-style: disc outside none;}
3268 + .procol {width: 475px; float: left;}
3269 + .ytindent .procol ul {font-size: 12px;}
3270 + .smallnote, .ytindent .smallnote {font-style: italic; font-size: 11px;}
3271 + .italic {font-style: italic;}
3272 + .ytindent h3 {font-size: 16px; line-height: 22px; margin: 5px 0px 10px 0px;}
3273 + #wizleftlink {float: left; display: block; width: 240px; font-style: italic; text-align: center; text-decoration: none;}
3274 + .button-primary {white-space: nowrap;}
3275 + p.submit {margin: 10px 0 0 0; padding: 10px 0 5px 0;}
3276 + .wp-core-ui p.submit .button-primary {
3277 + font-weight: bold;
3278 + font-size: 21px; min-height: 50px; padding: 0 20px 1px;
3279 + }
3280 + .wp-core-ui p.submit .button-primary[disabled] {
3281 + opacity: .4;
3282 + transition: opacity ease-in-out .3s;
3283 + }
3284 + .wp-core-ui p.submit .button-primary[disabled]:after {
3285 + content: url(<?php echo admin_url('images/wpspin_light.gif') ?>);
3286 + padding-left: 3px;
3287 + }
3288 + p.submit em {display: inline-block; padding-left: 20px; vertical-align: middle; width: 240px; margin-top: -6px;}
3289 + #opt_pro {box-shadow: 0px 0px 5px 0px #1870D5; width: 320px;vertical-align: top;}
3290 + #goprobox h3 {font-size: 14px;}
3291 + .chx {border-left: 5px solid rgba(100, 100, 100,.1); margin-bottom: 20px;}
3292 + .chx p {margin: 0px 0px 5px 0px;}
3293 + .cuz {background-image: linear-gradient(to bottom,#4983FF,#0C5597) !important; color: #ffffff;}
3294 + .brightpro {background-image: linear-gradient(to bottom,#ff5500,#cc2200) !important; color: #ffffff;}
3295 + #boxdefaultdims {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_defaultdims] ? '' : 'display: none;' ?>}
3296 + #boxcustomarrows {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_gallery_customarrows] ? 'display: block;' : 'display: none;' ?>}
3297 + #boxchannelsub {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_gallery_channelsub] ? 'display: block;' : 'display: none;' ?>}
3298 + #box_collapse_grid {font-weight: bold; padding: 0px 10px; <?php echo isset($all[self::$opt_gallery_collapse_grid]) && $all[self::$opt_gallery_collapse_grid] ? 'display: block;' : 'display: none;' ?>}
3299 + #box_restrict_wizard {padding: 0px 10px; <?php echo isset($all[self::$opt_restrict_wizard]) && $all[self::$opt_restrict_wizard] ? 'display: block;' : 'display: none;' ?>}
3300 + #box_restrict_wizard label {display: block; margin: 5px 10px;}
3301 + .textinput {border-width: 2px !important;}
3302 + input[type=text]::placeholder {font-weight: normal;}
3303 + h3.sect {border-radius: 10px; background-color: #D9E9F7; padding: 5px 5px 5px 10px; position: relative; font-weight: bold;}
3304 + h3.sect a {text-decoration: none; color: #E20000;}
3305 + h3.sect a.button-primary {color: #ffffff;}
3306 + h4.sect {border-radius: 10px; background-color: #D9E9F7; padding: 5px 5px 5px 10px; position: relative; font-weight: bold;}
3307 +
3308 + .nav-tab-wrapper sup {line-height: 0;}
3309 + .ytnav {margin-bottom: 15px;}
3310 + .ytnav a {font-weight: bold; display: inline-block; padding: 5px 10px; margin: 0px 15px 0px 0px; border: 1px solid #cccccc; border-radius: 6px;
3311 + text-decoration: none; background-color: #ffffff;}
3312 + .ytnav a:last-child {margin-right: 0;}
3313 + .jumper {height: 25px;}
3314 + .ssschema {float: right; width: 350px; height: auto; margin-right: 10px;}
3315 + .ssfb {float: right; height: auto; margin-right: 10px; margin-left: 15px; margin-bottom: 10px;}
3316 + .totop {position: absolute; right: 20px; top: 5px; color: #444444; font-size: 11px;}
3317 + input[type=checkbox] {border: 1px solid #000000;}
3318 + .chktitle {display: inline-block; padding: 1px 5px 1px 5px; border-radius: 3px; background-color: #ffffff; border: 1px solid #dddddd;}
3319 + b, strong {font-weight: bold;}
3320 + input.checkbox[disabled], input[type=radio][disabled] {border: 1px dashed #444444;}
3321 + .pad10 {padding: 10px;}
3322 + #boxdohl {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_dohl] ? '' : 'display: none;' ?>}
3323 + #boxdefaultvol {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_defaultvol] ? '' : 'display: none;' ?>}
3324 + .vol-output {display: none; width: 30px; color: #008800;}
3325 + .vol-range {background-color: #dddddd; border-radius: 3px; cursor: pointer;}
3326 + input#vol {vertical-align: middle;}
3327 + .vol-seeslider {display: none;}
3328 + .indent-option {margin-left: 25px;}
3329 + #boxmigratelist { <?php echo $all[self::$opt_migrate] ? '' : 'display: none;' ?>}
3330 + #boxresponsive_all { <?php echo $all[self::$opt_responsive] ? '' : 'display: none;' ?> padding-left: 25px; border-left: 5px solid rgba(100, 100, 100,.1); margin-left: 5px;}
3331 + .apikey-video{margin-left: 3%; display: inline-block; width: 50%; position: relative; padding-top: 29%}
3332 + .apikey-video iframe{display: block; width: 100%; height: 100%; position: absolute; top: 0; left: 0;}
3333 + #boxnocookie {display: inline-block; border-radius: 3px; padding: 2px 4px 2px 4px; color: red; <?php echo $all[self::$opt_nocookie] ? '' : 'display: none;' ?>}
3334 + #boxapinever {display: none; color: red;}
3335 + input[type="radio"]:checked ~ #boxapinever {display: block;}
3336 + #box_facade_mode { color: red; <?php echo (bool) $all[self::$opt_facade_mode] ? 'display: block;' : 'display: none;' ?>}
3337 + #box_gdpr_consent { color: red; <?php echo (bool) $all[self::$opt_gdpr_consent] ? 'display: block;' : 'display: none;' ?>}
3338 + .strike {text-decoration: line-through;}
3339 + .upgchecks { padding: 20px; border: 1px dotted #777777; background-color: #fcfcfc; }
3340 + .clearboth {clear: both;}
3341 + div.hr {clear: both; border-bottom: 1px dotted #A8BDD8; margin: 20px 0 20px 0;}
3342 + .wp-pointer-buttons a.close {margin-top: 0 !important;}
3343 + .pad20{padding: 20px 0 20px 0;}
3344 + .ssgallery {float: right; width: 130px; height: auto; margin-left: 15px; border: 3px solid #ffffff;}
3345 + .sssubscribe{display: block; width: 400px; height: auto;}
3346 + .ssaltgallery {float: right; height: auto; margin-right: 10px; margin-left: 15px; margin-bottom: 10px; width: 350px;}
3347 + .sspopupplayer {float: right; height: auto; margin-right: 10px; margin-left: 15px; margin-bottom: 10px; width: 350px;}
3348 + .sshidethumbimg {float: right; height: auto; margin-right: 10px; margin-left: 40px; margin-bottom: 10px; width: 315px;}
3349 + .sswizardbutton { max-width: 70%; height: auto;}
3350 + .save-changes-follow {position: fixed; z-index: 10000; bottom: 0; right: 0; background-color: #ffffff; padding: 0 20px; border-top-left-radius: 20px; border: 2px solid #aaaaaa; border-right-width: 0; border-bottom-width: 0;
3351 + -webkit-box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
3352 + -moz-box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
3353 + box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75); }
3354 + .alertify .ajs-body .ajs-content {line-height: 2.5em;}
3355 + #jumpmonetize h2:first-child {margin-bottom: 0;}
3356 +
3357 + .wrap-ytprefs h2.nav-tab-wrapper {
3358 + margin:22px 0 0 0;
3359 + }
3360 +
3361 + .wrap-ytprefs h3 .nav-tab {
3362 + padding: 5px 10px;
3363 + }
3364 +
3365 + .wrap-ytprefs section {
3366 + display:none;
3367 + padding-top:15px;
3368 + }
3369 + .wrap-ytprefs section#jumpdefaults {
3370 + display:block;
3371 + }
3372 + .wrap-ytprefs .no-js section {
3373 + display: block;
3374 + }
3375 +
3376 + .gdpr-options-left {
3377 + width: 65%;
3378 + float: left;
3379 + clear: left;
3380 + }
3381 +
3382 + .gdpr-options-right {
3383 + width: 33%;
3384 + float: right;
3385 + margin-top: 20px;
3386 + }
3387 +
3388 + .gdpr-options-right .img-gdpr-message {
3389 + width: 100%;
3390 + height: auto;
3391 + }
3392 +
3393 + iframe#gdpr_consent_message_ifr {
3394 + min-height: 250px !important;
3395 + }
3396 +
3397 + section#jumpwiz hr {
3398 + margin: 20px 0 20px 0;
3399 + }
3400 + .wiztab-screenshots {
3401 + float: right;
3402 + max-width: 50%;
3403 + height: auto;
3404 + clear: right;
3405 + margin-left: 30px;
3406 + margin-bottom: 15px;
3407 + display: block;
3408 + border: 5px solid #dddddd;
3409 + }
3410 +
3411 + .epyt-deprecated {
3412 + color: #aaaaaa;
3413 + }
3414 +
3415 + input[type="checkbox"] + label .check-note {
3416 + display: none;
3417 + }
3418 +
3419 + input[type="checkbox"]:checked + label .check-note {
3420 + display: inline;
3421 + }
3422 +
3423 + .not-live-content {
3424 + opacity: .3;
3425 + }
3426 +
3427 + #not_live_on:checked ~ .not-live-content, #not_live_on_channel:checked ~ .not-live-content {
3428 + opacity: 1;
3429 + }
3430 +
3431 + #facade_mode ~ .box_facade_mode {
3432 + opacity: .3;
3433 + }
3434 +
3435 + #facade_mode:checked ~ .box_facade_mode {
3436 + opacity: 1;
3437 + }
3438 +
3439 + #defer_js ~ .box_defer_jquery {
3440 + opacity: .3;
3441 + }
3442 +
3443 + #defer_js:checked ~ .box_defer_jquery {
3444 + opacity: 1;
3445 + }
3446 +
3447 + .epyt-fitvid {
3448 + width: 100%;
3449 + padding-top: 56.25%;
3450 + position: relative;
3451 + }
3452 +
3453 + .epyt-fitvid iframe {
3454 + position: absolute;
3455 + top: 0;
3456 + left:0;
3457 + right: 0;
3458 + bottom: 0;
3459 + width: 100%;
3460 + height: 100%;
3461 + }
3462 +
3463 + .wiztab-pagebuilder {
3464 + width: 50%;
3465 + float: left;
3466 + padding: 20px;
3467 + box-sizing: border-box;
3468 + }
3469 +
3470 + </style>
3471 + <div class="wrap wrap-ytprefs">
3472 + <h1><span class="dashicons-before dashicons-video-alt3"></span> <?php echo __('EmbedPlus for YouTube Settings') ?></h1>
3473 + <?php
3474 + self::settings_nav();
3475 + ?>
3476 +
3477 + <div class="ytindent">
3478 + <form name="form1" method="post" action="" id="ytform">
3479 + <input type="hidden" name="<?php echo $ytprefs_submitted; ?>" value="Y">
3480 + <?php wp_nonce_field('_epyt_save', '_epyt_nonce', true); ?>
3481 + <section class="pattern" id="jumpapikey">
3482 + <h2>
3483 + YouTube API Key
3484 + </h2>
3485 + <p>
3486 + Some features (such as galleries, and some wizard features) now require you to create a free YouTube API key from Google.
3487 + The instructions for this are very specific, so we created a video for you that's hopefully easy to follow: <a href="https://www.embedplus.com/how-to-create-a-youtube-api-key.aspx" target="_blank">Click this link</a> and follow the steps on the page. Then save your API key below.
3488 + </p>
3489 + <p>
3490 + <b class="chktitle">YouTube API Key:</b>
3491 + <input type="text" name="<?php echo self::$opt_apikey; ?>" id="<?php echo self::$opt_apikey; ?>" value="<?php echo esc_attr(trim($all[self::$opt_apikey])); ?>" class="textinput" style="width: 250px;">
3492 + </p>
3493 + </section>
3494 +
3495 + <section class="pattern" id="jumpdefaults">
3496 + <h2>
3497 + <?php _e("Default YouTube Options") ?>
3498 + </h2>
3499 + <p>
3500 + <?php _e("One of the benefits of using this plugin is that you can set site-wide default options for all your videos (click \"Save Changes\" when finished). However, you can also override them (and more) on a per-video basis. Directions on how to do that are in the next tab.") ?>
3501 + </p>
3502 +
3503 + <div class="ytindent chx">
3504 + <p>
3505 + <input name="<?php echo self::$opt_glance; ?>" id="<?php echo self::$opt_glance; ?>" <?php checked($all[self::$opt_glance], 1); ?> type="checkbox" class="checkbox">
3506 + <label for="<?php echo self::$opt_glance; ?>"><?php _e('<b class="chktitle">At a glance:</b> Show "At a Glance" Embed Links on the dashboard homepage.') ?></label>
3507 + </p>
3508 + <p>
3509 + <input name="<?php echo self::$opt_center; ?>" id="<?php echo self::$opt_center; ?>" <?php checked($all[self::$opt_center], 1); ?> type="checkbox" class="checkbox">
3510 + <label for="<?php echo self::$opt_center; ?>"><?php _e('<b class="chktitle">Centering:</b> Automatically center all your videos (not necessary if all your videos span the whole width of your blog).') ?></label>
3511 + </p>
3512 + <p>
3513 + <input name="<?php echo self::$opt_autoplay; ?>" id="<?php echo self::$opt_autoplay; ?>" <?php checked($all[self::$opt_autoplay], 1); ?> type="checkbox" class="checkbox">
3514 + <label for="<?php echo self::$opt_autoplay; ?>">
3515 + <?php _e('<b class="chktitle">Autoplay:</b> Automatically start playing your videos.') ?>
3516 + <strong>Note:</strong> If you're embedding videos from your own monetized YouTube channel, we advise you to read YouTube's resource page on ads on embedded videos:
3517 + <a href="https://support.google.com/youtube/answer/132596?hl=en" target="_blank">https://support.google.com/youtube/answer/132596?hl=en</a>
3518 + You'll see that videos that you want to monetize "should be embedded using the standard click-to-play embed and NOT a scripted play."
3519 + Unchecking this option guarantees standard click-to-play gallery embedding.
3520 + (Another Note: Desktop browsers like <a href="https://developers.google.com/youtube/iframe_api_reference#Mobile_considerations" target="_blank">Chrome and Safari are moving towards preventing autoplay for any video</a>. But, your chances are improved if you set your videos to initially start muted.)
3521 + </label>
3522 + </p>
3523 + <p>
3524 + <input name="<?php echo self::$opt_iv_load_policy; ?>" id="<?php echo self::$opt_iv_load_policy; ?>" <?php checked($all[self::$opt_iv_load_policy], 1); ?> type="checkbox" class="checkbox">
3525 + <label for="<?php echo self::$opt_iv_load_policy; ?>"><?php _e('<b class="chktitle">Annotations:</b> Show annotations by default.') ?></label>
3526 + </p>
3527 + <p>
3528 + <input name="<?php echo self::$opt_loop; ?>" id="<?php echo self::$opt_loop; ?>" <?php checked($all[self::$opt_loop], 1); ?> type="checkbox" class="checkbox">
3529 + <label for="<?php echo self::$opt_loop; ?>"><?php _e('<b class="chktitle">Looping:</b> Loop all your videos. Note: this feature is incompatible with the "hide related videos" feature.') ?></label>
3530 + </p>
3531 + <p>
3532 + <label>
3533 + <b class="chktitle">Related Videos:</b>
3534 + Show or hide related and recommended videos at the end of playback.
3535 + <br>
3536 + </label>
3537 + <input type="radio" name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>-1" value="-1" <?php checked($all[self::$opt_rel], -1); ?>>
3538 + <label for="<?php echo self::$opt_rel; ?>-1">Hide related videos at the end of playback</label> &nbsp;&nbsp;
3539 + <input type="radio" name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>0" value="0" <?php checked($all[self::$opt_rel], 0); ?>>
3540 + <label for="<?php echo self::$opt_rel; ?>0">Show related videos only from the video's channel</label> &nbsp;&nbsp;
3541 + <input type="radio" name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>1" value="1" <?php checked($all[self::$opt_rel], 1); ?>>
3542 + <label for="<?php echo self::$opt_rel; ?>1">Show related videos</label> &nbsp;&nbsp;
3543 + </p>
3544 + <p>
3545 + <input name="<?php echo self::$opt_fs; ?>" id="<?php echo self::$opt_fs; ?>" <?php checked($all[self::$opt_fs], 1); ?> type="checkbox" class="checkbox">
3546 + <label for="<?php echo self::$opt_fs; ?>"><?php _e('<b class="chktitle">Show Fullscreen Button:</b> Show the fullscreen button.') ?></label>
3547 + </p>
3548 + <p>
3549 + <input name="<?php echo self::$opt_acctitle; ?>" id="<?php echo self::$opt_acctitle; ?>" <?php checked($all[self::$opt_acctitle], 1); ?> type="checkbox" class="checkbox">
3550 + <label for="<?php echo self::$opt_acctitle; ?>"><b class="chktitle">Accessible Title Attributes: </b> Improve accessibility by using title attributes for screen reader support. It should help your site pass functional accessibility evaluations (FAE). </label>
3551 + </p>
3552 + <p>
3553 + <input name="<?php echo self::$opt_color; ?>" id="<?php echo self::$opt_color; ?>" <?php checked($all[self::$opt_color], 'red'); ?> type="checkbox" class="checkbox">
3554 + <label for="<?php echo self::$opt_color; ?>"><?php _e('<b class="chktitle">Red Progress Bar:</b> Use the red progress bar (uncheck to use a white progress bar).') ?></label>
3555 + </p>
3556 + <p>
3557 + <input name="<?php echo self::$opt_defaultdims; ?>" id="<?php echo self::$opt_defaultdims; ?>" <?php checked($all[self::$opt_defaultdims], 1); ?> type="checkbox" class="checkbox">
3558 + <span id="boxdefaultdims">
3559 + Width: <input type="number" min="200" name="<?php echo self::$opt_defaultwidth; ?>" id="<?php echo self::$opt_defaultwidth; ?>" value="<?php echo esc_attr(trim($all[self::$opt_defaultwidth])); ?>" class="textinput" style="width: 75px;"> &nbsp;
3560 + Height: <input type="number" min="200" name="<?php echo self::$opt_defaultheight; ?>" id="<?php echo self::$opt_defaultheight; ?>" value="<?php echo esc_attr(trim($all[self::$opt_defaultheight])); ?>" class="textinput" style="width: 75px;">
3561 + </span>
3562 +
3563 + <label for="<?php echo self::$opt_defaultdims; ?>"><?php _e('<b class="chktitle">Default Dimensions:</b> Make your videos have a default size, for better loading performance and consistency. Recommended: 800 x 450 (NOTE: If responsive sizing is also turned on, your videos will be responsive but also keep this aspect ratio.). Also, according to YouTube guidelines, the player must be a minimum of 200 x 200 (or recommended 480 x 270 for 16:9 ratio players) in order to display correctly.') ?></label>
3564 + </p>
3565 + <p>
3566 + <input name="<?php echo self::$opt_responsive; ?>" id="<?php echo self::$opt_responsive; ?>" <?php checked($all[self::$opt_responsive], 1); ?> type="checkbox" class="checkbox">
3567 + <label for="<?php echo self::$opt_responsive; ?>"><?php _e('<b class="chktitle">Responsive Video Sizing:</b> Make your videos responsive so that they dynamically fit in all screen sizes (smart phone, PC and tablet). NOTE: While this is checked, any custom hardcoded widths and heights you may have set will dynamically change too. <b>Uncheck this if your theme already properly handles responsive video sizing.</b>') ?></label>
3568 + <div id="boxresponsive_all">
3569 + <input type="radio" name="<?php echo self::$opt_responsive_all; ?>" id="<?php echo self::$opt_responsive_all; ?>1" value="1" <?php checked($all[self::$opt_responsive_all], 1); ?> >
3570 + <label for="<?php echo self::$opt_responsive_all; ?>1">Responsive for all YouTube videos</label> &nbsp;&nbsp;
3571 + <input type="radio" name="<?php echo self::$opt_responsive_all; ?>" id="<?php echo self::$opt_responsive_all; ?>0" value="0" <?php checked($all[self::$opt_responsive_all], 0); ?> >
3572 + <label for="<?php echo self::$opt_responsive_all; ?>0">Responsive for only videos embedded via this plugin</label>
3573 + </div>
3574 + </p>
3575 + <p>
3576 + <input name="<?php echo self::$opt_widgetfit; ?>" id="<?php echo self::$opt_widgetfit; ?>" <?php checked($all[self::$opt_widgetfit], 1); ?> type="checkbox" class="checkbox">
3577 + <label for="<?php echo self::$opt_widgetfit; ?>"><?php _e('<b class="chktitle">Autofit Widget Videos:</b> Make each video that you embed in a widget area automatically fit the width of its container.') ?></label>
3578 + </p>
3579 + <p>
3580 + <input name="<?php echo self::$opt_playsinline; ?>" id="<?php echo self::$opt_playsinline; ?>" <?php checked($all[self::$opt_playsinline], 1); ?> type="checkbox" class="checkbox">
3581 + <label for="<?php echo self::$opt_playsinline; ?>">
3582 + <b class="chktitle">iOS Playback:</b> Check this to allow your embeds to play inline within your page when viewed on iOS (iPhone and iPad) browsers. Uncheck it to have iOS launch your embeds in fullscreen instead.
3583 + <em>Disclaimer: YouTube/Google has issues with this iOS related parameter, but we are providing it here in the event that they support it consistently.</em>
3584 + </label>
3585 + </p>
3586 + <p>
3587 + <input name="<?php echo self::$opt_controls; ?>" id="<?php echo self::$opt_controls; ?>" <?php checked($all[self::$opt_controls], 1); ?> type="checkbox" class="checkbox">
3588 + <label for="<?php echo self::$opt_controls; ?>"><b class="chktitle">Show Controls:</b> Show the player's control bar. Unchecking this option creates a cleaner look but limits what your viewers can control (play position, volume, etc.).</label>
3589 + </p>
3590 + <p>
3591 + <input name="<?php echo self::$opt_disablekb; ?>" id="<?php echo self::$opt_disablekb; ?>" <?php checked($all[self::$opt_disablekb], 1); ?> type="checkbox" class="checkbox">
3592 + <label for="<?php echo self::$opt_disablekb; ?>"><b class="chktitle">Disable Keyboard Controls:</b> Prevent users from using keyboard controls (spacebar to play/pause, arrow keys to seek, etc.).</label>
3593 + </p>
3594 + <p>
3595 + <input name="<?php echo self::$opt_defaultvol; ?>" id="<?php echo self::$opt_defaultvol; ?>" <?php checked($all[self::$opt_defaultvol], 1); ?> type="checkbox" class="checkbox">
3596 + <label for="<?php echo self::$opt_defaultvol; ?>">
3597 + <b class="chktitle">Volume Initialization: </b>
3598 + Set an initial volume level for all of your embedded videos. Check this and you'll see a <span class="vol-seeslider">slider</span> <span class="vol-seetextbox">textbox</span> for setting the start volume to a value between 0 (mute) and 100 (max) percent. Leaving it unchecked means you want the visitor's default behavior. This feature is experimental and is less predictable on a page with more than one embed. Read more about why you might want to <a href="<?php echo self::$epbase ?>/mute-volume-youtube-wordpress.aspx" target="_blank">initialize YouTube embed volume here &raquo;</a>
3599 + </label>
3600 + <span id="boxdefaultvol">
3601 + Volume: <span class="vol-output"></span> <input min="0" max="100" step="1" type="text" name="<?php echo self::$opt_vol; ?>" id="<?php echo self::$opt_vol; ?>" value="<?php echo esc_attr(trim($all[self::$opt_vol])); ?>" >
3602 + </span>
3603 + </p>
3604 +
3605 + <p>
3606 + <input name="<?php echo self::$opt_pause_others; ?>" id="<?php echo self::$opt_pause_others; ?>" <?php checked($all[self::$opt_pause_others], 1); ?> type="checkbox" class="checkbox">
3607 + <label for="<?php echo self::$opt_pause_others; ?>">
3608 + <b class="chktitle"><?php _e('Simultaneous Playback Control:', 'youtube-embed-plus'); ?></b>
3609 + <?php _e('You can enable/disable the ability for visitors to have separate videos running at the same time on the same page. Check this to automatically pause other players while the current player is playing. (Note: this feature is not guaranteed to work with videos embedded from other plugins).', 'youtube-embed-plus'); ?>
3610 + </label>
3611 + </p>
3612 +
3613 + <p>
3614 + <input name="<?php echo self::$opt_cc_load_policy; ?>" id="<?php echo self::$opt_cc_load_policy; ?>" <?php checked($all[self::$opt_cc_load_policy], 1); ?> type="checkbox" class="checkbox">
3615 + <label for="<?php echo self::$opt_cc_load_policy; ?>"><?php _e('<b class="chktitle">Closed Captions:</b> Turn on closed captions by default.') ?></label>
3616 + </p>
3617 + <?php
3618 + $lang_codes = [
3619 + ["Abkhazian", "аҧсуа бызшәа, аҧсшәа", "ab", "abk", "abk"],
3620 + ["Afar", "Afaraf", "aa", "aar", "aar"],
3621 + ["Afrikaans", "Afrikaans", "af", "afr", "afr"],
3622 + ["Akan", "Akan", "ak", "aka", "aka"],
3623 + ["Albanian", "Shqip", "sq", "sqi", "alb"],
3624 + ["Amharic", "አማርኛ", "am", "amh", "amh"],
3625 + ["Arabic", "العربية", "ar", "ara", "ara"],
3626 + ["Aragonese", "aragonés", "an", "arg", "arg"],
3627 + ["Armenian", "Հայերեն", "hy", "hye", "arm"],
3628 + ["Assamese", "অসমীয়া", "as", "asm", "asm"],
3629 + ["Avaric", "авар мацӀ, магӀарул мацӀ", "av", "ava", "ava"],
3630 + ["Avestan", "avesta", "ae", "ave", "ave"],
3631 + ["Aymara", "aymar aru", "ay", "aym", "aym"],
3632 + ["Azerbaijani", "azərbaycan dili", "az", "aze", "aze"],
3633 + ["Bambara", "bamanankan", "bm", "bam", "bam"],
3634 + ["Bashkir", "башҡорт теле", "ba", "bak", "bak"],
3635 + ["Basque", "euskara, euskera", "eu", "eus", "baq"],
3636 + ["Belarusian", "беларуская мова", "be", "bel", "bel"],
3637 + ["Bengali", "বাংলা", "bn", "ben", "ben"],
3638 + ["Bihari languages", "भोजपुरी", "bh", "bih", "bih"],
3639 + ["Bislama", "Bislama", "bi", "bis", "bis"],
3640 + ["Bosnian", "bosanski jezik", "bs", "bos", "bos"],
3641 + ["Breton", "brezhoneg", "br", "bre", "bre"],
3642 + ["Bulgarian", "български език", "bg", "bul", "bul"],
3643 + ["Burmese", "ဗမာစာ", "my", "mya", "bur"],
3644 + ["Catalan, Valencian", "català, valencià", "ca", "cat", "cat"],
3645 + ["Chamorro", "Chamoru", "ch", "cha", "cha"],
3646 + ["Chechen", "нохчийн мотт", "ce", "che", "che"],
3647 + ["Chichewa, Chewa, Nyanja", "chiCheŵa, chinyanja", "ny", "nya", "nya"],
3648 + ["Chinese", "中文 (Zhōngwén), 汉语, 漢語", "zh", "zho", "chi"],
3649 + ["Chuvash", "чӑваш чӗлхи", "cv", "chv", "chv"],
3650 + ["Cornish", "Kernewek", "kw", "cor", "cor"],
3651 + ["Corsican", "corsu, lingua corsa", "co", "cos", "cos"],
3652 + ["Cree", "ᓀᐦᐃᔭᐍᐏᐣ", "cr", "cre", "cre"],
3653 + ["Croatian", "hrvatski jezik", "hr", "hrv", "hrv"],
3654 + ["Czech", "čeština, český jazyk", "cs", "ces", "cze"],
3655 + ["Danish", "dansk", "da", "dan", "dan"],
3656 + ["Divehi, Dhivehi, Maldivian", "ދިވެހި", "dv", "div", "div"],
3657 + ["Dutch, Flemish", "Nederlands, Vlaams", "nl", "nld", "dut"],
3658 + ["Dzongkha", "རྫོང་ཁ", "dz", "dzo", "dzo"],
3659 + ["English", "English", "en", "eng", "eng"],
3660 + ["Esperanto", "Esperanto", "eo", "epo", "epo"],
3661 + ["Estonian", "eesti, eesti keel", "et", "est", "est"],
3662 + ["Ewe", "Eʋegbe", "ee", "ewe", "ewe"],
3663 + ["Faroese", "føroyskt", "fo", "fao", "fao"],
3664 + ["Fijian", "vosa Vakaviti", "fj", "fij", "fij"],
3665 + ["Finnish", "suomi, suomen kieli", "fi", "fin", "fin"],
3666 + ["French", "français, langue française", "fr", "fra", "fre"],
3667 + ["Fulah", "Fulfulde, Pulaar, Pular", "ff", "ful", "ful"],
3668 + ["Galician", "Galego", "gl", "glg", "glg"],
3669 + ["Georgian", "ქართული", "ka", "kat", "geo"],
3670 + ["German", "Deutsch", "de", "deu", "ger"],
3671 + ["Greek, Modern (1453–)", "ελληνικά", "el", "ell", "gre"],
3672 + ["Guarani", "Avañe'ẽ", "gn", "grn", "grn"],
3673 + ["Gujarati", "ગુજરાતી", "gu", "guj", "guj"],
3674 + ["Haitian, Haitian Creole", "Kreyòl ayisyen", "ht", "hat", "hat"],
3675 + ["Hausa", "(Hausa) هَوُسَ", "ha", "hau", "hau"],
3676 + ["Hebrew", "עברית", "he", "heb", "heb"],
3677 + ["Herero", "Otjiherero", "hz", "her", "her"],
3678 + ["Hindi", "हिन्दी, हिंदी", "hi", "hin", "hin"],
3679 + ["Hiri Motu", "Hiri Motu", "ho", "hmo", "hmo"],
3680 + ["Hungarian", "magyar", "hu", "hun", "hun"],
3681 + ["Interlingua (International Auxiliary Language Association)", "Interlingua", "ia", "ina", "ina"],
3682 + ["Indonesian", "Bahasa Indonesia", "id", "ind", "ind"],
3683 + ["Interlingue, Occidental", "(originally:) Occidental, (after WWII:) Interlingue", "ie", "ile", "ile"],
3684 + ["Irish", "Gaeilge", "ga", "gle", "gle"],
3685 + ["Igbo", "Asụsụ Igbo", "ig", "ibo", "ibo"],
3686 + ["Inupiaq", "Iñupiaq, Iñupiatun", "ik", "ipk", "ipk"],
3687 + ["Ido", "Ido", "io", "ido", "ido"],
3688 + ["Icelandic", "Íslenska", "is", "isl", "ice"],
3689 + ["Italian", "Italiano", "it", "ita", "ita"],
3690 + ["Inuktitut", "ᐃᓄᒃᑎᑐᑦ", "iu", "iku", "iku"],
3691 + ["Japanese", "日本語 (にほんご)", "ja", "jpn", "jpn"],
3692 + ["Javanese", "ꦧꦱꦗꦮ, Basa Jawa", "jv", "jav", "jav"],
3693 + ["Kalaallisut, Greenlandic", "kalaallisut, kalaallit oqaasii", "kl", "kal", "kal"],
3694 + ["Kannada", "ಕನ್ನಡ", "kn", "kan", "kan"],
3695 + ["Kanuri", "Kanuri", "kr", "kau", "kau"],
3696 + ["Kashmiri", "कश्मीरी, كشميري‎", "ks", "kas", "kas"],
3697 + ["Kazakh", "қазақ тілі", "kk", "kaz", "kaz"],
3698 + ["Central Khmer", "ខ្មែរ, ខេមរភាសា, ភាសាខ្មែរ", "km", "khm", "khm"],
3699 + ["Kikuyu, Gikuyu", "Gĩkũyũ", "ki", "kik", "kik"],
3700 + ["Kinyarwanda", "Ikinyarwanda", "rw", "kin", "kin"],
3701 + ["Kirghiz, Kyrgyz", "Кыргызча, Кыргыз тили", "ky", "kir", "kir"],
3702 + ["Komi", "коми кыв", "kv", "kom", "kom"],
3703 + ["Kongo", "Kikongo", "kg", "kon", "kon"],
3704 + ["Korean", "한국어", "ko", "kor", "kor"],
3705 + ["Kurdish", "Kurdî, کوردی‎", "ku", "kur", "kur"],
3706 + ["Kuanyama, Kwanyama", "Kuanyama", "kj", "kua", "kua"],
3707 + ["Latin", "latine, lingua latina", "la", "lat", "lat"],
3708 + ["Luxembourgish, Letzeburgesch", "Lëtzebuergesch", "lb", "ltz", "ltz"],
3709 + ["Ganda", "Luganda", "lg", "lug", "lug"],
3710 + ["Limburgan, Limburger, Limburgish", "Limburgs", "li", "lim", "lim"],
3711 + ["Lingala", "Lingála", "ln", "lin", "lin"],
3712 + ["Lao", "ພາສາລາວ", "lo", "lao", "lao"],
3713 + ["Lithuanian", "lietuvių kalba", "lt", "lit", "lit"],
3714 + ["Luba-Katanga", "Kiluba", "lu", "lub", "lub"],
3715 + ["Latvian", "latviešu valoda", "lv", "lav", "lav"],
3716 + ["Manx", "Gaelg, Gailck", "gv", "glv", "glv"],
3717 + ["Macedonian", "македонски јазик", "mk", "mkd", "mac"],
3718 + ["Malagasy", "fiteny malagasy", "mg", "mlg", "mlg"],
3719 + ["Malay", "Bahasa Melayu, بهاس ملايو‎", "ms", "msa", "may"],
3720 + ["Malayalam", "മലയാളം", "ml", "mal", "mal"],
3721 + ["Maltese", "Malti", "mt", "mlt", "mlt"],
3722 + ["Maori", "te reo Māori", "mi", "mri", "mao"],
3723 + ["Marathi", "मराठी", "mr", "mar", "mar"],
3724 + ["Marshallese", "Kajin M̧ajeļ", "mh", "mah", "mah"],
3725 + ["Mongolian", "Монгол хэл", "mn", "mon", "mon"],
3726 + ["Nauru", "Dorerin Naoero", "na", "nau", "nau"],
3727 + ["Navajo, Navaho", "Diné bizaad", "nv", "nav", "nav"],
3728 + ["North Ndebele", "isiNdebele", "nd", "nde", "nde"],
3729 + ["Nepali", "नेपाली", "ne", "nep", "nep"],
3730 + ["Ndonga", "Owambo", "ng", "ndo", "ndo"],
3731 + ["Norwegian Bokmål", "Norsk Bokmål", "nb", "nob", "nob"],
3732 + ["Norwegian Nynorsk", "Norsk Nynorsk", "nn", "nno", "nno"],
3733 + ["Norwegian", "Norsk", "no", "nor", "nor"],
3734 + ["Sichuan Yi, Nuosu", "ꆈꌠ꒿ Nuosuhxop", "ii", "iii", "iii"],
3735 + ["South Ndebele", "isiNdebele", "nr", "nbl", "nbl"],
3736 + ["Occitan", "occitan, lenga d'òc", "oc", "oci", "oci"],
3737 + ["Ojibwa", "ᐊᓂᔑᓈᐯᒧᐎᓐ", "oj", "oji", "oji"],
3738 + ["Church Slavic, Old Slavonic, Church Slavonic, Old Bulgarian, Old Church Slavonic", "ѩзыкъ словѣньскъ", "cu", "chu", "chu"],
3739 + ["Oromo", "Afaan Oromoo", "om", "orm", "orm"],
3740 + ["Oriya", "ଓଡ଼ିଆ", "or", "ori", "ori"],
3741 + ["Ossetian, Ossetic", "ирон æвзаг", "os", "oss", "oss"],
3742 + ["Punjabi, Panjabi", "ਪੰਜਾਬੀ, پنجابی‎", "pa", "pan", "pan"],
3743 + ["Pali", "पालि, पाळि", "pi", "pli", "pli"],
3744 + ["Persian", "فارسی", "fa", "fas", "per"],
3745 + ["Polish", "język polski, polszczyzna", "pl", "pol", "pol"],
3746 + ["Pashto, Pushto", "پښتو", "ps", "pus", "pus"],
3747 + ["Portuguese", "Português", "pt", "por", "por"],
3748 + ["Quechua", "Runa Simi, Kichwa", "qu", "que", "que"],
3749 + ["Romansh", "Rumantsch Grischun", "rm", "roh", "roh"],
3750 + ["Rundi", "Ikirundi", "rn", "run", "run"],
3751 + ["Romanian, Moldavian, Moldovan", "Română", "ro", "ron", "rum"],
3752 + ["Russian", "русский", "ru", "rus", "rus"],
3753 + ["Sanskrit", "संस्कृतम्", "sa", "san", "san"],
3754 + ["Sardinian", "sardu", "sc", "srd", "srd"],
3755 + ["Sindhi", "सिन्धी, سنڌي، سندھی‎", "sd", "snd", "snd"],
3756 + ["Northern Sami", "Davvisámegiella", "se", "sme", "sme"],
3757 + ["Samoan", "gagana fa'a Samoa", "sm", "smo", "smo"],
3758 + ["Sango", "yângâ tî sängö", "sg", "sag", "sag"],
3759 + ["Serbian", "српски језик", "sr", "srp", "srp"],
3760 + ["Gaelic, Scottish Gaelic", "Gàidhlig", "gd", "gla", "gla"],
3761 + ["Shona", "chiShona", "sn", "sna", "sna"],
3762 + ["Sinhala, Sinhalese", "සිංහල", "si", "sin", "sin"],
3763 + ["Slovak", "Slovenčina, Slovenský Jazyk", "sk", "slk", "slo"],
3764 + ["Slovenian", "Slovenski Jezik, Slovenščina", "sl", "slv", "slv"],
3765 + ["Somali", "Soomaaliga, af Soomaali", "so", "som", "som"],
3766 + ["Southern Sotho", "Sesotho", "st", "sot", "sot"],
3767 + ["Spanish, Castilian", "Español", "es", "spa", "spa"],
3768 + ["Sundanese", "Basa Sunda", "su", "sun", "sun"],
3769 + ["Swahili", "Kiswahili", "sw", "swa", "swa"],
3770 + ["Swati", "SiSwati", "ss", "ssw", "ssw"],
3771 + ["Swedish", "Svenska", "sv", "swe", "swe"],
3772 + ["Tamil", "தமிழ்", "ta", "tam", "tam"],
3773 + ["Telugu", "తెలుగు", "te", "tel", "tel"],
3774 + ["Tajik", "тоҷикӣ, toçikī, تاجیکی‎", "tg", "tgk", "tgk"],
3775 + ["Thai", "ไทย", "th", "tha", "tha"],
3776 + ["Tigrinya", "ትግርኛ", "ti", "tir", "tir"],
3777 + ["Tibetan", "བོད་ཡིག", "bo", "bod", "tib"],
3778 + ["Turkmen", "Türkmen, Түркмен", "tk", "tuk", "tuk"],
3779 + ["Tagalog", "Wikang Tagalog", "tl", "tgl", "tgl"],
3780 + ["Tswana", "Setswana", "tn", "tsn", "tsn"],
3781 + ["Tonga (Tonga Islands)", "Faka Tonga", "to", "ton", "ton"],
3782 + ["Turkish", "Türkçe", "tr", "tur", "tur"],
3783 + ["Tsonga", "Xitsonga", "ts", "tso", "tso"],
3784 + ["Tatar", "татар теле, tatar tele", "tt", "tat", "tat"],
3785 + ["Twi", "Twi", "tw", "twi", "twi"],
3786 + ["Tahitian", "Reo Tahiti", "ty", "tah", "tah"],
3787 + ["Uighur, Uyghur", "ئۇيغۇرچە‎, Uyghurche", "ug", "uig", "uig"],
3788 + ["Ukrainian", "Українська", "uk", "ukr", "ukr"],
3789 + ["Urdu", "اردو", "ur", "urd", "urd"],
3790 + ["Uzbek", "Oʻzbek, Ўзбек, أۇزبېك‎", "uz", "uzb", "uzb"],
3791 + ["Venda", "Tshivenḓa", "ve", "ven", "ven"],
3792 + ["Vietnamese", "Tiếng Việt", "vi", "vie", "vie"],
3793 + ["Volapük", "Volapük", "vo", "vol", "vol"],
3794 + ["Walloon", "Walon", "wa", "wln", "wln"],
3795 + ["Welsh", "Cymraeg", "cy", "cym", "wel"],
3796 + ["Wolof", "Wollof", "wo", "wol", "wol"],
3797 + ["Western Frisian", "Frysk", "fy", "fry", "fry"],
3798 + ["Xhosa", "isiXhosa", "xh", "xho", "xho"],
3799 + ["Yiddish", "ייִדיש", "yi", "yid", "yid"],
3800 + ["Yoruba", "Yorùbá", "yo", "yor", "yor"],
3801 + ["Zhuang, Chuang", "Saɯ cueŋƅ, Saw cuengh", "za", "zha", "zha"],
3802 + ["Zulu", "isiZulu", "zu", "zul", "zul"]
3803 + ];
3804 +
3805 + $selected_val = trim($all[self::$opt_cc_lang_pref]);
3806 + ?>
3807 + <p>
3808 + <label for="<?php echo self::$opt_cc_lang_pref; ?>"><b class="chktitle">Closed Captions Language:</b></label>
3809 + <select name="<?php echo self::$opt_cc_lang_pref; ?>" id="<?php echo self::$opt_cc_lang_pref; ?>" style="width: 260px;">
3810 + <option <?php echo '' == $selected_val ? 'selected' : '' ?> value="">Default/Unspecified</option>
3811 + <?php
3812 + foreach ($lang_codes as $idx => $lang_row)
3813 + {
3814 + $iso_code = $lang_row[2];
3815 + $iso_label = $lang_row[0] . ' - ' . $lang_row[1];
3816 + ?>
3817 + <option <?php echo $iso_code == $selected_val ? 'selected' : '' ?> value="<?php echo $iso_code ?>"><?php echo $iso_label ?></option>
3818 + <?php
3819 + }
3820 + ?>
3821 + </select>
3822 + Select the preferred default language for closed captions (when available).
3823 + </p>
3824 + <p>
3825 + <input name="<?php echo self::$opt_dohl; ?>" id="<?php echo self::$opt_dohl; ?>" <?php checked($all[self::$opt_dohl], 1); ?> type="checkbox" class="checkbox">
3826 + <label for="<?php echo self::$opt_dohl; ?>"><b class="chktitle">Player Localization / Internationalization: </b>
3827 + Automatically detect your site's default language (using get_locale) and set your YouTube embeds interface language so that it matches. Specifically, this will set the player's tooltips and caption track if your language is natively supported by YouTube. We suggest checking this if English is not your site's default language. <a href="<?php echo self::$epbase ?>/youtube-iso-639-1-language-codes.aspx" target="_blank">See here for more details &raquo;</a></label>
3828 + </p>
3829 + <p>
3830 + <input name="<?php echo self::$opt_playlistorder; ?>" id="<?php echo self::$opt_playlistorder; ?>" <?php checked($all[self::$opt_playlistorder], 1); ?> type="checkbox" class="checkbox">
3831 + <label for="<?php echo self::$opt_playlistorder; ?>">
3832 + <b class="chktitle">Self-contained Playlist Ordering:</b>
3833 + Note: This option does <strong class="orange">NOT</strong> apply to galleries. It applies only to these kinds of <em>self-contained playlists</em> (Example: <a target="_blank" href="https://www.youtube.com/watch?v=J50PlRZHH9I&t=3m20s">https://www.youtube.com/watch?v=J50PlRZHH9I&t=3m20s</a>).
3834 + If you're trying to control the order of a <em>gallery</em> instead, then you must be the owner of the playlist, go to YouTube.com, and reorder it there. This plugin can only order a <em>gallery</em> the way the owner ordered the source playlist.
3835 + Check this option if you just want your <em>self-contained playlists</em> to begin with the latest added video by default. (Unchecking this will force playlists to always start with your selected specific video, even if you add videos to the playlist later).
3836 + </label>
3837 + </p>
3838 + <p>
3839 + <input name="<?php echo self::$opt_onboarded; ?>" id="<?php echo self::$opt_onboarded; ?>" <?php checked($all[self::$opt_onboarded], 1); ?> type="checkbox" class="checkbox">
3840 + <label for="<?php echo self::$opt_onboarded; ?>">
3841 + <b class="chktitle">Hide Quick Setup Guide:</b>
3842 + Check this to hide the installation setup wizard when this page loads.
3843 + </label>
3844 + </p>
3845 + <p>
3846 + <input name="<?php echo self::$opt_show_pointer; ?>" id="<?php echo self::$opt_show_pointer; ?>" <?php checked($all[self::$opt_show_pointer], 1); ?> type="checkbox" class="checkbox">
3847 + <label for="<?php echo self::$opt_show_pointer; ?>">
3848 + <b class="chktitle">Show New Feature Notice:</b>
3849 + Show admin notice of new plugin features after updates.
3850 + </label>
3851 + </p>
3852 + <div id="not_live_content_scroll" class="p">
3853 + <p>
3854 + <b class="chktitle">Use "Not Live" Fallback Content For Live Streams:</b> (<a href="<?php echo self::$epbase ?>/how-to-embed-a-youtube-livestream-in-wordpress.aspx" target="_blank">More info here</a>)
3855 + This feature lets you display alternate content if your live stream is not currently active. This feature works for <strong>direct link</strong> live streams
3856 + (more info about channel-based live streams below).
3857 + </p>
3858 + <div class="ytindent chx">
3859 + <input name="<?php echo self::$opt_not_live_on; ?>" id="<?php echo self::$opt_not_live_on; ?>" <?php checked($all[self::$opt_not_live_on], 1); ?> type="checkbox" class="checkbox">
3860 + <label for="<?php echo self::$opt_not_live_on; ?>"><span class="chktitle">Turn on for <b>direct link</b> live streams:</span>
3861 + When your direct-link embed is not streaming live, the YouTube live player usually displays a countdown after the user clicks the play button.
3862 + Instead of showing that player, you can display some "coming soon" content in that space for your visitors to see until your video begins to live stream.
3863 + The plugin will automatically switch to your video's live stream once it's active. In the <em>"Not Live" Fallback Content</em> box below, enter what you would like to appear until then.
3864 + You can even insert shortcodes from our plugin into the box below (shortcodes from other plugins may or may not work correctly).
3865 + If you just want to show the standard countdown player that YouTube provides, don't use this feature.
3866 + <strong>NOTE: Turning this on for direct-link live streams uses a significant amount of your YouTube API quota. We suggest unchecking it if your site has high traffic. If you chose to use this feature, do <u>not</u> put another live stream embed below.</strong>
3867 + </label>
3868 + <br>
3869 + <br>
3870 + <input disabled id="<?php echo self::$opt_not_live_on_channel; ?>" type="checkbox" class="checkbox">
3871 + <label><span class="chktitle">Turn on for <b>channel</b> live streams: <sup class="orange">upgrade required</sup></span>
3872 + Unfortunately, Google has recently removed their YouTube API feature that used to support channel-based live streams. It appears they won't change things back. However, you do have a couple of choices:
3873 + <ol>
3874 + <li>Use "Direct link" live streams, as explained above. The trade-off is that you will have to manually post and take down your future live streams every time they start and when they end, respectively.</li>
3875 + <li>Or <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" target="_blank">upgrade to Pro</a>, which has a solution that brings back all the "set it and forget it" features of channel-based embeds. We spent a significant amount of time developing a stable, long-term solution around YouTube's limitations, so we are releasing this effort exclusively to our Pro customers.</li>
3876 + </ol>
3877 + </label>
3878 + <div class="p not-live-content">
3879 + <p>
3880 + <b>"Not Live" Fallback Content:</b>
3881 + </p>
3882 + <?php
3883 + wp_editor(wp_kses_post($all[self::$opt_not_live_content]), self::$opt_not_live_content, array('textarea_rows' => 7));
3884 + ?>
3885 + </div>
3886 + </div>
3887 + </div>
3888 + </div>
3889 + </section>
3890 + <section class="pattern" id="jumpprivacy">
3891 + <h2>Security Options</h2>
3892 + <p>
3893 + <input name="<?php echo self::$opt_restrict_wizard; ?>" id="<?php echo self::$opt_restrict_wizard; ?>" <?php checked($all[self::$opt_restrict_wizard], 1); ?> type="checkbox" class="checkbox">
3894 + <label for="<?php echo self::$opt_restrict_wizard; ?>">
3895 + <b class="chktitle">Restrict Wizard Button:</b> Select which roles can use the EmbedPlus for YouTube wizard button. For example, you may wish to hide the button from contributors submitting content on the front end.
3896 + </label>
3897 + <br>
3898 + <span id="box_restrict_wizard" class="chx">
3899 + <?php
3900 + foreach (self::$dft_roles as $idx => $role)
3901 + {
3902 + ?>
3903 + <label>
3904 + <input type="checkbox" name="<?php echo self::$opt_restrict_wizard_roles . '[]' ?>" value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, $all[self::$opt_restrict_wizard_roles]) ? 'checked' : '' ?>>
3905 + <?php echo esc_html(ucfirst($role)); ?>s
3906 + </label>
3907 + <?php
3908 + }
3909 + ?>
3910 + </span>
3911 + </p>
3912 + <p>
3913 + <input name="<?php echo self::$opt_origin; ?>" id="<?php echo self::$opt_origin; ?>" <?php checked($all[self::$opt_origin], 1); ?> type="checkbox" class="checkbox">
3914 + <label for="<?php echo self::$opt_origin; ?>"><b class="chktitle">Extra Player Security: </b>
3915 + Add site origin information with each embed code as an extra security measure. In YouTube's/Google's own words, checking this option "protects against malicious third-party JavaScript being injected into your page and hijacking control of your YouTube player." We especially recommend checking it as it adds higher security than the built-in YouTube embedding method that comes with the current version of WordPress (i.e. oembed).
3916 + </label>
3917 + </p>
3918 +
3919 + <h2>Privacy Options</h2>
3920 + <p>These options may help with privacy restrictions such as GDPR and the EU Cookie Law.</p>
3921 + <div class="ytindent chx">
3922 + <p>
3923 + <b class="chktitle">YouTube API Loading:</b> Choose when to load the YouTube API. The "Restricted" or "Never" options will help with GDPR compliance:
3924 + <ul class="indent-option">
3925 + <li><label><input type="radio" name="<?php echo self::$opt_ytapi_load ?>" value="light" <?php checked($all[self::$opt_ytapi_load], 'light'); ?> /> <em>Restricted</em> - (Recommended) Only load the API on pages that have a YouTube video.</label></li>
3926 + <li><label>
3927 + <input type="radio" name="<?php echo self::$opt_ytapi_load ?>" value="never" <?php checked($all[self::$opt_ytapi_load], 'never'); ?> /> <em>Never</em> - Do not load the YouTube API. Note: The "Never" choice may break a few features such as Volume Initialization and Gallery Continuous/Auto Play.
3928 + <div id="boxapinever">
3929 + Note: Checking this option may break some features such as the ones listed below:
3930 + <ul class="list-ul">
3931 + <li>Galleries</li>
3932 + <li>Hide related videos at the end of playback</li>
3933 + <li>Volume initialization</li>
3934 + <li>Simultaneous playback control</li>
3935 + <li>Playing video on mobile devices</li>
3936 + </ul>
3937 + </div>
3938 + </label></li>
3939 + <li><label><input type="radio" name="<?php echo self::$opt_ytapi_load ?>" value="always" <?php checked($all[self::$opt_ytapi_load], 'always'); ?> /> <em>Always</em> - Load the API on all pages. In most cases, the "Always" choice is not necessary.</label></li>
3940 + </ul>
3941 + </p>
3942 +
3943 +
3944 + <p>
3945 + <input name="<?php echo self::$opt_gdpr_consent; ?>" id="<?php echo self::$opt_gdpr_consent; ?>" <?php checked($all[self::$opt_gdpr_consent], 1); ?> type="checkbox" class="checkbox">
3946 + <label for="<?php echo self::$opt_gdpr_consent; ?>">
3947 + <b class="chktitle">Privacy/GDPR - Show Consent Message:</b> Ask for consent before loading YouTube content. A message will be displayed in place of the YouTube video, as shown in the screenshot below. Once the visitor approves consent, the YouTube content will load. You can customize the message text and the button text in the next 2 options.
3948 + See this feature demonstrated in <a href="https://www.youtube.com/watch?v=lm_HIic6obw" target="_blank">this video</a>.
3949 + </label>
3950 + <span id="box_gdpr_consent">
3951 + Note: If your visitors click a red accept button but your site doesn't reveal the video, you probably have a caching plugin. There should be a setting in your caching plugin to prevent caching the consent cookie. The name of the consent cookie is: <code>ytprefs_gdpr_consent</code>
3952 + </span>
3953 + </p>
3954 +
3955 + <p>
3956 + <label for="<?php echo self::$opt_gdpr_consent_message; ?>">
3957 + <b class="chktitle">Privacy/GDPR - Consent Message Text:</b>
3958 + Below you can customize the message that will appear to visitors before they accept YouTube content:
3959 + </label>
3960 + <div class="clearboth"></div>
3961 + <div class="gdpr-options-left">
3962 + <?php
3963 + wp_editor(wp_kses_post($all[self::$opt_gdpr_consent_message]), self::$opt_gdpr_consent_message, array(
3964 + 'textarea_rows' => 22,
3965 + 'media_buttons' => false,
3966 + 'teeny' => true
3967 + ));
3968 + ?>
3969 + </div>
3970 + <div class="gdpr-options-right">
3971 + <p><em>Example of message and button:</em></p>
3972 +
3973 + <img src="<?php echo plugins_url('images/ss-gdpr-message.png', __FILE__) ?>" alt="GDPR Consent Message Example" class="img-gdpr-message" />
3974 + </div>
3975 +
3976 + </p>
3977 + <div class="clearboth"></div>
3978 + <p>
3979 + <label for="<?php echo self::$opt_gdpr_consent_button; ?>">
3980 + <b class="chktitle">Privacy/GDPR - Consent Button Text:</b>
3981 + This is the text for the red "Accept" button that appears with the above privacy/GDPR message:
3982 + </label>
3983 + <br>
3984 + <input type="text" placeholder="Example: Accept YouTube Content" name="<?php echo self::$opt_gdpr_consent_button; ?>" id="<?php echo self::$opt_gdpr_consent_button; ?>" value="<?php echo esc_attr(trim($all[self::$opt_gdpr_consent_button])); ?>" class="textinput regular-text"/>
3985 + </p>
3986 +
3987 + <p>
3988 + <input name="<?php echo self::$opt_nocookie; ?>" id="<?php echo self::$opt_nocookie; ?>" <?php checked($all[self::$opt_nocookie], 1); ?> type="checkbox" class="checkbox">
3989 + <label for="<?php echo self::$opt_nocookie; ?>">
3990 + <b class="chktitle">No Cookies:</b> Prevent YouTube from leaving tracking cookies on your visitors browsers unless they actual play the videos. This is coded to apply this behavior on links in your past post as well.
3991 + <div id="boxnocookie">
3992 + Note: Checking this option may introduce issues to features that depend YouTube's API, such as the ones listed below. We suggest testing them out to make sure you are still pleased with the results:
3993 + <ul class="list-ul">
3994 + <li>Galleries</li>
3995 + <li>Hide related videos at the end of playback</li>
3996 + <li>Volume initialization</li>
3997 + <li>Simultaneous playback control</li>
3998 + <li>Playing video on mobile devices</li>
3999 + </ul>
4000 + </div>
4001 + </label>
4002 + </p>
4003 + </div>
4004 + </section>
4005 +
4006 + <section class="pattern" id="jumpwiz">
4007 + <h2>Visual YouTube Wizard Directions</h2>
4008 + <p>
4009 + While you're writing your post or page, you have the ability to search YouTube and insert videos, playlists, and even galleries right from your editor. Below are directions for each type of WordPress editor.
4010 + For <strong>pagebuilder instructions</strong>, scroll down to the "Pagebuilder Tips" section.
4011 + </p>
4012 + <h3>Classic Editor</h3>
4013 + <img class="wiztab-screenshots" src="<?php echo plugins_url('images/ss-wiz-classic.png', __FILE__) ?>">
4014 + <p>
4015 + Simply click the EmbedPlus for YouTube wizard button found above
4016 + your post editor to start the wizard (see image to the right to locate this button). There, you'll have several options for different types of embeds.
4017 + Each embed code will have an "Insert Into Editor" button that you can click to directly embed the desired video link to your post without having to copy and paste.
4018 + </p>
4019 + <hr class="clearboth">
4020 + <h3>Widgets</h3>
4021 + <img class="wiztab-screenshots" src="<?php echo plugins_url('images/ss-wiz-widget.png', __FILE__) ?>">
4022 + <p>
4023 + To insert a video in a widget area, use the Text widget that comes with WordPress. Simply click the EmbedPlus for YouTube wizard button found above
4024 + the widget textbox to start the wizard (see image to the right to locate this button). There, you'll have several options for different types of embeds.
4025 + Each embed code will have an "Insert Into Editor" button that you can click to directly embed the desired video link to your post without having to copy and paste.
4026 + </p>
4027 + <hr class="clearboth"/>
4028 + <h3>Gutenberg Block Editor</h3>
4029 + <img class="wiztab-screenshots" src="<?php echo plugins_url('images/ss-wiz-gbblock.png', __FILE__) ?>">
4030 + <p>
4031 + Click on the (+) sign for the block editor list. The EmbedPlus for YouTube Wizard block is located under the "Embeds" category (make sure you choose "YouTube <strong>Wizard</strong>" not "YouTube").
4032 + Then your page will show a placeholder where you can launch the wizard. In the wizard, you'll have several options for different types of embeds.
4033 + Each embed code will have an "Insert Into Editor" button that you can click to directly embed the desired video link to your post without having to copy and paste.
4034 + You'll also be able to preview and interact with your embed without having to view the page on the front end.
4035 + </p>
4036 + <hr class="clearboth"/>
4037 + <h3>Gutenberg Classic Block</h3>
4038 + <img class="wiztab-screenshots" src="<?php echo plugins_url('images/ss-wiz-gbclassicblock.png', __FILE__) ?>">
4039 + <p>
4040 + Are you using Gutenberg but not quite ready to start using all the blocks? Well, you can still access our wizard if you wish to continue using Gutenberg's Classic block.
4041 + The Classic block brings back the former editor you used before WordPress, and so we've added a button to it you can use to launch the wizard (see example on the right).
4042 + Simply click the wizard button to start the wizard. There, you'll have several options for different types of embeds.
4043 + Each embed code will have an "Insert Into Editor" button that you can click to directly embed the desired video link to your post without having to copy and paste.
4044 + </p>
4045 + <hr class="clearboth"/>
4046 + <h3>Pro Customization</h3>
4047 + <img class="wiztab-screenshots" src="<?php echo plugins_url('images/ssprowizard.png', __FILE__) ?>">
4048 + <p>
4049 + <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx?ref=wizdirections" target="_blank"><b>Even more options are available to PRO users, no matter which editor you choose!</b></a>
4050 + Simply click the "Customize" button in the wizard to further personalize each of your embeds without having to manually add special codes yourself.
4051 + The customize button will allow you to easily override most of the above default options for that embed.
4052 + </p>
4053 + <hr class="clearboth"/>
4054 + <h2 id="jumppagebuilder">Pagebuilder Tips</h2>
4055 + <p>
4056 + Most page builders have a text widget in which our plugin's wizard can be launched. Watch the videos below for some popular ones, namely Elementor, Beaver Builder, and SiteOrigin.
4057 + </p>
4058 + <p>
4059 + <em>Note: Please do not check the "Also Defer jQuery" option if you use a pagebuilder. Some pagebuilders cannot work if jQuery is deferred.</em>
4060 + </p>
4061 + <div class="wiztab-pagebuilder">
4062 + <h3>Beaver Builder</h3>
4063 + <div class="epyt-fitvid">
4064 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/bPgz0jyt7TE?rel=0" allowfullscreen="" frameborder="0"></iframe>
4065 + </div>
4066 + </div>
4067 + <div class="wiztab-pagebuilder">
4068 + <h3>Elementor</h3>
4069 + <div class="epyt-fitvid">
4070 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/ldNfIGRTxDU?rel=0" allowfullscreen="" frameborder="0"></iframe>
4071 + </div>
4072 + </div>
4073 + <div class="wiztab-pagebuilder">
4074 + <h3>Site Origin</h3>
4075 + <div class="epyt-fitvid">
4076 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/7QNYw_g-7WM?rel=0" allowfullscreen="" frameborder="0"></iframe>
4077 + </div>
4078 + </div>
4079 + <div class="wiztab-pagebuilder">
4080 + <h3>Visual Composer</h3>
4081 + <div class="epyt-fitvid">
4082 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/FWBQc9XhAqM?rel=0" allowfullscreen="" frameborder="0"></iframe>
4083 + </div>
4084 + </div>
4085 + <div class="wiztab-pagebuilder">
4086 + <h3>WPBakery</h3>
4087 + <div class="epyt-fitvid">
4088 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/7T5wPoEujN8?rel=0" allowfullscreen="" frameborder="0"></iframe>
4089 + </div>
4090 + </div>
4091 + <div class="wiztab-pagebuilder">
4092 + <p>
4093 + If you don't see your page builder listed above, don't worry. For pretty much any page builder with a short code widget, you can also embed your video, gallery, live stream, or premiere by creating the short code using the plugin's wizard and then embedding the code in the short code widget or text widget of your page builder of choice.
4094 + </p>
4095 + </div>
4096 + </section>
4097 +
4098 + <section class="pattern" id="jumpgallery">
4099 + <h2>Gallery Settings and Directions</h2>
4100 + <img class="ssgallery" src="<?php echo plugins_url('images/ssgallery.png', __FILE__) ?>">
4101 + <p>
4102 + <a target="_blank" href="<?php echo self::$epbase ?>/responsive-youtube-playlist-channel-gallery-for-wordpress.aspx">You can now make playlist embeds (and channel-playlist embeds) have a gallery layout &raquo;</a>. <strong>First, you must obtain your YouTube API key</strong>.
4103 + Don't worry, it's an easy process. Just <a href="https://www.youtube.com/watch?v=ZCfrNvu6nMc" target="_blank">click this link &raquo;</a> and follow the video on that page to get your server API key. Since Google updates their API Key generation directions frequently, follow the general steps shown in the video.
4104 + Then paste your API key in the "API Key" tab, and click the "Save Changes" button.
4105 + </p>
4106 +
4107 + <p>
4108 + Below are the global settings for galleries. If you want each of your galleries to have custom settings, <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx?ref=galleryglobal" target="_blank">go PRO</a> for more options:
4109 + </p>
4110 + <div class="ytindent chx">
4111 +
4112 + <p>
4113 + <label for="<?php echo self::$opt_gallery_pagesize; ?>"><b class="chktitle">Gallery Page Size:</b></label>
4114 + <select name="<?php echo self::$opt_gallery_pagesize; ?>" id="<?php echo self::$opt_gallery_pagesize; ?>" style="width: 60px;">
4115 + <?php
4116 + $gps_val = intval(trim($all[self::$opt_gallery_pagesize]));
4117 + $gps_val = min($gps_val, 50);
4118 + for ($gps = 1; $gps <= 50; $gps++)
4119 + {
4120 + ?><option <?php echo $gps_val == $gps ? 'selected' : '' ?> value="<?php echo $gps ?>"><?php echo $gps ?></option>
4121 + <?php
4122 + }
4123 + ?>
4124 + </select>
4125 + Enter how many thumbnails per page should be shown at once (YouTube allows a maximum of 50 per page).
4126 + </p>
4127 + <p>
4128 + <label for="<?php echo self::$opt_gallery_columns; ?>"><b class="chktitle">Number of Columns:</b></label>
4129 + <input name="<?php echo self::$opt_gallery_columns; ?>" min="1" id="<?php echo self::$opt_gallery_columns; ?>" type="number" class="textinput" style="width: 60px;" value="<?php echo esc_attr(trim($all[self::$opt_gallery_columns])); ?>">
4130 + Enter how many thumbnails can fit per row.
4131 + </p>
4132 + <p>
4133 + <input name="<?php echo self::$opt_gallery_collapse_grid; ?>" id="<?php echo self::$opt_gallery_collapse_grid; ?>" <?php checked($all[self::$opt_gallery_collapse_grid], 1); ?> type="checkbox" class="checkbox">
4134 + <label for="<?php echo self::$opt_gallery_collapse_grid; ?>">
4135 + <b class="chktitle">Stack Thumbnails for Mobile:</b> Check this option to responsively stack thumbnails on smaller screens, for the grid layout.
4136 + </label>
4137 + <span id="box_collapse_grid">
4138 + <?php
4139 + foreach ($all[self::$opt_gallery_collapse_grid_breaks] as $idx => $bpts)
4140 + {
4141 + ?>
4142 + On screens up to
4143 + <input type="number" name="<?php echo self::$opt_gallery_collapse_grid_breaks . '[' . $idx . '][bp][max]'; ?>"
4144 + id="<?php echo self::$opt_gallery_collapse_grid_breaks . '[' . $idx . '][bp][max]'; ?>"
4145 + value="<?php echo intval(trim($bpts['bp']['max'])); ?>" class="textinput" style="width: 70px;">px wide, stack thumbnails to 1 column.
4146 + <input type="hidden" name="<?php echo self::$opt_gallery_collapse_grid_breaks . '[' . $idx . '][cols]'; ?>"
4147 + id="<?php echo self::$opt_gallery_collapse_grid_breaks . '[' . $idx . '][cols]'; ?>"
4148 + value="<?php echo intval(trim($bpts['cols'])); ?>">
4149 + <input type="hidden" name="<?php echo self::$opt_gallery_collapse_grid_breaks . '[' . $idx . '][bp][min]'; ?>"
4150 + id="<?php echo self::$opt_gallery_collapse_grid_breaks . '[' . $idx . '][bp][min]'; ?>"
4151 + value="<?php echo intval(trim($bpts['bp']['min'])); ?>">
4152 + <?php
4153 + }
4154 + ?>
4155 + <span class="smallnote grey pad20"><br>Note: a common mobile screen width is 767 pixels.</span>
4156 + </span>
4157 + </p>
4158 + <p>
4159 + <input name="<?php echo self::$opt_gallery_showpaging; ?>" id="<?php echo self::$opt_gallery_showpaging; ?>" <?php checked($all[self::$opt_gallery_showpaging], 1); ?> type="checkbox" class="checkbox">
4160 + <label for="<?php echo self::$opt_gallery_showpaging; ?>"><b class="chktitle">Show Pagination:</b> Show the Next/Previous buttons and page numbering.
4161 + It might be useful to hide pagination if you want your gallery to display just a subset of videos from a playlist or channel. That is, only the first page of videos (defined by your page size) will be visible to your visitors if these buttons are hidden.
4162 + </label>
4163 + </p>
4164 + <p>
4165 + <input name="<?php echo self::$opt_gallery_customarrows; ?>" id="<?php echo self::$opt_gallery_customarrows; ?>" <?php checked($all[self::$opt_gallery_customarrows], 1); ?> type="checkbox" class="checkbox">
4166 + <label for="<?php echo self::$opt_gallery_customarrows; ?>">
4167 + <b class="chktitle">Custom Next/Previous Text:</b> If you want your gallery viewers to see something besides "Next" and "Prev" when browsing through thumbnails, enter your replacement text here. This feature can be quite useful for non-English sites. For example, a French site might replace Prev with Pr&eacute;c&eacute;dent and Next with Suivant.
4168 + </label>
4169 + <span id="boxcustomarrows">
4170 + Previous Page: <input type="text" name="<?php echo self::$opt_gallery_customprev; ?>" id="<?php echo self::$opt_gallery_customprev; ?>" value="<?php echo esc_attr(trim($all[self::$opt_gallery_customprev])); ?>" class="textinput" style="width: 100px;"> &nbsp;
4171 + Next Page: <input type="text" name="<?php echo self::$opt_gallery_customnext; ?>" id="<?php echo self::$opt_gallery_customnext; ?>" value="<?php echo esc_attr(trim($all[self::$opt_gallery_customnext])); ?>" class="textinput" style="width: 100px;">
4172 + </span>
4173 + </p>
4174 + <p>
4175 + <input name="<?php echo self::$opt_gallery_channelsub; ?>" id="<?php echo self::$opt_gallery_channelsub; ?>" <?php checked($all[self::$opt_gallery_channelsub], 1); ?> type="checkbox" class="checkbox">
4176 + <label for="<?php echo self::$opt_gallery_channelsub; ?>">
4177 + <b class="chktitle">Show Subscribe Button: </b> Are you the channel owner for all your galleries? Check this box to add a "Subscribe" button to all your galleries as shown below. This might help you convert your site's visitors to YouTube subscribers of your channel.
4178 + </label>
4179 + <span id="boxchannelsub">
4180 + Paste Channel URL: <input type="text" placeholder="Example: https://www.youtube.com/user/YourChannel" name="<?php echo self::$opt_gallery_channelsublink; ?>" id="<?php echo self::$opt_gallery_channelsublink; ?>" value="<?php echo esc_url(trim($all[self::$opt_gallery_channelsublink])); ?>" class="textinput regular-text"> &nbsp;
4181 + Button text: <input type="text" name="<?php echo self::$opt_gallery_channelsubtext; ?>" id="<?php echo self::$opt_gallery_channelsubtext; ?>" value="<?php echo esc_attr(trim($all[self::$opt_gallery_channelsubtext])); ?>" class="textinput" style="width: 200px;">
4182 + </span>
4183 + </p>
4184 + <p><img class="sssubscribe" src="<?php echo plugins_url('images/sssubscribe.png', __FILE__) ?>"></p>
4185 +
4186 + <p>
4187 + <label for="<?php echo self::$opt_gallery_scrolloffset; ?>"><b class="chktitle">Scroll Offset:</b></label>
4188 + <input name="<?php echo self::$opt_gallery_scrolloffset; ?>" id="<?php echo self::$opt_gallery_scrolloffset; ?>" type="number" class="textinput" style="width: 60px;" value="<?php echo esc_attr(trim($all[self::$opt_gallery_scrolloffset])); ?>">
4189 + After you click on a thumbnail, the gallery will automatically smooth scroll up to the actual player. If you need it to scroll a few pixels further, increase this number.
4190 + </p>
4191 + <p>
4192 + <input name="<?php echo self::$opt_gallery_showtitle; ?>" id="<?php echo self::$opt_gallery_showtitle; ?>" <?php checked($all[self::$opt_gallery_showtitle], 1); ?> type="checkbox" class="checkbox">
4193 + <label for="<?php echo self::$opt_gallery_showtitle; ?>"><b class="chktitle">Show Thumbnail Title:</b> Show titles with each thumbnail.</label>
4194 + </p>
4195 + <p>
4196 + <input name="<?php echo self::$opt_gallery_hideprivate; ?>" id="<?php echo self::$opt_gallery_hideprivate; ?>" <?php checked($all[self::$opt_gallery_hideprivate], 1); ?> type="checkbox" class="checkbox">
4197 + <label for="<?php echo self::$opt_gallery_hideprivate; ?>"><b class="chktitle">Hide Private Thumbnails:</b> Hide thumbnails for videos in a playlist that cannot be embedded yet. Note: This may make some page sizes look uneven.</label>
4198 + </p>
4199 + <p>
4200 + <input name="<?php echo self::$opt_gallery_autonext; ?>" id="<?php echo self::$opt_gallery_autonext; ?>" <?php checked($all[self::$opt_gallery_autonext], 1); ?> type="checkbox" class="checkbox">
4201 + <label for="<?php echo self::$opt_gallery_autonext; ?>"><b class="chktitle">Automatic Continuous Play:</b> Automatically play the next video in the gallery as soon as the current video finished.
4202 + <strong>Note:</strong> If you're embedding videos from your own monetized YouTube channel, we advise you to read YouTube's resource page on ads on embedded videos:
4203 + <a href="https://support.google.com/youtube/answer/132596?hl=en" target="_blank">https://support.google.com/youtube/answer/132596?hl=en</a>
4204 + You'll see that videos that you want to monetize "should be embedded using the standard click-to-play embed and NOT a scripted play."
4205 + Unchecking this option guarantees standard click-to-play gallery embedding.
4206 + </label>
4207 + </p>
4208 + <p>
4209 + <input name="<?php echo self::$opt_gallery_thumbplay; ?>" id="<?php echo self::$opt_gallery_thumbplay; ?>" <?php checked($all[self::$opt_gallery_thumbplay], 1); ?> type="checkbox" class="checkbox">
4210 + <label for="<?php echo self::$opt_gallery_thumbplay; ?>"><b class="chktitle">Thumbnail Click Plays Video:</b>
4211 + Clicking on a gallery thumbnail autoplays the video. Uncheck this and visitors must also click the video's play button after clicking the thumbnail
4212 + (uncheck this option for standard click-to-play gallery embedding).
4213 + </label>
4214 + </p>
4215 + <div class="pad20">
4216 + <p>
4217 + Ready to get started with an actual gallery? Just click the plugin wizard button and pick your desired gallery embedding choice.
4218 + </p>
4219 + <p><img class="sswizardbutton" src="<?php echo plugins_url('images/sswizardbutton.jpg', __FILE__) ?>"></p>
4220 + </div>
4221 + </div>
4222 + </section>
4223 +
4224 + <section class="pattern" id="jumpcompat">
4225 + <h2>Compatibility Settings</h2>
4226 + <p>
4227 + With tens of thousands of active users, our plugin may not work with every plugin out there. Below are some settings you may wish to try out.
4228 + </p>
4229 + <div class="ytindent chx">
4230 + <p>
4231 + <input name="<?php echo self::$opt_ajax_save; ?>" id="<?php echo self::$opt_ajax_save; ?>" <?php checked($all[self::$opt_ajax_save], 1); ?> type="checkbox" class="checkbox">
4232 + <label for="<?php echo self::$opt_ajax_save; ?>">
4233 + <b class="chktitle">Save Settings with AJAX: </b>
4234 + Turn this option off if you are having trouble saving your settings.
4235 + </label>
4236 + </p>
4237 + <p>
4238 + <input name="<?php echo self::$opt_gb_compat; ?>" id="<?php echo self::$opt_gb_compat; ?>" <?php checked($all[self::$opt_gb_compat], 1); ?> type="checkbox" class="checkbox">
4239 + <label for="<?php echo self::$opt_gb_compat; ?>">
4240 + <b class="chktitle">Gutenberg Block Editor Theme Spacing: </b>
4241 + Check this option to fix possible issues with spacing below your videos. You may also want to try combining this option with Responsive Sizing.
4242 + </label>
4243 + </p>
4244 + <p>
4245 + <input name="<?php echo self::$opt_old_script_method; ?>" id="<?php echo self::$opt_old_script_method; ?>" <?php checked($all[self::$opt_old_script_method], 1); ?> type="checkbox" class="checkbox">
4246 + <label for="<?php echo self::$opt_old_script_method; ?>">
4247 + <b class="chktitle">Use Legacy Scripts: </b>
4248 + This is a legacy option for users with theme issues that require backwards compatibility (v.10.5 or earlier). It may also help with caching plugin or CDN plugin issues.
4249 + </label>
4250 + </p>
4251 + <p>
4252 + <input name="<?php echo self::$opt_admin_off_scripts; ?>" id="<?php echo self::$opt_admin_off_scripts; ?>" <?php checked($all[self::$opt_admin_off_scripts], 1); ?> type="checkbox" class="checkbox">
4253 + <label for="<?php echo self::$opt_admin_off_scripts; ?>">
4254 + <b class="chktitle">Turn Off Scripts While Editing: </b>
4255 + Front-end editors and visual pagebuilders often run Javascript while you're in edit mode. Check this to turn off this plugin's Javascript during edit mode, if you see conflicts.
4256 + Don't worry, all other visitors to your site will still view your site normally.
4257 + </label>
4258 + </p>
4259 + <p>
4260 + <input name="<?php echo self::$opt_migrate; ?>" id="<?php echo self::$opt_migrate; ?>" <?php checked($all[self::$opt_migrate], 1); ?> type="checkbox" class="checkbox">
4261 + <label for="<?php echo self::$opt_migrate; ?>">
4262 + <b class="chktitle">Migrate Shortcodes: </b> Inherit shortcodes from other plugins. This is useful for when a plugin becomes deprecated, or you simply prefer this plugin's features.
4263 + </label>
4264 + <div id="boxmigratelist">
4265 + <ul>
4266 + <li><input name="<?php echo self::$opt_migrate_embedplusvideo; ?>" id="<?php echo self::$opt_migrate_embedplusvideo; ?>" <?php checked($all[self::$opt_migrate_embedplusvideo], 1); ?> type="checkbox" class="checkbox"><label for="<?php echo self::$opt_migrate_embedplusvideo; ?>"><b>"YouTube Advanced Embed":</b> <code>[embedplusvideo]</code> shortcode</label></li>
4267 + <li><input name="<?php echo self::$opt_migrate_youtube; ?>" id="<?php echo self::$opt_migrate_youtube; ?>" <?php checked($all[self::$opt_migrate_youtube], 1); ?> type="checkbox" class="checkbox"><label for="<?php echo self::$opt_migrate_youtube; ?>"><b>"YouTube Embed":</b> <code>[youtube]</code> and <code>[youtube_video]</code> shortcodes</label></li>
4268 + <li class="smallnote orange" style="list-style: none;">This feature is beta. More shortcodes coming.</li>
4269 + </ul>
4270 +
4271 + </div>
4272 + </p>
4273 + <p>
4274 + <input name="<?php echo self::$opt_oldspacing; ?>" id="<?php echo self::$opt_oldspacing; ?>" <?php checked($all[self::$opt_oldspacing], 1); ?> type="checkbox" class="checkbox">
4275 + <label for="<?php echo self::$opt_oldspacing; ?>">
4276 + <b class="chktitle">Legacy Spacing:</b> Continue the spacing style from version 4.0 and older. Those versions required you to manually add spacing above and below your video. Unchecking this will automatically add the spacing.
4277 + </label>
4278 + </p>
4279 + <p>
4280 + <input name="<?php echo self::$opt_frontend_only; ?>" id="<?php echo self::$opt_frontend_only; ?>" <?php checked($all[self::$opt_frontend_only], 1); ?> type="checkbox" class="checkbox">
4281 + <label for="<?php echo self::$opt_frontend_only; ?>">
4282 + <b class="chktitle">Don't Run Shortcode In Admin:</b>
4283 + Checking this will only allow the shortcode to run on the front-end of your website, and not in the admin area.
4284 + </label>
4285 + </p>
4286 + <p>
4287 + <input name="<?php echo self::$opt_evselector_light; ?>" id="<?php echo self::$opt_evselector_light; ?>" <?php checked($all[self::$opt_evselector_light], 1); ?> type="checkbox" class="checkbox">
4288 + <label for="<?php echo self::$opt_evselector_light; ?>">
4289 + <b class="chktitle">Theme Video Problems: </b>
4290 + Check this option if you're having issues with autoplayed videos or background videos etc. that have been generated by your theme.
4291 + </label>
4292 + </p>
4293 + <p>
4294 + <input name="<?php echo self::$opt_stop_mobile_buffer; ?>" id="<?php echo self::$opt_stop_mobile_buffer; ?>" <?php checked($all[self::$opt_stop_mobile_buffer], 1); ?> type="checkbox" class="checkbox">
4295 + <label for="<?php echo self::$opt_stop_mobile_buffer; ?>">
4296 + <b class="chktitle">Mobile Autoplay Problems: </b>
4297 + Autoplay works for desktop, but mobile devices don't allow autoplay due to network carrier data charges. For mobile devices, this option may help the player to properly display the video for the visitor to click on.
4298 + (<strong>Note:</strong> Desktop browsers like <a href="https://developers.google.com/youtube/iframe_api_reference#Mobile_considerations" target="_blank">Chrome and Safari are moving towards preventing autoplay for any video</a>. But, your chances are improved if you set your videos to initially start muted.)
4299 + </label>
4300 + </p>
4301 + <p>
4302 + <input name="<?php echo self::$opt_ajax_compat; ?>" id="<?php echo self::$opt_ajax_compat; ?>" <?php checked($all[self::$opt_ajax_compat], 1); ?> type="checkbox" class="checkbox">
4303 + <label for="<?php echo self::$opt_ajax_compat; ?>">
4304 + <b class="chktitle">Ajax Theme:</b>
4305 + If you have a theme that loads pages with AJAX transitions, try checking this option.
4306 + </label>
4307 + </p>
4308 + <p>
4309 + <input name="<?php echo self::$opt_debugmode; ?>" id="<?php echo self::$opt_debugmode; ?>" <?php checked($all[self::$opt_debugmode], 1); ?> type="checkbox" class="checkbox">
4310 + <label for="<?php echo self::$opt_debugmode; ?>">
4311 + <b class="chktitle">Debug Mode: </b> If you ask for support, we may ask you to turn on debug mode here.
4312 + It may print out some diagnostic info so that we can help you solve your issue.
4313 + </label>
4314 + </p>
4315 + <p>
4316 + <input name="<?php echo self::$opt_uninstall_data; ?>" id="<?php echo self::$opt_uninstall_data; ?>" <?php checked($all[self::$opt_uninstall_data], 1); ?> type="checkbox" class="checkbox">
4317 + <label for="<?php echo self::$opt_uninstall_data; ?>">
4318 + <b class="chktitle">Delete Options When Uninstalling:</b> Checking this box will permanently delete your options the next time you uninstall the plugin. Leave it unchecked
4319 + to preserve your options between installations.
4320 + </label>
4321 + </p>
4322 + </div>
4323 +
4324 +
4325 + </section>
4326 + <section class="pattern" id="jumphowto">
4327 + <h2>Manual Embedding</h2>
4328 + <p>
4329 + <strong>We strongly recommend using the wizard in your editor to embed.</strong> However, if you choose to manually embed code, follow some legacy instructions below.
4330 + </p>
4331 + <h3>
4332 + Manually Embed a YouTube Video or Playlist &nbsp; <a class="smallnote" href="#jumpgallery">(For gallery directions, go here &raquo;)</a>
4333 + </h3>
4334 + <p>
4335 + <b>For videos:</b> <i>Method 1 - </i> Do you already have a URL to the video you want to embed in a post, page, or even a widget? All you have to do is paste it on its own line, as shown below (including the https:// part). Easy, eh?<br>
4336 + <i>Method 2 - </i> If you want to do some formatting (e.g. add HTML to center a video) or have two or more videos next to each other on the same line, wrap each link with the <code>[embedyt]...[/embedyt]</code> shortcode. <b>Tip for embedding videos on the same line:</b> As shown in the example image below, decrease the size of each video so that they fit together on the same line (See the "How To Override Defaults" section for height and width instructions).
4337 + </p>
4338 + <p>
4339 + <b>For galleries:</b> <a href="#jumpgallery">Click here</a> to scroll down to gallery settings and directions.
4340 + </p>
4341 + <p>
4342 + <b>For self-contained playlists:</b> Go to the page for the playlist that lists all of its videos (<a target="_blank" href="https://www.youtube.com/playlist?list=PLsRNoUx8w3rPxNGCQYBPobGxNj1BfDT7P">Example &raquo;</a>). Click on the video that you want the playlist to start with. Copy and paste that browser URL into your blog on its own line. If you want the first video to always be the latest video in your playlist, check the option "Playlist Ordering" in the settings down below (you will also see this option available if you use the Pro Wizard). If you want to have two or more playlists next to each other on the same line, wrap each link with the <code>[embedyt]...[/embedyt]</code> shortcode.
4343 + </p>
4344 + <p>
4345 + <b>For self-contained channel playlists:</b> At your editor, click on the <img style="vertical-align: text-bottom;" src="<?php echo plugins_url('images/wizbuttonbig.png', __FILE__) ?>"> wizard button and choose the option <i>Search for a video or channel to insert in my editor.</i> Then, click on the <i>channel playlist</i> option there (instead of <i>single video</i>). Search for the channel username and follow the rest of the directions there.
4346 + </p>
4347 + <p>
4348 + <strong>For directly embedding in your theme with PHP:</strong>
4349 + If you need to use PHP directly, we still recommend using the wizard to create the shortcode--but instead of pressing the "Insert" button, just copy the shortcode the wizard gives you. Then use the <code>do_shortcode()</code> function in your theme, like this:
4350 + <br>
4351 + <code>&lt;?php echo do_shortcode('[embedyt]....[/embedyt]'); ?&gt;</code>
4352 + </p>
4353 + <p>
4354 + <b>Examples:</b><br><br>
4355 + <img style="width: 900px; height: auto;" class="shadow" src="<?php echo plugins_url('images/sshowto.png', __FILE__) ?>" />
4356 + </p>
4357 + <p>
4358 + Always follow these rules for any URL:
4359 + </p>
4360 + <ul class="reglist">
4361 + <li>Make sure the URL is really on its own line by itself. Or, if you need multiple videos on the same line, make sure each URL is wrapped properly with the shortcode (Example: <code>[embedyt]http://www.youtube.com/watch?v=ABCDEFGHIJK&width=400&height=250[/embedyt]</code>)</li>
4362 + <li>Make sure the URL is <strong>not</strong> an active hyperlink (i.e., it should just be plain text). Otherwise, highlight the URL and click the "unlink" button in your editor: <img src="<?php echo plugins_url('images/unlink.png', __FILE__) ?>"/></li>
4363 + <li>Make sure you did <strong>not</strong> format or align the URL in any way. If your URL still appears in your actual post instead of a video, highlight it and click the "remove formatting" button (formatting can be invisible sometimes): <img src="<?php echo plugins_url('images/erase.png', __FILE__) ?>"/></li>
4364 + <li>If you really want to align the video, try wrapping the link with the shortcode first. For example: <code>[embedyt]http://www.youtube.com/watch?v=ABCDEFGHIJK[/embedyt]</code> Using the shortcode also allows you to have two or more videos next to each other on the same line. Just put the shortcoded links together on the same line. For example:<br>
4365 + <code>[embedyt]http://www.youtube.com/watch?v=ABCDEF[/embedyt] [embedyt]http://www.youtube.com/watch?v=GHIJK[/embedyt]</code>
4366 + </li>
4367 + </ul>
4368 +
4369 +
4370 + <h3>
4371 + <?php _e("How To Manually Override Defaults / Other Options") ?>
4372 + </h3>
4373 + <p>
4374 + Suppose you have a few videos that need to be different from the above defaults. You can add options to the end of a link as displayed below to override the above defaults. Each option should begin with '&'.
4375 + <br><span class="orange">PRO users: You can use the <a href="<?php echo self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=manual' ?>" target="_blank">customize</a> buttons that you will see inside the wizard, instead of memorizing the following codes.</span>
4376 + </p>
4377 + <?php
4378 + _e('<ul class="reglist">');
4379 + _e("<li><strong>width</strong> - Sets the width of your player. If omitted, the default width will be the width of your theme's content.<em> Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&width=500</strong>&height=350</em></li>");
4380 + _e("<li><strong>height</strong> - Sets the height of your player. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA&width=500<strong>&height=350</strong></em> </li>");
4381 + _e("<li><strong>autoplay</strong> - Set this to 1 to autoplay the video (or 0 to play the video once). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&autoplay=1</strong></em> (Note: Desktop browsers like Chrome and Safari are moving towards preventing autoplay for any video. But, your chances are improved if you set your videos to initially start muted.) </li>");
4382 + _e("<li><strong>cc_load_policy</strong> - Set this to 1 to turn on closed captioning (or 0 to leave them off). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&cc_load_policy=1</strong></em> </li>");
4383 + _e("<li><strong>iv_load_policy</strong> - Set this to 3 to turn off annotations (or 1 to show them). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&iv_load_policy=3</strong></em> </li>");
4384 + _e("<li><strong>loop</strong> - Set this to 1 to loop the video (or 0 to not loop). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&loop=1</strong></em> </li>");
4385 + _e("<li><strong>rel</strong> - Set this to 0 to not show related videos at the end of playing (or 1 to show them). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&rel=0</strong></em> </li>");
4386 + _e("<li><strong>fs</strong> - Set this to 0 to hide the fullscreen button (or 1 to show it). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&fs=0</strong></em> </li>");
4387 + _e("<li><strong>color</strong> - Set this to 'white' to make the player have a white progress bar (or 'red' for a red progress bar). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&color=white</strong></em> </li>");
4388 + _e("<li><strong>controls</strong> - Set this to 0 to completely hide the video controls (or 1 to show it). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&controls=0</strong></em> </li>");
4389 + _e("<li><strong>disablekb</strong> - Set this to 1 to disable keyboard controls (or 0 to enable them). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&disablekb=1</strong></em> </li>");
4390 + _e("<li><strong>playsinline</strong> - Set this to 1 to allow videos play inline with the page on iOS browsers. (Set to 0 to have iOS launch videos in fullscreen instead). <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&playsinline=1</strong></em> </li>");
4391 + _e("<li><strong>origin</strong> - Set this to 1 to add the 'origin' parameter for extra JavaScript security. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA<strong>&origin=1</strong></em> </li>");
4392 + _e('</ul>');
4393 +
4394 + _e("<p>You can also start and end each individual video at particular times. Like the above, each option should begin with '&'</p>");
4395 + _e('<ul class="reglist">');
4396 + _e("<li><strong>start</strong> - Sets the time (in seconds) to start the video. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350<strong>&start=20</strong></em> </li>");
4397 + _e("<li><strong>end</strong> - Sets the time (in seconds) to stop the video. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350<strong>&end=100</strong></em> </li>");
4398 + _e('</ul>');
4399 + ?>
4400 + </section>
4401 +
4402 + <section class="pattern" id="jumpperformance">
4403 + <h2><?php _e('Performance Settings & Tips', 'youtube-embed-plus'); ?></h2>
4404 + <p>
4405 + <?php _e('On this page, we describe performance options to help optimize page speed times of your pages containing YouTube embeds.', 'youtube-embed-plus'); ?>
4406 + </p>
4407 + <div class="p">
4408 + <input name="<?php echo self::$opt_facade_mode; ?>" id="<?php echo self::$opt_facade_mode; ?>" <?php checked($all[self::$opt_facade_mode], 1); ?> type="checkbox" class="checkbox">
4409 + <label for="<?php echo self::$opt_facade_mode ?>">
4410 + <b class="chktitle"><?php _e('Facade Mode:', 'youtube-embed-plus'); ?> <sup class="orange">new</sup></b>
4411 + <?php _e('This improves performance by loading a lighter version of the player, until it is clicked. Then the real player loads (note: for live streams, the real player is always loaded). We have tested this feature in multiple cases and found it to successfully improve your Lighthouse performance score by addressing the following recommendation: "Some third-party resources can be lazy loaded with a facade."', 'youtube-embed-plus'); ?>
4412 + <a href="https://www.youtube.com/watch?v=W7PKUjVBDNE" target="_blank"><?php _e('See an example of this feature at work.', 'youtube-embed-plus'); ?></a>
4413 + </label>
4414 + <div class="p box_facade_mode">
4415 + <input name="<?php echo self::$opt_facade_autoplay; ?>" id="<?php echo self::$opt_facade_autoplay; ?>" type="checkbox" class="checkbox" <?php checked($all[self::$opt_facade_autoplay], 1); ?>>
4416 + <label for="<?php echo self::$opt_facade_autoplay ?>">
4417 + <b class="chktitle"><?php _e('Autoplay On Facade Click:', 'youtube-embed-plus'); ?></b>
4418 + <span>
4419 + <?php _e('After clicking once on the facade (aka light thumbnail), it is replaced with the real player. Check this option to have the real player play immediately, otherwise it will require an additional click. Note that checking this option will use YouTube\'s autoplay feature, which will not contribute toward play counts. If you\'re embedding videos from someone else\'s channel, we recommend checking this. If you\'re embedding videos that are from your channel, then you should self-evaluate the tradeoff involving play counts and additional clicking.', 'youtube-embed-plus'); ?>
4420 + </span>
4421 + </label>
4422 + <br>
4423 + <br>
4424 + <label>
4425 + <b class="chktitle"><?php _e('Force Maximum Quality for Facade Images: <sup class="orange">new</sup>', 'text_domain') ?></b>
4426 + <?php _e('Attempt to load the maximum resolution image for the facade image. This max quality image does not exist for all videos, so you have a few choices below.', 'text_domain'); ?>
4427 + </label>
4428 + <ul class="indent-option">
4429 + <li>
4430 + <input type="radio" name="<?php echo self::$opt_maxres_facade; ?>" id="<?php echo self::$opt_maxres_facade; ?>_eager" value="eager" <?php checked($all[self::$opt_maxres_facade], 'eager'); ?>>
4431 + <label for="<?php echo self::$opt_maxres_facade; ?>_eager"> <?php _e("<em>Eager:</em> Try loading the max resolution image by default. If the max-res image does not exist for the video, the next highest available resolution will immediately load instead. This option is best for websites that embed videos having very high resolutions (i.e. the max-res images will likely exist).", 'text_domain') ?> </label> <br>
4432 + </li>
4433 + <li>
4434 + <input type="radio" name="<?php echo self::$opt_maxres_facade; ?>" id="<?php echo self::$opt_maxres_facade; ?>_soft" value="soft" <?php checked($all[self::$opt_maxres_facade], 'soft'); ?>>
4435 + <label for="<?php echo self::$opt_maxres_facade; ?>_soft"> <?php _e("<em>Soft:</em> Load a relatively high resolution image that is guaranteed to exist, but immediately try updating the image to maximum resolution if it exists. This option is best for sites with some videos that may have a missing max resolution image.", 'text_domain') ?> </label> <br>
4436 + </li>
4437 + <li>
4438 + <input type="radio" name="<?php echo self::$opt_maxres_facade; ?>" id="<?php echo self::$opt_maxres_facade; ?>_off" value="off" <?php checked($all[self::$opt_maxres_facade], 'off'); ?>>
4439 + <label for="<?php echo self::$opt_maxres_facade; ?>_off"><?php _e("<em>Off:</em> Don't try to maximize facade image quality. Just load the relatively high resolution image that all videos have.", 'text_domain') ?></label> <br>
4440 + </li>
4441 + </ul>
4442 + </div>
4443 + </div>
4444 + <div class="p">
4445 + <input name="<?php echo self::$opt_defer_js; ?>" id="<?php echo self::$opt_defer_js; ?>" <?php checked($all[self::$opt_defer_js], 1); ?> type="checkbox" class="checkbox">
4446 + <label for="<?php echo self::$opt_defer_js ?>">
4447 + <b class="chktitle"><?php _e('Defer Javascript:', 'youtube-embed-plus'); ?></b>
4448 + <?php _e('JavaScript (JS) deferral is a common website performance option that can offer significant improvements of page speed. You can reduce the initial load time of your page by allowing this plugin\'s scripts to begin execution only after a page is loaded. You may receive a better GTMetrix score with this option turned on. Note: This feature is compatible with most sites, but turn it off if you are having issues.', 'youtube-embed-plus'); ?>
4449 + </label>
4450 + <div class="p box_defer_jquery">
4451 + <input name="<?php echo self::$opt_defer_jquery; ?>" id="<?php echo self::$opt_defer_jquery; ?>" type="checkbox" class="checkbox" <?php checked($all[self::$opt_defer_jquery], 1); ?>>
4452 + <label for="<?php echo self::$opt_defer_jquery ?>">
4453 + <b class="chktitle"><?php _e('Also Defer jQuery:', 'youtube-embed-plus'); ?></b>
4454 + <span style="color: red;">
4455 + <?php _e('Note: Do NOT check this option if you are using a pagebuilder. Furthermore, defering jQuery may improve your GTMetrix score even more, but might not be compatible with your theme or other plugins (especially if they are not defering their own scripts). Use this option with caution.', 'youtube-embed-plus'); ?>
4456 + </span>
4457 + </label>
4458 + </div>
4459 + </div>
4460 + <p><?php _e('Note: Since the YouTube player is loaded in its own iframe from YouTube\'s servers, browser restrictions prevent this plugin from directly deferring the JS inside the iframe. However, if you upgrade to Pro, you can use the lazy loading feature <a href="#jumpupgrade">described here &raquo;</a> to further improve your page speeds or try out facade mode.', 'youtube-embed-plus'); ?></p>
4461 + </section>
4462 +
4463 + <div class="save-changes-follow"> <?php self::save_changes_button(isset($_POST[$ytprefs_submitted]) && $_POST[$ytprefs_submitted] == 'Y'); ?> </div>
4464 + </form>
4465 +
4466 + <section class="pattern" id="jumpupgrade">
4467 + <div class="upgchecks">
4468 + <h3 class="sect">Want the PRO Features?</h3>
4469 + <p>
4470 + Below are descriptions for some of our PRO features for more gallery customization options, faster page loading, enhanced SEO, and more. Simply purchase and install our separate PRO plugin (the PRO plugin automatically works for all your past embed links).
4471 + </p>
4472 + <p>
4473 + <input disabled type="checkbox" class="checkbox">
4474 + <label>
4475 + <b class="chktitle">Lazy-Loading for Performance:</b> <span class="pronon">(PRO Users)</span>
4476 + Lazy-loading can speed up your page loads by loading the player only until it is visible on the screen.
4477 + <a href="https://www.youtube.com/watch?v=omNdJvXDCLo" target="_blank">See an example here</a>.
4478 + An added bonus to this option is that you have the choice of several types of eye-catching lazy-loading effects that will make your YouTube embeds bounce, flip, pulse, or slide as they lazy load on the screen. Check this box to select your desired effect. <a target="_blank" href="<?php echo self::$epbase ?>/add-special-effects-to-youtube-embeds-in-wordpress.aspx">Read more here &raquo;</a>
4479 + </label>
4480 + </p>
4481 + <div class="hr"></div>
4482 + <p>
4483 + <img class="ssaltgallery" src="<?php echo plugins_url('images/ss-live-chat.jpg', __FILE__) ?>" />
4484 + <input disabled type="checkbox" class="checkbox">
4485 + <label>
4486 + <b class="chktitle"><?php _e('Enable Live Chat:', 'youtube-embed-plus') ?></b> <span class="pronon"><?php _e('(PRO Users)', 'youtube-embed-plus') ?></span> <?php _e('<sup class="orange">new</sup>') ?> <?php _e('Add more interaction to your site by including the YouTube live chat box as part of each live stream embed. Note that live chat can also be an option for earning money from your audience by using the Super Chat feature. <a href="https://creatoracademy.youtube.com/page/lesson/superchat" target="_blank">Learn more here</a>.') ?>
4487 + <strong class="check-note"><?php _e('<span class="orange">NOTE:</span> In wide containers, the chat box will appear to the right of the player. It will appear below the player when the container is less than 964px. Also, Google/YouTube disables live chat on mobile devices. So for mobile phones and tablets, the chat box will be hidden.') ?></strong>
4488 + </label>
4489 + <br>
4490 + <br>
4491 + </p>
4492 + <div class="hr"></div>
4493 + <p>
4494 + <img class="ssaltgallery" src="<?php echo plugins_url('images/ssaltgalleryall.jpg', __FILE__) ?>" />
4495 + <select disabled>
4496 + <option value="">Gallery Style</option>
4497 + </select>
4498 + <label>
4499 + <b class="chktitle">Advanced Gallery Customization Options: </b> <span class="pronon">(PRO Users)</span>
4500 + Switch from the grid style of the free version to another gallery style. Right now, we provide a vertical (single column) and horizontal (single row) list style as alternatives to the grid, with more designs coming. These current alternatives were inspired by the standard YouTube playlist player's "table of contents," except our gallery's video lists are always visible and shown under the playing video.
4501 + <a target="_blank" href="<?php echo self::$epbase ?>/responsive-youtube-playlist-channel-gallery-for-wordpress.aspx">Read more here &raquo;</a>
4502 + </label>
4503 + </p>
4504 +
4505 + <div class="hr"></div>
4506 + <p>
4507 + <img class="ssaltgallery" src="<?php echo plugins_url('images/ssverticallayout.png', __FILE__) ?>" />
4508 + <input disabled type="checkbox" class="checkbox">
4509 + <label>
4510 + <b class="chktitle">Show Gallery Descriptions (for vertical list styling): </b> <span class="pronon">(PRO Users)</span>
4511 + For the vertical list layout, this option will show full video descriptions (taken directly from YouTube.com) with each thumbnail. Note: these descriptions only apply the vertical list layout; other layouts don't have enough room.
4512 + </label>
4513 + </p>
4514 + <div class="hr"></div>
4515 + <p>
4516 + <img class="ssaltgallery" src="<?php echo plugins_url('images/ssaltgallerycircles.jpg', __FILE__) ?>" />
4517 + <select disabled>
4518 + <option value="">Select Thumbnail Shape</option>
4519 + </select>
4520 + <label>
4521 + <b class="chktitle">Gallery Thumbnail Shape: </b> <span class="pronon">(PRO Users)</span>
4522 + Differentiate your gallery by showing different thumbnail shapes. We currently offer rectangle and circle shapes.
4523 + <a target="_blank" href="<?php echo self::$epbase ?>/responsive-youtube-playlist-channel-gallery-for-wordpress.aspx">Read more here &raquo;</a>
4524 + </label>
4525 + </p>
4526 +
4527 + <div class="hr"></div>
4528 + <p>
4529 + <img class="sspopupplayer" src="<?php echo plugins_url('images/sspopupplayer.jpg', __FILE__) ?>" />
4530 + <label>
4531 + <b class="chktitle">Gallery Video Display Mode: </b> <span class="pronon">(PRO Users)</span>
4532 + Display your gallery videos simply above the thumbnails (default), or as a popup lightbox. Choosing "popup lightbox" will make your videos lazy-loaded, which will provide some performance benefits since the YouTube player is not initially loaded with your page. It's loaded with a popup only when a user clicks a thumbnail.
4533 + </label>
4534 + <br>
4535 + <input type="radio" disabled> Default &nbsp; <input type="radio" disabled> Popup lightbox
4536 + </p>
4537 +
4538 + <div class="hr"></div>
4539 +
4540 + <p>
4541 + <img class="sshidethumbimg" src="<?php echo plugins_url('images/sshidethumbimg.jpg', __FILE__) ?>" />
4542 + <input disabled type="checkbox" class="checkbox">
4543 + <label>
4544 + <b class="chktitle">Hide Thumbnail Images:</b> <span class="pronon">(PRO Users)</span>
4545 + (For "Grid" and "Vertical List" gallery layouts only) Hide the image for each thumbnail, leaving just the text. This can improve performance when imagery is not important.
4546 + <a href="<?php echo self::$epbase ?>/responsive-youtube-playlist-channel-gallery-for-wordpress.aspx" target="_blank">See an example here &raquo;</a>
4547 + </label>
4548 + </p>
4549 +
4550 + <div class="hr"></div>
4551 + <p>
4552 + <input disabled type="checkbox" class="checkbox">
4553 + <label>
4554 + <b class="chktitle">Faster Page Loads (Caching): </b> <span class="pronon">(PRO Users)</span>
4555 + Use embed caching to speed up your page loads. By default, WordPress needs to request information from YouTube.com's servers for every video you embed, every time a page is loaded. These data requests can add time to your total page load time. Turn on this feature to cache that data (instead of having to request for the same information every time you load a page). This should then make your pages that have videos load faster. It's been noted that even small speed ups in page load can help increase visitor engagement, retention, and conversions. Caching also makes galleries run faster.
4556 + </label>
4557 + <div class="indent-option">
4558 + <label>
4559 + <b class="chktitle">Cache Lifetime (hours): </b>
4560 + <input disabled value="24" type="number">
4561 + Tip: If your pages rarely change, you may wish to set this to a much higher value than 24 hours.
4562 + </label>
4563 + </div>
4564 + </p>
4565 + <div class="hr"></div>
4566 +
4567 + <p>
4568 + <input disabled type="checkbox" class="checkbox">
4569 + <label>
4570 + <b class="chktitle">Video SEO Tags:</b> <span class="pronon">(PRO Users)</span> Update your YouTube embeds with Google, Bing, and Yahoo friendly schema markup for videos.
4571 + </label>
4572 + </p>
4573 + <div class="hr"></div>
4574 + <p>
4575 + <input disabled type="checkbox" class="checkbox">
4576 + <label>
4577 + <b class="chktitle">Facebook Open Graph Markup:</b> <span class="pronon">(PRO Users)</span> Include Facebook Open Graph markup with the videos you embed with this plugin. We follow the guidelines for videos as described here: <a href="https://developers.facebook.com/docs/sharing/webmasters#media" target="_blank">https://developers.facebook.com/docs/sharing/webmasters#media</a>
4578 + </label>
4579 + </p>
4580 + <div class="hr"></div>
4581 + <p>
4582 + <img class="ssfb" src="<?php echo plugins_url('images/youtube_thumbnail_sample.jpg', __FILE__) ?>" />
4583 + <input disabled type="checkbox" class="checkbox">
4584 + <label>
4585 + <b class="chktitle">Featured Thumbnail Images:</b> <span class="pronon">(PRO Users)</span>
4586 + Automatically grab the thumbnail image of the first video embedded in each post or page, and use it as the featured image.
4587 + All you have to do is click Update on a post or page and the plugin does the rest!
4588 + (Example shown on the right) <a target="_blank" href="<?php echo self::$epbase ?>/add-youtube-video-thumbnails-featured-image-wordpress.aspx">Read more here &raquo;</a>
4589 + </label>
4590 + </p>
4591 + <div class="hr"></div>
4592 + <p>
4593 + <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx?ref=protabfooter" target="_blank">Purchase and download the PRO plugin to get the above and several other features &raquo;</a>
4594 + </p>
4595 + <div class="clearboth"></div>
4596 + </div>
4597 +
4598 + </section>
4599 +
4600 + <section class="pattern" id="jumpsupport">
4601 + <h2>Plugin Support</h2>
4602 +
4603 + <div id="nonprosupport">
4604 + <p>
4605 + Here is a short video explaining a few of the plugin's features:
4606 + </p>
4607 + <div class="epyt-fitvid">
4608 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/QDdvXBqfrzM?rel=0" allowfullscreen="" frameborder="0"></iframe>
4609 + </div>
4610 + <p>
4611 + We've also found that a common support request has been from users that are pasting video links on single lines, as required, but are not seeing the video embed show up. One of these suggestions is usually the fix:
4612 + </p>
4613 + <ul class="reglist">
4614 + <li>Make sure the URL is really on its own line by itself. Or, if you need multiple videos on the same line, make sure each URL is wrapped properly with the shortcode (Example: <code>[embedyt]http://www.youtube.com/watch?v=ABCDEFGHIJK&width=400&height=250[/embedyt]</code>)</li>
4615 + <li>Make sure the URL is not an active hyperlink (i.e., it should just be plain text). Otherwise, highlight the URL and click the "unlink" button in your editor: <img src="<?php echo plugins_url('images/unlink.png', __FILE__) ?>"/>.</li>
4616 + <li>Make sure you did <strong>not</strong> format or align the URL in any way. If your URL still appears in your actual post instead of a video, highlight it and click the "remove formatting" button (formatting can be invisible sometimes): <img src="<?php echo plugins_url('images/erase.png', __FILE__) ?>"/></li>
4617 + <li>Try wrapping the URL with the <code>[embedyt]...[/embedyt]</code> shortcode. For example: <code>[embedyt]http://www.youtube.com/watch?v=ABCDEFGHIJK[/embedyt]</code> Using the shortcode also allows you to have two or more videos next to each other on the same line. Just put the shortcoded links together on the same line. For example:<br>
4618 + <code>[embedyt]http://www.youtube.com/watch?v=ABCDEF&width=400&height=250[/embedyt] [embedyt]http://www.youtube.com/watch?v=GHIJK&width=400&height=250[/embedyt]</code>
4619 + <br> TIP: As shown above, decrease the size of each video so that they fit together on the same line (See the "How To Override Defaults" section for height and width instructions)
4620 + </li>
4621 + <li>If you upload a new video to a playlist or channel and that video is not yet showing up on a gallery you embedded, you should clear/reset any caching plugins you have. This will force your site to retrieve the freshest version of your playlist and/or channel video listing. If you don't reset you cache, then you'll have to wait until cache lifetime expires.</li>
4622 + <li>Finally, there's a slight chance your custom theme is the issue, if you have one. To know for sure, we suggest temporarily switching to one of the default WordPress themes (e.g., "Twenty Fourteen") just to see if your video does appear. If it suddenly works, then your custom theme is the issue. You can switch back when done testing.</li>
4623 + <li>If your videos always appear full size, try turning off "Responsive video sizing."</li>
4624 + <li>If none of the above work, you can contact us here if you still have issues: ext@embedplus.com. We'll try to respond within a week.</li>
4625 + </ul>
4626 + <p>
4627 + Deactivating the No Cookies option has also been proven to solve player errors.
4628 + </p>
4629 + <p>
4630 + We also have a YouTube channel. We use it to provide users with some helper videos and a way to keep updated on new features as they are introduced. <a href="https://www.youtube.com/subscription_center?add_user=EmbedPlus" target="_blank">Subscribe for tips and updates here &raquo;</a>
4631 + </p>
4632 + </div>
4633 + <br>
4634 + </section>
4635 + </div>
4636 + </div>
4637 + <script type="text/javascript">
4638 + (function ($)
4639 + {
4640 + window.savevalidate = function (e)
4641 + {
4642 + var $formDefaults = $(e.target);
4643 + var valid = true;
4644 + var $tabFocus = '';
4645 + var alertmessage = '';
4646 + if (jQuery("#<?php echo self::$opt_defaultdims; ?>").is(":checked"))
4647 + {
4648 + if (!(jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_defaultwidth; ?>").val())) &&
4649 + jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_defaultheight; ?>").val()))))
4650 + {
4651 + alertmessage += "Please enter valid numbers for default height and width, or uncheck the option.";
4652 + jQuery("#boxdefaultdims input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
4653 + valid = false;
4654 + $tabFocus = $("#<?php echo self::$opt_defaultdims; ?>").closest('section');
4655 + }
4656 + }
4657 +
4658 + if (jQuery("#<?php echo self::$opt_gallery_customarrows; ?>").is(":checked"))
4659 + {
4660 + if (!jQuery.trim(jQuery("#<?php echo self::$opt_gallery_customprev; ?>").val()) ||
4661 + !jQuery.trim(jQuery("#<?php echo self::$opt_gallery_customnext; ?>").val()))
4662 + {
4663 + alertmessage += "Please enter valid text for both the custom gallery Prev and Next buttons, or uncheck the option.";
4664 + jQuery("#boxcustomarrows input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
4665 + valid = false;
4666 + $tabFocus = $("#<?php echo self::$opt_gallery_customarrows; ?>").closest('section');
4667 + }
4668 + }
4669 +
4670 +
4671 + if (jQuery("#<?php echo self::$opt_gallery_channelsub; ?>").is(":checked"))
4672 + {
4673 + if (!jQuery.trim(jQuery("#<?php echo self::$opt_gallery_channelsublink; ?>").val()) ||
4674 + !jQuery.trim(jQuery("#<?php echo self::$opt_gallery_channelsubtext; ?>").val()))
4675 + {
4676 + alertmessage += "Please enter valid text for both the subscribe text and subscribe URL, or uncheck the option.";
4677 + jQuery("#boxchannelsub input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
4678 + valid = false;
4679 + $tabFocus = $("#<?php echo self::$opt_gallery_channelsub; ?>").closest('section');
4680 + }
4681 + }
4682 +
4683 +
4684 + if (jQuery("#<?php echo self::$opt_gallery_collapse_grid; ?>").is(":checked"))
4685 + {
4686 + var emptyStacks = [];
4687 + jQuery("#box_collapse_grid input").each(function ()
4688 + {
4689 + var val = jQuery(this).val();
4690 + if (jQuery.trim(val) === '' || !jQuery.isNumeric(val))
4691 + {
4692 + emptyStacks.push(this);
4693 + jQuery(this).css("background-color", "#ffcccc").css("outline", "2px solid #000000");
4694 + }
4695 + });
4696 + if (emptyStacks.length)
4697 + {
4698 + alertmessage += "Please enter a valid number for the gallery stacking screen width.";
4699 + valid = false;
4700 + $tabFocus = $("#<?php echo self::$opt_gallery_collapse_grid; ?>").closest('section');
4701 + }
4702 + }
4703 +
4704 +
4705 +
4706 + if (jQuery("#<?php echo self::$opt_defaultvol; ?>").is(":checked"))
4707 + {
4708 + if (!(jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_vol; ?>").val()))))
4709 + {
4710 + alertmessage += "Please enter a number between 0 and 100 for the default volume, or uncheck the option.";
4711 + jQuery("#boxdefaultvol input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
4712 + valid = false;
4713 + $tabFocus = $("#<?php echo self::$opt_defaultvol; ?>").closest('section');
4714 + }
4715 + }
4716 +
4717 + if (!valid)
4718 + {
4719 + alertify.alert(alertmessage);
4720 + var tabSelector = '.wrap-ytprefs .nav-tab-wrapper .nav-tab[href=#' + $tabFocus.attr('id') + ']';
4721 + $(tabSelector).trigger('click');
4722 + }
4723 + if (!$formDefaults.find('#ajax_save').is(':checked'))
4724 + {
4725 + return valid;
4726 + }
4727 + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// MAIN PREFS AJAX SAVE
4728 + if (valid)
4729 + {
4730 + e.preventDefault();
4731 + (window.tinyMCE || window.tinymce).triggerSave();
4732 + $formDefaults.find('.ytprefs-submit').prop('disabled', true);
4733 +
4734 + var formData = $formDefaults.ytprefsFormJSON();
4735 + formData.action = 'my_embedplus_settings_save_ajax';
4736 +
4737 + $.ajax({
4738 + type: "post",
4739 + dataType: "json",
4740 + timeout: 30000,
4741 + url: window._EPYTA_ ? window._EPYTA_.wpajaxurl : ajaxurl,
4742 + data: formData,
4743 + success: function (response)
4744 + {
4745 + alertify.alert(response ? response.message : 'Sorry, there was an error submitting your settings.', function ()
4746 + {
4747 + if (response.type == 'success')
4748 + {
4749 + window.top.location.href = window._EPYTA_.admin_url_ytprefs;
4750 + }
4751 + });
4752 + },
4753 + error: function (xhr, ajaxOptions, thrownError)
4754 + {
4755 + alertify.alert('Sorry, there was an error saving your settings. ' + (thrownError ? thrownError : ''));
4756 + },
4757 + complete: function ()
4758 + {
4759 + $formDefaults.find('.ytprefs-submit').prop('disabled', false);
4760 + }
4761 + });
4762 + }
4763 + };
4764 +
4765 + var mydomain = escape("http://" + window.location.host.toString());
4766 + jQuery(document).ready(function ($)
4767 + {
4768 + $(document).on('click', '.wrap-ytprefs .nav-tab-wrapper a, .epyt-jumptab', function ()
4769 + {
4770 + $a = $(this);
4771 + if (!$a.hasClass('href-link'))
4772 + {
4773 + $('.wrap-ytprefs .nav-tab-wrapper a').removeClass('nav-tab-active');
4774 + $a.addClass('nav-tab-active');
4775 + $('.wrap-ytprefs section').hide();
4776 + $('.wrap-ytprefs section').filter($a.attr('rel') ? $a.attr('rel') : $a.attr('href')).fadeIn(200);
4777 + return false;
4778 + }
4779 + });
4780 +
4781 + if (window.location.hash && window.location.hash == '#jumpmonetize')
4782 + {
4783 + setTimeout(function ()
4784 + {
4785 + window.scrollTo(0, 0);
4786 + }, 1);
4787 + $('.wrap-ytprefs .nav-tab-wrapper a[href="' + window.location.hash + '"]').trigger('click');
4788 + }
4789 +
4790 + $('#ytform').on('submit', function (e)
4791 + {
4792 + return window.savevalidate(e);
4793 + });
4794 +
4795 + jQuery('#<?php echo self::$opt_defaultdims; ?>').on('change', function ()
4796 + {
4797 + if (jQuery(this).is(":checked"))
4798 + {
4799 + jQuery("#boxdefaultdims").show(500);
4800 + }
4801 + else
4802 + {
4803 + jQuery("#boxdefaultdims").hide(500);
4804 + }
4805 +
4806 + });
4807 + jQuery('#<?php echo self::$opt_gallery_customarrows; ?>').on('change', function ()
4808 + {
4809 + if (jQuery(this).is(":checked"))
4810 + {
4811 + jQuery("#boxcustomarrows").show(500);
4812 + }
4813 + else
4814 + {
4815 + jQuery("#boxcustomarrows").hide(500);
4816 + }
4817 +
4818 + });
4819 + jQuery('#<?php echo self::$opt_gallery_collapse_grid; ?>').on('change', function ()
4820 + {
4821 + if (jQuery(this).is(":checked"))
4822 + {
4823 + jQuery("#box_collapse_grid").show(500);
4824 + }
4825 + else
4826 + {
4827 + jQuery("#box_collapse_grid").hide(500);
4828 + }
4829 + });
4830 + jQuery('#<?php echo self::$opt_restrict_wizard; ?>').on('change', function ()
4831 + {
4832 + if (jQuery(this).is(":checked"))
4833 + {
4834 + jQuery("#box_restrict_wizard").show(500);
4835 + }
4836 + else
4837 + {
4838 + jQuery("#box_restrict_wizard").hide(500);
4839 + }
4840 + });
4841 +
4842 + jQuery('#<?php echo self::$opt_gallery_channelsub; ?>').on('change', function ()
4843 + {
4844 + if (jQuery(this).is(":checked"))
4845 + {
4846 + jQuery("#boxchannelsub").show(500);
4847 + }
4848 + else
4849 + {
4850 + jQuery("#boxchannelsub").hide(500);
4851 + }
4852 +
4853 + });
4854 + jQuery('#<?php echo self::$opt_responsive; ?>').on('change', function ()
4855 + {
4856 + if (jQuery(this).is(":checked"))
4857 + {
4858 + jQuery("#boxresponsive_all").show(500);
4859 + }
4860 + else
4861 + {
4862 + jQuery("#boxresponsive_all").hide(500);
4863 + }
4864 + });
4865 + jQuery('#<?php echo self::$opt_migrate; ?>').on('change', function ()
4866 + {
4867 + if (jQuery(this).is(":checked"))
4868 + {
4869 + jQuery("#boxmigratelist").show(500);
4870 + }
4871 + else
4872 + {
4873 + jQuery("#boxmigratelist").hide(500);
4874 + }
4875 + });
4876 + jQuery('#<?php echo self::$opt_nocookie; ?>').on('change', function ()
4877 + {
4878 + if (jQuery(this).is(":checked"))
4879 + {
4880 + jQuery("#boxnocookie").show(500);
4881 + }
4882 + else
4883 + {
4884 + jQuery("#boxnocookie").hide(500);
4885 + }
4886 +
4887 + });
4888 + jQuery('#<?php echo self::$opt_gdpr_consent; ?>').on('change', function ()
4889 + {
4890 + if (jQuery(this).is(":checked"))
4891 + {
4892 + jQuery("#box_gdpr_consent").show(500);
4893 + }
4894 + else
4895 + {
4896 + jQuery("#box_gdpr_consent").hide(500);
4897 + }
4898 +
4899 + });
4900 +
4901 + jQuery('#<?php echo self::$opt_defaultvol; ?>').on('change', function ()
4902 + {
4903 + if (jQuery(this).is(":checked"))
4904 + {
4905 + jQuery("#boxdefaultvol").show(500);
4906 + }
4907 + else
4908 + {
4909 + jQuery("#boxdefaultvol").hide(500);
4910 + }
4911 +
4912 + });
4913 + var rangedetect = document.createElement("input");
4914 + rangedetect.setAttribute("type", "range");
4915 + var canrange = rangedetect.type !== "text";
4916 + //canrange = false;
4917 + if (canrange)
4918 + {
4919 + $("input#vol").prop("type", "range").addClass("vol-range").on("input change", function ()
4920 + {
4921 + $('.vol-output').text($(this).val() > 0 ? $(this).val() + '%' : 'Mute');
4922 + });
4923 + $('.vol-output').css("display", "inline-block").text($("input#vol").val() > 0 ? $("input#vol").val() + '%' : 'Mute');
4924 + $('.vol-seeslider').show();
4925 + $('.vol-seetextbox').hide();
4926 + }
4927 + else
4928 + {
4929 + $("input#vol").width(40);
4930 + }
4931 +
4932 + $('#defer_js').on('change', function ()
4933 + {
4934 + if (!$(this).is(':checked'))
4935 + {
4936 + $('#defer_jquery').prop('checked', false).prop('disabled', true);
4937 + }
4938 + else
4939 + {
4940 + $('#defer_jquery').prop('disabled', false);
4941 + }
4942 + });
4943 +
4944 + });
4945 + })(jQuery);
4946 + </script>
4947 +
4948 + <a href="<?php echo esc_attr(admin_url('admin.php?page=youtube-ep-onboarding') . '&random=' . rand(1, 1000) . '&TB_iframe=true&width=950&height=800'); ?>" class="thickbox ytprefs-onboarding-launch" id="ytprefs-onboarding-launch" title="EmbedPlus for YouTube Setup Guide"></a>
4949 +
4950 + <?php
4951 + if (function_exists('add_thickbox'))
4952 + {
4953 + add_thickbox();
4954 + }
4955 + }
4956 +
4957 + public static function settings_save($all)
4958 + {
4959 + $new_options = array();
4960 + $new_options[self::$opt_center] = self::postchecked(self::$opt_center) ? 1 : 0;
4961 + $new_options[self::$opt_glance] = self::postchecked(self::$opt_glance) ? 1 : 0;
4962 + $new_options[self::$opt_autoplay] = self::postchecked(self::$opt_autoplay) ? 1 : 0;
4963 + $new_options[self::$opt_debugmode] = self::postchecked(self::$opt_debugmode) ? 1 : 0;
4964 + $new_options[self::$opt_uninstall_data] = self::postchecked(self::$opt_uninstall_data) ? 1 : 0;
4965 + $new_options[self::$opt_admin_off_scripts] = self::postchecked(self::$opt_admin_off_scripts) ? 1 : 0;
4966 + $new_options[self::$opt_defer_js] = self::postchecked(self::$opt_defer_js) ? 1 : 0;
4967 + $new_options[self::$opt_defer_jquery] = self::postchecked(self::$opt_defer_jquery) ? 1 : 0;
4968 + $new_options[self::$opt_ajax_save] = self::postchecked(self::$opt_ajax_save) ? 1 : 0;
4969 + $new_options[self::$opt_show_pointer] = self::postchecked(self::$opt_show_pointer) ? 1 : 0;
4970 + $new_options[self::$opt_old_script_method] = self::postchecked(self::$opt_old_script_method) ? 1 : 0;
4971 + $new_options[self::$opt_cc_load_policy] = self::postchecked(self::$opt_cc_load_policy) ? 1 : 0;
4972 + $new_options[self::$opt_iv_load_policy] = self::postchecked(self::$opt_iv_load_policy) ? 1 : 3;
4973 + $new_options[self::$opt_loop] = self::postchecked(self::$opt_loop) ? 1 : 0;
4974 + $new_options[self::$opt_fs] = self::postchecked(self::$opt_fs) ? 1 : 0;
4975 + $new_options[self::$opt_playsinline] = self::postchecked(self::$opt_playsinline) ? 1 : 0;
4976 + $new_options[self::$opt_origin] = self::postchecked(self::$opt_origin) ? 1 : 0;
4977 + $new_options[self::$opt_controls] = self::postchecked(self::$opt_controls) ? 1 : 0;
4978 + $new_options[self::$opt_disablekb] = self::postchecked(self::$opt_disablekb) ? 1 : 0;
4979 + $new_options[self::$opt_color] = self::postchecked(self::$opt_color) ? 'red' : 'white';
4980 + $new_options[self::$opt_nocookie] = self::postchecked(self::$opt_nocookie) ? 1 : 0;
4981 + $new_options[self::$opt_gb_compat] = self::postchecked(self::$opt_gb_compat) ? 1 : 0;
4982 + $new_options[self::$opt_facade_mode] = self::postchecked(self::$opt_facade_mode) ? 1 : 0;
4983 + $new_options[self::$opt_facade_autoplay] = self::postchecked(self::$opt_facade_autoplay) ? 1 : 0;
4984 + $new_options[self::$opt_gdpr_consent] = self::postchecked(self::$opt_gdpr_consent) ? 1 : 0;
4985 + $new_options[self::$opt_playlistorder] = self::postchecked(self::$opt_playlistorder) ? 1 : 0;
4986 + $new_options[self::$opt_acctitle] = self::postchecked(self::$opt_acctitle) ? 1 : 0;
4987 + $new_options[self::$opt_migrate] = self::postchecked(self::$opt_migrate) ? 1 : 0;
4988 + $new_options[self::$opt_migrate_youtube] = self::postchecked(self::$opt_migrate_youtube) ? 1 : 0;
4989 + $new_options[self::$opt_migrate_embedplusvideo] = self::postchecked(self::$opt_migrate_embedplusvideo) ? 1 : 0;
4990 + $new_options[self::$opt_oldspacing] = self::postchecked(self::$opt_oldspacing) ? 1 : 0;
4991 + $new_options[self::$opt_frontend_only] = self::postchecked(self::$opt_frontend_only) ? 1 : 0;
4992 + $new_options[self::$opt_responsive] = self::postchecked(self::$opt_responsive) ? 1 : 0;
4993 + $new_options[self::$opt_widgetfit] = self::postchecked(self::$opt_widgetfit) ? 1 : 0;
4994 + $new_options[self::$opt_evselector_light] = self::postchecked(self::$opt_evselector_light) ? 1 : 0;
4995 + $new_options[self::$opt_stop_mobile_buffer] = self::postchecked(self::$opt_stop_mobile_buffer) ? 1 : 0;
4996 + $new_options[self::$opt_restrict_wizard] = self::postchecked(self::$opt_restrict_wizard) ? 1 : 0;
4997 + $new_options[self::$opt_ajax_compat] = self::postchecked(self::$opt_ajax_compat) ? 1 : 0;
4998 + $new_options[self::$opt_defaultdims] = self::postchecked(self::$opt_defaultdims) ? 1 : 0;
4999 + $new_options[self::$opt_pause_others] = self::postchecked(self::$opt_pause_others) ? 1 : 0;
5000 + $new_options[self::$opt_defaultvol] = self::postchecked(self::$opt_defaultvol) ? 1 : 0;
5001 + $new_options[self::$opt_dohl] = self::postchecked(self::$opt_dohl) ? 1 : 0;
5002 + $new_options[self::$opt_onboarded] = self::postchecked(self::$opt_onboarded) ? 1 : 0;
5003 + $new_options[self::$opt_not_live_on] = self::postchecked(self::$opt_not_live_on) ? 1 : 0;
5004 + $new_options[self::$opt_not_live_on_channel] = self::postchecked(self::$opt_not_live_on_channel) ? 1 : 0;
5005 + $new_options[self::$opt_gallery_hideprivate] = self::postchecked(self::$opt_gallery_hideprivate) ? 1 : 0;
5006 + $new_options[self::$opt_gallery_showtitle] = self::postchecked(self::$opt_gallery_showtitle) ? 1 : 0;
5007 + $new_options[self::$opt_gallery_showpaging] = self::postchecked(self::$opt_gallery_showpaging) ? 1 : 0;
5008 + $new_options[self::$opt_gallery_autonext] = self::postchecked(self::$opt_gallery_autonext) ? 1 : 0;
5009 + $new_options[self::$opt_gallery_thumbplay] = self::postchecked(self::$opt_gallery_thumbplay) ? 1 : 0;
5010 + $new_options[self::$opt_gallery_channelsub] = self::postchecked(self::$opt_gallery_channelsub) ? 1 : 0;
5011 + $new_options[self::$opt_gallery_customarrows] = self::postchecked(self::$opt_gallery_customarrows) ? 1 : 0;
5012 + $new_options[self::$opt_gallery_collapse_grid] = self::postchecked(self::$opt_gallery_collapse_grid) ? 1 : 0;
5013 +
5014 + $new_options[self::$opt_cc_lang_pref] = sanitize_title($_POST[self::$opt_cc_lang_pref]);
5015 +
5016 + $_rel = 0;
5017 + try
5018 + {
5019 + $_rel = is_numeric(trim($_POST[self::$opt_rel])) ? intval(trim($_POST[self::$opt_rel])) : $_rel;
5020 + }
5021 + catch (Exception $ex)
5022 + {
5023 +
5024 + }
5025 + $new_options[self::$opt_rel] = $_rel;
5026 +
5027 +
5028 + $_gdpr_consent_message = '';
5029 + try
5030 + {
5031 + $_gdpr_consent_message = wp_kses_post(stripslashes($_POST[self::$opt_gdpr_consent_message]));
5032 + }
5033 + catch (Exception $ex)
5034 + {
5035 + $_gdpr_consent_message = '';
5036 + }
5037 + $new_options[self::$opt_gdpr_consent_message] = $_gdpr_consent_message;
5038 +
5039 + $_gdpr_consent_button = '';
5040 + try
5041 + {
5042 + $_gdpr_consent_button = wp_kses_post(stripslashes($_POST[self::$opt_gdpr_consent_button]));
5043 + }
5044 + catch (Exception $ex)
5045 + {
5046 + $_gdpr_consent_button = '';
5047 + }
5048 + $new_options[self::$opt_gdpr_consent_button] = $_gdpr_consent_button;
5049 +
5050 + $_ytapi_load = 'light';
5051 + try
5052 + {
5053 + $_ytapi_load_temp = $_POST[self::$opt_ytapi_load];
5054 + if (in_array($_ytapi_load_temp, array('always', 'light', 'never')))
5055 + {
5056 + $_ytapi_load = $_ytapi_load_temp;
5057 + }
5058 + }
5059 + catch (Exception $ex)
5060 + {
5061 +
5062 + }
5063 + $new_options[self::$opt_ytapi_load] = $_ytapi_load;
5064 +
5065 + $_maxres_facade = 'eager';
5066 + try
5067 + {
5068 + $_maxres_facade_temp = filter_input(INPUT_POST, self::$opt_maxres_facade);
5069 + if (in_array($_maxres_facade_temp, array('eager', 'soft', 'off')))
5070 + {
5071 + $_maxres_facade = $_maxres_facade_temp;
5072 + }
5073 + }
5074 + catch (Exception $ex)
5075 + {
5076 +
5077 + }
5078 + $new_options[self::$opt_maxres_facade] = $_maxres_facade;
5079 +
5080 + $_restrict_wizard_roles = self::$dft_roles;
5081 + try
5082 + {
5083 + $_restrict_wizard_roles = is_array($_POST[self::$opt_restrict_wizard_roles]) ? $_POST[self::$opt_restrict_wizard_roles] : $_restrict_wizard_roles;
5084 + }
5085 + catch (Exception $ex)
5086 + {
5087 +
5088 + }
5089 + $new_options[self::$opt_restrict_wizard_roles] = $_restrict_wizard_roles;
5090 +
5091 +
5092 + $_defaultwidth = '';
5093 + try
5094 + {
5095 + $_defaultwidth = is_numeric(trim($_POST[self::$opt_defaultwidth])) ? intval(trim($_POST[self::$opt_defaultwidth])) : $_defaultwidth;
5096 + }
5097 + catch (Exception $ex)
5098 + {
5099 +
5100 + }
5101 + $new_options[self::$opt_defaultwidth] = $_defaultwidth;
5102 +
5103 + $_defaultheight = '';
5104 + try
5105 + {
5106 + $_defaultheight = is_numeric(trim($_POST[self::$opt_defaultheight])) ? intval(trim($_POST[self::$opt_defaultheight])) : $_defaultheight;
5107 + }
5108 + catch (Exception $ex)
5109 + {
5110 +
5111 + }
5112 + $new_options[self::$opt_defaultheight] = $_defaultheight;
5113 +
5114 + $_responsive_all = 1;
5115 + try
5116 + {
5117 + $_responsive_all = is_numeric(trim($_POST[self::$opt_responsive_all])) ? intval(trim($_POST[self::$opt_responsive_all])) : $_responsive_all;
5118 + }
5119 + catch (Exception $ex)
5120 + {
5121 +
5122 + }
5123 + $new_options[self::$opt_responsive_all] = $_responsive_all;
5124 +
5125 + $_vol = '';
5126 + try
5127 + {
5128 + $_vol = is_numeric(trim($_POST[self::$opt_vol])) ? intval(trim($_POST[self::$opt_vol])) : $_vol;
5129 + }
5130 + catch (Exception $ex)
5131 + {
5132 +
5133 + }
5134 + $new_options[self::$opt_vol] = $_vol;
5135 +
5136 + $_gallery_pagesize = 15;
5137 + try
5138 + {
5139 + $_gallery_pagesize = is_numeric(trim($_POST[self::$opt_gallery_pagesize])) ? intval(trim($_POST[self::$opt_gallery_pagesize])) : $_gallery_pagesize;
5140 + }
5141 + catch (Exception $ex)
5142 + {
5143 +
5144 + }
5145 + $new_options[self::$opt_gallery_pagesize] = $_gallery_pagesize;
5146 +
5147 +
5148 + $_gallery_columns = 3;
5149 + try
5150 + {
5151 + $_gallery_columns = is_numeric(trim($_POST[self::$opt_gallery_columns])) ? intval(trim($_POST[self::$opt_gallery_columns])) : $_gallery_columns;
5152 + }
5153 + catch (Exception $ex)
5154 + {
5155 +
5156 + }
5157 + $new_options[self::$opt_gallery_columns] = $_gallery_columns;
5158 +
5159 +
5160 + $_gallery_collapse_grid_breaks = self::$dft_bpts;
5161 + try
5162 + {
5163 + $_gallery_collapse_grid_breaks = is_array($_POST[self::$opt_gallery_collapse_grid_breaks]) ? $_POST[self::$opt_gallery_collapse_grid_breaks] : $_gallery_collapse_grid_breaks;
5164 + }
5165 + catch (Exception $ex)
5166 + {
5167 +
5168 + }
5169 + $new_options[self::$opt_gallery_collapse_grid_breaks] = $_gallery_collapse_grid_breaks;
5170 +
5171 +
5172 +
5173 + $_gallery_scrolloffset = 20;
5174 + try
5175 + {
5176 + $_gallery_scrolloffset = is_numeric(trim($_POST[self::$opt_gallery_scrolloffset])) ? intval(trim($_POST[self::$opt_gallery_scrolloffset])) : $_gallery_scrolloffset;
5177 + }
5178 + catch (Exception $ex)
5179 + {
5180 +
5181 + }
5182 + $new_options[self::$opt_gallery_scrolloffset] = $_gallery_scrolloffset;
5183 +
5184 + $_gallery_channelsublink = '';
5185 + try
5186 + {
5187 + $_gallery_channelsublink = trim(strip_tags($_POST[self::$opt_gallery_channelsublink]));
5188 + $pieces = explode('?', $_gallery_channelsublink);
5189 + $_gallery_channelsublink = trim($pieces[0]);
5190 + }
5191 + catch (Exception $ex)
5192 + {
5193 + $_gallery_channelsublink = '';
5194 + }
5195 + $new_options[self::$opt_gallery_channelsublink] = $_gallery_channelsublink;
5196 +
5197 +
5198 + $_gallery_channelsubtext = '';
5199 + try
5200 + {
5201 + $_gallery_channelsubtext = stripslashes(trim($_POST[self::$opt_gallery_channelsubtext]));
5202 + }
5203 + catch (Exception $ex)
5204 + {
5205 + $_gallery_channelsubtext = '';
5206 + }
5207 + $new_options[self::$opt_gallery_channelsubtext] = $_gallery_channelsubtext;
5208 +
5209 +
5210 + $_gallery_custom_prev = 'Prev';
5211 + try
5212 + {
5213 + $_gallery_custom_prev = trim(strip_tags($_POST[self::$opt_gallery_customprev]));
5214 + }
5215 + catch (Exception $ex)
5216 + {
5217 + $_gallery_custom_prev = 'Prev';
5218 + }
5219 + $new_options[self::$opt_gallery_customprev] = $_gallery_custom_prev;
5220 +
5221 +
5222 + $_gallery_custom_next = 'Next';
5223 + try
5224 + {
5225 + $_gallery_custom_next = trim(strip_tags($_POST[self::$opt_gallery_customnext]));
5226 + }
5227 + catch (Exception $ex)
5228 + {
5229 + $_gallery_custom_next = 'Next';
5230 + }
5231 + $new_options[self::$opt_gallery_customnext] = $_gallery_custom_next;
5232 +
5233 +
5234 + $_not_live_content = '';
5235 + try
5236 + {
5237 + $_not_live_content = wp_kses_post(stripslashes($_POST[self::$opt_not_live_content]));
5238 + }
5239 + catch (Exception $ex)
5240 + {
5241 + $_not_live_content = '';
5242 + }
5243 + $new_options[self::$opt_not_live_content] = $_not_live_content;
5244 +
5245 +
5246 + $_apikey = '';
5247 + try
5248 + {
5249 + $_apikey = trim(str_replace(array(' ', "'", '"'), array('', '', ''), strip_tags($_POST[self::$opt_apikey])));
5250 + }
5251 + catch (Exception $ex)
5252 + {
5253 + $_apikey = '';
5254 + }
5255 + $new_options[self::$opt_apikey] = $_apikey;
5256 +
5257 +
5258 + $all = $new_options + $all;
5259 +
5260 + update_option(self::$opt_alloptions, $all);
5261 + return array(
5262 + 'type' => 'success',
5263 + 'message' => 'Changes were saved. <em>If you are using a separate caching plugin and you do not see your changes after saving, <strong class="orange">you need to reset your cache.</strong></em>'
5264 + );
5265 + }
5266 +
5267 + public static function settings_save_ajax()
5268 + {
5269 + $result = array();
5270 + if (check_ajax_referer('_epyt_save', '_epyt_nonce', false) && current_user_can('manage_options'))
5271 + {
5272 + $all = get_option(self::$opt_alloptions);
5273 + $result = self::settings_save($all);
5274 + }
5275 + else
5276 + {
5277 + $result['type'] = 'error';
5278 + $result['message'] = 'Sorry, there was a problem saving your settings.';
5279 + }
5280 + echo json_encode($result);
5281 + die();
5282 + }
5283 +
5284 + public static function onboarding_save_valid(&$input)
5285 + {
5286 + $messages = array();
5287 + try
5288 + {
5289 + $input[self::$opt_responsive] = intval($input[self::$opt_responsive]);
5290 + $input[self::$opt_responsive_all] = intval($input[self::$opt_responsive_all]);
5291 + $input[self::$opt_defer_js] = intval($input[self::$opt_defer_js]);
5292 + $input[self::$opt_disablekb] = intval($input[self::$opt_disablekb]);
5293 +
5294 + $input[self::$opt_gallery_pagesize] = intval($input[self::$opt_gallery_pagesize]);
5295 + $input[self::$opt_gallery_columns] = intval($input[self::$opt_gallery_columns]);
5296 + $input[self::$opt_not_live_content] = wp_kses_post(stripslashes($input[self::$opt_not_live_content]));
5297 + $input[self::$opt_not_live_on] = intval($input[self::$opt_not_live_on]);
5298 + $input[self::$opt_not_live_on_channel] = intval($input[self::$opt_not_live_on_channel]);
5299 +
5300 + if (!in_array($input[self::$opt_ytapi_load], array('always', 'light', 'never')))
5301 + {
5302 + $input[self::$opt_ytapi_load] = 'light';
5303 + }
5304 + $input[self::$opt_facade_mode] = intval($input[self::$opt_facade_mode]);
5305 + $input[self::$opt_facade_autoplay] = intval($input[self::$opt_facade_autoplay]);
5306 + $input[self::$opt_gdpr_consent] = intval($input[self::$opt_gdpr_consent]);
5307 + $input[self::$opt_gdpr_consent_message] = wp_kses_post(stripslashes($input[self::$opt_gdpr_consent_message]));
5308 + $input[self::$opt_gdpr_consent_button] = wp_kses_post(stripslashes($input[self::$opt_gdpr_consent_button]));
5309 + $input[self::$opt_nocookie] = intval($input[self::$opt_nocookie]);
5310 + }
5311 + catch (Exception $ex)
5312 + {
5313 + $messages[] = 'Please enter valid data.';
5314 + }
5315 +
5316 + if (empty($messages))
5317 + {
5318 + return true;
5319 + }
5320 + return $messages;
5321 + }
5322 +
5323 + public static function onboarding_save()
5324 + {
5325 + $result = array();
5326 + $default = array(
5327 + self::$opt_rel => 1,
5328 + self::$opt_disablekb => 0,
5329 + self::$opt_responsive => 0,
5330 + self::$opt_responsive_all => 0,
5331 + self::$opt_defer_js => 0,
5332 + self::$opt_gallery_pagesize => 15,
5333 + self::$opt_gallery_columns => 3,
5334 + self::$opt_not_live_content => '',
5335 + self::$opt_not_live_on => 0,
5336 + self::$opt_not_live_on_channel => 0,
5337 + self::$opt_ytapi_load => 'light',
5338 + self::$opt_facade_mode => 0,
5339 + self::$opt_facade_autoplay => 1,
5340 + self::$opt_gdpr_consent => 0,
5341 + self::$opt_gdpr_consent_message => self::$dft_gdpr_consent_message,
5342 + self::$opt_gdpr_consent_button => 'Accept YouTube Content',
5343 + self::$opt_nocookie => 0
5344 + );
5345 +
5346 +
5347 + $input = shortcode_atts($default, stripslashes_deep($_POST));
5348 + $valid = self::onboarding_save_valid($input);
5349 + if ($valid === true)
5350 + {
5351 + self::update_option_set($input);
5352 + $result['type'] = 'success';
5353 + }
5354 + else
5355 + {
5356 + $result['type'] = 'error';
5357 + $result['message'] = implode('<br/>', $valid);
5358 + }
5359 +
5360 + return $result;
5361 + }
5362 +
5363 + public static function onboarding_save_ajax()
5364 + {
5365 + $result = array();
5366 + if (self::is_ajax() && self::ajax_referer() && current_user_can('manage_options'))
5367 + {
5368 + $result = self::onboarding_save();
5369 + }
5370 + else
5371 + {
5372 + $result['type'] = 'error';
5373 + $result['message'] = 'Sorry, there was a problem saving the data.';
5374 + }
5375 + echo json_encode($result);
5376 + die();
5377 + }
5378 +
5379 + public static function onboarding_save_apikey_valid(&$input)
5380 + {
5381 + $messages = array();
5382 + try
5383 + {
5384 + $input[self::$opt_apikey] = trim(str_replace(array(' ', "'", '"'), array('', '', ''), strip_tags($input[self::$opt_apikey])));
5385 + }
5386 + catch (Exception $ex)
5387 + {
5388 + $messages[] = 'Please enter a valid API key.';
5389 + }
5390 +
5391 + if (empty($messages))
5392 + {
5393 + return true;
5394 + }
5395 + return $messages;
5396 + }
5397 +
5398 + public static function onboarding_save_apikey()
5399 + {
5400 + $result = array();
5401 + $default = array(
5402 + self::$opt_apikey => '',
5403 + );
5404 +
5405 + $input = shortcode_atts($default, stripslashes_deep($_POST));
5406 + $valid = self::onboarding_save_apikey_valid($input);
5407 + if ($valid === true)
5408 + {
5409 + self::update_option_set($input);
5410 + $result['type'] = 'success';
5411 + }
5412 + else
5413 + {
5414 + $result['type'] = 'error';
5415 + $result['message'] = implode('<br/>', $valid);
5416 + }
5417 +
5418 + return $result;
5419 + }
5420 +
5421 + public static function onboarding_save_apikey_ajax()
5422 + {
5423 + $result = array();
5424 + if (self::is_ajax() && self::ajax_referer() && current_user_can('manage_options'))
5425 + {
5426 + $result = self::onboarding_save_apikey();
5427 + }
5428 + else
5429 + {
5430 + $result['type'] = 'error';
5431 + $result['message'] = 'Sorry, there was a problem saving the data.';
5432 + }
5433 + echo json_encode($result);
5434 + die();
5435 + }
5436 +
5437 + public static function ytprefs_show_onboarding()
5438 + {
5439 +
5440 + if (!current_user_can('manage_options'))
5441 + {
5442 + wp_die(__('You do not have sufficient permissions to access this page.'));
5443 + }
5444 + if (self::$double_plugin)
5445 + {
5446 + self::double_plugin_warning();
5447 + }
5448 + $all = get_option(self::$opt_alloptions);
5449 +
5450 + $do_once = array(
5451 + self::$opt_onboarded => 1
5452 + );
5453 + self::update_option_set($do_once);
5454 + ?>
5455 + <div class="wrap wrap-ytprefs-onboarding">
5456 + <div class="ytprefs-ob-title">
5457 + EmbedPlus for YouTube Setup Guide
5458 + </div>
5459 + <div class="relative">
5460 + <div class="ytprefs-ob-step ytprefs-ob-step1 active-step">
5461 + <div class="ytprefs-ob-content">
5462 + <div class="ytprefs-ob-block">
5463 + <p>
5464 + With so many options available in this plugin, we created this easy setup guide to help you quickly learn about its <strong>most common settings and newest features</strong>. We hope it will get you embedding videos, galleries, and/or live streams sooner.
5465 + </p>
5466 + <p>
5467 + You'll have an opportunity to see and set many other options after completing this setup guide.
5468 + </p>
5469 + </div>
5470 + </div>
5471 +
5472 + <div class="ytprefs-ob-content ytprefs-ob-content1">
5473 + <h2>
5474 + Below, check all that apply:<br><em>I'm interested in embedding...</em>
5475 + </h2>
5476 + <div class="ytprefs-hover-icons">
5477 + <img class="yob-single-icon" src="<?php echo plugins_url('images/icon-player-single.png', __FILE__) ?>"/>
5478 + <img class="yob-gallery-icon" src="<?php echo plugins_url('images/icon-playlist-gallery.png', __FILE__) ?>"/>
5479 + <img class="yob-standalone-icon" src="<?php echo plugins_url('images/icon-playlist-self.png', __FILE__) ?>"/>
5480 + <img class="yob-live-icon" src="<?php echo plugins_url('images/icon-player-live.png', __FILE__) ?>"/>
5481 + <img class="yob-privacy-icon" src="<?php echo plugins_url('images/icon-player-privacy.png', __FILE__) ?>"/>
5482 + <!-- <img class="yob-monetize-icon" src="<?php echo plugins_url('images/icon-player-money.png', __FILE__) ?>"/>-->
5483 + </div>
5484 + <ul class="ytprefs-ob-filter">
5485 + <li><label><input type="checkbox" data-obfilter="yob-single" /> Single videos.</label></li>
5486 + <li><label><input type="checkbox" data-obfilter="yob-gallery" /> Galleries of playlists or channels (displays thumbnails and a player).</label></li>
5487 + <li><label><input type="checkbox" data-obfilter="yob-standalone" /> Self-contained playlists or channels (no thumbnails, just YouTube's standard playlist player).</label></li>
5488 + <li><label><input type="checkbox" data-obfilter="yob-live" /> Live streams or premieres.</label></li>
5489 + <li style="display:none;"><label><input type="checkbox" data-obfilter="yob-privacy" /> With GDPR / privacy features.</label></li>
5490 + <!-- <li><label><input type="checkbox" data-obfilter="yob-monetize" /> Relevant video ads that earn me up to 10x higher CPMs (revenue) than display advertising.</label></li>-->
5491 + </ul>
5492 + <div class="ytprefs-ob-nav">
5493 + <button type="button" class="button-secondary ytprefs-ob-nav-close">Cancel</button>
5494 + <button type="button" disabled class="button-primary ytprefs-ob-nav-next">Next &raquo;</button>
5495 + </div>
5496 + <h2>
5497 + Intro Video
5498 + </h2>
5499 + <p>
5500 + Want a quick visual overview? Here's a preview of some of the free features of the plugin.
5501 + </p>
5502 + <div class="epyt-fitvid">
5503 + <iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/QDdvXBqfrzM?rel=0" allowfullscreen="" frameborder="0"></iframe>
5504 + </div>
5505 + <p>
5506 + </p>
5507 + </div>
5508 + </div>
5509 + <div class="ytprefs-ob-step ytprefs-ob-step2">
5510 + <div class="ytprefs-ob-content">
5511 + <h2>
5512 + You're interested in:
5513 + </h2>
5514 +
5515 + <form id="form-onboarding">
5516 + <input type="hidden" name="action" value="my_embedplus_onboarding_save_ajax"/>
5517 +
5518 + <div class="ytprefs-ob-setting yob-single yob-gallery yob-standalone yob-live">
5519 + <label>
5520 + <b class="chktitle">Related Videos:</b>
5521 + Show or hide related and recommended videos at the end of playback.
5522 + <br>
5523 + </label>
5524 + <input type="radio" name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>-1" value="-1" <?php checked($all[self::$opt_rel], -1); ?>>
5525 + <label for="<?php echo self::$opt_rel; ?>-1">Hide related videos at the end of playback</label> &nbsp;&nbsp;
5526 + <input type="radio" name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>0" value="0" <?php checked($all[self::$opt_rel], 0); ?>>
5527 + <label for="<?php echo self::$opt_rel; ?>0">Show related videos only from the video's channel</label> &nbsp;&nbsp;
5528 + <input type="radio" name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>1" value="1" <?php checked($all[self::$opt_rel], 1); ?>>
5529 + <label for="<?php echo self::$opt_rel; ?>1">Show related videos</label> &nbsp;&nbsp;
5530 + </div>
5531 + <div class="ytprefs-ob-setting yob-single yob-gallery yob-standalone">
5532 + <input value="1" name="<?php echo self::$opt_facade_mode; ?>" id="<?php echo self::$opt_facade_mode; ?>" <?php checked($all[self::$opt_facade_mode], 1); ?> type="checkbox" class="checkbox">
5533 + <label for="<?php echo self::$opt_facade_mode ?>">
5534 + <b class="chktitle"><?php _e('Facade Mode:', 'youtube-embed-plus'); ?> <sup class="orange">new</sup></b>
5535 + <?php _e('This improves performance by loading a lighter version of the player, until it is clicked. Then the real player loads (note: for live streams, the real player is always loaded). We have tested this feature in multiple cases and found it to successfully improve your Lighthouse performance score by addressing the following recommendation: "Some third-party resources can be lazy loaded with a facade."', 'youtube-embed-plus'); ?>
5536 + <a href="https://www.youtube.com/watch?v=W7PKUjVBDNE" target="_blank"><?php _e('See an example of this feature at work.', 'youtube-embed-plus'); ?></a>
5537 + </label>
5538 + <div class="p box_facade_mode">
5539 + <input value="1" name="<?php echo self::$opt_facade_autoplay; ?>" id="<?php echo self::$opt_facade_autoplay; ?>" type="checkbox" class="checkbox" <?php checked($all[self::$opt_facade_autoplay], 1); ?>>
5540 + <label for="<?php echo self::$opt_facade_autoplay ?>">
5541 + <b class="chktitle"><?php _e('Autoplay On Facade Click:', 'youtube-embed-plus'); ?></b>
5542 + <span>
5543 + <?php _e('After clicking once on the facade (aka light thumbnail), it is replaced with the real player. Check this option to have the real player play immediately, otherwise it will require an additional click. Note that checking this option will use YouTube\'s autoplay feature, which will not contribute toward play counts. If you\'re embedding videos from someone else\'s channel, we recommend checking this. If you\'re embedding videos that are from your channel, then you should self-evaluate the tradeoff involving play counts and additional clicking.', 'youtube-embed-plus'); ?>
5544 + </span>
5545 + </label>
5546 + </div>
5547 + </div>
5548 + <div class="ytprefs-ob-setting yob-single yob-gallery yob-standalone yob-live">
5549 + <input value="1" name="<?php echo self::$opt_responsive; ?>" id="<?php echo self::$opt_responsive; ?>" <?php checked($all[self::$opt_responsive], 1); ?> type="checkbox" class="checkbox">
5550 + <label for="<?php echo self::$opt_responsive; ?>"><?php _e('<b class="chktitle">Responsive Video Sizing:</b> Make your videos responsive so that they dynamically fit in all screen sizes (smart phone, PC and tablet). NOTE: While this is checked, any custom hardcoded widths and heights you may have set will dynamically change too. <b>Do not check this if your theme already handles responsive video sizing.</b>') ?></label>
5551 + <p id="boxresponsive_all" class="ytindent">
5552 + <input type="radio" name="<?php echo self::$opt_responsive_all; ?>" id="<?php echo self::$opt_responsive_all; ?>1" value="1" <?php checked($all[self::$opt_responsive_all], 1); ?> >
5553 + <label for="<?php echo self::$opt_responsive_all; ?>1">Responsive for all YouTube videos</label> &nbsp;&nbsp;
5554 + <input type="radio" name="<?php echo self::$opt_responsive_all; ?>" id="<?php echo self::$opt_responsive_all; ?>0" value="0" <?php checked($all[self::$opt_responsive_all], 0); ?> >
5555 + <label for="<?php echo self::$opt_responsive_all; ?>0">Responsive for only videos embedded via this plugin</label>
5556 + </p>
5557 + </div>
5558 + <div class="ytprefs-ob-setting yob-gallery">
5559 + <label for="<?php echo self::$opt_gallery_pagesize; ?>"><b class="chktitle">Default Gallery Page Size:</b></label>
5560 + <select name="<?php echo self::$opt_gallery_pagesize; ?>" id="<?php echo self::$opt_gallery_pagesize; ?>" style="width: 60px;">
5561 + <?php
5562 + $gps_val = intval(trim($all[self::$opt_gallery_pagesize]));
5563 + $gps_val = min($gps_val, 50);
5564 + for ($gps = 1; $gps <= 50; $gps++)
5565 + {
5566 + ?><option <?php echo $gps_val == $gps ? 'selected' : '' ?> value="<?php echo $gps ?>"><?php echo $gps ?></option>
5567 + <?php
5568 + }
5569 + ?>
5570 + </select>
5571 + Enter how many thumbnails per page should be shown at once (YouTube allows a maximum of 50 per page). You can later use the embedding wizard to customize this for specific galleries.
5572 + </div>
5573 +
5574 + <div class="ytprefs-ob-setting yob-gallery">
5575 + <label for="<?php echo self::$opt_gallery_columns; ?>"><b class="chktitle">Default Gallery Number of Columns:</b></label>
5576 + <input name="<?php echo self::$opt_gallery_columns; ?>" id="<?php echo self::$opt_gallery_columns; ?>" type="number" class="textinput" style="width: 60px;" value="<?php echo esc_attr(trim($all[self::$opt_gallery_columns])); ?>">
5577 + Enter how many thumbnails can fit per row. You can later use the embedding wizard to customize this for specific galleries.
5578 + </div>
5579 + <div class="ytprefs-ob-setting yob-live">
5580 + <p>
5581 + <b class="chktitle">Use "Not Live" Fallback Content For Live Streams:</b> (<a href="<?php echo self::$epbase ?>/how-to-embed-a-youtube-livestream-in-wordpress.aspx" target="_blank">More info here</a>)
5582 + This feature lets you display alternate content if your live stream is not currently active. This feature works for <strong>direct link</strong> live streams (more info about channel-based live streams below).
5583 + </p>
5584 + <div class="ytindent chx">
5585 + <input value="1" name="<?php echo self::$opt_not_live_on; ?>" id="<?php echo self::$opt_not_live_on; ?>" <?php checked($all[self::$opt_not_live_on], 1); ?> type="checkbox" class="checkbox">
5586 + <label for="<?php echo self::$opt_not_live_on; ?>"><span class="chktitle">Turn on for <b>direct link</b> live streams:</span>
5587 + When your direct-link embed is not streaming live, the YouTube live player usually displays a countdown after the user clicks the play button.
5588 + Instead of showing that player, you can display some "coming soon" content in that space for your visitors to see until your video begins to live stream.
5589 + The plugin will automatically switch to your video's live stream once it's active. In the <em>"Not Live" Fallback Content</em> box below, enter what you would like to appear until then.
5590 + You can even insert shortcodes from our plugin into the box below (shortcodes from other plugins may or may not work correctly).
5591 + If you just want to show the standard countdown player that YouTube provides, don't use this feature.
5592 + <strong>NOTE: Turning this on for direct-link live streams uses a significant amount of your YouTube API quota. We suggest unchecking it if your site has high traffic. If you chose to use this feature, do not put another live stream embed below.</strong>
5593 + </label>
5594 + <br>
5595 + <br>
5596 + <input disabled id="<?php echo self::$opt_not_live_on_channel; ?>" type="checkbox" class="checkbox">
5597 + <label><span class="chktitle">Turn on for <b>channel</b> live streams (<span class="orange">upgrade required</span>) </span>
5598 + Unfortunately, Google has recently removed their YouTube API feature that used to support channel-based live streams. It appears they won't change things back. However, you do have a couple of choices:
5599 + <ol>
5600 + <li>Use "Direct link" live streams, as explained above. The trade-off is that you will have to manually post and take down your future live streams every time they start and when they end, respectively.</li>
5601 + <li>Or <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" target="_blank">upgrade to Pro</a>, which has a solution that brings back all the "set it and forget it" features of channel-based embeds. We spent a significant amount of time developing a stable, long-term solution around YouTube's limitations, so we are releasing this effort exclusively to our Pro customers.</li>
5602 + </ol>
5603 + </label>
5604 + <div class="p not-live-content">
5605 + <p>
5606 + <b>"Not Live" Fallback Content:</b>
5607 + </p>
5608 + <?php
5609 + wp_editor(wp_kses_post($all[self::$opt_not_live_content]), self::$opt_not_live_content, array('textarea_rows' => 7));
5610 + ?>
5611 + </div>
5612 + </div>
5613 + </div>
5614 +
5615 + <div class="ytprefs-ob-setting yob-privacy">
5616 + <b class="chktitle">YouTube API Loading:</b> Choose when to load the YouTube API. The "Restricted" or "Never" options will help with GDPR compliance:
5617 + <ul class="indent-option">
5618 + <li><label><input type="radio" name="<?php echo self::$opt_ytapi_load ?>" value="light" <?php checked($all[self::$opt_ytapi_load], 'light'); ?> /> <em>Restricted</em> - (Recommended) Only load the API on pages that have a YouTube video.</label></li>
5619 + <li><label><input type="radio" name="<?php echo self::$opt_ytapi_load ?>" value="never" <?php checked($all[self::$opt_ytapi_load], 'never'); ?> /> <em>Never</em> - Do not load the YouTube API. Note: The "Never" choice may break a few features such as Volume Initialization and Gallery Continuous/Auto Play.</label></li>
5620 + <li><label><input type="radio" name="<?php echo self::$opt_ytapi_load ?>" value="always" <?php checked($all[self::$opt_ytapi_load], 'always'); ?> /> <em>Always</em> - Load the API on all pages. In most cases, the "Always" choice is not necessary.</label></li>
5621 + </ul>
5622 + </div>
5623 +
5624 +
5625 + <div class="ytprefs-ob-setting yob-privacy">
5626 + <input value="1" name="<?php echo self::$opt_gdpr_consent; ?>" id="<?php echo self::$opt_gdpr_consent; ?>" <?php checked($all[self::$opt_gdpr_consent], 1); ?> type="checkbox" class="checkbox">
5627 + <label for="<?php echo self::$opt_gdpr_consent; ?>">
5628 + <b class="chktitle">Privacy/GDPR - Show Consent Message:</b> Ask for consent before loading YouTube content. A message will be displayed in place of the YouTube video, as shown in the screenshot below. Once the visitor approves consent, the YouTube content will load. You can customize the message text and the button text in the next 2 options.
5629 + </label>
5630 + </div>
5631 +
5632 +
5633 + <div class="ytprefs-ob-setting yob-privacy">
5634 + <label for="<?php echo self::$opt_gdpr_consent_message; ?>">
5635 + <b class="chktitle">Privacy/GDPR - Consent Message Text:</b>
5636 + Below you can customize the message that will appear to visitors before they accept YouTube content:
5637 + </label>
5638 + <div class="clearboth"></div>
5639 + <div class="gdpr-options-left">
5640 + <?php
5641 + wp_editor(wp_kses_post($all[self::$opt_gdpr_consent_message]), self::$opt_gdpr_consent_message, array(
5642 + 'textarea_rows' => 22,
5643 + 'media_buttons' => false,
5644 + 'teeny' => true
5645 + ));
5646 + ?>
5647 + </div>
5648 + <div class="gdpr-options-right">
5649 + <p><em>Example of message and button:</em></p>
5650 +
5651 + <img src="<?php echo plugins_url('images/ss-gdpr-message.png', __FILE__) ?>" alt="GDPR Consent Message Example" class="img-gdpr-message" />
5652 + </div>
5653 +
5654 + </div>
5655 +
5656 + <div class="clearboth"></div>
5657 + <div class="ytprefs-ob-setting yob-privacy">
5658 + <label for="<?php echo self::$opt_gdpr_consent_button; ?>">
5659 + <b class="chktitle">Privacy/GDPR - Consent Button Text:</b>
5660 + This is the text for the red "Accept" button that appears with the above privacy/GDPR message:
5661 + </label>
5662 + <br>
5663 + <input type="text" placeholder="Example: Accept YouTube Content" name="<?php echo self::$opt_gdpr_consent_button; ?>" id="<?php echo self::$opt_gdpr_consent_button; ?>" value="<?php echo esc_attr(trim($all[self::$opt_gdpr_consent_button])); ?>" class="textinput regular-text"/>
5664 + </div>
5665 +
5666 + <div class="ytprefs-ob-setting yob-privacy">
5667 + <input value="1" name="<?php echo self::$opt_nocookie; ?>" id="<?php echo self::$opt_nocookie; ?>" <?php checked($all[self::$opt_nocookie], 1); ?> type="checkbox" class="checkbox">
5668 + <label for="<?php echo self::$opt_nocookie; ?>">
5669 + <b class="chktitle">No Cookies:</b> Prevent YouTube from leaving tracking cookies on your visitors browsers unless they actual play the videos. This is coded to apply this behavior on links in your past post as well.
5670 + <span id="boxnocookie">
5671 + Checking this option may introduce issues to features that depend YouTube's API, such as galleries and playlists. Furthermore, videos on mobile devices may have problems if you leave this checked. We suggest testing this out to make sure you are pleased with the results.
5672 + </span>
5673 + </label>
5674 + </div>
5675 +
5676 + <div class="ytprefs-ob-nav">
5677 + <button type="button" class="button-secondary ytprefs-ob-nav-prev">&laquo; Previous</button>
5678 + <button type="submit" class="button-primary ytprefs-ob-nav-next">Save & Next &raquo;</button>
5679 + </div>
5680 + </form>
5681 + </div>
5682 + </div>
5683 + <div class="ytprefs-ob-step ytprefs-ob-step3">
5684 + <div class="ytprefs-ob-content">
5685 + <h2>
5686 + YouTube API Key
5687 + </h2>
5688 + <form id="form-onboarding-apikey">
5689 + <input type="hidden" name="action" value="my_embedplus_onboarding_save_apikey_ajax"/>
5690 + <p>
5691 + Some features (such as galleries, and some wizard features) now require you to create a free YouTube API key from Google.
5692 + </p>
5693 + <?php
5694 + if (!empty($all[self::$opt_apikey]) && strlen($all[self::$opt_apikey]) > 0)
5695 + {
5696 + ?>
5697 + <p class="ytprefs-ob-success">
5698 + Great! You already have an API key.
5699 + </p>
5700 + <?php
5701 + }
5702 + else
5703 + {
5704 + ?>
5705 + <p>
5706 + The instructions for this are very specific, so we created a video for you that's hopefully easy to follow: <a href="https://www.embedplus.com/how-to-create-a-youtube-api-key.aspx" target="_blank">Click this link</a> and follow the steps on the page. Then save your API key here.
5707 + </p>
5708 + <?php
5709 + }
5710 + ?>
5711 + <p>
5712 + <input type="text" placeholder="Paste your YouTube API key here" name="<?php echo self::$opt_apikey; ?>" id="<?php echo self::$opt_apikey; ?>" value="<?php echo esc_attr(trim($all[self::$opt_apikey])); ?>" class="regular-text" style='max-width: 40%;'>
5713 + </p>
5714 +
5715 + <div class="ytprefs-ob-nav">
5716 + <div class="ytprefs-ob-nav-ultimate">
5717 + <button type="button" class="button-secondary ytprefs-ob-nav-prev">&laquo; Previous</button>
5718 + <button type="button" class="button-secondary ytprefs-ob-nav-close">I'll do this later.</button>
5719 + <button type="submit" class="button-primary ytprefs-ob-nav-next">Save & Finish</button>
5720 + </div>
5721 + <div class="ytprefs-ob-nav-penultimate ytprefs-ob-nav-hide">
5722 + <button type="button" class="button-secondary ytprefs-ob-nav-prev">&laquo; Previous</button>
5723 + <button type="button" class="button-secondary ytprefs-ob-nav-skip">I'll do this later &raquo;</button>
5724 + <button type="submit" class="button-primary ytprefs-ob-nav-next">Save & Next &raquo;</button>
5725 + </div>
5726 + </div>
5727 + </form>
5728 + </div>
5729 + </div>
5730 + <div class="ytprefs-ob-step ytprefs-ob-step4">
5731 + <div class="ytprefs-ob-content">
5732 + <div class="ytprefs-ob-nav">
5733 + <button type="button" class="button-secondary ytprefs-ob-nav-prev">&laquo; Previous</button>
5734 + <button type="button" class="button-primary ytprefs-ob-nav-close">Finish</button>
5735 + </div>
5736 + </div>
5737 + </div>
5738 +
5739 + </div>
5740 + </div>
5741 + <?php
5742 + }
5743 +
5744 + public static function save_changes_button($submitted)
5745 + {
5746 + $button_label = 'Save Changes';
5747 + if ($submitted)
5748 + {
5749 + $button_label = 'Changes Saved';
5750 + ?>
5751 + <script type="text/javascript">
5752 + jQuery(document).ready(function ()
5753 + {
5754 + setTimeout(function ()
5755 + {
5756 + jQuery('.ytprefs-submit').text('Save Changes');
5757 + }, 3000);
5758 + });</script>
5759 + <?php
5760 + }
5761 + ?>
5762 + <p class="submit">
5763 + <button type="submit" name="Submit" class="button-primary ytprefs-submit"><?php _e($button_label) ?></button>
5764 + <em>If you're using a separate caching plugin and you do not see your changes after saving, <strong class="orange">you need to reset your cache.</strong></em>
5765 + </p>
5766 + <?php
5767 + }
5768 +
5769 + public static function ytprefsscript()
5770 + {
5771 + $loggedin = current_user_can('edit_posts');
5772 + if (!($loggedin && self::$alloptions[self::$opt_admin_off_scripts]))
5773 + {
5774 + wp_enqueue_style(
5775 + '__EPYT__style', plugins_url('styles/ytprefs' . self::$min . '.css', __FILE__), array(), self::$version
5776 + );
5777 + $cols = floatval(self::$alloptions[self::$opt_gallery_columns]);
5778 + $cols = $cols == 0 ? 3.0 : $cols;
5779 + $colwidth = 100.0 / $cols;
5780 + $custom_css = "
5781 + .epyt-gallery-thumb {
5782 + width: " . round($colwidth, 3) . "%;
5783 + }
5784 + ";
5785 +
5786 + if (self::$alloptions[self::$opt_gallery_collapse_grid] == 1)
5787 + {
5788 + foreach (self::$alloptions[self::$opt_gallery_collapse_grid_breaks] as $idx => $bpts)
5789 + {
5790 + $custom_css .= "
5791 + @media (min-width:" . $bpts['bp']['min'] . "px) and (max-width: " . $bpts['bp']['max'] . "px) {
5792 + .epyt-gallery-rowbreak {
5793 + display: none;
5794 + }
5795 + .epyt-gallery-allthumbs[class*=\"epyt-cols\"] .epyt-gallery-thumb {
5796 + width: " . round(100.0 / intval($bpts['cols']), 3) . "% !important;
5797 + }
5798 + }";
5799 + }
5800 + }
5801 +
5802 + wp_add_inline_style('__EPYT__style', $custom_css);
5803 +
5804 + wp_enqueue_script('__ytprefs__', plugins_url('scripts/ytprefs' . self::$min . '.js', __FILE__), array('jquery'), self::$version);
5805 +
5806 + if (self::$alloptions[self::$opt_old_script_method] != 1)
5807 + {
5808 + $my_script_vars = array(
5809 + 'ajaxurl' => admin_url('admin-ajax.php'),
5810 + 'security' => wp_create_nonce('embedplus-nonce'),
5811 + 'gallery_scrolloffset' => intval(self::$alloptions[self::$opt_gallery_scrolloffset]),
5812 + 'eppathtoscripts' => plugins_url('scripts/', __FILE__),
5813 + 'eppath' => plugins_url('/', __FILE__),
5814 + 'epresponsiveselector' => self::get_responsiveselector(),
5815 + 'epdovol' => true,
5816 + 'version' => self::$alloptions[self::$opt_version],
5817 + 'evselector' => self::get_evselector(),
5818 + 'ajax_compat' => self::$alloptions[self::$opt_ajax_compat] == '1' ? true : false,
5819 + 'maxres_facade' => esc_attr(self::$alloptions[self::$opt_maxres_facade]),
5820 + 'ytapi_load' => self::$alloptions[self::$opt_ytapi_load],
5821 + 'pause_others' => self::$alloptions[self::$opt_pause_others] == '1' ? true : false,
5822 + 'stopMobileBuffer' => self::$alloptions[self::$opt_stop_mobile_buffer] == '1' ? true : false,
5823 + 'facade_mode' => self::$alloptions[self::$opt_facade_mode] == '1' ? true : false,
5824 + 'not_live_on_channel' => self::$alloptions[self::$opt_not_live_on_channel] == '1' ? true : false
5825 + );
5826 +
5827 + wp_localize_script('__ytprefs__', '_EPYT_', $my_script_vars);
5828 + }
5829 +
5830 + if ((bool) self::$alloptions[self::$opt_gdpr_consent])
5831 + {
5832 + wp_enqueue_script('__jquery_cookie__', plugins_url('scripts/jquery.cookie' . self::$min . '.js', __FILE__), array('jquery'), self::$version);
5833 + }
5834 +
5835 +
5836 + ////////////////////// cloudflare accomodation
5837 + //add_filter('script_loader_tag', array(self::class, 'set_cfasync'), 10, 3);
5838 + }
5839 + }
5840 +
5841 + public static function set_cfasync($tag, $handle, $src)
5842 + {
5843 + if ('__ytprefs__' !== $handle)
5844 + {
5845 + return $tag;
5846 + }
5847 + return str_replace('<script', '<script data-cfasync="false" ', $tag);
5848 + }
5849 +
5850 + public static function get_evselector()
5851 + {
5852 + $evselector = 'iframe.__youtube_prefs__[src], iframe[src*="youtube.com/embed/"], iframe[src*="youtube-nocookie.com/embed/"]';
5853 +
5854 + if (self::$alloptions[self::$opt_evselector_light] == 1)
5855 + {
5856 + $evselector = 'iframe.__youtube_prefs__[src]';
5857 + }
5858 +
5859 + return $evselector;
5860 + }
5861 +
5862 + public static function get_responsiveselector()
5863 + {
5864 + $responsiveselector = '[]';
5865 + if (self::$alloptions[self::$opt_widgetfit] == 1)
5866 + {
5867 + $responsiveselector = '["iframe.__youtube_prefs_widget__"]';
5868 + }
5869 + if (self::$alloptions[self::$opt_responsive] == 1)
5870 + {
5871 + if (self::$alloptions[self::$opt_responsive_all] == 1)
5872 + {
5873 + $responsiveselector = '["iframe.__youtube_prefs__","iframe[src*=\'youtube.com\']","iframe[src*=\'youtube-nocookie.com\']","iframe[data-ep-src*=\'youtube.com\']","iframe[data-ep-src*=\'youtube-nocookie.com\']","iframe[data-ep-gallerysrc*=\'youtube.com\']"]';
5874 + }
5875 + else
5876 + {
5877 + $responsiveselector = '["iframe.__youtube_prefs__"]';
5878 + }
5879 + }
5880 + return $responsiveselector;
5881 + }
5882 +
5883 + public static function admin_enqueue_scripts($hook)
5884 + {
5885 + if (in_array($hook, self::$admin_page_hooks))
5886 + {
5887 + wp_enqueue_style('__ytprefs_admin__alertify_css', plugins_url('styles/alertify/alertify' . self::$min . '.css', __FILE__), array(), self::$version);
5888 + wp_enqueue_style('__ytprefs_admin__alertify_theme_css', plugins_url('styles/alertify/themes/default' . self::$min . '.css', __FILE__), array(), self::$version);
5889 + wp_enqueue_script('__ytprefs_admin__alertify_js', plugins_url('scripts/alertify/alertify' . self::$min . '.js', __FILE__), array(), self::$version);
5890 + wp_enqueue_script('__ytprefs_admin__alertify_defaults_js', plugins_url('scripts/alertify/alertify-defaults' . self::$min . '.js', __FILE__), array(), self::$version);
5891 + }
5892 +
5893 + wp_enqueue_style('embedplusyoutube', plugins_url('scripts/embedplus_mce' . self::$min . '.css', __FILE__), array(), self::$version);
5894 + wp_enqueue_script('__ytprefs_admin__', plugins_url('scripts/ytprefs-admin' . self::$min . '.js', __FILE__), array('jquery', 'jquery-effects-fade'), self::$version, false);
5895 + $admin_script_vars = array(
5896 + 'wpajaxurl' => admin_url('admin-ajax.php'),
5897 + 'wizhref' => admin_url('admin.php?page=youtube-ep-wizard') . '&random=' . rand(1, 1000) . '&TB_iframe=true&width=950&height=800',
5898 + 'manage_options' => current_user_can('manage_options'),
5899 + 'security' => wp_create_nonce('embedplus-nonce'),
5900 + 'onboarded' => self::$alloptions[self::$opt_onboarded],
5901 + 'epbase' => self::$epbase,
5902 + 'admin_url' => admin_url(),
5903 + 'admin_url_ytprefs' => admin_url('admin.php?page=youtube-my-preferences'),
5904 + //'epblogwidth' => self::get_blogwidth(),
5905 + //'epprokey' => self::$alloptions[self::$opt_pro],
5906 + //'epbasesite' => self::$epbase,
5907 + //'epversion' => self::$version,
5908 + //'myytdefaults' => http_build_query(self::$alloptions),
5909 + //'eppluginadminurl' => admin_url('admin.php?page=youtube-my-preferences')
5910 + );
5911 + wp_localize_script('__ytprefs_admin__', '_EPYTA_', $admin_script_vars);
5912 +
5913 + if (function_exists('add_thickbox'))
5914 + {
5915 + add_thickbox();
5916 + }
5917 +
5918 +
5919 + if ((get_bloginfo('version') >= '3.3') && self::custom_admin_pointers_check())
5920 + {
5921 + add_action('admin_print_footer_scripts', array(self::class, 'custom_admin_pointers_footer'));
5922 + wp_enqueue_script('wp-pointer');
5923 + wp_enqueue_style('wp-pointer');
5924 + }
5925 +
5926 + if (self::$alloptions['glance'] == 1)
5927 + {
5928 + add_action('admin_print_footer_scripts', array(self::class, 'glance_script'));
5929 + }
5930 +
5931 + if ($hook == self::$wizard_hook)
5932 + {
5933 + wp_enqueue_style('__ytprefs_admin__wizard_ui', plugins_url('styles/jquery-ui' . self::$min . '.css', __FILE__), array(), self::$version);
5934 + wp_enqueue_style('__ytprefs_admin__wizard', plugins_url('styles/ytprefs-wizard' . self::$min . '.css', __FILE__), array(), self::$version);
5935 + wp_enqueue_script('__ytprefs_admin__wizard_script', plugins_url('scripts/ytprefs-wizard' . self::$min . '.js', __FILE__), array('jquery', 'jquery-ui-accordion', 'jquery-ui-tabs'), self::$version);
5936 + }
5937 +
5938 + if ($hook == self::$onboarding_hook)
5939 + {
5940 + wp_enqueue_style('__ytprefs_admin__onboarding_animate', plugins_url('scripts/embdyn' . self::$min . '.css', __FILE__), array(), self::$version);
5941 + wp_enqueue_style('__ytprefs_admin__onboarding_ui', plugins_url('styles/jquery-ui' . self::$min . '.css', __FILE__), array(), self::$version);
5942 + wp_enqueue_style('__ytprefs_admin__onboarding', plugins_url('styles/ytprefs-onboarding' . self::$min . '.css', __FILE__), array(), self::$version);
5943 + }
5944 + }
5945 +
5946 + public static function get_blogwidth()
5947 + {
5948 + $blogwidth = null;
5949 + try
5950 + {
5951 + $embed_size_w = intval(get_option('embed_size_w'));
5952 +
5953 + global $content_width;
5954 + if (empty($content_width))
5955 + {
5956 + $content_width = $GLOBALS['content_width'];
5957 + }
5958 +
5959 + $blogwidth = $embed_size_w ? $embed_size_w : ($content_width ? $content_width : 450);
5960 + }
5961 + catch (Exception $ex)
5962 + {
5963 +
5964 + }
5965 +
5966 + $blogwidth = preg_replace('/\D/', '', $blogwidth); //may have px
5967 +
5968 + return $blogwidth;
5969 + }
5970 +
5971 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5972 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5973 + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5974 +
5975 + private static function ajax_referer()
5976 + {
5977 + return check_ajax_referer('embedplus-nonce', 'security', false);
5978 + }
5979 +
5980 + public static function base_url()
5981 + {
5982 + $parsed = parse_url(site_url());
5983 + return $parsed['scheme'] . '://' . $parsed['host'];
5984 + }
5985 +
5986 + public static function on_deactivation()
5987 + {
5988 + }
5989 +
5990 + private static function update_option_set($new_options)
5991 + {
5992 + $all = get_option(self::$opt_alloptions);
5993 + $all = $new_options + $all;
5994 + update_option(self::$opt_alloptions, $all);
5995 + self::$alloptions = get_option(self::$opt_alloptions);
5996 + }
5997 +
5998 + public static function gb_block_assets()
5999 + {
6000 + // frontend+backend styles.
6001 + wp_enqueue_style('epytgb-style-css', plugins_url('dist/blocks.style.build.css', __FILE__), array('wp-blocks'), self::$version);
6002 + }
6003 +
6004 + public static function gb_editor_assets()
6005 + {
6006 + // backend styels
6007 + self::ytprefsscript();
6008 + self::fitvids();
6009 + if (!empty(self::$alloptions[self::$opt_not_live_on_channel]))
6010 + {
6011 + add_action("admin_print_footer_scripts", array(self::class, 'live_fallback_template'));
6012 + }
6013 +
6014 + if (!self::is_restrict_wizard() && current_user_can('edit_posts'))
6015 + {
6016 + // Scripts.
6017 + wp_enqueue_script(
6018 + 'epytgb-block-js', // Handle.
6019 + plugins_url('/dist/blocks.build.js', __FILE__), // Block.build.js: We register the block here. Built with Webpack.
6020 + array('wp-blocks', 'wp-i18n', 'wp-element'), // Dependencies, defined above.
6021 + self::$version, true // Enqueue the script in the footer.
6022 + );
6023 +
6024 + // Styles.
6025 + wp_enqueue_style(
6026 + 'epytgb-block-editor-css', // Handle.
6027 + plugins_url('dist/blocks.editor.build.css', __FILE__), // Block editor CSS.
6028 + array('wp-edit-blocks'), // Dependency to include the CSS after it.
6029 + self::$version
6030 + );
6031 +
6032 + // Tiny MCE
6033 + wp_enqueue_style('__ytprefs_admin__tinymce_css', plugins_url('styles/epyt_mce_wizard_button' . self::$min . '.css', __FILE__), array(), self::$version);
6034 + }
6035 + }
6036 +
6037 + public static function gb_classic_block_setup()
6038 + {
6039 + if (!self::is_restrict_wizard() && current_user_can('edit_posts'))
6040 + {
6041 + add_thickbox();
6042 + add_filter("mce_external_plugins", array(self::class, "gb_add_tinymce_plugin"));
6043 + add_filter('mce_buttons_2', array(self::class, 'gb_register_tinymce_button'));
6044 + }
6045 + }
6046 +
6047 + public static function gb_add_tinymce_plugin($plugin_array)
6048 + {
6049 + $plugin_array['epyt_mce_wizard_button'] = plugins_url('scripts/epyt_mce_wizard_button' . self::$min . '.js', __FILE__) . '?ver=' . self::$version;
6050 + return $plugin_array;
6051 + }
6052 +
6053 + public static function gb_register_tinymce_button($buttons)
6054 + {
6055 + array_push($buttons, "epyt_mce_wizard_button");
6056 + return $buttons;
6057 + }
6058 +
6059 + public static function gb_svg_defs()
6060 + {
6061 + ?>
6062 + <svg style="height: 0 !important; width: 0 !important; display: absolute !important; top: 0 !important; left: 0 !important;"><defs><style>.epytcls-1{fill:red;}.epytcls-2{fill-rule:evenodd;fill:url(#radial-gradient);}.epytcls-3{fill:#31aaff;}.epytcls-4{fill:#fff;}</style><radialGradient id="radial-gradient" cx="193" cy="85.85" r="77.53" gradientUnits="userSpaceOnUse"><stop offset="0.17" stop-color="#fff"/><stop offset="0.68" stop-color="#31aaff"/></radialGradient></defs></svg>
6063 + <?php
6064 + }
6065 +
6066 + public static function gb_canvas_svg_styles()
6067 + {
6068 + // The block editor canvas is an iframe, so the gradient and class rules that
6069 + // gb_svg_defs() prints into the admin document are out of scope for the icon
6070 + // rendered inside it. Restate them for the canvas only.
6071 + if (!is_admin())
6072 + {
6073 + return;
6074 + }
6075 +
6076 + wp_register_style('epytgb-canvas-svg-css', false, array(), self::$version);
6077 + wp_enqueue_style('epytgb-canvas-svg-css');
6078 + wp_add_inline_style('epytgb-canvas-svg-css', '.editor-styles-wrapper .epytcls-1{fill:red;}.editor-styles-wrapper .epytcls-2{fill-rule:evenodd;fill:#31aaff;}.editor-styles-wrapper .epytcls-3{fill:#31aaff;}.editor-styles-wrapper .epytcls-4{fill:#fff;}');
6079 + }
6080 +
6081 + public static function gb_register_block_types()
6082 + {
6083 + if (function_exists('register_block_type'))
6084 + {
6085 + register_block_type(
6086 + 'epyt/youtube', array(
6087 + 'attributes' => array(
6088 + 'shortcode' => array(
6089 + 'type' => 'string'
6090 + )
6091 + ),
6092 + 'render_callback' => array(self::class, 'gb_render_callback_youtube'),
6093 + )
6094 + );
6095 + }
6096 + }
6097 +
6098 + public static function gb_render_callback_youtube($attributes, $content)
6099 + {
6100 + if ($attributes && $attributes['shortcode'] && strpos($attributes['shortcode'], '[') === 0)
6101 + {
6102 + $render = do_shortcode($attributes['shortcode']);
6103 + if (empty($render) && stripos($attributes['shortcode'], 'live=1') !== false)
6104 + {
6105 + $render = '<em>This is a live embed that is not currently streaming. You can optionally fill out the <a href="' . admin_url('admin.php?page=youtube-my-preferences') . '#not_live_content_scroll" target="_blank">Not Live Content</a> field in the YouTube plugin\'s Default Settings.</em>';
6106 + }
6107 + return $render;
6108 + }
6109 + return isset($attributes['shortcode']) ? $attributes['shortcode'] : '';
6110 + }
6111 +
6112 +}
6113 +
6114 +// constants
6115 +define('EPYT_BASE_URL', rtrim(plugins_url('', __FILE__), "\\/") . '/');
6116 +define('EPYTGB_INCLUDES_PATH', rtrim(dirname(__FILE__), "\\/") . '/includes/gutenberg/');
6117 +
6118 +$youtubeplgplus = new YouTubePrefs();
6119 +
6120 +
6121 +
6122 +