Youtube Channel Gallery - Version 1.5.3

Version Description

  • Added tabs to the widget interface to better organize the fields.
  • Added new fields to control the player (Aspect ratio, Progress bar color, Autoplay, Show related videos, Show info).
  • Added Aspect ratio field to thumbnails.
  • Added Link text field to Links.
  • Added class to last thumbnail of each row to delete the margin-right in CSS.
  • Added class to first thumbnail of each row to clear float in CSS.
  • Check that the inserted user name exists.
  • Changes in CSS.
Download this release

Release Info

Developer javitxu123
Plugin Icon 128x128 Youtube Channel Gallery
Version 1.5.3
Comparing to
See all releases

Code changes from version 1.4.8.1 to 1.5.3

admin-styles.css ADDED
@@ -0,0 +1,46 @@
1
+
2
+ /*clearfix*/
3
+ .clearfix:before, .clearfix:after { content: ""; display: table; }
4
+ .clearfix:after { clear: both; }
5
+ .clearfix { zoom: 1; }
6
+
7
+
8
+ /*tabs ul*/
9
+ .ytchgtabs ul{
10
+ margin: 0;
11
+ padding: 0;
12
+ }
13
+
14
+ /*tabs li*/
15
+ .ytchgtabs li {
16
+ display: inline-block; margin: 1px .2em 0 0;
17
+ padding: 0;
18
+ list-style: none; white-space: nowrap;
19
+ position: relative;
20
+ background: #F3F3F3;
21
+ border: 1px solid #DFDFDF;
22
+ border-bottom: none;
23
+ border-radius: 5px 5px 0 0;
24
+ }
25
+ .ytchgtabs li.active{
26
+ margin-bottom: -1px;
27
+ padding-bottom: 1px;
28
+ background: #FAFAFA;
29
+ }
30
+
31
+
32
+
33
+ /*tabs a*/
34
+ .ytchgtabs a{
35
+ padding: 5px;
36
+ display: inline-block;
37
+ }
38
+
39
+ /*content*/
40
+ .ytchgtabs div {
41
+
42
+ border: 1px solid #DFDFDF;
43
+ padding: 1em 1.4em;
44
+ background: none;
45
+ background: #FAFAFA;
46
+ }
languages/youtube-channel-gallery-es_ES.mo CHANGED
Binary file
languages/youtube-channel-gallery-es_ES.po CHANGED
@@ -7,8 +7,8 @@ msgid ""
7
msgstr ""
8
"Project-Id-Version: youtube-channel-gallery\n"
9
"Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2012-07-24 14:14+0100\n"
11
- "PO-Revision-Date: 2012-07-24 14:15+0100\n"
12
"Last-Translator: Javier <javierpose@gmail.com>\n"
13
"Language-Team: PoseLab <javierpose@gmail.com>\n"
14
"MIME-Version: 1.0\n"
@@ -23,91 +23,111 @@ msgstr ""
23
"X-Poedit-SourceCharset: utf-8\n"
24
"X-Poedit-SearchPath-0: .\n"
25
26
- #: youtube-channel-gallery.php:44
27
- #: pruebas/youtube-channel-gallery_bueno.php:46
28
- #: pruebas/youtube-channel-gallery_bueno2.php:46
29
msgid "Youtube Channel Gallery"
30
msgstr "Galería de Canal de Youtube"
31
32
- #: youtube-channel-gallery.php:45
33
- #: pruebas/youtube-channel-gallery_bueno.php:47
34
- #: pruebas/youtube-channel-gallery_bueno2.php:47
35
msgid "Show a youtube video and a gallery of thumbnails for a youtube channel"
36
msgstr "Muestra un vídeo y una galería de miniaturas de una canal de Youtube "
37
38
- #: youtube-channel-gallery.php:100
39
- #: pruebas/youtube-channel-gallery_bueno.php:109
40
- #: pruebas/youtube-channel-gallery_bueno2.php:107
41
msgid "Title:"
42
msgstr "Título:"
43
44
- #: youtube-channel-gallery.php:105
45
- #: pruebas/youtube-channel-gallery_bueno.php:114
46
- #: pruebas/youtube-channel-gallery_bueno2.php:112
47
msgid "YouTube user name:"
48
msgstr "Nombre de usuario de Youtube:"
49
50
- #: youtube-channel-gallery.php:111
51
- #: pruebas/youtube-channel-gallery_bueno.php:120
52
- #: pruebas/youtube-channel-gallery_bueno2.php:118
53
- msgid "Show link to channel:"
54
- msgstr "Mostrar enlace al canal:"
55
-
56
- #: youtube-channel-gallery.php:115
57
- #: pruebas/youtube-channel-gallery_bueno.php:124
58
- #: pruebas/youtube-channel-gallery_bueno2.php:122
59
- msgid "Number of videos to show:"
60
- msgstr "Número de vídeos a mostrar:"
61
-
62
- #: youtube-channel-gallery.php:120
63
- #: pruebas/youtube-channel-gallery_bueno.php:129
64
- #: pruebas/youtube-channel-gallery_bueno2.php:127
65
msgid "Video width:"
66
msgstr "Ancho del vídeo:"
67
68
- #: youtube-channel-gallery.php:125
69
- #: pruebas/youtube-channel-gallery_bueno.php:134
70
- #: pruebas/youtube-channel-gallery_bueno2.php:132
71
- msgid "Thumbnail width:"
72
- msgstr "Ancho de miniaturas:"
73
74
- #: youtube-channel-gallery.php:130
75
- #: pruebas/youtube-channel-gallery_bueno.php:139
76
- #: pruebas/youtube-channel-gallery_bueno.php:144
77
- #: pruebas/youtube-channel-gallery_bueno2.php:137
78
- msgid "Thumbnail columns:"
79
- msgstr "Columnas de las miniaturas:"
80
81
- #: youtube-channel-gallery.php:135
82
- #: pruebas/youtube-channel-gallery_bueno.php:149
83
msgid "Theme:"
84
msgstr "Tema:"
85
86
- #: youtube-channel-gallery.php:137
87
- #: pruebas/youtube-channel-gallery_bueno.php:151
88
msgid "Dark"
89
msgstr "Oscuro"
90
91
- #: youtube-channel-gallery.php:138
92
msgid "Light"
93
msgstr "Claro"
94
95
- #: youtube-channel-gallery.php:270
96
- #: pruebas/youtube-channel-gallery_bueno.php:345
97
- #: pruebas/youtube-channel-gallery_bueno2.php:315
98
msgid "Show more videos»"
99
msgstr "Ver más vídeos»"
100
101
- #: youtube-channel-gallery.php:276
102
- #: pruebas/youtube-channel-gallery_bueno.php:351
103
- #: pruebas/youtube-channel-gallery_bueno2.php:321
104
msgid "There is no video to show."
105
msgstr "No hay ningún vídeo para mostrar."
106
107
- #: pruebas/youtube-channel-gallery_bueno.php:152
108
- msgid "Light:"
109
- msgstr "Claro"
110
-
111
#~ msgid "No post to duplicate has been supplied!"
112
#~ msgstr "No se facilitó ninguna entrada a copiar"
113
#~ msgid "Post creation failed, could not find original post:"
7
msgstr ""
8
"Project-Id-Version: youtube-channel-gallery\n"
9
"Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2012-10-17 10:30+0100\n"
11
+ "PO-Revision-Date: 2012-10-17 10:34+0100\n"
12
"Last-Translator: Javier <javierpose@gmail.com>\n"
13
"Language-Team: PoseLab <javierpose@gmail.com>\n"
14
"MIME-Version: 1.0\n"
23
"X-Poedit-SourceCharset: utf-8\n"
24
"X-Poedit-SearchPath-0: .\n"
25
26
+ #: youtube-channel-gallery.php:48
27
msgid "Youtube Channel Gallery"
28
msgstr "Galería de Canal de Youtube"
29
30
+ #: youtube-channel-gallery.php:49
31
msgid "Show a youtube video and a gallery of thumbnails for a youtube channel"
32
msgstr "Muestra un vídeo y una galería de miniaturas de una canal de Youtube "
33
34
+ #: youtube-channel-gallery.php:134
35
msgid "Title:"
36
msgstr "Título:"
37
38
+ #: youtube-channel-gallery.php:139
39
msgid "YouTube user name:"
40
msgstr "Nombre de usuario de Youtube:"
41
42
+ #: youtube-channel-gallery.php:181
43
msgid "Video width:"
44
msgstr "Ancho del vídeo:"
45
46
+ #: youtube-channel-gallery.php:187
47
+ #: youtube-channel-gallery.php:241
48
+ msgid "Aspect ratio:"
49
+ msgstr "Relación de aspecto:"
50
51
+ #: youtube-channel-gallery.php:189
52
+ #: youtube-channel-gallery.php:243
53
+ msgid "Standard (4x3)"
54
+ msgstr "Estándar (4x3)"
55
+
56
+ #: youtube-channel-gallery.php:190
57
+ #: youtube-channel-gallery.php:244
58
+ msgid "Widescreen (16x9)"
59
+ msgstr "Panorámico (16x9)"
60
61
+ #: youtube-channel-gallery.php:196
62
msgid "Theme:"
63
msgstr "Tema:"
64
65
+ #: youtube-channel-gallery.php:198
66
msgid "Dark"
67
msgstr "Oscuro"
68
69
+ #: youtube-channel-gallery.php:199
70
msgid "Light"
71
msgstr "Claro"
72
73
+ #: youtube-channel-gallery.php:205
74
+ msgid "Progress bar color:"
75
+ msgstr "Color de barra de progreso:"
76
+
77
+ #: youtube-channel-gallery.php:207
78
+ msgid "Red"
79
+ msgstr "Rojo"
80
+
81
+ #: youtube-channel-gallery.php:208
82
+ msgid "White"
83
+ msgstr "Blanco"
84
+
85
+ #: youtube-channel-gallery.php:213
86
+ msgid "Autoplay"
87
+ msgstr "Autoplay"
88
+
89
+ #: youtube-channel-gallery.php:218
90
+ msgid "Show related videos"
91
+ msgstr "Mostrar los vídeos relacionados"
92
+
93
+ #: youtube-channel-gallery.php:223
94
+ msgid "Show info (title, uploader)"
95
+ msgstr "Mostrar información (título, cargador)"
96
+
97
+ #: youtube-channel-gallery.php:230
98
+ msgid "Number of videos to show:"
99
+ msgstr "Número de vídeos a mostrar:"
100
+
101
+ #: youtube-channel-gallery.php:235
102
+ msgid "Thumbnail width:"
103
+ msgstr "Ancho de miniaturas:"
104
+
105
+ #: youtube-channel-gallery.php:249
106
+ msgid "Thumbnail columns:"
107
+ msgstr "Columnas de las miniaturas:"
108
+
109
+ #: youtube-channel-gallery.php:258
110
+ msgid "Link text:"
111
+ msgstr "Texto del enlace"
112
+
113
+ #: youtube-channel-gallery.php:264
114
+ msgid "Show link to channel:"
115
+ msgstr "Mostrar enlace al canal:"
116
+
117
+ #: youtube-channel-gallery.php:325
118
msgid "Show more videos»"
119
msgstr "Ver más vídeos»"
120
121
+ #: youtube-channel-gallery.php:358
122
+ msgid "You must insert a valid YouTube user name."
123
+ msgstr "Debe introducir un nombre válido de usuario de YouTube."
124
+
125
+ #: youtube-channel-gallery.php:447
126
msgid "There is no video to show."
127
msgstr "No hay ningún vídeo para mostrar."
128
129
+ #~ msgid "Light:"
130
+ #~ msgstr "Claro"
131
#~ msgid "No post to duplicate has been supplied!"
132
#~ msgstr "No se facilitó ninguna entrada a copiar"
133
#~ msgid "Post creation failed, could not find original post:"
readme.txt CHANGED
@@ -4,11 +4,11 @@ Donate link: http://poselab.com/
4
Tags: widget, gallery, youtube, channel, user
5
Requires at least: 2.8
6
Tested up to: 3.4.1
7
- Stable tag: 1.4.8.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
11
- Show a youtube video and a gallery of thumbnails for a youtube channel.
12
13
== Description ==
14
@@ -17,40 +17,89 @@ Show a youtube video and a gallery of thumbnails for a youtube user channel.
17
= Features: =
18
* Display latest thumbnail videos from YouTube user channel.
19
* When you click on one of the thumbnails the video plays at the top.
20
- * This plugin uses the YouTube IFrame player API that allows YouTube to serve an HTML5 player rather than a Flash player for mobile devices that do not support Flash.
21
* You can choose to use this plugin as a widget or as a shortcode.
22
* You can use multiple instances of the plugin on the same page.
23
24
= Widget fields: =
25
* Title: Widget Title.
26
* YouTube user name: the username of the user's Youtube videos you want to show.
27
- * Show link to channel: option to display a link to the youtube user channel.
28
* Number of videos to show: It must be a number indicating the number of thumbnails to be displayed.
29
- * Video width: indicates the width of the video player.
30
* Thumbnail size: indicates the width of the thumbnails. The height is automatically generated.
31
* Thumbnail columns: assign a numeric class to each thumbnail based on the number of columns to apply styles to each column.
32
- * Theme: select the youtube player theme (dark or light).
33
34
= Shortcode syntax: =
35
If you want to use it as Shortcode:
36
37
- `[Youtube_Channel_Gallery user="MaxonC4D" maxitems="3" theme="dark"]`
38
39
The attributes used in the shortcode are the same as the fields available in the widget, except the title field.
40
41
* user: YouTube user name (required).
42
- * link: Show link to channel. Values: 0 or 1. (optional).
43
- * maxitems: Number of videos to show (optional).
44
- * videowidth: Video width (optional).
45
- * thumbwidth: Thumbnail size (optional).
46
- * thumbcolumns: Thumbnail columns (optional).
47
- * theme: Theme. Values: dark or light (optional).
48
49
50
- = Demo: =
51
- You can see a demo of the plugin at the following URL:
52
53
- [Youtube Channel Gallery Demo](http://poselab.com/youtube-channel-gallery)
54
55
= Languages: =
56
* Spanish (es_ES) - [PoseLab](http://poselab.com/)
@@ -65,6 +114,7 @@ If you have created your own language pack, or have an update of an existing one
65
2. Activate the plugin through the 'Plugins' menu in WordPress.
66
3. Place the widget in your desired sidebar through the "widgets" admin page.
67
68
== Frequently Asked Questions ==
69
70
= Where is the “widgets” admin page? =
@@ -75,13 +125,25 @@ The “widgets” admin page is found in the administrator part (wp-admin) of yo
75
76
The username who uploaded a video to Youtube is located below each video, where says something like in this example, "Published on June 25, 2012 by DisneyShorts", where DisneyShorts is the username.
77
78
== Screenshots ==
79
80
1. Youtube Channel Gallery admin area.
81
2. Youtube Channel Gallery.
82
83
== Changelog ==
84
85
= 1.4.8.1 =
86
* Fixed warning: Cannot modify header information...
87
@@ -96,7 +158,7 @@ The username who uploaded a video to Youtube is located below each video, where
96
97
= 1.4.6 =
98
* Tweak on CSS.
99
- * Trying to correct issue that some users have with the player origin parameter.
100
101
= 1.4.5 =
102
* Tweaks on CSS.
@@ -119,4 +181,11 @@ The username who uploaded a video to Youtube is located below each video, where
119
* Added effect: hover on thumbnails to display a play button.
120
121
= 1.0 =
122
- * Initial Release.
4
Tags: widget, gallery, youtube, channel, user
5
Requires at least: 2.8
6
Tested up to: 3.4.1
7
+ Stable tag: 1.5.3
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
11
+ Show a YouTube video and a gallery of thumbnails for a youtube channel.
12
13
== Description ==
14
17
= Features: =
18
* Display latest thumbnail videos from YouTube user channel.
19
* When you click on one of the thumbnails the video plays at the top.
20
+ * This plugin uses the YouTube IFrame player API that allows YouTube to serve an HTML5 player, rather than a Flash player, for mobile devices that do not support Flash.
21
* You can choose to use this plugin as a widget or as a shortcode.
22
* You can use multiple instances of the plugin on the same page.
23
24
+
25
+ = Demo: =
26
+ You can see a demo of the plugin at the following URL:
27
+
28
+ [Youtube Channel Gallery Demo](http://poselab.com/youtube-channel-gallery)
29
+
30
+
31
= Widget fields: =
32
+ Description of the different fields of the widget.
33
+
34
* Title: Widget Title.
35
* YouTube user name: the username of the user's Youtube videos you want to show.
36
+
37
+ Player:
38
+
39
+ * Video width: indicates the width of the video player. Value: Number.
40
+ * Aspect ratio: indicates the proportions of the player, widescreen (16:9) or standard (4:3) format.
41
+ * Theme: display player controls (like a 'play' button or volume control) within a dark or light control bar.
42
+ * Progress bar color: specifies the color that will be used in the player's video progress bar to highlight the amount of the video that the viewer has already seen.
43
+ * Autoplay: Automatically play the initial video when the player loads.
44
+ * Show related videos: Load related videos once playback of initial video starts and display in "genie menu" when menu button is pressed.
45
+ * Show info (title, uploader): Display information like the video title and rating before the video starts playing.
46
+
47
+ Thumbnails:
48
+
49
* Number of videos to show: It must be a number indicating the number of thumbnails to be displayed.
50
* Thumbnail size: indicates the width of the thumbnails. The height is automatically generated.
51
+ * Aspect ratio: indicates the proportions of the thumbnails, widescreen (16:9) or standard (4:3) format.
52
* Thumbnail columns: assign a numeric class to each thumbnail based on the number of columns to apply styles to each column.
53
+
54
+ Link:
55
+
56
+ * Link text: field to customize the text of the link to the gallery on YouTube.
57
+ * Show link to channel: option to display a link to the youtube user channel.
58
+
59
60
= Shortcode syntax: =
61
If you want to use it as Shortcode:
62
63
+ `[Youtube_Channel_Gallery
64
+ user="MaxonC4D"
65
+ videowidth="500"
66
+ ratio="16/9"
67
+ theme="light"
68
+ color="white"
69
+ autoplay="1"
70
+ rel="1"
71
+ showinfo="1"
72
+ maxitems="9"
73
+ thumbwidth="90"
74
+ thumbratio="16/9"
75
+ thumbcolumns="3"
76
+ ]`
77
78
The attributes used in the shortcode are the same as the fields available in the widget, except the title field.
79
80
* user: YouTube user name (required).
81
82
+ Player:
83
84
+ * videowidth: Video width. Values: Number. (optional).
85
+ * ratio: Aspect ratio. Values: 4/3 (default) / 16/9. (optional).
86
+ * theme: Theme. Values: dark (default) / light. (optional).
87
+ * color: Progress bar color. Values: red (default) / white. (optional).
88
+ * autoplay: Autoplay. Values: 0 (default) / 1. (optional).
89
+ * rel: Show related videos. Values: 0 (default) / 1. (optional).
90
+ * showinfo: Show info (title, uploader). Values: 0 (default) / 1. (optional).
91
92
+ Thumbnails:
93
+
94
+ * maxitems: Number of videos to show. Values: Number. (optional).
95
+ * thumbwidth: Thumbnail size. Values: Number. (optional).
96
+ * thumbratio: Aspect ratio. Values: 4/3 (default) / 16/9. (optional).
97
+ * thumbcolumns: Thumbnail columns. Values: Number. (optional).
98
+
99
+ Link:
100
+
101
+ * link_tx: Link text. Values: String. (optional).
102
+ * link: Show link to channel. Values: 0 (default) / 1. (optional).
103
104
= Languages: =
105
* Spanish (es_ES) - [PoseLab](http://poselab.com/)
114
2. Activate the plugin through the 'Plugins' menu in WordPress.
115
3. Place the widget in your desired sidebar through the "widgets" admin page.
116
117
+
118
== Frequently Asked Questions ==
119
120
= Where is the “widgets” admin page? =
125
126
The username who uploaded a video to Youtube is located below each video, where says something like in this example, "Published on June 25, 2012 by DisneyShorts", where DisneyShorts is the username.
127
128
+
129
== Screenshots ==
130
131
1. Youtube Channel Gallery admin area.
132
2. Youtube Channel Gallery.
133
134
+
135
== Changelog ==
136
137
+ = 1.5.3 =
138
+ * Added tabs to the widget interface to better organize the fields.
139
+ * Added new fields to control the player (Aspect ratio, Progress bar color, Autoplay, Show related videos, Show info).
140
+ * Added Aspect ratio field to thumbnails.
141
+ * Added Link text field to Links.
142
+ * Added class to last thumbnail of each row to delete the margin-right in CSS.
143
+ * Added class to first thumbnail of each row to clear float in CSS.
144
+ * Check that the inserted user name exists.
145
+ * Changes in CSS.
146
+
147
= 1.4.8.1 =
148
* Fixed warning: Cannot modify header information...
149
158
159
= 1.4.6 =
160
* Tweak on CSS.
161
+ * Trying to correct issue that some users have with the origin parameter of the player.
162
163
= 1.4.5 =
164
* Tweaks on CSS.
181
* Added effect: hover on thumbnails to display a play button.
182
183
= 1.0 =
184
+ * Initial Release.
185
+
186
+
187
+
188
+ == Upgrade Notice ==
189
+
190
+ = 1.5.3 =
191
+ * New fields to control the player
screenshot-1.jpg CHANGED
Binary file
screenshot-2.jpg CHANGED
Binary file
styles.css CHANGED
@@ -1,26 +1,50 @@
1
- .ytcplayer{
2
display: block;
3
margin-bottom: 10px;
4
- padding: 0
5
}
6
7
ul.ytchagallery{
8
margin: 0; padding: 0;
9
list-style: none;
10
- *zoom: 1;
11
- }
12
- ul.ytchagallery:before,ul.ytchagallery:after {
13
- content: " ";
14
- display: table;
15
- }
16
- ul.ytchagallery:after {
17
- clear: both;
18
}
19
20
ul.ytchagallery li{
21
float:left;
22
margin: 0 10px 10px 0;padding: 0
23
}
24
ul.ytchagallery li a{
25
display: block;
26
border:1px solid #999;
@@ -38,4 +62,9 @@ ul.ytchagallery li a:hover .ytcplay{
38
background-position: center center;
39
}
40
41
1
+ /*------------------------------*/
2
+ /*Youtube Channel Gallery plugin*/
3
+ /*------------------------------*/
4
+
5
+ /*clearfix*/
6
+ .ytccf:before,
7
+ .ytccf:after {
8
+ content: " ";
9
+ display: table;
10
+ }
11
+ .ytccf:after {
12
+ clear: both;
13
+ }
14
+ .ytccf {
15
+ *zoom: 1;
16
+ }
17
+
18
+
19
+ /*shortcode wrapper*/
20
+ .ytcshort{
21
+ margin: 10px 0
22
+ }
23
+
24
+ /*Player*/
25
+ iframe.ytcplayer{
26
display: block;
27
margin-bottom: 10px;
28
+ padding: 0;
29
+
30
}
31
32
+ /*Thumbnails*/
33
ul.ytchagallery{
34
margin: 0; padding: 0;
35
list-style: none;
36
}
37
38
ul.ytchagallery li{
39
float:left;
40
margin: 0 10px 10px 0;padding: 0
41
}
42
+ ul.ytchagallery li.ytccell-first{
43
+ clear: left;
44
+ }
45
+ ul.ytchagallery li.ytccell-last{
46
+ margin-right: 0;
47
+ }
48
ul.ytchagallery li a{
49
display: block;
50
border:1px solid #999;
62
background-position: center center;
63
}
64
65
+ /*link*/
66
+ .ytcmore{
67
+ display: block
68
+ }
69
+
70
youtube-channel-gallery.php CHANGED
@@ -5,7 +5,7 @@
5
Description: Show a youtube video and a gallery of thumbnails for a youtube channel.
6
Author: Javier Gómez Pose
7
Author URI: http://www.poselab.com/
8
- Version: 1.4.8.1
9
License: GPL2
10
11
Copyright 2010 Javier Gómez Pose (email : javierpose@gmail.com)
@@ -38,7 +38,10 @@
38
39
//localization
40
load_plugin_textdomain('youtube-channel-gallery', false, dirname(plugin_basename( __FILE__ ) ) . '/languages/' );
41
- add_shortcode('Youtube_Channel_Gallery', array($this, 'YoutubeChannelGallery_Shortcode'));
42
43
parent::__construct(
44
'youtubechannelgallery_widget', // Base ID
@@ -75,13 +78,25 @@
75
$instance = $old_instance;
76
$instance['title'] = strip_tags( $new_instance['title'] );
77
$instance['ytchag_user'] = strip_tags( $new_instance['ytchag_user'] );
78
79
- $instance['ytchag_link'] = $new_instance['ytchag_link'];
80
$instance['ytchag_maxitems'] = strip_tags( $new_instance['ytchag_maxitems'] );
81
- $instance['ytchag_video_width'] = strip_tags( $new_instance['ytchag_video_width'] );
82
$instance['ytchag_thumb_width'] = strip_tags( $new_instance['ytchag_thumb_width'] );
83
$instance['ytchag_thumb_columns'] = strip_tags( $new_instance['ytchag_thumb_columns'] );
84
- $instance['ytchag_theme'] = strip_tags( $new_instance['ytchag_theme'] );
85
86
return $instance;
87
}
@@ -90,15 +105,31 @@
90
* Back-end widget form.
91
*/
92
public function form( $instance ) {
93
- $title = esc_attr($instance['title']);
94
$ytchag_user = strip_tags($instance['ytchag_user']);
95
- $ytchag_link = esc_attr($instance['ytchag_link']);
96
- $ytchag_maxitems = strip_tags($instance['ytchag_maxitems']);
97
$ytchag_video_width = strip_tags($instance['ytchag_video_width']);
98
$ytchag_thumb_width = strip_tags($instance['ytchag_thumb_width']);
99
$ytchag_thumb_columns = strip_tags($instance['ytchag_thumb_columns']);
100
- $ytchag_theme = strip_tags($instance['ytchag_theme']);
101
?>
102
<p>
103
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'youtube-channel-gallery' ); ?></label>
104
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
@@ -108,39 +139,137 @@
108
<label for="<?php echo $this->get_field_id( 'ytchag_user' ); ?>"><?php _e( 'YouTube user name:', 'youtube-channel-gallery' ); ?></label>
109
<input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_user' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_user' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_user ); ?>" />
110
</p>
111
-
112
- <p>
113
- <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytchag_link'], true ); ?> id="<?php echo $this->get_field_id( 'ytchag_link' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_link' ); ?>" />
114
- <label for="<?php echo $this->get_field_id( 'ytchag_link' ); ?>"><?php _e('Show link to channel:', 'youtube-channel-gallery'); ?></label><br />
115
- </p>
116
-
117
- <p>
118
- <label for="ytchag_maxitems"><?php _e( 'Number of videos to show:', 'youtube-channel-gallery' ); ?></label>
119
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_maxitems' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_maxitems' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_maxitems ); ?>" />
120
- </p>
121
-
122
- <p>
123
- <label for="ytchag_video_width"><?php _e( 'Video width:', 'youtube-channel-gallery' ); ?></label>
124
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_video_width' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_video_width' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_video_width ); ?>" />
125
- </p>
126
-
127
- <p>
128
- <label for="ytchag_thumb_width"><?php _e( 'Thumbnail width:', 'youtube-channel-gallery' ); ?></label>
129
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_thumb_width' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_thumb_width' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_thumb_width ); ?>" />
130
- </p>
131
-
132
- <p>
133
- <label for="ytchag_thumb_columns"><?php _e( 'Thumbnail columns:', 'youtube-channel-gallery' ); ?></label>
134
- <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_thumb_columns' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_thumb_columns' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_thumb_columns ); ?>" />
135
- </p>
136
137
- <p>
138
- <label for="ytchag_theme"><?php _e( 'Theme:', 'youtube-channel-gallery' ); ?></label>
139
- <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_theme' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_theme' ); ?>">
140
- <option value="dark"<?php selected( $instance['ytchag_theme'], 'dark' ); ?>><?php _e( 'Dark', 'youtube-channel-gallery' ); ?></option>
141
- <option value="light"<?php selected( $instance['ytchag_theme'], 'light' ); ?>><?php _e( 'Light', 'youtube-channel-gallery' ); ?></option>
142
- </select>
143
- </p>
144
145
<?php
146
}
@@ -152,107 +281,170 @@
152
private function ytchag_rss_markup($instance){
153
154
//$instance variables
155
$ytchag_user = apply_filters('ytchag_user', $instance['ytchag_user']);
156
- $ytchag_link = apply_filters('ytchag_link', $instance['ytchag_link']);
157
- $ytchag_maxitems = apply_filters('ytchag_maxitems', $instance['ytchag_maxitems']);
158
$ytchag_video_width = apply_filters('ytchag_video_width', $instance['ytchag_video_width']);
159
$ytchag_thumb_width = apply_filters('ytchag_thumb_width', $instance['ytchag_thumb_width']);
160
$ytchag_thumb_columns = apply_filters('ytchag_thumb_columns', $instance['ytchag_thumb_columns']);
161
- $ytchag_theme = apply_filters('ytchag_theme', $instance['ytchag_theme']);
162
163
//defaults
164
$ytchag_video_width = ( $ytchag_video_width ) ? $ytchag_video_width : 250;
165
$ytchag_thumb_width = ( $ytchag_thumb_width ) ? $ytchag_thumb_width : 85;
166
$ytchag_thumb_columns = ( $ytchag_thumb_columns ) ? $ytchag_thumb_columns : 0;
167
- $ytchag_theme = ( $ytchag_theme ) ? $ytchag_theme : 'dark';
168
169
//heights of video and thumbnail
170
- $ytchag_video_heigh = round($ytchag_video_width/(16/9) + 32);
171
- $ytchag_thumb_height = round($ytchag_thumb_width*75/100); // 75% 'cos sizes of thumbnail in xml file are 480x360 and 120x90
172
173
- if( $ytchag_user ) { // only if user name inserted
174
175
// links
176
$ytchag_rss_url = "http://gdata.youtube.com/feeds/api/users/" . $ytchag_user . "/uploads";
177
$ytchag_link_url = "http://www.youtube.com/user/" . $ytchag_user;
178
179
180
- //RSS Feed
181
-
182
- include_once(ABSPATH . WPINC . '/feed.php');
183
-
184
- $rss = fetch_feed($ytchag_rss_url);
185
- $maxitems = ( $ytchag_maxitems ) ? $ytchag_maxitems : 9;
186
- $items = $rss->get_items(0, $maxitems);
187
-
188
-
189
- if (!empty($items)) {
190
- $i = 0;
191
- $column = 0;
192
- foreach ( $items as $item ) {
193
194
- $url = $item->get_permalink();
195
- $youtubeid = $this->youtubeid($url);
196
- $title = $item->get_title();
197
198
- if ($enclosure = $item->get_enclosure()){
199
200
- //extract thumbnail
201
- //-----------------
202
203
- //thumbnail index in xml
204
- $big = 0;
205
- $small = 1;
206
- $size = $small;
207
- if($ytchag_thumb_width > '120'){
208
- $size = $big;
209
- }
210
211
- $allThumbs = $enclosure->get_thumbnails();
212
- foreach ($allThumbs as $index => $allThumb) {
213
- if ($index == $size) {
214
- $thumb = $allThumbs[$index];
215
}
216
}
217
- }
218
219
- //Show me the player: iframe player
220
- if($i == 0) {
221
- //count the plugin occurrences on page
222
- STATIC $plugincount = 0;
223
- $plugincount++;
224
225
- $content = '<iframe id="ytcplayer' . $plugincount . '" class="ytcplayer" width="' . $ytchag_video_width . '" height="' . $ytchag_video_heigh . '" src="http://www.youtube.com/embed/' . $youtubeid . '?&autoplay=0&theme=' . $ytchag_theme . '&enablejsapi=1" frameborder="0"></iframe>';
226
227
- $content.= '<ul class="ytchagallery">';
228
229
- } // if player end
230
- $i++;
231
232
- $column++;
233
- // list of thumbnail videos
234
-
235
- $content.= '<li class="ytccell-' . $column . '">';
236
- $content.= '<a class="ytcthumb" href="javascript: ytcplayVideo(\'ytcplayer' . $plugincount . '\', \'' . $youtubeid . '\');" alt="' . $title . '" title="' . $title . '" style="background-image: url(' . $thumb . ');">';
237
- $content.= '<div class="ytcplay" style="width: ' . $ytchag_thumb_width . 'px; height: ' . $ytchag_thumb_height . 'px"></div>';
238
- $content.= '</a></li>';
239
-
240
- if($ytchag_thumb_columns !=0 && $column%$ytchag_thumb_columns === 0){
241
- $column = 0;
242
- }
243
- } //foreach end
244
245
- $content.= '</ul>';
246
247
- //link to youtube.com gallery
248
- if( $ytchag_link) {
249
- $content.= '<a href="' . $ytchag_link_url . '" class="more">' . __('Show more videos»', 'youtube-channel-gallery') . '</a>';
250
-
251
}
252
- }
253
} else {
254
- $content.= '<p class="empty">' . __('There is no video to show.', 'youtube-channel-gallery') . '</p>';
255
-
256
}
257
258
return $content;
@@ -274,6 +466,11 @@
274
wp_enqueue_style('youtube-channel-gallery', plugins_url('/styles.css', __FILE__), false, false, 'all');
275
}//register_scripts_and_styles
276
277
/*--------------------------------------------------*/
278
/* Shortcode
279
/*--------------------------------------------------*/
@@ -285,25 +482,51 @@
285
286
extract( shortcode_atts( array(
287
'user' => '',
288
- 'link' => '0',
289
- 'maxitems' => '9',
290
- 'videowidth' => '280',
291
- 'thumbwidth' => '85',
292
- 'thumbcolumns' => '0',
293
- 'theme' => 'dark',
294
), $atts ) );
295
296
$instance['ytchag_user'] = $user;
297
-
298
- $instance['ytchag_link'] = $link;
299
- $instance['ytchag_maxitems'] = $maxitems;
300
$instance['ytchag_video_width'] = $videowidth;
301
$instance['ytchag_thumb_width'] = $thumbwidth;
302
$instance['ytchag_thumb_columns'] = $thumbcolumns;
303
- $instance['ytchag_theme'] = $theme;
304
305
306
- return $this->ytchag_rss_markup($instance);
307
308
} // YoutubeChannelGallery_Shortcode
309
5
Description: Show a youtube video and a gallery of thumbnails for a youtube channel.
6
Author: Javier Gómez Pose
7
Author URI: http://www.poselab.com/
8
+ Version: 1.5.3
9
License: GPL2
10
11
Copyright 2010 Javier Gómez Pose (email : javierpose@gmail.com)
38
39
//localization
40
load_plugin_textdomain('youtube-channel-gallery', false, dirname(plugin_basename( __FILE__ ) ) . '/languages/' );
41
+ add_shortcode('Youtube_Channel_Gallery', array($this, 'YoutubeChannelGallery_Shortcode'));
42
+
43
+ //load admin scripts
44
+ add_action('admin_print_scripts', array($this, 'register_admin_scripts_and_styles'));
45
46
parent::__construct(
47
'youtubechannelgallery_widget', // Base ID
78
$instance = $old_instance;
79
$instance['title'] = strip_tags( $new_instance['title'] );
80
$instance['ytchag_user'] = strip_tags( $new_instance['ytchag_user'] );
81
+
82
+ // Player options
83
+ $instance['ytchag_video_width'] = strip_tags( $new_instance['ytchag_video_width'] );
84
+ $instance['ytchag_ratio'] = strip_tags( $new_instance['ytchag_ratio'] );
85
+ $instance['ytchag_theme'] = strip_tags( $new_instance['ytchag_theme'] );
86
+ $instance['ytchag_color'] = strip_tags( $new_instance['ytchag_color'] );
87
+ $instance['ytchag_autoplay'] = strip_tags( $new_instance['ytchag_autoplay'] );
88
+ $instance['ytchag_rel'] = strip_tags( $new_instance['ytchag_rel'] );
89
+ $instance['ytchag_showinfo'] = ( isset( $new_instance['ytchag_showinfo'] ) ? 0 : 1 );
90
91
+ // Thumbnail options
92
$instance['ytchag_maxitems'] = strip_tags( $new_instance['ytchag_maxitems'] );
93
$instance['ytchag_thumb_width'] = strip_tags( $new_instance['ytchag_thumb_width'] );
94
+ $instance['ytchag_thumb_ratio'] = strip_tags( $new_instance['ytchag_thumb_ratio'] );
95
$instance['ytchag_thumb_columns'] = strip_tags( $new_instance['ytchag_thumb_columns'] );
96
+
97
+ // Link options
98
+ $instance['ytchag_link'] = $new_instance['ytchag_link'];
99
+ $instance['ytchag_link_tx'] = strip_tags( $new_instance['ytchag_link_tx'] );
100
101
return $instance;
102
}
105
* Back-end widget form.
106
*/
107
public function form( $instance ) {
108
+ $title = esc_attr($instance['title']);
109
$ytchag_user = strip_tags($instance['ytchag_user']);
110
+
111
+ // Player options
112
$ytchag_video_width = strip_tags($instance['ytchag_video_width']);
113
+ $ytchag_ratio = strip_tags($instance['ytchag_ratio']);
114
+ $ytchag_theme = strip_tags($instance['ytchag_theme']);
115
+ $ytchag_color = strip_tags($instance['ytchag_color']);
116
+ $ytchag_autoplay = strip_tags($instance['ytchag_autoplay']);
117
+ $ytchag_rel = strip_tags($instance['ytchag_rel']);
118
+ $ytchag_showinfo = strip_tags($instance['ytchag_showinfo']);
119
+
120
+ // Thumbnail options
121
+ $ytchag_maxitems = strip_tags($instance['ytchag_maxitems']);
122
$ytchag_thumb_width = strip_tags($instance['ytchag_thumb_width']);
123
+ $ytchag_thumb_ratio = strip_tags($instance['ytchag_thumb_ratio']);
124
$ytchag_thumb_columns = strip_tags($instance['ytchag_thumb_columns']);
125
+
126
+ // Link options
127
+ $ytchag_link = esc_attr($instance['ytchag_link']);
128
+ $ytchag_link_tx = strip_tags($instance['ytchag_link_tx']);
129
+
130
?>
131
+
132
+ <div class="ytchg">
133
<p>
134
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'youtube-channel-gallery' ); ?></label>
135
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
139
<label for="<?php echo $this->get_field_id( 'ytchag_user' ); ?>"><?php _e( 'YouTube user name:', 'youtube-channel-gallery' ); ?></label>
140
<input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_user' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_user' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_user ); ?>" />
141
</p>
142
143
+
144
+ <script type="text/javascript">
145
+ jQuery(document).ready(function($) {
146
+ $('#tabs-<?php echo $this->id; ?> div').hide();
147
+ $('#tabs-<?php echo $this->id; ?>-1').show();
148
+ $('#tabs-<?php echo $this->id; ?> ul li:first').addClass('active');
149
+
150
+ $('#tabs-<?php echo $this->id; ?> ul li a').click(function(){
151
+ //not work on the current tab
152
+ if(!$(this).parent().hasClass('active')){
153
+ $('#tabs-<?php echo $this->id; ?> ul li').removeClass('active');
154
+ $(this).parent().addClass('active');
155
+ var currentTab = $(this).attr('href');
156
+ //slideUp and slideDown to give it animation
157
+ $('#tabs-<?php echo $this->id; ?> div').slideUp('fast');
158
+ $(currentTab).slideDown('fast');
159
+ }
160
+ return false;
161
+ });
162
+ });
163
+ </script>
164
+
165
+
166
+ <?php //http://wordpress.stackexchange.com/questions/5515/update-widget-form-after-drag-and-drop-wp-save-bug?>
167
+
168
+ <div id="tabs-<?php echo $this->id; ?>" class="ytchgtabs">
169
+
170
+
171
+ <ul>
172
+ <li><a href="#tabs-<?php echo $this->id; ?>-1">Player</a></li>
173
+ <li><a href="#tabs-<?php echo $this->id; ?>-2">Thumbnails</a></li>
174
+ <li><a href="#tabs-<?php echo $this->id; ?>-3">Link</a></li>
175
+ </ul>
176
+
177
+
178
+ <div id="tabs-<?php echo $this->id; ?>-1">
179
+
180
+ <p>
181
+ <label for="ytchag_video_width"><?php _e( 'Video width:', 'youtube-channel-gallery' ); ?></label>
182
+ <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_video_width' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_video_width' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_video_width ); ?>" />
183
+ </p>
184
+
185
+ <p>
186
+
187
+ <label for="ytchag_ratio"><?php _e( 'Aspect ratio:', 'youtube-channel-gallery' ); ?></label>
188
+ <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_ratio' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_ratio' ); ?>">
189
+ <option value="4x3"<?php selected( $instance['ytchag_ratio'], '4x3' ); ?>><?php _e( 'Standard (4x3)', 'youtube-channel-gallery' ); ?></option>
190
+ <option value="16x9"<?php selected( $instance['ytchag_ratio'], '16x9' ); ?>><?php _e( 'Widescreen (16x9)', 'youtube-channel-gallery' ); ?></option>
191
+ </select>
192
+ </p>
193
+
194
+ <p>
195
+
196
+ <label for="ytchag_theme"><?php _e( 'Theme:', 'youtube-channel-gallery' ); ?></label>
197
+ <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_theme' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_theme' ); ?>">
198
+ <option value="dark"<?php selected( $instance['ytchag_theme'], 'dark' ); ?>><?php _e( 'Dark', 'youtube-channel-gallery' ); ?></option>
199
+ <option value="light"<?php selected( $instance['ytchag_theme'], 'light' ); ?>><?php _e( 'Light', 'youtube-channel-gallery' ); ?></option>
200
+ </select>
201
+ </p>
202
+
203
+ <p>
204
+
205
+ <label for="ytchag_color"><?php _e( 'Progress bar color:', 'youtube-channel-gallery' ); ?></label>
206
+ <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_color' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_color' ); ?>">
207
+ <option value="red"<?php selected( $instance['ytchag_color'], 'red' ); ?>><?php _e( 'Red', 'youtube-channel-gallery' ); ?></option>
208
+ <option value="white"<?php selected( $instance['ytchag_color'], 'white' ); ?>><?php _e( 'White', 'youtube-channel-gallery' ); ?></option>
209
+ </select>
210
+ </p>
211
+
212
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytchag_autoplay'], true ); ?> id="<?php echo $this->get_field_id( 'ytchag_autoplay' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_autoplay' ); ?>" />
213
+ <label for="<?php echo $this->get_field_id( 'ytchag_autoplay' ); ?>"><?php _e('Autoplay', 'youtube-channel-gallery'); ?></label>
214
+
215
+ <br>
216
+
217
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytchag_rel'], true ); ?> id="<?php echo $this->get_field_id( 'ytchag_rel' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_rel' ); ?>" />
218
+ <label for="<?php echo $this->get_field_id( 'ytchag_rel' ); ?>"><?php _e('Show related videos', 'youtube-channel-gallery'); ?></label>
219
+
220
+ <br>
221
+
222
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytchag_showinfo'], true ); ?> id="<?php echo $this->get_field_id( 'ytchag_showinfo' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_showinfo' ); ?>" />
223
+ <label for="<?php echo $this->get_field_id( 'ytchag_showinfo' ); ?>"><?php _e('Show info (title, uploader)', 'youtube-channel-gallery'); ?></label>
224
+
225
+ </div>
226
+
227
+
228
+ <div id="tabs-<?php echo $this->id; ?>-2">
229
+ <p>
230
+ <label for="ytchag_maxitems"><?php _e( 'Number of videos to show:', 'youtube-channel-gallery' ); ?></label>
231
+ <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_maxitems' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_maxitems' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_maxitems ); ?>" />
232
+ </p>
233
+
234
+ <p>
235
+ <label for="ytchag_thumb_width"><?php _e( 'Thumbnail width:', 'youtube-channel-gallery' ); ?></label>
236
+ <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_thumb_width' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_thumb_width' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_thumb_width ); ?>" />
237
+ </p>
238
+
239
+ <p>
240
+
241
+ <label for="ytchag_thumb_ratio"><?php _e( 'Aspect ratio:', 'youtube-channel-gallery' ); ?></label>
242
+ <select class="widefat" id="<?php echo $this->get_field_id( 'ytchag_thumb_ratio' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_thumb_ratio' ); ?>">
243
+ <option value="4x3"<?php selected( $instance['ytchag_thumb_ratio'], '4x3' ); ?>><?php _e( 'Standard (4x3)', 'youtube-channel-gallery' ); ?></option>
244
+ <option value="16x9"<?php selected( $instance['ytchag_thumb_ratio'], '16x9' ); ?>><?php _e( 'Widescreen (16x9)', 'youtube-channel-gallery' ); ?></option>
245
+ </select>
246
+ </p>
247
+
248
+ <p>
249
+ <label for="ytchag_thumb_columns"><?php _e( 'Thumbnail columns:', 'youtube-channel-gallery' ); ?></label>
250
+ <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_thumb_columns' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_thumb_columns' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_thumb_columns ); ?>" />
251
+ </p>
252
+ </div>
253
+
254
+
255
+ <div id="tabs-<?php echo $this->id; ?>-3">
256
+
257
+ <p>
258
+ <label for="ytchag_link_tx"><?php _e( 'Link text:', 'youtube-channel-gallery' ); ?></label>
259
+ <input class="widefat" id="<?php echo $this->get_field_id( 'ytchag_link_tx' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_link_tx' ); ?>" type="text" value="<?php echo esc_attr( $ytchag_link_tx ); ?>" />
260
+ </p>
261
+
262
+ <p>
263
+ <input class="checkbox" type="checkbox" <?php checked( (bool) $instance['ytchag_link'], true ); ?> id="<?php echo $this->get_field_id( 'ytchag_link' ); ?>" name="<?php echo $this->get_field_name( 'ytchag_link' ); ?>" />
264
+ <label for="<?php echo $this->get_field_id( 'ytchag_link' ); ?>"><?php _e('Show link to channel:', 'youtube-channel-gallery'); ?></label>
265
+ </p>
266
+
267
+ </div>
268
+ </div>
269
+
270
+
271
+
272
+ </div>
273
274
<?php
275
}
281
private function ytchag_rss_markup($instance){
282
283
//$instance variables
284
+ //--------------------------------
285
$ytchag_user = apply_filters('ytchag_user', $instance['ytchag_user']);
286
+
287
+ // Player options
288
$ytchag_video_width = apply_filters('ytchag_video_width', $instance['ytchag_video_width']);
289
+ $ytchag_ratio = apply_filters('ytchag_ratio', $instance['ytchag_ratio']);
290
+ $ytchag_theme = apply_filters('ytchag_theme', $instance['ytchag_theme']);
291
+ $ytchag_color = apply_filters('ytchag_color', $instance['ytchag_color']);
292
+ $ytchag_autoplay = apply_filters('ytchag_autoplay', $instance['ytchag_autoplay']);
293
+ $ytchag_rel = apply_filters('ytchag_rel', $instance['ytchag_rel']);
294
+ $ytchag_showinfo = apply_filters('ytchag_showinfo', $instance['ytchag_showinfo']);
295
+
296
+ // Thumbnail options
297
+ $ytchag_maxitems = apply_filters('ytchag_maxitems', $instance['ytchag_maxitems']);
298
$ytchag_thumb_width = apply_filters('ytchag_thumb_width', $instance['ytchag_thumb_width']);
299
+ $ytchag_thumb_ratio = apply_filters('ytchag_thumb_ratio', $instance['ytchag_thumb_ratio']);
300
$ytchag_thumb_columns = apply_filters('ytchag_thumb_columns', $instance['ytchag_thumb_columns']);
301
+
302
+ // Link options
303
+ $ytchag_link = apply_filters('ytchag_link', $instance['ytchag_link']);
304
+ $ytchag_link_tx = apply_filters('ytchag_link_tx', $instance['ytchag_link_tx']);
305
+ //--------------------------------
306
+ //end $instance variables
307
+
308
309
//defaults
310
+ //--------------------------------
311
+ // Player options
312
$ytchag_video_width = ( $ytchag_video_width ) ? $ytchag_video_width : 250;
313
+ $ytchag_theme = ( $ytchag_theme ) ? '&theme='. $ytchag_theme : ''; //defaul dark
314
+ $ytchag_color = ( $ytchag_color ) ? '&color='. $ytchag_color : ''; //defaul red
315
+ $ytchag_autoplay = ( $ytchag_autoplay ) ? '&autoplay='. $ytchag_autoplay : ''; //defaul 0
316
+ $ytchag_rel = ( $ytchag_rel ) ? '&rel='. $ytchag_rel : '&rel=0'; //defaul 1
317
+ $ytchag_showinfo = ( $ytchag_showinfo ) ? '&showinfo='. $ytchag_showinfo : '&showinfo=0'; //defaul 1
318
+
319
+ // Thumbnail options
320
$ytchag_thumb_width = ( $ytchag_thumb_width ) ? $ytchag_thumb_width : 85;
321
$ytchag_thumb_columns = ( $ytchag_thumb_columns ) ? $ytchag_thumb_columns : 0;
322
+
323
+ // Link options
324
+ $ytchag_link = ( $ytchag_link ) ? $ytchag_link : 0;
325
+ $ytchag_link_tx = ( $ytchag_link_tx ) ? $ytchag_link_tx : __('Show more videos»', 'youtube-channel-gallery');
326
+ //--------------------------------
327
+ //end defaults
328
+
329
330
//heights of video and thumbnail
331
+ //--------------------------------
332
+ //video height
333
+ if ($ytchag_ratio == '16x9') {
334
+ $ytchag_video_heigh = round( ($ytchag_video_width * 9) / 16);
335
+ } else {
336
+ $ytchag_video_heigh = round( ($ytchag_video_width * 3) / 4);
337
+ }
338
339
+ //thumbnail height
340
+ if ($ytchag_thumb_ratio == '16x9') {
341
+ $ytchag_thumb_height = round( ($ytchag_thumb_width * 9) / 16);
342
+ } else {
343
+ $ytchag_thumb_height = round( ($ytchag_thumb_width * 3) / 4);
344
+ }
345
+
346
+
347
+ // only if user name inserted
348
+ if( $ytchag_user ) {
349
350
// links
351
$ytchag_rss_url = "http://gdata.youtube.com/feeds/api/users/" . $ytchag_user . "/uploads";
352
$ytchag_link_url = "http://www.youtube.com/user/" . $ytchag_user;
353
354
355
+ // check if no correct user name
356
+ if ( file_get_contents($ytchag_rss_url) == '' ) {
357
358
+ $content= '<p class="empty">' . __('You must insert a valid YouTube user name.', 'youtube-channel-gallery') . '</p>';
359
360
+ // correct user name
361
+ } else{
362
363
+ //RSS Feed
364
+ include_once(ABSPATH . WPINC . '/feed.php');
365
+
366
+ $rss = fetch_feed($ytchag_rss_url);
367
+ $maxitems = ( $ytchag_maxitems ) ? $ytchag_maxitems : 9;
368
+ $items = $rss->get_items(0, $maxitems);
369
+
370
371
+ if (!empty($items)) {
372
+ $i = 0;
373
+ $column = 0;
374
+ foreach ( $items as $item ) {
375
+ $url = $item->get_permalink();
376
+ $youtubeid = $this->youtubeid($url);
377
+ $title = $item->get_title();
378
+
379
+ if ($enclosure = $item->get_enclosure()){
380
+
381
+ //extract thumbnail
382
+ //-----------------
383
+
384
+ //thumbnail index in xml
385
+ $big = 0;
386
+ $small = 1;
387
+ $size = $small;
388
+ if($ytchag_thumb_width > '120'){
389
+ $size = $big;
390
+ }
391
392
+ $allThumbs = $enclosure->get_thumbnails();
393
+ foreach ($allThumbs as $index => $allThumb) {
394
+ if ($index == $size) {
395
+ $thumb = $allThumbs[$index];
396
+ }
397
}
398
}
399
400
+ //Show me the player: iframe player
401
+ if($i == 0) {
402
+ //count the plugin occurrences on page
403
+ STATIC $plugincount = 0;
404
+ $plugincount++;
405
406
+ $content = '<iframe id="ytcplayer' . $plugincount . '" class="ytcplayer" allowfullscreen width="' . $ytchag_video_width . '" height="' . $ytchag_video_heigh . '" src="http://www.youtube.com/embed/' . $youtubeid . '?version=3' . $ytchag_theme . $ytchag_color . $ytchag_autoplay . $ytchag_rel . $ytchag_showinfo .'&enablejsapi=1" frameborder="0"></iframe>';
407
408
+ $content.= '<ul class="ytchagallery ytccf">';
409
410
+ } // if player end
411
+ $i++;
412
413
+ //columns control
414
+ $column++;
415
416
+ if($ytchag_thumb_columns !=0 && $column%$ytchag_thumb_columns === 0){
417
+ $columnnumber = ' ytccell-last';
418
+ } else if($ytchag_thumb_columns !=0 && $column === 1){
419
+ $columnnumber = ' ytccell-first';
420
+ }
421
+ $content.= '<li class="ytccell-' . $column . $columnnumber .'">';
422
423
+ if($ytchag_thumb_columns !=0 && $column%$ytchag_thumb_columns === 0 ){
424
+ $column = 0;
425
+ }else if($ytchag_thumb_columns !=0 && $column === 1){
426
+ $columnnumber = '';
427
+ }
428
+
429
+ $content.= '<a class="ytcthumb" href="javascript: ytcplayVideo(\'ytcplayer' . $plugincount . '\', \'' . $youtubeid . '\');" alt="' . $title . '" title="' . $title . '" style="background-image: url(' . $thumb . ');">';
430
+ $content.= '<div class="ytcplay" style="width: ' . $ytchag_thumb_width . 'px; height: ' . $ytchag_thumb_height . 'px"></div>';
431
+ $content.= '</a></li>';
432
+
433
+
434
+ } //foreach end
435
+
436
+ $content.= '</ul>';
437
+
438
+ //link to youtube.com gallery
439
+ if( $ytchag_link) {
440
+ $content.= '<a href="' . $ytchag_link_url . '" class="ytcmore">' . $ytchag_link_tx . '</a>';
441
}
442
+ }
443
+ }// end check user name
444
+
445
+ // user name not inserted
446
} else {
447
+ $content= '<p class="empty">' . __('There is no video to show.', 'youtube-channel-gallery') . '</p>';
448
}
449
450
return $content;
466
wp_enqueue_style('youtube-channel-gallery', plugins_url('/styles.css', __FILE__), false, false, 'all');
467
}//register_scripts_and_styles
468
469
+
470
+ public function register_admin_scripts_and_styles($hook) {
471
+ wp_enqueue_style('youtube-channel-gallery', plugins_url('/admin-styles.css', __FILE__), false, false, 'all');
472
+ }
473
+
474
/*--------------------------------------------------*/
475
/* Shortcode
476
/*--------------------------------------------------*/
482
483
extract( shortcode_atts( array(
484
'user' => '',
485
+
486
+ // Player options
487
+ 'videowidth' => '',
488
+ 'ratio' => '',
489
+ 'theme' => '',
490
+ 'color' => '',
491
+ 'autoplay' => '',
492
+ 'rel' => '',
493
+ 'showinfo' => '',
494
+
495
+ // Thumbnail options
496
+ 'maxitems' => '',
497
+ 'thumbwidth' => '',
498
+ 'thumbratio' => '',
499
+ 'thumbcolumns' => '',
500
+
501
+ // Link options
502
+ 'link' => '',
503
+ 'link_tx' => ''
504
+
505
), $atts ) );
506
507
$instance['ytchag_user'] = $user;
508
+
509
+ // Player options
510
$instance['ytchag_video_width'] = $videowidth;
511
+ $instance['ytchag_ratio'] = $ratio;
512
+ $instance['ytchag_theme'] = $theme;
513
+ $instance['ytchag_color'] = $color;
514
+ $instance['ytchag_autoplay'] = $autoplay;
515
+ $instance['ytchag_rel'] = $rel;
516
+ $instance['ytchag_showinfo'] = $showinfo;
517
+
518
+ // Thumbnail options
519
+ $instance['ytchag_maxitems'] = $maxitems;
520
$instance['ytchag_thumb_width'] = $thumbwidth;
521
+ $instance['ytchag_thumb_ratio'] = $thumbratio;
522
$instance['ytchag_thumb_columns'] = $thumbcolumns;
523
+
524
+ // Link options
525
+ $instance['ytchag_link'] = $link;
526
+ $instance['ytchag_link_tx'] = $link_tx;
527
528
529
+ return '<div class="ytcshort">'. $this->ytchag_rss_markup($instance) . '</div>';
530
531
} // YoutubeChannelGallery_Shortcode
532