YouTube Embed - Version 2.0

Version Description

  • Renamed to Artiss YouTube Embed from YouTube Embed
  • Major re-write, using new coding standards
  • New administration screens, introducing multiple profiles and playlists
  • AS3 player is now used, AS2 has been retired. Both OBJECT and IFRAME versions can be selected
  • Compliancy and browser checked - XHTML and HTML5 compliant and works in all the latest browsers
  • Migration options added, allowing compatibility with other similar plugins
  • Can now specify full video URL as well as video ID
  • No need to use separate shortcode for playlists, as they are automatically detected. Video IDs are also now validated
  • Options to allow YouTube URLs not within shortcodes to be accepted, as well as in comments
  • RDFa metadata added to code output
  • Caching of code and ID checking to improve performance
  • Templating system replaces CSS specification
  • README completely re-written, contextual help added to admin screens and links to further information
  • Improved editor button and link added to admin bar
  • Many, many more changes - too many to list!

=

Download this release

Release Info

Developer dartiss
Plugin Icon 128x128 YouTube Embed
Version 2.0
Comparing to
See all releases

Code changes from version 1.5 to 2.0

Files changed (50) hide show
  1. css/tinymce-button UNCOMPRESSED.css +6 -0
  2. css/tinymce-button-3.1 UNCOMPRESSED.css +3 -0
  3. css/tinymce-button-3.1.css +1 -0
  4. css/tinymce-button.css +1 -0
  5. css/youtube-embed UNCOMPRESSED.css +9 -0
  6. css/youtube-embed.css +1 -0
  7. embedplus.png +0 -0
  8. images/Thumbs.db +0 -0
  9. images/cross.png +0 -0
  10. images/menu_icon.png +0 -0
  11. images/poweredby.png +0 -0
  12. images/screen_icon.png +0 -0
  13. images/shadow.png +0 -0
  14. images/tick.png +0 -0
  15. images/youtube_button_b&w.png +0 -0
  16. youtube.png → images/youtube_button_colour.png +0 -0
  17. includes/about.php +51 -0
  18. includes/admin-bar.php +38 -0
  19. includes/admin-menu.php +200 -0
  20. includes/artiss-dashboard-widget.php +82 -0
  21. includes/content.php +244 -0
  22. includes/deprecated.php +58 -0
  23. includes/function-calls.php +209 -0
  24. includes/generate-download-code.php +35 -0
  25. includes/generate-embed-code.php +437 -0
  26. includes/generate-shorturl-code.php +35 -0
  27. includes/generate-thumbnail-code.php +48 -0
  28. includes/generate-transcript-code.php +87 -0
  29. includes/mcebutton.php +62 -0
  30. includes/options-general.php +222 -0
  31. includes/options-lists.php +178 -0
  32. includes/options-profiles.php +298 -0
  33. includes/options-widgets.php +195 -0
  34. includes/set-option-defaults.php +214 -0
  35. includes/shared.php +366 -0
  36. includes/shortcodes.php +250 -0
  37. includes/widgets.php +160 -0
  38. js/mcebutton UNCOMPRESSED.js +16 -0
  39. js/mcebutton.js +1 -0
  40. mcebutton.js +0 -1
  41. readme.txt +241 -136
  42. screenshot-1.png +0 -0
  43. screenshot-2.png +0 -0
  44. screenshot-3.png +0 -0
  45. screenshot-4.png +0 -0
  46. screenshot-5.png +0 -0
  47. uninstall.php +46 -0
  48. youtube-embed-options.php +0 -240
  49. youtube-embed.php +51 -464
  50. youtube-widget-options.php +0 -170
css/tinymce-button UNCOMPRESSED.css ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ .wp_themeSkin span.mce_YouTube {
2
+ background:url('../images/youtube_button_b&w.png') no-repeat 0 0;
3
+ }
4
+ .wp_themeSkin span.mce_YouTube:hover {
5
+ background:url('../images/youtube_button_colour.png') no-repeat 0 0;
6
+ }
css/tinymce-button-3.1 UNCOMPRESSED.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ .wp_themeSkin span.mce_YouTube {
2
+ background:url('../images/youtube_button_colour.png') no-repeat 0 0;
3
+ }
css/tinymce-button-3.1.css ADDED
@@ -0,0 +1 @@
 
1
+ .wp_themeSkin span.mce_YouTube{background:url('../images/youtube_button_colour.png') no-repeat 0 0;}
css/tinymce-button.css ADDED
@@ -0,0 +1 @@
 
1
+ .wp_themeSkin span.mce_YouTube{background:url('../images/youtube_button_b&w.png') no-repeat 0 0;}.wp_themeSkin span.mce_YouTube:hover{background:url('../images/youtube_button_colour.png') no-repeat 0 0;}
css/youtube-embed UNCOMPRESSED.css ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ .ytbox_grey {
2
+ background-color: #f1f1f1;
3
+ padding: 10px;
4
+ border: 1px solid #ddd;
5
+ }
6
+ .yt_heading {
7
+ font-weight: bold;
8
+ font-size: 1.1em;
9
+ }
css/youtube-embed.css ADDED
@@ -0,0 +1 @@
 
