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

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