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

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