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

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