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

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