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

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