PluginProbe
Embed Plus for YouTube Gallery, Livestream and Lazy Loading with Facades / 11.1
Embed Plus for YouTube Gallery, Livestream and Lazy Loading with Facades v11.1
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.1, at youtube.php

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