YouTube - Version 9.7

Version Description

Download this release

Release Info

Developer embedplus
Plugin Icon 128x128 YouTube
Version 9.7
Comparing to
See all releases

Code changes from version 9.5 to 9.7

Files changed (3) hide show
  1. images/videothumbs.png +0 -0
  2. readme.txt +10 -5
  3. youtube.php +238 -25
images/videothumbs.png ADDED
Binary file
readme.txt CHANGED
@@ -1,18 +1,19 @@
1
  === YouTube ===
2
  Contributors: embedplus
3
  Plugin Name: YouTube Embed
4
- Tags: origin, lazy load, lazy, load, effects, special effects, get_locale, translator, locale, country code, country, TinyMCE, localization, internationalization, language, multi-language, translate, captions, subtitles, hl, audio, initialize, mute, sound, track, volume, at a glance, channel, annotations, music, music video, songs, song, lyrics, responsive, short code, shortcode, youtube shortcode, health, diagnostic, youtube status, seo, video seo, rich snippets, reddit, google+, google plus, comments, search, widget, sidebar, responsive, fluid, iphone, mobile, android, tablet, ipad, youtube playlist, playlists, playlist, wmode, hd, autohd, auto hd, video analytics, analytics, google, google analytics, view count, vlog, vlogging, web videos, youtube analytics, youtube, youtube plugin, youtube shortcode, embed youtube, plugin, video, video shortcode, embed videos, youtube player, shortcode, simple, simple youtube, smart youtube playback, youtube embed, wordpress youtube embed, embedding youtube, youtube embedding, video plugin, https, ssl, secure, no-cookie, cookie, html5, youtube html5, multilingual, multi-lingual, l10n, i18n
5
- Requires at least: 2.9
6
  Tested up to: 4.1
7
- Stable tag: 9.5
8
  License: GPLv3 or later
9
 
10
- YouTube embed plugin. Embed the YouTube player and playlist in posts, pages, and widgets. Add analytics, SEO, and much more!
11
 
12
  == Description ==
13
 
14
  **Here are a few recently added features (even more features below):**
15
 
 
16
  * 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).
17
  * Easy "Insert" button for both the Visual and Text mode of the editor
