Version Description
(20161231) =
* (20161225) Optimize: Remove extract()
from shortcode parser
* Code cleanup and fixing to be compliant with WordPress Core coding standards
* Test compatibility with WordPreee 4.7 and PHP 7.0.14
* (20161224) Change: Update notification for missing YouTube Data API Key
* Change: Do not display shortcode options changes for fresh installation
* (20160824) Change: HTTP to HTTPS links and open remote links on settings page in new tab/window
* Change: Disable deprecated notification related to old v2.4 of plugin
* (20160419) Fix: resource from globals used if in widget set to use User uploads as resource.
* Enhance: Implemented Selective Refresh Support for Widget (WP 4.5)
* (20160131) Fix: prevent PHP Notices for Settings page.
* Fix: Cache feed
option in widget can't be disabled (always revert to default).
* Fix: Open link in
option in widget always revert to default.
* Security: prevent direct loading of settings and widget files.
* (20160120) Optimize: replace yt_play.png with optimized image.
Release Info
Developer | urkekg |
Plugin | YouTube Channel |
Version | 3.0.10 |
Comparing to | |
See all releases |
Code changes from version 3.0.9 to 3.0.10
- assets/img/play.png +0 -0
- assets/img/play.svg +0 -163
- assets/img/yt_play.png +0 -0
- assets/js/youtube-channel.js +0 -0
- assets/js/youtube-channel.min.js +0 -0
- feature-request.txt +2 -0
- inc/settings-support.php +2 -2
- inc/settings-template.php +12 -7
- inc/settings-usage-shortcode.php +129 -129
- inc/settings-usage.php +24 -24
- inc/settings.php +125 -156
- inc/tools.php +0 -5
- inc/widget.php +94 -79
- readme.txt +19 -4
- update.php +133 -133
- youtube-channel.php +258 -291
Binary file
|
@@ -1,163 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2 |
-
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3 |
-
|
4 |
-
<svg
|
5 |
-
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6 |
-
xmlns:cc="http://creativecommons.org/ns#"
|
7 |
-
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8 |
-
xmlns:svg="http://www.w3.org/2000/svg"
|
9 |
-
xmlns="http://www.w3.org/2000/svg"
|
10 |
-
xmlns:xlink="http://www.w3.org/1999/xlink"
|
11 |
-
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
12 |
-
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
13 |
-
width="48"
|
14 |
-
height="48"
|
15 |
-
id="svg2"
|
16 |
-
version="1.1"
|
17 |
-
inkscape:version="0.91pre2 r13516"
|
18 |
-
viewBox="0 0 48 48.000001"
|
19 |
-
sodipodi:docname="play.svg"
|
20 |
-
inkscape:export-filename="X:\devel\svn\wordpress\youtube-channel\trunk\assets\img\play.png"
|
21 |
-
inkscape:export-xdpi="90"
|
22 |
-
inkscape:export-ydpi="90">
|
23 |
-
<title
|
24 |
-
id="title3387">Play Now</title>
|
25 |
-
<defs
|
26 |
-
id="defs4">
|
27 |
-
<linearGradient
|
28 |
-
id="linearGradient3362"
|
29 |
-
inkscape:collect="always">
|
30 |
-
<stop
|
31 |
-
id="stop3364"
|
32 |
-
offset="0"
|
33 |
-
style="stop-color:#b63b3b;stop-opacity:1" />
|
34 |
-
<stop
|
35 |
-
id="stop3366"
|
36 |
-
offset="1"
|
37 |
-
style="stop-color:#b00808;stop-opacity:1" />
|
38 |
-
</linearGradient>
|
39 |
-
<linearGradient
|
40 |
-
inkscape:collect="always"
|
41 |
-
id="linearGradient3350">
|
42 |
-
<stop
|
43 |
-
style="stop-color:#f85252;stop-opacity:1"
|
44 |
-
offset="0"
|
45 |
-
id="stop3352" />
|
46 |
-
<stop
|
47 |
-
style="stop-color:#b00808;stop-opacity:1"
|
48 |
-
offset="1"
|
49 |
-
id="stop3354" />
|
50 |
-
</linearGradient>
|
51 |
-
<linearGradient
|
52 |
-
inkscape:collect="always"
|
53 |
-
xlink:href="#linearGradient3362"
|
54 |
-
id="linearGradient3356"
|
55 |
-
x1="84.347733"
|
56 |
-
y1="1005.3901"
|
57 |
-
x2="84.347733"
|
58 |
-
y2="1051.4783"
|
59 |
-
gradientUnits="userSpaceOnUse" />
|
60 |
-
<linearGradient
|
61 |
-
inkscape:collect="always"
|
62 |
-
xlink:href="#linearGradient3350"
|
63 |
-
id="linearGradient3360"
|
64 |
-
gradientUnits="userSpaceOnUse"
|
65 |
-
x1="84.347733"
|
66 |
-
y1="1005.3901"
|
67 |
-
x2="84.347733"
|
68 |
-
y2="1051.4783"
|
69 |
-
gradientTransform="matrix(0.95833335,0,0,0.95833335,3.4999987,42.848408)" />
|
70 |
-
</defs>
|
71 |
-
<sodipodi:namedview
|
72 |
-
id="base"
|
73 |
-
pagecolor="#ffffff"
|
74 |
-
bordercolor="#666666"
|
75 |
-
borderopacity="1.0"
|
76 |
-
inkscape:pageopacity="0"
|
77 |
-
inkscape:pageshadow="2"
|
78 |
-
inkscape:zoom="11.895833"
|
79 |
-
inkscape:cx="24"
|
80 |
-
inkscape:cy="24"
|
81 |
-
inkscape:document-units="px"
|
82 |
-
inkscape:current-layer="layer1"
|
83 |
-
showgrid="false"
|
84 |
-
inkscape:window-width="1366"
|
85 |
-
inkscape:window-height="706"
|
86 |
-
inkscape:window-x="-8"
|
87 |
-
inkscape:window-y="-8"
|
88 |
-
inkscape:window-maximized="1" />
|
89 |
-
<metadata
|
90 |
-
id="metadata7">
|
91 |
-
<rdf:RDF>
|
92 |
-
<cc:Work
|
93 |
-
rdf:about="">
|
94 |
-
<dc:format>image/svg+xml</dc:format>
|
95 |
-
<dc:type
|
96 |
-
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
97 |
-
<dc:title>Play Now</dc:title>
|
98 |
-
<dc:date>2014-09-14</dc:date>
|
99 |
-
<dc:creator>
|
100 |
-
<cc:Agent>
|
101 |
-
<dc:title>Aleksandar Urosevic</dc:title>
|
102 |
-
</cc:Agent>
|
103 |
-
</dc:creator>
|
104 |
-
<cc:license
|
105 |
-
rdf:resource="http://creativecommons.org/licenses/by-nc-sa/3.0/" />
|
106 |
-
<dc:description>Play button for WordPress plugin YouTube Channel</dc:description>
|
107 |
-
</cc:Work>
|
108 |
-
<cc:License
|
109 |
-
rdf:about="http://creativecommons.org/licenses/by-nc-sa/3.0/">
|
110 |
-
<cc:permits
|
111 |
-
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
112 |
-
<cc:permits
|
113 |
-
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
114 |
-
<cc:requires
|
115 |
-
rdf:resource="http://creativecommons.org/ns#Notice" />
|
116 |
-
<cc:requires
|
117 |
-
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
118 |
-
<cc:prohibits
|
119 |
-
rdf:resource="http://creativecommons.org/ns#CommercialUse" />
|
120 |
-
<cc:permits
|
121 |
-
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
122 |
-
<cc:requires
|
123 |
-
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
|
124 |
-
</cc:License>
|
125 |
-
</rdf:RDF>
|
126 |
-
</metadata>
|
127 |
-
<g
|
128 |
-
inkscape:label="Layer 1"
|
129 |
-
inkscape:groupmode="layer"
|
130 |
-
id="layer1"
|
131 |
-
transform="translate(0,-1004.3622)">
|
132 |
-
<g
|
133 |
-
id="g3377"
|
134 |
-
transform="translate(-60,0)">
|
135 |
-
<path
|
136 |
-
style="opacity:1;fill:url(#linearGradient3356);fill-opacity:1;stroke:none"
|
137 |
-
d="m 63.999992,1004.3622 39.999998,0 c 2.216,0 4,1.784 4,4 l 0,40 c 0,2.216 -1.784,4 -4,4 l -39.999998,0 c -2.216,0 -4,-1.784 -4,-4 l 0,-40 c 0,-2.216 1.784,-4 4,-4 z"
|
138 |
-
id="rect3348" />
|
139 |
-
<path
|
140 |
-
style="opacity:1;fill:url(#linearGradient3360);fill-opacity:1;stroke:none"
|
141 |
-
d="m 63.999992,1005.3622 39.999998,0 c 1.662,0 3,1.338 3,3 l 0,40 c 0,1.662 -1.338,3 -3,3 l -39.999998,0 c -1.662,0 -3,-1.338 -3,-3 l 0,-40 c 0,-1.662 1.338,-3 3,-3 z"
|
142 |
-
id="rect3358" />
|
143 |
-
<path
|
144 |
-
id="rect3368"
|
145 |
-
transform="translate(-7.3563764e-6,0)"
|
146 |
-
d="m 64,1005.3613 c -1.662,0 -3,1.338 -3,3 l 0,40 c 0,1.662 1.338,3 3,3 l 40,0 c 1.662,0 3,-1.338 3,-3 l 0,-40 c 0,-1.662 -1.338,-3 -3,-3 l -40,0 z m 0,1 40,0 c 1.108,0 2,0.892 2,2 l 0,40 c 0,1.108 -0.892,2 -2,2 l -40,0 c -1.108,0 -2,-0.892 -2,-2 l 0,-40 c 0,-1.108 0.892,-2 2,-2 z"
|
147 |
-
style="opacity:0.25;fill:#ffffff;fill-opacity:1;stroke:none"
|
148 |
-
inkscape:connector-curvature="0" />
|
149 |
-
<path
|
150 |
-
style="opacity:1;fill:#b63b3b;fill-opacity:1;stroke:none"
|
151 |
-
inkscape:transform-center-x="-3.9999989"
|
152 |
-
inkscape:transform-center-y="-0.0001121416"
|
153 |
-
d="m 98.999992,1027.3622 -12,6.9282 -12,6.9282 0,-13.8564 0,-13.8564 12.000001,6.9282 z"
|
154 |
-
id="path3375" />
|
155 |
-
<path
|
156 |
-
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none"
|
157 |
-
inkscape:transform-center-x="-3.9999989"
|
158 |
-
inkscape:transform-center-y="-0.0001121416"
|
159 |
-
d="m 97.999992,1028.3622 -12,6.9282 -12,6.9282 0,-13.8564 0,-13.8564 12.000001,6.9282 z"
|
160 |
-
id="path3373" />
|
161 |
-
</g>
|
162 |
-
</g>
|
163 |
-
</svg>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Binary file
|
File without changes
|
File without changes
|
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
Option to select how videos are sorted (by views) https://wordpress.org/support/topic/sort-by-views-1?replies=2
|
2 |
+
Display number of views below video https://wordpress.org/support/topic/show-views?replies=1
|
@@ -1,3 +1,3 @@
|
|
1 |
-
<p>For all questions, feature request and communication with author and users of this plugin, use our <a href="
|
2 |
|
3 |
-
<p>If you like <a href="
|
1 |
+
<p>For all questions, feature request and communication with author and users of this plugin, use our <a href="https://wordpress.org/support/plugin/youtube-channel" target="_blank">support forum</a>.</p>
|
2 |
|
3 |
+
<p>If you like <a href="https://wordpress.org/plugins/youtube-channel/" target="_blank">YouTube Channel</a> and my other <a href="https://urosevic.net/wordpress/plugins/" target="_blank">WordPress extensions</a>, feel free to support my work with <a href="https://urosevic.net/wordpress/donate/?donate_for=youtube-channel" target="_blank">donation</a>.</p>
|
@@ -1,9 +1,14 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
3 |
?>
|
4 |
<div class="wrap" id="youtube_channel_settings">
|
5 |
-
<p style="float:right;text-align:center;"><small>Support YTC developer</small><br><a href="
|
6 |
-
<h2><?php
|
7 |
<?php
|
8 |
$active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general';
|
9 |
|
@@ -18,13 +23,13 @@
|
|
18 |
'support' => __( 'Support', 'youtube-channel' ),
|
19 |
);
|
20 |
?>
|
21 |
-
<h2 class="nav-tab-wrapper">
|
22 |
<?php
|
23 |
foreach ( $tabs as $tab_name => $tab_title ) {
|
24 |
-
echo '<a href="?page=' . $
|
25 |
}
|
26 |
?>
|
27 |
-
</h2>
|
28 |
<?php
|
29 |
|
30 |
if ( ! empty( $tabs[ $active_tab ] ) ) {
|
@@ -35,7 +40,7 @@
|
|
35 |
echo '<form method="post" action="options.php">';
|
36 |
|
37 |
settings_fields( 'ytc_' . $active_tab );
|
38 |
-
do_settings_sections( $
|
39 |
|
40 |
submit_button();
|
41 |
|
1 |
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
global $wpau_youtube_channel;
|
8 |
?>
|
9 |
<div class="wrap" id="youtube_channel_settings">
|
10 |
+
<p style="float:right;text-align:center;"><small>Support YTC developer</small><br><a href="https://urosevic.net/wordpress/donate/?donate_for=youtube-channel" target="_blank">Donate via PayPal</a></p>
|
11 |
+
<h2><?php echo $wpau_youtube_channel->plugin_name . __( ' Settings', 'youtube-channel' ); ?></h2>
|
12 |
<?php
|
13 |
$active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general';
|
14 |
|
23 |
'support' => __( 'Support', 'youtube-channel' ),
|
24 |
);
|
25 |
?>
|
26 |
+
<h2 class="nav-tab-wrapper">
|
27 |
<?php
|
28 |
foreach ( $tabs as $tab_name => $tab_title ) {
|
29 |
+
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>';
|
30 |
}
|
31 |
?>
|
32 |
+
</h2>
|
33 |
<?php
|
34 |
|
35 |
if ( ! empty( $tabs[ $active_tab ] ) ) {
|
40 |
echo '<form method="post" action="options.php">';
|
41 |
|
42 |
settings_fields( 'ytc_' . $active_tab );
|
43 |
+
do_settings_sections( $wpau_youtube_channel->plugin_slug . '_' . $active_tab );
|
44 |
|
45 |
submit_button();
|
46 |
|
@@ -1,129 +1,129 @@
|
|
1 |
-
<h3><?php _e('How to use shortcode', 'youtube-channel'); ?></h3>
|
2 |
-
<p><?php
|
3 |
-
printf(
|
4 |
-
__(
|
5 |
-
'You can use shortcode %s with options listed below (all options are optional if you have set defaults in global plugin settings).',
|
6 |
-
'youtube-channel'
|
7 |
-
),
|
8 |
-
'<code>[youtube_channel]</code>'
|
9 |
-
); ?></p>
|
10 |
-
|
11 |
-
<h3 class="nav-tab-wrapper subnav-tab-wrapper">
|
12 |
-
<a href="#ytc-general-settings" class="nav-tab nav-tab-active"><?php _e('General Settings', 'youtube-channel'); ?></a>
|
13 |
-
<a href="#ytc-video-settings" class="nav-tab"><?php _e('Video Settings', 'youtube-channel'); ?></a>
|
14 |
-
<a href="#ytc-content-settings" class="nav-tab"><?php _e('Content Layout', 'youtube-channel'); ?></a>
|
15 |
-
<a href="#ytc-link-settings" class="nav-tab"><?php _e('Link to Channel', 'youtube-channel'); ?></a>
|
16 |
-
</h3>
|
17 |
-
|
18 |
-
<div class="tab-content-ytc tab-content-active" id="ytc-general-settings">
|
19 |
-
<ul>
|
20 |
-
<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>
|
21 |
-
<li><code>vanity</code> <em>(string)</em> Vanity name.</li>
|
22 |
-
<li><code>username</code> <em>(string)</em> Legacy YouTube username.</li>
|
23 |
-
<li><code>playlist</code> <em>(string)</em> ID of preferred YouTube playlist.</li>
|
24 |
-
<li><code>resource</code> <em>(int)</em> Resource to use for feed:
|
25 |
-
<ul>
|
26 |
-
<li>• <code>0</code> Channel (User Uploads)</li>
|
27 |
-
<li>• <code>1</code> Favorites (for defined channel)</li>
|
28 |
-
<li>• <code>2</code> Playlist</li>
|
29 |
-
<li>• <code>3</code> Liked Videos (for defined channel)</li>
|
30 |
-
</ul></li>
|
31 |
-
<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>
|
32 |
-
|
33 |
-
<li><code>fetch</code> <em>(int)</em> Number of videos that will be used as stack for random pick (min 2, max 50)</li>
|
34 |
-
<li><code>num</code> <em>(int)</em> Number of videos to display per YTC block.</li>
|
35 |
-
|
36 |
-
<li><code>random</code> <em>(bool)</em> Option to randomize videos on every page load. [<strong>Individual option, does not exists in global plugin settings!</strong>]</li>
|
37 |
-
</ul>
|
38 |
-
</div>
|
39 |
-
|
40 |
-
<div class="tab-content-ytc" id="ytc-video-settings">
|
41 |
-
<ul>
|
42 |
-
<li><code>ratio</code> <em>(int)</em> Set preferred aspect ratio for thumbnail and video. You can use:
|
43 |
-
<ul>
|
44 |
-
<li>• <code>3</code> 16:9 widescreen (default)</li>
|
45 |
-
<li>• <code>1</code> 4:3</li>
|
46 |
-
</ul></li>
|
47 |
-
<li><code>width</code> <em>(int)</em> Width of thumbnail and video in pixels.</li>
|
48 |
-
<li><code>responsive</code> <em>(bool)</em> Distribute one full width video per row.</li>
|
49 |
-
<li><code>display</code> <em>(string)</em> Object that will be used to represent video. We have couple predefined options:
|
50 |
-
<ul>
|
51 |
-
<li>• <code>thumbnail</code> Thumbnail will be used and video will be loaded in lightbox.</li>
|
52 |
-
<li>• <code>iframe</code> HTML5 (iframe)</li>
|
53 |
-
<li>• <code>iframe2</code> HTML5 (iframe) with asynchronous loading - recommended</li>
|
54 |
-
<li>• <code>playlist</code> Embedded playlist</li>
|
55 |
-
</ul></li>
|
56 |
-
|
57 |
-
<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>
|
58 |
-
<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>
|
59 |
-
<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>
|
60 |
-
<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>
|
61 |
-
<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>
|
62 |
-
<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>
|
63 |
-
<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>
|
64 |
-
</ul>
|
65 |
-
</div>
|
66 |
-
|
67 |
-
<div class="tab-content-ytc" id="ytc-content-settings">
|
68 |
-
<ul>
|
69 |
-
<li><code>showtitle</code> <em>(string)</em> Set to <code>none</code> to hide title; <code>above</code> to show video title above video/thumbnail, or <code>below</code> to show video title below video/thumbnail.</li>
|
70 |
-
<li><code>showdesc</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to show video description.</li>
|
71 |
-
<li><code>desclen</code> <em>(int)</em> Set number of characters to cut down length of video description. Set to <code>0</code> to use full length description.</li>
|
72 |
-
<li><code>noinfo</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to hide overlay video infos (from embedded player)</li>
|
73 |
-
<li><code>noanno</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to hide overlay video annotations (from embedded player)</li>
|
74 |
-
</ul>
|
75 |
-
</div>
|
76 |
-
|
77 |
-
<div class="tab-content-ytc" id="ytc-link-settings">
|
78 |
-
<ul>
|
79 |
-
<li><code>goto_txt</code> <em>(string)</em></li>
|
80 |
-
<li><code>popup</code> <em>(int)</em> Control where link to channel will be opened:
|
81 |
-
<ul>
|
82 |
-
<li>• <code>0</code> open link in same window</li>
|
83 |
-
<li>• <code>1</code> open link in new window with JavaScript</li>
|
84 |
-
<li>• <code>2</code> open link in new window with <code>target="_blank"</code> anchor attribute</li>
|
85 |
-
</ul>
|
86 |
-
</li>
|
87 |
-
<li><code>link_to</code> <em>(string)</em> URL to link:
|
88 |
-
<ul>
|
89 |
-
<li>• <code>none</code> hide link (default)</li>
|
90 |
-
<li>• <code>vanity</code> Vanity custom URL</li>
|
91 |
-
<li>• <code>channel</code> Channel page</li>
|
92 |
-
<li>• <code>legacy</code> Legacy username page</li>
|
93 |
-
</ul>
|
94 |
-
</li>
|
95 |
-
</ul>
|
96 |
-
</div>
|
97 |
-
|
98 |
-
<p><?php
|
99 |
-
printf(
|
100 |
-
__(
|
101 |
-
'Please note, you can omit all options listed above, and then will be used plugin defaults customized on tabs %1$s, %2$s, %3$s and %4$s.',
|
102 |
-
'youtube-chanel'
|
103 |
-
),
|
104 |
-
__('General', 'youtube-channel'),
|
105 |
-
__('Video', 'youtube-channel'),
|
106 |
-
__('Content', 'youtube-channel'),
|
107 |
-
__('Link to Channel', 'youtube-channel')
|
108 |
-
); ?></p>
|
109 |
-
<p><?php
|
110 |
-
printf(
|
111 |
-
__(
|
112 |
-
'Important note: %s blocks inserted through widget have their own settings.',
|
113 |
-
'youtube-channel'
|
114 |
-
),
|
115 |
-
__('YouTube Channel', 'youtube-channel')
|
116 |
-
); ?></p>
|
117 |
-
|
118 |
-
<script>
|
119 |
-
jQuery(document).ready(function($){
|
120 |
-
$('.subnav-tab-wrapper .nav-tab').on('click',function(ev){
|
121 |
-
ev.preventDefault();
|
122 |
-
var target = $(this).attr('href');
|
123 |
-
$('.subnav-tab-wrapper .nav-tab').removeClass('nav-tab-active');
|
124 |
-
$(this).addClass('nav-tab-active');
|
125 |
-
$('.tab-content-ytc').removeClass('tab-content-active');
|
126 |
-
$(target).addClass('tab-content-active');
|
127 |
-
});
|
128 |
-
});
|
129 |
-
</script>
|
1 |
+
<h3><?php _e( 'How to use shortcode', 'youtube-channel' ); ?></h3>
|
2 |
+
<p><?php
|
3 |
+
printf(
|
4 |
+
__(
|
5 |
+
'You can use shortcode %s with options listed below (all options are optional if you have set defaults in global plugin settings).',
|
6 |
+
'youtube-channel'
|
7 |
+
),
|
8 |
+
'<code>[youtube_channel]</code>'
|
9 |
+
); ?></p>
|
10 |
+
|
11 |
+
<h3 class="nav-tab-wrapper subnav-tab-wrapper">
|
12 |
+
<a href="#ytc-general-settings" class="nav-tab nav-tab-active"><?php _e( 'General Settings', 'youtube-channel' ); ?></a>
|
13 |
+
<a href="#ytc-video-settings" class="nav-tab"><?php _e( 'Video Settings', 'youtube-channel' ); ?></a>
|
14 |
+
<a href="#ytc-content-settings" class="nav-tab"><?php _e( 'Content Layout', 'youtube-channel' ); ?></a>
|
15 |
+
<a href="#ytc-link-settings" class="nav-tab"><?php _e( 'Link to Channel', 'youtube-channel' ); ?></a>
|
16 |
+
</h3>
|
17 |
+
|
18 |
+
<div class="tab-content-ytc tab-content-active" id="ytc-general-settings">
|
19 |
+
<ul>
|
20 |
+
<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>
|
21 |
+
<li><code>vanity</code> <em>(string)</em> Vanity name.</li>
|
22 |
+
<li><code>username</code> <em>(string)</em> Legacy YouTube username.</li>
|
23 |
+
<li><code>playlist</code> <em>(string)</em> ID of preferred YouTube playlist.</li>
|
24 |
+
<li><code>resource</code> <em>(int)</em> Resource to use for feed:
|
25 |
+
<ul>
|
26 |
+
<li>• <code>0</code> Channel (User Uploads)</li>
|
27 |
+
<li>• <code>1</code> Favorites (for defined channel)</li>
|
28 |
+
<li>• <code>2</code> Playlist</li>
|
29 |
+
<li>• <code>3</code> Liked Videos (for defined channel)</li>
|
30 |
+
</ul></li>
|
31 |
+
<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>
|
32 |
+
|
33 |
+
<li><code>fetch</code> <em>(int)</em> Number of videos that will be used as stack for random pick (min 2, max 50)</li>
|
34 |
+
<li><code>num</code> <em>(int)</em> Number of videos to display per YTC block.</li>
|
35 |
+
|
36 |
+
<li><code>random</code> <em>(bool)</em> Option to randomize videos on every page load. [<strong>Individual option, does not exists in global plugin settings!</strong>]</li>
|
37 |
+
</ul>
|
38 |
+
</div>
|
39 |
+
|
40 |
+
<div class="tab-content-ytc" id="ytc-video-settings">
|
41 |
+
<ul>
|
42 |
+
<li><code>ratio</code> <em>(int)</em> Set preferred aspect ratio for thumbnail and video. You can use:
|
43 |
+
<ul>
|
44 |
+
<li>• <code>3</code> 16:9 widescreen (default)</li>
|
45 |
+
<li>• <code>1</code> 4:3</li>
|
46 |
+
</ul></li>
|
47 |
+
<li><code>width</code> <em>(int)</em> Width of thumbnail and video in pixels.</li>
|
48 |
+
<li><code>responsive</code> <em>(bool)</em> Distribute one full width video per row.</li>
|
49 |
+
<li><code>display</code> <em>(string)</em> Object that will be used to represent video. We have couple predefined options:
|
50 |
+
<ul>
|
51 |
+
<li>• <code>thumbnail</code> Thumbnail will be used and video will be loaded in lightbox.</li>
|
52 |
+
<li>• <code>iframe</code> HTML5 (iframe)</li>
|
53 |
+
<li>• <code>iframe2</code> HTML5 (iframe) with asynchronous loading - recommended</li>
|
54 |
+
<li>• <code>playlist</code> Embedded playlist</li>
|
55 |
+
</ul></li>
|
56 |
+
|
57 |
+
<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>
|
58 |
+
<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>
|
59 |
+
<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>
|
60 |
+
<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>
|
61 |
+
<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>
|
62 |
+
<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>
|
63 |
+
<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>
|
64 |
+
</ul>
|
65 |
+
</div>
|
66 |
+
|
67 |
+
<div class="tab-content-ytc" id="ytc-content-settings">
|
68 |
+
<ul>
|
69 |
+
<li><code>showtitle</code> <em>(string)</em> Set to <code>none</code> to hide title; <code>above</code> to show video title above video/thumbnail, or <code>below</code> to show video title below video/thumbnail.</li>
|
70 |
+
<li><code>showdesc</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to show video description.</li>
|
71 |
+
<li><code>desclen</code> <em>(int)</em> Set number of characters to cut down length of video description. Set to <code>0</code> to use full length description.</li>
|
72 |
+
<li><code>noinfo</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to hide overlay video infos (from embedded player)</li>
|
73 |
+
<li><code>noanno</code> <em>(bool)</em> Set to <code>1</code> or <code>true</code> to hide overlay video annotations (from embedded player)</li>
|
74 |
+
</ul>
|
75 |
+
</div>
|
76 |
+
|
77 |
+
<div class="tab-content-ytc" id="ytc-link-settings">
|
78 |
+
<ul>
|
79 |
+
<li><code>goto_txt</code> <em>(string)</em></li>
|
80 |
+
<li><code>popup</code> <em>(int)</em> Control where link to channel will be opened:
|
81 |
+
<ul>
|
82 |
+
<li>• <code>0</code> open link in same window</li>
|
83 |
+
<li>• <code>1</code> open link in new window with JavaScript</li>
|
84 |
+
<li>• <code>2</code> open link in new window with <code>target="_blank"</code> anchor attribute</li>
|
85 |
+
</ul>
|
86 |
+
</li>
|
87 |
+
<li><code>link_to</code> <em>(string)</em> URL to link:
|
88 |
+
<ul>
|
89 |
+
<li>• <code>none</code> hide link (default)</li>
|
90 |
+
<li>• <code>vanity</code> Vanity custom URL</li>
|
91 |
+
<li>• <code>channel</code> Channel page</li>
|
92 |
+
<li>• <code>legacy</code> Legacy username page</li>
|
93 |
+
</ul>
|
94 |
+
</li>
|
95 |
+
</ul>
|
96 |
+
</div>
|
97 |
+
|
98 |
+
<p><?php
|
99 |
+
printf(
|
100 |
+
__(
|
101 |
+
'Please note, you can omit all options listed above, and then will be used plugin defaults customized on tabs %1$s, %2$s, %3$s and %4$s.',
|
102 |
+
'youtube-chanel'
|
103 |
+
),
|
104 |
+
__( 'General', 'youtube-channel' ),
|
105 |
+
__( 'Video', 'youtube-channel' ),
|
106 |
+
__( 'Content', 'youtube-channel' ),
|
107 |
+
__( 'Link to Channel', 'youtube-channel' )
|
108 |
+
); ?></p>
|
109 |
+
<p><?php
|
110 |
+
printf(
|
111 |
+
__(
|
112 |
+
'Important note: %s blocks inserted through widget have their own settings.',
|
113 |
+
'youtube-channel'
|
114 |
+
),
|
115 |
+
__( 'YouTube Channel', 'youtube-channel' )
|
116 |
+
); ?></p>
|
117 |
+
|
118 |
+
<script>
|
119 |
+
jQuery(document).ready(function($){
|
120 |
+
$('.subnav-tab-wrapper .nav-tab').on('click',function(ev){
|
121 |
+
ev.preventDefault();
|
122 |
+
var target = $(this).attr('href');
|
123 |
+
$('.subnav-tab-wrapper .nav-tab').removeClass('nav-tab-active');
|
124 |
+
$(this).addClass('nav-tab-active');
|
125 |
+
$('.tab-content-ytc').removeClass('tab-content-active');
|
126 |
+
$(target).addClass('tab-content-active');
|
127 |
+
});
|
128 |
+
});
|
129 |
+
</script>
|
@@ -1,24 +1,24 @@
|
|
1 |
-
<h3><?php _e('How to use YouTube Channel', 'youtube-channel'); ?></h3>
|
2 |
-
<p><?php _e('You can insert YouTube Channel in couple different ways.', 'youtube-channel'); ?></p>
|
3 |
-
<ol>
|
4 |
-
<li><?php
|
5 |
-
printf(
|
6 |
-
__(
|
7 |
-
'Add %s to preferred %s, and configure it there.',
|
8 |
-
'youtube-channel'
|
9 |
-
),
|
10 |
-
__('YouTube Channel Widget', 'youtube-channel'),
|
11 |
-
sprintf(
|
12 |
-
'<a href="widgets.php">%s</a>',
|
13 |
-
__('Widget Area', 'youtube-channel')
|
14 |
-
)
|
15 |
-
); ?></li>
|
16 |
-
<li><?php
|
17 |
-
printf(
|
18 |
-
__(
|
19 |
-
'Insert shortcode %s to your page or text widget, and even modify default settings by shortcode parameters listed in section below.',
|
20 |
-
'youtube_channel'
|
21 |
-
),
|
22 |
-
'<code>[youtube_channel]</code>'
|
23 |
-
); ?></li>
|
24 |
-
</ol>
|
1 |
+
<h3><?php _e( 'How to use YouTube Channel', 'youtube-channel' ); ?></h3>
|
2 |
+
<p><?php _e( 'You can insert YouTube Channel in couple different ways.', 'youtube-channel' ); ?></p>
|
3 |
+
<ol>
|
4 |
+
<li><?php
|
5 |
+
printf(
|
6 |
+
__(
|
7 |
+
'Add %1$s to preferred %2$s, and configure it there.',
|
8 |
+
'youtube-channel'
|
9 |
+
),
|
10 |
+
__( 'YouTube Channel Widget', 'youtube-channel' ),
|
11 |
+
sprintf(
|
12 |
+
'<a href="widgets.php">%s</a>',
|
13 |
+
__( 'Widget Area', 'youtube-channel' )
|
14 |
+
)
|
15 |
+
); ?></li>
|
16 |
+
<li><?php
|
17 |
+
printf(
|
18 |
+
__(
|
19 |
+
'Insert shortcode %s to your page or text widget, and even modify default settings by shortcode parameters listed in section below.',
|
20 |
+
'youtube_channel'
|
21 |
+
),
|
22 |
+
'<code>[youtube_channel]</code>'
|
23 |
+
); ?></li>
|
24 |
+
</ol>
|
@@ -1,5 +1,10 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
4 |
|
5 |
class WPAU_YOUTUBE_CHANNEL_SETTINGS {
|
@@ -13,11 +18,11 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
13 |
*/
|
14 |
public function __construct() {
|
15 |
|
16 |
-
global $
|
17 |
|
18 |
// get default values
|
19 |
-
$this->slug = $
|
20 |
-
$this->option_name = $
|
21 |
$this->defaults = get_option( $this->option_name );
|
22 |
|
23 |
// register actions
|
@@ -30,6 +35,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
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 ---
|
@@ -103,7 +109,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
103 |
)
|
104 |
),
|
105 |
'class' => 'regular-text',
|
106 |
-
'value' => $this->defaults['channel'],
|
107 |
) // args
|
108 |
);
|
109 |
// Vanity
|
@@ -137,7 +143,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
137 |
)
|
138 |
),
|
139 |
'class' => 'regular-text',
|
140 |
-
'value' => $this->defaults['vanity'],
|
141 |
) // args
|
142 |
);
|
143 |
// Username
|
@@ -155,7 +161,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
155 |
__( 'Your YouTube legacy username', 'youtube-channel' )
|
156 |
),
|
157 |
'class' => 'regular-text',
|
158 |
-
'value' => $this->defaults['username'],
|
159 |
) // args
|
160 |
);
|
161 |
// Default Playlist
|
@@ -173,7 +179,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
173 |
__( 'Enter default playlist ID (not playlist name)', 'youtube-channel' )
|
174 |
),
|
175 |
'class' => 'regular-text',
|
176 |
-
'value' => $this->defaults['playlist'],
|
177 |
) // args
|
178 |
);
|
179 |
// Resource
|
@@ -188,7 +194,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
188 |
'label' => __( 'Resource:', 'youtube-channel' ),
|
189 |
'description' => __( 'What to use as resource for feeds', 'youtube-channel' ),
|
190 |
'class' => 'regular-text',
|
191 |
-
'value' => $this->defaults['resource'],
|
192 |
'items' => array(
|
193 |
'0' => __( 'Channel', 'youtube-channel' ),
|
194 |
'1' => __( 'Favourites', 'youtube-channel' ),
|
@@ -208,30 +214,8 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
208 |
'field' => $this->option_name . '[cache]',
|
209 |
'description' => __( 'Define caching timeout for YouTube feeds, in seconds', 'youtube-channel' ),
|
210 |
'class' => 'wide-text',
|
211 |
-
'value' => $this->defaults['cache'],
|
212 |
-
'items' =>
|
213 |
-
'0' => __( 'Do not chache', 'youtube-channel' ),
|
214 |
-
'60' => __( '1 minute', 'youtube-channel' ),
|
215 |
-
'300' => __( '5 minutes', 'youtube-channel' ),
|
216 |
-
'900' => __( '15 minutes', 'youtube-channel' ),
|
217 |
-
'1800' => __( '30 minutes', 'youtube-channel' ),
|
218 |
-
'3600' => __( '1 hour', 'youtube-channel' ),
|
219 |
-
'7200' => __( '2 hours', 'youtube-channel' ),
|
220 |
-
'18000' => __( '5 hours', 'youtube-channel' ),
|
221 |
-
'36000' => __( '10 hours', 'youtube-channel' ),
|
222 |
-
'43200' => __( '12 hours', 'youtube-channel' ),
|
223 |
-
'64800' => __( '18 hours', 'youtube-channel' ),
|
224 |
-
'86400' => __( '1 day', 'youtube-channel' ),
|
225 |
-
'172800' => __( '2 days', 'youtube-channel' ),
|
226 |
-
'259200' => __( '3 days', 'youtube-channel' ),
|
227 |
-
'345600' => __( '4 days', 'youtube-channel' ),
|
228 |
-
'432000' => __( '5 days', 'youtube-channel' ),
|
229 |
-
'518400' => __( '6 days', 'youtube-channel' ),
|
230 |
-
'604800' => __( '1 week', 'youtube-channel' ),
|
231 |
-
'1209600' => __( '2 weeks', 'youtube-channel' ),
|
232 |
-
'1814400' => __( '3 weeks', 'youtube-channel' ),
|
233 |
-
'2419200' => __( '1 month', 'youtube-channel' ),
|
234 |
-
),
|
235 |
)
|
236 |
);
|
237 |
// Fetch
|
@@ -245,7 +229,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
245 |
'field' => $this->option_name . '[fetch]',
|
246 |
'description' => __( 'Number of videos that will be used for random pick (min 2, max 50, default 25)', 'youtube-channel' ),
|
247 |
'class' => 'num',
|
248 |
-
'value' => $this->defaults['fetch'],
|
249 |
'min' => 1,
|
250 |
'max' => 50,
|
251 |
'std' => 25,
|
@@ -262,7 +246,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
262 |
'field' => $this->option_name . '[num]',
|
263 |
'description' => __( 'Number of videos to display', 'youtube-channel' ),
|
264 |
'class' => 'num',
|
265 |
-
'value' => $this->defaults['num'],
|
266 |
'min' => 1,
|
267 |
'max' => 50,
|
268 |
'std' => 1,
|
@@ -290,11 +274,11 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
290 |
),
|
291 |
)
|
292 |
),
|
293 |
-
esc_url( '
|
294 |
__( 'Learn more here', 'youtube-channel' )
|
295 |
),
|
296 |
'class' => 'checkbox',
|
297 |
-
'value' => $this->defaults['privacy'],
|
298 |
) // args
|
299 |
);
|
300 |
// TinyMCE icon
|
@@ -311,7 +295,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
311 |
__( 'YouTube Channel', 'youtube-channel' )
|
312 |
),
|
313 |
'class' => 'checkbox',
|
314 |
-
'value' => isset( $this->defaults['tinymce'] ) ? $this->defaults['tinymce'] :
|
315 |
) // args
|
316 |
);
|
317 |
// --- Register setting General so $_POST handling is done ---
|
@@ -341,7 +325,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
341 |
'field' => $this->option_name . '[width]',
|
342 |
'description' => __( 'Set default width for displayed video, in pixels', 'youtube-channel' ),
|
343 |
'class' => 'num',
|
344 |
-
'value' => $this->defaults['width'],
|
345 |
'min' => 120,
|
346 |
'max' => 1980,
|
347 |
'std' => 306,
|
@@ -358,7 +342,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
358 |
'field' => $this->option_name . '[ratio]',
|
359 |
'description' => __( 'Select aspect ratio for displayed video', 'youtube-channel' ),
|
360 |
'class' => 'regular-text',
|
361 |
-
'value' => $this->defaults['ratio'],
|
362 |
'items' => array(
|
363 |
'3' => '16:9',
|
364 |
'1' => '4:3',
|
@@ -376,7 +360,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
376 |
'field' => $this->option_name . '[display]',
|
377 |
'description' => __( 'Choose how to embed video block', 'youtube-channel' ),
|
378 |
'class' => 'regular-text',
|
379 |
-
'value' => $this->defaults['display'],
|
380 |
'items' => array(
|
381 |
'thumbnail' => __( 'Thumbnail', 'youtube-channel' ),
|
382 |
'iframe' => __( 'HTML5 (iframe)', 'youtube-channel' ),
|
@@ -397,7 +381,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
397 |
'field' => $this->option_name . '[responsive]',
|
398 |
'description' => __( 'Enable this option to make YTC videos and thumbnails responsive by default. Please note, this option will set videos and thumbnail to full width relative to parent container, and disable more than one video per row.', 'youtube-channel' ),
|
399 |
'class' => 'checkbox',
|
400 |
-
'value' => $this->defaults['responsive'],
|
401 |
) // args
|
402 |
);
|
403 |
|
@@ -427,7 +411,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
427 |
__( 'Learn more here', 'youtube-channel' )
|
428 |
),
|
429 |
'class' => 'checkbox',
|
430 |
-
'value' =>
|
431 |
) // args
|
432 |
);
|
433 |
// No Lightbox
|
@@ -441,7 +425,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
441 |
'field' => $this->option_name . '[nolightbox]',
|
442 |
'description' => __( 'Enable this option to disable built-in lightbox for thumbnails (in case that you have youtube links lightbox trigger in theme or other plugin).', 'youtube-channel' ),
|
443 |
'class' => 'checkbox',
|
444 |
-
'value' =>
|
445 |
) // args
|
446 |
);
|
447 |
// Full Screen
|
@@ -455,7 +439,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
455 |
'field' => $this->option_name . '[fullscreen]',
|
456 |
'description' => __( 'Enable this option to make available Full Screen button for embedded playlists.', 'youtube-channel' ),
|
457 |
'class' => 'checkbox',
|
458 |
-
'value' => isset( $this->defaults['fullscreen'] ) ? $this->defaults['fullscreen'] :
|
459 |
) // args
|
460 |
);
|
461 |
|
@@ -470,7 +454,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
470 |
'field' => $this->option_name . '[themelight]',
|
471 |
'description' => __( 'Enable this option to use light theme for playback controls instead dark.', 'youtube-channel' ),
|
472 |
'class' => 'checkbox',
|
473 |
-
'value' => $this->defaults['themelight'],
|
474 |
) // args
|
475 |
);
|
476 |
// No Player Controls
|
@@ -484,7 +468,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
484 |
'field' => $this->option_name . '[controls]',
|
485 |
'description' => __( 'Enable this option to hide playback controls', 'youtube-channel' ),
|
486 |
'class' => 'checkbox',
|
487 |
-
'value' => $this->defaults['controls'],
|
488 |
) // args
|
489 |
);
|
490 |
// Fix Height (deprecated?)
|
@@ -499,7 +483,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
499 |
'field' => $this->option_name . '[autoplay]',
|
500 |
'description' => __( 'Enable this option to start video playback right after block is rendered', 'youtube-channel' ),
|
501 |
'class' => 'checkbox',
|
502 |
-
'value' => $this->defaults['autoplay'],
|
503 |
) // args
|
504 |
);
|
505 |
// Mute on autoplay
|
@@ -513,7 +497,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
513 |
'field' => $this->option_name . '[autoplay_mute]',
|
514 |
'description' => __( 'Enable this option to mute video when start autoplay', 'youtube-channel' ),
|
515 |
'class' => 'checkbox',
|
516 |
-
'value' => $this->defaults['autoplay_mute'],
|
517 |
) // args
|
518 |
);
|
519 |
// No related videos
|
@@ -527,7 +511,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
527 |
'field' => $this->option_name . '[norel]',
|
528 |
'description' => __( 'Enable this option to hide related videos after finished playback', 'youtube-channel' ),
|
529 |
'class' => 'checkbox',
|
530 |
-
'value' => $this->defaults['norel'],
|
531 |
) // args
|
532 |
);
|
533 |
// Hide YT logo
|
@@ -541,7 +525,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
541 |
'field' => $this->option_name . '[modestbranding]',
|
542 |
'description' => __( 'Enable this option to hide YouTube logo from playback control bar. Does not work for all videos.', 'youtube-channel' ),
|
543 |
'class' => 'checkbox',
|
544 |
-
'value' => $this->defaults['modestbranding'],
|
545 |
) // args
|
546 |
);
|
547 |
// Hide Annotations
|
@@ -555,7 +539,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
555 |
'field' => $this->option_name . '[hideanno]',
|
556 |
'description' => __( 'Enable this option to hide video annotations (custom text set by uploader over video during playback)', 'youtube-channel' ),
|
557 |
'class' => 'checkbox',
|
558 |
-
'value' => $this->defaults['hideanno'],
|
559 |
) // args
|
560 |
);
|
561 |
// Hide Video Info
|
@@ -569,7 +553,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
569 |
'field' => $this->option_name . '[hideinfo]',
|
570 |
'description' => __( 'Enable this option to hide informations about video before play start (video title and uploader in overlay)', 'youtube-channel' ),
|
571 |
'class' => 'checkbox',
|
572 |
-
'value' => $this->defaults['hideinfo'],
|
573 |
) // args
|
574 |
);
|
575 |
// --- Register setting Video so $_POST handling is done ---
|
@@ -599,7 +583,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
599 |
'field' => $this->option_name . '[showtitle]',
|
600 |
'description' => __( 'Select should we and where display title of video', 'youtube-channel' ),
|
601 |
'class' => 'regular-text',
|
602 |
-
'value' => $this->defaults['showtitle'],
|
603 |
'items' => array(
|
604 |
'none' => __( 'Hide title', 'youtube-channel' ),
|
605 |
'above' => __( 'Above video/thumbnail', 'youtube-channel' ),
|
@@ -618,7 +602,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
618 |
'field' => $this->option_name . '[showdesc]',
|
619 |
'description' => __( 'Enable this option to display description for video', 'youtube-channel' ),
|
620 |
'class' => 'checkbox',
|
621 |
-
'value' => $this->defaults['showdesc'],
|
622 |
) // args
|
623 |
);
|
624 |
// Description length
|
@@ -632,7 +616,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
632 |
'field' => $this->option_name . '[desclen]',
|
633 |
'description' => __( 'Enter length for video description in characters (0 for full length)', 'youtube-channel' ),
|
634 |
'class' => 'num',
|
635 |
-
'value' => $this->defaults['desclen'],
|
636 |
'min' => 0,
|
637 |
'max' => 2500,
|
638 |
'std' => 0,
|
@@ -667,7 +651,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
667 |
// 'label' => __('Ratio:', 'youtube-channel' ),
|
668 |
'description' => __( 'Set where link will lead visitors', 'youtube-channel' ),
|
669 |
'class' => 'regular-text',
|
670 |
-
'value' => $this->defaults['link_to'],
|
671 |
'items' => array(
|
672 |
'none' => __( 'Hide link', 'youtube-channel' ),
|
673 |
'vanity' => __( 'Vanity custom URL', 'youtube-channel' ),
|
@@ -688,7 +672,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
688 |
// 'label' => __('Ratio:', 'youtube-channel' ),
|
689 |
'description' => __( 'Set where link will be opened', 'youtube-channel' ),
|
690 |
'class' => 'regular-text',
|
691 |
-
'value' => $this->defaults['popup_goto'],
|
692 |
'items' => array(
|
693 |
'0' => __( 'same window', 'youtube-channel' ),
|
694 |
'1' => __( 'new window (JavaScript)', 'youtube-channel' ),
|
@@ -707,7 +691,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
707 |
'field' => $this->option_name . '[goto_txt]',
|
708 |
'class' => 'regular-text',
|
709 |
'description' => __( 'Set default title for link', 'youtube-channel' ),
|
710 |
-
'value' => $this->defaults['goto_txt'],
|
711 |
) // args
|
712 |
);
|
713 |
|
@@ -740,9 +724,9 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
740 |
|
741 |
// --- Section desciptions ---
|
742 |
public function settings_general_section_description() {
|
743 |
-
|
744 |
-
<p
|
745 |
-
|
746 |
wp_kses(
|
747 |
__(
|
748 |
'Configure general defaults for %1$s used as fallback options in widget or shortcodes. To get %2$s and %3$s visit <a href="%4$s" target="_blank">%5$s</a>.',
|
@@ -760,204 +744,189 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
760 |
__( 'Vanity URL', 'youtube-channel' ),
|
761 |
esc_url( 'https://www.youtube.com/account_advanced' ),
|
762 |
__( 'YouTube Account Overview', 'youtube-channel' )
|
763 |
-
)
|
764 |
-
|
765 |
-
|
766 |
-
} //
|
|
|
767 |
public function settings_video_section_description() {
|
768 |
-
|
769 |
-
|
770 |
-
printf(
|
771 |
__( 'Configure video specific defaults for %s used as fallback options in widget or shortcodes.', 'youtube-channel' ),
|
772 |
__( 'YouTube Channel', 'youtube-channel' )
|
773 |
-
)
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
public function settings_content_section_description() {
|
778 |
-
|
779 |
-
|
780 |
-
printf(
|
781 |
__( 'Configure defaults of content around and over videos for %s used as fallback options in widget or shortcodes.', 'youtube-channel' ),
|
782 |
__( 'YouTube Channel', 'youtube-channel' )
|
783 |
-
)
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
public function settings_link_section_description() {
|
788 |
-
|
789 |
-
|
790 |
-
printf(
|
791 |
__( 'Configure defaults for link to channel below %s block used as fallback options in widget or shortcodes.', 'youtube-channel' ),
|
792 |
__( 'YouTube Channel', 'youtube-channel' )
|
793 |
-
)
|
794 |
-
|
795 |
-
|
796 |
-
} // eom settings_link_section_description() {
|
797 |
|
798 |
/**
|
799 |
* This function provides separator for settings fields
|
800 |
*/
|
801 |
public function settings_field_separator( $args = null ) {
|
802 |
echo '<hr>';
|
803 |
-
} //
|
804 |
|
805 |
/**
|
806 |
* This function provides text inputs for settings fields
|
807 |
*/
|
808 |
-
public function settings_field_input_text($args) {
|
809 |
-
|
810 |
-
extract( $args );
|
811 |
|
812 |
printf(
|
813 |
'<input type="text" name="%1$s" id="%1$s" value="%2$s" class="%3$s" /><p class="description">%4$s</p>',
|
814 |
-
$field,
|
815 |
-
$value,
|
816 |
-
$class,
|
817 |
-
$description
|
818 |
);
|
819 |
|
820 |
-
} //
|
821 |
|
822 |
/**
|
823 |
* This function provides password inputs for settings fields
|
824 |
*/
|
825 |
-
public function settings_field_input_password($args) {
|
826 |
-
|
827 |
-
extract( $args );
|
828 |
|
829 |
printf(
|
830 |
'<input type="password" name="%1$s" id="%1$s" value="%2$s" class="%3$s" /><p class="description">%4$s</p>',
|
831 |
-
$field,
|
832 |
-
$value,
|
833 |
-
$class,
|
834 |
-
$description
|
835 |
);
|
836 |
|
837 |
-
} //
|
838 |
|
839 |
/**
|
840 |
* This function provides number inputs for settings fields
|
841 |
*/
|
842 |
-
public function settings_field_input_number($args) {
|
843 |
-
|
844 |
-
extract( $args );
|
845 |
|
846 |
printf(
|
847 |
'<input type="number" name="%1$s" id="%1$s" value="%2$s" min="%3$s" max="%4$s" class="%5$s" /><p class="description">%6$s</p>',
|
848 |
-
$field,
|
849 |
-
$value,
|
850 |
-
$min,
|
851 |
-
$max,
|
852 |
-
$class,
|
853 |
-
$description
|
854 |
);
|
855 |
|
856 |
-
} //
|
857 |
|
858 |
/**
|
859 |
* This function provides select for settings fields
|
860 |
*/
|
861 |
-
public function settings_field_select($args) {
|
862 |
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
// $html .= sprintf('<label for="%s">%s</label><br>', $field, $label);
|
867 |
-
$html .= sprintf( '<select id="%1$s" name="%1$s">', $field );
|
868 |
-
foreach ( $items as $key => $val ) {
|
869 |
-
$selected = ( $value == $key ) ? 'selected="selected"' : '';
|
870 |
$html .= sprintf( '<option %1$s value="%2$s">%3$s</option>', $selected, $key, $val );
|
871 |
}
|
872 |
-
$html .= sprintf( '</select><p class="description">%s</p>', $description );
|
873 |
|
874 |
echo $html;
|
875 |
|
876 |
-
} //
|
877 |
|
878 |
/**
|
879 |
* This function provides checkbox for settings fields
|
880 |
*/
|
881 |
-
public function settings_field_checkbox($args) {
|
882 |
-
|
883 |
-
extract( $args );
|
884 |
|
885 |
-
$checked =
|
886 |
printf(
|
887 |
'<label for="%1$s"><input type="checkbox" name="%1$s" id="%1$s" value="1" class="%2$s" %3$s />%4$s</label>',
|
888 |
-
$field,
|
889 |
-
$class,
|
890 |
$checked,
|
891 |
-
$description
|
892 |
);
|
893 |
|
894 |
-
} //
|
895 |
|
896 |
/**
|
897 |
* This function provides checkbox groupfor settings fields
|
898 |
*/
|
899 |
-
|
900 |
-
|
901 |
-
extract( $args );
|
902 |
|
903 |
// items
|
904 |
$out = '<fieldset>';
|
905 |
|
906 |
-
foreach ( $items as $key => $label ) {
|
907 |
|
908 |
$checked = '';
|
909 |
-
if ( ! empty( $value ) ) {
|
910 |
-
$checked =
|
911 |
}
|
912 |
|
913 |
$out .= sprintf(
|
914 |
'<label for="%1$s_%2$s"><input type="checkbox" name="%1$s[]" id="%1$s_%2$s" value="%2$s" class="%3$s" %4$s />%5$s</label><br>',
|
915 |
-
$field,
|
916 |
$key,
|
917 |
-
$class,
|
918 |
$checked,
|
919 |
$label
|
920 |
);
|
921 |
}
|
922 |
|
923 |
$out .= '</fieldset>';
|
924 |
-
$out .= sprintf( '<p class="description">%s</p>' , $description );
|
925 |
|
926 |
echo $out;
|
927 |
|
928 |
-
} //
|
|
|
929 |
|
930 |
/**
|
931 |
* This function provides radio buttons for settings fields
|
932 |
*/
|
933 |
-
|
934 |
-
|
935 |
-
extract( $args );
|
936 |
|
937 |
$html = '';
|
938 |
|
939 |
-
if ( ! empty( $prescription ) ) {
|
940 |
-
$html .= sprintf( '<p class="prescription">%s</p>', $prescription );
|
941 |
}
|
942 |
|
943 |
-
foreach ( $items as $key => $val ) {
|
944 |
|
945 |
-
$checked =
|
946 |
$html .= sprintf(
|
947 |
'<label for="%1$s_%2$s"><input type="radio" name="%1$s" id="%1$s_%2$s" value="%2$s" %3$s>%4$s</label><br />',
|
948 |
-
$field,
|
949 |
$key,
|
950 |
$checked,
|
951 |
$val
|
952 |
);
|
953 |
|
954 |
-
} // foreach $items
|
955 |
|
956 |
-
$html .= sprintf( '<p class="description">%s</p>', $description );
|
957 |
|
958 |
echo $html;
|
959 |
|
960 |
-
} //
|
|
|
961 |
|
962 |
/**
|
963 |
* Menu Callback
|
@@ -977,7 +946,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
977 |
* process options before update
|
978 |
*
|
979 |
*/
|
980 |
-
public function sanitize_options($options) {
|
981 |
|
982 |
$sanitized = get_option( $this->option_name );
|
983 |
|
@@ -1038,8 +1007,8 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
|
1038 |
// now return sanitized options to be written to database
|
1039 |
return $sanitized;
|
1040 |
|
1041 |
-
} //
|
1042 |
|
1043 |
-
} //
|
1044 |
|
1045 |
-
} //
|
1 |
<?php
|
2 |
|
3 |
+
// exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
exit;
|
6 |
+
}
|
7 |
+
|
8 |
if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL_SETTINGS' ) ) {
|
9 |
|
10 |
class WPAU_YOUTUBE_CHANNEL_SETTINGS {
|
18 |
*/
|
19 |
public function __construct() {
|
20 |
|
21 |
+
global $wpau_youtube_channel;
|
22 |
|
23 |
// get default values
|
24 |
+
$this->slug = $wpau_youtube_channel->plugin_slug;
|
25 |
+
$this->option_name = $wpau_youtube_channel->plugin_option;
|
26 |
$this->defaults = get_option( $this->option_name );
|
27 |
|
28 |
// register actions
|
35 |
* hook into WP's register_settings action hook
|
36 |
*/
|
37 |
public function register_settings() {
|
38 |
+
global $wpau_youtube_channel;
|
39 |
|
40 |
// =========================== General ===========================
|
41 |
// --- Add settings section General so we can add fields to it ---
|
109 |
)
|
110 |
),
|
111 |
'class' => 'regular-text',
|
112 |
+
'value' => isset( $this->defaults['channel'] ) ? $this->defaults['channel'] : '',
|
113 |
) // args
|
114 |
);
|
115 |
// Vanity
|
143 |
)
|
144 |
),
|
145 |
'class' => 'regular-text',
|
146 |
+
'value' => isset( $this->defaults['vanity'] ) ? $this->defaults['vanity'] : '',
|
147 |
) // args
|
148 |
);
|
149 |
// Username
|
161 |
__( 'Your YouTube legacy username', 'youtube-channel' )
|
162 |
),
|
163 |
'class' => 'regular-text',
|
164 |
+
'value' => isset( $this->defaults['username'] ) ? $this->defaults['username'] : '',
|
165 |
) // args
|
166 |
);
|
167 |
// Default Playlist
|
179 |
__( 'Enter default playlist ID (not playlist name)', 'youtube-channel' )
|
180 |
),
|
181 |
'class' => 'regular-text',
|
182 |
+
'value' => isset( $this->defaults['playlist'] ) ? $this->defaults['playlist'] : '',
|
183 |
) // args
|
184 |
);
|
185 |
// Resource
|
194 |
'label' => __( 'Resource:', 'youtube-channel' ),
|
195 |
'description' => __( 'What to use as resource for feeds', 'youtube-channel' ),
|
196 |
'class' => 'regular-text',
|
197 |
+
'value' => isset( $this->defaults['resource'] ) ? $this->defaults['resource'] : '0',
|
198 |
'items' => array(
|
199 |
'0' => __( 'Channel', 'youtube-channel' ),
|
200 |
'1' => __( 'Favourites', 'youtube-channel' ),
|
214 |
'field' => $this->option_name . '[cache]',
|
215 |
'description' => __( 'Define caching timeout for YouTube feeds, in seconds', 'youtube-channel' ),
|
216 |
'class' => 'wide-text',
|
217 |
+
'value' => isset( $this->defaults['cache'] ) ? $this->defaults['cache'] : '300',
|
218 |
+
'items' => $wpau_youtube_channel::cache_times_arr(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
)
|
220 |
);
|
221 |
// Fetch
|
229 |
'field' => $this->option_name . '[fetch]',
|
230 |
'description' => __( 'Number of videos that will be used for random pick (min 2, max 50, default 25)', 'youtube-channel' ),
|
231 |
'class' => 'num',
|
232 |
+
'value' => isset( $this->defaults['fetch'] ) ? $this->defaults['fetch'] : '25',
|
233 |
'min' => 1,
|
234 |
'max' => 50,
|
235 |
'std' => 25,
|
246 |
'field' => $this->option_name . '[num]',
|
247 |
'description' => __( 'Number of videos to display', 'youtube-channel' ),
|
248 |
'class' => 'num',
|
249 |
+
'value' => isset( $this->defaults['num'] ) ? $this->defaults['num'] : '1',
|
250 |
'min' => 1,
|
251 |
'max' => 50,
|
252 |
'std' => 1,
|
274 |
),
|
275 |
)
|
276 |
),
|
277 |
+
esc_url( 'https://support.google.com/youtube/answer/171780' ),
|
278 |
__( 'Learn more here', 'youtube-channel' )
|
279 |
),
|
280 |
'class' => 'checkbox',
|
281 |
+
'value' => isset( $this->defaults['privacy'] ) ? $this->defaults['privacy'] : '0',
|
282 |
) // args
|
283 |
);
|
284 |
// TinyMCE icon
|
295 |
__( 'YouTube Channel', 'youtube-channel' )
|
296 |
),
|
297 |
'class' => 'checkbox',
|
298 |
+
'value' => isset( $this->defaults['tinymce'] ) ? $this->defaults['tinymce'] : '0',
|
299 |
) // args
|
300 |
);
|
301 |
// --- Register setting General so $_POST handling is done ---
|
325 |
'field' => $this->option_name . '[width]',
|
326 |
'description' => __( 'Set default width for displayed video, in pixels', 'youtube-channel' ),
|
327 |
'class' => 'num',
|
328 |
+
'value' => isset( $this->defaults['width'] ) ? $this->defaults['width'] : '306',
|
329 |
'min' => 120,
|
330 |
'max' => 1980,
|
331 |
'std' => 306,
|
342 |
'field' => $this->option_name . '[ratio]',
|
343 |
'description' => __( 'Select aspect ratio for displayed video', 'youtube-channel' ),
|
344 |
'class' => 'regular-text',
|
345 |
+
'value' => isset( $this->defaults['ratio'] ) ? $this->defaults['ratio'] : '3',
|
346 |
'items' => array(
|
347 |
'3' => '16:9',
|
348 |
'1' => '4:3',
|
360 |
'field' => $this->option_name . '[display]',
|
361 |
'description' => __( 'Choose how to embed video block', 'youtube-channel' ),
|
362 |
'class' => 'regular-text',
|
363 |
+
'value' => isset( $this->defaults['display'] ) ? $this->defaults['display'] : 'thumbnail',
|
364 |
'items' => array(
|
365 |
'thumbnail' => __( 'Thumbnail', 'youtube-channel' ),
|
366 |
'iframe' => __( 'HTML5 (iframe)', 'youtube-channel' ),
|
381 |
'field' => $this->option_name . '[responsive]',
|
382 |
'description' => __( 'Enable this option to make YTC videos and thumbnails responsive by default. Please note, this option will set videos and thumbnail to full width relative to parent container, and disable more than one video per row.', 'youtube-channel' ),
|
383 |
'class' => 'checkbox',
|
384 |
+
'value' => isset( $this->defaults['responsive'] ) ? $this->defaults['responsive'] : '0',
|
385 |
) // args
|
386 |
);
|
387 |
|
411 |
__( 'Learn more here', 'youtube-channel' )
|
412 |
),
|
413 |
'class' => 'checkbox',
|
414 |
+
'value' => isset( $this->defaults['playsinline'] ) ? $this->defaults['playsinline'] : '0',
|
415 |
) // args
|
416 |
);
|
417 |
// No Lightbox
|
425 |
'field' => $this->option_name . '[nolightbox]',
|
426 |
'description' => __( 'Enable this option to disable built-in lightbox for thumbnails (in case that you have youtube links lightbox trigger in theme or other plugin).', 'youtube-channel' ),
|
427 |
'class' => 'checkbox',
|
428 |
+
'value' => isset( $this->defaults['nolightbox'] ) ? $this->defaults['nolightbox'] : '0',
|
429 |
) // args
|
430 |
);
|
431 |
// Full Screen
|
439 |
'field' => $this->option_name . '[fullscreen]',
|
440 |
'description' => __( 'Enable this option to make available Full Screen button for embedded playlists.', 'youtube-channel' ),
|
441 |
'class' => 'checkbox',
|
442 |
+
'value' => isset( $this->defaults['fullscreen'] ) ? $this->defaults['fullscreen'] : '0',
|
443 |
) // args
|
444 |
);
|
445 |
|
454 |
'field' => $this->option_name . '[themelight]',
|
455 |
'description' => __( 'Enable this option to use light theme for playback controls instead dark.', 'youtube-channel' ),
|
456 |
'class' => 'checkbox',
|
457 |
+
'value' => isset( $this->defaults['themelight'] ) ? $this->defaults['themelight'] : '0',
|
458 |
) // args
|
459 |
);
|
460 |
// No Player Controls
|
468 |
'field' => $this->option_name . '[controls]',
|
469 |
'description' => __( 'Enable this option to hide playback controls', 'youtube-channel' ),
|
470 |
'class' => 'checkbox',
|
471 |
+
'value' => isset( $this->defaults['controls'] ) ? $this->defaults['controls'] : '0',
|
472 |
) // args
|
473 |
);
|
474 |
// Fix Height (deprecated?)
|
483 |
'field' => $this->option_name . '[autoplay]',
|
484 |
'description' => __( 'Enable this option to start video playback right after block is rendered', 'youtube-channel' ),
|
485 |
'class' => 'checkbox',
|
486 |
+
'value' => isset( $this->defaults['autoplay'] ) ? $this->defaults['autoplay'] : '0',
|
487 |
) // args
|
488 |
);
|
489 |
// Mute on autoplay
|
497 |
'field' => $this->option_name . '[autoplay_mute]',
|
498 |
'description' => __( 'Enable this option to mute video when start autoplay', 'youtube-channel' ),
|
499 |
'class' => 'checkbox',
|
500 |
+
'value' => isset( $this->defaults['autoplay_mute'] ) ? $this->defaults['autoplay_mute'] : '0',
|
501 |
) // args
|
502 |
);
|
503 |
// No related videos
|
511 |
'field' => $this->option_name . '[norel]',
|
512 |
'description' => __( 'Enable this option to hide related videos after finished playback', 'youtube-channel' ),
|
513 |
'class' => 'checkbox',
|
514 |
+
'value' => isset( $this->defaults['norel'] ) ? $this->defaults['norel'] : '0',
|
515 |
) // args
|
516 |
);
|
517 |
// Hide YT logo
|
525 |
'field' => $this->option_name . '[modestbranding]',
|
526 |
'description' => __( 'Enable this option to hide YouTube logo from playback control bar. Does not work for all videos.', 'youtube-channel' ),
|
527 |
'class' => 'checkbox',
|
528 |
+
'value' => isset( $this->defaults['modestbranding'] ) ? $this->defaults['modestbranding'] : '0',
|
529 |
) // args
|
530 |
);
|
531 |
// Hide Annotations
|
539 |
'field' => $this->option_name . '[hideanno]',
|
540 |
'description' => __( 'Enable this option to hide video annotations (custom text set by uploader over video during playback)', 'youtube-channel' ),
|
541 |
'class' => 'checkbox',
|
542 |
+
'value' => isset( $this->defaults['hideanno'] ) ? $this->defaults['hideanno'] : '0',
|
543 |
) // args
|
544 |
);
|
545 |
// Hide Video Info
|
553 |
'field' => $this->option_name . '[hideinfo]',
|
554 |
'description' => __( 'Enable this option to hide informations about video before play start (video title and uploader in overlay)', 'youtube-channel' ),
|
555 |
'class' => 'checkbox',
|
556 |
+
'value' => isset( $this->defaults['hideinfo'] ) ? $this->defaults['hideinfo'] : '0',
|
557 |
) // args
|
558 |
);
|
559 |
// --- Register setting Video so $_POST handling is done ---
|
583 |
'field' => $this->option_name . '[showtitle]',
|
584 |
'description' => __( 'Select should we and where display title of video', 'youtube-channel' ),
|
585 |
'class' => 'regular-text',
|
586 |
+
'value' => isset( $this->defaults['showtitle'] ) ? $this->defaults['showtitle'] : 'none',
|
587 |
'items' => array(
|
588 |
'none' => __( 'Hide title', 'youtube-channel' ),
|
589 |
'above' => __( 'Above video/thumbnail', 'youtube-channel' ),
|
602 |
'field' => $this->option_name . '[showdesc]',
|
603 |
'description' => __( 'Enable this option to display description for video', 'youtube-channel' ),
|
604 |
'class' => 'checkbox',
|
605 |
+
'value' => isset( $this->defaults['showdesc'] ) ? $this->defaults['showdesc'] : '0',
|
606 |
) // args
|
607 |
);
|
608 |
// Description length
|
616 |
'field' => $this->option_name . '[desclen]',
|
617 |
'description' => __( 'Enter length for video description in characters (0 for full length)', 'youtube-channel' ),
|
618 |
'class' => 'num',
|
619 |
+
'value' => isset( $this->defaults['desclen'] ) ? $this->defaults['desclen'] : '0',
|
620 |
'min' => 0,
|
621 |
'max' => 2500,
|
622 |
'std' => 0,
|
651 |
// 'label' => __('Ratio:', 'youtube-channel' ),
|
652 |
'description' => __( 'Set where link will lead visitors', 'youtube-channel' ),
|
653 |
'class' => 'regular-text',
|
654 |
+
'value' => isset( $this->defaults['link_to'] ) ? $this->defaults['link_to'] : 'none',
|
655 |
'items' => array(
|
656 |
'none' => __( 'Hide link', 'youtube-channel' ),
|
657 |
'vanity' => __( 'Vanity custom URL', 'youtube-channel' ),
|
672 |
// 'label' => __('Ratio:', 'youtube-channel' ),
|
673 |
'description' => __( 'Set where link will be opened', 'youtube-channel' ),
|
674 |
'class' => 'regular-text',
|
675 |
+
'value' => isset( $this->defaults['popup_goto'] ) ? $this->defaults['popup_goto'] : '0',
|
676 |
'items' => array(
|
677 |
'0' => __( 'same window', 'youtube-channel' ),
|
678 |
'1' => __( 'new window (JavaScript)', 'youtube-channel' ),
|
691 |
'field' => $this->option_name . '[goto_txt]',
|
692 |
'class' => 'regular-text',
|
693 |
'description' => __( 'Set default title for link', 'youtube-channel' ),
|
694 |
+
'value' => isset( $this->defaults['goto_txt'] ) ? $this->defaults['goto_txt'] : '',
|
695 |
) // args
|
696 |
);
|
697 |
|
724 |
|
725 |
// --- Section desciptions ---
|
726 |
public function settings_general_section_description() {
|
727 |
+
|
728 |
+
echo '<p>' .
|
729 |
+
sprintf(
|
730 |
wp_kses(
|
731 |
__(
|
732 |
'Configure general defaults for %1$s used as fallback options in widget or shortcodes. To get %2$s and %3$s visit <a href="%4$s" target="_blank">%5$s</a>.',
|
744 |
__( 'Vanity URL', 'youtube-channel' ),
|
745 |
esc_url( 'https://www.youtube.com/account_advanced' ),
|
746 |
__( 'YouTube Account Overview', 'youtube-channel' )
|
747 |
+
) .
|
748 |
+
'<p>';
|
749 |
+
|
750 |
+
} // END public function settings_general_section_description()
|
751 |
+
|
752 |
public function settings_video_section_description() {
|
753 |
+
echo '<p>' .
|
754 |
+
sprintf(
|
|
|
755 |
__( 'Configure video specific defaults for %s used as fallback options in widget or shortcodes.', 'youtube-channel' ),
|
756 |
__( 'YouTube Channel', 'youtube-channel' )
|
757 |
+
) .
|
758 |
+
'</p>';
|
759 |
+
} // END public function settings_video_section_description()
|
760 |
+
|
761 |
public function settings_content_section_description() {
|
762 |
+
echo '<p>' .
|
763 |
+
sprintf(
|
|
|
764 |
__( 'Configure defaults of content around and over videos for %s used as fallback options in widget or shortcodes.', 'youtube-channel' ),
|
765 |
__( 'YouTube Channel', 'youtube-channel' )
|
766 |
+
) .
|
767 |
+
'</p>';
|
768 |
+
} // END public function settings_content_section_description()
|
769 |
+
|
770 |
public function settings_link_section_description() {
|
771 |
+
echo '<p>' .
|
772 |
+
sprintf(
|
|
|
773 |
__( 'Configure defaults for link to channel below %s block used as fallback options in widget or shortcodes.', 'youtube-channel' ),
|
774 |
__( 'YouTube Channel', 'youtube-channel' )
|
775 |
+
) .
|
776 |
+
'</p>';
|
777 |
+
} // END public function settings_link_section_description()
|
|
|
778 |
|
779 |
/**
|
780 |
* This function provides separator for settings fields
|
781 |
*/
|
782 |
public function settings_field_separator( $args = null ) {
|
783 |
echo '<hr>';
|
784 |
+
} // END public function settings_field_input_text()
|
785 |
|
786 |
/**
|
787 |
* This function provides text inputs for settings fields
|
788 |
*/
|
789 |
+
public function settings_field_input_text( $args ) {
|
|
|
|
|
790 |
|
791 |
printf(
|
792 |
'<input type="text" name="%1$s" id="%1$s" value="%2$s" class="%3$s" /><p class="description">%4$s</p>',
|
793 |
+
$args['field'],
|
794 |
+
$args['value'],
|
795 |
+
$args['class'],
|
796 |
+
$args['description']
|
797 |
);
|
798 |
|
799 |
+
} // END public function settings_field_input_text()
|
800 |
|
801 |
/**
|
802 |
* This function provides password inputs for settings fields
|
803 |
*/
|
804 |
+
public function settings_field_input_password( $args ) {
|
|
|
|
|
805 |
|
806 |
printf(
|
807 |
'<input type="password" name="%1$s" id="%1$s" value="%2$s" class="%3$s" /><p class="description">%4$s</p>',
|
808 |
+
$args['field'],
|
809 |
+
$args['value'],
|
810 |
+
$args['class'],
|
811 |
+
$args['description']
|
812 |
);
|
813 |
|
814 |
+
} // END public function settings_field_input_text()
|
815 |
|
816 |
/**
|
817 |
* This function provides number inputs for settings fields
|
818 |
*/
|
819 |
+
public function settings_field_input_number( $args ) {
|
|
|
|
|
820 |
|
821 |
printf(
|
822 |
'<input type="number" name="%1$s" id="%1$s" value="%2$s" min="%3$s" max="%4$s" class="%5$s" /><p class="description">%6$s</p>',
|
823 |
+
$args['field'],
|
824 |
+
$args['value'],
|
825 |
+
$args['min'],
|
826 |
+
$args['max'],
|
827 |
+
$args['class'],
|
828 |
+
$args['description']
|
829 |
);
|
830 |
|
831 |
+
} // END public function settings_field_input_text()
|
832 |
|
833 |
/**
|
834 |
* This function provides select for settings fields
|
835 |
*/
|
836 |
+
public function settings_field_select( $args ) {
|
837 |
|
838 |
+
$html = sprintf( '<select id="%1$s" name="%1$s">', $args['field'] );
|
839 |
+
foreach ( $args['items'] as $key => $val ) {
|
840 |
+
$selected = ( $args['value'] == $key ) ? 'selected="selected"' : '';
|
|
|
|
|
|
|
|
|
841 |
$html .= sprintf( '<option %1$s value="%2$s">%3$s</option>', $selected, $key, $val );
|
842 |
}
|
843 |
+
$html .= sprintf( '</select><p class="description">%s</p>', $args['description'] );
|
844 |
|
845 |
echo $html;
|
846 |
|
847 |
+
} // END public function settings_field_select()
|
848 |
|
849 |
/**
|
850 |
* This function provides checkbox for settings fields
|
851 |
*/
|
852 |
+
public function settings_field_checkbox( $args ) {
|
|
|
|
|
853 |
|
854 |
+
$checked = ! empty( $args['value'] ) ? 'checked="checked"' : '';
|
855 |
printf(
|
856 |
'<label for="%1$s"><input type="checkbox" name="%1$s" id="%1$s" value="1" class="%2$s" %3$s />%4$s</label>',
|
857 |
+
$args['field'],
|
858 |
+
$args['class'],
|
859 |
$checked,
|
860 |
+
$args['description']
|
861 |
);
|
862 |
|
863 |
+
} // END public function settings_field_checkbox()
|
864 |
|
865 |
/**
|
866 |
* This function provides checkbox groupfor settings fields
|
867 |
*/
|
868 |
+
/*
|
869 |
+
public function settings_field_checkbox_group( $args ) {
|
|
|
870 |
|
871 |
// items
|
872 |
$out = '<fieldset>';
|
873 |
|
874 |
+
foreach ( $args['items'] as $key => $label ) {
|
875 |
|
876 |
$checked = '';
|
877 |
+
if ( ! empty( $args['value'] ) ) {
|
878 |
+
$checked = in_array( $key, $args['value'] ) ? 'checked="checked"' : '';
|
879 |
}
|
880 |
|
881 |
$out .= sprintf(
|
882 |
'<label for="%1$s_%2$s"><input type="checkbox" name="%1$s[]" id="%1$s_%2$s" value="%2$s" class="%3$s" %4$s />%5$s</label><br>',
|
883 |
+
$args['field'],
|
884 |
$key,
|
885 |
+
$args['class'],
|
886 |
$checked,
|
887 |
$label
|
888 |
);
|
889 |
}
|
890 |
|
891 |
$out .= '</fieldset>';
|
892 |
+
$out .= sprintf( '<p class="description">%s</p>' , $args['description'] );
|
893 |
|
894 |
echo $out;
|
895 |
|
896 |
+
} // END public function settings_field_checkbox_group()
|
897 |
+
/**/
|
898 |
|
899 |
/**
|
900 |
* This function provides radio buttons for settings fields
|
901 |
*/
|
902 |
+
/*
|
903 |
+
public function settings_field_radio( $args ) {
|
|
|
904 |
|
905 |
$html = '';
|
906 |
|
907 |
+
if ( ! empty( $args['prescription'] ) ) {
|
908 |
+
$html .= sprintf( '<p class="prescription">%s</p>', $args['prescription'] );
|
909 |
}
|
910 |
|
911 |
+
foreach ( $args['items'] as $key => $val ) {
|
912 |
|
913 |
+
$checked = $args['value'] == $key ? 'checked="checked"' : '';
|
914 |
$html .= sprintf(
|
915 |
'<label for="%1$s_%2$s"><input type="radio" name="%1$s" id="%1$s_%2$s" value="%2$s" %3$s>%4$s</label><br />',
|
916 |
+
$args['field'],
|
917 |
$key,
|
918 |
$checked,
|
919 |
$val
|
920 |
);
|
921 |
|
922 |
+
} // END foreach $args['items']
|
923 |
|
924 |
+
$html .= sprintf( '<p class="description">%s</p>', $args['description'] );
|
925 |
|
926 |
echo $html;
|
927 |
|
928 |
+
} // END public function settings_field_radio()
|
929 |
+
/**/
|
930 |
|
931 |
/**
|
932 |
* Menu Callback
|
946 |
* process options before update
|
947 |
*
|
948 |
*/
|
949 |
+
public function sanitize_options( $options ) {
|
950 |
|
951 |
$sanitized = get_option( $this->option_name );
|
952 |
|
1007 |
// now return sanitized options to be written to database
|
1008 |
return $sanitized;
|
1009 |
|
1010 |
+
} // END public function sanitize_options()
|
1011 |
|
1012 |
+
} // END class WPAU_YOUTUBE_CHANNEL_SETTINGS
|
1013 |
|
1014 |
+
} // END class_exists WPAU_YOUTUBE_CHANNEL_SETTINGS
|
@@ -1,5 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
@@ -1,91 +1,101 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
/*
|
4 |
class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
5 |
|
6 |
public function __construct() {
|
7 |
-
|
|
|
|
|
8 |
// Initialize Widget
|
9 |
parent::__construct(
|
10 |
-
$
|
11 |
__( 'YouTube Channel' , 'youtube-channel' ),
|
12 |
array(
|
13 |
'description' => __(
|
14 |
'Serve YouTube videos from channel or playlist right to widget area',
|
15 |
'youtube-channel'
|
16 |
),
|
|
|
17 |
)
|
18 |
);
|
19 |
-
}
|
20 |
|
21 |
-
|
22 |
-
global $WPAU_YOUTUBE_CHANNEL;
|
23 |
-
// outputs the content of the widget
|
24 |
-
extract( $args );
|
25 |
|
26 |
-
|
|
|
27 |
|
28 |
-
$
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
}
|
33 |
-
$output
|
34 |
-
$output
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
37 |
-
|
38 |
|
39 |
-
public function form($instance) {
|
40 |
-
global $WPAU_YOUTUBE_CHANNEL;
|
41 |
$defaults = get_option( 'youtube_channel_defaults' );
|
42 |
|
43 |
-
//
|
|
|
44 |
// General Options
|
45 |
-
$title =
|
46 |
-
$class =
|
47 |
-
$vanity =
|
48 |
-
$channel =
|
49 |
-
$username =
|
50 |
-
$playlist =
|
51 |
|
52 |
-
$resource = (
|
53 |
|
54 |
-
$cache = (
|
55 |
|
56 |
-
$fetch =
|
57 |
-
$num =
|
58 |
|
59 |
-
$privacy =
|
60 |
-
$random =
|
61 |
|
62 |
// Video Settings
|
63 |
-
$ratio =
|
64 |
-
$width =
|
65 |
-
$responsive =
|
66 |
|
67 |
-
$display =
|
68 |
-
$no_thumb_title =
|
69 |
|
70 |
-
$themelight =
|
71 |
-
$controls =
|
72 |
-
$autoplay =
|
73 |
-
$autoplay_mute =
|
74 |
-
$norel =
|
75 |
|
76 |
// Content Layout
|
77 |
-
$showtitle =
|
78 |
-
$showdesc =
|
79 |
-
$modestbranding =
|
80 |
-
$desclen =
|
81 |
|
82 |
-
$hideanno =
|
83 |
-
$hideinfo =
|
84 |
|
85 |
// Link to Channel
|
86 |
-
$link_to =
|
87 |
-
$goto_txt =
|
88 |
-
$popup_goto = (
|
89 |
?>
|
90 |
|
91 |
<p>
|
@@ -98,7 +108,8 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
98 |
<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' ); ?>" />
|
99 |
</label>
|
100 |
</p>
|
101 |
-
<p
|
|
|
102 |
printf(
|
103 |
wp_kses(
|
104 |
__(
|
@@ -111,7 +122,8 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
111 |
__( 'Custom ID', 'youtube-channel' ),
|
112 |
'https://www.youtube.com/account_advanced'
|
113 |
);
|
114 |
-
|
|
|
115 |
<p class="half left glue-top">
|
116 |
<label for="<?php echo $this->get_field_id( 'vanity' ); ?>"><?php _e( 'Vanity/Custom ID', 'youtube-channel' ); ?>
|
117 |
<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' ); ?>" />
|
@@ -146,7 +158,7 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
146 |
<label for="<?php echo $this->get_field_id( 'cache' ); ?>"><?php _e( 'Cache feed', 'youtube-channel' ); ?>
|
147 |
<select class="widefat" id="<?php echo $this->get_field_id( 'cache' ); ?>" name="<?php echo $this->get_field_name( 'cache' ); ?>">
|
148 |
<option value="0"<?php selected( $cache, 0 ); ?>><?php _e( 'Do not cache', 'youtube-channel' ); ?></option>
|
149 |
-
<?php echo $
|
150 |
</select>
|
151 |
</label>
|
152 |
</p>
|
@@ -157,7 +169,7 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
157 |
<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' ); ?>
|
158 |
</p>
|
159 |
<p>
|
160 |
-
<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( __( 'Enable <a href="%s" target="_blank">privacy-enhanced mode</a>', 'youtube-channel' ), '
|
161 |
<br />
|
162 |
<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 from resource <small>(Have no effect if "What to show?" has been set to "Embedded Playlist")</small>', 'youtube-channel' ); ?></label>
|
163 |
</p>
|
@@ -218,7 +230,7 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
218 |
|
219 |
<h4><?php _e( 'Link to Channel', 'youtube-channel' ); ?></h4>
|
220 |
<p class="glue-top">
|
221 |
-
<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
|
222 |
</p>
|
223 |
<p class="half left glue-top">
|
224 |
<select class="widefat" id="<?php echo $this->get_field_id( 'link_to' ); ?>" name="<?php echo $this->get_field_name( 'link_to' ); ?>">
|
@@ -238,7 +250,8 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
238 |
|
239 |
<h4><?php _e( 'Does not work?', 'youtube-channel' ); ?></h4>
|
240 |
<p>
|
241 |
-
<small
|
|
|
242 |
printf(
|
243 |
wp_kses(
|
244 |
__(
|
@@ -250,15 +263,17 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
250 |
'https://wordpress.org/plugins/youtube-channel/faq/',
|
251 |
__( 'FAQ', 'youtube-channel' ),
|
252 |
"?ytc_debug_json_for={$this->number}",
|
253 |
-
'
|
254 |
'https://wordpress.org/support/topic/ytc3-read-before-you-post-support-question-or-report-bug'
|
255 |
-
);
|
|
|
256 |
</p>
|
257 |
|
258 |
-
<?php
|
259 |
-
}
|
|
|
|
|
260 |
|
261 |
-
public function update($new_instance, $old_instance) {
|
262 |
// processes widget options to be saved
|
263 |
$instance = $old_instance;
|
264 |
$instance['title'] = strip_tags( $new_instance['title'] );
|
@@ -270,40 +285,40 @@ class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
|
270 |
$instance['num'] = $new_instance['num'];
|
271 |
$instance['resource'] = $new_instance['resource'];
|
272 |
$instance['cache'] = $new_instance['cache'];
|
273 |
-
$instance['random'] =
|
274 |
$instance['fetch'] = $new_instance['fetch'];
|
275 |
|
276 |
$instance['goto_txt'] = strip_tags( $new_instance['goto_txt'] );
|
277 |
$instance['popup_goto'] = $new_instance['popup_goto'];
|
278 |
$instance['link_to'] = $new_instance['link_to'];
|
279 |
|
280 |
-
$instance['showtitle'] =
|
281 |
-
$instance['showdesc'] =
|
282 |
$instance['desclen'] = strip_tags( $new_instance['desclen'] );
|
283 |
$instance['width'] = strip_tags( $new_instance['width'] );
|
284 |
-
$instance['responsive'] =
|
285 |
|
286 |
$instance['display'] = strip_tags( $new_instance['display'] );
|
287 |
-
$instance['no_thumb_title'] =
|
288 |
-
$instance['autoplay'] =
|
289 |
-
$instance['autoplay_mute'] =
|
290 |
-
$instance['norel'] =
|
291 |
-
$instance['modestbranding'] =
|
292 |
|
293 |
-
$instance['controls'] = ( isset( $new_instance['controls'] ) ) ? $new_instance['controls'] : false;
|
294 |
$instance['ratio'] = strip_tags( $new_instance['ratio'] );
|
295 |
-
$instance['
|
296 |
-
$instance['
|
297 |
-
$instance['
|
298 |
-
$instance['
|
|
|
299 |
|
300 |
return $instance;
|
301 |
-
}
|
302 |
|
303 |
-
} //
|
304 |
|
|
|
305 |
|
306 |
-
//
|
307 |
function wpau_register_youtube_channel_widget() {
|
308 |
register_widget( 'WPAU_YOUTUBE_CHANNEL_Widget' );
|
309 |
}
|
1 |
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
|
7 |
+
/* YouTube Channel Widget */
|
8 |
class WPAU_YOUTUBE_CHANNEL_Widget extends WP_Widget {
|
9 |
|
10 |
public function __construct() {
|
11 |
+
|
12 |
+
global $wpau_youtube_channel;
|
13 |
+
|
14 |
// Initialize Widget
|
15 |
parent::__construct(
|
16 |
+
$wpau_youtube_channel->plugin_slug,
|
17 |
__( 'YouTube Channel' , 'youtube-channel' ),
|
18 |
array(
|
19 |
'description' => __(
|
20 |
'Serve YouTube videos from channel or playlist right to widget area',
|
21 |
'youtube-channel'
|
22 |
),
|
23 |
+
'customize_selective_refresh' => true,
|
24 |
)
|
25 |
);
|
|
|
26 |
|
27 |
+
} // END function __construct()
|
|
|
|
|
|
|
28 |
|
29 |
+
// Outputs the content of the widget
|
30 |
+
public function widget( $args, $instance ) {
|
31 |
|
32 |
+
global $wpau_youtube_channel;
|
33 |
+
|
34 |
+
$output = $args['before_widget'];
|
35 |
+
if ( ! empty( $instance['title'] ) ) {
|
36 |
+
$output .= $args['before_title'];
|
37 |
+
$output .= apply_filters( 'widget_title', $instance['title'] );
|
38 |
+
$output .= $args['after_title'];
|
39 |
}
|
40 |
+
$output .= $wpau_youtube_channel->output( $instance );
|
41 |
+
$output .= $args['after_widget'];
|
42 |
+
|
43 |
+
echo $output;
|
44 |
+
|
45 |
+
} // END public function widget()
|
46 |
|
47 |
+
public function form( $instance ) {
|
48 |
+
global $wpau_youtube_channel;
|
49 |
|
|
|
|
|
50 |
$defaults = get_option( 'youtube_channel_defaults' );
|
51 |
|
52 |
+
// Outputs the options form for widget settings
|
53 |
+
|
54 |
// General Options
|
55 |
+
$title = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
|
56 |
+
$class = ! empty( $instance['class'] ) ? esc_attr( $instance['class'] ) : '';
|
57 |
+
$vanity = ! empty( $instance['vanity'] ) ? esc_attr( $instance['vanity'] ) : '';
|
58 |
+
$channel = ! empty( $instance['channel'] ) ? esc_attr( $instance['channel'] ) : '';
|
59 |
+
$username = ! empty( $instance['username'] ) ? esc_attr( $instance['username'] ) : '';
|
60 |
+
$playlist = ! empty( $instance['playlist'] ) ? esc_attr( $instance['playlist'] ) : '';
|
61 |
|
62 |
+
$resource = isset( $instance['resource'] ) ? intval( $instance['resource'] ) : intval( $defaults['resource'] ); // resource to use: channel, favorites, playlist
|
63 |
|
64 |
+
$cache = isset( $instance['cache'] ) ? intval( $instance['cache'] ) : intval( $defaults['cache'] );
|
65 |
|
66 |
+
$fetch = ! empty( $instance['fetch'] ) ? intval( $instance['fetch'] ) : intval( $defaults['fetch'] ); // items to fetch
|
67 |
+
$num = ! empty( $instance['num'] ) ? intval( $instance['num'] ) : intval( $defaults['num'] ); // number of items to show
|
68 |
|
69 |
+
$privacy = ! empty( $instance['privacy'] ) ? esc_attr( $instance['privacy'] ) : 0;
|
70 |
+
$random = ! empty( $instance['random'] ) ? esc_attr( $instance['random'] ) : 0;
|
71 |
|
72 |
// Video Settings
|
73 |
+
$ratio = ! empty( $instance['ratio'] ) ? esc_attr( $instance['ratio'] ) : trim( $defaults['ratio'] );
|
74 |
+
$width = ! empty( $instance['width'] ) ? esc_attr( $instance['width'] ) : trim( $defaults['width'] );
|
75 |
+
$responsive = isset( $instance['responsive'] ) ? esc_attr( $instance['responsive'] ) : 1;
|
76 |
|
77 |
+
$display = ! empty( $instance['display'] ) ? esc_attr( $instance['display'] ) : trim( $defaults['display'] );
|
78 |
+
$no_thumb_title = ! empty( $instance['no_thumb_title'] ) ? esc_attr( $instance['no_thumb_title'] ) : 0;
|
79 |
|
80 |
+
$themelight = ! empty( $instance['themelight'] ) ? esc_attr( $instance['themelight'] ) : '';
|
81 |
+
$controls = ! empty( $instance['controls'] ) ? esc_attr( $instance['controls'] ) : '';
|
82 |
+
$autoplay = ! empty( $instance['autoplay'] ) ? esc_attr( $instance['autoplay'] ) : '';
|
83 |
+
$autoplay_mute = ! empty( $instance['autoplay_mute'] ) ? esc_attr( $instance['autoplay_mute'] ) : '';
|
84 |
+
$norel = ! empty( $instance['norel'] ) ? esc_attr( $instance['norel'] ) : '';
|
85 |
|
86 |
// Content Layout
|
87 |
+
$showtitle = ! empty( $instance['showtitle'] ) ? esc_attr( $instance['showtitle'] ) : 'none';
|
88 |
+
$showdesc = ! empty( $instance['showdesc'] ) ? esc_attr( $instance['showdesc'] ) : '';
|
89 |
+
$modestbranding = ! empty( $instance['modestbranding'] ) ? esc_attr( $instance['modestbranding'] ) : '';
|
90 |
+
$desclen = ! empty( $instance['desclen'] ) ? esc_attr( $instance['desclen'] ) : 0;
|
91 |
|
92 |
+
$hideanno = ! empty( $instance['hideanno'] ) ? esc_attr( $instance['hideanno'] ) : '';
|
93 |
+
$hideinfo = ! empty( $instance['hideinfo'] ) ? esc_attr( $instance['hideinfo'] ) : '';
|
94 |
|
95 |
// Link to Channel
|
96 |
+
$link_to = ! empty( $instance['link_to'] ) ? esc_attr( $instance['link_to'] ) : 'none';
|
97 |
+
$goto_txt = ! empty( $instance['goto_txt'] ) ? esc_attr( $instance['goto_txt'] ) : '';
|
98 |
+
$popup_goto = isset( $instance['popup_goto'] ) ? intval( $instance['popup_goto'] ) : $defaults['popup_goto'];
|
99 |
?>
|
100 |
|
101 |
<p>
|
108 |
<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' ); ?>" />
|
109 |
</label>
|
110 |
</p>
|
111 |
+
<p>
|
112 |
+
<?php
|
113 |
printf(
|
114 |
wp_kses(
|
115 |
__(
|
122 |
__( 'Custom ID', 'youtube-channel' ),
|
123 |
'https://www.youtube.com/account_advanced'
|
124 |
);
|
125 |
+
?>
|
126 |
+
</p>
|
127 |
<p class="half left glue-top">
|
128 |
<label for="<?php echo $this->get_field_id( 'vanity' ); ?>"><?php _e( 'Vanity/Custom ID', 'youtube-channel' ); ?>
|
129 |
<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' ); ?>" />
|
158 |
<label for="<?php echo $this->get_field_id( 'cache' ); ?>"><?php _e( 'Cache feed', 'youtube-channel' ); ?>
|
159 |
<select class="widefat" id="<?php echo $this->get_field_id( 'cache' ); ?>" name="<?php echo $this->get_field_name( 'cache' ); ?>">
|
160 |
<option value="0"<?php selected( $cache, 0 ); ?>><?php _e( 'Do not cache', 'youtube-channel' ); ?></option>
|
161 |
+
<?php echo $wpau_youtube_channel->cache_time( $cache ); ?>
|
162 |
</select>
|
163 |
</label>
|
164 |
</p>
|
169 |
<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' ); ?>
|
170 |
</p>
|
171 |
<p>
|
172 |
+
<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( __( 'Enable <a href="%s" target="_blank">privacy-enhanced mode</a>', 'youtube-channel' ), 'https://support.google.com/youtube/bin/answer.py?hl=en-GB&answer=171780' ); ?></label>
|
173 |
<br />
|
174 |
<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 from resource <small>(Have no effect if "What to show?" has been set to "Embedded Playlist")</small>', 'youtube-channel' ); ?></label>
|
175 |
</p>
|
230 |
|
231 |
<h4><?php _e( 'Link to Channel', 'youtube-channel' ); ?></h4>
|
232 |
<p class="glue-top">
|
233 |
+
<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 sprintf( __( 'Default: Visit our YouTube channel. You can use placeholders %1$s, %2$s and %3$s.', 'youtube-channel' ), '%vanity%', '%channel%', '%username%' ); ?>" placeholder="<?php _e( 'Visit our YouTube channel', 'youtube-channel' ); ?>" />
|
234 |
</p>
|
235 |
<p class="half left glue-top">
|
236 |
<select class="widefat" id="<?php echo $this->get_field_id( 'link_to' ); ?>" name="<?php echo $this->get_field_name( 'link_to' ); ?>">
|
250 |
|
251 |
<h4><?php _e( 'Does not work?', 'youtube-channel' ); ?></h4>
|
252 |
<p>
|
253 |
+
<small>
|
254 |
+
<?php
|
255 |
printf(
|
256 |
wp_kses(
|
257 |
__(
|
263 |
'https://wordpress.org/plugins/youtube-channel/faq/',
|
264 |
__( 'FAQ', 'youtube-channel' ),
|
265 |
"?ytc_debug_json_for={$this->number}",
|
266 |
+
'https://wordpress.org/support/plugin/youtube-channel',
|
267 |
'https://wordpress.org/support/topic/ytc3-read-before-you-post-support-question-or-report-bug'
|
268 |
+
); ?>
|
269 |
+
</small>
|
270 |
</p>
|
271 |
|
272 |
+
<?php
|
273 |
+
} // END public function form()
|
274 |
+
|
275 |
+
public function update( $new_instance, $old_instance ) {
|
276 |
|
|
|
277 |
// processes widget options to be saved
|
278 |
$instance = $old_instance;
|
279 |
$instance['title'] = strip_tags( $new_instance['title'] );
|
285 |
$instance['num'] = $new_instance['num'];
|
286 |
$instance['resource'] = $new_instance['resource'];
|
287 |
$instance['cache'] = $new_instance['cache'];
|
288 |
+
$instance['random'] = isset( $new_instance['random'] ) ? $new_instance['random'] : false;
|
289 |
$instance['fetch'] = $new_instance['fetch'];
|
290 |
|
291 |
$instance['goto_txt'] = strip_tags( $new_instance['goto_txt'] );
|
292 |
$instance['popup_goto'] = $new_instance['popup_goto'];
|
293 |
$instance['link_to'] = $new_instance['link_to'];
|
294 |
|
295 |
+
$instance['showtitle'] = isset( $new_instance['showtitle'] ) ? $new_instance['showtitle'] : 'none';
|
296 |
+
$instance['showdesc'] = isset( $new_instance['showdesc'] ) ? $new_instance['showdesc'] : false;
|
297 |
$instance['desclen'] = strip_tags( $new_instance['desclen'] );
|
298 |
$instance['width'] = strip_tags( $new_instance['width'] );
|
299 |
+
$instance['responsive'] = isset( $new_instance['responsive'] ) ? $new_instance['responsive'] : '';
|
300 |
|
301 |
$instance['display'] = strip_tags( $new_instance['display'] );
|
302 |
+
$instance['no_thumb_title'] = isset( $new_instance['no_thumb_title'] ) ? $new_instance['no_thumb_title'] : false;
|
303 |
+
$instance['autoplay'] = isset( $new_instance['autoplay'] ) ? $new_instance['autoplay'] : false;
|
304 |
+
$instance['autoplay_mute'] = isset( $new_instance['autoplay_mute'] ) ? $new_instance['autoplay_mute'] : false;
|
305 |
+
$instance['norel'] = isset( $new_instance['norel'] ) ? $new_instance['norel'] : false;
|
306 |
+
$instance['modestbranding'] = isset( $new_instance['modestbranding'] ) ? $new_instance['modestbranding'] : false;
|
307 |
|
|
|
308 |
$instance['ratio'] = strip_tags( $new_instance['ratio'] );
|
309 |
+
$instance['controls'] = isset( $new_instance['controls'] ) ? $new_instance['controls'] : false;
|
310 |
+
$instance['hideinfo'] = isset( $new_instance['hideinfo'] ) ? $new_instance['hideinfo'] : '';
|
311 |
+
$instance['hideanno'] = isset( $new_instance['hideanno'] ) ? $new_instance['hideanno'] : '';
|
312 |
+
$instance['themelight'] = isset( $new_instance['themelight'] ) ? $new_instance['themelight'] : '';
|
313 |
+
$instance['privacy'] = isset( $new_instance['privacy'] ) ? $new_instance['privacy'] : '';
|
314 |
|
315 |
return $instance;
|
|
|
316 |
|
317 |
+
} // END public function update()
|
318 |
|
319 |
+
} // END class WPAU_YOUTUBE_CHANNEL_Widget()
|
320 |
|
321 |
+
// Register WPAU_YOUTUBE_CHANNEL_Widget widget
|
322 |
function wpau_register_youtube_channel_widget() {
|
323 |
register_widget( 'WPAU_YOUTUBE_CHANNEL_Widget' );
|
324 |
}
|
@@ -1,10 +1,10 @@
|
|
1 |
=== YouTube Channel ===
|
2 |
Contributors: urkekg
|
3 |
-
Donate link:
|
4 |
Tags: youtube, channel, playlist, single, widget, widgets, youtube player, feed, video, thumbnail, embed, sidebar, iframe, html5, responsive
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 3.0.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -206,7 +206,7 @@ Do exactly what message says - check and correct Channel ID in default settings/
|
|
206 |
|
207 |
> **YTC ERROR** Check YouTube Data API Key restrictions, empty cache if enabled by appending in browser address bar parameter ?ytc_force_recache=1
|
208 |
|
209 |
-
1. Try to remove restrictions by IP in your
|
210 |
1. If that does not help, please try to create new API Key for Server w/o restrictions (not to regenerate existing one).
|
211 |
|
212 |
= How to use Google APIs Explorer to verify YouTube feeds? =
|
@@ -353,6 +353,21 @@ If you really need that missing feature ASAP, feel free to [contact me](urosevic
|
|
353 |
If you don't wish to pay for enhancements (then you don't care would that be implemented in a week, month, year or so), then send new [Support topic](https://wordpress.org/support/plugin/youtube-channel) with *Topic title* in format **[Feature Request] ...**
|
354 |
|
355 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
= 3.0.9 =
|
358 |
* Fix: broken autoplay when start to play all videos instead only first in YTC block set
|
1 |
=== YouTube Channel ===
|
2 |
Contributors: urkekg
|
3 |
+
Donate link: https://urosevic.net/wordpress/donate/?donate_for=youtube-channel
|
4 |
Tags: youtube, channel, playlist, single, widget, widgets, youtube player, feed, video, thumbnail, embed, sidebar, iframe, html5, responsive
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 4.7
|
7 |
+
Stable tag: 3.0.10
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
206 |
|
207 |
> **YTC ERROR** Check YouTube Data API Key restrictions, empty cache if enabled by appending in browser address bar parameter ?ytc_force_recache=1
|
208 |
|
209 |
+
1. Try to remove restrictions by referer or IP in your **YouTube Data API Key** and refresh page after couple minutes.
|
210 |
1. If that does not help, please try to create new API Key for Server w/o restrictions (not to regenerate existing one).
|
211 |
|
212 |
= How to use Google APIs Explorer to verify YouTube feeds? =
|
353 |
If you don't wish to pay for enhancements (then you don't care would that be implemented in a week, month, year or so), then send new [Support topic](https://wordpress.org/support/plugin/youtube-channel) with *Topic title* in format **[Feature Request] ...**
|
354 |
|
355 |
== Changelog ==
|
356 |
+
= 3.0.10 (20161231) =
|
357 |
+
* (20161225) Optimize: Remove `extract()` from shortcode parser
|
358 |
+
* Code cleanup and fixing to be compliant with WordPress Core coding standards
|
359 |
+
* Test compatibility with WordPreee 4.7 and PHP 7.0.14
|
360 |
+
* (20161224) Change: Update notification for missing YouTube Data API Key
|
361 |
+
* Change: Do not display shortcode options changes for fresh installation
|
362 |
+
* (20160824) Change: HTTP to HTTPS links and open remote links on settings page in new tab/window
|
363 |
+
* Change: Disable deprecated notification related to old v2.4 of plugin
|
364 |
+
* (20160419) Fix: resource from globals used if in widget set to use User uploads as resource.
|
365 |
+
* Enhance: Implemented Selective Refresh Support for Widget (WP 4.5)
|
366 |
+
* (20160131) Fix: prevent PHP Notices for Settings page.
|
367 |
+
* Fix: `Cache feed` option in widget can't be disabled (always revert to default).
|
368 |
+
* Fix: `Open link in` option in widget always revert to default.
|
369 |
+
* Security: prevent direct loading of settings and widget files.
|
370 |
+
* (20160120) Optimize: replace yt_play.png with optimized image.
|
371 |
|
372 |
= 3.0.9 =
|
373 |
* Fix: broken autoplay when start to play all videos instead only first in YTC block set
|
@@ -38,7 +38,7 @@ function au_youtube_channel_update() {
|
|
38 |
}
|
39 |
|
40 |
// Update plugin version number
|
41 |
-
update_option('youtube_channel_version', WPAU_YOUTUBE_CHANNEL::VER);
|
42 |
|
43 |
} // END function au_youtube_channel_update()
|
44 |
|
@@ -47,83 +47,81 @@ function au_youtube_channel_update() {
|
|
47 |
*/
|
48 |
function au_youtube_channel_update_routine_2() {
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
-
|
54 |
|
55 |
-
|
56 |
-
|
57 |
|
58 |
-
|
59 |
-
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
$v['popup_goto'] = 0;
|
69 |
-
if ( $v['popupgoto'] == 'on' ) {
|
70 |
-
$v['popup_goto'] = 1;
|
71 |
-
} else if ($v['target'] == 'on') {
|
72 |
-
$v['popup_goto'] = 2;
|
73 |
-
}
|
74 |
-
unset($v['usepl'], $v['popupgoto'], $v['target']);
|
75 |
-
|
76 |
-
$v['cache_time'] = 0;
|
77 |
-
$v['userchan'] = 0;
|
78 |
-
$v['enhprivacy'] = 0;
|
79 |
-
$v['autoplay_mute'] = 0;
|
80 |
-
|
81 |
-
// add old YTC widget to new set
|
82 |
-
// but append at the end if YTC widget with same ID already exist
|
83 |
-
// in new set (created in version 2.0.0)
|
84 |
-
if ( is_array($new[$k]) ) {
|
85 |
-
// populate at the end
|
86 |
-
array_push($new, $v);
|
87 |
-
$ytc_widget_id = 'youtube-channel-' . end( array_keys($new) );
|
88 |
-
} else {
|
89 |
-
// set as current widget ID
|
90 |
-
$new[$k] = $v;
|
91 |
-
$ytc_widget_id = "youtube-channel-$k";
|
92 |
-
}
|
93 |
-
|
94 |
-
$ytc_widget_added = 0;
|
95 |
-
foreach ( $widget_areas as $wak => $wav ) {
|
96 |
-
// check if here we have this widget
|
97 |
-
if ( is_array($wav) && in_array($ytc_widget_id, $wav) ) {
|
98 |
-
++$ytc_widget_added;
|
99 |
-
}
|
100 |
-
}
|
101 |
-
// fre some memory
|
102 |
-
unset($wak, $wav);
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
-
|
|
|
|
|
|
|
|
|
112 |
|
113 |
-
|
114 |
-
update_option('sidebars_widgets', $widget_areas);
|
115 |
|
116 |
-
|
117 |
-
|
118 |
|
119 |
-
|
120 |
-
|
121 |
|
122 |
-
|
|
|
123 |
|
124 |
-
|
125 |
-
unset ($old, $new, $k, $v, $widget_areas, $ytc_widget_added, $ytc_widget_id);
|
126 |
|
|
|
|
|
127 |
|
128 |
} // END function au_youtube_channel_update_routine_2()
|
129 |
|
@@ -134,12 +132,12 @@ function au_youtube_channel_update_routine_2() {
|
|
134 |
function au_youtube_channel_update_routine_3() {
|
135 |
|
136 |
// Remove deprecated option keys
|
137 |
-
delete_option('ytc_no_redux_notice');
|
138 |
-
delete_option('ytc_old_php_notice');
|
139 |
-
delete_option('ytc_version');
|
140 |
|
141 |
// get options from DB
|
142 |
-
$defaults = get_option('youtube_channel_defaults');
|
143 |
|
144 |
// prepare migration matrix
|
145 |
$options_matrix = array(
|
@@ -151,7 +149,7 @@ function au_youtube_channel_update_routine_3() {
|
|
151 |
'to_show' => 'display',
|
152 |
'showvidesc' => 'showdesc',
|
153 |
'videsclen' => 'desclen',
|
154 |
-
'enhprivacy' => 'privacy'
|
155 |
);
|
156 |
// set defaults
|
157 |
$init = array(
|
@@ -163,60 +161,67 @@ function au_youtube_channel_update_routine_3() {
|
|
163 |
'display' => 'thumbnail', // ex to_show
|
164 |
'showdesc' => 0, // ex showvidesc
|
165 |
'desclen' => 0, // ex videsclen
|
166 |
-
'privacy' => 0 // ex enhprivacy
|
167 |
);
|
168 |
|
169 |
// Do migration of option names
|
170 |
foreach ( $options_matrix as $old_option => $new_option ) {
|
171 |
-
if ( isset($defaults[ $old_option ]) ) {
|
172 |
$defaults[ $new_option ] = $defaults[ $old_option ];
|
173 |
-
unset($defaults[ $old_option ]);
|
174 |
-
} else if ( empty($defaults[ $new_option ]) ) {
|
175 |
$defaults[ $new_option ] = $init[ $new_option ];
|
176 |
}
|
177 |
}
|
178 |
// Free some memory
|
179 |
-
unset
|
180 |
|
181 |
// Write back updated defaults
|
182 |
update_option( 'youtube_channel_defaults', $defaults );
|
183 |
|
184 |
// Add empty option key for dismissed notices
|
185 |
-
add_option('youtube_channel_dismissed_notices', '', '', 'no');
|
186 |
|
187 |
// Delete all YouTube Channel transients
|
188 |
global $_wp_using_ext_object_cache, $wpdb;
|
189 |
if ( ! $_wp_using_ext_object_cache ) {
|
190 |
-
|
191 |
-
$clean = $wpdb
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
|
193 |
// optimize wp_options table
|
194 |
-
$wpdb
|
195 |
}
|
196 |
|
197 |
-
$ytc_widgets = get_option('widget_youtube-channel');
|
198 |
foreach ( $ytc_widgets as $widget_id => $widget_data ) {
|
199 |
// process widget arrays, not _multiwidget bool
|
200 |
-
if (
|
201 |
|
202 |
foreach ( $widget_data as $key => $val ) {
|
203 |
// if old key is in matrix
|
204 |
-
if ( array_key_exists($key, $options_matrix) ) {
|
205 |
// create new option if does not exists
|
206 |
-
if ( ! array_key_exists($options_matrix[ $key ], $widget_data) ) {
|
207 |
// copy old value to new key name
|
208 |
$ytc_widgets[ $widget_id ][ $options_matrix[ $key ] ] = $val;
|
209 |
}
|
210 |
// delete old key
|
211 |
-
unset
|
212 |
}
|
213 |
} // END foreach ( $widget_data as $key => $val )
|
214 |
|
215 |
} // END if ( $widget_id != '_multiwidget' )
|
216 |
|
217 |
}
|
218 |
-
update_option('widget_youtube-channel', $ytc_widgets);
|
219 |
-
unset
|
220 |
|
221 |
} // END function au_youtube_channel_update_routine_3()
|
222 |
|
@@ -226,27 +231,26 @@ function au_youtube_channel_update_routine_3() {
|
|
226 |
function au_youtube_channel_update_routine_5() {
|
227 |
|
228 |
// get options from DB
|
229 |
-
$defaults = get_option('youtube_channel_defaults');
|
230 |
|
231 |
-
if ( isset($defaults['only_pl']) ) {
|
232 |
-
unset($defaults['only_pl']);
|
233 |
}
|
234 |
|
235 |
-
if ( defined('YOUTUBE_DATA_API_KEY') ) {
|
236 |
|
237 |
-
if ( empty($defaults['apikey']) ) {
|
238 |
$defaults['apikey'] = YOUTUBE_DATA_API_KEY;
|
239 |
}
|
240 |
-
|
241 |
}
|
242 |
|
243 |
-
if ( isset($defaults) ) {
|
244 |
-
update_option('youtube_channel_defaults', $defaults);
|
245 |
-
unset($defaults);
|
246 |
}
|
247 |
|
248 |
// remove unused keys from DB
|
249 |
-
delete_option('youtube_channel_ver');
|
250 |
|
251 |
} //END function au_youtube_channel_update_routine_5()
|
252 |
|
@@ -256,13 +260,13 @@ function au_youtube_channel_update_routine_5() {
|
|
256 |
function au_youtube_channel_update_routine_10() {
|
257 |
|
258 |
// get options from DB
|
259 |
-
$defaults = get_option('youtube_channel_defaults');
|
260 |
|
261 |
// Set default `link_to` and migrate
|
262 |
-
if ( ! isset($defaults['link_to']) ) {
|
263 |
$defaults['link_to'] = 'none';
|
264 |
} else {
|
265 |
-
switch ($defaults['link_to']) {
|
266 |
case 2:
|
267 |
case 'vanity':
|
268 |
$defaults['link_to'] = 'vanity';
|
@@ -282,14 +286,14 @@ function au_youtube_channel_update_routine_10() {
|
|
282 |
}
|
283 |
|
284 |
// Migrate showbelow and showtitle in options
|
285 |
-
if ( ! empty($defaults['showtitle']) ) {
|
286 |
-
if ( ! empty($defaults['titlebelow']) ) {
|
287 |
$defaults['showtitle'] = 'below';
|
288 |
} else {
|
289 |
$defaults['showtitle'] = 'above';
|
290 |
}
|
291 |
-
if ( isset($defaults['titlebelow']) ) {
|
292 |
-
unset($defaults['titlebelow']);
|
293 |
}
|
294 |
} else {
|
295 |
$defaults['showtitle'] = 'none';
|
@@ -310,22 +314,21 @@ function au_youtube_channel_update_routine_10() {
|
|
310 |
'showgoto',
|
311 |
'userchan',
|
312 |
'fixnoitem',
|
313 |
-
'use_res'
|
314 |
);
|
315 |
foreach ( $deprecated_options as $deprecated ) {
|
316 |
-
if ( isset($defaults[$deprecated]) ) {
|
317 |
-
unset($defaults[$deprecated]);
|
318 |
}
|
319 |
}
|
320 |
|
321 |
-
if ( isset($defaults) ) {
|
322 |
-
update_option('youtube_channel_defaults', $defaults);
|
323 |
-
unset($defaults);
|
324 |
}
|
325 |
|
326 |
} //END function au_youtube_channel_update_routine_10()
|
327 |
|
328 |
-
|
329 |
/**
|
330 |
* Migrate widget settings to 3.0.8
|
331 |
*/
|
@@ -335,22 +338,22 @@ function au_youtube_channel_update_routine_11() {
|
|
335 |
'only_pl',
|
336 |
'showgoto',
|
337 |
'titlebelow',
|
338 |
-
'descappend'
|
339 |
);
|
340 |
// get YTC widgets
|
341 |
-
$ytc_widgets = get_option('widget_youtube-channel');
|
342 |
foreach ( $ytc_widgets as $widget_id => $widget_data ) {
|
343 |
// Process widget arrays, not _multiwidget bool
|
344 |
-
if (
|
345 |
|
346 |
// migrate only_pl to display
|
347 |
-
if ( isset($widget_data['only_pl']) && ! empty($widget_data['only_pl']) ) {
|
348 |
$ytc_widgets[ $widget_id ]['display'] = 'playlist';
|
349 |
}
|
350 |
|
351 |
// Migrate showbelow and showtitle in widgets
|
352 |
-
if ( ! empty($widget_data['showtitle']) ) {
|
353 |
-
if ( ! empty($widget_data['titlebelow']) ) {
|
354 |
$ytc_widgets[ $widget_id ]['showtitle'] = 'below';
|
355 |
} else {
|
356 |
$ytc_widgets[ $widget_id ]['showtitle'] = 'above';
|
@@ -360,16 +363,14 @@ function au_youtube_channel_update_routine_11() {
|
|
360 |
}
|
361 |
|
362 |
// migrate link_to
|
363 |
-
if ( ! empty($widget_data['showgoto']) ) {
|
364 |
|
365 |
-
if ( isset($widget_data['link_to']) ) {
|
366 |
-
if ( $widget_data['link_to']
|
367 |
$ytc_widgets[ $widget_id ]['link_to'] = 'legacy';
|
368 |
-
}
|
369 |
-
elseif ( $widget_data['link_to'] == 1 || $widget_data['link_to'] == 'channel' ) {
|
370 |
$ytc_widgets[ $widget_id ]['link_to'] = 'channel';
|
371 |
-
}
|
372 |
-
elseif ( $widget_data['link_to'] == 2 || $widget_data['link_to'] == 'vanity' ) {
|
373 |
$ytc_widgets[ $widget_id ]['link_to'] = 'vanity';
|
374 |
}
|
375 |
} else {
|
@@ -381,16 +382,15 @@ function au_youtube_channel_update_routine_11() {
|
|
381 |
|
382 |
// Delete deprecated option
|
383 |
foreach ( $deprecated_widget_options as $deprecated_option_key ) {
|
384 |
-
if ( isset($widget_data[ $deprecated_option_key ]) ) {
|
385 |
-
unset
|
386 |
}
|
387 |
}
|
388 |
-
|
389 |
} // END if ( $widget_id != '_multiwidget' )
|
390 |
|
391 |
} // END foreach ( $ytc_widgets as $widget_id => $widget_data )
|
392 |
|
393 |
-
update_option('widget_youtube-channel', $ytc_widgets);
|
394 |
} // END function au_youtube_channel_update_routine_11()
|
395 |
|
396 |
|
@@ -400,12 +400,12 @@ function au_youtube_channel_update_routine_11() {
|
|
400 |
function au_youtube_channel_update_routine_14() {
|
401 |
|
402 |
// get options from DB
|
403 |
-
$defaults = get_option('youtube_channel_defaults');
|
404 |
|
405 |
-
if ( ! isset($defaults['playsinline']) ) {
|
406 |
$defaults['playsinline'] = 0;
|
407 |
}
|
408 |
-
if ( ! isset($defaults['nolightbox']) ) {
|
409 |
$defaults['nolightbox'] = 0;
|
410 |
}
|
411 |
|
@@ -415,9 +415,9 @@ function au_youtube_channel_update_routine_14() {
|
|
415 |
// add new default option `tinymce`
|
416 |
$defaults['tinymce'] = 1;
|
417 |
|
418 |
-
if ( isset($defaults) ) {
|
419 |
-
update_option('youtube_channel_defaults', $defaults);
|
420 |
-
unset($defaults);
|
421 |
}
|
422 |
|
423 |
} // END function au_youtube_channel_update_routine_14()
|
38 |
}
|
39 |
|
40 |
// Update plugin version number
|
41 |
+
update_option( 'youtube_channel_version', WPAU_YOUTUBE_CHANNEL::VER );
|
42 |
|
43 |
} // END function au_youtube_channel_update()
|
44 |
|
47 |
*/
|
48 |
function au_youtube_channel_update_routine_2() {
|
49 |
|
50 |
+
if ( $old = get_option( 'widget_youtube_channel_widget' ) ) {
|
51 |
|
52 |
+
// get new YTC widgets
|
53 |
+
$new = get_option( 'widget_youtube-channel' );
|
54 |
|
55 |
+
// get all widget areas
|
56 |
+
$widget_areas = get_option( 'sidebars_widgets' );
|
57 |
|
58 |
+
// update options to 2.0.0+ version
|
59 |
+
foreach ( $old as $k => $v ) {
|
60 |
|
61 |
+
if ( '_multiwidget' !== $k ) {
|
62 |
+
// option for resource
|
63 |
+
$v['use_res'] = 0;
|
64 |
+
if ( 'on' == $v['usepl'] ) {
|
65 |
+
$v['use_res'] = 2;
|
66 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
+
$v['popup_goto'] = 0;
|
69 |
+
if ( 'on' == $v['popupgoto'] ) {
|
70 |
+
$v['popup_goto'] = 1;
|
71 |
+
} else if ( 'on' == $v['target'] ) {
|
72 |
+
$v['popup_goto'] = 2;
|
73 |
+
}
|
74 |
+
unset( $v['usepl'], $v['popupgoto'], $v['target'] );
|
75 |
+
|
76 |
+
$v['cache_time'] = 0;
|
77 |
+
$v['userchan'] = 0;
|
78 |
+
$v['enhprivacy'] = 0;
|
79 |
+
$v['autoplay_mute'] = 0;
|
80 |
+
|
81 |
+
// add old YTC widget to new set
|
82 |
+
// but append at the end if YTC widget with same ID already exist
|
83 |
+
// in new set (created in version 2.0.0)
|
84 |
+
if ( is_array( $new[ $k ] ) ) {
|
85 |
+
// populate at the end
|
86 |
+
array_push( $new, $v );
|
87 |
+
$ytc_widget_id = 'youtube-channel-' . end( array_keys( $new ) );
|
88 |
+
} else {
|
89 |
+
// set as current widget ID
|
90 |
+
$new[ $k ] = $v;
|
91 |
+
$ytc_widget_id = "youtube-channel-$k";
|
92 |
+
}
|
93 |
|
94 |
+
$ytc_widget_added = 0;
|
95 |
+
foreach ( $widget_areas as $wak => $wav ) {
|
96 |
+
// check if here we have this widget
|
97 |
+
if ( is_array( $wav ) && in_array( $ytc_widget_id, $wav ) ) {
|
98 |
+
++$ytc_widget_added;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
// free some memory
|
102 |
+
unset( $wak, $wav );
|
103 |
|
104 |
+
// if YTC widget has not present in any widget area, add it to inactive widgets ;)
|
105 |
+
if ( 0 == $ytc_widget_added ) {
|
106 |
+
array_push( $widget_areas['wp_inactive_widgets'], $ytc_widget_id );
|
107 |
+
}
|
108 |
+
} // add to inactive widgets if don't belong to any widget area
|
109 |
|
110 |
+
} // foreach widget option
|
|
|
111 |
|
112 |
+
// update widget areas set
|
113 |
+
update_option( 'sidebars_widgets', $widget_areas );
|
114 |
|
115 |
+
// update new YTC widgets
|
116 |
+
update_option( 'widget_youtube-channel', $new );
|
117 |
|
118 |
+
// remove old YTC widgets entry
|
119 |
+
delete_option( 'widget_youtube_channel_widget' );
|
120 |
|
121 |
+
} // if we have old YTC widgets
|
|
|
122 |
|
123 |
+
// clear temporary vars
|
124 |
+
unset( $old, $new, $k, $v, $widget_areas, $ytc_widget_added, $ytc_widget_id );
|
125 |
|
126 |
} // END function au_youtube_channel_update_routine_2()
|
127 |
|
132 |
function au_youtube_channel_update_routine_3() {
|
133 |
|
134 |
// Remove deprecated option keys
|
135 |
+
delete_option( 'ytc_no_redux_notice' );
|
136 |
+
delete_option( 'ytc_old_php_notice' );
|
137 |
+
delete_option( 'ytc_version' );
|
138 |
|
139 |
// get options from DB
|
140 |
+
$defaults = get_option( 'youtube_channel_defaults' );
|
141 |
|
142 |
// prepare migration matrix
|
143 |
$options_matrix = array(
|
149 |
'to_show' => 'display',
|
150 |
'showvidesc' => 'showdesc',
|
151 |
'videsclen' => 'desclen',
|
152 |
+
'enhprivacy' => 'privacy',
|
153 |
);
|
154 |
// set defaults
|
155 |
$init = array(
|
161 |
'display' => 'thumbnail', // ex to_show
|
162 |
'showdesc' => 0, // ex showvidesc
|
163 |
'desclen' => 0, // ex videsclen
|
164 |
+
'privacy' => 0, // ex enhprivacy
|
165 |
);
|
166 |
|
167 |
// Do migration of option names
|
168 |
foreach ( $options_matrix as $old_option => $new_option ) {
|
169 |
+
if ( isset( $defaults[ $old_option ] ) ) {
|
170 |
$defaults[ $new_option ] = $defaults[ $old_option ];
|
171 |
+
unset( $defaults[ $old_option ] );
|
172 |
+
} else if ( empty( $defaults[ $new_option ] ) ) {
|
173 |
$defaults[ $new_option ] = $init[ $new_option ];
|
174 |
}
|
175 |
}
|
176 |
// Free some memory
|
177 |
+
unset( $old_option, $new_option );
|
178 |
|
179 |
// Write back updated defaults
|
180 |
update_option( 'youtube_channel_defaults', $defaults );
|
181 |
|
182 |
// Add empty option key for dismissed notices
|
183 |
+
add_option( 'youtube_channel_dismissed_notices', '', '', 'no' );
|
184 |
|
185 |
// Delete all YouTube Channel transients
|
186 |
global $_wp_using_ext_object_cache, $wpdb;
|
187 |
if ( ! $_wp_using_ext_object_cache ) {
|
188 |
+
|
189 |
+
$clean = $wpdb->query( $wpdb->prepare("
|
190 |
+
DELETE FROM `$wpdb->options`
|
191 |
+
WHERE option_name LIKE %s
|
192 |
+
OR option_name LIKE %s
|
193 |
+
",
|
194 |
+
'_transient_ytc_%',
|
195 |
+
'_transient_timeout_ytc_%'
|
196 |
+
) );
|
197 |
|
198 |
// optimize wp_options table
|
199 |
+
$wpdb->query( "OPTIMIZE TABLE $wpdb->options" );
|
200 |
}
|
201 |
|
202 |
+
$ytc_widgets = get_option( 'widget_youtube-channel' );
|
203 |
foreach ( $ytc_widgets as $widget_id => $widget_data ) {
|
204 |
// process widget arrays, not _multiwidget bool
|
205 |
+
if ( '_multiwidget' != $widget_id ) {
|
206 |
|
207 |
foreach ( $widget_data as $key => $val ) {
|
208 |
// if old key is in matrix
|
209 |
+
if ( array_key_exists( $key, $options_matrix ) ) {
|
210 |
// create new option if does not exists
|
211 |
+
if ( ! array_key_exists( $options_matrix[ $key ], $widget_data ) ) {
|
212 |
// copy old value to new key name
|
213 |
$ytc_widgets[ $widget_id ][ $options_matrix[ $key ] ] = $val;
|
214 |
}
|
215 |
// delete old key
|
216 |
+
unset( $ytc_widgets[ $widget_id ][ $key ] );
|
217 |
}
|
218 |
} // END foreach ( $widget_data as $key => $val )
|
219 |
|
220 |
} // END if ( $widget_id != '_multiwidget' )
|
221 |
|
222 |
}
|
223 |
+
update_option( 'widget_youtube-channel', $ytc_widgets );
|
224 |
+
unset( $options_matrix, $init, $ytc_widgets, $widget_id, $widget_data );
|
225 |
|
226 |
} // END function au_youtube_channel_update_routine_3()
|
227 |
|
231 |
function au_youtube_channel_update_routine_5() {
|
232 |
|
233 |
// get options from DB
|
234 |
+
$defaults = get_option( 'youtube_channel_defaults' );
|
235 |
|
236 |
+
if ( isset( $defaults['only_pl'] ) ) {
|
237 |
+
unset( $defaults['only_pl'] );
|
238 |
}
|
239 |
|
240 |
+
if ( defined( 'YOUTUBE_DATA_API_KEY' ) ) {
|
241 |
|
242 |
+
if ( empty( $defaults['apikey'] ) ) {
|
243 |
$defaults['apikey'] = YOUTUBE_DATA_API_KEY;
|
244 |
}
|
|
|
245 |
}
|
246 |
|
247 |
+
if ( isset( $defaults ) ) {
|
248 |
+
update_option( 'youtube_channel_defaults', $defaults );
|
249 |
+
unset( $defaults );
|
250 |
}
|
251 |
|
252 |
// remove unused keys from DB
|
253 |
+
delete_option( 'youtube_channel_ver' );
|
254 |
|
255 |
} //END function au_youtube_channel_update_routine_5()
|
256 |
|
260 |
function au_youtube_channel_update_routine_10() {
|
261 |
|
262 |
// get options from DB
|
263 |
+
$defaults = get_option( 'youtube_channel_defaults' );
|
264 |
|
265 |
// Set default `link_to` and migrate
|
266 |
+
if ( ! isset( $defaults['link_to'] ) ) {
|
267 |
$defaults['link_to'] = 'none';
|
268 |
} else {
|
269 |
+
switch ( $defaults['link_to'] ) {
|
270 |
case 2:
|
271 |
case 'vanity':
|
272 |
$defaults['link_to'] = 'vanity';
|
286 |
}
|
287 |
|
288 |
// Migrate showbelow and showtitle in options
|
289 |
+
if ( ! empty( $defaults['showtitle'] ) ) {
|
290 |
+
if ( ! empty( $defaults['titlebelow'] ) ) {
|
291 |
$defaults['showtitle'] = 'below';
|
292 |
} else {
|
293 |
$defaults['showtitle'] = 'above';
|
294 |
}
|
295 |
+
if ( isset( $defaults['titlebelow'] ) ) {
|
296 |
+
unset( $defaults['titlebelow'] );
|
297 |
}
|
298 |
} else {
|
299 |
$defaults['showtitle'] = 'none';
|
314 |
'showgoto',
|
315 |
'userchan',
|
316 |
'fixnoitem',
|
317 |
+
'use_res',
|
318 |
);
|
319 |
foreach ( $deprecated_options as $deprecated ) {
|
320 |
+
if ( isset( $defaults[ $deprecated ] ) ) {
|
321 |
+
unset( $defaults[ $deprecated ] );
|
322 |
}
|
323 |
}
|
324 |
|
325 |
+
if ( isset( $defaults ) ) {
|
326 |
+
update_option( 'youtube_channel_defaults', $defaults );
|
327 |
+
unset( $defaults );
|
328 |
}
|
329 |
|
330 |
} //END function au_youtube_channel_update_routine_10()
|
331 |
|
|
|
332 |
/**
|
333 |
* Migrate widget settings to 3.0.8
|
334 |
*/
|
338 |
'only_pl',
|
339 |
'showgoto',
|
340 |
'titlebelow',
|
341 |
+
'descappend',
|
342 |
);
|
343 |
// get YTC widgets
|
344 |
+
$ytc_widgets = get_option( 'widget_youtube-channel' );
|
345 |
foreach ( $ytc_widgets as $widget_id => $widget_data ) {
|
346 |
// Process widget arrays, not _multiwidget bool
|
347 |
+
if ( '_multiwidget' != $widget_id ) {
|
348 |
|
349 |
// migrate only_pl to display
|
350 |
+
if ( isset( $widget_data['only_pl'] ) && ! empty( $widget_data['only_pl'] ) ) {
|
351 |
$ytc_widgets[ $widget_id ]['display'] = 'playlist';
|
352 |
}
|
353 |
|
354 |
// Migrate showbelow and showtitle in widgets
|
355 |
+
if ( ! empty( $widget_data['showtitle'] ) ) {
|
356 |
+
if ( ! empty( $widget_data['titlebelow'] ) ) {
|
357 |
$ytc_widgets[ $widget_id ]['showtitle'] = 'below';
|
358 |
} else {
|
359 |
$ytc_widgets[ $widget_id ]['showtitle'] = 'above';
|
363 |
}
|
364 |
|
365 |
// migrate link_to
|
366 |
+
if ( ! empty( $widget_data['showgoto'] ) ) {
|
367 |
|
368 |
+
if ( isset( $widget_data['link_to'] ) ) {
|
369 |
+
if ( 0 == $widget_data['link_to'] || 'legacy' == $widget_data['link_to'] ) {
|
370 |
$ytc_widgets[ $widget_id ]['link_to'] = 'legacy';
|
371 |
+
} elseif ( 1 == $widget_data['link_to'] || 'channel' == $widget_data['link_to'] ) {
|
|
|
372 |
$ytc_widgets[ $widget_id ]['link_to'] = 'channel';
|
373 |
+
} elseif ( 2 == $widget_data['link_to'] || 'vanity' == $widget_data['link_to'] ) {
|
|
|
374 |
$ytc_widgets[ $widget_id ]['link_to'] = 'vanity';
|
375 |
}
|
376 |
} else {
|
382 |
|
383 |
// Delete deprecated option
|
384 |
foreach ( $deprecated_widget_options as $deprecated_option_key ) {
|
385 |
+
if ( isset( $widget_data[ $deprecated_option_key ] ) ) {
|
386 |
+
unset( $ytc_widgets[ $widget_id ][ $deprecated_option_key ] );
|
387 |
}
|
388 |
}
|
|
|
389 |
} // END if ( $widget_id != '_multiwidget' )
|
390 |
|
391 |
} // END foreach ( $ytc_widgets as $widget_id => $widget_data )
|
392 |
|
393 |
+
update_option( 'widget_youtube-channel', $ytc_widgets );
|
394 |
} // END function au_youtube_channel_update_routine_11()
|
395 |
|
396 |
|
400 |
function au_youtube_channel_update_routine_14() {
|
401 |
|
402 |
// get options from DB
|
403 |
+
$defaults = get_option( 'youtube_channel_defaults' );
|
404 |
|
405 |
+
if ( ! isset( $defaults['playsinline'] ) ) {
|
406 |
$defaults['playsinline'] = 0;
|
407 |
}
|
408 |
+
if ( ! isset( $defaults['nolightbox'] ) ) {
|
409 |
$defaults['nolightbox'] = 0;
|
410 |
}
|
411 |
|
415 |
// add new default option `tinymce`
|
416 |
$defaults['tinymce'] = 1;
|
417 |
|
418 |
+
if ( isset( $defaults ) ) {
|
419 |
+
update_option( 'youtube_channel_defaults', $defaults );
|
420 |
+
unset( $defaults );
|
421 |
}
|
422 |
|
423 |
} // END function au_youtube_channel_update_routine_14()
|
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: YouTube Channel
|
4 |
-
Plugin URI:
|
5 |
Description: Quick and easy embed latest or random videos from YouTube channel (user uploads, liked or favourited videos) or playlist. Use <a href="widgets.php">widget</a> for sidebar or shortcode for content. Works with <em>YouTube Data API v3</em>.
|
6 |
-
Version: 3.0.
|
7 |
Author: Aleksandar Urošević
|
8 |
-
Author URI:
|
9 |
Text Domain: youtube-channel
|
10 |
*/
|
11 |
|
@@ -15,11 +15,10 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
18 |
-
class WPAU_YOUTUBE_CHANNEL
|
19 |
-
{
|
20 |
|
21 |
-
const DB_VER =
|
22 |
-
const VER = '3.0.
|
23 |
|
24 |
public $plugin_name = 'YouTube Channel';
|
25 |
public $plugin_slug = 'youtube-channel';
|
@@ -90,11 +89,11 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
90 |
*/
|
91 |
public static function activate() {
|
92 |
|
93 |
-
global $
|
94 |
-
$
|
95 |
-
$
|
96 |
|
97 |
-
} //
|
98 |
|
99 |
/**
|
100 |
* Return initial options
|
@@ -134,7 +133,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
134 |
'goto_txt' => 'Visit our channel',
|
135 |
'popup_goto' => 0, // 0 same window, 1 new window JS, 2 new window target
|
136 |
'link_to' => 'none', // 0 legacy username, 1 channel, 2 vanity
|
137 |
-
'tinymce' => 1, // show
|
138 |
);
|
139 |
|
140 |
add_option( 'youtube_channel_version', self::VER, '', 'no' );
|
@@ -166,14 +165,14 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
166 |
function admin_init() {
|
167 |
|
168 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_settings_link' ) );
|
169 |
-
//
|
170 |
add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 );
|
171 |
|
172 |
require_once( 'inc/settings.php' );
|
173 |
|
174 |
-
global $
|
175 |
-
if ( empty( $
|
176 |
-
$
|
177 |
}
|
178 |
|
179 |
} // END function admin_init_settings()
|
@@ -182,7 +181,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
182 |
* Append Settings link for Plugins page
|
183 |
* @param array $links array of links on plugins page
|
184 |
*/
|
185 |
-
function add_settings_link($links) {
|
186 |
|
187 |
$settings_title = __( 'Settings' );
|
188 |
$settings_link = "<a href=\"options-general.php?page={$this->plugin_slug}\">{$settings_title}</a>";
|
@@ -199,7 +198,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
199 |
/**
|
200 |
* Add link to official plugin page
|
201 |
*/
|
202 |
-
function add_plugin_meta_links($links, $file) {
|
203 |
|
204 |
if ( 'youtube-channel/youtube-channel.php' === $file ) {
|
205 |
return array_merge(
|
@@ -214,7 +213,8 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
214 |
}
|
215 |
return $links;
|
216 |
|
217 |
-
}
|
|
|
218 |
/**
|
219 |
* Enqueue admin scripts and styles for widget customization
|
220 |
*/
|
@@ -285,7 +285,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
285 |
)
|
286 |
) {
|
287 |
$notice['info'] .= sprintf(
|
288 |
-
__( '<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' ),
|
289 |
PHP_VERSION,
|
290 |
$this->plugin_name,
|
291 |
'?ytc_dismiss_notice_old_php=1'
|
@@ -298,7 +298,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
298 |
empty( $dismissed_notices['apikey_wpconfig'] )
|
299 |
) {
|
300 |
$notice['info'] .= sprintf(
|
301 |
-
__( '<p>Since <strong>%s</strong> v3.0.6 we store <strong>YouTube Data API Key</strong> in plugin settings. So, you can safely remove %s define line from your <strong>wp-config.php</strong> file. <a href="%s" class="dismiss">Dismiss</a></p>', 'youtube-channel' ),
|
302 |
$this->plugin_name,
|
303 |
'YOUTUBE_DATA_API_KEY',
|
304 |
'?ytc_dismiss_notice_apikey_wpconfig=1'
|
@@ -310,7 +310,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
310 |
$notice['error'] .= sprintf(
|
311 |
wp_kses(
|
312 |
__(
|
313 |
-
'<p
|
314 |
'youtube-channel'
|
315 |
),
|
316 |
array(
|
@@ -324,40 +324,27 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
324 |
__( 'YouTube Data API Key', 'youtube-channel' ),
|
325 |
esc_url( 'https://console.developers.google.com/project' ),
|
326 |
__( 'Google Developers Console', 'youtube-channel' ),
|
327 |
-
esc_url( '
|
328 |
esc_url( 'options-general.php?page=youtube-channel&tab=general' ),
|
329 |
-
__( 'General Settings', 'youtube-channel' )
|
330 |
-
esc_url( 'https://wordpress.org/support/plugin/youtube-channel' ),
|
331 |
-
__( 'support forum', 'youtube-channel' )
|
332 |
-
);
|
333 |
-
}
|
334 |
-
|
335 |
-
if (
|
336 |
-
empty( $dismissed_notices ) ||
|
337 |
-
( ! empty( $dismissed_notices ) && empty( $dismissed_notices['vanity_option'] ) )
|
338 |
-
) {
|
339 |
-
$notice['warning'] .= sprintf(
|
340 |
-
__( '<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' ),
|
341 |
-
$this->plugin_name,
|
342 |
-
$settings_page,
|
343 |
-
'widgets.php',
|
344 |
-
'?ytc_dismiss_notice_vanity_option=1'
|
345 |
);
|
346 |
}
|
347 |
|
348 |
-
// v3.0.8.1 shortcode changes
|
349 |
-
if (
|
350 |
-
empty( $dismissed_notices ) ||
|
351 |
-
( ! empty( $dismissed_notices ) && empty( $dismissed_notices['changed_shortcode_308'] ) )
|
352 |
-
) {
|
353 |
$notice['warning'] .= sprintf(
|
354 |
-
__( '<p><strong>%s</strong> changed shortcode parameters by removing <code>only_pl</code> and <code>showgoto</code>, and combining with parameters <code>display</code> and <code>link_to</code> respectively. Please check out <a href="%s&tab=help">%s</a> and update your shortcodes. <a href="%s" class="dismiss">Dismiss</a>', 'youtube-channel' ),
|
355 |
$this->plugin_name,
|
356 |
$settings_page,
|
357 |
'Help: How to use shortcode',
|
358 |
'?ytc_dismiss_notice_changed_shortcode_308=1'
|
359 |
);
|
|
|
|
|
|
|
|
|
360 |
}
|
|
|
361 |
foreach ( $notice as $type => $message ) {
|
362 |
if ( ! empty( $message ) ) {
|
363 |
echo "<div class=\"notice notice-{$type}\">{$message}</div>";
|
@@ -374,19 +361,19 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
374 |
|
375 |
$defaults = get_option( $this->plugin_option );
|
376 |
if ( empty( $defaults ) ) {
|
377 |
-
$this->init_options();
|
378 |
}
|
379 |
|
380 |
return $defaults;
|
381 |
|
382 |
-
}
|
383 |
|
384 |
/**
|
385 |
* Enqueue frontend scripts and styles
|
386 |
*/
|
387 |
function enqueue_scripts() {
|
388 |
|
389 |
-
//
|
390 |
if ( empty( $this->defaults['nolightbox'] ) ) {
|
391 |
wp_enqueue_style(
|
392 |
'magnific-popup-au',
|
@@ -409,16 +396,8 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
409 |
array(),
|
410 |
self::VER
|
411 |
);
|
412 |
-
|
413 |
-
|
414 |
-
'youtube-channel',
|
415 |
-
plugins_url('assets/js/youtube-channel.min.js', __FILE__),
|
416 |
-
array('jquery'),
|
417 |
-
self::VER,
|
418 |
-
true
|
419 |
-
);
|
420 |
-
*/
|
421 |
-
} // end function enqueue_scripts
|
422 |
|
423 |
/**
|
424 |
* Generate comlete inline JavaScript code that conains
|
@@ -495,140 +474,138 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
495 |
|
496 |
} // END function footer_scripts()
|
497 |
|
498 |
-
public function shortcode($atts) {
|
499 |
|
500 |
-
//
|
501 |
$instance = $this->defaults();
|
502 |
|
503 |
-
//
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
$atts
|
550 |
-
)
|
551 |
);
|
552 |
|
553 |
// backward compatibility for show -> display shortcode parameter
|
554 |
-
if ( ! empty( $show ) && $show !== $display && $show !== $instance['display'] ) {
|
555 |
-
$display = $show;
|
556 |
}
|
557 |
// backward compatibility for use_res -> resource shortcode parameter
|
558 |
-
if ( ! empty( $use_res ) ) {
|
559 |
-
$resource = $use_res;
|
560 |
-
} else if ( ! empty( $res ) ) {
|
561 |
-
$resource = $res;
|
562 |
}
|
563 |
|
564 |
// prepare instance for output
|
565 |
-
$instance['vanity'] = $vanity;
|
566 |
-
$instance['channel'] = $channel;
|
567 |
-
$instance['username'] = $username;
|
568 |
-
$instance['playlist'] = $playlist;
|
569 |
-
$instance['resource'] = $resource; // resource: 0 channel, 1 favorites, 2 playlist, 3 liked
|
570 |
-
$instance['cache'] = $cache; // in seconds, def 5min - settings?
|
571 |
-
$instance['privacy'] = $privacy; // enhanced privacy
|
572 |
|
573 |
-
$instance['fetch'] = (int) $fetch;
|
574 |
-
$instance['num'] = (int) $num; // num: 1
|
575 |
|
576 |
-
$instance['random'] = $random; // use embedded playlist - false by default
|
577 |
|
578 |
// Video Settings
|
579 |
-
$instance['ratio'] = $ratio; // aspect ratio: 3 - 16:9, 2 - 16:10, 1 - 4:3
|
580 |
-
$instance['width'] = (int) $width; // 306
|
581 |
-
$instance['responsive'] = $responsive; // enable responsivenes?
|
582 |
-
$instance['display'] = $display; // thumbnail, iframe, iframe2, playlist
|
583 |
-
$instance['no_thumb_title'] = $no_thumb_title; // hide tooltip for thumbnails
|
584 |
-
|
585 |
-
$instance['themelight'] = $themelight; // use light theme, dark by default
|
586 |
-
$instance['controls'] = $controls; // hide controls, false by default
|
587 |
-
$instance['autoplay'] = $autoplay; // autoplay disabled by default
|
588 |
-
$instance['autoplay_mute'] = $mute; // mute sound on autoplay - disabled by default
|
589 |
-
$instance['norel'] = $norel; // hide related videos
|
590 |
-
$instance['playsinline'] = $playsinline; // inline plaer for iOS
|
591 |
|
592 |
// Content Layout
|
593 |
-
$instance['showtitle'] = $showtitle; // show video title, disabled by default
|
594 |
-
$instance['showdesc'] = $showdesc; // show video description, disabled by default
|
595 |
-
$instance['modestbranding'] = $nobrand; // hide YT logo
|
596 |
-
$instance['desclen'] = (int) $desclen; // cut video description, number of characters
|
597 |
-
$instance['hideinfo'] = $noinfo; // hide info by default
|
598 |
-
$instance['hideanno'] = $noanno; // hide annotations, false by default
|
599 |
|
600 |
// Link to Channel
|
601 |
-
$instance['goto_txt'] = $goto_txt; // text for goto link - use settings
|
602 |
-
$instance['popup_goto'] = $popup; // open channel in: 0 same window, 1 javascript new, 2 target new
|
603 |
-
$instance['link_to'] = $link_to; // link to: none, vanity, legacy, channel
|
604 |
|
605 |
// Customization
|
606 |
-
$instance['class'] = $class; // custom additional class for container
|
607 |
|
608 |
-
return implode( array_values( $this->output( $instance ) ) );
|
|
|
609 |
} // END public function shortcode()
|
610 |
|
611 |
// Print out YTC block
|
612 |
-
public function output($instance) {
|
613 |
|
614 |
// Error message if no YouTube Data API Key
|
615 |
if ( empty( $this->defaults['apikey'] ) ) {
|
616 |
|
617 |
$error_msg = sprintf(
|
618 |
-
__( '<strong>%s</strong>
|
619 |
$this->plugin_name,
|
620 |
-
'
|
621 |
);
|
622 |
|
623 |
-
|
624 |
-
return $output;
|
625 |
|
626 |
}
|
627 |
|
628 |
// 1) Get resource from widget/shortcode
|
629 |
// 2) If not set, get global default
|
630 |
// 3) if no global, get plugin's default
|
631 |
-
if (
|
632 |
$instance['resource'] = $this->defaults['resource'];
|
633 |
}
|
634 |
$resource = intval( $instance['resource'] );
|
@@ -654,8 +631,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
654 |
}
|
655 |
// Now check has Playlist ID set or throw error
|
656 |
if ( '' == $playlist ) {
|
657 |
-
|
658 |
-
return $output;
|
659 |
}
|
660 |
break;
|
661 |
|
@@ -680,8 +656,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
680 |
$resource_name = 'Channel (User uploads)';
|
681 |
}
|
682 |
$error_msg = sprintf( '%s selected as resource but no Channel ID provided!', $resource_name );
|
683 |
-
|
684 |
-
return $output;
|
685 |
}
|
686 |
} // END switch ($resource)
|
687 |
|
@@ -714,17 +689,17 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
714 |
$resource_id = preg_replace( '/^UC/', 'UU', $channel );
|
715 |
}
|
716 |
|
717 |
-
// Start output
|
718 |
-
$output =
|
719 |
|
720 |
-
$output
|
721 |
|
722 |
if ( empty( $instance['display'] ) ) {
|
723 |
$instance['display'] = $this->defaults['display'];
|
724 |
}
|
725 |
if ( 'playlist' == $instance['display'] ) { // Insert as Embedded playlist
|
726 |
|
727 |
-
$output
|
728 |
|
729 |
} else { // Individual videos from channel, favourites, liked or playlist
|
730 |
|
@@ -792,13 +767,13 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
792 |
|
793 |
// Prevent further checks if we have WP Error or empty record even after fallback
|
794 |
if ( is_wp_error( $json_output ) ) {
|
795 |
-
$output
|
796 |
return $output;
|
797 |
} elseif ( isset( $json_output->items ) && 0 == sizeof( $json_output->items ) ) {
|
798 |
-
$output
|
799 |
return $output;
|
800 |
} elseif ( empty( $json_output ) ) {
|
801 |
-
$output
|
802 |
return $output;
|
803 |
}
|
804 |
|
@@ -857,7 +832,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
857 |
|
858 |
} // END ! empty($json_output->error->errors)
|
859 |
|
860 |
-
$output
|
861 |
|
862 |
} else { // ELSE if ($max_items == 0)
|
863 |
|
@@ -891,7 +866,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
891 |
}
|
892 |
|
893 |
// Generate single video block
|
894 |
-
$output
|
895 |
}
|
896 |
// Free some memory
|
897 |
unset( $random_used, $random_item, $json );
|
@@ -902,13 +877,13 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
902 |
|
903 |
// Append link to channel on bootom of the widget
|
904 |
if ( ! empty( $instance['link_to'] ) && 'none' != $instance['link_to'] ) {
|
905 |
-
$output
|
906 |
}
|
907 |
|
908 |
-
$output
|
909 |
|
910 |
// fix overflow on crappy themes
|
911 |
-
$output
|
912 |
|
913 |
return $output;
|
914 |
|
@@ -922,7 +897,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
922 |
* @param integer $items Number of items to fetch (min 2, max 50)
|
923 |
* @return array JSON with videos
|
924 |
*/
|
925 |
-
function fetch_youtube_feed($resource_id, $items) {
|
926 |
|
927 |
$feed_url = 'https://www.googleapis.com/youtube/v3/playlistItems?';
|
928 |
$feed_url .= 'part=snippet';
|
@@ -961,7 +936,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
961 |
* @param string $message Error message
|
962 |
* @return string FOrmatted message for error
|
963 |
*/
|
964 |
-
function front_debug($message) {
|
965 |
|
966 |
// Show visible error to admin, Oops message to visitors and lower members
|
967 |
if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) {
|
@@ -979,7 +954,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
979 |
|
980 |
return $output;
|
981 |
|
982 |
-
} // END function debug($message)
|
983 |
|
984 |
/**
|
985 |
* Calculate height by provided width and aspect ratio
|
@@ -1006,10 +981,12 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1006 |
* @param array $instance widget or shortcode settings
|
1007 |
* @return array components prepared for output
|
1008 |
*/
|
1009 |
-
function ytc_channel_link($instance) {
|
1010 |
|
1011 |
// initialize array
|
1012 |
-
$output = array();
|
|
|
|
|
1013 |
|
1014 |
// do we need to show goto link?
|
1015 |
if ( 'none' != $instance['link_to'] ) {
|
@@ -1021,7 +998,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1021 |
$vanity = trim( $instance['vanity'] );
|
1022 |
if ( empty( $vanity ) ) {
|
1023 |
if ( empty( $this->defaults['vanity'] ) ) {
|
1024 |
-
return
|
1025 |
}
|
1026 |
// Get vanity from defaults if not set in instance
|
1027 |
$vanity = $this->defaults['vanity'];
|
@@ -1037,7 +1014,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1037 |
$username = trim( $instance['username'] );
|
1038 |
if ( empty( $username ) ) {
|
1039 |
if ( empty( $this->defaults['username'] ) ) {
|
1040 |
-
return
|
1041 |
}
|
1042 |
$username = $this->defaults['username'];
|
1043 |
}
|
@@ -1048,7 +1025,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1048 |
$channel = trim( $instance['channel'] );
|
1049 |
if ( empty( $channel ) ) {
|
1050 |
if ( empty( $this->defaults['channel'] ) ) {
|
1051 |
-
return
|
1052 |
}
|
1053 |
$channel = $this->defaults['channel'];
|
1054 |
}
|
@@ -1063,21 +1040,21 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1063 |
|
1064 |
$newtab = __( 'in new window/tab', 'youtube-channel' );
|
1065 |
|
1066 |
-
$output
|
1067 |
-
$output
|
1068 |
-
$output
|
1069 |
switch ( $instance['popup_goto'] ) {
|
1070 |
case 1:
|
1071 |
-
$output
|
1072 |
break;
|
1073 |
case 2:
|
1074 |
-
$output
|
1075 |
break;
|
1076 |
default:
|
1077 |
-
$output
|
1078 |
} // switch popup_goto
|
1079 |
-
$output
|
1080 |
-
$output
|
1081 |
|
1082 |
} // showgoto
|
1083 |
|
@@ -1092,7 +1069,10 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1092 |
* @param int $y Order number of video
|
1093 |
* @return array Prepared single video block as array to concatenate
|
1094 |
*/
|
1095 |
-
function ytc_print_video($item, $instance, $y) {
|
|
|
|
|
|
|
1096 |
|
1097 |
// Calculate width and height
|
1098 |
if ( empty( $instance['width'] ) ) {
|
@@ -1134,11 +1114,11 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1134 |
// Set proper class for responsive thumbs per selected aspect ratio
|
1135 |
$arclass = $this->arclass( $instance );
|
1136 |
|
1137 |
-
$output
|
1138 |
|
1139 |
// Show video title above video?
|
1140 |
if ( ! empty( $instance['showtitle'] ) && 'above' == $instance['showtitle'] ) {
|
1141 |
-
$output
|
1142 |
}
|
1143 |
|
1144 |
// Print out video
|
@@ -1146,25 +1126,25 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1146 |
|
1147 |
// Start wrapper for responsive item
|
1148 |
if ( $instance['responsive'] ) {
|
1149 |
-
$output
|
1150 |
}
|
1151 |
|
1152 |
-
$output
|
1153 |
|
1154 |
-
if ( ! empty( $instance['norel'] ) ) { $output
|
1155 |
-
if ( ! empty( $instance['controls'] ) ) { $output
|
1156 |
-
if ( ! empty( $instance['hideinfo'] ) ) { $output
|
1157 |
-
if ( ! empty( $instance['autoplay'] ) && 1 == $y ) { $output
|
1158 |
-
if ( ! empty( $instance['hideanno'] ) ) { $output
|
1159 |
-
if ( ! empty( $instance['themelight'] ) ) { $output
|
1160 |
-
if ( ! empty( $instance['modestbranding'] ) ) { $output
|
1161 |
-
if ( ! empty( $instance['playsinline'] ) ) { $output
|
1162 |
|
1163 |
-
$output
|
1164 |
|
1165 |
// Close wrapper for responsive item
|
1166 |
if ( $instance['responsive'] ) {
|
1167 |
-
$output
|
1168 |
}
|
1169 |
} else if ( 'iframe2' == $instance['display'] ) {
|
1170 |
|
@@ -1189,14 +1169,14 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1189 |
|
1190 |
// Start wrapper for responsive item
|
1191 |
if ( $instance['responsive'] ) {
|
1192 |
-
$output
|
1193 |
}
|
1194 |
|
1195 |
-
$output
|
1196 |
|
1197 |
// Close wrapper for responsive item
|
1198 |
if ( $instance['responsive'] ) {
|
1199 |
-
$output
|
1200 |
}
|
1201 |
|
1202 |
$site_domain = $_SERVER['HTTP_HOST'];
|
@@ -1228,13 +1208,13 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1228 |
|
1229 |
// Do we need thumbnail w/ or w/o tooltip
|
1230 |
$tag_title = ( empty( $instance['no_thumb_title'] ) ) ? $tag_title = "title=\"{$yt_title}\"" : '';
|
1231 |
-
$output
|
1232 |
|
1233 |
} // what to show conditions
|
1234 |
|
1235 |
// show video title below video?
|
1236 |
if ( ! empty( $instance['showtitle'] ) && 'below' == $instance['showtitle'] ) {
|
1237 |
-
$output
|
1238 |
}
|
1239 |
|
1240 |
// do we need to show video description?
|
@@ -1251,100 +1231,89 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1251 |
}
|
1252 |
|
1253 |
if ( ! empty( $video_description ) ) {
|
1254 |
-
$output
|
1255 |
}
|
1256 |
}
|
1257 |
|
1258 |
-
$output
|
1259 |
|
1260 |
return $output;
|
1261 |
} // end function ytc_print_video
|
1262 |
|
1263 |
/* function to print standard playlist embed code */
|
1264 |
-
function embed_playlist($resource_id, $instance) {
|
1265 |
|
1266 |
-
$width =
|
1267 |
$height = self::height_ratio( $width, $instance['ratio'] );
|
1268 |
-
$autoplay =
|
1269 |
-
$theme =
|
1270 |
-
$modestbranding =
|
1271 |
-
$rel =
|
1272 |
-
$playsinline =
|
1273 |
|
1274 |
// enhanced privacy
|
1275 |
$youtube_domain = $this->youtube_domain( $instance );
|
1276 |
$arclass = $this->arclass( $instance );
|
1277 |
-
|
1278 |
-
|
1279 |
-
$output
|
1280 |
-
|
1281 |
-
$output
|
1282 |
-
$output
|
1283 |
-
$output
|
|
|
|
|
|
|
|
|
1284 |
|
1285 |
return $output;
|
1286 |
|
1287 |
} // END function embed_playlist($resource_id, $instance)
|
1288 |
|
1289 |
// Helper function cache_time()
|
1290 |
-
function cache_time($cache_time) {
|
1291 |
-
$times = array(
|
1292 |
-
'minute' => array(
|
1293 |
-
1 => __( '1 minute', 'youtube-channel' ),
|
1294 |
-
5 => __( '5 minutes', 'youtube-channel' ),
|
1295 |
-
15 => __( '15 minutes', 'youtube-channel' ),
|
1296 |
-
30 => __( '30 minutes', 'youtube-channel' ),
|
1297 |
-
),
|
1298 |
-
'hour' => array(
|
1299 |
-
1 => __( '1 hour', 'youtube-channel' ),
|
1300 |
-
2 => __( '2 hours', 'youtube-channel' ),
|
1301 |
-
5 => __( '5 hours', 'youtube-channel' ),
|
1302 |
-
10 => __( '10 hours', 'youtube-channel' ),
|
1303 |
-
12 => __( '12 hours', 'youtube-channel' ),
|
1304 |
-
18 => __( '18 hours', 'youtube-channel' ),
|
1305 |
-
),
|
1306 |
-
'day' => array(
|
1307 |
-
1 => __( '1 day', 'youtube-channel' ),
|
1308 |
-
2 => __( '2 days', 'youtube-channel' ),
|
1309 |
-
3 => __( '3 days', 'youtube-channel' ),
|
1310 |
-
4 => __( '4 days', 'youtube-channel' ),
|
1311 |
-
5 => __( '5 days', 'youtube-channel' ),
|
1312 |
-
6 => __( '6 days', 'youtube-channel' ),
|
1313 |
-
),
|
1314 |
-
'week' => array(
|
1315 |
-
1 => __( '1 week', 'youtube-channel' ),
|
1316 |
-
2 => __( '2 weeks', 'youtube-channel' ),
|
1317 |
-
3 => __( '3 weeks', 'youtube-channel' ),
|
1318 |
-
4 => __( '1 month', 'youtube-channel' ),
|
1319 |
-
),
|
1320 |
-
);
|
1321 |
|
1322 |
$out = '';
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
break;
|
1328 |
-
case 'hour':
|
1329 |
-
$sc = HOUR_IN_SECONDS;
|
1330 |
-
break;
|
1331 |
-
case 'day':
|
1332 |
-
$sc = DAY_IN_SECONDS;
|
1333 |
-
break;
|
1334 |
-
case 'week':
|
1335 |
-
$sc = WEEK_IN_SECONDS;
|
1336 |
-
break;
|
1337 |
-
}
|
1338 |
-
|
1339 |
-
foreach ( $timeset as $n => $s ) {
|
1340 |
-
$sec = $sc * $n;
|
1341 |
-
$out .= '<option value="' . $sec . '" ' . selected( $cache_time, $sec, 0 ).'>' . __( $s, 'youtube-channel' ) . '</option>';
|
1342 |
-
unset( $sec );
|
1343 |
-
}
|
1344 |
}
|
|
|
1345 |
return $out;
|
1346 |
-
} // end function cache_time
|
1347 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1348 |
|
1349 |
/**
|
1350 |
* Method to delete all YTC transient caches
|
@@ -1383,7 +1352,7 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1383 |
* @param integer $resource_id Resource ID
|
1384 |
* @return string Resource nice name
|
1385 |
*/
|
1386 |
-
function resource_nice_name($resource_id) {
|
1387 |
if ( 0 == $resource_id ) {
|
1388 |
$resource_nice_name = 'Channel (User uploads)';
|
1389 |
} elseif ( 1 == $resource_id ) {
|
@@ -1398,13 +1367,12 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1398 |
return $resource_nice_name;
|
1399 |
}
|
1400 |
|
1401 |
-
function youtube_domain($instance) {
|
1402 |
-
|
1403 |
-
return $youtube_domain;
|
1404 |
} // end function youtube_domain
|
1405 |
|
1406 |
-
function arclass($instance) {
|
1407 |
-
return
|
1408 |
} // END function arclass()
|
1409 |
|
1410 |
/**
|
@@ -1412,25 +1380,25 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1412 |
* @param array $plugins Unmodified set of plugins
|
1413 |
* @return array Set of TinyMCE plugins with YTC addition
|
1414 |
*/
|
1415 |
-
function mce_external_plugins($plugins) {
|
1416 |
|
1417 |
$plugins['youtube_channel'] = plugin_dir_url( __FILE__ ) . 'inc/tinymce/plugin.min.js';
|
1418 |
|
1419 |
return $plugins;
|
1420 |
|
1421 |
-
} // END function mce_external_plugins(
|
1422 |
|
1423 |
/**
|
1424 |
* Append TinyMCE button for YTC at the end of row 1
|
1425 |
* @param array $buttons Unmodified set of buttons
|
1426 |
* @return array Set of TinyMCE buttons with YTC addition
|
1427 |
*/
|
1428 |
-
function mce_buttons($buttons) {
|
1429 |
|
1430 |
$buttons[] = 'youtube_channel_shortcode';
|
1431 |
return $buttons;
|
1432 |
|
1433 |
-
} // END function mce_buttons(
|
1434 |
|
1435 |
function generate_debug_json() {
|
1436 |
global $wp_version;
|
@@ -1492,13 +1460,12 @@ if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
|
1492 |
|
1493 |
// Exit now, because we need only debug data in JSON file, not settings or any other page
|
1494 |
exit;
|
1495 |
-
}
|
1496 |
-
} // end class
|
1497 |
-
} // end class check
|
1498 |
|
1499 |
-
//
|
|
|
1500 |
|
1501 |
-
global $
|
1502 |
-
if ( empty( $
|
1503 |
-
$
|
1504 |
}
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: YouTube Channel
|
4 |
+
Plugin URI: https://urosevic.net/wordpress/plugins/youtube-channel/
|
5 |
Description: Quick and easy embed latest or random videos from YouTube channel (user uploads, liked or favourited videos) or playlist. Use <a href="widgets.php">widget</a> for sidebar or shortcode for content. Works with <em>YouTube Data API v3</em>.
|
6 |
+
Version: 3.0.10
|
7 |
Author: Aleksandar Urošević
|
8 |
+
Author URI: https://urosevic.net/
|
9 |
Text Domain: youtube-channel
|
10 |
*/
|
11 |
|
15 |
}
|
16 |
|
17 |
if ( ! class_exists( 'WPAU_YOUTUBE_CHANNEL' ) ) {
|
18 |
+
class WPAU_YOUTUBE_CHANNEL {
|
|
|
19 |
|
20 |
+
const DB_VER = 15;
|
21 |
+
const VER = '3.0.10';
|
22 |
|
23 |
public $plugin_name = 'YouTube Channel';
|
24 |
public $plugin_slug = 'youtube-channel';
|
89 |
*/
|
90 |
public static function activate() {
|
91 |
|
92 |
+
global $wpau_youtube_channel;
|
93 |
+
$wpau_youtube_channel->init_options();
|
94 |
+
$wpau_youtube_channel->maybe_update();
|
95 |
|
96 |
+
} // END public static function activate()
|
97 |
|
98 |
/**
|
99 |
* Return initial options
|
133 |
'goto_txt' => 'Visit our channel',
|
134 |
'popup_goto' => 0, // 0 same window, 1 new window JS, 2 new window target
|
135 |
'link_to' => 'none', // 0 legacy username, 1 channel, 2 vanity
|
136 |
+
'tinymce' => 1, // show TinyMCE button by default
|
137 |
);
|
138 |
|
139 |
add_option( 'youtube_channel_version', self::VER, '', 'no' );
|
165 |
function admin_init() {
|
166 |
|
167 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_settings_link' ) );
|
168 |
+
// Add row on Plugins page
|
169 |
add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 );
|
170 |
|
171 |
require_once( 'inc/settings.php' );
|
172 |
|
173 |
+
global $wpau_youtube_channel_settings;
|
174 |
+
if ( empty( $wpau_youtube_channel_settings ) ) {
|
175 |
+
$wpau_youtube_channel_settings = new WPAU_YOUTUBE_CHANNEL_SETTINGS();
|
176 |
}
|
177 |
|
178 |
} // END function admin_init_settings()
|
181 |
* Append Settings link for Plugins page
|
182 |
* @param array $links array of links on plugins page
|
183 |
*/
|
184 |
+
function add_settings_link( $links ) {
|
185 |
|
186 |
$settings_title = __( 'Settings' );
|
187 |
$settings_link = "<a href=\"options-general.php?page={$this->plugin_slug}\">{$settings_title}</a>";
|
198 |
/**
|
199 |
* Add link to official plugin page
|
200 |
*/
|
201 |
+
function add_plugin_meta_links( $links, $file ) {
|
202 |
|
203 |
if ( 'youtube-channel/youtube-channel.php' === $file ) {
|
204 |
return array_merge(
|
213 |
}
|
214 |
return $links;
|
215 |
|
216 |
+
} // END function add_plugin_meta_links()
|
217 |
+
|
218 |
/**
|
219 |
* Enqueue admin scripts and styles for widget customization
|
220 |
*/
|
285 |
)
|
286 |
) {
|
287 |
$notice['info'] .= sprintf(
|
288 |
+
__( '<p>Your website running on web server with PHP version %1$s. Please note that <strong>%2$s</strong> requires PHP at least 5.3 or newer to work properly. <a href="%3$s" class="dismiss">Dismiss</a></p>', 'youtube-channel' ),
|
289 |
PHP_VERSION,
|
290 |
$this->plugin_name,
|
291 |
'?ytc_dismiss_notice_old_php=1'
|
298 |
empty( $dismissed_notices['apikey_wpconfig'] )
|
299 |
) {
|
300 |
$notice['info'] .= sprintf(
|
301 |
+
__( '<p>Since <strong>%1$s</strong> v3.0.6 we store <strong>YouTube Data API Key</strong> in plugin settings. So, you can safely remove %2$s define line from your <strong>wp-config.php</strong> file. <a href="%3$s" class="dismiss">Dismiss</a></p>', 'youtube-channel' ),
|
302 |
$this->plugin_name,
|
303 |
'YOUTUBE_DATA_API_KEY',
|
304 |
'?ytc_dismiss_notice_apikey_wpconfig=1'
|
310 |
$notice['error'] .= sprintf(
|
311 |
wp_kses(
|
312 |
__(
|
313 |
+
'<p><strong>%1$s v3</strong> require <strong>%2$s</strong> set on plugin <a href="%6$s">%7$s</a>. You can generate your own key on <a href="%3$s" target="_blank">%4$s</a> by following <a href="%5$s" target="_blank">this tutorial</a>.</p>',
|
314 |
'youtube-channel'
|
315 |
),
|
316 |
array(
|
324 |
__( 'YouTube Data API Key', 'youtube-channel' ),
|
325 |
esc_url( 'https://console.developers.google.com/project' ),
|
326 |
__( 'Google Developers Console', 'youtube-channel' ),
|
327 |
+
esc_url( 'https://urosevic.net/wordpress/plugins/youtube-channel/#youtube_data_api_key' ),
|
328 |
esc_url( 'options-general.php?page=youtube-channel&tab=general' ),
|
329 |
+
__( 'General Settings', 'youtube-channel' )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
);
|
331 |
}
|
332 |
|
333 |
+
// v3.0.8.1 shortcode changes since v3.0.8
|
334 |
+
if ( ! empty( $dismissed_notices ) && empty( $dismissed_notices['changed_shortcode_308'] ) ) {
|
|
|
|
|
|
|
335 |
$notice['warning'] .= sprintf(
|
336 |
+
__( '<p><strong>%1$s</strong> changed shortcode parameters by removing <code>only_pl</code> and <code>showgoto</code>, and combining with parameters <code>display</code> and <code>link_to</code> respectively. Please check out <a href="%2$s&tab=help">%3$s</a> and update your shortcodes. <a href="%4$s" class="dismiss">Dismiss</a>', 'youtube-channel' ),
|
337 |
$this->plugin_name,
|
338 |
$settings_page,
|
339 |
'Help: How to use shortcode',
|
340 |
'?ytc_dismiss_notice_changed_shortcode_308=1'
|
341 |
);
|
342 |
+
} else if ( empty( $dismissed_notices ) ) {
|
343 |
+
// First time install? auto dismiss this notice
|
344 |
+
$dismissed_notices['changed_shortcode_308'] = 1;
|
345 |
+
update_option( 'youtube_channel_dismissed_notices', $dismissed_notices );
|
346 |
}
|
347 |
+
|
348 |
foreach ( $notice as $type => $message ) {
|
349 |
if ( ! empty( $message ) ) {
|
350 |
echo "<div class=\"notice notice-{$type}\">{$message}</div>";
|
361 |
|
362 |
$defaults = get_option( $this->plugin_option );
|
363 |
if ( empty( $defaults ) ) {
|
364 |
+
$defaults = $this->init_options();
|
365 |
}
|
366 |
|
367 |
return $defaults;
|
368 |
|
369 |
+
} // END public function defaults()
|
370 |
|
371 |
/**
|
372 |
* Enqueue frontend scripts and styles
|
373 |
*/
|
374 |
function enqueue_scripts() {
|
375 |
|
376 |
+
// Check do we need our own lightbox?
|
377 |
if ( empty( $this->defaults['nolightbox'] ) ) {
|
378 |
wp_enqueue_style(
|
379 |
'magnific-popup-au',
|
396 |
array(),
|
397 |
self::VER
|
398 |
);
|
399 |
+
|
400 |
+
} // END function enqueue_scripts()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
|
402 |
/**
|
403 |
* Generate comlete inline JavaScript code that conains
|
474 |
|
475 |
} // END function footer_scripts()
|
476 |
|
477 |
+
public function shortcode( $atts ) {
|
478 |
|
479 |
+
// Get general default settings
|
480 |
$instance = $this->defaults();
|
481 |
|
482 |
+
// Extract shortcode parameters
|
483 |
+
$atts = shortcode_atts(
|
484 |
+
array(
|
485 |
+
'vanity' => $instance['vanity'],
|
486 |
+
'channel' => $instance['channel'],
|
487 |
+
'username' => $instance['username'],
|
488 |
+
'playlist' => $instance['playlist'],
|
489 |
+
'res' => '', // (deprecated, but leave for back compatibility) ex res
|
490 |
+
'use_res' => '', // (deprecated, but leave for back compatibility) ex use_res
|
491 |
+
'resource' => $instance['resource'], // ex use_res
|
492 |
+
'only_pl' => 0, // disabled by default (was: $instance['only_pl'],)
|
493 |
+
'cache' => $instance['cache'], // ex cache_time
|
494 |
+
'privacy' => $instance['privacy'], // ex showvidesc
|
495 |
+
'fetch' => $instance['fetch'], // ex maxrnd
|
496 |
+
'num' => $instance['num'], // ex vidqty
|
497 |
+
|
498 |
+
'random' => 0, // ex getrnd
|
499 |
+
|
500 |
+
'ratio' => $instance['ratio'],
|
501 |
+
'width' => $instance['width'],
|
502 |
+
'responsive' => ! empty( $instance['responsive'] ) ? $instance['responsive'] : '0',
|
503 |
+
|
504 |
+
'show' => $instance['display'], // (deprecated, but keep for back compatibility) ex to_show
|
505 |
+
'display' => $instance['display'],
|
506 |
+
'no_thumb_title' => 0,
|
507 |
+
'themelight' => $instance['themelight'],
|
508 |
+
'controls' => $instance['controls'],
|
509 |
+
'autoplay' => $instance['autoplay'],
|
510 |
+
'mute' => $instance['autoplay_mute'],
|
511 |
+
'norel' => $instance['norel'],
|
512 |
+
'playsinline' => $instance['playsinline'], // play video on mobile devices inline instead in native device player
|
513 |
+
|
514 |
+
'showtitle' => $instance['showtitle'], // none, above, below
|
515 |
+
'showdesc' => $instance['showdesc'], // ex showvidesc
|
516 |
+
'nobrand' => ! empty( $instance['modestbranding'] ) ? $instance['modestbranding'] : '0',
|
517 |
+
'desclen' => $instance['desclen'], // ex videsclen
|
518 |
+
'noinfo' => $instance['hideinfo'],
|
519 |
+
'noanno' => $instance['hideanno'],
|
520 |
+
|
521 |
+
'goto_txt' => $instance['goto_txt'],
|
522 |
+
'popup' => $instance['popup_goto'],
|
523 |
+
'link_to' => $instance['link_to'], // none, vanity, channel, legacy
|
524 |
+
|
525 |
+
'class' => ! empty( $instance['class'] ) ? $instance['class'] : '',
|
526 |
+
),
|
527 |
+
$atts
|
|
|
|
|
528 |
);
|
529 |
|
530 |
// backward compatibility for show -> display shortcode parameter
|
531 |
+
if ( ! empty( $atts['show'] ) && $atts['show'] !== $atts['display'] && $atts['show'] !== $instance['display'] ) {
|
532 |
+
$atts['display'] = $atts['show'];
|
533 |
}
|
534 |
// backward compatibility for use_res -> resource shortcode parameter
|
535 |
+
if ( ! empty( $atts['use_res'] ) ) {
|
536 |
+
$atts['resource'] = $atts['use_res'];
|
537 |
+
} else if ( ! empty( $atts['res'] ) ) {
|
538 |
+
$atts['resource'] = $atts['res'];
|
539 |
}
|
540 |
|
541 |
// prepare instance for output
|
542 |
+
$instance['vanity'] = $atts['vanity'];
|
543 |
+
$instance['channel'] = $atts['channel'];
|
544 |
+
$instance['username'] = $atts['username'];
|
545 |
+
$instance['playlist'] = $atts['playlist'];
|
546 |
+
$instance['resource'] = $atts['resource']; // resource: 0 channel, 1 favorites, 2 playlist, 3 liked
|
547 |
+
$instance['cache'] = $atts['cache']; // in seconds, def 5min - settings?
|
548 |
+
$instance['privacy'] = $atts['privacy']; // enhanced privacy
|
549 |
|
550 |
+
$instance['fetch'] = (int) $atts['fetch'];
|
551 |
+
$instance['num'] = (int) $atts['num']; // num: 1
|
552 |
|
553 |
+
$instance['random'] = $atts['random']; // use embedded playlist - false by default
|
554 |
|
555 |
// Video Settings
|
556 |
+
$instance['ratio'] = $atts['ratio']; // aspect ratio: 3 - 16:9, 2 - 16:10, 1 - 4:3
|
557 |
+
$instance['width'] = (int) $atts['width']; // 306
|
558 |
+
$instance['responsive'] = $atts['responsive']; // enable responsivenes?
|
559 |
+
$instance['display'] = $atts['display']; // thumbnail, iframe, iframe2, playlist
|
560 |
+
$instance['no_thumb_title'] = $atts['no_thumb_title']; // hide tooltip for thumbnails
|
561 |
+
|
562 |
+
$instance['themelight'] = $atts['themelight']; // use light theme, dark by default
|
563 |
+
$instance['controls'] = $atts['controls']; // hide controls, false by default
|
564 |
+
$instance['autoplay'] = $atts['autoplay']; // autoplay disabled by default
|
565 |
+
$instance['autoplay_mute'] = $atts['mute']; // mute sound on autoplay - disabled by default
|
566 |
+
$instance['norel'] = $atts['norel']; // hide related videos
|
567 |
+
$instance['playsinline'] = $atts['playsinline']; // inline plaer for iOS
|
568 |
|
569 |
// Content Layout
|
570 |
+
$instance['showtitle'] = $atts['showtitle']; // show video title, disabled by default
|
571 |
+
$instance['showdesc'] = $atts['showdesc']; // show video description, disabled by default
|
572 |
+
$instance['modestbranding'] = $atts['nobrand']; // hide YT logo
|
573 |
+
$instance['desclen'] = (int) $atts['desclen']; // cut video description, number of characters
|
574 |
+
$instance['hideinfo'] = $atts['noinfo']; // hide info by default
|
575 |
+
$instance['hideanno'] = $atts['noanno']; // hide annotations, false by default
|
576 |
|
577 |
// Link to Channel
|
578 |
+
$instance['goto_txt'] = $atts['goto_txt']; // text for goto link - use settings
|
579 |
+
$instance['popup_goto'] = $atts['popup']; // open channel in: 0 same window, 1 javascript new, 2 target new
|
580 |
+
$instance['link_to'] = $atts['link_to']; // link to: none, vanity, legacy, channel
|
581 |
|
582 |
// Customization
|
583 |
+
$instance['class'] = $atts['class']; // custom additional class for container
|
584 |
|
585 |
+
// return implode( array_values( $this->output( $instance ) ) );
|
586 |
+
return $this->output( $instance );
|
587 |
} // END public function shortcode()
|
588 |
|
589 |
// Print out YTC block
|
590 |
+
public function output( $instance ) {
|
591 |
|
592 |
// Error message if no YouTube Data API Key
|
593 |
if ( empty( $this->defaults['apikey'] ) ) {
|
594 |
|
595 |
$error_msg = sprintf(
|
596 |
+
__( '<strong>%1$s v3</strong> requires <strong>YouTube DATA API Key</strong> to work. <a href="%2$s" target="_blank">Learn more here</a>.', 'youtube-channel' ),
|
597 |
$this->plugin_name,
|
598 |
+
'https://urosevic.net/wordpress/plugins/youtube-channel/#youtube_data_api_key'
|
599 |
);
|
600 |
|
601 |
+
return $this->front_debug( $error_msg );
|
|
|
602 |
|
603 |
}
|
604 |
|
605 |
// 1) Get resource from widget/shortcode
|
606 |
// 2) If not set, get global default
|
607 |
// 3) if no global, get plugin's default
|
608 |
+
if ( ! isset( $instance['resource'] ) ) {
|
609 |
$instance['resource'] = $this->defaults['resource'];
|
610 |
}
|
611 |
$resource = intval( $instance['resource'] );
|
631 |
}
|
632 |
// Now check has Playlist ID set or throw error
|
633 |
if ( '' == $playlist ) {
|
634 |
+
return $this->front_debug( 'Playlist selected as resource but no Playlist ID provided!' );
|
|
|
635 |
}
|
636 |
break;
|
637 |
|
656 |
$resource_name = 'Channel (User uploads)';
|
657 |
}
|
658 |
$error_msg = sprintf( '%s selected as resource but no Channel ID provided!', $resource_name );
|
659 |
+
return $this->front_debug( $error_msg );
|
|
|
660 |
}
|
661 |
} // END switch ($resource)
|
662 |
|
689 |
$resource_id = preg_replace( '/^UC/', 'UU', $channel );
|
690 |
}
|
691 |
|
692 |
+
// Start output string
|
693 |
+
$output = '';
|
694 |
|
695 |
+
$output .= "<div class=\"youtube_channel {$class}\">";
|
696 |
|
697 |
if ( empty( $instance['display'] ) ) {
|
698 |
$instance['display'] = $this->defaults['display'];
|
699 |
}
|
700 |
if ( 'playlist' == $instance['display'] ) { // Insert as Embedded playlist
|
701 |
|
702 |
+
$output .= self::embed_playlist( $resource_id, $instance );
|
703 |
|
704 |
} else { // Individual videos from channel, favourites, liked or playlist
|
705 |
|
767 |
|
768 |
// Prevent further checks if we have WP Error or empty record even after fallback
|
769 |
if ( is_wp_error( $json_output ) ) {
|
770 |
+
$output .= $this->front_debug( $json_output->get_error_message() );
|
771 |
return $output;
|
772 |
} elseif ( isset( $json_output->items ) && 0 == sizeof( $json_output->items ) ) {
|
773 |
+
$output .= $this->front_debug( sprintf( __( 'You have set to display videos from %1$s [resource list ID: %2$s], but there have no public videos in that resouce.' ), $resource_nice_name, $resource_id ) );
|
774 |
return $output;
|
775 |
} elseif ( empty( $json_output ) ) {
|
776 |
+
$output .= $this->front_debug( sprintf( __( 'We have empty record for this feed. Please read <a href="%1$s" target="_blank">FAQ</a> and if that does not help, contact <a href="%2$s" target="_blank">support</a>.' ), 'https://wordpress.org/plugins/youtube-channel/faq/', 'https://wordpress.org/support/plugin/youtube-channel' ) );
|
777 |
return $output;
|
778 |
}
|
779 |
|
832 |
|
833 |
} // END ! empty($json_output->error->errors)
|
834 |
|
835 |
+
$output .= $this->front_debug( $error_msg );
|
836 |
|
837 |
} else { // ELSE if ($max_items == 0)
|
838 |
|
866 |
}
|
867 |
|
868 |
// Generate single video block
|
869 |
+
$output .= $this->ytc_print_video( $item, $instance, $y );
|
870 |
}
|
871 |
// Free some memory
|
872 |
unset( $random_used, $random_item, $json );
|
877 |
|
878 |
// Append link to channel on bootom of the widget
|
879 |
if ( ! empty( $instance['link_to'] ) && 'none' != $instance['link_to'] ) {
|
880 |
+
$output .= $this->ytc_channel_link( $instance );
|
881 |
}
|
882 |
|
883 |
+
$output .= '</div><!-- .youtube_channel -->';
|
884 |
|
885 |
// fix overflow on crappy themes
|
886 |
+
$output .= '<div class="clearfix"></div>';
|
887 |
|
888 |
return $output;
|
889 |
|
897 |
* @param integer $items Number of items to fetch (min 2, max 50)
|
898 |
* @return array JSON with videos
|
899 |
*/
|
900 |
+
function fetch_youtube_feed( $resource_id, $items ) {
|
901 |
|
902 |
$feed_url = 'https://www.googleapis.com/youtube/v3/playlistItems?';
|
903 |
$feed_url .= 'part=snippet';
|
936 |
* @param string $message Error message
|
937 |
* @return string FOrmatted message for error
|
938 |
*/
|
939 |
+
function front_debug( $message ) {
|
940 |
|
941 |
// Show visible error to admin, Oops message to visitors and lower members
|
942 |
if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) {
|
954 |
|
955 |
return $output;
|
956 |
|
957 |
+
} // END function debug( $message )
|
958 |
|
959 |
/**
|
960 |
* Calculate height by provided width and aspect ratio
|
981 |
* @param array $instance widget or shortcode settings
|
982 |
* @return array components prepared for output
|
983 |
*/
|
984 |
+
function ytc_channel_link( $instance ) {
|
985 |
|
986 |
// initialize array
|
987 |
+
// $output = array();
|
988 |
+
// Initialize output string
|
989 |
+
$output = '';
|
990 |
|
991 |
// do we need to show goto link?
|
992 |
if ( 'none' != $instance['link_to'] ) {
|
998 |
$vanity = trim( $instance['vanity'] );
|
999 |
if ( empty( $vanity ) ) {
|
1000 |
if ( empty( $this->defaults['vanity'] ) ) {
|
1001 |
+
return '<!-- YTC ERROR: Selected Vanity custom URL to be linked but no Vanity Name provided! -->';
|
1002 |
}
|
1003 |
// Get vanity from defaults if not set in instance
|
1004 |
$vanity = $this->defaults['vanity'];
|
1014 |
$username = trim( $instance['username'] );
|
1015 |
if ( empty( $username ) ) {
|
1016 |
if ( empty( $this->defaults['username'] ) ) {
|
1017 |
+
return '<!-- YTC ERROR: Selected Legacy username to be linked but no Legacy username provided! -->';
|
1018 |
}
|
1019 |
$username = $this->defaults['username'];
|
1020 |
}
|
1025 |
$channel = trim( $instance['channel'] );
|
1026 |
if ( empty( $channel ) ) {
|
1027 |
if ( empty( $this->defaults['channel'] ) ) {
|
1028 |
+
return '<!-- YTC ERROR: Selected Channel page to be linked but no Channel ID provided! -->';
|
1029 |
}
|
1030 |
$channel = $this->defaults['channel'];
|
1031 |
}
|
1040 |
|
1041 |
$newtab = __( 'in new window/tab', 'youtube-channel' );
|
1042 |
|
1043 |
+
$output .= '<div class="clearfix"></div>';
|
1044 |
+
$output .= '<div class="ytc_link">';
|
1045 |
+
$output .= '<p>';
|
1046 |
switch ( $instance['popup_goto'] ) {
|
1047 |
case 1:
|
1048 |
+
$output .= "<a href=\"javascript: window.open('{$goto_url}'); void 0;\" title=\"{$goto_txt} {$newtab}\">{$goto_txt}</a>";
|
1049 |
break;
|
1050 |
case 2:
|
1051 |
+
$output .= "<a href=\"{$goto_url}\" target=\"_blank\" title=\"{$goto_txt} {$newtab}\">{$goto_txt}</a>";
|
1052 |
break;
|
1053 |
default:
|
1054 |
+
$output .= "<a href=\"{$goto_url}\" title=\"{$goto_txt}\">$goto_txt</a>";
|
1055 |
} // switch popup_goto
|
1056 |
+
$output .= '</p>';
|
1057 |
+
$output .= '</div>';
|
1058 |
|
1059 |
} // showgoto
|
1060 |
|
1069 |
* @param int $y Order number of video
|
1070 |
* @return array Prepared single video block as array to concatenate
|
1071 |
*/
|
1072 |
+
function ytc_print_video( $item, $instance, $y ) {
|
1073 |
+
|
1074 |
+
// Start output string
|
1075 |
+
$output = '';
|
1076 |
|
1077 |
// Calculate width and height
|
1078 |
if ( empty( $instance['width'] ) ) {
|
1114 |
// Set proper class for responsive thumbs per selected aspect ratio
|
1115 |
$arclass = $this->arclass( $instance );
|
1116 |
|
1117 |
+
$output .= "<div class=\"ytc_video_container ytc_video_{$y} ytc_video_{$vnumclass} ${arclass}\" style=\"width:{$instance['width']}px\">";
|
1118 |
|
1119 |
// Show video title above video?
|
1120 |
if ( ! empty( $instance['showtitle'] ) && 'above' == $instance['showtitle'] ) {
|
1121 |
+
$output .= "<h3 class=\"ytc_title ytc_title_above\">{$yt_title}</h3>";
|
1122 |
}
|
1123 |
|
1124 |
// Print out video
|
1126 |
|
1127 |
// Start wrapper for responsive item
|
1128 |
if ( $instance['responsive'] ) {
|
1129 |
+
$output .= '<div class="fluid-width-video-wrapper">';
|
1130 |
}
|
1131 |
|
1132 |
+
$output .= "<iframe title=\"YouTube Video Player\" width=\"{$instance['width']}\" height=\"{$height}\" src=\"//{$youtube_domain}/embed/{$yt_id}?wmode=opaque";
|
1133 |
|
1134 |
+
if ( ! empty( $instance['norel'] ) ) { $output .= '&rel=0'; } // disable related videos
|
1135 |
+
if ( ! empty( $instance['controls'] ) ) { $output .= '&controls=0'; }
|
1136 |
+
if ( ! empty( $instance['hideinfo'] ) ) { $output .= '&showinfo=0'; }
|
1137 |
+
if ( ! empty( $instance['autoplay'] ) && 1 == $y ) { $output .= '&autoplay=1'; }
|
1138 |
+
if ( ! empty( $instance['hideanno'] ) ) { $output .= '&iv_load_policy=3'; }
|
1139 |
+
if ( ! empty( $instance['themelight'] ) ) { $output .= '&theme=light'; }
|
1140 |
+
if ( ! empty( $instance['modestbranding'] ) ) { $output .= '&modestbranding=1'; }
|
1141 |
+
if ( ! empty( $instance['playsinline'] ) ) { $output .= '&playsinline=1'; }
|
1142 |
|
1143 |
+
$output .= "\" style=\"border:0;\" allowfullscreen id=\"ytc_{$yt_id}\"></iframe>";
|
1144 |
|
1145 |
// Close wrapper for responsive item
|
1146 |
if ( $instance['responsive'] ) {
|
1147 |
+
$output .= '</div>';
|
1148 |
}
|
1149 |
} else if ( 'iframe2' == $instance['display'] ) {
|
1150 |
|
1169 |
|
1170 |
// Start wrapper for responsive item
|
1171 |
if ( $instance['responsive'] ) {
|
1172 |
+
$output .= '<div class="fluid-width-video-wrapper">';
|
1173 |
}
|
1174 |
|
1175 |
+
$output .= "<div id=\"ytc_player_{$js_player_id}\"></div>";
|
1176 |
|
1177 |
// Close wrapper for responsive item
|
1178 |
if ( $instance['responsive'] ) {
|
1179 |
+
$output .= '</div>';
|
1180 |
}
|
1181 |
|
1182 |
$site_domain = $_SERVER['HTTP_HOST'];
|
1208 |
|
1209 |
// Do we need thumbnail w/ or w/o tooltip
|
1210 |
$tag_title = ( empty( $instance['no_thumb_title'] ) ) ? $tag_title = "title=\"{$yt_title}\"" : '';
|
1211 |
+
$output .= "<a href=\"//www.youtube.com/watch?v=${yt_id}${p}\" ${tag_title} class=\"ytc_thumb ytc-lightbox {$arclass}\"><span style=\"background-image: url({$yt_thumb});\" ${tag_title} id=\"ytc_{$yt_id}\"></span></a>";
|
1212 |
|
1213 |
} // what to show conditions
|
1214 |
|
1215 |
// show video title below video?
|
1216 |
if ( ! empty( $instance['showtitle'] ) && 'below' == $instance['showtitle'] ) {
|
1217 |
+
$output .= "<h3 class=\"ytc_title ytc_title_below\">{$yt_title}</h3>";
|
1218 |
}
|
1219 |
|
1220 |
// do we need to show video description?
|
1231 |
}
|
1232 |
|
1233 |
if ( ! empty( $video_description ) ) {
|
1234 |
+
$output .= "<p class=\"ytc_description\">{$video_description}{$etcetera}</p>";
|
1235 |
}
|
1236 |
}
|
1237 |
|
1238 |
+
$output .= '</div><!-- .ytc_video_container -->';
|
1239 |
|
1240 |
return $output;
|
1241 |
} // end function ytc_print_video
|
1242 |
|
1243 |
/* function to print standard playlist embed code */
|
1244 |
+
function embed_playlist( $resource_id, $instance ) {
|
1245 |
|
1246 |
+
$width = empty( $instance['width'] ) ? 306 : $instance['width'];
|
1247 |
$height = self::height_ratio( $width, $instance['ratio'] );
|
1248 |
+
$autoplay = empty( $instance['autoplay'] ) ? '' : '&autoplay=1';
|
1249 |
+
$theme = empty( $instance['themelight'] ) ? '' : '&theme=light';
|
1250 |
+
$modestbranding = empty( $instance['modestbranding'] ) ? '' : '&modestbranding=1';
|
1251 |
+
$rel = empty( $instance['norel'] ) ? '' : '&rel=0';
|
1252 |
+
$playsinline = empty( $instance['playsinline'] ) ? '' : '&playsinline=1';
|
1253 |
|
1254 |
// enhanced privacy
|
1255 |
$youtube_domain = $this->youtube_domain( $instance );
|
1256 |
$arclass = $this->arclass( $instance );
|
1257 |
+
|
1258 |
+
// Start output string
|
1259 |
+
$output = '';
|
1260 |
+
|
1261 |
+
$output .= "<div class=\"ytc_video_container ytc_video_1 ytc_video_single ytc_playlist_only {$arclass}\">";
|
1262 |
+
$output .= '<div class="fluid-width-video-wrapper">';
|
1263 |
+
$output .= "<iframe src=\"//{$youtube_domain}/embed/videoseries?list={$resource_id}{$autoplay}{$theme}{$modestbranding}{$rel}\"";
|
1264 |
+
if ( ! empty( $instance['fullscreen'] ) ) { $output .= ' allowfullscreen'; }
|
1265 |
+
$output .= " width=\"{$width}\" height=\"{$height}\" frameborder=\"0\"></iframe>";
|
1266 |
+
$output .= '</div><!-- .fluid-width-video-wrapper -->';
|
1267 |
+
$output .= '</div><!-- .ytc_video_container -->';
|
1268 |
|
1269 |
return $output;
|
1270 |
|
1271 |
} // END function embed_playlist($resource_id, $instance)
|
1272 |
|
1273 |
// Helper function cache_time()
|
1274 |
+
function cache_time( $cache_time ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1275 |
|
1276 |
$out = '';
|
1277 |
+
$times = self::cache_times_arr();
|
1278 |
+
foreach ( $times as $sec => $title ) {
|
1279 |
+
$out .= '<option value="' . $sec . '" ' . selected( $cache_time, $sec, 0 ) . '>' . $title . '</option>';
|
1280 |
+
unset( $sec );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1281 |
}
|
1282 |
+
|
1283 |
return $out;
|
|
|
1284 |
|
1285 |
+
} // END function cache_time()
|
1286 |
+
|
1287 |
+
/**
|
1288 |
+
* Define cache times array
|
1289 |
+
*/
|
1290 |
+
public static function cache_times_arr() {
|
1291 |
+
|
1292 |
+
return array(
|
1293 |
+
'0' => __( 'Do not cache', 'youtube-channel' ),
|
1294 |
+
'60' => __( '1 minute', 'youtube-channel' ),
|
1295 |
+
'300' => __( '5 minutes', 'youtube-channel' ),
|
1296 |
+
'900' => __( '15 minutes', 'youtube-channel' ),
|
1297 |
+
'1800' => __( '30 minutes', 'youtube-channel' ),
|
1298 |
+
'3600' => __( '1 hour', 'youtube-channel' ),
|
1299 |
+
'7200' => __( '2 hours', 'youtube-channel' ),
|
1300 |
+
'18000' => __( '5 hours', 'youtube-channel' ),
|
1301 |
+
'36000' => __( '10 hours', 'youtube-channel' ),
|
1302 |
+
'43200' => __( '12 hours', 'youtube-channel' ),
|
1303 |
+
'64800' => __( '18 hours', 'youtube-channel' ),
|
1304 |
+
'86400' => __( '1 day', 'youtube-channel' ),
|
1305 |
+
'172800' => __( '2 days', 'youtube-channel' ),
|
1306 |
+
'259200' => __( '3 days', 'youtube-channel' ),
|
1307 |
+
'345600' => __( '4 days', 'youtube-channel' ),
|
1308 |
+
'432000' => __( '5 days', 'youtube-channel' ),
|
1309 |
+
'518400' => __( '6 days', 'youtube-channel' ),
|
1310 |
+
'604800' => __( '1 week', 'youtube-channel' ),
|
1311 |
+
'1209600' => __( '2 weeks', 'youtube-channel' ),
|
1312 |
+
'1814400' => __( '3 weeks', 'youtube-channel' ),
|
1313 |
+
'2419200' => __( '1 month', 'youtube-channel' ),
|
1314 |
+
);
|
1315 |
+
|
1316 |
+
} // END public static function cache_times_arr()
|
1317 |
|
1318 |
/**
|
1319 |
* Method to delete all YTC transient caches
|
1352 |
* @param integer $resource_id Resource ID
|
1353 |
* @return string Resource nice name
|
1354 |
*/
|
1355 |
+
function resource_nice_name( $resource_id ) {
|
1356 |
if ( 0 == $resource_id ) {
|
1357 |
$resource_nice_name = 'Channel (User uploads)';
|
1358 |
} elseif ( 1 == $resource_id ) {
|
1367 |
return $resource_nice_name;
|
1368 |
}
|
1369 |
|
1370 |
+
function youtube_domain( $instance ) {
|
1371 |
+
return empty( $instance['privacy'] ) ? 'www.youtube.com' : 'www.youtube-nocookie.com';
|
|
|
1372 |
} // end function youtube_domain
|
1373 |
|
1374 |
+
function arclass( $instance ) {
|
1375 |
+
return ! empty( $instance['ratio'] ) && 1 == $instance['ratio'] ? 'ar4_3' : 'ar16_9';
|
1376 |
} // END function arclass()
|
1377 |
|
1378 |
/**
|
1380 |
* @param array $plugins Unmodified set of plugins
|
1381 |
* @return array Set of TinyMCE plugins with YTC addition
|
1382 |
*/
|
1383 |
+
function mce_external_plugins( $plugins ) {
|
1384 |
|
1385 |
$plugins['youtube_channel'] = plugin_dir_url( __FILE__ ) . 'inc/tinymce/plugin.min.js';
|
1386 |
|
1387 |
return $plugins;
|
1388 |
|
1389 |
+
} // END function mce_external_plugins()
|
1390 |
|
1391 |
/**
|
1392 |
* Append TinyMCE button for YTC at the end of row 1
|
1393 |
* @param array $buttons Unmodified set of buttons
|
1394 |
* @return array Set of TinyMCE buttons with YTC addition
|
1395 |
*/
|
1396 |
+
function mce_buttons( $buttons ) {
|
1397 |
|
1398 |
$buttons[] = 'youtube_channel_shortcode';
|
1399 |
return $buttons;
|
1400 |
|
1401 |
+
} // END function mce_buttons()
|
1402 |
|
1403 |
function generate_debug_json() {
|
1404 |
global $wp_version;
|
1460 |
|
1461 |
// Exit now, because we need only debug data in JSON file, not settings or any other page
|
1462 |
exit;
|
1463 |
+
} // End function generate_debug_json()
|
|
|
|
|
1464 |
|
1465 |
+
} // End class
|
1466 |
+
} // End class check
|
1467 |
|
1468 |
+
global $wpau_youtube_channel;
|
1469 |
+
if ( empty( $wpau_youtube_channel ) ) {
|
1470 |
+
$wpau_youtube_channel = new WPAU_YOUTUBE_CHANNEL();
|
1471 |
}
|