1
+ .ytbox_grey{background-color:#f1f1f1;padding:10px;border:1px solid #ddd;}.yt_heading{font-weight:bold;font-size:1.1em;}
embedplus.png DELETED
Binary file
images/Thumbs.db ADDED
Binary file
images/cross.png ADDED
Binary file
images/menu_icon.png ADDED
Binary file
images/poweredby.png ADDED
Binary file
images/screen_icon.png ADDED
Binary file
images/shadow.png ADDED
Binary file
images/tick.png ADDED
Binary file
images/youtube_button_b&w.png ADDED
Binary file
youtube.png → images/youtube_button_colour.png RENAMED
File without changes
includes/about.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * About Page
4
+ *
5
+ * About the plugin
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ */
10
+ ?>
11
+ <div class="wrap">
12
+ <div class="icon32"><img src="<?php echo WP_PLUGIN_URL; ?>/youtube-embed/images/screen_icon.png" alt="" title="" height="32px" width="32px"/><br /></div>
13
+
14
+ <h2><?php _e( 'About Artiss YouTube Embed'); ?></h2>
15
+
16
+ <p><?php _e( 'You are using Artiss YouTube Embed version ' . youtube_embed_version . '. It was written by David Artiss.' ); ?></p>
17
+
18
+ <a href="http://www.youtube.com/"><img src="<?php echo WP_PLUGIN_URL; ?>/youtube-embed/images/poweredby.png" alt="Powered by YouTube" title="Powered by YouTube" align="right" /></a>
19
+
20
+ <?php
21
+
22
+ _e( '<h3>Copyrights</h3>' );
23
+
24
+ _e( '<p>YouTube, and all associated logos, is the copyright of Google Inc.</p>' );
25
+
26
+ _e( '<p>EmbedPlus is copyright. Read the <a href="http://embedplus.com/terms.aspx" target="_blank">Terms &amp; Conditions of Use</a>.</p>' );
27
+
28
+ _e( '<h3>Acknowledgements</h3>' );
29
+
30
+ _e( '<p>Images have been compressed with <a href="http://www.smushit.com/ysmush.it/">Smush.it</a>.</p>' );
31
+
32
+ _e( '<p>JavaScript has been compressed with <a href="http://javascriptcompressor.com/">JavaScript Compressor</a>.</p>' );
33
+
34
+ _e( '<p>YouTube icons are courtesy of <a href="http://icondock.com/">IconDock</a>. Other icons are by <a href="http://p.yusukekamiyamane.com/">Yusuke Kamiyamane</a>.</p>' );
35
+
36
+ _e( '<h3>Support Information</h3>' );
37
+
38
+ _e( '<p>Useful support information and links can be found by clicking on the Help tab at the top of each of the Artiss YouTube Embed administration screens.</p>' );
39
+
40
+ _e( '<h4>This plugin, and all support, is supplied for free, but <a title="Donate" href="http://artiss.co.uk/donate" target="_blank">donations</a> are always welcome.</h4>' );
41
+
42
+ _e( '<h3>Stay in Touch</h3>' );
43
+
44
+ _e( '<p><a href="http://www.artiss.co.uk/wp-plugins">See the full list</a> of Artiss plugins, including beta releases.</p>' );
45
+
46
+ _e( '<p><a href="http://www.twitter.com/artiss_tech">Follow Artiss.co.uk</a> on Twitter.</p>' );
47
+
48
+ _e( '<p><a href="http://www.artiss.co.uk/feed">Subscribe</a> to the Artiss.co.uk news feed.</p>' );
49
+
50
+ ?>
51
+ </div>
includes/admin-bar.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Bar
4
+ *
5
+ * Set up Admin Bar links
6
+ *
7
+ * @package YouTubeEmbed
8
+ */
9
+
10
+ /**
11
+ * Add option to Admin Bar
12
+ *
13
+ * Add link to YouTube Embed profile options to Admin Bar. This will only appear
14
+ * if the user can edit plugins
15
+ *
16
+ * @since 2.0
17
+ */
18
+
19
+ function ye_admin_bar_render() {
20
+
21
+ if ( current_user_can( 'edit_plugins' ) ) {
22
+
23
+ $options = ye_set_general_defaults();
24
+
25
+ if ( $options[ 'admin_bar' ] != '' ) {
26
+
27
+ global $wp_admin_bar;
28
+ $wp_admin_bar -> add_menu( array(
29
+ 'parent' => 'appearance',
30
+ 'id' => 'ye-options',
31
+ 'title' => __( 'YouTube Embed' ),
32
+ 'href' => admin_url( 'admin.php?page=youtube-embed-profiles' ),
33
+ 'meta' => false ) );
34
+ }
35
+ }
36
+ }
37
+ add_action( 'wp_before_admin_bar_render', 'ye_admin_bar_render' );
38
+ ?>
includes/admin-menu.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Menu Functions
4
+ *
5
+ * Various functions relating to the various administration screens
6
+ *
7
+ * @package YouTubeEmbed
8
+ */
9
+
10
+ /**
11
+ * Admin Screen Initialisation
12
+ *
13
+ * Set up admin menu and submenu options
14
+ *
15
+ * @since 2.0
16
+ *
17
+ * @uses ye_add_submenu Add a submenu, with optional help drop-down
18
+ */
19
+
20
+ function ye_menu_initialise() {
21
+
22
+ add_menu_page( 'YouTube Embed Options', 'YouTube', 'manage_options', 'youtube-embed-general', 'ye_general_options', WP_PLUGIN_URL . '/youtube-embed/images/menu_icon.png' );
23
+
24
+ ye_add_submenu( 'YouTube Embed Options', 'Options', 'youtube-embed-general', 'ye_general_options' );
25
+ ye_add_submenu( 'YouTube Embed Profiles', 'Profiles', 'youtube-embed-profiles', 'ye_profile_options' );
26
+ ye_add_submenu( 'YouTube Embed Lists', 'Lists', 'youtube-embed-lists', 'ye_list_options' );
27
+ ye_add_submenu( 'YouTube Embed About', 'About', 'youtube-embed-about', 'ye_support_about' );
28
+
29
+ add_filter( 'plugin_action_links', 'ye_add_settings_link', 10, 2 );
30
+ }
31
+ add_action( 'admin_menu','ye_menu_initialise' );
32
+ add_filter( 'plugin_row_meta', 'ye_set_plugin_meta', 10, 2 );
33
+
34
+ /**
35
+ * Include general options screen
36
+ *
37
+ * XHTML options screen to prompt and update some general plugin options
38
+ *
39
+ * @since 2.0
40
+ */
41
+
42
+ function ye_general_options() {
43
+ include_once( WP_PLUGIN_DIR . "/youtube-embed/includes/options-general.php" );
44
+ }
45
+
46
+ /**
47
+ * Include profile options screen
48
+ *
49
+ * XHTML options screen to prompt and update profile options
50
+ *
51
+ * @since 2.0
52
+ */
53
+
54
+ function ye_profile_options() {
55
+ include_once( WP_PLUGIN_DIR . "/youtube-embed/includes/options-profiles.php" );
56
+ }
57
+
58
+ /**
59
+ * Include list options screen
60
+ *
61
+ * XHTML options screen to prompt and update list options
62
+ *
63
+ * @since 2.0
64
+ */
65
+
66
+ function ye_list_options() {
67
+ include_once( WP_PLUGIN_DIR . "/youtube-embed/includes/options-lists.php" );
68
+ }
69
+
70
+ /**
71
+ * Include about and support screen
72
+ *
73
+ * XHTML about screen which will, optionally, display help details as well
74
+ *
75
+ * @since 2.0
76
+ */
77
+
78
+ function ye_support_about() {
79
+ include_once( WP_PLUGIN_DIR . "/youtube-embed/includes/about.php" );
80
+ }
81
+
82
+ /**
83
+ * Add CSS files
84
+ *
85
+ * Add stylesheets to the admin screens
86
+ *
87
+ * @since 2.0
88
+ */
89
+
90
+ function ye_menu_css() {
91
+ wp_enqueue_style( 'youtube_embed', WP_PLUGIN_URL . '/youtube-embed/css/youtube-embed.css' );
92
+ global $wp_version;
93
+ if ( ( float ) $wp_version >= 3.2 ) { $version = ''; } else { $version = '-3.1'; }
94
+ wp_enqueue_style( 'tinymce_button', WP_PLUGIN_URL . '/youtube-embed/css/tinymce-button' . $version . '.css' );
95
+ }
96
+ add_action( 'admin_print_styles', 'ye_menu_css' );
97
+
98
+ /**
99
+ * Add JavaScript files
100
+ *
101
+ * Add JavaScript files to the admin screens
102
+ *
103
+ * @since 2.0
104
+ */
105
+
106
+ function ye_menu_js() {
107
+ wp_enqueue_script( 'jscolor', WP_PLUGIN_URL . '/youtube-embed/js/jscolor.js' );
108
+ }
109
+ add_action( 'admin_print_scripts', 'ye_menu_js' );
110
+
111
+ /**
112
+ * Add Settings link to plugin list
113
+ *
114
+ * Add a Settings link to the options listed against this plugin
115
+ *
116
+ * @since 2.0
117
+ *
118
+ * @param string $links Current links
119
+ * @param string $file File in use
120
+ * @return string Links, now with settings added
121
+ */
122
+
123
+ function ye_add_settings_link( $links, $file ) {
124
+
125
+ static $this_plugin;
126
+
127
+ if ( !$this_plugin ) { $this_plugin = plugin_basename( __FILE__ ); }
128
+
129
+ if ( strpos( $file, 'youtube-embed.php' ) !== false ) {
130
+ $settings_link = '<a href="admin.php?page=youtube-embed-general">' . __( 'Settings' ) . '</a>';
131
+ array_unshift( $links, $settings_link );
132
+ }
133
+
134
+ return $links;
135
+ }
136
+
137
+ /**
138
+ * Add meta to plugin details
139
+ *
140
+ * Add options to plugin meta line
141
+ *
142
+ * @since 2.0
143
+ *
144
+ * @param string $links Current links
145
+ * @param string $file File in use
146
+ * @return string Links, now with settings added
147
+ */
148
+
149
+ function ye_set_plugin_meta( $links, $file ) {
150
+
151
+ if ( strpos( $file, 'youtube-embed.php' ) !== false ) {
152
+ $links = array_merge( $links, array( '<a href="admin.php?page=youtube-embed-about">' . __( 'Support' ) . '</a>' ) );
153
+ $links = array_merge( $links, array( '<a href="http://www.artiss.co.uk/donate">' . __( 'Donate' ) . '</a>' ) );
154
+ }
155
+
156
+ return $links;
157
+ }
158
+
159
+
160
+ /**
161
+ * Add a submenu and, optionally, help
162
+ *
163
+ * Add a submenu and, if using WP 3 and above, help instructions to the drop-down
164
+ * at the top of the screen
165
+ *
166
+ * @since 2.0
167
+ *
168
+ * @param string $page_title Title to give menu page
169
+ * @param string $menu_title Title for menu option
170
+ * @param string $menu_slug Unique slug for the menu
171
+ * @param string $function Function name for menu option
172
+ */
173
+
174
+ function ye_add_submenu( $page_title, $menu_title, $menu_slug, $function ) {
175
+
176
+ $profile_slug = add_submenu_page( 'youtube-embed-general', $page_title, $menu_title, 'manage_options', $menu_slug, $function );
177
+
178
+ if ( $menu_slug == "youtube-embed-general" ) { $help_text = '<p>This screen allows you to select non-specific options for the Artiss YouTube Embed plugin. For the default embedding settings, please select the <a href="http://www.artiss.co.uk/wp-admin/admin.php?page=youtube-embed-profiles">Profiles</a> administration option.</p>'; }
179
+
180
+ if ( $menu_slug == "youtube-embed-profiles" ) { $help_text = "<p>This screen allows you to set the options for the default and additional profiles. If you don't specify a specific parameter when displaying your YouTube video then the default profile option will be used instead. Additional profiles, which you may name, can be used as well and used as required.</p>"; }
181
+
182
+ if ( $menu_slug == "youtube-embed-lists" ) { $help_text = '<p>This screen allows you to create lists of YouTube videos, which may be named. These lists can then be used in preference to a single video ID.</p>'; }
183
+
184
+ if ( $menu_slug != "youtube-embed-about" ) {
185
+ $help_text .= '<p>Remember to click the Save Settings button at the bottom of the screen for new settings to take effect.</p>';
186
+ } else {
187
+ $help_text = '<p>This screen provides useful information about this plugin along with methods of support.</p>';
188
+ }
189
+
190
+ $help_text .= '<p><strong>For more information:</strong></p><p><a href="http://www.artiss.co.uk/artiss-youtube-embed">Artiss YouTube Embed Plugin Documentation</a></p><p><a href="http://code.google.com/apis/youtube/player_parameters.html">YouTube Player Documentation</a></p>';
191
+
192
+ if ( $menu_slug == "youtube-embed-profiles" ) { $help_text .= '<p><a href="http://embedplus.com/">EmbedPlus website</a></p>'; }
193
+
194
+ $help_text .= '<p><a href="http://www.artiss.co.uk/forum/specific-plugins-group2/artiss-youtube-embed-forum7">Artiss YouTube Embed Support Forum</a></p><h4>This plugin, and all support, is supplied for free, but <a title="Donate" href="http://artiss.co.uk/donate" target="_blank">donations</a> are always welcome.</h4>';
195
+
196
+ add_contextual_help( $profile_slug, __( $help_text ) );
197
+
198
+ return;
199
+ }
200
+ ?>
includes/artiss-dashboard-widget.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Artiss Dashboard Widget
4
+ *
5
+ * Add a box to the dashboard to display Artiss plugin news and support links
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ */
10
+
11
+ /**
12
+ * Define Dashboard Widget
13
+ *
14
+ * Set up a new dashboard widget
15
+ *
16
+ */
17
+
18
+ function artiss_dashboard_widget() {
19
+ global $wp_meta_boxes;
20
+ wp_add_dashboard_widget( 'artiss_help_widget', 'Artiss Plugin News & Support', 'artiss_plugin_help' );
21
+ }
22
+ add_action( 'wp_dashboard_setup', 'artiss_dashboard_widget' );
23
+
24
+ /**
25
+ * Display Dashboard Widget
26
+ *
27
+ * Show dashboard widget. Fetch top news items from category feed and cache them.
28
+ *
29
+ */
30
+
31
+ function artiss_plugin_help() {
32
+
33
+ // Set number of minutes to cache output
34
+ $minutes_to_cache = 60;
35
+
36
+ // Set number of news items to display
37
+ $news_items = 5;
38
+
39
+ // Attempt to get the cache
40
+ $output = get_transient( 'artiss_dashboard_text' );
41
+
42
+ // No cache found
43
+ if (!$output) {
44
+
45
+ // Use MagpieRSS to fetch the feed
46
+ include_once( ABSPATH . WPINC . '/rss.php' );
47
+ $array = fetch_rss( 'http://www.artiss.co.uk/category/wordpress/feed' );
48
+
49
+ if ( $array != '' ) {
50
+
51
+ // If a feed is returned, slice up the results into an array
52
+ $items = array_slice( $array -> items, 0, $news_items );
53
+
54
+ // Now loop around the result and output
55
+ $output .= "<h4>News</h4><br/>\n";
56
+ if ( count( $items ) != 0 ) {
57
+ $output .= "<ul>\n";
58
+ foreach ( $items as $item ) {
59
+ $output .= '<li><a href="' . $item[ 'link' ] . '">' . $item[ 'title' ] . "</a></li>\n";
60
+ }
61
+ $output .= "</ul></br>\n";
62
+ } else {
63
+ $output .= "No news items were found - please check back later!</br></br>";
64
+ }
65
+ }
66
+
67
+ // Generate support links
68
+ $output .= "<h4>Support Links</h4><br/>\n<ul>\n<li><a href=\"http://www.artiss.co.uk\">Artiss.co.uk website</a><br/></li>\n<li><a href=\"http://www.artiss.co.uk/wp-plugins\">Main plugin page</a><br/></li>\n<li><a href=\"http://www.artiss.co.uk/forum\">Plugin forum </a></li>\n</ul></br>\n";
69
+
70
+ // Generate news links
71
+ $output .= "<h4>News</h4><br/>\n<ul>\n<li><a href=\"http://www.artiss.co.uk\">Subscribe to the RSS feed</a><br/></li>\n<li><a href=\"http://www.artiss.co.uk/wp-plugins\">Follow us on Twitter</a><br/></li>\n</ul>\n";
72
+
73
+ // Add donation link
74
+ $output .= "<h5 style=\"text-align: right\"><a href=\"http://www.artiss.co.uk/donate\">Donate</a></h5>";
75
+
76
+ // Update cache
77
+ set_transient( 'artiss_dashboard_text', $output, $minutes_to_cache * 60 );
78
+ }
79
+
80
+ echo $output;
81
+ }
82
+ ?>
includes/content.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Content
4
+ *
5
+ * Process the post/page content for embed requests
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ */
10
+
11
+ /**
12
+ * Search content for alternative embed methods
13
+ *
14
+ * Look through post/page content for various alternative methods of embedding - replace with
15
+ * embed code.
16
+ *
17
+ * @since 2.0
18
+ *
19
+ * @uses ye_convert_content Convert a URL to the embed code
20
+ * @uses ye_generate_youtube_code Generate the YouTube embed code
21
+ * @uses ye_set_general_defaults Get general defaults
22
+ * @uses ye_validate_id Validate the video ID
23
+ *
24
+ * @param string $content Post/page content
25
+ * @return string Resulting post/page content
26
+ */
27
+
28
+ function ye_content_search( $content ) {
29
+
30
+ $options = ye_set_general_defaults();
31
+
32
+ // The following are URL modifications
33
+
34
+ if ( $options[ 'alt' ] == 1 ) {
35
+
36
+ $changed = true;
37
+ while ( $changed ) {
38
+
39
+ $changed = false;
40
+
41
+ // Search for httpv URL
42
+ $identifier = 'httpv://www.youtube.com/watch?v=';
43
+ $search = strpos( $content, $identifier );
44
+ if ( $search !== false ) { $content = ye_convert_content( $content, $identifier, substr( $content, $search + strlen( $identifier ), 11 ), '', '', $options[ 'other_profile' ] ); $changed = true; }
45
+
46
+ // Search for httpa URL
47
+ $identifier = 'httpa://www.youtube.com/watch?v=';
48
+ $search = strpos( $content, $identifier );
49
+ if ( $search !== false ) { $content = ye_convert_content( $content, $identifier, substr( $content, $search + strlen( $identifier ), 11 ), 1, '', $options[ 'other_profile' ] ); $changed = true; }
50
+
51
+ // Search for httpvh URL
52
+ $identifier = 'httpvh://www.youtube.com/watch?v=';
53
+ $search = strpos( $content, $identifier );
54
+ if ( $search !== false ) { $content = ye_convert_content( $content, $identifier, substr( $content, $search + strlen( $identifier ), 11 ), '', '', $options[ 'other_profile' ] ); $changed = true; }
55
+
56
+ // Search for httpvp playlist URL
57
+ $identifier = 'httpvp://www.youtube.com/watch?p=';
58
+ $search = strpos( $content, $identifier );
59
+ if ( $search !== false ) { $content = ye_convert_content( $content, $identifier, substr( $content, $search + strlen( $identifier ), 16 ), '', '', $options[ 'other_profile' ] ); $changed = true; }
60
+
61
+ // Search for youtube:: URL
62
+ $identifier = 'youtube::';
63
+ $search = strpos( $content, $identifier );
64
+ if ( $search !== false ) {
65
+ $suffix = substr( $content, $search + strlen( $identifier ) + 11, 2 );
66
+ if ( $suffix == '::' ) { $content = ye_convert_content( $content, $identifier, substr( $content, $search + strlen( $identifier ), 11 ), '', '::', $options[ 'other_profile' ] ); $changed = true; }
67
+ }
68
+ }
69
+
70
+ }
71
+
72
+ // The following are embedding URLs that are within brackets but are not shortcodes
73
+
74
+ if ( $options[ 'bracket' ] == 1 ) {
75
+
76
+ // Loop around content, looking for brackets - possible YouTube URL within!
77
+ $current_pos = 0;
78
+ $bracket_found = true;
79
+
80
+ while ( $bracket_found ) {
81
+ $open_bracket = strpos( $content, '[', $current_pos );
82
+
83
+ if ($open_bracket !== false) {
84
+ $close_bracket = strpos( $content, ']', $open_bracket );
85
+
86
+ if ( $close_bracket !== false ) {
87
+ $code = substr( $content, $open_bracket + 1, $close_bracket - $open_bracket - 1 );
88
+ $code_found = false;
89
+ $id = $code;
90
+
91
+ // Maybe a video ID - validate first
92
+ if ( ( strlen( $code ) == 11 ) && ( !strpos( $code, ' ' ) ) ) {
93
+ $type = ye_validate_id( $code );
94
+ if ( $type == 'v' ) { $code_found = true; }
95
+ }
96
+
97
+ // Video URL
98
+ if ( ( strpos ($code, 'youtube.com/watch?v=' ) !== false ) && ( !$code_found ) ) { $code_found = true; }
99
+
100
+ // Other URLs
101
+ if ( ( substr( $code, 0, 8 ) == 'watch?v=' ) && ( !$code_found ) ) {
102
+ $id = substr( $code, 8 );
103
+ $code_found = true;
104
+ }
105
+ if ( ( substr( $code, 0, 2 ) == 'v=' ) && ( !$code_found ) ) {
106
+ $id = substr( $code, 2 );
107
+ $code_found = true;
108
+ }
109
+
110
+ // If an ID was found, update the code
111
+ if ( $code_found ) {
112
+ $ye_code = ye_generate_youtube_code( $id, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', $options[ 'other_profile' ], '', '' );
113
+ $content = str_replace( '[' . $code . ']', $ye_code, $content );
114
+ }
115
+ }
116
+ $current_pos = $close_bracket;
117
+ } else {
118
+ $bracket_found = false;
119
+ }
120
+ }
121
+ }
122
+
123
+ return $content;
124
+ }
125
+ add_filter( 'the_content', 'ye_content_search' );
126
+
127
+ /**
128
+ * Embed Handler
129
+ *
130
+ * Override the WP embed handler. Allows address and embed URLS types as well as playlists.
131
+ *
132
+ * @since 2.0
133
+ *
134
+ * @uses ye_set_general_defaults Fetch default profile option
135
+ * @uses ye_generate_youtube_code Generate the embed code
136
+ *
137
+ * @param array $matches The regex matches from the provided regex when calling
138
+ * @param array $attr Embed attributes
139
+ * @param string $url The original URL that was matched by the regex
140
+ * @param array $rawattr The original unmodified attributes
141
+ * @return string The embed HTML
142
+ */
143
+
144
+ function ye_embed_handler( $matches, $attr, $url, $rawattr ) {
145
+
146
+ $options = ye_set_general_defaults();
147
+ $code = ye_generate_youtube_code( $matches[ 1 ], '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', $options[ 'url_profile' ], '', '' );
148
+
149
+ return $code;
150
+ }
151
+ $url = ye_set_url_option();
152
+ if ( $url != '' ) {
153
+ wp_embed_register_handler( 'youtube', '/http:\/\/(?:www\.)?youtube.*watch\?[pv]=([a-zA-Z0-9\-_]+)/', 'ye_embed_handler' );
154
+ wp_embed_register_handler( 'youtube_embed', '/http:\/\/(?:www\.)?youtube.*[pv]\/([a-zA-Z0-9\-_]+)/', 'ye_embed_handler' );
155
+ }
156
+
157
+ /**
158
+ * Convert the Content
159
+ *
160
+ * Convert the URL to the embed code
161
+ *
162
+ * @since 2.0
163
+ *
164
+ * @uses ye_generate_youtube_code Generate the embed code
165
+ *
166
+ * @param string $content The post content
167
+ * @param string $identifier The text that identifies the embed
168
+ * @param string $id The video ID
169
+ * @param string $audio Audio only?
170
+ * @param string $suffix Characters that appear after the video ID
171
+ * @param string $profile The current profile
172
+ * @return string Content to return
173
+ */
174
+
175
+ function ye_convert_content( $content, $identifier, $id, $audio = '', $suffix = '', $profile = '' ) {
176
+
177
+ $code = ye_generate_youtube_code( $id, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', $profile, '', $audio );
178
+ $content = str_replace( $identifier.$id.$suffix, $code, $content);
179
+
180
+ return $content;
181
+ }
182
+
183
+ /**
184
+ * Filter comments
185
+ *
186
+ * Filter comments and add YouTube embeds
187
+ *
188
+ * @since 2.0
189
+ *
190
+ * @uses ye_set_general_defaults Get the general defaults
191
+ * @uses ye_generate_youtube_code Generate the YouTube embed code
192
+ *
193
+ * @param string $content The comments content
194
+ * @return string Content to return
195
+ */
196
+
197
+ function ye_filter_comments( $content ) {
198
+
199
+ $options = ye_set_general_defaults();
200
+
201
+ if ( $options[ 'comments' ] == 1 ) {
202
+
203
+ $identifier = 'http://www.youtube.com/watch?v=';
204
+ $search_pos = 0;
205
+ $search = strpos( $content, $identifier, $search_pos );
206
+
207
+ while ( $search !== false ) {
208
+ $prefix = substr( $content, $search - 1, 1 );
209
+ if ( ( $prefix != ']' ) && ( $prefix != '"' ) && ( $prefix != "'" ) ) {
210
+
211
+ // Check if link around video. If so, work out how much more needs stripping out
212
+ $anchor_start = 0;
213
+ $anchor_end = 0;
214
+ if ( $prefix == ">" ) {
215
+ $anchor_pos = strrpos( substr( $content, 0, $search ), '<a' );
216
+ if ( $anchor_pos !== false ) {
217
+ $anchor_start = $search - $anchor_pos;
218
+ $anchor_end = strpos(substr($content,$search),'</a>') - strlen($identifier) - 11;
219
+ }
220
+ }
221
+
222
+ // Work out video ID and generate code
223
+ $id = substr( $content, $search + strlen( $identifier ), 11 );
224
+ $code = ye_generate_youtube_code( $id, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', $options[ 'comments_profile' ], '', '' );
225
+
226
+ // Now replace the URL with the resultant code
227
+ $first_section = $search - 1 - $anchor_start;
228
+ if ( $first_section < 1 ) {
229
+ $content = $code . substr( $content, $search + strlen( $identifier ) + 11 + $anchor_end );
230
+ } else {
231
+ $content = substr( $content, 0, $first_section ) . $code . substr( $content, $search + strlen( $identifier ) + 11 + $anchor_end );
232
+ }
233
+
234
+ $search_pos = $search + strlen( $code ) - $anchor_start;
235
+ } else {
236
+ $search_pos = $search + strlen( $identifier ) + 11;
237
+ }
238
+ $search = strpos( $content, $identifier, $search_pos - 1);
239
+ }
240
+ }
241
+ return $content;
242
+ }
243
+ add_filter( 'comment_text', 'ye_filter_comments' );
244
+ ?>
includes/deprecated.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Deprecated Code
4
+ *
5
+ * Various pieces of code, now deprecated, but kept here for backwards compatibility
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ */
10
+
11
+ // Shortcode for showing playlists - can now use the standard video shortcode
12
+ // In fact, this shortcode now simply directs to the video shortcode
13
+ add_shortcode( 'youtube_playlist', 'ye_video_shortcode' );
14
+
15
+ // Shortcode for downloading playlist - in fact, this never worked as option doesn't
16
+ // allow playlists. None-the-less, now diverts to standard download shortcode
17
+ // and will display an appropriate error
18
+ add_shortcode( 'download_playlist', 'ye_video_download' );
19
+
20
+ /**
21
+ * Embed a playlist
22
+ *
23
+ * Function to embed a playlist
24
+ *
25
+ * @deprecated 2.0 Use youtube_video_embed() instead.
26
+ * @since 2.0
27
+ *
28
+ * @uses youtube_video_embed Embed a video
29
+ *
30
+ * @param string $content Video ID
31
+ * @param string $paras Parameters
32
+ * @param string $style CSS
33
+ */
34
+
35
+ function youtube_playlist_embed( $content, $paras, $style = '' ) {
36
+ youtube_video_embed( $content, $paras, $style );
37
+ return;
38
+ }
39
+
40
+ /**
41
+ * Get playlist download link
42
+ *
43
+ * Return YouTube playlist download URL
44
+ * No longer found to work, so simply reports an error now
45
+ *
46
+ * @deprecated 2.0 Use youtube_short_url() instead.
47
+ * @since 2.0
48
+ *
49
+ * @uses ye_error Display an error
50
+ *
51
+ * @param string $id Video ID
52
+ */
53
+
54
+ function get_playlist_download( $id = '' ) {
55
+ echo ye_error( 'This function does not support playlists' );
56
+ return;
57
+ }
58
+ ?>
includes/function-calls.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Function Calls
4
+ *
5
+ * Various function calls that the user may call directly
6
+ *
7
+ * @package YouTubeEmbed
8
+ */
9
+
10
+ /**
11
+ * Embed a YouTube video
12
+ *
13
+ * Write out XHTML to embed a YouTube video
14
+ *
15
+ * @since 2.0
16
+ *
17
+ * @uses ye_get_parameters Extract parameters from input
18
+ * @uses ye_get_embed_type Work out the correct embed type to use
19
+ * @uses ye_set_autohide Set correct autohide parameter
20
+ * @uses ye_generate_youtube_code Generate the YouTube code
21
+ *
22
+ * @param string $content YouTube video ID
23
+ * @param string $paras List of parameters
24
+ * @param string $style Optional CSS
25
+ */
26
+
27
+ function youtube_video_embed( $content, $paras = '', $style = '' ) {
28
+ $width = ye_get_parameters( $paras, 'width' );
29
+ $height = ye_get_parameters( $paras, 'height' );
30
+ $fullscreen = ye_get_parameters( $paras, 'fullscreen' );
31
+ $related = ye_get_parameters( $paras, 'related' );
32
+ $autoplay = ye_get_parameters( $paras, 'autoplay' );
33
+ $loop = ye_get_parameters( $paras, 'loop' );
34
+ $start = ye_get_parameters( $paras, 'start' );
35
+ $info = ye_get_parameters( $paras, 'info' );
36
+ $annotation = ye_get_parameters( $paras, 'annotation' );
37
+ $cc = ye_get_parameters( $paras, 'cc' );
38
+ $link = ye_get_parameters( $paras, 'link' );
39
+ $react = ye_get_parameters( $paras, 'react' );
40
+ $stop = ye_get_parameters( $paras, 'stop' );
41
+ $sweetspot = ye_get_parameters( $paras, 'sweetspot' );
42
+ $embedplus = ye_get_parameters( $paras, 'embedplus' );
43
+ $disablekb = ye_get_parameters( $paras, 'disablekb' );
44
+ $ratio = ye_get_parameters( $paras, 'ratio' );
45
+ $autohide = ye_get_parameters( $paras, 'autohide' );
46
+ $controls = ye_get_parameters( $paras, 'controls' );
47
+ $type = ye_get_parameters( $paras, 'type' );
48
+ $profile = ye_get_parameters( $paras, 'profile' );
49
+ $list = ye_get_parameters( $paras, 'list' );
50
+ $audio = ye_get_parameters( $paras, 'audio' );
51
+ $template = ye_get_parameters( $paras, 'template' );
52
+ $hd = ye_get_parameters( $paras, 'hd' );
53
+
54
+ // Get Embed type
55
+ $type = ye_get_embed_type( $type, $embedplus );
56
+
57
+ // Set up Autohide parameter
58
+ $autohide = ye_set_autohide( $autohide );
59
+
60
+ echo ye_generate_youtube_code( $content, $type, $width, $height, ye_convert( $fullscreen ), ye_convert( $related ), ye_convert( $autoplay ), ye_convert( $loop ), $start, ye_convert( $info ), ye_convert_3( $annotation ), ye_convert( $cc ), $style, ye_convert( $link ), ye_convert( $react ), $stop, ye_convert( $sweetspot ), ye_convert( $disablekb ), $ratio, $autohide, ye_convert( $controls ), $profile, $list, ye_convert( $audio ), $template, ye_convert( $hd ) );
61
+ return;
62
+ }
63
+
64
+ /**
65
+ * Display a video thumbnail
66
+ *
67
+ * Display a thumbnail of a video
68
+ *
69
+ * @since 2.0
70
+ *
71
+ * @uses ye_get_parameters Extract parameters from a string
72
+ * @uses ye_generate_thumbnaik_code Get the thumbnail code
73
+ *
74
+ * @param string $content YouTube video ID
75
+ * @param string $paras Parameters
76
+ * @param string $style CSS information
77
+ * @param string $alt Alt text
78
+ */
79
+
80
+ function youtube_thumb_embed( $content, $paras = '', $style = '', $alt = '' ) {
81
+
82
+ $class = ye_get_parameters( $paras, 'class' );
83
+ $rel = ye_get_parameters( $paras, 'rel' );
84
+ $target = ye_get_parameters( $paras, 'target' );
85
+ $width = ye_get_parameters( $paras, 'width' );
86
+ $height = ye_get_parameters( $paras, 'height' );
87
+
88
+ echo ye_generate_thumbnail_code( $content, $style, $class, $rel, $target, $width, $height, $alt );
89
+
90
+ return;
91
+ }
92
+
93
+ /**
94
+ * Return video short URL
95
+ *
96
+ * Return a short URL for the YouTube video
97
+ *
98
+ * @since 2.0
99
+ *
100
+ * @uses ye_generate_shorturl_code Display an error
101
+ *
102
+ * @param string $id YouTube video ID
103
+ * @return string Download URL
104
+ */
105
+
106
+ function youtube_short_url( $id ) {
107
+ return ye_generate_shorturl_code( $id );
108
+ }
109
+
110
+ /**
111
+ * Get video download URL
112
+ *
113
+ * Return a URL for the video so that it can be downloaded
114
+ *
115
+ * @since 2.0
116
+ *
117
+ * @uses ye_generate_download_code Get the download URL
118
+ *
119
+ * @param string $id YouTube video ID
120
+ * @return string Download URL
121
+ */
122
+
123
+ function get_video_download( $id ) {
124
+ return ye_generate_download_code( $id );
125
+ }
126
+
127
+ /**
128
+ * Get XML transcript
129
+ *
130
+ * Return XML formatted YouTube transcript
131
+ *
132
+ * @since 2.0
133
+ *
134
+ * @uses ye_error Output an error
135
+ * @uses ye_extract_id Extract a video ID
136
+ * @uses ye_get_file Get a file
137
+ * @uses ye_validate_id Check the video ID is valid
138
+ *
139
+ * @param string $id YouTube video ID
140
+ * @return string Transcript file in XML format
141
+ */
142
+
143
+ function get_youtube_transcript_xml ( $id ) {
144
+
145
+ // Extract the ID if a full URL has been specified
146
+ $id = ye_extract_id( $id );
147
+
148
+ // Check what type of video it is and whether it's valid
149
+ $embed_type = ye_validate_id( $id );
150
+ if ( $embed_type != 'v' ) { echo ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); return; }
151
+
152
+ // Get transcript file
153
+ $filename = 'http://video.google.com/timedtext?lang=en&v=' . $id;
154
+ $xml = ye_get_file( $filename );
155
+
156
+ // Check success and return appropriate output
157
+ if ( $xml[ 'rc' ] > 0 ) {
158
+ echo ye_error( 'Could not fetch the transcript file ' . $filename . '.' );
159
+ return;
160
+ } else {
161
+ return $xml;
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Get transcript
167
+ *
168
+ * Return XHTML formatted YouTube transcript
169
+ *
170
+ * @since 2.0
171
+ *
172
+ * @uses ye_generate_generatE_transcript Generate the transcript output
173
+ *
174
+ * @param string $id YouTube video ID
175
+ * @return string Transcript file in XHTML format
176
+ */
177
+
178
+ function get_youtube_transcript( $id ) {
179
+ return ye_generate_transcript( $id );
180
+ }
181
+
182
+ /**
183
+ * Get Video Name
184
+ *
185
+ * Function to return the name of a YouTube video
186
+ *
187
+ * @since 2.0
188
+ *
189
+ * @uses ye_extract_id Extract the video ID
190
+ * @uses ye_validate_id Get the name and video type
191
+ * @uses ye_error Return an error
192
+ *
193
+ * @param string $id Video ID
194
+ * @return string Video name
195
+ */
196
+
197
+ function get_youtube_name( $id ) {
198
+
199
+ // Extract the ID if a full URL has been specified
200
+ $id = ye_extract_id( $id );
201
+
202
+ // Check what type of video it is and whether it's valid
203
+ $return = ye_validate_id( $id, true );
204
+ if ( !$return['type'] ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
205
+
206
+ // Return the video title
207
+ return $return['title'];
208
+ }
209
+ ?>
includes/generate-download-code.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generate Download Code
4
+ *
5
+ * Create code to allow a YouTube video to be downloaded
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ *
10
+ * @uses ye_extract_id Extract an ID from a string
11
+ * @uses ye_validate_id Confirm the type of video
12
+ * @uses ye_error Display an error
13
+ *
14
+ * @param string $id YouTube video ID
15
+ * @param string $target Link target
16
+ * @param string $nofollow Use rel="nofollow" ?
17
+ * @param string $text Text to add link to
18
+ * @return string URL
19
+ */
20
+
21
+ function ye_generate_download_code( $id ) {
22
+
23
+ if ( $id == '' ) { return ye_error( 'No YouTube ID was found.' ); }
24
+
25
+ // Extract the ID if a full URL has been specified
26
+ $id = ye_extract_id( $id );
27
+
28
+ // Check what type of video it is and whether it's valid
29
+ $embed_type = ye_validate_id( $id );
30
+ if ( $embed_type != 'v' ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
31
+
32
+ // Create the link
33
+ return 'http://www.savevid.com/?url=http://www.youtube.com/watch?' . $embed_type . '=' . $id;
34
+ }
35
+ ?>
includes/generate-embed-code.php ADDED
@@ -0,0 +1,437 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generate embed code
4
+ *
5
+ * Functions calls to generate the required YouTube code
6
+ *
7
+ * @package YouTubeEmbed
8
+ */
9
+
10
+ /**
11
+ * Generate embed code
12
+ *
13
+ * Generate XHTML compatible YouTube embed code
14
+ *
15
+ * @since 2.0
16
+ *
17
+ * @uses ye_convert_id Convert special characters in ID
18
+ * @uses ye_error Display an error
19
+ * @uses ye_extract_id Get the video ID
20
+ * @uses ye_validate_list Get the requested listr
21
+ * @uses ye_validate_id Validate the video ID
22
+ * @uses ye_validate_profile Get the requested profile
23
+ * @uses ye_set_general_defaults Get general options
24
+ * @uses ye_set_profile_defaults Set default profile options
25
+ *
26
+ * @param string $id Video ID
27
+ * @param string $type Embed type
28
+ * @param string $width Video width
29
+ * @param string $height Video height
30
+ * @param string $fullscreen Fullscreen button
31
+ * @param string $related Show related info.
32
+ * @param string $autoplay Start video automatically
33
+ * @param string $loop Loop video to start
34
+ * @param string $start Start in seconds
35
+ * @param string $info Show video info.
36
+ * @param string $annotation Annotations
37
+ * @param string $cc Closed captions
38
+ * @param string $style Stylesheet information
39
+ * @param string $link Link back to YouTube
40
+ * @param string $react Show EmbedPlus reactions
41
+ * @param string $stop Stop in seconds
42
+ * @param string $sweetspot Show EmbedPlus sweetspots
43
+ * @param string $disablekb Disable keyboard controls
44
+ * @param string $ratio Video size ratio
45
+ * @param string $autohide Autohide controls
46
+ * @param string $controls Display controls
47
+ * @param string $profile Which profile to use
48
+ * @param string $list_style How to use a list, if used
49
+ * @param string $audio Only show controls, for audio playback
50
+ * @param string $template Display template
51
+ * @return string Code output
52
+ */
53
+
54
+ function ye_generate_youtube_code( $id = '', $type = '', $width = '', $height = '', $fullscreen = '', $related = '', $autoplay = '', $loop = '', $start = '', $info = '', $annotation = '', $cc = '', $style = '', $link = '', $react = '', $stop = '', $sweetspot = '', $disablekb = '', $ratio = '', $autohide = '', $controls = '', $profile = '', $list_style = '', $audio = '', $template = '', $hd = '' ) {
55
+
56
+ // Ensure an ID is passed
57
+ if ( $id == '' ) { return ye_error( 'No video/playlist ID has been supplied' ); }
58
+
59
+ // Get general options
60
+ $general = ye_set_general_defaults();
61
+
62
+ // Find the profile, if one is specified
63
+ $profile = ye_validate_profile( $profile, $general[ 'profile_no' ] );
64
+
65
+ // Get default values if no values are supplied
66
+ $options = ye_set_profile_defaults( $profile );
67
+
68
+ // Check it's not a list
69
+ $playlist_ids = '';
70
+ $list = ye_validate_list( $id, $general[ 'list_no' ] );
71
+ if ( !is_array( $list ) ) {
72
+
73
+ // Check if certain parameters are included in the URL
74
+ $width = ye_get_url_para( $id, 'w', $width );
75
+ $height = ye_get_url_para( $id, 'h', $height );
76
+
77
+ // Extract the ID if a full URL has been specified
78
+ $id = ye_extract_id( $id );
79
+
80
+ // Is it being previewed? In which case remove any cache
81
+ if ( ( preg_match( '/p=([0-9]*)&preview=true/', $_SERVER['QUERY_STRING'] ) == 1 ) && ( $general[ 'preview' ] == 1 ) ) {
82
+ delete_transient( 'ye_type_' . $id );
83
+ delete_transient( 'ye_title_' . $id );
84
+ }
85
+
86
+ // Check what type of video it is and whether it's valid
87
+ $return = ye_validate_id( $id, true );
88
+ $title = $return['title'];
89
+ $embed_type = $return[ 'type' ];
90
+
91
+ if ( $embed_type == '' ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
92
+
93
+ } else {
94
+
95
+ $embed_type = 'v';
96
+
97
+ // Randomize the video
98
+ if ( $list_style == 'random' ) { shuffle( $list ); }
99
+
100
+ // Extract one video randomly
101
+ if ( $list_style == 'single' ) {
102
+ $id = array_rand( $list, 1 );
103
+
104
+ // Build the playlist
105
+ } else {
106
+
107
+ $id = $list [ 0 ];
108
+ $title = '';
109
+ // Build the playlist
110
+ if ( count( $list ) > 1 ) {
111
+ $loop = 1;
112
+ while ( $loop < count( $list ) ) {
113
+ if ( $playlist_ids != '' ) { $playlist_ids .= ','; }
114
+ $id = ye_extract_id( $list[ $loop ] );
115
+ $playlist_ids .= $id;
116
+ $loop ++;
117
+ }
118
+ }
119
+ }
120
+ }
121
+
122
+ // Generate a cache key for the above passed parameters
123
+ $cache_key = 'ye_video_' . base64_encode( sha1( $id . $type . $width . $height . $fullscreen . $related . $autoplay . $loop . $start . $info . $annotation . $cc . $style . $link . $react . $stop . $sweetspot . $disablekb . $ratio . $autohide . $controls . $profile . $list_style . $audio . $template . $hd . $general . $options . $list, true ) );
124
+
125
+ // Try and get the output from cache. If it exists, return the code
126
+ if ( ( $general[ 'embed_cache' ] != 0 ) && ( !is_feed() ) ) {
127
+ $result = get_transient( $cache_key );
128
+ if ( $result !== false) { return $result; }
129
+ }
130
+
131
+ // If this is a feed then display a thumbnail and/or text link to the original video
132
+ if ( is_feed () ) {
133
+ $result = '';
134
+ if ( $playlist_ids != '' ) {
135
+ $result .= '<p>'.__('A video list cannot be viewed within this feed - please view the original content').".</p>\n";
136
+ } else {
137
+ $youtube_url = 'http://www.youtube.com/watch?' . $embed_type . '=' . $id;
138
+ if ( ( $embed_type == 'v' ) && ( $general[ 'feed' ] != 't' ) ) { $result .= '<p><a href="' . $youtube_url . '"><img src="http://img.youtube.com/vi/' . $id . "/2.jpg\"></a></p>\n"; }
139
+ if ( ( $general ['feed'] != 'v' ) or ( $embed_type != 'v' ) ) { $result .= '<p><a href="' . $youtube_url . '">' . __( 'Click here</a> to view the video on YouTube' ) . ".</p>\n"; }
140
+ }
141
+ return $result;
142
+ }
143
+
144
+ $metadata = $general[ 'metadata' ];
145
+
146
+ // Only set width and height from defaults if both are missing
147
+ if ( ( $width == '' ) && ( $height == '' ) ) {
148
+ $width = $options[ 'width' ];
149
+ $height = $options[ 'height' ];
150
+ }
151
+
152
+ // If values have not been pressed, use the default values
153
+ if ( $fullscreen == '' ) { $fullscreen = $options[ 'fullscreen' ]; }
154
+ if ( $related == '' ) { $related = $options[ 'related' ]; }
155
+ if ( $autoplay == '' ) { $autoplay = $options[ 'autoplay' ]; }
156
+ if ( $loop == '' ) { $loop = $options[ 'loop' ]; }
157
+ if ( $info == '' ) { $info = $options[ 'info' ]; }
158
+ if ( $annotation == '' ) { $annotation = $options[ 'annotation' ]; }
159
+ if ( $cc == '' ) { $cc = $options[ 'cc' ]; }
160
+ if ( $link == '' ) { $link = $options[ 'link' ]; }
161
+ if ( $react == '' ) { $react = $options[ 'react' ]; }
162
+ if ( $sweetspot == '' ) { $sweetspot = $options[ 'sweetspot' ]; }
163
+ if ( $disablekb == '' ) { $disablekb = $options[ 'disablekb' ]; }
164
+ if ( $autohide == '' ) { $autohide = $options[ 'autohide' ]; }
165
+ if ( $controls == '' ) { $controls = $options[ 'controls' ]; }
166
+ if ( $audio == '' ) { $audio = $options[ 'audio' ]; }
167
+ if ( $hd == '' ) { $hd = $options[ 'hd' ]; }
168
+
169
+ $wmode = $options[ 'wmode' ];
170
+ $shadow = $options[ 'shadow' ];
171
+
172
+ // If a style has been specified, build the code. Otherwise, use the template
173
+ if ( $template == '' ) {
174
+ if ( $style == '' ) {
175
+ $template = $options[ 'template' ];
176
+ } else {
177
+ $template = '<div style="' . $style . '">%video%</div>';
178
+ }
179
+ }
180
+ if ( strpos( $template, '%video%' ) === false ) { $template = '%video%'; }
181
+
182
+ // If a multi-play list has been specified and EmbedPlus selected, use fallback embedding method instead
183
+ if ( ( $playlist_ids != '' ) && ( $type == 'm' ) && ( $list != 'single' ) ) { $type = $options[ 'fallback' ]; }
184
+
185
+ // If looping and no playlist has been generated, add the current ID
186
+ // This is a workaround for the AS3 player which won't otherwise loop
187
+ if ( ( $loop == 1 ) && ( $embed_type != 'p' ) && ( $playlist_ids == '' ) ) { $playlist_ids = $id; }
188
+
189
+ // If no type was specified, depending on whether this is a video or playlist, set the specific default
190
+ if ( $type == '' ) {
191
+ if ( $embed_type == 'v' ) {
192
+ $type = $options[ 'type' ];
193
+ } else {
194
+ $type = $options[ 'playlist' ];
195
+ }
196
+ }
197
+
198
+ // Set parameters without default values
199
+ if ( $start == '' ) { $start = '0'; }
200
+ if ( $stop == '' ) { $stop = '0'; }
201
+
202
+ // If height or width is missing, calculate missing parameter using ratio
203
+ if ( ( ( $width == '' ) or ( $height == '' ) ) && ( ( $width != '' ) or ( $height != '' ) ) ) {
204
+ $ratio_to_use = '';
205
+ if ( $ratio != '' ) {
206
+ // Extract the ratio from the provided string
207
+ $pos = strpos( $ratio, ':', 0 );
208
+ if ( $pos !== false ) {
209
+ $ratio_l = substr( $ratio, 0, $pos );
210
+ $ratio_r = substr( $ratio, $pos + 1 );
211
+ if ( ( is_numeric( $ratio_l ) ) && ( is_numeric( $ratio_r ) ) ) { $ratio_to_use = $ratio_l / $ratio_r; }
212
+ }
213
+ }
214
+
215
+ // If no, or invalid, ratio supplied, calculate from the default video dimensions
216
+ if ( $ratio_to_use == '' ) { $ratio_to_use = $options[ 'width' ] / $options[ 'height' ]; }
217
+
218
+ // Complete the missing width or height using the ratio
219
+ if ( $width == '' ) { $width = round( $height * $ratio_to_use, 0); }
220
+ if ( $height == '' ) { $height = round( $width / $ratio_to_use, 0); }
221
+ }
222
+
223
+ // If audio playback option is set, restrict the height to just show the player toolbar
224
+ if ( $audio == '1' ) { $height = 27; }
225
+
226
+ // Set up embed types
227
+ $tab = '';
228
+ $class = 'youtube-player';
229
+ $paras = '?version=3&amp;modestbranding=1';
230
+
231
+ $embedplus = false;
232
+ $swf = false;
233
+ $iframe = false;
234
+
235
+ if ( $type != 'v' ) {
236
+ if ( $type == 'm' ) {
237
+ $embedplus = true;
238
+ $tab = "\t";
239
+ $embedheight = $height + 32;
240
+ $class = 'cantembedplus';
241
+ $fallback = $options[ 'fallback' ];
242
+ } else {
243
+ $swf = true;
244
+ }
245
+ } else {
246
+ $iframe = true;
247
+ }
248
+
249
+ // Generate parameters to add to URL
250
+ if ( $fullscreen == 1 ) { $paras .= '&amp;fs=1'; }
251
+ if ( $related != 1 ) { $paras .= '&amp;rel=0'; }
252
+ if ( $autoplay == 1 ) { $paras .= '&amp;autoplay=1'; }
253
+ if ( $loop == 1 ) { $paras .= '&amp;loop=1'; }
254
+ if ( $info == 1 ) { $paras .= '&amp;showinfo=1'; }
255
+ if ( $annotation != 1 ) { $paras .= '&amp;iv_load_policy=3'; }
256
+ if ( $cc == 1 ) { $paras .= '&amp;cc_load_policy=1'; }
257
+ if ( $disablekb == 1 ) { $paras .= '&amp;disablekb=1'; }
258
+ if ( $autohide != 2 ) { $paras .= '&amp;autohide=' . $autohide; }
259
+ if ( $controls != 1 ) { $paras .= '&amp;controls=0'; }
260
+
261
+ // If not a playlist, add the playlist parameter
262
+ if ( $playlist_ids != '' ) { $paras .= '&amp;playlist=' . $playlist_ids; }
263
+
264
+ // Generate EmbedPlus parameters
265
+ $paras_ep = '&amp;width=' . $width . '&amp;height=' . $height;
266
+ if ( $react != 1 ) { $paras_ep .= '&amp;react=0'; }
267
+ if ( $sweetspot != 1 ) { $paras_ep .= '&amp;sweetspot=0'; }
268
+ if ( $hd == 1 ) { $paras_ep .= '&amp;hd=1'; }
269
+
270
+ // Add start & stop parameters
271
+ if ( $start != 0 ) { $paras .= '&amp;start=' . $start; $paras_ep .= '&amp;start=' . $start; }
272
+ if ( $stop != 0 ) { $paras_ep .= '&amp;stop=' . $stop; }
273
+
274
+ $result = '';
275
+
276
+ // Add EmbedPlus code
277
+ if ( $embedplus ) {
278
+ $result .= "<object type=\"application/x-shockwave-flash\" width=\"" . $width . "\" height=\"" . $embedheight . "\" data=\"http://getembedplus.com/embedplus.swf\">\n";
279
+ $result .= "\t<param value=\"http://getembedplus.com/embedplus.swf\" name=\"movie\" />\n";
280
+ $result .= "\t<param value=\"high\" name=\"quality\" />\n";
281
+ $result .= "\t<param value=\"" . $wmode . "\" name=\"wmode\" />\n";
282
+ $result .= "\t<param value=\"always\" name=\"allowscriptaccess\" />\n";
283
+ if ( $fullscreen == 1 ) { $result .= "\t<param name=\"allowFullScreen\" value=\"true\" />\n"; }
284
+ $result .= "\t<param name=\"flashvars\" value=\"ytid=" . $id . $paras_ep . "\" />\n";
285
+ }
286
+
287
+ // Add AS3 YouTube embed code
288
+ if ( ( $swf ) or ( ( $embedplus ) && ( ( $fallback == 'o' ) or ( $fallback == 'p' ) ) ) ) {
289
+ $result .= $tab . "<object class=\"" . $class . "\" type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/" . $embed_type . "/" . $id . $paras . "\" width=\"" . $width . "\" height=\"" . $height . "\"";
290
+ if ( $metadata != 0 ) { $result .= " rel=\"media:video\" resource=\"http://www.youtube.com/" . $embed_type . "/" . $id ."\" xmlns:media=\"http://search.yahoo.com/searchmonkey/media/\""; }
291
+ $result .= ">\n";
292
+ if ( $metadata != 0 ) { $result .= $tab . "\t<a rel=\"media:thumbnail\" href=\"http://img.youtube.com/vi/" . $id . "/default.jpg\" />\n"; }
293
+ $result .= $tab . "\t<param name=\"movie\" value=\"http://www.youtube.com/" . $embed_type . "/" . $id . $paras . "\" />\n";
294
+ $result .= $tab . "\t<param name=\"wmode\" value=\"" . $wmode . "\" />\n";
295
+ if ( $fullscreen == 1 ) { $result .= $tab . "\t<param name=\"allowFullScreen\" value=\"true\" />\n"; }
296
+ if ( ( $link != 1 ) && ( $link != '' ) ) { $result .= $tab . "\t<param name=\"allowNetworking\" value=\"internal\" />\n"; }
297
+ if ( ( $metadata != 0 ) && ( $title != '' ) ) { $result .= $tab . "\t<span property=\"media:title\" content=\"" . htmlentities( $title ) . "\" />\n"; }
298
+ $result .= $tab . "</object>\n";
299
+ }
300
+
301
+ // Add IFRAME embed code
302
+ if ( ( $iframe ) or ( ( $embedplus ) && ( $fallback == "v" ) ) ) {
303
+ if ( $embed_type == "p" ) { $playlist_para = "p/"; } else { $playlist_para = ''; }
304
+ $result .= $tab . '<iframe style="border: 0" class="' . $class . '" width="' . $width . '" height="' . $height . '" src="http://www.youtube.com/embed/' . $playlist_para . $id . '?' . substr( $paras, 1 ) . '&amp;wmode=' . $wmode . '"';
305
+ if ( $fullscreen == 1 ) { $result .= ' allowfullscreen="allowfullscreen"'; }
306
+ $result .= "></iframe>\n";
307
+ }
308
+
309
+ // If using EmbedPlus, add the OBJECT closure tag
310
+ if ( $embedplus ) { $result .= "</object>\n<!--[if lte IE 6]> <style type=\"text/css\">.cantembedplus{display:none;}</style><![endif]-->\n"; }
311
+
312
+ // Add drop shadow
313
+ if ( ( is_numeric( $shadow ) ) && ( $shadow != 0 ) ) { $result .= "<br/><img src=\"" . WP_PLUGIN_URL . "/youtube-embed/images/shadow.png\" alt=\"\" title=\"\" height=\"" . $shadow . "\" width=\"" . $width . "\" />\n"; }
314
+
315
+ // Now apply the template to the result
316
+ $result = str_replace( '%video%', $result, $template );
317
+
318
+ // Now add a commented header and trailer
319
+ $result = "\n<!-- YouTube Embed v" . youtube_embed_version . " | http://www.artiss.co.uk/artiss-youtube-embed -->\n" . $result;
320
+ $result .= "<!-- End of YouTube Embed code -->\n";
321
+
322
+ // Cache the output
323
+ if ( $general[ 'embed_cache' ] != 0 ) { set_transient( $cache_key, $result, 3600 * $general[ 'embed_cache' ] ); }
324
+
325
+ return $result;
326
+ }
327
+
328
+ /**
329
+ * Validate a supplied profile name
330
+ *
331
+ * Returns a profile number for a supplied name
332
+ *
333
+ * @since 2.0
334
+ *
335
+ * @param string $name The name of the profile to find
336
+ * @param string $number The number of profiles available
337
+ * @return string The profile number (defaults to 0)
338
+ */
339
+
340
+ function ye_validate_profile( $name, $number ) {
341
+
342
+ $profile = 0;
343
+ $name = strtolower( $name );
344
+
345
+ if ( ( $name != '' ) && ( $name != 'default' ) ) {
346
+
347
+ // Loop around, fetching in profile names
348
+ $loop = 1;
349
+ while ( ( $loop <= $number ) && ( $profile == 0 ) ) {
350
+ if ( ( $name == $loop ) or ( $name == 'Profile ' . $loop ) ) {
351
+ $profile = $loop;
352
+ } else {
353
+ $profiles = get_option( 'youtube_embed_profile' . $loop );
354
+ $profname = strtolower( $profiles[ 'name' ] );
355
+ if ( $profname == $name ) { $profile = $loop; }
356
+ }
357
+ $loop ++;
358
+ }
359
+ }
360
+ return $profile;
361
+ }
362
+
363
+ /**
364
+ * Validate a supplied list name
365
+ *
366
+ * Returns a list for a supplied list number or name name - blank if not a valid list
367
+ *
368
+ * @since 2.0
369
+ *
370
+ * @param string $name The name of the list to find
371
+ * @param string $number The number of lists available
372
+ * @return string The list (defaults to blank)
373
+ */
374
+
375
+ function ye_validate_list( $name, $number ) {
376
+
377
+ $list = '';
378
+
379
+ // If the parameter contains commas, assume to be a comma seperated list and move into an array
380
+ if ( strpos( $name, ',' ) !== false ) {
381
+ $list = explode( ',', $name );
382
+ } else {
383
+
384
+ // No comma, so check if this is a named list
385
+ $name = strtolower( $name );
386
+
387
+ if ( $name != '' ) {
388
+
389
+ // Loop around, fetching in profile names
390
+ $loop = 1;
391
+ while ( ( $loop <= $number ) && ( $list == '' ) ) {
392
+ $listfiles = get_option( 'youtube_embed_list' . $loop );
393
+ if ( ( $name == $loop ) or ( $name == 'List ' . $loop ) ) {
394
+ $list = $listfiles[ 'list' ];
395
+ } else {
396
+ $listname = strtolower( $listfiles[ 'name' ] );
397
+ if ( $listname == $name ) { $list = $listfiles[ 'list' ]; }
398
+ }
399
+ $loop ++;
400
+ }
401
+ }
402
+ if ( $list != '' ) { $list = explode( "\n", $list ); }
403
+ }
404
+ return $list;
405
+ }
406
+
407
+ /**
408
+ * Get URL parameters
409
+ *
410
+ * Extract a requested parameter from a URL
411
+ *
412
+ * @since 2.0
413
+ *
414
+ * @param string $id The ID of the video
415
+ * @param string $para The parameter to extract
416
+ * @param string $current The current parameter value
417
+ * @return string The parameter value
418
+ */
419
+
420
+ function ye_get_url_para( $id, $para, $current ) {
421
+
422
+ // Look for an ampersand
423
+ $start_pos = false;
424
+ if ( strpos( $id, '&amp;' . $para . '=' ) !== false ) { $start_pos = strpos( $id, '&amp;' . $para . '=' ) + 6 + strlen( $para ); }
425
+
426
+ // If a parameter was found, look for the end of it
427
+ if ( $start_pos !== false ) {
428
+ $end_pos = strpos( $id, '&amp;', $start_pos + 1 );
429
+ if ( !$end_pos ) { $end_pos = strlen( $id ); }
430
+
431
+ // Extract the parameter and return it
432
+ $current = substr( $id, $start_pos, $end_pos - $start_pos );
433
+ }
434
+
435
+ return $current;
436
+ }
437
+ ?>
includes/generate-shorturl-code.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generate video short URL
4
+ *
5
+ * Create a short URL to a YouTube video
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ *
10
+ * @uses ye_extract_id Extract an ID from a string
11
+ * @uses ye_validate_id Confirm the type of video
12
+ * @uses ye_error Display an error
13
+ *
14
+ * @param string $id YouTube video ID
15
+ * @return string $youtube_code Code
16
+ */
17
+
18
+ function ye_generate_shorturl_code( $id ) {
19
+
20
+ // Check that an ID has been specified
21
+ if ( $id == '' ) {
22
+ return ye_error( 'No video ID has been supplied' );
23
+ } else {
24
+
25
+ // Extract the ID if a full URL has been specified
26
+ $id = ye_extract_id( $id );
27
+
28
+ // Check what type of video it is and whether it's valid
29
+ $embed_type = ye_validate_id( $id );
30
+ if ( $embed_type != 'v' ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
31
+
32
+ return 'http://youtu.be/' . $id;
33
+ }
34
+ }
35
+ ?>
includes/generate-thumbnail-code.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generate Thumbnail Code
4
+ *
5
+ * Generate XHTML compatible YouTube video thumbnail
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ *
10
+ * @uses ye_extract_id Extract an ID from a string
11
+ * @uses ye_validate_id Confirm the type of video
12
+ * @uses ye_error Display an error
13
+ *
14
+ * @param string $id YouTube video ID
15
+ * @param string $style Link STYLE
16
+ * @param string $class Link CLASS
17
+ * @param string $rel Link REL
18
+ * @param string $target Link target
19
+ * @param string $width Width
20
+ * @param string $height Height
21
+ * @param string $alt ALT text
22
+ * @return string $youtube_code Code
23
+ */
24
+
25
+ function ye_generate_thumbnail_code( $id, $style, $class, $rel, $target, $width, $height, $alt ) {
26
+
27
+ // Extract the ID if a full URL has been specified
28
+ $id = ye_extract_id( $id );
29
+
30
+ // Check what type of video it is and whether it's valid
31
+ $embed_type = ye_validate_id( $id );
32
+ if ( $embed_type != 'v' ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
33
+
34
+ // Now create the required code
35
+ if ( $alt == '' ) { $alt = 'YouTube Video ' . $id; }
36
+ $youtube_code = '<a href="http://www.youtube.com/watch?v=' . $id . '"';
37
+ if ( $style != '' ) { $youtube_code .= ' style="' . $style . '"'; }
38
+ if ( $class != '' ) { $youtube_code .= ' class="' . $class . '"'; }
39
+ if ( $rel != '' ) { $youtube_code .= ' rel="' . $rel . '"'; }
40
+ if ( $target != '' ) { $youtube_code .= ' target="' . $target . '"'; }
41
+ $youtube_code .= '><img src="http://img.youtube.com/vi/' . $id . '/2.jpg"';
42
+ if ( $width != '' ) { $youtube_code .= ' width="' . $width . 'px"'; }
43
+ if ( $height != '' ) { $youtube_code .= ' height="' . $height . 'px"'; }
44
+ $youtube_code .= ' alt="' . $alt . '"/></a>';
45
+
46
+ return $youtube_code;
47
+ }
48
+ ?>
includes/generate-transcript-code.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Create Transcript
4
+ *
5
+ * All functions relating to creating YouTube transcripts
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ */
10
+
11
+ /**
12
+ * Get YouTube Transcript
13
+ *
14
+ * Generate re-encoded YouTube transcript
15
+ *
16
+ * @since 2.0
17
+ *
18
+ * @uses ye_get_file Get a file
19
+ *
20
+ * @param string $id Video ID
21
+ * @return string $output Transcript output
22
+ */
23
+
24
+ function ye_generate_transcript( $id ) {
25
+
26
+ // Extract the ID if a full URL has been specified
27
+ $id = ye_extract_id( $id );
28
+
29
+ // Check what type of video it is and whether it's valid
30
+ $embed_type = ye_validate_id( $id );
31
+ if ( $embed_type != 'v' ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
32
+
33
+ // Get general options
34
+ $general = ye_set_general_defaults();
35
+
36
+ // Check to see if cache is available
37
+ if ( $general[ 'transcript_cache' ] != 0 ) {
38
+ $cache_key = 'ye_transcript_'.$id;
39
+ $output = get_transient( $cache_key );
40
+ if ( $output !== false) { return $output; }
41
+ }
42
+
43
+ // Get transcript file
44
+ $return = ye_get_file( 'http://video.google.com/timedtext?lang=en&v=' . $id );
45
+ $xml = $return[ 'file' ];
46
+ $output = '';
47
+
48
+ // If transcript file exists, strip and output
49
+ if ( $return[ 'rc' ] == 0 ) {
50
+ $output = "<!-- YouTube Embed v" . youtube_embed_version . " | http://www.artiss.co.uk/artiss-youtube-embed -->\n";
51
+ $pos = 0;
52
+ $eof = false;
53
+
54
+ while ( !$eof ) {
55
+ $text_start = strpos( $xml, '<text ',$pos );
56
+ if ( $text_start !== false ) {
57
+
58
+ // Extract the start time
59
+ $start_start = strpos( $xml, 'start="', $text_start ) + 7;
60
+ $start_end = strpos( $xml, '"', $start_start ) - 1;
61
+ $start = substr( $xml, $start_start, $start_end - $start_start + 1 );
62
+
63
+ // Convert time format
64
+ $start = str_pad( floor( $start ), 3, '0', STR_PAD_LEFT );
65
+ $start = substr( $start, 0, -2 ) . ':' . substr( $start, -2, 2 );
66
+
67
+ // Now extract the text
68
+ $text_start = strpos( $xml, '>', $text_start ) + 1;
69
+ $text_end = strpos( $xml, '</text>', $text_start ) - 1;
70
+ $text = substr( $xml, $text_start, $text_end - $text_start + 1 );
71
+
72
+ // Now return the output
73
+ $output .= "<div class=\"Transcript\"><span class=\"TranscriptTime\">" . $start . "</span> <span class=\"TranscriptText\">" . htmlspecialchars_decode( $text ) . "</span></div>\n";
74
+ $pos = $text_end + 7;
75
+ } else {
76
+ $eof = true;
77
+ }
78
+ }
79
+ $output .= "<!-- End of YouTube Embed code -->\n";
80
+ }
81
+
82
+ // Save the cache
83
+ if ( $general[ 'transcript_cache' ] != 0 ) { set_transient( $cache_key, $output, 3600 * $general[ 'transcript_cache' ] ); }
84
+
85
+ return $output;
86
+ }
87
+ ?>
includes/mcebutton.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * TinyMCE Button Functions
4
+ *
5
+ * Add extra button(s) to TinyMCE interface
6
+ *
7
+ * @package YouTubeEmbed
8
+ */
9
+
10
+ /**
11
+ * Set up TinyMCE button
12
+ *
13
+ * Add filters (assuming user is editing) for TinyMCE
14
+ *
15
+ * @since 2.0
16
+ */
17
+
18
+ function youtube_embed_button() {
19
+
20
+ if ( current_user_can( 'edit_pages' ) ) {
21
+ $options = ye_set_general_defaults();
22
+
23
+ if ( ( get_user_option( 'rich_editing' ) == 'true' ) && ( $options[ 'editor_button' ] != '' ) ) {
24
+ add_filter( 'mce_external_plugins', 'add_youtube_embed_mce_plugin' );
25
+ add_filter( 'mce_buttons', 'register_youtube_embed_button' );
26
+ }
27
+ }
28
+ }
29
+ add_action( 'init','youtube_embed_button' );
30
+
31
+ /**
32
+ * Register new TinyMCE button
33
+ *
34
+ * Register details of new TinyMCE button
35
+ *
36
+ * @since 2.0
37
+ *
38
+ * @param string $buttons TinyMCE button data
39
+ * @return string TinyMCE button data, but with new YouTube button added
40
+ */
41
+
42
+ function register_youtube_embed_button( $buttons ) {
43
+ array_push( $buttons, '|', 'YouTube' );
44
+ return $buttons;
45
+ }
46
+
47
+ /**
48
+ * Register TinyMCE Script
49
+ *
50
+ * Register JavaScript that will be actioned when the new TinyMCE button is used
51
+ *
52
+ * @since 2.0
53
+ *
54
+ * @param string $plugin_array Array of MCE plugin data
55
+ * @return string Array of MCE plugin data, now with URL of MCE script
56
+ */
57
+
58
+ function add_youtube_embed_mce_plugin( $plugin_array ) {
59
+ $plugin_array[ 'YouTube' ] = WP_PLUGIN_URL . '/youtube-embed/js/mcebutton.js';
60
+ return $plugin_array;
61
+ }
62
+ ?>
includes/options-general.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * General Options Page
4
+ *
5
+ * Screen for generic options
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ */
10
+
11
+ ?>
12
+ <div class="wrap">
13
+ <div class="icon32"><img src="<?php echo WP_PLUGIN_URL; ?>/youtube-embed/images/screen_icon.png" alt="" title="" height="32px" width="32px"/><br /></div>
14
+ <h2>Artiss YouTube Embed Options</h2>
15
+
16
+ <?php
17
+ // If options have been updated on screen, update the database
18
+ if ( ( !empty( $_POST ) ) && ( check_admin_referer( 'youtube-embed-general', 'youtube_embed_general_nonce' ) ) ) {
19
+
20
+ $options[ 'editor_button' ] = $_POST[ 'youtube_embed_editor_button' ];
21
+ $options[ 'admin_bar' ] = $_POST[ 'youtube_embed_admin_bar' ];
22
+ $options[ 'profile_no' ] = $_POST[ 'youtube_embed_profile_no' ];
23
+
24
+ // If the number of profiles is less than zero, put it to 0
25
+ if ( $options[ 'profile_no' ] < 0 ) { $options[ 'profile_no' ] = 0; }
26
+
27
+ $options[ 'list_no' ] = $_POST[ 'youtube_embed_list_no' ];
28
+
29
+ // If the number of lists is less than 1, put it to 1
30
+ if ( $options[ 'list_no' ] < 1 ) { $options[ 'list_no' ] = 1; }
31
+
32
+ $options[ 'embed_cache' ] = $_POST[ 'youtube_embed_embed_cache' ];
33
+ $options[ 'info_cache' ] = $_POST[ 'youtube_embed_info_cache' ];
34
+ $options[ 'transcript_cache' ] = $_POST[ 'youtube_embed_transcript_cache' ];
35
+
36
+ // If an embed cache has been specified and the information cache is less,
37
+ // put it to zero to switch off
38
+ if ( ( $options[ 'embed_cache' ] != 0 ) && ( $options[ 'info_cache' ] <= $options[ 'embed_cache' ] ) ) {
39
+ $options[ 'info_cache' ] = 0;
40
+ }
41
+
42
+ $options[ 'fetch_title' ] = $_POST[ 'youtube_embed_fetch_title' ];
43
+ $options[ 'alt_profile' ] = $_POST[ 'youtube_embed_alt_profile' ];
44
+ $options[ 'alt_profile2' ] = $_POST[ 'youtube_embed_alt_profile2' ];
45
+ $options[ 'bracket' ] = $_POST[ 'youtube_embed_bracket' ];
46
+ $options[ 'alt' ] = $_POST[ 'youtube_embed_alt' ];
47
+ $options[ 'other_profile' ] = $_POST[ 'youtube_embed_other_profile' ];
48
+ $options[ 'url_profile' ] = $_POST[ 'youtube_embed_url_profile' ];
49
+ $options[ 'comments' ] = $_POST[ 'youtube_embed_comments' ];
50
+ $options[ 'comments_profile' ] = $_POST[ 'youtube_embed_comments_profile' ];
51
+ $options[ 'metadata' ] = $_POST[ 'youtube_embed_metadata' ];
52
+ $options[ 'feed' ] = $_POST[ 'youtube_embed_feed' ];
53
+
54
+ // Update the options
55
+ update_option( 'youtube_embed_general', $options );
56
+
57
+ // Update the alternative shortcodes
58
+ $shortcode[ 1 ] = $_POST[ 'youtube_embed_shortcode' ];
59
+ $shortcode[ 2 ] = $_POST[ 'youtube_embed_shortcode2' ];
60
+ update_option( 'youtube_embed_shortcode', $shortcode );
61
+
62
+ // Update the URL override
63
+ update_option( 'youtube_embed_url', $_POST[ 'youtube_embed_url' ] );
64
+
65
+ echo '<div class="updated fade"><p><strong>' . __( 'Settings Saved.' ) . "</strong></p></div>\n";
66
+ }
67
+
68
+ // Get options
69
+ $options = ye_set_general_defaults();
70
+ $shortcode = ye_set_shortcode_option();
71
+ $url = ye_set_url_option();
72
+ ?>
73
+
74
+ <p><?php _e( 'These are the general settings for Artiss YouTube Embed. Please select <a href="http://www.artiss.co.uk/wp-admin/admin.php?page=youtube-embed-profiles">Profiles</a> for default embedding settings.' ); ?></p>
75
+
76
+ <form method="post" action="<?php echo get_bloginfo( 'wpurl' ).'/wp-admin/admin.php?page=youtube-embed-general' ?>">
77
+
78
+ <span class="yt_heading"><?php _e( 'Embedding' ); ?></span>
79
+
80
+ <table class="form-table">
81
+ <tr>
82
+ <th scope="row"><?php _e( 'Add Metadata' ); ?></th>
83
+ <td><input type="checkbox" name="youtube_embed_metadata" value="1"<?php if ( $options[ 'metadata' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Allow rich metadata to be added to code. <a href="http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-metadata">Learn more</a>' ); ?></span></td>
84
+ </tr>
85
+
86
+ <tr>
87
+ <th scope="row"><?php _e( 'URL Embedding' ); ?></th>
88
+ <td><input type="checkbox" name="youtube_embed_url" value="1"<?php if ( $url == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Override built-in WP processing of YouTube URLs. <a href="http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-urls">Learn more</a>' ); ?></span></td>
89
+ </tr>
90
+
91
+ <tr>
92
+ <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Profile to use' ); ?></th>
93
+ <td><select name="youtube_embed_url_profile">
94
+ <?php ye_generate_profile_list( $options[ 'url_profile' ], $options[ 'profile_no' ] ) ?>
95
+ </select></td>
96
+ </tr>
97
+
98
+ <tr>
99
+ <th scope="row"><?php _e( 'Comment Embedding' ); ?></th>
100
+ <td><input type="checkbox" name="youtube_embed_comments" value="1"<?php if ( $options[ 'comments' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Allow YouTube URLs in comments - will display as embedded videos. <a href="http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-comments">Learn more</a>' ); ?></span></td>
101
+ </tr>
102
+
103
+ <tr>
104
+ <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Profile to use' ); ?></th>
105
+ <td><select name="youtube_embed_comments_profile">
106
+ <?php ye_generate_profile_list( $options[ 'comments_profile' ], $options[ 'profile_no' ] ) ?>
107
+ </select></td>
108
+ </tr>
109
+
110
+ <tr>
111
+ <th scope="row"><?php _e( 'Feed' ); ?></th>
112
+ <td><select name="youtube_embed_feed">
113
+ <option value="t"<?php if ( $options[ 'feed' ] == "t" ) { echo " selected='selected'"; } ?>><?php _e ( 'Text link' ); ?></option>
114
+ <option value="v"<?php if ( $options[ 'feed' ] == "v" ) { echo " selected='selected'"; } ?>><?php _e ( 'Thumbnail' ); ?></option>
115
+ <option value="b"<?php if ( $options[ 'feed' ] == "b" ) { echo " selected='selected'"; } ?>><?php _e ( 'Thumbnail &amp; Text Link' ); ?></option>
116
+ </select>&nbsp;<span class="description"><?php _e( 'Videos cannot be embedded in feeds. Select how you wish them to be shown instead.' ); ?></span></td>
117
+ </tr>
118
+ </table>
119
+
120
+ <br/><span class="yt_heading"><?php _e( 'Alternative Shortcodes' ); ?></span><br/><br/>Specify up to 2 alternative shortcodes to compliment the standard <code>[youtube]</code> shortcode.
121
+
122
+ <table class="form-table">
123
+ <tr>
124
+ <th scope="row"><?php _e( 'Alternative Shortcode 1' ); ?></th>
125
+ <td><input type="text" size="30" name="youtube_embed_shortcode" value="<?php echo $shortcode[ 1 ]; ?>"/></td>
126
+ </tr>
127
+
128
+ <tr>
129
+ <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Profile to use' ); ?></th>
130
+ <td><select name="youtube_embed_alt_profile">
131
+ <?php ye_generate_profile_list( $options[ 'alt_profile' ], $options[ 'profile_no' ] ) ?>
132
+ </select></td>
133
+ </tr>
134
+
135
+ <tr>
136
+ <th scope="row"><?php _e( 'Alternative Shortcode 2' ); ?></th>
137
+ <td><input type="text" size="30" name="youtube_embed_shortcode2" value="<?php echo $shortcode[ 2 ]; ?>"/></td>
138
+ </tr>
139
+
140
+ <tr>
141
+ <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Profile to use' ); ?></th>
142
+ <td><select name="youtube_embed_alt_profile2">
143
+ <?php ye_generate_profile_list( $options[ 'alt_profile2' ], $options[ 'profile_no' ] ) ?>
144
+ </select></td>
145
+ </tr>
146
+ </table>
147
+
148
+ <br/><span class="yt_heading"><?php _e( 'Migration' ); ?></span><br/><br/>Switch on compatibility with other embedding plugins. For more details on migrating from another plugin, please <a href="http://www.artiss.co.uk/artiss-youtube-embed/compatibility">click here</a>.
149
+
150
+ <table class="form-table">
151
+ <tr>
152
+ <th scope="row"><?php _e( 'Bracket Embedding' ); ?></th>
153
+ <td><input type="checkbox" name="youtube_embed_bracket" value="1"<?php if ( $options[ 'bracket' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Allow embedding using URLs within brackets. Activating impacts performance' ); ?></span></td>
154
+ </tr>
155
+
156
+ <tr>
157
+ <th scope="row"><?php _e( 'Alternative Embedding' ); ?></th>
158
+ <td><input type="checkbox" name="youtube_embed_alt" value="1"<?php if ( $options[ 'alt' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Allow all other types of embedding. Activating impacts performance' ); ?></span></td>
159
+ </tr>
160
+
161
+ <tr>
162
+ <th scope="row">&nbsp;&nbsp;&nbsp;&nbsp;<?php _e( 'Profile to use' ); ?></th>
163
+ <td><select name="youtube_embed_other_profile">
164
+ <?php ye_generate_profile_list( $options[ 'other_profile' ], $options[ 'profile_no' ] ) ?>
165
+ </select>&nbsp;<span class="description"><?php _e( 'For above 2 options' ); ?></span></td>
166
+ </tr>
167
+ </table>
168
+
169
+ <br/><span class="yt_heading"><?php _e( 'Admin Options' ); ?></span>
170
+
171
+ <table class="form-table">
172
+ <tr>
173
+ <th scope="row"><?php _e( 'Show YouTube Button' ); ?></th>
174
+ <td><input type="checkbox" name="youtube_embed_editor_button" value="1"<?php if ( $options[ 'editor_button' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Show the YouTube button on the post editor' ); ?></span></td>
175
+ </tr>
176
+
177
+ <tr>
178
+ <th scope="row"><?php _e( 'Add to Admin Bar' ); ?></th>
179
+ <td><input type="checkbox" name="youtube_embed_admin_bar" value="1"<?php if ( $options[ 'admin_bar' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Add link to options screen to Admin Bar' ); ?></span></td>
180
+ </tr>
181
+ </table>
182
+
183
+ <br/><span class="yt_heading"><?php _e( 'Profile &amp; List Sizes' ); ?></span>
184
+
185
+ <table class="form-table">
186
+ <tr>
187
+ <th scope="row"><?php _e( 'Number of Profiles' ); ?></th>
188
+ <td><input type="text" size="2" maxlength="2" name="youtube_embed_profile_no" value="<?php echo $options[ 'profile_no' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'Maximum number of profiles' ); ?></span></td>
189
+ </tr>
190
+
191
+ <tr>
192
+ <th scope="row"><?php _e( 'Number of Lists' ); ?></th>
193
+ <td><input type="text" size="2" maxlength="2" name="youtube_embed_list_no" value="<?php echo $options[ 'list_no' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'Maximum number of lists' ); ?></span></td>
194
+ </tr>
195
+ </table>
196
+
197
+ <br/><span class="yt_heading"><?php _e( 'Performance' ); ?></span>
198
+
199
+ <table class="form-table">
200
+ <tr>
201
+ <th scope="row"><?php _e( 'Embed Cache' ); ?></th>
202
+ <td><input type="text" size="3" maxlength="3" name="youtube_embed_embed_cache" value="<?php echo $options[ 'embed_cache' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'How many hours to retain embed output. 0 to switch off' ); ?></span></td>
203
+ </tr>
204
+
205
+ <tr>
206
+ <th scope="row"><?php _e( 'Video Information Cache' ); ?></th>
207
+ <td><input type="text" size="3" maxlength="3" name="youtube_embed_info_cache" value="<?php echo $options[ 'info_cache' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'How many hours to retain video information, including it\'s validity. 0 to switch off' ); ?></span></td>
208
+ </tr>
209
+
210
+ <tr>
211
+ <th scope="row"><?php _e( 'Transcript Cache' ); ?></th>
212
+ <td><input type="text" size="3" maxlength="3" name="youtube_embed_transcript_cache" value="<?php echo $options[ 'transcript_cache' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'How many hours to store transcripts for in cache. 0 to switch off' ); ?></span></td>
213
+ </tr>
214
+ </table>
215
+
216
+ <?php wp_nonce_field( 'youtube-embed-general','youtube_embed_general_nonce', true, true ); ?>
217
+
218
+ <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Settings' ); ?>"/></p>
219
+
220
+ </form>
221
+
222
+ </div>
includes/options-lists.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Lists Options Page
4
+ *
5
+ * Screen for specifying different lists and the video IDs within them
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ */
10
+ ?>
11
+ <div class="wrap">
12
+
13
+ <div class="icon32"><img src="<?php echo WP_PLUGIN_URL; ?>/youtube-embed/images/screen_icon.png" alt="" title="" height="32px" width="32px"/><br /></div>
14
+
15
+ <h2>Artiss YouTube Embed Lists</h2>
16
+
17
+ <?php
18
+ // Set current list number
19
+ if ( isset( $_POST[ 'youtube_embed_list_no' ] ) ) { $list_no = $_POST[ 'youtube_embed_list_no' ]; } else { $list_no = 0; }
20
+ if ( $list_no == '' ) { $list_no = 1; }
21
+ $id_nums = 0;
22
+
23
+ // If options have been updated on screen, update the database
24
+ if ( ( !empty( $_POST[ 'Submit' ] ) ) && ( check_admin_referer( 'youtube-embed-general', 'youtube_embed_general_nonce' ) ) ) {
25
+
26
+ $class = 'updated fade';
27
+ $message = 'Settings Saved.';
28
+ $id_nums = 0;
29
+ $new_id_list = '';
30
+
31
+ if ( ( $_POST[ 'youtube_embed_video_list' ] == '' ) or ( $_POST[ 'youtube_embed_name' ] == '' ) ) {
32
+ $class = 'error';
33
+ $message = 'All fields must be completed.';
34
+ } else {
35
+ $id_array = explode( "\n", $_POST[ 'youtube_embed_video_list' ] );
36
+ $loop = 0;
37
+ $valid = true;
38
+
39
+ // Loop through the video IDs
40
+ while ( $loop < count( $id_array ) ) {
41
+
42
+ // Extract the ID from the provided data
43
+ $id = trim( ye_extract_id( $id_array[ $loop ] ) );
44
+ if ( $id != '' ) {
45
+
46
+ // Validate the video type - store results in an array
47
+ $video_out[ $loop ][ 1 ] = $id;
48
+ $video_info = ye_validate_id( $id, true );
49
+ $type = $video_info[ 'type' ];
50
+ $video_out[ $loop ][ 2 ] = $video_info[ 'title' ];
51
+
52
+ if ( $type == 'p' ) {
53
+ $video_out[ $loop ][ 3 ] = 'This is a playlist';
54
+ $video_out[ $loop ][ 4 ] = '-1';
55
+ $valid = false;
56
+ } else {
57
+
58
+ if ( $type == '' ) {
59
+ $video_out[ $loop ][ 3 ] = 'Invalid video ID';
60
+ $video_out[ $loop ][ 4 ] = '-2';
61
+ $valid = false;
62
+ } else {
63
+ $video_out[ $loop ][ 3 ] = 'Valid video';
64
+ $video_out[ $loop ][ 4 ] = '0';
65
+ }
66
+ }
67
+
68
+ $new_id_list .= $video_out[ $loop ][ 1 ]."\n";
69
+ $id_nums ++;
70
+ }
71
+ $loop ++;
72
+ }
73
+
74
+ // If one or more IDs weren't valid, output an error
75
+ if (!$valid) {
76
+ $class = 'error';
77
+ $message = 'Errors were found with your video list. See the list below for details.';
78
+ }
79
+ }
80
+
81
+ // Update the options
82
+ $options[ 'name' ] = $_POST[ 'youtube_embed_name' ];
83
+
84
+ if ( $new_id_list == '' ) {
85
+ $options[ 'list' ] = $_POST[ 'youtube_embed_video_list' ];
86
+ } else {
87
+ $options[ 'list' ] = substr( $new_id_list, 0, strlen( $new_id_list ) - 1 );
88
+ }
89
+
90
+ if ( substr( $class, 0, 7 ) == 'updated' ) { update_option( 'youtube_embed_list' . $list_no, $options ); }
91
+ echo '<div class="' . $class.'"><p><strong>' . __( $message ) . "</strong></p></div>\n";
92
+ } else {
93
+ $class = '';
94
+ }
95
+
96
+ // Fetch options into an array
97
+ if ( $class != "error" ) { $options = ye_set_list_defaults( $list_no ); }
98
+ $general = ye_set_general_defaults();
99
+ ?>
100
+
101
+ <form method="post" action="<?php echo get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=youtube-embed-lists'; ?>">
102
+
103
+ <span class="alignright">
104
+ <select name="youtube_embed_list_no">
105
+ <?php
106
+ $loop = 1;
107
+ while ( $loop <= $general[ 'list_no' ] ) {
108
+
109
+ $listfiles = get_option( 'youtube_embed_list' . $loop );
110
+ $listname = $listfiles[ 'name' ];
111
+
112
+ if ( $listname == '' ) { $listname = 'List ' . $loop; }
113
+ echo '<option value="' . $loop . '"';
114
+ if ( $list_no == $loop ) { echo " selected='selected'"; }
115
+ echo '>' . __( $listname ) . "</option>\n";
116
+
117
+ $loop ++;
118
+ }
119
+ ?>
120
+ </select>
121
+ <input type="submit" name="List" class="button-secondary" value="<?php _e( 'Change list' ); ?>"/>
122
+ </span><br/>
123
+
124
+ <?php echo __( 'These are the options for list ' . $list_no . '.<br/>Update the name, if required, and specify a list of YouTube video IDs. Use the drop-down on the right hand side to swap between lists.' ); ?>
125
+
126
+ <table class="form-table">
127
+
128
+ <tr>
129
+ <th scope="row"><?php _e( 'List name' ); ?></th><td>
130
+ <input type="text" size="20" maxlength="20" name="youtube_embed_name" value="<?php echo $options[ 'name' ]; ?>"/>
131
+ <?php echo '&nbsp;<span class="description">' . __( 'The name you wish to give this list' ) . '</span>'; ?>
132
+ </td></tr>
133
+
134
+ <tr>
135
+ <th scope="row"><?php _e( 'Video IDs (one per line)' ); ?></th><td>
136
+ <textarea name="youtube_embed_video_list" id="youtube_embed_video_list" cols="12" rows="10" class="widefat"><?php echo $options[ 'list' ]; ?></textarea>
137
+ </td></tr>
138
+ </table>
139
+
140
+ <?php wp_nonce_field( 'youtube-embed-general','youtube_embed_general_nonce', true, true ); ?>
141
+
142
+ <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Settings' ); ?>"/></p>
143
+
144
+ </form>
145
+
146
+ <?php
147
+
148
+ // If video IDs exist display them on screen along with their status'
149
+ if ( $id_nums > 0 ) {
150
+
151
+ echo "<table class=\"widefat\">\n<thead>\n\t<tr>\n\t\t<th>Video ID</th>\n\t\t<th>Video Title</th>\n\t\t<th>Status</th>\n\t</tr>\n</thead>\n<tbody>\n";
152
+ $loop = 0;
153
+
154
+ while ( $loop < $id_nums ) {
155
+
156
+ echo "\t<tr>\n\t\t<td>" . $video_out[ $loop ][ 1 ] . "</td>\n";
157
+ echo "\t\t<td>" . $video_out[ $loop ][ 2 ] . "</td>\n";
158
+ echo "\t\t<td style=\"";
159
+
160
+ if ( $video_out[ $loop ][ 4 ] != 0 ) {
161
+ echo 'font-weight: bold; color: #f00;';
162
+ }
163
+
164
+ echo '"><img src="' . WP_PLUGIN_URL . '/youtube-embed/images/';
165
+ if ( $video_out[ $loop ][ 4 ] == 0 ) {
166
+ echo 'tick.png" alt="The video ID is valid" title="The video ID is valid" ';
167
+ } else {
168
+ echo 'cross.png" alt="The video ID is invalid" title="The video ID is invalid" ';
169
+ }
170
+
171
+ echo "height=\"16px\" width=\"16px\"/>&nbsp;" . $video_out[ $loop ][ 3 ] . "</td>\n\t</tr>\n";
172
+ $loop ++;
173
+ }
174
+ echo "</tbody>\n</table>\n";
175
+ }
176
+ ?>
177
+
178
+ </div>
includes/options-profiles.php ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Profiles Options Page
4
+ *
5
+ * Screen for specifying different profiles and settings the options for each
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ */
10
+ ?>
11
+ <div class="wrap">
12
+
13
+ <div class="icon32"><img src="<?php echo WP_PLUGIN_URL; ?>/youtube-embed/images/screen_icon.png" alt="" title="" height="32px" width="32px"/><br /></div>
14
+
15
+ <h2>Artiss YouTube Embed Profiles</h2>
16
+
17
+ <?php
18
+ // Set current profile number
19
+ if ( isset( $_POST[ 'youtube_embed_profile_no' ] ) ) { $profile_no = $_POST[ 'youtube_embed_profile_no' ]; } else { $profile_no = 0; }
20
+ if ( $profile_no == '' ) { $profile_no = 0; }
21
+
22
+ // If options have been updated on screen, update the database
23
+ if ( ( !empty( $_POST[ 'Submit' ] ) ) && ( check_admin_referer( 'youtube-embed-profile' , 'youtube_embed_profile_nonce' ) ) ) {
24
+
25
+ $options[ 'name' ] = $_POST[ 'youtube_embed_name' ];
26
+ $options[ 'type' ] = $_POST[ 'youtube_embed_type' ];
27
+ $options[ 'playlist' ] = $_POST[ 'youtube_embed_playlist' ];
28
+ $options[ 'width' ] = $_POST[ 'youtube_embed_width' ];
29
+ $options[ 'height' ] = $_POST[ 'youtube_embed_height' ];
30
+
31
+ $options[ 'template' ] = htmlspecialchars_decode( $_POST[ 'youtube_embed_template' ] );
32
+ if ( strpos( $options[ 'template' ], '%video%' ) === false ) { $options[ 'template' ] = '%video%'; }
33
+
34
+ $options[ 'fullscreen' ] = $_POST[ 'youtube_embed_fullscreen' ];
35
+ $options[ 'autoplay'] = $_POST[ 'youtube_embed_autoplay' ];
36
+ $options[ 'loop'] = $_POST[ 'youtube_embed_loop' ];
37
+ $options[ 'cc'] = $_POST[ 'youtube_embed_cc' ];
38
+ $options[ 'annotation'] = $_POST[ 'youtube_embed_annotation' ];
39
+ $options[ 'related'] = $_POST[ 'youtube_embed_related' ];
40
+ $options[ 'info'] = $_POST[ 'youtube_embed_info' ];
41
+ $options[ 'link'] = $_POST[ 'youtube_embed_link' ];
42
+ $options[ 'react'] = $_POST[ 'youtube_embed_react' ];
43
+ $options[ 'sweetspot'] = $_POST[ 'youtube_embed_sweetspot' ];
44
+ $options[ 'disablekb'] = $_POST[ 'youtube_embed_disablekb' ];
45
+ $options[ 'autohide'] = $_POST[ 'youtube_embed_autohide' ];
46
+ $options[ 'controls'] = $_POST[ 'youtube_embed_controls' ];
47
+ $options[ 'fallback'] = $_POST[ 'youtube_embed_fallback' ];
48
+ $options[ 'wmode'] = $_POST[ 'youtube_embed_wmode' ];
49
+ $options[ 'shadow'] = $_POST[ 'youtube_embed_shadow' ];
50
+ $options[ 'audio'] = $_POST[ 'youtube_embed_audio' ];
51
+ $options[ 'hd'] = $_POST[ 'youtube_embed_hd' ];
52
+
53
+ $default_size = $_POST[ 'youtube_embed_size' ];
54
+
55
+ if ( $default_size !== '' ) {
56
+ $options[ 'width' ] = ltrim( substr( $default_size, 0, 4 ), '0' );
57
+ $options[ 'height'] = ltrim( substr( $default_size, -4, 4 ), '0' );
58
+ }
59
+
60
+ update_option( 'youtube_embed_profile' . $profile_no, $options );
61
+ echo '<div class="updated fade"><p><strong>' . __( $options[ 'name' ].' Profile Saved.' ) . "</strong></p></div>\n";
62
+ } else {
63
+ $default_size = '';
64
+ }
65
+
66
+ // Video option button has been pressed
67
+ if ( !empty( $_POST[ 'Video' ] ) ) { $video_type = $_POST[ 'youtube_embed_video_type' ]; } else { $video_type = 'd'; }
68
+
69
+ // Fetch options into an array
70
+ $options = ye_set_profile_defaults( $profile_no );
71
+ $general = ye_set_general_defaults();
72
+ ?>
73
+ <form method="post" action="<?php echo get_bloginfo( 'wpurl' ) . '/wp-admin/admin.php?page=youtube-embed-profiles' ?>">
74
+
75
+ <span class="alignright">
76
+ <select name="youtube_embed_profile_no">
77
+ <?php ye_generate_profile_list( $profile_no, $general[ 'profile_no' ] ) ?>
78
+ </select>
79
+ <input type="submit" name="Profile" class="button-secondary" value="<?php _e('Change profile'); ?>"/>
80
+ </span><br/>
81
+
82
+ <?php
83
+ _e( 'These are the options for ' );
84
+ if ( $profile_no == "0" ) { _e( 'the default profile.' ); } else { _e( 'profile ' . $profile_no . "." ); }
85
+ _e( '<br/>Use the drop-down on the right hand side to swap between profiles.' );
86
+ ?>
87
+
88
+ <table class="form-table">
89
+
90
+ <tr>
91
+ <th scope="row"><?php _e( 'Profile name' ); ?></th><td>
92
+ <input type="text" size="20" maxlength="20" name="youtube_embed_name" value="<?php echo $options[ 'name' ]; ?>"<?php if ( $profile_no == 0 ) { echo ' readonly="readonly"'; } ?>/>
93
+ <?php if ( $profile_no != 0 ) { echo '&nbsp;<span class="description">' . __( 'The name you wish to give this profile' ) . '</span>'; } ?>
94
+ </td></tr>
95
+
96
+ <tr valign="top">
97
+ <th scope="row"><?php _e( 'Video Embed Type' ); ?></th>
98
+ <td><span class="description"><?php _e( 'The type of player to use for videos.' ); ?></span><br/>
99
+ <input type="radio" name="youtube_embed_type" value="v"<?php if ( $options[ 'type' ] == "v" ) { echo ' checked="checked"'; } ?>/><?php _e( '&nbsp;IFRAME' ); ?><span class="description"><?php _e( '&nbsp;Uses HTML5, where available. This is the current YouTube default..' ); ?></span><br/>
100
+ <input type="radio" name="youtube_embed_type" value="p"<?php if ( $options[ 'type' ] == "p" ) { echo ' checked="checked"'; } ?>/><?php _e( '&nbsp;OBJECT' ); ?><span class="description"><?php _e( '&nbsp;Use the AS3 Flash player.' ); ?></span><br/>
101
+ <input type="radio" name="youtube_embed_type" value="m"<?php if ( $options[ 'type' ] == "m" ) { echo ' checked="checked"'; } ?>/><?php _e( '&nbsp;EmbedPlus' ); ?><span class="description"><?php _e( '&nbsp;Use <a href="http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-embedplus">EmbedPlus</a>, if Flash is available.' ); ?></span>
102
+ </td>
103
+ </tr>
104
+
105
+ <tr valign="top">
106
+ <th scope="row"><?php _e( 'Playlist Embed Type' ); ?></th>
107
+ <td><span class="description"><?php _e( 'The type of player to use when showing playlists.' ); ?></span><br/>
108
+ <input type="radio" name="youtube_embed_playlist" value="v"<?php if ( $options[ 'playlist' ] == "v" ) { echo ' checked="checked"'; } ?>/><?php _e( '&nbsp;IFRAME' ); ?><br/>
109
+ <input type="radio" name="youtube_embed_playlist" value="o"<?php if ( $options[ 'playlist' ] == "o" ) { echo ' checked="checked"'; } ?>/><?php _e( '&nbsp;OBJECT' ); ?><br/>
110
+ </td>
111
+ </tr>
112
+ </table>
113
+
114
+ <br/><span class="yt_heading"><?php _e( 'All Embed Type Options' ); ?></span>
115
+
116
+ <table class="form-table">
117
+
118
+ <tr>
119
+ <th scope="row"><?php _e( 'Template' ); ?></th>
120
+ <td><input type="text" size="40" name="youtube_embed_template" value="<?php echo htmlspecialchars( $options[ 'template' ] ); ?>"/>&nbsp;<span class="description">Wrapper for video output. Must include <code>%video%</code> tag to show video position</span></td>
121
+ </tr>
122
+ </table>
123
+
124
+ <table class="form-table ytbox_grey">
125
+ <tr>
126
+ <th scope="row"><?php _e( 'Video size' ); ?></th>
127
+ <td><input type="text" size="3" maxlength="3" name="youtube_embed_width" value="<?php echo $options[ 'width' ]; ?>"/>&nbsp;x&nbsp;<input type="text" size="3" maxlength="3" name="youtube_embed_height" value="<?php echo $options[ 'height' ]; ?>"/>&nbsp;<span class="description"><?php _e( 'The width x height of the video, in pixels' ); ?></span></td>
128
+ </tr>
129
+
130
+ <tr valign="top">
131
+ <th scope="row"><?php _e( 'Default Sizes' ); ?></th>
132
+ <td><select name="youtube_embed_size">
133
+ <option value=""<?php if ( $default_size == '' ) { echo " selected='selected'"; } ?>><?php _e( 'Use above sizes' ); ?></option>
134
+ <option value="04800385"<?php if ( $default_size == "04800385" ) { echo " selected='selected'"; } ?>><?php _e ( '480x385 4:3' ); ?></option>
135
+ <option value="05600340"<?php if ( $default_size == "05600340" ) { echo " selected='selected'"; } ?>><?php _e( '560x340 16:9' ); ?></option>
136
+ <option value="06400385"<?php if ( $default_size == "06400385" ) { echo " selected='selected'"; } ?>><?php _e( '640x385 16:9' ); ?></option>
137
+ <option value="08530505"<?php if ( $default_size == "08530505" ) { echo " selected='selected'"; } ?>><?php _e( '853x505 16:9' ); ?></option>
138
+ <option value="12800745"<?php if ( $default_size == "12800745" ) { echo " selected='selected'"; } ?>><?php _e( '1280x745 16:9' ); ?></option>
139
+ </select>&nbsp;<span class="description"><?php _e( 'Select one of these default sizes to override the above video sizes' ); ?></span></td>
140
+ </tr>
141
+ </table>
142
+
143
+ <table class="form-table">
144
+
145
+ <tr>
146
+ <th scope="row"><?php _e( 'Audio Only' ); ?></th>
147
+ <td><input type="checkbox" name="youtube_embed_audio" value="1"<?php if ( $options[ 'audio' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Only show the toolbar for audio only playback' ); ?></span></td>
148
+ </tr>
149
+
150
+ <tr>
151
+ <th scope="row"><?php _e( 'Drop Shadow Height' ); ?></th>
152
+ <td><input type="text" size="2" name="youtube_embed_shadow" value="<?php echo $options[ 'shadow' ]; ?>"/>px&nbsp;<span class="description">Number of pixels high for drop-shadow. Put to 0 to switch off.</span></td>
153
+ </tr>
154
+ </table>
155
+
156
+ <br/><span class="yt_heading"><?php _e( 'Non-EmbedPlus Options' ); ?></span>
157
+ <br/><br/>The following options are not supported by EmbedPlus.
158
+
159
+ <table class="form-table">
160
+
161
+ <tr>
162
+ <th scope="row"><?php _e( 'Auto hide' ); ?></th>
163
+ <td><select name="youtube_embed_autohide">
164
+ <option value="0"<?php if ( $options[ 'autohide' ] == "0" ) { echo " selected='selected'"; } ?>><?php _e( 'Controls &amp; progress bar remain visible' ); ?></option>
165
+ <option value="1"<?php if ( $options[ 'autohide' ] == "1" ) { echo " selected='selected'"; } ?>><?php _e( 'Controls &amp; progress bar fade out' ); ?></option>
166
+ <option value="2"<?php if ( $options[ 'autohide' ] == "2" ) { echo " selected='selected'"; } ?>><?php _e( 'Progress bar fades' ); ?></option>
167
+ </select>&nbsp;<span class="description"><?php _e( 'Video controls will automatically hide after a video begins playing' ); ?></span></td>
168
+ </tr>
169
+
170
+ <tr>
171
+ <th scope="row"><?php _e( 'Autoplay' ); ?></th>
172
+ <td><input type="checkbox" name="youtube_embed_autoplay" value="1"<?php if ( $options[ 'autoplay' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'The video will start playing when the player loads' ); ?></span></td>
173
+ </tr>
174
+
175
+ <tr>
176
+ <th scope="row"><?php _e( 'Controls' ); ?></th>
177
+ <td><input type="checkbox" name="youtube_embed_controls" value="1"<?php if ( $options[ 'controls' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Video player controls will display' ); ?></span></td>
178
+ </tr>
179
+
180
+ <tr>
181
+ <th scope="row"><?php _e( 'Loop Video' ); ?></th>
182
+ <td><input type="checkbox" name="youtube_embed_loop" value="1"<?php if ( $options[ 'loop' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Play the initial video again and again. In the case of a playlist, this will play the entire playlist and then start again at the first video' ); ?></span></td>
183
+ </tr>
184
+ </table>
185
+
186
+ <br/><span class="yt_heading"><?php _e( 'Non-EmbedPlus &amp; HTML5 Options' ); ?></span>
187
+ <br/><br/>The following options are not supported if using EmbedPlus or if the IFRAME player uses HTML5.
188
+
189
+ <table class="form-table">
190
+ <tr>
191
+ <th scope="row"><?php _e( 'Annotations' ); ?></th>
192
+ <td><input type="checkbox" name="youtube_embed_annotation" value="1"<?php if ( $options[ 'annotation' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Video annotations are shown by default' ); ?></span></td>
193
+ </tr>
194
+
195
+ <tr>
196
+ <th scope="row"><?php _e( 'Closed Captions' ); ?></th>
197
+ <td><input type="checkbox" name="youtube_embed_cc" value="1"<?php if ( $options[ 'cc' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Show closed captions (subtitles) by default, even if the user has turned captions off' ); ?></span></td>
198
+ </tr>
199
+
200
+ <tr>
201
+ <th scope="row"><?php _e( 'Disable Keyboard' ); ?></th>
202
+ <td><input type="checkbox" name="youtube_embed_disablekb" value="1"<?php if ( $options[ 'disablekb' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Disable the player keyboard controls' ); ?></span></td>
203
+ </tr>
204
+
205
+ <tr>
206
+ <th scope="row"><?php _e( 'Fullscreen' ); ?></th>
207
+ <td><input type="checkbox" name="youtube_embed_fullscreen" value="1"<?php if ( $options[ 'fullscreen' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'A button will allow the viewer to watch the video fullscreen' ); ?></span></td>
208
+ </tr>
209
+
210
+ <tr>
211
+ <th scope="row"><?php _e( 'Information' ); ?></th>
212
+ <td><input type="checkbox" name="youtube_embed_info" value="1"<?php if ( $options[ 'info' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Display the video title and uploader before the video starts' ); ?></span></td>
213
+ </tr>
214
+
215
+ <tr>
216
+ <th scope="row"><?php _e( 'Link to YouTube' ); ?></th>
217
+ <td><input type="checkbox" name="youtube_embed_link" value="1"<?php if ( $options[ 'link' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Video links back to YouTube when clicked' ); ?></span></td>
218
+ </tr>
219
+
220
+ <tr>
221
+ <th scope="row"><?php _e( 'Related Videos' ); ?></th>
222
+ <td><input type="checkbox" name="youtube_embed_related" value="1"<?php if ( $options[ 'related' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Load related videos once playback starts. Also toggles the search option.' ); ?></span></td>
223
+ </tr>
224
+ </table>
225
+
226
+ <br/><span class="yt_heading"><?php _e( 'Non-IFRAME Options' ); ?></span>
227
+ <br/><br/>The following options are not supported if using the IFRAME player.
228
+
229
+ <table class="form-table">
230
+ <tr valign="top">
231
+ <th scope="row"><?php _e( 'Window Mode' ); ?></th>
232
+ <td><select name="youtube_embed_wmode">
233
+ <option value="opaque"<?php if ( $options[ 'wmode' ] == "opaque" ) { echo " selected='selected'"; } ?>><?php _e( 'Opaque' ); ?></option>
234
+ <option value="transparent"<?php if ( $options[ 'wmode' ] == "transparent" ) { echo " selected='selected'"; } ?>><?php _e( 'Transparent' ); ?></option>
235
+ <option value="window"<?php if ( $options[ 'wmode' ] == "window" ) { echo " selected='selected'"; } ?>><?php _e( 'Window' ); ?></option>
236
+ </select><span class="description"><?php _e( 'Sets the Window Mode property of the Flash movie for transparency, layering, and positioning in the browser. <a href="http://www.communitymx.com/content/article.cfm?cid=e5141">Learn more</a>.' ); ?></span></td>
237
+ </tr>
238
+ </table>
239
+
240
+ <br/><span class="yt_heading"><?php _e( 'EmbedPlus Options' ); ?></span><span class="description" style="float: right"><?php _e( '<a href="http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-embedplus">Learn more about EmbedPlus</a>' ); ?></span>
241
+
242
+ <table class="form-table">
243
+ <tr valign="top">
244
+ <th scope="row"><?php _e( 'Fallback Embed Type' ); ?></th>
245
+ <td><span class="description"><?php _e( 'The type of player to use if Flash is not available and EmbedPlus cannot be used.' ); ?></span><br/>
246
+ <input type="radio" name="youtube_embed_fallback" value="v"<?php if ( $options[ 'fallback' ] == "v" ) { echo ' checked="checked"'; } ?>/><?php _e( '&nbsp;IFRAME' ); ?><br/>
247
+ <input type="radio" name="youtube_embed_fallback" value="p"<?php if ( $options[ 'fallback' ] == "p" ) { echo ' checked="checked"'; } ?>/><?php _e( '&nbsp;OBJECT' ); ?></td>
248
+ </tr>
249
+
250
+ <tr>
251
+ <th scope="row"><?php _e( 'Play HD' ); ?></th>
252
+ <td><input type="checkbox" name="youtube_embed_hd" value="1"<?php if ( $options[ 'hd' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Play the video in HD if possible' ); ?></span></td>
253
+ </tr>
254
+
255
+ <tr>
256
+ <th scope="row"><?php _e( 'Real-time Reactions' ); ?></th>
257
+ <td><input type="checkbox" name="youtube_embed_react" value="1"<?php if ( $options[ 'react' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Show the Real-time Reactions button' ); ?></span></td>
258
+ </tr>
259
+
260
+ <tr>
261
+ <th scope="row"><?php _e( 'Sweet Spots' ); ?></th>
262
+ <td><input type="checkbox" name="youtube_embed_sweetspot" value="1"<?php if ( $options[ 'sweetspot' ] == "1" ) { echo ' checked="checked"'; } ?>/>&nbsp;<span class="description"><?php _e( 'Find sweet spots for the next and previous buttons' ); ?></span></td>
263
+ </tr>
264
+ </table>
265
+
266
+ <?php wp_nonce_field( 'youtube-embed-profile', 'youtube_embed_profile_nonce', true, true ); ?>
267
+
268
+ <p class="submit"><input type="submit" name="Submit" class="button-primary" value="<?php _e( 'Save Settings' ); ?>"/></p>
269
+
270
+ </form>
271
+
272
+ <a href="#" name="video"></a>
273
+ <form method="post" action="<?php echo get_bloginfo( 'wpurl' ).'/wp-admin/admin.php?page=youtube-embed-profiles#video' ?>">
274
+ <div class="ytbox_grey">
275
+ <h3><?php _e( 'YouTube Video Sample' ); ?></h3>
276
+ <p><?php _e( 'This uses the above settings, once they have been saved. <b>Would you like this to be your video? If so, <a href="http://www.artiss.co.uk/contact">contact me</a>!</b>' ); ?></p>
277
+ <p><?php _e( 'Use the drop-down below to change which parameters the video uses - press the Change Video button to update it.' ); ?></p>
278
+ <p><select name="youtube_embed_video_type">
279
+ <option value="d"<?php if ( $video_type == "d" ) { echo " selected='selected'"; } ?>><?php _e( 'Standard' ); ?></option>
280
+ <option value="p"<?php if ( $video_type == "p" ) { echo " selected='selected'"; } ?>><?php _e( 'EmbedPlus' ); ?></option>
281
+ <option value="3"<?php if ( $video_type == "3" ) { echo " selected='selected'"; } ?>><?php _e( '3D' ); ?></option>
282
+ <option value="l"<?php if ( $video_type == "l" ) { echo " selected='selected'"; } ?>><?php _e( 'Playlist' ); ?></option>
283
+ </select>
284
+ <?php wp_nonce_field( 'youtube-embed-profile', 'youtube_embed_profile_nonce', true, true ); ?>
285
+ <input type="submit" name="Video" class="button-secondary" value="<?php _e( 'Change video' ); ?>"/></p>
286
+
287
+ <p><?php
288
+ if ( $video_type == "d" ) { $id = 'TJJJaDMpCn0'; $type = ''; }
289
+ if ( $video_type == "p" ) { $id = 'YVvn8dpSAt0'; $type = 'm'; }
290
+ if ( $video_type == "3" ) { $id = 'NR5UoBY87GM'; $type = ''; ; }
291
+ if ( $video_type == "l" ) { $id = '095393D5B42B2266'; $type = ''; }
292
+ echo ye_generate_youtube_code( $id, $type, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', $profile_no );
293
+ ?></p>
294
+ </div>
295
+
296
+ </form>
297
+
298
+ </div>
includes/options-widgets.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Set default options
3
+ $default = array( 'titles' => 'YouTube', 'id' => '', 'type' => 'v', 'width' => '320', 'height' => '240', 'fullscreen' => '', 'related' => '', 'autoplay' => '', 'loop' => '', 'start' => '', 'info' => '1', 'annotation' => '1', 'cc' => '', 'link' => '1', 'react' => '1', 'stop' => '', 'sweetspot' => '1', 'disablekb' => '', 'autohide' => '2', 'controls' => '1', 'profile' => '0', 'list' => '', 'template' => '%video%', 'hd' => '1' );
4
+ $instance = wp_parse_args( ( array ) $instance, $default );
5
+ $general = ye_set_general_defaults();
6
+
7
+ // Title field
8
+ $field_id = $this -> get_field_id( 'titles' );
9
+ $field_name = $this -> get_field_name( 'titles' );
10
+ echo "\r\n" . '<p><label for="' . $field_id . '">' . __( 'Title' ) . ': </label><input type="text" class="widefat" id="' . $field_id . '" name="' . $field_name . '" value="' . attribute_escape( $instance[ 'titles' ] ).'" /></p>';
11
+
12
+ // Video ID field
13
+ $field_id = $this -> get_field_id( 'id' );
14
+ $field_name = $this -> get_field_name( 'id' );
15
+ echo "\r\n" . '<p><label for="' . $field_id . '">' . __( 'Video URL, ID or List name' ) . ': </label><input type="text" class="widefat" id="' . $field_id . '" name="' . $field_name . '" value="' . attribute_escape( $instance[ 'id' ] ) . '" /></p>';
16
+
17
+ // Profile field
18
+ $field_id = $this -> get_field_id( 'profile' );
19
+ $field_name = $this -> get_field_name( 'profile' );
20
+ echo "\r\n" . '<p><label for="' . $field_id . '">' . __( 'Profile' ) . ': </label><select name="' . $field_name . '" class="widefat" id="' . $field_id . '">';
21
+ ye_generate_profile_list( attribute_escape( $instance[ 'profile' ] ), $general[ 'profile_no' ] );
22
+ echo '</select></p>';
23
+
24
+ // Embed type field
25
+ $field_id = $this -> get_field_id( 'type' );
26
+ $field_name = $this -> get_field_name( 'type' );
27
+ echo "\r\n" . '<p><label for="' . $field_id . '">' . __( 'Embed Type' ) . ': </label><select name="' . $field_name . '" class="widefat" id="' . $field_id . '"><option value="v"';
28
+ if ( attribute_escape( $instance[ 'type' ] ) == 'v' ) { echo " selected='selected'"; }
29
+ echo '>' . __( 'IFRAME' ) . '</option><option value="p"';
30
+ if ( attribute_escape( $instance[ 'type' ] ) == 'p' ) { echo " selected='selected'"; }
31
+ echo '>' . __( 'OBJECT' ) . '</option><option value="m"';
32
+ if ( attribute_escape( $instance[ 'type' ] ) == 'm' ) { echo " selected='selected'"; }
33
+ echo '>' . __( 'EmbedPlus' ) . '</option></select></p>';
34
+
35
+ // Template
36
+ $field_id = $this -> get_field_id( 'template' );
37
+ $field_name = $this -> get_field_name( 'template' );
38
+ echo "\r\n" . '<p><label for="' . $field_id . '">'.__( 'Template' ).': </label><input type="text" class="widefat" id="' . $field_id . '" name="' . $field_name . '" value="' . attribute_escape( $instance[ 'template' ] ) . '" /></p>';
39
+
40
+ // Size fields
41
+ $field_id = $this -> get_field_id( 'width' );
42
+ $field_name = $this -> get_field_name( 'width' );
43
+ echo "\r\n" . '<p><label for="' . $field_id . '">' . __( 'Size' ) . ': </label><input type="text" size="3" maxlength="3" id="' . $field_id . '" name="' . $field_name . '" value="' . attribute_escape( $instance[ 'width' ] ) . '" />&nbsp;x&nbsp;';
44
+
45
+ $field_id = $this -> get_field_id( 'height' );
46
+ $field_name = $this -> get_field_name( 'height' );
47
+ echo '<input type="text" size="3" maxlength="3" id="' . $field_id . '" name="' . $field_name . '" value="' . attribute_escape( $instance[ 'height' ] ) . '" />&nbsp;pixels</p>';
48
+
49
+ ?>
50
+ <h4><?php _e( 'Non-EmbedPlus Options' ); ?></h4>
51
+ <?php
52
+
53
+ // Start field
54
+ $field_id = $this -> get_field_id( 'start' );
55
+ $field_name = $this -> get_field_name( 'start' );
56
+ echo "\r\n" . '<p><label for="' . $field_id . '">' . __( 'Start' ) . ': </label><input type="text" size="3" maxlength="3" id="' . $field_id . '" name="' . $field_name . '" value="' . attribute_escape( $instance[ 'start' ] ) . '" /> seconds</p>';
57
+
58
+ // Autohide field
59
+ $field_id = $this -> get_field_id( 'autohide' );
60
+ $field_name = $this -> get_field_name( 'autohide' );
61
+ echo "\r\n" . '<p><label for="' . $field_id . '">' . __( 'Auto hide' ) . ': </label><select name="' . $field_name . '" class="widefat" id="' . $field_id . '"><option value="0"';
62
+ if ( attribute_escape( $instance[ 'autohide' ] ) == '0' ) { echo " selected='selected'"; }
63
+ echo '>' . __( 'Controls &amp; progress bar visible' ) . '</option><option value="1"';
64
+ if ( attribute_escape( $instance[ 'autohide' ] ) == '1' ) { echo " selected='selected'"; }
65
+ echo '>' . __( 'Controls &amp; progress bar fade out' ) . '</option><option value="2"';
66
+ if ( attribute_escape( $instance[ 'autohide' ] ) == '2' ) { echo " selected='selected'"; }
67
+ echo '>' . __( 'Progress bar fades' ) . '</option></select></p>';
68
+
69
+ // List field
70
+ $field_id = $this -> get_field_id( 'list' );
71
+ $field_name = $this -> get_field_name( 'list' );
72
+ echo "\r\n" . '<p><label for="' . $field_id . '">' . __( 'List Playback' ) . ': </label><select name="' . $field_name . '" class="widefat" id="' . $field_id . '"><option value="0"';
73
+ if ( attribute_escape( $instance[ 'list' ] ) == '' ) { echo " selected='selected'"; }
74
+ echo '>' . __( 'Play each video in order' ) . '</option><option value="1"';
75
+ if ( attribute_escape( $instance[ 'list' ] ) == 'random' ) { echo " selected='selected'"; }
76
+ echo '>' . __( 'Play videos randomly' ) . '</option><option value="2"';
77
+ if ( attribute_escape( $instance[ 'list' ] ) == 'single' ) { echo " selected='selected'"; }
78
+ echo '>' . __( 'Play one random video' ) . '</option></select></p>';
79
+
80
+ echo "<table>\n";
81
+
82
+ // Autoplay field
83
+ $field_id = $this -> get_field_id( 'autoplay' );
84
+ $field_name = $this -> get_field_name( 'autoplay' );
85
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Autoplay' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
86
+ if ( attribute_escape( $instance[ 'autoplay' ] ) == '1') { echo "checked='checked' "; }
87
+ echo '/></td></tr>';
88
+
89
+ // Controls field
90
+ $field_id = $this -> get_field_id( 'controls' );
91
+ $field_name = $this -> get_field_name( 'controls' );
92
+ echo "\r\n" . '<tr><td>' . __( 'Controls' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
93
+ if ( attribute_escape( $instance[ 'controls' ] ) == '1') { echo "checked='checked' "; }
94
+ echo '/></td></tr>';
95
+
96
+ // Loop video field
97
+ $field_id = $this -> get_field_id( 'loop' );
98
+ $field_name = $this -> get_field_name( 'loop' );
99
+ echo "\r\n" . '<tr><td>' . __( 'Loop Video' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
100
+ if ( attribute_escape( $instance[ 'loop' ] ) == '1') { echo "checked='checked' "; }
101
+ echo '/></td></tr>';
102
+
103
+ echo "</table>\n";
104
+
105
+ ?>
106
+ <h4><?php _e( 'Non-EmbedPlus & HTML5 Options' ); ?></h4>
107
+ <?php
108
+
109
+ echo "<table>\n";
110
+
111
+ // Annotation field
112
+ $field_id = $this -> get_field_id( 'annotation' );
113
+ $field_name = $this -> get_field_name( 'annotation' );
114
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Annotations' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
115
+ if ( attribute_escape( $instance[ 'annotation' ] ) == '1') { echo "checked='checked' "; }
116
+ echo '/></td></tr>';
117
+
118
+ // Closed Caption field
119
+ $field_id = $this -> get_field_id( 'cc' );
120
+ $field_name = $this -> get_field_name( 'cc' );
121
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Closed Captions' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
122
+ if ( attribute_escape( $instance[ 'cc' ] ) == '1') { echo "checked='checked' "; }
123
+ echo '/></td></tr>';
124
+
125
+ // Disable keyboard field
126
+ $field_id = $this -> get_field_id( 'disablekb' );
127
+ $field_name = $this -> get_field_name( 'disablekb' );
128
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Disable Keyboard' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
129
+ if ( attribute_escape( $instance[ 'disablekb' ] ) == '1') { echo "checked='checked' "; }
130
+ echo '/></td></tr>';
131
+
132
+ // Fullscreen field
133
+ $field_id = $this -> get_field_id( 'fullscreen' );
134
+ $field_name = $this -> get_field_name( 'fullscreen' );
135
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Fullscreen' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
136
+ if ( attribute_escape( $instance[ 'fullscreen' ] ) == '1') { echo "checked='checked' "; }
137
+ echo '/></td></tr>';
138
+
139
+ // Information field
140
+ $field_id = $this -> get_field_id( 'info' );
141
+ $field_name = $this -> get_field_name( 'info' );
142
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Information' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
143
+ if ( attribute_escape( $instance[ 'info' ] ) == '1') { echo "checked='checked' "; }
144
+ echo '/></td></tr>';
145
+
146
+ // YouTube Link field
147
+ $field_id = $this -> get_field_id( 'link' );
148
+ $field_name = $this -> get_field_name( 'link' );
149
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Link to YouTube' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
150
+ if ( attribute_escape( $instance[ 'link' ] ) == '1') { echo "checked='checked' "; }
151
+ echo '/></td></tr>';
152
+
153
+ // Related videos field
154
+ $field_id = $this -> get_field_id( 'related' );
155
+ $field_name = $this -> get_field_name( 'related' );
156
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Related Videos' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
157
+ if ( attribute_escape( $instance[ 'related' ] ) == '1') { echo "checked='checked' "; }
158
+ echo '/></td></tr>';
159
+
160
+ echo "</table>\n";
161
+
162
+ ?>
163
+ <h4><?php _e('EmbedPlus Options'); ?></h4>
164
+ <?php
165
+
166
+ // Stop field
167
+ $field_id = $this -> get_field_id( 'stop' );
168
+ $field_name = $this -> get_field_name( 'stop' );
169
+ echo "\r\n" . '<p><label for="' . $field_id . '">' . __( 'Stop' ) . ': </label><input type="text" size="3" maxlength="3" id="' . $field_id . '" name="' . $field_name . '" value="' . attribute_escape( $instance[ 'stop' ] ) . '" /> seconds</p>';
170
+
171
+ echo "<table>\n";
172
+
173
+ // HD field
174
+ $field_id = $this -> get_field_id( 'hd' );
175
+ $field_name = $this -> get_field_name( 'hd' );
176
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Play HD' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
177
+ if ( attribute_escape( $instance[ 'hd' ] ) == '1') { echo "checked='checked' "; }
178
+ echo '/></td></tr>';
179
+
180
+ // Reactions field
181
+ $field_id = $this -> get_field_id( 'react' );
182
+ $field_name = $this -> get_field_name( 'react' );
183
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Real-time Reactions' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
184
+ if ( attribute_escape( $instance[ 'react' ] ) == '1') { echo "checked='checked' "; }
185
+ echo '/></td></tr>';
186
+
187
+ // Sweetspot field
188
+ $field_id = $this -> get_field_id( 'sweetspot' );
189
+ $field_name = $this -> get_field_name( 'sweetspot' );
190
+ echo "\r\n" . '<tr><td width="100%">' . __( 'Sweet Spots' ) . '</td><td><input type="checkbox" name="' . $field_name . '" id="' . $field_id . '" value="1" ';
191
+ if ( attribute_escape( $instance[ 'sweetspot' ] ) == '1') { echo "checked='checked' "; }
192
+ echo '/></td></tr>';
193
+
194
+ echo "</table>\n";
195
+ ?>
includes/set-option-defaults.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Set Default Options
4
+ *
5
+ * Set up default values for the various options
6
+ *
7
+ * @package YouTubeEmbed
8
+ */
9
+
10
+ /**
11
+ * Function to set Shortcode option
12
+ *
13
+ * Looks up shortcode option - if it's not set, assign a default
14
+ *
15
+ * @since 2.0
16
+ *
17
+ * @return string Alternative Shortcode
18
+ */
19
+
20
+ function ye_set_shortcode_option() {
21
+
22
+ $shortcode = get_option( 'youtube_embed_shortcode' );
23
+
24
+ // If setting doesn't exist, set defaults
25
+ if ( $shortcode == '' ) {
26
+ $shortcode[ 1 ] = 'youtube_video';
27
+ $shortcode[ 2 ] = '';
28
+ update_option( 'youtube_embed_shortcode', $shortcode );
29
+ }
30
+
31
+ return $shortcode;
32
+ }
33
+
34
+ /**
35
+ * Function to set URL option
36
+ *
37
+ * Looks up URL option - if it's not set, override the WP URL embedding
38
+ *
39
+ * @since 2.0
40
+ *
41
+ * @return string URL override
42
+ */
43
+
44
+ function ye_set_url_option() {
45
+
46
+ $url = get_option( 'youtube_embed_url' );
47
+
48
+ // If setting doesn't exist, set defaults
49
+ if ( $url == '' ) { update_option( 'youtube_embed_url', '' ); }
50
+
51
+ return $url;
52
+ }
53
+
54
+ /**
55
+ * Function to set general YouTube options
56
+ *
57
+ * Looks up options. If none exist, or some are missing, set default values
58
+ *
59
+ * @since 2.0
60
+ *
61
+ * @return strings Options array
62
+ */
63
+
64
+ function ye_set_general_defaults() {
65
+ $options = get_option( 'youtube_embed_general' );
66
+ $changed = false;
67
+
68
+ if ( !is_array( $options ) ) {
69
+ if ( get_option( 'youtube_embed_editor' ) ) {
70
+ // If the old options exist, import them and then delete them
71
+ $old_opts = get_option( 'youtube_embed_editor' );
72
+ $options[ 'editor_button' ] = $old_opts[ 'youtube' ];
73
+ delete_option( 'youtube_embed_editor' );
74
+ $changed = true;
75
+ } else {
76
+ // If array doesn't exist, set defaults
77
+ $options = array( 'editor_button' => 1, 'admin_bar' => 1, 'profile_no' => 5, 'list_no' => 5, 'info_cache' => 24, 'embed_cache' => 1, 'transcript_cache' => 24, 'alt_profile' => 0, 'alt_profile2' => 0, 'bracket' => '', 'alt' => 0, 'url_profile' => 0, 'other_profile' => 0, 'comments' => '', 'comments_profile' => 0, 'metadata' => 1, 'feed' => 'b' );
78
+ $changed = true;
79
+ }
80
+ }
81
+
82
+ // Because of upgrading, check each option - if not set, apply default
83
+ if ( !array_key_exists( 'editor_button', $options ) ) { $options[ 'editor_button' ] = 1; $changed = true; }
84
+ if ( !array_key_exists( 'admin_bar', $options ) ) { $options[ 'admin_bar' ] = 1; $changed = true; }
85
+ if ( !array_key_exists( 'profile_no', $options ) ) { $options[ 'profile_no' ] = 5; $changed = true; }
86
+ if ( !array_key_exists( 'list_no', $options ) ) { $options[ 'list_no' ] = 5; $changed = true; }
87
+ if ( !array_key_exists( 'info_cache', $options ) ) { $options[ 'info_cache' ] = 1; $changed = true; }
88
+ if ( !array_key_exists( 'embed_cache', $options ) ) { $options[ 'embed_cache' ] = 24; $changed = true; }
89
+ if ( !array_key_exists( 'transcript_cache', $options ) ) { $options[ 'transcript_cache' ] = 24; $changed = true; }
90
+ if ( !array_key_exists( 'alt_profile', $options ) ) { $options[ 'alt_profile' ] = 0; $changed = true; }
91
+ if ( !array_key_exists( 'alt_profile2', $options ) ) { $options[ 'alt_profile2' ] = 0; $changed = true; }
92
+ if ( !array_key_exists( 'url_profile', $options ) ) { $options[ 'url_profile' ] = 0; $changed = true; }
93
+ if ( !array_key_exists( 'other_profile', $options ) ) { $options[ 'other_profile' ] = 0; $changed = true; }
94
+ if ( !array_key_exists( 'comments_profile', $options ) ) { $options[ 'comments_profile' ] = 0; $changed = true; }
95
+ if ( !array_key_exists( 'metadata', $options ) ) { $options[ 'metadata' ] = 1; $changed = true; }
96
+ if ( !array_key_exists( 'feed', $options ) ) { $options[ 'feed' ] = 'b'; $changed = true; }
97
+
98
+ // Update the options, if changed, and return the result
99
+ if ( $changed ) { update_option( 'youtube_embed_general', $options ); }
100
+ return $options;
101
+ }
102
+
103
+ /**
104
+ * Function to set YouTube profile options
105
+ *
106
+ * Looks up profile options, based on passed profile numer.
107
+ * If none exist, or some are missing, set default values
108
+ *
109
+ * @since 2.0
110
+ *
111
+ * @param string $profile Profile number
112
+ * @return string Options array
113
+ */
114
+
115
+ function ye_set_profile_defaults( $profile ) {
116
+ if ( $profile == 0 ) {
117
+ $profname = 'Default';
118
+ } else {
119
+ $profname = 'Profile ' . $profile;
120
+ }
121
+ $options = get_option( 'youtube_embed_profile' . $profile );
122
+ $changed = false;
123
+ $new_user = false;
124
+
125
+
126
+ // Work out default dimensions
127
+ if ( isset( $GLOBALS[ 'content_width' ] ) ) {
128
+ $width = $GLOBALS[ 'content_width' ];
129
+ } else {
130
+ $width = 560;
131
+ }
132
+ $height = round( ( $width / 16 ) * 9, 0 );
133
+
134
+ if ( !is_array( $options ) ) {
135
+ if ( ( $profile == 0 ) && ( get_option( 'youtube_embed' ) ) ) {
136
+ // If the old options exist, import them and then delete them
137
+ $old_opts = get_option( 'youtube_embed' );
138
+ $options = $old_opts;
139
+ delete_option( 'youtube_embed' );
140
+ if ( $options[ 'style' ] != '') { $options [ 'template' ] = '<div style="' . $options[ 'style' ] . '">%video%</div>';}
141
+ $changed = true;
142
+ } else {
143
+ // If array doesn't exist, set defaults
144
+ $options = array( 'width' => $width, 'height' => $height, 'fullscreen' => '', 'template' => '%video%', 'autoplay' => '', 'start' => '0', 'loop' => '', 'cc' => '', 'annotation' => '1', 'related' => '', 'info' => '1', 'link' => '1', 'react' => '1', 'stop' => '0', 'sweetspot' => '1', 'type' => 'v', 'disablekb' => '', 'autohide' => '2', 'controls' => '1', 'playlist' => 'v', 'fallback' => 'v', 'wmode' => 'opaque', 'shadow' => '0', 'audio' => '', 'hd' => '1' );
145
+ $changed = true;
146
+ }
147
+ }
148
+
149
+ // Because of upgrading, check each option - if not set, apply default
150
+ if ( !array_key_exists( 'name', $options ) ) { $options[ 'name' ] = $profname; $changed = true; }
151
+ if ( !array_key_exists( 'width', $options ) ) {
152
+ $option[ 'width' ] = $width;
153
+ $options[ 'height' ] = $height;
154
+ $changed = true;
155
+ }
156
+ if ( !array_key_exists( 'height', $options ) ) { $options[ 'height' ] = '340'; $changed = true; }
157
+ if ( !array_key_exists( 'annotation', $options ) ) { $options[ 'annotation' ] = '1'; $changed = true; }
158
+ if ( !array_key_exists( 'info', $options ) ) { $options[ 'info' ] = '1'; $changed = true; }
159
+ if ( !array_key_exists( 'link', $options ) ) { $options[ 'link' ] = '1'; $changed = true; }
160
+ if ( !array_key_exists( 'react', $options ) ) { $options[ 'react' ] = '1'; $changed = true; }
161
+ if ( !array_key_exists( 'sweetspot', $options ) ) { $options[ 'sweetspot' ] = '1'; $changed = true; }
162
+ if ( !array_key_exists( 'type', $options ) ) { $options[ 'type' ] = 'v'; $changed = true; }
163
+ if ( !array_key_exists( 'link', $options ) ) { $options[ 'link' ] = '1'; $changed = true; }
164
+ if ( !array_key_exists( 'react', $options ) ) { $options[ 'react' ] = '1'; $changed = true; }
165
+ if ( !array_key_exists( 'sweetspot', $options ) ) { $options[ 'sweetspot' ] = '1'; $changed = true; }
166
+ if ( !array_key_exists( 'autohide', $options ) ) { $options[ 'autohide' ] = '2'; $changed = true; }
167
+ if ( !array_key_exists( 'controls', $options ) ) { $options[ 'controls' ] = '1'; $changed = true; }
168
+ if ( !array_key_exists( 'playlist', $options ) ) { $options[ 'playlist' ] = 'v'; $changed = true; }
169
+ if ( !array_key_exists( 'fallback', $options ) ) { $options[ 'fallback' ] = 'v'; $changed = true; }
170
+ if ( !array_key_exists( 'wmode', $options ) ) { $options[ 'wmode' ] = 'opaque'; $changed = true; }
171
+ if ( !array_key_exists( 'shadow', $options ) ) { $options[ 'shadow' ] = '0'; $changed = true; }
172
+ if ( !array_key_exists( 'template', $options ) ) { $options[ 'template' ] = '%video%'; $changed = true; }
173
+ if ( !array_key_exists( 'hd', $options ) ) { $options[ 'hd' ] = '1'; $changed = true; }
174
+
175
+ // Update the options, if changed, and return the result
176
+ if ( $changed ) { update_option( 'youtube_embed_profile' . $profile, $options ); }
177
+
178
+ // Remove added slashes from template XHTML
179
+ $options[ 'template' ] = stripslashes( $options[ 'template' ] );
180
+
181
+ return $options;
182
+ }
183
+
184
+ /**
185
+ * Function to set default list options
186
+ *
187
+ * Looks up list options, based on passed list number.
188
+ * If none exist, or some are missing, set default values
189
+ *
190
+ * @since 2.0
191
+ *
192
+ * @param string $list List number
193
+ * @return string Options array
194
+ */
195
+
196
+ function ye_set_list_defaults( $list ) {
197
+ $options = get_option( 'youtube_embed_list' . $list );
198
+ $changed = false;
199
+
200
+ // If array doesn't exist, set defaults
201
+ if ( !is_array( $options ) ) {
202
+ $options = array( 'name' => 'List ' . $list, 'list' => '' );
203
+ $changed = true;
204
+ }
205
+
206
+ // Because of upgrading, check each option - if not set, apply default
207
+ if ( !array_key_exists( 'name',$options ) ) { $options[ 'name' ] = 'List ' . $list; $changed = true; }
208
+ if ( !array_key_exists( 'list',$options ) ) { $options[ 'list' ] = ''; $changed = true; }
209
+
210
+ // Update the options, if changed, and return the result
211
+ if ( $changed ) { update_option( 'youtube_embed_list' . $list, $options ); }
212
+ return $options;
213
+ }
214
+ ?>
includes/shared.php ADDED
@@ -0,0 +1,366 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shared Functions
4
+ *
5
+ * Small utilities shared by a number of other functions
6
+ *
7
+ * @package YouTubeEmbed
8
+ */
9
+
10
+ /**
11
+ * Extract parameters (1.0)
12
+ *
13
+ * Function to extract parameters from an input string
14
+ *
15
+ * @since 2.0
16
+ *
17
+ * @param string $input Input string to search through
18
+ * @param string $para Parameter to look for
19
+ * @return string Parameter value (if found)
20
+ */
21
+
22
+ function ye_get_parameters( $input, $para ) {
23
+
24
+ $start = strpos( strtolower( $input ), $para . '=' );
25
+ $content = '';
26
+
27
+ if ( $start !== false ) {
28
+ $start = $start + strlen( $para ) + 1;
29
+ $end=strpos( strtolower( $input ), '&', $start );
30
+ if ( $end !== false ) { $end = $end - 1; } else { $end = strlen( $input ); }
31
+ $content = substr( $input, $start, $end - $start + 1 );
32
+ }
33
+
34
+ return $content;
35
+ }
36
+
37
+ /**
38
+ * Extract a video ID
39
+ *
40
+ * Function to extract an ID if a full URL has been supplied
41
+ *
42
+ * @since 2.0
43
+ *
44
+ * @param string $id Video ID
45
+ * @return string Extracted ID
46
+ */
47
+
48
+ function ye_extract_id( $id ) {
49
+
50
+ // Check if it's the full URL, as found in address bar
51
+ $video_pos = strpos( $id, 'youtube.com/watch?', 0 );
52
+
53
+ if ( $video_pos !== false ) {
54
+ $video_pos = $video_pos + 20;
55
+ $ampersand_pos = strpos( $id, '&', $video_pos );
56
+ if ( !$ampersand_pos ) {
57
+ $id = substr( $id, $video_pos );
58
+ } else {
59
+ $id = substr( $id, $video_pos, $ampersand_pos - $video_pos );
60
+ }
61
+
62
+ } else {
63
+
64
+ // Now check to see if it's a full URL, as used in the embed code
65
+ // Need to check both video and playlist formats
66
+ $video_pos = strpos( $id, "youtube.com/v/" );
67
+ if ($video_pos === false) { $video_pos = strpos( $id, "youtube.com/p/" ); }
68
+
69
+ if ( $video_pos !== false ) {
70
+ $video_pos = $video_pos + 14;
71
+ $qmark_pos = strpos( $id, '?', $video_pos );
72
+ if ( !$qmark_pos ) {
73
+ $id = substr( $id, $video_pos );
74
+ } else {
75
+ $id = substr( $id, $video_pos, $qmark_pos - $video_pos );
76
+ }
77
+ }
78
+ }
79
+
80
+ // Convert video ID characters
81
+ $id = str_replace( '&#8211;', '--', $id );
82
+ $id = str_replace( '&#215;', 'x', $id );
83
+
84
+ return $id;
85
+ }
86
+
87
+ /**
88
+ * Validate video type
89
+ *
90
+ * Function to work out what type of video has been requested and
91
+ * whether it is valid. Also fetches the video title.
92
+ *
93
+ * @since 2.0
94
+ *
95
+ * @param string $id Video ID
96
+ * @param string $title_needed Whether the title requires extracting
97
+ * @return string Array containing file details
98
+ */
99
+
100
+ function ye_validate_id( $id, $title_needed = false ) {
101
+
102
+ $type = false;
103
+ $title = false;
104
+ $options = false;
105
+
106
+ // Attempt to get the video type and title from cache
107
+ $type = get_transient( 'ye_type_' . $id );
108
+ $title = get_transient( 'ye_title_' . $id );
109
+
110
+ // Check if items are cached
111
+ $cache = true;
112
+ if ( ( !$type ) or ( !$title) ) { $cache = false; }
113
+
114
+ // Get video information if not cached
115
+ if ( !$cache ) {
116
+
117
+ $options = ye_set_general_defaults();
118
+
119
+ // Check with YouTube API as to whether the ID is a video
120
+ $id_check = ye_get_file( 'http://gdata.youtube.com/feeds/api/videos/' . $id, false );
121
+ if ( $id_check[ 'response' ] != 200 ) {
122
+
123
+ // Check with YouTube API as to whether the ID is a playlist
124
+ $id_check = ye_get_file( 'http://gdata.youtube.com/feeds/api/playlists/' . $id, false );
125
+ if ( $id_check[ 'response' ] != 200 ) {
126
+ $type = '';
127
+ } else {
128
+ $type = 'p';
129
+ }
130
+ } else {
131
+ $type = 'v';
132
+ }
133
+
134
+ // Update the cache
135
+ set_transient( 'ye_type_' . $id, $type, $options[ 'info_cache' ] * 3600 );
136
+
137
+ // If the video is valid extract the title from the XML
138
+ if ( ( $title_needed) && ( $id_check[ 'file' ] != '' ) ) {
139
+
140
+ // Find title in XML
141
+ $tag_start = strpos( $id_check[ 'file' ], '<title ', 1 );
142
+ if ( $tag_start !== false ) {
143
+ $tag_end = strpos( $id_check[ 'file' ], '>', $tag_start + 1 );
144
+ if ( $tag_end !== false ) {
145
+ $end_tag = strpos( $id_check[ 'file' ], '</title>', $tag_start );
146
+ if ( $end_tag !== false ) {
147
+ $title = substr( $id_check[ 'file' ], $tag_end + 1, $end_tag - $tag_end - 1 );
148
+ }
149
+ }
150
+ }
151
+
152
+ // Update the cache
153
+ set_transient( 'ye_title_' . $id, $title, $options[ 'info_cache' ] * 3600 );
154
+ }
155
+ }
156
+
157
+ if ( !$title_needed ) { return $type; }
158
+
159
+ $return[ 'type' ] = $type;
160
+ $return[ 'title' ] = $title;
161
+ return $return;
162
+ }
163
+
164
+ /**
165
+ * Function to report an error
166
+ *
167
+ * Display an error message in a standard format
168
+ *
169
+ * @since 2.0
170
+ *
171
+ * @param string $errorin Error message
172
+ * @return string Error output
173
+ */
174
+
175
+ function ye_error( $errorin ) {
176
+
177
+ return '<p style="color: #f00; font-weight: bold;">Artiss YouTube Embed: ' . $errorin . "</p>\n";
178
+
179
+ }
180
+
181
+ /**
182
+ * Convert input to a 1 or 0 equivalent
183
+ *
184
+ * Function to convert a Yes or No input to an equivalent 1 or 0 output
185
+ *
186
+ * @since 2.0
187
+ *
188
+ * @uses ye_yes_or_no Convert input to a true or false equivalent
189
+ *
190
+ * @param string $input Input, usually Yes or No
191
+ * @return string 1, 0 or blank, depending on input
192
+ */
193
+
194
+ function ye_convert( $input ) {
195
+
196
+ $input = ye_yes_or_no( $input );
197
+ $output = '';
198
+ if ( $input === true ) { $output = '1'; }
199
+ if ( $input === false ) { $output = '0'; }
200
+
201
+ return $output;
202
+ }
203
+
204
+ /**
205
+ * Convert input to a 1 or 3 equivalent
206
+ *
207
+ * Function to convert a Yes or No input to an equivalent 1 or 3 output
208
+ *
209
+ * @since 2.0
210
+ *
211
+ * @uses ye_yes_or_no Convert input to a true or false equivalent
212
+ *
213
+ * @param string $input Input, usually Yes or No
214
+ * @return string 1, 3 or blank, depending on input
215
+ */
216
+
217
+ function ye_convert_3( $input ) {
218
+
219
+ $input = ye_yes_or_no( $input );
220
+ $output = '';
221
+ if ( $input === true ) { $output = '1'; }
222
+ if ( $input === false ) { $output = '3'; }
223
+
224
+ return $output;
225
+ }
226
+
227
+ /**
228
+ * Convert input to True or False (1.0)
229
+ *
230
+ * Return true or false, depending on the input. Possible inputs are Yes, No, 0, 1, True,
231
+ * False, On, Off
232
+ *
233
+ * @since 2.0
234
+ *
235
+ * @param string $input Value passed for checking
236
+ * @return string Blank string or boolean true, false
237
+ */
238
+
239
+ function ye_yes_or_no( $input = '' ) {
240
+
241
+ $input = strtolower( $input );
242
+ if ( ( $input === true ) or ( $input == 'true' ) or ( $input == '1' ) or ( $input == 'yes' ) or ( $input == 'on' ) ) { return true; }
243
+ if ( ( $input === false ) or ( $input == 'false' ) or ( $input == '0' ) or ( $input == 'no' ) or ( $input == 'off' ) ) { return false; }
244
+
245
+ return;
246
+ }
247
+
248
+ /**
249
+ * Fetch a file (1.5)
250
+ *
251
+ * Use WordPress API to fetch a file and check results
252
+ *
253
+ * @since 2.0
254
+ *
255
+ * @param string $filein File name to fetch
256
+ * @param string $header Only get headers?
257
+ * @return string Array containing file contents and response
258
+ */
259
+
260
+ function ye_get_file( $filein, $header = false ) {
261
+
262
+ if ( $header ) {
263
+ $fileout = wp_remote_head( $filein );
264
+ if ( !isset( $fileout[ 'headers' ] ) ) {
265
+ $file_return[ 'rc' ] = 1;
266
+ } else {
267
+ $file_return[ 'rc' ] = 0;
268
+ }
269
+ } else {
270
+ $fileout = wp_remote_get( $filein );
271
+ if ( !isset( $fileout[ 'body' ] ) ) {
272
+ $file_return[ 'rc' ] = 1;
273
+ } else {
274
+ $file_return[ 'file' ] = $fileout[ 'body' ];
275
+ $file_return[ 'rc' ] = 0;
276
+ }
277
+ }
278
+
279
+ if ( isset( $fileout[ 'response' ][ 'code' ] ) ) {
280
+ $file_return[ 'response' ] = $fileout[ 'response' ][ 'code' ];
281
+ }
282
+
283
+ return $file_return;
284
+ }
285
+
286
+ /**
287
+ * Function to set embed type
288
+ *
289
+ * Depending on embed parameters set a value
290
+ *
291
+ * @since 2.0
292
+ *
293
+ * @uses ye_convert Convert value to a 0 or 1 equivalent
294
+ *
295
+ * @param string $type Current embed type
296
+ * @param string $embedplus Whether EmbedPlus embedding is required
297
+ * @return string The type of embedding to use
298
+ */
299
+
300
+ function ye_get_embed_type( $type, $embedplus ) {
301
+
302
+ $embedplus = ye_convert( $embedplus );
303
+ $type = strtolower( $type );
304
+
305
+ if ( ( $type == 'embedplus' ) or ( $embedplus == '1' ) ) { $type = 'm'; }
306
+ if ( $type == 'iframe' ) { $type = 'v'; }
307
+ if ( $type == 'object' ) { $type = 'p'; }
308
+
309
+ return $type;
310
+ }
311
+
312
+ /**
313
+ * Convert autohide parameter
314
+ *
315
+ * Convert autohide text value to a numeric equivalent
316
+ *
317
+ * @since 2.0
318
+ *
319
+ * @param string $autohide Autohide parameter value
320
+ * @return string Autohide numeric equivalent
321
+ */
322
+
323
+ function ye_set_autohide( $autohide ) {
324
+
325
+ $autohide = strtolower( $autohide );
326
+ if ( $autohide == 'no' ) { $autohide = '0'; }
327
+ if ( $autohide == 'yes' ) { $autohide = '1'; }
328
+ if ( $autohide == 'fade' ) { $autohide = '2'; }
329
+
330
+ return $autohide;
331
+ }
332
+
333
+ /**
334
+ * Generate a profile list
335
+ *
336
+ * Generate FORM options for the current profiles
337
+ *
338
+ * @since 2.0
339
+ *
340
+ * @param string $current The current profile number
341
+ * @param string $total The total number of profiles
342
+ */
343
+
344
+ function ye_generate_profile_list( $current, $total ) {
345
+
346
+ echo '<option value="0"';
347
+ if ( $current == "0" ) { echo " selected='selected'"; }
348
+ echo ' >'.__('Default').'</option>';
349
+ $loop = 1;
350
+ while ( $loop <= $total ) {
351
+
352
+ $profiles = get_option( 'youtube_embed_profile' . $loop );
353
+ $profname = $profiles[ 'name' ];
354
+
355
+ if ( $profname == '' ) { $profname = "Profile " . $loop; }
356
+ echo '<option value="' . $loop . '"';
357
+
358
+ if ( $current == $loop ) { echo " selected='selected'"; }
359
+ echo '>' . __( $profname ) . "</option>\n";
360
+
361
+ $loop ++;
362
+ }
363
+
364
+ return;
365
+ }
366
+ ?>
includes/shortcodes.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Shortcodes
4
+ *
5
+ * Define the various shortcodes
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ */
10
+
11
+ /**
12
+ * Default Video shortcode
13
+ *
14
+ * Main [youtube] shortcode to display video
15
+ *
16
+ * @since 2.0
17
+ *
18
+ * @uses ye_video_shortcode Action the shortcode parameters
19
+ *
20
+ * @param string $paras Shortcode parameters
21
+ * @param string $content Shortcode content
22
+ * @return string YouTube embed code
23
+ */
24
+
25
+ function ye_video_shortcode_default( $paras = '', $content = '' ) {
26
+ return ye_video_shortcode( $paras, $content );
27
+ }
28
+ add_shortcode( 'youtube', 'ye_video_shortcode_default' );
29
+
30
+ /**
31
+ * Alternative Video shortcode 1
32
+ *
33
+ * 1st alternative shortcode to display video
34
+ *
35
+ * @since 2.0
36
+ *
37
+ * @uses ye_video_shortcode Action the shortcode parameters
38
+ *
39
+ * @param string $paras Shortcode parameters
40
+ * @param string $content Shortcode content
41
+ * @return string YouTube embed code
42
+ */
43
+
44
+ function ye_video_shortcode_alt1( $paras = '', $content = '' ) {
45
+ return ye_video_shortcode( $paras, $content, '', 1 );
46
+ }
47
+ $shortcode = ye_set_shortcode_option();
48
+ if ( $shortcode[ 1 ] != '' ) { add_shortcode( $shortcode[ 1 ], 'ye_video_shortcode_alt1' ); }
49
+
50
+ /**
51
+ * Alternative Video shortcode 2
52
+ *
53
+ * 2nd alternative shortcode to display video
54
+ *
55
+ * @since 2.0
56
+ *
57
+ * @uses ye_video_shortcode Action the shortcode parameters
58
+ *
59
+ * @param string $paras Shortcode parameters
60
+ * @param string $content Shortcode content
61
+ * @return string YouTube embed code
62
+ */
63
+
64
+ function ye_video_shortcode_alt2( $paras = '', $content = '' ) {
65
+ return ye_video_shortcode( $paras, $content, '', 2 );
66
+ }
67
+ if ( $shortcode[ 2 ] != '' ) { add_shortcode( $shortcode[ 2 ], 'ye_video_shortcode_alt2' ); }
68
+
69
+ /**
70
+ * Video shortcode
71
+ *
72
+ * Use shortcode parameters to embed a YouTube video or playlist
73
+ *
74
+ * @since 2.0
75
+ *
76
+ * @uses ye_get_embed_type Get the embed type
77
+ * @uses ye_set_autohide Get the autohide parameter
78
+ * @uses ye_generate_youtube_code Generate the embed code
79
+ *
80
+ * @param string $paras Shortcode parameters
81
+ * @param string $content Shortcode content
82
+ * @param string $alt_shortcode The number of the alternative shortcode used
83
+ * @return string YouTube embed code
84
+ */
85
+
86
+ function ye_video_shortcode( $paras = '', $content = '', $callback = '', $alt_shortcode = '' ) {
87
+
88
+ extract( shortcode_atts( array( 'type' => '', 'width' => '', 'height' => '', 'fullscreen' => '', 'related' => '', 'autoplay' => '', 'loop' => '', 'start' => '', 'info' => '', 'annotation' => '', 'cc' => '', 'style' => '', 'link' => '', 'react' => '', 'stop' => '', 'sweetspot' => '', 'disablekb' => '', 'ratio' => '', 'autohide' => '', 'controls' => '', 'profile' => '', 'embedplus' => '', 'audio' => '', 'id' => '', 'url' => '', 'rel' => '', 'fs' => '', 'cc_load_policy' => '', 'iv_load_policy' => '', 'showinfo' => '', 'youtubeurl' => '', 'template' => '', 'list' => '', 'hd' => '' ), $paras ) );
89
+
90
+ // If no profile specified and an alternative shortcode used, get that shortcodes default profile
91
+ if ( ( $profile == '' ) && ( $alt_shortcode != '' ) ) {
92
+ // Profile is now blank or 2
93
+ if ( $alt_shortcode == '1' ) { $alt_shortcode = ''; }
94
+ // Get general options
95
+ $options = ye_set_general_defaults();
96
+ $profile = $options[ 'alt_profile'.$alt_shortcode ];
97
+ }
98
+
99
+ // If an alternative field is set, use it
100
+ if ( ( $id != '' ) && ( $content == '' ) ) { $content = $id; }
101
+ if ( ( $url != '' ) && ( $content == '' ) ) { $content = $url; }
102
+ if ( ( $youtubeurl != '' ) && ( $content == '' ) ) { $content = $youtubeurl; }
103
+
104
+ if ( ( $rel != '' ) && ( $related == '' ) ) { $related = $rel;}
105
+ if ( ( $fs != '' ) && ( $fullscreen == '' ) ) { $fullscreen = $fs;}
106
+ if ( ( $cc_load_policy != '' ) && ( $cc == '' ) ) { $cc = $cc_load_policy;}
107
+ if ( ( $iv_load_policy != '' ) && ( $annotation == '' ) ) { $annotation = $iv_load_policy;}
108
+ if ( ( $showinfo != '' ) && ( $info == '' ) ) { $info = $showinfo;}
109
+
110
+ // If ID was not passed in the content and the first parameter is set, assume that to be the ID
111
+ if ( ( $content == '' ) && ( $paras[ 0 ] != '' ) ) {
112
+ $content = $paras[ 0 ];
113
+ if ( (substr( $content, 0, 1 ) == ":" ) or ( substr( $content, 0, 1 ) == "=" ) ) { $content = substr( $content, 1 ); }
114
+ if ( $paras[ 1 ] != '' ) { $width = $paras[ 1 ]; }
115
+ if ( $paras[ 2 ] != '' ) { $height = $paras[ 2 ]; }
116
+ }
117
+
118
+ // Get Embed type
119
+ $type = ye_get_embed_type( $type, $embedplus );
120
+
121
+ // Set up Autohide parameter
122
+ $autohide = ye_set_autohide( $autohide );
123
+
124
+ // Create YouTube code
125
+ $youtube_code = ye_generate_youtube_code( $content, $type, $width, $height, ye_convert( $fullscreen ), ye_convert( $related ), ye_convert( $autoplay ), ye_convert( $loop ), $start, ye_convert( $info ), ye_convert_3( $annotation ), ye_convert( $cc ), $style, ye_convert( $link ), ye_convert( $react ), $stop, ye_convert( $sweetspot ), ye_convert( $disablekb ), $ratio, $autohide, ye_convert( $controls ), $profile, $list, ye_convert( $audio ), $template, ye_convert( $hd ) );
126
+
127
+ return $youtube_code;
128
+ }
129
+
130
+ /**
131
+ * Return a thumbnail URL
132
+ *
133
+ * Shortcode to return the URL for a thumbnail
134
+ *
135
+ * @since 2.0
136
+ *
137
+ * @uses ye_generate_thumbnail_code Generate the thumbnail code
138
+ *
139
+ * @param string $paras Shortcode parameters
140
+ * @param string $content Shortcode content
141
+ * @return string YouTube thumbnail code
142
+ */
143
+
144
+ function ye_thumbnail_sc( $paras = '', $content = '' ) {
145
+ extract( shortcode_atts( array( 'style' => '', 'class' => '', 'rel' => '', 'target' => '', 'width' => '', 'height' => '', 'alt' => '' ), $paras ) );
146
+ return ye_generate_thumbnail_code( $content, $style, $class, $rel, $target, $width, $height, $alt );
147
+ }
148
+ add_shortcode( 'youtube_thumb', 'ye_thumbnail_sc' );
149
+
150
+ /**
151
+ * Short URL shortcode
152
+ *
153
+ * Generate a short URL for a YouTube video
154
+ *
155
+ * @since 2.0
156
+ *
157
+ * @uses ye_error Show an error
158
+ *
159
+ * @param string $paras Shortcode parameters
160
+ * @param string $content Shortcode content
161
+ * @return string YouTube short URL code
162
+ */
163
+
164
+ function ye_shorturl_sc( $paras = '', $content = '' ) {
165
+ extract( shortcode_atts( array( 'id' => '' ), $paras ) );
166
+ return ye_generate_shorturl_code( $id );
167
+ }
168
+ add_shortcode( 'youtube_url', 'ye_shorturl_sc' );
169
+
170
+ /**
171
+ * Download shortcode
172
+ *
173
+ * Generate a short URL for a YouTube video
174
+ *
175
+ * @since 2.0
176
+ *
177
+ * @uses ye_generate_download_code Generate the download code
178
+ *
179
+ * @param string $paras Shortcode parameters
180
+ * @param string $content Shortcode content
181
+ * @return string YouTube download link
182
+ */
183
+
184
+ function ye_video_download( $paras = '', $content = '' ) {
185
+ extract( shortcode_atts( array( 'id' => '', 'target' => '', 'nofollow' => '' ), $paras ) );
186
+
187
+ // Return the URL
188
+ $link = ye_generate_download_code( $id );
189
+
190
+ // Now add the HTML to the URL (assuming it's not an error)
191
+ if ( substr( $link, 0, 2 ) != '<p' ) {
192
+ $link = '<a href="' . $link . '"';
193
+ if ( $target != '' ) { $link .= ' target="' . $target . '"'; }
194
+ if ( strtolower( $nofollow ) != 'no' ) { $link .= ' rel="nofollow"'; }
195
+ $link .= '>' . $content . '</a>';
196
+ }
197
+
198
+ return $link;
199
+ }
200
+ add_shortcode( 'download_video', 'ye_video_download' );
201
+
202
+ /**
203
+ * Transcript Shortcode
204
+ *
205
+ * Shortcode to return YouTube transcripts
206
+ *
207
+ * @since 2.0
208
+ *
209
+ * @uses ye_generate_transcript Generate the transcript
210
+ *
211
+ * @param string $paras Shortcode parameters
212
+ * @param string $content Shortcode content
213
+ * @return string Transcript XHTML
214
+ */
215
+
216
+ function ye_transcript_sc( $paras = '', $content = '' ) {
217
+ return ye_generate_transcript( $content );
218
+ }
219
+ add_shortcode( 'transcript', 'ye_transcript_sc' );
220
+
221
+ /**
222
+ * Video Name Shortcode
223
+ *
224
+ * Shortcode to return the name of a YouTube video
225
+ *
226
+ * @since 2.0
227
+ *
228
+ * @uses ye_extract_id Extract the video ID
229
+ * @uses ye_validate_id Get the name and video type
230
+ * @uses ye_error Return an error
231
+ *
232
+ * @param string $paras Shortcode parameters
233
+ * @param string $content Shortcode content
234
+ * @return string Video name
235
+ */
236
+
237
+ function ye_video_name_shortcode( $paras = '', $content = '' ) {
238
+
239
+ // Extract the ID if a full URL has been specified
240
+ $id = ye_extract_id( $content );
241
+
242
+ // Check what type of video it is and whether it's valid
243
+ $return = ye_validate_id( $id, true );
244
+ if ( !$return['type'] ) { return ye_error( 'The YouTube ID of ' . $id . ' is invalid.' ); }
245
+
246
+ // Return the video title
247
+ return $return['title'];
248
+ }
249
+ add_shortcode( 'youtube_name', 'ye_video_name_shortcode' );
250
+ ?>
includes/widgets.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Widgets
4
+ *
5
+ * Create and display widgets
6
+ *
7
+ * @package YouTubeEmbed
8
+ */
9
+
10
+ global $wp_version;
11
+ if ( ( float ) $wp_version >= 2.8 ) {
12
+
13
+ class YouTubeEmbedWidget extends WP_Widget {
14
+
15
+ /**
16
+ * Widget Constructor
17
+ *
18
+ * Call WP_Widget class to define widget
19
+ *
20
+ * @since 2.0
21
+ *
22
+ * @uses WP_Widget Standard WP_Widget class
23
+ */
24
+
25
+ function YouTubeEmbedWidget() {
26
+ parent::WP_Widget( 'youtube_embed_widget',
27
+ 'YouTube Embed',
28
+ array( 'description' => 'Embed YouTube Widget.', 'class' => 'my-widget-class' )
29
+ );
30
+ }
31
+
32
+ /**
33
+ * Display widget
34
+ *
35
+ * Display the YouTube widget
36
+ *
37
+ * @since 2.0
38
+ *
39
+ * @uses generate_youtube_code Generate the required YouTube code
40
+ *
41
+ * @param string $args Arguments
42
+ * @param string $instance Instance
43
+ */
44
+
45
+ function widget( $args, $instance ) {
46
+ extract( $args, EXTR_SKIP );
47
+
48
+ // Output the header
49
+ echo $before_widget;
50
+
51
+ // Extract title for heading
52
+ $title = $instance[ 'titles' ];
53
+
54
+ // Output title, if one exists
55
+ if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
56
+
57
+ // Generate the video and output it
58
+ echo ye_generate_youtube_code ( $instance[ 'id' ],
59
+ $instance[ 'type' ],
60
+ $instance[ 'width' ],
61
+ $instance[ 'height' ],
62
+ $instance[ 'fullscreen' ],
63
+ $instance[ 'related' ],
64
+ $instance[ 'autoplay' ],
65
+ $instance[ 'loop' ],
66
+ $instance[ 'start' ],
67
+ $instance[ 'info' ],
68
+ $instance[ 'annotation' ],
69
+ $instance[ 'cc' ],
70
+ '',
71
+ $instance[ 'link' ],
72
+ $instance[ 'react' ],
73
+ $instance[ 'stop' ],
74
+ $instance[ 'sweetspot' ],
75
+ $instance[ 'disablekb' ],
76
+ '',
77
+ $instance[ 'autohide' ],
78
+ $instance[ 'controls' ],
79
+ $instance[ 'profile' ],
80
+ $instance[ 'list' ],
81
+ '',
82
+ $instance[ 'template' ],
83
+ $instance[ 'hd' ] );
84
+
85
+ // Output the trailer
86
+ echo $after_widget;
87
+ }
88
+
89
+ /**
90
+ * Widget update/save function
91
+ *
92
+ * Update and save widget
93
+ *
94
+ * @since 2.0
95
+ *
96
+ * @param string $new_instance New instance
97
+ * @param string $old_instance Old instance
98
+ * @return string Instance
99
+ */
100
+
101
+ function update( $new_instance, $old_instance ) {
102
+
103
+ $instance = $old_instance;
104
+ $instance[ 'titles' ] = strip_tags( $new_instance[ 'titles' ] );
105
+ $instance[ 'id' ] = $new_instance[ 'id' ];
106
+ $instance[ 'type' ] = $new_instance[ 'type' ];
107
+ $instance[ 'width' ] = $new_instance[ 'width' ];
108
+ $instance[ 'height' ] = $new_instance[ 'height' ];
109
+ $instance[ 'fullscreen' ] = $new_instance[ 'fullscreen' ];
110
+ $instance[ 'related' ] = $new_instance[ 'related' ];
111
+ $instance[ 'autoplay' ] = $new_instance[ 'autoplay' ];
112
+ $instance[ 'loop' ] = $new_instance[ 'loop' ];
113
+ $instance[ 'start' ] = $new_instance[ 'start' ];
114
+ $instance[ 'info' ] = $new_instance[ 'info' ];
115
+ $instance[ 'annotation' ] = $new_instance[ 'annotation' ];
116
+ $instance[ 'cc' ] = $new_instance[ 'cc' ];
117
+ $instance[ 'link' ] = $new_instance[ 'link' ];
118
+ $instance[ 'react' ] = $new_instance[ 'react' ];
119
+ $instance[ 'stop' ] = $new_instance[ 'stop' ];
120
+ $instance[ 'sweetspot' ] = $new_instance[ 'sweetspot' ];
121
+ $instance[ 'disablekb' ] = $new_instance[ 'disablekb' ];
122
+ $instance[ 'autohide' ] = $new_instance[ 'autohide' ];
123
+ $instance[ 'controls' ] = $new_instance[ 'controls' ];
124
+ $instance[ 'profile' ] = $new_instance[ 'profile' ];
125
+ $instance[ 'list' ] = $new_instance[ 'list' ];
126
+ $instance[ 'template' ] = $new_instance[ 'template' ];
127
+ $instance[ 'hd' ] = $new_instance[ 'hd' ];
128
+
129
+ return $instance;
130
+ }
131
+
132
+ /**
133
+ * Widget Admin control form
134
+ *
135
+ * Define admin file
136
+ *
137
+ * @since 2.0
138
+ *
139
+ * @param string $instance Instance
140
+ */
141
+
142
+ function form( $instance ) {
143
+ include( WP_PLUGIN_DIR . '/youtube-embed/includes/options-widgets.php' );
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Register Widget
149
+ *
150
+ * Register widget when loading the WP core
151
+ *
152
+ * @since 2.0
153
+ */
154
+
155
+ function youtube_embed_register_widgets() {
156
+ register_widget( 'YouTubeEmbedWidget' );
157
+ }
158
+ add_action( 'widgets_init', 'youtube_embed_register_widgets' );
159
+ }
160
+ ?>
js/mcebutton UNCOMPRESSED.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function() {
2
+ tinymce.create('tinymce.plugins.youtube', {
3
+ init : function(ed, url) {
4
+ ed.addButton('YouTube', {
5
+ title : 'YouTube Embed',
6
+ onclick : function() {
7
+ ed.selection.setContent('[youtube]' + ed.selection.getContent() + '[/youtube]');
8
+ }
9
+ });
10
+ },
11
+ createControl : function(n, cm) {
12
+ return null;
13
+ },
14
+ });
15
+ tinymce.PluginManager.add('YouTube', tinymce.plugins.youtube);
16
+ })();
js/mcebutton.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(){tinymce.create('tinymce.plugins.youtube',{init:function(ed,url){ed.addButton('YouTube',{title:'YouTube Embed',onclick:function(){ed.selection.setContent('[youtube]'+ed.selection.getContent()+'[/youtube]')}})},createControl:function(n,cm){return null},});tinymce.PluginManager.add('YouTube',tinymce.plugins.youtube)})();
mcebutton.js DELETED
@@ -1 +0,0 @@
1
- (function(){tinymce.create('tinymce.plugins.youtube',{init:function(ed,url){ed.addButton('YouTube',{title:'YouTube Embed',image:url+'/youtube.png',onclick:function(){ed.selection.setContent('[youtube]'+ed.selection.getContent()+'[/youtube]')}})},createControl:function(n,cm){return null},});tinymce.PluginManager.add('YouTube',tinymce.plugins.youtube)})();
 
readme.txt CHANGED
@@ -1,221 +1,269 @@
1
- === YouTube Embed ===
2
  Contributors: dartiss
3
  Donate link: http://artiss.co.uk/donate
4
- Tags: YouTube, embed, XHTML, video, playlist, thumbnail, EmbedPlus, widget, shortcode
5
- Requires at least: 2.8
6
- Tested up to: 3.1
7
- Stable tag: 1.5
8
 
9
- YouTube Embed is a powerful, but simple to use, method of embedding YouTube videos in your WordPress theme.
10
 
11
  == Description ==
12
 
13
- **If you have upgraded an existing version of this plugin to 1.4 or 1.4.1 or above you may find that your videos no longer appear. To resolve this please download 1.4.2 or above.**
14
 
15
- YouTube Embed is a powerful, but simple to use, method of embedding YouTube videos in your WordPress theme.
 
 
 
 
 
 
 
 
16
 
17
- It works with all the current YouTube API parameters, including HD video, and produces XHTML valid output. It also, unlike many other similar plugins, works with videos with certain characters within their ID (e.g. double dashes).
 
 
 
 
 
 
 
 
18
 
19
  **For help with this plugin, or simply to comment or get in touch, please read the appropriate section in "Other Notes" for details. This plugin, and all support, is supplied for free, but [donations](http://artiss.co.uk/donate "Donate") are always welcome.**
20
 
21
- Over the coming instructions I'll take you through the various ways to embed video, playlists and other YouTube related abilities.
22
 
23
- From version 1.4 this plugin also supports [EmbedPlus](http://embedplus.com/ "EmbedPlus"), which adds real-time reactions, chopping, movable zoom, slow motion, annotations, chapter / scene skipping, amongst others.
24
 
25
- There are 3 ways to embed a video - a function call (requires PHP coding, but can be placed anywhere), a short code (which can be easily placed in a post or page) or with a sidebar widget.
26
 
27
- A video will use the default settings which can be changed via the YouTube Embed options screen within your administration panel. However, you can also change any of these settings on a per-video basis. For a full list of the available parameters, please see the separate section.
28
 
29
- Let's go through each of the 3 methods in turn...
30
 
31
- **1. Function Call**
 
 
 
 
 
 
 
32
 
33
- For those with access (and the requirement) to their theme PHP, a function calls adds total flexibility as it can be added anywhere within your theme.
34
 
35
- `<?php if (function_exists('youtube_video_embed')) {youtube_video_embed('id','paras','style');} ?>`
 
 
 
 
36
 
37
- Where id is the video ID, paras is a list of parameters (more on this in a minute) and style (optional) is a list of stylesheet elements that you wish to apply to the resulting video.
38
 
39
- The parameters are supplied with an ampersand separating each. Here's an example where I override the height and width of a video...
 
 
 
 
 
 
40
 
41
- `<?php if (function_exists('youtube_video_embed')) {youtube_video_embed('id','width=100&height=200');} ?>`
42
 
43
- **2. Short Code**
 
 
 
44
 
45
- This is an easy one. Within any post or page, simply type the following...
46
 
47
- `[youtube]id[/youtube]`
48
 
49
- Where id is the ID of the video.
50
 
51
- If you wish to override any of the settings then these must be specified within the opening short code. So, to adjust the width and height, you'd put...
 
52
 
53
- `[youtube width=100 height=200]id[/youtube]`
54
 
55
- In this case, the width is 100px and the height is 200px. You may also specify a stylesheet override by using the `style` parameter. For example...
56
 
57
- `[youtube style="text-align:center"]id[/youtube]`
58
 
59
- This will centre the resulting video.
60
 
61
- **3. Widget**
62
 
63
- The widget is available from the Appearance->Widgets menu within Administration.
64
 
65
- Drag it to the appropriate sidebar and click on the down arrow to modify the default options. The options must be set as you have to specify the video ID and type (video or playlist).
66
 
67
- **EmbedPlus**
68
 
69
- To use EmbedPlus you can either set this on via the default options screen or, on an individual basis, use the parameter `embedplus`.
70
 
71
- For example, here is EmbedPlus being used for both a PHP function and a shortcode...
72
 
73
- `youtube_video_embed('id','width=100&height=200&embedplus=yes');
74
- [youtube width="100" height="200" embedplus="Yes"]id[/youtube]`
75
 
76
- When using the widget option, you can select EmbedPlus as the "type" of video, along with a standard video and a playlist.
77
 
78
- **Playlists**
79
 
80
- You can also embed playlists using any of the video embedding methods mentioned before.
81
 
82
- For function calls, simply use the function `youtube_playlist_embed`, with the same parameters as the video equivalent.
83
 
84
- For short codes, use the short code `[youtube_playlist]`, again with the same parameters as before.
85
 
86
- For the widget, simply change the "Type" option in the Widget options to "Playlist".
87
 
88
- In all cases you must specify a valid playlist ID, instead of the standard video ID.
89
 
90
- **Thumbnails**
91
 
92
- YouTube embed also has the ability to return a thumbnail of a video (sorry, this doesn't work with playlists).
93
 
94
- There are two methods you can use for this - a shortcode or a function call.
95
 
96
- Use the following function call to add a thumbnail to any part of your theme.
97
 
98
- `<?php if (function_exists('youtube_thumb_embed')) {youtube_thumb_embed('id','paras','style','alt');} ?>`
99
 
100
- Like the video embed equivalent, the ID is the video ID, the style is a list of stylesheet elements (but is optional) and alt is the alternative text for the thumbnail image (also optional). The parameters are different, however, but, again, are separated by ampersand.
101
 
102
- The parameters are as follows...
 
 
103
 
104
- * *rel* - specify a REL override, e.g. rel="nofollow"
105
- * *target* - specify a TARGET override, e.g. target="_blank"
106
- * *width* - this specifies the width of the thumbnail image
107
- * *height* - this specifies the height of the thumbnail image
108
 
109
- Here's an example, with parameters to specify the REL, TARGET and ALT elements.
110
 
111
- `<?php if (function_exists('youtube_thumb_embed')) {youtube_thumb_embed('id','rel=nofollow&target=_blank','','Demo Video');} ?>`
112
 
113
- To use the short code method, insert [youtube_thumb]id[/youtube_thumb] into a post or page to create a thumbnail of the relevant video ID which, once clicked, will open up the appropriate YouTube page.
114
 
115
- Like the function call above, you can specify a number of parameters. They are the same as detailed above but with the addition of two further parameters...
116
 
117
- * *style* - allows you to specify any stylesheet elements that you'd like applied
118
- * *alt* - specify some "ALT" text for the thumbnail image
119
 
120
- For example...
121
 
122
- `[youtube_thumb target="_blank" alt="Demo video"]id[/youtube_thumb]`
123
 
124
- This overrides the TARGET and ALT elements of the thumbnail.
125
 
126
- **Short URL**
127
 
128
- You may return a short URL for any YouTube video by way of either a function call or a shortcode.
129
 
130
- For a function call, add the following to your code to return a URL - note that this is not written out, but returned as a value. id is the video ID.
131
 
132
- `<?php if (function_exists('youtube_short_url')) {youtube_short_url('id');} ?>`
133
 
134
- So, an example may be...
135
 
136
- `<a href="<?php echo youtube_short_url('id'); ?>"Click here for video</a>`
137
 
138
- This will create a link to a video using the short URL standard.
139
 
140
- To use the shortcode method simply insert `[youtube_url]id[/youtube_url]` anywhere within a post or page to return a shortened URL. As with other examples, id is the ID of the video.
141
 
142
- **Transcripts**
143
 
144
- Some YouTube videos include transcripts - this is the speech from the video with timings. These are available in XML format and can, via a function call or shortcode, be displayed in your post/page.
145
 
146
- The shortcode `transcript` will display the transcript in your post/page, along with the start time for each line. Simply supply the video ID as a parameter. For example...
147
 
148
- `[transcript]id[/transcript]`
149
 
150
- If no transcript exists, nothing will be output.
151
 
152
- For style purposes, the `SPAN` around the time has a class of `TranscriptTime`, the `SPAN` around the text has a class of `TranscriptText` and the `DIV` around the whole transcript output has a class of `Transcript`.
153
 
154
- If you wish to use a PHP function call to get the transcript, then you would use the format...
155
 
156
- `get_youtube_transcript(ID)`
 
 
 
157
 
158
- In all of these cases, the original XML format has been changed to a readable output. If, though, you'd like to return the original XML format, then you can use the following call...
159
 
160
- `get_youtube_transcript_xml(ID)`
161
 
162
- **Video Download**
163
 
164
- If you wish your users to be able to download a YouTube video or playlist then you can do this via either a shortcode of PHP function call.
 
 
 
 
 
 
 
 
 
 
165
 
166
- The function call is named `get_video_download` or `get_playlist_download` and has one parameter - the video or playlist ID. It will return the download link URL.
167
 
168
- For example...
169
 
170
- `<a href="<?php get_video_download('id'); ?>">Download the video</a>`
171
 
172
- Alternatively, you can use the shortcode `download_video` or `download_playlist`. The content to link is specified between the open and close shortcode tags and there are 3 parameters...
173
 
174
- *id* - The ID of the video or playlist. This is required.
175
- *target* - The target of the link (e.g. `_blank`). This is optional.
176
- *nofollow* - This should be `Yes` or `No` to specify whether a `nofollow` tag should be added to the link. This is optional and by default it will be included.
177
 
178
- For example...
 
 
179
 
180
- `[download_video id="id" target="_blank"]Download the video[/download_video]`
 
 
 
 
181
 
182
- == Parameters ==
183
 
184
- The following parameters can be specified for any embedded YouTube video. Some of these will also work with playlists but, due to a lack of YouTube documentation on the subject, I'm unable to say which they are.
185
 
186
- The following work with a standard video/playlist and an EmbedPlus video...
187
 
188
- * *embedplus* - yes or no, whether you wish to use EmbedPlus
189
- * *hd* - yes or no, this determines whether a video defaults to HD quality, if available
190
- * *width* - the width of the video in pixels
191
- * *height* - the height of the video in pixels
192
- * *ratio* - if the height or width is omitted then it will be calculated with this ratio, in the format w:h (width:height) If this ratio is not supplied or is invalid it will be calculated using your default height and width settings. The ratio can only be specified via the shortcode or function call.
193
- * *fullscreen* - yes or no, this adds a button to the video player, allowing the video to be shown fullscreen
194
- * *start* - this can be specified if you wish for the video not to start at the beginning. Specify a number of seconds
195
 
196
- The following only work with the standard video/playlist embedding...
197
 
198
- * *color1* - this is 1 of 2 colors that can be used on the video player. It is in a hex RGB format, and should be 6 letters long.
199
- * *color2* - this is the second video player colour. Again, this is a hex RGB format.
200
- * *border* - yes or show, this is whether you wish the border to be shown
201
- * *autoplay* - yes or no, this specifies whether the video automatically starts to play
202
- * *loop* - yes or no, this specifies whether the video loops back to the beginning once it completes
203
- * *cc* - yes or no, this turns on or off closed captions (subtitles)
204
- * *annotation* - yes or no, this specifies whether you wish video annotations to be shown
205
- * *egm* - yes or no, this enables or disables the Enhanced Genie Menu
206
- * *related* - yes or no, this specifies whether you wish to display related videos
207
- * *info* - yes or no, this determines whether video information is shown
208
- * *search* - yes or no, determine whether search box should be shown
209
- * *link* - yes or no, this determines whether the video links back to YouTube
210
- * *disablekb* - yes or not, this is whether you wish the keyboard controls to be disabled or not
211
 
212
- The following are only valid with an EmbedPlus video...
213
 
214
- * *stop* - this stops the video at a specific time, given in seconds
215
- * *react* - yes or no, this specified whether you wish to show the Real-time Reactions button
216
- * *sweetspot* - yes or no, this will find sweet spots for the next/prev buttons
217
 
218
- For further details on these parameters (with the exception of those added by EmbedPlus), please read the [YouTube documentation](http://code.google.com/apis/youtube/player_parameters.html "YouTube Embedded Player Parameters").
 
 
 
 
 
 
 
 
 
 
 
219
 
220
  == Licence ==
221
 
@@ -227,9 +275,7 @@ All of my plugins are supported via [my website](http://www.artiss.co.uk "Artiss
227
 
228
  Please feel free to visit the site for plugin updates and development news - either visit the site regularly, follow [my news feed](http://www.artiss.co.uk/feed "RSS News Feed") or [follow me on Twitter](http://www.twitter.com/artiss_tech "Artiss.co.uk on Twitter") (@artiss_tech).
229
 
230
- For problems, suggestions or enhancements for this plugin, there is [a dedicated page](http://www.artiss.co.uk/youtube-embed "YouTube Embed") and [a forum](http://www.artiss.co.uk/forum "WordPress Plugins Forum"). The dedicated page will also list any known issues and planned enhancements.
231
-
232
- Alternatively, please [contact me directly](http://www.artiss.co.uk/contact "Contact Me").
233
 
234
  **This plugin, and all support, is supplied for free, but [donations](http://artiss.co.uk/donate "Donate") are always welcome.**
235
 
@@ -237,36 +283,75 @@ Alternatively, please [contact me directly](http://www.artiss.co.uk/contact "Con
237
 
238
  [New Technology Finds The Most Buzzed-About Parts Of Videos](http://www.socialtimes.com/2011/03/new-technology-finds-the-most-buzzed-about-parts-of-videos-interview/ "New Technology Finds The Most Buzzed-About Parts Of Videos") - SocialTimes.
239
 
 
 
 
 
 
 
240
  == Installation ==
241
 
242
- 1. Upload the entire `youtube-embed` folder to your `wp-content/plugins/` directory.
243
  2. Activate the plugin through the 'Plugins' menu in WordPress.
244
- 3. Visit the YouTube Embed options screen in your Administration menu and set the default parameters
245
- 4. If using the widget browse to `Appearance->Widgets`, add the widget and configure the options
246
 
247
  == Frequently Asked Questions ==
248
 
249
  = How do I find the ID of a YouTube video? =
250
 
251
- If you play a YouTube video, look at the URL - it will probably look something like this...
252
-
253
- `http://www.youtube.com/watch?v=L5Y4qzc_JTg`
254
 
255
  The video ID is the list of letters and numbers after `v=`, in this case `L5Y4qzc_JTg`.
256
 
257
- = I've installed another plugin which also uses the 'youtube' shortcode. How can I use yours too? =
 
 
 
 
 
 
 
 
 
 
258
 
259
- Jetpack is a good example of a plugin that can do this - install this and leave the "shortcodes" component active and this plugin may no longer appear to work for you.
260
 
261
- If the `youtube` shortcode has already been used, an additional code is now available - `youtube_video`. This does the same thing and has the same parameters.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
 
263
  = Which version of PHP does this plugin work with? =
264
 
265
  It has been tested and been found valid from PHP 4 upwards.
266
 
 
 
 
 
 
 
267
  == Screenshots ==
268
 
269
- 1. YouTube Embed admin screen, showing demonstration video
 
 
 
 
270
 
271
  == Changelog ==
272
 
@@ -309,6 +394,23 @@ It has been tested and been found valid from PHP 4 upwards.
309
  * Option to create a download link (for video and playlist) using function call or shortcode
310
  * You can now change on the options screen which set of parameters the demonstration video uses (i.e. "normal" or EmbedPlus). This allows you to try your options on a different video type without switching to it.
311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  == Upgrade Notice ==
313
 
314
  = 1.0 =
@@ -336,4 +438,7 @@ It has been tested and been found valid from PHP 4 upwards.
336
  * Upgrade is you upgraded to version 1.4 or 1.4.1 from a previous version, to fix an important bug
337
 
338
  = 1.5 =
339
- * Upgrade to add a number of new options including video size ratios, disabling keyboard controls, an editor button and different demonstration video options on the admin screen
 
 
 
1
+ === Artiss YouTube Embed ===
2
  Contributors: dartiss
3
  Donate link: http://artiss.co.uk/donate
4
+ Tags: admin, annotations, artiss, automatic, editor, embed, embedding, embedplus, flash, flv, google, hd, height, iframe, manage, media, plugin, page, play, playlist, post, profile, sidebar, simple, url, valid, video, widget,width, xhtml, youtube, youtuber
5
+ Requires at least: 2.9
6
+ Tested up to: 3.2.1
7
+ Stable tag: 2.0
8
 
9
+ A simple to use method of embedding YouTube videos into your posts and pages but with powerful features for those that need them.
10
 
11
  == Description ==
12
 
13
+ Artiss YouTube Embed (formally YouTube Embed) is an incredibly simple, yet powerful, method of embedding YouTube videos into your WordPress site. Options include:
14
 
15
+ * XHTML and HTML5 compliant - works with all the latest browsers
16
+ * Multiple embedding methods available - OBJECT, IFRAME and EmbedPlus
17
+ * Allow users to add videos to comments
18
+ * Build your own playlists and play them back however you want
19
+ * Create multiple profiles - use them for different videos to get the exact style that you want
20
+ * Google compatible metadata is added to the video output - great for SEO!
21
+ * Code is cached for maximum performance
22
+ * Using a different YouTube plugin? Documentation and tools are provided to help you migrate to Artiss YouTube Embed
23
+ * And much, much more!
24
 
25
+ To add a video to a post or page simply use the shortcode `[youtube]video[/youtube]`, where `video` is the ID or URL of the video. Alternatively, you can add one (or more) widgets to your sidebar.
26
+
27
+ Within the administration area of your blog you will find a new menu named `YouTube` (see screenshot 1). Click on the `Options` sub-menu to set a number of general options. Alternatively click on the `Profiles` sub-menu to set the default options which define the output of your videos - any videos you display (unless overridden by parameters - more on that later) will use the settings from the Profiles screen.
28
+
29
+ The above should get you started - for more information and advanced options please read the "Other Notes" tab. This also includes details on how to migrate from another embedding plugin to Artiss YouTube Embed.
30
+
31
+ Although this document contains a lot of information more is available from a series of linked pages, plus as much information as possible is provided on the various administration pages. Whilst on the administration pages, click on the "Help" button in the top right for some useful tips and links. If anything isn't covered and you're unsure of what it does please ask [on the forum](http://www.artiss.co.uk/forum "WordPress Plugins Forum").
32
+
33
+ Not yet convinced? [See the feature comparison](https://spreadsheets.google.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0AqxzQNe7e-NwdF80eUZuNjdtS1J1bWM4VERFVUN6ZHc&single=true&gid=4&output=html "YouTube Embed : Comparison") between this and the top 10 alternative plugins for embedding YouTube videos.
34
 
35
  **For help with this plugin, or simply to comment or get in touch, please read the appropriate section in "Other Notes" for details. This plugin, and all support, is supplied for free, but [donations](http://artiss.co.uk/donate "Donate") are always welcome.**
36
 
37
+ == Advanced embedding options ==
38
 
39
+ A basic shortcode will embed your video using your default profile settings. However, you may wish to override some of these options on a video-by-video basis - this is done via parameters added to the shortcode.
40
 
41
+ e.g. `[youtube width=300 height=200]Z_sCoHGIpU0[/youtube]`
42
 
43
+ Which options are available depends upon the embedding type you're using - you can specify any of them but, depending on the type, they may be ignored. There are 3 types - OBJECT, IFRAME and EmbedPlus. IFRAME is the current YouTube default and will use HTML 5, if available - this makes it ideal for maximum compatibility. However, HTML5 has a number of features that's not available with the standard Flash player.
44
 
45
+ The following parameters work with all embed types:
46
 
47
+ * **audio** - yes or no, this will hide the video and display just the toolbar (ideal for audio only playback) if switched on
48
+ * **height** - the video height, in pixels
49
+ * **list** - if you've specified your own list, use this to select the way the videos should be output. Should be `random` (display videos in a random order), `single` (show just one video, randomly picked from the list) or `order` (show each video in the original order - this is the default)
50
+ * **profile** - specify a different default profile (see section on Profiles for further details)
51
+ * **ratio** - allows you to define a window ratio - specify just a height or width and the ratio will calculate the missing dimension. Uses the format x:x, e.g. 4:3, 16:9
52
+ * **template** - specify a template (see section on Templates for further details)
53
+ * **type** - which embedding type to use, this can be `embedplus`, `iframe` or `object`
54
+ * **width** - the video width, in pixels
55
 
56
+ The following parameters will not work with EmbedPlus:
57
 
58
+ * **autohide** - 0, 1 or 2, this parameter indicates whether the video controls will automatically hide after a video begins playing. The default behaviour, a value of 2, is for the video progress bar to fade out while the player controls (play button, volume control, etc.) remain visible. If this parameter is set to 0, the video progress bar and the video player controls will be visible throughout the video. If this parameter is set to 1, then the video progress bar and the player controls will slide out of view a couple of seconds after the video starts playing. They will only reappear if the user moves her mouse over the video player or presses a key on her keyboard.
59
+ * **autoplay** - yes or no, should the video automatically start playing?
60
+ * **controls** - yes or no, should the controls be shown?
61
+ * **loop** - yes or no, whether to start the video again once it ends
62
+ * **start** - a number of seconds from where to start the video playing
63
 
64
+ The following parameters will not work with EmbedPlus or if IFRAME uses HTML5:
65
 
66
+ * **annotation** - yes or no, this determines if annotations are shown
67
+ * **cc** - yes or no, decided whether closed captions (subtitles) are displayed
68
+ * **disablekb** - yes or no, disable keyboard controls
69
+ * **fullscreen** - yes or no, this will add the fullscreen button to the toolbar. This also works with EmbedPlus.
70
+ * **info** - yes or no, show video information
71
+ * **link** - yes or no, link video to YouTube
72
+ * **related** - yes or no, show related videos
73
 
74
+ The following parameters are only for use with EmbedPlus:
75
 
76
+ * **hd** - play the video in HD quality, if available
77
+ * **react** - yes or no, this specified whether you wish to show the Real-time Reactions button
78
+ * **stop** - this stops the video at a specific time, given in seconds
79
+ * **sweetspot** - yes or no, this will find sweet spots for the next/prev buttons
80
 
81
+ == Alternative Shortcodes ==
82
 
83
+ Within administration, selecting `Options` from the `YouTube` menu will provide a list of general options. One section is named `Alternative Shortcodes` and allows you to specify 1 or 2 additional shortcodes - these will work exactly the same as the standard shortcode of `[youtube]`.
84
 
85
+ There are 2 reasons why you might want to do this...
86
 
87
+ 1. If migrating from another plugin, it may use a different shortcode - more details can be found in the section named "Migration"
88
+ 2. If another plugin uses the same shortcode (e.g. Jetpack) this will allow you to specify and use an alternative
89
 
90
+ Each of the new shortcodes can also have their own default profile assigned to them (see the Profiles section for more details on this).
91
 
92
+ == Function Call ==
93
 
94
+ As well as a shortcode you can also use a PHP function call to display a video (e.g. in a sidebar). The function is named `youtube_video_embed` and has 2 parameters - the first is the video ID (or URL) and the second is a list of display parameters. The display parameters are the same as those used in the shortcode but are separated by an ampersand.
95
 
96
+ e.g. `youtube_video_embed( 'Z_sCoHGIpU0', 'width=300&height=200' )`
97
 
98
+ == Widgets ==
99
 
100
+ Sidebar widgets can be easily added. In Administration simply click on the `Widgets` option under the `Appearance` menu. `YouTube Embed` will be one of the listed widgets. Drag it to the appropriate sidebar on the right hand side and then choose your video options - any that aren't specified are taken from your default profile.
101
 
102
+ And that's it! You can use unlimited widgets, so you can add different videos to different sidebars.
103
 
104
+ == Playlists ==
105
 
106
+ YouTube allows users to create their own playlists - collections of videos that can be played in sequence.
107
 
108
+ Before version 2 of Artiss YouTube Embed, separate shortcodes and function calls had to be used to specify these. However, now you can simply specify their ID or URL with the standard methods.
109
 
110
+ e.g. `[youtube]095393D5B42B2266[/youtube]`
 
111
 
112
+ Playlists cannot be used along with the EmbedPlus embedding method.
113
 
114
+ A better alternative to playlists is the build-in lists function in Artiss YouTube Embed - see the Lists section for further details.
115
 
116
+ == Templates ==
117
 
118
+ Both in the profile and as a parameter you can specify a template. This allows you to define any CSS that you wish to "wrap" around the YouTube output.
119
 
120
+ The template consists simply of any HTML that you wish but with `%video%` where you wish the video to appear.
121
 
122
+ e.g. `<div align="center">%video%</div>`
123
 
124
+ == Profiles ==
125
 
126
+ You've probably already had a look at the default profile, accessible by selecting `Profiles` from the `YouTube` administration menu option. Here you can specify the default option which will apply to any embedded video.
127
 
128
+ However, in the top right hand corner is a drop-down box and a button marked `Change profile`. Simply select an alternative profile and click the button and you can then edit the options for this alternative profile. You can even name it as well.
129
 
130
+ To use this profile, simply use the parameter `profile=` followed by the profile name or number. The options for this profile will then be used.
131
 
132
+ This could be useful, for instance, for having a separate profile for different parts of your site - posts, sidebar, etc - or for different video types (e.g. widescreen).
133
 
134
+ By default you have 5 extra profiles - if you wish to have more (or less) this number can be changed from the `Options` sub-menu.
135
 
136
+ == Lists ==
137
 
138
+ Although this plugin will play standard YouTube playlists their playback options are limited. Instead you can create your own video lists. Under the `YouTube` administration menu is a sub-menu named `Lists`. Select this and you will be shown a screen where you can type in a list of video IDs (or URLS). You can also provide a name for the list.
139
+
140
+ When saving the list each video is validated.
141
 
142
+ As with profiles you can select the list from a drop down in the top right-hand corner. You can also change the number of lists from the `Options` sub-menu too.
 
 
 
143
 
144
+ To use a list, simply specify the list name or number instead of a video ID.
145
 
146
+ e.g. `[youtube]List 1[/youtube]`
147
 
148
+ There is also a parameter, named `list`, that lets you modify the playback of the list. You can either play each in turn, play them randomly, or have just one played (but picked randomly).
149
 
150
+ == Transcripts ==
151
 
152
+ Some YouTube videos include transcripts - this is a text output of the speech from the video with timings added. These are available in XML format and can, via a function call or shortcode, be displayed in your post.
 
153
 
154
+ The shortcode `transcript` will display the transcript in your post along with the start time for each line. Simply supply the video ID as a parameter.
155
 
156
+ e.g. `[transcript]MSPsrhCPt-0[/transcript]`
157
 
158
+ If no transcript exists, nothing will be output.
159
 
160
+ For style purposes, the `SPAN` around the time has a class of `TranscriptTime`, the `SPAN` around the text has a class of `TranscriptText` and the `DIV` around the whole transcript output has a class of `Transcript`.
161
 
162
+ If you wish to use a PHP function call to get the transcript, then you would use the format `get_youtube_transcript( ID )`, where ID is the video ID.
163
 
164
+ In all of these cases, the original XML format has been changed to a readable output. If, though, you'd like to return the original XML format, then you can use the call `get_youtube_transcript_xml( ID )`.
165
 
166
+ == Migration ==
167
 
168
+ Within administration, selecting `Options` from the `YouTube` menu will provide a list of general options. One section is named `Migration`. There are 2 boxes that can be ticked to activate 2 different types of alternative embedding - these have been provided to allow easy migration from other similar plugins. You can also assign a specific profile to these migrated options.
169
 
170
+ The first option, `Bracket Embedding`, allows YouTube IDs to be assigned within brackets - similar to shortcodes but without the actual shortcode name. e.g. `[http://www.youtube.com/watch?v=Z_sCoHGIpU0]`.
171
 
172
+ The second option, `Alternative Embedding`, activates a short of other alternative embedding methods.
173
 
174
+ In both cases, activating these will impact performance so should only be used if absolutely necessary.
175
 
176
+ [Read more details](http://www.artiss.co.uk/artiss-youtube-embed/compatibility "Artiss YouTube Embed Compatibility") on which options to select for which plugin.
177
 
178
+ == Further options ==
179
 
180
+ **Thumbnails**
181
 
182
+ Artiss YouTube embed also has the ability to return a thumbnail of a video (sorry, this doesn't work with playlists). There are two methods you can use for this - a shortcode or a function call.
183
 
184
+ Use the function call `youtube_thumb_embed( 'id', 'paras', '', 'alt' )` to add a thumbnail to any part of your theme.
185
 
186
+ Like the video embed equivalent, the ID is the video ID and alt is the alternative text for the thumbnail image (optional). The parameters are different, however, but, again, are separated by ampersand.
187
 
188
+ The parameters are as follows...
189
 
190
+ * **rel** - specify a REL override, e.g. rel="nofollow"
191
+ * **target** - specify a TARGET override, e.g. target="_blank"
192
+ * **width** - this specifies the width of the thumbnail image
193
+ * **height** - this specifies the height of the thumbnail image
194
 
195
+ e.g. `youtube_thumb_embed( 'id', 'rel=nofollow&target=_blank', '', 'Demo Video' )`
196
 
197
+ To use the shortcode method, insert `[youtube_thumb]id[/youtube_thumb]` into a post or page to create a thumbnail of the relevant video ID which, once clicked, will open up the appropriate YouTube page.
198
 
199
+ Like the function call above, you can specify a number of parameters. They are the same as detailed above but with the addition of one further parameter...
200
 
201
+ * **alt** - specify some `ALT` text for the thumbnail image
202
+
203
+ e.g. `[youtube_thumb target="_blank" alt="Demo video"]id[/youtube_thumb]`
204
+
205
+ This overrides the `TARGET` and `ALT` elements of the thumbnail.
206
+
207
+ **Video name**
208
+
209
+ You can retrieve the name of a video via 1 of 2 methods.
210
+
211
+ You can call the PHP function `get_youtube_name`, passing it to the video URL or ID - this will return the name of the video.
212
 
213
+ e.g. `echo get_youtube_name( 'Z_sCoHGIpU0' );`
214
 
215
+ Alternatively, you can use the shortcode `[youtube_name]`, again passing the video URL or ID. The video name will be displayed.
216
 
217
+ e.g. `[youtube_name]Z_sCoHGIpU0[/youtube_name]`
218
 
219
+ **Shortened URL**
220
 
221
+ You may return a short URL for any YouTube video by way of either a function call or a shortcode.
222
+
223
+ For a function call add `youtube_short_url( 'id' )` to your code to return a URL (note that this is not written out, but returned as a value), where `id` is the video ID.
224
 
225
+ e.g. `<a href="<?php echo youtube_short_url( 'Z_sCoHGIpU0' ); ?>"Click here for video</a>`
226
+
227
+ This will create a link to a video using the short URL standard.
228
 
229
+ To use the shortcode method simply insert `[youtube_url id=xx]` anywhere within a post to return a shortened URL. `xx` is the ID of the video.
230
+
231
+ **Download URL**
232
+
233
+ If you wish your users to be able to download a YouTube video or playlist then you can do this via either a shortcode of PHP function call.
234
 
235
+ The function call is named `get_video_download` and has one parameter - the video ID. It will return the download link URL.
236
 
237
+ e.g. `<a href="<?php echo get_video_download( 'Z_sCoHGIpU0' ); ?>">Download the video</a>`
238
 
239
+ Alternatively, you can use the shortcode `download_video`. The content to link is specified between the open and close shortcode tags and there are 3 parameters...
240
 
241
+ * **id** - The ID of the video or playlist. This is required.
242
+ * **target** - The target of the link (e.g. `_blank`). This is optional.
243
+ * **nofollow** - yes or no, use this to specify whether a `nofollow` tag should be added to the link. This is optional and by default it will be included.
 
 
 
 
244
 
245
+ e.g. `[download_video id="Z_sCoHGIpU0" target="_blank"]Download the video[/download_video]`
246
 
247
+ **Caching**
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
+ Caches are used to improve plugin performance. Under the `YouTube` administration menu is a sub-menu named `Options`. Select this and find the section named `Performance`. From here there are 3 cache options...
250
 
251
+ 1. Embed Cache - this is how long to store the resulting cache code. It will update if you change any parameters so, theoretically, shouldn't need to change. It defaults to 24 hours.
252
+ 2. Video Information Cache - video IDs are checked with YouTube to ensure that they're valid. This option lets you to specify how often this should be checked. This defaults to 1 hour.
253
+ 3. Transcript Cache - how long to store transcripts. Defaults to 24 hours.
254
 
255
+ In all cases putting the cache to 0 will switch off caching for that option.
256
+
257
+ **Further Embedding Options**
258
+
259
+ Under the `YouTube` administration menu is a sub-menu named `Options`. Select this and find the section named `Embedding`. There are 4 options here...
260
+
261
+ 1. Add Metadata - by default, RDFa metadata is added to video output. This can be switched on or off as required (see the FAQs for more information about metadata usage).
262
+ 2. URL Embedding - if you place a YouTube URL directly into a post then WordPress will convert this to a video. This, however, is not performed by Artiss YouTube Embed. Select this option to allow this plugin to take over this functionality.
263
+ 3. Comment Embedding - tick this to allow YouTube URLs added to comments to be converted to embedded videos.
264
+ 4. Feed - videos will not appear in feeds so use this option to decide whether you want them to be converted to links and/or thumbnails.
265
+
266
+ In the case of URL and Comment embedding a profile can be selected.
267
 
268
  == Licence ==
269
 
275
 
276
  Please feel free to visit the site for plugin updates and development news - either visit the site regularly, follow [my news feed](http://www.artiss.co.uk/feed "RSS News Feed") or [follow me on Twitter](http://www.twitter.com/artiss_tech "Artiss.co.uk on Twitter") (@artiss_tech).
277
 
278
+ For problems, suggestions or enhancements for this plugin, there is [a dedicated page](http://www.artiss.co.uk/artiss-youtube-embed "Artiss YouTube Embed") and [a forum](http://www.artiss.co.uk/forum "WordPress Plugins Forum"). The dedicated page will also list any known issues and planned enhancements.
 
 
279
 
280
  **This plugin, and all support, is supplied for free, but [donations](http://artiss.co.uk/donate "Donate") are always welcome.**
281
 
283
 
284
  [New Technology Finds The Most Buzzed-About Parts Of Videos](http://www.socialtimes.com/2011/03/new-technology-finds-the-most-buzzed-about-parts-of-videos-interview/ "New Technology Finds The Most Buzzed-About Parts Of Videos") - SocialTimes.
285
 
286
+ [Andesch tips on WordPress plugins!](http://andershagstrom.se/andesch-tipsar-om-wordpress-plugins/ "Andesch tipsar om WordPress-plugins!") - Anders.
287
+
288
+ [Critical Mass](http://www.bikinginmemphis.com/2011/03/26/critical-mass/ "Critical Mass") - Biking in Memphis.
289
+
290
+ [Embedding YouTube Videos In Your WordPress Theme](http://frogenyozurt.com/2011/04/embedding-youtube-videos-in-your-wordpress-theme/ "Embedding YouTube Videos In Your WordPress Theme") - FrogenYozurt.Com.
291
+
292
  == Installation ==
293
 
294
+ 1. Upload the entire `youtube-embed`folder to your wp-content/plugins/ directory.
295
  2. Activate the plugin through the 'Plugins' menu in WordPress.
296
+ 3. That's it, you're done - you just need to add the shortcode wherever you need.
 
297
 
298
  == Frequently Asked Questions ==
299
 
300
  = How do I find the ID of a YouTube video? =
301
 
302
+ If you play a YouTube video, look at the URL - it will probably look something like this - `http://www.youtube.com/watch?v=L5Y4qzc_JTg`.
 
 
303
 
304
  The video ID is the list of letters and numbers after `v=`, in this case `L5Y4qzc_JTg`.
305
 
306
+ = Why can't I change the player colour as I used to? =
307
+
308
+ Artiss YouTube Embed is now using the latest version of the YouTube Player, named AS3. This does not allow for the player colour to be modified, and a few other options are now missing as well.
309
+
310
+ Equally, some options are not supported depending on whether you use the IFRAME or OBJECT embedding method.
311
+
312
+ [Read more about which options are supported](http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-api "API Support").
313
+
314
+ = I've upgraded from an earlier version of Artiss YouTube Embed and one of the functions / shortcodes / parameters that I used is no longer documented =
315
+
316
+ Code created for previous versions of the plugin should still work - however, the functions will not be documented to deter people from using them in the future.
317
 
318
+ = Is the generated code standards compliant? =
319
 
320
+ In all cases, yes. However, it depends on which options you choose as to which DOCTYPE it will validate to.
321
+
322
+ IFRAME does not work with XHTML so will only validate as XHTML transitional (this includes if you use IFRAME as the fallback to EmbedPlus).
323
+
324
+ If you include Metadata then you must use the XHTML Strict + RDFa DOCTYPE - in this case it validates.
325
+
326
+ If you don't include Metadata then it will also validate as HTML5 compliant.
327
+
328
+ The [W3C Markup Validation Service](http://validator.w3.org/ "W3C Markup Validation Service") was used to test the above.
329
+
330
+ You can [read more about this here](http://www.artiss.co.uk/artiss-youtube-embed/further-help#ye-standards "Standards Compliance").
331
+
332
+ = Which browsers does the output work on? =
333
+
334
+ It uses standard OBJECT and IFRAME coding - this, along with the above standards compliance, means that the output should work on most browsers.
335
+
336
+ However, I can confirm that it's been tested in IE7 (IE8 in compatibility mode), IE8, IE9, Firefox 5 and Chrome 12.
337
 
338
  = Which version of PHP does this plugin work with? =
339
 
340
  It has been tested and been found valid from PHP 4 upwards.
341
 
342
+ Please note, however, that the minimum for WordPress is now PHP 5.2.4. Even though this plugin supports a lower version, I am not coding specifically to achieve this - therefore this minimum may change in the future.
343
+
344
+ = A new box has appeared on my dashboard all about Artiss plugins =
345
+
346
+ That's correct - all Artiss plugins will now add this feature to keep you up-to-date with the latest plugin news and support links. If you wish to switch it off simply click on the "Screen Options" tab at the top and untick "Artiss Plugin News & Support".
347
+
348
  == Screenshots ==
349
 
350
+ 1. Artiss YouTube Embed in the administration menu.
351
+ 2. The main options screen.
352
+ 3. The profiles screen.
353
+ 4. The lists screen - videos have been added and validated. The drop-down help is also shown.
354
+ 5. The About screen
355
 
356
  == Changelog ==
357
 
394
  * Option to create a download link (for video and playlist) using function call or shortcode
395
  * You can now change on the options screen which set of parameters the demonstration video uses (i.e. "normal" or EmbedPlus). This allows you to try your options on a different video type without switching to it.
396
 
397
+ = 2.0 =
398
+ * Renamed to Artiss YouTube Embed from YouTube Embed
399
+ * Major re-write, using new coding standards
400
+ * New administration screens, introducing multiple profiles and playlists
401
+ * AS3 player is now used, AS2 has been retired. Both OBJECT and IFRAME versions can be selected
402
+ * Compliancy and browser checked - XHTML and HTML5 compliant and works in all the latest browsers
403
+ * Migration options added, allowing compatibility with other similar plugins
404
+ * Can now specify full video URL as well as video ID
405
+ * No need to use separate shortcode for playlists, as they are automatically detected. Video IDs are also now validated
406
+ * Options to allow YouTube URLs not within shortcodes to be accepted, as well as in comments
407
+ * RDFa metadata added to code output
408
+ * Caching of code and ID checking to improve performance
409
+ * Templating system replaces CSS specification
410
+ * README completely re-written, contextual help added to admin screens and links to further information
411
+ * Improved editor button and link added to admin bar
412
+ * Many, many more changes - too many to list!
413
+
414
  == Upgrade Notice ==
415
 
416
  = 1.0 =
438
  * Upgrade is you upgraded to version 1.4 or 1.4.1 from a previous version, to fix an important bug
439
 
440
  = 1.5 =
441
+ * Upgrade to add a number of new options including video size ratios, disabling keyboard controls, an editor button and different demonstration video options on the admin screen
442
+
443
+ = 2.0 =
444
+ * Upgrade to take advantage of many new features. Code completely re-written.
screenshot-1.png CHANGED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
screenshot-5.png ADDED
Binary file
uninstall.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uninstaller
4
+ *
5
+ * Uninstall the plugin by removing any options from the database
6
+ *
7
+ * @package YouTubeEmbed
8
+ * @since 2.0
9
+ */
10
+
11
+ // If the uninstall was not called by WordPress, exit
12
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
+ exit();
14
+ }
15
+
16
+ // Read the general options (will tell us how many profile and list options there should be
17
+ $options = get_option( 'youtube_embed_general' );
18
+
19
+ // If the general options existed, delete it!
20
+ if ( is_array( $options ) ) {
21
+ delete_option( 'youtube_embed_general' );
22
+
23
+ // If the number of profiles field exists, delete each one in turn
24
+ if ( array_key_exists( 'profile_no', $options ) ) {
25
+ $loop = 0;
26
+ while ( $loop <= $options[ 'profile_no' ] ) {
27
+ delete_option( 'youtube_embed_profile' . $loop );
28
+ $loop ++;
29
+ }
30
+ }
31
+
32
+ // If the number of lists field exists, delete each one in turn
33
+ if ( !array_key_exists( 'list_no', $options ) ) {
34
+ $loop = 1;
35
+ while ( $loop <= $options[ 'list_no' ] ) {
36
+ delete_option( 'youtube_embed_list' . $loop );
37
+ $loop ++;
38
+ }
39
+ }
40
+ }
41
+
42
+ // Delete all other options
43
+ delete_option( 'widget_youtube_embed_widget' );
44
+ delete_option( 'youtube_embed_shortcode' );
45
+ delete_option( 'youtube_embed_url' );
46
+ ?>
youtube-embed-options.php DELETED
@@ -1,240 +0,0 @@
1
- <div class="wrap">
2
- <?php screen_icon(); ?>
3
- <h2>YouTube Embed Options</h2>
4
- <?php
5
- // If options have been updated on screen, update the database
6
- if(!empty($_POST['Submit'])) {
7
- $options['width']=$_POST['youtube_embed_width'];
8
- $options['height']=$_POST['youtube_embed_height'];
9
- $options['border']=$_POST['youtube_embed_border'];
10
- $options['fullscreen']=$_POST['youtube_embed_fullscreen'];
11
- $options['hd']=$_POST['youtube_embed_hd'];
12
- $options['color1']=$_POST['youtube_embed_color1'];
13
- $options['color2']=$_POST['youtube_embed_color2'];
14
- $options['style']=$_POST['youtube_embed_style'];
15
- $options['autoplay']=$_POST['youtube_embed_autoplay'];
16
- $options['start']=$_POST['youtube_embed_start'];
17
- $options['loop']=$_POST['youtube_embed_loop'];
18
- $options['cc']=$_POST['youtube_embed_cc'];
19
- $options['annotation']=$_POST['youtube_embed_annotation'];
20
- $options['egm']=$_POST['youtube_embed_egm'];
21
- $options['related']=$_POST['youtube_embed_related'];
22
- $options['info']=$_POST['youtube_embed_info'];
23
- $options['search']=$_POST['youtube_embed_search'];
24
- $options['link']=$_POST['youtube_embed_link'];
25
- $options['react']=$_POST['youtube_embed_react'];
26
- $options['stop']=$_POST['youtube_embed_stop'];
27
- $options['sweetspot']=$_POST['youtube_embed_sweetspot'];
28
- $options['type']=$_POST['youtube_embed_type'];
29
- $options['disablekb']=$_POST['youtube_embed_disablekb'];
30
- update_option("youtube_embed",$options);
31
- $editor['youtube']=$_POST['youtube_embed_youtube_key'];
32
- update_option("youtube_embed_editor",$editor);
33
- }
34
-
35
- // Video option button has been pressed
36
- if(!empty($_POST['Video'])) {$video_type=$_POST['youtube_embed_video_type'];} else {$video_type="d";}
37
-
38
- // Fetch options into an array
39
- $options=get_option("youtube_embed");
40
- $editor=get_option("youtube_embed_editor");
41
-
42
- // Set defaults if no array is defined
43
- if (!is_array($options)) {
44
- echo "<div class=\"updated\"><p><strong>Please review the default options below and click \"Save Settings\" to update them.</strong></p></div>\n";
45
- $options=array('width'=>'425','height'=>'355','border'=>'0','fullscreen'=>'0','hd'=>'1','color1'=>'2b405b','color2'=>'6b8ab6','style'=>'','autoplay'=>'0','start'=>'0','loop'=>'0','cc'=>'0','annotation'=>'1','egm'=>'0','related'=>'0','info'=>'1','search'=>'1','link'=>'1','react'=>'1','stop'=>'0','sweetspot'=>'1','type'=>'v','disablekb'=>'0');
46
- }
47
- if (!is_array($editor)) {$editor=array('youtube'=>'1');}
48
-
49
- // Set default values for new options, if missing
50
- if ($options['link']=="") {$options['link']='1';}
51
- if ($options['react']=="") {$options['react']='1';}
52
- if ($options['stop']=="") {$options['stop']='0';}
53
- if ($options['sweetspot']=="") {$options['sweetspot']='1';}
54
- if ($options['type']=="") {$options['type']='v';}
55
- if ($options['disablekb']=="") {$options['disablekb']='0';}
56
- ?>
57
-
58
- <a href="http://embedplus.com/"><img src="<?php echo WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)); ?>embedplus.png" alt="EmbedPlus" title="EmbedPlus" align="right" /></a>
59
-
60
- <p><?php _e('These are the default settings for YouTube videos embedded with YouTube Embed.'); ?></p>
61
- <p><?php _e('Further details about these parameters can be found in <a href="http://code.google.com/apis/youtube/player_parameters.html">the official YouTube documentation</a> for normal embedded videos.'); ?></p>
62
- <p><?php _e('You can find about more information about EmbedPlus from <a href="http://embedplus.com/">their website</a>.'); ?></p>
63
- <p><?php _e('If you like this plugin, please <a href="http://www.artiss.co.uk/donate">consider donating</a>.'); ?></p>
64
-
65
- <form method="post" action="<?php echo get_bloginfo('wpurl').'/wp-admin/options-general.php?page=youtube-embed-settings&amp;updated=true' ?>">
66
- <table class="form-table">
67
-
68
- <tr valign="top">
69
- <th scope="row"><?php _e('Embed Type'); ?></th>
70
- <td><select name="youtube_embed_type">
71
- <option value="v"<?php if ($options['type']=="v") {echo " selected='selected'";} ?>><?php _e('Standard'); ?></option>
72
- <option value="m"<?php if ($options['type']=="m") {echo " selected='selected'";} ?>><?php _e('EmbedPlus'); ?></option>
73
- </select></td>
74
-
75
- <th scope="row"><?php _e('Default to HD Quality'); ?></th>
76
- <td colspan="2"><select name="youtube_embed_hd">
77
- <option value="0"<?php if ($options['hd']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
78
- <option value="1"<?php if ($options['hd']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
79
- </select> (if available)</td>
80
- </tr><tr>
81
-
82
- <th scope="row"><?php _e('Style Information'); ?></th>
83
- <td colspan="2"><input type="text" size="40" name="youtube_embed_style" value="<?php echo $options['style']; ?>"/> e.g. text-align:center</td>
84
- </tr><tr>
85
-
86
- <th scope="row"><?php _e('Width'); ?></th>
87
- <td><input type="text" size="3" maxlength="3" name="youtube_embed_width" value="<?php echo $options['width']; ?>"/>px</td>
88
-
89
- <th scope="row"><?php _e('Height'); ?></th>
90
- <td><input type="text" size="3" maxlength="3" name="youtube_embed_height" value="<?php echo $options['height']; ?>"/>px</td>
91
- </tr><tr>
92
-
93
- <th scope="row"><?php _e('Fullscreen Button'); ?></th>
94
- <td><select name="youtube_embed_fullscreen">
95
- <option value="0"<?php if ($options['fullscreen']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
96
- <option value="1"<?php if ($options['fullscreen']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
97
- </select></td>
98
-
99
- <th scope="row"><?php _e('Start'); ?></th>
100
- <td><input type="text" size="3" maxlength="3" name="youtube_embed_start" value="<?php echo $options['start']; ?>"/> seconds</td>
101
- </tr><tr>
102
-
103
- <th style="font-weight: bold" scope="row"><?php _e('Standard Video/Playlist Only'); ?></th>
104
- </tr><tr>
105
-
106
- <th scope="row"><?php _e('Color 1'); ?></th>
107
- <td>#<input type="text" size="6" maxlength="6" name="youtube_embed_color1" value="<?php echo $options['color1']; ?>"/>&nbsp;<span style="padding-right: 16px; background-color: #<?php echo $options['color1']; ?>">&nbsp;</span></td>
108
-
109
- <th scope="row"><?php _e('Color 2'); ?></th>
110
- <td>#<input type="text" size="6" maxlength="6" name="youtube_embed_color2" value="<?php echo $options['color2']; ?>"/>&nbsp;<span style="padding-right: 16px; background-color: #<?php echo $options['color2'] ?>">&nbsp;</span></td>
111
- </tr><tr>
112
-
113
- <th scope="row"><?php _e('Show Border'); ?></th>
114
- <td><select name="youtube_embed_border">
115
- <option value="0"<?php if ($options['border']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
116
- <option value="1"<?php if ($options['border']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
117
- </select></td>
118
-
119
- <th scope="row"><?php _e('Autoplay'); ?></th>
120
- <td><select name="youtube_embed_autoplay">
121
- <option value="0"<?php if ($options['autoplay']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
122
- <option value="1"<?php if ($options['autoplay']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
123
- </select></td>
124
- </tr><tr>
125
-
126
- <th scope="row"><?php _e('Loop Video'); ?></th>
127
- <td><select name="youtube_embed_loop">
128
- <option value="0"<?php if ($options['loop']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
129
- <option value="1"<?php if ($options['loop']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
130
- </select></td>
131
-
132
- <th scope="row"><?php _e('Show Closed Captions'); ?></th>
133
- <td><select name="youtube_embed_cc">
134
- <option value="0"<?php if ($options['cc']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
135
- <option value="1"<?php if ($options['cc']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
136
- </select></td>
137
- </tr><tr>
138
-
139
- <th scope="row"><?php _e('Show Annotations'); ?></th>
140
- <td><select name="youtube_embed_annotation">
141
- <option value="3"<?php if ($options['annotation']=="3") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
142
- <option value="1"<?php if ($options['annotation']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
143
- </select></td>
144
-
145
- <th scope="row"><?php _e('Enable Enhanced Genie Menu'); ?></th>
146
- <td><select name="youtube_embed_egm">
147
- <option value="0"<?php if ($options['egm']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
148
- <option value="1"<?php if ($options['egm']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
149
- </select></td>
150
- </tr><tr>
151
-
152
- <th scope="row"><?php _e('Show Related Videos'); ?></th>
153
- <td><select name="youtube_embed_related">
154
- <option value="0"<?php if ($options['related']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
155
- <option value="1"<?php if ($options['related']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
156
- </select></td>
157
-
158
- <th scope="row"><?php _e('Show Video Information'); ?></th>
159
- <td><select name="youtube_embed_info">
160
- <option value="0"<?php if ($options['info']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
161
- <option value="1"<?php if ($options['info']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
162
- </select></td>
163
- </tr><tr>
164
-
165
- <th scope="row"><?php _e('Show Search Box'); ?></th>
166
- <td><select name="youtube_embed_search">
167
- <option value="0"<?php if ($options['search']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
168
- <option value="1"<?php if ($options['search']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
169
- </select></td>
170
-
171
- <th scope="row"><?php _e('Link back to YouTube'); ?></th>
172
- <td><select name="youtube_embed_link">
173
- <option value="0"<?php if (($options['link']=="0")&&($options['link']!="")) {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
174
- <option value="1"<?php if (($options['link']=="1")or($options['link']=="")) {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
175
- </select></td>
176
- </tr><tr>
177
-
178
- <th scope="row"><?php _e('Disable Keyboard Controls'); ?></th>
179
- <td><select name="youtube_embed_disablekb">
180
- <option value="0"<?php if (($options['disablekb']=="0")&&($options['disablekb']!="")) {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
181
- <option value="1"<?php if (($options['disablekb']=="1")or($options['disablekb']=="")) {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
182
- </select></td>
183
- </tr><tr>
184
-
185
- <th style="font-weight: bold" scope="row"><?php _e('EmbedPlus Video Only'); ?></th>
186
- </tr><tr>
187
-
188
- <th scope="row"><?php _e('Stop'); ?></th>
189
- <td><input type="text" size="3" maxlength="3" name="youtube_embed_stop" value="<?php echo $options['stop']; ?>"/> seconds</td>
190
- </tr><tr>
191
-
192
- <th scope="row"><?php _e('Show Real-time Reactions Button'); ?></th>
193
- <td><select name="youtube_embed_react">
194
- <option value="1"<?php if ($options['react']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
195
- <option value="0"<?php if ($options['react']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
196
- </select></td>
197
-
198
- <th scope="row"><?php _e('Find Sweet Spots for Next/Prev Buttons'); ?></th>
199
- <td><select name="youtube_embed_sweetspot">
200
- <option value="1"<?php if ($options['sweetspot']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
201
- <option value="0"<?php if ($options['sweetspot']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
202
- </select></td>
203
- </tr><tr>
204
-
205
- <th style="font-weight: bold" scope="row"><?php _e('Editor Options'); ?></th>
206
- </tr><tr>
207
-
208
- <th scope="row"><?php _e('Show YouTube Button'); ?></th>
209
- <td><select name="youtube_embed_youtube_key">
210
- <option value="1"<?php if ($editor['youtube']=="1") {echo " selected='selected'";} ?>><?php _e('Yes'); ?></option>
211
- <option value="0"<?php if ($editor['youtube']=="0") {echo " selected='selected'";} ?>><?php _e('No'); ?></option>
212
- </select></td>
213
- </tr>
214
-
215
- </table>
216
- <p class="submit">
217
- <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Settings'); ?>"/>
218
- </p>
219
-
220
- <h3><?php _e('YouTube Video Sample'); ?></h3>
221
- <p><?php _e('This uses the above settings, once they have been saved. <b>Would you like this to be your video? If so, <a href="http://www.artiss.co.uk/contact">contact me</a>!</b>'); ?></p>
222
- <p><?php _e('Use the drop-down below to change which parameters the video uses - press the Change Video button to update it.</b>'); ?></p>
223
- <p><select name="youtube_embed_video_type">
224
- <option value="d"<?php if ($video_type=="d") {echo " selected='selected'";} ?>><?php _e('Default'); ?></option>
225
- <option value="p"<?php if ($video_type=="p") {echo " selected='selected'";} ?>><?php _e('EmbedPlus'); ?></option>
226
- </select>
227
- <input type="submit" name="Video" class="button-secondary" value="<?php _e('Change video'); ?>"/></p>
228
-
229
- <p><?php
230
- if ($video_type=="d") {$id='ru6219KIKS0'; $paras='';}
231
- if ($video_type=="p") {$id='YVvn8dpSAt0'; $paras='embedplus=yes';}
232
- youtube_video_embed($id,$paras);
233
- ?></p>
234
-
235
- </form>
236
-
237
- <h3><?php _e('Further Help'); ?></h3>
238
- <?php _e('<p>All of my plugins are supported via <a title="Artiss.co.uk" href="http://www.artiss.co.uk" target="_blank">my website</a>.</p><p>Please feel free to visit the site for plugin updates and development news - either visit the site regularly, follow <a title="RSS News Feed" href="http://www.artiss.co.uk/feed" target="_blank">my news feed</a> or <a title="Artiss.co.uk on Twitter" href="http://www.twitter.com/artiss_tech" target="_blank">follow me on Twitter</a> (@artiss_tech).</p><p>For problems, suggestions or enhancements for this plugin, there is <a title="YouTube Embed" href="http://www.artiss.co.uk/youtube-embed" target="_blank">a dedicated page</a> and <a title="WordPress Plugins Forum" href="http://www.artiss.co.uk/forum" target="_blank">a forum</a>. The dedicated page will also list any known issues and planned enhancements.</p><p>Alternatively, please <a title="Contact Me" href="http://www.artiss.co.uk/contact" target="_blank">contact me directly</a>.</p><p style="font-weight: bold">This plugin, and all support, is supplied for free, but <a title="Donate" href="http://artiss.co.uk/donate" target="_blank">donations</a> are always welcome.</p>'); ?>
239
- <p><a href="http://validator.w3.org"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31px" width="88px" style="float: right"/></a></p>
240
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
youtube-embed.php CHANGED
@@ -1,495 +1,82 @@
1
  <?php
2
  /*
3
- Plugin Name: YouTube Embed
4
- Plugin URI: http://www.artiss.co.uk/youtube-embed
5
  Description: Embed YouTube Videos in WordPress
6
- Version: 1.5
7
  Author: David Artiss
8
  Author URI: http://www.artiss.co.uk
9
  */
10
- define('youtube_embed_version','1.5');
11
 
12
- // Set up WordPress shortcodes and actions
13
- add_shortcode('youtube','youtube_video_sc');
14
- add_shortcode('youtube_video','youtube_video_sc');
15
- add_shortcode('youtube_playlist','youtube_playlist_sc');
16
- add_shortcode('youtube_thumb','youtube_thumbnail_sc');
17
- add_shortcode('youtube_url','youtube_url_sc');
18
- add_shortcode('transcript','youtube_transcript');
19
- add_shortcode('download_video','youtube_video_download');
20
- add_shortcode('download_playlist','youtube_playlist_download');
21
- add_action('admin_menu','youtube_embed_menu');
22
- add_action('init','youtube_button');
23
-
24
- /*
25
- Shortcodes
26
- */
27
-
28
- // Embed a YouTube video
29
- function youtube_video_sc($paras="",$content="") {
30
- extract(shortcode_atts(array('width'=>'','height'=>'','fullscreen'=>'','related'=>'','autoplay'=>'','loop'=>'','egm'=>'','border'=>'','color1'=>'','color2'=>'','start'=>'','hd'=>'','search'=>'','info'=>'','annotation'=>'','cc'=>'','style'=>'','link'=>'','react'=>'','stop'=>'','sweetspot'=>'','embedplus'=>'','disablekb'=>'','ratio'=>''),$paras));
31
- $embedplus=ye_convert($embedplus);
32
- if ($embedplus=="1") {$type="m";}
33
- if ($embedplus=="0") {$type="v";}
34
- $youtube_code=generate_youtube_code($content,$type,$width,$height,ye_convert($fullscreen),ye_convert($related),ye_convert($autoplay),ye_convert($loop),ye_convert($egm),ye_convert($border),$color1,$color2,$start,ye_convert($hd),ye_convert($search),ye_convert($info),ye_convert_3($annotation),ye_convert($cc),$style,ye_convert($link),ye_convert($react),$stop,ye_convert($sweetspot),ye_convert($disablekb),$ratio);
35
- return $youtube_code;
36
- }
37
-
38
- // Embed a YouTube playlist
39
- function youtube_playlist_sc($paras="",$content="") {
40
- extract(shortcode_atts(array('width'=>'','height'=>'','fullscreen'=>'','related'=>'','autoplay'=>'','loop'=>'','egm'=>'','border'=>'','color1'=>'','color2'=>'','start'=>'','hd'=>'','search'=>'','info'=>'','annotation'=>'','cc'=>'','style'=>'','link'=>'','react'=>'','stop'=>'','sweetspot'=>'','disablekb'=>'','ratio'=>''),$paras));
41
- return generate_youtube_code($content,"p",$width,$height,ye_convert($fullscreen),ye_convert($related),ye_convert($autoplay),ye_convert($loop),ye_convert($egm),ye_convert($border),$color1,$color2,$start,ye_convert($hd),ye_convert($search),ye_convert($info),ye_convert_3($annotation),ye_convert($cc),$style,ye_convert($link),ye_convert($react),$stop,ye_convert($sweetspot),ye_convert($disablekb),$ratio);
42
- }
43
-
44
- // Return a thumbnail URL
45
- function youtube_thumbnail_sc($paras="",$content="") {
46
- extract(shortcode_atts(array('style'=>'','class'=>'','rel'=>'','target'=>'','width'=>'','height'=>'','alt'=>''),$paras));
47
- return generate_thumbnail_code($content,$style,$class,$rel,$target,$width,$height,$alt);
48
- }
49
-
50
- // Return a short YouTube URL
51
- function youtube_url_sc($paras="",$content="") {
52
- if ($content=="") {return youtube_embed_error("No video ID has been supplied");} else {return "http://youtu.be/".$content;}
53
- }
54
-
55
- // Shortcode to return YouTube transcripts
56
- function youtube_transcript($paras="",$content="") {
57
- return get_youtube_transcript($content);
58
- }
59
-
60
- // Shortcode to show a link to download the video
61
- function youtube_video_download($paras="",$content="") {
62
- extract(shortcode_atts(array('id'=>'','target'=>'','nofollow'=>''),$paras));
63
- $link='<a href="'.get_video_download($id).'"';
64
- if ($target!="") {$link.=' target="'.$target.'"';}
65
- if (strtolower($nofollow)!="no") {$link.=' rel="nofollow"';}
66
- return $link.'>'.$content.'</a>';
67
- }
68
-
69
- // Shortcode to show a link to download the playlist
70
- function youtube_playlist_download($paras="",$content="") {
71
- extract(shortcode_atts(array('id'=>'','target'=>'','nofollow'=>''),$paras));
72
- $link='<a href="'.get_playlist_download($id);
73
- if ($target!="") {$link.=' target="'.$target.'"';}
74
- if (strtolower($nofollow)!="no") {$link.=' rel="nofollow"';}
75
- return $link.'">'.$content.'</a>';
76
- }
77
-
78
- /*
79
- Function calls
80
- */
81
-
82
- // Embed a YouTube video
83
- function youtube_video_embed($content,$paras="",$style="") {
84
- $width=youtube_get_parameters($paras,"width");
85
- $height=youtube_get_parameters($paras,"height");
86
- $fullscreen=youtube_get_parameters($paras,"fullscreen");
87
- $related=youtube_get_parameters($paras,"related");
88
- $autoplay=youtube_get_parameters($paras,"autoplay");
89
- $loop=youtube_get_parameters($paras,"loop");
90
- $egm=youtube_get_parameters($paras,"egm");
91
- $border=youtube_get_parameters($paras,"border");
92
- $color1=youtube_get_parameters($paras,"color1");
93
- $color2=youtube_get_parameters($paras,"color2");
94
- $start=youtube_get_parameters($paras,"start");
95
- $hd=youtube_get_parameters($paras,"hd");
96
- $search=youtube_get_parameters($paras,"search");
97
- $info=youtube_get_parameters($paras,"info");
98
- $annotation=youtube_get_parameters($paras,"annotation");
99
- $cc=youtube_get_parameters($paras,"cc");
100
- $link=youtube_get_parameters($paras,"link");
101
- $react=youtube_get_parameters($paras,"react");
102
- $stop=youtube_get_parameters($paras,"stop");
103
- $sweetspot=youtube_get_parameters($paras,"sweetspot");
104
- $embedplus=ye_convert(youtube_get_parameters($paras,"embedplus"));
105
- $disablekb=ye_convert(youtube_get_parameters($paras,"disablekb"));
106
- $ratio=youtube_get_parameters($paras,"ratio");
107
- if ($embedplus=="1") {$type="m";}
108
- if ($embedplus=="0") {$type="v";}
109
- echo generate_youtube_code($content,$type,$width,$height,ye_convert($fullscreen),ye_convert($related),ye_convert($autoplay),ye_convert($loop),ye_convert($egm),ye_convert($border),$color1,$color2,$start,ye_convert($hd),ye_convert($search),ye_convert($info),ye_convert_3($annotation),ye_convert($cc),$style,ye_convert($link),ye_convert($react),$stop,ye_convert($sweetspot),ye_convert($disablekb),$ratio);
110
- return;
111
- }
112
-
113
- // Embed a playlist
114
- function youtube_playlist_embed($content,$paras="",$style="") {
115
- youtube_video_embed($content,$paras="",$style="","p");
116
- return;
117
- }
118
-
119
- // Display a video thumbnail
120
- function youtube_thumb_embed($content,$paras="",$style="",$alt="") {
121
- $class=youtube_get_parameters($paras,"class");
122
- $rel=youtube_get_parameters($paras,"rel");
123
- $target=youtube_get_parameters($paras,"target");
124
- $width=youtube_get_parameters($paras,"width");
125
- $height=youtube_get_parameters($paras,"height");
126
- echo generate_thumbnail_code($content,$style,$class,$rel,$target,$width,$height,$alt);
127
- return;
128
- }
129
-
130
- // Display a short YouTube URL
131
- function youtube_short_url($id) {
132
- return "http://youtu.be/".$id;
133
- }
134
-
135
- // Return XML formatted YouTube transcript
136
- function get_youtube_transcript_xml($id="") {
137
- $return=youtube_get_file("http://video.google.com/timedtext?lang=en&v=".$id);
138
- if ($return['rc']<0) {return false;} else {return $return['file'];}
139
- }
140
-
141
- // Return YouTube video download URL
142
- function get_video_download($id="") {return "http://www.savevid.com/?url=http://www.youtube.com/watch?v=".$id;}
143
-
144
- // Return YouTube playlist download URL
145
- function get_playlist_download($id="") {return "http://www.savevid.com/?url=http://www.youtube.com/watch?p=".$id;}
146
-
147
- /*
148
- Admin Menu
149
- */
150
-
151
- function youtube_embed_menu() {
152
- add_options_page('YouTube Embed Settings','YouTube Embed',10, 'youtube-embed-settings', 'youtube_embed_options');
153
- }
154
-
155
- function youtube_embed_options() {
156
- include_once(WP_PLUGIN_DIR."/youtube-embed/youtube-embed-options.php");
157
- }
158
-
159
- /*
160
- Widgets
161
  */
162
 
163
- global $wp_version;
164
- if((float)$wp_version>=2.8){
165
-
166
- class YouTubeEmbedWidget extends WP_Widget {
167
 
168
- // Constructor
169
- function YouTubeEmbedWidget() {
170
- parent::WP_Widget('youtube_embed_widget', 'YouTube Embed', array('description' => 'Embed YouTube Widget.', 'class' => 'my-widget-class'));
171
- }
172
 
173
- // Display widget
174
- function widget($args, $instance) {
175
- extract($args, EXTR_SKIP);
176
- echo $before_widget;
177
- $title=$instance['titles'];
178
- $id=$instance['id'];
179
- if (!empty($title)) {echo $before_title.$title.$after_title;}
180
- echo generate_youtube_code($instance['id'],$instance['type'],$instance['width'],$instance['height'],$instance['fullscreen'],$instance['related'],$instance['autoplay'],$instance['loop'],$instance['egm'],$instance['border'],$instance['color1'],$instance['color2'],$instance['start'],$instance['hd'],$instance['search'],$instance['info'],$instance['annotation'],$instance['cc'],$instance['style'],$instance['link'],$instance['react'],$instance['stop'],$instance['sweetspot'],$instance['disablekb'],'');
181
- echo $after_widget;
182
- }
183
 
184
- // Update/save function
185
- function update($new_instance, $old_instance) {
186
- $instance=$old_instance;
187
- $instance['titles']=strip_tags($new_instance['titles']);
188
- $instance['id']=$new_instance['id'];
189
- $instance['type']=$new_instance['type'];
190
- $instance['width']=$new_instance['width'];
191
- $instance['height']=$new_instance['height'];
192
- $instance['border']=$new_instance['border'];
193
- $instance['fullscreen']=$new_instance['fullscreen'];
194
- $instance['hd']=$new_instance['hd'];
195
- $instance['color1']=$new_instance['color1'];
196
- $instance['color2']=$new_instance['color2'];
197
- $instance['style']=$new_instance['style'];
198
- $instance['autoplay']=$new_instance['autoplay'];
199
- $instance['start']=$new_instance['start'];
200
- $instance['loop']=$new_instance['loop'];
201
- $instance['cc']=$new_instance['cc'];
202
- $instance['annotation']=$new_instance['annotation'];
203
- $instance['egm']=$new_instance['egm'];
204
- $instance['related']=$new_instance['related'];
205
- $instance['info']=$new_instance['info'];
206
- $instance['search']=$new_instance['search'];
207
- $instance['link']=$new_instance['link'];
208
- $instance['react']=$new_instance['react'];
209
- $instance['stop']=$new_instance['stop'];
210
- $instance['sweetspot']=$new_instance['sweetspot'];
211
- $instance['disablekb']=$new_instance['disablekb'];
212
- return $instance;
213
- }
214
 
215
- // Admin control form
216
- function form($instance) {
217
- include_once(WP_PLUGIN_DIR."/youtube-embed/youtube-widget-options.php");
218
- }
219
- }
220
-
221
- // Register widget when loading the WP core
222
- add_action('widgets_init',youtube_embed_register_widgets);
223
- function youtube_embed_register_widgets() {register_widget('YouTubeEmbedWidget');}
224
- }
225
-
226
- /*
227
- Generate Embed code
228
- */
229
 
230
- // Generate XHTML compatible YouTube embed code
231
- function generate_youtube_code($id,$type,$width,$height,$fullscreen,$related,$autoplay,$loop,$egm,$border,$color1,$color2,$start,$hd,$search,$info,$annotation,$cc,$style,$link,$react,$stop,$sweetspot,$disablekb,$ratio) {
232
 
233
- // Ensure an ID is passed
234
- if (($id=="")&&(strtolower($widget)!="yes")) {
235
- return youtube_embed_error("No video/playlist ID has been supplied");
236
- } else {
237
 
238
- // Get default values if no values are supplied
239
- $options=get_option("youtube_embed");
240
- if (!is_array($options)) {
241
- $options=array('width'=>'425','height'=>'355','border'=>'0','fullscreen'=>'0','hd'=>'1','color1'=>'2b405b','color2'=>'6b8ab6','style'=>'','autoplay'=>'0','start'=>'0','loop'=>'0','cc'=>'0','annotation'=>'1','egm'=>'0','related'=>'0','info'=>'1','search'=>'1','link'=>'1','react'=>'1','stop'=>'0','sweetspot'=>'1','type'=>'v','disablekb'=>'0');
242
- }
243
- if (($width=="")&&($height=="")) {
244
- $width=$options['width'];
245
- $height=$options['height'];
246
- }
247
- if ($fullscreen=="") {$fullscreen=$options['fullscreen'];}
248
- if ($related=="") {$related=$options['related'];}
249
- if ($autoplay=="") {$autoplay=$options['autoplay'];}
250
- if ($loop=="") {$loop=$options['loop'];}
251
- if ($egm=="") {$egm=$options['egm'];}
252
- if ($border=="") {$border=$options['border'];}
253
- if ($color1=="") {$color1=$options['color1'];}
254
- if ($color2=="") {$color2=$options['color2'];}
255
- if ($start=="") {$start=$options['start'];}
256
- if ($hd=="") {$hd=$options['hd'];}
257
- if ($search=="") {$search=$options['search'];}
258
- if ($info=="") {$info=$options['info'];}
259
- if ($annotation=="") {$annotation=$options['annotation'];}
260
- if ($cc=="") {$cc=$options['cc'];}
261
- if ($style=="") {$style=$options['style'];}
262
- if ($link=="") {$link=$options['link'];}
263
- if ($react=="") {$react=$options['react'];}
264
- if ($stop=="") {$stop=$options['stop'];}
265
- if ($sweetspot=="") {$sweetspot=$options['sweetspot'];}
266
- if ($type=="") {$type=$options['type'];}
267
- if ($disablekb=="") {$disablekb=$options['disablekb'];}
268
 
269
- // Set default values for new options, if missing
270
- if ($link=="") {$link='1';}
271
- if ($react=="") {$react='1';}
272
- if ($stop=="") {$stop='0';}
273
- if ($sweetspot=="") {$sweetspot='1';}
274
- if ($type=="") {$type='v';}
275
- if ($disablekb=="") {$disablekb='0';}
276
 
277
- // If height or width is missing, calculate missing parameter using ratio
278
- if ((($width=="")or($height==""))&&(($width!="")or($height!=""))) {
279
- if ($ratio!="") {
280
- // Extract the ratio from the provided string
281
- $ratio_to_use="";
282
- $pos=strpos($ratio,":",0);
283
- if ($pos!==false) {
284
- $ratio_l=substr($ratio,0,$pos);
285
- $ratio_r=substr($ratio,$pos+1);
286
- if ((is_numeric($ratio_l))&&(is_numeric($ratio_r))) {$ratio_to_use=$ratio_l/$ratio_r;}
287
- }
288
- }
289
 
290
- // If no, or invalid, ratio supplied, calculate from the default video dimensions
291
- if ($ratio_to_use=="") {$ratio_to_use=$options['width']/$options['height'];}
292
 
293
- // Complete the missing width or height using the ratio
294
- if ($width=="") {$width=round($height*$ratio_to_use,0);}
295
- if ($height=="") {$height=round($width/$ratio_to_use,0);}
296
- }
297
 
298
- // Set up EmbedPlus
299
- if ($type=="m") {
300
- $type="v";
301
- $embedplus=true;
302
- $tab="\t";
303
- $embedheight=$height+32;
304
- $objectclass=' class="cantembedplus"';
305
- } else {
306
- $embedplus=false;
307
- $tab="";
308
- $objectclass="";
309
- }
310
 
311
- // Convert video ID characters
312
- $id=str_replace("&#8211;","--",$id);
313
- $id=str_replace("&#215;","x",$id);
314
 
315
- // Generate parameters to add to URL
316
- $paras="&amp;fs=".$fullscreen."&amp;rel=".$related."&amp;autoplay=".$autoplay."&amp;loop=".$loop."&amp;egm=".$egm."&amp;border=".$border."&amp;color1=0x".$color1."&amp;color2=0x".$color2."&amp;hd=".$hd."&amp;showsearch=".$search."&amp;showinfo=".$info."&amp;iv_load_policy=".$annotation."&amp;cc_load_policy=".$cc."&amp;disablekb=".$disablekb;
317
- $paras_ep="&amp;width=".$width."&amp;height=".$height."&amp;hd=".$hd."&amp;react=".$react."&amp;sweetspot=".$sweetspot;
318
- if ($start!=0) {$paras.="&amp;start=".$start; $paras_ep.="&amp;start=".$start;}
319
- if ($stop!=0) {$paras_ep.="&amp;stop=".$stop;}
 
 
 
 
 
 
320
 
321
- // Code header
322
- $result="<!-- YouTube Embed v".youtube_embed_version." | http://www.artiss.co.uk/youtube-embed -->\n";
323
- if ($style!="") {$result.="<div style=\"".$style."\">\n";}
324
-
325
- // Add EmbedPlus code (if required)
326
- if ($embedplus) {
327
- $result.="<object type=\"application/x-shockwave-flash\" width=\"".$width."\" height=\"".$embedheight."\" data=\"http://getembedplus.com/embedplus.swf\">\n";
328
- $result.="<param value=\"http://getembedplus.com/embedplus.swf\" name=\"movie\" />\n";
329
- $result.="<param value=\"high\" name=\"quality\" />\n";
330
- $result.="<param value=\"transparent\" name=\"wmode\" />\n";
331
- $result.="<param value=\"always\" name=\"allowscriptaccess\" />\n";
332
- if ($fullscreen==1) {$result.="<param name=\"allowFullScreen\" value=\"true\" />\n";}
333
- $result.="<param name=\"flashvars\" value=\"ytid=".$id.$paras_ep."\" />\n";
334
- }
335
-
336
- // Add standard YouTube embed code
337
- $result.=$tab."<object".$objectclass." type=\"application/x-shockwave-flash\" data=\"http://www.youtube.com/".$type."/".$id.$paras."\" width=\"".$width."\" height=\"".$height."\" wmode=\"transparent\">\n";
338
- $result.=$tab."<param name=\"movie\" value=\"http://www.youtube.com/".$type."/".$id.$paras."\" />\n";
339
- $result.=$tab."<param name=\"wmode\" value=\"transparent\" />\n";
340
- if ($fullscreen==1) {$result.=$tab."<param name=\"allowFullScreen\" value=\"true\" />\n";}
341
- if (($link!=1)&&($link!="")) {$result.=$tab."<param name=\"allowNetworking\" value=\"internal\" />\n";}
342
-
343
- // Code footer
344
- $result.=$tab."</object>\n";
345
- if ($embedplus) {$result.="</object>\n<!--[if lte IE 6]> <style type=\"text/css\">.cantembedplus{display:none;}</style><![endif]-->\n";}
346
- if ($style!="") {$result.="</div>\n";}
347
- $result.="<!-- End of YouTube Embed code -->\n";
348
- return $result;
349
- }
350
- }
351
-
352
- // Generate XHTML compatible YouTube video thumbnail
353
- function generate_thumbnail_code($id,$style,$class,$rel,$target,$width,$height,$alt) {
354
- if ($alt=="") {$alt="YouTube Video ".$id;}
355
- $youtube_code="<a href=\"http://www.youtube.com/watch?v=".$id."\"";
356
- if ($style!="") {$youtube_code=$youtube_code." style=\"".$style."\"";}
357
- if ($class!="") {$youtube_code=$youtube_code." class=\"".$class."\"";}
358
- if ($rel!="") {$youtube_code=$youtube_code." rel=\"".$rel."\"";}
359
- if ($target!="") {$youtube_code=$youtube_code." target=\"".$target."\"";}
360
- $youtube_code=$youtube_code."><img src=\"http://img.youtube.com/vi/".$id."/2.jpg\"";
361
- if ($width!="") {$youtube_code=$youtube_code." width=\"".$width."px\"";}
362
- if ($height!="") {$youtube_code=$youtube_code." height=\"".$height."px\"";}
363
- $youtube_code=$youtube_code." alt=\"".$alt."\"";
364
- return $youtube_code."/></a>";
365
  }
366
 
367
- // Generate re-encoded YouTube transcript
368
- function get_youtube_transcript($id) {
369
-
370
- // Get transcript file
371
- $return=youtube_get_file("http://video.google.com/timedtext?lang=en&v=".$id);
372
- $xml=$return['file'];
373
- $output="";
374
-
375
- // If transcript file exists, strip and output
376
- if ($return['rc']>0) {
377
- $output="<!-- YouTube Embed v".youtube_embed_version." | http://www.artiss.co.uk/youtube-embed -->\n";
378
- $pos=0;
379
- $eof=false;
380
- while (!$eof) {
381
- $text_start=strpos($xml,"<text ",$pos);
382
- if ($text_start!==false) {
383
-
384
- // Extract the start time
385
- $start_start=strpos($xml,'start="',$text_start)+7;
386
- $start_end=strpos($xml,'"',$start_start)-1;
387
- $start=substr($xml,$start_start,$start_end-$start_start+1);
388
-
389
- // Convert time format
390
- $start=str_pad(floor($start),3,"0",STR_PAD_LEFT);
391
- $start=substr($start,0,-2).":".substr($start,-2,2);
392
- // Now extract the text
393
- $text_start=strpos($xml,">",$text_start)+1;
394
- $text_end=strpos($xml,"</text>",$text_start)-1;
395
- $text=substr($xml,$text_start,$text_end-$text_start+1);
396
 
397
- // Now return the output
398
- $output.="<div class=\"Transcript\"><span class=\"TranscriptTime\">".$start."</span> <span class=\"TranscriptText\">".htmlspecialchars_decode($text)."</span></div>";
399
- $pos=$text_end+7;
400
- } else {
401
- $eof=true;
402
- }
403
- }
404
- $output.="<!-- End of YouTube Embed code -->\n";
405
- }
406
- return $output;
407
- }
408
-
409
- /*
410
- Editor Button
411
- */
412
-
413
- function youtube_button() {
414
- if ((!current_user_can('edit_posts'))&&(!current_user_can('edit_pages'))) {return;}
415
- $editor=get_option("youtube_embed_editor");
416
- if ((get_user_option('rich_editing')=='true')&&($editor['youtube']!="0")) {
417
- add_filter('mce_external_plugins','add_youtube_mce_plugin');
418
- add_filter('mce_buttons','register_youtube_button');
419
- }
420
- }
421
-
422
- // Register button
423
- function register_youtube_button($buttons) {
424
- array_push($buttons,"|","YouTube");
425
- return $buttons;
426
- }
427
-
428
- // Register TinyMCE Plugin
429
- function add_youtube_mce_plugin( $plugin_array ) {
430
- $plugin_array['YouTube']=WP_PLUGIN_URL.'/youtube-embed/mcebutton.js';
431
- return $plugin_array;
432
- }
433
-
434
- /*
435
- Shared Functions
436
  */
437
 
438
- // Function to extract parameters from an input string (1.0)
439
- function youtube_get_parameters($input,$para) {
440
- $start=strpos(strtolower($input),$para."=");
441
- $content="";
442
- if ($start!==false) {
443
- $start=$start+strlen($para)+1;
444
- $end=strpos(strtolower($input),"&",$start);
445
- if ($end!==false) {$end=$end-1;} else {$end=strlen($input);}
446
- $content=substr($input,$start,$end-$start+1);
447
- }
448
- return $content;
449
- }
450
-
451
- // Function to report an error
452
- function youtube_embed_error($errorin) {return "<p style=\"color: #f00; font-weight: bold;\">YouTube Embed: ".$errorin."</p>\n";}
453
-
454
- // Function to convert a Yes or No input to an equivalent 1 or 0 output
455
- function ye_convert($input) {
456
- $input=strtolower($input);
457
- $output="";
458
- if (($input=="yes")or($input=="1")) {$output="1";}
459
- if (($input=="no")or($input=="0")) {$output="0";}
460
- return $output;
461
- }
462
-
463
- // Function to convert a Yes or No input to an equivalent 1 or 3 output
464
- function ye_convert_3($input) {
465
- $input=strtolower($input);
466
- $output="";
467
- if (($input=="yes")or($input=="1")) {$output="1";}
468
- if (($input=="no")or($input=="3")) {$output="3";}
469
- return $output;
470
- }
471
-
472
- // Function to get a file using CURL or alternative (1.4)
473
- function youtube_get_file($filein) {
474
- $fileout="";
475
- // Try to get with CURL, if installed
476
- if (in_array('curl',get_loaded_extensions())===true) {
477
- $cURL = curl_init();
478
- curl_setopt($cURL,CURLOPT_URL,$filein);
479
- curl_setopt($cURL,CURLOPT_RETURNTRANSFER,1);
480
- $fileout=curl_exec($cURL);
481
- curl_close($cURL);
482
- if ($fileout=="") {$rc=-1;} else {$rc=1;}
483
- }
484
- // If CURL failed and a url_fopen is allowed, use that
485
- $fopen_status=strtolower(ini_get('allow_url_fopen'));
486
- if (($fileout=="")&&(($fopen_status===true)or($fopen_status=="yes")or($fopen_status=="on")or($fopen_status=="1"))) {
487
- $fileout=file_get_contents($filein);
488
- if ($fileout=="") {$rc=-2;} else {$rc=2;}
489
- }
490
- if ((in_array('curl',get_loaded_extensions())!==true)&&(ini_get('allow_url_fopen')==1)) {$rc==-3;}
491
- $file_return['file']=$fileout;
492
- $file_return['rc']=$rc;
493
- return $file_return;
494
  }
495
  ?>
1
  <?php
2
  /*
3
+ Plugin Name: Artiss YouTube Embed
4
+ Plugin URI: http://www.artiss.co.uk/artiss-youtube-embed
5
  Description: Embed YouTube Videos in WordPress
6
+ Version: 2.0
7
  Author: David Artiss
8
  Author URI: http://www.artiss.co.uk
9
  */
 
10
 
11
+ /**
12
+ * YouTube Embed
13
+ *
14
+ * Main code - include various functions
15
+ *
16
+ * @package YouTubeEmbed
17
+ * @since 2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  */
19
 
20
+ define( 'youtube_embed_version', '2.0' );
 
 
 
21
 
22
+ $functions_dir = WP_PLUGIN_DIR . '/youtube-embed/includes/';
 
 
 
23
 
24
+ // Include all the various functions
 
 
 
 
 
 
 
 
 
25
 
26
+ include_once( $functions_dir . 'shared.php' ); // Shared routines
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
+ include_once( $functions_dir . 'set-option-defaults.php' ); // Set default options
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
+ include_once( $functions_dir . 'admin-bar.php' ); // Admin bar
 
31
 
32
+ include_once( $functions_dir . 'generate-embed-code.php' ); // Generate YouTube embed code
 
 
 
33
 
34
+ if ( is_admin() ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ include_once( $functions_dir . 'admin-menu.php' ); // Administration menus
 
 
 
 
 
 
37
 
38
+ include_once( $functions_dir . 'mcebutton.php' ); // Editor button
39
+
40
+ if ( !has_action( 'wp_dashboard_setup', 'artiss_dashboard_widget' ) ) {
 
 
 
 
 
 
 
 
 
41
 
42
+ include_once( $functions_dir . 'artiss-dashboard-widget.php' ); // Artiss dashboard widget
 
43
 
44
+ }
 
 
 
45
 
46
+ } else {
47
+
48
+ include_once( $functions_dir . 'content.php' ); // Process post content
 
 
 
 
 
 
 
 
 
49
 
50
+ include_once( $functions_dir . 'function-calls.php' ); // Function calls
 
 
51
 
52
+ include_once( $functions_dir . 'generate-download-code.php' ); // Generate download URLs
53
+
54
+ include_once( $functions_dir . 'generate-shorturl-code.php' ); // Generate short URLs
55
+
56
+ include_once( $functions_dir . 'generate-thumbnail-code.php' ); // Generate thumbnail code
57
+
58
+ include_once( $functions_dir . 'generate-transcript-code.php' ); // Generate transcripts
59
+
60
+ include_once( $functions_dir . 'shortcodes.php' ); // Shortcodes
61
+
62
+ include_once( $functions_dir . 'deprecated.php' ); // Deprecated options
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
 
66
+ include_once($functions_dir . 'widgets.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
+ /**
69
+ * Output some useful debug information
70
+ *
71
+ * Quick debug task to output version number and plugin directory, in case of queries
72
+ *
73
+ * @since 2.0
74
+ *
75
+ * @return string Plugin version and plugin directory, seperated by double colons
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  */
77
 
78
+ if ( !is_admin() ) {
79
+ function ye_debug( $paras = '', $content = '' ) { echo youtube_embed_version . ' :: ' . WP_PLUGIN_DIR; }
80
+ add_shortcode( 'ye-debug', 'ye_debug' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
  ?>
youtube-widget-options.php DELETED
@@ -1,170 +0,0 @@
1
- <?php
2
- $default=array('titles'=>'YouTube','id'=>'','type'=>'v','width'=>'170','height'=>'142','border'=>'0','fullscreen'=>'0','hd'=>'1','color1'=>'2b405b','color2'=>'6b8ab6','style'=>'','autoplay'=>'0','start'=>'0','loop'=>'0','cc'=>'0','annotation'=>'1','egm'=>'0','related'=>'0','info'=>'1','search'=>'1','link'=>'1','react'=>'1','stop'=>'0','sweetspot'=>'1','disablekb'=>'0');
3
- $instance=wp_parse_args( (array) $instance, $default);
4
-
5
- $field_id=$this->get_field_id('titles');
6
- $field_name=$this->get_field_name('titles');
7
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title').': </label><input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['titles'] ).'" /></p>';
8
-
9
- $field_id=$this->get_field_id('id');
10
- $field_name=$this->get_field_name('id');
11
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Video ID').': </label><input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['id'] ).'" /></p>';
12
-
13
- $field_id=$this->get_field_id('type');
14
- $field_name=$this->get_field_name('type');
15
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Embed Type').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="v"';
16
- if (attribute_escape( $instance['type'] )=="v") {echo " selected='selected'";}
17
- echo '>'.__('Video (Standard)').'</option><option value="m"';
18
- if (attribute_escape( $instance['type'] )=="m") {echo " selected='selected'";}
19
- echo '>'.__('Video (EmbedPlus)').'</option><option value="p"';
20
- if (attribute_escape( $instance['type'] )=="p") {echo " selected='selected'";}
21
- echo '>'.__('Playlist').'</option></select></p>';
22
-
23
- $field_id=$this->get_field_id('hd');
24
- $field_name=$this->get_field_name('hd');
25
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Default to HD Quality').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
26
- if (attribute_escape( $instance['hd'] )=="1") {echo " selected='selected'";}
27
- echo '>'.__('Yes').'</option><option value="0"';
28
- if (attribute_escape( $instance['hd'] )=="0") {echo " selected='selected'";}
29
- echo '>'.__('No').'</option></select></p>';
30
-
31
- $field_id=$this->get_field_id('style');
32
- $field_name=$this->get_field_name('style');
33
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Style').': </label><input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['style'] ).'" /></p>';
34
-
35
- $field_id=$this->get_field_id('width');
36
- $field_name=$this->get_field_name('width');
37
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Width').': </label><input type="text" size="3" maxlength="3" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['width'] ).'" />px</p>';
38
-
39
- $field_id=$this->get_field_id('height');
40
- $field_name=$this->get_field_name('height');
41
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Height').': </label><input type="text" size="3" maxlength="3" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['height'] ).'" />px</p>';
42
-
43
- $field_id=$this->get_field_id('fullscreen');
44
- $field_name=$this->get_field_name('fullscreen');
45
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Fullscreen Button').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
46
- if (attribute_escape( $instance['fullscreen'] )=="1") {echo " selected='selected'";}
47
- echo '>'.__('Yes').'</option><option value="0"';
48
- if (attribute_escape( $instance['fullscreen'] )=="0") {echo " selected='selected'";}
49
- echo '>'.__('No').'</option></select></p>';
50
-
51
- $field_id=$this->get_field_id('start');
52
- $field_name=$this->get_field_name('start');
53
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Start').': </label><input type="text" size="3" maxlength="3" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['start'] ).'" /> seconds</p>';
54
-
55
- ?>
56
- <h3><?php _e('Standard Video/Playlist Only'); ?></h3>
57
- <?php
58
-
59
- $field_id=$this->get_field_id('border');
60
- $field_name=$this->get_field_name('border');
61
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Border').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
62
- if (attribute_escape( $instance['border'] )=="1") {echo " selected='selected'";}
63
- echo '>'.__('Yes').'</option><option value="0"';
64
- if (attribute_escape( $instance['border'] )=="0") {echo " selected='selected'";}
65
- echo '>'.__('No').'</option></select></p>';
66
-
67
- $field_id=$this->get_field_id('color1');
68
- $field_name=$this->get_field_name('color1');
69
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Color 1').': #</label><input type="text" size="6" maxlength="6" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['color1'] ).'" /></p>';
70
-
71
- $field_id=$this->get_field_id('color2');
72
- $field_name=$this->get_field_name('color2');
73
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Color 2').': #</label><input type="text" size="6" maxlength="6" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['color2'] ).'" /></p>';
74
-
75
- $field_id=$this->get_field_id('autoplay');
76
- $field_name=$this->get_field_name('autoplay');
77
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Autoplay').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
78
- if (attribute_escape( $instance['autoplay'] )=="1") {echo " selected='selected'";}
79
- echo '>'.__('Yes').'</option><option value="0"';
80
- if (attribute_escape( $instance['autoplay'] )=="0") {echo " selected='selected'";}
81
- echo '>'.__('No').'</option></select></p>';
82
-
83
- $field_id=$this->get_field_id('loop');
84
- $field_name=$this->get_field_name('loop');
85
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Loop Video').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
86
- if (attribute_escape( $instance['loop'] )=="1") {echo " selected='selected'";}
87
- echo '>'.__('Yes').'</option><option value="0"';
88
- if (attribute_escape( $instance['loop'] )=="0") {echo " selected='selected'";}
89
- echo '>'.__('No').'</option></select></p>';
90
-
91
- $field_id=$this->get_field_id('cc');
92
- $field_name=$this->get_field_name('cc');
93
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Closed Captions').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
94
- if (attribute_escape( $instance['cc'] )=="1") {echo " selected='selected'";}
95
- echo '>'.__('Yes').'</option><option value="0"';
96
- if (attribute_escape( $instance['cc'] )=="0") {echo " selected='selected'";}
97
- echo '>'.__('No').'</option></select></p>';
98
-
99
- $field_id=$this->get_field_id('annotation');
100
- $field_name=$this->get_field_name('annotation');
101
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Annotations').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
102
- if (attribute_escape( $instance['annotation'] )=="1") {echo " selected='selected'";}
103
- echo '>'.__('Yes').'</option><option value="3"';
104
- if (attribute_escape( $instance['annotation'] )=="3") {echo " selected='selected'";}
105
- echo '>'.__('No').'</option></select></p>';
106
-
107
- $field_id=$this->get_field_id('egm');
108
- $field_name=$this->get_field_name('egm');
109
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Enable Enhanced Genie Menu').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
110
- if (attribute_escape( $instance['egm'] )=="1") {echo " selected='selected'";}
111
- echo '>'.__('Yes').'</option><option value="0"';
112
- if (attribute_escape( $instance['egm'] )=="0") {echo " selected='selected'";}
113
- echo '>'.__('No').'</option></select></p>';
114
-
115
- $field_id=$this->get_field_id('related');
116
- $field_name=$this->get_field_name('related');
117
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Related Videos').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
118
- if (attribute_escape( $instance['related'] )=="1") {echo " selected='selected'";}
119
- echo '>'.__('Yes').'</option><option value="0"';
120
- if (attribute_escape( $instance['related'] )=="0") {echo " selected='selected'";}
121
- echo '>'.__('No').'</option></select></p>';
122
-
123
- $field_id=$this->get_field_id('info');
124
- $field_name=$this->get_field_name('info');
125
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Video Information').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
126
- if (attribute_escape( $instance['info'] )=="1") {echo " selected='selected'";}
127
- echo '>'.__('Yes').'</option><option value="0"';
128
- if (attribute_escape( $instance['info'] )=="0") {echo " selected='selected'";}
129
- echo '>'.__('No').'</option></select></p>';
130
-
131
- $field_id=$this->get_field_id('search');
132
- $field_name=$this->get_field_name('search');
133
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Search Box').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
134
- if (attribute_escape( $instance['search'] )=="1") {echo " selected='selected'";}
135
- echo '>'.__('Yes').'</option><option value="0"';
136
- if (attribute_escape( $instance['search'] )=="0") {echo " selected='selected'";}
137
- echo '>'.__('No').'</option></select></p>';
138
-
139
- $field_id=$this->get_field_id('link');
140
- $field_name=$this->get_field_name('link');
141
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Link Back to YouTube').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
142
- if (attribute_escape( $instance['link'] )=="1") {echo " selected='selected'";}
143
- echo '>'.__('Yes').'</option><option value="0"';
144
- if (attribute_escape( $instance['link'] )=="0") {echo " selected='selected'";}
145
- echo '>'.__('No').'</option></select></p>';
146
-
147
- ?>
148
- <h3><?php _e('EmbedPlus Video Only'); ?></h3>
149
- <?php
150
-
151
- $field_id=$this->get_field_id('stop');
152
- $field_name=$this->get_field_name('stop');
153
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Stop').': </label><input type="text" size="3" maxlength="3" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['stop'] ).'" /> seconds</p>';
154
-
155
- $field_id=$this->get_field_id('react');
156
- $field_name=$this->get_field_name('react');
157
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Show Reactions Button').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
158
- if (attribute_escape( $instance['react'] )=="1") {echo " selected='selected'";}
159
- echo '>'.__('Yes').'</option><option value="0"';
160
- if (attribute_escape( $instance['react'] )=="0") {echo " selected='selected'";}
161
- echo '>'.__('No').'</option></select></p>';
162
-
163
- $field_id=$this->get_field_id('sweetspot');
164
- $field_name=$this->get_field_name('sweetspot');
165
- echo "\r\n".'<p><label for="'.$field_id.'">'.__('Find Sweet Spots').': </label><select name="'.$field_name.'" class="widefat" id="'.$field_id.'"><option value="1"';
166
- if (attribute_escape( $instance['sweetspot'] )=="1") {echo " selected='selected'";}
167
- echo '>'.__('Yes').'</option><option value="0"';
168
- if (attribute_escape( $instance['sweetspot'] )=="0") {echo " selected='selected'";}
169
- echo '>'.__('No').'</option></select></p>';
170
- ?>