YouTube - Version 1.0

Version Description

Download this release

Release Info

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

Version 1.0

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,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === YouTube ===
2
+ Contributors: embedplus
3
+ Plugin Name: YouTube Embed
4
+ Tags: basic 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
7
+ Stable tag: 1.0
8
+ License: GPLv3 or later
9
+
10
+ YouTube embed plugin for WordPress. Provides the basic features of YouTube for your blog, and convenient defaults.
11
+
12
+ == Description ==
13
+
14
+ This YouTube embed plugin for WordPress is very simple. It provides the basic features of YouTube, and will have you embedding in seconds after installing it. 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).
15
+
16
+ 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:
17
+
18
+ * 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
19
+ * 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
20
+ * 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
21
+ * 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
22
+ * 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
23
+ * loop - Set this to 1 to loop the video (or 0 to not loop). Example: http://www.youtube.com/watch?v=quwebVjAEJA&loop=1
24
+ * 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
25
+ * * 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
26
+ * 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
27
+ * 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
28
+
29
+ == Installation ==
30
+
31
+ 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.
32
+ 1. Access the Plugins admin menu to activate the YouTube embed plugin.
33
+ 1. Make your default settings after clicking the new YouTube menu item that shows up in your admin panel.
34
+ 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.
35
+
36
+ Additional codes (adding these will override the default settings in the admin):
37
+
38
+ * 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
39
+ * 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
40
+ * 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
41
+ * 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
42
+ * 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
43
+ * loop - Set this to 1 to loop the video (or 0 to not loop). Example: http://www.youtube.com/watch?v=quwebVjAEJA&loop=1
44
+ * 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
45
+ * 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
46
+ * 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
47
+ * 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
48
+
49
+ = Contact =
50
+
51
+ Please use the Support forum until we put up a site for this plugin.
52
+
53
+ == Screenshots ==
54
+
55
+ 1. YouTube Embed Screenshot 1: Paste a YouTube link on its own line and it will become a YouTube embed on your website.
56
+ 2. YouTube Embed Screenshot 2: YouTube's admin settings.
57
+
58
+ == Changelog ==
59
+
60
+ = YouTube Embed 1.0 =
61
+
62
+ First release uploaded to the plugin repository.
63
+
64
+ == Other Notes ==
65
+
66
+ Again, note that this is a no-frills plugin. We're just supporting the basic functions that people typically want when embedding YouTube videos. If you want more, take a look at a more powerful one 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
youtube.php ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: YouTube Embed
4
+ Plugin URI: http://www.embedplus.com
5
+ Description: YouTube embed plugin for WordPress. Provides the basic features of YouTube for your blog, and convenient defaults.
6
+ Version: 1.0
7
+ Author: EmbedPlus Team
8
+ Author URI: http://www.embedplus.com
9
+ */
10
+
11
+ /*
12
+ YouTube Embed
13
+ Copyright (C) 2012 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 $optembedwidth = null;
36
+ public static $optembedheight = null;
37
+ public static $defaultheight = null;
38
+ public static $defaultwidth = null;
39
+ public static $opt_auto_hd = 'youtubeprefs_auto_hd';
40
+ public static $opt_autoplay = 'youtubeprefs_autoplay';
41
+ public static $opt_cc_load_policy = 'youtubeprefs_cc_load_policy';
42
+ public static $opt_iv_load_policy = 'youtubeprefs_iv_load_policy';
43
+ public static $opt_loop = 'youtubeprefs_loop';
44
+ public static $opt_modestbranding = 'youtubeprefs_modestbranding';
45
+ public static $opt_rel = 'youtubeprefs_rel';
46
+ public static $opt_showinfo = 'youtubeprefs_showinfo';
47
+ public static $opt_theme = 'youtubeprefs_theme';
48
+
49
+ /*
50
+ color
51
+ controls
52
+ disablekb
53
+ enablejsapi
54
+ list
55
+ listType
56
+ playlist
57
+ *
58
+ */
59
+ public static $ytregex = '@^\s*https?://(?:www\.)?(?:youtube.com/watch\?|youtu.be/)([^\s"]+)\s*$@im';
60
+
61
+ public function __construct()
62
+ {
63
+
64
+ $do_autoembeds = get_option('embed_autourls');
65
+ if ($do_autoembeds == 0)
66
+ {
67
+ update_option('embed_autourls', 1);
68
+ }
69
+ self::do_ytprefs();
70
+
71
+ if (self::wp_above_version('2.9'))
72
+ {
73
+ add_action('admin_menu', 'YouTubePrefs::ytprefs_plugin_menu');
74
+ }
75
+ // if (!is_admin())
76
+ // {
77
+ // // allow shortcode in widgets
78
+ // //add_filter('widget_text', 'do_shortcode', 11);
79
+ // }
80
+
81
+ }
82
+
83
+ static function initoptions()
84
+ {
85
+ if (self::wp_above_version('2.9'))
86
+ {
87
+ add_option(self::$opt_auto_hd, 0);
88
+ add_option(self::$opt_autoplay, 0);
89
+ add_option(self::$opt_cc_load_policy, 0);
90
+ add_option(self::$opt_iv_load_policy, 1);
91
+ add_option(self::$opt_loop, 0);
92
+ add_option(self::$opt_modestbranding, 0);
93
+ add_option(self::$opt_rel, 1);
94
+ add_option(self::$opt_showinfo, 1);
95
+ add_option(self::$opt_theme, 'dark');
96
+
97
+ update_option('embed_autourls', 1);
98
+ }
99
+ }
100
+
101
+ public static function wp_above_version($ver)
102
+ {
103
+ global $wp_version;
104
+ if (version_compare($wp_version, $ver, '>='))
105
+ {
106
+ return true;
107
+ }
108
+ return false;
109
+ }
110
+
111
+ public static function do_ytprefs()
112
+ {
113
+ if (self::wp_above_version('2.9') && !is_admin())
114
+ {
115
+ add_filter('the_content', 'YouTubePrefs::apply_prefs', 1);
116
+ }
117
+ }
118
+
119
+ public static function apply_prefs($content)
120
+ {
121
+ $content = preg_replace_callback(self::$ytregex, "YouTubePrefs::get_html", $content);
122
+ return $content;
123
+ }
124
+
125
+ public static function get_html($m)
126
+ {
127
+ $link = trim(preg_replace('/&amp;/i', '&', $m[0]));
128
+ $link = preg_replace('/\s/', '', $link);
129
+ $linkparams = explode('?', $link);
130
+ $linkparams = self::keyvalue($linkparams[1], true);
131
+ self::init_dimensions($link, $linkparams);
132
+
133
+ $linkscheme = parse_url($link, PHP_URL_SCHEME);
134
+
135
+ $code1 = '<iframe width="' . self::$defaultwidth . '" height="' . self::$defaultheight .
136
+ '" src="' . $linkscheme . '://www.youtube.com/embed/' . $linkparams['v'] . '?';
137
+ $code2 = '" frameborder="0" allowfullscreen></iframe>';
138
+
139
+ $prefparams = array();
140
+
141
+ //get_option(self::$opt_auto_hd, 0);
142
+ $autoplay = get_option(self::$opt_autoplay, 0);
143
+ $cc_load_policy = get_option(self::$opt_cc_load_policy, 0) == 1 ? 1 : '';
144
+ $iv_load_policy = get_option(self::$opt_iv_load_policy, 1);
145
+ $loop = get_option(self::$opt_loop, 0);
146
+ $modestbranding = get_option(self::$opt_modestbranding, 0) == 1 ? 1 : '';
147
+ $rel = get_option(self::$opt_rel, 1);
148
+ $showinfo = get_option(self::$opt_showinfo, 1);
149
+ $theme = get_option(self::$opt_theme, 'dark');
150
+
151
+ if ($autoplay == 1)
152
+ $prefparams['autoplay'] = 1;
153
+ if ($cc_load_policy == 1)
154
+ $prefparams['cc_load_policy'] = 1;
155
+ if ($iv_load_policy == 3)
156
+ $prefparams['iv_load_policy'] = 3;
157
+ if ($loop == 1)
158
+ $prefparams['loop'] = 1;
159
+ if ($modestbranding == 1)
160
+ $prefparams['modestbranding'] = 1;
161
+ if ($rel == 0)
162
+ $prefparams['rel'] = 0;
163
+ if ($showinfo == 0)
164
+ $prefparams['showinfo'] = 0;
165
+ if ($theme == 'light')
166
+ $prefparams['theme'] = 'light';
167
+
168
+ $finalparams = $linkparams + $prefparams;
169
+ $finalsrc = '';
170
+
171
+ if (count($finalparams) > 1)
172
+ {
173
+ foreach ($finalparams as $key => $value)
174
+ {
175
+ if ($key != 'v')
176
+ {
177
+ $finalsrc .= htmlspecialchars($key) . '=' . htmlspecialchars($value) . '&';
178
+ if ($key == 'loop' && $value == 1)
179
+ $finalsrc .= 'playlist=' . $finalparams['v'] . '&';
180
+ }
181
+ }
182
+ }
183
+
184
+ $code = $code1 . $finalsrc . $code2;
185
+
186
+ // reset static vals for next embed
187
+ self::$optembedwidth = null;
188
+ self::$optembedheight = null;
189
+ self::$defaultheight = null;
190
+ self::$defaultwidth = null;
191
+
192
+ return $code;
193
+ }
194
+
195
+ public static function keyvalue($qry, $includev)
196
+ {
197
+ $ytvars = explode('&', $qry);
198
+ $ytkvp = array();
199
+ foreach ($ytvars as $k => $v)
200
+ {
201
+ $kvp = explode('=', $v);
202
+ if (count($kvp) == 2 && ($includev || strtolower($kvp[0]) != 'v'))
203
+ {
204
+ $ytkvp[$kvp[0]] = $kvp[1];
205
+ }
206
+ }
207
+
208
+ return $ytkvp;
209
+ }
210
+
211
+ public static function init_dimensions($url, $urlkvp)
212
+ {
213
+
214
+ // get default dimensions; try embed size in settings, then try theme's content width, then just 480px
215
+ if (self::$defaultwidth == null)
216
+ {
217
+ self::$optembedwidth = intval(get_option('embed_size_w'));
218
+ self::$optembedheight = intval(get_option('embed_size_h'));
219
+
220
+ global $content_width;
221
+ if (empty($content_width))
222
+ $content_width = $GLOBALS['content_width'];
223
+
224
+ self::$defaultwidth = $urlkvp['width'] ? $urlkvp['width'] : (self::$optembedwidth ? self::$optembedwidth : ($content_width ? $content_width : 480));
225
+ self::$defaultheight = self::get_aspect_height($url);
226
+ }
227
+ }
228
+
229
+ public static function get_aspect_height($url)
230
+ {
231
+
232
+ // attempt to get aspect ratio correct height from oEmbed
233
+ $aspectheight = round((self::$defaultwidth * 9) / 16, 0);
234
+ if ($url)
235
+ {
236
+ require_once( ABSPATH . WPINC . '/class-oembed.php' );
237
+ $oembed = _wp_oembed_get_object();
238
+ $args = array();
239
+ $args['width'] = self::$defaultwidth;
240
+ $args['height'] = self::$optembedheight;
241
+ $args['discover'] = false;
242
+ $odata = $oembed->fetch('http://www.youtube.com/oembed', $url, $args);
243
+
244
+ if ($odata)
245
+ {
246
+ $aspectheight = $odata->height;
247
+ }
248
+ }
249
+
250
+ //add 30 for YouTube's own bar
251
+ return $aspectheight + 30;
252
+ }
253
+
254
+ public static function ytprefs_plugin_menu()
255
+ {
256
+ add_menu_page('YouTube Settings', 'YouTube', 'manage_options', 'youtube-my-preferences', 'YouTubePrefs::ytprefs_show_options', plugins_url('images/youtubeicon16.png', __FILE__), '10.00392854349');
257
+ }
258
+
259
+ public static function ytprefs_show_options()
260
+ {
261
+
262
+ if (!current_user_can('manage_options'))
263
+ {
264
+ wp_die(__('You do not have sufficient permissions to access this page.'));
265
+ }
266
+
267
+ // variables for the field and option names
268
+ $ytprefs_submitted = 'ytprefs_submitted';
269
+
270
+ // Read in existing option values from database
271
+ $auto_hd = get_option(self::$opt_auto_hd);
272
+ $autoplay = get_option(self::$opt_autoplay, 0);
273
+ $cc_load_policy = get_option(self::$opt_cc_load_policy, 0);
274
+ $iv_load_policy = get_option(self::$opt_iv_load_policy, 1);
275
+ $loop = get_option(self::$opt_loop, 0);
276
+ $modestbranding = get_option(self::$opt_modestbranding, 0);
277
+ $rel = get_option(self::$opt_rel, 1);
278
+ $showinfo = get_option(self::$opt_showinfo, 1);
279
+ $theme = get_option(self::$opt_theme, 'dark');
280
+
281
+ // See if the user has posted us some information
282
+ // If they did, this hidden field will be set to 'Y'
283
+ if (isset($_POST[$ytprefs_submitted]) && $_POST[$ytprefs_submitted] == 'Y')
284
+ {
285
+ // Read their posted values
286
+ $auto_hd = $_POST[self::$opt_auto_hd] == (true || 'on') ? 1 : 0;
287
+ $autoplay = $_POST[self::$opt_autoplay] == (true || 'on') ? 1 : 0;
288
+ $cc_load_policy = $_POST[self::$opt_cc_load_policy] == (true || 'on') ? 1 : 0;
289
+ $iv_load_policy = $_POST[self::$opt_iv_load_policy] == (true || 'on') ? 1 : 3;
290
+ $loop = $_POST[self::$opt_loop] == (true || 'on') ? 1 : 0;
291
+ $modestbranding = $_POST[self::$opt_modestbranding] == (true || 'on') ? 1 : 0;
292
+ $rel = $_POST[self::$opt_rel] == (true || 'on') ? 1 : 0;
293
+ $showinfo = $_POST[self::$opt_showinfo] == (true || 'on') ? 1 : 0;
294
+ $theme = $_POST[self::$opt_theme] == (true || 'on') ? 'dark' : 'light';
295
+
296
+
297
+ // Save the posted value in the database
298
+ update_option(self::$opt_auto_hd, $auto_hd);
299
+ update_option(self::$opt_autoplay, $autoplay);
300
+ update_option(self::$opt_cc_load_policy, $cc_load_policy);
301
+ update_option(self::$opt_iv_load_policy, $iv_load_policy);
302
+ update_option(self::$opt_loop, $loop);
303
+ update_option(self::$opt_modestbranding, $modestbranding);
304
+ update_option(self::$opt_rel, $rel);
305
+ update_option(self::$opt_showinfo, $showinfo);
306
+ update_option(self::$opt_theme, $theme);
307
+
308
+ // Put a settings updated message on the screen
309
+ ?>
310
+ <div class="updated"><p><strong><?php _e('Settings saved.'); ?></strong></p></div>
311
+ <?php
312
+ }
313
+
314
+ // Now display the settings editing screen
315
+
316
+ echo '<div class="wrap">';
317
+
318
+ // header
319
+
320
+ echo "<h2>" . '<img src="' . plugins_url('images/youtubeicon16.png', __FILE__) . '" /> ' . __('YouTube Preferences') . "</h2>";
321
+
322
+ // settings form
323
+ ?>
324
+ <style type="text/css">
325
+ #ytform p { line-height: 20px; }
326
+ #ytform ul li {margin-left: 30px; list-style: disc outside none;}
327
+ .ytindent {padding: 0px 0px 0px 20px;}
328
+ .shadow {-webkit-box-shadow: 0px 0px 20px 0px #000000; box-shadow: 0px 0px 20px 0px #000000;}
329
+ </style>
330
+
331
+ <div class="ytindent">
332
+ <form name="form1" method="post" action="" id="ytform">
333
+ <input type="hidden" name="<?php echo $ytprefs_submitted; ?>" value="Y">
334
+ <h3>
335
+ <?php _e("How to Insert a YouTube Video") ?>
336
+ </h3>
337
+ <p>
338
+ 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?
339
+ </p>
340
+ <p>
341
+ <img class="shadow" src="<?php echo plugins_url('images/ownline.jpg', __FILE__) ?>" />
342
+ </p>
343
+
344
+ <p>
345
+ Note: Make sure the link is in plain text (not hyperlinked/blue).
346
+ </p>
347
+
348
+ <h3>
349
+ <?php _e("Default Options") ?>
350
+ </h3>
351
+ <p>
352
+ <?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.") ?>
353
+ </p>
354
+
355
+ <div class="ytindent">
356
+
357
+ <!--
358
+ <p>
359
+ <input name="<?php echo self::$opt_auto_hd; ?>" id="<?php echo self::$opt_auto_hd; ?>" <?php checked($auto_hd, 1); ?> type="checkbox" class="checkbox">
360
+ <label for="<?php echo self::$opt_auto_hd; ?>"><?php _e('Automatically make all videos HD quality (when possible).') ?></label>
361
+ </p>
362
+ -->
363
+ <p>
364
+ <input name="<?php echo self::$opt_autoplay; ?>" id="<?php echo self::$opt_autoplay; ?>" <?php checked($autoplay, 1); ?> type="checkbox" class="checkbox">
365
+ <label for="<?php echo self::$opt_autoplay; ?>"><?php _e('Automatically start playing your videos') ?></label>
366
+ </p>
367
+ <p>
368
+ <input name="<?php echo self::$opt_cc_load_policy; ?>" id="<?php echo self::$opt_cc_load_policy; ?>" <?php checked($cc_load_policy, 1); ?> type="checkbox" class="checkbox">
369
+ <label for="<?php echo self::$opt_cc_load_policy; ?>"><?php _e('Turn on closed captions by default') ?></label>
370
+ </p>
371
+ <p>
372
+ <input name="<?php echo self::$opt_iv_load_policy; ?>" id="<?php echo self::$opt_iv_load_policy; ?>" <?php checked($iv_load_policy, 1); ?> type="checkbox" class="checkbox">
373
+ <label for="<?php echo self::$opt_iv_load_policy; ?>"><?php _e('Show annotations by default') ?></label>
374
+ </p>
375
+ <p>
376
+ <input name="<?php echo self::$opt_loop; ?>" id="<?php echo self::$opt_loop; ?>" <?php checked($loop, 1); ?> type="checkbox" class="checkbox">
377
+ <label for="<?php echo self::$opt_loop; ?>"><?php _e('Loop all your videos') ?></label>
378
+ </p>
379
+ <p>
380
+ <input name="<?php echo self::$opt_modestbranding; ?>" id="<?php echo self::$opt_modestbranding; ?>" <?php checked($modestbranding, 1); ?> type="checkbox" class="checkbox">
381
+ <label for="<?php echo self::$opt_modestbranding; ?>"><?php _e('Modest branding - hide YouTube logo while playing') ?></label>
382
+ </p>
383
+ <p>
384
+ <input name="<?php echo self::$opt_rel; ?>" id="<?php echo self::$opt_rel; ?>" <?php checked($rel, 1); ?> type="checkbox" class="checkbox">
385
+ <label for="<?php echo self::$opt_rel; ?>"><?php _e('Show related videos at the end') ?></label>
386
+ </p>
387
+ <p>
388
+ <input name="<?php echo self::$opt_showinfo; ?>" id="<?php echo self::$opt_showinfo; ?>" <?php checked($showinfo, 1); ?> type="checkbox" class="checkbox">
389
+ <label for="<?php echo self::$opt_showinfo; ?>"><?php _e('Show the video title and other info') ?></label>
390
+ </p>
391
+ <p>
392
+ <input name="<?php echo self::$opt_theme; ?>" id="<?php echo self::$opt_theme; ?>" <?php checked($theme, 'dark'); ?> type="checkbox" class="checkbox">
393
+ <label for="<?php echo self::$opt_theme; ?>"><?php _e('Use the dark theme (uncheck to use light theme)') ?></label>
394
+ </p>
395
+ <p class="submit">
396
+ <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
397
+ </p>
398
+ </div>
399
+
400
+ <h3>
401
+ <?php _e("How To Override Defaults / Other Options") ?>
402
+ </h3>
403
+ <?php
404
+ _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. Each option should begin with '&'. </p>");
405
+ _e('<ul>');
406
+ _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>");
407
+ _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>");
408
+ _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>");
409
+ _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>");
410
+ _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>");
411
+ _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>");
412
+ _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>");
413
+ _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>");
414
+ _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>");
415
+ _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>");
416
+ _e('</ul>');
417
+
418
+ _e("<p>You can also start and end each individual video at particular times. Like the above, each option should begin with '&'</p>");
419
+ _e('<ul>');
420
+ _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>");
421
+ _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>");
422
+ _e('</ul>');
423
+ ?>
424
+
425
+ </form>
426
+
427
+ <h3><?php _e('Other Notes') ?></h3>
428
+ <P>
429
+ <?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."); ?>
430
+ </p>
431
+ </div>
432
+ <?php
433
+ }
434
+
435
+ }
436
+
437
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
438
+ //class start
439
+ class Add_new_tinymce_btn
440
+ {
441
+
442
+ public $btn_arr;
443
+ public $js_file;
444
+
445
+ /*
446
+ * call the constructor and set class variables
447
+ * From the constructor call the functions via wordpress action/filter
448
+ */
449
+
450
+ function __construct($seperator, $btn_name, $javascrip_location)
451
+ {
452
+ $this->btn_arr = array("Seperator" => $seperator, "Name" => $btn_name);
453
+ $this->js_file = $javascrip_location;
454
+ add_action('init', array($this, 'add_tinymce_button'));
455
+ add_filter('tiny_mce_version', array($this, 'refresh_mce_version'));
456
+ }
457
+
458
+ /*
459
+ * create the buttons only if the user has editing privs.
460
+ * If so we create the button and add it to the tinymce button array
461
+ */
462
+
463
+ function add_tinymce_button()
464
+ {
465
+ if (!current_user_can('edit_posts') && !current_user_can('edit_pages'))
466
+ return;
467
+ if (get_user_option('rich_editing') == 'true')
468
+ {
469
+ //the function that adds the javascript
470
+ add_filter('mce_external_plugins', array($this, 'add_new_tinymce_plugin'));
471
+ //adds the button to the tinymce button array
472
+ add_filter('mce_buttons', array($this, 'register_new_button'));
473
+ }
474
+ }
475
+
476
+ /*
477
+ * add the new button to the tinymce array
478
+ */
479
+
480
+ function register_new_button($buttons)
481
+ {
482
+ array_push($buttons, $this->btn_arr["Seperator"], $this->btn_arr["Name"]);
483
+ return $buttons;
484
+ }
485
+
486
+ /*
487
+ * Call the javascript file that loads the
488
+ * instructions for the new button
489
+ */
490
+
491
+ function add_new_tinymce_plugin($plugin_array)
492
+ {
493
+ $plugin_array[$this->btn_arr['Name']] = $this->js_file;
494
+ return $plugin_array;
495
+ }
496
+
497
+ /*
498
+ * This function tricks tinymce in thinking
499
+ * it needs to refresh the buttons
500
+ */
501
+
502
+ function refresh_mce_version($ver)
503
+ {
504
+ $ver += 3;
505
+ return $ver;
506
+ }
507
+
508
+ }
509
+
510
+ //class end
511
+
512
+ register_activation_hook(__FILE__, array('YouTubePrefs', 'initoptions'));
513
+
514
+ $youtubeplg = new YouTubePrefs();
515
+
516
+ /*
517
+ $youtubeprefsmce = new Add_new_tinymce_btn('|', 'youtubeprefswiz', plugins_url() . '/youtube/js/youtube_mce.js.php');
518
+
519
+ if (YouTubePrefs::wp_above_version('2.9'))
520
+ {
521
+ add_action('admin_enqueue_scripts', 'youtubeprefs_admin_enqueue_scripts');
522
+ }
523
+ else
524
+ {
525
+ wp_enqueue_style('youtubeprefswiz', plugins_url() . '/youtube/js/youtube_mce.css');
526
+ }
527
+
528
+ function youtubeprefs_admin_enqueue_scripts()
529
+ {
530
+ wp_enqueue_style('youtubeprefswiz', plugins_url() . '/youtube/js/youtube_mce.css');
531
+ }
532
+ */