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

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