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