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

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