18
  * [Embed an entire channel as a playlist >>](https://www.youtube.com/watch?v=_9D4yMyd40g)
@@ -27,6 +28,7 @@ YouTube embed plugin. Embed the YouTube player and playlist in posts, pages, and
27
 
28
  You can even extend the plugin with PRO features like:
29
 
 
30
  * [Eye-catching special effects for YouTube embeds >>](http://www.embedplus.com/add-special-effects-to-youtube-embeds-in-wordpress.aspx) (uses lazy loading)
31
  * Automatic tagging for video SEO
32
  * Automatic Open Graph tagging for Facebook
@@ -136,6 +138,9 @@ You can also start and end each individual video at particular times. Like the a
136
 
137
  == Changelog ==
138
 
 
 
 
139
  = YouTube Embed 9.5 =
140
  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).
141
 
@@ -314,6 +319,6 @@ First release uploaded to the plugin repository.
314
 
315
  == Other Notes ==
316
 
317
- This YouTube plugin can include premium features like automatic schema tagging for video SEO, mobile compatibility checking, and deleted video alerts when you [upgrade to PRO.](https://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx).
318
 
319
  We also have a YouTube channel with some helper videos. [Check them out here >>](https://www.youtube.com/user/EmbedPlus)
1
  === YouTube ===
2
  Contributors: embedplus
3
  Plugin Name: YouTube Embed
4
+ Tags: featured image, css, cross site scripting, accessibility, same origin, screen reader, security, thumbnail, thumbnails, video thumbnails, wordpress security, xss, youtube thumbnails, thumbnail image, origin, lazy load, lazy, load, effects, special effects, get_locale, translator, locale, country code, country, TinyMCE, localization, internationalization, language, multi-language, translate, captions, subtitles, hl, audio, initialize, mute, sound, track, volume, at a glance, channel, annotations, music, music video, songs, song, lyrics, responsive, short code, shortcode, youtube shortcode, diagnostic, youtube status, seo, video seo, rich snippets, reddit, google+, google plus, comments, search, widget, sidebar, responsive, fluid, iphone, mobile, android, tablet, ipad, youtube playlist, playlists, playlist, wmode, hd, autohd, auto hd, video analytics, analytics, google, google analytics, view count, vlog, vlogging, web videos, youtube analytics, youtube, youtube plugin, youtube shortcode, embed youtube, plugin, video, video shortcode, embed videos, youtube player, shortcode, simple, simple youtube, smart youtube playback, youtube embed, wordpress youtube embed, embedding youtube, youtube embedding, video plugin, https, ssl, secure, no-cookie, cookie, html5, youtube html5, multilingual, multi-lingual, l10n, i18n
5
+ Requires at least: 3.1
6
  Tested up to: 4.1
7
+ Stable tag: 9.7
8
  License: GPLv3 or later
9
 
10
+ YouTube embed plugin. Embed the YouTube player and playlist in posts/pages and widgets. Add video thumbnails, analytics, SEO, security, and more.
11
 
12
  == Description ==
13
 
14
  **Here are a few recently added features (even more features below):**
15
 
16
+ * Improved accessibility by using title attributes for screen reader support. It should help your site pass functional accessibility evaluations (FAE).
17
  * 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).
18
  * Easy "Insert" button for both the Visual and Text mode of the editor
19
  * [Embed an entire channel as a playlist >>](https://www.youtube.com/watch?v=_9D4yMyd40g)
28
 
29
  You can even extend the plugin with PRO features like:
30
 
31
+ * Automatic video thumbnail images: each post or page that contains at least one video will have the thumbnail of its first video serve as its featured image.
32
  * [Eye-catching special effects for YouTube embeds >>](http://www.embedplus.com/add-special-effects-to-youtube-embeds-in-wordpress.aspx) (uses lazy loading)
33
  * Automatic tagging for video SEO
34
  * Automatic Open Graph tagging for Facebook
138
 
139
  == Changelog ==
140
 
141
+ = YouTube Embed 9.7 =
142
+ Adds improved accessibility for screen readers and video thumbnail as featured image support.
143
+
144
  = YouTube Embed 9.5 =
145
  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).
146
 
319
 
320
  == Other Notes ==
321
 
322
+ This YouTube plugin can include premium features like animation effects using lazy loading, automatic video thumbnail support, automatic schema tagging for video SEO, mobile compatibility checking, and deleted video alerts when you [upgrade to PRO](https://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx).
323
 
324
  We also have a YouTube channel with some helper videos. [Check them out here >>](https://www.youtube.com/user/EmbedPlus)
youtube.php CHANGED
@@ -3,14 +3,14 @@
3
  Plugin Name: YouTube
4
  Plugin URI: http://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx
5
  Description: YouTube embed plugin with basic features and convenient defaults. Upgrade now to add tracking, instant video SEO tags, and much more!
6
- Version: 9.5
7
  Author: EmbedPlus Team
8
  Author URI: http://www.embedplus.com
9
  */
10
 
11
  /*
12
  YouTube
13
- Copyright (C) 2014 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
@@ -32,12 +32,13 @@
32
  class YouTubePrefs
33
  {
34
 
35
- public static $version = '9.5';
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 $opt_center = 'centervid';
42
  public static $opt_glance = 'glance';
43
  public static $opt_autoplay = 'autoplay';
@@ -61,9 +62,11 @@ class YouTubePrefs
61
  public static $opt_ssl = 'ssl';
62
  public static $opt_ogvideo = 'ogvideo';
63
  public static $opt_nocookie = 'nocookie';
 
64
  public static $opt_pro = 'pro';
65
  public static $opt_oldspacing = 'oldspacing';
66
  public static $opt_responsive = 'responsive';
 
67
  public static $opt_widgetfit = 'widgetfit';
68
  public static $opt_defaultdims = 'defaultdims';
69
  public static $opt_defaultwidth = 'width';
@@ -71,7 +74,7 @@ class YouTubePrefs
71
  public static $opt_defaultvol = 'defaultvol';
72
  public static $opt_vol = 'vol';
73
  public static $opt_schemaorg = 'schemaorg';
74
- public static $opt_origin = 'origin';
75
  public static $opt_dynload = 'dynload';
76
  public static $opt_dyntype = 'dyntype';
77
  public static $opt_alloptions = 'youtubeprefs_alloptions';
@@ -642,12 +645,14 @@ class YouTubePrefs
642
  $_pro = '';
643
  $_ssl = 0;
644
  $_nocookie = 0;
 
645
  $_ogvideo = 0;
646
  $_controls = 2;
647
  $_oldspacing = 1;
648
  $_responsive = 0;
649
  $_widgetfit = 1;
650
  $_schemaorg = 0;
 
651
  $_dynload = 0;
652
  $_dyntype = '';
653
  $_wmode = 'opaque';
@@ -687,6 +692,7 @@ class YouTubePrefs
687
  $_pro = self::tryget($arroptions, self::$opt_pro, '');
688
  $_ssl = self::tryget($arroptions, self::$opt_ssl, 0);
689
  $_nocookie = self::tryget($arroptions, self::$opt_nocookie, 0);
 
690
  $_ogvideo = self::tryget($arroptions, self::$opt_ogvideo, 0);
691
  $_controls = self::tryget($arroptions, self::$opt_controls, 2);
692
  $_autohide = self::tryget($arroptions, self::$opt_autohide, 2);
@@ -694,6 +700,7 @@ class YouTubePrefs
694
  $_responsive = self::tryget($arroptions, self::$opt_responsive, 0);
695
  $_widgetfit = self::tryget($arroptions, self::$opt_widgetfit, 1);
696
  $_schemaorg = self::tryget($arroptions, self::$opt_schemaorg, 0);
 
697
  $_dynload = self::tryget($arroptions, self::$opt_dynload, 0);
698
  $_dyntype = self::tryget($arroptions, self::$opt_dyntype, '');
699
  $_defaultdims = self::tryget($arroptions, self::$opt_defaultdims, 0);
@@ -731,12 +738,14 @@ class YouTubePrefs
731
  self::$opt_pro => $_pro,
732
  self::$opt_ssl => $_ssl,
733
  self::$opt_nocookie => $_nocookie,
 
734
  self::$opt_ogvideo => $_ogvideo,
735
  self::$opt_controls => $_controls,
736
  self::$opt_oldspacing => $_oldspacing,
737
  self::$opt_responsive => $_responsive,
738
  self::$opt_widgetfit => $_widgetfit,
739
  self::$opt_schemaorg => $_schemaorg,
 
740
  self::$opt_dynload => $_dynload,
741
  self::$opt_dyntype => $_dyntype,
742
  self::$opt_defaultdims => $_defaultdims,
@@ -774,6 +783,13 @@ class YouTubePrefs
774
  add_filter('widget_text', 'YouTubePrefs::apply_prefs_widget', 1);
775
  add_shortcode('embedyt', array('YouTubePrefs', 'apply_prefs_shortcode'));
776
  }
 
 
 
 
 
 
 
777
  }
778
 
779
  public static function apply_prefs_shortcode($atts, $content = null)
@@ -833,6 +849,7 @@ class YouTubePrefs
833
  $voloutput = '';
834
  $dynsrc = '';
835
  $dyntype = '';
 
836
 
837
  $finalparams = $linkparams + self::$alloptions;
838
 
@@ -843,6 +860,7 @@ class YouTubePrefs
843
  $youtubebaseurl = 'youtube-nocookie';
844
  }
845
 
 
846
  // if (self::$alloptions[self::$opt_ssl] == 1)
847
  // {
848
  // $linkscheme = 'https';
@@ -910,10 +928,36 @@ class YouTubePrefs
910
  $centercode = ' style="display: block; margin: 0px auto;" ';
911
  }
912
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
913
  $code1 = '<iframe ' . $dyntype . $centercode . ' id="_ytid_' . rand(10000, 99999) . '" width="' . self::$defaultwidth . '" height="' . self::$defaultheight .
914
  '" ' . $dynsrc . 'src="//www.' . $youtubebaseurl . '.com/embed/' . (isset($linkparams['v']) ? $linkparams['v'] : '') . '?';
915
  $code2 = '" frameborder="0" type="text/html" class="__youtube_prefs__' . ($iscontent ? '' : ' __youtube_prefs_widget__') .
916
- '"' . $voloutput . ' allowfullscreen webkitallowfullscreen mozallowfullscreen ></iframe>' . $schemaorgoutput;
917
 
918
  $origin = '';
919
 
@@ -950,6 +994,7 @@ class YouTubePrefs
950
  // reset static vals for next embed
951
  self::$defaultheight = null;
952
  self::$defaultwidth = null;
 
953
 
954
  return $code;
955
  }
@@ -1091,20 +1136,28 @@ class YouTubePrefs
1091
  }
1092
  }
1093
 
 
 
 
 
 
 
 
 
 
 
 
 
1094
  public static function get_aspect_height($url, $urlkvp, $finalparams)
1095
  {
1096
 
1097
  // attempt to get aspect ratio correct height from oEmbed
1098
  $aspectheight = round((self::$defaultwidth * 9) / 16, 0);
 
 
1099
  if ($url)
1100
  {
1101
- require_once( ABSPATH . WPINC . '/class-oembed.php' );
1102
- $oembed = _wp_oembed_get_object();
1103
- $args = array();
1104
- $args['width'] = self::$defaultwidth;
1105
- $args['height'] = self::$defaultwidth; //square to get biggest height from width // self::$optembedheight;
1106
- $args['discover'] = false;
1107
- $odata = $oembed->fetch('https://www.youtube.com/oembed', $url, $args);
1108
 
1109
  if ($odata)
1110
  {
@@ -1120,6 +1173,146 @@ class YouTubePrefs
1120
  return $aspectheight;
1121
  }
1122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1123
  public static function do_ogvideo()
1124
  {
1125
  global $wp_query;
@@ -1368,16 +1561,11 @@ class YouTubePrefs
1368
  $new_pointer_content .= '<p>'; // . __(''); // ooopointer
1369
  if (!(self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0))
1370
  {
1371
- //$new_pointer_content .= __('Adds <em>Autofit Widget</em> option for Free and PRO users. Also adds <em>slide from left</em> animation to <a target="_blank" href="' . self::$epbase . '/add-special-effects-to-youtube-embeds-in-wordpress.aspx?ref=frompointer">Pro effects &raquo;</a>');
1372
- $new_pointer_content .= __('The Free and PRO versions can now automatically apply YouTube&#39;s site origin parameter to provide higher security than the built-in YouTube embedding that comes with WordPress (i.e. oembed). As described in the Google documentation, it enforces your site&#39;s origin with each YouTube embed to prevent third-party Javascript injection. Animations have also been extended for <a href="' . self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=frompointer" target="_blank">PRO users &raquo;</a>.');
1373
- //<a href=\"" . admin_url('admin.php?page=youtube-my-preferences') . "#jumpdefaults\">See the settings page for more details &raquo;</a>"
1374
- //$new_pointer_content .= __('This YouTube plugin update makes HTTPS embedding available for both FREE and <a class="orange" href="' . self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=frompointer" target="_blank">PRO &raquo;</a> users. Please view this settings page to see the option. It will even automatically go and secure the non-HTTPS embeds you made in the past.');
1375
  }
1376
  else
1377
  {
1378
- $new_pointer_content .= __('The Free and PRO versions can now automatically apply YouTube&#39;s site origin parameter to provide higher security than the built-in YouTube embedding that comes with WordPress (i.e. oembed). As described in the Google documentation, it enforces your site&#39;s origin with each YouTube embed to prevent third-party Javascript injection. Animations have also been extended for PRO users.');
1379
- //$new_pointer_content .= __('With this version, the plugin can now automatically detect your site\\\'s default language and set the interface of the embedded YouTube player to match (for FREE and <a href="' . self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=frompointer" target="_blank">PRO versions &raquo;)</a>.');
1380
- //$new_pointer_content .= __('');
1381
  }
1382
  $new_pointer_content .= '</p>';
1383
 
@@ -1445,12 +1633,14 @@ class YouTubePrefs
1445
  $new_options[self::$opt_wmode] = self::postchecked(self::$opt_wmode) ? 'opaque' : 'transparent';
1446
  $new_options[self::$opt_vq] = self::postchecked(self::$opt_vq) ? 'hd720' : '';
1447
  $new_options[self::$opt_nocookie] = self::postchecked(self::$opt_nocookie) ? 1 : 0;
 
1448
  $new_options[self::$opt_ogvideo] = self::postchecked(self::$opt_ogvideo) ? 1 : 0;
1449
  //$new_options[self::$opt_ssl] = self::postchecked(self::$opt_ssl) ? 1 : 0;
1450
  $new_options[self::$opt_oldspacing] = self::postchecked(self::$opt_oldspacing) ? 1 : 0;
1451
  $new_options[self::$opt_responsive] = self::postchecked(self::$opt_responsive) ? 1 : 0;
1452
  $new_options[self::$opt_widgetfit] = self::postchecked(self::$opt_widgetfit) ? 1 : 0;
1453
  $new_options[self::$opt_schemaorg] = self::postchecked(self::$opt_schemaorg) ? 1 : 0;
 
1454
  $new_options[self::$opt_dynload] = self::postchecked(self::$opt_dynload) ? 1 : 0;
1455
  $new_options[self::$opt_defaultdims] = self::postchecked(self::$opt_defaultdims) ? 1 : 0;
1456
  $new_options[self::$opt_defaultvol] = self::postchecked(self::$opt_defaultvol) ? 1 : 0;
@@ -1520,6 +1710,7 @@ class YouTubePrefs
1520
  // Save the posted value in the database
1521
 
1522
  update_option(self::$opt_alloptions, $all);
 
1523
  // Put a settings updated message on the screen
1524
  ?>
1525
  <div class="updated"><p><strong><?php _e('Settings saved.'); ?></strong></p></div>
@@ -1720,6 +1911,10 @@ class YouTubePrefs
1720
  <input name="<?php echo self::$opt_showinfo; ?>" id="<?php echo self::$opt_showinfo; ?>" <?php checked($all[self::$opt_showinfo], 1); ?> type="checkbox" class="checkbox">
1721
  <label for="<?php echo self::$opt_showinfo; ?>"><?php _e('<b class="chktitle">Show Title:</b> Show the video title and other info.') ?></label>
1722
  </p>
 
 
 
 
1723
  <p>
1724
  <input name="<?php echo self::$opt_theme; ?>" id="<?php echo self::$opt_theme; ?>" <?php checked($all[self::$opt_theme], 'dark'); ?> type="checkbox" class="checkbox">
1725
  <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>
@@ -1824,7 +2019,7 @@ class YouTubePrefs
1824
  </label>
1825
  </p>
1826
 
1827
- <p class="smallnote orange">Below are PRO features for enhanced SEO and performance (works for even past embed links). <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" target="_blank">Activate them &raquo;</a></p>
1828
  <div class="upgchecks">
1829
  <?php
1830
  if ($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0)
@@ -1857,6 +2052,13 @@ class YouTubePrefs
1857
  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>
1858
  </label>
1859
  </p>
 
 
 
 
 
 
 
1860
 
1861
  <p>
1862
  <input name="<?php echo self::$opt_schemaorg; ?>" id="<?php echo self::$opt_schemaorg; ?>" <?php checked($all[self::$opt_schemaorg], 1); ?> type="checkbox" class="checkbox">
@@ -1884,6 +2086,13 @@ class YouTubePrefs
1884
  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>
1885
  </label>
1886
  </p>
 
 
 
 
 
 
 
1887
  <p>
1888
  <input disabled type="checkbox" class="checkbox">
1889
  <label>
@@ -1902,7 +2111,7 @@ class YouTubePrefs
1902
  <?php
1903
  }
1904
  ?>
1905
- <div class="clearboth"></div>
1906
  </div>
1907
  <p class="submit">
1908
  <br>
@@ -1993,6 +2202,10 @@ class YouTubePrefs
1993
  <img src="<?php echo plugins_url('images/mobilecompat.png', __FILE__) ?>">
1994
  Check if your embeds have restrictions that can block mobile viewing <sup class="orange bold">NEW</sup>
1995
  </li>
 
 
 
 
1996
 
1997
  </ul>
1998
  </div>
@@ -2024,10 +2237,10 @@ class YouTubePrefs
2024
  <img src="<?php echo plugins_url('images/infinity.png', __FILE__) ?>">
2025
  Unlimited PRO upgrades and downloads
2026
  </li>
2027
- <!-- <li>
2028
- <img src="<?php echo plugins_url('images/questionsale.png', __FILE__) ?>">
2029
- What else? You tell us!
2030
- </li> -->
2031
  </ul>
2032
  </div>
2033
  <div style="clear: both;"></div>
3
  Plugin Name: YouTube
4
  Plugin URI: http://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx
5
  Description: YouTube embed plugin with basic features and convenient defaults. Upgrade now to add tracking, instant video SEO tags, and much more!
6
+ Version: 9.7
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
32
  class YouTubePrefs
33
  {
34
 
35
+ public static $version = '9.7';
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';
62
  public static $opt_ssl = 'ssl';
63
  public static $opt_ogvideo = 'ogvideo';
64
  public static $opt_nocookie = 'nocookie';
65
+ public static $opt_acctitle = 'acctitle';
66
  public static $opt_pro = 'pro';
67
  public static $opt_oldspacing = 'oldspacing';
68
  public static $opt_responsive = 'responsive';
69
+ public static $opt_origin = 'origin';
70
  public static $opt_widgetfit = 'widgetfit';
71
  public static $opt_defaultdims = 'defaultdims';
72
  public static $opt_defaultwidth = 'width';
74
  public static $opt_defaultvol = 'defaultvol';
75
  public static $opt_vol = 'vol';
76
  public static $opt_schemaorg = 'schemaorg';
77
+ public static $opt_ftpostimg = 'ftpostimg';
78
  public static $opt_dynload = 'dynload';
79
  public static $opt_dyntype = 'dyntype';
80
  public static $opt_alloptions = 'youtubeprefs_alloptions';
645
  $_pro = '';
646
  $_ssl = 0;
647
  $_nocookie = 0;
648
+ $_acctitle = 0;
649
  $_ogvideo = 0;
650
  $_controls = 2;
651
  $_oldspacing = 1;
652
  $_responsive = 0;
653
  $_widgetfit = 1;
654
  $_schemaorg = 0;
655
+ $_ftpostimg = 0;
656
  $_dynload = 0;
657
  $_dyntype = '';
658
  $_wmode = 'opaque';
692
  $_pro = self::tryget($arroptions, self::$opt_pro, '');
693
  $_ssl = self::tryget($arroptions, self::$opt_ssl, 0);
694
  $_nocookie = self::tryget($arroptions, self::$opt_nocookie, 0);
695
+ $_acctitle = self::tryget($arroptions, self::$opt_acctitle, 0);
696
  $_ogvideo = self::tryget($arroptions, self::$opt_ogvideo, 0);
697
  $_controls = self::tryget($arroptions, self::$opt_controls, 2);
698
  $_autohide = self::tryget($arroptions, self::$opt_autohide, 2);
700
  $_responsive = self::tryget($arroptions, self::$opt_responsive, 0);
701
  $_widgetfit = self::tryget($arroptions, self::$opt_widgetfit, 1);
702
  $_schemaorg = self::tryget($arroptions, self::$opt_schemaorg, 0);
703
+ $_ftpostimg = self::tryget($arroptions, self::$opt_ftpostimg, 0);
704
  $_dynload = self::tryget($arroptions, self::$opt_dynload, 0);
705
  $_dyntype = self::tryget($arroptions, self::$opt_dyntype, '');
706
  $_defaultdims = self::tryget($arroptions, self::$opt_defaultdims, 0);
738
  self::$opt_pro => $_pro,
739
  self::$opt_ssl => $_ssl,
740
  self::$opt_nocookie => $_nocookie,
741
+ self::$opt_acctitle => $_acctitle,
742
  self::$opt_ogvideo => $_ogvideo,
743
  self::$opt_controls => $_controls,
744
  self::$opt_oldspacing => $_oldspacing,
745
  self::$opt_responsive => $_responsive,
746
  self::$opt_widgetfit => $_widgetfit,
747
  self::$opt_schemaorg => $_schemaorg,
748
+ self::$opt_ftpostimg => $_ftpostimg,
749
  self::$opt_dynload => $_dynload,
750
  self::$opt_dyntype => $_dyntype,
751
  self::$opt_defaultdims => $_defaultdims,
783
  add_filter('widget_text', 'YouTubePrefs::apply_prefs_widget', 1);
784
  add_shortcode('embedyt', array('YouTubePrefs', 'apply_prefs_shortcode'));
785
  }
786
+ else
787
+ {
788
+ if (self::$alloptions[self::$opt_ftpostimg] == 1 && self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0)
789
+ {
790
+ add_action('save_post', array('YouTubePrefs', 'doftpostimg'), 110, 3);
791
+ }
792
+ }
793
  }
794
 
795
  public static function apply_prefs_shortcode($atts, $content = null)
849
  $voloutput = '';
850
  $dynsrc = '';
851
  $dyntype = '';
852
+ $acctitle = '';
853
 
854
  $finalparams = $linkparams + self::$alloptions;
855
 
860
  $youtubebaseurl = 'youtube-nocookie';
861
  }
862
 
863
+
864
  // if (self::$alloptions[self::$opt_ssl] == 1)
865
  // {
866
  // $linkscheme = 'https';
928
  $centercode = ' style="display: block; margin: 0px auto;" ';
929
  }
930
 
931
+ if (self::$alloptions[self::$opt_acctitle] == 1)
932
+ {
933
+ try
934
+ {
935
+ //attr escape
936
+ if (self::$oembeddata)
937
+ {
938
+ $acctitle = self::$oembeddata->title;
939
+ }
940
+ else
941
+ {
942
+ $odata = self::get_oembed('http://youtube.com/watch?v=' . $linkparams['v'], 1920, 1280);
943
+ $acctitle = $odata->title;
944
+ }
945
+
946
+ if ($acctitle)
947
+ {
948
+ $acctitle = ' title="' . esc_attr($acctitle) . '" ';
949
+ }
950
+ }
951
+ catch (Exception $e)
952
+ {
953
+
954
+ }
955
+ }
956
+
957
  $code1 = '<iframe ' . $dyntype . $centercode . ' id="_ytid_' . rand(10000, 99999) . '" width="' . self::$defaultwidth . '" height="' . self::$defaultheight .
958
  '" ' . $dynsrc . 'src="//www.' . $youtubebaseurl . '.com/embed/' . (isset($linkparams['v']) ? $linkparams['v'] : '') . '?';
959
  $code2 = '" frameborder="0" type="text/html" class="__youtube_prefs__' . ($iscontent ? '' : ' __youtube_prefs_widget__') .
960
+ '"' . $voloutput . $acctitle . ' allowfullscreen webkitallowfullscreen mozallowfullscreen ></iframe>' . $schemaorgoutput;
961
 
962
  $origin = '';
963
 
994
  // reset static vals for next embed
995
  self::$defaultheight = null;
996
  self::$defaultwidth = null;
997
+ self::$oembeddata = null;
998
 
999
  return $code;
1000
  }
1136
  }
1137
  }
1138
 
1139
+ public static function get_oembed($url, $height, $width)
1140
+ {
1141
+ require_once( ABSPATH . WPINC . '/class-oembed.php' );
1142
+ $oembed = _wp_oembed_get_object();
1143
+ $args = array();
1144
+ $args['width'] = $width;
1145
+ $args['height'] = $height;
1146
+ $args['discover'] = false;
1147
+ self::$oembeddata = $oembed->fetch('https://www.youtube.com/oembed', $url, $args);
1148
+ return self::$oembeddata;
1149
+ }
1150
+
1151
  public static function get_aspect_height($url, $urlkvp, $finalparams)
1152
  {
1153
 
1154
  // attempt to get aspect ratio correct height from oEmbed
1155
  $aspectheight = round((self::$defaultwidth * 9) / 16, 0);
1156
+
1157
+
1158
  if ($url)
1159
  {
1160
+ $odata = self::get_oembed($url, self::$defaultwidth, self::$defaultwidth);
 
 
 
 
 
 
1161
 
1162
  if ($odata)
1163
  {
1173
  return $aspectheight;
1174
  }
1175
 
1176
+ public static function doftpostimg($postid, $post, $update)
1177
+ {
1178
+ if (current_user_can('edit_posts') && current_user_can('edit_pages'))
1179
+ {
1180
+ if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || !in_array($post->post_status, array('publish', 'pending', 'draft', 'future', 'private')))
1181
+ {
1182
+ return;
1183
+ }
1184
+ try
1185
+ {
1186
+ self::doftpostimgfor($post);
1187
+ }
1188
+ catch (Exception $ex)
1189
+ {
1190
+ // display error message
1191
+ }
1192
+ }
1193
+ }
1194
+
1195
+ public static function doftpostimgfor($post)
1196
+ {
1197
+ $search_content = isset($post->post_content) ? $post->post_content : '';
1198
+ $search_content = substr($search_content, 0, 1500);
1199
+
1200
+ $search_content = apply_filters('youtube_embedplus_video_content', $search_content);
1201
+
1202
+ $vid_match = null;
1203
+ if ($search_content && $post->ID && !has_post_thumbnail($post->ID) && preg_match(self::$justurlregex, $search_content, $vid_match)
1204
+ )
1205
+ {
1206
+
1207
+ $first_vid_link = trim(str_replace(self::$badentities, self::$goodliterals, $vid_match[0]));
1208
+
1209
+ $first_vid_link = preg_replace('/\s/', '', $first_vid_link);
1210
+ $linkparamstemp = explode('?', $first_vid_link);
1211
+
1212
+ $linkparams = array();
1213
+ if (count($linkparamstemp) > 1)
1214
+ {
1215
+ $linkparams = self::keyvalue($linkparamstemp[1], true);
1216
+ }
1217
+ if (strpos($linkparamstemp[0], 'youtu.be') !== false && !isset($linkparams['v']))
1218
+ {
1219
+ $vtemp = explode('/', $linkparamstemp[0]);
1220
+ $linkparams['v'] = array_pop($vtemp);
1221
+ }
1222
+
1223
+
1224
+
1225
+ $just_id = $linkparams['v'];
1226
+ $ftimgurl = null;
1227
+ if ($just_id)
1228
+ {
1229
+ require_once( ABSPATH . WPINC . '/class-oembed.php' );
1230
+ $oembed = _wp_oembed_get_object();
1231
+ $args = array();
1232
+ $args['width'] = 1920;
1233
+ $args['height'] = 1080;
1234
+ $args['discover'] = false;
1235
+ $odata = $oembed->fetch('https://www.youtube.com/oembed', 'http://youtube.com/watch?v=' . $just_id, $args);
1236
+
1237
+ if ($odata)
1238
+ {
1239
+ $ftimgurl = $odata->thumbnail_url;
1240
+ }
1241
+ }
1242
+
1243
+ $ftimgid = $ftimgurl && !is_wp_error($ftimgurl) ? self::media_sideload($ftimgurl, $post->ID, sanitize_title(preg_replace("/[^a-zA-Z0-9\s]/", "-", $post->title))) : 0;
1244
+
1245
+ if (!$ftimgid)
1246
+ {
1247
+ return;
1248
+ }
1249
+
1250
+ set_post_thumbnail($post->ID, $ftimgid);
1251
+ }
1252
+ }
1253
+
1254
+ public static function media_sideload($url, $post_id, $filename = null)
1255
+ {
1256
+ if (!$url || !$post_id)
1257
+ {
1258
+ return new WP_Error('missing', __('Please provide a valid URL and post ID', ''));
1259
+ }
1260
+
1261
+ $post_title = get_the_title($post_id);
1262
+
1263
+ require_once(ABSPATH . 'wp-admin/includes/file.php');
1264
+ $tmp = download_url($url);
1265
+
1266
+ if (is_wp_error($tmp))
1267
+ {
1268
+ @unlink($file_array['tmp_name']);
1269
+ $file_array['tmp_name'] = '';
1270
+ return $tmp;
1271
+ }
1272
+
1273
+ preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches);
1274
+ $url_filename = basename($matches[0]);
1275
+ $url_type = wp_check_filetype($url_filename);
1276
+
1277
+ if (!empty($filename))
1278
+ {
1279
+ $filename = sanitize_file_name($filename);
1280
+ $tmppath = pathinfo($tmp);
1281
+ $new = $tmppath['dirname'] . '/' . $filename . '.' . $tmppath['extension'];
1282
+ rename($tmp, $new);
1283
+ $tmp = $new;
1284
+ }
1285
+
1286
+ $file_array['tmp_name'] = $tmp;
1287
+ if (!empty($filename))
1288
+ {
1289
+ $file_array['name'] = $filename . '.' . $url_type['ext'];
1290
+ }
1291
+ else
1292
+ {
1293
+ $file_array['name'] = $url_filename;
1294
+ }
1295
+
1296
+ $post_data = array(
1297
+ 'post_title' => $post_title,
1298
+ 'post_parent' => $post_id,
1299
+ );
1300
+
1301
+ require_once( ABSPATH . 'wp-admin/includes/file.php' );
1302
+ require_once( ABSPATH . 'wp-admin/includes/media.php' );
1303
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
1304
+
1305
+ $att_id = media_handle_sideload($file_array, $post_id, null, $post_data);
1306
+
1307
+ if (is_wp_error($att_id))
1308
+ {
1309
+ @unlink($file_array['tmp_name']);
1310
+ return $att_id;
1311
+ }
1312
+
1313
+ return $att_id;
1314
+ }
1315
+
1316
  public static function do_ogvideo()
1317
  {
1318
  global $wp_query;
1561
  $new_pointer_content .= '<p>'; // . __(''); // ooopointer
1562
  if (!(self::$alloptions[self::$opt_pro] && strlen(trim(self::$alloptions[self::$opt_pro])) > 0))
1563
  {
1564
+ $new_pointer_content .= __('New accessibility option added to FREE and PRO. Automatic video thumbnails as featured images is now an option for <a href="' . self::$epbase . '/dashboard/pro-easy-video-analytics.aspx?ref=frompointer" target="_blank">PRO users &raquo;</a>.');
 
 
 
1565
  }
1566
  else
1567
  {
1568
+ $new_pointer_content .= __('New accessibility option added to FREE and PRO. Automatic video thumbnails as featured images is now an option for PRO users.');
 
 
1569
  }
1570
  $new_pointer_content .= '</p>';
1571
 
1633
  $new_options[self::$opt_wmode] = self::postchecked(self::$opt_wmode) ? 'opaque' : 'transparent';
1634
  $new_options[self::$opt_vq] = self::postchecked(self::$opt_vq) ? 'hd720' : '';
1635
  $new_options[self::$opt_nocookie] = self::postchecked(self::$opt_nocookie) ? 1 : 0;
1636
+ $new_options[self::$opt_acctitle] = self::postchecked(self::$opt_acctitle) ? 1 : 0;
1637
  $new_options[self::$opt_ogvideo] = self::postchecked(self::$opt_ogvideo) ? 1 : 0;
1638
  //$new_options[self::$opt_ssl] = self::postchecked(self::$opt_ssl) ? 1 : 0;
1639
  $new_options[self::$opt_oldspacing] = self::postchecked(self::$opt_oldspacing) ? 1 : 0;
1640
  $new_options[self::$opt_responsive] = self::postchecked(self::$opt_responsive) ? 1 : 0;
1641
  $new_options[self::$opt_widgetfit] = self::postchecked(self::$opt_widgetfit) ? 1 : 0;
1642
  $new_options[self::$opt_schemaorg] = self::postchecked(self::$opt_schemaorg) ? 1 : 0;
1643
+ $new_options[self::$opt_ftpostimg] = self::postchecked(self::$opt_ftpostimg) ? 1 : 0;
1644
  $new_options[self::$opt_dynload] = self::postchecked(self::$opt_dynload) ? 1 : 0;
1645
  $new_options[self::$opt_defaultdims] = self::postchecked(self::$opt_defaultdims) ? 1 : 0;
1646
  $new_options[self::$opt_defaultvol] = self::postchecked(self::$opt_defaultvol) ? 1 : 0;
1710
  // Save the posted value in the database
1711
 
1712
  update_option(self::$opt_alloptions, $all);
1713
+
1714
  // Put a settings updated message on the screen
1715
  ?>
1716
  <div class="updated"><p><strong><?php _e('Settings saved.'); ?></strong></p></div>
1911
  <input name="<?php echo self::$opt_showinfo; ?>" id="<?php echo self::$opt_showinfo; ?>" <?php checked($all[self::$opt_showinfo], 1); ?> type="checkbox" class="checkbox">
1912
  <label for="<?php echo self::$opt_showinfo; ?>"><?php _e('<b class="chktitle">Show Title:</b> Show the video title and other info.') ?></label>
1913
  </p>
1914
+ <p>
1915
+ <input name="<?php echo self::$opt_acctitle; ?>" id="<?php echo self::$opt_acctitle; ?>" <?php checked($all[self::$opt_acctitle], 1); ?> type="checkbox" class="checkbox">
1916
+ <label for="<?php echo self::$opt_acctitle; ?>"><b class="chktitle">Accessible Title Attributes: <sup class="orange">NEW</sup></b> Improve accessibility by using title attributes for screen reader support. It should help your site pass functional accessibility evaluation (FAE). </label>
1917
+ </p>
1918
  <p>
1919
  <input name="<?php echo self::$opt_theme; ?>" id="<?php echo self::$opt_theme; ?>" <?php checked($all[self::$opt_theme], 'dark'); ?> type="checkbox" class="checkbox">
1920
  <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>
2019
  </label>
2020
  </p>
2021
 
2022
+ <p class="smallnote orange">Below are PRO features for enhanced SEO and performance (works for even past embed links). <a href="<?php echo self::$epbase ?>/dashboard/pro-easy-video-analytics.aspx" target="_blank">Activate them and several other features &raquo;</a></p>
2023
  <div class="upgchecks">
2024
  <?php
2025
  if ($all[self::$opt_pro] && strlen(trim($all[self::$opt_pro])) > 0)
2052
  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>
2053
  </label>
2054
  </p>
2055
+ <p>
2056
+ <input name="<?php echo self::$opt_ftpostimg; ?>" id="<?php echo self::$opt_ftpostimg; ?>" <?php checked($all[self::$opt_ftpostimg], 1); ?> type="checkbox" class="checkbox">
2057
+ <label for="<?php echo self::$opt_ftpostimg; ?>">
2058
+ <b>(PRO)</b> <b class="chktitle">Automatic Video Thumbnails: <sup class="orange">NEW</sup></b>
2059
+ Automatically grab the thumbnail image of the first video embedded in each post or page, and use it as the featured image. All you have to do is click Update on a post or page and the plugin does the rest!
2060
+ </label>
2061
+ </p>
2062
 
2063
  <p>
2064
  <input name="<?php echo self::$opt_schemaorg; ?>" id="<?php echo self::$opt_schemaorg; ?>" <?php checked($all[self::$opt_schemaorg], 1); ?> type="checkbox" class="checkbox">
2086
  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>
2087
  </label>
2088
  </p>
2089
+ <p>
2090
+ <input disabled type="checkbox" class="checkbox">
2091
+ <label>
2092
+ <b class="chktitle">Automatic Video Thumbnails: <sup class="orange">NEW</sup></b> <span class="pronon">(PRO Users)</span>
2093
+ Automatically grab the thumbnail image of the first video embedded in each post or page, and use it as the featured image. All you have to do is click Update on a post or page and the plugin does the rest!
2094
+ </label>
2095
+ </p>
2096
  <p>
2097
  <input disabled type="checkbox" class="checkbox">
2098
  <label>
2111
  <?php
2112
  }
2113
  ?>
2114
+ <div class="clearboth"></div>
2115
  </div>
2116
  <p class="submit">
2117
  <br>
2202
  <img src="<?php echo plugins_url('images/mobilecompat.png', __FILE__) ?>">
2203
  Check if your embeds have restrictions that can block mobile viewing <sup class="orange bold">NEW</sup>
2204
  </li>
2205
+ <li>
2206
+ <img src="<?php echo plugins_url('images/videothumbs.png', __FILE__) ?>">
2207
+ Automatic video thumbnail images (just click 'Update') <sup class="orange bold">NEW</sup>
2208
+ </li>
2209
 
2210
  </ul>
2211
  </div>
2237
  <img src="<?php echo plugins_url('images/infinity.png', __FILE__) ?>">
2238
  Unlimited PRO upgrades and downloads
2239
  </li>
2240
+ <li>
2241
+ <img src="<?php echo plugins_url('images/questionsale.png', __FILE__) ?>">
2242
+ What else? You tell us!
2243
+ </li>
2244
  </ul>
2245
  </div>
2246
  <div style="clear: both;"></div>