YouTube - Version 2.3

Version Description

Download this release

Release Info

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

Version 2.3

images/clickdashboard.png ADDED
Binary file
images/epstats16.png ADDED
Binary file
images/ownline.jpg 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,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === YouTube ===
2
+ Contributors: embedplus
3
+ Plugin Name: YouTube Embed
4
+ Tags: 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.5.1
7
+ Stable tag: 2.3
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
+ * 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`
28
+ * 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`
29
+ * 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`
30
+ * loop - Set this to 1 to loop the video (or 0 to not loop). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&loop=1`
31
+ * 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`
32
+ * 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`
33
+ * 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`
34
+ * 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`
35
+
36
+ You can also start and end each individual video at particular times. Like the above, each option should begin with '&'
37
+
38
+ * start - Sets the time (in seconds) to start the video. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350&start=20`
39
+ * end - Sets the time (in seconds) to stop the video. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350&end=100`
40
+
41
+ == Installation ==
42
+
43
+ 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.
44
+ 1. Access the Plugins admin menu to activate the YouTube embed plugin.
45
+ 1. Make your default settings after clicking the new YouTube menu item that shows up in your admin panel.
46
+ 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.
47
+ 1. To get an analytics dashboard, [sign up for one of the options here >>](https://www.embedplus.com/dashboard/wordpress-video-analytics-seo.aspx)
48
+
49
+ Additional codes (adding these will override the default settings in the admin):
50
+
51
+ * 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`
52
+ * 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`
53
+ * 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`
54
+ * 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`
55
+ * 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`
56
+ * loop - Set this to 1 to loop the video (or 0 to not loop). Example: `http://www.youtube.com/watch?v=quwebVjAEJA&loop=1`
57
+ * 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`
58
+ * 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`
59
+ * 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`
60
+ * 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`
61
+
62
+ You can also start and end each individual video at particular times. Like the above, each option should begin with '&'
63
+
64
+ * start - Sets the time (in seconds) to start the video. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350&start=20`
65
+ * end - Sets the time (in seconds) to stop the video. Example: `http://www.youtube.com/watch?v=quwebVjAEJA&width=500&height=350&end=100`
66
+
67
+ = Contact =
68
+
69
+ Please use the Support forum until we put up a site for this plugin.
70
+
71
+ == Screenshots ==
72
+
73
+ 1. YouTube Embed Screenshot 1: Paste a YouTube link on its own line and it will become a YouTube embed on your website.
74
+ 2. YouTube Embed Screenshot 2: YouTube's admin settings.
75
+
76
+ == Changelog ==
77
+
78
+ = YouTube Embed 2.3 =
79
+ Start/end time shortcut bug fix
80
+
81
+ = YouTube Embed 2.2 =
82
+ Minor changes
83
+
84
+ = YouTube Embed 2.1 =
85
+ By request from several users, we've added easier access to the video analytics dashboard
86
+
87
+ = YouTube Embed 2.0 =
88
+
89
+ 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:
90
+
91
+ * How much are your visitors actually watching the videos you post?
92
+ * How does the view activity on your site compare to other sites like it?
93
+ * What and when are your best and worst performers?
94
+ * How much do the producers of the YouTube videos you embed rely on **your site** for views?
95
+
96
+ We think these are all interesting questions; however, note that there's no need to upgrade if you don't.
97
+
98
+ = YouTube Embed 1.1 =
99
+ Fixed minor bug.
100
+
101
+ = YouTube Embed 1.0 =
102
+ First release uploaded to the plugin repository.
103
+
104
+ == Other Notes ==
105
+
106
+ 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.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installdir = explode("wp-content", __FILE__);
3
+ $installdir = $installdir[0];
4
+
5
+ require( $installdir . 'wp-load.php' );
6
+ ?>
7
+
8
+ <?php if (false)
9
+ {
10
+ ?>
11
+
12
+
13
+ <script type="text/javascript">
14
+ <?php } ?>
15
+
16
+ (function() {
17
+ tinymce.create('tinymce.plugins.Embedplusstats_youtubeprefs', {
18
+ init : function(ed, url) {
19
+ var plep = new Image();
20
+ plep.src = url+'/btn_embedplusstats.png';
21
+ ed.addButton('embedplusstats_youtubeprefs', {
22
+ title : 'What happens after you embed a YouTube video? Click here to start using this popular feature from EmbedPlus Labs »',
23
+ onclick : function(ev) {
24
+ window.open('http://www.embedplus.com/dashboard/wordpress-video-analytics-seo.aspx', '_blank');
25
+ }
26
+ });
27
+
28
+ },
29
+ createControl : function(n, cm) {
30
+ return null;
31
+ },
32
+ getInfo : function() {
33
+ return {
34
+ longname : "Embedplus Video Analytics Dashboard",
35
+ author : 'EmbedPlus',
36
+ authorurl : 'http://www.embedplus.com/',
37
+ infourl : 'http://www.embedplus.com/',
38
+ version : "2.1"
39
+ };
40
+ }
41
+ });
42
+ tinymce.PluginManager.add('embedplusstats_youtubeprefs', tinymce.plugins.Embedplusstats_youtubeprefs);
43
+
44
+ })();
45
+
46
+ <?php if (false)
47
+ {
48
+ ?>
49
+ </script>
50
+ <?php } ?>
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,664 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.3
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.3';
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_alloptions = 'youtubeprefs_alloptions';
52
+ public static $alloptions = null;
53
+ public static $yt_options = array();
54
+
55
+ /*
56
+ color
57
+ controls
58
+ disablekb
59
+ enablejsapi
60
+ list
61
+ listType
62
+ playlist
63
+ *
64
+ */
65
+ public static $ytregex = '@^\s*https?://(?:www\.)?(?:youtube.com/watch\?|youtu.be/)([^\s"]+)\s*$@im';
66
+
67
+ public function __construct()
68
+ {
69
+ $do_autoembeds = get_option('embed_autourls');
70
+ if ($do_autoembeds == 0)
71
+ {
72
+ update_option('embed_autourls', 1);
73
+ }
74
+
75
+ self::$alloptions = get_option(self::$opt_alloptions);
76
+ if (self::$alloptions == false || version_compare(self::$alloptions[self::$opt_version], self::$version, '<'))
77
+ {
78
+ self::initoptions();
79
+ }
80
+ self::$optembedwidth = intval(get_option('embed_size_w'));
81
+ self::$optembedheight = intval(get_option('embed_size_h'));
82
+
83
+ self::$yt_options = array(
84
+ self::$opt_autoplay,
85
+ self::$opt_cc_load_policy,
86
+ self::$opt_iv_load_policy,
87
+ self::$opt_loop,
88
+ self::$opt_modestbranding,
89
+ self::$opt_rel,
90
+ self::$opt_showinfo,
91
+ self::$opt_theme,
92
+ 'start',
93
+ 'end'
94
+ );
95
+
96
+ self::do_ytprefs();
97
+
98
+ if (self::wp_above_version('2.9'))
99
+ {
100
+ add_action('admin_menu', 'YouTubePrefs::ytprefs_plugin_menu');
101
+ }
102
+ // if (!is_admin())
103
+ // {
104
+ // // allow shortcode in widgets
105
+ // //add_filter('widget_text', 'do_shortcode', 11);
106
+ // }
107
+ }
108
+
109
+ static function initoptions()
110
+ {
111
+ if (self::wp_above_version('2.9'))
112
+ {
113
+ if (get_option(self::$opt_alloptions) === false)
114
+ {
115
+ $_auto_hd = get_option('youtubeprefs_auto_hd', 0);
116
+ $_autoplay = get_option('youtubeprefs_autoplay', 0);
117
+ $_cc_load_policy = get_option('youtubeprefs_cc_load_policy', 0);
118
+ $_iv_load_policy = get_option('youtubeprefs_iv_load_policy', 1);
119
+ $_loop = get_option('youtubeprefs_loop', 0);
120
+ $_modestbranding = get_option('youtubeprefs_modestbranding', 0);
121
+ $_rel = get_option('youtubeprefs_rel', 1);
122
+ $_showinfo = get_option('youtubeprefs_showinfo', 1);
123
+ $_theme = get_option('youtubeprefs_theme', 'dark');
124
+
125
+ $all = array(
126
+ self::$opt_version => self::$version,
127
+ self::$opt_center => 0,
128
+ self::$opt_auto_hd => $_auto_hd,
129
+ self::$opt_autoplay => $_autoplay,
130
+ self::$opt_cc_load_policy => $_cc_load_policy,
131
+ self::$opt_iv_load_policy => $_iv_load_policy,
132
+ self::$opt_loop => $_loop,
133
+ self::$opt_modestbranding => $_modestbranding,
134
+ self::$opt_rel => $_rel,
135
+ self::$opt_showinfo => $_showinfo,
136
+ self::$opt_theme => $_theme
137
+ );
138
+
139
+ add_option(self::$opt_alloptions, $all);
140
+
141
+ // add_option(self::$opt_auto_hd, 0);
142
+ // add_option(self::$opt_autoplay, 0);
143
+ // add_option(self::$opt_cc_load_policy, 0);
144
+ // add_option(self::$opt_iv_load_policy, 1);
145
+ // add_option(self::$opt_loop, 0);
146
+ // add_option(self::$opt_modestbranding, 0);
147
+ // add_option(self::$opt_rel, 1);
148
+ // add_option(self::$opt_showinfo, 1);
149
+ // add_option(self::$opt_theme, 'dark');
150
+
151
+ update_option('embed_autourls', 1);
152
+ }
153
+ self::$alloptions = get_option(self::$opt_alloptions);
154
+ }
155
+ }
156
+
157
+ public static function wp_above_version($ver)
158
+ {
159
+ global $wp_version;
160
+ if (version_compare($wp_version, $ver, '>='))
161
+ {
162
+ return true;
163
+ }
164
+ return false;
165
+ }
166
+
167
+ public static function do_ytprefs()
168
+ {
169
+ if (self::wp_above_version('2.9') && !is_admin())
170
+ {
171
+ add_filter('the_content', 'YouTubePrefs::apply_prefs', 1);
172
+ }
173
+ }
174
+
175
+ public static function apply_prefs($content)
176
+ {
177
+ $content = preg_replace_callback(self::$ytregex, "YouTubePrefs::get_html", $content);
178
+ return $content;
179
+ }
180
+
181
+ public static function get_html($m)
182
+ {
183
+ $link = trim(preg_replace('/&amp;/i', '&', $m[0]));
184
+ $link = preg_replace('/\s/', '', $link);
185
+ $linkparams = explode('?', $link);
186
+ $linkparams = self::keyvalue($linkparams[1], true);
187
+ self::init_dimensions($link, $linkparams);
188
+
189
+ $linkscheme = parse_url($link, PHP_URL_SCHEME);
190
+
191
+ $code1 = '<iframe id="_ytid_' . rand(10000, 99999) . '" width="' . self::$defaultwidth . '" height="' . self::$defaultheight .
192
+ '" src="' . $linkscheme . '://www.youtube.com/embed/' . $linkparams['v'] . '?';
193
+ $code2 = '" frameborder="0" allowfullscreen type="text/html" class="__youtube_prefs__"></iframe>';
194
+
195
+ /*
196
+ $prefparams = array();
197
+
198
+ //get_option(self::$opt_auto_hd, 0);
199
+ $autoplay = get_option(self::$opt_autoplay, 0);
200
+ $cc_load_policy = get_option(self::$opt_cc_load_policy, 0) == 1 ? 1 : '';
201
+ $iv_load_policy = get_option(self::$opt_iv_load_policy, 1);
202
+ $loop = get_option(self::$opt_loop, 0);
203
+ $modestbranding = get_option(self::$opt_modestbranding, 0) == 1 ? 1 : '';
204
+ $rel = get_option(self::$opt_rel, 1);
205
+ $showinfo = get_option(self::$opt_showinfo, 1);
206
+ $theme = get_option(self::$opt_theme, 'dark');
207
+
208
+ if ($autoplay == 1)
209
+ $prefparams['autoplay'] = 1;
210
+ if ($cc_load_policy == 1)
211
+ $prefparams['cc_load_policy'] = 1;
212
+ if ($iv_load_policy == 3)
213
+ $prefparams['iv_load_policy'] = 3;
214
+ if ($loop == 1)
215
+ $prefparams['loop'] = 1;
216
+ if ($modestbranding == 1)
217
+ $prefparams['modestbranding'] = 1;
218
+ if ($rel == 0)
219
+ $prefparams['rel'] = 0;
220
+ if ($showinfo == 0)
221
+ $prefparams['showinfo'] = 0;
222
+ if ($theme == 'light')
223
+ $prefparams['theme'] = 'light';
224
+ */
225
+
226
+ $finalparams = $linkparams + self::$alloptions;
227
+ $origin = '';
228
+
229
+ try
230
+ {
231
+ if (!empty($_SERVER["HTTP_HOST"]))
232
+ {
233
+ $origin = 'origin=' .
234
+ ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://') . $_SERVER["HTTP_HOST"] . '&';
235
+ }
236
+ }
237
+ catch (Exception $e)
238
+ {
239
+
240
+ }
241
+ $finalsrc = 'enablejsapi=1&'; // . $origin;
242
+
243
+ if (count($finalparams) > 1)
244
+ {
245
+ foreach ($finalparams as $key => $value)
246
+ {
247
+ if (in_array($key, self::$yt_options))
248
+ {
249
+ $finalsrc .= htmlspecialchars($key) . '=' . htmlspecialchars($value) . '&';
250
+ if ($key == 'loop' && $value == 1)
251
+ $finalsrc .= 'playlist=' . $finalparams['v'] . '&';
252
+ }
253
+ }
254
+ }
255
+
256
+ $code = $code1 . $finalsrc . $code2;
257
+
258
+ if (self::$alloptions[self::$opt_center] == 1)
259
+ {
260
+ $code = '<div style="text-align: center; display: block;">' . $code . '</div>';
261
+ }
262
+
263
+ // reset static vals for next embed
264
+ self::$defaultheight = null;
265
+ self::$defaultwidth = null;
266
+
267
+ return $code;
268
+ }
269
+
270
+ public static function keyvalue($qry, $includev)
271
+ {
272
+ $ytvars = explode('&', $qry);
273
+ $ytkvp = array();
274
+ foreach ($ytvars as $k => $v)
275
+ {
276
+ $kvp = explode('=', $v);
277
+ if (count($kvp) == 2 && ($includev || strtolower($kvp[0]) != 'v'))
278
+ {
279
+ $ytkvp[$kvp[0]] = $kvp[1];
280
+ }
281
+ }
282
+
283
+ return $ytkvp;
284
+ }
285
+
286
+ public static function init_dimensions($url, $urlkvp)
287
+ {
288
+ // get default dimensions; try embed size in settings, then try theme's content width, then just 480px
289
+ if (self::$defaultwidth == null)
290
+ {
291
+ global $content_width;
292
+ if (empty($content_width))
293
+ $content_width = $GLOBALS['content_width'];
294
+
295
+ self::$defaultwidth = $urlkvp['width'] ? $urlkvp['width'] : (self::$optembedwidth ? self::$optembedwidth : ($content_width ? $content_width : 480));
296
+ self::$defaultheight = self::get_aspect_height($url);
297
+ }
298
+ }
299
+
300
+ public static function get_aspect_height($url)
301
+ {
302
+
303
+ // attempt to get aspect ratio correct height from oEmbed
304
+ $aspectheight = round((self::$defaultwidth * 9) / 16, 0);
305
+ if ($url)
306
+ {
307
+ require_once( ABSPATH . WPINC . '/class-oembed.php' );
308
+ $oembed = _wp_oembed_get_object();
309
+ $args = array();
310
+ $args['width'] = self::$defaultwidth;
311
+ $args['height'] = self::$optembedheight;
312
+ $args['discover'] = false;
313
+ $odata = $oembed->fetch('http://www.youtube.com/oembed', $url, $args);
314
+
315
+ if ($odata)
316
+ {
317
+ $aspectheight = $odata->height;
318
+ }
319
+ }
320
+
321
+ //add 30 for YouTube's own bar
322
+ return $aspectheight + 30;
323
+ }
324
+
325
+ public static function ytprefs_plugin_menu()
326
+ {
327
+ add_menu_page('YouTube Settings', 'YouTube', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options', plugins_url('images/youtubeicon16.png', __FILE__), '10.00392854349');
328
+ add_menu_page('YouTube Analytics Dashboard', 'My YouTube Performance', 'manage_options', 'youtube-ep-analytics-dashboard', 'YouTubePrefs::epstats_show_options', plugins_url('images/epstats16.png', __FILE__), '10.00492884349');
329
+ }
330
+
331
+ public static function epstats_show_options()
332
+ {
333
+
334
+ if (!current_user_can('manage_options'))
335
+ {
336
+ wp_die(__('You do not have sufficient permissions to access this page.'));
337
+ }
338
+
339
+ // Now display the settings editing screen
340
+ ?>
341
+ <div class="wrap">
342
+ <?php
343
+ // header
344
+
345
+ echo "<h2>" . '<img src="' . plugins_url('images/epstats16.png', __FILE__) . '" /> ' . __('YouTube Analytics Dashboard') . "</h2>";
346
+
347
+ // settings form
348
+ ?>
349
+ <style type="text/css">
350
+ .epicon { width: 20px; height: 20px; vertical-align: middle; padding-right: 5px;}
351
+ .epindent {padding-left: 25px;}
352
+ </style>
353
+ <br>
354
+ <iframe style="-webkit-box-shadow: 0px 0px 20px 0px #000000; box-shadow: 0px 0px 20px 0px #000000;" src="https://www.embedplus.com/dashboard/wordpress-video-analytics-seo.aspx?domain=<?php echo (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ""); ?>" width="1030" height="1600" scrolling="auto"/>
355
+ </div>
356
+ <?php
357
+ }
358
+
359
+ public static function ytprefs_show_options()
360
+ {
361
+
362
+ if (!current_user_can('manage_options'))
363
+ {
364
+ wp_die(__('You do not have sufficient permissions to access this page.'));
365
+ }
366
+
367
+ // variables for the field and option names
368
+ $ytprefs_submitted = 'ytprefs_submitted';
369
+
370
+ // Read in existing option values from database
371
+ /*
372
+ $auto_hd = get_option(self::$opt_auto_hd);
373
+ $autoplay = get_option(self::$opt_autoplay, 0);
374
+ $cc_load_policy = get_option(self::$opt_cc_load_policy, 0);
375
+ $iv_load_policy = get_option(self::$opt_iv_load_policy, 1);
376
+ $loop = get_option(self::$opt_loop, 0);
377
+ $modestbranding = get_option(self::$opt_modestbranding, 0);
378
+ $rel = get_option(self::$opt_rel, 1);
379
+ $showinfo = get_option(self::$opt_showinfo, 1);
380
+ $theme = get_option(self::$opt_theme, 'dark');
381
+ */
382
+
383
+ $all = get_option(self::$opt_alloptions);
384
+
385
+ // See if the user has posted us some information
386
+ // If they did, this hidden field will be set to 'Y'
387
+ if (isset($_POST[$ytprefs_submitted]) && $_POST[$ytprefs_submitted] == 'Y')
388
+ {
389
+ // Read their posted values
390
+ // $auto_hd = $_POST[self::$opt_auto_hd] == (true || 'on') ? 1 : 0;
391
+ // $autoplay = $_POST[self::$opt_autoplay] == (true || 'on') ? 1 : 0;
392
+ // $cc_load_policy = $_POST[self::$opt_cc_load_policy] == (true || 'on') ? 1 : 0;
393
+ // $iv_load_policy = $_POST[self::$opt_iv_load_policy] == (true || 'on') ? 1 : 3;
394
+ // $loop = $_POST[self::$opt_loop] == (true || 'on') ? 1 : 0;
395
+ // $modestbranding = $_POST[self::$opt_modestbranding] == (true || 'on') ? 1 : 0;
396
+ // $rel = $_POST[self::$opt_rel] == (true || 'on') ? 1 : 0;
397
+ // $showinfo = $_POST[self::$opt_showinfo] == (true || 'on') ? 1 : 0;
398
+ // $theme = $_POST[self::$opt_theme] == (true || 'on') ? 'dark' : 'light';
399
+
400
+ $new_options = array();
401
+ $new_options[self::$opt_center] = $_POST[self::$opt_center] == (true || 'on') ? 1 : 0;
402
+ $new_options[self::$opt_auto_hd] = $_POST[self::$opt_auto_hd] == (true || 'on') ? 1 : 0;
403
+ $new_options[self::$opt_autoplay] = $_POST[self::$opt_autoplay] == (true || 'on') ? 1 : 0;
404
+ $new_options[self::$opt_cc_load_policy] = $_POST[self::$opt_cc_load_policy] == (true || 'on') ? 1 : 0;
405
+ $new_options[self::$opt_iv_load_policy] = $_POST[self::$opt_iv_load_policy] == (true || 'on') ? 1 : 3;
406
+ $new_options[self::$opt_loop] = $_POST[self::$opt_loop] == (true || 'on') ? 1 : 0;
407
+ $new_options[self::$opt_modestbranding] = $_POST[self::$opt_modestbranding] == (true || 'on') ? 1 : 0;
408
+ $new_options[self::$opt_rel] = $_POST[self::$opt_rel] == (true || 'on') ? 1 : 0;
409
+ $new_options[self::$opt_showinfo] = $_POST[self::$opt_showinfo] == (true || 'on') ? 1 : 0;
410
+ $new_options[self::$opt_theme] = $_POST[self::$opt_theme] == (true || 'on') ? 'dark' : 'light';
411
+
412
+ $all = $new_options + $all;
413
+
414
+ // Save the posted value in the database
415
+ // update_option(self::$opt_auto_hd, $auto_hd);
416
+ // update_option(self::$opt_autoplay, $autoplay);
417
+ // update_option(self::$opt_cc_load_policy, $cc_load_policy);
418
+ // update_option(self::$opt_iv_load_policy, $iv_load_policy);
419
+ // update_option(self::$opt_loop, $loop);
420
+ // update_option(self::$opt_modestbranding, $modestbranding);
421
+ // update_option(self::$opt_rel, $rel);
422
+ // update_option(self::$opt_showinfo, $showinfo);
423
+ // update_option(self::$opt_theme, $theme);
424
+
425
+ update_option(self::$opt_alloptions, $all);
426
+ // Put a settings updated message on the screen
427
+ ?>
428
+ <div class="updated"><p><strong><?php _e('Settings saved.'); ?></strong></p></div>
429
+ <?php
430
+ }
431
+
432
+ // Now display the settings editing screen
433
+
434
+ echo '<div class="wrap">';
435
+
436
+ // header
437
+
438
+ echo "<h2>" . '<img src="' . plugins_url('images/youtubeicon16.png', __FILE__) . '" /> ' . __('YouTube Preferences') . "</h2>";
439
+
440
+ echo '<em>Hear about major upcoming announcements and feature updates by <a target="_blank" href="http://eepurl.com/tpof9">signing up here</a>.</em>';
441
+
442
+ echo '<a style="display: block; padding-top: 10px; text-decoration: none;" target="_blank" href="http://www.embedplus.com/dashboard/wordpress-video-analytics-seo.aspx"><img src="' . plugins_url('images/clickdashboard.png', __FILE__) . '" /></a>';
443
+
444
+ // settings form
445
+ ?>
446
+
447
+ <p>
448
+ Need support? Email us at <?php echo antispambot('team@embedplus.com') ?>. Due to the number of feature requests we get, priority will be give to users currently subscribing to one of our available <a href="https://www.embedplus.com/dashboard/easy-video-analytics-seo.aspx" target="_blank">analytics options &raquo;</a>.
449
+ </p>
450
+
451
+ <style type="text/css">
452
+ #ytform p { line-height: 20px; }
453
+ #ytform ul li {margin-left: 30px; list-style: disc outside none;}
454
+ .ytindent {padding: 0px 0px 0px 20px;}
455
+ .shadow {-webkit-box-shadow: 0px 0px 20px 0px #000000; box-shadow: 0px 0px 20px 0px #000000;}
456
+ </style>
457
+
458
+ <div class="ytindent">
459
+ <form name="form1" method="post" action="" id="ytform">
460
+ <input type="hidden" name="<?php echo $ytprefs_submitted; ?>" value="Y">
461
+ <h3>
462
+ <?php _e("How to Insert a YouTube Video") ?>
463
+ </h3>
464
+ <p>
465
+ 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?
466
+ </p>
467
+ <p>
468
+ <img class="shadow" src="<?php echo plugins_url('images/ownline.jpg', __FILE__) ?>" />
469
+ </p>
470
+
471
+ <p>
472
+ Note: Make sure the link is in plain text (not hyperlinked/blue).
473
+ </p>
474
+
475
+ <h3>
476
+ <?php _e("Default Options") ?>
477
+ </h3>
478
+ <p>
479
+ <?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.") ?>
480
+ </p>
481
+
482
+ <div class="ytindent">
483
+ <p>
484
+ <input name="<?php echo self::$opt_center; ?>" id="<?php echo self::$opt_center; ?>" <?php checked($all[self::$opt_center], 1); ?> type="checkbox" class="checkbox">
485
+ <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>
486
+ </p>
487
+ <p>
488
+ <input name="<?php echo self::$opt_autoplay; ?>" id="<?php echo self::$opt_autoplay; ?>" <?php checked($all[self::$opt_autoplay], 1); ?> type="checkbox" class="checkbox">
489
+ <label for="<?php echo self::$opt_autoplay; ?>"><?php _e('Automatically start playing your videos') ?></label>
490
+ </p>
491
+ <p>
492
+ <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">
493
+ <label for="<?php echo self::$opt_cc_load_policy; ?>"><?php _e('Turn on closed captions by default') ?></label>
494
+ </p>
495
+ <p>
496
+ <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">
497
+ <label for="<?php echo self::$opt_iv_load_policy; ?>"><?php _e('Show annotations by default') ?></label>
498
+ </p>
499
+ <p>
500
+ <input name="<?php echo self::$opt_loop; ?>" id="<?php echo self::$opt_loop; ?>" <?php checked($all[self::$opt_loop], 1); ?> type="checkbox" class="checkbox">
501
+ <label for="<?php echo self::$opt_loop; ?>"><?php _e('Loop all your videos') ?></label>
502
+ </p>
503
+ <p>
504
+ <input name="<?php echo self::$opt_modestbranding; ?>" id="<?php echo self::$opt_modestbranding; ?>" <?php checked($all[self::$opt_modestbranding], 1); ?> type="checkbox" class="checkbox">
505
+ <label for="<?php echo self::$opt_modestbranding; ?>"><?php _e('Modest branding - hide YouTube logo while playing') ?></label>
506
+ </p>
507
+ <p>
508
+ <input name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>" <?php checked($all[self::$opt_rel], 1); ?> type="checkbox" class="checkbox">
509
+ <label for="<?php echo self::$opt_rel; ?>"><?php _e('Show related videos at the end') ?></label>
510
+ </p>
511
+ <p>
512
+ <input name="<?php echo self::$opt_showinfo; ?>" id="<?php echo self::$opt_showinfo; ?>" <?php checked($all[self::$opt_showinfo], 1); ?> type="checkbox" class="checkbox">
513
+ <label for="<?php echo self::$opt_showinfo; ?>"><?php _e('Show the video title and other info') ?></label>
514
+ </p>
515
+ <p>
516
+ <input name="<?php echo self::$opt_theme; ?>" id="<?php echo self::$opt_theme; ?>" <?php checked($all[self::$opt_theme], 'dark'); ?> type="checkbox" class="checkbox">
517
+ <label for="<?php echo self::$opt_theme; ?>"><?php _e('Use the dark theme (uncheck to use light theme)') ?></label>
518
+ </p>
519
+ <p class="submit">
520
+ <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
521
+ </p>
522
+ </div>
523
+
524
+ <h3>
525
+ <?php _e("How To Override Defaults / Other Options") ?>
526
+ </h3>
527
+ <?php
528
+ _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>");
529
+ _e('<ul>');
530
+ _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>");
531
+ _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>");
532
+ _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>");
533
+ _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>");
534
+ _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>");
535
+ _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>");
536
+ _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>");
537
+ _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>");
538
+ _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>");
539
+ _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>");
540
+ _e('</ul>');
541
+
542
+ _e("<p>You can also start and end each individual video at particular times. Like the above, each option should begin with '&'</p>");
543
+ _e('<ul>');
544
+ _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>");
545
+ _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>");
546
+ _e('</ul>');
547
+ ?>
548
+
549
+ </form>
550
+
551
+ <h3><?php _e('Other Notes') ?></h3>
552
+ <P>
553
+ <?php _e("Note that this is a no-frills plugin. We're just supporting the basic functions that people typically want when embedding YouTube videos, and providing an easy way to make defaults. If you want more, take a look at a more powerful one here: <a target=\"_blank\" href=\"http://wordpress.org/extend/plugins/embedplus-for-wordpress/\">Advanced YouTube Embed</a> by <a target=\"_blank\" href=\"http://www.embedplus.com\">EmbedPlus</a>."); ?>
554
+ </p>
555
+ <p>
556
+ <?php echo '<em>Hear about major upcoming announcements and feature updates by <a target="_blank" href="http://eepurl.com/tpof9">signing up here</a>.</em>'; ?>
557
+ </p>
558
+
559
+ </div>
560
+ <?php
561
+ }
562
+
563
+ public static function ytprefsscript()
564
+ {
565
+ wp_enqueue_script('__ytprefs__', plugins_url('scripts/ytprefs.min.js', __FILE__));
566
+ }
567
+
568
+ }
569
+
570
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
571
+ //class start
572
+ class Add_new_tinymce_btn_Youtubeprefs
573
+ {
574
+
575
+ public $btn_arr;
576
+ public $js_file;
577
+
578
+ /*
579
+ * call the constructor and set class variables
580
+ * From the constructor call the functions via wordpress action/filter
581
+ */
582
+
583
+ function __construct($seperator, $btn_name, $javascrip_location)
584
+ {
585
+ $this->btn_arr = array("Seperator" => $seperator, "Name" => $btn_name);
586
+ $this->js_file = $javascrip_location;
587
+ add_action('init', array($this, 'add_tinymce_button'));
588
+ add_filter('tiny_mce_version', array($this, 'refresh_mce_version'));
589
+ }
590
+
591
+ /*
592
+ * create the buttons only if the user has editing privs.
593
+ * If so we create the button and add it to the tinymce button array
594
+ */
595
+
596
+ function add_tinymce_button()
597
+ {
598
+ if (!current_user_can('edit_posts') && !current_user_can('edit_pages'))
599
+ return;
600
+ if (get_user_option('rich_editing') == 'true')
601
+ {
602
+ //the function that adds the javascript
603
+ add_filter('mce_external_plugins', array($this, 'add_new_tinymce_plugin'));
604
+ //adds the button to the tinymce button array
605
+ add_filter('mce_buttons', array($this, 'register_new_button'));
606
+ }
607
+ }
608
+
609
+ /*
610
+ * add the new button to the tinymce array
611
+ */
612
+
613
+ function register_new_button($buttons)
614
+ {
615
+ array_push($buttons, $this->btn_arr["Seperator"], $this->btn_arr["Name"]);
616
+ return $buttons;
617
+ }
618
+
619
+ /*
620
+ * Call the javascript file that loads the
621
+ * instructions for the new button
622
+ */
623
+
624
+ function add_new_tinymce_plugin($plugin_array)
625
+ {
626
+ $plugin_array[$this->btn_arr['Name']] = $this->js_file;
627
+ return $plugin_array;
628
+ }
629
+
630
+ /*
631
+ * This function tricks tinymce in thinking
632
+ * it needs to refresh the buttons
633
+ */
634
+
635
+ function refresh_mce_version($ver)
636
+ {
637
+ $ver += 3;
638
+ return $ver;
639
+ }
640
+
641
+ }
642
+
643
+ //class end
644
+
645
+
646
+ register_activation_hook(__FILE__, array('YouTubePrefs', 'initoptions'));
647
+ add_action('wp_enqueue_scripts', array('YouTubePrefs', 'ytprefsscript'));
648
+
649
+ $youtubeplg = new YouTubePrefs();
650
+
651
+ $epstatsmce_youtubeprefs = new Add_new_tinymce_btn_Youtubeprefs('|', 'embedplusstats_youtubeprefs', plugins_url() . '/youtube-embed-plus/scripts/embedplusstats_mce.js.php');
652
+ if (YouTubePrefs::wp_above_version('2.9'))
653
+ {
654
+ add_action('admin_enqueue_scripts', 'youtubeprefs_admin_enqueue_scripts');
655
+ }
656
+ else
657
+ {
658
+ wp_enqueue_style('embedpluswiz', plugins_url() . '/youtube-embed-plus/scripts/embedplus_mce.css');
659
+ }
660
+
661
+ function youtubeprefs_admin_enqueue_scripts()
662
+ {
663
+ wp_enqueue_style('embedpluswiz', plugins_url() . '/youtube-embed-plus/scripts/embedplus_mce.css');
664
+ }