Version Description
(2015-05-07/08/09/10) =
* Fix: Migraton of global and widget settings to v3.0.0
* Add: New Global Settings page as replacement of Redux Framework solution
* Add: Non-Dismissable Dashboard notice if YouTube Data API Key missing with link to explanation page
* Change: Option key ytc_version
to youtube_channel_version
* Change: Shortcode parameters: res
to resource
, show
to display
; but leave old parameter names for backward compatibility
* Enhance: Various plugin core micro optimizations
* Enhance: Dashboard notices
* Enhance: Proper options migration on plugin update
* Remove: Redux Framework mentioning from core plugin
* Remove: Redux Framework config.php
* Remove: chromeless.swf asset
* Remove: option Fix height taken by controls
as now YouTube displays control bar only when video is hovered
Release Info
Developer | urkekg |
Plugin | YouTube Channel |
Version | 3.0.0 |
Comparing to | |
See all releases |
Code changes from version 2.4.2.1 to 3.0.0
- assets/css/admin.css +32 -0
- assets/js/admin.js +46 -0
- assets/js/admin.min.js +1 -0
- inc/chromeless.swf +0 -0
- inc/config.php +0 -519
- inc/settings.php +862 -0
- inc/settings_template.php +61 -0
- inc/settings_tools.php +1 -1
- inc/settings_usage.php +1 -0
- inc/settings_usage_shortcode.php +22 -16
- inc/widget.php +151 -150
- readme.txt +68 -45
- update.php +220 -0
- youtube-channel.php +654 -536
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
div[id*='_youtube-channel-'] .widget-content p {
|
2 |
+
width: 100%;
|
3 |
+
clear: both;
|
4 |
+
}
|
5 |
+
div[id*='_youtube-channel-'] .widget-content p.half {
|
6 |
+
width: 49%;
|
7 |
+
}
|
8 |
+
div[id*='_youtube-channel-'] .widget-content p.glue-top {
|
9 |
+
margin-top: 0;
|
10 |
+
}
|
11 |
+
div[id*='_youtube-channel-'] .widget-content p.half.left {
|
12 |
+
float: left;
|
13 |
+
clear: left;
|
14 |
+
}
|
15 |
+
div[id*='_youtube-channel-'] .widget-content p.half.right {
|
16 |
+
float: right;
|
17 |
+
clear: right;
|
18 |
+
}
|
19 |
+
div[id*='_youtube-channel-'] .widget-content p.hidden {
|
20 |
+
display: none;
|
21 |
+
}
|
22 |
+
div[id*='_youtube-channel-'] .widget-content p.visible {
|
23 |
+
display: block;
|
24 |
+
}
|
25 |
+
@media screen and (max-width: 782px) {
|
26 |
+
div[id*='_youtube-channel-'] .widget-content p.half.left,
|
27 |
+
div[id*='_youtube-channel-'] .widget-content p.half.right {
|
28 |
+
width: 100%;
|
29 |
+
float: none;
|
30 |
+
clear: none;
|
31 |
+
}
|
32 |
+
}
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($){
|
2 |
+
|
3 |
+
$('select[id*="-use_res"]').each(function(e, i){
|
4 |
+
ytc_toggle_widget_option_select($(this).attr('id'), 2);
|
5 |
+
});
|
6 |
+
$('select[id*="-use_res"]').on('change', function(e, i){
|
7 |
+
ytc_toggle_widget_option_select($(this).attr('id'), 2);
|
8 |
+
});
|
9 |
+
$('input[id*="-showgoto"]').each(function(e, i){
|
10 |
+
ytc_toggle_widget_option_checkbox($(this).attr('id'));
|
11 |
+
});
|
12 |
+
$('input[id*="-showgoto"]').on('change', function(e, i){
|
13 |
+
ytc_toggle_widget_option_checkbox($(this).attr('id'));
|
14 |
+
});
|
15 |
+
|
16 |
+
$(document).ajaxSuccess(function(e, xhr, settings){
|
17 |
+
$('select[id*="-use_res"]').each(function(e, i){
|
18 |
+
ytc_toggle_widget_option_select($(this).attr('id'), 2);
|
19 |
+
});
|
20 |
+
$('select[id*="-use_res"]').on('change', function(e, i){
|
21 |
+
ytc_toggle_widget_option_select($(this).attr('id'), 2);
|
22 |
+
});
|
23 |
+
$('input[id*="-showgoto"]').each(function(e, i){
|
24 |
+
ytc_toggle_widget_option_checkbox($(this).attr('id'));
|
25 |
+
});
|
26 |
+
$('input[id*="-showgoto"]').on('change', function(e, i){
|
27 |
+
ytc_toggle_widget_option_checkbox($(this).attr('id'));
|
28 |
+
});
|
29 |
+
});
|
30 |
+
|
31 |
+
function ytc_toggle_widget_option_select(id, value) {
|
32 |
+
if ( $('#' + id).val() == value ) {
|
33 |
+
$('p.' + id).addClass('visible').removeClass('hidden');
|
34 |
+
} else {
|
35 |
+
$('p.' + id).addClass('hidden').removeClass('visible');
|
36 |
+
}
|
37 |
+
}
|
38 |
+
function ytc_toggle_widget_option_checkbox(id) {
|
39 |
+
if ( $('#' + id).attr('checked') === 'checked' ) {
|
40 |
+
$('p.' + id).addClass('visible').removeClass('hidden');
|
41 |
+
} else {
|
42 |
+
$('p.' + id).addClass('hidden').removeClass('visible');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
});
|
@@ -0,0 +1 @@
|
|
|
1 |
+
jQuery(document).ready(function(i){function t(t,e){i("#"+t).val()==e?i("p."+t).addClass("visible").removeClass("hidden"):i("p."+t).addClass("hidden").removeClass("visible")}function e(t){"checked"===i("#"+t).attr("checked")?i("p."+t).addClass("visible").removeClass("hidden"):i("p."+t).addClass("hidden").removeClass("visible")}i('select[id*="-use_res"]').each(function(){t(i(this).attr("id"),2)}),i('select[id*="-use_res"]').on("change",function(){t(i(this).attr("id"),2)}),i('input[id*="-showgoto"]').each(function(){e(i(this).attr("id"))}),i('input[id*="-showgoto"]').on("change",function(){e(i(this).attr("id"))}),i(document).ajaxSuccess(function(){i('select[id*="-use_res"]').each(function(){t(i(this).attr("id"),2)}),i('select[id*="-use_res"]').on("change",function(){t(i(this).attr("id"),2)}),i('input[id*="-showgoto"]').each(function(){e(i(this).attr("id"))}),i('input[id*="-showgoto"]').on("change",function(){e(i(this).attr("id"))})})});
|
Binary file
|
@@ -1,519 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
ReduxFramework YouTube Channel File
|
4 |
-
**/
|
5 |
-
|
6 |
-
if ( !class_exists( "ReduxFramework" ) ) {
|
7 |
-
return;
|
8 |
-
}
|
9 |
-
|
10 |
-
if ( !class_exists( "Redux_Framework_YouTube_Channel" ) ) {
|
11 |
-
class Redux_Framework_YouTube_Channel {
|
12 |
-
|
13 |
-
public $args = array();
|
14 |
-
public $sections = array();
|
15 |
-
public $ReduxFramework;
|
16 |
-
|
17 |
-
public function __construct( ) {
|
18 |
-
|
19 |
-
// Set the default arguments
|
20 |
-
$this->setArguments();
|
21 |
-
|
22 |
-
// Create the sections and fields
|
23 |
-
$this->setSections();
|
24 |
-
|
25 |
-
if ( !isset( $this->args['opt_name'] ) ) { // No errors please
|
26 |
-
return;
|
27 |
-
}
|
28 |
-
|
29 |
-
// If Redux is running as a plugin, this will remove the demo notice and links
|
30 |
-
add_action( 'redux/plugin/hooks', array( $this, 'remove_demo' ) );
|
31 |
-
|
32 |
-
$this->ReduxFramework = new ReduxFramework($this->sections, $this->args);
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
// Remove the demo link and the notice of integrated demo from the redux-framework plugin
|
37 |
-
function remove_demo() {
|
38 |
-
|
39 |
-
// Used to hide the demo mode link from the plugin page. Only used when Redux is a plugin.
|
40 |
-
if ( class_exists('ReduxFrameworkPlugin') ) {
|
41 |
-
remove_filter( 'plugin_row_meta', array( ReduxFrameworkPlugin::get_instance(), 'plugin_meta_demo_mode_link'), null, 2 );
|
42 |
-
}
|
43 |
-
|
44 |
-
// Used to hide the activation notice informing users of the demo panel. Only used when Redux is a plugin.
|
45 |
-
remove_action('admin_notices', array( ReduxFrameworkPlugin::get_instance(), 'admin_notices' ) );
|
46 |
-
|
47 |
-
}
|
48 |
-
|
49 |
-
public function setSections() {
|
50 |
-
global $WPAU_YOUTUBE_CHANNEL;
|
51 |
-
// ACTUAL DECLARATION OF SECTIONS
|
52 |
-
|
53 |
-
$this->sections[] = array(
|
54 |
-
'title' => __('General', 'youtube-channel'),
|
55 |
-
'icon' => 'el-icon-home',
|
56 |
-
'fields' => array(
|
57 |
-
array(
|
58 |
-
'id' => 'channel',
|
59 |
-
'type' => 'text',
|
60 |
-
'title' => __('YouTube Channel ID', 'youtube-channel'),
|
61 |
-
'desc' => __('Enter your YouTube channel ID (channel name, not full URL to channel)', 'youtube-channel'),
|
62 |
-
'default' => $WPAU_YOUTUBE_CHANNEL->channel_id
|
63 |
-
),
|
64 |
-
array(
|
65 |
-
'id' => 'playlist',
|
66 |
-
'type' => 'text',
|
67 |
-
'title' => __('Default Playlist ID', 'youtube-channel'),
|
68 |
-
'desc' => __('Enter default playlist ID (not playlist name)', 'youtube-channel'),
|
69 |
-
'default' => $WPAU_YOUTUBE_CHANNEL->playlist_id
|
70 |
-
),
|
71 |
-
array(
|
72 |
-
'id' => 'use_res',
|
73 |
-
'type' => 'select',
|
74 |
-
'title' => __('Resource to use', 'youtube-channel'),
|
75 |
-
'desc' => __('What to use as resource for feeds', 'youtube-channel'),
|
76 |
-
'options' => array(
|
77 |
-
'0' => __('Channel', 'youtube-channel'),
|
78 |
-
'1' => __('Favorites', 'youtube-channel'),
|
79 |
-
'2' => __('Playlist', 'youtube-channel'),
|
80 |
-
),
|
81 |
-
'default' => '0'
|
82 |
-
),
|
83 |
-
array(
|
84 |
-
'id' => 'only_pl',
|
85 |
-
'type' => 'checkbox',
|
86 |
-
'title' => __('Embed standard playlist', 'youtube-channel'),
|
87 |
-
'desc' => __('Enable this option to embed whole playlist instead single video from playlist when you chose playlist as resource', 'youtube-channel'),
|
88 |
-
'default' => '0'// 1 = on | 0 = off
|
89 |
-
),
|
90 |
-
array(
|
91 |
-
'id' => 'cache_time',
|
92 |
-
'type' => 'select',
|
93 |
-
'title' => __('Cache Timeout', 'youtube-channel'),
|
94 |
-
'desc' => __('Define caching timeout for YouTube feeds, in seconds', 'youtube-channel'),
|
95 |
-
|
96 |
-
'options' => array(
|
97 |
-
'0' => __('Do not chache', 'youtube-channel'),
|
98 |
-
'60' => __('1 minute', 'youtube-channel'),
|
99 |
-
'300' => __('5 minutes', 'youtube-channel'),
|
100 |
-
'900' => __('15 minutes', 'youtube-channel'),
|
101 |
-
'1800' => __('30 minutes', 'youtube-channel'),
|
102 |
-
'3600' => __('1 hour', 'youtube-channel'),
|
103 |
-
'7200' => __('2 hours', 'youtube-channel'),
|
104 |
-
'18000' => __('5 hours', 'youtube-channel'),
|
105 |
-
'36000' => __('10 hours', 'youtube-channel'),
|
106 |
-
'43200' => __('12 hours', 'youtube-channel'),
|
107 |
-
'64800' => __('18 hours', 'youtube-channel'),
|
108 |
-
'86400' => __('1 day', 'youtube-channel'),
|
109 |
-
'172800' => __('2 days', 'youtube-channel'),
|
110 |
-
'259200' => __('3 days', 'youtube-channel'),
|
111 |
-
'345600' => __('4 days', 'youtube-channel'),
|
112 |
-
'432000' => __('5 days', 'youtube-channel'),
|
113 |
-
'518400' => __('6 days', 'youtube-channel'),
|
114 |
-
'604800' => __('1 week', 'youtube-channel'),
|
115 |
-
'1209600' => __('2 weeks', 'youtube-channel'),
|
116 |
-
'1814400' => __('3 weeks', 'youtube-channel'),
|
117 |
-
'2419200' => __('1 month', 'youtube-channel')
|
118 |
-
),
|
119 |
-
'default' => '0'
|
120 |
-
),
|
121 |
-
array(
|
122 |
-
'id' =>'maxrnd',
|
123 |
-
'type' => 'spinner',
|
124 |
-
'title' => __('Fetch', 'youtube-channel'),
|
125 |
-
'desc' => __('Number of videos that will be used for random pick (min 2, max 50, default 25)', 'youtube-channel'),
|
126 |
-
'default' => 25,
|
127 |
-
'min' => 2,
|
128 |
-
'max' => 50,
|
129 |
-
'step' => 1
|
130 |
-
),
|
131 |
-
array(
|
132 |
-
'id' =>'vidqty',
|
133 |
-
'type' => 'spinner',
|
134 |
-
'title' => __('Show', 'youtube-channel'),
|
135 |
-
'desc' => __('Number of videos to display', 'youtube-channel'),
|
136 |
-
'default' => 1,
|
137 |
-
'min' => 1,
|
138 |
-
'max' => 50,
|
139 |
-
'step' => 1
|
140 |
-
),
|
141 |
-
array(
|
142 |
-
'id' => 'enhprivacy',
|
143 |
-
'type' => 'checkbox',
|
144 |
-
'title' => __('Use Enhanced privacy', 'youtube-channel'),
|
145 |
-
'desc' => sprintf(__('Enable this option to protect your visitors <a href="%s" target="_blank">privacy</a>.', 'youtube-channel'), 'http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780'),
|
146 |
-
'default' => 0
|
147 |
-
),
|
148 |
-
array(
|
149 |
-
'id' => 'fixnoitem',
|
150 |
-
'type' => 'checkbox',
|
151 |
-
'title' => __('Fix <em>No items</em> error/Respect playlist order', 'youtube-channel'),
|
152 |
-
'desc' => __('Enable this option if you get error No Item', 'youtube-channel'),
|
153 |
-
'default' => 0
|
154 |
-
),
|
155 |
-
array(
|
156 |
-
'id' => 'getrnd',
|
157 |
-
'type' => 'checkbox',
|
158 |
-
'title' => __('Show random video', 'youtube-channel'),
|
159 |
-
'desc' => __('Get random videos of all fetched from channel or playlist', 'youtube-channel'),
|
160 |
-
'default' => 0
|
161 |
-
),
|
162 |
-
|
163 |
-
)
|
164 |
-
);
|
165 |
-
|
166 |
-
$this->sections[] = array(
|
167 |
-
'icon' => 'el-icon-youtube',
|
168 |
-
'title' => __('Video', 'youtube-channel'),
|
169 |
-
'fields' => array(
|
170 |
-
|
171 |
-
array(
|
172 |
-
'id' => 'ratio',
|
173 |
-
'type' => 'select',
|
174 |
-
'title' => __('Aspect Ratio', 'youtube-channel'),
|
175 |
-
'desc' => __('Select aspect ratio for displayed video', 'youtube-channel'),
|
176 |
-
|
177 |
-
'options' => array(
|
178 |
-
'3' => __('16:9', 'youtube-channel'),
|
179 |
-
'2' => __('16:10', 'youtube-channel'),
|
180 |
-
'1' => __('4:3', 'youtube-channel')
|
181 |
-
),
|
182 |
-
'default' => '3'
|
183 |
-
),
|
184 |
-
array(
|
185 |
-
'id' => 'responsive',
|
186 |
-
'type' => 'checkbox',
|
187 |
-
'title' => __('Make responsive', 'youtube-channel'),
|
188 |
-
'desc' => __('Enable this option to make all YTC videos responsive. Please note, this option will set all videos full width relative to parent container, and disable more than one video per row.', 'youtube-channel'),
|
189 |
-
'default' => 0
|
190 |
-
),
|
191 |
-
array(
|
192 |
-
'id' => 'width',
|
193 |
-
'type' => 'spinner',
|
194 |
-
'title' => __('Video Width', 'youtube-channel'),
|
195 |
-
'desc' => __('Set default width for displayed video, in pixels', 'youtube-channel'),
|
196 |
-
'default' => 306,
|
197 |
-
'min' => 50,
|
198 |
-
'max' => 1980,
|
199 |
-
'step' => 1
|
200 |
-
),
|
201 |
-
array(
|
202 |
-
'id' => 'to_show',
|
203 |
-
'type' => 'select',
|
204 |
-
'title' => __('What to show?', 'youtube-channel'),
|
205 |
-
'desc' => __('Set what will be shown by default', 'youtube-channel'),
|
206 |
-
|
207 |
-
'options' => array(
|
208 |
-
'thumbnail' => __('Thumbnail', 'youtube-channel'),
|
209 |
-
'object' => __('Flash (object)', 'youtube-channel'),
|
210 |
-
'iframe' => __('HTML5 (iframe)', 'youtube-channel'),
|
211 |
-
'iframe2' => __('HTML5 (iframe) Async', 'youtube-channel'),
|
212 |
-
'chromeless' => __('Chromeless', 'youtube-channel')
|
213 |
-
),
|
214 |
-
'default' => 'thumbnail'
|
215 |
-
),
|
216 |
-
array(
|
217 |
-
'id' => 'themelight',
|
218 |
-
'type' => 'checkbox',
|
219 |
-
'title' => __('Use light theme', 'youtube-channel'),
|
220 |
-
'desc' => __('Enable this option to use light theme for playback controls instead dark', 'youtube-channel'),
|
221 |
-
'default' => 0
|
222 |
-
),
|
223 |
-
array(
|
224 |
-
'id' => 'controls',
|
225 |
-
'type' => 'checkbox',
|
226 |
-
'title' => __('Hide player controls', 'youtube-channel'),
|
227 |
-
'desc' => __('Enable this option to hide playback controls', 'youtube-channel'),
|
228 |
-
'default' => 0
|
229 |
-
),
|
230 |
-
array(
|
231 |
-
'id' => 'fixyt',
|
232 |
-
'type' => 'checkbox',
|
233 |
-
'title' => __('Fix video height', 'youtube-channel'),
|
234 |
-
'desc' => __('Enable this option to fix video height when playback controls are not hidden', 'youtube-channel'),
|
235 |
-
'default' => 0
|
236 |
-
),
|
237 |
-
array(
|
238 |
-
'id' => 'autoplay',
|
239 |
-
'type' => 'checkbox',
|
240 |
-
'title' => __('Autoplay video or playlist', 'youtube-channel'),
|
241 |
-
'desc' => __('Enable this option to start video playback right after block is rendered', 'youtube-channel'),
|
242 |
-
'default' => 0
|
243 |
-
),
|
244 |
-
array(
|
245 |
-
'id' => 'autoplay_mute',
|
246 |
-
'type' => 'checkbox',
|
247 |
-
'title' => __('Mute video on autoplay', 'youtube-channel'),
|
248 |
-
'desc' => __('Enable this option to mute video when start autoplay', 'youtube-channel'),
|
249 |
-
'default' => 0
|
250 |
-
),
|
251 |
-
array(
|
252 |
-
'id' => 'norel',
|
253 |
-
'type' => 'checkbox',
|
254 |
-
'title' => __('Hide related videos', 'youtube-channel'),
|
255 |
-
'desc' => __('Enable this option to hide related videos after finished playback', 'youtube-channel'),
|
256 |
-
'default' => 0
|
257 |
-
),
|
258 |
-
array(
|
259 |
-
'id' => 'modestbranding',
|
260 |
-
'type' => 'checkbox',
|
261 |
-
'title' => __('Hide YT Logo', 'youtube-channel'),
|
262 |
-
'desc' => __('Enable this option to hide YouTube logo from playback control bar. Does not work for all videos.', 'youtube-channel'),
|
263 |
-
'default' => 0
|
264 |
-
),
|
265 |
-
|
266 |
-
)
|
267 |
-
);
|
268 |
-
|
269 |
-
$this->sections[] = array(
|
270 |
-
'icon' => 'el-icon-view-mode',
|
271 |
-
'title' => __('Content', 'youtube-channel'),
|
272 |
-
'fields' => array(
|
273 |
-
|
274 |
-
array(
|
275 |
-
'id' => 'showtitle',
|
276 |
-
'type' => 'checkbox',
|
277 |
-
'title' => __('Show video title', 'youtube-channel'),
|
278 |
-
'desc' => __('Enable this option to display title of video', 'youtube-channel'),
|
279 |
-
'default' => 0
|
280 |
-
),
|
281 |
-
array(
|
282 |
-
'id' => 'showvidesc',
|
283 |
-
'type' => 'checkbox',
|
284 |
-
'title' => __('Show video description', 'youtube-channel'),
|
285 |
-
'desc' => __('Enable this option to display description for video', 'youtube-channel'),
|
286 |
-
'default' => 0
|
287 |
-
),
|
288 |
-
array(
|
289 |
-
'id' =>'videsclen',
|
290 |
-
'type' => 'spinner',
|
291 |
-
'title' => __('Description length', 'youtube-channel'),
|
292 |
-
'desc' => __('Enter length for video description in characters (0 for full length)', 'youtube-channel'),
|
293 |
-
'default' => 0,
|
294 |
-
'min' => 0,
|
295 |
-
'max' => 2500,
|
296 |
-
'step' => 1
|
297 |
-
),
|
298 |
-
array(
|
299 |
-
'id' => 'descappend',
|
300 |
-
'type' => 'text',
|
301 |
-
'title' => __('Et cetera string', 'youtube-channel'),
|
302 |
-
'desc' => __('Indicator for shortened video description (default: …)', 'youtube-channel'),
|
303 |
-
'default' => __('...', 'youtube-channel')
|
304 |
-
),
|
305 |
-
array(
|
306 |
-
'id' => 'hideanno',
|
307 |
-
'type' => 'checkbox',
|
308 |
-
'title' => __('Hide annotations from video', 'youtube-channel'),
|
309 |
-
'desc' => __('Enable this option to hide video annotations (custom text set by uploader over video during playback)', 'youtube-channel'),
|
310 |
-
'default' => 0
|
311 |
-
),
|
312 |
-
array(
|
313 |
-
'id' => 'hideinfo',
|
314 |
-
'type' => 'checkbox',
|
315 |
-
'title' => __('Hide video info', 'youtube-channel'),
|
316 |
-
'desc' => __('Enable this option to hide informations about video before play start (video title and uploader in overlay)', 'youtube-channel'),
|
317 |
-
'default' => 0
|
318 |
-
),
|
319 |
-
|
320 |
-
)
|
321 |
-
);
|
322 |
-
|
323 |
-
$this->sections[] = array(
|
324 |
-
'icon' => 'el-icon-link',
|
325 |
-
'title' => __('Link to Channel', 'youtube-channel'),
|
326 |
-
'fields' => array(
|
327 |
-
|
328 |
-
array(
|
329 |
-
'id' => 'goto_txt',
|
330 |
-
'type' => 'text',
|
331 |
-
'title' => __('Visit YouTube Channel text', 'youtube-channel'),
|
332 |
-
'desc' => __('Use placeholder %channel% to insert channel name', 'youtube-channel'),
|
333 |
-
'default' => __('Visit my channel %channel%', 'youtube-channel')
|
334 |
-
),
|
335 |
-
array(
|
336 |
-
'id' => 'showgoto',
|
337 |
-
'type' => 'checkbox',
|
338 |
-
'title' => __('Show link to channel', 'youtube-channel'),
|
339 |
-
'desc' => __('Enable this option to show customized link to channel at the bottom of YTC block', 'youtube-channel'),
|
340 |
-
'default' => 0
|
341 |
-
),
|
342 |
-
array(
|
343 |
-
'id' => 'popup_goto',
|
344 |
-
'type' => 'select',
|
345 |
-
'title' => __('Open YouTube channel page', 'youtube-channel'),
|
346 |
-
'desc' => __('Set what will be shown by default', 'youtube-channel'),
|
347 |
-
|
348 |
-
'options' => array(
|
349 |
-
'0' => __('in same window', 'youtube-channel'),
|
350 |
-
'1' => __('in new window (JavaScript)', 'youtube-channel'),
|
351 |
-
'2' => __('in new window (Target)', 'youtube-channel')
|
352 |
-
),
|
353 |
-
'default' => '0'
|
354 |
-
),
|
355 |
-
array(
|
356 |
-
'id' => 'userchan',
|
357 |
-
'type' => 'checkbox',
|
358 |
-
'title' => __('Link to channel instead to user', 'youtube-channel'),
|
359 |
-
'desc' => __('Enable this option if link to your channel have <code>/channel/</code> instead <code>/user/</code> part in URL', 'youtube-channel'),
|
360 |
-
'default' => 0
|
361 |
-
),
|
362 |
-
|
363 |
-
)
|
364 |
-
);
|
365 |
-
|
366 |
-
$this->sections[] = array(
|
367 |
-
'icon' => 'el-icon-magic',
|
368 |
-
'title' => __('Tools', 'youtube-channel'),
|
369 |
-
'fields' => array(
|
370 |
-
array(
|
371 |
-
'id' => 'recache',
|
372 |
-
'type' => 'raw',
|
373 |
-
'markdown' => false,
|
374 |
-
'content' => file_get_contents(dirname(__FILE__) . '/settings_tools.php')
|
375 |
-
),
|
376 |
-
)
|
377 |
-
);
|
378 |
-
|
379 |
-
$this->sections[] = array(
|
380 |
-
'type' => 'divide',
|
381 |
-
);
|
382 |
-
|
383 |
-
$this->sections[] = array(
|
384 |
-
'icon' => 'el-icon-question-sign',
|
385 |
-
'title' => __('Usage', 'youtube-channel'),
|
386 |
-
'fields' => array(
|
387 |
-
array(
|
388 |
-
'id' => 'implementation',
|
389 |
-
'title' => 'How to use '.$WPAU_YOUTUBE_CHANNEL->plugin_name,
|
390 |
-
'type' => 'raw',
|
391 |
-
'content' => file_get_contents(dirname(__FILE__) . '/settings_usage.php')
|
392 |
-
),
|
393 |
-
array(
|
394 |
-
'id' => 'shortcode',
|
395 |
-
'title' => 'How to use shortcode',
|
396 |
-
'subtitle' => 'Shortcode parameters with default values',
|
397 |
-
'type' => 'raw',
|
398 |
-
// 'raw_html' => true,
|
399 |
-
'content' => file_get_contents(dirname(__FILE__) . '/settings_usage_shortcode.php')
|
400 |
-
)
|
401 |
-
)
|
402 |
-
);
|
403 |
-
|
404 |
-
$this->sections[] = array(
|
405 |
-
'icon' => 'el-icon-group',
|
406 |
-
'title' => __('Support', 'youtube-channel'),
|
407 |
-
'fields' => array(
|
408 |
-
array(
|
409 |
-
'id' => 'support',
|
410 |
-
'type' => 'raw',
|
411 |
-
// 'raw_html' => true,
|
412 |
-
'content' => file_get_contents(dirname(__FILE__) . '/settings_support.php')
|
413 |
-
),
|
414 |
-
)
|
415 |
-
);
|
416 |
-
|
417 |
-
}
|
418 |
-
|
419 |
-
/**
|
420 |
-
All the possible arguments for Redux.
|
421 |
-
For full documentation on arguments, please refer to: https://github.com/ReduxFramework/ReduxFramework/wiki/Arguments
|
422 |
-
|
423 |
-
**/
|
424 |
-
public function setArguments() {
|
425 |
-
global $WPAU_YOUTUBE_CHANNEL;
|
426 |
-
$theme = wp_get_theme(); // For use with some settings. Not necessary.
|
427 |
-
|
428 |
-
$this->args = array(
|
429 |
-
|
430 |
-
// TYPICAL -> Change these values as you need/desire
|
431 |
-
'opt_name' => $WPAU_YOUTUBE_CHANNEL->plugin_option, // This is where your data is stored in the database and also becomes your global variable name.
|
432 |
-
'display_name' => $WPAU_YOUTUBE_CHANNEL->plugin_name, // Name that appears at the top of your panel
|
433 |
-
'display_version' => $WPAU_YOUTUBE_CHANNEL->plugin_version, // Version that appears at the top of your panel
|
434 |
-
'menu_type' => 'submenu', //Specify if the admin menu should appear or not. Options: menu or submenu (Under appearance only)
|
435 |
-
'allow_sub_menu' => true, // Show the sections below the admin menu item or not
|
436 |
-
'menu_title' => __( $WPAU_YOUTUBE_CHANNEL->plugin_name, $WPAU_YOUTUBE_CHANNEL->plugin_slug ),
|
437 |
-
'page' => __( $WPAU_YOUTUBE_CHANNEL->plugin_name.' Options', $WPAU_YOUTUBE_CHANNEL->plugin_slug ),
|
438 |
-
'google_api_key' => '', // Must be defined to add google fonts to the typography module
|
439 |
-
'global_variable' => '', // Set a different name for your global variable other than the opt_name
|
440 |
-
'dev_mode' => false, // Show the time the page took to load, etc
|
441 |
-
'customizer' => true, // Enable basic customizer support
|
442 |
-
|
443 |
-
// OPTIONAL -> Give you extra features
|
444 |
-
'page_priority' => null, // Order where the menu appears in the admin area. If there is any conflict, something will not show. Warning.
|
445 |
-
'page_parent' => 'options-general.php', // For a full list of options, visit: http://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters
|
446 |
-
'page_permissions' => 'manage_options', // Permissions needed to access the options panel.
|
447 |
-
'menu_icon' => '', // Specify a custom URL to an icon
|
448 |
-
'last_tab' => '', // Force your panel to always open to a specific tab (by id)
|
449 |
-
'page_icon' => 'icon-settings', // Icon displayed in the admin panel next to your menu_title
|
450 |
-
'page_slug' => $WPAU_YOUTUBE_CHANNEL->plugin_slug, // Page slug used to denote the panel
|
451 |
-
'save_defaults' => true, // On load save the defaults to DB before user clicks save or not
|
452 |
-
'default_show' => false, // If true, shows the default value next to each field that is not the default value.
|
453 |
-
'default_mark' => '', // What to print by the field's title if the value shown is default. Suggested: *
|
454 |
-
|
455 |
-
|
456 |
-
// CAREFUL -> These options are for advanced use only
|
457 |
-
'transient_time' => 60 * MINUTE_IN_SECONDS,
|
458 |
-
'output' => true, // Global shut-off for dynamic CSS output by the framework. Will also disable google fonts output
|
459 |
-
'output_tag' => true, // Allows dynamic CSS to be generated for customizer and google fonts, but stops the dynamic CSS from going to the head
|
460 |
-
//'domain' => 'redux-framework', // Translation domain key. Don't change this unless you want to retranslate all of Redux.
|
461 |
-
//'footer_credit' => '', // Disable the footer credit of Redux. Please leave if you can help it.
|
462 |
-
|
463 |
-
|
464 |
-
// FUTURE -> Not in use yet, but reserved or partially implemented. Use at your own risk.
|
465 |
-
'database' => '', // possible: options, theme_mods, theme_mods_expanded, transient. Not fully functional, warning!
|
466 |
-
|
467 |
-
|
468 |
-
'show_import_export' => true, // REMOVE
|
469 |
-
'system_info' => false, // REMOVE
|
470 |
-
|
471 |
-
'help_tabs' => array(),
|
472 |
-
'help_sidebar' => '', // __( '', $this->args['domain'] );
|
473 |
-
);
|
474 |
-
|
475 |
-
|
476 |
-
// SOCIAL ICONS -> Setup custom links in the footer for quick links in your panel footer icons.
|
477 |
-
$this->args['share_icons'][] = array(
|
478 |
-
'url' => 'https://www.facebook.com/urosevic',
|
479 |
-
'title' => 'Author on Facebook',
|
480 |
-
'icon' => 'el-icon-facebook'
|
481 |
-
);
|
482 |
-
$this->args['share_icons'][] = array(
|
483 |
-
'url' => 'http://twitter.com/urosevic',
|
484 |
-
'title' => 'Add me on Twitter',
|
485 |
-
'icon' => 'el-icon-twitter'
|
486 |
-
);
|
487 |
-
$this->args['share_icons'][] = array(
|
488 |
-
'url' => 'http://rs.linkedin.com/in/aurosevic',
|
489 |
-
'title' => 'Find me on LinkedIn',
|
490 |
-
'icon' => 'el-icon-linkedin'
|
491 |
-
);
|
492 |
-
$this->args['share_icons'][] = array(
|
493 |
-
'url' => 'http://youtube.com/user/urkekg',
|
494 |
-
'title' => 'Subscribe to my YouTube',
|
495 |
-
'icon' => 'el-icon-youtube'
|
496 |
-
);
|
497 |
-
$this->args['share_icons'][] = array(
|
498 |
-
'url' => 'http://urosevic.net/wordpress/plugins/youtube-channel/',
|
499 |
-
'title' => 'Visit official plugin site',
|
500 |
-
'icon' => 'el-icon-home-alt'
|
501 |
-
);
|
502 |
-
|
503 |
-
// Panel Intro text -> before the form
|
504 |
-
if (!isset($this->args['global_variable']) || $this->args['global_variable'] !== false ) {
|
505 |
-
if (!empty($this->args['global_variable'])) {
|
506 |
-
$v = $this->args['global_variable'];
|
507 |
-
} else {
|
508 |
-
$v = str_replace("-", "_", $this->args['opt_name']);
|
509 |
-
}
|
510 |
-
$this->args['intro_text'] = '<p style="float:right;"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Q6Q762MQ97XJ6" target="_blank" title="Donate via PayPal - The safer, easier way to pay online!"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" style="width:147px;height:47px;border:0" alt="PayPal - The safer, easier way to pay online!"></a></p>';
|
511 |
-
$this->args['intro_text'] .= __('<p>Easy embed playable videos from YouTube.</p><p>Here you can set default options that will be used as defaults for new widgets, and for shortcode.</p>', 'youtube-channel' );
|
512 |
-
$this->args['intro_text'] .='<p> </p>';
|
513 |
-
}
|
514 |
-
|
515 |
-
}
|
516 |
-
}
|
517 |
-
global $reduxConfig;
|
518 |
-
$reduxConfig = new Redux_Framework_YouTube_Channel();
|
519 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -0,0 +1,862 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! class_exists('WPAU_YOUTUBE_CHANNEL_SETTINGS') ) {
|
4 |
+
|
5 |
+
class WPAU_YOUTUBE_CHANNEL_SETTINGS {
|
6 |
+
|
7 |
+
private $option_name;
|
8 |
+
private $defaults;
|
9 |
+
private $slug;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Construct the plugin object
|
13 |
+
*/
|
14 |
+
public function __construct() {
|
15 |
+
|
16 |
+
global $WPAU_YOUTUBE_CHANNEL;
|
17 |
+
|
18 |
+
// get default values
|
19 |
+
$this->slug = $WPAU_YOUTUBE_CHANNEL->plugin_slug;
|
20 |
+
$this->option_name = $WPAU_YOUTUBE_CHANNEL->plugin_option;
|
21 |
+
$this->defaults = get_option( $this->option_name );
|
22 |
+
|
23 |
+
// register actions
|
24 |
+
add_action( 'admin_init', array(&$this, 'register_settings') );
|
25 |
+
add_action( 'admin_menu', array(&$this, 'add_menu') );
|
26 |
+
|
27 |
+
} // END public function __construct
|
28 |
+
|
29 |
+
/**
|
30 |
+
* hook into WP's register_settings action hook
|
31 |
+
*/
|
32 |
+
public function register_settings() {
|
33 |
+
|
34 |
+
// =========================== General ===========================
|
35 |
+
// --- Add settings section General so we can add fields to it ---
|
36 |
+
add_settings_section(
|
37 |
+
'ytc_general', // Section Name
|
38 |
+
__('General', 'wpsk'), // Section Title
|
39 |
+
array(&$this, 'settings_general_section_description'), // Section Callback Function
|
40 |
+
$this->slug . '_general' // Page Name
|
41 |
+
);
|
42 |
+
// --- Add Fields to General section ---
|
43 |
+
// Channel ID
|
44 |
+
add_settings_field(
|
45 |
+
$this->option_name . 'channel', // Setting Slug
|
46 |
+
__('YouTube Channel ID', 'wpsk'), // Title
|
47 |
+
array(&$this, 'settings_field_input_text'), // Callback
|
48 |
+
$this->slug . '_general', // Page Name
|
49 |
+
'ytc_general', // Section Name
|
50 |
+
array(
|
51 |
+
'field' => $this->option_name . '[channel]',
|
52 |
+
'description' => __('Your YouTube Channel ID (ID only starting with UC, not full URL)', 'wpsk'),
|
53 |
+
'class' => 'regular-text',
|
54 |
+
'value' => $this->defaults['channel'],
|
55 |
+
) // args
|
56 |
+
);
|
57 |
+
// Vanity
|
58 |
+
add_settings_field(
|
59 |
+
$this->option_name . 'vanity', // id
|
60 |
+
__('YouTube Vanity Name', 'wpsk'), // Title
|
61 |
+
array(&$this, 'settings_field_input_text'), // Callback
|
62 |
+
$this->slug . '_general', // Page
|
63 |
+
'ytc_general', // section
|
64 |
+
array(
|
65 |
+
'field' => $this->option_name . "[vanity]",
|
66 |
+
'description' => __('Your YouTube Custom Name (only part after www.youtube.com/c/ instead whole URL)', 'wpsk'),
|
67 |
+
'class' => 'regular-text',
|
68 |
+
'value' => $this->defaults['vanity'],
|
69 |
+
) // args
|
70 |
+
);
|
71 |
+
// Username
|
72 |
+
add_settings_field(
|
73 |
+
$this->option_name . 'username', // id
|
74 |
+
__('Legacy YouTube Username', 'wpsk'), // Title
|
75 |
+
array(&$this, 'settings_field_input_text'), // Callback
|
76 |
+
$this->slug . '_general', // Page
|
77 |
+
'ytc_general', // section
|
78 |
+
array(
|
79 |
+
'field' => $this->option_name . "[username]",
|
80 |
+
'description' => __('Your YouTube legacy username', 'wpsk'),
|
81 |
+
'class' => 'regular-text',
|
82 |
+
'value' => $this->defaults['username'],
|
83 |
+
) // args
|
84 |
+
);
|
85 |
+
// Default Playlist
|
86 |
+
add_settings_field(
|
87 |
+
$this->option_name . 'playlist', // id
|
88 |
+
__('Default Playlist ID', 'wpsk'), // Title
|
89 |
+
array(&$this, 'settings_field_input_text'), // Callback
|
90 |
+
$this->slug . '_general', // Page
|
91 |
+
'ytc_general', // section
|
92 |
+
array(
|
93 |
+
'field' => $this->option_name . "[playlist]",
|
94 |
+
'description' => __('Enter default playlist ID (not playlist name)', 'wpsk'),
|
95 |
+
'class' => 'regular-text',
|
96 |
+
'value' => $this->defaults['playlist'],
|
97 |
+
) // args
|
98 |
+
);
|
99 |
+
// Resource
|
100 |
+
add_settings_field(
|
101 |
+
$this->option_name . 'resource', // id
|
102 |
+
__('Resource to use', 'wpsk'), // Title
|
103 |
+
array(&$this, 'settings_field_select'), // Callback
|
104 |
+
$this->slug . '_general', // Page
|
105 |
+
'ytc_general', // section
|
106 |
+
array(
|
107 |
+
'field' => $this->option_name . "[resource]",
|
108 |
+
'label' => __('Resource:', 'wpsk'),
|
109 |
+
'description' => __('What to use as resource for feeds', 'wpsk'),
|
110 |
+
'class' => 'regular-text',
|
111 |
+
'value' => $this->defaults['resource'],
|
112 |
+
'items' => array(
|
113 |
+
'0' => 'Channel',
|
114 |
+
'1' => 'Favourites',
|
115 |
+
'3' => 'Linked Video',
|
116 |
+
'2' => 'Playlist'
|
117 |
+
)
|
118 |
+
) // args
|
119 |
+
);
|
120 |
+
// Playlist Only
|
121 |
+
add_settings_field(
|
122 |
+
$this->option_name . 'only_pl', // id
|
123 |
+
__('Embed standard playlist', 'wpsk'), // Title
|
124 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
125 |
+
$this->slug . '_general', // Page
|
126 |
+
'ytc_general', // section
|
127 |
+
array(
|
128 |
+
'field' => $this->option_name . "[only_pl]",
|
129 |
+
'description' => __("Enable this option to embed whole playlist instead single video from playlist when you chose playlist as resource", 'wpsk'),
|
130 |
+
'class' => 'checkbox',
|
131 |
+
'value' => $this->defaults['only_pl'],
|
132 |
+
) // args
|
133 |
+
);
|
134 |
+
// Cache
|
135 |
+
add_settings_field(
|
136 |
+
$this->option_name . 'cache', // id
|
137 |
+
__('Cache Timeout','wpsk'),
|
138 |
+
array(&$this, 'settings_field_select'),
|
139 |
+
$this->slug . '_general',
|
140 |
+
'ytc_general',
|
141 |
+
array(
|
142 |
+
'field' => $this->option_name . "[cache]",
|
143 |
+
'description' => __('Define caching timeout for YouTube feeds, in seconds', 'wpsk'),
|
144 |
+
'class' => 'wide-text',
|
145 |
+
'value' => $this->defaults['cache'],
|
146 |
+
'items' => array(
|
147 |
+
'0' => __('Do not chache', 'youtube-channel'),
|
148 |
+
'60' => __('1 minute', 'youtube-channel'),
|
149 |
+
'300' => __('5 minutes', 'youtube-channel'),
|
150 |
+
'900' => __('15 minutes', 'youtube-channel'),
|
151 |
+
'1800' => __('30 minutes', 'youtube-channel'),
|
152 |
+
'3600' => __('1 hour', 'youtube-channel'),
|
153 |
+
'7200' => __('2 hours', 'youtube-channel'),
|
154 |
+
'18000' => __('5 hours', 'youtube-channel'),
|
155 |
+
'36000' => __('10 hours', 'youtube-channel'),
|
156 |
+
'43200' => __('12 hours', 'youtube-channel'),
|
157 |
+
'64800' => __('18 hours', 'youtube-channel'),
|
158 |
+
'86400' => __('1 day', 'youtube-channel'),
|
159 |
+
'172800' => __('2 days', 'youtube-channel'),
|
160 |
+
'259200' => __('3 days', 'youtube-channel'),
|
161 |
+
'345600' => __('4 days', 'youtube-channel'),
|
162 |
+
'432000' => __('5 days', 'youtube-channel'),
|
163 |
+
'518400' => __('6 days', 'youtube-channel'),
|
164 |
+
'604800' => __('1 week', 'youtube-channel'),
|
165 |
+
'1209600' => __('2 weeks', 'youtube-channel'),
|
166 |
+
'1814400' => __('3 weeks', 'youtube-channel'),
|
167 |
+
'2419200' => __('1 month', 'youtube-channel')
|
168 |
+
)
|
169 |
+
)
|
170 |
+
);
|
171 |
+
// Fetch
|
172 |
+
add_settings_field(
|
173 |
+
$this->option_name . 'fetch', // id
|
174 |
+
__('Fetch', 'wpsk'), // Title
|
175 |
+
array(&$this, 'settings_field_input_number'), // Callback
|
176 |
+
$this->slug . '_general', // Page
|
177 |
+
'ytc_general', // section
|
178 |
+
array(
|
179 |
+
'field' => $this->option_name . "[fetch]",
|
180 |
+
'description' => __('Number of videos that will be used for random pick (min 2, max 50, default 25)', 'wpsk'),
|
181 |
+
'class' => 'num',
|
182 |
+
'value' => $this->defaults['fetch'],
|
183 |
+
'min' => 1,
|
184 |
+
'max' => 50,
|
185 |
+
'std' => 25
|
186 |
+
) // args
|
187 |
+
);
|
188 |
+
// Show
|
189 |
+
add_settings_field(
|
190 |
+
$this->option_name . 'num', // id
|
191 |
+
__('Show', 'wpsk'), // Title
|
192 |
+
array(&$this, 'settings_field_input_number'), // Callback
|
193 |
+
$this->slug . '_general', // Page
|
194 |
+
'ytc_general', // section
|
195 |
+
array(
|
196 |
+
'field' => $this->option_name . "[num]",
|
197 |
+
'description' => __('Number of videos to display', 'wpsk'),
|
198 |
+
'class' => 'num',
|
199 |
+
'value' => $this->defaults['num'],
|
200 |
+
'min' => 1,
|
201 |
+
'max' => 50,
|
202 |
+
'std' => 1
|
203 |
+
) // args
|
204 |
+
);
|
205 |
+
// Enhanced privacy
|
206 |
+
add_settings_field(
|
207 |
+
$this->option_name . 'privacy', // id
|
208 |
+
__('Use Enhanced privacy', 'wpsk'), // Title
|
209 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
210 |
+
$this->slug . '_general', // Page
|
211 |
+
'ytc_general', // section
|
212 |
+
array(
|
213 |
+
'field' => $this->option_name . "[privacy]",
|
214 |
+
'description' => __("Enable this option to protect your visitors privacy. http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780", 'wpsk'),
|
215 |
+
'class' => 'checkbox',
|
216 |
+
'value' => $this->defaults['privacy'],
|
217 |
+
) // args
|
218 |
+
);
|
219 |
+
// Random video
|
220 |
+
add_settings_field(
|
221 |
+
$this->option_name . 'random', // id
|
222 |
+
__('Show random video', 'wpsk'), // Title
|
223 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
224 |
+
$this->slug . '_general', // Page
|
225 |
+
'ytc_general', // section
|
226 |
+
array(
|
227 |
+
'field' => $this->option_name . "[random]",
|
228 |
+
'description' => __("Get random videos of all fetched from channel or playlist", 'wpsk'),
|
229 |
+
'class' => 'checkbox',
|
230 |
+
'value' => $this->defaults['random'],
|
231 |
+
) // args
|
232 |
+
);
|
233 |
+
// --- Register setting General so $_POST handling is done ---
|
234 |
+
register_setting(
|
235 |
+
'ytc_general', // Setting group
|
236 |
+
$this->option_name, // option name
|
237 |
+
array($this, 'sanitize_options')
|
238 |
+
);
|
239 |
+
|
240 |
+
// =========================== VIDEO ===========================
|
241 |
+
// --- Add settings section Video so we can add fields to it ---
|
242 |
+
add_settings_section(
|
243 |
+
'ytc_video', // Section Name
|
244 |
+
__('Video Tweaks', 'wpsk'), // Section Title
|
245 |
+
array(&$this, 'settings_video_section_description'), // Section Callback Function
|
246 |
+
$this->slug . '_video' // Page Name
|
247 |
+
);
|
248 |
+
// --- Add Fields to video section ---
|
249 |
+
// Width
|
250 |
+
add_settings_field(
|
251 |
+
$this->option_name . 'width', // id
|
252 |
+
__('Width', 'wpsk'), // Title
|
253 |
+
array(&$this, 'settings_field_input_number'), // Callback
|
254 |
+
$this->slug . '_video', // Page
|
255 |
+
'ytc_video', // section
|
256 |
+
array(
|
257 |
+
'field' => $this->option_name . "[width]",
|
258 |
+
'description' => __('Set default width for displayed video, in pixels', 'wpsk'),
|
259 |
+
'class' => 'num',
|
260 |
+
'value' => $this->defaults['width'],
|
261 |
+
'min' => 120,
|
262 |
+
'max' => 1980,
|
263 |
+
'std' => 306
|
264 |
+
) // args
|
265 |
+
);
|
266 |
+
// Aspect Ratio
|
267 |
+
add_settings_field(
|
268 |
+
$this->option_name . 'ratio', // id
|
269 |
+
__('Aspect ratio', 'wpsk'), // Title
|
270 |
+
array(&$this, 'settings_field_select'), // Callback
|
271 |
+
$this->slug . '_video', // Page
|
272 |
+
'ytc_video', // section
|
273 |
+
array(
|
274 |
+
'field' => $this->option_name . "[ratio]",
|
275 |
+
// 'label' => __('Ratio:', 'wpsk'),
|
276 |
+
'description' => __('Select aspect ratio for displayed video', 'wpsk'),
|
277 |
+
'class' => 'regular-text',
|
278 |
+
'value' => $this->defaults['ratio'],
|
279 |
+
'items' => array(
|
280 |
+
'3' => '16:9',
|
281 |
+
'1' => '4:3'
|
282 |
+
)
|
283 |
+
) // args
|
284 |
+
);
|
285 |
+
// Responsive
|
286 |
+
add_settings_field(
|
287 |
+
$this->option_name . 'responsive', // id
|
288 |
+
__('Responsive video', 'wpsk'), // Title
|
289 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
290 |
+
$this->slug . '_video', // Page
|
291 |
+
'ytc_video', // section
|
292 |
+
array(
|
293 |
+
'field' => $this->option_name . "[responsive]",
|
294 |
+
'description' => __("Enable this option to make all YTC videos responsive. Please note, this option will set all videos full width relative to parent container, and disable more than one video per row.", 'wpsk'),
|
295 |
+
'class' => 'checkbox',
|
296 |
+
'value' => $this->defaults['responsive'],
|
297 |
+
) // args
|
298 |
+
);
|
299 |
+
// Display
|
300 |
+
add_settings_field(
|
301 |
+
$this->option_name . 'display', // id
|
302 |
+
__('What to show?', 'wpsk'), // Title
|
303 |
+
array(&$this, 'settings_field_select'), // Callback
|
304 |
+
$this->slug . '_video', // Page
|
305 |
+
'ytc_video', // section
|
306 |
+
array(
|
307 |
+
'field' => $this->option_name . "[display]",
|
308 |
+
// 'label' => __('Ratio:', 'wpsk'),
|
309 |
+
'description' => __('Select aspect ratio for displayed video', 'wpsk'),
|
310 |
+
'class' => 'regular-text',
|
311 |
+
'value' => $this->defaults['display'],
|
312 |
+
'items' => array(
|
313 |
+
'thumbnail' => 'Thumbnail',
|
314 |
+
'iframe' => 'HTML5 (iframe)',
|
315 |
+
'iframe2' => 'HTML5 (iframe) Asynchronous'
|
316 |
+
)
|
317 |
+
) // args
|
318 |
+
);
|
319 |
+
// Light Theme
|
320 |
+
add_settings_field(
|
321 |
+
$this->option_name . 'themelight', // id
|
322 |
+
__('Light Theme', 'wpsk'), // Title
|
323 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
324 |
+
$this->slug . '_video', // Page
|
325 |
+
'ytc_video', // section
|
326 |
+
array(
|
327 |
+
'field' => $this->option_name . "[themelight]",
|
328 |
+
'description' => __("Enable this option to use light theme for playback controls instead dark.", 'wpsk'),
|
329 |
+
'class' => 'checkbox',
|
330 |
+
'value' => $this->defaults['themelight'],
|
331 |
+
) // args
|
332 |
+
);
|
333 |
+
// No Player Controls
|
334 |
+
add_settings_field(
|
335 |
+
$this->option_name . 'controls', // id
|
336 |
+
__('Hide Player Controls', 'wpsk'), // Title
|
337 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
338 |
+
$this->slug . '_video', // Page
|
339 |
+
'ytc_video', // section
|
340 |
+
array(
|
341 |
+
'field' => $this->option_name . "[controls]",
|
342 |
+
'description' => __("Enable this option to hide playback controls", 'wpsk'),
|
343 |
+
'class' => 'checkbox',
|
344 |
+
'value' => $this->defaults['controls'],
|
345 |
+
) // args
|
346 |
+
);
|
347 |
+
// Fix Height (deprecated?)
|
348 |
+
// Autoplay
|
349 |
+
add_settings_field(
|
350 |
+
$this->option_name . 'autoplay', // id
|
351 |
+
__('Autoplay video or playlist', 'wpsk'), // Title
|
352 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
353 |
+
$this->slug . '_video', // Page
|
354 |
+
'ytc_video', // section
|
355 |
+
array(
|
356 |
+
'field' => $this->option_name . "[autoplay]",
|
357 |
+
'description' => __("Enable this option to start video playback right after block is rendered", 'wpsk'),
|
358 |
+
'class' => 'checkbox',
|
359 |
+
'value' => $this->defaults['autoplay'],
|
360 |
+
) // args
|
361 |
+
);
|
362 |
+
// Mute on autoplay
|
363 |
+
add_settings_field(
|
364 |
+
$this->option_name . 'autoplay_mute', // id
|
365 |
+
__('Mute video on autoplay', 'wpsk'), // Title
|
366 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
367 |
+
$this->slug . '_video', // Page
|
368 |
+
'ytc_video', // section
|
369 |
+
array(
|
370 |
+
'field' => $this->option_name . "[autoplay_mute]",
|
371 |
+
'description' => __("Enable this option to mute video when start autoplay", 'wpsk'),
|
372 |
+
'class' => 'checkbox',
|
373 |
+
'value' => $this->defaults['autoplay_mute'],
|
374 |
+
) // args
|
375 |
+
);
|
376 |
+
// No related videos
|
377 |
+
add_settings_field(
|
378 |
+
$this->option_name . 'norel', // id
|
379 |
+
__('Hide related videos', 'wpsk'), // Title
|
380 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
381 |
+
$this->slug . '_video', // Page
|
382 |
+
'ytc_video', // section
|
383 |
+
array(
|
384 |
+
'field' => $this->option_name . "[norel]",
|
385 |
+
'description' => __("Enable this option to hide related videos after finished playback", 'wpsk'),
|
386 |
+
'class' => 'checkbox',
|
387 |
+
'value' => $this->defaults['norel'],
|
388 |
+
) // args
|
389 |
+
);
|
390 |
+
// Hide YT logo
|
391 |
+
add_settings_field(
|
392 |
+
$this->option_name . 'modestbranding', // id
|
393 |
+
__('Hide YT logo', 'wpsk'), // Title
|
394 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
395 |
+
$this->slug . '_video', // Page
|
396 |
+
'ytc_video', // section
|
397 |
+
array(
|
398 |
+
'field' => $this->option_name . "[modestbranding]",
|
399 |
+
'description' => __("Enable this option to hide YouTube logo from playback control bar. Does not work for all videos.
|
400 |
+
", 'wpsk'),
|
401 |
+
'class' => 'checkbox',
|
402 |
+
'value' => $this->defaults['modestbranding'],
|
403 |
+
) // args
|
404 |
+
);
|
405 |
+
// --- Register setting Video so $_POST handling is done ---
|
406 |
+
register_setting(
|
407 |
+
'ytc_video', // Setting group
|
408 |
+
$this->option_name, // option name
|
409 |
+
array($this, 'sanitize_options')
|
410 |
+
);
|
411 |
+
|
412 |
+
// =========================== CONTENT ===========================
|
413 |
+
// --- Add settings section Content so we can add fields to it ---
|
414 |
+
add_settings_section(
|
415 |
+
'ytc_content', // Section Name
|
416 |
+
__('Content Tweaks', 'wpsk'), // Section Title
|
417 |
+
array(&$this, 'settings_content_section_description'), // Section Callback Function
|
418 |
+
$this->slug . '_content' // Page Name
|
419 |
+
);
|
420 |
+
// --- Add Fields to video section ---
|
421 |
+
// Video Title
|
422 |
+
add_settings_field(
|
423 |
+
$this->option_name . 'showtitle', // id
|
424 |
+
__('Show video title', 'wpsk'), // Title
|
425 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
426 |
+
$this->slug . '_content', // Page
|
427 |
+
'ytc_content', // section
|
428 |
+
array(
|
429 |
+
'field' => $this->option_name . "[showtitle]",
|
430 |
+
'description' => __("Enable this option to display title of video", 'wpsk'),
|
431 |
+
'class' => 'checkbox',
|
432 |
+
'value' => $this->defaults['showtitle'],
|
433 |
+
) // args
|
434 |
+
);
|
435 |
+
// Video Description
|
436 |
+
add_settings_field(
|
437 |
+
$this->option_name . 'showdesc', // id
|
438 |
+
__('Show video description', 'wpsk'), // Title
|
439 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
440 |
+
$this->slug . '_content', // Page
|
441 |
+
'ytc_content', // section
|
442 |
+
array(
|
443 |
+
'field' => $this->option_name . "[showdesc]",
|
444 |
+
'description' => __("Enable this option to display description for video", 'wpsk'),
|
445 |
+
'class' => 'checkbox',
|
446 |
+
'value' => $this->defaults['showdesc'],
|
447 |
+
) // args
|
448 |
+
);
|
449 |
+
// Description length
|
450 |
+
add_settings_field(
|
451 |
+
$this->option_name . 'desclen', // id
|
452 |
+
__('Description length', 'wpsk'), // Title
|
453 |
+
array(&$this, 'settings_field_input_number'), // Callback
|
454 |
+
$this->slug . '_content', // Page
|
455 |
+
'ytc_content', // section
|
456 |
+
array(
|
457 |
+
'field' => $this->option_name . "[desclen]",
|
458 |
+
'description' => __('Enter length for video description in characters (0 for full length)', 'wpsk'),
|
459 |
+
'class' => 'num',
|
460 |
+
'value' => $this->defaults['desclen'],
|
461 |
+
'min' => 0,
|
462 |
+
'max' => 2500,
|
463 |
+
'std' => 0
|
464 |
+
) // args
|
465 |
+
);
|
466 |
+
// Et cetera string
|
467 |
+
add_settings_field(
|
468 |
+
$this->option_name . 'descappend', // id
|
469 |
+
__('Et cetera string', 'wpsk'), // Title
|
470 |
+
array(&$this, 'settings_field_input_text'), // Callback
|
471 |
+
$this->slug . '_content', // Page
|
472 |
+
'ytc_content', // section
|
473 |
+
array(
|
474 |
+
'field' => $this->option_name . "[descappend]",
|
475 |
+
'description' => __('Indicator for shortened video description (default: …)', 'wpsk'),
|
476 |
+
'class' => 'small-text',
|
477 |
+
'value' => $this->defaults['descappend'],
|
478 |
+
) // args
|
479 |
+
);
|
480 |
+
// Hide Annotations
|
481 |
+
add_settings_field(
|
482 |
+
$this->option_name . 'hideanno', // id
|
483 |
+
__('Hide video annotations', 'wpsk'), // Title
|
484 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
485 |
+
$this->slug . '_content', // Page
|
486 |
+
'ytc_content', // section
|
487 |
+
array(
|
488 |
+
'field' => $this->option_name . "[hideanno]",
|
489 |
+
'description' => __("Enable this option to hide video annotations (custom text set by uploader over video during playback)", 'wpsk'),
|
490 |
+
'class' => 'checkbox',
|
491 |
+
'value' => $this->defaults['hideanno'],
|
492 |
+
) // args
|
493 |
+
);
|
494 |
+
// Hide Video Info
|
495 |
+
add_settings_field(
|
496 |
+
$this->option_name . 'hideinfo', // id
|
497 |
+
__('Hide video info', 'wpsk'), // Title
|
498 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
499 |
+
$this->slug . '_content', // Page
|
500 |
+
'ytc_content', // section
|
501 |
+
array(
|
502 |
+
'field' => $this->option_name . "[hideinfo]",
|
503 |
+
'description' => __("Enable this option to hide informations about video before play start (video title and uploader in overlay)", 'wpsk'),
|
504 |
+
'class' => 'checkbox',
|
505 |
+
'value' => $this->defaults['hideinfo'],
|
506 |
+
) // args
|
507 |
+
);
|
508 |
+
|
509 |
+
// --- Register setting Content so $_POST handling is done ---
|
510 |
+
register_setting(
|
511 |
+
'ytc_content', // Setting group
|
512 |
+
$this->option_name, // option name
|
513 |
+
array($this, 'sanitize_options')
|
514 |
+
);
|
515 |
+
|
516 |
+
// =========================== LINK ===========================
|
517 |
+
// --- Add settings section Link to Channel so we can add fields to it ---
|
518 |
+
add_settings_section(
|
519 |
+
'ytc_link', // Section Name
|
520 |
+
__('Link to Channel', 'wpsk'), // Section Title
|
521 |
+
array(&$this, 'settings_link_section_description'), // Section Callback Function
|
522 |
+
$this->slug . '_link' // Page Name
|
523 |
+
);
|
524 |
+
// --- Add Fields to video section ---
|
525 |
+
// Show link to channel
|
526 |
+
add_settings_field(
|
527 |
+
$this->option_name . 'showgoto', // id
|
528 |
+
__('Show link to channel', 'wpsk'), // Title
|
529 |
+
array(&$this, 'settings_field_checkbox'), // Callback
|
530 |
+
$this->slug . '_link', // Page
|
531 |
+
'ytc_link', // section
|
532 |
+
array(
|
533 |
+
'field' => $this->option_name . "[showgoto]",
|
534 |
+
'description' => __("Enable this option to show customized link to channel at the bottom of YTC block", 'wpsk'),
|
535 |
+
'class' => 'checkbox',
|
536 |
+
'value' => $this->defaults['showgoto'],
|
537 |
+
) // args
|
538 |
+
);
|
539 |
+
// Visit channel text
|
540 |
+
add_settings_field(
|
541 |
+
$this->option_name . 'goto_txt', // id
|
542 |
+
__('Text for Visit channel link', 'wpsk'), // Title
|
543 |
+
array(&$this, 'settings_field_input_text'), // Callback
|
544 |
+
$this->slug . '_link', // Page
|
545 |
+
'ytc_link', // section
|
546 |
+
array(
|
547 |
+
'field' => $this->option_name . "[goto_txt]",
|
548 |
+
'description' => __('Use placeholder %channel% or %vanity% to insert channel/nice name', 'wpsk'),
|
549 |
+
'class' => 'regular-text',
|
550 |
+
'value' => $this->defaults['goto_txt'],
|
551 |
+
) // args
|
552 |
+
);
|
553 |
+
// Open in...
|
554 |
+
add_settings_field(
|
555 |
+
$this->option_name . 'popup_goto', // id
|
556 |
+
__('Open link in...', 'wpsk'), // Title
|
557 |
+
array(&$this, 'settings_field_select'), // Callback
|
558 |
+
$this->slug . '_link', // Page
|
559 |
+
'ytc_link', // section
|
560 |
+
array(
|
561 |
+
'field' => $this->option_name . "[popup_goto]",
|
562 |
+
// 'label' => __('Ratio:', 'wpsk'),
|
563 |
+
'description' => __('Set where link will be opened', 'wpsk'),
|
564 |
+
'class' => 'regular-text',
|
565 |
+
'value' => $this->defaults['popup_goto'],
|
566 |
+
'items' => array(
|
567 |
+
'0' => 'same window',
|
568 |
+
'1' => 'new window (JavaScript)',
|
569 |
+
'2' => 'new window (target="_blank")'
|
570 |
+
)
|
571 |
+
) // args
|
572 |
+
);
|
573 |
+
// Link to...
|
574 |
+
add_settings_field(
|
575 |
+
$this->option_name . 'link_to', // id
|
576 |
+
__('Link to...', 'wpsk'), // Title
|
577 |
+
array(&$this, 'settings_field_select'), // Callback
|
578 |
+
$this->slug . '_link', // Page
|
579 |
+
'ytc_link', // section
|
580 |
+
array(
|
581 |
+
'field' => $this->option_name . "[link_to]",
|
582 |
+
// 'label' => __('Ratio:', 'wpsk'),
|
583 |
+
'description' => __('Set where link will lead visitors', 'wpsk'),
|
584 |
+
'class' => 'regular-text',
|
585 |
+
'value' => $this->defaults['link_to'],
|
586 |
+
'items' => array(
|
587 |
+
'2' => 'Vanity custom URL',
|
588 |
+
'1' => 'Channel page URL',
|
589 |
+
'0' => 'Legacy username page'
|
590 |
+
)
|
591 |
+
) // args
|
592 |
+
);
|
593 |
+
// --- Register setting Content so $_POST handling is done ---
|
594 |
+
register_setting(
|
595 |
+
'ytc_link', // Setting group
|
596 |
+
$this->option_name, // option name
|
597 |
+
array($this, 'sanitize_options')
|
598 |
+
);
|
599 |
+
|
600 |
+
} // eom register_settings()
|
601 |
+
|
602 |
+
/**
|
603 |
+
* Add settings menu
|
604 |
+
*/
|
605 |
+
public function add_menu() {
|
606 |
+
|
607 |
+
// Add a page to manage this plugin's settings
|
608 |
+
add_options_page(
|
609 |
+
__('YouTube Channel', 'wpsk'),
|
610 |
+
__('YouTube Channel','wpsk'),
|
611 |
+
'manage_options',
|
612 |
+
$this->slug,
|
613 |
+
array(&$this, 'plugin_settings_page')
|
614 |
+
);
|
615 |
+
|
616 |
+
} // eom add_menu()
|
617 |
+
|
618 |
+
// ===================== HELPERS ==========================
|
619 |
+
|
620 |
+
// --- Section desciptions ---
|
621 |
+
public function settings_general_section_description() {
|
622 |
+
?>
|
623 |
+
<p>Configure general defaults for YouTube Channel used as fallback options in widget or shortcodes. To get Channel ID and Vanity/Custom URL visit <a href="https://www.youtube.com/account_advanced" target="_blank">YouTube Account Overview</a>.</p>
|
624 |
+
<?php
|
625 |
+
} // eom settings_general_section_description()
|
626 |
+
public function settings_video_section_description() {
|
627 |
+
?>
|
628 |
+
<p>Configure video specific defaults for YouTube Channel used as fallback options in widget or shortcodes.</p>
|
629 |
+
<?php
|
630 |
+
} // eom settings_video_section_description() {
|
631 |
+
public function settings_content_section_description() {
|
632 |
+
?>
|
633 |
+
<p>Configure defaults of content around and over videos for YouTube Channel used as fallback options in widget or shortcodes.</p>
|
634 |
+
<?php
|
635 |
+
} // eom settings_content_section_description() {
|
636 |
+
public function settings_link_section_description() {
|
637 |
+
?>
|
638 |
+
<p>Configure defaults for link to channel below YouTube Channel block used as fallback options in widget or shortcodes.</p>
|
639 |
+
<?php
|
640 |
+
} // eom settings_link_section_description() {
|
641 |
+
|
642 |
+
/**
|
643 |
+
* This function provides separator for settings fields
|
644 |
+
*/
|
645 |
+
public function settings_field_separator($args=null) {
|
646 |
+
echo '<hr>';
|
647 |
+
} // eom settings_field_input_text()
|
648 |
+
|
649 |
+
/**
|
650 |
+
* This function provides text inputs for settings fields
|
651 |
+
*/
|
652 |
+
public function settings_field_input_text($args) {
|
653 |
+
|
654 |
+
extract( $args );
|
655 |
+
|
656 |
+
echo sprintf('<input type="text" name="%s" id="%s" value="%s" class="%s" /><p class="description">%s</p>', $field, $field, $value, $class, $description);
|
657 |
+
|
658 |
+
} // eom settings_field_input_text()
|
659 |
+
|
660 |
+
/**
|
661 |
+
* This function provides number inputs for settings fields
|
662 |
+
*/
|
663 |
+
public function settings_field_input_number($args) {
|
664 |
+
|
665 |
+
extract( $args );
|
666 |
+
|
667 |
+
echo sprintf('<input type="number" name="%s" id="%s" value="%s" min="%s" max="%s" class="%s" /><p class="description">%s</p>', $field, $field, $value, $min, $max, $class, $description);
|
668 |
+
|
669 |
+
} // eom settings_field_input_text()
|
670 |
+
|
671 |
+
/**
|
672 |
+
* This function provides select for settings fields
|
673 |
+
*/
|
674 |
+
public function settings_field_select($args) {
|
675 |
+
|
676 |
+
extract( $args );
|
677 |
+
|
678 |
+
$html = '';
|
679 |
+
// $html .= sprintf('<label for="%s">%s</label><br>', $field, $label);
|
680 |
+
$html .= sprintf('<select id="%s" name="%s">', $field, $field);
|
681 |
+
foreach ($items as $key=>$val)
|
682 |
+
{
|
683 |
+
$selected = ($value==$key) ? 'selected="selected"' : '';
|
684 |
+
$html .= sprintf('<option %s value="%s">%s</option>',$selected,$key,$val);
|
685 |
+
}
|
686 |
+
$html .= sprintf('</select><p class="description">%s</p>',$description);
|
687 |
+
|
688 |
+
echo $html;
|
689 |
+
|
690 |
+
} // eom settings_field_select()
|
691 |
+
|
692 |
+
/**
|
693 |
+
* This function provides checkbox for settings fields
|
694 |
+
*/
|
695 |
+
public function settings_field_checkbox($args) {
|
696 |
+
|
697 |
+
extract( $args );
|
698 |
+
|
699 |
+
$checked = ( !empty($args['value']) ) ? 'checked="checked"' : '';
|
700 |
+
echo sprintf('<label for="%s"><input type="checkbox" name="%s" id="%s" value="1" class="%s" %s />%s</label>', $field, $field, $field, $class, $checked, $description);
|
701 |
+
|
702 |
+
} // eom settings_field_checkbox()
|
703 |
+
|
704 |
+
/**
|
705 |
+
* This function provides checkbox groupfor settings fields
|
706 |
+
*/
|
707 |
+
public function settings_field_checkbox_group($args) {
|
708 |
+
|
709 |
+
extract( $args );
|
710 |
+
|
711 |
+
// items
|
712 |
+
$out = '<fieldset>';
|
713 |
+
|
714 |
+
foreach ( $items as $key => $label ) {
|
715 |
+
|
716 |
+
$checked = '';
|
717 |
+
if ( ! empty($value) ) {
|
718 |
+
$checked = ( in_array($key, $value) ) ? 'checked="checked"' : '';
|
719 |
+
}
|
720 |
+
|
721 |
+
$out .= sprintf(
|
722 |
+
'<label for="%s_%s"><input type="checkbox" name="%s[]" id="%s_%s" value="%s" class="%s" %s />%s</label><br>',
|
723 |
+
$field,
|
724 |
+
$key,
|
725 |
+
|
726 |
+
$field,
|
727 |
+
|
728 |
+
$field,
|
729 |
+
$key,
|
730 |
+
|
731 |
+
$key,
|
732 |
+
|
733 |
+
$class,
|
734 |
+
$checked,
|
735 |
+
$label
|
736 |
+
);
|
737 |
+
}
|
738 |
+
|
739 |
+
$out .= '</fieldset>';
|
740 |
+
$out .= sprintf('<p class="description">%s</p>' , $description);
|
741 |
+
|
742 |
+
echo $out;
|
743 |
+
|
744 |
+
} // eom settings_field_checkbox()
|
745 |
+
|
746 |
+
/**
|
747 |
+
* This function provides radio buttons for settings fields
|
748 |
+
*/
|
749 |
+
public function settings_field_radio($args) {
|
750 |
+
|
751 |
+
extract( $args );
|
752 |
+
|
753 |
+
$html = '';
|
754 |
+
|
755 |
+
if ( ! empty($prescription) )
|
756 |
+
$html .= sprintf('<p class="prescription">%s</p>', $prescription);
|
757 |
+
|
758 |
+
foreach ($items as $key=>$val) {
|
759 |
+
|
760 |
+
$checked = ($value==$key) ? 'checked="checked"' : '';
|
761 |
+
$html .= sprintf(
|
762 |
+
'<label for="%s_%s"><input type="radio" name="%s" id="%s_%s" value="%s" %s>%s</label><br />',
|
763 |
+
$field, $key,
|
764 |
+
$field,
|
765 |
+
$field, $key,
|
766 |
+
$key,
|
767 |
+
$checked,
|
768 |
+
$val
|
769 |
+
);
|
770 |
+
|
771 |
+
} // foreach $items
|
772 |
+
|
773 |
+
$html .= sprintf('<p class="description">%s</p>',$description);
|
774 |
+
|
775 |
+
echo $html;
|
776 |
+
|
777 |
+
} // eom settings_field_checkbox()
|
778 |
+
|
779 |
+
/**
|
780 |
+
* Menu Callback
|
781 |
+
*/
|
782 |
+
public function plugin_settings_page() {
|
783 |
+
|
784 |
+
if ( ! current_user_can('manage_options') ) {
|
785 |
+
wp_die(__('You do not have sufficient permissions to access this page.'));
|
786 |
+
}
|
787 |
+
|
788 |
+
// Render the settings template
|
789 |
+
require_once('settings_template.php');
|
790 |
+
|
791 |
+
} // eom plugin_settings_page()
|
792 |
+
|
793 |
+
/**
|
794 |
+
* process options before update
|
795 |
+
*
|
796 |
+
*/
|
797 |
+
public function sanitize_options($options) {
|
798 |
+
|
799 |
+
$sanitized = get_option( $this->option_name );
|
800 |
+
|
801 |
+
switch ( $_POST['option_page'] ) {
|
802 |
+
|
803 |
+
// --- General ---
|
804 |
+
case 'ytc_general':
|
805 |
+
$sanitized['channel'] = ( ! empty($options['channel']) ) ? trim($options['channel']) : $this->defaults['channel'];
|
806 |
+
$sanitized['vanity'] = ( ! empty($options['vanity']) ) ? trim($options['vanity']) : $this->defaults['vanity'];
|
807 |
+
$sanitized['username'] = ( ! empty($options['username']) ) ? trim($options['username']) : $this->defaults['username'];
|
808 |
+
$sanitized['playlist'] = ( ! empty($options['playlist']) ) ? trim($options['playlist']) : $this->defaults['playlist'];
|
809 |
+
$sanitized['resource'] = ( ! empty($options['resource']) ) ? intval($options['resource']) : $this->defaults['resource'];
|
810 |
+
$sanitized['only_pl'] = ( ! empty($options['only_pl']) && $options['only_pl'] ) ? 1 : 0;
|
811 |
+
$sanitized['cache'] = ( ! empty($options['cache']) ) ? intval($options['cache']) : $this->defaults['cache'];
|
812 |
+
$sanitized['fetch'] = ( ! empty($options['fetch']) ) ? intval($options['fetch']) : $this->defaults['fetch'];
|
813 |
+
$sanitized['num'] = ( ! empty($options['num']) ) ? intval($options['num']) : $this->defaults['num'];
|
814 |
+
$sanitized['privacy'] = ( ! empty($options['privacy']) && $options['privacy'] ) ? 1 : 0;
|
815 |
+
$sanitized['random'] = ( ! empty($options['random']) && $options['random'] ) ? 1 : 0;
|
816 |
+
break; // General
|
817 |
+
|
818 |
+
// --- Video ---
|
819 |
+
case 'ytc_video':
|
820 |
+
$sanitized['width'] = ( ! empty($options['width']) ) ? intval($options['width']) : $this->defaults['width'];
|
821 |
+
$sanitized['ratio'] = ( ! empty($options['ratio']) ) ? intval($options['ratio']) : $this->defaults['ratio'];
|
822 |
+
$sanitized['responsive'] = ( ! empty($options['responsive']) && $options['responsive'] ) ? 1 : 0;
|
823 |
+
$sanitized['display'] = ( ! empty($options['display']) ) ? intval($options['display']) : $this->defaults['display'];
|
824 |
+
$sanitized['themelight'] = ( ! empty($options['themelight']) && $options['themelight'] ) ? 1 : 0;
|
825 |
+
$sanitized['controls'] = ( ! empty($options['controls']) && $options['controls'] ) ? 1 : 0;
|
826 |
+
$sanitized['autoplay'] = ( ! empty($options['autoplay']) && $options['autoplay'] ) ? 1 : 0;
|
827 |
+
$sanitized['autoplay_mute'] = ( ! empty($options['autoplay_mute']) && $options['autoplay_mute'] ) ? 1 : 0;
|
828 |
+
$sanitized['norel'] = ( ! empty($options['norel']) && $options['norel'] ) ? 1 : 0;
|
829 |
+
$sanitized['modestbranding'] = ( ! empty($options['modestbranding']) && $options['modestbranding'] ) ? 1 : 0;
|
830 |
+
break; // Video
|
831 |
+
|
832 |
+
// --- Content ---
|
833 |
+
case 'ytc_content':
|
834 |
+
$sanitized['showtitle'] = ( ! empty($options['showtitle']) && $options['showtitle'] ) ? 1 : 0;
|
835 |
+
$sanitized['showdesc'] = ( ! empty($options['showdesc']) && $options['showdesc'] ) ? 1 : 0;
|
836 |
+
$sanitized['desclen'] = ( ! empty($options['desclen']) ) ? intval($options['desclen']) : $this->defaults['desclen'];
|
837 |
+
$sanitized['descappend'] = ( ! empty($options['descappend']) ) ? $options['descappend'] : $this->defaults['descappend'];
|
838 |
+
$sanitized['hideanno'] = ( ! empty($options['hideanno']) && $options['hideanno'] ) ? 1 : 0;
|
839 |
+
$sanitized['hideinfo'] = ( ! empty($options['hideinfo']) && $options['hideinfo'] ) ? 1 : 0;
|
840 |
+
break; // Content
|
841 |
+
|
842 |
+
// --- Link to Channel ---
|
843 |
+
case 'ytc_link':
|
844 |
+
$sanitized['showgoto'] = ( ! empty($options['showgoto']) && $options['showgoto'] ) ? 1 : 0;
|
845 |
+
$sanitized['goto_txt'] = ( ! empty($options['goto_txt']) ) ? $options['goto_txt'] : $this->defaults['goto_txt'];
|
846 |
+
$sanitized['popup_goto'] = ( ! empty($options['popup_goto']) ) ? intval($options['popup_goto']) : $this->defaults['popup_goto'];
|
847 |
+
$sanitized['link_to'] = ( ! empty($options['link_to']) ) ? intval($options['link_to']) : $this->defaults['link_to'];
|
848 |
+
break; // Link to Channel
|
849 |
+
|
850 |
+
} // switch
|
851 |
+
// $sanitized['dashboard_roles'] = ( ! empty($options['dashboard_roles']) && is_array($options['dashboard_roles']) ) ? $options['dashboard_roles'] : array('administrator','editor','client');
|
852 |
+
// $sanitized['dashboard_redirect_url'] = ( ! empty($options['dashboard_redirect_url']) ) ? $options['dashboard_redirect_url'] : '';
|
853 |
+
|
854 |
+
// --- Update ---
|
855 |
+
// now return sanitized options to be written to database
|
856 |
+
return $sanitized;
|
857 |
+
|
858 |
+
} // eom sanitize_options()
|
859 |
+
|
860 |
+
} // eo class WPAU_YOUTUBE_CHANNEL_SETTINGS
|
861 |
+
|
862 |
+
} // eo class_exists WPAU_YOUTUBE_CHANNEL_SETTINGS
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
global $WPAU_YOUTUBE_CHANNEL;
|
3 |
+
?>
|
4 |
+
<div class="wrap" id="youtube_channel_settings">
|
5 |
+
<h2><?php _e( $WPAU_YOUTUBE_CHANNEL->plugin_name . ' Settings', 'wpsk' ); ?></h2>
|
6 |
+
<?php
|
7 |
+
|
8 |
+
$active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
|
9 |
+
|
10 |
+
|
11 |
+
// define available tabs
|
12 |
+
$tabs = array(
|
13 |
+
'general' => 'General',
|
14 |
+
'video' => 'Video',
|
15 |
+
'content' => 'Content',
|
16 |
+
'link' => 'Link to Channel',
|
17 |
+
'tools' => 'Tools',
|
18 |
+
'help' => 'Help',
|
19 |
+
'support' => 'Support'
|
20 |
+
);
|
21 |
+
?>
|
22 |
+
<h2 class="nav-tab-wrapper">
|
23 |
+
<?php
|
24 |
+
foreach ( $tabs as $tab_name => $tab_title ) {
|
25 |
+
echo '<a href="?page=' . $WPAU_YOUTUBE_CHANNEL->plugin_slug . '&tab=' . $tab_name . '" class="nav-tab' . ( ( $active_tab == $tab_name ) ? ' nav-tab-active' : '' ) . '">' . $tab_title . '</a>';
|
26 |
+
}
|
27 |
+
?>
|
28 |
+
</h2>
|
29 |
+
<?php
|
30 |
+
|
31 |
+
if ( ! empty($tabs[ $active_tab ]) ) {
|
32 |
+
|
33 |
+
if ( ! in_array( $active_tab, array('tools', 'help', 'support') ) ) {
|
34 |
+
// for all tabs except tools and help
|
35 |
+
|
36 |
+
echo '<form method="post" action="options.php">';
|
37 |
+
|
38 |
+
settings_fields( 'ytc_' . $active_tab );
|
39 |
+
// settings_fields( $WPAU_YOUTUBE_CHANNEL->plugin_slug . '_' . $active_tab );
|
40 |
+
do_settings_sections( $WPAU_YOUTUBE_CHANNEL->plugin_slug . '_' . $active_tab );
|
41 |
+
// do_settings_sections( 'ytc_' . $active_tab );
|
42 |
+
// settings_fields( $WPAU_YOUTUBE_CHANNEL->plugin_slug . '_' . $active_tab );
|
43 |
+
// do_settings_sections( $WPAU_YOUTUBE_CHANNEL->plugin_slug . '_' . $active_tab );
|
44 |
+
|
45 |
+
submit_button();
|
46 |
+
|
47 |
+
echo '</form>';
|
48 |
+
|
49 |
+
} else if ( $active_tab == 'tools' ) {
|
50 |
+
include_once("settings_tools.php");
|
51 |
+
} else if ( $active_tab == 'help' ) {
|
52 |
+
include_once("settings_usage.php");
|
53 |
+
include_once("settings_usage_shortcode.php");
|
54 |
+
} else if ( $active_tab == 'support' ) {
|
55 |
+
include_once("settings_support.php");
|
56 |
+
} // $active_tab != 'tools|help|support'
|
57 |
+
|
58 |
+
} // ! empty ( $tabs[$active_tab] )
|
59 |
+
?>
|
60 |
+
|
61 |
+
</div>
|
@@ -12,7 +12,7 @@ jQuery(document).ready(function($){
|
|
12 |
if ( $('#recache_slug').val() == '' ) {
|
13 |
$('#recache_message').html("Please type relative path and try again!").show().delay(3000).fadeOut(700);
|
14 |
} else {
|
15 |
-
window.open( $('#recache_slug').val()+'?ytc_force_recache=1' );
|
16 |
}
|
17 |
});
|
18 |
});
|
12 |
if ( $('#recache_slug').val() == '' ) {
|
13 |
$('#recache_message').html("Please type relative path and try again!").show().delay(3000).fadeOut(700);
|
14 |
} else {
|
15 |
+
window.open( $('#recache_slug').val()+'?ytc_force_recache=1' );
|
16 |
}
|
17 |
});
|
18 |
});
|
@@ -1,3 +1,4 @@
|
|
|
|
1 |
<p>You can insert YouTube Channel in couple different ways.</p>
|
2 |
<ol>
|
3 |
<li>Insert <a href="widget.php">YouTube Channel Widget</a> in preferred Widget Area, and configure it there.</li>
|
1 |
+
<h3>How to use YouTube Channel</h3>
|
2 |
<p>You can insert YouTube Channel in couple different ways.</p>
|
3 |
<ol>
|
4 |
<li>Insert <a href="widget.php">YouTube Channel Widget</a> in preferred Widget Area, and configure it there.</li>
|
@@ -1,14 +1,18 @@
|
|
1 |
-
<
|
2 |
-
<
|
|
|
|
|
3 |
<ul>
|
4 |
-
<li><code>class</code> <em>(string)</em> Set custom class if you wish to target special styling for specific YTC block</li>
|
5 |
<li><code>channel</code> <em>(string)</em> ID of preferred YouTube channel. Do not set full URL to channel, but just last part from URL - ID (name)</li>
|
|
|
|
|
6 |
<li><code>playlist</code> <em>(string)</em> ID of preferred YouTube playlist.</li>
|
7 |
-
<li><code>
|
8 |
<ul>
|
9 |
<li>• <code>0</code> Channel</li>
|
10 |
<li>• <code>1</code> Favorites (for defined channel)</li>
|
11 |
<li>• <code>2</code> Playlist</li>
|
|
|
12 |
</ul></li>
|
13 |
<li><code>only_pl</code> <em>(bool)</em> If you set to use Playlist as resource, you can embed youtube playlist block instead single video from playlist. Simply set this option to true (<code>1</code> or <code>true</code>)</li>
|
14 |
<li><code>cache</code> <em>(int)</em> Period in seconds for caching feed. You can disable caching by setting this option to <code>0</code>, but if you have a lot of visits, consider at least short caching (couple minutes).</li>
|
@@ -16,38 +20,34 @@
|
|
16 |
<li><code>fetch</code> <em>(int)</em> Number of videos that will be used as stack for random pick (min 2, max 50)</li>
|
17 |
<li><code>num</code> <em>(int)</em> Number of videos to display per YTC block.</li>
|
18 |
|
19 |
-
<li><code>fix</code> <em>(bool)</em> Option to fix <em>No Items</em> error, and also to respect order of videos in feed or playlist.</li>
|
20 |
<li><code>random</code> <em>(bool)</em> Option to randomize videos on every page load.</li>
|
21 |
</ul>
|
22 |
-
<
|
23 |
<ul>
|
24 |
<li><code>ratio</code> <em>(int)</em> Set preferred aspect ratio for thumbnail and video. You can use:
|
25 |
<ul>
|
26 |
-
<li>• <code>3</code> 16:9 (
|
27 |
-
<li>• <code>2</code> 16:10 (computer screen)</li>
|
28 |
<li>• <code>1</code> 4:3</li>
|
29 |
</ul></li>
|
30 |
-
<li><code>responsive</code> <em>(bool)</em> Distribute one full width video per row.</li>
|
31 |
<li><code>width</code> <em>(int)</em> Width of thumbnail and video in pixels.</li>
|
32 |
-
<li><code>
|
|
|
33 |
<ul>
|
34 |
<li>• <code>thumbnail</code> Thumbnail will be used and video will be loaded in lightbox.</li>
|
35 |
<li>• <code>iframe</code> HTML5 (iframe)</li>
|
36 |
<li>• <code>iframe2</code> HTML5 (iframe) with asynchronous loading - recommended</li>
|
37 |
-
<li>• <code>object</code> Flash object (not so good for Apple devices)</li>
|
38 |
-
<li>• <code>chromeless</code> Chromeless solution (also not good for Apple devices)</li>
|
39 |
</ul></li>
|
40 |
|
41 |
<li><code>no_thumb_title</code> <em>(bool)</em> By default YouTube thumbnail will have tooltip with info about video title and date of publishing. By setting this option to <code>1</code> or <code>true</code> you can hide tooltip</li>
|
42 |
<li><code>themelight</code> <em>(bool)</em> By default YouTube have dark play controls theme. By setting this option to <code>1</code> or <code>true</code> you can get light theme in player (HTML5 and Flash)</li>
|
43 |
-
<li><code>controls</code> <em>(bool)</em> Set this option to <code>1</code> or <code>true</code> to hide playback controls
|
44 |
<li><code>fix_h</code> <em>(bool)</em> If you did not set to hide player controls, you can set this option to <code>1</code> or <code>true</code> to fix video height taken by controls</li>
|
45 |
<li><code>autoplay</code> <em>(bool)</em> Enable autoplay of first video in YTC video stack by setting this option to <code>1</code> or <code>true</code></li>
|
46 |
<li><code>mute</code> <em>(bool)</em> Set this option to <code>1</code> or <code>true</code> to mute videos set to autoplay on load</li>
|
47 |
<li><code>norel</code> <em>(bool)</em> Set this option to <code>1</code> or <code>true</code> to hire related videos after finished playbak</li>
|
48 |
<li><code>nobrand</code> <em>(bool)</em> Set this option to <code>1</code> or <code>true</code> to hire YouTube logo from playback control bar</li>
|
49 |
</ul>
|
50 |
-
<
|
51 |
<ul>
|
52 |
<li><code>showtitle</code> <em>(bool)</em> </li>
|
53 |
<li><code>showdesc</code> <em>(bool)</em> </li>
|
@@ -55,12 +55,18 @@
|
|
55 |
<li><code>noinfo</code> <em>(bool)</em> </li>
|
56 |
<li><code>noanno</code> <em>(bool)</em> </li>
|
57 |
</ul>
|
58 |
-
<
|
59 |
<ul>
|
60 |
<li><code>goto</code> <em>(bool)</em> </li>
|
61 |
<li><code>goto_txt</code> <em>(string)</em></li>
|
62 |
<li><code>popup</code> <em>(int)</em></li>
|
63 |
-
<li><code>
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
</ul>
|
65 |
|
66 |
<p>Please note, you can exclude all options listed above, and then we'll use default options from Settings page.</p>
|
1 |
+
<h3>How to use shortcode</h3>
|
2 |
+
<p>You can use shortcode <code>[youtube_channel]</code> with options listed below (all options are optional):</p>
|
3 |
+
|
4 |
+
<h4>General Settings</h4>
|
5 |
<ul>
|
|
|
6 |
<li><code>channel</code> <em>(string)</em> ID of preferred YouTube channel. Do not set full URL to channel, but just last part from URL - ID (name)</li>
|
7 |
+
<li><code>vanity</code> <em>(string)</em> Vanity name.</li>
|
8 |
+
<li><code>username</code> <em>(string)</em> Legacy YouTube username.</li>
|
9 |
<li><code>playlist</code> <em>(string)</em> ID of preferred YouTube playlist.</li>
|
10 |
+
<li><code>resource</code> <em>(int)</em> Resource to use for feed:
|
11 |
<ul>
|
12 |
<li>• <code>0</code> Channel</li>
|
13 |
<li>• <code>1</code> Favorites (for defined channel)</li>
|
14 |
<li>• <code>2</code> Playlist</li>
|
15 |
+
<li>• <code>3</code> Liked Videos (for defined channel)</li>
|
16 |
</ul></li>
|
17 |
<li><code>only_pl</code> <em>(bool)</em> If you set to use Playlist as resource, you can embed youtube playlist block instead single video from playlist. Simply set this option to true (<code>1</code> or <code>true</code>)</li>
|
18 |
<li><code>cache</code> <em>(int)</em> Period in seconds for caching feed. You can disable caching by setting this option to <code>0</code>, but if you have a lot of visits, consider at least short caching (couple minutes).</li>
|
20 |
<li><code>fetch</code> <em>(int)</em> Number of videos that will be used as stack for random pick (min 2, max 50)</li>
|
21 |
<li><code>num</code> <em>(int)</em> Number of videos to display per YTC block.</li>
|
22 |
|
|
|
23 |
<li><code>random</code> <em>(bool)</em> Option to randomize videos on every page load.</li>
|
24 |
</ul>
|
25 |
+
<h4>Video Settings</h4>
|
26 |
<ul>
|
27 |
<li><code>ratio</code> <em>(int)</em> Set preferred aspect ratio for thumbnail and video. You can use:
|
28 |
<ul>
|
29 |
+
<li>• <code>3</code> 16:9 widescreen (default)</li>
|
|
|
30 |
<li>• <code>1</code> 4:3</li>
|
31 |
</ul></li>
|
|
|
32 |
<li><code>width</code> <em>(int)</em> Width of thumbnail and video in pixels.</li>
|
33 |
+
<li><code>responsive</code> <em>(bool)</em> Distribute one full width video per row.</li>
|
34 |
+
<li><code>display</code> <em>(string)</em> Object that will be used to represent video. We have couple predefined options:
|
35 |
<ul>
|
36 |
<li>• <code>thumbnail</code> Thumbnail will be used and video will be loaded in lightbox.</li>
|
37 |
<li>• <code>iframe</code> HTML5 (iframe)</li>
|
38 |
<li>• <code>iframe2</code> HTML5 (iframe) with asynchronous loading - recommended</li>
|
|
|
|
|
39 |
</ul></li>
|
40 |
|
41 |
<li><code>no_thumb_title</code> <em>(bool)</em> By default YouTube thumbnail will have tooltip with info about video title and date of publishing. By setting this option to <code>1</code> or <code>true</code> you can hide tooltip</li>
|
42 |
<li><code>themelight</code> <em>(bool)</em> By default YouTube have dark play controls theme. By setting this option to <code>1</code> or <code>true</code> you can get light theme in player (HTML5 and Flash)</li>
|
43 |
+
<li><code>controls</code> <em>(bool)</em> Set this option to <code>1</code> or <code>true</code> to hide playback controls. To display controls set this option to <code>0</code> or <code>false</code>.</li>
|
44 |
<li><code>fix_h</code> <em>(bool)</em> If you did not set to hide player controls, you can set this option to <code>1</code> or <code>true</code> to fix video height taken by controls</li>
|
45 |
<li><code>autoplay</code> <em>(bool)</em> Enable autoplay of first video in YTC video stack by setting this option to <code>1</code> or <code>true</code></li>
|
46 |
<li><code>mute</code> <em>(bool)</em> Set this option to <code>1</code> or <code>true</code> to mute videos set to autoplay on load</li>
|
47 |
<li><code>norel</code> <em>(bool)</em> Set this option to <code>1</code> or <code>true</code> to hire related videos after finished playbak</li>
|
48 |
<li><code>nobrand</code> <em>(bool)</em> Set this option to <code>1</code> or <code>true</code> to hire YouTube logo from playback control bar</li>
|
49 |
</ul>
|
50 |
+
<h4>Content Layout</h4>
|
51 |
<ul>
|
52 |
<li><code>showtitle</code> <em>(bool)</em> </li>
|
53 |
<li><code>showdesc</code> <em>(bool)</em> </li>
|
55 |
<li><code>noinfo</code> <em>(bool)</em> </li>
|
56 |
<li><code>noanno</code> <em>(bool)</em> </li>
|
57 |
</ul>
|
58 |
+
<h4>Link to Channel</h4>
|
59 |
<ul>
|
60 |
<li><code>goto</code> <em>(bool)</em> </li>
|
61 |
<li><code>goto_txt</code> <em>(string)</em></li>
|
62 |
<li><code>popup</code> <em>(int)</em></li>
|
63 |
+
<li><code>link_to</code> <em>(int)</em> URL to link:
|
64 |
+
<ul>
|
65 |
+
<li>• <code>2</code> Vanity custom URL (default)</li>
|
66 |
+
<li>• <code>1</code> Channel page</li>
|
67 |
+
<li>• <code>0</code> Legacy username page</li>
|
68 |
+
</ul>
|
69 |
+
</li>
|
70 |
</ul>
|
71 |
|
72 |
<p>Please note, you can exclude all options listed above, and then we'll use default options from Settings page.</p>
|
@@ -26,127 +26,133 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
26 |
$output[] = implode($WPAU_YOUTUBE_CHANNEL->output($instance));
|
27 |
$output[] = $after_widget;
|
28 |
|
29 |
-
echo implode('',array_values($output));
|
30 |
}
|
31 |
|
32 |
public function form($instance) {
|
33 |
global $WPAU_YOUTUBE_CHANNEL;
|
|
|
|
|
34 |
// outputs the options form for widget settings
|
35 |
// General Options
|
36 |
-
$title
|
37 |
-
$class
|
38 |
-
$
|
39 |
-
$
|
|
|
|
|
40 |
|
41 |
-
$
|
42 |
-
$only_pl
|
43 |
|
44 |
-
$
|
45 |
|
46 |
-
$
|
47 |
-
$
|
48 |
|
49 |
-
$
|
50 |
-
$
|
51 |
-
$getrnd = (!empty($instance['getrnd'])) ? esc_attr($instance['getrnd']) : '';
|
52 |
|
53 |
// Video Settings
|
54 |
-
$ratio
|
55 |
-
$width
|
56 |
-
$responsive
|
57 |
-
|
58 |
-
$
|
59 |
-
$no_thumb_title
|
60 |
-
|
61 |
-
$
|
62 |
-
$
|
63 |
-
$autoplay
|
64 |
-
$autoplay_mute
|
65 |
-
$norel
|
66 |
|
67 |
// Content Layout
|
68 |
-
$showtitle
|
69 |
-
$
|
70 |
-
$modestbranding
|
71 |
-
$
|
72 |
-
$descappend
|
73 |
|
74 |
-
$hideanno
|
75 |
-
$hideinfo
|
76 |
|
77 |
// Link to Channel
|
78 |
-
$goto_txt
|
79 |
-
$showgoto
|
80 |
-
$popup_goto
|
81 |
-
$
|
82 |
-
|
83 |
-
// Debug YTC
|
84 |
-
$debugon = (!empty($instance['debugon'])) ? esc_attr($instance['debugon']) : '';
|
85 |
?>
|
86 |
|
87 |
<p>
|
88 |
-
<label for="<?php echo $this->get_field_id('title');
|
|
|
|
|
89 |
</p>
|
90 |
<p>
|
91 |
-
<label for="<?php echo $this->get_field_id('class');
|
|
|
|
|
92 |
</p>
|
93 |
-
<p>
|
94 |
-
|
|
|
|
|
|
|
95 |
</p>
|
96 |
-
<p>
|
97 |
-
<label for="<?php echo $this->get_field_id('
|
|
|
|
|
98 |
</p>
|
99 |
-
<p>
|
100 |
-
<label for="<?php echo $this->get_field_id('
|
101 |
-
<
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
</select>
|
106 |
-
<br />
|
107 |
-
<label style="display: none" for="<?php echo $this->get_field_id( 'only_pl' ); ?>" id="<?php echo $this->get_field_id( 'only_pl' ); ?>_label"><input class="checkbox" type="checkbox" <?php checked( (bool) $only_pl, true ); ?> id="<?php echo $this->get_field_id( 'only_pl' ); ?>" name="<?php echo $this->get_field_name( 'only_pl' ); ?>" title="<?php _e('Enable this option to embed YouTube playlist instead single video from playlist.', 'youtube-channel'); ?>" /> <?php _e('Embed standard playlist<br /><small>(Please note <em>What to show?</em> have no effect for embedded playlist)</small>', 'youtube-channel'); ?></label>
|
108 |
</p>
|
109 |
-
|
110 |
-
<
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
toggle_<?php echo $onlypl_js_fn; ?>($(this));
|
115 |
-
});
|
116 |
-
function toggle_<?php echo $onlypl_js_fn; ?>(d) {
|
117 |
-
if ( d.find(':selected')[0].value == 2 ) {
|
118 |
-
$('#<?php echo $this->get_field_id( 'only_pl' ); ?>_label').fadeIn();
|
119 |
-
} else {
|
120 |
-
$('#<?php echo $this->get_field_id( 'only_pl' ); ?>_label').fadeOut();
|
121 |
-
}
|
122 |
-
}
|
123 |
-
});
|
124 |
-
</script>
|
125 |
-
<p>
|
126 |
-
<label for="<?php echo $this->get_field_id('cache_time'); ?>"><?php _e('Cache feed', 'youtube-channel'); ?>:</label>
|
127 |
-
<select class="widefat" id="<?php echo $this->get_field_id( 'cache_time' ); ?>" name="<?php echo $this->get_field_name( 'cache_time' ); ?>">
|
128 |
-
<option value="0"<?php selected( $cache_time, 0 ); ?>><?php _e('Do not cache', 'youtube-channel'); ?></option>
|
129 |
-
<?php echo $WPAU_YOUTUBE_CHANNEL->cache_time($cache_time); ?>
|
130 |
</select>
|
131 |
</p>
|
132 |
-
|
133 |
-
|
134 |
-
<br
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
</p>
|
137 |
<p>
|
138 |
-
<input class="checkbox" type="checkbox" <?php checked( (bool) $
|
139 |
<br />
|
140 |
-
<input class="checkbox" type="checkbox" <?php checked( (bool) $
|
141 |
-
<br />
|
142 |
-
<input class="checkbox" type="checkbox" <?php checked( (bool) $getrnd, true ); ?> id="<?php echo $this->get_field_id( 'getrnd' ); ?>" name="<?php echo $this->get_field_name( 'getrnd' ); ?>" title="<?php _e('Get random videos of all fetched from channel or playlist', 'youtube-channel'); ?>" /> <label for="<?php echo $this->get_field_id( 'getrnd' ); ?>"><?php _e('Show random video', 'youtube-channel'); ?></label>
|
143 |
</p>
|
144 |
|
145 |
<h4><?php _e('Video Settings', 'youtube-channel'); ?></h4>
|
146 |
<p><label for="<?php echo $this->get_field_id('ratio'); ?>"><?php _e('Aspect ratio', 'youtube-channel'); ?>:</label>
|
147 |
<select class="widefat" id="<?php echo $this->get_field_id( 'ratio' ); ?>" name="<?php echo $this->get_field_name( 'ratio' ); ?>">
|
148 |
<option value="3"<?php selected( $ratio, 3 ); ?>>16:9</option>
|
149 |
-
<option value="2"<?php selected( $ratio, 2 ); ?>>16:10</option>
|
150 |
<option value="1"<?php selected( $ratio, 1 ); ?>>4:3</option>
|
151 |
</select><br />
|
152 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $responsive, true ); ?> id="<?php echo $this->get_field_id( 'responsive' ); ?>" name="<?php echo $this->get_field_name( 'responsive' ); ?>" /> <label for="<?php echo $this->get_field_id( 'responsive' ); ?>"><?php _e('Responsive video (distribute one full width video per row)', 'youtube-channel'); ?></label>
|
@@ -155,18 +161,15 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
155 |
<label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width', 'youtube-channel'); ?>:</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; ?>" title="<?php _e('Set video width in pixels', 'youtube-channel'); ?>" /> px (<?php _e('default', 'youtube-channel'); ?> 306)
|
156 |
</p>
|
157 |
<p>
|
158 |
-
<label for="<?php echo $this->get_field_id('
|
159 |
-
<select class="widefat" id="<?php echo $this->get_field_id( '
|
160 |
-
<option value="thumbnail"<?php selected( $
|
161 |
-
<option value="
|
162 |
-
<option value="
|
163 |
-
<option value="iframe2"<?php selected( $to_show, 'iframe2' ); ?>><?php _e('HTML5 (iframe) Async', 'youtube-channel'); ?></option>
|
164 |
-
<option value="chromeless"<?php selected( $to_show, 'chromeless' ); ?>><?php _e('Chromeless', 'youtube-channel'); ?></option>
|
165 |
</select>
|
166 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $no_thumb_title, true ); ?> id="<?php echo $this->get_field_id( 'no_thumb_title' ); ?>" name="<?php echo $this->get_field_name( 'no_thumb_title' ); ?>" /> <label for="<?php echo $this->get_field_id( 'no_thumb_title' ); ?>"><?php _e('Hide thumbnail tooltip', 'youtube-channel'); ?></label><br />
|
167 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
|
168 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
|
169 |
-
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
|
170 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 or playlist', 'youtube-channel'); ?></label><br />
|
171 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $autoplay_mute, true ); ?> id="<?php echo $this->get_field_id( 'autoplay_mute' ); ?>" name="<?php echo $this->get_field_name( 'autoplay_mute' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay_mute' ); ?>"><?php _e('Mute video on autoplay', 'youtube-channel'); ?></label><br />
|
172 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $norel, true ); ?> id="<?php echo $this->get_field_id( 'norel' ); ?>" name="<?php echo $this->get_field_name( 'norel' ); ?>" /> <label for="<?php echo $this->get_field_id( 'norel' ); ?>"><?php _e('Hide related videos', 'youtube-channel'); ?></label><br />
|
@@ -176,8 +179,8 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
176 |
<h4><?php _e('Content Layout', 'youtube-channel'); ?></h4>
|
177 |
<p>
|
178 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
|
179 |
-
<input class="checkbox" type="checkbox" <?php checked( (bool) $
|
180 |
-
<label for="<?php echo $this->get_field_id('
|
181 |
<label for="<?php echo $this->get_field_id('descappend'); ?>"><?php _e('Et cetera string', 'youtube-channel'); ?> <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; ?>" title="<?php _e('Default: &hellip;', 'youtube-channel'); ?>"/></label><br />
|
182 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
|
183 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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>
|
@@ -185,16 +188,24 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
185 |
|
186 |
<h4><?php _e('Link to Channel', 'youtube-channel'); ?></h4>
|
187 |
<p>
|
188 |
-
<
|
189 |
-
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
<select class="widefat" id="<?php echo $this->get_field_id( 'popup_goto' ); ?>" name="<?php echo $this->get_field_name( 'popup_goto' ); ?>">
|
192 |
-
<option value="0"<?php selected( $popup_goto, 0 ); ?>><?php _e('in same window', 'youtube-channel'); ?></option>
|
193 |
-
<option value="1"<?php selected( $popup_goto, 1 ); ?>><?php _e('in new window (JavaScript)', 'youtube-channel'); ?></option>
|
194 |
-
<option value="2"<?php selected( $popup_goto, 2 ); ?>><?php _e('in new window (
|
195 |
</select>
|
196 |
-
|
197 |
-
<input class="checkbox" type="checkbox" <?php checked( (bool) $userchan, true ); ?> id="<?php echo $this->get_field_id( 'userchan' ); ?>" name="<?php echo $this->get_field_name( 'userchan' ); ?>" /> <label for="<?php echo $this->get_field_id( 'userchan' ); ?>"><?php _e('Link to channel instead to user', 'youtube-channel'); ?></label><br />
|
198 |
</p>
|
199 |
|
200 |
<h4><?php _e('Does not work? Contact support!', 'youtube-channel'); ?></h4>
|
@@ -206,64 +217,54 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
206 |
|
207 |
public function update($new_instance, $old_instance) {
|
208 |
// processes widget options to be saved
|
209 |
-
$instance
|
210 |
-
$instance['title']
|
211 |
-
$instance['class']
|
212 |
-
$instance['channel']
|
213 |
-
$instance['
|
214 |
-
$instance['playlist']
|
215 |
-
$instance['
|
216 |
-
$instance['
|
217 |
-
$instance['
|
218 |
-
$instance['
|
219 |
-
$instance['
|
220 |
-
|
221 |
-
$instance['
|
222 |
-
|
223 |
-
$instance['
|
224 |
-
|
225 |
-
$instance['
|
226 |
-
$instance['
|
227 |
-
|
228 |
-
$instance['
|
229 |
-
$instance['
|
230 |
-
$instance['
|
231 |
-
|
232 |
-
$instance['
|
|
|
|
|
|
|
233 |
$instance['no_thumb_title'] = (isset($new_instance['no_thumb_title'])) ? $new_instance['no_thumb_title'] : false;
|
234 |
-
$instance['autoplay']
|
235 |
-
$instance['autoplay_mute']
|
236 |
-
$instance['norel']
|
237 |
-
$instance['modestbranding']= (isset($new_instance['modestbranding'])) ? $new_instance['modestbranding'] : false;
|
238 |
-
|
239 |
-
$instance['controls']
|
240 |
-
$instance['
|
241 |
-
$instance['
|
242 |
-
$instance['
|
243 |
-
$instance['
|
244 |
-
$instance['
|
245 |
-
$instance['themelight'] = (isset($new_instance['themelight'])) ? $new_instance['themelight'] : '';
|
246 |
-
$instance['debugon'] = (isset($new_instance['debugon'])) ? $new_instance['debugon'] : '';
|
247 |
-
$instance['userchan'] = (isset($new_instance['userchan'])) ? $new_instance['userchan'] : '';
|
248 |
-
$instance['enhprivacy'] = (isset($new_instance['enhprivacy'])) ? $new_instance['enhprivacy'] : '';
|
249 |
|
250 |
return $instance;
|
251 |
}
|
252 |
|
253 |
-
function debug_string($arr) {
|
254 |
-
$out = '';
|
255 |
-
foreach ( $arr as $key => $val ) {
|
256 |
-
if ( empty($val) ) { $val = 'null'; }
|
257 |
-
$out .= $key . ': ' . $val . chr(13);
|
258 |
-
}
|
259 |
-
return $out;
|
260 |
-
}
|
261 |
-
|
262 |
} // end class WPAU_YOUTUBE_CHANNEL_Widget()
|
263 |
|
264 |
|
265 |
// register Foo_Widget widget
|
266 |
function wpau_register_youtube_channel_widget() {
|
267 |
-
|
268 |
}
|
269 |
add_action( 'widgets_init', 'wpau_register_youtube_channel_widget' );
|
26 |
$output[] = implode($WPAU_YOUTUBE_CHANNEL->output($instance));
|
27 |
$output[] = $after_widget;
|
28 |
|
29 |
+
echo implode('', array_values($output));
|
30 |
}
|
31 |
|
32 |
public function form($instance) {
|
33 |
global $WPAU_YOUTUBE_CHANNEL;
|
34 |
+
$defaults = get_option('youtube_channel_defaults');
|
35 |
+
|
36 |
// outputs the options form for widget settings
|
37 |
// General Options
|
38 |
+
$title = (!empty($instance['title'])) ? esc_attr($instance['title']) : '';
|
39 |
+
$class = (!empty($instance['class'])) ? esc_attr($instance['class']) : '';
|
40 |
+
$vanity = ( ! empty($instance['vanity']) ) ? esc_attr($instance['vanity']) : trim($defaults['vanity']);
|
41 |
+
$channel = (!empty($instance['channel'])) ? esc_attr($instance['channel']) : trim($defaults['channel']);
|
42 |
+
$username = (!empty($instance['username'])) ? esc_attr($instance['username']) : trim($defaults['username']);
|
43 |
+
$playlist = (!empty($instance['playlist'])) ? esc_attr($instance['playlist']) : trim($defaults['playlist']);
|
44 |
|
45 |
+
$resource = (!empty($instance['resource'])) ? esc_attr($instance['resource']) : 0; // resource to use: channel, favorites, playlist
|
46 |
+
$only_pl = (!empty($instance['only_pl'])) ? esc_attr($instance['only_pl']) : '';
|
47 |
|
48 |
+
$cache = (!empty($instance['cache'])) ? esc_attr($instance['cache']) : trim($defaults['cache']);
|
49 |
|
50 |
+
$fetch = (!empty($instance['fetch'])) ? esc_attr($instance['fetch']) : trim($defaults['fetch']); // items to fetch
|
51 |
+
$num = (!empty($instance['num'])) ? esc_attr($instance['num']) : trim($defaults['num']); // number of items to show
|
52 |
|
53 |
+
$privacy = (!empty($instance['privacy'])) ? esc_attr($instance['privacy']) : 0;
|
54 |
+
$random = (!empty($instance['random'])) ? esc_attr($instance['random']) : 0;
|
|
|
55 |
|
56 |
// Video Settings
|
57 |
+
$ratio = (!empty($instance['ratio'])) ? esc_attr($instance['ratio']) : trim($defaults['ratio']);
|
58 |
+
$width = (!empty($instance['width'])) ? esc_attr($instance['width']) : trim($defaults['width']);
|
59 |
+
$responsive = (!empty($instance['responsive'])) ? esc_attr($instance['responsive']) : 0;
|
60 |
+
|
61 |
+
$display = (!empty($instance['display'])) ? esc_attr($instance['display']) : trim($defaults['display']);
|
62 |
+
$no_thumb_title = (!empty($instance['no_thumb_title'])) ? esc_attr($instance['no_thumb_title']) : 0;
|
63 |
+
|
64 |
+
$themelight = (!empty($instance['themelight'])) ? esc_attr($instance['themelight']) : '';
|
65 |
+
$controls = (!empty($instance['controls'])) ? esc_attr($instance['controls']) : '';
|
66 |
+
$autoplay = (!empty($instance['autoplay'])) ? esc_attr($instance['autoplay']) : '';
|
67 |
+
$autoplay_mute = (!empty($instance['autoplay_mute'])) ? esc_attr($instance['autoplay_mute']) : '';
|
68 |
+
$norel = (!empty($instance['norel'])) ? esc_attr($instance['norel']) : '';
|
69 |
|
70 |
// Content Layout
|
71 |
+
$showtitle = (!empty($instance['showtitle'])) ? esc_attr($instance['showtitle']) : '';
|
72 |
+
$showdesc = (!empty($instance['showdesc'])) ? esc_attr($instance['showdesc']) : '';
|
73 |
+
$modestbranding = (!empty($instance['modestbranding'])) ? esc_attr($instance['modestbranding']) : '';
|
74 |
+
$desclen = (!empty($instance['desclen'])) ? esc_attr($instance['desclen']) : 0;
|
75 |
+
$descappend = (!empty($instance['descappend'])) ? esc_attr($instance['descappend']) : '…';
|
76 |
|
77 |
+
$hideanno = (!empty($instance['hideanno'])) ? esc_attr($instance['hideanno']) : '';
|
78 |
+
$hideinfo = (!empty($instance['hideinfo'])) ? esc_attr($instance['hideinfo']) : '';
|
79 |
|
80 |
// Link to Channel
|
81 |
+
$goto_txt = (!empty($instance['goto_txt'])) ? esc_attr($instance['goto_txt']) : '';
|
82 |
+
$showgoto = (!empty($instance['showgoto'])) ? esc_attr($instance['showgoto']) : '';
|
83 |
+
$popup_goto = (!empty($instance['popup_goto'])) ? esc_attr($instance['popup_goto']) : '';
|
84 |
+
$link_to = (!empty($instance['link_to'])) ? esc_attr($instance['link_to']) : '';
|
|
|
|
|
|
|
85 |
?>
|
86 |
|
87 |
<p>
|
88 |
+
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title', 'youtube-channel'); ?>:
|
89 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" title="<?php _e('Title for widget', 'youtube-channel'); ?>" />
|
90 |
+
</label>
|
91 |
</p>
|
92 |
<p>
|
93 |
+
<label for="<?php echo $this->get_field_id('class'); ?>"><?php _e('Custom CSS Class', 'youtube-channel'); ?>:
|
94 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id('class'); ?>" name="<?php echo $this->get_field_name('class'); ?>" value="<?php echo $class; ?>" title="<?php _e('Enter custom class for YTC block, if you wish to target block styling', 'youtube-channel'); ?>" />
|
95 |
+
</label>
|
96 |
</p>
|
97 |
+
<p>Get your Channel ID and Custom ID from <a href="https://www.youtube.com/account_advanced" target="_blank">here</a>.</p>
|
98 |
+
<p class="half left glue-top">
|
99 |
+
<label for="<?php echo $this->get_field_id('vanity'); ?>"><?php _e('Vanity/Custom ID', 'youtube-channel'); ?>:
|
100 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id('vanity'); ?>" name="<?php echo $this->get_field_name('vanity'); ?>" value="<?php echo $vanity; ?>" title="<?php _e('YouTube Vanity/Custom ID from URL (part after /c/)', 'youtube-channel'); ?>" />
|
101 |
+
</label>
|
102 |
</p>
|
103 |
+
<p class="half right glue-top">
|
104 |
+
<label for="<?php echo $this->get_field_id('channel'); ?>"><?php _e('Channel ID', 'youtube-channel'); ?>:
|
105 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id('channel'); ?>" name="<?php echo $this->get_field_name('channel'); ?>" value="<?php echo $channel; ?>" title="<?php _e('Find Channel ID behind My Channel menu item in YouTube (ID have UC at the beginning)', 'youtube-channel'); ?>" />
|
106 |
+
</label>
|
107 |
</p>
|
108 |
+
<p class="half left glue-top">
|
109 |
+
<label for="<?php echo $this->get_field_id('username'); ?>"><?php _e('Legacy Username', 'youtube-channel'); ?>:
|
110 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id('username'); ?>" name="<?php echo $this->get_field_name('username'); ?>" value="<?php echo $username; ?>" title="<?php _e('Legacy YouTube username located behind /user/ part of channel URL (available only on old YouTube accounts)', 'youtube-channel'); ?>" />
|
111 |
+
</label>
|
112 |
+
</p>
|
113 |
+
<p class="half right glue-top">
|
114 |
+
<label for="<?php echo $this->get_field_id('playlist'); ?>"><?php _e('Playlist ID', 'youtube-channel'); ?>:
|
115 |
+
<input type="text" class="widefat" id="<?php echo $this->get_field_id('playlist'); ?>" name="<?php echo $this->get_field_name('playlist'); ?>" value="<?php echo $playlist; ?>" title="<?php _e('Find Playlist ID in your playlists (ID have PL at the beginning)', 'youtube-channel'); ?>" />
|
116 |
+
</label>
|
117 |
+
</p>
|
118 |
+
<p class="half left glue-top">
|
119 |
+
<label for="<?php echo $this->get_field_id('resource'); ?>"><?php _e('Resource to use', 'youtube-channel'); ?>:</label>
|
120 |
+
<select class="widefat" id="<?php echo $this->get_field_id( 'resource' ); ?>" name="<?php echo $this->get_field_name( 'resource' ); ?>">
|
121 |
+
<option value="0"<?php selected( $resource, 0 ); ?>><?php _e('Channel', 'youtube-channel'); ?></option>
|
122 |
+
<option value="1"<?php selected( $resource, 1 ); ?>><?php _e('Favourites', 'youtube-channel'); ?></option>
|
123 |
+
<option value="3"<?php selected( $resource, 3 ); ?>><?php _e('Liked Videos', 'youtube-channel'); ?></option>
|
124 |
+
<option value="2"<?php selected( $resource, 2 ); ?>><?php _e('Playlist', 'youtube-channel'); ?></option>
|
125 |
</select>
|
|
|
|
|
126 |
</p>
|
127 |
+
<p class="half right glue-top">
|
128 |
+
<label for="<?php echo $this->get_field_id('cache'); ?>"><?php _e('Cache feed', 'youtube-channel'); ?>:</label>
|
129 |
+
<select class="widefat" id="<?php echo $this->get_field_id( 'cache' ); ?>" name="<?php echo $this->get_field_name( 'cache' ); ?>">
|
130 |
+
<option value="0"<?php selected( $cache, 0 ); ?>><?php _e('Do not cache', 'youtube-channel'); ?></option>
|
131 |
+
<?php echo $WPAU_YOUTUBE_CHANNEL->cache_time($cache); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
</select>
|
133 |
</p>
|
134 |
+
|
135 |
+
<p class="playlist-only <?php echo $this->get_field_id('resource'); ?> glue-top">
|
136 |
+
<label for="<?php echo $this->get_field_id( 'only_pl' ); ?>" id="<?php echo $this->get_field_id( 'only_pl' ); ?>_label"><input class="checkbox" type="checkbox" <?php checked( (bool) $only_pl, true ); ?> id="<?php echo $this->get_field_id( 'only_pl' ); ?>" name="<?php echo $this->get_field_name( 'only_pl' ); ?>" title="<?php _e('Enable this option to embed YouTube playlist instead single video from playlist.', 'youtube-channel'); ?>" /> <?php _e('Embed standard playlist<br /><small>(Please note <em>What to show?</em> have no effect for embedded playlist)</small>', 'youtube-channel'); ?></label>
|
137 |
+
</p>
|
138 |
+
|
139 |
+
<p class="half left glue-top">
|
140 |
+
<label for="<?php echo $this->get_field_id('fetch'); ?>"><?php _e('Fetch', 'youtube-channel'); ?>: <input class="small-text" id="<?php echo $this->get_field_id('fetch'); ?>" name="<?php echo $this->get_field_name('fetch'); ?>" type="number" min="2" value="<?php echo $fetch; ?>" title="<?php _e('Number of videos that will be used for random pick (min 2, max 50, default 25)', 'youtube-channel'); ?>" /> <?php _e('video(s)', 'youtube-channel'); ?></label>
|
141 |
+
</p>
|
142 |
+
<p class="half right glue-top">
|
143 |
+
<label for="<?php echo $this->get_field_id('num'); ?>"><?php _e('Show', 'youtube-channel'); ?>:</label> <input class="small-text" id="<?php echo $this->get_field_id('num'); ?>" name="<?php echo $this->get_field_name('num'); ?>" type="number" min="1" value="<?php echo ( $num ) ? $num : '1'; ?>" title="<?php _e('Number of videos to display', 'youtube-channel'); ?>" /> <?php _e('video(s)', 'youtube-channel'); ?>
|
144 |
</p>
|
145 |
<p>
|
146 |
+
<input class="checkbox" type="checkbox" <?php checked( (bool) $privacy, true ); ?> id="<?php echo $this->get_field_id( 'privacy' ); ?>" name="<?php echo $this->get_field_name( 'privacy' ); ?>" title="<?php _e('Enable this option to protect your visitors privacy', 'youtube-channel'); ?>" /> <label for="<?php echo $this->get_field_id( 'privacy' ); ?>"><?php printf(__('Use <a href="%s" target="_blank">Enhanced Privacy</a>', 'youtube-channel'), 'http://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780'); ?></label>
|
147 |
<br />
|
148 |
+
<input class="checkbox" type="checkbox" <?php checked( (bool) $random, true ); ?> id="<?php echo $this->get_field_id( 'random' ); ?>" name="<?php echo $this->get_field_name( 'random' ); ?>" title="<?php _e('Get random videos of all fetched from channel or playlist', 'youtube-channel'); ?>" /> <label for="<?php echo $this->get_field_id( 'random' ); ?>"><?php _e('Show random video', 'youtube-channel'); ?></label>
|
|
|
|
|
149 |
</p>
|
150 |
|
151 |
<h4><?php _e('Video Settings', 'youtube-channel'); ?></h4>
|
152 |
<p><label for="<?php echo $this->get_field_id('ratio'); ?>"><?php _e('Aspect ratio', 'youtube-channel'); ?>:</label>
|
153 |
<select class="widefat" id="<?php echo $this->get_field_id( 'ratio' ); ?>" name="<?php echo $this->get_field_name( 'ratio' ); ?>">
|
154 |
<option value="3"<?php selected( $ratio, 3 ); ?>>16:9</option>
|
155 |
+
<?php /* <option value="2"<?php selected( $ratio, 2 ); ?>>16:10</option> */ ?>
|
156 |
<option value="1"<?php selected( $ratio, 1 ); ?>>4:3</option>
|
157 |
</select><br />
|
158 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $responsive, true ); ?> id="<?php echo $this->get_field_id( 'responsive' ); ?>" name="<?php echo $this->get_field_name( 'responsive' ); ?>" /> <label for="<?php echo $this->get_field_id( 'responsive' ); ?>"><?php _e('Responsive video (distribute one full width video per row)', 'youtube-channel'); ?></label>
|
161 |
<label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Width', 'youtube-channel'); ?>:</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; ?>" title="<?php _e('Set video width in pixels', 'youtube-channel'); ?>" /> px (<?php _e('default', 'youtube-channel'); ?> 306)
|
162 |
</p>
|
163 |
<p>
|
164 |
+
<label for="<?php echo $this->get_field_id('display'); ?>"><?php _e('What to show?', 'youtube-channel'); ?></label>
|
165 |
+
<select class="widefat" id="<?php echo $this->get_field_id( 'display' ); ?>" name="<?php echo $this->get_field_name( 'display' ); ?>">
|
166 |
+
<option value="thumbnail"<?php selected( $display, 'thumbnail' ); ?>><?php _e('Thumbnail', 'youtube-channel'); ?></option>
|
167 |
+
<option value="iframe"<?php selected( $display, 'iframe' ); ?>><?php _e('HTML5 (iframe)', 'youtube-channel'); ?></option>
|
168 |
+
<option value="iframe2"<?php selected( $display, 'iframe2' ); ?>><?php _e('HTML5 (iframe) Asynchronous', 'youtube-channel'); ?></option>
|
|
|
|
|
169 |
</select>
|
170 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $no_thumb_title, true ); ?> id="<?php echo $this->get_field_id( 'no_thumb_title' ); ?>" name="<?php echo $this->get_field_name( 'no_thumb_title' ); ?>" /> <label for="<?php echo $this->get_field_id( 'no_thumb_title' ); ?>"><?php _e('Hide thumbnail tooltip', 'youtube-channel'); ?></label><br />
|
171 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
|
172 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
|
|
|
173 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 or playlist', 'youtube-channel'); ?></label><br />
|
174 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $autoplay_mute, true ); ?> id="<?php echo $this->get_field_id( 'autoplay_mute' ); ?>" name="<?php echo $this->get_field_name( 'autoplay_mute' ); ?>" /> <label for="<?php echo $this->get_field_id( 'autoplay_mute' ); ?>"><?php _e('Mute video on autoplay', 'youtube-channel'); ?></label><br />
|
175 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $norel, true ); ?> id="<?php echo $this->get_field_id( 'norel' ); ?>" name="<?php echo $this->get_field_name( 'norel' ); ?>" /> <label for="<?php echo $this->get_field_id( 'norel' ); ?>"><?php _e('Hide related videos', 'youtube-channel'); ?></label><br />
|
179 |
<h4><?php _e('Content Layout', 'youtube-channel'); ?></h4>
|
180 |
<p>
|
181 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
|
182 |
+
<input class="checkbox" type="checkbox" <?php checked( (bool) $showdesc, true ); ?> id="<?php echo $this->get_field_id( 'showdesc' ); ?>" name="<?php echo $this->get_field_name( 'showdesc' ); ?>" /> <label for="<?php echo $this->get_field_id( 'showdesc' ); ?>"><?php _e('Show video description', 'youtube-channel'); ?></label><br />
|
183 |
+
<label for="<?php echo $this->get_field_id('desclen'); ?>"><?php _e('Description length', 'youtube-channel'); ?>: <input class="small-text" id="<?php echo $this->get_field_id('desclen'); ?>" name="<?php echo $this->get_field_name('desclen'); ?>" type="number" value="<?php echo $desclen; ?>" title="<?php _e('Set number of characters to cut down video description to (0 means full length)', 'youtube-channel');?>" /> (0 = full)</label><br />
|
184 |
<label for="<?php echo $this->get_field_id('descappend'); ?>"><?php _e('Et cetera string', 'youtube-channel'); ?> <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; ?>" title="<?php _e('Default: &hellip;', 'youtube-channel'); ?>"/></label><br />
|
185 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 />
|
186 |
<input class="checkbox" type="checkbox" <?php checked( (bool) $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>
|
188 |
|
189 |
<h4><?php _e('Link to Channel', 'youtube-channel'); ?></h4>
|
190 |
<p>
|
191 |
+
<input class="checkbox" type="checkbox" <?php checked( (bool) $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 below videos', 'youtube-channel'); ?></label>
|
192 |
+
</p>
|
193 |
+
<p class="glue-top <?php echo $this->get_field_id('showgoto'); ?>">
|
194 |
+
<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; ?>" title="<?php _e('Default: Visit our YouTube channel. You can use placeholders %vanity%, %channel% and %username%.', 'youtube-channel'); ?>" placeholder="<?php _e('Visit our YouTube channel', 'youtube-channel'); ?>" />
|
195 |
+
</p>
|
196 |
+
<p class="half left glue-top <?php echo $this->get_field_id( 'showgoto' ); ?>">
|
197 |
+
<select class="widefat" id="<?php echo $this->get_field_id( 'link_to' ); ?>" name="<?php echo $this->get_field_name( 'link_to' ); ?>">
|
198 |
+
<option value="2"<?php selected( $link_to, 2 ); ?>><?php _e('Link to Vanity customized URL', 'youtube-channel'); ?></option>
|
199 |
+
<option value="1"<?php selected( $link_to, 1 ); ?>><?php _e('Link to Channel page URL', 'youtube-channel'); ?></option>
|
200 |
+
<option value="0"<?php selected( $link_to, 0 ); ?>><?php _e('Link to Legacy username page', 'youtube-channel'); ?></option>
|
201 |
+
</select>
|
202 |
+
</p>
|
203 |
+
<p class="half right glue-top <?php echo $this->get_field_id( 'showgoto' ); ?>">
|
204 |
<select class="widefat" id="<?php echo $this->get_field_id( 'popup_goto' ); ?>" name="<?php echo $this->get_field_name( 'popup_goto' ); ?>">
|
205 |
+
<option value="0"<?php selected( $popup_goto, 0 ); ?>><?php _e('Open link in same window', 'youtube-channel'); ?></option>
|
206 |
+
<option value="1"<?php selected( $popup_goto, 1 ); ?>><?php _e('Open link in new window (JavaScript)', 'youtube-channel'); ?></option>
|
207 |
+
<option value="2"<?php selected( $popup_goto, 2 ); ?>><?php _e('Open link in new window (target="blank")', 'youtube-channel'); ?></option>
|
208 |
</select>
|
|
|
|
|
209 |
</p>
|
210 |
|
211 |
<h4><?php _e('Does not work? Contact support!', 'youtube-channel'); ?></h4>
|
217 |
|
218 |
public function update($new_instance, $old_instance) {
|
219 |
// processes widget options to be saved
|
220 |
+
$instance = $old_instance;
|
221 |
+
$instance['title'] = strip_tags($new_instance['title']);
|
222 |
+
$instance['class'] = strip_tags($new_instance['class']);
|
223 |
+
$instance['channel'] = strip_tags($new_instance['channel']);
|
224 |
+
$instance['username'] = strip_tags($new_instance['username']);
|
225 |
+
$instance['playlist'] = strip_tags($new_instance['playlist']);
|
226 |
+
$instance['vanity'] = strip_tags($new_instance['vanity']);
|
227 |
+
$instance['num'] = $new_instance['num'];
|
228 |
+
$instance['resource'] = $new_instance['resource'];
|
229 |
+
$instance['cache'] = $new_instance['cache'];
|
230 |
+
$instance['only_pl'] = (isset($new_instance['only_pl'])) ? $new_instance['only_pl'] : false;
|
231 |
+
$instance['random'] = (isset($new_instance['random'])) ? $new_instance['random'] : false;
|
232 |
+
$instance['fetch'] = $new_instance['fetch'];
|
233 |
+
|
234 |
+
$instance['showgoto'] = (isset($new_instance['showgoto'])) ? $new_instance['showgoto'] : false;
|
235 |
+
$instance['goto_txt'] = strip_tags($new_instance['goto_txt']);
|
236 |
+
$instance['popup_goto'] = $new_instance['popup_goto'];
|
237 |
+
$instance['link_to'] = $new_instance['link_to'];
|
238 |
+
|
239 |
+
$instance['showtitle'] = (isset($new_instance['showtitle'])) ? $new_instance['showtitle'] : false;
|
240 |
+
$instance['showdesc'] = (isset($new_instance['showdesc'])) ? $new_instance['showdesc'] : false;
|
241 |
+
$instance['descappend'] = strip_tags($new_instance['descappend']);
|
242 |
+
$instance['desclen'] = strip_tags($new_instance['desclen']);
|
243 |
+
$instance['width'] = strip_tags($new_instance['width']);
|
244 |
+
$instance['responsive'] = (isset($new_instance['responsive'])) ? $new_instance['responsive'] : '';
|
245 |
+
|
246 |
+
$instance['display'] = strip_tags($new_instance['display']);
|
247 |
$instance['no_thumb_title'] = (isset($new_instance['no_thumb_title'])) ? $new_instance['no_thumb_title'] : false;
|
248 |
+
$instance['autoplay'] = (isset($new_instance['autoplay'])) ? $new_instance['autoplay'] : false;
|
249 |
+
$instance['autoplay_mute'] = (isset($new_instance['autoplay_mute'])) ? $new_instance['autoplay_mute'] : false;
|
250 |
+
$instance['norel'] = (isset($new_instance['norel'])) ? $new_instance['norel'] : false;
|
251 |
+
$instance['modestbranding'] = (isset($new_instance['modestbranding'])) ? $new_instance['modestbranding'] : false;
|
252 |
+
|
253 |
+
$instance['controls'] = (isset($new_instance['controls'])) ? $new_instance['controls'] : false;
|
254 |
+
$instance['ratio'] = strip_tags($new_instance['ratio']);
|
255 |
+
$instance['hideinfo'] = (isset($new_instance['hideinfo'])) ? $new_instance['hideinfo'] : '';
|
256 |
+
$instance['hideanno'] = (isset($new_instance['hideanno'])) ? $new_instance['hideanno'] : '';
|
257 |
+
$instance['themelight'] = (isset($new_instance['themelight'])) ? $new_instance['themelight'] : '';
|
258 |
+
$instance['privacy'] = (isset($new_instance['privacy'])) ? $new_instance['privacy'] : '';
|
|
|
|
|
|
|
|
|
259 |
|
260 |
return $instance;
|
261 |
}
|
262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
} // end class WPAU_YOUTUBE_CHANNEL_Widget()
|
264 |
|
265 |
|
266 |
// register Foo_Widget widget
|
267 |
function wpau_register_youtube_channel_widget() {
|
268 |
+
register_widget( 'WPAU_YOUTUBE_CHANNEL_Widget' );
|
269 |
}
|
270 |
add_action( 'widgets_init', 'wpau_register_youtube_channel_widget' );
|
@@ -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, responsive
|
5 |
Requires at least: 3.9.0
|
6 |
-
Tested up to: 4.2
|
7 |
-
Stable tag:
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -19,7 +19,6 @@ Simply insert widget to sidebar, set channel name and if you wish leave all othe
|
|
19 |
If you like this extension and you find it useful, please rate it on the right side.
|
20 |
|
21 |
= Features =
|
22 |
-
|
23 |
* Display latest videos from YouTube channel, favorites or playlist
|
24 |
* Option to get random video from resources mentioned above
|
25 |
* Responsive (one full width video per row) or non responsive (video wall)
|
@@ -35,10 +34,9 @@ If you like this extension and you find it useful, please rate it on the right s
|
|
35 |
|
36 |
= Notice =
|
37 |
|
38 |
-
For fully functional plugin you need to have PHP 5.3
|
39 |
|
40 |
= Styling =
|
41 |
-
|
42 |
You can use `style.css` from theme to style `YouTube Video` widget content.
|
43 |
|
44 |
* `.youtube_channel` - main widget wrapper class (non-responsive block have additional class `default`, responsive block have additional class `responsive`)
|
@@ -53,31 +51,22 @@ You can use `style.css` from theme to style `YouTube Video` widget content.
|
|
53 |
|
54 |
= Known Issues =
|
55 |
|
56 |
-
* Controls light theme and hidden annotations does not work for chromeless object.
|
57 |
* Video description for videos from playlist does not work.
|
58 |
* Removing YouTube logo from playback control bar does not work for all videos
|
59 |
* Async HTML5 video does not work for 2nd same video on same page (two YTC blocks set to Async HTML5)
|
60 |
-
*
|
61 |
|
62 |
-
If WordFence or other malware scan tool detect YouTube Channel
|
63 |
|
64 |
= Credits =
|
65 |
|
66 |
-
*
|
67 |
-
*
|
68 |
-
* Code improvements and textdomain adds done by [dimadin](http://wordpress.org/extend/plugins/profile/dimadin).
|
69 |
* [Federico Bozo](http://corchoweb.com/) reminded me to fix z-index problem
|
70 |
* Czech localization by [Ladislav Drábek](http://zholesova.cz)
|
71 |
* Spanish localization by [Diego Riaño](http://Digital03.net)
|
72 |
* Danish localisation by [GSAdev v. Georg Adamsen](http://www.gsadev.dk)
|
73 |
|
74 |
-
= How To Use =
|
75 |
-
**Add New Widget**
|
76 |
-
[youtube http://www.youtube.com/watch?v=Sj84cja7ieg]
|
77 |
-
|
78 |
-
**Use Playlist**
|
79 |
-
[youtube http://www.youtube.com/watch?v=y9zoi_Pk2kY]
|
80 |
-
|
81 |
= Shortcode =
|
82 |
|
83 |
Along to Widget, you can add YouTube Channel block inline by using shortcode `[youtube_channel]`. Default plugin parameters will be used for shortcode, but you can customize all parameters per shortcode.
|
@@ -86,36 +75,33 @@ Along to Widget, you can add YouTube Channel block inline by using shortcode `[y
|
|
86 |
|
87 |
* `class` (string) Set custom class if you wish to target special styling for specific YTC block
|
88 |
* `channel` (string) ID of preferred YouTube channel. Do not set full URL to channel, but just last part from URL - ID (name)
|
|
|
89 |
* `playlist` (string) ID of preferred YouTube playlist.
|
90 |
-
* `
|
91 |
* `0` Channel
|
92 |
* `1` Favorites (for defined channel)
|
93 |
* `2` Playlist
|
|
|
94 |
* `only_pl` (bool) If you set to use Playlist as resource, you can embed youtube playlist block instead single video from playlist. Simply set this option to true (1 or true)
|
95 |
* `cache` (int) Period in seconds for caching feed. You can disable caching by setting this option to 0, but if you have a lot of visits, consider at least short caching (couple minutes).
|
96 |
* `fetch` (int) Number of videos that will be used as stack for random pick (min 2, max 50)
|
97 |
* `num` (int) Number of videos to display per YTC block.
|
98 |
-
* `fix` (bool) Option to fix No Items error, and also to respect order of videos in feed or playlist.
|
99 |
* `random` (bool) Option to randomize videos on every page load.
|
100 |
|
101 |
**Video Settings**
|
102 |
|
103 |
* `ratio` (int) Set preferred aspect ratio for thumbnail and video. You can use:
|
104 |
* `3` 16:9 (widescreen)
|
105 |
-
* `2` 16:10 (computer screen) **deprecated**
|
106 |
* `1` 4:3
|
107 |
* `responsive` (bool) Distribute one full width video per row.
|
108 |
* `width` (int) Width of thumbnail and video in pixels.
|
109 |
-
* `
|
110 |
-
* `thumbnail` Thumbnail will be used and video will be loaded in lightbox.
|
111 |
* `iframe` HTML5 (iframe)
|
112 |
* `iframe2` HTML5 (iframe) with asynchronous loading - recommended
|
113 |
-
* `object` Flash object (not so good for Apple devices) **deprecated**
|
114 |
-
* `chromeless` Chromeless solution (also not good for Apple devices) **deprecated**
|
115 |
* `no_thumb_title` (bool) By default YouTube thumbnail will have tooltip with info about video title and date of publishing. By setting this option to 1 or true you can hide tooltip
|
116 |
* `themelight` (bool) By default YouTube have dark play controls theme. By setting this option to 1 or true you can get light theme in player (HTML5 and Flash)
|
117 |
* `controls` (bool) Set this option to 1 or true to hide playback controls.
|
118 |
-
* `fix_h` (bool) If you did not set to hide player controls, you can set this option to 1 or true to fix video height taken by controls
|
119 |
* `autoplay` (bool) Enable autoplay of first video in YTC video stack by setting this option to 1 or true
|
120 |
* `mute` (bool) Set this option to 1 or true to mute videos set to autoplay on load
|
121 |
* `norel` (bool) Set this option to 1 or true to hire related videos after finished playbak
|
@@ -134,7 +120,7 @@ Along to Widget, you can add YouTube Channel block inline by using shortcode `[y
|
|
134 |
* `goto` (bool)
|
135 |
* `goto_txt` (string)
|
136 |
* `popup` (int)
|
137 |
-
* `
|
138 |
|
139 |
== Installation ==
|
140 |
|
@@ -147,6 +133,23 @@ You can use the built in installer and upgrader, or you can install the plugin m
|
|
147 |
|
148 |
If you have to upgrade manually simply repeat the installation steps and re-enable the plugin.
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
== Frequently Asked Questions ==
|
151 |
|
152 |
= I set more than one items to fetch, but only one video is displayed. How to fix this? =
|
@@ -192,6 +195,34 @@ Also, even when hidding logo works for your video, on hover or when video is pau
|
|
192 |
|
193 |
== Changelog ==
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
= 2.4.2.1 (2015-04-24) =
|
196 |
* Fix: devicesupport workaround strip 1st video from playlist and favourites and apply only for channel
|
197 |
|
@@ -211,13 +242,21 @@ Also, even when hidding logo works for your video, on hover or when video is pau
|
|
211 |
* Fix: missing support to hide playback controls, info and annotations for embedded playlist
|
212 |
|
213 |
= 2.4.1.5 (2015-04-13) =
|
214 |
-
* Change: Add dismiss link for Old PHP notice and lower suggested PHP version to 5.3.x
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
|
216 |
= 2.4.1.4 (2015-04-09) =
|
217 |
* (2015-04-09) Add: Notification about old PHP if lower than 5.3.29
|
218 |
-
* Change: Run admin functions only in dashboard
|
219 |
* (2015-02-09) Fix: strip whitespace from the beginngine/end of channel and playlist ID
|
220 |
* (2014-12-30) Fix: prevent Undefined Offset notice when on resource we get less items than user requested in shortcode/widget
|
|
|
|
|
221 |
|
222 |
= 2.4.1.3 (2014-12-10) =
|
223 |
* Fix: previous release broke opening lightbox for thumbnails and load YouTube website.
|
@@ -407,19 +446,3 @@ Responsive, bug fixes, support for WordPress 4.1
|
|
407 |
2. YouTube Channel customized widget settings
|
408 |
3. YouTube Channel in WP Customizer
|
409 |
4. YouTube Channel preview
|
410 |
-
|
411 |
-
== Other Notes ==
|
412 |
-
|
413 |
-
Version 2.4.2 is latest feature release that will use YouTube API v2 and Redux Framework. We'll release micro releases only with bugfixes.
|
414 |
-
|
415 |
-
We hope that until end of May 2015 we'll finish version 3.0.0. Please note, you'll need to create your own Google API Key and add it in `wp-config.php` to be able to use YouTube Channel v3.0.0.
|
416 |
-
|
417 |
-
= Main differences we'll introduce in v3.0.0 =
|
418 |
-
|
419 |
-
* Google YouTube API v3
|
420 |
-
* WP Settings API (back to the roots to reduce 3rd party requirements - Redux Framework)
|
421 |
-
* Available types to show: Thumbnail (default), HTML5 (iframe) and HTML5 (iframe) Asynchronous (FLASH and Chromeless object has been deprecated and removed)
|
422 |
-
* Available resources: Channel, Favourites, Liked Videos or Playlist
|
423 |
-
* Available aspect ratios: 16:9 (as default fallback) or 4:3 (16:10 has been deprecated and removed)
|
424 |
-
* Links to channel below video blocks will be: Vanity customized name, Channel ID or Legacy username
|
425 |
-
* No more problems with `No items`
|
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, responsive
|
5 |
Requires at least: 3.9.0
|
6 |
+
Tested up to: 4.2.2
|
7 |
+
Stable tag: 3.0.0
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
19 |
If you like this extension and you find it useful, please rate it on the right side.
|
20 |
|
21 |
= Features =
|
|
|
22 |
* Display latest videos from YouTube channel, favorites or playlist
|
23 |
* Option to get random video from resources mentioned above
|
24 |
* Responsive (one full width video per row) or non responsive (video wall)
|
34 |
|
35 |
= Notice =
|
36 |
|
37 |
+
For fully functional plugin you need to have PHP 5.3 or newer! If you experience issues on older PHP, we can't help you as we don't have access to such old development platform.
|
38 |
|
39 |
= Styling =
|
|
|
40 |
You can use `style.css` from theme to style `YouTube Video` widget content.
|
41 |
|
42 |
* `.youtube_channel` - main widget wrapper class (non-responsive block have additional class `default`, responsive block have additional class `responsive`)
|
51 |
|
52 |
= Known Issues =
|
53 |
|
|
|
54 |
* Video description for videos from playlist does not work.
|
55 |
* Removing YouTube logo from playback control bar does not work for all videos
|
56 |
* Async HTML5 video does not work for 2nd same video on same page (two YTC blocks set to Async HTML5)
|
57 |
+
* Thumbnail and opening video in lightbox does not work with `Responz` theme by `Thenify.me` if you wish to hide related videos, because this theme uses original `Magnific Popup` library that does not support `rel` parameter.
|
58 |
|
59 |
+
If WordFence or other malware scan tool detect YouTube Channel fule youtube-channel.php as potential risk because `base64_encode()` and `base64_decode()` functions, remember that we use this two functions to store and restore JSON feeds to transient cache, so potential detection is false positive.
|
60 |
|
61 |
= Credits =
|
62 |
|
63 |
+
* For playing videos in lightbox we use enhanced [Magnific Popup](http://dimsemenov.com/plugins/magnific-popup/).
|
64 |
+
* Initial textdomain adds done by [dimadin](http://wordpress.org/extend/plugins/profile/dimadin).
|
|
|
65 |
* [Federico Bozo](http://corchoweb.com/) reminded me to fix z-index problem
|
66 |
* Czech localization by [Ladislav Drábek](http://zholesova.cz)
|
67 |
* Spanish localization by [Diego Riaño](http://Digital03.net)
|
68 |
* Danish localisation by [GSAdev v. Georg Adamsen](http://www.gsadev.dk)
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
= Shortcode =
|
71 |
|
72 |
Along to Widget, you can add YouTube Channel block inline by using shortcode `[youtube_channel]`. Default plugin parameters will be used for shortcode, but you can customize all parameters per shortcode.
|
75 |
|
76 |
* `class` (string) Set custom class if you wish to target special styling for specific YTC block
|
77 |
* `channel` (string) ID of preferred YouTube channel. Do not set full URL to channel, but just last part from URL - ID (name)
|
78 |
+
* `vanity` (string) part after www.youtube.com/c/ from [Custom URL](https://support.google.com/youtube/answer/2657968?hl=en)
|
79 |
* `playlist` (string) ID of preferred YouTube playlist.
|
80 |
+
* `resource` (int) Resource to use for feed:
|
81 |
* `0` Channel
|
82 |
* `1` Favorites (for defined channel)
|
83 |
* `2` Playlist
|
84 |
+
* `3` Liked Videos
|
85 |
* `only_pl` (bool) If you set to use Playlist as resource, you can embed youtube playlist block instead single video from playlist. Simply set this option to true (1 or true)
|
86 |
* `cache` (int) Period in seconds for caching feed. You can disable caching by setting this option to 0, but if you have a lot of visits, consider at least short caching (couple minutes).
|
87 |
* `fetch` (int) Number of videos that will be used as stack for random pick (min 2, max 50)
|
88 |
* `num` (int) Number of videos to display per YTC block.
|
|
|
89 |
* `random` (bool) Option to randomize videos on every page load.
|
90 |
|
91 |
**Video Settings**
|
92 |
|
93 |
* `ratio` (int) Set preferred aspect ratio for thumbnail and video. You can use:
|
94 |
* `3` 16:9 (widescreen)
|
|
|
95 |
* `1` 4:3
|
96 |
* `responsive` (bool) Distribute one full width video per row.
|
97 |
* `width` (int) Width of thumbnail and video in pixels.
|
98 |
+
* `display` (string) Object that will be used to represent video. We have couple predefined options:
|
99 |
+
* `thumbnail` Thumbnail will be used and video will be loaded in lightbox. (default)
|
100 |
* `iframe` HTML5 (iframe)
|
101 |
* `iframe2` HTML5 (iframe) with asynchronous loading - recommended
|
|
|
|
|
102 |
* `no_thumb_title` (bool) By default YouTube thumbnail will have tooltip with info about video title and date of publishing. By setting this option to 1 or true you can hide tooltip
|
103 |
* `themelight` (bool) By default YouTube have dark play controls theme. By setting this option to 1 or true you can get light theme in player (HTML5 and Flash)
|
104 |
* `controls` (bool) Set this option to 1 or true to hide playback controls.
|
|
|
105 |
* `autoplay` (bool) Enable autoplay of first video in YTC video stack by setting this option to 1 or true
|
106 |
* `mute` (bool) Set this option to 1 or true to mute videos set to autoplay on load
|
107 |
* `norel` (bool) Set this option to 1 or true to hire related videos after finished playbak
|
120 |
* `goto` (bool)
|
121 |
* `goto_txt` (string)
|
122 |
* `popup` (int)
|
123 |
+
* `link_to` (int)
|
124 |
|
125 |
== Installation ==
|
126 |
|
133 |
|
134 |
If you have to upgrade manually simply repeat the installation steps and re-enable the plugin.
|
135 |
|
136 |
+
= YouTube Data API Key =
|
137 |
+
Main difference since v2.x branch is that now we use [YouTube Data API v3](https://developers.google.com/youtube/v3/) so to make plugin to work, you'll need to generate YouTube Data API Key and insert it to `wp-config.php` file.
|
138 |
+
|
139 |
+
Learn more about [Obtaining authorization credentials](https://developers.google.com/youtube/registering_an_application) and for detailed instructions how to generate your own API Key watch video below.
|
140 |
+
|
141 |
+
[youtube http://www.youtube.com/watch?v=8NlXV77QO8U]
|
142 |
+
|
143 |
+
When you generate your own YouTube Data API Key, edit wp-config.php file and find line
|
144 |
+
|
145 |
+
`/* That's all, stop editing! Happy blogging. */`
|
146 |
+
|
147 |
+
Insert above that line code
|
148 |
+
`define('YOUTUBE_DATA_API_KEY', 'YOUR_API_KEY');`
|
149 |
+
|
150 |
+
just replace keyword <strong>YOUR_API_KEY</strong> with your real API Key previously generated (surround API key to single quotes). For example, if your key is **AIzaCuBWKZLyQthAgV3ofeYtCwrMSYvm6tX8IEY** then that line should be:
|
151 |
+
`define('YOUTUBE_DATA_API_KEY', 'AIzaCuBWKZLyQthAgV3ofeYtCwrMSYvm6tX8IEY');`
|
152 |
+
|
153 |
== Frequently Asked Questions ==
|
154 |
|
155 |
= I set more than one items to fetch, but only one video is displayed. How to fix this? =
|
195 |
|
196 |
== Changelog ==
|
197 |
|
198 |
+
= 3.0.0 (2015-05-07/08/09/10) =
|
199 |
+
* Fix: Migraton of global and widget settings to v3.0.0
|
200 |
+
* Add: New Global Settings page as replacement of Redux Framework solution
|
201 |
+
* Add: Non-Dismissable Dashboard notice if YouTube Data API Key missing with link to explanation page
|
202 |
+
* Change: Option key `ytc_version` to `youtube_channel_version`
|
203 |
+
* Change: Shortcode parameters: `res` to `resource`, `show` to `display`; but leave old parameter names for backward compatibility
|
204 |
+
* Enhance: Various plugin core micro optimizations
|
205 |
+
* Enhance: Dashboard notices
|
206 |
+
* Enhance: Proper options migration on plugin update
|
207 |
+
* Remove: Redux Framework mentioning from core plugin
|
208 |
+
* Remove: Redux Framework config.php
|
209 |
+
* Remove: chromeless.swf asset
|
210 |
+
* Remove: option `Fix height taken by controls` as now YouTube displays control bar only when video is hovered
|
211 |
+
|
212 |
+
= 3.0.0alpha2 (2015-03-07/22/24) =
|
213 |
+
* Add: Rewrite plugin to work with YouTube Data API v3
|
214 |
+
* Add: Vanity link as option to Link to channel (now supports Legacy username, Channel and Vanity URL) with cleanup Vanity ID routine
|
215 |
+
* Add: Liked videos as resource (now support channel, playlists, favourites and liked videos)
|
216 |
+
* Add: Admin notification in widget output on front-end if no YouTube Data API Key is defined to prevent errors
|
217 |
+
* Add: Dismissable Dashboard notice if PHP version is lower than 5.3 as YTC maybe will not work with older versions.
|
218 |
+
* Change: Global and widget option names: `use_res` to `resource`, `cache_time` to `cache`, `maxrnd` to `fetch`, `vidqty` to `num`, `getrnd` to `random`, `to_show` to `display`, `showvidesc` to `showdesc`, `enhprivacy` to `privacy`, `videsclen` to `desclen`,
|
219 |
+
* Change: Widget settings functionality, two column options, better toggle for playlist and GoTo section
|
220 |
+
* Enhance: Caching routine (reduce possibility of failed feed fetch)
|
221 |
+
* Remove: Chromeless and Flash player - leave only Thumbnail and HTML5
|
222 |
+
* Remove: Aspect Ration 16:10 (so support only 16:9 and 4:3, same as modern YouTube)
|
223 |
+
* Remove: "Fix No Item" option - not required for YouTube API 3.0
|
224 |
+
|
225 |
+
*OLD RELEASES*
|
226 |
= 2.4.2.1 (2015-04-24) =
|
227 |
* Fix: devicesupport workaround strip 1st video from playlist and favourites and apply only for channel
|
228 |
|
242 |
* Fix: missing support to hide playback controls, info and annotations for embedded playlist
|
243 |
|
244 |
= 2.4.1.5 (2015-04-13) =
|
245 |
+
* (2015-04-13) Change: Add dismiss link for Old PHP notice and lower suggested PHP version to 5.3.x
|
246 |
+
* (2015-02-19) Fix: missing admin notices if ReduxFramework not active
|
247 |
+
* (2015-02-10) Add: links to explanations for channel ID and vanity URL
|
248 |
+
* (2015-02-10) Add: goto macro %vanity% to insert vanity ID
|
249 |
+
* (2015-02-10) Add: field for vanity URL ID
|
250 |
+
* (2015-02-10) Add: option to select link to user page, channel page or vanity URL for goto link
|
251 |
+
* (2015-02-10) Remove: option to use channel instead user page for goto link
|
252 |
|
253 |
= 2.4.1.4 (2015-04-09) =
|
254 |
* (2015-04-09) Add: Notification about old PHP if lower than 5.3.29
|
255 |
+
* (2015-04-09) Change: Run admin functions only in dashboard
|
256 |
* (2015-02-09) Fix: strip whitespace from the beginngine/end of channel and playlist ID
|
257 |
* (2014-12-30) Fix: prevent Undefined Offset notice when on resource we get less items than user requested in shortcode/widget
|
258 |
+
* (2014-12-30) Fix: prevent Undefined Offset notice when on resource we get less items than user requested in shortcode/widget
|
259 |
+
* (2014-12-30) Add: make fallback cache for every feed and use it if no item occurs to avoid No items
|
260 |
|
261 |
= 2.4.1.3 (2014-12-10) =
|
262 |
* Fix: previous release broke opening lightbox for thumbnails and load YouTube website.
|
446 |
2. YouTube Channel customized widget settings
|
447 |
3. YouTube Channel in WP Customizer
|
448 |
4. YouTube Channel preview
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Run the incremental updates one by one.
|
4 |
+
*
|
5 |
+
* For example, if the current DB version is 3, and the target DB version is 6,
|
6 |
+
* this function will execute update routines if they exist:
|
7 |
+
* - au_youtube_channel_update_routine_4()
|
8 |
+
* - au_youtube_channel_update_routine_5()
|
9 |
+
* - au_youtube_channel_update_routine_6()
|
10 |
+
*/
|
11 |
+
|
12 |
+
function au_youtube_channel_update() {
|
13 |
+
// no PHP timeout for running updates
|
14 |
+
set_time_limit( 0 );
|
15 |
+
|
16 |
+
// this is the current database schema version number
|
17 |
+
$current_db_ver = get_option( 'youtube_channel_db_ver', 0 );
|
18 |
+
|
19 |
+
// this is the target version that we need to reach
|
20 |
+
$target_db_ver = WPAU_YOUTUBE_CHANNEL::DB_VER;
|
21 |
+
|
22 |
+
// run update routines one by one until the current version number
|
23 |
+
// reaches the target version number
|
24 |
+
while ( $current_db_ver < $target_db_ver ) {
|
25 |
+
// increment the current db_ver by one
|
26 |
+
++$current_db_ver;
|
27 |
+
|
28 |
+
// each db version will require a separate update function
|
29 |
+
// for example, for db_ver 3, the function name should be solis_update_routine_3
|
30 |
+
$func = "au_youtube_channel_update_routine_{$current_db_ver}";
|
31 |
+
if ( function_exists( $func ) ) {
|
32 |
+
call_user_func( $func );
|
33 |
+
}
|
34 |
+
|
35 |
+
// update the option in the database, so that this process can always
|
36 |
+
// pick up where it left off
|
37 |
+
update_option( 'youtube_channel_db_ver', $current_db_ver );
|
38 |
+
}
|
39 |
+
} // END function au_youtube_channel_update()
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Migrate pre-2.0.0 widgets to 2.0.0 version
|
43 |
+
*/
|
44 |
+
function au_youtube_channel_update_routine_2() {
|
45 |
+
|
46 |
+
if ( $old = get_option('widget_youtube_channel_widget') ) {
|
47 |
+
|
48 |
+
// get new YTC widgets
|
49 |
+
$new = get_option('widget_youtube-channel');
|
50 |
+
|
51 |
+
// get all widget areas
|
52 |
+
$widget_areas = get_option('sidebars_widgets');
|
53 |
+
|
54 |
+
// update options to 2.0.0+ version
|
55 |
+
foreach ($old as $k => $v) {
|
56 |
+
|
57 |
+
if ( $k !== "_multiwidget" ){
|
58 |
+
// option for resource
|
59 |
+
$v['use_res'] = 0;
|
60 |
+
if ( $v['usepl'] == 'on' ) {
|
61 |
+
$v['use_res'] = 2;
|
62 |
+
}
|
63 |
+
|
64 |
+
$v['popup_goto'] = 0;
|
65 |
+
if ( $v['popupgoto'] == 'on' ) {
|
66 |
+
$v['popup_goto'] = 1;
|
67 |
+
} else if ($v['target'] == 'on') {
|
68 |
+
$v['popup_goto'] = 2;
|
69 |
+
}
|
70 |
+
unset($v['usepl'], $v['popupgoto'], $v['target']);
|
71 |
+
|
72 |
+
$v['cache_time'] = 0;
|
73 |
+
$v['userchan'] = 0;
|
74 |
+
$v['enhprivacy'] = 0;
|
75 |
+
$v['autoplay_mute'] = 0;
|
76 |
+
|
77 |
+
// add old YTC widget to new set
|
78 |
+
// but append at the end if YTC widget with same ID already exist
|
79 |
+
// in new set (created in version 2.0.0)
|
80 |
+
if ( is_array($new[$k]) ) {
|
81 |
+
// populate at the end
|
82 |
+
array_push($new, $v);
|
83 |
+
$ytc_widget_id = 'youtube-channel-' . end( array_keys($new) );
|
84 |
+
} else {
|
85 |
+
// set as current widget ID
|
86 |
+
$new[$k] = $v;
|
87 |
+
$ytc_widget_id = "youtube-channel-$k";
|
88 |
+
}
|
89 |
+
|
90 |
+
$ytc_widget_added = 0;
|
91 |
+
foreach ( $widget_areas as $wak => $wav ) {
|
92 |
+
// check if here we have this widget
|
93 |
+
if ( is_array($wav) && in_array($ytc_widget_id, $wav) ) {
|
94 |
+
++$ytc_widget_added;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
// fre some memory
|
98 |
+
unset($wak, $wav);
|
99 |
+
|
100 |
+
// if YTC widget has not present in any widget area, add it to inactive widgets ;)
|
101 |
+
if ( $ytc_widget_added == 0 ) {
|
102 |
+
array_push($widget_areas['wp_inactive_widgets'], $ytc_widget_id);
|
103 |
+
}
|
104 |
+
|
105 |
+
} // add to inactive widgets if don't belong to any widget area
|
106 |
+
|
107 |
+
} // foreach widget option
|
108 |
+
|
109 |
+
// update widget areas set
|
110 |
+
update_option('sidebars_widgets', $widget_areas);
|
111 |
+
|
112 |
+
// update new YTC widgets
|
113 |
+
update_option('widget_youtube-channel', $new);
|
114 |
+
|
115 |
+
// remove old YTC widgets entry
|
116 |
+
delete_option('widget_youtube_channel_widget');
|
117 |
+
|
118 |
+
} // if we have old YTC widgets
|
119 |
+
|
120 |
+
// clear temporary vars
|
121 |
+
unset ($old, $new, $k, $v, $widget_areas, $ytc_widget_added, $ytc_widget_id);
|
122 |
+
|
123 |
+
|
124 |
+
} // END function au_youtube_channel_update_routine_2()
|
125 |
+
|
126 |
+
/**
|
127 |
+
* migrate to v3.0.0
|
128 |
+
* @return [type] [description]
|
129 |
+
*/
|
130 |
+
function au_youtube_channel_update_routine_3() {
|
131 |
+
|
132 |
+
// Remove deprecated option keys
|
133 |
+
delete_option('ytc_no_redux_notice');
|
134 |
+
delete_option('ytc_old_php_notice');
|
135 |
+
delete_option('ytc_version');
|
136 |
+
|
137 |
+
// get options from DB
|
138 |
+
$defaults = get_option('youtube_channel_defaults');
|
139 |
+
|
140 |
+
// prepare migration matrix
|
141 |
+
$options_matrix = array(
|
142 |
+
'use_res' => 'resource',
|
143 |
+
'cache_time' => 'cache',
|
144 |
+
'maxrnd' => 'fetch',
|
145 |
+
'vidqty' => 'num',
|
146 |
+
'getrnd' => 'random',
|
147 |
+
'to_show' => 'display',
|
148 |
+
'showvidesc' => 'showdesc',
|
149 |
+
'videsclen' => 'desclen',
|
150 |
+
'enhprivacy' => 'privacy'
|
151 |
+
);
|
152 |
+
// set defaults
|
153 |
+
$init = array(
|
154 |
+
'resource' => 0, // ex use_res
|
155 |
+
'cache' => 300, // 5 minutes // ex cache_time
|
156 |
+
'fetch' => 25, // ex maxrnd
|
157 |
+
'num' => 1, // ex vidqty
|
158 |
+
'random' => 0, // ex getrnd
|
159 |
+
'display' => 'thumbnail', // ex to_show
|
160 |
+
'showdesc' => 0, // ex showvidesc
|
161 |
+
'desclen' => 0, // ex videsclen
|
162 |
+
'privacy' => 0 // ex enhprivacy
|
163 |
+
);
|
164 |
+
|
165 |
+
// Do migration of option names
|
166 |
+
foreach ( $options_matrix as $old_option => $new_option ) {
|
167 |
+
if ( isset($defaults[ $old_option ]) ) {
|
168 |
+
$defaults[ $new_option ] = $defaults[ $old_option ];
|
169 |
+
unset($defaults[ $old_option ]);
|
170 |
+
} else if ( empty($defaults[ $new_option ]) ) {
|
171 |
+
$defaults[ $new_option ] = $init[ $new_option ];
|
172 |
+
}
|
173 |
+
}
|
174 |
+
// Free some memory
|
175 |
+
unset ( $old_option, $new_option );
|
176 |
+
|
177 |
+
// Write back updated defaults
|
178 |
+
update_option( 'youtube_channel_defaults', $defaults );
|
179 |
+
|
180 |
+
// Add empty option key for dismissed notices
|
181 |
+
add_option('youtube_channel_dismissed_notices', '', '', 'no');
|
182 |
+
|
183 |
+
// Update plugin version number
|
184 |
+
update_option('youtube_channel_version', WPAU_YOUTUBE_CHANNEL::VER);
|
185 |
+
|
186 |
+
// Delete all YouTube Channel transients
|
187 |
+
global $_wp_using_ext_object_cache, $wpdb;
|
188 |
+
if ( ! $_wp_using_ext_object_cache ) {
|
189 |
+
$sql = "DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_ytc_%' OR option_name LIKE '_transient_timeout_ytc_%'";
|
190 |
+
$clean = $wpdb -> query( $sql );
|
191 |
+
|
192 |
+
// optimize wp_options table
|
193 |
+
$wpdb -> query( "OPTIMIZE TABLE $wpdb->options" );
|
194 |
+
}
|
195 |
+
|
196 |
+
$ytc_widgets = get_option('widget_youtube-channel');
|
197 |
+
foreach ( $ytc_widgets as $widget_id => $widget_data ) {
|
198 |
+
// process widget arrays, not _multiwidget bool
|
199 |
+
if ( $widget_id != '_multiwidget' ) {
|
200 |
+
|
201 |
+
foreach ( $widget_data as $key => $val ) {
|
202 |
+
// if old key is in matrix
|
203 |
+
if ( array_key_exists($key, $options_matrix) ) {
|
204 |
+
// create new option if does not exists
|
205 |
+
if ( ! array_key_exists($options_matrix[ $key ], $widget_data) ) {
|
206 |
+
// copy old value to new key name
|
207 |
+
$ytc_widgets[ $widget_id ][ $options_matrix[ $key ] ] = $val;
|
208 |
+
}
|
209 |
+
// delete old key
|
210 |
+
unset ($ytc_widgets[ $widget_id ][ $key ]);
|
211 |
+
}
|
212 |
+
} // END foreach ( $widget_data as $key => $val )
|
213 |
+
|
214 |
+
} // END if ( $widget_id != '_multiwidget' )
|
215 |
+
|
216 |
+
}
|
217 |
+
update_option('widget_youtube-channel', $ytc_widgets);
|
218 |
+
unset ($options_matrix, $init, $ytc_widgets, $widget_id, $widget_data);
|
219 |
+
|
220 |
+
} // END function au_youtube_channel_update_routine_3()
|
@@ -2,12 +2,12 @@
|
|
2 |
/*
|
3 |
Plugin Name: YouTube Channel
|
4 |
Plugin URI: http://urosevic.net/wordpress/plugins/youtube-channel/
|
5 |
-
Description: <a href="widgets.php">Widget</a> that display latest video thumbnail
|
6 |
Author: Aleksandar Urošević
|
7 |
-
Version:
|
8 |
Author URI: http://urosevic.net/
|
9 |
*/
|
10 |
-
// @TODO make
|
11 |
|
12 |
// Exit if accessed directly
|
13 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
@@ -17,284 +17,303 @@ if ( !class_exists('WPAU_YOUTUBE_CHANNEL') )
|
|
17 |
class WPAU_YOUTUBE_CHANNEL
|
18 |
{
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
public $
|
24 |
-
public $
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
public $plugin_url;
|
27 |
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
// debug JSON
|
32 |
-
if (!empty($_GET['ytc_debug_json_for']))
|
33 |
$this->generate_debug_json();
|
34 |
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
//
|
42 |
-
if ( is_admin() )
|
43 |
-
add_action('init', array($this, 'settings_init'), 900);
|
44 |
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
require_once('inc/widget.php');
|
47 |
|
48 |
-
//
|
49 |
add_shortcode( 'youtube_channel', array($this, 'shortcode') );
|
50 |
add_shortcode( 'ytc', array($this, 'shortcode') );
|
51 |
|
52 |
-
|
53 |
-
// Update YTC version in database on request
|
54 |
-
if ( !empty($_GET['ytc_dismiss_update_notice']) )
|
55 |
-
update_option( 'ytc_version', $this->plugin_version );
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
update_option( 'ytc_old_php_notice', true);
|
64 |
|
65 |
-
|
66 |
-
if ( version_compare(PHP_VERSION, "5.3", "<") && ! get_option('ytc_old_php_notice') )
|
67 |
-
add_action( 'admin_notices', array($this, 'admin_notices_old_php') );
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
79 |
|
80 |
-
|
|
|
|
|
81 |
|
82 |
-
function
|
83 |
-
{
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
add_filter('plugin_action_links_'.plugin_basename(__FILE__), array($this, 'add_settings_link') );
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
}
|
95 |
-
} else {
|
96 |
-
// Add admin notice for Redux Framework
|
97 |
-
if ( !get_option('ytc_no_redux_notice', 0) )
|
98 |
-
add_action( 'admin_notices', array($this,'admin_notice_redux') );
|
99 |
}
|
100 |
|
101 |
-
|
|
|
102 |
|
103 |
-
function
|
104 |
-
{
|
105 |
-
$previous_version = get_option('ytc_version','0');
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
case "0":
|
112 |
-
$msg = sprintf(__('Please review <a href="%s">global settings</a>, YTC widgets and shortcodes.', 'youtube-channel'), $settings_page);
|
113 |
-
break;
|
114 |
-
case "2.2.2":
|
115 |
-
$msg = sprintf(__('If you use caching for any YTC widget or shortcode, please <strong>ReCache</strong> feeds in <strong>Tools</strong> section of <a href="%s">plugin settings</a> page.', 'youtube-channel'), $settings_page);
|
116 |
-
break;
|
117 |
-
case "2.2.3":
|
118 |
-
if (class_exists( "ReduxFramework" )){
|
119 |
-
$msg = sprintf(__('We switched to <em>Redux Framework</em> so please review global plugin <a href="%s">settings page</a>.', 'youtube-channel'), $settings_page);
|
120 |
-
} else {
|
121 |
-
$msg = __('We switched to <em>Redux Framework</em> so please install and activate dependency and then review global YouTube Channel plugin settings.', 'youtube-channel');
|
122 |
-
}
|
123 |
-
break;
|
124 |
-
}
|
125 |
-
if ( !empty($msg) && class_exists( "ReduxFramework" ) )
|
126 |
-
printf(
|
127 |
-
'<div class="update-nag"><p><strong>%s</strong> ' . __("updated to version", 'youtube-channel') . ' <strong>%s</strong>. '.$msg.' <a href="?ytc_dismiss_update_notice=1" class="button button-secondary">' . __("I did this already, dismiss notice!", 'youtube-channel') . '</a></p></div>',
|
128 |
-
$this->plugin_name,
|
129 |
-
$this->plugin_version);
|
130 |
-
} // end admin_notices
|
131 |
-
|
132 |
-
function admin_notices_old_php()
|
133 |
-
{
|
134 |
-
$btn = '<a href="?ytc_dismiss_old_php_notice=1">' . __("I got it! Dismiss this notice.", 'youtube-channel') . '</a>';
|
135 |
-
echo '<div class="error"><p>Your WordPress running on server with PHP version '.PHP_VERSION.'. YouTube Channel plugin requires at least PHP 5.3.x so if you experience any issue, we can`t help. '.$btn.'</p></div>';
|
136 |
-
} // END admin_notices_old_php()
|
137 |
|
138 |
-
|
139 |
-
{
|
140 |
-
$ignoreredux = ' <a href="?ytc_ignore_redux=1" class="button primary">'.__("Dismiss this notice", 'youtube-channel') . '</a>';
|
141 |
-
echo '<div class="error"><p>'.sprintf(__("To configure global <strong>%s</strong> options, you need to install and activate <strong>%s</strong>.", 'youtube-channel'), $this->plugin_name, "Redux Framework Plugin") . $ignoreredux . '</p></div>';
|
142 |
-
} // admin_notice()
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
array_unshift( $links, $settings_link );
|
|
|
|
|
|
|
|
|
|
|
148 |
return $links;
|
149 |
-
} // add_settings_link()
|
150 |
|
151 |
-
|
152 |
-
{
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
'only_pl' => false,
|
159 |
-
'cache_time' => 300, // 5 minutes
|
160 |
-
'maxrnd' => 25,
|
161 |
-
'vidqty' => 1,
|
162 |
-
'enhprivacy' => false,
|
163 |
-
'fixnoitem' => false,
|
164 |
-
'getrnd' => false,
|
165 |
-
'ratio' => 3, // 3 - 16:9, 2 - 16:10, 1 - 4:3
|
166 |
-
'width' => 306,
|
167 |
-
'responsive' => true,
|
168 |
-
'to_show' => 'thumbnail', // thumbnail, iframe, iframe2, chromeless, object
|
169 |
-
'no_thumb_title' => 0, // disable tooltip for thumbnails
|
170 |
-
'themelight' => false,
|
171 |
-
'controls' => false,
|
172 |
-
'fixyt' => false,
|
173 |
-
'autoplay' => false,
|
174 |
-
'autoplay_mute' => false,
|
175 |
-
'norel' => false,
|
176 |
-
|
177 |
-
'showtitle' => false,
|
178 |
-
'showvidesc' => false,
|
179 |
-
'videsclen' => 0,
|
180 |
-
'descappend' => '…',
|
181 |
-
'modestbranding' => false,
|
182 |
-
'hideanno' => false,
|
183 |
-
'hideinfo' => false,
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
);
|
190 |
-
$defaults = get_option($this->plugin_option, $init);
|
191 |
|
192 |
-
|
193 |
-
// return $options;
|
194 |
-
return $defaults;
|
195 |
-
}
|
196 |
|
197 |
/**
|
198 |
-
*
|
|
|
199 |
*/
|
200 |
-
|
201 |
-
{
|
202 |
-
// Transit old settings to new format
|
203 |
-
// get pre-2.0.0 YTC widgets, and if exist, convert to 2.0.0+ version
|
204 |
-
if ( $old = get_option('widget_youtube_channel_widget') ) {
|
205 |
-
// if we have pre-2.0.0 YTC widgets, merge them to new version
|
206 |
-
|
207 |
-
// get new YTC widgets
|
208 |
-
$new = get_option('widget_youtube-channel');
|
209 |
|
210 |
-
|
211 |
-
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
$v['cache_time'] = 0;
|
232 |
-
$v['userchan'] = 0;
|
233 |
-
$v['enhprivacy'] = 0;
|
234 |
-
$v['autoplay_mute'] = 0;
|
235 |
-
|
236 |
-
// add old YTC widget to new set
|
237 |
-
// but append at the end if YTC widget with same ID already exist
|
238 |
-
// in new set (created in version 2.0.0)
|
239 |
-
if ( is_array($new[$k]) ) {
|
240 |
-
// populate at the end
|
241 |
-
array_push($new, $v);
|
242 |
-
$ytc_widget_id = "youtube-channel-".end(array_keys($new));
|
243 |
-
} else {
|
244 |
-
// set as current widget ID
|
245 |
-
$new[$k] = $v;
|
246 |
-
$ytc_widget_id = "youtube-channel-$k";
|
247 |
-
}
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
|
259 |
-
|
260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
-
|
265 |
-
|
|
|
|
|
|
|
266 |
|
267 |
-
|
268 |
-
update_option('widget_youtube-channel',$new);
|
269 |
|
270 |
-
|
271 |
-
|
|
|
|
|
|
|
272 |
|
273 |
-
|
274 |
-
|
|
|
|
|
275 |
|
276 |
-
|
277 |
|
278 |
-
}
|
279 |
|
280 |
function enqueue_scripts() {
|
281 |
-
wp_enqueue_style( 'youtube-channel', plugins_url('assets/css/youtube-channel.min.css', __FILE__), array(),
|
282 |
|
283 |
// enqueue fitVids
|
284 |
-
wp_enqueue_script( 'fitvids', plugins_url('assets/js/jquery.fitvids.min.js', __FILE__), array('jquery'),
|
285 |
|
286 |
// enqueue magnific-popup
|
287 |
-
wp_enqueue_script( 'magnific-popup-au', plugins_url('assets/lib/magnific-popup/jquery.magnific-popup.min.js', __FILE__), array('jquery'),
|
288 |
-
wp_enqueue_style( 'magnific-popup-au', plugins_url('assets/lib/magnific-popup/magnific-popup.min.css', __FILE__), array(),
|
289 |
-
wp_enqueue_script( 'youtube-channel', plugins_url('assets/js/youtube-channel.min.js', __FILE__), array(),
|
290 |
} // end function enqueue_scripts
|
291 |
|
292 |
function footer_scripts() {
|
293 |
// Print JS only if we have set YTC array
|
294 |
-
if ( !empty($_SESSION['ytc_html5_js']) )
|
295 |
{
|
296 |
-
?>
|
297 |
-
<!-- YouTube Channel v<?php echo
|
298 |
<script type="text/javascript">
|
299 |
var tag = document.createElement('script');
|
300 |
tag.src = "//www.youtube.com/iframe_api";
|
@@ -312,8 +331,8 @@ function ytc_mute(event){
|
|
312 |
|
313 |
} // eof footer_scripts
|
314 |
|
315 |
-
public function shortcode($atts)
|
316 |
-
|
317 |
// get general default settings
|
318 |
$instance = $this->defaults();
|
319 |
|
@@ -321,239 +340,332 @@ function ytc_mute(event){
|
|
321 |
extract(
|
322 |
shortcode_atts(
|
323 |
array(
|
|
|
324 |
'channel' => $instance['channel'],
|
|
|
325 |
'playlist' => $instance['playlist'],
|
326 |
-
'res' => $instance['
|
|
|
327 |
'only_pl' => $instance['only_pl'],
|
328 |
-
'cache' => $instance['
|
|
|
|
|
|
|
329 |
|
330 |
-
'
|
331 |
-
'num' => $instance['vidqty'],
|
332 |
-
|
333 |
-
'fix' => $instance['fixnoitem'],
|
334 |
-
'random' => $instance['getrnd'],
|
335 |
|
336 |
'ratio' => $instance['ratio'],
|
337 |
'width' => $instance['width'],
|
338 |
-
'responsive' => (!empty($instance['responsive'])) ? $instance['responsive'] : '0',
|
339 |
-
|
340 |
-
'show' => $instance['to_show'],
|
341 |
-
'no_thumb_title' => (!empty($instance['no_thumb_title'])) ? $instance['no_thumb_title'] : '0',
|
342 |
|
|
|
|
|
|
|
343 |
'themelight' => $instance['themelight'],
|
344 |
'controls' => $instance['controls'],
|
345 |
-
'fix_h' => $instance['fixyt'],
|
346 |
'autoplay' => $instance['autoplay'],
|
347 |
'mute' => $instance['autoplay_mute'],
|
348 |
'norel' => $instance['norel'],
|
349 |
|
350 |
'showtitle' => $instance['showtitle'],
|
351 |
-
'showdesc' => $instance['
|
352 |
-
'nobrand' => (!empty($instance['modestbranding'])) ? $instance['modestbranding'] : '0',
|
353 |
-
'desclen' => $instance['
|
354 |
'noinfo' => $instance['hideinfo'],
|
355 |
'noanno' => $instance['hideanno'],
|
356 |
|
357 |
'goto' => $instance['showgoto'],
|
358 |
'goto_txt' => $instance['goto_txt'],
|
359 |
'popup' => $instance['popup_goto'],
|
360 |
-
'
|
361 |
|
362 |
-
'class' => (!empty($instance['class'])) ? $instance['class'] : ''
|
363 |
-
|
364 |
$atts
|
365 |
)
|
366 |
);
|
367 |
|
368 |
// prepare instance for output
|
369 |
-
$instance['
|
370 |
-
$instance['
|
371 |
-
$instance['
|
372 |
-
$instance['
|
373 |
-
$instance['
|
|
|
|
|
|
|
374 |
|
375 |
-
$instance['
|
376 |
-
$instance['
|
377 |
|
378 |
-
$instance['
|
379 |
-
$instance['getrnd'] = $random; // use embedded playlist - false by default
|
380 |
|
381 |
// Video Settings
|
382 |
-
$instance['ratio']
|
383 |
-
$instance['width']
|
384 |
-
$instance['responsive']
|
385 |
-
$instance['
|
386 |
-
$instance['no_thumb_title'] = $no_thumb_title; // hide
|
387 |
-
|
388 |
-
$instance['themelight']
|
389 |
-
$instance['controls']
|
390 |
-
$instance['
|
391 |
-
$instance['
|
392 |
-
$instance['
|
393 |
-
$instance['norel'] = $norel; // hide related videos
|
394 |
|
395 |
// Content Layout
|
396 |
-
$instance['showtitle']
|
397 |
-
$instance['
|
398 |
-
$instance['modestbranding']= $nobrand; // hide YT logo
|
399 |
-
$instance['
|
400 |
-
$instance['hideinfo']
|
401 |
-
$instance['hideanno']
|
402 |
|
403 |
// Link to Channel
|
404 |
-
$instance['showgoto']
|
405 |
-
$instance['goto_txt']
|
406 |
-
$instance['popup_goto']
|
407 |
-
$instance['
|
|
|
408 |
|
409 |
// Customization
|
410 |
-
$instance['class']
|
411 |
|
412 |
return implode(array_values($this->output($instance)));
|
413 |
-
} // END function shortcode()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
|
415 |
-
|
416 |
-
|
417 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
|
419 |
-
//
|
420 |
-
|
421 |
-
if ( $channel == "" ) $channel = trim($this->channel_id);
|
422 |
|
423 |
-
|
424 |
-
|
425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
|
427 |
-
|
428 |
-
|
429 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
|
431 |
-
|
432 |
|
433 |
-
|
|
|
|
|
|
|
|
|
434 |
|
|
|
435 |
$output = array();
|
436 |
|
437 |
-
$output[] = "<div class=\"youtube_channel $
|
438 |
-
|
439 |
-
if ( $instance['only_pl'] && $use_res == 2 ) { // print standard playlist
|
440 |
-
$output = array_merge($output, self::ytc_only_pl($instance));
|
441 |
-
} else { // channel or playlist single videos
|
442 |
-
|
443 |
-
// get max items for random video
|
444 |
-
$maxrnd = $instance['maxrnd'];
|
445 |
-
if ( $maxrnd < 1 ) { $maxrnd = 10; } // default 10
|
446 |
-
elseif ( $maxrnd > 50 ) { $maxrnd = 50; } // max 50
|
447 |
-
|
448 |
-
$feed_attr = '?alt=json';
|
449 |
-
$feed_attr .= '&v=2';
|
450 |
|
451 |
-
|
452 |
-
$feed_attr .= '&fields=entry(published,title,link,content)';
|
453 |
|
454 |
-
|
455 |
-
$feed_attr .= '&orderby=published';
|
456 |
|
457 |
-
|
458 |
-
if ( $getrnd ) $feed_attr .= "&max-results=${maxrnd}";
|
459 |
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
|
|
|
|
|
|
|
|
|
|
464 |
break;
|
465 |
-
case 2: //
|
466 |
-
$
|
467 |
-
$
|
468 |
break;
|
469 |
-
|
470 |
-
$
|
|
|
|
|
|
|
|
|
|
|
471 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
472 |
|
473 |
-
// do we need cache?
|
474 |
-
if ($instance['cache_time'] > 0 ) {
|
475 |
// generate feed cache key for caching time
|
476 |
-
$
|
477 |
-
$cache_key = "ytc_${md5_feed_url}_${instance['cache_time']}";
|
478 |
|
479 |
-
if (!empty($_GET['ytc_force_recache']))
|
480 |
delete_transient($cache_key);
|
481 |
|
482 |
// get/set transient cache
|
483 |
-
if ( false === ($json = get_transient($cache_key)) ) {
|
|
|
484 |
// no cached JSON, get new
|
485 |
-
$
|
486 |
-
'timeout' => 2 // two seconds only
|
487 |
-
);
|
488 |
-
$response = wp_remote_get($feed_url, $wprga);
|
489 |
-
$json = wp_remote_retrieve_body( $response );
|
490 |
|
491 |
// set decoded JSON to transient cache_key
|
492 |
-
set_transient($cache_key, base64_encode($json), $instance['
|
|
|
493 |
} else {
|
|
|
494 |
// we already have cached feed JSON, get it encoded
|
495 |
$json = base64_decode($json);
|
|
|
496 |
}
|
|
|
497 |
} else {
|
|
|
498 |
// just get fresh feed if cache disabled
|
499 |
-
$
|
500 |
-
|
501 |
-
);
|
502 |
-
$response = wp_remote_get($feed_url, $wprga);
|
503 |
-
$json = wp_remote_retrieve_body( $response );
|
504 |
}
|
505 |
|
|
|
|
|
|
|
506 |
// decode JSON data
|
507 |
$json_output = json_decode($json);
|
508 |
|
509 |
-
//
|
510 |
-
$
|
511 |
-
|
512 |
-
//
|
513 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
|
515 |
-
$
|
516 |
-
if ( $
|
517 |
-
$
|
518 |
|
519 |
-
if ( $
|
520 |
-
$items =
|
521 |
} else {
|
522 |
-
if (
|
523 |
-
$items =
|
524 |
}
|
525 |
}
|
526 |
|
527 |
-
if ($
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
|
534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
|
536 |
-
|
537 |
-
|
538 |
-
$vidqty = sizeof($items);
|
539 |
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
while ( $y > 1 && in_array($rnd_item, $rnd_used) ) {
|
544 |
-
$rnd_item = mt_rand(0, (count($items)-1));
|
545 |
}
|
546 |
-
$
|
547 |
-
$item = $items[ $
|
548 |
} else {
|
549 |
-
$item = $items[ $y-1 ];
|
550 |
}
|
551 |
|
552 |
// print single video block
|
553 |
$output = array_merge( $output, $this->ytc_print_video($item, $instance, $y) );
|
554 |
}
|
|
|
|
|
|
|
|
|
555 |
|
556 |
-
}
|
557 |
} // single playlist or ytc way
|
558 |
|
559 |
$output = array_merge( $output, $this->ytc_channel_link($instance) ); // insert link to channel on bootom of widget
|
@@ -561,56 +673,133 @@ function ytc_mute(event){
|
|
561 |
$output[] = '</div><!-- .youtube_channel -->';
|
562 |
|
563 |
return $output;
|
564 |
-
|
|
|
565 |
|
566 |
// --- HELPER FUNCTIONS ---
|
567 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
// function to calculate height by width and ratio
|
569 |
function height_ratio($width=306, $ratio) {
|
|
|
570 |
switch ($ratio)
|
571 |
{
|
572 |
case 1:
|
573 |
$height = round(($width / 4 ) * 3);
|
574 |
break;
|
575 |
case 2:
|
576 |
-
$height = round(($width / 16 ) * 10);
|
577 |
-
break;
|
578 |
case 3:
|
579 |
default:
|
580 |
$height = round(($width / 16 ) * 9);
|
581 |
}
|
582 |
return $height;
|
583 |
-
} //
|
584 |
|
585 |
-
|
|
|
|
|
|
|
|
|
586 |
function ytc_channel_link($instance) {
|
|
|
587 |
// initialize array
|
588 |
$output = array();
|
|
|
589 |
// do we need to show goto link?
|
590 |
-
if (
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
595 |
if ( $goto_txt == "" )
|
596 |
-
$goto_txt =
|
597 |
-
|
598 |
-
|
|
|
|
|
599 |
|
600 |
$output[] = '<div class="ytc_link">';
|
601 |
-
|
602 |
-
$goto_url = "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
603 |
$newtab = __("in new window/tab", 'youtube-channel');
|
|
|
604 |
$output[] = '<p>';
|
605 |
switch ( $instance['popup_goto'] ) {
|
606 |
case 1:
|
607 |
-
$output[] =
|
608 |
break;
|
609 |
case 2:
|
610 |
-
$output[] =
|
611 |
break;
|
612 |
default:
|
613 |
-
$output[] =
|
614 |
} // switch popup_goto
|
615 |
$output[] = '</p>';
|
616 |
$output[] = '</div>';
|
@@ -641,33 +830,25 @@ function ytc_mute(event){
|
|
641 |
$imgfixedheight = $width / 4 * 3;
|
642 |
|
643 |
// which type to show
|
644 |
-
$
|
645 |
-
|
646 |
-
// if not thumbnail, increase video height for 25px taken by video controls
|
647 |
-
if ( $to_show != 'thumbnail' && !$controls && $instance['fixyt'] )
|
648 |
-
$height += 25;
|
649 |
-
|
650 |
$hideanno = $instance['hideanno'];
|
651 |
$themelight = $instance['themelight'];
|
652 |
/* end of video settings */
|
653 |
|
654 |
-
|
655 |
-
$yt_id
|
656 |
$yt_url = "v/$yt_id";
|
|
|
|
|
657 |
|
658 |
-
$
|
659 |
-
$
|
660 |
-
$yt_video = preg_replace('/\&.*$/','',$yt_video);
|
661 |
-
|
662 |
-
$yt_title = $item->title->{'$t'};
|
663 |
-
$yt_date = $item->published->{'$t'};
|
664 |
-
//$yt_date = $item->get_date('j F Y | g:i a');
|
665 |
|
666 |
switch ($y) {
|
667 |
case 1:
|
668 |
$vnumclass = 'first';
|
669 |
break;
|
670 |
-
case $instance['
|
671 |
$autoplay = false;
|
672 |
$vnumclass = 'last';
|
673 |
break;
|
@@ -684,68 +865,31 @@ function ytc_mute(event){
|
|
684 |
case 2: $arclass = 'ar16_10'; break;
|
685 |
default: $arclass = 'ar16_9';
|
686 |
}
|
687 |
-
|
688 |
-
// open container
|
689 |
-
$output[] = "<div class=\"ytc_video_container ytc_video_${y} ytc_video_${vnumclass} ${arclass}\" style=\"width:${width}px\">";
|
690 |
|
691 |
// show video title?
|
692 |
-
if ( ! empty(
|
693 |
-
$output[] = "<h3 class=\"ytc_title\"
|
|
|
694 |
|
695 |
-
//
|
696 |
-
$ytc_vid = "ytc_$
|
697 |
|
698 |
-
//
|
699 |
$youtube_domain = $this->youtube_domain($instance);
|
700 |
|
701 |
-
//
|
702 |
-
if ( $
|
703 |
-
|
704 |
-
|
705 |
-
if ( empty($instance['no_thumb_title']) )
|
706 |
-
$title = sprintf( __('Watch video %1$s published on %2$s', 'youtube-channel' ), $yt_title, $yt_date );
|
707 |
-
|
708 |
-
$p = '';
|
709 |
-
if ( $norel ) $p .= '&rel=0';
|
710 |
-
if ( $modestbranding ) $p .= "&modestbranding=1";
|
711 |
-
if ( $controls ) $p .= "&controls=0";
|
712 |
-
|
713 |
-
// Do we need thumbnail w/ or w/o tooltip
|
714 |
-
if ( empty($instance['no_thumb_title']) ) {
|
715 |
-
$output[] = "<a href=\"${yt_video}${p}\" title=\"$yt_title\" class=\"ytc_thumb ytc-lightbox $arclass\"><span style=\"background-image: url($yt_thumb);\" title=\"$title\" id=\"$ytc_vid\"></span></a>";
|
716 |
-
} else {
|
717 |
-
$output[] = "<a href=\"${yt_video}${p}\" class=\"ytc_thumb ytc-lightbox $arclass\"><span style=\"background-image: url($yt_thumb);\" id=\"$ytc_vid\"></span></a>";
|
718 |
}
|
719 |
-
} else if ( $to_show == "chromeless" ) {
|
720 |
-
// This should be removed
|
721 |
-
ob_start();
|
722 |
-
?>
|
723 |
-
<object type="application/x-shockwave-flash" data="<?php echo $this->plugin_url . 'inc/chromeless.swf'; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" id="<?php echo $ytc_vid; ?>">
|
724 |
-
<param name="flashVars" value="video_source=<?php echo $yt_id; ?>&video_width=<?php echo $width; ?>&video_height=<?php
|
725 |
-
echo $height;
|
726 |
-
if ( $autoplay ) echo "&autoplay=Yes";
|
727 |
-
if ( !$controls ) echo "&youtube_controls=Yes";
|
728 |
-
if ( $hideanno ) echo "&iv_load_policy=3";
|
729 |
-
if ( $themelight ) echo "&theme=light";
|
730 |
-
if ( $modestbranding ) echo "&modestbranding=1";
|
731 |
-
if ( $norel ) echo "&rel=0";
|
732 |
-
?>" />
|
733 |
-
<param name="quality" value="high" />
|
734 |
-
<param name="wmode" value="opaque" />
|
735 |
-
<param name="swfversion" value="6.0.65.0" />
|
736 |
-
<param name="movie" value="<?php echo $this->plugin_url . 'chromeless.swf'; ?>" />
|
737 |
-
</object>
|
738 |
-
<?php
|
739 |
-
$output[] = ob_get_contents();
|
740 |
-
ob_end_clean();
|
741 |
-
} else if ( $to_show == "iframe" ) {
|
742 |
-
if ( empty($usepl) ) $yt_url = $yt_id;
|
743 |
|
744 |
// Start wrapper for responsive item
|
745 |
-
if ( $instance['responsive'] )
|
|
|
|
|
746 |
|
747 |
-
|
748 |
-
$output[] = "<iframe title=\"YouTube video player\" width=\"$width\" height=\"$height\" src=\"//${youtube_domain}/embed/${yt_url}?wmode=opaque";
|
749 |
if ( $controls ) $output[] = "&controls=0";
|
750 |
if ( $hideinfo ) $output[] = "&showinfo=0";
|
751 |
if ( $autoplay ) $output[] = "&autoplay=1";
|
@@ -755,12 +899,14 @@ function ytc_mute(event){
|
|
755 |
// disable related videos
|
756 |
if ( $norel ) $output[] = "&rel=0";
|
757 |
|
758 |
-
$output[] = "\" style=\"border:
|
759 |
|
760 |
// Close wrapper for responsive item
|
761 |
-
if ( $instance['responsive'] )
|
|
|
|
|
762 |
|
763 |
-
} else if ( $
|
764 |
|
765 |
// youtube API async
|
766 |
if ( empty($usepl) ) $yt_url = $yt_id;
|
@@ -776,15 +922,17 @@ function ytc_mute(event){
|
|
776 |
$js_player_id = str_replace('-', '_', $yt_url);
|
777 |
|
778 |
// Start wrapper for responsive item
|
779 |
-
if ( $instance['responsive'] )
|
|
|
|
|
780 |
|
781 |
-
|
782 |
-
$output[] = "<div id=\"ytc_player_${js_player_id}\"></div>";
|
783 |
|
784 |
// Close wrapper for responsive item
|
785 |
-
if ( $instance['responsive'] )
|
|
|
|
|
786 |
|
787 |
-
// Prepare JS for async
|
788 |
$site_domain = $_SERVER['HTTP_HOST'];
|
789 |
$ytc_html5_js = <<<JS
|
790 |
var ytc_player_$js_player_id;
|
@@ -807,70 +955,64 @@ JS;
|
|
807 |
else
|
808 |
$_SESSION['ytc_html5_js'] .= $ytc_html5_js;
|
809 |
|
810 |
-
} else { // default is
|
811 |
-
|
812 |
-
// This will be deprecated since next release 3.0.0 and iframe will be default fallback
|
813 |
-
$obj_url = '//'.$youtube_domain.'/'.$yt_url.'?version=3';
|
814 |
-
$obj_url .= ( $controls ) ? '&controls=0' : '';
|
815 |
-
$obj_url .= ( $hideinfo ) ? '&showinfo=0' : '';
|
816 |
-
$obj_url .= ( $autoplay ) ? '&autoplay=1' : '';
|
817 |
-
$obj_url .= ( $hideanno ) ? '&iv_load_policy=3' : '';
|
818 |
-
$obj_url .= ( $themelight ) ? '&theme=light' : '';
|
819 |
-
$obj_url .= ( $modestbranding ) ? '&modestbranding=1' : '';
|
820 |
-
$obj_url .= ( $norel ) ? '&rel=0' : '';
|
821 |
-
ob_start();
|
822 |
-
?>
|
823 |
-
<object width="<?php echo $width; ?>" height="<?php echo $height; ?>" type="application/x-shockwave-flash" data="<?php echo $obj_url; ?>">
|
824 |
-
<param name="movie" value="<?php echo $obj_url; ?>" />
|
825 |
-
<param name="allowFullScreen" value="true" />
|
826 |
-
<param name="allowscriptaccess" value="always" />
|
827 |
-
<param name="quality" value="high" />
|
828 |
-
<param name="wmode" value="opaque" />
|
829 |
-
<embed src="<?php echo $obj_url; ?>" type="application/x-shockwave-flash" width="<?php echo $width; ?>" height="<?php echo $height; ?>" allowscriptaccess="always" allowfullscreen="true" />
|
830 |
-
</object>
|
831 |
-
|
832 |
-
<?php
|
833 |
-
$output[] = ob_get_contents();
|
834 |
-
ob_end_clean();
|
835 |
-
}
|
836 |
|
837 |
-
|
838 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
839 |
|
840 |
-
|
841 |
-
if ( empty($
|
842 |
-
$
|
843 |
}
|
844 |
|
845 |
-
|
846 |
-
$
|
847 |
-
if (
|
848 |
-
|
849 |
-
|
|
|
|
|
|
|
850 |
} else {
|
851 |
-
$
|
852 |
}
|
853 |
|
854 |
-
|
855 |
-
|
856 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
857 |
if ( $instance['descappend'] ) {
|
858 |
$etcetera = $instance['descappend'];
|
859 |
} else {
|
860 |
$etcetera = '…';
|
861 |
}
|
862 |
}
|
863 |
-
} else {
|
864 |
-
$video_description = $videsc[1];
|
865 |
-
$etcetera = '';
|
866 |
}
|
867 |
-
|
868 |
-
|
|
|
|
|
|
|
869 |
}
|
|
|
870 |
$output[] = '</div><!-- .ytc_video_container -->';
|
871 |
|
872 |
return $output;
|
873 |
-
} //
|
874 |
|
875 |
/* function to print standard playlist embed code */
|
876 |
function ytc_only_pl($instance) {
|
@@ -882,7 +1024,6 @@ JS;
|
|
882 |
$playlist = (empty($instance['playlist'])) ? $this->playlist_id : $instance['playlist'];
|
883 |
|
884 |
$height = self::height_ratio($width, $instance['ratio']);
|
885 |
-
$height += ($instance['fixyt']) ? 54 : 0;
|
886 |
|
887 |
$playlist = $this->clean_playlist_id($playlist);
|
888 |
|
@@ -894,36 +1035,11 @@ JS;
|
|
894 |
|
895 |
$rel = (empty($instance['norel'])) ? '' : '&rel=0';
|
896 |
|
897 |
-
$controls = (empty($instance['controls']) ) ? '' : '&controls=0';
|
898 |
-
$hideinfo = (empty($instance['hideinfo']) ) ? '' : '&showinfo=0';
|
899 |
-
$hideanno = (empty($instance['hideanno']) ) ? '' : '&iv_load_policy=3';
|
900 |
-
|
901 |
-
// set proper class for responsive thumbs per selected aspect ratio
|
902 |
-
switch ($instance['ratio'])
|
903 |
-
{
|
904 |
-
case 1: $arclass = 'ar4_3'; break;
|
905 |
-
case 2: $arclass = 'ar16_10'; break;
|
906 |
-
default: $arclass = 'ar16_9';
|
907 |
-
}
|
908 |
-
|
909 |
// enhanced privacy
|
910 |
$youtube_domain = $this->youtube_domain($instance);
|
911 |
-
|
912 |
-
//
|
913 |
-
|
914 |
-
|
915 |
-
// Start wrapper for responsive item
|
916 |
-
if ( $instance['responsive'] ) $output[] = '<div class="fluid-width-video-wrapper">';
|
917 |
-
|
918 |
-
// Prepare item
|
919 |
-
$output[] = "<iframe src=\"//$youtube_domain/embed/videoseries?list=PL${playlist}${autoplay}${theme}${modestbranding}${rel}${controls}${hideinfo}${hideanno}\" width=\"$width\" height=\"$height\" frameborder=\"0\"></iframe>";
|
920 |
-
|
921 |
-
// Close wrapper for responsive item
|
922 |
-
if ( $instance['responsive'] ) $output[] = '</div>';
|
923 |
-
|
924 |
-
// Close element
|
925 |
-
$output[] = '</div>'; // close .ytc_video_container
|
926 |
-
|
927 |
return $output;
|
928 |
} // end function ytc_only_pl
|
929 |
|
@@ -983,7 +1099,7 @@ JS;
|
|
983 |
foreach ($timeset as $n => $s)
|
984 |
{
|
985 |
$sec = $sc * $n;
|
986 |
-
$out .=
|
987 |
unset($sec);
|
988 |
}
|
989 |
}
|
@@ -991,7 +1107,7 @@ JS;
|
|
991 |
} // end function cache_time
|
992 |
|
993 |
function youtube_domain($instance) {
|
994 |
-
$youtube_domain = ( !empty($instance['
|
995 |
return $youtube_domain;
|
996 |
} // end function youtube_domain
|
997 |
|
@@ -1032,8 +1148,7 @@ JS;
|
|
1032 |
'server' => $_SERVER["SERVER_SOFTWARE"],
|
1033 |
'php' => PHP_VERSION,
|
1034 |
'wp' => $wp_version,
|
1035 |
-
'ytc' =>
|
1036 |
-
'redux' => $redux,
|
1037 |
'url' => get_site_url(),
|
1038 |
'widget_id' => $for
|
1039 |
),
|
@@ -1041,7 +1156,7 @@ JS;
|
|
1041 |
);
|
1042 |
|
1043 |
// return JSON file
|
1044 |
-
header(
|
1045 |
header('Content-Type: application/json');
|
1046 |
echo json_encode($data);
|
1047 |
|
@@ -1054,5 +1169,8 @@ JS;
|
|
1054 |
} // end class
|
1055 |
} // end class check
|
1056 |
|
|
|
|
|
1057 |
global $WPAU_YOUTUBE_CHANNEL;
|
1058 |
-
|
|
2 |
/*
|
3 |
Plugin Name: YouTube Channel
|
4 |
Plugin URI: http://urosevic.net/wordpress/plugins/youtube-channel/
|
5 |
+
Description: <a href="widgets.php">Widget</a> that display latest video thumbnail or iframe (HTML5) video from YouTube Channel, Liked Videos, Favourites or Playlist.
|
6 |
Author: Aleksandar Urošević
|
7 |
+
Version: 3.0.0
|
8 |
Author URI: http://urosevic.net/
|
9 |
*/
|
10 |
+
// @TODO make FitVideo optional
|
11 |
|
12 |
// Exit if accessed directly
|
13 |
if ( ! defined( 'ABSPATH' ) ) exit;
|
17 |
class WPAU_YOUTUBE_CHANNEL
|
18 |
{
|
19 |
|
20 |
+
const DB_VER = 3;
|
21 |
+
const VER = '3.0.0';
|
22 |
+
|
23 |
+
public $plugin_name = "YouTube Channel";
|
24 |
+
public $plugin_slug = "youtube-channel";
|
25 |
+
|
26 |
+
public $plugin_option = "youtube_channel_defaults";
|
27 |
+
|
28 |
+
public $vanity_id = "AleksandarUrosevic";
|
29 |
+
public $username_id = "urkekg";
|
30 |
+
// user channel UC
|
31 |
+
// favourites list FL
|
32 |
+
// liked list LL
|
33 |
+
public $channel_id = "UCRPqmcpGcJ_gFtTmN_a4aVA";
|
34 |
+
public $playlist_id = "PLEC850BE962234400";
|
35 |
public $plugin_url;
|
36 |
|
37 |
+
/**
|
38 |
+
* Construct class
|
39 |
+
*/
|
40 |
+
function __construct() {
|
41 |
+
|
42 |
+
$this->plugin_url = plugin_dir_url(__FILE__);
|
43 |
+
load_plugin_textdomain( $this->plugin_slug, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
44 |
|
45 |
// debug JSON
|
46 |
+
if ( ! empty($_GET['ytc_debug_json_for']) )
|
47 |
$this->generate_debug_json();
|
48 |
|
49 |
+
// Activation hook and maybe update trigger
|
50 |
+
register_activation_hook( __FILE__, array($this, 'activate') );
|
51 |
+
add_action( 'plugins_loaded', array($this, 'maybe_update') );
|
52 |
+
|
53 |
+
$this->defaults = self::defaults();
|
54 |
+
|
55 |
+
if ( is_admin() ) {
|
56 |
+
|
57 |
+
// Initialize Plugin Settings Magic
|
58 |
+
add_action( 'init', array($this, 'admin_init') );
|
59 |
+
|
60 |
+
// Add various Dashboard notices (if needed)
|
61 |
+
add_action( 'admin_notices', array($this, 'admin_notices') );
|
62 |
|
63 |
+
// Enqueue scripts and styles for Widgets page
|
64 |
+
add_action('admin_enqueue_scripts', array($this, 'widget_scripts'));
|
65 |
|
66 |
+
} else { // ELSE if ( is_admin() )
|
|
|
|
|
67 |
|
68 |
+
// Enqueue frontend scripts
|
69 |
+
add_action( 'wp_enqueue_scripts', array($this, 'enqueue_scripts') );
|
70 |
+
add_action( 'wp_footer', array($this, 'footer_scripts') );
|
71 |
+
|
72 |
+
} // END if ( is_admin() )
|
73 |
+
|
74 |
+
// Load widget
|
75 |
require_once('inc/widget.php');
|
76 |
|
77 |
+
// Register shortcodes `youtube_channel` and `ytc`
|
78 |
add_shortcode( 'youtube_channel', array($this, 'shortcode') );
|
79 |
add_shortcode( 'ytc', array($this, 'shortcode') );
|
80 |
|
81 |
+
} // END function __construct()
|
|
|
|
|
|
|
82 |
|
83 |
+
/**
|
84 |
+
* Activate the plugin
|
85 |
+
* Credits: http://solislab.com/blog/plugin-activation-checklist/#update-routines
|
86 |
+
*/
|
87 |
+
public static function activate() {
|
88 |
|
89 |
+
$this->init_options();
|
90 |
+
$this->maybe_update();
|
|
|
91 |
|
92 |
+
} // end function activate
|
|
|
|
|
93 |
|
94 |
+
/**
|
95 |
+
* Return initial options
|
96 |
+
* @return array Global defaults for current plugin version
|
97 |
+
*/
|
98 |
+
public function init_options() {
|
99 |
+
update_option('youtube_channel_version', self::VER);
|
100 |
+
add_option('youtube_channel_db_ver', self::DB_VER);
|
101 |
|
102 |
+
$init = array(
|
103 |
+
'vanity' => $this->vanity_id,
|
104 |
+
'channel' => $this->channel_id,
|
105 |
+
'username' => $this->username_id,
|
106 |
+
'playlist' => $this->playlist_id,
|
107 |
+
'resource' => 0, // ex use_res
|
108 |
+
'only_pl' => 0,
|
109 |
+
'cache' => 300, // 5 minutes // ex cache_time
|
110 |
+
'fetch' => 25, // ex maxrnd
|
111 |
+
'num' => 1, // ex vidqty
|
112 |
+
'privacy' => 0,
|
113 |
+
'random' => 0, // ex getrnd
|
114 |
+
|
115 |
+
'ratio' => 3, // 3 - 16:9, 1 - 4:3 (deprecated: 2 - 16:10)
|
116 |
+
'width' => 306,
|
117 |
+
'responsive' => true,
|
118 |
+
'display' => 'thumbnail', // thumbnail, iframe, iframe2 (deprecated: chromeless, object)
|
119 |
+
'themelight' => 0,
|
120 |
+
'controls' => 0,
|
121 |
+
'autoplay' => 0,
|
122 |
+
'autoplay_mute' => 0,
|
123 |
+
'norel' => 0,
|
124 |
+
|
125 |
+
'showtitle' => 0,
|
126 |
+
'showdesc' => 0,
|
127 |
+
'desclen' => 0,
|
128 |
+
'descappend' => '…',
|
129 |
+
'modestbranding' => 0,
|
130 |
+
'hideanno' => 0,
|
131 |
+
'hideinfo' => 0,
|
132 |
|
133 |
+
'goto_txt' => 'Visit our channel',
|
134 |
+
'showgoto' => 0,
|
135 |
+
'popup_goto' => 0, // 0 same window, 1 new window JS, 2 new window target
|
136 |
+
'link_to' => 0 // 0 legacy username, 1 channel, 2 vanity
|
137 |
+
);
|
138 |
|
139 |
+
add_option('youtube_channel_ver', self::VER, '', 'no');
|
140 |
+
add_option('youtube_channel_db_ver', self::DB_VER, '', 'no');
|
141 |
+
add_option($this->plugin_option, $init, '', 'no');
|
142 |
|
143 |
+
} // END public function init_options()
|
|
|
144 |
|
145 |
+
/**
|
146 |
+
* Check do we need to migrate options
|
147 |
+
*/
|
148 |
+
public function maybe_update() {
|
|
|
149 |
|
150 |
+
// bail if this plugin data doesn't need updating
|
151 |
+
if ( get_option( 'youtube_channel_db_ver' ) >= self::DB_VER ) {
|
152 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
153 |
}
|
154 |
|
155 |
+
require_once( __DIR__ . '/update.php' );
|
156 |
+
au_youtube_channel_update();
|
157 |
|
158 |
+
} // END public function maybe_update()
|
|
|
|
|
159 |
|
160 |
+
/**
|
161 |
+
* Initialize Settings link for Plugins page and create Settings page
|
162 |
+
*/
|
163 |
+
function admin_init() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
+
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'add_settings_link') );
|
|
|
|
|
|
|
|
|
166 |
|
167 |
+
require_once( 'inc/settings.php' );
|
168 |
+
|
169 |
+
global $WPAU_YOUTUBE_CHANNEL_SETTINGS;
|
170 |
+
if ( empty($WPAU_YOUTUBE_CHANNEL_SETTINGS) )
|
171 |
+
$WPAU_YOUTUBE_CHANNEL_SETTINGS = new WPAU_YOUTUBE_CHANNEL_SETTINGS();
|
172 |
+
|
173 |
+
} // END function admin_init_settings()
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Append Settings link for Plugins page
|
177 |
+
* @param array $links array of links on plugins page
|
178 |
+
*/
|
179 |
+
function add_settings_link($links) {
|
180 |
+
|
181 |
+
$settings_title = __('Settings');
|
182 |
+
$settings_link = "<a href=\"options-general.php?page={$this->plugin_slug}\">{$settings_title}</a>";
|
183 |
array_unshift( $links, $settings_link );
|
184 |
+
|
185 |
+
// Free some memory
|
186 |
+
unset($settings_title, $settings_link);
|
187 |
+
|
188 |
+
// Return updated array of links
|
189 |
return $links;
|
|
|
190 |
|
191 |
+
} // END function add_settings_link()
|
|
|
192 |
|
193 |
+
/**
|
194 |
+
* Enqueue admin scripts and styles for widget customization
|
195 |
+
*/
|
196 |
+
function widget_scripts() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
|
198 |
+
global $pagenow;
|
199 |
+
|
200 |
+
// Enqueue only on widget page
|
201 |
+
if( $pagenow !== 'widgets.php' && $pagenow !== 'customize.php' ) return;
|
202 |
+
|
203 |
+
wp_enqueue_script(
|
204 |
+
$this->plugin_slug . '-admin',
|
205 |
+
plugins_url( 'assets/js/admin.min.js', __FILE__ ),
|
206 |
+
array('jquery'),
|
207 |
+
self::VER
|
208 |
+
);
|
209 |
+
wp_enqueue_style(
|
210 |
+
$this->plugin_slug . '-admin',
|
211 |
+
plugins_url( 'assets/css/admin.css', __FILE__ ),
|
212 |
+
array(),
|
213 |
+
self::VER
|
214 |
);
|
|
|
215 |
|
216 |
+
} // END function widget_scripts()
|
|
|
|
|
|
|
217 |
|
218 |
/**
|
219 |
+
* Print dashboard notice
|
220 |
+
* @return string Formatted notice with usefull explanation
|
221 |
*/
|
222 |
+
function admin_notices() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
|
224 |
+
// Get array of dismissed notices
|
225 |
+
$dismissed_notices = get_option('youtube_channel_dismissed_notices');
|
226 |
|
227 |
+
// Dismiss notices if requested and then update option in DB
|
228 |
+
if ( ! empty($_GET['ytc_dismiss_notice_old_php']) ) {
|
229 |
+
$dismissed_notices['old_php'] = 1;
|
230 |
+
update_option('youtube_channel_dismissed_notices', $dismissed_notices);
|
231 |
+
}
|
232 |
+
if ( ! empty($_GET['ytc_dismiss_notice_vanity_option']) ) {
|
233 |
+
$dismissed_notices['vanity_option'] = 1;
|
234 |
+
update_option('youtube_channel_dismissed_notices', $dismissed_notices);
|
235 |
+
}
|
236 |
|
237 |
+
// Prepare vars for notices
|
238 |
+
$settings_page = 'options-general.php?page=youtube-channel';
|
239 |
+
$notice = array(
|
240 |
+
'error' => '',
|
241 |
+
'warning' => '',
|
242 |
+
'info' => ''
|
243 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
|
245 |
+
// Warn if PHP version is lower than 5.3
|
246 |
+
if ( version_compare(PHP_VERSION, "5.3", "<") && ( empty($dismissed_notices) || ( ! empty($dismissed_notices) && empty($dismissed_notices['old_php']) ) ) ) {
|
247 |
+
$notice['info'] .= sprintf(
|
248 |
+
__('<p>Your website running on web server with PHP version %s. Please note that <strong>%s</strong> requires PHP at least 5.3 or newer to work properly. <a href="%s" class="dismiss">Dismiss</a></p>', 'youtube-channel'),
|
249 |
+
PHP_VERSION,
|
250 |
+
$this->plugin_name,
|
251 |
+
'?ytc_dismiss_notice_old_php=1'
|
252 |
+
);
|
253 |
+
}
|
254 |
|
255 |
+
// No YouTube DATA Api Key?
|
256 |
+
if ( ! defined('YOUTUBE_DATA_API_KEY') ) {
|
257 |
+
$notice['error'] .= sprintf(
|
258 |
+
__('<p>Please note, to make <strong>%s</strong> plugin v3+ work, generate <strong>YouTube Data API Key</strong> and add it to <strong>wp-config.php</strong> file as we explained <a href="%s" target="_blank">here</a>.<br>If you already did this during <em>3.0.0-Alpha</em> test period, please rename constant name from <strong>GOOGLE_API_KEY</strong> to <strong>%s</strong>.<br><br>If you have any issue with new version of plugin, please ask for help on official <a href="%s" target="_blank">support forum</a>.<br>This notice will disappear when you add missing key as mentioned above!</p>', 'youtube-channel'),
|
259 |
+
$this->plugin_name,
|
260 |
+
'http://urosevic.net/wordpress/plugins/youtube-channel/#youtube_data_api_key',
|
261 |
+
'YOUTUBE_DATA_API_KEY',
|
262 |
+
'https://wordpress.org/support/plugin/youtube-channel'
|
263 |
+
);
|
264 |
+
}
|
265 |
|
266 |
+
if ( empty($dismissed_notices) || ( ! empty($dismissed_notices) && empty($dismissed_notices['vanity_option']) ) ) {
|
267 |
+
$notice['warning'] .= sprintf(
|
268 |
+
__('<p><strong>%s</strong> since version 2.4 supports linking to channel through <em>Vanity/Custom</em> URL. Please review <a href="%s">global</a> and <a href="%s">widgets</a> settings. <a href="%s" class="dismiss">Dismiss</a>', 'youtube-channel'),
|
269 |
+
$this->plugin_name,
|
270 |
+
$settings_page,
|
271 |
+
'widgets.php',
|
272 |
+
'?ytc_dismiss_notice_vanity_option=1'
|
273 |
+
);
|
274 |
+
}
|
275 |
|
276 |
+
foreach ( $notice as $type => $message ) {
|
277 |
+
if ( ! empty($message) ) {
|
278 |
+
echo "<div class=\"notice notice-{$type}\">{$message}</div>";
|
279 |
+
}
|
280 |
+
}
|
281 |
|
282 |
+
} // END function admin_notices()
|
|
|
283 |
|
284 |
+
/**
|
285 |
+
* Get default options from DB
|
286 |
+
* @return array Latest global defaults
|
287 |
+
*/
|
288 |
+
public function defaults() {
|
289 |
|
290 |
+
$defaults = get_option($this->plugin_option);
|
291 |
+
if ( empty($defaults) ) {
|
292 |
+
$this->init_options();
|
293 |
+
}
|
294 |
|
295 |
+
return $defaults;
|
296 |
|
297 |
+
}
|
298 |
|
299 |
function enqueue_scripts() {
|
300 |
+
wp_enqueue_style( 'youtube-channel', plugins_url('assets/css/youtube-channel.min.css', __FILE__), array(), self::VER );
|
301 |
|
302 |
// enqueue fitVids
|
303 |
+
wp_enqueue_script( 'fitvids', plugins_url('assets/js/jquery.fitvids.min.js', __FILE__), array('jquery'), self::VER, true );
|
304 |
|
305 |
// enqueue magnific-popup
|
306 |
+
wp_enqueue_script( 'magnific-popup-au', plugins_url('assets/lib/magnific-popup/jquery.magnific-popup.min.js', __FILE__), array('jquery'), self::VER, true );
|
307 |
+
wp_enqueue_style( 'magnific-popup-au', plugins_url('assets/lib/magnific-popup/magnific-popup.min.css', __FILE__), array(), self::VER );
|
308 |
+
wp_enqueue_script( 'youtube-channel', plugins_url('assets/js/youtube-channel.min.js', __FILE__), array(), self::VER, true );
|
309 |
} // end function enqueue_scripts
|
310 |
|
311 |
function footer_scripts() {
|
312 |
// Print JS only if we have set YTC array
|
313 |
+
if ( ! empty($_SESSION['ytc_html5_js']) )
|
314 |
{
|
315 |
+
?>
|
316 |
+
<!-- YouTube Channel v<?php echo self::VER; ?> -->
|
317 |
<script type="text/javascript">
|
318 |
var tag = document.createElement('script');
|
319 |
tag.src = "//www.youtube.com/iframe_api";
|
331 |
|
332 |
} // eof footer_scripts
|
333 |
|
334 |
+
public function shortcode($atts) {
|
335 |
+
|
336 |
// get general default settings
|
337 |
$instance = $this->defaults();
|
338 |
|
340 |
extract(
|
341 |
shortcode_atts(
|
342 |
array(
|
343 |
+
'vanity' => $instance['vanity'],
|
344 |
'channel' => $instance['channel'],
|
345 |
+
'username' => $instance['username'],
|
346 |
'playlist' => $instance['playlist'],
|
347 |
+
'res' => $instance['resource'], // (deprecated, but leave for back compatibility) ex use_res
|
348 |
+
'resource' => $instance['resource'], // ex use_res
|
349 |
'only_pl' => $instance['only_pl'],
|
350 |
+
'cache' => $instance['cache'], // ex cache_time
|
351 |
+
'privacy' => $instance['privacy'], // ex showvidesc
|
352 |
+
'fetch' => $instance['fetch'], // ex maxrnd
|
353 |
+
'num' => $instance['num'], // ex vidqty
|
354 |
|
355 |
+
'random' => $instance['random'], // ex getrnd
|
|
|
|
|
|
|
|
|
356 |
|
357 |
'ratio' => $instance['ratio'],
|
358 |
'width' => $instance['width'],
|
359 |
+
'responsive' => ( ! empty($instance['responsive']) ) ? $instance['responsive'] : '0',
|
|
|
|
|
|
|
360 |
|
361 |
+
'show' => $instance['display'], // (deprecated, but keep for back compatibility) ex to_show
|
362 |
+
'display' => $instance['display'],
|
363 |
+
'no_thumb_title' => 0,
|
364 |
'themelight' => $instance['themelight'],
|
365 |
'controls' => $instance['controls'],
|
|
|
366 |
'autoplay' => $instance['autoplay'],
|
367 |
'mute' => $instance['autoplay_mute'],
|
368 |
'norel' => $instance['norel'],
|
369 |
|
370 |
'showtitle' => $instance['showtitle'],
|
371 |
+
'showdesc' => $instance['showdesc'], // ex showvidesc
|
372 |
+
'nobrand' => ( ! empty($instance['modestbranding']) ) ? $instance['modestbranding'] : '0',
|
373 |
+
'desclen' => $instance['desclen'], // ex videsclen
|
374 |
'noinfo' => $instance['hideinfo'],
|
375 |
'noanno' => $instance['hideanno'],
|
376 |
|
377 |
'goto' => $instance['showgoto'],
|
378 |
'goto_txt' => $instance['goto_txt'],
|
379 |
'popup' => $instance['popup_goto'],
|
380 |
+
'link_to' => $instance['link_to'],
|
381 |
|
382 |
+
'class' => ( ! empty($instance['class']) ) ? $instance['class'] : ''
|
383 |
+
),
|
384 |
$atts
|
385 |
)
|
386 |
);
|
387 |
|
388 |
// prepare instance for output
|
389 |
+
$instance['vanity'] = $vanity;
|
390 |
+
$instance['channel'] = $channel;
|
391 |
+
$instance['username'] = $username;
|
392 |
+
$instance['playlist'] = $playlist;
|
393 |
+
$instance['resource'] = $resource; // resource: 0 channel, 1 favorites, 2 playlist
|
394 |
+
$instance['only_pl'] = $only_pl; // use embedded playlist - false by default
|
395 |
+
$instance['cache'] = $cache; // in seconds, def 5min - settings?
|
396 |
+
$instance['privacy'] = $privacy; // enhanced privacy
|
397 |
|
398 |
+
$instance['fetch'] = $fetch;
|
399 |
+
$instance['num'] = $num; // num: 1
|
400 |
|
401 |
+
$instance['random'] = $random; // use embedded playlist - false by default
|
|
|
402 |
|
403 |
// Video Settings
|
404 |
+
$instance['ratio'] = $ratio; // aspect ratio: 3 - 16:9, 2 - 16:10, 1 - 4:3
|
405 |
+
$instance['width'] = $width; // 306
|
406 |
+
$instance['responsive'] = $responsive; // enable responsivenes?
|
407 |
+
$instance['display'] = $display; // thumbnail, iframe, iframe2
|
408 |
+
$instance['no_thumb_title'] = $no_thumb_title; // hide tooltip for thumbnails
|
409 |
+
|
410 |
+
$instance['themelight'] = $themelight; // use light theme, dark by default
|
411 |
+
$instance['controls'] = $controls; // hide controls, false by default
|
412 |
+
$instance['autoplay'] = $autoplay; // autoplay disabled by default
|
413 |
+
$instance['autoplay_mute'] = $mute; // mute sound on autoplay - disabled by default
|
414 |
+
$instance['norel'] = $norel; // hide related videos
|
|
|
415 |
|
416 |
// Content Layout
|
417 |
+
$instance['showtitle'] = $showtitle; // show video title, disabled by default
|
418 |
+
$instance['showdesc'] = $showdesc; // show video description, disabled by default
|
419 |
+
$instance['modestbranding'] = $nobrand; // hide YT logo
|
420 |
+
$instance['desclen'] = $desclen; // cut video description, number of characters
|
421 |
+
$instance['hideinfo'] = $noinfo; // hide info by default
|
422 |
+
$instance['hideanno'] = $noanno; // hide annotations, false by default
|
423 |
|
424 |
// Link to Channel
|
425 |
+
$instance['showgoto'] = $goto; // show goto link, disabled by default
|
426 |
+
$instance['goto_txt'] = $goto_txt; // text for goto link - use settings
|
427 |
+
$instance['popup_goto'] = $popup; // open channel in: 0 same window, 1 javascript new, 2 target new
|
428 |
+
$instance['link_to'] = $link_to; // open channel in: 0 same window, 1 javascript new, 2 target new
|
429 |
+
//$instance['userchan'] = $userchan; // DEPRECATED link to user channel instaled page
|
430 |
|
431 |
// Customization
|
432 |
+
$instance['class'] = $class; // custom additional class for container
|
433 |
|
434 |
return implode(array_values($this->output($instance)));
|
435 |
+
} // END public function shortcode()
|
436 |
+
|
437 |
+
// Print out YTC block
|
438 |
+
public function output($instance) {
|
439 |
+
|
440 |
+
// print info about API key to admins
|
441 |
+
// and "Coming soon..." for visitors
|
442 |
+
if ( ! defined('YOUTUBE_DATA_API_KEY') ) {
|
443 |
+
if ( current_user_can('manage_options') ) {
|
444 |
+
return array(
|
445 |
+
__sprintf('<strong>%s</strong> version 3+ requires <strong>YouTube DATA API Key</strong> to work. <a href="%s" target="_blank">Learn more here</a>.', 'youtube-channel'),
|
446 |
+
$this->plugin_name,
|
447 |
+
'http://urosevic.net/wordpress/plugins/youtube-channel/#youtube_data_api_key'
|
448 |
+
);
|
449 |
+
} else {
|
450 |
+
return array("Coming soon...");
|
451 |
+
}
|
452 |
+
}
|
453 |
|
454 |
+
// 1) Get resource from widget/shortcode
|
455 |
+
// 2) If not set, get global default
|
456 |
+
// 3) if no global, get plugin's default
|
457 |
+
$resource = intval($instance['resource']);
|
458 |
+
if ( empty($resource) && $resource !== 0 ) {
|
459 |
+
$resource = intval($this->defaults['resource']);
|
460 |
+
if ( empty($resource) ) {
|
461 |
+
$resource = 0;
|
462 |
+
}
|
463 |
+
}
|
464 |
|
465 |
+
// Get Channel or Playlist ID based on requested resource
|
466 |
+
switch ($resource) {
|
|
|
467 |
|
468 |
+
// Playlist
|
469 |
+
case '3':
|
470 |
+
// 1) Get Playlist from shortcode/widget
|
471 |
+
// 2) If not set, use global default
|
472 |
+
// 3) If no global, use plugin's default
|
473 |
+
if ( ! empty($instance['playlist']) ) {
|
474 |
+
$playlist = trim($instance['playlist']);
|
475 |
+
} else {
|
476 |
+
$playlist = trim($this->defaults['playlist']);
|
477 |
+
if ( $playlist == "" ) {
|
478 |
+
$playlist = trim($this->playlist_id);
|
479 |
+
}
|
480 |
+
}
|
481 |
+
break;
|
482 |
|
483 |
+
// Channel, Favourites, Liked
|
484 |
+
default:
|
485 |
+
/* Channel */
|
486 |
+
// 1) Get channel from shortcode/widget
|
487 |
+
// 2) If not set, use global default
|
488 |
+
// 3) If no global, use plugin's default
|
489 |
+
if ( ! empty($instance['channel']) ) {
|
490 |
+
$channel = trim($instance['channel']);
|
491 |
+
} else {
|
492 |
+
$channel = trim($this->defaults['channel']);
|
493 |
+
if ( empty($channel) ) {
|
494 |
+
$channel = trim($this->channel_id);
|
495 |
+
}
|
496 |
+
}
|
497 |
|
498 |
+
} // END switch ($resource)
|
499 |
|
500 |
+
// Set custom class and responsive if needed
|
501 |
+
$class = $instance['class'] ? $instance['class'] : 'default';
|
502 |
+
if ( ! empty($instance['responsive']) ) {
|
503 |
+
$class .= ' responsive';
|
504 |
+
}
|
505 |
|
506 |
+
// Start output array
|
507 |
$output = array();
|
508 |
|
509 |
+
$output[] = "<div class=\"youtube_channel {$class}\">";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
510 |
|
511 |
+
if ( $instance['only_pl'] && $resource == 2 ) { // print standard playlist
|
|
|
512 |
|
513 |
+
$output = array_merge($output, self::ytc_only_pl($instance));
|
|
|
514 |
|
515 |
+
} else { // videos from channel, favourites, liked or playlist
|
|
|
516 |
|
517 |
+
// get max items for random video
|
518 |
+
$fetch = $instance['fetch'];
|
519 |
+
if ( $fetch < 1 ) { $fetch = 10; } // default 10
|
520 |
+
elseif ( $fetch > 50 ) { $fetch = 50; } // max 50
|
521 |
+
|
522 |
+
switch ($resource) {
|
523 |
+
case 1: // Favourites
|
524 |
+
$resource_name = 'favourites';
|
525 |
+
$resource_id = preg_replace('/^UC/', 'FL', $channel);
|
526 |
break;
|
527 |
+
case 2: // Playlist
|
528 |
+
$resource_name = 'playlist';
|
529 |
+
$resource_id = $playlist;
|
530 |
break;
|
531 |
+
case 3: // Liked
|
532 |
+
$resource_name = 'liked';
|
533 |
+
$resource_id = preg_replace('/^UC/', 'LL', $channel);
|
534 |
+
break;
|
535 |
+
default: // Channel
|
536 |
+
$resource_name = 'channel';
|
537 |
+
$resource_id = $channel;
|
538 |
}
|
539 |
+
$resource_key = "{$resource_id}_{$fetch}";
|
540 |
+
|
541 |
+
// Do we need cache? let we define cache fallback key
|
542 |
+
$cache_key_fallback = 'ytc_' . md5($resource_key) . '_fallback';
|
543 |
+
|
544 |
+
// Do cache magic
|
545 |
+
if ( $instance['cache'] > 0 ) {
|
546 |
|
|
|
|
|
547 |
// generate feed cache key for caching time
|
548 |
+
$cache_key = 'ytc_'.md5($resource_key).'_'.$instance['cache'];
|
|
|
549 |
|
550 |
+
if ( ! empty($_GET['ytc_force_recache']) )
|
551 |
delete_transient($cache_key);
|
552 |
|
553 |
// get/set transient cache
|
554 |
+
if ( false === ($json = get_transient($cache_key)) || empty($json) ) {
|
555 |
+
|
556 |
// no cached JSON, get new
|
557 |
+
$json = $this->fetch_youtube_feed($resource_name, $resource_id, $fetch);
|
|
|
|
|
|
|
|
|
558 |
|
559 |
// set decoded JSON to transient cache_key
|
560 |
+
set_transient($cache_key, base64_encode($json), $instance['cache']);
|
561 |
+
|
562 |
} else {
|
563 |
+
|
564 |
// we already have cached feed JSON, get it encoded
|
565 |
$json = base64_decode($json);
|
566 |
+
|
567 |
}
|
568 |
+
|
569 |
} else {
|
570 |
+
|
571 |
// just get fresh feed if cache disabled
|
572 |
+
$json = $this->fetch_youtube_feed($resource_name, $resource_id, $fetch);
|
573 |
+
|
|
|
|
|
|
|
574 |
}
|
575 |
|
576 |
+
// free some memory
|
577 |
+
unset( $response );
|
578 |
+
|
579 |
// decode JSON data
|
580 |
$json_output = json_decode($json);
|
581 |
|
582 |
+
// if current feed is messed up, try to get it from fallback cache
|
583 |
+
if ( is_wp_error($json_output) && ! is_object($json_output) && empty($json_output->items) ) {
|
584 |
+
error_log("[YTC] Get fallback feed for $feed_url");
|
585 |
+
// do we have fallback cache?!
|
586 |
+
if ( true === ( $json_fallback = get_transient( $cache_key_fallback ) ) && ! empty($json_fallback) ) {
|
587 |
+
$json_output = json_decode( base64_decode($json_fallback) );
|
588 |
+
// and free memory
|
589 |
+
unset( $json_fallback );
|
590 |
+
}
|
591 |
+
}
|
592 |
+
|
593 |
+
// Predefine `max_items` to prevent undefined notices
|
594 |
+
$max_items = 0;
|
595 |
+
if ( ! is_wp_error($json_output) && is_object($json_output) && !empty($json_output->items) ) {
|
596 |
+
// Sort by date uploaded
|
597 |
+
$json_entry = $json_output->items;
|
598 |
|
599 |
+
$num = $instance['num'];
|
600 |
+
if ( $num > $fetch ) { $fetch = $num; }
|
601 |
+
$max_items = ( $fetch > sizeof($json_entry) ) ? sizeof($json_entry) : $fetch;
|
602 |
|
603 |
+
if ( ! empty($instance['random']) ) {
|
604 |
+
$items = array_slice($json_entry, 0, $max_items);
|
605 |
} else {
|
606 |
+
if ( ! $num ) $num = 1;
|
607 |
+
$items = array_slice($json_entry, 0, $num);
|
608 |
}
|
609 |
}
|
610 |
|
611 |
+
if ($max_items == 0) {
|
612 |
+
|
613 |
+
// is this WP error?
|
614 |
+
if ( is_wp_error($json_output) ) {
|
615 |
+
$error_string = $json_output->get_error_message();
|
616 |
+
$output[] = $error_string;
|
617 |
+
unset($error_string);
|
618 |
+
} else {
|
619 |
+
$output[] = __("Ups, something went wrong.", 'youtube-channel');
|
620 |
+
// append YouTube DATA API error reason as comment
|
621 |
+
if ( ! empty($json_output) && is_object($json_output) && !empty($json_output->error->errors) ) {
|
622 |
+
$output[] = "<!-- YTC ERROR:\n";
|
623 |
+
$output[] = 'domain: ' . $json_output->error->errors[0]->domain . "\n";
|
624 |
+
$output[] = 'reason: ' . $json_output->error->errors[0]->reason . "\n";
|
625 |
+
$output[] = 'message: ' . $json_output->error->errors[0]->message . "\n";
|
626 |
+
$output[] = "-->\n";
|
627 |
+
}
|
628 |
+
}
|
629 |
+
|
630 |
+
} else { // ELSE if ($max_items == 0)
|
631 |
+
|
632 |
+
// looks that feed is OK, let we update fallback that never expire
|
633 |
+
set_transient($cache_key_fallback, base64_encode($json), 0);
|
634 |
+
|
635 |
+
// and now free some memory
|
636 |
+
unset ( $json, $json_output, $json_entry );
|
637 |
|
638 |
+
// set array for unique random item
|
639 |
+
if ( ! empty($instance['random']) ) {
|
640 |
+
$random_used = array();
|
641 |
+
}
|
642 |
+
|
643 |
+
/* AU:20141230 reduce number of videos if requested > available */
|
644 |
+
if ( $num > sizeof($items) ) {
|
645 |
+
$num = sizeof($items);
|
646 |
+
}
|
647 |
|
648 |
+
for ($y = 1; $y <= $num; ++$y) {
|
649 |
+
if ( ! empty($instance['random']) ) {
|
|
|
650 |
|
651 |
+
$random_item = mt_rand( 0, (count($items)-1) );
|
652 |
+
while ( $y > 1 && in_array($random_item, $random_used) ) {
|
653 |
+
$random_item = mt_rand(0, (count($items)-1));
|
|
|
|
|
654 |
}
|
655 |
+
$random_used[] = $random_item;
|
656 |
+
$item = $items[ $random_item ];
|
657 |
} else {
|
658 |
+
$item = $items[ $y - 1 ];
|
659 |
}
|
660 |
|
661 |
// print single video block
|
662 |
$output = array_merge( $output, $this->ytc_print_video($item, $instance, $y) );
|
663 |
}
|
664 |
+
// Free some memory
|
665 |
+
unset($random_used, $random_item, $json);
|
666 |
+
|
667 |
+
} // END if ($max_items == 0)
|
668 |
|
|
|
669 |
} // single playlist or ytc way
|
670 |
|
671 |
$output = array_merge( $output, $this->ytc_channel_link($instance) ); // insert link to channel on bootom of widget
|
673 |
$output[] = '</div><!-- .youtube_channel -->';
|
674 |
|
675 |
return $output;
|
676 |
+
|
677 |
+
} // END public function output($instance)
|
678 |
|
679 |
// --- HELPER FUNCTIONS ---
|
680 |
|
681 |
+
/**
|
682 |
+
* Download YouTube video feed through API 3.0
|
683 |
+
* @param string $resource Name of resource (channel, playlist, favourites, liked)
|
684 |
+
* @param string $id ID of resource
|
685 |
+
* @param integer $items Number of items to fetch (min 2, max 50)
|
686 |
+
* @return array JSON with videos
|
687 |
+
*/
|
688 |
+
function fetch_youtube_feed($resource, $resource_id, $items) {
|
689 |
+
|
690 |
+
if ( $resource == 'channel' ) {
|
691 |
+
|
692 |
+
// channel
|
693 |
+
$feed_url = "https://www.googleapis.com/youtube/v3/search?";
|
694 |
+
$feed_url .= "part=snippet";
|
695 |
+
$feed_url .= "&channelId=" . $resource_id;
|
696 |
+
$feed_url .= "&order=date";
|
697 |
+
$feed_url .= "&type=video";
|
698 |
+
|
699 |
+
} else if ( in_array($resource, array('playlist','favourites','liked')) ) {
|
700 |
+
|
701 |
+
// playlist
|
702 |
+
$feed_url = "https://www.googleapis.com/youtube/v3/playlistItems?";
|
703 |
+
$feed_url .= "part=snippet";
|
704 |
+
$feed_url .= "&playlistId=" . $resource_id;
|
705 |
+
|
706 |
+
}
|
707 |
+
|
708 |
+
// universal
|
709 |
+
$feed_url .= "&maxResults=" . $items;
|
710 |
+
$feed_url .= "&fields=items(id%2Csnippet)";
|
711 |
+
$feed_url .= "&key=" . YOUTUBE_DATA_API_KEY;
|
712 |
+
|
713 |
+
$wprga = array(
|
714 |
+
'timeout' => 2 // two seconds only
|
715 |
+
);
|
716 |
+
$response = wp_remote_get($feed_url, $wprga);
|
717 |
+
$json = wp_remote_retrieve_body( $response );
|
718 |
+
|
719 |
+
return $json;
|
720 |
+
|
721 |
+
} // END function fetch_youtube_feed($resource, $resource_id, $items)
|
722 |
+
|
723 |
// function to calculate height by width and ratio
|
724 |
function height_ratio($width=306, $ratio) {
|
725 |
+
|
726 |
switch ($ratio)
|
727 |
{
|
728 |
case 1:
|
729 |
$height = round(($width / 4 ) * 3);
|
730 |
break;
|
731 |
case 2:
|
|
|
|
|
732 |
case 3:
|
733 |
default:
|
734 |
$height = round(($width / 16 ) * 9);
|
735 |
}
|
736 |
return $height;
|
737 |
+
} // END function height_ratio($width=306, $ratio)
|
738 |
|
739 |
+
/**
|
740 |
+
* Generate link to YouTUbe channel/user
|
741 |
+
* @param array $instance widget or shortcode settings
|
742 |
+
* @return array components prepared for output
|
743 |
+
*/
|
744 |
function ytc_channel_link($instance) {
|
745 |
+
|
746 |
// initialize array
|
747 |
$output = array();
|
748 |
+
|
749 |
// do we need to show goto link?
|
750 |
+
if ( $instance['showgoto'] ) {
|
751 |
+
|
752 |
+
$link_to = $instance['link_to'];
|
753 |
+
|
754 |
+
$channel = trim($instance['channel']);
|
755 |
+
if ( empty( $channel ) )
|
756 |
+
$channel = $this->channel_id;
|
757 |
+
|
758 |
+
$username = trim($instance['username']);
|
759 |
+
if ( empty( $username ) )
|
760 |
+
$username = $this->username_id;
|
761 |
+
|
762 |
+
// sanity vanity content (strip all in front of last slash to cleanup vanity ID only)
|
763 |
+
$vanity = trim($instance['vanity']);
|
764 |
+
if ( ! empty( $vanity ) && strpos($vanity, 'youtube.com') !== false )
|
765 |
+
$vanity = preg_replace('/^.*\//', '', $vanity);
|
766 |
+
|
767 |
+
// if $vanity is empty, use default
|
768 |
+
if ( empty( $vanity ) )
|
769 |
+
$vanity = $this->vanity_id;
|
770 |
+
|
771 |
+
$goto_txt = trim($instance['goto_txt']);
|
772 |
+
|
773 |
if ( $goto_txt == "" )
|
774 |
+
$goto_txt = __('Visit our YouTube channel', 'youtube-channel');
|
775 |
+
|
776 |
+
$goto_txt = str_replace('%username%', $username, $goto_txt);
|
777 |
+
$goto_txt = str_replace('%channel%', $channel, $goto_txt);
|
778 |
+
$goto_txt = str_replace('%vanity%', $vanity, $goto_txt);
|
779 |
|
780 |
$output[] = '<div class="ytc_link">';
|
781 |
+
|
782 |
+
$goto_url = "https://www.youtube.com/";
|
783 |
+
if ( $link_to == '2' ) { // vanity
|
784 |
+
$goto_url .= "c/$vanity";
|
785 |
+
} else if ( $link_to == '0') { // legacy username
|
786 |
+
$goto_url .= "user/$username";
|
787 |
+
} else { // channel (default)
|
788 |
+
$goto_url .= "channel/$channel";
|
789 |
+
}
|
790 |
+
|
791 |
$newtab = __("in new window/tab", 'youtube-channel');
|
792 |
+
|
793 |
$output[] = '<p>';
|
794 |
switch ( $instance['popup_goto'] ) {
|
795 |
case 1:
|
796 |
+
$output[] = '<a href="javascript: window.open(\''.$goto_url.'\'); void 0;" title="'.$goto_txt.' '.$newtab.'">'.$goto_txt.'</a>';
|
797 |
break;
|
798 |
case 2:
|
799 |
+
$output[] = '<a href="'.$goto_url.'" target="_blank" title="'.$goto_txt.' '.$newtab.'">'.$goto_txt.'</a>';
|
800 |
break;
|
801 |
default:
|
802 |
+
$output[] = '<a href="'.$goto_url.'" title="'.$goto_txt.'">'.$goto_txt.'</a>';
|
803 |
} // switch popup_goto
|
804 |
$output[] = '</p>';
|
805 |
$output[] = '</div>';
|
830 |
$imgfixedheight = $width / 4 * 3;
|
831 |
|
832 |
// which type to show
|
833 |
+
$display = (empty($instance['display'])) ? 'object' : $instance['display'];
|
|
|
|
|
|
|
|
|
|
|
834 |
$hideanno = $instance['hideanno'];
|
835 |
$themelight = $instance['themelight'];
|
836 |
/* end of video settings */
|
837 |
|
838 |
+
// from channel videoId is in own node `id`
|
839 |
+
$yt_id = ($instance['resource'] == 0) ? $item->id->videoId : $item->snippet->resourceId->videoId;
|
840 |
$yt_url = "v/$yt_id";
|
841 |
+
$yt_thumb = "//img.youtube.com/vi/$yt_id/0.jpg"; // zero for HD thumb
|
842 |
+
$yt_video = "//www.youtube.com/watch?v=" . $yt_id;
|
843 |
|
844 |
+
$yt_title = $item->snippet->title;
|
845 |
+
$yt_date = $item->snippet->publishedAt;
|
|
|
|
|
|
|
|
|
|
|
846 |
|
847 |
switch ($y) {
|
848 |
case 1:
|
849 |
$vnumclass = 'first';
|
850 |
break;
|
851 |
+
case $instance['num']:
|
852 |
$autoplay = false;
|
853 |
$vnumclass = 'last';
|
854 |
break;
|
865 |
case 2: $arclass = 'ar16_10'; break;
|
866 |
default: $arclass = 'ar16_9';
|
867 |
}
|
868 |
+
$output[] = "<div class=\"ytc_video_container ytc_video_{$y} ytc_video_{$vnumclass} ${arclass}\" style=\"width:{$width}px\">";
|
|
|
|
|
869 |
|
870 |
// show video title?
|
871 |
+
if ( ! empty($instance['showtitle']) ) {
|
872 |
+
$output[] = "<h3 class=\"ytc_title\">{$yt_title}</h3>";
|
873 |
+
}
|
874 |
|
875 |
+
// Define object ID
|
876 |
+
$ytc_vid = "ytc_{$yt_id}";
|
877 |
|
878 |
+
// Enhanced privacy?
|
879 |
$youtube_domain = $this->youtube_domain($instance);
|
880 |
|
881 |
+
// Print out video
|
882 |
+
if ( $display == "iframe" ) {
|
883 |
+
if ( empty($usepl) ) {
|
884 |
+
$yt_url = $yt_id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
885 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
886 |
|
887 |
// Start wrapper for responsive item
|
888 |
+
if ( $instance['responsive'] ) {
|
889 |
+
$output[] = '<div class="fluid-width-video-wrapper">';
|
890 |
+
}
|
891 |
|
892 |
+
$output[] = "<iframe title=\"YouTube Video Player\" width=\"{$width}\" height=\"{$height}\" src=\"//{$youtube_domain}/embed/{$yt_url}?wmode=opaque";
|
|
|
893 |
if ( $controls ) $output[] = "&controls=0";
|
894 |
if ( $hideinfo ) $output[] = "&showinfo=0";
|
895 |
if ( $autoplay ) $output[] = "&autoplay=1";
|
899 |
// disable related videos
|
900 |
if ( $norel ) $output[] = "&rel=0";
|
901 |
|
902 |
+
$output[] = "\" style=\"border:0;\" allowfullscreen id=\"{$ytc_vid}\"></iframe>";
|
903 |
|
904 |
// Close wrapper for responsive item
|
905 |
+
if ( $instance['responsive'] ) {
|
906 |
+
$output[] = '</div>';
|
907 |
+
}
|
908 |
|
909 |
+
} else if ( $display == "iframe2" ) {
|
910 |
|
911 |
// youtube API async
|
912 |
if ( empty($usepl) ) $yt_url = $yt_id;
|
922 |
$js_player_id = str_replace('-', '_', $yt_url);
|
923 |
|
924 |
// Start wrapper for responsive item
|
925 |
+
if ( $instance['responsive'] ) {
|
926 |
+
$output[] = '<div class="fluid-width-video-wrapper">';
|
927 |
+
}
|
928 |
|
929 |
+
$output[] = '<div id="ytc_player_'.$js_player_id.'"></div>';
|
|
|
930 |
|
931 |
// Close wrapper for responsive item
|
932 |
+
if ( $instance['responsive'] ) {
|
933 |
+
$output[] = '</div>';
|
934 |
+
}
|
935 |
|
|
|
936 |
$site_domain = $_SERVER['HTTP_HOST'];
|
937 |
$ytc_html5_js = <<<JS
|
938 |
var ytc_player_$js_player_id;
|
955 |
else
|
956 |
$_SESSION['ytc_html5_js'] .= $ytc_html5_js;
|
957 |
|
958 |
+
} else { // default is thumbnail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
959 |
|
960 |
+
// set proper class for responsive thumbs per selected aspect ratio
|
961 |
+
switch ($instance['ratio']) {
|
962 |
+
case 1:
|
963 |
+
$arclass = 'ar4_3';
|
964 |
+
break;
|
965 |
+
default:
|
966 |
+
$arclass = 'ar16_9';
|
967 |
+
}
|
968 |
|
969 |
+
// Do we need tooltip for thumbnail?
|
970 |
+
if ( empty($instance['no_thumb_title']) ) {
|
971 |
+
$title = sprintf( __('Watch video %1$s published on %2$s', 'youtube-channel' ), $yt_title, $yt_date );
|
972 |
}
|
973 |
|
974 |
+
$p = '';
|
975 |
+
if ( $norel ) $p .= '&rel=0';
|
976 |
+
if ( $modestbranding ) $p .= "&modestbranding=1";
|
977 |
+
if ( $controls ) $p .= "&controls=0";
|
978 |
+
|
979 |
+
// Do we need thumbnail w/ or w/o tooltip
|
980 |
+
if ( empty($instance['no_thumb_title']) ) {
|
981 |
+
$output[] = "<a href=\"${yt_video}${p}\" title=\"{$yt_title}\" class=\"ytc_thumb ytc-lightbox {$arclass}\"><span style=\"background-image: url({$yt_thumb});\" title=\"{$title}\" id=\"{$ytc_vid}\"></span></a>";
|
982 |
} else {
|
983 |
+
$output[] = "<a href=\"${yt_video}${p}\" class=\"ytc_thumb ytc-lightbox {$arclass}\"><span style=\"background-image: url({$yt_thumb});\" id=\"{$ytc_vid}\"></span></a>";
|
984 |
}
|
985 |
|
986 |
+
// $output[] = '<a href="'.$yt_video.$p.'" title="'.$yt_title.'" class="ytc_thumb ytc-lightbox '.$arclass.'"><span style="background-image: url('.$yt_thumb.');" title="'.$title.'" id="'.$ytc_vid.'"></span></a>';
|
987 |
+
|
988 |
+
} // what to show conditions
|
989 |
+
|
990 |
+
// do we need to show video description?
|
991 |
+
if ( $instance['showdesc'] ) {
|
992 |
+
|
993 |
+
$video_description = $item->snippet->description;
|
994 |
+
$etcetera = '';
|
995 |
+
if ( $instance['desclen'] > 0 ) {
|
996 |
+
if ( strlen($video_description) > $instance['desclen'] ) {
|
997 |
+
$video_description = substr($video_description, 0, $instance['desclen']);
|
998 |
if ( $instance['descappend'] ) {
|
999 |
$etcetera = $instance['descappend'];
|
1000 |
} else {
|
1001 |
$etcetera = '…';
|
1002 |
}
|
1003 |
}
|
|
|
|
|
|
|
1004 |
}
|
1005 |
+
|
1006 |
+
if ( ! empty($video_description) ) {
|
1007 |
+
$output[] = "<p class=\"ytc_description\">{$video_description}{$etcetera}</p>";
|
1008 |
+
}
|
1009 |
+
|
1010 |
}
|
1011 |
+
|
1012 |
$output[] = '</div><!-- .ytc_video_container -->';
|
1013 |
|
1014 |
return $output;
|
1015 |
+
} // end function ytc_print_video
|
1016 |
|
1017 |
/* function to print standard playlist embed code */
|
1018 |
function ytc_only_pl($instance) {
|
1024 |
$playlist = (empty($instance['playlist'])) ? $this->playlist_id : $instance['playlist'];
|
1025 |
|
1026 |
$height = self::height_ratio($width, $instance['ratio']);
|
|
|
1027 |
|
1028 |
$playlist = $this->clean_playlist_id($playlist);
|
1029 |
|
1035 |
|
1036 |
$rel = (empty($instance['norel'])) ? '' : '&rel=0';
|
1037 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1038 |
// enhanced privacy
|
1039 |
$youtube_domain = $this->youtube_domain($instance);
|
1040 |
+
$output[] = '<div class="ytc_video_container ytc_video_1 ytc_video_single">
|
1041 |
+
<iframe src="//'.$youtube_domain.'/embed/videoseries?list=PL'.$playlist.$autoplay.$theme.$modestbranding.$rel.'"
|
1042 |
+
width="'.$width.'" height="'.$height.'" frameborder="0"></iframe></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1043 |
return $output;
|
1044 |
} // end function ytc_only_pl
|
1045 |
|
1099 |
foreach ($timeset as $n => $s)
|
1100 |
{
|
1101 |
$sec = $sc * $n;
|
1102 |
+
$out .='<option value="'.$sec.'" '. selected( $cache_time, $sec, 0 ).'>'.__($s, $this->plugin_slug).'</option>';
|
1103 |
unset($sec);
|
1104 |
}
|
1105 |
}
|
1107 |
} // end function cache_time
|
1108 |
|
1109 |
function youtube_domain($instance) {
|
1110 |
+
$youtube_domain = ( !empty($instance['privacy']) ) ? 'www.youtube-nocookie.com' : 'www.youtube.com';
|
1111 |
return $youtube_domain;
|
1112 |
} // end function youtube_domain
|
1113 |
|
1148 |
'server' => $_SERVER["SERVER_SOFTWARE"],
|
1149 |
'php' => PHP_VERSION,
|
1150 |
'wp' => $wp_version,
|
1151 |
+
'ytc' => self::VER,
|
|
|
1152 |
'url' => get_site_url(),
|
1153 |
'widget_id' => $for
|
1154 |
),
|
1156 |
);
|
1157 |
|
1158 |
// return JSON file
|
1159 |
+
header('Content-disposition: attachment; filename='.$for.'.json');
|
1160 |
header('Content-Type: application/json');
|
1161 |
echo json_encode($data);
|
1162 |
|
1169 |
} // end class
|
1170 |
} // end class check
|
1171 |
|
1172 |
+
// add_action('plugins_loaded', create_function( '', '$WPAU_YOUTUBE_CHANNEL = new WPAU_YOUTUBE_CHANNEL();' ) );
|
1173 |
+
|
1174 |
global $WPAU_YOUTUBE_CHANNEL;
|
1175 |
+
if ( empty($WPAU_YOUTUBE_CHANNEL) )
|
1176 |
+
$WPAU_YOUTUBE_CHANNEL = new WPAU_YOUTUBE_CHANNEL();
|