Version Description
- Added option to show preferred quantity of videos
- Added option to embed classic playlist
- Added class to video container: universal .ytc_video_container and selective (.ytc_video_first, .ytc_video_mid, .ytc_video_last)
- Added class to video title .ytc_title
- Added class to video description text .ytc_description
- Added class to container for link to channel .ytc_link
- Added routine to unique random video from channel if displayed more than one video
- Added option to set
et cetera
string for shortened video description - Changed option for random video to use channel or playlist
- Fields for width and height converted to number with spinner
- Improved playlist ID handler
Download this release
Release Info
Developer | urkekg |
Plugin | YouTube Channel |
Version | 1.4.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.2 to 1.4.0
- languages/youtube-channel-cs_CZ.mo +0 -0
- languages/youtube-channel-cs_CZ.po +194 -0
- readme.txt +46 -7
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- youtube-channel.php +258 -145
languages/youtube-channel-cs_CZ.mo
ADDED
Binary file
|
languages/youtube-channel-cs_CZ.po
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# SOME DESCRIPTIVE TITLE.
|
2 |
+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
3 |
+
# This file is distributed under the same license as the PACKAGE package.
|
4 |
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
5 |
+
#
|
6 |
+
msgid ""
|
7 |
+
msgstr ""
|
8 |
+
"Project-Id-Version: Youtube Channel 1.3.2\n"
|
9 |
+
"Report-Msgid-Bugs-To: \n"
|
10 |
+
"POT-Creation-Date: 2011-09-28 21:16+0200\n"
|
11 |
+
"PO-Revision-Date: 2012-03-02 11:45+0100\n"
|
12 |
+
"Last-Translator: Ladislav Drábek <ladislav.drabek@zholesova.cz>\n"
|
13 |
+
"Language-Team: zholesova.cz <Ladislav Drábek <ladislav.drabek@zholesova.cz>>\n"
|
14 |
+
"Language: \n"
|
15 |
+
"MIME-Version: 1.0\n"
|
16 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
17 |
+
"Content-Transfer-Encoding: 8bit\n"
|
18 |
+
"X-Poedit-Language: Czech\n"
|
19 |
+
"X-Poedit-Country: CZECH REPUBLIC\n"
|
20 |
+
"X-Poedit-SourceCharset: utf-8\n"
|
21 |
+
|
22 |
+
#: ../youtube-channel.php:56
|
23 |
+
msgid "Aspect ratio (relative to width):"
|
24 |
+
msgstr "Poměr stran (relativně k šířce):"
|
25 |
+
|
26 |
+
#: ../youtube-channel.php:72
|
27 |
+
msgid "Autoplay video"
|
28 |
+
msgstr "Automaticky přehrát video"
|
29 |
+
|
30 |
+
#: ../youtube-channel.php:49
|
31 |
+
msgid "Channel:"
|
32 |
+
msgstr "Kanál:"
|
33 |
+
|
34 |
+
#: ../youtube-channel.php:71
|
35 |
+
msgid "Fix height taken by controls"
|
36 |
+
msgstr "Oprava výšky zabrané ovládáním"
|
37 |
+
|
38 |
+
#: ../youtube-channel.php:53
|
39 |
+
msgid "Get random video from channel"
|
40 |
+
msgstr "Získej náhodné video z kanálu"
|
41 |
+
|
42 |
+
#: ../youtube-channel.php:55
|
43 |
+
msgid "Height"
|
44 |
+
msgstr "Výška"
|
45 |
+
|
46 |
+
#: ../youtube-channel.php:73
|
47 |
+
msgid "Hide player controls"
|
48 |
+
msgstr "Skryj ovládání přehrávače"
|
49 |
+
|
50 |
+
#: ../youtube-channel.php:74
|
51 |
+
msgid "Hide video info"
|
52 |
+
msgstr "Skryj info o videu"
|
53 |
+
|
54 |
+
#: ../youtube-channel.php:52
|
55 |
+
msgid "Items to fetch (min 1, max 50):"
|
56 |
+
msgstr "Videí k načtení (min 1, max 50):"
|
57 |
+
|
58 |
+
#: ../youtube-channel.php:187
|
59 |
+
msgid "No items"
|
60 |
+
msgstr "Žádné video"
|
61 |
+
|
62 |
+
#: ../youtube-channel.php:79
|
63 |
+
msgid "Open channel in new window/tab"
|
64 |
+
msgstr "Otevírej kanál v novém okně / záložce"
|
65 |
+
|
66 |
+
#: ../youtube-channel.php:50
|
67 |
+
msgid "Playlist:"
|
68 |
+
msgstr "Playlist:"
|
69 |
+
|
70 |
+
#: ../youtube-channel.php:78
|
71 |
+
msgid "Show link to channel"
|
72 |
+
msgstr "Ukaž odkaz na kanál"
|
73 |
+
|
74 |
+
#: ../youtube-channel.php:75
|
75 |
+
msgid "Show video title"
|
76 |
+
msgstr "Ukaž název videa"
|
77 |
+
|
78 |
+
#: ../youtube-channel.php:80
|
79 |
+
msgid "Use target=\"_blank\" (invalid XHTML)"
|
80 |
+
msgstr "Použij target=\"_blank\" (nevalidní XHTML) - slouží pro otevírání v novém okně"
|
81 |
+
|
82 |
+
#: ../youtube-channel.php:51
|
83 |
+
msgid "Use the playlist instead of channel"
|
84 |
+
msgstr "Použij playlist místo kanálu"
|
85 |
+
|
86 |
+
#: ../youtube-channel.php:77
|
87 |
+
msgid "Visit YouTube Channel text:"
|
88 |
+
msgstr "Text pro odkaz na kanál:"
|
89 |
+
|
90 |
+
#: ../youtube-channel.php:256
|
91 |
+
#, php-format
|
92 |
+
msgid "Visit channel %1$s"
|
93 |
+
msgstr "Navštiv kanál %1$s"
|
94 |
+
|
95 |
+
#: ../youtube-channel.php:219
|
96 |
+
#, php-format
|
97 |
+
msgid "Watch video %1$s published on %2$s"
|
98 |
+
msgstr "Podívej se na video %1$s z %2$s"
|
99 |
+
|
100 |
+
#: ../youtube-channel.php:64
|
101 |
+
msgid "What to show?"
|
102 |
+
msgstr "Jak zobrazit?"
|
103 |
+
|
104 |
+
#: ../youtube-channel.php:48
|
105 |
+
msgid "Widget Title:"
|
106 |
+
msgstr "Název Widgetu"
|
107 |
+
|
108 |
+
#: ../youtube-channel.php:54
|
109 |
+
msgid "Width"
|
110 |
+
msgstr "Šířka"
|
111 |
+
|
112 |
+
#: ../youtube-channel.php:23
|
113 |
+
msgid "YouTube Channel"
|
114 |
+
msgstr "YouTube Channel"
|
115 |
+
|
116 |
+
#: ../youtube-channel.php:69
|
117 |
+
msgid "chromeless video"
|
118 |
+
msgstr "\"chromeless\" video"
|
119 |
+
|
120 |
+
#: ../youtube-channel.php:58
|
121 |
+
msgid "custom"
|
122 |
+
msgstr "vlastní"
|
123 |
+
|
124 |
+
#: ../youtube-channel.php:54
|
125 |
+
#: ../youtube-channel.php:55
|
126 |
+
msgid "default"
|
127 |
+
msgstr "standard"
|
128 |
+
|
129 |
+
#: ../youtube-channel.php:68
|
130 |
+
msgid "iframe (HTML5 player)"
|
131 |
+
msgstr "iframe (HTML5 přehrávač)"
|
132 |
+
|
133 |
+
#: ../youtube-channel.php:259
|
134 |
+
msgid "in new window/tab"
|
135 |
+
msgstr "v novém okně / záložce"
|
136 |
+
|
137 |
+
#: ../youtube-channel.php:67
|
138 |
+
msgid "object (flash player)"
|
139 |
+
msgstr "objekt (flash player)"
|
140 |
+
|
141 |
+
#: ../youtube-channel.php:66
|
142 |
+
msgid "thumbnail"
|
143 |
+
msgstr "náhled"
|
144 |
+
|
145 |
+
#@ youtube-channel
|
146 |
+
#: youtube-channel.php:59
|
147 |
+
msgid "Try to fix `No items` error"
|
148 |
+
msgstr "Pokus se opravit problém s „Žádné video“"
|
149 |
+
|
150 |
+
#@ youtube-channel
|
151 |
+
#: youtube-channel.php:78
|
152 |
+
msgid "Use light theme (default is dark)"
|
153 |
+
msgstr "Použij světlé téma (stabdard je tmavé)"
|
154 |
+
|
155 |
+
#@ youtube-channel
|
156 |
+
#: youtube-channel.php:84
|
157 |
+
msgid "Show video description"
|
158 |
+
msgstr "Ukaž popisek videa"
|
159 |
+
|
160 |
+
#@ youtube-channel
|
161 |
+
#: youtube-channel.php:85
|
162 |
+
msgid "Hide annotations from video"
|
163 |
+
msgstr "Skryj poznámky z videa"
|
164 |
+
|
165 |
+
#@ youtube-channel
|
166 |
+
#: youtube-channel.php:88
|
167 |
+
msgid "Description length"
|
168 |
+
msgstr "Délka popisu videa"
|
169 |
+
|
170 |
+
#@ youtube-channel
|
171 |
+
#: youtube-channel.php:57
|
172 |
+
msgid "Get one random video of latest N videos from channel (min 1, max 50):"
|
173 |
+
msgstr "Vyber náhodně jedno video z posledních N videí kanálu (min 1, max. 50):"
|
174 |
+
|
175 |
+
#@ youtube-channel
|
176 |
+
#: youtube-channel.php:58
|
177 |
+
msgid "Show random video from channel"
|
178 |
+
msgstr "Ukaž náhodné video z kanálu"
|
179 |
+
|
180 |
+
#@ youtube-channel
|
181 |
+
#: youtube-channel.php:60
|
182 |
+
msgid "Video property"
|
183 |
+
msgstr "Nastavení videa"
|
184 |
+
|
185 |
+
#@ youtube-channel
|
186 |
+
#: youtube-channel.php:82
|
187 |
+
msgid "Layout behaviour"
|
188 |
+
msgstr "Rozvržení"
|
189 |
+
|
190 |
+
#@ youtube-channel
|
191 |
+
#: youtube-channel.php:89
|
192 |
+
msgid "Link to channel"
|
193 |
+
msgstr "Odkaz na kanál"
|
194 |
+
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: urkekg
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6
|
4 |
Tags: youtube, channel, playlist, single, widget, widgets, youtube player, flash player, rss, feed, video, thumbnail, embed, sidebar, chromeless, iframe, html5
|
5 |
Requires at least: 3.2.1
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Sidebar widget to show latest video thumbnail, playable flash object or chromeless video from YouTube Channel or Playlist.
|
10 |
|
@@ -37,8 +37,22 @@ If you like this extension and you find it useful, please rate it on the right s
|
|
37 |
* Option to use target="_blank" instead of javascript window.open() for chanel link in new tab/window
|
38 |
* Translated to Serbian and Spanish (English by default)
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
= Issues =
|
41 |
Controls light theme and hidden annotations does not work for chromeless object.
|
|
|
42 |
|
43 |
= Credits =
|
44 |
Chromeless option borrowed from [Chromeless YouTube](http://wordpress.org/extend/plugins/chromeless-youtube/) extension.
|
@@ -58,9 +72,9 @@ If you have to upgrade manually simply repeat the installation steps and re-enab
|
|
58 |
|
59 |
== TODO ==
|
60 |
|
|
|
|
|
61 |
* Add option to show favorite videos
|
62 |
-
* Option to force display of HD video (useless for small sized video?)
|
63 |
-
* Add option to show more than one (and how much) latest videos
|
64 |
|
65 |
== Frequently Asked Questions ==
|
66 |
|
@@ -74,7 +88,7 @@ Currently YTC can display only one video per time. Option `Items to fetch` us us
|
|
74 |
|
75 |
= How to get playlist ID? =
|
76 |
|
77 |
-
Playlist ID can be manualy extracted from YouTube playlist URL. Part of strings after `&list=` that begins with uppercase letters `PL` represent playlist ID.
|
78 |
|
79 |
Since version 1.3.1 you can paste full YouTube playlist URL and ID will be automaticaly extracted.
|
80 |
|
@@ -82,7 +96,33 @@ Since version 1.3.1 you can paste full YouTube playlist URL and ID will be autom
|
|
82 |
|
83 |
YouTube provide 320p videos if height of embeded video is set to 320 or more. If you use small YTC video size, 240p will be loaded instead.
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
= 1.3.2 =
|
87 |
* Add option to show video description below video
|
88 |
* Add option to shorten video description to N characters
|
@@ -151,5 +191,4 @@ Just try it and rate it. Only initial release is available right now.
|
|
151 |
== Screenshots ==
|
152 |
|
153 |
1. Widget `YouTube Channel` configuration panel
|
154 |
-
2. Widget `YouTube Channel` in action with iframe (HTML5) video object with
|
155 |
-
3. Widget `YouTube Channel` in action with Chromeless video object w/o controls
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6
|
4 |
Tags: youtube, channel, playlist, single, widget, widgets, youtube player, flash player, rss, feed, video, thumbnail, embed, sidebar, chromeless, iframe, html5
|
5 |
Requires at least: 3.2.1
|
6 |
+
Tested up to: 3.4.2
|
7 |
+
Stable tag: 1.4.0
|
8 |
|
9 |
Sidebar widget to show latest video thumbnail, playable flash object or chromeless video from YouTube Channel or Playlist.
|
10 |
|
37 |
* Option to use target="_blank" instead of javascript window.open() for chanel link in new tab/window
|
38 |
* Translated to Serbian and Spanish (English by default)
|
39 |
|
40 |
+
= Styling =
|
41 |
+
You can use `style.css` from theme to style `YouTube Video` widget content.
|
42 |
+
|
43 |
+
* `.youtube_channel` - widget wrapper class
|
44 |
+
* `.ytc_title` - class of video title abowe thumbnail/video object
|
45 |
+
* `.ytc_video_container` - class of container for single item
|
46 |
+
* `.ytc_video_1`, `.ytc_video_2`, ... - class of container for single item with ordering number of item in widget
|
47 |
+
* `.ytc_video_first` - class of first container for single item
|
48 |
+
* `.ytc_video_last` - class of last container for single item
|
49 |
+
* `.ytc_video_mid` - class of all other containers for single item
|
50 |
+
* `.ytc_description` - class for video description text
|
51 |
+
* `.ytc_link` - class of container for link to channel
|
52 |
+
|
53 |
= Issues =
|
54 |
Controls light theme and hidden annotations does not work for chromeless object.
|
55 |
+
Video description for videos from playlist does nt work.
|
56 |
|
57 |
= Credits =
|
58 |
Chromeless option borrowed from [Chromeless YouTube](http://wordpress.org/extend/plugins/chromeless-youtube/) extension.
|
72 |
|
73 |
== TODO ==
|
74 |
|
75 |
+
* Add option to open video for thumbnail image in lightbox
|
76 |
+
* Improve autoplay option to start playing only first video item
|
77 |
* Add option to show favorite videos
|
|
|
|
|
78 |
|
79 |
== Frequently Asked Questions ==
|
80 |
|
88 |
|
89 |
= How to get playlist ID? =
|
90 |
|
91 |
+
Playlist ID can be manualy extracted from YouTube playlist URL. Part of strings after `&list=` that begins with uppercase letters `PL` represent playlist ID. You can paste ID with or without leading `PL` string.
|
92 |
|
93 |
Since version 1.3.1 you can paste full YouTube playlist URL and ID will be automaticaly extracted.
|
94 |
|
96 |
|
97 |
YouTube provide 320p videos if height of embeded video is set to 320 or more. If you use small YTC video size, 240p will be loaded instead.
|
98 |
|
99 |
+
= There is two playlist checkboxes, how they works? =
|
100 |
+
|
101 |
+
If you wish to use videos from playlist instead of videos from channel (display random videos, one or more videos, with all kind of settings) enable option `Use the playlist instead of channel`.
|
102 |
+
If you wish to show only single embedded playlist block using IFRAME (HTML5), then enable option `Embed only standard playlist` and all other settings will be ignored.
|
103 |
+
|
104 |
+
= What is a difference between `Fetch latest` and `Show ... videos`? =
|
105 |
+
|
106 |
+
Value for `Fetch latest` says how many items will containt set of videos for choosing random video.
|
107 |
+
value for `Show ... videos` says how many videos will be displayed in widget.
|
108 |
+
|
109 |
== Changelog ==
|
110 |
+
= 1.4.0 =
|
111 |
+
* Added option to show preferred quantity of videos
|
112 |
+
* Added option to embed classic playlist
|
113 |
+
* Added class to video container: universal .ytc_video_container and selective (.ytc_video_first, .ytc_video_mid, .ytc_video_last)
|
114 |
+
* Added class to video title .ytc_title
|
115 |
+
* Added class to video description text .ytc_description
|
116 |
+
* Added class to container for link to channel .ytc_link
|
117 |
+
* Added routine to unique random video from channel if displayed more than one video
|
118 |
+
* Added option to set `et cetera` string for shortened video description
|
119 |
+
* Changed option for random video to use channel or playlist
|
120 |
+
* Fields for width and height converted to number with spinner
|
121 |
+
* Improved playlist ID handler
|
122 |
+
|
123 |
+
= 1.3.3 =
|
124 |
+
* Added Czech translation by Ladislav Drábek
|
125 |
+
|
126 |
= 1.3.2 =
|
127 |
* Add option to show video description below video
|
128 |
* Add option to shorten video description to N characters
|
191 |
== Screenshots ==
|
192 |
|
193 |
1. Widget `YouTube Channel` configuration panel
|
194 |
+
2. Widget `YouTube Channel` in action with iframe (HTML5) video object with two video items, displayed video title and shortened description
|
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
DELETED
Binary file
|
youtube-channel.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: YouTube Channel
|
|
4 |
Plugin URI: http://blog.urosevic.net/wordpress/youtube-channel/
|
5 |
Description: <a href="widgets.php">Widget</a> that display latest video thumbnail, iframe (HTML5 video), object (Flash video) or chromeless video from YouTube Channel or Playlist.
|
6 |
Author: Aleksandar Urošević
|
7 |
-
Version: 1.
|
8 |
Author URI: http://urosevic.net/
|
9 |
*/
|
10 |
|
@@ -27,8 +27,10 @@ class YouTube_Channel_Widget extends WP_Widget {
|
|
27 |
// outputs the options form on admin
|
28 |
$title = esc_attr($instance['title']);
|
29 |
$channel = esc_attr($instance['channel']);
|
|
|
30 |
$playlist = esc_attr($instance['playlist']);
|
31 |
$usepl = esc_attr($instance['usepl']);
|
|
|
32 |
$getrnd = esc_attr($instance['getrnd']);
|
33 |
$maxrnd = esc_attr($instance['maxrnd']);
|
34 |
$goto_txt = esc_attr($instance['goto_txt']);
|
@@ -38,9 +40,11 @@ class YouTube_Channel_Widget extends WP_Widget {
|
|
38 |
$showtitle = esc_attr($instance['showtitle']);
|
39 |
$showvidesc = esc_attr($instance['showvidesc']);
|
40 |
$videsclen = esc_attr($instance['videsclen']);
|
|
|
41 |
$width = esc_attr($instance['width']);
|
42 |
$height = esc_attr($instance['height']);
|
43 |
$to_show = esc_attr($instance['to_show']);
|
|
|
44 |
$autoplay = esc_attr($instance['autoplay']);
|
45 |
$controls = esc_attr($instance['controls']);
|
46 |
$fixnoitem = esc_attr($instance['fixnoitem']);
|
@@ -52,14 +56,17 @@ class YouTube_Channel_Widget extends WP_Widget {
|
|
52 |
?>
|
53 |
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title:', 'youtube-channel'); ?><input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
|
54 |
<p><label for="<?php echo $this->get_field_id('channel'); ?>"><?php _e('Channel:', 'youtube-channel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('channel'); ?>" name="<?php echo $this->get_field_name('channel'); ?>" type="text" value="<?php echo $channel; ?>" /></label></p>
|
55 |
-
<p><label for="<?php echo $this->get_field_id('playlist'); ?>"><?php _e('Playlist:', 'youtube-channel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('playlist'); ?>" name="<?php echo $this->get_field_name('playlist'); ?>" type="text" value="<?php echo $playlist; ?>" /></label>
|
56 |
-
<
|
57 |
-
<p><label for="<?php echo $this->get_field_id('
|
58 |
-
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['
|
59 |
-
<
|
|
|
|
|
|
|
60 |
<h4><?php _e('Video property', 'youtube-channel'); ?></h4>
|
61 |
-
<p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width', 'youtube-channel'); ?> (<?php _e('default', 'youtube-channel'); ?> 220)
|
62 |
-
<p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height', 'youtube-channel'); ?> (<?php _e('default', 'youtube-channel'); ?> 165)
|
63 |
<p><label for="<?php echo $this->get_field_id('to_show'); ?>"><?php _e('Aspect ratio (relative to width):', 'youtube-channel'); ?>
|
64 |
<select class="widefat" id="<?php echo $this->get_field_id( 'ratio' ); ?>" name="<?php echo $this->get_field_name( 'ratio' ); ?>">
|
65 |
<option value="0"<?php selected( $instance['ratio'], 0 ); ?>><?php _e('custom', 'youtube-channel'); ?></option>
|
@@ -78,14 +85,17 @@ class YouTube_Channel_Widget extends WP_Widget {
|
|
78 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['themelight'], true ); ?> id="<?php echo $this->get_field_id( 'themelight' ); ?>" name="<?php echo $this->get_field_name( 'themelight' ); ?>" /> <label for="<?php echo $this->get_field_id( 'themelight' ); ?>"><?php _e('Use light theme (default is dark)', 'youtube-channel'); ?></label><br />
|
79 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['controls'], true ); ?> id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" /> <label for="<?php echo $this->get_field_id( 'controls' ); ?>"><?php _e('Hide player controls', 'youtube-channel'); ?></label><br />
|
80 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['fixyt'], true ); ?> id="<?php echo $this->get_field_id( 'fixyt' ); ?>" name="<?php echo $this->get_field_name( 'fixyt' ); ?>" /> <label for="<?php echo $this->get_field_id( 'fixyt' ); ?>"><?php _e('Fix height taken by controls', 'youtube-channel'); ?></label><br />
|
|
|
|
|
81 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['autoplay'], true ); ?> id="<?php echo $this->get_field_id( 'autoplay' ); ?>" name="<?php echo $this->get_field_name( 'autoplay' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay' ); ?>"><?php _e('Autoplay video', 'youtube-channel'); ?></label></p>
|
82 |
<h4><?php _e('Layout behaviour', 'youtube-channel'); ?></h4>
|
83 |
<p><input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showtitle'], true ); ?> id="<?php echo $this->get_field_id( 'showtitle' ); ?>" name="<?php echo $this->get_field_name( 'showtitle' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showtitle' ); ?>"><?php _e('Show video title', 'youtube-channel'); ?></label><br />
|
84 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showvidesc'], true ); ?> id="<?php echo $this->get_field_id( 'showvidesc' ); ?>" name="<?php echo $this->get_field_name( 'showvidesc' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showvidesc' ); ?>"><?php _e('Show video description', 'youtube-channel'); ?></label><br />
|
|
|
|
|
85 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['hideanno'], true ); ?> id="<?php echo $this->get_field_id( 'hideanno' ); ?>" name="<?php echo $this->get_field_name( 'hideanno' ); ?>" /> <label for="<?php echo $this->get_field_id( 'hideanno' ); ?>"><?php _e('Hide annotations from video', 'youtube-channel'); ?></label><br />
|
86 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['hideinfo'], true ); ?> id="<?php echo $this->get_field_id( 'hideinfo' ); ?>" name="<?php echo $this->get_field_name( 'hideinfo' ); ?>" /> <label for="<?php echo $this->get_field_id( 'hideinfo' ); ?>"><?php _e('Hide video info', 'youtube-channel'); ?></label></p>
|
87 |
</p>
|
88 |
-
<p><label for="<?php echo $this->get_field_id('videsclen'); ?>"><?php _e('Description length', 'youtube-channel'); ?> (<?php _e('default', 'youtube-channel'); ?> 0 for full):<input class="widefat" id="<?php echo $this->get_field_id('videsclen'); ?>" name="<?php echo $this->get_field_name('videsclen'); ?>" type="text" value="<?php echo $videsclen; ?>" /></label></p>
|
89 |
<h4><?php _e('Link to channel', 'youtube-channel'); ?></h4>
|
90 |
<p><label for="<?php echo $this->get_field_id('goto_txt'); ?>"><?php _e('Visit YouTube Channel text:', 'youtube-channel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('goto_txt'); ?>" name="<?php echo $this->get_field_name('goto_txt'); ?>" type="text" value="<?php echo $goto_txt; ?>" /></label>
|
91 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showgoto'], true ); ?> id="<?php echo $this->get_field_id( 'showgoto' ); ?>" name="<?php echo $this->get_field_name( 'showgoto' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showgoto' ); ?>"><?php _e('Show link to channel', 'youtube-channel'); ?></label><br />
|
@@ -100,8 +110,10 @@ class YouTube_Channel_Widget extends WP_Widget {
|
|
100 |
$instance = $old_instance;
|
101 |
$instance['title'] = strip_tags($new_instance['title']);
|
102 |
$instance['channel'] = strip_tags($new_instance['channel']);
|
|
|
103 |
$instance['playlist'] = strip_tags($new_instance['playlist']);
|
104 |
$instance['usepl'] = $new_instance['usepl'];
|
|
|
105 |
$instance['getrnd'] = $new_instance['getrnd'];
|
106 |
$instance['maxrnd'] = $new_instance['maxrnd'];
|
107 |
$instance['goto_txt'] = strip_tags($new_instance['goto_txt']);
|
@@ -110,11 +122,13 @@ class YouTube_Channel_Widget extends WP_Widget {
|
|
110 |
$instance['target'] = $new_instance['target'];
|
111 |
$instance['showtitle'] = $new_instance['showtitle'];
|
112 |
$instance['showvidesc'] = $new_instance['showvidesc'];
|
|
|
113 |
$instance['videsclen'] = strip_tags($new_instance['videsclen']);
|
114 |
$instance['width'] = strip_tags($new_instance['width']);
|
115 |
$instance['height'] = strip_tags($new_instance['height']);
|
116 |
$instance['to_show'] = strip_tags($new_instance['to_show']);
|
117 |
$instance['autoplay'] = $new_instance['autoplay'];
|
|
|
118 |
$instance['controls'] = $new_instance['controls'];
|
119 |
$instance['fixnoitem'] = $new_instance['fixnoitem'];
|
120 |
$instance['ratio'] = strip_tags($new_instance['ratio']);
|
@@ -137,128 +151,191 @@ class YouTube_Channel_Widget extends WP_Widget {
|
|
137 |
|
138 |
// set playlist id
|
139 |
$playlist = $instance['playlist'];
|
|
|
140 |
// trim PL in front of playlist ID
|
141 |
$playlist = preg_replace('/^PL/', '', $playlist);
|
142 |
-
if ( $playlist == "" ) { $playlist = "9DD839E3EB7475DF"; }
|
143 |
$usepl = $instance['usepl'];
|
144 |
-
|
145 |
-
// get max items for random video
|
146 |
-
$maxrnd = $instance['maxrnd'];
|
147 |
-
if ( $maxrnd < 1 ) { $maxrnd = 10; } // default 10
|
148 |
-
elseif ( $maxrnd > 50 ) { $maxrnd = 50; } // max 50
|
149 |
-
// get hideinfo, autoplay and controls settings
|
150 |
-
$hideinfo = $instance['hideinfo'];
|
151 |
-
$autoplay = $instance['autoplay'];
|
152 |
-
$controls = $instance['controls'];
|
153 |
-
|
154 |
-
// set width and height
|
155 |
-
$width = $instance['width'];
|
156 |
-
if ( $width == "" ) { $width = 220; }
|
157 |
-
// use ratio?
|
158 |
-
$ratio = $instance['ratio'];
|
159 |
-
if ( $ratio == 1 ) { // 4:3
|
160 |
-
$height = round(($width / 4 ) * 3);
|
161 |
-
} else if ( $ratio == 2 ) { // 16:10
|
162 |
-
$height = round(($width / 16 ) * 10);
|
163 |
-
} else if ( $ratio == 3 ) { // 16:9
|
164 |
-
$height = round(($width / 16 ) * 9);
|
165 |
-
} else { // set default if 0 or ratio not set
|
166 |
-
$height = $instance['height'];
|
167 |
-
if ( $height == "" ) { $height = 165; }
|
168 |
-
}
|
169 |
-
// calculate image height based on width for 4:3 thumbnail
|
170 |
-
$imgfixedheight = $width / 4 * 3;
|
171 |
-
|
172 |
-
// which type to show
|
173 |
-
$to_show = $instance['to_show'];
|
174 |
-
if ( $to_show == "" ) { $to_show = "object"; }
|
175 |
-
|
176 |
-
// if not thumbnail, increase video height for 25px taken by video controls
|
177 |
-
if ( !$instance['thumbnail'] && !$controls ) {
|
178 |
-
$height += 25;
|
179 |
-
}
|
180 |
-
|
181 |
-
$hideanno = $instance['hideanno'];
|
182 |
-
$themelight = $instance['themelight'];
|
183 |
|
184 |
echo $before_widget;
|
185 |
if ( $title )
|
186 |
echo $before_title . $title . $after_title;
|
|
|
187 |
?>
|
|
|
188 |
<div class="youtube_channel">
|
189 |
-
<?php
|
190 |
-
include_once(ABSPATH . WPINC . '/rss.php');
|
191 |
-
$rss_settings = '?alt=rss&v=2';
|
192 |
-
if ( !$instance['fixnoitem'] ) {
|
193 |
-
$rss_settings .= '&orderby=published';
|
194 |
-
}
|
195 |
-
$rss_settings .= '&rel=0&max-results='.$maxrnd;
|
196 |
-
if ( $usepl ) {
|
197 |
-
// check what is set: full URL or playlist ID
|
198 |
-
if ( substr($playlist,0,4) == "http" ) {
|
199 |
-
// if URL provided, extract playlist ID
|
200 |
-
$playlist = preg_replace('/.*list=PL([A-Z0-9]*).*/','$1', $playlist);
|
201 |
-
}
|
202 |
-
$rss_url = 'http://gdata.youtube.com/feeds/api/playlists/'.$playlist.$rss_settings;
|
203 |
-
} else {
|
204 |
-
$rss_url = 'http://gdata.youtube.com/feeds/base/users/'.$channel.'/uploads'.$rss_settings;
|
205 |
-
}
|
206 |
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
226 |
|
227 |
-
|
228 |
-
$yt_id = $item->get_link();
|
229 |
-
$yt_id = preg_replace('/^.*=(.*)&.*$/', '${1}', $yt_id);
|
230 |
-
if ( $getrnd ) {
|
231 |
-
$yt_url = "v/$yt_id";
|
232 |
} else {
|
233 |
-
$
|
234 |
}
|
235 |
-
|
236 |
-
$
|
237 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
$yt_url = "v/$yt_id";
|
239 |
-
}
|
240 |
-
$
|
241 |
-
|
242 |
-
|
243 |
-
$
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
-
|
253 |
-
|
254 |
|
255 |
-
|
256 |
-
|
257 |
$title = sprintf( __( 'Watch video %1$s published on %2$s' , 'youtube-channel' ), $yt_title, $yt_date );
|
|
|
258 |
echo <<<EOF
|
259 |
<a href="$yt_video" title="$title"><div style="width: ${width}px; height: ${height}px; overflow: hidden; background: url($yt_thumb) 50% 50% no-repeat; background-size: ${width}px ${imgfixedheight}px;" title="$yt_title" id="$ytc_vid"></div></a>
|
260 |
EOF;
|
261 |
-
|
262 |
?>
|
263 |
<object type="application/x-shockwave-flash" data="<?php echo YOUTUBE_CHANNEL_URL . 'chromeless.swf'; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" id="<?php echo $ytc_vid; ?>">
|
264 |
<param name="flashVars" value="video_source=<?php echo $yt_id; ?>&video_width=<?php echo $width; ?>&video_height=<?php echo $height; ?><?php if ( $autoplay ) { echo "&autoplay=Yes"; } if ( !$controls ) { echo "&youtube_controls=Yes"; } if ( $hideanno ) { echo "&iv_load_policy=3"; } if ( $themelight ) { echo "&theme=light"; } ?>" />
|
@@ -268,12 +345,12 @@ EOF;
|
|
268 |
<param name="movie" value="<?php echo YOUTUBE_CHANNEL_URL . 'chromeless.swf'; ?>" />
|
269 |
</object>
|
270 |
<?php
|
271 |
-
|
272 |
-
|
273 |
?>
|
274 |
<iframe title="YouTube video player" width="<?php echo $width; ?>" height="<?php echo $height; ?>" src="http://www.youtube.com/embed/<?php echo $yt_url."?wmode=opaque&enablejsapi=1"; if ( $controls ) { echo "&controls=0"; } if ( $hideinfo ) { echo "&showinfo=0"; } if ( $autoplay ) { echo "&autoplay=1"; } if ( $hideanno ) { echo "&iv_load_policy=3"; } if ( $themelight ) { echo "&theme=light"; } ?>" frameborder="0" allowfullscreen id="<?php echo $ytc_vid ?>"></iframe>
|
275 |
<?php
|
276 |
-
|
277 |
?>
|
278 |
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="<?php echo $width; ?>" height="<?php echo $height; ?>" id="<?php echo $ytc_vid; ?>">
|
279 |
<param name="movie" value="http://www.youtube.com/<?php echo $yt_url; ?>?version=3<?php if ( $controls ) { echo "&controls=0"; } if ( $hideinfo ) { echo "&showinfo=0"; } if ( $autoplay ) { echo "&autoplay=1"; } if ( $hideanno ) { echo "&iv_load_policy=3"; } if ( $themelight ) { echo "&theme=light"; } ?>" />
|
@@ -287,49 +364,85 @@ EOF;
|
|
287 |
<!--<![endif]-->
|
288 |
</object>
|
289 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
}
|
|
|
|
|
|
|
|
|
291 |
|
292 |
-
//
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
}
|
300 |
-
|
301 |
-
|
302 |
}
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
echo <<<EOF
|
313 |
-
<
|
314 |
EOF;
|
315 |
-
|
316 |
echo <<<EOF
|
317 |
-
<
|
318 |
EOF;
|
319 |
-
|
320 |
-
|
321 |
echo <<<EOF
|
322 |
<p><a href="http://www.youtube.com/user/$channel/" title="$goto_txt">$goto_txt</a></p>
|
323 |
EOF;
|
324 |
-
|
325 |
-
|
326 |
-
}
|
327 |
-
?>
|
328 |
-
</div>
|
329 |
-
<?php
|
330 |
-
echo $after_widget;
|
331 |
-
}
|
332 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
}
|
334 |
|
335 |
/* Register plugin's widget */
|
4 |
Plugin URI: http://blog.urosevic.net/wordpress/youtube-channel/
|
5 |
Description: <a href="widgets.php">Widget</a> that display latest video thumbnail, iframe (HTML5 video), object (Flash video) or chromeless video from YouTube Channel or Playlist.
|
6 |
Author: Aleksandar Urošević
|
7 |
+
Version: 1.4.0
|
8 |
Author URI: http://urosevic.net/
|
9 |
*/
|
10 |
|
27 |
// outputs the options form on admin
|
28 |
$title = esc_attr($instance['title']);
|
29 |
$channel = esc_attr($instance['channel']);
|
30 |
+
$vidqty = esc_attr($instance['vidqty']);
|
31 |
$playlist = esc_attr($instance['playlist']);
|
32 |
$usepl = esc_attr($instance['usepl']);
|
33 |
+
$only_pl = esc_attr($instance['only_pl']);
|
34 |
$getrnd = esc_attr($instance['getrnd']);
|
35 |
$maxrnd = esc_attr($instance['maxrnd']);
|
36 |
$goto_txt = esc_attr($instance['goto_txt']);
|
40 |
$showtitle = esc_attr($instance['showtitle']);
|
41 |
$showvidesc = esc_attr($instance['showvidesc']);
|
42 |
$videsclen = esc_attr($instance['videsclen']);
|
43 |
+
$descappend = esc_attr($instance['descappend']);
|
44 |
$width = esc_attr($instance['width']);
|
45 |
$height = esc_attr($instance['height']);
|
46 |
$to_show = esc_attr($instance['to_show']);
|
47 |
+
$lightbox = esc_attr($instance['lightbox']);
|
48 |
$autoplay = esc_attr($instance['autoplay']);
|
49 |
$controls = esc_attr($instance['controls']);
|
50 |
$fixnoitem = esc_attr($instance['fixnoitem']);
|
56 |
?>
|
57 |
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title:', 'youtube-channel'); ?><input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
|
58 |
<p><label for="<?php echo $this->get_field_id('channel'); ?>"><?php _e('Channel:', 'youtube-channel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('channel'); ?>" name="<?php echo $this->get_field_name('channel'); ?>" type="text" value="<?php echo $channel; ?>" /></label></p>
|
59 |
+
<p><label for="<?php echo $this->get_field_id('playlist'); ?>"><?php _e('Playlist:', 'youtube-channel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('playlist'); ?>" name="<?php echo $this->get_field_name('playlist'); ?>" type="text" value="<?php echo $playlist; ?>" /></label></p>
|
60 |
+
<p><label for="<?php echo $this->get_field_id('maxrnd'); ?>"><?php _e('Fetch latest:', 'youtube-channel'); ?> <input class="small-text" id="<?php echo $this->get_field_id('maxrnd'); ?>" name="<?php echo $this->get_field_name('maxrnd'); ?>" type="number" min="2" value="<?php echo $maxrnd; ?>" /> (min 2, max 50)</label></p>
|
61 |
+
<p><label for="<?php echo $this->get_field_id('vidqty'); ?>"><?php _e('Show:', 'youtube-channel'); ?></label> <input class="small-text" id="<?php echo $this->get_field_id('vidqty'); ?>" name="<?php echo $this->get_field_name('vidqty'); ?>" type="number" min="1" value="<?php echo $vidqty; ?>" /> videos</p>
|
62 |
+
<p><input class="checkbox" type="checkbox" <?php checked( (bool) $instance['fixnoitem'], true ); ?> id="<?php echo $this->get_field_id( 'fixnoitem' ); ?>" name="<?php echo $this->get_field_name( 'fixnoitem' ); ?>" /> <label for="<?php echo $this->get_field_id( 'fixnoitem' ); ?>"><?php _e('Try to fix `No items` error', 'youtube-channel'); ?></label><br />
|
63 |
+
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['usepl'], true ); ?> id="<?php echo $this->get_field_id( 'usepl' ); ?>" name="<?php echo $this->get_field_name( 'usepl' ); ?>" /> <label for="<?php echo $this->get_field_id( 'usepl' ); ?>"><?php _e('Use the playlist instead of channel', 'youtube-channel'); ?></label><br />
|
64 |
+
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['getrnd'], true ); ?> id="<?php echo $this->get_field_id( 'getrnd' ); ?>" name="<?php echo $this->get_field_name( 'getrnd' ); ?>" /> <label for="<?php echo $this->get_field_id( 'getrnd' ); ?>"><?php _e('Show random video', 'youtube-channel'); ?></label><br />
|
65 |
+
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['only_pl'], true ); ?> id="<?php echo $this->get_field_id( 'only_pl' ); ?>" name="<?php echo $this->get_field_name( 'only_pl' ); ?>" /> <label for="<?php echo $this->get_field_id( 'only_pl' ); ?>"><?php _e('Embed only standard playlist', 'youtube-channel'); ?></label></p>
|
66 |
+
|
67 |
<h4><?php _e('Video property', 'youtube-channel'); ?></h4>
|
68 |
+
<p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width', 'youtube-channel'); ?> (<?php _e('default', 'youtube-channel'); ?> 220):</label> <input class="small-text" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="number" min="32" value="<?php echo $width; ?>" /> px</p>
|
69 |
+
<p><label for="<?php echo $this->get_field_id('height'); ?>"><?php _e('Height', 'youtube-channel'); ?> (<?php _e('default', 'youtube-channel'); ?> 165):</label> <input class="small-text" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="number" min="32" value="<?php echo $height; ?>" /> px</p>
|
70 |
<p><label for="<?php echo $this->get_field_id('to_show'); ?>"><?php _e('Aspect ratio (relative to width):', 'youtube-channel'); ?>
|
71 |
<select class="widefat" id="<?php echo $this->get_field_id( 'ratio' ); ?>" name="<?php echo $this->get_field_name( 'ratio' ); ?>">
|
72 |
<option value="0"<?php selected( $instance['ratio'], 0 ); ?>><?php _e('custom', 'youtube-channel'); ?></option>
|
85 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['themelight'], true ); ?> id="<?php echo $this->get_field_id( 'themelight' ); ?>" name="<?php echo $this->get_field_name( 'themelight' ); ?>" /> <label for="<?php echo $this->get_field_id( 'themelight' ); ?>"><?php _e('Use light theme (default is dark)', 'youtube-channel'); ?></label><br />
|
86 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['controls'], true ); ?> id="<?php echo $this->get_field_id( 'controls' ); ?>" name="<?php echo $this->get_field_name( 'controls' ); ?>" /> <label for="<?php echo $this->get_field_id( 'controls' ); ?>"><?php _e('Hide player controls', 'youtube-channel'); ?></label><br />
|
87 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['fixyt'], true ); ?> id="<?php echo $this->get_field_id( 'fixyt' ); ?>" name="<?php echo $this->get_field_name( 'fixyt' ); ?>" /> <label for="<?php echo $this->get_field_id( 'fixyt' ); ?>"><?php _e('Fix height taken by controls', 'youtube-channel'); ?></label><br />
|
88 |
+
<?php /* <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['lightbox'], true ); ?> id="<?php echo $this->get_field_id( 'lightbox' ); ?>" name="<?php echo $this->get_field_name( 'lightbox' ); ?>" /> <label for="<?php echo $this->get_field_id( 'lightbox' ); ?>"><?php _e('Open thumbnail video in lightbox', 'youtube-channel'); ?></label><br /> */ ?>
|
89 |
+
<?php /*if ( $instance['to_show'] == 'thumbnail' && $instance['lightbox'] && !is_plugin_active('wp-video-lightbox/wp-video-lightbox.php') ){ echo '<p>To load videos in lightbox please install and activate <a href="http://wordpress.org/extend/plugins/wp-video-lightbox/">WP Video Lightbox</a> plugin by Ruhul Amin.</p>'; } */?>
|
90 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['autoplay'], true ); ?> id="<?php echo $this->get_field_id( 'autoplay' ); ?>" name="<?php echo $this->get_field_name( 'autoplay' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay' ); ?>"><?php _e('Autoplay video', 'youtube-channel'); ?></label></p>
|
91 |
<h4><?php _e('Layout behaviour', 'youtube-channel'); ?></h4>
|
92 |
<p><input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showtitle'], true ); ?> id="<?php echo $this->get_field_id( 'showtitle' ); ?>" name="<?php echo $this->get_field_name( 'showtitle' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showtitle' ); ?>"><?php _e('Show video title', 'youtube-channel'); ?></label><br />
|
93 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showvidesc'], true ); ?> id="<?php echo $this->get_field_id( 'showvidesc' ); ?>" name="<?php echo $this->get_field_name( 'showvidesc' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showvidesc' ); ?>"><?php _e('Show video description', 'youtube-channel'); ?></label><br />
|
94 |
+
<label for="<?php echo $this->get_field_id('videsclen'); ?>"><?php _e('Description length', 'youtube-channel'); ?>: <input class="small-text" id="<?php echo $this->get_field_id('videsclen'); ?>" name="<?php echo $this->get_field_name('videsclen'); ?>" type="number" value="<?php echo $videsclen; ?>" /> (0 = full)</label><br />
|
95 |
+
<label for="descappend">Et cetera string <input class="small-text" id="<?php echo $this->get_field_id('descappend'); ?>" name="<?php echo $this->get_field_name('descappend'); ?>" type="text" value="<?php echo $descappend; ?>" /> default &hellip;</label><br />
|
96 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['hideanno'], true ); ?> id="<?php echo $this->get_field_id( 'hideanno' ); ?>" name="<?php echo $this->get_field_name( 'hideanno' ); ?>" /> <label for="<?php echo $this->get_field_id( 'hideanno' ); ?>"><?php _e('Hide annotations from video', 'youtube-channel'); ?></label><br />
|
97 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['hideinfo'], true ); ?> id="<?php echo $this->get_field_id( 'hideinfo' ); ?>" name="<?php echo $this->get_field_name( 'hideinfo' ); ?>" /> <label for="<?php echo $this->get_field_id( 'hideinfo' ); ?>"><?php _e('Hide video info', 'youtube-channel'); ?></label></p>
|
98 |
</p>
|
|
|
99 |
<h4><?php _e('Link to channel', 'youtube-channel'); ?></h4>
|
100 |
<p><label for="<?php echo $this->get_field_id('goto_txt'); ?>"><?php _e('Visit YouTube Channel text:', 'youtube-channel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('goto_txt'); ?>" name="<?php echo $this->get_field_name('goto_txt'); ?>" type="text" value="<?php echo $goto_txt; ?>" /></label>
|
101 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $instance['showgoto'], true ); ?> id="<?php echo $this->get_field_id( 'showgoto' ); ?>" name="<?php echo $this->get_field_name( 'showgoto' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showgoto' ); ?>"><?php _e('Show link to channel', 'youtube-channel'); ?></label><br />
|
110 |
$instance = $old_instance;
|
111 |
$instance['title'] = strip_tags($new_instance['title']);
|
112 |
$instance['channel'] = strip_tags($new_instance['channel']);
|
113 |
+
$instance['vidqty'] = $new_instance['vidqty'];
|
114 |
$instance['playlist'] = strip_tags($new_instance['playlist']);
|
115 |
$instance['usepl'] = $new_instance['usepl'];
|
116 |
+
$instance['only_pl'] = $new_instance['only_pl'];
|
117 |
$instance['getrnd'] = $new_instance['getrnd'];
|
118 |
$instance['maxrnd'] = $new_instance['maxrnd'];
|
119 |
$instance['goto_txt'] = strip_tags($new_instance['goto_txt']);
|
122 |
$instance['target'] = $new_instance['target'];
|
123 |
$instance['showtitle'] = $new_instance['showtitle'];
|
124 |
$instance['showvidesc'] = $new_instance['showvidesc'];
|
125 |
+
$instance['descappend'] = strip_tags($new_instance['descappend']);
|
126 |
$instance['videsclen'] = strip_tags($new_instance['videsclen']);
|
127 |
$instance['width'] = strip_tags($new_instance['width']);
|
128 |
$instance['height'] = strip_tags($new_instance['height']);
|
129 |
$instance['to_show'] = strip_tags($new_instance['to_show']);
|
130 |
$instance['autoplay'] = $new_instance['autoplay'];
|
131 |
+
$instance['lightbox'] = $new_instance['lightbox'];
|
132 |
$instance['controls'] = $new_instance['controls'];
|
133 |
$instance['fixnoitem'] = $new_instance['fixnoitem'];
|
134 |
$instance['ratio'] = strip_tags($new_instance['ratio']);
|
151 |
|
152 |
// set playlist id
|
153 |
$playlist = $instance['playlist'];
|
154 |
+
if ( $playlist == "" ) { $playlist = "PLEC850BE962234400"; }
|
155 |
// trim PL in front of playlist ID
|
156 |
$playlist = preg_replace('/^PL/', '', $playlist);
|
|
|
157 |
$usepl = $instance['usepl'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
echo $before_widget;
|
160 |
if ( $title )
|
161 |
echo $before_title . $title . $after_title;
|
162 |
+
|
163 |
?>
|
164 |
+
|
165 |
<div class="youtube_channel">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
+
<?php
|
168 |
+
if ( $instance['only_pl'] ) { // print standard playlist
|
169 |
+
ytc_only_pl($instance);
|
170 |
+
} else { // channel or playlist single videos
|
171 |
+
|
172 |
+
// get max items for random video
|
173 |
+
$maxrnd = $instance['maxrnd'];
|
174 |
+
if ( $maxrnd < 1 ) { $maxrnd = 10; } // default 10
|
175 |
+
elseif ( $maxrnd > 50 ) { $maxrnd = 50; } // max 50
|
176 |
+
|
177 |
+
include_once(ABSPATH . WPINC . '/rss.php');
|
178 |
+
$rss_settings = '?alt=rss&v=2';
|
179 |
+
if ( !$instance['fixnoitem'] ) {
|
180 |
+
$rss_settings .= '&orderby=published';
|
181 |
+
}
|
182 |
+
|
183 |
+
#$vidqty = $instance['vidqty'];
|
184 |
+
#if ( $maxrnd > $vidqty ) {}
|
185 |
+
$rss_settings .= '&rel=0&max-results='.$maxrnd;
|
186 |
+
if ( $usepl ) {
|
187 |
+
// check what is set: full URL or playlist ID
|
188 |
+
$playlist = ytc_clean_playlist_id($playlist);
|
189 |
|
190 |
+
$rss_url = 'http://gdata.youtube.com/feeds/api/playlists/'.$playlist.$rss_settings;
|
|
|
|
|
|
|
|
|
191 |
} else {
|
192 |
+
$rss_url = 'http://gdata.youtube.com/feeds/base/users/'.$channel.'/uploads'.$rss_settings;
|
193 |
}
|
194 |
+
|
195 |
+
$rss = fetch_feed($rss_url);
|
196 |
+
if ( !is_wp_error($rss) ) {
|
197 |
+
$getrnd = $instance['getrnd'];
|
198 |
+
$vidqty = $instance['vidqty'];
|
199 |
+
if ( $vidqty > $maxrnd ) { $maxrnd = $vidqty; }
|
200 |
+
$maxitems = $rss->get_item_quantity($maxrnd); // max items in widget settings
|
201 |
+
|
202 |
+
if ( $getrnd ) {
|
203 |
+
$items = $rss->get_items(0, $maxitems);
|
204 |
+
} else {
|
205 |
+
if ( !$vidqty ) { $vidqty = 1; }
|
206 |
+
$items = $rss->get_items(0, $vidqty); // set 0, 2 for next video
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
if ($maxitems == 0) {
|
211 |
+
echo __( 'No items' , 'youtube-channel' );
|
212 |
+
} else {
|
213 |
+
if ( $getrnd ) { $rnd_used = array(); } // set array for unique random item
|
214 |
+
for ($y = 1; $y <= $vidqty; $y++) {
|
215 |
+
|
216 |
+
if ( $getrnd ) {
|
217 |
+
$rnd_item = mt_rand(0, (count($items)-1));
|
218 |
+
while ( $y > 1 && in_array($rnd_item, $rnd_used) ) {
|
219 |
+
$rnd_item = mt_rand(0, (count($items)-1));
|
220 |
+
}
|
221 |
+
$rnd_used[] = $rnd_item;
|
222 |
+
$item = $items[$rnd_item];
|
223 |
+
} else {
|
224 |
+
$item = $items[$y-1];
|
225 |
+
//$next_item = $items[1];
|
226 |
+
}
|
227 |
+
|
228 |
+
// print single video block
|
229 |
+
ytc_print_video($item, $instance, $y);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
} // single playlist or ytc way
|
233 |
+
|
234 |
+
ytc_channel_link($instance); // insert link to channel on bootom of widget
|
235 |
+
?>
|
236 |
+
|
237 |
+
</div><!-- .youtube_channel -->
|
238 |
+
<?php
|
239 |
+
echo $after_widget;
|
240 |
+
}
|
241 |
+
|
242 |
+
}
|
243 |
+
|
244 |
+
/* function to print standard playlist embed code */
|
245 |
+
function ytc_only_pl($instance) {
|
246 |
+
$width = $instance['width'];
|
247 |
+
$height = height_ratio($width, $instance['ratio']) + 25;
|
248 |
+
$playlist = ytc_clean_playlist_id($instance['playlist']);
|
249 |
+
print '
|
250 |
+
<div class="ytc_video_container ytc_video_1 ytc_video_single">
|
251 |
+
<iframe src="http://www.youtube.com/embed/videoseries?list=PL'.$playlist.'"
|
252 |
+
width="'.$width.'" height="'.$height.'" frameborder="0"></iframe>
|
253 |
+
</div>
|
254 |
+
';
|
255 |
+
}
|
256 |
+
|
257 |
+
/* function to print video in widget */
|
258 |
+
function ytc_print_video($item, $instance, $y) {
|
259 |
+
/* video settings */
|
260 |
+
|
261 |
+
// get hideinfo, autoplay and controls settings
|
262 |
+
// where this is used?
|
263 |
+
$hideinfo = $instance['hideinfo'];
|
264 |
+
$autoplay = $instance['autoplay'];
|
265 |
+
$controls = $instance['controls'];
|
266 |
+
|
267 |
+
// set width and height
|
268 |
+
$width = $instance['width'];
|
269 |
+
$height = height_ratio($width, $instance['ratio']);
|
270 |
+
|
271 |
+
// calculate image height based on width for 4:3 thumbnail
|
272 |
+
$imgfixedheight = $width / 4 * 3;
|
273 |
+
|
274 |
+
// which type to show
|
275 |
+
$to_show = $instance['to_show'];
|
276 |
+
if ( $to_show == "" ) { $to_show = "object"; }
|
277 |
+
|
278 |
+
// if not thumbnail, increase video height for 25px taken by video controls
|
279 |
+
if ( $to_show != 'thumbnail' && !$controls && $instance['fixyt'] ) {
|
280 |
+
$height += 25;
|
281 |
+
}
|
282 |
+
|
283 |
+
$hideanno = $instance['hideanno'];
|
284 |
+
$themelight = $instance['themelight'];
|
285 |
+
/* end of video settings */
|
286 |
+
|
287 |
+
if ( $instance['usepl'] ) {
|
288 |
+
$yt_id = $item->get_link();
|
289 |
+
$yt_id = preg_replace('/^.*=(.*)&.*$/', '${1}', $yt_id);
|
290 |
+
|
291 |
+
#if ( $getrnd ) {
|
292 |
$yt_url = "v/$yt_id";
|
293 |
+
#} else {
|
294 |
+
# $yt_url = "p/$playlist";
|
295 |
+
#}
|
296 |
+
} else {
|
297 |
+
$yt_id = split(":", $item->get_id());
|
298 |
+
$yt_id = $yt_id[3];
|
299 |
+
$yt_url = "v/$yt_id";
|
300 |
+
}
|
301 |
+
|
302 |
+
$yt_thumb = "http://img.youtube.com/vi/$yt_id/0.jpg"; // zero for HD thumb
|
303 |
+
$yt_video = $item->get_permalink();
|
304 |
+
$yt_title = esc_html( $item->get_title() );
|
305 |
+
$yt_date = $item->get_date('j F Y | g:i a');
|
306 |
+
// $next_id = split(":", $next_item->get_id());
|
307 |
+
// $next_id = $yt_id[3];
|
308 |
+
|
309 |
+
switch ($y) {
|
310 |
+
case 1:
|
311 |
+
$vnumclass = 'first';
|
312 |
+
break;
|
313 |
+
case $instance['vidqty']:
|
314 |
+
$vnumclass = 'last';
|
315 |
+
break;
|
316 |
+
default:
|
317 |
+
$vnumclass = 'mid';
|
318 |
+
break;
|
319 |
+
}
|
320 |
+
|
321 |
+
echo '<div class="ytc_video_container ytc_video_'.$y.' ytc_video_'.$vnumclass.'">';
|
322 |
+
|
323 |
+
// show video title?
|
324 |
+
if ( $instance['showtitle'] ) {
|
325 |
+
echo '<h3 class="ytc_title">'.$yt_title.'</h3>';
|
326 |
+
}
|
327 |
|
328 |
+
// define object ID
|
329 |
+
$ytc_vid = 'ytc_' . $yt_id;
|
330 |
|
331 |
+
// print out video
|
332 |
+
if ( $to_show == "thumbnail" ) {
|
333 |
$title = sprintf( __( 'Watch video %1$s published on %2$s' , 'youtube-channel' ), $yt_title, $yt_date );
|
334 |
+
/* if ( $instance['lightbox'] ) { $in_lightbox = 'rel="ytc-lightbox"'; } else { $in_lightbox = ''; } */
|
335 |
echo <<<EOF
|
336 |
<a href="$yt_video" title="$title"><div style="width: ${width}px; height: ${height}px; overflow: hidden; background: url($yt_thumb) 50% 50% no-repeat; background-size: ${width}px ${imgfixedheight}px;" title="$yt_title" id="$ytc_vid"></div></a>
|
337 |
EOF;
|
338 |
+
} else if ( $to_show == "chromeless" ) {
|
339 |
?>
|
340 |
<object type="application/x-shockwave-flash" data="<?php echo YOUTUBE_CHANNEL_URL . 'chromeless.swf'; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" id="<?php echo $ytc_vid; ?>">
|
341 |
<param name="flashVars" value="video_source=<?php echo $yt_id; ?>&video_width=<?php echo $width; ?>&video_height=<?php echo $height; ?><?php if ( $autoplay ) { echo "&autoplay=Yes"; } if ( !$controls ) { echo "&youtube_controls=Yes"; } if ( $hideanno ) { echo "&iv_load_policy=3"; } if ( $themelight ) { echo "&theme=light"; } ?>" />
|
345 |
<param name="movie" value="<?php echo YOUTUBE_CHANNEL_URL . 'chromeless.swf'; ?>" />
|
346 |
</object>
|
347 |
<?php
|
348 |
+
} else if ( $to_show == "iframe" ) {
|
349 |
+
if (!$usepl) { $yt_url = $yt_id; }
|
350 |
?>
|
351 |
<iframe title="YouTube video player" width="<?php echo $width; ?>" height="<?php echo $height; ?>" src="http://www.youtube.com/embed/<?php echo $yt_url."?wmode=opaque&enablejsapi=1"; if ( $controls ) { echo "&controls=0"; } if ( $hideinfo ) { echo "&showinfo=0"; } if ( $autoplay ) { echo "&autoplay=1"; } if ( $hideanno ) { echo "&iv_load_policy=3"; } if ( $themelight ) { echo "&theme=light"; } ?>" frameborder="0" allowfullscreen id="<?php echo $ytc_vid ?>"></iframe>
|
352 |
<?php
|
353 |
+
} else { // default is object
|
354 |
?>
|
355 |
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="<?php echo $width; ?>" height="<?php echo $height; ?>" id="<?php echo $ytc_vid; ?>">
|
356 |
<param name="movie" value="http://www.youtube.com/<?php echo $yt_url; ?>?version=3<?php if ( $controls ) { echo "&controls=0"; } if ( $hideinfo ) { echo "&showinfo=0"; } if ( $autoplay ) { echo "&autoplay=1"; } if ( $hideanno ) { echo "&iv_load_policy=3"; } if ( $themelight ) { echo "&theme=light"; } ?>" />
|
364 |
<!--<![endif]-->
|
365 |
</object>
|
366 |
<?php
|
367 |
+
}
|
368 |
+
|
369 |
+
// do we need to show video description?
|
370 |
+
if ( $instance['showvidesc'] ) {
|
371 |
+
preg_match('/<div><span>(.*)<\/span><\/div>/', $item->get_description(), $videsc);
|
372 |
+
if ( $instance['videsclen'] > 0 ) {
|
373 |
+
$video_description = substr($videsc[1], 0, $instance['videsclen']);
|
374 |
+
} else {
|
375 |
+
$video_description = $videsc[1];
|
376 |
+
}
|
377 |
+
if ( $video_description != '' ) {
|
378 |
+
if ( $instance['descappend'] ) {
|
379 |
+
$etcetera = $instance['descappend'];
|
380 |
+
} else {
|
381 |
+
$etcetera = '…';
|
382 |
+
}
|
383 |
}
|
384 |
+
echo '<p class="ytc_description">' .$video_description.$etcetera. '</p>';
|
385 |
+
}
|
386 |
+
echo '</div><!-- .ytc_video_container -->';
|
387 |
+
}
|
388 |
|
389 |
+
// function to calculate height by width and ratio
|
390 |
+
function height_ratio($width, $ratio) {
|
391 |
+
if ( $width == "" ) { $width = 220; }
|
392 |
+
|
393 |
+
if ( $ratio == 1 ) { // 4:3
|
394 |
+
$height = round(($width / 4 ) * 3);
|
395 |
+
} else if ( $ratio == 2 ) { // 16:10
|
396 |
+
$height = round(($width / 16 ) * 10);
|
397 |
+
} else if ( $ratio == 3 ) { // 16:9
|
398 |
+
$height = round(($width / 16 ) * 9);
|
399 |
+
} else { // set default if 0 or ratio not set
|
400 |
+
$height = $instance['height'];
|
401 |
+
if ( $height == "" ) { $height = 165; }
|
402 |
}
|
403 |
+
return $height;
|
|
|
404 |
}
|
405 |
+
|
406 |
+
// function to insert link to channel
|
407 |
+
function ytc_channel_link($instance) {
|
408 |
+
// do we need to show goto link?
|
409 |
+
if ( $instance['showgoto'] ) {
|
410 |
+
$channel = $instance['channel'];
|
411 |
+
$goto_txt = $instance['goto_txt'];
|
412 |
+
if ( $goto_txt == "" ) {
|
413 |
+
$goto_txt = sprintf( __( 'Visit channel %1$s' , 'youtube-channel' ), $channel );
|
414 |
+
}
|
415 |
+
|
416 |
+
echo '<div class="ytc_link">';
|
417 |
+
if ( $instance['popupgoto'] ) {
|
418 |
+
$newtab = __("in new window/tab", "youtube-channel");
|
419 |
+
if ( $instance['target'] ) {
|
420 |
echo <<<EOF
|
421 |
+
<a href="http://www.youtube.com/user/$channel/" target="_blank" title="$goto_txt $newtab">$goto_txt</a>
|
422 |
EOF;
|
423 |
+
} else {
|
424 |
echo <<<EOF
|
425 |
+
<a href="javascript: window.open('http://www.youtube.com/user/$channel/'); void 0;" title="$goto_txt $newtab">$goto_txt</a>
|
426 |
EOF;
|
427 |
+
} // target
|
428 |
+
} else {
|
429 |
echo <<<EOF
|
430 |
<p><a href="http://www.youtube.com/user/$channel/" title="$goto_txt">$goto_txt</a></p>
|
431 |
EOF;
|
432 |
+
} // popupgoto
|
433 |
+
echo '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
|
435 |
+
} // showgoto
|
436 |
+
}
|
437 |
+
|
438 |
+
function ytc_clean_playlist_id($playlist) {
|
439 |
+
if ( substr($playlist,0,4) == "http" ) {
|
440 |
+
// if URL provided, extract playlist ID
|
441 |
+
$playlist = preg_replace('/.*list=PL([A-Z0-9]*).*/','$1', $playlist);
|
442 |
+
} else if ( substr($playlist,0,2) == 'PL' ) {
|
443 |
+
$playlist = substr($playlist,2);
|
444 |
+
}
|
445 |
+
return $playlist;
|
446 |
}
|
447 |
|
448 |
/* Register plugin's widget */
|