Feeds for YouTube (YouTube video, channel, and gallery plugin) - Version 1.3

Version Description

  • New: Integrations with popular GDPR cookie consent solutions added: Cookie Notice by dFactory, GDPR Cookie Consent by WebToffee, Cookiebot by Cybot A/S, Complianz by Really Simple Plugins, and Borlabs Cookie by Borlabs. Visit the YouTube Feed settings page, Customize tab, GDPR section for more information.
  • Fix: Date that video was published would not always match what was shown on YouTube.com.
Download this release

Release Info

Developer smashballoon
Plugin Icon 128x128 Feeds for YouTube (YouTube video, channel, and gallery plugin)
Version 1.3
Comparing to
See all releases

Code changes from version 1.2.4 to 1.3

README.txt CHANGED
@@ -1,11 +1,11 @@
1
- === Feeds for YouTube - YouTube video, channel, and gallery plugin ===
2
  Author: Smash Balloon
3
  Contributors: smashballoon, craig-at-smash-balloon
4
  Support Website: http://smashballoon/youtube-feed/
5
  Tags: YouTube, YouTube feed, YouTube widget, YouTube channel, YouTube gallery
6
  Requires at least: 3.4
7
  Tested up to: 5.6
8
- Stable tag: 1.2.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -15,7 +15,7 @@ The Feeds for YouTube plugin allows you to display customizable YouTube feeds fr
15
  **Display customizable YouTube channel feeds on your website. Feed YouTube channel content automatically to your website in a powerful and customizable gallery.**
16
 
17
  ### YouTube Feed Features
18
- * **Completely Customizable** feeds - by default inherits your theme's styles
19
  * **Completely responsive and mobile optimized** - your feeds look great on any screen size
20
  * **Light and low overhead** - minimal bloat and optimized requests to YouTube
21
  * **Multiple layouts** - display videos from any YouTube channel in a list, gallery, or grid layout
@@ -32,8 +32,8 @@ For simple step-by-step directions on how to set up the Feeds for YouTube plugin
32
  ### Benefits
33
  * **Increase social engagement** between you and your subscribers
34
  * **Save time** by using the plugin to generate dynamic, search engine crawlable content on your website
35
- * **Get more YouTube subscribers** by displaying your YouTube videos directly on your site
36
- * Display your YouTube channel content **your way** to perfectly match your website's style
37
  * The plugin is **updated regularly** with new features, bug-fixes and API changes
38
  * Support is quick, effective, and always happy to help
39
  * We're dedicated to providing the **most customizable**, **robust** and **well supported** YouTube gallery plugin in the world!
@@ -165,6 +165,10 @@ By default, the plugin retrieves new videos for your YouTube gallery once every
165
  7. To display a YouTube feed just copy and paste the [youtube-feed] shortcode into a widget or page
166
 
167
  == Changelog ==
 
 
 
 
168
  = 1.2.4 =
169
  * Tweak: Minor update to item.php template to accommodate dynamic title attribute in lightbox.
170
  * Tweak: Added support for improved notices on the plugin settings page.
1
+ === Feeds for YouTube (YouTube video, channel, and gallery plugin) ===
2
  Author: Smash Balloon
3
  Contributors: smashballoon, craig-at-smash-balloon
4
  Support Website: http://smashballoon/youtube-feed/
5
  Tags: YouTube, YouTube feed, YouTube widget, YouTube channel, YouTube gallery
6
  Requires at least: 3.4
7
  Tested up to: 5.6
8
+ Stable tag: 1.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
15
  **Display customizable YouTube channel feeds on your website. Feed YouTube channel content automatically to your website in a powerful and customizable gallery.**
16
 
17
  ### YouTube Feed Features
18
+ * **Completely Customizable** YouTube feeds - by default inherits your theme's styles
19
  * **Completely responsive and mobile optimized** - your feeds look great on any screen size
20
  * **Light and low overhead** - minimal bloat and optimized requests to YouTube
21
  * **Multiple layouts** - display videos from any YouTube channel in a list, gallery, or grid layout
32
  ### Benefits
33
  * **Increase social engagement** between you and your subscribers
34
  * **Save time** by using the plugin to generate dynamic, search engine crawlable content on your website
35
+ * **Get more subscribers** by displaying your videos directly on your site
36
+ * Display your channel content **your way** to perfectly match your website's style
37
  * The plugin is **updated regularly** with new features, bug-fixes and API changes
38
  * Support is quick, effective, and always happy to help
39
  * We're dedicated to providing the **most customizable**, **robust** and **well supported** YouTube gallery plugin in the world!
165
  7. To display a YouTube feed just copy and paste the [youtube-feed] shortcode into a widget or page
166
 
167
  == Changelog ==
168
+ = 1.3 =
169
+ * New: Integrations with popular GDPR cookie consent solutions added: Cookie Notice by dFactory, GDPR Cookie Consent by WebToffee, Cookiebot by Cybot A/S, Complianz by Really Simple Plugins, and Borlabs Cookie by Borlabs. Visit the YouTube Feed settings page, Customize tab, GDPR section for more information.
170
+ * Fix: Date that video was published would not always match what was shown on YouTube.com.
171
+
172
  = 1.2.4 =
173
  * Tweak: Minor update to item.php template to accommodate dynamic title attribute in lightbox.
174
  * Tweak: Added support for improved notices on the plugin settings page.
css/admin-notifications.css CHANGED
@@ -1,171 +1,171 @@
1
- #sby-notifications {
2
- position: relative;
3
- background: #FFFFFF 0 0 no-repeat padding-box;
4
- box-shadow: 0px 5px 15px #0000000D;
5
- border-radius: 6px;
6
- opacity: 1;
7
- min-height: 48px;
8
- padding: 15px 102px 15px 72px;
9
- margin: 0 0 14px 0;
10
- }
11
-
12
- #sby-notifications * {
13
- box-sizing: border-box;
14
- }
15
-
16
- #sby-notifications .bell,
17
- #sby-notifications .thumb{
18
- position: absolute;
19
- top: 15px;
20
- left: 15px;
21
- width: 42px;
22
- height: 48px;
23
- }
24
- #sby-notifications .thumb img {
25
- max-width: 100%;
26
- }
27
- #sby-notifications .thumb .img-overlay {
28
- top: 42px;
29
- left: -6px;
30
- width: 54px;
31
- position: absolute;
32
- background: #ca4a1f;
33
- color: #fff;
34
- padding: 2px 4px;
35
- border-radius: 3px;
36
- line-height: 1;
37
- font-size: 11px;
38
- font-weight: bold;
39
- text-align: center;
40
- }
41
-
42
- #sby-notifications .messages .message {
43
- display: none;
44
- }
45
-
46
- #sby-notifications .messages .message.current {
47
- display: block;
48
- }
49
-
50
- #sby-notifications .messages .message .title {
51
- font-weight: bold;
52
- font-size: 17px;
53
- line-height: 20px;
54
- margin: 0;
55
- color: #444;
56
- }
57
-
58
- #sby-notifications .messages .message .content {
59
- font-weight: normal;
60
- font-size: 13px;
61
- line-height: 20px;
62
- margin: 6px 0 40px 0;
63
- }
64
-
65
- #sby-notifications .messages .message .buttons {
66
- margin: -30px 80px 0 0;
67
- }
68
-
69
- #sby-notifications .messages .message .buttons a {
70
- margin: 0 6px 0 0;
71
- padding: 8px 10px;
72
- line-height: 13px;
73
- font-size: 13px;
74
- min-height: unset;
75
- }
76
-
77
- #sby-notifications .messages .message .buttons .button-secondary {
78
- border: 1px solid #0071A1;
79
- }
80
-
81
- #sby-notifications .dismiss {
82
- position: absolute;
83
- top: 15px;
84
- right: 15px;
85
- width: 16px;
86
- height: 16px;
87
- color: #72777C;
88
- font-size: 16px;
89
- cursor: pointer;
90
- text-align: center;
91
- vertical-align: middle;
92
- line-height: 16px;
93
- }
94
-
95
- #sby-notifications .dismiss:hover {
96
- color: #dc3232;
97
- }
98
-
99
- #sby-notifications .navigation {
100
- position: absolute;
101
- bottom: 15px;
102
- right: 15px;
103
- width: 63px;
104
- height: 30px;
105
- }
106
-
107
- #sby-notifications .navigation a {
108
- display: block;
109
- width: 30px;
110
- height: 30px;
111
- border: 1px solid #7E8993;
112
- border-radius: 3px;
113
- font-size: 8px;
114
- text-align: center;
115
- vertical-align: middle;
116
- line-height: 30px;
117
- cursor: pointer;
118
- background-color: #ffffff;
119
- color: #41454A;
120
- }
121
- #sby-notifications .navigation svg {
122
- width: 8px;
123
- height: 8px;
124
- }
125
-
126
- #sby-notifications .navigation a:hover {
127
- background-color: #f1f1f1;
128
- }
129
-
130
- #sby-notifications .navigation .prev {
131
- float: left;
132
- }
133
-
134
- #sby-notifications .navigation .next {
135
- float: right;
136
- }
137
-
138
- #sby-notifications .navigation .disabled {
139
- border-color: #dddddd;
140
- color: #A0A5AA;
141
- cursor: default;
142
- }
143
-
144
- #sby-notifications .navigation .disabled:hover {
145
- background-color: #ffffff;
146
- }
147
-
148
- @media screen and (max-width: 768px) {
149
- #sby-notifications {
150
- padding: 15px 15px 15px 72px;
151
- }
152
- #sby-notifications .messages .message .title {
153
- margin: 0 30px 0 0;
154
- }
155
- #sby-notifications .messages .message .content {
156
- font-size: 16px;
157
- line-height: 24px;
158
- }
159
- #sby-notifications .messages .message .buttons {
160
- margin: -30px 80px 0 0;
161
- }
162
- #sby-notifications .messages .message .buttons a {
163
- margin: 0;
164
- display: table;
165
- }
166
- #sby-notifications .messages .message .buttons .button-secondary {
167
- margin-top: 6px;
168
- }
169
- }
170
-
171
- /*# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXRzL2Nzcy9hZG1pbi1ub3RpZmljYXRpb25zLmNzcyIsInNvdXJjZXMiOlsiYXNzZXRzL3Njc3MvYWRtaW4tbm90aWZpY2F0aW9ucy5zY3NzIl0sInNvdXJjZXNDb250ZW50IjpbIi8vIEFkbWluIG5vdGlmaWNhdGlvbiBzdHlsZXMuXG5cbiN3cGZvcm1zLW5vdGlmaWNhdGlvbnMge1xuXG5cdHBvc2l0aW9uOiByZWxhdGl2ZTtcblx0YmFja2dyb3VuZDogI0ZGRkZGRiAwIDAgbm8tcmVwZWF0IHBhZGRpbmctYm94O1xuXHRib3gtc2hhZG93OiAwcHggNXB4IDE1cHggIzAwMDAwMDBEO1xuXHRib3JkZXItcmFkaXVzOiA2cHg7XG5cdG9wYWNpdHk6IDE7XG5cdG1pbi1oZWlnaHQ6IDQ4cHg7XG5cdHBhZGRpbmc6IDE1cHggMTAycHggMTVweCA3MnB4O1xuXHRtYXJnaW46IDAgMCAxNHB4IDA7XG5cblx0KiB7XG5cdFx0Ym94LXNpemluZzogYm9yZGVyLWJveDtcblx0fVxuXG5cdC5iZWxsIHtcblx0XHRwb3NpdGlvbjogYWJzb2x1dGU7XG5cdFx0dG9wOiAxNXB4O1xuXHRcdGxlZnQ6IDE1cHg7XG5cdFx0d2lkdGg6IDQycHg7XG5cdFx0aGVpZ2h0OiA0OHB4O1xuXHR9XG5cblx0Lm1lc3NhZ2VzIHtcblx0XHQubWVzc2FnZSB7XG5cdFx0XHRkaXNwbGF5OiBub25lO1xuXG5cdFx0XHQmLmN1cnJlbnQge1xuXHRcdFx0XHRkaXNwbGF5OiBibG9jaztcblx0XHRcdH1cblxuXHRcdFx0LnRpdGxlIHtcblx0XHRcdFx0Zm9udC13ZWlnaHQ6IGJvbGQ7XG5cdFx0XHRcdGZvbnQtc2l6ZTogMTdweDtcblx0XHRcdFx0bGluZS1oZWlnaHQ6IDIwcHg7XG5cdFx0XHRcdG1hcmdpbjogMDtcblx0XHRcdFx0Y29sb3I6ICM0NDQ7XG5cdFx0XHR9XG5cblx0XHRcdC5jb250ZW50IHtcblx0XHRcdFx0Zm9udC13ZWlnaHQ6IG5vcm1hbDtcblx0XHRcdFx0Zm9udC1zaXplOiAxM3B4O1xuXHRcdFx0XHRsaW5lLWhlaWdodDogMjBweDtcblx0XHRcdFx0bWFyZ2luOiA2cHggMCA0MHB4IDA7XG5cdFx0XHR9XG5cblx0XHRcdC5idXR0b25zIHtcblx0XHRcdFx0bWFyZ2luOiAtMzBweCA4MHB4IDAgMDtcblxuXHRcdFx0XHRhIHtcblx0XHRcdFx0XHRtYXJnaW46IDAgNnB4IDAgMDtcblx0XHRcdFx0XHRwYWRkaW5nOiA4cHggMTBweDtcblx0XHRcdFx0XHRsaW5lLWhlaWdodDogMTNweDtcblx0XHRcdFx0XHRmb250LXNpemU6IDEzcHg7XG5cdFx0XHRcdFx0bWluLWhlaWdodDogdW5zZXQ7XG5cdFx0XHRcdH1cblxuXHRcdFx0XHQuYnV0dG9uLXNlY29uZGFyeSB7XG5cdFx0XHRcdFx0Ym9yZGVyOiAxcHggc29saWQgIzAwNzFBMTtcblx0XHRcdFx0fVxuXHRcdFx0fVxuXHRcdH1cblx0fVxuXG5cdC5kaXNtaXNzIHtcblx0XHRwb3NpdGlvbjogYWJzb2x1dGU7XG5cdFx0dG9wOiAxNXB4O1xuXHRcdHJpZ2h0OiAxNXB4O1xuXHRcdHdpZHRoOiAxNnB4O1xuXHRcdGhlaWdodDogMTZweDtcblx0XHRjb2xvcjogIzcyNzc3Qztcblx0XHRmb250LXNpemU6IDE2cHg7XG5cdFx0Y3Vyc29yOiBwb2ludGVyO1xuXHRcdHRleHQtYWxpZ246IGNlbnRlcjtcblx0XHR2ZXJ0aWNhbC1hbGlnbjogbWlkZGxlO1xuXHRcdGxpbmUtaGVpZ2h0OiAxNnB4O1xuXG5cdFx0Jjpob3ZlciB7XG5cdFx0XHRjb2xvcjogI2RjMzIzMjtcblx0XHR9XG5cdH1cblxuXHQubmF2aWdhdGlvbiB7XG5cdFx0cG9zaXRpb246IGFic29sdXRlO1xuXHRcdGJvdHRvbTogMTVweDtcblx0XHRyaWdodDogMTVweDtcblx0XHR3aWR0aDogNjNweDtcblx0XHRoZWlnaHQ6IDMwcHg7XG5cblx0XHRhIHtcblx0XHRcdGRpc3BsYXk6IGJsb2NrO1xuXHRcdFx0d2lkdGg6IDMwcHg7XG5cdFx0XHRoZWlnaHQ6IDMwcHg7XG5cdFx0XHRib3JkZXI6IDFweCBzb2xpZCAjN0U4OTkzO1xuXHRcdFx0Ym9yZGVyLXJhZGl1czogM3B4O1xuXHRcdFx0Zm9udC1zaXplOiA4cHg7XG5cdFx0XHR0ZXh0LWFsaWduOiBjZW50ZXI7XG5cdFx0XHR2ZXJ0aWNhbC1hbGlnbjogbWlkZGxlO1xuXHRcdFx0bGluZS1oZWlnaHQ6IDMwcHg7XG5cdFx0XHRjdXJzb3I6IHBvaW50ZXI7XG5cdFx0XHRiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmZmZmO1xuXHRcdFx0Y29sb3I6ICM0MTQ1NEE7XG5cblx0XHRcdCY6aG92ZXIge1xuXHRcdFx0XHRiYWNrZ3JvdW5kLWNvbG9yOiAjZjFmMWYxO1xuXHRcdFx0fVxuXHRcdH1cblxuXHRcdC5wcmV2IHtcblx0XHRcdGZsb2F0OiBsZWZ0O1xuXHRcdH1cblxuXHRcdC5uZXh0IHtcblx0XHRcdGZsb2F0OiByaWdodDtcblx0XHR9XG5cblx0XHQuZGlzYWJsZWQge1xuXHRcdFx0Ym9yZGVyLWNvbG9yOiAjZGRkZGRkO1xuXHRcdFx0Y29sb3I6ICNBMEE1QUE7XG5cdFx0XHRjdXJzb3I6IGRlZmF1bHQ7XG5cblx0XHRcdCY6aG92ZXIge1xuXHRcdFx0XHRiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmZmZmO1xuXHRcdFx0fVxuXHRcdH1cblx0fVxufVxuXG5AbWVkaWEgc2NyZWVuIGFuZCAobWF4LXdpZHRoOiA3NjhweCkge1xuXG5cdCN3cGZvcm1zLW5vdGlmaWNhdGlvbnMge1xuXHRcdHBhZGRpbmc6IDE1cHggMTVweCAxNXB4IDcycHg7XG5cblx0XHQubWVzc2FnZXMge1xuXG5cdFx0XHQubWVzc2FnZSB7XG5cblx0XHRcdFx0LnRpdGxlIHtcblx0XHRcdFx0XHRtYXJnaW46IDAgMzBweCAwIDA7XG5cdFx0XHRcdH1cblxuXHRcdFx0XHQuY29udGVudCB7XG5cdFx0XHRcdFx0Zm9udC1zaXplOiAxNnB4O1xuXHRcdFx0XHRcdGxpbmUtaGVpZ2h0OiAyNHB4XG5cdFx0XHRcdH1cblxuXHRcdFx0XHQuYnV0dG9ucyB7XG5cdFx0XHRcdFx0bWFyZ2luOiAtMzBweCA4MHB4IDAgMDtcblxuXHRcdFx0XHRcdGEge1xuXHRcdFx0XHRcdFx0bWFyZ2luOiAwO1xuXHRcdFx0XHRcdFx0ZGlzcGxheTogdGFibGU7XG5cdFx0XHRcdFx0fVxuXG5cdFx0XHRcdFx0LmJ1dHRvbi1zZWNvbmRhcnkge1xuXHRcdFx0XHRcdFx0bWFyZ2luLXRvcDogNnB4O1xuXHRcdFx0XHRcdH1cblx0XHRcdFx0fVxuXHRcdFx0fVxuXHRcdH1cblx0fVxufSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxBQUFBLHNCQUFzQixDQUFDO0VBRXRCLFFBQVEsRUFBRSxRQUFRO0VBQ2xCLFVBQVUsRUFBRSxpQ0FBaUM7RUFDN0MsVUFBVSxFQUFFLHNCQUFzQjtFQUNsQyxhQUFhLEVBQUUsR0FBRztFQUNsQixPQUFPLEVBQUUsQ0FBQztFQUNWLFVBQVUsRUFBRSxJQUFJO0VBQ2hCLE9BQU8sRUFBRSxvQkFBb0I7RUFDN0IsTUFBTSxFQUFFLFVBQVU7Q0FxSGxCOztBQTlIRCxBQVdDLHNCQVhxQixDQVdyQixDQUFDLENBQUM7RUFDRCxVQUFVLEVBQUUsVUFBVTtDQUN0Qjs7QUFiRixBQWVDLHNCQWZxQixDQWVyQixLQUFLLENBQUM7RUFDTCxRQUFRLEVBQUUsUUFBUTtFQUNsQixHQUFHLEVBQUUsSUFBSTtFQUNULElBQUksRUFBRSxJQUFJO0VBQ1YsS0FBSyxFQUFFLElBQUk7RUFDWCxNQUFNLEVBQUUsSUFBSTtDQUNaOztBQXJCRixBQXdCRSxzQkF4Qm9CLENBdUJyQixTQUFTLENBQ1IsUUFBUSxDQUFDO0VBQ1IsT0FBTyxFQUFFLElBQUk7Q0FvQ2I7O0FBN0RILEFBMkJHLHNCQTNCbUIsQ0F1QnJCLFNBQVMsQ0FDUixRQUFRLEFBR04sUUFBUSxDQUFDO0VBQ1QsT0FBTyxFQUFFLEtBQUs7Q0FDZDs7QUE3QkosQUErQkcsc0JBL0JtQixDQXVCckIsU0FBUyxDQUNSLFFBQVEsQ0FPUCxNQUFNLENBQUM7RUFDTixXQUFXLEVBQUUsSUFBSTtFQUNqQixTQUFTLEVBQUUsSUFBSTtFQUNmLFdBQVcsRUFBRSxJQUFJO0VBQ2pCLE1BQU0sRUFBRSxDQUFDO0VBQ1QsS0FBSyxFQUFFLElBQUk7Q0FDWDs7QUFyQ0osQUF1Q0csc0JBdkNtQixDQXVCckIsU0FBUyxDQUNSLFFBQVEsQ0FlUCxRQUFRLENBQUM7RUFDUixXQUFXLEVBQUUsTUFBTTtFQUNuQixTQUFTLEVBQUUsSUFBSTtFQUNmLFdBQVcsRUFBRSxJQUFJO0VBQ2pCLE1BQU0sRUFBRSxZQUFZO0NBQ3BCOztBQTVDSixBQThDRyxzQkE5Q21CLENBdUJyQixTQUFTLENBQ1IsUUFBUSxDQXNCUCxRQUFRLENBQUM7RUFDUixNQUFNLEVBQUUsY0FBYztDQWF0Qjs7QUE1REosQUFpREksc0JBakRrQixDQXVCckIsU0FBUyxDQUNSLFFBQVEsQ0FzQlAsUUFBUSxDQUdQLENBQUMsQ0FBQztFQUNELE1BQU0sRUFBRSxTQUFTO0VBQ2pCLE9BQU8sRUFBRSxRQUFRO0VBQ2pCLFdBQVcsRUFBRSxJQUFJO0VBQ2pCLFNBQVMsRUFBRSxJQUFJO0VBQ2YsVUFBVSxFQUFFLEtBQUs7Q0FDakI7O0FBdkRMLEFBeURJLHNCQXpEa0IsQ0F1QnJCLFNBQVMsQ0FDUixRQUFRLENBc0JQLFFBQVEsQ0FXUCxpQkFBaUIsQ0FBQztFQUNqQixNQUFNLEVBQUUsaUJBQWlCO0NBQ3pCOztBQTNETCxBQWdFQyxzQkFoRXFCLENBZ0VyQixRQUFRLENBQUM7RUFDUixRQUFRLEVBQUUsUUFBUTtFQUNsQixHQUFHLEVBQUUsSUFBSTtFQUNULEtBQUssRUFBRSxJQUFJO0VBQ1gsS0FBSyxFQUFFLElBQUk7RUFDWCxNQUFNLEVBQUUsSUFBSTtFQUNaLEtBQUssRUFBRSxPQUFPO0VBQ2QsU0FBUyxFQUFFLElBQUk7RUFDZixNQUFNLEVBQUUsT0FBTztFQUNmLFVBQVUsRUFBRSxNQUFNO0VBQ2xCLGNBQWMsRUFBRSxNQUFNO0VBQ3RCLFdBQVcsRUFBRSxJQUFJO0NBS2pCOztBQWhGRixBQTZFRSxzQkE3RW9CLENBZ0VyQixRQUFRLEFBYU4sTUFBTSxDQUFDO0VBQ1AsS0FBSyxFQUFFLE9BQU87Q0FDZDs7QUEvRUgsQUFrRkMsc0JBbEZxQixDQWtGckIsV0FBVyxDQUFDO0VBQ1gsUUFBUSxFQUFFLFFBQVE7RUFDbEIsTUFBTSxFQUFFLElBQUk7RUFDWixLQUFLLEVBQUUsSUFBSTtFQUNYLEtBQUssRUFBRSxJQUFJO0VBQ1gsTUFBTSxFQUFFLElBQUk7Q0FzQ1o7O0FBN0hGLEFBeUZFLHNCQXpGb0IsQ0FrRnJCLFdBQVcsQ0FPVixDQUFDLENBQUM7RUFDRCxPQUFPLEVBQUUsS0FBSztFQUNkLEtBQUssRUFBRSxJQUFJO0VBQ1gsTUFBTSxFQUFFLElBQUk7RUFDWixNQUFNLEVBQUUsaUJBQWlCO0VBQ3pCLGFBQWEsRUFBRSxHQUFHO0VBQ2xCLFNBQVMsRUFBRSxHQUFHO0VBQ2QsVUFBVSxFQUFFLE1BQU07RUFDbEIsY0FBYyxFQUFFLE1BQU07RUFDdEIsV0FBVyxFQUFFLElBQUk7RUFDakIsTUFBTSxFQUFFLE9BQU87RUFDZixnQkFBZ0IsRUFBRSxPQUFPO0VBQ3pCLEtBQUssRUFBRSxPQUFPO0NBS2Q7O0FBMUdILEFBdUdHLHNCQXZHbUIsQ0FrRnJCLFdBQVcsQ0FPVixDQUFDLEFBY0MsTUFBTSxDQUFDO0VBQ1AsZ0JBQWdCLEVBQUUsT0FBTztDQUN6Qjs7QUF6R0osQUE0R0Usc0JBNUdvQixDQWtGckIsV0FBVyxDQTBCVixLQUFLLENBQUM7RUFDTCxLQUFLLEVBQUUsSUFBSTtDQUNYOztBQTlHSCxBQWdIRSxzQkFoSG9CLENBa0ZyQixXQUFXLENBOEJWLEtBQUssQ0FBQztFQUNMLEtBQUssRUFBRSxLQUFLO0NBQ1o7O0FBbEhILEFBb0hFLHNCQXBIb0IsQ0FrRnJCLFdBQVcsQ0FrQ1YsU0FBUyxDQUFDO0VBQ1QsWUFBWSxFQUFFLE9BQU87RUFDckIsS0FBSyxFQUFFLE9BQU87RUFDZCxNQUFNLEVBQUUsT0FBTztDQUtmOztBQTVISCxBQXlIRyxzQkF6SG1CLENBa0ZyQixXQUFXLENBa0NWLFNBQVMsQUFLUCxNQUFNLENBQUM7RUFDUCxnQkFBZ0IsRUFBRSxPQUFPO0NBQ3pCOztBQUtKLE1BQU0sQ0FBQyxNQUFNLE1BQU0sU0FBUyxFQUFFLEtBQUs7RUFFbEMsQUFBQSxzQkFBc0IsQ0FBQztJQUN0QixPQUFPLEVBQUUsbUJBQW1CO0dBNkI1QjtFQTlCRCxBQU9HLHNCQVBtQixDQUdyQixTQUFTLENBRVIsUUFBUSxDQUVQLE1BQU0sQ0FBQztJQUNOLE1BQU0sRUFBRSxVQUFVO0dBQ2xCO0VBVEosQUFXRyxzQkFYbUIsQ0FHckIsU0FBUyxDQUVSLFFBQVEsQ0FNUCxRQUFRLENBQUM7SUFDUixTQUFTLEVBQUUsSUFBSTtJQUNmLFdBQVcsRUFBRSxJQUNkO0dBQUM7RUFkSixBQWdCRyxzQkFoQm1CLENBR3JCLFNBQVMsQ0FFUixRQUFRLENBV1AsUUFBUSxDQUFDO0lBQ1IsTUFBTSxFQUFFLGNBQWM7R0FVdEI7RUEzQkosQUFtQkksc0JBbkJrQixDQUdyQixTQUFTLENBRVIsUUFBUSxDQVdQLFFBQVEsQ0FHUCxDQUFDLENBQUM7SUFDRCxNQUFNLEVBQUUsQ0FBQztJQUNULE9BQU8sRUFBRSxLQUFLO0dBQ2Q7RUF0QkwsQUF3Qkksc0JBeEJrQixDQUdyQixTQUFTLENBRVIsUUFBUSxDQVdQLFFBQVEsQ0FRUCxpQkFBaUIsQ0FBQztJQUNqQixVQUFVLEVBQUUsR0FBRztHQUNmIn0= */
1
+ #sby-notifications {
2
+ position: relative;
3
+ background: #FFFFFF 0 0 no-repeat padding-box;
4
+ box-shadow: 0px 5px 15px #0000000D;
5
+ border-radius: 6px;
6
+ opacity: 1;
7
+ min-height: 48px;
8
+ padding: 15px 102px 15px 72px;
9
+ margin: 0 0 14px 0;
10
+ }
11
+
12
+ #sby-notifications * {
13
+ box-sizing: border-box;
14
+ }
15
+
16
+ #sby-notifications .bell,
17
+ #sby-notifications .thumb{
18
+ position: absolute;
19
+ top: 15px;
20
+ left: 15px;
21
+ width: 42px;
22
+ height: 48px;
23
+ }
24
+ #sby-notifications .thumb img {
25
+ max-width: 100%;
26
+ }
27
+ #sby-notifications .thumb .img-overlay {
28
+ top: 42px;
29
+ left: -6px;
30
+ width: 54px;
31
+ position: absolute;
32
+ background: #ca4a1f;
33
+ color: #fff;
34
+ padding: 2px 4px;
35
+ border-radius: 3px;
36
+ line-height: 1;
37
+ font-size: 11px;
38
+ font-weight: bold;
39
+ text-align: center;
40
+ }
41
+
42
+ #sby-notifications .messages .message {
43
+ display: none;
44
+ }
45
+
46
+ #sby-notifications .messages .message.current {
47
+ display: block;
48
+ }
49
+
50
+ #sby-notifications .messages .message .title {
51
+ font-weight: bold;
52
+ font-size: 17px;
53
+ line-height: 20px;
54
+ margin: 0;
55
+ color: #444;
56
+ }
57
+
58
+ #sby-notifications .messages .message .content {
59
+ font-weight: normal;
60
+ font-size: 13px;
61
+ line-height: 20px;
62
+ margin: 6px 0 40px 0;
63
+ }
64
+
65
+ #sby-notifications .messages .message .buttons {
66
+ margin: -30px 80px 0 0;
67
+ }
68
+
69
+ #sby-notifications .messages .message .buttons a {
70
+ margin: 0 6px 0 0;
71
+ padding: 8px 10px;
72
+ line-height: 13px;
73
+ font-size: 13px;
74
+ min-height: unset;
75
+ }
76
+
77
+ #sby-notifications .messages .message .buttons .button-secondary {
78
+ border: 1px solid #0071A1;
79
+ }
80
+
81
+ #sby-notifications .dismiss {
82
+ position: absolute;
83
+ top: 15px;
84
+ right: 15px;
85
+ width: 16px;
86
+ height: 16px;
87
+ color: #72777C;
88
+ font-size: 16px;
89
+ cursor: pointer;
90
+ text-align: center;
91
+ vertical-align: middle;
92
+ line-height: 16px;
93
+ }
94
+
95
+ #sby-notifications .dismiss:hover {
96
+ color: #dc3232;
97
+ }
98
+
99
+ #sby-notifications .navigation {
100
+ position: absolute;
101
+ bottom: 15px;
102
+ right: 15px;
103
+ width: 63px;
104
+ height: 30px;
105
+ }
106
+
107
+ #sby-notifications .navigation a {
108
+ display: block;
109
+ width: 30px;
110
+ height: 30px;
111
+ border: 1px solid #7E8993;
112
+ border-radius: 3px;
113
+ font-size: 8px;
114
+ text-align: center;
115
+ vertical-align: middle;
116
+ line-height: 30px;
117
+ cursor: pointer;
118
+ background-color: #ffffff;
119
+ color: #41454A;
120
+ }
121
+ #sby-notifications .navigation svg {
122
+ width: 8px;
123
+ height: 8px;
124
+ }
125
+
126
+ #sby-notifications .navigation a:hover {
127
+ background-color: #f1f1f1;
128
+ }
129
+
130
+ #sby-notifications .navigation .prev {
131
+ float: left;
132
+ }
133
+
134
+ #sby-notifications .navigation .next {
135
+ float: right;
136
+ }
137
+
138
+ #sby-notifications .navigation .disabled {
139
+ border-color: #dddddd;
140
+ color: #A0A5AA;
141
+ cursor: default;
142
+ }
143
+
144
+ #sby-notifications .navigation .disabled:hover {
145
+ background-color: #ffffff;
146
+ }
147
+
148
+ @media screen and (max-width: 768px) {
149
+ #sby-notifications {
150
+ padding: 15px 15px 15px 72px;
151
+ }
152
+ #sby-notifications .messages .message .title {
153
+ margin: 0 30px 0 0;
154
+ }
155
+ #sby-notifications .messages .message .content {
156
+ font-size: 16px;
157
+ line-height: 24px;
158
+ }
159
+ #sby-notifications .messages .message .buttons {
160
+ margin: -30px 80px 0 0;
161
+ }
162
+ #sby-notifications .messages .message .buttons a {
163
+ margin: 0;
164
+ display: table;
165
+ }
166
+ #sby-notifications .messages .message .buttons .button-secondary {
167
+ margin-top: 6px;
168
+ }
169
+ }
170
+
171
+ /*# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNzZXRzL2Nzcy9hZG1pbi1ub3RpZmljYXRpb25zLmNzcyIsInNvdXJjZXMiOlsiYXNzZXRzL3Njc3MvYWRtaW4tbm90aWZpY2F0aW9ucy5zY3NzIl0sInNvdXJjZXNDb250ZW50IjpbIi8vIEFkbWluIG5vdGlmaWNhdGlvbiBzdHlsZXMuXG5cbiN3cGZvcm1zLW5vdGlmaWNhdGlvbnMge1xuXG5cdHBvc2l0aW9uOiByZWxhdGl2ZTtcblx0YmFja2dyb3VuZDogI0ZGRkZGRiAwIDAgbm8tcmVwZWF0IHBhZGRpbmctYm94O1xuXHRib3gtc2hhZG93OiAwcHggNXB4IDE1cHggIzAwMDAwMDBEO1xuXHRib3JkZXItcmFkaXVzOiA2cHg7XG5cdG9wYWNpdHk6IDE7XG5cdG1pbi1oZWlnaHQ6IDQ4cHg7XG5cdHBhZGRpbmc6IDE1cHggMTAycHggMTVweCA3MnB4O1xuXHRtYXJnaW46IDAgMCAxNHB4IDA7XG5cblx0KiB7XG5cdFx0Ym94LXNpemluZzogYm9yZGVyLWJveDtcblx0fVxuXG5cdC5iZWxsIHtcblx0XHRwb3NpdGlvbjogYWJzb2x1dGU7XG5cdFx0dG9wOiAxNXB4O1xuXHRcdGxlZnQ6IDE1cHg7XG5cdFx0d2lkdGg6IDQycHg7XG5cdFx0aGVpZ2h0OiA0OHB4O1xuXHR9XG5cblx0Lm1lc3NhZ2VzIHtcblx0XHQubWVzc2FnZSB7XG5cdFx0XHRkaXNwbGF5OiBub25lO1xuXG5cdFx0XHQmLmN1cnJlbnQge1xuXHRcdFx0XHRkaXNwbGF5OiBibG9jaztcblx0XHRcdH1cblxuXHRcdFx0LnRpdGxlIHtcblx0XHRcdFx0Zm9udC13ZWlnaHQ6IGJvbGQ7XG5cdFx0XHRcdGZvbnQtc2l6ZTogMTdweDtcblx0XHRcdFx0bGluZS1oZWlnaHQ6IDIwcHg7XG5cdFx0XHRcdG1hcmdpbjogMDtcblx0XHRcdFx0Y29sb3I6ICM0NDQ7XG5cdFx0XHR9XG5cblx0XHRcdC5jb250ZW50IHtcblx0XHRcdFx0Zm9udC13ZWlnaHQ6IG5vcm1hbDtcblx0XHRcdFx0Zm9udC1zaXplOiAxM3B4O1xuXHRcdFx0XHRsaW5lLWhlaWdodDogMjBweDtcblx0XHRcdFx0bWFyZ2luOiA2cHggMCA0MHB4IDA7XG5cdFx0XHR9XG5cblx0XHRcdC5idXR0b25zIHtcblx0XHRcdFx0bWFyZ2luOiAtMzBweCA4MHB4IDAgMDtcblxuXHRcdFx0XHRhIHtcblx0XHRcdFx0XHRtYXJnaW46IDAgNnB4IDAgMDtcblx0XHRcdFx0XHRwYWRkaW5nOiA4cHggMTBweDtcblx0XHRcdFx0XHRsaW5lLWhlaWdodDogMTNweDtcblx0XHRcdFx0XHRmb250LXNpemU6IDEzcHg7XG5cdFx0XHRcdFx0bWluLWhlaWdodDogdW5zZXQ7XG5cdFx0XHRcdH1cblxuXHRcdFx0XHQuYnV0dG9uLXNlY29uZGFyeSB7XG5cdFx0XHRcdFx0Ym9yZGVyOiAxcHggc29saWQgIzAwNzFBMTtcblx0XHRcdFx0fVxuXHRcdFx0fVxuXHRcdH1cblx0fVxuXG5cdC5kaXNtaXNzIHtcblx0XHRwb3NpdGlvbjogYWJzb2x1dGU7XG5cdFx0dG9wOiAxNXB4O1xuXHRcdHJpZ2h0OiAxNXB4O1xuXHRcdHdpZHRoOiAxNnB4O1xuXHRcdGhlaWdodDogMTZweDtcblx0XHRjb2xvcjogIzcyNzc3Qztcblx0XHRmb250LXNpemU6IDE2cHg7XG5cdFx0Y3Vyc29yOiBwb2ludGVyO1xuXHRcdHRleHQtYWxpZ246IGNlbnRlcjtcblx0XHR2ZXJ0aWNhbC1hbGlnbjogbWlkZGxlO1xuXHRcdGxpbmUtaGVpZ2h0OiAxNnB4O1xuXG5cdFx0Jjpob3ZlciB7XG5cdFx0XHRjb2xvcjogI2RjMzIzMjtcblx0XHR9XG5cdH1cblxuXHQubmF2aWdhdGlvbiB7XG5cdFx0cG9zaXRpb246IGFic29sdXRlO1xuXHRcdGJvdHRvbTogMTVweDtcblx0XHRyaWdodDogMTVweDtcblx0XHR3aWR0aDogNjNweDtcblx0XHRoZWlnaHQ6IDMwcHg7XG5cblx0XHRhIHtcblx0XHRcdGRpc3BsYXk6IGJsb2NrO1xuXHRcdFx0d2lkdGg6IDMwcHg7XG5cdFx0XHRoZWlnaHQ6IDMwcHg7XG5cdFx0XHRib3JkZXI6IDFweCBzb2xpZCAjN0U4OTkzO1xuXHRcdFx0Ym9yZGVyLXJhZGl1czogM3B4O1xuXHRcdFx0Zm9udC1zaXplOiA4cHg7XG5cdFx0XHR0ZXh0LWFsaWduOiBjZW50ZXI7XG5cdFx0XHR2ZXJ0aWNhbC1hbGlnbjogbWlkZGxlO1xuXHRcdFx0bGluZS1oZWlnaHQ6IDMwcHg7XG5cdFx0XHRjdXJzb3I6IHBvaW50ZXI7XG5cdFx0XHRiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmZmZmO1xuXHRcdFx0Y29sb3I6ICM0MTQ1NEE7XG5cblx0XHRcdCY6aG92ZXIge1xuXHRcdFx0XHRiYWNrZ3JvdW5kLWNvbG9yOiAjZjFmMWYxO1xuXHRcdFx0fVxuXHRcdH1cblxuXHRcdC5wcmV2IHtcblx0XHRcdGZsb2F0OiBsZWZ0O1xuXHRcdH1cblxuXHRcdC5uZXh0IHtcblx0XHRcdGZsb2F0OiByaWdodDtcblx0XHR9XG5cblx0XHQuZGlzYWJsZWQge1xuXHRcdFx0Ym9yZGVyLWNvbG9yOiAjZGRkZGRkO1xuXHRcdFx0Y29sb3I6ICNBMEE1QUE7XG5cdFx0XHRjdXJzb3I6IGRlZmF1bHQ7XG5cblx0XHRcdCY6aG92ZXIge1xuXHRcdFx0XHRiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmZmZmO1xuXHRcdFx0fVxuXHRcdH1cblx0fVxufVxuXG5AbWVkaWEgc2NyZWVuIGFuZCAobWF4LXdpZHRoOiA3NjhweCkge1xuXG5cdCN3cGZvcm1zLW5vdGlmaWNhdGlvbnMge1xuXHRcdHBhZGRpbmc6IDE1cHggMTVweCAxNXB4IDcycHg7XG5cblx0XHQubWVzc2FnZXMge1xuXG5cdFx0XHQubWVzc2FnZSB7XG5cblx0XHRcdFx0LnRpdGxlIHtcblx0XHRcdFx0XHRtYXJnaW46IDAgMzBweCAwIDA7XG5cdFx0XHRcdH1cblxuXHRcdFx0XHQuY29udGVudCB7XG5cdFx0XHRcdFx0Zm9udC1zaXplOiAxNnB4O1xuXHRcdFx0XHRcdGxpbmUtaGVpZ2h0OiAyNHB4XG5cdFx0XHRcdH1cblxuXHRcdFx0XHQuYnV0dG9ucyB7XG5cdFx0XHRcdFx0bWFyZ2luOiAtMzBweCA4MHB4IDAgMDtcblxuXHRcdFx0XHRcdGEge1xuXHRcdFx0XHRcdFx0bWFyZ2luOiAwO1xuXHRcdFx0XHRcdFx0ZGlzcGxheTogdGFibGU7XG5cdFx0XHRcdFx0fVxuXG5cdFx0XHRcdFx0LmJ1dHRvbi1zZWNvbmRhcnkge1xuXHRcdFx0XHRcdFx0bWFyZ2luLXRvcDogNnB4O1xuXHRcdFx0XHRcdH1cblx0XHRcdFx0fVxuXHRcdFx0fVxuXHRcdH1cblx0fVxufSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxBQUFBLHNCQUFzQixDQUFDO0VBRXRCLFFBQVEsRUFBRSxRQUFRO0VBQ2xCLFVBQVUsRUFBRSxpQ0FBaUM7RUFDN0MsVUFBVSxFQUFFLHNCQUFzQjtFQUNsQyxhQUFhLEVBQUUsR0FBRztFQUNsQixPQUFPLEVBQUUsQ0FBQztFQUNWLFVBQVUsRUFBRSxJQUFJO0VBQ2hCLE9BQU8sRUFBRSxvQkFBb0I7RUFDN0IsTUFBTSxFQUFFLFVBQVU7Q0FxSGxCOztBQTlIRCxBQVdDLHNCQVhxQixDQVdyQixDQUFDLENBQUM7RUFDRCxVQUFVLEVBQUUsVUFBVTtDQUN0Qjs7QUFiRixBQWVDLHNCQWZxQixDQWVyQixLQUFLLENBQUM7RUFDTCxRQUFRLEVBQUUsUUFBUTtFQUNsQixHQUFHLEVBQUUsSUFBSTtFQUNULElBQUksRUFBRSxJQUFJO0VBQ1YsS0FBSyxFQUFFLElBQUk7RUFDWCxNQUFNLEVBQUUsSUFBSTtDQUNaOztBQXJCRixBQXdCRSxzQkF4Qm9CLENBdUJyQixTQUFTLENBQ1IsUUFBUSxDQUFDO0VBQ1IsT0FBTyxFQUFFLElBQUk7Q0FvQ2I7O0FBN0RILEFBMkJHLHNCQTNCbUIsQ0F1QnJCLFNBQVMsQ0FDUixRQUFRLEFBR04sUUFBUSxDQUFDO0VBQ1QsT0FBTyxFQUFFLEtBQUs7Q0FDZDs7QUE3QkosQUErQkcsc0JBL0JtQixDQXVCckIsU0FBUyxDQUNSLFFBQVEsQ0FPUCxNQUFNLENBQUM7RUFDTixXQUFXLEVBQUUsSUFBSTtFQUNqQixTQUFTLEVBQUUsSUFBSTtFQUNmLFdBQVcsRUFBRSxJQUFJO0VBQ2pCLE1BQU0sRUFBRSxDQUFDO0VBQ1QsS0FBSyxFQUFFLElBQUk7Q0FDWDs7QUFyQ0osQUF1Q0csc0JBdkNtQixDQXVCckIsU0FBUyxDQUNSLFFBQVEsQ0FlUCxRQUFRLENBQUM7RUFDUixXQUFXLEVBQUUsTUFBTTtFQUNuQixTQUFTLEVBQUUsSUFBSTtFQUNmLFdBQVcsRUFBRSxJQUFJO0VBQ2pCLE1BQU0sRUFBRSxZQUFZO0NBQ3BCOztBQTVDSixBQThDRyxzQkE5Q21CLENBdUJyQixTQUFTLENBQ1IsUUFBUSxDQXNCUCxRQUFRLENBQUM7RUFDUixNQUFNLEVBQUUsY0FBYztDQWF0Qjs7QUE1REosQUFpREksc0JBakRrQixDQXVCckIsU0FBUyxDQUNSLFFBQVEsQ0FzQlAsUUFBUSxDQUdQLENBQUMsQ0FBQztFQUNELE1BQU0sRUFBRSxTQUFTO0VBQ2pCLE9BQU8sRUFBRSxRQUFRO0VBQ2pCLFdBQVcsRUFBRSxJQUFJO0VBQ2pCLFNBQVMsRUFBRSxJQUFJO0VBQ2YsVUFBVSxFQUFFLEtBQUs7Q0FDakI7O0FBdkRMLEFBeURJLHNCQXpEa0IsQ0F1QnJCLFNBQVMsQ0FDUixRQUFRLENBc0JQLFFBQVEsQ0FXUCxpQkFBaUIsQ0FBQztFQUNqQixNQUFNLEVBQUUsaUJBQWlCO0NBQ3pCOztBQTNETCxBQWdFQyxzQkFoRXFCLENBZ0VyQixRQUFRLENBQUM7RUFDUixRQUFRLEVBQUUsUUFBUTtFQUNsQixHQUFHLEVBQUUsSUFBSTtFQUNULEtBQUssRUFBRSxJQUFJO0VBQ1gsS0FBSyxFQUFFLElBQUk7RUFDWCxNQUFNLEVBQUUsSUFBSTtFQUNaLEtBQUssRUFBRSxPQUFPO0VBQ2QsU0FBUyxFQUFFLElBQUk7RUFDZixNQUFNLEVBQUUsT0FBTztFQUNmLFVBQVUsRUFBRSxNQUFNO0VBQ2xCLGNBQWMsRUFBRSxNQUFNO0VBQ3RCLFdBQVcsRUFBRSxJQUFJO0NBS2pCOztBQWhGRixBQTZFRSxzQkE3RW9CLENBZ0VyQixRQUFRLEFBYU4sTUFBTSxDQUFDO0VBQ1AsS0FBSyxFQUFFLE9BQU87Q0FDZDs7QUEvRUgsQUFrRkMsc0JBbEZxQixDQWtGckIsV0FBVyxDQUFDO0VBQ1gsUUFBUSxFQUFFLFFBQVE7RUFDbEIsTUFBTSxFQUFFLElBQUk7RUFDWixLQUFLLEVBQUUsSUFBSTtFQUNYLEtBQUssRUFBRSxJQUFJO0VBQ1gsTUFBTSxFQUFFLElBQUk7Q0FzQ1o7O0FBN0hGLEFBeUZFLHNCQXpGb0IsQ0FrRnJCLFdBQVcsQ0FPVixDQUFDLENBQUM7RUFDRCxPQUFPLEVBQUUsS0FBSztFQUNkLEtBQUssRUFBRSxJQUFJO0VBQ1gsTUFBTSxFQUFFLElBQUk7RUFDWixNQUFNLEVBQUUsaUJBQWlCO0VBQ3pCLGFBQWEsRUFBRSxHQUFHO0VBQ2xCLFNBQVMsRUFBRSxHQUFHO0VBQ2QsVUFBVSxFQUFFLE1BQU07RUFDbEIsY0FBYyxFQUFFLE1BQU07RUFDdEIsV0FBVyxFQUFFLElBQUk7RUFDakIsTUFBTSxFQUFFLE9BQU87RUFDZixnQkFBZ0IsRUFBRSxPQUFPO0VBQ3pCLEtBQUssRUFBRSxPQUFPO0NBS2Q7O0FBMUdILEFBdUdHLHNCQXZHbUIsQ0FrRnJCLFdBQVcsQ0FPVixDQUFDLEFBY0MsTUFBTSxDQUFDO0VBQ1AsZ0JBQWdCLEVBQUUsT0FBTztDQUN6Qjs7QUF6R0osQUE0R0Usc0JBNUdvQixDQWtGckIsV0FBVyxDQTBCVixLQUFLLENBQUM7RUFDTCxLQUFLLEVBQUUsSUFBSTtDQUNYOztBQTlHSCxBQWdIRSxzQkFoSG9CLENBa0ZyQixXQUFXLENBOEJWLEtBQUssQ0FBQztFQUNMLEtBQUssRUFBRSxLQUFLO0NBQ1o7O0FBbEhILEFBb0hFLHNCQXBIb0IsQ0FrRnJCLFdBQVcsQ0FrQ1YsU0FBUyxDQUFDO0VBQ1QsWUFBWSxFQUFFLE9BQU87RUFDckIsS0FBSyxFQUFFLE9BQU87RUFDZCxNQUFNLEVBQUUsT0FBTztDQUtmOztBQTVISCxBQXlIRyxzQkF6SG1CLENBa0ZyQixXQUFXLENBa0NWLFNBQVMsQUFLUCxNQUFNLENBQUM7RUFDUCxnQkFBZ0IsRUFBRSxPQUFPO0NBQ3pCOztBQUtKLE1BQU0sQ0FBQyxNQUFNLE1BQU0sU0FBUyxFQUFFLEtBQUs7RUFFbEMsQUFBQSxzQkFBc0IsQ0FBQztJQUN0QixPQUFPLEVBQUUsbUJBQW1CO0dBNkI1QjtFQTlCRCxBQU9HLHNCQVBtQixDQUdyQixTQUFTLENBRVIsUUFBUSxDQUVQLE1BQU0sQ0FBQztJQUNOLE1BQU0sRUFBRSxVQUFVO0dBQ2xCO0VBVEosQUFXRyxzQkFYbUIsQ0FHckIsU0FBUyxDQUVSLFFBQVEsQ0FNUCxRQUFRLENBQUM7SUFDUixTQUFTLEVBQUUsSUFBSTtJQUNmLFdBQVcsRUFBRSxJQUNkO0dBQUM7RUFkSixBQWdCRyxzQkFoQm1CLENBR3JCLFNBQVMsQ0FFUixRQUFRLENBV1AsUUFBUSxDQUFDO0lBQ1IsTUFBTSxFQUFFLGNBQWM7R0FVdEI7RUEzQkosQUFtQkksc0JBbkJrQixDQUdyQixTQUFTLENBRVIsUUFBUSxDQVdQLFFBQVEsQ0FHUCxDQUFDLENBQUM7SUFDRCxNQUFNLEVBQUUsQ0FBQztJQUNULE9BQU8sRUFBRSxLQUFLO0dBQ2Q7RUF0QkwsQUF3Qkksc0JBeEJrQixDQUdyQixTQUFTLENBRVIsUUFBUSxDQVdQLFFBQVEsQ0FRUCxpQkFBaUIsQ0FBQztJQUNqQixVQUFVLEVBQUUsR0FBRztHQUNmIn0= */
css/admin.css CHANGED
@@ -1,1083 +1,1153 @@
1
- #sbspf_admin h2{
2
- padding: 15px 0 0 0;
3
- clear: both;
4
- }
5
- #sbspf_admin hr {
6
- border: none;
7
- margin: 15px 0;
8
- border-bottom: 1px solid #ccc;
9
- }
10
- #sbspf_admin .sbspf_spinner {
11
- float: none;
12
- }
13
- #sbspf_admin .sbspf_success {
14
- display: inline-block;
15
- position: relative;
16
- margin: 4px 12px 0;
17
- }
18
- #sbspf_admin .sbspf_success svg {
19
- vertical-align: bottom;
20
- width: 16px;
21
- color: #7ad03a;
22
- }
23
- #sbspf_admin .sbspf_fade {
24
- opacity: .6;
25
- }
26
- #sbspf_admin .sbspf_aside {
27
- font-style: italic;
28
- font-weight: normal;
29
- font-size: 12px;
30
- margin: .3em 0;
31
- }
32
- #sbspf_admin .sbspf_red {
33
- color: #eb381c;
34
- }
35
- #sbspf_admin #sbspf_get_token:hover{
36
- background-color: #3880c4;
37
- color: #fff;
38
-
39
- -moz-transition: all 0.1s ease-in-out;
40
- -webkit-transition: all 0.1s ease-in-out;
41
- -o-transition: all 0.1s ease-in-out;
42
- transition: all 0.1s ease-in-out;
43
- }
44
- /* Tooltips */
45
- #sbspf_admin .sbspf_tooltip {
46
- display: none;
47
- }
48
- #sbspf_admin .sbspf_tooltip_link {
49
- font-size: 13px;
50
- margin-left: 10px;
51
- }
52
- #sbspf_admin .sbspf_tooltip_link svg,
53
- #sbspf_admin .sbspf_layouts svg,
54
- .sbspf_small_svg {
55
- width: 13px;
56
- }
57
- #sbspf_admin .sbspf_more_info{
58
- clear: both;
59
- padding: 10px 15px;
60
- margin: 10px 0;
61
- font-size: 13px;
62
- background: #f9f9f9;
63
- background: rgba(255,255,255,0.8);
64
- -moz-border-radius: 8px;
65
- -webkit-border-radius: 8px;
66
- border-radius: 8px;
67
- }
68
- #sbspf_admin .postbox .sbspf_more_info{
69
- background: #eee;
70
- background: rgba(0,0,0,0.05);
71
- }
72
- #sbspf_admin .sbspf_more_info p{
73
- font-size: 13px;
74
- }
75
- #sbspf_admin .sbspf_tooltip_link {
76
- vertical-align: top;
77
- }
78
- #sbspf_admin .sbspf_tooltip_link svg {
79
- vertical-align: bottom;
80
- }
81
- #sbspf_admin .sbspf-highlight{
82
- background: #ffed51;
83
- font-weight: bold;
84
- color: black;
85
- }
86
-
87
- /* Quick Start */
88
- #sbspf_admin .sbspf-quick-start{
89
- display: block;
90
- float: left;
91
- clear: both;
92
- width: 808px;
93
- max-width: 100%;
94
- margin: 15px 0 0 0;
95
- padding: 15px 20px;
96
-
97
- border: 1px solid #ccc;
98
- background: #eee;
99
- background: rgba(255,255,255,0.5);
100
-
101
- -moz-border-radius: 5px;
102
- -webkit-border-radius: 5px;
103
- border-radius: 5px;
104
- }
105
- #sbspf_admin .sbspf-quick-start h3,
106
- #sbspf_admin .sbspf-quick-start p{
107
- margin: 0;
108
- padding: 5px 0;
109
- }
110
- #sbspf_admin .sbspf-success{
111
- font-size: 14px;
112
- }
113
- #sbspf_admin .sbspf-footnote{
114
- width: 100%;
115
- float: left;
116
- clear: both;
117
- padding: 20px 0 0 0;
118
- border-top: 1px solid #ccc;
119
- margin: 20px 0 0 0;
120
- }
121
- #sbspf_have_own_tokens {
122
- margin: 1px 6px 0 0;
123
- }
124
- #sbspf_width_options {
125
- margin-top: 8px;
126
- }
127
- /* Pro Notice */
128
- #sbspf_admin .sbspf-pro-notice,
129
- #sbspf_admin .sbspf-pro-notice img{
130
- display: block;
131
- float: left;
132
- clear: both;
133
- margin: 20px 0 0 0;
134
- overflow: hidden;
135
- max-width: 100%;
136
-
137
- -moz-border-radius: 4px;
138
- -webkit-border-radius: 4px;
139
- border-radius: 4px;
140
-
141
- -moz-transition: all 0.5s ease-in-out;
142
- -webkit-transition: all 0.5s ease-in-out;
143
- -o-transition: all 0.5s ease-in-out;
144
- transition: all 0.5s ease-in-out;
145
- }
146
- #sbspf_admin .sbspf-pro-notice img{
147
- margin: 0;
148
- }
149
- #sbspf_admin .sbspf-pro-notice:hover{
150
- opacity: 0.95;
151
-
152
- -moz-transition: all 0.1s ease-in-out;
153
- -webkit-transition: all 0.1s ease-in-out;
154
- -o-transition: all 0.1s ease-in-out;
155
- transition: all 0.1s ease-in-out;
156
- }
157
-
158
- /* General Formatting */
159
- #sbspf_admin .sbspf_note {
160
- font-size: 12px;
161
- font-style: italic;
162
- margin-left: 5px;
163
- }
164
- #sbspf_admin .sbspf_shortcode {
165
- position: absolute;
166
- z-index: 10;
167
- font-size: 11px;
168
- float: left;
169
- width: auto;
170
- white-space: pre-line;
171
- line-height: 1.4;
172
- max-width: 195px;
173
- }
174
- .sbspf_size_4 {
175
- max-width: 60px;
176
- }
177
- #sbspf_admin td textarea {
178
- width: 100%;
179
- max-width: 700px;
180
- }
181
-
182
- /* Lock floating on top */
183
- .sbspf_lock {
184
- position: absolute;
185
- top: 50%;
186
- right: 50%;
187
- height: 18px;
188
- padding: 4px 10px;
189
- background: rgba(255,255,255,1);
190
- border-radius: 5px;
191
- box-shadow: 0 0 5px 0 rgba(0,0,0,0.1);
192
- color: #333;
193
- z-index: 99;
194
- font-size: 14px;
195
- font-weight: 700;
196
- text-decoration: none;
197
- border: 1px solid #333;
198
- }
199
-
200
- .sbspf_lock svg {
201
- height: 11px;
202
- margin-right: 4px;
203
- }
204
-
205
- /* Types */
206
- #sbspf_admin .sbspf_row{
207
- width: 100%;
208
- float: left;
209
- clear: both;
210
- margin-bottom: 5px;
211
- }
212
- #sbspf_admin .sbspf_col{
213
- float: left;
214
- }
215
- #sbspf_admin .sbspf_col.sbspf_one{
216
- width: 138px;
217
- }
218
- #sbspf_admin .sbspf_col.sbspf_two{
219
- width: 73%;
220
- }
221
- #sbspf_admin .sbspf_row input[type=radio]{
222
- margin: 5px 2px 0 0;
223
- }
224
- #sbspf_admin .sbspf_radio_label {
225
- padding-top: 4px;
226
- display: -moz-inline-stack;
227
- display: inline-block;
228
- vertical-align: top;
229
- zoom: 1;
230
- *display: inline;
231
- }
232
-
233
- /* Log In Get Access Token Button */
234
- #sbspf_admin #sbspf_get_token{
235
- display: block;
236
- float: left;
237
- clear: both;
238
- padding: 0 21px;
239
- height: 47px;
240
- line-height: 47px;
241
- font-size: 14px;
242
-
243
- background: #386793;
244
-
245
- color: #e9eef3;
246
- text-decoration: none;
247
-
248
- -moz-border-radius: 5px;
249
- -webkit-border-radius: 5px;
250
- border-radius: 5px;
251
-
252
- -moz-transition: all 0.5s ease-in-out;
253
- -webkit-transition: all 0.5s ease-in-out;
254
- -o-transition: all 0.5s ease-in-out;
255
- transition: all 0.5s ease-in-out;
256
- }
257
-
258
- /* Connected Accounts */
259
- #sbspf_get_token svg {
260
- width: 29px;
261
- margin-right: 10px;
262
- position: relative;
263
- top: 7px;
264
- }
265
- #sbspf_admin .sbspf_connected_account {
266
- position: relative;
267
- box-sizing: border-box;
268
- padding: 10px 35px 10px 10px;
269
- border-radius: 5px;
270
- background: #fff;
271
- margin-bottom: 5px;
272
- overflow: hidden;
273
- clear: both;
274
- border: 1px solid #ddd;
275
- max-width: 700px;
276
- }
277
- #sbspf_admin .sbspf_connected_account .sbspf_ca_accesstoken input {
278
- min-height: auto;
279
- line-height: 1;
280
- }
281
- #sbspf_admin .sbspf_ca_user_id{
282
- width: 275px;
283
- }
284
- #sbspf_admin .sbspf_ca_refresh_token {
285
- width: 510px;
286
- }
287
- #sbspf_admin .sbspf_connected_account svg {
288
- vertical-align: bottom;
289
- }
290
- #sbspf_admin .sbspf_ca_username {
291
- line-height: 1.4;
292
- margin-left: 15px;
293
- float: left;
294
- font-size: 18px;
295
- }
296
- #sbspf_admin .sbspf_connected_account .sbspf_ca_avatar{
297
- margin-right: 15px;
298
- }
299
- #sbspf_admin .sbspf_connected_account .sbspf_ca_username {
300
- margin-left: 0;
301
- margin-right: 15px;
302
- }
303
- #sbspf_admin .sbspf_connected_account .sbspf_ca_username strong{
304
- float: left;
305
- }
306
- #sbspf_admin .sbspf_connected_account .sbspf_ca_username span{
307
- font-size: 10px;
308
- font-weight: normal;
309
- padding: 0;
310
- margin: 0;
311
- display: block;
312
- }
313
-
314
- #sbspf_admin .sbspf_ca_actions {
315
- display: inline-block;
316
- }
317
- #sbspf_admin .sbspf_ca_actions .fa,
318
- #sbspf_admin .sbspf_ca_actions svg{
319
- margin-right: 5px;
320
- }
321
- #sbspf_admin .sbspf_ca_actions a.button-primary,
322
- #sbspf_admin .sbspf_ca_actions a.button-secondary,
323
- #sbspf_admin .sbspf_ca_accesstoken a.sbspf_ca_token_shortcode {
324
- font-size: 12px;
325
- padding: 6px;
326
- height: auto;
327
- line-height: 1;
328
- margin: 7px 5px 0 0;
329
- vertical-align: top;
330
- }
331
- #sbspf_admin .sbspf_ca_at_is_valid {
332
- margin-top: 10px;
333
- display: none;
334
- }
335
-
336
- @-webkit-keyframes sbspf_flash {
337
- 0% {
338
- background-color: #cae2a5;
339
- opacity:1;
340
- border: 1px solid #b2ce88;
341
- }
342
- 100% {
343
- background-color: #fff;
344
- }
345
- }
346
- #sbspf_admin .sbspf_account_updated{
347
- border: 1px solid #ddd;
348
- background: #fff;
349
-
350
- -webkit-animation-name: sbspf_flash;
351
- -webkit-animation-duration: 700ms;
352
- -webkit-animation-iteration-count: 1;
353
- -webkit-animation-timing-function: linear;
354
- -moz-animation-name: sbspf_flash;
355
- -moz-animation-duration: 700ms;
356
- -moz-animation-iteration-count: 1;
357
- -moz-animation-timing-function: linear;
358
- }
359
-
360
- #sbspf_admin .sbspf_account_active{
361
- border: 1px solid #b2ce88;
362
- background: #ecf2e3;
363
- }
364
-
365
- #sbspf_admin .sbspf_ca_alert {
366
- display: none;
367
- }
368
- #sbspf_admin .sbspf_ca_alert {
369
- padding: 5px 10px;
370
- margin: 0px 0 12px 0;
371
- border-radius: 5px;
372
- font-size: 13px;
373
- border: 1px solid;
374
- }
375
- #sbspf_admin .sbspf_ca_updated {
376
- display: inline-block;
377
- background: #d3dec1;
378
- color: #2e4506;
379
- border-color: #a9b594;
380
- }
381
- #sbspf_admin .sbspf_account_invalid .sbspf_ca_alert {
382
- display: inline-block;
383
- }
384
- #sbspf_admin .sbspf_ca_avatar{
385
- float: left;
386
- width: 40px;
387
- height: 40px;
388
- border-radius: 5px;
389
- }
390
- #sbspf_admin .sbspf_ca_accesstoken{
391
- display: none;
392
- width: 100%;
393
- float: left;
394
- clear: both;
395
- margin-top: 10px;
396
- }
397
- #sbspf_admin .sbspf_ca_token_label{
398
- display: inline-block;
399
- position: relative;
400
- background: #f9f9f9;
401
- color: #555;
402
- padding: 3px 5px;
403
- font-size: 12px;
404
- border: 1px solid #d6d6d6;
405
- height: 16px;
406
- line-height: 15px;
407
- border-radius: 4px 0 0 4px;
408
- min-width: 80px;
409
- margin-bottom: 2px;
410
- }
411
- #sbspf_admin .sbspf_permissions_desc,
412
- #sbspf_admin .sbspf_ca_token,
413
- #sbspf_admin .sbspf_ca_refresh_token,
414
- #sbspf_admin .sbspf_ca_user_id {
415
- padding: 3px 10px;
416
- }
417
-
418
- #sbspf_admin .sbspf_ca_token,
419
- #sbspf_admin .sbspf_ca_user_id,
420
- #sbspf_admin .sbspf_ca_refresh_token{
421
- position: relative;
422
- top: 1px;
423
- border: 1px solid #d6d6d6;
424
- border-left: none;
425
- font-size: 13px;
426
- border-radius: 0 4px 4px 0;
427
- background: rgba(255,255,255,0.8);
428
- display: inline-block;
429
- margin-left: 0;
430
- }
431
- #sbspf_admin .sbspf_ca_token {
432
- width: 510px;
433
- }
434
- #sbspf_admin .sbspf_ca_accesstoken a.sbspf_ca_token_shortcode{
435
- margin: 0 8px 8px;
436
- padding: 6px;
437
- height: auto;
438
- line-height: 1;
439
- }
440
-
441
- #sbspf_admin .sbspf_delete_account{
442
- position: absolute;
443
- right: 10px;
444
- top: 10px;
445
-
446
- padding: 5px 10px;
447
- background: rgba(0,0,0,0.05);
448
- color: #666;
449
- border-radius: 50px;
450
- text-decoration: none;
451
- font-size: 12px;
452
- }
453
- #sbspf_admin .sbspf_delete_account:hover,
454
- #sbspf_admin .sbspf_delete_account:focus{
455
- background: #333;
456
- color: #ddd;
457
- }
458
- #sbspf_admin .sbspf_ca_delete a {
459
- display: block;
460
- height: 13px;
461
- padding: 5px 6px;
462
- }
463
- #sbspf_admin .sbspf_ca_delete svg {
464
- height: 12px;
465
- line-height: 1;
466
- padding-bottom: 2px;
467
- }
468
- #sbspf_admin .sbspf_delete_account .sbspf_remove_text{
469
- margin-left: 5px;
470
- }
471
-
472
- .sbspf_connected_accounts_wrap{
473
- vertical-align: top;
474
- }
475
- #sbspf_admin .sbspf_no_accounts{
476
- display: inline-block;
477
- padding: 4px 15px;
478
- border-radius: 8px;
479
- background: rgba(255,255,255,0.8);
480
- margin-bottom: 3px;
481
- }
482
- #sbspf_admin #sbspf_manual_submit:active{
483
- vertical-align: unset;
484
- }
485
- #sbspf_admin .sbspf_manually_connect_wrap{
486
- padding-top: 5px;
487
- }
488
- #sbspf_admin .sbspf_user_feed_account_wrap:first-child,
489
- #sbspf_admin .sbspf_tagged_feed_account_wrap:first-child{
490
- padding-top: 5px;
491
- }
492
- #sbspf_admin .sbspf_user_feed_account_wrap:last-child,
493
- #sbspf_admin .sbspf_tagged_feed_account_wrap:last-child{
494
- padding-bottom: 6px;
495
- }
496
- #sbspf_admin .sbspf_user_feed_account_wrap,
497
- #sbspf_admin .sbspf_tagged_feed_account_wrap{
498
- padding-bottom: 5px;
499
- padding-left: 2px;
500
- }
501
- #sbspf_admin .sbspf_user_feed_account_wrap span,
502
- #sbspf_admin .sbspf_tagged_feed_account_wrap span{
503
- font-size: 13px;
504
- }
505
- #sbspf_admin .sbspf_manual_account_id_toggle label{
506
- display: block;
507
- margin: 10px 0 0 0;
508
- font-size: 13px;
509
- }
510
- #sbspf_admin .sbspf_business_profile_tag{
511
- display: none;
512
- padding: 8px 10px;
513
- background: rgba(0,0,0,0.05);
514
- border-radius: 0 5px 5px 0;
515
- margin: 0 0 0 -2px;
516
- font-size: 13px;
517
- height: 15px;
518
- line-height: 15px;
519
- box-shadow: inset 0 0 1px rgba(0,0,0,.5);
520
- }
521
- #sbspf_admin .sbspf_ca_info{
522
- overflow: hidden;
523
- }
524
- #sbspf_admin .sbspf_ca_show_token .fa,
525
- #sbspf_admin .sbspf_ca_show_token svg{
526
- margin-right: 0;
527
- }
528
- #sbspf_admin .sbspf_ca_show_token{
529
- display: inline-block;
530
- padding: 10px 5px 0px 5px;
531
- margin: 0;
532
- font-size: 12px;
533
- vertical-align: top;
534
- }
535
- #sbspf_admin .sbspf_ca_shortcode{
536
- display: none;
537
- padding: 0;
538
- width: 100%;
539
- float: left;
540
- clear: both;
541
- margin: 10px 0 0 0;
542
- }
543
- #sbspf_admin .sbspf_ca_shortcode p{
544
- padding-bottom: 10px;
545
- font-size: 13px;
546
- }
547
- #sbspf_admin .sbspf_ca_shortcode code{
548
- margin-top: 5px;
549
- display: inline-block;
550
- }
551
- #sbspf_admin .sbspf_user_feed_ids_wrap .sbspf_ca_avatar{
552
- width: 20px;
553
- height: 20px;
554
- position: relative;
555
- top: 5px;
556
- margin-right: 8px;
557
- border-radius: 4px;
558
- }
559
-
560
-
561
- @media all and (max-width: 1200px){
562
- #sbspf_admin .sbspf_delete_account .sbspf_remove_text{
563
- display: none;
564
- }
565
- #sbspf_admin .sbspf_ca_token,
566
- #sbspf_admin .sbspf_ca_user_id{
567
- border-left: 1px solid #d6d6d6;
568
- border-radius: 4px;
569
- }
570
- }
571
- @media all and (max-width: 800px){
572
- #sbspf_admin .sbspf_col.sbspf_one {
573
- width: 25%;
574
- margin-right: 5%;
575
- }
576
- #sbspf_admin .sbspf_col.sbspf_two{
577
- width: 70%;
578
- }
579
- }
580
-
581
- /* Configure */
582
- #sbspf_config {
583
- float: left;
584
- width: 100%;
585
- clear: both;
586
- margin: 10px 0 10px 0;
587
- }
588
- #sbspf_config .sbspf_not_working {
589
- position: relative;
590
- top: 14px;
591
- left: 15px;
592
- }
593
- /* Caching settings */
594
- #sbspf_admin #sbspf-caching-time-settings{
595
- display: inline-block;
596
- }
597
- #sbspf_admin .sbspf-caching-cron-options .submit{
598
- display: inline-block;
599
- margin: 0;
600
- padding: 0;
601
- }
602
- #sbspf_admin .sbspf-caching-sched-notice{
603
- font-size: 11px;
604
- display: block;
605
- width: 100%;
606
- }
607
- #sbspf_admin .sbspf-caching-sched-notice span{
608
- color: green;
609
- background: #e5eae1;
610
- padding: 5px 10px;
611
- border-radius: 5px;
612
- border: 1px solid #ccd3c6;
613
- display: inline-block;
614
- }
615
- #sbspf_admin .sbspf_cron_cache_opts .sbspf_row{
616
- padding: 3px 0;
617
- }
618
- #sbspf_admin .sbspf_cron_cache_opts .sbspf_row label {
619
- display: inline-block;
620
- margin: 5px 2px 0 0;
621
- }
622
-
623
- /* Layout */
624
- .form-table .sbspf_layout_type {
625
- display: inline-block;
626
- margin-left: 20px;
627
- }
628
- .form-table .sbspf_layout_type:first-child {
629
- margin-left: 0;
630
- }
631
- .sbspf_layout_setting,
632
- .sbspf_sub_option_setting{
633
- margin-bottom: 20px;
634
- }
635
- .sbspf_layout_setting:last-child,
636
- .sbspf_box_setting:last-child,
637
- .sbspf_sub_option_setting:last-child{
638
- margin-bottom: 0;
639
- }
640
- .sbspf_layout_setting label,
641
- .sbspf_box_setting label {
642
- display: inline-block;
643
- font-weight: bold;
644
- font-size: 14px;
645
- padding-bottom: 5px;
646
- padding-right: 5px;
647
- }
648
- #sbspf_admin .sbspf_layout_options_wrap .sbspf_shortcode_symbol{
649
- bottom: 4px;
650
- right: -20px;
651
- }
652
- #sbspf_admin .sbspf_layout_options_wrap .sbspf_shortcode,
653
- #sbspf_admin .sbspf_box_setting .sbspf_shortcode{
654
- position: relative;
655
- float: none;
656
- top: -4px
657
- }
658
- .sbspf_layout_cell,
659
- .sbspf_sub_option_cell{
660
- padding: 0;
661
- display: inline-block;
662
- float: left;
663
- width: 155px;
664
- padding: 15px 15px 10px 15px;
665
- margin-right: 10px;
666
- margin-bottom: 10px;
667
- background: #f6f6f6;
668
- border: 1px solid #ddd;
669
- -moz-border-radius: 5px;
670
- -webkit-border-radius: 5px;
671
- border-radius: 5px;
672
- vertical-align: top;
673
- }
674
- .sbspf_layout_cell:nth-child(4) {
675
- margin-right: 0;
676
- }
677
- @media all and (max-width: 1200px){
678
- .sbspf_layout_cell,
679
- .sbspf_sub_option_cell{
680
- width: 21%;
681
- padding: 1%;
682
- margin-right: 1%;
683
- }
684
- .sbspf_sub_option_cell {
685
- width: 30%;
686
- }
687
- }
688
- @media all and (max-width: 480px){
689
- .sbspf_layout_cell,
690
- .sbspf_sub_option_cell{
691
- width: 98%;
692
- padding: 1%;
693
- margin: 5px 0;
694
- }
695
- }
696
- .sbspf_label {
697
- font-size: 16px;
698
- font-weight: bold;
699
- padding-left: 2px;
700
- }
701
- .sbspf_layout_cell:hover,
702
- .sbspf_layout_cell:focus,
703
- .sbspf_sub_option_cell:hover,
704
- .sbspf_sub_option_cell:focus{
705
- background: #fcfcfc;
706
- cursor: pointer;
707
- }
708
- .sbspf_layout_cell.sbspf_layout_selected,
709
- .sbspf_sub_option_cell.sbspf_sub_option_selected{
710
- background: #f7faf1;
711
- border: 1px solid #7ad03a;
712
- }
713
- .sbspf_layout_cell h3
714
- .sbspf_sub_option_cell h3 {
715
- font-size: 15px;
716
- margin-top: 0;
717
- }
718
- .sbspf_layout_cell img,
719
- .sbspf_sub_option_cell img {
720
- width: 100%;
721
- border: 1px solid #ddd;
722
- margin-top: 5px;
723
- }
724
- #sbspf_admin .sbspf_layout_settings,
725
- #sbspf_admin .sbspf_sub_option_settings{
726
- float: left;
727
- clear: both;
728
- width: 96%;
729
- max-width: 700px;
730
-
731
- padding: 20px 2%;
732
- margin: 0 0 10px 0;
733
- font-size: 13px;
734
- background: #f9f9f9;
735
- background: rgba(255,255,255,0.8);
736
-
737
- -moz-border-radius: 8px;
738
- -webkit-border-radius: 8px;
739
- border-radius: 8px;
740
- }
741
- .sbspf_layout_setting,
742
- .sbspf_sub_option_setting{
743
- clear:left;
744
- margin-bottom: 20px;
745
- }
746
- #sbspf_admin .sbspf_layout_options_wrap .sbspf-tooltip,
747
- #sbspf_admin .sbspf_box_setting .sbspf-tooltip{
748
- width: 98%;
749
- padding: 10px 1%;
750
- background: #eee;
751
- background: rgba(0,0,0,0.05);
752
- }
753
- #sbspf_admin .sbspf_layout_mobile_layout_setting {
754
- width: auto;
755
- }
756
-
757
-
758
- /* Display Tab */
759
- #sbspf_admin table.sbspf_shortcode_table{
760
- border-collapse: collapse;
761
- }
762
- #sbspf_admin table.sbspf_shortcode_table th,
763
- #sbspf_admin table.sbspf_shortcode_table td{
764
- border: 1px solid #999;
765
- padding: 0.5rem;
766
- text-align: left;
767
- }
768
- #sbspf_admin table.sbspf_shortcode_table th{
769
- background: rgba(0,0,0,0.1);
770
- }
771
- #sbspf_admin table.sbspf_shortcode_table td{
772
- background: rgba(255,255,255,0.5);
773
- }
774
- #sbspf_admin .sbspf_table_header{
775
- background: #ddd;
776
- font-weight: bold;
777
- }
778
-
779
- /* Modal */
780
-
781
- #sbspf_modal_overlay{
782
- position: fixed;
783
- z-index: 999;
784
- width: 100%;
785
- top: 0;
786
- right: 0;
787
- bottom: 0;
788
- left: 0;
789
-
790
- background: rgba(0,0,0,0.3);
791
- }
792
- #sbspf_modal_overlay .sbspf_modal{
793
- position: absolute;
794
- top: 160px;
795
- left: 50%;
796
- width: 450px;
797
-
798
- margin: 0 0 0 -230px;
799
- padding: 20px 30px;
800
- background: #fff;
801
-
802
- -webkit-box-shadow: 0 1px 20px rgba(0,0,0,0.2);
803
- box-shadow: 0 1px 20px rgba(0,0,0,0.2);
804
-
805
- -moz-border-radius: 3px;
806
- -webkit-border-radius: 3px;
807
- border-radius: 3px;
808
- }
809
- #sbspf_modal_overlay .sbspf_modal p{
810
- margin: 8px 0;
811
- }
812
- #sbspf_modal_overlay .sbspf_modal .sbspf_submit{
813
- margin-top: 20px;
814
- }
815
- #sbspf_modal_overlay .sbspf_modal .heading{
816
- font-weight: 500;
817
- font-size: 15px;
818
- }
819
- @media all and (max-width: 480px){
820
- #sbspf_modal_overlay .sbspf_modal{
821
- max-width: 100%;
822
- margin: 0 0 0 -50%;
823
- box-sizing: border-box;
824
- }
825
- }
826
- .sbspf_emphasis {
827
- display: block;
828
- font-size: 16px;
829
- text-align: center;
830
- margin-bottom: 20px;
831
- }
832
- .sbspf_emphasis svg {
833
- height: 14px;
834
- }
835
- .sbspf_modal_message h3 {
836
- font-size: 14px;
837
- }
838
- .sbspf_modal .sbspf_modal_close{
839
- position: absolute;
840
- top: 0;
841
- right: 0;
842
- padding: 10px;
843
- font-size: 14px;
844
- color: #ccc;
845
- margin: 0;
846
- }
847
- .sbspf_modal .sbspf_modal_close:focus,
848
- .sbspf_modal .sbspf_modal_close:hover{
849
- color: #333;
850
- }
851
- /* Pro only notices */
852
- #sbspf_admin .sbspf_sub_options,
853
- #sbspf_admin .sbspf_layout_cell,
854
- #sbspf_admin .sbspf_layout_settings,
855
- #sbspf_admin .sbspf_disabled_wrap{
856
- position: relative;
857
- }
858
- #sbspf_admin .sbspf_sub_options:after,
859
- #sbspf_admin .sbspf_disabled_wrap{
860
- clear: both;
861
- display: table;
862
- content: ""
863
- }
864
- #sbspf_admin .sbspf_disabled_wrap{
865
- width: 100%;
866
- max-width: 520px;
867
- }
868
- #sbspf_admin .sby_includes_pro_only .sbspf_pro_tooltip {
869
- top: 50%;
870
- left: 30px;
871
- bottom: auto;
872
- margin-top: -96px;
873
- }
874
- #sbspf_admin .sbspf-show-pro{
875
- margin-top: 10px;
876
- text-align: center;
877
- }
878
- .sbspf_layout_cell.sbspf_pro_only .sbspf_lock{
879
- margin-top: -4px;
880
- }
881
- #sbspf_admin .sbspf_layout_cell.sbspf_pro_only .sbspf_pro_tooltip {
882
- margin-top: -38px;
883
- left: 54px;
884
- }
885
- #sbspf_admin .sbspf_pro_only,
886
- #sbspf_admin .sbspf_pro_only label,
887
- #sbspf_admin .sbspf_pro_only input,
888
- #sbspf_admin .sbspf_pro_only select,
889
- #sbspf_admin .sbspf_pro_only_row,
890
- #sbspf_admin .sbspf_pro_only_row label,
891
- #sbspf_admin .sbspf_pro_only_row input,
892
- #sbspf_admin .sbspf_pro_only_row select{
893
- color: #999 !important;
894
- }
895
- #sbspf_admin tr.sbspf_pro_only{
896
- background: #eacccc;
897
- }
898
- #sbspf_admin .sbspf_type_row.sbspf_pro_only input[type=text]{
899
- opacity: 0.5;
900
- background: white;
901
- }
902
- .sbspf_lock.sbspf_pro_lock {
903
- background: rgba(255,255,255,0.8);
904
- color: #666;
905
- border: 1px solid #ccc;
906
- margin-right: -34px;
907
- }
908
- .sbspf_lock.sbspf_pro_lock i {
909
- margin-right: 8px;
910
- }
911
- #sbspf_admin .sbspf_pro_lock:hover,
912
- #sbspf_admin .sbspf_pro_lock:hover{
913
- background: #fff;
914
- border: 1px solid #ccc;
915
- color: #333;
916
- box-shadow: 0 0 8px 0 rgba(0,0,0,0.15);
917
- }
918
- #sbspf_admin .sbspf_pro_tooltip{
919
- text-align: center;
920
- z-index:99;
921
- display: none;
922
- position: absolute;
923
- bottom: 22px;
924
- left: -8px;
925
-
926
- background: #333;
927
- color: #eee;
928
- width: 90%;
929
- padding: 8px 10px 10px 10px;
930
- border-radius: 3px;
931
- line-height: 1.3;
932
- font-size: 12px;
933
- width: 190px;
934
- }
935
- #sbspf_admin .sbspf_pro_tooltip .fa-caret-down {
936
- position: absolute;
937
- bottom: -12px;
938
- font-size: 20px;
939
- left: 49%;
940
- color: #333;
941
- }
942
- #sbspf_admin .sbspf_layouts .sbspf_pro_tooltip,
943
- #sbspf_admin .sbspf_sub_options .sbspf_pro_tooltip{
944
- left: 284px;
945
- top: -21px;
946
- bottom: auto;
947
- margin-left: -101px;
948
- }
949
- #sbspf_admin .sbspf_layouts .sbspf_layout_cell .sbspf_pro_tooltip{
950
- left: 84px;
951
- top: 32px;
952
- }
953
- #sbspf_admin .sbspf_table_key{
954
- display: block;
955
- float: left;
956
- width: 11px;
957
- height: 11px;
958
- border: 1px solid #999;
959
- background: #eacccc;
960
- margin: 3px 6px 0 0;
961
- }
962
-
963
- /* SBY Specific */
964
- #sbspf_admin .sby_mode_option {
965
- position: relative;
966
- margin-bottom: 20px;
967
- }
968
- #sbspf_admin .sby_mode_option label {
969
- display: inline-block;
970
- font-weight: bold;
971
- }
972
- #sbspf_admin .sby_mode_option .sbspf_note {
973
- display: block;
974
- margin-left: 0;
975
- }
976
- #sbspf_admin .sby_mode_option .sbspf_note,
977
- #sbspf_admin .sby_mode_option label {
978
- margin-bottom: 5px;
979
- }
980
- #sbspf_admin .sby_mode_option input[type=radio] {
981
- position: absolute;
982
- top: 6px;
983
- }
984
- #sbspf_admin .sby_mode_option_text {
985
- margin-left: 22px;
986
- }
987
- #sbspf_admin .sby_mode_option.sbspf_fade .sby_important,
988
- #sbspf_admin .sby_mode_option.sbspf_fade .sbspf_note {
989
- opacity: 1;
990
- }
991
-
992
- /* Notices */
993
- .sby_includes_pro_only .sbspf_lock {
994
- left: 100px;
995
- right: auto;
996
- margin-top: -40px;
997
- }
998
- .sbspf_sub_options .sbspf_lock {
999
- top: 38px;
1000
- left: 260px;
1001
- right: auto;
1002
- }
1003
- .sby_types_disabled_wrap .sbspf_lock {
1004
- margin-top: -20px;
1005
- }
1006
- #sbspf_admin .sby_types_disabled_wrap .sbspf_pro_tooltip {
1007
- top: 50%;
1008
- margin-left: -112px;
1009
- margin-top: -78px;
1010
- bottom: auto;
1011
- left: 50%;
1012
- }
1013
- @media screen and (max-width: 480px) {
1014
- .sbspf_sub_options .sbspf_lock {
1015
- top: 60px;
1016
- left: 50%;
1017
- margin-left: -40px;
1018
- right: auto;
1019
- }
1020
- #sbspf_admin .sbspf_sub_options .sbspf_pro_tooltip {
1021
- top: 0px;
1022
- left: 50%;
1023
- margin-left: -112px;
1024
- }
1025
- }
1026
-
1027
- /* Lite Notice */
1028
- @media screen and (max-width: 600px) {
1029
- #sbspf-notice-bar {
1030
- display:none !important
1031
- }
1032
- }
1033
-
1034
- #sbspf-notice-bar {
1035
- background-color: #DDDDDD;
1036
- color: #777777;
1037
- text-align: center;
1038
- position: relative;
1039
- padding: 7px;
1040
- margin-bottom: 0;
1041
- opacity: 1;
1042
- transition: all .3s ease-in-out;
1043
- max-height: 100px;
1044
- overflow: hidden
1045
- }
1046
-
1047
- #sbspf-notice-bar.out {
1048
- opacity: .5;
1049
- max-height: 0
1050
- }
1051
-
1052
- #sbspf-notice-bar a {
1053
- color: #e34f0e;
1054
- }
1055
-
1056
- #sbspf-notice-bar a:hover {
1057
- color: #b85a1b
1058
- }
1059
-
1060
- #sbspf-notice-bar .dismiss {
1061
- position: absolute;
1062
- top: 0;
1063
- right: 0;
1064
- border: none;
1065
- padding: 5px;
1066
- margin-top: 1px;
1067
- background: 0 0;
1068
- color: #72777c;
1069
- cursor: pointer
1070
- }
1071
-
1072
- #sbspf-notice-bar .dismiss:before {
1073
- background: 0 0;
1074
- color: #72777c;
1075
- content: "\f335";
1076
- display: block;
1077
- font: normal 20px/20px dashicons;
1078
- speak: none;
1079
- height: 20px;
1080
- text-align: center;
1081
- width: 20px;
1082
- -webkit-font-smoothing: antialiased
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1083
  }
1
+ #sbspf_admin h2{
2
+ padding: 15px 0 0 0;
3
+ clear: both;
4
+ }
5
+ #sbspf_admin hr {
6
+ border: none;
7
+ margin: 15px 0;
8
+ border-bottom: 1px solid #ccc;
9
+ }
10
+ #sbspf_admin .sbspf_spinner {
11
+ float: none;
12
+ }
13
+ #sbspf_admin .sbspf_success {
14
+ display: inline-block;
15
+ position: relative;
16
+ margin: 4px 12px 0;
17
+ }
18
+ #sbspf_admin .sbspf_success svg {
19
+ vertical-align: bottom;
20
+ width: 16px;
21
+ color: #7ad03a;
22
+ }
23
+ #sbspf_admin .sbspf_fade {
24
+ opacity: .6;
25
+ }
26
+ #sbspf_admin .sbspf_aside {
27
+ font-style: italic;
28
+ font-weight: normal;
29
+ font-size: 12px;
30
+ margin: .3em 0;
31
+ }
32
+ #sbspf_admin .sbspf_red {
33
+ color: #eb381c;
34
+ }
35
+ #sbspf_admin #sbspf_get_token:hover{
36
+ background-color: #3880c4;
37
+ color: #fff;
38
+
39
+ -moz-transition: all 0.1s ease-in-out;
40
+ -webkit-transition: all 0.1s ease-in-out;
41
+ -o-transition: all 0.1s ease-in-out;
42
+ transition: all 0.1s ease-in-out;
43
+ }
44
+ /* Quick Links */
45
+ #sbspf_admin .sbspf-contents-links a,
46
+ #sbspf_admin .sbspf-contents-links span {
47
+ display: block;
48
+ float: left;
49
+ padding: 2px 5px;
50
+ }
51
+ #sbspf_admin .sbspf-contents-links{
52
+ float: left;
53
+ clear: both;
54
+ width: 100%;
55
+ padding-bottom: 12px;
56
+ border-bottom: 1px solid #ccc;
57
+ margin-bottom: 15px;
58
+ }
59
+ /* Tooltips */
60
+ #sbspf_admin .sbspf_tooltip {
61
+ display: none;
62
+ }
63
+ #sbspf_admin .sbspf_tooltip_link {
64
+ font-size: 13px;
65
+ margin-left: 10px;
66
+ }
67
+ #sbspf_admin .sbspf_tooltip_link svg,
68
+ #sbspf_admin .sbspf_layouts svg,
69
+ .sbspf_small_svg {
70
+ width: 13px;
71
+ }
72
+ #sbspf_admin .sbspf_more_info{
73
+ clear: both;
74
+ padding: 10px 15px;
75
+ margin: 10px 0;
76
+ font-size: 13px;
77
+ background: #f9f9f9;
78
+ background: rgba(255,255,255,0.8);
79
+ -moz-border-radius: 8px;
80
+ -webkit-border-radius: 8px;
81
+ border-radius: 8px;
82
+ }
83
+ #sbspf_admin .postbox .sbspf_more_info{
84
+ background: #eee;
85
+ background: rgba(0,0,0,0.05);
86
+ }
87
+ #sbspf_admin .sbspf_more_info p{
88
+ font-size: 13px;
89
+ }
90
+ #sbspf_admin .sbspf_tooltip_link {
91
+ vertical-align: top;
92
+ }
93
+ #sbspf_admin .sbspf_tooltip_link svg {
94
+ vertical-align: bottom;
95
+ }
96
+ #sbspf_admin .sbspf-highlight{
97
+ background: #ffed51;
98
+ font-weight: bold;
99
+ color: black;
100
+ }
101
+
102
+ /* Quick Start */
103
+ #sbspf_admin .sbspf-quick-start{
104
+ display: block;
105
+ float: left;
106
+ clear: both;
107
+ width: 808px;
108
+ max-width: 100%;
109
+ margin: 15px 0 0 0;
110
+ padding: 15px 20px;
111
+
112
+ border: 1px solid #ccc;
113
+ background: #eee;
114
+ background: rgba(255,255,255,0.5);
115
+
116
+ -moz-border-radius: 5px;
117
+ -webkit-border-radius: 5px;
118
+ border-radius: 5px;
119
+ }
120
+ #sbspf_admin .sbspf-quick-start h3,
121
+ #sbspf_admin .sbspf-quick-start p{
122
+ margin: 0;
123
+ padding: 5px 0;
124
+ }
125
+ #sbspf_admin .sbspf-success{
126
+ font-size: 14px;
127
+ }
128
+ #sbspf_admin .sbspf-footnote{
129
+ width: 100%;
130
+ float: left;
131
+ clear: both;
132
+ padding: 20px 0 0 0;
133
+ border-top: 1px solid #ccc;
134
+ margin: 20px 0 0 0;
135
+ }
136
+ #sbspf_have_own_tokens {
137
+ margin: 1px 6px 0 0;
138
+ }
139
+ #sbspf_width_options {
140
+ margin-top: 8px;
141
+ }
142
+ /* Pro Notice */
143
+ #sbspf_admin .sbspf-pro-notice,
144
+ #sbspf_admin .sbspf-pro-notice img{
145
+ display: block;
146
+ float: left;
147
+ clear: both;
148
+ margin: 20px 0 0 0;
149
+ overflow: hidden;
150
+ max-width: 100%;
151
+
152
+ -moz-border-radius: 4px;
153
+ -webkit-border-radius: 4px;
154
+ border-radius: 4px;
155
+
156
+ -moz-transition: all 0.5s ease-in-out;
157
+ -webkit-transition: all 0.5s ease-in-out;
158
+ -o-transition: all 0.5s ease-in-out;
159
+ transition: all 0.5s ease-in-out;
160
+ }
161
+ #sbspf_admin .sbspf-pro-notice img{
162
+ margin: 0;
163
+ }
164
+ #sbspf_admin .sbspf-pro-notice:hover{
165
+ opacity: 0.95;
166
+
167
+ -moz-transition: all 0.1s ease-in-out;
168
+ -webkit-transition: all 0.1s ease-in-out;
169
+ -o-transition: all 0.1s ease-in-out;
170
+ transition: all 0.1s ease-in-out;
171
+ }
172
+
173
+ /* General Formatting */
174
+ #sbspf_admin .sbspf_note {
175
+ font-size: 12px;
176
+ font-style: italic;
177
+ margin-left: 5px;
178
+ }
179
+ #sbspf_admin .sbspf_shortcode {
180
+ position: absolute;
181
+ z-index: 10;
182
+ font-size: 11px;
183
+ float: left;
184
+ width: auto;
185
+ white-space: pre-line;
186
+ line-height: 1.4;
187
+ max-width: 195px;
188
+ }
189
+ .sbspf_size_4 {
190
+ max-width: 60px;
191
+ }
192
+ #sbspf_admin td textarea {
193
+ width: 100%;
194
+ max-width: 700px;
195
+ }
196
+
197
+ /* Lock floating on top */
198
+ .sbspf_lock {
199
+ position: absolute;
200
+ top: 50%;
201
+ right: 50%;
202
+ height: 18px;
203
+ padding: 4px 10px;
204
+ background: rgba(255,255,255,1);
205
+ border-radius: 5px;
206
+ box-shadow: 0 0 5px 0 rgba(0,0,0,0.1);
207
+ color: #333;
208
+ z-index: 99;
209
+ font-size: 14px;
210
+ font-weight: 700;
211
+ text-decoration: none;
212
+ border: 1px solid #333;
213
+ }
214
+
215
+ .sbspf_lock svg {
216
+ height: 11px;
217
+ margin-right: 4px;
218
+ }
219
+
220
+ /* Types */
221
+ #sbspf_admin .sbspf_row{
222
+ width: 100%;
223
+ float: left;
224
+ clear: both;
225
+ margin-bottom: 5px;
226
+ }
227
+ #sbspf_admin .sbspf_col{
228
+ float: left;
229
+ }
230
+ #sbspf_admin .sbspf_col.sbspf_one{
231
+ width: 138px;
232
+ }
233
+ #sbspf_admin .sbspf_col.sbspf_two{
234
+ width: 73%;
235
+ }
236
+ #sbspf_admin .sbspf_row input[type=radio]{
237
+ margin: 5px 2px 0 0;
238
+ }
239
+ #sbspf_admin .sbspf_radio_label {
240
+ padding-top: 4px;
241
+ display: -moz-inline-stack;
242
+ display: inline-block;
243
+ vertical-align: top;
244
+ zoom: 1;
245
+ *display: inline;
246
+ }
247
+
248
+ /* Log In Get Access Token Button */
249
+ #sbspf_admin #sbspf_get_token{
250
+ display: block;
251
+ float: left;
252
+ clear: both;
253
+ padding: 0 21px;
254
+ height: 47px;
255
+ line-height: 47px;
256
+ font-size: 14px;
257
+
258
+ background: #386793;
259
+
260
+ color: #e9eef3;
261
+ text-decoration: none;
262
+
263
+ -moz-border-radius: 5px;
264
+ -webkit-border-radius: 5px;
265
+ border-radius: 5px;
266
+
267
+ -moz-transition: all 0.5s ease-in-out;
268
+ -webkit-transition: all 0.5s ease-in-out;
269
+ -o-transition: all 0.5s ease-in-out;
270
+ transition: all 0.5s ease-in-out;
271
+ }
272
+
273
+ /* Connected Accounts */
274
+ #sbspf_get_token svg {
275
+ width: 29px;
276
+ margin-right: 10px;
277
+ position: relative;
278
+ top: 7px;
279
+ }
280
+ #sbspf_admin .sbspf_connected_account {
281
+ position: relative;
282
+ box-sizing: border-box;
283
+ padding: 10px 35px 10px 10px;
284
+ border-radius: 5px;
285
+ background: #fff;
286
+ margin-bottom: 5px;
287
+ overflow: hidden;
288
+ clear: both;
289
+ border: 1px solid #ddd;
290
+ max-width: 700px;
291
+ }
292
+ #sbspf_admin .sbspf_connected_account .sbspf_ca_accesstoken input {
293
+ min-height: auto;
294
+ line-height: 1;
295
+ }
296
+ #sbspf_admin .sbspf_ca_user_id{
297
+ width: 275px;
298
+ }
299
+ #sbspf_admin .sbspf_ca_refresh_token {
300
+ width: 510px;
301
+ }
302
+ #sbspf_admin .sbspf_connected_account svg {
303
+ vertical-align: bottom;
304
+ }
305
+ #sbspf_admin .sbspf_ca_username {
306
+ line-height: 1.4;
307
+ margin-left: 15px;
308
+ float: left;
309
+ font-size: 18px;
310
+ }
311
+ #sbspf_admin .sbspf_connected_account .sbspf_ca_avatar{
312
+ margin-right: 15px;
313
+ }
314
+ #sbspf_admin .sbspf_connected_account .sbspf_ca_username {
315
+ margin-left: 0;
316
+ margin-right: 15px;
317
+ }
318
+ #sbspf_admin .sbspf_connected_account .sbspf_ca_username strong{
319
+ float: left;
320
+ }
321
+ #sbspf_admin .sbspf_connected_account .sbspf_ca_username span{
322
+ font-size: 10px;
323
+ font-weight: normal;
324
+ padding: 0;
325
+ margin: 0;
326
+ display: block;
327
+ }
328
+
329
+ #sbspf_admin .sbspf_ca_actions {
330
+ display: inline-block;
331
+ }
332
+ #sbspf_admin .sbspf_ca_actions .fa,
333
+ #sbspf_admin .sbspf_ca_actions svg{
334
+ margin-right: 5px;
335
+ }
336
+ #sbspf_admin .sbspf_ca_actions a.button-primary,
337
+ #sbspf_admin .sbspf_ca_actions a.button-secondary,
338
+ #sbspf_admin .sbspf_ca_accesstoken a.sbspf_ca_token_shortcode {
339
+ font-size: 12px;
340
+ padding: 6px;
341
+ height: auto;
342
+ line-height: 1;
343
+ margin: 7px 5px 0 0;
344
+ vertical-align: top;
345
+ }
346
+ #sbspf_admin .sbspf_ca_at_is_valid {
347
+ margin-top: 10px;
348
+ display: none;
349
+ }
350
+
351
+ @-webkit-keyframes sbspf_flash {
352
+ 0% {
353
+ background-color: #cae2a5;
354
+ opacity:1;
355
+ border: 1px solid #b2ce88;
356
+ }
357
+ 100% {
358
+ background-color: #fff;
359
+ }
360
+ }
361
+ #sbspf_admin .sbspf_account_updated{
362
+ border: 1px solid #ddd;
363
+ background: #fff;
364
+
365
+ -webkit-animation-name: sbspf_flash;
366
+ -webkit-animation-duration: 700ms;
367
+ -webkit-animation-iteration-count: 1;
368
+ -webkit-animation-timing-function: linear;
369
+ -moz-animation-name: sbspf_flash;
370
+ -moz-animation-duration: 700ms;
371
+ -moz-animation-iteration-count: 1;
372
+ -moz-animation-timing-function: linear;
373
+ }
374
+
375
+ #sbspf_admin .sbspf_account_active{
376
+ border: 1px solid #b2ce88;
377
+ background: #ecf2e3;
378
+ }
379
+
380
+ #sbspf_admin .sbspf_ca_alert {
381
+ display: none;
382
+ }
383
+ #sbspf_admin .sbspf_ca_alert {
384
+ padding: 5px 10px;
385
+ margin: 0px 0 12px 0;
386
+ border-radius: 5px;
387
+ font-size: 13px;
388
+ border: 1px solid;
389
+ }
390
+ #sbspf_admin .sbspf_ca_updated {
391
+ display: inline-block;
392
+ background: #d3dec1;
393
+ color: #2e4506;
394
+ border-color: #a9b594;
395
+ }
396
+ #sbspf_admin .sbspf_account_invalid .sbspf_ca_alert {
397
+ display: inline-block;
398
+ }
399
+ #sbspf_admin .sbspf_ca_avatar{
400
+ float: left;
401
+ width: 40px;
402
+ height: 40px;
403
+ border-radius: 5px;
404
+ }
405
+ #sbspf_admin .sbspf_ca_accesstoken{
406
+ display: none;
407
+ width: 100%;
408
+ float: left;
409
+ clear: both;
410
+ margin-top: 10px;
411
+ }
412
+ #sbspf_admin .sbspf_ca_token_label{
413
+ display: inline-block;
414
+ position: relative;
415
+ background: #f9f9f9;
416
+ color: #555;
417
+ padding: 3px 5px;
418
+ font-size: 12px;
419
+ border: 1px solid #d6d6d6;
420
+ height: 16px;
421
+ line-height: 15px;
422
+ border-radius: 4px 0 0 4px;
423
+ min-width: 80px;
424
+ margin-bottom: 2px;
425
+ }
426
+ #sbspf_admin .sbspf_permissions_desc,
427
+ #sbspf_admin .sbspf_ca_token,
428
+ #sbspf_admin .sbspf_ca_refresh_token,
429
+ #sbspf_admin .sbspf_ca_user_id {
430
+ padding: 3px 10px;
431
+ }
432
+
433
+ #sbspf_admin .sbspf_ca_token,
434
+ #sbspf_admin .sbspf_ca_user_id,
435
+ #sbspf_admin .sbspf_ca_refresh_token{
436
+ position: relative;
437
+ top: 1px;
438
+ border: 1px solid #d6d6d6;
439
+ border-left: none;
440
+ font-size: 13px;
441
+ border-radius: 0 4px 4px 0;
442
+ background: rgba(255,255,255,0.8);
443
+ display: inline-block;
444
+ margin-left: 0;
445
+ }
446
+ #sbspf_admin .sbspf_ca_token {
447
+ width: 510px;
448
+ }
449
+ #sbspf_admin .sbspf_ca_accesstoken a.sbspf_ca_token_shortcode{
450
+ margin: 0 8px 8px;
451
+ padding: 6px;
452
+ height: auto;
453
+ line-height: 1;
454
+ }
455
+
456
+ #sbspf_admin .sbspf_delete_account{
457
+ position: absolute;
458
+ right: 10px;
459
+ top: 10px;
460
+
461
+ padding: 5px 10px;
462
+ background: rgba(0,0,0,0.05);
463
+ color: #666;
464
+ border-radius: 50px;
465
+ text-decoration: none;
466
+ font-size: 12px;
467
+ }
468
+ #sbspf_admin .sbspf_delete_account:hover,
469
+ #sbspf_admin .sbspf_delete_account:focus{
470
+ background: #333;
471
+ color: #ddd;
472
+ }
473
+ #sbspf_admin .sbspf_ca_delete a {
474
+ display: block;
475
+ height: 13px;
476
+ padding: 5px 6px;
477
+ }
478
+ #sbspf_admin .sbspf_ca_delete svg {
479
+ height: 12px;
480
+ line-height: 1;
481
+ padding-bottom: 2px;
482
+ }
483
+ #sbspf_admin .sbspf_delete_account .sbspf_remove_text{
484
+ margin-left: 5px;
485
+ }
486
+
487
+ .sbspf_connected_accounts_wrap{
488
+ vertical-align: top;
489
+ }
490
+ #sbspf_admin .sbspf_no_accounts{
491
+ display: inline-block;
492
+ padding: 4px 15px;
493
+ border-radius: 8px;
494
+ background: rgba(255,255,255,0.8);
495
+ margin-bottom: 3px;
496
+ }
497
+ #sbspf_admin #sbspf_manual_submit:active{
498
+ vertical-align: unset;
499
+ }
500
+ #sbspf_admin .sbspf_manually_connect_wrap{
501
+ padding-top: 5px;
502
+ }
503
+ #sbspf_admin .sbspf_user_feed_account_wrap:first-child,
504
+ #sbspf_admin .sbspf_tagged_feed_account_wrap:first-child{
505
+ padding-top: 5px;
506
+ }
507
+ #sbspf_admin .sbspf_user_feed_account_wrap:last-child,
508
+ #sbspf_admin .sbspf_tagged_feed_account_wrap:last-child{
509
+ padding-bottom: 6px;
510
+ }
511
+ #sbspf_admin .sbspf_user_feed_account_wrap,
512
+ #sbspf_admin .sbspf_tagged_feed_account_wrap{
513
+ padding-bottom: 5px;
514
+ padding-left: 2px;
515
+ }
516
+ #sbspf_admin .sbspf_user_feed_account_wrap span,
517
+ #sbspf_admin .sbspf_tagged_feed_account_wrap span{
518
+ font-size: 13px;
519
+ }
520
+ #sbspf_admin .sbspf_manual_account_id_toggle label{
521
+ display: block;
522
+ margin: 10px 0 0 0;
523
+ font-size: 13px;
524
+ }
525
+ #sbspf_admin .sbspf_business_profile_tag{
526
+ display: none;
527
+ padding: 8px 10px;
528
+ background: rgba(0,0,0,0.05);
529
+ border-radius: 0 5px 5px 0;
530
+ margin: 0 0 0 -2px;
531
+ font-size: 13px;
532
+ height: 15px;
533
+ line-height: 15px;
534
+ box-shadow: inset 0 0 1px rgba(0,0,0,.5);
535
+ }
536
+ #sbspf_admin .sbspf_ca_info{
537
+ overflow: hidden;
538
+ }
539
+ #sbspf_admin .sbspf_ca_show_token .fa,
540
+ #sbspf_admin .sbspf_ca_show_token svg{
541
+ margin-right: 0;
542
+ }
543
+ #sbspf_admin .sbspf_ca_show_token{
544
+ display: inline-block;
545
+ padding: 10px 5px 0px 5px;
546
+ margin: 0;
547
+ font-size: 12px;
548
+ vertical-align: top;
549
+ }
550
+ #sbspf_admin .sbspf_ca_shortcode{
551
+ display: none;
552
+ padding: 0;
553
+ width: 100%;
554
+ float: left;
555
+ clear: both;
556
+ margin: 10px 0 0 0;
557
+ }
558
+ #sbspf_admin .sbspf_ca_shortcode p{
559
+ padding-bottom: 10px;
560
+ font-size: 13px;
561
+ }
562
+ #sbspf_admin .sbspf_ca_shortcode code{
563
+ margin-top: 5px;
564
+ display: inline-block;
565
+ }
566
+ #sbspf_admin .sbspf_user_feed_ids_wrap .sbspf_ca_avatar{
567
+ width: 20px;
568
+ height: 20px;
569
+ position: relative;
570
+ top: 5px;
571
+ margin-right: 8px;
572
+ border-radius: 4px;
573
+ }
574
+
575
+
576
+ @media all and (max-width: 1200px){
577
+ #sbspf_admin .sbspf_delete_account .sbspf_remove_text{
578
+ display: none;
579
+ }
580
+ #sbspf_admin .sbspf_ca_token,
581
+ #sbspf_admin .sbspf_ca_user_id{
582
+ border-left: 1px solid #d6d6d6;
583
+ border-radius: 4px;
584
+ }
585
+ }
586
+ @media all and (max-width: 800px){
587
+ #sbspf_admin .sbspf_col.sbspf_one {
588
+ width: 25%;
589
+ margin-right: 5%;
590
+ }
591
+ #sbspf_admin .sbspf_col.sbspf_two{
592
+ width: 70%;
593
+ }
594
+ }
595
+ /* GDPR Settings */
596
+ #sbspf_admin .sby-list{
597
+ list-style: inside disc;
598
+ }
599
+ .gdpr_tooltip p{
600
+ padding: 0 0 10px 0;
601
+ }
602
+ .gdpr_tooltip span{
603
+ display: inline-block;
604
+ margin: 0;
605
+ font-weight: bold;
606
+ font-size: 14px;
607
+ }
608
+ .gdpr_tooltip .sby-list{
609
+ padding: 0 0 10px 0;
610
+ }
611
+ .gdpr_tooltip li{
612
+ padding: 0;
613
+ }
614
+ .sbspf_gdpr_plugin_active .sbspf_active{
615
+ display: inline-block;
616
+ padding: 10px 20px 15px 20px;
617
+ border-radius: 5px;
618
+ background: #edf4f0;
619
+ border: 1px solid #2c8649;
620
+ color: #2c8649;
621
+ margin: 8px 0 0 0;
622
+ }
623
+ .sbspf_gdpr_plugin_active svg{
624
+ width: 16px;
625
+ height: 16px;
626
+ position: relative;
627
+ top: 3px;
628
+ margin-right: 2px;
629
+ }
630
+ .sbspf_gdpr_plugin_active path{
631
+ fill: green;
632
+ }
633
+ .sbspf_gdpr_list,
634
+ .sbspf_gdpr_yes,
635
+ .sbspf_gdpr_no{
636
+ display: none;
637
+ }
638
+ #sbspf_admin .sbspf_gdpr_error{
639
+ padding: 10px 20px 15px 20px;
640
+ border-radius: 5px;
641
+ background: #F7E6E6;
642
+ border: 1px solid #BA7B7B;
643
+ color: #592626;
644
+ }
645
+ /* Configure */
646
+ #sbspf_config {
647
+ float: left;
648
+ width: 100%;
649
+ clear: both;
650
+ margin: 10px 0 10px 0;
651
+ }
652
+ #sbspf_config .sbspf_not_working {
653
+ position: relative;
654
+ top: 14px;
655
+ left: 15px;
656
+ }
657
+ /* Caching settings */
658
+ #sbspf_admin #sbspf-caching-time-settings{
659
+ display: inline-block;
660
+ }
661
+ #sbspf_admin .sbspf-caching-cron-options .submit{
662
+ display: inline-block;
663
+ margin: 0;
664
+ padding: 0;
665
+ }
666
+ #sbspf_admin .sbspf-caching-sched-notice{
667
+ font-size: 11px;
668
+ display: block;
669
+ width: 100%;
670
+ }
671
+ #sbspf_admin .sbspf-caching-sched-notice span{
672
+ color: green;
673
+ background: #e5eae1;
674
+ padding: 5px 10px;
675
+ border-radius: 5px;
676
+ border: 1px solid #ccd3c6;
677
+ display: inline-block;
678
+ }
679
+ #sbspf_admin .sbspf_cron_cache_opts .sbspf_row{
680
+ padding: 3px 0;
681
+ }
682
+ #sbspf_admin .sbspf_cron_cache_opts .sbspf_row label {
683
+ display: inline-block;
684
+ margin: 5px 2px 0 0;
685
+ }
686
+
687
+ /* Layout */
688
+ .form-table .sbspf_layout_type {
689
+ display: inline-block;
690
+ margin-left: 20px;
691
+ }
692
+ .form-table .sbspf_layout_type:first-child {
693
+ margin-left: 0;
694
+ }
695
+ .sbspf_layout_setting,
696
+ .sbspf_sub_option_setting{
697
+ margin-bottom: 20px;
698
+ }
699
+ .sbspf_layout_setting:last-child,
700
+ .sbspf_box_setting:last-child,
701
+ .sbspf_sub_option_setting:last-child{
702
+ margin-bottom: 0;
703
+ }
704
+ .sbspf_layout_setting label,
705
+ .sbspf_box_setting label {
706
+ display: inline-block;
707
+ font-weight: bold;
708
+ font-size: 14px;
709
+ padding-bottom: 5px;
710
+ padding-right: 5px;
711
+ }
712
+ #sbspf_admin .sbspf_layout_options_wrap .sbspf_shortcode_symbol{
713
+ bottom: 4px;
714
+ right: -20px;
715
+ }
716
+ #sbspf_admin .sbspf_layout_options_wrap .sbspf_shortcode,
717
+ #sbspf_admin .sbspf_box_setting .sbspf_shortcode{
718
+ position: relative;
719
+ float: none;
720
+ top: -4px
721
+ }
722
+ .sbspf_layout_cell,
723
+ .sbspf_sub_option_cell{
724
+ padding: 0;
725
+ display: inline-block;
726
+ float: left;
727
+ width: 155px;
728
+ padding: 15px 15px 10px 15px;
729
+ margin-right: 10px;
730
+ margin-bottom: 10px;
731
+ background: #f6f6f6;
732
+ border: 1px solid #ddd;
733
+ -moz-border-radius: 5px;
734
+ -webkit-border-radius: 5px;
735
+ border-radius: 5px;
736
+ vertical-align: top;
737
+ }
738
+ .sbspf_layout_cell:nth-child(4) {
739
+ margin-right: 0;
740
+ }
741
+ @media all and (max-width: 1200px){
742
+ .sbspf_layout_cell,
743
+ .sbspf_sub_option_cell{
744
+ width: 21%;
745
+ padding: 1%;
746
+ margin-right: 1%;
747
+ }
748
+ .sbspf_sub_option_cell {
749
+ width: 30%;
750
+ }
751
+ }
752
+ @media all and (max-width: 480px){
753
+ .sbspf_layout_cell,
754
+ .sbspf_sub_option_cell{
755
+ width: 98%;
756
+ padding: 1%;
757
+ margin: 5px 0;
758
+ }
759
+ }
760
+ .sbspf_label {
761
+ font-size: 16px;
762
+ font-weight: bold;
763
+ padding-left: 2px;
764
+ }
765
+ .sbspf_layout_cell:hover,
766
+ .sbspf_layout_cell:focus,
767
+ .sbspf_sub_option_cell:hover,
768
+ .sbspf_sub_option_cell:focus{
769
+ background: #fcfcfc;
770
+ cursor: pointer;
771
+ }
772
+ .sbspf_layout_cell.sbspf_layout_selected,
773
+ .sbspf_sub_option_cell.sbspf_sub_option_selected{
774
+ background: #f7faf1;
775
+ border: 1px solid #7ad03a;
776
+ }
777
+ .sbspf_layout_cell h3
778
+ .sbspf_sub_option_cell h3 {
779
+ font-size: 15px;
780
+ margin-top: 0;
781
+ }
782
+ .sbspf_layout_cell img,
783
+ .sbspf_sub_option_cell img {
784
+ width: 100%;
785
+ border: 1px solid #ddd;
786
+ margin-top: 5px;
787
+ }
788
+ .sbspf_box {
789
+ margin-top: 10px;
790
+ margin-bottom: 5px;
791
+ }
792
+ #sbspf_admin .sbspf_layout_settings,
793
+ #sbspf_admin .sbspf_sub_option_settings,
794
+ .sbspf_box_setting{
795
+ float: left;
796
+ clear: both;
797
+ width: 96%;
798
+ max-width: 700px;
799
+
800
+ padding: 15px;
801
+ margin: 0 0 10px 0;
802
+ font-size: 13px;
803
+ background: #f9f9f9;
804
+ background: rgba(255,255,255,0.8);
805
+
806
+ -moz-border-radius: 8px;
807
+ -webkit-border-radius: 8px;
808
+ border-radius: 8px;
809
+ }
810
+ .sbspf_layout_setting,
811
+ .sbspf_sub_option_setting{
812
+ clear:left;
813
+ margin-bottom: 20px;
814
+ }
815
+ #sbspf_admin .sbspf_layout_options_wrap .sbspf-tooltip,
816
+ #sbspf_admin .sbspf_box_setting .sbspf-tooltip{
817
+ width: 98%;
818
+ padding: 10px 1%;
819
+ background: #eee;
820
+ background: rgba(0,0,0,0.05);
821
+ }
822
+ #sbspf_admin .sbspf_layout_mobile_layout_setting {
823
+ width: auto;
824
+ }
825
+
826
+
827
+ /* Display Tab */
828
+ #sbspf_admin table.sbspf_shortcode_table{
829
+ border-collapse: collapse;
830
+ }
831
+ #sbspf_admin table.sbspf_shortcode_table th,
832
+ #sbspf_admin table.sbspf_shortcode_table td{
833
+ border: 1px solid #999;
834
+ padding: 0.5rem;
835
+ text-align: left;
836
+ }
837
+ #sbspf_admin table.sbspf_shortcode_table th{
838
+ background: rgba(0,0,0,0.1);
839
+ }
840
+ #sbspf_admin table.sbspf_shortcode_table td{
841
+ background: rgba(255,255,255,0.5);
842
+ }
843
+ #sbspf_admin .sbspf_table_header{
844
+ background: #ddd;
845
+ font-weight: bold;
846
+ }
847
+
848
+ /* Modal */
849
+
850
+ #sbspf_modal_overlay{
851
+ position: fixed;
852
+ z-index: 999;
853
+ width: 100%;
854
+ top: 0;
855
+ right: 0;
856
+ bottom: 0;
857
+ left: 0;
858
+
859
+ background: rgba(0,0,0,0.3);
860
+ }
861
+ #sbspf_modal_overlay .sbspf_modal{
862
+ position: absolute;
863
+ top: 160px;
864
+ left: 50%;
865
+ width: 450px;
866
+
867
+ margin: 0 0 0 -230px;
868
+ padding: 20px 30px;
869
+ background: #fff;
870
+
871
+ -webkit-box-shadow: 0 1px 20px rgba(0,0,0,0.2);
872
+ box-shadow: 0 1px 20px rgba(0,0,0,0.2);
873
+
874
+ -moz-border-radius: 3px;
875
+ -webkit-border-radius: 3px;
876
+ border-radius: 3px;
877
+ }
878
+ #sbspf_modal_overlay .sbspf_modal p{
879
+ margin: 8px 0;
880
+ }
881
+ #sbspf_modal_overlay .sbspf_modal .sbspf_submit{
882
+ margin-top: 20px;
883
+ }
884
+ #sbspf_modal_overlay .sbspf_modal .heading{
885
+ font-weight: 500;
886
+ font-size: 15px;
887
+ }
888
+ @media all and (max-width: 480px){
889
+ #sbspf_modal_overlay .sbspf_modal{
890
+ max-width: 100%;
891
+ margin: 0 0 0 -50%;
892
+ box-sizing: border-box;
893
+ }
894
+ }
895
+ .sbspf_emphasis {
896
+ display: block;
897
+ font-size: 16px;
898
+ text-align: center;
899
+ margin-bottom: 20px;
900
+ }
901
+ .sbspf_emphasis svg {
902
+ height: 14px;
903
+ }
904
+ .sbspf_modal_message h3 {
905
+ font-size: 14px;
906
+ }
907
+ .sbspf_modal .sbspf_modal_close{
908
+ position: absolute;
909
+ top: 0;
910
+ right: 0;
911
+ padding: 10px;
912
+ font-size: 14px;
913
+ color: #ccc;
914
+ margin: 0;
915
+ }
916
+ .sbspf_modal .sbspf_modal_close:focus,
917
+ .sbspf_modal .sbspf_modal_close:hover{
918
+ color: #333;
919
+ }
920
+ /* Pro only notices */
921
+ #sbspf_admin .sbspf_sub_options,
922
+ #sbspf_admin .sbspf_layout_cell,
923
+ #sbspf_admin .sbspf_layout_settings,
924
+ #sbspf_admin .sbspf_disabled_wrap{
925
+ position: relative;
926
+ }
927
+ #sbspf_admin .sbspf_sub_options:after,
928
+ #sbspf_admin .sbspf_disabled_wrap,
929
+ .sbspf_box:after{
930
+ clear: both;
931
+ display: table;
932
+ content: ""
933
+ }
934
+ #sbspf_admin .sbspf_disabled_wrap{
935
+ width: 100%;
936
+ max-width: 520px;
937
+ }
938
+ #sbspf_admin .sby_includes_pro_only .sbspf_pro_tooltip {
939
+ top: 50%;
940
+ left: 30px;
941
+ bottom: auto;
942
+ margin-top: -96px;
943
+ }
944
+ #sbspf_admin .sbspf-show-pro{
945
+ margin-top: 10px;
946
+ text-align: center;
947
+ }
948
+ .sbspf_layout_cell.sbspf_pro_only .sbspf_lock{
949
+ margin-top: -4px;
950
+ }
951
+ #sbspf_admin .sbspf_layout_cell.sbspf_pro_only .sbspf_pro_tooltip {
952
+ margin-top: -38px;
953
+ left: 54px;
954
+ }
955
+ #sbspf_admin .sbspf_pro_only,
956
+ #sbspf_admin .sbspf_pro_only label,
957
+ #sbspf_admin .sbspf_pro_only input,
958
+ #sbspf_admin .sbspf_pro_only select,
959
+ #sbspf_admin .sbspf_pro_only_row,
960
+ #sbspf_admin .sbspf_pro_only_row label,
961
+ #sbspf_admin .sbspf_pro_only_row input,
962
+ #sbspf_admin .sbspf_pro_only_row select{
963
+ color: #999 !important;
964
+ }
965
+ #sbspf_admin tr.sbspf_pro_only{
966
+ background: #eacccc;
967
+ }
968
+ #sbspf_admin .sbspf_type_row.sbspf_pro_only input[type=text]{
969
+ opacity: 0.5;
970
+ background: white;
971
+ }
972
+ .sbspf_lock.sbspf_pro_lock {
973
+ background: rgba(255,255,255,0.8);
974
+ color: #666;
975
+ border: 1px solid #ccc;
976
+ margin-right: -34px;
977
+ }
978
+ .sbspf_lock.sbspf_pro_lock i {
979
+ margin-right: 8px;
980
+ }
981
+ #sbspf_admin .sbspf_pro_lock:hover,
982
+ #sbspf_admin .sbspf_pro_lock:hover{
983
+ background: #fff;
984
+ border: 1px solid #ccc;
985
+ color: #333;
986
+ box-shadow: 0 0 8px 0 rgba(0,0,0,0.15);
987
+ }
988
+ #sbspf_admin .sbspf_pro_tooltip{
989
+ text-align: center;
990
+ z-index:99;
991
+ display: none;
992
+ position: absolute;
993
+ bottom: 22px;
994
+ left: -8px;
995
+
996
+ background: #333;
997
+ color: #eee;
998
+ width: 90%;
999
+ padding: 8px 10px 10px 10px;
1000
+ border-radius: 3px;
1001
+ line-height: 1.3;
1002
+ font-size: 12px;
1003
+ width: 190px;
1004
+ }
1005
+ #sbspf_admin .sbspf_pro_tooltip .fa-caret-down {
1006
+ position: absolute;
1007
+ bottom: -12px;
1008
+ font-size: 20px;
1009
+ left: 49%;
1010
+ color: #333;
1011
+ }
1012
+ #sbspf_admin .sbspf_layouts .sbspf_pro_tooltip,
1013
+ #sbspf_admin .sbspf_sub_options .sbspf_pro_tooltip{
1014
+ left: 284px;
1015
+ top: -21px;
1016
+ bottom: auto;
1017
+ margin-left: -101px;
1018
+ }
1019
+ #sbspf_admin .sbspf_layouts .sbspf_layout_cell .sbspf_pro_tooltip{
1020
+ left: 84px;
1021
+ top: 32px;
1022
+ }
1023
+ #sbspf_admin .sbspf_table_key{
1024
+ display: block;
1025
+ float: left;
1026
+ width: 11px;
1027
+ height: 11px;
1028
+ border: 1px solid #999;
1029
+ background: #eacccc;
1030
+ margin: 3px 6px 0 0;
1031
+ }
1032
+
1033
+ /* SBY Specific */
1034
+ #sbspf_admin .sby_mode_option {
1035
+ position: relative;
1036
+ margin-bottom: 20px;
1037
+ }
1038
+ #sbspf_admin .sby_mode_option label {
1039
+ display: inline-block;
1040
+ font-weight: bold;
1041
+ }
1042
+ #sbspf_admin .sby_mode_option .sbspf_note {
1043
+ display: block;
1044
+ margin-left: 0;
1045
+ }
1046
+ #sbspf_admin .sby_mode_option .sbspf_note,
1047
+ #sbspf_admin .sby_mode_option label {
1048
+ margin-bottom: 5px;
1049
+ }
1050
+ #sbspf_admin .sby_mode_option input[type=radio] {
1051
+ position: absolute;
1052
+ top: 6px;
1053
+ }
1054
+ #sbspf_admin .sby_mode_option_text {
1055
+ margin-left: 22px;
1056
+ }
1057
+ #sbspf_admin .sby_mode_option.sbspf_fade .sby_important,
1058
+ #sbspf_admin .sby_mode_option.sbspf_fade .sbspf_note {
1059
+ opacity: 1;
1060
+ }
1061
+
1062
+ /* Notices */
1063
+ .sby_includes_pro_only .sbspf_lock {
1064
+ left: 100px;
1065
+ right: auto;
1066
+ margin-top: -40px;
1067
+ }
1068
+ .sbspf_sub_options .sbspf_lock {
1069
+ top: 38px;
1070
+ left: 260px;
1071
+ right: auto;
1072
+ }
1073
+ .sby_types_disabled_wrap .sbspf_lock {
1074
+ margin-top: -20px;
1075
+ }
1076
+ #sbspf_admin .sby_types_disabled_wrap .sbspf_pro_tooltip {
1077
+ top: 50%;
1078
+ margin-left: -112px;
1079
+ margin-top: -78px;
1080
+ bottom: auto;
1081
+ left: 50%;
1082
+ }
1083
+ @media screen and (max-width: 480px) {
1084
+ .sbspf_sub_options .sbspf_lock {
1085
+ top: 60px;
1086
+ left: 50%;
1087
+ margin-left: -40px;
1088
+ right: auto;
1089
+ }
1090
+ #sbspf_admin .sbspf_sub_options .sbspf_pro_tooltip {
1091
+ top: 0px;
1092
+ left: 50%;
1093
+ margin-left: -112px;
1094
+ }
1095
+ }
1096
+
1097
+ /* Lite Notice */
1098
+ @media screen and (max-width: 600px) {
1099
+ #sbspf-notice-bar {
1100
+ display:none !important
1101
+ }
1102
+ }
1103
+
1104
+ #sbspf-notice-bar {
1105
+ background-color: #DDDDDD;
1106
+ color: #777777;
1107
+ text-align: center;
1108
+ position: relative;
1109
+ padding: 7px;
1110
+ margin-bottom: 0;
1111
+ opacity: 1;
1112
+ transition: all .3s ease-in-out;
1113
+ max-height: 100px;
1114
+ overflow: hidden
1115
+ }
1116
+
1117
+ #sbspf-notice-bar.out {
1118
+ opacity: .5;
1119
+ max-height: 0
1120
+ }
1121
+
1122
+ #sbspf-notice-bar a {
1123
+ color: #e34f0e;
1124
+ }
1125
+
1126
+ #sbspf-notice-bar a:hover {
1127
+ color: #b85a1b
1128
+ }
1129
+
1130
+ #sbspf-notice-bar .dismiss {
1131
+ position: absolute;
1132
+ top: 0;
1133
+ right: 0;
1134
+ border: none;
1135
+ padding: 5px;
1136
+ margin-top: 1px;
1137
+ background: 0 0;
1138
+ color: #72777c;
1139
+ cursor: pointer
1140
+ }
1141
+
1142
+ #sbspf-notice-bar .dismiss:before {
1143
+ background: 0 0;
1144
+ color: #72777c;
1145
+ content: "\f335";
1146
+ display: block;
1147
+ font: normal 20px/20px dashicons;
1148
+ speak: none;
1149
+ height: 20px;
1150
+ text-align: center;
1151
+ width: 20px;
1152
+ -webkit-font-smoothing: antialiased
1153
  }
css/sb-youtube.css CHANGED
@@ -1,1355 +1,1394 @@
1
- /**************/
2
- /*** LAYOUT ***/
3
- /**************/
4
-
5
- /* Feed container */
6
- [id^=sb_youtube_].sb_youtube {
7
- width: 100%;
8
- margin: 0 auto;
9
- padding: 0;
10
- -webkit-box-sizing: border-box;
11
- -moz-box-sizing: border-box;
12
- box-sizing: border-box;
13
- }
14
- [id^=sb_youtube_].sb_youtube * {
15
- -webkit-box-sizing: border-box;
16
- -moz-box-sizing: border-box;
17
- box-sizing: border-box
18
- }
19
- [id^=sb_youtube_].sb_youtube:after{
20
- content: "";
21
- display: table;
22
- clear: both;
23
- }
24
- [id^=sb_youtube_].sb_youtube iframe,
25
- #sby_lightbox iframe{
26
- pointer-events: all !important;
27
- }
28
-
29
- /*********************/
30
- /*** STYLE OPTIONS ***/
31
- /*********************/
32
- [id^=sb_youtube_].sb_youtube.sby_fixed_height{
33
- overflow: hidden;
34
- overflow-y: auto;
35
- -webkit-box-sizing: border-box;
36
- -moz-box-sizing: border-box;
37
- box-sizing: border-box;
38
- }
39
- [id^=sb_youtube_].sb_youtube .sby_items_wrap{
40
- width: 100%;
41
- float: left;
42
- line-height: 0;
43
-
44
- -webkit-box-sizing: border-box;
45
- -moz-box-sizing: border-box;
46
- box-sizing: border-box;
47
- }
48
-
49
- /* Items */
50
- [id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item,
51
- [id^=sb_youtube_].sb_youtube .sby_player_outer_wrap .sby_video_thumbnail_wrap,
52
- [id^=sb_youtube_].sb_youtube .sby_player_wrap{
53
- display: -moz-inline-stack;
54
- display: inline-block;
55
- vertical-align: top;
56
- zoom: 1;
57
- *display: inline;
58
-
59
- max-height: 1000px;
60
- padding: inherit !important;
61
- text-decoration: none;
62
- opacity: 1;
63
- overflow: hidden;
64
-
65
- -webkit-box-sizing: border-box;
66
- -moz-box-sizing: border-box;
67
- box-sizing: border-box;
68
-
69
- -webkit-transition: all 0.5s ease;
70
- -moz-transition: all 0.5s ease;
71
- -o-transition: all 0.5s ease;
72
- -ms-transition: all 0.5s ease;
73
- transition: all 0.5s ease;
74
- }
75
- [id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item.sby_no_margin {
76
- margin: 0 !important;
77
- }
78
- [id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item {
79
- float: left;
80
- }
81
- /* Transition items in */
82
- [id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item.sby_transition{
83
- opacity: 0;
84
- max-height: 0;
85
- }
86
-
87
- /* Cols */
88
- [id^=sb_youtube_].sb_youtube.sby_col_0 .sby_items_wrap .sby_item{ width: 100%; }
89
- [id^=sb_youtube_].sb_youtube.sby_col_1 .sby_items_wrap .sby_item{ width: 100%; }
90
- [id^=sb_youtube_].sb_youtube.sby_col_2 .sby_items_wrap .sby_item{ width: 50%; }
91
- [id^=sb_youtube_].sb_youtube.sby_col_3 .sby_items_wrap .sby_item{ width: 33.33%; }
92
- [id^=sb_youtube_].sb_youtube.sby_col_4 .sby_items_wrap .sby_item{ width: 25%; }
93
- [id^=sb_youtube_].sb_youtube.sby_col_5 .sby_items_wrap .sby_item{ width: 20%; }
94
- [id^=sb_youtube_].sb_youtube.sby_col_6 .sby_items_wrap .sby_item{ width: 16.66%; }
95
- [id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item{ width: 14.28%; }
96
- [id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item{ width: 12.5%; }
97
- [id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item{ width: 11.11%; }
98
- [id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item{ width: 10%; }
99
-
100
- /* Disable mobile layout */
101
- /*
102
- [id^=sb_youtube_].sb_youtube.sby_col_1.sby_disable_mobile .sby_items_wrap .sby_item{ width: 100%; }
103
- [id^=sb_youtube_].sb_youtube.sby_col_2.sby_disable_mobile .sby_items_wrap .sby_item{ width: 50%; }
104
- [id^=sb_youtube_].sb_youtube.sby_col_3.sby_disable_mobile .sby_items_wrap .sby_item{ width: 33.33%; }
105
- [id^=sb_youtube_].sb_youtube.sby_col_4.sby_disable_mobile .sby_items_wrap .sby_item{ width: 25%; }
106
- [id^=sb_youtube_].sb_youtube.sby_col_5.sby_disable_mobile .sby_items_wrap .sby_item{ width: 20%; }
107
- [id^=sb_youtube_].sb_youtube.sby_col_6.sby_disable_mobile .sby_items_wrap .sby_item{ width: 16.66%; }
108
- [id^=sb_youtube_].sb_youtube.sby_col_7.sby_disable_mobile .sby_items_wrap .sby_item{ width: 14.28%; }
109
- [id^=sb_youtube_].sb_youtube.sby_col_8.sby_disable_mobile .sby_items_wrap .sby_item{ width: 12.5%; }
110
- [id^=sb_youtube_].sb_youtube.sby_col_9.sby_disable_mobile .sby_items_wrap .sby_item{ width: 11.11%; }
111
- [id^=sb_youtube_].sb_youtube.sby_col_10.sby_disable_mobile .sby_items_wrap .sby_item{ width: 10%; }
112
- */
113
- /* Photos */
114
- .sby-screenreader{text-indent: -9999px !important;display: block !important;width: 0 !important;height: 0 !important;line-height: 0 !important;}
115
- [id^=sb_youtube_].sb_youtube .sby_video_thumbnail_wrap,
116
- [id^=sb_youtube_].sb_youtube .sby_player_outer_wrap {
117
- width: 100%;
118
- position: relative;
119
- float: left;
120
- }
121
- [id^=sb_youtube_].sb_youtube .sby_video_thumbnail{
122
- display: block;
123
- position: relative;
124
- text-decoration: none;
125
- line-height: 0;
126
- z-index: 5;
127
- }
128
- [id^=sb_youtube_].sb_youtube .sby_video_thumbnail img{
129
- width: 100%;
130
- height: auto;
131
- border-radius: 0;
132
- }
133
- [id^=sb_youtube_].sb_youtube .sby_link{
134
- display: none;
135
- position: absolute;
136
- z-index: 1;
137
- top: 0;
138
- right: 0;
139
- bottom: 0;
140
- left: 0;
141
-
142
- width: 100%;
143
- padding: 0;
144
- background: #333;
145
- background: rgba(0,0,0,0.6);
146
- text-align: center;
147
- color: #fff;
148
- font-size: 12px;
149
- line-height: 1.1;
150
- overflow: hidden;
151
- }
152
- [id^=sb_youtube_].sb_youtube .sby_link.sby_default p,
153
- [id^=sb_youtube_].sb_youtube .sby_link.sby_default span,
154
- [id^=sb_youtube_].sb_youtube .sby_link.sby_default a{
155
- text-shadow: 0px 0px 10px #000;
156
- }
157
- [id^=sb_youtube_].sb_youtube .sby_link .sby_username a,
158
- [id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link,
159
- [id^=sb_youtube_].sb_youtube .sby_link .sby_hover_bottom,
160
- [id^=sb_youtube_].sb_youtube .sby_link .sby_playbtn,
161
- [id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link,
162
- [id^=sb_youtube_].sb_youtube .sby_link .svg-inline--fa.fa-play{
163
- filter: alpha(opacity=90);
164
- opacity: 0.9;
165
- }
166
- [id^=sb_youtube_].sb_youtube .sby_link .sby_username a:hover,
167
- [id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link:hover,
168
- [id^=sb_youtube_].sb_youtube .sby_link .sby_playbtn:hover,
169
- [id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link:hover,
170
- [id^=sb_youtube_].sb_youtube .sby_link .svg-inline--fa.fa-play:hover{
171
- filter: alpha(opacity=100);
172
- opacity: 1;
173
- }
174
- [id^=sb_youtube_].sb_youtube .sby_link_area{
175
- position: absolute;
176
- top: 0;
177
- right: 0;
178
- bottom: 0;
179
- left: 0;
180
- z-index: 1;
181
- }
182
-
183
- [id^=sb_youtube_].sb_youtube .sby_link a{
184
- padding: 0;
185
- text-decoration: none;
186
- color: #ddd;
187
- color: rgba(255,255,255,0.7);
188
- line-height: 1.1;
189
- background: none;
190
-
191
- display: -moz-inline-stack;
192
- display: inline-block;
193
- vertical-align: top;
194
- zoom: 1;
195
- *display: inline;
196
- }
197
- [id^=sb_youtube_].sb_youtube .sby_link a:hover,
198
- [id^=sb_youtube_].sb_youtube .sby_link a:active{
199
- color: #fff;
200
- }
201
-
202
- [id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link{
203
- display: block;
204
- /*display: none;*/
205
- position: absolute;
206
- z-index: 2;
207
- top: 50%;
208
- left: 50%;
209
-
210
- margin-top: -24px;
211
- margin-left: -21px;
212
- padding: 0;
213
- font-size: 49px;
214
- font-style: normal !important;
215
- }
216
- [id^=sb_youtube_].sb_youtube .sby_type_video .sby_lightbox_link,
217
- [id^=sb_youtube_].sb_youtube .sby_carousel_vid_first .sby_lightbox_link{
218
- display: none;
219
- }
220
-
221
- [id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link{
222
- /*float: right;*/
223
- font-size: 30px;
224
- position: absolute;
225
- z-index: 100;
226
- bottom: 0;
227
- right: 2px;
228
- padding: 8px;
229
- }
230
- [id^=sb_youtube_].sb_youtube .sby_link a:hover,
231
- [id^=sb_youtube_].sb_youtube .sby_link a:focus{
232
- text-decoration: underline;
233
- }
234
-
235
- /* Player */
236
- [id^=sb_youtube_].sb_youtube .sby_player_wrap {
237
- z-index: 1;
238
- width: 100% !important;
239
- height: 100% !important;
240
- position: absolute;
241
- top: 0;
242
- left: 0;
243
- }
244
- [id^=sb_youtube_].sb_youtube .sby_player_wrap iframe {
245
- width: 100% !important;
246
- height: 100% !important;
247
- }
248
-
249
- /* Use CSS for lightbox fade instead of JS */
250
- [id^=sb_youtube_].sb_youtube .sby_thumbnail_hover {
251
- opacity: 0;
252
- display: block;
253
- position: absolute;
254
- top: 0;
255
- right: 0;
256
- bottom: 0;
257
- left: 0;
258
- z-index: 10;
259
- color: #fff;
260
- background: #333;
261
- background: rgba(0,0,0,.6);
262
- transition: opacity .6s ease-in-out;
263
- -moz-transition: opacity .6s ease-in-out;
264
- -webkit-transition: opacity .6s ease-in-out;
265
- }
266
- [id^=sb_youtube_].sb_youtube.sby_layout_list .sby_thumbnail_hover {
267
- display: none;
268
- }
269
- .sby_video_title {
270
- display: inline-block;
271
- height: 100%;
272
- padding: 10px;
273
- overflow: hidden;
274
- font-size: 13px;
275
- line-height: 1.2;
276
- }
277
- [id^=sb_youtube_].sb_youtube .sby_video_thumbnail:hover .sby_thumbnail_hover {
278
- opacity: 1;
279
- display: block;
280
- transition: opacity .2s ease-in-out;
281
- -moz-transition: opacity .2s ease-in-out;
282
- -webkit-transition: opacity .2s ease-in-out;
283
- }
284
- [id^=sb_youtube_].sb_youtube.sby_layout_list .sby_video_thumbnail:hover .sby_thumbnail_hover {
285
- opacity: 0;
286
- display: none;
287
- transition: none;
288
- -moz-transition: none;
289
- -webkit-transition: none;
290
- }
291
-
292
- /* Play Button */
293
- [id^=sb_youtube_].sb_youtube .sby_video_thumbnail:hover .sby_play_btn {
294
- opacity: .5;
295
- }
296
- [id^=sb_youtube_].sb_youtube .sby_play_btn {
297
- position: absolute;
298
- z-index: 1;
299
- left: 50%;
300
- bottom: 50%;
301
- top: 50%;
302
- right: 50%;
303
- margin-top: -25px;
304
- margin-left: -28px;
305
- color: #fff;
306
- width: 57px;
307
- height: 50px;
308
- opacity: 1;
309
- transition: opacity .2s ease-in-out;
310
- -moz-transition: opacity .2s ease-in-out;
311
- -webkit-transition: opacity .2s ease-in-out;
312
- }
313
- [id^=sb_youtube_].sb_youtube .sby_play_btn_bg {
314
- display: block;
315
- position: absolute;
316
- z-index: -1;
317
- top: 17px;
318
- left: 22px;
319
- width: 0;
320
- height: 0;
321
- border: 0 solid transparent;
322
- border-bottom-width: 9px;
323
- border-top-width: 9px;
324
- border-left: 16px solid #fff;
325
- }
326
- [id^=sb_youtube_].sb_youtube .sby_play_btn svg:not(:root).svg-inline--fa{
327
- width: 57px;
328
- height: auto;
329
- opacity: 0.75;
330
- }
331
-
332
- [id^=sb_youtube_].sb_youtube .sby_play_btn svg,
333
- [id^=sb_youtube_].sb_youtube .sby_play_btn i{
334
- color: #000;
335
- }
336
- /* Medium */
337
- [id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn {
338
- margin-top: -20px;
339
- margin-left: -22px;
340
- width: 45px;
341
- height: 40px;
342
- }
343
- [id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn_bg {
344
- top: 13px;
345
- left: 18px;
346
- border-bottom-width: 7px;
347
- border-top-width: 7px;
348
- border-left: 12px solid #fff;
349
- }
350
- [id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn svg:not(:root).svg-inline--fa{
351
- width: 45px;
352
- }
353
-
354
- /* Small */
355
- [id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn{
356
- margin-top: -16px;
357
- margin-left: -18px;
358
- width: 36px;
359
- height: 32px;
360
- }
361
- [id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn_bg {
362
- top: 10px;
363
- left: 14px;
364
- border-bottom-width: 6px;
365
- border-top-width: 6px;
366
- border-left: 10px solid #fff;
367
- }
368
- [id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn svg:not(:root).svg-inline--fa{
369
- width: 36px;
370
- }
371
-
372
- /* Loader */
373
- [id^=sb_youtube_].sb_youtube .sby_loader{
374
- width: 20px;
375
- height: 20px;
376
-
377
- position: relative;
378
- top: 50%;
379
- left: 50%;
380
- margin: -10px 0 0 -10px;
381
- background-color: #000;
382
- background-color: rgba(0,0,0,0.5);
383
-
384
- border-radius: 100%;
385
- -webkit-animation: sby-sk-scaleout 1.0s infinite ease-in-out;
386
- animation: sby-sk-scaleout 1.0s infinite ease-in-out;
387
- }
388
- [id^=sb_youtube_].sb_youtube .sb_youtube_header br,
389
- [id^=sb_youtube_].sb_youtube .sby_items_wrap br,
390
- [id^=sb_youtube_].sb_youtube .sby_footer br{
391
- display: none;
392
- }
393
- .sby_footer p {
394
- display: inline;
395
- padding: 0;
396
- margin: 0;
397
- }
398
- /* Loader in button */
399
- [id^=sb_youtube_].sb_youtube .sby_footer .sby_loader,
400
- [id^=sb_youtube_].sb_youtube .sby_item .sby_loader,
401
- [id^=sb_youtube_].sb_youtube .sby_player_outer_wrap .sby_loader{
402
- position: absolute;
403
- margin-top: -11px;
404
- background-color: #fff;
405
- }
406
- [id^=sb_youtube_].sb_youtube .sby_item.sby_player_loading,
407
- [id^=sb_youtube_].sb_youtube .sby_player_outer_wrap.sby_player_loading {
408
- opacity: .8;
409
- }
410
- @-webkit-keyframes sby-sk-scaleout {
411
- 0% { -webkit-transform: scale(0) }
412
- 100% {
413
- -webkit-transform: scale(1.0);
414
- opacity: 0;
415
- }
416
- }
417
- @keyframes sby-sk-scaleout {
418
- 0% {
419
- -webkit-transform: scale(0);
420
- -ms-transform: scale(0);
421
- transform: scale(0);
422
- } 100% {
423
- -webkit-transform: scale(1.0);
424
- -ms-transform: scale(1.0);
425
- transform: scale(1.0);
426
- opacity: 0;
427
- }
428
- }
429
-
430
- [id^=sb_youtube_].sb_youtube .fa-spin,
431
- #sby_lightbox .fa-spin{
432
- -webkit-animation: fa-spin 2s infinite linear;
433
- animation: fa-spin 2s infinite linear
434
- }
435
-
436
- [id^=sb_youtube_].sb_youtube .fa-pulse,
437
- #sby_lightbox .fa-pulse{
438
- -webkit-animation: fa-spin 1s infinite steps(8);
439
- animation: fa-spin 1s infinite steps(8)
440
- }
441
-
442
- @-webkit-keyframes fa-spin {
443
- 0% {
444
- -webkit-transform: rotate(0deg);
445
- transform: rotate(0deg)
446
- }
447
- 100% {
448
- -webkit-transform: rotate(359deg);
449
- transform: rotate(359deg)
450
- }
451
- }
452
-
453
- @keyframes fa-spin {
454
- 0% {
455
- -webkit-transform: rotate(0deg);
456
- transform: rotate(0deg)
457
- }
458
- 100% {
459
- -webkit-transform: rotate(359deg);
460
- transform: rotate(359deg)
461
- }
462
- }
463
-
464
- /* HEADER */
465
- [id^=sb_youtube_].sb_youtube .sb_youtube_header{
466
- float: left;
467
- clear: both;
468
- margin: 0 0 15px 0;
469
- padding: 0;
470
- line-height: 1.2;
471
- width: 100%;
472
- }
473
- [id^=sb_youtube_].sb_youtube .sb_youtube_header a{
474
- float: left;
475
- display: block;
476
- /*width: 100%;*/
477
- min-width: 100%\9;
478
- text-decoration: none;
479
- transition: color 0.5s ease;
480
- }
481
- /** Medium Header */
482
- /* Only use medium & large headers on devices above 480px */
483
- @media all and (min-width: 480px){
484
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_img {
485
- width: 80px;
486
- height: 80px;
487
- border-radius: 40px;
488
- }
489
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_img img {
490
- width: 80px;
491
- height: 80px;
492
- border-radius: 40px;
493
- }
494
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3 {
495
- font-size: 20px;
496
- }
497
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info,
498
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio{
499
- font-size: 14px;
500
- }
501
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3,
502
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info,
503
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio{
504
- margin-left: 95px !important;
505
- line-height: 1.4
506
- }
507
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3{
508
- margin-right: -85px !important;
509
- }
510
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info{
511
- margin-top: 4px !important;
512
- }
513
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text.sby_no_bio h3{
514
- padding-top: 20px !important;
515
- }
516
- /** Large Header */
517
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_img {
518
- width: 120px;
519
- height: 120px;
520
- border-radius: 60px;
521
- }
522
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_img img {
523
- width: 120px;
524
- height: 120px;
525
- border-radius: 60px;
526
- }
527
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3 {
528
- font-size: 28px;
529
- }
530
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info,
531
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio{
532
- font-size: 16px;
533
- }
534
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3,
535
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info,
536
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio{
537
- margin-left: 140px !important;
538
- line-height: 1.5;
539
- }
540
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3{
541
- margin-right: -120px !important;
542
- }
543
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info{
544
- margin-top: 12px !important;
545
- }
546
- [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text.sby_no_bio h3{
547
- padding-top: 32px !important;
548
- }
549
- }
550
-
551
- /* Header profile pic */
552
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img{
553
- float: left;
554
- position: relative;
555
- width: 50px;
556
- margin: 0 0 0 -100% !important;
557
- overflow: hidden;
558
-
559
- -moz-border-radius: 40px;
560
- -webkit-border-radius: 40px;
561
- border-radius: 40px;
562
- }
563
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img img{
564
- float: left;
565
- margin: 0 !important;
566
- padding: 0 !important;
567
- border: none !important;
568
-
569
- -moz-border-radius: 40px;
570
- -webkit-border-radius: 40px;
571
- border-radius: 40px;
572
- }
573
- /* Profile pic hover */
574
- /* Profile pic hover */
575
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{
576
- opacity: 0;
577
- position: absolute;
578
- width: 100%;
579
- top: 0;
580
- bottom: 0;
581
- left: 0;
582
- text-align: center;
583
- color: #fff;
584
- background: rgba(0,0,0,0.75);
585
- }
586
-
587
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover .sby_new_logo{
588
- position: absolute;
589
- top: 50%;
590
- left: 50%;
591
- margin-top: -12px;
592
- margin-left: -12px;
593
- width: 24px;
594
- height: 24px;
595
- font-size: 24px;
596
- }
597
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover i {
598
- overflow: hidden;
599
- background: url('../img/small-logo.png') no-repeat 0 0;
600
- }
601
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{
602
- z-index: 2;
603
- transition: opacity 0.4s ease-in-out;
604
- }
605
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_fade_in{
606
- opacity: 1;
607
- transition: opacity 0.2s ease-in-out;
608
- }
609
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{
610
- position: absolute;
611
- width: 100%;
612
- top: 0;
613
- bottom: 0;
614
- left: 0;
615
- text-align: center;
616
- color: #fff;
617
- background: rgba(0,0,0,0.75);
618
-
619
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
620
- filter: alpha(opacity=0);
621
- -moz-opacity: 0;
622
- -khtml-opacity: 0;
623
- opacity: 0;
624
- border-radius: 40px;
625
- transition: opacity 0.2s;
626
- }
627
- /* Fade the Youtube icon in when hovering on the header */
628
- [id^=sb_youtube_].sb_youtube .sb_youtube_header a:hover .sby_header_img_hover,
629
- [id^=sb_youtube_].sb_youtube .sb_youtube_header a:focus .sby_header_img_hover{
630
- opacity: 1;
631
- }
632
- /* Header text */
633
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text{
634
- float: left;
635
- width: 100%;
636
- padding-top: 5px;
637
- }
638
- [id^=sb_youtube_].sb_youtube .sb_youtube_header a{
639
- text-decoration: none;
640
- }
641
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text .sby_bio,
642
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text h3{
643
- float: left;
644
- clear: both;
645
- width: auto;
646
- margin: 0 0 0 60px !important;
647
- padding: 0 !important;
648
- }
649
- [id^=sb_youtube_].sb_youtube .sb_youtube_header h3{
650
- font-size: 16px;
651
- line-height: 1.3;
652
- }
653
- [id^=sb_youtube_].sb_youtube .sb_youtube_header p{
654
- font-size: 13px;
655
- line-height: 1.3;
656
- margin: 0;
657
- padding: 0;
658
- }
659
- [id^=sb_youtube_].sb_youtube p:empty { display: none; }
660
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text img.emoji{
661
- margin-right: 3px !important;
662
- }
663
-
664
- /* No bio */
665
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text.sby_no_bio h3{
666
- padding-top: 9px !important;
667
- }
668
- [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text.sby_no_bio .sby_bio_info{
669
- clear: both;
670
- }
671
-
672
- /* Buttons */
673
- [id^=sb_youtube_].sb_youtube .sby_footer{
674
- float: left;
675
- clear: both;
676
- width: 100%;
677
- text-align: center;
678
- }
679
- [id^=sb_youtube_].sb_youtube .sby_footer .fa-spinner{
680
- display: none;
681
- position: absolute;
682
- top: 50%;
683
- left: 50%;
684
- margin: -8px 0 0 -7px;
685
- font-size: 15px;
686
- }
687
- [id^=sb_youtube_].sb_youtube .sby_footer{
688
- opacity: 1;
689
- transition: all 0.5s ease-in;
690
- }
691
- [id^=sb_youtube_].sb_youtube .sby_load_btn .sby_btn_text, [id^=sb_youtube_].sb_youtube .sby_load_btn .sby_loader{
692
- opacity: 1;
693
- transition: all 0.1s ease-in;
694
- }
695
- [id^=sb_youtube_].sb_youtube .sby_hidden{
696
- opacity: 0 !important;
697
- }
698
- [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn,
699
- [id^=sb_youtube_].sb_youtube .sby_follow_btn a{
700
- display: -moz-inline-stack;
701
- display: inline-block;
702
- vertical-align: top;
703
- zoom: 1;
704
- *display: inline;
705
-
706
- padding: 7px 14px;
707
- margin: 5px auto 0 auto;
708
- background: #333;
709
- color: #eee;
710
- border: none;
711
- color: #fff;
712
- text-decoration: none;
713
- font-size: 13px;
714
- line-height: 1.5;
715
-
716
- -moz-border-radius: 4px;
717
- -webkit-border-radius: 4px;
718
- border-radius: 4px;
719
-
720
- -webkit-box-sizing: border-box;
721
- -moz-box-sizing: border-box;
722
- box-sizing: border-box;
723
- }
724
- [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn {
725
- position: relative;
726
- }
727
- /* Follow button */
728
- [id^=sb_youtube_].sb_youtube .sby_follow_btn{
729
- display: -moz-inline-stack;
730
- display: inline-block;
731
- vertical-align: top;
732
- zoom: 1;
733
- *display: inline;
734
- text-align: center;
735
- }
736
- [id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_top{
737
- display: block;
738
- margin-bottom: 5px;
739
- }
740
- [id^=sb_youtube_].sb_youtube .sby_follow_btn a{
741
- background: #408bd1;
742
- color: #fff;
743
- }
744
- [id^=sb_youtube_].sb_youtube .sby_follow_btn a,
745
- [id^=sb_youtube_].sb_youtube .sby_follow_btn a,
746
- [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn{
747
- transition: all 0.1s ease-in;
748
- }
749
- /* Hover state for default colors */
750
- [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn:hover{
751
- outline: none;
752
- box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.25);
753
- }
754
- [id^=sb_youtube_].sb_youtube .sby_follow_btn a:hover,
755
- [id^=sb_youtube_].sb_youtube .sby_follow_btn a:focus{
756
- outline: none;
757
- box-shadow: inset 0 0 10px 20px #359dff;
758
- }
759
- /* If a custom color is applied then just use opacity for the hover effect */
760
- [id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_custom a:hover,
761
- [id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_custom a:focus,
762
- [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn.sby_custom:hover{
763
- box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.15);
764
- }
765
- /* Active state */
766
- [id^=sb_youtube_].sb_youtube .sby_follow_btn a:active,
767
- [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn:active{
768
- box-shadow: inset 0 0 10px 20px rgba(0,0,0,0.3);
769
- }
770
-
771
- [id^=sb_youtube_].sb_youtube .sby_follow_btn .fa,
772
- [id^=sb_youtube_].sb_youtube .sby_follow_btn svg{
773
- margin-bottom: -1px;
774
- margin-right: 7px;
775
- font-size: 15px;
776
- }
777
- [id^=sb_youtube_].sb_youtube .sby_follow_btn svg{
778
- vertical-align: -.125em;
779
- }
780
- [id^=sb_youtube_].sb_youtube .sby_footer .sby_follow_btn{
781
- margin-left: 5px;
782
- }
783
-
784
- /* Media queries */
785
- @media all and (max-width: 640px){
786
- /* Make 3-6 cols into 2 col */
787
- [id^=sb_youtube_].sb_youtube.sby_col_3.sby_mob_col_auto .sby_items_wrap .sby_item,
788
- [id^=sb_youtube_].sb_youtube.sby_col_4.sby_mob_col_auto .sby_items_wrap .sby_item,
789
- [id^=sb_youtube_].sb_youtube.sby_col_5.sby_mob_col_auto .sby_items_wrap .sby_item,
790
- [id^=sb_youtube_].sb_youtube.sby_col_6.sby_mob_col_auto .sby_items_wrap .sby_item{
791
- width: 50%;
792
- }
793
- /* Make 7-10 cols into 4 col */
794
- [id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item,
795
- [id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item,
796
- [id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item,
797
- [id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item,
798
- [id^=sb_youtube_].sb_youtube.sby_col_7.sby_mob_col_auto .sby_items_wrap .sby_item,
799
- [id^=sb_youtube_].sb_youtube.sby_col_8.sby_mob_col_auto .sby_items_wrap .sby_item,
800
- [id^=sb_youtube_].sb_youtube.sby_col_9.sby_mob_col_auto .sby_items_wrap .sby_item,
801
- [id^=sb_youtube_].sb_youtube.sby_col_10.sby_mob_col_auto .sby_items_wrap .sby_item{
802
- width: 25%;
803
- }
804
- [id^=sb_youtube_].sb_youtube.sby_col_2 .sby_items_wrap .sby_item{ width: 50%; }
805
- [id^=sb_youtube_].sb_youtube.sby_col_3 .sby_items_wrap .sby_item{ width: 33.33%; }
806
- [id^=sb_youtube_].sb_youtube.sby_col_4 .sby_items_wrap .sby_item{ width: 25%; }
807
- [id^=sb_youtube_].sb_youtube.sby_col_5 .sby_items_wrap .sby_item{ width: 20%; }
808
- [id^=sb_youtube_].sb_youtube.sby_col_6 .sby_items_wrap .sby_item{ width: 16.66%; }
809
- [id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item{ width: 14.28%; }
810
- [id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item{ width: 12.5%; }
811
- [id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item{ width: 11.11%; }
812
- [id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item{ width: 10%; }
813
- /* On mobile make the min-width 100% */
814
- [id^=sb_youtube_].sb_youtube.sby_width_resp{
815
- width: 100% !important;
816
- }
817
- }
818
- @media all and (max-width: 480px){
819
- /* Make all cols into 1 col */
820
- [id^=sb_youtube_].sb_youtube.sby_col_3.sby_mob_col_auto .sby_items_wrap .sby_item,
821
- [id^=sb_youtube_].sb_youtube.sby_col_4.sby_mob_col_auto .sby_items_wrap .sby_item,
822
- [id^=sb_youtube_].sb_youtube.sby_col_5.sby_mob_col_auto .sby_items_wrap .sby_item,
823
- [id^=sb_youtube_].sb_youtube.sby_col_6.sby_mob_col_auto .sby_items_wrap .sby_item,
824
- [id^=sb_youtube_].sb_youtube.sby_col_7.sby_mob_col_auto .sby_items_wrap .sby_item,
825
- [id^=sb_youtube_].sb_youtube.sby_col_8.sby_mob_col_auto .sby_items_wrap .sby_item,
826
- [id^=sb_youtube_].sb_youtube.sby_col_9.sby_mob_col_auto .sby_items_wrap .sby_item,
827
- [id^=sb_youtube_].sb_youtube.sby_col_10.sby_mob_col_auto .sby_items_wrap .sby_item,
828
- [id^=sb_youtube_].sb_youtube.sby_mob_col_1 .sby_items_wrap .sby_item{
829
- width: 100%;
830
- }
831
- [id^=sb_youtube_].sb_youtube.sby_mob_col_2 .sby_items_wrap .sby_item{ width: 50%; }
832
- [id^=sb_youtube_].sb_youtube.sby_mob_col_3 .sby_items_wrap .sby_item{ width: 33.33%; }
833
- [id^=sb_youtube_].sb_youtube.sby_mob_col_4 .sby_items_wrap .sby_item{ width: 25%; }
834
- [id^=sb_youtube_].sb_youtube.sby_mob_col_5 .sby_items_wrap .sby_item{ width: 20%; }
835
- [id^=sb_youtube_].sb_youtube.sby_mob_col_6 .sby_items_wrap .sby_item{ width: 16.66%; }
836
- [id^=sb_youtube_].sb_youtube.sby_mob_col_7 .sby_items_wrap .sby_item{ width: 14.28%; }
837
- }
838
-
839
- /* --- Lightbox --- */
840
-
841
- .sby_lightboxOverlay {
842
- position: absolute;
843
- top: 0;
844
- left: 0;
845
- z-index: 99999;
846
- background-color: black;
847
- filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
848
- opacity: 0.9;
849
- display: none;
850
- }
851
- .sby_lightbox {
852
- position: absolute;
853
- left: 0;
854
- width: 100%;
855
- z-index: 100000;
856
- line-height: 0;
857
- font-weight: normal;
858
- }
859
- .sby_lightbox .sby_lb-image {
860
- display: block;
861
- height: auto;
862
- max-width: inherit;
863
- -webkit-border-radius: 3px;
864
- -moz-border-radius: 3px;
865
- -ms-border-radius: 3px;
866
- -o-border-radius: 3px;
867
- border-radius: 3px;
868
- }
869
- .sby_lightbox a:hover,
870
- .sby_lightbox a:focus,
871
- .sby_lightbox a:active{
872
- outline: none;
873
- }
874
- .sby_lightbox a img {
875
- border: none;
876
- }
877
- .sby_lb-outerContainer {
878
- position: relative;
879
- background-color: #000;
880
- *zoom: 1;
881
- width: 250px;
882
- height: 250px;
883
- margin: 0 auto 5px auto;
884
- -webkit-border-radius: 3px;
885
- -moz-border-radius: 3px;
886
- -ms-border-radius: 3px;
887
- -o-border-radius: 3px;
888
- border-radius: 3px;
889
- }
890
- .sby_lb-outerContainer:after {
891
- content: "";
892
- display: table;
893
- clear: both;
894
- }
895
- .sby_lb-container {
896
- position: relative;
897
- padding: 4px;
898
- top: 0;
899
- left: 0;
900
- width: 100%;
901
- height: 100%;
902
- bottom: 0;
903
- right: 0;
904
-
905
- -webkit-border-radius: 3px;
906
- -moz-border-radius: 3px;
907
- -ms-border-radius: 3px;
908
- -o-border-radius: 3px;
909
- border-radius: 3px;
910
- }
911
- .sby_lb-loader {
912
- position: absolute;
913
- top: 43%;
914
- left: 0;
915
- height: 25%;
916
- width: 100%;
917
- text-align: center;
918
- line-height: 0;
919
- }
920
- .sby_lb-cancel {
921
- display: block;
922
- width: 32px;
923
- height: 32px;
924
- margin: 0 auto;
925
- background-color: #666;
926
- background-color: rgba(255,255,255,0.5);
927
-
928
- border-radius: 100%;
929
- -webkit-animation: ctf-sk-scaleout 1.0s infinite ease-in-out;
930
- animation: ctf-sk-scaleout 1.0s infinite ease-in-out;
931
- }
932
-
933
-
934
- .sby_lb-nav {
935
- /*position: absolute;*/
936
- top: 0;
937
- left: 0;
938
- /*height: 100%;*/
939
- width: 100%;
940
- z-index: 10;
941
- /*pointer-events: none;*/
942
- }
943
- .sby_lb-container > .nav {
944
- left: 0;
945
- }
946
- .sby_lb-nav a {
947
- position: absolute;
948
- z-index: 100;
949
- top: 0;
950
- height: 90%;
951
- outline: none;
952
- background-image: url('data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
953
- }
954
-
955
-
956
- /* Arrows */
957
- .sby_lb-prev, .sby_lb-next {
958
- height: 100%;
959
- cursor: pointer;
960
- display: block;
961
- }
962
- .sby_lb-nav a.sby_lb-prev {
963
- /*width: 30%;*/
964
- width: 50px;
965
- left: -70px;
966
- padding-left: 10px;
967
- padding-right: 10px;
968
- float: left;
969
-
970
- filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0.5);
971
- opacity: 0.5;
972
- -webkit-transition: opacity 0.2s;
973
- -moz-transition: opacity 0.2;
974
- -o-transition: opacity 0.2s;
975
- transition: opacity 0.2s;
976
-
977
- }
978
-
979
- .sby_lb-nav a.sby_lb-prev:hover {
980
- filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
981
- opacity: 1;
982
- }
983
-
984
- .sby_lb-nav a.sby_lb-next {
985
- /*width: 30%;*/
986
- width: 50px;
987
- right: -70px;
988
- padding-left: 10px;
989
- padding-right: 10px;
990
- float: right;
991
-
992
- filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0.5);
993
- opacity: 0.5;
994
- -webkit-transition: opacity 0.2s;
995
- -moz-transition: opacity 0.2s;
996
- -o-transition: opacity 0.2s;
997
- transition: opacity 0.2s;
998
-
999
- }
1000
-
1001
- .sby_lb-nav a.sby_lb-next:hover {
1002
- filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
1003
- opacity: 1;
1004
- }
1005
-
1006
- .sby_lb-nav span{
1007
- display: block;
1008
- top: 55%;
1009
- position: absolute;
1010
- left: 20px;
1011
- width: 34px;
1012
- height: 45px;
1013
- margin: -25px 0 0 0;
1014
- background: url(../img/sby-sprite.png) no-repeat;
1015
- }
1016
- .sby_lb-nav a.sby_lb-prev span{
1017
- background-position: -53px 0;
1018
- }
1019
- .sby_lb-nav a.sby_lb-next span{
1020
- left: auto;
1021
- right: 20px;
1022
- background-position: -18px 0;
1023
- }
1024
-
1025
-
1026
- .sby_lb-dataContainer {
1027
- margin: 0 auto;
1028
- padding-top: 5px;
1029
- *zoom: 1;
1030
- width: 100%;
1031
- font-family: "Open Sans", Helvetica, Arial, sans-serif;
1032
-
1033
- -moz-border-radius-bottomleft: 4px;
1034
- -webkit-border-bottom-left-radius: 4px;
1035
- border-bottom-left-radius: 4px;
1036
- -moz-border-radius-bottomright: 4px;
1037
- -webkit-border-bottom-right-radius: 4px;
1038
- border-bottom-right-radius: 4px;
1039
- }
1040
- .sby_lb-dataContainer:after {
1041
- content: "";
1042
- display: table;
1043
- clear: both;
1044
- }
1045
- .sby_lb-data {
1046
- padding: 0 4px;
1047
- color: #ccc;
1048
- }
1049
- .sby_lb-data .sby_lb-details {
1050
- width: 85%;
1051
- float: left;
1052
- text-align: left;
1053
- line-height: 1.1;
1054
- }
1055
- .sby_lb-data .sby_lb-caption {
1056
- float: left;
1057
- font-size: 13px;
1058
- font-weight: normal;
1059
- line-height: 1.3;
1060
- padding-bottom: 3px;
1061
- color: #ccc;
1062
-
1063
- word-wrap: break-word;
1064
- -webkit-hyphens: auto;
1065
- -moz-hyphens: auto;
1066
- hyphens: auto;
1067
- }
1068
- .sby_lb-data .sby_lb-caption a,
1069
- .sby_lb-data .sby_lb-caption .ctf-screename-sep{
1070
- color: #ccc;
1071
- font-weight: bold;
1072
- text-decoration: none;
1073
- }
1074
- .sby_lb-data .sby_lb-caption a:hover{
1075
- color: #fff;
1076
- text-decoration: underline;
1077
- }
1078
- .sby_lb-data .sby_lb-caption .sby_lightbox_username{
1079
- float: left;
1080
- width: 100%;
1081
- color: #ccc;
1082
- padding-bottom: 0;
1083
- display: block;
1084
- margin: 0 0 5px 0;
1085
- }
1086
- .sby_lb-data .sby_lb-caption .sby_lightbox_username{
1087
- color: #ccc;
1088
- }
1089
- .sby_lb-data .sby_lb-caption .sby_lightbox_username:hover p{
1090
- color: #fff;
1091
- text-decoration: underline;
1092
- }
1093
- .sby_lightbox .sby_lightbox_username img {
1094
- float: left;
1095
- border: none;
1096
- width: 48px;
1097
- height: 48px;
1098
- margin-right: 10px;
1099
- background: #666;
1100
-
1101
- -moz-border-radius: 5px;
1102
- -webkit-border-radius: 5px;
1103
- border-radius: 5px;
1104
- }
1105
- .sby_lightbox_username p{
1106
- float: left;
1107
- margin: 0;
1108
- padding: 0;
1109
- color: #ccc;
1110
- line-height: 32px;
1111
- font-weight: bold;
1112
- font-size: 13px;
1113
- text-align: left;
1114
- }
1115
-
1116
- .sby_lb-data .ctf-caption-text{
1117
- width: 100%;
1118
- margin-left: 58px;
1119
- padding-top: 3px;
1120
- }
1121
- .sby_lb-data .sby_lb-caption .ctf-tweet-date,
1122
- .sby_lb-data .sby_lb-caption .ctf-author-screenname{
1123
- font-weight: normal;
1124
- }
1125
- .sby_lb-data .sby_lb-info{
1126
- width: 100%;
1127
- float: left;
1128
- clear: both;
1129
- }
1130
- .sby_lb-data .sby_lb-number {
1131
- display: block;
1132
- float: left;
1133
- clear: both;
1134
- padding: 5px 0 15px 0;
1135
- font-size: 12px;
1136
- color: #999999;
1137
- }
1138
- .sby_lb-data .sby_lb-close {
1139
- display: block;
1140
- float: right;
1141
- width: 30px;
1142
- height: 30px;
1143
- background: url(../img/close.png) top right no-repeat;
1144
- text-align: right;
1145
- outline: none;
1146
- filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=70);
1147
- opacity: 0.7;
1148
- -webkit-transition: opacity 0.2s;
1149
- -moz-transition: opacity 0.2s;
1150
- -o-transition: opacity 0.2s;
1151
- transition: opacity 0.2s;
1152
- }
1153
- .sby_lb-data .sby_lb-close:hover {
1154
- cursor: pointer;
1155
- filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
1156
- opacity: 1;
1157
- }
1158
-
1159
- /* Lightbox video - must go after lighbox CSS */
1160
- /* Leave a gap at the bottom of the nav for video controls */
1161
- .sby_lb-nav {
1162
- height: auto;
1163
- }
1164
- /* Remove 4px padding from lightbox container so video lines up */
1165
- .sby_lb-container{
1166
- padding: 0;
1167
- }
1168
- .sby_lb-container iframe {
1169
- position: absolute;
1170
- top: 0;
1171
- left:0;
1172
- width: 100%;
1173
- height: 100%;
1174
- z-index: 1;
1175
- }
1176
- /* Lightbox action links */
1177
- #sby_lightbox .sby_lightbox_action{
1178
- float: left;
1179
- /*clear: both;*/
1180
- position: relative;
1181
- padding: 0 0 0 10px;
1182
- margin: 5px 0 0 10px;
1183
- border-left: 1px solid #666;
1184
- font-size: 12px;
1185
- }
1186
- #sby_lightbox .sby_lightbox_action a{
1187
- display: block;
1188
- float: left;
1189
- color: #999;
1190
- text-decoration: none;
1191
- }
1192
- #sby_lightbox .sby_lightbox_action a:hover,
1193
- #sby_lightbox .sby_lightbox_action a:focus{
1194
- color: #fff;
1195
- }
1196
- #sby_lightbox .sby_lightbox_action .fa,
1197
- #sby_lightbox .sby_lightbox_action svg {
1198
- margin-right: 5px;
1199
- }
1200
- #sby_lightbox .sby_lightbox_action.sby_youtube .fa {
1201
- font-size: 13px;
1202
- }
1203
- #sby_lightbox .sby_tooltip_social a svg {
1204
- font-size: 19px;
1205
- padding: 3px 4px;
1206
- margin: auto;
1207
- }
1208
- /* Lightbox tooltip */
1209
- #sby_lightbox .sby_lightbox_tooltip{
1210
- display: none;
1211
- position: absolute;
1212
- width: 100px;
1213
- bottom: 22px;
1214
- left: 0;
1215
- padding: 5px 10px;
1216
- margin: 0;
1217
- background: rgba(255,255,255,0.9);
1218
- color: #222;
1219
- font-size: 12px;
1220
- line-height: 1.3;
1221
-
1222
- -moz-border-radius: 4px;
1223
- -webkit-border-radius: 4px;
1224
- border-radius: 4px;
1225
-
1226
- box-shadow: 0 0 10px rgba(0,0,0,0.4);
1227
- -moz-box-shadow: 0 0 10px rgba(0,0,0,0.4);
1228
- -webkit-box-shadow: 0 0 10px rgba(0,0,0,0.4);
1229
-
1230
- -webkit-box-sizing: border-box;
1231
- -moz-box-sizing: border-box;
1232
- box-sizing: border-box;
1233
- }
1234
- #sby_lightbox .sby_lightbox_tooltip .fa-play{
1235
- position: absolute;
1236
- font-size: 8px;
1237
- bottom: -6px;
1238
- left: 36px;
1239
- color: rgba(255,255,255,0.9);
1240
- }
1241
- #sby_lightbox .sby_tooltip_social a .fa{
1242
- font-size: 16px;
1243
- margin: 0;
1244
- padding: 5px;
1245
- }
1246
- #sby_lightbox .sby_tooltip_social a#sby_facebook_icon .fa,
1247
- #sby_lightbox .sby_tooltip_social a#sby_twitter_icon .fa,
1248
- #sby_lightbox .sby_tooltip_social a#sby_pinterest_icon .fa{
1249
- padding-top: 4px;
1250
- font-size: 18px;
1251
- }
1252
-
1253
- /* Hide photos tooltip */
1254
- #sby_lightbox #sby_mod_box{
1255
- width: 280px;
1256
- padding: 5px 10px 7px 10px;
1257
- }
1258
- /* Social icons tooltip */
1259
- #sby_lightbox .sby_tooltip_social{
1260
- width: 172px;
1261
- padding: 5px 5px 4px 5px;
1262
- }
1263
- #sby_lightbox .sby_tooltip_social a{
1264
- color: #333;
1265
-
1266
- -moz-border-radius: 4px;
1267
- -webkit-border-radius: 4px;
1268
- border-radius: 4px;
1269
- }
1270
- #sby_lightbox .sby_lightbox_action #sby_facebook_icon:hover{ background: #3b5998; }
1271
- #sby_lightbox .sby_lightbox_action #sby_twitter_icon:hover{ background: #00aced; }
1272
- #sby_lightbox .sby_lightbox_action #sby_google_icon:hover{ background: #dd4b39; }
1273
- #sby_lightbox .sby_lightbox_action #sby_linkedin_icon:hover{ background: #007bb6; }
1274
- #sby_lightbox .sby_lightbox_action #sby_pinterest_icon:hover{ background: #cb2027; }
1275
- #sby_lightbox .sby_lightbox_action #sby_email_icon:hover{ background: #333; }
1276
-
1277
- .sby_lb-outerContainer, .sby_lb-dataContainer{
1278
- min-width: 450px;
1279
- }
1280
- @media all and (max-width: 450px){
1281
- .sby_lb-outerContainer, .sby_lb-dataContainer {
1282
- min-width: 0; /* Remove min-width on lightbox on mobile */
1283
- }
1284
- }
1285
- .sby_lightbox .sby_lb-image {
1286
- display: block;
1287
- height: auto;
1288
- max-width: inherit;
1289
- margin: 0 auto;
1290
- -webkit-border-radius: 0;
1291
- -moz-border-radius: 0;
1292
- -ms-border-radius: 0;
1293
- -o-border-radius: 0;
1294
- border-radius: 0;
1295
- }
1296
-
1297
- /* Mod only error msgs */
1298
- #sby_mod_error{
1299
- display: none;
1300
- border: 1px solid #ddd;
1301
- background: #eee;
1302
- color: #333;
1303
- margin: 10px 0 0;
1304
- padding: 10px 15px;
1305
- font-size: 13px;
1306
- text-align: center;
1307
- clear: both;
1308
- margin-bottom: 10px;
1309
-
1310
- -moz-border-radius: 4px;
1311
- -webkit-border-radius: 4px;
1312
- border-radius: 4px;
1313
- }
1314
- #sby_mod_error p{
1315
- padding: 5px 0 !important;
1316
- margin: 0 !important;
1317
- line-height: 1.3 !important;
1318
- }
1319
- #sby_mod_error ol,
1320
- #sby_mod_error ul{
1321
- padding: 5px 0 5px 20px !important;
1322
- margin: 0 !important;
1323
- }
1324
- #sby_mod_error li{
1325
- padding: 1px 0 !important;
1326
- margin: 0 !important;
1327
- }
1328
- #sby_mod_error span{
1329
- font-size: 12px;
1330
- }
1331
-
1332
- /* SVGs */
1333
- [id^=sb_youtube_].sb_youtube svg:not(:root).svg-inline--fa,
1334
- [id^=sb_youtube_].sb_youtube_lightbox svg:not(:root).svg-inline--fa{
1335
- box-sizing: unset;
1336
- overflow: visible;
1337
- width: 1em;
1338
- }
1339
- [id^=sb_youtube_].sb_youtube .svg-inline--fa.fa-w-16,
1340
- [id^=sb_youtube_].sb_youtube .svg-inline--fa.fa-w-16{
1341
- width: 16px;
1342
- }
1343
- [id^=sb_youtube_].sb_youtube .svg-inline--fa,
1344
- [id^=sb_youtube_].sb_youtube_lightbox .svg-inline--fa{
1345
- display: inline-block;
1346
- font-size: inherit;
1347
- height: 1em;
1348
- overflow: visible;
1349
- vertical-align: -.125em;
1350
- }
1351
-
1352
- [id^=sb_youtube_].sb_youtube.sby_player_loaded .sby_player_outer_wrap .sby_video_thumbnail,
1353
- [id^=sb_youtube_].sb_youtube.sby_player_loaded.sby_layout_list .sby_video_thumbnail{
1354
- z-index: -1 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1355
  }
1
+ /**************/
2
+ /*** LAYOUT ***/
3
+ /**************/
4
+
5
+ /* Feed container */
6
+ [id^=sb_youtube_].sb_youtube {
7
+ width: 100%;
8
+ margin: 0 auto;
9
+ padding: 0;
10
+ -webkit-box-sizing: border-box;
11
+ -moz-box-sizing: border-box;
12
+ box-sizing: border-box;
13
+ }
14
+ [id^=sb_youtube_].sb_youtube * {
15
+ -webkit-box-sizing: border-box;
16
+ -moz-box-sizing: border-box;
17
+ box-sizing: border-box
18
+ }
19
+ [id^=sb_youtube_].sb_youtube:after{
20
+ content: "";
21
+ display: table;
22
+ clear: both;
23
+ }
24
+ [id^=sb_youtube_].sb_youtube iframe,
25
+ #sby_lightbox iframe{
26
+ pointer-events: all !important;
27
+ }
28
+
29
+ /*********************/
30
+ /*** STYLE OPTIONS ***/
31
+ /*********************/
32
+ [id^=sb_youtube_].sb_youtube.sby_fixed_height{
33
+ overflow: hidden;
34
+ overflow-y: auto;
35
+ -webkit-box-sizing: border-box;
36
+ -moz-box-sizing: border-box;
37
+ box-sizing: border-box;
38
+ }
39
+ [id^=sb_youtube_].sb_youtube .sby_items_wrap{
40
+ width: 100%;
41
+ float: left;
42
+ line-height: 0;
43
+
44
+ -webkit-box-sizing: border-box;
45
+ -moz-box-sizing: border-box;
46
+ box-sizing: border-box;
47
+ }
48
+
49
+ /* Items */
50
+ [id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item,
51
+ [id^=sb_youtube_].sb_youtube .sby_player_outer_wrap .sby_video_thumbnail_wrap,
52
+ [id^=sb_youtube_].sb_youtube .sby_player_wrap{
53
+ display: -moz-inline-stack;
54
+ display: inline-block;
55
+ vertical-align: top;
56
+ zoom: 1;
57
+ *display: inline;
58
+
59
+ max-height: 1000px;
60
+ padding: inherit !important;
61
+ text-decoration: none;
62
+ opacity: 1;
63
+ overflow: hidden;
64
+
65
+ -webkit-box-sizing: border-box;
66
+ -moz-box-sizing: border-box;
67
+ box-sizing: border-box;
68
+
69
+ -webkit-transition: all 0.5s ease;
70
+ -moz-transition: all 0.5s ease;
71
+ -o-transition: all 0.5s ease;
72
+ -ms-transition: all 0.5s ease;
73
+ transition: all 0.5s ease;
74
+ }
75
+ [id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item.sby_no_margin {
76
+ margin: 0 !important;
77
+ }
78
+ [id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item {
79
+ float: left;
80
+ }
81
+ /* Transition items in */
82
+ [id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item.sby_transition{
83
+ opacity: 0;
84
+ max-height: 0;
85
+ }
86
+
87
+ /* Cols */
88
+ [id^=sb_youtube_].sb_youtube.sby_col_0 .sby_items_wrap .sby_item{ width: 100%; }
89
+ [id^=sb_youtube_].sb_youtube.sby_col_1 .sby_items_wrap .sby_item{ width: 100%; }
90
+ [id^=sb_youtube_].sb_youtube.sby_col_2 .sby_items_wrap .sby_item{ width: 50%; }
91
+ [id^=sb_youtube_].sb_youtube.sby_col_3 .sby_items_wrap .sby_item{ width: 33.33%; }
92
+ [id^=sb_youtube_].sb_youtube.sby_col_4 .sby_items_wrap .sby_item{ width: 25%; }
93
+ [id^=sb_youtube_].sb_youtube.sby_col_5 .sby_items_wrap .sby_item{ width: 20%; }
94
+ [id^=sb_youtube_].sb_youtube.sby_col_6 .sby_items_wrap .sby_item{ width: 16.66%; }
95
+ [id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item{ width: 14.28%; }
96
+ [id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item{ width: 12.5%; }
97
+ [id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item{ width: 11.11%; }
98
+ [id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item{ width: 10%; }
99
+
100
+ /* Disable mobile layout */
101
+ /*
102
+ [id^=sb_youtube_].sb_youtube.sby_col_1.sby_disable_mobile .sby_items_wrap .sby_item{ width: 100%; }
103
+ [id^=sb_youtube_].sb_youtube.sby_col_2.sby_disable_mobile .sby_items_wrap .sby_item{ width: 50%; }
104
+ [id^=sb_youtube_].sb_youtube.sby_col_3.sby_disable_mobile .sby_items_wrap .sby_item{ width: 33.33%; }
105
+ [id^=sb_youtube_].sb_youtube.sby_col_4.sby_disable_mobile .sby_items_wrap .sby_item{ width: 25%; }
106
+ [id^=sb_youtube_].sb_youtube.sby_col_5.sby_disable_mobile .sby_items_wrap .sby_item{ width: 20%; }
107
+ [id^=sb_youtube_].sb_youtube.sby_col_6.sby_disable_mobile .sby_items_wrap .sby_item{ width: 16.66%; }
108
+ [id^=sb_youtube_].sb_youtube.sby_col_7.sby_disable_mobile .sby_items_wrap .sby_item{ width: 14.28%; }
109
+ [id^=sb_youtube_].sb_youtube.sby_col_8.sby_disable_mobile .sby_items_wrap .sby_item{ width: 12.5%; }
110
+ [id^=sb_youtube_].sb_youtube.sby_col_9.sby_disable_mobile .sby_items_wrap .sby_item{ width: 11.11%; }
111
+ [id^=sb_youtube_].sb_youtube.sby_col_10.sby_disable_mobile .sby_items_wrap .sby_item{ width: 10%; }
112
+ */
113
+ /* Photos */
114
+ .sby-screenreader{text-indent: -9999px !important;display: block !important;width: 0 !important;height: 0 !important;line-height: 0 !important;}
115
+ [id^=sb_youtube_].sb_youtube .sby_video_thumbnail_wrap,
116
+ [id^=sb_youtube_].sb_youtube .sby_player_outer_wrap {
117
+ width: 100%;
118
+ position: relative;
119
+ float: left;
120
+ }
121
+ [id^=sb_youtube_].sb_youtube .sby_video_thumbnail{
122
+ display: block;
123
+ position: relative;
124
+ text-decoration: none;
125
+ line-height: 0;
126
+ z-index: 5;
127
+ }
128
+ [id^=sb_youtube_].sb_youtube .sby_video_thumbnail img{
129
+ width: 100%;
130
+ height: auto;
131
+ border-radius: 0;
132
+ }
133
+ [id^=sb_youtube_].sb_youtube .sby_link{
134
+ display: none;
135
+ position: absolute;
136
+ z-index: 1;
137
+ top: 0;
138
+ right: 0;
139
+ bottom: 0;
140
+ left: 0;
141
+
142
+ width: 100%;
143
+ padding: 0;
144
+ background: #333;
145
+ background: rgba(0,0,0,0.6);
146
+ text-align: center;
147
+ color: #fff;
148
+ font-size: 12px;
149
+ line-height: 1.1;
150
+ overflow: hidden;
151
+ }
152
+ [id^=sb_youtube_].sb_youtube .sby_link.sby_default p,
153
+ [id^=sb_youtube_].sb_youtube .sby_link.sby_default span,
154
+ [id^=sb_youtube_].sb_youtube .sby_link.sby_default a{
155
+ text-shadow: 0px 0px 10px #000;
156
+ }
157
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_username a,
158
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link,
159
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_hover_bottom,
160
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_playbtn,
161
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link,
162
+ [id^=sb_youtube_].sb_youtube .sby_link .svg-inline--fa.fa-play{
163
+ filter: alpha(opacity=90);
164
+ opacity: 0.9;
165
+ }
166
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_username a:hover,
167
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link:hover,
168
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_playbtn:hover,
169
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link:hover,
170
+ [id^=sb_youtube_].sb_youtube .sby_link .svg-inline--fa.fa-play:hover{
171
+ filter: alpha(opacity=100);
172
+ opacity: 1;
173
+ }
174
+ [id^=sb_youtube_].sb_youtube .sby_link_area{
175
+ position: absolute;
176
+ top: 0;
177
+ right: 0;
178
+ bottom: 0;
179
+ left: 0;
180
+ z-index: 1;
181
+ }
182
+
183
+ [id^=sb_youtube_].sb_youtube .sby_link a{
184
+ padding: 0;
185
+ text-decoration: none;
186
+ color: #ddd;
187
+ color: rgba(255,255,255,0.7);
188
+ line-height: 1.1;
189
+ background: none;
190
+
191
+ display: -moz-inline-stack;
192
+ display: inline-block;
193
+ vertical-align: top;
194
+ zoom: 1;
195
+ *display: inline;
196
+ }
197
+ [id^=sb_youtube_].sb_youtube .sby_link a:hover,
198
+ [id^=sb_youtube_].sb_youtube .sby_link a:active{
199
+ color: #fff;
200
+ }
201
+
202
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link{
203
+ display: block;
204
+ /*display: none;*/
205
+ position: absolute;
206
+ z-index: 2;
207
+ top: 50%;
208
+ left: 50%;
209
+
210
+ margin-top: -24px;
211
+ margin-left: -21px;
212
+ padding: 0;
213
+ font-size: 49px;
214
+ font-style: normal !important;
215
+ }
216
+ [id^=sb_youtube_].sb_youtube .sby_type_video .sby_lightbox_link,
217
+ [id^=sb_youtube_].sb_youtube .sby_carousel_vid_first .sby_lightbox_link{
218
+ display: none;
219
+ }
220
+
221
+ [id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link{
222
+ /*float: right;*/
223
+ font-size: 30px;
224
+ position: absolute;
225
+ z-index: 100;
226
+ bottom: 0;
227
+ right: 2px;
228
+ padding: 8px;
229
+ }
230
+ [id^=sb_youtube_].sb_youtube .sby_link a:hover,
231
+ [id^=sb_youtube_].sb_youtube .sby_link a:focus{
232
+ text-decoration: underline;
233
+ }
234
+
235
+ /* Player */
236
+ [id^=sb_youtube_].sb_youtube .sby_player_wrap {
237
+ z-index: 1;
238
+ width: 100% !important;
239
+ height: 100% !important;
240
+ position: absolute;
241
+ top: 0;
242
+ left: 0;
243
+ }
244
+ [id^=sb_youtube_].sb_youtube .sby_player_wrap iframe {
245
+ width: 100% !important;
246
+ height: 100% !important;
247
+ }
248
+
249
+ /* Use CSS for lightbox fade instead of JS */
250
+ [id^=sb_youtube_].sb_youtube .sby_thumbnail_hover {
251
+ opacity: 0;
252
+ display: block;
253
+ position: absolute;
254
+ top: 0;
255
+ right: 0;
256
+ bottom: 0;
257
+ left: 0;
258
+ z-index: 10;
259
+ color: #fff;
260
+ background: #333;
261
+ background: rgba(0,0,0,.6);
262
+ transition: opacity .6s ease-in-out;
263
+ -moz-transition: opacity .6s ease-in-out;
264
+ -webkit-transition: opacity .6s ease-in-out;
265
+ }
266
+ [id^=sb_youtube_].sb_youtube.sby_layout_list .sby_thumbnail_hover {
267
+ display: none;
268
+ }
269
+ .sby_video_title {
270
+ display: inline-block;
271
+ height: 100%;
272
+ padding: 10px;
273
+ overflow: hidden;
274
+ font-size: 13px;
275
+ line-height: 1.2;
276
+ }
277
+ [id^=sb_youtube_].sb_youtube .sby_video_thumbnail:hover .sby_thumbnail_hover {
278
+ opacity: 1;
279
+ display: block;
280
+ transition: opacity .2s ease-in-out;
281
+ -moz-transition: opacity .2s ease-in-out;
282
+ -webkit-transition: opacity .2s ease-in-out;
283
+ }
284
+ [id^=sb_youtube_].sb_youtube .sby_current .sby_thumbnail_hover {
285
+ opacity: 1;
286
+ }
287
+ [id^=sb_youtube_].sb_youtube.sby_layout_list .sby_video_thumbnail:hover .sby_thumbnail_hover {
288
+ opacity: 0;
289
+ display: none;
290
+ transition: none;
291
+ -moz-transition: none;
292
+ -webkit-transition: none;
293
+ }
294
+
295
+ a.sby_video_thumbnail:after {
296
+ box-shadow: inset 0 0 1px 0 rgba(0,0,0,0.7);
297
+ bottom: 0;
298
+ content: '';
299
+ left: 0;
300
+ position: absolute;
301
+ z-index: 1;
302
+ right: 0;
303
+ top: 0;
304
+ width: 100%;
305
+ }
306
+
307
+ /* Play Button */
308
+ [id^=sb_youtube_].sb_youtube .sby_video_thumbnail:hover .sby_play_btn {
309
+ opacity: .5;
310
+ }
311
+ [id^=sb_youtube_].sb_youtube .sby_play_btn {
312
+ position: absolute;
313
+ z-index: 1;
314
+ left: 50%;
315
+ bottom: 50%;
316
+ top: 50%;
317
+ right: 50%;
318
+ margin-top: -25px;
319
+ margin-left: -28px;
320
+ color: #fff;
321
+ width: 57px;
322
+ height: 50px;
323
+ opacity: 1;
324
+ transition: opacity .2s ease-in-out;
325
+ -moz-transition: opacity .2s ease-in-out;
326
+ -webkit-transition: opacity .2s ease-in-out;
327
+ }
328
+ [id^=sb_youtube_].sb_youtube .sby_play_btn_bg {
329
+ display: block;
330
+ position: absolute;
331
+ z-index: -1;
332
+ top: 17px;
333
+ left: 22px;
334
+ width: 0;
335
+ height: 0;
336
+ border: 0 solid transparent;
337
+ border-bottom-width: 9px;
338
+ border-top-width: 9px;
339
+ border-left: 16px solid #fff;
340
+ }
341
+ [id^=sb_youtube_].sb_youtube .sby_play_btn svg:not(:root).svg-inline--fa{
342
+ width: 57px;
343
+ height: auto;
344
+ opacity: 0.75;
345
+ }
346
+
347
+ [id^=sb_youtube_].sb_youtube .sby_play_btn svg,
348
+ [id^=sb_youtube_].sb_youtube .sby_play_btn i{
349
+ color: #000;
350
+ }
351
+ /* Medium */
352
+ [id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn {
353
+ margin-top: -20px;
354
+ margin-left: -22px;
355
+ width: 45px;
356
+ height: 40px;
357
+ }
358
+ [id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn_bg {
359
+ top: 13px;
360
+ left: 18px;
361
+ border-bottom-width: 7px;
362
+ border-top-width: 7px;
363
+ border-left: 12px solid #fff;
364
+ }
365
+ [id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn svg:not(:root).svg-inline--fa{
366
+ width: 45px;
367
+ }
368
+
369
+ /* Small */
370
+ [id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn{
371
+ margin-top: -16px;
372
+ margin-left: -18px;
373
+ width: 36px;
374
+ height: 32px;
375
+ }
376
+ [id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn_bg {
377
+ top: 10px;
378
+ left: 14px;
379
+ border-bottom-width: 6px;
380
+ border-top-width: 6px;
381
+ border-left: 10px solid #fff;
382
+ }
383
+ [id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn svg:not(:root).svg-inline--fa{
384
+ width: 36px;
385
+ }
386
+
387
+ /* Loader */
388
+ [id^=sb_youtube_].sb_youtube .sby_loader{
389
+ width: 20px;
390
+ height: 20px;
391
+
392
+ position: relative;
393
+ top: 50%;
394
+ left: 50%;
395
+ margin: -10px 0 0 -10px;
396
+ background-color: #000;
397
+ background-color: rgba(0,0,0,0.5);
398
+
399
+ border-radius: 100%;
400
+ -webkit-animation: sby-sk-scaleout 1.0s infinite ease-in-out;
401
+ animation: sby-sk-scaleout 1.0s infinite ease-in-out;
402
+ }
403
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header br,
404
+ [id^=sb_youtube_].sb_youtube .sby_items_wrap br,
405
+ [id^=sb_youtube_].sb_youtube .sby_footer br{
406
+ display: none;
407
+ }
408
+ .sby_footer p {
409
+ display: inline;
410
+ padding: 0;
411
+ margin: 0;
412
+ }
413
+ /* Loader in button */
414
+ [id^=sb_youtube_].sb_youtube .sby_footer .sby_loader,
415
+ [id^=sb_youtube_].sb_youtube .sby_item .sby_loader,
416
+ [id^=sb_youtube_].sb_youtube .sby_player_outer_wrap .sby_loader{
417
+ position: absolute;
418
+ margin-top: -11px;
419
+ background-color: #fff;
420
+ }
421
+ [id^=sb_youtube_].sb_youtube .sby_item.sby_player_loading,
422
+ [id^=sb_youtube_].sb_youtube .sby_player_outer_wrap.sby_player_loading {
423
+ opacity: .8;
424
+ }
425
+ @-webkit-keyframes sby-sk-scaleout {
426
+ 0% { -webkit-transform: scale(0) }
427
+ 100% {
428
+ -webkit-transform: scale(1.0);
429
+ opacity: 0;
430
+ }
431
+ }
432
+ @keyframes sby-sk-scaleout {
433
+ 0% {
434
+ -webkit-transform: scale(0);
435
+ -ms-transform: scale(0);
436
+ transform: scale(0);
437
+ } 100% {
438
+ -webkit-transform: scale(1.0);
439
+ -ms-transform: scale(1.0);
440
+ transform: scale(1.0);
441
+ opacity: 0;
442
+ }
443
+ }
444
+
445
+ [id^=sb_youtube_].sb_youtube .fa-spin,
446
+ #sby_lightbox .fa-spin{
447
+ -webkit-animation: fa-spin 2s infinite linear;
448
+ animation: fa-spin 2s infinite linear
449
+ }
450
+
451
+ [id^=sb_youtube_].sb_youtube .fa-pulse,
452
+ #sby_lightbox .fa-pulse{
453
+ -webkit-animation: fa-spin 1s infinite steps(8);
454
+ animation: fa-spin 1s infinite steps(8)
455
+ }
456
+
457
+ @-webkit-keyframes fa-spin {
458
+ 0% {
459
+ -webkit-transform: rotate(0deg);
460
+ transform: rotate(0deg)
461
+ }
462
+ 100% {
463
+ -webkit-transform: rotate(359deg);
464
+ transform: rotate(359deg)
465
+ }
466
+ }
467
+
468
+ @keyframes fa-spin {
469
+ 0% {
470
+ -webkit-transform: rotate(0deg);
471
+ transform: rotate(0deg)
472
+ }
473
+ 100% {
474
+ -webkit-transform: rotate(359deg);
475
+ transform: rotate(359deg)
476
+ }
477
+ }
478
+
479
+ /* HEADER */
480
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header{
481
+ float: left;
482
+ clear: both;
483
+ margin: 0 0 15px 0;
484
+ padding: 0;
485
+ line-height: 1.2;
486
+ width: 100%;
487
+ }
488
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header a{
489
+ float: left;
490
+ display: block;
491
+ /*width: 100%;*/
492
+ min-width: 100%\9;
493
+ text-decoration: none;
494
+ transition: color 0.5s ease;
495
+ }
496
+ /** Medium Header */
497
+ /* Only use medium & large headers on devices above 480px */
498
+ @media all and (min-width: 480px){
499
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_img {
500
+ width: 80px;
501
+ height: 80px;
502
+ border-radius: 40px;
503
+ }
504
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_img img {
505
+ width: 80px;
506
+ height: 80px;
507
+ border-radius: 40px;
508
+ }
509
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3 {
510
+ font-size: 20px;
511
+ }
512
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info,
513
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio{
514
+ font-size: 14px;
515
+ }
516
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3,
517
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info,
518
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio{
519
+ margin-left: 95px !important;
520
+ line-height: 1.4
521
+ }
522
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3{
523
+ margin-right: -85px !important;
524
+ }
525
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info{
526
+ margin-top: 4px !important;
527
+ }
528
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text.sby_no_bio h3{
529
+ padding-top: 20px !important;
530
+ }
531
+ /** Large Header */
532
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_img {
533
+ width: 120px;
534
+ height: 120px;
535
+ border-radius: 60px;
536
+ }
537
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_img img {
538
+ width: 120px;
539
+ height: 120px;
540
+ border-radius: 60px;
541
+ }
542
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3 {
543
+ font-size: 28px;
544
+ }
545
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info,
546
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio{
547
+ font-size: 16px;
548
+ }
549
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3,
550
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info,
551
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio{
552
+ margin-left: 140px !important;
553
+ line-height: 1.5;
554
+ }
555
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3{
556
+ margin-right: -120px !important;
557
+ }
558
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info{
559
+ margin-top: 12px !important;
560
+ }
561
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text.sby_no_bio h3{
562
+ padding-top: 32px !important;
563
+ }
564
+ }
565
+
566
+ /* Header profile pic */
567
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img{
568
+ float: left;
569
+ position: relative;
570
+ width: 50px;
571
+ margin: 0 0 0 -100% !important;
572
+ overflow: hidden;
573
+
574
+ -moz-border-radius: 40px;
575
+ -webkit-border-radius: 40px;
576
+ border-radius: 40px;
577
+ }
578
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img img{
579
+ float: left;
580
+ margin: 0 !important;
581
+ padding: 0 !important;
582
+ border: none !important;
583
+
584
+ -moz-border-radius: 40px;
585
+ -webkit-border-radius: 40px;
586
+ border-radius: 40px;
587
+ }
588
+ /* Profile pic hover */
589
+ /* Profile pic hover */
590
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{
591
+ opacity: 0;
592
+ position: absolute;
593
+ width: 100%;
594
+ top: 0;
595
+ bottom: 0;
596
+ left: 0;
597
+ text-align: center;
598
+ color: #fff;
599
+ background: rgba(0,0,0,0.75);
600
+ }
601
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_no_consent .sby_header_img {
602
+ height: 50px;
603
+ }
604
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_no_consent .sby_header_img_hover{
605
+ opacity: 1;
606
+ }
607
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover .sby_new_logo{
608
+ position: absolute;
609
+ top: 50%;
610
+ left: 50%;
611
+ margin-top: -12px;
612
+ margin-left: -12px;
613
+ width: 24px;
614
+ height: 24px;
615
+ font-size: 24px;
616
+ }
617
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover i {
618
+ overflow: hidden;
619
+ background: url('../img/small-logo.png') no-repeat 0 0;
620
+ }
621
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{
622
+ z-index: 2;
623
+ transition: opacity 0.4s ease-in-out;
624
+ }
625
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_fade_in{
626
+ opacity: 1;
627
+ transition: opacity 0.2s ease-in-out;
628
+ }
629
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{
630
+ position: absolute;
631
+ width: 100%;
632
+ top: 0;
633
+ bottom: 0;
634
+ left: 0;
635
+ text-align: center;
636
+ color: #fff;
637
+ background: rgba(0,0,0,0.75);
638
+
639
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
640
+ filter: alpha(opacity=0);
641
+ -moz-opacity: 0;
642
+ -khtml-opacity: 0;
643
+ opacity: 0;
644
+ border-radius: 40px;
645
+ transition: opacity 0.2s;
646
+ }
647
+ /* Fade the Youtube icon in when hovering on the header */
648
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header a:hover .sby_header_img_hover,
649
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header a:focus .sby_header_img_hover{
650
+ opacity: 1;
651
+ }
652
+ /* Header text */
653
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text{
654
+ float: left;
655
+ width: 100%;
656
+ padding-top: 5px;
657
+ }
658
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header a{
659
+ text-decoration: none;
660
+ }
661
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text .sby_bio,
662
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text h3{
663
+ float: left;
664
+ clear: both;
665
+ width: auto;
666
+ margin: 0 0 0 60px !important;
667
+ padding: 0 !important;
668
+ }
669
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header h3{
670
+ font-size: 16px;
671
+ line-height: 1.3;
672
+ }
673
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header p{
674
+ font-size: 13px;
675
+ line-height: 1.3;
676
+ margin: 0;
677
+ padding: 0;
678
+ }
679
+ [id^=sb_youtube_].sb_youtube p:empty { display: none; }
680
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text img.emoji{
681
+ margin-right: 3px !important;
682
+ }
683
+
684
+ /* No bio */
685
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text.sby_no_bio h3{
686
+ padding-top: 9px !important;
687
+ }
688
+ [id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text.sby_no_bio .sby_bio_info{
689
+ clear: both;
690
+ }
691
+
692
+ /* Buttons */
693
+ [id^=sb_youtube_].sb_youtube .sby_footer{
694
+ float: left;
695
+ clear: both;
696
+ width: 100%;
697
+ text-align: center;
698
+ }
699
+ [id^=sb_youtube_].sb_youtube .sby_footer .fa-spinner{
700
+ display: none;
701
+ position: absolute;
702
+ top: 50%;
703
+ left: 50%;
704
+ margin: -8px 0 0 -7px;
705
+ font-size: 15px;
706
+ }
707
+ [id^=sb_youtube_].sb_youtube .sby_footer{
708
+ opacity: 1;
709
+ transition: all 0.5s ease-in;
710
+ }
711
+ [id^=sb_youtube_].sb_youtube .sby_load_btn .sby_btn_text, [id^=sb_youtube_].sb_youtube .sby_load_btn .sby_loader{
712
+ opacity: 1;
713
+ transition: all 0.1s ease-in;
714
+ }
715
+ [id^=sb_youtube_].sb_youtube .sby_hidden{
716
+ opacity: 0 !important;
717
+ }
718
+ [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn,
719
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn a{
720
+ display: -moz-inline-stack;
721
+ display: inline-block;
722
+ vertical-align: top;
723
+ zoom: 1;
724
+ *display: inline;
725
+
726
+ padding: 7px 14px;
727
+ margin: 5px auto 0 auto;
728
+ background: #333;
729
+ color: #eee;
730
+ border: none;
731
+ color: #fff;
732
+ text-decoration: none;
733
+ font-size: 13px;
734
+ line-height: 1.5;
735
+
736
+ -moz-border-radius: 4px;
737
+ -webkit-border-radius: 4px;
738
+ border-radius: 4px;
739
+
740
+ -webkit-box-sizing: border-box;
741
+ -moz-box-sizing: border-box;
742
+ box-sizing: border-box;
743
+ }
744
+ [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn {
745
+ position: relative;
746
+ }
747
+ /* Follow button */
748
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn{
749
+ display: -moz-inline-stack;
750
+ display: inline-block;
751
+ vertical-align: top;
752
+ zoom: 1;
753
+ *display: inline;
754
+ text-align: center;
755
+ }
756
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_top{
757
+ display: block;
758
+ margin-bottom: 5px;
759
+ }
760
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn a{
761
+ background: #408bd1;
762
+ color: #fff;
763
+ }
764
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn a,
765
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn a,
766
+ [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn{
767
+ transition: all 0.1s ease-in;
768
+ }
769
+ /* Hover state for default colors */
770
+ [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn:hover{
771
+ outline: none;
772
+ box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.25);
773
+ }
774
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn a:hover,
775
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn a:focus{
776
+ outline: none;
777
+ box-shadow: inset 0 0 10px 20px #359dff;
778
+ }
779
+ /* If a custom color is applied then just use opacity for the hover effect */
780
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_custom a:hover,
781
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_custom a:focus,
782
+ [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn.sby_custom:hover{
783
+ box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.15);
784
+ }
785
+ /* Active state */
786
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn a:active,
787
+ [id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn:active{
788
+ box-shadow: inset 0 0 10px 20px rgba(0,0,0,0.3);
789
+ }
790
+
791
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn .fa,
792
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn svg{
793
+ margin-bottom: -1px;
794
+ margin-right: 7px;
795
+ font-size: 15px;
796
+ }
797
+ [id^=sb_youtube_].sb_youtube .sby_follow_btn svg{
798
+ vertical-align: -.125em;
799
+ }
800
+ [id^=sb_youtube_].sb_youtube .sby_footer .sby_follow_btn{
801
+ margin-left: 5px;
802
+ }
803
+
804
+ /* Media queries */
805
+ @media all and (max-width: 640px){
806
+ /* Make 3-6 cols into 2 col */
807
+ [id^=sb_youtube_].sb_youtube.sby_col_3.sby_mob_col_auto .sby_items_wrap .sby_item,
808
+ [id^=sb_youtube_].sb_youtube.sby_col_4.sby_mob_col_auto .sby_items_wrap .sby_item,
809
+ [id^=sb_youtube_].sb_youtube.sby_col_5.sby_mob_col_auto .sby_items_wrap .sby_item,
810
+ [id^=sb_youtube_].sb_youtube.sby_col_6.sby_mob_col_auto .sby_items_wrap .sby_item{
811
+ width: 50%;
812
+ }
813
+ /* Make 7-10 cols into 4 col */
814
+ [id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item,
815
+ [id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item,
816
+ [id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item,
817
+ [id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item,
818
+ [id^=sb_youtube_].sb_youtube.sby_col_7.sby_mob_col_auto .sby_items_wrap .sby_item,
819
+ [id^=sb_youtube_].sb_youtube.sby_col_8.sby_mob_col_auto .sby_items_wrap .sby_item,
820
+ [id^=sb_youtube_].sb_youtube.sby_col_9.sby_mob_col_auto .sby_items_wrap .sby_item,
821
+ [id^=sb_youtube_].sb_youtube.sby_col_10.sby_mob_col_auto .sby_items_wrap .sby_item{
822
+ width: 25%;
823
+ }
824
+ [id^=sb_youtube_].sb_youtube.sby_col_2 .sby_items_wrap .sby_item{ width: 50%; }
825
+ [id^=sb_youtube_].sb_youtube.sby_col_3 .sby_items_wrap .sby_item{ width: 33.33%; }
826
+ [id^=sb_youtube_].sb_youtube.sby_col_4 .sby_items_wrap .sby_item{ width: 25%; }
827
+ [id^=sb_youtube_].sb_youtube.sby_col_5 .sby_items_wrap .sby_item{ width: 20%; }
828
+ [id^=sb_youtube_].sb_youtube.sby_col_6 .sby_items_wrap .sby_item{ width: 16.66%; }
829
+ [id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item{ width: 14.28%; }
830
+ [id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item{ width: 12.5%; }
831
+ [id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item{ width: 11.11%; }
832
+ [id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item{ width: 10%; }
833
+ /* On mobile make the min-width 100% */
834
+ [id^=sb_youtube_].sb_youtube.sby_width_resp{
835
+ width: 100% !important;
836
+ }
837
+ }
838
+ @media all and (max-width: 480px){
839
+ /* Make all cols into 1 col */
840
+ [id^=sb_youtube_].sb_youtube.sby_col_3.sby_mob_col_auto .sby_items_wrap .sby_item,
841
+ [id^=sb_youtube_].sb_youtube.sby_col_4.sby_mob_col_auto .sby_items_wrap .sby_item,
842
+ [id^=sb_youtube_].sb_youtube.sby_col_5.sby_mob_col_auto .sby_items_wrap .sby_item,
843
+ [id^=sb_youtube_].sb_youtube.sby_col_6.sby_mob_col_auto .sby_items_wrap .sby_item,
844
+ [id^=sb_youtube_].sb_youtube.sby_col_7.sby_mob_col_auto .sby_items_wrap .sby_item,
845
+ [id^=sb_youtube_].sb_youtube.sby_col_8.sby_mob_col_auto .sby_items_wrap .sby_item,
846
+ [id^=sb_youtube_].sb_youtube.sby_col_9.sby_mob_col_auto .sby_items_wrap .sby_item,
847
+ [id^=sb_youtube_].sb_youtube.sby_col_10.sby_mob_col_auto .sby_items_wrap .sby_item,
848
+ [id^=sb_youtube_].sb_youtube.sby_mob_col_1 .sby_items_wrap .sby_item{
849
+ width: 100%;
850
+ }
851
+ [id^=sb_youtube_].sb_youtube.sby_mob_col_2 .sby_items_wrap .sby_item{ width: 50%; }
852
+ [id^=sb_youtube_].sb_youtube.sby_mob_col_3 .sby_items_wrap .sby_item{ width: 33.33%; }
853
+ [id^=sb_youtube_].sb_youtube.sby_mob_col_4 .sby_items_wrap .sby_item{ width: 25%; }
854
+ [id^=sb_youtube_].sb_youtube.sby_mob_col_5 .sby_items_wrap .sby_item{ width: 20%; }
855
+ [id^=sb_youtube_].sb_youtube.sby_mob_col_6 .sby_items_wrap .sby_item{ width: 16.66%; }
856
+ [id^=sb_youtube_].sb_youtube.sby_mob_col_7 .sby_items_wrap .sby_item{ width: 14.28%; }
857
+ }
858
+
859
+ /* --- Lightbox --- */
860
+
861
+ .sby_lightboxOverlay {
862
+ position: absolute;
863
+ top: 0;
864
+ left: 0;
865
+ z-index: 99999;
866
+ background-color: black;
867
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
868
+ opacity: 0.9;
869
+ display: none;
870
+ }
871
+ .sby_lightbox {
872
+ position: absolute;
873
+ left: 0;
874
+ width: 100%;
875
+ z-index: 100000;
876
+ line-height: 0;
877
+ font-weight: normal;
878
+ }
879
+ .sby_lightbox .sby_lb-image {
880
+ display: block;
881
+ height: auto;
882
+ max-width: inherit;
883
+ -webkit-border-radius: 3px;
884
+ -moz-border-radius: 3px;
885
+ -ms-border-radius: 3px;
886
+ -o-border-radius: 3px;
887
+ border-radius: 3px;
888
+ }
889
+ .sby_lightbox a:hover,
890
+ .sby_lightbox a:focus,
891
+ .sby_lightbox a:active{
892
+ outline: none;
893
+ }
894
+ .sby_lightbox a img {
895
+ border: none;
896
+ }
897
+ .sby_lb-outerContainer {
898
+ position: relative;
899
+ background-color: #000;
900
+ *zoom: 1;
901
+ width: 250px;
902
+ height: 250px;
903
+ margin: 0 auto 5px auto;
904
+ -webkit-border-radius: 3px;
905
+ -moz-border-radius: 3px;
906
+ -ms-border-radius: 3px;
907
+ -o-border-radius: 3px;
908
+ border-radius: 3px;
909
+ }
910
+ .sby_lb-outerContainer:after {
911
+ content: "";
912
+ display: table;
913
+ clear: both;
914
+ }
915
+ .sby_lb-container {
916
+ position: relative;
917
+ padding: 4px;
918
+ top: 0;
919
+ left: 0;
920
+ width: 100%;
921
+ height: 100%;
922
+ bottom: 0;
923
+ right: 0;
924
+
925
+ -webkit-border-radius: 3px;
926
+ -moz-border-radius: 3px;
927
+ -ms-border-radius: 3px;
928
+ -o-border-radius: 3px;
929
+ border-radius: 3px;
930
+ }
931
+ .sby_lb-loader {
932
+ position: absolute;
933
+ top: 43%;
934
+ left: 0;
935
+ height: 25%;
936
+ width: 100%;
937
+ text-align: center;
938
+ line-height: 0;
939
+ }
940
+ .sby_lb-cancel {
941
+ display: block;
942
+ width: 32px;
943
+ height: 32px;
944
+ margin: 0 auto;
945
+ background-color: #666;
946
+ background-color: rgba(255,255,255,0.5);
947
+
948
+ border-radius: 100%;
949
+ -webkit-animation: ctf-sk-scaleout 1.0s infinite ease-in-out;
950
+ animation: ctf-sk-scaleout 1.0s infinite ease-in-out;
951
+ }
952
+
953
+
954
+ .sby_lb-nav {
955
+ /*position: absolute;*/
956
+ top: 0;
957
+ left: 0;
958
+ /*height: 100%;*/
959
+ width: 100%;
960
+ z-index: 10;
961
+ /*pointer-events: none;*/
962
+ }
963
+ .sby_lb-container > .nav {
964
+ left: 0;
965
+ }
966
+ .sby_lb-nav a {
967
+ position: absolute;
968
+ z-index: 100;
969
+ top: 0;
970
+ height: 90%;
971
+ outline: none;
972
+ background-image: url('data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
973
+ }
974
+
975
+
976
+ /* Arrows */
977
+ .sby_lb-prev, .sby_lb-next {
978
+ height: 100%;
979
+ cursor: pointer;
980
+ display: block;
981
+ }
982
+ .sby_lb-nav a.sby_lb-prev {
983
+ /*width: 30%;*/
984
+ width: 50px;
985
+ left: -70px;
986
+ padding-left: 10px;
987
+ padding-right: 10px;
988
+ float: left;
989
+
990
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0.5);
991
+ opacity: 0.5;
992
+ -webkit-transition: opacity 0.2s;
993
+ -moz-transition: opacity 0.2;
994
+ -o-transition: opacity 0.2s;
995
+ transition: opacity 0.2s;
996
+
997
+ }
998
+
999
+ .sby_lb-nav a.sby_lb-prev:hover {
1000
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
1001
+ opacity: 1;
1002
+ }
1003
+
1004
+ .sby_lb-nav a.sby_lb-next {
1005
+ /*width: 30%;*/
1006
+ width: 50px;
1007
+ right: -70px;
1008
+ padding-left: 10px;
1009
+ padding-right: 10px;
1010
+ float: right;
1011
+
1012
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0.5);
1013
+ opacity: 0.5;
1014
+ -webkit-transition: opacity 0.2s;
1015
+ -moz-transition: opacity 0.2s;
1016
+ -o-transition: opacity 0.2s;
1017
+ transition: opacity 0.2s;
1018
+
1019
+ }
1020
+
1021
+ .sby_lb-nav a.sby_lb-next:hover {
1022
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
1023
+ opacity: 1;
1024
+ }
1025
+
1026
+ .sby_lb-nav span{
1027
+ display: block;
1028
+ top: 55%;
1029
+ position: absolute;
1030
+ left: 20px;
1031
+ width: 34px;
1032
+ height: 45px;
1033
+ margin: -25px 0 0 0;
1034
+ background: url(../img/sby-sprite.png) no-repeat;
1035
+ }
1036
+ .sby_lb-nav a.sby_lb-prev span{
1037
+ background-position: -53px 0;
1038
+ }
1039
+ .sby_lb-nav a.sby_lb-next span{
1040
+ left: auto;
1041
+ right: 20px;
1042
+ background-position: -18px 0;
1043
+ }
1044
+
1045
+
1046
+ .sby_lb-dataContainer {
1047
+ margin: 0 auto;
1048
+ padding-top: 5px;
1049
+ *zoom: 1;
1050
+ width: 100%;
1051
+ font-family: "Open Sans", Helvetica, Arial, sans-serif;
1052
+
1053
+ -moz-border-radius-bottomleft: 4px;
1054
+ -webkit-border-bottom-left-radius: 4px;
1055
+ border-bottom-left-radius: 4px;
1056
+ -moz-border-radius-bottomright: 4px;
1057
+ -webkit-border-bottom-right-radius: 4px;
1058
+ border-bottom-right-radius: 4px;
1059
+ }
1060
+ .sby_lb-dataContainer:after {
1061
+ content: "";
1062
+ display: table;
1063
+ clear: both;
1064
+ }
1065
+ .sby_lb-data {
1066
+ padding: 0 4px;
1067
+ color: #ccc;
1068
+ }
1069
+ .sby_lb-data .sby_lb-details {
1070
+ width: 85%;
1071
+ float: left;
1072
+ text-align: left;
1073
+ line-height: 1.1;
1074
+ }
1075
+ .sby_lb-data .sby_lb-caption {
1076
+ float: left;
1077
+ font-size: 13px;
1078
+ font-weight: normal;
1079
+ line-height: 1.3;
1080
+ padding-bottom: 3px;
1081
+ color: #ccc;
1082
+
1083
+ word-wrap: break-word;
1084
+ -webkit-hyphens: auto;
1085
+ -moz-hyphens: auto;
1086
+ hyphens: auto;
1087
+ }
1088
+ .sby_lb-data .sby_lb-caption a,
1089
+ .sby_lb-data .sby_lb-caption .ctf-screename-sep{
1090
+ color: #ccc;
1091
+ font-weight: bold;
1092
+ text-decoration: none;
1093
+ }
1094
+ .sby_lb-data .sby_lb-caption a:hover{
1095
+ color: #fff;
1096
+ text-decoration: underline;
1097
+ }
1098
+ .sby_lb-data .sby_lb-caption .sby_lightbox_username{
1099
+ float: left;
1100
+ width: 100%;
1101
+ color: #ccc;
1102
+ padding-bottom: 0;
1103
+ display: block;
1104
+ margin: 0 0 5px 0;
1105
+ }
1106
+ .sby_lb-data .sby_lb-caption .sby_lightbox_username{
1107
+ color: #ccc;
1108
+ }
1109
+ .sby_lb-data .sby_lb-caption .sby_lightbox_username:hover p{
1110
+ color: #fff;
1111
+ text-decoration: underline;
1112
+ }
1113
+ .sby_lightbox .sby_lightbox_username img {
1114
+ float: left;
1115
+ border: none;
1116
+ width: 48px;
1117
+ height: 48px;
1118
+ margin-right: 10px;
1119
+ background: #666;
1120
+
1121
+ -moz-border-radius: 5px;
1122
+ -webkit-border-radius: 5px;
1123
+ border-radius: 5px;
1124
+ }
1125
+ .sby_lightbox_username p{
1126
+ float: left;
1127
+ margin: 0;
1128
+ padding: 0;
1129
+ color: #ccc;
1130
+ line-height: 32px;
1131
+ font-weight: bold;
1132
+ font-size: 13px;
1133
+ text-align: left;
1134
+ }
1135
+
1136
+ .sby_lb-data .ctf-caption-text{
1137
+ width: 100%;
1138
+ margin-left: 58px;
1139
+ padding-top: 3px;
1140
+ }
1141
+ .sby_lb-data .sby_lb-caption .ctf-tweet-date,
1142
+ .sby_lb-data .sby_lb-caption .ctf-author-screenname{
1143
+ font-weight: normal;
1144
+ }
1145
+ .sby_lb-data .sby_lb-info{
1146
+ width: 100%;
1147
+ float: left;
1148
+ clear: both;
1149
+ }
1150
+ .sby_lb-data .sby_lb-number {
1151
+ display: block;
1152
+ float: left;
1153
+ clear: both;
1154
+ padding: 5px 0 15px 0;
1155
+ font-size: 12px;
1156
+ color: #999999;
1157
+ }
1158
+ .sby_lb-data .sby_lb-close {
1159
+ display: block;
1160
+ float: right;
1161
+ width: 30px;
1162
+ height: 30px;
1163
+ background: url(../img/close.png) top right no-repeat;
1164
+ text-align: right;
1165
+ outline: none;
1166
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=70);
1167
+ opacity: 0.7;
1168
+ -webkit-transition: opacity 0.2s;
1169
+ -moz-transition: opacity 0.2s;
1170
+ -o-transition: opacity 0.2s;
1171
+ transition: opacity 0.2s;
1172
+ }
1173
+ .sby_lb-data .sby_lb-close:hover {
1174
+ cursor: pointer;
1175
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
1176
+ opacity: 1;
1177
+ }
1178
+
1179
+ /* Lightbox video - must go after lighbox CSS */
1180
+ /* Leave a gap at the bottom of the nav for video controls */
1181
+ .sby_lb-nav {
1182
+ height: auto;
1183
+ }
1184
+ /* Remove 4px padding from lightbox container so video lines up */
1185
+ .sby_lb-container{
1186
+ padding: 0;
1187
+ }
1188
+ .sby_lb-container iframe {
1189
+ position: absolute;
1190
+ top: 0;
1191
+ left:0;
1192
+ width: 100%;
1193
+ height: 100%;
1194
+ z-index: 1;
1195
+ }
1196
+ /* Lightbox action links */
1197
+ #sby_lightbox .sby_lightbox_action{
1198
+ float: left;
1199
+ /*clear: both;*/
1200
+ position: relative;
1201
+ padding: 0 0 0 10px;
1202
+ margin: 5px 0 0 10px;
1203
+ border-left: 1px solid #666;
1204
+ font-size: 12px;
1205
+ }
1206
+ #sby_lightbox .sby_lightbox_action a{
1207
+ display: block;
1208
+ float: left;
1209
+ color: #999;
1210
+ text-decoration: none;
1211
+ }
1212
+ #sby_lightbox .sby_lightbox_action a:hover,
1213
+ #sby_lightbox .sby_lightbox_action a:focus{
1214
+ color: #fff;
1215
+ }
1216
+ #sby_lightbox .sby_lightbox_action .fa,
1217
+ #sby_lightbox .sby_lightbox_action svg {
1218
+ margin-right: 5px;
1219
+ }
1220
+ #sby_lightbox .sby_lightbox_action.sby_youtube .fa {
1221
+ font-size: 13px;
1222
+ }
1223
+ #sby_lightbox .sby_tooltip_social a svg {
1224
+ font-size: 19px;
1225
+ padding: 3px 4px;
1226
+ margin: auto;
1227
+ }
1228
+ /* Lightbox tooltip */
1229
+ #sby_lightbox .sby_lightbox_tooltip{
1230
+ display: none;
1231
+ position: absolute;
1232
+ width: 100px;
1233
+ bottom: 22px;
1234
+ left: 0;
1235
+ padding: 5px 10px;
1236
+ margin: 0;
1237
+ background: rgba(255,255,255,0.9);
1238
+ color: #222;
1239
+ font-size: 12px;
1240
+ line-height: 1.3;
1241
+
1242
+ -moz-border-radius: 4px;
1243
+ -webkit-border-radius: 4px;
1244
+ border-radius: 4px;
1245
+
1246
+ box-shadow: 0 0 10px rgba(0,0,0,0.4);
1247
+ -moz-box-shadow: 0 0 10px rgba(0,0,0,0.4);
1248
+ -webkit-box-shadow: 0 0 10px rgba(0,0,0,0.4);
1249
+
1250
+ -webkit-box-sizing: border-box;
1251
+ -moz-box-sizing: border-box;
1252
+ box-sizing: border-box;
1253
+ }
1254
+ #sby_lightbox .sby_lightbox_tooltip .fa-play{
1255
+ position: absolute;
1256
+ font-size: 8px;
1257
+ bottom: -6px;
1258
+ left: 36px;
1259
+ color: rgba(255,255,255,0.9);
1260
+ }
1261
+ #sby_lightbox .sby_tooltip_social a .fa{
1262
+ font-size: 16px;
1263
+ margin: 0;
1264
+ padding: 5px;
1265
+ }
1266
+ #sby_lightbox .sby_tooltip_social a#sby_facebook_icon .fa,
1267
+ #sby_lightbox .sby_tooltip_social a#sby_twitter_icon .fa,
1268
+ #sby_lightbox .sby_tooltip_social a#sby_pinterest_icon .fa{
1269
+ padding-top: 4px;
1270
+ font-size: 18px;
1271
+ }
1272
+ #sby_lightbox .sby_gdpr_notice {
1273
+ z-index: 6;
1274
+ display: block;
1275
+ position: absolute;
1276
+ top: 50%;
1277
+ left: 50%;
1278
+ margin-left: -44px;
1279
+ margin-top: -44px;
1280
+ padding: 20px;
1281
+ }
1282
+ #sby_lightbox .sby_gdpr_notice svg:not(:root).svg-inline--fa {
1283
+ position: relative;
1284
+ display: block !important;
1285
+ height: 48px;
1286
+ width: 48px;
1287
+ opacity: .8;
1288
+ }
1289
+ #sby_lightbox .sby_gdpr_notice:hover svg:not(:root).svg-inline--fa {
1290
+ opacity: 1;
1291
+ }
1292
+ /* Hide photos tooltip */
1293
+ #sby_lightbox #sby_mod_box{
1294
+ width: 280px;
1295
+ padding: 5px 10px 7px 10px;
1296
+ }
1297
+ /* Social icons tooltip */
1298
+ #sby_lightbox .sby_tooltip_social{
1299
+ width: 172px;
1300
+ padding: 5px 5px 4px 5px;
1301
+ }
1302
+ #sby_lightbox .sby_tooltip_social a{
1303
+ color: #333;
1304
+
1305
+ -moz-border-radius: 4px;
1306
+ -webkit-border-radius: 4px;
1307
+ border-radius: 4px;
1308
+ }
1309
+ #sby_lightbox .sby_lightbox_action #sby_facebook_icon:hover{ background: #3b5998; }
1310
+ #sby_lightbox .sby_lightbox_action #sby_twitter_icon:hover{ background: #00aced; }
1311
+ #sby_lightbox .sby_lightbox_action #sby_google_icon:hover{ background: #dd4b39; }
1312
+ #sby_lightbox .sby_lightbox_action #sby_linkedin_icon:hover{ background: #007bb6; }
1313
+ #sby_lightbox .sby_lightbox_action #sby_pinterest_icon:hover{ background: #cb2027; }
1314
+ #sby_lightbox .sby_lightbox_action #sby_email_icon:hover{ background: #333; }
1315
+
1316
+ .sby_lb-outerContainer, .sby_lb-dataContainer{
1317
+ min-width: 450px;
1318
+ }
1319
+ @media all and (max-width: 450px){
1320
+ .sby_lb-outerContainer, .sby_lb-dataContainer {
1321
+ min-width: 0; /* Remove min-width on lightbox on mobile */
1322
+ }
1323
+ }
1324
+ .sby_lightbox .sby_lb-image {
1325
+ display: block;
1326
+ height: auto;
1327
+ max-width: inherit;
1328
+ margin: 0 auto;
1329
+ -webkit-border-radius: 0;
1330
+ -moz-border-radius: 0;
1331
+ -ms-border-radius: 0;
1332
+ -o-border-radius: 0;
1333
+ border-radius: 0;
1334
+ }
1335
+
1336
+ /* Mod only error msgs */
1337
+ #sby_mod_error{
1338
+ display: none;
1339
+ border: 1px solid #ddd;
1340
+ background: #eee;
1341
+ color: #333;
1342
+ margin: 10px 0 0;
1343
+ padding: 10px 15px;
1344
+ font-size: 13px;
1345
+ text-align: center;
1346
+ clear: both;
1347
+ margin-bottom: 10px;
1348
+
1349
+ -moz-border-radius: 4px;
1350
+ -webkit-border-radius: 4px;
1351
+ border-radius: 4px;
1352
+ }
1353
+ #sby_mod_error p{
1354
+ padding: 5px 0 !important;
1355
+ margin: 0 !important;
1356
+ line-height: 1.3 !important;
1357
+ }
1358
+ #sby_mod_error ol,
1359
+ #sby_mod_error ul{
1360
+ padding: 5px 0 5px 20px !important;
1361
+ margin: 0 !important;
1362
+ }
1363
+ #sby_mod_error li{
1364
+ padding: 1px 0 !important;
1365
+ margin: 0 !important;
1366
+ }
1367
+ #sby_mod_error span{
1368
+ font-size: 12px;
1369
+ }
1370
+
1371
+ /* SVGs */
1372
+ [id^=sb_youtube_].sb_youtube svg:not(:root).svg-inline--fa,
1373
+ [id^=sb_youtube_].sb_youtube_lightbox svg:not(:root).svg-inline--fa{
1374
+ box-sizing: unset;
1375
+ overflow: visible;
1376
+ width: 1em;
1377
+ }
1378
+ [id^=sb_youtube_].sb_youtube .svg-inline--fa.fa-w-16,
1379
+ [id^=sb_youtube_].sb_youtube .svg-inline--fa.fa-w-16{
1380
+ width: 16px;
1381
+ }
1382
+ [id^=sb_youtube_].sb_youtube .svg-inline--fa,
1383
+ [id^=sb_youtube_].sb_youtube_lightbox .svg-inline--fa{
1384
+ display: inline-block;
1385
+ font-size: inherit;
1386
+ height: 1em;
1387
+ overflow: visible;
1388
+ vertical-align: -.125em;
1389
+ }
1390
+
1391
+ [id^=sb_youtube_].sb_youtube.sby_player_loaded .sby_player_outer_wrap .sby_video_thumbnail,
1392
+ [id^=sb_youtube_].sb_youtube.sby_player_loaded.sby_layout_list .sby_video_thumbnail{
1393
+ z-index: -1 !important;
1394
  }
css/sb-youtube.min.css CHANGED
@@ -1 +1 @@
1
- [id^=sb_youtube_].sb_youtube{width:100%;margin:0 auto;padding:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[id^=sb_youtube_].sb_youtube *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[id^=sb_youtube_].sb_youtube:after{content:"";display:table;clear:both}#sby_lightbox iframe,[id^=sb_youtube_].sb_youtube iframe{pointer-events:all!important}[id^=sb_youtube_].sb_youtube.sby_fixed_height{overflow:hidden;overflow-y:auto;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[id^=sb_youtube_].sb_youtube .sby_items_wrap{width:100%;float:left;line-height:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube .sby_player_outer_wrap .sby_video_thumbnail_wrap,[id^=sb_youtube_].sb_youtube .sby_player_wrap{display:-moz-inline-stack;display:inline-block;vertical-align:top;zoom:1;max-height:1000px;padding:inherit!important;text-decoration:none;opacity:1;overflow:hidden;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:all .5s ease;-moz-transition:all .5s ease;-o-transition:all .5s ease;-ms-transition:all .5s ease;transition:all .5s ease}[id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item.sby_no_margin{margin:0!important}[id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item{float:left}[id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item.sby_transition{opacity:0;max-height:0}[id^=sb_youtube_].sb_youtube.sby_col_0 .sby_items_wrap .sby_item{width:100%}[id^=sb_youtube_].sb_youtube.sby_col_1 .sby_items_wrap .sby_item{width:100%}[id^=sb_youtube_].sb_youtube.sby_col_2 .sby_items_wrap .sby_item{width:50%}[id^=sb_youtube_].sb_youtube.sby_col_3 .sby_items_wrap .sby_item{width:33.33%}[id^=sb_youtube_].sb_youtube.sby_col_4 .sby_items_wrap .sby_item{width:25%}[id^=sb_youtube_].sb_youtube.sby_col_5 .sby_items_wrap .sby_item{width:20%}[id^=sb_youtube_].sb_youtube.sby_col_6 .sby_items_wrap .sby_item{width:16.66%}[id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item{width:14.28%}[id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item{width:12.5%}[id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item{width:11.11%}[id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item{width:10%}.sby-screenreader{text-indent:-9999px!important;display:block!important;width:0!important;height:0!important;line-height:0!important}[id^=sb_youtube_].sb_youtube .sby_player_outer_wrap,[id^=sb_youtube_].sb_youtube .sby_video_thumbnail_wrap{width:100%;position:relative;float:left}[id^=sb_youtube_].sb_youtube .sby_video_thumbnail{display:block;position:relative;text-decoration:none;line-height:0;z-index:5}[id^=sb_youtube_].sb_youtube .sby_video_thumbnail img{width:100%;height:auto;border-radius:0}[id^=sb_youtube_].sb_youtube .sby_link{display:none;position:absolute;z-index:1;top:0;right:0;bottom:0;left:0;width:100%;padding:0;background:#333;background:rgba(0,0,0,.6);text-align:center;color:#fff;font-size:12px;line-height:1.1;overflow:hidden}[id^=sb_youtube_].sb_youtube .sby_link.sby_default a,[id^=sb_youtube_].sb_youtube .sby_link.sby_default p,[id^=sb_youtube_].sb_youtube .sby_link.sby_default span{text-shadow:0 0 10px #000}[id^=sb_youtube_].sb_youtube .sby_link .sby_hover_bottom,[id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link,[id^=sb_youtube_].sb_youtube .sby_link .sby_playbtn,[id^=sb_youtube_].sb_youtube .sby_link .sby_username a,[id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link,[id^=sb_youtube_].sb_youtube .sby_link .svg-inline--fa.fa-play{opacity:.9}[id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link:hover,[id^=sb_youtube_].sb_youtube .sby_link .sby_playbtn:hover,[id^=sb_youtube_].sb_youtube .sby_link .sby_username a:hover,[id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link:hover,[id^=sb_youtube_].sb_youtube .sby_link .svg-inline--fa.fa-play:hover{opacity:1}[id^=sb_youtube_].sb_youtube .sby_link_area{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1}[id^=sb_youtube_].sb_youtube .sby_link a{padding:0;text-decoration:none;color:#ddd;color:rgba(255,255,255,.7);line-height:1.1;background:0 0;display:-moz-inline-stack;display:inline-block;vertical-align:top;zoom:1}[id^=sb_youtube_].sb_youtube .sby_link a:active,[id^=sb_youtube_].sb_youtube .sby_link a:hover{color:#fff}[id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link{display:block;position:absolute;z-index:2;top:50%;left:50%;margin-top:-24px;margin-left:-21px;padding:0;font-size:49px;font-style:normal!important}[id^=sb_youtube_].sb_youtube .sby_carousel_vid_first .sby_lightbox_link,[id^=sb_youtube_].sb_youtube .sby_type_video .sby_lightbox_link{display:none}[id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link{font-size:30px;position:absolute;z-index:100;bottom:0;right:2px;padding:8px}[id^=sb_youtube_].sb_youtube .sby_link a:focus,[id^=sb_youtube_].sb_youtube .sby_link a:hover{text-decoration:underline}[id^=sb_youtube_].sb_youtube .sby_player_wrap{z-index:1;width:100%!important;height:100%!important;position:absolute;top:0;left:0}[id^=sb_youtube_].sb_youtube .sby_player_wrap iframe{width:100%!important;height:100%!important}[id^=sb_youtube_].sb_youtube .sby_thumbnail_hover{opacity:0;display:block;position:absolute;top:0;right:0;bottom:0;left:0;z-index:10;color:#fff;background:#333;background:rgba(0,0,0,.6);transition:opacity .6s ease-in-out;-moz-transition:opacity .6s ease-in-out;-webkit-transition:opacity .6s ease-in-out}[id^=sb_youtube_].sb_youtube.sby_layout_list .sby_thumbnail_hover{display:none}.sby_video_title{display:inline-block;height:100%;padding:10px;overflow:hidden;font-size:13px;line-height:1.2}[id^=sb_youtube_].sb_youtube .sby_video_thumbnail:hover .sby_thumbnail_hover{opacity:1;display:block;transition:opacity .2s ease-in-out;-moz-transition:opacity .2s ease-in-out;-webkit-transition:opacity .2s ease-in-out}[id^=sb_youtube_].sb_youtube.sby_layout_list .sby_video_thumbnail:hover .sby_thumbnail_hover{opacity:0;display:none;transition:none;-moz-transition:none;-webkit-transition:none}[id^=sb_youtube_].sb_youtube .sby_video_thumbnail:hover .sby_play_btn{opacity:.5}[id^=sb_youtube_].sb_youtube .sby_play_btn{position:absolute;z-index:1;left:50%;bottom:50%;top:50%;right:50%;margin-top:-25px;margin-left:-28px;color:#fff;width:57px;height:50px;opacity:1;transition:opacity .2s ease-in-out;-moz-transition:opacity .2s ease-in-out;-webkit-transition:opacity .2s ease-in-out}[id^=sb_youtube_].sb_youtube .sby_play_btn_bg{display:block;position:absolute;z-index:-1;top:17px;left:22px;width:0;height:0;border:0 solid transparent;border-bottom-width:9px;border-top-width:9px;border-left:16px solid #fff}[id^=sb_youtube_].sb_youtube .sby_play_btn svg:not(:root).svg-inline--fa{width:57px;height:auto;opacity:.75}[id^=sb_youtube_].sb_youtube .sby_play_btn i,[id^=sb_youtube_].sb_youtube .sby_play_btn svg{color:#000}[id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn{margin-top:-20px;margin-left:-22px;width:45px;height:40px}[id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn_bg{top:13px;left:18px;border-bottom-width:7px;border-top-width:7px;border-left:12px solid #fff}[id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn svg:not(:root).svg-inline--fa{width:45px}[id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn{margin-top:-16px;margin-left:-18px;width:36px;height:32px}[id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn_bg{top:10px;left:14px;border-bottom-width:6px;border-top-width:6px;border-left:10px solid #fff}[id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn svg:not(:root).svg-inline--fa{width:36px}[id^=sb_youtube_].sb_youtube .sby_loader{width:20px;height:20px;position:relative;top:50%;left:50%;margin:-10px 0 0 -10px;background-color:#000;background-color:rgba(0,0,0,.5);border-radius:100%;-webkit-animation:sby-sk-scaleout 1s infinite ease-in-out;animation:sby-sk-scaleout 1s infinite ease-in-out}[id^=sb_youtube_].sb_youtube .sb_youtube_header br,[id^=sb_youtube_].sb_youtube .sby_footer br,[id^=sb_youtube_].sb_youtube .sby_items_wrap br{display:none}.sby_footer p{display:inline;padding:0;margin:0}[id^=sb_youtube_].sb_youtube .sby_footer .sby_loader,[id^=sb_youtube_].sb_youtube .sby_item .sby_loader,[id^=sb_youtube_].sb_youtube .sby_player_outer_wrap .sby_loader{position:absolute;margin-top:-11px;background-color:#fff}[id^=sb_youtube_].sb_youtube .sby_item.sby_player_loading,[id^=sb_youtube_].sb_youtube .sby_player_outer_wrap.sby_player_loading{opacity:.8}@-webkit-keyframes sby-sk-scaleout{0%{-webkit-transform:scale(0)}100%{-webkit-transform:scale(1);opacity:0}}@keyframes sby-sk-scaleout{0%{-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}100%{-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);opacity:0}}#sby_lightbox .fa-spin,[id^=sb_youtube_].sb_youtube .fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}#sby_lightbox .fa-pulse,[id^=sb_youtube_].sb_youtube .fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}[id^=sb_youtube_].sb_youtube .sb_youtube_header{float:left;clear:both;margin:0 0 15px 0;padding:0;line-height:1.2;width:100%}[id^=sb_youtube_].sb_youtube .sb_youtube_header a{float:left;display:block;text-decoration:none;transition:color .5s ease}@media all and (min-width:480px){[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_img{width:80px;height:80px;border-radius:40px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_img img{width:80px;height:80px;border-radius:40px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3{font-size:20px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info{font-size:14px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3{margin-left:95px!important;line-height:1.4}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3{margin-right:-85px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info{margin-top:4px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text.sby_no_bio h3{padding-top:20px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_img{width:120px;height:120px;border-radius:60px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_img img{width:120px;height:120px;border-radius:60px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3{font-size:28px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info{font-size:16px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3{margin-left:140px!important;line-height:1.5}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3{margin-right:-120px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info{margin-top:12px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text.sby_no_bio h3{padding-top:32px!important}}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img{float:left;position:relative;width:50px;margin:0 0 0 -100%!important;overflow:hidden;-moz-border-radius:40px;-webkit-border-radius:40px;border-radius:40px}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img img{float:left;margin:0!important;padding:0!important;border:none!important;-moz-border-radius:40px;-webkit-border-radius:40px;border-radius:40px}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{opacity:0;position:absolute;width:100%;top:0;bottom:0;left:0;text-align:center;color:#fff;background:rgba(0,0,0,.75)}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover .sby_new_logo{position:absolute;top:50%;left:50%;margin-top:-12px;margin-left:-12px;width:24px;height:24px;font-size:24px}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover i{overflow:hidden;background:url(../img/small-logo.png) no-repeat 0 0}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{z-index:2;transition:opacity .4s ease-in-out}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_fade_in{opacity:1;transition:opacity .2s ease-in-out}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{position:absolute;width:100%;top:0;bottom:0;left:0;text-align:center;color:#fff;background:rgba(0,0,0,.75);-moz-opacity:0;-khtml-opacity:0;opacity:0;border-radius:40px;transition:opacity .2s}[id^=sb_youtube_].sb_youtube .sb_youtube_header a:focus .sby_header_img_hover,[id^=sb_youtube_].sb_youtube .sb_youtube_header a:hover .sby_header_img_hover{opacity:1}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text{float:left;width:100%;padding-top:5px}[id^=sb_youtube_].sb_youtube .sb_youtube_header a{text-decoration:none}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text .sby_bio,[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text h3{float:left;clear:both;width:auto;margin:0 0 0 60px!important;padding:0!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header h3{font-size:16px;line-height:1.3}[id^=sb_youtube_].sb_youtube .sb_youtube_header p{font-size:13px;line-height:1.3;margin:0;padding:0}[id^=sb_youtube_].sb_youtube p:empty{display:none}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text img.emoji{margin-right:3px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text.sby_no_bio h3{padding-top:9px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text.sby_no_bio .sby_bio_info{clear:both}[id^=sb_youtube_].sb_youtube .sby_footer{float:left;clear:both;width:100%;text-align:center}[id^=sb_youtube_].sb_youtube .sby_footer .fa-spinner{display:none;position:absolute;top:50%;left:50%;margin:-8px 0 0 -7px;font-size:15px}[id^=sb_youtube_].sb_youtube .sby_footer{opacity:1;transition:all .5s ease-in}[id^=sb_youtube_].sb_youtube .sby_load_btn .sby_btn_text,[id^=sb_youtube_].sb_youtube .sby_load_btn .sby_loader{opacity:1;transition:all .1s ease-in}[id^=sb_youtube_].sb_youtube .sby_hidden{opacity:0!important}[id^=sb_youtube_].sb_youtube .sby_follow_btn a,[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn{display:-moz-inline-stack;display:inline-block;vertical-align:top;zoom:1;padding:7px 14px;margin:5px auto 0 auto;background:#333;color:#eee;border:none;color:#fff;text-decoration:none;font-size:13px;line-height:1.5;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn{position:relative}[id^=sb_youtube_].sb_youtube .sby_follow_btn{display:-moz-inline-stack;display:inline-block;vertical-align:top;zoom:1;text-align:center}[id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_top{display:block;margin-bottom:5px}[id^=sb_youtube_].sb_youtube .sby_follow_btn a{background:#408bd1;color:#fff}[id^=sb_youtube_].sb_youtube .sby_follow_btn a,[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn{transition:all .1s ease-in}[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn:hover{outline:0;box-shadow:inset 0 0 20px 20px rgba(255,255,255,.25)}[id^=sb_youtube_].sb_youtube .sby_follow_btn a:focus,[id^=sb_youtube_].sb_youtube .sby_follow_btn a:hover{outline:0;box-shadow:inset 0 0 10px 20px #359dff}[id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_custom a:focus,[id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_custom a:hover,[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn.sby_custom:hover{box-shadow:inset 0 0 20px 20px rgba(255,255,255,.15)}[id^=sb_youtube_].sb_youtube .sby_follow_btn a:active,[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn:active{box-shadow:inset 0 0 10px 20px rgba(0,0,0,.3)}[id^=sb_youtube_].sb_youtube .sby_follow_btn .fa,[id^=sb_youtube_].sb_youtube .sby_follow_btn svg{margin-bottom:-1px;margin-right:7px;font-size:15px}[id^=sb_youtube_].sb_youtube .sby_follow_btn svg{vertical-align:-.125em}[id^=sb_youtube_].sb_youtube .sby_footer .sby_follow_btn{margin-left:5px}@media all and (max-width:640px){[id^=sb_youtube_].sb_youtube.sby_col_3.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_4.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_5.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_6.sby_mob_col_auto .sby_items_wrap .sby_item{width:50%}[id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_10.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_7.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_8.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_9.sby_mob_col_auto .sby_items_wrap .sby_item{width:25%}[id^=sb_youtube_].sb_youtube.sby_col_2 .sby_items_wrap .sby_item{width:50%}[id^=sb_youtube_].sb_youtube.sby_col_3 .sby_items_wrap .sby_item{width:33.33%}[id^=sb_youtube_].sb_youtube.sby_col_4 .sby_items_wrap .sby_item{width:25%}[id^=sb_youtube_].sb_youtube.sby_col_5 .sby_items_wrap .sby_item{width:20%}[id^=sb_youtube_].sb_youtube.sby_col_6 .sby_items_wrap .sby_item{width:16.66%}[id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item{width:14.28%}[id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item{width:12.5%}[id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item{width:11.11%}[id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item{width:10%}[id^=sb_youtube_].sb_youtube.sby_width_resp{width:100%!important}}@media all and (max-width:480px){[id^=sb_youtube_].sb_youtube.sby_col_10.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_3.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_4.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_5.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_6.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_7.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_8.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_9.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_mob_col_1 .sby_items_wrap .sby_item{width:100%}[id^=sb_youtube_].sb_youtube.sby_mob_col_2 .sby_items_wrap .sby_item{width:50%}[id^=sb_youtube_].sb_youtube.sby_mob_col_3 .sby_items_wrap .sby_item{width:33.33%}[id^=sb_youtube_].sb_youtube.sby_mob_col_4 .sby_items_wrap .sby_item{width:25%}[id^=sb_youtube_].sb_youtube.sby_mob_col_5 .sby_items_wrap .sby_item{width:20%}[id^=sb_youtube_].sb_youtube.sby_mob_col_6 .sby_items_wrap .sby_item{width:16.66%}[id^=sb_youtube_].sb_youtube.sby_mob_col_7 .sby_items_wrap .sby_item{width:14.28%}}.sby_lightboxOverlay{position:absolute;top:0;left:0;z-index:99999;background-color:#000;opacity:.9;display:none}.sby_lightbox{position:absolute;left:0;width:100%;z-index:100000;line-height:0;font-weight:400}.sby_lightbox .sby_lb-image{display:block;height:auto;max-width:inherit;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;-o-border-radius:3px;border-radius:3px}.sby_lightbox a:active,.sby_lightbox a:focus,.sby_lightbox a:hover{outline:0}.sby_lightbox a img{border:none}.sby_lb-outerContainer{position:relative;background-color:#000;width:250px;height:250px;margin:0 auto 5px auto;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;-o-border-radius:3px;border-radius:3px}.sby_lb-outerContainer:after{content:"";display:table;clear:both}.sby_lb-container{position:relative;padding:4px;top:0;left:0;width:100%;height:100%;bottom:0;right:0;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;-o-border-radius:3px;border-radius:3px}.sby_lb-loader{position:absolute;top:43%;left:0;height:25%;width:100%;text-align:center;line-height:0}.sby_lb-cancel{display:block;width:32px;height:32px;margin:0 auto;background-color:#666;background-color:rgba(255,255,255,.5);border-radius:100%;-webkit-animation:ctf-sk-scaleout 1s infinite ease-in-out;animation:ctf-sk-scaleout 1s infinite ease-in-out}.sby_lb-nav{top:0;left:0;width:100%;z-index:10}.sby_lb-container>.nav{left:0}.sby_lb-nav a{position:absolute;z-index:100;top:0;height:90%;outline:0;background-image:url(data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}.sby_lb-next,.sby_lb-prev{height:100%;cursor:pointer;display:block}.sby_lb-nav a.sby_lb-prev{width:50px;left:-70px;padding-left:10px;padding-right:10px;float:left;opacity:.5;-webkit-transition:opacity .2s;-moz-transition:opacity .2;-o-transition:opacity .2s;transition:opacity .2s}.sby_lb-nav a.sby_lb-prev:hover{opacity:1}.sby_lb-nav a.sby_lb-next{width:50px;right:-70px;padding-left:10px;padding-right:10px;float:right;opacity:.5;-webkit-transition:opacity .2s;-moz-transition:opacity .2s;-o-transition:opacity .2s;transition:opacity .2s}.sby_lb-nav a.sby_lb-next:hover{opacity:1}.sby_lb-nav span{display:block;top:55%;position:absolute;left:20px;width:34px;height:45px;margin:-25px 0 0 0;background:url(../img/sby-sprite.png) no-repeat}.sby_lb-nav a.sby_lb-prev span{background-position:-53px 0}.sby_lb-nav a.sby_lb-next span{left:auto;right:20px;background-position:-18px 0}.sby_lb-dataContainer{margin:0 auto;padding-top:5px;width:100%;font-family:"Open Sans",Helvetica,Arial,sans-serif;-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px}.sby_lb-dataContainer:after{content:"";display:table;clear:both}.sby_lb-data{padding:0 4px;color:#ccc}.sby_lb-data .sby_lb-details{width:85%;float:left;text-align:left;line-height:1.1}.sby_lb-data .sby_lb-caption{float:left;font-size:13px;font-weight:400;line-height:1.3;padding-bottom:3px;color:#ccc;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto}.sby_lb-data .sby_lb-caption .ctf-screename-sep,.sby_lb-data .sby_lb-caption a{color:#ccc;font-weight:700;text-decoration:none}.sby_lb-data .sby_lb-caption a:hover{color:#fff;text-decoration:underline}.sby_lb-data .sby_lb-caption .sby_lightbox_username{float:left;width:100%;color:#ccc;padding-bottom:0;display:block;margin:0 0 5px 0}.sby_lb-data .sby_lb-caption .sby_lightbox_username{color:#ccc}.sby_lb-data .sby_lb-caption .sby_lightbox_username:hover p{color:#fff;text-decoration:underline}.sby_lightbox .sby_lightbox_username img{float:left;border:none;width:48px;height:48px;margin-right:10px;background:#666;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sby_lightbox_username p{float:left;margin:0;padding:0;color:#ccc;line-height:32px;font-weight:700;font-size:13px;text-align:left}.sby_lb-data .ctf-caption-text{width:100%;margin-left:58px;padding-top:3px}.sby_lb-data .sby_lb-caption .ctf-author-screenname,.sby_lb-data .sby_lb-caption .ctf-tweet-date{font-weight:400}.sby_lb-data .sby_lb-info{width:100%;float:left;clear:both}.sby_lb-data .sby_lb-number{display:block;float:left;clear:both;padding:5px 0 15px 0;font-size:12px;color:#999}.sby_lb-data .sby_lb-close{display:block;float:right;width:30px;height:30px;background:url(../img/close.png) top right no-repeat;text-align:right;outline:0;opacity:.7;-webkit-transition:opacity .2s;-moz-transition:opacity .2s;-o-transition:opacity .2s;transition:opacity .2s}.sby_lb-data .sby_lb-close:hover{cursor:pointer;opacity:1}.sby_lb-nav{height:auto}.sby_lb-container{padding:0}.sby_lb-container iframe{position:absolute;top:0;left:0;width:100%;height:100%;z-index:1}#sby_lightbox .sby_lightbox_action{float:left;position:relative;padding:0 0 0 10px;margin:5px 0 0 10px;border-left:1px solid #666;font-size:12px}#sby_lightbox .sby_lightbox_action a{display:block;float:left;color:#999;text-decoration:none}#sby_lightbox .sby_lightbox_action a:focus,#sby_lightbox .sby_lightbox_action a:hover{color:#fff}#sby_lightbox .sby_lightbox_action .fa,#sby_lightbox .sby_lightbox_action svg{margin-right:5px}#sby_lightbox .sby_lightbox_action.sby_youtube .fa{font-size:13px}#sby_lightbox .sby_tooltip_social a svg{font-size:19px;padding:3px 4px;margin:auto}#sby_lightbox .sby_lightbox_tooltip{display:none;position:absolute;width:100px;bottom:22px;left:0;padding:5px 10px;margin:0;background:rgba(255,255,255,.9);color:#222;font-size:12px;line-height:1.3;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;box-shadow:0 0 10px rgba(0,0,0,.4);-moz-box-shadow:0 0 10px rgba(0,0,0,.4);-webkit-box-shadow:0 0 10px rgba(0,0,0,.4);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}#sby_lightbox .sby_lightbox_tooltip .fa-play{position:absolute;font-size:8px;bottom:-6px;left:36px;color:rgba(255,255,255,.9)}#sby_lightbox .sby_tooltip_social a .fa{font-size:16px;margin:0;padding:5px}#sby_lightbox .sby_tooltip_social a#sby_facebook_icon .fa,#sby_lightbox .sby_tooltip_social a#sby_pinterest_icon .fa,#sby_lightbox .sby_tooltip_social a#sby_twitter_icon .fa{padding-top:4px;font-size:18px}#sby_lightbox #sby_mod_box{width:280px;padding:5px 10px 7px 10px}#sby_lightbox .sby_tooltip_social{width:172px;padding:5px 5px 4px 5px}#sby_lightbox .sby_tooltip_social a{color:#333;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}#sby_lightbox .sby_lightbox_action #sby_facebook_icon:hover{background:#3b5998}#sby_lightbox .sby_lightbox_action #sby_twitter_icon:hover{background:#00aced}#sby_lightbox .sby_lightbox_action #sby_google_icon:hover{background:#dd4b39}#sby_lightbox .sby_lightbox_action #sby_linkedin_icon:hover{background:#007bb6}#sby_lightbox .sby_lightbox_action #sby_pinterest_icon:hover{background:#cb2027}#sby_lightbox .sby_lightbox_action #sby_email_icon:hover{background:#333}.sby_lb-dataContainer,.sby_lb-outerContainer{min-width:450px}@media all and (max-width:450px){.sby_lb-dataContainer,.sby_lb-outerContainer{min-width:0}}.sby_lightbox .sby_lb-image{display:block;height:auto;max-width:inherit;margin:0 auto;-webkit-border-radius:0;-moz-border-radius:0;-ms-border-radius:0;-o-border-radius:0;border-radius:0}#sby_mod_error{display:none;border:1px solid #ddd;background:#eee;color:#333;margin:10px 0 0;padding:10px 15px;font-size:13px;text-align:center;clear:both;margin-bottom:10px;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}#sby_mod_error p{padding:5px 0!important;margin:0!important;line-height:1.3!important}#sby_mod_error ol,#sby_mod_error ul{padding:5px 0 5px 20px!important;margin:0!important}#sby_mod_error li{padding:1px 0!important;margin:0!important}#sby_mod_error span{font-size:12px}[id^=sb_youtube_].sb_youtube svg:not(:root).svg-inline--fa,[id^=sb_youtube_].sb_youtube_lightbox svg:not(:root).svg-inline--fa{box-sizing:unset;overflow:visible;width:1em}[id^=sb_youtube_].sb_youtube .svg-inline--fa.fa-w-16{width:16px}[id^=sb_youtube_].sb_youtube .svg-inline--fa,[id^=sb_youtube_].sb_youtube_lightbox .svg-inline--fa{display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em}[id^=sb_youtube_].sb_youtube.sby_player_loaded .sby_player_outer_wrap .sby_video_thumbnail,[id^=sb_youtube_].sb_youtube.sby_player_loaded.sby_layout_list .sby_video_thumbnail{z-index:-1!important}
1
+ [id^=sb_youtube_].sb_youtube{width:100%;margin:0 auto;padding:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[id^=sb_youtube_].sb_youtube *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[id^=sb_youtube_].sb_youtube:after{content:"";display:table;clear:both}#sby_lightbox iframe,[id^=sb_youtube_].sb_youtube iframe{pointer-events:all!important}[id^=sb_youtube_].sb_youtube.sby_fixed_height{overflow:hidden;overflow-y:auto;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[id^=sb_youtube_].sb_youtube .sby_items_wrap{width:100%;float:left;line-height:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube .sby_player_outer_wrap .sby_video_thumbnail_wrap,[id^=sb_youtube_].sb_youtube .sby_player_wrap{display:-moz-inline-stack;display:inline-block;vertical-align:top;zoom:1;max-height:1000px;padding:inherit!important;text-decoration:none;opacity:1;overflow:hidden;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:all .5s ease;-moz-transition:all .5s ease;-o-transition:all .5s ease;-ms-transition:all .5s ease;transition:all .5s ease}[id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item.sby_no_margin{margin:0!important}[id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item{float:left}[id^=sb_youtube_].sb_youtube .sby_items_wrap .sby_item.sby_transition{opacity:0;max-height:0}[id^=sb_youtube_].sb_youtube.sby_col_0 .sby_items_wrap .sby_item{width:100%}[id^=sb_youtube_].sb_youtube.sby_col_1 .sby_items_wrap .sby_item{width:100%}[id^=sb_youtube_].sb_youtube.sby_col_2 .sby_items_wrap .sby_item{width:50%}[id^=sb_youtube_].sb_youtube.sby_col_3 .sby_items_wrap .sby_item{width:33.33%}[id^=sb_youtube_].sb_youtube.sby_col_4 .sby_items_wrap .sby_item{width:25%}[id^=sb_youtube_].sb_youtube.sby_col_5 .sby_items_wrap .sby_item{width:20%}[id^=sb_youtube_].sb_youtube.sby_col_6 .sby_items_wrap .sby_item{width:16.66%}[id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item{width:14.28%}[id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item{width:12.5%}[id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item{width:11.11%}[id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item{width:10%}.sby-screenreader{text-indent:-9999px!important;display:block!important;width:0!important;height:0!important;line-height:0!important}[id^=sb_youtube_].sb_youtube .sby_player_outer_wrap,[id^=sb_youtube_].sb_youtube .sby_video_thumbnail_wrap{width:100%;position:relative;float:left}[id^=sb_youtube_].sb_youtube .sby_video_thumbnail{display:block;position:relative;text-decoration:none;line-height:0;z-index:5}[id^=sb_youtube_].sb_youtube .sby_video_thumbnail img{width:100%;height:auto;border-radius:0}[id^=sb_youtube_].sb_youtube .sby_link{display:none;position:absolute;z-index:1;top:0;right:0;bottom:0;left:0;width:100%;padding:0;background:#333;background:rgba(0,0,0,.6);text-align:center;color:#fff;font-size:12px;line-height:1.1;overflow:hidden}[id^=sb_youtube_].sb_youtube .sby_link.sby_default a,[id^=sb_youtube_].sb_youtube .sby_link.sby_default p,[id^=sb_youtube_].sb_youtube .sby_link.sby_default span{text-shadow:0 0 10px #000}[id^=sb_youtube_].sb_youtube .sby_link .sby_hover_bottom,[id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link,[id^=sb_youtube_].sb_youtube .sby_link .sby_playbtn,[id^=sb_youtube_].sb_youtube .sby_link .sby_username a,[id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link,[id^=sb_youtube_].sb_youtube .sby_link .svg-inline--fa.fa-play{opacity:.9}[id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link:hover,[id^=sb_youtube_].sb_youtube .sby_link .sby_playbtn:hover,[id^=sb_youtube_].sb_youtube .sby_link .sby_username a:hover,[id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link:hover,[id^=sb_youtube_].sb_youtube .sby_link .svg-inline--fa.fa-play:hover{opacity:1}[id^=sb_youtube_].sb_youtube .sby_link_area{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1}[id^=sb_youtube_].sb_youtube .sby_link a{padding:0;text-decoration:none;color:#ddd;color:rgba(255,255,255,.7);line-height:1.1;background:0 0;display:-moz-inline-stack;display:inline-block;vertical-align:top;zoom:1}[id^=sb_youtube_].sb_youtube .sby_link a:active,[id^=sb_youtube_].sb_youtube .sby_link a:hover{color:#fff}[id^=sb_youtube_].sb_youtube .sby_link .sby_lightbox_link{display:block;position:absolute;z-index:2;top:50%;left:50%;margin-top:-24px;margin-left:-21px;padding:0;font-size:49px;font-style:normal!important}[id^=sb_youtube_].sb_youtube .sby_carousel_vid_first .sby_lightbox_link,[id^=sb_youtube_].sb_youtube .sby_type_video .sby_lightbox_link{display:none}[id^=sb_youtube_].sb_youtube .sby_link .sby_youtube_link{font-size:30px;position:absolute;z-index:100;bottom:0;right:2px;padding:8px}[id^=sb_youtube_].sb_youtube .sby_link a:focus,[id^=sb_youtube_].sb_youtube .sby_link a:hover{text-decoration:underline}[id^=sb_youtube_].sb_youtube .sby_player_wrap{z-index:1;width:100%!important;height:100%!important;position:absolute;top:0;left:0}[id^=sb_youtube_].sb_youtube .sby_player_wrap iframe{width:100%!important;height:100%!important}[id^=sb_youtube_].sb_youtube .sby_thumbnail_hover{opacity:0;display:block;position:absolute;top:0;right:0;bottom:0;left:0;z-index:10;color:#fff;background:#333;background:rgba(0,0,0,.6);transition:opacity .6s ease-in-out;-moz-transition:opacity .6s ease-in-out;-webkit-transition:opacity .6s ease-in-out}[id^=sb_youtube_].sb_youtube.sby_layout_list .sby_thumbnail_hover{display:none}.sby_video_title{display:inline-block;height:100%;padding:10px;overflow:hidden;font-size:13px;line-height:1.2}[id^=sb_youtube_].sb_youtube .sby_video_thumbnail:hover .sby_thumbnail_hover{opacity:1;display:block;transition:opacity .2s ease-in-out;-moz-transition:opacity .2s ease-in-out;-webkit-transition:opacity .2s ease-in-out}[id^=sb_youtube_].sb_youtube .sby_current .sby_thumbnail_hover{opacity:1}[id^=sb_youtube_].sb_youtube.sby_layout_list .sby_video_thumbnail:hover .sby_thumbnail_hover{opacity:0;display:none;transition:none;-moz-transition:none;-webkit-transition:none}a.sby_video_thumbnail:after{box-shadow:inset 0 0 1px 0 rgba(0,0,0,.7);bottom:0;content:'';left:0;position:absolute;z-index:1;right:0;top:0;width:100%}[id^=sb_youtube_].sb_youtube .sby_video_thumbnail:hover .sby_play_btn{opacity:.5}[id^=sb_youtube_].sb_youtube .sby_play_btn{position:absolute;z-index:1;left:50%;bottom:50%;top:50%;right:50%;margin-top:-25px;margin-left:-28px;color:#fff;width:57px;height:50px;opacity:1;transition:opacity .2s ease-in-out;-moz-transition:opacity .2s ease-in-out;-webkit-transition:opacity .2s ease-in-out}[id^=sb_youtube_].sb_youtube .sby_play_btn_bg{display:block;position:absolute;z-index:-1;top:17px;left:22px;width:0;height:0;border:0 solid transparent;border-bottom-width:9px;border-top-width:9px;border-left:16px solid #fff}[id^=sb_youtube_].sb_youtube .sby_play_btn svg:not(:root).svg-inline--fa{width:57px;height:auto;opacity:.75}[id^=sb_youtube_].sb_youtube .sby_play_btn i,[id^=sb_youtube_].sb_youtube .sby_play_btn svg{color:#000}[id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn{margin-top:-20px;margin-left:-22px;width:45px;height:40px}[id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn_bg{top:13px;left:18px;border-bottom-width:7px;border-top-width:7px;border-left:12px solid #fff}[id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn svg:not(:root).svg-inline--fa{width:45px}[id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn{margin-top:-16px;margin-left:-18px;width:36px;height:32px}[id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn_bg{top:10px;left:14px;border-bottom-width:6px;border-top-width:6px;border-left:10px solid #fff}[id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn svg:not(:root).svg-inline--fa{width:36px}[id^=sb_youtube_].sb_youtube .sby_loader{width:20px;height:20px;position:relative;top:50%;left:50%;margin:-10px 0 0 -10px;background-color:#000;background-color:rgba(0,0,0,.5);border-radius:100%;-webkit-animation:sby-sk-scaleout 1s infinite ease-in-out;animation:sby-sk-scaleout 1s infinite ease-in-out}[id^=sb_youtube_].sb_youtube .sb_youtube_header br,[id^=sb_youtube_].sb_youtube .sby_footer br,[id^=sb_youtube_].sb_youtube .sby_items_wrap br{display:none}.sby_footer p{display:inline;padding:0;margin:0}[id^=sb_youtube_].sb_youtube .sby_footer .sby_loader,[id^=sb_youtube_].sb_youtube .sby_item .sby_loader,[id^=sb_youtube_].sb_youtube .sby_player_outer_wrap .sby_loader{position:absolute;margin-top:-11px;background-color:#fff}[id^=sb_youtube_].sb_youtube .sby_item.sby_player_loading,[id^=sb_youtube_].sb_youtube .sby_player_outer_wrap.sby_player_loading{opacity:.8}@-webkit-keyframes sby-sk-scaleout{0%{-webkit-transform:scale(0)}100%{-webkit-transform:scale(1);opacity:0}}@keyframes sby-sk-scaleout{0%{-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}100%{-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);opacity:0}}#sby_lightbox .fa-spin,[id^=sb_youtube_].sb_youtube .fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}#sby_lightbox .fa-pulse,[id^=sb_youtube_].sb_youtube .fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}[id^=sb_youtube_].sb_youtube .sb_youtube_header{float:left;clear:both;margin:0 0 15px 0;padding:0;line-height:1.2;width:100%}[id^=sb_youtube_].sb_youtube .sb_youtube_header a{float:left;display:block;text-decoration:none;transition:color .5s ease}@media all and (min-width:480px){[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_img{width:80px;height:80px;border-radius:40px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_img img{width:80px;height:80px;border-radius:40px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3{font-size:20px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info{font-size:14px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3{margin-left:95px!important;line-height:1.4}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text h3{margin-right:-85px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text .sby_bio_info{margin-top:4px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_medium .sby_header_text.sby_no_bio h3{padding-top:20px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_img{width:120px;height:120px;border-radius:60px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_img img{width:120px;height:120px;border-radius:60px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3{font-size:28px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info{font-size:16px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info,[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3{margin-left:140px!important;line-height:1.5}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text h3{margin-right:-120px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text .sby_bio_info{margin-top:12px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_large .sby_header_text.sby_no_bio h3{padding-top:32px!important}}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img{float:left;position:relative;width:50px;margin:0 0 0 -100%!important;overflow:hidden;-moz-border-radius:40px;-webkit-border-radius:40px;border-radius:40px}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img img{float:left;margin:0!important;padding:0!important;border:none!important;-moz-border-radius:40px;-webkit-border-radius:40px;border-radius:40px}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{opacity:0;position:absolute;width:100%;top:0;bottom:0;left:0;text-align:center;color:#fff;background:rgba(0,0,0,.75)}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_no_consent .sby_header_img{height:50px}[id^=sb_youtube_].sb_youtube .sb_youtube_header.sby_no_consent .sby_header_img_hover{opacity:1}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover .sby_new_logo{position:absolute;top:50%;left:50%;margin-top:-12px;margin-left:-12px;width:24px;height:24px;font-size:24px}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover i{overflow:hidden;background:url(../img/small-logo.png) no-repeat 0 0}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{z-index:2;transition:opacity .4s ease-in-out}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_fade_in{opacity:1;transition:opacity .2s ease-in-out}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_img_hover{position:absolute;width:100%;top:0;bottom:0;left:0;text-align:center;color:#fff;background:rgba(0,0,0,.75);-moz-opacity:0;-khtml-opacity:0;opacity:0;border-radius:40px;transition:opacity .2s}[id^=sb_youtube_].sb_youtube .sb_youtube_header a:focus .sby_header_img_hover,[id^=sb_youtube_].sb_youtube .sb_youtube_header a:hover .sby_header_img_hover{opacity:1}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text{float:left;width:100%;padding-top:5px}[id^=sb_youtube_].sb_youtube .sb_youtube_header a{text-decoration:none}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text .sby_bio,[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text h3{float:left;clear:both;width:auto;margin:0 0 0 60px!important;padding:0!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header h3{font-size:16px;line-height:1.3}[id^=sb_youtube_].sb_youtube .sb_youtube_header p{font-size:13px;line-height:1.3;margin:0;padding:0}[id^=sb_youtube_].sb_youtube p:empty{display:none}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text img.emoji{margin-right:3px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text.sby_no_bio h3{padding-top:9px!important}[id^=sb_youtube_].sb_youtube .sb_youtube_header .sby_header_text.sby_no_bio .sby_bio_info{clear:both}[id^=sb_youtube_].sb_youtube .sby_footer{float:left;clear:both;width:100%;text-align:center}[id^=sb_youtube_].sb_youtube .sby_footer .fa-spinner{display:none;position:absolute;top:50%;left:50%;margin:-8px 0 0 -7px;font-size:15px}[id^=sb_youtube_].sb_youtube .sby_footer{opacity:1;transition:all .5s ease-in}[id^=sb_youtube_].sb_youtube .sby_load_btn .sby_btn_text,[id^=sb_youtube_].sb_youtube .sby_load_btn .sby_loader{opacity:1;transition:all .1s ease-in}[id^=sb_youtube_].sb_youtube .sby_hidden{opacity:0!important}[id^=sb_youtube_].sb_youtube .sby_follow_btn a,[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn{display:-moz-inline-stack;display:inline-block;vertical-align:top;zoom:1;padding:7px 14px;margin:5px auto 0 auto;background:#333;color:#eee;border:none;color:#fff;text-decoration:none;font-size:13px;line-height:1.5;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn{position:relative}[id^=sb_youtube_].sb_youtube .sby_follow_btn{display:-moz-inline-stack;display:inline-block;vertical-align:top;zoom:1;text-align:center}[id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_top{display:block;margin-bottom:5px}[id^=sb_youtube_].sb_youtube .sby_follow_btn a{background:#408bd1;color:#fff}[id^=sb_youtube_].sb_youtube .sby_follow_btn a,[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn{transition:all .1s ease-in}[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn:hover{outline:0;box-shadow:inset 0 0 20px 20px rgba(255,255,255,.25)}[id^=sb_youtube_].sb_youtube .sby_follow_btn a:focus,[id^=sb_youtube_].sb_youtube .sby_follow_btn a:hover{outline:0;box-shadow:inset 0 0 10px 20px #359dff}[id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_custom a:focus,[id^=sb_youtube_].sb_youtube .sby_follow_btn.sby_custom a:hover,[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn.sby_custom:hover{box-shadow:inset 0 0 20px 20px rgba(255,255,255,.15)}[id^=sb_youtube_].sb_youtube .sby_follow_btn a:active,[id^=sb_youtube_].sb_youtube .sby_footer .sby_load_btn:active{box-shadow:inset 0 0 10px 20px rgba(0,0,0,.3)}[id^=sb_youtube_].sb_youtube .sby_follow_btn .fa,[id^=sb_youtube_].sb_youtube .sby_follow_btn svg{margin-bottom:-1px;margin-right:7px;font-size:15px}[id^=sb_youtube_].sb_youtube .sby_follow_btn svg{vertical-align:-.125em}[id^=sb_youtube_].sb_youtube .sby_footer .sby_follow_btn{margin-left:5px}@media all and (max-width:640px){[id^=sb_youtube_].sb_youtube.sby_col_3.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_4.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_5.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_6.sby_mob_col_auto .sby_items_wrap .sby_item{width:50%}[id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_10.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_7.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_8.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_9.sby_mob_col_auto .sby_items_wrap .sby_item{width:25%}[id^=sb_youtube_].sb_youtube.sby_col_2 .sby_items_wrap .sby_item{width:50%}[id^=sb_youtube_].sb_youtube.sby_col_3 .sby_items_wrap .sby_item{width:33.33%}[id^=sb_youtube_].sb_youtube.sby_col_4 .sby_items_wrap .sby_item{width:25%}[id^=sb_youtube_].sb_youtube.sby_col_5 .sby_items_wrap .sby_item{width:20%}[id^=sb_youtube_].sb_youtube.sby_col_6 .sby_items_wrap .sby_item{width:16.66%}[id^=sb_youtube_].sb_youtube.sby_col_7 .sby_items_wrap .sby_item{width:14.28%}[id^=sb_youtube_].sb_youtube.sby_col_8 .sby_items_wrap .sby_item{width:12.5%}[id^=sb_youtube_].sb_youtube.sby_col_9 .sby_items_wrap .sby_item{width:11.11%}[id^=sb_youtube_].sb_youtube.sby_col_10 .sby_items_wrap .sby_item{width:10%}[id^=sb_youtube_].sb_youtube.sby_width_resp{width:100%!important}}@media all and (max-width:480px){[id^=sb_youtube_].sb_youtube.sby_col_10.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_3.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_4.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_5.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_6.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_7.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_8.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_col_9.sby_mob_col_auto .sby_items_wrap .sby_item,[id^=sb_youtube_].sb_youtube.sby_mob_col_1 .sby_items_wrap .sby_item{width:100%}[id^=sb_youtube_].sb_youtube.sby_mob_col_2 .sby_items_wrap .sby_item{width:50%}[id^=sb_youtube_].sb_youtube.sby_mob_col_3 .sby_items_wrap .sby_item{width:33.33%}[id^=sb_youtube_].sb_youtube.sby_mob_col_4 .sby_items_wrap .sby_item{width:25%}[id^=sb_youtube_].sb_youtube.sby_mob_col_5 .sby_items_wrap .sby_item{width:20%}[id^=sb_youtube_].sb_youtube.sby_mob_col_6 .sby_items_wrap .sby_item{width:16.66%}[id^=sb_youtube_].sb_youtube.sby_mob_col_7 .sby_items_wrap .sby_item{width:14.28%}}.sby_lightboxOverlay{position:absolute;top:0;left:0;z-index:99999;background-color:#000;opacity:.9;display:none}.sby_lightbox{position:absolute;left:0;width:100%;z-index:100000;line-height:0;font-weight:400}.sby_lightbox .sby_lb-image{display:block;height:auto;max-width:inherit;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;-o-border-radius:3px;border-radius:3px}.sby_lightbox a:active,.sby_lightbox a:focus,.sby_lightbox a:hover{outline:0}.sby_lightbox a img{border:none}.sby_lb-outerContainer{position:relative;background-color:#000;width:250px;height:250px;margin:0 auto 5px auto;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;-o-border-radius:3px;border-radius:3px}.sby_lb-outerContainer:after{content:"";display:table;clear:both}.sby_lb-container{position:relative;padding:4px;top:0;left:0;width:100%;height:100%;bottom:0;right:0;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;-o-border-radius:3px;border-radius:3px}.sby_lb-loader{position:absolute;top:43%;left:0;height:25%;width:100%;text-align:center;line-height:0}.sby_lb-cancel{display:block;width:32px;height:32px;margin:0 auto;background-color:#666;background-color:rgba(255,255,255,.5);border-radius:100%;-webkit-animation:ctf-sk-scaleout 1s infinite ease-in-out;animation:ctf-sk-scaleout 1s infinite ease-in-out}.sby_lb-nav{top:0;left:0;width:100%;z-index:10}.sby_lb-container>.nav{left:0}.sby_lb-nav a{position:absolute;z-index:100;top:0;height:90%;outline:0;background-image:url(data:image/gif;base64,R0lGODlhAQABAPAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}.sby_lb-next,.sby_lb-prev{height:100%;cursor:pointer;display:block}.sby_lb-nav a.sby_lb-prev{width:50px;left:-70px;padding-left:10px;padding-right:10px;float:left;opacity:.5;-webkit-transition:opacity .2s;-moz-transition:opacity .2;-o-transition:opacity .2s;transition:opacity .2s}.sby_lb-nav a.sby_lb-prev:hover{opacity:1}.sby_lb-nav a.sby_lb-next{width:50px;right:-70px;padding-left:10px;padding-right:10px;float:right;opacity:.5;-webkit-transition:opacity .2s;-moz-transition:opacity .2s;-o-transition:opacity .2s;transition:opacity .2s}.sby_lb-nav a.sby_lb-next:hover{opacity:1}.sby_lb-nav span{display:block;top:55%;position:absolute;left:20px;width:34px;height:45px;margin:-25px 0 0 0;background:url(../img/sby-sprite.png) no-repeat}.sby_lb-nav a.sby_lb-prev span{background-position:-53px 0}.sby_lb-nav a.sby_lb-next span{left:auto;right:20px;background-position:-18px 0}.sby_lb-dataContainer{margin:0 auto;padding-top:5px;width:100%;font-family:"Open Sans",Helvetica,Arial,sans-serif;-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px}.sby_lb-dataContainer:after{content:"";display:table;clear:both}.sby_lb-data{padding:0 4px;color:#ccc}.sby_lb-data .sby_lb-details{width:85%;float:left;text-align:left;line-height:1.1}.sby_lb-data .sby_lb-caption{float:left;font-size:13px;font-weight:400;line-height:1.3;padding-bottom:3px;color:#ccc;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto}.sby_lb-data .sby_lb-caption .ctf-screename-sep,.sby_lb-data .sby_lb-caption a{color:#ccc;font-weight:700;text-decoration:none}.sby_lb-data .sby_lb-caption a:hover{color:#fff;text-decoration:underline}.sby_lb-data .sby_lb-caption .sby_lightbox_username{float:left;width:100%;color:#ccc;padding-bottom:0;display:block;margin:0 0 5px 0}.sby_lb-data .sby_lb-caption .sby_lightbox_username{color:#ccc}.sby_lb-data .sby_lb-caption .sby_lightbox_username:hover p{color:#fff;text-decoration:underline}.sby_lightbox .sby_lightbox_username img{float:left;border:none;width:48px;height:48px;margin-right:10px;background:#666;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sby_lightbox_username p{float:left;margin:0;padding:0;color:#ccc;line-height:32px;font-weight:700;font-size:13px;text-align:left}.sby_lb-data .ctf-caption-text{width:100%;margin-left:58px;padding-top:3px}.sby_lb-data .sby_lb-caption .ctf-author-screenname,.sby_lb-data .sby_lb-caption .ctf-tweet-date{font-weight:400}.sby_lb-data .sby_lb-info{width:100%;float:left;clear:both}.sby_lb-data .sby_lb-number{display:block;float:left;clear:both;padding:5px 0 15px 0;font-size:12px;color:#999}.sby_lb-data .sby_lb-close{display:block;float:right;width:30px;height:30px;background:url(../img/close.png) top right no-repeat;text-align:right;outline:0;opacity:.7;-webkit-transition:opacity .2s;-moz-transition:opacity .2s;-o-transition:opacity .2s;transition:opacity .2s}.sby_lb-data .sby_lb-close:hover{cursor:pointer;opacity:1}.sby_lb-nav{height:auto}.sby_lb-container{padding:0}.sby_lb-container iframe{position:absolute;top:0;left:0;width:100%;height:100%;z-index:1}#sby_lightbox .sby_lightbox_action{float:left;position:relative;padding:0 0 0 10px;margin:5px 0 0 10px;border-left:1px solid #666;font-size:12px}#sby_lightbox .sby_lightbox_action a{display:block;float:left;color:#999;text-decoration:none}#sby_lightbox .sby_lightbox_action a:focus,#sby_lightbox .sby_lightbox_action a:hover{color:#fff}#sby_lightbox .sby_lightbox_action .fa,#sby_lightbox .sby_lightbox_action svg{margin-right:5px}#sby_lightbox .sby_lightbox_action.sby_youtube .fa{font-size:13px}#sby_lightbox .sby_tooltip_social a svg{font-size:19px;padding:3px 4px;margin:auto}#sby_lightbox .sby_lightbox_tooltip{display:none;position:absolute;width:100px;bottom:22px;left:0;padding:5px 10px;margin:0;background:rgba(255,255,255,.9);color:#222;font-size:12px;line-height:1.3;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;box-shadow:0 0 10px rgba(0,0,0,.4);-moz-box-shadow:0 0 10px rgba(0,0,0,.4);-webkit-box-shadow:0 0 10px rgba(0,0,0,.4);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}#sby_lightbox .sby_lightbox_tooltip .fa-play{position:absolute;font-size:8px;bottom:-6px;left:36px;color:rgba(255,255,255,.9)}#sby_lightbox .sby_tooltip_social a .fa{font-size:16px;margin:0;padding:5px}#sby_lightbox .sby_tooltip_social a#sby_facebook_icon .fa,#sby_lightbox .sby_tooltip_social a#sby_pinterest_icon .fa,#sby_lightbox .sby_tooltip_social a#sby_twitter_icon .fa{padding-top:4px;font-size:18px}#sby_lightbox .sby_gdpr_notice{z-index:6;display:block;position:absolute;top:50%;left:50%;margin-left:-44px;margin-top:-44px;padding:20px}#sby_lightbox .sby_gdpr_notice svg:not(:root).svg-inline--fa{position:relative;display:block!important;height:48px;width:48px;opacity:.8}#sby_lightbox .sby_gdpr_notice:hover svg:not(:root).svg-inline--fa{opacity:1}#sby_lightbox #sby_mod_box{width:280px;padding:5px 10px 7px 10px}#sby_lightbox .sby_tooltip_social{width:172px;padding:5px 5px 4px 5px}#sby_lightbox .sby_tooltip_social a{color:#333;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}#sby_lightbox .sby_lightbox_action #sby_facebook_icon:hover{background:#3b5998}#sby_lightbox .sby_lightbox_action #sby_twitter_icon:hover{background:#00aced}#sby_lightbox .sby_lightbox_action #sby_google_icon:hover{background:#dd4b39}#sby_lightbox .sby_lightbox_action #sby_linkedin_icon:hover{background:#007bb6}#sby_lightbox .sby_lightbox_action #sby_pinterest_icon:hover{background:#cb2027}#sby_lightbox .sby_lightbox_action #sby_email_icon:hover{background:#333}.sby_lb-dataContainer,.sby_lb-outerContainer{min-width:450px}@media all and (max-width:450px){.sby_lb-dataContainer,.sby_lb-outerContainer{min-width:0}}.sby_lightbox .sby_lb-image{display:block;height:auto;max-width:inherit;margin:0 auto;-webkit-border-radius:0;-moz-border-radius:0;-ms-border-radius:0;-o-border-radius:0;border-radius:0}#sby_mod_error{display:none;border:1px solid #ddd;background:#eee;color:#333;margin:10px 0 0;padding:10px 15px;font-size:13px;text-align:center;clear:both;margin-bottom:10px;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}#sby_mod_error p{padding:5px 0!important;margin:0!important;line-height:1.3!important}#sby_mod_error ol,#sby_mod_error ul{padding:5px 0 5px 20px!important;margin:0!important}#sby_mod_error li{padding:1px 0!important;margin:0!important}#sby_mod_error span{font-size:12px}[id^=sb_youtube_].sb_youtube svg:not(:root).svg-inline--fa,[id^=sb_youtube_].sb_youtube_lightbox svg:not(:root).svg-inline--fa{box-sizing:unset;overflow:visible;width:1em}[id^=sb_youtube_].sb_youtube .svg-inline--fa.fa-w-16{width:16px}[id^=sb_youtube_].sb_youtube .svg-inline--fa,[id^=sb_youtube_].sb_youtube_lightbox .svg-inline--fa{display:inline-block;font-size:inherit;height:1em;overflow:visible;vertical-align:-.125em}[id^=sb_youtube_].sb_youtube.sby_player_loaded .sby_player_outer_wrap .sby_video_thumbnail,[id^=sb_youtube_].sb_youtube.sby_player_loaded.sby_layout_list .sby_video_thumbnail{z-index:-1!important}
css/sby-blocks.css CHANGED
@@ -1,3 +1,3 @@
1
- .sb_youtube {
2
- pointer-events: none !important;
3
  }
1
+ .sb_youtube {
2
+ pointer-events: none !important;
3
  }
css/sby-notices.css CHANGED
@@ -1,118 +1,118 @@
1
- /* Review notice */
2
- .sby_notice{
3
- position: relative;
4
- overflow: hidden;
5
- max-width: 885px;
6
- margin-top: 10px;
7
- padding: 10px 10px 7px 10px;
8
-
9
- background: #E6F0E8;
10
- border: 1px solid #6AB074;
11
- color: #214F28;
12
- }
13
- .sby_notice .sby_thumb{
14
- position: relative;
15
- display: inline-block;
16
- width: 74px;
17
- margin: 0 0 0 -100% !important;
18
-
19
- -moz-border-radius: 4px;
20
- -webkit-border-radius: 4px;
21
- border-radius: 4px;
22
- }
23
- .sby_notice .sby_thumb .img-overlay {
24
- position: absolute;
25
- bottom: 4px;
26
- padding: 6px 7px 6px 5px;
27
- font-size: 13px;
28
- font-weight: bold;
29
- background: #fff;
30
- background: rgba(255,255,255,0.85);
31
- line-height: 1;
32
- color: #333;
33
- box-shadow: 1px -1px 3px 0 rgba(0,0,0,0.15);
34
- }
35
- .sby_notice .sby_thumb img {
36
- max-width: 100%;
37
- }
38
- .sby_notice .sby-notice-text{
39
- float: left;
40
- clear: none;
41
- width: 100%;
42
- padding: 0;
43
- }
44
- .sby_notice .sby-links{
45
- margin-top: 4px !important;
46
- }
47
- .sby_notice p{
48
- float: left;
49
- clear: both;
50
- width: auto;
51
- margin: 0 0 0 90px !important;
52
- padding: 2px 40px 2px 0;
53
- line-height: 1.4;
54
- }
55
- .sby_notice a{
56
- display: inline-block;
57
- padding: 0 8px;
58
- color: #178529;
59
- }
60
- .sby_notice a:hover,
61
- .sby_notice a:focus{
62
- color: #0c7abf;
63
- }
64
- .sby_notice .links{
65
- margin: 0 0 0 90px !important;
66
- padding: 4px 0 0 0;
67
- margin-top: 1px !important;
68
- }
69
- .sby_review_notice .links{
70
- margin-left: 82px !important;
71
- margin-top: 0 !important;
72
- }
73
- .sby_notice .sby_notice_close,
74
- .sby_notice .sby_bfcm_sale_notice_close,
75
- .sby_notice .sby_new_user_sale_notice_close {
76
- position: absolute;
77
- top: 0;
78
- right: 0;
79
- padding: 10px;
80
- line-height: 1;
81
- }
82
- .sby_notice .sby_notice_close:hover,
83
- .sby_notice .sby_notice_close:focus{
84
- color: #a34100;
85
- }
86
- .sby_notice strong span {
87
- font-weight: 900;
88
- }
89
- /* Notice CTA btn */
90
- .sby_notice .sby_offer_btn,
91
- .sby_notice .sby_main_cta{
92
- padding: 4px 12px 6px 12px;
93
- background: green;
94
- color: #fff;
95
- border-radius: 4px;
96
- display: inline-block;
97
- text-decoration: none;
98
- margin-left: 0;
99
- margin-right: 4px;
100
- }
101
- .sby_notice .sby_offer_btn:hover,
102
- .sby_notice .sby_offer_btn:focus,
103
- .sby_notice .sby_main_cta:hover,
104
- .sby_notice .sby_main_cta:focus{
105
- background: #049404;
106
- color: #fff;
107
- }
108
- .sby_notice .sby_other_notice{
109
- padding-top: 10px;
110
- font-style: italic;
111
- font-size: 12px;
112
- }
113
- .sby_notice .sby_other_notice a{
114
- padding: 0;
115
- }
116
- .sby_notice .links > .sby_main_cta:first-child {
117
- margin-left: 8px;
118
  }
1
+ /* Review notice */
2
+ .sby_notice{
3
+ position: relative;
4
+ overflow: hidden;
5
+ max-width: 885px;
6
+ margin-top: 10px;
7
+ padding: 10px 10px 7px 10px;
8
+
9
+ background: #E6F0E8;
10
+ border: 1px solid #6AB074;
11
+ color: #214F28;
12
+ }
13
+ .sby_notice .sby_thumb{
14
+ position: relative;
15
+ display: inline-block;
16
+ width: 74px;
17
+ margin: 0 0 0 -100% !important;
18
+
19
+ -moz-border-radius: 4px;
20
+ -webkit-border-radius: 4px;
21
+ border-radius: 4px;
22
+ }
23
+ .sby_notice .sby_thumb .img-overlay {
24
+ position: absolute;
25
+ bottom: 4px;
26
+ padding: 6px 7px 6px 5px;
27
+ font-size: 13px;
28
+ font-weight: bold;
29
+ background: #fff;
30
+ background: rgba(255,255,255,0.85);
31
+ line-height: 1;
32
+ color: #333;
33
+ box-shadow: 1px -1px 3px 0 rgba(0,0,0,0.15);
34
+ }
35
+ .sby_notice .sby_thumb img {
36
+ max-width: 100%;
37
+ }
38
+ .sby_notice .sby-notice-text{
39
+ float: left;
40
+ clear: none;
41
+ width: 100%;
42
+ padding: 0;
43
+ }
44
+ .sby_notice .sby-links{
45
+ margin-top: 4px !important;
46
+ }
47
+ .sby_notice p{
48
+ float: left;
49
+ clear: both;
50
+ width: auto;
51
+ margin: 0 0 0 90px !important;
52
+ padding: 2px 40px 2px 0;
53
+ line-height: 1.4;
54
+ }
55
+ .sby_notice a{
56
+ display: inline-block;
57
+ padding: 0 8px;
58
+ color: #178529;
59
+ }
60
+ .sby_notice a:hover,
61
+ .sby_notice a:focus{
62
+ color: #0c7abf;
63
+ }
64
+ .sby_notice .links{
65
+ margin: 0 0 0 90px !important;
66
+ padding: 4px 0 0 0;
67
+ margin-top: 1px !important;
68
+ }
69
+ .sby_review_notice .links{
70
+ margin-left: 82px !important;
71
+ margin-top: 0 !important;
72
+ }
73
+ .sby_notice .sby_notice_close,
74
+ .sby_notice .sby_bfcm_sale_notice_close,
75
+ .sby_notice .sby_new_user_sale_notice_close {
76
+ position: absolute;
77
+ top: 0;
78
+ right: 0;
79
+ padding: 10px;
80
+ line-height: 1;
81
+ }
82
+ .sby_notice .sby_notice_close:hover,
83
+ .sby_notice .sby_notice_close:focus{
84
+ color: #a34100;
85
+ }
86
+ .sby_notice strong span {
87
+ font-weight: 900;
88
+ }
89
+ /* Notice CTA btn */
90
+ .sby_notice .sby_offer_btn,
91
+ .sby_notice .sby_main_cta{
92
+ padding: 4px 12px 6px 12px;
93
+ background: green;
94
+ color: #fff;
95
+ border-radius: 4px;
96
+ display: inline-block;
97
+ text-decoration: none;
98
+ margin-left: 0;
99
+ margin-right: 4px;
100
+ }
101
+ .sby_notice .sby_offer_btn:hover,
102
+ .sby_notice .sby_offer_btn:focus,
103
+ .sby_notice .sby_main_cta:hover,
104
+ .sby_notice .sby_main_cta:focus{
105
+ background: #049404;
106
+ color: #fff;
107
+ }
108
+ .sby_notice .sby_other_notice{
109
+ padding-top: 10px;
110
+ font-style: italic;
111
+ font-size: 12px;
112
+ }
113
+ .sby_notice .sby_other_notice a{
114
+ padding: 0;
115
+ }
116
+ .sby_notice .links > .sby_main_cta:first-child {
117
+ margin-left: 8px;
118
  }
{trunk/img → img}/sby-icon-offer.png RENAMED
File without changes
inc/admin/admin-functions.php CHANGED
@@ -1,778 +1,778 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- die( '-1' );
4
- }
5
-
6
- function sby_admin_init() {
7
- global $sby_settings;
8
-
9
- $base_path = trailingslashit( SBY_PLUGIN_DIR ) . 'inc/admin/templates';
10
- $slug = SBY_SLUG;
11
- $plugin_name = SBY_PLUGIN_NAME;
12
- $capability = current_user_can( 'manage_options' ) ? 'manage_options' : 'manage_youtube_feed_options';
13
- $icon = 'dashicons-video-alt3';
14
- $position = 99;
15
- $tabs = array(
16
- array(
17
- 'title' => __( 'Configure', SBY_TEXT_DOMAIN ),
18
- 'slug' => 'configure',
19
- 'capability' => $capability,
20
- 'next_step_instructions' => __( 'Customize your feed', SBY_TEXT_DOMAIN )
21
- ),
22
- array(
23
- 'title' => __( 'Customize', SBY_TEXT_DOMAIN ),
24
- 'slug' => 'customize',
25
- 'capability' => $capability,
26
- 'next_step_instructions' => __( 'Display your feed', SBY_TEXT_DOMAIN )
27
- ),
28
- array(
29
- 'title' => __( 'Display', SBY_TEXT_DOMAIN ),
30
- 'slug' => 'display',
31
- 'capability' => $capability
32
- ),
33
- array(
34
- 'title' => __( 'Support', SBY_TEXT_DOMAIN ),
35
- 'slug' => 'support',
36
- 'capability' => $capability,
37
- 'numbered_tab' => false
38
- )
39
- );
40
-
41
- $active_tab = $tabs[0]['slug'];
42
- if ( isset( $_GET['tab'] ) ) {
43
- $active_tab = sanitize_text_field( $_GET['tab'] ); $tabs[0]['slug'];
44
- } elseif ( isset( $_GET['page'] ) ) {
45
- foreach ( $tabs as $tab ) {
46
- if ( $_GET['page'] === $slug . '_' . $tab['slug'] ) {
47
- $active_tab = $tab['slug'];
48
- }
49
- }
50
- }
51
- $vars = new SBY_Vars();
52
- $admin = new SBY_Admin( $vars, $base_path, $slug, $plugin_name, $capability, $icon, $position, $tabs, $sby_settings, $active_tab, 'sby_settings' );
53
- $admin->access_token_listener();
54
-
55
- $first_connected = sby_get_first_connected_account();
56
- $first_channel_id = isset( $first_connected['channel_id'] ) ? $first_connected['channel_id'] : '';
57
-
58
- $types = array(
59
- array(
60
- 'slug' => 'channel',
61
- 'label' => __( 'Channel', SBY_TEXT_DOMAIN ),
62
- 'input_type' => 'text',
63
- 'default' => $first_channel_id,
64
- 'note' => __( 'Eg: Channel ID or User Name', SBY_TEXT_DOMAIN ),
65
- 'example' => 'smashballoon',
66
- 'description' => __( 'Display videos from a YouTube channel (channel)', SBY_TEXT_DOMAIN ),
67
- 'tooltip' => '<p>' . __( 'Enter any channel ID or user name to display all of an accounts latest videos starting with the most recently published.', SBY_TEXT_DOMAIN ) . '</p><p><ul>
68
- <li><b>' . __( 'Channel ID or User Name', SBY_TEXT_DOMAIN ).'</b><br>
69
- ' . __( 'You can find the ID or User Name of your YouTube Channel from the URL. In each URL format, the text you need to use is highlighted below:', SBY_TEXT_DOMAIN ).'<br><br>
70
- ' . __( 'URL Format 1:', SBY_TEXT_DOMAIN ).' <code>https://www.youtube.com/channel/<span class="sbspf-highlight">UC1a2b3c4D5F6g7i8j9k</span></code>
71
- <br>
72
- ' . __( 'URL Format 2:', SBY_TEXT_DOMAIN ).' <code>https://www.youtube.com/user/<span class="sbspf-highlight">your_user_name</span></code>
73
- </li>
74
- </ul></p>'
75
- ),
76
- array(
77
- 'slug' => 'playlist',
78
- 'label' => __( 'Playlist', SBY_TEXT_DOMAIN ),
79
- 'input_type' => 'text',
80
- 'default' => '',
81
- 'pro' => true,
82
- 'note' => __( 'Eg: Playlist ID', SBY_TEXT_DOMAIN ),
83
- 'example' => 'PLLLm1a2b3c4D6g7i8j9k_1a',
84
- 'description' => __( 'Display videos from a specific playlist (playlist)', SBY_TEXT_DOMAIN ),
85
- 'tooltip' => '<p>' . __( 'Enter any playlist ID to display videos from a playlist starting with the most recently published.', SBY_TEXT_DOMAIN ) . '</p><p><ul>
86
- <li><b>' . __( 'Playlist ID', SBY_TEXT_DOMAIN ).'</b><br>
87
- ' . __( 'You can find the ID of your YouTube playlist from the URL. The text you need to use is highlighted below:', SBY_TEXT_DOMAIN ).'<br><br>
88
- <code>https://www.youtube.com/playlist?list=<span class="sbspf-highlight">PLLLm1a2b3c4D6g7i8j9k_1a2b3c4D57i8j9k</span></code>
89
- </li>
90
- </ul></p>'
91
- ),
92
- array(
93
- 'slug' => 'favorites',
94
- 'label' => __( 'Favorites', SBY_TEXT_DOMAIN ),
95
- 'input_type' => 'text',
96
- 'default' => '',
97
- 'pro' => true,
98
- 'note' => __( 'Eg: Channel ID or User Name', SBY_TEXT_DOMAIN ),
99
- 'example' => 'smashballoon',
100
- 'description' => __( 'Display the "favorites" playlist for a channel (favorites)', SBY_TEXT_DOMAIN ),
101
- 'tooltip' => '<p>' . __( 'Displays all videos marked as "favorites" by a YouTube account starting with the most recently published.', SBY_TEXT_DOMAIN ) . '</p><p><ul>
102
- <li><b>' . __( 'Channel ID or User Name', SBY_TEXT_DOMAIN ).'</b><br>
103
- ' . __( 'You can find the ID or User Name of your YouTube Channel from the URL. In each URL format, the text you need to use is highlighted below:', SBY_TEXT_DOMAIN ).'<br><br>
104
- ' . __( 'URL Format 1:', SBY_TEXT_DOMAIN ).' <code>https://www.youtube.com/channel/<span class="sbspf-highlight">UC1a2b3c4D5F6g7i8j9k</span></code>
105
- <br>
106
- ' . __( 'URL Format 2:', SBY_TEXT_DOMAIN ).' <code>https://www.youtube.com/user/<span class="sbspf-highlight">your_user_name</span></code>
107
- </li>
108
- </ul></p>'
109
- ),
110
- array(
111
- 'slug' => 'search',
112
- 'label' => __( 'Search', SBY_TEXT_DOMAIN ),
113
- 'input_type' => 'text',
114
- 'default' => '',
115
- 'pro' => true,
116
- 'note' => __( 'Eg: Search Term', SBY_TEXT_DOMAIN ),
117
- 'example' => 'cats',
118
- 'description' => __( 'Display a feed of matching search results (search)', SBY_TEXT_DOMAIN ),
119
- 'tooltip' => '<p>' . __( 'Enter any search term or phrase. Separate multiple terms with commas. You can add your own additional query vars using the <a href="https://smashballoon.com/youtube-feed/custom-search-guide/" target="_blank" rel="noopener">guide on our website</a> and the input field above.', SBY_TEXT_DOMAIN ) . '</p>',
120
- ),
121
- array(
122
- 'slug' => 'live',
123
- 'label' => __( 'Live Streams', SBY_TEXT_DOMAIN ),
124
- 'input_type' => 'text',
125
- 'default' => '',
126
- 'pro' => true,
127
- 'note' => __( 'Eg: Channel ID', SBY_TEXT_DOMAIN ),
128
- 'example' => 'UC1a2b3c4D5F6g7i8j9k',
129
- 'description' => __( 'Display upcoming and currently playing live streams (live)', SBY_TEXT_DOMAIN ),
130
- 'tooltip' => '<p>' . __( 'Displays upcoming and currently playing live streaming videos sorted by soonest scheduled broadcast.', SBY_TEXT_DOMAIN ) . '</p><p><ul>
131
- <li><b>' . __( 'Channel ID', SBY_TEXT_DOMAIN ).'</b><br>
132
- ' . __( 'You can find the ID of your YouTube Channel from the URL. The text you need to use is highlighted below:', SBY_TEXT_DOMAIN ).'<br><br>
133
- <code>https://www.youtube.com/channel/<span class="sbspf-highlight">UC1a2b3c4D5F6g7i8j9k</span></code>
134
- </li>
135
- </ul></p>'
136
- )
137
- );
138
- $admin->set_feed_types( $types );
139
-
140
- $text_domain = SBY_TEXT_DOMAIN;
141
- /* Layout */
142
- $layouts = array(
143
- array(
144
- 'slug' => 'grid',
145
- 'label' => __( 'Grid', $text_domain ),
146
- 'image' => 'img/grid.png',
147
- 'note' => __( 'Video thumbnails are displayed in columns and play in a lightbox when clicked.', $text_domain ),
148
- 'options' => array(
149
- array(
150
- 'name' => 'cols',
151
- 'callback' => 'select',
152
- 'label' => __( 'Columns', $text_domain ),
153
- 'min' => 1,
154
- 'max' => 7,
155
- 'default' => 3,
156
- 'shortcode' => array(
157
- 'example' => '3',
158
- 'description' => __( 'Videos in carousel when 480px screen width or less.', $text_domain ),
159
- )
160
- ),
161
- array(
162
- 'name' => 'colsmobile',
163
- 'callback' => 'select',
164
- 'label' => __( 'Mobile Columns', $text_domain ),
165
- 'min' => 1,
166
- 'max' => 2,
167
- 'default' => 2,
168
- 'shortcode' => array(
169
- 'example' => '2',
170
- 'description' => __( 'Columns when 480px screen width or less.', $text_domain ),
171
- )
172
- ),
173
- )
174
- ),
175
- array(
176
- 'slug' => 'gallery',
177
- 'label' => __( 'Gallery', $text_domain ),
178
- 'image' => 'img/gallery.png',
179
- 'note' => __( 'One large video that plays when clicked with thumbnails underneath to play more.', $text_domain ),
180
- 'options' => array(
181
- array(
182
- 'name' => 'cols',
183
- 'callback' => 'select',
184
- 'label' => __( 'Columns', $text_domain ),
185
- 'min' => 1,
186
- 'max' => 7,
187
- 'default' => 3,
188
- 'shortcode' => array(
189
- 'example' => '3',
190
- 'description' => __( 'Videos in carousel when 480px screen width or less.', $text_domain ),
191
- )
192
- ),
193
- array(
194
- 'name' => 'colsmobile',
195
- 'callback' => 'select',
196
- 'label' => __( 'Mobile Columns', $text_domain ),
197
- 'min' => 1,
198
- 'max' => 2,
199
- 'default' => 2,
200
- 'shortcode' => array(
201
- 'example' => '2',
202
- 'description' => __( 'Columns when 480px screen width or less.', $text_domain ),
203
- )
204
- ),
205
- )
206
- ),
207
- array(
208
- 'slug' => 'list',
209
- 'label' => __( 'List', $text_domain ),
210
- 'image' => 'img/list.png',
211
- 'note' => __( 'A single columns of videos that play when clicked.', $text_domain ),
212
- ),
213
- array(
214
- 'slug' => 'carousel',
215
- 'label' => __( 'Carousel', $text_domain ),
216
- 'image' => 'img/carousel.png',
217
- 'note' => __( 'Posts are displayed in a slideshow carousel.', $text_domain ),
218
- 'pro' => true,
219
- 'options' => array(
220
- array(
221
- 'name' => 'cols',
222
- 'callback' => 'select',
223
- 'label' => __( 'Columns', $text_domain ),
224
- 'min' => 1,
225
- 'max' => 7,
226
- 'default' => 3,
227
- 'shortcode' => array(
228
- 'example' => '3',
229
- 'description' => __( 'Videos in carousel when 480px screen width or less.', $text_domain ),
230
- )
231
- ),
232
- array(
233
- 'name' => 'colsmobile',
234
- 'callback' => 'select',
235
- 'label' => __( 'Mobile Columns', $text_domain ),
236
- 'min' => 1,
237
- 'max' => 2,
238
- 'default' => 2,
239
- 'shortcode' => array(
240
- 'example' => '2',
241
- 'description' => __( 'Columns when 480px screen width or less.', $text_domain ),
242
- ) ),
243
- array(
244
- 'name' => 'rows',
245
- 'callback' => 'select',
246
- 'label' => __( 'Number of Rows', $text_domain ),
247
- 'min' => 1,
248
- 'max' => 2,
249
- 'default' => 1,
250
- 'shortcode' => array(
251
- 'example' => '2',
252
- 'description' => __( 'Choose 2 rows to show two posts in a single slide.', $text_domain ),
253
- )
254
- ),
255
- array(
256
- 'name' => 'loop',
257
- 'callback' => 'select',
258
- 'label' => __( 'Loop Type', $text_domain ),
259
- 'options' => array(
260
- array(
261
- 'label' => __( 'Rewind', $text_domain ),
262
- 'value' => 'rewind'
263
- ),
264
- array(
265
- 'label' => __( 'Infinity', $text_domain ),
266
- 'value' => 'infinity'
267
- )
268
- ),
269
- 'default' => 'rewind',
270
- 'shortcode' => array(
271
- 'example' => 'infinity',
272
- 'description' => __( 'What happens when the last slide is reached.', $text_domain ),
273
- )
274
- ),
275
- array(
276
- 'name' => 'arrows',
277
- 'callback' => 'checkbox',
278
- 'label' => __( 'Show Navigation Arrows', $text_domain ),
279
- 'default' => true,
280
- 'shortcode' => array(
281
- 'example' => 'false',
282
- 'description' => __( 'Show arrows on the sides to navigate posts.', $text_domain ),
283
- )
284
- ),
285
- array(
286
- 'name' => 'pag',
287
- 'callback' => 'checkbox',
288
- 'label' => __( 'Show Pagination', $text_domain ),
289
- 'default' => true,
290
- 'shortcode' => array(
291
- 'example' => 'false',
292
- 'description' => __( 'Show dots below carousel for an ordinal indication of which slide is being shown.', $text_domain ),
293
- )
294
- ),
295
- array(
296
- 'name' => 'autoplay',
297
- 'callback' => 'checkbox',
298
- 'label' => __( 'Enable Autoplay', $text_domain ),
299
- 'default' => false,
300
- 'shortcode' => array(
301
- 'example' => 'true',
302
- 'description' => __( 'Whether or not to change slides automatically on an interval.', $text_domain ),
303
- )
304
- ),
305
- array(
306
- 'name' => 'time',
307
- 'callback' => 'text',
308
- 'label' => __( 'Interval Time', $text_domain ),
309
- 'default' => 5000,
310
- 'shortcode' => array(
311
- 'example' => '3000',
312
- 'description' => __( 'Duration in milliseconds before the slide changes.', $text_domain ),
313
- )
314
- ),
315
- )
316
- ),
317
-
318
- );
319
- $admin->set_feed_layouts( $layouts );
320
-
321
- $display_your_feed_table_headings = array(
322
- array(
323
- 'slug' => 'configure',
324
- 'label' => __( 'Configure Options', SBY_TEXT_DOMAIN ),
325
- ),
326
- array(
327
- 'slug' => 'customize',
328
- 'label' => __( 'Customize Options', SBY_TEXT_DOMAIN ),
329
- ),
330
- array(
331
- 'slug' => 'layout',
332
- 'label' => __( 'Layout Options', SBY_TEXT_DOMAIN ),
333
- ),
334
- array(
335
- 'slug' => 'experience',
336
- 'label' => __( 'Video Experience Options', SBY_TEXT_DOMAIN ),
337
- ),
338
- array(
339
- 'slug' => 'header',
340
- 'label' => __( 'Header Options', SBY_TEXT_DOMAIN ),
341
- ),
342
- array(
343
- 'slug' => 'button',
344
- 'label' => __( '"Load More" Button Options', SBY_TEXT_DOMAIN ),
345
- ),
346
- array(
347
- 'slug' => 'subscribe',
348
- 'label' => __( '"Subscribe" Button Options', SBY_TEXT_DOMAIN ),
349
- )
350
- );
351
- $admin->set_display_table_sections( $display_your_feed_table_headings );
352
-
353
- $admin->init();
354
- }
355
-
356
- function sby_admin_style() {
357
- wp_enqueue_style( SBY_SLUG . '_admin_notices_css', SBY_PLUGIN_URL . 'css/sby-notices.css', array(), SBYVER );
358
- if ( ! sby_is_admin_page() ) {
359
- return;
360
- }
361
- wp_enqueue_style( SBY_SLUG . '_admin_css', SBY_PLUGIN_URL . 'css/admin.css', array(), SBYVER );
362
- wp_enqueue_style( 'sb_font_awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' );
363
- wp_enqueue_style( 'wp-color-picker' );
364
- }
365
- add_action( 'admin_enqueue_scripts', 'sby_admin_style' );
366
-
367
- function sby_admin_scripts() {
368
- if ( ! sby_is_admin_page() ) {
369
- return;
370
- }
371
- wp_enqueue_script( SBY_SLUG . '_admin_js', SBY_PLUGIN_URL . 'js/admin.js', array(), SBYVER );
372
- wp_localize_script( SBY_SLUG . '_admin_js', 'sbspf', array(
373
- 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
374
- 'nonce' => wp_create_nonce( 'sbspf_nonce' )
375
- )
376
- );
377
- wp_enqueue_script('wp-color-picker' );
378
- }
379
- add_action( 'admin_enqueue_scripts', 'sby_admin_scripts' );
380
-
381
- function sby_is_admin_page() {
382
- if ( ! isset( $_GET['page'] ) ) {
383
- return false;
384
- } elseif ( strpos( sanitize_text_field( $_GET['page'] ), SBY_SLUG ) !== false ) {
385
- return true;
386
- }
387
- return false;
388
- }
389
-
390
- function sby_admin_icon( $icon, $class = '' ) {
391
- $class = ! empty( $class ) ? ' ' . $class : '';
392
- if ( $icon === 'question-circle' ) {
393
- return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="question-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-question-circle fa-w-16'.$class.'"><path fill="currentColor" d="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z" class=""></path></svg>';
394
- } elseif ( $icon === 'info-circle' ) {
395
- return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="info-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-info-circle fa-w-16'.$class.'"><path fill="currentColor" d="M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z" class=""></path></svg>';
396
- } elseif ( $icon === 'life-ring' ) {
397
- return '<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="life-ring" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-life-ring fa-w-16'.$class.'"><path fill="currentColor" d="M256 504c136.967 0 248-111.033 248-248S392.967 8 256 8 8 119.033 8 256s111.033 248 248 248zm-103.398-76.72l53.411-53.411c31.806 13.506 68.128 13.522 99.974 0l53.411 53.411c-63.217 38.319-143.579 38.319-206.796 0zM336 256c0 44.112-35.888 80-80 80s-80-35.888-80-80 35.888-80 80-80 80 35.888 80 80zm91.28 103.398l-53.411-53.411c13.505-31.806 13.522-68.128 0-99.974l53.411-53.411c38.319 63.217 38.319 143.579 0 206.796zM359.397 84.72l-53.411 53.411c-31.806-13.505-68.128-13.522-99.973 0L152.602 84.72c63.217-38.319 143.579-38.319 206.795 0zM84.72 152.602l53.411 53.411c-13.506 31.806-13.522 68.128 0 99.974L84.72 359.398c-38.319-63.217-38.319-143.579 0-206.796z" class=""></path></svg>';
398
- } elseif ( $icon === 'envelope' ) {
399
- return '<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="envelope" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-envelope fa-w-16'.$class.'"><path fill="currentColor" d="M464 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm0 48v40.805c-22.422 18.259-58.168 46.651-134.587 106.49-16.841 13.247-50.201 45.072-73.413 44.701-23.208.375-56.579-31.459-73.413-44.701C106.18 199.465 70.425 171.067 48 152.805V112h416zM48 400V214.398c22.914 18.251 55.409 43.862 104.938 82.646 21.857 17.205 60.134 55.186 103.062 54.955 42.717.231 80.509-37.199 103.053-54.947 49.528-38.783 82.032-64.401 104.947-82.653V400H48z" class=""></path></svg>';
400
- } elseif ( $icon === 'chevron-right' ) {
401
- return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="chevron-circle-right" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-chevron-circle-right fa-w-16'.$class.'"><path fill="currentColor" d="M256 8c137 0 248 111 248 248S393 504 256 504 8 393 8 256 119 8 256 8zm113.9 231L234.4 103.5c-9.4-9.4-24.6-9.4-33.9 0l-17 17c-9.4 9.4-9.4 24.6 0 33.9L285.1 256 183.5 357.6c-9.4 9.4-9.4 24.6 0 33.9l17 17c9.4 9.4 24.6 9.4 33.9 0L369.9 273c9.4-9.4 9.4-24.6 0-34z" class=""></path></svg>';
402
- } elseif ( $icon === 'rocket' ) {
403
- return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="rocket" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-rocket fa-w-16'.$class.'"><path fill="currentColor" d="M505.05 19.1a15.89 15.89 0 0 0-12.2-12.2C460.65 0 435.46 0 410.36 0c-103.2 0-165.1 55.2-211.29 128H94.87A48 48 0 0 0 52 154.49l-49.42 98.8A24 24 0 0 0 24.07 288h103.77l-22.47 22.47a32 32 0 0 0 0 45.25l50.9 50.91a32 32 0 0 0 45.26 0L224 384.16V488a24 24 0 0 0 34.7 21.49l98.7-49.39a47.91 47.91 0 0 0 26.5-42.9V312.79c72.59-46.3 128-108.4 128-211.09.1-25.2.1-50.4-6.85-82.6zM384 168a40 40 0 1 1 40-40 40 40 0 0 1-40 40z" class=""></path></svg>';
404
- } elseif ( $icon === 'minus-circle' ) {
405
- return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="minus-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-minus-circle fa-w-16'.$class.'"><path fill="currentColor" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zM124 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H124z" class=""></path></svg>';
406
- } elseif ( $icon === 'times' ) {
407
- return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="times" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512" class="svg-inline--fa fa-times fa-w-11'.$class.'"><path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z" class=""></path></svg>';
408
- } elseif ( $icon === 'cog' ) {
409
- return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="cog" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-cog fa-w-16'.$class.'"><path fill="currentColor" d="M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z" class=""></path></svg>';
410
- } elseif ( $icon === 'ellipsis' ) {
411
- return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="ellipsis-h" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-ellipsis-h fa-w-16'.$class.'"><path fill="currentColor" d="M328 256c0 39.8-32.2 72-72 72s-72-32.2-72-72 32.2-72 72-72 72 32.2 72 72zm104-72c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72zm-352 0c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72z" class=""></path></svg>';
412
- } else {
413
- sby_icon( $icon );
414
- }
415
- }
416
-
417
- function sby_delete_connected_account() {
418
- if ( ! isset( $_POST['sbspf_nonce'] ) || ! isset( $_POST['account_id']) ) return;
419
- $nonce = $_POST['sbspf_nonce'];
420
- if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
421
- die ( 'You did not do this the right way!' );
422
- }
423
-
424
- global $sby_settings;
425
-
426
- $account_id = sanitize_text_field( $_POST['account_id'] );
427
- $to_save = array();
428
-
429
- foreach ( $sby_settings['connected_accounts'] as $connected_account ) {
430
- if ( (string)$connected_account['channel_id'] !== (string)$account_id ) {
431
- $to_save[ $connected_account['channel_id'] ] = $connected_account;
432
- }
433
- }
434
-
435
- $sby_settings['connected_accounts'] = $to_save;
436
- update_option( 'sby_settings', $sby_settings );
437
-
438
- echo wp_json_encode( array( 'success' => true ) );
439
-
440
- die();
441
- }
442
- add_action( 'wp_ajax_sby_ca_after_remove_clicked', 'sby_delete_connected_account' );
443
-
444
- function sby_process_access_token() {
445
- if ( ! isset( $_POST['sbspf_nonce'] ) || ! isset( $_POST['sby_access_token'] ) ) return;
446
- $nonce = $_POST['sbspf_nonce'];
447
- if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
448
- die ( 'You did not do this the right way!' );
449
- }
450
-
451
- $account = sby_attempt_connection();
452
-
453
- if ( $account ) {
454
- global $sby_settings;
455
-
456
- $options = $sby_settings;
457
- $username = $account['username'] ? $account['username'] : $account['channel_id'];
458
- if ( isset( $account['local_avatar'] ) && $account['local_avatar'] && isset( $options['favorlocal'] ) && $options['favorlocal' ] === 'on' ) {
459
- $upload = wp_upload_dir();
460
- $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBY_UPLOADS_NAME );
461
- $profile_picture = '<img class="sbspf_ca_avatar" src="'.$resized_url . $account['username'].'.jpg" />'; //Could add placeholder avatar image
462
- } else {
463
- $profile_picture = $account['profile_picture'] ? '<img class="sbspf_ca_avatar" src="'.$account['profile_picture'].'" />' : ''; //Could add placeholder avatar image
464
- }
465
-
466
- $text_domain = SBY_TEXT_DOMAIN;
467
- $slug = SBY_SLUG;
468
- ob_start();
469
- include trailingslashit( SBY_PLUGIN_DIR ) . 'inc/admin/templates/single-connected-account.php';
470
- if ( sby_notice_not_dismissed() ) {
471
- include trailingslashit( SBY_PLUGIN_DIR ) . 'inc/admin/templates/modal.php';
472
- echo '<span class="sby_account_just_added"></span>';
473
- }
474
-
475
- $html = ob_get_contents();
476
- ob_get_clean();
477
-
478
- $return = array(
479
- 'account_id' => $account['channel_id'],
480
- 'html' => $html
481
- );
482
- } else {
483
- $return = array(
484
- 'error' => __( 'Could not connect your account. Please check to make sure this is a valid access token for the Smash Balloon YouTube App.'),
485
- 'html' => ''
486
- );
487
- }
488
-
489
- echo wp_json_encode( $return );
490
-
491
- die();
492
- }
493
- add_action( 'wp_ajax_sby_process_access_token', 'sby_process_access_token' );
494
-
495
- function sby_delete_wp_posts() {
496
- if ( ! isset( $_POST['sbspf_nonce'] ) ) return;
497
- $nonce = $_POST['sbspf_nonce'];
498
- if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
499
- die ( 'You did not do this the right way!' );
500
- }
501
-
502
- sby_clear_wp_posts();
503
-
504
- echo '{}';
505
-
506
- die();
507
- }
508
- add_action( 'wp_ajax_sby_delete_wp_posts', 'sby_delete_wp_posts' );
509
-
510
- function sby_attempt_connection() {
511
- if ( ! current_user_can( 'manage_youtube_feed_options' ) ) {
512
- return false;
513
- }
514
- if ( isset( $_GET['sby_access_token'] ) ) {
515
- $access_token = sanitize_text_field( urldecode( $_GET['sby_access_token'] ) );
516
- $refresh_token = '';
517
- } else {
518
- $access_token = sanitize_text_field( $_POST['sby_access_token'] );
519
- $refresh_token = '';
520
- }
521
-
522
- $account_info = array(
523
- 'access_token' => $access_token,
524
- 'refresh_token' => $refresh_token
525
- );
526
- $sby_api_connect = new SBY_API_Connect( $account_info, 'tokeninfo' );
527
- $sby_api_connect->connect();
528
-
529
- $data = $sby_api_connect->get_data();
530
-
531
- if ( isset( $data['audience'] ) ) {
532
- $expires = $data['expires_in'] + time();
533
- $sby_api_connect = new SBY_API_Connect( $account_info, 'channels' );
534
- $sby_api_connect->connect();
535
- $data = $sby_api_connect->get_data();
536
-
537
- if ( isset( $data['items'] ) ) {
538
- $account_info['username'] = $data['items'][0]['snippet']['title'];
539
- $account_info['channel_id'] = $data['items'][0]['id'];
540
- $account_info['profile_picture'] = $data['items'][0]['snippet']['thumbnails']['default']['url'];
541
- $account_info['privacy'] = '';
542
- $account_info['expires'] = $expires;
543
- //privacyStatus
544
- SBY_Admin::connect_account( $account_info );
545
-
546
- return $account_info;
547
- } else {
548
- $account_info['username'] = '(No Channel)';
549
- $account_info['channel_id'] = '';
550
- $account_info['profile_picture'] = '';
551
- $account_info['privacy'] = '';
552
- $account_info['expires'] = $expires;
553
- //privacyStatus
554
- SBY_Admin::connect_account( $account_info );
555
-
556
- return $account_info;
557
- }
558
- }
559
- return false;
560
- }
561
-
562
- function sbspf_account_search() {
563
- if ( ! isset( $_POST['sbspf_nonce'] ) || ! isset( $_POST['term']) ) return;
564
- $nonce = $_POST['sbspf_nonce'];
565
- if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
566
- die ( 'You did not do this the right way!' );
567
- }
568
-
569
- global $sby_settings;
570
-
571
- $term = sanitize_text_field( $_POST['term'] );
572
- $params = array(
573
- 'q' => $term,
574
- 'type' => 'channel'
575
- );
576
-
577
- $connected_account_for_term = array();
578
- foreach ( $sby_settings['connected_accounts'] as $connected_account ) {
579
- $connected_account_for_term = $connected_account;
580
- }
581
- if ( $connected_account_for_term['expires'] < time() + 5 ) {
582
- $new_token_data = SBY_API_Connect::refresh_token( sby_get_account_bottom(), $connected_account_for_term['refresh_token'], sby_get_account_top() );
583
-
584
- if ( isset( $new_token_data['access_token'] ) ) {
585
- $connected_account_for_term['access_token'] = $new_token_data['access_token'];
586
- $connected_accounts_for_feed[ $term ]['access_token'] = $new_token_data['access_token'];
587
- $connected_account_for_term['expires'] = $new_token_data['expires_in'] + time();
588
- $connected_accounts_for_feed[ $term ]['expires'] = $new_token_data['expires_in'] + time();
589
-
590
- sby_update_or_connect_account( $connected_account_for_term );
591
-
592
- }
593
- }
594
-
595
- $search = new SBY_API_Connect( $connected_account_for_term, 'search', $params );
596
-
597
- $search->connect();
598
-
599
-
600
- echo wp_json_encode( $search->get_data() );
601
-
602
- die();
603
- }
604
- add_action( 'wp_ajax_sbspf_account_search', 'sbspf_account_search' );
605
-
606
- function sby_reset_cron( $settings ) {
607
- $sbi_caching_type = isset( $settings['caching_type'] ) ? $settings['caching_type'] : '';
608
- $sbi_cache_cron_interval = isset( $settings['cache_cron_interval'] ) ? $settings['cache_cron_interval'] : '';
609
- $sbi_cache_cron_time = isset( $settings['cache_cron_time'] ) ? $settings['cache_cron_time'] : '';
610
- $sbi_cache_cron_am_pm = isset( $settings['cache_cron_am_pm'] ) ? $settings['cache_cron_am_pm'] : '';
611
-
612
- if ( $sbi_caching_type === 'background' ) {
613
- delete_option( 'sby_cron_report' );
614
- SBY_Cron_Updater::start_cron_job( $sbi_cache_cron_interval, $sbi_cache_cron_time, $sbi_cache_cron_am_pm );
615
- }
616
- }
617
- add_action( 'sby_settings_after_configure_save', 'sby_reset_cron', 10, 1 );
618
-
619
- function sby_maybe_start_cron_clear_cache( $settings ) {
620
- $sby_doing_cron_clear = isset( $settings['cronclear'] ) ? $settings['cronclear'] : false;
621
-
622
- if ( $sby_doing_cron_clear ) {
623
- wp_clear_scheduled_hook( 'sby_cron_job' );
624
-
625
- wp_schedule_event( time(), 'hourly', 'sby_cron_job' );
626
- }
627
- }
628
- add_action( 'sby_settings_after_customize_save', 'sby_maybe_start_cron_clear_cache', 10, 1 );
629
-
630
- function sby_clear_wp_posts() {
631
-
632
- global $wpdb;
633
-
634
- $youtube_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type = '".SBY_CPT."';" );
635
-
636
- $id_string = implode( ', ', $youtube_ids );
637
- if ( ! empty( $id_string ) ) {
638
- $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE post_id IN ($id_string);" );
639
- $wpdb->query( "DELETE FROM $wpdb->posts WHERE post_type = '".SBY_CPT."';" );
640
- }
641
- }
642
-
643
- /** Notices */
644
-
645
- function sby_dismiss_at_warning_notice() {
646
-
647
- update_user_meta( get_current_user_id(), 'sby_at_warning_notice', time() );
648
-
649
- die();
650
- }
651
- add_action( 'wp_ajax_sby_dismiss_at_warning_notice', 'sby_dismiss_at_warning_notice' );
652
-
653
- function sby_dismiss_connect_warning_notice() {
654
-
655
- update_user_meta( get_current_user_id(), 'sby_connect_warning_notice', time() );
656
-
657
- die();
658
- }
659
- add_action( 'wp_ajax_sby_dismiss_connect_warning_button', 'sby_dismiss_connect_warning_notice' );
660
-
661
- function sby_notice_not_dismissed( $key = 'sby_at_warning_notice' ) {
662
- $meta = get_user_meta( get_current_user_id(), $key, true );
663
- return (int)$meta + DAY_IN_SECONDS < time();
664
- }
665
-
666
- function sby_access_token_warning_modal() {
667
- if ( isset( $_GET['page'] ) && $_GET['page'] === SBY_SLUG && isset( $_GET['sby_access_token'] ) && sby_notice_not_dismissed() ) {
668
- $text_domain = SBY_TEXT_DOMAIN;
669
- include trailingslashit( SBY_PLUGIN_DIR ) . 'inc/admin/templates/modal.php';
670
- echo '<span class="sby_account_just_added"></span>';
671
- }
672
-
673
- }
674
- add_action( 'admin_footer', 'sby_access_token_warning_modal', 1 );
675
-
676
- function sby_get_current_time() {
677
- $current_time = time();
678
-
679
- // where to do tests
680
- //$current_time = strtotime( 'November 25, 2020' ) + 1;
681
-
682
- return $current_time;
683
- }
684
-
685
- // generates the html for the admin notices
686
- function sby_notices_html() {
687
-
688
- //delete_transient( 'instagram_feed_rating_notice_waiting' );
689
-
690
- //set_transient( 'instagram_feed_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS );
691
- //update_option( 'sby_rating_notice', 'pending', false );
692
-
693
-
694
- }
695
- //add_action( 'admin_notices', 'sby_notices_html', 12 ); // priority 8 for Instagram, priority 10 for Facebook
696
-
697
-
698
- function sby_lite_dismiss() {
699
- if ( ! isset( $_POST['sbspf_nonce'] ) ) return;
700
- $nonce = $_POST['sbspf_nonce'];
701
- if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
702
- die ( 'You did not do this the right way!' );
703
- }
704
-
705
- set_transient( 'youtube_feed_dismiss_lite', 'dismiss', 1 * WEEK_IN_SECONDS );
706
-
707
- die();
708
- }
709
- add_action( 'wp_ajax_sby_lite_dismiss', 'sby_lite_dismiss' );
710
-
711
- function sby_get_future_date( $month, $year, $week, $day, $direction ) {
712
- if ( $direction > 0 ) {
713
- $startday = 1;
714
- } else {
715
- $startday = date( 't', mktime(0, 0, 0, $month, 1, $year ) );
716
- }
717
-
718
- $start = mktime( 0, 0, 0, $month, $startday, $year );
719
- $weekday = date( 'N', $start );
720
-
721
- $offset = 0;
722
- if ( $direction * $day >= $direction * $weekday ) {
723
- $offset = -$direction * 7;
724
- }
725
-
726
- $offset += $direction * ($week * 7) + ($day - $weekday);
727
- return mktime( 0, 0, 0, $month, $startday + $offset, $year );
728
- }
729
-
730
- function sby_admin_hide_unrelated_notices() {
731
-
732
- // Bail if we're not on a Sby screen or page.
733
- if ( ! sby_is_admin_page() ) {
734
- return;
735
- }
736
-
737
- // Extra banned classes and callbacks from third-party plugins.
738
- $blacklist = array(
739
- 'classes' => array(),
740
- 'callbacks' => array(
741
- 'sbydb_admin_notice', // 'Database for Sby' plugin.
742
- ),
743
- );
744
-
745
- global $wp_filter;
746
-
747
- foreach ( array( 'user_admin_notices', 'admin_notices', 'all_admin_notices' ) as $notices_type ) {
748
- if ( empty( $wp_filter[ $notices_type ]->callbacks ) || ! is_array( $wp_filter[ $notices_type ]->callbacks ) ) {
749
- continue;
750
- }
751
- foreach ( $wp_filter[ $notices_type ]->callbacks as $priority => $hooks ) {
752
- foreach ( $hooks as $name => $arr ) {
753
- if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
754
- unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
755
- continue;
756
- }
757
- $class = ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) ? strtolower( get_class( $arr['function'][0] ) ) : '';
758
- if (
759
- ! empty( $class ) &&
760
- strpos( $class, 'sby' ) !== false &&
761
- ! in_array( $class, $blacklist['classes'], true )
762
- ) {
763
- continue;
764
- }
765
- if (
766
- ! empty( $name ) && (
767
- strpos( $name, 'sby' ) === false ||
768
- in_array( $class, $blacklist['classes'], true ) ||
769
- in_array( $name, $blacklist['callbacks'], true )
770
- )
771
- ) {
772
- unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
773
- }
774
- }
775
- }
776
- }
777
- }
778
  add_action( 'admin_print_scripts', 'sby_admin_hide_unrelated_notices' );
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die( '-1' );
4
+ }
5
+
6
+ function sby_admin_init() {
7
+ global $sby_settings;
8
+
9
+ $base_path = trailingslashit( SBY_PLUGIN_DIR ) . 'inc/admin/templates';
10
+ $slug = SBY_SLUG;
11
+ $plugin_name = SBY_PLUGIN_NAME;
12
+ $capability = current_user_can( 'manage_options' ) ? 'manage_options' : 'manage_youtube_feed_options';
13
+ $icon = 'dashicons-video-alt3';
14
+ $position = 99;
15
+ $tabs = array(
16
+ array(
17
+ 'title' => __( 'Configure', SBY_TEXT_DOMAIN ),
18
+ 'slug' => 'configure',
19
+ 'capability' => $capability,
20
+ 'next_step_instructions' => __( 'Customize your feed', SBY_TEXT_DOMAIN )
21
+ ),
22
+ array(
23
+ 'title' => __( 'Customize', SBY_TEXT_DOMAIN ),
24
+ 'slug' => 'customize',
25
+ 'capability' => $capability,
26
+ 'next_step_instructions' => __( 'Display your feed', SBY_TEXT_DOMAIN )
27
+ ),
28
+ array(
29
+ 'title' => __( 'Display', SBY_TEXT_DOMAIN ),
30
+ 'slug' => 'display',
31
+ 'capability' => $capability
32
+ ),
33
+ array(
34
+ 'title' => __( 'Support', SBY_TEXT_DOMAIN ),
35
+ 'slug' => 'support',
36
+ 'capability' => $capability,
37
+ 'numbered_tab' => false
38
+ )
39
+ );
40
+
41
+ $active_tab = $tabs[0]['slug'];
42
+ if ( isset( $_GET['tab'] ) ) {
43
+ $active_tab = sanitize_text_field( $_GET['tab'] ); $tabs[0]['slug'];
44
+ } elseif ( isset( $_GET['page'] ) ) {
45
+ foreach ( $tabs as $tab ) {
46
+ if ( $_GET['page'] === $slug . '_' . $tab['slug'] ) {
47
+ $active_tab = $tab['slug'];
48
+ }
49
+ }
50
+ }
51
+ $vars = new SBY_Vars();
52
+ $admin = new SBY_Admin( $vars, $base_path, $slug, $plugin_name, $capability, $icon, $position, $tabs, $sby_settings, $active_tab, 'sby_settings' );
53
+ $admin->access_token_listener();
54
+
55
+ $first_connected = sby_get_first_connected_account();
56
+ $first_channel_id = isset( $first_connected['channel_id'] ) ? $first_connected['channel_id'] : '';
57
+
58
+ $types = array(
59
+ array(
60
+ 'slug' => 'channel',
61
+ 'label' => __( 'Channel', SBY_TEXT_DOMAIN ),
62
+ 'input_type' => 'text',
63
+ 'default' => $first_channel_id,
64
+ 'note' => __( 'Eg: Channel ID or User Name', SBY_TEXT_DOMAIN ),
65
+ 'example' => 'smashballoon',
66
+ 'description' => __( 'Display videos from a YouTube channel (channel)', SBY_TEXT_DOMAIN ),
67
+ 'tooltip' => '<p>' . __( 'Enter any channel ID or user name to display all of an accounts latest videos starting with the most recently published.', SBY_TEXT_DOMAIN ) . '</p><p><ul>
68
+ <li><b>' . __( 'Channel ID or User Name', SBY_TEXT_DOMAIN ).'</b><br>
69
+ ' . __( 'You can find the ID or User Name of your YouTube Channel from the URL. In each URL format, the text you need to use is highlighted below:', SBY_TEXT_DOMAIN ).'<br><br>
70
+ ' . __( 'URL Format 1:', SBY_TEXT_DOMAIN ).' <code>https://www.youtube.com/channel/<span class="sbspf-highlight">UC1a2b3c4D5F6g7i8j9k</span></code>
71
+ <br>
72
+ ' . __( 'URL Format 2:', SBY_TEXT_DOMAIN ).' <code>https://www.youtube.com/user/<span class="sbspf-highlight">your_user_name</span></code>
73
+ </li>
74
+ </ul></p>'
75
+ ),
76
+ array(
77
+ 'slug' => 'playlist',
78
+ 'label' => __( 'Playlist', SBY_TEXT_DOMAIN ),
79
+ 'input_type' => 'text',
80
+ 'default' => '',
81
+ 'pro' => true,
82
+ 'note' => __( 'Eg: Playlist ID', SBY_TEXT_DOMAIN ),
83
+ 'example' => 'PLLLm1a2b3c4D6g7i8j9k_1a',
84
+ 'description' => __( 'Display videos from a specific playlist (playlist)', SBY_TEXT_DOMAIN ),
85
+ 'tooltip' => '<p>' . __( 'Enter any playlist ID to display videos from a playlist starting with the most recently published.', SBY_TEXT_DOMAIN ) . '</p><p><ul>
86
+ <li><b>' . __( 'Playlist ID', SBY_TEXT_DOMAIN ).'</b><br>
87
+ ' . __( 'You can find the ID of your YouTube playlist from the URL. The text you need to use is highlighted below:', SBY_TEXT_DOMAIN ).'<br><br>
88
+ <code>https://www.youtube.com/playlist?list=<span class="sbspf-highlight">PLLLm1a2b3c4D6g7i8j9k_1a2b3c4D57i8j9k</span></code>
89
+ </li>
90
+ </ul></p>'
91
+ ),
92
+ array(
93
+ 'slug' => 'favorites',
94
+ 'label' => __( 'Favorites', SBY_TEXT_DOMAIN ),
95
+ 'input_type' => 'text',
96
+ 'default' => '',
97
+ 'pro' => true,
98
+ 'note' => __( 'Eg: Channel ID or User Name', SBY_TEXT_DOMAIN ),
99
+ 'example' => 'smashballoon',
100
+ 'description' => __( 'Display the "favorites" playlist for a channel (favorites)', SBY_TEXT_DOMAIN ),
101
+ 'tooltip' => '<p>' . __( 'Displays all videos marked as "favorites" by a YouTube account starting with the most recently published.', SBY_TEXT_DOMAIN ) . '</p><p><ul>
102
+ <li><b>' . __( 'Channel ID or User Name', SBY_TEXT_DOMAIN ).'</b><br>
103
+ ' . __( 'You can find the ID or User Name of your YouTube Channel from the URL. In each URL format, the text you need to use is highlighted below:', SBY_TEXT_DOMAIN ).'<br><br>
104
+ ' . __( 'URL Format 1:', SBY_TEXT_DOMAIN ).' <code>https://www.youtube.com/channel/<span class="sbspf-highlight">UC1a2b3c4D5F6g7i8j9k</span></code>
105
+ <br>
106
+ ' . __( 'URL Format 2:', SBY_TEXT_DOMAIN ).' <code>https://www.youtube.com/user/<span class="sbspf-highlight">your_user_name</span></code>
107
+ </li>
108
+ </ul></p>'
109
+ ),
110
+ array(
111
+ 'slug' => 'search',
112
+ 'label' => __( 'Search', SBY_TEXT_DOMAIN ),
113
+ 'input_type' => 'text',
114
+ 'default' => '',
115
+ 'pro' => true,
116
+ 'note' => __( 'Eg: Search Term', SBY_TEXT_DOMAIN ),
117
+ 'example' => 'cats',
118
+ 'description' => __( 'Display a feed of matching search results (search)', SBY_TEXT_DOMAIN ),
119
+ 'tooltip' => '<p>' . __( 'Enter any search term or phrase. Separate multiple terms with commas. You can add your own additional query vars using the <a href="https://smashballoon.com/youtube-feed/custom-search-guide/" target="_blank" rel="noopener">guide on our website</a> and the input field above.', SBY_TEXT_DOMAIN ) . '</p>',
120
+ ),
121
+ array(
122
+ 'slug' => 'live',
123
+ 'label' => __( 'Live Streams', SBY_TEXT_DOMAIN ),
124
+ 'input_type' => 'text',
125
+ 'default' => '',
126
+ 'pro' => true,
127
+ 'note' => __( 'Eg: Channel ID', SBY_TEXT_DOMAIN ),
128
+ 'example' => 'UC1a2b3c4D5F6g7i8j9k',
129
+ 'description' => __( 'Display upcoming and currently playing live streams (live)', SBY_TEXT_DOMAIN ),
130
+ 'tooltip' => '<p>' . __( 'Displays upcoming and currently playing live streaming videos sorted by soonest scheduled broadcast.', SBY_TEXT_DOMAIN ) . '</p><p><ul>
131
+ <li><b>' . __( 'Channel ID', SBY_TEXT_DOMAIN ).'</b><br>
132
+ ' . __( 'You can find the ID of your YouTube Channel from the URL. The text you need to use is highlighted below:', SBY_TEXT_DOMAIN ).'<br><br>
133
+ <code>https://www.youtube.com/channel/<span class="sbspf-highlight">UC1a2b3c4D5F6g7i8j9k</span></code>
134
+ </li>
135
+ </ul></p>'
136
+ )
137
+ );
138
+ $admin->set_feed_types( $types );
139
+
140
+ $text_domain = SBY_TEXT_DOMAIN;
141
+ /* Layout */
142
+ $layouts = array(
143
+ array(
144
+ 'slug' => 'grid',
145
+ 'label' => __( 'Grid', $text_domain ),
146
+ 'image' => 'img/grid.png',
147
+ 'note' => __( 'Video thumbnails are displayed in columns and play in a lightbox when clicked.', $text_domain ),
148
+ 'options' => array(
149
+ array(
150
+ 'name' => 'cols',
151
+ 'callback' => 'select',
152
+ 'label' => __( 'Columns', $text_domain ),
153
+ 'min' => 1,
154
+ 'max' => 7,
155
+ 'default' => 3,
156
+ 'shortcode' => array(
157
+ 'example' => '3',
158
+ 'description' => __( 'Videos in carousel when 480px screen width or less.', $text_domain ),
159
+ )
160
+ ),
161
+ array(
162
+ 'name' => 'colsmobile',
163
+ 'callback' => 'select',
164
+ 'label' => __( 'Mobile Columns', $text_domain ),
165
+ 'min' => 1,
166
+ 'max' => 2,
167
+ 'default' => 2,
168
+ 'shortcode' => array(
169
+ 'example' => '2',
170
+ 'description' => __( 'Columns when 480px screen width or less.', $text_domain ),
171
+ )
172
+ ),
173
+ )
174
+ ),
175
+ array(
176
+ 'slug' => 'gallery',
177
+ 'label' => __( 'Gallery', $text_domain ),
178
+ 'image' => 'img/gallery.png',
179
+ 'note' => __( 'One large video that plays when clicked with thumbnails underneath to play more.', $text_domain ),
180
+ 'options' => array(
181
+ array(
182
+ 'name' => 'cols',
183
+ 'callback' => 'select',
184
+ 'label' => __( 'Columns', $text_domain ),
185
+ 'min' => 1,
186
+ 'max' => 7,
187
+ 'default' => 3,
188
+ 'shortcode' => array(
189
+ 'example' => '3',
190
+ 'description' => __( 'Videos in carousel when 480px screen width or less.', $text_domain ),
191
+ )
192
+ ),
193
+ array(
194
+ 'name' => 'colsmobile',
195
+ 'callback' => 'select',
196
+ 'label' => __( 'Mobile Columns', $text_domain ),
197
+ 'min' => 1,
198
+ 'max' => 2,
199
+ 'default' => 2,
200
+ 'shortcode' => array(
201
+ 'example' => '2',
202
+ 'description' => __( 'Columns when 480px screen width or less.', $text_domain ),
203
+ )
204
+ ),
205
+ )
206
+ ),
207
+ array(
208
+ 'slug' => 'list',
209
+ 'label' => __( 'List', $text_domain ),
210
+ 'image' => 'img/list.png',
211
+ 'note' => __( 'A single columns of videos that play when clicked.', $text_domain ),
212
+ ),
213
+ array(
214
+ 'slug' => 'carousel',
215
+ 'label' => __( 'Carousel', $text_domain ),
216
+ 'image' => 'img/carousel.png',
217
+ 'note' => __( 'Posts are displayed in a slideshow carousel.', $text_domain ),
218
+ 'pro' => true,
219
+ 'options' => array(
220
+ array(
221
+ 'name' => 'cols',
222
+ 'callback' => 'select',
223
+ 'label' => __( 'Columns', $text_domain ),
224
+ 'min' => 1,
225
+ 'max' => 7,
226
+ 'default' => 3,
227
+ 'shortcode' => array(
228
+ 'example' => '3',
229
+ 'description' => __( 'Videos in carousel when 480px screen width or less.', $text_domain ),
230
+ )
231
+ ),
232
+ array(
233
+ 'name' => 'colsmobile',
234
+ 'callback' => 'select',
235
+ 'label' => __( 'Mobile Columns', $text_domain ),
236
+ 'min' => 1,
237
+ 'max' => 2,
238
+ 'default' => 2,
239
+ 'shortcode' => array(
240
+ 'example' => '2',
241
+ 'description' => __( 'Columns when 480px screen width or less.', $text_domain ),
242
+ ) ),
243
+ array(
244
+ 'name' => 'rows',
245
+ 'callback' => 'select',
246
+ 'label' => __( 'Number of Rows', $text_domain ),
247
+ 'min' => 1,
248
+ 'max' => 2,
249
+ 'default' => 1,
250
+ 'shortcode' => array(
251
+ 'example' => '2',
252
+ 'description' => __( 'Choose 2 rows to show two posts in a single slide.', $text_domain ),
253
+ )
254
+ ),
255
+ array(
256
+ 'name' => 'loop',
257
+ 'callback' => 'select',
258
+ 'label' => __( 'Loop Type', $text_domain ),
259
+ 'options' => array(
260
+ array(
261
+ 'label' => __( 'Rewind', $text_domain ),
262
+ 'value' => 'rewind'
263
+ ),
264
+ array(
265
+ 'label' => __( 'Infinity', $text_domain ),
266
+ 'value' => 'infinity'
267
+ )
268
+ ),
269
+ 'default' => 'rewind',
270
+ 'shortcode' => array(
271
+ 'example' => 'infinity',
272
+ 'description' => __( 'What happens when the last slide is reached.', $text_domain ),
273
+ )
274
+ ),
275
+ array(
276
+ 'name' => 'arrows',
277
+ 'callback' => 'checkbox',
278
+ 'label' => __( 'Show Navigation Arrows', $text_domain ),
279
+ 'default' => true,
280
+ 'shortcode' => array(
281
+ 'example' => 'false',
282
+ 'description' => __( 'Show arrows on the sides to navigate posts.', $text_domain ),
283
+ )
284
+ ),
285
+ array(
286
+ 'name' => 'pag',
287
+ 'callback' => 'checkbox',
288
+ 'label' => __( 'Show Pagination', $text_domain ),
289
+ 'default' => true,
290
+ 'shortcode' => array(
291
+ 'example' => 'false',
292
+ 'description' => __( 'Show dots below carousel for an ordinal indication of which slide is being shown.', $text_domain ),
293
+ )
294
+ ),
295
+ array(
296
+ 'name' => 'autoplay',
297
+ 'callback' => 'checkbox',
298
+ 'label' => __( 'Enable Autoplay', $text_domain ),
299
+ 'default' => false,
300
+ 'shortcode' => array(
301
+ 'example' => 'true',
302
+ 'description' => __( 'Whether or not to change slides automatically on an interval.', $text_domain ),
303
+ )
304
+ ),
305
+ array(
306
+ 'name' => 'time',
307
+ 'callback' => 'text',
308
+ 'label' => __( 'Interval Time', $text_domain ),
309
+ 'default' => 5000,
310
+ 'shortcode' => array(
311
+ 'example' => '3000',
312
+ 'description' => __( 'Duration in milliseconds before the slide changes.', $text_domain ),
313
+ )
314
+ ),
315
+ )
316
+ ),
317
+
318
+ );
319
+ $admin->set_feed_layouts( $layouts );
320
+
321
+ $display_your_feed_table_headings = array(
322
+ array(
323
+ 'slug' => 'configure',
324
+ 'label' => __( 'Configure Options', SBY_TEXT_DOMAIN ),
325
+ ),
326
+ array(
327
+ 'slug' => 'customize',
328
+ 'label' => __( 'Customize Options', SBY_TEXT_DOMAIN ),
329
+ ),
330
+ array(
331
+ 'slug' => 'layout',
332
+ 'label' => __( 'Layout Options', SBY_TEXT_DOMAIN ),
333
+ ),
334
+ array(
335
+ 'slug' => 'experience',
336
+ 'label' => __( 'Video Experience Options', SBY_TEXT_DOMAIN ),
337
+ ),
338
+ array(
339
+ 'slug' => 'header',
340
+ 'label' => __( 'Header Options', SBY_TEXT_DOMAIN ),
341
+ ),
342
+ array(
343
+ 'slug' => 'button',
344
+ 'label' => __( '"Load More" Button Options', SBY_TEXT_DOMAIN ),
345
+ ),
346
+ array(
347
+ 'slug' => 'subscribe',
348
+ 'label' => __( '"Subscribe" Button Options', SBY_TEXT_DOMAIN ),
349
+ )
350
+ );
351
+ $admin->set_display_table_sections( $display_your_feed_table_headings );
352
+
353
+ $admin->init();
354
+ }
355
+
356
+ function sby_admin_style() {
357
+ wp_enqueue_style( SBY_SLUG . '_admin_notices_css', SBY_PLUGIN_URL . 'css/sby-notices.css', array(), SBYVER );
358
+ if ( ! sby_is_admin_page() ) {
359
+ return;
360
+ }
361
+ wp_enqueue_style( SBY_SLUG . '_admin_css', SBY_PLUGIN_URL . 'css/admin.css', array(), SBYVER );
362
+ wp_enqueue_style( 'sb_font_awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' );
363
+ wp_enqueue_style( 'wp-color-picker' );
364
+ }
365
+ add_action( 'admin_enqueue_scripts', 'sby_admin_style' );
366
+
367
+ function sby_admin_scripts() {
368
+ if ( ! sby_is_admin_page() ) {
369
+ return;
370
+ }
371
+ wp_enqueue_script( SBY_SLUG . '_admin_js', SBY_PLUGIN_URL . 'js/admin.js', array(), SBYVER );
372
+ wp_localize_script( SBY_SLUG . '_admin_js', 'sbspf', array(
373
+ 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
374
+ 'nonce' => wp_create_nonce( 'sbspf_nonce' )
375
+ )
376
+ );
377
+ wp_enqueue_script('wp-color-picker' );
378
+ }
379
+ add_action( 'admin_enqueue_scripts', 'sby_admin_scripts' );
380
+
381
+ function sby_is_admin_page() {
382
+ if ( ! isset( $_GET['page'] ) ) {
383
+ return false;
384
+ } elseif ( strpos( sanitize_text_field( $_GET['page'] ), SBY_SLUG ) !== false ) {
385
+ return true;
386
+ }
387
+ return false;
388
+ }
389
+
390
+ function sby_admin_icon( $icon, $class = '' ) {
391
+ $class = ! empty( $class ) ? ' ' . $class : '';
392
+ if ( $icon === 'question-circle' ) {
393
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="question-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-question-circle fa-w-16'.$class.'"><path fill="currentColor" d="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z" class=""></path></svg>';
394
+ } elseif ( $icon === 'info-circle' ) {
395
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="info-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-info-circle fa-w-16'.$class.'"><path fill="currentColor" d="M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z" class=""></path></svg>';
396
+ } elseif ( $icon === 'life-ring' ) {
397
+ return '<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="life-ring" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-life-ring fa-w-16'.$class.'"><path fill="currentColor" d="M256 504c136.967 0 248-111.033 248-248S392.967 8 256 8 8 119.033 8 256s111.033 248 248 248zm-103.398-76.72l53.411-53.411c31.806 13.506 68.128 13.522 99.974 0l53.411 53.411c-63.217 38.319-143.579 38.319-206.796 0zM336 256c0 44.112-35.888 80-80 80s-80-35.888-80-80 35.888-80 80-80 80 35.888 80 80zm91.28 103.398l-53.411-53.411c13.505-31.806 13.522-68.128 0-99.974l53.411-53.411c38.319 63.217 38.319 143.579 0 206.796zM359.397 84.72l-53.411 53.411c-31.806-13.505-68.128-13.522-99.973 0L152.602 84.72c63.217-38.319 143.579-38.319 206.795 0zM84.72 152.602l53.411 53.411c-13.506 31.806-13.522 68.128 0 99.974L84.72 359.398c-38.319-63.217-38.319-143.579 0-206.796z" class=""></path></svg>';
398
+ } elseif ( $icon === 'envelope' ) {
399
+ return '<svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="envelope" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-envelope fa-w-16'.$class.'"><path fill="currentColor" d="M464 64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V112c0-26.51-21.49-48-48-48zm0 48v40.805c-22.422 18.259-58.168 46.651-134.587 106.49-16.841 13.247-50.201 45.072-73.413 44.701-23.208.375-56.579-31.459-73.413-44.701C106.18 199.465 70.425 171.067 48 152.805V112h416zM48 400V214.398c22.914 18.251 55.409 43.862 104.938 82.646 21.857 17.205 60.134 55.186 103.062 54.955 42.717.231 80.509-37.199 103.053-54.947 49.528-38.783 82.032-64.401 104.947-82.653V400H48z" class=""></path></svg>';
400
+ } elseif ( $icon === 'chevron-right' ) {
401
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="chevron-circle-right" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-chevron-circle-right fa-w-16'.$class.'"><path fill="currentColor" d="M256 8c137 0 248 111 248 248S393 504 256 504 8 393 8 256 119 8 256 8zm113.9 231L234.4 103.5c-9.4-9.4-24.6-9.4-33.9 0l-17 17c-9.4 9.4-9.4 24.6 0 33.9L285.1 256 183.5 357.6c-9.4 9.4-9.4 24.6 0 33.9l17 17c9.4 9.4 24.6 9.4 33.9 0L369.9 273c9.4-9.4 9.4-24.6 0-34z" class=""></path></svg>';
402
+ } elseif ( $icon === 'rocket' ) {
403
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="rocket" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-rocket fa-w-16'.$class.'"><path fill="currentColor" d="M505.05 19.1a15.89 15.89 0 0 0-12.2-12.2C460.65 0 435.46 0 410.36 0c-103.2 0-165.1 55.2-211.29 128H94.87A48 48 0 0 0 52 154.49l-49.42 98.8A24 24 0 0 0 24.07 288h103.77l-22.47 22.47a32 32 0 0 0 0 45.25l50.9 50.91a32 32 0 0 0 45.26 0L224 384.16V488a24 24 0 0 0 34.7 21.49l98.7-49.39a47.91 47.91 0 0 0 26.5-42.9V312.79c72.59-46.3 128-108.4 128-211.09.1-25.2.1-50.4-6.85-82.6zM384 168a40 40 0 1 1 40-40 40 40 0 0 1-40 40z" class=""></path></svg>';
404
+ } elseif ( $icon === 'minus-circle' ) {
405
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="minus-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-minus-circle fa-w-16'.$class.'"><path fill="currentColor" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zM124 296c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6 0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H124z" class=""></path></svg>';
406
+ } elseif ( $icon === 'times' ) {
407
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="times" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512" class="svg-inline--fa fa-times fa-w-11'.$class.'"><path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z" class=""></path></svg>';
408
+ } elseif ( $icon === 'cog' ) {
409
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="cog" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-cog fa-w-16'.$class.'"><path fill="currentColor" d="M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z" class=""></path></svg>';
410
+ } elseif ( $icon === 'ellipsis' ) {
411
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="ellipsis-h" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-ellipsis-h fa-w-16'.$class.'"><path fill="currentColor" d="M328 256c0 39.8-32.2 72-72 72s-72-32.2-72-72 32.2-72 72-72 72 32.2 72 72zm104-72c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72zm-352 0c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72z" class=""></path></svg>';
412
+ } else {
413
+ sby_icon( $icon );
414
+ }
415
+ }
416
+
417
+ function sby_delete_connected_account() {
418
+ if ( ! isset( $_POST['sbspf_nonce'] ) || ! isset( $_POST['account_id']) ) return;
419
+ $nonce = $_POST['sbspf_nonce'];
420
+ if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
421
+ die ( 'You did not do this the right way!' );
422
+ }
423
+
424
+ global $sby_settings;
425
+
426
+ $account_id = sanitize_text_field( $_POST['account_id'] );
427
+ $to_save = array();
428
+
429
+ foreach ( $sby_settings['connected_accounts'] as $connected_account ) {
430
+ if ( (string)$connected_account['channel_id'] !== (string)$account_id ) {
431
+ $to_save[ $connected_account['channel_id'] ] = $connected_account;
432
+ }
433
+ }
434
+
435
+ $sby_settings['connected_accounts'] = $to_save;
436
+ update_option( 'sby_settings', $sby_settings );
437
+
438
+ echo wp_json_encode( array( 'success' => true ) );
439
+
440
+ die();
441
+ }
442
+ add_action( 'wp_ajax_sby_ca_after_remove_clicked', 'sby_delete_connected_account' );
443
+
444
+ function sby_process_access_token() {
445
+ if ( ! isset( $_POST['sbspf_nonce'] ) || ! isset( $_POST['sby_access_token'] ) ) return;
446
+ $nonce = $_POST['sbspf_nonce'];
447
+ if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
448
+ die ( 'You did not do this the right way!' );
449
+ }
450
+
451
+ $account = sby_attempt_connection();
452
+
453
+ if ( $account ) {
454
+ global $sby_settings;
455
+
456
+ $options = $sby_settings;
457
+ $username = $account['username'] ? $account['username'] : $account['channel_id'];
458
+ if ( isset( $account['local_avatar'] ) && $account['local_avatar'] && isset( $options['favorlocal'] ) && $options['favorlocal' ] === 'on' ) {
459
+ $upload = wp_upload_dir();
460
+ $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBY_UPLOADS_NAME );
461
+ $profile_picture = '<img class="sbspf_ca_avatar" src="'.$resized_url . $account['username'].'.jpg" />'; //Could add placeholder avatar image
462
+ } else {
463
+ $profile_picture = $account['profile_picture'] ? '<img class="sbspf_ca_avatar" src="'.$account['profile_picture'].'" />' : ''; //Could add placeholder avatar image
464
+ }
465
+
466
+ $text_domain = SBY_TEXT_DOMAIN;
467
+ $slug = SBY_SLUG;
468
+ ob_start();
469
+ include trailingslashit( SBY_PLUGIN_DIR ) . 'inc/admin/templates/single-connected-account.php';
470
+ if ( sby_notice_not_dismissed() ) {
471
+ include trailingslashit( SBY_PLUGIN_DIR ) . 'inc/admin/templates/modal.php';
472
+ echo '<span class="sby_account_just_added"></span>';
473
+ }
474
+
475
+ $html = ob_get_contents();
476
+ ob_get_clean();
477
+
478
+ $return = array(
479
+ 'account_id' => $account['channel_id'],
480
+ 'html' => $html
481
+ );
482
+ } else {
483
+ $return = array(
484
+ 'error' => __( 'Could not connect your account. Please check to make sure this is a valid access token for the Smash Balloon YouTube App.'),
485
+ 'html' => ''
486
+ );
487
+ }
488
+
489
+ echo wp_json_encode( $return );
490
+
491
+ die();
492
+ }
493
+ add_action( 'wp_ajax_sby_process_access_token', 'sby_process_access_token' );
494
+
495
+ function sby_delete_wp_posts() {
496
+ if ( ! isset( $_POST['sbspf_nonce'] ) ) return;
497
+ $nonce = $_POST['sbspf_nonce'];
498
+ if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
499
+ die ( 'You did not do this the right way!' );
500
+ }
501
+
502
+ sby_clear_wp_posts();
503
+
504
+ echo '{}';
505
+
506
+ die();
507
+ }
508
+ add_action( 'wp_ajax_sby_delete_wp_posts', 'sby_delete_wp_posts' );
509
+
510
+ function sby_attempt_connection() {
511
+ if ( ! current_user_can( 'manage_youtube_feed_options' ) ) {
512
+ return false;
513
+ }
514
+ if ( isset( $_GET['sby_access_token'] ) ) {
515
+ $access_token = sanitize_text_field( urldecode( $_GET['sby_access_token'] ) );
516
+ $refresh_token = '';
517
+ } else {
518
+ $access_token = sanitize_text_field( $_POST['sby_access_token'] );
519
+ $refresh_token = '';
520
+ }
521
+
522
+ $account_info = array(
523
+ 'access_token' => $access_token,
524
+ 'refresh_token' => $refresh_token
525
+ );
526
+ $sby_api_connect = new SBY_API_Connect( $account_info, 'tokeninfo' );
527
+ $sby_api_connect->connect();
528
+
529
+ $data = $sby_api_connect->get_data();
530
+
531
+ if ( isset( $data['audience'] ) ) {
532
+ $expires = $data['expires_in'] + time();
533
+ $sby_api_connect = new SBY_API_Connect( $account_info, 'channels' );
534
+ $sby_api_connect->connect();
535
+ $data = $sby_api_connect->get_data();
536
+
537
+ if ( isset( $data['items'] ) ) {
538
+ $account_info['username'] = $data['items'][0]['snippet']['title'];
539
+ $account_info['channel_id'] = $data['items'][0]['id'];
540
+ $account_info['profile_picture'] = $data['items'][0]['snippet']['thumbnails']['default']['url'];
541
+ $account_info['privacy'] = '';
542
+ $account_info['expires'] = $expires;
543
+ //privacyStatus
544
+ SBY_Admin::connect_account( $account_info );
545
+
546
+ return $account_info;
547
+ } else {
548
+ $account_info['username'] = '(No Channel)';
549
+ $account_info['channel_id'] = '';
550
+ $account_info['profile_picture'] = '';
551
+ $account_info['privacy'] = '';
552
+ $account_info['expires'] = $expires;
553
+ //privacyStatus
554
+ SBY_Admin::connect_account( $account_info );
555
+
556
+ return $account_info;
557
+ }
558
+ }
559
+ return false;
560
+ }
561
+
562
+ function sbspf_account_search() {
563
+ if ( ! isset( $_POST['sbspf_nonce'] ) || ! isset( $_POST['term']) ) return;
564
+ $nonce = $_POST['sbspf_nonce'];
565
+ if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
566
+ die ( 'You did not do this the right way!' );
567
+ }
568
+
569
+ global $sby_settings;
570
+
571
+ $term = sanitize_text_field( $_POST['term'] );
572
+ $params = array(
573
+ 'q' => $term,
574
+ 'type' => 'channel'
575
+ );
576
+
577
+ $connected_account_for_term = array();
578
+ foreach ( $sby_settings['connected_accounts'] as $connected_account ) {
579
+ $connected_account_for_term = $connected_account;
580
+ }
581
+ if ( $connected_account_for_term['expires'] < time() + 5 ) {
582
+ $new_token_data = SBY_API_Connect::refresh_token( sby_get_account_bottom(), $connected_account_for_term['refresh_token'], sby_get_account_top() );
583
+
584
+ if ( isset( $new_token_data['access_token'] ) ) {
585
+ $connected_account_for_term['access_token'] = $new_token_data['access_token'];
586
+ $connected_accounts_for_feed[ $term ]['access_token'] = $new_token_data['access_token'];
587
+ $connected_account_for_term['expires'] = $new_token_data['expires_in'] + time();
588
+ $connected_accounts_for_feed[ $term ]['expires'] = $new_token_data['expires_in'] + time();
589
+
590
+ sby_update_or_connect_account( $connected_account_for_term );
591
+
592
+ }
593
+ }
594
+
595
+ $search = new SBY_API_Connect( $connected_account_for_term, 'search', $params );
596
+
597
+ $search->connect();
598
+
599
+
600
+ echo wp_json_encode( $search->get_data() );
601
+
602
+ die();
603
+ }
604
+ add_action( 'wp_ajax_sbspf_account_search', 'sbspf_account_search' );
605
+
606
+ function sby_reset_cron( $settings ) {
607
+ $sbi_caching_type = isset( $settings['caching_type'] ) ? $settings['caching_type'] : '';
608
+ $sbi_cache_cron_interval = isset( $settings['cache_cron_interval'] ) ? $settings['cache_cron_interval'] : '';
609
+ $sbi_cache_cron_time = isset( $settings['cache_cron_time'] ) ? $settings['cache_cron_time'] : '';
610
+ $sbi_cache_cron_am_pm = isset( $settings['cache_cron_am_pm'] ) ? $settings['cache_cron_am_pm'] : '';
611
+
612
+ if ( $sbi_caching_type === 'background' ) {
613
+ delete_option( 'sby_cron_report' );
614
+ SBY_Cron_Updater::start_cron_job( $sbi_cache_cron_interval, $sbi_cache_cron_time, $sbi_cache_cron_am_pm );
615
+ }
616
+ }
617
+ add_action( 'sby_settings_after_configure_save', 'sby_reset_cron', 10, 1 );
618
+
619
+ function sby_maybe_start_cron_clear_cache( $settings ) {
620
+ $sby_doing_cron_clear = isset( $settings['cronclear'] ) ? $settings['cronclear'] : false;
621
+
622
+ if ( $sby_doing_cron_clear ) {
623
+ wp_clear_scheduled_hook( 'sby_cron_job' );
624
+
625
+ wp_schedule_event( time(), 'hourly', 'sby_cron_job' );
626
+ }
627
+ }
628
+ add_action( 'sby_settings_after_customize_save', 'sby_maybe_start_cron_clear_cache', 10, 1 );
629
+
630
+ function sby_clear_wp_posts() {
631
+
632
+ global $wpdb;
633
+
634
+ $youtube_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type = '".SBY_CPT."';" );
635
+
636
+ $id_string = implode( ', ', $youtube_ids );
637
+ if ( ! empty( $id_string ) ) {
638
+ $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE post_id IN ($id_string);" );
639
+ $wpdb->query( "DELETE FROM $wpdb->posts WHERE post_type = '".SBY_CPT."';" );
640
+ }
641
+ }
642
+
643
+ /** Notices */
644
+
645
+ function sby_dismiss_at_warning_notice() {
646
+
647
+ update_user_meta( get_current_user_id(), 'sby_at_warning_notice', time() );
648
+
649
+ die();
650
+ }
651
+ add_action( 'wp_ajax_sby_dismiss_at_warning_notice', 'sby_dismiss_at_warning_notice' );
652
+
653
+ function sby_dismiss_connect_warning_notice() {
654
+
655
+ update_user_meta( get_current_user_id(), 'sby_connect_warning_notice', time() );
656
+
657
+ die();
658
+ }
659
+ add_action( 'wp_ajax_sby_dismiss_connect_warning_button', 'sby_dismiss_connect_warning_notice' );
660
+
661
+ function sby_notice_not_dismissed( $key = 'sby_at_warning_notice' ) {
662
+ $meta = get_user_meta( get_current_user_id(), $key, true );
663
+ return (int)$meta + DAY_IN_SECONDS < time();
664
+ }
665
+
666
+ function sby_access_token_warning_modal() {
667
+ if ( isset( $_GET['page'] ) && $_GET['page'] === SBY_SLUG && isset( $_GET['sby_access_token'] ) && sby_notice_not_dismissed() ) {
668
+ $text_domain = SBY_TEXT_DOMAIN;
669
+ include trailingslashit( SBY_PLUGIN_DIR ) . 'inc/admin/templates/modal.php';
670
+ echo '<span class="sby_account_just_added"></span>';
671
+ }
672
+
673
+ }
674
+ add_action( 'admin_footer', 'sby_access_token_warning_modal', 1 );
675
+
676
+ function sby_get_current_time() {
677
+ $current_time = time();
678
+
679
+ // where to do tests
680
+ //$current_time = strtotime( 'November 25, 2020' ) + 1;
681
+
682
+ return $current_time;
683
+ }
684
+
685
+ // generates the html for the admin notices
686
+ function sby_notices_html() {
687
+
688
+ //delete_transient( 'instagram_feed_rating_notice_waiting' );
689
+
690
+ //set_transient( 'instagram_feed_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS );
691
+ //update_option( 'sby_rating_notice', 'pending', false );
692
+
693
+
694
+ }
695
+ //add_action( 'admin_notices', 'sby_notices_html', 12 ); // priority 8 for Instagram, priority 10 for Facebook
696
+
697
+
698
+ function sby_lite_dismiss() {
699
+ if ( ! isset( $_POST['sbspf_nonce'] ) ) return;
700
+ $nonce = $_POST['sbspf_nonce'];
701
+ if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
702
+ die ( 'You did not do this the right way!' );
703
+ }
704
+
705
+ set_transient( 'youtube_feed_dismiss_lite', 'dismiss', 1 * WEEK_IN_SECONDS );
706
+
707
+ die();
708
+ }
709
+ add_action( 'wp_ajax_sby_lite_dismiss', 'sby_lite_dismiss' );
710
+
711
+ function sby_get_future_date( $month, $year, $week, $day, $direction ) {
712
+ if ( $direction > 0 ) {
713
+ $startday = 1;
714
+ } else {
715
+ $startday = date( 't', mktime(0, 0, 0, $month, 1, $year ) );
716
+ }
717
+
718
+ $start = mktime( 0, 0, 0, $month, $startday, $year );
719
+ $weekday = date( 'N', $start );
720
+
721
+ $offset = 0;
722
+ if ( $direction * $day >= $direction * $weekday ) {
723
+ $offset = -$direction * 7;
724
+ }
725
+
726
+ $offset += $direction * ($week * 7) + ($day - $weekday);
727
+ return mktime( 0, 0, 0, $month, $startday + $offset, $year );
728
+ }
729
+
730
+ function sby_admin_hide_unrelated_notices() {
731
+
732
+ // Bail if we're not on a Sby screen or page.
733
+ if ( ! sby_is_admin_page() ) {
734
+ return;
735
+ }
736
+
737
+ // Extra banned classes and callbacks from third-party plugins.
738
+ $blacklist = array(
739
+ 'classes' => array(),
740
+ 'callbacks' => array(
741
+ 'sbydb_admin_notice', // 'Database for Sby' plugin.
742
+ ),
743
+ );
744
+
745
+ global $wp_filter;
746
+
747
+ foreach ( array( 'user_admin_notices', 'admin_notices', 'all_admin_notices' ) as $notices_type ) {
748
+ if ( empty( $wp_filter[ $notices_type ]->callbacks ) || ! is_array( $wp_filter[ $notices_type ]->callbacks ) ) {
749
+ continue;
750
+ }
751
+ foreach ( $wp_filter[ $notices_type ]->callbacks as $priority => $hooks ) {
752
+ foreach ( $hooks as $name => $arr ) {
753
+ if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
754
+ unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
755
+ continue;
756
+ }
757
+ $class = ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) ? strtolower( get_class( $arr['function'][0] ) ) : '';
758
+ if (
759
+ ! empty( $class ) &&
760
+ strpos( $class, 'sby' ) !== false &&
761
+ ! in_array( $class, $blacklist['classes'], true )
762
+ ) {
763
+ continue;
764
+ }
765
+ if (
766
+ ! empty( $name ) && (
767
+ strpos( $name, 'sby' ) === false ||
768
+ in_array( $class, $blacklist['classes'], true ) ||
769
+ in_array( $name, $blacklist['callbacks'], true )
770
+ )
771
+ ) {
772
+ unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
773
+ }
774
+ }
775
+ }
776
+ }
777
+ }
778
  add_action( 'admin_print_scripts', 'sby_admin_hide_unrelated_notices' );
inc/admin/class-sbspf-admin.php CHANGED
@@ -1,1045 +1,1045 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- die( '-1' );
4
- }
5
-
6
- class SB_YOUTUBE_Admin {
7
-
8
- protected $vars;
9
-
10
- protected $base_path;
11
-
12
- protected $slug;
13
-
14
- protected $plugin_name;
15
-
16
- protected $capability;
17
-
18
- protected $tabs;
19
-
20
- protected $active_tab;
21
-
22
- protected $settings_sections;
23
-
24
- protected $display_your_feed_sections;
25
-
26
- protected $option_name;
27
-
28
- protected $pro_only;
29
-
30
- protected $types;
31
-
32
- protected $layouts;
33
-
34
- protected $false_fields;
35
-
36
- protected $textarea_fields;
37
-
38
- public function __construct( $vars, $base_path, $slug, $plugin_name, $capability, $icon, $position, $tabs, $settings, $active_tab = false, $option_name = 'sbspf_settings' ) {
39
- $this->vars = $vars;
40
- $this->base_path = $base_path;
41
- $this->slug = $slug;
42
- $this->plugin_name = $plugin_name;
43
- $this->capability = $capability;
44
- $this->icon = $icon;
45
- $this->position = $position;
46
-
47
- $this->tabs = $tabs;
48
-
49
- if ( $active_tab ) {
50
- $this->set_active_tab( $active_tab );
51
- } else {
52
- $this->set_active_tab( $tabs[0]['slug'] );
53
- }
54
- $this->settings = $settings;
55
- $this->option_name = $option_name;
56
- $this->pro_only = array();
57
- $this->false_fields = array();
58
- $this->textarea_fields = array();
59
- $this->display_your_feed_sections = array();
60
- }
61
-
62
- public function get_vars() {
63
- return $this->vars;
64
- }
65
-
66
- public function get_option_name() {
67
- return $this->option_name;
68
- }
69
-
70
- public function verify_post( $post ) {
71
- return wp_verify_nonce( $post[ $this->option_name . '_validate' ], $this->option_name . '_validate' );
72
- }
73
-
74
- public function hidden_fields_for_tab( $tab ) {
75
- wp_nonce_field( $this->get_option_name() . '_validate', $this->get_option_name() . '_validate', true, true );
76
- ?>
77
- <input type="hidden" name="<?php echo $this->get_option_name() . '_tab_marker'; ?>" value="<?php echo esc_attr( $tab ); ?>"/>
78
- <?php
79
- }
80
-
81
- public function init() {
82
- add_action( 'admin_menu', array( $this, 'create_menus' ) );
83
- add_action( 'admin_init', array( $this, 'settings_init' ) );
84
- add_action( 'admin_init', array( $this, 'additional_settings_init' ) );
85
-
86
- }
87
-
88
- public function settings_init() {
89
- $text_domain = $this->vars->text_domain();
90
- /**
91
- * Configure Tab
92
- */
93
- $args = array(
94
- 'id' => 'sbspf_types',
95
- 'tab' => 'configure',
96
- 'save_after' => 'true'
97
- );
98
- $this->add_settings_section( $args );
99
-
100
- /* Types */
101
- $args = array(
102
- 'name' => 'type',
103
- 'section' => 'sbspf_types',
104
- 'callback' => 'types',
105
- 'title' => '<label>' . __( 'Feed Type', $text_domain ) .'</label>',
106
- 'shortcode' => array(
107
- 'key' => 'type',
108
- 'example' => 'channel',
109
- 'description' => __( 'Type of feed to display', $text_domain ) . ' e.g. channel, playlist, search, favorites, live',
110
- 'display_section' => 'configure'
111
- ),
112
- 'types' => $this->types
113
- );
114
- $this->add_settings_field( $args );
115
-
116
- /* Cache */
117
- $args = array(
118
- 'name' => 'cache',
119
- 'section' => 'sbspf_types',
120
- 'callback' => 'cache',
121
- 'title' => __( 'Check for new posts', $text_domain )
122
- );
123
- $this->add_settings_field( $args );
124
-
125
- /**
126
- * Customize Tab
127
- */
128
- $args = array(
129
- 'title' => __( 'General', $text_domain ),
130
- 'id' => 'sbspf_general',
131
- 'tab' => 'customize',
132
- 'save_after' => 'true'
133
- );
134
- $this->add_settings_section( $args );
135
-
136
- /* Width and Height */
137
- $select_options = array(
138
- array(
139
- 'label' => '%',
140
- 'value' => '%'
141
- ),
142
- array(
143
- 'label' => 'px',
144
- 'value' => 'px'
145
- )
146
- );
147
-
148
- $args = array(
149
- 'name' => 'width',
150
- 'default' => '100',
151
- 'section' => 'sbspf_general',
152
- 'callback' => 'text',
153
- 'min' => 1,
154
- 'size' => 4,
155
- 'title' => __( 'Width of Feed', $text_domain ),
156
- 'shortcode' => array(
157
- 'key' => 'width',
158
- 'example' => '300px',
159
- 'description' => __( 'The width of your feed. Any number with a unit like "px" or "%".', $text_domain ),
160
- 'display_section' => 'customize'
161
- ),
162
- 'select_name' => 'widthunit',
163
- 'select_options' => $select_options,
164
- 'hidden' => array(
165
- 'callback' => 'checkbox',
166
- 'name' => 'width_responsive',
167
- 'label' => __( 'Set to be 100% width on mobile?', $text_domain ),
168
- 'before' => '<div id="sbspf_width_options">',
169
- 'after' => '</div>',
170
- 'tooltip_info' => __( 'If you set a width on the feed then this will be used on mobile as well as desktop. Check this setting to set the feed width to be 100% on mobile so that it is responsive.', $text_domain )
171
- ),
172
- );
173
- $this->add_settings_field( $args );
174
-
175
- $select_options = array(
176
- array(
177
- 'label' => '%',
178
- 'value' => '%'
179
- ),
180
- array(
181
- 'label' => 'px',
182
- 'value' => 'px'
183
- )
184
- );
185
- $args = array(
186
- 'name' => 'height',
187
- 'default' => '',
188
- 'section' => 'sbspf_general',
189
- 'callback' => 'text',
190
- 'min' => 1,
191
- 'size' => 4,
192
- 'title' => __( 'Height of Feed', $text_domain ),
193
- 'shortcode' => array(
194
- 'key' => 'height',
195
- 'example' => '500px',
196
- 'description' => __( 'The height of your feed. Any number with a unit like "px" or "em".', $text_domain ),
197
- 'display_section' => 'customize'
198
- ),
199
- 'select_name' => 'heightunit',
200
- 'select_options' => $select_options,
201
- );
202
- $this->add_settings_field( $args );
203
-
204
- $args = array(
205
- 'name' => 'background',
206
- 'default' => '',
207
- 'section' => 'sbspf_general',
208
- 'callback' => 'color',
209
- 'title' => __( 'Background Color', $text_domain ),
210
- 'shortcode' => array(
211
- 'key' => 'background',
212
- 'example' => '#f00',
213
- 'description' => __( 'Background color for the feed. Any hex color code.', $text_domain ),
214
- 'display_section' => 'customize'
215
- ),
216
- );
217
- $this->add_settings_field( $args );
218
-
219
- $args = array(
220
- 'title' => __( 'Layout', $text_domain ),
221
- 'id' => 'sbspf_layout',
222
- 'tab' => 'customize',
223
- 'save_after' => 'true'
224
- );
225
- $this->add_settings_section( $args );
226
-
227
- $args = array(
228
- 'name' => 'layout',
229
- 'section' => 'sbspf_layout',
230
- 'callback' => 'layout',
231
- 'title' => __( 'Layout Type', $text_domain ),
232
- 'layouts' => $this->layouts,
233
- 'shortcode' => array(
234
- 'key' => 'layout',
235
- 'example' => 'list',
236
- 'description' => __( 'How your posts are display visually.', $text_domain ),
237
- 'display_section' => 'layout'
238
- )
239
- );
240
- $this->add_settings_field( $args );
241
- }
242
-
243
- public function additional_settings_init() {
244
-
245
- }
246
-
247
- public function add_false_field( $name, $tab ) {
248
- $this->false_fields[ $tab ][] = $name;
249
- }
250
-
251
- public function get_false_fields( $tab ) {
252
- if ( isset( $this->false_fields[ $tab ] ) ) {
253
- return $this->false_fields[ $tab ];
254
- }
255
-
256
- return array();
257
- }
258
-
259
- public function add_textarea_field( $name, $tab ) {
260
- $this->textarea_fields[ $tab ][] = $name;
261
- }
262
-
263
- public function get_textarea_fields( $tab ) {
264
- if ( isset( $this->textarea_fields[ $tab ] ) ) {
265
- return $this->textarea_fields[ $tab ];
266
- }
267
-
268
- return array();
269
- }
270
-
271
- public function blank() {
272
-
273
- }
274
-
275
- public function add_settings_section( $args ) {
276
- $title = isset( $args['title'] ) ? $args['title'] : '';
277
- $callback = isset( $args['callback'] ) ? $args['callback'] : array( $this, 'blank' );
278
- add_settings_section(
279
- $args['id'],
280
- $title,
281
- $callback,
282
- $args['id']
283
- );
284
-
285
- $save_after = isset( $args['save_after'] ) ? $args['save_after'] : false;
286
- $pro = isset( $args['pro'] ) && ($args['pro'] !== false) ? $args['pro'] : false;
287
- $this->settings_sections[ $args['tab'] ][] = array(
288
- 'id' => $args['id'],
289
- 'save_after' => $save_after,
290
- 'pro' => $pro
291
-
292
- );
293
- }
294
-
295
- public function add_settings_field( $args ) {
296
- $title_after = '';
297
- $shortcode = false;
298
- if ( isset( $args['shortcode'] ) ) {
299
- $title_after = isset( $args['shortcode']['after'] ) ? $args['shortcode']['after'] : '';
300
- $shortcode = $args['shortcode'];
301
- }
302
-
303
- if ( $shortcode ) {
304
- $this->display_your_feed_sections[ $shortcode['display_section'] ]['settings'][] = $shortcode;
305
- if ( isset( $args['pro'] ) ) {
306
- $this->pro_only[] = $args['name'];
307
- }
308
- }
309
-
310
- if ( $args['callback'] === 'types' ) {
311
- $formatted_label = '<label for="' . $this->option_name . '_' . $args['name'] . '">' . $args['title'] .'</label>';
312
- $formatted_label .= '<code class="sbspf_shortcode">type'. "\n";
313
- foreach ( $args['types'] as $type ) {
314
- $shortcode = array(
315
- 'key' => $type['slug'],
316
- 'example' => $type['example'],
317
- 'description' => $type['description'],
318
- 'display_section' => 'configure'
319
- );
320
- $this->display_your_feed_sections[ $shortcode['display_section'] ]['settings'][] = $shortcode;
321
- if ( isset( $type['pro'] ) ) {
322
- $this->pro_only[] = $type['slug'];
323
- }
324
-
325
- $formatted_label .= 'Eg: type=' . $type['slug'] . '<br>';
326
- $formatted_label .= $type['slug'] . '="' . substr( $type['example'], 0, 14) . '"<br>';
327
-
328
- }
329
- $formatted_label .= '</code><br>';
330
-
331
- $title = $formatted_label;
332
- } else {
333
- $title = $this->format_title( $args['title'], $args['name'], $shortcode, $title_after );
334
- }
335
-
336
- if ( $args['callback'] === 'checkbox' || (isset( $args['falsefield'] ) && $args['falsefield'] === true) ) {
337
- $tab = 'none';
338
- foreach ( $this->settings_sections as $key => $settings_sections ) {
339
- foreach ( $settings_sections as $this_tab_sections ) {
340
- if ( $this_tab_sections['id'] === $args['section'] ) {
341
- $tab = $key;
342
- }
343
- }
344
-
345
- }
346
- $this->add_false_field( $args['name'], $tab );
347
- }
348
-
349
- if ( $args['callback'] === 'layout' || $args['callback'] === 'sub_option' ) {
350
- $tab = 'none';
351
- foreach ( $this->settings_sections as $key => $settings_sections ) {
352
- foreach ( $settings_sections as $this_tab_sections ) {
353
- if ( $this_tab_sections['id'] === $args['section'] ) {
354
- $tab = $key;
355
- }
356
- }
357
-
358
- }
359
- $sub_options = isset( $args['layouts'] ) ? $args['layouts'] : $args['sub_options'];
360
- foreach ( $sub_options as $sub_option ) {
361
- if ( isset( $sub_option['options'] ) ) {
362
- foreach( $sub_option['options'] as $sub_sub_option ) {
363
- if ( ! empty( $sub_sub_option['shortcode'] ) ) {
364
- $key = ! empty( $sub_sub_option['shortcode']['key'] ) ? $sub_sub_option['shortcode']['key'] : $sub_option['slug'] . $sub_sub_option['name'];
365
- $example = ! empty( $sub_sub_option['shortcode']['example'] ) ? $sub_sub_option['shortcode']['example'] : '';
366
- $description = ! empty( $sub_sub_option['shortcode']['description'] ) ? $sub_sub_option['shortcode']['description'] : '';
367
- $display_section = ! empty( $sub_sub_option['shortcode']['display_section'] ) ? $sub_sub_option['shortcode']['display_section'] : str_replace( 'sbspf_', '', $args['section'] );
368
- $sub_shortcode = array(
369
- 'key' => $key,
370
- 'example' => $example,
371
- 'description' => $description,
372
- 'display_section' => $display_section
373
- );
374
- if ( isset( $this->display_your_feed_sections[ $display_section ] ) ) {
375
- $this->display_your_feed_sections[ $display_section ]['settings'][] = $sub_shortcode;
376
- if ( isset( $sub_sub_option['pro'] ) ) {
377
- $this->pro_only[] = $key;
378
- }
379
- }
380
- }
381
- if ( $sub_sub_option['callback'] === 'checkbox' ) {
382
- $this->add_false_field( $sub_option['slug'] . $sub_sub_option['name'], $tab );
383
- }
384
- }
385
- }
386
- }
387
- }
388
-
389
- if ( $args['callback'] === 'textarea' ) {
390
- $tab = 'none';
391
- foreach ( $this->settings_sections as $key => $settings_sections ) {
392
- foreach ( $settings_sections as $this_tab_sections ) {
393
- if ( $this_tab_sections['id'] === $args['section'] ) {
394
- $tab = $key;
395
- }
396
- }
397
-
398
- }
399
- $this->add_textarea_field( $args['name'], $tab );
400
- }
401
-
402
- add_settings_field(
403
- $args['name'],
404
- $title,
405
- array( $this, $args['callback'] ),
406
- $args['section'],
407
- $args['section'],
408
- $args
409
- );
410
-
411
- if ( isset( $args['hidden'] ) ) {
412
- if ( $args['hidden']['callback'] === 'checkbox' ) {
413
- $tab = 'none';
414
- foreach ( $this->settings_sections as $key => $settings_sections ) {
415
- foreach ( $settings_sections as $this_tab_sections ) {
416
- if ( $this_tab_sections['id'] === $args['section'] ) {
417
- $tab = $key;
418
- }
419
- }
420
-
421
- }
422
- $this->add_false_field( $args['hidden']['name'], $tab );
423
- }
424
- }
425
- }
426
-
427
- public function set_feed_types( $types ) {
428
- $this->types = $types;
429
- }
430
-
431
- public function set_feed_layouts( $layouts ) {
432
- $this->layouts = $layouts;
433
- }
434
-
435
- public function set_display_table_sections( $headings ) {
436
- foreach ( $headings as $heading ) {
437
- $this->display_your_feed_sections[ $heading['slug'] ] = array(
438
- 'label' => $heading['label'],
439
- 'settings' => array()
440
- );
441
- }
442
- }
443
-
444
- public function checkbox( $args ) {
445
- $default = isset( $args['default'] ) ? $args['default'] : false;
446
- $selected = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default;
447
- $label = isset( $args['label'] ) ? $args['label'] : __( 'Yes' );
448
- $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text();
449
- $has_shortcode = isset( $args['has_shortcode'] ) && $args['has_shortcode'] && isset( $args['shortcode_example'] ) ? '1' : '';
450
- $pro_flag = isset( $args['pro'] ) ? ' <span class="sbspf_pro_only"></span>' : '';
451
- echo $pro_flag;
452
- ?>
453
- <input name="<?php echo $this->option_name .'['.esc_attr( $args['name'] ).']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>" class="sbspf_single_checkbox" type="checkbox"<?php if ( $selected ) echo ' checked'; ?>/>
454
- <label for="<?php echo $this->option_name . '_' . $args['name'] . $has_shortcode; ?>"><?php echo esc_html( $label ); ?></label><?php if ( $has_shortcode === '1' ) : ?><code class="sbspf_shortcode"> <?php echo $args['name'] . "\n"; ?>
455
- Eg: <?php echo $args['name']; ?>=<?php echo $args['shortcode_example']; ?></code><br><?php endif; ?>
456
- <?php if ( isset( $args['tooltip_info'] ) ) : ?>
457
- <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $tooltip_text; ?></a>
458
- <p class="sbspf_tooltip sbspf_more_info"><?php echo $args['tooltip_info']; ?></p>
459
- <?php
460
- endif;
461
- }
462
-
463
- public function multi_checkbox( $args ) {
464
- $default = isset( $args['default'] ) ? $args['default'] : false;
465
- $selection_array = isset( $this->settings[ $args['name'] ] ) ? (array)$this->settings[ $args['name'] ] : (array)$default;
466
- $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text();
467
- $index = 0;
468
- ?>
469
- <?php foreach ( $args['select_options'] as $select_option ) :
470
- $selected = in_array( $select_option['value'], $selection_array, true );
471
- $pro_only = (isset( $select_option['pro'] ) && $select_option['pro']) ? ' sbspf_pro_only' : '';
472
- $class = ! empty( $select_option['class'] ) ? ' ' . $select_option['class'] : '';
473
- ?>
474
- <div class="sbspf_multi_checkbox_option<?php echo $pro_only . $class; ?>">
475
- <input name="<?php echo $this->option_name .'['.esc_attr( $args['name'] ).'][]'; ?>" id="<?php echo $this->option_name . '_' . $args['name']. '_' . $index; ?>" value="<?php echo esc_attr( $select_option['value'] ); ?>" type="checkbox"<?php if ( $selected ) echo ' checked'; ?>/>
476
- <label for="<?php echo $this->option_name . '_' . $args['name'] . '_' . $index; ?>"><?php echo esc_html( $select_option['label'] ); ?></label>
477
- </div>
478
- <?php
479
- $index++;
480
- endforeach; ?>
481
-
482
- <?php if ( isset( $args['tooltip_info'] ) ) : ?>
483
- <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $tooltip_text; ?></a>
484
- <p class="sbspf_tooltip sbspf_more_info"><?php echo $args['tooltip_info']; ?></p>
485
- <?php
486
- endif;
487
- }
488
-
489
- public function text( $args ) {
490
- $default = isset( $args['default'] ) ? $args['default'] : '';
491
- $value = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default;
492
- $size = ( isset( $args['size'] ) ) ? ' size="'. $args['size'].'"' : '';
493
- $class = isset( $args['class'] ) ? ' class="'. esc_attr( $args['class'] ) . '"' : '';
494
-
495
- $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text();
496
- $pro_flag = isset( $args['pro'] ) ? ' <span class="sbspf_pro_only"></span>' : '';
497
- echo $pro_flag;
498
-
499
- if ( isset( $args['min'] ) ) :
500
- $min = ( isset( $args['min'] ) ) ? ' min="'. $args['min'].'"' : '';
501
- $max = ( isset( $args['max'] ) ) ? ' max="'. $args['max'].'"' : '';
502
- $step = ( isset( $args['step'] ) ) ? ' step="'. $args['step'].'"' : '';
503
- $class = isset( $args['class'] ) ? ' class="sbspf_number_field sbspf_size_' . $args['size'] . ' '. esc_attr( $args['class'] ) . '"' : ' class="sbspf_number_field sbspf_size_' . $args['size'] . '"';
504
- ?>
505
- <input name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>"<?php echo $class; ?> type="number"<?php echo $size; ?><?php echo $min; ?><?php echo $max; ?><?php echo $step; ?> value="<?php echo esc_attr( $value ); ?>" />
506
- <?php elseif ( isset( $args['color'] ) ) : ?>
507
- <input name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>" class="sbspf_colorpicker" type="text" value="#<?php echo esc_attr( str_replace('#', '', $value ) ); ?>" />
508
- <?php else: ?>
509
- <input name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>"<?php echo $class; ?> type="text" value="<?php echo esc_attr( stripslashes( $value ) ); ?>" />
510
- <?php endif; ?>
511
-
512
- <?php if ( isset( $args['select_options'] ) ) :
513
- $value = isset( $this->settings[ $args['select_name'] ] ) ? $this->settings[ $args['select_name'] ] : $args['select_options'][0]['value'];
514
- ?>
515
- <select name="<?php echo $this->option_name.'['.$args['select_name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['select_name']; ?>">
516
- <?php foreach ( $args['select_options'] as $select_option ) : ?>
517
- <option value="<?php echo esc_attr( $select_option['value'] ); ?>"<?php if ( (string)$select_option['value'] === (string)$value ) echo ' selected'; ?>><?php echo esc_html( $select_option['label'] ); ?></option>
518
- <?php endforeach; ?>
519
- </select>
520
- <?php endif; ?>
521
-
522
- <?php if ( isset( $args['hidden'] ) ) : ?>
523
-
524
- <?php
525
- if ( is_callable( array( $this, $args['hidden']['callback'] ) ) ){
526
- echo $args['hidden']['before'];
527
- call_user_func_array(
528
- array( $this, $args['hidden']['callback'] ),
529
- array( $args['hidden'] )
530
- );
531
- echo $args['hidden']['after'];
532
- }
533
- ?>
534
- <?php endif; ?>
535
-
536
- <?php if ( isset( $args['additional'] ) ) : ?>
537
- <?php echo $args['additional']; ?>
538
- <?php endif; ?>
539
-
540
- <?php if ( isset( $args['tooltip_info'] ) ) : ?>
541
- <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $tooltip_text; ?></a>
542
- <p class="sbspf_tooltip sbspf_more_info"><?php echo $args['tooltip_info']; ?></p>
543
- <?php
544
- endif;
545
- }
546
-
547
- public function select( $args ) {
548
- $default = isset( $args['default'] ) ? $args['default'] : $args['options'][0]['value'];
549
- $value = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default;
550
-
551
- if ( isset( $args['min'] ) && isset( $args['max'] ) && ((int)$args['min'] < (int)$args['max']) && empty( $args['options'] ) ) {
552
- $args['options'] = array();
553
- $i = (int)$args['min'];
554
-
555
- while ( $i <= (int)$args['max'] ) {
556
- $args['options'][] = array(
557
- 'label' => $i,
558
- 'value' => $i
559
- );
560
- $i++;
561
- }
562
- }
563
-
564
- $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text();
565
- $pro_class = isset( $args['pro'] ) ? ' class="sbspf_pro_only"' : '';
566
- ?>
567
- <select<?php echo $pro_class; ?> name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>">
568
- <?php foreach ( $args['options'] as $select_option ) : ?>
569
- <option value="<?php echo esc_attr( $select_option['value'] ); ?>"<?php if ( (string)$select_option['value'] === (string)$value ) echo ' selected'; ?>><?php echo esc_html( $select_option['label'] ); ?></option>
570
- <?php endforeach; ?>
571
- </select>
572
-
573
- <?php if ( isset( $args['additional'] ) ) : ?>
574
- <?php echo $args['additional']; ?>
575
- <?php endif; ?>
576
-
577
- <?php if ( isset( $args['tooltip_info'] ) ) : ?>
578
- <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $tooltip_text; ?></a>
579
- <p class="sbspf_tooltip sbspf_more_info"><?php echo $args['tooltip_info']; ?></p>
580
- <?php endif;
581
- }
582
-
583
- public function textarea( $args ) {
584
- $default = isset( $args['default'] ) ? $args['default'] : '';
585
- $value = isset( $this->settings[ $args['name'] ] ) ? stripslashes( $this->settings[ $args['name'] ] ) : $default;
586
- $pro_class = isset( $args['pro'] ) ? ' class="sbspf_pro_only"' : '';
587
-
588
- if ( isset( $args['tooltip_info'] ) ) : ?>
589
- <span><?php echo $args['tooltip_info']; ?></span><br>
590
- <?php endif; ?>
591
-
592
- <textarea<?php echo $pro_class; ?> name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>"rows="7"><?php echo $value; ?></textarea>
593
-
594
- <?php if ( isset( $args['note'] ) ) : ?>
595
- <br><span class="sbspf_note"><?php echo $args['note']; ?></span>
596
- <?php endif;
597
- }
598
-
599
- public function color( $args ) {
600
- $args['color'] = true;
601
- $this->text( $args );
602
- }
603
-
604
- public function types( $args ) {
605
- $type_selected = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $args['types'][0]['slug'];
606
-
607
- foreach ( $args['types'] as $type ) :
608
- $input_type = isset( $type['input_type'] ) ? $type['input_type'] : 'connected_account';
609
- $selected = ! empty( $this->settings[ $type['slug'] ] ) ? $this->settings[ $type['slug'] ] : $type['default'];
610
- if ( $input_type === 'connected_account' ) {
611
- $selected = isset( $this->settings[ $type['slug'] . '_ids' ] ) ? $this->settings[ $type['slug'] . '_ids' ] : array();
612
- }
613
- $on_select = isset( $type['onselect'] ) ? $type['onselect'] : false;
614
- $pro_class = isset( $type['pro'] ) ? ' sbspf_pro_only' : '';
615
- ?>
616
- <div class="sbspf_row sbspf_type_row<?php echo $pro_class; ?>" style="min-height: 29px;">
617
- <div class="sbspf_col sbspf_one">
618
- <input type="radio" name="<?php echo $this->option_name.'['.esc_attr( $args['name'] ).']'; ?>" class="sbspf_type_input" id="sbspf_type_<?php echo esc_attr( $type['slug'] ); ?>" value="<?php echo esc_attr( $type['slug'] ); ?>"<?php if ( $type_selected === $type['slug'] ) echo 'checked'; ?>>
619
- <label class="sbspf_radio_label" for="sbspf_type_<?php echo esc_attr( $type['slug'] ); ?>"><?php echo esc_html( $type['label'] ); ?>: <a class="sbspf_type_tooltip_link" href="JavaScript:void(0);"><i class="fa fa-question-circle" aria-hidden="true" style="margin-left: 2px;"></i></a></label>
620
- </div>
621
- <div class="sbspf_col sbspf_two">
622
- <?php if ( $input_type === 'text' ) :
623
- $placeholder = isset( $type['note'] ) ? ' placeholder="' . esc_attr( $type['note'] ). '"' : '';
624
- ?>
625
- <input name="<?php echo $this->option_name.'['.esc_attr( $type['slug'] ).']'; ?>" id="sbspf_<?php echo esc_attr( $type['slug'] ); ?>" type="text" value="<?php echo esc_attr( $selected ); ?>" size="45"<?php echo $placeholder; ?>>
626
- <?php else :
627
- $connected_accounts = $this->get_connected_accounts(); ?>
628
- <div class="sbspf_<?php echo esc_attr( $type['slug'] ); ?>_feed_ids_wrap">
629
- <?php foreach ( $connected_accounts as $connected_account ) : if ( in_array( $connected_account['channel_id'], $selected, true ) ) : ?>
630
- <div id="sbspf_<?php echo esc_attr( $type['slug'] ); ?>_feed_id_<?php echo esc_attr( $connected_account['channel_id'] ); ?>" class="sbspf_<?php echo esc_attr( $type['slug'] ); ?>_feed_account_wrap">
631
- <strong><?php echo esc_html( $connected_account['username'] ); ?></strong> <span>(<?php echo esc_attr( $connected_account['channel_id'] ); ?>)</span><input type="hidden" name="<?php echo $this->option_name.'['.esc_attr( $type['slug'] ).'_feed_ids][]'; ?>" value="<?php echo esc_attr( $connected_account['channel_id'] ); ?>">
632
- </div>
633
- <?php endif; endforeach; ?>
634
- </div>
635
- <?php if ( empty( $selected ) ) : ?>
636
- <p class="sbspf_no_accounts" style="margin-top: -3px; margin-right: 10px;"><?php _e( 'Connect an account above', $this->vars->text_domain() ); ?></p>
637
- <?php endif; ?>
638
-
639
- <?php endif; ?>
640
- <?php if ( $input_type !== 'text' && isset( $type['note'] ) ) : ?>
641
- <br><span class="sbspf_note"><?php echo $type['note']; ?></span>
642
- <?php endif; ?>
643
- </div>
644
- <?php if ( $on_select ) : ?>
645
- <div class="sbspf_onselect">
646
- <?php call_user_func_array( array( $this, $on_select ), array( $type ) ); ?>
647
- </div>
648
- <?php endif; ?>
649
-
650
- <div class="sbspf_tooltip sbspf_type_tooltip sbspf_more_info">
651
- <?php if ( ! empty( $type['tooltip'] ) ) : ?>
652
- <?php echo $type['tooltip']; ?>
653
- <?php endif; ?>
654
- </div>
655
-
656
-
657
-
658
- </div>
659
- <?php endforeach;
660
- }
661
-
662
- public function sub_option( $args ) {
663
- $value = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : 'related';
664
- $pro_flag = isset( $args['pro'] ) ? ' <span class="sbspf_pro_only"></span>' : '';
665
- echo $pro_flag;
666
- $cta_options = $args['sub_options'];
667
- ?>
668
- <?php if ( ! empty( $args['before'] ) ) {
669
- echo $args['before'];
670
- }?>
671
-
672
- <div class="sbspf_sub_options">
673
- <?php foreach ( $cta_options as $sub_option ) :
674
- $pro_class = isset( $sub_option['pro'] ) ? ' sbspf_pro_only' : '';
675
- ?>
676
- <div class="sbspf_sub_option_cell<?php echo esc_attr( $pro_class ); ?>">
677
- <input class="sbspf_sub_option_type" id="sbspf_sub_option_type_<?php echo esc_attr( $sub_option['slug'] ); ?>" name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" type="radio" value="<?php echo esc_attr( $sub_option['slug'] ); ?>"<?php if ( $sub_option['slug'] === $value ) echo ' checked'?>><label for="sbspf_sub_option_type_<?php echo esc_attr( $sub_option['slug'] ); ?>"><span class="sbspf_label"><?php echo $sub_option['label']; ?></span></label>
678
- </div>
679
- <?php endforeach; ?>
680
-
681
- <div class="sbspf_box_setting">
682
- <?php if ( isset( $cta_options ) ) : foreach ( $cta_options as $sub_option ) :
683
- $pro_class = isset( $sub_option['pro'] ) ? ' sbspf_pro_only' : '';
684
- ?>
685
- <div class="sbspf_sub_option_settings sbspf_sub_option_type_<?php echo esc_attr( $sub_option['slug'] ) . $pro_class; ?>">
686
-
687
- <div class="sbspf_sub_option_setting">
688
- <?php echo sby_admin_icon( 'info-circle', 'sbspf_small_svg' ); ?>&nbsp;&nbsp;&nbsp;<span class="sbspf_note" style="margin-left: 0;"><?php echo $sub_option['note']; ?></span>
689
- </div>
690
- <?php if ( ! empty( $sub_option['options'] ) ) : ?>
691
- <?php foreach ( $sub_option['options'] as $option ) :
692
- $option['name'] = $sub_option['slug'].$option['name'];
693
- ?>
694
- <div class="sbspf_sub_option_setting">
695
- <?php if ( $option['callback'] !== 'checkbox' ) :
696
- if ( isset( $option['shortcode'] ) ) : ?>
697
- <label title="<?php echo __( 'Click for shortcode option', $this->vars->text_domain() ); ?>"><?php echo $option['label']; ?></label><code class="sbspf_shortcode"> <?php echo $option['name'] . "\n"; ?>
698
- Eg: <?php echo $option['name']; ?>=<?php echo $option['shortcode']['example']; ?></code><br>
699
- <?php else: ?>
700
- <label><?php echo $option['label']; ?></label><br>
701
- <?php endif; ?>
702
- <?php else:
703
- $option['shortcode_example'] = $option['shortcode']['example'];
704
- $option['has_shortcode'] = true;
705
- endif; ?>
706
- <?php call_user_func_array( array( $this, $option['callback'] ), array( $option ) ); ?>
707
-
708
- </div>
709
-
710
- <?php endforeach; ?>
711
- <?php endif; ?>
712
-
713
- </div>
714
-
715
- <?php endforeach; endif; ?>
716
- </div>
717
- </div>
718
- <?php
719
- }
720
-
721
- public function cache( $args ) {
722
- $social_network = $this->vars->social_network();
723
- $type_selected = isset( $this->settings['caching_type'] ) ? $this->settings['caching_type'] : 'page';
724
- $caching_time = isset( $this->settings['caching_time'] ) ? $this->settings['caching_time'] : 1;
725
- $cache_time_unit_selected = isset( $this->settings['cache_time_unit'] ) ? $this->settings['cache_time_unit'] : 'hours';
726
- $cache_cron_interval_selected = isset( $this->settings['cache_cron_interval'] ) ? $this->settings['cache_cron_interval'] : '';
727
- $cache_cron_time = isset( $this->settings['cache_cron_time'] ) ? $this->settings['cache_cron_time'] : '';
728
- $cache_cron_am_pm = isset( $this->settings['cache_cron_am_pm'] ) ? $this->settings['cache_cron_am_pm'] : '';
729
-
730
- ?>
731
- <div class="sbspf_cache_settings_wrap">
732
- <div class="sbspf_row">
733
- <input type="radio" name="<?php echo $this->option_name.'[caching_type]'; ?>" class="sbspf_caching_type_input" id="sbspf_caching_type_page" value="page"<?php if ( $type_selected === 'page' ) echo ' checked'?>>
734
- <label class="sbspf_radio_label" for="sbspf_caching_type_page"><?php _e ( 'When the page loads', $this->vars->text_domain() ); ?></label>
735
- <a class="sbspf_tooltip_link" href="JavaScript:void(0);" style="position: relative; top: 2px;"><?php echo $this->default_tooltip_text() ?></a>
736
- <p class="sbspf_tooltip sbspf_more_info"><?php echo sprintf( __( "Your %s data is temporarily cached by the plugin in your WordPress database. There are two ways that you can set the plugin to check for new data:<br><br>
737
- <b>1. When the page loads</b><br>Selecting this option means that when the cache expires then the plugin will check %s for new posts the next time that the feed is loaded. You can choose how long this data should be cached for with a minimum time of 15 minutes. If you set the time to 60 minutes then the plugin will clear the cached data after that length of time, and the next time the page is viewed it will check for new data. <b>Tip:</b> If you're experiencing an issue with the plugin not updating automatically then try enabling the setting labeled <b>'Force cache to clear on interval'</b> which is located on the 'Customize' tab.<br><br>
738
- <b>2. In the background</b><br>Selecting this option means that the plugin will check for new data in the background so that the feed is updated behind the scenes. You can select at what time and how often the plugin should check for new data using the settings below. <b>Please note</b> that the plugin will initially check for data from Instagram when the page first loads, but then after that will check in the background on the schedule selected - unless the cache is cleared.", $this->vars->text_domain() ), $social_network, $social_network ); ?>
739
- </p>
740
- </div>
741
- <div class="sbspf_row sbspf-caching-page-options" style="display: none;">
742
- <?php _e ( 'Every', $this->vars->text_domain() ); ?>:
743
- <input name="<?php echo $this->option_name.'[caching_time]'; ?>" type="text" value="<?php echo esc_attr( $caching_time ); ?>" size="4">
744
- <select name="<?php echo $this->option_name.'[caching_time_unit]'; ?>">
745
- <option value="minutes"<?php if ( $cache_time_unit_selected === 'minutes' ) echo ' selected'?>><?php _e ( 'Minutes', $this->vars->text_domain() ); ?></option>
746
- <option value="hours"<?php if ( $cache_time_unit_selected === 'hours' ) echo ' selected'?>><?php _e ( 'Hours', $this->vars->text_domain() ); ?></option>
747
- <option value="days"<?php if ( $cache_time_unit_selected === 'days' ) echo ' selected'?>><?php _e ( 'Days', $this->vars->text_domain() ); ?></option>
748
- </select>
749
- <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php _e ( 'What does this mean?', $this->vars->text_domain() ); ?></a>
750
- <p class="sbspf_tooltip sbspf_more_info"><?php echo sprintf( __("Your %s posts are temporarily cached by the plugin in your WordPress database. You can choose how long the posts should be cached for. If you set the time to 1 hour then the plugin will clear the cache after that length of time and check %s for posts again.", $this->vars->text_domain() ), $social_network, $social_network ); ?></p>
751
- </div>
752
-
753
- <div class="sbspf_row">
754
- <input type="radio" name="<?php echo $this->option_name.'[caching_type]'; ?>" id="sbspf_caching_type_cron" class="sbspf_caching_type_input" value="background" <?php if ( $type_selected === 'background' ) echo ' checked'?>>
755
- <label class="sbspf_radio_label" for="sbspf_caching_type_cron"><?php _e ( 'In the background', $this->vars->text_domain() ); ?></label>
756
- </div>
757
- <div class="sbspf_row sbspf-caching-cron-options" style="display: block;">
758
-
759
- <select name="<?php echo $this->option_name.'[cache_cron_interval]'; ?>" id="sbspf_cache_cron_interval">
760
- <option value="30mins"<?php if ( $cache_cron_interval_selected === '30mins' ) echo ' selected'?>><?php _e ( 'Every 30 minutes', $this->vars->text_domain() ); ?></option>
761
- <option value="1hour"<?php if ( $cache_cron_interval_selected === '1hour' ) echo ' selected'?>><?php _e ( 'Every hour', $this->vars->text_domain() ); ?></option>
762
- <option value="12hours"<?php if ( $cache_cron_interval_selected === '12hours' ) echo ' selected'?>><?php _e ( 'Every 12 hours', $this->vars->text_domain() ); ?></option>
763
- <option value="24hours"<?php if ( $cache_cron_interval_selected === '24hours' ) echo ' selected'?>><?php _e ( 'Every 24 hours', $this->vars->text_domain() ); ?></option>
764
- </select>
765
-
766
- <div id="sbspf-caching-time-settings" style="">
767
- <?php _e ( 'at', $this->vars->text_domain() ); ?>
768
- <select name="<?php echo $this->option_name.'[cache_cron_time]'; ?>" style="width: 80px">
769
- <option value="1"<?php if ( (int)$cache_cron_time === 1 ) echo ' selected'?>>1:00</option>
770
- <option value="2"<?php if ( (int)$cache_cron_time === 2 ) echo ' selected'?>>2:00</option>
771
- <option value="3"<?php if ( (int)$cache_cron_time === 3 ) echo ' selected'?>>3:00</option>
772
- <option value="4"<?php if ( (int)$cache_cron_time === 4 ) echo ' selected'?>>4:00</option>
773
- <option value="5"<?php if ( (int)$cache_cron_time === 5 ) echo ' selected'?>>5:00</option>
774
- <option value="6"<?php if ( (int)$cache_cron_time === 6 ) echo ' selected'?>>6:00</option>
775
- <option value="7"<?php if ( (int)$cache_cron_time === 7 ) echo ' selected'?>>7:00</option>
776
- <option value="8"<?php if ( (int)$cache_cron_time === 8 ) echo ' selected'?>>8:00</option>
777
- <option value="9"<?php if ( (int)$cache_cron_time === 9 ) echo ' selected'?>>9:00</option>
778
- <option value="10"<?php if ( (int)$cache_cron_time === 10 ) echo ' selected'?>>10:00</option>
779
- <option value="11"<?php if ( (int)$cache_cron_time === 11 ) echo ' selected'?>>11:00</option>
780
- <option value="0"<?php if ( (int)$cache_cron_time === 0 ) echo ' selected'?>>12:00</option>
781
- </select>
782
-
783
- <select name="<?php echo $this->option_name.'[cache_cron_am_pm]'; ?>" style="width: 50px">
784
- <option value="am"<?php if ( $cache_cron_am_pm === 'am' ) echo ' selected'?>><?php _e ( 'AM', $this->vars->text_domain() ); ?></option>
785
- <option value="pm"<?php if ( $cache_cron_am_pm === 'pm' ) echo ' selected'?>><?php _e ( 'PM', $this->vars->text_domain() ); ?></option>
786
- </select>
787
- </div>
788
-
789
- <?php
790
- if ( wp_next_scheduled( 'sbspf_feed_update' ) ) {
791
- $time_format = get_option( 'time_format' );
792
- if ( ! $time_format ) {
793
- $time_format = 'g:i a';
794
- }
795
- //
796
- $schedule = wp_get_schedule( 'sbspf_feed_update' );
797
- if ( $schedule == '30mins' ) $schedule = __( 'every 30 minutes', $this->vars->text_domain() );
798
- if ( $schedule == 'twicedaily' ) $schedule = __( 'every 12 hours', $this->vars->text_domain() );
799
- $sbspf_next_cron_event = wp_next_scheduled( 'sbspf_feed_update' );
800
- echo '<p class="sbspf-caching-sched-notice"><span><b>' . __( 'Next check', $this->vars->text_domain() ) . ': ' . date( $time_format, $sbspf_next_cron_event + sbspf_get_utc_offset() ) . ' (' . $schedule . ')</b> - ' . __( 'Note: Saving the settings on this page will clear the cache and reset this schedule', $this->vars->text_domain() ) . '</span></p>';
801
- } else {
802
- echo '<p style="font-size: 11px; color: #666;">' . __( 'Nothing currently scheduled', $this->vars->text_domain() ) . '</p>';
803
- }
804
- ?>
805
- </div>
806
- </div>
807
- <?php
808
- }
809
-
810
- public function layout( $args ) {
811
- $default = isset( $args['default'] ) ? $args['default'] : $args['layouts'][0]['slug'];
812
- $value = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default;
813
- ?>
814
- <div class="sbspf_layouts">
815
- <?php foreach ( $args['layouts'] as $layout ) :
816
- $pro_class = isset( $layout['pro'] ) ? ' sbspf_pro_only' : '';
817
- ?>
818
- <div class="sbspf_layout_cell<?php echo $pro_class; ?>">
819
- <input class="sbspf_layout_type" id="sbspf_layout_type_<?php echo esc_attr( $layout['slug'] ); ?>" name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" type="radio" value="<?php echo esc_attr( $layout['slug'] ); ?>"<?php if ( $layout['slug'] === $value ) echo ' checked'?>><label for="sbspf_layout_type_<?php echo esc_attr( $layout['slug'] ); ?>"><span class="sbspf_label"><?php echo $layout['label']; ?></span><img src="<?php echo esc_url( $this->vars->plugin_url() . $layout['image'] ); ?>"></label>
820
- </div>
821
- <?php endforeach; ?>
822
-
823
- <div class="sbspf_layout_options_wrap">
824
- <?php foreach ( $args['layouts'] as $layout ) :
825
- $pro_class = isset( $layout['pro'] ) ? ' sbspf_pro_only' : '';
826
- ?>
827
- <div class="sbspf_layout_settings sbspf_layout_type_<?php echo esc_attr( $layout['slug'] ) . $pro_class; ?>">
828
-
829
- <div class="sbspf_layout_setting">
830
- <?php echo sby_admin_icon( 'info-circle' ); ?>&nbsp;&nbsp;&nbsp;<span class="sbspf_note" style="margin-left: 0;"><?php echo $layout['note']; ?></span>
831
- </div>
832
- <?php if ( ! empty( $layout['options'] ) ) : ?>
833
- <?php foreach ( $layout['options'] as $option ) :
834
- $option['name'] = $layout['slug'].$option['name'];
835
- $option['shortcode']['example'] = isset( $option['shortcode']['example'] ) ? $option['shortcode']['example'] : $option['shortcode_example'];
836
-
837
- ?>
838
- <div class="sbspf_layout_setting">
839
- <?php if ( $option['callback'] !== 'checkbox' ) : ?>
840
- <label title="<?php echo __( 'Click for shortcode option', $this->vars->text_domain() ); ?>"><?php echo $option['label']; ?></label><code class="sbspf_shortcode"> <?php echo $option['name'] . "\n"; ?>
841
- Eg: <?php echo $option['name']; ?>=<?php echo $option['shortcode']['example']; ?></code><br>
842
- <?php else:
843
-
844
- $option['has_shortcode'] = true;
845
- endif; ?>
846
- <?php call_user_func_array( array( $this, $option['callback'] ), array( $option ) ); ?>
847
-
848
- </div>
849
-
850
- <?php endforeach; ?>
851
- <?php endif; ?>
852
-
853
- </div>
854
-
855
- <?php endforeach; ?>
856
- </div>
857
- </div>
858
- <?php
859
- }
860
-
861
- public function instructions( $args ) {
862
- ?>
863
- <div class="sbspf_instructions_wrap">
864
- <?php echo $args['instructions']?>
865
- </div>
866
- <?php
867
- }
868
-
869
- public function format_title( $label, $name, $shortcode_args = false, $after = '' ) {
870
- $formatted_label = '<label for="' . $this->option_name . '_' . $name . '">' . $label .'</label>';
871
- if ( $shortcode_args ) {
872
- $formatted_label .= '<code class="sbspf_shortcode"> ' . $shortcode_args['key'] . "\n";
873
- $formatted_label .= 'Eg: ' . $shortcode_args['key'] . '=' . $shortcode_args['example'] . '</code><br>';
874
- }
875
- $formatted_label .= $after;
876
-
877
- return $formatted_label;
878
- }
879
-
880
- public function validate_options( $input, $tab ) {
881
- $updated_options = get_option( $this->option_name, array() );
882
- $false_if_empty_keys = $this->get_false_fields( $tab );
883
- $textarea_keys = $this->get_textarea_fields( $tab );
884
-
885
- foreach ( $false_if_empty_keys as $false_key ) {
886
- $updated_options[ $false_key ] = false;
887
- }
888
-
889
- foreach ( $input as $key => $val ) {
890
- if ( in_array( $key, $false_if_empty_keys ) ) {
891
- $updated_options[ $key ] = ($val === 'on');
892
- } elseif ( in_array( $key, $textarea_keys ) ) {
893
- $updated_options[ $key ] = sanitize_textarea_field( $val );
894
- } elseif ( is_array( $val ) ) {
895
- $updated_options[ $key ] = array();
896
- foreach ( $val as $key2 => $val2 ) {
897
- $updated_options[ $key ][ $key2 ] = sanitize_text_field( $val2 );
898
- }
899
- } else {
900
- $updated_options[ $key ] = sanitize_text_field( $val );
901
- }
902
- }
903
-
904
-
905
- if ( $tab === 'configure' ) {
906
- do_action( $this->option_name . '_after_configure_save', $updated_options );
907
- } elseif ( $tab === 'customize' ) {
908
- do_action( $this->option_name . '_after_customize_save', $updated_options );
909
- }
910
-
911
- return $updated_options;
912
- }
913
-
914
-
915
- public function update_options( $new_settings ) {
916
- update_option( $this->get_option_name(), $new_settings );
917
- $this->settings = $new_settings;
918
- }
919
-
920
- public function get_sections( $tab ) {
921
- if ( isset( $this->settings_sections[ $tab ] ) ) {
922
- return $this->settings_sections[ $tab ];
923
- }
924
- return array();
925
- }
926
-
927
- public function create_menus() {
928
- add_menu_page(
929
- $this->plugin_name,
930
- $this->plugin_name,
931
- $this->capability,
932
- $this->slug,
933
- array( $this, 'create_options_page' ),
934
- $this->icon,
935
- $this->position
936
- );
937
-
938
- foreach ( $this->tabs as $tab ) {
939
- if ( $tab['slug'] !== 'configure' ) {
940
- $title = isset( $tab['title'] ) ? $tab['title'] : '';
941
- $capability = isset( $tab['capability'] ) ? $tab['capability'] : 'manage_options';
942
- $slug = isset( $tab['slug'] ) ? $tab['slug'] : '';
943
- $callback = isset( $tab['callback'] ) ? $tab['callback'] : array( $this, 'create_options_page' );
944
-
945
- add_submenu_page(
946
- $this->slug,
947
- $title,
948
- $title,
949
- $capability,
950
- $this->slug . '_' . $slug,
951
- $callback
952
- );
953
- }
954
- }
955
-
956
- $this->after_create_menues();
957
- }
958
-
959
- public function after_create_menues() {
960
-
961
- }
962
-
963
- public function set_active_tab( $active_tab ) {
964
- foreach ( $this->tabs as $tab ) {
965
- if ( $tab['slug'] === $active_tab ) {
966
- $this->active_tab = $tab['slug'];
967
- }
968
- }
969
- }
970
-
971
- public function get_tabs() {
972
- return $this->tabs;
973
- }
974
-
975
- public function get_active_tab() {
976
- return $this->active_tab;
977
- }
978
-
979
- public function get_slug() {
980
- return $this->slug;
981
- }
982
-
983
- public function get_plugin_name() {
984
- return $this->plugin_name;
985
- }
986
-
987
- public function get_path( $view ) {
988
- return trailingslashit( $this->base_path ) . $view . '.php';
989
- }
990
-
991
- public function create_options_page() {
992
- require_once trailingslashit( $this->base_path ) . 'main.php';
993
- }
994
-
995
- public function next_step() {
996
- $return = array();
997
- $i = 0;
998
- foreach ( $this->tabs as $tab ) {
999
- if ( $this->active_tab === $tab['slug'] && isset( $tab['next_step_instructions'] ) ) {
1000
- $next_tab_slug = isset( $this->tabs[ $i + 1 ]['slug'] ) ? $this->tabs[ $i + 1 ]['slug'] : $tab['slug'];
1001
- $return = array(
1002
- 'instructions' => $tab['next_step_instructions'],
1003
- 'next_tab' => $next_tab_slug
1004
- );
1005
- }
1006
- $i++;
1007
- }
1008
- return $return;
1009
- }
1010
-
1011
- public function get_connected_accounts() {
1012
- global $sbspf_settings;
1013
-
1014
- if ( isset( $sbspf_settings['connected_accounts'] ) ) {
1015
- return $sbspf_settings['connected_accounts'];
1016
- }
1017
- return array();
1018
- }
1019
-
1020
- public static function connect_account( $args ) {
1021
- global $sbspf_settings;
1022
-
1023
- // do connection
1024
-
1025
- // random fake data
1026
- $account_id = time();
1027
-
1028
- $sbspf_settings['connected_accounts'][ $account_id ] = array(
1029
- 'access_token' => 'at_' . str_shuffle( $account_id ),
1030
- 'channel_id' => $account_id,
1031
- 'username' => 'test' . $account_id,
1032
- 'is_valid' => true,
1033
- 'last_checked' => time(),
1034
- 'profile_picture' => $args['profile_picture']
1035
- );
1036
-
1037
- update_option( 'sbspf_settings', $sbspf_settings );
1038
-
1039
- return $sbspf_settings['connected_accounts'][ $account_id ];
1040
- }
1041
-
1042
- public function default_tooltip_text() {
1043
- return '<span class="screen-reader-text">' . __( 'What does this mean?', $this->vars->text_domain() ) . '</span>' . sby_admin_icon( 'question-circle' );
1044
- }
1045
- }
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die( '-1' );
4
+ }
5
+
6
+ class SB_YOUTUBE_Admin {
7
+
8
+ protected $vars;
9
+
10
+ protected $base_path;
11
+
12
+ protected $slug;
13
+
14
+ protected $plugin_name;
15
+
16
+ protected $capability;
17
+
18
+ protected $tabs;
19
+
20
+ protected $active_tab;
21
+
22
+ protected $settings_sections;
23
+
24
+ protected $display_your_feed_sections;
25
+
26
+ protected $option_name;
27
+
28
+ protected $pro_only;
29
+
30
+ protected $types;
31
+
32
+ protected $layouts;
33
+
34
+ protected $false_fields;
35
+
36
+ protected $textarea_fields;
37
+
38
+ public function __construct( $vars, $base_path, $slug, $plugin_name, $capability, $icon, $position, $tabs, $settings, $active_tab = false, $option_name = 'sbspf_settings' ) {
39
+ $this->vars = $vars;
40
+ $this->base_path = $base_path;
41
+ $this->slug = $slug;
42
+ $this->plugin_name = $plugin_name;
43
+ $this->capability = $capability;
44
+ $this->icon = $icon;
45
+ $this->position = $position;
46
+
47
+ $this->tabs = $tabs;
48
+
49
+ if ( $active_tab ) {
50
+ $this->set_active_tab( $active_tab );
51
+ } else {
52
+ $this->set_active_tab( $tabs[0]['slug'] );
53
+ }
54
+ $this->settings = $settings;
55
+ $this->option_name = $option_name;
56
+ $this->pro_only = array();
57
+ $this->false_fields = array();
58
+ $this->textarea_fields = array();
59
+ $this->display_your_feed_sections = array();
60
+ }
61
+
62
+ public function get_vars() {
63
+ return $this->vars;
64
+ }
65
+
66
+ public function get_option_name() {
67
+ return $this->option_name;
68
+ }
69
+
70
+ public function verify_post( $post ) {
71
+ return wp_verify_nonce( $post[ $this->option_name . '_validate' ], $this->option_name . '_validate' );
72
+ }
73
+
74
+ public function hidden_fields_for_tab( $tab ) {
75
+ wp_nonce_field( $this->get_option_name() . '_validate', $this->get_option_name() . '_validate', true, true );
76
+ ?>
77
+ <input type="hidden" name="<?php echo $this->get_option_name() . '_tab_marker'; ?>" value="<?php echo esc_attr( $tab ); ?>"/>
78
+ <?php
79
+ }
80
+
81
+ public function init() {
82
+ add_action( 'admin_menu', array( $this, 'create_menus' ) );
83
+ add_action( 'admin_init', array( $this, 'settings_init' ) );
84
+ add_action( 'admin_init', array( $this, 'additional_settings_init' ) );
85
+
86
+ }
87
+
88
+ public function settings_init() {
89
+ $text_domain = $this->vars->text_domain();
90
+ /**
91
+ * Configure Tab
92
+ */
93
+ $args = array(
94
+ 'id' => 'sbspf_types',
95
+ 'tab' => 'configure',
96
+ 'save_after' => 'true'
97
+ );
98
+ $this->add_settings_section( $args );
99
+
100
+ /* Types */
101
+ $args = array(
102
+ 'name' => 'type',
103
+ 'section' => 'sbspf_types',
104
+ 'callback' => 'types',
105
+ 'title' => '<label>' . __( 'Feed Type', $text_domain ) .'</label>',
106
+ 'shortcode' => array(
107
+ 'key' => 'type',
108
+ 'example' => 'channel',
109
+ 'description' => __( 'Type of feed to display', $text_domain ) . ' e.g. channel, playlist, search, favorites, live',
110
+ 'display_section' => 'configure'
111
+ ),
112
+ 'types' => $this->types
113
+ );
114
+ $this->add_settings_field( $args );
115
+
116
+ /* Cache */
117
+ $args = array(
118
+ 'name' => 'cache',
119
+ 'section' => 'sbspf_types',
120
+ 'callback' => 'cache',
121
+ 'title' => __( 'Check for new posts', $text_domain )
122
+ );
123
+ $this->add_settings_field( $args );
124
+
125
+ /**
126
+ * Customize Tab
127
+ */
128
+ $args = array(
129
+ 'title' => __( 'General', $text_domain ),
130
+ 'id' => 'sbspf_general',
131
+ 'tab' => 'customize',
132
+ 'save_after' => 'true'
133
+ );
134
+ $this->add_settings_section( $args );
135
+
136
+ /* Width and Height */
137
+ $select_options = array(
138
+ array(
139
+ 'label' => '%',
140
+ 'value' => '%'
141
+ ),
142
+ array(
143
+ 'label' => 'px',
144
+ 'value' => 'px'
145
+ )
146
+ );
147
+
148
+ $args = array(
149
+ 'name' => 'width',
150
+ 'default' => '100',
151
+ 'section' => 'sbspf_general',
152
+ 'callback' => 'text',
153
+ 'min' => 1,
154
+ 'size' => 4,
155
+ 'title' => __( 'Width of Feed', $text_domain ),
156
+ 'shortcode' => array(
157
+ 'key' => 'width',
158
+ 'example' => '300px',
159
+ 'description' => __( 'The width of your feed. Any number with a unit like "px" or "%".', $text_domain ),
160
+ 'display_section' => 'customize'
161
+ ),
162
+ 'select_name' => 'widthunit',
163
+ 'select_options' => $select_options,
164
+ 'hidden' => array(
165
+ 'callback' => 'checkbox',
166
+ 'name' => 'width_responsive',
167
+ 'label' => __( 'Set to be 100% width on mobile?', $text_domain ),
168
+ 'before' => '<div id="sbspf_width_options">',
169
+ 'after' => '</div>',
170
+ 'tooltip_info' => __( 'If you set a width on the feed then this will be used on mobile as well as desktop. Check this setting to set the feed width to be 100% on mobile so that it is responsive.', $text_domain )
171
+ ),
172
+ );
173
+ $this->add_settings_field( $args );
174
+
175
+ $select_options = array(
176
+ array(
177
+ 'label' => '%',
178
+ 'value' => '%'
179
+ ),
180
+ array(
181
+ 'label' => 'px',
182
+ 'value' => 'px'
183
+ )
184
+ );
185
+ $args = array(
186
+ 'name' => 'height',
187
+ 'default' => '',
188
+ 'section' => 'sbspf_general',
189
+ 'callback' => 'text',
190
+ 'min' => 1,
191
+ 'size' => 4,
192
+ 'title' => __( 'Height of Feed', $text_domain ),
193
+ 'shortcode' => array(
194
+ 'key' => 'height',
195
+ 'example' => '500px',
196
+ 'description' => __( 'The height of your feed. Any number with a unit like "px" or "em".', $text_domain ),
197
+ 'display_section' => 'customize'
198
+ ),
199
+ 'select_name' => 'heightunit',
200
+ 'select_options' => $select_options,
201
+ );
202
+ $this->add_settings_field( $args );
203
+
204
+ $args = array(
205
+ 'name' => 'background',
206
+ 'default' => '',
207
+ 'section' => 'sbspf_general',
208
+ 'callback' => 'color',
209
+ 'title' => __( 'Background Color', $text_domain ),
210
+ 'shortcode' => array(
211
+ 'key' => 'background',
212
+ 'example' => '#f00',
213
+ 'description' => __( 'Background color for the feed. Any hex color code.', $text_domain ),
214
+ 'display_section' => 'customize'
215
+ ),
216
+ );
217
+ $this->add_settings_field( $args );
218
+
219
+ $args = array(
220
+ 'title' => __( 'Layout', $text_domain ),
221
+ 'id' => 'sbspf_layout',
222
+ 'tab' => 'customize',
223
+ 'save_after' => 'true'
224
+ );
225
+ $this->add_settings_section( $args );
226
+
227
+ $args = array(
228
+ 'name' => 'layout',
229
+ 'section' => 'sbspf_layout',
230
+ 'callback' => 'layout',
231
+ 'title' => __( 'Layout Type', $text_domain ),
232
+ 'layouts' => $this->layouts,
233
+ 'shortcode' => array(
234
+ 'key' => 'layout',
235
+ 'example' => 'list',
236
+ 'description' => __( 'How your posts are display visually.', $text_domain ),
237
+ 'display_section' => 'layout'
238
+ )
239
+ );
240
+ $this->add_settings_field( $args );
241
+ }
242
+
243
+ public function additional_settings_init() {
244
+
245
+ }
246
+
247
+ public function add_false_field( $name, $tab ) {
248
+ $this->false_fields[ $tab ][] = $name;
249
+ }
250
+
251
+ public function get_false_fields( $tab ) {
252
+ if ( isset( $this->false_fields[ $tab ] ) ) {
253
+ return $this->false_fields[ $tab ];
254
+ }
255
+
256
+ return array();
257
+ }
258
+
259
+ public function add_textarea_field( $name, $tab ) {
260
+ $this->textarea_fields[ $tab ][] = $name;
261
+ }
262
+
263
+ public function get_textarea_fields( $tab ) {
264
+ if ( isset( $this->textarea_fields[ $tab ] ) ) {
265
+ return $this->textarea_fields[ $tab ];
266
+ }
267
+
268
+ return array();
269
+ }
270
+
271
+ public function blank() {
272
+
273
+ }
274
+
275
+ public function add_settings_section( $args ) {
276
+ $title = isset( $args['title'] ) ? $args['title'] : '';
277
+ $callback = isset( $args['callback'] ) ? $args['callback'] : array( $this, 'blank' );
278
+ add_settings_section(
279
+ $args['id'],
280
+ $title,
281
+ $callback,
282
+ $args['id']
283
+ );
284
+
285
+ $save_after = isset( $args['save_after'] ) ? $args['save_after'] : false;
286
+ $pro = isset( $args['pro'] ) && ($args['pro'] !== false) ? $args['pro'] : false;
287
+ $this->settings_sections[ $args['tab'] ][] = array(
288
+ 'id' => $args['id'],
289
+ 'save_after' => $save_after,
290
+ 'pro' => $pro
291
+
292
+ );
293
+ }
294
+
295
+ public function add_settings_field( $args ) {
296
+ $title_after = '';
297
+ $shortcode = false;
298
+ if ( isset( $args['shortcode'] ) ) {
299
+ $title_after = isset( $args['shortcode']['after'] ) ? $args['shortcode']['after'] : '';
300
+ $shortcode = $args['shortcode'];
301
+ }
302
+
303
+ if ( $shortcode ) {
304
+ $this->display_your_feed_sections[ $shortcode['display_section'] ]['settings'][] = $shortcode;
305
+ if ( isset( $args['pro'] ) ) {
306
+ $this->pro_only[] = $args['name'];
307
+ }
308
+ }
309
+
310
+ if ( $args['callback'] === 'types' ) {
311
+ $formatted_label = '<label for="' . $this->option_name . '_' . $args['name'] . '">' . $args['title'] .'</label>';
312
+ $formatted_label .= '<code class="sbspf_shortcode">type'. "\n";
313
+ foreach ( $args['types'] as $type ) {
314
+ $shortcode = array(
315
+ 'key' => $type['slug'],
316
+ 'example' => $type['example'],
317
+ 'description' => $type['description'],
318
+ 'display_section' => 'configure'
319
+ );
320
+ $this->display_your_feed_sections[ $shortcode['display_section'] ]['settings'][] = $shortcode;
321
+ if ( isset( $type['pro'] ) ) {
322
+ $this->pro_only[] = $type['slug'];
323
+ }
324
+
325
+ $formatted_label .= 'Eg: type=' . $type['slug'] . '<br>';
326
+ $formatted_label .= $type['slug'] . '="' . substr( $type['example'], 0, 14) . '"<br>';
327
+
328
+ }
329
+ $formatted_label .= '</code><br>';
330
+
331
+ $title = $formatted_label;
332
+ } else {
333
+ $title = $this->format_title( $args['title'], $args['name'], $shortcode, $title_after );
334
+ }
335
+
336
+ if ( $args['callback'] === 'checkbox' || (isset( $args['falsefield'] ) && $args['falsefield'] === true) ) {
337
+ $tab = 'none';
338
+ foreach ( $this->settings_sections as $key => $settings_sections ) {
339
+ foreach ( $settings_sections as $this_tab_sections ) {
340
+ if ( $this_tab_sections['id'] === $args['section'] ) {
341
+ $tab = $key;
342
+ }
343
+ }
344
+
345
+ }
346
+ $this->add_false_field( $args['name'], $tab );
347
+ }
348
+
349
+ if ( $args['callback'] === 'layout' || $args['callback'] === 'sub_option' ) {
350
+ $tab = 'none';
351
+ foreach ( $this->settings_sections as $key => $settings_sections ) {
352
+ foreach ( $settings_sections as $this_tab_sections ) {
353
+ if ( $this_tab_sections['id'] === $args['section'] ) {
354
+ $tab = $key;
355
+ }
356
+ }
357
+
358
+ }
359
+ $sub_options = isset( $args['layouts'] ) ? $args['layouts'] : $args['sub_options'];
360
+ foreach ( $sub_options as $sub_option ) {
361
+ if ( isset( $sub_option['options'] ) ) {
362
+ foreach( $sub_option['options'] as $sub_sub_option ) {
363
+ if ( ! empty( $sub_sub_option['shortcode'] ) ) {
364
+ $key = ! empty( $sub_sub_option['shortcode']['key'] ) ? $sub_sub_option['shortcode']['key'] : $sub_option['slug'] . $sub_sub_option['name'];
365
+ $example = ! empty( $sub_sub_option['shortcode']['example'] ) ? $sub_sub_option['shortcode']['example'] : '';
366
+ $description = ! empty( $sub_sub_option['shortcode']['description'] ) ? $sub_sub_option['shortcode']['description'] : '';
367
+ $display_section = ! empty( $sub_sub_option['shortcode']['display_section'] ) ? $sub_sub_option['shortcode']['display_section'] : str_replace( 'sbspf_', '', $args['section'] );
368
+ $sub_shortcode = array(
369
+ 'key' => $key,
370
+ 'example' => $example,
371
+ 'description' => $description,
372
+ 'display_section' => $display_section
373
+ );
374
+ if ( isset( $this->display_your_feed_sections[ $display_section ] ) ) {
375
+ $this->display_your_feed_sections[ $display_section ]['settings'][] = $sub_shortcode;
376
+ if ( isset( $sub_sub_option['pro'] ) ) {
377
+ $this->pro_only[] = $key;
378
+ }
379
+ }
380
+ }
381
+ if ( $sub_sub_option['callback'] === 'checkbox' ) {
382
+ $this->add_false_field( $sub_option['slug'] . $sub_sub_option['name'], $tab );
383
+ }
384
+ }
385
+ }
386
+ }
387
+ }
388
+
389
+ if ( $args['callback'] === 'textarea' ) {
390
+ $tab = 'none';
391
+ foreach ( $this->settings_sections as $key => $settings_sections ) {
392
+ foreach ( $settings_sections as $this_tab_sections ) {
393
+ if ( $this_tab_sections['id'] === $args['section'] ) {
394
+ $tab = $key;
395
+ }
396
+ }
397
+
398
+ }
399
+ $this->add_textarea_field( $args['name'], $tab );
400
+ }
401
+
402
+ add_settings_field(
403
+ $args['name'],
404
+ $title,
405
+ array( $this, $args['callback'] ),
406
+ $args['section'],
407
+ $args['section'],
408
+ $args
409
+ );
410
+
411
+ if ( isset( $args['hidden'] ) ) {
412
+ if ( $args['hidden']['callback'] === 'checkbox' ) {
413
+ $tab = 'none';
414
+ foreach ( $this->settings_sections as $key => $settings_sections ) {
415
+ foreach ( $settings_sections as $this_tab_sections ) {
416
+ if ( $this_tab_sections['id'] === $args['section'] ) {
417
+ $tab = $key;
418
+ }
419
+ }
420
+
421
+ }
422
+ $this->add_false_field( $args['hidden']['name'], $tab );
423
+ }
424
+ }
425
+ }
426
+
427
+ public function set_feed_types( $types ) {
428
+ $this->types = $types;
429
+ }
430
+
431
+ public function set_feed_layouts( $layouts ) {
432
+ $this->layouts = $layouts;
433
+ }
434
+
435
+ public function set_display_table_sections( $headings ) {
436
+ foreach ( $headings as $heading ) {
437
+ $this->display_your_feed_sections[ $heading['slug'] ] = array(
438
+ 'label' => $heading['label'],
439
+ 'settings' => array()
440
+ );
441
+ }
442
+ }
443
+
444
+ public function checkbox( $args ) {
445
+ $default = isset( $args['default'] ) ? $args['default'] : false;
446
+ $selected = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default;
447
+ $label = isset( $args['label'] ) ? $args['label'] : __( 'Yes' );
448
+ $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text();
449
+ $has_shortcode = isset( $args['has_shortcode'] ) && $args['has_shortcode'] && isset( $args['shortcode_example'] ) ? '1' : '';
450
+ $pro_flag = isset( $args['pro'] ) ? ' <span class="sbspf_pro_only"></span>' : '';
451
+ echo $pro_flag;
452
+ ?>
453
+ <input name="<?php echo $this->option_name .'['.esc_attr( $args['name'] ).']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>" class="sbspf_single_checkbox" type="checkbox"<?php if ( $selected ) echo ' checked'; ?>/>
454
+ <label for="<?php echo $this->option_name . '_' . $args['name'] . $has_shortcode; ?>"><?php echo esc_html( $label ); ?></label><?php if ( $has_shortcode === '1' ) : ?><code class="sbspf_shortcode"> <?php echo $args['name'] . "\n"; ?>
455
+ Eg: <?php echo $args['name']; ?>=<?php echo $args['shortcode_example']; ?></code><br><?php endif; ?>
456
+ <?php if ( isset( $args['tooltip_info'] ) ) : ?>
457
+ <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $tooltip_text; ?></a>
458
+ <p class="sbspf_tooltip sbspf_more_info"><?php echo $args['tooltip_info']; ?></p>
459
+ <?php
460
+ endif;
461
+ }
462
+
463
+ public function multi_checkbox( $args ) {
464
+ $default = isset( $args['default'] ) ? $args['default'] : false;
465
+ $selection_array = isset( $this->settings[ $args['name'] ] ) ? (array)$this->settings[ $args['name'] ] : (array)$default;
466
+ $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text();
467
+ $index = 0;
468
+ ?>
469
+ <?php foreach ( $args['select_options'] as $select_option ) :
470
+ $selected = in_array( $select_option['value'], $selection_array, true );
471
+ $pro_only = (isset( $select_option['pro'] ) && $select_option['pro']) ? ' sbspf_pro_only' : '';
472
+ $class = ! empty( $select_option['class'] ) ? ' ' . $select_option['class'] : '';
473
+ ?>
474
+ <div class="sbspf_multi_checkbox_option<?php echo $pro_only . $class; ?>">
475
+ <input name="<?php echo $this->option_name .'['.esc_attr( $args['name'] ).'][]'; ?>" id="<?php echo $this->option_name . '_' . $args['name']. '_' . $index; ?>" value="<?php echo esc_attr( $select_option['value'] ); ?>" type="checkbox"<?php if ( $selected ) echo ' checked'; ?>/>
476
+ <label for="<?php echo $this->option_name . '_' . $args['name'] . '_' . $index; ?>"><?php echo esc_html( $select_option['label'] ); ?></label>
477
+ </div>
478
+ <?php
479
+ $index++;
480
+ endforeach; ?>
481
+
482
+ <?php if ( isset( $args['tooltip_info'] ) ) : ?>
483
+ <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $tooltip_text; ?></a>
484
+ <p class="sbspf_tooltip sbspf_more_info"><?php echo $args['tooltip_info']; ?></p>
485
+ <?php
486
+ endif;
487
+ }
488
+
489
+ public function text( $args ) {
490
+ $default = isset( $args['default'] ) ? $args['default'] : '';
491
+ $value = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default;
492
+ $size = ( isset( $args['size'] ) ) ? ' size="'. $args['size'].'"' : '';
493
+ $class = isset( $args['class'] ) ? ' class="'. esc_attr( $args['class'] ) . '"' : '';
494
+
495
+ $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text();
496
+ $pro_flag = isset( $args['pro'] ) ? ' <span class="sbspf_pro_only"></span>' : '';
497
+ echo $pro_flag;
498
+
499
+ if ( isset( $args['min'] ) ) :
500
+ $min = ( isset( $args['min'] ) ) ? ' min="'. $args['min'].'"' : '';
501
+ $max = ( isset( $args['max'] ) ) ? ' max="'. $args['max'].'"' : '';
502
+ $step = ( isset( $args['step'] ) ) ? ' step="'. $args['step'].'"' : '';
503
+ $class = isset( $args['class'] ) ? ' class="sbspf_number_field sbspf_size_' . $args['size'] . ' '. esc_attr( $args['class'] ) . '"' : ' class="sbspf_number_field sbspf_size_' . $args['size'] . '"';
504
+ ?>
505
+ <input name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>"<?php echo $class; ?> type="number"<?php echo $size; ?><?php echo $min; ?><?php echo $max; ?><?php echo $step; ?> value="<?php echo esc_attr( $value ); ?>" />
506
+ <?php elseif ( isset( $args['color'] ) ) : ?>
507
+ <input name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>" class="sbspf_colorpicker" type="text" value="#<?php echo esc_attr( str_replace('#', '', $value ) ); ?>" />
508
+ <?php else: ?>
509
+ <input name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>"<?php echo $class; ?> type="text" value="<?php echo esc_attr( stripslashes( $value ) ); ?>" />
510
+ <?php endif; ?>
511
+
512
+ <?php if ( isset( $args['select_options'] ) ) :
513
+ $value = isset( $this->settings[ $args['select_name'] ] ) ? $this->settings[ $args['select_name'] ] : $args['select_options'][0]['value'];
514
+ ?>
515
+ <select name="<?php echo $this->option_name.'['.$args['select_name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['select_name']; ?>">
516
+ <?php foreach ( $args['select_options'] as $select_option ) : ?>
517
+ <option value="<?php echo esc_attr( $select_option['value'] ); ?>"<?php if ( (string)$select_option['value'] === (string)$value ) echo ' selected'; ?>><?php echo esc_html( $select_option['label'] ); ?></option>
518
+ <?php endforeach; ?>
519
+ </select>
520
+ <?php endif; ?>
521
+
522
+ <?php if ( isset( $args['hidden'] ) ) : ?>
523
+
524
+ <?php
525
+ if ( is_callable( array( $this, $args['hidden']['callback'] ) ) ){
526
+ echo $args['hidden']['before'];
527
+ call_user_func_array(
528
+ array( $this, $args['hidden']['callback'] ),
529
+ array( $args['hidden'] )
530
+ );
531
+ echo $args['hidden']['after'];
532
+ }
533
+ ?>
534
+ <?php endif; ?>
535
+
536
+ <?php if ( isset( $args['additional'] ) ) : ?>
537
+ <?php echo $args['additional']; ?>
538
+ <?php endif; ?>
539
+
540
+ <?php if ( isset( $args['tooltip_info'] ) ) : ?>
541
+ <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $tooltip_text; ?></a>
542
+ <p class="sbspf_tooltip sbspf_more_info"><?php echo $args['tooltip_info']; ?></p>
543
+ <?php
544
+ endif;
545
+ }
546
+
547
+ public function select( $args ) {
548
+ $default = isset( $args['default'] ) ? $args['default'] : $args['options'][0]['value'];
549
+ $value = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default;
550
+
551
+ if ( isset( $args['min'] ) && isset( $args['max'] ) && ((int)$args['min'] < (int)$args['max']) && empty( $args['options'] ) ) {
552
+ $args['options'] = array();
553
+ $i = (int)$args['min'];
554
+
555
+ while ( $i <= (int)$args['max'] ) {
556
+ $args['options'][] = array(
557
+ 'label' => $i,
558
+ 'value' => $i
559
+ );
560
+ $i++;
561
+ }
562
+ }
563
+
564
+ $tooltip_text = isset( $args['tooltip_text'] ) ? $args['label'] : $this->default_tooltip_text();
565
+ $pro_class = isset( $args['pro'] ) ? ' class="sbspf_pro_only"' : '';
566
+ ?>
567
+ <select<?php echo $pro_class; ?> name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>">
568
+ <?php foreach ( $args['options'] as $select_option ) : ?>
569
+ <option value="<?php echo esc_attr( $select_option['value'] ); ?>"<?php if ( (string)$select_option['value'] === (string)$value ) echo ' selected'; ?>><?php echo esc_html( $select_option['label'] ); ?></option>
570
+ <?php endforeach; ?>
571
+ </select>
572
+
573
+ <?php if ( isset( $args['additional'] ) ) : ?>
574
+ <?php echo $args['additional']; ?>
575
+ <?php endif; ?>
576
+
577
+ <?php if ( isset( $args['tooltip_info'] ) ) : ?>
578
+ <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $tooltip_text; ?></a>
579
+ <p class="sbspf_tooltip sbspf_more_info"><?php echo $args['tooltip_info']; ?></p>
580
+ <?php endif;
581
+ }
582
+
583
+ public function textarea( $args ) {
584
+ $default = isset( $args['default'] ) ? $args['default'] : '';
585
+ $value = isset( $this->settings[ $args['name'] ] ) ? stripslashes( $this->settings[ $args['name'] ] ) : $default;
586
+ $pro_class = isset( $args['pro'] ) ? ' class="sbspf_pro_only"' : '';
587
+
588
+ if ( isset( $args['tooltip_info'] ) ) : ?>
589
+ <span><?php echo $args['tooltip_info']; ?></span><br>
590
+ <?php endif; ?>
591
+
592
+ <textarea<?php echo $pro_class; ?> name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" id="<?php echo $this->option_name . '_' . $args['name']; ?>"rows="7"><?php echo $value; ?></textarea>
593
+
594
+ <?php if ( isset( $args['note'] ) ) : ?>
595
+ <br><span class="sbspf_note"><?php echo $args['note']; ?></span>
596
+ <?php endif;
597
+ }
598
+
599
+ public function color( $args ) {
600
+ $args['color'] = true;
601
+ $this->text( $args );
602
+ }
603
+
604
+ public function types( $args ) {
605
+ $type_selected = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $args['types'][0]['slug'];
606
+
607
+ foreach ( $args['types'] as $type ) :
608
+ $input_type = isset( $type['input_type'] ) ? $type['input_type'] : 'connected_account';
609
+ $selected = ! empty( $this->settings[ $type['slug'] ] ) ? $this->settings[ $type['slug'] ] : $type['default'];
610
+ if ( $input_type === 'connected_account' ) {
611
+ $selected = isset( $this->settings[ $type['slug'] . '_ids' ] ) ? $this->settings[ $type['slug'] . '_ids' ] : array();
612
+ }
613
+ $on_select = isset( $type['onselect'] ) ? $type['onselect'] : false;
614
+ $pro_class = isset( $type['pro'] ) ? ' sbspf_pro_only' : '';
615
+ ?>
616
+ <div class="sbspf_row sbspf_type_row<?php echo $pro_class; ?>" style="min-height: 29px;">
617
+ <div class="sbspf_col sbspf_one">
618
+ <input type="radio" name="<?php echo $this->option_name.'['.esc_attr( $args['name'] ).']'; ?>" class="sbspf_type_input" id="sbspf_type_<?php echo esc_attr( $type['slug'] ); ?>" value="<?php echo esc_attr( $type['slug'] ); ?>"<?php if ( $type_selected === $type['slug'] ) echo 'checked'; ?>>
619
+ <label class="sbspf_radio_label" for="sbspf_type_<?php echo esc_attr( $type['slug'] ); ?>"><?php echo esc_html( $type['label'] ); ?>: <a class="sbspf_type_tooltip_link" href="JavaScript:void(0);"><i class="fa fa-question-circle" aria-hidden="true" style="margin-left: 2px;"></i></a></label>
620
+ </div>
621
+ <div class="sbspf_col sbspf_two">
622
+ <?php if ( $input_type === 'text' ) :
623
+ $placeholder = isset( $type['note'] ) ? ' placeholder="' . esc_attr( $type['note'] ). '"' : '';
624
+ ?>
625
+ <input name="<?php echo $this->option_name.'['.esc_attr( $type['slug'] ).']'; ?>" id="sbspf_<?php echo esc_attr( $type['slug'] ); ?>" type="text" value="<?php echo esc_attr( $selected ); ?>" size="45"<?php echo $placeholder; ?>>
626
+ <?php else :
627
+ $connected_accounts = $this->get_connected_accounts(); ?>
628
+ <div class="sbspf_<?php echo esc_attr( $type['slug'] ); ?>_feed_ids_wrap">
629
+ <?php foreach ( $connected_accounts as $connected_account ) : if ( in_array( $connected_account['channel_id'], $selected, true ) ) : ?>
630
+ <div id="sbspf_<?php echo esc_attr( $type['slug'] ); ?>_feed_id_<?php echo esc_attr( $connected_account['channel_id'] ); ?>" class="sbspf_<?php echo esc_attr( $type['slug'] ); ?>_feed_account_wrap">
631
+ <strong><?php echo esc_html( $connected_account['username'] ); ?></strong> <span>(<?php echo esc_attr( $connected_account['channel_id'] ); ?>)</span><input type="hidden" name="<?php echo $this->option_name.'['.esc_attr( $type['slug'] ).'_feed_ids][]'; ?>" value="<?php echo esc_attr( $connected_account['channel_id'] ); ?>">
632
+ </div>
633
+ <?php endif; endforeach; ?>
634
+ </div>
635
+ <?php if ( empty( $selected ) ) : ?>
636
+ <p class="sbspf_no_accounts" style="margin-top: -3px; margin-right: 10px;"><?php _e( 'Connect an account above', $this->vars->text_domain() ); ?></p>
637
+ <?php endif; ?>
638
+
639
+ <?php endif; ?>
640
+ <?php if ( $input_type !== 'text' && isset( $type['note'] ) ) : ?>
641
+ <br><span class="sbspf_note"><?php echo $type['note']; ?></span>
642
+ <?php endif; ?>
643
+ </div>
644
+ <?php if ( $on_select ) : ?>
645
+ <div class="sbspf_onselect">
646
+ <?php call_user_func_array( array( $this, $on_select ), array( $type ) ); ?>
647
+ </div>
648
+ <?php endif; ?>
649
+
650
+ <div class="sbspf_tooltip sbspf_type_tooltip sbspf_more_info">
651
+ <?php if ( ! empty( $type['tooltip'] ) ) : ?>
652
+ <?php echo $type['tooltip']; ?>
653
+ <?php endif; ?>
654
+ </div>
655
+
656
+
657
+
658
+ </div>
659
+ <?php endforeach;
660
+ }
661
+
662
+ public function sub_option( $args ) {
663
+ $value = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : 'related';
664
+ $pro_flag = isset( $args['pro'] ) ? ' <span class="sbspf_pro_only"></span>' : '';
665
+ echo $pro_flag;
666
+ $cta_options = $args['sub_options'];
667
+ ?>
668
+ <?php if ( ! empty( $args['before'] ) ) {
669
+ echo $args['before'];
670
+ }?>
671
+
672
+ <div class="sbspf_sub_options">
673
+ <?php foreach ( $cta_options as $sub_option ) :
674
+ $pro_class = isset( $sub_option['pro'] ) ? ' sbspf_pro_only' : '';
675
+ ?>
676
+ <div class="sbspf_sub_option_cell<?php echo esc_attr( $pro_class ); ?>">
677
+ <input class="sbspf_sub_option_type" id="sbspf_sub_option_type_<?php echo esc_attr( $sub_option['slug'] ); ?>" name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" type="radio" value="<?php echo esc_attr( $sub_option['slug'] ); ?>"<?php if ( $sub_option['slug'] === $value ) echo ' checked'?>><label for="sbspf_sub_option_type_<?php echo esc_attr( $sub_option['slug'] ); ?>"><span class="sbspf_label"><?php echo $sub_option['label']; ?></span></label>
678
+ </div>
679
+ <?php endforeach; ?>
680
+
681
+ <div class="sbspf_box_setting">
682
+ <?php if ( isset( $cta_options ) ) : foreach ( $cta_options as $sub_option ) :
683
+ $pro_class = isset( $sub_option['pro'] ) ? ' sbspf_pro_only' : '';
684
+ ?>
685
+ <div class="sbspf_sub_option_settings sbspf_sub_option_type_<?php echo esc_attr( $sub_option['slug'] ) . $pro_class; ?>">
686
+
687
+ <div class="sbspf_sub_option_setting">
688
+ <?php echo sby_admin_icon( 'info-circle', 'sbspf_small_svg' ); ?>&nbsp;&nbsp;&nbsp;<span class="sbspf_note" style="margin-left: 0;"><?php echo $sub_option['note']; ?></span>
689
+ </div>
690
+ <?php if ( ! empty( $sub_option['options'] ) ) : ?>
691
+ <?php foreach ( $sub_option['options'] as $option ) :
692
+ $option['name'] = $sub_option['slug'].$option['name'];
693
+ ?>
694
+ <div class="sbspf_sub_option_setting">
695
+ <?php if ( $option['callback'] !== 'checkbox' ) :
696
+ if ( isset( $option['shortcode'] ) ) : ?>
697
+ <label title="<?php echo __( 'Click for shortcode option', $this->vars->text_domain() ); ?>"><?php echo $option['label']; ?></label><code class="sbspf_shortcode"> <?php echo $option['name'] . "\n"; ?>
698
+ Eg: <?php echo $option['name']; ?>=<?php echo $option['shortcode']['example']; ?></code><br>
699
+ <?php else: ?>
700
+ <label><?php echo $option['label']; ?></label><br>
701
+ <?php endif; ?>
702
+ <?php else:
703
+ $option['shortcode_example'] = $option['shortcode']['example'];
704
+ $option['has_shortcode'] = true;
705
+ endif; ?>
706
+ <?php call_user_func_array( array( $this, $option['callback'] ), array( $option ) ); ?>
707
+
708
+ </div>
709
+
710
+ <?php endforeach; ?>
711
+ <?php endif; ?>
712
+
713
+ </div>
714
+
715
+ <?php endforeach; endif; ?>
716
+ </div>
717
+ </div>
718
+ <?php
719
+ }
720
+
721
+ public function cache( $args ) {
722
+ $social_network = $this->vars->social_network();
723
+ $type_selected = isset( $this->settings['caching_type'] ) ? $this->settings['caching_type'] : 'page';
724
+ $caching_time = isset( $this->settings['caching_time'] ) ? $this->settings['caching_time'] : 1;
725
+ $cache_time_unit_selected = isset( $this->settings['cache_time_unit'] ) ? $this->settings['cache_time_unit'] : 'hours';
726
+ $cache_cron_interval_selected = isset( $this->settings['cache_cron_interval'] ) ? $this->settings['cache_cron_interval'] : '';
727
+ $cache_cron_time = isset( $this->settings['cache_cron_time'] ) ? $this->settings['cache_cron_time'] : '';
728
+ $cache_cron_am_pm = isset( $this->settings['cache_cron_am_pm'] ) ? $this->settings['cache_cron_am_pm'] : '';
729
+
730
+ ?>
731
+ <div class="sbspf_cache_settings_wrap">
732
+ <div class="sbspf_row">
733
+ <input type="radio" name="<?php echo $this->option_name.'[caching_type]'; ?>" class="sbspf_caching_type_input" id="sbspf_caching_type_page" value="page"<?php if ( $type_selected === 'page' ) echo ' checked'?>>
734
+ <label class="sbspf_radio_label" for="sbspf_caching_type_page"><?php _e ( 'When the page loads', $this->vars->text_domain() ); ?></label>
735
+ <a class="sbspf_tooltip_link" href="JavaScript:void(0);" style="position: relative; top: 2px;"><?php echo $this->default_tooltip_text() ?></a>
736
+ <p class="sbspf_tooltip sbspf_more_info"><?php echo sprintf( __( "Your %s data is temporarily cached by the plugin in your WordPress database. There are two ways that you can set the plugin to check for new data:<br><br>
737
+ <b>1. When the page loads</b><br>Selecting this option means that when the cache expires then the plugin will check %s for new posts the next time that the feed is loaded. You can choose how long this data should be cached for with a minimum time of 15 minutes. If you set the time to 60 minutes then the plugin will clear the cached data after that length of time, and the next time the page is viewed it will check for new data. <b>Tip:</b> If you're experiencing an issue with the plugin not updating automatically then try enabling the setting labeled <b>'Force cache to clear on interval'</b> which is located on the 'Customize' tab.<br><br>
738
+ <b>2. In the background</b><br>Selecting this option means that the plugin will check for new data in the background so that the feed is updated behind the scenes. You can select at what time and how often the plugin should check for new data using the settings below. <b>Please note</b> that the plugin will initially check for data from Instagram when the page first loads, but then after that will check in the background on the schedule selected - unless the cache is cleared.", $this->vars->text_domain() ), $social_network, $social_network ); ?>
739
+ </p>
740
+ </div>
741
+ <div class="sbspf_row sbspf-caching-page-options" style="display: none;">
742
+ <?php _e ( 'Every', $this->vars->text_domain() ); ?>:
743
+ <input name="<?php echo $this->option_name.'[caching_time]'; ?>" type="text" value="<?php echo esc_attr( $caching_time ); ?>" size="4">
744
+ <select name="<?php echo $this->option_name.'[caching_time_unit]'; ?>">
745
+ <option value="minutes"<?php if ( $cache_time_unit_selected === 'minutes' ) echo ' selected'?>><?php _e ( 'Minutes', $this->vars->text_domain() ); ?></option>
746
+ <option value="hours"<?php if ( $cache_time_unit_selected === 'hours' ) echo ' selected'?>><?php _e ( 'Hours', $this->vars->text_domain() ); ?></option>
747
+ <option value="days"<?php if ( $cache_time_unit_selected === 'days' ) echo ' selected'?>><?php _e ( 'Days', $this->vars->text_domain() ); ?></option>
748
+ </select>
749
+ <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php _e ( 'What does this mean?', $this->vars->text_domain() ); ?></a>
750
+ <p class="sbspf_tooltip sbspf_more_info"><?php echo sprintf( __("Your %s posts are temporarily cached by the plugin in your WordPress database. You can choose how long the posts should be cached for. If you set the time to 1 hour then the plugin will clear the cache after that length of time and check %s for posts again.", $this->vars->text_domain() ), $social_network, $social_network ); ?></p>
751
+ </div>
752
+
753
+ <div class="sbspf_row">
754
+ <input type="radio" name="<?php echo $this->option_name.'[caching_type]'; ?>" id="sbspf_caching_type_cron" class="sbspf_caching_type_input" value="background" <?php if ( $type_selected === 'background' ) echo ' checked'?>>
755
+ <label class="sbspf_radio_label" for="sbspf_caching_type_cron"><?php _e ( 'In the background', $this->vars->text_domain() ); ?></label>
756
+ </div>
757
+ <div class="sbspf_row sbspf-caching-cron-options" style="display: block;">
758
+
759
+ <select name="<?php echo $this->option_name.'[cache_cron_interval]'; ?>" id="sbspf_cache_cron_interval">
760
+ <option value="30mins"<?php if ( $cache_cron_interval_selected === '30mins' ) echo ' selected'?>><?php _e ( 'Every 30 minutes', $this->vars->text_domain() ); ?></option>
761
+ <option value="1hour"<?php if ( $cache_cron_interval_selected === '1hour' ) echo ' selected'?>><?php _e ( 'Every hour', $this->vars->text_domain() ); ?></option>
762
+ <option value="12hours"<?php if ( $cache_cron_interval_selected === '12hours' ) echo ' selected'?>><?php _e ( 'Every 12 hours', $this->vars->text_domain() ); ?></option>
763
+ <option value="24hours"<?php if ( $cache_cron_interval_selected === '24hours' ) echo ' selected'?>><?php _e ( 'Every 24 hours', $this->vars->text_domain() ); ?></option>
764
+ </select>
765
+
766
+ <div id="sbspf-caching-time-settings" style="">
767
+ <?php _e ( 'at', $this->vars->text_domain() ); ?>
768
+ <select name="<?php echo $this->option_name.'[cache_cron_time]'; ?>" style="width: 80px">
769
+ <option value="1"<?php if ( (int)$cache_cron_time === 1 ) echo ' selected'?>>1:00</option>
770
+ <option value="2"<?php if ( (int)$cache_cron_time === 2 ) echo ' selected'?>>2:00</option>
771
+ <option value="3"<?php if ( (int)$cache_cron_time === 3 ) echo ' selected'?>>3:00</option>
772
+ <option value="4"<?php if ( (int)$cache_cron_time === 4 ) echo ' selected'?>>4:00</option>
773
+ <option value="5"<?php if ( (int)$cache_cron_time === 5 ) echo ' selected'?>>5:00</option>
774
+ <option value="6"<?php if ( (int)$cache_cron_time === 6 ) echo ' selected'?>>6:00</option>
775
+ <option value="7"<?php if ( (int)$cache_cron_time === 7 ) echo ' selected'?>>7:00</option>
776
+ <option value="8"<?php if ( (int)$cache_cron_time === 8 ) echo ' selected'?>>8:00</option>
777
+ <option value="9"<?php if ( (int)$cache_cron_time === 9 ) echo ' selected'?>>9:00</option>
778
+ <option value="10"<?php if ( (int)$cache_cron_time === 10 ) echo ' selected'?>>10:00</option>
779
+ <option value="11"<?php if ( (int)$cache_cron_time === 11 ) echo ' selected'?>>11:00</option>
780
+ <option value="0"<?php if ( (int)$cache_cron_time === 0 ) echo ' selected'?>>12:00</option>
781
+ </select>
782
+
783
+ <select name="<?php echo $this->option_name.'[cache_cron_am_pm]'; ?>" style="width: 50px">
784
+ <option value="am"<?php if ( $cache_cron_am_pm === 'am' ) echo ' selected'?>><?php _e ( 'AM', $this->vars->text_domain() ); ?></option>
785
+ <option value="pm"<?php if ( $cache_cron_am_pm === 'pm' ) echo ' selected'?>><?php _e ( 'PM', $this->vars->text_domain() ); ?></option>
786
+ </select>
787
+ </div>
788
+
789
+ <?php
790
+ if ( wp_next_scheduled( 'sbspf_feed_update' ) ) {
791
+ $time_format = get_option( 'time_format' );
792
+ if ( ! $time_format ) {
793
+ $time_format = 'g:i a';
794
+ }
795
+ //
796
+ $schedule = wp_get_schedule( 'sbspf_feed_update' );
797
+ if ( $schedule == '30mins' ) $schedule = __( 'every 30 minutes', $this->vars->text_domain() );
798
+ if ( $schedule == 'twicedaily' ) $schedule = __( 'every 12 hours', $this->vars->text_domain() );
799
+ $sbspf_next_cron_event = wp_next_scheduled( 'sbspf_feed_update' );
800
+ echo '<p class="sbspf-caching-sched-notice"><span><b>' . __( 'Next check', $this->vars->text_domain() ) . ': ' . date( $time_format, $sbspf_next_cron_event + sbspf_get_utc_offset() ) . ' (' . $schedule . ')</b> - ' . __( 'Note: Saving the settings on this page will clear the cache and reset this schedule', $this->vars->text_domain() ) . '</span></p>';
801
+ } else {
802
+ echo '<p style="font-size: 11px; color: #666;">' . __( 'Nothing currently scheduled', $this->vars->text_domain() ) . '</p>';
803
+ }
804
+ ?>
805
+ </div>
806
+ </div>
807
+ <?php
808
+ }
809
+
810
+ public function layout( $args ) {
811
+ $default = isset( $args['default'] ) ? $args['default'] : $args['layouts'][0]['slug'];
812
+ $value = isset( $this->settings[ $args['name'] ] ) ? $this->settings[ $args['name'] ] : $default;
813
+ ?>
814
+ <div class="sbspf_layouts">
815
+ <?php foreach ( $args['layouts'] as $layout ) :
816
+ $pro_class = isset( $layout['pro'] ) ? ' sbspf_pro_only' : '';
817
+ ?>
818
+ <div class="sbspf_layout_cell<?php echo $pro_class; ?>">
819
+ <input class="sbspf_layout_type" id="sbspf_layout_type_<?php echo esc_attr( $layout['slug'] ); ?>" name="<?php echo $this->option_name.'['.$args['name'].']'; ?>" type="radio" value="<?php echo esc_attr( $layout['slug'] ); ?>"<?php if ( $layout['slug'] === $value ) echo ' checked'?>><label for="sbspf_layout_type_<?php echo esc_attr( $layout['slug'] ); ?>"><span class="sbspf_label"><?php echo $layout['label']; ?></span><img src="<?php echo esc_url( $this->vars->plugin_url() . $layout['image'] ); ?>"></label>
820
+ </div>
821
+ <?php endforeach; ?>
822
+
823
+ <div class="sbspf_layout_options_wrap">
824
+ <?php foreach ( $args['layouts'] as $layout ) :
825
+ $pro_class = isset( $layout['pro'] ) ? ' sbspf_pro_only' : '';
826
+ ?>
827
+ <div class="sbspf_layout_settings sbspf_layout_type_<?php echo esc_attr( $layout['slug'] ) . $pro_class; ?>">
828
+
829
+ <div class="sbspf_layout_setting">
830
+ <?php echo sby_admin_icon( 'info-circle' ); ?>&nbsp;&nbsp;&nbsp;<span class="sbspf_note" style="margin-left: 0;"><?php echo $layout['note']; ?></span>
831
+ </div>
832
+ <?php if ( ! empty( $layout['options'] ) ) : ?>
833
+ <?php foreach ( $layout['options'] as $option ) :
834
+ $option['name'] = $layout['slug'].$option['name'];
835
+ $option['shortcode']['example'] = isset( $option['shortcode']['example'] ) ? $option['shortcode']['example'] : $option['shortcode_example'];
836
+
837
+ ?>
838
+ <div class="sbspf_layout_setting">
839
+ <?php if ( $option['callback'] !== 'checkbox' ) : ?>
840
+ <label title="<?php echo __( 'Click for shortcode option', $this->vars->text_domain() ); ?>"><?php echo $option['label']; ?></label><code class="sbspf_shortcode"> <?php echo $option['name'] . "\n"; ?>
841
+ Eg: <?php echo $option['name']; ?>=<?php echo $option['shortcode']['example']; ?></code><br>
842
+ <?php else:
843
+
844
+ $option['has_shortcode'] = true;
845
+ endif; ?>
846
+ <?php call_user_func_array( array( $this, $option['callback'] ), array( $option ) ); ?>
847
+
848
+ </div>
849
+
850
+ <?php endforeach; ?>
851
+ <?php endif; ?>
852
+
853
+ </div>
854
+
855
+ <?php endforeach; ?>
856
+ </div>
857
+ </div>
858
+ <?php
859
+ }
860
+
861
+ public function instructions( $args ) {
862
+ ?>
863
+ <div class="sbspf_instructions_wrap">
864
+ <?php echo $args['instructions']?>
865
+ </div>
866
+ <?php
867
+ }
868
+
869
+ public function format_title( $label, $name, $shortcode_args = false, $after = '' ) {
870
+ $formatted_label = '<label for="' . $this->option_name . '_' . $name . '">' . $label .'</label>';
871
+ if ( $shortcode_args ) {
872
+ $formatted_label .= '<code class="sbspf_shortcode"> ' . $shortcode_args['key'] . "\n";
873
+ $formatted_label .= 'Eg: ' . $shortcode_args['key'] . '=' . $shortcode_args['example'] . '</code><br>';
874
+ }
875
+ $formatted_label .= $after;
876
+
877
+ return $formatted_label;
878
+ }
879
+
880
+ public function validate_options( $input, $tab ) {
881
+ $updated_options = get_option( $this->option_name, array() );
882
+ $false_if_empty_keys = $this->get_false_fields( $tab );
883
+ $textarea_keys = $this->get_textarea_fields( $tab );
884
+
885
+ foreach ( $false_if_empty_keys as $false_key ) {
886
+ $updated_options[ $false_key ] = false;
887
+ }
888
+
889
+ foreach ( $input as $key => $val ) {
890
+ if ( in_array( $key, $false_if_empty_keys ) ) {
891
+ $updated_options[ $key ] = ($val === 'on');
892
+ } elseif ( in_array( $key, $textarea_keys ) ) {
893
+ $updated_options[ $key ] = sanitize_textarea_field( $val );
894
+ } elseif ( is_array( $val ) ) {
895
+ $updated_options[ $key ] = array();
896
+ foreach ( $val as $key2 => $val2 ) {
897
+ $updated_options[ $key ][ $key2 ] = sanitize_text_field( $val2 );
898
+ }
899
+ } else {
900
+ $updated_options[ $key ] = sanitize_text_field( $val );
901
+ }
902
+ }
903
+
904
+
905
+ if ( $tab === 'configure' ) {
906
+ do_action( $this->option_name . '_after_configure_save', $updated_options );
907
+ } elseif ( $tab === 'customize' ) {
908
+ do_action( $this->option_name . '_after_customize_save', $updated_options );
909
+ }
910
+
911
+ return $updated_options;
912
+ }
913
+
914
+
915
+ public function update_options( $new_settings ) {
916
+ update_option( $this->get_option_name(), $new_settings );
917
+ $this->settings = $new_settings;
918
+ }
919
+
920
+ public function get_sections( $tab ) {
921
+ if ( isset( $this->settings_sections[ $tab ] ) ) {
922
+ return $this->settings_sections[ $tab ];
923
+ }
924
+ return array();
925
+ }
926
+
927
+ public function create_menus() {
928
+ add_menu_page(
929
+ $this->plugin_name,
930
+ $this->plugin_name,
931
+ $this->capability,
932
+ $this->slug,
933
+ array( $this, 'create_options_page' ),
934
+ $this->icon,
935
+ $this->position
936
+ );
937
+
938
+ foreach ( $this->tabs as $tab ) {
939
+ if ( $tab['slug'] !== 'configure' ) {
940
+ $title = isset( $tab['title'] ) ? $tab['title'] : '';
941
+ $capability = isset( $tab['capability'] ) ? $tab['capability'] : 'manage_options';
942
+ $slug = isset( $tab['slug'] ) ? $tab['slug'] : '';
943
+ $callback = isset( $tab['callback'] ) ? $tab['callback'] : array( $this, 'create_options_page' );
944
+
945
+ add_submenu_page(
946
+ $this->slug,
947
+ $title,
948
+ $title,
949
+ $capability,
950
+ $this->slug . '_' . $slug,
951
+ $callback
952
+ );
953
+ }
954
+ }
955
+
956
+ $this->after_create_menues();
957
+ }
958
+
959
+ public function after_create_menues() {
960
+
961
+ }
962
+
963
+ public function set_active_tab( $active_tab ) {
964
+ foreach ( $this->tabs as $tab ) {
965
+ if ( $tab['slug'] === $active_tab ) {
966
+ $this->active_tab = $tab['slug'];
967
+ }
968
+ }
969
+ }
970
+
971
+ public function get_tabs() {
972
+ return $this->tabs;
973
+ }
974
+
975
+ public function get_active_tab() {
976
+ return $this->active_tab;
977
+ }
978
+
979
+ public function get_slug() {
980
+ return $this->slug;
981
+ }
982
+
983
+ public function get_plugin_name() {
984
+ return $this->plugin_name;
985
+ }
986
+
987
+ public function get_path( $view ) {
988
+ return trailingslashit( $this->base_path ) . $view . '.php';
989
+ }
990
+
991
+ public function create_options_page() {
992
+ require_once trailingslashit( $this->base_path ) . 'main.php';
993
+ }
994
+
995
+ public function next_step() {
996
+ $return = array();
997
+ $i = 0;
998
+ foreach ( $this->tabs as $tab ) {
999
+ if ( $this->active_tab === $tab['slug'] && isset( $tab['next_step_instructions'] ) ) {
1000
+ $next_tab_slug = isset( $this->tabs[ $i + 1 ]['slug'] ) ? $this->tabs[ $i + 1 ]['slug'] : $tab['slug'];
1001
+ $return = array(
1002
+ 'instructions' => $tab['next_step_instructions'],
1003
+ 'next_tab' => $next_tab_slug
1004
+ );
1005
+ }
1006
+ $i++;
1007
+ }
1008
+ return $return;
1009
+ }
1010
+
1011
+ public function get_connected_accounts() {
1012
+ global $sbspf_settings;
1013
+
1014
+ if ( isset( $sbspf_settings['connected_accounts'] ) ) {
1015
+ return $sbspf_settings['connected_accounts'];
1016
+ }
1017
+ return array();
1018
+ }
1019
+
1020
+ public static function connect_account( $args ) {
1021
+ global $sbspf_settings;
1022
+
1023
+ // do connection
1024
+
1025
+ // random fake data
1026
+ $account_id = time();
1027
+
1028
+ $sbspf_settings['connected_accounts'][ $account_id ] = array(
1029
+ 'access_token' => 'at_' . str_shuffle( $account_id ),
1030
+ 'channel_id' => $account_id,
1031
+ 'username' => 'test' . $account_id,
1032
+ 'is_valid' => true,
1033
+ 'last_checked' => time(),
1034
+ 'profile_picture' => $args['profile_picture']
1035
+ );
1036
+
1037
+ update_option( 'sbspf_settings', $sbspf_settings );
1038
+
1039
+ return $sbspf_settings['connected_accounts'][ $account_id ];
1040
+ }
1041
+
1042
+ public function default_tooltip_text() {
1043
+ return '<span class="screen-reader-text">' . __( 'What does this mean?', $this->vars->text_domain() ) . '</span>' . sby_admin_icon( 'question-circle' );
1044
+ }
1045
+ }
inc/admin/class-sby-admin.php CHANGED
@@ -1,956 +1,1091 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- die( '-1' );
4
- }
5
-
6
- class SBY_Admin extends SB_YOUTUBE_Admin {
7
-
8
- public function settings_init() {
9
- $text_domain = $this->vars->text_domain();
10
-
11
- $defaults = sby_settings_defaults();
12
-
13
- /**
14
- * Configure Tab
15
- */
16
- $args = array(
17
- 'id' => 'sbspf_types',
18
- 'tab' => 'configure',
19
- 'save_after' => 'true'
20
- );
21
- $this->add_settings_section( $args );
22
-
23
- /* Types */
24
- $args = array(
25
- 'name' => 'type',
26
- 'section' => 'sbspf_types',
27
- 'callback' => 'types',
28
- 'title' => '<label>' . __( 'Feed Type', $text_domain ) .'</label>',
29
- 'shortcode' => array(
30
- 'key' => 'type',
31
- 'example' => 'channel',
32
- 'description' => __( 'Type of feed to display', $text_domain ) . ' e.g. channel, playlist, search, favorites, live',
33
- 'display_section' => 'configure'
34
- ),
35
- 'types' => $this->types
36
- );
37
- $this->add_settings_field( $args );
38
-
39
- $this->pro_only[] = 'type';
40
-
41
-
42
- /* Cache */
43
- $args = array(
44
- 'name' => 'cache',
45
- 'section' => 'sbspf_types',
46
- 'callback' => 'cache',
47
- 'title' => __( 'Check for new posts', $text_domain )
48
- );
49
- $this->add_settings_field( $args );
50
-
51
-
52
- /**
53
- * Customize Tab
54
- */
55
- $args = array(
56
- 'title' => __( 'General', $text_domain ),
57
- 'id' => 'sbspf_general',
58
- 'tab' => 'customize',
59
- 'save_after' => 'true'
60
- );
61
- $this->add_settings_section( $args );
62
-
63
- /* Width and Height */
64
- $select_options = array(
65
- array(
66
- 'label' => '%',
67
- 'value' => '%'
68
- ),
69
- array(
70
- 'label' => 'px',
71
- 'value' => 'px'
72
- )
73
- );
74
-
75
- $args = array(
76
- 'name' => 'width',
77
- 'default' => '100',
78
- 'section' => 'sbspf_general',
79
- 'callback' => 'text',
80
- 'min' => 1,
81
- 'size' => 4,
82
- 'title' => __( 'Width of Feed', $text_domain ),
83
- 'shortcode' => array(
84
- 'key' => 'width',
85
- 'example' => '300px',
86
- 'description' => __( 'The width of your feed. Any number with a unit like "px" or "%".', $text_domain ),
87
- 'display_section' => 'customize'
88
- ),
89
- 'select_name' => 'widthunit',
90
- 'select_options' => $select_options,
91
- 'hidden' => array(
92
- 'callback' => 'checkbox',
93
- 'name' => 'width_responsive',
94
- 'label' => __( 'Set to be 100% width on mobile?', $text_domain ),
95
- 'before' => '<div id="sbspf_width_options">',
96
- 'after' => '</div>',
97
- 'tooltip_info' => __( 'If you set a width on the feed then this will be used on mobile as well as desktop. Check this setting to set the feed width to be 100% on mobile so that it is responsive.', $text_domain )
98
- ),
99
- );
100
- $this->add_settings_field( $args );
101
-
102
- $select_options = array(
103
- array(
104
- 'label' => '%',
105
- 'value' => '%'
106
- ),
107
- array(
108
- 'label' => 'px',
109
- 'value' => 'px'
110
- )
111
- );
112
- $args = array(
113
- 'name' => 'height',
114
- 'default' => '',
115
- 'section' => 'sbspf_general',
116
- 'callback' => 'text',
117
- 'min' => 1,
118
- 'size' => 4,
119
- 'title' => __( 'Height of Feed', $text_domain ),
120
- 'shortcode' => array(
121
- 'key' => 'height',
122
- 'example' => '500px',
123
- 'description' => __( 'The height of your feed. Any number with a unit like "px" or "em".', $text_domain ),
124
- 'display_section' => 'customize'
125
- ),
126
- 'select_name' => 'heightunit',
127
- 'select_options' => $select_options,
128
- );
129
- $this->add_settings_field( $args );
130
-
131
- $args = array(
132
- 'name' => 'background',
133
- 'default' => '',
134
- 'section' => 'sbspf_general',
135
- 'callback' => 'color',
136
- 'title' => __( 'Background Color', $text_domain ),
137
- 'shortcode' => array(
138
- 'key' => 'background',
139
- 'example' => '#f00',
140
- 'description' => __( 'Background color for the feed. Any hex color code.', $text_domain ),
141
- 'display_section' => 'customize'
142
- ),
143
- );
144
- $this->add_settings_field( $args );
145
-
146
- $args = array(
147
- 'title' => __( 'Layout', $text_domain ),
148
- 'id' => 'sbspf_layout',
149
- 'tab' => 'customize',
150
- 'save_after' => 'true'
151
- );
152
- $this->add_settings_section( $args );
153
-
154
- $args = array(
155
- 'name' => 'layout',
156
- 'section' => 'sbspf_layout',
157
- 'callback' => 'layout',
158
- 'title' => __( 'Layout Type', $text_domain ),
159
- 'layouts' => $this->layouts,
160
- 'shortcode' => array(
161
- 'key' => 'layout',
162
- 'example' => 'list',
163
- 'description' => __( 'How your posts are displayed visually.', $text_domain ) . ' e.g. list, grid, gallery',
164
- 'display_section' => 'layout'
165
- )
166
- );
167
- $this->add_settings_field( $args );
168
-
169
- $this->pro_only[] = 'carouselcols';
170
- $this->pro_only[] = 'carouselcolsmobile';
171
- $this->pro_only[] = 'carouselrows';
172
- $this->pro_only[] = 'carouselloop';
173
- $this->pro_only[] = 'carouselarrows';
174
- $this->pro_only[] = 'carouselpag';
175
- $this->pro_only[] = 'carouselautoplay';
176
- $this->pro_only[] = 'carouseltime';
177
-
178
- $select_options = array(
179
- array(
180
- 'label' => 'px',
181
- 'value' => 'px'
182
- ),
183
- array(
184
- 'label' => '%',
185
- 'value' => '%'
186
- )
187
- );
188
-
189
- $args = array(
190
- 'name' => 'num',
191
- 'default' => $defaults['num'],
192
- 'section' => 'sbspf_layout',
193
- 'callback' => 'text',
194
- 'min' => 1,
195
- 'max' => 50,
196
- 'size' => 4,
197
- 'title' => __( 'Number of Videos', $text_domain ),
198
- 'additional' => '<span class="sby_note">' . __( 'Number of videos to show initially.', $text_domain ) . '</span>',
199
- 'shortcode' => array(
200
- 'key' => 'num',
201
- 'example' => 5,
202
- 'description' => __( 'The number of videos in the feed', $text_domain ),
203
- 'display_section' => 'layout'
204
- )
205
- );
206
- $this->add_settings_field( $args );
207
-
208
- $include_options = array(
209
- array(
210
- 'label' => __( 'Play Icon', $text_domain ),
211
- 'value' => 'icon'
212
- ),
213
- array(
214
- 'label' => __( 'Title', $text_domain ),
215
- 'value' => 'title',
216
- 'pro' => true
217
- ),
218
- array(
219
- 'label' => __( 'User Name', $text_domain ),
220
- 'value' => 'user',
221
- 'pro' => true
222
- ),
223
- array(
224
- 'label' => __( 'Views', $text_domain ),
225
- 'value' => 'views',
226
- 'pro' => true
227
- ),
228
- array(
229
- 'label' => __( 'Date', $text_domain ),
230
- 'value' => 'date',
231
- 'pro' => true
232
- ),
233
- array(
234
- 'label' => __( 'Live Stream Countdown (when applies)', $text_domain ),
235
- 'value' => 'countdown',
236
- 'pro' => true
237
- ),
238
- array(
239
- 'label' => __( 'Stats (like and comment counts)', $text_domain ),
240
- 'value' => 'stats',
241
- 'pro' => true
242
- ),
243
- array(
244
- 'label' => __( 'Description', $text_domain ),
245
- 'value' => 'description',
246
- 'pro' => true
247
- ),
248
- );
249
- $args = array(
250
- 'name' => 'include',
251
- 'default' => $defaults['include'],
252
- 'section' => 'sbspf_layout',
253
- 'callback' => 'multi_checkbox',
254
- 'title' => __( 'Show/Hide', $text_domain ),
255
- 'shortcode' => array(
256
- 'key' => 'include',
257
- 'example' => '"icon"',
258
- 'description' => __( 'What video information will display in the feed. eg.', $text_domain ) . ' icon',
259
- 'display_section' => 'customize'
260
- ),
261
- 'select_options' => $include_options,
262
- );
263
- $this->add_settings_field( $args );
264
-
265
- $args = array(
266
- 'name' => 'itemspacing',
267
- 'default' => 5,
268
- 'section' => 'sbspf_layout',
269
- 'callback' => 'text',
270
- 'min' => 0,
271
- 'size' => 4,
272
- 'title' => __( 'Spacing between videos', $text_domain ),
273
- 'shortcode' => array(
274
- 'key' => 'itemspacing',
275
- 'example' => '5px',
276
- 'description' => __( 'The spacing/padding around the videos in the feed. Any number with a unit like "px" or "em".', $text_domain ),
277
- 'display_section' => 'layout'
278
- ),
279
- 'select_name' => 'itemspacingunit',
280
- 'select_options' => $select_options,
281
- );
282
- $this->add_settings_field( $args );
283
-
284
- $select_options = array(
285
- array(
286
- 'label' => __( 'Below video thumbnail', $text_domain ),
287
- 'value' => 'below'
288
- ),
289
- array(
290
- 'label' => __( 'Next to video thumbnail', $text_domain ),
291
- 'value' => 'side'
292
- )
293
- );
294
- $args = array(
295
- 'name' => 'infoposition',
296
- 'default' => 'below',
297
- 'section' => 'sbspf_layout',
298
- 'pro' => true,
299
- 'callback' => 'select',
300
- 'title' => __( 'Position', $text_domain ),
301
- 'shortcode' => array(
302
- 'key' => 'infoposition',
303
- 'example' => 'side',
304
- 'description' => __( 'Where the information (title, description, stats) will display. eg.', $text_domain ) . ' below, side, none',
305
- 'display_section' => 'customize'
306
- ),
307
- 'options' => $select_options,
308
- );
309
- $this->add_settings_field( $args );
310
-
311
- $args = array(
312
- 'title' => __( 'Header', $text_domain ),
313
- 'id' => 'sbspf_header',
314
- 'tab' => 'customize',
315
- );
316
- $this->add_settings_section( $args );
317
-
318
- $args = array(
319
- 'name' => 'showheader',
320
- 'section' => 'sbspf_header',
321
- 'callback' => 'checkbox',
322
- 'title' => __( 'Show Header', $text_domain ),
323
- 'default' => true,
324
- 'shortcode' => array(
325
- 'key' => 'showheader',
326
- 'example' => 'false',
327
- 'description' => __( 'Include a header for this feed.', $text_domain ),
328
- 'display_section' => 'header'
329
- )
330
- );
331
- $this->add_settings_field( $args );
332
-
333
- $args = array(
334
- 'name' => 'showdescription',
335
- 'section' => 'sbspf_header',
336
- 'callback' => 'checkbox',
337
- 'title' => __( 'Show Channel Description', $text_domain ),
338
- 'default' => true,
339
- 'shortcode' => array(
340
- 'key' => 'showdescription',
341
- 'example' => 'false',
342
- 'description' => __( 'Include the channel description in the header.', $text_domain ),
343
- 'display_section' => 'header'
344
- )
345
- );
346
- $this->add_settings_field( $args );
347
-
348
- $args = array(
349
- 'name' => 'showsubscribers',
350
- 'section' => 'sbspf_header',
351
- 'callback' => 'checkbox',
352
- 'pro' => true,
353
- 'title' => __( 'Show Subscribers', $text_domain ),
354
- 'default' => true,
355
- 'shortcode' => array(
356
- 'key' => 'showsubscribers',
357
- 'example' => 'false',
358
- 'description' => __( 'Include the number of subscribers in the header.', $text_domain ),
359
- 'display_section' => 'header'
360
- )
361
- );
362
- $this->add_settings_field( $args );
363
-
364
- $args = array(
365
- 'title' => __( '"Load More" Button', $text_domain ),
366
- 'id' => 'sbspf_loadmore',
367
- 'tab' => 'customize',
368
- );
369
- $this->add_settings_section( $args );
370
-
371
- $args = array(
372
- 'name' => 'showbutton',
373
- 'section' => 'sbspf_loadmore',
374
- 'callback' => 'checkbox',
375
- 'title' => __( 'Show "Load More" Button', $text_domain ),
376
- 'default' => true,
377
- 'shortcode' => array(
378
- 'key' => 'showbutton',
379
- 'example' => 'false',
380
- 'description' => __( 'Include a "Load More" button at the bottom of the feed to load more videos.', $text_domain ),
381
- 'display_section' => 'button'
382
- )
383
- );
384
- $this->add_settings_field( $args );
385
-
386
- $args = array(
387
- 'name' => 'buttoncolor',
388
- 'default' => '',
389
- 'section' => 'sbspf_loadmore',
390
- 'callback' => 'color',
391
- 'title' => __( 'Button Background Color', $text_domain ),
392
- 'shortcode' => array(
393
- 'key' => 'buttoncolor',
394
- 'example' => '#0f0',
395
- 'description' => __( 'Background color for the "Load More" button. Any hex color code.', $text_domain ),
396
- 'display_section' => 'button'
397
- ),
398
- );
399
- $this->add_settings_field( $args );
400
-
401
- $args = array(
402
- 'name' => 'buttontextcolor',
403
- 'default' => '',
404
- 'section' => 'sbspf_loadmore',
405
- 'callback' => 'color',
406
- 'title' => __( 'Button Text Color', $text_domain ),
407
- 'shortcode' => array(
408
- 'key' => 'buttontextcolor',
409
- 'example' => '#00f',
410
- 'description' => __( 'Text color for the "Load More" button. Any hex color code.', $text_domain ),
411
- 'display_section' => 'button'
412
- ),
413
- );
414
- $this->add_settings_field( $args );
415
-
416
- $args = array(
417
- 'name' => 'buttontext',
418
- 'default' => __( 'Load More...', $text_domain ),
419
- 'section' => 'sbspf_loadmore',
420
- 'callback' => 'text',
421
- 'title' => __( 'Button Text', $text_domain ),
422
- 'shortcode' => array(
423
- 'key' => 'buttontext',
424
- 'example' => '"More Videos"',
425
- 'description' => __( 'The text that appers on the "Load More" button.', $text_domain ),
426
- 'display_section' => 'button'
427
- )
428
- );
429
- $this->add_settings_field( $args );
430
-
431
- /* Subscribe button */
432
- $args = array(
433
- 'title' => __( '"Subscribe" Button', $text_domain ),
434
- 'id' => 'sbspf_subscribe',
435
- 'tab' => 'customize',
436
- 'save_after' => true
437
- );
438
- $this->add_settings_section( $args );
439
-
440
- $args = array(
441
- 'name' => 'showsubscribe',
442
- 'section' => 'sbspf_subscribe',
443
- 'callback' => 'checkbox',
444
- 'title' => __( 'Show "Subscribe" Button', $text_domain ),
445
- 'default' => true,
446
- 'shortcode' => array(
447
- 'key' => 'showsubscribe',
448
- 'example' => 'false',
449
- 'description' => __( 'Include a "Subscribe" button at the bottom of the feed to load more videos.', $text_domain ),
450
- 'display_section' => 'subscribe'
451
- )
452
- );
453
- $this->add_settings_field( $args );
454
-
455
- $args = array(
456
- 'name' => 'subscribecolor',
457
- 'default' => '',
458
- 'section' => 'sbspf_subscribe',
459
- 'callback' => 'color',
460
- 'title' => __( 'Subscribe Background Color', $text_domain ),
461
- 'shortcode' => array(
462
- 'key' => 'subscribecolor',
463
- 'example' => '#0f0',
464
- 'description' => __( 'Background color for the "Subscribe" button. Any hex color code.', $text_domain ),
465
- 'display_section' => 'subscribe'
466
- ),
467
- );
468
- $this->add_settings_field( $args );
469
-
470
- $args = array(
471
- 'name' => 'subscribetextcolor',
472
- 'default' => '',
473
- 'section' => 'sbspf_subscribe',
474
- 'callback' => 'color',
475
- 'title' => __( 'Subscribe Text Color', $text_domain ),
476
- 'shortcode' => array(
477
- 'key' => 'subscribetextcolor',
478
- 'example' => '#00f',
479
- 'description' => __( 'Text color for the "Subscribe" button. Any hex color code.', $text_domain ),
480
- 'display_section' => 'subscribe'
481
- ),
482
- );
483
- $this->add_settings_field( $args );
484
-
485
- $args = array(
486
- 'name' => 'subscribetext',
487
- 'default' => __( 'Subscribe', $text_domain ),
488
- 'section' => 'sbspf_subscribe',
489
- 'callback' => 'text',
490
- 'title' => __( 'Subscribe Text', $text_domain ),
491
- 'shortcode' => array(
492
- 'key' => 'subscribetext',
493
- 'example' => '"Subscribe to My Channel"',
494
- 'description' => __( 'The text that appers on the "Subscribe" button.', $text_domain ),
495
- 'display_section' => 'subscribe'
496
- )
497
- );
498
- $this->add_settings_field( $args );
499
-
500
- $args = array(
501
- 'title' => __( 'Video Experience', $text_domain ),
502
- 'id' => 'sbspf_experience',
503
- 'tab' => 'customize',
504
- );
505
- $this->add_settings_section( $args );
506
-
507
- $select_options = array(
508
- array(
509
- 'label' => '9:16',
510
- 'value' => '9:16'
511
- ),
512
- array(
513
- 'label' => '3:4',
514
- 'value' => '3:4'
515
- ),
516
- );
517
- $args = array(
518
- 'name' => 'playerratio',
519
- 'default' => '9:16',
520
- 'section' => 'sbspf_experience',
521
- 'callback' => 'select',
522
- 'title' => __( 'Player Size Ratio', $text_domain ),
523
- 'shortcode' => array(
524
- 'key' => 'playerratio',
525
- 'example' => '9:16',
526
- 'description' => __( 'Player height relative to width e.g.', $text_domain ) . ' 9:16, 3:4',
527
- 'display_section' => 'experience'
528
- ),
529
- 'options' => $select_options,
530
- 'tooltip_info' => __( 'A 9:16 ratio does not leave room for video title and playback tools while a 3:4 ratio does.', $text_domain )
531
- );
532
- $this->add_settings_field( $args );
533
-
534
- $select_options = array(
535
- array(
536
- 'label' => __( 'Play when clicked', $text_domain ),
537
- 'value' => 'onclick'
538
- ),
539
- array(
540
- 'label' => 'Play automatically (desktop only)',
541
- 'value' => 'automatically'
542
- )
543
- );
544
- $args = array(
545
- 'name' => 'playvideo',
546
- 'default' => 'onclick',
547
- 'section' => 'sbspf_experience',
548
- 'callback' => 'select',
549
- 'title' => __( 'When does video play?', $text_domain ),
550
- 'shortcode' => array(
551
- 'key' => 'playvideo',
552
- 'example' => 'onclick',
553
- 'description' => __( 'What the user needs to do to play a video. eg.', $text_domain ) . ' onclick, automatically',
554
- 'display_section' => 'customize'
555
- ),
556
- 'options' => $select_options,
557
- 'tooltip_info' => __( 'List layout will not play automatically. Choose whether to play the video automatically in the player or wait until the user clicks the play button after the video is loaded.', $text_domain )
558
- );
559
- $this->add_settings_field( $args );
560
-
561
- $cta_options = array(
562
- array(
563
- 'label' => __( 'Related Videos', SBY_TEXT_DOMAIN ),
564
- 'slug' => 'related',
565
- 'pro' => true,
566
- 'note' => __( 'Display video thumbnails from the feed that play on your site when clicked.', SBY_TEXT_DOMAIN )
567
- ),
568
- array(
569
- 'label' => 'Custom Link',
570
- 'slug' => 'link',
571
- 'pro' => true,
572
- 'note' => __( 'Display a button link to a custom URL.', SBY_TEXT_DOMAIN ),
573
- 'options' => array(
574
- array(
575
- 'name' => 'instructions',
576
- 'callback' => 'instructions',
577
- 'instructions' => __( 'To set a link for each video individually, add the link and button text in the video description on YouTube in this format:', SBY_TEXT_DOMAIN ) . '<br><br><code>{Link: Button Text https://my-site.com/buy-now/my-product/}</code>',
578
- 'label' => __( 'Custom link for each video', SBY_TEXT_DOMAIN ),
579
- ),
580
- array(
581
- 'name' => 'url',
582
- 'callback' => 'text',
583
- 'label' => __( 'Default Link', SBY_TEXT_DOMAIN ),
584
- 'class' => 'large-text',
585
- 'default' => '',
586
- 'shortcode' => array(
587
- 'example' => 'https://my-site.com/buy-now/my-product/',
588
- 'description' => __( 'URL for viewer to visit for the call to action.', $text_domain ),
589
- )
590
- ),
591
- array(
592
- 'name' => 'opentype',
593
- 'callback' => 'select',
594
- 'options' => array(
595
- array(
596
- 'label' => __( 'Same window', SBY_TEXT_DOMAIN ),
597
- 'value' => 'same'
598
- ),
599
- array(
600
- 'label' => __( 'New window', SBY_TEXT_DOMAIN ),
601
- 'value' => 'newwindow'
602
- )
603
- ),
604
- 'label' => __( 'Link Open Type', SBY_TEXT_DOMAIN ),
605
- 'default' => 'same',
606
- 'shortcode' => array(
607
- 'example' => 'newwindow',
608
- 'description' => __( 'Whether to open the page in a new window or the same window.', $text_domain ),
609
- )
610
- ),
611
- array(
612
- 'name' => 'text',
613
- 'callback' => 'text',
614
- 'label' => __( 'Default Button Text', SBY_TEXT_DOMAIN ),
615
- 'default' => __( 'Learn More', SBY_TEXT_DOMAIN ),
616
- 'shortcode' => array(
617
- 'example' => 'Buy Now',
618
- 'description' => __( 'Text that appears on the call-to-action button.', $text_domain ),
619
- )
620
- ),
621
- array(
622
- 'name' => 'color',
623
- 'default' => '',
624
- 'callback' => 'color',
625
- 'label' => __( 'Button Background Color', SBY_TEXT_DOMAIN ),
626
- 'shortcode' => array(
627
- 'example' => '#0f0',
628
- 'description' => __( 'Button background. Turns opaque on hover.', $text_domain ),
629
- )
630
- ),
631
- array(
632
- 'name' => 'textcolor',
633
- 'default' => '',
634
- 'callback' => 'color',
635
- 'label' => __( 'Button Text Color', SBY_TEXT_DOMAIN ),
636
- 'shortcode' => array(
637
- 'example' => '#0f0',
638
- 'description' => __( 'Color of the text on the call-to-action-button', $text_domain ),
639
- )
640
- )
641
- )
642
- ),
643
- array(
644
- 'label' => __( 'YouTube Default', SBY_TEXT_DOMAIN ),
645
- 'slug' => 'default',
646
- 'pro' => true,
647
- 'note' => __( 'YouTube suggested videos from your channel that play on YouTube when clicked.', SBY_TEXT_DOMAIN )
648
- ),
649
- );
650
- $this->pro_only[] = 'linkurl';
651
- $this->pro_only[] = 'linkopentype';
652
- $this->pro_only[] = 'linktext';
653
- $this->pro_only[] = 'linkcolor';
654
- $this->pro_only[] = 'linktextcolor';
655
-
656
- $args = array(
657
- 'name' => 'cta',
658
- 'default' => 'related',
659
- 'section' => 'sbspf_experience',
660
- 'callback' => 'sub_option',
661
- 'pro' => true,
662
- 'sub_options' => $cta_options,
663
- 'title' => __( 'Call to Action', $text_domain ),
664
- 'before' => '<p style="margin-bottom: 10px">' . __( 'What the user sees when a video pauses or ends.', $text_domain ) . '</p>',
665
- 'shortcode' => array(
666
- 'key' => 'cta',
667
- 'example' => 'link',
668
- 'description' => __( 'What the user sees when a video pauses or ends. eg.', $text_domain ) . ' related, link',
669
- 'display_section' => 'experience'
670
- ),
671
- 'tooltip_info' => __( 'Choose what will happen after a video is paused or completes.', $text_domain )
672
- );
673
- $this->add_settings_field( $args );
674
-
675
- $args = array(
676
- 'title' => __( 'Moderation', $text_domain ),
677
- 'id' => 'sbspf_moderation',
678
- 'tab' => 'customize',
679
- 'pro' => __( 'Upgrade to Pro to enable Moderation settings', $text_domain ),
680
- );
681
- $this->add_settings_section( $args );
682
-
683
- $args = array(
684
- 'name' => 'includewords',
685
- 'default' => '',
686
- 'section' => 'sbspf_moderation',
687
- 'callback' => 'text',
688
- 'class' => 'large-text',
689
- 'title' => __( 'Show videos containing these words or hashtags', $text_domain ),
690
- 'shortcode' => array(
691
- 'key' => 'includewords',
692
- 'example' => '#filter',
693
- 'description' => __( 'Show videos that have specific text in the title or description.', $text_domain ),
694
- 'display_section' => 'customize'
695
- ),
696
- 'additional' => __( '"includewords" separate multiple words with commas, include "#" for hashtags', $text_domain )
697
- );
698
- $this->add_settings_field( $args );
699
-
700
- $args = array(
701
- 'name' => 'excludewords',
702
- 'default' => '',
703
- 'section' => 'sbspf_moderation',
704
- 'callback' => 'text',
705
- 'class' => 'large-text',
706
- 'title' => __( 'Remove videos containing these words or hashtags', $text_domain ),
707
- 'shortcode' => array(
708
- 'key' => 'excludewords',
709
- 'example' => '#filter',
710
- 'description' => __( 'Remove videos that have specific text in the title or description.', $text_domain ),
711
- 'display_section' => 'customize'
712
- ),
713
- 'additional' => __( '"excludewords" separate multiple words with commas, include "#" for hashtags', $text_domain )
714
- );
715
- $this->add_settings_field( $args );
716
- $this->pro_only[] = 'includewords';
717
- $this->pro_only[] = 'excludewords';
718
-
719
- $args = array(
720
- 'name' => 'hidevideos',
721
- 'default' => '',
722
- 'section' => 'sbspf_moderation',
723
- 'callback' => 'textarea',
724
- 'title' => __( 'Hide Specific Videos', $text_domain ),
725
- 'options' => $select_options,
726
- 'tooltip_info' => __( 'Separate IDs with commas.', $text_domain ) . '<a class="sbspf_tooltip_link" href="JavaScript:void(0);">'.$this->default_tooltip_text().'</a>
727
- <p class="sbspf_tooltip sbspf_more_info">' . __( 'These are the specific ID numbers associated with a video or with a post. You can find the ID of a video by viewing the video on YouTube and copy/pasting the ID number from the end of the URL. ex. <code>https://www.youtube.com/watch?v=<span class="sbspf-highlight">Ij1KvL8eN</span></code>', $text_domain ) . '</p>'
728
- );
729
- $this->add_settings_field( $args );
730
-
731
- $args = array(
732
- 'title' => __( 'Custom Code Snippets', $text_domain ),
733
- 'id' => 'sbspf_custom_snippets',
734
- 'tab' => 'customize'
735
- );
736
- $this->add_settings_section( $args );
737
-
738
- $args = array(
739
- 'name' => 'custom_css',
740
- 'default' => '',
741
- 'section' => 'sbspf_custom_snippets',
742
- 'callback' => 'textarea',
743
- 'title' => __( 'Custom CSS', $text_domain ),
744
- 'options' => $select_options,
745
- 'tooltip_info' => __( 'Enter your own custom CSS in the box below', $text_domain )
746
- );
747
- $this->add_settings_field( $args );
748
-
749
- $args = array(
750
- 'name' => 'custom_js',
751
- 'default' => '',
752
- 'section' => 'sbspf_custom_snippets',
753
- 'callback' => 'textarea',
754
- 'title' => __( 'Custom JavaScript', $text_domain ),
755
- 'options' => $select_options,
756
- 'tooltip_info' => __( 'Enter your own custom JavaScript/jQuery in the box below', $text_domain ),
757
- 'note' => __( 'Note: Custom JavaScript reruns every time more videos are loaded into the feed', $text_domain )
758
- );
759
- $this->add_settings_field( $args );
760
-
761
- $args = array(
762
- 'title' => __( 'Advanced', $text_domain ),
763
- 'id' => 'sbspf_advanced',
764
- 'tab' => 'customize',
765
- 'save_after' => true
766
- );
767
- $this->add_settings_section( $args );
768
-
769
- $args = array(
770
- 'name' => 'preserve_settings',
771
- 'section' => 'sbspf_advanced',
772
- 'callback' => 'checkbox',
773
- 'title' => __( 'Preserve settings when plugin is removed', $text_domain ),
774
- 'default' => false,
775
- 'tooltip_info' => __( 'When removing the plugin your settings are automatically erased. Checking this box will prevent any settings from being deleted. This means that you can uninstall and reinstall the plugin without losing your settings.', $text_domain )
776
- );
777
- $this->add_settings_field( $args );
778
-
779
- $select_options = array(
780
- array(
781
- 'label' => __( 'Background', $text_domain ),
782
- 'value' => 'background'
783
- ),
784
- array(
785
- 'label' => __( 'Page', $text_domain ),
786
- 'value' => 'page'
787
- ),
788
- array(
789
- 'label' => __( 'None', $text_domain ),
790
- 'value' => 'none'
791
- )
792
- );
793
- $additional = '<input id="sby-clear-cache" class="button-secondary sbspf-button-action" data-sby-action="sby_delete_wp_posts" data-sby-confirm="'.esc_attr( 'This will permanently delete all YouTube posts from the wp_posts table and the related data in the postmeta table. Existing feeds will only have 15 or fewer videos available initially. Continue?', $text_domain ).'" style="margin-top: 1px;" type="submit" value="'.esc_attr( 'Clear YouTube Posts', $text_domain ).'">';
794
- $args = array(
795
- 'name' => 'storage_process',
796
- 'default' => '',
797
- 'section' => 'sbspf_advanced',
798
- 'callback' => 'select',
799
- 'title' => __( 'Local storage process', $text_domain ),
800
- 'options' => $select_options,
801
- 'additional' => $additional,
802
- 'tooltip_info' => __( 'To preserve your feeds and videos even if the YouTube API is unavailable, a record of each video is added to the wp_posts table in the WordPress database. Please note that changing this setting to "none" will limit the number of posts available in the feed to 15 or less.', $text_domain )
803
- );
804
- $this->add_settings_field( $args );
805
-
806
- $args = array(
807
- 'name' => 'cronclear',
808
- 'section' => 'sbspf_advanced',
809
- 'callback' => 'checkbox',
810
- 'title' => __( 'Cron Clear Cache', $text_domain ),
811
- 'default' => false,
812
- 'tooltip_info' => __( 'If your YouTube feed is not updating, your WordPress installation may have a rare issue with clearing temporary data in your database. Enable this setting to use WordPress cron to clear your feed caches.', $text_domain )
813
- );
814
- $this->add_settings_field( $args );
815
-
816
- $args = array(
817
- 'name' => 'ajaxtheme',
818
- 'section' => 'sbspf_advanced',
819
- 'callback' => 'checkbox',
820
- 'title' => __( 'Are you using an AJAX theme?', $text_domain ),
821
- 'default' => false,
822
- 'tooltip_info' => __( 'When navigating your site, if your theme uses Ajax to load content into your pages (meaning your page doesn\'t refresh) then check this setting. If you\'re not sure then it\'s best to leave this setting unchecked while checking with your theme author, otherwise checking it may cause a problem.', $text_domain )
823
- );
824
- $this->add_settings_field( $args );
825
-
826
- $args = array(
827
- 'name' => 'customtemplates',
828
- 'section' => 'sbspf_advanced',
829
- 'callback' => 'checkbox',
830
- 'title' => __( 'Enable Custom Templates', $text_domain ),
831
- 'default' => false,
832
- 'tooltip_info' => __( 'The default HTML for the feed can be replaced with custom templates added to your theme\'s folder. Enable this setting to use these templates. See <a href="https://smashballoon.com/youtube-custom-templates/" target="_blank">this guide</a>', $text_domain )
833
- );
834
- $this->add_settings_field( $args );
835
-
836
- $args = array(
837
- 'name' => 'eagerload',
838
- 'section' => 'sbspf_advanced',
839
- 'callback' => 'checkbox',
840
- 'title' => __( 'Load Iframes on Page Load', $text_domain ),
841
- 'default' => false,
842
- 'tooltip_info' => __( 'To optimize the performance of your site and feeds, the plugin loads iframes only after a visitor interacts with the feed. Enabling this setting will cause YouTube player iframes to load when the page loads. Some features may work differently when this is enabled.', $text_domain )
843
- );
844
- $this->add_settings_field( $args );
845
-
846
- }
847
-
848
- public function cache( $args ) {
849
- $social_network = $this->vars->social_network();
850
- $type_selected = isset( $this->settings['caching_type'] ) ? $this->settings['caching_type'] : 'page';
851
- $caching_time = isset( $this->settings['caching_time'] ) ? $this->settings['caching_time'] : 1;
852
- $cache_time_unit_selected = isset( $this->settings['cache_time_unit'] ) ? $this->settings['cache_time_unit'] : 'hours';
853
-
854
- $cache_cron_interval_selected = isset( $this->settings['cache_cron_interval'] ) ? $this->settings['cache_cron_interval'] : '';
855
- $cache_cron_time = isset( $this->settings['cache_cron_time'] ) ? $this->settings['cache_cron_time'] : '';
856
- $cache_cron_am_pm = isset( $this->settings['cache_cron_am_pm'] ) ? $this->settings['cache_cron_am_pm'] : '';
857
-
858
- ?>
859
- <div class="sbspf_cache_settings_wrap">
860
- <div class="sbspf_row">
861
- <input type="radio" name="<?php echo $this->option_name.'[caching_type]'; ?>" class="sbspf_caching_type_input" id="sbspf_caching_type_page" value="page"<?php if ( $type_selected === 'page' ) echo ' checked'?>>
862
- <label class="sbspf_radio_label" for="sbspf_caching_type_page"><?php _e ( 'When the page loads', $this->vars->text_domain() ); ?></label>
863
- <a class="sbspf_tooltip_link" href="JavaScript:void(0);" style="position: relative; top: 2px;"><?php echo $this->default_tooltip_text() ?></a>
864
- <p class="sbspf_tooltip sbspf_more_info"><?php echo sprintf( __( "Your %s data is temporarily cached by the plugin in your WordPress database. There are two ways that you can set the plugin to check for new data:<br><br>
865
- <b>1. When the page loads</b><br>Selecting this option means that when the cache expires then the plugin will check %s for new posts the next time that the feed is loaded. You can choose how long this data should be cached for with a minimum time of 15 minutes. If you set the time to 60 minutes then the plugin will clear the cached data after that length of time, and the next time the page is viewed it will check for new data. <b>Tip:</b> If you're experiencing an issue with the plugin not updating automatically then try enabling the setting labeled <b>'Force cache to clear on interval'</b> which is located on the 'Customize' tab.<br><br>
866
- <b>2. In the background</b><br>Selecting this option means that the plugin will check for new data in the background so that the feed is updated behind the scenes. You can select at what time and how often the plugin should check for new data using the settings below. <b>Please note</b> that the plugin will initially check for data from Instagram when the page first loads, but then after that will check in the background on the schedule selected - unless the cache is cleared.", $this->vars->text_domain() ), $social_network, $social_network ); ?>
867
- </p>
868
- </div>
869
- <div class="sbspf_row sbspf-caching-page-options" style="display: none;">
870
- <?php _e ( 'Every', $this->vars->text_domain() ); ?>:
871
- <input name="<?php echo $this->option_name.'[caching_time]'; ?>" type="text" value="<?php echo esc_attr( $caching_time ); ?>" size="4">
872
- <select name="<?php echo $this->option_name.'[cache_time_unit]'; ?>">
873
- <option value="minutes"<?php if ( $cache_time_unit_selected === 'minutes' ) echo ' selected'?>><?php _e ( 'Minutes', $this->vars->text_domain() ); ?></option>
874
- <option value="hours"<?php if ( $cache_time_unit_selected === 'hours' ) echo ' selected'?>><?php _e ( 'Hours', $this->vars->text_domain() ); ?></option>
875
- <option value="days"<?php if ( $cache_time_unit_selected === 'days' ) echo ' selected'?>><?php _e ( 'Days', $this->vars->text_domain() ); ?></option>
876
- </select>
877
- <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php _e ( 'What does this mean?', $this->vars->text_domain() ); ?></a>
878
- <p class="sbspf_tooltip sbspf_more_info"><?php echo sprintf( __("Your %s posts are temporarily cached by the plugin in your WordPress database. You can choose how long the posts should be cached for. If you set the time to 1 hour then the plugin will clear the cache after that length of time and check %s for posts again.", $this->vars->text_domain() ), $social_network, $social_network ); ?></p>
879
- </div>
880
-
881
- <div class="sbspf_row">
882
- <input type="radio" name="<?php echo $this->option_name.'[caching_type]'; ?>" id="sbspf_caching_type_cron" class="sbspf_caching_type_input" value="background" <?php if ( $type_selected === 'background' ) echo ' checked'?>>
883
- <label class="sbspf_radio_label" for="sbspf_caching_type_cron"><?php _e ( 'In the background', $this->vars->text_domain() ); ?></label>
884
- </div>
885
- <div class="sbspf_row sbspf-caching-cron-options" style="display: block;">
886
-
887
- <select name="<?php echo $this->option_name.'[cache_cron_interval]'; ?>" id="sbspf_cache_cron_interval">
888
- <option value="30mins"<?php if ( $cache_cron_interval_selected === '30mins' ) echo ' selected'?>><?php _e ( 'Every 30 minutes', $this->vars->text_domain() ); ?></option>
889
- <option value="1hour"<?php if ( $cache_cron_interval_selected === '1hour' ) echo ' selected'?>><?php _e ( 'Every hour', $this->vars->text_domain() ); ?></option>
890
- <option value="12hours"<?php if ( $cache_cron_interval_selected === '12hours' ) echo ' selected'?>><?php _e ( 'Every 12 hours', $this->vars->text_domain() ); ?></option>
891
- <option value="24hours"<?php if ( $cache_cron_interval_selected === '24hours' ) echo ' selected'?>><?php _e ( 'Every 24 hours', $this->vars->text_domain() ); ?></option>
892
- </select>
893
-
894
- <div id="sbspf-caching-time-settings" style="">
895
- <?php _e ( 'at', $this->vars->text_domain() ); ?>
896
- <select name="<?php echo $this->option_name.'[cache_cron_time]'; ?>" style="width: 80px">
897
- <option value="1"<?php if ( (int)$cache_cron_time === 1 ) echo ' selected'?>>1:00</option>
898
- <option value="2"<?php if ( (int)$cache_cron_time === 2 ) echo ' selected'?>>2:00</option>
899
- <option value="3"<?php if ( (int)$cache_cron_time === 3 ) echo ' selected'?>>3:00</option>
900
- <option value="4"<?php if ( (int)$cache_cron_time === 4 ) echo ' selected'?>>4:00</option>
901
- <option value="5"<?php if ( (int)$cache_cron_time === 5 ) echo ' selected'?>>5:00</option>
902
- <option value="6"<?php if ( (int)$cache_cron_time === 6 ) echo ' selected'?>>6:00</option>
903
- <option value="7"<?php if ( (int)$cache_cron_time === 7 ) echo ' selected'?>>7:00</option>
904
- <option value="8"<?php if ( (int)$cache_cron_time === 8 ) echo ' selected'?>>8:00</option>
905
- <option value="9"<?php if ( (int)$cache_cron_time === 9 ) echo ' selected'?>>9:00</option>
906
- <option value="10"<?php if ( (int)$cache_cron_time === 10 ) echo ' selected'?>>10:00</option>
907
- <option value="11"<?php if ( (int)$cache_cron_time === 11 ) echo ' selected'?>>11:00</option>
908
- <option value="0"<?php if ( (int)$cache_cron_time === 0 ) echo ' selected'?>>12:00</option>
909
- </select>
910
-
911
- <select name="<?php echo $this->option_name.'[cache_cron_am_pm]'; ?>" style="width: 50px">
912
- <option value="am"<?php if ( $cache_cron_am_pm === 'am' ) echo ' selected'?>><?php _e ( 'AM', $this->vars->text_domain() ); ?></option>
913
- <option value="pm"<?php if ( $cache_cron_am_pm === 'pm' ) echo ' selected'?>><?php _e ( 'PM', $this->vars->text_domain() ); ?></option>
914
- </select>
915
- </div>
916
-
917
- <?php
918
- if ( wp_next_scheduled( 'sbspf_feed_update' ) ) {
919
- $time_format = get_option( 'time_format' );
920
- if ( ! $time_format ) {
921
- $time_format = 'g:i a';
922
- }
923
- //
924
- $schedule = wp_get_schedule( 'sbspf_feed_update' );
925
- if ( $schedule == '30mins' ) $schedule = __( 'every 30 minutes', $this->vars->text_domain() );
926
- if ( $schedule == 'twicedaily' ) $schedule = __( 'every 12 hours', $this->vars->text_domain() );
927
- $sbspf_next_cron_event = wp_next_scheduled( 'sbspf_feed_update' );
928
- echo '<p class="sbspf-caching-sched-notice"><span><b>' . __( 'Next check', $this->vars->text_domain() ) . ': ' . date( $time_format, $sbspf_next_cron_event + sbspf_get_utc_offset() ) . ' (' . $schedule . ')</b> - ' . __( 'Note: Saving the settings on this page will clear the cache and reset this schedule', $this->vars->text_domain() ) . '</span></p>';
929
- } else {
930
- echo '<p style="font-size: 11px; color: #666;">' . __( 'Nothing currently scheduled', $this->vars->text_domain() ) . '</p>';
931
- }
932
- ?>
933
- </div>
934
- </div>
935
- <?php
936
- }
937
-
938
- public function get_connected_accounts() {
939
- global $sby_settings;
940
-
941
- if ( isset( $sby_settings['connected_accounts'] ) ) {
942
- return $sby_settings['connected_accounts'];
943
- }
944
- return array();
945
- }
946
-
947
- public function access_token_listener() {
948
- if ( isset( $_GET['page'] ) && $_GET['page'] === SBY_SLUG && isset( $_GET['sby_access_token'] ) ) {
949
- sby_attempt_connection();
950
- }
951
- }
952
-
953
- public static function connect_account( $args ) {
954
- sby_update_or_connect_account( $args );
955
- }
956
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die( '-1' );
4
+ }
5
+
6
+ class SBY_Admin extends SB_YOUTUBE_Admin {
7
+
8
+ public function settings_init() {
9
+ $text_domain = $this->vars->text_domain();
10
+
11
+ $defaults = sby_settings_defaults();
12
+ $this->add_false_field( 'disablecdn', 'customize' );
13
+
14
+ /**
15
+ * Configure Tab
16
+ */
17
+ $args = array(
18
+ 'id' => 'sbspf_types',
19
+ 'tab' => 'configure',
20
+ 'save_after' => 'true'
21
+ );
22
+ $this->add_settings_section( $args );
23
+
24
+ /* Types */
25
+ $args = array(
26
+ 'name' => 'type',
27
+ 'section' => 'sbspf_types',
28
+ 'callback' => 'types',
29
+ 'title' => '<label>' . __( 'Feed Type', $text_domain ) .'</label>',
30
+ 'shortcode' => array(
31
+ 'key' => 'type',
32
+ 'example' => 'channel',
33
+ 'description' => __( 'Type of feed to display', $text_domain ) . ' e.g. channel, playlist, search, favorites, live',
34
+ 'display_section' => 'configure'
35
+ ),
36
+ 'types' => $this->types
37
+ );
38
+ $this->add_settings_field( $args );
39
+
40
+ $this->pro_only[] = 'type';
41
+
42
+
43
+ /* Cache */
44
+ $args = array(
45
+ 'name' => 'cache',
46
+ 'section' => 'sbspf_types',
47
+ 'callback' => 'cache',
48
+ 'title' => __( 'Check for new posts', $text_domain )
49
+ );
50
+ $this->add_settings_field( $args );
51
+
52
+
53
+ /**
54
+ * Customize Tab
55
+ */
56
+ $args = array(
57
+ 'title' => __( 'General', $text_domain ),
58
+ 'id' => 'sbspf_general',
59
+ 'tab' => 'customize',
60
+ 'save_after' => 'true'
61
+ );
62
+ $this->add_settings_section( $args );
63
+
64
+ /* Width and Height */
65
+ $select_options = array(
66
+ array(
67
+ 'label' => '%',
68
+ 'value' => '%'
69
+ ),
70
+ array(
71
+ 'label' => 'px',
72
+ 'value' => 'px'
73
+ )
74
+ );
75
+
76
+ $args = array(
77
+ 'name' => 'width',
78
+ 'default' => '100',
79
+ 'section' => 'sbspf_general',
80
+ 'callback' => 'text',
81
+ 'min' => 1,
82
+ 'size' => 4,
83
+ 'title' => __( 'Width of Feed', $text_domain ),
84
+ 'shortcode' => array(
85
+ 'key' => 'width',
86
+ 'example' => '300px',
87
+ 'description' => __( 'The width of your feed. Any number with a unit like "px" or "%".', $text_domain ),
88
+ 'display_section' => 'customize'
89
+ ),
90
+ 'select_name' => 'widthunit',
91
+ 'select_options' => $select_options,
92
+ 'hidden' => array(
93
+ 'callback' => 'checkbox',
94
+ 'name' => 'width_responsive',
95
+ 'label' => __( 'Set to be 100% width on mobile?', $text_domain ),
96
+ 'before' => '<div id="sbspf_width_options">',
97
+ 'after' => '</div>',
98
+ 'tooltip_info' => __( 'If you set a width on the feed then this will be used on mobile as well as desktop. Check this setting to set the feed width to be 100% on mobile so that it is responsive.', $text_domain )
99
+ ),
100
+ );
101
+ $this->add_settings_field( $args );
102
+
103
+ $select_options = array(
104
+ array(
105
+ 'label' => '%',
106
+ 'value' => '%'
107
+ ),
108
+ array(
109
+ 'label' => 'px',
110
+ 'value' => 'px'
111
+ )
112
+ );
113
+ $args = array(
114
+ 'name' => 'height',
115
+ 'default' => '',
116
+ 'section' => 'sbspf_general',
117
+ 'callback' => 'text',
118
+ 'min' => 1,
119
+ 'size' => 4,
120
+ 'title' => __( 'Height of Feed', $text_domain ),
121
+ 'shortcode' => array(
122
+ 'key' => 'height',
123
+ 'example' => '500px',
124
+ 'description' => __( 'The height of your feed. Any number with a unit like "px" or "em".', $text_domain ),
125
+ 'display_section' => 'customize'
126
+ ),
127
+ 'select_name' => 'heightunit',
128
+ 'select_options' => $select_options,
129
+ );
130
+ $this->add_settings_field( $args );
131
+
132
+ $args = array(
133
+ 'name' => 'background',
134
+ 'default' => '',
135
+ 'section' => 'sbspf_general',
136
+ 'callback' => 'color',
137
+ 'title' => __( 'Background Color', $text_domain ),
138
+ 'shortcode' => array(
139
+ 'key' => 'background',
140
+ 'example' => '#f00',
141
+ 'description' => __( 'Background color for the feed. Any hex color code.', $text_domain ),
142
+ 'display_section' => 'customize'
143
+ ),
144
+ );
145
+ $this->add_settings_field( $args );
146
+
147
+ $args = array(
148
+ 'title' => __( 'Layout', $text_domain ),
149
+ 'id' => 'sbspf_layout',
150
+ 'tab' => 'customize',
151
+ 'save_after' => 'true'
152
+ );
153
+ $this->add_settings_section( $args );
154
+
155
+ $args = array(
156
+ 'name' => 'layout',
157
+ 'section' => 'sbspf_layout',
158
+ 'callback' => 'layout',
159
+ 'title' => __( 'Layout Type', $text_domain ),
160
+ 'layouts' => $this->layouts,
161
+ 'shortcode' => array(
162
+ 'key' => 'layout',
163
+ 'example' => 'list',
164
+ 'description' => __( 'How your posts are displayed visually.', $text_domain ) . ' e.g. list, grid, gallery',
165
+ 'display_section' => 'layout'
166
+ )
167
+ );
168
+ $this->add_settings_field( $args );
169
+
170
+ $this->pro_only[] = 'carouselcols';
171
+ $this->pro_only[] = 'carouselcolsmobile';
172
+ $this->pro_only[] = 'carouselrows';
173
+ $this->pro_only[] = 'carouselloop';
174
+ $this->pro_only[] = 'carouselarrows';
175
+ $this->pro_only[] = 'carouselpag';
176
+ $this->pro_only[] = 'carouselautoplay';
177
+ $this->pro_only[] = 'carouseltime';
178
+
179
+ $select_options = array(
180
+ array(
181
+ 'label' => 'px',
182
+ 'value' => 'px'
183
+ ),
184
+ array(
185
+ 'label' => '%',
186
+ 'value' => '%'
187
+ )
188
+ );
189
+
190
+ $args = array(
191
+ 'name' => 'num',
192
+ 'default' => $defaults['num'],
193
+ 'section' => 'sbspf_layout',
194
+ 'callback' => 'text',
195
+ 'min' => 1,
196
+ 'max' => 50,
197
+ 'size' => 4,
198
+ 'title' => __( 'Number of Videos', $text_domain ),
199
+ 'additional' => '<span class="sby_note">' . __( 'Number of videos to show initially.', $text_domain ) . '</span>',
200
+ 'shortcode' => array(
201
+ 'key' => 'num',
202
+ 'example' => 5,
203
+ 'description' => __( 'The number of videos in the feed', $text_domain ),
204
+ 'display_section' => 'layout'
205
+ )
206
+ );
207
+ $this->add_settings_field( $args );
208
+
209
+ $include_options = array(
210
+ array(
211
+ 'label' => __( 'Play Icon', $text_domain ),
212
+ 'value' => 'icon'
213
+ ),
214
+ array(
215
+ 'label' => __( 'Title', $text_domain ),
216
+ 'value' => 'title',
217
+ 'pro' => true
218
+ ),
219
+ array(
220
+ 'label' => __( 'User Name', $text_domain ),
221
+ 'value' => 'user',
222
+ 'pro' => true
223
+ ),
224
+ array(
225
+ 'label' => __( 'Views', $text_domain ),
226
+ 'value' => 'views',
227
+ 'pro' => true
228
+ ),
229
+ array(
230
+ 'label' => __( 'Date', $text_domain ),
231
+ 'value' => 'date',
232
+ 'pro' => true
233
+ ),
234
+ array(
235
+ 'label' => __( 'Live Stream Countdown (when applies)', $text_domain ),
236
+ 'value' => 'countdown',
237
+ 'pro' => true
238
+ ),
239
+ array(
240
+ 'label' => __( 'Stats (like and comment counts)', $text_domain ),
241
+ 'value' => 'stats',
242
+ 'pro' => true
243
+ ),
244
+ array(
245
+ 'label' => __( 'Description', $text_domain ),
246
+ 'value' => 'description',
247
+ 'pro' => true
248
+ ),
249
+ );
250
+ $args = array(
251
+ 'name' => 'include',
252
+ 'default' => $defaults['include'],
253
+ 'section' => 'sbspf_layout',
254
+ 'callback' => 'multi_checkbox',
255
+ 'title' => __( 'Show/Hide', $text_domain ),
256
+ 'shortcode' => array(
257
+ 'key' => 'include',
258
+ 'example' => '"icon"',
259
+ 'description' => __( 'What video information will display in the feed. eg.', $text_domain ) . ' icon',
260
+ 'display_section' => 'customize'
261
+ ),
262
+ 'select_options' => $include_options,
263
+ );
264
+ $this->add_settings_field( $args );
265
+
266
+ $args = array(
267
+ 'name' => 'itemspacing',
268
+ 'default' => 5,
269
+ 'section' => 'sbspf_layout',
270
+ 'callback' => 'text',
271
+ 'min' => 0,
272
+ 'size' => 4,
273
+ 'title' => __( 'Spacing between videos', $text_domain ),
274
+ 'shortcode' => array(
275
+ 'key' => 'itemspacing',
276
+ 'example' => '5px',
277
+ 'description' => __( 'The spacing/padding around the videos in the feed. Any number with a unit like "px" or "em".', $text_domain ),
278
+ 'display_section' => 'layout'
279
+ ),
280
+ 'select_name' => 'itemspacingunit',
281
+ 'select_options' => $select_options,
282
+ );
283
+ $this->add_settings_field( $args );
284
+
285
+ $select_options = array(
286
+ array(
287
+ 'label' => __( 'Below video thumbnail', $text_domain ),
288
+ 'value' => 'below'
289
+ ),
290
+ array(
291
+ 'label' => __( 'Next to video thumbnail', $text_domain ),
292
+ 'value' => 'side'
293
+ )
294
+ );
295
+ $args = array(
296
+ 'name' => 'infoposition',
297
+ 'default' => 'below',
298
+ 'section' => 'sbspf_layout',
299
+ 'pro' => true,
300
+ 'callback' => 'select',
301
+ 'title' => __( 'Position', $text_domain ),
302
+ 'shortcode' => array(
303
+ 'key' => 'infoposition',
304
+ 'example' => 'side',
305
+ 'description' => __( 'Where the information (title, description, stats) will display. eg.', $text_domain ) . ' below, side, none',
306
+ 'display_section' => 'customize'
307
+ ),
308
+ 'options' => $select_options,
309
+ );
310
+ $this->add_settings_field( $args );
311
+
312
+ $args = array(
313
+ 'title' => __( 'Header', $text_domain ),
314
+ 'id' => 'sbspf_header',
315
+ 'tab' => 'customize',
316
+ );
317
+ $this->add_settings_section( $args );
318
+
319
+ $args = array(
320
+ 'name' => 'showheader',
321
+ 'section' => 'sbspf_header',
322
+ 'callback' => 'checkbox',
323
+ 'title' => __( 'Show Header', $text_domain ),
324
+ 'default' => true,
325
+ 'shortcode' => array(
326
+ 'key' => 'showheader',
327
+ 'example' => 'false',
328
+ 'description' => __( 'Include a header for this feed.', $text_domain ),
329
+ 'display_section' => 'header'
330
+ )
331
+ );
332
+ $this->add_settings_field( $args );
333
+
334
+ $args = array(
335
+ 'name' => 'showdescription',
336
+ 'section' => 'sbspf_header',
337
+ 'callback' => 'checkbox',
338
+ 'title' => __( 'Show Channel Description', $text_domain ),
339
+ 'default' => true,
340
+ 'shortcode' => array(
341
+ 'key' => 'showdescription',
342
+ 'example' => 'false',
343
+ 'description' => __( 'Include the channel description in the header.', $text_domain ),
344
+ 'display_section' => 'header'
345
+ )
346
+ );
347
+ $this->add_settings_field( $args );
348
+
349
+ $args = array(
350
+ 'name' => 'showsubscribers',
351
+ 'section' => 'sbspf_header',
352
+ 'callback' => 'checkbox',
353
+ 'pro' => true,
354
+ 'title' => __( 'Show Subscribers', $text_domain ),
355
+ 'default' => true,
356
+ 'shortcode' => array(
357
+ 'key' => 'showsubscribers',
358
+ 'example' => 'false',
359
+ 'description' => __( 'Include the number of subscribers in the header.', $text_domain ),
360
+ 'display_section' => 'header'
361
+ )
362
+ );
363
+ $this->add_settings_field( $args );
364
+
365
+ $args = array(
366
+ 'title' => __( '"Load More" Button', $text_domain ),
367
+ 'id' => 'sbspf_loadmore',
368
+ 'tab' => 'customize',
369
+ );
370
+ $this->add_settings_section( $args );
371
+
372
+ $args = array(
373
+ 'name' => 'showbutton',
374
+ 'section' => 'sbspf_loadmore',
375
+ 'callback' => 'checkbox',
376
+ 'title' => __( 'Show "Load More" Button', $text_domain ),
377
+ 'default' => true,
378
+ 'shortcode' => array(
379
+ 'key' => 'showbutton',
380
+ 'example' => 'false',
381
+ 'description' => __( 'Include a "Load More" button at the bottom of the feed to load more videos.', $text_domain ),
382
+ 'display_section' => 'button'
383
+ )
384
+ );
385
+ $this->add_settings_field( $args );
386
+
387
+ $args = array(
388
+ 'name' => 'buttoncolor',
389
+ 'default' => '',
390
+ 'section' => 'sbspf_loadmore',
391
+ 'callback' => 'color',
392
+ 'title' => __( 'Button Background Color', $text_domain ),
393
+ 'shortcode' => array(
394
+ 'key' => 'buttoncolor',
395
+ 'example' => '#0f0',
396
+ 'description' => __( 'Background color for the "Load More" button. Any hex color code.', $text_domain ),
397
+ 'display_section' => 'button'
398
+ ),
399
+ );
400
+ $this->add_settings_field( $args );
401
+
402
+ $args = array(
403
+ 'name' => 'buttontextcolor',
404
+ 'default' => '',
405
+ 'section' => 'sbspf_loadmore',
406
+ 'callback' => 'color',
407
+ 'title' => __( 'Button Text Color', $text_domain ),
408
+ 'shortcode' => array(
409
+ 'key' => 'buttontextcolor',
410
+ 'example' => '#00f',
411
+ 'description' => __( 'Text color for the "Load More" button. Any hex color code.', $text_domain ),
412
+ 'display_section' => 'button'
413
+ ),
414
+ );
415
+ $this->add_settings_field( $args );
416
+
417
+ $args = array(
418
+ 'name' => 'buttontext',
419
+ 'default' => __( 'Load More...', $text_domain ),
420
+ 'section' => 'sbspf_loadmore',
421
+ 'callback' => 'text',
422
+ 'title' => __( 'Button Text', $text_domain ),
423
+ 'shortcode' => array(
424
+ 'key' => 'buttontext',
425
+ 'example' => '"More Videos"',
426
+ 'description' => __( 'The text that appers on the "Load More" button.', $text_domain ),
427
+ 'display_section' => 'button'
428
+ )
429
+ );
430
+ $this->add_settings_field( $args );
431
+
432
+ /* Subscribe button */
433
+ $args = array(
434
+ 'title' => __( '"Subscribe" Button', $text_domain ),
435
+ 'id' => 'sbspf_subscribe',
436
+ 'tab' => 'customize',
437
+ 'save_after' => true
438
+ );
439
+ $this->add_settings_section( $args );
440
+
441
+ $args = array(
442
+ 'name' => 'showsubscribe',
443
+ 'section' => 'sbspf_subscribe',
444
+ 'callback' => 'checkbox',
445
+ 'title' => __( 'Show "Subscribe" Button', $text_domain ),
446
+ 'default' => true,
447
+ 'shortcode' => array(
448
+ 'key' => 'showsubscribe',
449
+ 'example' => 'false',
450
+ 'description' => __( 'Include a "Subscribe" button at the bottom of the feed to load more videos.', $text_domain ),
451
+ 'display_section' => 'subscribe'
452
+ )
453
+ );
454
+ $this->add_settings_field( $args );
455
+
456
+ $args = array(
457
+ 'name' => 'subscribecolor',
458
+ 'default' => '',
459
+ 'section' => 'sbspf_subscribe',
460
+ 'callback' => 'color',
461
+ 'title' => __( 'Subscribe Background Color', $text_domain ),
462
+ 'shortcode' => array(
463
+ 'key' => 'subscribecolor',
464
+ 'example' => '#0f0',
465
+ 'description' => __( 'Background color for the "Subscribe" button. Any hex color code.', $text_domain ),
466
+ 'display_section' => 'subscribe'
467
+ ),
468
+ );
469
+ $this->add_settings_field( $args );
470
+
471
+ $args = array(
472
+ 'name' => 'subscribetextcolor',
473
+ 'default' => '',
474
+ 'section' => 'sbspf_subscribe',
475
+ 'callback' => 'color',
476
+ 'title' => __( 'Subscribe Text Color', $text_domain ),
477
+ 'shortcode' => array(
478
+ 'key' => 'subscribetextcolor',
479
+ 'example' => '#00f',
480
+ 'description' => __( 'Text color for the "Subscribe" button. Any hex color code.', $text_domain ),
481
+ 'display_section' => 'subscribe'
482
+ ),
483
+ );
484
+ $this->add_settings_field( $args );
485
+
486
+ $args = array(
487
+ 'name' => 'subscribetext',
488
+ 'default' => __( 'Subscribe', $text_domain ),
489
+ 'section' => 'sbspf_subscribe',
490
+ 'callback' => 'text',
491
+ 'title' => __( 'Subscribe Text', $text_domain ),
492
+ 'shortcode' => array(
493
+ 'key' => 'subscribetext',
494
+ 'example' => '"Subscribe to My Channel"',
495
+ 'description' => __( 'The text that appers on the "Subscribe" button.', $text_domain ),
496
+ 'display_section' => 'subscribe'
497
+ )
498
+ );
499
+ $this->add_settings_field( $args );
500
+
501
+ $args = array(
502
+ 'title' => __( 'Video Experience', $text_domain ),
503
+ 'id' => 'sbspf_experience',
504
+ 'tab' => 'customize',
505
+ );
506
+ $this->add_settings_section( $args );
507
+
508
+ $select_options = array(
509
+ array(
510
+ 'label' => '9:16',
511
+ 'value' => '9:16'
512
+ ),
513
+ array(
514
+ 'label' => '3:4',
515
+ 'value' => '3:4'
516
+ ),
517
+ );
518
+ $args = array(
519
+ 'name' => 'playerratio',
520
+ 'default' => '9:16',
521
+ 'section' => 'sbspf_experience',
522
+ 'callback' => 'select',
523
+ 'title' => __( 'Player Size Ratio', $text_domain ),
524
+ 'shortcode' => array(
525
+ 'key' => 'playerratio',
526
+ 'example' => '9:16',
527
+ 'description' => __( 'Player height relative to width e.g.', $text_domain ) . ' 9:16, 3:4',
528
+ 'display_section' => 'experience'
529
+ ),
530
+ 'options' => $select_options,
531
+ 'tooltip_info' => __( 'A 9:16 ratio does not leave room for video title and playback tools while a 3:4 ratio does.', $text_domain )
532
+ );
533
+ $this->add_settings_field( $args );
534
+
535
+ $select_options = array(
536
+ array(
537
+ 'label' => __( 'Play when clicked', $text_domain ),
538
+ 'value' => 'onclick'
539
+ ),
540
+ array(
541
+ 'label' => 'Play automatically (desktop only)',
542
+ 'value' => 'automatically'
543
+ )
544
+ );
545
+ $args = array(
546
+ 'name' => 'playvideo',
547
+ 'default' => 'onclick',
548
+ 'section' => 'sbspf_experience',
549
+ 'callback' => 'select',
550
+ 'title' => __( 'When does video play?', $text_domain ),
551
+ 'shortcode' => array(
552
+ 'key' => 'playvideo',
553
+ 'example' => 'onclick',
554
+ 'description' => __( 'What the user needs to do to play a video. eg.', $text_domain ) . ' onclick, automatically',
555
+ 'display_section' => 'customize'
556
+ ),
557
+ 'options' => $select_options,
558
+ 'tooltip_info' => __( 'List layout will not play automatically. Choose whether to play the video automatically in the player or wait until the user clicks the play button after the video is loaded.', $text_domain )
559
+ );
560
+ $this->add_settings_field( $args );
561
+
562
+ $cta_options = array(
563
+ array(
564
+ 'label' => __( 'Related Videos', SBY_TEXT_DOMAIN ),
565
+ 'slug' => 'related',
566
+ 'pro' => true,
567
+ 'note' => __( 'Display video thumbnails from the feed that play on your site when clicked.', SBY_TEXT_DOMAIN )
568
+ ),
569
+ array(
570
+ 'label' => 'Custom Link',
571
+ 'slug' => 'link',
572
+ 'pro' => true,
573
+ 'note' => __( 'Display a button link to a custom URL.', SBY_TEXT_DOMAIN ),
574
+ 'options' => array(
575
+ array(
576
+ 'name' => 'instructions',
577
+ 'callback' => 'instructions',
578
+ 'instructions' => __( 'To set a link for each video individually, add the link and button text in the video description on YouTube in this format:', SBY_TEXT_DOMAIN ) . '<br><br><code>{Link: Button Text https://my-site.com/buy-now/my-product/}</code>',
579
+ 'label' => __( 'Custom link for each video', SBY_TEXT_DOMAIN ),
580
+ ),
581
+ array(
582
+ 'name' => 'url',
583
+ 'callback' => 'text',
584
+ 'label' => __( 'Default Link', SBY_TEXT_DOMAIN ),
585
+ 'class' => 'large-text',
586
+ 'default' => '',
587
+ 'shortcode' => array(
588
+ 'example' => 'https://my-site.com/buy-now/my-product/',
589
+ 'description' => __( 'URL for viewer to visit for the call to action.', $text_domain ),
590
+ )
591
+ ),
592
+ array(
593
+ 'name' => 'opentype',
594
+ 'callback' => 'select',
595
+ 'options' => array(
596
+ array(
597
+ 'label' => __( 'Same window', SBY_TEXT_DOMAIN ),
598
+ 'value' => 'same'
599
+ ),
600
+ array(
601
+ 'label' => __( 'New window', SBY_TEXT_DOMAIN ),
602
+ 'value' => 'newwindow'
603
+ )
604
+ ),
605
+ 'label' => __( 'Link Open Type', SBY_TEXT_DOMAIN ),
606
+ 'default' => 'same',
607
+ 'shortcode' => array(
608
+ 'example' => 'newwindow',
609
+ 'description' => __( 'Whether to open the page in a new window or the same window.', $text_domain ),
610
+ )
611
+ ),
612
+ array(
613
+ 'name' => 'text',
614
+ 'callback' => 'text',
615
+ 'label' => __( 'Default Button Text', SBY_TEXT_DOMAIN ),
616
+ 'default' => __( 'Learn More', SBY_TEXT_DOMAIN ),
617
+ 'shortcode' => array(
618
+ 'example' => 'Buy Now',
619
+ 'description' => __( 'Text that appears on the call-to-action button.', $text_domain ),
620
+ )
621
+ ),
622
+ array(
623
+ 'name' => 'color',
624
+ 'default' => '',
625
+ 'callback' => 'color',
626
+ 'label' => __( 'Button Background Color', SBY_TEXT_DOMAIN ),
627
+ 'shortcode' => array(
628
+ 'example' => '#0f0',
629
+ 'description' => __( 'Button background. Turns opaque on hover.', $text_domain ),
630
+ )
631
+ ),
632
+ array(
633
+ 'name' => 'textcolor',
634
+ 'default' => '',
635
+ 'callback' => 'color',
636
+ 'label' => __( 'Button Text Color', SBY_TEXT_DOMAIN ),
637
+ 'shortcode' => array(
638
+ 'example' => '#0f0',
639
+ 'description' => __( 'Color of the text on the call-to-action-button', $text_domain ),
640
+ )
641
+ )
642
+ )
643
+ ),
644
+ array(
645
+ 'label' => __( 'YouTube Default', SBY_TEXT_DOMAIN ),
646
+ 'slug' => 'default',
647
+ 'pro' => true,
648
+ 'note' => __( 'YouTube suggested videos from your channel that play on YouTube when clicked.', SBY_TEXT_DOMAIN )
649
+ ),
650
+ );
651
+ $this->pro_only[] = 'linkurl';
652
+ $this->pro_only[] = 'linkopentype';
653
+ $this->pro_only[] = 'linktext';
654
+ $this->pro_only[] = 'linkcolor';
655
+ $this->pro_only[] = 'linktextcolor';
656
+
657
+ $args = array(
658
+ 'name' => 'cta',
659
+ 'default' => 'related',
660
+ 'section' => 'sbspf_experience',
661
+ 'callback' => 'sub_option',
662
+ 'pro' => true,
663
+ 'sub_options' => $cta_options,
664
+ 'title' => __( 'Call to Action', $text_domain ),
665
+ 'before' => '<p style="margin-bottom: 10px">' . __( 'What the user sees when a video pauses or ends.', $text_domain ) . '</p>',
666
+ 'shortcode' => array(
667
+ 'key' => 'cta',
668
+ 'example' => 'link',
669
+ 'description' => __( 'What the user sees when a video pauses or ends. eg.', $text_domain ) . ' related, link',
670
+ 'display_section' => 'experience'
671
+ ),
672
+ 'tooltip_info' => __( 'Choose what will happen after a video is paused or completes.', $text_domain )
673
+ );
674
+ $this->add_settings_field( $args );
675
+
676
+ $args = array(
677
+ 'title' => __( 'Moderation', $text_domain ),
678
+ 'id' => 'sbspf_moderation',
679
+ 'tab' => 'customize',
680
+ 'pro' => __( 'Upgrade to Pro to enable Moderation settings', $text_domain ),
681
+ );
682
+ $this->add_settings_section( $args );
683
+
684
+ $args = array(
685
+ 'name' => 'includewords',
686
+ 'default' => '',
687
+ 'section' => 'sbspf_moderation',
688
+ 'callback' => 'text',
689
+ 'class' => 'large-text',
690
+ 'title' => __( 'Show videos containing these words or hashtags', $text_domain ),
691
+ 'shortcode' => array(
692
+ 'key' => 'includewords',
693
+ 'example' => '#filter',
694
+ 'description' => __( 'Show videos that have specific text in the title or description.', $text_domain ),
695
+ 'display_section' => 'customize'
696
+ ),
697
+ 'additional' => __( '"includewords" separate multiple words with commas, include "#" for hashtags', $text_domain )
698
+ );
699
+ $this->add_settings_field( $args );
700
+
701
+ $args = array(
702
+ 'name' => 'excludewords',
703
+ 'default' => '',
704
+ 'section' => 'sbspf_moderation',
705
+ 'callback' => 'text',
706
+ 'class' => 'large-text',
707
+ 'title' => __( 'Remove videos containing these words or hashtags', $text_domain ),
708
+ 'shortcode' => array(
709
+ 'key' => 'excludewords',
710
+ 'example' => '#filter',
711
+ 'description' => __( 'Remove videos that have specific text in the title or description.', $text_domain ),
712
+ 'display_section' => 'customize'
713
+ ),
714
+ 'additional' => __( '"excludewords" separate multiple words with commas, include "#" for hashtags', $text_domain )
715
+ );
716
+ $this->add_settings_field( $args );
717
+ $this->pro_only[] = 'includewords';
718
+ $this->pro_only[] = 'excludewords';
719
+
720
+ $args = array(
721
+ 'name' => 'hidevideos',
722
+ 'default' => '',
723
+ 'section' => 'sbspf_moderation',
724
+ 'callback' => 'textarea',
725
+ 'title' => __( 'Hide Specific Videos', $text_domain ),
726
+ 'options' => $select_options,
727
+ 'tooltip_info' => __( 'Separate IDs with commas.', $text_domain ) . '<a class="sbspf_tooltip_link" href="JavaScript:void(0);">'.$this->default_tooltip_text().'</a>
728
+ <p class="sbspf_tooltip sbspf_more_info">' . __( 'These are the specific ID numbers associated with a video or with a post. You can find the ID of a video by viewing the video on YouTube and copy/pasting the ID number from the end of the URL. ex. <code>https://www.youtube.com/watch?v=<span class="sbspf-highlight">Ij1KvL8eN</span></code>', $text_domain ) . '</p>'
729
+ );
730
+ $this->add_settings_field( $args );
731
+
732
+ $args = array(
733
+ 'title' => __( 'Custom Code Snippets', $text_domain ),
734
+ 'id' => 'sbspf_custom_snippets',
735
+ 'tab' => 'customize'
736
+ );
737
+ $this->add_settings_section( $args );
738
+
739
+ $args = array(
740
+ 'name' => 'custom_css',
741
+ 'default' => '',
742
+ 'section' => 'sbspf_custom_snippets',
743
+ 'callback' => 'textarea',
744
+ 'title' => __( 'Custom CSS', $text_domain ),
745
+ 'options' => $select_options,
746
+ 'tooltip_info' => __( 'Enter your own custom CSS in the box below', $text_domain )
747
+ );
748
+ $this->add_settings_field( $args );
749
+
750
+ $args = array(
751
+ 'name' => 'custom_js',
752
+ 'default' => '',
753
+ 'section' => 'sbspf_custom_snippets',
754
+ 'callback' => 'textarea',
755
+ 'title' => __( 'Custom JavaScript', $text_domain ),
756
+ 'options' => $select_options,
757
+ 'tooltip_info' => __( 'Enter your own custom JavaScript/jQuery in the box below', $text_domain ),
758
+ 'note' => __( 'Note: Custom JavaScript reruns every time more videos are loaded into the feed', $text_domain )
759
+ );
760
+ $this->add_settings_field( $args );
761
+
762
+ $args = array(
763
+ 'title' => __( 'GDPR', $text_domain ),
764
+ 'id' => 'sbspf_gdpr',
765
+ 'tab' => 'customize',
766
+ 'save_after' => 'true'
767
+ );
768
+ $this->add_settings_section( $args );
769
+
770
+ $this->add_settings_field( array(
771
+ 'name' => 'gdpr',
772
+ 'title' => __( 'Enable GDPR Settings', $text_domain ),
773
+ 'callback' => 'gdpr', // name of the function that outputs the html
774
+ 'section' => 'sbspf_gdpr', // matches the section name
775
+ ));
776
+
777
+ $args = array(
778
+ 'title' => __( 'Advanced', $text_domain ),
779
+ 'id' => 'sbspf_advanced',
780
+ 'tab' => 'customize',
781
+ 'save_after' => true
782
+ );
783
+ $this->add_settings_section( $args );
784
+
785
+ $args = array(
786
+ 'name' => 'preserve_settings',
787
+ 'section' => 'sbspf_advanced',
788
+ 'callback' => 'checkbox',
789
+ 'title' => __( 'Preserve settings when plugin is removed', $text_domain ),
790
+ 'default' => false,
791
+ 'tooltip_info' => __( 'When removing the plugin your settings are automatically erased. Checking this box will prevent any settings from being deleted. This means that you can uninstall and reinstall the plugin without losing your settings.', $text_domain )
792
+ );
793
+ $this->add_settings_field( $args );
794
+
795
+ $select_options = array(
796
+ array(
797
+ 'label' => __( 'Background', $text_domain ),
798
+ 'value' => 'background'
799
+ ),
800
+ array(
801
+ 'label' => __( 'Page', $text_domain ),
802
+ 'value' => 'page'
803
+ ),
804
+ array(
805
+ 'label' => __( 'None', $text_domain ),
806
+ 'value' => 'none'
807
+ )
808
+ );
809
+ $additional = '<input id="sby-clear-cache" class="button-secondary sbspf-button-action" data-sby-action="sby_delete_wp_posts" data-sby-confirm="'.esc_attr( 'This will permanently delete all YouTube posts from the wp_posts table and the related data in the postmeta table. Existing feeds will only have 15 or fewer videos available initially. Continue?', $text_domain ).'" style="margin-top: 1px;" type="submit" value="'.esc_attr( 'Clear YouTube Posts', $text_domain ).'">';
810
+ $args = array(
811
+ 'name' => 'storage_process',
812
+ 'default' => '',
813
+ 'section' => 'sbspf_advanced',
814
+ 'callback' => 'select',
815
+ 'title' => __( 'Local storage process', $text_domain ),
816
+ 'options' => $select_options,
817
+ 'additional' => $additional,
818
+ 'tooltip_info' => __( 'To preserve your feeds and videos even if the YouTube API is unavailable, a record of each video is added to the wp_posts table in the WordPress database. Please note that changing this setting to "none" will limit the number of posts available in the feed to 15 or less.', $text_domain )
819
+ );
820
+ $this->add_settings_field( $args );
821
+
822
+ $args = array(
823
+ 'name' => 'cronclear',
824
+ 'section' => 'sbspf_advanced',
825
+ 'callback' => 'checkbox',
826
+ 'title' => __( 'Cron Clear Cache', $text_domain ),
827
+ 'default' => false,
828
+ 'tooltip_info' => __( 'If your YouTube feed is not updating, your WordPress installation may have a rare issue with clearing temporary data in your database. Enable this setting to use WordPress cron to clear your feed caches.', $text_domain )
829
+ );
830
+ $this->add_settings_field( $args );
831
+
832
+ $args = array(
833
+ 'name' => 'ajaxtheme',
834
+ 'section' => 'sbspf_advanced',
835
+ 'callback' => 'checkbox',
836
+ 'title' => __( 'Are you using an AJAX theme?', $text_domain ),
837
+ 'default' => false,
838
+ 'tooltip_info' => __( 'When navigating your site, if your theme uses Ajax to load content into your pages (meaning your page doesn\'t refresh) then check this setting. If you\'re not sure then it\'s best to leave this setting unchecked while checking with your theme author, otherwise checking it may cause a problem.', $text_domain )
839
+ );
840
+ $this->add_settings_field( $args );
841
+
842
+ $args = array(
843
+ 'name' => 'customtemplates',
844
+ 'section' => 'sbspf_advanced',
845
+ 'callback' => 'checkbox',
846
+ 'title' => __( 'Enable Custom Templates', $text_domain ),
847
+ 'default' => false,
848
+ 'tooltip_info' => __( 'The default HTML for the feed can be replaced with custom templates added to your theme\'s folder. Enable this setting to use these templates. See <a href="https://smashballoon.com/youtube-custom-templates/" target="_blank">this guide</a>', $text_domain )
849
+ );
850
+ $this->add_settings_field( $args );
851
+
852
+ $args = array(
853
+ 'name' => 'eagerload',
854
+ 'section' => 'sbspf_advanced',
855
+ 'callback' => 'checkbox',
856
+ 'title' => __( 'Load Iframes on Page Load', $text_domain ),
857
+ 'default' => false,
858
+ 'tooltip_info' => __( 'To optimize the performance of your site and feeds, the plugin loads iframes only after a visitor interacts with the feed. Enabling this setting will cause YouTube player iframes to load when the page loads. Some features may work differently when this is enabled.', $text_domain )
859
+ );
860
+ $this->add_settings_field( $args );
861
+
862
+ }
863
+
864
+ public function cache( $args ) {
865
+ $social_network = $this->vars->social_network();
866
+ $type_selected = isset( $this->settings['caching_type'] ) ? $this->settings['caching_type'] : 'page';
867
+ $caching_time = isset( $this->settings['caching_time'] ) ? $this->settings['caching_time'] : 1;
868
+ $cache_time_unit_selected = isset( $this->settings['cache_time_unit'] ) ? $this->settings['cache_time_unit'] : 'hours';
869
+
870
+ $cache_cron_interval_selected = isset( $this->settings['cache_cron_interval'] ) ? $this->settings['cache_cron_interval'] : '';
871
+ $cache_cron_time = isset( $this->settings['cache_cron_time'] ) ? $this->settings['cache_cron_time'] : '';
872
+ $cache_cron_am_pm = isset( $this->settings['cache_cron_am_pm'] ) ? $this->settings['cache_cron_am_pm'] : '';
873
+
874
+ ?>
875
+ <div class="sbspf_cache_settings_wrap">
876
+ <div class="sbspf_row">
877
+ <input type="radio" name="<?php echo $this->option_name.'[caching_type]'; ?>" class="sbspf_caching_type_input" id="sbspf_caching_type_page" value="page"<?php if ( $type_selected === 'page' ) echo ' checked'?>>
878
+ <label class="sbspf_radio_label" for="sbspf_caching_type_page"><?php _e ( 'When the page loads', $this->vars->text_domain() ); ?></label>
879
+ <a class="sbspf_tooltip_link" href="JavaScript:void(0);" style="position: relative; top: 2px;"><?php echo $this->default_tooltip_text() ?></a>
880
+ <p class="sbspf_tooltip sbspf_more_info"><?php echo sprintf( __( "Your %s data is temporarily cached by the plugin in your WordPress database. There are two ways that you can set the plugin to check for new data:<br><br>
881
+ <b>1. When the page loads</b><br>Selecting this option means that when the cache expires then the plugin will check %s for new posts the next time that the feed is loaded. You can choose how long this data should be cached for with a minimum time of 15 minutes. If you set the time to 60 minutes then the plugin will clear the cached data after that length of time, and the next time the page is viewed it will check for new data. <b>Tip:</b> If you're experiencing an issue with the plugin not updating automatically then try enabling the setting labeled <b>'Force cache to clear on interval'</b> which is located on the 'Customize' tab.<br><br>
882
+ <b>2. In the background</b><br>Selecting this option means that the plugin will check for new data in the background so that the feed is updated behind the scenes. You can select at what time and how often the plugin should check for new data using the settings below. <b>Please note</b> that the plugin will initially check for data from Instagram when the page first loads, but then after that will check in the background on the schedule selected - unless the cache is cleared.", $this->vars->text_domain() ), $social_network, $social_network ); ?>
883
+ </p>
884
+ </div>
885
+ <div class="sbspf_row sbspf-caching-page-options" style="display: none;">
886
+ <?php _e ( 'Every', $this->vars->text_domain() ); ?>:
887
+ <input name="<?php echo $this->option_name.'[caching_time]'; ?>" type="text" value="<?php echo esc_attr( $caching_time ); ?>" size="4">
888
+ <select name="<?php echo $this->option_name.'[cache_time_unit]'; ?>">
889
+ <option value="minutes"<?php if ( $cache_time_unit_selected === 'minutes' ) echo ' selected'?>><?php _e ( 'Minutes', $this->vars->text_domain() ); ?></option>
890
+ <option value="hours"<?php if ( $cache_time_unit_selected === 'hours' ) echo ' selected'?>><?php _e ( 'Hours', $this->vars->text_domain() ); ?></option>
891
+ <option value="days"<?php if ( $cache_time_unit_selected === 'days' ) echo ' selected'?>><?php _e ( 'Days', $this->vars->text_domain() ); ?></option>
892
+ </select>
893
+ <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php _e ( 'What does this mean?', $this->vars->text_domain() ); ?></a>
894
+ <p class="sbspf_tooltip sbspf_more_info"><?php echo sprintf( __("Your %s posts are temporarily cached by the plugin in your WordPress database. You can choose how long the posts should be cached for. If you set the time to 1 hour then the plugin will clear the cache after that length of time and check %s for posts again.", $this->vars->text_domain() ), $social_network, $social_network ); ?></p>
895
+ </div>
896
+
897
+ <div class="sbspf_row">
898
+ <input type="radio" name="<?php echo $this->option_name.'[caching_type]'; ?>" id="sbspf_caching_type_cron" class="sbspf_caching_type_input" value="background" <?php if ( $type_selected === 'background' ) echo ' checked'?>>
899
+ <label class="sbspf_radio_label" for="sbspf_caching_type_cron"><?php _e ( 'In the background', $this->vars->text_domain() ); ?></label>
900
+ </div>
901
+ <div class="sbspf_row sbspf-caching-cron-options" style="display: block;">
902
+
903
+ <select name="<?php echo $this->option_name.'[cache_cron_interval]'; ?>" id="sbspf_cache_cron_interval">
904
+ <option value="30mins"<?php if ( $cache_cron_interval_selected === '30mins' ) echo ' selected'?>><?php _e ( 'Every 30 minutes', $this->vars->text_domain() ); ?></option>
905
+ <option value="1hour"<?php if ( $cache_cron_interval_selected === '1hour' ) echo ' selected'?>><?php _e ( 'Every hour', $this->vars->text_domain() ); ?></option>
906
+ <option value="12hours"<?php if ( $cache_cron_interval_selected === '12hours' ) echo ' selected'?>><?php _e ( 'Every 12 hours', $this->vars->text_domain() ); ?></option>
907
+ <option value="24hours"<?php if ( $cache_cron_interval_selected === '24hours' ) echo ' selected'?>><?php _e ( 'Every 24 hours', $this->vars->text_domain() ); ?></option>
908
+ </select>
909
+
910
+ <div id="sbspf-caching-time-settings" style="">
911
+ <?php _e ( 'at', $this->vars->text_domain() ); ?>
912
+ <select name="<?php echo $this->option_name.'[cache_cron_time]'; ?>" style="width: 80px">
913
+ <option value="1"<?php if ( (int)$cache_cron_time === 1 ) echo ' selected'?>>1:00</option>
914
+ <option value="2"<?php if ( (int)$cache_cron_time === 2 ) echo ' selected'?>>2:00</option>
915
+ <option value="3"<?php if ( (int)$cache_cron_time === 3 ) echo ' selected'?>>3:00</option>
916
+ <option value="4"<?php if ( (int)$cache_cron_time === 4 ) echo ' selected'?>>4:00</option>
917
+ <option value="5"<?php if ( (int)$cache_cron_time === 5 ) echo ' selected'?>>5:00</option>
918
+ <option value="6"<?php if ( (int)$cache_cron_time === 6 ) echo ' selected'?>>6:00</option>
919
+ <option value="7"<?php if ( (int)$cache_cron_time === 7 ) echo ' selected'?>>7:00</option>
920
+ <option value="8"<?php if ( (int)$cache_cron_time === 8 ) echo ' selected'?>>8:00</option>
921
+ <option value="9"<?php if ( (int)$cache_cron_time === 9 ) echo ' selected'?>>9:00</option>
922
+ <option value="10"<?php if ( (int)$cache_cron_time === 10 ) echo ' selected'?>>10:00</option>
923
+ <option value="11"<?php if ( (int)$cache_cron_time === 11 ) echo ' selected'?>>11:00</option>
924
+ <option value="0"<?php if ( (int)$cache_cron_time === 0 ) echo ' selected'?>>12:00</option>
925
+ </select>
926
+
927
+ <select name="<?php echo $this->option_name.'[cache_cron_am_pm]'; ?>" style="width: 50px">
928
+ <option value="am"<?php if ( $cache_cron_am_pm === 'am' ) echo ' selected'?>><?php _e ( 'AM', $this->vars->text_domain() ); ?></option>
929
+ <option value="pm"<?php if ( $cache_cron_am_pm === 'pm' ) echo ' selected'?>><?php _e ( 'PM', $this->vars->text_domain() ); ?></option>
930
+ </select>
931
+ </div>
932
+
933
+ <?php
934
+ if ( wp_next_scheduled( 'sbspf_feed_update' ) ) {
935
+ $time_format = get_option( 'time_format' );
936
+ if ( ! $time_format ) {
937
+ $time_format = 'g:i a';
938
+ }
939
+ //
940
+ $schedule = wp_get_schedule( 'sbspf_feed_update' );
941
+ if ( $schedule == '30mins' ) $schedule = __( 'every 30 minutes', $this->vars->text_domain() );
942
+ if ( $schedule == 'twicedaily' ) $schedule = __( 'every 12 hours', $this->vars->text_domain() );
943
+ $sbspf_next_cron_event = wp_next_scheduled( 'sbspf_feed_update' );
944
+ echo '<p class="sbspf-caching-sched-notice"><span><b>' . __( 'Next check', $this->vars->text_domain() ) . ': ' . date( $time_format, $sbspf_next_cron_event + sbspf_get_utc_offset() ) . ' (' . $schedule . ')</b> - ' . __( 'Note: Saving the settings on this page will clear the cache and reset this schedule', $this->vars->text_domain() ) . '</span></p>';
945
+ } else {
946
+ echo '<p style="font-size: 11px; color: #666;">' . __( 'Nothing currently scheduled', $this->vars->text_domain() ) . '</p>';
947
+ }
948
+ ?>
949
+ </div>
950
+ </div>
951
+ <?php
952
+ }
953
+
954
+ public function gdpr( $args ) {
955
+ $gdpr = ( isset( $this->settings['gdpr'] ) ) ? $this->settings['gdpr'] : 'auto';
956
+ $select_options = array(
957
+ array(
958
+ 'label' => __( 'Automatic', 'youtube-feed' ),
959
+ 'value' => 'auto'
960
+ ),
961
+ array(
962
+ 'label' => __( 'Yes', 'youtube-feed' ),
963
+ 'value' => 'yes'
964
+ ),
965
+ array(
966
+ 'label' => __( 'No', 'youtube-feed' ),
967
+ 'value' => 'no'
968
+ )
969
+ )
970
+ ?>
971
+ <?php
972
+ $gdpr_list = "<ul class='sby-list'>
973
+ <li>" . __('YouTube Player API will not be loaded.', 'youtube-feed') . "</li>
974
+ <li>" . __('Thumbnail images for videos will display instead of actual video.', 'youtube-feed') . "</li>
975
+ <li>" . __('To view videos, visitors will click on links to view the video on youtube.com.', 'youtube-feed') . "</li>
976
+ </ul>";
977
+ ?>
978
+ <div>
979
+ <select name="<?php echo $this->option_name.'[gdpr]'; ?>" id="sbspf_gdpr_setting">
980
+ <?php foreach ( $select_options as $select_option ) :
981
+ $selected = $select_option['value'] === $gdpr ? ' selected' : '';
982
+ ?>
983
+ <option value="<?php echo esc_attr( $select_option['value'] ); ?>"<?php echo $selected; ?> ><?php echo esc_html( $select_option['label'] ); ?></option>
984
+ <?php endforeach; ?>
985
+ </select>
986
+ <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $this->default_tooltip_text(); ?></a>
987
+ <div class="sbspf_tooltip sbspf_more_info gdpr_tooltip">
988
+
989
+ <p><span><?php _e("Yes", 'youtube-feed' ); ?>:</span> <?php _e("Enabling this setting prevents all videos and external code from loading on your website. To accommodate this, some features of the plugin will be disabled or limited.", 'youtube-feed' ); ?> <a href="JavaScript:void(0);" class="sbspf_show_gdpr_list"><?php _e( 'What will be limited?', 'youtube-feed' ); ?></a></p>
990
+
991
+ <?php echo "<div class='sbspf_gdpr_list'>" . $gdpr_list . '</div>'; ?>
992
+
993
+
994
+ <p><span><?php _e("No", 'youtube-feed' ); ?>:</span> <?php _e("The plugin will still make some requests to display and play videos directly from YouTube.", 'youtube-feed' ); ?></p>
995
+
996
+
997
+ <p><span><?php _e("Automatic", 'youtube-feed' ); ?>:</span> <?php echo sprintf( __( 'The plugin will only videos if consent has been given by one of these integrated %s', 'youtube-feed' ), '<a href="https://smashballoon.com/doc/gdpr-plugin-list/?youtube" target="_blank" rel="noopener">' . __( 'GDPR cookie plugins', 'youtube-feed' ) . '</a>' ); ?></p>
998
+
999
+ <p><?php echo sprintf( __( '%s to learn more about GDPR compliance in the Feeds for YouTube plugin.', 'youtube-feed' ), '<a href="https://smashballoon.com/doc/feeds-for-youtube-gdpr-compliance/?youtube" target="_blank" rel="noopener">'. __( 'Click here', 'youtube-feed' ).'</a>' ); ?></p>
1000
+ </div>
1001
+ </div>
1002
+
1003
+ <div id="sbspf_images_options" class="sbspf_box">
1004
+ <div class="sbspf_box_setting">
1005
+ <?php
1006
+ $checked = isset( $this->settings['disablecdn'] ) && $this->settings['disablecdn'] ? ' checked' : false;
1007
+ ?>
1008
+ <input name="<?php echo $this->option_name.'[disablecdn]'; ?>" id="sbspf_disablecdn" class="sbspf_single_checkbox" type="checkbox"<?php echo $checked; ?>>
1009
+ <label for="sbspf_disablecdn"><?php _e("Block CDN Images", 'youtube-feed' ); ?></label>
1010
+ <a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php echo $this->default_tooltip_text(); ?></a>
1011
+ <div class="sbspf_tooltip sbspf_more_info">
1012
+ <?php _e("Images in the feed come from YouTube's CDN. Enabling this setting will show a placeholder image until consent is given.", 'youtube-feed' ); ?>
1013
+ </div>
1014
+ </div>
1015
+ </div>
1016
+
1017
+ <?php if ( ! SBY_GDPR_Integrations::gdpr_tests_successful( isset( $_GET['retest'] ) ) ) :
1018
+ $errors = SBY_GDPR_Integrations::gdpr_tests_error_message();
1019
+ ?>
1020
+ <div class="sbspf_box sbspf_gdpr_error">
1021
+ <div class="sbspf_box_setting">
1022
+ <p>
1023
+ <strong><?php _e( 'Error:', 'youtube-feed' ); ?></strong> <?php _e("Due to a configuration issue on your web server, the GDPR setting is unable to be enabled. Please see below for more information.", 'youtube-feed' ); ?></p>
1024
+ <p>
1025
+ <?php echo $errors; ?>
1026
+ </p>
1027
+ </div>
1028
+ </div>
1029
+ <?php else: ?>
1030
+
1031
+ <div class="sbspf_gdpr_auto">
1032
+ <?php if ( SBY_GDPR_Integrations::gdpr_plugins_active() ) :
1033
+ $active_plugin = SBY_GDPR_Integrations::gdpr_plugins_active();
1034
+ ?>
1035
+ <div class="sbspf_gdpr_plugin_active">
1036
+ <div class="sbspf_active">
1037
+ <p>
1038
+ <svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="check-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-check-circle fa-w-16 fa-2x"><path fill="currentColor" d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z" class=""></path></svg>
1039
+ <b><?php echo sprintf( __( '%s detected', 'youtube-feed' ), $active_plugin ); ?></b>
1040
+ <br />
1041
+ <?php _e( 'Some Feeds for YouTube features will be limited for visitors to ensure GDPR compliance until they give consent.', 'youtube-feed' ); ?>
1042
+ <a href="JavaScript:void(0);" class="sbspf_show_gdpr_list"><?php _e( 'What will be limited?', 'youtube-feed' ); ?></a>
1043
+ </p>
1044
+ <?php echo "<div class='sbspf_gdpr_list'>" . $gdpr_list . '</div>'; ?>
1045
+ </div>
1046
+
1047
+ </div>
1048
+ <?php else: ?>
1049
+ <div class="sbspf_box">
1050
+ <div class="sbspf_box_setting">
1051
+ <p><?php _e( 'No GDPR consent plugin detected. Install a compatible <a href="https://smashballoon.com/doc/gdpr-plugin-list/?youtube">GDPR consent plugin</a>, or manually enable the setting above to display a GDPR compliant version of the feed to all visitors.', 'youtube-feed' ); ?></p>
1052
+ </div>
1053
+ </div>
1054
+ <?php endif; ?>
1055
+ </div>
1056
+
1057
+ <div class="sbspf_box sbspf_gdpr_yes">
1058
+ <div class="sbspf_box_setting">
1059
+ <p><?php _e( "No requests will be made to third-party websites. To accommodate this, some features of the plugin will be limited:", 'youtube-feed' ); ?></p>
1060
+ <?php echo $gdpr_list; ?>
1061
+ </div>
1062
+ </div>
1063
+
1064
+ <div class="sbspf_box sbspf_gdpr_no">
1065
+ <div class="sbspf_box_setting">
1066
+ <p><?php _e( "The plugin will function as normal and load images and videos directly from Twitter.", 'youtube-feed' ); ?></p>
1067
+ </div>
1068
+ </div>
1069
+
1070
+ <?php endif;
1071
+ }
1072
+
1073
+ public function get_connected_accounts() {
1074
+ global $sby_settings;
1075
+
1076
+ if ( isset( $sby_settings['connected_accounts'] ) ) {
1077
+ return $sby_settings['connected_accounts'];
1078
+ }
1079
+ return array();
1080
+ }
1081
+
1082
+ public function access_token_listener() {
1083
+ if ( isset( $_GET['page'] ) && $_GET['page'] === SBY_SLUG && isset( $_GET['sby_access_token'] ) ) {
1084
+ sby_attempt_connection();
1085
+ }
1086
+ }
1087
+
1088
+ public static function connect_account( $args ) {
1089
+ sby_update_or_connect_account( $args );
1090
+ }
1091
+ }
inc/admin/class-sby-new-user.php CHANGED
@@ -1,400 +1,400 @@
1
- <?php
2
- /**
3
- * SBY_New_User.
4
- *
5
- * @since 2.18
6
- */
7
-
8
- // Exit if accessed directly
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class SBY_New_User extends SBY_Notifications {
14
-
15
- /**
16
- * Source of notifications content.
17
- *
18
- * @since 2.18
19
- *
20
- * @var string
21
- */
22
- const SOURCE_URL = 'http://plugin.smashballoon.com/newuser.json';
23
-
24
- /**
25
- * @var string
26
- */
27
- const OPTION_NAME = 'sby_newuser_notifications';
28
-
29
- /**
30
- * Register hooks.
31
- *
32
- * @since 2.18
33
- */
34
- public function hooks() {
35
- add_action( 'admin_notices', array( $this, 'output' ), 8 );
36
-
37
- add_action( 'admin_init', array( $this, 'dismiss' ) );
38
- }
39
-
40
- public function option_name() {
41
- return self::OPTION_NAME;
42
- }
43
-
44
- public function source_url() {
45
- return self::SOURCE_URL;
46
- }
47
-
48
- /**
49
- * Verify notification data before it is saved.
50
- *
51
- * @param array $notifications Array of notifications items to verify.
52
- *
53
- * @return array
54
- *
55
- * @since 2.18
56
- */
57
- public function verify( $notifications ) {
58
- $data = array();
59
-
60
- if ( ! is_array( $notifications ) || empty( $notifications ) ) {
61
- return $data;
62
- }
63
-
64
- $option = $this->get_option();
65
-
66
- foreach ( $notifications as $key => $notification ) {
67
-
68
- // The message should never be empty, if they are, ignore.
69
- if ( empty( $notification['content'] ) ) {
70
- continue;
71
- }
72
-
73
- // Ignore if notification has already been dismissed.
74
- if ( ! empty( $option['dismissed'] ) && in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
75
- continue;
76
- }
77
-
78
- $data[ $key ] = $notification;
79
- }
80
-
81
- return $data;
82
- }
83
-
84
- /**
85
- * Verify saved notification data for active notifications.
86
- *
87
- * @since 2.18
88
- *
89
- * @param array $notifications Array of notifications items to verify.
90
- *
91
- * @return array
92
- */
93
- public function verify_active( $notifications ) {
94
- if ( ! is_array( $notifications ) || empty( $notifications ) ) {
95
- return array();
96
- }
97
-
98
- $sby_statuses_option = get_option( 'sby_statuses', array() );
99
- $current_time = sby_get_current_time();
100
-
101
- // rating notice logic
102
- $sby_rating_notice_option = get_option( 'sby_rating_notice', false );
103
- $sby_rating_notice_waiting = get_transient( 'feeds_for_youtube_rating_notice_waiting' );
104
- $should_show_rating_notice = ($sby_rating_notice_waiting !== 'waiting' && $sby_rating_notice_option !== 'dismissed');
105
-
106
- // new user discount logic
107
- $in_new_user_month_range = true;
108
- $should_show_new_user_discount = false;
109
- $has_been_one_month_since_rating_dismissal = isset( $sby_statuses_option['rating_notice_dismissed'] ) ? ((int)$sby_statuses_option['rating_notice_dismissed'] + ((int)$notifications['review']['wait'] * DAY_IN_SECONDS)) < $current_time + 1: true;
110
-
111
- if ( isset( $sby_statuses_option['first_install'] ) && $sby_statuses_option['first_install'] === 'from_update' ) {
112
- global $current_user;
113
- $user_id = $current_user->ID;
114
- $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sby_ignore_new_user_sale_notice' );
115
- $ignore_new_user_sale_notice_meta = isset( $ignore_new_user_sale_notice_meta[0] ) ? $ignore_new_user_sale_notice_meta[0] : '';
116
- if ( $ignore_new_user_sale_notice_meta !== 'always' ) {
117
- $should_show_new_user_discount = true;
118
- }
119
- } elseif ( $in_new_user_month_range && $has_been_one_month_since_rating_dismissal && $sby_rating_notice_waiting !== 'waiting' ) {
120
- global $current_user;
121
- $user_id = $current_user->ID;
122
- $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sby_ignore_new_user_sale_notice' );
123
- $ignore_new_user_sale_notice_meta = isset( $ignore_new_user_sale_notice_meta[0] ) ? $ignore_new_user_sale_notice_meta[0] : '';
124
-
125
- if ( $ignore_new_user_sale_notice_meta !== 'always'
126
- && isset( $sby_statuses_option['first_install'] )
127
- && $current_time > (int)$sby_statuses_option['first_install'] + ((int)$notifications['discount']['wait'] * DAY_IN_SECONDS) ) {
128
- $should_show_new_user_discount = true;
129
- }
130
- }
131
-
132
- if ( isset( $notifications['review'] ) && $should_show_rating_notice ) {
133
- return array( $notifications['review'] );
134
- } elseif ( isset( $notifications['discount'] ) && $should_show_new_user_discount ) {
135
- return array( $notifications['discount'] );
136
- }
137
-
138
- return array();
139
- }
140
-
141
- /**
142
- * Get notification data.
143
- *
144
- * @since 2.18
145
- *
146
- * @return array
147
- */
148
- public function get() {
149
- if ( ! $this->has_access() ) {
150
- return array();
151
- }
152
-
153
- $option = $this->get_option();
154
-
155
- // Only update if does not exist.
156
- if ( empty( $option['update'] ) ) {
157
- $this->update();
158
- }
159
-
160
- $events = ! empty( $option['events'] ) ? $this->verify_active( $option['events'] ) : array();
161
- $feed = ! empty( $option['feed'] ) ? $this->verify_active( $option['feed'] ) : array();
162
-
163
- return array_merge( $events, $feed );
164
- }
165
-
166
- /**
167
- * Add a manual notification event.
168
- *
169
- * @since 2.18
170
- *
171
- * @param array $notification Notification data.
172
- */
173
- public function add( $notification ) {
174
- if ( empty( $notification['id'] ) ) {
175
- return;
176
- }
177
-
178
- $option = $this->get_option();
179
-
180
- if ( in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
181
- return;
182
- }
183
-
184
- foreach ( $option['events'] as $item ) {
185
- if ( $item['id'] === $notification['id'] ) {
186
- return;
187
- }
188
- }
189
-
190
- $notification = $this->verify( array( $notification ) );
191
-
192
- update_option(
193
- $this->option_name(),
194
- array(
195
- 'update' => $option['update'],
196
- 'feed' => $option['feed'],
197
- 'events' => array_merge( $notification, $option['events'] ),
198
- 'dismissed' => $option['dismissed'],
199
- )
200
- );
201
- }
202
-
203
- /**
204
- * Update notification data from feed.
205
- *
206
- * @since 2.18
207
- */
208
- public function update() {
209
- $feed = $this->fetch_feed();
210
- $option = $this->get_option();
211
-
212
- update_option(
213
- $this->option_name(),
214
- array(
215
- 'update' => time(),
216
- 'feed' => $feed,
217
- 'events' => $option['events'],
218
- 'dismissed' => $option['dismissed'],
219
- )
220
- );
221
- }
222
-
223
- /**
224
- * Do not enqueue anything extra.
225
- *
226
- * @since 2.18
227
- */
228
- public function enqueues() {
229
-
230
- }
231
-
232
- /**
233
- * Output notifications on Form Overview admin area.
234
- *
235
- * @since 2.18
236
- */
237
- public function output() {
238
- // If the Instagram Feed plugin is active, notices only shown on SBY Settings pages
239
- if ( function_exists( 'sb_instagram_activate' )
240
- && ! function_exists( 'sb_instagram_feed_pro_init' ) ) {
241
- return;
242
- }
243
-
244
- if ( function_exists( 'cff_check_for_db_updates' ) ) {
245
- return;
246
- }
247
-
248
- if ( function_exists( 'ctf_check_for_db_updates' ) ) {
249
- return;
250
- }
251
-
252
- $notifications = $this->get();
253
-
254
- if ( empty( $notifications ) ) {
255
- return;
256
- }
257
-
258
- // new user notices included in regular settings page notifications so this
259
- // checks to see if user is one of those pages
260
- if ( ! empty( $_GET['page'] )
261
- && strpos( $_GET['page'], 'youtube-feed' ) !== false ) {
262
- return;
263
- }
264
-
265
- $content_allowed_tags = array(
266
- 'em' => array(),
267
- 'strong' => array(),
268
- 'span' => array(
269
- 'style' => array(),
270
- ),
271
- 'a' => array(
272
- 'href' => array(),
273
- 'target' => array(),
274
- 'rel' => array(),
275
- ),
276
- );
277
- $image_overlay = '';
278
-
279
- foreach ( $notifications as $notification ) {
280
- $type = sanitize_text_field( $notification['id'] );
281
- $img_src = SBY_PLUGIN_URL . 'img/' . sanitize_text_field( $notification['image'] );
282
- $content = '';
283
- if ( ! empty( $notification['content'] ) ) {
284
- $content = wp_kses( $this->replace_merge_fields( $notification['content'], $notification ), $content_allowed_tags );
285
- }
286
- $buttons = array();
287
- if ( ! empty( $notification['btns'] ) && is_array( $notification['btns'] ) ) {
288
- foreach ( $notification['btns'] as $btn_type => $btn ) {
289
- if ( ! is_array( $btn['url'] ) ) {
290
- $buttons[ $btn_type ]['url'] = $this->replace_merge_fields( $btn['url'], $notification );
291
- } elseif ( is_array( $btn['url'] ) ) {
292
- $buttons[ $btn_type ]['url'] = add_query_arg( $btn['url'] );
293
- }
294
-
295
- $buttons[ $btn_type ]['attr'] = '';
296
- if ( ! empty( $btn['attr'] ) ) {
297
- $buttons[ $btn_type ]['attr'] = ' target="_blank" rel="noopener noreferrer"';
298
- }
299
-
300
- $buttons[ $btn_type ]['class'] = '';
301
- if ( ! empty( $btn['class'] ) ) {
302
- $buttons[ $btn_type ]['class'] = ' ' . $btn['class'];
303
- }
304
-
305
- $buttons[ $btn_type ]['text'] = '';
306
- if ( ! empty( $btn['text'] ) ) {
307
- $buttons[ $btn_type ]['text'] = wp_kses( $btn['text'], $content_allowed_tags );
308
- }
309
- }
310
- }
311
- if ( isset( $notification['image_overlay'] ) ) {
312
- $image_overlay = '<div class="img-overlay">'. esc_html( $notification['image_overlay'] ).'</div>';
313
- }
314
- }
315
- ?>
316
-
317
- <div class="sby_notice sby_<?php echo esc_attr( $type ); ?>_notice">
318
- <div class="sby_thumb">
319
- <img src="<?php echo esc_url( $img_src ); ?>" alt="notice">
320
- <?php echo $image_overlay; ?>
321
- </div>
322
- <div class="sby-notice-text">
323
- <p style="padding-top: 4px;"><?php echo $content; ?></p>
324
- <p class="links">
325
- <?php foreach ( $buttons as $button ) : ?>
326
- <a class="<?php echo esc_attr( $button['class'] ); ?>" href="<?php echo esc_attr( $button['url'] ); ?>"<?php echo $button['attr']; ?>><?php echo $button['text']; ?></a>
327
- <?php endforeach; ?>
328
- </p>
329
- </div>
330
- <a class="sby_notice_close" href="<?php echo add_query_arg( array( 'sby_dismiss' => $type ) ); ?>"><i class="fa fa-close"></i></a>
331
- </div>
332
- <?php
333
- }
334
-
335
- /**
336
- * Hide messages permanently or some can be dismissed temporarily
337
- *
338
- * @since 2.18
339
- */
340
- public function dismiss() {
341
- global $current_user;
342
- $user_id = $current_user->ID;
343
- $sby_statuses_option = get_option( 'sby_statuses', array() );
344
-
345
- if ( isset( $_GET['sby_ignore_rating_notice_nag'] ) ) {
346
- if ( (int)$_GET['sby_ignore_rating_notice_nag'] === 1 ) {
347
- update_option( 'sby_rating_notice', 'dismissed', false );
348
- $sby_statuses_option['rating_notice_dismissed'] = sby_get_current_time();
349
- update_option( 'sby_statuses', $sby_statuses_option, false );
350
-
351
- } elseif ( $_GET['sby_ignore_rating_notice_nag'] === 'later' ) {
352
- set_transient( 'feeds_for_youtube_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS );
353
- update_option( 'sby_rating_notice', 'pending', false );
354
- }
355
- }
356
-
357
- if ( isset( $_GET['sby_ignore_new_user_sale_notice'] ) ) {
358
- $response = sanitize_text_field( $_GET['sby_ignore_new_user_sale_notice'] );
359
- if ( $response === 'always' ) {
360
- update_user_meta( $user_id, 'sby_ignore_new_user_sale_notice', 'always' );
361
-
362
- $current_month_number = (int)date('n', sby_get_current_time() );
363
- $not_early_in_the_year = ($current_month_number > 5);
364
-
365
- if ( $not_early_in_the_year ) {
366
- update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', date( 'Y', sby_get_current_time() ) );
367
- }
368
-
369
- }
370
- }
371
-
372
- if ( isset( $_GET['sby_ignore_bfcm_sale_notice'] ) ) {
373
- $response = sanitize_text_field( $_GET['sby_ignore_bfcm_sale_notice'] );
374
- if ( $response === 'always' ) {
375
- update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', 'always' );
376
- } elseif ( $response === date( 'Y', sby_get_current_time() ) ) {
377
- update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', date( 'Y', sby_get_current_time() ) );
378
- }
379
- update_user_meta( $user_id, 'sby_ignore_new_user_sale_notice', 'always' );
380
- }
381
-
382
- if ( isset( $_GET['sby_dismiss'] ) ) {
383
- if ( $_GET['sby_dismiss'] === 'review' ) {
384
- update_option( 'sby_rating_notice', 'dismissed', false );
385
- $sby_statuses_option['rating_notice_dismissed'] = sby_get_current_time();
386
- update_option( 'sby_statuses', $sby_statuses_option, false );
387
- } elseif ( $_GET['sby_dismiss'] === 'discount' ) {
388
- update_user_meta( $user_id, 'sby_ignore_new_user_sale_notice', 'always' );
389
-
390
- $current_month_number = (int)date('n', sby_get_current_time() );
391
- $not_early_in_the_year = ($current_month_number > 5);
392
-
393
- if ( $not_early_in_the_year ) {
394
- update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', date( 'Y', sby_get_current_time() ) );
395
- }
396
- }
397
- update_user_meta( $user_id, 'sby_ignore_new_user_sale_notice', 'always' );
398
- }
399
- }
400
- }
1
+ <?php
2
+ /**
3
+ * SBY_New_User.
4
+ *
5
+ * @since 2.18
6
+ */
7
+
8
+ // Exit if accessed directly
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class SBY_New_User extends SBY_Notifications {
14
+
15
+ /**
16
+ * Source of notifications content.
17
+ *
18
+ * @since 2.18
19
+ *
20
+ * @var string
21
+ */
22
+ const SOURCE_URL = 'http://plugin.smashballoon.com/newuser.json';
23
+
24
+ /**
25
+ * @var string
26
+ */
27
+ const OPTION_NAME = 'sby_newuser_notifications';
28
+
29
+ /**
30
+ * Register hooks.
31
+ *
32
+ * @since 2.18
33
+ */
34
+ public function hooks() {
35
+ add_action( 'admin_notices', array( $this, 'output' ), 8 );
36
+
37
+ add_action( 'admin_init', array( $this, 'dismiss' ) );
38
+ }
39
+
40
+ public function option_name() {
41
+ return self::OPTION_NAME;
42
+ }
43
+
44
+ public function source_url() {
45
+ return self::SOURCE_URL;
46
+ }
47
+
48
+ /**
49
+ * Verify notification data before it is saved.
50
+ *
51
+ * @param array $notifications Array of notifications items to verify.
52
+ *
53
+ * @return array
54
+ *
55
+ * @since 2.18
56
+ */
57
+ public function verify( $notifications ) {
58
+ $data = array();
59
+
60
+ if ( ! is_array( $notifications ) || empty( $notifications ) ) {
61
+ return $data;
62
+ }
63
+
64
+ $option = $this->get_option();
65
+
66
+ foreach ( $notifications as $key => $notification ) {
67
+
68
+ // The message should never be empty, if they are, ignore.
69
+ if ( empty( $notification['content'] ) ) {
70
+ continue;
71
+ }
72
+
73
+ // Ignore if notification has already been dismissed.
74
+ if ( ! empty( $option['dismissed'] ) && in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
75
+ continue;
76
+ }
77
+
78
+ $data[ $key ] = $notification;
79
+ }
80
+
81
+ return $data;
82
+ }
83
+
84
+ /**
85
+ * Verify saved notification data for active notifications.
86
+ *
87
+ * @since 2.18
88
+ *
89
+ * @param array $notifications Array of notifications items to verify.
90
+ *
91
+ * @return array
92
+ */
93
+ public function verify_active( $notifications ) {
94
+ if ( ! is_array( $notifications ) || empty( $notifications ) ) {
95
+ return array();
96
+ }
97
+
98
+ $sby_statuses_option = get_option( 'sby_statuses', array() );
99
+ $current_time = sby_get_current_time();
100
+
101
+ // rating notice logic
102
+ $sby_rating_notice_option = get_option( 'sby_rating_notice', false );
103
+ $sby_rating_notice_waiting = get_transient( 'feeds_for_youtube_rating_notice_waiting' );
104
+ $should_show_rating_notice = ($sby_rating_notice_waiting !== 'waiting' && $sby_rating_notice_option !== 'dismissed');
105
+
106
+ // new user discount logic
107
+ $in_new_user_month_range = true;
108
+ $should_show_new_user_discount = false;
109
+ $has_been_one_month_since_rating_dismissal = isset( $sby_statuses_option['rating_notice_dismissed'] ) ? ((int)$sby_statuses_option['rating_notice_dismissed'] + ((int)$notifications['review']['wait'] * DAY_IN_SECONDS)) < $current_time + 1: true;
110
+
111
+ if ( isset( $sby_statuses_option['first_install'] ) && $sby_statuses_option['first_install'] === 'from_update' ) {
112
+ global $current_user;
113
+ $user_id = $current_user->ID;
114
+ $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sby_ignore_new_user_sale_notice' );
115
+ $ignore_new_user_sale_notice_meta = isset( $ignore_new_user_sale_notice_meta[0] ) ? $ignore_new_user_sale_notice_meta[0] : '';
116
+ if ( $ignore_new_user_sale_notice_meta !== 'always' ) {
117
+ $should_show_new_user_discount = true;
118
+ }
119
+ } elseif ( $in_new_user_month_range && $has_been_one_month_since_rating_dismissal && $sby_rating_notice_waiting !== 'waiting' ) {
120
+ global $current_user;
121
+ $user_id = $current_user->ID;
122
+ $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sby_ignore_new_user_sale_notice' );
123
+ $ignore_new_user_sale_notice_meta = isset( $ignore_new_user_sale_notice_meta[0] ) ? $ignore_new_user_sale_notice_meta[0] : '';
124
+
125
+ if ( $ignore_new_user_sale_notice_meta !== 'always'
126
+ && isset( $sby_statuses_option['first_install'] )
127
+ && $current_time > (int)$sby_statuses_option['first_install'] + ((int)$notifications['discount']['wait'] * DAY_IN_SECONDS) ) {
128
+ $should_show_new_user_discount = true;
129
+ }
130
+ }
131
+
132
+ if ( isset( $notifications['review'] ) && $should_show_rating_notice ) {
133
+ return array( $notifications['review'] );
134
+ } elseif ( isset( $notifications['discount'] ) && $should_show_new_user_discount ) {
135
+ return array( $notifications['discount'] );
136
+ }
137
+
138
+ return array();
139
+ }
140
+
141
+ /**
142
+ * Get notification data.
143
+ *
144
+ * @since 2.18
145
+ *
146
+ * @return array
147
+ */
148
+ public function get() {
149
+ if ( ! $this->has_access() ) {
150
+ return array();
151
+ }
152
+
153
+ $option = $this->get_option();
154
+
155
+ // Only update if does not exist.
156
+ if ( empty( $option['update'] ) ) {
157
+ $this->update();
158
+ }
159
+
160
+ $events = ! empty( $option['events'] ) ? $this->verify_active( $option['events'] ) : array();
161
+ $feed = ! empty( $option['feed'] ) ? $this->verify_active( $option['feed'] ) : array();
162
+
163
+ return array_merge( $events, $feed );
164
+ }
165
+
166
+ /**
167
+ * Add a manual notification event.
168
+ *
169
+ * @since 2.18
170
+ *
171
+ * @param array $notification Notification data.
172
+ */
173
+ public function add( $notification ) {
174
+ if ( empty( $notification['id'] ) ) {
175
+ return;
176
+ }
177
+
178
+ $option = $this->get_option();
179
+
180
+ if ( in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
181
+ return;
182
+ }
183
+
184
+ foreach ( $option['events'] as $item ) {
185
+ if ( $item['id'] === $notification['id'] ) {
186
+ return;
187
+ }
188
+ }
189
+
190
+ $notification = $this->verify( array( $notification ) );
191
+
192
+ update_option(
193
+ $this->option_name(),
194
+ array(
195
+ 'update' => $option['update'],
196
+ 'feed' => $option['feed'],
197
+ 'events' => array_merge( $notification, $option['events'] ),
198
+ 'dismissed' => $option['dismissed'],
199
+ )
200
+ );
201
+ }
202
+
203
+ /**
204
+ * Update notification data from feed.
205
+ *
206
+ * @since 2.18
207
+ */
208
+ public function update() {
209
+ $feed = $this->fetch_feed();
210
+ $option = $this->get_option();
211
+
212
+ update_option(
213
+ $this->option_name(),
214
+ array(
215
+ 'update' => time(),
216
+ 'feed' => $feed,
217
+ 'events' => $option['events'],
218
+ 'dismissed' => $option['dismissed'],
219
+ )
220
+ );
221
+ }
222
+
223
+ /**
224
+ * Do not enqueue anything extra.
225
+ *
226
+ * @since 2.18
227
+ */
228
+ public function enqueues() {
229
+
230
+ }
231
+
232
+ /**
233
+ * Output notifications on Form Overview admin area.
234
+ *
235
+ * @since 2.18
236
+ */
237
+ public function output() {
238
+ // If the Instagram Feed plugin is active, notices only shown on SBY Settings pages
239
+ if ( function_exists( 'sb_instagram_activate' )
240
+ && ! function_exists( 'sb_instagram_feed_pro_init' ) ) {
241
+ return;
242
+ }
243
+
244
+ if ( function_exists( 'cff_check_for_db_updates' ) ) {
245
+ return;
246
+ }
247
+
248
+ if ( function_exists( 'ctf_check_for_db_updates' ) ) {
249
+ return;
250
+ }
251
+
252
+ $notifications = $this->get();
253
+
254
+ if ( empty( $notifications ) ) {
255
+ return;
256
+ }
257
+
258
+ // new user notices included in regular settings page notifications so this
259
+ // checks to see if user is one of those pages
260
+ if ( ! empty( $_GET['page'] )
261
+ && strpos( $_GET['page'], 'youtube-feed' ) !== false ) {
262
+ return;
263
+ }
264
+
265
+ $content_allowed_tags = array(
266
+ 'em' => array(),
267
+ 'strong' => array(),
268
+ 'span' => array(
269
+ 'style' => array(),
270
+ ),
271
+ 'a' => array(
272
+ 'href' => array(),
273
+ 'target' => array(),
274
+ 'rel' => array(),
275
+ ),
276
+ );
277
+ $image_overlay = '';
278
+
279
+ foreach ( $notifications as $notification ) {
280
+ $type = sanitize_text_field( $notification['id'] );
281
+ $img_src = SBY_PLUGIN_URL . 'img/' . sanitize_text_field( $notification['image'] );
282
+ $content = '';
283
+ if ( ! empty( $notification['content'] ) ) {
284
+ $content = wp_kses( $this->replace_merge_fields( $notification['content'], $notification ), $content_allowed_tags );
285
+ }
286
+ $buttons = array();
287
+ if ( ! empty( $notification['btns'] ) && is_array( $notification['btns'] ) ) {
288
+ foreach ( $notification['btns'] as $btn_type => $btn ) {
289
+ if ( ! is_array( $btn['url'] ) ) {
290
+ $buttons[ $btn_type ]['url'] = $this->replace_merge_fields( $btn['url'], $notification );
291
+ } elseif ( is_array( $btn['url'] ) ) {
292
+ $buttons[ $btn_type ]['url'] = add_query_arg( $btn['url'] );
293
+ }
294
+
295
+ $buttons[ $btn_type ]['attr'] = '';
296
+ if ( ! empty( $btn['attr'] ) ) {
297
+ $buttons[ $btn_type ]['attr'] = ' target="_blank" rel="noopener noreferrer"';
298
+ }
299
+
300
+ $buttons[ $btn_type ]['class'] = '';
301
+ if ( ! empty( $btn['class'] ) ) {
302
+ $buttons[ $btn_type ]['class'] = ' ' . $btn['class'];
303
+ }
304
+
305
+ $buttons[ $btn_type ]['text'] = '';
306
+ if ( ! empty( $btn['text'] ) ) {
307
+ $buttons[ $btn_type ]['text'] = wp_kses( $btn['text'], $content_allowed_tags );
308
+ }
309
+ }
310
+ }
311
+ if ( isset( $notification['image_overlay'] ) ) {
312
+ $image_overlay = '<div class="img-overlay">'. esc_html( $notification['image_overlay'] ).'</div>';
313
+ }
314
+ }
315
+ ?>
316
+
317
+ <div class="sby_notice sby_<?php echo esc_attr( $type ); ?>_notice">
318
+ <div class="sby_thumb">
319
+ <img src="<?php echo esc_url( $img_src ); ?>" alt="notice">
320
+ <?php echo $image_overlay; ?>
321
+ </div>
322
+ <div class="sby-notice-text">
323
+ <p style="padding-top: 4px;"><?php echo $content; ?></p>
324
+ <p class="links">
325
+ <?php foreach ( $buttons as $button ) : ?>
326
+ <a class="<?php echo esc_attr( $button['class'] ); ?>" href="<?php echo esc_attr( $button['url'] ); ?>"<?php echo $button['attr']; ?>><?php echo $button['text']; ?></a>
327
+ <?php endforeach; ?>
328
+ </p>
329
+ </div>
330
+ <a class="sby_notice_close" href="<?php echo add_query_arg( array( 'sby_dismiss' => $type ) ); ?>"><i class="fa fa-close"></i></a>
331
+ </div>
332
+ <?php
333
+ }
334
+
335
+ /**
336
+ * Hide messages permanently or some can be dismissed temporarily
337
+ *
338
+ * @since 2.18
339
+ */
340
+ public function dismiss() {
341
+ global $current_user;
342
+ $user_id = $current_user->ID;
343
+ $sby_statuses_option = get_option( 'sby_statuses', array() );
344
+
345
+ if ( isset( $_GET['sby_ignore_rating_notice_nag'] ) ) {
346
+ if ( (int)$_GET['sby_ignore_rating_notice_nag'] === 1 ) {
347
+ update_option( 'sby_rating_notice', 'dismissed', false );
348
+ $sby_statuses_option['rating_notice_dismissed'] = sby_get_current_time();
349
+ update_option( 'sby_statuses', $sby_statuses_option, false );
350
+
351
+ } elseif ( $_GET['sby_ignore_rating_notice_nag'] === 'later' ) {
352
+ set_transient( 'feeds_for_youtube_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS );
353
+ update_option( 'sby_rating_notice', 'pending', false );
354
+ }
355
+ }
356
+
357
+ if ( isset( $_GET['sby_ignore_new_user_sale_notice'] ) ) {
358
+ $response = sanitize_text_field( $_GET['sby_ignore_new_user_sale_notice'] );
359
+ if ( $response === 'always' ) {
360
+ update_user_meta( $user_id, 'sby_ignore_new_user_sale_notice', 'always' );
361
+
362
+ $current_month_number = (int)date('n', sby_get_current_time() );
363
+ $not_early_in_the_year = ($current_month_number > 5);
364
+
365
+ if ( $not_early_in_the_year ) {
366
+ update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', date( 'Y', sby_get_current_time() ) );
367
+ }
368
+
369
+ }
370
+ }
371
+
372
+ if ( isset( $_GET['sby_ignore_bfcm_sale_notice'] ) ) {
373
+ $response = sanitize_text_field( $_GET['sby_ignore_bfcm_sale_notice'] );
374
+ if ( $response === 'always' ) {
375
+ update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', 'always' );
376
+ } elseif ( $response === date( 'Y', sby_get_current_time() ) ) {
377
+ update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', date( 'Y', sby_get_current_time() ) );
378
+ }
379
+ update_user_meta( $user_id, 'sby_ignore_new_user_sale_notice', 'always' );
380
+ }
381
+
382
+ if ( isset( $_GET['sby_dismiss'] ) ) {
383
+ if ( $_GET['sby_dismiss'] === 'review' ) {
384
+ update_option( 'sby_rating_notice', 'dismissed', false );
385
+ $sby_statuses_option['rating_notice_dismissed'] = sby_get_current_time();
386
+ update_option( 'sby_statuses', $sby_statuses_option, false );
387
+ } elseif ( $_GET['sby_dismiss'] === 'discount' ) {
388
+ update_user_meta( $user_id, 'sby_ignore_new_user_sale_notice', 'always' );
389
+
390
+ $current_month_number = (int)date('n', sby_get_current_time() );
391
+ $not_early_in_the_year = ($current_month_number > 5);
392
+
393
+ if ( $not_early_in_the_year ) {
394
+ update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', date( 'Y', sby_get_current_time() ) );
395
+ }
396
+ }
397
+ update_user_meta( $user_id, 'sby_ignore_new_user_sale_notice', 'always' );
398
+ }
399
+ }
400
+ }
inc/admin/class-sby-notifications.php CHANGED
@@ -1,582 +1,582 @@
1
- <?php
2
- /**
3
- * SBY_Notifications.
4
- *
5
- * @since 1.7/1.11
6
- */
7
-
8
- // Exit if accessed directly
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class SBY_Notifications {
14
-
15
- /**
16
- * Source of notifications content.
17
- *
18
- * @var string
19
- */
20
- const SOURCE_URL = 'http://plugin.smashballoon.com/notifications.json';
21
-
22
- /**
23
- * @var string
24
- */
25
- const OPTION_NAME = 'sby_notifications';
26
-
27
- /**
28
- * JSON data contains notices for all plugins. This is used
29
- * to select messages only meant for this plugin
30
- *
31
- * @var string
32
- */
33
- const PLUGIN = 'youtube';
34
-
35
- /**
36
- * Option value.
37
- *
38
- * @since 1.7/1.11
39
- *
40
- * @var bool|array
41
- */
42
- public $option = false;
43
-
44
- /**
45
- * Initialize class.
46
- *
47
- * @since 1.7/1.11
48
- */
49
- public function init() {
50
- $this->hooks();
51
- }
52
-
53
- /**
54
- * Use this function to get the option name to allow
55
- * inheritance for the New_User class
56
- *
57
- * @return string
58
- */
59
- public function option_name() {
60
- return self::OPTION_NAME;
61
- }
62
-
63
- /**
64
- * Use this function to get the source URL to allow
65
- * inheritance for the New_User class
66
- *
67
- * @return string
68
- */
69
- public function source_url() {
70
- return self::SOURCE_URL;
71
- }
72
-
73
- /**
74
- * Register hooks.
75
- *
76
- * @since 1.7/1.11
77
- */
78
- public function hooks() {
79
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueues' ) );
80
-
81
- add_action( 'sby_admin_overview_before_title', array( $this, 'output' ) );
82
-
83
- // on cron. Once a week?
84
- add_action( 'sby_notification_update', array( $this, 'update' ) );
85
-
86
- add_action( 'wp_ajax_sby_dashboard_notification_dismiss', array( $this, 'dismiss' ) );
87
- }
88
-
89
-
90
- /**
91
- * Check if user has access and is enabled.
92
- *
93
- * @since 1.7/1.11
94
- *
95
- * @return bool
96
- */
97
- public function has_access() {
98
- $access = false;
99
-
100
- if ( current_user_can( 'manage_options' ) ) {
101
- $access = true;
102
- }
103
-
104
- return apply_filters( 'sby_admin_notifications_has_access', $access );
105
- }
106
-
107
- /**
108
- * Get option value.
109
- *
110
- * @since 1.7/1.11
111
- *
112
- * @param bool $cache Reference property cache if available.
113
- *
114
- * @return array
115
- */
116
- public function get_option( $cache = true ) {
117
- if ( $this->option && $cache ) {
118
- return $this->option;
119
- }
120
-
121
- $option = get_option( $this->option_name(), array() );
122
-
123
- $this->option = array(
124
- 'update' => ! empty( $option['update'] ) ? $option['update'] : 0,
125
- 'events' => ! empty( $option['events'] ) ? $option['events'] : array(),
126
- 'feed' => ! empty( $option['feed'] ) ? $option['feed'] : array(),
127
- 'dismissed' => ! empty( $option['dismissed'] ) ? $option['dismissed'] : array(),
128
- );
129
-
130
- return $this->option;
131
- }
132
-
133
- /**
134
- * Fetch notifications from feed.
135
- *
136
- * @since 1.7/1.11
137
- *
138
- * @return array
139
- */
140
- public function fetch_feed() {
141
- $res = wp_remote_get( $this->source_url() );
142
-
143
- if ( is_wp_error( $res ) ) {
144
- return array();
145
- }
146
-
147
- $body = wp_remote_retrieve_body( $res );
148
-
149
- if ( empty( $body ) ) {
150
- return array();
151
- }
152
-
153
- $body = str_replace( array( 'sbi_', 'sbi-' ), array( 'sby_', 'sby-' ), $body );
154
-
155
- return $this->verify( json_decode( $body, true ) );
156
- }
157
-
158
- /**
159
- * Verify notification data before it is saved.
160
- *
161
- * @since 1.7/1.11
162
- *
163
- * @param array $notifications Array of notifications items to verify.
164
- *
165
- * @return array
166
- */
167
- public function verify( $notifications ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
168
- $data = array();
169
-
170
- if ( ! is_array( $notifications ) || empty( $notifications ) ) {
171
- return $data;
172
- }
173
-
174
- $option = $this->get_option();
175
-
176
- foreach ( $notifications as $notification ) {
177
-
178
- // The message and license should never be empty, if they are, ignore.
179
- if ( empty( $notification['content'] ) || empty( $notification['type'] ) ) {
180
- continue;
181
- }
182
-
183
- // Ignore if license type does not match.
184
- $license = sby_is_pro_version() ? 'pro' : 'free';
185
-
186
- if ( ! in_array( $license, $notification['type'], true ) ) {
187
- continue;
188
- }
189
-
190
- // Ignore if expired.
191
- if ( ! empty( $notification['end'] ) && sby_get_current_time() > strtotime( $notification['end'] ) ) {
192
- continue;
193
- }
194
-
195
- // Ignore if notification has already been dismissed.
196
- if ( ! empty( $option['dismissed'] ) && in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
197
- continue;
198
- }
199
-
200
- // TODO: Ignore if notification existed before installing SBY.
201
- // Prevents bombarding the user with notifications after activation.
202
- $activated = false;
203
- if ( ! empty( $activated )
204
- && ! empty( $notification['start'] )
205
- && $activated > strtotime( $notification['start'] ) ) {
206
- continue;
207
- }
208
-
209
- $data[] = $notification;
210
- }
211
-
212
- return $data;
213
- }
214
-
215
- /**
216
- * Verify saved notification data for active notifications.
217
- *
218
- * @since 1.7/1.11
219
- *
220
- * @param array $notifications Array of notifications items to verify.
221
- *
222
- * @return array
223
- */
224
- public function verify_active( $notifications ) {
225
- if ( ! is_array( $notifications ) || empty( $notifications ) ) {
226
- return array();
227
- }
228
-
229
- // Remove notfications that are not active.
230
- foreach ( $notifications as $key => $notification ) {
231
- if ( ( ! empty( $notification['start'] ) && sby_get_current_time() < strtotime( $notification['start'] ) )
232
- || ( ! empty( $notification['end'] ) && sby_get_current_time() > strtotime( $notification['end'] ) ) ) {
233
- unset( $notifications[ $key ] );
234
- }
235
- }
236
-
237
- return $notifications;
238
- }
239
-
240
- /**
241
- * Get notification data.
242
- *
243
- * @since 1.7/1.11
244
- *
245
- * @return array
246
- */
247
- public function get() {
248
- if ( ! $this->has_access() ) {
249
- return array();
250
- }
251
-
252
- $option = $this->get_option();
253
-
254
- // Update notifications using async task.
255
- if ( empty( $option['update'] ) || sby_get_current_time() > $option['update'] + DAY_IN_SECONDS ) {
256
- $this->update();
257
- }
258
-
259
- $events = ! empty( $option['events'] ) ? $this->verify_active( $option['events'] ) : array();
260
- $feed = ! empty( $option['feed'] ) ? $this->verify_active( $option['feed'] ) : array();
261
-
262
- // If there is a new user notification, add it to the beginning of the notification list
263
- $sby_newuser = new SBY_New_User();
264
- $newuser_notifications = $sby_newuser->get();
265
-
266
- if ( ! empty( $newuser_notifications ) ) {
267
- $events = array_merge( $newuser_notifications, $events );
268
- }
269
-
270
- return array_merge( $events, $feed );
271
- }
272
-
273
- /**
274
- * Get notification count.
275
- *
276
- * @since 1.7/1.11
277
- *
278
- * @return int
279
- */
280
- public function get_count() {
281
- return count( $this->get() );
282
- }
283
-
284
- /**
285
- * Add a manual notification event.
286
- *
287
- * @since 1.7/1.11
288
- *
289
- * @param array $notification Notification data.
290
- */
291
- public function add( $notification ) {
292
- if ( empty( $notification['id'] ) ) {
293
- return;
294
- }
295
-
296
- $option = $this->get_option();
297
-
298
- if ( in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
299
- return;
300
- }
301
-
302
- foreach ( $option['events'] as $item ) {
303
- if ( $item['id'] === $notification['id'] ) {
304
- return;
305
- }
306
- }
307
-
308
- $notification = $this->verify( array( $notification ) );
309
-
310
- update_option(
311
- 'sby_notifications',
312
- array(
313
- 'update' => $option['update'],
314
- 'feed' => $option['feed'],
315
- 'events' => array_merge( $notification, $option['events'] ),
316
- 'dismissed' => $option['dismissed'],
317
- )
318
- );
319
- }
320
-
321
- /**
322
- * Update notification data from feed.
323
- *
324
- * @since 1.7/1.11
325
- */
326
- public function update() {
327
- $feed = $this->fetch_feed();
328
- $option = $this->get_option();
329
-
330
- update_option(
331
- 'sby_notifications',
332
- array(
333
- 'update' => sby_get_current_time(),
334
- 'feed' => $feed,
335
- 'events' => $option['events'],
336
- 'dismissed' => $option['dismissed'],
337
- )
338
- );
339
- }
340
-
341
- /**
342
- * Admin area Form Overview enqueues.
343
- *
344
- * @since 1.7/1.11
345
- */
346
- public function enqueues() {
347
- if ( ! $this->has_access() ) {
348
- return;
349
- }
350
-
351
- $notifications = $this->get();
352
-
353
- if ( empty( $notifications ) ) {
354
- return;
355
- }
356
-
357
- $min = '';
358
-
359
- wp_enqueue_style(
360
- 'sby-admin-notifications',
361
- SBY_PLUGIN_URL . "css/admin-notifications{$min}.css",
362
- array(),
363
- SBYVER
364
- );
365
-
366
- wp_enqueue_script(
367
- 'sby-admin-notifications',
368
- SBY_PLUGIN_URL . "js/admin-notifications{$min}.js",
369
- array( 'jquery' ),
370
- SBYVER,
371
- true
372
- );
373
-
374
- wp_localize_script( 'sby-admin-notifications', 'sby_admin', array(
375
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
376
- 'nonce' => wp_create_nonce( 'sby-admin' )
377
- )
378
- );
379
- }
380
-
381
- /**
382
- * Fields from the remote source contain placeholders to allow
383
- * some messages to be used for multiple plugins.
384
- *
385
- * @param $content string
386
- * @param $notification array
387
- *
388
- * @return string
389
- *
390
- * @since 1.7/1.11
391
- */
392
- public function replace_merge_fields( $content, $notification ) {
393
- $merge_fields = array(
394
- '{plugin}' => 'Feeds for YouTube',
395
- '{amount}' => isset( $notification['amount'] ) ? $notification['amount'] : '',
396
- '{platform}' => 'YouTube',
397
- '{lowerplatform}' => 'youtube',
398
- '{review-url}' => 'https://wordpress.org/support/plugin/feeds-for-youtube/reviews/',
399
- '{slug}' => 'youtube-feed',
400
- '{campaign}' => 'youtube-free'
401
- );
402
-
403
- if ( sby_is_pro_version() ) {
404
- $merge_fields['{campaign}'] = 'youtube-pro';
405
- $merge_fields['{plugin}'] = 'Feeds for YouTube Pro';
406
- }
407
-
408
- foreach ( $merge_fields as $find => $replace ) {
409
- $content = str_replace( $find, $replace, $content );
410
- }
411
-
412
- return $content;
413
- }
414
-
415
- /**
416
- * Output notifications on Feeds for YouTube admin area.
417
- *
418
- * @since 1.7/1.11
419
- */
420
- public function output() {
421
- $notifications = $this->get();
422
-
423
- if ( empty( $notifications ) ) {
424
- return;
425
- }
426
-
427
- $notifications_html = '';
428
- $current_class = ' current';
429
- $content_allowed_tags = array(
430
- 'em' => array(),
431
- 'strong' => array(),
432
- 'span' => array(
433
- 'style' => array(),
434
- ),
435
- 'a' => array(
436
- 'href' => array(),
437
- 'target' => array(),
438
- 'rel' => array(),
439
- ),
440
- );
441
-
442
- foreach ( $notifications as $notification ) {
443
-
444
- // Buttons HTML.
445
- $buttons_html = '';
446
- if ( ! empty( $notification['btns'] ) && is_array( $notification['btns'] ) ) {
447
- foreach ( $notification['btns'] as $btn_type => $btn ) {
448
- if ( is_array( $btn['url'] ) ) {
449
- $btn['url'] = add_query_arg( $btn['url'] );
450
- }
451
- if ( ! empty( $btn['attr'] ) ) {
452
- $btn['target'] = '_blank';
453
- }
454
- $buttons_html .= sprintf(
455
- '<a href="%1$s" class="button button-%2$s"%3$s>%4$s</a>',
456
- ! empty( $btn['url'] ) ? esc_url( $this->replace_merge_fields( $btn['url'], $notification ) ) : '',
457
- $btn_type === 'primary' ? 'primary' : 'secondary',
458
- ! empty( $btn['target'] ) && $btn['target'] === '_blank' ? ' target="_blank" rel="noopener noreferrer"' : '',
459
- ! empty( $btn['text'] ) ? sanitize_text_field( $btn['text'] ) : ''
460
- );
461
- }
462
- $buttons_html = ! empty( $buttons_html ) ? '<div class="buttons">' . $buttons_html . '</div>' : '';
463
- }
464
-
465
- if ( empty( $notification['image'] ) ) {
466
- $image_html = '<div class="bell">';
467
-
468
- $image_html .= '<svg xmlns="http://www.w3.org/2000/svg" width="42" height="48" viewBox="0 0 42 48"><defs><style>.a{fill:#777;}.b{fill:#ca4a1f;}</style></defs><path class="a" d="M23-79a6.005,6.005,0,0,1-6-6h10.06a12.066,12.066,0,0,0,1.791,1.308,6.021,6.021,0,0,1-2.077,3.352A6.008,6.008,0,0,1,23-79Zm1.605-9H5.009a2.955,2.955,0,0,1-2.173-.923A3.088,3.088,0,0,1,2-91a2.919,2.919,0,0,1,.807-2.036c.111-.12.229-.243.351-.371a14.936,14.936,0,0,0,3.126-4.409A23.283,23.283,0,0,0,8.007-107.5a14.846,14.846,0,0,1,.906-5.145,14.5,14.5,0,0,1,2.509-4.324A15.279,15.279,0,0,1,20-122.046V-124a3,3,0,0,1,3-3,3,3,0,0,1,3,3v1.954a15.28,15.28,0,0,1,8.58,5.078,14.5,14.5,0,0,1,2.509,4.324,14.846,14.846,0,0,1,.906,5.145c0,.645.016,1.281.047,1.888A12.036,12.036,0,0,0,35-106a11.921,11.921,0,0,0-8.485,3.515A11.923,11.923,0,0,0,23-94a12,12,0,0,0,1.6,6Z" transform="translate(-2 127)"/><circle class="b" cx="9" cy="9" r="9" transform="translate(24 24)"/></svg>';
469
- $image_html .= '</div>';
470
- } else {
471
- if ( $notification['image'] === 'balloon'
472
- || $notification['id'] === 'review'
473
- || $notification['id'] === 'discount') {
474
- $image_html = '<div class="bell">';
475
-
476
- $image_html .= '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1438 1878" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2">';
477
- $image_html .= ' <path d="M671.51004 492.9884C539.9423 433.8663 402.90125 345.5722 274.97656 304.47286c45.45163 108.39592 83.81332 223.88017 123.51 338.03105C319.308 702.00293 226.8217 748.19258 138.46278 798.51607c75.1914 74.32371 181.67968 117.34651 266.52444 182.01607-67.96124 83.86195-201.48527 171.01801-234.02107 247.01998 140.6922-17.6268 304.63688-46.21031 435.53794-52.00418 28.76427 144.58328 43.5987 303.09763 84.50756 435.53713 60.92033-175.26574 116.0014-356.37317 188.51594-520.0451 111.90644 46.2857 248.29012 102.72607 357.52902 130.01188-76.64636-107.5347-146.59346-221.76948-214.5166-338.02903 100.51162-72.83876 202.1718-144.52451 299.02538-221.02092-136.89514-12.61229-278.73428-20.28827-422.53618-25.99865-22.85288-148.33212-16.84826-325.51604-52.005-461.53983-53.19327 111.4882-115.96694 213.39155-175.51418 318.52497m65.00513 1228.60735c-18.0795 77.37586 41.4876 109.11326 32.50298 156.01215-58.8141-20.268-103.0576-30.67962-182.01567-19.50203 2.47018-60.37036 56.76662-68.90959 45.50432-143.0108C-208.90184 1619.4318-210.59186 99.02478 626.00572 5.44992c1046.0409-117.00405 1078.86445 1689.2596 110.50945 1716.14582" fill="#e34f0e"/>';
478
- $image_html .= ' <path d="M847.02422 174.46342c35.15674 136.02379 29.15212 313.20771 52.0046 461.53578 143.8023 5.71443 285.63982 13.38636 422.53658 26.0027-96.85317 76.4964-198.51497 148.18216-299.02579 221.0189 67.92355 116.26239 137.87024 230.49432 214.51864 338.03024-109.24093-27.28662-245.62461-83.72577-357.53106-130.01269-72.51454 163.67274-127.5956 344.78017-188.51553 520.0459-40.90926-132.4395-55.74329-290.95384-84.50796-435.53712-130.90066 5.79549-294.84493 34.37738-435.53754 52.00418 32.5358-76.00075 166.05902-163.156 234.02026-247.02038-84.84516-64.67037-191.33222-107.69074-266.52363-182.01486 88.35892-50.32349 180.8436-96.51314 260.02295-156.0162-39.69708-114.14683-78.05674-229.63108-123.50878-338.027C402.89923 345.5722 539.9423 433.86629 671.51004 492.98839c59.54684-105.13342 122.3209-207.03677 175.51418-318.52497" fill="#fff"/>';
479
- $image_html .= '</svg>';
480
- } else {
481
- $image_html = '<div class="thumb">';
482
- $img_src = SBY_PLUGIN_URL . 'img/' . sanitize_text_field( $notification['image'] );
483
- $image_html .= '<img src="'.esc_url( $img_src ).'" alt="notice">';
484
-
485
- if ( isset( $notification['image_overlay'] ) ) {
486
- $image_html .= '<div class="img-overlay">'. esc_html( str_replace( '%', '%%', $notification['image_overlay'] ) ).'</div>';
487
- }
488
- }
489
-
490
- $image_html .= '</div>';
491
-
492
- }
493
-
494
- // Notification HTML.
495
- $notifications_html .= sprintf(
496
- '<div class="message%5$s" data-message-id="%4$s">' . $image_html . '
497
- <h3 class="title">%1$s</h3>
498
- <p class="content">%2$s</p>
499
- %3$s
500
- </div>',
501
- ! empty( $notification['title'] ) ? $this->replace_merge_fields( sanitize_text_field( $notification['title'] ), $notification ) : '',
502
- ! empty( $notification['content'] ) ? wp_kses( $this->replace_merge_fields( $notification['content'], $notification ), $content_allowed_tags ) : '',
503
- $buttons_html,
504
- ! empty( $notification['id'] ) ? esc_attr( sanitize_text_field( $notification['id'] ) ) : 0,
505
- $current_class
506
- );
507
-
508
- // Only first notification is current.
509
- $current_class = '';
510
- }
511
- ?>
512
-
513
- <div id="sby-notifications">
514
- <a class="dismiss" title="<?php echo esc_attr__( 'Dismiss this message', 'feeds-for-youtube' ); ?>"><i class="fa fa-times-circle" aria-hidden="true"></i></a>
515
-
516
- <div class="navigation">
517
- <a class="prev disabled" title="<?php echo esc_attr__( 'Previous message', 'feeds-for-youtube' ); ?>"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="chevron-left" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" class="svg-inline--fa fa-chevron-left fa-w-10"><path fill="currentColor" d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z" class=""></path></svg></a>
518
- <a class="next disabled" title="<?php echo esc_attr__( 'Next message', 'feeds-for-youtube' ); ?>"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="chevron-right" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" class="svg-inline--fa fa-chevron-right fa-w-10"><path fill="currentColor" d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z" class=""></path></svg></a>
519
- </div>
520
-
521
- <div class="messages">
522
- <?php echo $notifications_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
523
- </div>
524
- </div>
525
- <?php
526
- }
527
-
528
- /**
529
- * Dismiss notification via AJAX. If it's a new user message, also dismiss it
530
- * on all admin pages.
531
- *
532
- * @since 1.7/1.11
533
- */
534
- public function dismiss() {
535
- // Run a security check.
536
- check_ajax_referer( 'sby-admin', 'nonce' );
537
-
538
- // Check for access and required param.
539
- if ( ! $this->has_access() || empty( $_POST['id'] ) ) {
540
- wp_send_json_error();
541
- }
542
-
543
- $id = sanitize_text_field( wp_unslash( $_POST['id'] ) );
544
-
545
- if ( $id === 'review' ) {
546
- $sby_statuses_option = get_option( 'sby_statuses', array() );
547
-
548
- update_option( 'sby_rating_notice', 'dismissed', false );
549
- $sby_statuses_option['rating_notice_dismissed'] = sby_get_current_time();
550
- update_option( 'sby_statuses', $sby_statuses_option, false );
551
- } elseif ( $id === 'discount' ) {
552
- update_user_meta( get_current_user_id(), 'sby_ignore_new_user_sale_notice', 'always' );
553
-
554
- $current_month_number = (int)date('n', sby_get_current_time() );
555
- $not_early_in_the_year = ($current_month_number > 5);
556
-
557
- if ( $not_early_in_the_year ) {
558
- update_user_meta( get_current_user_id(), 'sby_ignore_bfcm_sale_notice', date( 'Y', sby_get_current_time() ) );
559
- }
560
- }
561
-
562
- $option = $this->get_option();
563
- $type = is_numeric( $id ) ? 'feed' : 'events';
564
-
565
- $option['dismissed'][] = $id;
566
- $option['dismissed'] = array_unique( $option['dismissed'] );
567
-
568
- // Remove notification.
569
- if ( is_array( $option[ $type ] ) && ! empty( $option[ $type ] ) ) {
570
- foreach ( $option[ $type ] as $key => $notification ) {
571
- if ( $notification['id'] == $id ) { // phpcs:ignore WordPress.PHP.StrictComparisons
572
- unset( $option[ $type ][ $key ] );
573
- break;
574
- }
575
- }
576
- }
577
-
578
- update_option( 'sby_notifications', $option );
579
-
580
- wp_send_json_success();
581
- }
582
- }
1
+ <?php
2
+ /**
3
+ * SBY_Notifications.
4
+ *
5
+ * @since 1.7/1.11
6
+ */
7
+
8
+ // Exit if accessed directly
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class SBY_Notifications {
14
+
15
+ /**
16
+ * Source of notifications content.
17
+ *
18
+ * @var string
19
+ */
20
+ const SOURCE_URL = 'http://plugin.smashballoon.com/notifications.json';
21
+
22
+ /**
23
+ * @var string
24
+ */
25
+ const OPTION_NAME = 'sby_notifications';
26
+
27
+ /**
28
+ * JSON data contains notices for all plugins. This is used
29
+ * to select messages only meant for this plugin
30
+ *
31
+ * @var string
32
+ */
33
+ const PLUGIN = 'youtube';
34
+
35
+ /**
36
+ * Option value.
37
+ *
38
+ * @since 1.7/1.11
39
+ *
40
+ * @var bool|array
41
+ */
42
+ public $option = false;
43
+
44
+ /**
45
+ * Initialize class.
46
+ *
47
+ * @since 1.7/1.11
48
+ */
49
+ public function init() {
50
+ $this->hooks();
51
+ }
52
+
53
+ /**
54
+ * Use this function to get the option name to allow
55
+ * inheritance for the New_User class
56
+ *
57
+ * @return string
58
+ */
59
+ public function option_name() {
60
+ return self::OPTION_NAME;
61
+ }
62
+
63
+ /**
64
+ * Use this function to get the source URL to allow
65
+ * inheritance for the New_User class
66
+ *
67
+ * @return string
68
+ */
69
+ public function source_url() {
70
+ return self::SOURCE_URL;
71
+ }
72
+
73
+ /**
74
+ * Register hooks.
75
+ *
76
+ * @since 1.7/1.11
77
+ */
78
+ public function hooks() {
79
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueues' ) );
80
+
81
+ add_action( 'sby_admin_overview_before_title', array( $this, 'output' ) );
82
+
83
+ // on cron. Once a week?
84
+ add_action( 'sby_notification_update', array( $this, 'update' ) );
85
+
86
+ add_action( 'wp_ajax_sby_dashboard_notification_dismiss', array( $this, 'dismiss' ) );
87
+ }
88
+
89
+
90
+ /**
91
+ * Check if user has access and is enabled.
92
+ *
93
+ * @since 1.7/1.11
94
+ *
95
+ * @return bool
96
+ */
97
+ public function has_access() {
98
+ $access = false;
99
+
100
+ if ( current_user_can( 'manage_options' ) ) {
101
+ $access = true;
102
+ }
103
+
104
+ return apply_filters( 'sby_admin_notifications_has_access', $access );
105
+ }
106
+
107
+ /**
108
+ * Get option value.
109
+ *
110
+ * @since 1.7/1.11
111
+ *
112
+ * @param bool $cache Reference property cache if available.
113
+ *
114
+ * @return array
115
+ */
116
+ public function get_option( $cache = true ) {
117
+ if ( $this->option && $cache ) {
118
+ return $this->option;
119
+ }
120
+
121
+ $option = get_option( $this->option_name(), array() );
122
+
123
+ $this->option = array(
124
+ 'update' => ! empty( $option['update'] ) ? $option['update'] : 0,
125
+ 'events' => ! empty( $option['events'] ) ? $option['events'] : array(),
126
+ 'feed' => ! empty( $option['feed'] ) ? $option['feed'] : array(),
127
+ 'dismissed' => ! empty( $option['dismissed'] ) ? $option['dismissed'] : array(),
128
+ );
129
+
130
+ return $this->option;
131
+ }
132
+
133
+ /**
134
+ * Fetch notifications from feed.
135
+ *
136
+ * @since 1.7/1.11
137
+ *
138
+ * @return array
139
+ */
140
+ public function fetch_feed() {
141
+ $res = wp_remote_get( $this->source_url() );
142
+
143
+ if ( is_wp_error( $res ) ) {
144
+ return array();
145
+ }
146
+
147
+ $body = wp_remote_retrieve_body( $res );
148
+
149
+ if ( empty( $body ) ) {
150
+ return array();
151
+ }
152
+
153
+ $body = str_replace( array( 'sbi_', 'sbi-' ), array( 'sby_', 'sby-' ), $body );
154
+
155
+ return $this->verify( json_decode( $body, true ) );
156
+ }
157
+
158
+ /**
159
+ * Verify notification data before it is saved.
160
+ *
161
+ * @since 1.7/1.11
162
+ *
163
+ * @param array $notifications Array of notifications items to verify.
164
+ *
165
+ * @return array
166
+ */
167
+ public function verify( $notifications ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
168
+ $data = array();
169
+
170
+ if ( ! is_array( $notifications ) || empty( $notifications ) ) {
171
+ return $data;
172
+ }
173
+
174
+ $option = $this->get_option();
175
+
176
+ foreach ( $notifications as $notification ) {
177
+
178
+ // The message and license should never be empty, if they are, ignore.
179
+ if ( empty( $notification['content'] ) || empty( $notification['type'] ) ) {
180
+ continue;
181
+ }
182
+
183
+ // Ignore if license type does not match.
184
+ $license = sby_is_pro_version() ? 'pro' : 'free';
185
+
186
+ if ( ! in_array( $license, $notification['type'], true ) ) {
187
+ continue;
188
+ }
189
+
190
+ // Ignore if expired.
191
+ if ( ! empty( $notification['end'] ) && sby_get_current_time() > strtotime( $notification['end'] ) ) {
192
+ continue;
193
+ }
194
+
195
+ // Ignore if notification has already been dismissed.
196
+ if ( ! empty( $option['dismissed'] ) && in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
197
+ continue;
198
+ }
199
+
200
+ // TODO: Ignore if notification existed before installing SBY.
201
+ // Prevents bombarding the user with notifications after activation.
202
+ $activated = false;
203
+ if ( ! empty( $activated )
204
+ && ! empty( $notification['start'] )
205
+ && $activated > strtotime( $notification['start'] ) ) {
206
+ continue;
207
+ }
208
+
209
+ $data[] = $notification;
210
+ }
211
+
212
+ return $data;
213
+ }
214
+
215
+ /**
216
+ * Verify saved notification data for active notifications.
217
+ *
218
+ * @since 1.7/1.11
219
+ *
220
+ * @param array $notifications Array of notifications items to verify.
221
+ *
222
+ * @return array
223
+ */
224
+ public function verify_active( $notifications ) {
225
+ if ( ! is_array( $notifications ) || empty( $notifications ) ) {
226
+ return array();
227
+ }
228
+
229
+ // Remove notfications that are not active.
230
+ foreach ( $notifications as $key => $notification ) {
231
+ if ( ( ! empty( $notification['start'] ) && sby_get_current_time() < strtotime( $notification['start'] ) )
232
+ || ( ! empty( $notification['end'] ) && sby_get_current_time() > strtotime( $notification['end'] ) ) ) {
233
+ unset( $notifications[ $key ] );
234
+ }
235
+ }
236
+
237
+ return $notifications;
238
+ }
239
+
240
+ /**
241
+ * Get notification data.
242
+ *
243
+ * @since 1.7/1.11
244
+ *
245
+ * @return array
246
+ */
247
+ public function get() {
248
+ if ( ! $this->has_access() ) {
249
+ return array();
250
+ }
251
+
252
+ $option = $this->get_option();
253
+
254
+ // Update notifications using async task.
255
+ if ( empty( $option['update'] ) || sby_get_current_time() > $option['update'] + DAY_IN_SECONDS ) {
256
+ $this->update();
257
+ }
258
+
259
+ $events = ! empty( $option['events'] ) ? $this->verify_active( $option['events'] ) : array();
260
+ $feed = ! empty( $option['feed'] ) ? $this->verify_active( $option['feed'] ) : array();
261
+
262
+ // If there is a new user notification, add it to the beginning of the notification list
263
+ $sby_newuser = new SBY_New_User();
264
+ $newuser_notifications = $sby_newuser->get();
265
+
266
+ if ( ! empty( $newuser_notifications ) ) {
267
+ $events = array_merge( $newuser_notifications, $events );
268
+ }
269
+
270
+ return array_merge( $events, $feed );
271
+ }
272
+
273
+ /**
274
+ * Get notification count.
275
+ *
276
+ * @since 1.7/1.11
277
+ *
278
+ * @return int
279
+ */
280
+ public function get_count() {
281
+ return count( $this->get() );
282
+ }
283
+
284
+ /**
285
+ * Add a manual notification event.
286
+ *
287
+ * @since 1.7/1.11
288
+ *
289
+ * @param array $notification Notification data.
290
+ */
291
+ public function add( $notification ) {
292
+ if ( empty( $notification['id'] ) ) {
293
+ return;
294
+ }
295
+
296
+ $option = $this->get_option();
297
+
298
+ if ( in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
299
+ return;
300
+ }
301
+
302
+ foreach ( $option['events'] as $item ) {
303
+ if ( $item['id'] === $notification['id'] ) {
304
+ return;
305
+ }
306
+ }
307
+
308
+ $notification = $this->verify( array( $notification ) );
309
+
310
+ update_option(
311
+ 'sby_notifications',
312
+ array(
313
+ 'update' => $option['update'],
314
+ 'feed' => $option['feed'],
315
+ 'events' => array_merge( $notification, $option['events'] ),
316
+ 'dismissed' => $option['dismissed'],
317
+ )
318
+ );
319
+ }
320
+
321
+ /**
322
+ * Update notification data from feed.
323
+ *
324
+ * @since 1.7/1.11
325
+ */
326
+ public function update() {
327
+ $feed = $this->fetch_feed();
328
+ $option = $this->get_option();
329
+
330
+ update_option(
331
+ 'sby_notifications',
332
+ array(
333
+ 'update' => sby_get_current_time(),
334
+ 'feed' => $feed,
335
+ 'events' => $option['events'],
336
+ 'dismissed' => $option['dismissed'],
337
+ )
338
+ );
339
+ }
340
+
341
+ /**
342
+ * Admin area Form Overview enqueues.
343
+ *
344
+ * @since 1.7/1.11
345
+ */
346
+ public function enqueues() {
347
+ if ( ! $this->has_access() ) {
348
+ return;
349
+ }
350
+
351
+ $notifications = $this->get();
352
+
353
+ if ( empty( $notifications ) ) {
354
+ return;
355
+ }
356
+
357
+ $min = '';
358
+
359
+ wp_enqueue_style(
360
+ 'sby-admin-notifications',
361
+ SBY_PLUGIN_URL . "css/admin-notifications{$min}.css",
362
+ array(),
363
+ SBYVER
364
+ );
365
+
366
+ wp_enqueue_script(
367
+ 'sby-admin-notifications',
368
+ SBY_PLUGIN_URL . "js/admin-notifications{$min}.js",
369
+ array( 'jquery' ),
370
+ SBYVER,
371
+ true
372
+ );
373
+
374
+ wp_localize_script( 'sby-admin-notifications', 'sby_admin', array(
375
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
376
+ 'nonce' => wp_create_nonce( 'sby-admin' )
377
+ )
378
+ );
379
+ }
380
+
381
+ /**
382
+ * Fields from the remote source contain placeholders to allow
383
+ * some messages to be used for multiple plugins.
384
+ *
385
+ * @param $content string
386
+ * @param $notification array
387
+ *
388
+ * @return string
389
+ *
390
+ * @since 1.7/1.11
391
+ */
392
+ public function replace_merge_fields( $content, $notification ) {
393
+ $merge_fields = array(
394
+ '{plugin}' => 'Feeds for YouTube',
395
+ '{amount}' => isset( $notification['amount'] ) ? $notification['amount'] : '',
396
+ '{platform}' => 'YouTube',
397
+ '{lowerplatform}' => 'youtube',
398
+ '{review-url}' => 'https://wordpress.org/support/plugin/feeds-for-youtube/reviews/',
399
+ '{slug}' => 'youtube-feed',
400
+ '{campaign}' => 'youtube-free'
401
+ );
402
+
403
+ if ( sby_is_pro_version() ) {
404
+ $merge_fields['{campaign}'] = 'youtube-pro';
405
+ $merge_fields['{plugin}'] = 'Feeds for YouTube Pro';
406
+ }
407
+
408
+ foreach ( $merge_fields as $find => $replace ) {
409
+ $content = str_replace( $find, $replace, $content );
410
+ }
411
+
412
+ return $content;
413
+ }
414
+
415
+ /**
416
+ * Output notifications on Feeds for YouTube admin area.
417
+ *
418
+ * @since 1.7/1.11
419
+ */
420
+ public function output() {
421
+ $notifications = $this->get();
422
+
423
+ if ( empty( $notifications ) ) {
424
+ return;
425
+ }
426
+
427
+ $notifications_html = '';
428
+ $current_class = ' current';
429
+ $content_allowed_tags = array(
430
+ 'em' => array(),
431
+ 'strong' => array(),
432
+ 'span' => array(
433
+ 'style' => array(),
434
+ ),
435
+ 'a' => array(
436
+ 'href' => array(),
437
+ 'target' => array(),
438
+ 'rel' => array(),
439
+ ),
440
+ );
441
+
442
+ foreach ( $notifications as $notification ) {
443
+
444
+ // Buttons HTML.
445
+ $buttons_html = '';
446
+ if ( ! empty( $notification['btns'] ) && is_array( $notification['btns'] ) ) {
447
+ foreach ( $notification['btns'] as $btn_type => $btn ) {
448
+ if ( is_array( $btn['url'] ) ) {
449
+ $btn['url'] = add_query_arg( $btn['url'] );
450
+ }
451
+ if ( ! empty( $btn['attr'] ) ) {
452
+ $btn['target'] = '_blank';
453
+ }
454
+ $buttons_html .= sprintf(
455
+ '<a href="%1$s" class="button button-%2$s"%3$s>%4$s</a>',
456
+ ! empty( $btn['url'] ) ? esc_url( $this->replace_merge_fields( $btn['url'], $notification ) ) : '',
457
+ $btn_type === 'primary' ? 'primary' : 'secondary',
458
+ ! empty( $btn['target'] ) && $btn['target'] === '_blank' ? ' target="_blank" rel="noopener noreferrer"' : '',
459
+ ! empty( $btn['text'] ) ? sanitize_text_field( $btn['text'] ) : ''
460
+ );
461
+ }
462
+ $buttons_html = ! empty( $buttons_html ) ? '<div class="buttons">' . $buttons_html . '</div>' : '';
463
+ }
464
+
465
+ if ( empty( $notification['image'] ) ) {
466
+ $image_html = '<div class="bell">';
467
+
468
+ $image_html .= '<svg xmlns="http://www.w3.org/2000/svg" width="42" height="48" viewBox="0 0 42 48"><defs><style>.a{fill:#777;}.b{fill:#ca4a1f;}</style></defs><path class="a" d="M23-79a6.005,6.005,0,0,1-6-6h10.06a12.066,12.066,0,0,0,1.791,1.308,6.021,6.021,0,0,1-2.077,3.352A6.008,6.008,0,0,1,23-79Zm1.605-9H5.009a2.955,2.955,0,0,1-2.173-.923A3.088,3.088,0,0,1,2-91a2.919,2.919,0,0,1,.807-2.036c.111-.12.229-.243.351-.371a14.936,14.936,0,0,0,3.126-4.409A23.283,23.283,0,0,0,8.007-107.5a14.846,14.846,0,0,1,.906-5.145,14.5,14.5,0,0,1,2.509-4.324A15.279,15.279,0,0,1,20-122.046V-124a3,3,0,0,1,3-3,3,3,0,0,1,3,3v1.954a15.28,15.28,0,0,1,8.58,5.078,14.5,14.5,0,0,1,2.509,4.324,14.846,14.846,0,0,1,.906,5.145c0,.645.016,1.281.047,1.888A12.036,12.036,0,0,0,35-106a11.921,11.921,0,0,0-8.485,3.515A11.923,11.923,0,0,0,23-94a12,12,0,0,0,1.6,6Z" transform="translate(-2 127)"/><circle class="b" cx="9" cy="9" r="9" transform="translate(24 24)"/></svg>';
469
+ $image_html .= '</div>';
470
+ } else {
471
+ if ( $notification['image'] === 'balloon'
472
+ || $notification['id'] === 'review'
473
+ || $notification['id'] === 'discount') {
474
+ $image_html = '<div class="bell">';
475
+
476
+ $image_html .= '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1438 1878" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2">';
477
+ $image_html .= ' <path d="M671.51004 492.9884C539.9423 433.8663 402.90125 345.5722 274.97656 304.47286c45.45163 108.39592 83.81332 223.88017 123.51 338.03105C319.308 702.00293 226.8217 748.19258 138.46278 798.51607c75.1914 74.32371 181.67968 117.34651 266.52444 182.01607-67.96124 83.86195-201.48527 171.01801-234.02107 247.01998 140.6922-17.6268 304.63688-46.21031 435.53794-52.00418 28.76427 144.58328 43.5987 303.09763 84.50756 435.53713 60.92033-175.26574 116.0014-356.37317 188.51594-520.0451 111.90644 46.2857 248.29012 102.72607 357.52902 130.01188-76.64636-107.5347-146.59346-221.76948-214.5166-338.02903 100.51162-72.83876 202.1718-144.52451 299.02538-221.02092-136.89514-12.61229-278.73428-20.28827-422.53618-25.99865-22.85288-148.33212-16.84826-325.51604-52.005-461.53983-53.19327 111.4882-115.96694 213.39155-175.51418 318.52497m65.00513 1228.60735c-18.0795 77.37586 41.4876 109.11326 32.50298 156.01215-58.8141-20.268-103.0576-30.67962-182.01567-19.50203 2.47018-60.37036 56.76662-68.90959 45.50432-143.0108C-208.90184 1619.4318-210.59186 99.02478 626.00572 5.44992c1046.0409-117.00405 1078.86445 1689.2596 110.50945 1716.14582" fill="#e34f0e"/>';
478
+ $image_html .= ' <path d="M847.02422 174.46342c35.15674 136.02379 29.15212 313.20771 52.0046 461.53578 143.8023 5.71443 285.63982 13.38636 422.53658 26.0027-96.85317 76.4964-198.51497 148.18216-299.02579 221.0189 67.92355 116.26239 137.87024 230.49432 214.51864 338.03024-109.24093-27.28662-245.62461-83.72577-357.53106-130.01269-72.51454 163.67274-127.5956 344.78017-188.51553 520.0459-40.90926-132.4395-55.74329-290.95384-84.50796-435.53712-130.90066 5.79549-294.84493 34.37738-435.53754 52.00418 32.5358-76.00075 166.05902-163.156 234.02026-247.02038-84.84516-64.67037-191.33222-107.69074-266.52363-182.01486 88.35892-50.32349 180.8436-96.51314 260.02295-156.0162-39.69708-114.14683-78.05674-229.63108-123.50878-338.027C402.89923 345.5722 539.9423 433.86629 671.51004 492.98839c59.54684-105.13342 122.3209-207.03677 175.51418-318.52497" fill="#fff"/>';
479
+ $image_html .= '</svg>';
480
+ } else {
481
+ $image_html = '<div class="thumb">';
482
+ $img_src = SBY_PLUGIN_URL . 'img/' . sanitize_text_field( $notification['image'] );
483
+ $image_html .= '<img src="'.esc_url( $img_src ).'" alt="notice">';
484
+
485
+ if ( isset( $notification['image_overlay'] ) ) {
486
+ $image_html .= '<div class="img-overlay">'. esc_html( str_replace( '%', '%%', $notification['image_overlay'] ) ).'</div>';
487
+ }
488
+ }
489
+
490
+ $image_html .= '</div>';
491
+
492
+ }
493
+
494
+ // Notification HTML.
495
+ $notifications_html .= sprintf(
496
+ '<div class="message%5$s" data-message-id="%4$s">' . $image_html . '
497
+ <h3 class="title">%1$s</h3>
498
+ <p class="content">%2$s</p>
499
+ %3$s
500
+ </div>',
501
+ ! empty( $notification['title'] ) ? $this->replace_merge_fields( sanitize_text_field( $notification['title'] ), $notification ) : '',
502
+ ! empty( $notification['content'] ) ? wp_kses( $this->replace_merge_fields( $notification['content'], $notification ), $content_allowed_tags ) : '',
503
+ $buttons_html,
504
+ ! empty( $notification['id'] ) ? esc_attr( sanitize_text_field( $notification['id'] ) ) : 0,
505
+ $current_class
506
+ );
507
+
508
+ // Only first notification is current.
509
+ $current_class = '';
510
+ }
511
+ ?>
512
+
513
+ <div id="sby-notifications">
514
+ <a class="dismiss" title="<?php echo esc_attr__( 'Dismiss this message', 'feeds-for-youtube' ); ?>"><i class="fa fa-times-circle" aria-hidden="true"></i></a>
515
+
516
+ <div class="navigation">
517
+ <a class="prev disabled" title="<?php echo esc_attr__( 'Previous message', 'feeds-for-youtube' ); ?>"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="chevron-left" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" class="svg-inline--fa fa-chevron-left fa-w-10"><path fill="currentColor" d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z" class=""></path></svg></a>
518
+ <a class="next disabled" title="<?php echo esc_attr__( 'Next message', 'feeds-for-youtube' ); ?>"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="chevron-right" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" class="svg-inline--fa fa-chevron-right fa-w-10"><path fill="currentColor" d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z" class=""></path></svg></a>
519
+ </div>
520
+
521
+ <div class="messages">
522
+ <?php echo $notifications_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
523
+ </div>
524
+ </div>
525
+ <?php
526
+ }
527
+
528
+ /**
529
+ * Dismiss notification via AJAX. If it's a new user message, also dismiss it
530
+ * on all admin pages.
531
+ *
532
+ * @since 1.7/1.11
533
+ */
534
+ public function dismiss() {
535
+ // Run a security check.
536
+ check_ajax_referer( 'sby-admin', 'nonce' );
537
+
538
+ // Check for access and required param.
539
+ if ( ! $this->has_access() || empty( $_POST['id'] ) ) {
540
+ wp_send_json_error();
541
+ }
542
+
543
+ $id = sanitize_text_field( wp_unslash( $_POST['id'] ) );
544
+
545
+ if ( $id === 'review' ) {
546
+ $sby_statuses_option = get_option( 'sby_statuses', array() );
547
+
548
+ update_option( 'sby_rating_notice', 'dismissed', false );
549
+ $sby_statuses_option['rating_notice_dismissed'] = sby_get_current_time();
550
+ update_option( 'sby_statuses', $sby_statuses_option, false );
551
+ } elseif ( $id === 'discount' ) {
552
+ update_user_meta( get_current_user_id(), 'sby_ignore_new_user_sale_notice', 'always' );
553
+
554
+ $current_month_number = (int)date('n', sby_get_current_time() );
555
+ $not_early_in_the_year = ($current_month_number > 5);
556
+
557
+ if ( $not_early_in_the_year ) {
558
+ update_user_meta( get_current_user_id(), 'sby_ignore_bfcm_sale_notice', date( 'Y', sby_get_current_time() ) );
559
+ }
560
+ }
561
+
562
+ $option = $this->get_option();
563
+ $type = is_numeric( $id ) ? 'feed' : 'events';
564
+
565
+ $option['dismissed'][] = $id;
566
+ $option['dismissed'] = array_unique( $option['dismissed'] );
567
+
568
+ // Remove notification.
569
+ if ( is_array( $option[ $type ] ) && ! empty( $option[ $type ] ) ) {
570
+ foreach ( $option[ $type ] as $key => $notification ) {
571
+ if ( $notification['id'] == $id ) { // phpcs:ignore WordPress.PHP.StrictComparisons
572
+ unset( $option[ $type ][ $key ] );
573
+ break;
574
+ }
575
+ }
576
+ }
577
+
578
+ update_option( 'sby_notifications', $option );
579
+
580
+ wp_send_json_success();
581
+ }
582
+ }
inc/admin/templates/configure.php CHANGED
@@ -1,42 +1,42 @@
1
- <h3><?php _e( 'Configure', $text_domain ); ?></h3>
2
- <div id="sbspf_config">
3
- <?php
4
- $notice_not_dismissed = sby_notice_not_dismissed( 'sby_connect_warning_notice' );
5
- $warning_data_att = $notice_not_dismissed ? ' data-show-warning="1"' : '';
6
- ?>
7
- <a href="<?php echo $oauth_processor_url . admin_url( 'admin.php?page=' . esc_attr( $slug ) ); ?>" id="sbspf_get_token"<?php echo $warning_data_att; ?>><?php echo sby_icon( $slug, 'sbspf_small_svg' ); ?> <?php echo sprintf( __( 'Connect to %s to Create a Feed', $text_domain ), $social_network ); ?></a>
8
- <a class="sbspf_not_working" href="https://smashballoon.com/<?php echo esc_attr( $slug ); ?>/token/" target="_blank"><?php _e( "Button not working?", $text_domain ); ?></a>
9
- </div>
10
-
11
- <form method="post" action="">
12
- <?php
13
- $settings = $this->settings;
14
- $api_key = isset( $settings['api_key'] ) ? $settings['api_key'] : '';
15
- ?>
16
- <table class="form-table sbspf_own_credentials_wrap" role="presentation">
17
- <tbody>
18
- <tr>
19
- <th scope="row">
20
- <label for="sby_app_id"><?php _e( "API Key", $text_domain ); ?></label>
21
- <p class="sbspf_aside sbspf_red"><?php _e( "Recommended", $text_domain ); ?></p>
22
- </th>
23
- <td>
24
- <input name="<?php echo $this->get_option_name(); ?>[api_key]" id="sby_api_key" type="text" value="<?php echo esc_attr( $api_key ); ?>" size="64" minlength="15" maxlength="200" />
25
- <p class="sbspf_aside"><?php echo __( 'Entering an API key is <strong>optional</strong> but recommended. It allows the plugin to fetch older videos and prevents potential disruption in your feed. It only takes a few minutes: <a href="https://smashballoon.com/youtube-api-key/" target="_blank" rel="noopener">Get my API key.</a>', $text_domain ); ?></p>
26
- </td>
27
- </tr>
28
-
29
- </tbody>
30
- </table>
31
- <?php $this->hidden_fields_for_tab( 'configure' ); ?>
32
- <?php include_once $this->get_path( 'connected-accounts' ); ?>
33
-
34
- <?php foreach ( $this->get_sections( 'configure' ) as $section ) : ?>
35
-
36
- <?php do_settings_sections( $section['id'] ); // matches the section name ?>
37
- <?php if ( $section['save_after'] ) : ?>
38
- <p class="submit"><input class="button-primary" type="submit" name="save" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p>
39
- <?php endif; ?>
40
- <hr>
41
- <?php endforeach; ?>
42
  </form>
1
+ <h3><?php _e( 'Configure', $text_domain ); ?></h3>
2
+ <div id="sbspf_config">
3
+ <?php
4
+ $notice_not_dismissed = sby_notice_not_dismissed( 'sby_connect_warning_notice' );
5
+ $warning_data_att = $notice_not_dismissed ? ' data-show-warning="1"' : '';
6
+ ?>
7
+ <a href="<?php echo $oauth_processor_url . admin_url( 'admin.php?page=' . esc_attr( $slug ) ); ?>" id="sbspf_get_token"<?php echo $warning_data_att; ?>><?php echo sby_icon( $slug, 'sbspf_small_svg' ); ?> <?php echo sprintf( __( 'Connect to %s to Create a Feed', $text_domain ), $social_network ); ?></a>
8
+ <a class="sbspf_not_working" href="https://smashballoon.com/<?php echo esc_attr( $slug ); ?>/token/" target="_blank"><?php _e( "Button not working?", $text_domain ); ?></a>
9
+ </div>
10
+
11
+ <form method="post" action="">
12
+ <?php
13
+ $settings = $this->settings;
14
+ $api_key = isset( $settings['api_key'] ) ? $settings['api_key'] : '';
15
+ ?>
16
+ <table class="form-table sbspf_own_credentials_wrap" role="presentation">
17
+ <tbody>
18
+ <tr>
19
+ <th scope="row">
20
+ <label for="sby_app_id"><?php _e( "API Key", $text_domain ); ?></label>
21
+ <p class="sbspf_aside sbspf_red"><?php _e( "Recommended", $text_domain ); ?></p>
22
+ </th>
23
+ <td>
24
+ <input name="<?php echo $this->get_option_name(); ?>[api_key]" id="sby_api_key" type="text" value="<?php echo esc_attr( $api_key ); ?>" size="64" minlength="15" maxlength="200" />
25
+ <p class="sbspf_aside"><?php echo __( 'Entering an API key is <strong>optional</strong> but recommended. It allows the plugin to fetch older videos and prevents potential disruption in your feed. It only takes a few minutes: <a href="https://smashballoon.com/youtube-api-key/" target="_blank" rel="noopener">Get my API key.</a>', $text_domain ); ?></p>
26
+ </td>
27
+ </tr>
28
+
29
+ </tbody>
30
+ </table>
31
+ <?php $this->hidden_fields_for_tab( 'configure' ); ?>
32
+ <?php include_once $this->get_path( 'connected-accounts' ); ?>
33
+
34
+ <?php foreach ( $this->get_sections( 'configure' ) as $section ) : ?>
35
+
36
+ <?php do_settings_sections( $section['id'] ); // matches the section name ?>
37
+ <?php if ( $section['save_after'] ) : ?>
38
+ <p class="submit"><input class="button-primary" type="submit" name="save" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p>
39
+ <?php endif; ?>
40
+ <hr>
41
+ <?php endforeach; ?>
42
  </form>
inc/admin/templates/connected-accounts.php CHANGED
@@ -1,41 +1,41 @@
1
- <?php
2
- $connected_accounts = $this->get_connected_accounts();
3
- $connected_channels = array();
4
- ?>
5
- <table class="form-table sbspf_connected-accounts-wrap" role="presentation">
6
- <tbody>
7
- <tr>
8
- <th scope="row">
9
- <label><?php echo sprintf( __( '%s Accounts', $text_domain ), $social_network ); ?></label>
10
- <span style="font-weight:normal; font-style:italic; font-size: 12px; display: block;"><?php echo sprintf( __( 'Use the button above to connect %s account', $text_domain ), $sn_with_a_an ); ?></span>
11
- </th>
12
- <td class="sbspf_connected_accounts_wrap">
13
- <?php if ( empty( $connected_accounts ) ) : ?>
14
- <p class="sbspf_no_accounts"><?php echo sprintf( __( 'No %s accounts connected. Click the button above to connect an account.', $text_domain ), $social_network ); ?></p><br />
15
- <?php else: ?>
16
- <?php foreach ( $connected_accounts as $account ) :
17
- $username = $account['username'] ? $account['username'] : $account['channel_id'];
18
- if ( isset( $account['local_avatar'] ) && $account['local_avatar'] && isset( $options['sbspf_favor_local'] ) && $options['sbspf_favor_local' ] === 'on' ) {
19
- $upload = wp_upload_dir();
20
- $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBI_UPLOADS_NAME );
21
- $profile_picture = '<img class="sbspf_ca_avatar" src="'.$resized_url . $account['username'].'.jpg" />'; //Could add placeholder avatar image
22
- } else {
23
- $profile_picture = $account['profile_picture'] ? '<img class="sbspf_ca_avatar" src="'.$account['profile_picture'].'" />' : ''; //Could add placeholder avatar image
24
- }
25
- $is_invalid_class = ! $account['is_valid'] ? ' sbspf_account_invalid' : '';
26
- $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
27
- $use_tagged = isset( $account['use_tagged'] ) && $account['use_tagged'] == '1';
28
-
29
- include $this->get_path( 'single-connected-account' );
30
- ?>
31
- <?php endforeach; ?>
32
- <?php endif; ?>
33
- <a href="JavaScript:void(0);" class="sbspf_manually_connect button-secondary"><?php _e( 'Manually Connect a Primary Account', $text_domain ); ?></a>
34
- <div class="sbspf_manually_connect_wrap">
35
- <input name="sbspf_manual_at" id="sbspf_manual_at" type="text" value="" style="margin-top: 4px; padding: 5px 9px; margin-left: 0px;" size="64" minlength="15" maxlength="200" placeholder="<?php _e('Enter a valid Access Token', $text_domain );?>" />
36
- <p class="sbspf_submit" style="display: inline-block;"><input type="sbspf_submit" name="submit" id="sbspf_manual_submit" class="button button-primary" style="text-align: center; padding: 0;" value="<?php _e('Connect This Account', $text_domain );?>"></p>
37
- </div>
38
- </td>
39
- </tr>
40
- </tbody>
41
  </table>
1
+ <?php
2
+ $connected_accounts = $this->get_connected_accounts();
3
+ $connected_channels = array();
4
+ ?>
5
+ <table class="form-table sbspf_connected-accounts-wrap" role="presentation">
6
+ <tbody>
7
+ <tr>
8
+ <th scope="row">
9
+ <label><?php echo sprintf( __( '%s Accounts', $text_domain ), $social_network ); ?></label>
10
+ <span style="font-weight:normal; font-style:italic; font-size: 12px; display: block;"><?php echo sprintf( __( 'Use the button above to connect %s account', $text_domain ), $sn_with_a_an ); ?></span>
11
+ </th>
12
+ <td class="sbspf_connected_accounts_wrap">
13
+ <?php if ( empty( $connected_accounts ) ) : ?>
14
+ <p class="sbspf_no_accounts"><?php echo sprintf( __( 'No %s accounts connected. Click the button above to connect an account.', $text_domain ), $social_network ); ?></p><br />
15
+ <?php else: ?>
16
+ <?php foreach ( $connected_accounts as $account ) :
17
+ $username = $account['username'] ? $account['username'] : $account['channel_id'];
18
+ if ( isset( $account['local_avatar'] ) && $account['local_avatar'] && isset( $options['sbspf_favor_local'] ) && $options['sbspf_favor_local' ] === 'on' ) {
19
+ $upload = wp_upload_dir();
20
+ $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBI_UPLOADS_NAME );
21
+ $profile_picture = '<img class="sbspf_ca_avatar" src="'.$resized_url . $account['username'].'.jpg" />'; //Could add placeholder avatar image
22
+ } else {
23
+ $profile_picture = $account['profile_picture'] ? '<img class="sbspf_ca_avatar" src="'.$account['profile_picture'].'" />' : ''; //Could add placeholder avatar image
24
+ }
25
+ $is_invalid_class = ! $account['is_valid'] ? ' sbspf_account_invalid' : '';
26
+ $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
27
+ $use_tagged = isset( $account['use_tagged'] ) && $account['use_tagged'] == '1';
28
+
29
+ include $this->get_path( 'single-connected-account' );
30
+ ?>
31
+ <?php endforeach; ?>
32
+ <?php endif; ?>
33
+ <a href="JavaScript:void(0);" class="sbspf_manually_connect button-secondary"><?php _e( 'Manually Connect a Primary Account', $text_domain ); ?></a>
34
+ <div class="sbspf_manually_connect_wrap">
35
+ <input name="sbspf_manual_at" id="sbspf_manual_at" type="text" value="" style="margin-top: 4px; padding: 5px 9px; margin-left: 0px;" size="64" minlength="15" maxlength="200" placeholder="<?php _e('Enter a valid Access Token', $text_domain );?>" />
36
+ <p class="sbspf_submit" style="display: inline-block;"><input type="sbspf_submit" name="submit" id="sbspf_manual_submit" class="button button-primary" style="text-align: center; padding: 0;" value="<?php _e('Connect This Account', $text_domain );?>"></p>
37
+ </div>
38
+ </td>
39
+ </tr>
40
+ </tbody>
41
  </table>
inc/admin/templates/customize.php CHANGED
@@ -1,22 +1,33 @@
1
-
2
- <form method="post" action="">
3
- <?php $this->hidden_fields_for_tab( 'customize' ); ?>
4
-
5
- <?php foreach ( $this->get_sections( 'customize' ) as $section ) :
6
- if ( $section['pro'] ) : ?>
7
- <div class="sbspf_pro_section">
8
- <p style="padding-bottom: 18px;" class="sbspf_pro_reveal">
9
- <a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&amp;utm_campaign=sby" target="_blank"><?php echo esc_html( $section['pro'] ); ?></a><br>
10
- <a href="javascript:void(0);" class="button button-secondary sbspf-show-pro"><b>+</b> <?php _e( 'Show Pro Options', $text_domain ); ?></a>
11
- </p>
12
- <?php endif;
13
- do_settings_sections( $section['id'] ); // matches the section name
14
- if ( $section['pro'] ) {
15
- echo '</div>';
16
- }
17
- if ( $section['save_after'] ) : ?>
18
- <p class="submit"><input class="button-primary" type="submit" name="save" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p>
19
- <?php endif; ?>
20
- <hr>
21
- <?php endforeach; ?>
22
- </form>
 
 
 
 
 
 
 
 
 
 
 
1
+ <p class="sbspf-contents-links" id="general">
2
+ <span>Quick links: </span>
3
+ <a href="#layout"><?php _e( 'Layout', $text_domain ); ?></a>
4
+ <a href="#header"><?php _e( 'Header', $text_domain ); ?></a>
5
+ <a href="#loadmore"><?php _e( 'Buttons', $text_domain ); ?></a>
6
+ <a href="#gdpr"><?php _e( 'GDPR', $text_domain ); ?></a>
7
+ <a href="#advanced"><?php _e( 'Advanced', $text_domain ); ?></a>
8
+
9
+ </p>
10
+ <form method="post" action="">
11
+ <?php $this->hidden_fields_for_tab( 'customize' ); ?>
12
+
13
+ <?php foreach ( $this->get_sections( 'customize' ) as $section ) :
14
+ if ( $section['pro'] ) : ?>
15
+ <div class="sbspf_pro_section">
16
+ <p style="padding-bottom: 18px;" class="sbspf_pro_reveal">
17
+ <a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&amp;utm_campaign=sby" target="_blank"><?php echo esc_html( $section['pro'] ); ?></a><br>
18
+ <a href="javascript:void(0);" class="button button-secondary sbspf-show-pro"><b>+</b> <?php _e( 'Show Pro Options', $text_domain ); ?></a>
19
+ </p>
20
+ <?php endif; ?>
21
+ <span id="<?php echo str_replace( 'sbspf_', '', $section['id'] ); ?>"></span>
22
+
23
+ <?php
24
+ do_settings_sections( $section['id'] ); // matches the section name
25
+ if ( $section['pro'] ) {
26
+ echo '</div>';
27
+ }
28
+ if ( $section['save_after'] ) : ?>
29
+ <p class="submit"><input class="button-primary" type="submit" name="save" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p>
30
+ <?php endif; ?>
31
+ <hr>
32
+ <?php endforeach; ?>
33
+ </form>
inc/admin/templates/display.php CHANGED
@@ -1,42 +1,42 @@
1
- <h3><?php _e( 'Display your Feed', $text_domain ); ?></h3>
2
- <p><?php _e( "Copy and paste the following shortcode directly into the page, post or widget where you'd like the feed to show up:", $text_domain ); ?></p>
3
- <input type="text" value="[<?php echo $slug; ?>]" size="20" readonly="readonly" style="text-align: center;" onclick="this.focus();this.select()" title="<?php _e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', $text_domain ); ?>" />
4
-
5
- <h3 style="padding-top: 10px;"><?php _e( 'Multiple Feeds', $text_domain ); ?></h3>
6
- <p><?php _e( "If you'd like to display multiple feeds then you can set different settings directly in the shortcode like so:", $text_domain ); ?>
7
- </br><code>[<?php echo $slug; ?> channel=gopro num=9]</code></p>
8
- <p><?php _e( "You can display as many different feeds as you like, on either the same page or on different pages, by just using the shortcode options below. For example:", $text_domain ); ?><br />
9
- <code>[<?php echo $slug; ?>]</code><br />
10
- <code>[<?php echo $slug; ?> channel="ANOTHER_CHANNEL"]</code><br />
11
- <code>[<?php echo $slug; ?> num=4 showheader=false]</code>
12
- </p>
13
- <p><?php _e( "See the table below for a full list of available shortcode options:", $text_domain ); ?></p>
14
- <p><span class="sbspf_table_key"></span><?php _e( "Pro version only", $text_domain ); ?></p>
15
- <table class="sbspf_shortcode_table">
16
- <tbody>
17
- <tr valign="top">
18
- <th scope="row"><?php _e( 'Shortcode option', $text_domain ); ?></th>
19
- <th scope="row"><?php _e( 'Description', $text_domain ); ?></th>
20
- <th scope="row"><?php _e( 'Example', $text_domain ); ?></th>
21
- </tr>
22
-
23
- <?php foreach ( $this->display_your_feed_sections as $display_your_feed_section ) : ?>
24
- <tr class="sbspf_table_header"><td colspan=3><?php echo $display_your_feed_section['label'] ?></td></tr>
25
- <?php foreach ( $display_your_feed_section['settings'] as $setting ) :
26
- $pro_only_class = '';
27
- if ( in_array( $setting['key'], $this->pro_only, true ) ) {
28
- $pro_only_class = ' class="sbspf_pro_only"';
29
- }
30
- ?>
31
- <tr<?php echo $pro_only_class; ?>>
32
- <td><?php echo $setting['key']; ?></td>
33
- <td><?php echo $setting['description']; ?></td>
34
- <td><code>[<?php echo $slug; ?> <?php echo $setting['key']; ?>="<?php echo str_replace('"', '', $setting['example'] ); ?>"]</code></td>
35
- </tr>
36
- <?php endforeach; ?>
37
-
38
- <?php endforeach; ?>
39
-
40
- </tbody>
41
- </table>
42
- <p><?php echo sby_admin_icon( 'question-circle', 'sbspf_small_svg' ); ?>&nbsp; <?php _e('Need help?', $text_domain ); ?> <a href="?page=<?php echo esc_attr( $slug ); ?>&tab=support"><?php _e('Get Support', $text_domain ); ?></a></p>
1
+ <h3><?php _e( 'Display your Feed', $text_domain ); ?></h3>
2
+ <p><?php _e( "Copy and paste the following shortcode directly into the page, post or widget where you'd like the feed to show up:", $text_domain ); ?></p>
3
+ <input type="text" value="[<?php echo $slug; ?>]" size="20" readonly="readonly" style="text-align: center;" onclick="this.focus();this.select()" title="<?php _e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', $text_domain ); ?>" />
4
+
5
+ <h3 style="padding-top: 10px;"><?php _e( 'Multiple Feeds', $text_domain ); ?></h3>
6
+ <p><?php _e( "If you'd like to display multiple feeds then you can set different settings directly in the shortcode like so:", $text_domain ); ?>
7
+ </br><code>[<?php echo $slug; ?> channel=gopro num=9]</code></p>
8
+ <p><?php _e( "You can display as many different feeds as you like, on either the same page or on different pages, by just using the shortcode options below. For example:", $text_domain ); ?><br />
9
+ <code>[<?php echo $slug; ?>]</code><br />
10
+ <code>[<?php echo $slug; ?> channel="ANOTHER_CHANNEL"]</code><br />
11
+ <code>[<?php echo $slug; ?> num=4 showheader=false]</code>
12
+ </p>
13
+ <p><?php _e( "See the table below for a full list of available shortcode options:", $text_domain ); ?></p>
14
+ <p><span class="sbspf_table_key"></span><?php _e( "Pro version only", $text_domain ); ?></p>
15
+ <table class="sbspf_shortcode_table">
16
+ <tbody>
17
+ <tr valign="top">
18
+ <th scope="row"><?php _e( 'Shortcode option', $text_domain ); ?></th>
19
+ <th scope="row"><?php _e( 'Description', $text_domain ); ?></th>
20
+ <th scope="row"><?php _e( 'Example', $text_domain ); ?></th>
21
+ </tr>
22
+
23
+ <?php foreach ( $this->display_your_feed_sections as $display_your_feed_section ) : ?>
24
+ <tr class="sbspf_table_header"><td colspan=3><?php echo $display_your_feed_section['label'] ?></td></tr>
25
+ <?php foreach ( $display_your_feed_section['settings'] as $setting ) :
26
+ $pro_only_class = '';
27
+ if ( in_array( $setting['key'], $this->pro_only, true ) ) {
28
+ $pro_only_class = ' class="sbspf_pro_only"';
29
+ }
30
+ ?>
31
+ <tr<?php echo $pro_only_class; ?>>
32
+ <td><?php echo $setting['key']; ?></td>
33
+ <td><?php echo $setting['description']; ?></td>
34
+ <td><code>[<?php echo $slug; ?> <?php echo $setting['key']; ?>="<?php echo str_replace('"', '', $setting['example'] ); ?>"]</code></td>
35
+ </tr>
36
+ <?php endforeach; ?>
37
+
38
+ <?php endforeach; ?>
39
+
40
+ </tbody>
41
+ </table>
42
+ <p><?php echo sby_admin_icon( 'question-circle', 'sbspf_small_svg' ); ?>&nbsp; <?php _e('Need help?', $text_domain ); ?> <a href="?page=<?php echo esc_attr( $slug ); ?>&tab=support"><?php _e('Get Support', $text_domain ); ?></a></p>
inc/admin/templates/main.php CHANGED
@@ -1,81 +1,81 @@
1
- <?php
2
- $vars = $this->get_vars();
3
- $text_domain = $vars->text_domain();
4
- $setup_url = $vars->setup_url();
5
- $oauth_processor_url = $vars->oauth_processor_url();
6
- $social_network = $vars->social_network();
7
- $sn_with_a_an = $vars->social_network( true );
8
- $plugin_version = $vars->version();
9
- $demo_url = $vars->demo_url();
10
- $pro_logo = $vars->pro_logo();
11
-
12
- if ( isset( $_POST[ $this->get_option_name() . '_validate' ] ) && $this->verify_post( $_POST ) ) {
13
- $tab = isset( $_POST[ $this->get_option_name() . '_tab_marker' ] ) ? sanitize_text_field( $_POST[ $this->get_option_name() . '_tab_marker' ] ) : 'main';
14
- $new_settings = $this->validate_options( $_POST[ $this->get_option_name() ], $tab );
15
- $this->update_options( $new_settings );
16
- ?>
17
- <div class="updated"><p><strong><?php _e('Settings saved.', $text_domain ); ?></strong></p></div>
18
-
19
- <?php
20
- }
21
- $plugin_name = $this->get_plugin_name();
22
- $active_tab = $this->get_active_tab();
23
- $slug = $this->get_slug();
24
- $tabs = $this->get_tabs();
25
- ?>
26
-
27
- <div id="sbspf_admin" class="wrap sbspf-admin sby_admin" data-sb-plugin="sbspf">
28
- <?php
29
- $lite_notice_dismissed = get_transient( 'youtube_feed_dismiss_lite' );
30
-
31
- if ( ! $lite_notice_dismissed ) :
32
- ?>
33
- <div id="sbspf-notice-bar" style="display:none">
34
- <span class="sbspf-notice-bar-message"><?php _e( 'You\'re using Feeds for YouTube Lite. To unlock more features consider <a href="https://smashballoon.com/youtube-feed/?utm_source=WordPress&utm_campaign=youtubeliteplugin&utm_medium=notice-bar" target="_blank" rel="noopener noreferrer">upgrading to Pro</a>.', $text_domain ); ?></span>
35
- <button type="button" class="dismiss" title="<?php _e( 'Dismiss this message.', $text_domain ); ?>" data-page="overview">
36
- </button>
37
- </div>
38
- <?php endif; ?>
39
-
40
- <?php do_action( 'sby_admin_overview_before_title' ); ?>
41
-
42
- <h1><?php echo esc_html( $plugin_name ); ?></h1>
43
-
44
- <!-- Display the tabs along with styling for the 'active' tab -->
45
- <h2 class="nav-tab-wrapper">
46
- <?php
47
- $i = 1;
48
- foreach ( $tabs as $tab ) :
49
- $title = isset( $tab['numbered_tab'] ) && ! $tab['numbered_tab'] ? __( $tab['title'], 'feeds-for-youtube' ) : $i . '. ' . __( $tab['title'], 'feeds-for-youtube' );
50
- ?>
51
- <a href="admin.php?page=<?php echo esc_attr( $slug ); ?>&tab=<?php echo esc_attr( $tab['slug'] ); ?>" class="nav-tab <?php if ( $active_tab === $tab['slug'] ){ echo 'nav-tab-active'; } ?>"><?php echo $title; ?></a>
52
- <?php
53
- $i ++;
54
- endforeach; ?>
55
- </h2>
56
- <?php
57
- settings_errors();
58
-
59
- include $this->get_path( $active_tab );
60
-
61
- $next_step = $this->next_step();
62
- if ( ! empty( $next_step ) ) : ?>
63
- <p class="sbspf_footer_help">
64
- <?php echo sby_admin_icon( 'chevron-right', 'sbspf_small_svg' ) ; ?>&nbsp; <?php _e('Next Step', $text_domain ); ?>: <a href="?page=<?php echo esc_attr( $slug ); ?>&tab=<?php echo esc_attr( $next_step['next_tab'] ); ?>"><?php echo esc_html( __( $next_step['instructions'], 'feeds-for-youtube' ) ); ?></a>
65
- </p>
66
- <?php endif; ?>
67
-
68
- <p class="sbspf_footer_help"><?php echo sby_admin_icon( 'life-ring', 'sbspf_small_svg' ); ?>&nbsp; <?php _e('Need help setting up the plugin? Check out our <a href="' . esc_url( $setup_url ) . '" target="_blank">setup directions</a>', $text_domain); ?></p>
69
-
70
- <div class="sbspf-quick-start">
71
- <h3><?php echo sby_admin_icon( 'rocket', 'sbspf_small_svg' ); ?>&nbsp; <?php _e( 'Display your feed', $text_domain); ?></h3>
72
- <p><?php _e( "Copy and paste this shortcode directly into the page, post or widget where you'd like to display the feed:", $text_domain ); ?>
73
- <input type="text" value="[<?php echo $slug; ?>]" size="18" readonly="readonly" style="text-align: center;" onclick="this.focus();this.select()" title="<?php _e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', $text_domain ); ?>" /></p>
74
- <p><?php _e( "Find out how to display <a href='?page=".$slug."&tab=display'>multiple feeds</a>.", $text_domain ); ?></p>
75
- </div>
76
-
77
- <a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank" class="sbspf-pro-notice"><img src="<?php echo SBY_PLUGIN_URL . 'img/pro.png' ?>" alt="Pro" /></a>
78
-
79
-
80
- </div>
81
  <div class="wp-clearfix"></div>
1
+ <?php
2
+ $vars = $this->get_vars();
3
+ $text_domain = $vars->text_domain();
4
+ $setup_url = $vars->setup_url();
5
+ $oauth_processor_url = $vars->oauth_processor_url();
6
+ $social_network = $vars->social_network();
7
+ $sn_with_a_an = $vars->social_network( true );
8
+ $plugin_version = $vars->version();
9
+ $demo_url = $vars->demo_url();
10
+ $pro_logo = $vars->pro_logo();
11
+
12
+ if ( isset( $_POST[ $this->get_option_name() . '_validate' ] ) && $this->verify_post( $_POST ) ) {
13
+ $tab = isset( $_POST[ $this->get_option_name() . '_tab_marker' ] ) ? sanitize_text_field( $_POST[ $this->get_option_name() . '_tab_marker' ] ) : 'main';
14
+ $new_settings = $this->validate_options( $_POST[ $this->get_option_name() ], $tab );
15
+ $this->update_options( $new_settings );
16
+ ?>
17
+ <div class="updated"><p><strong><?php _e('Settings saved.', $text_domain ); ?></strong></p></div>
18
+
19
+ <?php
20
+ }
21
+ $plugin_name = $this->get_plugin_name();
22
+ $active_tab = $this->get_active_tab();
23
+ $slug = $this->get_slug();
24
+ $tabs = $this->get_tabs();
25
+ ?>
26
+
27
+ <div id="sbspf_admin" class="wrap sbspf-admin sby_admin" data-sb-plugin="sbspf">
28
+ <?php
29
+ $lite_notice_dismissed = get_transient( 'youtube_feed_dismiss_lite' );
30
+
31
+ if ( ! $lite_notice_dismissed ) :
32
+ ?>
33
+ <div id="sbspf-notice-bar" style="display:none">
34
+ <span class="sbspf-notice-bar-message"><?php _e( 'You\'re using Feeds for YouTube Lite. To unlock more features consider <a href="https://smashballoon.com/youtube-feed/?utm_source=WordPress&utm_campaign=youtubeliteplugin&utm_medium=notice-bar" target="_blank" rel="noopener noreferrer">upgrading to Pro</a>.', $text_domain ); ?></span>
35
+ <button type="button" class="dismiss" title="<?php _e( 'Dismiss this message.', $text_domain ); ?>" data-page="overview">
36
+ </button>
37
+ </div>
38
+ <?php endif; ?>
39
+
40
+ <?php do_action( 'sby_admin_overview_before_title' ); ?>
41
+
42
+ <h1><?php echo esc_html( $plugin_name ); ?></h1>
43
+
44
+ <!-- Display the tabs along with styling for the 'active' tab -->
45
+ <h2 class="nav-tab-wrapper">
46
+ <?php
47
+ $i = 1;
48
+ foreach ( $tabs as $tab ) :
49
+ $title = isset( $tab['numbered_tab'] ) && ! $tab['numbered_tab'] ? __( $tab['title'], 'feeds-for-youtube' ) : $i . '. ' . __( $tab['title'], 'feeds-for-youtube' );
50
+ ?>
51
+ <a href="admin.php?page=<?php echo esc_attr( $slug ); ?>&tab=<?php echo esc_attr( $tab['slug'] ); ?>" class="nav-tab <?php if ( $active_tab === $tab['slug'] ){ echo 'nav-tab-active'; } ?>"><?php echo $title; ?></a>
52
+ <?php
53
+ $i ++;
54
+ endforeach; ?>
55
+ </h2>
56
+ <?php
57
+ settings_errors();
58
+
59
+ include $this->get_path( $active_tab );
60
+
61
+ $next_step = $this->next_step();
62
+ if ( ! empty( $next_step ) ) : ?>
63
+ <p class="sbspf_footer_help">
64
+ <?php echo sby_admin_icon( 'chevron-right', 'sbspf_small_svg' ) ; ?>&nbsp; <?php _e('Next Step', $text_domain ); ?>: <a href="?page=<?php echo esc_attr( $slug ); ?>&tab=<?php echo esc_attr( $next_step['next_tab'] ); ?>"><?php echo esc_html( __( $next_step['instructions'], 'feeds-for-youtube' ) ); ?></a>
65
+ </p>
66
+ <?php endif; ?>
67
+
68
+ <p class="sbspf_footer_help"><?php echo sby_admin_icon( 'life-ring', 'sbspf_small_svg' ); ?>&nbsp; <?php _e('Need help setting up the plugin? Check out our <a href="' . esc_url( $setup_url ) . '" target="_blank">setup directions</a>', $text_domain); ?></p>
69
+
70
+ <div class="sbspf-quick-start">
71
+ <h3><?php echo sby_admin_icon( 'rocket', 'sbspf_small_svg' ); ?>&nbsp; <?php _e( 'Display your feed', $text_domain); ?></h3>
72
+ <p><?php _e( "Copy and paste this shortcode directly into the page, post or widget where you'd like to display the feed:", $text_domain ); ?>
73
+ <input type="text" value="[<?php echo $slug; ?>]" size="18" readonly="readonly" style="text-align: center;" onclick="this.focus();this.select()" title="<?php _e( 'To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', $text_domain ); ?>" /></p>
74
+ <p><?php _e( "Find out how to display <a href='?page=".$slug."&tab=display'>multiple feeds</a>.", $text_domain ); ?></p>
75
+ </div>
76
+
77
+ <a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank" class="sbspf-pro-notice"><img src="<?php echo SBY_PLUGIN_URL . 'img/pro.png' ?>" alt="Pro" /></a>
78
+
79
+
80
+ </div>
81
  <div class="wp-clearfix"></div>
inc/admin/templates/modal.php CHANGED
@@ -1,16 +1,16 @@
1
- <div id="sbspf_modal_overlay">
2
- <div class="sbspf_modal">
3
- <div class="sbspf_modal_message">
4
- <div class="sby_after_connection">
5
- <p class="heading"><?php _e ( 'You have successfully connected your account' ); ?></p>
6
- <p><?php _e ( 'You may receive an email from Google notifying you that our plugin has been granted read-access to your account.', $text_domain ); ?></p>
7
- <p class="sbspf_submit">
8
- <a href="JavaScript:void(0);" class="button button-secondary sbspf_dismiss_at_warning_button" data-action="sby_dismiss_at_warning_notice"><?php esc_html_e( 'Dismiss', $text_domain); ?></a>
9
- </p>
10
- <a href="JavaScript:void(0);" class="sbspf_modal_close sbspf_dismiss_at_warning_button" data-action="sby_dismiss_at_warning_notice"><i class="fa fa-times"></i></a>
11
-
12
- </div>
13
- </div>
14
-
15
- </div>
16
  </div>
1
+ <div id="sbspf_modal_overlay">
2
+ <div class="sbspf_modal">
3
+ <div class="sbspf_modal_message">
4
+ <div class="sby_after_connection">
5
+ <p class="heading"><?php _e ( 'You have successfully connected your account' ); ?></p>
6
+ <p><?php _e ( 'You may receive an email from Google notifying you that our plugin has been granted read-access to your account.', $text_domain ); ?></p>
7
+ <p class="sbspf_submit">
8
+ <a href="JavaScript:void(0);" class="button button-secondary sbspf_dismiss_at_warning_button" data-action="sby_dismiss_at_warning_notice"><?php esc_html_e( 'Dismiss', $text_domain); ?></a>
9
+ </p>
10
+ <a href="JavaScript:void(0);" class="sbspf_modal_close sbspf_dismiss_at_warning_button" data-action="sby_dismiss_at_warning_notice"><i class="fa fa-times"></i></a>
11
+
12
+ </div>
13
+ </div>
14
+
15
+ </div>
16
  </div>
inc/admin/templates/single-connected-account.php CHANGED
@@ -1,61 +1,61 @@
1
- <?php
2
- $just_updated = isset( $_GET['sby_access_token'] ) && $account['access_token'] === $_GET['sby_access_token'];
3
- $just_updated_class = $just_updated ? ' sbspf_just_updated' : '';
4
- ?>
5
-
6
- <div class="sbspf_connected_account<?php echo $just_updated_class; ?>" id="sbspf_connected_account_<?php esc_attr_e( $account['channel_id'] ); ?>" data-accesstoken="<?php esc_attr_e( $account['access_token'] ); ?>" data-userid="<?php esc_attr_e( $account['channel_id'] ); ?>" data-username="<?php esc_attr_e( $account['username'] ); ?>">
7
-
8
- <div class="sbspf_ca_alert">
9
- <span><?php _e( 'The Access Token for this account is expired or invalid. Click the button above to attempt to renew it.', $text_domain ) ?></span>
10
- </div>
11
- <?php if ( $just_updated ) : ?>
12
- <div class="sbspf_ca_alert sbspf_ca_updated">
13
- <span><?php _e( 'Successfully Connected', $text_domain ) ?></span>
14
- </div>
15
- <?php endif; ?>
16
- <div class="sbspf_ca_info">
17
-
18
- <div class="sbspf_ca_delete">
19
- <a href="JavaScript:void(0);" class="sbspf_delete_account"><?php echo sby_admin_icon( 'times', 'sbspf_small_svg' ) ; ?><span class="sbspf_remove_text"><?php _e( 'Remove', $text_domain ); ?></span></a>
20
- </div>
21
-
22
- <div class="sbspf_ca_username">
23
- <?php echo $profile_picture; ?>
24
- <?php if ( ! empty( $account['channel_id'] ) ) : ?>
25
- <strong><?php echo $username; ?><span><?php _e('Channel ID:', $text_domain ); ?><?php echo ' ' . $account['channel_id']; ?></span></strong>
26
- <?php else: ?>
27
- <strong><?php echo $username; ?><span><?php echo sprintf( __( '%sHow to create a channel%s', $text_domain ), '<a href="https://support.google.com/youtube/answer/1646861?hl=en" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></span></strong>
28
- <?php endif; ?>
29
- </div>
30
-
31
- <div class="sbspf_ca_actions">
32
- <?php if ( ! empty( $account['channel_id'] ) ) : ?>
33
- <a class="sbspf_ca_token_shortcode button-secondary" href="JavaScript:void(0);"><?php echo sby_admin_icon( 'chevron-right', 'sbspf_small_svg' ) ; ?><?php _e( 'Add to another Feed', $text_domain ); ?></a>
34
- <?php endif; ?>
35
- <a class="sbspf_ca_show_token button-secondary" href="JavaScript:void(0);" title="<?php _e('Show access token and account info', $text_domain ); ?>"><?php echo sby_admin_icon( 'ellipsis', 'sbspf_small_svg' ) ; ?></a>
36
- </div>
37
-
38
- <div class="sbspf_ca_shortcode">
39
-
40
- <p><?php _e('Copy and paste this shortcode into your page or widget area', $text_domain ); ?>:<br>
41
- <?php if ( !empty( $account['username'] ) ) : ?>
42
- <code>[<?php echo $slug; ?> channel="<?php echo $account['channel_id']; ?>"]</code>
43
- <?php else : ?>
44
- <code>[<?php echo $slug; ?> accesstoken="<?php echo $account['access_token']; ?>"]</code>
45
- <?php endif; ?>
46
- </p>
47
-
48
- <p><?php _e('To add multiple channels in the same feed, simply separate them using commas', $text_domain); ?>:<br>
49
- <code>[<?php echo $slug; ?> channel="<?php echo $account['channel_id']; ?>, a_second_channel, a_third_channel"]</code>
50
-
51
- <p><?php echo sprintf( __('Click on the %s tab to learn more about shortcodes', $text_domain), '<a href="admin.php?page='. esc_attr( $slug ). '&tab=display" target="_blank">'. __( 'Display Your Feed', $text_domain ) . '</a>' ); ?></p>
52
- </div>
53
-
54
- <div class="sbspf_ca_accesstoken">
55
- <span class="sbspf_ca_token_label"><?php _e('Access Token', $text_domain);?>:</span><input type="text" class="sbspf_ca_token" value="<?php echo $account['access_token']; ?>" readonly="readonly" onclick="this.focus();this.select()" title="<?php _e('To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', $text_domain);?>"><br>
56
- <span class="sbspf_ca_token_label"><?php _e('Channel ID', $text_domain);?>:</span><input type="text" class="sbspf_ca_user_id" value="<?php echo $account['channel_id']; ?>" readonly="readonly" onclick="this.focus();this.select()" title="<?php _e('To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', $text_domain);?>"><br>
57
- </div>
58
-
59
- </div>
60
-
61
  </div>
1
+ <?php
2
+ $just_updated = isset( $_GET['sby_access_token'] ) && $account['access_token'] === $_GET['sby_access_token'];
3
+ $just_updated_class = $just_updated ? ' sbspf_just_updated' : '';
4
+ ?>
5
+
6
+ <div class="sbspf_connected_account<?php echo $just_updated_class; ?>" id="sbspf_connected_account_<?php esc_attr_e( $account['channel_id'] ); ?>" data-accesstoken="<?php esc_attr_e( $account['access_token'] ); ?>" data-userid="<?php esc_attr_e( $account['channel_id'] ); ?>" data-username="<?php esc_attr_e( $account['username'] ); ?>">
7
+
8
+ <div class="sbspf_ca_alert">
9
+ <span><?php _e( 'The Access Token for this account is expired or invalid. Click the button above to attempt to renew it.', $text_domain ) ?></span>
10
+ </div>
11
+ <?php if ( $just_updated ) : ?>
12
+ <div class="sbspf_ca_alert sbspf_ca_updated">
13
+ <span><?php _e( 'Successfully Connected', $text_domain ) ?></span>
14
+ </div>
15
+ <?php endif; ?>
16
+ <div class="sbspf_ca_info">
17
+
18
+ <div class="sbspf_ca_delete">
19
+ <a href="JavaScript:void(0);" class="sbspf_delete_account"><?php echo sby_admin_icon( 'times', 'sbspf_small_svg' ) ; ?><span class="sbspf_remove_text"><?php _e( 'Remove', $text_domain ); ?></span></a>
20
+ </div>
21
+
22
+ <div class="sbspf_ca_username">
23
+ <?php echo $profile_picture; ?>
24
+ <?php if ( ! empty( $account['channel_id'] ) ) : ?>
25
+ <strong><?php echo $username; ?><span><?php _e('Channel ID:', $text_domain ); ?><?php echo ' ' . $account['channel_id']; ?></span></strong>
26
+ <?php else: ?>
27
+ <strong><?php echo $username; ?><span><?php echo sprintf( __( '%sHow to create a channel%s', $text_domain ), '<a href="https://support.google.com/youtube/answer/1646861?hl=en" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></span></strong>
28
+ <?php endif; ?>
29
+ </div>
30
+
31
+ <div class="sbspf_ca_actions">
32
+ <?php if ( ! empty( $account['channel_id'] ) ) : ?>
33
+ <a class="sbspf_ca_token_shortcode button-secondary" href="JavaScript:void(0);"><?php echo sby_admin_icon( 'chevron-right', 'sbspf_small_svg' ) ; ?><?php _e( 'Add to another Feed', $text_domain ); ?></a>
34
+ <?php endif; ?>
35
+ <a class="sbspf_ca_show_token button-secondary" href="JavaScript:void(0);" title="<?php _e('Show access token and account info', $text_domain ); ?>"><?php echo sby_admin_icon( 'ellipsis', 'sbspf_small_svg' ) ; ?></a>
36
+ </div>
37
+
38
+ <div class="sbspf_ca_shortcode">
39
+
40
+ <p><?php _e('Copy and paste this shortcode into your page or widget area', $text_domain ); ?>:<br>
41
+ <?php if ( !empty( $account['username'] ) ) : ?>
42
+ <code>[<?php echo $slug; ?> channel="<?php echo $account['channel_id']; ?>"]</code>
43
+ <?php else : ?>
44
+ <code>[<?php echo $slug; ?> accesstoken="<?php echo $account['access_token']; ?>"]</code>
45
+ <?php endif; ?>
46
+ </p>
47
+
48
+ <p><?php _e('To add multiple channels in the same feed, simply separate them using commas', $text_domain); ?>:<br>
49
+ <code>[<?php echo $slug; ?> channel="<?php echo $account['channel_id']; ?>, a_second_channel, a_third_channel"]</code>
50
+
51
+ <p><?php echo sprintf( __('Click on the %s tab to learn more about shortcodes', $text_domain), '<a href="admin.php?page='. esc_attr( $slug ). '&tab=display" target="_blank">'. __( 'Display Your Feed', $text_domain ) . '</a>' ); ?></p>
52
+ </div>
53
+
54
+ <div class="sbspf_ca_accesstoken">
55
+ <span class="sbspf_ca_token_label"><?php _e('Access Token', $text_domain);?>:</span><input type="text" class="sbspf_ca_token" value="<?php echo $account['access_token']; ?>" readonly="readonly" onclick="this.focus();this.select()" title="<?php _e('To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', $text_domain);?>"><br>
56
+ <span class="sbspf_ca_token_label"><?php _e('Channel ID', $text_domain);?>:</span><input type="text" class="sbspf_ca_user_id" value="<?php echo $account['channel_id']; ?>" readonly="readonly" onclick="this.focus();this.select()" title="<?php _e('To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).', $text_domain);?>"><br>
57
+ </div>
58
+
59
+ </div>
60
+
61
  </div>
inc/admin/templates/support.php CHANGED
@@ -1,122 +1,122 @@
1
- <h3><?php _e( 'Need help?', $text_domain ); ?></h3>
2
-
3
- <p><?php echo sby_admin_icon( 'life-ring', 'sbspf_small_svg' ); ?>&nbsp; <?php _e( 'Check out our ', $text_domain ); ?><a href="<?php echo esc_url( $setup_url ); ?>" target="_blank"><?php _e( 'setup directions', $text_domain ); ?></a> <?php _e( 'for a step-by-step guide on how to setup and use the plugin', $text_domain ); ?>.</p>
4
-
5
- <p><?php echo sby_admin_icon( 'envelope', 'sbspf_small_svg' ); ?>&nbsp; <?php _e( 'Have a problem? Submit a ', $text_domain ); ?><a href="<?php echo esc_url( SBY_SUPPORT_URL ); ?>" target="_blank"><?php _e( 'support ticket', $text_domain ); ?></a> <?php _e( 'on our website', $text_domain ); ?>. <?php _e( 'Please include your <b>System Info</b> below with all support requests.', $text_domain ); ?></p>
6
-
7
- <br />
8
- <h3><?php _e('System Info', $text_domain ); ?> &nbsp; <span style="color: #666; font-size: 11px; font-weight: normal;"><?php _e( 'Click the text below to select all', $text_domain ); ?></span></h3>
9
-
10
- <textarea readonly="readonly" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)." style="width: 70%; height: 500px; white-space: pre; font-family: Menlo,Monaco,monospace;">
11
- ## SITE/SERVER INFO: ##
12
- Plugin Version: <?php echo $plugin_name . ' v' . $plugin_version. "\n"; ?>
13
- Site URL: <?php echo site_url() . "\n"; ?>
14
- Home URL: <?php echo home_url() . "\n"; ?>
15
- WordPress Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
16
- PHP Version: <?php echo PHP_VERSION . "\n"; ?>
17
- Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
18
- PHP allow_url_fopen: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes" . "\n" : "No" . "\n"; ?>
19
- PHP cURL: <?php echo is_callable('curl_init') ? "Yes" . "\n" : "No" . "\n"; ?>
20
- JSON: <?php echo function_exists("json_decode") ? "Yes" . "\n" : "No" . "\n" ?>
21
- SSL Stream: <?php echo in_array('https', stream_get_wrappers()) ? "Yes" . "\n" : "No" . "\n" //extension=php_openssl.dll in php.ini ?>
22
-
23
- ## ACTIVE PLUGINS: ##
24
- <?php
25
- $plugins = get_plugins();
26
- $active_plugins = get_option( 'active_plugins', array() );
27
-
28
- foreach ( $plugins as $plugin_path => $plugin ) {
29
- // If the plugin isn't active, don't show it.
30
- if ( in_array( $plugin_path, $active_plugins ) ) {
31
- echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
32
- }
33
- }
34
- ?>
35
-
36
- ## OPTIONS: ##
37
- <?php
38
- $options = get_option( $this->get_option_name(), array() );
39
- foreach ( $options as $key => $val ) {
40
- if ( $key !== 'connected_accounts' ) {
41
- if ( is_array( $val ) ) {
42
- foreach ( $val as $key2 => $val2 ) {
43
- if ( is_array( $val2 ) ) {
44
- foreach ( $val2 as $key3 => $val3 ) {
45
- $label = $key . ':';
46
- $value = isset( $val3 ) ? esc_attr( $val3 ) : 'unset';
47
- echo str_pad( $label, 24 ) . $value ."\n";
48
- }
49
- } else {
50
- $label = $key . ':';
51
- $value = isset( $val2 ) ? esc_attr( $val2 ) : 'unset';
52
- echo str_pad( $label, 24 ) . $value ."\n";
53
- }
54
- }
55
- } else {
56
- $label = $key . ':';
57
- $value = isset( $val ) ? esc_attr( $val ) : 'unset';
58
- echo str_pad( $label, 24 ) . $value ."\n";
59
- }
60
- }
61
- }
62
- ?>
63
-
64
- ## Connected Accounts: ##
65
- <?php
66
- foreach ( $options['connected_accounts'] as $account ) {
67
- foreach ( $account as $key2 => $val2 ) {
68
- if ( is_array( $val2 ) ) {
69
- foreach ( $val2 as $key3 => $val3 ) {
70
- $label = $key3 . ':';
71
- $value = isset( $val3 ) ? esc_attr( $val3 ) : 'unset';
72
- echo str_pad( $label, 24 ) . $value ."\n";
73
- }
74
- } else {
75
- $label = $key2 . ':';
76
- $value = isset( $val2 ) ? esc_attr( $val2 ) : 'unset';
77
- echo str_pad( $label, 24 ) . $value ."\n";
78
- }
79
- }
80
- }
81
- ?>
82
-
83
- ## Cron Events: ##
84
- <?php
85
- $cron = _get_cron_array();
86
- foreach ( $cron as $key => $data ) {
87
- $is_target = false;
88
- foreach ( $data as $key2 => $val ) {
89
- if ( strpos( $key2, 'sby' ) !== false ) {
90
- $is_target = true;
91
- echo $key2;
92
- echo "\n";
93
- }
94
- }
95
- if ( $is_target) {
96
- echo date( "Y-m-d H:i:s", $key );
97
- echo "\n";
98
- echo 'Next Scheduled: ' . ((int)$key - time())/60 . ' minutes';
99
- echo "\n\n";
100
- }
101
- }
102
- ?>
103
- ## Cron Cache Report: ##
104
- <?php $cron_report = get_option( 'sby_cron_report', array() );
105
- if ( ! empty( $cron_report ) ) {
106
- var_export( $cron_report );
107
- }
108
- echo "\n";
109
- ?>
110
-
111
- ## Error Log: ##
112
- <?php
113
- global $sby_posts_manager;
114
- $errors = $sby_posts_manager->get_errors();
115
- if ( ! empty( $errors ) ) :
116
- foreach ( $errors as $type => $error ) :
117
- echo $type . ': ' . str_replace( array( '<p>', '<b>', '</p>', '</b>' ), ' ', $error[1] ) . "\n";
118
- endforeach;
119
- endif;
120
- ?>
121
-
122
  </textarea>
1
+ <h3><?php _e( 'Need help?', $text_domain ); ?></h3>
2
+
3
+ <p><?php echo sby_admin_icon( 'life-ring', 'sbspf_small_svg' ); ?>&nbsp; <?php _e( 'Check out our ', $text_domain ); ?><a href="<?php echo esc_url( $setup_url ); ?>" target="_blank"><?php _e( 'setup directions', $text_domain ); ?></a> <?php _e( 'for a step-by-step guide on how to setup and use the plugin', $text_domain ); ?>.</p>
4
+
5
+ <p><?php echo sby_admin_icon( 'envelope', 'sbspf_small_svg' ); ?>&nbsp; <?php _e( 'Have a problem? Submit a ', $text_domain ); ?><a href="<?php echo esc_url( SBY_SUPPORT_URL ); ?>" target="_blank"><?php _e( 'support ticket', $text_domain ); ?></a> <?php _e( 'on our website', $text_domain ); ?>. <?php _e( 'Please include your <b>System Info</b> below with all support requests.', $text_domain ); ?></p>
6
+
7
+ <br />
8
+ <h3><?php _e('System Info', $text_domain ); ?> &nbsp; <span style="color: #666; font-size: 11px; font-weight: normal;"><?php _e( 'Click the text below to select all', $text_domain ); ?></span></h3>
9
+
10
+ <textarea readonly="readonly" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)." style="width: 70%; height: 500px; white-space: pre; font-family: Menlo,Monaco,monospace;">
11
+ ## SITE/SERVER INFO: ##
12
+ Plugin Version: <?php echo $plugin_name . ' v' . $plugin_version. "\n"; ?>
13
+ Site URL: <?php echo site_url() . "\n"; ?>
14
+ Home URL: <?php echo home_url() . "\n"; ?>
15
+ WordPress Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
16
+ PHP Version: <?php echo PHP_VERSION . "\n"; ?>
17
+ Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
18
+ PHP allow_url_fopen: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes" . "\n" : "No" . "\n"; ?>
19
+ PHP cURL: <?php echo is_callable('curl_init') ? "Yes" . "\n" : "No" . "\n"; ?>
20
+ JSON: <?php echo function_exists("json_decode") ? "Yes" . "\n" : "No" . "\n" ?>
21
+ SSL Stream: <?php echo in_array('https', stream_get_wrappers()) ? "Yes" . "\n" : "No" . "\n" //extension=php_openssl.dll in php.ini ?>
22
+
23
+ ## ACTIVE PLUGINS: ##
24
+ <?php
25
+ $plugins = get_plugins();
26
+ $active_plugins = get_option( 'active_plugins', array() );
27
+
28
+ foreach ( $plugins as $plugin_path => $plugin ) {
29
+ // If the plugin isn't active, don't show it.
30
+ if ( in_array( $plugin_path, $active_plugins ) ) {
31
+ echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
32
+ }
33
+ }
34
+ ?>
35
+
36
+ ## OPTIONS: ##
37
+ <?php
38
+ $options = get_option( $this->get_option_name(), array() );
39
+ foreach ( $options as $key => $val ) {
40
+ if ( $key !== 'connected_accounts' ) {
41
+ if ( is_array( $val ) ) {
42
+ foreach ( $val as $key2 => $val2 ) {
43
+ if ( is_array( $val2 ) ) {
44
+ foreach ( $val2 as $key3 => $val3 ) {
45
+ $label = $key . ':';
46
+ $value = isset( $val3 ) ? esc_attr( $val3 ) : 'unset';
47
+ echo str_pad( $label, 24 ) . $value ."\n";
48
+ }
49
+ } else {
50
+ $label = $key . ':';
51
+ $value = isset( $val2 ) ? esc_attr( $val2 ) : 'unset';
52
+ echo str_pad( $label, 24 ) . $value ."\n";
53
+ }
54
+ }
55
+ } else {
56
+ $label = $key . ':';
57
+ $value = isset( $val ) ? esc_attr( $val ) : 'unset';
58
+ echo str_pad( $label, 24 ) . $value ."\n";
59
+ }
60
+ }
61
+ }
62
+ ?>
63
+
64
+ ## Connected Accounts: ##
65
+ <?php
66
+ foreach ( $options['connected_accounts'] as $account ) {
67
+ foreach ( $account as $key2 => $val2 ) {
68
+ if ( is_array( $val2 ) ) {
69
+ foreach ( $val2 as $key3 => $val3 ) {
70
+ $label = $key3 . ':';
71
+ $value = isset( $val3 ) ? esc_attr( $val3 ) : 'unset';
72
+ echo str_pad( $label, 24 ) . $value ."\n";
73
+ }
74
+ } else {
75
+ $label = $key2 . ':';
76
+ $value = isset( $val2 ) ? esc_attr( $val2 ) : 'unset';
77
+ echo str_pad( $label, 24 ) . $value ."\n";
78
+ }
79
+ }
80
+ }
81
+ ?>
82
+
83
+ ## Cron Events: ##
84
+ <?php
85
+ $cron = _get_cron_array();
86
+ foreach ( $cron as $key => $data ) {
87
+ $is_target = false;
88
+ foreach ( $data as $key2 => $val ) {
89
+ if ( strpos( $key2, 'sby' ) !== false ) {
90
+ $is_target = true;
91
+ echo $key2;
92
+ echo "\n";
93
+ }
94
+ }
95
+ if ( $is_target) {
96
+ echo date( "Y-m-d H:i:s", $key );
97
+ echo "\n";
98
+ echo 'Next Scheduled: ' . ((int)$key - time())/60 . ' minutes';
99
+ echo "\n\n";
100
+ }
101
+ }
102
+ ?>
103
+ ## Cron Cache Report: ##
104
+ <?php $cron_report = get_option( 'sby_cron_report', array() );
105
+ if ( ! empty( $cron_report ) ) {
106
+ var_export( $cron_report );
107
+ }
108
+ echo "\n";
109
+ ?>
110
+
111
+ ## Error Log: ##
112
+ <?php
113
+ global $sby_posts_manager;
114
+ $errors = $sby_posts_manager->get_errors();
115
+ if ( ! empty( $errors ) ) :
116
+ foreach ( $errors as $type => $error ) :
117
+ echo $type . ': ' . str_replace( array( '<p>', '<b>', '</p>', '</b>' ), ' ', $error[1] ) . "\n";
118
+ endforeach;
119
+ endif;
120
+ ?>
121
+
122
  </textarea>
inc/blocks/class-sby-blocks.php CHANGED
@@ -1,149 +1,149 @@
1
- <?php
2
- /**
3
- * Instagram Feed block with live preview.
4
- *
5
- * @since 1.7.1
6
- */
7
- class SBY_Blocks {
8
-
9
- /**
10
- * Indicates if current integration is allowed to load.
11
- *
12
- * @since 1.8
13
- *
14
- * @return bool
15
- */
16
- public function allow_load() {
17
- return function_exists( 'register_block_type' );
18
- }
19
-
20
- /**
21
- * Loads an integration.
22
- *
23
- * @since 1.7.1
24
- */
25
- public function load() {
26
- $this->hooks();
27
- }
28
-
29
- /**
30
- * Integration hooks.
31
- *
32
- * @since 1.7.1
33
- */
34
- protected function hooks() {
35
- add_action( 'init', array( $this, 'register_block' ) );
36
- add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
37
- }
38
-
39
- /**
40
- * Register Instagram Feed Gutenberg block on the backend.
41
- *
42
- * @since 1.7.1
43
- */
44
- public function register_block() {
45
-
46
- wp_register_style(
47
- 'sby-blocks-styles',
48
- trailingslashit( SBY_PLUGIN_URL ) . 'css/sby-blocks.css',
49
- array( 'wp-edit-blocks' ),
50
- SBYVER
51
- );
52
-
53
- $attributes = array(
54
- 'shortcodeSettings' => array(
55
- 'type' => 'string',
56
- ),
57
- 'noNewChanges' => array(
58
- 'type' => 'boolean',
59
- ),
60
- 'executed' => array(
61
- 'type' => 'boolean',
62
- )
63
- );
64
-
65
- register_block_type(
66
- 'sby/sby-feed-block',
67
- array(
68
- 'attributes' => $attributes,
69
- 'render_callback' => array( $this, 'get_feed_html' ),
70
- )
71
- );
72
- }
73
-
74
- /**
75
- * Load Instagram Feed Gutenberg block scripts.
76
- *
77
- * @since 1.7.1
78
- */
79
- public function enqueue_block_editor_assets() {
80
- sby_scripts_enqueue( true );
81
-
82
- wp_enqueue_style( 'sby-blocks-styles' );
83
- wp_enqueue_script(
84
- 'sby-feed-block',
85
- trailingslashit( SBY_PLUGIN_URL ) . 'js/sby-blocks.js',
86
- array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
87
- SBYVER,
88
- true
89
- );
90
-
91
- $shortcodeSettings = '';
92
-
93
- $i18n = array(
94
- 'addSettings' => esc_html__( 'Add Settings', SBY_TEXT_DOMAIN ),
95
- 'shortcodeSettings' => esc_html__( 'Shortcode Settings', SBY_TEXT_DOMAIN ),
96
- 'example' => esc_html__( 'Example', SBY_TEXT_DOMAIN ),
97
- 'preview' => esc_html__( 'Apply Changes', SBY_TEXT_DOMAIN ),
98
-
99
- );
100
-
101
- wp_localize_script(
102
- 'sby-feed-block',
103
- 'sby_block_editor',
104
- array(
105
- 'wpnonce' => wp_create_nonce( 'sby-blocks' ),
106
- 'canShowFeed' => true,
107
- 'shortcodeSettings' => $shortcodeSettings,
108
- 'i18n' => $i18n,
109
- )
110
- );
111
- }
112
-
113
- /**
114
- * Get form HTML to display in a Instagram Feed Gutenberg block.
115
- *
116
- * @param array $attr Attributes passed by Instagram Feed Gutenberg block.
117
- *
118
- * @since 1.7.1
119
- *
120
- * @return string
121
- */
122
- public function get_feed_html( $attr ) {
123
-
124
- $return = '';
125
-
126
- $shortcode_settings = isset( $attr['shortcodeSettings'] ) ? $attr['shortcodeSettings'] : '';
127
-
128
- $shortcode_settings = str_replace(array( '[youtube-feed', ']' ), '', $shortcode_settings );
129
-
130
- $return .= do_shortcode( '[youtube-feed '.$shortcode_settings.']' );
131
-
132
- return $return;
133
-
134
- }
135
-
136
- /**
137
- * Checking if is Gutenberg REST API call.
138
- *
139
- * @since 1.7.1
140
- *
141
- * @return bool True if is Gutenberg REST API call.
142
- */
143
- public static function is_gb_editor() {
144
-
145
- // TODO: Find a better way to check if is GB editor API call.
146
- return defined( 'REST_REQUEST' ) && REST_REQUEST && ! empty( $_REQUEST['context'] ) && 'edit' === $_REQUEST['context']; // phpcs:ignore
147
- }
148
-
149
- }
1
+ <?php
2
+ /**
3
+ * Instagram Feed block with live preview.
4
+ *
5
+ * @since 1.7.1
6
+ */
7
+ class SBY_Blocks {
8
+
9
+ /**
10
+ * Indicates if current integration is allowed to load.
11
+ *
12
+ * @since 1.8
13
+ *
14
+ * @return bool
15
+ */
16
+ public function allow_load() {
17
+ return function_exists( 'register_block_type' );
18
+ }
19
+
20
+ /**
21
+ * Loads an integration.
22
+ *
23
+ * @since 1.7.1
24
+ */
25
+ public function load() {
26
+ $this->hooks();
27
+ }
28
+
29
+ /**
30
+ * Integration hooks.
31
+ *
32
+ * @since 1.7.1
33
+ */
34
+ protected function hooks() {
35
+ add_action( 'init', array( $this, 'register_block' ) );
36
+ add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
37
+ }
38
+
39
+ /**
40
+ * Register Instagram Feed Gutenberg block on the backend.
41
+ *
42
+ * @since 1.7.1
43
+ */
44
+ public function register_block() {
45
+
46
+ wp_register_style(
47
+ 'sby-blocks-styles',
48
+ trailingslashit( SBY_PLUGIN_URL ) . 'css/sby-blocks.css',
49
+ array( 'wp-edit-blocks' ),
50
+ SBYVER
51
+ );
52
+
53
+ $attributes = array(
54
+ 'shortcodeSettings' => array(
55
+ 'type' => 'string',
56
+ ),
57
+ 'noNewChanges' => array(
58
+ 'type' => 'boolean',
59
+ ),
60
+ 'executed' => array(
61
+ 'type' => 'boolean',
62
+ )
63
+ );
64
+
65
+ register_block_type(
66
+ 'sby/sby-feed-block',
67
+ array(
68
+ 'attributes' => $attributes,
69
+ 'render_callback' => array( $this, 'get_feed_html' ),
70
+ )
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Load Instagram Feed Gutenberg block scripts.
76
+ *
77
+ * @since 1.7.1
78
+ */
79
+ public function enqueue_block_editor_assets() {
80
+ sby_scripts_enqueue( true );
81
+
82
+ wp_enqueue_style( 'sby-blocks-styles' );
83
+ wp_enqueue_script(
84
+ 'sby-feed-block',
85
+ trailingslashit( SBY_PLUGIN_URL ) . 'js/sby-blocks.js',
86
+ array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
87
+ SBYVER,
88
+ true
89
+ );
90
+
91
+ $shortcodeSettings = '';
92
+
93
+ $i18n = array(
94
+ 'addSettings' => esc_html__( 'Add Settings', SBY_TEXT_DOMAIN ),
95
+ 'shortcodeSettings' => esc_html__( 'Shortcode Settings', SBY_TEXT_DOMAIN ),
96
+ 'example' => esc_html__( 'Example', SBY_TEXT_DOMAIN ),
97
+ 'preview' => esc_html__( 'Apply Changes', SBY_TEXT_DOMAIN ),
98
+
99
+ );
100
+
101
+ wp_localize_script(
102
+ 'sby-feed-block',
103
+ 'sby_block_editor',
104
+ array(
105
+ 'wpnonce' => wp_create_nonce( 'sby-blocks' ),
106
+ 'canShowFeed' => true,
107
+ 'shortcodeSettings' => $shortcodeSettings,
108
+ 'i18n' => $i18n,
109
+ )
110
+ );
111
+ }
112
+
113
+ /**
114
+ * Get form HTML to display in a Instagram Feed Gutenberg block.
115
+ *
116
+ * @param array $attr Attributes passed by Instagram Feed Gutenberg block.
117
+ *
118
+ * @since 1.7.1
119
+ *
120
+ * @return string
121
+ */
122
+ public function get_feed_html( $attr ) {
123
+
124
+ $return = '';
125
+
126
+ $shortcode_settings = isset( $attr['shortcodeSettings'] ) ? $attr['shortcodeSettings'] : '';
127
+
128
+ $shortcode_settings = str_replace(array( '[youtube-feed', ']' ), '', $shortcode_settings );
129
+
130
+ $return .= do_shortcode( '[youtube-feed '.$shortcode_settings.']' );
131
+
132
+ return $return;
133
+
134
+ }
135
+
136
+ /**
137
+ * Checking if is Gutenberg REST API call.
138
+ *
139
+ * @since 1.7.1
140
+ *
141
+ * @return bool True if is Gutenberg REST API call.
142
+ */
143
+ public static function is_gb_editor() {
144
+
145
+ // TODO: Find a better way to check if is GB editor API call.
146
+ return defined( 'REST_REQUEST' ) && REST_REQUEST && ! empty( $_REQUEST['context'] ) && 'edit' === $_REQUEST['context']; // phpcs:ignore
147
+ }
148
+
149
+ }
inc/class-sby-api-connect.php CHANGED
@@ -1,195 +1,195 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- die( '-1' );
4
- }
5
-
6
- class SBY_API_Connect
7
- {
8
- /**
9
- * @var string
10
- */
11
- private $url;
12
-
13
- /**
14
- * @var object
15
- */
16
- protected $response;
17
-
18
- public function __construct( $connected_account_or_url, $endpoint = '', $params = array() ) {
19
- if ( is_array( $connected_account_or_url ) && isset( $connected_account_or_url['access_token'] ) ) {
20
- $this->set_url( $connected_account_or_url, $endpoint, $params );
21
- } elseif ( is_array( $connected_account_or_url ) ) {
22
- $this->set_url( $connected_account_or_url, $endpoint, $params );
23
- } elseif ( strpos( $connected_account_or_url, 'https' ) !== false ) {
24
- $this->url = $connected_account_or_url;
25
- } else {
26
- $this->url = '';
27
- }
28
- }
29
-
30
- public function get_data() {
31
- if (!is_wp_error($this->response) && !empty($this->response['data'])) {
32
- return $this->response['data'];
33
- } else {
34
- return $this->response;
35
- }
36
- }
37
-
38
- public function get_wp_error() {
39
- if ( $this->is_wp_error() ) {
40
- return array( 'response' => $this->response, 'url' => $this->url );
41
- } else {
42
- return false;
43
- }
44
- }
45
-
46
- public function get_next_page( $params = false ) {
47
- if ( ! empty( $this->response['nextPageToken'] ) ) {
48
- return $this->response['nextPageToken'];
49
- } else {
50
- return '';
51
- }
52
- }
53
-
54
- public function set_url_from_args( $url ) {
55
- $this->url = $url;
56
- }
57
-
58
- public function get_url() {
59
- return $this->url;
60
- }
61
-
62
- public function is_wp_error() {
63
- return is_wp_error( $this->response );
64
- }
65
-
66
-
67
- public function is_youtube_error() {
68
- return (is_wp_error( $this->response ) || isset( $this->response['error'] ));
69
- }
70
-
71
- public function connect() {
72
- $args = array(
73
- 'timeout' => 60,
74
- 'sslverify' => false
75
- );
76
- $response = wp_remote_get( esc_url_raw( $this->url ), $args );
77
-
78
- if ( ! is_wp_error( $response ) ) {
79
- // certain ways of representing the html for double quotes causes errors so replaced here.
80
- $response = json_decode( str_replace( '%22', '&rdquo;', $response['body'] ), true );
81
- }
82
-
83
- $this->response = $response;
84
- }
85
-
86
- public static function handle_youtube_error( $response, $error_connected_account, $request_type = '' ) {
87
- //
88
- if ( isset( $response['error'] ) ) {
89
- if ( isset( $response['error']['errors'][0]['reason'] ) && $response['error']['errors'][0]['message'] === 'Invalid Credentials' ) {
90
- $error_message = '<p><b>' . __( 'Reconnect to YouTube to show this feed.', 'custom-facebook-feed' ) . '</b></p>';
91
- $error_message .= '<p>' . __( 'To create a new feed, first connect to YouTube using the "Connect to YouTube to Create a Feed" button on the settings page and connect any account.', SBY_TEXT_DOMAIN ) . '</p>';
92
-
93
- if ( current_user_can( 'manage_youtube_feed_options' ) ) {
94
- $error_message .= '<a href="' . admin_url( 'admin.php?page=youtube-feed' ) . '" target="blank" rel="noopener nofollow">' . __( 'Reconnect in the YouTube Feed Settings Area' ) . '</a>';
95
- }
96
- global $sby_posts_manager;
97
-
98
- $sby_posts_manager->add_frontend_error( 'accesstoken', $error_message );
99
- $sby_posts_manager->add_error( 'accesstoken', array( 'Trying to connect a new account', $error_message ) );
100
-
101
- return false;
102
- } elseif ( isset( $response['error']['errors'][0]['reason'] ) ) {
103
- $error = $response['error']['errors'][0]['message'];
104
-
105
- $error_message = '<p><b>'. sprintf( __( 'Error %s: %s.', 'instagram-feed' ), $response['error']['code'], $error ) .'</b></p>';
106
- $error_message .= '<p>Domain code: ' . $response['error']['errors'][0]['domain'];
107
- $error_message .= '<br>Reason code: ' . $response['error']['errors'][0]['reason'];
108
- if ( current_user_can( 'manage_youtube_feed_options' ) ) {
109
- if ( isset( $response['error']['errors'][0]['extendedHelp'] ) ) {
110
- $error_message .= '<br>Extended Help Link: ' . $response['error']['errors'][0]['extendedHelp'];
111
- }
112
- $error_message .= '</p>';
113
-
114
- $error_message .= '<a href="https://smashballoon.com/youtube-feed/docs/errors/" target="blank" rel="noopener nofollow">' . __( 'Directions on how to resolve this issue' ) . '</a>';
115
- } else {
116
- $error_message .= '</p>';
117
- }
118
-
119
- global $sby_posts_manager;
120
-
121
- $sby_posts_manager->add_frontend_error( 'api', $error_message );
122
- $sby_posts_manager->add_error( 'api', array( 'Error connecting', $error_message ) );
123
-
124
- $sby_posts_manager->add_api_request_delay( 300 );
125
- }
126
- }
127
- }
128
-
129
- public static function handle_wp_remote_get_error( $response ) {
130
- $message = sprintf( __( 'Error connecting to %s.', SBY_TEXT_DOMAIN ), $response['url'] ). ' ';
131
- if ( isset( $response['response'] ) && isset( $response['response']->errors ) ) {
132
- foreach ( $response['response']->errors as $key => $item ) {
133
- $message .= ' '.$key . ' - ' . $item[0] . ' |';
134
- }
135
- }
136
-
137
- global $sby_posts_manager;
138
-
139
- $sby_posts_manager->add_api_request_delay( 300 );
140
-
141
- $sby_posts_manager->add_error( 'connection', array( 'Error connecting', $message ) );
142
- }
143
-
144
- protected function set_url( $connected_account, $endpoint_slug, $params ) {
145
- $num = ! empty( $params['num'] ) && isset( $connected_account['api_key'] ) ? (int)$params['num'] : 50;
146
-
147
- if ( $endpoint_slug === 'tokeninfo' ) {
148
- $url = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=' . $connected_account['access_token'];
149
- } elseif ( $endpoint_slug === 'channels' ) {
150
- $channel_param = 'mine=true';
151
- if ( isset( $params['channel_name'] ) ) {
152
- $channel_param = 'forUsername=' . $params['channel_name'];
153
- } elseif ( isset( $params['channel_id'] ) ) {
154
- $channel_param = 'id=' . $params['channel_id'];
155
- }
156
-
157
- $access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
158
-
159
- $url = 'https://www.googleapis.com/youtube/v3/channels?part=id,snippet,contentDetails&'.$channel_param.'&' . $access_credentials;
160
- } elseif ( $endpoint_slug === 'playlistItems' ) {
161
- $access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
162
- $next_page = '';
163
- if ( isset( $params['nextPageToken'] ) ) {
164
- $next_page = '&pageToken=' . $params['nextPageToken'];
165
- }
166
-
167
- $url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=id,snippet&maxResults='.$num.'&playlistId='.$params['playlist_id'].'&' . $access_credentials . $next_page;
168
- } else {
169
- $channel_param = 'mine=true';
170
- if ( isset( $params['username'] ) ) {
171
- $channel_param = 'forUsername=' . $params['username'];
172
- } elseif ( isset( $params['channel_id'] ) ) {
173
- $channel_param = 'id=' . $params['channel_id'];
174
- }
175
- $access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
176
-
177
- $url = 'https://www.googleapis.com/youtube/v3/channels?part=id,snippet&'.$channel_param.'&' . $access_credentials;
178
- }
179
-
180
- $this->set_url_from_args( $url );
181
- }
182
-
183
- public static function refresh_token( $client_id, $refresh_token, $client_secret ) {
184
- $response = wp_remote_post( 'https://www.googleapis.com/oauth2/v4/token/?client_id=' . $client_id . '&client_secret=' . $client_secret . '&refresh_token='. $refresh_token . '&grant_type=refresh_token' );
185
-
186
- if ( $response['response']['code'] === 200 ) {
187
- $return = json_decode( $response['body'], true );
188
- } else {
189
- $return = array();
190
- }
191
-
192
- return $return;
193
- }
194
-
195
  }
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die( '-1' );
4
+ }
5
+
6
+ class SBY_API_Connect
7
+ {
8
+ /**
9
+ * @var string
10
+ */
11
+ private $url;
12
+
13
+ /**
14
+ * @var object
15
+ */
16
+ protected $response;
17
+
18
+ public function __construct( $connected_account_or_url, $endpoint = '', $params = array() ) {
19
+ if ( is_array( $connected_account_or_url ) && isset( $connected_account_or_url['access_token'] ) ) {
20
+ $this->set_url( $connected_account_or_url, $endpoint, $params );
21
+ } elseif ( is_array( $connected_account_or_url ) ) {
22
+ $this->set_url( $connected_account_or_url, $endpoint, $params );
23
+ } elseif ( strpos( $connected_account_or_url, 'https' ) !== false ) {
24
+ $this->url = $connected_account_or_url;
25
+ } else {
26
+ $this->url = '';
27
+ }
28
+ }
29
+
30
+ public function get_data() {
31
+ if (!is_wp_error($this->response) && !empty($this->response['data'])) {
32
+ return $this->response['data'];
33
+ } else {
34
+ return $this->response;
35
+ }
36
+ }
37
+
38
+ public function get_wp_error() {
39
+ if ( $this->is_wp_error() ) {
40
+ return array( 'response' => $this->response, 'url' => $this->url );
41
+ } else {
42
+ return false;
43
+ }
44
+ }
45
+
46
+ public function get_next_page( $params = false ) {
47
+ if ( ! empty( $this->response['nextPageToken'] ) ) {
48
+ return $this->response['nextPageToken'];
49
+ } else {
50
+ return '';
51
+ }
52
+ }
53
+
54
+ public function set_url_from_args( $url ) {
55
+ $this->url = $url;
56
+ }
57
+
58
+ public function get_url() {
59
+ return $this->url;
60
+ }
61
+
62
+ public function is_wp_error() {
63
+ return is_wp_error( $this->response );
64
+ }
65
+
66
+
67
+ public function is_youtube_error() {
68
+ return (is_wp_error( $this->response ) || isset( $this->response['error'] ));
69
+ }
70
+
71
+ public function connect() {
72
+ $args = array(
73
+ 'timeout' => 60,
74
+ 'sslverify' => false
75
+ );
76
+ $response = wp_remote_get( esc_url_raw( $this->url ), $args );
77
+
78
+ if ( ! is_wp_error( $response ) ) {
79
+ // certain ways of representing the html for double quotes causes errors so replaced here.
80
+ $response = json_decode( str_replace( '%22', '&rdquo;', $response['body'] ), true );
81
+ }
82
+
83
+ $this->response = $response;
84
+ }
85
+
86
+ public static function handle_youtube_error( $response, $error_connected_account, $request_type = '' ) {
87
+ //
88
+ if ( isset( $response['error'] ) ) {
89
+ if ( isset( $response['error']['errors'][0]['reason'] ) && $response['error']['errors'][0]['message'] === 'Invalid Credentials' ) {
90
+ $error_message = '<p><b>' . __( 'Reconnect to YouTube to show this feed.', 'custom-facebook-feed' ) . '</b></p>';
91
+ $error_message .= '<p>' . __( 'To create a new feed, first connect to YouTube using the "Connect to YouTube to Create a Feed" button on the settings page and connect any account.', SBY_TEXT_DOMAIN ) . '</p>';
92
+
93
+ if ( current_user_can( 'manage_youtube_feed_options' ) ) {
94
+ $error_message .= '<a href="' . admin_url( 'admin.php?page=youtube-feed' ) . '" target="blank" rel="noopener nofollow">' . __( 'Reconnect in the YouTube Feed Settings Area' ) . '</a>';
95
+ }
96
+ global $sby_posts_manager;
97
+
98
+ $sby_posts_manager->add_frontend_error( 'accesstoken', $error_message );
99
+ $sby_posts_manager->add_error( 'accesstoken', array( 'Trying to connect a new account', $error_message ) );
100
+
101
+ return false;
102
+ } elseif ( isset( $response['error']['errors'][0]['reason'] ) ) {
103
+ $error = $response['error']['errors'][0]['message'];
104
+
105
+ $error_message = '<p><b>'. sprintf( __( 'Error %s: %s.', 'instagram-feed' ), $response['error']['code'], $error ) .'</b></p>';
106
+ $error_message .= '<p>Domain code: ' . $response['error']['errors'][0]['domain'];
107
+ $error_message .= '<br>Reason code: ' . $response['error']['errors'][0]['reason'];
108
+ if ( current_user_can( 'manage_youtube_feed_options' ) ) {
109
+ if ( isset( $response['error']['errors'][0]['extendedHelp'] ) ) {
110
+ $error_message .= '<br>Extended Help Link: ' . $response['error']['errors'][0]['extendedHelp'];
111
+ }
112
+ $error_message .= '</p>';
113
+
114
+ $error_message .= '<a href="https://smashballoon.com/youtube-feed/docs/errors/" target="blank" rel="noopener nofollow">' . __( 'Directions on how to resolve this issue' ) . '</a>';
115
+ } else {
116
+ $error_message .= '</p>';
117
+ }
118
+
119
+ global $sby_posts_manager;
120
+
121
+ $sby_posts_manager->add_frontend_error( 'api', $error_message );
122
+ $sby_posts_manager->add_error( 'api', array( 'Error connecting', $error_message ) );
123
+
124
+ $sby_posts_manager->add_api_request_delay( 300 );
125
+ }
126
+ }
127
+ }
128
+
129
+ public static function handle_wp_remote_get_error( $response ) {
130
+ $message = sprintf( __( 'Error connecting to %s.', SBY_TEXT_DOMAIN ), $response['url'] ). ' ';
131
+ if ( isset( $response['response'] ) && isset( $response['response']->errors ) ) {
132
+ foreach ( $response['response']->errors as $key => $item ) {
133
+ $message .= ' '.$key . ' - ' . $item[0] . ' |';
134
+ }
135
+ }
136
+
137
+ global $sby_posts_manager;
138
+
139
+ $sby_posts_manager->add_api_request_delay( 300 );
140
+
141
+ $sby_posts_manager->add_error( 'connection', array( 'Error connecting', $message ) );
142
+ }
143
+
144
+ protected function set_url( $connected_account, $endpoint_slug, $params ) {
145
+ $num = ! empty( $params['num'] ) && isset( $connected_account['api_key'] ) ? (int)$params['num'] : 50;
146
+
147
+ if ( $endpoint_slug === 'tokeninfo' ) {
148
+ $url = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=' . $connected_account['access_token'];
149
+ } elseif ( $endpoint_slug === 'channels' ) {
150
+ $channel_param = 'mine=true';
151
+ if ( isset( $params['channel_name'] ) ) {
152
+ $channel_param = 'forUsername=' . $params['channel_name'];
153
+ } elseif ( isset( $params['channel_id'] ) ) {
154
+ $channel_param = 'id=' . $params['channel_id'];
155
+ }
156
+
157
+ $access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
158
+
159
+ $url = 'https://www.googleapis.com/youtube/v3/channels?part=id,snippet,contentDetails&'.$channel_param.'&' . $access_credentials;
160
+ } elseif ( $endpoint_slug === 'playlistItems' ) {
161
+ $access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
162
+ $next_page = '';
163
+ if ( isset( $params['nextPageToken'] ) ) {
164
+ $next_page = '&pageToken=' . $params['nextPageToken'];
165
+ }
166
+
167
+ $url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=id,snippet&maxResults='.$num.'&playlistId='.$params['playlist_id'].'&' . $access_credentials . $next_page;
168
+ } else {
169
+ $channel_param = 'mine=true';
170
+ if ( isset( $params['username'] ) ) {
171
+ $channel_param = 'forUsername=' . $params['username'];
172
+ } elseif ( isset( $params['channel_id'] ) ) {
173
+ $channel_param = 'id=' . $params['channel_id'];
174
+ }
175
+ $access_credentials = isset( $connected_account['api_key'] ) ? 'key=' . $connected_account['api_key'] : 'access_token=' . $connected_account['access_token'];
176
+
177
+ $url = 'https://www.googleapis.com/youtube/v3/channels?part=id,snippet&'.$channel_param.'&' . $access_credentials;
178
+ }
179
+
180
+ $this->set_url_from_args( $url );
181
+ }
182
+
183
+ public static function refresh_token( $client_id, $refresh_token, $client_secret ) {
184
+ $response = wp_remote_post( 'https://www.googleapis.com/oauth2/v4/token/?client_id=' . $client_id . '&client_secret=' . $client_secret . '&refresh_token='. $refresh_token . '&grant_type=refresh_token' );
185
+
186
+ if ( $response['response']['code'] === 200 ) {
187
+ $return = json_decode( $response['body'], true );
188
+ } else {
189
+ $return = array();
190
+ }
191
+
192
+ return $return;
193
+ }
194
+
195
  }
inc/class-sby-cron-update.php CHANGED
@@ -1,205 +1,205 @@
1
- <?php
2
- /**
3
- * Class SBY_Cron_Updater
4
- *
5
- * Finds all regular feed transients saved in the database and updates
6
- * each cached feed in the background using WP Cron. This is set up with the
7
- * "sby_cron_updater" function in the if-functions.php file. The "display_instagram"
8
- * function will trigger a single feed update if no transient is found
9
- * for the feed
10
- *
11
- * @since 1.0/1.0
12
- */
13
-
14
- if ( ! defined( 'ABSPATH' ) ) {
15
- die( '-1' );
16
- }
17
-
18
- class SBY_Cron_Updater
19
- {
20
- /**
21
- * Find and loop through all feed cache transients and update the post and
22
- * header caches
23
- *
24
- * Overwritten in the Pro version
25
- *
26
- * @since 1.0
27
- */
28
- public static function do_feed_updates() {
29
- $feed_caches = SBY_Cron_Updater::get_feed_cache_option_names();
30
- shuffle( $feed_caches );
31
- $database_settings = sby_get_database_settings();
32
-
33
- // this is outputted in system info
34
- $report = array(
35
- 'notes' => array(
36
- 'time_ran' => date( 'Y-m-d H:i:s' ),
37
- 'num_found_transients' => count( $feed_caches )
38
- )
39
- );
40
-
41
- foreach ( $feed_caches as $feed_cache ) {
42
-
43
- $feed_id = str_replace( '_transient_', '', $feed_cache['option_name'] );
44
- $report[ $feed_id ] = array();
45
-
46
- $transient = get_transient( $feed_id );
47
-
48
- if ( $transient ) {
49
- $feed_data = json_decode( $transient, true );
50
-
51
- // shortcode attributes are saved in order to recreate the feed is needed
52
- $atts = isset( $feed_data['atts'] ) ? $feed_data['atts'] : array();
53
- $last_retrieve = isset( $feed_data['last_retrieve'] ) ? (int)$feed_data['last_retrieve'] : 0;
54
- // the last approximate time the feed was requested to be displayed on a page is recorded
55
- // in order to stop updating feeds not in use.
56
- $last_requested = isset( $feed_data['last_requested'] ) ? (int)$feed_data['last_requested'] : false;
57
- $report[ $feed_id ]['last_retrieve'] = date( 'Y-m-d H:i:s', $last_retrieve );
58
- if ( $atts !== false ) {
59
-
60
- if ( ! $last_requested || $last_requested > (time() - 60*60*24*30) ) {
61
- $sby_settings_obj = new SBY_Settings( $atts, $database_settings );
62
-
63
- if ( empty( $database_settings['connected_accounts'] ) && empty( $database_settings['api_key'] ) ) {
64
- $report[ $feed_id ]['did_update'] = 'no - no connected account';
65
- } else {
66
- SBY_Cron_Updater::do_single_feed_cron_update( $sby_settings_obj, $feed_data, $atts );
67
-
68
- $report[ $feed_id ]['did_update'] = 'yes';
69
- }
70
- } else {
71
- $report[ $feed_id ]['did_update'] = 'no - not recently requested';
72
- }
73
-
74
-
75
- } else {
76
- $report[ $feed_id ]['did_update'] = 'no - missing atts';
77
- }
78
-
79
- } else {
80
- $report[ $feed_id ]['did_update'] = 'no - no transient found';
81
- }
82
-
83
- }
84
-
85
- update_option( 'sby_cron_report', $report, false );
86
- }
87
-
88
- /**
89
- * Update a single feed cache based on settings. Local image storing and
90
- * resizing is done in the background here as well unless this is the initial
91
- * time the feed is created and no cached data exists yet.
92
- *
93
- * Overwritten in the Pro version
94
- *
95
- * @param object $sby_settings_obj object created by the sby_settings class
96
- * @param array $feed_data post, header, shortcode settings, and other info
97
- * associated with the feed that is saved in the cache
98
- * @param array $atts shortcode settings
99
- * @param bool $include_resize whether or not to resize images during the update since
100
- * images can also be resized with an ajax call when the feed is viewed on the frontend
101
- *
102
- * @since 1.0
103
- */
104
- public static function do_single_feed_cron_update( $sby_settings_obj, $feed_data, $atts, $include_resize = true ) {
105
- $sby_settings_obj->set_feed_type_and_terms();
106
- $sby_settings_obj->set_transient_name();
107
- $transient_name = $sby_settings_obj->get_transient_name();
108
- $settings = $sby_settings_obj->get_settings();
109
- $feed_type_and_terms = $sby_settings_obj->get_feed_type_and_terms();
110
-
111
- $youtube_feed = new SBY_Feed( $transient_name );
112
-
113
- while ( $youtube_feed->need_posts( $settings['num'] ) && $youtube_feed->can_get_more_posts() ) {
114
- $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $sby_settings_obj->get_connected_accounts_in_feed() );
115
- }
116
-
117
- $to_cache = array(
118
- 'atts' => $atts,
119
- 'last_requested' => $feed_data['last_requested'],
120
- 'last_retrieve' => time()
121
- );
122
-
123
- $youtube_feed->set_cron_cache( $to_cache, $sby_settings_obj->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
124
-
125
- if ( $youtube_feed->need_header( $settings, $feed_type_and_terms ) ) {
126
- $youtube_feed->set_remote_header_data( $settings, $feed_type_and_terms, $sby_settings_obj->get_connected_accounts_in_feed() );
127
-
128
- $youtube_feed->cache_header_data( $sby_settings_obj->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
129
- }
130
-
131
- $post_data = $youtube_feed->get_post_data();
132
- $post_data = array_slice( $post_data, 0, $settings['num'] );
133
-
134
- sby_process_post_set_caching( $post_data, $transient_name );
135
-
136
- }
137
-
138
- /**
139
- * Retrieve option name column values for all feed cache transients
140
- *
141
- * @return array
142
- *
143
- * @since 1.0
144
- */
145
- public static function get_feed_cache_option_names() {
146
- global $wpdb;
147
- $feed_caches = array();
148
-
149
- $results = $wpdb->get_results( "
150
- SELECT option_name
151
- FROM $wpdb->options
152
- WHERE `option_name` LIKE ('%\_transient\_sby\_%')
153
- AND `option_name` NOT LIKE ('%\_transient\_sby\_header%');", ARRAY_A );
154
-
155
- if ( isset( $results[0] ) ) {
156
- $feed_caches = $results;
157
- }
158
-
159
- return $feed_caches;
160
- }
161
-
162
- /**
163
- * Start cron jobs based on user's settings for cron cache update frequency.
164
- * This is triggered when settings are saved on the "Configure" tab.
165
- *
166
- * @param string $sby_cache_cron_interval arbitrary name from one of the
167
- * settings on the "Configure" tab
168
- * @param string $sby_cache_cron_time hour of the day (1 = 1:00)
169
- * @param string $sby_cache_cron_am_pm am or pm (time of day)
170
- *
171
- * @since 1.0
172
- */
173
- public static function start_cron_job( $sby_cache_cron_interval, $sby_cache_cron_time, $sby_cache_cron_am_pm ) {
174
- wp_clear_scheduled_hook( 'sby_feed_update' );
175
-
176
- if ( $sby_cache_cron_interval === '12hours' || $sby_cache_cron_interval === '24hours' ) {
177
- $relative_time_now = time() + sby_get_utc_offset();
178
- $base_day = strtotime( date( 'Y-m-d', $relative_time_now ) );
179
- $add_time = $sby_cache_cron_am_pm === 'pm' ? (int)$sby_cache_cron_time + 12 : (int)$sby_cache_cron_time;
180
- $utc_start_time = $base_day + (($add_time * 60 * 60) - sby_get_utc_offset());
181
-
182
- if ( $utc_start_time < time() ) {
183
- if ( $sby_cache_cron_interval === '12hours' ) {
184
- $utc_start_time += 60*60*12;
185
- } else {
186
- $utc_start_time += 60*60*24;
187
- }
188
- }
189
-
190
- if ( $sby_cache_cron_interval === '12hours' ) {
191
- wp_schedule_event( $utc_start_time, 'twicedaily', 'sby_feed_update' );
192
- } else {
193
- wp_schedule_event( $utc_start_time, 'daily', 'sby_feed_update' );
194
- }
195
-
196
- } else {
197
- if ( $sby_cache_cron_interval === '30mins' ) {
198
- wp_schedule_event( time(), 'sby30mins', 'sby_feed_update' );
199
- } else {
200
- wp_schedule_event( time(), 'hourly', 'sby_feed_update' );
201
- }
202
- }
203
-
204
- }
205
  }
1
+ <?php
2
+ /**
3
+ * Class SBY_Cron_Updater
4
+ *
5
+ * Finds all regular feed transients saved in the database and updates
6
+ * each cached feed in the background using WP Cron. This is set up with the
7
+ * "sby_cron_updater" function in the if-functions.php file. The "display_instagram"
8
+ * function will trigger a single feed update if no transient is found
9
+ * for the feed
10
+ *
11
+ * @since 1.0/1.0
12
+ */
13
+
14
+ if ( ! defined( 'ABSPATH' ) ) {
15
+ die( '-1' );
16
+ }
17
+
18
+ class SBY_Cron_Updater
19
+ {
20
+ /**
21
+ * Find and loop through all feed cache transients and update the post and
22
+ * header caches
23
+ *
24
+ * Overwritten in the Pro version
25
+ *
26
+ * @since 1.0
27
+ */
28
+ public static function do_feed_updates() {
29
+ $feed_caches = SBY_Cron_Updater::get_feed_cache_option_names();
30
+ shuffle( $feed_caches );
31
+ $database_settings = sby_get_database_settings();
32
+
33
+ // this is outputted in system info
34
+ $report = array(
35
+ 'notes' => array(
36
+ 'time_ran' => date( 'Y-m-d H:i:s' ),
37
+ 'num_found_transients' => count( $feed_caches )
38
+ )
39
+ );
40
+
41
+ foreach ( $feed_caches as $feed_cache ) {
42
+
43
+ $feed_id = str_replace( '_transient_', '', $feed_cache['option_name'] );
44
+ $report[ $feed_id ] = array();
45
+
46
+ $transient = get_transient( $feed_id );
47
+
48
+ if ( $transient ) {
49
+ $feed_data = json_decode( $transient, true );
50
+
51
+ // shortcode attributes are saved in order to recreate the feed is needed
52
+ $atts = isset( $feed_data['atts'] ) ? $feed_data['atts'] : array();
53
+ $last_retrieve = isset( $feed_data['last_retrieve'] ) ? (int)$feed_data['last_retrieve'] : 0;
54
+ // the last approximate time the feed was requested to be displayed on a page is recorded
55
+ // in order to stop updating feeds not in use.
56
+ $last_requested = isset( $feed_data['last_requested'] ) ? (int)$feed_data['last_requested'] : false;
57
+ $report[ $feed_id ]['last_retrieve'] = date( 'Y-m-d H:i:s', $last_retrieve );
58
+ if ( $atts !== false ) {
59
+
60
+ if ( ! $last_requested || $last_requested > (time() - 60*60*24*30) ) {
61
+ $sby_settings_obj = new SBY_Settings( $atts, $database_settings );
62
+
63
+ if ( empty( $database_settings['connected_accounts'] ) && empty( $database_settings['api_key'] ) ) {
64
+ $report[ $feed_id ]['did_update'] = 'no - no connected account';
65
+ } else {
66
+ SBY_Cron_Updater::do_single_feed_cron_update( $sby_settings_obj, $feed_data, $atts );
67
+
68
+ $report[ $feed_id ]['did_update'] = 'yes';
69
+ }
70
+ } else {
71
+ $report[ $feed_id ]['did_update'] = 'no - not recently requested';
72
+ }
73
+
74
+
75
+ } else {
76
+ $report[ $feed_id ]['did_update'] = 'no - missing atts';
77
+ }
78
+
79
+ } else {
80
+ $report[ $feed_id ]['did_update'] = 'no - no transient found';
81
+ }
82
+
83
+ }
84
+
85
+ update_option( 'sby_cron_report', $report, false );
86
+ }
87
+
88
+ /**
89
+ * Update a single feed cache based on settings. Local image storing and
90
+ * resizing is done in the background here as well unless this is the initial
91
+ * time the feed is created and no cached data exists yet.
92
+ *
93
+ * Overwritten in the Pro version
94
+ *
95
+ * @param object $sby_settings_obj object created by the sby_settings class
96
+ * @param array $feed_data post, header, shortcode settings, and other info
97
+ * associated with the feed that is saved in the cache
98
+ * @param array $atts shortcode settings
99
+ * @param bool $include_resize whether or not to resize images during the update since
100
+ * images can also be resized with an ajax call when the feed is viewed on the frontend
101
+ *
102
+ * @since 1.0
103
+ */
104
+ public static function do_single_feed_cron_update( $sby_settings_obj, $feed_data, $atts, $include_resize = true ) {
105
+ $sby_settings_obj->set_feed_type_and_terms();
106
+ $sby_settings_obj->set_transient_name();
107
+ $transient_name = $sby_settings_obj->get_transient_name();
108
+ $settings = $sby_settings_obj->get_settings();
109
+ $feed_type_and_terms = $sby_settings_obj->get_feed_type_and_terms();
110
+
111
+ $youtube_feed = new SBY_Feed( $transient_name );
112
+
113
+ while ( $youtube_feed->need_posts( $settings['num'] ) && $youtube_feed->can_get_more_posts() ) {
114
+ $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $sby_settings_obj->get_connected_accounts_in_feed() );
115
+ }
116
+
117
+ $to_cache = array(
118
+ 'atts' => $atts,
119
+ 'last_requested' => $feed_data['last_requested'],
120
+ 'last_retrieve' => time()
121
+ );
122
+
123
+ $youtube_feed->set_cron_cache( $to_cache, $sby_settings_obj->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
124
+
125
+ if ( $youtube_feed->need_header( $settings, $feed_type_and_terms ) ) {
126
+ $youtube_feed->set_remote_header_data( $settings, $feed_type_and_terms, $sby_settings_obj->get_connected_accounts_in_feed() );
127
+
128
+ $youtube_feed->cache_header_data( $sby_settings_obj->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
129
+ }
130
+
131
+ $post_data = $youtube_feed->get_post_data();
132
+ $post_data = array_slice( $post_data, 0, $settings['num'] );
133
+
134
+ sby_process_post_set_caching( $post_data, $transient_name );
135
+
136
+ }
137
+
138
+ /**
139
+ * Retrieve option name column values for all feed cache transients
140
+ *
141
+ * @return array
142
+ *
143
+ * @since 1.0
144
+ */
145
+ public static function get_feed_cache_option_names() {
146
+ global $wpdb;
147
+ $feed_caches = array();
148
+
149
+ $results = $wpdb->get_results( "
150
+ SELECT option_name
151
+ FROM $wpdb->options
152
+ WHERE `option_name` LIKE ('%\_transient\_sby\_%')
153
+ AND `option_name` NOT LIKE ('%\_transient\_sby\_header%');", ARRAY_A );
154
+
155
+ if ( isset( $results[0] ) ) {
156
+ $feed_caches = $results;
157
+ }
158
+
159
+ return $feed_caches;
160
+ }
161
+
162
+ /**
163
+ * Start cron jobs based on user's settings for cron cache update frequency.
164
+ * This is triggered when settings are saved on the "Configure" tab.
165
+ *
166
+ * @param string $sby_cache_cron_interval arbitrary name from one of the
167
+ * settings on the "Configure" tab
168
+ * @param string $sby_cache_cron_time hour of the day (1 = 1:00)
169
+ * @param string $sby_cache_cron_am_pm am or pm (time of day)
170
+ *
171
+ * @since 1.0
172
+ */
173
+ public static function start_cron_job( $sby_cache_cron_interval, $sby_cache_cron_time, $sby_cache_cron_am_pm ) {
174
+ wp_clear_scheduled_hook( 'sby_feed_update' );
175
+
176
+ if ( $sby_cache_cron_interval === '12hours' || $sby_cache_cron_interval === '24hours' ) {
177
+ $relative_time_now = time() + sby_get_utc_offset();
178
+ $base_day = strtotime( date( 'Y-m-d', $relative_time_now ) );
179
+ $add_time = $sby_cache_cron_am_pm === 'pm' ? (int)$sby_cache_cron_time + 12 : (int)$sby_cache_cron_time;
180
+ $utc_start_time = $base_day + (($add_time * 60 * 60) - sby_get_utc_offset());
181
+
182
+ if ( $utc_start_time < time() ) {
183
+ if ( $sby_cache_cron_interval === '12hours' ) {
184
+ $utc_start_time += 60*60*12;
185
+ } else {
186
+ $utc_start_time += 60*60*24;
187
+ }
188
+ }
189
+
190
+ if ( $sby_cache_cron_interval === '12hours' ) {
191
+ wp_schedule_event( $utc_start_time, 'twicedaily', 'sby_feed_update' );
192
+ } else {
193
+ wp_schedule_event( $utc_start_time, 'daily', 'sby_feed_update' );
194
+ }
195
+
196
+ } else {
197
+ if ( $sby_cache_cron_interval === '30mins' ) {
198
+ wp_schedule_event( time(), 'sby30mins', 'sby_feed_update' );
199
+ } else {
200
+ wp_schedule_event( time(), 'hourly', 'sby_feed_update' );
201
+ }
202
+ }
203
+
204
+ }
205
  }
inc/class-sby-display-elements.php CHANGED
@@ -1,369 +1,376 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- die( '-1' );
5
- }
6
-
7
- class SBY_Display_Elements
8
- {
9
- /**
10
- * Images are hidden initially with the new/transition classes
11
- * except if the js image loading is disabled using the plugin
12
- * settings
13
- *
14
- * @param $settings
15
- *
16
- * @return string
17
- *
18
- * @since 1.0
19
- */
20
- public static function get_item_classes( $settings ) {
21
- $classes = array( 'sby_new' );
22
- if ( !$settings['disable_js_image_loading'] ) {
23
- $classes[] = 'sby_transition';
24
- } else {
25
- $classes[] = 'sby_no_js';
26
-
27
- $classes[] = 'sby_no_resraise';
28
- $classes[] = 'sby_js_load_disabled';
29
- }
30
-
31
- if ( $settings['layout'] !== 'list' ) {
32
- $classes[] = 'sby_no_margin';
33
- }
34
-
35
- return ' ' . implode( ' ', $classes );
36
- }
37
-
38
- /**
39
- * Overwritten in the Pro version.
40
- *
41
- * @param string $type key of the kind of icon needed
42
- * @param string $icon_type svg or font
43
- *
44
- * @return string the complete html for the icon
45
- *
46
- * @since 1.0
47
- */
48
- public static function get_icon( $type, $icon_type ) {
49
- return self::get_basic_icons( $type, $icon_type );
50
- }
51
-
52
- public static function get_cols( $settings ) {
53
- if ( isset( $settings[ $settings['layout'] . 'cols'] ) ) {
54
- return $settings[ $settings['layout'] . 'cols'];
55
- }
56
- return 0;
57
- }
58
-
59
- public static function get_cols_mobile( $settings ) {
60
- if ( isset( $settings[ $settings['layout'] . 'colsmobile'] ) ) {
61
- return $settings[ $settings['layout'] . 'colsmobile'];
62
- }
63
- return 0;
64
- }
65
-
66
- public static function get_style_att( $context, $settings, $pos = false ) {
67
- $style_settings = array();
68
- $item_spacing_setting = $settings['itemspacing'];
69
- if ( ! preg_match("/(px)|(%)/", $item_spacing_setting ) ) {
70
- $item_spacing_setting = $item_spacing_setting . $settings['itemspacingunit'];
71
- }
72
- if ( $context === 'player' ) {
73
- $style_settings['margin-bottom'] = $item_spacing_setting;
74
- } elseif ( $context === 'item' ) {
75
- if ( $settings['layout'] === 'list' ) {
76
- $style_settings['margin-bottom'] = $item_spacing_setting;
77
- }
78
- } elseif ( $context === 'items_wrap' || $context === 'player_outer_wrap' ) {
79
- if ( $settings['layout'] !== 'list' ) {
80
- $style_settings['padding'] = $item_spacing_setting;
81
- }
82
- if ( isset( $settings['descriptiontextsize'] ) && $settings['descriptiontextsize'] !== '13px' ) {
83
- $style_settings['font-size'] = $settings['descriptiontextsize'];
84
- }
85
- } elseif ( $context === 'header' ) {
86
- if ( $settings['itemspacing'] > 0 ) {
87
- $style_settings['padding'] = $item_spacing_setting;
88
- }
89
- if ( $settings['itemspacing'] < 10 ) {
90
- $style_settings['margin-bottom'] = '10px';
91
- }
92
- $style_settings['padding-bottom'] = '0';
93
- }
94
-
95
- if ( $context === 'player_outer_wrap' ) {
96
- $style_settings['padding-bottom'] = 0;
97
- }
98
-
99
- $style_att = '';
100
- if ( ! empty( $style_settings ) ) {
101
- $style_att = ' style="';
102
- foreach ( $style_settings as $prop => $val ) {
103
- $style_att .= $prop . ': '. $val . ';';
104
- }
105
- $style_att .= '"';
106
- }
107
-
108
- return $style_att;
109
- }
110
-
111
- /**
112
- * Returns the best media url for an image based on settings.
113
- * By default a white placeholder image is loaded and replaced
114
- * with the most optimal image size based on the actual dimensions
115
- * of the image element in the feed.
116
- *
117
- * @param array $post data for an individual post
118
- * @param array $settings
119
- * @param array $resized_images (optional) not yet used but
120
- * can pass in existing resized images to use in the source
121
- *
122
- * @return string
123
- *
124
- * @since 1.0
125
- */
126
- public static function get_optimum_media_url( $post, $settings, $resized_images = array() ) {
127
- $media_url = '';
128
- $optimum_res = $settings['imageres'];
129
- $account_type = isset( $post['images'] ) ? 'personal' : 'business';
130
-
131
- // only use the placeholder if it will be replaced using JS
132
- if ( !$settings['disable_js_image_loading'] ) {
133
- return trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder.png';
134
- } else {
135
- $optimum_res = 'full';
136
- $settings['imageres'] = 'full';
137
- }
138
-
139
- $media_url = SBY_Parse::get_media_url( $post, 'lightbox' );
140
-
141
- return $media_url;
142
- }
143
-
144
- /**
145
- * Creates a style attribute that contains all of the styles for
146
- * the main feed div.
147
- *
148
- * @param $settings
149
- *
150
- * @return string
151
- */
152
- public static function get_feed_style( $settings ) {
153
-
154
- $styles = '';
155
- $bg_color = str_replace( '#', '', $settings['background'] );
156
-
157
- if ( ! empty( $settings['imagepadding'] )
158
- || ! empty( $bg_color )
159
- || ! empty( $settings['width'] )
160
- || ! empty( $settings['height'] ) ) {
161
- $styles = ' style="';
162
- if ( ! empty( $settings['imagepadding'] ) ) {
163
- $styles .= 'padding-bottom: ' . ((int)$settings['imagepadding'] * 2) . esc_attr( $settings['imagepaddingunit'] ) . ';';
164
- }
165
- if ( ! empty( $bg_color ) ) {
166
- $styles .= 'background-color: rgb(' . esc_attr( sby_hextorgb( $bg_color ) ). ');';
167
- }
168
- if ( ! empty( $settings['width'] ) ) {
169
- $styles .= 'width: ' . (int)$settings['width'] . esc_attr( $settings['widthunit'] ) . ';';
170
- }
171
- if ( ! empty( $settings['height'] ) ) {
172
- $styles .= 'height: ' . (int)$settings['height'] . esc_attr( $settings['heightunit'] ) . ';';
173
- }
174
- $styles .= '"';
175
- }
176
- return $styles;
177
- }
178
-
179
- /**
180
- * Creates a style attribute for the sby_images div
181
- *
182
- * @param $settings
183
- *
184
- * @return string
185
- *
186
- * @since 1.0
187
- */
188
- public static function get_items_wrap_style( $settings ) {
189
- if ( ! empty ( $settings['imagepadding'] ) ) {
190
- return 'style="padding: '.(int)$settings['imagepadding'] . esc_attr( $settings['imagepaddingunit'] ) . ';"';
191
- }
192
- return '';
193
- }
194
-
195
- /**
196
- * Creates a style attribute for the header. Can be used in
197
- * several places based on the header style
198
- *
199
- * @param $settings
200
- *
201
- * @return string
202
- *
203
- * @since 1.0
204
- */
205
- public static function get_header_text_color_styles( $settings ) {
206
- $header_color = str_replace( '#', '', $settings['headercolor'] );
207
-
208
- if ( ! empty( $header_color ) ) {
209
- return 'style="color: rgb(' . esc_attr( sby_hextorgb( $header_color ) ). ');"';
210
- }
211
- return '';
212
- }
213
-
214
- /**
215
- * Header icon and text size is styled using the class added here.
216
- *
217
- * @param $settings
218
- *
219
- * @return string
220
- *
221
- * @since 1.0
222
- */
223
- public static function get_header_size_class( $settings ) {
224
- $header_size_class = in_array( strtolower( $settings['headersize'] ), array( 'medium', 'large' ) ) ? ' sby_'.strtolower( $settings['headersize'] ) : '';
225
- return $header_size_class;
226
- }
227
-
228
- /**
229
- * Creates a style attribute for the subscribe button. Can be in
230
- * the feed footer or in a boxed header.
231
- *
232
- * @param $settings
233
- *
234
- * @return string
235
- *
236
- * @since 1.0
237
- */
238
- public static function get_subscribe_styles( $settings ) {
239
- $styles = '';
240
- $subscribe_color = str_replace( '#', '', $settings['subscribecolor'] );
241
- $subscribe_text_color = str_replace( '#', '', $settings['subscribetextcolor'] );
242
-
243
- if ( ! empty( $subscribe_color ) || ! empty( $subscribe_text_color ) ) {
244
- $styles = 'style="';
245
- if ( ! empty( $subscribe_color ) ) {
246
- $styles .= 'background: rgb(' . esc_attr( sby_hextorgb( $subscribe_color ) ) . ');';
247
- }
248
- if ( ! empty( $subscribe_text_color ) ) {
249
- $styles .= 'color: rgb(' . esc_attr( sby_hextorgb( $subscribe_text_color ) ). ');';
250
- }
251
- $styles .= '"';
252
- }
253
- return $styles;
254
- }
255
-
256
- /**
257
- * Creates a style attribute for styling the load more button.
258
- *
259
- * @param $settings
260
- *
261
- * @return string
262
- *
263
- * @since 1.0
264
- */
265
- public static function get_load_button_styles( $settings ) {
266
- $styles = '';
267
- $button_color = str_replace( '#', '', $settings['buttoncolor'] );
268
- $button_text_color = str_replace( '#', '', $settings['buttontextcolor'] );
269
-
270
- if ( ! empty( $button_color ) || ! empty( $button_text_color ) ) {
271
- $styles = 'style="';
272
- if ( ! empty( $button_color ) ) {
273
- $styles .= 'background: rgb(' . esc_attr( sby_hextorgb( $button_color ) ) . ');';
274
- }
275
- if ( ! empty( $button_text_color ) ) {
276
- $styles .= 'color: rgb(' . esc_attr( sby_hextorgb( $button_text_color ) ). ');';
277
- }
278
- $styles .= '"';
279
- }
280
- return $styles;
281
- }
282
-
283
- /**
284
- * A not very elegant but useful method to abstract out how the settings
285
- * work for displaying certain elements in the feed.
286
- *
287
- * @param string $element specific key, view below for supported ones
288
- * @param $settings
289
- *
290
- * @return bool
291
- *
292
- * @since 5.0
293
- */
294
- public static function should_show_element( $element, $context, $settings ) {
295
- //user, views, date
296
- if ( $context === 'item-hover' ) {
297
- $include_array = is_array( $settings['hoverinclude'] ) ? $settings['hoverinclude'] : explode( ',', str_replace( ' ', '', $settings['hoverinclude'] ) );
298
- } else {
299
- $include_array = is_array( $settings['include'] ) ? $settings['include'] : explode( ',', str_replace( ' ', '', $settings['include'] ) );
300
- }
301
-
302
- if ( in_array( $element, $include_array, true ) ) {
303
- return true;
304
- }
305
-
306
- return false;
307
- }
308
-
309
- /**
310
- * Returns the html for an icon based on the kind requested
311
- *
312
- * @param string $type kind of icon needed (ex "video" is a play button)
313
- * @param string $icon_type svg or font
314
- *
315
- * @return string
316
- *
317
- * @since 1.0
318
- */
319
- protected static function get_basic_icons( $type, $icon_type ) {
320
- if ( $type === 'carousel' ) {
321
- if ( $icon_type === 'svg' ) {
322
- return '<svg class="svg-inline--fa fa-clone fa-w-16 sby_lightbox_carousel_icon" aria-hidden="true" data-fa-proƒcessed="" data-prefix="far" data-icon="clone" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
323
- <path fill="currentColor" d="M464 0H144c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h320c26.51 0 48-21.49 48-48v-48h48c26.51 0 48-21.49 48-48V48c0-26.51-21.49-48-48-48zM362 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h42v224c0 26.51 21.49 48 48 48h224v42a6 6 0 0 1-6 6zm96-96H150a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h308a6 6 0 0 1 6 6v308a6 6 0 0 1-6 6z"></path>
324
- </svg>';
325
- } else {
326
- return '<i class="fa fa-clone sby_carousel_icon" aria-hidden="true"></i>';
327
- }
328
-
329
- } elseif ( $type === 'video' ) {
330
- if ( $icon_type === 'svg' ) {
331
- return '<svg style="color: rgba(255,255,255,1)" class="svg-inline--fa fa-play fa-w-14 sby_playbtn" aria-hidden="true" data-fa-processed="" data-prefix="fa" data-icon="play" role="presentation" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path></svg>';
332
- } else {
333
- return '<i class="fa fa-play sby_playbtn" aria-hidden="true"></i>';
334
- }
335
- } elseif ( $type === 'youtube' ) {
336
- if ( $icon_type === 'svg' ) {
337
- return '<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="youtube" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="svg-inline--fa fa-youtube fa-w-18"><path fill="currentColor" d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z" class=""></path></svg>';
338
- } else {
339
- return '<i aria-hidden="true" role="img" class="sby_new_logo fab fa-youtube"></i>';
340
- }
341
- } elseif ( $type === 'newlogo' ) {
342
- if ( $icon_type === 'svg' ) {
343
- return '<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="youtube" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="sby_new_logo svg-inline--fa fa-youtube fa-w-18"><path fill="currentColor" d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z" class=""></path></svg>';
344
- } else {
345
- return '<i aria-hidden="true" role="img" class="sby_new_logo fab fa-youtube"></i>';
346
- }
347
- } elseif ( $type === 'play') {
348
- if ( $icon_type === 'svg' ) {
349
- return '<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="youtube" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="svg-inline--fa fa-youtube fa-w-18"><path fill="currentColor" d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z" class=""></path></svg>';
350
- } else {
351
- return '<i aria-hidden="true" role="img" class="fa fas fa-play"></i>';
352
- }
353
- } else {
354
- return '';
355
- }
356
- }
357
-
358
- public static function escaped_data_att_string( $atts ) {
359
- if ( empty( $atts ) ) {
360
- return '';
361
- }
362
- $string = '';
363
- foreach ( $atts as $key => $value ) {
364
- $string .= ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
365
- }
366
-
367
- return $string;
368
- }
 
 
 
 
 
 
 
369
  }
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
+ }
6
+
7
+ class SBY_Display_Elements
8
+ {
9
+ /**
10
+ * Images are hidden initially with the new/transition classes
11
+ * except if the js image loading is disabled using the plugin
12
+ * settings
13
+ *
14
+ * @param $settings
15
+ *
16
+ * @return string
17
+ *
18
+ * @since 1.0
19
+ */
20
+ public static function get_item_classes( $settings ) {
21
+ $classes = array( 'sby_new' );
22
+ if ( !$settings['disable_js_image_loading'] ) {
23
+ $classes[] = 'sby_transition';
24
+ } else {
25
+ $classes[] = 'sby_no_js';
26
+
27
+ $classes[] = 'sby_no_resraise';
28
+ $classes[] = 'sby_js_load_disabled';
29
+ }
30
+
31
+ if ( $settings['layout'] !== 'list' ) {
32
+ $classes[] = 'sby_no_margin';
33
+ }
34
+
35
+ return ' ' . implode( ' ', $classes );
36
+ }
37
+
38
+ /**
39
+ * Overwritten in the Pro version.
40
+ *
41
+ * @param string $type key of the kind of icon needed
42
+ * @param string $icon_type svg or font
43
+ *
44
+ * @return string the complete html for the icon
45
+ *
46
+ * @since 1.0
47
+ */
48
+ public static function get_icon( $type, $icon_type ) {
49
+ return self::get_basic_icons( $type, $icon_type );
50
+ }
51
+
52
+ public static function get_cols( $settings ) {
53
+ if ( isset( $settings[ $settings['layout'] . 'cols'] ) ) {
54
+ return $settings[ $settings['layout'] . 'cols'];
55
+ }
56
+ return 0;
57
+ }
58
+
59
+ public static function get_cols_mobile( $settings ) {
60
+ if ( isset( $settings[ $settings['layout'] . 'colsmobile'] ) ) {
61
+ return $settings[ $settings['layout'] . 'colsmobile'];
62
+ }
63
+ return 0;
64
+ }
65
+
66
+ public static function get_style_att( $context, $settings, $pos = false ) {
67
+ $style_settings = array();
68
+ $item_spacing_setting = $settings['itemspacing'];
69
+ if ( ! preg_match("/(px)|(%)/", $item_spacing_setting ) ) {
70
+ $item_spacing_setting = $item_spacing_setting . $settings['itemspacingunit'];
71
+ }
72
+ if ( $context === 'player' ) {
73
+ $style_settings['margin-bottom'] = $item_spacing_setting;
74
+ } elseif ( $context === 'item' ) {
75
+ if ( $settings['layout'] === 'list' ) {
76
+ $style_settings['margin-bottom'] = $item_spacing_setting;
77
+ }
78
+ } elseif ( $context === 'items_wrap' || $context === 'player_outer_wrap' ) {
79
+ if ( $settings['layout'] !== 'list' ) {
80
+ $style_settings['padding'] = $item_spacing_setting;
81
+ }
82
+ if ( isset( $settings['descriptiontextsize'] ) && $settings['descriptiontextsize'] !== '13px' ) {
83
+ $style_settings['font-size'] = $settings['descriptiontextsize'];
84
+ }
85
+ } elseif ( $context === 'header' ) {
86
+ if ( $settings['itemspacing'] > 0 ) {
87
+ $style_settings['padding'] = $item_spacing_setting;
88
+ }
89
+ if ( $settings['itemspacing'] < 10 ) {
90
+ $style_settings['margin-bottom'] = '10px';
91
+ }
92
+ $style_settings['padding-bottom'] = '0';
93
+ }
94
+
95
+ if ( $context === 'player_outer_wrap' ) {
96
+ $style_settings['padding-bottom'] = 0;
97
+ }
98
+
99
+ $style_att = '';
100
+ if ( ! empty( $style_settings ) ) {
101
+ $style_att = ' style="';
102
+ foreach ( $style_settings as $prop => $val ) {
103
+ $style_att .= $prop . ': '. $val . ';';
104
+ }
105
+ $style_att .= '"';
106
+ }
107
+
108
+ return $style_att;
109
+ }
110
+
111
+ public static function get_display_avatar( $header_data, $settings ) {
112
+ if ( SBY_GDPR_Integrations::doing_gdpr( $settings ) && $settings['disablecdn'] ) {
113
+ return trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder.png';
114
+ }
115
+ return SBY_Parse::get_avatar( $header_data, $settings );
116
+ }
117
+
118
+ /**
119
+ * Returns the best media url for an image based on settings.
120
+ * By default a white placeholder image is loaded and replaced
121
+ * with the most optimal image size based on the actual dimensions
122
+ * of the image element in the feed.
123
+ *
124
+ * @param array $post data for an individual post
125
+ * @param array $settings
126
+ * @param array $resized_images (optional) not yet used but
127
+ * can pass in existing resized images to use in the source
128
+ *
129
+ * @return string
130
+ *
131
+ * @since 1.0
132
+ */
133
+ public static function get_optimum_media_url( $post, $settings, $resized_images = array() ) {
134
+ $media_url = '';
135
+ $optimum_res = $settings['imageres'];
136
+ $account_type = isset( $post['images'] ) ? 'personal' : 'business';
137
+
138
+ // only use the placeholder if it will be replaced using JS
139
+ if ( !$settings['disable_js_image_loading'] || $settings['disablecdn'] ) {
140
+ return trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder.png';
141
+ } else {
142
+ $optimum_res = 'full';
143
+ $settings['imageres'] = 'full';
144
+ }
145
+
146
+ $media_url = SBY_Parse::get_media_url( $post, 'lightbox' );
147
+
148
+ return $media_url;
149
+ }
150
+
151
+ /**
152
+ * Creates a style attribute that contains all of the styles for
153
+ * the main feed div.
154
+ *
155
+ * @param $settings
156
+ *
157
+ * @return string
158
+ */
159
+ public static function get_feed_style( $settings ) {
160
+
161
+ $styles = '';
162
+ $bg_color = str_replace( '#', '', $settings['background'] );
163
+
164
+ if ( ! empty( $settings['imagepadding'] )
165
+ || ! empty( $bg_color )
166
+ || ! empty( $settings['width'] )
167
+ || ! empty( $settings['height'] ) ) {
168
+ $styles = ' style="';
169
+ if ( ! empty( $settings['imagepadding'] ) ) {
170
+ $styles .= 'padding-bottom: ' . ((int)$settings['imagepadding'] * 2) . esc_attr( $settings['imagepaddingunit'] ) . ';';
171
+ }
172
+ if ( ! empty( $bg_color ) ) {
173
+ $styles .= 'background-color: rgb(' . esc_attr( sby_hextorgb( $bg_color ) ). ');';
174
+ }
175
+ if ( ! empty( $settings['width'] ) ) {
176
+ $styles .= 'width: ' . (int)$settings['width'] . esc_attr( $settings['widthunit'] ) . ';';
177
+ }
178
+ if ( ! empty( $settings['height'] ) ) {
179
+ $styles .= 'height: ' . (int)$settings['height'] . esc_attr( $settings['heightunit'] ) . ';';
180
+ }
181
+ $styles .= '"';
182
+ }
183
+ return $styles;
184
+ }
185
+
186
+ /**
187
+ * Creates a style attribute for the sby_images div
188
+ *
189
+ * @param $settings
190
+ *
191
+ * @return string
192
+ *
193
+ * @since 1.0
194
+ */
195
+ public static function get_items_wrap_style( $settings ) {
196
+ if ( ! empty ( $settings['imagepadding'] ) ) {
197
+ return 'style="padding: '.(int)$settings['imagepadding'] . esc_attr( $settings['imagepaddingunit'] ) . ';"';
198
+ }
199
+ return '';
200
+ }
201
+
202
+ /**
203
+ * Creates a style attribute for the header. Can be used in
204
+ * several places based on the header style
205
+ *
206
+ * @param $settings
207
+ *
208
+ * @return string
209
+ *
210
+ * @since 1.0
211
+ */
212
+ public static function get_header_text_color_styles( $settings ) {
213
+ $header_color = str_replace( '#', '', $settings['headercolor'] );
214
+
215
+ if ( ! empty( $header_color ) ) {
216
+ return 'style="color: rgb(' . esc_attr( sby_hextorgb( $header_color ) ). ');"';
217
+ }
218
+ return '';
219
+ }
220
+
221
+ /**
222
+ * Header icon and text size is styled using the class added here.
223
+ *
224
+ * @param $settings
225
+ *
226
+ * @return string
227
+ *
228
+ * @since 1.0
229
+ */
230
+ public static function get_header_size_class( $settings ) {
231
+ $header_size_class = in_array( strtolower( $settings['headersize'] ), array( 'medium', 'large' ) ) ? ' sby_'.strtolower( $settings['headersize'] ) : '';
232
+ return $header_size_class;
233
+ }
234
+
235
+ /**
236
+ * Creates a style attribute for the subscribe button. Can be in
237
+ * the feed footer or in a boxed header.
238
+ *
239
+ * @param $settings
240
+ *
241
+ * @return string
242
+ *
243
+ * @since 1.0
244
+ */
245
+ public static function get_subscribe_styles( $settings ) {
246
+ $styles = '';
247
+ $subscribe_color = str_replace( '#', '', $settings['subscribecolor'] );
248
+ $subscribe_text_color = str_replace( '#', '', $settings['subscribetextcolor'] );
249
+
250
+ if ( ! empty( $subscribe_color ) || ! empty( $subscribe_text_color ) ) {
251
+ $styles = 'style="';
252
+ if ( ! empty( $subscribe_color ) ) {
253
+ $styles .= 'background: rgb(' . esc_attr( sby_hextorgb( $subscribe_color ) ) . ');';
254
+ }
255
+ if ( ! empty( $subscribe_text_color ) ) {
256
+ $styles .= 'color: rgb(' . esc_attr( sby_hextorgb( $subscribe_text_color ) ). ');';
257
+ }
258
+ $styles .= '"';
259
+ }
260
+ return $styles;
261
+ }
262
+
263
+ /**
264
+ * Creates a style attribute for styling the load more button.
265
+ *
266
+ * @param $settings
267
+ *
268
+ * @return string
269
+ *
270
+ * @since 1.0
271
+ */
272
+ public static function get_load_button_styles( $settings ) {
273
+ $styles = '';
274
+ $button_color = str_replace( '#', '', $settings['buttoncolor'] );
275
+ $button_text_color = str_replace( '#', '', $settings['buttontextcolor'] );
276
+
277
+ if ( ! empty( $button_color ) || ! empty( $button_text_color ) ) {
278
+ $styles = 'style="';
279
+ if ( ! empty( $button_color ) ) {
280
+ $styles .= 'background: rgb(' . esc_attr( sby_hextorgb( $button_color ) ) . ');';
281
+ }
282
+ if ( ! empty( $button_text_color ) ) {
283
+ $styles .= 'color: rgb(' . esc_attr( sby_hextorgb( $button_text_color ) ). ');';
284
+ }
285
+ $styles .= '"';
286
+ }
287
+ return $styles;
288
+ }
289
+
290
+ /**
291
+ * A not very elegant but useful method to abstract out how the settings
292
+ * work for displaying certain elements in the feed.
293
+ *
294
+ * @param string $element specific key, view below for supported ones
295
+ * @param $settings
296
+ *
297
+ * @return bool
298
+ *
299
+ * @since 5.0
300
+ */
301
+ public static function should_show_element( $element, $context, $settings ) {
302
+ //user, views, date
303
+ if ( $context === 'item-hover' ) {
304
+ $include_array = is_array( $settings['hoverinclude'] ) ? $settings['hoverinclude'] : explode( ',', str_replace( ' ', '', $settings['hoverinclude'] ) );
305
+ } else {
306
+ $include_array = is_array( $settings['include'] ) ? $settings['include'] : explode( ',', str_replace( ' ', '', $settings['include'] ) );
307
+ }
308
+
309
+ if ( in_array( $element, $include_array, true ) ) {
310
+ return true;
311
+ }
312
+
313
+ return false;
314
+ }
315
+
316
+ /**
317
+ * Returns the html for an icon based on the kind requested
318
+ *
319
+ * @param string $type kind of icon needed (ex "video" is a play button)
320
+ * @param string $icon_type svg or font
321
+ *
322
+ * @return string
323
+ *
324
+ * @since 1.0
325
+ */
326
+ protected static function get_basic_icons( $type, $icon_type ) {
327
+ if ( $type === 'carousel' ) {
328
+ if ( $icon_type === 'svg' ) {
329
+ return '<svg class="svg-inline--fa fa-clone fa-w-16 sby_lightbox_carousel_icon" aria-hidden="true" data-fa-proƒcessed="" data-prefix="far" data-icon="clone" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
330
+ <path fill="currentColor" d="M464 0H144c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h320c26.51 0 48-21.49 48-48v-48h48c26.51 0 48-21.49 48-48V48c0-26.51-21.49-48-48-48zM362 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h42v224c0 26.51 21.49 48 48 48h224v42a6 6 0 0 1-6 6zm96-96H150a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h308a6 6 0 0 1 6 6v308a6 6 0 0 1-6 6z"></path>
331
+ </svg>';
332
+ } else {
333
+ return '<i class="fa fa-clone sby_carousel_icon" aria-hidden="true"></i>';
334
+ }
335
+
336
+ } elseif ( $type === 'video' ) {
337
+ if ( $icon_type === 'svg' ) {
338
+ return '<svg style="color: rgba(255,255,255,1)" class="svg-inline--fa fa-play fa-w-14 sby_playbtn" aria-hidden="true" data-fa-processed="" data-prefix="fa" data-icon="play" role="presentation" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path></svg>';
339
+ } else {
340
+ return '<i class="fa fa-play sby_playbtn" aria-hidden="true"></i>';
341
+ }
342
+ } elseif ( $type === 'youtube' ) {
343
+ if ( $icon_type === 'svg' ) {
344
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="youtube" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="svg-inline--fa fa-youtube fa-w-18"><path fill="currentColor" d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z" class=""></path></svg>';
345
+ } else {
346
+ return '<i aria-hidden="true" role="img" class="sby_new_logo fab fa-youtube"></i>';
347
+ }
348
+ } elseif ( $type === 'newlogo' ) {
349
+ if ( $icon_type === 'svg' ) {
350
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="youtube" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="sby_new_logo svg-inline--fa fa-youtube fa-w-18"><path fill="currentColor" d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z" class=""></path></svg>';
351
+ } else {
352
+ return '<i aria-hidden="true" role="img" class="sby_new_logo fab fa-youtube"></i>';
353
+ }
354
+ } elseif ( $type === 'play') {
355
+ if ( $icon_type === 'svg' ) {
356
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="youtube" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="svg-inline--fa fa-youtube fa-w-18"><path fill="currentColor" d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z" class=""></path></svg>';
357
+ } else {
358
+ return '<i aria-hidden="true" role="img" class="fa fas fa-play"></i>';
359
+ }
360
+ } else {
361
+ return '';
362
+ }
363
+ }
364
+
365
+ public static function escaped_data_att_string( $atts ) {
366
+ if ( empty( $atts ) ) {
367
+ return '';
368
+ }
369
+ $string = '';
370
+ foreach ( $atts as $key => $value ) {
371
+ $string .= ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
372
+ }
373
+
374
+ return $string;
375
+ }
376
  }
inc/class-sby-feed.php CHANGED
@@ -1,1634 +1,1640 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- die( '-1' );
5
- }
6
-
7
- class SBY_Feed
8
- {
9
- /**
10
- * @var string
11
- */
12
- protected $regular_feed_transient_name;
13
-
14
- /**
15
- * @var string
16
- */
17
- private $header_transient_name;
18
-
19
- /**
20
- * @var string
21
- */
22
- private $backup_feed_transient_name;
23
-
24
- /**
25
- * @var string
26
- */
27
- private $backup_header_transient_name;
28
-
29
- protected $channels_data;
30
-
31
- /**
32
- * @var array
33
- */
34
- private $post_data;
35
-
36
- /**
37
- * @var
38
- */
39
- private $header_data;
40
-
41
- /**
42
- * @var array
43
- */
44
- protected $next_pages;
45
-
46
- /**
47
- * @var array
48
- */
49
- private $transient_atts;
50
-
51
- /**
52
- * @var int
53
- */
54
- private $last_retrieve;
55
-
56
- /**
57
- * @var bool
58
- */
59
- private $should_paginate;
60
-
61
- /**
62
- * @var int
63
- */
64
- private $num_api_calls;
65
-
66
- /**
67
- * @var int
68
- */
69
- private $max_api_calls;
70
-
71
- /**
72
- * @var array
73
- */
74
- protected $image_ids_post_set;
75
-
76
- /**
77
- * @var array
78
- */
79
- public $post_ids_with_no_details;
80
-
81
- /**
82
- * @var bool
83
- */
84
- private $should_use_backup;
85
-
86
- /**
87
- * @var array
88
- */
89
- private $report;
90
-
91
- private $successful_video_api_request_made;
92
-
93
- private $do_page_cache_all;
94
-
95
- /**
96
- * SBY_Feed constructor.
97
- *
98
- * @param string $transient_name ID of this feed
99
- * generated in the SBY_Settings class
100
- */
101
- public function __construct( $transient_name ) {
102
- $this->regular_feed_transient_name = $transient_name;
103
- $this->backup_feed_transient_name = SBY_BACKUP_PREFIX . $transient_name;
104
-
105
- $sby_header_transient_name = str_replace( 'sby_', 'sby_header_', $transient_name );
106
- $sby_header_transient_name = substr($sby_header_transient_name, 0, 44);
107
- $this->header_transient_name = $sby_header_transient_name;
108
- $this->backup_header_transient_name = SBY_BACKUP_PREFIX . $sby_header_transient_name;
109
-
110
- $this->channels_data = array();
111
-
112
- $this->post_data = array();
113
- $this->next_pages = array();
114
- $this->should_paginate = true;
115
-
116
- // this is a count of how many api calls have been made for each feed
117
- // type and term.
118
- // By default the limit is 10
119
- $this->num_api_calls = 0;
120
- $this->max_api_calls = apply_filters( 'sby_max_concurrent_api_calls', 10 );
121
- $this->should_use_backup = false;
122
-
123
- // used for errors and the sby_debug report
124
- $this->report = array();
125
- $this->successful_video_api_request_made = false;
126
- $this->post_ids_with_no_details = array();
127
- $this->do_page_cache_all = false;
128
- }
129
-
130
- /**
131
- * @return array
132
- *
133
- * @since 1.0
134
- */
135
- public function get_post_data() {
136
- return $this->post_data;
137
- }
138
-
139
- /**
140
- * @return array
141
- *
142
- * @since 1.0
143
- */
144
- public function set_post_data( $post_data ) {
145
- $this->post_data = $post_data;
146
- }
147
-
148
- public function get_misc_data( $feed_id, $posts ) {
149
- return array();
150
- }
151
-
152
- /**
153
- * @return array
154
- *
155
- * @since 1.0
156
- */
157
- public function get_next_pages() {
158
- return $this->next_pages;
159
- }
160
-
161
- /**
162
- * Checks the database option related the transient expiration
163
- * to ensure it will be available when the page loads
164
- *
165
- * @return bool
166
- *
167
- * @since 2.0/4.0
168
- */
169
- public function regular_cache_exists() {
170
- //Check whether the cache transient exists in the database and is available for more than one more minute
171
- $transient_exists = get_transient( $this->regular_feed_transient_name );
172
-
173
- return $transient_exists;
174
- }
175
-
176
- /**
177
- * Checks the database option related the header transient
178
- * expiration to ensure it will be available when the page loads
179
- *
180
- * @return bool
181
- *
182
- * @since 1.0
183
- */
184
- public function regular_header_cache_exists() {
185
- $header_transient = get_transient( $this->header_transient_name );
186
-
187
- return $header_transient;
188
- }
189
-
190
- public function get_channel_cache( $channel, $force_get_cache = false ) {
191
- if ( $this->is_pageable() && ! $force_get_cache ) {
192
- return false;
193
- }
194
-
195
- $maybe_cache = get_option( SBY_CHANNEL_CACHE_PREFIX . $channel );
196
- if ( $maybe_cache !== false ) {
197
- $maybe_cache = json_decode( $maybe_cache, true );
198
- }
199
-
200
- return $maybe_cache;
201
- }
202
-
203
- public function set_channel_cache( $channel, $cache ) {
204
- if ( is_array( $cache ) ) {
205
- $cache = wp_json_encode( $cache );
206
- }
207
-
208
- update_option( SBY_CHANNEL_CACHE_PREFIX . $channel, $cache, false );
209
- }
210
-
211
- /**
212
- * @return bool
213
- *
214
- * @since 1.0
215
- */
216
- public function should_use_backup() {
217
- return $this->should_use_backup || empty( $this->post_data );
218
- }
219
-
220
- /**
221
- * The header is only displayed when the setting is enabled and
222
- * an account has been connected
223
- *
224
- * Overwritten in the Pro version
225
- *
226
- * @param array $settings settings specific to this feed
227
- * @param array $feed_types_and_terms organized settings related to feed data
228
- * (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
229
- *
230
- * @return bool
231
- *
232
- * @since 1.0
233
- */
234
- public function need_header( $settings, $feed_types_and_terms ) {
235
- $showheader = ($settings['showheader'] === 'on' || $settings['showheader'] === 'true' || $settings['showheader'] === true);
236
- return ($showheader && isset( $feed_types_and_terms['channels'] ));
237
- }
238
-
239
- /**
240
- * Use the transient name to retrieve cached data for header
241
- *
242
- * @since 1.0
243
- */
244
- public function set_header_data_from_cache() {
245
- $header_cache = get_transient( $this->header_transient_name );
246
-
247
- $header_cache = json_decode( $header_cache, true );
248
-
249
- if ( ! empty( $header_cache ) ) {
250
- $this->header_data = $header_cache;
251
- }
252
- }
253
-
254
- public function set_header_data( $header_data ) {
255
- $this->header_data = $header_data;
256
- }
257
-
258
- /**
259
- * @since 1.0
260
- */
261
- public function get_header_data() {
262
- return $this->header_data;
263
- }
264
-
265
- /**
266
- * Sets the post data, pagination data, shortcode atts used (cron cache),
267
- * and timestamp of last retrieval from transient (cron cache)
268
- *
269
- * @param array $atts available for cron caching
270
- *
271
- * @since 1.0
272
- */
273
- public function set_post_data_from_cache( $atts = array() ) {
274
- $transient_data = get_transient( $this->regular_feed_transient_name );
275
-
276
- $transient_data = json_decode( $transient_data, true );
277
-
278
- if ( $transient_data ) {
279
- $post_data = isset( $transient_data['data'] ) ? $transient_data['data'] : array();
280
- $this->post_data = $post_data;
281
- $this->next_pages = isset( $transient_data['pagination'] ) ? $transient_data['pagination'] : array();
282
-
283
- if ( isset( $transient_data['atts'] ) ) {
284
- $this->transient_atts = $transient_data['atts'];
285
- $this->last_retrieve = $transient_data['last_retrieve'];
286
- }
287
- }
288
- }
289
-
290
- /**
291
- * Sets post data from a permanent database backup of feed
292
- * if it was created
293
- *
294
- * @since 1.0
295
- */
296
- public function maybe_set_post_data_from_backup() {
297
- $args = array(
298
- 'post_type' => SBY_CPT,
299
- 'post_status' => array( 'publish', 'pending', 'draft' ),
300
- 'orderby' => 'date',
301
- 'order' => 'DESC',
302
- 'posts_per_page' => 50,
303
- 'meta_query' => array(
304
- array(
305
- 'value' => sby_strip_after_hash( $this->regular_feed_transient_name ),
306
- 'key' => 'sby_feed_id'
307
- )
308
- )
309
- );
310
- $feed_videos = new WP_Query( $args );
311
-
312
- if ( $feed_videos->have_posts() ) {
313
- $posts = array();
314
- while ( $feed_videos->have_posts() ) {
315
- $feed_videos->the_post();
316
- $json = get_post_meta( get_the_ID(), 'sby_json', true );
317
-
318
- if ( $json ) {
319
- $posts[] = json_decode( $json, true );
320
- }
321
- }
322
-
323
- wp_reset_postdata();
324
-
325
- $this->post_data = $posts;
326
- return true;
327
- } else {
328
- $this->add_report( 'no backup post data found' );
329
- wp_reset_postdata();
330
-
331
- return false;
332
- }
333
- }
334
-
335
- /**
336
- * Sets header data from a permanent database backup of feed
337
- * if it was created
338
- *
339
- * @since 1.0
340
- */
341
- public function maybe_set_header_data_from_backup() {
342
- $backup_header_data = get_option( $this->backup_header_transient_name, false );
343
-
344
- if ( ! empty( $backup_header_data ) ) {
345
- $backup_header_data = json_decode( $backup_header_data, true );
346
- $this->header_data = $backup_header_data;
347
-
348
- return true;
349
- } else {
350
- $this->add_report( 'no backup header data found' );
351
-
352
- return false;
353
- }
354
- }
355
-
356
- /**
357
- * Returns recorded image IDs for this post set
358
- * for use with image resizing
359
- *
360
- * @return array
361
- *
362
- * @since 1.0
363
- */
364
- public function get_image_ids_post_set() {
365
- return $this->image_ids_post_set;
366
- }
367
-
368
- /**
369
- * Cron caching needs additional data saved in the transient
370
- * to work properly. This function checks to make sure it's present
371
- *
372
- * @return bool
373
- *
374
- * @since 1.0
375
- */
376
- public function need_to_start_cron_job() {
377
- return (( ! empty( $this->post_data ) && ! isset( $this->transient_atts )) || empty( $this->post_data ));
378
- }
379
-
380
- /**
381
- * Checks to see if there are enough posts available to create
382
- * the current page of the feed
383
- *
384
- * @param int $num
385
- * @param int $offset
386
- *
387
- * @return bool
388
- *
389
- * @since 1.0
390
- */
391
- public function need_posts( $num, $offset = 0 ) {
392
- $num_existing_posts = is_array( $this->post_data ) ? count( $this->post_data ) : 0;
393
- $num_needed_for_page = (int)$num + (int)$offset;
394
-
395
- ($num_existing_posts < $num_needed_for_page) ? $this->add_report( 'need more posts' ) : $this->add_report( 'have enough posts' );
396
-
397
- return ($num_existing_posts < $num_needed_for_page);
398
- }
399
-
400
- /**
401
- * Checks to see if there are additional pages available for any of the
402
- * accounts in the feed and that the max conccurrent api request limit
403
- * has not been reached
404
- *
405
- * @return bool
406
- *
407
- * @since 1.0
408
- */
409
- public function can_get_more_posts() {
410
- $one_type_and_term_has_more_ages = $this->next_pages !== false;
411
- $max_concurrent_api_calls_not_met = $this->num_api_calls < $this->max_api_calls;
412
- $max_concurrent_api_calls_not_met ? $this->add_report( 'max conccurrent requests not met' ) : $this->add_report( 'max concurrent met' );
413
- $one_type_and_term_has_more_ages ? $this->add_report( 'more pages available' ) : $this->add_report( 'no next page' );
414
-
415
- return ($one_type_and_term_has_more_ages && $max_concurrent_api_calls_not_met);
416
- }
417
-
418
- public function get_play_list_for_term( $type, $term, $connected_account_for_term, $params ) {
419
-
420
- if ( $type === 'search' || $type === 'live' ) {
421
- return false;
422
- }
423
- $existing_channel_cache = $this->get_channel_cache( $term );
424
-
425
- if ( $existing_channel_cache ) {
426
- $this->channels_data[ $term ] = $existing_channel_cache;
427
- }
428
-
429
- if ( empty( $this->channels_data[ $term ] ) ) {
430
- if ( $connected_account_for_term['expires'] < time() + 5 ) {
431
- $error_message = '<p><b>' . __( 'Reconnect to YouTube to show this feed.', 'custom-facebook-feed' ) . '</b></p>';
432
- $error_message .= '<p>' . __( 'To create a new feed, first connect to YouTube using the "Connect to YouTube to Create a Feed" button on the settings page and connect any account.', SBY_TEXT_DOMAIN ) . '</p>';
433
-
434
- if ( current_user_can( 'manage_youtube_feed_options' ) ) {
435
- $error_message .= '<a href="' . admin_url( 'admin.php?page=youtube-feed' ) . '" target="blank" rel="noopener nofollow">' . __( 'Reconnect in the YouTube Feed Settings Area' ) . '</a>';
436
- }
437
- global $sby_posts_manager;
438
-
439
- $sby_posts_manager->add_frontend_error( 'accesstoken', $error_message );
440
- $sby_posts_manager->add_error( 'accesstoken', array( 'Trying to connect a new account', $error_message ) );
441
-
442
- return false;
443
- }
444
- $channel_data = array();
445
- $api_connect_channels = $this->make_api_connection( $connected_account_for_term, 'channels', $params );
446
-
447
- $this->add_report( 'channel api call made for ' . $term . ' - ' . $type );
448
-
449
- $api_connect_channels->connect();
450
- if ( ! $api_connect_channels->is_wp_error() && ! $api_connect_channels->is_youtube_error() ) {
451
- $channel_data = $api_connect_channels->get_data();
452
- $channel_id = SBY_Parse::get_channel_id( $channel_data );
453
- $this->set_channel_cache( $channel_id, $channel_data );
454
-
455
- if ( isset( $params['channel_name'] ) ) {
456
- sby_set_channel_id_from_channel_name( $params['channel_name'], $channel_id );
457
- $this->set_channel_cache( $params['channel_name'], $channel_data );
458
- }
459
-
460
- $params = array( 'channel_id' => $channel_id );
461
- $this->channels_data[ $channel_id ] = $channel_data;
462
- $this->channels_data[ $term ] = $channel_data;
463
- } else {
464
- if ( ! $api_connect_channels->is_wp_error() ) {
465
- $return = SBY_API_Connect::handle_youtube_error( $api_connect_channels->get_data(), $connected_account_for_term );
466
- if ( $return && isset( $return['access_token'] ) ) {
467
- $connected_account_for_term['access_token'] = $return['access_token'];
468
- $connected_accounts_for_feed[ $term ]['access_token'] = $return['access_token'];
469
- $connected_account_for_term['expires'] = $return['expires_in'] + time();
470
- $connected_accounts_for_feed[ $term ]['expires'] = $return['expires_in'] + time();
471
-
472
- sby_update_or_connect_account( $connected_account_for_term );
473
- $this->add_report( 'refreshing access token for ' . $connected_account_for_term['channel_id'] );
474
-
475
- $sby_api_connect_channel = $this->make_api_connection( $connected_account_for_term, 'channels', $params );
476
- $sby_api_connect_channel->connect();
477
- if ( ! $sby_api_connect_channel->is_youtube_error() ) {
478
- $channel_data = $sby_api_connect_channel->get_data();
479
- $channel_id = SBY_Parse::get_channel_id( $channel_data );
480
- $this->set_channel_cache( $channel_id, $channel_data );
481
-
482
- if ( isset( $params['channel_name'] ) ) {
483
- sby_set_channel_id_from_channel_name( $params['channel_name'], $channel_id );
484
- $this->set_channel_cache( $params['channel_name'], $channel_data );
485
- }
486
-
487
- $this->channels_data[ $channel_id ] = $channel_data;
488
- $this->channels_data[ $term ] = $channel_data;
489
-
490
- }
491
- } else {
492
- $this->add_report( 'error connecting to channel' );
493
- }
494
- } else {
495
- $api_connect_channels->handle_wp_remote_get_error( $api_connect_channels->get_data() );
496
- }
497
- }
498
- }
499
-
500
- $playlist = isset( $this->channels_data[ $term ]['items'][0]['contentDetails']['relatedPlaylists']['uploads'] ) ? $this->channels_data[ $term ]['items'][0]['contentDetails']['relatedPlaylists']['uploads'] : false;
501
-
502
- return $playlist;
503
- }
504
-
505
- public function maybe_refresh_token( $term, $connected_account_for_term ) {
506
- return $connected_account_for_term;
507
- }
508
-
509
- public function is_efficient_type( $type ) {
510
- return true;
511
- }
512
-
513
- public function requires_workaround_connection( $type ) {
514
- return false;
515
- }
516
-
517
- public function make_workaround_connection( $connected_account_for_term, $type, $params ) {
518
- return $this->make_api_connection( $connected_account_for_term, $type, $params );
519
- }
520
-
521
-
522
- /**
523
- * Appends one filtered API request worth of posts for each feed term
524
- *
525
- * @param $settings
526
- * @param array $feed_types_and_terms organized settings related to feed data
527
- * (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
528
- * @param array $connected_accounts_for_feed connected account data for the
529
- * feed types and terms
530
- *
531
- * @since 1.0
532
- */
533
-
534
- public function add_remote_posts( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
535
- $new_post_sets = array();
536
- $next_pages = $this->next_pages;
537
- global $sby_posts_manager;
538
- $api_requests_delayed = $sby_posts_manager->are_current_api_request_delays();
539
-
540
- /**
541
- * Number of posts to retrieve in each API call
542
- *
543
- * @param int Minimum number of posts needed in each API request
544
- * @param array $settings Settings for this feed
545
- *
546
- * @since 1.0
547
- */
548
- $num = apply_filters( 'sby_num_in_request', (int)$settings['minnum'], $settings );
549
-
550
- $params = array(
551
- 'num' => $num
552
- );
553
-
554
- $one_successful_connection = false;
555
- $next_page_found = false;
556
- $one_api_request_delayed = false;
557
-
558
-
559
-
560
- foreach ( $feed_types_and_terms as $type => $terms ) {
561
- if ( is_array( $terms ) && count( $terms ) > 5 ) {
562
- shuffle( $terms );
563
- }
564
- foreach ( $terms as $term_and_params ) {
565
-
566
- $term = $term_and_params['term'];
567
- $params = array_merge( $params, $term_and_params['params'] );
568
-
569
- $connected_accounts_for_feed[ $term ] = $this->maybe_refresh_token( $term, $connected_accounts_for_feed[ $term ] );
570
- $connected_account_for_term = $connected_accounts_for_feed[ $term ];
571
-
572
- $play_list = $this->get_play_list_for_term( $type, $term, $connected_account_for_term, $params );
573
-
574
- if ( ! empty( $next_pages[ $term . '_' . $type ] ) ) {
575
- $params['nextPageToken'] = $next_pages[ $term . '_' . $type ];
576
- }
577
-
578
- if ( $this->is_pageable() ) {
579
- $this->add_remote_pageable_posts( $settings, $feed_types_and_terms, $connected_accounts_for_feed );
580
- } else {
581
- $this->add_remote_non_pageable( $settings, $feed_types_and_terms, $connected_accounts_for_feed );
582
- }
583
-
584
- if ( ! $this->is_efficient_type( $type ) && $this->is_pageable() ) {
585
-
586
- if ( $this->requires_workaround_connection( $type ) ) {
587
- $api_connect_playlist_items = $this->make_workaround_connection( $connected_account_for_term, $type, $params );
588
- $this->add_report( 'Workaround API call made for ' . $term );
589
-
590
- } else {
591
- if ( $play_list ) {
592
- $params['playlist_id'] = $play_list;
593
- $api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, 'playlistItems', $params );
594
- } else {
595
- $api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, $type, $params );
596
- }
597
-
598
- $api_connect_playlist_items->connect();
599
- $this->add_report( 'API call made for ' . $term );
600
- }
601
-
602
-
603
- if ( ! $api_connect_playlist_items->is_wp_error() && ! $api_connect_playlist_items->is_youtube_error() ) {
604
- $one_successful_connection = true;
605
- $data = $api_connect_playlist_items->get_data();
606
-
607
- if ( isset( $data['items'][0] ) ) {
608
- $post_set = $this->filter_posts( $data['items'], $settings );
609
-
610
- $this->successful_video_api_request_made = true;
611
-
612
- $new_post_sets[] = $post_set;
613
- }
614
-
615
- $next_page = $api_connect_playlist_items->get_next_page( $params );
616
- $report = is_array( $next_page ) ? implode( ',', $next_page ) : $next_page;
617
- $this->add_report( 'Next Page ' . $report );
618
-
619
-
620
- if ( ! empty( $next_page ) ) {
621
- $next_pages[ $term . '_' . $type ] = $next_page;
622
- $next_page_found = true;
623
- } else {
624
- $next_pages[ $term . '_' . $type ] = false;
625
- }
626
- }
627
-
628
-
629
- $this->num_api_calls++;
630
-
631
- } else {
632
-
633
- if ( ! $this->is_pageable() && (int)self::get_channel_status( $term ) !== 1 ) {
634
- self::update_channel_status( $term, 1 );
635
- $this->do_page_cache_all = true;
636
- $play_list = $this->get_play_list_for_term( $type, $term, $connected_account_for_term, $params );
637
-
638
- $channel_id = isset( $this->channels_data[ $term ] ) ? SBY_Parse::get_channel_id( $this->channels_data[ $term ] ) : '';
639
- $params['channel_id'] = $channel_id;
640
- $params['num'] = 50;
641
-
642
- if ( $play_list ) {
643
-
644
- $params['playlist_id'] = $play_list;
645
- if ( ! empty( $next_pages[ $term . '_' . $type ] ) && $next_pages[ $term . '_' . $type ] !== 'rss' ) {
646
- $params['nextPageToken'] = $next_pages[ $term . '_' . $type ];
647
- }
648
-
649
- self::update_channel_status( $term, 1 );
650
- $this->do_page_cache_all = true;
651
- $this->add_report( 'using API request to get first 50 videos' );
652
-
653
- $api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, 'playlistItems', $params );
654
-
655
- $api_connect_playlist_items->connect();
656
-
657
- if ( ! $api_connect_playlist_items->is_wp_error() && ! $api_connect_playlist_items->is_youtube_error() ) {
658
- $one_successful_connection = true;
659
- $data = $api_connect_playlist_items->get_data();
660
-
661
- if ( isset( $data['items'][0] ) ) {
662
- $post_set = $this->filter_posts( $data['items'], $settings );
663
-
664
- $this->successful_video_api_request_made = true;
665
-
666
- $new_post_sets[] = $post_set;
667
- }
668
-
669
- $next_pages[ $term . '_' . $type ] = false;
670
- }
671
- } else {
672
- $this->add_report( 'no first playlist' );
673
- }
674
-
675
- } elseif ( ! $this->is_pageable()
676
- && isset( $params['channel_id'] )
677
- && (! isset( $next_pages[ $term . '_' . $type ] ) || $next_pages[ $term . '_' . $type ] !== 'rss') ) {
678
-
679
- $rss_connect_playlist_items = new SBY_RSS_Connect( 'playlistItems', $params );
680
- $this->add_report( 'RSS call made for ' . $term );
681
-
682
- $rss_connect_playlist_items->connect();
683
-
684
- $one_successful_connection = true;
685
-
686
- $data = $rss_connect_playlist_items->get_data();
687
-
688
- if ( isset( $data[0] ) ) {
689
- $data = array(
690
- 'items' => $data
691
- );
692
- $post_set = $this->filter_posts( $data['items'], $settings );
693
-
694
- $this->successful_video_api_request_made = true;
695
-
696
- if ( count( $post_set ) > 14 ) {
697
- if ( (int)self::get_channel_status( $term ) !== 1 ) {
698
- $next_pages[ $term . '_' . $type ] = 'rss';
699
- $next_page_found = true;
700
- } else {
701
- $this->add_report( 'RSS update only for ' . $term );
702
- $post_set = $this->merge_cached_posts( $post_set, $term );
703
- $next_pages[ $term . '_' . $type ] = false;
704
- }
705
- } else {
706
- $next_pages[ $term . '_' . $type ] = false;
707
- }
708
-
709
- $new_post_sets[] = $post_set;
710
-
711
- }
712
- } elseif ( isset( $connected_account_for_term['rss_only'] ) ) {
713
- $rss_connect_playlist_items = new SBY_RSS_Connect( 'playlistItems', $params );
714
- $this->add_report( 'RSS Only call made for ' . $term );
715
-
716
- $rss_connect_playlist_items->connect();
717
-
718
- $one_successful_connection = true;
719
-
720
- $data = $rss_connect_playlist_items->get_data();
721
- $next_pages[ $term . '_' . $type ] = false;
722
-
723
- if ( isset( $data[0] ) ) {
724
- $data = array(
725
- 'items' => $data
726
- );
727
- $post_set = $this->filter_posts( $data['items'], $settings );
728
-
729
- $this->successful_video_api_request_made = true;
730
- $new_post_sets[] = $post_set;
731
- }
732
- } else {
733
-
734
- if ( ! $api_requests_delayed
735
- && (! isset( $next_pages[ $term . '_' . $type ] ) || $next_pages[ $term . '_' . $type ] !== false) ) {
736
-
737
- $play_list = $this->get_play_list_for_term( $type, $term, $connected_account_for_term, $params );
738
-
739
- $channel_id = isset( $this->channels_data[ $term ] ) ? SBY_Parse::get_channel_id( $this->channels_data[ $term ] ) : '';
740
- $params['channel_id'] = $channel_id;
741
-
742
- if ( $play_list ) {
743
-
744
- $params['playlist_id'] = $play_list;
745
- if ( ! empty( $next_pages[ $term . '_' . $type ] ) && $next_pages[ $term . '_' . $type ] !== 'rss' ) {
746
- $params['nextPageToken'] = $next_pages[ $term . '_' . $type ];
747
- }
748
-
749
- if ( isset( $next_pages[ $term . '_' . $type ] ) && $next_pages[ $term . '_' . $type ] === 'rss' ) {
750
- self::update_channel_status( $term, 1 );
751
- $this->do_page_cache_all = true;
752
- $this->add_report( 'using API request to get first 50 videos' );
753
- } else {
754
- $this->add_report( 'using API request to get more videos' );
755
- }
756
-
757
- $api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, 'playlistItems', $params );
758
-
759
- $api_connect_playlist_items->connect();
760
-
761
- if ( ! $api_connect_playlist_items->is_wp_error() && ! $api_connect_playlist_items->is_youtube_error() ) {
762
- $one_successful_connection = true;
763
- $data = $api_connect_playlist_items->get_data();
764
-
765
- if ( isset( $data['items'][0] ) ) {
766
- $post_set = $this->filter_posts( $data['items'], $settings );
767
-
768
- $this->successful_video_api_request_made = true;
769
-
770
- $new_post_sets[] = $post_set;
771
- }
772
-
773
- $next_page = $this->is_pageable() ? $api_connect_playlist_items->get_next_page() : false;
774
- if ( ! empty( $next_page ) ) {
775
- $next_pages[ $term . '_' . $type ] = $next_page;
776
- $next_page_found = true;
777
- } else {
778
- $next_pages[ $term . '_' . $type ] = false;
779
- }
780
- }
781
- } else {
782
- $this->add_report( 'no first playlist' );
783
- }
784
-
785
- if ( ! $this->is_pageable()
786
- && empty( $next_pages[ $term . '_' . $type ] )
787
- && ! empty( $params['channel_id'] ) ) {
788
- $this->add_report( 'using RSS to get first 15' );
789
-
790
- $rss_connect_playlist_items = new SBY_RSS_Connect( 'playlistItems', $params );
791
-
792
- $rss_connect_playlist_items->connect();
793
-
794
- $one_successful_connection = true;
795
-
796
- $data = $rss_connect_playlist_items->get_data();
797
-
798
- if ( isset( $data[0] ) ) {
799
- $data = array(
800
- 'items' => $data
801
- );
802
- $post_set = $this->filter_posts( $data['items'], $settings );
803
-
804
- $this->successful_video_api_request_made = true;
805
-
806
-
807
- if ( count( $post_set ) > 14 ) {
808
- if ( (int)self::get_channel_status( $term ) !== 1 ) {
809
- $next_pages[ $term . '_' . $type ] = 'rss';
810
- $next_page_found = true;
811
- } else {
812
- $this->add_report( 'RSS Only' . $term );
813
- $post_set = $this->merge_cached_posts( $post_set, $term );
814
- $next_pages[ $term . '_' . $type ] = false;
815
- }
816
- } else {
817
- $next_pages[ $term . '_' . $type ] = false;
818
- }
819
-
820
- $new_post_sets[] = $post_set;
821
-
822
- }
823
- } else {
824
- $this->num_api_calls++;
825
- }
826
-
827
- }
828
- }
829
- }
830
-
831
- }
832
-
833
- }
834
-
835
- if ( ! $one_successful_connection || ($one_api_request_delayed && empty( $new_post_sets )) ) {
836
- $this->should_use_backup = true;
837
- }
838
- $posts = $this->merge_posts( $new_post_sets, $settings );
839
-
840
- $posts = $this->sort_posts( $posts, $settings );
841
-
842
- if ( ! empty( $this->post_data ) && is_array( $this->post_data ) ) {
843
- $posts = array_merge( $this->post_data, $posts );
844
- }
845
-
846
- $this->post_data = $posts;
847
-
848
- if ( isset( $next_page_found ) && $next_page_found ) {
849
- $this->next_pages = $next_pages;
850
- } else {
851
- $this->next_pages = false;
852
- }
853
- }
854
-
855
- public function add_remote_pageable_posts() {
856
-
857
- }
858
-
859
- public function add_remote_non_pageable() {
860
-
861
- }
862
-
863
- private function is_pageable() {
864
- global $sby_settings;
865
-
866
- return ! empty( $sby_settings['api_key'] );
867
- }
868
-
869
- public function merge_cached_posts( $current_posts, $channel_id ) {
870
- $args = array(
871
- 'post_type' => SBY_CPT,
872
- 'post_status' => array( 'publish', 'pending', 'draft' ),
873
- 'orderby' => 'date',
874
- 'order' => 'DESC',
875
- 'posts_per_page' => 80,
876
- 'meta_query' => array(
877
- array(
878
- 'value' => $channel_id,
879
- 'key' => 'sby_channel_id'
880
- )
881
- )
882
- );
883
- $feed_videos = new WP_Query( $args );
884
-
885
- if ( $feed_videos->have_posts() ) {
886
- $posts = array();
887
- while ( $feed_videos->have_posts() ) {
888
- $feed_videos->the_post();
889
- $json = get_post_meta( get_the_ID(), 'sby_json', true );
890
- if ( $json ) {
891
- $posts[] = json_decode( $json, true );
892
- }
893
- }
894
-
895
- wp_reset_postdata();
896
- $this->add_report( 'merging cached posts' );
897
-
898
- $posts = array_merge( $current_posts, $posts );
899
-
900
- return $posts;
901
- } else {
902
- $this->add_report( 'no cached posts found' );
903
- wp_reset_postdata();
904
-
905
- return $current_posts;
906
- }
907
- }
908
-
909
- /**
910
- * Connects to the YouTube API and records returned data. Will use channel data if already
911
- * set by the regular feed
912
- *
913
- * @param $settings
914
- * @param array $feed_types_and_terms organized settings related to feed data
915
- * (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
916
- * @param array $connected_accounts_for_feed connected account data for the
917
- * feed types and terms
918
- *
919
- * @since 1.0
920
- */
921
- public function set_remote_header_data( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
922
- $first_user = $this->get_first_user( $feed_types_and_terms, $settings );
923
- $this->header_data = false;
924
- $existing_channel_cache = $this->get_channel_cache( $first_user );
925
-
926
- if ( $existing_channel_cache ) {
927
- $this->channels_data[ $first_user ] = $existing_channel_cache;
928
- $this->add_report( 'header data for ' . $first_user . ' exists in cache' );
929
- }
930
-
931
- if ( isset( $this->channels_data[ $first_user ] ) && ! $this->is_pageable() ) {
932
- $this->header_data = $this->channels_data[ $first_user ];
933
- } elseif ( ! empty( $first_user ) ) {
934
- $connected_account_for_term = sby_get_first_connected_account();
935
- if ( $connected_account_for_term['expires'] < time() + 5 ) {
936
- $error_message = '<p><b>' . __( 'Reconnect to YouTube to show this feed.', 'custom-facebook-feed' ) . '</b></p>';
937
- $error_message .= '<p>' . __( 'To create a new feed, first connect to YouTube using the "Connect to YouTube to Create a Feed" button on the settings page and connect any account.', SBY_TEXT_DOMAIN ) . '</p>';
938
-
939
- if ( current_user_can( 'manage_youtube_feed_options' ) ) {
940
- $error_message .= '<a href="' . admin_url( 'admin.php?page=youtube-feed' ) . '" target="blank" rel="noopener nofollow">' . __( 'Reconnect in the YouTube Feed Settings Area' ) . '</a>';
941
- }
942
- global $sby_posts_manager;
943
-
944
- $sby_posts_manager->add_frontend_error( 'accesstoken', $error_message );
945
- $sby_posts_manager->add_error( 'accesstoken', array( 'Trying to connect a new account', $error_message ) );
946
- } else {
947
- $channel_params_type = strpos( $first_user, 'UC' ) !== 0 ? 'channel_name' : 'channel_id';
948
- $params[ $channel_params_type ] = $first_user;
949
- $connection = $this->make_api_connection( $connected_account_for_term, 'channels', $params );
950
-
951
- $connection->connect();
952
- $this->add_report( 'api call made for header - ' . $first_user );
953
-
954
- if ( ! $connection->is_wp_error() && ! $connection->is_youtube_error() ) {
955
- $this->header_data = $connection->get_data();
956
- $channel_id = SBY_Parse::get_channel_id( $this->header_data );
957
- $this->set_channel_cache( $channel_id, $this->header_data );
958
- $this->channels_data[ $channel_id ] = $this->header_data;
959
- $this->channels_data[ $first_user ] = $this->header_data;
960
-
961
- if ( isset( $connected_accounts_for_feed[ $first_user ]['local_avatar'] ) && $connected_accounts_for_feed[ $first_user ]['local_avatar'] ) {
962
- $upload = wp_upload_dir();
963
- $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBY_UPLOADS_NAME );
964
-
965
- $full_file_name = $resized_url . $this->header_data['username'] . '.jpg';
966
- $this->header_data['local_avatar'] = $full_file_name;
967
- }
968
- } else {
969
- if ( $connection->is_wp_error() ) {
970
- SBY_API_Connect::handle_wp_remote_get_error( $connection->get_wp_error() );
971
- } else {
972
- SBY_API_Connect::handle_youtube_error( $connection->get_data(), $connected_accounts_for_feed[ $first_user ], 'header' );
973
- }
974
- }
975
- }
976
- }
977
- }
978
-
979
- /**
980
- * Stores feed data in a transient for a specified time
981
- *
982
- * @param int $cache_time
983
- *
984
- * @since 1.0
985
- */
986
- public function cache_feed_data( $cache_time ) {
987
- if ( ! empty( $this->post_data ) || ! empty( $this->next_pages ) ) {
988
- $this->remove_duplicate_posts();
989
- $this->trim_posts_to_max();
990
-
991
- $post_data = $this->post_data;
992
-
993
- if (! isset( $post_data[0]['iframe'] )) {
994
- $to_cache = array(
995
- 'data' => $this->post_data,
996
- 'pagination' => $this->next_pages
997
- );
998
-
999
- set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
1000
- } else {
1001
- $this->add_report( 'iframe not caching' );
1002
- }
1003
-
1004
-
1005
- } else {
1006
- $this->add_report( 'no data not caching' );
1007
- }
1008
- }
1009
-
1010
- /**
1011
- * Stores feed data with additional data specifically for cron caching
1012
- *
1013
- * @param array $to_cache feed data with additional things like the shortcode
1014
- * settings, when the cache was last requested, when new posts were last retrieved
1015
- * @param int $cache_time how long the cache will last
1016
- *
1017
- * @since 1.0
1018
- */
1019
- public function set_cron_cache( $to_cache, $cache_time ) {
1020
- if ( ! empty( $this->post_data )
1021
- || ! empty( $this->next_pages )
1022
- || ! empty( $to_cache['data'] ) ) {
1023
- $this->remove_duplicate_posts();
1024
- $this->trim_posts_to_max();
1025
-
1026
- $to_cache['data'] = isset( $to_cache['data'] ) ? $to_cache['data'] : $this->post_data;
1027
- $to_cache['pagination'] = isset( $to_cache['next_pages'] ) ? $to_cache['next_pages'] : $this->next_pages;
1028
- $to_cache['atts'] = isset( $to_cache['atts'] ) ? $to_cache['atts'] : $this->transient_atts;
1029
- $to_cache['last_requested'] = isset( $to_cache['last_requested'] ) ? $to_cache['last_requested'] : time();
1030
- $to_cache['last_retrieve'] = isset( $to_cache['last_retrieve'] ) ? $to_cache['last_retrieve'] : $this->last_retrieve;
1031
-
1032
- set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
1033
- } else {
1034
- $this->add_report( 'no data not caching' );
1035
- }
1036
-
1037
- }
1038
-
1039
- /**
1040
- * Stores header data for a specified time as a transient
1041
- *
1042
- * @param int $cache_time
1043
- * @param bool $save_backup
1044
- *
1045
- * @since 1.0
1046
- */
1047
- public function cache_header_data( $cache_time, $save_backup = true ) {
1048
- if ( $this->header_data ) {
1049
- set_transient( $this->header_transient_name, wp_json_encode( $this->header_data ), $cache_time );
1050
-
1051
- if ( $save_backup ) {
1052
- update_option( $this->backup_header_transient_name, wp_json_encode( $this->header_data ), false );
1053
- }
1054
- }
1055
- }
1056
-
1057
- /**
1058
- * Used to randomly trigger an updating of the last requested data for cron caching
1059
- *
1060
- * @return bool
1061
- *
1062
- * @since 1.0
1063
- */
1064
- public function should_update_last_requested() {
1065
- return (rand( 1, 20 ) === 20);
1066
- }
1067
-
1068
- /**
1069
- * Determines if pagination can and should be used based on settings and available feed data
1070
- *
1071
- * @param array $settings
1072
- * @param int $offset
1073
- *
1074
- * @return bool
1075
- *
1076
- * @since 1.0
1077
- */
1078
- public function should_use_pagination( $settings, $offset = 0 ) {
1079
- $posts_available = count( $this->post_data ) - ($offset + $settings['num']);
1080
- $show_loadmore_button_by_settings = ($settings['showbutton'] == 'on' || $settings['showbutton'] == 'true' || $settings['showbutton'] == true ) && $settings['showbutton'] !== 'false';
1081
-
1082
- if ( $show_loadmore_button_by_settings ) {
1083
- // used for permanent and whitelist feeds
1084
- if ( $this->feed_is_complete( $settings, $offset ) ) {
1085
- $this->add_report( 'no pagination, feed complete' );
1086
- return false;
1087
- }
1088
- if ( $posts_available > 0 ) {
1089
- $this->add_report( 'do pagination, posts available' );
1090
- return true;
1091
- }
1092
- $pages = $this->next_pages;
1093
-
1094
- if ( $pages && ! $this->should_use_backup() ) {
1095
- foreach ( $pages as $page ) {
1096
- if ( ! empty( $page ) ) {
1097
- return true;
1098
- }
1099
- }
1100
- }
1101
-
1102
- }
1103
-
1104
-
1105
- $this->add_report( 'no pagination, no posts available' );
1106
-
1107
- return false;
1108
- }
1109
-
1110
- public static function get_channel_status( $channel ) {
1111
- $channel_setting = get_option( 'sby_channel_status', array() );
1112
-
1113
- if ( isset( $channel_setting[ $channel ] ) ) {
1114
- return $channel_setting[ $channel ];
1115
- }
1116
-
1117
- return 0;
1118
- }
1119
-
1120
- public static function update_channel_status( $channel, $status ) {
1121
- $channel_setting = get_option( 'sby_channel_status', array() );
1122
-
1123
- $channel_setting[ $channel ] = $status;
1124
-
1125
- update_option( 'sby_channel_status', $channel_setting, false );
1126
- }
1127
-
1128
- /**
1129
- * Generates the HTML for the feed if post data is available. Although it seems
1130
- * some of the variables ar not used they are set here to hide where they
1131
- * come from when used in the feed templates.
1132
- *
1133
- * @param array $settings
1134
- * @param array $atts
1135
- * @param array $feed_types_and_terms organized settings related to feed data
1136
- * (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
1137
- * @param array $connected_accounts_for_feed connected account data for the
1138
- * feed types and terms
1139
- *
1140
- * @return false|string
1141
- *
1142
- * @since 1.0
1143
- */
1144
- public function get_the_feed_html( $settings, $atts, $feed_types_and_terms, $connected_accounts_for_feed ) {
1145
- global $sby_posts_manager;
1146
-
1147
- if ( empty( $this->post_data ) && ! empty( $connected_accounts_for_feed ) ) {
1148
- $error = '<p><b>' . __( 'Error: No videos found.', SBY_TEXT_DOMAIN ) . '</b>';
1149
- $error .= '<p>' . __( 'Make sure this is a valid channel ID and that the channel has videos available on youtube.com.', SBY_TEXT_DOMAIN ) . '</p>';
1150
-
1151
- $sby_posts_manager->add_frontend_error( 'noposts', $error );
1152
- }
1153
-
1154
- $posts = array_slice( $this->post_data, 0, $settings['minnum'] );
1155
- $header_data = ! empty( $this->header_data ) ? $this->header_data : false;
1156
-
1157
- $first_username = false;
1158
- if ( $header_data ) {
1159
- $first_username = SBY_Parse::get_channel_id( $header_data );
1160
- } elseif ( isset( $this->post_data[0] ) ) { // in case no connected account for feed
1161
- $first_username = SBY_Parse::get_channel_id( $this->post_data[0] );
1162
- }
1163
-
1164
- $use_pagination = $this->should_use_pagination( $settings, 0 );
1165
-
1166
- $feed_id = $this->regular_feed_transient_name;
1167
- $shortcode_atts = ! empty( $atts ) ? wp_json_encode( $atts ) : '{}';
1168
-
1169
- $settings['header_outside'] = false;
1170
- $settings['header_inside'] = false;
1171
- if ( $header_data && $settings['showheader'] ) {
1172
- $settings['header_inside'] = true;
1173
- }
1174
-
1175
- $other_atts = '';
1176
-
1177
- $classes = array();
1178
- if ( empty( $settings['widthresp'] ) || $settings['widthresp'] == 'on' || $settings['widthresp'] == 'true' || $settings['widthresp'] === true ) {
1179
- if ( $settings['widthresp'] !== 'false' ) {
1180
- $classes[] = 'sby_width_resp';
1181
- }
1182
- }
1183
- if ( ! empty( $settings['class'] ) ) {
1184
- $classes[] = esc_attr( $settings['class'] );
1185
- }
1186
- if ( ! empty( $settings['height'] )
1187
- && (((int)$settings['height'] < 100 && $settings['heightunit'] === '%') || $settings['heightunit'] === 'px') ) {
1188
- $classes[] = 'sby_fixed_height';
1189
- }
1190
- if ( ! empty( $settings['disablemobile'] )
1191
- && ($settings['disablemobile'] == 'on' || $settings['disablemobile'] == 'true' || $settings['disablemobile'] == true) ) {
1192
- if ( $settings['disablemobile'] !== 'false' ) {
1193
- $classes[] = 'sby_disable_mobile';
1194
- }
1195
- }
1196
-
1197
- $additional_classes = '';
1198
- if ( ! empty( $classes ) ) {
1199
- $additional_classes = ' ' . implode( ' ', $classes );
1200
- }
1201
-
1202
- $other_atts = $this->add_other_atts( $other_atts, $settings );
1203
-
1204
- $flags = array();
1205
-
1206
- if ( $this->successful_video_api_request_made && ! empty( $posts ) ) {
1207
- if ( $settings['storage_process'] === 'page' ) {
1208
- $this_posts = $posts;
1209
- if ( $this->do_page_cache_all ) {
1210
- $this_posts = $this->post_data;
1211
- }
1212
- $this->add_report( 'Adding videos to wp_posts ' . count( $this_posts ) );
1213
-
1214
- sby_process_post_set_caching( $this_posts, $feed_id );
1215
- } elseif ( $settings['storage_process'] === 'background' ) {
1216
- $flags[] = 'checkWPPosts';
1217
- if ( $this->do_page_cache_all ) {
1218
- $this->add_report( 'Flagging videos to wp_posts ' . count( $this->post_data ) );
1219
- $flags[] = 'cacheAll';
1220
- }
1221
- }
1222
- }
1223
-
1224
- if ( $settings['disable_resize'] ) {
1225
- $flags[] = 'resizeDisable';
1226
- } elseif ( $settings['favor_local'] ) {
1227
- $flags[] = 'favorLocal';
1228
- }
1229
-
1230
- if ( $settings['disable_js_image_loading'] ) {
1231
- $flags[] = 'imageLoadDisable';
1232
- }
1233
- if ( $settings['ajax_post_load'] ) {
1234
- $flags[] = 'ajaxPostLoad';
1235
- }
1236
- if ( $settings['playerratio'] === '3:4' ) {
1237
- $flags[] = 'narrowPlayer';
1238
- }
1239
- if ( isset( $_GET['sby_debug'] ) ) {
1240
- $flags[] = 'debug';
1241
- }
1242
-
1243
- if ( ! empty( $flags ) ) {
1244
- $other_atts .= ' data-sby-flags="' . implode(',', $flags ) . '"';
1245
- }
1246
-
1247
- if ( $settings['layout'] === 'grid' || $settings['layout'] === 'carousel' ) {
1248
- $other_atts .= ' data-sby-supports-lightbox="1"';
1249
- }
1250
- $icon_type = $settings['font_method'];
1251
-
1252
- ob_start();
1253
- include sby_get_feed_template_part( 'feed', $settings );
1254
- $html = ob_get_contents();
1255
- ob_get_clean();
1256
-
1257
- if ( $settings['ajaxtheme'] ) {
1258
- $html .= $this->get_ajax_page_load_html();
1259
- }
1260
-
1261
- return $html;
1262
- }
1263
-
1264
- /**
1265
- * Generates HTML for individual sby_item elements
1266
- *
1267
- * @param array $settings
1268
- * @param int $offset
1269
- * @param array $feed_types_and_terms organized settings related to feed data
1270
- * (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
1271
- * @param array $connected_accounts_for_feed connected account data for the
1272
- * feed types and terms
1273
- *
1274
- * @return false|string
1275
- *
1276
- * @since 1.0
1277
- */
1278
- public function get_the_items_html( $settings, $offset, $feed_types_and_terms = array(), $connected_accounts_for_feed = array() ) {
1279
- if ( empty( $this->post_data ) ) {
1280
- ob_start();
1281
- $html = ob_get_contents();
1282
- ob_get_clean(); ?>
1283
- <p><?php _e( 'No posts found.', SBY_TEXT_DOMAIN ); ?></p>
1284
- <?php
1285
- $html = ob_get_contents();
1286
- ob_get_clean();
1287
- return $html;
1288
- }
1289
-
1290
- $posts = array_slice( $this->post_data, $offset, $settings['num'] );
1291
-
1292
- ob_start();
1293
-
1294
- $this->posts_loop( $posts, $settings, $offset );
1295
-
1296
- $html = ob_get_contents();
1297
- ob_get_clean();
1298
-
1299
- return $html;
1300
- }
1301
-
1302
- /**
1303
- * Overwritten in the Pro version
1304
- *
1305
- * @return object
1306
- */
1307
- public function make_api_connection( $connected_account_or_page, $type = NULL, $params = NULL ) {
1308
- return new SBY_API_Connect( $connected_account_or_page, $type, $params );
1309
- }
1310
-
1311
- /**
1312
- * When the feed is loaded with AJAX, the JavaScript for the plugin
1313
- * needs to be triggered again. This function is a workaround that adds
1314
- * the file and settings to the page whenever the feed is generated.
1315
- *
1316
- * @return string
1317
- *
1318
- * @since 1.0
1319
- */
1320
- public static function get_ajax_page_load_html() {
1321
- global $sby_settings;
1322
-
1323
- $js_options = array(
1324
- 'adminAjaxUrl' => admin_url( 'admin-ajax.php' ),
1325
- 'placeholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder.png',
1326
- 'placeholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder-narrow.png',
1327
- 'lightboxPlaceholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder.png',
1328
- 'lightboxPlaceholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder-narrow.png',
1329
- 'autoplay' => $sby_settings['playvideo'] === 'automatically',
1330
- 'semiEagerload' => $sby_settings['eagerload'],
1331
- 'eagerload' => false
1332
- );
1333
-
1334
- $encoded_options = wp_json_encode( $js_options );
1335
-
1336
- $js_option_html = '<script type="text/javascript">if (typeof sbyOptions === "undefined") var sbyOptions = ' . $encoded_options . ';</script>';
1337
- $js_option_html .= "<script type='text/javascript' src='" . trailingslashit( SBY_PLUGIN_URL ) . 'js/sb-youtube.min.js?ver=' . SBYVER . "'></script>";
1338
-
1339
- return $js_option_html;
1340
- }
1341
-
1342
- /**
1343
- * Overwritten in the Pro version
1344
- *
1345
- * @param $feed_types_and_terms
1346
- *
1347
- * @return string
1348
- *
1349
- * @since 2.1/5.2
1350
- */
1351
- public function get_first_user( $feed_types_and_terms, $settings = array() ) {
1352
- if ( isset( $feed_types_and_terms['channels'][0] ) ) {
1353
- return $feed_types_and_terms['channels'][0]['term'];
1354
- } else {
1355
- return '';
1356
- }
1357
- }
1358
-
1359
- public function do_page_cache_all() {
1360
- return $this->do_page_cache_all;
1361
- }
1362
-
1363
- public function successful_video_api_request_made() {
1364
- return $this->successful_video_api_request_made;
1365
- }
1366
-
1367
- /**
1368
- * Adds recorded strings to an array
1369
- *
1370
- * @param $to_add
1371
- *
1372
- * @since 1.0
1373
- */
1374
- public function add_report( $to_add ) {
1375
- $this->report[] = $to_add;
1376
- }
1377
-
1378
- /**
1379
- * @return array
1380
- *
1381
- * @since 1.0
1382
- */
1383
- public function get_report() {
1384
- return $this->report;
1385
- }
1386
-
1387
- /**
1388
- * Additional options/settings added to the main div
1389
- * for the feed
1390
- *
1391
- * Overwritten in the Pro version
1392
- *
1393
- * @param $other_atts
1394
- * @param $settings
1395
- *
1396
- * @return string
1397
- */
1398
- protected function add_other_atts( $other_atts, $settings ) {
1399
- return '';
1400
- }
1401
-
1402
- /**
1403
- * Used for filtering a single API request worth of posts
1404
- *
1405
- * Overwritten in the Pro version
1406
- *
1407
- * @param array $post_set a single set of post data from the api
1408
- *
1409
- * @return mixed|array
1410
- *
1411
- * @since 1.0
1412
- */
1413
- protected function filter_posts( $post_set, $settings = array() ) {
1414
- // array_unique( $post_set, SORT_REGULAR);
1415
-
1416
- return $post_set;
1417
- }
1418
-
1419
- protected function remove_duplicate_posts() {
1420
- $posts = $this->post_data;
1421
- $ids_in_feed = array();
1422
- $non_duplicate_posts = array();
1423
- $removed = array();
1424
-
1425
- foreach ( $posts as $post ) {
1426
- $post_id = SBY_Parse::get_video_id( $post );
1427
- if ( ! in_array( $post_id, $ids_in_feed, true ) ) {
1428
- $ids_in_feed[] = $post_id;
1429
- $non_duplicate_posts[] = $post;
1430
- } else {
1431
- $removed[] = $post_id;
1432
- }
1433
- }
1434
-
1435
- $this->add_report( 'removed duplicates: ' . implode(', ', $removed ) );
1436
- $this->set_post_data( $non_duplicate_posts );
1437
- }
1438
-
1439
- /**
1440
- * Used for limiting the cache size
1441
- *
1442
- * @since 2.0/5.1.1
1443
- */
1444
- protected function trim_posts_to_max() {
1445
- if ( ! is_array( $this->post_data ) ) {
1446
- return;
1447
- }
1448
-
1449
- $max = apply_filters( 'sby_max_cache_size', 500 );
1450
- $this->set_post_data( array_slice( $this->post_data , 0, $max ) );
1451
-
1452
- }
1453
-
1454
- /**
1455
- * Used for permanent feeds or white list feeds to
1456
- * stop pagination if all posts are already added
1457
- *
1458
- * Overwritten in the Pro version
1459
- *
1460
- * @param array $settings
1461
- * @param int $offset
1462
- *
1463
- * @return bool
1464
- *
1465
- * @since 1.0
1466
- */
1467
- protected function feed_is_complete( $settings, $offset = 0 ) {
1468
- return false;
1469
- }
1470
-
1471
- /**
1472
- * Iterates through post data and tracks the index of the current post.
1473
- * The actual post ids of the posts are stored in an array so the plugin
1474
- * can search for local images that may be available.
1475
- *
1476
- * @param array $posts final filtered post data for the feed
1477
- * @param array $settings
1478
- * @param int $offset
1479
- *
1480
- * @since 1.0
1481
- */
1482
- protected function posts_loop( $posts, $settings, $offset = 0 ) {
1483
-
1484
- $image_ids = array();
1485
- $post_index = $offset;
1486
- if ( ! isset( $settings['feed_id'] ) ) {
1487
- $settings['feed_id'] = $this->regular_feed_transient_name;
1488
- }
1489
- $misc_data = $this->get_misc_data( $settings['feed_id'], $posts );
1490
- $icon_type = $settings['font_method'];
1491
-
1492
- foreach ( $posts as $post ) {
1493
- $image_ids[] = SBY_Parse::get_post_id( $post );
1494
- include sby_get_feed_template_part( 'item', $settings );
1495
- $post_index++;
1496
- }
1497
-
1498
- $this->image_ids_post_set = $image_ids;
1499
- }
1500
-
1501
- /**
1502
- * Uses array of API request results and merges them based on how
1503
- * the feed should be sorted. Mixed feeds are always sorted alternating
1504
- * since there is no post date for hashtag feeds.
1505
- *
1506
- * @param array $post_sets an array of single API request worth
1507
- * of posts
1508
- * @param array $settings
1509
- *
1510
- * @return array
1511
- *
1512
- * @since 1.0
1513
- */
1514
- private function merge_posts( $post_sets, $settings ) {
1515
-
1516
- $merged_posts = array();
1517
- if ( $settings['sortby'] === 'alternate' ) {
1518
- // don't bother merging posts if there is only one post set
1519
- if ( isset( $post_sets[1] ) ) {
1520
- $min_cycles = max( 1, (int)$settings['num'] );
1521
- for( $i = 0; $i <= $min_cycles; $i++ ) {
1522
- foreach ( $post_sets as $post_set ) {
1523
- if ( isset( $post_set[ $i ] ) && isset( $post_set[ $i ]['id'] ) ) {
1524
- $merged_posts[] = $post_set[ $i ];
1525
- }
1526
- }
1527
- }
1528
- } else {
1529
- $merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
1530
- }
1531
- } elseif ( $settings['sortby'] === 'api' ) {
1532
- if ( isset( $post_sets[0] ) ) {
1533
- foreach ( $post_sets as $post_set ) {
1534
- $merged_posts = array_merge( $merged_posts, $post_set );
1535
- }
1536
- }
1537
- } else {
1538
- // don't bother merging posts if there is only one post set
1539
- if ( isset( $post_sets[1] ) ) {
1540
- foreach ( $post_sets as $post_set ) {
1541
- if ( isset( $post_set[0]['id'] ) ) {
1542
- $merged_posts = array_merge( $merged_posts, $post_set );
1543
- }
1544
- }
1545
- } else {
1546
- $merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
1547
- }
1548
- }
1549
-
1550
-
1551
- return $merged_posts;
1552
- }
1553
-
1554
- /**
1555
- * Sorts a post set based on sorting settings. Sorting by "alternate"
1556
- * is done when merging posts for efficiency's sake so the post set is
1557
- * just returned as it is.
1558
- *
1559
- * @param array $post_set
1560
- * @param array $settings
1561
- *
1562
- * @return mixed|array
1563
- *
1564
- * @since 1.0
1565
- */
1566
- protected function sort_posts( $post_set, $settings ) {
1567
- if ( empty( $post_set ) ) {
1568
- return $post_set;
1569
- }
1570
-
1571
- // sorting done with "merge_posts" to be more efficient
1572
- if ( $settings['sortby'] === 'alternate' || $settings['sortby'] === 'api' ) {
1573
- $return_post_set = $post_set;
1574
- } elseif ( $settings['sortby'] === 'random' ) {
1575
- /*
1576
- * randomly selects posts in a random order. Cache saves posts
1577
- * in this random order so paginating does not cause some posts to show up
1578
- * twice or not at all
1579
- */
1580
- usort($post_set, 'sby_rand_sort' );
1581
- $return_post_set = $post_set;
1582
-
1583
- } else {
1584
- // compares posted on dates of posts
1585
- usort($post_set, 'sby_date_sort' );
1586
- $return_post_set = $post_set;
1587
- }
1588
-
1589
- /**
1590
- * Apply a custom sorting of posts
1591
- *
1592
- * @param array $return_post_set Ordered set of filtered posts
1593
- * @param array $settings Settings for this feed
1594
- *
1595
- * @since 1.0
1596
- */
1597
-
1598
- return apply_filters( 'sby_sorted_posts', $return_post_set, $settings );
1599
- }
1600
-
1601
- /**
1602
- * Can trigger a second attempt at getting posts from the API
1603
- *
1604
- * Overwritten in the Pro version
1605
- *
1606
- * @param string $type
1607
- * @param array $connected_account_with_error
1608
- * @param int $attempts
1609
- *
1610
- * @return bool
1611
- *
1612
- * @since 1.0
1613
- */
1614
- protected function can_try_another_request( $type, $connected_account_with_error, $attempts = 0 ) {
1615
- return false;
1616
- }
1617
-
1618
- /**
1619
- * returns a second connected account if it exists
1620
- *
1621
- * Overwritten in the Pro version
1622
- *
1623
- * @param string $type
1624
- * @param array $attempted_connected_accounts
1625
- *
1626
- * @return bool
1627
- *
1628
- * @since 1.0
1629
- */
1630
- protected function get_different_connected_account( $type, $attempted_connected_accounts ) {
1631
- return false;
1632
- }
1633
-
 
 
 
 
 
 
1634
  }
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
+ }
6
+
7
+ class SBY_Feed
8
+ {
9
+ /**
10
+ * @var string
11
+ */
12
+ protected $regular_feed_transient_name;
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ private $header_transient_name;
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ private $backup_feed_transient_name;
23
+
24
+ /**
25
+ * @var string
26
+ */
27
+ private $backup_header_transient_name;
28
+
29
+ protected $channels_data;
30
+
31
+ /**
32
+ * @var array
33
+ */
34
+ private $post_data;
35
+
36
+ /**
37
+ * @var
38
+ */
39
+ private $header_data;
40
+
41
+ /**
42
+ * @var array
43
+ */
44
+ protected $next_pages;
45
+
46
+ /**
47
+ * @var array
48
+ */
49
+ private $transient_atts;
50
+
51
+ /**
52
+ * @var int
53
+ */
54
+ private $last_retrieve;
55
+
56
+ /**
57
+ * @var bool
58
+ */
59
+ private $should_paginate;
60
+
61
+ /**
62
+ * @var int
63
+ */
64
+ private $num_api_calls;
65
+
66
+ /**
67
+ * @var int
68
+ */
69
+ private $max_api_calls;
70
+
71
+ /**
72
+ * @var array
73
+ */
74
+ protected $image_ids_post_set;
75
+
76
+ /**
77
+ * @var array
78
+ */
79
+ public $post_ids_with_no_details;
80
+
81
+ /**
82
+ * @var bool
83
+ */
84
+ private $should_use_backup;
85
+
86
+ /**
87
+ * @var array
88
+ */
89
+ private $report;
90
+
91
+ private $successful_video_api_request_made;
92
+
93
+ private $do_page_cache_all;
94
+
95
+ /**
96
+ * SBY_Feed constructor.
97
+ *
98
+ * @param string $transient_name ID of this feed
99
+ * generated in the SBY_Settings class
100
+ */
101
+ public function __construct( $transient_name ) {
102
+ $this->regular_feed_transient_name = $transient_name;
103
+ $this->backup_feed_transient_name = SBY_BACKUP_PREFIX . $transient_name;
104
+
105
+ $sby_header_transient_name = str_replace( 'sby_', 'sby_header_', $transient_name );
106
+ $sby_header_transient_name = substr($sby_header_transient_name, 0, 44);
107
+ $this->header_transient_name = $sby_header_transient_name;
108
+ $this->backup_header_transient_name = SBY_BACKUP_PREFIX . $sby_header_transient_name;
109
+
110
+ $this->channels_data = array();
111
+
112
+ $this->post_data = array();
113
+ $this->next_pages = array();
114
+ $this->should_paginate = true;
115
+
116
+ // this is a count of how many api calls have been made for each feed
117
+ // type and term.
118
+ // By default the limit is 10
119
+ $this->num_api_calls = 0;
120
+ $this->max_api_calls = apply_filters( 'sby_max_concurrent_api_calls', 10 );
121
+ $this->should_use_backup = false;
122
+
123
+ // used for errors and the sby_debug report
124
+ $this->report = array();
125
+ $this->successful_video_api_request_made = false;
126
+ $this->post_ids_with_no_details = array();
127
+ $this->do_page_cache_all = false;
128
+ }
129
+
130
+ /**
131
+ * @return array
132
+ *
133
+ * @since 1.0
134
+ */
135
+ public function get_post_data() {
136
+ return $this->post_data;
137
+ }
138
+
139
+ /**
140
+ * @return array
141
+ *
142
+ * @since 1.0
143
+ */
144
+ public function set_post_data( $post_data ) {
145
+ $this->post_data = $post_data;
146
+ }
147
+
148
+ public function get_misc_data( $feed_id, $posts ) {
149
+ return array();
150
+ }
151
+
152
+ /**
153
+ * @return array
154
+ *
155
+ * @since 1.0
156
+ */
157
+ public function get_next_pages() {
158
+ return $this->next_pages;
159
+ }
160
+
161
+ /**
162
+ * Checks the database option related the transient expiration
163
+ * to ensure it will be available when the page loads
164
+ *
165
+ * @return bool
166
+ *
167
+ * @since 2.0/4.0
168
+ */
169
+ public function regular_cache_exists() {
170
+ //Check whether the cache transient exists in the database and is available for more than one more minute
171
+ $transient_exists = get_transient( $this->regular_feed_transient_name );
172
+
173
+ return $transient_exists;
174
+ }
175
+
176
+ /**
177
+ * Checks the database option related the header transient
178
+ * expiration to ensure it will be available when the page loads
179
+ *
180
+ * @return bool
181
+ *
182
+ * @since 1.0
183
+ */
184
+ public function regular_header_cache_exists() {
185
+ $header_transient = get_transient( $this->header_transient_name );
186
+
187
+ return $header_transient;
188
+ }
189
+
190
+ public function get_channel_cache( $channel, $force_get_cache = false ) {
191
+ if ( $this->is_pageable() && ! $force_get_cache ) {
192
+ return false;
193
+ }
194
+
195
+ $maybe_cache = get_option( SBY_CHANNEL_CACHE_PREFIX . $channel );
196
+ if ( $maybe_cache !== false ) {
197
+ $maybe_cache = json_decode( $maybe_cache, true );
198
+ }
199
+
200
+ return $maybe_cache;
201
+ }
202
+
203
+ public function set_channel_cache( $channel, $cache ) {
204
+ if ( is_array( $cache ) ) {
205
+ $cache = wp_json_encode( $cache );
206
+ }
207
+
208
+ update_option( SBY_CHANNEL_CACHE_PREFIX . $channel, $cache, false );
209
+ }
210
+
211
+ /**
212
+ * @return bool
213
+ *
214
+ * @since 1.0
215
+ */
216
+ public function should_use_backup() {
217
+ return $this->should_use_backup || empty( $this->post_data );
218
+ }
219
+
220
+ /**
221
+ * The header is only displayed when the setting is enabled and
222
+ * an account has been connected
223
+ *
224
+ * Overwritten in the Pro version
225
+ *
226
+ * @param array $settings settings specific to this feed
227
+ * @param array $feed_types_and_terms organized settings related to feed data
228
+ * (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
229
+ *
230
+ * @return bool
231
+ *
232
+ * @since 1.0
233
+ */
234
+ public function need_header( $settings, $feed_types_and_terms ) {
235
+ $showheader = ($settings['showheader'] === 'on' || $settings['showheader'] === 'true' || $settings['showheader'] === true);
236
+ return ($showheader && isset( $feed_types_and_terms['channels'] ));
237
+ }
238
+
239
+ /**
240
+ * Use the transient name to retrieve cached data for header
241
+ *
242
+ * @since 1.0
243
+ */
244
+ public function set_header_data_from_cache() {
245
+ $header_cache = get_transient( $this->header_transient_name );
246
+
247
+ $header_cache = json_decode( $header_cache, true );
248
+
249
+ if ( ! empty( $header_cache ) ) {
250
+ $this->header_data = $header_cache;
251
+ }
252
+ }
253
+
254
+ public function set_header_data( $header_data ) {
255
+ $this->header_data = $header_data;
256
+ }
257
+
258
+ /**
259
+ * @since 1.0
260
+ */
261
+ public function get_header_data() {
262
+ return $this->header_data;
263
+ }
264
+
265
+ /**
266
+ * Sets the post data, pagination data, shortcode atts used (cron cache),
267
+ * and timestamp of last retrieval from transient (cron cache)
268
+ *
269
+ * @param array $atts available for cron caching
270
+ *
271
+ * @since 1.0
272
+ */
273
+ public function set_post_data_from_cache( $atts = array() ) {
274
+ $transient_data = get_transient( $this->regular_feed_transient_name );
275
+
276
+ $transient_data = json_decode( $transient_data, true );
277
+
278
+ if ( $transient_data ) {
279
+ $post_data = isset( $transient_data['data'] ) ? $transient_data['data'] : array();
280
+ $this->post_data = $post_data;
281
+ $this->next_pages = isset( $transient_data['pagination'] ) ? $transient_data['pagination'] : array();
282
+
283
+ if ( isset( $transient_data['atts'] ) ) {
284
+ $this->transient_atts = $transient_data['atts'];
285
+ $this->last_retrieve = $transient_data['last_retrieve'];
286
+ }
287
+ }
288
+ }
289
+
290
+ /**
291
+ * Sets post data from a permanent database backup of feed
292
+ * if it was created
293
+ *
294
+ * @since 1.0
295
+ */
296
+ public function maybe_set_post_data_from_backup() {
297
+ $args = array(
298
+ 'post_type' => SBY_CPT,
299
+ 'post_status' => array( 'publish', 'pending', 'draft' ),
300
+ 'orderby' => 'date',
301
+ 'order' => 'DESC',
302
+ 'posts_per_page' => 50,
303
+ 'meta_query' => array(
304
+ array(
305
+ 'value' => sby_strip_after_hash( $this->regular_feed_transient_name ),
306
+ 'key' => 'sby_feed_id'
307
+ )
308
+ )
309
+ );
310
+ $feed_videos = new WP_Query( $args );
311
+
312
+ if ( $feed_videos->have_posts() ) {
313
+ $posts = array();
314
+ while ( $feed_videos->have_posts() ) {
315
+ $feed_videos->the_post();
316
+ $json = get_post_meta( get_the_ID(), 'sby_json', true );
317
+
318
+ if ( $json ) {
319
+ $posts[] = json_decode( $json, true );
320
+ }
321
+ }
322
+
323
+ wp_reset_postdata();
324
+
325
+ $this->post_data = $posts;
326
+ return true;
327
+ } else {
328
+ $this->add_report( 'no backup post data found' );
329
+ wp_reset_postdata();
330
+
331
+ return false;
332
+ }
333
+ }
334
+
335
+ /**
336
+ * Sets header data from a permanent database backup of feed
337
+ * if it was created
338
+ *
339
+ * @since 1.0
340
+ */
341
+ public function maybe_set_header_data_from_backup() {
342
+ $backup_header_data = get_option( $this->backup_header_transient_name, false );
343
+
344
+ if ( ! empty( $backup_header_data ) ) {
345
+ $backup_header_data = json_decode( $backup_header_data, true );
346
+ $this->header_data = $backup_header_data;
347
+
348
+ return true;
349
+ } else {
350
+ $this->add_report( 'no backup header data found' );
351
+
352
+ return false;
353
+ }
354
+ }
355
+
356
+ /**
357
+ * Returns recorded image IDs for this post set
358
+ * for use with image resizing
359
+ *
360
+ * @return array
361
+ *
362
+ * @since 1.0
363
+ */
364
+ public function get_image_ids_post_set() {
365
+ return $this->image_ids_post_set;
366
+ }
367
+
368
+ /**
369
+ * Cron caching needs additional data saved in the transient
370
+ * to work properly. This function checks to make sure it's present
371
+ *
372
+ * @return bool
373
+ *
374
+ * @since 1.0
375
+ */
376
+ public function need_to_start_cron_job() {
377
+ return (( ! empty( $this->post_data ) && ! isset( $this->transient_atts )) || empty( $this->post_data ));
378
+ }
379
+
380
+ /**
381
+ * Checks to see if there are enough posts available to create
382
+ * the current page of the feed
383
+ *
384
+ * @param int $num
385
+ * @param int $offset
386
+ *
387
+ * @return bool
388
+ *
389
+ * @since 1.0
390
+ */
391
+ public function need_posts( $num, $offset = 0 ) {
392
+ $num_existing_posts = is_array( $this->post_data ) ? count( $this->post_data ) : 0;
393
+ $num_needed_for_page = (int)$num + (int)$offset;
394
+
395
+ ($num_existing_posts < $num_needed_for_page) ? $this->add_report( 'need more posts' ) : $this->add_report( 'have enough posts' );
396
+
397
+ return ($num_existing_posts < $num_needed_for_page);
398
+ }
399
+
400
+ /**
401
+ * Checks to see if there are additional pages available for any of the
402
+ * accounts in the feed and that the max conccurrent api request limit
403
+ * has not been reached
404
+ *
405
+ * @return bool
406
+ *
407
+ * @since 1.0
408
+ */
409
+ public function can_get_more_posts() {
410
+ $one_type_and_term_has_more_ages = $this->next_pages !== false;
411
+ $max_concurrent_api_calls_not_met = $this->num_api_calls < $this->max_api_calls;
412
+ $max_concurrent_api_calls_not_met ? $this->add_report( 'max conccurrent requests not met' ) : $this->add_report( 'max concurrent met' );
413
+ $one_type_and_term_has_more_ages ? $this->add_report( 'more pages available' ) : $this->add_report( 'no next page' );
414
+
415
+ return ($one_type_and_term_has_more_ages && $max_concurrent_api_calls_not_met);
416
+ }
417
+
418
+ public function get_play_list_for_term( $type, $term, $connected_account_for_term, $params ) {
419
+
420
+ if ( $type === 'search' || $type === 'live' ) {
421
+ return false;
422
+ }
423
+ $existing_channel_cache = $this->get_channel_cache( $term );
424
+
425
+ if ( $existing_channel_cache ) {
426
+ $this->channels_data[ $term ] = $existing_channel_cache;
427
+ }
428
+
429
+ if ( empty( $this->channels_data[ $term ] ) ) {
430
+ if ( $connected_account_for_term['expires'] < time() + 5 ) {
431
+ $error_message = '<p><b>' . __( 'Reconnect to YouTube to show this feed.', 'custom-facebook-feed' ) . '</b></p>';
432
+ $error_message .= '<p>' . __( 'To create a new feed, first connect to YouTube using the "Connect to YouTube to Create a Feed" button on the settings page and connect any account.', SBY_TEXT_DOMAIN ) . '</p>';
433
+
434
+ if ( current_user_can( 'manage_youtube_feed_options' ) ) {
435
+ $error_message .= '<a href="' . admin_url( 'admin.php?page=youtube-feed' ) . '" target="blank" rel="noopener nofollow">' . __( 'Reconnect in the YouTube Feed Settings Area' ) . '</a>';
436
+ }
437
+ global $sby_posts_manager;
438
+
439
+ $sby_posts_manager->add_frontend_error( 'accesstoken', $error_message );
440
+ $sby_posts_manager->add_error( 'accesstoken', array( 'Trying to connect a new account', $error_message ) );
441
+
442
+ return false;
443
+ }
444
+ $channel_data = array();
445
+ $api_connect_channels = $this->make_api_connection( $connected_account_for_term, 'channels', $params );
446
+
447
+ $this->add_report( 'channel api call made for ' . $term . ' - ' . $type );
448
+
449
+ $api_connect_channels->connect();
450
+ if ( ! $api_connect_channels->is_wp_error() && ! $api_connect_channels->is_youtube_error() ) {
451
+ $channel_data = $api_connect_channels->get_data();
452
+ $channel_id = SBY_Parse::get_channel_id( $channel_data );
453
+ $this->set_channel_cache( $channel_id, $channel_data );
454
+
455
+ if ( isset( $params['channel_name'] ) ) {
456
+ sby_set_channel_id_from_channel_name( $params['channel_name'], $channel_id );
457
+ $this->set_channel_cache( $params['channel_name'], $channel_data );
458
+ }
459
+
460
+ $params = array( 'channel_id' => $channel_id );
461
+ $this->channels_data[ $channel_id ] = $channel_data;
462
+ $this->channels_data[ $term ] = $channel_data;
463
+ } else {
464
+ if ( ! $api_connect_channels->is_wp_error() ) {
465
+ $return = SBY_API_Connect::handle_youtube_error( $api_connect_channels->get_data(), $connected_account_for_term );
466
+ if ( $return && isset( $return['access_token'] ) ) {
467
+ $connected_account_for_term['access_token'] = $return['access_token'];
468
+ $connected_accounts_for_feed[ $term ]['access_token'] = $return['access_token'];
469
+ $connected_account_for_term['expires'] = $return['expires_in'] + time();
470
+ $connected_accounts_for_feed[ $term ]['expires'] = $return['expires_in'] + time();
471
+
472
+ sby_update_or_connect_account( $connected_account_for_term );
473
+ $this->add_report( 'refreshing access token for ' . $connected_account_for_term['channel_id'] );
474
+
475
+ $sby_api_connect_channel = $this->make_api_connection( $connected_account_for_term, 'channels', $params );
476
+ $sby_api_connect_channel->connect();
477
+ if ( ! $sby_api_connect_channel->is_youtube_error() ) {
478
+ $channel_data = $sby_api_connect_channel->get_data();
479
+ $channel_id = SBY_Parse::get_channel_id( $channel_data );
480
+ $this->set_channel_cache( $channel_id, $channel_data );
481
+
482
+ if ( isset( $params['channel_name'] ) ) {
483
+ sby_set_channel_id_from_channel_name( $params['channel_name'], $channel_id );
484
+ $this->set_channel_cache( $params['channel_name'], $channel_data );
485
+ }
486
+
487
+ $this->channels_data[ $channel_id ] = $channel_data;
488
+ $this->channels_data[ $term ] = $channel_data;
489
+
490
+ }
491
+ } else {
492
+ $this->add_report( 'error connecting to channel' );
493
+ }
494
+ } else {
495
+ $api_connect_channels->handle_wp_remote_get_error( $api_connect_channels->get_data() );
496
+ }
497
+ }
498
+ }
499
+
500
+ $playlist = isset( $this->channels_data[ $term ]['items'][0]['contentDetails']['relatedPlaylists']['uploads'] ) ? $this->channels_data[ $term ]['items'][0]['contentDetails']['relatedPlaylists']['uploads'] : false;
501
+
502
+ return $playlist;
503
+ }
504
+
505
+ public function maybe_refresh_token( $term, $connected_account_for_term ) {
506
+ return $connected_account_for_term;
507
+ }
508
+
509
+ public function is_efficient_type( $type ) {
510
+ return true;
511
+ }
512
+
513
+ public function requires_workaround_connection( $type ) {
514
+ return false;
515
+ }
516
+
517
+ public function make_workaround_connection( $connected_account_for_term, $type, $params ) {
518
+ return $this->make_api_connection( $connected_account_for_term, $type, $params );
519
+ }
520
+
521
+
522
+ /**
523
+ * Appends one filtered API request worth of posts for each feed term
524
+ *
525
+ * @param $settings
526
+ * @param array $feed_types_and_terms organized settings related to feed data
527
+ * (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
528
+ * @param array $connected_accounts_for_feed connected account data for the
529
+ * feed types and terms
530
+ *
531
+ * @since 1.0
532
+ */
533
+
534
+ public function add_remote_posts( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
535
+ $new_post_sets = array();
536
+ $next_pages = $this->next_pages;
537
+ global $sby_posts_manager;
538
+ $api_requests_delayed = $sby_posts_manager->are_current_api_request_delays();
539
+
540
+ /**
541
+ * Number of posts to retrieve in each API call
542
+ *
543
+ * @param int Minimum number of posts needed in each API request
544
+ * @param array $settings Settings for this feed
545
+ *
546
+ * @since 1.0
547
+ */
548
+ $num = apply_filters( 'sby_num_in_request', (int)$settings['minnum'], $settings );
549
+
550
+ $params = array(
551
+ 'num' => $num
552
+ );
553
+
554
+ $one_successful_connection = false;
555
+ $next_page_found = false;
556
+ $one_api_request_delayed = false;
557
+
558
+
559
+
560
+ foreach ( $feed_types_and_terms as $type => $terms ) {
561
+ if ( is_array( $terms ) && count( $terms ) > 5 ) {
562
+ shuffle( $terms );
563
+ }
564
+ foreach ( $terms as $term_and_params ) {
565
+
566
+ $term = $term_and_params['term'];
567
+ $params = array_merge( $params, $term_and_params['params'] );
568
+
569
+ $connected_accounts_for_feed[ $term ] = $this->maybe_refresh_token( $term, $connected_accounts_for_feed[ $term ] );
570
+ $connected_account_for_term = $connected_accounts_for_feed[ $term ];
571
+
572
+ $play_list = $this->get_play_list_for_term( $type, $term, $connected_account_for_term, $params );
573
+
574
+ if ( ! empty( $next_pages[ $term . '_' . $type ] ) ) {
575
+ $params['nextPageToken'] = $next_pages[ $term . '_' . $type ];
576
+ }
577
+
578
+ if ( $this->is_pageable() ) {
579
+ $this->add_remote_pageable_posts( $settings, $feed_types_and_terms, $connected_accounts_for_feed );
580
+ } else {
581
+ $this->add_remote_non_pageable( $settings, $feed_types_and_terms, $connected_accounts_for_feed );
582
+ }
583
+
584
+ if ( ! $this->is_efficient_type( $type ) && $this->is_pageable() ) {
585
+
586
+ if ( $this->requires_workaround_connection( $type ) ) {
587
+ $api_connect_playlist_items = $this->make_workaround_connection( $connected_account_for_term, $type, $params );
588
+ $this->add_report( 'Workaround API call made for ' . $term );
589
+
590
+ } else {
591
+ if ( $play_list ) {
592
+ $params['playlist_id'] = $play_list;
593
+ $api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, 'playlistItems', $params );
594
+ } else {
595
+ $api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, $type, $params );
596
+ }
597
+
598
+ $api_connect_playlist_items->connect();
599
+ $this->add_report( 'API call made for ' . $term );
600
+ }
601
+
602
+
603
+ if ( ! $api_connect_playlist_items->is_wp_error() && ! $api_connect_playlist_items->is_youtube_error() ) {
604
+ $one_successful_connection = true;
605
+ $data = $api_connect_playlist_items->get_data();
606
+
607
+ if ( isset( $data['items'][0] ) ) {
608
+ $post_set = $this->filter_posts( $data['items'], $settings );
609
+
610
+ $this->successful_video_api_request_made = true;
611
+
612
+ $new_post_sets[] = $post_set;
613
+ }
614
+
615
+ $next_page = $api_connect_playlist_items->get_next_page( $params );
616
+ $report = is_array( $next_page ) ? implode( ',', $next_page ) : $next_page;
617
+ $this->add_report( 'Next Page ' . $report );
618
+
619
+
620
+ if ( ! empty( $next_page ) ) {
621
+ $next_pages[ $term . '_' . $type ] = $next_page;
622
+ $next_page_found = true;
623
+ } else {
624
+ $next_pages[ $term . '_' . $type ] = false;
625
+ }
626
+ }
627
+
628
+
629
+ $this->num_api_calls++;
630
+
631
+ } else {
632
+
633
+ if ( ! $this->is_pageable() && (int)self::get_channel_status( $term ) !== 1 ) {
634
+ self::update_channel_status( $term, 1 );
635
+ $this->do_page_cache_all = true;
636
+ $play_list = $this->get_play_list_for_term( $type, $term, $connected_account_for_term, $params );
637
+
638
+ $channel_id = isset( $this->channels_data[ $term ] ) ? SBY_Parse::get_channel_id( $this->channels_data[ $term ] ) : '';
639
+ $params['channel_id'] = $channel_id;
640
+ $params['num'] = 50;
641
+
642
+ if ( $play_list ) {
643
+
644
+ $params['playlist_id'] = $play_list;
645
+ if ( ! empty( $next_pages[ $term . '_' . $type ] ) && $next_pages[ $term . '_' . $type ] !== 'rss' ) {
646
+ $params['nextPageToken'] = $next_pages[ $term . '_' . $type ];
647
+ }
648
+
649
+ self::update_channel_status( $term, 1 );
650
+ $this->do_page_cache_all = true;
651
+ $this->add_report( 'using API request to get first 50 videos' );
652
+
653
+ $api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, 'playlistItems', $params );
654
+
655
+ $api_connect_playlist_items->connect();
656
+
657
+ if ( ! $api_connect_playlist_items->is_wp_error() && ! $api_connect_playlist_items->is_youtube_error() ) {
658
+ $one_successful_connection = true;
659
+ $data = $api_connect_playlist_items->get_data();
660
+
661
+ if ( isset( $data['items'][0] ) ) {
662
+ $post_set = $this->filter_posts( $data['items'], $settings );
663
+
664
+ $this->successful_video_api_request_made = true;
665
+
666
+ $new_post_sets[] = $post_set;
667
+ }
668
+
669
+ $next_pages[ $term . '_' . $type ] = false;
670
+ }
671
+ } else {
672
+ $this->add_report( 'no first playlist' );
673
+ }
674
+
675
+ } elseif ( ! $this->is_pageable()
676
+ && isset( $params['channel_id'] )
677
+ && (! isset( $next_pages[ $term . '_' . $type ] ) || $next_pages[ $term . '_' . $type ] !== 'rss') ) {
678
+
679
+ $rss_connect_playlist_items = new SBY_RSS_Connect( 'playlistItems', $params );
680
+ $this->add_report( 'RSS call made for ' . $term );
681
+
682
+ $rss_connect_playlist_items->connect();
683
+
684
+ $one_successful_connection = true;
685
+
686
+ $data = $rss_connect_playlist_items->get_data();
687
+
688
+ if ( isset( $data[0] ) ) {
689
+ $data = array(
690
+ 'items' => $data
691
+ );
692
+ $post_set = $this->filter_posts( $data['items'], $settings );
693
+
694
+ $this->successful_video_api_request_made = true;
695
+
696
+ if ( count( $post_set ) > 14 ) {
697
+ if ( (int)self::get_channel_status( $term ) !== 1 ) {
698
+ $next_pages[ $term . '_' . $type ] = 'rss';
699
+ $next_page_found = true;
700
+ } else {
701
+ $this->add_report( 'RSS update only for ' . $term );
702
+ $post_set = $this->merge_cached_posts( $post_set, $term );
703
+ $next_pages[ $term . '_' . $type ] = false;
704
+ }
705
+ } else {
706
+ $next_pages[ $term . '_' . $type ] = false;
707
+ }
708
+
709
+ $new_post_sets[] = $post_set;
710
+
711
+ }
712
+ } elseif ( isset( $connected_account_for_term['rss_only'] ) ) {
713
+ $rss_connect_playlist_items = new SBY_RSS_Connect( 'playlistItems', $params );
714
+ $this->add_report( 'RSS Only call made for ' . $term );
715
+
716
+ $rss_connect_playlist_items->connect();
717
+
718
+ $one_successful_connection = true;
719
+
720
+ $data = $rss_connect_playlist_items->get_data();
721
+ $next_pages[ $term . '_' . $type ] = false;
722
+
723
+ if ( isset( $data[0] ) ) {
724
+ $data = array(
725
+ 'items' => $data
726
+ );
727
+ $post_set = $this->filter_posts( $data['items'], $settings );
728
+
729
+ $this->successful_video_api_request_made = true;
730
+ $new_post_sets[] = $post_set;
731
+ }
732
+ } else {
733
+
734
+ if ( ! $api_requests_delayed
735
+ && (! isset( $next_pages[ $term . '_' . $type ] ) || $next_pages[ $term . '_' . $type ] !== false) ) {
736
+
737
+ $play_list = $this->get_play_list_for_term( $type, $term, $connected_account_for_term, $params );
738
+
739
+ $channel_id = isset( $this->channels_data[ $term ] ) ? SBY_Parse::get_channel_id( $this->channels_data[ $term ] ) : '';
740
+ $params['channel_id'] = $channel_id;
741
+
742
+ if ( $play_list ) {
743
+
744
+ $params['playlist_id'] = $play_list;
745
+ if ( ! empty( $next_pages[ $term . '_' . $type ] ) && $next_pages[ $term . '_' . $type ] !== 'rss' ) {
746
+ $params['nextPageToken'] = $next_pages[ $term . '_' . $type ];
747
+ }
748
+
749
+ if ( isset( $next_pages[ $term . '_' . $type ] ) && $next_pages[ $term . '_' . $type ] === 'rss' ) {
750
+ self::update_channel_status( $term, 1 );
751
+ $this->do_page_cache_all = true;
752
+ $this->add_report( 'using API request to get first 50 videos' );
753
+ } else {
754
+ $this->add_report( 'using API request to get more videos' );
755
+ }
756
+
757
+ $api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, 'playlistItems', $params );
758
+
759
+ $api_connect_playlist_items->connect();
760
+
761
+ if ( ! $api_connect_playlist_items->is_wp_error() && ! $api_connect_playlist_items->is_youtube_error() ) {
762
+ $one_successful_connection = true;
763
+ $data = $api_connect_playlist_items->get_data();
764
+
765
+ if ( isset( $data['items'][0] ) ) {
766
+ $post_set = $this->filter_posts( $data['items'], $settings );
767
+
768
+ $this->successful_video_api_request_made = true;
769
+
770
+ $new_post_sets[] = $post_set;
771
+ }
772
+
773
+ $next_page = $this->is_pageable() ? $api_connect_playlist_items->get_next_page() : false;
774
+ if ( ! empty( $next_page ) ) {
775
+ $next_pages[ $term . '_' . $type ] = $next_page;
776
+ $next_page_found = true;
777
+ } else {
778
+ $next_pages[ $term . '_' . $type ] = false;
779
+ }
780
+ }
781
+ } else {
782
+ $this->add_report( 'no first playlist' );
783
+ }
784
+
785
+ if ( ! $this->is_pageable()
786
+ && empty( $next_pages[ $term . '_' . $type ] )
787
+ && ! empty( $params['channel_id'] ) ) {
788
+ $this->add_report( 'using RSS to get first 15' );
789
+
790
+ $rss_connect_playlist_items = new SBY_RSS_Connect( 'playlistItems', $params );
791
+
792
+ $rss_connect_playlist_items->connect();
793
+
794
+ $one_successful_connection = true;
795
+
796
+ $data = $rss_connect_playlist_items->get_data();
797
+
798
+ if ( isset( $data[0] ) ) {
799
+ $data = array(
800
+ 'items' => $data
801
+ );
802
+ $post_set = $this->filter_posts( $data['items'], $settings );
803
+
804
+ $this->successful_video_api_request_made = true;
805
+
806
+
807
+ if ( count( $post_set ) > 14 ) {
808
+ if ( (int)self::get_channel_status( $term ) !== 1 ) {
809
+ $next_pages[ $term . '_' . $type ] = 'rss';
810
+ $next_page_found = true;
811
+ } else {
812
+ $this->add_report( 'RSS Only' . $term );
813
+ $post_set = $this->merge_cached_posts( $post_set, $term );
814
+ $next_pages[ $term . '_' . $type ] = false;
815
+ }
816
+ } else {
817
+ $next_pages[ $term . '_' . $type ] = false;
818
+ }
819
+
820
+ $new_post_sets[] = $post_set;
821
+
822
+ }
823
+ } else {
824
+ $this->num_api_calls++;
825
+ }
826
+
827
+ }
828
+ }
829
+ }
830
+
831
+ }
832
+
833
+ }
834
+
835
+ if ( ! $one_successful_connection || ($one_api_request_delayed && empty( $new_post_sets )) ) {
836
+ $this->should_use_backup = true;
837
+ }
838
+ $posts = $this->merge_posts( $new_post_sets, $settings );
839
+
840
+ $posts = $this->sort_posts( $posts, $settings );
841
+
842
+ if ( ! empty( $this->post_data ) && is_array( $this->post_data ) ) {
843
+ $posts = array_merge( $this->post_data, $posts );
844
+ }
845
+
846
+ $this->post_data = $posts;
847
+
848
+ if ( isset( $next_page_found ) && $next_page_found ) {
849
+ $this->next_pages = $next_pages;
850
+ } else {
851
+ $this->next_pages = false;
852
+ }
853
+ }
854
+
855
+ public function add_remote_pageable_posts() {
856
+
857
+ }
858
+
859
+ public function add_remote_non_pageable() {
860
+
861
+ }
862
+
863
+ private function is_pageable() {
864
+ global $sby_settings;
865
+
866
+ return ! empty( $sby_settings['api_key'] );
867
+ }
868
+
869
+ public function merge_cached_posts( $current_posts, $channel_id ) {
870
+ $args = array(
871
+ 'post_type' => SBY_CPT,
872
+ 'post_status' => array( 'publish', 'pending', 'draft' ),
873
+ 'orderby' => 'date',
874
+ 'order' => 'DESC',
875
+ 'posts_per_page' => 80,
876
+ 'meta_query' => array(
877
+ array(
878
+ 'value' => $channel_id,
879
+ 'key' => 'sby_channel_id'
880
+ )
881
+ )
882
+ );
883
+ $feed_videos = new WP_Query( $args );
884
+
885
+ if ( $feed_videos->have_posts() ) {
886
+ $posts = array();
887
+ while ( $feed_videos->have_posts() ) {
888
+ $feed_videos->the_post();
889
+ $json = get_post_meta( get_the_ID(), 'sby_json', true );
890
+ if ( $json ) {
891
+ $posts[] = json_decode( $json, true );
892
+ }
893
+ }
894
+
895
+ wp_reset_postdata();
896
+ $this->add_report( 'merging cached posts' );
897
+
898
+ $posts = array_merge( $current_posts, $posts );
899
+
900
+ return $posts;
901
+ } else {
902
+ $this->add_report( 'no cached posts found' );
903
+ wp_reset_postdata();
904
+
905
+ return $current_posts;
906
+ }
907
+ }
908
+
909
+ /**
910
+ * Connects to the YouTube API and records returned data. Will use channel data if already
911
+ * set by the regular feed
912
+ *
913
+ * @param $settings
914
+ * @param array $feed_types_and_terms organized settings related to feed data
915
+ * (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
916
+ * @param array $connected_accounts_for_feed connected account data for the
917
+ * feed types and terms
918
+ *
919
+ * @since 1.0
920
+ */
921
+ public function set_remote_header_data( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
922
+ $first_user = $this->get_first_user( $feed_types_and_terms, $settings );
923
+ $this->header_data = false;
924
+ $existing_channel_cache = $this->get_channel_cache( $first_user );
925
+
926
+ if ( $existing_channel_cache ) {
927
+ $this->channels_data[ $first_user ] = $existing_channel_cache;
928
+ $this->add_report( 'header data for ' . $first_user . ' exists in cache' );
929
+ }
930
+
931
+ if ( isset( $this->channels_data[ $first_user ] ) && ! $this->is_pageable() ) {
932
+ $this->header_data = $this->channels_data[ $first_user ];
933
+ } elseif ( ! empty( $first_user ) ) {
934
+ $connected_account_for_term = sby_get_first_connected_account();
935
+ if ( $connected_account_for_term['expires'] < time() + 5 ) {
936
+ $error_message = '<p><b>' . __( 'Reconnect to YouTube to show this feed.', 'custom-facebook-feed' ) . '</b></p>';
937
+ $error_message .= '<p>' . __( 'To create a new feed, first connect to YouTube using the "Connect to YouTube to Create a Feed" button on the settings page and connect any account.', SBY_TEXT_DOMAIN ) . '</p>';
938
+
939
+ if ( current_user_can( 'manage_youtube_feed_options' ) ) {
940
+ $error_message .= '<a href="' . admin_url( 'admin.php?page=youtube-feed' ) . '" target="blank" rel="noopener nofollow">' . __( 'Reconnect in the YouTube Feed Settings Area' ) . '</a>';
941
+ }
942
+ global $sby_posts_manager;
943
+
944
+ $sby_posts_manager->add_frontend_error( 'accesstoken', $error_message );
945
+ $sby_posts_manager->add_error( 'accesstoken', array( 'Trying to connect a new account', $error_message ) );
946
+ } else {
947
+ $channel_params_type = strpos( $first_user, 'UC' ) !== 0 ? 'channel_name' : 'channel_id';
948
+ $params[ $channel_params_type ] = $first_user;
949
+ $connection = $this->make_api_connection( $connected_account_for_term, 'channels', $params );
950
+
951
+ $connection->connect();
952
+ $this->add_report( 'api call made for header - ' . $first_user );
953
+
954
+ if ( ! $connection->is_wp_error() && ! $connection->is_youtube_error() ) {
955
+ $this->header_data = $connection->get_data();
956
+ $channel_id = SBY_Parse::get_channel_id( $this->header_data );
957
+ $this->set_channel_cache( $channel_id, $this->header_data );
958
+ $this->channels_data[ $channel_id ] = $this->header_data;
959
+ $this->channels_data[ $first_user ] = $this->header_data;
960
+
961
+ if ( isset( $connected_accounts_for_feed[ $first_user ]['local_avatar'] ) && $connected_accounts_for_feed[ $first_user ]['local_avatar'] ) {
962
+ $upload = wp_upload_dir();
963
+ $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBY_UPLOADS_NAME );
964
+
965
+ $full_file_name = $resized_url . $this->header_data['username'] . '.jpg';
966
+ $this->header_data['local_avatar'] = $full_file_name;
967
+ }
968
+ } else {
969
+ if ( $connection->is_wp_error() ) {
970
+ SBY_API_Connect::handle_wp_remote_get_error( $connection->get_wp_error() );
971
+ } else {
972
+ SBY_API_Connect::handle_youtube_error( $connection->get_data(), $connected_accounts_for_feed[ $first_user ], 'header' );
973
+ }
974
+ }
975
+ }
976
+ }
977
+ }
978
+
979
+ /**
980
+ * Stores feed data in a transient for a specified time
981
+ *
982
+ * @param int $cache_time
983
+ *
984
+ * @since 1.0
985
+ */
986
+ public function cache_feed_data( $cache_time ) {
987
+ if ( ! empty( $this->post_data ) || ! empty( $this->next_pages ) ) {
988
+ $this->remove_duplicate_posts();
989
+ $this->trim_posts_to_max();
990
+
991
+ $post_data = $this->post_data;
992
+
993
+ if (! isset( $post_data[0]['iframe'] )) {
994
+ $to_cache = array(
995
+ 'data' => $this->post_data,
996
+ 'pagination' => $this->next_pages
997
+ );
998
+
999
+ set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
1000
+ } else {
1001
+ $this->add_report( 'iframe not caching' );
1002
+ }
1003
+
1004
+
1005
+ } else {
1006
+ $this->add_report( 'no data not caching' );
1007
+ }
1008
+ }
1009
+
1010
+ /**
1011
+ * Stores feed data with additional data specifically for cron caching
1012
+ *
1013
+ * @param array $to_cache feed data with additional things like the shortcode
1014
+ * settings, when the cache was last requested, when new posts were last retrieved
1015
+ * @param int $cache_time how long the cache will last
1016
+ *
1017
+ * @since 1.0
1018
+ */
1019
+ public function set_cron_cache( $to_cache, $cache_time ) {
1020
+ if ( ! empty( $this->post_data )
1021
+ || ! empty( $this->next_pages )
1022
+ || ! empty( $to_cache['data'] ) ) {
1023
+ $this->remove_duplicate_posts();
1024
+ $this->trim_posts_to_max();
1025
+
1026
+ $to_cache['data'] = isset( $to_cache['data'] ) ? $to_cache['data'] : $this->post_data;
1027
+ $to_cache['pagination'] = isset( $to_cache['next_pages'] ) ? $to_cache['next_pages'] : $this->next_pages;
1028
+ $to_cache['atts'] = isset( $to_cache['atts'] ) ? $to_cache['atts'] : $this->transient_atts;
1029
+ $to_cache['last_requested'] = isset( $to_cache['last_requested'] ) ? $to_cache['last_requested'] : time();
1030
+ $to_cache['last_retrieve'] = isset( $to_cache['last_retrieve'] ) ? $to_cache['last_retrieve'] : $this->last_retrieve;
1031
+
1032
+ set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
1033
+ } else {
1034
+ $this->add_report( 'no data not caching' );
1035
+ }
1036
+
1037
+ }
1038
+
1039
+ /**
1040
+ * Stores header data for a specified time as a transient
1041
+ *
1042
+ * @param int $cache_time
1043
+ * @param bool $save_backup
1044
+ *
1045
+ * @since 1.0
1046
+ */
1047
+ public function cache_header_data( $cache_time, $save_backup = true ) {
1048
+ if ( $this->header_data ) {
1049
+ set_transient( $this->header_transient_name, wp_json_encode( $this->header_data ), $cache_time );
1050
+
1051
+ if ( $save_backup ) {
1052
+ update_option( $this->backup_header_transient_name, wp_json_encode( $this->header_data ), false );
1053
+ }
1054
+ }
1055
+ }
1056
+
1057
+ /**
1058
+ * Used to randomly trigger an updating of the last requested data for cron caching
1059
+ *
1060
+ * @return bool
1061
+ *
1062
+ * @since 1.0
1063
+ */
1064
+ public function should_update_last_requested() {
1065
+ return (rand( 1, 20 ) === 20);
1066
+ }
1067
+
1068
+ /**
1069
+ * Determines if pagination can and should be used based on settings and available feed data
1070
+ *
1071
+ * @param array $settings
1072
+ * @param int $offset
1073
+ *
1074
+ * @return bool
1075
+ *
1076
+ * @since 1.0
1077
+ */
1078
+ public function should_use_pagination( $settings, $offset = 0 ) {
1079
+ $posts_available = count( $this->post_data ) - ($offset + $settings['num']);
1080
+ $show_loadmore_button_by_settings = ($settings['showbutton'] == 'on' || $settings['showbutton'] == 'true' || $settings['showbutton'] == true ) && $settings['showbutton'] !== 'false';
1081
+
1082
+ if ( $show_loadmore_button_by_settings ) {
1083
+ // used for permanent and whitelist feeds
1084
+ if ( $this->feed_is_complete( $settings, $offset ) ) {
1085
+ $this->add_report( 'no pagination, feed complete' );
1086
+ return false;
1087
+ }
1088
+ if ( $posts_available > 0 ) {
1089
+ $this->add_report( 'do pagination, posts available' );
1090
+ return true;
1091
+ }
1092
+ $pages = $this->next_pages;
1093
+
1094
+ if ( $pages && ! $this->should_use_backup() ) {
1095
+ foreach ( $pages as $page ) {
1096
+ if ( ! empty( $page ) ) {
1097
+ return true;
1098
+ }
1099
+ }
1100
+ }
1101
+
1102
+ }
1103
+
1104
+
1105
+ $this->add_report( 'no pagination, no posts available' );
1106
+
1107
+ return false;
1108
+ }
1109
+
1110
+ public static function get_channel_status( $channel ) {
1111
+ $channel_setting = get_option( 'sby_channel_status', array() );
1112
+
1113
+ if ( isset( $channel_setting[ $channel ] ) ) {
1114
+ return $channel_setting[ $channel ];
1115
+ }
1116
+
1117
+ return 0;
1118
+ }
1119
+
1120
+ public static function update_channel_status( $channel, $status ) {
1121
+ $channel_setting = get_option( 'sby_channel_status', array() );
1122
+
1123
+ $channel_setting[ $channel ] = $status;
1124
+
1125
+ update_option( 'sby_channel_status', $channel_setting, false );
1126
+ }
1127
+
1128
+ /**
1129
+ * Generates the HTML for the feed if post data is available. Although it seems
1130
+ * some of the variables ar not used they are set here to hide where they
1131
+ * come from when used in the feed templates.
1132
+ *
1133
+ * @param array $settings
1134
+ * @param array $atts
1135
+ * @param array $feed_types_and_terms organized settings related to feed data
1136
+ * (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
1137
+ * @param array $connected_accounts_for_feed connected account data for the
1138
+ * feed types and terms
1139
+ *
1140
+ * @return false|string
1141
+ *
1142
+ * @since 1.0
1143
+ */
1144
+ public function get_the_feed_html( $settings, $atts, $feed_types_and_terms, $connected_accounts_for_feed ) {
1145
+ global $sby_posts_manager;
1146
+
1147
+ if ( empty( $this->post_data ) && ! empty( $connected_accounts_for_feed ) ) {
1148
+ $error = '<p><b>' . __( 'Error: No videos found.', SBY_TEXT_DOMAIN ) . '</b>';
1149
+ $error .= '<p>' . __( 'Make sure this is a valid channel ID and that the channel has videos available on youtube.com.', SBY_TEXT_DOMAIN ) . '</p>';
1150
+
1151
+ $sby_posts_manager->add_frontend_error( 'noposts', $error );
1152
+ }
1153
+
1154
+ $posts = array_slice( $this->post_data, 0, $settings['minnum'] );
1155
+ $header_data = ! empty( $this->header_data ) ? $this->header_data : false;
1156
+
1157
+ $first_username = false;
1158
+ if ( $header_data ) {
1159
+ $first_username = SBY_Parse::get_channel_id( $header_data );
1160
+ } elseif ( isset( $this->post_data[0] ) ) { // in case no connected account for feed
1161
+ $first_username = SBY_Parse::get_channel_id( $this->post_data[0] );
1162
+ }
1163
+
1164
+ $use_pagination = $this->should_use_pagination( $settings, 0 );
1165
+
1166
+ $feed_id = $this->regular_feed_transient_name;
1167
+ $shortcode_atts = ! empty( $atts ) ? wp_json_encode( $atts ) : '{}';
1168
+
1169
+ $settings['header_outside'] = false;
1170
+ $settings['header_inside'] = false;
1171
+ if ( $header_data && $settings['showheader'] ) {
1172
+ $settings['header_inside'] = true;
1173
+ }
1174
+
1175
+ $other_atts = '';
1176
+
1177
+ $classes = array();
1178
+ if ( empty( $settings['widthresp'] ) || $settings['widthresp'] == 'on' || $settings['widthresp'] == 'true' || $settings['widthresp'] === true ) {
1179
+ if ( $settings['widthresp'] !== 'false' ) {
1180
+ $classes[] = 'sby_width_resp';
1181
+ }
1182
+ }
1183
+ if ( ! empty( $settings['class'] ) ) {
1184
+ $classes[] = esc_attr( $settings['class'] );
1185
+ }
1186
+ if ( ! empty( $settings['height'] )
1187
+ && (((int)$settings['height'] < 100 && $settings['heightunit'] === '%') || $settings['heightunit'] === 'px') ) {
1188
+ $classes[] = 'sby_fixed_height';
1189
+ }
1190
+ if ( ! empty( $settings['disablemobile'] )
1191
+ && ($settings['disablemobile'] == 'on' || $settings['disablemobile'] == 'true' || $settings['disablemobile'] == true) ) {
1192
+ if ( $settings['disablemobile'] !== 'false' ) {
1193
+ $classes[] = 'sby_disable_mobile';
1194
+ }
1195
+ }
1196
+
1197
+ $additional_classes = '';
1198
+ if ( ! empty( $classes ) ) {
1199
+ $additional_classes = ' ' . implode( ' ', $classes );
1200
+ }
1201
+
1202
+ $other_atts = $this->add_other_atts( $other_atts, $settings );
1203
+
1204
+ $flags = array();
1205
+
1206
+ if ( $this->successful_video_api_request_made && ! empty( $posts ) ) {
1207
+ if ( $settings['storage_process'] === 'page' ) {
1208
+ $this_posts = $posts;
1209
+ if ( $this->do_page_cache_all ) {
1210
+ $this_posts = $this->post_data;
1211
+ }
1212
+ $this->add_report( 'Adding videos to wp_posts ' . count( $this_posts ) );
1213
+
1214
+ sby_process_post_set_caching( $this_posts, $feed_id );
1215
+ } elseif ( $settings['storage_process'] === 'background' ) {
1216
+ $flags[] = 'checkWPPosts';
1217
+ if ( $this->do_page_cache_all ) {
1218
+ $this->add_report( 'Flagging videos to wp_posts ' . count( $this->post_data ) );
1219
+ $flags[] = 'cacheAll';
1220
+ }
1221
+ }
1222
+ }
1223
+
1224
+ if ( $settings['disable_resize'] ) {
1225
+ $flags[] = 'resizeDisable';
1226
+ } elseif ( $settings['favor_local'] ) {
1227
+ $flags[] = 'favorLocal';
1228
+ }
1229
+
1230
+ if ( $settings['disable_js_image_loading'] ) {
1231
+ $flags[] = 'imageLoadDisable';
1232
+ }
1233
+ if ( $settings['ajax_post_load'] ) {
1234
+ $flags[] = 'ajaxPostLoad';
1235
+ }
1236
+ if ( $settings['playerratio'] === '3:4' ) {
1237
+ $flags[] = 'narrowPlayer';
1238
+ }
1239
+ if ( SBY_GDPR_Integrations::doing_gdpr( $settings ) ) {
1240
+ $flags[] = 'gdpr';
1241
+ }
1242
+ if ( $settings['disablecdn'] ) {
1243
+ $flags[] = 'disablecdn';
1244
+ }
1245
+ if ( isset( $_GET['sby_debug'] ) ) {
1246
+ $flags[] = 'debug';
1247
+ }
1248
+
1249
+ if ( ! empty( $flags ) ) {
1250
+ $other_atts .= ' data-sby-flags="' . implode(',', $flags ) . '"';
1251
+ }
1252
+
1253
+ if ( $settings['layout'] === 'grid' || $settings['layout'] === 'carousel' ) {
1254
+ $other_atts .= ' data-sby-supports-lightbox="1"';
1255
+ }
1256
+ $icon_type = $settings['font_method'];
1257
+
1258
+ ob_start();
1259
+ include sby_get_feed_template_part( 'feed', $settings );
1260
+ $html = ob_get_contents();
1261
+ ob_get_clean();
1262
+
1263
+ if ( $settings['ajaxtheme'] ) {
1264
+ $html .= $this->get_ajax_page_load_html();
1265
+ }
1266
+
1267
+ return $html;
1268
+ }
1269
+
1270
+ /**
1271
+ * Generates HTML for individual sby_item elements
1272
+ *
1273
+ * @param array $settings
1274
+ * @param int $offset
1275
+ * @param array $feed_types_and_terms organized settings related to feed data
1276
+ * (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
1277
+ * @param array $connected_accounts_for_feed connected account data for the
1278
+ * feed types and terms
1279
+ *
1280
+ * @return false|string
1281
+ *
1282
+ * @since 1.0
1283
+ */
1284
+ public function get_the_items_html( $settings, $offset, $feed_types_and_terms = array(), $connected_accounts_for_feed = array() ) {
1285
+ if ( empty( $this->post_data ) ) {
1286
+ ob_start();
1287
+ $html = ob_get_contents();
1288
+ ob_get_clean(); ?>
1289
+ <p><?php _e( 'No posts found.', SBY_TEXT_DOMAIN ); ?></p>
1290
+ <?php
1291
+ $html = ob_get_contents();
1292
+ ob_get_clean();
1293
+ return $html;
1294
+ }
1295
+
1296
+ $posts = array_slice( $this->post_data, $offset, $settings['num'] );
1297
+
1298
+ ob_start();
1299
+
1300
+ $this->posts_loop( $posts, $settings, $offset );
1301
+
1302
+ $html = ob_get_contents();
1303
+ ob_get_clean();
1304
+
1305
+ return $html;
1306
+ }
1307
+
1308
+ /**
1309
+ * Overwritten in the Pro version
1310
+ *
1311
+ * @return object
1312
+ */
1313
+ public function make_api_connection( $connected_account_or_page, $type = NULL, $params = NULL ) {
1314
+ return new SBY_API_Connect( $connected_account_or_page, $type, $params );
1315
+ }
1316
+
1317
+ /**
1318
+ * When the feed is loaded with AJAX, the JavaScript for the plugin
1319
+ * needs to be triggered again. This function is a workaround that adds
1320
+ * the file and settings to the page whenever the feed is generated.
1321
+ *
1322
+ * @return string
1323
+ *
1324
+ * @since 1.0
1325
+ */
1326
+ public static function get_ajax_page_load_html() {
1327
+ global $sby_settings;
1328
+
1329
+ $js_options = array(
1330
+ 'adminAjaxUrl' => admin_url( 'admin-ajax.php' ),
1331
+ 'placeholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder.png',
1332
+ 'placeholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder-narrow.png',
1333
+ 'lightboxPlaceholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder.png',
1334
+ 'lightboxPlaceholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder-narrow.png',
1335
+ 'autoplay' => $sby_settings['playvideo'] === 'automatically',
1336
+ 'semiEagerload' => $sby_settings['eagerload'],
1337
+ 'eagerload' => false
1338
+ );
1339
+
1340
+ $encoded_options = wp_json_encode( $js_options );
1341
+
1342
+ $js_option_html = '<script type="text/javascript">if (typeof sbyOptions === "undefined") var sbyOptions = ' . $encoded_options . ';</script>';
1343
+ $js_option_html .= "<script type='text/javascript' src='" . trailingslashit( SBY_PLUGIN_URL ) . 'js/sb-youtube.min.js?ver=' . SBYVER . "'></script>";
1344
+
1345
+ return $js_option_html;
1346
+ }
1347
+
1348
+ /**
1349
+ * Overwritten in the Pro version
1350
+ *
1351
+ * @param $feed_types_and_terms
1352
+ *
1353
+ * @return string
1354
+ *
1355
+ * @since 2.1/5.2
1356
+ */
1357
+ public function get_first_user( $feed_types_and_terms, $settings = array() ) {
1358
+ if ( isset( $feed_types_and_terms['channels'][0] ) ) {
1359
+ return $feed_types_and_terms['channels'][0]['term'];
1360
+ } else {
1361
+ return '';
1362
+ }
1363
+ }
1364
+
1365
+ public function do_page_cache_all() {
1366
+ return $this->do_page_cache_all;
1367
+ }
1368
+
1369
+ public function successful_video_api_request_made() {
1370
+ return $this->successful_video_api_request_made;
1371
+ }
1372
+
1373
+ /**
1374
+ * Adds recorded strings to an array
1375
+ *
1376
+ * @param $to_add
1377
+ *
1378
+ * @since 1.0
1379
+ */
1380
+ public function add_report( $to_add ) {
1381
+ $this->report[] = $to_add;
1382
+ }
1383
+
1384
+ /**
1385
+ * @return array
1386
+ *
1387
+ * @since 1.0
1388
+ */
1389
+ public function get_report() {
1390
+ return $this->report;
1391
+ }
1392
+
1393
+ /**
1394
+ * Additional options/settings added to the main div
1395
+ * for the feed
1396
+ *
1397
+ * Overwritten in the Pro version
1398
+ *
1399
+ * @param $other_atts
1400
+ * @param $settings
1401
+ *
1402
+ * @return string
1403
+ */
1404
+ protected function add_other_atts( $other_atts, $settings ) {
1405
+ return '';
1406
+ }
1407
+
1408
+ /**
1409
+ * Used for filtering a single API request worth of posts
1410
+ *
1411
+ * Overwritten in the Pro version
1412
+ *
1413
+ * @param array $post_set a single set of post data from the api
1414
+ *
1415
+ * @return mixed|array
1416
+ *
1417
+ * @since 1.0
1418
+ */
1419
+ protected function filter_posts( $post_set, $settings = array() ) {
1420
+ // array_unique( $post_set, SORT_REGULAR);
1421
+
1422
+ return $post_set;
1423
+ }
1424
+
1425
+ protected function remove_duplicate_posts() {
1426
+ $posts = $this->post_data;
1427
+ $ids_in_feed = array();
1428
+ $non_duplicate_posts = array();
1429
+ $removed = array();
1430
+
1431
+ foreach ( $posts as $post ) {
1432
+ $post_id = SBY_Parse::get_video_id( $post );
1433
+ if ( ! in_array( $post_id, $ids_in_feed, true ) ) {
1434
+ $ids_in_feed[] = $post_id;
1435
+ $non_duplicate_posts[] = $post;
1436
+ } else {
1437
+ $removed[] = $post_id;
1438
+ }
1439
+ }
1440
+
1441
+ $this->add_report( 'removed duplicates: ' . implode(', ', $removed ) );
1442
+ $this->set_post_data( $non_duplicate_posts );
1443
+ }
1444
+
1445
+ /**
1446
+ * Used for limiting the cache size
1447
+ *
1448
+ * @since 2.0/5.1.1
1449
+ */
1450
+ protected function trim_posts_to_max() {
1451
+ if ( ! is_array( $this->post_data ) ) {
1452
+ return;
1453
+ }
1454
+
1455
+ $max = apply_filters( 'sby_max_cache_size', 500 );
1456
+ $this->set_post_data( array_slice( $this->post_data , 0, $max ) );
1457
+
1458
+ }
1459
+
1460
+ /**
1461
+ * Used for permanent feeds or white list feeds to
1462
+ * stop pagination if all posts are already added
1463
+ *
1464
+ * Overwritten in the Pro version
1465
+ *
1466
+ * @param array $settings
1467
+ * @param int $offset
1468
+ *
1469
+ * @return bool
1470
+ *
1471
+ * @since 1.0
1472
+ */
1473
+ protected function feed_is_complete( $settings, $offset = 0 ) {
1474
+ return false;
1475
+ }
1476
+
1477
+ /**
1478
+ * Iterates through post data and tracks the index of the current post.
1479
+ * The actual post ids of the posts are stored in an array so the plugin
1480
+ * can search for local images that may be available.
1481
+ *
1482
+ * @param array $posts final filtered post data for the feed
1483
+ * @param array $settings
1484
+ * @param int $offset
1485
+ *
1486
+ * @since 1.0
1487
+ */
1488
+ protected function posts_loop( $posts, $settings, $offset = 0 ) {
1489
+
1490
+ $image_ids = array();
1491
+ $post_index = $offset;
1492
+ if ( ! isset( $settings['feed_id'] ) ) {
1493
+ $settings['feed_id'] = $this->regular_feed_transient_name;
1494
+ }
1495
+ $misc_data = $this->get_misc_data( $settings['feed_id'], $posts );
1496
+ $icon_type = $settings['font_method'];
1497
+
1498
+ foreach ( $posts as $post ) {
1499
+ $image_ids[] = SBY_Parse::get_post_id( $post );
1500
+ include sby_get_feed_template_part( 'item', $settings );
1501
+ $post_index++;
1502
+ }
1503
+
1504
+ $this->image_ids_post_set = $image_ids;
1505
+ }
1506
+
1507
+ /**
1508
+ * Uses array of API request results and merges them based on how
1509
+ * the feed should be sorted. Mixed feeds are always sorted alternating
1510
+ * since there is no post date for hashtag feeds.
1511
+ *
1512
+ * @param array $post_sets an array of single API request worth
1513
+ * of posts
1514
+ * @param array $settings
1515
+ *
1516
+ * @return array
1517
+ *
1518
+ * @since 1.0
1519
+ */
1520
+ private function merge_posts( $post_sets, $settings ) {
1521
+
1522
+ $merged_posts = array();
1523
+ if ( $settings['sortby'] === 'alternate' ) {
1524
+ // don't bother merging posts if there is only one post set
1525
+ if ( isset( $post_sets[1] ) ) {
1526
+ $min_cycles = max( 1, (int)$settings['num'] );
1527
+ for( $i = 0; $i <= $min_cycles; $i++ ) {
1528
+ foreach ( $post_sets as $post_set ) {
1529
+ if ( isset( $post_set[ $i ] ) && isset( $post_set[ $i ]['id'] ) ) {
1530
+ $merged_posts[] = $post_set[ $i ];
1531
+ }
1532
+ }
1533
+ }
1534
+ } else {
1535
+ $merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
1536
+ }
1537
+ } elseif ( $settings['sortby'] === 'api' ) {
1538
+ if ( isset( $post_sets[0] ) ) {
1539
+ foreach ( $post_sets as $post_set ) {
1540
+ $merged_posts = array_merge( $merged_posts, $post_set );
1541
+ }
1542
+ }
1543
+ } else {
1544
+ // don't bother merging posts if there is only one post set
1545
+ if ( isset( $post_sets[1] ) ) {
1546
+ foreach ( $post_sets as $post_set ) {
1547
+ if ( isset( $post_set[0]['id'] ) ) {
1548
+ $merged_posts = array_merge( $merged_posts, $post_set );
1549
+ }
1550
+ }
1551
+ } else {
1552
+ $merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
1553
+ }
1554
+ }
1555
+
1556
+
1557
+ return $merged_posts;
1558
+ }
1559
+
1560
+ /**
1561
+ * Sorts a post set based on sorting settings. Sorting by "alternate"
1562
+ * is done when merging posts for efficiency's sake so the post set is
1563
+ * just returned as it is.
1564
+ *
1565
+ * @param array $post_set
1566
+ * @param array $settings
1567
+ *
1568
+ * @return mixed|array
1569
+ *
1570
+ * @since 1.0
1571
+ */
1572
+ protected function sort_posts( $post_set, $settings ) {
1573
+ if ( empty( $post_set ) ) {
1574
+ return $post_set;
1575
+ }
1576
+
1577
+ // sorting done with "merge_posts" to be more efficient
1578
+ if ( $settings['sortby'] === 'alternate' || $settings['sortby'] === 'api' ) {
1579
+ $return_post_set = $post_set;
1580
+ } elseif ( $settings['sortby'] === 'random' ) {
1581
+ /*
1582
+ * randomly selects posts in a random order. Cache saves posts
1583
+ * in this random order so paginating does not cause some posts to show up
1584
+ * twice or not at all
1585
+ */
1586
+ usort($post_set, 'sby_rand_sort' );
1587
+ $return_post_set = $post_set;
1588
+
1589
+ } else {
1590
+ // compares posted on dates of posts
1591
+ usort($post_set, 'sby_date_sort' );
1592
+ $return_post_set = $post_set;
1593
+ }
1594
+
1595
+ /**
1596
+ * Apply a custom sorting of posts
1597
+ *
1598
+ * @param array $return_post_set Ordered set of filtered posts
1599
+ * @param array $settings Settings for this feed
1600
+ *
1601
+ * @since 1.0
1602
+ */
1603
+
1604
+ return apply_filters( 'sby_sorted_posts', $return_post_set, $settings );
1605
+ }
1606
+
1607
+ /**
1608
+ * Can trigger a second attempt at getting posts from the API
1609
+ *
1610
+ * Overwritten in the Pro version
1611
+ *
1612
+ * @param string $type
1613
+ * @param array $connected_account_with_error
1614
+ * @param int $attempts
1615
+ *
1616
+ * @return bool
1617
+ *
1618
+ * @since 1.0
1619
+ */
1620
+ protected function can_try_another_request( $type, $connected_account_with_error, $attempts = 0 ) {
1621
+ return false;
1622
+ }
1623
+
1624
+ /**
1625
+ * returns a second connected account if it exists
1626
+ *
1627
+ * Overwritten in the Pro version
1628
+ *
1629
+ * @param string $type
1630
+ * @param array $attempted_connected_accounts
1631
+ *
1632
+ * @return bool
1633
+ *
1634
+ * @since 1.0
1635
+ */
1636
+ protected function get_different_connected_account( $type, $attempted_connected_accounts ) {
1637
+ return false;
1638
+ }
1639
+
1640
  }
inc/class-sby-gdpr-integrations.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class SBY_GDPR_Integrations
4
+ *
5
+ * Adds GDPR related workarounds for third-party plugins:
6
+ * https://wordpress.org/plugins/cookie-law-info/
7
+ *
8
+ * @since 2.6/5.9
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ die( '-1' );
13
+ }
14
+
15
+ class SBY_GDPR_Integrations {
16
+
17
+ /**
18
+ * Undoing of Cookie Notice's Twitter Feed related code
19
+ * needs to be done late.
20
+ */
21
+ public static function init() {
22
+ }
23
+
24
+ /**
25
+ * Whether or not consent plugins that Twitter Feed
26
+ * is compatible with are active.
27
+ *
28
+ * @return bool|string
29
+ */
30
+ public static function gdpr_plugins_active() {
31
+ if ( class_exists( 'Cookie_Notice' ) ) {
32
+ return 'Cookie Notice by dFactory';
33
+ }
34
+ if ( function_exists( 'run_cookie_law_info' ) ) {
35
+ return 'GDPR Cookie Consent by WebToffee';
36
+ }
37
+ if ( class_exists( 'Cookiebot_WP' ) ) {
38
+ return 'Cookiebot by Cybot A/S';
39
+ }
40
+ if ( class_exists( 'COMPLIANZ' ) ) {
41
+ return 'Complianz by Really Simple Plugins';
42
+ }
43
+ if ( function_exists('BorlabsCookieHelper') ) {
44
+ return 'Borlabs Cookie by Borlabs';
45
+ }
46
+
47
+ return false;
48
+ }
49
+
50
+ /**
51
+ * GDPR features can be added automatically, forced enabled,
52
+ * or forced disabled.
53
+ *
54
+ * @param $settings
55
+ *
56
+ * @return bool
57
+ */
58
+ public static function doing_gdpr( $settings ) {
59
+ $gdpr = isset( $settings['gdpr'] ) ? $settings['gdpr'] : 'auto';
60
+ if ( $gdpr === 'no' ) {
61
+ return false;
62
+ }
63
+ if ( $gdpr === 'yes' ) {
64
+ return true;
65
+ }
66
+ return (SBY_GDPR_Integrations::gdpr_plugins_active() !== false);
67
+ }
68
+
69
+ /**
70
+ * GDPR features are reliant on the image resizing features
71
+ *
72
+ * @param bool $retest
73
+ *
74
+ * @return bool
75
+ */
76
+ public static function gdpr_tests_successful( $retest = false ) {
77
+ return true;
78
+ }
79
+
80
+ public static function gdpr_tests_error_message() {
81
+ return '';
82
+ }
83
+
84
+ }
inc/class-sby-parse.php CHANGED
@@ -1,258 +1,265 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- die( '-1' );
5
- }
6
-
7
- class SBY_Parse
8
- {
9
- /**
10
- * @param $post array
11
- *
12
- * @return mixed
13
- *
14
- * @since 1.0
15
- */
16
- public static function get_post_id( $post ) {
17
- if ( isset( $post['id'] ) && ! is_array( $post['id'] ) ) {
18
- return $post['id'];
19
- } else {
20
- return SBY_Parse::get_channel_id( $post ) . '_' . SBY_Parse::get_video_id( $post );
21
- }
22
- }
23
-
24
- public static function get_video_id( $post ) {
25
- if ( isset( $post['snippet']['resourceId']['videoId'] ) ) {
26
- return $post['snippet']['resourceId']['videoId'];
27
- } elseif ( isset( $post['id']['videoId'] ) ) {
28
- return $post['id']['videoId'];
29
- } elseif ( isset( $post['id']) ) {
30
- return $post['id'];
31
- }
32
-
33
- return '';
34
- }
35
-
36
- /**
37
- * @param $post array
38
- *
39
- * @return false|int
40
- *
41
- * @since 1.0
42
- */
43
- public static function get_timestamp( $post ) {
44
- $timestamp = 0;
45
- if ( isset( $post['snippet']['publishedAt'] ) ) {
46
- $remove_extra = str_replace( array( 'T', '+00:00', '.000Z', '+' ), ' ', $post['snippet']['publishedAt'] );
47
- $timestamp = strtotime( $remove_extra );
48
- }
49
-
50
- return $timestamp;
51
- }
52
-
53
- /**
54
- * @param $post array
55
- *
56
- * @return mixed
57
- *
58
- * @since 1.0
59
- */
60
- public static function get_permalink( $post ) {
61
- if ( isset( $post['snippet']['resourceId']['videoId'] ) ) {
62
- return 'https://www.youtube.com/watch?v=' . $post['snippet']['resourceId']['videoId'];
63
- } elseif ( isset( $post['snippet']['channelId'] ) ) {
64
- return 'https://www.youtube.com/channel/' . $post['snippet']['channelId'];
65
- }
66
-
67
- return 'https://www.youtube.com/';
68
- }
69
-
70
- /**
71
- * @param array $post
72
- * @param string $resolution
73
- *
74
- * @return string
75
- *
76
- * @since 1.0
77
- */
78
- public static function get_media_url( $post, $resolution = 'lightbox' ) {
79
- $thumbnail_key = 'standard';
80
- switch ( $resolution ) {
81
- case 'thumb' :
82
- $thumbnail_key = 'default';
83
- break;
84
- case 'medium' :
85
- $thumbnail_key = 'medium';
86
- break;
87
- case 'high' :
88
- $thumbnail_key = 'high';
89
- break;
90
- case 'lightbox' :
91
- $thumbnail_key = 'maxres';
92
- break;
93
- }
94
-
95
- if ( isset( $post['snippet']['thumbnails'][ $thumbnail_key ]['url'] ) ) {
96
- return $post['snippet']['thumbnails'][ $thumbnail_key ]['url'];
97
- } elseif ( isset( $post['snippet']['thumbnails']['high']['url'] ) ) {
98
- return $post['snippet']['thumbnails']['high']['url'];
99
- } elseif ( isset( $post['snippet']['thumbnails']['medium']['url'] ) ) {
100
- return $post['snippet']['thumbnails']['medium']['url'];
101
- }
102
-
103
- return '';
104
- }
105
-
106
- /**
107
- * Uses the existing data for the individual YouTube post to
108
- * set the best image sources for each resolution size. Due to
109
- * random bugs or just how the API works, different post types
110
- * need special treatment.
111
- *
112
- * @param array $post
113
- * @param array $resized_images
114
- *
115
- * @return array
116
- *
117
- * @since 1.0
118
- */
119
- public static function get_media_src_set( $post, $resized_images = array() ) {
120
- $media_urls = array();
121
- $thumbnails = isset( $post['snippet']['thumbnails'] ) ? $post['snippet']['thumbnails'] : false;
122
- $largest_found = '';
123
-
124
- if ( $thumbnails ) {
125
- if ( isset( $thumbnails['default']['url'] ) ) {
126
- $media_urls['120'] = $thumbnails['default']['url'];
127
- $largest_found = $thumbnails['default']['url'];
128
- } else {
129
- $media_urls['120'] = $largest_found;
130
- }
131
- if ( isset( $thumbnails['medium']['url'] ) ) {
132
- $media_urls['320'] = $thumbnails['medium']['url'];
133
- $largest_found = $thumbnails['medium']['url'];
134
- } else {
135
- $media_urls['320'] = $largest_found;
136
- }
137
- if ( isset( $thumbnails['high']['url'] ) ) {
138
- $media_urls['480'] = $thumbnails['high']['url'];
139
- $largest_found = $thumbnails['high']['url'];
140
- } else {
141
- $media_urls['480'] = $largest_found;
142
- }
143
- if ( isset( $thumbnails['standard']['url'] ) ) {
144
- $media_urls['640'] = $thumbnails['standard']['url'];
145
- } else {
146
- $media_urls['640'] = $largest_found;
147
- }
148
- }
149
-
150
-
151
- return $media_urls;
152
- }
153
-
154
- /**
155
- * A default can be set in the case that the user doesn't use captions
156
- * for posts as this is also used as the alt text for the image.
157
- *
158
- * @param $post
159
- * @param string $default
160
- *
161
- * @return string
162
- *
163
- * @since 1.0
164
- */
165
- public static function get_caption( $post, $default = '' ) {
166
- $caption = $default;
167
- if ( isset( $post['snippet']['description'] ) ) {
168
- $caption = $post['snippet']['description'];
169
- }
170
-
171
- return $caption;
172
- }
173
-
174
- public static function get_video_title( $channel_or_playlist_item_data ) {
175
- if ( isset( $channel_or_playlist_item_data['items'][0]['snippet']['title'] ) ) {
176
- return $channel_or_playlist_item_data['items'][0]['snippet']['title'];
177
- } else if ( isset( $channel_or_playlist_item_data['snippet']['title'] ) ) {
178
- return $channel_or_playlist_item_data['snippet']['title'];
179
- }
180
- return '';
181
- }
182
-
183
- public static function get_channel_id( $channel_or_playlist_item_data ) {
184
- if ( isset( $channel_or_playlist_item_data['items'][0]['id'] ) ) {
185
- return $channel_or_playlist_item_data['items'][0]['id'];
186
- } elseif ( isset( $channel_or_playlist_item_data['snippet']['channelId'] ) ) {
187
- return $channel_or_playlist_item_data['snippet']['channelId'];
188
- }
189
- return '';
190
- }
191
-
192
- public static function get_channel_title( $channel_or_playlist_item_data ) {
193
- if ( isset( $channel_or_playlist_item_data['items'][0]['snippet']['title'] ) ) {
194
- return $channel_or_playlist_item_data['items'][0]['snippet']['title'];
195
- } elseif ( isset( $channel_or_playlist_item_data['snippet']['channelTitle'] ) ) {
196
- return $channel_or_playlist_item_data['snippet']['channelTitle'];
197
- }
198
- return '';
199
- }
200
-
201
- public static function get_channel_permalink( $channel_data ) {
202
- return 'https://www.youtube.com/channel/' . SBY_Parse::get_channel_id( $channel_data ) . '/';
203
- }
204
-
205
- /**
206
- * @param array $header_data
207
- * @param array $settings
208
- *
209
- * @return string
210
- *
211
- * @since 1.0
212
- */
213
- public static function get_avatar( $header_data, $settings = array( 'favor_local' => false ) ) {
214
- if ( $settings['favor_local'] && ! empty( $header_data['local_avatar'] ) ) {
215
- return $header_data['local_avatar'];
216
- } else {
217
- if ( isset( $header_data['items'][0]['snippet']['thumbnails'] ) ) {
218
- $header_size = isset( $settings['headersize'] ) ? $settings['headersize'] : '';
219
- if ( $header_size === 'large' ) {
220
- return $header_data['items'][0]['snippet']['thumbnails']['high']['url'];
221
- } elseif ( $header_size === 'medium' ) {
222
- return $header_data['items'][0]['snippet']['thumbnails']['medium']['url'];
223
- } else {
224
- return $header_data['items'][0]['snippet']['thumbnails']['default']['url'];
225
- }
226
- }
227
- }
228
- return '';
229
- }
230
-
231
- public static function get_item_avatar( $post, $avatars ) {
232
- if ( empty ( $avatars ) ) {
233
- return '';
234
- } else {
235
- $username = SBY_Parse::get_channel_id( $post );
236
- if ( isset( $avatars[ $username ] ) ) {
237
- return $avatars[ $username ];
238
- }
239
- }
240
- return '';
241
- }
242
-
243
- /**
244
- * Account bio/description used in header
245
- *
246
- * @param $header_data
247
- *
248
- * @return string
249
- *
250
- * @since 1.0
251
- */
252
- public static function get_channel_description( $header_data ) {
253
- if ( isset( $header_data['items'][0]['snippet']['description'] ) ) {
254
- return $header_data['items'][0]['snippet']['description'];
255
- }
256
- return '';
257
- }
 
 
 
 
 
 
 
258
  }
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
+ }
6
+
7
+ class SBY_Parse
8
+ {
9
+ /**
10
+ * @param $post array
11
+ *
12
+ * @return mixed
13
+ *
14
+ * @since 1.0
15
+ */
16
+ public static function get_post_id( $post ) {
17
+ if ( isset( $post['id'] ) && ! is_array( $post['id'] ) ) {
18
+ return $post['id'];
19
+ } else {
20
+ return SBY_Parse::get_channel_id( $post ) . '_' . SBY_Parse::get_video_id( $post );
21
+ }
22
+ }
23
+
24
+ public static function get_video_id( $post ) {
25
+ if ( isset( $post['snippet']['resourceId']['videoId'] ) ) {
26
+ return $post['snippet']['resourceId']['videoId'];
27
+ } elseif ( isset( $post['id']['videoId'] ) ) {
28
+ return $post['id']['videoId'];
29
+ } elseif ( isset( $post['id']) ) {
30
+ return $post['id'];
31
+ }
32
+
33
+ return '';
34
+ }
35
+
36
+ /**
37
+ * @param $post array
38
+ *
39
+ * @return false|int
40
+ *
41
+ * @since 1.0
42
+ */
43
+ public static function get_timestamp( $post ) {
44
+ $timestamp = 0;
45
+
46
+ if ( isset( $post['contentDetails']['videoPublishedAt'] ) ) {
47
+ $data = $post['contentDetails']['videoPublishedAt'];
48
+ } elseif ( isset( $post['snippet']['publishedAt'] ) ) {
49
+ $data = $post['snippet']['publishedAt'];
50
+ }
51
+ if ( isset( $data ) ) {
52
+ $remove_extra = str_replace( array( 'T', '+00:00', '.000Z', '+' ), ' ', $data );
53
+ $timestamp = strtotime( $remove_extra );
54
+ }
55
+
56
+
57
+ return $timestamp;
58
+ }
59
+
60
+ /**
61
+ * @param $post array
62
+ *
63
+ * @return mixed
64
+ *
65
+ * @since 1.0
66
+ */
67
+ public static function get_permalink( $post ) {
68
+ if ( isset( $post['snippet']['resourceId']['videoId'] ) ) {
69
+ return 'https://www.youtube.com/watch?v=' . $post['snippet']['resourceId']['videoId'];
70
+ } elseif ( isset( $post['snippet']['channelId'] ) ) {
71
+ return 'https://www.youtube.com/channel/' . $post['snippet']['channelId'];
72
+ }
73
+
74
+ return 'https://www.youtube.com/';
75
+ }
76
+
77
+ /**
78
+ * @param array $post
79
+ * @param string $resolution
80
+ *
81
+ * @return string
82
+ *
83
+ * @since 1.0
84
+ */
85
+ public static function get_media_url( $post, $resolution = 'lightbox' ) {
86
+ $thumbnail_key = 'standard';
87
+ switch ( $resolution ) {
88
+ case 'thumb' :
89
+ $thumbnail_key = 'default';
90
+ break;
91
+ case 'medium' :
92
+ $thumbnail_key = 'medium';
93
+ break;
94
+ case 'high' :
95
+ $thumbnail_key = 'high';
96
+ break;
97
+ case 'lightbox' :
98
+ $thumbnail_key = 'maxres';
99
+ break;
100
+ }
101
+
102
+ if ( isset( $post['snippet']['thumbnails'][ $thumbnail_key ]['url'] ) ) {
103
+ return $post['snippet']['thumbnails'][ $thumbnail_key ]['url'];
104
+ } elseif ( isset( $post['snippet']['thumbnails']['high']['url'] ) ) {
105
+ return $post['snippet']['thumbnails']['high']['url'];
106
+ } elseif ( isset( $post['snippet']['thumbnails']['medium']['url'] ) ) {
107
+ return $post['snippet']['thumbnails']['medium']['url'];
108
+ }
109
+
110
+ return '';
111
+ }
112
+
113
+ /**
114
+ * Uses the existing data for the individual YouTube post to
115
+ * set the best image sources for each resolution size. Due to
116
+ * random bugs or just how the API works, different post types
117
+ * need special treatment.
118
+ *
119
+ * @param array $post
120
+ * @param array $resized_images
121
+ *
122
+ * @return array
123
+ *
124
+ * @since 1.0
125
+ */
126
+ public static function get_media_src_set( $post, $resized_images = array() ) {
127
+ $media_urls = array();
128
+ $thumbnails = isset( $post['snippet']['thumbnails'] ) ? $post['snippet']['thumbnails'] : false;
129
+ $largest_found = '';
130
+
131
+ if ( $thumbnails ) {
132
+ if ( isset( $thumbnails['default']['url'] ) ) {
133
+ $media_urls['120'] = $thumbnails['default']['url'];
134
+ $largest_found = $thumbnails['default']['url'];
135
+ } else {
136
+ $media_urls['120'] = $largest_found;
137
+ }
138
+ if ( isset( $thumbnails['medium']['url'] ) ) {
139
+ $media_urls['320'] = $thumbnails['medium']['url'];
140
+ $largest_found = $thumbnails['medium']['url'];
141
+ } else {
142
+ $media_urls['320'] = $largest_found;
143
+ }
144
+ if ( isset( $thumbnails['high']['url'] ) ) {
145
+ $media_urls['480'] = $thumbnails['high']['url'];
146
+ $largest_found = $thumbnails['high']['url'];
147
+ } else {
148
+ $media_urls['480'] = $largest_found;
149
+ }
150
+ if ( isset( $thumbnails['standard']['url'] ) ) {
151
+ $media_urls['640'] = $thumbnails['standard']['url'];
152
+ } else {
153
+ $media_urls['640'] = $largest_found;
154
+ }
155
+ }
156
+
157
+
158
+ return $media_urls;
159
+ }
160
+
161
+ /**
162
+ * A default can be set in the case that the user doesn't use captions
163
+ * for posts as this is also used as the alt text for the image.
164
+ *
165
+ * @param $post
166
+ * @param string $default
167
+ *
168
+ * @return string
169
+ *
170
+ * @since 1.0
171
+ */
172
+ public static function get_caption( $post, $default = '' ) {
173
+ $caption = $default;
174
+ if ( isset( $post['snippet']['description'] ) ) {
175
+ $caption = $post['snippet']['description'];
176
+ }
177
+
178
+ return $caption;
179
+ }
180
+
181
+ public static function get_video_title( $channel_or_playlist_item_data ) {
182
+ if ( isset( $channel_or_playlist_item_data['items'][0]['snippet']['title'] ) ) {
183
+ return $channel_or_playlist_item_data['items'][0]['snippet']['title'];
184
+ } else if ( isset( $channel_or_playlist_item_data['snippet']['title'] ) ) {
185
+ return $channel_or_playlist_item_data['snippet']['title'];
186
+ }
187
+ return '';
188
+ }
189
+
190
+ public static function get_channel_id( $channel_or_playlist_item_data ) {
191
+ if ( isset( $channel_or_playlist_item_data['items'][0]['id'] ) ) {
192
+ return $channel_or_playlist_item_data['items'][0]['id'];
193
+ } elseif ( isset( $channel_or_playlist_item_data['snippet']['channelId'] ) ) {
194
+ return $channel_or_playlist_item_data['snippet']['channelId'];
195
+ }
196
+ return '';
197
+ }
198
+
199
+ public static function get_channel_title( $channel_or_playlist_item_data ) {
200
+ if ( isset( $channel_or_playlist_item_data['items'][0]['snippet']['title'] ) ) {
201
+ return $channel_or_playlist_item_data['items'][0]['snippet']['title'];
202
+ } elseif ( isset( $channel_or_playlist_item_data['snippet']['channelTitle'] ) ) {
203
+ return $channel_or_playlist_item_data['snippet']['channelTitle'];
204
+ }
205
+ return '';
206
+ }
207
+
208
+ public static function get_channel_permalink( $channel_data ) {
209
+ return 'https://www.youtube.com/channel/' . SBY_Parse::get_channel_id( $channel_data ) . '/';
210
+ }
211
+
212
+ /**
213
+ * @param array $header_data
214
+ * @param array $settings
215
+ *
216
+ * @return string
217
+ *
218
+ * @since 1.0
219
+ */
220
+ public static function get_avatar( $header_data, $settings = array( 'favor_local' => false ) ) {
221
+ if ( $settings['favor_local'] && ! empty( $header_data['local_avatar'] ) ) {
222
+ return $header_data['local_avatar'];
223
+ } else {
224
+ if ( isset( $header_data['items'][0]['snippet']['thumbnails'] ) ) {
225
+ $header_size = isset( $settings['headersize'] ) ? $settings['headersize'] : '';
226
+ if ( $header_size === 'large' ) {
227
+ return $header_data['items'][0]['snippet']['thumbnails']['high']['url'];
228
+ } elseif ( $header_size === 'medium' ) {
229
+ return $header_data['items'][0]['snippet']['thumbnails']['medium']['url'];
230
+ } else {
231
+ return $header_data['items'][0]['snippet']['thumbnails']['default']['url'];
232
+ }
233
+ }
234
+ }
235
+ return '';
236
+ }
237
+
238
+ public static function get_item_avatar( $post, $avatars ) {
239
+ if ( empty ( $avatars ) ) {
240
+ return '';
241
+ } else {
242
+ $username = SBY_Parse::get_channel_id( $post );
243
+ if ( isset( $avatars[ $username ] ) ) {
244
+ return $avatars[ $username ];
245
+ }
246
+ }
247
+ return '';
248
+ }
249
+
250
+ /**
251
+ * Account bio/description used in header
252
+ *
253
+ * @param $header_data
254
+ *
255
+ * @return string
256
+ *
257
+ * @since 1.0
258
+ */
259
+ public static function get_channel_description( $header_data ) {
260
+ if ( isset( $header_data['items'][0]['snippet']['description'] ) ) {
261
+ return $header_data['items'][0]['snippet']['description'];
262
+ }
263
+ return '';
264
+ }
265
  }
inc/class-sby-posts-manager.php CHANGED
@@ -1,328 +1,328 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- die( '-1' );
5
- }
6
-
7
- class SBY_Posts_Manager
8
- {
9
- var $options_prefix;
10
-
11
- /**
12
- * @var int
13
- */
14
- var $limit;
15
-
16
- /**
17
- * @var array
18
- */
19
- var $errors;
20
-
21
- var $ajax_status;
22
-
23
- /**
24
- * @var array
25
- */
26
- var $frontend_errors;
27
-
28
- /**
29
- * @var bool
30
- */
31
- var $resizing_tables_exist;
32
-
33
- /**
34
- * SBY_Posts_Manager constructor.
35
- */
36
- public function __construct( $options_prefix, $errors, $ajax_status ) {
37
- $this->options_prefix = $options_prefix;
38
- $this->errors = $errors;
39
- $this->ajax_status = $ajax_status;
40
- $this->frontend_errors = array();
41
- }
42
-
43
- /**
44
- * @return array
45
- *
46
- * @since 1.0
47
- */
48
- public function get_ajax_status() {
49
- return $this->ajax_status;
50
- }
51
-
52
- /**
53
- * @param $to_update
54
- *
55
- * @since 1.0
56
- */
57
- public function update_ajax_status( $to_update ) {
58
- foreach ( $to_update as $key => $value ) {
59
- $this->ajax_status[ $key ] = $value;
60
- }
61
-
62
- update_option( $this->options_prefix . '_ajax_status', $this->ajax_status );
63
- }
64
-
65
- /**
66
- * When the plugin is first installed and used, an AJAX call to admin-ajax.php
67
- * is made to verify that it's available
68
- *
69
- * @param bool $force_check
70
- *
71
- * @return bool
72
- *
73
- * @since 1.0
74
- */
75
- public function maybe_start_ajax_test( $force_check = false ) {
76
- if ( ! $this->ajax_status['tested'] || $force_check ) {
77
- set_transient( $this->options_prefix . '_doing_ajax_test', 'yes', 60*60 );
78
- $this->update_ajax_status( array( 'tested' => true ) );
79
- return true;
80
- }
81
-
82
- return false;
83
- }
84
-
85
- /**
86
- * Called if a successful admin ajax request is made
87
- *
88
- * @since 1.0
89
- */
90
- public function update_successful_ajax_test() {
91
- $this->update_ajax_status( array( 'successful' => true ) );
92
- }
93
-
94
- /**
95
- * @return bool
96
- *
97
- * @since 1.0
98
- */
99
- public function should_add_ajax_test_notice() {
100
- return ($this->ajax_status['tested'] && ! $this->ajax_status['successful'] && get_transient( $this->options_prefix . '_doing_ajax_test' ) !== 'yes');
101
- }
102
-
103
- /**
104
- * The plugin has a limit on how many post records can be stored and
105
- * images resized to avoid overloading servers. This function deletes the post that
106
- * has the longest time passed since it was retrieved.
107
- *
108
- * @since 1.0
109
- */
110
- public function delete_least_used_image() {
111
-
112
- }
113
-
114
- /**
115
- * Calculates how many records are in the database and whether or not it exceeds the limit
116
- *
117
- * @return bool
118
- *
119
- * @since 1.0
120
- */
121
- public function max_total_records_reached() {
122
- global $wpdb;
123
- $table_name = $wpdb->prefix . SBY_ITEMS;
124
-
125
- $num_records = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
126
-
127
- if ( !isset( $this->limit ) && (int)$num_records > SBY_MAX_RECORDS ) {
128
- $this->limit = (int)$num_records - SBY_MAX_RECORDS;
129
- }
130
-
131
- return ((int)$num_records > SBY_MAX_RECORDS);
132
- }
133
-
134
- /**
135
- * The plugin caps how many new images are created in a 15 minute window to
136
- * avoid overloading servers
137
- *
138
- * @return bool
139
- *
140
- * @since 1.0
141
- */
142
- public function max_resizing_per_time_period_reached() {
143
- global $wpdb;
144
- $table_name = $wpdb->prefix . SBY_ITEMS;
145
-
146
- $fifteen_minutes_ago = date( 'Y-m-d H:i:s', time() - 15 * 60 );
147
-
148
- $num_new_records = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name WHERE created_on > '$fifteen_minutes_ago'" );
149
-
150
- return ((int)$num_new_records > 100);
151
- }
152
-
153
- /**
154
- * @return bool
155
- *
156
- * @since 1.0
157
- */
158
- public function image_resizing_disabled() {
159
- global $sby_settings;
160
-
161
- $disable_resizing = isset( $sby_settings['disable_resize'] ) ? $sby_settings['disable_resize'] === 'on' || $sby_settings['disable_resize'] === true : false;
162
-
163
- if ( ! $disable_resizing ) {
164
- $disable_resizing = isset( $this->resizing_tables_exist ) ? ! $this->resizing_tables_exist : ! $this->does_resizing_tables_exist();
165
- }
166
-
167
- return $disable_resizing;
168
- }
169
-
170
- /**
171
- * Used to skip image resizing if the tables were never successfully
172
- * created
173
- *
174
- * @return bool
175
- *
176
- * @since 1.0
177
- */
178
- public function does_resizing_tables_exist() {
179
- return true;
180
- }
181
-
182
- /**
183
- * Resets the custom tables and deletes all image files
184
- *
185
- * @since 1.0
186
- */
187
- public function delete_all_sby_posts() {
188
- $upload = wp_upload_dir();
189
-
190
- global $wpdb;
191
-
192
- $image_files = glob( trailingslashit( $upload['basedir'] ) . trailingslashit( SBY_UPLOADS_NAME ) . '*' ); // get all file names
193
- foreach ( $image_files as $file ) { // iterate files
194
- if ( is_file( $file ) ) {
195
- unlink( $file );
196
- }
197
- }
198
-
199
- $options = get_option( $this->options_prefix . '_settings', array() );
200
- $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
201
-
202
- foreach ( $connected_accounts as $account_id => $data ) {
203
-
204
- if ( isset( $data['local_avatar'] ) ) {
205
- $connected_accounts[ $account_id ]['local_avatar'] = false;
206
- }
207
-
208
- }
209
-
210
- $options['connected_accounts'] = $connected_accounts;
211
-
212
- update_option( $this->options_prefix . '_settings', $options );
213
-
214
- $table_name = $wpdb->prefix . "options";
215
-
216
- $wpdb->query( "
217
- DELETE
218
- FROM $table_name
219
- WHERE `option_name` LIKE ('%\_transient\_\$sby\_%')
220
- " );
221
- $wpdb->query( "
222
- DELETE
223
- FROM $table_name
224
- WHERE `option_name` LIKE ('%\_transient\_timeout\_\$sby\_%')
225
- " );
226
-
227
- $upload = wp_upload_dir();
228
- $upload_dir = $upload['basedir'];
229
- $upload_dir = trailingslashit( $upload_dir ) . SBY_UPLOADS_NAME;
230
- if ( ! file_exists( $upload_dir ) ) {
231
- $created = wp_mkdir_p( $upload_dir );
232
- if ( $created ) {
233
- $this->remove_error( 'upload_dir' );
234
- } else {
235
- $this->add_error( 'upload_dir', array( __( 'There was an error creating the folder for storing resized images.', SBY_TEXT_DOMAIN ), $upload_dir ) );
236
- }
237
- } else {
238
- $this->remove_error( 'upload_dir' );
239
- }
240
-
241
- }
242
-
243
- /**
244
- * @return array
245
- *
246
- * @since 1.0
247
- */
248
- public function get_errors() {
249
- return $this->errors;
250
- }
251
-
252
- /**
253
- * @param $type
254
- * @param $message_array
255
- *
256
- * @since 1.0
257
- */
258
- public function add_error( $type, $message_array ) {
259
- $this->errors[ $type ] = $message_array;
260
-
261
- update_option( 'sby_errors', $this->errors, false );
262
- }
263
-
264
- /**
265
- * @param $type
266
- *
267
- * @since 1.0
268
- */
269
- public function remove_error( $type ) {
270
- if ( isset( $this->errors[ $type ] ) ) {
271
- unset( $this->errors[ $type ] );
272
-
273
- update_option( $this->options_prefix . '_errors', $this->errors, false );
274
- }
275
- }
276
-
277
- public function remove_all_errors() {
278
- delete_option( $this->options_prefix . '_errors' );
279
- }
280
-
281
- /**
282
- * @param $type
283
- * @param $message
284
- *
285
- * @since 1.0
286
- */
287
- public function add_frontend_error( $type, $message ) {
288
- $this->frontend_errors[ $type ] = $message;
289
- }
290
-
291
- /**
292
- * @return array
293
- *
294
- * @since 1.0
295
- */
296
- public function get_frontend_errors() {
297
- return $this->frontend_errors;
298
- }
299
-
300
- /**
301
- * @return array
302
- *
303
- * @since 1.0
304
- */
305
- public function reset_frontend_errors() {
306
- return $this->frontend_errors = array();
307
- }
308
-
309
- /**
310
- * @since 1.0
311
- */
312
- public function add_api_request_delay( $time_in_seconds = 300, $account_id = false ) {
313
- if ( $account_id ) {
314
- set_transient( SBY_USE_BACKUP_PREFIX . $this->options_prefix . '_' . $account_id, '1', $time_in_seconds );
315
- } else {
316
- set_transient( SBY_USE_BACKUP_PREFIX . $this->options_prefix . '_delay_requests', '1', $time_in_seconds );
317
- }
318
- }
319
-
320
- /**
321
- * @since 1.0
322
- */
323
- public function are_current_api_request_delays( $account_id = false ) {
324
- $is_delay = (get_transient( SBY_USE_BACKUP_PREFIX . $this->options_prefix . '_delay_requests' ) !== false);
325
-
326
- return $is_delay;
327
- }
328
  }
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ die( '-1' );
5
+ }
6
+
7
+ class SBY_Posts_Manager
8
+ {
9
+ var $options_prefix;
10
+
11
+ /**
12
+ * @var int
13
+ */
14
+ var $limit;
15
+
16
+ /**
17
+ * @var array
18
+ */
19
+ var $errors;
20
+
21
+ var $ajax_status;
22
+
23
+ /**
24
+ * @var array
25
+ */
26
+ var $frontend_errors;
27
+
28
+ /**
29
+ * @var bool
30
+ */
31
+ var $resizing_tables_exist;
32
+
33
+ /**
34
+ * SBY_Posts_Manager constructor.
35
+ */
36
+ public function __construct( $options_prefix, $errors, $ajax_status ) {
37
+ $this->options_prefix = $options_prefix;
38
+ $this->errors = $errors;
39
+ $this->ajax_status = $ajax_status;
40
+ $this->frontend_errors = array();
41
+ }
42
+
43
+ /**
44
+ * @return array
45
+ *
46
+ * @since 1.0
47
+ */
48
+ public function get_ajax_status() {
49
+ return $this->ajax_status;
50
+ }
51
+
52
+ /**
53
+ * @param $to_update
54
+ *
55
+ * @since 1.0
56
+ */
57
+ public function update_ajax_status( $to_update ) {
58
+ foreach ( $to_update as $key => $value ) {
59
+ $this->ajax_status[ $key ] = $value;
60
+ }
61
+
62
+ update_option( $this->options_prefix . '_ajax_status', $this->ajax_status );
63
+ }
64
+
65
+ /**
66
+ * When the plugin is first installed and used, an AJAX call to admin-ajax.php
67
+ * is made to verify that it's available
68
+ *
69
+ * @param bool $force_check
70
+ *
71
+ * @return bool
72
+ *
73
+ * @since 1.0
74
+ */
75
+ public function maybe_start_ajax_test( $force_check = false ) {
76
+ if ( ! $this->ajax_status['tested'] || $force_check ) {
77
+ set_transient( $this->options_prefix . '_doing_ajax_test', 'yes', 60*60 );
78
+ $this->update_ajax_status( array( 'tested' => true ) );
79
+ return true;
80
+ }
81
+
82
+ return false;
83
+ }
84
+
85
+ /**
86
+ * Called if a successful admin ajax request is made
87
+ *
88
+ * @since 1.0
89
+ */
90
+ public function update_successful_ajax_test() {
91
+ $this->update_ajax_status( array( 'successful' => true ) );
92
+ }
93
+
94
+ /**
95
+ * @return bool
96
+ *
97
+ * @since 1.0
98
+ */
99
+ public function should_add_ajax_test_notice() {
100
+ return ($this->ajax_status['tested'] && ! $this->ajax_status['successful'] && get_transient( $this->options_prefix . '_doing_ajax_test' ) !== 'yes');
101
+ }
102
+
103
+ /**
104
+ * The plugin has a limit on how many post records can be stored and
105
+ * images resized to avoid overloading servers. This function deletes the post that
106
+ * has the longest time passed since it was retrieved.
107
+ *
108
+ * @since 1.0
109
+ */
110
+ public function delete_least_used_image() {
111
+
112
+ }
113
+
114
+ /**
115
+ * Calculates how many records are in the database and whether or not it exceeds the limit
116
+ *
117
+ * @return bool
118
+ *
119
+ * @since 1.0
120
+ */
121
+ public function max_total_records_reached() {
122
+ global $wpdb;
123
+ $table_name = $wpdb->prefix . SBY_ITEMS;
124
+
125
+ $num_records = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
126
+
127
+ if ( !isset( $this->limit ) && (int)$num_records > SBY_MAX_RECORDS ) {
128
+ $this->limit = (int)$num_records - SBY_MAX_RECORDS;
129
+ }
130
+
131
+ return ((int)$num_records > SBY_MAX_RECORDS);
132
+ }
133
+
134
+ /**
135
+ * The plugin caps how many new images are created in a 15 minute window to
136
+ * avoid overloading servers
137
+ *
138
+ * @return bool
139
+ *
140
+ * @since 1.0
141
+ */
142
+ public function max_resizing_per_time_period_reached() {
143
+ global $wpdb;
144
+ $table_name = $wpdb->prefix . SBY_ITEMS;
145
+
146
+ $fifteen_minutes_ago = date( 'Y-m-d H:i:s', time() - 15 * 60 );
147
+
148
+ $num_new_records = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name WHERE created_on > '$fifteen_minutes_ago'" );
149
+
150
+ return ((int)$num_new_records > 100);
151
+ }
152
+
153
+ /**
154
+ * @return bool
155
+ *
156
+ * @since 1.0
157
+ */
158
+ public function image_resizing_disabled() {
159
+ global $sby_settings;
160
+
161
+ $disable_resizing = isset( $sby_settings['disable_resize'] ) ? $sby_settings['disable_resize'] === 'on' || $sby_settings['disable_resize'] === true : false;
162
+
163
+ if ( ! $disable_resizing ) {
164
+ $disable_resizing = isset( $this->resizing_tables_exist ) ? ! $this->resizing_tables_exist : ! $this->does_resizing_tables_exist();
165
+ }
166
+
167
+ return $disable_resizing;
168
+ }
169
+
170
+ /**
171
+ * Used to skip image resizing if the tables were never successfully
172
+ * created
173
+ *
174
+ * @return bool
175
+ *
176
+ * @since 1.0
177
+ */
178
+ public function does_resizing_tables_exist() {
179
+ return true;
180
+ }
181
+
182
+ /**
183
+ * Resets the custom tables and deletes all image files
184
+ *
185
+ * @since 1.0
186
+ */
187
+ public function delete_all_sby_posts() {
188
+ $upload = wp_upload_dir();
189
+
190
+ global $wpdb;
191
+
192
+ $image_files = glob( trailingslashit( $upload['basedir'] ) . trailingslashit( SBY_UPLOADS_NAME ) . '*' ); // get all file names
193
+ foreach ( $image_files as $file ) { // iterate files
194
+ if ( is_file( $file ) ) {
195
+ unlink( $file );
196
+ }
197
+ }
198
+
199
+ $options = get_option( $this->options_prefix . '_settings', array() );
200
+ $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
201
+
202
+ foreach ( $connected_accounts as $account_id => $data ) {
203
+
204
+ if ( isset( $data['local_avatar'] ) ) {
205
+ $connected_accounts[ $account_id ]['local_avatar'] = false;
206
+ }
207
+
208
+ }
209
+
210
+ $options['connected_accounts'] = $connected_accounts;
211
+
212
+ update_option( $this->options_prefix . '_settings', $options );
213
+
214
+ $table_name = $wpdb->prefix . "options";
215
+
216
+ $wpdb->query( "
217
+ DELETE
218
+ FROM $table_name
219
+ WHERE `option_name` LIKE ('%\_transient\_\$sby\_%')
220
+ " );
221
+ $wpdb->query( "
222
+ DELETE
223
+ FROM $table_name
224
+ WHERE `option_name` LIKE ('%\_transient\_timeout\_\$sby\_%')
225
+ " );
226
+
227
+ $upload = wp_upload_dir();
228
+ $upload_dir = $upload['basedir'];
229
+ $upload_dir = trailingslashit( $upload_dir ) . SBY_UPLOADS_NAME;
230
+ if ( ! file_exists( $upload_dir ) ) {
231
+ $created = wp_mkdir_p( $upload_dir );
232
+ if ( $created ) {
233
+ $this->remove_error( 'upload_dir' );
234
+ } else {
235
+ $this->add_error( 'upload_dir', array( __( 'There was an error creating the folder for storing resized images.', SBY_TEXT_DOMAIN ), $upload_dir ) );
236
+ }
237
+ } else {
238
+ $this->remove_error( 'upload_dir' );
239
+ }
240
+
241
+ }
242
+
243
+ /**
244
+ * @return array
245
+ *
246
+ * @since 1.0
247
+ */
248
+ public function get_errors() {
249
+ return $this->errors;
250
+ }
251
+
252
+ /**
253
+ * @param $type
254
+ * @param $message_array
255
+ *
256
+ * @since 1.0
257
+ */
258
+ public function add_error( $type, $message_array ) {
259
+ $this->errors[ $type ] = $message_array;
260
+
261
+ update_option( 'sby_errors', $this->errors, false );
262
+ }
263
+
264
+ /**
265
+ * @param $type
266
+ *
267
+ * @since 1.0
268
+ */
269
+ public function remove_error( $type ) {
270
+ if ( isset( $this->errors[ $type ] ) ) {
271
+ unset( $this->errors[ $type ] );
272
+
273
+ update_option( $this->options_prefix . '_errors', $this->errors, false );
274
+ }
275
+ }
276
+
277
+ public function remove_all_errors() {
278
+ delete_option( $this->options_prefix . '_errors' );
279
+ }
280
+
281
+ /**
282
+ * @param $type
283
+ * @param $message
284
+ *
285
+ * @since 1.0
286
+ */
287
+ public function add_frontend_error( $type, $message ) {
288
+ $this->frontend_errors[ $type ] = $message;
289
+ }
290
+
291
+ /**
292
+ * @return array
293
+ *
294
+ * @since 1.0
295
+ */
296
+ public function get_frontend_errors() {
297
+ return $this->frontend_errors;
298
+ }
299
+
300
+ /**
301
+ * @return array
302
+ *
303
+ * @since 1.0
304
+ */
305
+ public function reset_frontend_errors() {
306
+ return $this->frontend_errors = array();
307
+ }
308
+
309
+ /**
310
+ * @since 1.0
311
+ */
312
+ public function add_api_request_delay( $time_in_seconds = 300, $account_id = false ) {
313
+ if ( $account_id ) {
314
+ set_transient( SBY_USE_BACKUP_PREFIX . $this->options_prefix . '_' . $account_id, '1', $time_in_seconds );
315
+ } else {
316
+ set_transient( SBY_USE_BACKUP_PREFIX . $this->options_prefix . '_delay_requests', '1', $time_in_seconds );
317
+ }
318
+ }
319
+
320
+ /**
321
+ * @since 1.0
322
+ */
323
+ public function are_current_api_request_delays( $account_id = false ) {
324
+ $is_delay = (get_transient( SBY_USE_BACKUP_PREFIX . $this->options_prefix . '_delay_requests' ) !== false);
325
+
326
+ return $is_delay;
327
+ }
328
  }
inc/class-sby-rss-connect.php CHANGED
@@ -1,123 +1,137 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- die( '-1' );
4
- }
5
-
6
- class SBY_RSS_Connect
7
- {
8
- /**
9
- * @var string
10
- */
11
- private $url;
12
-
13
- /**
14
- * @var object
15
- */
16
- private $response;
17
-
18
- public function __construct( $endpoint = '', $params = array() ) {
19
- $this->set_url( $endpoint, $params );
20
- }
21
-
22
- public function get_data() {
23
- return $this->response;
24
- }
25
-
26
- public function set_url_from_args( $url ) {
27
- $this->url = $url;
28
- }
29
-
30
- public function get_url() {
31
- return $this->url;
32
- }
33
-
34
- public function connect() {
35
-
36
- if ( ! ini_get( 'allow_url_fopen' ) ) {
37
- $error_message = '<p><b>'. __( 'Unable to retrieve new videos without an API key.', 'youtube-feed' ) .'</b></p>';
38
- if ( current_user_can( 'manage_youtube_feed_options' ) ) {
39
- $error_message .= '<p>' . sprintf( __( 'Due to your server configuration, an API key is required to update your feed. See %sthis FAQ%s to set up an API key.', 'youtube-feed' ), '<a href="https://smashballoon.com/youtube-api-key/" target="_blank" rel="noopener nofollow">', '</a>' ) . '</p>';
40
- }
41
- global $sby_posts_manager;
42
-
43
- $sby_posts_manager->add_frontend_error( 'api', $error_message );
44
- $sby_posts_manager->add_error( 'api', array( 'Error connecting', $error_message ) );
45
-
46
- $sby_posts_manager->add_api_request_delay( 300 );
47
-
48
- return array();
49
- }
50
-
51
- if ( wp_remote_retrieve_response_code( wp_remote_get( $this->url ) ) === 404 ) {
52
- $error_message = '<p><b>'. __( 'Cannot collect videos from this channel. Please make sure this is a valid channel ID.', 'youtube-feed' ) .'</b></p>';
53
-
54
- global $sby_posts_manager;
55
-
56
- $sby_posts_manager->add_frontend_error( 'api', $error_message );
57
- $sby_posts_manager->add_error( 'api', array( 'Error connecting', $error_message ) );
58
-
59
- $sby_posts_manager->add_api_request_delay( 300 );
60
-
61
- return array();
62
- }
63
-
64
- $parsed_obj = new SimpleXMLElement( $this->url, null, true );
65
-
66
- $items_array = array();
67
- if ( isset( $parsed_obj->entry ) ) {
68
- foreach ( $parsed_obj->entry as $video_xml ) {
69
-
70
- $this_item_array = array();
71
-
72
- $high_thumbnail_url = (string) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->thumbnail->attributes()->url;
73
-
74
- $this_item_array['snippet'] = array(
75
- 'publishedAt' => (string) $video_xml->published,
76
- 'channelId' => (string) $video_xml->children( 'http://www.youtube.com/xml/schemas/2015' )->channelId,
77
- 'title' => (string) $video_xml->title,
78
- 'description' => (string) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->description,
79
- 'thumbnails' => array(
80
- 'default' => array(
81
- 'url' => (string) str_replace( 'hqdefault.jpg', 'default.jpg', $high_thumbnail_url ),
82
- ),
83
- 'medium' => array(
84
- 'url' => str_replace( 'hqdefault.jpg', 'mqdefault.jpg', $high_thumbnail_url ),
85
- ),
86
- 'high' => array(
87
- 'url' => $high_thumbnail_url,
88
- 'width' => (string) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->thumbnail->attributes()->width,
89
- 'height' => (string) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->thumbnail->attributes()->height,
90
- ),
91
- 'standard' => array(
92
- 'url' => str_replace( 'hqdefault.jpg', 'sddefault.jpg', $high_thumbnail_url ),
93
- ),
94
- 'maxres' => array(
95
- 'url' => str_replace( 'hqdefault.jpg', 'maxresdefault.jpg', $high_thumbnail_url ),
96
- ),
97
- ),
98
- 'channelTitle' => (string) $video_xml->author->name,
99
- 'resourceId' => array(
100
- 'videoId' => (string) $video_xml->children( 'http://www.youtube.com/xml/schemas/2015' )->videoId
101
- ),
102
- );
103
- $this_item_array['statistics'] = array(
104
- 'viewCount' => (int) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->community->statistics->attributes()->views,
105
- 'starRating' => (float) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->community->starRating->attributes()->average,
106
- );
107
- $items_array[] = $this_item_array;
108
-
109
- }
110
- }
111
-
112
-
113
- $this->response = $items_array;
114
-
115
- }
116
-
117
- protected function set_url( $endpoint_slug, $params ) {
118
- $url = 'https://www.youtube.com/feeds/videos.xml?channel_id=' . $params['channel_id'];
119
-
120
- $this->set_url_from_args( $url );
121
- }
122
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die( '-1' );
4
+ }
5
+
6
+ class SBY_RSS_Connect
7
+ {
8
+ /**
9
+ * @var string
10
+ */
11
+ private $url;
12
+
13
+ /**
14
+ * @var object
15
+ */
16
+ private $response;
17
+
18
+ private $is_live_stream;
19
+
20
+ public function __construct( $endpoint = '', $params = array() ) {
21
+ $this->is_live_stream = false;
22
+ if ( isset( $params['livestream'] ) ) {
23
+ $this->is_live_stream = true;
24
+ }
25
+ $this->set_url( $endpoint, $params );
26
+ }
27
+
28
+ public function get_data() {
29
+ return $this->response;
30
+ }
31
+
32
+ public function set_url_from_args( $url ) {
33
+ $this->url = $url;
34
+ }
35
+
36
+ public function get_url() {
37
+ return $this->url;
38
+ }
39
+
40
+ public function connect() {
41
+
42
+ if ( ! ini_get( 'allow_url_fopen' ) ) {
43
+ if ( ! $this->is_live_stream ) {
44
+ $error_message = '<p><b>'. __( 'Unable to retrieve new videos without an API key.', 'youtube-feed' ) .'</b></p>';
45
+ if ( current_user_can( 'manage_youtube_feed_options' ) ) {
46
+ $error_message .= '<p>' . sprintf( __( 'Due to your server configuration, an API key is required to update your feed. See %sthis FAQ%s to set up an API key.', 'youtube-feed' ), '<a href="https://smashballoon.com/youtube-api-key/" target="_blank" rel="noopener nofollow">', '</a>' ) . '</p>';
47
+ }
48
+ } else {
49
+ $error_message = '<p><b>'. __( 'Unable to retrieve new videos due to server configuration.', 'youtube-feed' ) .'</b></p>';
50
+ if ( current_user_can( 'manage_youtube_feed_options' ) ) {
51
+ $error_message .= '<p>' . sprintf( __( 'You must have the allow_url_fopen directive enabled in your server\'s php.ini file to retrieve live streams.', 'youtube-feed' ), '<a href="https://smashballoon.com/youtube-api-key/" target="_blank" rel="noopener nofollow">', '</a>' ) . '</p>';
52
+ }
53
+ }
54
+
55
+ global $sby_posts_manager;
56
+
57
+ $sby_posts_manager->add_frontend_error( 'api', $error_message );
58
+ $sby_posts_manager->add_error( 'api', array( 'Error connecting', $error_message ) );
59
+
60
+ $sby_posts_manager->add_api_request_delay( 300 );
61
+
62
+ return array();
63
+ }
64
+
65
+ if ( wp_remote_retrieve_response_code( wp_remote_get( $this->url ) ) === 404 ) {
66
+ $error_message = '<p><b>'. __( 'Cannot collect videos from this channel. Please make sure this is a valid channel ID.', 'youtube-feed' ) .'</b></p>';
67
+
68
+ global $sby_posts_manager;
69
+
70
+ $sby_posts_manager->add_frontend_error( 'api', $error_message );
71
+ $sby_posts_manager->add_error( 'api', array( 'Error connecting', $error_message ) );
72
+
73
+ $sby_posts_manager->add_api_request_delay( 300 );
74
+
75
+ return array();
76
+ }
77
+
78
+ $parsed_obj = new SimpleXMLElement( $this->url, null, true );
79
+
80
+ $items_array = array();
81
+ if ( isset( $parsed_obj->entry ) ) {
82
+ foreach ( $parsed_obj->entry as $video_xml ) {
83
+
84
+ $this_item_array = array();
85
+
86
+ $high_thumbnail_url = (string) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->thumbnail->attributes()->url;
87
+
88
+ $this_item_array['snippet'] = array(
89
+ 'publishedAt' => (string) $video_xml->published,
90
+ 'channelId' => (string) $video_xml->children( 'http://www.youtube.com/xml/schemas/2015' )->channelId,
91
+ 'title' => (string) $video_xml->title,
92
+ 'description' => (string) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->description,
93
+ 'thumbnails' => array(
94
+ 'default' => array(
95
+ 'url' => (string) str_replace( 'hqdefault.jpg', 'default.jpg', $high_thumbnail_url ),
96
+ ),
97
+ 'medium' => array(
98
+ 'url' => str_replace( 'hqdefault.jpg', 'mqdefault.jpg', $high_thumbnail_url ),
99
+ ),
100
+ 'high' => array(
101
+ 'url' => $high_thumbnail_url,
102
+ 'width' => (string) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->thumbnail->attributes()->width,
103
+ 'height' => (string) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->thumbnail->attributes()->height,
104
+ ),
105
+ 'standard' => array(
106
+ 'url' => str_replace( 'hqdefault.jpg', 'sddefault.jpg', $high_thumbnail_url ),
107
+ ),
108
+ 'maxres' => array(
109
+ 'url' => str_replace( 'hqdefault.jpg', 'maxresdefault.jpg', $high_thumbnail_url ),
110
+ ),
111
+ ),
112
+ 'channelTitle' => (string) $video_xml->author->name,
113
+ 'resourceId' => array(
114
+ 'videoId' => (string) $video_xml->children( 'http://www.youtube.com/xml/schemas/2015' )->videoId
115
+ ),
116
+ );
117
+ $this_item_array['statistics'] = array(
118
+ 'viewCount' => (int) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->community->statistics->attributes()->views,
119
+ 'starRating' => (float) $video_xml->children( 'http://search.yahoo.com/mrss/' )->group->community->starRating->attributes()->average,
120
+ );
121
+ $items_array[] = $this_item_array;
122
+
123
+ }
124
+ }
125
+
126
+
127
+ $this->response = $items_array;
128
+
129
+ }
130
+
131
+ protected function set_url( $endpoint_slug, $params ) {
132
+ $url = 'https://www.youtube.com/feeds/videos.xml?channel_id=' . $params['channel_id'];
133
+
134
+ $this->set_url_from_args( $url );
135
+ }
136
+
137
  }
inc/class-sby-settings.php CHANGED
@@ -1,352 +1,352 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- die( '-1' );
4
- }
5
-
6
- class SBY_Settings {
7
- /**
8
- * @var array
9
- */
10
- protected $atts;
11
-
12
- /**
13
- * @var array
14
- */
15
- protected $db;
16
-
17
- /**
18
- * @var array
19
- */
20
- protected $settings;
21
-
22
- /**
23
- * @var array
24
- */
25
- protected $feed_type_and_terms;
26
-
27
- /**
28
- * @var array
29
- */
30
- protected $connected_accounts;
31
-
32
- /**
33
- * @var array
34
- */
35
- protected $connected_accounts_in_feed;
36
-
37
- /**
38
- * @var string
39
- */
40
- protected $transient_name;
41
-
42
- /**
43
- * SBY_Settings constructor.
44
- *
45
- * Overwritten in the Pro version.
46
- *
47
- * @param array $atts shortcode settings
48
- * @param array $db settings from the wp_options table
49
- */
50
- public function __construct( $atts, $db ) {
51
- $atts = is_array( $atts ) ? $atts : array();
52
-
53
- // convert string 'false' and 'true' to booleans
54
- foreach ( $atts as $key => $value ) {
55
- if ( $value === 'false' ) {
56
- $atts[ $key ] = false;
57
- } elseif ( $value === 'true' ) {
58
- $atts[ $key ] = true;
59
- }
60
- }
61
-
62
- $this->atts = $atts;
63
- $this->db = $db;
64
-
65
- $this->connected_accounts = isset( $db['connected_accounts'] ) ? $db['connected_accounts'] : array();
66
-
67
- if ( ! empty( $this->db['api_key'] ) ) {
68
- $this->connected_accounts = array(
69
- 'own' => array(
70
- 'access_token' => '',
71
- 'refresh_token' => '',
72
- 'channel_id' => '',
73
- 'username' => '',
74
- 'is_valid' => true,
75
- 'last_checked' => '',
76
- 'profile_picture' => '',
77
- 'privacy' => '',
78
- 'expires' => '2574196927',
79
- 'api_key' => $this->db['api_key']
80
- )
81
- );
82
- }
83
-
84
- $this->settings = wp_parse_args( $atts, $db );
85
-
86
- if ( empty( $this->connected_accounts ) ) {
87
- $this->settings['showheader'] = false;
88
- $this->connected_accounts = array( 'rss_only' => true );
89
- }
90
-
91
- $this->settings['nummobile'] = $this->settings['num'];
92
- $this->settings['minnum'] = $this->settings['num'];
93
-
94
- $this->after_settings_set();
95
- }
96
-
97
- protected function after_settings_set() {
98
-
99
- }
100
-
101
- /**
102
- * @return array
103
- *
104
- * @since 1.0
105
- */
106
- public function get_settings() {
107
- return $this->settings;
108
- }
109
-
110
- /**
111
- * The plugin will output settings on the frontend for debugging purposes.
112
- * Safe settings to display are added here.
113
- *
114
- * Overwritten in the Pro version.
115
- *
116
- * @return array
117
- *
118
- * @since 1.0
119
- */
120
- public static function get_public_db_settings_keys() {
121
- $public = array(
122
- );
123
-
124
- return $public;
125
- }
126
-
127
- /**
128
- * @return array
129
- *
130
- * @since 1.0
131
- */
132
- public function get_connected_accounts() {
133
- return $this->connected_accounts;
134
- }
135
-
136
- /**
137
- * @return array|bool
138
- *
139
- * @since 1.0
140
- */
141
- public function get_connected_accounts_in_feed() {
142
- if ( isset( $this->connected_accounts_in_feed ) ) {
143
- return $this->connected_accounts_in_feed;
144
- } else {
145
- return false;
146
- }
147
- }
148
-
149
- /**
150
- * @return bool|string
151
- *
152
- * @since 1.0
153
- */
154
- public function get_transient_name() {
155
- if ( isset( $this->transient_name ) ) {
156
- return $this->transient_name;
157
- } else {
158
- return false;
159
- }
160
- }
161
-
162
- /**
163
- * Uses the feed types and terms as well as as some
164
- * settings to create a semi-unique feed id used for
165
- * caching and other features.
166
- *
167
- * Overwritten in the Pro version.
168
- *
169
- * @param string $transient_name
170
- *
171
- * @since 1.0
172
- */
173
- public function set_transient_name( $transient_name = '' ) {
174
-
175
- if ( ! empty( $transient_name ) ) {
176
- $this->transient_name = $transient_name;
177
- } elseif ( ! empty( $this->settings['feedid'] ) ) {
178
- $this->transient_name = 'sby_' . $this->settings['feedid'];
179
- } else {
180
- $feed_type_and_terms = $this->feed_type_and_terms;
181
-
182
- $sby_transient_name = 'sby_';
183
-
184
- if ( isset( $feed_type_and_terms['channels'] ) ) {
185
- foreach ( $feed_type_and_terms['channels'] as $term_and_params ) {
186
- $channel = $term_and_params['term'];
187
- $sby_transient_name .= $channel;
188
- }
189
- }
190
-
191
- $num = $this->settings['num'];
192
-
193
- $num_length = strlen( $num ) + 1;
194
-
195
- //Add both parts of the caching string together and make sure it doesn't exceed 45
196
- $sby_transient_name = substr( $sby_transient_name, 0, 45 - $num_length );
197
-
198
- $sby_transient_name .= '#' . $num;
199
-
200
- $this->transient_name = $sby_transient_name;
201
- }
202
-
203
- }
204
-
205
- /**
206
- * @return array|bool
207
- *
208
- * @since 1.0
209
- */
210
- public function get_feed_type_and_terms() {
211
- if ( isset( $this->feed_type_and_terms ) ) {
212
- return $this->feed_type_and_terms;
213
- } else {
214
- return false;
215
- }
216
- }
217
-
218
- /**
219
- * Based on the settings related to retrieving post data from the API,
220
- * this setting is used to make sure all endpoints needed for the feed are
221
- * connected and stored for easily looping through when adding posts
222
- *
223
- * Overwritten in the Pro version.
224
- *
225
- * @since 1.0
226
- */
227
- public function set_feed_type_and_terms() {
228
- //global $sby_posts_manager;
229
-
230
- $connected_accounts_in_feed = array();
231
- $feed_type_and_terms = array(
232
- 'channels' => array()
233
- );
234
-
235
- if ( ! empty( $this->settings['id'] ) ) {
236
- $channel_array = is_array( $this->settings['id'] ) ? $this->settings['id'] : explode( ',', str_replace( ' ', '', $this->settings['id'] ) );
237
- foreach ( $channel_array as $channel ) {
238
- if ( isset( $this->connected_accounts[ $channel ] ) ) {
239
- $feed_type_and_terms['channels'][] = array(
240
- 'term' => $this->connected_accounts[ $channel ]['channel_id'],
241
- 'params' => array(
242
- 'channel_id' => $this->connected_accounts[ $channel ]['channel_id']
243
- )
244
- );
245
- $connected_accounts_in_feed[ $this->connected_accounts[ $channel ]['channel_id'] ] = $this->connected_accounts[ $channel ];
246
- }
247
- }
248
-
249
- if ( empty( $connected_accounts_in_feed ) ) {
250
- $an_account = array();
251
- foreach ( $this->connected_accounts as $account ) {
252
- if ( empty( $an_account ) ) {
253
- $an_account = $account;
254
- }
255
- }
256
-
257
- foreach ( $channel_array as $channel ) {
258
- $feed_type_and_terms['channels'][] = array(
259
- 'term' => $channel,
260
- 'params' => array(
261
- 'channel_id' => $channel
262
- )
263
- );
264
- $connected_accounts_in_feed[ $channel ] = $an_account;
265
- }
266
- }
267
-
268
- } elseif ( ! empty( $this->settings['channel'] ) ) {
269
- $channel_array = is_array( $this->settings['channel'] ) ? $this->settings['channel'] : explode( ',', str_replace( ' ', '', $this->settings['channel'] ) );
270
-
271
- $an_account = array();
272
- foreach ( $this->connected_accounts as $account ) {
273
- if ( empty( $an_account ) ) {
274
- $an_account = $account;
275
- }
276
- }
277
-
278
- foreach ( $channel_array as $channel ) {
279
- if ( strpos( $channel, 'UC' ) !== 0 ) {
280
- $channel_id = sby_get_channel_id_from_channel_name( $channel );
281
- if ( $channel_id ) {
282
- $feed_type_and_terms['channels'][] = array(
283
- 'term' => $channel_id,
284
- 'params' => array(
285
- 'channel_id' => $channel_id
286
- )
287
- );
288
- $connected_accounts_in_feed[ $channel_id ] = $an_account;
289
- } else {
290
- $feed_type_and_terms['channels'][] = array(
291
- 'term' => $channel,
292
- 'params' => array(
293
- 'channel_name' => $channel
294
- )
295
- );
296
- $connected_accounts_in_feed[ $channel ] = $an_account;
297
- }
298
-
299
- } else {
300
- $feed_type_and_terms['channels'][] = array(
301
- 'term' => $channel,
302
- 'params' => array(
303
- 'channel_id' => $channel
304
- )
305
- );
306
- $connected_accounts_in_feed[ $channel ] = $an_account;
307
- }
308
- }
309
-
310
- } else {
311
- foreach ( $this->connected_accounts as $connected_account ) {
312
- if ( empty( $feed_type_and_terms['channels'] ) ) {
313
- $feed_type_and_terms['channels'][] = array(
314
- 'term' => $connected_account['channel_id'],
315
- 'params' => array(
316
- 'channel_id' => $connected_account['channel_id']
317
- )
318
- );
319
- $connected_accounts_in_feed[ $connected_account['channel_id'] ] = $connected_account;
320
- }
321
-
322
- }
323
- }
324
-
325
- $this->connected_accounts_in_feed = $connected_accounts_in_feed;
326
- $this->feed_type_and_terms = $feed_type_and_terms;
327
- }
328
-
329
- /**
330
- * @return float|int
331
- *
332
- * @since 1.0
333
- */
334
- public function get_cache_time_in_seconds() {
335
- if ( $this->db['caching_type'] === 'background' ) {
336
- return SBY_CRON_UPDATE_CACHE_TIME;
337
- } else {
338
- //If the caching time doesn't exist in the database then set it to be 1 hour
339
- $cache_time = isset( $this->settings['cache_time'] ) ? (int)$this->settings['cache_time'] : 1;
340
- $cache_time_unit = isset( $this->settings['cache_time_unit'] ) ? $this->settings['cache_time_unit'] : 'hours';
341
-
342
- //Calculate the cache time in seconds
343
- if ( $cache_time_unit == 'minutes' ) $cache_time_unit = 60;
344
- if ( $cache_time_unit == 'hours' ) $cache_time_unit = 60*60;
345
- if ( $cache_time_unit == 'days' ) $cache_time_unit = 60*60*24;
346
-
347
- $cache_time = max( 900, $cache_time * $cache_time_unit );
348
-
349
- return $cache_time;
350
- }
351
- }
352
  }
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die( '-1' );
4
+ }
5
+
6
+ class SBY_Settings {
7
+ /**
8
+ * @var array
9
+ */
10
+ protected $atts;
11
+
12
+ /**
13
+ * @var array
14
+ */
15
+ protected $db;
16
+
17
+ /**
18
+ * @var array
19
+ */
20
+ protected $settings;
21
+
22
+ /**
23
+ * @var array
24
+ */
25
+ protected $feed_type_and_terms;
26
+
27
+ /**
28
+ * @var array
29
+ */
30
+ protected $connected_accounts;
31
+
32
+ /**
33
+ * @var array
34
+ */
35
+ protected $connected_accounts_in_feed;
36
+
37
+ /**
38
+ * @var string
39
+ */
40
+ protected $transient_name;
41
+
42
+ /**
43
+ * SBY_Settings constructor.
44
+ *
45
+ * Overwritten in the Pro version.
46
+ *
47
+ * @param array $atts shortcode settings
48
+ * @param array $db settings from the wp_options table
49
+ */
50
+ public function __construct( $atts, $db ) {
51
+ $atts = is_array( $atts ) ? $atts : array();
52
+
53
+ // convert string 'false' and 'true' to booleans
54
+ foreach ( $atts as $key => $value ) {
55
+ if ( $value === 'false' ) {
56
+ $atts[ $key ] = false;
57
+ } elseif ( $value === 'true' ) {
58
+ $atts[ $key ] = true;
59
+ }
60
+ }
61
+
62
+ $this->atts = $atts;
63
+ $this->db = $db;
64
+
65
+ $this->connected_accounts = isset( $db['connected_accounts'] ) ? $db['connected_accounts'] : array();
66
+
67
+ if ( ! empty( $this->db['api_key'] ) ) {
68
+ $this->connected_accounts = array(
69
+ 'own' => array(
70
+ 'access_token' => '',
71
+ 'refresh_token' => '',
72
+ 'channel_id' => '',
73
+ 'username' => '',
74
+ 'is_valid' => true,
75
+ 'last_checked' => '',
76
+ 'profile_picture' => '',
77
+ 'privacy' => '',
78
+ 'expires' => '2574196927',
79
+ 'api_key' => $this->db['api_key']
80
+ )
81
+ );
82
+ }
83
+
84
+ $this->settings = wp_parse_args( $atts, $db );
85
+
86
+ if ( empty( $this->connected_accounts ) ) {
87
+ $this->settings['showheader'] = false;
88
+ $this->connected_accounts = array( 'rss_only' => true );
89
+ }
90
+
91
+ $this->settings['nummobile'] = $this->settings['num'];
92
+ $this->settings['minnum'] = $this->settings['num'];
93
+
94
+ $this->after_settings_set();
95
+ }
96
+
97
+ protected function after_settings_set() {
98
+
99
+ }
100
+
101
+ /**
102
+ * @return array
103
+ *
104
+ * @since 1.0
105
+ */
106
+ public function get_settings() {
107
+ return $this->settings;
108
+ }
109
+
110
+ /**
111
+ * The plugin will output settings on the frontend for debugging purposes.
112
+ * Safe settings to display are added here.
113
+ *
114
+ * Overwritten in the Pro version.
115
+ *
116
+ * @return array
117
+ *
118
+ * @since 1.0
119
+ */
120
+ public static function get_public_db_settings_keys() {
121
+ $public = array(
122
+ );
123
+
124
+ return $public;
125
+ }
126
+
127
+ /**
128
+ * @return array
129
+ *
130
+ * @since 1.0
131
+ */
132
+ public function get_connected_accounts() {
133
+ return $this->connected_accounts;
134
+ }
135
+
136
+ /**
137
+ * @return array|bool
138
+ *
139
+ * @since 1.0
140
+ */
141
+ public function get_connected_accounts_in_feed() {
142
+ if ( isset( $this->connected_accounts_in_feed ) ) {
143
+ return $this->connected_accounts_in_feed;
144
+ } else {
145
+ return false;
146
+ }
147
+ }
148
+
149
+ /**
150
+ * @return bool|string
151
+ *
152
+ * @since 1.0
153
+ */
154
+ public function get_transient_name() {
155
+ if ( isset( $this->transient_name ) ) {
156
+ return $this->transient_name;
157
+ } else {
158
+ return false;
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Uses the feed types and terms as well as as some
164
+ * settings to create a semi-unique feed id used for
165
+ * caching and other features.
166
+ *
167
+ * Overwritten in the Pro version.
168
+ *
169
+ * @param string $transient_name
170
+ *
171
+ * @since 1.0
172
+ */
173
+ public function set_transient_name( $transient_name = '' ) {
174
+
175
+ if ( ! empty( $transient_name ) ) {
176
+ $this->transient_name = $transient_name;
177
+ } elseif ( ! empty( $this->settings['feedid'] ) ) {
178
+ $this->transient_name = 'sby_' . $this->settings['feedid'];
179
+ } else {
180
+ $feed_type_and_terms = $this->feed_type_and_terms;
181
+
182
+ $sby_transient_name = 'sby_';
183
+
184
+ if ( isset( $feed_type_and_terms['channels'] ) ) {
185
+ foreach ( $feed_type_and_terms['channels'] as $term_and_params ) {
186
+ $channel = $term_and_params['term'];
187
+ $sby_transient_name .= $channel;
188
+ }
189
+ }
190
+
191
+ $num = $this->settings['num'];
192
+
193
+ $num_length = strlen( $num ) + 1;
194
+
195
+ //Add both parts of the caching string together and make sure it doesn't exceed 45
196
+ $sby_transient_name = substr( $sby_transient_name, 0, 45 - $num_length );
197
+
198
+ $sby_transient_name .= '#' . $num;
199
+
200
+ $this->transient_name = $sby_transient_name;
201
+ }
202
+
203
+ }
204
+
205
+ /**
206
+ * @return array|bool
207
+ *
208
+ * @since 1.0
209
+ */
210
+ public function get_feed_type_and_terms() {
211
+ if ( isset( $this->feed_type_and_terms ) ) {
212
+ return $this->feed_type_and_terms;
213
+ } else {
214
+ return false;
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Based on the settings related to retrieving post data from the API,
220
+ * this setting is used to make sure all endpoints needed for the feed are
221
+ * connected and stored for easily looping through when adding posts
222
+ *
223
+ * Overwritten in the Pro version.
224
+ *
225
+ * @since 1.0
226
+ */
227
+ public function set_feed_type_and_terms() {
228
+ //global $sby_posts_manager;
229
+
230
+ $connected_accounts_in_feed = array();
231
+ $feed_type_and_terms = array(
232
+ 'channels' => array()
233
+ );
234
+
235
+ if ( ! empty( $this->settings['id'] ) ) {
236
+ $channel_array = is_array( $this->settings['id'] ) ? $this->settings['id'] : explode( ',', str_replace( ' ', '', $this->settings['id'] ) );
237
+ foreach ( $channel_array as $channel ) {
238
+ if ( isset( $this->connected_accounts[ $channel ] ) ) {
239
+ $feed_type_and_terms['channels'][] = array(
240
+ 'term' => $this->connected_accounts[ $channel ]['channel_id'],
241
+ 'params' => array(
242
+ 'channel_id' => $this->connected_accounts[ $channel ]['channel_id']
243
+ )
244
+ );
245
+ $connected_accounts_in_feed[ $this->connected_accounts[ $channel ]['channel_id'] ] = $this->connected_accounts[ $channel ];
246
+ }
247
+ }
248
+
249
+ if ( empty( $connected_accounts_in_feed ) ) {
250
+ $an_account = array();
251
+ foreach ( $this->connected_accounts as $account ) {
252
+ if ( empty( $an_account ) ) {
253
+ $an_account = $account;
254
+ }
255
+ }
256
+
257
+ foreach ( $channel_array as $channel ) {
258
+ $feed_type_and_terms['channels'][] = array(
259
+ 'term' => $channel,
260
+ 'params' => array(
261
+ 'channel_id' => $channel
262
+ )
263
+ );
264
+ $connected_accounts_in_feed[ $channel ] = $an_account;
265
+ }
266
+ }
267
+
268
+ } elseif ( ! empty( $this->settings['channel'] ) ) {
269
+ $channel_array = is_array( $this->settings['channel'] ) ? $this->settings['channel'] : explode( ',', str_replace( ' ', '', $this->settings['channel'] ) );
270
+
271
+ $an_account = array();
272
+ foreach ( $this->connected_accounts as $account ) {
273
+ if ( empty( $an_account ) ) {
274
+ $an_account = $account;
275
+ }
276
+ }
277
+
278
+ foreach ( $channel_array as $channel ) {
279
+ if ( strpos( $channel, 'UC' ) !== 0 ) {
280
+ $channel_id = sby_get_channel_id_from_channel_name( $channel );
281
+ if ( $channel_id ) {
282
+ $feed_type_and_terms['channels'][] = array(
283
+ 'term' => $channel_id,
284
+ 'params' => array(
285
+ 'channel_id' => $channel_id
286
+ )
287
+ );
288
+ $connected_accounts_in_feed[ $channel_id ] = $an_account;
289
+ } else {
290
+ $feed_type_and_terms['channels'][] = array(
291
+ 'term' => $channel,
292
+ 'params' => array(
293
+ 'channel_name' => $channel
294
+ )
295
+ );
296
+ $connected_accounts_in_feed[ $channel ] = $an_account;
297
+ }
298
+
299
+ } else {
300
+ $feed_type_and_terms['channels'][] = array(
301
+ 'term' => $channel,
302
+ 'params' => array(
303
+ 'channel_id' => $channel
304
+ )
305
+ );
306
+ $connected_accounts_in_feed[ $channel ] = $an_account;
307
+ }
308
+ }
309
+
310
+ } else {
311
+ foreach ( $this->connected_accounts as $connected_account ) {
312
+ if ( empty( $feed_type_and_terms['channels'] ) ) {
313
+ $feed_type_and_terms['channels'][] = array(
314
+ 'term' => $connected_account['channel_id'],
315
+ 'params' => array(
316
+ 'channel_id' => $connected_account['channel_id']
317
+ )
318
+ );
319
+ $connected_accounts_in_feed[ $connected_account['channel_id'] ] = $connected_account;
320
+ }
321
+
322
+ }
323
+ }
324
+
325
+ $this->connected_accounts_in_feed = $connected_accounts_in_feed;
326
+ $this->feed_type_and_terms = $feed_type_and_terms;
327
+ }
328
+
329
+ /**
330
+ * @return float|int
331
+ *
332
+ * @since 1.0
333
+ */
334
+ public function get_cache_time_in_seconds() {
335
+ if ( $this->db['caching_type'] === 'background' ) {
336
+ return SBY_CRON_UPDATE_CACHE_TIME;
337
+ } else {
338
+ //If the caching time doesn't exist in the database then set it to be 1 hour
339
+ $cache_time = isset( $this->settings['cache_time'] ) ? (int)$this->settings['cache_time'] : 1;
340
+ $cache_time_unit = isset( $this->settings['cache_time_unit'] ) ? $this->settings['cache_time_unit'] : 'hours';
341
+
342
+ //Calculate the cache time in seconds
343
+ if ( $cache_time_unit == 'minutes' ) $cache_time_unit = 60;
344
+ if ( $cache_time_unit == 'hours' ) $cache_time_unit = 60*60;
345
+ if ( $cache_time_unit == 'days' ) $cache_time_unit = 60*60*24;
346
+
347
+ $cache_time = max( 900, $cache_time * $cache_time_unit );
348
+
349
+ return $cache_time;
350
+ }
351
+ }
352
  }
inc/class-sby-vars.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- die( '-1' );
4
- }
5
-
6
- class SBY_Vars {
7
- public function version() { return SBYVER; }
8
-
9
- public function plugin_dir() { return SBY_PLUGIN_DIR; }
10
-
11
- public function plugin_url() { return SBY_PLUGIN_URL; }
12
-
13
- public function plugin_basename() { return SBY_PLUGIN_BASENAME; }
14
-
15
- public function cron_update_cache_time() { return SBY_CRON_UPDATE_CACHE_TIME; }
16
-
17
- public function max_records() { return SBY_MAX_RECORDS; }
18
-
19
- public function text_domain() { return SBY_TEXT_DOMAIN; }
20
-
21
- public function slug() { return SBY_SLUG; }
22
-
23
- public function plugin_name( $with_a_an = false ) { if ( $with_a_an ) { return SBY_INDEF_ART . ' ' . SBY_PLUGIN_NAME; } return SBY_PLUGIN_NAME; }
24
-
25
- public function social_network() { return SBY_SOCIAL_NETWORK; }
26
-
27
- public function setup_url() { return SBY_SETUP_URL; }
28
-
29
- public function support_url() { return SBY_SUPPORT_URL; }
30
-
31
- public function oauth_processor_url() { return SBY_OAUTH_PROCESSOR_URL; }
32
-
33
- public function demo_url() { return SBY_DEMO_URL; }
34
-
35
- public function pro_logo() { return SBY_PRO_LOGO; }
36
  }
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die( '-1' );
4
+ }
5
+
6
+ class SBY_Vars {
7
+ public function version() { return SBYVER; }
8
+
9
+ public function plugin_dir() { return SBY_PLUGIN_DIR; }
10
+
11
+ public function plugin_url() { return SBY_PLUGIN_URL; }
12
+
13
+ public function plugin_basename() { return SBY_PLUGIN_BASENAME; }
14
+
15
+ public function cron_update_cache_time() { return SBY_CRON_UPDATE_CACHE_TIME; }
16
+
17
+ public function max_records() { return SBY_MAX_RECORDS; }
18
+
19
+ public function text_domain() { return SBY_TEXT_DOMAIN; }
20
+
21
+ public function slug() { return SBY_SLUG; }
22
+
23
+ public function plugin_name( $with_a_an = false ) { if ( $with_a_an ) { return SBY_INDEF_ART . ' ' . SBY_PLUGIN_NAME; } return SBY_PLUGIN_NAME; }
24
+
25
+ public function social_network() { return SBY_SOCIAL_NETWORK; }
26
+
27
+ public function setup_url() { return SBY_SETUP_URL; }
28
+
29
+ public function support_url() { return SBY_SUPPORT_URL; }
30
+
31
+ public function oauth_processor_url() { return SBY_OAUTH_PROCESSOR_URL; }
32
+
33
+ public function demo_url() { return SBY_DEMO_URL; }
34
+
35
+ public function pro_logo() { return SBY_PRO_LOGO; }
36
  }
inc/class-sby-wp-post.php CHANGED
@@ -1,166 +1,166 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- die( '-1' );
4
- }
5
-
6
- class SBY_WP_Post
7
- {
8
- private $youtube_api_data;
9
-
10
- private $feed_id;
11
-
12
- private $wp_post_id;
13
-
14
- public function __construct( $json_or_array, $feed_id ) {
15
- $this->youtube_api_data = $json_or_array;
16
- $this->feed_id = $feed_id;
17
- }
18
-
19
- public function update_post( $status = 'draft' ) {
20
- if ( ! $this->get_wp_post_id() ) {
21
- $postarr = array(
22
- 'post_title' => SBY_Parse::get_video_title( $this->youtube_api_data ),
23
- 'post_content' => $this->get_post_content(),
24
- 'post_type' => SBY_CPT,
25
- 'post_date' => date( 'Y-m-d H:i:s', SBY_Parse::get_timestamp( $this->youtube_api_data ) + sby_get_utc_offset() ),
26
- 'post_date_gmt' => date( 'Y-m-d H:i:s', SBY_Parse::get_timestamp( $this->youtube_api_data ) ),
27
- 'post_status' => $status
28
- );
29
- $wp_post_id = wp_insert_post( $postarr );
30
-
31
- if ( (int)$wp_post_id > 0 ) {
32
- $this->wp_post_id = $wp_post_id;
33
-
34
- $success = $this->update_meta();
35
- }
36
- }
37
-
38
- }
39
-
40
- public function update_meta() {
41
- if ( ! isset( $this->wp_post_id ) ) {
42
- return false;
43
- }
44
-
45
- $prefix = 'sby_';
46
-
47
- update_post_meta( $this->wp_post_id, $prefix . 'video_id', SBY_Parse::get_video_id( $this->youtube_api_data ) );
48
- update_post_meta( $this->wp_post_id, $prefix . 'feed_id', sby_strip_after_hash( $this->feed_id ) );
49
- update_post_meta( $this->wp_post_id, $prefix . 'channel_id', SBY_Parse::get_channel_id( $this->youtube_api_data ) );
50
- update_post_meta( $this->wp_post_id, $prefix . 'channel_title', SBY_Parse::get_channel_title( $this->youtube_api_data ) );
51
- update_post_meta( $this->wp_post_id, $prefix . 'description', SBY_Parse::get_caption( $this->youtube_api_data ) );
52
- update_post_meta( $this->wp_post_id, $prefix . 'last_updated', date( 'Y-m-d H:i:s' ) );
53
- update_post_meta( $this->wp_post_id, $prefix . 'thumbnails', SBY_Parse::get_media_src_set( $this->youtube_api_data ) );
54
- update_post_meta( $this->wp_post_id, $prefix . 'youtube_publish_date', date( 'Y-m-d H:i:s', SBY_Parse::get_timestamp( $this->youtube_api_data ) ) );
55
-
56
- if ( class_exists( 'SBY_Parse_Pro' ) ) {
57
- update_post_meta( $this->wp_post_id, $prefix . 'live_broadcast_content', SBY_Parse_Pro::get_live_broadcast_content( $this->youtube_api_data ) );
58
- }
59
-
60
- $post_array = $this->youtube_api_data;
61
-
62
- array_walk_recursive( $post_array, 'sby_replace_double_quotes' );
63
-
64
- update_post_meta( $this->wp_post_id, $prefix . 'json', esc_sql( wp_json_encode( $post_array ) ) );
65
-
66
- return true;
67
- }
68
-
69
- public function post_content_description_is_incomplete() {
70
- $content = get_the_content( '', false, $this->get_wp_post_id() );
71
-
72
- return (strpos( $content, '<!-- sby:description-incomplete -->' ) !== false);
73
- }
74
-
75
- public function update_video_details() {
76
- if ( empty( $this->youtube_api_data['statistics'] ) ) {
77
- return false;
78
- }
79
-
80
- $post_id = $this->get_wp_post_id();
81
-
82
- if ( $post_id ) {
83
- $prefix = 'sby_';
84
-
85
- if ( class_exists( 'SBY_Parse_Pro' ) ) {
86
- update_post_meta( $post_id, $prefix . 'comment_count', SBY_Parse_Pro::get_comment_count( $this->youtube_api_data ) );
87
- update_post_meta( $post_id, $prefix . 'view_count', SBY_Parse_Pro::get_view_count( $this->youtube_api_data ) );
88
- update_post_meta( $post_id, $prefix . 'like_count', SBY_Parse_Pro::get_like_count( $this->youtube_api_data ) );
89
- update_post_meta( $post_id, $prefix . 'scheduled_start_time', date( 'Y-m-d H:i:s', SBY_Parse_Pro::get_scheduled_start_timestamp( $this->youtube_api_data ) ) );
90
- update_post_meta( $post_id, $prefix . 'actual_start_time', date( 'Y-m-d H:i:s', SBY_Parse_Pro::get_actual_start_timestamp( $this->youtube_api_data ) ) );
91
- update_post_meta( $post_id, $prefix . 'actual_end_time', date( 'Y-m-d H:i:s', SBY_Parse_Pro::get_actual_end_timestamp( $this->youtube_api_data ) ) );
92
- }
93
-
94
- update_post_meta( $post_id, $prefix . 'last_details_check_time', date( 'Y-m-d H:i:s' ) );
95
- $description = SBY_Parse::get_caption( $this->youtube_api_data );
96
- if ( ! empty( $description ) ) {
97
- update_post_meta( $post_id, $prefix . 'description', $description );
98
- if ( $this->post_content_description_is_incomplete() ) {
99
- $this->update_content();
100
- }
101
- }
102
- return true;
103
- }
104
-
105
- return false;
106
- }
107
- public function update_content() {
108
- $my_post = array();
109
- $my_post['ID'] = $this->get_wp_post_id();
110
- $my_post['post_content'] = $this->get_post_content( true );
111
-
112
- wp_update_post( $my_post );
113
- }
114
-
115
- public static function maybe_get_channel_id_for_name( $name ) {
116
-
117
- }
118
-
119
- public static function maybe_get_channel_id_for_channel_title( $title ) {
120
- global $wpdb;
121
-
122
- $channel_id = $wpdb->get_col( $wpdb->prepare( "
123
- SELECT Max(CASE
124
- WHEN m.meta_key = 'sby_channel_id' THEN m.meta_value
125
- ELSE NULL
126
- END) AS sby_channel_id
127
- FROM $wpdb->postmeta as m
128
- WHERE m.post_id IN (SELECT m2.post_id FROM $wpdb->postmeta as m2 WHERE m2.meta_key = 'sby_channel_title' AND m2.meta_value = %s )
129
- GROUP BY m.post_id
130
- LIMIT 1", $title ) );
131
-
132
- if ( isset( $channel_id[0] ) ) {
133
- return $channel_id[0];
134
- }
135
- return false;
136
- }
137
-
138
- public function get_wp_post_id() {
139
- if ( isset( $this->wp_post_id ) ) {
140
- return $this->wp_post_id;
141
- }
142
-
143
- $video_id = SBY_Parse::get_video_id( $this->youtube_api_data );
144
-
145
- global $wpdb;
146
- $results = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE meta_value = %s AND meta_key = %s", $video_id, 'sby_video_id' ), ARRAY_A );
147
-
148
- if ( isset( $results[0] ) ) {
149
- $this->wp_post_id = $results[0]['post_id'];
150
-
151
- return $results[0]['post_id'];
152
- } else {
153
- return false;
154
- }
155
- }
156
-
157
- protected function get_post_content( $override = false ) {
158
- $description = SBY_Parse::get_caption( $this->youtube_api_data );
159
- $flag = '';
160
- if ( ! $override && substr( $description, -3 ) === '...' ) {
161
- $flag = '<!-- sby:description-incomplete -->';
162
- }
163
-
164
- return '['.SBY_SLUG.'-single]<!-- sby:description-start -->' . wp_kses_post( $description ) . '<!-- sby:description-end -->' . $flag;
165
- }
166
  }
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ die( '-1' );
4
+ }
5
+
6
+ class SBY_WP_Post
7
+ {
8
+ private $youtube_api_data;
9
+
10
+ private $feed_id;
11
+
12
+ private $wp_post_id;
13
+
14
+ public function __construct( $json_or_array, $feed_id ) {
15
+ $this->youtube_api_data = $json_or_array;
16
+ $this->feed_id = $feed_id;
17
+ }
18
+
19
+ public function update_post( $status = 'draft' ) {
20
+ if ( ! $this->get_wp_post_id() ) {
21
+ $postarr = array(
22
+ 'post_title' => SBY_Parse::get_video_title( $this->youtube_api_data ),
23
+ 'post_content' => $this->get_post_content(),
24
+ 'post_type' => SBY_CPT,
25
+ 'post_date' => date( 'Y-m-d H:i:s', SBY_Parse::get_timestamp( $this->youtube_api_data ) + sby_get_utc_offset() ),
26
+ 'post_date_gmt' => date( 'Y-m-d H:i:s', SBY_Parse::get_timestamp( $this->youtube_api_data ) ),
27
+ 'post_status' => $status
28
+ );
29
+ $wp_post_id = wp_insert_post( $postarr );
30
+
31
+ if ( (int)$wp_post_id > 0 ) {
32
+ $this->wp_post_id = $wp_post_id;
33
+
34
+ $success = $this->update_meta();
35
+ }
36
+ }
37
+
38
+ }
39
+
40
+ public function update_meta() {
41
+ if ( ! isset( $this->wp_post_id ) ) {
42
+ return false;
43
+ }
44
+
45
+ $prefix = 'sby_';
46
+
47
+ update_post_meta( $this->wp_post_id, $prefix . 'video_id', SBY_Parse::get_video_id( $this->youtube_api_data ) );
48
+ update_post_meta( $this->wp_post_id, $prefix . 'feed_id', sby_strip_after_hash( $this->feed_id ) );
49
+ update_post_meta( $this->wp_post_id, $prefix . 'channel_id', SBY_Parse::get_channel_id( $this->youtube_api_data ) );
50
+ update_post_meta( $this->wp_post_id, $prefix . 'channel_title', SBY_Parse::get_channel_title( $this->youtube_api_data ) );
51
+ update_post_meta( $this->wp_post_id, $prefix . 'description', SBY_Parse::get_caption( $this->youtube_api_data ) );
52
+ update_post_meta( $this->wp_post_id, $prefix . 'last_updated', date( 'Y-m-d H:i:s' ) );
53
+ update_post_meta( $this->wp_post_id, $prefix . 'thumbnails', SBY_Parse::get_media_src_set( $this->youtube_api_data ) );
54
+ update_post_meta( $this->wp_post_id, $prefix . 'youtube_publish_date', date( 'Y-m-d H:i:s', SBY_Parse::get_timestamp( $this->youtube_api_data ) ) );
55
+
56
+ if ( class_exists( 'SBY_Parse_Pro' ) ) {
57
+ update_post_meta( $this->wp_post_id, $prefix . 'live_broadcast_content', SBY_Parse_Pro::get_live_broadcast_content( $this->youtube_api_data ) );
58
+ }
59
+
60
+ $post_array = $this->youtube_api_data;
61
+
62
+ array_walk_recursive( $post_array, 'sby_replace_double_quotes' );
63
+
64
+ update_post_meta( $this->wp_post_id, $prefix . 'json', esc_sql( wp_json_encode( $post_array ) ) );
65
+
66
+ return true;
67
+ }
68
+
69
+ public function post_content_description_is_incomplete() {
70
+ $content = get_the_content( '', false, $this->get_wp_post_id() );
71
+
72
+ return (strpos( $content, '<!-- sby:description-incomplete -->' ) !== false);
73
+ }
74
+
75
+ public function update_video_details() {
76
+ if ( empty( $this->youtube_api_data['statistics'] ) ) {
77
+ return false;
78
+ }
79
+
80
+ $post_id = $this->get_wp_post_id();
81
+
82
+ if ( $post_id ) {
83
+ $prefix = 'sby_';
84
+
85
+ if ( class_exists( 'SBY_Parse_Pro' ) ) {
86
+ update_post_meta( $post_id, $prefix . 'comment_count', SBY_Parse_Pro::get_comment_count( $this->youtube_api_data ) );
87
+ update_post_meta( $post_id, $prefix . 'view_count', SBY_Parse_Pro::get_view_count( $this->youtube_api_data ) );
88
+ update_post_meta( $post_id, $prefix . 'like_count', SBY_Parse_Pro::get_like_count( $this->youtube_api_data ) );
89
+ update_post_meta( $post_id, $prefix . 'scheduled_start_time', date( 'Y-m-d H:i:s', SBY_Parse_Pro::get_scheduled_start_timestamp( $this->youtube_api_data ) ) );
90
+ update_post_meta( $post_id, $prefix . 'actual_start_time', date( 'Y-m-d H:i:s', SBY_Parse_Pro::get_actual_start_timestamp( $this->youtube_api_data ) ) );
91
+ update_post_meta( $post_id, $prefix . 'actual_end_time', date( 'Y-m-d H:i:s', SBY_Parse_Pro::get_actual_end_timestamp( $this->youtube_api_data ) ) );
92
+ }
93
+
94
+ update_post_meta( $post_id, $prefix . 'last_details_check_time', date( 'Y-m-d H:i:s' ) );
95
+ $description = SBY_Parse::get_caption( $this->youtube_api_data );
96
+ if ( ! empty( $description ) ) {
97
+ update_post_meta( $post_id, $prefix . 'description', $description );
98
+ if ( $this->post_content_description_is_incomplete() ) {
99
+ $this->update_content();
100
+ }
101
+ }
102
+ return true;
103
+ }
104
+
105
+ return false;
106
+ }
107
+ public function update_content() {
108
+ $my_post = array();
109
+ $my_post['ID'] = $this->get_wp_post_id();
110
+ $my_post['post_content'] = $this->get_post_content( true );
111
+
112
+ wp_update_post( $my_post );
113
+ }
114
+
115
+ public static function maybe_get_channel_id_for_name( $name ) {
116
+
117
+ }
118
+
119
+ public static function maybe_get_channel_id_for_channel_title( $title ) {
120
+ global $wpdb;
121
+
122
+ $channel_id = $wpdb->get_col( $wpdb->prepare( "
123
+ SELECT Max(CASE
124
+ WHEN m.meta_key = 'sby_channel_id' THEN m.meta_value
125
+ ELSE NULL
126
+ END) AS sby_channel_id
127
+ FROM $wpdb->postmeta as m
128
+ WHERE m.post_id IN (SELECT m2.post_id FROM $wpdb->postmeta as m2 WHERE m2.meta_key = 'sby_channel_title' AND m2.meta_value = %s )
129
+ GROUP BY m.post_id
130
+ LIMIT 1", $title ) );
131
+
132
+ if ( isset( $channel_id[0] ) ) {
133
+ return $channel_id[0];
134
+ }
135
+ return false;
136
+ }
137
+
138
+ public function get_wp_post_id() {
139
+ if ( isset( $this->wp_post_id ) ) {
140
+ return $this->wp_post_id;
141
+ }
142
+
143
+ $video_id = SBY_Parse::get_video_id( $this->youtube_api_data );
144
+
145
+ global $wpdb;
146
+ $results = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE meta_value = %s AND meta_key = %s", $video_id, 'sby_video_id' ), ARRAY_A );
147
+
148
+ if ( isset( $results[0] ) ) {
149
+ $this->wp_post_id = $results[0]['post_id'];
150
+
151
+ return $results[0]['post_id'];
152
+ } else {
153
+ return false;
154
+ }
155
+ }
156
+
157
+ protected function get_post_content( $override = false ) {
158
+ $description = SBY_Parse::get_caption( $this->youtube_api_data );
159
+ $flag = '';
160
+ if ( ! $override && substr( $description, -3 ) === '...' ) {
161
+ $flag = '<!-- sby:description-incomplete -->';
162
+ }
163
+
164
+ return '['.SBY_SLUG.'-single]<!-- sby:description-start -->' . wp_kses_post( $description ) . '<!-- sby:description-end -->' . $flag;
165
+ }
166
  }
inc/sby-functions.php CHANGED
@@ -1,871 +1,871 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
-
5
- add_shortcode('youtube-feed', 'sby_youtube_feed');
6
- function sby_youtube_feed( $atts = array() ) {
7
- $database_settings = sby_get_database_settings();
8
- if ( !$database_settings['ajaxtheme'] ) {
9
- wp_enqueue_script( 'sby_scripts' );
10
- }
11
-
12
- if ( $database_settings['enqueue_css_in_shortcode'] ) {
13
- wp_enqueue_style( 'sby_styles' );
14
- }
15
-
16
- $youtube_feed_settings = new SBY_Settings( $atts, $database_settings );
17
- $youtube_feed_settings->set_feed_type_and_terms();
18
- $youtube_feed_settings->set_transient_name();
19
- $transient_name = $youtube_feed_settings->get_transient_name();
20
- $settings = $youtube_feed_settings->get_settings();
21
- $feed_type_and_terms = $youtube_feed_settings->get_feed_type_and_terms();
22
-
23
- if ( empty( $database_settings['connected_accounts'] )
24
- && empty( $database_settings['api_key'] )
25
- && ! isset( $feed_type_and_terms['channels'][0]['channel_id'] ) ) {
26
- $style = current_user_can( 'manage_youtube_feed_options' ) ? ' style="display: block;"' : '';
27
- ob_start(); ?>
28
- <div id="sbi_mod_error" <?php echo $style; ?>>
29
- <span><?php _e('This error message is only visible to WordPress admins', 'feeds-for-youtube' ); ?></span><br />
30
- <p><b><?php _e( 'Error: No connected account or API key.', 'feeds-for-youtube' ); ?></b>
31
- <p><?php _e( 'Please go to the YouTube Feed settings page to enter an API key or connect an account.', 'youtube-feed' ); ?></p>
32
- </div>
33
- <?php
34
- $html = ob_get_contents();
35
- ob_get_clean();
36
- return $html;
37
- }
38
-
39
- $youtube_feed = new SBY_Feed( $transient_name );
40
-
41
- if ( $database_settings['caching_type'] === 'background' ) {
42
- $youtube_feed->add_report( 'background caching used' );
43
- if ( $youtube_feed->regular_cache_exists() ) {
44
- $youtube_feed->add_report( 'setting posts from cache' );
45
- $youtube_feed->set_post_data_from_cache();
46
- }
47
-
48
- if ( $youtube_feed->need_to_start_cron_job() ) {
49
- $youtube_feed->add_report( 'setting up feed for cron cache' );
50
- $to_cache = array(
51
- 'atts' => $atts,
52
- 'last_requested' => time(),
53
- );
54
-
55
- $youtube_feed->set_cron_cache( $to_cache, $youtube_feed_settings->get_cache_time_in_seconds() );
56
-
57
- SBY_Cron_Updater::do_single_feed_cron_update( $youtube_feed_settings, $to_cache, $atts, false );
58
-
59
- $youtube_feed->set_post_data_from_cache();
60
-
61
- } elseif ( $youtube_feed->should_update_last_requested() ) {
62
- $youtube_feed->add_report( 'updating last requested' );
63
- $to_cache = array(
64
- 'last_requested' => time(),
65
- );
66
-
67
- $youtube_feed->set_cron_cache( $to_cache, $youtube_feed_settings->get_cache_time_in_seconds() );
68
- }
69
-
70
- } elseif ( $youtube_feed->regular_cache_exists() ) {
71
- $youtube_feed->add_report( 'page load caching used and regular cache exists' );
72
- $youtube_feed->set_post_data_from_cache();
73
-
74
- if ( $youtube_feed->need_posts( $settings['num'] ) && $youtube_feed->can_get_more_posts() ) {
75
- while ( $youtube_feed->need_posts( $settings['num'] ) && $youtube_feed->can_get_more_posts() ) {
76
- $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
77
- }
78
- $youtube_feed->cache_feed_data( $youtube_feed_settings->get_cache_time_in_seconds() );
79
- }
80
-
81
- } else {
82
- $youtube_feed->add_report( 'no feed cache found' );
83
-
84
- while ( $youtube_feed->need_posts( $settings['num'] ) && $youtube_feed->can_get_more_posts() ) {
85
- $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
86
- }
87
-
88
- if ( ! $youtube_feed->should_use_backup() ) {
89
- $youtube_feed->cache_feed_data( $youtube_feed_settings->get_cache_time_in_seconds() );
90
- }
91
-
92
- }
93
-
94
- if ( $youtube_feed->should_use_backup() ) {
95
- $youtube_feed->add_report( 'trying to use backup' );
96
- $youtube_feed->maybe_set_post_data_from_backup();
97
- $youtube_feed->maybe_set_header_data_from_backup();
98
- }
99
-
100
- // if need a header
101
- if ( $youtube_feed->need_header( $settings, $feed_type_and_terms ) && ! $youtube_feed->should_use_backup() ) {
102
- if ( $database_settings['caching_type'] === 'background' ) {
103
- $youtube_feed->add_report( 'background header caching used' );
104
- $youtube_feed->set_header_data_from_cache();
105
- } elseif ( $youtube_feed->regular_header_cache_exists() ) {
106
- // set_post_data_from_cache
107
- $youtube_feed->add_report( 'page load caching used and regular header cache exists' );
108
- $youtube_feed->set_header_data_from_cache();
109
- } else {
110
- $youtube_feed->add_report( 'no header cache exists' );
111
- $youtube_feed->set_remote_header_data( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
112
-
113
- $youtube_feed->cache_header_data( $youtube_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
114
- }
115
- } else {
116
- $youtube_feed->add_report( 'no header needed' );
117
- }
118
-
119
- return $youtube_feed->get_the_feed_html( $settings, $atts, $youtube_feed_settings->get_feed_type_and_terms(), $youtube_feed_settings->get_connected_accounts_in_feed() );
120
- }
121
-
122
- /**
123
- * Outputs an organized error report for the front end.
124
- * This hooks into the end of the feed before the closing div
125
- *
126
- * @param object $youtube_feed
127
- * @param string $feed_id
128
- */
129
- function sby_error_report( $youtube_feed, $feed_id ) {
130
- global $sby_posts_manager;
131
-
132
- $style = current_user_can( 'manage_youtube_feed_options' ) ? ' style="display: block;"' : '';
133
-
134
- $error_messages = $sby_posts_manager->get_frontend_errors();
135
- if ( ! empty( $error_messages ) ) {?>
136
- <div id="sby_mod_error"<?php echo $style; ?>>
137
- <span><?php _e('This error message is only visible to WordPress admins', SBY_TEXT_DOMAIN ); ?></span><br />
138
- <?php foreach ( $error_messages as $error_message ) {
139
- echo $error_message;
140
- } ?>
141
- </div>
142
- <?php
143
- }
144
-
145
- $sby_posts_manager->reset_frontend_errors();
146
- }
147
- add_action( 'sby_before_feed_end', 'sby_error_report', 10, 2 );
148
-
149
- /**
150
- * Called after the load more button is clicked using admin-ajax.php
151
- */
152
- function sby_get_next_post_set() {
153
- if ( ! isset( $_POST['feed_id'] ) || strpos( $_POST['feed_id'], 'sby' ) === false ) {
154
- die( 'invalid feed ID');
155
- }
156
-
157
- $feed_id = sanitize_text_field( $_POST['feed_id'] );
158
- $atts_raw = isset( $_POST['atts'] ) ? json_decode( stripslashes( $_POST['atts'] ), true ) : array();
159
- if ( is_array( $atts_raw ) ) {
160
- array_map( 'sanitize_text_field', $atts_raw );
161
- } else {
162
- $atts_raw = array();
163
- }
164
- $atts = $atts_raw; // now sanitized
165
-
166
- $offset = isset( $_POST['offset'] ) ? (int)$_POST['offset'] : 0;
167
-
168
- $database_settings = sby_get_database_settings();
169
- $youtube_feed_settings = new SBY_Settings( $atts, $database_settings );
170
-
171
- if ( empty( $database_settings['connected_accounts'] ) && empty( $database_settings['api_key'] ) ) {
172
- die( 'error no connected account' );
173
- }
174
-
175
- $youtube_feed_settings->set_feed_type_and_terms();
176
- $youtube_feed_settings->set_transient_name( $feed_id );
177
- $transient_name = $youtube_feed_settings->get_transient_name();
178
-
179
- if ( $transient_name !== $feed_id ) {
180
- die( 'id does not match' );
181
- }
182
-
183
- $settings = $youtube_feed_settings->get_settings();
184
-
185
- $feed_type_and_terms = $youtube_feed_settings->get_feed_type_and_terms();
186
-
187
- $youtube_feed = new SBY_Feed( $transient_name );
188
-
189
- if ( $settings['caching_type'] === 'permanent' && empty( $settings['doingModerationMode'] ) ) {
190
- $youtube_feed->add_report( 'trying to use permanent cache' );
191
- $youtube_feed->maybe_set_post_data_from_backup();
192
- } elseif ( $settings['caching_type'] === 'background' ) {
193
- $youtube_feed->add_report( 'background caching used' );
194
- if ( $youtube_feed->regular_cache_exists() ) {
195
- $youtube_feed->add_report( 'setting posts from cache' );
196
- $youtube_feed->set_post_data_from_cache();
197
- }
198
-
199
- if ( $youtube_feed->need_posts( $settings['num'], $offset ) && $youtube_feed->can_get_more_posts() ) {
200
- while ( $youtube_feed->need_posts( $settings['num'], $offset ) && $youtube_feed->can_get_more_posts() ) {
201
- $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
202
- }
203
-
204
- if ( $youtube_feed->need_to_start_cron_job() ) {
205
- $youtube_feed->add_report( 'needed to start cron job' );
206
- $to_cache = array(
207
- 'atts' => $atts,
208
- 'last_requested' => time(),
209
- );
210
-
211
- $youtube_feed->set_cron_cache( $to_cache, $youtube_feed_settings->get_cache_time_in_seconds() );
212
-
213
- } else {
214
- $youtube_feed->add_report( 'updating last requested and adding to cache' );
215
- $to_cache = array(
216
- 'last_requested' => time(),
217
- );
218
-
219
- $youtube_feed->set_cron_cache( $to_cache, $youtube_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
220
- }
221
- }
222
-
223
- } elseif ( $youtube_feed->regular_cache_exists() ) {
224
- $youtube_feed->add_report( 'regular cache exists' );
225
- $youtube_feed->set_post_data_from_cache();
226
-
227
- if ( $youtube_feed->need_posts( $settings['num'], $offset ) && $youtube_feed->can_get_more_posts() ) {
228
- while ( $youtube_feed->need_posts( $settings['num'], $offset ) && $youtube_feed->can_get_more_posts() ) {
229
- $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
230
- }
231
-
232
- $youtube_feed->add_report( 'adding to cache' );
233
- $youtube_feed->cache_feed_data( $youtube_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
234
- }
235
-
236
-
237
- } else {
238
- $youtube_feed->add_report( 'no feed cache found' );
239
-
240
- while ( $youtube_feed->need_posts( $settings['num'], $offset ) && $youtube_feed->can_get_more_posts() ) {
241
- $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
242
- }
243
-
244
- if ( $youtube_feed->should_use_backup() ) {
245
- $youtube_feed->add_report( 'trying to use a backup cache' );
246
- $youtube_feed->maybe_set_post_data_from_backup();
247
- } else {
248
- $youtube_feed->add_report( 'transient gone, adding to cache' );
249
- $youtube_feed->cache_feed_data( $youtube_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
250
- }
251
- }
252
-
253
- $feed_status = array( 'shouldPaginate' => $youtube_feed->should_use_pagination( $settings, $offset ), );
254
-
255
- $feed_status['cacheAll'] = $youtube_feed->do_page_cache_all();
256
-
257
- $post_data = $youtube_feed->get_post_data();
258
-
259
- if ( $youtube_feed->successful_video_api_request_made() && ! empty( $post_data ) ) {
260
- if ( $settings['storage_process'] === 'page' ) {
261
- foreach ( $youtube_feed->get_post_data() as $post ) {
262
- $wp_post = new SBY_WP_Post( $post, $this->regular_feed_transient_name );
263
- $wp_post->update_post();
264
- }
265
- } elseif ( $settings['storage_process'] === 'background' ) {
266
- $feed_status['checkWPPosts'] = true;
267
- $feed_status['cacheAll'] = true;
268
- }
269
- }
270
-
271
- /*if ( $settings['disable_js_image_loading'] || $settings['imageres'] !== 'auto' ) {
272
- global $sby_posts_manager;
273
- $post_data = array_slice( $youtube_feed->get_post_data(), $offset, $settings['minnum'] );
274
-
275
- if ( ! $sby_posts_manager->image_resizing_disabled() ) {
276
- $image_ids = array();
277
- foreach ( $post_data as $post ) {
278
- $image_ids[] = SBY_Parse::get_post_id( $post );
279
- }
280
- $resized_images = SBY_Feed::get_resized_images_source_set( $image_ids, 0, $feed_id );
281
-
282
- $youtube_feed->set_resized_images( $resized_images );
283
- }
284
- }*/
285
-
286
- $return = array(
287
- 'html' => $youtube_feed->get_the_items_html( $settings, $offset, $youtube_feed_settings->get_feed_type_and_terms(), $youtube_feed_settings->get_connected_accounts_in_feed() ),
288
- 'feedStatus' => $feed_status,
289
- 'report' => $youtube_feed->get_report(),
290
- 'resizedImages' => array()
291
- //'resizedImages' => SBY_Feed::get_resized_images_source_set( $youtube_feed->get_image_ids_post_set(), 0, $feed_id )
292
- );
293
-
294
- //SBY_Feed::update_last_requested( $youtube_feed->get_image_ids_post_set() );
295
-
296
- echo wp_json_encode( $return );
297
-
298
- global $sby_posts_manager;
299
-
300
- $sby_posts_manager->update_successful_ajax_test();
301
-
302
- die();
303
- }
304
- add_action( 'wp_ajax_sby_load_more_clicked', 'sby_get_next_post_set' );
305
- add_action( 'wp_ajax_nopriv_sby_load_more_clicked', 'sby_get_next_post_set' );
306
-
307
- /**
308
- * Posts that need resized images are processed after being sent to the server
309
- * using AJAX
310
- *
311
- * @return string
312
- */
313
- function sby_process_wp_posts() {
314
- if ( ! isset( $_POST['feed_id'] ) || strpos( $_POST['feed_id'], 'sby' ) === false ) {
315
- die( 'invalid feed ID');
316
- }
317
-
318
- $feed_id = sanitize_text_field( $_POST['feed_id'] );
319
-
320
- $atts_raw = isset( $_POST['atts'] ) ? json_decode( stripslashes( $_POST['atts'] ), true ) : array();
321
- if ( is_array( $atts_raw ) ) {
322
- array_map( 'sanitize_text_field', $atts_raw );
323
- } else {
324
- $atts_raw = array();
325
- }
326
- $atts = $atts_raw; // now sanitized
327
-
328
- $offset = isset( $_POST['offset'] ) ? (int)$_POST['offset'] : 0;
329
-
330
- $cache_all = isset( $_POST['cache_all'] ) ? $_POST['cache_all'] === 'true' : false;
331
-
332
- if ( $cache_all ) {
333
- $database_settings = sby_get_database_settings();
334
- $youtube_feed_settings = new SBY_Settings( $atts, $database_settings );
335
- $youtube_feed_settings->set_feed_type_and_terms();
336
- $youtube_feed_settings->set_transient_name( $feed_id );
337
- $transient_name = $youtube_feed_settings->get_transient_name();
338
-
339
- $feed_id = $transient_name;
340
- }
341
-
342
- $database_settings = sby_get_database_settings();
343
- $sby_settings = new SBY_Settings( $atts, $database_settings );
344
-
345
- $settings = $sby_settings->get_settings();
346
-
347
- $youtube_feed = new SBY_Feed( $feed_id );
348
- if ( $youtube_feed->regular_cache_exists() ) {
349
- $youtube_feed->set_post_data_from_cache();
350
-
351
- if ( !$cache_all ) {
352
- $posts = array_slice( $youtube_feed->get_post_data(), max( 0, $offset - $settings['minnum'] ), $settings['minnum'] );
353
- } else {
354
- $posts = $youtube_feed->get_post_data();
355
- }
356
-
357
- foreach ( $posts as $post ) {
358
- $wp_post = new SBY_WP_Post( $post, $feed_id );
359
- $wp_post->update_post();
360
- }
361
- }
362
-
363
-
364
-
365
- //global $sby_posts_manager;
366
-
367
- //$sby_posts_manager->update_successful_ajax_test();
368
- if ( $cache_all ) {
369
- die( 'cache all' );
370
- }
371
- die( 'check success' );
372
- }
373
- add_action( 'wp_ajax_sby_check_wp_submit', 'sby_process_wp_posts' );
374
- add_action( 'wp_ajax_nopriv_sby_check_wp_submit', 'sby_process_wp_posts' );
375
-
376
- function sby_process_post_set_caching( $posts, $feed_id ) {
377
-
378
- // if is an array of video ids already, don't need to get them
379
- if ( isset( $posts[0] ) && SBY_Parse::get_video_id( $posts[0] ) === '' ) {
380
- $vid_ids = $posts;
381
- } else {
382
- $vid_ids = array();
383
- foreach ( $posts as $post ) {
384
- $vid_ids[] = SBY_Parse::get_video_id( $post );
385
- $wp_post = new SBY_WP_Post( $post, $feed_id );
386
- $sby_video_settings = SBY_CPT::get_sby_cpt_settings();
387
- $wp_post->update_post( $sby_video_settings['post_status'] );
388
- }
389
- }
390
-
391
- return array();
392
- }
393
-
394
- function sby_debug_report( $youtube_feed, $feed_id ) {
395
-
396
- if ( ! isset( $_GET['sby_debug'] ) ) {
397
- return;
398
- }
399
-
400
- ?>
401
- <p>Status</p>
402
- <ul>
403
- <li>Time: <?php echo date( "Y-m-d H:i:s", time() ); ?></li>
404
- <?php foreach ( $youtube_feed->get_report() as $item ) : ?>
405
- <li><?php echo esc_html( $item ); ?></li>
406
- <?php endforeach; ?>
407
-
408
- </ul>
409
-
410
- <?php
411
- $database_settings = sby_get_database_settings();
412
-
413
- $public_settings_keys = SBY_Settings::get_public_db_settings_keys();
414
- ?>
415
- <p>Settings</p>
416
- <ul>
417
- <?php foreach ( $public_settings_keys as $key ) : if ( isset( $database_settings[ $key ] ) ) : ?>
418
- <li>
419
- <small><?php echo esc_html( $key ); ?>:</small>
420
- <?php if ( ! is_array( $database_settings[ $key ] ) ) :
421
- echo $database_settings[ $key ];
422
- else : ?>
423
- <pre>
424
- <?php var_export( $database_settings[ $key ] ); ?>
425
- </pre>
426
- <?php endif; ?>
427
- </li>
428
-
429
- <?php endif; endforeach; ?>
430
- </ul>
431
- <?php
432
- }
433
- add_action( 'sby_before_feed_end', 'sby_debug_report', 11, 2 );
434
-
435
- function sby_clear_cache() {
436
- //Delete all transients
437
- global $wpdb;
438
- $table_name = $wpdb->prefix . "options";
439
- $wpdb->query( "
440
- DELETE
441
- FROM $table_name
442
- WHERE `option_name` LIKE ('%\_transient\_sby\_%')
443
- " );
444
- $wpdb->query( "
445
- DELETE
446
- FROM $table_name
447
- WHERE `option_name` LIKE ('%\_transient\_timeout\_sby\_%')
448
- " );
449
- $wpdb->query( "
450
- DELETE
451
- FROM $table_name
452
- WHERE `option_name` LIKE ('%\_transient\_&sby\_%')
453
- " );
454
- $wpdb->query( "
455
- DELETE
456
- FROM $table_name
457
- WHERE `option_name` LIKE ('%\_transient\_timeout\_&sby\_%')
458
- " );
459
- $wpdb->query( "
460
- DELETE
461
- FROM $table_name
462
- WHERE `option_name` LIKE ('%\_transient\_\$sby\_%')
463
- " );
464
- $wpdb->query( "
465
- DELETE
466
- FROM $table_name
467
- WHERE `option_name` LIKE ('%\_transient\_timeout\_\$sby\_%')
468
- " );
469
-
470
- sby_clear_page_caches();
471
- }
472
- add_action( 'sby_settings_after_configure_save', 'sby_clear_cache' );
473
-
474
- function sby_maybe_clear_cache_using_cron() {
475
- global $sby_settings;
476
- $sby_doing_cron_clear = isset( $sby_settings['cronclear'] ) ? $sby_settings['cronclear'] : false;
477
-
478
- if ( $sby_doing_cron_clear ) {
479
- sby_clear_cache();
480
- }
481
- }
482
- add_action( 'sby_cron_job', 'sby_maybe_clear_cache_using_cron' );
483
-
484
- /**
485
- * When certain events occur, page caches need to
486
- * clear or errors occur or changes will not be seen
487
- */
488
- function sby_clear_page_caches() {
489
- if ( isset( $GLOBALS['wp_fastest_cache'] ) && method_exists( $GLOBALS['wp_fastest_cache'], 'deleteCache' ) ){
490
- /* Clear WP fastest cache*/
491
- $GLOBALS['wp_fastest_cache']->deleteCache();
492
- }
493
-
494
- if ( function_exists( 'wp_cache_clear_cache' ) ) {
495
- wp_cache_clear_cache();
496
- }
497
-
498
- if ( class_exists('W3_Plugin_TotalCacheAdmin') ) {
499
- $plugin_totalcacheadmin = & w3_instance('W3_Plugin_TotalCacheAdmin');
500
-
501
- $plugin_totalcacheadmin->flush_all();
502
- }
503
-
504
- if ( function_exists( 'rocket_clean_domain' ) ) {
505
- rocket_clean_domain();
506
- }
507
-
508
- if ( class_exists( 'autoptimizeCache' ) ) {
509
- /* Clear autoptimize */
510
- autoptimizeCache::clearall();
511
- }
512
- }
513
-
514
- /**
515
- * Triggered by a cron event to update feeds
516
- */
517
- function sby_cron_updater() {
518
- global $sby_settings;
519
-
520
- if ( $sby_settings['caching_type'] === 'background' ) {
521
- SBY_Cron_Updater::do_feed_updates();
522
- }
523
-
524
- }
525
- add_action( 'sby_feed_update', 'sby_cron_updater' );
526
-
527
- function sby_update_or_connect_account( $args ) {
528
- global $sby_settings;
529
- $account_id = $args['channel_id'];
530
- $sby_settings['connected_accounts'][ $account_id ] = array(
531
- 'access_token' => $args['access_token'],
532
- 'refresh_token' => $args['refresh_token'],
533
- 'channel_id' => $args['channel_id'],
534
- 'username' => $args['username'],
535
- 'is_valid' => true,
536
- 'last_checked' => time(),
537
- 'profile_picture' => $args['profile_picture'],
538
- 'privacy' => $args['privacy'],
539
- 'expires' => $args['expires']
540
- );
541
-
542
- update_option( 'sby_settings', $sby_settings );
543
-
544
- return $sby_settings['connected_accounts'][ $account_id ];
545
- }
546
-
547
- function sby_get_first_connected_account() {
548
- global $sby_settings;
549
- $an_account = array();
550
-
551
- if ( ! empty( $sby_settings['api_key'] ) ) {
552
- $an_account = array(
553
- 'access_token' => '',
554
- 'refresh_token' => '',
555
- 'channel_id' => '',
556
- 'username' => '',
557
- 'is_valid' => true,
558
- 'last_checked' => '',
559
- 'profile_picture' => '',
560
- 'privacy' => '',
561
- 'expires' => '2574196927',
562
- 'api_key' => $sby_settings['api_key']
563
- );
564
- } else {
565
- $connected_accounts = $sby_settings['connected_accounts'];
566
- foreach ( $connected_accounts as $account ) {
567
- if ( empty( $an_account ) ) {
568
- $an_account = $account;
569
- }
570
- }
571
- }
572
-
573
- if ( empty( $an_account ) ) {
574
- $an_account = array( 'rss_only' => true );
575
- }
576
-
577
- return $an_account;
578
- }
579
-
580
- function sby_get_feed_template_part( $part, $settings = array() ) {
581
- $file = '';
582
-
583
- $using_custom_templates_in_theme = apply_filters( 'sby_use_theme_templates', $settings['customtemplates'] );
584
- $generic_path = trailingslashit( SBY_PLUGIN_DIR ) . 'templates/';
585
-
586
- if ( $using_custom_templates_in_theme ) {
587
- $custom_header_template = locate_template( 'sby/header.php', false, false );
588
- $custom_player_template = locate_template( 'sby/player.php', false, false );
589
- $custom_item_template = locate_template( 'sby/item.php', false, false );
590
- $custom_footer_template = locate_template( 'sby/footer.php', false, false );
591
- $custom_feed_template = locate_template( 'sby/feed.php', false, false );
592
- } else {
593
- $custom_header_template = false;
594
- $custom_player_template = false;
595
- $custom_item_template = false;
596
- $custom_footer_template = false;
597
- $custom_feed_template = false;
598
- }
599
-
600
- if ( $part === 'header' ) {
601
- if ( $custom_header_template ) {
602
- $file = $custom_header_template;
603
- } else {
604
- $file = $generic_path . 'header.php';
605
- }
606
- } elseif ( $part === 'player' ) {
607
- if ( $custom_player_template ) {
608
- $file = $custom_player_template;
609
- } else {
610
- $file = $generic_path . 'player.php';
611
- }
612
- } elseif ( $part === 'item' ) {
613
- if ( $custom_item_template ) {
614
- $file = $custom_item_template;
615
- } else {
616
- $file = $generic_path . 'item.php';
617
- }
618
- } elseif ( $part === 'footer' ) {
619
- if ( $custom_footer_template ) {
620
- $file = $custom_footer_template;
621
- } else {
622
- $file = $generic_path . 'footer.php';
623
- }
624
- } elseif ( $part === 'feed' ) {
625
- if ( $custom_feed_template ) {
626
- $file = $custom_feed_template;
627
- } else {
628
- $file = $generic_path . 'feed.php';
629
- }
630
- }
631
-
632
- return $file;
633
- }
634
-
635
- /**
636
- * Get the settings in the database with defaults
637
- *
638
- * @return array
639
- */
640
- function sby_get_database_settings() {
641
- global $sby_settings;
642
-
643
- $defaults = sby_settings_defaults();
644
-
645
- return array_merge( $defaults, $sby_settings );
646
- }
647
-
648
-
649
- function sby_get_channel_id_from_channel_name( $channel_name ) {
650
- $channel_ids = get_option( 'sby_channel_ids', array() );
651
-
652
- if ( isset( $channel_ids[ strtolower( $channel_name ) ] ) ) {
653
- return $channel_ids[ strtolower( $channel_name ) ];
654
- }
655
-
656
- return false;
657
- }
658
-
659
- function sby_set_channel_id_from_channel_name( $channel_name, $channel_id ) {
660
- $channel_ids = get_option( 'sby_channel_ids', array() );
661
-
662
- $channel_ids[ strtolower( $channel_name ) ] = $channel_id;
663
-
664
- update_option( 'sby_channel_ids', $channel_ids, false );
665
- }
666
-
667
- function sby_icon( $icon, $class = '' ) {
668
- $class = ! empty( $class ) ? ' ' . trim( $class ) : '';
669
- if ( $icon === SBY_SLUG ) {
670
- return '<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="youtube" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="svg-inline--fa fa-youtube fa-w-18'.$class.'"><path fill="currentColor" d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z" class=""></path></svg>';
671
- } else {
672
- return '<i aria-hidden="true" role="img" class="fab fa-youtube"></i>';
673
- }
674
- }
675
-
676
-
677
- /**
678
- * @param $a
679
- * @param $b
680
- *
681
- * @return false|int
682
- */
683
- function sby_date_sort( $a, $b ) {
684
- $time_stamp_a = SBY_Parse::get_timestamp( $a );
685
- $time_stamp_b = SBY_Parse::get_timestamp( $b );
686
-
687
- if ( isset( $time_stamp_a ) ) {
688
- return $time_stamp_b - $time_stamp_a;
689
- } else {
690
- return rand ( -1, 1 );
691
- }
692
- }
693
-
694
- /**
695
- * @param $a
696
- * @param $b
697
- *
698
- * @return false|int
699
- */
700
- function sby_rand_sort( $a, $b ) {
701
- return rand ( -1, 1 );
702
- }
703
-
704
- /**
705
- * Converts a hex code to RGB so opacity can be
706
- * applied more easily
707
- *
708
- * @param $hex
709
- *
710
- * @return string
711
- */
712
- function sby_hextorgb( $hex ) {
713
- // allows someone to use rgb in shortcode
714
- if ( strpos( $hex, ',' ) !== false ) {
715
- return $hex;
716
- }
717
-
718
- $hex = str_replace( '#', '', $hex );
719
-
720
- if ( strlen( $hex ) === 3 ) {
721
- $r = hexdec( substr( $hex,0,1 ).substr( $hex,0,1 ) );
722
- $g = hexdec( substr( $hex,1,1 ).substr( $hex,1,1 ) );
723
- $b = hexdec( substr( $hex,2,1 ).substr( $hex,2,1 ) );
724
- } else {
725
- $r = hexdec( substr( $hex,0,2 ) );
726
- $g = hexdec( substr( $hex,2,2 ) );
727
- $b = hexdec( substr( $hex,4,2 ) );
728
- }
729
- $rgb = array( $r, $g, $b );
730
-
731
- return implode( ',', $rgb ); // returns the rgb values separated by commas
732
- }
733
-
734
- function sby_get_utc_offset() {
735
- return get_option( 'gmt_offset', 0 ) * HOUR_IN_SECONDS;
736
- }
737
-
738
- function sby_is_pro_version() {
739
- return defined( 'SBY_PLUGIN_EDD_NAME' );
740
- }
741
-
742
- function sby_strip_after_hash( $string ) {
743
- $string_array = explode( '#', $string );
744
- $finished_string = $string_array[0];
745
-
746
- return $finished_string;
747
- }
748
-
749
- function sby_get_account_bottom() {
750
- return '';
751
- }
752
-
753
- function sby_get_account_top() {
754
- return '';
755
- }
756
-
757
- function sby_replace_double_quotes( &$element, $index ) {
758
- $element = str_replace( '"', "&quot;", $element );
759
- }
760
-
761
- function sby_esc_attr_with_br( $text ) {
762
- return str_replace( array( '&lt;br /&gt;', '&lt;br&gt;' ), '&lt;br /&gt;', esc_attr( nl2br( $text ) ) );
763
- }
764
- /**
765
- * Adds the ajax url and custom JavaScript to the page
766
- */
767
- function sby_custom_js() {
768
- global $sby_settings;
769
-
770
- $js = isset( $sby_settings['custom_js'] ) ? trim( $sby_settings['custom_js'] ) : '';
771
-
772
- echo '<!-- YouTube Feed JS -->';
773
- echo "\r\n";
774
- echo '<script type="text/javascript">';
775
- echo "\r\n";
776
-
777
- if ( ! empty( $js ) ) {
778
- echo "\r\n";
779
- echo "jQuery( document ).ready(function($) {";
780
- echo "\r\n";
781
- echo "window.sbyCustomJS = function(){";
782
- echo "\r\n";
783
- echo stripslashes($js);
784
- echo "\r\n";
785
- echo "}";
786
- echo "\r\n";
787
- echo "});";
788
- }
789
-
790
- echo "\r\n";
791
- echo '</script>';
792
- echo "\r\n";
793
- }
794
- add_action( 'wp_footer', 'sby_custom_js' );
795
-
796
- //Custom CSS
797
- add_action( 'wp_head', 'sby_custom_css' );
798
- function sby_custom_css() {
799
- global $sby_settings;
800
-
801
- $css = isset( $sby_settings['custom_css'] ) ? trim( $sby_settings['custom_css'] ) : '';
802
-
803
- //Show CSS if an admin (so can see Hide Photos link), if including Custom CSS or if hiding some photos
804
- if ( current_user_can( 'manage_youtube_feed_options' ) || current_user_can( 'manage_options' ) || ! empty( $css ) ) {
805
-
806
- echo '<!-- Instagram Feed CSS -->';
807
- echo "\r\n";
808
- echo '<style type="text/css">';
809
-
810
- if ( ! empty( $css ) ){
811
- echo "\r\n";
812
- echo stripslashes($css);
813
- }
814
-
815
- if ( current_user_can( 'manage_youtube_feed_options' ) || current_user_can( 'manage_options' ) ){
816
- echo "\r\n";
817
- echo "#sby_mod_link, #sby_mod_error{ display: block !important; width: 100%; float: left; box-sizing: border-box; }";
818
- }
819
-
820
- echo "\r\n";
821
- echo '</style>';
822
- echo "\r\n";
823
- }
824
-
825
- }
826
-
827
- /**
828
- * Makes the JavaScript file available and enqueues the stylesheet
829
- * for the plugin
830
- */
831
- function sby_scripts_enqueue( $enqueue = false ) {
832
- //Register the script to make it available
833
-
834
- //Options to pass to JS file
835
- global $sby_settings;
836
-
837
- $js_file = 'js/sb-youtube.min.js';
838
- if ( isset( $_GET['sby_debug'] ) ) {
839
- $js_file = 'js/sb-youtube.js';
840
- }
841
-
842
- if ( isset( $sby_settings['enqueue_js_in_head'] ) && $sby_settings['enqueue_js_in_head'] ) {
843
- wp_enqueue_script( 'sby_scripts', trailingslashit( SBY_PLUGIN_URL ) . $js_file, array('jquery'), SBYVER, false );
844
- } else {
845
- wp_register_script( 'sby_scripts', trailingslashit( SBY_PLUGIN_URL ) . $js_file, array('jquery'), SBYVER, true );
846
- }
847
-
848
- if ( isset( $sby_settings['enqueue_css_in_shortcode'] ) && $sby_settings['enqueue_css_in_shortcode'] ) {
849
- wp_register_style( 'sby_styles', trailingslashit( SBY_PLUGIN_URL ) . 'css/sb-youtube.min.css', array(), SBYVER );
850
- } else {
851
- wp_enqueue_style( 'sby_styles', trailingslashit( SBY_PLUGIN_URL ) . 'css/sb-youtube.min.css', array(), SBYVER );
852
- }
853
- $data = array(
854
- 'adminAjaxUrl' => admin_url( 'admin-ajax.php' ),
855
- 'placeholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder.png',
856
- 'placeholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder-narrow.png',
857
- 'lightboxPlaceholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder.png',
858
- 'lightboxPlaceholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder-narrow.png',
859
- 'autoplay' => $sby_settings['playvideo'] === 'automatically',
860
- 'semiEagerload' => false,
861
- 'eagerload' => $sby_settings['eagerload']
862
- );
863
- //Pass option to JS file
864
- wp_localize_script('sby_scripts', 'sbyOptions', $data );
865
-
866
- if ( $enqueue ) {
867
- wp_enqueue_style( 'sby_styles' );
868
- wp_enqueue_script( 'sby_scripts' );
869
- }
870
- }
871
  add_action( 'wp_enqueue_scripts', 'sby_scripts_enqueue', 2 );
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+
5
+ add_shortcode('youtube-feed', 'sby_youtube_feed');
6
+ function sby_youtube_feed( $atts = array() ) {
7
+ $database_settings = sby_get_database_settings();
8
+ if ( !$database_settings['ajaxtheme'] ) {
9
+ wp_enqueue_script( 'sby_scripts' );
10
+ }
11
+
12
+ if ( $database_settings['enqueue_css_in_shortcode'] ) {
13
+ wp_enqueue_style( 'sby_styles' );
14
+ }
15
+
16
+ $youtube_feed_settings = new SBY_Settings( $atts, $database_settings );
17
+ $youtube_feed_settings->set_feed_type_and_terms();
18
+ $youtube_feed_settings->set_transient_name();
19
+ $transient_name = $youtube_feed_settings->get_transient_name();
20
+ $settings = $youtube_feed_settings->get_settings();
21
+ $feed_type_and_terms = $youtube_feed_settings->get_feed_type_and_terms();
22
+
23
+ if ( empty( $database_settings['connected_accounts'] )
24
+ && empty( $database_settings['api_key'] )
25
+ && ! isset( $feed_type_and_terms['channels'][0]['channel_id'] ) ) {
26
+ $style = current_user_can( 'manage_youtube_feed_options' ) ? ' style="display: block;"' : '';
27
+ ob_start(); ?>
28
+ <div id="sbi_mod_error" <?php echo $style; ?>>
29
+ <span><?php _e('This error message is only visible to WordPress admins', 'feeds-for-youtube' ); ?></span><br />
30
+ <p><b><?php _e( 'Error: No connected account or API key.', 'feeds-for-youtube' ); ?></b>
31
+ <p><?php _e( 'Please go to the YouTube Feed settings page to enter an API key or connect an account.', 'youtube-feed' ); ?></p>
32
+ </div>
33
+ <?php
34
+ $html = ob_get_contents();
35
+ ob_get_clean();
36
+ return $html;
37
+ }
38
+
39
+ $youtube_feed = new SBY_Feed( $transient_name );
40
+
41
+ if ( $database_settings['caching_type'] === 'background' ) {
42
+ $youtube_feed->add_report( 'background caching used' );
43
+ if ( $youtube_feed->regular_cache_exists() ) {
44
+ $youtube_feed->add_report( 'setting posts from cache' );
45
+ $youtube_feed->set_post_data_from_cache();
46
+ }
47
+
48
+ if ( $youtube_feed->need_to_start_cron_job() ) {
49
+ $youtube_feed->add_report( 'setting up feed for cron cache' );
50
+ $to_cache = array(
51
+ 'atts' => $atts,
52
+ 'last_requested' => time(),
53
+ );
54
+
55
+ $youtube_feed->set_cron_cache( $to_cache, $youtube_feed_settings->get_cache_time_in_seconds() );
56
+
57
+ SBY_Cron_Updater::do_single_feed_cron_update( $youtube_feed_settings, $to_cache, $atts, false );
58
+
59
+ $youtube_feed->set_post_data_from_cache();
60
+
61
+ } elseif ( $youtube_feed->should_update_last_requested() ) {
62
+ $youtube_feed->add_report( 'updating last requested' );
63
+ $to_cache = array(
64
+ 'last_requested' => time(),
65
+ );
66
+
67
+ $youtube_feed->set_cron_cache( $to_cache, $youtube_feed_settings->get_cache_time_in_seconds() );
68
+ }
69
+
70
+ } elseif ( $youtube_feed->regular_cache_exists() ) {
71
+ $youtube_feed->add_report( 'page load caching used and regular cache exists' );
72
+ $youtube_feed->set_post_data_from_cache();
73
+
74
+ if ( $youtube_feed->need_posts( $settings['num'] ) && $youtube_feed->can_get_more_posts() ) {
75
+ while ( $youtube_feed->need_posts( $settings['num'] ) && $youtube_feed->can_get_more_posts() ) {
76
+ $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
77
+ }
78
+ $youtube_feed->cache_feed_data( $youtube_feed_settings->get_cache_time_in_seconds() );
79
+ }
80
+
81
+ } else {
82
+ $youtube_feed->add_report( 'no feed cache found' );
83
+
84
+ while ( $youtube_feed->need_posts( $settings['num'] ) && $youtube_feed->can_get_more_posts() ) {
85
+ $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
86
+ }
87
+
88
+ if ( ! $youtube_feed->should_use_backup() ) {
89
+ $youtube_feed->cache_feed_data( $youtube_feed_settings->get_cache_time_in_seconds() );
90
+ }
91
+
92
+ }
93
+
94
+ if ( $youtube_feed->should_use_backup() ) {
95
+ $youtube_feed->add_report( 'trying to use backup' );
96
+ $youtube_feed->maybe_set_post_data_from_backup();
97
+ $youtube_feed->maybe_set_header_data_from_backup();
98
+ }
99
+
100
+ // if need a header
101
+ if ( $youtube_feed->need_header( $settings, $feed_type_and_terms ) && ! $youtube_feed->should_use_backup() ) {
102
+ if ( $database_settings['caching_type'] === 'background' ) {
103
+ $youtube_feed->add_report( 'background header caching used' );
104
+ $youtube_feed->set_header_data_from_cache();
105
+ } elseif ( $youtube_feed->regular_header_cache_exists() ) {
106
+ // set_post_data_from_cache
107
+ $youtube_feed->add_report( 'page load caching used and regular header cache exists' );
108
+ $youtube_feed->set_header_data_from_cache();
109
+ } else {
110
+ $youtube_feed->add_report( 'no header cache exists' );
111
+ $youtube_feed->set_remote_header_data( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
112
+
113
+ $youtube_feed->cache_header_data( $youtube_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
114
+ }
115
+ } else {
116
+ $youtube_feed->add_report( 'no header needed' );
117
+ }
118
+
119
+ return $youtube_feed->get_the_feed_html( $settings, $atts, $youtube_feed_settings->get_feed_type_and_terms(), $youtube_feed_settings->get_connected_accounts_in_feed() );
120
+ }
121
+
122
+ /**
123
+ * Outputs an organized error report for the front end.
124
+ * This hooks into the end of the feed before the closing div
125
+ *
126
+ * @param object $youtube_feed
127
+ * @param string $feed_id
128
+ */
129
+ function sby_error_report( $youtube_feed, $feed_id ) {
130
+ global $sby_posts_manager;
131
+
132
+ $style = current_user_can( 'manage_youtube_feed_options' ) ? ' style="display: block;"' : '';
133
+
134
+ $error_messages = $sby_posts_manager->get_frontend_errors();
135
+ if ( ! empty( $error_messages ) ) {?>
136
+ <div id="sby_mod_error"<?php echo $style; ?>>
137
+ <span><?php _e('This error message is only visible to WordPress admins', SBY_TEXT_DOMAIN ); ?></span><br />
138
+ <?php foreach ( $error_messages as $error_message ) {
139
+ echo $error_message;
140
+ } ?>
141
+ </div>
142
+ <?php
143
+ }
144
+
145
+ $sby_posts_manager->reset_frontend_errors();
146
+ }
147
+ add_action( 'sby_before_feed_end', 'sby_error_report', 10, 2 );
148
+
149
+ /**
150
+ * Called after the load more button is clicked using admin-ajax.php
151
+ */
152
+ function sby_get_next_post_set() {
153
+ if ( ! isset( $_POST['feed_id'] ) || strpos( $_POST['feed_id'], 'sby' ) === false ) {
154
+ die( 'invalid feed ID');
155
+ }
156
+
157
+ $feed_id = sanitize_text_field( $_POST['feed_id'] );
158
+ $atts_raw = isset( $_POST['atts'] ) ? json_decode( stripslashes( $_POST['atts'] ), true ) : array();
159
+ if ( is_array( $atts_raw ) ) {
160
+ array_map( 'sanitize_text_field', $atts_raw );
161
+ } else {
162
+ $atts_raw = array();
163
+ }
164
+ $atts = $atts_raw; // now sanitized
165
+
166
+ $offset = isset( $_POST['offset'] ) ? (int)$_POST['offset'] : 0;
167
+
168
+ $database_settings = sby_get_database_settings();
169
+ $youtube_feed_settings = new SBY_Settings( $atts, $database_settings );
170
+
171
+ if ( empty( $database_settings['connected_accounts'] ) && empty( $database_settings['api_key'] ) ) {
172
+ die( 'error no connected account' );
173
+ }
174
+
175
+ $youtube_feed_settings->set_feed_type_and_terms();
176
+ $youtube_feed_settings->set_transient_name( $feed_id );
177
+ $transient_name = $youtube_feed_settings->get_transient_name();
178
+
179
+ if ( $transient_name !== $feed_id ) {
180
+ die( 'id does not match' );
181
+ }
182
+
183
+ $settings = $youtube_feed_settings->get_settings();
184
+
185
+ $feed_type_and_terms = $youtube_feed_settings->get_feed_type_and_terms();
186
+
187
+ $youtube_feed = new SBY_Feed( $transient_name );
188
+
189
+ if ( $settings['caching_type'] === 'permanent' && empty( $settings['doingModerationMode'] ) ) {
190
+ $youtube_feed->add_report( 'trying to use permanent cache' );
191
+ $youtube_feed->maybe_set_post_data_from_backup();
192
+ } elseif ( $settings['caching_type'] === 'background' ) {
193
+ $youtube_feed->add_report( 'background caching used' );
194
+ if ( $youtube_feed->regular_cache_exists() ) {
195
+ $youtube_feed->add_report( 'setting posts from cache' );
196
+ $youtube_feed->set_post_data_from_cache();
197
+ }
198
+
199
+ if ( $youtube_feed->need_posts( $settings['num'], $offset ) && $youtube_feed->can_get_more_posts() ) {
200
+ while ( $youtube_feed->need_posts( $settings['num'], $offset ) && $youtube_feed->can_get_more_posts() ) {
201
+ $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
202
+ }
203
+
204
+ if ( $youtube_feed->need_to_start_cron_job() ) {
205
+ $youtube_feed->add_report( 'needed to start cron job' );
206
+ $to_cache = array(
207
+ 'atts' => $atts,
208
+ 'last_requested' => time(),
209
+ );
210
+
211
+ $youtube_feed->set_cron_cache( $to_cache, $youtube_feed_settings->get_cache_time_in_seconds() );
212
+
213
+ } else {
214
+ $youtube_feed->add_report( 'updating last requested and adding to cache' );
215
+ $to_cache = array(
216
+ 'last_requested' => time(),
217
+ );
218
+
219
+ $youtube_feed->set_cron_cache( $to_cache, $youtube_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
220
+ }
221
+ }
222
+
223
+ } elseif ( $youtube_feed->regular_cache_exists() ) {
224
+ $youtube_feed->add_report( 'regular cache exists' );
225
+ $youtube_feed->set_post_data_from_cache();
226
+
227
+ if ( $youtube_feed->need_posts( $settings['num'], $offset ) && $youtube_feed->can_get_more_posts() ) {
228
+ while ( $youtube_feed->need_posts( $settings['num'], $offset ) && $youtube_feed->can_get_more_posts() ) {
229
+ $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
230
+ }
231
+
232
+ $youtube_feed->add_report( 'adding to cache' );
233
+ $youtube_feed->cache_feed_data( $youtube_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
234
+ }
235
+
236
+
237
+ } else {
238
+ $youtube_feed->add_report( 'no feed cache found' );
239
+
240
+ while ( $youtube_feed->need_posts( $settings['num'], $offset ) && $youtube_feed->can_get_more_posts() ) {
241
+ $youtube_feed->add_remote_posts( $settings, $feed_type_and_terms, $youtube_feed_settings->get_connected_accounts_in_feed() );
242
+ }
243
+
244
+ if ( $youtube_feed->should_use_backup() ) {
245
+ $youtube_feed->add_report( 'trying to use a backup cache' );
246
+ $youtube_feed->maybe_set_post_data_from_backup();
247
+ } else {
248
+ $youtube_feed->add_report( 'transient gone, adding to cache' );
249
+ $youtube_feed->cache_feed_data( $youtube_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
250
+ }
251
+ }
252
+
253
+ $feed_status = array( 'shouldPaginate' => $youtube_feed->should_use_pagination( $settings, $offset ), );
254
+
255
+ $feed_status['cacheAll'] = $youtube_feed->do_page_cache_all();
256
+
257
+ $post_data = $youtube_feed->get_post_data();
258
+
259
+ if ( $youtube_feed->successful_video_api_request_made() && ! empty( $post_data ) ) {
260
+ if ( $settings['storage_process'] === 'page' ) {
261
+ foreach ( $youtube_feed->get_post_data() as $post ) {
262
+ $wp_post = new SBY_WP_Post( $post, $this->regular_feed_transient_name );
263
+ $wp_post->update_post();
264
+ }
265
+ } elseif ( $settings['storage_process'] === 'background' ) {
266
+ $feed_status['checkWPPosts'] = true;
267
+ $feed_status['cacheAll'] = true;
268
+ }
269
+ }
270
+
271
+ /*if ( $settings['disable_js_image_loading'] || $settings['imageres'] !== 'auto' ) {
272
+ global $sby_posts_manager;
273
+ $post_data = array_slice( $youtube_feed->get_post_data(), $offset, $settings['minnum'] );
274
+
275
+ if ( ! $sby_posts_manager->image_resizing_disabled() ) {
276
+ $image_ids = array();
277
+ foreach ( $post_data as $post ) {
278
+ $image_ids[] = SBY_Parse::get_post_id( $post );
279
+ }
280
+ $resized_images = SBY_Feed::get_resized_images_source_set( $image_ids, 0, $feed_id );
281
+
282
+ $youtube_feed->set_resized_images( $resized_images );
283
+ }
284
+ }*/
285
+
286
+ $return = array(
287
+ 'html' => $youtube_feed->get_the_items_html( $settings, $offset, $youtube_feed_settings->get_feed_type_and_terms(), $youtube_feed_settings->get_connected_accounts_in_feed() ),
288
+ 'feedStatus' => $feed_status,
289
+ 'report' => $youtube_feed->get_report(),
290
+ 'resizedImages' => array()
291
+ //'resizedImages' => SBY_Feed::get_resized_images_source_set( $youtube_feed->get_image_ids_post_set(), 0, $feed_id )
292
+ );
293
+
294
+ //SBY_Feed::update_last_requested( $youtube_feed->get_image_ids_post_set() );
295
+
296
+ echo wp_json_encode( $return );
297
+
298
+ global $sby_posts_manager;
299
+
300
+ $sby_posts_manager->update_successful_ajax_test();
301
+
302
+ die();
303
+ }
304
+ add_action( 'wp_ajax_sby_load_more_clicked', 'sby_get_next_post_set' );
305
+ add_action( 'wp_ajax_nopriv_sby_load_more_clicked', 'sby_get_next_post_set' );
306
+
307
+ /**
308
+ * Posts that need resized images are processed after being sent to the server
309
+ * using AJAX
310
+ *
311
+ * @return string
312
+ */
313
+ function sby_process_wp_posts() {
314
+ if ( ! isset( $_POST['feed_id'] ) || strpos( $_POST['feed_id'], 'sby' ) === false ) {
315
+ die( 'invalid feed ID');
316
+ }
317
+
318
+ $feed_id = sanitize_text_field( $_POST['feed_id'] );
319
+
320
+ $atts_raw = isset( $_POST['atts'] ) ? json_decode( stripslashes( $_POST['atts'] ), true ) : array();
321
+ if ( is_array( $atts_raw ) ) {
322
+ array_map( 'sanitize_text_field', $atts_raw );
323
+ } else {
324
+ $atts_raw = array();
325
+ }
326
+ $atts = $atts_raw; // now sanitized
327
+
328
+ $offset = isset( $_POST['offset'] ) ? (int)$_POST['offset'] : 0;
329
+
330
+ $cache_all = isset( $_POST['cache_all'] ) ? $_POST['cache_all'] === 'true' : false;
331
+
332
+ if ( $cache_all ) {
333
+ $database_settings = sby_get_database_settings();
334
+ $youtube_feed_settings = new SBY_Settings( $atts, $database_settings );
335
+ $youtube_feed_settings->set_feed_type_and_terms();
336
+ $youtube_feed_settings->set_transient_name( $feed_id );
337
+ $transient_name = $youtube_feed_settings->get_transient_name();
338
+
339
+ $feed_id = $transient_name;
340
+ }
341
+
342
+ $database_settings = sby_get_database_settings();
343
+ $sby_settings = new SBY_Settings( $atts, $database_settings );
344
+
345
+ $settings = $sby_settings->get_settings();
346
+
347
+ $youtube_feed = new SBY_Feed( $feed_id );
348
+ if ( $youtube_feed->regular_cache_exists() ) {
349
+ $youtube_feed->set_post_data_from_cache();
350
+
351
+ if ( !$cache_all ) {
352
+ $posts = array_slice( $youtube_feed->get_post_data(), max( 0, $offset - $settings['minnum'] ), $settings['minnum'] );
353
+ } else {
354
+ $posts = $youtube_feed->get_post_data();
355
+ }
356
+
357
+ foreach ( $posts as $post ) {
358
+ $wp_post = new SBY_WP_Post( $post, $feed_id );
359
+ $wp_post->update_post();
360
+ }
361
+ }
362
+
363
+
364
+
365
+ //global $sby_posts_manager;
366
+
367
+ //$sby_posts_manager->update_successful_ajax_test();
368
+ if ( $cache_all ) {
369
+ die( 'cache all' );
370
+ }
371
+ die( 'check success' );
372
+ }
373
+ add_action( 'wp_ajax_sby_check_wp_submit', 'sby_process_wp_posts' );
374
+ add_action( 'wp_ajax_nopriv_sby_check_wp_submit', 'sby_process_wp_posts' );
375
+
376
+ function sby_process_post_set_caching( $posts, $feed_id ) {
377
+
378
+ // if is an array of video ids already, don't need to get them
379
+ if ( isset( $posts[0] ) && SBY_Parse::get_video_id( $posts[0] ) === '' ) {
380
+ $vid_ids = $posts;
381
+ } else {
382
+ $vid_ids = array();
383
+ foreach ( $posts as $post ) {
384
+ $vid_ids[] = SBY_Parse::get_video_id( $post );
385
+ $wp_post = new SBY_WP_Post( $post, $feed_id );
386
+ $sby_video_settings = SBY_CPT::get_sby_cpt_settings();
387
+ $wp_post->update_post( $sby_video_settings['post_status'] );
388
+ }
389
+ }
390
+
391
+ return array();
392
+ }
393
+
394
+ function sby_debug_report( $youtube_feed, $feed_id ) {
395
+
396
+ if ( ! isset( $_GET['sby_debug'] ) ) {
397
+ return;
398
+ }
399
+
400
+ ?>
401
+ <p>Status</p>
402
+ <ul>
403
+ <li>Time: <?php echo date( "Y-m-d H:i:s", time() ); ?></li>
404
+ <?php foreach ( $youtube_feed->get_report() as $item ) : ?>
405
+ <li><?php echo esc_html( $item ); ?></li>
406
+ <?php endforeach; ?>
407
+
408
+ </ul>
409
+
410
+ <?php
411
+ $database_settings = sby_get_database_settings();
412
+
413
+ $public_settings_keys = SBY_Settings::get_public_db_settings_keys();
414
+ ?>
415
+ <p>Settings</p>
416
+ <ul>
417
+ <?php foreach ( $public_settings_keys as $key ) : if ( isset( $database_settings[ $key ] ) ) : ?>
418
+ <li>
419
+ <small><?php echo esc_html( $key ); ?>:</small>
420
+ <?php if ( ! is_array( $database_settings[ $key ] ) ) :
421
+ echo $database_settings[ $key ];
422
+ else : ?>
423
+ <pre>
424
+ <?php var_export( $database_settings[ $key ] ); ?>
425
+ </pre>
426
+ <?php endif; ?>
427
+ </li>
428
+
429
+ <?php endif; endforeach; ?>
430
+ </ul>
431
+ <?php
432
+ }
433
+ add_action( 'sby_before_feed_end', 'sby_debug_report', 11, 2 );
434
+
435
+ function sby_clear_cache() {
436
+ //Delete all transients
437
+ global $wpdb;
438
+ $table_name = $wpdb->prefix . "options";
439
+ $wpdb->query( "
440
+ DELETE
441
+ FROM $table_name
442
+ WHERE `option_name` LIKE ('%\_transient\_sby\_%')
443
+ " );
444
+ $wpdb->query( "
445
+ DELETE
446
+ FROM $table_name
447
+ WHERE `option_name` LIKE ('%\_transient\_timeout\_sby\_%')
448
+ " );
449
+ $wpdb->query( "
450
+ DELETE
451
+ FROM $table_name
452
+ WHERE `option_name` LIKE ('%\_transient\_&sby\_%')
453
+ " );
454
+ $wpdb->query( "
455
+ DELETE
456
+ FROM $table_name
457
+ WHERE `option_name` LIKE ('%\_transient\_timeout\_&sby\_%')
458
+ " );
459
+ $wpdb->query( "
460
+ DELETE
461
+ FROM $table_name
462
+ WHERE `option_name` LIKE ('%\_transient\_\$sby\_%')
463
+ " );
464
+ $wpdb->query( "
465
+ DELETE
466
+ FROM $table_name
467
+ WHERE `option_name` LIKE ('%\_transient\_timeout\_\$sby\_%')
468
+ " );
469
+
470
+ sby_clear_page_caches();
471
+ }
472
+ add_action( 'sby_settings_after_configure_save', 'sby_clear_cache' );
473
+
474
+ function sby_maybe_clear_cache_using_cron() {
475
+ global $sby_settings;
476
+ $sby_doing_cron_clear = isset( $sby_settings['cronclear'] ) ? $sby_settings['cronclear'] : false;
477
+
478
+ if ( $sby_doing_cron_clear ) {
479
+ sby_clear_cache();
480
+ }
481
+ }
482
+ add_action( 'sby_cron_job', 'sby_maybe_clear_cache_using_cron' );
483
+
484
+ /**
485
+ * When certain events occur, page caches need to
486
+ * clear or errors occur or changes will not be seen
487
+ */
488
+ function sby_clear_page_caches() {
489
+ if ( isset( $GLOBALS['wp_fastest_cache'] ) && method_exists( $GLOBALS['wp_fastest_cache'], 'deleteCache' ) ){
490
+ /* Clear WP fastest cache*/
491
+ $GLOBALS['wp_fastest_cache']->deleteCache();
492
+ }
493
+
494
+ if ( function_exists( 'wp_cache_clear_cache' ) ) {
495
+ wp_cache_clear_cache();
496
+ }
497
+
498
+ if ( class_exists('W3_Plugin_TotalCacheAdmin') ) {
499
+ $plugin_totalcacheadmin = & w3_instance('W3_Plugin_TotalCacheAdmin');
500
+
501
+ $plugin_totalcacheadmin->flush_all();
502
+ }
503
+
504
+ if ( function_exists( 'rocket_clean_domain' ) ) {
505
+ rocket_clean_domain();
506
+ }
507
+
508
+ if ( class_exists( 'autoptimizeCache' ) ) {
509
+ /* Clear autoptimize */
510
+ autoptimizeCache::clearall();
511
+ }
512
+ }
513
+
514
+ /**
515
+ * Triggered by a cron event to update feeds
516
+ */
517
+ function sby_cron_updater() {
518
+ global $sby_settings;
519
+
520
+ if ( $sby_settings['caching_type'] === 'background' ) {
521
+ SBY_Cron_Updater::do_feed_updates();
522
+ }
523
+
524
+ }
525
+ add_action( 'sby_feed_update', 'sby_cron_updater' );
526
+
527
+ function sby_update_or_connect_account( $args ) {
528
+ global $sby_settings;
529
+ $account_id = $args['channel_id'];
530
+ $sby_settings['connected_accounts'][ $account_id ] = array(
531
+ 'access_token' => $args['access_token'],
532
+ 'refresh_token' => $args['refresh_token'],
533
+ 'channel_id' => $args['channel_id'],
534
+ 'username' => $args['username'],
535
+ 'is_valid' => true,
536
+ 'last_checked' => time(),
537
+ 'profile_picture' => $args['profile_picture'],
538
+ 'privacy' => $args['privacy'],
539
+ 'expires' => $args['expires']
540
+ );
541
+
542
+ update_option( 'sby_settings', $sby_settings );
543
+
544
+ return $sby_settings['connected_accounts'][ $account_id ];
545
+ }
546
+
547
+ function sby_get_first_connected_account() {
548
+ global $sby_settings;
549
+ $an_account = array();
550
+
551
+ if ( ! empty( $sby_settings['api_key'] ) ) {
552
+ $an_account = array(
553
+ 'access_token' => '',
554
+ 'refresh_token' => '',
555
+ 'channel_id' => '',
556
+ 'username' => '',
557
+ 'is_valid' => true,
558
+ 'last_checked' => '',
559
+ 'profile_picture' => '',
560
+ 'privacy' => '',
561
+ 'expires' => '2574196927',
562
+ 'api_key' => $sby_settings['api_key']
563
+ );
564
+ } else {
565
+ $connected_accounts = $sby_settings['connected_accounts'];
566
+ foreach ( $connected_accounts as $account ) {
567
+ if ( empty( $an_account ) ) {
568
+ $an_account = $account;
569
+ }
570
+ }
571
+ }
572
+
573
+ if ( empty( $an_account ) ) {
574
+ $an_account = array( 'rss_only' => true );
575
+ }
576
+
577
+ return $an_account;
578
+ }
579
+
580
+ function sby_get_feed_template_part( $part, $settings = array() ) {
581
+ $file = '';
582
+
583
+ $using_custom_templates_in_theme = apply_filters( 'sby_use_theme_templates', $settings['customtemplates'] );
584
+ $generic_path = trailingslashit( SBY_PLUGIN_DIR ) . 'templates/';
585
+
586
+ if ( $using_custom_templates_in_theme ) {
587
+ $custom_header_template = locate_template( 'sby/header.php', false, false );
588
+ $custom_player_template = locate_template( 'sby/player.php', false, false );
589
+ $custom_item_template = locate_template( 'sby/item.php', false, false );
590
+ $custom_footer_template = locate_template( 'sby/footer.php', false, false );
591
+ $custom_feed_template = locate_template( 'sby/feed.php', false, false );
592
+ } else {
593
+ $custom_header_template = false;
594
+ $custom_player_template = false;
595
+ $custom_item_template = false;
596
+ $custom_footer_template = false;
597
+ $custom_feed_template = false;
598
+ }
599
+
600
+ if ( $part === 'header' ) {
601
+ if ( $custom_header_template ) {
602
+ $file = $custom_header_template;
603
+ } else {
604
+ $file = $generic_path . 'header.php';
605
+ }
606
+ } elseif ( $part === 'player' ) {
607
+ if ( $custom_player_template ) {
608
+ $file = $custom_player_template;
609
+ } else {
610
+ $file = $generic_path . 'player.php';
611
+ }
612
+ } elseif ( $part === 'item' ) {
613
+ if ( $custom_item_template ) {
614
+ $file = $custom_item_template;
615
+ } else {
616
+ $file = $generic_path . 'item.php';
617
+ }
618
+ } elseif ( $part === 'footer' ) {
619
+ if ( $custom_footer_template ) {
620
+ $file = $custom_footer_template;
621
+ } else {
622
+ $file = $generic_path . 'footer.php';
623
+ }
624
+ } elseif ( $part === 'feed' ) {
625
+ if ( $custom_feed_template ) {
626
+ $file = $custom_feed_template;
627
+ } else {
628
+ $file = $generic_path . 'feed.php';
629
+ }
630
+ }
631
+
632
+ return $file;
633
+ }
634
+
635
+ /**
636
+ * Get the settings in the database with defaults
637
+ *
638
+ * @return array
639
+ */
640
+ function sby_get_database_settings() {
641
+ global $sby_settings;
642
+
643
+ $defaults = sby_settings_defaults();
644
+
645
+ return array_merge( $defaults, $sby_settings );
646
+ }
647
+
648
+
649
+ function sby_get_channel_id_from_channel_name( $channel_name ) {
650
+ $channel_ids = get_option( 'sby_channel_ids', array() );
651
+
652
+ if ( isset( $channel_ids[ strtolower( $channel_name ) ] ) ) {
653
+ return $channel_ids[ strtolower( $channel_name ) ];
654
+ }
655
+
656
+ return false;
657
+ }
658
+
659
+ function sby_set_channel_id_from_channel_name( $channel_name, $channel_id ) {
660
+ $channel_ids = get_option( 'sby_channel_ids', array() );
661
+
662
+ $channel_ids[ strtolower( $channel_name ) ] = $channel_id;
663
+
664
+ update_option( 'sby_channel_ids', $channel_ids, false );
665
+ }
666
+
667
+ function sby_icon( $icon, $class = '' ) {
668
+ $class = ! empty( $class ) ? ' ' . trim( $class ) : '';
669
+ if ( $icon === SBY_SLUG ) {
670
+ return '<svg aria-hidden="true" focusable="false" data-prefix="fab" data-icon="youtube" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" class="svg-inline--fa fa-youtube fa-w-18'.$class.'"><path fill="currentColor" d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z" class=""></path></svg>';
671
+ } else {
672
+ return '<i aria-hidden="true" role="img" class="fab fa-youtube"></i>';
673
+ }
674
+ }
675
+
676
+
677
+ /**
678
+ * @param $a
679
+ * @param $b
680
+ *
681
+ * @return false|int
682
+ */
683
+ function sby_date_sort( $a, $b ) {
684
+ $time_stamp_a = SBY_Parse::get_timestamp( $a );
685
+ $time_stamp_b = SBY_Parse::get_timestamp( $b );
686
+
687
+ if ( isset( $time_stamp_a ) ) {
688
+ return $time_stamp_b - $time_stamp_a;
689
+ } else {
690
+ return rand ( -1, 1 );
691
+ }
692
+ }
693
+
694
+ /**
695
+ * @param $a
696
+ * @param $b
697
+ *
698
+ * @return false|int
699
+ */
700
+ function sby_rand_sort( $a, $b ) {
701
+ return rand ( -1, 1 );
702
+ }
703
+
704
+ /**
705
+ * Converts a hex code to RGB so opacity can be
706
+ * applied more easily
707
+ *
708
+ * @param $hex
709
+ *
710
+ * @return string
711
+ */
712
+ function sby_hextorgb( $hex ) {
713
+ // allows someone to use rgb in shortcode
714
+ if ( strpos( $hex, ',' ) !== false ) {
715
+ return $hex;
716
+ }
717
+
718
+ $hex = str_replace( '#', '', $hex );
719
+
720
+ if ( strlen( $hex ) === 3 ) {
721
+ $r = hexdec( substr( $hex,0,1 ).substr( $hex,0,1 ) );
722
+ $g = hexdec( substr( $hex,1,1 ).substr( $hex,1,1 ) );
723
+ $b = hexdec( substr( $hex,2,1 ).substr( $hex,2,1 ) );
724
+ } else {
725
+ $r = hexdec( substr( $hex,0,2 ) );
726
+ $g = hexdec( substr( $hex,2,2 ) );
727
+ $b = hexdec( substr( $hex,4,2 ) );
728
+ }
729
+ $rgb = array( $r, $g, $b );
730
+
731
+ return implode( ',', $rgb ); // returns the rgb values separated by commas
732
+ }
733
+
734
+ function sby_get_utc_offset() {
735
+ return get_option( 'gmt_offset', 0 ) * HOUR_IN_SECONDS;
736
+ }
737
+
738
+ function sby_is_pro_version() {
739
+ return defined( 'SBY_PLUGIN_EDD_NAME' );
740
+ }
741
+
742
+ function sby_strip_after_hash( $string ) {
743
+ $string_array = explode( '#', $string );
744
+ $finished_string = $string_array[0];
745
+
746
+ return $finished_string;
747
+ }
748
+
749
+ function sby_get_account_bottom() {
750
+ return '';
751
+ }
752
+
753
+ function sby_get_account_top() {
754
+ return '';
755
+ }
756
+
757
+ function sby_replace_double_quotes( &$element, $index ) {
758
+ $element = str_replace( '"', "&quot;", $element );
759
+ }
760
+
761
+ function sby_esc_attr_with_br( $text ) {
762
+ return str_replace( array( '&lt;br /&gt;', '&lt;br&gt;' ), '&lt;br /&gt;', esc_attr( nl2br( $text ) ) );
763
+ }
764
+ /**
765
+ * Adds the ajax url and custom JavaScript to the page
766
+ */
767
+ function sby_custom_js() {
768
+ global $sby_settings;
769
+
770
+ $js = isset( $sby_settings['custom_js'] ) ? trim( $sby_settings['custom_js'] ) : '';
771
+
772
+ echo '<!-- YouTube Feed JS -->';
773
+ echo "\r\n";
774
+ echo '<script type="text/javascript">';
775
+ echo "\r\n";
776
+
777
+ if ( ! empty( $js ) ) {
778
+ echo "\r\n";
779
+ echo "jQuery( document ).ready(function($) {";
780
+ echo "\r\n";
781
+ echo "window.sbyCustomJS = function(){";
782
+ echo "\r\n";
783
+ echo stripslashes($js);
784
+ echo "\r\n";
785
+ echo "}";
786
+ echo "\r\n";
787
+ echo "});";
788
+ }
789
+
790
+ echo "\r\n";
791
+ echo '</script>';
792
+ echo "\r\n";
793
+ }
794
+ add_action( 'wp_footer', 'sby_custom_js' );
795
+
796
+ //Custom CSS
797
+ add_action( 'wp_head', 'sby_custom_css' );
798
+ function sby_custom_css() {
799
+ global $sby_settings;
800
+
801
+ $css = isset( $sby_settings['custom_css'] ) ? trim( $sby_settings['custom_css'] ) : '';
802
+
803
+ //Show CSS if an admin (so can see Hide Photos link), if including Custom CSS or if hiding some photos
804
+ if ( current_user_can( 'manage_youtube_feed_options' ) || current_user_can( 'manage_options' ) || ! empty( $css ) ) {
805
+
806
+ echo '<!-- Instagram Feed CSS -->';
807
+ echo "\r\n";
808
+ echo '<style type="text/css">';
809
+
810
+ if ( ! empty( $css ) ){
811
+ echo "\r\n";
812
+ echo stripslashes($css);
813
+ }
814
+
815
+ if ( current_user_can( 'manage_youtube_feed_options' ) || current_user_can( 'manage_options' ) ){
816
+ echo "\r\n";
817
+ echo "#sby_mod_link, #sby_mod_error{ display: block !important; width: 100%; float: left; box-sizing: border-box; }";
818
+ }
819
+
820
+ echo "\r\n";
821
+ echo '</style>';
822
+ echo "\r\n";
823
+ }
824
+
825
+ }
826
+
827
+ /**
828
+ * Makes the JavaScript file available and enqueues the stylesheet
829
+ * for the plugin
830
+ */
831
+ function sby_scripts_enqueue( $enqueue = false ) {
832
+ //Register the script to make it available
833
+
834
+ //Options to pass to JS file
835
+ global $sby_settings;
836
+
837
+ $js_file = 'js/sb-youtube.min.js';
838
+ if ( isset( $_GET['sby_debug'] ) ) {
839
+ $js_file = 'js/sb-youtube.js';
840
+ }
841
+
842
+ if ( isset( $sby_settings['enqueue_js_in_head'] ) && $sby_settings['enqueue_js_in_head'] ) {
843
+ wp_enqueue_script( 'sby_scripts', trailingslashit( SBY_PLUGIN_URL ) . $js_file, array('jquery'), SBYVER, false );
844
+ } else {
845
+ wp_register_script( 'sby_scripts', trailingslashit( SBY_PLUGIN_URL ) . $js_file, array('jquery'), SBYVER, true );
846
+ }
847
+
848
+ if ( isset( $sby_settings['enqueue_css_in_shortcode'] ) && $sby_settings['enqueue_css_in_shortcode'] ) {
849
+ wp_register_style( 'sby_styles', trailingslashit( SBY_PLUGIN_URL ) . 'css/sb-youtube.min.css', array(), SBYVER );
850
+ } else {
851
+ wp_enqueue_style( 'sby_styles', trailingslashit( SBY_PLUGIN_URL ) . 'css/sb-youtube.min.css', array(), SBYVER );
852
+ }
853
+ $data = array(
854
+ 'adminAjaxUrl' => admin_url( 'admin-ajax.php' ),
855
+ 'placeholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder.png',
856
+ 'placeholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder-narrow.png',
857
+ 'lightboxPlaceholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder.png',
858
+ 'lightboxPlaceholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder-narrow.png',
859
+ 'autoplay' => $sby_settings['playvideo'] === 'automatically',
860
+ 'semiEagerload' => false,
861
+ 'eagerload' => $sby_settings['eagerload']
862
+ );
863
+ //Pass option to JS file
864
+ wp_localize_script('sby_scripts', 'sbyOptions', $data );
865
+
866
+ if ( $enqueue ) {
867
+ wp_enqueue_style( 'sby_styles' );
868
+ wp_enqueue_script( 'sby_scripts' );
869
+ }
870
+ }
871
  add_action( 'wp_enqueue_scripts', 'sby_scripts_enqueue', 2 );
inc/widget.php CHANGED
@@ -1,63 +1,63 @@
1
- <?php
2
- /**
3
- * Class SbyWidget
4
- *
5
- * Adds support for a text widget with the [youtube-feed] shortcode inside
6
- */
7
-
8
- class SbyWidget extends WP_Widget
9
- {
10
- function __construct() {
11
- parent::__construct(
12
- 'youtube-feeds-widget',
13
- __( 'YouTube Feed', SBY_TEXT_DOMAIN ),
14
- array( 'description' => __( 'Display your YouTube feed', SBY_TEXT_DOMAIN ), )
15
- );
16
- }
17
-
18
- public function widget( $args, $instance ) {
19
-
20
- $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) : '';
21
- $content = isset( $instance['content'] ) ? strip_tags( $instance['content'] ) : '['.SBY_SLUG.']';
22
-
23
- echo $args['before_widget'];
24
-
25
- if ( ! empty( $title ) ) {
26
- echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
27
- }
28
-
29
- echo do_shortcode( $content );
30
-
31
- echo $args['after_widget'];
32
- }
33
-
34
- public function form( $instance ) {
35
-
36
- $title = isset( $instance['title'] ) ? $instance['title'] : '';
37
- $content = isset ( $instance['content'] ) ? strip_tags( $instance['content'] ) : '['.SBY_SLUG.']';
38
- ?>
39
- <p>
40
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label>
41
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
42
- </p>
43
- <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'content' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'content' ) ); ?>" rows="16"><?php echo strip_tags( $content ); ?></textarea>
44
- <?php
45
- }
46
-
47
- public function update( $new_instance, $old_instance ) {
48
- $instance = array();
49
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
50
- $instance['content'] = ( ! empty( $new_instance['content'] ) ) ? strip_tags( $new_instance['content'] ) : '';
51
-
52
- return $instance;
53
- }
54
- }
55
-
56
- // register and load the widget
57
- function sby_load_widget() {
58
- register_widget( 'SbyWidget' );
59
- }
60
- add_action( 'widgets_init', 'sby_load_widget' );
61
-
62
- // allow shortcode in widgets
63
- add_filter( 'widget_text', 'do_shortcode' );
1
+ <?php
2
+ /**
3
+ * Class SbyWidget
4
+ *
5
+ * Adds support for a text widget with the [youtube-feed] shortcode inside
6
+ */
7
+
8
+ class SbyWidget extends WP_Widget
9
+ {
10
+ function __construct() {
11
+ parent::__construct(
12
+ 'youtube-feeds-widget',
13
+ __( 'YouTube Feed', SBY_TEXT_DOMAIN ),
14
+ array( 'description' => __( 'Display your YouTube feed', SBY_TEXT_DOMAIN ), )
15
+ );
16
+ }
17
+
18
+ public function widget( $args, $instance ) {
19
+
20
+ $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) : '';
21
+ $content = isset( $instance['content'] ) ? strip_tags( $instance['content'] ) : '['.SBY_SLUG.']';
22
+
23
+ echo $args['before_widget'];
24
+
25
+ if ( ! empty( $title ) ) {
26
+ echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
27
+ }
28
+
29
+ echo do_shortcode( $content );
30
+
31
+ echo $args['after_widget'];
32
+ }
33
+
34
+ public function form( $instance ) {
35
+
36
+ $title = isset( $instance['title'] ) ? $instance['title'] : '';
37
+ $content = isset ( $instance['content'] ) ? strip_tags( $instance['content'] ) : '['.SBY_SLUG.']';
38
+ ?>
39
+ <p>
40
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:' ); ?></label>
41
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
42
+ </p>
43
+ <textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'content' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'content' ) ); ?>" rows="16"><?php echo strip_tags( $content ); ?></textarea>
44
+ <?php
45
+ }
46
+
47
+ public function update( $new_instance, $old_instance ) {
48
+ $instance = array();
49
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
50
+ $instance['content'] = ( ! empty( $new_instance['content'] ) ) ? strip_tags( $new_instance['content'] ) : '';
51
+
52
+ return $instance;
53
+ }
54
+ }
55
+
56
+ // register and load the widget
57
+ function sby_load_widget() {
58
+ register_widget( 'SbyWidget' );
59
+ }
60
+ add_action( 'widgets_init', 'sby_load_widget' );
61
+
62
+ // allow shortcode in widgets
63
+ add_filter( 'widget_text', 'do_shortcode' );
js/admin-notifications.js CHANGED
@@ -1,208 +1,208 @@
1
- /**
2
- * SBY Admin Notifications.
3
- *
4
- * @since 2.18
5
- */
6
-
7
- 'use strict';
8
-
9
- var SBYAdminNotifications = window.SBYAdminNotifications || ( function( document, window, $ ) {
10
-
11
- /**
12
- * Elements holder.
13
- *
14
- * @since 2.18
15
- *
16
- * @type {object}
17
- */
18
- var el = {
19
-
20
- $notifications: $( '#sby-notifications' ),
21
- $nextButton: $( '#sby-notifications .navigation .next' ),
22
- $prevButton: $( '#sby-notifications .navigation .prev' ),
23
- $adminBarCounter: $( '#wp-admin-bar-wpforms-menu .sby-menu-notification-counter' ),
24
- $adminBarMenuItem: $( '#wp-admin-bar-sby-notifications' ),
25
-
26
- };
27
-
28
- /**
29
- * Public functions and properties.
30
- *
31
- * @since 2.18
32
- *
33
- * @type {object}
34
- */
35
- var app = {
36
-
37
- /**
38
- * Start the engine.
39
- *
40
- * @since 2.18
41
- */
42
- init: function() {
43
- el.$notifications.find( '.messages a').each(function() {
44
- if ($(this).attr('href').indexOf('dismiss=') > -1 ) {
45
- $(this).addClass('button-dismiss');
46
- }
47
- })
48
-
49
- $( app.ready );
50
- },
51
-
52
- /**
53
- * Document ready.
54
- *
55
- * @since 2.18
56
- */
57
- ready: function() {
58
-
59
- app.updateNavigation();
60
- app.events();
61
- },
62
-
63
- /**
64
- * Register JS events.
65
- *
66
- * @since 2.18
67
- */
68
- events: function() {
69
-
70
- el.$notifications
71
- .on( 'click', '.dismiss', app.dismiss )
72
- .on( 'click', '.button-dismiss', app.buttonDismiss )
73
- .on( 'click', '.next', app.navNext )
74
- .on( 'click', '.prev', app.navPrev );
75
- },
76
-
77
- /**
78
- * Click on a dismiss button.
79
- *
80
- * @since 2.18
81
- */
82
- buttonDismiss: function( event ) {
83
- event.preventDefault();
84
- app.dismiss(event);
85
- },
86
-
87
- /**
88
- * Click on the Dismiss notification button.
89
- *
90
- * @since 2.18
91
- *
92
- * @param {object} event Event object.
93
- */
94
- dismiss: function( event ) {
95
-
96
- if ( el.$currentMessage.length === 0 ) {
97
- return;
98
- }
99
-
100
- // Update counter.
101
- var count = parseInt( el.$adminBarCounter.text(), 10 );
102
- if ( count > 1 ) {
103
- --count;
104
- el.$adminBarCounter.html( '<span>' + count + '</span>' );
105
- } else {
106
- el.$adminBarCounter.remove();
107
- el.$adminBarMenuItem.remove();
108
- }
109
-
110
- // Remove notification.
111
- var $nextMessage = el.$nextMessage.length < 1 ? el.$prevMessage : el.$nextMessage,
112
- messageId = el.$currentMessage.data( 'message-id' );
113
-
114
- if ( $nextMessage.length === 0 ) {
115
- el.$notifications.remove();
116
- } else {
117
- el.$currentMessage.remove();
118
- $nextMessage.addClass( 'current' );
119
- app.updateNavigation();
120
- }
121
-
122
- // AJAX call - update option.
123
- var data = {
124
- action: 'sby_dashboard_notification_dismiss',
125
- nonce: sby_admin.nonce,
126
- id: messageId,
127
- };
128
-
129
- $.post( sby_admin.ajax_url, data, function( res ) {
130
-
131
- if ( ! res.success ) {
132
- //SBYAdmin.debug( res );
133
- }
134
- } ).fail( function( xhr, textStatus, e ) {
135
-
136
- //SBYAdmin.debug( xhr.responseText );
137
- } );
138
- },
139
-
140
- /**
141
- * Click on the Next notification button.
142
- *
143
- * @since 2.18
144
- *
145
- * @param {object} event Event object.
146
- */
147
- navNext: function( event ) {
148
-
149
- if ( el.$nextButton.hasClass( 'disabled' ) ) {
150
- return;
151
- }
152
-
153
- el.$currentMessage.removeClass( 'current' );
154
- el.$nextMessage.addClass( 'current' );
155
-
156
- app.updateNavigation();
157
- },
158
-
159
- /**
160
- * Click on the Previous notification button.
161
- *
162
- * @since 2.18
163
- *
164
- * @param {object} event Event object.
165
- */
166
- navPrev: function( event ) {
167
-
168
- if ( el.$prevButton.hasClass( 'disabled' ) ) {
169
- return;
170
- }
171
-
172
- el.$currentMessage.removeClass( 'current' );
173
- el.$prevMessage.addClass( 'current' );
174
-
175
- app.updateNavigation();
176
- },
177
-
178
- /**
179
- * Update navigation buttons.
180
- *
181
- * @since 2.18
182
- */
183
- updateNavigation: function() {
184
-
185
- el.$currentMessage = el.$notifications.find( '.message.current' );
186
- el.$nextMessage = el.$currentMessage.next( '.message' );
187
- el.$prevMessage = el.$currentMessage.prev( '.message' );
188
-
189
- if ( el.$nextMessage.length === 0 ) {
190
- el.$nextButton.addClass( 'disabled' );
191
- } else {
192
- el.$nextButton.removeClass( 'disabled' );
193
- }
194
-
195
- if ( el.$prevMessage.length === 0 ) {
196
- el.$prevButton.addClass( 'disabled' );
197
- } else {
198
- el.$prevButton.removeClass( 'disabled' );
199
- }
200
- },
201
- };
202
-
203
- return app;
204
-
205
- }( document, window, jQuery ) );
206
-
207
- // Initialize.
208
- SBYAdminNotifications.init();
1
+ /**
2
+ * SBY Admin Notifications.
3
+ *
4
+ * @since 2.18
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ var SBYAdminNotifications = window.SBYAdminNotifications || ( function( document, window, $ ) {
10
+
11
+ /**
12
+ * Elements holder.
13
+ *
14
+ * @since 2.18
15
+ *
16
+ * @type {object}
17
+ */
18
+ var el = {
19
+
20
+ $notifications: $( '#sby-notifications' ),
21
+ $nextButton: $( '#sby-notifications .navigation .next' ),
22
+ $prevButton: $( '#sby-notifications .navigation .prev' ),
23
+ $adminBarCounter: $( '#wp-admin-bar-wpforms-menu .sby-menu-notification-counter' ),
24
+ $adminBarMenuItem: $( '#wp-admin-bar-sby-notifications' ),
25
+
26
+ };
27
+
28
+ /**
29
+ * Public functions and properties.
30
+ *
31
+ * @since 2.18
32
+ *
33
+ * @type {object}
34
+ */
35
+ var app = {
36
+
37
+ /**
38
+ * Start the engine.
39
+ *
40
+ * @since 2.18
41
+ */
42
+ init: function() {
43
+ el.$notifications.find( '.messages a').each(function() {
44
+ if ($(this).attr('href').indexOf('dismiss=') > -1 ) {
45
+ $(this).addClass('button-dismiss');
46
+ }
47
+ })
48
+
49
+ $( app.ready );
50
+ },
51
+
52
+ /**
53
+ * Document ready.
54
+ *
55
+ * @since 2.18
56
+ */
57
+ ready: function() {
58
+
59
+ app.updateNavigation();
60
+ app.events();
61
+ },
62
+
63
+ /**
64
+ * Register JS events.
65
+ *
66
+ * @since 2.18
67
+ */
68
+ events: function() {
69
+
70
+ el.$notifications
71
+ .on( 'click', '.dismiss', app.dismiss )
72
+ .on( 'click', '.button-dismiss', app.buttonDismiss )
73
+ .on( 'click', '.next', app.navNext )
74
+ .on( 'click', '.prev', app.navPrev );
75
+ },
76
+
77
+ /**
78
+ * Click on a dismiss button.
79
+ *
80
+ * @since 2.18
81
+ */
82
+ buttonDismiss: function( event ) {
83
+ event.preventDefault();
84
+ app.dismiss(event);
85
+ },
86
+
87
+ /**
88
+ * Click on the Dismiss notification button.
89
+ *
90
+ * @since 2.18
91
+ *
92
+ * @param {object} event Event object.
93
+ */
94
+ dismiss: function( event ) {
95
+
96
+ if ( el.$currentMessage.length === 0 ) {
97
+ return;
98
+ }
99
+
100
+ // Update counter.
101
+ var count = parseInt( el.$adminBarCounter.text(), 10 );
102
+ if ( count > 1 ) {
103
+ --count;
104
+ el.$adminBarCounter.html( '<span>' + count + '</span>' );
105
+ } else {
106
+ el.$adminBarCounter.remove();
107
+ el.$adminBarMenuItem.remove();
108
+ }
109
+
110
+ // Remove notification.
111
+ var $nextMessage = el.$nextMessage.length < 1 ? el.$prevMessage : el.$nextMessage,
112
+ messageId = el.$currentMessage.data( 'message-id' );
113
+
114
+ if ( $nextMessage.length === 0 ) {
115
+ el.$notifications.remove();
116
+ } else {
117
+ el.$currentMessage.remove();
118
+ $nextMessage.addClass( 'current' );
119
+ app.updateNavigation();
120
+ }
121
+
122
+ // AJAX call - update option.
123
+ var data = {
124
+ action: 'sby_dashboard_notification_dismiss',
125
+ nonce: sby_admin.nonce,
126
+ id: messageId,
127
+ };
128
+
129
+ $.post( sby_admin.ajax_url, data, function( res ) {
130
+
131
+ if ( ! res.success ) {
132
+ //SBYAdmin.debug( res );
133
+ }
134
+ } ).fail( function( xhr, textStatus, e ) {
135
+
136
+ //SBYAdmin.debug( xhr.responseText );
137
+ } );
138
+ },
139
+
140
+ /**
141
+ * Click on the Next notification button.
142
+ *
143
+ * @since 2.18
144
+ *
145
+ * @param {object} event Event object.
146
+ */
147
+ navNext: function( event ) {
148
+
149
+ if ( el.$nextButton.hasClass( 'disabled' ) ) {
150
+ return;
151
+ }
152
+
153
+ el.$currentMessage.removeClass( 'current' );
154
+ el.$nextMessage.addClass( 'current' );
155
+
156
+ app.updateNavigation();
157
+ },
158
+
159
+ /**
160
+ * Click on the Previous notification button.
161
+ *
162
+ * @since 2.18
163
+ *
164
+ * @param {object} event Event object.
165
+ */
166
+ navPrev: function( event ) {
167
+
168
+ if ( el.$prevButton.hasClass( 'disabled' ) ) {
169
+ return;
170
+ }
171
+
172
+ el.$currentMessage.removeClass( 'current' );
173
+ el.$prevMessage.addClass( 'current' );
174
+
175
+ app.updateNavigation();
176
+ },
177
+
178
+ /**
179
+ * Update navigation buttons.
180
+ *
181
+ * @since 2.18
182
+ */
183
+ updateNavigation: function() {
184
+
185
+ el.$currentMessage = el.$notifications.find( '.message.current' );
186
+ el.$nextMessage = el.$currentMessage.next( '.message' );
187
+ el.$prevMessage = el.$currentMessage.prev( '.message' );
188
+
189
+ if ( el.$nextMessage.length === 0 ) {
190
+ el.$nextButton.addClass( 'disabled' );
191
+ } else {
192
+ el.$nextButton.removeClass( 'disabled' );
193
+ }
194
+
195
+ if ( el.$prevMessage.length === 0 ) {
196
+ el.$prevButton.addClass( 'disabled' );
197
+ } else {
198
+ el.$prevButton.removeClass( 'disabled' );
199
+ }
200
+ },
201
+ };
202
+
203
+ return app;
204
+
205
+ }( document, window, jQuery ) );
206
+
207
+ // Initialize.
208
+ SBYAdminNotifications.init();
js/admin.js CHANGED
@@ -1,880 +1,914 @@
1
- (function($){
2
- function SbspfAdmin(plugin,$adminEl) {
3
- this.plugin = plugin;
4
- this.$adminEl = $adminEl;
5
- this.accesstokenSplitter = 'access_token=';
6
- }
7
-
8
- SbspfAdmin.prototype = {
9
- init: function() {
10
- var self = this,
11
- id = '#'+this.plugin,
12
- cla = '.'+this.plugin;
13
- this.addAccessTokenListener();
14
- $('.'+this.plugin +'_connected_accounts_wrap .'+this.plugin +'_connected_account').each(function() {
15
- self.initClickRemove($(this));
16
- self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
17
- });
18
- this.$adminEl.find('.sbspf_type_input').change(function() {
19
- self.updateOnSelect($(this));
20
- });self.updateOnSelect();
21
-
22
-
23
- self.initAppCredToggle();
24
-
25
- self.initWidthResponsiveToggle();
26
- self.initActionButtons();
27
-
28
- this.addManualAccessTokenListener();
29
-
30
- $(id + '_search_submit').click(function(event) {
31
- event.preventDefault();
32
-
33
- var submitData = {
34
- 'term' : $(id + '_channel_search').val(),
35
- 'action' : self.plugin + '_account_search',
36
- 'sbspf_nonce' : sbspf.nonce
37
- };
38
- var onSuccess = function (data) {
39
- if (data.trim().indexOf('{') === 0) {
40
- var returnObj = JSON.parse(data.trim());
41
-
42
- var html = '';
43
- $.each(returnObj.items,function(index,value){
44
- });
45
- }
46
- };
47
- sbAjax(submitData,onSuccess);
48
- });
49
-
50
- // color picker
51
- var $ctfColorpicker = $(cla+'_colorpicker');
52
-
53
- if($ctfColorpicker.length > 0){
54
- $ctfColorpicker.wpColorPicker();
55
- }
56
-
57
- // shortcode tooltips
58
- var $adminLabel = $(id +'_admin label');
59
-
60
- $adminLabel.click(function(){
61
- var $shortcode = $(this).siblings(cla + '_shortcode');
62
- if($shortcode.is(':visible')){
63
- $shortcode.hide();
64
- } else {
65
- $shortcode.show();
66
- }
67
- });
68
- $adminLabel.hover(function(){
69
- if($(this).siblings(cla + '_shortcode').length && ! $(this).find(cla + '_shortcode_symbol').length){
70
- $(this).append('<code class="'+self.plugin+'_shortcode_symbol">[]</code>');
71
- }
72
- }, function(){
73
- $(this).find(cla + '_shortcode_symbol').remove();
74
- });
75
- $(cla + '_shortcode').hide();
76
-
77
- //Scroll to hash for quick links
78
- $(id + '_admin a').click(function() {
79
- if(location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
80
- var target = $(this.hash);
81
- target = target.length ? target : this.hash.slice(1);
82
- if(target.length) {
83
- $('html,body').animate({
84
- scrollTop: target.offset().top
85
- }, 500);
86
- return false;
87
- }
88
- }
89
- });
90
-
91
- //Caching options
92
- if( $(id+'_caching_type_page').is(':checked') ) {
93
- $(cla+'-caching-cron-options').hide();
94
- $(cla+'-caching-page-options').show();
95
- } else {
96
- $(cla+'-caching-page-options').hide();
97
- $(cla+'-caching-cron-options').show();
98
- }
99
-
100
- $('.'+self.plugin+'_caching_type_input').change(function() {
101
- if (this.value == 'page') {
102
- $(cla+'-caching-cron-options').slideUp();
103
- $(cla+'-caching-page-options').slideDown();
104
- }
105
- else if (this.value == 'background') {
106
- $(cla+'-caching-page-options').slideUp();
107
- $(cla+'-caching-cron-options').slideDown();
108
- }
109
- });
110
-
111
- //Should we show the caching time settings?
112
- var sbspf_cache_cron_interval = $(id+'_cache_cron_interval').val(),
113
- $sbspf_caching_time_settings = $(id+'-caching-time-settings');
114
-
115
- //Should we show anything initially?
116
- if(sbspf_cache_cron_interval == '30mins' || sbspf_cache_cron_interval == '1hour') $sbspf_caching_time_settings.hide();
117
-
118
- $(id+'_cache_cron_interval').change(function(){
119
- sbspf_cache_cron_interval = $(id+'_cache_cron_interval').val();
120
-
121
- if(sbspf_cache_cron_interval == '30mins' || sbspf_cache_cron_interval == '1hour'){
122
- $sbspf_caching_time_settings.hide();
123
- } else {
124
- $sbspf_caching_time_settings.show();
125
- }
126
- });
127
- sbspf_cache_cron_interval = $(id+'_cache_cron_interval').val();
128
-
129
- if(sbspf_cache_cron_interval == '30mins' || sbspf_cache_cron_interval == '1hour'){
130
- $sbspf_caching_time_settings.hide();
131
- } else {
132
- $sbspf_caching_time_settings.show();
133
- }
134
-
135
- self.updateLayoutOptionsDisplay();
136
- $(cla + '_layout_type').change(function() {
137
- self.updateLayoutOptionsDisplay()
138
- });
139
- $(cla + '_sub_option_type').change(function() {
140
- self.updateBoxSelectionDisplay()
141
- });
142
- self.updateBoxSelectionDisplay();
143
-
144
- // tooltips
145
- $(id +'_admin '+ cla + '_tooltip_link').click(function(){
146
- $(this).closest('tr, h3, '+ cla + '_tooltip_wrap').find(cla + '_tooltip').slideToggle();
147
- });
148
-
149
- $(id +'_admin '+ cla + '_type_tooltip_link').click(function(){
150
- $(this).closest(cla + '_row').find(cla + '_tooltip').slideToggle();
151
- });
152
-
153
- //Mobile width
154
- var $feedWidth = $(id+'_admin '+id+'_settings_width'),
155
- $widthUnit = $(id+'_admin '+id+'_settings_width_unit');
156
- if ($feedWidth.length) {
157
- $feedWidth.change(function(){
158
- self.updateFeedWidthDisplay();
159
- });
160
- $widthUnit.change(function(){
161
- self.updateFeedWidthDisplay();
162
- });
163
- self.updateFeedWidthDisplay();
164
- }
165
-
166
- this.afterInit();
167
- },
168
- afterInit: function() {
169
-
170
- },
171
- addAccessTokenListener: function() {
172
- var self = this;
173
- if (window.location.hash.length > 5 && window.location.hash.indexOf(this.accesstokenSplitter) > -1) {
174
- var accessToken = window.location.hash.split(this.accesstokenSplitter);
175
- // clear access token from hash
176
- window.location.hash = '';
177
- var submitData = {
178
- 'access_token' : accessToken[1],
179
- 'action' : this.plugin + '_process_access_token',
180
- 'sbspf_nonce' : sbspf.nonce
181
- };
182
- var onSuccess = function (data) {
183
- if (data.trim().indexOf('{') === 0) {
184
- var returnObj = JSON.parse(data.trim());
185
- $('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
186
- self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
187
- self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
188
- }
189
- };
190
- sbAjax(submitData,onSuccess);
191
- }
192
- },
193
- initClickRemove: function(el) {
194
- var self = this;
195
- el.find('.'+this.plugin +'_delete_account').click(function() {
196
- if (!$(this).closest('.'+self.plugin +'_connected_accounts_wrap').hasClass(self.plugin +'-waiting')) {
197
- $(this).closest('.'+self.plugin +'_connected_accounts_wrap').addClass(self.plugin +'-waiting');
198
- var $connectedAccount = $(this).closest('.'+self.plugin +'_connected_account'),
199
- accountID = $connectedAccount.attr('data-userid');
200
-
201
- if (window.confirm("Delete this connected account?")) {
202
- $('#'+self.plugin +'_user_feed_id_' + accountID).remove();
203
- $('#'+self.plugin +'_connected_account_' + accountID).append('<div class="spinner" style="margin-top: -10px;visibility: visible;top: 50%;position: absolute;right: 50%;"></div>').find('.'+self.plugin +'_ca_info').css('opacity','.5');
204
-
205
- var submitData = {
206
- 'account_id' : accountID,
207
- 'action' : self.getAction( 'ca_after_remove_clicked' ),
208
- 'sbspf_nonce' : sbspf.nonce
209
- };
210
- var onSuccess = function (data) {
211
- if (data.trim().indexOf('{') === 0) {
212
- var returnObj = JSON.parse(data.trim());
213
- $('.'+self.plugin +'-waiting').removeClass(self.plugin +'-waiting');
214
- $connectedAccount.fadeOut(300, function() { $(this).remove(); });
215
- self.afterConnectedAccountRemoved(accountID);
216
- }
217
- };
218
- sbAjax(submitData,onSuccess);
219
- } else {
220
- $('.'+self.plugin +'-waiting').removeClass(self.plugin +'-waiting');
221
- }
222
- }
223
-
224
- });
225
- },
226
- initInfoToggle: function(el) {
227
- var self = this;
228
- el.find('.'+self.plugin +'_ca_show_token').off().click(function() {
229
- $(this).closest('.'+self.plugin +'_ca_info').find('.'+self.plugin +'_ca_accesstoken').slideToggle(200);
230
- });
231
-
232
- el.find('.'+self.plugin +'_ca_token_shortcode').off().click(function() {
233
- $(this).closest('.'+self.plugin +'_ca_info').find('.'+self.plugin +'_ca_shortcode').slideToggle(200);
234
- });
235
- },
236
- initAppCredToggle: function() {
237
- var self = this;
238
- $('#'+self.plugin +'_have_own_tokens').click(function() {
239
- if ($(this).is(':checked')) {
240
- $(this).closest('form').find('.'+self.plugin +'_own_credentials_wrap').slideDown();
241
- } else {
242
- $(this).closest('form').find('.'+self.plugin +'_own_credentials_wrap').slideUp();
243
- }
244
- });
245
-
246
- if ($('#'+self.plugin +'_have_own_tokens').is(':checked')) {
247
- $('#'+self.plugin +'_have_own_tokens').closest('form').find('.'+self.plugin +'_own_credentials_wrap').slideDown();
248
- } else {
249
- $('#'+self.plugin +'_have_own_tokens').closest('form').find('.'+self.plugin +'_own_credentials_wrap').slideUp();
250
- }
251
- },
252
- initWidthResponsiveToggle: function() {
253
- //Mobile width
254
- var feedWidth = $('#sby_settings_width').length ? $('#sby_settings_width').val() : '100',
255
- widthUnit = $('#sby_settings_widthunit').length ? $('#sby_settings_widthunit').val() : '%',
256
- $widthOptions = $('#sbspf_width_options');
257
-
258
- if ($('#sby_settings_widthunit').length) {
259
-
260
- //Show initially if a width is set
261
- if (feedWidth !== '100' && widthUnit === '%') {
262
- $widthOptions.slideDown();
263
- } else {
264
- $widthOptions.slideUp();
265
- }
266
-
267
- $('#sby_settings_width_unit, #sby_settings_width').change(function(){
268
- feedWidth = $('#sby_settings_width').length ? $('#sby_settings_width').val() : '100';
269
- widthUnit = $('#sby_settings_widthunit').length ? $('#sby_settings_widthunit').val() : '%';
270
-
271
- if (feedWidth !== '100' && widthUnit === '%') {
272
- $widthOptions.slideDown();
273
- } else {
274
- $widthOptions.slideUp();
275
- }
276
-
277
- });
278
-
279
- }
280
- },
281
- initActionButtons: function() {
282
- $('#sbspf_admin .sbspf-button-action').each(function(){
283
- $(this).click(function() {
284
- event.preventDefault();
285
- $(this).next('.sbspf_success').remove();
286
-
287
- var doAction = typeof $(this).attr('data-sby-action') !== 'undefined' ? $(this).attr('data-sby-action') : '',
288
- confirmMessage = typeof $(this).attr('data-sby-confirm') !== 'undefined' ? $(this).attr('data-sby-confirm') : false,
289
- $targetWaitingEl = typeof $(this).attr('data-sby-waiter') !== 'undefined' ? $($(this).attr('data-sby-waiter')) : $(this),
290
- $self = $(this);
291
- if (!confirmMessage || window.confirm(confirmMessage)) {
292
- $(this).attr('disabled',true);
293
- $targetWaitingEl.after('<div class="spinner sbspf_spinner" style="display:inline-block;visibility: visible;"></div>');
294
-
295
- var submitData = {
296
- 'action' : doAction,
297
- 'sbspf_nonce' : sbspf.nonce
298
- };
299
- var onSuccess = function (data) {
300
- $self.removeAttr('disabled');
301
- $targetWaitingEl.next('.spinner').fadeOut('slow',function(){
302
- $targetWaitingEl.after('<span class="sbspf_success"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="check-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-check-circle fa-w-16"><path fill="currentColor" d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z" class=""></path></svg></span>');
303
- });
304
-
305
- if (data.trim().indexOf('{') === 0) {
306
- var returnObj = JSON.parse(data.trim());
307
- console.log(returnObj);
308
-
309
- }
310
- };
311
- sbAjax(submitData,onSuccess);
312
- } else {
313
- $('.'+self.plugin +'-waiting').removeClass(self.plugin +'-waiting');
314
- }
315
- });
316
- });
317
- },
318
- getAction(action) {
319
- return self.plugin + '_' + action
320
- },
321
- addManualAccessTokenListener: function() {
322
- var self = this,
323
- id = '#'+this.plugin,
324
- cla = '.'+this.plugin;
325
-
326
- $(cla+'_manually_connect_wrap').hide();
327
- $(cla+'_manually_connect').click(function(event) {
328
- event.preventDefault();
329
- if ( $(cla+'_manually_connect_wrap').is(':visible') ) {
330
- $(cla+'_manually_connect_wrap').slideUp(200);
331
- } else {
332
- $(cla+'_manually_connect_wrap').slideDown(200);
333
- $(id+'_manual_at').focus();
334
- }
335
- });
336
-
337
- $(id+'_manual_submit').click(function(event) {
338
- event.preventDefault();
339
- var $self = $(this);
340
- var accessToken = $(id+'_manual_at').val(),
341
- error = false;
342
-
343
- if (accessToken.length < 15) {
344
- if (!$(cla+'_manually_connect_wrap').find(cla+'_user_id_error').length) {
345
- $(cla+'_manually_connect_wrap').show().prepend('<div class="'+self.plugin+'_user_id_error" style="display:block;">Please enter a valid access token</div>');
346
- }
347
- } else if (! error) {
348
- $(this).attr('disabled',true);
349
- $(this).closest(cla+'_manually_connect_wrap').fadeOut();
350
- $(cla+'_connected_accounts_wrap').fadeTo("slow" , 0.5).find(cla+'_user_id_error').remove();
351
-
352
- var submitData = {
353
- 'access_token' : accessToken,
354
- 'action' : self.plugin + '_process_access_token',
355
- 'sbspf_nonce' : sbspf.nonce
356
- };
357
- var onSuccess = function (data) {
358
- $(cla+'_connected_accounts_wrap').fadeTo("slow" , 1);
359
- $self.removeAttr('disabled');
360
- var returnObj = JSON.parse(data.trim());
361
- $('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
362
- self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
363
- self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
364
- };
365
- sbAjax(submitData,onSuccess);
366
- }
367
-
368
- });
369
- },
370
- afterConnectedAccountRemoved: function(accountID) {
371
-
372
- },
373
- updateLayoutOptionsDisplay: function() {
374
- self = this;
375
- setTimeout(function(){
376
- $('.'+self.plugin+'_layout_settings').hide();
377
- $('.'+self.plugin+'_layout_settings.'+self.plugin+'_layout_type_'+$('.'+self.plugin+'_layout_type:checked').val()).show();
378
- }, 1);
379
- },
380
- updateBoxSelectionDisplay: function() {
381
- self = this;
382
- setTimeout(function(){
383
- $('.'+self.plugin+'_sub_option_settings').hide();
384
- $('.'+self.plugin+'_sub_option_settings.'+self.plugin+'_sub_option_type_'+$('.'+self.plugin+'_sub_option_type:checked').val()).show();
385
- }, 1);
386
- },
387
- updateFeedWidthDisplay: function() {
388
- self = this;
389
- var sbspfFeedWidth = $('#'+self.plugin+'_admin '+'#'+self.plugin+'_settings_width').val(),
390
- sbspfWidthUnit = $('#'+self.plugin+'_admin '+'#'+self.plugin+'_settings_width_unit').val(),
391
- $sbspfWidthOptions = $('#'+self.plugin+'_admin '+'#'+self.plugin+'_width_options');
392
-
393
- if( sbspfFeedWidth.length < 2 || (sbspfFeedWidth == '100' && sbspfWidthUnit == '%') ) {
394
- $sbspfWidthOptions.slideUp();
395
- } else {
396
- $sbspfWidthOptions.slideDown();
397
- }
398
- },
399
- updateOnSelect: function($changed) {
400
- this.$adminEl.find('.sbspf_type_input').each(function() {
401
- if ($(this).is(':checked')) {
402
- $(this).closest('.sbspf_type_row').find('.sbspf_onselect').show();
403
- } else {
404
- $(this).closest('.sbspf_type_row').find('.sbspf_onselect').hide();
405
- }
406
- });
407
- //console.log($changed.is(':checked'),$changed.closest('.sbspf_type_row').find('.sbspf_onselect').length)
408
-
409
- },
410
- encodeHTML: function(raw) {
411
- // make sure passed variable is defined
412
- if (typeof raw === 'undefined') {
413
- return '';
414
- }
415
- // replace greater than and less than symbols with html entity to disallow html in comments
416
- var encoded = raw.replace(/(>)/g,'&gt;'),
417
- encoded = encoded.replace(/(<)/g,'&lt;');
418
- encoded = encoded.replace(/(&lt;br\/&gt;)/g,'<br>');
419
- encoded = encoded.replace(/(&lt;br&gt;)/g,'<br>');
420
-
421
- return encoded;
422
- },
423
- };
424
-
425
- window.sbspf_admin_init = function() {
426
- var plugin = typeof $('.sbspf-admin').attr('data-sb-plugin') !== 'undefined' ? $('.sbspf-admin').attr('data-sb-plugin') : 'sbspf',
427
- $adminEl = $('#sbspf_admin.sby_admin');
428
- window.sb = new SbspfAdmin(plugin,$adminEl);
429
- window.sb.init();
430
- };
431
-
432
- function sbAjax(submitData,onSuccess) {
433
- $.ajax({
434
- url: sbspf.ajaxUrl,
435
- type: 'post',
436
- data: submitData,
437
- success: onSuccess
438
- });
439
- }
440
-
441
- function SbYoutubeAdmin(plugin,$adminEl) {
442
- SbspfAdmin.call(this, plugin,$adminEl);
443
- this.afterInit = function() {
444
- var self = this,
445
- id = '#'+this.plugin,
446
- cla = '.'+this.plugin;
447
-
448
- // notices
449
-
450
- if (jQuery('#sbspf-notice-bar').length) {
451
- jQuery('#wpadminbar').after(jQuery('#sbspf-notice-bar'));
452
- jQuery('#wpcontent').css('padding-left', 0);
453
- jQuery('#wpbody').css('padding-left', '20px');
454
- jQuery('#sbspf-notice-bar').show();
455
- }
456
-
457
- jQuery('#sbspf-notice-bar .dismiss').click(function(e) {
458
- e.preventDefault();
459
- jQuery('#sbspf-notice-bar').remove();
460
- var submitData = {
461
- 'action' : 'sby_lite_dismiss',
462
- 'sbspf_nonce' : sbspf.nonce
463
- };
464
- var onSuccess = function (data) {
465
- };
466
- sbAjax(submitData,onSuccess);
467
- });
468
-
469
- $('#sbspf_usecustomsearch').change(function() {
470
- if ($(this).is(':checked')) {
471
- $('#sbspf_usecustomsearch_reveal').show();
472
- } else {
473
- $('#sbspf_usecustomsearch_reveal').hide();
474
- }
475
- });
476
-
477
- if ($('#sbspf_usecustomsearch').is(':checked')) {
478
- $('#sbspf_usecustomsearch_reveal').show();
479
- } else {
480
- $('#sbspf_usecustomsearch_reveal').hide();
481
- }
482
-
483
-
484
- $('.sbspf_dismiss_button').click(function() {
485
- event.preventDefault();
486
- $('#sbspf_modal_overlay').remove();
487
- var submitData = {
488
- 'action' : $(this).attr('data-action')
489
- };
490
- sbAjax(submitData,function() {});
491
- });
492
-
493
- $('.sbspf_dismiss_at_warning_button').click(function() {
494
- event.preventDefault();
495
- $('#sbspf_modal_overlay').remove();
496
- var submitData = {
497
- 'action' : $(this).attr('data-action')
498
- };
499
- sbAjax(submitData,function() {});
500
- });
501
-
502
- $('.sby_api_key_needed').each(function() {
503
- $(this).find('label').append('<span class="sby_api_key_needed_message"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="key" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-key fa-w-16"><path fill="currentColor" d="M512 176.001C512 273.203 433.202 352 336 352c-11.22 0-22.19-1.062-32.827-3.069l-24.012 27.014A23.999 23.999 0 0 1 261.223 384H224v40c0 13.255-10.745 24-24 24h-40v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24v-78.059c0-6.365 2.529-12.47 7.029-16.971l161.802-161.802C163.108 213.814 160 195.271 160 176 160 78.798 238.797.001 335.999 0 433.488-.001 512 78.511 512 176.001zM336 128c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" class=""></path></svg> API Key Needed</span>');
504
- });
505
-
506
- var proJustHoverHTML = '<a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&amp;utm_campaign=sby" target="_blank" class="sbspf_lock sbspf_pro_lock"><i class="fa fa-rocket"></i>Pro</a>',
507
- proLockHTML = '<p class="sbspf_pro_tooltip" style="display: none;">Upgrade to the Pro version to unlock this feature<i class="fa fa-caret-down" aria-hidden="true"></i></p>' + proJustHoverHTML,
508
- proAvailableHTML = '<span class="sbspf_note"> - <a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&amp;utm_campaign=sby" target="_blank">Available in Pro version</a></span>';
509
-
510
- $('.sbspf_pro_only').each(function() {
511
- if (jQuery(this).closest('td').find('.sbspf_sub_options').length) {
512
- if (!jQuery(this).closest('td').find('.sbspf_lock').length) {
513
- jQuery(this).closest('td').find('.sbspf_sub_options').append(proLockHTML);
514
- }
515
- jQuery(this).closest('td').find('input,select,textarea').each(function() {
516
- if (typeof jQuery(this).attr('name') !== 'undefined') {
517
- jQuery(this).attr('name',jQuery(this).attr('name').replace('sb','demosb'));
518
- }
519
- });
520
- if (jQuery(this).html() === '') {
521
- jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
522
- if (jQuery(this).html() === '') {
523
- jQuery(this).remove();
524
- }
525
- }
526
- } else if (jQuery(this).hasClass('sbspf_layout_cell')) {
527
- if (!jQuery(this).find('.sbspf_lock').length) {
528
- jQuery(this).append(proJustHoverHTML);
529
- jQuery(this).find('img').css('opacity', .4);
530
- }
531
- } else if (jQuery(this).hasClass('sbspf_layout_settings')){
532
- if (!jQuery(this).find('.sbspf_lock').length) {
533
- jQuery(this).find('.sbspf_layout_setting').first().append('<span class="sbspf_note"><a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&amp;utm_campaign=sby" target="_blank">Upgrade to Pro to enable the carousel layout</a></span>');
534
- jQuery(this).find('input,select,textarea').attr('disabled','true');
535
- }
536
- } else {
537
- if (jQuery(this).closest('td').find('.sbspf_single_checkbox').length
538
- && ! jQuery(this).closest('td').find('.sbspf_lock').length){
539
- jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
540
- jQuery(this).closest('tr').find('.sbspf_single_checkbox').next('label').after(proAvailableHTML);
541
- if (jQuery(this).html() === '') {
542
- jQuery(this).remove();
543
- }
544
- } else if (jQuery(this).closest('td').find('select.sbspf_pro_only').length
545
- && ! jQuery(this).closest('td').find('.sbspf_lock').length){
546
- jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
547
- jQuery(this).closest('tr').find('select.sbspf_pro_only').after(proAvailableHTML);
548
- if (jQuery(this).html() === '') {
549
- jQuery(this).remove();
550
- }
551
- }else if (jQuery(this).find('input[type=checkbox]').length) {
552
- var $closestTD = jQuery(this).closest('td');
553
- jQuery(this).find('input').attr('disabled','true');
554
- if (jQuery(this).find('input').is(':checked')) {
555
- var $clone = jQuery(this).find('input').clone();
556
- $clone.removeAttr('disabled').removeAttr('checked').attr('type','hidden');
557
- jQuery(this).append($clone);
558
- }
559
- jQuery(this).find('input').removeAttr('checked');
560
- if (!$closestTD.find('.sbspf_disabled_wrap').length) {
561
- $closestTD.append('<div class="sbspf_disabled_wrap sby_includes_pro_only"></div>');
562
- $closestTD.find('.sby_includes_pro_only').append('<span class="sbspf_note"><a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&amp;utm_campaign=sby" target="_blank">Upgrade to Pro to display video descriptions, dates, statistics, live streaming information, and more.</a></span>');
563
- }
564
- }
565
-
566
- }
567
- });
568
-
569
- var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
570
- $closestTD.append('<div class="sbspf_disabled_wrap sby_types_disabled_wrap">'+proLockHTML+'</div>');
571
-
572
- $('.sbspf_type_row').each(function() {
573
- if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
574
- $('.sbspf_disabled_wrap').append($(this));
575
- $(this).find('input').attr('disabled',true);
576
- } else {
577
- $(this).find('input').removeAttr('disabled');
578
- }
579
- });
580
-
581
- $('.sbspf_pro_section').each(function() {
582
- if ($(this).find('.sbspf_pro_reveal').length) {
583
- $(this).find('h2').first().after($(this).find('.sbspf_pro_reveal'));
584
- $(this).find('tr').addClass('sbspf_pro_only_row');
585
- var $table = $(this).find('table');
586
- $table.hide();
587
- $(this).find('.sbspf-show-pro').click(function(event){
588
- event.preventDefault();
589
- $table.toggle();
590
- });
591
- jQuery(this).find('input,select,textarea').each(function() {
592
- if (typeof jQuery(this).attr('name') !== 'undefined') {
593
- jQuery(this).attr('name',jQuery(this).attr('name').replace('sb','demosb'));
594
- }
595
- });
596
- }
597
- });
598
-
599
- jQuery('.sbspf_pro_lock').hover(function(){
600
- jQuery(this).siblings('.sbspf_pro_tooltip').show();
601
- }, function(){
602
- jQuery('.sbspf_pro_tooltip').hide();
603
- });
604
-
605
- if (typeof $('#sbspf_get_token').attr('data-show-warning') !== 'undefined') {
606
- $('#sbspf_get_token').click(function(event) {
607
- event.preventDefault();
608
- var html = self.getModal();
609
- $('#sbspf_admin').append(html);
610
- $('#sbspf_admin').find('.sbspf_modal_close').click(function() {
611
- $('#sbspf_admin').find('#sbspf_modal_overlay').remove();
612
- });
613
-
614
- var submitData = {
615
- 'action' : 'sby_dismiss_connect_warning_button'
616
- };
617
- sbAjax(submitData,function() {});
618
- })
619
- }
620
-
621
- };
622
-
623
- this.toggleCustomDateField = function() {
624
- if ($('#sby_settings_dateformat').val() === 'custom') {
625
- $('.sby_customdate_wrap').slideDown();
626
- } else {
627
- $('.sby_customdate_wrap').slideUp();
628
- }
629
- };
630
-
631
- this.toggleAPIKeyWarnings = function() {
632
- if ($('#sby_api_key').val() !== '') {
633
- if ($('.sby_disabled_wrap').length) {
634
- var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
635
- $('.sbspf_type_row').each(function() {
636
- if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
637
- $closestTD.append($(this));
638
- $(this).find('input').removeAttr('disabled');
639
- }
640
- });
641
- $('.sby_disabled_wrap').remove();
642
- }
643
-
644
-
645
- } else if (!$('.sby_disabled_wrap').length) {
646
- var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
647
- $closestTD.append('<div class="sby_disabled_wrap sbspf_fade"><div class="sbspf_lock"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="key" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-key fa-w-16"><path fill="currentColor" d="M512 176.001C512 273.203 433.202 352 336 352c-11.22 0-22.19-1.062-32.827-3.069l-24.012 27.014A23.999 23.999 0 0 1 261.223 384H224v40c0 13.255-10.745 24-24 24h-40v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24v-78.059c0-6.365 2.529-12.47 7.029-16.971l161.802-161.802C163.108 213.814 160 195.271 160 176 160 78.798 238.797.001 335.999 0 433.488-.001 512 78.511 512 176.001zM336 128c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" class=""></path></svg>API Key Needed</div></div>');
648
-
649
- $('.sbspf_type_row').each(function() {
650
- if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
651
- $('.sby_disabled_wrap').append($(this));
652
- $(this).find('input').attr('disabled',true);
653
- } else {
654
- $(this).find('input').removeAttr('disabled');
655
- }
656
- });
657
- }
658
-
659
- };
660
-
661
- this.getModal = function () {
662
-
663
- var modal = '<div id="sbspf_modal_overlay">' +
664
- '<div class="sbspf_modal">' +
665
- '<div class="sbspf_modal_message">' +
666
- ' <div class="sby_before_connection">' +
667
- ' <p>The Feeds for YouTube plugin requires <strong>"read only"</strong> access to your YouTube account in order to retrieve data from the YouTube API.</p>' +
668
- ' <p><strong>Please note:</strong> The plugin is only able to read public data from your account and cannot be used to edit or write to your YouTube account in any way.</p>' +
669
- ' <p class="sbspf_submit">' +
670
- ' <a href="'+$('#sbspf_get_token').attr('href')+'" class="button button-primary sbspf_dismiss_connect_warning_button" data-action="sby_dismiss_connect_warning_notice">Continue</a>' +
671
- ' </p>' +
672
- ' <a href="JavaScript:void(0);" class="sbspf_modal_close sbspf_dismiss_connect_warning_button" data-action="sby_dismiss_connect_warning_notice"><i class="fa fa-times"></i></a>' +
673
- '' +
674
- ' </div>' +
675
- '</div>' +
676
- '' +
677
- '</div>' +
678
- '</div>';
679
-
680
- return modal;
681
- };
682
-
683
- this.toggleAccessTokenDisclaimer = function () {
684
- var self = this;
685
- if ($('.sby_account_just_added').length) {
686
- $('.sby_api_needed').remove();
687
- $('.sby_after_connection').show();
688
- } else {
689
- $('.sby_after_connection').remove();
690
- $('.sby_api_needed').show();
691
- }
692
- };
693
-
694
- this.addAccessTokenListener = function () {
695
- var self = this;
696
- if (window.location.hash.length > 5 && window.location.hash.indexOf(this.accesstokenSplitter) > -1) {
697
- var accessToken = window.location.hash.split(this.accesstokenSplitter);
698
- // clear access token from hash
699
- window.location.hash = '';
700
- var submitData = {
701
- 'access_token' : accessToken[1],
702
- 'action' : 'sby_process_access_token',
703
- 'sbspf_nonce' : sbspf.nonce
704
- };
705
- var onSuccess = function (data) {
706
- if (data.trim().indexOf('{') === 0) {
707
- var returnObj = JSON.parse(data.trim());
708
- $('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
709
- self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
710
- self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
711
- }
712
- };
713
- sbAjax(submitData,onSuccess);
714
- }
715
- };
716
-
717
- this.addManualAccessTokenListener = function() {
718
- var self = this,
719
- id = '#'+this.plugin,
720
- cla = '.'+this.plugin;
721
-
722
- $(cla+'_manually_connect_wrap').hide();
723
- $(cla+'_manually_connect').click(function(event) {
724
- event.preventDefault();
725
- if ( $(cla+'_manually_connect_wrap').is(':visible') ) {
726
- $(cla+'_manually_connect_wrap').slideUp(200);
727
- } else {
728
- $(cla+'_manually_connect_wrap').slideDown(200);
729
- $(id+'_manual_at').focus();
730
- }
731
- });
732
-
733
- $(id+'_manual_submit').click(function(event) {
734
- event.preventDefault();
735
- var $self = $(this);
736
- var accessToken = $(id+'_manual_at').val(),
737
- refreshToken = $(id+'_manual_rt').val(),
738
- error = false;
739
-
740
- if (accessToken.length < 15) {
741
- if (!$(cla+'_manually_connect_wrap').find(cla+'_user_id_error').length) {
742
- $(cla+'_manually_connect_wrap').show().prepend('<div class="'+self.plugin+'_user_id_error" style="display:block;">Please enter a valid access token</div>');
743
- }
744
- } else if (! error) {
745
- $(this).attr('disabled',true);
746
- $(this).closest(cla+'_manually_connect_wrap').fadeOut();
747
- $(cla+'_connected_accounts_wrap').fadeTo("slow" , 0.5).find(cla+'_user_id_error').remove();
748
-
749
- var submitData = {
750
- 'sby_access_token' : accessToken,
751
- 'sby_refresh_token' : refreshToken,
752
- 'action' : 'sby_process_access_token',
753
- 'sbspf_nonce' : sbspf.nonce
754
- };
755
- var onSuccess = function (data) {
756
- $(cla+'_connected_accounts_wrap').fadeTo("slow" , 1);
757
- $self.removeAttr('disabled');
758
- if (data.trim().indexOf('{') === 0) {
759
- var returnObj = JSON.parse(data.trim());
760
- if (typeof returnObj.error === 'undefined') {
761
- if (!$('#sbspf_connected_account_'+returnObj.account_id).length) {
762
- $('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
763
- self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
764
- self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
765
- console.log('added');
766
- } else {
767
- $('#sbspf_connected_account_'+returnObj.account_id).replaceWith(returnObj.html);
768
- self.initClickRemove($('#sbspf_connected_account_'+returnObj.account_id));
769
- self.initInfoToggle($('#sbspf_connected_account_'+returnObj.account_id));
770
- console.log('updated');
771
- }
772
- } else {
773
- alert(returnObj.error);
774
- }
775
- }
776
-
777
- };
778
- sbAjax(submitData,onSuccess);
779
- }
780
-
781
- });
782
- };
783
- this.addManualAccessTokenListener = function() {
784
- var self = this,
785
- id = '#'+this.plugin,
786
- cla = '.'+this.plugin;
787
-
788
- $(cla+'_manually_connect_wrap').hide();
789
- $(cla+'_manually_connect').click(function(event) {
790
- event.preventDefault();
791
- if ( $(cla+'_manually_connect_wrap').is(':visible') ) {
792
- $(cla+'_manually_connect_wrap').slideUp(200);
793
- } else {
794
- $(cla+'_manually_connect_wrap').slideDown(200);
795
- $(id+'_manual_at').focus();
796
- }
797
- });
798
-
799
- $(id+'_manual_submit').click(function(event) {
800
- event.preventDefault();
801
- var $self = $(this);
802
- var accessToken = $(id+'_manual_at').val(),
803
- refreshToken = $(id+'_manual_rt').val(),
804
- error = false;
805
-
806
- if (accessToken.length < 15) {
807
- if (!$(cla+'_manually_connect_wrap').find(cla+'_user_id_error').length) {
808
- $(cla+'_manually_connect_wrap').show().prepend('<div class="'+self.plugin+'_user_id_error" style="display:block;">Please enter a valid access token</div>');
809
- }
810
- } else if (! error) {
811
- $(this).attr('disabled',true);
812
- $(this).closest(cla+'_manually_connect_wrap').fadeOut();
813
- $(cla+'_connected_accounts_wrap').fadeTo("slow" , 0.5).find(cla+'_user_id_error').remove();
814
-
815
- var submitData = {
816
- 'sby_access_token' : accessToken,
817
- 'sby_refresh_token' : refreshToken,
818
- 'action' : 'sby_process_access_token',
819
- 'sbspf_nonce' : sbspf.nonce
820
- };
821
- var onSuccess = function (data) {
822
- $(cla+'_connected_accounts_wrap').fadeTo("slow" , 1);
823
- $self.removeAttr('disabled');
824
- if (data.trim().indexOf('{') === 0) {
825
- var returnObj = JSON.parse(data.trim());
826
- if (typeof returnObj.error === 'undefined') {
827
- if (!$('#sbspf_connected_account_'+returnObj.account_id).length) {
828
- $('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
829
- self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
830
- self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
831
- console.log('added');
832
- } else {
833
- $('#sbspf_connected_account_'+returnObj.account_id).replaceWith(returnObj.html);
834
- self.initClickRemove($('#sbspf_connected_account_'+returnObj.account_id));
835
- self.initInfoToggle($('#sbspf_connected_account_'+returnObj.account_id));
836
- console.log('updated');
837
- }
838
- } else {
839
- alert(returnObj.error);
840
- }
841
- }
842
-
843
- self.toggleAccessTokenDisclaimer();
844
- $('.sbspf_dismiss_at_warning_button').click(function() {
845
- event.preventDefault();
846
- $('#sbspf_modal_overlay').remove();
847
- var submitData = {
848
- 'action' : $(this).attr('data-action')
849
- };
850
- sbAjax(submitData,function() {});
851
- });
852
-
853
- };
854
- sbAjax(submitData,onSuccess);
855
- }
856
-
857
- });
858
- };
859
- this.getAction = function(action) {
860
- return 'sby_' + action;
861
- };
862
-
863
-
864
- }
865
-
866
- SbYoutubeAdmin.prototype = Object.create(SbspfAdmin.prototype);
867
-
868
-
869
- window.sby_admin_init = function() {
870
- var plugin = typeof $('.sbspf-admin').attr('data-sb-plugin') !== 'undefined' ? $('.sbspf-admin').attr('data-sb-plugin') : 'sbspf',
871
- $adminEl = $('#sbspf_admin.sby_admin');
872
- window.sb = new SbYoutubeAdmin(plugin,$adminEl);
873
- window.sb.init();
874
- };
875
-
876
- })(jQuery);
877
-
878
- jQuery(document).ready(function($) {
879
- sby_admin_init();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
880
  });
1
+ (function($){
2
+ function SbspfAdmin(plugin,$adminEl) {
3
+ this.plugin = plugin;
4
+ this.$adminEl = $adminEl;
5
+ this.accesstokenSplitter = 'access_token=';
6
+ }
7
+
8
+ SbspfAdmin.prototype = {
9
+ init: function() {
10
+ var self = this,
11
+ id = '#'+this.plugin,
12
+ cla = '.'+this.plugin;
13
+ this.addAccessTokenListener();
14
+ $('.'+this.plugin +'_connected_accounts_wrap .'+this.plugin +'_connected_account').each(function() {
15
+ self.initClickRemove($(this));
16
+ self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
17
+ });
18
+ this.$adminEl.find('.sbspf_type_input').change(function() {
19
+ self.updateOnSelect($(this));
20
+ });self.updateOnSelect();
21
+
22
+
23
+ self.initAppCredToggle();
24
+
25
+ self.initWidthResponsiveToggle();
26
+ self.initActionButtons();
27
+
28
+ this.addManualAccessTokenListener();
29
+
30
+ $(id + '_search_submit').click(function(event) {
31
+ event.preventDefault();
32
+
33
+ var submitData = {
34
+ 'term' : $(id + '_channel_search').val(),
35
+ 'action' : self.plugin + '_account_search',
36
+ 'sbspf_nonce' : sbspf.nonce
37
+ };
38
+ var onSuccess = function (data) {
39
+ if (data.trim().indexOf('{') === 0) {
40
+ var returnObj = JSON.parse(data.trim());
41
+
42
+ var html = '';
43
+ $.each(returnObj.items,function(index,value){
44
+ });
45
+ }
46
+ };
47
+ sbAjax(submitData,onSuccess);
48
+ });
49
+
50
+ // color picker
51
+ var $ctfColorpicker = $(cla+'_colorpicker');
52
+
53
+ if($ctfColorpicker.length > 0){
54
+ $ctfColorpicker.wpColorPicker();
55
+ }
56
+
57
+ // shortcode tooltips
58
+ var $adminLabel = $(id +'_admin label');
59
+
60
+ $adminLabel.click(function(){
61
+ var $shortcode = $(this).siblings(cla + '_shortcode');
62
+ if($shortcode.is(':visible')){
63
+ $shortcode.hide();
64
+ } else {
65
+ $shortcode.show();
66
+ }
67
+ });
68
+ $adminLabel.hover(function(){
69
+ if($(this).siblings(cla + '_shortcode').length && ! $(this).find(cla + '_shortcode_symbol').length){
70
+ $(this).append('<code class="'+self.plugin+'_shortcode_symbol">[]</code>');
71
+ }
72
+ }, function(){
73
+ $(this).find(cla + '_shortcode_symbol').remove();
74
+ });
75
+ $(cla + '_shortcode').hide();
76
+
77
+ //Scroll to hash for quick links
78
+ $(id + '_admin a').click(function() {
79
+ if(location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
80
+ var target = $(this.hash);
81
+ target = target.length ? target : this.hash.slice(1);
82
+ if(target.length) {
83
+ $('html,body').animate({
84
+ scrollTop: target.offset().top
85
+ }, 500);
86
+ return false;
87
+ }
88
+ }
89
+ });
90
+
91
+ //Caching options
92
+ if( $(id+'_caching_type_page').is(':checked') ) {
93
+ $(cla+'-caching-cron-options').hide();
94
+ $(cla+'-caching-page-options').show();
95
+ } else {
96
+ $(cla+'-caching-page-options').hide();
97
+ $(cla+'-caching-cron-options').show();
98
+ }
99
+
100
+ $('.'+self.plugin+'_caching_type_input').change(function() {
101
+ if (this.value == 'page') {
102
+ $(cla+'-caching-cron-options').slideUp();
103
+ $(cla+'-caching-page-options').slideDown();
104
+ }
105
+ else if (this.value == 'background') {
106
+ $(cla+'-caching-page-options').slideUp();
107
+ $(cla+'-caching-cron-options').slideDown();
108
+ }
109
+ });
110
+
111
+ //Should we show the caching time settings?
112
+ var sbspf_cache_cron_interval = $(id+'_cache_cron_interval').val(),
113
+ $sbspf_caching_time_settings = $(id+'-caching-time-settings');
114
+
115
+ //Should we show anything initially?
116
+ if(sbspf_cache_cron_interval == '30mins' || sbspf_cache_cron_interval == '1hour') $sbspf_caching_time_settings.hide();
117
+
118
+ $(id+'_cache_cron_interval').change(function(){
119
+ sbspf_cache_cron_interval = $(id+'_cache_cron_interval').val();
120
+
121
+ if(sbspf_cache_cron_interval == '30mins' || sbspf_cache_cron_interval == '1hour'){
122
+ $sbspf_caching_time_settings.hide();
123
+ } else {
124
+ $sbspf_caching_time_settings.show();
125
+ }
126
+ });
127
+ sbspf_cache_cron_interval = $(id+'_cache_cron_interval').val();
128
+
129
+ if(sbspf_cache_cron_interval == '30mins' || sbspf_cache_cron_interval == '1hour'){
130
+ $sbspf_caching_time_settings.hide();
131
+ } else {
132
+ $sbspf_caching_time_settings.show();
133
+ }
134
+
135
+ self.updateLayoutOptionsDisplay();
136
+ $(cla + '_layout_type').change(function() {
137
+ self.updateLayoutOptionsDisplay()
138
+ });
139
+ $(cla + '_sub_option_type').change(function() {
140
+ self.updateBoxSelectionDisplay()
141
+ });
142
+ self.updateBoxSelectionDisplay();
143
+
144
+ // tooltips
145
+ $(id +'_admin '+ cla + '_tooltip_link').click(function(){
146
+ if ($(this).closest( cla + '_box').length) {
147
+ $(this).closest( cla + '_box').find(cla + '_tooltip').slideToggle();
148
+
149
+ } else {
150
+ $(this).closest('tr, h3, '+ cla + '_tooltip_wrap').find(cla + '_tooltip').slideToggle();
151
+ }
152
+ });
153
+
154
+ $(id +'_admin '+ cla + '_type_tooltip_link').click(function(){
155
+ $(this).closest(cla + '_row').find(cla + '_tooltip').slideToggle();
156
+ });
157
+
158
+ //Mobile width
159
+ var $feedWidth = $(id+'_admin '+id+'_settings_width'),
160
+ $widthUnit = $(id+'_admin '+id+'_settings_width_unit');
161
+ if ($feedWidth.length) {
162
+ $feedWidth.change(function(){
163
+ self.updateFeedWidthDisplay();
164
+ });
165
+ $widthUnit.change(function(){
166
+ self.updateFeedWidthDisplay();
167
+ });
168
+ self.updateFeedWidthDisplay();
169
+ }
170
+
171
+ this.afterInit();
172
+ },
173
+ afterInit: function() {
174
+
175
+ },
176
+ addAccessTokenListener: function() {
177
+ var self = this;
178
+ if (window.location.hash.length > 5 && window.location.hash.indexOf(this.accesstokenSplitter) > -1) {
179
+ var accessToken = window.location.hash.split(this.accesstokenSplitter);
180
+ // clear access token from hash
181
+ window.location.hash = '';
182
+ var submitData = {
183
+ 'access_token' : accessToken[1],
184
+ 'action' : this.plugin + '_process_access_token',
185
+ 'sbspf_nonce' : sbspf.nonce
186
+ };
187
+ var onSuccess = function (data) {
188
+ if (data.trim().indexOf('{') === 0) {
189
+ var returnObj = JSON.parse(data.trim());
190
+ $('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
191
+ self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
192
+ self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
193
+ }
194
+ };
195
+ sbAjax(submitData,onSuccess);
196
+ }
197
+ },
198
+ initClickRemove: function(el) {
199
+ var self = this;
200
+ el.find('.'+this.plugin +'_delete_account').click(function() {
201
+ if (!$(this).closest('.'+self.plugin +'_connected_accounts_wrap').hasClass(self.plugin +'-waiting')) {
202
+ $(this).closest('.'+self.plugin +'_connected_accounts_wrap').addClass(self.plugin +'-waiting');
203
+ var $connectedAccount = $(this).closest('.'+self.plugin +'_connected_account'),
204
+ accountID = $connectedAccount.attr('data-userid');
205
+
206
+ if (window.confirm("Delete this connected account?")) {
207
+ $('#'+self.plugin +'_user_feed_id_' + accountID).remove();
208
+ $('#'+self.plugin +'_connected_account_' + accountID).append('<div class="spinner" style="margin-top: -10px;visibility: visible;top: 50%;position: absolute;right: 50%;"></div>').find('.'+self.plugin +'_ca_info').css('opacity','.5');
209
+
210
+ var submitData = {
211
+ 'account_id' : accountID,
212
+ 'action' : self.getAction( 'ca_after_remove_clicked' ),
213
+ 'sbspf_nonce' : sbspf.nonce
214
+ };
215
+ var onSuccess = function (data) {
216
+ if (data.trim().indexOf('{') === 0) {
217
+ var returnObj = JSON.parse(data.trim());
218
+ $('.'+self.plugin +'-waiting').removeClass(self.plugin +'-waiting');
219
+ $connectedAccount.fadeOut(300, function() { $(this).remove(); });
220
+ self.afterConnectedAccountRemoved(accountID);
221
+ }
222
+ };
223
+ sbAjax(submitData,onSuccess);
224
+ } else {
225
+ $('.'+self.plugin +'-waiting').removeClass(self.plugin +'-waiting');
226
+ }
227
+ }
228
+
229
+ });
230
+ },
231
+ initInfoToggle: function(el) {
232
+ var self = this;
233
+ el.find('.'+self.plugin +'_ca_show_token').off().click(function() {
234
+ $(this).closest('.'+self.plugin +'_ca_info').find('.'+self.plugin +'_ca_accesstoken').slideToggle(200);
235
+ });
236
+
237
+ el.find('.'+self.plugin +'_ca_token_shortcode').off().click(function() {
238
+ $(this).closest('.'+self.plugin +'_ca_info').find('.'+self.plugin +'_ca_shortcode').slideToggle(200);
239
+ });
240
+ },
241
+ initAppCredToggle: function() {
242
+ var self = this;
243
+ $('#'+self.plugin +'_have_own_tokens').click(function() {
244
+ if ($(this).is(':checked')) {
245
+ $(this).closest('form').find('.'+self.plugin +'_own_credentials_wrap').slideDown();
246
+ } else {
247
+ $(this).closest('form').find('.'+self.plugin +'_own_credentials_wrap').slideUp();
248
+ }
249
+ });
250
+
251
+ if ($('#'+self.plugin +'_have_own_tokens').is(':checked')) {
252
+ $('#'+self.plugin +'_have_own_tokens').closest('form').find('.'+self.plugin +'_own_credentials_wrap').slideDown();
253
+ } else {
254
+ $('#'+self.plugin +'_have_own_tokens').closest('form').find('.'+self.plugin +'_own_credentials_wrap').slideUp();
255
+ }
256
+ },
257
+ initWidthResponsiveToggle: function() {
258
+ //Mobile width
259
+ var feedWidth = $('#sby_settings_width').length ? $('#sby_settings_width').val() : '100',
260
+ widthUnit = $('#sby_settings_widthunit').length ? $('#sby_settings_widthunit').val() : '%',
261
+ $widthOptions = $('#sbspf_width_options');
262
+
263
+ if ($('#sby_settings_widthunit').length) {
264
+
265
+ //Show initially if a width is set
266
+ if (feedWidth !== '100' && widthUnit === '%') {
267
+ $widthOptions.slideDown();
268
+ } else {
269
+ $widthOptions.slideUp();
270
+ }
271
+
272
+ $('#sby_settings_width_unit, #sby_settings_width').change(function(){
273
+ feedWidth = $('#sby_settings_width').length ? $('#sby_settings_width').val() : '100';
274
+ widthUnit = $('#sby_settings_widthunit').length ? $('#sby_settings_widthunit').val() : '%';
275
+
276
+ if (feedWidth !== '100' && widthUnit === '%') {
277
+ $widthOptions.slideDown();
278
+ } else {
279
+ $widthOptions.slideUp();
280
+ }
281
+
282
+ });
283
+
284
+ }
285
+ },
286
+ initActionButtons: function() {
287
+ $('#sbspf_admin .sbspf-button-action').each(function(){
288
+ $(this).click(function() {
289
+ event.preventDefault();
290
+ $(this).next('.sbspf_success').remove();
291
+
292
+ var doAction = typeof $(this).attr('data-sby-action') !== 'undefined' ? $(this).attr('data-sby-action') : '',
293
+ confirmMessage = typeof $(this).attr('data-sby-confirm') !== 'undefined' ? $(this).attr('data-sby-confirm') : false,
294
+ $targetWaitingEl = typeof $(this).attr('data-sby-waiter') !== 'undefined' ? $($(this).attr('data-sby-waiter')) : $(this),
295
+ $self = $(this);
296
+ if (!confirmMessage || window.confirm(confirmMessage)) {
297
+ $(this).attr('disabled',true);
298
+ $targetWaitingEl.after('<div class="spinner sbspf_spinner" style="display:inline-block;visibility: visible;"></div>');
299
+
300
+ var submitData = {
301
+ 'action' : doAction,
302
+ 'sbspf_nonce' : sbspf.nonce
303
+ };
304
+ var onSuccess = function (data) {
305
+ $self.removeAttr('disabled');
306
+ $targetWaitingEl.next('.spinner').fadeOut('slow',function(){
307
+ $targetWaitingEl.after('<span class="sbspf_success"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="check-circle" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-check-circle fa-w-16"><path fill="currentColor" d="M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z" class=""></path></svg></span>');
308
+ });
309
+
310
+ if (data.trim().indexOf('{') === 0) {
311
+ var returnObj = JSON.parse(data.trim());
312
+ console.log(returnObj);
313
+
314
+ }
315
+ };
316
+ sbAjax(submitData,onSuccess);
317
+ } else {
318
+ $('.'+self.plugin +'-waiting').removeClass(self.plugin +'-waiting');
319
+ }
320
+ });
321
+ });
322
+ },
323
+ getAction(action) {
324
+ return self.plugin + '_' + action
325
+ },
326
+ addManualAccessTokenListener: function() {
327
+ var self = this,
328
+ id = '#'+this.plugin,
329
+ cla = '.'+this.plugin;
330
+
331
+ $(cla+'_manually_connect_wrap').hide();
332
+ $(cla+'_manually_connect').click(function(event) {
333
+ event.preventDefault();
334
+ if ( $(cla+'_manually_connect_wrap').is(':visible') ) {
335
+ $(cla+'_manually_connect_wrap').slideUp(200);
336
+ } else {
337
+ $(cla+'_manually_connect_wrap').slideDown(200);
338
+ $(id+'_manual_at').focus();
339
+ }
340
+ });
341
+
342
+ $(id+'_manual_submit').click(function(event) {
343
+ event.preventDefault();
344
+ var $self = $(this);
345
+ var accessToken = $(id+'_manual_at').val(),
346
+ error = false;
347
+
348
+ if (accessToken.length < 15) {
349
+ if (!$(cla+'_manually_connect_wrap').find(cla+'_user_id_error').length) {
350
+ $(cla+'_manually_connect_wrap').show().prepend('<div class="'+self.plugin+'_user_id_error" style="display:block;">Please enter a valid access token</div>');
351
+ }
352
+ } else if (! error) {
353
+ $(this).attr('disabled',true);
354
+ $(this).closest(cla+'_manually_connect_wrap').fadeOut();
355
+ $(cla+'_connected_accounts_wrap').fadeTo("slow" , 0.5).find(cla+'_user_id_error').remove();
356
+
357
+ var submitData = {
358
+ 'access_token' : accessToken,
359
+ 'action' : self.plugin + '_process_access_token',
360
+ 'sbspf_nonce' : sbspf.nonce
361
+ };
362
+ var onSuccess = function (data) {
363
+ $(cla+'_connected_accounts_wrap').fadeTo("slow" , 1);
364
+ $self.removeAttr('disabled');
365
+ var returnObj = JSON.parse(data.trim());
366
+ $('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
367
+ self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
368
+ self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
369
+ };
370
+ sbAjax(submitData,onSuccess);
371
+ }
372
+
373
+ });
374
+ },
375
+ afterConnectedAccountRemoved: function(accountID) {
376
+
377
+ },
378
+ updateLayoutOptionsDisplay: function() {
379
+ self = this;
380
+ setTimeout(function(){
381
+ $('.'+self.plugin+'_layout_settings').hide();
382
+ $('.'+self.plugin+'_layout_settings.'+self.plugin+'_layout_type_'+$('.'+self.plugin+'_layout_type:checked').val()).show();
383
+ }, 1);
384
+ },
385
+ updateBoxSelectionDisplay: function() {
386
+ self = this;
387
+ setTimeout(function(){
388
+ $('.'+self.plugin+'_sub_option_settings').hide();
389
+ $('.'+self.plugin+'_sub_option_settings.'+self.plugin+'_sub_option_type_'+$('.'+self.plugin+'_sub_option_type:checked').val()).show();
390
+ }, 1);
391
+ },
392
+ updateFeedWidthDisplay: function() {
393
+ self = this;
394
+ var sbspfFeedWidth = $('#'+self.plugin+'_admin '+'#'+self.plugin+'_settings_width').val(),
395
+ sbspfWidthUnit = $('#'+self.plugin+'_admin '+'#'+self.plugin+'_settings_width_unit').val(),
396
+ $sbspfWidthOptions = $('#'+self.plugin+'_admin '+'#'+self.plugin+'_width_options');
397
+
398
+ if( sbspfFeedWidth.length < 2 || (sbspfFeedWidth == '100' && sbspfWidthUnit == '%') ) {
399
+ $sbspfWidthOptions.slideUp();
400
+ } else {
401
+ $sbspfWidthOptions.slideDown();
402
+ }
403
+ },
404
+ updateOnSelect: function($changed) {
405
+ this.$adminEl.find('.sbspf_type_input').each(function() {
406
+ if ($(this).is(':checked')) {
407
+ $(this).closest('.sbspf_type_row').find('.sbspf_onselect').show();
408
+ } else {
409
+ $(this).closest('.sbspf_type_row').find('.sbspf_onselect').hide();
410
+ }
411
+ });
412
+ //console.log($changed.is(':checked'),$changed.closest('.sbspf_type_row').find('.sbspf_onselect').length)
413
+
414
+ },
415
+ encodeHTML: function(raw) {
416
+ // make sure passed variable is defined
417
+ if (typeof raw === 'undefined') {
418
+ return '';
419
+ }
420
+ // replace greater than and less than symbols with html entity to disallow html in comments
421
+ var encoded = raw.replace(/(>)/g,'&gt;'),
422
+ encoded = encoded.replace(/(<)/g,'&lt;');
423
+ encoded = encoded.replace(/(&lt;br\/&gt;)/g,'<br>');
424
+ encoded = encoded.replace(/(&lt;br&gt;)/g,'<br>');
425
+
426
+ return encoded;
427
+ },
428
+ };
429
+
430
+ window.sbspf_admin_init = function() {
431
+ var plugin = typeof $('.sbspf-admin').attr('data-sb-plugin') !== 'undefined' ? $('.sbspf-admin').attr('data-sb-plugin') : 'sbspf',
432
+ $adminEl = $('#sbspf_admin.sby_admin');
433
+ window.sb = new SbspfAdmin(plugin,$adminEl);
434
+ window.sb.init();
435
+ };
436
+
437
+ function sbAjax(submitData,onSuccess) {
438
+ $.ajax({
439
+ url: sbspf.ajaxUrl,
440
+ type: 'post',
441
+ data: submitData,
442
+ success: onSuccess
443
+ });
444
+ }
445
+
446
+ function SbYoutubeAdmin(plugin,$adminEl) {
447
+ SbspfAdmin.call(this, plugin,$adminEl);
448
+ this.afterInit = function() {
449
+ var self = this,
450
+ id = '#'+this.plugin,
451
+ cla = '.'+this.plugin;
452
+
453
+ // notices
454
+
455
+ if (jQuery('#sbspf-notice-bar').length) {
456
+ jQuery('#wpadminbar').after(jQuery('#sbspf-notice-bar'));
457
+ jQuery('#wpcontent').css('padding-left', 0);
458
+ jQuery('#wpbody').css('padding-left', '20px');
459
+ jQuery('#sbspf-notice-bar').show();
460
+ }
461
+
462
+ jQuery('#sbspf-notice-bar .dismiss').click(function(e) {
463
+ e.preventDefault();
464
+ jQuery('#sbspf-notice-bar').remove();
465
+ var submitData = {
466
+ 'action' : 'sby_lite_dismiss',
467
+ 'sbspf_nonce' : sbspf.nonce
468
+ };
469
+ var onSuccess = function (data) {
470
+ };
471
+ sbAjax(submitData,onSuccess);
472
+ });
473
+
474
+ $('#sbspf_usecustomsearch').change(function() {
475
+ if ($(this).is(':checked')) {
476
+ $('#sbspf_usecustomsearch_reveal').show();
477
+ } else {
478
+ $('#sbspf_usecustomsearch_reveal').hide();
479
+ }
480
+ });
481
+
482
+ if ($('#sbspf_usecustomsearch').is(':checked')) {
483
+ $('#sbspf_usecustomsearch_reveal').show();
484
+ } else {
485
+ $('#sbspf_usecustomsearch_reveal').hide();
486
+ }
487
+
488
+
489
+ $('.sbspf_dismiss_button').click(function() {
490
+ event.preventDefault();
491
+ $('#sbspf_modal_overlay').remove();
492
+ var submitData = {
493
+ 'action' : $(this).attr('data-action')
494
+ };
495
+ sbAjax(submitData,function() {});
496
+ });
497
+
498
+ $('.sbspf_dismiss_at_warning_button').click(function() {
499
+ event.preventDefault();
500
+ $('#sbspf_modal_overlay').remove();
501
+ var submitData = {
502
+ 'action' : $(this).attr('data-action')
503
+ };
504
+ sbAjax(submitData,function() {});
505
+ });
506
+
507
+ $('.sby_api_key_needed').each(function() {
508
+ $(this).find('label').append('<span class="sby_api_key_needed_message"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="key" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-key fa-w-16"><path fill="currentColor" d="M512 176.001C512 273.203 433.202 352 336 352c-11.22 0-22.19-1.062-32.827-3.069l-24.012 27.014A23.999 23.999 0 0 1 261.223 384H224v40c0 13.255-10.745 24-24 24h-40v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24v-78.059c0-6.365 2.529-12.47 7.029-16.971l161.802-161.802C163.108 213.814 160 195.271 160 176 160 78.798 238.797.001 335.999 0 433.488-.001 512 78.511 512 176.001zM336 128c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" class=""></path></svg> API Key Needed</span>');
509
+ });
510
+
511
+ var proJustHoverHTML = '<a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&amp;utm_campaign=sby" target="_blank" class="sbspf_lock sbspf_pro_lock"><i class="fa fa-rocket"></i>Pro</a>',
512
+ proLockHTML = '<p class="sbspf_pro_tooltip" style="display: none;">Upgrade to the Pro version to unlock this feature<i class="fa fa-caret-down" aria-hidden="true"></i></p>' + proJustHoverHTML,
513
+ proAvailableHTML = '<span class="sbspf_note"> - <a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&amp;utm_campaign=sby" target="_blank">Available in Pro version</a></span>';
514
+
515
+ $('.sbspf_pro_only').each(function() {
516
+ if (jQuery(this).closest('td').find('.sbspf_sub_options').length) {
517
+ if (!jQuery(this).closest('td').find('.sbspf_lock').length) {
518
+ jQuery(this).closest('td').find('.sbspf_sub_options').append(proLockHTML);
519
+ }
520
+ jQuery(this).closest('td').find('input,select,textarea').each(function() {
521
+ if (typeof jQuery(this).attr('name') !== 'undefined') {
522
+ jQuery(this).attr('name',jQuery(this).attr('name').replace('sb','demosb'));
523
+ }
524
+ });
525
+ if (jQuery(this).html() === '') {
526
+ jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
527
+ if (jQuery(this).html() === '') {
528
+ jQuery(this).remove();
529
+ }
530
+ }
531
+ } else if (jQuery(this).hasClass('sbspf_layout_cell')) {
532
+ if (!jQuery(this).find('.sbspf_lock').length) {
533
+ jQuery(this).append(proJustHoverHTML);
534
+ jQuery(this).find('img').css('opacity', .4);
535
+ }
536
+ } else if (jQuery(this).hasClass('sbspf_layout_settings')){
537
+ if (!jQuery(this).find('.sbspf_lock').length) {
538
+ jQuery(this).find('.sbspf_layout_setting').first().append('<span class="sbspf_note"><a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&amp;utm_campaign=sby" target="_blank">Upgrade to Pro to enable the carousel layout</a></span>');
539
+ jQuery(this).find('input,select,textarea').attr('disabled','true');
540
+ }
541
+ } else {
542
+ if (jQuery(this).closest('td').find('.sbspf_single_checkbox').length
543
+ && ! jQuery(this).closest('td').find('.sbspf_lock').length){
544
+ jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
545
+ jQuery(this).closest('tr').find('.sbspf_single_checkbox').next('label').after(proAvailableHTML);
546
+ if (jQuery(this).html() === '') {
547
+ jQuery(this).remove();
548
+ }
549
+ } else if (jQuery(this).closest('td').find('select.sbspf_pro_only').length
550
+ && ! jQuery(this).closest('td').find('.sbspf_lock').length){
551
+ jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
552
+ jQuery(this).closest('tr').find('select.sbspf_pro_only').after(proAvailableHTML);
553
+ if (jQuery(this).html() === '') {
554
+ jQuery(this).remove();
555
+ }
556
+ }else if (jQuery(this).find('input[type=checkbox]').length) {
557
+ var $closestTD = jQuery(this).closest('td');
558
+ jQuery(this).find('input').attr('disabled','true');
559
+ if (jQuery(this).find('input').is(':checked')) {
560
+ var $clone = jQuery(this).find('input').clone();
561
+ $clone.removeAttr('disabled').removeAttr('checked').attr('type','hidden');
562
+ jQuery(this).append($clone);
563
+ }
564
+ jQuery(this).find('input').removeAttr('checked');
565
+ if (!$closestTD.find('.sbspf_disabled_wrap').length) {
566
+ $closestTD.append('<div class="sbspf_disabled_wrap sby_includes_pro_only"></div>');
567
+ $closestTD.find('.sby_includes_pro_only').append('<span class="sbspf_note"><a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&amp;utm_campaign=sby" target="_blank">Upgrade to Pro to display video descriptions, dates, statistics, live streaming information, and more.</a></span>');
568
+ }
569
+ }
570
+
571
+ }
572
+ });
573
+
574
+ var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
575
+ $closestTD.append('<div class="sbspf_disabled_wrap sby_types_disabled_wrap">'+proLockHTML+'</div>');
576
+
577
+ $('.sbspf_type_row').each(function() {
578
+ if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
579
+ $('.sbspf_disabled_wrap').append($(this));
580
+ $(this).find('input').attr('disabled',true);
581
+ } else {
582
+ $(this).find('input').removeAttr('disabled');
583
+ }
584
+ });
585
+
586
+ $('.sbspf_pro_section').each(function() {
587
+ if ($(this).find('.sbspf_pro_reveal').length) {
588
+ $(this).find('h2').first().after($(this).find('.sbspf_pro_reveal'));
589
+ $(this).find('tr').addClass('sbspf_pro_only_row');
590
+ var $table = $(this).find('table');
591
+ $table.hide();
592
+ $(this).find('.sbspf-show-pro').click(function(event){
593
+ event.preventDefault();
594
+ $table.toggle();
595
+ });
596
+ jQuery(this).find('input,select,textarea').each(function() {
597
+ if (typeof jQuery(this).attr('name') !== 'undefined') {
598
+ jQuery(this).attr('name',jQuery(this).attr('name').replace('sb','demosb'));
599
+ }
600
+ });
601
+ }
602
+ });
603
+
604
+ jQuery('.sbspf_pro_lock').hover(function(){
605
+ jQuery(this).siblings('.sbspf_pro_tooltip').show();
606
+ }, function(){
607
+ jQuery('.sbspf_pro_tooltip').hide();
608
+ });
609
+
610
+ if (typeof $('#sbspf_get_token').attr('data-show-warning') !== 'undefined') {
611
+ $('#sbspf_get_token').click(function(event) {
612
+ event.preventDefault();
613
+ var html = self.getModal();
614
+ $('#sbspf_admin').append(html);
615
+ $('#sbspf_admin').find('.sbspf_modal_close').click(function() {
616
+ $('#sbspf_admin').find('#sbspf_modal_overlay').remove();
617
+ });
618
+
619
+ var submitData = {
620
+ 'action' : 'sby_dismiss_connect_warning_button'
621
+ };
622
+ sbAjax(submitData,function() {});
623
+ })
624
+ }
625
+
626
+ jQuery('.sbspf_show_gdpr_list').on('click', function(){
627
+ jQuery(this).closest('div').find('.sbspf_gdpr_list').slideToggle();
628
+ });
629
+
630
+ //Selecting a post style
631
+ jQuery('#sbspf_gdpr_setting').on('change', function(){
632
+ sbspfCheckGdprSetting( jQuery(this).val() );
633
+ });
634
+ function sbspfCheckGdprSetting(option) {
635
+ if( option == 'yes' ){
636
+ jQuery('.sbspf_gdpr_yes,#sbspf_images_options').show();
637
+ jQuery('.sbspf_gdpr_no, .sbspf_gdpr_auto').hide();
638
+ }
639
+ if( option == 'no' ){
640
+ jQuery('.sbspf_gdpr_no').show();
641
+ jQuery('.sbspf_gdpr_yes, .sbspf_gdpr_auto, #sbspf_images_options').hide();
642
+ }
643
+ if( option == 'auto' ){
644
+ jQuery('.sbspf_gdpr_auto').show();
645
+ jQuery('.sbspf_gdpr_yes, .sbspf_gdpr_no').hide();
646
+ if (jQuery('.sbspf_gdpr_plugin_active').length) {
647
+ jQuery('#sbspf_images_options').show();
648
+ } else {
649
+ jQuery('#sbspf_images_options').hide();
650
+ }
651
+ }
652
+ }
653
+ sbspfCheckGdprSetting(jQuery('#sbspf_gdpr_setting').val());
654
+
655
+ };
656
+
657
+ this.toggleCustomDateField = function() {
658
+ if ($('#sby_settings_dateformat').val() === 'custom') {
659
+ $('.sby_customdate_wrap').slideDown();
660
+ } else {
661
+ $('.sby_customdate_wrap').slideUp();
662
+ }
663
+ };
664
+
665
+ this.toggleAPIKeyWarnings = function() {
666
+ if ($('#sby_api_key').val() !== '') {
667
+ if ($('.sby_disabled_wrap').length) {
668
+ var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
669
+ $('.sbspf_type_row').each(function() {
670
+ if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
671
+ $closestTD.append($(this));
672
+ $(this).find('input').removeAttr('disabled');
673
+ }
674
+ });
675
+ $('.sby_disabled_wrap').remove();
676
+ }
677
+
678
+
679
+ } else if (!$('.sby_disabled_wrap').length) {
680
+ var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
681
+ $closestTD.append('<div class="sby_disabled_wrap sbspf_fade"><div class="sbspf_lock"><svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="key" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-key fa-w-16"><path fill="currentColor" d="M512 176.001C512 273.203 433.202 352 336 352c-11.22 0-22.19-1.062-32.827-3.069l-24.012 27.014A23.999 23.999 0 0 1 261.223 384H224v40c0 13.255-10.745 24-24 24h-40v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24v-78.059c0-6.365 2.529-12.47 7.029-16.971l161.802-161.802C163.108 213.814 160 195.271 160 176 160 78.798 238.797.001 335.999 0 433.488-.001 512 78.511 512 176.001zM336 128c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" class=""></path></svg>API Key Needed</div></div>');
682
+
683
+ $('.sbspf_type_row').each(function() {
684
+ if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
685
+ $('.sby_disabled_wrap').append($(this));
686
+ $(this).find('input').attr('disabled',true);
687
+ } else {
688
+ $(this).find('input').removeAttr('disabled');
689
+ }
690
+ });
691
+ }
692
+
693
+ };
694
+
695
+ this.getModal = function () {
696
+
697
+ var modal = '<div id="sbspf_modal_overlay">' +
698
+ '<div class="sbspf_modal">' +
699
+ '<div class="sbspf_modal_message">' +
700
+ ' <div class="sby_before_connection">' +
701
+ ' <p>The Feeds for YouTube plugin requires <strong>"read only"</strong> access to your YouTube account in order to retrieve data from the YouTube API.</p>' +
702
+ ' <p><strong>Please note:</strong> The plugin is only able to read public data from your account and cannot be used to edit or write to your YouTube account in any way.</p>' +
703
+ ' <p class="sbspf_submit">' +
704
+ ' <a href="'+$('#sbspf_get_token').attr('href')+'" class="button button-primary sbspf_dismiss_connect_warning_button" data-action="sby_dismiss_connect_warning_notice">Continue</a>' +
705
+ ' </p>' +
706
+ ' <a href="JavaScript:void(0);" class="sbspf_modal_close sbspf_dismiss_connect_warning_button" data-action="sby_dismiss_connect_warning_notice"><i class="fa fa-times"></i></a>' +
707
+ '' +
708
+ ' </div>' +
709
+ '</div>' +
710
+ '' +
711
+ '</div>' +
712
+ '</div>';
713
+
714
+ return modal;
715
+ };
716
+
717
+ this.toggleAccessTokenDisclaimer = function () {
718
+ var self = this;
719
+ if ($('.sby_account_just_added').length) {
720
+ $('.sby_api_needed').remove();
721
+ $('.sby_after_connection').show();
722
+ } else {
723
+ $('.sby_after_connection').remove();
724
+ $('.sby_api_needed').show();
725
+ }
726
+ };
727
+
728
+ this.addAccessTokenListener = function () {
729
+ var self = this;
730
+ if (window.location.hash.length > 5 && window.location.hash.indexOf(this.accesstokenSplitter) > -1) {
731
+ var accessToken = window.location.hash.split(this.accesstokenSplitter);
732
+ // clear access token from hash
733
+ window.location.hash = '';
734
+ var submitData = {
735
+ 'access_token' : accessToken[1],
736
+ 'action' : 'sby_process_access_token',
737
+ 'sbspf_nonce' : sbspf.nonce
738
+ };
739
+ var onSuccess = function (data) {
740
+ if (data.trim().indexOf('{') === 0) {
741
+ var returnObj = JSON.parse(data.trim());
742
+ $('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
743
+ self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
744
+ self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
745
+ }
746
+ };
747
+ sbAjax(submitData,onSuccess);
748
+ }
749
+ };
750
+
751
+ this.addManualAccessTokenListener = function() {
752
+ var self = this,
753
+ id = '#'+this.plugin,
754
+ cla = '.'+this.plugin;
755
+
756
+ $(cla+'_manually_connect_wrap').hide();
757
+ $(cla+'_manually_connect').click(function(event) {
758
+ event.preventDefault();
759
+ if ( $(cla+'_manually_connect_wrap').is(':visible') ) {
760
+ $(cla+'_manually_connect_wrap').slideUp(200);
761
+ } else {
762
+ $(cla+'_manually_connect_wrap').slideDown(200);
763
+ $(id+'_manual_at').focus();
764
+ }
765
+ });
766
+
767
+ $(id+'_manual_submit').click(function(event) {
768
+ event.preventDefault();
769
+ var $self = $(this);
770
+ var accessToken = $(id+'_manual_at').val(),
771
+ refreshToken = $(id+'_manual_rt').val(),
772
+ error = false;
773
+
774
+ if (accessToken.length < 15) {
775
+ if (!$(cla+'_manually_connect_wrap').find(cla+'_user_id_error').length) {
776
+ $(cla+'_manually_connect_wrap').show().prepend('<div class="'+self.plugin+'_user_id_error" style="display:block;">Please enter a valid access token</div>');
777
+ }
778
+ } else if (! error) {
779
+ $(this).attr('disabled',true);
780
+ $(this).closest(cla+'_manually_connect_wrap').fadeOut();
781
+ $(cla+'_connected_accounts_wrap').fadeTo("slow" , 0.5).find(cla+'_user_id_error').remove();
782
+
783
+ var submitData = {
784
+ 'sby_access_token' : accessToken,
785
+ 'sby_refresh_token' : refreshToken,
786
+ 'action' : 'sby_process_access_token',
787
+ 'sbspf_nonce' : sbspf.nonce
788
+ };
789
+ var onSuccess = function (data) {
790
+ $(cla+'_connected_accounts_wrap').fadeTo("slow" , 1);
791
+ $self.removeAttr('disabled');
792
+ if (data.trim().indexOf('{') === 0) {
793
+ var returnObj = JSON.parse(data.trim());
794
+ if (typeof returnObj.error === 'undefined') {
795
+ if (!$('#sbspf_connected_account_'+returnObj.account_id).length) {
796
+ $('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
797
+ self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
798
+ self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
799
+ console.log('added');
800
+ } else {
801
+ $('#sbspf_connected_account_'+returnObj.account_id).replaceWith(returnObj.html);
802
+ self.initClickRemove($('#sbspf_connected_account_'+returnObj.account_id));
803
+ self.initInfoToggle($('#sbspf_connected_account_'+returnObj.account_id));
804
+ console.log('updated');
805
+ }
806
+ } else {
807
+ alert(returnObj.error);
808
+ }
809
+ }
810
+
811
+ };
812
+ sbAjax(submitData,onSuccess);
813
+ }
814
+
815
+ });
816
+ };
817
+ this.addManualAccessTokenListener = function() {
818
+ var self = this,
819
+ id = '#'+this.plugin,
820
+ cla = '.'+this.plugin;
821
+
822
+ $(cla+'_manually_connect_wrap').hide();
823
+ $(cla+'_manually_connect').click(function(event) {
824
+ event.preventDefault();
825
+ if ( $(cla+'_manually_connect_wrap').is(':visible') ) {
826
+ $(cla+'_manually_connect_wrap').slideUp(200);
827
+ } else {
828
+ $(cla+'_manually_connect_wrap').slideDown(200);
829
+ $(id+'_manual_at').focus();
830
+ }
831
+ });
832
+
833
+ $(id+'_manual_submit').click(function(event) {
834
+ event.preventDefault();
835
+ var $self = $(this);
836
+ var accessToken = $(id+'_manual_at').val(),
837
+ refreshToken = $(id+'_manual_rt').val(),
838
+ error = false;
839
+
840
+ if (accessToken.length < 15) {
841
+ if (!$(cla+'_manually_connect_wrap').find(cla+'_user_id_error').length) {
842
+ $(cla+'_manually_connect_wrap').show().prepend('<div class="'+self.plugin+'_user_id_error" style="display:block;">Please enter a valid access token</div>');
843
+ }
844
+ } else if (! error) {
845
+ $(this).attr('disabled',true);
846
+ $(this).closest(cla+'_manually_connect_wrap').fadeOut();
847
+ $(cla+'_connected_accounts_wrap').fadeTo("slow" , 0.5).find(cla+'_user_id_error').remove();
848
+
849
+ var submitData = {
850
+ 'sby_access_token' : accessToken,
851
+ 'sby_refresh_token' : refreshToken,
852
+ 'action' : 'sby_process_access_token',
853
+ 'sbspf_nonce' : sbspf.nonce
854
+ };
855
+ var onSuccess = function (data) {
856
+ $(cla+'_connected_accounts_wrap').fadeTo("slow" , 1);
857
+ $self.removeAttr('disabled');
858
+ if (data.trim().indexOf('{') === 0) {
859
+ var returnObj = JSON.parse(data.trim());
860
+ if (typeof returnObj.error === 'undefined') {
861
+ if (!$('#sbspf_connected_account_'+returnObj.account_id).length) {
862
+ $('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
863
+ self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
864
+ self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
865
+ console.log('added');
866
+ } else {
867
+ $('#sbspf_connected_account_'+returnObj.account_id).replaceWith(returnObj.html);
868
+ self.initClickRemove($('#sbspf_connected_account_'+returnObj.account_id));
869
+ self.initInfoToggle($('#sbspf_connected_account_'+returnObj.account_id));
870
+ console.log('updated');
871
+ }
872
+ } else {
873
+ alert(returnObj.error);
874
+ }
875
+ }
876
+
877
+ self.toggleAccessTokenDisclaimer();
878
+ $('.sbspf_dismiss_at_warning_button').click(function() {
879
+ event.preventDefault();
880
+ $('#sbspf_modal_overlay').remove();
881
+ var submitData = {
882
+ 'action' : $(this).attr('data-action')
883
+ };
884
+ sbAjax(submitData,function() {});
885
+ });
886
+
887
+ };
888
+ sbAjax(submitData,onSuccess);
889
+ }
890
+
891
+ });
892
+ };
893
+ this.getAction = function(action) {
894
+ return 'sby_' + action;
895
+ };
896
+
897
+
898
+ }
899
+
900
+ SbYoutubeAdmin.prototype = Object.create(SbspfAdmin.prototype);
901
+
902
+
903
+ window.sby_admin_init = function() {
904
+ var plugin = typeof $('.sbspf-admin').attr('data-sb-plugin') !== 'undefined' ? $('.sbspf-admin').attr('data-sb-plugin') : 'sbspf',
905
+ $adminEl = $('#sbspf_admin.sby_admin');
906
+ window.sb = new SbYoutubeAdmin(plugin,$adminEl);
907
+ window.sb.init();
908
+ };
909
+
910
+ })(jQuery);
911
+
912
+ jQuery(document).ready(function($) {
913
+ sby_admin_init();
914
  });
js/sb-youtube.js CHANGED
@@ -1,1809 +1,2036 @@
1
- var sby_js_exists = (typeof sby_js_exists !== 'undefined') ? true : false;
2
- if(!sby_js_exists) {
3
-
4
- //Checks whether browser support HTML5 video element
5
- function sby_supports_video() {
6
- return !!document.createElement('video').canPlayType;
7
- }
8
-
9
- (function($){
10
-
11
- function sbyAddImgLiquid() {
12
- /*! imgLiquid v0.9.944 / 03-05-2013 https://github.com/karacas/imgLiquid */
13
- var sby_imgLiquid = sby_imgLiquid || {VER: "0.9.944"};
14
- sby_imgLiquid.bgs_Available = !1, sby_imgLiquid.bgs_CheckRunned = !1, function (i) {
15
- function t() {
16
- if (!sby_imgLiquid.bgs_CheckRunned) {
17
- sby_imgLiquid.bgs_CheckRunned = !0;
18
- var t = i('<span style="background-size:cover" />');
19
- i("body").append(t), !function () {
20
- var i = t[0];
21
- if (i && window.getComputedStyle) {
22
- var e = window.getComputedStyle(i, null);
23
- e && e.backgroundSize && (sby_imgLiquid.bgs_Available = "cover" === e.backgroundSize)
24
- }
25
- }(), t.remove()
26
- }
27
- }
28
-
29
- i.fn.extend({
30
- sby_imgLiquid: function (e) {
31
- this.defaults = {
32
- fill: !0,
33
- verticalAlign: "center",
34
- horizontalAlign: "center",
35
- useBackgroundSize: !0,
36
- useDataHtmlAttr: !0,
37
- responsive: !0,
38
- delay: 0,
39
- fadeInTime: 0,
40
- removeBoxBackground: !0,
41
- hardPixels: !0,
42
- responsiveCheckTime: 500,
43
- timecheckvisibility: 500,
44
- onStart: null,
45
- onFinish: null,
46
- onItemStart: null,
47
- onItemFinish: null,
48
- onItemError: null
49
- }, t();
50
- var a = this;
51
- return this.options = e, this.settings = i.extend({}, this.defaults, this.options), this.settings.onStart && this.settings.onStart(), this.each(function (t) {
52
- function e() {
53
- -1 === u.css("background-image").indexOf(encodeURI(c.attr("src"))) && u.css({"background-image": 'url("' + encodeURI(c.attr("src")) + '")'}), u.css({
54
- "background-size": g.fill ? "cover" : "contain",
55
- "background-position": (g.horizontalAlign + " " + g.verticalAlign).toLowerCase(),
56
- "background-repeat": "no-repeat"
57
- }), i("a:first", u).css({
58
- display: "block",
59
- width: "100%",
60
- height: "100%"
61
- }), i("img", u).css({display: "none"}), g.onItemFinish && g.onItemFinish(t, u, c), u.addClass("sby_imgLiquid_bgSize"), u.addClass("sby_imgLiquid_ready"), l()
62
- }
63
-
64
- function o() {
65
- function e() {
66
- c.data("sby_imgLiquid_error") || c.data("sby_imgLiquid_loaded") || c.data("sby_imgLiquid_oldProcessed") || (u.is(":visible") && c[0].complete && c[0].width > 0 && c[0].height > 0 ? (c.data("sby_imgLiquid_loaded", !0), setTimeout(r, t * g.delay)) : setTimeout(e, g.timecheckvisibility))
67
- }
68
-
69
- if (c.data("oldSrc") && c.data("oldSrc") !== c.attr("src")) {
70
- var a = c.clone().removeAttr("style");
71
- return a.data("sby_imgLiquid_settings", c.data("sby_imgLiquid_settings")), c.parent().prepend(a), c.remove(), c = a, c[0].width = 0, void setTimeout(o, 10)
72
- }
73
- return c.data("sby_imgLiquid_oldProcessed") ? void r() : (c.data("sby_imgLiquid_oldProcessed", !1), c.data("oldSrc", c.attr("src")), i("img:not(:first)", u).css("display", "none"), u.css({overflow: "hidden"}), c.fadeTo(0, 0).removeAttr("width").removeAttr("height").css({
74
- visibility: "visible",
75
- "max-width": "none",
76
- "max-height": "none",
77
- width: "auto",
78
- height: "auto",
79
- display: "block"
80
- }), c.on("error", n), c[0].onerror = n, e(), void d())
81
- }
82
-
83
- function d() {
84
- (g.responsive || c.data("sby_imgLiquid_oldProcessed")) && c.data("sby_imgLiquid_settings") && (g = c.data("sby_imgLiquid_settings"), u.actualSize = u.get(0).offsetWidth + u.get(0).offsetHeight / 1e4, u.sizeOld && u.actualSize !== u.sizeOld && r(), u.sizeOld = u.actualSize, setTimeout(d, g.responsiveCheckTime))
85
- }
86
-
87
- function n() {
88
- c.data("sby_imgLiquid_error", !0), u.addClass("sby_imgLiquid_error"), g.onItemError && g.onItemError(t, u, c), l()
89
- }
90
-
91
- function s() {
92
- var i = {};
93
- if (a.settings.useDataHtmlAttr) {
94
- var t = u.attr("data-sby_imgLiquid-fill"),
95
- e = u.attr("data-sby_imgLiquid-horizontalAlign"),
96
- o = u.attr("data-sby_imgLiquid-verticalAlign");
97
- ("true" === t || "false" === t) && (i.fill = Boolean("true" === t)), void 0 === e || "left" !== e && "center" !== e && "right" !== e && -1 === e.indexOf("%") || (i.horizontalAlign = e), void 0 === o || "top" !== o && "bottom" !== o && "center" !== o && -1 === o.indexOf("%") || (i.verticalAlign = o)
98
- }
99
- return sby_imgLiquid.isIE && a.settings.ieFadeInDisabled && (i.fadeInTime = 0), i
100
- }
101
-
102
- function r() {
103
- var i, e, a, o, d, n, s, r, m = 0, h = 0, f = u.width(), v = u.height();
104
- void 0 === c.data("owidth") && c.data("owidth", c[0].width), void 0 === c.data("oheight") && c.data("oheight", c[0].height), g.fill === f / v >= c.data("owidth") / c.data("oheight") ? (i = "100%", e = "auto", a = Math.floor(f), o = Math.floor(f * (c.data("oheight") / c.data("owidth")))) : (i = "auto", e = "100%", a = Math.floor(v * (c.data("owidth") / c.data("oheight"))), o = Math.floor(v)), d = g.horizontalAlign.toLowerCase(), s = f - a, "left" === d && (h = 0), "center" === d && (h = .5 * s), "right" === d && (h = s), -1 !== d.indexOf("%") && (d = parseInt(d.replace("%", ""), 10), d > 0 && (h = s * d * .01)), n = g.verticalAlign.toLowerCase(), r = v - o, "left" === n && (m = 0), "center" === n && (m = .5 * r), "bottom" === n && (m = r), -1 !== n.indexOf("%") && (n = parseInt(n.replace("%", ""), 10), n > 0 && (m = r * n * .01)), g.hardPixels && (i = a, e = o), c.css({
105
- width: i,
106
- height: e,
107
- "margin-left": Math.floor(h),
108
- "margin-top": Math.floor(m)
109
- }), c.data("sby_imgLiquid_oldProcessed") || (c.fadeTo(g.fadeInTime, 1), c.data("sby_imgLiquid_oldProcessed", !0), g.removeBoxBackground && u.css("background-image", "none"), u.addClass("sby_imgLiquid_nobgSize"), u.addClass("sby_imgLiquid_ready")), g.onItemFinish && g.onItemFinish(t, u, c), l()
110
- }
111
-
112
- function l() {
113
- t === a.length - 1 && a.settings.onFinish && a.settings.onFinish()
114
- }
115
-
116
- var g = a.settings, u = i(this), c = i("img:first", u);
117
- return c.length ? (c.data("sby_imgLiquid_settings") ? (u.removeClass("sby_imgLiquid_error").removeClass("sby_imgLiquid_ready"), g = i.extend({}, c.data("sby_imgLiquid_settings"), a.options)) : g = i.extend({}, a.settings, s()), c.data("sby_imgLiquid_settings", g), g.onItemStart && g.onItemStart(t, u, c), void (sby_imgLiquid.bgs_Available && g.useBackgroundSize ? e() : o())) : void n()
118
- })
119
- }
120
- })
121
- }(jQuery);
122
-
123
- // Use imagefill to set the images as backgrounds so they can be square
124
- !function () {
125
- var css = sby_imgLiquid.injectCss,
126
- head = document.getElementsByTagName('head')[0],
127
- style = document.createElement('style');
128
- style.type = 'text/css';
129
- if (style.styleSheet) {
130
- style.styleSheet.cssText = css;
131
- } else {
132
- style.appendChild(document.createTextNode(css));
133
- }
134
- head.appendChild(style);
135
- }();
136
- }
137
-
138
- function sbyAddVisibilityListener() {
139
- /* Detect when element becomes visible. Used for when the feed is initially hidden, in a tab for example. https://github.com/shaunbowe/jquery.visibilityChanged */
140
- !function (i) {
141
- var n = {
142
- callback: function () {
143
- }, runOnLoad: !0, frequency: 100, sbyPreviousVisibility: null
144
- }, c = {};
145
- c.sbyCheckVisibility = function (i, n) {
146
- if (jQuery.contains(document, i[0])) {
147
- var e = n.sbyPreviousVisibility, t = i.is(":visible");
148
- n.sbyPreviousVisibility = t, null == e ? n.runOnLoad && n.callback(i, t) : e !== t && n.callback(i, t), setTimeout(function () {
149
- c.sbyCheckVisibility(i, n)
150
- }, n.frequency)
151
- }
152
- }, i.fn.sbyVisibilityChanged = function (e) {
153
- var t = i.extend({}, n, e);
154
- return this.each(function () {
155
- c.sbyCheckVisibility(i(this), t)
156
- })
157
- }
158
- }(jQuery);
159
- }
160
-
161
- function Sby() {
162
- this.feeds = {};
163
- this.options = sbyOptions;
164
- this.isTouch = sbyIsTouch();
165
- }
166
-
167
- Sby.prototype = {
168
- createPage: function (createFeeds, createFeedsArgs) {
169
- if (typeof window.sbyajaxurl === 'undefined' || window.sbyajaxurl.indexOf(window.location.hostname) === -1) {
170
- window.sbyajaxurl = window.location.hostname + '/wp-admin/admin-ajax.php';
171
- }
172
-
173
- $('.sby_no_js_error_message').remove();
174
- $('.sby_no_js').removeClass('sby_no_js');
175
- var youtubeScriptId = "youtube-api";
176
- var youtubeScript = document.getElementById(youtubeScriptId);
177
-
178
- if (youtubeScript === null) {
179
- var tag = document.createElement("script");
180
- var firstScript = document.getElementsByTagName("script")[0];
181
-
182
- tag.src = "https://www.youtube.com/iframe_api";
183
- tag.id = youtubeScriptId;
184
- firstScript.parentNode.insertBefore(tag, firstScript);
185
-
186
- }
187
- createFeeds(createFeedsArgs);
188
- },
189
- createLightbox: function() {
190
- var lbBuilder = sbyGetlightboxBuilder();
191
- var sby_lb_delay = (function () {
192
- var sby_timer = 0;
193
- return function (sby_callback, sby_ms) {
194
- clearTimeout(sby_timer);
195
- sby_timer = setTimeout(sby_callback, sby_ms);
196
- };
197
- })();
198
- jQuery(window).resize(function () {
199
- sby_lb_delay(function () {
200
- lbBuilder.afterResize();
201
- }, 200);
202
- });
203
- /* Lightbox v2.7.1 by Lokesh Dhakar - http://lokeshdhakar.com/projects/lightbox2/ - Heavily modified specifically for this plugin */
204
- (function() {
205
- var a = jQuery,
206
- b = function() {
207
- function a() {
208
- this.fadeDuration = 500, this.fitImagesInViewport = !0, this.resizeDuration = 700, this.positionFromTop = 50, this.showImageNumberLabel = !0, this.alwaysShowNavOnTouchDevices = !1, this.wrapAround = !1
209
- }
210
- return a.prototype.albumLabel = function(a, b) {
211
- return a + " / " + b
212
- }, a
213
- }(),
214
- c = function() {
215
- function b(a) {
216
- this.options = a, this.album = [], this.currentImageIndex = void 0, this.init()
217
- }
218
- return b.prototype.init = function() {
219
- this.enable(), this.build()
220
- }, b.prototype.enable = function() {
221
- var b = this;
222
- a("body").on("click", "a[data-sby-lightbox]", function(c) {
223
- return b.start(a(c.currentTarget)), !1
224
- })
225
- }, b.prototype.build = function() {
226
- var b = this;
227
- a(""+
228
- lbBuilder.template()).appendTo(a("body")), this.$lightbox = a("#sby_lightbox"), this.$overlay = a("#sby_lightboxOverlay"), this.$outerContainer = this.$lightbox.find(".sby_lb-outerContainer"), this.$container = this.$lightbox.find(".sby_lb-container"), this.containerTopPadding = parseInt(this.$container.css("padding-top"), 10), this.containerRightPadding = parseInt(this.$container.css("padding-right"), 10), this.containerBottomPadding = parseInt(this.$container.css("padding-bottom"), 10), this.containerLeftPadding = parseInt(this.$container.css("padding-left"), 10), this.$overlay.hide().on("click", function() {
229
- return b.end(), !1
230
- }), jQuery(document).on('click', function(event, b, c) {
231
- //Fade out the lightbox if click anywhere outside of the two elements defined below
232
- if (!jQuery(event.target).closest('.sby_lb-outerContainer').length) {
233
- if (!jQuery(event.target).closest('.sby_lb-dataContainer').length) {
234
- //Fade out lightbox
235
- if (typeof window.sbyLightboxPlayer !== 'undefined') { YT.get('sby_lb-player').pauseVideo(); }
236
-
237
- jQuery('#sby_lightboxOverlay, #sby_lightbox').fadeOut();
238
- }
239
- }
240
- }), this.$lightbox.hide(),
241
- jQuery('#sby_lightboxOverlay').on("click", function(c) {
242
- if (typeof window.sbyLightboxPlayer !== 'undefined') { YT.get('sby_lb-player').pauseVideo(); }
243
-
244
- return "sby_lightbox" === a(c.target).attr("id") && b.end(), !1
245
- }), this.$lightbox.find(".sby_lb-prev").on("click", function() {
246
-
247
- if (typeof window.sbyLightboxPlayer !== 'undefined') { YT.get('sby_lb-player').pauseVideo(); }
248
-
249
- return b.changeImage(0 === b.currentImageIndex ? b.album.length - 1 : b.currentImageIndex - 1), !1
250
- }), this.$lightbox.find(".sby_lb-container").on("swiperight", function() {
251
-
252
- if (typeof window.sbyLightboxPlayer !== 'undefined') { YT.get('sby_lb-player').pauseVideo(); }
253
-
254
- return b.changeImage(0 === b.currentImageIndex ? b.album.length - 1 : b.currentImageIndex - 1), !1
255
- }), this.$lightbox.find(".sby_lb-next").on("click", function() {
256
-
257
- if (typeof window.sbyLightboxPlayer !== 'undefined') { YT.get('sby_lb-player').pauseVideo(); }
258
-
259
- return b.changeImage(b.currentImageIndex === b.album.length - 1 ? 0 : b.currentImageIndex + 1), !1
260
- }), this.$lightbox.find(".sby_lb-container").on("swipeleft", function() {
261
-
262
- if (typeof window.sbyLightboxPlayer !== 'undefined') { YT.get('sby_lb-player').pauseVideo(); }
263
-
264
- return b.changeImage(b.currentImageIndex === b.album.length - 1 ? 0 : b.currentImageIndex + 1), !1
265
- }), this.$lightbox.find(".sby_lb-loader, .sby_lb-close").on("click", function() {
266
-
267
- if (typeof window.sbyLightboxPlayer !== 'undefined') { YT.get('sby_lb-player').pauseVideo(); }
268
-
269
- return b.end(), !1
270
- })
271
- }, b.prototype.start = function(b) {
272
- function c(a) {
273
- d.album.push(lbBuilder.getData(a))
274
- }
275
- var d = this,
276
- e = a(window);
277
- e.on("resize", a.proxy(this.sizeOverlay, this)), a("select, object, embed").css({
278
- visibility: "hidden"
279
- }), this.sizeOverlay(), this.album = [];
280
- var f, g = 0,
281
- h = b.attr("data-sby-lightbox");
282
- if (h) {
283
- f = a(b.prop("tagName") + '[data-sby-lightbox="' + h + '"]');
284
- for (var i = 0; i < f.length; i = ++i) c(a(f[i])), f[i] === b[0] && (g = i)
285
- } else if ("lightbox" === b.attr("rel")) c(b);
286
- else {
287
- f = a(b.prop("tagName") + '[rel="' + b.attr("rel") + '"]');
288
- for (var j = 0; j < f.length; j = ++j) c(a(f[j])), f[j] === b[0] && (g = j)
289
- }
290
- var k = e.scrollTop() + this.options.positionFromTop,
291
- l = e.scrollLeft();
292
- this.$lightbox.css({
293
- top: k + "px",
294
- left: l + "px"
295
- }).fadeIn(this.options.fadeDuration), this.changeImage(g)
296
- }, b.prototype.changeImage = function(b) {
297
- var c = this;
298
- this.disableKeyboardNav();
299
- var d = this.$lightbox.find(".sby_lb-image");
300
- this.$overlay.fadeIn(this.options.fadeDuration), a(".sby_lb-loader").fadeIn("slow"), this.$lightbox.find(".sby_lb-image, .sby_lb-nav, .sby_lb-prev, .sby_lb-next, .sby_lb-dataContainer, .sby_lb-numbers, .sby_lb-caption").hide(), this.$outerContainer.addClass("animating");
301
- var e = new Image;
302
- e.onload = function() {
303
- var f, g, h, i, j, k, l;
304
- var sbyArrowWidth = 100;
305
- d.attr("src", c.album[b].link), f = a(e), d.width(e.width), d.height(e.height), c.options.fitImagesInViewport && (l = a(window).width(), k = a(window).height(), j = l - c.containerLeftPadding - c.containerRightPadding - 20 - sbyArrowWidth, i = k - c.containerTopPadding - c.containerBottomPadding - 150, (e.width > j || e.height > i) && (e.width / j > e.height / i ? (h = j, g = parseInt(e.height / (e.width / h), 10), d.width(h), d.height(g)) : (g = i, h = parseInt(e.width / (e.height / g), 10), d.width(h), d.height(g)))), c.sizeContainer(d.width(), d.height())
306
- }, e.src = this.album[b].link, this.currentImageIndex = b
307
- }, b.prototype.sizeOverlay = function() {
308
- this.$overlay.width(a(window).width()).height(a(document).height())
309
- }, b.prototype.sizeContainer = function(a, b) {
310
- function c() {
311
- d.$lightbox.find(".sby_lb-dataContainer").width(g), d.$lightbox.find(".sby_lb-prevLink").height(h), d.$lightbox.find(".sby_lb-nextLink").height(h), d.showImage()
312
- }
313
- var d = this,
314
- e = this.$outerContainer.outerWidth(),
315
- f = this.$outerContainer.outerHeight(),
316
- g = a + this.containerLeftPadding + this.containerRightPadding,
317
- h = b + this.containerTopPadding + this.containerBottomPadding;
318
- e !== g || f !== h ? this.$outerContainer.animate({
319
- width: g,
320
- height: h
321
- }, this.options.resizeDuration, "swing", function() {
322
- c()
323
- }) : c()
324
- }, b.prototype.showImage = function() {
325
- this.$lightbox.find(".sby_lb-loader").hide(), this.$lightbox.find(".sby_lb-image").fadeIn("slow"), this.updateNav(), this.updateDetails(), this.preloadNeighboringImages(), this.enableKeyboardNav()
326
- }, b.prototype.updateNav = function() {
327
- var a = !1;
328
- try {
329
- document.createEvent("TouchEvent"), a = this.options.alwaysShowNavOnTouchDevices ? !0 : !1
330
- } catch (b) {}
331
- this.$lightbox.find(".sby_lb-nav").show(), this.album.length > 1 && (this.options.wrapAround ? (a && this.$lightbox.find(".sby_lb-prev, .sby_lb-next").css("opacity", "1"), this.$lightbox.find(".sby_lb-prev, .sby_lb-next").show()) : (this.currentImageIndex > 0 && (this.$lightbox.find(".sby_lb-prev").show(), a && this.$lightbox.find(".sby_lb-prev").css("opacity", "1")), this.currentImageIndex < this.album.length - 1 && (this.$lightbox.find(".sby_lb-next").show(), a && this.$lightbox.find(".sby_lb-next").css("opacity", "1"))))
332
- }, b.prototype.updateDetails = function() {
333
- var b = this;
334
-
335
- /** NEW PHOTO ACTION **/
336
- if(jQuery('iframe.sby_lb-player-loaded').length) {
337
- jQuery('.sby_lb-player-placeholder').replaceWith(jQuery('iframe.sby_lb-player-loaded'));
338
- jQuery('iframe.sby_lb-player-loaded').removeClass('sby_lb-player-loaded').show();
339
- }
340
- //Switch video when either a new popup or navigating to new one
341
- var feed = window.sby.feeds[this.album[this.currentImageIndex].feedIndex];
342
- lbBuilder.beforePlayerSetup(this.$lightbox,this.album[this.currentImageIndex],this.currentImageIndex,this.album,feed);
343
-
344
- if( sby_supports_video() ){
345
- jQuery('#sby_lightbox').removeClass('sby_video_lightbox');
346
- if (this.album[this.currentImageIndex].video.length){
347
- var playerID = 'sby_lb-player';
348
- jQuery('#sby_lightbox').addClass('sby_video_lightbox');
349
-
350
- var videoID = this.album[this.currentImageIndex].video,
351
- autoplay = sbyOptions.autoplay;
352
- if (typeof window.sbyLightboxPlayer === 'undefined') {
353
- var args = {
354
- host: window.location.protocol + '//www.youtube-nocookie.com',
355
- videoId: videoID,
356
- playerVars: {
357
- modestbranding: 1,
358
- rel: 0,
359
- autoplay: autoplay
360
- },
361
- events: {
362
- 'onStateChange': function(data) {
363
- var videoID = data.target.getVideoData()['video_id'];
364
- feed.afterStateChange(playerID,videoID,data,$('#' + playerID).closest('.sby_video_thumbnail_wrap'));
365
- }
366
- }
367
- };
368
- feed.maybeAddCTA(playerID);
369
-
370
- window.sbyLightboxPlayer = new window.YT.Player(playerID, args);
371
- } else {
372
- window.sbyLightboxPlayer.loadVideoById(videoID);
373
- }
374
-
375
- lbBuilder.afterPlayerSetup(this.$lightbox,this.album[this.currentImageIndex],this.currentImageIndex,this.album);
376
-
377
- if (this.album.length > 1 && this.options.showImageNumberLabel) {
378
- this.$lightbox.find(".sby_lb-number").text(this.options.albumLabel(this.currentImageIndex + 1, this.album.length)).fadeIn("fast");
379
- } else {
380
- this.$lightbox.find(".sby_lb-number").hide();
381
- }
382
- this.$outerContainer.removeClass("animating");
383
- this.$lightbox.find(".sby_lb-dataContainer").fadeIn(this.options.resizeDuration, function() {
384
- return b.sizeOverlay()
385
- });
386
-
387
- setTimeout(function() {
388
- $('#sby_lightbox .sby_lb-player').css({
389
- 'height' : $('#sby_lightbox .sby_lb-outerContainer').height()+'px',
390
- 'width' : $('#sby_lightbox .sby_lb-outerContainer').width()+'px',
391
- 'top': 0
392
- });
393
- },400);
394
-
395
- if (this.$lightbox.find('iframe').length) {
396
- this.$lightbox.find('iframe').attr('title',this.album[this.currentImageIndex].videoTitle);
397
- }
398
- }
399
- }
400
- }, b.prototype.preloadNeighboringImages = function() {
401
- if (this.album.length > this.currentImageIndex + 1) {
402
- var a = new Image;
403
- a.src = this.album[this.currentImageIndex + 1].link
404
- }
405
- if (this.currentImageIndex > 0) {
406
- var b = new Image;
407
- b.src = this.album[this.currentImageIndex - 1].link
408
- }
409
- }, b.prototype.enableKeyboardNav = function() {
410
- a(document).on("keyup.keyboard", a.proxy(this.keyboardAction, this))
411
- }, b.prototype.disableKeyboardNav = function() {
412
- a(document).off(".keyboard")
413
- }, b.prototype.keyboardAction = function(a) {
414
-
415
- var KEYCODE_ESC = 27;
416
- var KEYCODE_LEFTARROW = 37;
417
- var KEYCODE_RIGHTARROW = 39;
418
-
419
- var keycode = event.keyCode;
420
- var key = String.fromCharCode(keycode).toLowerCase();
421
- if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) {
422
- if( sby_supports_video() ) $('#sby_lightbox video.sby_video')[0].pause();
423
- $('#sby_lightbox iframe').attr('src', '');
424
- this.end();
425
- } else if (key === 'p' || keycode === KEYCODE_LEFTARROW) {
426
- if (this.currentImageIndex !== 0) {
427
- this.changeImage(this.currentImageIndex - 1);
428
- } else if (this.options.wrapAround && this.album.length > 1) {
429
- this.changeImage(this.album.length - 1);
430
- }
431
-
432
- if( sby_supports_video() ) $('#sby_lightbox video.sby_video')[0].pause();
433
- $('#sby_lightbox iframe').attr('src', '');
434
-
435
- } else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) {
436
- if (this.currentImageIndex !== this.album.length - 1) {
437
- this.changeImage(this.currentImageIndex + 1);
438
- } else if (this.options.wrapAround && this.album.length > 1) {
439
- this.changeImage(0);
440
- }
441
-
442
- if (typeof window.sbyLightboxPlayer !== 'undefined') { YT.get('sby_lb-player').pauseVideo(); }
443
- }
444
-
445
- }, b.prototype.end = function() {
446
- this.disableKeyboardNav(), a(window).off("resize", this.sizeOverlay), this.$lightbox.fadeOut(this.options.fadeDuration), this.$overlay.fadeOut(this.options.fadeDuration), a("select, object, embed").css({
447
- visibility: "visible"
448
- })
449
- }, b
450
- }();
451
- a(function() {
452
- {
453
- var a = new b;
454
- new c(a)
455
-
456
- //Lightbox hide photo function
457
- $('.sby_lightbox_action a').unbind().bind('click', function(){
458
- $(this).parent().find('.sby_lightbox_tooltip').toggle();
459
- });
460
- }
461
- })
462
- }).call(this);
463
- },
464
- createFeeds: function (args) {
465
- window.sby.createLightbox();
466
- args.whenFeedsCreated(
467
- $('.sb_youtube').each(function (index) {
468
- $(this).attr('data-sby-index', index + 1);
469
- $(this).find('.sby_player').replaceWith('<div id="sby_player'+index+'"></div>');
470
- var $self = $(this),
471
- flags = typeof $self.attr('data-sby-flags') !== 'undefined' ? $self.attr('data-sby-flags').split(',') : [],
472
- general = typeof $self.attr('data-options') !== 'undefined' ? JSON.parse($self.attr('data-options')) : {};
473
- if (flags.indexOf('testAjax') > -1) {
474
- window.sby.triggeredTest = true;
475
- var submitData = {
476
- 'action' : 'sby_on_ajax_test_trigger'
477
- },
478
- onSuccess = function(data) {
479
- console.log('did test');
480
- };
481
- sbyAjax(submitData,onSuccess)
482
- }
483
- var feedOptions = {
484
- cols : $self.attr('data-cols'),
485
- colsmobile : $self.attr('data-colsmobile') !== 'same' ? $self.attr('data-colsmobile') : $self.attr('data-cols'),
486
- num : $self.attr('data-num'),
487
- imgRes : $self.attr('data-res'),
488
- feedID : $self.attr('data-feedid'),
489
- shortCodeAtts : $self.attr('data-shortcode-atts'),
490
- resizingEnabled : (flags.indexOf('resizeDisable') === -1),
491
- imageLoadEnabled : (flags.indexOf('imageLoadDisable') === -1),
492
- debugEnabled : (flags.indexOf('debug') > -1),
493
- favorLocal : (flags.indexOf('favorLocal') > -1),
494
- ajaxPostLoad : (flags.indexOf('ajaxPostLoad') > -1),
495
- checkWPPosts : (flags.indexOf('checkWPPosts') > -1),
496
- cacheAll : (flags.indexOf('cacheAll') > -1),
497
- lightboxEnabled : typeof $self.attr('data-sby-supports-lightbox') !== 'undefined',
498
- autoMinRes : 1,
499
- general : general
500
- };
501
-
502
- window.sby.feeds[index] = sbyGetNewFeed(this, index, feedOptions);
503
- if (typeof window.sbyAPIReady !== 'undefined') {
504
- window.sby.feeds[index].playerAPIReady = true;
505
- }
506
- window.sby.feeds[index].setResizedImages();
507
- window.sby.feeds[index].init();
508
-
509
- var evt = jQuery.Event('sbyafterfeedcreate');
510
- evt.feed = window.sby.feeds[index];
511
- jQuery(window).trigger(evt);
512
-
513
- })
514
- );
515
- },
516
- afterFeedsCreated: function () {
517
- // enable header hover action
518
- $('.sb_instagram_header').each(function () {
519
- var $thisHeader = $(this);
520
- $thisHeader.find('.sby_header_link').hover(function () {
521
- $thisHeader.find('.sby_header_img_hover').addClass('sby_fade_in');
522
- }, function () {
523
- $thisHeader.find('.sby_header_img_hover').removeClass('sby_fade_in');
524
- });
525
- });
526
-
527
- },
528
- encodeHTML: function(raw) {
529
- // make sure passed variable is defined
530
- if (typeof raw === 'undefined') {
531
- return '';
532
- }
533
- // replace greater than and less than symbols with html entity to disallow html in comments
534
- var encoded = raw.replace(/(>)/g,'&gt;'),
535
- encoded = encoded.replace(/(<)/g,'&lt;');
536
- encoded = encoded.replace(/(&lt;br\/&gt;)/g,'<br>');
537
- encoded = encoded.replace(/(&lt;br&gt;)/g,'<br>');
538
-
539
- return encoded;
540
- },
541
- urlDetect: function(text) {
542
- var urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g;
543
- return text.match(urlRegex);
544
- }
545
- };
546
-
547
- function SbyFeed(el, index, settings) {
548
- this.el = el;
549
- this.index = index;
550
- this.settings = settings;
551
- this.placeholderURL = window.sby.options.placeholder;
552
- if (settings.narrowPlayer) {
553
- this.placeholderURL = window.sby.options.placeholderNarrow
554
- }
555
- this.playerAPIReady = false;
556
- this.consentGiven = true;
557
- this.players = {};
558
- this.minImageWidth = 0;
559
- this.imageResolution = 150;
560
- this.resizedImages = {};
561
- this.needsResizing = [];
562
- this.outOfPages = false;
563
- this.isInitialized = false;
564
- this.mostRecentlyLoadedPosts = [];
565
- }
566
-
567
- SbyFeed.prototype = {
568
- init: function() {
569
- var feed = this;
570
- if ($(this.el).find('#sby_mod_error').length) {
571
- $(this.el).prepend($(this.el).find('#sby_mod_error'));
572
- }
573
- if (this.settings.ajaxPostLoad) {
574
- this.getNewPostSet();
575
- } else {
576
- this.afterInitialImagesLoaded();
577
- //Only check the width once the resize event is over
578
- }
579
- var sby_delay = (function () {
580
- var sby_timer = 0;
581
- return function (sby_callback, sby_ms) {
582
- clearTimeout(sby_timer);
583
- sby_timer = setTimeout(sby_callback, sby_ms);
584
- };
585
- })();
586
- jQuery(window).resize(function () {
587
- sby_delay(function () {
588
- feed.afterResize();
589
- }, 500);
590
- });
591
- },
592
- initLayout: function() {
593
- this.initGalleryLayout();
594
- this.initGrid();
595
-
596
- },
597
- initGalleryLayout: function() {
598
- var $self = $(this.el),
599
- feed = this;
600
- if ($self.hasClass('sby_layout_gallery') && $self.find('.sby_player_outer_wrap').length) {
601
- this.maybeRaiseSingleImageResolution($self.find('.sby_player_outer_wrap'), 0, true);
602
- $self.find('.sby_player_outer_wrap .sby_video_thumbnail').off().click(function (event) {
603
- event.preventDefault();
604
- feed.onThumbnailClick($(this), true);
605
- });
606
-
607
- $self.mouseenter(function() {
608
- if (!feed.canCreatePlayer()) {
609
- return;
610
- }
611
- if (!$self.find('.sby_player_outer_wrap iframe').length) {
612
- $self.addClass('sby_player_added').find('.sby_player_outer_wrap').addClass('sby_player_loading');
613
- $self.find('.sby_player_outer_wrap .sby_video_thumbnail').find('.sby_loader').show().removeClass('sby_hidden');
614
- feed.createPlayer('sby_player'+feed.index);
615
- } else if (typeof feed.player === 'undefined' && feed.playerEagerLoaded()) {
616
- feed.createPlayer('sby_player'+feed.index);
617
- }
618
- });
619
-
620
- if (window.sbySemiEagerLoading) {
621
- feed.createPlayer('sby_player'+feed.index);
622
- }
623
-
624
- }
625
- },
626
- initGrid: function() {
627
- if (window.sbySemiEagerLoading && jQuery('#sby_lightbox').length) {
628
- var feed = this;
629
- playerID = 'sby_lb-player';
630
- jQuery('#sby_lightbox').addClass('sby_video_lightbox');
631
-
632
- var videoID = $(this.el).find('sby_item').first().attr('data-video-id'),
633
- autoplay = sbyOptions.autoplay;
634
- if (typeof window.sbyLightboxPlayer === 'undefined') {
635
- var args = {
636
- host: window.location.protocol + '//www.youtube-nocookie.com',
637
- videoId: videoID,
638
- playerVars: {
639
- modestbranding: 1,
640
- rel: 0,
641
- autoplay: autoplay
642
- },
643
- events: {
644
- 'onStateChange': function (data) {
645
- var videoID = data.target.getVideoData()['video_id'];
646
- feed.afterStateChange(playerID, videoID, data, $('#' + playerID).closest('.sby_video_thumbnail_wrap'));
647
- }
648
- }
649
- };
650
- feed.maybeAddCTA(playerID);
651
-
652
- window.sbyLightboxPlayer = new window.YT.Player(playerID, args);
653
- }
654
- }
655
- },
656
- createPlayer: function(playerID,videoID,autoplay,args) {
657
- var $self = $(this.el),
658
- feed = this;
659
- videoID = typeof videoID !== 'undefined' ? videoID : this.getVideoID($self.find('.sby_item').first());
660
- autoplay = typeof autoplay !== 'undefined' ? autoplay : 0;
661
-
662
- if (typeof args === 'undefined') {
663
- args = {
664
- host: window.location.protocol + '//www.youtube-nocookie.com',
665
- videoId: videoID,
666
- playerVars: {
667
- modestbranding: 1,
668
- rel: 0,
669
- autoplay: autoplay
670
- },
671
- }
672
- }
673
- if (typeof args.events === 'undefined') {
674
- args.events = {
675
- 'onReady': function () {
676
- $self.find('.sby_player_outer_wrap').removeClass('sby_player_loading').find('.sby_video_thumbnail').css('z-index', -1).find('.sby_loader').hide().addClass('sby_hidden');
677
- if ($('#' + playerID).length && $('#' + playerID).closest('.sby_video_thumbnail_wrap').find('.sby_video_thumbnail').length) {
678
- $('#' + playerID).closest('.sby_video_thumbnail_wrap').find('.sby_video_thumbnail').fadeTo(0, 'slow', function () {
679
- $(this).css('z-index', -1);
680
- $(this).find('.sby_loader').hide().addClass('sby_hidden');
681
- $(this).closest('.sby_item').removeClass('sby_player_loading');
682
- });
683
- }
684
- },
685
- 'onStateChange': function(data) {
686
- $self.find('.sby_player_outer_wrap').removeClass('sby_player_loading').find('.sby_video_thumbnail').css('z-index', -1).find('.sby_loader').hide().addClass('sby_hidden');
687
- feed.afterStateChange(playerID,videoID,data,$('#' + playerID).closest('.sby_video_thumbnail_wrap'));
688
- if (data.data !== 1) return;
689
- if (typeof feed.players !== 'undefined') {
690
- $self.find('.sby_item').each(function() {
691
- var itemVidID = feed.getVideoID($(this));
692
- if ($(this).find('iframe').length && (itemVidID !== videoID)) {
693
- if (typeof feed.players[itemVidID] !== 'undefined' && typeof feed.players[itemVidID].pauseVideo === 'function') {
694
- feed.players[itemVidID].pauseVideo();
695
- }
696
- }
697
- });
698
- }
699
-
700
- },
701
- }
702
- }
703
- if (window.sbyEagerLoading) {
704
- var newPlayer = YT.get(playerID);
705
- } else {
706
- var newPlayer = new window.YT.Player(playerID, args);
707
- }
708
-
709
- this.maybeAddCTA(playerID);
710
-
711
- if ($self.hasClass('sby_layout_list') && typeof this.players[videoID] === 'undefined') {
712
- this.players[videoID] = newPlayer;
713
- } else if (typeof this.player === 'undefined') {
714
- this.player = newPlayer;
715
- }
716
-
717
- return newPlayer;
718
- },
719
- afterStateChange: function(playerID,videoID,data,$player) {
720
- },
721
- afterInitialImagesLoaded: function() {
722
- this.initLayout();
723
- this.loadMoreButtonInit();
724
- this.hideExtraItemsForWidth();
725
- this.beforeNewImagesRevealed();
726
- this.revealNewImages();
727
- this.afterNewImagesRevealed();
728
- this.afterFeedSet();
729
- this.sizePlayer();
730
- this.sizeItems();
731
- },
732
- afterResize: function() {
733
- this.setImageHeight();
734
- this.setImageResolution();
735
- this.maybeRaiseImageResolution();
736
- this.setImageSizeClass();
737
- this.sizePlayer();
738
- this.sizeItems();
739
- },
740
- afterLoadMoreClicked: function($button) {
741
- $button.find('.sby_loader').removeClass('sby_hidden');
742
- $button.find('.sby_btn_text').addClass('sby_hidden');
743
- $button.closest('.sb_youtube').find('.sby_num_diff_hide').addClass('sby_transition').removeClass('sby_num_diff_hide');
744
- },
745
- afterNewImagesLoaded: function() {
746
- var $self = $(this.el),
747
- feed = this;
748
- this.beforeNewImagesRevealed();
749
- this.revealNewImages();
750
- this.afterNewImagesRevealed();
751
- this.sizePlayer();
752
- this.sizeItems();
753
- setTimeout(function () {
754
- //Hide the loader in the load more button
755
- $self.find('.sby_loader').addClass('sby_hidden');
756
- $self.find('.sby_btn_text').removeClass('sby_hidden');
757
- feed.maybeRaiseImageResolution();
758
- }, 500);
759
- },
760
- beforeNewImagesRevealed: function() {
761
- this.setImageHeight();
762
- this.maybeRaiseImageResolution(true);
763
- this.setImageSizeClass();
764
- },
765
- afterFeedSet: function() {
766
-
767
- },
768
- sizePlayer: function() {
769
- var $self = $(this.el),
770
- feed = this;
771
- if ($self.hasClass('sby_layout_gallery')) {
772
- $playerThumbnail = $self.find('.sby_player_item').find('.sby_player_video_thumbnail');
773
- var playerWidth = $playerThumbnail.innerWidth(),
774
- newPlayerHeight = Math.floor(playerWidth * 9 / 16);
775
- if (feed.settings.narrowPlayer) {
776
- newPlayerHeight = Math.floor(playerWidth * 3 / 4);
777
- }
778
- $playerThumbnail.css('height',newPlayerHeight+'px').css('overflow','hidden');
779
-
780
- } else if ($self.hasClass('sby_layout_list')) {
781
- $self.find('.sby_item').each(function(){
782
- $playerThumbnail = $(this).find('.sby_item_video_thumbnail');
783
- var playerWidth = $playerThumbnail.innerWidth(),
784
- newPlayerHeight = Math.floor(playerWidth * 9 / 16);
785
- if (feed.settings.narrowPlayer) {
786
- newPlayerHeight = Math.floor(playerWidth * 3 / 4);
787
- }
788
- $playerThumbnail.css('height',newPlayerHeight+'px').css('overflow','hidden');
789
- });
790
- }
791
- },
792
- sizeItems: function() {
793
- var $self = $(this.el),
794
- feed = this;
795
- if (!$self.hasClass('sby_layout_list')) {
796
- $self.find('.sby_item').find('.sby_item_video_thumbnail').each(function() {
797
- if ($(this).hasClass('sby_imgLiquid_ready')) {
798
- var thumbWidth = $(this).innerWidth(),
799
- newThumbHeight = Math.floor(thumbWidth * 9 / 16);
800
- $(this).css('height',newThumbHeight+'px').css('overflow','hidden');
801
- }
802
-
803
- });
804
- }
805
- },
806
- revealNewImages: function() {
807
- var $self = $(this.el),
808
- feed = this;
809
- this.applyImageLiquid();
810
-
811
- // Call Custom JS if it exists
812
- if (typeof sbyCustomJS == 'function') setTimeout(function(){ sbyCustomJS(); }, 100);
813
-
814
- $self.find('.sby-screenreader').find('img').remove();
815
-
816
- $self.find('.sby_item.sby_new').each(function (index) {
817
- var $self = jQuery(this);
818
-
819
- //Photo links
820
- //If lightbox is disabled
821
- $self.find('.sby_video_thumbnail').hover(function () {
822
- jQuery(this).fadeTo(200, 0.85);
823
- }, function () {
824
- jQuery(this).stop().fadeTo(500, 1);
825
- });
826
- videoID = $self.attr('data-video-id');
827
-
828
- if (window.sbyEagerLoading && feed.canCreatePlayer() && $('#sby_player_'+videoID).length) {
829
- player = new YT.Player('sby_player_'+videoID, {
830
- height: '100',
831
- width: '100',
832
- videoId: videoID,
833
- playerVars: {
834
- modestbranding: 1,
835
- rel: 0,
836
- autoplay: 0
837
- },
838
- events: {
839
- 'onStateChange': function(data) {
840
- var videoID = data.target.getVideoData()['video_id'];
841
- if (data.data !== 1) return;
842
- $self.find('.sby_item').each(function() {
843
- var itemVidID = jQuery(this).attr('data-video-id');
844
-
845
- if (jQuery(this).find('iframe').length && jQuery(data.target.a).attr('id') !== jQuery(this).find('iframe').attr('id')) {
846
- YT.get('sby_player_'+itemVidID).pauseVideo();
847
- }
848
- });
849
- }
850
- }
851
- });
852
- }
853
-
854
- $self.find('.sby_video_thumbnail').mouseenter(function() {
855
- feed.onThumbnailEnter($(this), false);
856
- });
857
- $self.find('.sby_player_wrap').mouseleave(function() {
858
- feed.onThumbnailLeave($(this), false);
859
- });
860
- //init click
861
- $self.find('.sby_video_thumbnail').click(function(event) {
862
- event.preventDefault();
863
- feed.onThumbnailClick($(this), false);
864
- });
865
-
866
- // lightbox
867
- if (feed.settings.lightboxEnabled) {
868
- $self.find('.sby_video_thumbnail').attr('data-sby-lightbox',feed.index);
869
- if (typeof sbyOptions !== 'undefined' && typeof sbyOptions.lightboxPlaceholder !== 'undefined') {
870
- if (feed.settings.narrowPlayer) {
871
- $self.find('.sby_video_thumbnail').attr('href',sbyOptions.lightboxPlaceholderNarrow);
872
- } else {
873
- $self.find('.sby_video_thumbnail').attr('href',sbyOptions.lightboxPlaceholder);
874
- }
875
- }
876
- }
877
- feed.afterItemRevealed($self);
878
-
879
- // no info
880
- if ($self.find('.sby_info_item').text().trim() === '') {
881
- $self.find('.sby_info_item').addClass('sby_no_space');
882
- }
883
- }); //End .sby_item each
884
-
885
- $self.find('.sby_player_item').each(function (index) {
886
- var $self = jQuery(this);
887
-
888
- feed.afterItemRevealed($self);
889
- }); //End .sby_item each
890
-
891
- //Remove the new class after 500ms, once the sorting is done
892
- setTimeout(function () {
893
- $self.find('.sby_item.sby_new').removeClass('sby_new');
894
- //Loop through items and remove class to reveal them
895
- var time = 10,
896
- num = $self.find('.sby_transition').length;
897
- $self.find('.sby_transition').each(function(index) {
898
- var $sby_item_transition_el = jQuery(this);
899
-
900
- setTimeout( function(){
901
- $sby_item_transition_el.removeClass('sby_transition');
902
- }, time);
903
- time += 10;
904
- });
905
- }, 500);
906
-
907
-
908
- },
909
- afterItemRevealed: function() {
910
-
911
- },
912
- afterNewImagesRevealed: function() {
913
- this.listenForVisibilityChange();
914
- this.sendNeedsResizingToServer();
915
- this.sendCheckWPPostsToServer();
916
- if (!this.settings.imageLoadEnabled) {
917
- $('.sby_no_resraise').removeClass('sby_no_resraise');
918
- }
919
-
920
- var evt = $.Event('sbyafterimagesloaded');
921
- evt.el = $(this.el);
922
- $(window).trigger(evt);
923
- },
924
- setResizedImages: function () {
925
- if ($(this.el).find('.sby_resized_image_data').length
926
- && typeof $(this.el).find('.sby_resized_image_data').attr('data-resized') !== 'undefined'
927
- && $(this.el).find('.sby_resized_image_data').attr('data-resized').indexOf('{"') === 0) {
928
- this.resizedImages = JSON.parse($(this.el).find('.sby_resized_image_data').attr('data-resized'));
929
- $(this.el).find('.sby_resized_image_data').remove();
930
- }
931
- },
932
- sendNeedsResizingToServer: function() {
933
- var feed = this;
934
- if (feed.needsResizing.length > 0 && feed.settings.resizingEnabled) {
935
- var itemOffset = $(this.el).find('.sby_item').length;
936
-
937
- var submitData = {
938
- action: 'sby_resized_images_submit',
939
- needs_resizing: feed.needsResizing,
940
- offset: itemOffset,
941
- feed_id: feed.settings.feedID,
942
- atts: feed.settings.shortCodeAtts,
943
- };
944
- var onSuccess = function(data) {
945
- if (data.trim().indexOf('{') === 0) {
946
- var response = JSON.parse(data);
947
- if (feed.settings.debugEnabled) {
948
- console.log(response);
949
- }
950
- }
951
- };
952
- sbyAjax(submitData,onSuccess);
953
- }
954
- },
955
- sendCheckWPPostsToServer: function() {
956
- var feed = this;
957
- if (feed.settings.checkWPPosts || feed.settings.singleCheckPosts) {
958
- var feedID = typeof feed.settings.feedID !== 'undefined' ? feed.settings.feedID : 'sby_single',
959
- posts = feed.mostRecentlyLoadedPosts;
960
- feed.mostRecentlyLoadedPosts = [];
961
- var submitData = {
962
- action: 'sby_check_wp_submit',
963
- feed_id: feedID,
964
- atts: feed.settings.shortCodeAtts,
965
- offset: ! $(this.el).hasClass('sby_layout_carousel') ? $(this.el).find('.sby_item').length : Math.floor(($(this.el).find('.sby_item').length / 2) -1),
966
- posts: posts,
967
- cache_all : feed.settings.cacheAll
968
- };
969
- var onSuccess = function(data) {
970
- if (data.trim().indexOf('{') === 0) {
971
- var response = JSON.parse(data);
972
- if (feed.settings.debugEnabled) {
973
- console.log(response);
974
- }
975
- feed.afterSendCheckWPPostsToServer(response);
976
-
977
- }
978
- };
979
- sbyAjax(submitData,onSuccess);
980
- }
981
- },
982
- afterSendCheckWPPostsToServer: function (response) {
983
-
984
- },
985
- loadMoreButtonInit: function () {
986
- var $self = $(this.el),
987
- feed = this;
988
- $self.find('.sby_footer .sby_load_btn').off().on('click', function () {
989
- feed.afterLoadMoreClicked(jQuery(this));
990
- feed.getNewPostSet();
991
- }); //End click event
992
- },
993
- getNewPostSet: function () {
994
- var $self = $(this.el),
995
- feed = this;
996
- var itemOffset = $self.find('.sby_item').length,
997
- submitData = {
998
- action: 'sby_load_more_clicked',
999
- offset: itemOffset,
1000
- feed_id: feed.settings.feedID,
1001
- atts: feed.settings.shortCodeAtts,
1002
- current_resolution: feed.imageResolution
1003
- };
1004
- var onSuccess = function (data) {
1005
- if (data.trim().indexOf('{') === 0) {
1006
- var response = JSON.parse(data),
1007
- checkWPPosts = typeof response.feedStatus.checkWPPosts !== 'undefined' ? response.feedStatus.checkWPPosts : false;;
1008
- if (feed.settings.debugEnabled) {
1009
- console.log(response);
1010
- }
1011
- if (checkWPPosts) {
1012
- feed.settings.checkWPPosts = true;
1013
- } else {
1014
- feed.settings.checkWPPosts = false;
1015
- }
1016
- feed.appendNewPosts(response.html);
1017
- feed.addResizedImages(response.resizedImages);
1018
- if (feed.settings.ajaxPostLoad) {
1019
- feed.settings.ajaxPostLoad = false;
1020
- feed.afterInitialImagesLoaded();
1021
- } else {
1022
- feed.afterNewImagesLoaded();
1023
- }
1024
-
1025
- if (!response.feedStatus.shouldPaginate) {
1026
- feed.outOfPages = true;
1027
- $self.find('.sby_load_btn').hide();
1028
- } else {
1029
- feed.outOfPages = false;
1030
- }
1031
-
1032
- $('.sby_no_js').removeClass('sby_no_js');
1033
- }
1034
-
1035
- };
1036
- sbyAjax(submitData, onSuccess);
1037
- },
1038
- appendNewPosts: function (newPostsHtml) {
1039
- var $self = $(this.el),
1040
- feed = this;
1041
- if ($self.find('.sby_items_wrap .sby_item').length) {
1042
- $self.find('.sby_items_wrap .sby_item').last().after(newPostsHtml);
1043
- } else {
1044
- $self.find('.sby_items_wrap').append(newPostsHtml);
1045
- }
1046
- },
1047
- addResizedImages: function (resizedImagesToAdd) {
1048
- for (var imageID in resizedImagesToAdd) {
1049
- this.resizedImages[imageID] = resizedImagesToAdd[imageID];
1050
- }
1051
- },
1052
- setImageHeight: function() {
1053
- },
1054
- maybeRaiseSingleImageResolution: function ($item, index, forceChange) {
1055
- var feed = this,
1056
- imgSrcSet = feed.getImageUrls($item),
1057
- currentUrl = $item.find('.sby_video_thumbnail > img').attr('src'),
1058
- currentRes = 150,
1059
- aspectRatio = 1, // all thumbnails are oriented the same so the best calculation uses 1
1060
- forceChange = typeof forceChange !== 'undefined' ? forceChange : false;
1061
-
1062
- if ($item.hasClass('sby_no_resraise')) {
1063
- return;
1064
- }
1065
-
1066
- $.each(imgSrcSet, function (index, value) {
1067
- if (value === currentUrl) {
1068
- currentRes = parseInt(index);
1069
- // If the image has already been changed to an existing real source, don't force the change
1070
- forceChange = false;
1071
- }
1072
- });
1073
- //Image res
1074
- var newRes = 640;
1075
- switch (feed.settings.imgRes) {
1076
- case 'thumb':
1077
- newRes = 120;
1078
- break;
1079
- case 'medium':
1080
- newRes = 320;
1081
- break;
1082
- case 'large':
1083
- newRes = 480;
1084
- break;
1085
- case 'full':
1086
- newRes = 640;
1087
- break;
1088
- default:
1089
- var minImageWidth = Math.max(feed.settings.autoMinRes,$item.find('.sby_video_thumbnail').innerWidth()),
1090
- thisImageReplace = feed.getBestResolutionForAuto(minImageWidth, aspectRatio, $(this.el).find('sby_item').first());
1091
- switch (thisImageReplace) {
1092
- case 480:
1093
- newRes = 480;
1094
- break;
1095
- case 320:
1096
- newRes = 320;
1097
- break;
1098
- case 120:
1099
- newRes = 120;
1100
- break;
1101
- }
1102
- break;
1103
- }
1104
-
1105
- if (newRes > currentRes || currentUrl === feed.placeholderURL || forceChange) {
1106
- if (feed.settings.debugEnabled) {
1107
- var reason = currentUrl === feed.placeholderURL ? 'was placeholder' : 'too small';
1108
- console.log('rais res for ' + currentUrl, reason);
1109
- }
1110
- var newUrl = imgSrcSet[newRes];
1111
- $item.find('.sby_video_thumbnail > img').attr('src', newUrl);
1112
- if ($item.find('.sby_video_thumbnail').hasClass('sby_imgLiquid_ready')) {
1113
- $item.find('.sby_video_thumbnail').css('background-image', 'url("' + newUrl + '")');
1114
- }
1115
- }
1116
-
1117
- $item.find('img').on('error', function () {
1118
- if (!$(this).hasClass('sby_img_error')) {
1119
- $(this).addClass('sby_img_error');
1120
- var sourceFromAPI = ($(this).attr('src').indexOf('i.ytimg.com') > -1);
1121
-
1122
- if (!sourceFromAPI) {
1123
- if (typeof $(this).closest('.sby_video_thumbnail').attr('data-full-res') !== 'undefined') {
1124
- //$(this).attr('src', $(this).closest('.sby_video_thumbnail').attr('data-full-res'));
1125
- //$(this).closest('.sby_video_thumbnail').css('background-image', 'url(' + $(this).closest('.sby_video_thumbnail').attr('d