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

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