YouTube - Version 2.6

Version Description

Download this release

Release Info

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

Version 2.6

images/bulletgraph45.png ADDED
Binary file
images/clickdashboard.png ADDED
Binary file
images/epstats16.png ADDED
Binary file
images/hideget.jpg ADDED
Binary file
images/infinity.png ADDED
Binary file
images/ownline.jpg ADDED
Binary file
images/prioritysupport.png ADDED
Binary file
images/questionsale.png ADDED
Binary file
images/unlink.png ADDED
Binary file
images/youtubeicon.png ADDED
Binary file
images/youtubeicon16.png ADDED
Binary file
images/youtubeicon16off.png ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === YouTube ===
2
+ Contributors: embedplus
3
+ Plugin Name: YouTube Embed
4
+ Tags: hd, autohd, auto hd, seo, video analytics, basic analytics, google, google analytics, view count, vlog, vlogging, web videos, youtube analytics, youtube, youtube, youtube plugin, youtube shortcode, embed youtube, plugin, video, video shortcode, embed videos, plugin, youtube player, shortcode, simple, simple youtube, smart youtube playback, youtube embed, wordpress youtube embed, embedding youtube, youtube embedding, video plugin
5
+ Requires at least: 2.9
6
+ Tested up to: 3.6
7
+ Stable tag: 2.6
8
+ License: GPLv3 or later
9
+
10
+ YouTube embed plugin with basic features and convenient defaults. Upgrade now to add view tracking and access to your very own analytics dashboard.
11
+
12
+ == Description ==
13
+
14
+ This YouTube embed plugin for WordPress is very simple. It provides the basic features of the YouTube embedded player, and will have you posting videos in seconds after installing it. Version 2.0 and after adds view tracking to each embed so that you can gain access to your very own YouTube analytics dashboard. Upgrade if you'd like the feature and get answers to questions like:
15
+
16
+ * How much are your visitors actually watching the videos you post?
17
+ * How does the view activity on your site compare to other sites like it?
18
+ * What and when are your best and worst performers?
19
+ * How much do the producers of the YouTube videos you embed rely on **your site** for views?
20
+
21
+ If you want to explore a more advanced plugin, we suggest looking at another one like: [Advanced YouTube Embed](http://wordpress.org/extend/plugins/embedplus-for-wordpress/) by [EmbedPlus](http://www.embedplus.com).
22
+
23
+ To start using this plugin, simply paste a YouTube link on its own line. You can also make default settings for all your YouTube videos under the YouTube admin menu. You can make additional YouTube embed customizations by adding more to the link as shown below:
24
+
25
+ * width - Sets the width of your player. If omitted, the default width will be the width of your theme's content. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350`
26
+ * height - Sets the height of your player. If omitted, this will be calculated for you automatically. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350`
27
+ * vq - Set this to `hd720` or `hd1080` to force the video to play in HD quality. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&vq=hd720`
28
+ * autoplay - Set this to 1 to autoplay the video (or 0 to play the video once). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&autoplay=1`
29
+ * cc_load_policy - Set this to 1 to turn on closed captioning (or 0 to leave them off). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&cc_load_policy=1`
30
+ * iv_load_policy - Set this to 3 to turn off annotations (or 1 to show them). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&iv_load_policy=3`
31
+ * loop - Set this to 1 to loop the video (or 0 to not loop). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&loop=1`
32
+ * modestbranding - Set this to 1 to remove the YouTube logo while playing (or 0 to show the logo). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&modestbranding=1`
33
+ * rel - Set this to 0 to not show related videos at the end of playing (or 1 to show them). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&rel=0`
34
+ * showinfo - Set this to 0 to hide the video title and other info (or 1 to show it). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&showinfo=0`
35
+ * theme - Set this to 'light' to make the player have the light-colored theme (or 'dark' for the dark theme). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&theme=light`
36
+
37
+ You can also start and end each individual video at particular times. Like the above, each option should begin with '&'
38
+
39
+ * start - Sets the time (in seconds) to start the video. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350&start=20`
40
+ * end - Sets the time (in seconds) to stop the video. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350&end=100`
41
+
42
+ == Installation ==
43
+
44
+ 1. Use the WordPress plugin installer to install the plugin. Alternatively, you can just extract the folder in our download package and upload it to your plugin directory.
45
+ 1. Access the Plugins admin menu to activate the YouTube embed plugin.
46
+ 1. Make your default settings after clicking the new YouTube menu item that shows up in your admin panel.
47
+ 1. In your editor, start pasting the links with any desired additional codes needed for your YouTube embed. Make sure the link is on its own line.
48
+ 1. To get an analytics dashboard, [sign up for one of the options here >>](https://www.embedplus.com/dashboard/wordpress-video-analytics-seo.aspx)
49
+
50
+ Additional codes (adding these will override the default settings in the admin):
51
+
52
+ * width - Sets the width of your player. If omitted, the default width will be the width of your theme's content. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350`
53
+ * height - Sets the height of your player. If omitted, this will be calculated for you automatically. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350`
54
+ * vq - Set this to `hd720` or `hd1080` to force the video to play in HD quality. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&vq=hd720`
55
+ * autoplay - Set this to 1 to autoplay the video (or 0 to play the video once). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&autoplay=1`
56
+ * cc_load_policy - Set this to 1 to turn on closed captioning (or 0 to leave them off). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&cc_load_policy=1`
57
+ * iv_load_policy - Set this to 3 to turn off annotations (or 1 to show them). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&iv_load_policy=3`
58
+ * loop - Set this to 1 to loop the video (or 0 to not loop). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&loop=1`
59
+ * modestbranding - Set this to 1 to remove the YouTube logo while playing (or 0 to show the logo). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&modestbranding=1`
60
+ * rel - Set this to 0 to not show related videos at the end of playing (or 1 to show them). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&rel=0`
61
+ * showinfo - Set this to 0 to hide the video title and other info (or 1 to show it). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&showinfo=0`
62
+ * theme - Set this to 'light' to make the player have the light-colored theme (or 'dark' for the dark theme). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&theme=light`
63
+
64
+ You can also start and end each individual video at particular times. Like the above, each option should begin with '&'
65
+
66
+ * start - Sets the time (in seconds) to start the video. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350&start=20`
67
+ * end - Sets the time (in seconds) to stop the video. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350&end=100`
68
+
69
+ == Screenshots ==
70
+
71
+ 1. YouTube Embed Screenshot 1: Paste a YouTube link on its own line and it will become a YouTube embed on your website.
72
+ 2. YouTube Embed Screenshot 2: YouTube's admin settings.
73
+
74
+ == Changelog ==
75
+
76
+ = YouTube Embed 2.6 =
77
+ Compatible with WP 3.6
78
+
79
+ = YouTube Embed 2.4 =
80
+ Added auto HD support
81
+ Support for shorthand (i.e. `http://www.youtu.be`)
82
+ Fixed editor issue
83
+
84
+ = YouTube Embed 2.3 =
85
+ Start/end time shortcut bug fix
86
+
87
+ = YouTube Embed 2.2 =
88
+ Minor changes
89
+
90
+ = YouTube Embed 2.1 =
91
+ By request from several users, we've added easier access to the video analytics dashboard
92
+
93
+ = YouTube Embed 2.0 =
94
+
95
+ This upgrade specifically integrates a user-friendly YouTube Analytics Dashboard to this plugin so you can learn a lot more about the videos you post. Download it if you would like it to use your site's YouTube-related activity to help answer questions like:
96
+
97
+ * How much are your visitors actually watching the videos you post?
98
+ * How does the view activity on your site compare to other sites like it?
99
+ * What and when are your best and worst performers?
100
+ * How much do the producers of the YouTube videos you embed rely on **your site** for views?
101
+
102
+ We think these are all interesting questions; however, note that there's no need to upgrade if you don't.
103
+
104
+ = YouTube Embed 1.1 =
105
+ Fixed minor bug.
106
+
107
+ = YouTube Embed 1.0 =
108
+ First release uploaded to the plugin repository.
109
+
110
+ == Other Notes ==
111
+
112
+ Again, note that this is a no-frills plugin. We're just supporting the basic functions that people typically want when embedding YouTube videos. This includes [YouTube embed analytics](https://www.embedplus.com/dashboard/wordpress-video-analytics-seo.aspx) to help you learn a lot about the videos you post. If you want more, take a look at a more powerful plugin here: [Advanced YouTube Embed]( http://wordpress.org/extend/plugins/embedplus-for-wordpress/) by [EmbedPlus](http://www.embedplus.com).
screenshot-1.jpg ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
scripts/btn_embedplusstats.png ADDED
Binary file
scripts/btn_embedplusstatsoff.png ADDED
Binary file
scripts/embedplus_mce.css ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wp_themeSkin span.mce_embedpluswiz, span.mce_embedpluswiz
2
+ {
3
+ background: transparent url("btn_embedpluswizoff.png") no-repeat scroll center center !important;
4
+ }
5
+
6
+ .wp_themeSkin span.mce_embedpluswiz:hover, span.mce_embedpluswiz:hover
7
+ {
8
+ background-image: url("btn_embedpluswiz.png") !important;
9
+ }
10
+
11
+ .wp_themeSkin span.mce_embedplusstats, span.mce_embedplusstats,
12
+ .wp_themeSkin span.mce_embedplusstats_youtubeprefs, span.mce_embedplusstats_youtubeprefs
13
+
14
+ {
15
+ background: transparent url("btn_embedplusstatsoff.png") no-repeat scroll center center !important;
16
+ }
17
+
18
+ .wp_themeSkin span.mce_embedplusstats:hover, span.mce_embedplusstats:hover,
19
+ .wp_themeSkin span.mce_embedplusstats_youtubeprefs:hover, span.mce_embedplusstats_youtubeprefs:hover
20
+ {
21
+ background-image: url("btn_embedplusstats.png") !important;
22
+ }
23
+
scripts/embedplusstats_mce.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function() {
2
+ tinymce.create('tinymce.plugins.Embedplusstats_youtubeprefs', {
3
+ init : function(ed, url) {
4
+ var plep = new Image();
5
+ plep.src = url+'/btn_embedplusstats.png';
6
+ ed.addButton('embedplusstats_youtubeprefs', {
7
+ title : 'How much are your visitors actually watching the videos you post? Click here to start using this popular feature from EmbedPlus Labs »',
8
+ onclick : function(ev) {
9
+ window.open('https://www.embedplus.com/dashboard/easy-video-analytics-seo.aspx', '_blank');
10
+ }
11
+ });
12
+
13
+ },
14
+ createControl : function(n, cm) {
15
+ return null;
16
+ },
17
+ getInfo : function() {
18
+ return {
19
+ longname : "Embedplus Video Analytics Dashboard",
20
+ author : 'EmbedPlus',
21
+ authorurl : 'http://www.embedplus.com/',
22
+ infourl : 'http://www.embedplus.com/',
23
+ version : "2.4"
24
+ };
25
+ }
26
+ });
27
+ tinymce.PluginManager.add('embedplusstats_youtubeprefs', tinymce.plugins.Embedplusstats_youtubeprefs);
28
+
29
+ })();
scripts/ytprefs.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function onYouTubeIframeAPIReady(){var e=document.querySelectorAll("iframe.__youtube_prefs__");for(var t=0;t<e.length;t++){_EPADashboard_.setupevents(e[t].id)}}(function(){if(!document.querySelectorAll){document.querySelectorAll=function(e){var t=document,n=t.documentElement.firstChild,r=t.createElement("STYLE");n.appendChild(r);t.__qsaels=[];r.styleSheet.cssText=e+"{x:expression(document.__qsaels.push(this))}";window.scrollBy(0,0);return t.__qsaels}}if(typeof window._EPADashboard_=="undefined"){window._EPADashboard_={onPlayerReady:function(e){setTimeout(function(){var t=_EPADashboard_.justid(e.target.getVideoUrl());_EPADashboard_.jp("ytid="+t)},4e3)},onPlayerStateChange:function(e){var t=e.target.getIframe();if(e.data==1&&e.target.ponce!==true&&t.src.indexOf("autoplay=1")==-1){e.target.ponce=true;var n=_EPADashboard_.justid(e.target.getVideoUrl());_EPADashboard_.jp("ytid="+n+"&p=1")}},justid:function(e){return(new RegExp("[\\?&]v=([^&#]*)")).exec(e)[1]},setupevents:function(e){new YT.Player(e,{events:{onReady:_EPADashboard_.onPlayerReady,onStateChange:_EPADashboard_.onPlayerStateChange}})},jp:function(e){var t=document.createElement("script");t.src="//www.embedplus.com/test-page.aspx?es=w&u="+encodeURIComponent(window.location.href.split("#")[0])+e+(navigator.userAgent.toLowerCase().indexOf("chrome")>-1?"&b=c&":"&b=&");var n=document.getElementsByTagName("head")[0].appendChild(t);setTimeout(function(){n.parentNode.removeChild(n)},500)}}}if(typeof window.YT=="undefined"){var e=document.createElement("script");e.src="//www.youtube.com/iframe_api";e.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(e)}})()
youtube.php ADDED
@@ -0,0 +1,715 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: YouTube
4
+ Plugin URI: http://www.embedplus.com
5
+ Description: YouTube embed plugin with basic features and convenient defaults. Upgrade now to add view tracking and access to your very own analytics dashboard.
6
+ Version: 2.6
7
+ Author: EmbedPlus Team
8
+ Author URI: http://www.embedplus.com
9
+ */
10
+
11
+ /*
12
+ YouTube
13
+ Copyright (C) 2013 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 = '2.6';
36
+ public static $opt_version = 'version';
37
+ public static $optembedwidth = null;
38
+ public static $optembedheight = null;
39
+ public static $defaultheight = null;
40
+ public static $defaultwidth = null;
41
+ public static $opt_center = 'centervid';
42
+ public static $opt_auto_hd = 'auto_hd';
43
+ public static $opt_autoplay = 'autoplay';
44
+ public static $opt_cc_load_policy = 'cc_load_policy';
45
+ public static $opt_iv_load_policy = 'iv_load_policy';
46
+ public static $opt_loop = 'loop';
47
+ public static $opt_modestbranding = 'modestbranding';
48
+ public static $opt_rel = 'rel';
49
+ public static $opt_showinfo = 'showinfo';
50
+ public static $opt_theme = 'theme';
51
+ public static $opt_vq = 'vq';
52
+ public static $opt_alloptions = 'youtubeprefs_alloptions';
53
+ public static $alloptions = null;
54
+ public static $yt_options = array();
55
+
56
+ /*
57
+ color
58
+ controls
59
+ autohide
60
+ disablekb
61
+ list
62
+ listType
63
+ playlist
64
+ */
65
+ //TEST REGEX
66
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
67
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
68
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
69
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
70
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
71
+ public static $ytregex = '@^\s*https?://(?:www\.)?(?:(?:youtube.com/watch\?)|(?:youtu.be/))([^\s"]+)\s*$@im';
72
+
73
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
74
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
75
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
76
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
77
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
78
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
79
+
80
+ public function __construct()
81
+ {
82
+ $do_autoembeds = get_option('embed_autourls');
83
+ if ($do_autoembeds == 0)
84
+ {
85
+ update_option('embed_autourls', 1);
86
+ }
87
+
88
+ self::$alloptions = get_option(self::$opt_alloptions);
89
+ if (self::$alloptions == false || version_compare(self::$alloptions[self::$opt_version], self::$version, '<'))
90
+ {
91
+ self::initoptions();
92
+ }
93
+ self::$optembedwidth = intval(get_option('embed_size_w'));
94
+ self::$optembedheight = intval(get_option('embed_size_h'));
95
+
96
+ self::$yt_options = array(
97
+ self::$opt_autoplay,
98
+ self::$opt_cc_load_policy,
99
+ self::$opt_iv_load_policy,
100
+ self::$opt_loop,
101
+ self::$opt_modestbranding,
102
+ self::$opt_rel,
103
+ self::$opt_showinfo,
104
+ self::$opt_theme,
105
+ self::$opt_vq,
106
+ 'start',
107
+ 'end'
108
+ );
109
+
110
+ self::do_ytprefs();
111
+
112
+ if (self::wp_above_version('2.9'))
113
+ {
114
+ add_action('admin_menu', 'YouTubePrefs::ytprefs_plugin_menu');
115
+ }
116
+ // if (!is_admin())
117
+ // {
118
+ // // allow shortcode in widgets
119
+ // //add_filter('widget_text', 'do_shortcode', 11);
120
+ // }
121
+ }
122
+
123
+ static function initoptions()
124
+ {
125
+ if (self::wp_above_version('2.9'))
126
+ {
127
+ if (get_option(self::$opt_alloptions) === false)
128
+ {
129
+ $_auto_hd = get_option('youtubeprefs_auto_hd', 0);
130
+ $_autoplay = get_option('youtubeprefs_autoplay', 0);
131
+ $_cc_load_policy = get_option('youtubeprefs_cc_load_policy', 0);
132
+ $_iv_load_policy = get_option('youtubeprefs_iv_load_policy', 1);
133
+ $_loop = get_option('youtubeprefs_loop', 0);
134
+ $_modestbranding = get_option('youtubeprefs_modestbranding', 0);
135
+ $_rel = get_option('youtubeprefs_rel', 1);
136
+ $_showinfo = get_option('youtubeprefs_showinfo', 1);
137
+ $_theme = get_option('youtubeprefs_theme', 'dark');
138
+ $_vq = get_option('youtubeprefs_vq', '');
139
+
140
+
141
+ $all = array(
142
+ self::$opt_version => self::$version,
143
+ self::$opt_center => 0,
144
+ self::$opt_auto_hd => $_auto_hd,
145
+ self::$opt_autoplay => $_autoplay,
146
+ self::$opt_cc_load_policy => $_cc_load_policy,
147
+ self::$opt_iv_load_policy => $_iv_load_policy,
148
+ self::$opt_loop => $_loop,
149
+ self::$opt_modestbranding => $_modestbranding,
150
+ self::$opt_rel => $_rel,
151
+ self::$opt_showinfo => $_showinfo,
152
+ self::$opt_theme => $_theme,
153
+ self::$opt_vq => $_vq
154
+ );
155
+
156
+ add_option(self::$opt_alloptions, $all);
157
+
158
+ // add_option(self::$opt_auto_hd, 0);
159
+ // add_option(self::$opt_autoplay, 0);
160
+ // add_option(self::$opt_cc_load_policy, 0);
161
+ // add_option(self::$opt_iv_load_policy, 1);
162
+ // add_option(self::$opt_loop, 0);
163
+ // add_option(self::$opt_modestbranding, 0);
164
+ // add_option(self::$opt_rel, 1);
165
+ // add_option(self::$opt_showinfo, 1);
166
+ // add_option(self::$opt_theme, 'dark');
167
+
168
+ update_option('embed_autourls', 1);
169
+ }
170
+ self::$alloptions = get_option(self::$opt_alloptions);
171
+ }
172
+ }
173
+
174
+ public static function wp_above_version($ver)
175
+ {
176
+ global $wp_version;
177
+ if (version_compare($wp_version, $ver, '>='))
178
+ {
179
+ return true;
180
+ }
181
+ return false;
182
+ }
183
+
184
+ public static function do_ytprefs()
185
+ {
186
+ if (self::wp_above_version('2.9') && !is_admin())
187
+ {
188
+ add_filter('the_content', 'YouTubePrefs::apply_prefs', 1);
189
+ }
190
+ }
191
+
192
+ public static function apply_prefs($content)
193
+ {
194
+ $content = preg_replace_callback(self::$ytregex, "YouTubePrefs::get_html", $content);
195
+ return $content;
196
+ }
197
+
198
+ public static function get_html($m)
199
+ {
200
+ $link = trim(preg_replace('/&amp;/i', '&', $m[0]));
201
+ $link = preg_replace('/\s/', '', $link);
202
+ $linkparamstemp = explode('?', $link);
203
+ $linkparams = self::keyvalue($linkparamstemp[1], true);
204
+ if (strpos($linkparamstemp[0], 'youtu.be') !== false && !$linkparams['v'])
205
+ {
206
+ $vtemp = explode('/', $linkparamstemp[0]);
207
+ $linkparams['v'] = array_pop($vtemp);
208
+ }
209
+
210
+ self::init_dimensions($link, $linkparams);
211
+
212
+ $linkscheme = parse_url($link, PHP_URL_SCHEME);
213
+
214
+ $code1 = '<iframe id="_ytid_' . rand(10000, 99999) . '" width="' . self::$defaultwidth . '" height="' . self::$defaultheight .
215
+ '" src="' . $linkscheme . '://www.youtube.com/embed/' . $linkparams['v'] . '?';
216
+ $code2 = '" frameborder="0" allowfullscreen type="text/html" class="__youtube_prefs__"></iframe>';
217
+
218
+ /*
219
+ $prefparams = array();
220
+
221
+ //get_option(self::$opt_auto_hd, 0);
222
+ $autoplay = get_option(self::$opt_autoplay, 0);
223
+ $cc_load_policy = get_option(self::$opt_cc_load_policy, 0) == 1 ? 1 : '';
224
+ $iv_load_policy = get_option(self::$opt_iv_load_policy, 1);
225
+ $loop = get_option(self::$opt_loop, 0);
226
+ $modestbranding = get_option(self::$opt_modestbranding, 0) == 1 ? 1 : '';
227
+ $rel = get_option(self::$opt_rel, 1);
228
+ $showinfo = get_option(self::$opt_showinfo, 1);
229
+ $theme = get_option(self::$opt_theme, 'dark');
230
+
231
+ if ($autoplay == 1)
232
+ $prefparams['autoplay'] = 1;
233
+ if ($cc_load_policy == 1)
234
+ $prefparams['cc_load_policy'] = 1;
235
+ if ($iv_load_policy == 3)
236
+ $prefparams['iv_load_policy'] = 3;
237
+ if ($loop == 1)
238
+ $prefparams['loop'] = 1;
239
+ if ($modestbranding == 1)
240
+ $prefparams['modestbranding'] = 1;
241
+ if ($rel == 0)
242
+ $prefparams['rel'] = 0;
243
+ if ($showinfo == 0)
244
+ $prefparams['showinfo'] = 0;
245
+ if ($theme == 'light')
246
+ $prefparams['theme'] = 'light';
247
+ */
248
+
249
+ $finalparams = $linkparams + self::$alloptions;
250
+ $origin = '';
251
+
252
+ try
253
+ {
254
+ if (!empty($_SERVER["HTTP_HOST"]))
255
+ {
256
+ $origin = 'origin=' .
257
+ ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://') . $_SERVER["HTTP_HOST"] . '&';
258
+ }
259
+ }
260
+ catch (Exception $e)
261
+ {
262
+
263
+ }
264
+ $finalsrc = 'enablejsapi=1&'; // . $origin;
265
+
266
+ if (count($finalparams) > 1)
267
+ {
268
+ foreach ($finalparams as $key => $value)
269
+ {
270
+ if (in_array($key, self::$yt_options))
271
+ {
272
+ $finalsrc .= htmlspecialchars($key) . '=' . htmlspecialchars($value) . '&';
273
+ if ($key == 'loop' && $value == 1)
274
+ $finalsrc .= 'playlist=' . $finalparams['v'] . '&';
275
+ }
276
+ }
277
+ }
278
+
279
+ $code = $code1 . $finalsrc . $code2;
280
+
281
+ if (self::$alloptions[self::$opt_center] == 1)
282
+ {
283
+ $code = '<div style="text-align: center; display: block;">' . $code . '</div>';
284
+ }
285
+
286
+ // reset static vals for next embed
287
+ self::$defaultheight = null;
288
+ self::$defaultwidth = null;
289
+
290
+ return $code;
291
+ }
292
+
293
+ public static function keyvalue($qry, $includev)
294
+ {
295
+ $ytvars = explode('&', $qry);
296
+ $ytkvp = array();
297
+ foreach ($ytvars as $k => $v)
298
+ {
299
+ $kvp = explode('=', $v);
300
+ if (count($kvp) == 2 && ($includev || strtolower($kvp[0]) != 'v'))
301
+ {
302
+ $ytkvp[$kvp[0]] = $kvp[1];
303
+ }
304
+ }
305
+
306
+ return $ytkvp;
307
+ }
308
+
309
+ public static function init_dimensions($url, $urlkvp)
310
+ {
311
+ // get default dimensions; try embed size in settings, then try theme's content width, then just 480px
312
+ if (self::$defaultwidth == null)
313
+ {
314
+ global $content_width;
315
+ if (empty($content_width))
316
+ $content_width = $GLOBALS['content_width'];
317
+
318
+ self::$defaultwidth = $urlkvp['width'] ? $urlkvp['width'] : (self::$optembedwidth ? self::$optembedwidth : ($content_width ? $content_width : 480));
319
+ self::$defaultheight = self::get_aspect_height($url);
320
+ }
321
+ }
322
+
323
+ public static function get_aspect_height($url)
324
+ {
325
+
326
+ // attempt to get aspect ratio correct height from oEmbed
327
+ $aspectheight = round((self::$defaultwidth * 9) / 16, 0);
328
+ if ($url)
329
+ {
330
+ require_once( ABSPATH . WPINC . '/class-oembed.php' );
331
+ $oembed = _wp_oembed_get_object();
332
+ $args = array();
333
+ $args['width'] = self::$defaultwidth;
334
+ $args['height'] = self::$optembedheight;
335
+ $args['discover'] = false;
336
+ $odata = $oembed->fetch('http://www.youtube.com/oembed', $url, $args);
337
+
338
+ if ($odata)
339
+ {
340
+ $aspectheight = $odata->height;
341
+ }
342
+ }
343
+
344
+ //add 30 for YouTube's own bar
345
+ return $aspectheight + 30;
346
+ }
347
+
348
+ public static function ytprefs_plugin_menu()
349
+ {
350
+ add_menu_page('YouTube Settings', 'YouTube', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options', plugins_url('images/youtubeicon16.png', __FILE__), '10.00392854349');
351
+ add_menu_page('YouTube Analytics Dashboard', 'EmbedPlus YouTube Pro', 'manage_options', 'youtube-ep-analytics-dashboard', 'YouTubePrefs::epstats_show_options', plugins_url('images/epstats16.png', __FILE__), '10.00492884349');
352
+ }
353
+
354
+ public static function epstats_show_options()
355
+ {
356
+
357
+ if (!current_user_can('manage_options'))
358
+ {
359
+ wp_die(__('You do not have sufficient permissions to access this page.'));
360
+ }
361
+
362
+ // Now display the settings editing screen
363
+ ?>
364
+ <div class="wrap">
365
+ <?php
366
+ // header
367
+
368
+ echo "<h2>" . '<img src="' . plugins_url('images/epstats16.png', __FILE__) . '" /> ' . __('YouTube Analytics Dashboard') . "</h2>";
369
+
370
+ // settings form
371
+ ?>
372
+ <style type="text/css">
373
+ .epicon { width: 20px; height: 20px; vertical-align: middle; padding-right: 5px;}
374
+ .epindent {padding-left: 25px;}
375
+ </style>
376
+ <br>
377
+ <iframe style="-webkit-box-shadow: 0px 0px 20px 0px #000000; box-shadow: 0px 0px 20px 0px #000000;" src="https://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx?domain=<?php echo (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ""); ?>" width="1030" height="1800" scrolling="auto"/>
378
+ </div>
379
+ <?php
380
+ }
381
+
382
+ public static function ytprefs_show_options()
383
+ {
384
+
385
+ if (!current_user_can('manage_options'))
386
+ {
387
+ wp_die(__('You do not have sufficient permissions to access this page.'));
388
+ }
389
+
390
+ // variables for the field and option names
391
+ $ytprefs_submitted = 'ytprefs_submitted';
392
+
393
+ // Read in existing option values from database
394
+ /*
395
+ $auto_hd = get_option(self::$opt_auto_hd);
396
+ $autoplay = get_option(self::$opt_autoplay, 0);
397
+ $cc_load_policy = get_option(self::$opt_cc_load_policy, 0);
398
+ $iv_load_policy = get_option(self::$opt_iv_load_policy, 1);
399
+ $loop = get_option(self::$opt_loop, 0);
400
+ $modestbranding = get_option(self::$opt_modestbranding, 0);
401
+ $rel = get_option(self::$opt_rel, 1);
402
+ $showinfo = get_option(self::$opt_showinfo, 1);
403
+ $theme = get_option(self::$opt_theme, 'dark');
404
+ */
405
+
406
+ $all = get_option(self::$opt_alloptions);
407
+
408
+ // See if the user has posted us some information
409
+ // If they did, this hidden field will be set to 'Y'
410
+ if (isset($_POST[$ytprefs_submitted]) && $_POST[$ytprefs_submitted] == 'Y')
411
+ {
412
+ // Read their posted values
413
+ // $auto_hd = $_POST[self::$opt_auto_hd] == (true || 'on') ? 1 : 0;
414
+ // $autoplay = $_POST[self::$opt_autoplay] == (true || 'on') ? 1 : 0;
415
+ // $cc_load_policy = $_POST[self::$opt_cc_load_policy] == (true || 'on') ? 1 : 0;
416
+ // $iv_load_policy = $_POST[self::$opt_iv_load_policy] == (true || 'on') ? 1 : 3;
417
+ // $loop = $_POST[self::$opt_loop] == (true || 'on') ? 1 : 0;
418
+ // $modestbranding = $_POST[self::$opt_modestbranding] == (true || 'on') ? 1 : 0;
419
+ // $rel = $_POST[self::$opt_rel] == (true || 'on') ? 1 : 0;
420
+ // $showinfo = $_POST[self::$opt_showinfo] == (true || 'on') ? 1 : 0;
421
+ // $theme = $_POST[self::$opt_theme] == (true || 'on') ? 'dark' : 'light';
422
+
423
+ $new_options = array();
424
+ $new_options[self::$opt_center] = $_POST[self::$opt_center] == (true || 'on') ? 1 : 0;
425
+ $new_options[self::$opt_auto_hd] = $_POST[self::$opt_auto_hd] == (true || 'on') ? 1 : 0;
426
+ $new_options[self::$opt_autoplay] = $_POST[self::$opt_autoplay] == (true || 'on') ? 1 : 0;
427
+ $new_options[self::$opt_cc_load_policy] = $_POST[self::$opt_cc_load_policy] == (true || 'on') ? 1 : 0;
428
+ $new_options[self::$opt_iv_load_policy] = $_POST[self::$opt_iv_load_policy] == (true || 'on') ? 1 : 3;
429
+ $new_options[self::$opt_loop] = $_POST[self::$opt_loop] == (true || 'on') ? 1 : 0;
430
+ $new_options[self::$opt_modestbranding] = $_POST[self::$opt_modestbranding] == (true || 'on') ? 1 : 0;
431
+ $new_options[self::$opt_rel] = $_POST[self::$opt_rel] == (true || 'on') ? 1 : 0;
432
+ $new_options[self::$opt_showinfo] = $_POST[self::$opt_showinfo] == (true || 'on') ? 1 : 0;
433
+ $new_options[self::$opt_theme] = $_POST[self::$opt_theme] == (true || 'on') ? 'dark' : 'light';
434
+ $new_options[self::$opt_vq] = $_POST[self::$opt_vq] == (true || 'on') ? 'hd720' : '';
435
+
436
+ $all = $new_options + $all;
437
+
438
+ // Save the posted value in the database
439
+ // update_option(self::$opt_auto_hd, $auto_hd);
440
+ // update_option(self::$opt_autoplay, $autoplay);
441
+ // update_option(self::$opt_cc_load_policy, $cc_load_policy);
442
+ // update_option(self::$opt_iv_load_policy, $iv_load_policy);
443
+ // update_option(self::$opt_loop, $loop);
444
+ // update_option(self::$opt_modestbranding, $modestbranding);
445
+ // update_option(self::$opt_rel, $rel);
446
+ // update_option(self::$opt_showinfo, $showinfo);
447
+ // update_option(self::$opt_theme, $theme);
448
+
449
+ update_option(self::$opt_alloptions, $all);
450
+ // Put a settings updated message on the screen
451
+ ?>
452
+ <div class="updated"><p><strong><?php _e('Settings saved.'); ?></strong></p></div>
453
+ <?php
454
+ }
455
+
456
+ // Now display the settings editing screen
457
+
458
+ echo '<div class="wrap">';
459
+
460
+ // header
461
+
462
+ echo "<h2>" . '<img src="' . plugins_url('images/youtubeicon16.png', __FILE__) . '" /> ' . __('YouTube Preferences') . "</h2>";
463
+
464
+ // settings form
465
+ ?>
466
+
467
+ <style type="text/css">
468
+ #ytform p { line-height: 20px; }
469
+ #ytform ul li {margin-left: 30px; list-style: disc outside none;}
470
+ .ytindent {padding: 0px 0px 0px 20px;}
471
+ .shadow {-webkit-box-shadow: 0px 0px 20px 0px #000000; box-shadow: 0px 0px 20px 0px #000000;}
472
+ .gopro img {vertical-align: middle;
473
+ width: 20px;
474
+ height: 20px;
475
+ padding-bottom: 4px;}
476
+ .bold {font-weight: bold;}
477
+ #goprobox {border-radius: 15px; padding: 5px 20px 20px 20px; margin: 15px; border: 3px solid #dddddd; width: 300px;}
478
+ </style>
479
+
480
+ <div class="ytindent">
481
+
482
+
483
+ <div id="goprobox">
484
+
485
+ <h3>
486
+ Go PRO
487
+ </h3>
488
+ <ul class="gopro">
489
+ <li>
490
+ <img src="<?php echo plugins_url('images/prioritysupport.png', __FILE__) ?>">
491
+ Priority support (Puts your request in front)
492
+ </li>
493
+ <li>
494
+ <img src="<?php echo plugins_url('images/bulletgraph45.png', __FILE__) ?>">
495
+ Your own video analytics dashboard
496
+ </li>
497
+ <li>
498
+ <img src="<?php echo plugins_url('images/infinity.png', __FILE__) ?>">
499
+ Unlimited PRO upgrades and downloads
500
+ </li>
501
+ <li>
502
+ <img src="<?php echo plugins_url('images/questionsale.png', __FILE__) ?>">
503
+ What else? You tell us!
504
+ </li>
505
+ </ul>
506
+ <a href="https://www.embedplus.com/dashboard/pro-easy-video-analytics.aspx" class="button-primary" target="_blank">Click here to go PRO &raquo;</a>
507
+
508
+ </div>
509
+
510
+
511
+ <br>
512
+ <form name="form1" method="post" action="" id="ytform">
513
+ <input type="hidden" name="<?php echo $ytprefs_submitted; ?>" value="Y">
514
+ <h3>
515
+ <?php _e("How to Insert a YouTube Video") ?>
516
+ </h3>
517
+ <p>
518
+ All you have to do is paste the link to the YouTube video on its own line, as shown below (including the http:// part). Easy, eh?
519
+ </p>
520
+ <ul class="reglist">
521
+ <li>Make sure the url is really on its own line by itself</li>
522
+ <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>
523
+ </ul>
524
+ <p>
525
+ <img class="shadow" src="<?php echo plugins_url('images/ownline.jpg', __FILE__) ?>" />
526
+ </p>
527
+ <br>
528
+
529
+ <h3>
530
+ <?php _e("Default Options") ?>
531
+ </h3>
532
+ <p>
533
+ <?php _e("Below you can set the default options for all your videos. However, you can override them (and more) on a per-video basis. Directions on how to do that are in the next section.") ?>
534
+ </p>
535
+
536
+ <div class="ytindent">
537
+ <p>
538
+ <input name="<?php echo self::$opt_center; ?>" id="<?php echo self::$opt_center; ?>" <?php checked($all[self::$opt_center], 1); ?> type="checkbox" class="checkbox">
539
+ <label for="<?php echo self::$opt_center; ?>"><?php _e('Automatically center all your videos (not necessary if all you\'re videos span the whole width of your blog)') ?></label>
540
+ </p>
541
+ <p>
542
+ <input name="<?php echo self::$opt_autoplay; ?>" id="<?php echo self::$opt_autoplay; ?>" <?php checked($all[self::$opt_autoplay], 1); ?> type="checkbox" class="checkbox">
543
+ <label for="<?php echo self::$opt_autoplay; ?>"><?php _e('Automatically start playing your videos') ?></label>
544
+ </p>
545
+ <p>
546
+ <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">
547
+ <label for="<?php echo self::$opt_cc_load_policy; ?>"><?php _e('Turn on closed captions by default') ?></label>
548
+ </p>
549
+ <p>
550
+ <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">
551
+ <label for="<?php echo self::$opt_iv_load_policy; ?>"><?php _e('Show annotations by default') ?></label>
552
+ </p>
553
+ <p>
554
+ <input name="<?php echo self::$opt_loop; ?>" id="<?php echo self::$opt_loop; ?>" <?php checked($all[self::$opt_loop], 1); ?> type="checkbox" class="checkbox">
555
+ <label for="<?php echo self::$opt_loop; ?>"><?php _e('Loop all your videos') ?></label>
556
+ </p>
557
+ <p>
558
+ <input name="<?php echo self::$opt_modestbranding; ?>" id="<?php echo self::$opt_modestbranding; ?>" <?php checked($all[self::$opt_modestbranding], 1); ?> type="checkbox" class="checkbox">
559
+ <label for="<?php echo self::$opt_modestbranding; ?>"><?php _e('Modest branding - hide YouTube logo while playing') ?></label>
560
+ </p>
561
+ <p>
562
+ <input name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>" <?php checked($all[self::$opt_rel], 1); ?> type="checkbox" class="checkbox">
563
+ <label for="<?php echo self::$opt_rel; ?>"><?php _e('Show related videos at the end') ?></label>
564
+ </p>
565
+ <p>
566
+ <input name="<?php echo self::$opt_showinfo; ?>" id="<?php echo self::$opt_showinfo; ?>" <?php checked($all[self::$opt_showinfo], 1); ?> type="checkbox" class="checkbox">
567
+ <label for="<?php echo self::$opt_showinfo; ?>"><?php _e('Show the video title and other info') ?></label>
568
+ </p>
569
+ <p>
570
+ <input name="<?php echo self::$opt_theme; ?>" id="<?php echo self::$opt_theme; ?>" <?php checked($all[self::$opt_theme], 'dark'); ?> type="checkbox" class="checkbox">
571
+ <label for="<?php echo self::$opt_theme; ?>"><?php _e('Use the dark theme (uncheck to use light theme)') ?></label>
572
+ </p>
573
+ <p>
574
+ <input name="<?php echo self::$opt_vq; ?>" id="<?php echo self::$opt_vq; ?>" <?php checked($all[self::$opt_vq], 'hd720'); ?> type="checkbox" class="checkbox">
575
+ <label for="<?php echo self::$opt_vq; ?>"><?php _e('Force HD quality when available') ?></label>
576
+ </p>
577
+ <p class="submit">
578
+ <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
579
+ </p>
580
+ </div>
581
+
582
+ <h3>
583
+ <?php _e("How To Override Defaults / Other Options") ?>
584
+ </h3>
585
+ <?php
586
+ _e("<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 '&'. </p>");
587
+ _e('<ul>');
588
+ _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>");
589
+ _e("<li><strong>height</strong> - Sets the height of your player. If omitted, this will be calculated for you automatically. <em>Example: http://www.youtube.com/watch?v=quwebVjAEJA&width=500<strong>&height=350</strong></em> </li>");
590
+ _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>");
591
+ _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>");
592
+ _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>");
593
+ _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>");
594
+ _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>");
595
+ _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>");
596
+ _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>");
597
+ _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>");
598
+ _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>");
599
+ _e('</ul>');
600
+
601
+ _e("<p>You can also start and end each individual video at particular times. Like the above, each option should begin with '&'</p>");
602
+ _e('<ul>');
603
+ _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>");
604
+ _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>");
605
+ _e('</ul>');
606
+ ?>
607
+
608
+ </form>
609
+
610
+ </div>
611
+ <?php
612
+ }
613
+
614
+ public static function ytprefsscript()
615
+ {
616
+ wp_enqueue_script('__ytprefs__', plugins_url('scripts/ytprefs.min.js', __FILE__));
617
+ }
618
+
619
+ }
620
+
621
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
622
+ //class start
623
+ class Add_new_tinymce_btn_Youtubeprefs
624
+ {
625
+
626
+ public $btn_arr;
627
+ public $js_file;
628
+
629
+ /*
630
+ * call the constructor and set class variables
631
+ * From the constructor call the functions via wordpress action/filter
632
+ */
633
+
634
+ function __construct($seperator, $btn_name, $javascrip_location)
635
+ {
636
+ $this->btn_arr = array("Seperator" => $seperator, "Name" => $btn_name);
637
+ $this->js_file = $javascrip_location;
638
+ add_action('init', array($this, 'add_tinymce_button'));
639
+ add_filter('tiny_mce_version', array($this, 'refresh_mce_version'));
640
+ }
641
+
642
+ /*
643
+ * create the buttons only if the user has editing privs.
644
+ * If so we create the button and add it to the tinymce button array
645
+ */
646
+
647
+ function add_tinymce_button()
648
+ {
649
+ if (!current_user_can('edit_posts') && !current_user_can('edit_pages'))
650
+ return;
651
+ if (get_user_option('rich_editing') == 'true')
652
+ {
653
+ //the function that adds the javascript
654
+ add_filter('mce_external_plugins', array($this, 'add_new_tinymce_plugin'));
655
+ //adds the button to the tinymce button array
656
+ add_filter('mce_buttons', array($this, 'register_new_button'));
657
+ }
658
+ }
659
+
660
+ /*
661
+ * add the new button to the tinymce array
662
+ */
663
+
664
+ function register_new_button($buttons)
665
+ {
666
+ array_push($buttons, $this->btn_arr["Seperator"], $this->btn_arr["Name"]);
667
+ return $buttons;
668
+ }
669
+
670
+ /*
671
+ * Call the javascript file that loads the
672
+ * instructions for the new button
673
+ */
674
+
675
+ function add_new_tinymce_plugin($plugin_array)
676
+ {
677
+ $plugin_array[$this->btn_arr['Name']] = $this->js_file;
678
+ return $plugin_array;
679
+ }
680
+
681
+ /*
682
+ * This function tricks tinymce in thinking
683
+ * it needs to refresh the buttons
684
+ */
685
+
686
+ function refresh_mce_version($ver)
687
+ {
688
+ $ver += 3;
689
+ return $ver;
690
+ }
691
+
692
+ }
693
+
694
+ //class end
695
+
696
+
697
+ register_activation_hook(__FILE__, array('YouTubePrefs', 'initoptions'));
698
+ add_action('wp_enqueue_scripts', array('YouTubePrefs', 'ytprefsscript'));
699
+
700
+ $youtubeplg = new YouTubePrefs();
701
+
702
+ $epstatsmce_youtubeprefs = new Add_new_tinymce_btn_Youtubeprefs('|', 'embedplusstats_youtubeprefs', plugins_url() . '/youtube-embed-plus/scripts/embedplusstats_mce.js');
703
+ if (YouTubePrefs::wp_above_version('2.9'))
704
+ {
705
+ add_action('admin_enqueue_scripts', 'youtubeprefs_admin_enqueue_scripts');
706
+ }
707
+ else
708
+ {
709
+ wp_enqueue_style('embedplusyoutube', plugins_url() . '/youtube-embed-plus/scripts/embedplus_mce.css');
710
+ }
711
+
712
+ function youtubeprefs_admin_enqueue_scripts()
713
+ {
714
+ wp_enqueue_style('embedplusyoutube', plugins_url() . '/youtube-embed-plus/scripts/embedplus_mce.css');
715
+ }