PluginProbe
Embed Plus for YouTube Gallery, Livestream and Lazy Loading with Facades / 11.2
Embed Plus for YouTube Gallery, Livestream and Lazy Loading with Facades v11.2
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
youtube-embed-plus / youtube.php

youtube.php in Embed Plus for YouTube Gallery, Livestream and Lazy Loading with Facades 11.2, at youtube.php

4,340 lines 231.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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. Embed a responsive YouTube video, playlist gallery, or channel gallery. Add video thumbnails, analytics, SEO, caching...
6 Version: 11.2
7 Author: EmbedPlus Team
8 Author URI: http://www.embedplus.com
9 */
10
11 /*
12 YouTube
13 Copyright (C) 2016 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 = '11.2';
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_debugmode = 'debugmode';
46 public static $opt_old_script_method = 'old_script_method';
47 public static $opt_cc_load_policy = 'cc_load_policy';
48 public static $opt_iv_load_policy = 'iv_load_policy';
49 public static $opt_loop = 'loop';
50 public static $opt_modestbranding = 'modestbranding';
51 public static $opt_rel = 'rel';
52 public static $opt_showinfo = 'showinfo';
53 public static $opt_playsinline = 'playsinline';
54 public static $opt_autohide = 'autohide';
55 public static $opt_controls = 'controls';
56 public static $opt_theme = 'theme';
57 public static $opt_color = 'color';
58 public static $opt_listType = 'listType';
59 public static $opt_wmode = 'wmode';
60 public static $opt_vq = 'vq';
61 public static $opt_html5 = 'html5';
62 public static $opt_dohl = 'dohl';
63 public static $opt_hl = 'hl';
64 public static $opt_ssl = 'ssl';
65 public static $opt_ogvideo = 'ogvideo';
66 public static $opt_nocookie = 'nocookie';
67 public static $opt_playlistorder = 'playlistorder';
68 public static $opt_acctitle = 'acctitle';
69 public static $opt_pro = 'pro';
70 public static $opt_oldspacing = 'oldspacing';
71 public static $opt_responsive = 'responsive';
72 public static $opt_responsive_all = 'responsive_all';
73 public static $opt_origin = 'origin';
74 public static $opt_widgetfit = 'widgetfit';
75 public static $opt_evselector_light = 'evselector_light';
76 public static $opt_defaultdims = 'defaultdims';
77 public static $opt_defaultwidth = 'width';
78 public static $opt_defaultheight = 'height';
79 public static $opt_defaultvol = 'defaultvol';
80 public static $opt_vol = 'vol';
81 public static $opt_apikey = 'apikey';
82 public static $opt_schemaorg = 'schemaorg';
83 public static $opt_ftpostimg = 'ftpostimg';
84 public static $opt_spdc = 'spdc';
85 public static $opt_spdcexp = 'spdcexp';
86 public static $opt_migrate = 'migrate';
87 public static $opt_migrate_youtube = 'migrate_youtube';
88 public static $spdcprefix = 'ytpref';
89 public static $spdcall = 'youtubeprefs_spdcall';
90 public static $opt_dynload = 'dynload';
91 public static $opt_dyntype = 'dyntype';
92 public static $opt_gallery_pagesize = 'gallery_pagesize';
93 public static $opt_gallery_apikey = 'gallery_apikey';
94 public static $opt_gallery_columns = 'gallery_columns';
95 public static $opt_gallery_style = 'gallery_style';
96 public static $opt_gallery_scrolloffset = 'gallery_scrolloffset';
97 public static $opt_gallery_showtitle = 'gallery_showtitle';
98 public static $opt_gallery_showpaging = 'gallery_showpaging';
99 public static $opt_gallery_thumbplay = 'gallery_thumbplay';
100 public static $opt_gallery_autonext = 'gallery_autonext';
101 public static $opt_gallery_channelsub = 'gallery_channelsub';
102 public static $opt_gallery_channelsublink = 'gallery_channelsublink';
103 public static $opt_gallery_channelsubtext = 'gallery_channelsubtext';
104 public static $opt_gallery_customarrows = 'gallery_customarrows';
105 public static $opt_gallery_customprev = 'gallery_customprev';
106 public static $opt_gallery_customnext = 'gallery_customnext';
107 public static $opt_gallery_showdsc = 'gallery_showdsc';
108 public static $opt_gallery_thumbcrop = 'gallery_thumbcrop';
109 public static $opt_admin_off_scripts = 'admin_off_scripts';
110 public static $opt_alloptions = 'youtubeprefs_alloptions';
111 public static $alloptions = null;
112 public static $yt_options = array();
113 //public static $epbase = 'http://localhost:2346';
114 public static $epbase = '//www.embedplus.com';
115 public static $double_plugin = false;
116 public static $scriptsprinted = 0;
117 public static $min = '.min';
118 public static $badentities = array('&#215;', '×', '&#8211;', '–', '&amp;', '&#038;', '&#38;');
119 public static $goodliterals = array('x', 'x', '--', '--', '&', '&', '&');
120 ///////////////////////////////////////////////////////////////////////////////////////////////////
121 ///////////////////////////////////////////////////////////////////////////////////////////////////
122 ///////////////////////////////////////////////////////////////////////////////////////////////////
123 ///////////////////////////////////////////////////////////////////////////////////////////////////
124 ///////////////////////////////////////////////////////////////////////////////////////////////////
125 //public static $ytregex = '@^[\r\n]{0,1}[[:blank:]]*https?://(?:www\.)?(?:(?:youtube.com/watch\?)|(?:youtu.be/))([^\s"]+)[[:blank:]]*[\r\n]{0,1}$@im';
126 public static $oldytregex = '@^\s*https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))/{0,1}\?)|(?:youtu.be/))([^\s"]+)\s*$@im';
127 public static $ytregex = '@^[\r\t ]*https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))/{0,1}\?)|(?:youtu.be/))([^\s"]+)[\r\t ]*$@im';
128 public static $justurlregex = '@https?://(?:www\.)?(?:(?:youtube.com/(?:(?:watch)|(?:embed)|(?:playlist))/{0,1}\?)|(?:youtu.be/))([^\[\s"]+)@i';
129
130 ///////////////////////////////////////////////////////////////////////////////////////////////////
131 ///////////////////////////////////////////////////////////////////////////////////////////////////
132 ///////////////////////////////////////////////////////////////////////////////////////////////////
133 ///////////////////////////////////////////////////////////////////////////////////////////////////
134 ///////////////////////////////////////////////////////////////////////////////////////////////////
135 ///////////////////////////////////////////////////////////////////////////////////////////////////
136
137 public function __construct()
138 {
139
140 add_action('admin_init', array("YouTubePrefs", 'check_double_plugin_warning'));
141
142 self::$alloptions = get_option(self::$opt_alloptions);
143 if (self::$alloptions == false || version_compare(self::$alloptions[self::$opt_version], self::$version, '<'))
144 {
145 self::initoptions();
146 }
147
148 if (self::$alloptions[self::$opt_oldspacing] == 1)
149 {
150 self::$ytregex = self::$oldytregex;
151 }
152
153 self::$optembedwidth = intval(get_option('embed_size_w'));
154 self::$optembedheight = intval(get_option('embed_size_h'));
155
156 self::$yt_options = array(
157 self::$opt_autoplay,
158 self::$opt_cc_load_policy,
159 self::$opt_iv_load_policy,
160 self::$opt_loop,
161 self::$opt_modestbranding,
162 self::$opt_rel,
163 self::$opt_showinfo,
164 self::$opt_playsinline,
165 self::$opt_autohide,
166 self::$opt_controls,
167 self::$opt_html5,
168 self::$opt_hl,
169 self::$opt_theme,
170 self::$opt_color,
171 self::$opt_listType,
172 self::$opt_wmode,
173 self::$opt_vq,
174 'index',
175 'list',
176 'start',
177 'end'
178 );
179
180 add_action('media_buttons', 'YouTubePrefs::media_button_wizard', 11);
181
182
183 self::do_ytprefs();
184 add_action('admin_menu', 'YouTubePrefs::ytprefs_plugin_menu');
185
186 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 8)
187 {
188 add_action('admin_bar_menu', 'YouTubePrefs::ytprefs_admin_bar', 100);
189 add_action('wp_enqueue_scripts', array('YouTubePrefs', 'ytprefs_admin_bar_scripts'));
190 add_action('admin_enqueue_scripts', array('YouTubePrefs', 'ytprefs_admin_bar_scripts'));
191 }
192
193
194 if (!is_admin())
195 {
196
197
198 if (self::$alloptions[self::$opt_old_script_method] == 1)
199 {
200 add_action('wp_print_scripts', array('YouTubePrefs', 'jsvars'));
201 add_action('wp_enqueue_scripts', array('YouTubePrefs', 'jsvars'));
202 }
203
204 add_action('wp_enqueue_scripts', array('YouTubePrefs', 'ytprefsscript'), 100);
205 add_action('wp_enqueue_scripts', array('YouTubePrefs', 'fitvids'), 101);
206
207
208
209 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_ogvideo] == 1)
210 {
211 add_action('wp_head', array('YouTubePrefs', 'do_ogvideo'));
212 }
213 }
214
215 if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG)
216 {
217 self::$min = '';
218 }
219 }
220
221 public static function ytprefs_admin_bar_scripts()
222 {
223 if (current_user_can('edit_posts'))
224 {
225 wp_enqueue_script('__ytprefs__bar', plugins_url('scripts/ytprefs-bar' . self::$min . '.js', __FILE__), array('jquery'));
226 wp_localize_script('__ytprefs__bar', '_EPYTA_', array(
227 'ajaxurl' => admin_url('admin-ajax.php'),
228 'security' => wp_create_nonce('embedplus-nonce'),
229 'pluginurl' => plugins_url('/', __FILE__)
230 ));
231 }
232 }
233
234 public static function ytprefs_admin_bar($wp_admin_bar)
235 {
236 $args = array(
237 'id' => 'ytprefs-bar-cache',
238 'title' => 'Clear YouTube Cache',
239 'href' => '#',
240 'meta' => array(
241 'class' => ''
242 )
243 );
244 $wp_admin_bar->add_node($args);
245 }
246
247 public static function show_glance_list()
248 {
249 $glancehref = self::show_glance();
250 $cnt = self::get_glance_count();
251
252 //display via list
253 return
254 '<li class="page-count">
255 <a href="' . $glancehref . '" class="thickbox ytprefs_glance_button" id="ytprefs_glance_button" title="YouTube Embeds At a Glance">
256 ' . number_format_i18n($cnt) . ' With YouTube
257 </a>
258 </li>';
259 }
260
261 public static function show_glance_table()
262 {
263 $glancehref = self::show_glance();
264 $cnt = self::get_glance_count();
265 return
266 '<tr>
267 <td class="first b"><a title="YouTube Embeds At a Glance" href="' . $glancehref . '" class="thickbox ytprefs_glance_button">' . number_format_i18n($cnt) . '</a></td>
268 <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>
269 </tr>';
270 }
271
272 public static function get_glance_count()
273 {
274 global $wpdb;
275 $query_sql = "
276 SELECT count(*) as mytotal
277 FROM $wpdb->posts
278 WHERE (post_content LIKE '%youtube.com/%' OR post_content LIKE '%youtu.be/%')
279 AND post_status = 'publish'";
280
281 $query_result = $wpdb->get_results($query_sql, OBJECT);
282
283 return intval($query_result[0]->mytotal);
284 }
285
286 public static function show_glance()
287 {
288 $glancehref = admin_url('admin.php?page=youtube-ep-glance') . '&random=' . rand(1, 1000) . '&TB_iframe=true&width=780&height=800';
289 return $glancehref;
290 }
291
292 public static function glance_page()
293 {
294 ?>
295 <div class="wrap">
296 <style type="text/css">
297 #wphead {display:none;}
298 #wpbody{margin-left: 0px;}
299 .wrap {font-family: Arial; padding: 0px 10px 0px 10px; line-height: 180%;}
300 .bold {font-weight: bold;}
301 .orange {color: #f85d00;}
302 #adminmenuback {display: none;}
303 #adminmenu, adminmenuwrap {display: none;}
304 #wpcontent, .auto-fold #wpcontent {margin-left: 0px;}
305 #wpadminbar {display:none;}
306 html.wp-toolbar {padding: 0px;}
307 #footer, #wpfooter, .auto-fold #wpfooter {display: none;}
308 #wpfooter {clear: both}
309 .acctitle {background-color: #dddddd; border-radius: 5px; padding: 7px 15px 7px 15px; cursor: pointer; margin: 10px; font-weight: bold; font-size: 12px;}
310 .acctitle:hover {background-color: #cccccc;}
311 .accbox {display: none; position: relative; margin: 5px 8px 30px 15px; clear: both; line-height: 180%;}
312 .accclose {position: absolute; top: -38px; right: 5px; cursor: pointer; width: 24px; height: 24px;}
313 .accloader {padding-right: 20px;}
314 .accthumb {display: block; width: 300px; float: left; margin-right: 25px;}
315 .accinfo {width: 300px; float: left;}
316 .accvidtitle {font-weight: bold; font-size: 16px;}
317 .accthumb img {width: 300px; height: auto; display: block;}
318 .clearboth {clear: both;}
319 .pad20 {padding: 20px;}
320 .center {text-align: center;}
321 </style>
322 <script type="text/javascript">
323 function accclose(ele)
324 {
325 jQuery(ele).parent('.accbox').hide(400);
326 }
327
328 (function ($j)
329 {
330 $j(document).ready(function () {
331
332
333 $j('.acctitle').click(function () {
334 var $acctitle = $j(this);
335 var $accbox = $j(this).parent().children('.accbox');
336 var pid = $accbox.attr("data-postid");
337
338 $acctitle.prepend('<img class="accloader" src="<?php echo plugins_url('images/ajax-loader.gif', __FILE__) ?>" />');
339 jQuery.ajax({
340 type: "post",
341 dataType: "json",
342 timeout: 30000,
343 url: wpajaxurl,
344 data: {action: 'my_embedplus_glance_vids', postid: pid},
345 success: function (response) {
346 if (response.type == "success") {
347 $accbox.html(response.data),
348 $accbox.show(400);
349 }
350 else {
351 }
352 },
353 error: function (xhr, ajaxOptions, thrownError) {
354
355 },
356 complete: function () {
357 $acctitle.children('.accloader').remove();
358 }
359
360 });
361
362
363 });
364 });
365 })(jQuery);
366
367
368 </script>
369 <?php
370 global $wpdb;
371 $query_sql = "
372 SELECT SQL_CALC_FOUND_ROWS *
373 FROM $wpdb->posts
374 WHERE (post_content LIKE '%youtube.com/%' OR post_content LIKE '%youtu.be/%')
375 AND post_status = 'publish'
376 order by post_date DESC LIMIT 0, 10";
377
378 $query_result = $wpdb->get_results($query_sql, OBJECT);
379
380 if ($query_result !== null)
381 {
382 $total = $wpdb->get_var("SELECT FOUND_ROWS();");
383 global $post;
384 echo '<h2><img src="' . plugins_url('images/youtubeicon16.png', __FILE__) . '" /> 10 Latest Posts/Pages with YouTube Videos (' . $total . ' Total)</h2>';
385 ?>
386
387 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.
388
389 <?php
390 if ($total > 0)
391 {
392 echo '<ul class="accord">';
393 foreach ($query_result as $post)
394 {
395 echo '<li>';
396 setup_postdata($post);
397 the_title('<div class="acctitle">', ' &raquo;</div>');
398 echo '<div class="accbox" data-postid="' . $post->ID . '"></div><div class="clearboth"></div></li>';
399 }
400 echo '</ul>';
401 }
402 else
403 {
404 echo '<p class="center bold orange">You currently do not have any YouTube embeds yet.</p>';
405 }
406 }
407
408 wp_reset_postdata();
409 ?>
410 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>.
411
412 </div>
413 <?php
414 }
415
416 public static function my_embedplus_glance_vids()
417 {
418 $result = array();
419 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
420 {
421 $postid = intval($_REQUEST['postid']);
422 $currpost = get_post($postid);
423
424 $thehtml = '<img class="accclose" onclick="accclose(this)" src="' . plugins_url('images/accclose.png', __FILE__) . '" />';
425
426 $matches = Array();
427 $ismatch = preg_match_all(self::$justurlregex, $currpost->post_content, $matches);
428
429 if ($ismatch)
430 {
431 foreach ($matches[0] as $match)
432 {
433 $link = trim(preg_replace('/&amp;/i', '&', $match));
434 $link = preg_replace('/\s/', '', $link);
435 $link = trim(str_replace(self::$badentities, self::$goodliterals, $link));
436
437 $linkparamstemp = explode('?', $link);
438
439 $linkparams = array();
440 if (count($linkparamstemp) > 1)
441 {
442 $linkparams = self::keyvalue($linkparamstemp[1], true);
443 }
444 if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
445 {
446 $vtemp = explode('/', $linkparamstemp[0]);
447 $linkparams['v'] = array_pop($vtemp);
448 }
449
450 $vidid = $linkparams['v'];
451
452 if ($vidid != null)
453 {
454 try
455 {
456 $odata = self::get_oembed('https://youtube.com/watch?v=' . $vidid, 1920, 1280);
457 $postlink = get_permalink($postid);
458 if ($odata != null && !is_wp_error($odata))
459 {
460 $_name = esc_attr(sanitize_text_field($odata->title));
461 $_description = esc_attr(sanitize_text_field($odata->author_name));
462 $_thumbnailUrl = esc_url("https://i.ytimg.com/vi/" . $vidid . "/0.jpg");
463
464 $thehtml .= '<a target="_blank" href="' . $postlink . '" class="accthumb"><img src="' . $_thumbnailUrl . '" /></a>';
465 $thehtml .= '<div class="accinfo">';
466 $thehtml .= '<a target="_blank" href="' . $postlink . '" class="accvidtitle">' . $_name . '</a>';
467 $thehtml .= '<div class="accdesc">' . (strlen($_description) > 400 ? substr($_description, 0, 400) . "..." : $_description) . '</div>';
468 $thehtml .= '</div>';
469 $thehtml .= '<div class="clearboth pad20"></div>';
470 }
471 else
472 {
473 $thehtml .= '<p class="center bold orange">This <a target="_blank" href="' . $postlink . '">post/page</a> contains a video that has been removed from YouTube.';
474
475 if (!(self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0))
476 {
477 $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>';
478 }
479 $thehtml .= '</strong>';
480 }
481 }
482 catch (Exception $ex)
483 {
484
485 }
486 }
487 else if (isset($linkparams['list']))
488 {
489 // if playlist
490 try
491 {
492 $odata = self::get_oembed('https://youtube.com/playlist?list=' . $linkparams['list'], 1920, 1280);
493 $postlink = get_permalink($postid);
494 if ($odata != null && !is_wp_error($odata))
495 {
496 $_name = esc_attr(sanitize_text_field($odata->title));
497 $_description = esc_attr(sanitize_text_field($odata->author_name));
498 $_thumbnailUrl = esc_url($odata->thumbnail_url);
499
500 $thehtml .= '<a target="_blank" href="' . $postlink . '" class="accthumb"><img src="' . $_thumbnailUrl . '" /></a>';
501 $thehtml .= '<div class="accinfo">';
502 $thehtml .= '<a target="_blank" href="' . $postlink . '" class="accvidtitle">' . $_name . '</a>';
503 $thehtml .= '<div class="accdesc">' . (strlen($_description) > 400 ? substr($_description, 0, 400) . "..." : $_description) . '</div>';
504 $thehtml .= '</div>';
505 $thehtml .= '<div class="clearboth pad20"></div>';
506 }
507 else
508 {
509 $thehtml .= '<p class="center bold orange">This <a target="_blank" href="' . $postlink . '">post/page</a> contains a video that has been removed from YouTube.';
510
511 if (!(self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0))
512 {
513 $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>';
514 }
515 $thehtml .= '</strong>';
516 }
517 }
518 catch (Exception $ex)
519 {
520
521 }
522 }
523 }
524 }
525
526
527
528 if ($currpost != null)
529 {
530 $result['type'] = 'success';
531 $result['data'] = $thehtml;
532 }
533 else
534 {
535 $result['type'] = 'error';
536 }
537 echo json_encode($result);
538 }
539 else
540 {
541 $result['type'] = 'error';
542 header("Location: " . $_SERVER["HTTP_REFERER"]);
543 }
544 die();
545 }
546
547 public static function my_embedplus_glance_count()
548 {
549 $result = array();
550 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
551 {
552 $thehtml = '';
553
554 try
555 {
556 if (version_compare(get_bloginfo('version'), '3.8', '>='))
557 {
558 $result['container'] = '#dashboard_right_now ul';
559 $thehtml .= self::show_glance_list();
560 }
561 else
562 {
563 $result['container'] = '#dashboard_right_now .table_content table tbody';
564 $thehtml .= self::show_glance_table();
565 }
566 $result['type'] = 'success';
567 $result['data'] = $thehtml;
568 }
569 catch (Exception $e)
570 {
571 $result['type'] = 'error';
572 }
573
574 echo json_encode($result);
575 }
576 else
577 {
578 $result['type'] = 'error';
579 header("Location: " . $_SERVER["HTTP_REFERER"]);
580 }
581 die();
582 }
583
584 public static function media_button_wizard()
585 {
586 add_thickbox();
587
588 $wizhref = self::$epbase . '/wpembedcode-simple-search-' . YouTubePrefs::$version . '.aspx?pluginversion=' . YouTubePrefs::$version .
589 '&wpversion=' . get_bloginfo('version') .
590 '&settingsurl=' . urlencode(admin_url('admin.php?page=youtube-my-preferences#jumpdefaults')) .
591 '&dashurl=' . urlencode(admin_url('admin.php?page=youtube-ep-analytics-dashboard')) .
592 '&blogwidth=' . YouTubePrefs::get_blogwidth() .
593 '&domain=' . urlencode(site_url()) .
594 '&prokey=' . urlencode(YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro]) .
595 '&myytdefaults=' . urlencode(http_build_query(YouTubePrefs::$alloptions)) .
596 '&random=' . rand(1, 1000) .
597 '&TB_iframe=true&width=950&height=800';
598 ?>
599 <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>
600 <?php
601 }
602
603 public static function check_double_plugin_warning()
604 {
605 if (is_plugin_active('embedplus-for-wordpress/embedplus.php'))
606 {
607 add_action('admin_notices', array("YouTubePrefs", "double_plugin_warning"));
608 //self::$double_plugin = true;
609 }
610 }
611
612 public static function double_plugin_warning()
613 {
614 global $pagenow;
615 $user_id = get_current_user_id();
616 if ($pagenow != 'plugins.php' || get_user_meta($user_id, 'embedplus_double_plugin_warning', true) != 1)
617 {
618 //echo '<div class="error">' . $_SERVER['QUERY_STRING'] .'</div>';
619 if ($pagenow == 'plugins.php' || strpos($_SERVER['QUERY_STRING'], 'youtube-my-preferences') !== false ||
620 strpos($_SERVER['QUERY_STRING'], 'embedplus-video-analytics-dashboard') !== false ||
621 strpos($_SERVER['QUERY_STRING'], 'youtube-ep-analytics-dashboard') !== false ||
622 strpos($_SERVER['QUERY_STRING'], 'embedplus-official-options') !== false)
623 {
624 ?>
625 <style type="text/css">
626 .embedpluswarning img
627 {
628 vertical-align: text-bottom;
629 }
630 div.bgyellow {background-color: #FCFC94; position: relative;}
631 a.epxout, a.epxout:hover {font-weight: bold; color: #ffffff; background-color: #ff8888; text-decoration: none;
632 border-radius: 20px; font-size: 15px; position: absolute; top: 3px; right: 3px;
633 line-height: 20px; text-align: center; width: 20px; height: 20px; display: block; cursor: pointer;}
634 </style>
635 <div class="error bgyellow embedpluswarningbox">
636 <p class="embedpluswarning">
637 <?php
638 if ($pagenow == 'plugins.php')
639 {
640 echo '<a class="epxout">&times;</a>';
641 }
642 ?>
643 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>
644 </div>
645 <iframe allowTransparency="true" src="<?php echo self::$epbase . '/both-plugins-conflict.aspx' ?>" style="width:2px; height: 2px;" ></iframe>
646 <script type="text/javascript">
647 (function ($) {
648 $(document).ready(function () {
649 $('.epxout').click(function () {
650 $.ajax({
651 type: "post",
652 dataType: "json",
653 timeout: 30000,
654 url: wpajaxurl,
655 data: {action: 'my_embedplus_dismiss_double_plugin_warning'},
656 success: function (response) {
657 if (response.type == "success") {
658 $(".embedpluswarningbox").hide();
659 }
660 },
661 error: function (xhr, ajaxOptions, thrownError) {
662 },
663 complete: function () {
664 }
665 });
666 });
667
668 });
669 })(jQuery);
670 </script>
671 <?php
672 }
673 }
674 }
675
676 public static function my_embedplus_dismiss_double_plugin_warning()
677 {
678 $result = array();
679 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
680 {
681 $user_id = get_current_user_id();
682 update_user_meta($user_id, 'embedplus_double_plugin_warning', 1);
683 $result['type'] = 'success';
684 echo json_encode($result);
685 }
686 else
687 {
688 $result['type'] = 'error';
689 header("Location: " . $_SERVER["HTTP_REFERER"]);
690 }
691 die();
692 }
693
694 public static function jsvars()
695 {
696 $loggedin = current_user_can('edit_posts');
697 if (!($loggedin && self::$alloptions[self::$opt_admin_off_scripts]))
698 {
699 ?>
700 <script data-cfasync="false">
701 window._EPYT_ = window._EPYT_ || {
702 ajaxurl: "<?php echo admin_url('admin-ajax.php'); ?>",
703 security: "<?php echo wp_create_nonce('embedplus-nonce'); ?>",
704 gallery_scrolloffset: <?php echo intval(self::$alloptions[self::$opt_gallery_scrolloffset]) ?>,
705 eppathtoscripts: "<?php echo plugins_url('scripts/', __FILE__); ?>",
706 epresponsiveselector: <?php echo self::get_responsiveselector(); ?>,
707 version: "<?php echo self::$alloptions[self::$opt_version] ?>",
708 epdovol: true,
709 evselector: '<?php echo self::get_evselector(); ?>'
710 };
711 </script>
712 <?php
713 }
714 }
715
716 public static function fitvids()
717 {
718 $loggedin = current_user_can('edit_posts');
719 if (!($loggedin && self::$alloptions[self::$opt_admin_off_scripts]))
720 {
721 wp_enqueue_script('__ytprefsfitvids__', plugins_url('scripts/fitvids' . self::$min . '.js', __FILE__), array('__ytprefs__'), false, true);
722 }
723 }
724
725 public static function initoptions()
726 {
727 //vanilla defaults
728 $_center = 0;
729 $_glance = 1;
730 $_autoplay = get_option('youtubeprefs_autoplay', 0);
731 $_cc_load_policy = get_option('youtubeprefs_cc_load_policy', 0);
732 $_iv_load_policy = get_option('youtubeprefs_iv_load_policy', 1);
733 $_loop = get_option('youtubeprefs_loop', 0);
734 $_modestbranding = get_option('youtubeprefs_modestbranding', 0);
735 $_rel = get_option('youtubeprefs_rel', 1);
736 $_showinfo = get_option('youtubeprefs_showinfo', 1);
737 $_html5 = get_option('youtubeprefs_html5', 0);
738 $_theme = get_option('youtubeprefs_theme', 'dark');
739 $_color = get_option('youtubeprefs_color', 'red');
740 $_vq = get_option('youtubeprefs_vq', '');
741 $_autohide = 2;
742 $_pro = '';
743 $_ssl = 0;
744 $_nocookie = 0;
745 $_playlistorder = 0;
746 $_acctitle = 0;
747 $_ogvideo = 0;
748 $_migrate = 0;
749 $_migrate_youtube = 0;
750 $_controls = 2;
751 $_oldspacing = 1;
752 $_responsive = 0;
753 $_responsive_all = 1;
754 $_widgetfit = 1;
755 $_evselector_light = 0;
756 $_schemaorg = 0;
757 $_ftpostimg = 0;
758 $_spdc = 0;
759 $_spdcexp = 24;
760 $_dynload = 0;
761 $_dyntype = '';
762 $_wmode = 'opaque';
763 $_defaultdims = 0;
764 $_defaultwidth = '';
765 $_defaultheight = '';
766 $_playsinline = 0;
767 $_origin = 0;
768 $_defaultvol = 0;
769 $_vol = '';
770 $_apikey = '';
771 $_hl = '';
772 $_dohl = 0;
773 $_gallery_columns = 3;
774 $_gallery_scrolloffset = 20;
775 $_gallery_showtitle = 1;
776 $_gallery_showpaging = 1;
777 $_gallery_autonext = 0;
778 $_gallery_thumbplay = 1;
779 $_gallery_channelsub = 0;
780 $_gallery_channelsublink = '';
781 $_gallery_channelsubtext = 'Subscribe to my channel';
782 $_gallery_customarrows = 0;
783 $_gallery_customprev = 'Prev';
784 $_gallery_customnext = 'Next';
785 $_gallery_pagesize = 15;
786 $_gallery_style = 'grid';
787 $_gallery_showdsc = 0;
788 $_gallery_thumbcrop = 'box';
789 $_debugmode = 0;
790 $_admin_off_scripts = 0;
791 $_old_script_method = 0;
792
793 $arroptions = get_option(self::$opt_alloptions);
794
795 //update vanilla to previous settings if exists
796 if ($arroptions !== false)
797 {
798 $_center = self::tryget($arroptions, self::$opt_center, 0);
799 $_glance = self::tryget($arroptions, self::$opt_glance, 1);
800 $_autoplay = self::tryget($arroptions, self::$opt_autoplay, 0);
801 $_debugmode = self::tryget($arroptions, self::$opt_debugmode, 0);
802 $_old_script_method = self::tryget($arroptions, self::$opt_old_script_method, 0);
803 $_cc_load_policy = self::tryget($arroptions, self::$opt_cc_load_policy, 0);
804 $_iv_load_policy = self::tryget($arroptions, self::$opt_iv_load_policy, 1);
805 $_loop = self::tryget($arroptions, self::$opt_loop, 0);
806 $_modestbranding = self::tryget($arroptions, self::$opt_modestbranding, 0);
807 $_rel = self::tryget($arroptions, self::$opt_rel, 1);
808 $_showinfo = self::tryget($arroptions, self::$opt_showinfo, 1);
809 $_playsinline = self::tryget($arroptions, self::$opt_playsinline, 0);
810 $_origin = self::tryget($arroptions, self::$opt_origin, 0);
811 $_html5 = self::tryget($arroptions, self::$opt_html5, 0);
812 $_hl = self::tryget($arroptions, self::$opt_hl, '');
813 $_dohl = self::tryget($arroptions, self::$opt_dohl, 0);
814 $_theme = self::tryget($arroptions, self::$opt_theme, 'dark');
815 $_color = self::tryget($arroptions, self::$opt_color, 'red');
816 $_wmode = self::tryget($arroptions, self::$opt_wmode, 'opaque');
817 $_vq = self::tryget($arroptions, self::$opt_vq, '');
818 $_pro = self::tryget($arroptions, self::$opt_pro, '');
819 $_ssl = self::tryget($arroptions, self::$opt_ssl, 0);
820 $_nocookie = self::tryget($arroptions, self::$opt_nocookie, 0);
821 $_playlistorder = self::tryget($arroptions, self::$opt_playlistorder, 0);
822 $_acctitle = self::tryget($arroptions, self::$opt_acctitle, 0);
823 $_ogvideo = self::tryget($arroptions, self::$opt_ogvideo, 0);
824 $_migrate = self::tryget($arroptions, self::$opt_migrate, 0);
825 $_migrate_youtube = self::tryget($arroptions, self::$opt_migrate_youtube, 0);
826 $_controls = self::tryget($arroptions, self::$opt_controls, 2);
827 $_autohide = self::tryget($arroptions, self::$opt_autohide, 2);
828 $_oldspacing = self::tryget($arroptions, self::$opt_oldspacing, 1);
829 $_responsive = self::tryget($arroptions, self::$opt_responsive, 0);
830 $_responsive_all = self::tryget($arroptions, self::$opt_responsive_all, 1);
831 $_widgetfit = self::tryget($arroptions, self::$opt_widgetfit, 1);
832 $_evselector_light = self::tryget($arroptions, self::$opt_evselector_light, 0);
833 $_schemaorg = self::tryget($arroptions, self::$opt_schemaorg, 0);
834 $_ftpostimg = self::tryget($arroptions, self::$opt_ftpostimg, 0);
835 $_spdc = self::tryget($arroptions, self::$opt_spdc, 0);
836 $_spdcexp = self::tryget($arroptions, self::$opt_spdcexp, 24);
837 $_dynload = self::tryget($arroptions, self::$opt_dynload, 0);
838 $_dyntype = self::tryget($arroptions, self::$opt_dyntype, '');
839 $_defaultdims = self::tryget($arroptions, self::$opt_defaultdims, 0);
840 $_defaultwidth = self::tryget($arroptions, self::$opt_defaultwidth, '');
841 $_defaultheight = self::tryget($arroptions, self::$opt_defaultheight, '');
842 $_defaultvol = self::tryget($arroptions, self::$opt_defaultvol, 0);
843 $_vol = self::tryget($arroptions, self::$opt_vol, '');
844 $_apikey = self::tryget($arroptions, self::$opt_apikey, '');
845 $_gallery_pagesize = self::tryget($arroptions, self::$opt_gallery_pagesize, 15);
846 $_gallery_columns = self::tryget($arroptions, self::$opt_gallery_columns, 3);
847 $_gallery_scrolloffset = self::tryget($arroptions, self::$opt_gallery_scrolloffset, 20);
848 $_gallery_showtitle = self::tryget($arroptions, self::$opt_gallery_showtitle, 1);
849 $_gallery_showpaging = self::tryget($arroptions, self::$opt_gallery_showpaging, 1);
850 $_gallery_autonext = self::tryget($arroptions, self::$opt_gallery_autonext, 0);
851 $_gallery_thumbplay = self::tryget($arroptions, self::$opt_gallery_thumbplay, 1);
852 $_gallery_style = self::tryget($arroptions, self::$opt_gallery_style, 'grid');
853 $_gallery_thumbcrop = self::tryget($arroptions, self::$opt_gallery_thumbcrop, 'box');
854 $_gallery_channelsub = self::tryget($arroptions, self::$opt_gallery_channelsub, $_gallery_channelsub);
855 $_gallery_channelsublink = self::tryget($arroptions, self::$opt_gallery_channelsublink, $_gallery_channelsublink);
856 $_gallery_channelsubtext = self::tryget($arroptions, self::$opt_gallery_channelsubtext, $_gallery_channelsubtext);
857 $_gallery_customarrows = self::tryget($arroptions, self::$opt_gallery_customarrows, $_gallery_customarrows);
858 $_gallery_customnext = self::tryget($arroptions, self::$opt_gallery_customnext, $_gallery_customnext);
859 $_gallery_customprev = self::tryget($arroptions, self::$opt_gallery_customprev, $_gallery_customprev);
860 $_gallery_showdsc = self::tryget($arroptions, self::$opt_gallery_showdsc, $_gallery_showdsc);
861 $_admin_off_scripts = self::tryget($arroptions, self::$opt_admin_off_scripts, $_admin_off_scripts);
862 }
863 else
864 {
865 $_oldspacing = 0;
866 }
867
868 $all = array(
869 self::$opt_version => self::$version,
870 self::$opt_center => $_center,
871 self::$opt_glance => $_glance,
872 self::$opt_autoplay => $_autoplay,
873 self::$opt_cc_load_policy => $_cc_load_policy,
874 self::$opt_iv_load_policy => $_iv_load_policy,
875 self::$opt_loop => $_loop,
876 self::$opt_modestbranding => $_modestbranding,
877 self::$opt_rel => $_rel,
878 self::$opt_showinfo => $_showinfo,
879 self::$opt_playsinline => $_playsinline,
880 self::$opt_origin => $_origin,
881 self::$opt_autohide => $_autohide,
882 self::$opt_html5 => $_html5,
883 self::$opt_hl => $_hl,
884 self::$opt_dohl => $_dohl,
885 self::$opt_theme => $_theme,
886 self::$opt_color => $_color,
887 self::$opt_wmode => $_wmode,
888 self::$opt_vq => $_vq,
889 self::$opt_pro => $_pro,
890 self::$opt_ssl => $_ssl,
891 self::$opt_nocookie => $_nocookie,
892 self::$opt_playlistorder => $_playlistorder,
893 self::$opt_acctitle => $_acctitle,
894 self::$opt_ogvideo => $_ogvideo,
895 self::$opt_migrate => $_migrate,
896 self::$opt_migrate_youtube => $_migrate_youtube,
897 self::$opt_controls => $_controls,
898 self::$opt_oldspacing => $_oldspacing,
899 self::$opt_responsive => $_responsive,
900 self::$opt_responsive_all => $_responsive_all,
901 self::$opt_widgetfit => $_widgetfit,
902 self::$opt_evselector_light => $_evselector_light,
903 self::$opt_schemaorg => $_schemaorg,
904 self::$opt_ftpostimg => $_ftpostimg,
905 self::$opt_spdc => $_spdc,
906 self::$opt_spdcexp => $_spdcexp,
907 self::$opt_dynload => $_dynload,
908 self::$opt_dyntype => $_dyntype,
909 self::$opt_defaultdims => $_defaultdims,
910 self::$opt_defaultwidth => $_defaultwidth,
911 self::$opt_defaultheight => $_defaultheight,
912 self::$opt_defaultvol => $_defaultvol,
913 self::$opt_vol => $_vol,
914 self::$opt_apikey => $_apikey,
915 self::$opt_gallery_columns => $_gallery_columns,
916 self::$opt_gallery_scrolloffset => $_gallery_scrolloffset,
917 self::$opt_gallery_showtitle => $_gallery_showtitle,
918 self::$opt_gallery_showpaging => $_gallery_showpaging,
919 self::$opt_gallery_autonext => $_gallery_autonext,
920 self::$opt_gallery_thumbplay => $_gallery_thumbplay,
921 self::$opt_gallery_channelsub => $_gallery_channelsub,
922 self::$opt_gallery_channelsublink => $_gallery_channelsublink,
923 self::$opt_gallery_channelsubtext => $_gallery_channelsubtext,
924 self::$opt_gallery_customarrows => $_gallery_customarrows,
925 self::$opt_gallery_customnext => $_gallery_customnext,
926 self::$opt_gallery_customprev => $_gallery_customprev,
927 self::$opt_gallery_showdsc => $_gallery_showdsc,
928 self::$opt_gallery_style => $_gallery_style,
929 self::$opt_gallery_thumbcrop => $_gallery_thumbcrop,
930 self::$opt_gallery_pagesize => $_gallery_pagesize,
931 self::$opt_debugmode => $_debugmode,
932 self::$opt_admin_off_scripts => $_admin_off_scripts,
933 self::$opt_old_script_method => $_old_script_method
934 );
935
936 update_option(self::$opt_alloptions, $all);
937 update_option('embed_autourls', 1);
938 self::$alloptions = get_option(self::$opt_alloptions);
939 }
940
941 public static function tryget($array, $key, $default = null)
942 {
943 return isset($array[$key]) ? $array[$key] : $default;
944 }
945
946 public static function wp_above_version($ver)
947 {
948 global $wp_version;
949 if (version_compare($wp_version, $ver, '>='))
950 {
951 return true;
952 }
953 return false;
954 }
955
956 public static function do_ytprefs()
957 {
958 add_filter('autoptimize_filter_js_exclude', 'YouTubePrefs::ao_override_jsexclude', 10, 1);
959 if (!is_admin())
960 {
961 add_filter('the_content', 'YouTubePrefs::apply_prefs_content', 1);
962 add_filter('widget_text', 'YouTubePrefs::apply_prefs_widget', 1);
963 add_shortcode('embedyt', array('YouTubePrefs', 'apply_prefs_shortcode'));
964 if (self::$alloptions[self::$opt_migrate] == 1)
965 {
966 if (self::$alloptions[self::$opt_migrate_youtube] == 1)
967 {
968 add_shortcode('youtube', array('YouTubePrefs', 'apply_prefs_shortcode_youtube'));
969 add_shortcode('youtube_video', array('YouTubePrefs', 'apply_prefs_shortcode_youtube'));
970 }
971 }
972 }
973 else
974 {
975 if (self::$alloptions[self::$opt_ftpostimg] == 1 && self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
976 {
977 add_action('save_post', array('YouTubePrefs', 'doftpostimg'), 110, 3);
978 }
979 }
980 }
981
982 public static function ao_override_jsexclude($exclude)
983 {
984 if (strpos($exclude, 'ytprefs' . self::$min . '.js') === false)
985 {
986 return $exclude . ",ytprefs' . self::$min . '.js,__ytprefs__";
987 }
988 return $exclude;
989 }
990
991 public static function apply_prefs_shortcode($atts, $content = null)
992 {
993 $content = trim($content);
994 $currfilter = current_filter();
995 if (preg_match(self::$justurlregex, $content))
996 {
997 return self::get_html(array($content), $currfilter == 'widget_text' ? false : true);
998 }
999 return '';
1000 }
1001
1002 public static function apply_prefs_shortcode_youtube($atts, $content = null)
1003 {
1004 $content = 'https://www.youtube.com/watch?v=' . trim($content);
1005 $currfilter = current_filter();
1006 if (preg_match(self::$justurlregex, $content))
1007 {
1008 return self::get_html(array($content), $currfilter == 'widget_text' ? false : true);
1009 }
1010 return '';
1011 }
1012
1013 public static function apply_prefs_content($content)
1014 {
1015 $content = preg_replace_callback(self::$ytregex, "YouTubePrefs::get_html_content", $content);
1016 return $content;
1017 }
1018
1019 public static function apply_prefs_widget($content)
1020 {
1021 $content = preg_replace_callback(self::$ytregex, "YouTubePrefs::get_html_widget", $content);
1022 return $content;
1023 }
1024
1025 public static function get_html_content($m)
1026 {
1027 return self::get_html($m, true);
1028 }
1029
1030 public static function get_html_widget($m)
1031 {
1032 return self::get_html($m, false);
1033 }
1034
1035 public static function get_gallery_page($options)
1036 {
1037 $gallobj = new stdClass();
1038
1039 $options->pageSize = min(intval($options->pageSize), 50);
1040 $options->columns = intval($options->columns);
1041 $options->showTitle = intval($options->showTitle);
1042 $options->showPaging = intval($options->showPaging);
1043 $options->autonext = intval($options->autonext);
1044 $options->thumbplay = intval($options->thumbplay);
1045 $options->showDsc = intval($options->showDsc);
1046 $options->thumbcrop = sanitize_html_class($options->thumbcrop);
1047 $options->style = sanitize_html_class($options->style);
1048
1049 if (empty($options->apiKey))
1050 {
1051 $gallobj->html = '<div>Please enter your YouTube API key to embed galleries.</div>';
1052 return $gallobj;
1053 }
1054
1055 $apiEndpoint = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,status&playlistId=' . $options->playlistId
1056 . '&maxResults=' . $options->pageSize
1057 . '&key=' . $options->apiKey;
1058 if ($options->pageToken != null)
1059 {
1060 $apiEndpoint .= '&pageToken=' . $options->pageToken;
1061 }
1062 $spdckey = '';
1063 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 9 && self::$alloptions[self::$opt_spdc] == 1)
1064 {
1065 try
1066 {
1067 $optionsstr = json_encode($options);
1068 $spdckey = self::$spdcprefix . '_' . md5($apiEndpoint . $optionsstr);
1069 $spdcval = get_transient($spdckey);
1070 if (!empty($spdcval))
1071 {
1072 //self::debuglog((microtime(true) - $time_start) . "\t" . $spdckey . "\t" . $spdcval . "\r\n");
1073 $gallobj->html = $spdcval;
1074 return $gallobj;
1075 }
1076 }
1077 catch (Exception $ex)
1078 {
1079
1080 }
1081 }
1082
1083 $code = '';
1084 $init_id = null;
1085
1086 $apiResult = wp_remote_get($apiEndpoint);
1087
1088 if (is_wp_error($apiResult))
1089 {
1090 $gallobj->html = '<div>Sorry, there was a YouTube API error: <em>' . htmlspecialchars(strip_tags($apiResult->get_error_message())) . '</em>' .
1091 ' Please make sure you performed the <a href="https://www.youtube.com/watch?v=px8LvNIVblg" target="_blank">steps in this video</a> to create and save a proper API key.' .
1092 '</div>';
1093 return $gallobj;
1094 }
1095
1096 if (self::$alloptions[self::$opt_debugmode] == 1 && current_user_can('manage_options'))
1097 {
1098 $redactedEndpoint = preg_replace('@&key=[^&]+@i', '&key=PRIVATE', $apiEndpoint);
1099 $gallobj->html = '<pre onclick="_EPADashboard_.selectText(this);" class="epyt-debug">CLICK this debug text to auto-select all. Then, COPY the selection.' . "\n\n" . $redactedEndpoint . "\n\n" . print_r($apiResult, true) . '</pre>';
1100 return $gallobj;
1101 }
1102
1103 $jsonResult = json_decode($apiResult['body']);
1104
1105 if (isset($jsonResult->error))
1106 {
1107 if (isset($jsonResult->error->message))
1108 {
1109 $gallobj->html = '<div>Sorry, there was a YouTube API error: <em>' . htmlspecialchars(strip_tags($jsonResult->error->message)) . '</em>' .
1110 ' Please make sure you performed the <a href="https://www.youtube.com/watch?v=px8LvNIVblg" target="_blank">steps in this video</a> to create and save a proper API key.' .
1111 '</div>';
1112 return $gallobj;
1113 }
1114 $gallobj->html = '<div>Sorry, there may be an issue with your YouTube API key. Please make sure you performed the <a href="https://www.youtube.com/watch?v=px8LvNIVblg" target="_blank">steps in this video</a> to create and save a proper API key.</div>';
1115 return $gallobj;
1116 }
1117
1118
1119
1120 $resultsPerPage = $options->pageSize; // $jsonResult->pageInfo->resultsPerPage;
1121 $totalResults = $jsonResult->pageInfo->totalResults;
1122
1123 $nextPageToken = '';
1124 $prevPageToken = '';
1125 if (isset($jsonResult->nextPageToken))
1126 {
1127 $nextPageToken = $jsonResult->nextPageToken;
1128 }
1129
1130 if (isset($jsonResult->prevPageToken))
1131 {
1132 $prevPageToken = $jsonResult->prevPageToken;
1133 }
1134
1135 $cnt = 0;
1136 $colclass = '';
1137 if (in_array($options->style, array('grid', '')))
1138 {
1139 $colclass = ' epyt-cols-' . $options->columns . ' ';
1140 }
1141
1142 $cropclass = '';
1143 if (!in_array($options->thumbcrop, array('box', '')))
1144 {
1145 $cropclass = ' epyt-thumb-' . $options->thumbcrop . ' ';
1146 }
1147
1148 $code.= '<div class="epyt-gallery-allthumbs ' . $cropclass . $colclass . '">';
1149
1150
1151
1152
1153 if (isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items))
1154 {
1155
1156 foreach ($jsonResult->items as $item)
1157 {
1158
1159 $thumb = new stdClass();
1160
1161 $thumb->id = isset($item->snippet->resourceId->videoId) ? $item->snippet->resourceId->videoId : null;
1162 $thumb->id = $thumb->id ? $thumb->id : $item->id->videoId;
1163 $thumb->title = $options->showTitle ? $item->snippet->title : '';
1164 $thumb->privacyStatus = isset($item->status->privacyStatus) ? $item->status->privacyStatus : null;
1165
1166 if ($cnt == 0 && $options->pageToken == null)
1167 {
1168 $init_id = $thumb->id;
1169 }
1170
1171 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && $options->style == 'listview')
1172 {
1173 $thumb->dsc = $options->showDsc ? $item->snippet->description : '';
1174 }
1175
1176 if ($thumb->privacyStatus == 'private')
1177 {
1178 $thumb->img = plugins_url('/images/private.png', __FILE__);
1179 $thumb->quality = 'medium';
1180 }
1181 else
1182 {
1183 if (isset($item->snippet->thumbnails->high->url))
1184 {
1185 $thumb->img = $item->snippet->thumbnails->high->url;
1186 $thumb->quality = 'high';
1187 }
1188 elseif (isset($item->snippet->thumbnails->default->url))
1189 {
1190 $thumb->img = $item->snippet->thumbnails->default->url;
1191 $thumb->quality = 'default';
1192 }
1193 else
1194 {
1195 $thumb->img = $item->snippet->thumbnails->medium->url;
1196 $thumb->quality = 'medium';
1197 }
1198 }
1199
1200 $code .= self::get_thumbnail_html($thumb, $options);
1201 $cnt++;
1202
1203 if ($cnt % $options->columns === 0 && $options->style !== 'carousel')
1204 {
1205 $code .= '<div class="epyt-gallery-rowbreak"></div>';
1206 }
1207 }
1208 }
1209
1210 $code .= '<div class="epyt-gallery-clear"></div></div>';
1211
1212 if ($options->style === 'carousel' && $options->showTitle)
1213 {
1214 $code .= '<div class="epyt-gallery-rowtitle"></div>';
1215 }
1216
1217
1218 $totalPages = ceil($totalResults / $resultsPerPage);
1219 $pagination = '<div class="epyt-pagination">';
1220
1221 $txtprev = self::$alloptions[self::$opt_gallery_customarrows] ? self::$alloptions[self::$opt_gallery_customprev] : _('Prev');
1222 $pagination .= '<div class="epyt-pagebutton epyt-prev ' . (empty($prevPageToken) ? ' hide ' : '') . '" data-playlistid="' . esc_attr($options->playlistId)
1223 . '" data-pagesize="' . intval($options->pageSize)
1224 . '" data-pagetoken="' . esc_attr($prevPageToken)
1225 . '" data-style="' . esc_attr($options->style)
1226 . '" data-columns="' . intval($options->columns)
1227 . '" data-showtitle="' . intval($options->showTitle)
1228 . '" data-showpaging="' . intval($options->showPaging)
1229 . '" data-autonext="' . intval($options->autonext)
1230 . '" data-thumbplay="' . intval($options->thumbplay)
1231 . ((self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 9 && $options->style == 'listview' && $options->showDsc) ? '" data-showdsc="' . intval($options->showDsc) : '')
1232 . ((self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 9 && !in_array($options->thumbcrop, array('box', ''))) ? '" data-thumbcrop="' . $options->thumbcrop : '')
1233 . '"><div class="arrow">&laquo;</div> <div>' . $txtprev . '</div></div>';
1234
1235
1236 $pagination .= '<div class="epyt-pagenumbers ' . ($totalPages > 1 ? '' : 'hide') . '">';
1237 $pagination .= '<div class="epyt-current">1</div><div class="epyt-pageseparator"> / </div><div class="epyt-totalpages">' . $totalPages . '</div>';
1238 $pagination .= '</div>';
1239
1240 $txtnext = self::$alloptions[self::$opt_gallery_customarrows] ? self::$alloptions[self::$opt_gallery_customnext] : _('Next');
1241 $pagination .= '<div class="epyt-pagebutton epyt-next' . (empty($nextPageToken) ? ' hide ' : '') . '" data-playlistid="' . esc_attr($options->playlistId)
1242 . '" data-pagesize="' . intval($options->pageSize)
1243 . '" data-pagetoken="' . esc_attr($nextPageToken)
1244 . '" data-style="' . esc_attr($options->style)
1245 . '" data-columns="' . intval($options->columns)
1246 . '" data-showtitle="' . intval($options->showTitle)
1247 . '" data-showpaging="' . intval($options->showPaging)
1248 . '" data-autonext="' . intval($options->autonext)
1249 . '" data-thumbplay="' . intval($options->thumbplay)
1250 . ((self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && $options->style == 'listview' && $options->showDsc) ? '" data-showdsc="' . intval($options->showDsc) : '')
1251 . ((self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 9 && !in_array($options->thumbcrop, array('box', ''))) ? '" data-thumbcrop="' . $options->thumbcrop : '')
1252 . '"><div>' . $txtnext . '</div> <div class="arrow">&raquo;</div></div>';
1253
1254 $pagination .= '<div class="epyt-loader"><img width="16" height="11" src="' . plugins_url('images/gallery-page-loader.gif', __FILE__) . '"></div>';
1255
1256 $pagination .= '</div>';
1257
1258 if ($options->showPaging == 0)
1259 {
1260 $pagination = '';
1261 }
1262 $code = $pagination . $code . $pagination;
1263
1264 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_spdc] == 1)
1265 {
1266 $daysecs = self::$alloptions[self::$opt_spdcexp] * 60 * 60;
1267 set_transient($spdckey, $code, $daysecs);
1268 $allk = get_option(self::$spdcall, array());
1269 $allk[] = $spdckey;
1270 update_option(self::$spdcall, $allk);
1271
1272 //self::debuglog((microtime(true) - $time_start) . "\t" . $spdckey . "\t" . $code . "\r\n");
1273 }
1274
1275 $gallobj->html = $code;
1276 $gallobj->init_id = $init_id;
1277 return $gallobj;
1278 }
1279
1280 public static function get_thumbnail_html($thumb, $options)
1281 {
1282 $escId = esc_attr($thumb->id);
1283 $code = '';
1284 $styleclass = '';
1285 $rawstyle = '';
1286 $dschtml = '';
1287 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
1288 {
1289 if ($options->style == 'listview')
1290 {
1291 $styleclass = 'epyt-listview';
1292 $dschtml = isset($thumb->dsc) && !empty($thumb->dsc) ? '<div class="epyt-gallery-dsc">' . $thumb->dsc . '</div>' : '';
1293 }
1294 else if ($options->style == 'carousel')
1295 {
1296 $rawstyle = ' style="width: ' . (100.0 / floatval($options->pageSize)) . '%;" ';
1297 }
1298 }
1299
1300 $code .= '<div data-videoid="' . $escId . '" class="epyt-gallery-thumb ' . $styleclass . '" ' . $rawstyle . '>';
1301 $code .= '<div class="epyt-gallery-img-box"><div class="epyt-gallery-img" style="background-image: url(' . esc_attr($thumb->img) . ')">' .
1302 '<div class="epyt-gallery-playhover"><img class="epyt-play-img" width="30" height="23" src="' . plugins_url('images/playhover.png', __FILE__) . '" /><div class="epyt-gallery-playcrutch"></div></div>' .
1303 '</div></div>';
1304 if ($options->style != 'carousel' && !empty($thumb->title))
1305 {
1306 $code .= '<div class="epyt-gallery-title">' . esc_html($thumb->title) . '</div>';
1307 }
1308 else
1309 {
1310 $code .= '<div class="epyt-gallery-notitle"><span>' . esc_html($thumb->title) . '</span></div>';
1311 }
1312 $code .= $dschtml . '</div>';
1313
1314
1315 return $code;
1316 }
1317
1318 public static function my_embedplus_gallery_page()
1319 {
1320 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
1321 {
1322 //check_ajax_referer('embedplus-nonce', 'security');
1323 $options = (object) $_POST['options'];
1324 $options->apiKey = self::$alloptions[self::$opt_apikey];
1325 echo self::get_gallery_page($options)->html;
1326 die();
1327 }
1328 }
1329
1330 public static function get_html($m, $iscontent)
1331 {
1332 //$time_start = microtime(true);
1333
1334 $link = trim(str_replace(self::$badentities, self::$goodliterals, $m[0]));
1335
1336 $link = preg_replace('/\s/', '', $link);
1337 $linkparamstemp = explode('?', $link);
1338
1339 $linkparams = array();
1340 if (count($linkparamstemp) > 1)
1341 {
1342 $linkparams = self::keyvalue($linkparamstemp[1], true);
1343 }
1344 if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
1345 {
1346 $vtemp = explode('/', $linkparamstemp[0]);
1347 $linkparams['v'] = array_pop($vtemp);
1348 }
1349
1350 //$linkscheme = 'http';
1351 $youtubebaseurl = 'youtube';
1352 $schemaorgoutput = '';
1353 $voloutput = '';
1354 $dynsrc = '';
1355 $dyntype = '';
1356 $acctitle = '';
1357 $videoseries = '';
1358
1359 $finalparams = $linkparams + self::$alloptions;
1360
1361 $spdckey = '';
1362 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_spdc] == 1)
1363 {
1364 try
1365 {
1366 $kparams = $finalparams;
1367 $kparams['iscontent'] = $iscontent;
1368 ksort($kparams);
1369 $jparams = json_encode($kparams);
1370 $spdckey = self::$spdcprefix . '_' . md5($jparams);
1371 $spdcval = get_transient($spdckey);
1372 if (!empty($spdcval))
1373 {
1374 //self::debuglog((microtime(true) - $time_start) . "\t" . $spdckey . "\t" . $spdcval . "\r\n");
1375 return $spdcval;
1376 }
1377 }
1378 catch (Exception $ex)
1379 {
1380
1381 }
1382 }
1383
1384 self::init_dimensions($link, $linkparams, $finalparams);
1385
1386 if (self::$alloptions[self::$opt_nocookie] == 1)
1387 {
1388 $youtubebaseurl = 'youtube-nocookie';
1389 }
1390
1391
1392 // if (self::$alloptions[self::$opt_ssl] == 1)
1393 // {
1394 // $linkscheme = 'https';
1395 // }
1396
1397 if (self::$alloptions[self::$opt_defaultvol] == 1)
1398 {
1399 $voloutput = ' data-vol="' . self::$alloptions[self::$opt_vol] . '" ';
1400 }
1401
1402
1403 // if (!(self::$alloptions[self::$opt_dohl] == 1 && isset($finalparams[self::$opt_hl]) && strlen($finalparams[self::$opt_hl]) == 2))
1404 // {
1405 // unset($finalparams[self::$opt_hl]);
1406 // }
1407 if (self::$alloptions[self::$opt_dohl] == 1)
1408 {
1409 $locale = get_locale();
1410 $finalparams[self::$opt_hl] = $locale;
1411 }
1412 else
1413 {
1414 unset($finalparams[self::$opt_hl]);
1415 }
1416
1417 if (isset($finalparams[self::$opt_html5]) && $finalparams[self::$opt_html5] == 0)
1418 {
1419 unset($finalparams[self::$opt_html5]);
1420 }
1421
1422 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
1423 {
1424
1425 if (self::$alloptions[self::$opt_schemaorg] == 1 && isset($finalparams['v']))
1426 {
1427 $schemaorgoutput = self::getschemaorgoutput($finalparams['v']);
1428 }
1429
1430
1431
1432 if (self::$alloptions[self::$opt_dynload] == 1
1433 //&& $finalparams[self::$opt_autoplay] != 1
1434 )
1435 {
1436 $dynsrc = 'data-ep-';
1437 $dyntype = ' data-ep-a="' . self::$alloptions[self::$opt_dyntype] . '" ';
1438 }
1439
1440 if (isset($linkparams[self::$opt_vol]) && is_numeric(trim($linkparams[self::$opt_vol])))
1441 {
1442 $voloutput = ' data-vol="' . $linkparams[self::$opt_vol] . '" ';
1443 }
1444 }
1445 else
1446 {
1447 if (isset($finalparams[self::$opt_vol]))
1448 {
1449 unset($finalparams[self::$opt_vol]);
1450 }
1451 }
1452
1453 $centercode = '';
1454 if ($finalparams[self::$opt_center] == 1)
1455 {
1456 $centercode = ' style="display: block; margin: 0px auto;" ';
1457 }
1458
1459 if (self::$alloptions[self::$opt_acctitle] == 1)
1460 {
1461 try
1462 {
1463 //attr escape
1464 if (self::$oembeddata)
1465 {
1466 $acctitle = self::$oembeddata->title;
1467 }
1468 else
1469 {
1470
1471 if (isset($linkparams['list']))
1472 {
1473 $odata = self::get_oembed('http://youtube.com/playlist?list=' . $linkparams['list'], 1920, 1280);
1474 $acctitle = $odata->title;
1475 }
1476 else
1477 {
1478 $odata = self::get_oembed('http://youtube.com/watch?v=' . $linkparams['v'], 1920, 1280);
1479 $acctitle = $odata->title;
1480 }
1481 }
1482
1483 if ($acctitle)
1484 {
1485 $acctitle = ' title="' . esc_attr($acctitle) . '" ';
1486 }
1487 }
1488 catch (Exception $e)
1489 {
1490
1491 }
1492 }
1493
1494 // playlist cleanup
1495 $videoidoutput = isset($linkparams['v']) ? $linkparams['v'] : '';
1496 if (!isset($finalparams['layout']) && isset($finalparams['list']))
1497 {
1498 //$videoseries = 'videoseries/';
1499 }
1500 if ((self::$alloptions[self::$opt_playlistorder] == 1 || isset($finalparams['plindex'])) && isset($finalparams['list']))
1501 {
1502 try
1503 {
1504 $videoidoutput = '';
1505 if (isset($finalparams['plindex']))
1506 {
1507 $finalparams['index'] = intval($finalparams['plindex']);
1508 }
1509 }
1510 catch (Exception $ex)
1511 {
1512
1513 }
1514 }
1515
1516 $galleryWrapper1 = '';
1517 $galleryWrapper2 = '';
1518 $galleryCode = '';
1519 if (
1520 isset($finalparams['layout']) && strtolower($finalparams['layout']) == 'gallery' && isset($finalparams['list'])
1521 )
1522 {
1523 $gallery_options = new stdClass();
1524 $gallery_options->playlistId = $finalparams['list'];
1525 $gallery_options->pageToken = null;
1526 $gallery_options->pageSize = $finalparams[self::$opt_gallery_pagesize];
1527 $gallery_options->columns = intval($finalparams[self::$opt_gallery_columns]);
1528 $gallery_options->showTitle = intval($finalparams[self::$opt_gallery_showtitle]);
1529 $gallery_options->showPaging = intval($finalparams[self::$opt_gallery_showpaging]);
1530 $gallery_options->autonext = intval($finalparams[self::$opt_gallery_autonext]);
1531 $gallery_options->thumbplay = intval($finalparams[self::$opt_gallery_thumbplay]);
1532 $gallery_options->showDsc = intval($finalparams[self::$opt_gallery_showdsc]);
1533 $gallery_options->style = $finalparams[self::$opt_gallery_style];
1534 $gallery_options->thumbcrop = $finalparams[self::$opt_gallery_thumbcrop];
1535 $gallery_options->apiKey = self::$alloptions[self::$opt_apikey];
1536
1537 $subbutton = '';
1538 if (self::$alloptions[self::$opt_gallery_channelsub] == 1)
1539 {
1540 $subbutton = '<div class="epyt-gallery-subscribe"><a target="_blank" class="epyt-gallery-subbutton" href="' .
1541 esc_attr(self::$alloptions[self::$opt_gallery_channelsublink]) . '?sub_confirmation=1"><img src="' . plugins_url('images/play-subscribe.png', __FILE__) . '" />' .
1542 htmlspecialchars(self::$alloptions[self::$opt_gallery_channelsubtext], ENT_QUOTES) . '</a></div>';
1543 }
1544
1545
1546 $gallery_page_obj = self::get_gallery_page($gallery_options);
1547
1548 //$dynsrc = '';// 'data-ep-gallery';
1549 $galleryWrapper1 = '<div class="epyt-gallery" data-currpage="1">';
1550 $galleryWrapper2 = '</div>';
1551 $galleryCode = $subbutton . '<div class="epyt-gallery-list epyt-gallery-style-' . esc_attr($gallery_options->style) . '">' .
1552 $gallery_page_obj->html .
1553 '</div>';
1554 $videoidoutput = isset($gallery_page_obj->init_id) ? $gallery_page_obj->init_id : ''; // 'GALLERYVIDEOID';
1555 }
1556
1557 $code1 = '<iframe ' . $dyntype . $centercode . ' id="_ytid_' . rand(10000, 99999) . '" width="' . self::$defaultwidth . '" height="' . self::$defaultheight .
1558 '" ' . $dynsrc . 'src="https://www.' . $youtubebaseurl . '.com/embed/' . $videoseries . $videoidoutput . '?';
1559 $code2 = '" frameborder="0" class="__youtube_prefs__' . ($iscontent ? '' : ' __youtube_prefs_widget__') .
1560 '"' . $voloutput . $acctitle . ' allowfullscreen ></iframe>' . $schemaorgoutput;
1561
1562 $origin = '';
1563
1564 try
1565 {
1566 if (self::$alloptions[self::$opt_origin] == 1)
1567 {
1568 $url_parts = parse_url(site_url());
1569 $origin = 'origin=' . $url_parts['scheme'] . '://' . $url_parts['host'] . '&';
1570 }
1571 }
1572 catch (Exception $e)
1573 {
1574 $origin = '';
1575 }
1576 $finalsrc = 'enablejsapi=1&' . $origin;
1577
1578 if (count($finalparams) > 1)
1579 {
1580 foreach ($finalparams as $key => $value)
1581 {
1582 if (in_array($key, self::$yt_options))
1583 {
1584 if (!empty($galleryCode) && ($key == 'listType' || $key == 'list'))
1585 {
1586
1587 }
1588 else
1589 {
1590 $finalsrc .= htmlspecialchars($key) . '=' . htmlspecialchars($value) . '&';
1591 if ($key == 'loop' && $value == 1 && !isset($finalparams['list']))
1592 {
1593 $finalsrc .= 'playlist=' . $finalparams['v'] . '&';
1594 }
1595 }
1596 }
1597 }
1598 }
1599
1600 $code = $galleryWrapper1 . $code1 . $finalsrc . $code2 . $galleryCode . $galleryWrapper2; //. '<!--' . $m[0] . '-->';
1601 // reset static vals for next embed
1602 self::$defaultheight = null;
1603 self::$defaultwidth = null;
1604 self::$oembeddata = null;
1605
1606
1607
1608
1609
1610 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0 && self::$alloptions[self::$opt_spdc] == 1)
1611 {
1612 $daysecs = self::$alloptions[self::$opt_spdcexp] * 60 * 60;
1613 set_transient($spdckey, $code, $daysecs);
1614 $allk = get_option(self::$spdcall, array());
1615 $allk[] = $spdckey;
1616 update_option(self::$spdcall, $allk);
1617
1618 //self::debuglog((microtime(true) - $time_start) . "\t" . $spdckey . "\t" . $code . "\r\n");
1619 }
1620 return $code;
1621 }
1622
1623 public static function debuglog($str)
1624 {
1625 $handle = fopen(__DIR__ . "\\debug.txt", "a+");
1626 fwrite($handle, $str);
1627 fclose($handle);
1628 }
1629
1630 public static function spdcpurge()
1631 {
1632 $allk = get_option(self::$spdcall, array());
1633 if (is_array($allk))
1634 {
1635 foreach ($allk as $t)
1636 {
1637 $success = delete_transient($t);
1638 }
1639 }
1640 update_option(self::$spdcall, array());
1641 }
1642
1643 public static function keyvalue($qry, $includev)
1644 {
1645 $ytvars = explode('&', $qry);
1646 $ytkvp = array();
1647 foreach ($ytvars as $k => $v)
1648 {
1649 $kvp = explode('=', $v);
1650 if (count($kvp) == 2 && ($includev || strtolower($kvp[0]) != 'v'))
1651 {
1652 $ytkvp[$kvp[0]] = $kvp[1];
1653 }
1654 }
1655
1656 return $ytkvp;
1657 }
1658
1659 public static function getschemaorgoutput($vidid)
1660 {
1661 $schemaorgcode = '';
1662 try
1663 {
1664 $ytapilink = 'https://www.googleapis.com/youtube/v3/videos?id=' . $vidid . '&part=contentDetails,snippet&key=' . self::$alloptions[self::$opt_apikey];
1665
1666
1667 $apidata = wp_remote_get($ytapilink);
1668 if (!is_wp_error($apidata))
1669 {
1670 $raw = wp_remote_retrieve_body($apidata);
1671 if (!empty($raw))
1672 {
1673 $json = json_decode($raw, true);
1674 if (is_array($json))
1675 {
1676 $_name = esc_attr(sanitize_text_field(str_replace("@", "&#64;", $json['items'][0]['snippet']['title'])));
1677 $_description = esc_attr(sanitize_text_field(str_replace("@", "&#64;", $json['items'][0]['snippet']['description'])));
1678 $_thumbnailUrl = esc_url("https://i.ytimg.com/vi/" . $vidid . "/0.jpg");
1679 $_duration = $json['items'][0]['contentDetails']['duration']; // "T0H9M35S" "PT9M35S"
1680 $_uploadDate = sanitize_text_field($json['items'][0]['snippet']['publishedAt']); // "2014-10-03T15:30:12.000Z"
1681
1682 $schemaorgcode = '<span itemprop="video" itemscope itemtype="http://schema.org/VideoObject">';
1683 $schemaorgcode .= '<meta itemprop="embedURL" content="https://www.youtube.com/embed/' . $vidid . '">';
1684 $schemaorgcode .= '<meta itemprop="name" content="' . $_name . '">';
1685 $schemaorgcode .= '<meta itemprop="description" content="' . $_description . '">';
1686 $schemaorgcode .= '<meta itemprop="thumbnailUrl" content="' . $_thumbnailUrl . '">';
1687 $schemaorgcode .= '<meta itemprop="duration" content="' . $_duration . '">';
1688 $schemaorgcode .= '<meta itemprop="uploadDate" content="' . $_uploadDate . '">';
1689 $schemaorgcode .= '</span>';
1690 }
1691 }
1692 }
1693 }
1694 catch (Exception $ex)
1695 {
1696
1697 }
1698 return $schemaorgcode;
1699 }
1700
1701 public static function secondsToDuration($seconds)
1702 {
1703 $remaining = $seconds;
1704 $parts = array();
1705 $multipliers = array(
1706 'hours' => 3600,
1707 'minutes' => 60,
1708 'seconds' => 1
1709 );
1710
1711 foreach ($multipliers as $type => $m)
1712 {
1713 $parts[$type] = (int) ($remaining / $m);
1714 $remaining -= ($parts[$type] * $m);
1715 }
1716
1717 return $parts;
1718 }
1719
1720 public static function formatDuration($parts)
1721 {
1722 $default = array(
1723 'hours' => 0,
1724 'minutes' => 0,
1725 'seconds' => 0
1726 );
1727
1728 extract(array_merge($default, $parts));
1729
1730 return "T{$hours}H{$minutes}M{$seconds}S";
1731 }
1732
1733 public static function init_dimensions($url, $urlkvp, $finalparams)
1734 {
1735 // get default dimensions; try embed size in settings, then try theme's content width, then just 480px
1736 if (self::$defaultwidth == null)
1737 {
1738 global $content_width;
1739 if (empty($content_width))
1740 {
1741 $content_width = $GLOBALS['content_width'];
1742 }
1743
1744 if (isset($urlkvp['width']) && is_numeric($urlkvp['width']))
1745 {
1746 self::$defaultwidth = $urlkvp['width'];
1747 }
1748 else if (self::$alloptions[self::$opt_defaultdims] == 1 && (isset(self::$alloptions[self::$opt_defaultwidth]) && is_numeric(self::$alloptions[self::$opt_defaultwidth])))
1749 {
1750 self::$defaultwidth = self::$alloptions[self::$opt_defaultwidth];
1751 }
1752 else if (self::$optembedwidth)
1753 {
1754 self::$defaultwidth = self::$optembedwidth;
1755 }
1756 else if ($content_width)
1757 {
1758 self::$defaultwidth = $content_width;
1759 }
1760 else
1761 {
1762 self::$defaultwidth = 480;
1763 }
1764
1765
1766
1767 if (isset($urlkvp['height']) && is_numeric($urlkvp['height']))
1768 {
1769 self::$defaultheight = $urlkvp['height'];
1770 }
1771 else if (self::$alloptions[self::$opt_defaultdims] == 1 && (isset(self::$alloptions[self::$opt_defaultheight]) && is_numeric(self::$alloptions[self::$opt_defaultheight])))
1772 {
1773 self::$defaultheight = self::$alloptions[self::$opt_defaultheight];
1774 }
1775 else
1776 {
1777 self::$defaultheight = self::get_aspect_height($url, $urlkvp, $finalparams);
1778 }
1779 }
1780 }
1781
1782 public static function get_oembed($url, $height, $width)
1783 {
1784 require_once( ABSPATH . WPINC . '/class-oembed.php' );
1785 $oembed = _wp_oembed_get_object();
1786 $args = array();
1787 $args['width'] = $width;
1788 $args['height'] = $height;
1789 $args['discover'] = false;
1790 self::$oembeddata = $oembed->fetch('https://www.youtube.com/oembed', $url, $args);
1791 return self::$oembeddata;
1792 }
1793
1794 public static function get_aspect_height($url, $urlkvp, $finalparams)
1795 {
1796
1797 // attempt to get aspect ratio correct height from oEmbed
1798 $aspectheight = round((self::$defaultwidth * 9) / 16, 0);
1799
1800
1801 if ($url)
1802 {
1803 $odata = self::get_oembed($url, self::$defaultwidth, self::$defaultwidth);
1804
1805 if ($odata)
1806 {
1807 $aspectheight = $odata->height;
1808 }
1809 }
1810
1811 if ($finalparams[self::$opt_controls] != 0 && $finalparams[self::$opt_autohide] != 1)
1812 {
1813 //add 28 for YouTube's own bar: DEPRECATED
1814 //$aspectheight += 28;
1815 }
1816 return $aspectheight;
1817 }
1818
1819 public static function doftpostimg($postid, $post, $update)
1820 {
1821 if (current_user_can('edit_posts'))
1822 {
1823 if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || !in_array($post->post_status, array('publish', 'pending', 'draft', 'future', 'private')))
1824 {
1825 return;
1826 }
1827 try
1828 {
1829 self::doftpostimgfor($post);
1830 }
1831 catch (Exception $ex)
1832 {
1833 // display error message
1834 }
1835 }
1836 }
1837
1838 public static function doftpostimgfor($post)
1839 {
1840 $search_content = isset($post->post_content) ? $post->post_content : '';
1841 $search_content = substr(wp_strip_all_tags($search_content), 0, 5000);
1842
1843 $search_content = apply_filters('youtube_embedplus_video_content', $search_content);
1844
1845 $vid_match = null;
1846 if ($search_content && $post->ID && !has_post_thumbnail($post->ID) && preg_match(self::$justurlregex, $search_content, $vid_match)
1847 )
1848 {
1849
1850 $first_vid_link = trim(str_replace(self::$badentities, self::$goodliterals, $vid_match[0]));
1851
1852 $first_vid_link = preg_replace('/\s/', '', $first_vid_link);
1853 $linkparamstemp = explode('?', $first_vid_link);
1854
1855 $linkparams = array();
1856 if (count($linkparamstemp) > 1)
1857 {
1858 $linkparams = self::keyvalue($linkparamstemp[1], true);
1859 }
1860 if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
1861 {
1862 $vtemp = explode('/', $linkparamstemp[0]);
1863 $linkparams['v'] = array_pop($vtemp);
1864 }
1865
1866 $just_id = $linkparams['v'];
1867
1868 if ($just_id == null && isset($linkparams['list']))
1869 {
1870 $apiEndpoint = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,status&playlistId=' . $linkparams['list']
1871 . '&maxResults=10&key=' . self::$alloptions[self::$opt_apikey];
1872 try
1873 {
1874 $apiResult = wp_remote_get($apiEndpoint);
1875 if (!is_wp_error($apiResult))
1876 {
1877 $jsonResult = json_decode($apiResult['body']);
1878 if (!isset($jsonResult->error) && isset($jsonResult->items) && $jsonResult->items != null && is_array($jsonResult->items))
1879 {
1880
1881 $item = $jsonResult->items[0];
1882 $just_id = isset($item->snippet->resourceId->videoId) ? $item->snippet->resourceId->videoId : null;
1883 $just_id = $just_id ? $just_id : $item->id->videoId;
1884 }
1885 }
1886 }
1887 catch (Exception $ex)
1888 {
1889
1890 }
1891 }
1892
1893 if ($just_id != null)
1894 {
1895 $ftimgurl = "https://img.youtube.com/vi/" . $just_id . "/maxresdefault.jpg";
1896 $ftimgid = self::media_sideload($ftimgurl, $post->ID, sanitize_title(preg_replace("/[^a-zA-Z0-9\s]/", "-", $post->post_title)));
1897
1898 if (!ftimgid || is_wp_error($ftimgid))
1899 {
1900 $ftimgurl = null;
1901 $ftimgid = 0;
1902 if ($just_id)
1903 {
1904 require_once( ABSPATH . WPINC . '/class-oembed.php' );
1905 $oembed = _wp_oembed_get_object();
1906 $args = array();
1907 $args['width'] = 1920;
1908 $args['height'] = 1080;
1909 $args['discover'] = false;
1910 $odata = $oembed->fetch('https://www.youtube.com/oembed', 'http://youtube.com/watch?v=' . $just_id, $args);
1911
1912 if ($odata)
1913 {
1914 $ftimgurl = $odata->thumbnail_url;
1915 }
1916 }
1917
1918 $ftimgid = $ftimgurl && !is_wp_error($ftimgurl) ? self::media_sideload($ftimgurl, $post->ID, sanitize_title(preg_replace("/[^a-zA-Z0-9\s]/", "-", $post->title))) : 0;
1919
1920 if (!$ftimgid || is_wp_error($ftimgid))
1921 {
1922 return;
1923 }
1924 }
1925 set_post_thumbnail($post->ID, $ftimgid);
1926 }
1927 }
1928 }
1929
1930 public static function media_sideload($url, $post_id, $filename = null)
1931 {
1932 if (!$url || !$post_id)
1933 {
1934 return new WP_Error('missing', __('Please provide a valid URL and post ID', ''));
1935 }
1936
1937 $post_title = get_the_title($post_id);
1938
1939 require_once(ABSPATH . 'wp-admin/includes/file.php');
1940 $tmp = download_url($url);
1941
1942 if (is_wp_error($tmp))
1943 {
1944 @unlink($file_array['tmp_name']);
1945 $file_array['tmp_name'] = '';
1946 return $tmp;
1947 }
1948
1949 preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches);
1950 $url_filename = basename($matches[0]);
1951 $url_type = wp_check_filetype($url_filename);
1952
1953 if (!empty($filename))
1954 {
1955 $filename = sanitize_file_name($filename);
1956 $tmppath = pathinfo($tmp);
1957 $new = $tmppath['dirname'] . '/' . $filename . '.' . $tmppath['extension'];
1958 rename($tmp, $new);
1959 $tmp = $new;
1960 }
1961
1962 $file_array['tmp_name'] = $tmp;
1963 if (!empty($filename))
1964 {
1965 $file_array['name'] = $filename . '.' . $url_type['ext'];
1966 }
1967 else
1968 {
1969 $file_array['name'] = $url_filename;
1970 }
1971
1972 $post_data = array(
1973 'post_title' => $post_title,
1974 'post_parent' => $post_id,
1975 );
1976
1977 require_once( ABSPATH . 'wp-admin/includes/file.php' );
1978 require_once( ABSPATH . 'wp-admin/includes/media.php' );
1979 require_once( ABSPATH . 'wp-admin/includes/image.php' );
1980
1981 $att_id = media_handle_sideload($file_array, $post_id, null, $post_data);
1982
1983 if (is_wp_error($att_id))
1984 {
1985 @unlink($file_array['tmp_name']);
1986 return $att_id;
1987 }
1988
1989 return $att_id;
1990 }
1991
1992 public static function do_ogvideo()
1993 {
1994 global $wp_query;
1995 $the_content = $wp_query->post->post_content;
1996 $matches = Array();
1997 $ismatch = preg_match_all(self::$justurlregex, $the_content, $matches);
1998
1999 if ($ismatch)
2000 {
2001 $match = $matches[0][0];
2002
2003 $link = trim(preg_replace('/&amp;/i', '&', $match));
2004 $link = preg_replace('/\s/', '', $link);
2005 $link = trim(str_replace(self::$badentities, self::$goodliterals, $link));
2006
2007 $linkparamstemp = explode('?', $link);
2008
2009 $linkparams = array();
2010 if (count($linkparamstemp) > 1)
2011 {
2012 $linkparams = self::keyvalue($linkparamstemp[1], true);
2013 }
2014 if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
2015 {
2016 $vtemp = explode('/', $linkparamstemp[0]);
2017 $linkparams['v'] = array_pop($vtemp);
2018 }
2019
2020 if (isset($linkparams['v']))
2021 {
2022 ?>
2023 <meta property="og:type" content="video">
2024 <meta property="og:video" content="https://www.youtube.com/v/<?php echo $linkparams['v']; ?>?autohide=1&amp;version=3">
2025 <meta property="og:video:type" content="application/x-shockwave-flash">
2026 <meta property="og:video:width" content="480">
2027 <meta property="og:video:height" content="360">
2028 <meta property="og:image" content="https://img.youtube.com/vi/<?php echo $linkparams['v']; ?>/0.jpg">
2029 <?php
2030 }
2031 }
2032 }
2033
2034 public static function ytprefs_plugin_menu()
2035 {
2036 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
2037 {
2038 add_menu_page('YouTube Settings', 'YouTube PRO', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options', plugins_url('images/youtubeicon16.png', __FILE__), '10.000392854349');
2039 add_submenu_page('youtube-my-preferences', '', '', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options');
2040 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');
2041 }
2042 else
2043 {
2044 add_menu_page('YouTube Settings', 'YouTube Free', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options', plugins_url('images/youtubeicon16.png', __FILE__), '10.000392854349');
2045 add_submenu_page('youtube-my-preferences', '', '', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options');
2046 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');
2047 }
2048 add_submenu_page(null, 'YouTube Posts', 'YouTube Posts', 'manage_options', 'youtube-ep-glance', 'YouTubePrefs::glance_page');
2049 }
2050
2051 public static function epstats_show_options()
2052 {
2053
2054 if (!current_user_can('manage_options'))
2055 {
2056 wp_die(__('You do not have sufficient permissions to access this page.'));
2057 }
2058
2059 if (self::$double_plugin)
2060 {
2061 //add_action('admin_notices', array("YouTubePrefs", "double_plugin_warning"));
2062 self::double_plugin_warning();
2063 }
2064
2065
2066 // Now display the settings editing screen
2067 ?>
2068 <div class="wrap">
2069 <style type="text/css">
2070 .wrap {font-family: Arial;}
2071 .epicon { width: 20px; height: 20px; vertical-align: middle; padding-right: 5px;}
2072 .epindent {padding-left: 25px;}
2073 iframe.shadow {-webkit-box-shadow: 0px 0px 20px 0px #000000; box-shadow: 0px 0px 20px 0px #000000;}
2074 .bold {font-weight: bold;}
2075 .orange {color: #f85d00;}
2076 </style>
2077 <br>
2078 <?php
2079 $thishost = (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "");
2080 $thiskey = self::$alloptions[self::$opt_pro];
2081
2082 $dashurl = self::$epbase . "/dashboard/pro-easy-video-analytics.aspx?ref=protab&domain=" . $thishost . "&prokey=" . $thiskey;
2083
2084 if (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
2085 {
2086 //// header
2087 echo "<h2>" . '<img src="' . plugins_url('images/epstats16.png', __FILE__) . '" /> ' . __('YouTube Analytics Dashboard') . "</h2>";
2088 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>';
2089 }
2090 else
2091 {
2092 //// header
2093 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>";
2094 }
2095 ?>
2096 <iframe class="shadow" src="<?php echo $dashurl ?>" width="1060" height="3600" scrolling="auto"/>
2097 </div>
2098 <?php
2099 }
2100
2101 public static function my_embedplus_pro_record()
2102 {
2103 $result = array();
2104 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
2105 {
2106 $tmppro = preg_replace('/[^A-Za-z0-9-]/i', '', $_REQUEST[self::$opt_pro]);
2107 $new_options = array();
2108 $new_options[self::$opt_pro] = $tmppro;
2109 $all = get_option(self::$opt_alloptions);
2110 $all = $new_options + $all;
2111 update_option(self::$opt_alloptions, $all);
2112
2113 if (strlen($tmppro) > 0)
2114 {
2115 $result['type'] = 'success';
2116 }
2117 else
2118 {
2119 $result['type'] = 'error';
2120 }
2121 echo json_encode($result);
2122 }
2123 else
2124 {
2125 $result['type'] = 'error';
2126 header("Location: " . $_SERVER["HTTP_REFERER"]);
2127 }
2128 die();
2129 }
2130
2131 public static function my_embedplus_clearspdc()
2132 {
2133 $result = array();
2134 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
2135 {
2136 try
2137 {
2138 self::spdcpurge();
2139 $result['type'] = 'success';
2140 }
2141 catch (Exception $ex)
2142 {
2143 $result['type'] = 'error';
2144 }
2145 echo json_encode($result);
2146 }
2147 else
2148 {
2149 $result['type'] = 'error';
2150 header("Location: " . $_SERVER["HTTP_REFERER"]);
2151 }
2152 die();
2153 }
2154
2155 public static function custom_admin_pointers_check()
2156 {
2157 //return false; // ooopointer shut all off;
2158 $admin_pointers = self::custom_admin_pointers();
2159 foreach ($admin_pointers as $pointer => $array)
2160 {
2161 if ($array['active'])
2162 return true;
2163 }
2164 }
2165
2166 public static function glance_script()
2167 {
2168 add_thickbox();
2169 ?>
2170 <script type="text/javascript">
2171 function widen_ytprefs_glance() {
2172 setTimeout(function () {
2173 jQuery("#TB_window").animate({marginLeft: '-' + parseInt((780 / 2), 10) + 'px', width: '780px'}, 300);
2174 jQuery("#TB_window iframe").animate({width: '780px'}, 300);
2175 }, 15);
2176 }
2177
2178 (function ($j)
2179 {
2180 $j(document).ready(function () {
2181
2182 $j.ajax({
2183 type: "post",
2184 dataType: "json",
2185 timeout: 30000,
2186 url: wpajaxurl,
2187 data: {action: 'my_embedplus_glance_count'},
2188 success: function (response) {
2189 if (response.type == "success") {
2190 $j(response.container).append(response.data);
2191 $j(".ytprefs_glance_button").click(widen_ytprefs_glance);
2192 $j(window).resize(widen_ytprefs_glance);
2193 if (typeof ep_do_pointers == 'function')
2194 {
2195 //ep_do_pointers($j);
2196 }
2197 }
2198 else {
2199 }
2200 },
2201 error: function (xhr, ajaxOptions, thrownError) {
2202
2203 },
2204 complete: function () {
2205 }
2206 });
2207
2208 });
2209
2210 })(jQuery);
2211 </script>
2212 <?php
2213 }
2214
2215 public static function custom_admin_pointers_footer()
2216 {
2217 $admin_pointers = self::custom_admin_pointers();
2218 ?>
2219 <script type="text/javascript">
2220 /* <![CDATA[ */
2221 function ep_do_pointers($)
2222 {
2223 <?php
2224 foreach ($admin_pointers as $pointer => $array)
2225 {
2226 if ($array['active'])
2227 {
2228 ?>
2229 $('<?php echo $array['anchor_id']; ?>').pointer({
2230 content: '<?php echo $array['content']; ?>',
2231 position: {
2232 edge: '<?php echo $array['edge']; ?>',
2233 align: '<?php echo $array['align']; ?>'
2234 },
2235 close: function () {
2236 $.post(wpajaxurl, {
2237 pointer: '<?php echo $pointer; ?>',
2238 action: 'dismiss-wp-pointer'
2239 });
2240 }
2241 }).pointer('open');
2242 <?php
2243 }
2244 }
2245 ?>
2246 }
2247
2248 ep_do_pointers(jQuery); // switch off all pointers via js ooopointer
2249 /* ]]> */
2250 </script>
2251 <?php
2252 }
2253
2254 public static function custom_admin_pointers()
2255 {
2256 $dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true));
2257 $version = str_replace('.', '_', self::$version); // replace all periods in version with an underscore
2258 $prefix = 'custom_admin_pointers' . $version . '_';
2259
2260 $new_pointer_content = '<h3>' . __('New Update') . '</h3>'; // ooopointer
2261
2262 $new_pointer_content .= '<p>'; // ooopointer
2263 if (!(self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0))
2264 {
2265 $new_pointer_content .= __("This update adds improved wizard and gallery options to Free and Pro versions. A \"clear YouTube cache\" shortcut was added to <a target=_blank href=" . self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=frompointer' . ">Pro versions &raquo;</a>");
2266 }
2267 else
2268 {
2269 $new_pointer_content .= __("This update adds improved wizard and gallery options to Free and Pro versions. A \"clear YouTube cache\" shortcut was added to Pro versions.");
2270 }
2271 $new_pointer_content .= '</p>';
2272
2273 return array(
2274 $prefix . 'new_items' => array(
2275 'content' => $new_pointer_content,
2276 'anchor_id' => 'a.toplevel_page_youtube-my-preferences', //'#ytprefs_glance_button',
2277 'edge' => 'top',
2278 'align' => 'left',
2279 'active' => (!in_array($prefix . 'new_items', $dismissed) )
2280 ),
2281 );
2282 }
2283
2284 public static function postchecked($idx)
2285 {
2286 return isset($_POST[$idx]) && $_POST[$idx] == (true || 'on');
2287 }
2288
2289 public static function ytprefs_show_options()
2290 {
2291
2292 if (!current_user_can('manage_options'))
2293 {
2294 wp_die(__('You do not have sufficient permissions to access this page.'));
2295 }
2296
2297 if (self::$double_plugin)
2298 {
2299 //add_action('admin_notices', array("YouTubePrefs", "double_plugin_warning"));
2300 self::double_plugin_warning();
2301 }
2302
2303
2304 // variables for the field and option names
2305 $ytprefs_submitted = 'ytprefs_submitted';
2306
2307 // Read in existing option values from database
2308
2309 $all = get_option(self::$opt_alloptions);
2310
2311 // See if the user has posted us some information
2312 // If they did, this hidden field will be set to 'Y'
2313 if (isset($_POST[$ytprefs_submitted]) && $_POST[$ytprefs_submitted] == 'Y')
2314 {
2315 // Read their posted values
2316
2317 $new_options = array();
2318 $new_options[self::$opt_center] = self::postchecked(self::$opt_center) ? 1 : 0;
2319 $new_options[self::$opt_glance] = self::postchecked(self::$opt_glance) ? 1 : 0;
2320 $new_options[self::$opt_autoplay] = self::postchecked(self::$opt_autoplay) ? 1 : 0;
2321 $new_options[self::$opt_debugmode] = self::postchecked(self::$opt_debugmode) ? 1 : 0;
2322 $new_options[self::$opt_admin_off_scripts] = self::postchecked(self::$opt_admin_off_scripts) ? 1 : 0;
2323 $new_options[self::$opt_old_script_method] = self::postchecked(self::$opt_old_script_method) ? 1 : 0;
2324 $new_options[self::$opt_cc_load_policy] = self::postchecked(self::$opt_cc_load_policy) ? 1 : 0;
2325 $new_options[self::$opt_iv_load_policy] = self::postchecked(self::$opt_iv_load_policy) ? 1 : 3;
2326 $new_options[self::$opt_loop] = self::postchecked(self::$opt_loop) ? 1 : 0;
2327 $new_options[self::$opt_modestbranding] = self::postchecked(self::$opt_modestbranding) ? 1 : 0;
2328 $new_options[self::$opt_rel] = self::postchecked(self::$opt_rel) ? 1 : 0;
2329 $new_options[self::$opt_showinfo] = self::postchecked(self::$opt_showinfo) ? 1 : 0;
2330 $new_options[self::$opt_playsinline] = self::postchecked(self::$opt_playsinline) ? 1 : 0;
2331 $new_options[self::$opt_origin] = self::postchecked(self::$opt_origin) ? 1 : 0;
2332 $new_options[self::$opt_controls] = self::postchecked(self::$opt_controls) ? 2 : 0;
2333 $new_options[self::$opt_autohide] = self::postchecked(self::$opt_autohide) ? 1 : 2;
2334 $new_options[self::$opt_html5] = self::postchecked(self::$opt_html5) ? 1 : 0;
2335 $new_options[self::$opt_theme] = self::postchecked(self::$opt_theme) ? 'dark' : 'light';
2336 $new_options[self::$opt_color] = self::postchecked(self::$opt_color) ? 'red' : 'white';
2337 $new_options[self::$opt_wmode] = self::postchecked(self::$opt_wmode) ? 'opaque' : 'transparent';
2338 $new_options[self::$opt_vq] = self::postchecked(self::$opt_vq) ? 'hd720' : '';
2339 $new_options[self::$opt_nocookie] = self::postchecked(self::$opt_nocookie) ? 1 : 0;
2340 $new_options[self::$opt_playlistorder] = self::postchecked(self::$opt_playlistorder) ? 1 : 0;
2341 $new_options[self::$opt_acctitle] = self::postchecked(self::$opt_acctitle) ? 1 : 0;
2342 $new_options[self::$opt_ogvideo] = self::postchecked(self::$opt_ogvideo) ? 1 : 0;
2343 $new_options[self::$opt_migrate] = self::postchecked(self::$opt_migrate) ? 1 : 0;
2344 $new_options[self::$opt_migrate_youtube] = self::postchecked(self::$opt_migrate_youtube) ? 1 : 0;
2345 //$new_options[self::$opt_ssl] = self::postchecked(self::$opt_ssl) ? 1 : 0;
2346 $new_options[self::$opt_oldspacing] = self::postchecked(self::$opt_oldspacing) ? 1 : 0;
2347 $new_options[self::$opt_responsive] = self::postchecked(self::$opt_responsive) ? 1 : 0;
2348 $new_options[self::$opt_widgetfit] = self::postchecked(self::$opt_widgetfit) ? 1 : 0;
2349 $new_options[self::$opt_evselector_light] = self::postchecked(self::$opt_evselector_light) ? 1 : 0;
2350 $new_options[self::$opt_schemaorg] = self::postchecked(self::$opt_schemaorg) ? 1 : 0;
2351 $new_options[self::$opt_ftpostimg] = self::postchecked(self::$opt_ftpostimg) ? 1 : 0;
2352 $new_options[self::$opt_spdc] = self::postchecked(self::$opt_spdc) ? 1 : 0;
2353 $new_options[self::$opt_dynload] = self::postchecked(self::$opt_dynload) ? 1 : 0;
2354 $new_options[self::$opt_defaultdims] = self::postchecked(self::$opt_defaultdims) ? 1 : 0;
2355 $new_options[self::$opt_defaultvol] = self::postchecked(self::$opt_defaultvol) ? 1 : 0;
2356 $new_options[self::$opt_dohl] = self::postchecked(self::$opt_dohl) ? 1 : 0;
2357 $new_options[self::$opt_gallery_showtitle] = self::postchecked(self::$opt_gallery_showtitle) ? 1 : 0;
2358 $new_options[self::$opt_gallery_showpaging] = self::postchecked(self::$opt_gallery_showpaging) ? 1 : 0;
2359 $new_options[self::$opt_gallery_autonext] = self::postchecked(self::$opt_gallery_autonext) ? 1 : 0;
2360 $new_options[self::$opt_gallery_thumbplay] = self::postchecked(self::$opt_gallery_thumbplay) ? 1 : 0;
2361 $new_options[self::$opt_gallery_channelsub] = self::postchecked(self::$opt_gallery_channelsub) ? 1 : 0;
2362 $new_options[self::$opt_gallery_customarrows] = self::postchecked(self::$opt_gallery_customarrows) ? 1 : 0;
2363 $new_options[self::$opt_gallery_showdsc] = self::postchecked(self::$opt_gallery_showdsc) ? 1 : 0;
2364
2365 $_defaultwidth = '';
2366 try
2367 {
2368 $_defaultwidth = is_numeric(trim($_POST[self::$opt_defaultwidth])) ? intval(trim($_POST[self::$opt_defaultwidth])) : $_defaultwidth;
2369 }
2370 catch (Exception $ex)
2371 {
2372
2373 }
2374 $new_options[self::$opt_defaultwidth] = $_defaultwidth;
2375
2376 $_defaultheight = '';
2377 try
2378 {
2379 $_defaultheight = is_numeric(trim($_POST[self::$opt_defaultheight])) ? intval(trim($_POST[self::$opt_defaultheight])) : $_defaultheight;
2380 }
2381 catch (Exception $ex)
2382 {
2383
2384 }
2385 $new_options[self::$opt_defaultheight] = $_defaultheight;
2386
2387 $_responsive_all = 1;
2388 try
2389 {
2390 $_responsive_all = is_numeric(trim($_POST[self::$opt_responsive_all])) ? intval(trim($_POST[self::$opt_responsive_all])) : $_responsive_all;
2391 }
2392 catch (Exception $ex)
2393 {
2394
2395 }
2396 $new_options[self::$opt_responsive_all] = $_responsive_all;
2397
2398 $_vol = '';
2399 try
2400 {
2401 $_vol = is_numeric(trim($_POST[self::$opt_vol])) ? intval(trim($_POST[self::$opt_vol])) : $_vol;
2402 }
2403 catch (Exception $ex)
2404 {
2405
2406 }
2407 $new_options[self::$opt_vol] = $_vol;
2408
2409 $_gallery_pagesize = 12;
2410 try
2411 {
2412 $_gallery_pagesize = is_numeric(trim($_POST[self::$opt_gallery_pagesize])) ? intval(trim($_POST[self::$opt_gallery_pagesize])) : $_gallery_pagesize;
2413 }
2414 catch (Exception $ex)
2415 {
2416
2417 }
2418 $new_options[self::$opt_gallery_pagesize] = $_gallery_pagesize;
2419
2420
2421 $_gallery_columns = 3;
2422 try
2423 {
2424 $_gallery_columns = is_numeric(trim($_POST[self::$opt_gallery_columns])) ? intval(trim($_POST[self::$opt_gallery_columns])) : $_gallery_columns;
2425 }
2426 catch (Exception $ex)
2427 {
2428
2429 }
2430 $new_options[self::$opt_gallery_columns] = $_gallery_columns;
2431
2432 $_gallery_scrolloffset = 20;
2433 try
2434 {
2435 $_gallery_scrolloffset = is_numeric(trim($_POST[self::$opt_gallery_scrolloffset])) ? intval(trim($_POST[self::$opt_gallery_scrolloffset])) : $_gallery_scrolloffset;
2436 }
2437 catch (Exception $ex)
2438 {
2439
2440 }
2441 $new_options[self::$opt_gallery_scrolloffset] = $_gallery_scrolloffset;
2442
2443 $_gallery_style = 'grid';
2444 try
2445 {
2446 if (isset($_POST[self::$opt_gallery_style]))
2447 {
2448 $_gallery_style = trim(str_replace(array(' ', "'", '"'), array('', '', ''), strip_tags($_POST[self::$opt_gallery_style])));
2449 }
2450 }
2451 catch (Exception $ex)
2452 {
2453 $_gallery_style = 'grid';
2454 }
2455 $new_options[self::$opt_gallery_style] = $_gallery_style;
2456
2457
2458 $_gallery_thumbcrop = 'box';
2459 try
2460 {
2461 if (isset($_POST[self::$opt_gallery_thumbcrop]))
2462 {
2463 $_gallery_thumbcrop = trim(str_replace(array(' ', "'", '"'), array('', '', ''), strip_tags($_POST[self::$opt_gallery_thumbcrop])));
2464 }
2465 }
2466 catch (Exception $ex)
2467 {
2468 $_gallery_thumbcrop = 'box';
2469 }
2470 $new_options[self::$opt_gallery_thumbcrop] = $_gallery_thumbcrop;
2471
2472
2473 $_gallery_channelsublink = '';
2474 try
2475 {
2476 $_gallery_channelsublink = trim(strip_tags($_POST[self::$opt_gallery_channelsublink]));
2477 $pieces = explode('?', $_gallery_channelsublink);
2478 $_gallery_channelsublink = trim($pieces[0]);
2479 }
2480 catch (Exception $ex)
2481 {
2482 $_gallery_channelsublink = '';
2483 }
2484 $new_options[self::$opt_gallery_channelsublink] = $_gallery_channelsublink;
2485
2486
2487 $_gallery_channelsubtext = '';
2488 try
2489 {
2490 $_gallery_channelsubtext = stripslashes(trim($_POST[self::$opt_gallery_channelsubtext]));
2491 }
2492 catch (Exception $ex)
2493 {
2494 $_gallery_channelsubtext = '';
2495 }
2496 $new_options[self::$opt_gallery_channelsubtext] = $_gallery_channelsubtext;
2497
2498
2499 $_gallery_custom_prev = 'Prev';
2500 try
2501 {
2502 $_gallery_custom_prev = trim(strip_tags($_POST[self::$opt_gallery_customprev]));
2503 }
2504 catch (Exception $ex)
2505 {
2506 $_gallery_custom_prev = 'Prev';
2507 }
2508 $new_options[self::$opt_gallery_customprev] = $_gallery_custom_prev;
2509
2510
2511 $_gallery_custom_next = 'Next';
2512 try
2513 {
2514 $_gallery_custom_next = trim(strip_tags($_POST[self::$opt_gallery_customnext]));
2515 }
2516 catch (Exception $ex)
2517 {
2518 $_gallery_custom_next = 'Next';
2519 }
2520 $new_options[self::$opt_gallery_customnext] = $_gallery_custom_next;
2521
2522
2523 $_apikey = $all[self::$opt_apikey];
2524 try
2525 {
2526 $_curr_apikey = $all[self::$opt_apikey];
2527 $_schema_apikey = '';
2528 if (isset($_POST[self::$opt_apikey]))
2529 {
2530 $_schema_apikey = trim(str_replace(array(' ', "'", '"'), array('', '', ''), strip_tags($_POST[self::$opt_apikey])));
2531 }
2532
2533 $_gallery_apikey = trim(str_replace(array(' ', "'", '"'), array('', '', ''), strip_tags($_POST[self::$opt_gallery_apikey])));
2534
2535 if (!empty($_schema_apikey) && $_schema_apikey != $_curr_apikey)
2536 {
2537 $_apikey = $_schema_apikey;
2538 }
2539 if (!empty($_gallery_apikey) && $_gallery_apikey != $_curr_apikey)
2540 {
2541 $_apikey = $_gallery_apikey;
2542 }
2543 }
2544 catch (Exception $ex)
2545 {
2546
2547 }
2548 $new_options[self::$opt_apikey] = $_apikey;
2549
2550 // $_hl = '';
2551 // try
2552 // {
2553 // $temphl = strtolower(trim($_POST[self::$opt_hl]));
2554 // $_hl = preg_match('/^[a-z][a-z]$/i', $temphl) ? $temphl : '';
2555 // }
2556 // catch (Exception $ex)
2557 // {
2558 //
2559 // }
2560 // $new_options[self::$opt_hl] = $_hl;
2561
2562 $_dyntype = '';
2563 try
2564 {
2565 if (isset($_POST[self::$opt_dyntype]))
2566 {
2567 $tempdyntype = trim($_POST[self::$opt_dyntype]);
2568 $_dyntype = preg_match('/^[a-zA-Z-]+$/i', $tempdyntype) ? $tempdyntype : '';
2569 }
2570 }
2571 catch (Exception $ex)
2572 {
2573
2574 }
2575 $new_options[self::$opt_dyntype] = $_dyntype;
2576
2577 $_spdcexp = 24;
2578 try
2579 {
2580 $_spdcexp = isset($_POST[self::$opt_spdcexp]) && is_numeric(trim($_POST[self::$opt_spdcexp])) ? intval(trim($_POST[self::$opt_spdcexp])) : $_spdcexp;
2581 }
2582 catch (Exception $ex)
2583 {
2584
2585 }
2586 $new_options[self::$opt_spdcexp] = $_spdcexp;
2587
2588
2589
2590 $all = $new_options + $all;
2591
2592 update_option(self::$opt_alloptions, $all);
2593
2594 try
2595 {
2596 self::spdcpurge();
2597 if ($all[self::$opt_spdc] == 1)
2598 {
2599 wp_remote_get(site_url());
2600 }
2601 }
2602 catch (Exception $ex)
2603 {
2604
2605 }
2606 ?>
2607 <div class="updated"><p><strong><?php _e('Changes saved.'); ?></strong></p></div>
2608 <?php
2609 }
2610
2611
2612 // Now display the settings editing screen
2613
2614 echo '<div class="wrap" style="max-width: 1000px;">';
2615
2616 // header
2617
2618 echo "<h2>" . '<img src="' . plugins_url('images/youtubeicon16.png', __FILE__) . '" /> ' . __('YouTube Settings') . "</h2>";
2619
2620 // settings form
2621 ?>
2622
2623 <style type="text/css">
2624 .wrap {font-family: Arial; color: #000000;}
2625 #ytform p { line-height: 20px; margin-bottom: 11px; }
2626 #ytform ul li {margin-left: 30px; list-style: disc outside none;}
2627 .ytindent {padding: 0px 0px 0px 20px; font-size: 12px;}
2628 .ytindent ul, .ytindent p {font-size: 12px;}
2629 .shadow {-webkit-box-shadow: 0px 0px 20px 0px #000000; box-shadow: 0px 0px 20px 0px #000000;}
2630 .gopro {margin: 0px;}
2631 .gopro img {vertical-align: middle;
2632 width: 19px;
2633 height: 19px;
2634 padding-bottom: 4px;}
2635 .gopro li {margin-bottom: 0px;}
2636 .orange {color: #f85d00;}
2637 .bold {font-weight: bold;}
2638 .grey{color: #888888;}
2639 #goprobox {border-radius: 15px; padding: 10px 15px 15px 15px; margin-top: 15px; border: 3px solid #CCE5EC; position: relative;}
2640 #salenote {position: absolute; right: 10px; top: 10px; width: 75px; height: 30px;}
2641 #nonprosupport {border-radius: 15px; padding: 10px 15px 20px 15px; border: 3px solid #ff6655;}
2642 .pronon {font-weight: bold; color: #f85d00;}
2643 ul.reglist li {margin: 0px 0px 0px 30px; list-style: disc outside none;}
2644 .procol {width: 475px; float: left;}
2645 .ytindent .procol ul {font-size: 11px;}
2646 .smallnote, .ytindent .smallnote {font-style: italic; font-size: 10px;}
2647 .italic {font-style: italic;}
2648 .ytindent h3 {font-size: 15px; line-height: 22px; margin: 5px 0px 10px 0px;}
2649 #wizleftlink {float: left; display: block; width: 240px; font-style: italic; text-align: center; text-decoration: none;}
2650 .button-primary {font-weight: bold; white-space: nowrap;}
2651 p.submit {margin: 10px 0 0 0; padding: 10px 0 5px 0;}
2652 .wp-core-ui p.submit .button-primary {font-size: 20px; height: 50px; padding: 0 20px 1px;
2653 background: #2ea2cc; /* Old browsers */
2654 background: -moz-linear-gradient(top, #2ea2cc 0%, #007396 98%); /* FF3.6+ */
2655 background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2ea2cc), color-stop(98%,#007396)); /* Chrome,Safari4+ */
2656 background: -webkit-linear-gradient(top, #2ea2cc 0%,#007396 98%); /* Chrome10+,Safari5.1+ */
2657 background: -o-linear-gradient(top, #2ea2cc 0%,#007396 98%); /* Opera 11.10+ */
2658 background: -ms-linear-gradient(top, #2ea2cc 0%,#007396 98%); /* IE10+ */
2659 background: linear-gradient(to bottom, #2ea2cc 0%,#007396 98%); /* W3C */
2660 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2ea2cc', endColorstr='#007396',GradientType=0 ); /* IE6-9 */
2661 }
2662 p.submit em {display: inline-block; padding-left: 20px; vertical-align: middle; width: 240px; margin-top: -6px;}
2663 #opt_pro {box-shadow: 0px 0px 5px 0px #1870D5; width: 320px;vertical-align: top;}
2664 #goprobox h3 {font-size: 13px;}
2665 .chx {border-left: 5px solid rgba(100, 100, 100,.1);}
2666 .chx p {margin: 0px 0px 5px 0px;}
2667 .cuz {background-image: linear-gradient(to bottom,#4983FF,#0C5597) !important; color: #ffffff;}
2668 .brightpro {background-image: linear-gradient(to bottom,#ff5500,#cc2200) !important; color: #ffffff;}
2669 #boxdefaultdims {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_defaultdims] ? '' : 'display: none;' ?>}
2670 #boxcustomarrows {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_gallery_customarrows] ? 'display: block;' : 'display: none;' ?>}
2671 #boxchannelsub {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_gallery_channelsub] ? 'display: block;' : 'display: none;' ?>}
2672 .textinput {border-width: 2px !important;}
2673 h3.sect {border-radius: 10px; background-color: #D9E9F7; padding: 5px 5px 5px 10px; position: relative; font-weight: bold;}
2674 h3.sect a {text-decoration: none; color: #E20000;}
2675 h3.sect a.button-primary {color: #ffffff;}
2676 h4.sect {border-radius: 10px; background-color: #D9E9F7; padding: 5px 5px 5px 10px; position: relative; font-weight: bold;}
2677
2678 .ytnav {margin-bottom: 15px;}
2679 .ytnav a {font-weight: bold; display: inline-block; padding: 5px 10px; margin: 0px 20px 0px 0px; border: 1px solid #cccccc; border-radius: 6px;
2680 text-decoration: none; background-color: #ffffff;}
2681 .jumper {height: 25px;}
2682 .ssschema {float: right; width: 350px; height: auto; margin-right: 10px;}
2683 .ssfb {float: right; height: auto; margin-right: 10px; margin-left: 15px; margin-bottom: 10px;}
2684 .totop {position: absolute; right: 20px; top: 5px; color: #444444; font-size: 10px;}
2685 input[type=checkbox] {border: 1px solid #000000;}
2686 .chktitle {display: inline-block; padding: 1px 5px 1px 5px; border-radius: 3px; background-color: #ffffff; border: 1px solid #dddddd;}
2687 b, strong {font-weight: bold;}
2688 input.checkbox[disabled] {border: 1px dashed #444444;}
2689 .pad10 {padding: 10px;}
2690 #boxdohl {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_dohl] ? '' : 'display: none;' ?>}
2691 #boxdyn {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_dynload] ? 'display: block;' : 'display: none;' ?>}
2692 #boxspdc {padding: 0px 10px; <?php echo $all[self::$opt_spdc] ? '' : 'display: none;' ?>}
2693 #boxdefaultvol {font-weight: bold; padding: 0px 10px; <?php echo $all[self::$opt_defaultvol] ? '' : 'display: none;' ?>}
2694 .vol-output {display: none; width: 30px; color: #008800;}
2695 .vol-range {background-color: #dddddd; border-radius: 3px; cursor: pointer;}
2696 input#vol {vertical-align: middle;}
2697 .vol-seeslider {display: none;}
2698 input#spdcexp {width: 70px;}
2699 .indent-option {margin-left: 25px;}
2700 #boxschemaorg {font-weight: bold; padding: 7px 0; <?php echo $all[self::$opt_schemaorg] ? 'display: block;' : 'display: none;' ?>}
2701 #boxmigratelist { <?php echo $all[self::$opt_migrate] ? '' : 'display: none;' ?>}
2702 #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;}
2703 .apikey-msg {display: inline-block; width: 45%; vertical-align: top;}
2704 .apikey-video{margin-left: 3%; display: inline-block; width: 50%; position: relative; padding-top: 29%}
2705 .apikey-video iframe{display: block; width: 100%; height: 100%; position: absolute; top: 0; left: 0;}
2706 #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;' ?>}
2707 .strike {text-decoration: line-through;}
2708 .upgchecks { padding: 20px; border-radius: 15px; border: 1px dotted #777777; background-color: #fcfcfc; }
2709 .clearboth {clear: both;}
2710 div.hr {clear: both; border-bottom: 1px dotted #A8BDD8; margin: 20px 0 20px 0;}
2711 .wp-pointer-buttons a.close {margin-top: 0 !important;}
2712 .pad20{padding: 20px 0 20px 0;}
2713 .ssgallery {float: right; width: 130px; height: auto; margin-left: 15px; border: 3px solid #ffffff;}
2714 .sssubscribe{display: block; width: 400px; height: auto;}
2715 .ssaltgallery {float: right; height: auto; margin-right: 10px; margin-left: 15px; margin-bottom: 10px; width: 350px;}
2716 .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;
2717 -webkit-box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
2718 -moz-box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75);
2719 box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.75); }
2720 </style>
2721 <div class="ytindent">
2722 <br>
2723 <div id="jumphowto"></div>
2724 <div class="ytnav">
2725 <a href="#jumphowto">How To Embed</a>
2726 <a href="#jumpwiz">Visual Wizard</a>
2727 <a href="#jumpdefaults">Defaults</a>
2728 <a href="#jumpcompat">Compatibility</a>
2729 <a href="#jumpgallery">Gallery Settings</a>
2730 <a href="#jumpoverride">Override Defaults</a>
2731 <a target="_blank" href="<?php echo self::$epbase . "/dashboard/pro-easy-video-analytics.aspx?ref=protab" ?>" style="border-color: #888888;">Upgrade?</a>
2732 <a href="#jumpsupport">Support</a>
2733 </div>
2734
2735 <form name="form1" method="post" action="" id="ytform">
2736 <input type="hidden" name="<?php echo $ytprefs_submitted; ?>" value="Y">
2737
2738 <h3 class="sect">
2739 How to Insert a YouTube Video or Playlist &nbsp; <a class="smallnote" href="#jumpgallery">(For gallery directions, go here &raquo;)</a>
2740 </h3>
2741 <p>
2742 <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>
2743 <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).
2744 </p>
2745 <p>
2746 <b>For galleries:</b> <a href="#jumpgallery">Click here</a> to scroll down to gallery settings and directions.
2747 </p>
2748 <p>
2749 <b>For self-contained 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 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.
2750 </p>
2751 <p>
2752 <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.
2753 </p>
2754 <p>
2755 <b>Examples:</b><br><br>
2756 <img style="width: 900px; height: auto;" class="shadow" src="<?php echo plugins_url('images/sshowto.png', __FILE__) ?>" />
2757 </p>
2758 <p>
2759 Always follow these rules for any URL:
2760 </p>
2761 <ul class="reglist">
2762 <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>
2763 <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>
2764 <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>
2765 <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>
2766 <code>[embedyt]http://www.youtube.com/watch?v=ABCDEF[/embedyt] [embedyt]http://www.youtube.com/watch?v=GHIJK[/embedyt]</code>
2767 </ul>
2768
2769 <div class="jumper" id="jumpwiz"></div>
2770 <h3 class="sect">Visual YouTube Wizard <a href="#top" class="totop">&#9650; top</a></h3>
2771
2772 <p>
2773 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.
2774 Simply click the <img style="vertical-align: text-bottom;" src="<?php echo plugins_url('images/wizbuttonbig.png', __FILE__) ?>"> wizard button found above
2775 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.
2776 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
2777 you can click to directly embed the desired video link to your post without having to copy and paste.
2778 </p>
2779 <p>
2780 The ability to read the latest Internet discussions about the videos you want to embed is now free to all users.
2781 </p>
2782 <p>
2783 <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.
2784 <br>
2785 <br>
2786
2787 <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>
2788
2789 </p>
2790 <div class="jumper" id="jumpdefaults"></div>
2791 <h3 class="sect">
2792 <?php _e("Default YouTube Options") ?> <a href="#top" class="totop">&#9650; top</a>
2793 </h3>
2794 <p>
2795 <?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.") ?>
2796 </p>
2797 <?php // self::save_changes_button(); ?>
2798
2799 <div class="ytindent chx">
2800 <p>
2801 <input name="<?php echo self::$opt_glance; ?>" id="<?php echo self::$opt_glance; ?>" <?php checked($all[self::$opt_glance], 1); ?> type="checkbox" class="checkbox">
2802 <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>
2803 </p>
2804 <p>
2805 <input name="<?php echo self::$opt_center; ?>" id="<?php echo self::$opt_center; ?>" <?php checked($all[self::$opt_center], 1); ?> type="checkbox" class="checkbox">
2806 <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>
2807 </p>
2808 <p>
2809 <input name="<?php echo self::$opt_autoplay; ?>" id="<?php echo self::$opt_autoplay; ?>" <?php checked($all[self::$opt_autoplay], 1); ?> type="checkbox" class="checkbox">
2810 <label for="<?php echo self::$opt_autoplay; ?>"><?php _e('<b class="chktitle">Autoplay:</b> Automatically start playing your videos.') ?></label>
2811 </p>
2812 <p>
2813 <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">
2814 <label for="<?php echo self::$opt_iv_load_policy; ?>"><?php _e('<b class="chktitle">Annotations:</b> Show annotations by default.') ?></label>
2815 </p>
2816 <p>
2817 <input name="<?php echo self::$opt_loop; ?>" id="<?php echo self::$opt_loop; ?>" <?php checked($all[self::$opt_loop], 1); ?> type="checkbox" class="checkbox">
2818 <label for="<?php echo self::$opt_loop; ?>"><?php _e('<b class="chktitle">Looping:</b> Loop all your videos.') ?></label>
2819 </p>
2820 <p>
2821 <input name="<?php echo self::$opt_modestbranding; ?>" id="<?php echo self::$opt_modestbranding; ?>" <?php checked($all[self::$opt_modestbranding], 1); ?> type="checkbox" class="checkbox">
2822 <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>
2823 </p>
2824 <p>
2825 <input name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>" <?php checked($all[self::$opt_rel], 1); ?> type="checkbox" class="checkbox">
2826 <label for="<?php echo self::$opt_rel; ?>"><?php _e('<b class="chktitle">Related Videos:</b> Show related videos at the end.') ?></label>
2827 </p>
2828 <p>
2829 <input name="<?php echo self::$opt_showinfo; ?>" id="<?php echo self::$opt_showinfo; ?>" <?php checked($all[self::$opt_showinfo], 1); ?> type="checkbox" class="checkbox">
2830 <label for="<?php echo self::$opt_showinfo; ?>"><?php _e('<b class="chktitle">Show Title:</b> Show the video title and other info.') ?></label>
2831 </p>
2832 <p>
2833 <input name="<?php echo self::$opt_acctitle; ?>" id="<?php echo self::$opt_acctitle; ?>" <?php checked($all[self::$opt_acctitle], 1); ?> type="checkbox" class="checkbox">
2834 <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>
2835 </p>
2836 <p>
2837 <input name="<?php echo self::$opt_theme; ?>" id="<?php echo self::$opt_theme; ?>" <?php checked($all[self::$opt_theme], 'dark'); ?> type="checkbox" class="checkbox">
2838 <label for="<?php echo self::$opt_theme; ?>"><?php _e('<b class="chktitle strike">Dark Theme:</b> Use the dark theme (uncheck to use light theme). <b>Note: YouTube has deprecated this option and will always use the dark theme.</b>') ?></label>
2839 </p>
2840 <p>
2841 <input name="<?php echo self::$opt_color; ?>" id="<?php echo self::$opt_color; ?>" <?php checked($all[self::$opt_color], 'red'); ?> type="checkbox" class="checkbox">
2842 <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>
2843 </p>
2844 <p>
2845 <input name="<?php echo self::$opt_vq; ?>" id="<?php echo self::$opt_vq; ?>" <?php checked($all[self::$opt_vq], 'hd720'); ?> type="checkbox" class="checkbox">
2846 <label for="<?php echo self::$opt_vq; ?>"><?php _e('<b class="chktitle strike">HD Quality:</b> Force HD quality when available. <b>NOTE: YouTube has deprecated this unofficially supported option.</b>') ?> </label>
2847 </p>
2848 <p>
2849 <input name="<?php echo self::$opt_wmode; ?>" id="<?php echo self::$opt_wmode; ?>" <?php checked($all[self::$opt_wmode], 'opaque'); ?> type="checkbox" class="checkbox">
2850 <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>
2851 </p>
2852 <p>
2853 <input name="<?php echo self::$opt_defaultdims; ?>" id="<?php echo self::$opt_defaultdims; ?>" <?php checked($all[self::$opt_defaultdims], 1); ?> type="checkbox" class="checkbox">
2854 <span id="boxdefaultdims">
2855 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;
2856 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;">
2857 </span>
2858
2859 <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>
2860 </p>
2861 <p>
2862 <input name="<?php echo self::$opt_responsive; ?>" id="<?php echo self::$opt_responsive; ?>" <?php checked($all[self::$opt_responsive], 1); ?> type="checkbox" class="checkbox">
2863 <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>
2864 <div id="boxresponsive_all">
2865 <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); ?> >
2866 <label for="<?php echo self::$opt_responsive_all; ?>1">Responsive for all YouTube videos</label> &nbsp;&nbsp;
2867 <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); ?> >
2868 <label for="<?php echo self::$opt_responsive_all; ?>0">Responsive for only videos embedded via this plugin</label>
2869 </div>
2870 </p>
2871 <p>
2872 <input name="<?php echo self::$opt_widgetfit; ?>" id="<?php echo self::$opt_widgetfit; ?>" <?php checked($all[self::$opt_widgetfit], 1); ?> type="checkbox" class="checkbox">
2873 <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>
2874 </p>
2875 <p>
2876 <input name="<?php echo self::$opt_playsinline; ?>" id="<?php echo self::$opt_playsinline; ?>" <?php checked($all[self::$opt_playsinline], 1); ?> type="checkbox" class="checkbox">
2877 <label for="<?php echo self::$opt_playsinline; ?>">
2878 <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.
2879 <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>
2880 </label>
2881 </p>
2882 <p>
2883 <input name="<?php echo self::$opt_origin; ?>" id="<?php echo self::$opt_origin; ?>" <?php checked($all[self::$opt_origin], 1); ?> type="checkbox" class="checkbox">
2884 <label for="<?php echo self::$opt_origin; ?>"><b class="chktitle">Extra Player Security: </b>
2885 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).
2886 </label>
2887 </p>
2888 <p>
2889 <input name="<?php echo self::$opt_nocookie; ?>" id="<?php echo self::$opt_nocookie; ?>" <?php checked($all[self::$opt_nocookie], 1); ?> type="checkbox" class="checkbox">
2890 <span id="boxnocookie">
2891 Uncheck this option if you are planning to embed galleries and playlists on your site. Furthermore, videos on mobile devices may have problems if you leave this checked.
2892 </span>
2893 <label for="<?php echo self::$opt_nocookie; ?>">
2894 <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>
2895 </label>
2896 </p>
2897 <p>
2898 <input name="<?php echo self::$opt_controls; ?>" id="<?php echo self::$opt_controls; ?>" <?php checked($all[self::$opt_controls], 2); ?> type="checkbox" class="checkbox">
2899 <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>
2900 </p>
2901 <p>
2902 <input name="<?php echo self::$opt_autohide; ?>" id="<?php echo self::$opt_autohide; ?>" <?php checked($all[self::$opt_autohide], 1); ?> type="checkbox" class="checkbox">
2903 <label for="<?php echo self::$opt_autohide; ?>"><b class="chktitle strike">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.
2904 <strong>Note: YouTube has deprecated this option, and will always autohide the controls.</strong>
2905 </label>
2906 </p>
2907 <!-- <p>
2908 <input name="<?php echo self::$opt_ssl; ?>" id="<?php echo self::$opt_ssl; ?>" <?php checked($all[self::$opt_ssl], 1); ?> type="checkbox" class="checkbox">
2909 <label for="<?php echo self::$opt_ssl; ?>">
2910 <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.
2911 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>
2912 </label>
2913 </p>-->
2914 <p>
2915 <input name="<?php echo self::$opt_defaultvol; ?>" id="<?php echo self::$opt_defaultvol; ?>" <?php checked($all[self::$opt_defaultvol], 1); ?> type="checkbox" class="checkbox">
2916 <label for="<?php echo self::$opt_defaultvol; ?>">
2917 <b class="chktitle">Volume Initialization: </b>
2918 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>
2919 </label>
2920 <span id="boxdefaultvol">
2921 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]); ?>" >
2922 </span>
2923 </p>
2924
2925 <p>
2926 <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">
2927 <label for="<?php echo self::$opt_cc_load_policy; ?>"><?php _e('<b class="chktitle">Closed Captions:</b> Turn on closed captions by default.') ?></label>
2928 </p>
2929 <p>
2930 <input name="<?php echo self::$opt_dohl; ?>" id="<?php echo self::$opt_dohl; ?>" <?php checked($all[self::$opt_dohl], 1); ?> type="checkbox" class="checkbox">
2931 <!-- <span id="boxdohl">
2932 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">
2933 </span>-->
2934 <label for="<?php echo self::$opt_dohl; ?>"><b class="chktitle">Player Localization / Internationalization: </b>
2935 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>
2936 </p>
2937 <p>
2938 <input name="<?php echo self::$opt_html5; ?>" id="<?php echo self::$opt_html5; ?>" <?php checked($all[self::$opt_html5], 1); ?> type="checkbox" class="checkbox">
2939 <label for="<?php echo self::$opt_html5; ?>">
2940 <b class="chktitle strike">HTML5 First:</b>
2941 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.
2942 </label>
2943 </p>
2944
2945 <p>
2946 <input name="<?php echo self::$opt_playlistorder; ?>" id="<?php echo self::$opt_playlistorder; ?>" <?php checked($all[self::$opt_playlistorder], 1); ?> type="checkbox" class="checkbox">
2947 <label for="<?php echo self::$opt_playlistorder; ?>">
2948 <b class="chktitle">Playlist Ordering:</b>
2949 Check this option if you want your playlists 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).
2950 Note that this is not for setting the thumbnail list order of galleries, just the standard playlist player that YouTube provides.
2951 </label>
2952 </p>
2953
2954
2955
2956 </div>
2957
2958 <div class="jumper" id="jumpcompat"></div>
2959 <h3 class="sect">Compatibility Settings <a href="#top" class="totop">&#9650; top</a></h3>
2960 <p>
2961 With thousands of active users, our plugin may not work with every plugin out there. Below are some settings you may wish to try out.
2962 </p>
2963 <div class="ytindent chx">
2964 <p>
2965 <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">
2966 <label for="<?php echo self::$opt_old_script_method; ?>">
2967 <b class="chktitle">Use Legacy Scripts: </b>
2968 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.
2969 </label>
2970 </p>
2971 <p>
2972 <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">
2973 <label for="<?php echo self::$opt_admin_off_scripts; ?>">
2974 <b class="chktitle">Turn Off Scripts While Editing: </b>
2975 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.
2976 Don't worry, all other visitors to your site will still view your site normally.
2977 </label>
2978 </p>
2979 <p>
2980 <input name="<?php echo self::$opt_migrate; ?>" id="<?php echo self::$opt_migrate; ?>" <?php checked($all[self::$opt_migrate], 1); ?> type="checkbox" class="checkbox">
2981 <label for="<?php echo self::$opt_migrate; ?>">
2982 <b class="chktitle">Migrate Shortcodes: </b> Inherit other shortcodes.
2983 </label>
2984 <div id="boxmigratelist">
2985 <ul>
2986 <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>
2987 <li class="smallnote orange" style="list-style: none;">This feature is beta. More shortcodes coming.</li>
2988 </ul>
2989
2990 </div>
2991 </p>
2992 <p>
2993 <input name="<?php echo self::$opt_oldspacing; ?>" id="<?php echo self::$opt_oldspacing; ?>" <?php checked($all[self::$opt_oldspacing], 1); ?> type="checkbox" class="checkbox">
2994 <label for="<?php echo self::$opt_oldspacing; ?>">
2995 <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.
2996 </label>
2997 </p>
2998 <p>
2999 <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">
3000 <label for="<?php echo self::$opt_evselector_light; ?>">
3001 <b class="chktitle">Theme Video Problems: </b>
3002 Check this option if you're having issues with autoplayed videos or background videos etc. that have been generated by your theme.
3003 </label>
3004 </p>
3005 <p>
3006 <input name="<?php echo self::$opt_debugmode; ?>" id="<?php echo self::$opt_debugmode; ?>" <?php checked($all[self::$opt_debugmode], 1); ?> type="checkbox" class="checkbox">
3007 <label for="<?php echo self::$opt_debugmode; ?>">
3008 <b class="chktitle">Debug Mode: </b> If you ask for support, we may ask you to turn on debug mode here.
3009 It may print out some diagnostic info so that we can help you solve your issue.
3010 </label>
3011 </p>
3012
3013 </div>
3014 <div class="jumper" id="jumpgallery"></div>
3015 <h3 class="sect">Gallery Settings and Directions <a href="#top" class="totop">&#9650; top</a></h3>
3016 <img class="ssgallery" src="<?php echo plugins_url('images/ssgallery.png', __FILE__) ?>">
3017 <p>
3018 <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>.
3019 Don't worry, it's an easy process. Just <a href="https://www.youtube.com/watch?v=px8LvNIVblg" target="_blank">click this link &raquo;</a> and follow the video on that page to get your API key. Then paste it in the "YouTube API Key" box below, and click the "Save Changes" button.
3020 </p>
3021 <p>
3022 <b>Playlist Galleries:</b> To display a self-contained playlist as a gallery with thumbnails, simply add the following parameter to the end of your playlist url:
3023 </p>
3024 <p><code>&layout=gallery</code></p>
3025 <p>For example, below is a playlist that has been converted into a gallery. Notice the new layout parameter, with no spaces:</p>
3026 <p>
3027 <code>[embedyt]https://www.youtube.com/playlist?list=PLx0sYbCqOb8TBPRdmBHs5Iftvv9TPboYG&layout=gallery[/embedyt]</code>
3028 </p>
3029 <p>
3030 <b>Channel Galleries:</b> To display a channel as a gallery with thumbnails, <a href="https://youtu.be/XvFL-Rr-2Qo" target="_blank">watch the first minute and a half of this video </a>.
3031 </p>
3032
3033
3034
3035 <p class="smallnote">
3036 Note: The PRO wizard has steps to visually create and customize playlist, channel, and gallery codes like the above.
3037 </p>
3038 <p>
3039 Below are the settings for galleries:
3040 </p>
3041 <div class="ytindent chx">
3042 <p>
3043 <b class="chktitle">YouTube API Key:</b>
3044 <input type="text" name="<?php echo self::$opt_gallery_apikey; ?>" id="<?php echo self::$opt_gallery_apikey; ?>" value="<?php echo trim($all[self::$opt_apikey]); ?>" class="textinput" style="width: 250px;">
3045 Required so your site can get the thumbnails, title text, and other content from YouTube's servers that used to render galleries. <a href="https://www.youtube.com/watch?v=px8LvNIVblg" target="_blank">Click this link &raquo;</a> and follow the video to the right to get your API key.
3046 </p>
3047 <p>
3048 <label for="<?php echo self::$opt_gallery_pagesize; ?>"><b class="chktitle">Gallery Page Size:</b></label>
3049 <select name="<?php echo self::$opt_gallery_pagesize; ?>" id="<?php echo self::$opt_gallery_pagesize; ?>" style="width: 60px;">
3050 <?php
3051 $gps_val = intval(trim($all[self::$opt_gallery_pagesize]));
3052 $gps_val = min($gps_val, 50);
3053 for ($gps = 1; $gps <= 50; $gps++)
3054 {
3055 ?><option <?php echo $gps_val == $gps ? 'selected' : '' ?> value="<?php echo $gps ?>"><?php echo $gps ?></option>
3056 <?php
3057 }
3058 ?>
3059 </select>
3060 Enter how many thumbnails per page should be shown at once (YouTube allows a maximum of 50 per page).
3061 </p>
3062 <p>
3063 <label for="<?php echo self::$opt_gallery_columns; ?>"><b class="chktitle">Number of Columns:</b></label>
3064 <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 trim($all[self::$opt_gallery_columns]); ?>">
3065 Enter how many thumbnails can fit per row.
3066 </p>
3067 <p>
3068 <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">
3069 <label for="<?php echo self::$opt_gallery_showpaging; ?>"><b class="chktitle">Show Pagination:</b> <sup class="orange">NEW</sup> Show the Next/Previous buttons and page numbering.</label>
3070 </p>
3071 <p>
3072 <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">
3073 <label for="<?php echo self::$opt_gallery_customarrows; ?>">
3074 <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.
3075 </label>
3076 <span id="boxcustomarrows">
3077 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;
3078 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;">
3079 </span>
3080 </p>
3081 <p>
3082 <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">
3083 <label for="<?php echo self::$opt_gallery_channelsub; ?>">
3084 <b class="chktitle">Show Subscribe Button: </b> <sup class="orange">NEW</sup> 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.
3085 </label>
3086 <span id="boxchannelsub">
3087 Channel URL: <input type="text" placeholder="https://www.youtube.com/user/YourChannel" name="<?php echo self::$opt_gallery_channelsublink; ?>" id="<?php echo self::$opt_gallery_channelsublink; ?>" value="<?php echo esc_attr(trim($all[self::$opt_gallery_channelsublink])); ?>" class="textinput" style="width: 200px;"> &nbsp;
3088 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;">
3089 </span>
3090 </p>
3091 <p><img class="sssubscribe" src="<?php echo plugins_url('images/sssubscribe.png', __FILE__) ?>"></p>
3092
3093 <p>
3094 <label for="<?php echo self::$opt_gallery_scrolloffset; ?>"><b class="chktitle">Scroll Offset:</b></label>
3095 <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 trim($all[self::$opt_gallery_scrolloffset]); ?>">
3096 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.
3097 </p>
3098 <p>
3099 <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">
3100 <label for="<?php echo self::$opt_gallery_showtitle; ?>"><b class="chktitle">Show Thumbnail Title:</b> Show titles with each thumbnail.</label>
3101 </p>
3102 <p>
3103 <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">
3104 <label for="<?php echo self::$opt_gallery_autonext; ?>"><b class="chktitle">Automatic Continuous Play:</b> <sup class="orange">NEW</sup> Automatically play the next video in the gallery as soon as the current video finished.</label>
3105 </p>
3106 <p>
3107 <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">
3108 <label for="<?php echo self::$opt_gallery_thumbplay; ?>"><b class="chktitle">Thumbnail Click Plays Video:</b> <sup class="orange">NEW</sup> Clicking on a gallery thumbnail autoplays the video. Uncheck this and visitors must also click the video's play button after clicking the thumbnail.</label>
3109 </p>
3110 <div class="pad20">
3111 <p>
3112 <strong class="orange">Note:</strong> We have an instructional video that shows how to generate the codes needed to embed two different types of galleries using the FREE and PRO version of the plugin:
3113 </p>
3114 <ol>
3115 <li>a gallery from an entire YouTube channel, and</li>
3116 <li>a gallery from a specific playlist</li>
3117 </ol>
3118 <p>
3119 We advise that you <a href="https://www.youtube.com/watch?v=XvFL-Rr-2Qo" target="_blank">watch the video here &raquo;</a> with YouTube.com annotations turned on so you don't miss important steps.
3120 The PRO wizard is an alternate way to fully create playlist, channel, and gallery codes.
3121 </p>
3122 </div>
3123 </div>
3124
3125 <?php // self::save_changes_button(); ?>
3126
3127 <div class="upgchecks">
3128 <h3 class="sect">PRO Features</h3>
3129 <?php
3130 if ($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 9)
3131 {
3132 ?>
3133 <p class="smallnote orange">Below are PRO features for enhanced SEO and performance (works for even past embed links). Gallery options for PRO users will also be listed here.</p>
3134 <p>
3135 <img class="ssaltgallery" src="<?php echo plugins_url('images/ssaltgalleryall.jpg', __FILE__) ?>" />
3136 <?php $cleanstyle = trim($all[self::$opt_gallery_style]); ?>
3137 <select name="<?php echo self::$opt_gallery_style; ?>" id="<?php echo self::$opt_gallery_style; ?>" >
3138 <option value="">Gallery Style</option>
3139 <option value="grid" <?php echo 'grid' === $cleanstyle ? 'selected' : '' ?> >Grid (default)</option>
3140 <option value="listview" <?php echo 'listview' === $cleanstyle ? 'selected' : '' ?> >Vertical List</option>
3141 <option value="carousel" <?php echo 'carousel' === $cleanstyle ? 'selected' : '' ?> >Horizontal Slider</option>
3142 </select>
3143 <label for="<?php echo self::$opt_gallery_style; ?>">
3144 <b>(PRO)</b> <b class="chktitle">Alternate Gallery Styling:</b></b>
3145 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.
3146 <a target="_blank" href="<?php echo self::$epbase ?>/responsive-youtube-playlist-channel-gallery-for-wordpress.aspx">Read more here &raquo;</a>
3147 </label>
3148 </p>
3149
3150 <div class="hr"></div>
3151 <p>
3152 <img class="ssaltgallery" src="<?php echo plugins_url('images/ssverticallayout.png', __FILE__) ?>" />
3153 <input name="<?php echo self::$opt_gallery_showdsc; ?>" id="<?php echo self::$opt_gallery_showdsc; ?>" <?php checked($all[self::$opt_gallery_showdsc], 1); ?> type="checkbox" class="checkbox">
3154 <label for="<?php echo self::$opt_gallery_showdsc; ?>">
3155 <b>(PRO)</b> <b class="chktitle">Show Gallery Descriptions (for vertical list styling): </b>
3156 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.
3157 </label>
3158 </p>
3159 <div class="hr"></div>
3160 <p>
3161 <img class="ssaltgallery" src="<?php echo plugins_url('images/ssaltgallerycircles.jpg', __FILE__) ?>" />
3162 <?php $cleancrop = trim($all[self::$opt_gallery_thumbcrop]); ?>
3163 <select name="<?php echo self::$opt_gallery_thumbcrop; ?>" id="<?php echo self::$opt_gallery_thumbcrop; ?>" >
3164 <option value="">Thumbnail Shape</option>
3165 <option value="box" <?php echo 'box' === $cleancrop ? 'selected' : '' ?> >Rectangle (default)</option>
3166 <option value="portal" <?php echo 'portal' === $cleancrop ? 'selected' : '' ?> >Circular</option>
3167 </select>
3168 <label for="<?php echo self::$opt_gallery_thumbcrop; ?>">
3169 <b>(PRO)</b> <b class="chktitle">Gallery Thumbnail Shape:</b></b>
3170 Differentiate your gallery by showing different thumbnail shapes. We currently offer rectangle and circle shapes.
3171 </label>
3172 </p>
3173 <div class="hr"></div>
3174
3175 <p>
3176 <input name="<?php echo self::$opt_spdc; ?>" id="<?php echo self::$opt_spdc; ?>" <?php checked($all[self::$opt_spdc], 1); ?> type="checkbox" class="checkbox">
3177 <label for="<?php echo self::$opt_spdc; ?>">
3178 <b>(PRO)</b> <b class="chktitle">Faster Page Loads (Caching): </b>
3179 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.
3180 </label>
3181 <div class="indent-option">
3182 <div id="boxspdc">
3183 <label>
3184 <b class="chktitle">Cache Liftime (hours): </b>
3185 <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"/>
3186 </label>
3187 Tip: If your pages rarely change, you may wish to set this to a much higher value than 24 hours.
3188
3189 <div class="pad20">
3190 <input type="button" class="button button-primary" value="Click to clear YouTube cache"/>
3191 <span style="display: none;" id="clearspdcloading" class="orange bold">Clearing...</span>
3192 <span class="orange bold" style="display: none;" id="clearspdcsuccess">Finished clearing YouTube cache.</span>
3193 <span class="orange bold" style="display: none;" id="clearspdcfailed">Sorry, there seemed to be a problem clearing the cache.</span>
3194 </div>
3195 </div>
3196 </div>
3197 </p>
3198 <div class="hr"></div>
3199
3200 <p>
3201 <input name="<?php echo self::$opt_schemaorg; ?>" id="<?php echo self::$opt_schemaorg; ?>" <?php checked($all[self::$opt_schemaorg], 1); ?> type="checkbox" class="checkbox">
3202 <label for="<?php echo self::$opt_schemaorg; ?>">
3203 <b>(PRO)</b> <b class="chktitle">Video SEO Tags:</b> Update your YouTube embeds with Google, Bing, and Yahoo friendly schema markup for videos.
3204 </label>
3205 <span id="boxschemaorg">
3206 <span class="apikey-msg">
3207 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,
3208 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.
3209 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:
3210 <br>
3211 <span style="vertical-align: middle; display: inline-block;">
3212 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;">
3213 </span>
3214 </span>
3215 <span class="apikey-video">
3216 <iframe width="384" height="216" src="https://www.youtube.com/embed/px8LvNIVblg?rel=0" frameborder="0" allowfullscreen></iframe>
3217 </span>
3218 </span>
3219 </p>
3220 <div class="hr"></div>
3221 <p>
3222 <input name="<?php echo self::$opt_dynload; ?>" id="<?php echo self::$opt_dynload; ?>" <?php checked($all[self::$opt_dynload], 1); ?> type="checkbox" class="checkbox">
3223 <label for="<?php echo self::$opt_dynload; ?>">
3224 <b>(PRO)</b> <b class="chktitle">Special Lazy-Loading Effects:</b>
3225 Add eye-catching special 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>
3226 </label>
3227 <br>
3228 <span id="boxdyn">
3229 Animation:
3230 <?php $cleandyn = trim($all[self::$opt_dyntype]); ?>
3231 <select name="<?php echo self::$opt_dyntype; ?>" id="<?php echo self::$opt_dyntype; ?>" >
3232 <option value="">Select type</option>
3233 <option value="rotateIn" <?php echo 'rotateIn' === $cleandyn ? 'selected' : '' ?> >rotate in</option>
3234 <option value="slideInRight" <?php echo 'slideInRight' === $cleandyn ? 'selected' : '' ?> >slide from right</option>
3235 <option value="slideInLeft" <?php echo 'slideInLeft' === $cleandyn ? 'selected' : '' ?> >slide from left</option>
3236 <option value="bounceIn" <?php echo 'bounceIn' === $cleandyn ? 'selected' : '' ?> >bounce in</option>
3237 <option value="flipInX" <?php echo 'flipInX' === $cleandyn ? 'selected' : '' ?> >flip up/down</option>
3238 <option value="flipInY" <?php echo 'flipInY' === $cleandyn ? 'selected' : '' ?> >flip left/right</option>
3239 <option value="pulse" <?php echo 'pulse' === $cleandyn ? 'selected' : '' ?> >pulse</option>
3240 <option value="tada" <?php echo 'tada' === $cleandyn ? 'selected' : '' ?> >jiggle</option>
3241 <option value="fadeInDown" <?php echo 'fadeInDown' === $cleandyn ? 'selected' : '' ?> >fade in downward</option>
3242 <option value="fadeInUp" <?php echo 'fadeInUp' === $cleandyn ? 'selected' : '' ?> >fade in upward</option>
3243 <option value="zoomInDown" <?php echo 'zoomInDown' === $cleandyn ? 'selected' : '' ?> >zoom in downward</option>
3244 <option value="zoomInUp" <?php echo 'zoomInUp' === $cleandyn ? 'selected' : '' ?> >zoom in upward</option>
3245 </select>
3246 </span>
3247 </p>
3248 <div class="hr"></div>
3249 <p>
3250 <img class="ssfb" src="<?php echo plugins_url('images/ssfb.jpg', __FILE__) ?>" />
3251 <input name="<?php echo self::$opt_ogvideo; ?>" id="<?php echo self::$opt_ogvideo; ?>" <?php checked($all[self::$opt_ogvideo], 1); ?> type="checkbox" class="checkbox">
3252 <label for="<?php echo self::$opt_ogvideo; ?>">
3253 <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.
3254 </label>
3255 </p>
3256 <div class="hr"></div>
3257 <p>
3258 <img class="ssfb" src="<?php echo plugins_url('images/youtube_thumbnail_sample.jpg', __FILE__) ?>" />
3259 <input name="<?php echo self::$opt_ftpostimg; ?>" id="<?php echo self::$opt_ftpostimg; ?>" <?php checked($all[self::$opt_ftpostimg], 1); ?> type="checkbox" class="checkbox">
3260 <label for="<?php echo self::$opt_ftpostimg; ?>">
3261 <b>(PRO)</b> <b class="chktitle">Automatic Video Thumbnails: </b>
3262 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!
3263 (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>
3264 </label>
3265 </p>
3266
3267 <?php
3268 }
3269 else
3270 {
3271 ?>
3272 <p class="smallnote orange">Below are PRO features for enhanced SEO and performance (works for even past embed links). </p>
3273 <p>
3274 <img class="ssaltgallery" src="<?php echo plugins_url('images/ssaltgalleryall.jpg', __FILE__) ?>" />
3275 <select disabled>
3276 <option value="">Gallery Style</option>
3277 </select>
3278 <label>
3279 <b class="chktitle">Alternate Gallery Styling: </b> <span class="pronon">(PRO Users)</span>
3280 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.
3281 <a target="_blank" href="<?php echo self::$epbase ?>/responsive-youtube-playlist-channel-gallery-for-wordpress.aspx">Read more here &raquo;</a>
3282 </label>
3283 </p>
3284
3285 <div class="hr"></div>
3286 <p>
3287 <img class="ssaltgallery" src="<?php echo plugins_url('images/ssverticallayout.png', __FILE__) ?>" />
3288 <input disabled type="checkbox" class="checkbox">
3289 <label>
3290 <b class="chktitle">Show Gallery Descriptions (for vertical list styling): </b> <span class="pronon">(PRO Users)</span>
3291 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.
3292 </label>
3293 </p>
3294 <div class="hr"></div>
3295 <p>
3296 <img class="ssaltgallery" src="<?php echo plugins_url('images/ssaltgallerycircles.jpg', __FILE__) ?>" />
3297 <select disabled>
3298 <option value="">Select Thumbnail Shape</option>
3299 </select>
3300 <label>
3301 <b class="chktitle">Gallery Thumbnail Shape: </b> <span class="pronon">(PRO Users)</span>
3302 Differentiate your gallery by showing different thumbnail shapes. We currently offer rectangle and circle shapes.
3303 <a target="_blank" href="<?php echo self::$epbase ?>/responsive-youtube-playlist-channel-gallery-for-wordpress.aspx">Read more here &raquo;</a>
3304 </label>
3305 </p>
3306
3307 <div class="hr"></div>
3308 <p>
3309 <input disabled type="checkbox" class="checkbox">
3310 <label>
3311 <b class="chktitle">Faster Page Loads (Caching): </b> <span class="pronon">(PRO Users)</span>
3312 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.
3313 </label>
3314 <div class="indent-option">
3315 <label>
3316 <b class="chktitle">Cache Lifetime (hours): </b>
3317 <input disabled value="24" type="number">
3318 Tip: If your pages rarely change, you may wish to set this to a much higher value than 24 hours.
3319 </label>
3320 </div>
3321 </p>
3322 <div class="hr"></div>
3323
3324
3325 <p>
3326 <input disabled type="checkbox" class="checkbox">
3327 <label>
3328 <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.
3329 </label>
3330 </p>
3331 <div class="hr"></div>
3332 <p>
3333 <input disabled type="checkbox" class="checkbox">
3334 <label>
3335 <b class="chktitle">Special Loading Effects:</b> <span class="pronon">(PRO Users)</span>
3336 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>
3337 </label>
3338 </p>
3339 <div class="hr"></div>
3340 <p>
3341 <img class="ssfb" src="<?php echo plugins_url('images/ssfb.jpg', __FILE__) ?>" />
3342 <input disabled type="checkbox" class="checkbox">
3343 <label>
3344 <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.
3345 </label>
3346 </p>
3347 <div class="hr"></div>
3348 <p>
3349 <img class="ssfb" src="<?php echo plugins_url('images/youtube_thumbnail_sample.jpg', __FILE__) ?>" />
3350 <input disabled type="checkbox" class="checkbox">
3351 <label>
3352 <b class="chktitle">Automatic Video Thumbnails:</b> <span class="pronon">(PRO Users)</span>
3353 Automatically grab the thumbnail image of the first video embedded in each post or page, and use it as the featured image.
3354 All you have to do is click Update on a post or page and the plugin does the rest!
3355 (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>
3356 </label>
3357 </p>
3358 <div class="hr"></div>
3359 <p>
3360 <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" target="_blank">Activate the above and several other features &raquo;</a>
3361 </p>
3362 <?php
3363 }
3364 ?>
3365 <div class="clearboth"></div>
3366 </div>
3367 <?php // self::save_changes_button(); ?>
3368
3369 <hr>
3370
3371
3372 <div class="jumper" id="jumpoverride"></div>
3373
3374 <h3 class="sect">
3375 <?php _e("How To Override Defaults / Other Options") ?> <a href="#top" class="totop">&#9650; top</a>
3376 </h3>
3377 <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 '&'.
3378 <br><span class="smallnote orange">PRO users: You can use the big blue <a href="<?php echo self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=protab' ?>" target="_blank">customize</a> buttons that you will see inside the wizard, instead of memorizing the following.</span>
3379 <?php
3380 _e('<ul>');
3381 _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>");
3382 _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>");
3383 _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>");
3384 _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>");
3385 _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>");
3386 _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>");
3387 _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>");
3388 _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>");
3389 _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>");
3390 _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>");
3391 _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>");
3392 _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>");
3393 _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>");
3394 _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>");
3395 _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>");
3396 _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>");
3397 _e('</ul>');
3398
3399 _e("<p>You can also start and end each individual video at particular times. Like the above, each option should begin with '&'</p>");
3400 _e('<ul>');
3401 _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>");
3402 _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>");
3403 _e('</ul>');
3404 ?>
3405 <div class="save-changes-follow"> <?php self::save_changes_button(isset($_POST[$ytprefs_submitted]) && $_POST[$ytprefs_submitted] == 'Y'); ?> </div>
3406 </form>
3407 <div class="jumper" id="jumppro"></div>
3408 <div id="goprobox">
3409 <?php
3410 if ($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0)
3411 {
3412 echo "<h3>" . __('Thank you for going PRO.');
3413 echo ' &nbsp;<input type="submit" name="showkey" class="button-primary" style="vertical-align: 15%;" id="showprokey" value="View my PRO key" />';
3414 echo "</h3>";
3415 ?>
3416 <?php
3417 }
3418 else
3419 {
3420 ?>
3421
3422 <h3 class="sect">
3423 <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;
3424 PRO users help keep new features coming and our coffee cups filled. Go PRO and get these perks in return:
3425 </h3>
3426 <div class="procol">
3427 <ul class="gopro">
3428 <li>
3429 <img src="<?php echo plugins_url('images/iconcache.png', __FILE__) ?>">
3430 Faster Page Loads (Caching)
3431 </li>
3432 <li>
3433 <img src="<?php echo plugins_url('images/iconwizard.png', __FILE__) ?>">
3434 Full Visual Embedding Wizard (Easily customize embeds without memorizing codes)
3435 </li>
3436 <li>
3437 <img src="<?php echo plugins_url('images/icongallery.png', __FILE__) ?>">
3438 Alternate Gallery Styling
3439 </li>
3440 <li>
3441 <img src="<?php echo plugins_url('images/iconfx.png', __FILE__) ?>">
3442 Add eye-catching special effects as your videos load
3443 </li>
3444 <li>
3445 <img src="<?php echo plugins_url('images/deletechecker.png', __FILE__) ?>">
3446 Deleted Video Checker (alerts you if YouTube deletes videos you embedded)
3447 </li>
3448 <li>
3449 <img src="<?php echo plugins_url('images/globe.png', __FILE__) ?>">
3450 Alerts when visitors from different countries are blocked from viewing your embeds
3451 </li>
3452 <li>
3453 <img src="<?php echo plugins_url('images/mobilecompat.png', __FILE__) ?>">
3454 Check if your embeds have restrictions that can block mobile viewing
3455 </li>
3456
3457 </ul>
3458 </div>
3459 <div class="procol" style="max-width: 465px;">
3460 <ul class="gopro">
3461 <li>
3462 <img src="<?php echo plugins_url('images/videothumbs.png', __FILE__) ?>">
3463 Automatic video thumbnail images (just click 'Update')
3464 </li>
3465 <li>
3466 <img src="<?php echo plugins_url('images/prioritysupport.png', __FILE__) ?>">
3467 Priority support (Puts your request in front)
3468 </li>
3469 <li>
3470 <img src="<?php echo plugins_url('images/bulletgraph45.png', __FILE__) ?>">
3471 User-friendly video analytics dashboard
3472 </li>
3473
3474 <li id="fbstuff">
3475 <img src="<?php echo plugins_url('images/iconfb.png', __FILE__) ?>">
3476 Automatic Open Graph tagging for Facebook
3477 </li>
3478 <!-- <li>
3479 <img src="<?php echo plugins_url('images/iconythealth.png', __FILE__) ?>">
3480 Instant YouTube embed diagnostic reports
3481 </li> -->
3482 <li>
3483 <img src="<?php echo plugins_url('images/vseo.png', __FILE__) ?>">
3484 Automatic tagging for video SEO (will even work for your old embeds)
3485 </li>
3486 <li>
3487 <img src="<?php echo plugins_url('images/iconvolume.png', __FILE__) ?>">
3488 Fine-Grained Volume Initialization – Individual video volume settings in the wizard
3489 </li>
3490
3491 <li>
3492 <img src="<?php echo plugins_url('images/infinity.png', __FILE__) ?>">
3493 Unlimited PRO upgrades and downloads
3494 </li>
3495 <!-- <li>
3496 <img src="<?php echo plugins_url('images/questionsale.png', __FILE__) ?>">
3497 What else? You tell us!
3498 </li> -->
3499 </ul>
3500 </div>
3501 <div style="clear: both;"></div>
3502 <br>
3503 <h3 class="bold">Enter and save your PRO key (emailed to you):</h3>
3504 <?php } ?>
3505 <form name="form2" method="post" action="" id="epform2" class="submitpro" <?php
3506 if ($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0)
3507 {
3508 echo 'style="display: none;"';
3509 }
3510 ?>>
3511
3512 <input name="<?php echo self::$opt_pro; ?>" id="opt_pro" value="<?php echo $all[self::$opt_pro]; ?>" type="text">
3513 <input type="submit" name="Submit" class="button-primary" id="prokeysubmit" value="<?php _e('Save Key') ?>" />
3514 <?php
3515 if (!($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0))
3516 {
3517 ?>
3518 &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>
3519 <?php
3520 }
3521 ?>
3522 <br>
3523 <span style="display: none;" id="prokeyloading" class="orange bold">Verifying...</span>
3524 <span class="orange bold" style="display: none;" id="prokeysuccess">Success! Please refresh this page.</span>
3525 <span class="orange bold" style="display: none;" id="prokeyfailed">Sorry, that seems to be an invalid key, or it has been used already. If you're behind a firewall, you may need to try activating on another network.</span>
3526 <span class="orange bold" style="display: none;" id="prokeycancel">Your request is being processed. Response code: CR1.</span>
3527
3528 </form>
3529
3530 </div>
3531 <div class="smallnote">
3532 <!--&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>
3533 writing/editing. It will apply some experimental artificial intelligence techniques on your post content for these recommendations, all at the click of a button.
3534 -->
3535 </div>
3536 <div class="jumper" id="jumpsupport"></div>
3537 <div id="nonprosupport">
3538 <h3 class="bold">Support tips for all users (Free and PRO)</h3>
3539 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:
3540 <ul class="reglist">
3541 <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>
3542 <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>
3543 <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>
3544 <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>
3545 <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>
3546 <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)
3547 </li>
3548 <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>
3549 <li>If your videos always appear full size, try turning off "Responsive video sizing."</li>
3550 <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>
3551 </ul>
3552 <p>
3553 Deactivating the No Cookies option has also been proven to solve player errors.
3554 </p>
3555 <p>
3556 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>
3557 </p>
3558 </div>
3559 <br>
3560 <h3 class="sect">
3561 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>
3562 </h3>
3563 <p>
3564 <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.
3565 </p>
3566
3567
3568 <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>
3569
3570 <?php
3571 if (!($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0))
3572 {
3573 ?>
3574 <br>
3575 <br>
3576 <iframe src="<?php echo self::$epbase ?>/dashboard/likecoupon.aspx" width="600" height="500"></iframe>
3577 <?php }
3578 ?>
3579 <div class="ytnav">
3580 <a href="#jumphowto">How To Embed</a>
3581 <a href="#jumpwiz">Visual Wizard</a>
3582 <a href="#jumpdefaults">Defaults</a>
3583 <a href="#jumpcompat">Compatibility</a>
3584 <a href="#jumpgallery">Gallery Settings</a>
3585 <a href="#jumpoverride">Override Defaults</a>
3586 <a target="_blank" href="<?php echo self::$epbase . "/dashboard/pro-easy-video-analytics.aspx?ref=protab" ?>" style="border-color: #888888;">Upgrade?</a>
3587 <a href="#jumpsupport">Support</a>
3588 </div>
3589
3590
3591 <script type="text/javascript">
3592
3593 function savevalidate()
3594 {
3595 var valid = true;
3596 var alertmessage = '';
3597 if (jQuery("#<?php echo self::$opt_defaultdims; ?>").is(":checked"))
3598 {
3599 if (!(jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_defaultwidth; ?>").val())) &&
3600 jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_defaultheight; ?>").val()))))
3601 {
3602 alertmessage += "Please enter valid numbers for default height and width, or uncheck the option.";
3603 jQuery("#boxdefaultdims input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
3604 valid = false;
3605 }
3606 }
3607
3608 if (jQuery("#<?php echo self::$opt_gallery_customarrows; ?>").is(":checked"))
3609 {
3610 if (!jQuery.trim(jQuery("#<?php echo self::$opt_gallery_customprev; ?>").val()) ||
3611 !jQuery.trim(jQuery("#<?php echo self::$opt_gallery_customnext; ?>").val()))
3612 {
3613 alertmessage += "Please enter valid text for both the custom gallery Prev and Next buttons, or uncheck the option.";
3614 jQuery("#boxcustomarrows input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
3615 valid = false;
3616 }
3617 }
3618
3619
3620 if (jQuery("#<?php echo self::$opt_gallery_channelsub; ?>").is(":checked"))
3621 {
3622 if (!jQuery.trim(jQuery("#<?php echo self::$opt_gallery_channelsublink; ?>").val()) ||
3623 !jQuery.trim(jQuery("#<?php echo self::$opt_gallery_channelsubtext; ?>").val()))
3624 {
3625 alertmessage += "Please enter valid text for both the subscribe text and subscribe URL, or uncheck the option.";
3626 jQuery("#boxchannelsub input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
3627 valid = false;
3628 }
3629 }
3630
3631 if (jQuery("#<?php echo self::$opt_defaultvol; ?>").is(":checked"))
3632 {
3633 if (!(jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_vol; ?>").val()))))
3634 {
3635 alertmessage += "Please enter a number between 0 and 100 for the default volume, or uncheck the option.";
3636 jQuery("#boxdefaultvol input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
3637 valid = false;
3638 }
3639 }
3640
3641 if (jQuery("#<?php echo self::$opt_spdc; ?>").is(":checked"))
3642 {
3643 if (!(jQuery.isNumeric(jQuery.trim(jQuery("#<?php echo self::$opt_spdcexp; ?>").val()))))
3644 {
3645 alertmessage += "Please enter a valid number of hours (greater than 0) for the cache lifetime, or uncheck the option.";
3646 jQuery("#boxspdc input[type=number], #boxspdc input[type=text]").css("background-color", "#ffcccc").css("border", "2px solid #000000");
3647 valid = false;
3648 }
3649 }
3650
3651
3652
3653 if (jQuery("#<?php echo self::$opt_schemaorg; ?>").is(":checked"))
3654 {
3655 if (!(jQuery.trim(jQuery("#<?php echo self::$opt_apikey; ?>").val()).length > 0))
3656 {
3657 alertmessage += "Please enter a valid YouTube API key, or uncheck the 'Video SEO Tags' option.";
3658 jQuery("#boxschemaorg input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
3659 valid = false;
3660 }
3661 }
3662
3663
3664
3665 if (jQuery("#<?php echo self::$opt_dynload; ?>").is(":checked"))
3666 {
3667 if (!(/^[A-Za-z-]+$/.test(jQuery.trim(jQuery("#<?php echo self::$opt_dyntype; ?>").val()))))
3668 {
3669 alertmessage += "Please select an animation, or uncheck the option.";
3670 jQuery("#boxdyn select").css("background-color", "#ffcccc").css("border", "2px solid #000000");
3671 valid = false;
3672 }
3673 }
3674
3675
3676
3677
3678 // if (jQuery("#<?php echo self::$opt_dohl; ?>").is(":checked"))
3679 // {
3680 // if (!(/^[A-Za-z][A-Za-z]$/.test(jQuery.trim(jQuery("#<?php echo self::$opt_hl; ?>").val()))))
3681 // {
3682 // alertmessage += "Please enter a valid 2-letter language code.";
3683 // jQuery("#boxdohl input").css("background-color", "#ffcccc").css("border", "2px solid #000000");
3684 // valid = false;
3685 // }
3686 // }
3687
3688 if (!valid)
3689 {
3690 alert(alertmessage);
3691 }
3692 return valid;
3693 }
3694
3695 var prokeyval;
3696 var mydomain = escape("http://" + window.location.host.toString());
3697
3698 jQuery(document).ready(function ($) {
3699 jQuery('#<?php echo self::$opt_defaultdims; ?>').change(function ()
3700 {
3701 if (jQuery(this).is(":checked"))
3702 {
3703 jQuery("#boxdefaultdims").show(500);
3704 }
3705 else
3706 {
3707 jQuery("#boxdefaultdims").hide(500);
3708 }
3709
3710 });
3711
3712 jQuery('#<?php echo self::$opt_gallery_customarrows; ?>').change(function ()
3713 {
3714 if (jQuery(this).is(":checked"))
3715 {
3716 jQuery("#boxcustomarrows").show(500);
3717 }
3718 else
3719 {
3720 jQuery("#boxcustomarrows").hide(500);
3721 }
3722
3723 });
3724
3725 jQuery('#<?php echo self::$opt_gallery_channelsub; ?>').change(function ()
3726 {
3727 if (jQuery(this).is(":checked"))
3728 {
3729 jQuery("#boxchannelsub").show(500);
3730 }
3731 else
3732 {
3733 jQuery("#boxchannelsub").hide(500);
3734 }
3735
3736 });
3737
3738 jQuery('#<?php echo self::$opt_dynload; ?>').change(function ()
3739 {
3740 if (jQuery(this).is(":checked"))
3741 {
3742 jQuery("#boxdyn").show(500);
3743 }
3744 else
3745 {
3746 jQuery("#boxdyn").hide(500);
3747 }
3748
3749 });
3750
3751 jQuery('#<?php echo self::$opt_spdc; ?>').change(function ()
3752 {
3753 if (jQuery(this).is(":checked"))
3754 {
3755 jQuery("#boxspdc").show(500);
3756 }
3757 else
3758 {
3759 jQuery("#boxspdc").hide(500);
3760 }
3761 });
3762
3763
3764 jQuery('#<?php echo self::$opt_responsive; ?>').change(function ()
3765 {
3766 if (jQuery(this).is(":checked"))
3767 {
3768 jQuery("#boxresponsive_all").show(500);
3769 }
3770 else
3771 {
3772 jQuery("#boxresponsive_all").hide(500);
3773 }
3774 });
3775
3776
3777
3778 jQuery('#<?php echo self::$opt_migrate; ?>').change(function ()
3779 {
3780 if (jQuery(this).is(":checked"))
3781 {
3782 jQuery("#boxmigratelist").show(500);
3783 }
3784 else
3785 {
3786 jQuery("#boxmigratelist").hide(500);
3787 }
3788 });
3789
3790
3791
3792 jQuery('#<?php echo self::$opt_nocookie; ?>').change(function ()
3793 {
3794 if (jQuery(this).is(":checked"))
3795 {
3796 jQuery("#boxnocookie").show(500);
3797 }
3798 else
3799 {
3800 jQuery("#boxnocookie").hide(500);
3801 }
3802
3803 });
3804
3805 jQuery('#<?php echo self::$opt_schemaorg; ?>').change(function ()
3806 {
3807 if (jQuery(this).is(":checked"))
3808 {
3809 jQuery("#boxschemaorg").show(500);
3810 }
3811 else
3812 {
3813 jQuery("#boxschemaorg").hide(500);
3814 }
3815 });
3816
3817
3818 // jQuery('#<?php echo self::$opt_dohl; ?>').change(function()
3819 // {
3820 // if (jQuery(this).is(":checked"))
3821 // {
3822 // jQuery("#boxdohl").show(500);
3823 // }
3824 // else
3825 // {
3826 // jQuery("#boxdohl").hide(500);
3827 // }
3828 //
3829 // });
3830
3831
3832
3833 jQuery('#<?php echo self::$opt_defaultvol; ?>').change(function ()
3834 {
3835 if (jQuery(this).is(":checked"))
3836 {
3837 jQuery("#boxdefaultvol").show(500);
3838 }
3839 else
3840 {
3841 jQuery("#boxdefaultvol").hide(500);
3842 }
3843
3844 });
3845
3846 var rangedetect = document.createElement("input");
3847 rangedetect.setAttribute("type", "range");
3848 var canrange = rangedetect.type !== "text";
3849 //canrange = false;
3850 if (canrange)
3851 {
3852 $("input#vol").prop("type", "range").addClass("vol-range").on("input change", function () {
3853 $('.vol-output').text($(this).val() > 0 ? $(this).val() + '%' : 'Mute');
3854 });
3855 $('.vol-output').css("display", "inline-block").text($("input#vol").val() > 0 ? $("input#vol").val() + '%' : 'Mute');
3856 $('.vol-seeslider').show();
3857 $('.vol-seetextbox').hide();
3858 }
3859 else
3860 {
3861 $("input#vol").width(40);
3862 }
3863
3864
3865 jQuery('#boxspdc input.button').click(function () {
3866 jQuery('#clearspdcloading').show();
3867 jQuery('#clearspdcfailed').hide();
3868 jQuery('#clearspdcsuccess').hide();
3869
3870 $clearbutton = jQuery(this);
3871 $clearbutton.attr('disabled', 'disabled');
3872
3873 jQuery.ajax({
3874 type: "post",
3875 dataType: "json",
3876 timeout: 30000,
3877 url: wpajaxurl,
3878 data: {action: 'my_embedplus_clearspdc'},
3879 success: function (response) {
3880 if (response.type == "success") {
3881 jQuery("#clearspdcsuccess").show();
3882 }
3883 else {
3884 jQuery("#clearspdcfailed").show();
3885 }
3886 },
3887 error: function (xhr, ajaxOptions, thrownError) {
3888 jQuery("#clearspdcfailed").show();
3889 },
3890 complete: function () {
3891 jQuery('#clearspdcloading').hide();
3892 $clearbutton.removeAttr('disabled');
3893 }
3894
3895 });
3896
3897 });
3898
3899
3900
3901
3902 jQuery("#showcase-validate").click(function () {
3903 window.open("<?php echo self::$epbase . "/showcase-validate.aspx?prokey=" . self::$alloptions[self::$opt_pro] ?>" + "&domain=" + mydomain);
3904 });
3905
3906 jQuery('#showprokey').click(function () {
3907 jQuery('.submitpro').show(500);
3908 return false;
3909 });
3910
3911 jQuery('#prokeysubmit').click(function () {
3912 jQuery(this).attr('disabled', 'disabled');
3913 jQuery('#prokeyfailed').hide();
3914 jQuery('#prokeysuccess').hide();
3915 jQuery('#prokeyloading').show();
3916 prokeyval = jQuery('#opt_pro').val();
3917
3918 var tempscript = document.createElement("script");
3919 tempscript.src = "<?php echo self::$epbase ?>/dashboard/wordpress-pro-validatejp.aspx?simple=1&prokey=" + prokeyval + "&domain=" + mydomain;
3920 var n = document.getElementsByTagName("head")[0].appendChild(tempscript);
3921 setTimeout(function () {
3922 n.parentNode.removeChild(n);
3923 }, 500);
3924 return false;
3925 });
3926
3927 window.embedplus_record_prokey = function (good) {
3928
3929 jQuery.ajax({
3930 type: "post",
3931 dataType: "json",
3932 timeout: 30000,
3933 url: wpajaxurl,
3934 data: {action: 'my_embedplus_pro_record', <?php echo self::$opt_pro; ?>: (good ? prokeyval : "")},
3935 success: function (response) {
3936 if (response.type == "success") {
3937 jQuery("#prokeysuccess").show();
3938 }
3939 else {
3940 jQuery("#prokeyfailed").show();
3941 }
3942 },
3943 error: function (xhr, ajaxOptions, thrownError) {
3944 jQuery('#prokeyfailed').show();
3945 },
3946 complete: function () {
3947 jQuery('#prokeyloading').hide();
3948 jQuery('#prokeysubmit').removeAttr('disabled');
3949 }
3950
3951 });
3952
3953 };
3954
3955
3956 window.embedplus_cancel_prokey = function () {
3957
3958 jQuery.ajax({
3959 type: "post",
3960 dataType: "json",
3961 timeout: 30000,
3962 url: wpajaxurl,
3963 data: {action: 'my_embedplus_pro_record', <?php echo self::$opt_pro; ?>: ""},
3964 success: function (response) {
3965 jQuery("#prokeycancel").show();
3966 },
3967 error: function (xhr, ajaxOptions, thrownError) {
3968 jQuery('#prokeyfailed').show();
3969 },
3970 complete: function () {
3971 jQuery('#prokeyloading').hide();
3972 jQuery('#prokeysubmit').removeAttr('disabled');
3973 }
3974
3975 });
3976
3977 };
3978
3979 });
3980 </script>
3981 <?php
3982 if (function_exists('add_thickbox'))
3983 {
3984 add_thickbox();
3985 }
3986 ?>
3987
3988 <?php
3989 }
3990
3991 public static function save_changes_button($submitted)
3992 {
3993 $button_label = 'Save Changes';
3994 if ($submitted)
3995 {
3996 $button_label = 'Changes Saved';
3997 ?>
3998 <script type="text/javascript">
3999 jQuery(document).ready(function () {
4000 setTimeout(function () {
4001 jQuery('input.ytprefs-submit').val('Save Changes');
4002 }, 3000);
4003 });
4004
4005 </script>
4006 <?php
4007 }
4008 ?>
4009 <p class="submit">
4010 <input type="submit" onclick="return savevalidate();" name="Submit" class="button-primary ytprefs-submit" value="<?php _e($button_label) ?>" />
4011 <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>
4012 </p>
4013 <?php
4014 }
4015
4016 public static function ytprefsscript()
4017 {
4018 $loggedin = current_user_can('edit_posts');
4019 if (!($loggedin && self::$alloptions[self::$opt_admin_off_scripts]))
4020 {
4021 wp_enqueue_style(
4022 '__EPYT__style', plugins_url('styles/ytprefs' . self::$min . '.css', __FILE__)
4023 );
4024 $cols = floatval(self::$alloptions[self::$opt_gallery_columns]);
4025 $cols = $cols == 0 ? 3.0 : $cols;
4026 $colwidth = 100.0 / $cols;
4027 $custom_css = "
4028 .epyt-gallery-thumb {
4029 width: " . round($colwidth, 3) . "%;
4030 }";
4031 wp_add_inline_style('__EPYT__style', $custom_css);
4032
4033 wp_enqueue_script('__ytprefs__', plugins_url('scripts/ytprefs' . self::$min . '.js', __FILE__), array('jquery'));
4034
4035 if (self::$alloptions[self::$opt_old_script_method] != 1)
4036 {
4037 wp_localize_script('__ytprefs__', '_EPYT_', array(
4038 'ajaxurl' => admin_url('admin-ajax.php'),
4039 'security' => wp_create_nonce('embedplus-nonce'),
4040 'gallery_scrolloffset' => intval(self::$alloptions[self::$opt_gallery_scrolloffset]),
4041 'eppathtoscripts' => plugins_url('scripts/', __FILE__),
4042 'epresponsiveselector' => self::get_responsiveselector(),
4043 'epdovol' => true,
4044 'version' => self::$alloptions[self::$opt_version],
4045 'evselector' => self::get_evselector()
4046 ));
4047 }
4048
4049 ////////////////////// cloudflare accomodation
4050 //add_filter('script_loader_tag', 'YouTubePrefs::set_cfasync', 10, 3);
4051
4052 if (!is_admin() && (self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0) && self::$alloptions[self::$opt_dynload] == 1)
4053 {
4054 wp_enqueue_style('__dyntype__', plugins_url('scripts/embdyn.min.css', __FILE__));
4055 wp_enqueue_script('__dynload__', plugins_url('scripts/embdyn' . self::$min . '.js', __FILE__), array('jquery'));
4056 }
4057 }
4058 }
4059
4060 public static function set_cfasync($tag, $handle, $src)
4061 {
4062 if ('__ytprefs__' !== $handle)
4063 {
4064 return $tag;
4065 }
4066 return str_replace('<script', '<script data-cfasync="false" ', $tag);
4067 }
4068
4069 public static function get_evselector()
4070 {
4071 $evselector = 'iframe.__youtube_prefs__[src], iframe[src*="youtube.com/embed/"], iframe[src*="youtube-nocookie.com/embed/"]';
4072
4073 if (self::$alloptions[self::$opt_evselector_light] == 1)
4074 {
4075 $evselector = 'iframe.__youtube_prefs__[src]';
4076 }
4077
4078 return $evselector;
4079 }
4080
4081 public static function get_responsiveselector()
4082 {
4083 $responsiveselector = '[]';
4084 if (self::$alloptions[self::$opt_widgetfit] == 1)
4085 {
4086 $responsiveselector = '["iframe.__youtube_prefs_widget__"]';
4087 }
4088 if (self::$alloptions[self::$opt_responsive] == 1)
4089 {
4090 if (self::$alloptions[self::$opt_responsive_all] == 1)
4091 {
4092 $responsiveselector = '["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\']"]';
4093 }
4094 else
4095 {
4096 $responsiveselector = '["iframe.__youtube_prefs__"]';
4097 }
4098 }
4099 return $responsiveselector;
4100 }
4101
4102 public static function get_blogwidth()
4103 {
4104 $blogwidth = null;
4105 try
4106 {
4107 $embed_size_w = intval(get_option('embed_size_w'));
4108
4109 global $content_width;
4110 if (empty($content_width))
4111 {
4112 $content_width = $GLOBALS['content_width'];
4113 }
4114
4115 $blogwidth = $embed_size_w ? $embed_size_w : ($content_width ? $content_width : 450);
4116 }
4117 catch (Exception $ex)
4118 {
4119
4120 }
4121
4122 $blogwidth = preg_replace('/\D/', '', $blogwidth); //may have px
4123
4124 return $blogwidth;
4125 }
4126
4127 }
4128
4129 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4130 //class start
4131 class Add_new_tinymce_btn_Youtubeprefs
4132 {
4133
4134 public $btn_arr;
4135 public $js_file;
4136
4137 /*
4138 * call the constructor and set class variables
4139 * From the constructor call the functions via wordpress action/filter
4140 */
4141
4142 function __construct($seperator, $btn_name, $javascrip_location)
4143 {
4144 $this->btn_arr = array("Seperator" => $seperator, "Name" => $btn_name);
4145 $this->js_file = $javascrip_location;
4146 add_action('init', array($this, 'add_tinymce_button'));
4147 add_filter('tiny_mce_version', array($this, 'refresh_mce_version'));
4148 }
4149
4150 /*
4151 * create the buttons only if the user has editing privs.
4152 * If so we create the button and add it to the tinymce button array
4153 */
4154
4155 function add_tinymce_button()
4156 {
4157 if (!current_user_can('edit_posts') && !current_user_can('edit_pages'))
4158 return;
4159 if (get_user_option('rich_editing') == 'true')
4160 {
4161 //the function that adds the javascript
4162 add_filter('mce_external_plugins', array($this, 'add_new_tinymce_plugin'));
4163 //adds the button to the tinymce button array
4164 add_filter('mce_buttons', array($this, 'register_new_button'));
4165 }
4166 }
4167
4168 /*
4169 * add the new button to the tinymce array
4170 */
4171
4172 function register_new_button($buttons)
4173 {
4174 array_push($buttons, $this->btn_arr["Seperator"], $this->btn_arr["Name"]);
4175 return $buttons;
4176 }
4177
4178 /*
4179 * Call the javascript file that loads the
4180 * instructions for the new button
4181 */
4182
4183 function add_new_tinymce_plugin($plugin_array)
4184 {
4185 $plugin_array[$this->btn_arr['Name']] = $this->js_file;
4186 return $plugin_array;
4187 }
4188
4189 /*
4190 * This function tricks tinymce in thinking
4191 * it needs to refresh the buttons
4192 */
4193
4194 function refresh_mce_version($ver)
4195 {
4196 $ver += 3;
4197 return $ver;
4198 }
4199
4200 }
4201
4202 //class end
4203
4204
4205 register_activation_hook(__FILE__, array('YouTubePrefs', 'initoptions'));
4206 $youtubeplgplus = new YouTubePrefs();
4207
4208
4209 add_action("wp_ajax_my_embedplus_pro_record", array('YouTubePrefs', 'my_embedplus_pro_record'));
4210 add_action("wp_ajax_my_embedplus_clearspdc", array('YouTubePrefs', 'my_embedplus_clearspdc'));
4211 add_action("wp_ajax_my_embedplus_glance_vids", array('YouTubePrefs', 'my_embedplus_glance_vids'));
4212 add_action("wp_ajax_my_embedplus_glance_count", array('YouTubePrefs', 'my_embedplus_glance_count'));
4213 add_action("wp_ajax_my_embedplus_dismiss_double_plugin_warning", array('YouTubePrefs', 'my_embedplus_dismiss_double_plugin_warning'));
4214 add_action("wp_ajax_my_embedplus_gallery_page", array('YouTubePrefs', 'my_embedplus_gallery_page'));
4215 add_action("wp_ajax_nopriv_my_embedplus_gallery_page", array('YouTubePrefs', 'my_embedplus_gallery_page'));
4216
4217 add_action('admin_enqueue_scripts', 'youtubeprefs_admin_enqueue_scripts');
4218
4219 function youtubeprefs_admin_enqueue_scripts()
4220 {
4221 wp_enqueue_style('embedplusyoutube', plugins_url() . '/youtube-embed-plus/scripts/embedplus_mce.css');
4222 add_action('wp_print_scripts', 'youtubeprefs_output_scriptvars');
4223 wp_enqueue_script('__ytprefs_admin__', plugins_url('scripts/ytprefs-admin.min.js', __FILE__), array('jquery'));
4224
4225 if (
4226 //(!(isset(YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro]) && strlen(trim(YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro])) > 0)) && // display only if not pro ooopointer
4227 (get_bloginfo('version') >= '3.3') && YouTubePrefs::custom_admin_pointers_check()
4228 )
4229 {
4230 add_action('admin_print_footer_scripts', 'YouTubePrefs::custom_admin_pointers_footer');
4231
4232 wp_enqueue_script('wp-pointer');
4233 wp_enqueue_style('wp-pointer');
4234 }
4235
4236 if (YouTubePrefs::$alloptions['glance'] == 1)
4237 {
4238 add_action('admin_print_footer_scripts', 'YouTubePrefs::glance_script');
4239 }
4240 }
4241
4242 function youtubeprefs_output_scriptvars()
4243 {
4244 YouTubePrefs::$scriptsprinted++;
4245 if (YouTubePrefs::$scriptsprinted == 1)
4246 {
4247 $blogwidth = YouTubePrefs::get_blogwidth();
4248 $epprokey = YouTubePrefs::$alloptions[YouTubePrefs::$opt_pro];
4249 $myytdefaults = http_build_query(YouTubePrefs::$alloptions);
4250 ?>
4251 <script type="text/javascript">
4252 var wpajaxurl = "<?php echo admin_url('admin-ajax.php') ?>";
4253 if (window.location.toString().indexOf('https://') == 0)
4254 {
4255 wpajaxurl = wpajaxurl.replace("http://", "https://");
4256 }
4257
4258 var epblogwidth = <?php echo $blogwidth; ?>;
4259 var epprokey = '<?php echo $epprokey; ?>';
4260 var epbasesite = '<?php echo YouTubePrefs::$epbase; ?>';
4261 var epversion = '<?php echo YouTubePrefs::$version; ?>';
4262 var myytdefaults = '<?php echo $myytdefaults; ?>';
4263 var eppluginadminurl = '<?php echo admin_url('admin.php?page=youtube-my-preferences'); ?>';
4264
4265 // Create IE + others compatible event handler
4266 var epeventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
4267 var epeventer = window[epeventMethod];
4268 var epmessageEvent = epeventMethod == "attachEvent" ? "onmessage" : "message";
4269
4270 // Listen to message from child window
4271 epeventer(epmessageEvent, function (e)
4272 {
4273 var embedcode = "";
4274 try
4275 {
4276 if (e.data.indexOf("youtubeembedplus") == 0)
4277 {
4278
4279 embedcode = e.data.split("|")[1];
4280 if (embedcode.indexOf("[") !== 0)
4281 {
4282 embedcode = "<p>" + embedcode + "</p>";
4283 }
4284
4285 if (window.tinyMCE !== null && window.tinyMCE.activeEditor !== null && !window.tinyMCE.activeEditor.isHidden())
4286 {
4287 if (typeof window.tinyMCE.execInstanceCommand !== 'undefined')
4288 {
4289 window.tinyMCE.execInstanceCommand(
4290 window.tinyMCE.activeEditor.id,
4291 'mceInsertContent',
4292 false,
4293 embedcode);
4294 }
4295 else
4296 {
4297 send_to_editor(embedcode);
4298 }
4299 }
4300 else
4301 {
4302 embedcode = embedcode.replace('<p>', '\n').replace('</p>', '\n');
4303 if (typeof QTags.insertContent === 'function')
4304 {
4305 QTags.insertContent(embedcode);
4306 }
4307 else
4308 {
4309 send_to_editor(embedcode);
4310 }
4311 }
4312 tb_remove();
4313
4314 }
4315 }
4316 catch (err)
4317 {
4318 if (typeof console !== 'undefined')
4319 console.log(err.message);
4320 }
4321
4322
4323 }, false);
4324
4325
4326
4327 </script>
4328 <?php
4329 }
4330 }
4331
4332 // function embedplus_strip_shortcode_from_excerpt($content)
4333 // {
4334 // $content = strip_shortcodes($content);
4335 // return 'STRIPPED' . $content;
4336 // }
4337 //
4338 // add_filter('the_excerpt', 'embedplus_strip_shortcode_from_excerpt', 5);
4339 // add_filter('get_the_excerpt', 'embedplus_strip_shortcode_from_excerpt', 5);
4340