Version Description
- Tweak: More details are provided for API errors such as an API key not working after being created.
- Tweak: If an API key has not been entered, an account reconnection is required if trying to display videos from a previously unused channel and more than an hour has passed since the last account connection.
- Tweak: Play icon changed to YouTube logo to comply with their terms of service.
- Fix: Prevented a Fatal PHP error caused by retrieving YouTube videos without using an API key and either entering a non-existing YouTube channel ID or having allow_url_fopen disabled on the server.
- Fix: Non-latin characters were displaying incorrectly in titles and descriptions when a feed was using backup data.
- Fix: Thumbnails were not resizing properly when the browser was resized.
Download this release
Release Info
Developer | smashballoon |
Plugin | Feeds for YouTube (YouTube video, channel, and gallery plugin) |
Version | 1.2.2 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.2.2
- README.txt +9 -1
- css/admin.css +1068 -1045
- css/sb-youtube.css +1354 -1320
- css/sb-youtube.min.css +1 -1
- css/sby-blocks.css +2 -2
- css/sby-notices.css +88 -88
- img/sby-icon-offer.png +0 -0
- inc/admin/admin-functions.php +959 -958
- inc/admin/class-sbspf-admin.php +1042 -1042
- inc/admin/class-sby-admin.php +945 -945
- inc/admin/templates/configure.php +37 -37
- inc/admin/templates/connected-accounts.php +42 -44
- inc/admin/templates/customize.php +22 -22
- inc/admin/templates/display.php +42 -42
- inc/admin/templates/main.php +78 -78
- inc/admin/templates/single-connected-account.php +55 -45
- inc/admin/templates/support.php +121 -121
- inc/blocks/class-sby-blocks.php +149 -149
- inc/class-sby-api-connect.php +194 -184
- inc/class-sby-cron-update.php +209 -209
- inc/class-sby-display-elements.php +368 -368
- inc/class-sby-feed.php +1588 -1577
- inc/class-sby-parse.php +257 -257
- inc/class-sby-posts-manager.php +327 -344
- inc/class-sby-rss-connect.php +122 -111
- inc/class-sby-settings.php +351 -351
- inc/class-sby-vars.php +35 -35
- inc/class-sby-wp-post.php +162 -161
- inc/sby-functions.php +857 -835
- inc/widget.php +63 -63
- js/admin.js +744 -744
- js/sb-youtube.js +1729 -1800
README.txt
CHANGED
@@ -5,7 +5,7 @@ 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.4
|
8 |
-
Stable tag: 1.2.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -165,6 +165,14 @@ 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.1 =
|
169 |
* Tweak: Video thumbnails are cropped to a 9:16 aspect ratio to remove black bars at the top and bottom of the images.
|
170 |
* Tweak: Improved workarounds for video player issues caused by having iframes from other sources on the same page.
|
5 |
Tags: YouTube, YouTube feed, YouTube widget, YouTube channel, YouTube gallery
|
6 |
Requires at least: 3.4
|
7 |
Tested up to: 5.4
|
8 |
+
Stable tag: 1.2.2
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
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.2 =
|
169 |
+
* Tweak: More details are provided for API errors such as an API key not working after being created.
|
170 |
+
* Tweak: If an API key has not been entered, an account reconnection is required if trying to display videos from a previously unused channel and more than an hour has passed since the last account connection.
|
171 |
+
* Tweak: Play icon changed to YouTube logo to comply with their terms of service.
|
172 |
+
* Fix: Prevented a Fatal PHP error caused by retrieving YouTube videos without using an API key and either entering a non-existing YouTube channel ID or having allow_url_fopen disabled on the server.
|
173 |
+
* Fix: Non-latin characters were displaying incorrectly in titles and descriptions when a feed was using backup data.
|
174 |
+
* Fix: Thumbnails were not resizing properly when the browser was resized.
|
175 |
+
|
176 |
= 1.2.1 =
|
177 |
* Tweak: Video thumbnails are cropped to a 9:16 aspect ratio to remove black bars at the top and bottom of the images.
|
178 |
* Tweak: Improved workarounds for video player issues caused by having iframes from other sources on the same page.
|
css/admin.css
CHANGED
@@ -1,1046 +1,1069 @@
|
|
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 |
-
|
36 |
-
#
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
.
|
46 |
-
|
47 |
-
}
|
48 |
-
#sbspf_admin .
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
#
|
70 |
-
|
71 |
-
}
|
72 |
-
#sbspf_admin .
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
padding:
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
width:
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
.
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
#
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
#sbspf_admin .
|
207 |
-
width:
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
}
|
212 |
-
#sbspf_admin .
|
213 |
-
|
214 |
-
}
|
215 |
-
#sbspf_admin .
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
display:
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
width:
|
276 |
-
}
|
277 |
-
#sbspf_admin .sbspf_connected_account
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
}
|
296 |
-
#sbspf_admin .sbspf_connected_account .
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
margin: 0;
|
301 |
-
|
302 |
-
}
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
}
|
321 |
-
#sbspf_admin .
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
#
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
background: #
|
378 |
-
color: #
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
#sbspf_admin .
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
#sbspf_admin .
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
}
|
411 |
-
#sbspf_admin .
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
}
|
417 |
-
|
418 |
-
#sbspf_admin .
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
border-radius:
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
#sbspf_admin .
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
height:
|
438 |
-
|
439 |
-
}
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
}
|
482 |
-
#sbspf_admin
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
}
|
501 |
-
#sbspf_admin .
|
502 |
-
#sbspf_admin .
|
503 |
-
|
504 |
-
}
|
505 |
-
#sbspf_admin .
|
506 |
-
display:
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
}
|
524 |
-
#sbspf_admin .
|
525 |
-
|
526 |
-
|
527 |
-
}
|
528 |
-
#sbspf_admin .
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
}
|
565 |
-
#
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
}
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
}
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
.
|
619 |
-
display: inline-block;
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
}
|
635 |
-
.
|
636 |
-
.
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
.sbspf_layout_cell
|
679 |
-
.
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
.
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
}
|
695 |
-
|
696 |
-
.
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
}
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
-
|
716 |
-
|
717 |
-
}
|
718 |
-
.
|
719 |
-
.
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
#sbspf_admin .
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
border-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
}
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
}
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
}
|
848 |
-
#sbspf_admin .
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
#sbspf_admin .
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
#sbspf_admin .
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
margin-
|
870 |
-
}
|
871 |
-
.
|
872 |
-
margin-
|
873 |
-
|
874 |
-
|
875 |
-
#sbspf_admin .
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
#sbspf_admin .
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
background:
|
890 |
-
color: #
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
#sbspf_admin .
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
bottom:
|
910 |
-
|
911 |
-
|
912 |
-
#
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
width:
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
}
|
935 |
-
#sbspf_admin .
|
936 |
-
|
937 |
-
|
938 |
-
}
|
939 |
-
#sbspf_admin .
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
#sbspf_admin .sby_mode_option
|
951 |
-
|
952 |
-
|
953 |
-
}
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
}
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
margin-left:
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
}
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
#sbspf-notice-bar
|
1016 |
-
|
1017 |
-
}
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
position:
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1046 |
}
|
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;
|
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 |
+
@media all and (max-width: 480px){
|
810 |
+
#sbspf_modal_overlay .sbspf_modal{
|
811 |
+
max-width: 100%;
|
812 |
+
margin: 0 0 0 -50%;
|
813 |
+
box-sizing: border-box;
|
814 |
+
}
|
815 |
+
}
|
816 |
+
.sbspf_emphasis {
|
817 |
+
display: block;
|
818 |
+
font-size: 16px;
|
819 |
+
text-align: center;
|
820 |
+
margin-bottom: 20px;
|
821 |
+
}
|
822 |
+
.sbspf_emphasis svg {
|
823 |
+
height: 14px;
|
824 |
+
}
|
825 |
+
.sbspf_modal_message h3 {
|
826 |
+
font-size: 14px;
|
827 |
+
}
|
828 |
+
.sbspf_modal .sbspf_modal_close{
|
829 |
+
position: absolute;
|
830 |
+
top: 0;
|
831 |
+
right: 0;
|
832 |
+
padding: 10px;
|
833 |
+
font-size: 14px;
|
834 |
+
color: #ccc;
|
835 |
+
margin: 0;
|
836 |
+
}
|
837 |
+
.sbspf_modal .sbspf_modal_close:focus,
|
838 |
+
.sbspf_modal .sbspf_modal_close:hover{
|
839 |
+
color: #333;
|
840 |
+
}
|
841 |
+
/* Pro only notices */
|
842 |
+
#sbspf_admin .sbspf_sub_options,
|
843 |
+
#sbspf_admin .sbspf_layout_cell,
|
844 |
+
#sbspf_admin .sbspf_layout_settings,
|
845 |
+
#sbspf_admin .sbspf_disabled_wrap{
|
846 |
+
position: relative;
|
847 |
+
}
|
848 |
+
#sbspf_admin .sbspf_sub_options:after,
|
849 |
+
#sbspf_admin .sbspf_disabled_wrap{
|
850 |
+
clear: both;
|
851 |
+
display: table;
|
852 |
+
content: ""
|
853 |
+
}
|
854 |
+
#sbspf_admin .sbspf_disabled_wrap{
|
855 |
+
width: 100%;
|
856 |
+
max-width: 520px;
|
857 |
+
}
|
858 |
+
#sbspf_admin .sby_includes_pro_only .sbspf_pro_tooltip {
|
859 |
+
top: 50%;
|
860 |
+
left: 30px;
|
861 |
+
bottom: auto;
|
862 |
+
margin-top: -96px;
|
863 |
+
}
|
864 |
+
#sbspf_admin .sbspf-show-pro{
|
865 |
+
margin-top: 10px;
|
866 |
+
text-align: center;
|
867 |
+
}
|
868 |
+
.sbspf_layout_cell.sbspf_pro_only .sbspf_lock{
|
869 |
+
margin-top: -4px;
|
870 |
+
}
|
871 |
+
#sbspf_admin .sbspf_layout_cell.sbspf_pro_only .sbspf_pro_tooltip {
|
872 |
+
margin-top: -38px;
|
873 |
+
left: 54px;
|
874 |
+
}
|
875 |
+
#sbspf_admin .sbspf_pro_only,
|
876 |
+
#sbspf_admin .sbspf_pro_only label,
|
877 |
+
#sbspf_admin .sbspf_pro_only input,
|
878 |
+
#sbspf_admin .sbspf_pro_only select,
|
879 |
+
#sbspf_admin .sbspf_pro_only_row,
|
880 |
+
#sbspf_admin .sbspf_pro_only_row label,
|
881 |
+
#sbspf_admin .sbspf_pro_only_row input,
|
882 |
+
#sbspf_admin .sbspf_pro_only_row select{
|
883 |
+
color: #999 !important;
|
884 |
+
}
|
885 |
+
#sbspf_admin tr.sbspf_pro_only{
|
886 |
+
background: #eacccc;
|
887 |
+
}
|
888 |
+
.sbspf_lock.sbspf_pro_lock {
|
889 |
+
background: rgba(255,255,255,0.8);
|
890 |
+
color: #666;
|
891 |
+
border: 1px solid #ccc;
|
892 |
+
margin-right: -34px;
|
893 |
+
}
|
894 |
+
.sbspf_lock.sbspf_pro_lock i {
|
895 |
+
margin-right: 8px;
|
896 |
+
}
|
897 |
+
#sbspf_admin .sbspf_pro_lock:hover,
|
898 |
+
#sbspf_admin .sbspf_pro_lock:hover{
|
899 |
+
background: #fff;
|
900 |
+
border: 1px solid #ccc;
|
901 |
+
color: #333;
|
902 |
+
box-shadow: 0 0 8px 0 rgba(0,0,0,0.15);
|
903 |
+
}
|
904 |
+
#sbspf_admin .sbspf_pro_tooltip{
|
905 |
+
text-align: center;
|
906 |
+
z-index:99;
|
907 |
+
display: none;
|
908 |
+
position: absolute;
|
909 |
+
bottom: 22px;
|
910 |
+
left: -8px;
|
911 |
+
|
912 |
+
background: #333;
|
913 |
+
color: #eee;
|
914 |
+
width: 90%;
|
915 |
+
padding: 8px 10px 10px 10px;
|
916 |
+
border-radius: 3px;
|
917 |
+
line-height: 1.3;
|
918 |
+
font-size: 12px;
|
919 |
+
width: 190px;
|
920 |
+
}
|
921 |
+
#sbspf_admin .sbspf_pro_tooltip .fa-caret-down {
|
922 |
+
position: absolute;
|
923 |
+
bottom: -12px;
|
924 |
+
font-size: 20px;
|
925 |
+
left: 49%;
|
926 |
+
color: #333;
|
927 |
+
}
|
928 |
+
#sbspf_admin .sbspf_layouts .sbspf_pro_tooltip,
|
929 |
+
#sbspf_admin .sbspf_sub_options .sbspf_pro_tooltip{
|
930 |
+
left: 284px;
|
931 |
+
top: -21px;
|
932 |
+
bottom: auto;
|
933 |
+
margin-left: -101px;
|
934 |
+
}
|
935 |
+
#sbspf_admin .sbspf_layouts .sbspf_layout_cell .sbspf_pro_tooltip{
|
936 |
+
left: 84px;
|
937 |
+
top: 32px;
|
938 |
+
}
|
939 |
+
#sbspf_admin .sbspf_table_key{
|
940 |
+
display: block;
|
941 |
+
float: left;
|
942 |
+
width: 11px;
|
943 |
+
height: 11px;
|
944 |
+
border: 1px solid #999;
|
945 |
+
background: #eacccc;
|
946 |
+
margin: 3px 6px 0 0;
|
947 |
+
}
|
948 |
+
|
949 |
+
/* SBY Specific */
|
950 |
+
#sbspf_admin .sby_mode_option {
|
951 |
+
position: relative;
|
952 |
+
margin-bottom: 20px;
|
953 |
+
}
|
954 |
+
#sbspf_admin .sby_mode_option label {
|
955 |
+
display: inline-block;
|
956 |
+
font-weight: bold;
|
957 |
+
}
|
958 |
+
#sbspf_admin .sby_mode_option .sbspf_note {
|
959 |
+
display: block;
|
960 |
+
margin-left: 0;
|
961 |
+
}
|
962 |
+
#sbspf_admin .sby_mode_option .sbspf_note,
|
963 |
+
#sbspf_admin .sby_mode_option label {
|
964 |
+
margin-bottom: 5px;
|
965 |
+
}
|
966 |
+
#sbspf_admin .sby_mode_option input[type=radio] {
|
967 |
+
position: absolute;
|
968 |
+
top: 6px;
|
969 |
+
}
|
970 |
+
#sbspf_admin .sby_mode_option_text {
|
971 |
+
margin-left: 22px;
|
972 |
+
}
|
973 |
+
#sbspf_admin .sby_mode_option.sbspf_fade .sby_important,
|
974 |
+
#sbspf_admin .sby_mode_option.sbspf_fade .sbspf_note {
|
975 |
+
opacity: 1;
|
976 |
+
}
|
977 |
+
|
978 |
+
/* Notices */
|
979 |
+
.sby_includes_pro_only .sbspf_lock {
|
980 |
+
left: 100px;
|
981 |
+
right: auto;
|
982 |
+
margin-top: -40px;
|
983 |
+
}
|
984 |
+
.sbspf_sub_options .sbspf_lock {
|
985 |
+
top: 38px;
|
986 |
+
left: 260px;
|
987 |
+
right: auto;
|
988 |
+
}
|
989 |
+
.sby_types_disabled_wrap .sbspf_lock {
|
990 |
+
margin-top: -20px;
|
991 |
+
}
|
992 |
+
#sbspf_admin .sby_types_disabled_wrap .sbspf_pro_tooltip {
|
993 |
+
top: 50%;
|
994 |
+
margin-left: -112px;
|
995 |
+
margin-top: -78px;
|
996 |
+
bottom: auto;
|
997 |
+
left: 50%;
|
998 |
+
}
|
999 |
+
@media screen and (max-width: 480px) {
|
1000 |
+
.sbspf_sub_options .sbspf_lock {
|
1001 |
+
top: 60px;
|
1002 |
+
left: 50%;
|
1003 |
+
margin-left: -40px;
|
1004 |
+
right: auto;
|
1005 |
+
}
|
1006 |
+
#sbspf_admin .sbspf_sub_options .sbspf_pro_tooltip {
|
1007 |
+
top: 0px;
|
1008 |
+
left: 50%;
|
1009 |
+
margin-left: -112px;
|
1010 |
+
}
|
1011 |
+
}
|
1012 |
+
|
1013 |
+
/* Lite Notice */
|
1014 |
+
@media screen and (max-width: 600px) {
|
1015 |
+
#sbspf-notice-bar {
|
1016 |
+
display:none !important
|
1017 |
+
}
|
1018 |
+
}
|
1019 |
+
|
1020 |
+
#sbspf-notice-bar {
|
1021 |
+
background-color: #DDDDDD;
|
1022 |
+
color: #777777;
|
1023 |
+
text-align: center;
|
1024 |
+
position: relative;
|
1025 |
+
padding: 7px;
|
1026 |
+
margin-bottom: 0;
|
1027 |
+
opacity: 1;
|
1028 |
+
transition: all .3s ease-in-out;
|
1029 |
+
max-height: 100px;
|
1030 |
+
overflow: hidden
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
#sbspf-notice-bar.out {
|
1034 |
+
opacity: .5;
|
1035 |
+
max-height: 0
|
1036 |
+
}
|
1037 |
+
|
1038 |
+
#sbspf-notice-bar a {
|
1039 |
+
color: #e34f0e;
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
#sbspf-notice-bar a:hover {
|
1043 |
+
color: #b85a1b
|
1044 |
+
}
|
1045 |
+
|
1046 |
+
#sbspf-notice-bar .dismiss {
|
1047 |
+
position: absolute;
|
1048 |
+
top: 0;
|
1049 |
+
right: 0;
|
1050 |
+
border: none;
|
1051 |
+
padding: 5px;
|
1052 |
+
margin-top: 1px;
|
1053 |
+
background: 0 0;
|
1054 |
+
color: #72777c;
|
1055 |
+
cursor: pointer
|
1056 |
+
}
|
1057 |
+
|
1058 |
+
#sbspf-notice-bar .dismiss:before {
|
1059 |
+
background: 0 0;
|
1060 |
+
color: #72777c;
|
1061 |
+
content: "\f335";
|
1062 |
+
display: block;
|
1063 |
+
font: normal 20px/20px dashicons;
|
1064 |
+
speak: none;
|
1065 |
+
height: 20px;
|
1066 |
+
text-align: center;
|
1067 |
+
width: 20px;
|
1068 |
+
-webkit-font-smoothing: antialiased
|
1069 |
}
|
css/sb-youtube.css
CHANGED
@@ -1,1321 +1,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_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 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
margin-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
[id^=sb_youtube_].sb_youtube
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
[id^=sb_youtube_].sb_youtube.
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
top:
|
348 |
-
left:
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
[id^=sb_youtube_].sb_youtube .
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
[id^=sb_youtube_].sb_youtube .
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
#
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
485 |
-
width:
|
486 |
-
height:
|
487 |
-
border-radius:
|
488 |
-
}
|
489 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
490 |
-
width:
|
491 |
-
height:
|
492 |
-
border-radius:
|
493 |
-
}
|
494 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
495 |
-
font-size:
|
496 |
-
}
|
497 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
498 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
499 |
-
font-size:
|
500 |
-
}
|
501 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
502 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
503 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
504 |
-
margin-left:
|
505 |
-
line-height: 1.
|
506 |
-
}
|
507 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
508 |
-
margin-right: -
|
509 |
-
}
|
510 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
511 |
-
margin-top:
|
512 |
-
}
|
513 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header.
|
514 |
-
padding-top:
|
515 |
-
}
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
}
|
530 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header .
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
}
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
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 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
}
|
605 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
[id^=sb_youtube_].sb_youtube .sb_youtube_header .
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
}
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
[id^=sb_youtube_].sb_youtube .
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
}
|
691 |
-
[id^=sb_youtube_].sb_youtube .
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
[id^=sb_youtube_].sb_youtube .
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
display:
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
background: #
|
709 |
-
color: #
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
[id^=sb_youtube_].sb_youtube .sby_follow_btn
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
}
|
744 |
-
[id^=sb_youtube_].sb_youtube .sby_follow_btn
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
@media all and (max-width:
|
786 |
-
/* Make
|
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 |
-
|
792 |
-
|
793 |
-
|
794 |
-
[id^=sb_youtube_].sb_youtube.
|
795 |
-
[id^=sb_youtube_].sb_youtube.
|
796 |
-
|
797 |
-
|
798 |
-
[id^=sb_youtube_].sb_youtube.
|
799 |
-
[id^=sb_youtube_].sb_youtube.
|
800 |
-
[id^=sb_youtube_].sb_youtube.
|
801 |
-
[id^=sb_youtube_].sb_youtube.
|
802 |
-
|
803 |
-
|
804 |
-
}
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
.
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
}
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
.
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
}
|
836 |
-
.
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
.
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
background-color:
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
height:
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
-
|
941 |
-
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
.sby_lb-nav a
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
}
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
.
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
}
|
1016 |
-
.sby_lb-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
}
|
1045 |
-
.sby_lb-data
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
.sby_lb-data .sby_lb-caption .
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
float: left;
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
}
|
1105 |
-
.
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
}
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
}
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
}
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
#sby_lightbox .
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
}
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
}
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
border:
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
}
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
}
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1321 |
}
|
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 |
}
|
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;left:50%;bottom:50%;top:50%;right:50%;margin-top:-24px;margin-left:-24px;color:#fff;width:48px;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 svg:not(:root).svg-inline--fa{width:48px;height:auto}[id^=sb_youtube_].sb_youtube .sby_play_btn i,[id^=sb_youtube_].sb_youtube .sby_play_btn svg{-webkit-filter:drop-shadow( 0 0 2px rgba(0,0,0,.4) );filter:drop-shadow( 0 0 2px rgba(0,0,0,.4) )}[id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn{margin-top:-12px;margin-left:-10px;width:23px}[id^=sb_youtube_].sb_youtube.sby_medium .sby_play_btn svg.svg-inline--fa.fa-play{width:23px}[id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn{margin-top:-9px;margin-left:-7px;width:18px}[id^=sb_youtube_].sb_youtube.sby_small .sby_play_btn svg.svg-inline--fa.fa-play{width:18px}[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 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:9999;background-color:#000;opacity:.9;display:none}.sby_lightbox{position:absolute;left:0;width:100%;z-index:10000;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;-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_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}
|
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,89 +1,89 @@
|
|
1 |
-
/* Review notice */
|
2 |
-
.sby_review_notice{
|
3 |
-
position: relative;
|
4 |
-
overflow: hidden;
|
5 |
-
max-width: 870px;
|
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_bfcm_sale_notice,
|
14 |
-
.sby_new_user_sale_notice{
|
15 |
-
max-width: 672px;
|
16 |
-
}
|
17 |
-
.sby_review_notice img{
|
18 |
-
width: 74px;
|
19 |
-
margin: 0 0 0 -100% !important;
|
20 |
-
|
21 |
-
-moz-border-radius: 4px;
|
22 |
-
-webkit-border-radius: 4px;
|
23 |
-
border-radius: 4px;
|
24 |
-
}
|
25 |
-
.sby_review_notice .sby-notice-text{
|
26 |
-
float: left;
|
27 |
-
clear: none;
|
28 |
-
width: 100%;
|
29 |
-
padding: 0;
|
30 |
-
}
|
31 |
-
.sby_review_notice p{
|
32 |
-
float: left;
|
33 |
-
clear: both;
|
34 |
-
width: auto;
|
35 |
-
margin: 0 0 0 90px !important;
|
36 |
-
padding: 2px 40px 2px 0;
|
37 |
-
line-height: 1.4;
|
38 |
-
}
|
39 |
-
.sby_review_notice .sby-links{
|
40 |
-
margin-top: 4px !important;
|
41 |
-
}
|
42 |
-
.sby_review_notice a{
|
43 |
-
display: inline-block;
|
44 |
-
padding: 0 8px;
|
45 |
-
color: #178529;
|
46 |
-
}
|
47 |
-
.sby_review_notice a:hover,
|
48 |
-
.sby_review_notice a:focus{
|
49 |
-
color: #0c7abf;
|
50 |
-
}
|
51 |
-
.sby_review_notice .links{
|
52 |
-
margin: 0 0 0 82px !important;
|
53 |
-
padding: 4px 0 0 0;
|
54 |
-
margin-top: 6px !important;
|
55 |
-
}
|
56 |
-
.sby_review_notice .sby_notice_close,
|
57 |
-
.sby_review_notice .sby_bfcm_sale_notice_close,
|
58 |
-
.sby_review_notice .sby_new_user_sale_notice_close {
|
59 |
-
position: absolute;
|
60 |
-
top: 0;
|
61 |
-
right: 0;
|
62 |
-
padding: 10px;
|
63 |
-
line-height: 1;
|
64 |
-
}
|
65 |
-
.sby_review_notice .sby_notice_close:hover,
|
66 |
-
.sby_review_notice .sby_notice_close:focus{
|
67 |
-
color: #a34100;
|
68 |
-
}
|
69 |
-
.sby_review_notice .sby_offer_btn {
|
70 |
-
padding: 4px 12px 6px 12px;
|
71 |
-
background: green;
|
72 |
-
color: #fff;
|
73 |
-
border-radius: 4px;
|
74 |
-
display: inline-block;
|
75 |
-
text-decoration: none;
|
76 |
-
margin-left: 0;
|
77 |
-
}
|
78 |
-
.sby_review_notice .sby_offer_btn:hover, .sby_review_notice .sby_offer_btn:focus {
|
79 |
-
background: #049404;
|
80 |
-
color: #fff;
|
81 |
-
}
|
82 |
-
.sby_review_notice .sby_other_notice{
|
83 |
-
padding-top: 10px;
|
84 |
-
font-style: italic;
|
85 |
-
font-size: 12px;
|
86 |
-
}
|
87 |
-
.sby_review_notice .sby_other_notice a{
|
88 |
-
padding: 0;
|
89 |
}
|
1 |
+
/* Review notice */
|
2 |
+
.sby_review_notice{
|
3 |
+
position: relative;
|
4 |
+
overflow: hidden;
|
5 |
+
max-width: 870px;
|
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_bfcm_sale_notice,
|
14 |
+
.sby_new_user_sale_notice{
|
15 |
+
max-width: 672px;
|
16 |
+
}
|
17 |
+
.sby_review_notice img{
|
18 |
+
width: 74px;
|
19 |
+
margin: 0 0 0 -100% !important;
|
20 |
+
|
21 |
+
-moz-border-radius: 4px;
|
22 |
+
-webkit-border-radius: 4px;
|
23 |
+
border-radius: 4px;
|
24 |
+
}
|
25 |
+
.sby_review_notice .sby-notice-text{
|
26 |
+
float: left;
|
27 |
+
clear: none;
|
28 |
+
width: 100%;
|
29 |
+
padding: 0;
|
30 |
+
}
|
31 |
+
.sby_review_notice p{
|
32 |
+
float: left;
|
33 |
+
clear: both;
|
34 |
+
width: auto;
|
35 |
+
margin: 0 0 0 90px !important;
|
36 |
+
padding: 2px 40px 2px 0;
|
37 |
+
line-height: 1.4;
|
38 |
+
}
|
39 |
+
.sby_review_notice .sby-links{
|
40 |
+
margin-top: 4px !important;
|
41 |
+
}
|
42 |
+
.sby_review_notice a{
|
43 |
+
display: inline-block;
|
44 |
+
padding: 0 8px;
|
45 |
+
color: #178529;
|
46 |
+
}
|
47 |
+
.sby_review_notice a:hover,
|
48 |
+
.sby_review_notice a:focus{
|
49 |
+
color: #0c7abf;
|
50 |
+
}
|
51 |
+
.sby_review_notice .links{
|
52 |
+
margin: 0 0 0 82px !important;
|
53 |
+
padding: 4px 0 0 0;
|
54 |
+
margin-top: 6px !important;
|
55 |
+
}
|
56 |
+
.sby_review_notice .sby_notice_close,
|
57 |
+
.sby_review_notice .sby_bfcm_sale_notice_close,
|
58 |
+
.sby_review_notice .sby_new_user_sale_notice_close {
|
59 |
+
position: absolute;
|
60 |
+
top: 0;
|
61 |
+
right: 0;
|
62 |
+
padding: 10px;
|
63 |
+
line-height: 1;
|
64 |
+
}
|
65 |
+
.sby_review_notice .sby_notice_close:hover,
|
66 |
+
.sby_review_notice .sby_notice_close:focus{
|
67 |
+
color: #a34100;
|
68 |
+
}
|
69 |
+
.sby_review_notice .sby_offer_btn {
|
70 |
+
padding: 4px 12px 6px 12px;
|
71 |
+
background: green;
|
72 |
+
color: #fff;
|
73 |
+
border-radius: 4px;
|
74 |
+
display: inline-block;
|
75 |
+
text-decoration: none;
|
76 |
+
margin-left: 0;
|
77 |
+
}
|
78 |
+
.sby_review_notice .sby_offer_btn:hover, .sby_review_notice .sby_offer_btn:focus {
|
79 |
+
background: #049404;
|
80 |
+
color: #fff;
|
81 |
+
}
|
82 |
+
.sby_review_notice .sby_other_notice{
|
83 |
+
padding-top: 10px;
|
84 |
+
font-style: italic;
|
85 |
+
font-size: 12px;
|
86 |
+
}
|
87 |
+
.sby_review_notice .sby_other_notice a{
|
88 |
+
padding: 0;
|
89 |
}
|
img/sby-icon-offer.png
CHANGED
Binary file
|
inc/admin/admin-functions.php
CHANGED
@@ -1,959 +1,960 @@
|
|
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 |
-
$html = ob_get_contents();
|
471 |
-
ob_get_clean();
|
472 |
-
|
473 |
-
$return = array(
|
474 |
-
'account_id' => $account['channel_id'],
|
475 |
-
'html' => $html
|
476 |
-
);
|
477 |
-
} else {
|
478 |
-
$return = array(
|
479 |
-
'error' => __( 'Could not connect your account. Please check to make sure this is a valid access token for the Smash Balloon YouTube App.'),
|
480 |
-
'html' => ''
|
481 |
-
);
|
482 |
-
}
|
483 |
-
|
484 |
-
echo wp_json_encode( $return );
|
485 |
-
|
486 |
-
die();
|
487 |
-
}
|
488 |
-
add_action( 'wp_ajax_sby_process_access_token', 'sby_process_access_token' );
|
489 |
-
|
490 |
-
function sby_delete_wp_posts() {
|
491 |
-
if ( ! isset( $_POST['sbspf_nonce'] ) ) return;
|
492 |
-
$nonce = $_POST['sbspf_nonce'];
|
493 |
-
if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
|
494 |
-
die ( 'You did not do this the right way!' );
|
495 |
-
}
|
496 |
-
|
497 |
-
sby_clear_wp_posts();
|
498 |
-
|
499 |
-
echo '{}';
|
500 |
-
|
501 |
-
die();
|
502 |
-
}
|
503 |
-
add_action( 'wp_ajax_sby_delete_wp_posts', 'sby_delete_wp_posts' );
|
504 |
-
|
505 |
-
function sby_attempt_connection() {
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
$
|
511 |
-
|
512 |
-
|
513 |
-
$
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
'
|
519 |
-
|
520 |
-
|
521 |
-
$sby_api_connect
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
$
|
528 |
-
$sby_api_connect
|
529 |
-
$
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
$account_info['
|
534 |
-
$account_info['
|
535 |
-
$account_info['
|
536 |
-
$account_info['
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
$
|
557 |
-
|
558 |
-
'
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
$
|
571 |
-
$
|
572 |
-
$
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
$
|
593 |
-
$
|
594 |
-
$
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
}
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
$wpdb->query( "DELETE FROM $wpdb->
|
613 |
-
|
614 |
-
}
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
$
|
636 |
-
$
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
$
|
644 |
-
$
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
//$sby_statuses_option = array( 'first_install' =>
|
654 |
-
|
655 |
-
|
656 |
-
//
|
657 |
-
//
|
658 |
-
|
659 |
-
|
660 |
-
//
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
//
|
666 |
-
|
667 |
-
$
|
668 |
-
$
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
$
|
673 |
-
$
|
674 |
-
$
|
675 |
-
|
676 |
-
|
677 |
-
$
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
$ignore_bfcm_sale_notice_meta =
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
$
|
692 |
-
$
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
$
|
698 |
-
$ignore_new_user_sale_notice_meta =
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
$
|
707 |
-
$ignore_new_user_sale_notice_meta =
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
&&
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
$
|
721 |
-
$
|
722 |
-
|
723 |
-
|
724 |
-
var_dump( 'new user rating
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
var_dump( '
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
var_dump( '
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
var_dump( '
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
$
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
$
|
752 |
-
$
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
'
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
'
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
<
|
772 |
-
|
773 |
-
<p
|
774 |
-
|
775 |
-
echo "
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
$
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
<
|
799 |
-
|
800 |
-
<p
|
801 |
-
|
802 |
-
<a class='sby_notice_dismiss
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
<
|
817 |
-
|
818 |
-
<p
|
819 |
-
|
820 |
-
<a class='sby_notice_dismiss'
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
$
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
$
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
$
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
if
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
'
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
in_array( $
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
}
|
|
|
959 |
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 |
+
$html = ob_get_contents();
|
471 |
+
ob_get_clean();
|
472 |
+
|
473 |
+
$return = array(
|
474 |
+
'account_id' => $account['channel_id'],
|
475 |
+
'html' => $html
|
476 |
+
);
|
477 |
+
} else {
|
478 |
+
$return = array(
|
479 |
+
'error' => __( 'Could not connect your account. Please check to make sure this is a valid access token for the Smash Balloon YouTube App.'),
|
480 |
+
'html' => ''
|
481 |
+
);
|
482 |
+
}
|
483 |
+
|
484 |
+
echo wp_json_encode( $return );
|
485 |
+
|
486 |
+
die();
|
487 |
+
}
|
488 |
+
add_action( 'wp_ajax_sby_process_access_token', 'sby_process_access_token' );
|
489 |
+
|
490 |
+
function sby_delete_wp_posts() {
|
491 |
+
if ( ! isset( $_POST['sbspf_nonce'] ) ) return;
|
492 |
+
$nonce = $_POST['sbspf_nonce'];
|
493 |
+
if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
|
494 |
+
die ( 'You did not do this the right way!' );
|
495 |
+
}
|
496 |
+
|
497 |
+
sby_clear_wp_posts();
|
498 |
+
|
499 |
+
echo '{}';
|
500 |
+
|
501 |
+
die();
|
502 |
+
}
|
503 |
+
add_action( 'wp_ajax_sby_delete_wp_posts', 'sby_delete_wp_posts' );
|
504 |
+
|
505 |
+
function sby_attempt_connection() {
|
506 |
+
if ( ! current_user_can( 'manage_youtube_feed_options' ) ) {
|
507 |
+
return false;
|
508 |
+
}
|
509 |
+
if ( isset( $_GET['sby_access_token'] ) ) {
|
510 |
+
$access_token = sanitize_text_field( urldecode( $_GET['sby_access_token'] ) );
|
511 |
+
$refresh_token = sanitize_text_field( urldecode( $_GET['sby_refresh_token'] ) );
|
512 |
+
} else {
|
513 |
+
$access_token = sanitize_text_field( $_POST['sby_access_token'] );
|
514 |
+
$refresh_token = sanitize_text_field( $_POST['sby_refresh_token'] );
|
515 |
+
}
|
516 |
+
|
517 |
+
$account_info = array(
|
518 |
+
'access_token' => $access_token,
|
519 |
+
'refresh_token' => $refresh_token
|
520 |
+
);
|
521 |
+
$sby_api_connect = new SBY_API_Connect( $account_info, 'tokeninfo' );
|
522 |
+
$sby_api_connect->connect();
|
523 |
+
|
524 |
+
$data = $sby_api_connect->get_data();
|
525 |
+
|
526 |
+
if ( isset( $data['audience'] ) ) {
|
527 |
+
$expires = $data['expires_in'] + time();
|
528 |
+
$sby_api_connect = new SBY_API_Connect( $account_info, 'channels' );
|
529 |
+
$sby_api_connect->connect();
|
530 |
+
$data = $sby_api_connect->get_data();
|
531 |
+
|
532 |
+
if ( isset( $data['items'] ) ) {
|
533 |
+
$account_info['username'] = $data['items'][0]['snippet']['title'];
|
534 |
+
$account_info['channel_id'] = $data['items'][0]['id'];
|
535 |
+
$account_info['profile_picture'] = $data['items'][0]['snippet']['thumbnails']['default']['url'];
|
536 |
+
$account_info['privacy'] = '';
|
537 |
+
$account_info['expires'] = $expires;
|
538 |
+
//privacyStatus
|
539 |
+
SBY_Admin::connect_account( $account_info );
|
540 |
+
|
541 |
+
return $account_info;
|
542 |
+
}
|
543 |
+
}
|
544 |
+
return false;
|
545 |
+
}
|
546 |
+
|
547 |
+
function sbspf_account_search() {
|
548 |
+
if ( ! isset( $_POST['sbspf_nonce'] ) || ! isset( $_POST['term']) ) return;
|
549 |
+
$nonce = $_POST['sbspf_nonce'];
|
550 |
+
if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
|
551 |
+
die ( 'You did not do this the right way!' );
|
552 |
+
}
|
553 |
+
|
554 |
+
global $sby_settings;
|
555 |
+
|
556 |
+
$term = sanitize_text_field( $_POST['term'] );
|
557 |
+
$params = array(
|
558 |
+
'q' => $term,
|
559 |
+
'type' => 'channel'
|
560 |
+
);
|
561 |
+
|
562 |
+
$connected_account_for_term = array();
|
563 |
+
foreach ( $sby_settings['connected_accounts'] as $connected_account ) {
|
564 |
+
$connected_account_for_term = $connected_account;
|
565 |
+
}
|
566 |
+
if ( $connected_account_for_term['expires'] < time() + 5 ) {
|
567 |
+
$new_token_data = SBY_API_Connect::refresh_token( sby_get_account_bottom(), $connected_account_for_term['refresh_token'], sby_get_account_top() );
|
568 |
+
|
569 |
+
if ( isset( $new_token_data['access_token'] ) ) {
|
570 |
+
$connected_account_for_term['access_token'] = $new_token_data['access_token'];
|
571 |
+
$connected_accounts_for_feed[ $term ]['access_token'] = $new_token_data['access_token'];
|
572 |
+
$connected_account_for_term['expires'] = $new_token_data['expires_in'] + time();
|
573 |
+
$connected_accounts_for_feed[ $term ]['expires'] = $new_token_data['expires_in'] + time();
|
574 |
+
|
575 |
+
sby_update_or_connect_account( $connected_account_for_term );
|
576 |
+
|
577 |
+
}
|
578 |
+
}
|
579 |
+
|
580 |
+
$search = new SBY_API_Connect( $connected_account_for_term, 'search', $params );
|
581 |
+
|
582 |
+
$search->connect();
|
583 |
+
|
584 |
+
|
585 |
+
echo wp_json_encode( $search->get_data() );
|
586 |
+
|
587 |
+
die();
|
588 |
+
}
|
589 |
+
add_action( 'wp_ajax_sbspf_account_search', 'sbspf_account_search' );
|
590 |
+
|
591 |
+
function sby_reset_cron( $settings ) {
|
592 |
+
$sbi_caching_type = isset( $settings['caching_type'] ) ? $settings['caching_type'] : '';
|
593 |
+
$sbi_cache_cron_interval = isset( $settings['cache_cron_interval'] ) ? $settings['cache_cron_interval'] : '';
|
594 |
+
$sbi_cache_cron_time = isset( $settings['cache_cron_time'] ) ? $settings['cache_cron_time'] : '';
|
595 |
+
$sbi_cache_cron_am_pm = isset( $settings['cache_cron_am_pm'] ) ? $settings['cache_cron_am_pm'] : '';
|
596 |
+
|
597 |
+
if ( $sbi_caching_type === 'background' ) {
|
598 |
+
delete_option( 'sby_cron_report' );
|
599 |
+
SBY_Cron_Updater::start_cron_job( $sbi_cache_cron_interval, $sbi_cache_cron_time, $sbi_cache_cron_am_pm );
|
600 |
+
}
|
601 |
+
}
|
602 |
+
add_action( 'sby_settings_after_configure_save', 'sby_reset_cron', 10, 1 );
|
603 |
+
|
604 |
+
function sby_clear_wp_posts() {
|
605 |
+
|
606 |
+
global $wpdb;
|
607 |
+
|
608 |
+
$youtube_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type = '".SBY_CPT."';" );
|
609 |
+
|
610 |
+
$id_string = implode( ', ', $youtube_ids );
|
611 |
+
if ( ! empty( $id_string ) ) {
|
612 |
+
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE post_id IN ($id_string);" );
|
613 |
+
$wpdb->query( "DELETE FROM $wpdb->posts WHERE post_type = '".SBY_CPT."';" );
|
614 |
+
}
|
615 |
+
}
|
616 |
+
|
617 |
+
/** Notices */
|
618 |
+
|
619 |
+
function sby_get_current_time() {
|
620 |
+
$current_time = time();
|
621 |
+
|
622 |
+
// where to do tests
|
623 |
+
//$current_time = strtotime( 'November 25, 2020' ) + 1;
|
624 |
+
|
625 |
+
return $current_time;
|
626 |
+
}
|
627 |
+
|
628 |
+
// generates the html for the admin notices
|
629 |
+
function sby_notices_html() {
|
630 |
+
|
631 |
+
if ( function_exists( 'sbi_notices_html' ) || function_exists( 'cff_notices_html' || function_exists( 'ctf_notices_html' ) ) ) {
|
632 |
+
return;
|
633 |
+
}
|
634 |
+
|
635 |
+
$current_screen = get_current_screen();
|
636 |
+
$is_plugins_page = isset( $current_screen->id ) && $current_screen->id === 'plugins';
|
637 |
+
$page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
|
638 |
+
//Only show to admins
|
639 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
640 |
+
return;
|
641 |
+
}
|
642 |
+
|
643 |
+
$sby_statuses_option = get_option( 'sby_statuses', array() );
|
644 |
+
$current_time = sby_get_current_time();
|
645 |
+
$sby_bfcm_discount_code = 'happysmashgiving' . date('Y', $current_time );
|
646 |
+
|
647 |
+
// reset everything for testing
|
648 |
+
if ( false ) {
|
649 |
+
global $current_user;
|
650 |
+
$user_id = $current_user->ID;
|
651 |
+
delete_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice' );
|
652 |
+
//delete_user_meta( $user_id, 'sby_ignore_new_user_sale_notice' );
|
653 |
+
//$sby_statuses_option = array( 'first_install' => strtotime( 'December 8, 2019' ) );
|
654 |
+
//$sby_statuses_option = array( 'first_install' => time() );
|
655 |
+
|
656 |
+
//update_option( 'sby_statuses', $sby_statuses_option, false );
|
657 |
+
//delete_option( 'sby_rating_notice');
|
658 |
+
//delete_transient( 'instagram_feed_rating_notice_waiting' );
|
659 |
+
|
660 |
+
//set_transient( 'instagram_feed_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS );
|
661 |
+
//update_option( 'sby_rating_notice', 'pending', false );
|
662 |
+
}
|
663 |
+
|
664 |
+
//$sby_statuses_option['rating_notice_dismissed'] = time();
|
665 |
+
//update_option( 'sby_statuses', $sby_statuses_option, false );
|
666 |
+
// rating notice logic
|
667 |
+
$sby_rating_notice_option = get_option( 'sby_rating_notice', false );
|
668 |
+
$sby_rating_notice_waiting = get_transient( 'feeds_for_youtube_rating_notice_waiting' );
|
669 |
+
$should_show_rating_notice = ($sby_rating_notice_waiting !== 'waiting' && $sby_rating_notice_option !== 'dismissed');
|
670 |
+
|
671 |
+
// black friday cyber monday logic
|
672 |
+
$thanksgiving_this_year = sby_get_future_date( 11, date('Y', $current_time ), 4, 4, 1 );
|
673 |
+
$one_week_before_black_friday_this_year = $thanksgiving_this_year - 7*24*60*60;
|
674 |
+
$one_day_after_cyber_monday_this_year = $thanksgiving_this_year + 5*24*60*60;
|
675 |
+
$has_been_two_days_since_rating_dismissal = isset( $sby_statuses_option['rating_notice_dismissed'] ) ? ((int)$sby_statuses_option['rating_notice_dismissed'] + 2*24*60*60) < $current_time : true;
|
676 |
+
|
677 |
+
$could_show_bfcm_discount = ($current_time > $one_week_before_black_friday_this_year && $current_time < $one_day_after_cyber_monday_this_year);
|
678 |
+
$should_show_bfcm_discount = false;
|
679 |
+
if ( $could_show_bfcm_discount && $has_been_two_days_since_rating_dismissal ) {
|
680 |
+
global $current_user;
|
681 |
+
$user_id = $current_user->ID;
|
682 |
+
|
683 |
+
$ignore_bfcm_sale_notice_meta = get_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice' );
|
684 |
+
$ignore_bfcm_sale_notice_meta = isset( $ignore_bfcm_sale_notice_meta[0] ) ? $ignore_bfcm_sale_notice_meta[0] : '';
|
685 |
+
|
686 |
+
/* Check that the user hasn't already clicked to ignore the message */
|
687 |
+
$should_show_bfcm_discount = ($ignore_bfcm_sale_notice_meta !== 'always' && $ignore_bfcm_sale_notice_meta !== date( 'Y', $current_time ));
|
688 |
+
}
|
689 |
+
|
690 |
+
// new user discount logic
|
691 |
+
$in_new_user_month_range = true;
|
692 |
+
$should_show_new_user_discount = false;
|
693 |
+
$has_been_one_month_since_rating_dismissal = isset( $sby_statuses_option['rating_notice_dismissed'] ) ? ((int)$sby_statuses_option['rating_notice_dismissed'] + 30*24*60*60) < $current_time + 1: true;
|
694 |
+
|
695 |
+
if ( isset( $sby_statuses_option['first_install'] ) && $sby_statuses_option['first_install'] === 'from_update' ) {
|
696 |
+
global $current_user;
|
697 |
+
$user_id = $current_user->ID;
|
698 |
+
$ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sby_ignore_new_user_sale_notice' );
|
699 |
+
$ignore_new_user_sale_notice_meta = isset( $ignore_new_user_sale_notice_meta[0] ) ? $ignore_new_user_sale_notice_meta[0] : '';
|
700 |
+
|
701 |
+
if ( $ignore_new_user_sale_notice_meta !== 'always' ) {
|
702 |
+
$should_show_new_user_discount = true;
|
703 |
+
}
|
704 |
+
} elseif ( $in_new_user_month_range && $has_been_one_month_since_rating_dismissal ) {
|
705 |
+
global $current_user;
|
706 |
+
$user_id = $current_user->ID;
|
707 |
+
$ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sby_ignore_new_user_sale_notice' );
|
708 |
+
$ignore_new_user_sale_notice_meta = isset( $ignore_new_user_sale_notice_meta[0] ) ? $ignore_new_user_sale_notice_meta[0] : '';
|
709 |
+
|
710 |
+
if ( $ignore_new_user_sale_notice_meta !== 'always'
|
711 |
+
&& isset( $sby_statuses_option['first_install'] )
|
712 |
+
&& $current_time > (int)$sby_statuses_option['first_install'] + 60*60*24*30 ) {
|
713 |
+
$should_show_new_user_discount = true;
|
714 |
+
}
|
715 |
+
}
|
716 |
+
|
717 |
+
// for debugging
|
718 |
+
if ( false ) {
|
719 |
+
global $current_user;
|
720 |
+
$user_id = $current_user->ID;
|
721 |
+
$ignore_bfcm_sale_notice_meta = get_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice' );
|
722 |
+
$ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sby_ignore_new_user_sale_notice' );
|
723 |
+
|
724 |
+
var_dump( 'new user rating option', $sby_rating_notice_option );
|
725 |
+
var_dump( 'new user rating transient', $sby_rating_notice_waiting );
|
726 |
+
|
727 |
+
var_dump( 'should show new user rating notice?', $should_show_rating_notice );
|
728 |
+
|
729 |
+
var_dump( 'new user discount month range?', $in_new_user_month_range );
|
730 |
+
var_dump( 'should show new user discount?', $should_show_new_user_discount );
|
731 |
+
|
732 |
+
var_dump( 'Thanksgiving this year?', date('m/d/Y', $thanksgiving_this_year ) );
|
733 |
+
|
734 |
+
var_dump( 'could show bfcm discount?', $could_show_bfcm_discount );
|
735 |
+
var_dump( 'rating was dismissed?', date('m/d/Y', $sby_statuses_option['rating_notice_dismissed'] ) );
|
736 |
+
|
737 |
+
var_dump( 'should show bfcm discount?', $should_show_bfcm_discount );
|
738 |
+
|
739 |
+
var_dump( 'ignore_bfcm_sale_notice_meta', $ignore_bfcm_sale_notice_meta );
|
740 |
+
var_dump( 'ignore_new_user_sale_notice_meta', $ignore_new_user_sale_notice_meta );
|
741 |
+
|
742 |
+
var_dump( $sby_statuses_option );
|
743 |
+
}
|
744 |
+
|
745 |
+
|
746 |
+
// no pro version yet, set these to false
|
747 |
+
$should_show_new_user_discount = false;
|
748 |
+
$should_show_bfcm_discount = false;
|
749 |
+
|
750 |
+
if ( $should_show_rating_notice ) {
|
751 |
+
$other_notice_html = '';
|
752 |
+
$dismiss_url = add_query_arg( 'sby_ignore_rating_notice_nag', '1' );
|
753 |
+
$later_url = add_query_arg( 'sby_ignore_rating_notice_nag', 'later' );
|
754 |
+
if ( $should_show_bfcm_discount ) {
|
755 |
+
$other_notice_html = '<p class="sby_other_notice">' . __( 'PS. We currently have a <a href="https://smashballoon.com/video-feed/?utm_source=plugin-free&utm_campaign=sby&discount='.$sby_bfcm_discount_code.'" target="_blank"><b style="font-weight: 700;">Black Friday deal</b></a> for 60% off the Pro version!', SBY_TEXT_DOMAIN ) . '</p>';
|
756 |
+
|
757 |
+
$dismiss_url = add_query_arg( array(
|
758 |
+
'sby_ignore_rating_notice_nag' => '1',
|
759 |
+
'sby_ignore_bfcm_sale_notice' => date( 'Y', $current_time )
|
760 |
+
)
|
761 |
+
);
|
762 |
+
$later_url = add_query_arg( array(
|
763 |
+
'sby_ignore_rating_notice_nag' => 'later',
|
764 |
+
'sby_ignore_bfcm_sale_notice' => date( 'Y', $current_time )
|
765 |
+
)
|
766 |
+
);
|
767 |
+
}
|
768 |
+
|
769 |
+
echo "
|
770 |
+
<div class='sby_notice sby_review_notice'>
|
771 |
+
<img src='". SBY_PLUGIN_URL . 'img/sby-icon.png' ."' alt='" . SBY_PLUGIN_NAME . "'>
|
772 |
+
<div class='sby-notice-text'>
|
773 |
+
<p style='padding-top: 4px;'>" . sprintf( __( "It's great to see that you've been using the %s plugin for a while now. Hopefully you're happy with it! If so, would you consider leaving a positive review? It really helps to support the plugin and helps others to discover it too!", SBY_TEXT_DOMAIN ), '<strong style=\'font-weight: 700;\'>'.SBY_PLUGIN_NAME.'</strong>' ) . "</p>
|
774 |
+
<p class='links'";
|
775 |
+
if( $should_show_bfcm_discount ) echo " style='margin-top: 0 !important;'";
|
776 |
+
echo ">
|
777 |
+
<a class='sby_notice_dismiss' href='https://wordpress.org/support/plugin/feeds-for-youtube/reviews/' target='_blank'>" . __( 'Sure, I\'d love to!', SBY_TEXT_DOMAIN ) . "</a>
|
778 |
+
·
|
779 |
+
<a class='sby_notice_dismiss' href='" .esc_url( $dismiss_url ). "'>" . __( 'No thanks', SBY_TEXT_DOMAIN ) . "</a>
|
780 |
+
·
|
781 |
+
<a class='sby_notice_dismiss' href='" .esc_url( $dismiss_url ). "'>" . __( 'I\'ve already given a review', SBY_TEXT_DOMAIN ) . "</a>
|
782 |
+
·
|
783 |
+
<a class='sby_notice_dismiss' href='" .esc_url( $later_url ). "'>" . __( 'Ask Me Later', SBY_TEXT_DOMAIN ) . "</a>
|
784 |
+
</p>"
|
785 |
+
. $other_notice_html .
|
786 |
+
"</div>
|
787 |
+
<a class='sby_notice_close' href='" .esc_url( $dismiss_url ). "'><i class='fa fa-close'></i></a>
|
788 |
+
</div>";
|
789 |
+
|
790 |
+
} elseif ( $should_show_new_user_discount ) {
|
791 |
+
global $current_user;
|
792 |
+
$user_id = $current_user->ID;
|
793 |
+
$ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sby_ignore_new_user_sale_notice' );
|
794 |
+
if ( $ignore_new_user_sale_notice_meta !== 'always' ) {
|
795 |
+
|
796 |
+
echo "
|
797 |
+
<div class='sby_notice sby_review_notice sby_new_user_sale_notice'>
|
798 |
+
<img src='" . SBY_PLUGIN_URL . 'img/sby-icon-offer.png' . "' alt='".SBY_PLUGIN_NAME."'>
|
799 |
+
<div class='sby-notice-text'>
|
800 |
+
<p>" . __( '<b style="font-weight: 700;">Exclusive offer!</b> We don\'t run promotions very often, but for a limited time we\'re offering <b style="font-weight: 700;">60% off</b> our Pro version to all users of our free Feeds for YouTube plugin.', SBY_TEXT_DOMAIN ) . "</p>
|
801 |
+
<p class='sby-links'>
|
802 |
+
<a class='sby_notice_dismiss sby_offer_btn' href='https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby&discount=youtubethankyou' target='_blank'><b>" . __( 'Get this offer', SBY_TEXT_DOMAIN ) . "</b></a>
|
803 |
+
<a class='sby_notice_dismiss' style='margin-left: 5px;' href='" . esc_url( add_query_arg( 'sby_ignore_new_user_sale_notice', 'always' ) ) . "'>" . __( 'I\'m not interested', SBY_TEXT_DOMAIN ) . "</a>
|
804 |
+
|
805 |
+
</p>
|
806 |
+
</div>
|
807 |
+
<a class='sby_new_user_sale_notice_close' href='" . esc_url( add_query_arg( 'sby_ignore_new_user_sale_notice', 'always' ) ) . "'><i class='fa fa-close'></i></a>
|
808 |
+
</div>
|
809 |
+
";
|
810 |
+
}
|
811 |
+
|
812 |
+
} elseif ( $should_show_bfcm_discount ) {
|
813 |
+
|
814 |
+
echo "
|
815 |
+
<div class='sby_notice sby_review_notice sby_bfcm_sale_notice'>
|
816 |
+
<img src='". SBY_PLUGIN_URL . 'img/sby-icon-offer.png' ."' alt='".SBY_PLUGIN_NAME."'>
|
817 |
+
<div class='sby-notice-text'>
|
818 |
+
<p>" . sprintf( __( '<b style="font-weight: 700;">Black Friday/Cyber Monday Deal!</b> Thank you for using our free %s plugin. For a limited time, we\'re offering <b style="font-weight: 700;">60% off</b> the Pro version for all of our users.', SBY_TEXT_DOMAIN ), SBY_PLUGIN_NAME ) . "</p>
|
819 |
+
<p class='sby-links'>
|
820 |
+
<a class='sby_notice_dismiss sby_offer_btn' href='https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby&discount=".$sby_bfcm_discount_code."' target='_blank'><b>" . __( 'Get this offer', SBY_TEXT_DOMAIN ) . "</b></a>
|
821 |
+
<a class='sby_notice_dismiss' style='margin-left: 5px;' href='" .esc_url( add_query_arg( 'sby_ignore_bfcm_sale_notice', date( 'Y', $current_time ) ) ). "'>" . __( 'I\'m not interested', SBY_TEXT_DOMAIN ) . "</a>
|
822 |
+
</p>
|
823 |
+
</div>
|
824 |
+
<a class='sby_bfcm_sale_notice_close' href='" .esc_url( add_query_arg( 'sby_ignore_bfcm_sale_notice', date( 'Y', $current_time ) ) ). "'><i class='fa fa-close'></i></a>
|
825 |
+
</div>
|
826 |
+
";
|
827 |
+
|
828 |
+
}
|
829 |
+
|
830 |
+
}
|
831 |
+
add_action( 'admin_notices', 'sby_notices_html', 12 ); // priority 8 for Instagram, priority 10 for Facebook
|
832 |
+
|
833 |
+
function sby_process_nags() {
|
834 |
+
|
835 |
+
global $current_user;
|
836 |
+
$user_id = $current_user->ID;
|
837 |
+
$sby_statuses_option = get_option( 'sby_statuses', array() );
|
838 |
+
|
839 |
+
if ( isset( $_GET['sby_ignore_rating_notice_nag'] ) ) {
|
840 |
+
if ( (int)$_GET['sby_ignore_rating_notice_nag'] === 1 ) {
|
841 |
+
update_option( 'sby_rating_notice', 'dismissed', false );
|
842 |
+
$sby_statuses_option['rating_notice_dismissed'] = sby_get_current_time();
|
843 |
+
update_option( 'sby_statuses', $sby_statuses_option, false );
|
844 |
+
|
845 |
+
} elseif ( $_GET['sby_ignore_rating_notice_nag'] === 'later' ) {
|
846 |
+
set_transient( 'feeds_for_youtube_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS );
|
847 |
+
update_option( 'sby_rating_notice', 'pending', false );
|
848 |
+
}
|
849 |
+
}
|
850 |
+
|
851 |
+
if ( isset( $_GET['sby_ignore_new_user_sale_notice'] ) ) {
|
852 |
+
$response = sanitize_text_field( $_GET['sby_ignore_new_user_sale_notice'] );
|
853 |
+
if ( $response === 'always' ) {
|
854 |
+
update_user_meta( $user_id, 'sby_ignore_new_user_sale_notice', 'always' );
|
855 |
+
|
856 |
+
$current_month_number = (int)date('n', sby_get_current_time() );
|
857 |
+
$not_early_in_the_year = ($current_month_number > 5);
|
858 |
+
|
859 |
+
if ( $not_early_in_the_year ) {
|
860 |
+
update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', date( 'Y', sby_get_current_time() ) );
|
861 |
+
}
|
862 |
+
|
863 |
+
}
|
864 |
+
}
|
865 |
+
|
866 |
+
if ( isset( $_GET['sby_ignore_bfcm_sale_notice'] ) ) {
|
867 |
+
$response = sanitize_text_field( $_GET['sby_ignore_bfcm_sale_notice'] );
|
868 |
+
if ( $response === 'always' ) {
|
869 |
+
update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', 'always' );
|
870 |
+
} elseif ( $response === date( 'Y', sby_get_current_time() ) ) {
|
871 |
+
update_user_meta( $user_id, 'sby_ignore_bfcm_sale_notice', date( 'Y', sby_get_current_time() ) );
|
872 |
+
}
|
873 |
+
update_user_meta( $user_id, 'sby_ignore_new_user_sale_notice', 'always' );
|
874 |
+
}
|
875 |
+
|
876 |
+
}
|
877 |
+
add_action( 'admin_init', 'sby_process_nags' );
|
878 |
+
|
879 |
+
|
880 |
+
function sby_lite_dismiss() {
|
881 |
+
if ( ! isset( $_POST['sbspf_nonce'] ) ) return;
|
882 |
+
$nonce = $_POST['sbspf_nonce'];
|
883 |
+
if ( ! wp_verify_nonce( $nonce, 'sbspf_nonce' ) ) {
|
884 |
+
die ( 'You did not do this the right way!' );
|
885 |
+
}
|
886 |
+
|
887 |
+
set_transient( 'youtube_feed_dismiss_lite', 'dismiss', 1 * WEEK_IN_SECONDS );
|
888 |
+
|
889 |
+
die();
|
890 |
+
}
|
891 |
+
add_action( 'wp_ajax_sby_lite_dismiss', 'sby_lite_dismiss' );
|
892 |
+
|
893 |
+
function sby_get_future_date( $month, $year, $week, $day, $direction ) {
|
894 |
+
if ( $direction > 0 ) {
|
895 |
+
$startday = 1;
|
896 |
+
} else {
|
897 |
+
$startday = date( 't', mktime(0, 0, 0, $month, 1, $year ) );
|
898 |
+
}
|
899 |
+
|
900 |
+
$start = mktime( 0, 0, 0, $month, $startday, $year );
|
901 |
+
$weekday = date( 'N', $start );
|
902 |
+
|
903 |
+
$offset = 0;
|
904 |
+
if ( $direction * $day >= $direction * $weekday ) {
|
905 |
+
$offset = -$direction * 7;
|
906 |
+
}
|
907 |
+
|
908 |
+
$offset += $direction * ($week * 7) + ($day - $weekday);
|
909 |
+
return mktime( 0, 0, 0, $month, $startday + $offset, $year );
|
910 |
+
}
|
911 |
+
|
912 |
+
function sby_admin_hide_unrelated_notices() {
|
913 |
+
|
914 |
+
// Bail if we're not on a Sby screen or page.
|
915 |
+
if ( ! sby_is_admin_page() ) {
|
916 |
+
return;
|
917 |
+
}
|
918 |
+
|
919 |
+
// Extra banned classes and callbacks from third-party plugins.
|
920 |
+
$blacklist = array(
|
921 |
+
'classes' => array(),
|
922 |
+
'callbacks' => array(
|
923 |
+
'sbydb_admin_notice', // 'Database for Sby' plugin.
|
924 |
+
),
|
925 |
+
);
|
926 |
+
|
927 |
+
global $wp_filter;
|
928 |
+
|
929 |
+
foreach ( array( 'user_admin_notices', 'admin_notices', 'all_admin_notices' ) as $notices_type ) {
|
930 |
+
if ( empty( $wp_filter[ $notices_type ]->callbacks ) || ! is_array( $wp_filter[ $notices_type ]->callbacks ) ) {
|
931 |
+
continue;
|
932 |
+
}
|
933 |
+
foreach ( $wp_filter[ $notices_type ]->callbacks as $priority => $hooks ) {
|
934 |
+
foreach ( $hooks as $name => $arr ) {
|
935 |
+
if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
|
936 |
+
unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
|
937 |
+
continue;
|
938 |
+
}
|
939 |
+
$class = ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) ? strtolower( get_class( $arr['function'][0] ) ) : '';
|
940 |
+
if (
|
941 |
+
! empty( $class ) &&
|
942 |
+
strpos( $class, 'sby' ) !== false &&
|
943 |
+
! in_array( $class, $blacklist['classes'], true )
|
944 |
+
) {
|
945 |
+
continue;
|
946 |
+
}
|
947 |
+
if (
|
948 |
+
! empty( $name ) && (
|
949 |
+
strpos( $name, 'sby' ) === false ||
|
950 |
+
in_array( $class, $blacklist['classes'], true ) ||
|
951 |
+
in_array( $name, $blacklist['callbacks'], true )
|
952 |
+
)
|
953 |
+
) {
|
954 |
+
unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
|
955 |
+
}
|
956 |
+
}
|
957 |
+
}
|
958 |
+
}
|
959 |
+
}
|
960 |
add_action( 'admin_print_scripts', 'sby_admin_hide_unrelated_notices' );
|
inc/admin/class-sbspf-admin.php
CHANGED
@@ -1,1042 +1,1042 @@
|
|
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' ); ?> <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' ); ?> <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 |
-
if ( $tab === 'configure' ) {
|
905 |
-
do_action( $this->option_name . '_after_configure_save', $updated_options );
|
906 |
-
}
|
907 |
-
|
908 |
-
return $updated_options;
|
909 |
-
}
|
910 |
-
|
911 |
-
|
912 |
-
public function update_options( $new_settings ) {
|
913 |
-
update_option( $this->get_option_name(), $new_settings );
|
914 |
-
$this->settings = $new_settings;
|
915 |
-
}
|
916 |
-
|
917 |
-
public function get_sections( $tab ) {
|
918 |
-
if ( isset( $this->settings_sections[ $tab ] ) ) {
|
919 |
-
return $this->settings_sections[ $tab ];
|
920 |
-
}
|
921 |
-
return array();
|
922 |
-
}
|
923 |
-
|
924 |
-
public function create_menus() {
|
925 |
-
add_menu_page(
|
926 |
-
$this->plugin_name,
|
927 |
-
$this->plugin_name,
|
928 |
-
$this->capability,
|
929 |
-
$this->slug,
|
930 |
-
array( $this, 'create_options_page' ),
|
931 |
-
$this->icon,
|
932 |
-
$this->position
|
933 |
-
);
|
934 |
-
|
935 |
-
foreach ( $this->tabs as $tab ) {
|
936 |
-
if ( $tab['slug'] !== 'configure' ) {
|
937 |
-
$title = isset( $tab['title'] ) ? $tab['title'] : '';
|
938 |
-
$capability = isset( $tab['capability'] ) ? $tab['capability'] : 'manage_options';
|
939 |
-
$slug = isset( $tab['slug'] ) ? $tab['slug'] : '';
|
940 |
-
$callback = isset( $tab['callback'] ) ? $tab['callback'] : array( $this, 'create_options_page' );
|
941 |
-
|
942 |
-
add_submenu_page(
|
943 |
-
$this->slug,
|
944 |
-
$title,
|
945 |
-
$title,
|
946 |
-
$capability,
|
947 |
-
$this->slug . '_' . $slug,
|
948 |
-
$callback
|
949 |
-
);
|
950 |
-
}
|
951 |
-
}
|
952 |
-
|
953 |
-
$this->after_create_menues();
|
954 |
-
}
|
955 |
-
|
956 |
-
public function after_create_menues() {
|
957 |
-
|
958 |
-
}
|
959 |
-
|
960 |
-
public function set_active_tab( $active_tab ) {
|
961 |
-
foreach ( $this->tabs as $tab ) {
|
962 |
-
if ( $tab['slug'] === $active_tab ) {
|
963 |
-
$this->active_tab = $tab['slug'];
|
964 |
-
}
|
965 |
-
}
|
966 |
-
}
|
967 |
-
|
968 |
-
public function get_tabs() {
|
969 |
-
return $this->tabs;
|
970 |
-
}
|
971 |
-
|
972 |
-
public function get_active_tab() {
|
973 |
-
return $this->active_tab;
|
974 |
-
}
|
975 |
-
|
976 |
-
public function get_slug() {
|
977 |
-
return $this->slug;
|
978 |
-
}
|
979 |
-
|
980 |
-
public function get_plugin_name() {
|
981 |
-
return $this->plugin_name;
|
982 |
-
}
|
983 |
-
|
984 |
-
public function get_path( $view ) {
|
985 |
-
return trailingslashit( $this->base_path ) . $view . '.php';
|
986 |
-
}
|
987 |
-
|
988 |
-
public function create_options_page() {
|
989 |
-
require_once trailingslashit( $this->base_path ) . 'main.php';
|
990 |
-
}
|
991 |
-
|
992 |
-
public function next_step() {
|
993 |
-
$return = array();
|
994 |
-
$i = 0;
|
995 |
-
foreach ( $this->tabs as $tab ) {
|
996 |
-
if ( $this->active_tab === $tab['slug'] && isset( $tab['next_step_instructions'] ) ) {
|
997 |
-
$next_tab_slug = isset( $this->tabs[ $i + 1 ]['slug'] ) ? $this->tabs[ $i + 1 ]['slug'] : $tab['slug'];
|
998 |
-
$return = array(
|
999 |
-
'instructions' => $tab['next_step_instructions'],
|
1000 |
-
'next_tab' => $next_tab_slug
|
1001 |
-
);
|
1002 |
-
}
|
1003 |
-
$i++;
|
1004 |
-
}
|
1005 |
-
return $return;
|
1006 |
-
}
|
1007 |
-
|
1008 |
-
public function get_connected_accounts() {
|
1009 |
-
global $sbspf_settings;
|
1010 |
-
|
1011 |
-
if ( isset( $sbspf_settings['connected_accounts'] ) ) {
|
1012 |
-
return $sbspf_settings['connected_accounts'];
|
1013 |
-
}
|
1014 |
-
return array();
|
1015 |
-
}
|
1016 |
-
|
1017 |
-
public static function connect_account( $args ) {
|
1018 |
-
global $sbspf_settings;
|
1019 |
-
|
1020 |
-
// do connection
|
1021 |
-
|
1022 |
-
// random fake data
|
1023 |
-
$account_id = time();
|
1024 |
-
|
1025 |
-
$sbspf_settings['connected_accounts'][ $account_id ] = array(
|
1026 |
-
'access_token' => 'at_' . str_shuffle( $account_id ),
|
1027 |
-
'channel_id' => $account_id,
|
1028 |
-
'username' => 'test' . $account_id,
|
1029 |
-
'is_valid' => true,
|
1030 |
-
'last_checked' => time(),
|
1031 |
-
'profile_picture' => $args['profile_picture']
|
1032 |
-
);
|
1033 |
-
|
1034 |
-
update_option( 'sbspf_settings', $sbspf_settings );
|
1035 |
-
|
1036 |
-
return $sbspf_settings['connected_accounts'][ $account_id ];
|
1037 |
-
}
|
1038 |
-
|
1039 |
-
public function default_tooltip_text() {
|
1040 |
-
return '<span class="screen-reader-text">' . __( 'What does this mean?', $this->vars->text_domain() ) . '</span>' . sby_admin_icon( 'question-circle' );
|
1041 |
-
}
|
1042 |
-
}
|
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' ); ?> <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' ); ?> <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 |
+
if ( $tab === 'configure' ) {
|
905 |
+
do_action( $this->option_name . '_after_configure_save', $updated_options );
|
906 |
+
}
|
907 |
+
|
908 |
+
return $updated_options;
|
909 |
+
}
|
910 |
+
|
911 |
+
|
912 |
+
public function update_options( $new_settings ) {
|
913 |
+
update_option( $this->get_option_name(), $new_settings );
|
914 |
+
$this->settings = $new_settings;
|
915 |
+
}
|
916 |
+
|
917 |
+
public function get_sections( $tab ) {
|
918 |
+
if ( isset( $this->settings_sections[ $tab ] ) ) {
|
919 |
+
return $this->settings_sections[ $tab ];
|
920 |
+
}
|
921 |
+
return array();
|
922 |
+
}
|
923 |
+
|
924 |
+
public function create_menus() {
|
925 |
+
add_menu_page(
|
926 |
+
$this->plugin_name,
|
927 |
+
$this->plugin_name,
|
928 |
+
$this->capability,
|
929 |
+
$this->slug,
|
930 |
+
array( $this, 'create_options_page' ),
|
931 |
+
$this->icon,
|
932 |
+
$this->position
|
933 |
+
);
|
934 |
+
|
935 |
+
foreach ( $this->tabs as $tab ) {
|
936 |
+
if ( $tab['slug'] !== 'configure' ) {
|
937 |
+
$title = isset( $tab['title'] ) ? $tab['title'] : '';
|
938 |
+
$capability = isset( $tab['capability'] ) ? $tab['capability'] : 'manage_options';
|
939 |
+
$slug = isset( $tab['slug'] ) ? $tab['slug'] : '';
|
940 |
+
$callback = isset( $tab['callback'] ) ? $tab['callback'] : array( $this, 'create_options_page' );
|
941 |
+
|
942 |
+
add_submenu_page(
|
943 |
+
$this->slug,
|
944 |
+
$title,
|
945 |
+
$title,
|
946 |
+
$capability,
|
947 |
+
$this->slug . '_' . $slug,
|
948 |
+
$callback
|
949 |
+
);
|
950 |
+
}
|
951 |
+
}
|
952 |
+
|
953 |
+
$this->after_create_menues();
|
954 |
+
}
|
955 |
+
|
956 |
+
public function after_create_menues() {
|
957 |
+
|
958 |
+
}
|
959 |
+
|
960 |
+
public function set_active_tab( $active_tab ) {
|
961 |
+
foreach ( $this->tabs as $tab ) {
|
962 |
+
if ( $tab['slug'] === $active_tab ) {
|
963 |
+
$this->active_tab = $tab['slug'];
|
964 |
+
}
|
965 |
+
}
|
966 |
+
}
|
967 |
+
|
968 |
+
public function get_tabs() {
|
969 |
+
return $this->tabs;
|
970 |
+
}
|
971 |
+
|
972 |
+
public function get_active_tab() {
|
973 |
+
return $this->active_tab;
|
974 |
+
}
|
975 |
+
|
976 |
+
public function get_slug() {
|
977 |
+
return $this->slug;
|
978 |
+
}
|
979 |
+
|
980 |
+
public function get_plugin_name() {
|
981 |
+
return $this->plugin_name;
|
982 |
+
}
|
983 |
+
|
984 |
+
public function get_path( $view ) {
|
985 |
+
return trailingslashit( $this->base_path ) . $view . '.php';
|
986 |
+
}
|
987 |
+
|
988 |
+
public function create_options_page() {
|
989 |
+
require_once trailingslashit( $this->base_path ) . 'main.php';
|
990 |
+
}
|
991 |
+
|
992 |
+
public function next_step() {
|
993 |
+
$return = array();
|
994 |
+
$i = 0;
|
995 |
+
foreach ( $this->tabs as $tab ) {
|
996 |
+
if ( $this->active_tab === $tab['slug'] && isset( $tab['next_step_instructions'] ) ) {
|
997 |
+
$next_tab_slug = isset( $this->tabs[ $i + 1 ]['slug'] ) ? $this->tabs[ $i + 1 ]['slug'] : $tab['slug'];
|
998 |
+
$return = array(
|
999 |
+
'instructions' => $tab['next_step_instructions'],
|
1000 |
+
'next_tab' => $next_tab_slug
|
1001 |
+
);
|
1002 |
+
}
|
1003 |
+
$i++;
|
1004 |
+
}
|
1005 |
+
return $return;
|
1006 |
+
}
|
1007 |
+
|
1008 |
+
public function get_connected_accounts() {
|
1009 |
+
global $sbspf_settings;
|
1010 |
+
|
1011 |
+
if ( isset( $sbspf_settings['connected_accounts'] ) ) {
|
1012 |
+
return $sbspf_settings['connected_accounts'];
|
1013 |
+
}
|
1014 |
+
return array();
|
1015 |
+
}
|
1016 |
+
|
1017 |
+
public static function connect_account( $args ) {
|
1018 |
+
global $sbspf_settings;
|
1019 |
+
|
1020 |
+
// do connection
|
1021 |
+
|
1022 |
+
// random fake data
|
1023 |
+
$account_id = time();
|
1024 |
+
|
1025 |
+
$sbspf_settings['connected_accounts'][ $account_id ] = array(
|
1026 |
+
'access_token' => 'at_' . str_shuffle( $account_id ),
|
1027 |
+
'channel_id' => $account_id,
|
1028 |
+
'username' => 'test' . $account_id,
|
1029 |
+
'is_valid' => true,
|
1030 |
+
'last_checked' => time(),
|
1031 |
+
'profile_picture' => $args['profile_picture']
|
1032 |
+
);
|
1033 |
+
|
1034 |
+
update_option( 'sbspf_settings', $sbspf_settings );
|
1035 |
+
|
1036 |
+
return $sbspf_settings['connected_accounts'][ $account_id ];
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
public function default_tooltip_text() {
|
1040 |
+
return '<span class="screen-reader-text">' . __( 'What does this mean?', $this->vars->text_domain() ) . '</span>' . sby_admin_icon( 'question-circle' );
|
1041 |
+
}
|
1042 |
+
}
|
inc/admin/class-sby-admin.php
CHANGED
@@ -1,945 +1,945 @@
|
|
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' => 'ajaxtheme',
|
808 |
-
'section' => 'sbspf_advanced',
|
809 |
-
'callback' => 'checkbox',
|
810 |
-
'title' => __( 'Are you using an AJAX theme?', $text_domain ),
|
811 |
-
'default' => false,
|
812 |
-
'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 )
|
813 |
-
);
|
814 |
-
$this->add_settings_field( $args );
|
815 |
-
|
816 |
-
$args = array(
|
817 |
-
'name' => 'customtemplates',
|
818 |
-
'section' => 'sbspf_advanced',
|
819 |
-
'callback' => 'checkbox',
|
820 |
-
'title' => __( 'Enable Custom Templates', $text_domain ),
|
821 |
-
'default' => false,
|
822 |
-
'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 )
|
823 |
-
);
|
824 |
-
$this->add_settings_field( $args );
|
825 |
-
|
826 |
-
$args = array(
|
827 |
-
'name' => 'eagerload',
|
828 |
-
'section' => 'sbspf_advanced',
|
829 |
-
'callback' => 'checkbox',
|
830 |
-
'title' => __( 'Load Iframes on Page Load', $text_domain ),
|
831 |
-
'default' => false,
|
832 |
-
'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 )
|
833 |
-
);
|
834 |
-
$this->add_settings_field( $args );
|
835 |
-
|
836 |
-
}
|
837 |
-
|
838 |
-
public function cache( $args ) {
|
839 |
-
$social_network = $this->vars->social_network();
|
840 |
-
$type_selected = isset( $this->settings['caching_type'] ) ? $this->settings['caching_type'] : 'page';
|
841 |
-
$caching_time = isset( $this->settings['caching_time'] ) ? $this->settings['caching_time'] : 1;
|
842 |
-
$cache_time_unit_selected = isset( $this->settings['cache_time_unit'] ) ? $this->settings['cache_time_unit'] : 'hours';
|
843 |
-
$cache_cron_interval_selected = isset( $this->settings['cache_cron_interval'] ) ? $this->settings['cache_cron_interval'] : '';
|
844 |
-
$cache_cron_time = isset( $this->settings['cache_cron_time'] ) ? $this->settings['cache_cron_time'] : '';
|
845 |
-
$cache_cron_am_pm = isset( $this->settings['cache_cron_am_pm'] ) ? $this->settings['cache_cron_am_pm'] : '';
|
846 |
-
|
847 |
-
?>
|
848 |
-
<div class="sbspf_cache_settings_wrap">
|
849 |
-
<div class="sbspf_row">
|
850 |
-
<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'?>>
|
851 |
-
<label class="sbspf_radio_label" for="sbspf_caching_type_page"><?php _e ( 'When the page loads', $this->vars->text_domain() ); ?></label>
|
852 |
-
<a class="sbspf_tooltip_link" href="JavaScript:void(0);" style="position: relative; top: 2px;"><?php echo $this->default_tooltip_text() ?></a>
|
853 |
-
<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>
|
854 |
-
<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>
|
855 |
-
<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 ); ?>
|
856 |
-
</p>
|
857 |
-
</div>
|
858 |
-
<div class="sbspf_row sbspf-caching-page-options" style="display: none;">
|
859 |
-
<?php _e ( 'Every', $this->vars->text_domain() ); ?>:
|
860 |
-
<input name="<?php echo $this->option_name.'[caching_time]'; ?>" type="text" value="<?php echo esc_attr( $caching_time ); ?>" size="4">
|
861 |
-
<select name="<?php echo $this->option_name.'[caching_time_unit]'; ?>">
|
862 |
-
<option value="minutes"<?php if ( $cache_time_unit_selected === 'minutes' ) echo ' selected'?>><?php _e ( 'Minutes', $this->vars->text_domain() ); ?></option>
|
863 |
-
<option value="hours"<?php if ( $cache_time_unit_selected === 'hours' ) echo ' selected'?>><?php _e ( 'Hours', $this->vars->text_domain() ); ?></option>
|
864 |
-
<option value="days"<?php if ( $cache_time_unit_selected === 'days' ) echo ' selected'?>><?php _e ( 'Days', $this->vars->text_domain() ); ?></option>
|
865 |
-
</select>
|
866 |
-
<a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php _e ( 'What does this mean?', $this->vars->text_domain() ); ?></a>
|
867 |
-
<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>
|
868 |
-
</div>
|
869 |
-
|
870 |
-
<div class="sbspf_row">
|
871 |
-
<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'?>>
|
872 |
-
<label class="sbspf_radio_label" for="sbspf_caching_type_cron"><?php _e ( 'In the background', $this->vars->text_domain() ); ?></label>
|
873 |
-
</div>
|
874 |
-
<div class="sbspf_row sbspf-caching-cron-options" style="display: block;">
|
875 |
-
|
876 |
-
<select name="<?php echo $this->option_name.'[cache_cron_interval]'; ?>" id="sbspf_cache_cron_interval">
|
877 |
-
<option value="30mins"<?php if ( $cache_cron_interval_selected === '30mins' ) echo ' selected'?>><?php _e ( 'Every 30 minutes', $this->vars->text_domain() ); ?></option>
|
878 |
-
<option value="1hour"<?php if ( $cache_cron_interval_selected === '1hour' ) echo ' selected'?>><?php _e ( 'Every hour', $this->vars->text_domain() ); ?></option>
|
879 |
-
<option value="12hours"<?php if ( $cache_cron_interval_selected === '12hours' ) echo ' selected'?>><?php _e ( 'Every 12 hours', $this->vars->text_domain() ); ?></option>
|
880 |
-
<option value="24hours"<?php if ( $cache_cron_interval_selected === '24hours' ) echo ' selected'?>><?php _e ( 'Every 24 hours', $this->vars->text_domain() ); ?></option>
|
881 |
-
</select>
|
882 |
-
|
883 |
-
<div id="sbspf-caching-time-settings" style="">
|
884 |
-
<?php _e ( 'at', $this->vars->text_domain() ); ?>
|
885 |
-
<select name="<?php echo $this->option_name.'[cache_cron_time]'; ?>" style="width: 80px">
|
886 |
-
<option value="1"<?php if ( (int)$cache_cron_time === 1 ) echo ' selected'?>>1:00</option>
|
887 |
-
<option value="2"<?php if ( (int)$cache_cron_time === 2 ) echo ' selected'?>>2:00</option>
|
888 |
-
<option value="3"<?php if ( (int)$cache_cron_time === 3 ) echo ' selected'?>>3:00</option>
|
889 |
-
<option value="4"<?php if ( (int)$cache_cron_time === 4 ) echo ' selected'?>>4:00</option>
|
890 |
-
<option value="5"<?php if ( (int)$cache_cron_time === 5 ) echo ' selected'?>>5:00</option>
|
891 |
-
<option value="6"<?php if ( (int)$cache_cron_time === 6 ) echo ' selected'?>>6:00</option>
|
892 |
-
<option value="7"<?php if ( (int)$cache_cron_time === 7 ) echo ' selected'?>>7:00</option>
|
893 |
-
<option value="8"<?php if ( (int)$cache_cron_time === 8 ) echo ' selected'?>>8:00</option>
|
894 |
-
<option value="9"<?php if ( (int)$cache_cron_time === 9 ) echo ' selected'?>>9:00</option>
|
895 |
-
<option value="10"<?php if ( (int)$cache_cron_time === 10 ) echo ' selected'?>>10:00</option>
|
896 |
-
<option value="11"<?php if ( (int)$cache_cron_time === 11 ) echo ' selected'?>>11:00</option>
|
897 |
-
<option value="0"<?php if ( (int)$cache_cron_time === 0 ) echo ' selected'?>>12:00</option>
|
898 |
-
</select>
|
899 |
-
|
900 |
-
<select name="<?php echo $this->option_name.'[cache_cron_am_pm]'; ?>" style="width: 50px">
|
901 |
-
<option value="am"<?php if ( $cache_cron_am_pm === 'am' ) echo ' selected'?>><?php _e ( 'AM', $this->vars->text_domain() ); ?></option>
|
902 |
-
<option value="pm"<?php if ( $cache_cron_am_pm === 'pm' ) echo ' selected'?>><?php _e ( 'PM', $this->vars->text_domain() ); ?></option>
|
903 |
-
</select>
|
904 |
-
</div>
|
905 |
-
|
906 |
-
<?php
|
907 |
-
if ( wp_next_scheduled( 'sbspf_feed_update' ) ) {
|
908 |
-
$time_format = get_option( 'time_format' );
|
909 |
-
if ( ! $time_format ) {
|
910 |
-
$time_format = 'g:i a';
|
911 |
-
}
|
912 |
-
//
|
913 |
-
$schedule = wp_get_schedule( 'sbspf_feed_update' );
|
914 |
-
if ( $schedule == '30mins' ) $schedule = __( 'every 30 minutes', $this->vars->text_domain() );
|
915 |
-
if ( $schedule == 'twicedaily' ) $schedule = __( 'every 12 hours', $this->vars->text_domain() );
|
916 |
-
$sbspf_next_cron_event = wp_next_scheduled( 'sbspf_feed_update' );
|
917 |
-
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>';
|
918 |
-
} else {
|
919 |
-
echo '<p style="font-size: 11px; color: #666;">' . __( 'Nothing currently scheduled', $this->vars->text_domain() ) . '</p>';
|
920 |
-
}
|
921 |
-
?>
|
922 |
-
</div>
|
923 |
-
</div>
|
924 |
-
<?php
|
925 |
-
}
|
926 |
-
|
927 |
-
public function get_connected_accounts() {
|
928 |
-
global $sby_settings;
|
929 |
-
|
930 |
-
if ( isset( $sby_settings['connected_accounts'] ) ) {
|
931 |
-
return $sby_settings['connected_accounts'];
|
932 |
-
}
|
933 |
-
return array();
|
934 |
-
}
|
935 |
-
|
936 |
-
public function access_token_listener() {
|
937 |
-
if ( isset( $_GET['page'] ) && $_GET['page'] === SBY_SLUG && isset( $_GET['sby_access_token'] ) ) {
|
938 |
-
sby_attempt_connection();
|
939 |
-
}
|
940 |
-
}
|
941 |
-
|
942 |
-
public static function connect_account( $args ) {
|
943 |
-
sby_update_or_connect_account( $args );
|
944 |
-
}
|
945 |
-
}
|
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' => 'ajaxtheme',
|
808 |
+
'section' => 'sbspf_advanced',
|
809 |
+
'callback' => 'checkbox',
|
810 |
+
'title' => __( 'Are you using an AJAX theme?', $text_domain ),
|
811 |
+
'default' => false,
|
812 |
+
'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 )
|
813 |
+
);
|
814 |
+
$this->add_settings_field( $args );
|
815 |
+
|
816 |
+
$args = array(
|
817 |
+
'name' => 'customtemplates',
|
818 |
+
'section' => 'sbspf_advanced',
|
819 |
+
'callback' => 'checkbox',
|
820 |
+
'title' => __( 'Enable Custom Templates', $text_domain ),
|
821 |
+
'default' => false,
|
822 |
+
'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 )
|
823 |
+
);
|
824 |
+
$this->add_settings_field( $args );
|
825 |
+
|
826 |
+
$args = array(
|
827 |
+
'name' => 'eagerload',
|
828 |
+
'section' => 'sbspf_advanced',
|
829 |
+
'callback' => 'checkbox',
|
830 |
+
'title' => __( 'Load Iframes on Page Load', $text_domain ),
|
831 |
+
'default' => false,
|
832 |
+
'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 )
|
833 |
+
);
|
834 |
+
$this->add_settings_field( $args );
|
835 |
+
|
836 |
+
}
|
837 |
+
|
838 |
+
public function cache( $args ) {
|
839 |
+
$social_network = $this->vars->social_network();
|
840 |
+
$type_selected = isset( $this->settings['caching_type'] ) ? $this->settings['caching_type'] : 'page';
|
841 |
+
$caching_time = isset( $this->settings['caching_time'] ) ? $this->settings['caching_time'] : 1;
|
842 |
+
$cache_time_unit_selected = isset( $this->settings['cache_time_unit'] ) ? $this->settings['cache_time_unit'] : 'hours';
|
843 |
+
$cache_cron_interval_selected = isset( $this->settings['cache_cron_interval'] ) ? $this->settings['cache_cron_interval'] : '';
|
844 |
+
$cache_cron_time = isset( $this->settings['cache_cron_time'] ) ? $this->settings['cache_cron_time'] : '';
|
845 |
+
$cache_cron_am_pm = isset( $this->settings['cache_cron_am_pm'] ) ? $this->settings['cache_cron_am_pm'] : '';
|
846 |
+
|
847 |
+
?>
|
848 |
+
<div class="sbspf_cache_settings_wrap">
|
849 |
+
<div class="sbspf_row">
|
850 |
+
<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'?>>
|
851 |
+
<label class="sbspf_radio_label" for="sbspf_caching_type_page"><?php _e ( 'When the page loads', $this->vars->text_domain() ); ?></label>
|
852 |
+
<a class="sbspf_tooltip_link" href="JavaScript:void(0);" style="position: relative; top: 2px;"><?php echo $this->default_tooltip_text() ?></a>
|
853 |
+
<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>
|
854 |
+
<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>
|
855 |
+
<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 ); ?>
|
856 |
+
</p>
|
857 |
+
</div>
|
858 |
+
<div class="sbspf_row sbspf-caching-page-options" style="display: none;">
|
859 |
+
<?php _e ( 'Every', $this->vars->text_domain() ); ?>:
|
860 |
+
<input name="<?php echo $this->option_name.'[caching_time]'; ?>" type="text" value="<?php echo esc_attr( $caching_time ); ?>" size="4">
|
861 |
+
<select name="<?php echo $this->option_name.'[caching_time_unit]'; ?>">
|
862 |
+
<option value="minutes"<?php if ( $cache_time_unit_selected === 'minutes' ) echo ' selected'?>><?php _e ( 'Minutes', $this->vars->text_domain() ); ?></option>
|
863 |
+
<option value="hours"<?php if ( $cache_time_unit_selected === 'hours' ) echo ' selected'?>><?php _e ( 'Hours', $this->vars->text_domain() ); ?></option>
|
864 |
+
<option value="days"<?php if ( $cache_time_unit_selected === 'days' ) echo ' selected'?>><?php _e ( 'Days', $this->vars->text_domain() ); ?></option>
|
865 |
+
</select>
|
866 |
+
<a class="sbspf_tooltip_link" href="JavaScript:void(0);"><?php _e ( 'What does this mean?', $this->vars->text_domain() ); ?></a>
|
867 |
+
<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>
|
868 |
+
</div>
|
869 |
+
|
870 |
+
<div class="sbspf_row">
|
871 |
+
<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'?>>
|
872 |
+
<label class="sbspf_radio_label" for="sbspf_caching_type_cron"><?php _e ( 'In the background', $this->vars->text_domain() ); ?></label>
|
873 |
+
</div>
|
874 |
+
<div class="sbspf_row sbspf-caching-cron-options" style="display: block;">
|
875 |
+
|
876 |
+
<select name="<?php echo $this->option_name.'[cache_cron_interval]'; ?>" id="sbspf_cache_cron_interval">
|
877 |
+
<option value="30mins"<?php if ( $cache_cron_interval_selected === '30mins' ) echo ' selected'?>><?php _e ( 'Every 30 minutes', $this->vars->text_domain() ); ?></option>
|
878 |
+
<option value="1hour"<?php if ( $cache_cron_interval_selected === '1hour' ) echo ' selected'?>><?php _e ( 'Every hour', $this->vars->text_domain() ); ?></option>
|
879 |
+
<option value="12hours"<?php if ( $cache_cron_interval_selected === '12hours' ) echo ' selected'?>><?php _e ( 'Every 12 hours', $this->vars->text_domain() ); ?></option>
|
880 |
+
<option value="24hours"<?php if ( $cache_cron_interval_selected === '24hours' ) echo ' selected'?>><?php _e ( 'Every 24 hours', $this->vars->text_domain() ); ?></option>
|
881 |
+
</select>
|
882 |
+
|
883 |
+
<div id="sbspf-caching-time-settings" style="">
|
884 |
+
<?php _e ( 'at', $this->vars->text_domain() ); ?>
|
885 |
+
<select name="<?php echo $this->option_name.'[cache_cron_time]'; ?>" style="width: 80px">
|
886 |
+
<option value="1"<?php if ( (int)$cache_cron_time === 1 ) echo ' selected'?>>1:00</option>
|
887 |
+
<option value="2"<?php if ( (int)$cache_cron_time === 2 ) echo ' selected'?>>2:00</option>
|
888 |
+
<option value="3"<?php if ( (int)$cache_cron_time === 3 ) echo ' selected'?>>3:00</option>
|
889 |
+
<option value="4"<?php if ( (int)$cache_cron_time === 4 ) echo ' selected'?>>4:00</option>
|
890 |
+
<option value="5"<?php if ( (int)$cache_cron_time === 5 ) echo ' selected'?>>5:00</option>
|
891 |
+
<option value="6"<?php if ( (int)$cache_cron_time === 6 ) echo ' selected'?>>6:00</option>
|
892 |
+
<option value="7"<?php if ( (int)$cache_cron_time === 7 ) echo ' selected'?>>7:00</option>
|
893 |
+
<option value="8"<?php if ( (int)$cache_cron_time === 8 ) echo ' selected'?>>8:00</option>
|
894 |
+
<option value="9"<?php if ( (int)$cache_cron_time === 9 ) echo ' selected'?>>9:00</option>
|
895 |
+
<option value="10"<?php if ( (int)$cache_cron_time === 10 ) echo ' selected'?>>10:00</option>
|
896 |
+
<option value="11"<?php if ( (int)$cache_cron_time === 11 ) echo ' selected'?>>11:00</option>
|
897 |
+
<option value="0"<?php if ( (int)$cache_cron_time === 0 ) echo ' selected'?>>12:00</option>
|
898 |
+
</select>
|
899 |
+
|
900 |
+
<select name="<?php echo $this->option_name.'[cache_cron_am_pm]'; ?>" style="width: 50px">
|
901 |
+
<option value="am"<?php if ( $cache_cron_am_pm === 'am' ) echo ' selected'?>><?php _e ( 'AM', $this->vars->text_domain() ); ?></option>
|
902 |
+
<option value="pm"<?php if ( $cache_cron_am_pm === 'pm' ) echo ' selected'?>><?php _e ( 'PM', $this->vars->text_domain() ); ?></option>
|
903 |
+
</select>
|
904 |
+
</div>
|
905 |
+
|
906 |
+
<?php
|
907 |
+
if ( wp_next_scheduled( 'sbspf_feed_update' ) ) {
|
908 |
+
$time_format = get_option( 'time_format' );
|
909 |
+
if ( ! $time_format ) {
|
910 |
+
$time_format = 'g:i a';
|
911 |
+
}
|
912 |
+
//
|
913 |
+
$schedule = wp_get_schedule( 'sbspf_feed_update' );
|
914 |
+
if ( $schedule == '30mins' ) $schedule = __( 'every 30 minutes', $this->vars->text_domain() );
|
915 |
+
if ( $schedule == 'twicedaily' ) $schedule = __( 'every 12 hours', $this->vars->text_domain() );
|
916 |
+
$sbspf_next_cron_event = wp_next_scheduled( 'sbspf_feed_update' );
|
917 |
+
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>';
|
918 |
+
} else {
|
919 |
+
echo '<p style="font-size: 11px; color: #666;">' . __( 'Nothing currently scheduled', $this->vars->text_domain() ) . '</p>';
|
920 |
+
}
|
921 |
+
?>
|
922 |
+
</div>
|
923 |
+
</div>
|
924 |
+
<?php
|
925 |
+
}
|
926 |
+
|
927 |
+
public function get_connected_accounts() {
|
928 |
+
global $sby_settings;
|
929 |
+
|
930 |
+
if ( isset( $sby_settings['connected_accounts'] ) ) {
|
931 |
+
return $sby_settings['connected_accounts'];
|
932 |
+
}
|
933 |
+
return array();
|
934 |
+
}
|
935 |
+
|
936 |
+
public function access_token_listener() {
|
937 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] === SBY_SLUG && isset( $_GET['sby_access_token'] ) ) {
|
938 |
+
sby_attempt_connection();
|
939 |
+
}
|
940 |
+
}
|
941 |
+
|
942 |
+
public static function connect_account( $args ) {
|
943 |
+
sby_update_or_connect_account( $args );
|
944 |
+
}
|
945 |
+
}
|
inc/admin/templates/configure.php
CHANGED
@@ -1,38 +1,38 @@
|
|
1 |
-
<h3><?php _e( 'Configure', $text_domain ); ?></h3>
|
2 |
-
<div id="sbspf_config">
|
3 |
-
<a href="<?php echo $oauth_processor_url . admin_url( 'admin.php?page=' . esc_attr( $slug ) ); ?>" id="sbspf_get_token"><?php echo sby_icon( $slug, 'sbspf_small_svg' ); ?> <?php echo sprintf( __( '
|
4 |
-
<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>
|
5 |
-
</div>
|
6 |
-
|
7 |
-
<form method="post" action="">
|
8 |
-
<?php
|
9 |
-
$settings = $this->settings;
|
10 |
-
$api_key = isset( $settings['api_key'] ) ? $settings['api_key'] : '';
|
11 |
-
?>
|
12 |
-
<table class="form-table sbspf_own_credentials_wrap" role="presentation">
|
13 |
-
<tbody>
|
14 |
-
<tr>
|
15 |
-
<th scope="row">
|
16 |
-
<label for="sby_app_id"><?php _e( "API Key", $text_domain ); ?></label>
|
17 |
-
<p class="sbspf_aside sbspf_red"><?php _e( "Recommended", $text_domain ); ?></p>
|
18 |
-
</th>
|
19 |
-
<td>
|
20 |
-
<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" />
|
21 |
-
<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>
|
22 |
-
</td>
|
23 |
-
</tr>
|
24 |
-
|
25 |
-
</tbody>
|
26 |
-
</table>
|
27 |
-
<?php $this->hidden_fields_for_tab( 'configure' ); ?>
|
28 |
-
<?php include_once $this->get_path( 'connected-accounts' ); ?>
|
29 |
-
|
30 |
-
<?php foreach ( $this->get_sections( 'configure' ) as $section ) : ?>
|
31 |
-
|
32 |
-
<?php do_settings_sections( $section['id'] ); // matches the section name ?>
|
33 |
-
<?php if ( $section['save_after'] ) : ?>
|
34 |
-
<p class="submit"><input class="button-primary" type="submit" name="save" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p>
|
35 |
-
<?php endif; ?>
|
36 |
-
<hr>
|
37 |
-
<?php endforeach; ?>
|
38 |
</form>
|
1 |
+
<h3><?php _e( 'Configure', $text_domain ); ?></h3>
|
2 |
+
<div id="sbspf_config">
|
3 |
+
<a href="<?php echo $oauth_processor_url . admin_url( 'admin.php?page=' . esc_attr( $slug ) ); ?>" id="sbspf_get_token"><?php echo sby_icon( $slug, 'sbspf_small_svg' ); ?> <?php echo sprintf( __( 'Connect to %s to Create a Feed', $text_domain ), $social_network ); ?></a>
|
4 |
+
<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>
|
5 |
+
</div>
|
6 |
+
|
7 |
+
<form method="post" action="">
|
8 |
+
<?php
|
9 |
+
$settings = $this->settings;
|
10 |
+
$api_key = isset( $settings['api_key'] ) ? $settings['api_key'] : '';
|
11 |
+
?>
|
12 |
+
<table class="form-table sbspf_own_credentials_wrap" role="presentation">
|
13 |
+
<tbody>
|
14 |
+
<tr>
|
15 |
+
<th scope="row">
|
16 |
+
<label for="sby_app_id"><?php _e( "API Key", $text_domain ); ?></label>
|
17 |
+
<p class="sbspf_aside sbspf_red"><?php _e( "Recommended", $text_domain ); ?></p>
|
18 |
+
</th>
|
19 |
+
<td>
|
20 |
+
<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" />
|
21 |
+
<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>
|
22 |
+
</td>
|
23 |
+
</tr>
|
24 |
+
|
25 |
+
</tbody>
|
26 |
+
</table>
|
27 |
+
<?php $this->hidden_fields_for_tab( 'configure' ); ?>
|
28 |
+
<?php include_once $this->get_path( 'connected-accounts' ); ?>
|
29 |
+
|
30 |
+
<?php foreach ( $this->get_sections( 'configure' ) as $section ) : ?>
|
31 |
+
|
32 |
+
<?php do_settings_sections( $section['id'] ); // matches the section name ?>
|
33 |
+
<?php if ( $section['save_after'] ) : ?>
|
34 |
+
<p class="submit"><input class="button-primary" type="submit" name="save" value="<?php esc_attr_e( 'Save Changes' ); ?>" /></p>
|
35 |
+
<?php endif; ?>
|
36 |
+
<hr>
|
37 |
+
<?php endforeach; ?>
|
38 |
</form>
|
inc/admin/templates/connected-accounts.php
CHANGED
@@ -1,44 +1,42 @@
|
|
1 |
-
<?php
|
2 |
-
$connected_accounts = $this->get_connected_accounts();
|
3 |
-
$connected_channels = array();
|
4 |
-
|
5 |
-
|
6 |
-
<
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
<
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
$
|
21 |
-
$
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
$
|
27 |
-
$
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
<
|
35 |
-
|
36 |
-
<input name="
|
37 |
-
<
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
</table>
|
44 |
-
<?php endif; ?>
|
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 |
+
<input name="sbspf_manual_rt" id="sbspf_manual_rt" 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 Refresh Token', $text_domain );?>" />
|
37 |
+
<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>
|
38 |
+
</div>
|
39 |
+
</td>
|
40 |
+
</tr>
|
41 |
+
</tbody>
|
42 |
+
</table>
|
|
|
|
inc/admin/templates/customize.php
CHANGED
@@ -1,22 +1,22 @@
|
|
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&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 |
+
|
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&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>
|
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' ); ?> <?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' ); ?> <?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,79 +1,79 @@
|
|
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 |
-
<h1><?php echo esc_html( $plugin_name ); ?></h1>
|
41 |
-
|
42 |
-
<!-- Display the tabs along with styling for the 'active' tab -->
|
43 |
-
<h2 class="nav-tab-wrapper">
|
44 |
-
<?php
|
45 |
-
$i = 1;
|
46 |
-
foreach ( $tabs as $tab ) :
|
47 |
-
$title = isset( $tab['numbered_tab'] ) && ! $tab['numbered_tab'] ? __( $tab['title'], 'feeds-for-youtube' ) : $i . '. ' . __( $tab['title'], 'feeds-for-youtube' );
|
48 |
-
?>
|
49 |
-
<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>
|
50 |
-
<?php
|
51 |
-
$i ++;
|
52 |
-
endforeach; ?>
|
53 |
-
</h2>
|
54 |
-
<?php
|
55 |
-
settings_errors();
|
56 |
-
|
57 |
-
include $this->get_path( $active_tab );
|
58 |
-
|
59 |
-
$next_step = $this->next_step();
|
60 |
-
if ( ! empty( $next_step ) ) : ?>
|
61 |
-
<p class="sbspf_footer_help">
|
62 |
-
<?php echo sby_admin_icon( 'chevron-right', 'sbspf_small_svg' ) ; ?> <?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>
|
63 |
-
</p>
|
64 |
-
<?php endif; ?>
|
65 |
-
|
66 |
-
<p class="sbspf_footer_help"><?php echo sby_admin_icon( 'life-ring', 'sbspf_small_svg' ); ?> <?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>
|
67 |
-
|
68 |
-
<div class="sbspf-quick-start">
|
69 |
-
<h3><?php echo sby_admin_icon( 'rocket', 'sbspf_small_svg' ); ?> <?php _e( 'Display your feed', $text_domain); ?></h3>
|
70 |
-
<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 ); ?>
|
71 |
-
<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>
|
72 |
-
<p><?php _e( "Find out how to display <a href='?page=".$slug."&tab=display'>multiple feeds</a>.", $text_domain ); ?></p>
|
73 |
-
</div>
|
74 |
-
|
75 |
-
<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>
|
76 |
-
|
77 |
-
|
78 |
-
</div>
|
79 |
<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 |
+
<h1><?php echo esc_html( $plugin_name ); ?></h1>
|
41 |
+
|
42 |
+
<!-- Display the tabs along with styling for the 'active' tab -->
|
43 |
+
<h2 class="nav-tab-wrapper">
|
44 |
+
<?php
|
45 |
+
$i = 1;
|
46 |
+
foreach ( $tabs as $tab ) :
|
47 |
+
$title = isset( $tab['numbered_tab'] ) && ! $tab['numbered_tab'] ? __( $tab['title'], 'feeds-for-youtube' ) : $i . '. ' . __( $tab['title'], 'feeds-for-youtube' );
|
48 |
+
?>
|
49 |
+
<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>
|
50 |
+
<?php
|
51 |
+
$i ++;
|
52 |
+
endforeach; ?>
|
53 |
+
</h2>
|
54 |
+
<?php
|
55 |
+
settings_errors();
|
56 |
+
|
57 |
+
include $this->get_path( $active_tab );
|
58 |
+
|
59 |
+
$next_step = $this->next_step();
|
60 |
+
if ( ! empty( $next_step ) ) : ?>
|
61 |
+
<p class="sbspf_footer_help">
|
62 |
+
<?php echo sby_admin_icon( 'chevron-right', 'sbspf_small_svg' ) ; ?> <?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>
|
63 |
+
</p>
|
64 |
+
<?php endif; ?>
|
65 |
+
|
66 |
+
<p class="sbspf_footer_help"><?php echo sby_admin_icon( 'life-ring', 'sbspf_small_svg' ); ?> <?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>
|
67 |
+
|
68 |
+
<div class="sbspf-quick-start">
|
69 |
+
<h3><?php echo sby_admin_icon( 'rocket', 'sbspf_small_svg' ); ?> <?php _e( 'Display your feed', $text_domain); ?></h3>
|
70 |
+
<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 ); ?>
|
71 |
+
<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>
|
72 |
+
<p><?php _e( "Find out how to display <a href='?page=".$slug."&tab=display'>multiple feeds</a>.", $text_domain ); ?></p>
|
73 |
+
</div>
|
74 |
+
|
75 |
+
<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>
|
76 |
+
|
77 |
+
|
78 |
+
</div>
|
79 |
<div class="wp-clearfix"></div>
|
inc/admin/templates/single-connected-account.php
CHANGED
@@ -1,46 +1,56 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
</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 |
+
<strong><?php echo $username; ?><span><?php _e('Channel ID:', $text_domain ); ?><?php echo ' ' . $account['channel_id']; ?></span></strong>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
<div class="sbspf_ca_actions">
|
28 |
+
<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>
|
29 |
+
<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>
|
30 |
+
</div>
|
31 |
+
|
32 |
+
<div class="sbspf_ca_shortcode">
|
33 |
+
|
34 |
+
<p><?php _e('Copy and paste this shortcode into your page or widget area', $text_domain ); ?>:<br>
|
35 |
+
<?php if ( !empty( $account['username'] ) ) : ?>
|
36 |
+
<code>[<?php echo $slug; ?> channel="<?php echo $account['channel_id']; ?>"]</code>
|
37 |
+
<?php else : ?>
|
38 |
+
<code>[<?php echo $slug; ?> accesstoken="<?php echo $account['access_token']; ?>"]</code>
|
39 |
+
<?php endif; ?>
|
40 |
+
</p>
|
41 |
+
|
42 |
+
<p><?php _e('To add multiple channels in the same feed, simply separate them using commas', $text_domain); ?>:<br>
|
43 |
+
<code>[<?php echo $slug; ?> channel="<?php echo $account['channel_id']; ?>, a_second_channel, a_third_channel"]</code>
|
44 |
+
|
45 |
+
<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>
|
46 |
+
</div>
|
47 |
+
|
48 |
+
<div class="sbspf_ca_accesstoken">
|
49 |
+
<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>
|
50 |
+
<span class="sbspf_ca_token_label"><?php _e('Refresh Token', $text_domain);?>:</span><input type="text" class="sbspf_ca_refresh_token" value="<?php echo $account['refresh_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>
|
51 |
+
<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>
|
52 |
+
</div>
|
53 |
+
|
54 |
+
</div>
|
55 |
+
|
56 |
</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' ); ?> <?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' ); ?> <?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 ); ?> <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' ); ?> <?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' ); ?> <?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 ); ?> <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,185 +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', '”', $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 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
$
|
155 |
-
}
|
156 |
-
|
157 |
-
$
|
158 |
-
|
159 |
-
$
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
$url = 'https://www.googleapis.com/youtube/v3/
|
168 |
-
}
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
$
|
178 |
-
}
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
}
|
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', '”', $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,210 +1,210 @@
|
|
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'] : false;
|
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 |
-
if ( $include_resize ) {
|
132 |
-
$post_data = $youtube_feed->get_post_data();
|
133 |
-
$post_data = array_slice( $post_data, 0, $settings['num'] );
|
134 |
-
|
135 |
-
foreach ( $post_data as $post ) {
|
136 |
-
$wp_post = new SBY_WP_Post( $post, $transient_name );
|
137 |
-
$wp_post->update_post();
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Retrieve option name column values for all feed cache transients
|
145 |
-
*
|
146 |
-
* @return array
|
147 |
-
*
|
148 |
-
* @since 1.0
|
149 |
-
*/
|
150 |
-
public static function get_feed_cache_option_names() {
|
151 |
-
global $wpdb;
|
152 |
-
$feed_caches = array();
|
153 |
-
|
154 |
-
$results = $wpdb->get_results( "
|
155 |
-
SELECT option_name
|
156 |
-
FROM $wpdb->options
|
157 |
-
WHERE `option_name` LIKE ('%\_transient\_sby\_%')
|
158 |
-
AND `option_name` NOT LIKE ('%\_transient\_sby\_header%');", ARRAY_A );
|
159 |
-
|
160 |
-
if ( isset( $results[0] ) ) {
|
161 |
-
$feed_caches = $results;
|
162 |
-
}
|
163 |
-
|
164 |
-
return $feed_caches;
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Start cron jobs based on user's settings for cron cache update frequency.
|
169 |
-
* This is triggered when settings are saved on the "Configure" tab.
|
170 |
-
*
|
171 |
-
* @param string $sby_cache_cron_interval arbitrary name from one of the
|
172 |
-
* settings on the "Configure" tab
|
173 |
-
* @param string $sby_cache_cron_time hour of the day (1 = 1:00)
|
174 |
-
* @param string $sby_cache_cron_am_pm am or pm (time of day)
|
175 |
-
*
|
176 |
-
* @since 1.0
|
177 |
-
*/
|
178 |
-
public static function start_cron_job( $sby_cache_cron_interval, $sby_cache_cron_time, $sby_cache_cron_am_pm ) {
|
179 |
-
wp_clear_scheduled_hook( 'sby_feed_update' );
|
180 |
-
|
181 |
-
if ( $sby_cache_cron_interval === '12hours' || $sby_cache_cron_interval === '24hours' ) {
|
182 |
-
$relative_time_now = time() + sby_get_utc_offset();
|
183 |
-
$base_day = strtotime( date( 'Y-m-d', $relative_time_now ) );
|
184 |
-
$add_time = $sby_cache_cron_am_pm === 'pm' ? (int)$sby_cache_cron_time + 12 : (int)$sby_cache_cron_time;
|
185 |
-
$utc_start_time = $base_day + (($add_time * 60 * 60) - sby_get_utc_offset());
|
186 |
-
|
187 |
-
if ( $utc_start_time < time() ) {
|
188 |
-
if ( $sby_cache_cron_interval === '12hours' ) {
|
189 |
-
$utc_start_time += 60*60*12;
|
190 |
-
} else {
|
191 |
-
$utc_start_time += 60*60*24;
|
192 |
-
}
|
193 |
-
}
|
194 |
-
|
195 |
-
if ( $sby_cache_cron_interval === '12hours' ) {
|
196 |
-
wp_schedule_event( $utc_start_time, 'twicedaily', 'sby_feed_update' );
|
197 |
-
} else {
|
198 |
-
wp_schedule_event( $utc_start_time, 'daily', 'sby_feed_update' );
|
199 |
-
}
|
200 |
-
|
201 |
-
} else {
|
202 |
-
if ( $sby_cache_cron_interval === '30mins' ) {
|
203 |
-
wp_schedule_event( time(), 'sby30mins', 'sby_feed_update' );
|
204 |
-
} else {
|
205 |
-
wp_schedule_event( time(), 'hourly', 'sby_feed_update' );
|
206 |
-
}
|
207 |
-
}
|
208 |
-
|
209 |
-
}
|
210 |
}
|
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'] : false;
|
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 |
+
if ( $include_resize ) {
|
132 |
+
$post_data = $youtube_feed->get_post_data();
|
133 |
+
$post_data = array_slice( $post_data, 0, $settings['num'] );
|
134 |
+
|
135 |
+
foreach ( $post_data as $post ) {
|
136 |
+
$wp_post = new SBY_WP_Post( $post, $transient_name );
|
137 |
+
$wp_post->update_post();
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Retrieve option name column values for all feed cache transients
|
145 |
+
*
|
146 |
+
* @return array
|
147 |
+
*
|
148 |
+
* @since 1.0
|
149 |
+
*/
|
150 |
+
public static function get_feed_cache_option_names() {
|
151 |
+
global $wpdb;
|
152 |
+
$feed_caches = array();
|
153 |
+
|
154 |
+
$results = $wpdb->get_results( "
|
155 |
+
SELECT option_name
|
156 |
+
FROM $wpdb->options
|
157 |
+
WHERE `option_name` LIKE ('%\_transient\_sby\_%')
|
158 |
+
AND `option_name` NOT LIKE ('%\_transient\_sby\_header%');", ARRAY_A );
|
159 |
+
|
160 |
+
if ( isset( $results[0] ) ) {
|
161 |
+
$feed_caches = $results;
|
162 |
+
}
|
163 |
+
|
164 |
+
return $feed_caches;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Start cron jobs based on user's settings for cron cache update frequency.
|
169 |
+
* This is triggered when settings are saved on the "Configure" tab.
|
170 |
+
*
|
171 |
+
* @param string $sby_cache_cron_interval arbitrary name from one of the
|
172 |
+
* settings on the "Configure" tab
|
173 |
+
* @param string $sby_cache_cron_time hour of the day (1 = 1:00)
|
174 |
+
* @param string $sby_cache_cron_am_pm am or pm (time of day)
|
175 |
+
*
|
176 |
+
* @since 1.0
|
177 |
+
*/
|
178 |
+
public static function start_cron_job( $sby_cache_cron_interval, $sby_cache_cron_time, $sby_cache_cron_am_pm ) {
|
179 |
+
wp_clear_scheduled_hook( 'sby_feed_update' );
|
180 |
+
|
181 |
+
if ( $sby_cache_cron_interval === '12hours' || $sby_cache_cron_interval === '24hours' ) {
|
182 |
+
$relative_time_now = time() + sby_get_utc_offset();
|
183 |
+
$base_day = strtotime( date( 'Y-m-d', $relative_time_now ) );
|
184 |
+
$add_time = $sby_cache_cron_am_pm === 'pm' ? (int)$sby_cache_cron_time + 12 : (int)$sby_cache_cron_time;
|
185 |
+
$utc_start_time = $base_day + (($add_time * 60 * 60) - sby_get_utc_offset());
|
186 |
+
|
187 |
+
if ( $utc_start_time < time() ) {
|
188 |
+
if ( $sby_cache_cron_interval === '12hours' ) {
|
189 |
+
$utc_start_time += 60*60*12;
|
190 |
+
} else {
|
191 |
+
$utc_start_time += 60*60*24;
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
if ( $sby_cache_cron_interval === '12hours' ) {
|
196 |
+
wp_schedule_event( $utc_start_time, 'twicedaily', 'sby_feed_update' );
|
197 |
+
} else {
|
198 |
+
wp_schedule_event( $utc_start_time, 'daily', 'sby_feed_update' );
|
199 |
+
}
|
200 |
+
|
201 |
+
} else {
|
202 |
+
if ( $sby_cache_cron_interval === '30mins' ) {
|
203 |
+
wp_schedule_event( time(), 'sby30mins', 'sby_feed_update' );
|
204 |
+
} else {
|
205 |
+
wp_schedule_event( time(), 'hourly', 'sby_feed_update' );
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
}
|
210 |
}
|
inc/class-sby-display-elements.php
CHANGED
@@ -1,369 +1,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 |
-
/**
|
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="
|
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 |
+
/**
|
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 |
}
|
inc/class-sby-feed.php
CHANGED
@@ -1,1578 +1,1589 @@
|
|
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 |
-
private $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 |
-
$
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
$
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
*
|
525 |
-
*
|
526 |
-
* @param $settings
|
527 |
-
*
|
528 |
-
*
|
529 |
-
*
|
530 |
-
*
|
531 |
-
*
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
$
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
*
|
543 |
-
*
|
544 |
-
* @param
|
545 |
-
*
|
546 |
-
*
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
$
|
556 |
-
$
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
$
|
568 |
-
$
|
569 |
-
$
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
$
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
$
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
$
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
$
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
$
|
616 |
-
$
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
$
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
&& isset( $
|
634 |
-
|
635 |
-
|
636 |
-
$
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
);
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
$
|
656 |
-
|
657 |
-
|
658 |
-
$this->
|
659 |
-
$
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
$
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
$
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
);
|
684 |
-
|
685 |
-
|
686 |
-
$
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
$
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
$this->
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
$
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
$
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
&& empty( $
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
);
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
$
|
767 |
-
|
768 |
-
|
769 |
-
$this->
|
770 |
-
$
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
'
|
829 |
-
'
|
830 |
-
'
|
831 |
-
'
|
832 |
-
'
|
833 |
-
|
834 |
-
|
835 |
-
'
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
);
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
$
|
846 |
-
$json
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
$
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
*
|
869 |
-
*
|
870 |
-
*
|
871 |
-
*
|
872 |
-
* @param array $
|
873 |
-
*
|
874 |
-
*
|
875 |
-
*
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
$
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
$
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
$
|
901 |
-
$
|
902 |
-
|
903 |
-
$
|
904 |
-
$this->
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
$
|
911 |
-
$this->header_data
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
$this->
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
}
|
1011 |
-
|
1012 |
-
/**
|
1013 |
-
*
|
1014 |
-
*
|
1015 |
-
* @
|
1016 |
-
*
|
1017 |
-
*
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
*
|
1085 |
-
*
|
1086 |
-
*
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
if ( $
|
1103 |
-
$
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
$
|
1111 |
-
|
1112 |
-
|
1113 |
-
$
|
1114 |
-
|
1115 |
-
|
1116 |
-
$
|
1117 |
-
}
|
1118 |
-
|
1119 |
-
$
|
1120 |
-
|
1121 |
-
$
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
$
|
1144 |
-
}
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
if ( $settings['
|
1192 |
-
$
|
1193 |
-
}
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
*
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
*
|
1259 |
-
*
|
1260 |
-
* @return
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
$
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
public function
|
1319 |
-
$this->
|
1320 |
-
}
|
1321 |
-
|
1322 |
-
/**
|
1323 |
-
*
|
1324 |
-
*
|
1325 |
-
* @
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
*
|
1335 |
-
*
|
1336 |
-
*
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
*
|
1348 |
-
*
|
1349 |
-
*
|
1350 |
-
*
|
1351 |
-
* @
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
*
|
1417 |
-
*
|
1418 |
-
*
|
1419 |
-
*
|
1420 |
-
* @
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
}
|
1492 |
-
}
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
*
|
1564 |
-
*
|
1565 |
-
*
|
1566 |
-
*
|
1567 |
-
* @
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1578 |
}
|
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 |
+
private $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 |
+
$connected_accounts_for_feed[ $term ] = $this->maybe_refresh_token( $term, $connected_accounts_for_feed[ $term ] );
|
569 |
+
$connected_account_for_term = $connected_accounts_for_feed[ $term ];
|
570 |
+
|
571 |
+
$play_list = $this->get_play_list_for_term( $type, $term, $connected_account_for_term, $params );
|
572 |
+
|
573 |
+
if ( ! empty( $next_pages[ $term . '_' . $type ] ) ) {
|
574 |
+
$params['nextPageToken'] = $next_pages[ $term . '_' . $type ];
|
575 |
+
}
|
576 |
+
|
577 |
+
if ( $this->is_pageable() ) {
|
578 |
+
$this->add_remote_pageable_posts( $settings, $feed_types_and_terms, $connected_accounts_for_feed );
|
579 |
+
} else {
|
580 |
+
$this->add_remote_non_pageable( $settings, $feed_types_and_terms, $connected_accounts_for_feed );
|
581 |
+
}
|
582 |
+
|
583 |
+
if ( ! $this->is_efficient_type( $type ) && $this->is_pageable() ) {
|
584 |
+
|
585 |
+
if ( $this->requires_workaround_connection( $type ) ) {
|
586 |
+
$api_connect_playlist_items = $this->make_workaround_connection( $connected_account_for_term, $type, $params );
|
587 |
+
$this->add_report( 'Workaround API call made for ' . $term );
|
588 |
+
|
589 |
+
} else {
|
590 |
+
if ( $play_list ) {
|
591 |
+
$params = array( 'playlist_id' => $play_list );
|
592 |
+
$api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, 'playlistItems', $params );
|
593 |
+
} else {
|
594 |
+
$api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, $type, $params );
|
595 |
+
}
|
596 |
+
|
597 |
+
$api_connect_playlist_items->connect();
|
598 |
+
$this->add_report( 'API call made for ' . $term );
|
599 |
+
}
|
600 |
+
|
601 |
+
|
602 |
+
if ( ! $api_connect_playlist_items->is_wp_error() && ! $api_connect_playlist_items->is_youtube_error() ) {
|
603 |
+
$one_successful_connection = true;
|
604 |
+
$data = $api_connect_playlist_items->get_data();
|
605 |
+
|
606 |
+
if ( isset( $data['items'][0] ) ) {
|
607 |
+
$post_set = $this->filter_posts( $data['items'], $settings );
|
608 |
+
|
609 |
+
$this->successful_video_api_request_made = true;
|
610 |
+
|
611 |
+
$new_post_sets[] = $post_set;
|
612 |
+
}
|
613 |
+
|
614 |
+
$next_page = $api_connect_playlist_items->get_next_page( $params );
|
615 |
+
$report = is_array( $next_page ) ? implode( ',', $next_page ) : $next_page;
|
616 |
+
$this->add_report( 'Next Page ' . $report );
|
617 |
+
|
618 |
+
|
619 |
+
if ( ! empty( $next_page ) ) {
|
620 |
+
$next_pages[ $term . '_' . $type ] = $next_page;
|
621 |
+
$next_page_found = true;
|
622 |
+
} else {
|
623 |
+
$next_pages[ $term . '_' . $type ] = false;
|
624 |
+
}
|
625 |
+
}
|
626 |
+
|
627 |
+
|
628 |
+
$this->num_api_calls++;
|
629 |
+
|
630 |
+
} else {
|
631 |
+
if ( ! $this->is_pageable()
|
632 |
+
&& isset( $params['channel_id'] )
|
633 |
+
&& (! isset( $next_pages[ $term . '_' . $type ] ) || $next_pages[ $term . '_' . $type ] !== 'rss') ) {
|
634 |
+
|
635 |
+
$rss_connect_playlist_items = new SBY_RSS_Connect( 'playlistItems', $params );
|
636 |
+
$this->add_report( 'RSS call made for ' . $term );
|
637 |
+
|
638 |
+
$rss_connect_playlist_items->connect();
|
639 |
+
|
640 |
+
$one_successful_connection = true;
|
641 |
+
|
642 |
+
$data = $rss_connect_playlist_items->get_data();
|
643 |
+
|
644 |
+
if ( isset( $data[0] ) ) {
|
645 |
+
$data = array(
|
646 |
+
'items' => $data
|
647 |
+
);
|
648 |
+
$post_set = $this->filter_posts( $data['items'], $settings );
|
649 |
+
|
650 |
+
$this->successful_video_api_request_made = true;
|
651 |
+
|
652 |
+
if ( count( $post_set ) > 14 ) {
|
653 |
+
if ( (int)self::get_channel_status( $term ) !== 1 ) {
|
654 |
+
$next_pages[ $term . '_' . $type ] = 'rss';
|
655 |
+
$next_page_found = true;
|
656 |
+
} else {
|
657 |
+
$this->add_report( 'RSS update only for ' . $term );
|
658 |
+
$post_set = $this->merge_cached_posts( $post_set, $term );
|
659 |
+
$next_pages[ $term . '_' . $type ] = false;
|
660 |
+
}
|
661 |
+
} else {
|
662 |
+
$next_pages[ $term . '_' . $type ] = false;
|
663 |
+
}
|
664 |
+
|
665 |
+
$new_post_sets[] = $post_set;
|
666 |
+
|
667 |
+
}
|
668 |
+
} elseif ( isset( $connected_account_for_term['rss_only'] ) ) {
|
669 |
+
$rss_connect_playlist_items = new SBY_RSS_Connect( 'playlistItems', $params );
|
670 |
+
$this->add_report( 'RSS Only call made for ' . $term );
|
671 |
+
|
672 |
+
$rss_connect_playlist_items->connect();
|
673 |
+
|
674 |
+
$one_successful_connection = true;
|
675 |
+
|
676 |
+
$data = $rss_connect_playlist_items->get_data();
|
677 |
+
$next_pages[ $term . '_' . $type ] = false;
|
678 |
+
|
679 |
+
if ( isset( $data[0] ) ) {
|
680 |
+
$data = array(
|
681 |
+
'items' => $data
|
682 |
+
);
|
683 |
+
$post_set = $this->filter_posts( $data['items'], $settings );
|
684 |
+
|
685 |
+
$this->successful_video_api_request_made = true;
|
686 |
+
$new_post_sets[] = $post_set;
|
687 |
+
}
|
688 |
+
} else {
|
689 |
+
|
690 |
+
if ( ! $api_requests_delayed
|
691 |
+
&& (! isset( $next_pages[ $term . '_' . $type ] ) || $next_pages[ $term . '_' . $type ] !== false) ) {
|
692 |
+
|
693 |
+
$play_list = $this->get_play_list_for_term( $type, $term, $connected_account_for_term, $params );
|
694 |
+
|
695 |
+
$channel_id = isset( $this->channels_data[ $term ] ) ? SBY_Parse::get_channel_id( $this->channels_data[ $term ] ) : '';
|
696 |
+
$params = array( 'channel_id' => $channel_id );
|
697 |
+
|
698 |
+
if ( $play_list ) {
|
699 |
+
|
700 |
+
$params = array( 'playlist_id' => $play_list );
|
701 |
+
if ( ! empty( $next_pages[ $term . '_' . $type ] ) && $next_pages[ $term . '_' . $type ] !== 'rss' ) {
|
702 |
+
$params['nextPageToken'] = $next_pages[ $term . '_' . $type ];
|
703 |
+
}
|
704 |
+
|
705 |
+
if ( isset( $next_pages[ $term . '_' . $type ] ) && $next_pages[ $term . '_' . $type ] === 'rss' ) {
|
706 |
+
self::update_channel_status( $term, 1 );
|
707 |
+
$this->do_page_cache_all = true;
|
708 |
+
$this->add_report( 'using API request to get first 50 videos' );
|
709 |
+
} else {
|
710 |
+
$this->add_report( 'using API request to get more videos' );
|
711 |
+
}
|
712 |
+
|
713 |
+
$api_connect_playlist_items = $this->make_api_connection( $connected_account_for_term, 'playlistItems', $params );
|
714 |
+
|
715 |
+
$api_connect_playlist_items->connect();
|
716 |
+
|
717 |
+
if ( ! $api_connect_playlist_items->is_wp_error() && ! $api_connect_playlist_items->is_youtube_error() ) {
|
718 |
+
$one_successful_connection = true;
|
719 |
+
$data = $api_connect_playlist_items->get_data();
|
720 |
+
|
721 |
+
if ( isset( $data['items'][0] ) ) {
|
722 |
+
$post_set = $this->filter_posts( $data['items'], $settings );
|
723 |
+
|
724 |
+
$this->successful_video_api_request_made = true;
|
725 |
+
|
726 |
+
$new_post_sets[] = $post_set;
|
727 |
+
}
|
728 |
+
|
729 |
+
$next_page = $this->is_pageable() ? $api_connect_playlist_items->get_next_page() : false;
|
730 |
+
if ( ! empty( $next_page ) ) {
|
731 |
+
$next_pages[ $term . '_' . $type ] = $next_page;
|
732 |
+
$next_page_found = true;
|
733 |
+
} else {
|
734 |
+
$next_pages[ $term . '_' . $type ] = false;
|
735 |
+
}
|
736 |
+
}
|
737 |
+
} else {
|
738 |
+
$this->add_report( 'no first playlist' );
|
739 |
+
}
|
740 |
+
|
741 |
+
if ( ! $this->is_pageable()
|
742 |
+
&& empty( $next_pages[ $term . '_' . $type ] )
|
743 |
+
&& ! empty( $params['channel_id'] ) ) {
|
744 |
+
$this->add_report( 'using RSS to get first 15' );
|
745 |
+
|
746 |
+
$rss_connect_playlist_items = new SBY_RSS_Connect( 'playlistItems', $params );
|
747 |
+
|
748 |
+
$rss_connect_playlist_items->connect();
|
749 |
+
|
750 |
+
$one_successful_connection = true;
|
751 |
+
|
752 |
+
$data = $rss_connect_playlist_items->get_data();
|
753 |
+
|
754 |
+
if ( isset( $data[0] ) ) {
|
755 |
+
$data = array(
|
756 |
+
'items' => $data
|
757 |
+
);
|
758 |
+
$post_set = $this->filter_posts( $data['items'], $settings );
|
759 |
+
|
760 |
+
$this->successful_video_api_request_made = true;
|
761 |
+
|
762 |
+
|
763 |
+
if ( count( $post_set ) > 14 ) {
|
764 |
+
if ( (int)self::get_channel_status( $term ) !== 1 ) {
|
765 |
+
$next_pages[ $term . '_' . $type ] = 'rss';
|
766 |
+
$next_page_found = true;
|
767 |
+
} else {
|
768 |
+
$this->add_report( 'RSS Only' . $term );
|
769 |
+
$post_set = $this->merge_cached_posts( $post_set, $term );
|
770 |
+
$next_pages[ $term . '_' . $type ] = false;
|
771 |
+
}
|
772 |
+
} else {
|
773 |
+
$next_pages[ $term . '_' . $type ] = false;
|
774 |
+
}
|
775 |
+
|
776 |
+
$new_post_sets[] = $post_set;
|
777 |
+
|
778 |
+
}
|
779 |
+
} else {
|
780 |
+
$this->num_api_calls++;
|
781 |
+
}
|
782 |
+
|
783 |
+
}
|
784 |
+
}
|
785 |
+
}
|
786 |
+
|
787 |
+
}
|
788 |
+
|
789 |
+
}
|
790 |
+
|
791 |
+
if ( ! $one_successful_connection || ($one_api_request_delayed && empty( $new_post_sets )) ) {
|
792 |
+
$this->should_use_backup = true;
|
793 |
+
}
|
794 |
+
$posts = $this->merge_posts( $new_post_sets, $settings );
|
795 |
+
|
796 |
+
$posts = $this->sort_posts( $posts, $settings );
|
797 |
+
|
798 |
+
if ( ! empty( $this->post_data ) && is_array( $this->post_data ) ) {
|
799 |
+
$posts = array_merge( $this->post_data, $posts );
|
800 |
+
}
|
801 |
+
|
802 |
+
$this->post_data = $posts;
|
803 |
+
|
804 |
+
if ( isset( $next_page_found ) && $next_page_found ) {
|
805 |
+
$this->next_pages = $next_pages;
|
806 |
+
} else {
|
807 |
+
$this->next_pages = false;
|
808 |
+
}
|
809 |
+
}
|
810 |
+
|
811 |
+
public function add_remote_pageable_posts() {
|
812 |
+
|
813 |
+
}
|
814 |
+
|
815 |
+
public function add_remote_non_pageable() {
|
816 |
+
|
817 |
+
}
|
818 |
+
|
819 |
+
private function is_pageable() {
|
820 |
+
global $sby_settings;
|
821 |
+
|
822 |
+
return ! empty( $sby_settings['api_key'] );
|
823 |
+
}
|
824 |
+
|
825 |
+
public function merge_cached_posts( $current_posts, $channel_id ) {
|
826 |
+
$args = array(
|
827 |
+
'post_type' => SBY_CPT,
|
828 |
+
'post_status' => array( 'publish', 'pending', 'draft' ),
|
829 |
+
'orderby' => 'date',
|
830 |
+
'order' => 'DESC',
|
831 |
+
'posts_per_page' => 80,
|
832 |
+
'meta_query' => array(
|
833 |
+
array(
|
834 |
+
'value' => $channel_id,
|
835 |
+
'key' => 'sby_channel_id'
|
836 |
+
)
|
837 |
+
)
|
838 |
+
);
|
839 |
+
$feed_videos = new WP_Query( $args );
|
840 |
+
|
841 |
+
if ( $feed_videos->have_posts() ) {
|
842 |
+
$posts = array();
|
843 |
+
while ( $feed_videos->have_posts() ) {
|
844 |
+
$feed_videos->the_post();
|
845 |
+
$json = get_post_meta( get_the_ID(), 'sby_json', true );
|
846 |
+
if ( $json ) {
|
847 |
+
$posts[] = json_decode( $json, true );
|
848 |
+
}
|
849 |
+
}
|
850 |
+
|
851 |
+
wp_reset_postdata();
|
852 |
+
$this->add_report( 'merging cached posts' );
|
853 |
+
|
854 |
+
$posts = array_merge( $current_posts, $posts );
|
855 |
+
|
856 |
+
return $posts;
|
857 |
+
} else {
|
858 |
+
$this->add_report( 'no cached posts found' );
|
859 |
+
wp_reset_postdata();
|
860 |
+
|
861 |
+
return $current_posts;
|
862 |
+
}
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
* Connects to the YouTube API and records returned data. Will use channel data if already
|
867 |
+
* set by the regular feed
|
868 |
+
*
|
869 |
+
* @param $settings
|
870 |
+
* @param array $feed_types_and_terms organized settings related to feed data
|
871 |
+
* (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
|
872 |
+
* @param array $connected_accounts_for_feed connected account data for the
|
873 |
+
* feed types and terms
|
874 |
+
*
|
875 |
+
* @since 1.0
|
876 |
+
*/
|
877 |
+
public function set_remote_header_data( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
|
878 |
+
$first_user = $this->get_first_user( $feed_types_and_terms, $settings );
|
879 |
+
$this->header_data = false;
|
880 |
+
$existing_channel_cache = $this->get_channel_cache( $first_user );
|
881 |
+
|
882 |
+
if ( $existing_channel_cache ) {
|
883 |
+
$this->channels_data[ $first_user ] = $existing_channel_cache;
|
884 |
+
$this->add_report( 'header data for ' . $first_user . ' exists in cache' );
|
885 |
+
}
|
886 |
+
|
887 |
+
if ( isset( $this->channels_data[ $first_user ] ) && ! $this->is_pageable() ) {
|
888 |
+
$this->header_data = $this->channels_data[ $first_user ];
|
889 |
+
} elseif ( ! empty( $first_user ) ) {
|
890 |
+
$connected_account_for_term = sby_get_first_connected_account();
|
891 |
+
if ( $connected_account_for_term['expires'] < time() + 5 ) {
|
892 |
+
$error_message = '<p><b>' . __( 'Reconnect to YouTube to show this feed.', 'custom-facebook-feed' ) . '</b></p>';
|
893 |
+
$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>';
|
894 |
+
|
895 |
+
if ( current_user_can( 'manage_youtube_feed_options' ) ) {
|
896 |
+
$error_message .= '<a href="' . admin_url( 'admin.php?page=youtube-feed' ) . '" target="blank" rel="noopener nofollow">' . __( 'Reconnect in the YouTube Feed Settings Area' ) . '</a>';
|
897 |
+
}
|
898 |
+
global $sby_posts_manager;
|
899 |
+
|
900 |
+
$sby_posts_manager->add_frontend_error( 'accesstoken', $error_message );
|
901 |
+
$sby_posts_manager->add_error( 'accesstoken', array( 'Trying to connect a new account', $error_message ) );
|
902 |
+
} else {
|
903 |
+
$params = strpos( $first_user, 'UC' ) !== 0 ? array( 'channel_name' => $first_user ) : array( 'channel_id' => $first_user );
|
904 |
+
$connection = $this->make_api_connection( $connected_account_for_term, 'channels', $params );
|
905 |
+
|
906 |
+
$connection->connect();
|
907 |
+
$this->add_report( 'api call made for header - ' . $first_user );
|
908 |
+
|
909 |
+
if ( ! $connection->is_wp_error() && ! $connection->is_youtube_error() ) {
|
910 |
+
$this->header_data = $connection->get_data();
|
911 |
+
$channel_id = SBY_Parse::get_channel_id( $this->header_data );
|
912 |
+
$this->set_channel_cache( $channel_id, $this->header_data );
|
913 |
+
$this->channels_data[ $channel_id ] = $this->header_data;
|
914 |
+
$this->channels_data[ $first_user ] = $this->header_data;
|
915 |
+
|
916 |
+
if ( isset( $connected_accounts_for_feed[ $first_user ]['local_avatar'] ) && $connected_accounts_for_feed[ $first_user ]['local_avatar'] ) {
|
917 |
+
$upload = wp_upload_dir();
|
918 |
+
$resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBY_UPLOADS_NAME );
|
919 |
+
|
920 |
+
$full_file_name = $resized_url . $this->header_data['username'] . '.jpg';
|
921 |
+
$this->header_data['local_avatar'] = $full_file_name;
|
922 |
+
}
|
923 |
+
} else {
|
924 |
+
if ( $connection->is_wp_error() ) {
|
925 |
+
SBY_API_Connect::handle_wp_remote_get_error( $connection->get_wp_error() );
|
926 |
+
} else {
|
927 |
+
SBY_API_Connect::handle_youtube_error( $connection->get_data(), $connected_accounts_for_feed[ $first_user ], 'header' );
|
928 |
+
}
|
929 |
+
}
|
930 |
+
}
|
931 |
+
}
|
932 |
+
}
|
933 |
+
|
934 |
+
/**
|
935 |
+
* Stores feed data in a transient for a specified time
|
936 |
+
*
|
937 |
+
* @param int $cache_time
|
938 |
+
*
|
939 |
+
* @since 1.0
|
940 |
+
*/
|
941 |
+
public function cache_feed_data( $cache_time ) {
|
942 |
+
if ( ! empty( $this->post_data ) || ! empty( $this->next_pages ) ) {
|
943 |
+
$this->remove_duplicate_posts();
|
944 |
+
$this->trim_posts_to_max();
|
945 |
+
|
946 |
+
$post_data = $this->post_data;
|
947 |
+
|
948 |
+
if (! isset( $post_data[0]['iframe'] )) {
|
949 |
+
$to_cache = array(
|
950 |
+
'data' => $this->post_data,
|
951 |
+
'pagination' => $this->next_pages
|
952 |
+
);
|
953 |
+
|
954 |
+
set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
|
955 |
+
} else {
|
956 |
+
$this->add_report( 'iframe not caching' );
|
957 |
+
}
|
958 |
+
|
959 |
+
|
960 |
+
} else {
|
961 |
+
$this->add_report( 'no data not caching' );
|
962 |
+
}
|
963 |
+
}
|
964 |
+
|
965 |
+
/**
|
966 |
+
* Stores feed data with additional data specifically for cron caching
|
967 |
+
*
|
968 |
+
* @param array $to_cache feed data with additional things like the shortcode
|
969 |
+
* settings, when the cache was last requested, when new posts were last retrieved
|
970 |
+
* @param int $cache_time how long the cache will last
|
971 |
+
*
|
972 |
+
* @since 1.0
|
973 |
+
*/
|
974 |
+
public function set_cron_cache( $to_cache, $cache_time ) {
|
975 |
+
if ( ! empty( $this->post_data )
|
976 |
+
|| ! empty( $this->next_pages )
|
977 |
+
|| ! empty( $to_cache['data'] ) ) {
|
978 |
+
$this->remove_duplicate_posts();
|
979 |
+
$this->trim_posts_to_max();
|
980 |
+
|
981 |
+
$to_cache['data'] = isset( $to_cache['data'] ) ? $to_cache['data'] : $this->post_data;
|
982 |
+
$to_cache['pagination'] = isset( $to_cache['next_pages'] ) ? $to_cache['next_pages'] : $this->next_pages;
|
983 |
+
$to_cache['atts'] = isset( $to_cache['atts'] ) ? $to_cache['atts'] : $this->transient_atts;
|
984 |
+
$to_cache['last_requested'] = isset( $to_cache['last_requested'] ) ? $to_cache['last_requested'] : time();
|
985 |
+
$to_cache['last_retrieve'] = isset( $to_cache['last_retrieve'] ) ? $to_cache['last_retrieve'] : $this->last_retrieve;
|
986 |
+
|
987 |
+
set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
|
988 |
+
} else {
|
989 |
+
$this->add_report( 'no data not caching' );
|
990 |
+
}
|
991 |
+
|
992 |
+
}
|
993 |
+
|
994 |
+
/**
|
995 |
+
* Stores header data for a specified time as a transient
|
996 |
+
*
|
997 |
+
* @param int $cache_time
|
998 |
+
* @param bool $save_backup
|
999 |
+
*
|
1000 |
+
* @since 1.0
|
1001 |
+
*/
|
1002 |
+
public function cache_header_data( $cache_time, $save_backup = true ) {
|
1003 |
+
if ( $this->header_data ) {
|
1004 |
+
set_transient( $this->header_transient_name, wp_json_encode( $this->header_data ), $cache_time );
|
1005 |
+
|
1006 |
+
if ( $save_backup ) {
|
1007 |
+
update_option( $this->backup_header_transient_name, wp_json_encode( $this->header_data ), false );
|
1008 |
+
}
|
1009 |
+
}
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
/**
|
1013 |
+
* Used to randomly trigger an updating of the last requested data for cron caching
|
1014 |
+
*
|
1015 |
+
* @return bool
|
1016 |
+
*
|
1017 |
+
* @since 1.0
|
1018 |
+
*/
|
1019 |
+
public function should_update_last_requested() {
|
1020 |
+
return (rand( 1, 20 ) === 20);
|
1021 |
+
}
|
1022 |
+
|
1023 |
+
/**
|
1024 |
+
* Determines if pagination can and should be used based on settings and available feed data
|
1025 |
+
*
|
1026 |
+
* @param array $settings
|
1027 |
+
* @param int $offset
|
1028 |
+
*
|
1029 |
+
* @return bool
|
1030 |
+
*
|
1031 |
+
* @since 1.0
|
1032 |
+
*/
|
1033 |
+
public function should_use_pagination( $settings, $offset = 0 ) {
|
1034 |
+
$posts_available = count( $this->post_data ) - ($offset + $settings['num']);
|
1035 |
+
$show_loadmore_button_by_settings = ($settings['showbutton'] == 'on' || $settings['showbutton'] == 'true' || $settings['showbutton'] == true ) && $settings['showbutton'] !== 'false';
|
1036 |
+
|
1037 |
+
if ( $show_loadmore_button_by_settings ) {
|
1038 |
+
// used for permanent and whitelist feeds
|
1039 |
+
if ( $this->feed_is_complete( $settings, $offset ) ) {
|
1040 |
+
$this->add_report( 'no pagination, feed complete' );
|
1041 |
+
return false;
|
1042 |
+
}
|
1043 |
+
if ( $posts_available > 0 ) {
|
1044 |
+
$this->add_report( 'do pagination, posts available' );
|
1045 |
+
return true;
|
1046 |
+
}
|
1047 |
+
$pages = $this->next_pages;
|
1048 |
+
|
1049 |
+
if ( $pages && ! $this->should_use_backup() ) {
|
1050 |
+
foreach ( $pages as $page ) {
|
1051 |
+
if ( ! empty( $page ) ) {
|
1052 |
+
return true;
|
1053 |
+
}
|
1054 |
+
}
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
}
|
1058 |
+
|
1059 |
+
|
1060 |
+
$this->add_report( 'no pagination, no posts available' );
|
1061 |
+
|
1062 |
+
return false;
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
public static function get_channel_status( $channel ) {
|
1066 |
+
$channel_setting = get_option( 'sby_channel_status', array() );
|
1067 |
+
|
1068 |
+
if ( isset( $channel_setting[ $channel ] ) ) {
|
1069 |
+
return $channel_setting[ $channel ];
|
1070 |
+
}
|
1071 |
+
|
1072 |
+
return 0;
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
public static function update_channel_status( $channel, $status ) {
|
1076 |
+
$channel_setting = get_option( 'sby_channel_status', array() );
|
1077 |
+
|
1078 |
+
$channel_setting[ $channel ] = $status;
|
1079 |
+
|
1080 |
+
update_option( 'sby_channel_status', $channel_setting, false );
|
1081 |
+
}
|
1082 |
+
|
1083 |
+
/**
|
1084 |
+
* Generates the HTML for the feed if post data is available. Although it seems
|
1085 |
+
* some of the variables ar not used they are set here to hide where they
|
1086 |
+
* come from when used in the feed templates.
|
1087 |
+
*
|
1088 |
+
* @param array $settings
|
1089 |
+
* @param array $atts
|
1090 |
+
* @param array $feed_types_and_terms organized settings related to feed data
|
1091 |
+
* (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
|
1092 |
+
* @param array $connected_accounts_for_feed connected account data for the
|
1093 |
+
* feed types and terms
|
1094 |
+
*
|
1095 |
+
* @return false|string
|
1096 |
+
*
|
1097 |
+
* @since 1.0
|
1098 |
+
*/
|
1099 |
+
public function get_the_feed_html( $settings, $atts, $feed_types_and_terms, $connected_accounts_for_feed ) {
|
1100 |
+
global $sby_posts_manager;
|
1101 |
+
|
1102 |
+
if ( empty( $this->post_data ) && ! empty( $connected_accounts_for_feed ) ) {
|
1103 |
+
$error = '<p><b>' . __( 'Error: No videos found.', SBY_TEXT_DOMAIN ) . '</b>';
|
1104 |
+
$error .= '<p>' . __( 'Make sure this is a valid channel ID and that the channel has videos available on youtube.com.', SBY_TEXT_DOMAIN ) . '</p>';
|
1105 |
+
|
1106 |
+
$sby_posts_manager->add_frontend_error( 'noposts', $error );
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
$posts = array_slice( $this->post_data, 0, $settings['minnum'] );
|
1110 |
+
$header_data = ! empty( $this->header_data ) ? $this->header_data : false;
|
1111 |
+
|
1112 |
+
$first_username = false;
|
1113 |
+
if ( $header_data ) {
|
1114 |
+
$first_username = SBY_Parse::get_channel_id( $header_data );
|
1115 |
+
} elseif ( isset( $this->post_data[0] ) ) { // in case no connected account for feed
|
1116 |
+
$first_username = SBY_Parse::get_channel_id( $this->post_data[0] );
|
1117 |
+
}
|
1118 |
+
|
1119 |
+
$use_pagination = $this->should_use_pagination( $settings, 0 );
|
1120 |
+
|
1121 |
+
$feed_id = $this->regular_feed_transient_name;
|
1122 |
+
$shortcode_atts = ! empty( $atts ) ? wp_json_encode( $atts ) : '{}';
|
1123 |
+
|
1124 |
+
$settings['header_outside'] = false;
|
1125 |
+
$settings['header_inside'] = false;
|
1126 |
+
if ( $header_data && $settings['showheader'] ) {
|
1127 |
+
$settings['header_inside'] = true;
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
$other_atts = '';
|
1131 |
+
|
1132 |
+
$classes = array();
|
1133 |
+
if ( empty( $settings['widthresp'] ) || $settings['widthresp'] == 'on' || $settings['widthresp'] == 'true' || $settings['widthresp'] === true ) {
|
1134 |
+
if ( $settings['widthresp'] !== 'false' ) {
|
1135 |
+
$classes[] = 'sby_width_resp';
|
1136 |
+
}
|
1137 |
+
}
|
1138 |
+
if ( ! empty( $settings['class'] ) ) {
|
1139 |
+
$classes[] = esc_attr( $settings['class'] );
|
1140 |
+
}
|
1141 |
+
if ( ! empty( $settings['height'] )
|
1142 |
+
&& (((int)$settings['height'] < 100 && $settings['heightunit'] === '%') || $settings['heightunit'] === 'px') ) {
|
1143 |
+
$classes[] = 'sby_fixed_height';
|
1144 |
+
}
|
1145 |
+
if ( ! empty( $settings['disablemobile'] )
|
1146 |
+
&& ($settings['disablemobile'] == 'on' || $settings['disablemobile'] == 'true' || $settings['disablemobile'] == true) ) {
|
1147 |
+
if ( $settings['disablemobile'] !== 'false' ) {
|
1148 |
+
$classes[] = 'sby_disable_mobile';
|
1149 |
+
}
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
$additional_classes = '';
|
1153 |
+
if ( ! empty( $classes ) ) {
|
1154 |
+
$additional_classes = ' ' . implode( ' ', $classes );
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
$other_atts = $this->add_other_atts( $other_atts, $settings );
|
1158 |
+
|
1159 |
+
$flags = array();
|
1160 |
+
|
1161 |
+
if ( $this->successful_video_api_request_made && ! empty( $posts ) ) {
|
1162 |
+
if ( $settings['storage_process'] === 'page' ) {
|
1163 |
+
$this_posts = $posts;
|
1164 |
+
if ( $this->do_page_cache_all ) {
|
1165 |
+
$this_posts = $this->post_data;
|
1166 |
+
}
|
1167 |
+
$this->add_report( 'Adding videos to wp_posts ' . count( $this_posts ) );
|
1168 |
+
|
1169 |
+
sby_process_post_set_caching( $this_posts, $feed_id );
|
1170 |
+
} elseif ( $settings['storage_process'] === 'background' ) {
|
1171 |
+
$flags[] = 'checkWPPosts';
|
1172 |
+
if ( $this->do_page_cache_all ) {
|
1173 |
+
$this->add_report( 'Flagging videos to wp_posts ' . count( $this->post_data ) );
|
1174 |
+
$flags[] = 'cacheAll';
|
1175 |
+
}
|
1176 |
+
}
|
1177 |
+
}
|
1178 |
+
|
1179 |
+
if ( $settings['disable_resize'] ) {
|
1180 |
+
$flags[] = 'resizeDisable';
|
1181 |
+
} elseif ( $settings['favor_local'] ) {
|
1182 |
+
$flags[] = 'favorLocal';
|
1183 |
+
}
|
1184 |
+
|
1185 |
+
if ( $settings['disable_js_image_loading'] ) {
|
1186 |
+
$flags[] = 'imageLoadDisable';
|
1187 |
+
}
|
1188 |
+
if ( $settings['ajax_post_load'] ) {
|
1189 |
+
$flags[] = 'ajaxPostLoad';
|
1190 |
+
}
|
1191 |
+
if ( $settings['playerratio'] === '3:4' ) {
|
1192 |
+
$flags[] = 'narrowPlayer';
|
1193 |
+
}
|
1194 |
+
if ( isset( $_GET['sby_debug'] ) ) {
|
1195 |
+
$flags[] = 'debug';
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
if ( ! empty( $flags ) ) {
|
1199 |
+
$other_atts .= ' data-sby-flags="' . implode(',', $flags ) . '"';
|
1200 |
+
}
|
1201 |
+
|
1202 |
+
if ( $settings['layout'] === 'grid' || $settings['layout'] === 'carousel' ) {
|
1203 |
+
$other_atts .= ' data-sby-supports-lightbox="1"';
|
1204 |
+
}
|
1205 |
+
$icon_type = $settings['font_method'];
|
1206 |
+
|
1207 |
+
ob_start();
|
1208 |
+
include sby_get_feed_template_part( 'feed', $settings );
|
1209 |
+
$html = ob_get_contents();
|
1210 |
+
ob_get_clean();
|
1211 |
+
|
1212 |
+
if ( $settings['ajaxtheme'] ) {
|
1213 |
+
$html .= $this->get_ajax_page_load_html();
|
1214 |
+
}
|
1215 |
+
|
1216 |
+
return $html;
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
/**
|
1220 |
+
* Generates HTML for individual sby_item elements
|
1221 |
+
*
|
1222 |
+
* @param array $settings
|
1223 |
+
* @param int $offset
|
1224 |
+
* @param array $feed_types_and_terms organized settings related to feed data
|
1225 |
+
* (ex. 'user' => array( 'smashballoon', 'customyoutubefeed' )
|
1226 |
+
* @param array $connected_accounts_for_feed connected account data for the
|
1227 |
+
* feed types and terms
|
1228 |
+
*
|
1229 |
+
* @return false|string
|
1230 |
+
*
|
1231 |
+
* @since 1.0
|
1232 |
+
*/
|
1233 |
+
public function get_the_items_html( $settings, $offset, $feed_types_and_terms = array(), $connected_accounts_for_feed = array() ) {
|
1234 |
+
if ( empty( $this->post_data ) ) {
|
1235 |
+
ob_start();
|
1236 |
+
$html = ob_get_contents();
|
1237 |
+
ob_get_clean(); ?>
|
1238 |
+
<p><?php _e( 'No posts found.', SBY_TEXT_DOMAIN ); ?></p>
|
1239 |
+
<?php
|
1240 |
+
$html = ob_get_contents();
|
1241 |
+
ob_get_clean();
|
1242 |
+
return $html;
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
$posts = array_slice( $this->post_data, $offset, $settings['num'] );
|
1246 |
+
|
1247 |
+
ob_start();
|
1248 |
+
|
1249 |
+
$this->posts_loop( $posts, $settings, $offset );
|
1250 |
+
|
1251 |
+
$html = ob_get_contents();
|
1252 |
+
ob_get_clean();
|
1253 |
+
|
1254 |
+
return $html;
|
1255 |
+
}
|
1256 |
+
|
1257 |
+
/**
|
1258 |
+
* Overwritten in the Pro version
|
1259 |
+
*
|
1260 |
+
* @return object
|
1261 |
+
*/
|
1262 |
+
public function make_api_connection( $connected_account_or_page, $type = NULL, $params = NULL ) {
|
1263 |
+
return new SBY_API_Connect( $connected_account_or_page, $type, $params );
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
/**
|
1267 |
+
* When the feed is loaded with AJAX, the JavaScript for the plugin
|
1268 |
+
* needs to be triggered again. This function is a workaround that adds
|
1269 |
+
* the file and settings to the page whenever the feed is generated.
|
1270 |
+
*
|
1271 |
+
* @return string
|
1272 |
+
*
|
1273 |
+
* @since 1.0
|
1274 |
+
*/
|
1275 |
+
public static function get_ajax_page_load_html() {
|
1276 |
+
global $sby_settings;
|
1277 |
+
|
1278 |
+
$js_options = array(
|
1279 |
+
'adminAjaxUrl' => admin_url( 'admin-ajax.php' ),
|
1280 |
+
'placeholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder.png',
|
1281 |
+
'placeholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder-narrow.png',
|
1282 |
+
'lightboxPlaceholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder.png',
|
1283 |
+
'lightboxPlaceholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder-narrow.png',
|
1284 |
+
'autoplay' => $sby_settings['playvideo'] === 'automatically',
|
1285 |
+
'semiEagerload' => $sby_settings['eagerload'],
|
1286 |
+
'eagerload' => false
|
1287 |
+
);
|
1288 |
+
|
1289 |
+
$encoded_options = wp_json_encode( $js_options );
|
1290 |
+
|
1291 |
+
$js_option_html = '<script type="text/javascript">if (typeof sbyOptions === "undefined") var sbyOptions = ' . $encoded_options . ';</script>';
|
1292 |
+
$js_option_html .= "<script type='text/javascript' src='" . trailingslashit( SBY_PLUGIN_URL ) . 'js/sb-youtube.min.js?ver=' . SBYVER . "'></script>";
|
1293 |
+
|
1294 |
+
return $js_option_html;
|
1295 |
+
}
|
1296 |
+
|
1297 |
+
/**
|
1298 |
+
* Overwritten in the Pro version
|
1299 |
+
*
|
1300 |
+
* @param $feed_types_and_terms
|
1301 |
+
*
|
1302 |
+
* @return string
|
1303 |
+
*
|
1304 |
+
* @since 2.1/5.2
|
1305 |
+
*/
|
1306 |
+
public function get_first_user( $feed_types_and_terms, $settings = array() ) {
|
1307 |
+
if ( isset( $feed_types_and_terms['channels'][0] ) ) {
|
1308 |
+
return $feed_types_and_terms['channels'][0]['term'];
|
1309 |
+
} else {
|
1310 |
+
return '';
|
1311 |
+
}
|
1312 |
+
}
|
1313 |
+
|
1314 |
+
public function do_page_cache_all() {
|
1315 |
+
return $this->do_page_cache_all;
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
public function successful_video_api_request_made() {
|
1319 |
+
return $this->successful_video_api_request_made;
|
1320 |
+
}
|
1321 |
+
|
1322 |
+
/**
|
1323 |
+
* Adds recorded strings to an array
|
1324 |
+
*
|
1325 |
+
* @param $to_add
|
1326 |
+
*
|
1327 |
+
* @since 1.0
|
1328 |
+
*/
|
1329 |
+
public function add_report( $to_add ) {
|
1330 |
+
$this->report[] = $to_add;
|
1331 |
+
}
|
1332 |
+
|
1333 |
+
/**
|
1334 |
+
* @return array
|
1335 |
+
*
|
1336 |
+
* @since 1.0
|
1337 |
+
*/
|
1338 |
+
public function get_report() {
|
1339 |
+
return $this->report;
|
1340 |
+
}
|
1341 |
+
|
1342 |
+
/**
|
1343 |
+
* Additional options/settings added to the main div
|
1344 |
+
* for the feed
|
1345 |
+
*
|
1346 |
+
* Overwritten in the Pro version
|
1347 |
+
*
|
1348 |
+
* @param $other_atts
|
1349 |
+
* @param $settings
|
1350 |
+
*
|
1351 |
+
* @return string
|
1352 |
+
*/
|
1353 |
+
protected function add_other_atts( $other_atts, $settings ) {
|
1354 |
+
return '';
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
/**
|
1358 |
+
* Used for filtering a single API request worth of posts
|
1359 |
+
*
|
1360 |
+
* Overwritten in the Pro version
|
1361 |
+
*
|
1362 |
+
* @param array $post_set a single set of post data from the api
|
1363 |
+
*
|
1364 |
+
* @return mixed|array
|
1365 |
+
*
|
1366 |
+
* @since 1.0
|
1367 |
+
*/
|
1368 |
+
protected function filter_posts( $post_set, $settings = array() ) {
|
1369 |
+
// array_unique( $post_set, SORT_REGULAR);
|
1370 |
+
|
1371 |
+
return $post_set;
|
1372 |
+
}
|
1373 |
+
|
1374 |
+
protected function remove_duplicate_posts() {
|
1375 |
+
$posts = $this->post_data;
|
1376 |
+
$ids_in_feed = array();
|
1377 |
+
$non_duplicate_posts = array();
|
1378 |
+
$removed = array();
|
1379 |
+
|
1380 |
+
foreach ( $posts as $post ) {
|
1381 |
+
$post_id = SBY_Parse::get_video_id( $post );
|
1382 |
+
if ( ! in_array( $post_id, $ids_in_feed, true ) ) {
|
1383 |
+
$ids_in_feed[] = $post_id;
|
1384 |
+
$non_duplicate_posts[] = $post;
|
1385 |
+
} else {
|
1386 |
+
$removed[] = $post_id;
|
1387 |
+
}
|
1388 |
+
}
|
1389 |
+
|
1390 |
+
$this->add_report( 'removed duplicates: ' . implode(', ', $removed ) );
|
1391 |
+
$this->set_post_data( $non_duplicate_posts );
|
1392 |
+
}
|
1393 |
+
|
1394 |
+
/**
|
1395 |
+
* Used for limiting the cache size
|
1396 |
+
*
|
1397 |
+
* @since 2.0/5.1.1
|
1398 |
+
*/
|
1399 |
+
protected function trim_posts_to_max() {
|
1400 |
+
if ( ! is_array( $this->post_data ) ) {
|
1401 |
+
return;
|
1402 |
+
}
|
1403 |
+
|
1404 |
+
$max = apply_filters( 'sby_max_cache_size', 500 );
|
1405 |
+
$this->set_post_data( array_slice( $this->post_data , 0, $max ) );
|
1406 |
+
|
1407 |
+
}
|
1408 |
+
|
1409 |
+
/**
|
1410 |
+
* Used for permanent feeds or white list feeds to
|
1411 |
+
* stop pagination if all posts are already added
|
1412 |
+
*
|
1413 |
+
* Overwritten in the Pro version
|
1414 |
+
*
|
1415 |
+
* @param array $settings
|
1416 |
+
* @param int $offset
|
1417 |
+
*
|
1418 |
+
* @return bool
|
1419 |
+
*
|
1420 |
+
* @since 1.0
|
1421 |
+
*/
|
1422 |
+
protected function feed_is_complete( $settings, $offset = 0 ) {
|
1423 |
+
return false;
|
1424 |
+
}
|
1425 |
+
|
1426 |
+
/**
|
1427 |
+
* Iterates through post data and tracks the index of the current post.
|
1428 |
+
* The actual post ids of the posts are stored in an array so the plugin
|
1429 |
+
* can search for local images that may be available.
|
1430 |
+
*
|
1431 |
+
* @param array $posts final filtered post data for the feed
|
1432 |
+
* @param array $settings
|
1433 |
+
* @param int $offset
|
1434 |
+
*
|
1435 |
+
* @since 1.0
|
1436 |
+
*/
|
1437 |
+
protected function posts_loop( $posts, $settings, $offset = 0 ) {
|
1438 |
+
|
1439 |
+
$image_ids = array();
|
1440 |
+
$post_index = $offset;
|
1441 |
+
if ( ! isset( $settings['feed_id'] ) ) {
|
1442 |
+
$settings['feed_id'] = $this->regular_feed_transient_name;
|
1443 |
+
}
|
1444 |
+
$misc_data = $this->get_misc_data( $settings['feed_id'], $posts );
|
1445 |
+
$icon_type = $settings['font_method'];
|
1446 |
+
|
1447 |
+
foreach ( $posts as $post ) {
|
1448 |
+
$image_ids[] = SBY_Parse::get_post_id( $post );
|
1449 |
+
include sby_get_feed_template_part( 'item', $settings );
|
1450 |
+
$post_index++;
|
1451 |
+
}
|
1452 |
+
|
1453 |
+
$this->image_ids_post_set = $image_ids;
|
1454 |
+
}
|
1455 |
+
|
1456 |
+
/**
|
1457 |
+
* Uses array of API request results and merges them based on how
|
1458 |
+
* the feed should be sorted. Mixed feeds are always sorted alternating
|
1459 |
+
* since there is no post date for hashtag feeds.
|
1460 |
+
*
|
1461 |
+
* @param array $post_sets an array of single API request worth
|
1462 |
+
* of posts
|
1463 |
+
* @param array $settings
|
1464 |
+
*
|
1465 |
+
* @return array
|
1466 |
+
*
|
1467 |
+
* @since 1.0
|
1468 |
+
*/
|
1469 |
+
private function merge_posts( $post_sets, $settings ) {
|
1470 |
+
|
1471 |
+
$merged_posts = array();
|
1472 |
+
if ( $settings['sortby'] === 'alternate' ) {
|
1473 |
+
// don't bother merging posts if there is only one post set
|
1474 |
+
if ( isset( $post_sets[1] ) ) {
|
1475 |
+
$min_cycles = max( 1, (int)$settings['num'] );
|
1476 |
+
for( $i = 0; $i <= $min_cycles; $i++ ) {
|
1477 |
+
foreach ( $post_sets as $post_set ) {
|
1478 |
+
if ( isset( $post_set[ $i ] ) && isset( $post_set[ $i ]['id'] ) ) {
|
1479 |
+
$merged_posts[] = $post_set[ $i ];
|
1480 |
+
}
|
1481 |
+
}
|
1482 |
+
}
|
1483 |
+
} else {
|
1484 |
+
$merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
|
1485 |
+
}
|
1486 |
+
} elseif ( $settings['sortby'] === 'api' ) {
|
1487 |
+
if ( isset( $post_sets[0] ) ) {
|
1488 |
+
foreach ( $post_sets as $post_set ) {
|
1489 |
+
$merged_posts = array_merge( $merged_posts, $post_set );
|
1490 |
+
}
|
1491 |
+
}
|
1492 |
+
} else {
|
1493 |
+
// don't bother merging posts if there is only one post set
|
1494 |
+
if ( isset( $post_sets[1] ) ) {
|
1495 |
+
foreach ( $post_sets as $post_set ) {
|
1496 |
+
if ( isset( $post_set[0]['id'] ) ) {
|
1497 |
+
$merged_posts = array_merge( $merged_posts, $post_set );
|
1498 |
+
}
|
1499 |
+
}
|
1500 |
+
} else {
|
1501 |
+
$merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
|
1502 |
+
}
|
1503 |
+
}
|
1504 |
+
|
1505 |
+
|
1506 |
+
return $merged_posts;
|
1507 |
+
}
|
1508 |
+
|
1509 |
+
/**
|
1510 |
+
* Sorts a post set based on sorting settings. Sorting by "alternate"
|
1511 |
+
* is done when merging posts for efficiency's sake so the post set is
|
1512 |
+
* just returned as it is.
|
1513 |
+
*
|
1514 |
+
* @param array $post_set
|
1515 |
+
* @param array $settings
|
1516 |
+
*
|
1517 |
+
* @return mixed|array
|
1518 |
+
*
|
1519 |
+
* @since 1.0
|
1520 |
+
*/
|
1521 |
+
protected function sort_posts( $post_set, $settings ) {
|
1522 |
+
if ( empty( $post_set ) ) {
|
1523 |
+
return $post_set;
|
1524 |
+
}
|
1525 |
+
|
1526 |
+
// sorting done with "merge_posts" to be more efficient
|
1527 |
+
if ( $settings['sortby'] === 'alternate' || $settings['sortby'] === 'api' ) {
|
1528 |
+
$return_post_set = $post_set;
|
1529 |
+
} elseif ( $settings['sortby'] === 'random' ) {
|
1530 |
+
/*
|
1531 |
+
* randomly selects posts in a random order. Cache saves posts
|
1532 |
+
* in this random order so paginating does not cause some posts to show up
|
1533 |
+
* twice or not at all
|
1534 |
+
*/
|
1535 |
+
usort($post_set, 'sby_rand_sort' );
|
1536 |
+
$return_post_set = $post_set;
|
1537 |
+
|
1538 |
+
} else {
|
1539 |
+
// compares posted on dates of posts
|
1540 |
+
usort($post_set, 'sby_date_sort' );
|
1541 |
+
$return_post_set = $post_set;
|
1542 |
+
}
|
1543 |
+
|
1544 |
+
/**
|
1545 |
+
* Apply a custom sorting of posts
|
1546 |
+
*
|
1547 |
+
* @param array $return_post_set Ordered set of filtered posts
|
1548 |
+
* @param array $settings Settings for this feed
|
1549 |
+
*
|
1550 |
+
* @since 1.0
|
1551 |
+
*/
|
1552 |
+
|
1553 |
+
return apply_filters( 'sby_sorted_posts', $return_post_set, $settings );
|
1554 |
+
}
|
1555 |
+
|
1556 |
+
/**
|
1557 |
+
* Can trigger a second attempt at getting posts from the API
|
1558 |
+
*
|
1559 |
+
* Overwritten in the Pro version
|
1560 |
+
*
|
1561 |
+
* @param string $type
|
1562 |
+
* @param array $connected_account_with_error
|
1563 |
+
* @param int $attempts
|
1564 |
+
*
|
1565 |
+
* @return bool
|
1566 |
+
*
|
1567 |
+
* @since 1.0
|
1568 |
+
*/
|
1569 |
+
protected function can_try_another_request( $type, $connected_account_with_error, $attempts = 0 ) {
|
1570 |
+
return false;
|
1571 |
+
}
|
1572 |
+
|
1573 |
+
/**
|
1574 |
+
* returns a second connected account if it exists
|
1575 |
+
*
|
1576 |
+
* Overwritten in the Pro version
|
1577 |
+
*
|
1578 |
+
* @param string $type
|
1579 |
+
* @param array $attempted_connected_accounts
|
1580 |
+
*
|
1581 |
+
* @return bool
|
1582 |
+
*
|
1583 |
+
* @since 1.0
|
1584 |
+
*/
|
1585 |
+
protected function get_different_connected_account( $type, $attempted_connected_accounts ) {
|
1586 |
+
return false;
|
1587 |
+
}
|
1588 |
+
|
1589 |
}
|
inc/class-sby-parse.php
CHANGED
@@ -1,258 +1,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 |
-
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 = 'high';
|
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 |
+
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 = 'high';
|
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 |
}
|
inc/class-sby-posts-manager.php
CHANGED
@@ -1,345 +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 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
} elseif ( isset( $errors['connection'] ) ) {
|
329 |
-
$error .= '<p>' . $errors['connection'][1] . '</p>';
|
330 |
-
}
|
331 |
-
} else {
|
332 |
-
$error .= '<p>' . __( 'There may be an issue with the YouTube access token that you are using. Your server might also be unable to connect to YouTube at this time.', SBY_TEXT_DOMAIN );
|
333 |
-
}
|
334 |
-
|
335 |
-
$this->add_frontend_error( 'api_delay', $error );
|
336 |
-
|
337 |
-
}
|
338 |
-
|
339 |
-
if ( ! $is_delay && $account_id ) {
|
340 |
-
$is_delay = (get_transient( SBY_BACKUP_PREFIX . $this->options_prefix . '_' . $account_id ) !== false);
|
341 |
-
}
|
342 |
-
|
343 |
-
return $is_delay;
|
344 |
-
}
|
345 |
}
|
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,112 +1,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 |
-
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 |
-
|
37 |
-
'
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
$
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
'
|
81 |
-
'
|
82 |
-
),
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
'
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
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 |
}
|
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,162 +1,163 @@
|
|
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 |
-
|
57 |
-
|
58 |
-
|
59 |
-
array_walk_recursive( $post_array, 'sby_replace_double_quotes' );
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
update_post_meta( $post_id, $prefix . '
|
84 |
-
update_post_meta( $post_id, $prefix . '
|
85 |
-
update_post_meta( $post_id, $prefix . '
|
86 |
-
update_post_meta( $post_id, $prefix . '
|
87 |
-
update_post_meta( $post_id, $prefix . '
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
$
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
$my_post
|
106 |
-
$my_post['
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
$
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
|
|
162 |
}
|
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 |
+
update_post_meta( $this->wp_post_id, $prefix . 'live_broadcast_content', SBY_Parse_Pro::get_live_broadcast_content( $this->youtube_api_data ) );
|
56 |
+
|
57 |
+
$post_array = $this->youtube_api_data;
|
58 |
+
|
59 |
+
array_walk_recursive( $post_array, 'sby_replace_double_quotes' );
|
60 |
+
|
61 |
+
update_post_meta( $this->wp_post_id, $prefix . 'json', esc_sql( wp_json_encode( $post_array ) ) );
|
62 |
+
|
63 |
+
return true;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function post_content_description_is_incomplete() {
|
67 |
+
$content = get_the_content( '', false, $this->get_wp_post_id() );
|
68 |
+
|
69 |
+
return (strpos( $content, '<!-- sby:description-incomplete -->' ) !== false);
|
70 |
+
}
|
71 |
+
|
72 |
+
public function update_video_details() {
|
73 |
+
if ( empty( $this->youtube_api_data['statistics'] ) ) {
|
74 |
+
return false;
|
75 |
+
}
|
76 |
+
|
77 |
+
$post_id = $this->get_wp_post_id();
|
78 |
+
|
79 |
+
if ( $post_id ) {
|
80 |
+
$prefix = 'sby_';
|
81 |
+
|
82 |
+
if ( class_exists( 'SBY_Parse_Pro' ) ) {
|
83 |
+
update_post_meta( $post_id, $prefix . 'comment_count', SBY_Parse_Pro::get_comment_count( $this->youtube_api_data ) );
|
84 |
+
update_post_meta( $post_id, $prefix . 'view_count', SBY_Parse_Pro::get_view_count( $this->youtube_api_data ) );
|
85 |
+
update_post_meta( $post_id, $prefix . 'like_count', SBY_Parse_Pro::get_like_count( $this->youtube_api_data ) );
|
86 |
+
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 ) ) );
|
87 |
+
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 ) ) );
|
88 |
+
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 ) ) );
|
89 |
+
}
|
90 |
+
|
91 |
+
update_post_meta( $post_id, $prefix . 'last_details_check_time', date( 'Y-m-d H:i:s' ) );
|
92 |
+
$description = SBY_Parse::get_caption( $this->youtube_api_data );
|
93 |
+
if ( ! empty( $description ) ) {
|
94 |
+
update_post_meta( $post_id, $prefix . 'description', $description );
|
95 |
+
if ( $this->post_content_description_is_incomplete() ) {
|
96 |
+
$this->update_content();
|
97 |
+
}
|
98 |
+
}
|
99 |
+
return true;
|
100 |
+
}
|
101 |
+
|
102 |
+
return false;
|
103 |
+
}
|
104 |
+
public function update_content() {
|
105 |
+
$my_post = array();
|
106 |
+
$my_post['ID'] = $this->get_wp_post_id();
|
107 |
+
$my_post['post_content'] = $this->get_post_content( true );
|
108 |
+
|
109 |
+
wp_update_post( $my_post );
|
110 |
+
}
|
111 |
+
|
112 |
+
public static function maybe_get_channel_id_for_name( $name ) {
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
public static function maybe_get_channel_id_for_channel_title( $title ) {
|
117 |
+
global $wpdb;
|
118 |
+
|
119 |
+
$channel_id = $wpdb->get_col( $wpdb->prepare( "
|
120 |
+
SELECT Max(CASE
|
121 |
+
WHEN m.meta_key = 'sby_channel_id' THEN m.meta_value
|
122 |
+
ELSE NULL
|
123 |
+
END) AS sby_channel_id
|
124 |
+
FROM $wpdb->postmeta as m
|
125 |
+
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 )
|
126 |
+
GROUP BY m.post_id
|
127 |
+
LIMIT 1", $title ) );
|
128 |
+
|
129 |
+
if ( isset( $channel_id[0] ) ) {
|
130 |
+
return $channel_id[0];
|
131 |
+
}
|
132 |
+
return false;
|
133 |
+
}
|
134 |
+
|
135 |
+
public function get_wp_post_id() {
|
136 |
+
if ( isset( $this->wp_post_id ) ) {
|
137 |
+
return $this->wp_post_id;
|
138 |
+
}
|
139 |
+
|
140 |
+
$video_id = SBY_Parse::get_video_id( $this->youtube_api_data );
|
141 |
+
|
142 |
+
global $wpdb;
|
143 |
+
$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 );
|
144 |
+
|
145 |
+
if ( isset( $results[0] ) ) {
|
146 |
+
$this->wp_post_id = $results[0]['post_id'];
|
147 |
+
|
148 |
+
return $results[0]['post_id'];
|
149 |
+
} else {
|
150 |
+
return false;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
protected function get_post_content( $override = false ) {
|
155 |
+
$description = SBY_Parse::get_caption( $this->youtube_api_data );
|
156 |
+
$flag = '';
|
157 |
+
if ( ! $override && substr( $description, -3 ) === '...' ) {
|
158 |
+
$flag = '<!-- sby:description-incomplete -->';
|
159 |
+
}
|
160 |
+
|
161 |
+
return '['.SBY_SLUG.'-single]<!-- sby:description-start -->' . wp_kses_post( $description ) . '<!-- sby:description-end -->' . $flag;
|
162 |
+
}
|
163 |
}
|
inc/sby-functions.php
CHANGED
@@ -1,836 +1,858 @@
|
|
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
|
377 |
-
|
378 |
-
if
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
<?php
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
}
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
if ( $
|
592 |
-
$file = $
|
593 |
-
} else {
|
594 |
-
$file = $generic_path . '
|
595 |
-
}
|
596 |
-
} elseif ( $part === '
|
597 |
-
if ( $
|
598 |
-
$file = $
|
599 |
-
} else {
|
600 |
-
$file = $generic_path . '
|
601 |
-
}
|
602 |
-
}
|
603 |
-
|
604 |
-
|
605 |
-
}
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
$
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
function
|
640 |
-
$
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
if (
|
660 |
-
return
|
661 |
-
} else {
|
662 |
-
return
|
663 |
-
}
|
664 |
-
}
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
* @param $
|
669 |
-
*
|
670 |
-
*
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
function
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
echo
|
772 |
-
echo "
|
773 |
-
echo
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
836 |
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 |
+
/**
|
475 |
+
* When certain events occur, page caches need to
|
476 |
+
* clear or errors occur or changes will not be seen
|
477 |
+
*/
|
478 |
+
function sby_clear_page_caches() {
|
479 |
+
if ( isset( $GLOBALS['wp_fastest_cache'] ) && method_exists( $GLOBALS['wp_fastest_cache'], 'deleteCache' ) ){
|
480 |
+
/* Clear WP fastest cache*/
|
481 |
+
$GLOBALS['wp_fastest_cache']->deleteCache();
|
482 |
+
}
|
483 |
+
|
484 |
+
if ( function_exists( 'wp_cache_clear_cache' ) ) {
|
485 |
+
wp_cache_clear_cache();
|
486 |
+
}
|
487 |
+
|
488 |
+
if ( class_exists('W3_Plugin_TotalCacheAdmin') ) {
|
489 |
+
$plugin_totalcacheadmin = & w3_instance('W3_Plugin_TotalCacheAdmin');
|
490 |
+
|
491 |
+
$plugin_totalcacheadmin->flush_all();
|
492 |
+
}
|
493 |
+
|
494 |
+
if ( function_exists( 'rocket_clean_domain' ) ) {
|
495 |
+
rocket_clean_domain();
|
496 |
+
}
|
497 |
+
|
498 |
+
if ( class_exists( 'autoptimizeCache' ) ) {
|
499 |
+
/* Clear autoptimize */
|
500 |
+
autoptimizeCache::clearall();
|
501 |
+
}
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Triggered by a cron event to update feeds
|
506 |
+
*/
|
507 |
+
function sby_cron_updater() {
|
508 |
+
global $sby_settings;
|
509 |
+
|
510 |
+
if ( $sby_settings['caching_type'] === 'background' ) {
|
511 |
+
SBY_Cron_Updater::do_feed_updates();
|
512 |
+
}
|
513 |
+
|
514 |
+
}
|
515 |
+
add_action( 'sby_feed_update', 'sby_cron_updater' );
|
516 |
+
|
517 |
+
function sby_update_or_connect_account( $args ) {
|
518 |
+
global $sby_settings;
|
519 |
+
$account_id = $args['channel_id'];
|
520 |
+
$sby_settings['connected_accounts'][ $account_id ] = array(
|
521 |
+
'access_token' => $args['access_token'],
|
522 |
+
'refresh_token' => $args['refresh_token'],
|
523 |
+
'channel_id' => $args['channel_id'],
|
524 |
+
'username' => $args['username'],
|
525 |
+
'is_valid' => true,
|
526 |
+
'last_checked' => time(),
|
527 |
+
'profile_picture' => $args['profile_picture'],
|
528 |
+
'privacy' => $args['privacy'],
|
529 |
+
'expires' => $args['expires']
|
530 |
+
);
|
531 |
+
|
532 |
+
update_option( 'sby_settings', $sby_settings );
|
533 |
+
|
534 |
+
return $sby_settings['connected_accounts'][ $account_id ];
|
535 |
+
}
|
536 |
+
|
537 |
+
function sby_get_first_connected_account() {
|
538 |
+
global $sby_settings;
|
539 |
+
$an_account = array();
|
540 |
+
|
541 |
+
if ( ! empty( $sby_settings['api_key'] ) ) {
|
542 |
+
$an_account = array(
|
543 |
+
'access_token' => '',
|
544 |
+
'refresh_token' => '',
|
545 |
+
'channel_id' => '',
|
546 |
+
'username' => '',
|
547 |
+
'is_valid' => true,
|
548 |
+
'last_checked' => '',
|
549 |
+
'profile_picture' => '',
|
550 |
+
'privacy' => '',
|
551 |
+
'expires' => '2574196927',
|
552 |
+
'api_key' => $sby_settings['api_key']
|
553 |
+
);
|
554 |
+
} else {
|
555 |
+
$connected_accounts = $sby_settings['connected_accounts'];
|
556 |
+
foreach ( $connected_accounts as $account ) {
|
557 |
+
if ( empty( $an_account ) ) {
|
558 |
+
$an_account = $account;
|
559 |
+
}
|
560 |
+
}
|
561 |
+
}
|
562 |
+
|
563 |
+
if ( empty( $an_account ) ) {
|
564 |
+
$an_account = array( 'rss_only' => true );
|
565 |
+
}
|
566 |
+
|
567 |
+
return $an_account;
|
568 |
+
}
|
569 |
+
|
570 |
+
function sby_get_feed_template_part( $part, $settings = array() ) {
|
571 |
+
$file = '';
|
572 |
+
|
573 |
+
$using_custom_templates_in_theme = apply_filters( 'sby_use_theme_templates', $settings['customtemplates'] );
|
574 |
+
$generic_path = trailingslashit( SBY_PLUGIN_DIR ) . 'templates/';
|
575 |
+
|
576 |
+
if ( $using_custom_templates_in_theme ) {
|
577 |
+
$custom_header_template = locate_template( 'sby/header.php', false, false );
|
578 |
+
$custom_player_template = locate_template( 'sby/player.php', false, false );
|
579 |
+
$custom_item_template = locate_template( 'sby/item.php', false, false );
|
580 |
+
$custom_footer_template = locate_template( 'sby/footer.php', false, false );
|
581 |
+
$custom_feed_template = locate_template( 'sby/feed.php', false, false );
|
582 |
+
} else {
|
583 |
+
$custom_header_template = false;
|
584 |
+
$custom_player_template = false;
|
585 |
+
$custom_item_template = false;
|
586 |
+
$custom_footer_template = false;
|
587 |
+
$custom_feed_template = false;
|
588 |
+
}
|
589 |
+
|
590 |
+
if ( $part === 'header' ) {
|
591 |
+
if ( $custom_header_template ) {
|
592 |
+
$file = $custom_header_template;
|
593 |
+
} else {
|
594 |
+
$file = $generic_path . 'header.php';
|
595 |
+
}
|
596 |
+
} elseif ( $part === 'player' ) {
|
597 |
+
if ( $custom_player_template ) {
|
598 |
+
$file = $custom_player_template;
|
599 |
+
} else {
|
600 |
+
$file = $generic_path . 'player.php';
|
601 |
+
}
|
602 |
+
} elseif ( $part === 'item' ) {
|
603 |
+
if ( $custom_item_template ) {
|
604 |
+
$file = $custom_item_template;
|
605 |
+
} else {
|
606 |
+
$file = $generic_path . 'item.php';
|
607 |
+
}
|
608 |
+
} elseif ( $part === 'footer' ) {
|
609 |
+
if ( $custom_footer_template ) {
|
610 |
+
$file = $custom_footer_template;
|
611 |
+
} else {
|
612 |
+
$file = $generic_path . 'footer.php';
|
613 |
+
}
|
614 |
+
} elseif ( $part === 'feed' ) {
|
615 |
+
if ( $custom_feed_template ) {
|
616 |
+
$file = $custom_feed_template;
|
617 |
+
} else {
|
618 |
+
$file = $generic_path . 'feed.php';
|
619 |
+
}
|
620 |
+
}
|
621 |
+
|
622 |
+
return $file;
|
623 |
+
}
|
624 |
+
|
625 |
+
/**
|
626 |
+
* Get the settings in the database with defaults
|
627 |
+
*
|
628 |
+
* @return array
|
629 |
+
*/
|
630 |
+
function sby_get_database_settings() {
|
631 |
+
global $sby_settings;
|
632 |
+
|
633 |
+
$defaults = sby_settings_defaults();
|
634 |
+
|
635 |
+
return array_merge( $defaults, $sby_settings );
|
636 |
+
}
|
637 |
+
|
638 |
+
|
639 |
+
function sby_get_channel_id_from_channel_name( $channel_name ) {
|
640 |
+
$channel_ids = get_option( 'sby_channel_ids', array() );
|
641 |
+
|
642 |
+
if ( isset( $channel_ids[ strtolower( $channel_name ) ] ) ) {
|
643 |
+
return $channel_ids[ strtolower( $channel_name ) ];
|
644 |
+
}
|
645 |
+
|
646 |
+
return false;
|
647 |
+
}
|
648 |
+
|
649 |
+
function sby_set_channel_id_from_channel_name( $channel_name, $channel_id ) {
|
650 |
+
$channel_ids = get_option( 'sby_channel_ids', array() );
|
651 |
+
|
652 |
+
$channel_ids[ strtolower( $channel_name ) ] = $channel_id;
|
653 |
+
|
654 |
+
update_option( 'sby_channel_ids', $channel_ids, false );
|
655 |
+
}
|
656 |
+
|
657 |
+
function sby_icon( $icon, $class = '' ) {
|
658 |
+
$class = ! empty( $class ) ? ' ' . trim( $class ) : '';
|
659 |
+
if ( $icon === SBY_SLUG ) {
|
660 |
+
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>';
|
661 |
+
} else {
|
662 |
+
return '<i aria-hidden="true" role="img" class="fab fa-youtube"></i>';
|
663 |
+
}
|
664 |
+
}
|
665 |
+
|
666 |
+
|
667 |
+
/**
|
668 |
+
* @param $a
|
669 |
+
* @param $b
|
670 |
+
*
|
671 |
+
* @return false|int
|
672 |
+
*/
|
673 |
+
function sby_date_sort( $a, $b ) {
|
674 |
+
$time_stamp_a = SBY_Parse::get_timestamp( $a );
|
675 |
+
$time_stamp_b = SBY_Parse::get_timestamp( $b );
|
676 |
+
|
677 |
+
if ( isset( $time_stamp_a ) ) {
|
678 |
+
return $time_stamp_b - $time_stamp_a;
|
679 |
+
} else {
|
680 |
+
return rand ( -1, 1 );
|
681 |
+
}
|
682 |
+
}
|
683 |
+
|
684 |
+
/**
|
685 |
+
* @param $a
|
686 |
+
* @param $b
|
687 |
+
*
|
688 |
+
* @return false|int
|
689 |
+
*/
|
690 |
+
function sby_rand_sort( $a, $b ) {
|
691 |
+
return rand ( -1, 1 );
|
692 |
+
}
|
693 |
+
|
694 |
+
/**
|
695 |
+
* Converts a hex code to RGB so opacity can be
|
696 |
+
* applied more easily
|
697 |
+
*
|
698 |
+
* @param $hex
|
699 |
+
*
|
700 |
+
* @return string
|
701 |
+
*/
|
702 |
+
function sby_hextorgb( $hex ) {
|
703 |
+
// allows someone to use rgb in shortcode
|
704 |
+
if ( strpos( $hex, ',' ) !== false ) {
|
705 |
+
return $hex;
|
706 |
+
}
|
707 |
+
|
708 |
+
$hex = str_replace( '#', '', $hex );
|
709 |
+
|
710 |
+
if ( strlen( $hex ) === 3 ) {
|
711 |
+
$r = hexdec( substr( $hex,0,1 ).substr( $hex,0,1 ) );
|
712 |
+
$g = hexdec( substr( $hex,1,1 ).substr( $hex,1,1 ) );
|
713 |
+
$b = hexdec( substr( $hex,2,1 ).substr( $hex,2,1 ) );
|
714 |
+
} else {
|
715 |
+
$r = hexdec( substr( $hex,0,2 ) );
|
716 |
+
$g = hexdec( substr( $hex,2,2 ) );
|
717 |
+
$b = hexdec( substr( $hex,4,2 ) );
|
718 |
+
}
|
719 |
+
$rgb = array( $r, $g, $b );
|
720 |
+
|
721 |
+
return implode( ',', $rgb ); // returns the rgb values separated by commas
|
722 |
+
}
|
723 |
+
|
724 |
+
function sby_get_utc_offset() {
|
725 |
+
return get_option( 'gmt_offset', 0 ) * HOUR_IN_SECONDS;
|
726 |
+
}
|
727 |
+
|
728 |
+
function sby_is_pro_version() {
|
729 |
+
return defined( 'SBY_PLUGIN_EDD_NAME' );
|
730 |
+
}
|
731 |
+
|
732 |
+
function sby_strip_after_hash( $string ) {
|
733 |
+
$string_array = explode( '#', $string );
|
734 |
+
$finished_string = $string_array[0];
|
735 |
+
|
736 |
+
return $finished_string;
|
737 |
+
}
|
738 |
+
|
739 |
+
function sby_get_account_bottom() {
|
740 |
+
return '';
|
741 |
+
}
|
742 |
+
|
743 |
+
function sby_get_account_top() {
|
744 |
+
return '';
|
745 |
+
}
|
746 |
+
|
747 |
+
function sby_replace_double_quotes( &$element, $index ) {
|
748 |
+
$element = str_replace( '"', """, $element );
|
749 |
+
}
|
750 |
+
|
751 |
+
/**
|
752 |
+
* Adds the ajax url and custom JavaScript to the page
|
753 |
+
*/
|
754 |
+
function sby_custom_js() {
|
755 |
+
global $sby_settings;
|
756 |
+
|
757 |
+
$js = isset( $sby_settings['custom_js'] ) ? trim( $sby_settings['custom_js'] ) : '';
|
758 |
+
|
759 |
+
echo '<!-- YouTube Feed JS -->';
|
760 |
+
echo "\r\n";
|
761 |
+
echo '<script type="text/javascript">';
|
762 |
+
echo "\r\n";
|
763 |
+
|
764 |
+
if ( ! empty( $js ) ) {
|
765 |
+
echo "\r\n";
|
766 |
+
echo "jQuery( document ).ready(function($) {";
|
767 |
+
echo "\r\n";
|
768 |
+
echo "window.sbyCustomJS = function(){";
|
769 |
+
echo "\r\n";
|
770 |
+
echo stripslashes($js);
|
771 |
+
echo "\r\n";
|
772 |
+
echo "}";
|
773 |
+
echo "\r\n";
|
774 |
+
echo "});";
|
775 |
+
}
|
776 |
+
|
777 |
+
echo "\r\n";
|
778 |
+
echo '</script>';
|
779 |
+
echo "\r\n";
|
780 |
+
}
|
781 |
+
add_action( 'wp_footer', 'sby_custom_js' );
|
782 |
+
|
783 |
+
//Custom CSS
|
784 |
+
add_action( 'wp_head', 'sby_custom_css' );
|
785 |
+
function sby_custom_css() {
|
786 |
+
global $sby_settings;
|
787 |
+
|
788 |
+
$css = isset( $sby_settings['custom_css'] ) ? trim( $sby_settings['custom_css'] ) : '';
|
789 |
+
|
790 |
+
//Show CSS if an admin (so can see Hide Photos link), if including Custom CSS or if hiding some photos
|
791 |
+
if ( current_user_can( 'manage_youtube_feed_options' ) || current_user_can( 'manage_options' ) || ! empty( $css ) ) {
|
792 |
+
|
793 |
+
echo '<!-- Instagram Feed CSS -->';
|
794 |
+
echo "\r\n";
|
795 |
+
echo '<style type="text/css">';
|
796 |
+
|
797 |
+
if ( ! empty( $css ) ){
|
798 |
+
echo "\r\n";
|
799 |
+
echo stripslashes($css);
|
800 |
+
}
|
801 |
+
|
802 |
+
if ( current_user_can( 'manage_youtube_feed_options' ) || current_user_can( 'manage_options' ) ){
|
803 |
+
echo "\r\n";
|
804 |
+
echo "#sby_mod_link, #sby_mod_error{ display: block !important; width: 100%; float: left; box-sizing: border-box; }";
|
805 |
+
}
|
806 |
+
|
807 |
+
echo "\r\n";
|
808 |
+
echo '</style>';
|
809 |
+
echo "\r\n";
|
810 |
+
}
|
811 |
+
|
812 |
+
}
|
813 |
+
|
814 |
+
/**
|
815 |
+
* Makes the JavaScript file available and enqueues the stylesheet
|
816 |
+
* for the plugin
|
817 |
+
*/
|
818 |
+
function sby_scripts_enqueue( $enqueue = false ) {
|
819 |
+
//Register the script to make it available
|
820 |
+
|
821 |
+
//Options to pass to JS file
|
822 |
+
global $sby_settings;
|
823 |
+
|
824 |
+
$js_file = 'js/sb-youtube.min.js';
|
825 |
+
if ( isset( $_GET['sby_debug'] ) ) {
|
826 |
+
$js_file = 'js/sb-youtube.js';
|
827 |
+
}
|
828 |
+
|
829 |
+
if ( isset( $sby_settings['enqueue_js_in_head'] ) && $sby_settings['enqueue_js_in_head'] ) {
|
830 |
+
wp_enqueue_script( 'sby_scripts', trailingslashit( SBY_PLUGIN_URL ) . $js_file, array('jquery'), SBYVER, false );
|
831 |
+
} else {
|
832 |
+
wp_register_script( 'sby_scripts', trailingslashit( SBY_PLUGIN_URL ) . $js_file, array('jquery'), SBYVER, true );
|
833 |
+
}
|
834 |
+
|
835 |
+
if ( isset( $sby_settings['enqueue_css_in_shortcode'] ) && $sby_settings['enqueue_css_in_shortcode'] ) {
|
836 |
+
wp_register_style( 'sby_styles', trailingslashit( SBY_PLUGIN_URL ) . 'css/sb-youtube.min.css', array(), SBYVER );
|
837 |
+
} else {
|
838 |
+
wp_enqueue_style( 'sby_styles', trailingslashit( SBY_PLUGIN_URL ) . 'css/sb-youtube.min.css', array(), SBYVER );
|
839 |
+
}
|
840 |
+
$data = array(
|
841 |
+
'adminAjaxUrl' => admin_url( 'admin-ajax.php' ),
|
842 |
+
'placeholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder.png',
|
843 |
+
'placeholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/placeholder-narrow.png',
|
844 |
+
'lightboxPlaceholder' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder.png',
|
845 |
+
'lightboxPlaceholderNarrow' => trailingslashit( SBY_PLUGIN_URL ) . 'img/lightbox-placeholder-narrow.png',
|
846 |
+
'autoplay' => $sby_settings['playvideo'] === 'automatically',
|
847 |
+
'semiEagerload' => false,
|
848 |
+
'eagerload' => $sby_settings['eagerload']
|
849 |
+
);
|
850 |
+
//Pass option to JS file
|
851 |
+
wp_localize_script('sby_scripts', 'sbyOptions', $data );
|
852 |
+
|
853 |
+
if ( $enqueue ) {
|
854 |
+
wp_enqueue_style( 'sby_styles' );
|
855 |
+
wp_enqueue_script( 'sby_scripts' );
|
856 |
+
}
|
857 |
+
}
|
858 |
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.js
CHANGED
@@ -1,745 +1,745 @@
|
|
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,'>'),
|
417 |
-
encoded = encoded.replace(/(<)/g,'<');
|
418 |
-
encoded = encoded.replace(/(<br\/>)/g,'<br>');
|
419 |
-
encoded = encoded.replace(/(<br>)/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 |
-
$('.sby_api_key_needed').each(function() {
|
494 |
-
$(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>');
|
495 |
-
});
|
496 |
-
|
497 |
-
var proJustHoverHTML = '<a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank" class="sbspf_lock sbspf_pro_lock"><i class="fa fa-rocket"></i>Pro</a>',
|
498 |
-
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,
|
499 |
-
proAvailableHTML = '<span class="sbspf_note"> - <a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank">Available in Pro version</a></span>';
|
500 |
-
|
501 |
-
$('.sbspf_pro_only').each(function() {
|
502 |
-
if (jQuery(this).closest('td').find('.sbspf_sub_options').length) {
|
503 |
-
if (!jQuery(this).closest('td').find('.sbspf_lock').length) {
|
504 |
-
jQuery(this).closest('td').find('.sbspf_sub_options').append(proLockHTML);
|
505 |
-
}
|
506 |
-
jQuery(this).closest('td').find('input,select,textarea').each(function() {
|
507 |
-
if (typeof jQuery(this).attr('name') !== 'undefined') {
|
508 |
-
jQuery(this).attr('name',jQuery(this).attr('name').replace('sb','demosb'));
|
509 |
-
}
|
510 |
-
});
|
511 |
-
if (jQuery(this).html() === '') {
|
512 |
-
jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
|
513 |
-
if (jQuery(this).html() === '') {
|
514 |
-
jQuery(this).remove();
|
515 |
-
}
|
516 |
-
}
|
517 |
-
} else if (jQuery(this).hasClass('sbspf_layout_cell')) {
|
518 |
-
if (!jQuery(this).find('.sbspf_lock').length) {
|
519 |
-
jQuery(this).append(proJustHoverHTML);
|
520 |
-
jQuery(this).find('img').css('opacity', .4);
|
521 |
-
}
|
522 |
-
} else if (jQuery(this).hasClass('sbspf_layout_settings')){
|
523 |
-
if (!jQuery(this).find('.sbspf_lock').length) {
|
524 |
-
jQuery(this).find('.sbspf_layout_setting').first().append('<span class="sbspf_note"><a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank">Upgrade to Pro to enable the carousel layout</a></span>');
|
525 |
-
jQuery(this).find('input,select,textarea').attr('disabled','true');
|
526 |
-
}
|
527 |
-
} else {
|
528 |
-
if (jQuery(this).closest('td').find('.sbspf_single_checkbox').length
|
529 |
-
&& ! jQuery(this).closest('td').find('.sbspf_lock').length){
|
530 |
-
jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
|
531 |
-
jQuery(this).closest('tr').find('.sbspf_single_checkbox').next('label').after(proAvailableHTML);
|
532 |
-
if (jQuery(this).html() === '') {
|
533 |
-
jQuery(this).remove();
|
534 |
-
}
|
535 |
-
} else if (jQuery(this).closest('td').find('select.sbspf_pro_only').length
|
536 |
-
&& ! jQuery(this).closest('td').find('.sbspf_lock').length){
|
537 |
-
jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
|
538 |
-
jQuery(this).closest('tr').find('select.sbspf_pro_only').after(proAvailableHTML);
|
539 |
-
if (jQuery(this).html() === '') {
|
540 |
-
jQuery(this).remove();
|
541 |
-
}
|
542 |
-
}else if (jQuery(this).find('input[type=checkbox]').length) {
|
543 |
-
var $closestTD = jQuery(this).closest('td');
|
544 |
-
jQuery(this).find('input').attr('disabled','true');
|
545 |
-
if (jQuery(this).find('input').is(':checked')) {
|
546 |
-
var $clone = jQuery(this).find('input').clone();
|
547 |
-
$clone.removeAttr('disabled').removeAttr('checked').attr('type','hidden');
|
548 |
-
jQuery(this).append($clone);
|
549 |
-
}
|
550 |
-
jQuery(this).find('input').removeAttr('checked');
|
551 |
-
if (!$closestTD.find('.sbspf_disabled_wrap').length) {
|
552 |
-
$closestTD.append('<div class="sbspf_disabled_wrap sby_includes_pro_only"></div>');
|
553 |
-
$closestTD.find('.sby_includes_pro_only').append('<span class="sbspf_note"><a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank">Upgrade to Pro to display video descriptions, dates, statistics, live streaming information, and more.</a></span>');
|
554 |
-
}
|
555 |
-
}
|
556 |
-
|
557 |
-
}
|
558 |
-
});
|
559 |
-
|
560 |
-
var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
|
561 |
-
$closestTD.append('<div class="sbspf_disabled_wrap sby_types_disabled_wrap">'+proLockHTML+'</div>');
|
562 |
-
|
563 |
-
$('.sbspf_type_row').each(function() {
|
564 |
-
if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
|
565 |
-
$('.sbspf_disabled_wrap').append($(this));
|
566 |
-
$(this).find('input').attr('disabled',true);
|
567 |
-
} else {
|
568 |
-
$(this).find('input').removeAttr('disabled');
|
569 |
-
}
|
570 |
-
});
|
571 |
-
|
572 |
-
$('.sbspf_pro_section').each(function() {
|
573 |
-
if ($(this).find('.sbspf_pro_reveal').length) {
|
574 |
-
$(this).find('h2').first().after($(this).find('.sbspf_pro_reveal'));
|
575 |
-
$(this).find('tr').addClass('sbspf_pro_only_row');
|
576 |
-
var $table = $(this).find('table');
|
577 |
-
$table.hide();
|
578 |
-
$(this).find('.sbspf-show-pro').click(function(event){
|
579 |
-
event.preventDefault();
|
580 |
-
$table.toggle();
|
581 |
-
});
|
582 |
-
jQuery(this).find('input,select,textarea').each(function() {
|
583 |
-
if (typeof jQuery(this).attr('name') !== 'undefined') {
|
584 |
-
jQuery(this).attr('name',jQuery(this).attr('name').replace('sb','demosb'));
|
585 |
-
}
|
586 |
-
});
|
587 |
-
}
|
588 |
-
});
|
589 |
-
|
590 |
-
jQuery('.sbspf_pro_lock').hover(function(){
|
591 |
-
jQuery(this).siblings('.sbspf_pro_tooltip').show();
|
592 |
-
}, function(){
|
593 |
-
jQuery('.sbspf_pro_tooltip').hide();
|
594 |
-
});
|
595 |
-
|
596 |
-
};
|
597 |
-
|
598 |
-
this.toggleCustomDateField = function() {
|
599 |
-
if ($('#sby_settings_dateformat').val() === 'custom') {
|
600 |
-
$('.sby_customdate_wrap').slideDown();
|
601 |
-
} else {
|
602 |
-
$('.sby_customdate_wrap').slideUp();
|
603 |
-
}
|
604 |
-
};
|
605 |
-
|
606 |
-
this.toggleAPIKeyWarnings = function() {
|
607 |
-
if ($('#sby_api_key').val() !== '') {
|
608 |
-
if ($('.sby_disabled_wrap').length) {
|
609 |
-
var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
|
610 |
-
$('.sbspf_type_row').each(function() {
|
611 |
-
if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
|
612 |
-
$closestTD.append($(this));
|
613 |
-
$(this).find('input').removeAttr('disabled');
|
614 |
-
}
|
615 |
-
});
|
616 |
-
$('.sby_disabled_wrap').remove();
|
617 |
-
}
|
618 |
-
|
619 |
-
|
620 |
-
} else if (!$('.sby_disabled_wrap').length) {
|
621 |
-
var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
|
622 |
-
$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>');
|
623 |
-
|
624 |
-
$('.sbspf_type_row').each(function() {
|
625 |
-
if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
|
626 |
-
$('.sby_disabled_wrap').append($(this));
|
627 |
-
$(this).find('input').attr('disabled',true);
|
628 |
-
} else {
|
629 |
-
$(this).find('input').removeAttr('disabled');
|
630 |
-
}
|
631 |
-
});
|
632 |
-
}
|
633 |
-
|
634 |
-
};
|
635 |
-
|
636 |
-
this.addAccessTokenListener = function () {
|
637 |
-
var self = this;
|
638 |
-
if (window.location.hash.length > 5 && window.location.hash.indexOf(this.accesstokenSplitter) > -1) {
|
639 |
-
var accessToken = window.location.hash.split(this.accesstokenSplitter);
|
640 |
-
// clear access token from hash
|
641 |
-
window.location.hash = '';
|
642 |
-
var submitData = {
|
643 |
-
'access_token' : accessToken[1],
|
644 |
-
'action' : 'sby_process_access_token',
|
645 |
-
'sbspf_nonce' : sbspf.nonce
|
646 |
-
};
|
647 |
-
var onSuccess = function (data) {
|
648 |
-
if (data.trim().indexOf('{') === 0) {
|
649 |
-
var returnObj = JSON.parse(data.trim());
|
650 |
-
$('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
|
651 |
-
self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
|
652 |
-
self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
|
653 |
-
}
|
654 |
-
};
|
655 |
-
sbAjax(submitData,onSuccess);
|
656 |
-
}
|
657 |
-
};
|
658 |
-
|
659 |
-
this.addManualAccessTokenListener = function() {
|
660 |
-
var self = this,
|
661 |
-
id = '#'+this.plugin,
|
662 |
-
cla = '.'+this.plugin;
|
663 |
-
|
664 |
-
$(cla+'_manually_connect_wrap').hide();
|
665 |
-
$(cla+'_manually_connect').click(function(event) {
|
666 |
-
event.preventDefault();
|
667 |
-
if ( $(cla+'_manually_connect_wrap').is(':visible') ) {
|
668 |
-
$(cla+'_manually_connect_wrap').slideUp(200);
|
669 |
-
} else {
|
670 |
-
$(cla+'_manually_connect_wrap').slideDown(200);
|
671 |
-
$(id+'_manual_at').focus();
|
672 |
-
}
|
673 |
-
});
|
674 |
-
|
675 |
-
$(id+'_manual_submit').click(function(event) {
|
676 |
-
event.preventDefault();
|
677 |
-
var $self = $(this);
|
678 |
-
var accessToken = $(id+'_manual_at').val(),
|
679 |
-
refreshToken = $(id+'_manual_rt').val(),
|
680 |
-
error = false;
|
681 |
-
|
682 |
-
if (accessToken.length < 15) {
|
683 |
-
if (!$(cla+'_manually_connect_wrap').find(cla+'_user_id_error').length) {
|
684 |
-
$(cla+'_manually_connect_wrap').show().prepend('<div class="'+self.plugin+'_user_id_error" style="display:block;">Please enter a valid access token</div>');
|
685 |
-
}
|
686 |
-
} else if (! error) {
|
687 |
-
$(this).attr('disabled',true);
|
688 |
-
$(this).closest(cla+'_manually_connect_wrap').fadeOut();
|
689 |
-
$(cla+'_connected_accounts_wrap').fadeTo("slow" , 0.5).find(cla+'_user_id_error').remove();
|
690 |
-
|
691 |
-
var submitData = {
|
692 |
-
'sby_access_token' : accessToken,
|
693 |
-
'sby_refresh_token' : refreshToken,
|
694 |
-
'action' : 'sby_process_access_token',
|
695 |
-
'sbspf_nonce' : sbspf.nonce
|
696 |
-
};
|
697 |
-
var onSuccess = function (data) {
|
698 |
-
$(cla+'_connected_accounts_wrap').fadeTo("slow" , 1);
|
699 |
-
$self.removeAttr('disabled');
|
700 |
-
if (data.trim().indexOf('{') === 0) {
|
701 |
-
var returnObj = JSON.parse(data.trim());
|
702 |
-
if (typeof returnObj.error === 'undefined') {
|
703 |
-
if (!$('#sbspf_connected_account_'+returnObj.account_id).length) {
|
704 |
-
$('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
|
705 |
-
self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
|
706 |
-
self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
|
707 |
-
console.log('added');
|
708 |
-
} else {
|
709 |
-
$('#sbspf_connected_account_'+returnObj.account_id).replaceWith(returnObj.html);
|
710 |
-
self.initClickRemove($('#sbspf_connected_account_'+returnObj.account_id));
|
711 |
-
self.initInfoToggle($('#sbspf_connected_account_'+returnObj.account_id));
|
712 |
-
console.log('updated');
|
713 |
-
}
|
714 |
-
} else {
|
715 |
-
alert(returnObj.error);
|
716 |
-
}
|
717 |
-
}
|
718 |
-
|
719 |
-
};
|
720 |
-
sbAjax(submitData,onSuccess);
|
721 |
-
}
|
722 |
-
|
723 |
-
});
|
724 |
-
};
|
725 |
-
this.getAction = function(action) {
|
726 |
-
return 'sby_' + action;
|
727 |
-
};
|
728 |
-
|
729 |
-
}
|
730 |
-
|
731 |
-
SbYoutubeAdmin.prototype = Object.create(SbspfAdmin.prototype);
|
732 |
-
|
733 |
-
|
734 |
-
window.sby_admin_init = function() {
|
735 |
-
var plugin = typeof $('.sbspf-admin').attr('data-sb-plugin') !== 'undefined' ? $('.sbspf-admin').attr('data-sb-plugin') : 'sbspf',
|
736 |
-
$adminEl = $('#sbspf_admin.sby_admin');
|
737 |
-
window.sb = new SbYoutubeAdmin(plugin,$adminEl);
|
738 |
-
window.sb.init();
|
739 |
-
};
|
740 |
-
|
741 |
-
})(jQuery);
|
742 |
-
|
743 |
-
jQuery(document).ready(function($) {
|
744 |
-
sby_admin_init();
|
745 |
});
|
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,'>'),
|
417 |
+
encoded = encoded.replace(/(<)/g,'<');
|
418 |
+
encoded = encoded.replace(/(<br\/>)/g,'<br>');
|
419 |
+
encoded = encoded.replace(/(<br>)/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 |
+
$('.sby_api_key_needed').each(function() {
|
494 |
+
$(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>');
|
495 |
+
});
|
496 |
+
|
497 |
+
var proJustHoverHTML = '<a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank" class="sbspf_lock sbspf_pro_lock"><i class="fa fa-rocket"></i>Pro</a>',
|
498 |
+
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,
|
499 |
+
proAvailableHTML = '<span class="sbspf_note"> - <a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank">Available in Pro version</a></span>';
|
500 |
+
|
501 |
+
$('.sbspf_pro_only').each(function() {
|
502 |
+
if (jQuery(this).closest('td').find('.sbspf_sub_options').length) {
|
503 |
+
if (!jQuery(this).closest('td').find('.sbspf_lock').length) {
|
504 |
+
jQuery(this).closest('td').find('.sbspf_sub_options').append(proLockHTML);
|
505 |
+
}
|
506 |
+
jQuery(this).closest('td').find('input,select,textarea').each(function() {
|
507 |
+
if (typeof jQuery(this).attr('name') !== 'undefined') {
|
508 |
+
jQuery(this).attr('name',jQuery(this).attr('name').replace('sb','demosb'));
|
509 |
+
}
|
510 |
+
});
|
511 |
+
if (jQuery(this).html() === '') {
|
512 |
+
jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
|
513 |
+
if (jQuery(this).html() === '') {
|
514 |
+
jQuery(this).remove();
|
515 |
+
}
|
516 |
+
}
|
517 |
+
} else if (jQuery(this).hasClass('sbspf_layout_cell')) {
|
518 |
+
if (!jQuery(this).find('.sbspf_lock').length) {
|
519 |
+
jQuery(this).append(proJustHoverHTML);
|
520 |
+
jQuery(this).find('img').css('opacity', .4);
|
521 |
+
}
|
522 |
+
} else if (jQuery(this).hasClass('sbspf_layout_settings')){
|
523 |
+
if (!jQuery(this).find('.sbspf_lock').length) {
|
524 |
+
jQuery(this).find('.sbspf_layout_setting').first().append('<span class="sbspf_note"><a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank">Upgrade to Pro to enable the carousel layout</a></span>');
|
525 |
+
jQuery(this).find('input,select,textarea').attr('disabled','true');
|
526 |
+
}
|
527 |
+
} else {
|
528 |
+
if (jQuery(this).closest('td').find('.sbspf_single_checkbox').length
|
529 |
+
&& ! jQuery(this).closest('td').find('.sbspf_lock').length){
|
530 |
+
jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
|
531 |
+
jQuery(this).closest('tr').find('.sbspf_single_checkbox').next('label').after(proAvailableHTML);
|
532 |
+
if (jQuery(this).html() === '') {
|
533 |
+
jQuery(this).remove();
|
534 |
+
}
|
535 |
+
} else if (jQuery(this).closest('td').find('select.sbspf_pro_only').length
|
536 |
+
&& ! jQuery(this).closest('td').find('.sbspf_lock').length){
|
537 |
+
jQuery(this).closest('tr').addClass('sbspf_pro_only_row');
|
538 |
+
jQuery(this).closest('tr').find('select.sbspf_pro_only').after(proAvailableHTML);
|
539 |
+
if (jQuery(this).html() === '') {
|
540 |
+
jQuery(this).remove();
|
541 |
+
}
|
542 |
+
}else if (jQuery(this).find('input[type=checkbox]').length) {
|
543 |
+
var $closestTD = jQuery(this).closest('td');
|
544 |
+
jQuery(this).find('input').attr('disabled','true');
|
545 |
+
if (jQuery(this).find('input').is(':checked')) {
|
546 |
+
var $clone = jQuery(this).find('input').clone();
|
547 |
+
$clone.removeAttr('disabled').removeAttr('checked').attr('type','hidden');
|
548 |
+
jQuery(this).append($clone);
|
549 |
+
}
|
550 |
+
jQuery(this).find('input').removeAttr('checked');
|
551 |
+
if (!$closestTD.find('.sbspf_disabled_wrap').length) {
|
552 |
+
$closestTD.append('<div class="sbspf_disabled_wrap sby_includes_pro_only"></div>');
|
553 |
+
$closestTD.find('.sby_includes_pro_only').append('<span class="sbspf_note"><a href="https://smashballoon.com/youtube-feed/?utm_source=plugin-free&utm_campaign=sby" target="_blank">Upgrade to Pro to display video descriptions, dates, statistics, live streaming information, and more.</a></span>');
|
554 |
+
}
|
555 |
+
}
|
556 |
+
|
557 |
+
}
|
558 |
+
});
|
559 |
+
|
560 |
+
var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
|
561 |
+
$closestTD.append('<div class="sbspf_disabled_wrap sby_types_disabled_wrap">'+proLockHTML+'</div>');
|
562 |
+
|
563 |
+
$('.sbspf_type_row').each(function() {
|
564 |
+
if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
|
565 |
+
$('.sbspf_disabled_wrap').append($(this));
|
566 |
+
$(this).find('input').attr('disabled',true);
|
567 |
+
} else {
|
568 |
+
$(this).find('input').removeAttr('disabled');
|
569 |
+
}
|
570 |
+
});
|
571 |
+
|
572 |
+
$('.sbspf_pro_section').each(function() {
|
573 |
+
if ($(this).find('.sbspf_pro_reveal').length) {
|
574 |
+
$(this).find('h2').first().after($(this).find('.sbspf_pro_reveal'));
|
575 |
+
$(this).find('tr').addClass('sbspf_pro_only_row');
|
576 |
+
var $table = $(this).find('table');
|
577 |
+
$table.hide();
|
578 |
+
$(this).find('.sbspf-show-pro').click(function(event){
|
579 |
+
event.preventDefault();
|
580 |
+
$table.toggle();
|
581 |
+
});
|
582 |
+
jQuery(this).find('input,select,textarea').each(function() {
|
583 |
+
if (typeof jQuery(this).attr('name') !== 'undefined') {
|
584 |
+
jQuery(this).attr('name',jQuery(this).attr('name').replace('sb','demosb'));
|
585 |
+
}
|
586 |
+
});
|
587 |
+
}
|
588 |
+
});
|
589 |
+
|
590 |
+
jQuery('.sbspf_pro_lock').hover(function(){
|
591 |
+
jQuery(this).siblings('.sbspf_pro_tooltip').show();
|
592 |
+
}, function(){
|
593 |
+
jQuery('.sbspf_pro_tooltip').hide();
|
594 |
+
});
|
595 |
+
|
596 |
+
};
|
597 |
+
|
598 |
+
this.toggleCustomDateField = function() {
|
599 |
+
if ($('#sby_settings_dateformat').val() === 'custom') {
|
600 |
+
$('.sby_customdate_wrap').slideDown();
|
601 |
+
} else {
|
602 |
+
$('.sby_customdate_wrap').slideUp();
|
603 |
+
}
|
604 |
+
};
|
605 |
+
|
606 |
+
this.toggleAPIKeyWarnings = function() {
|
607 |
+
if ($('#sby_api_key').val() !== '') {
|
608 |
+
if ($('.sby_disabled_wrap').length) {
|
609 |
+
var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
|
610 |
+
$('.sbspf_type_row').each(function() {
|
611 |
+
if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
|
612 |
+
$closestTD.append($(this));
|
613 |
+
$(this).find('input').removeAttr('disabled');
|
614 |
+
}
|
615 |
+
});
|
616 |
+
$('.sby_disabled_wrap').remove();
|
617 |
+
}
|
618 |
+
|
619 |
+
|
620 |
+
} else if (!$('.sby_disabled_wrap').length) {
|
621 |
+
var $closestTD = $('.sbspf_row.sbspf_type_row').first().closest('td');
|
622 |
+
$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>');
|
623 |
+
|
624 |
+
$('.sbspf_type_row').each(function() {
|
625 |
+
if ($(this).find('.sbspf_type_input').attr('value') !== 'channel') {
|
626 |
+
$('.sby_disabled_wrap').append($(this));
|
627 |
+
$(this).find('input').attr('disabled',true);
|
628 |
+
} else {
|
629 |
+
$(this).find('input').removeAttr('disabled');
|
630 |
+
}
|
631 |
+
});
|
632 |
+
}
|
633 |
+
|
634 |
+
};
|
635 |
+
|
636 |
+
this.addAccessTokenListener = function () {
|
637 |
+
var self = this;
|
638 |
+
if (window.location.hash.length > 5 && window.location.hash.indexOf(this.accesstokenSplitter) > -1) {
|
639 |
+
var accessToken = window.location.hash.split(this.accesstokenSplitter);
|
640 |
+
// clear access token from hash
|
641 |
+
window.location.hash = '';
|
642 |
+
var submitData = {
|
643 |
+
'access_token' : accessToken[1],
|
644 |
+
'action' : 'sby_process_access_token',
|
645 |
+
'sbspf_nonce' : sbspf.nonce
|
646 |
+
};
|
647 |
+
var onSuccess = function (data) {
|
648 |
+
if (data.trim().indexOf('{') === 0) {
|
649 |
+
var returnObj = JSON.parse(data.trim());
|
650 |
+
$('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
|
651 |
+
self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
|
652 |
+
self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
|
653 |
+
}
|
654 |
+
};
|
655 |
+
sbAjax(submitData,onSuccess);
|
656 |
+
}
|
657 |
+
};
|
658 |
+
|
659 |
+
this.addManualAccessTokenListener = function() {
|
660 |
+
var self = this,
|
661 |
+
id = '#'+this.plugin,
|
662 |
+
cla = '.'+this.plugin;
|
663 |
+
|
664 |
+
$(cla+'_manually_connect_wrap').hide();
|
665 |
+
$(cla+'_manually_connect').click(function(event) {
|
666 |
+
event.preventDefault();
|
667 |
+
if ( $(cla+'_manually_connect_wrap').is(':visible') ) {
|
668 |
+
$(cla+'_manually_connect_wrap').slideUp(200);
|
669 |
+
} else {
|
670 |
+
$(cla+'_manually_connect_wrap').slideDown(200);
|
671 |
+
$(id+'_manual_at').focus();
|
672 |
+
}
|
673 |
+
});
|
674 |
+
|
675 |
+
$(id+'_manual_submit').click(function(event) {
|
676 |
+
event.preventDefault();
|
677 |
+
var $self = $(this);
|
678 |
+
var accessToken = $(id+'_manual_at').val(),
|
679 |
+
refreshToken = $(id+'_manual_rt').val(),
|
680 |
+
error = false;
|
681 |
+
|
682 |
+
if (accessToken.length < 15) {
|
683 |
+
if (!$(cla+'_manually_connect_wrap').find(cla+'_user_id_error').length) {
|
684 |
+
$(cla+'_manually_connect_wrap').show().prepend('<div class="'+self.plugin+'_user_id_error" style="display:block;">Please enter a valid access token</div>');
|
685 |
+
}
|
686 |
+
} else if (! error) {
|
687 |
+
$(this).attr('disabled',true);
|
688 |
+
$(this).closest(cla+'_manually_connect_wrap').fadeOut();
|
689 |
+
$(cla+'_connected_accounts_wrap').fadeTo("slow" , 0.5).find(cla+'_user_id_error').remove();
|
690 |
+
|
691 |
+
var submitData = {
|
692 |
+
'sby_access_token' : accessToken,
|
693 |
+
'sby_refresh_token' : refreshToken,
|
694 |
+
'action' : 'sby_process_access_token',
|
695 |
+
'sbspf_nonce' : sbspf.nonce
|
696 |
+
};
|
697 |
+
var onSuccess = function (data) {
|
698 |
+
$(cla+'_connected_accounts_wrap').fadeTo("slow" , 1);
|
699 |
+
$self.removeAttr('disabled');
|
700 |
+
if (data.trim().indexOf('{') === 0) {
|
701 |
+
var returnObj = JSON.parse(data.trim());
|
702 |
+
if (typeof returnObj.error === 'undefined') {
|
703 |
+
if (!$('#sbspf_connected_account_'+returnObj.account_id).length) {
|
704 |
+
$('.'+self.plugin +'_connected_accounts_wrap').prepend(returnObj.html);
|
705 |
+
self.initClickRemove($('.'+self.plugin +'_connected_accounts_wrap').last());
|
706 |
+
self.initInfoToggle($('.'+self.plugin +'_connected_accounts_wrap').last());
|
707 |
+
console.log('added');
|
708 |
+
} else {
|
709 |
+
$('#sbspf_connected_account_'+returnObj.account_id).replaceWith(returnObj.html);
|
710 |
+
self.initClickRemove($('#sbspf_connected_account_'+returnObj.account_id));
|
711 |
+
self.initInfoToggle($('#sbspf_connected_account_'+returnObj.account_id));
|
712 |
+
console.log('updated');
|
713 |
+
}
|
714 |
+
} else {
|
715 |
+
alert(returnObj.error);
|
716 |
+
}
|
717 |
+
}
|
718 |
+
|
719 |
+
};
|
720 |
+
sbAjax(submitData,onSuccess);
|
721 |
+
}
|
722 |
+
|
723 |
+
});
|
724 |
+
};
|
725 |
+
this.getAction = function(action) {
|
726 |
+
return 'sby_' + action;
|
727 |
+
};
|
728 |
+
|
729 |
+
}
|
730 |
+
|
731 |
+
SbYoutubeAdmin.prototype = Object.create(SbspfAdmin.prototype);
|
732 |
+
|
733 |
+
|
734 |
+
window.sby_admin_init = function() {
|
735 |
+
var plugin = typeof $('.sbspf-admin').attr('data-sb-plugin') !== 'undefined' ? $('.sbspf-admin').attr('data-sb-plugin') : 'sbspf',
|
736 |
+
$adminEl = $('#sbspf_admin.sby_admin');
|
737 |
+
window.sb = new SbYoutubeAdmin(plugin,$adminEl);
|
738 |
+
window.sb.init();
|
739 |
+
};
|
740 |
+
|
741 |
+
})(jQuery);
|
742 |
+
|
743 |
+
jQuery(document).ready(function($) {
|
744 |
+
sby_admin_init();
|
745 |
});
|
js/sb-youtube.js
CHANGED
@@ -1,1801 +1,1804 @@
|
|
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 |
-
}
|
396 |
-
}
|
397 |
-
}, b.prototype.preloadNeighboringImages = function() {
|
398 |
-
if (this.album.length > this.currentImageIndex + 1) {
|
399 |
-
var a = new Image;
|
400 |
-
a.src = this.album[this.currentImageIndex + 1].link
|
401 |
-
}
|
402 |
-
if (this.currentImageIndex > 0) {
|
403 |
-
var b = new Image;
|
404 |
-
b.src = this.album[this.currentImageIndex - 1].link
|
405 |
-
}
|
406 |
-
}, b.prototype.enableKeyboardNav = function() {
|
407 |
-
a(document).on("keyup.keyboard", a.proxy(this.keyboardAction, this))
|
408 |
-
}, b.prototype.disableKeyboardNav = function() {
|
409 |
-
a(document).off(".keyboard")
|
410 |
-
}, b.prototype.keyboardAction = function(a) {
|
411 |
-
|
412 |
-
var KEYCODE_ESC = 27;
|
413 |
-
var KEYCODE_LEFTARROW = 37;
|
414 |
-
var KEYCODE_RIGHTARROW = 39;
|
415 |
-
|
416 |
-
var keycode = event.keyCode;
|
417 |
-
var key = String.fromCharCode(keycode).toLowerCase();
|
418 |
-
if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) {
|
419 |
-
if( sby_supports_video() ) $('#sby_lightbox video.sby_video')[0].pause();
|
420 |
-
$('#sby_lightbox iframe').attr('src', '');
|
421 |
-
this.end();
|
422 |
-
} else if (key === 'p' || keycode === KEYCODE_LEFTARROW) {
|
423 |
-
if (this.currentImageIndex !== 0) {
|
424 |
-
this.changeImage(this.currentImageIndex - 1);
|
425 |
-
} else if (this.options.wrapAround && this.album.length > 1) {
|
426 |
-
this.changeImage(this.album.length - 1);
|
427 |
-
}
|
428 |
-
|
429 |
-
if( sby_supports_video() ) $('#sby_lightbox video.sby_video')[0].pause();
|
430 |
-
$('#sby_lightbox iframe').attr('src', '');
|
431 |
-
|
432 |
-
} else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) {
|
433 |
-
if (this.currentImageIndex !== this.album.length - 1) {
|
434 |
-
this.changeImage(this.currentImageIndex + 1);
|
435 |
-
} else if (this.options.wrapAround && this.album.length > 1) {
|
436 |
-
this.changeImage(0);
|
437 |
-
}
|
438 |
-
|
439 |
-
if (typeof window.sbyLightboxPlayer !== 'undefined') { YT.get('sby_lb-player').pauseVideo(); }
|
440 |
-
}
|
441 |
-
|
442 |
-
}, b.prototype.end = function() {
|
443 |
-
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({
|
444 |
-
visibility: "visible"
|
445 |
-
})
|
446 |
-
}, b
|
447 |
-
}();
|
448 |
-
a(function() {
|
449 |
-
{
|
450 |
-
var a = new b;
|
451 |
-
new c(a)
|
452 |
-
|
453 |
-
//Lightbox hide photo function
|
454 |
-
$('.sby_lightbox_action a').unbind().bind('click', function(){
|
455 |
-
$(this).parent().find('.sby_lightbox_tooltip').toggle();
|
456 |
-
});
|
457 |
-
}
|
458 |
-
})
|
459 |
-
}).call(this);
|
460 |
-
},
|
461 |
-
createFeeds: function (args) {
|
462 |
-
window.sby.createLightbox();
|
463 |
-
args.whenFeedsCreated(
|
464 |
-
$('.sb_youtube').each(function (index) {
|
465 |
-
$(this).attr('data-sby-index', index + 1);
|
466 |
-
$(this).find('.sby_player').replaceWith('<div id="sby_player'+index+'"></div>');
|
467 |
-
var $self = $(this),
|
468 |
-
flags = typeof $self.attr('data-sby-flags') !== 'undefined' ? $self.attr('data-sby-flags').split(',') : [],
|
469 |
-
general = typeof $self.attr('data-options') !== 'undefined' ? JSON.parse($self.attr('data-options')) : {};
|
470 |
-
if (flags.indexOf('testAjax') > -1) {
|
471 |
-
window.sby.triggeredTest = true;
|
472 |
-
var submitData = {
|
473 |
-
'action' : 'sby_on_ajax_test_trigger'
|
474 |
-
},
|
475 |
-
onSuccess = function(data) {
|
476 |
-
console.log('did test');
|
477 |
-
};
|
478 |
-
sbyAjax(submitData,onSuccess)
|
479 |
-
}
|
480 |
-
var feedOptions = {
|
481 |
-
cols : $self.attr('data-cols'),
|
482 |
-
colsmobile : $self.attr('data-colsmobile') !== 'same' ? $self.attr('data-colsmobile') : $self.attr('data-cols'),
|
483 |
-
num : $self.attr('data-num'),
|
484 |
-
imgRes : $self.attr('data-res'),
|
485 |
-
feedID : $self.attr('data-feedid'),
|
486 |
-
shortCodeAtts : $self.attr('data-shortcode-atts'),
|
487 |
-
resizingEnabled : (flags.indexOf('resizeDisable') === -1),
|
488 |
-
imageLoadEnabled : (flags.indexOf('imageLoadDisable') === -1),
|
489 |
-
debugEnabled : (flags.indexOf('debug') > -1),
|
490 |
-
favorLocal : (flags.indexOf('favorLocal') > -1),
|
491 |
-
ajaxPostLoad : (flags.indexOf('ajaxPostLoad') > -1),
|
492 |
-
checkWPPosts : (flags.indexOf('checkWPPosts') > -1),
|
493 |
-
cacheAll : (flags.indexOf('cacheAll') > -1),
|
494 |
-
lightboxEnabled : typeof $self.attr('data-sby-supports-lightbox') !== 'undefined',
|
495 |
-
autoMinRes : 1,
|
496 |
-
general : general
|
497 |
-
};
|
498 |
-
|
499 |
-
window.sby.feeds[index] = sbyGetNewFeed(this, index, feedOptions);
|
500 |
-
if (typeof window.sbyAPIReady !== 'undefined') {
|
501 |
-
window.sby.feeds[index].playerAPIReady = true;
|
502 |
-
}
|
503 |
-
window.sby.feeds[index].setResizedImages();
|
504 |
-
window.sby.feeds[index].init();
|
505 |
-
|
506 |
-
var evt = jQuery.Event('sbyafterfeedcreate');
|
507 |
-
evt.feed = window.sby.feeds[index];
|
508 |
-
jQuery(window).trigger(evt);
|
509 |
-
|
510 |
-
})
|
511 |
-
);
|
512 |
-
},
|
513 |
-
afterFeedsCreated: function () {
|
514 |
-
// enable header hover action
|
515 |
-
$('.sb_instagram_header').each(function () {
|
516 |
-
var $thisHeader = $(this);
|
517 |
-
$thisHeader.find('.sby_header_link').hover(function () {
|
518 |
-
$thisHeader.find('.sby_header_img_hover').addClass('sby_fade_in');
|
519 |
-
}, function () {
|
520 |
-
$thisHeader.find('.sby_header_img_hover').removeClass('sby_fade_in');
|
521 |
-
});
|
522 |
-
});
|
523 |
-
|
524 |
-
},
|
525 |
-
encodeHTML: function(raw) {
|
526 |
-
// make sure passed variable is defined
|
527 |
-
if (typeof raw === 'undefined') {
|
528 |
-
return '';
|
529 |
-
}
|
530 |
-
// replace greater than and less than symbols with html entity to disallow html in comments
|
531 |
-
var encoded = raw.replace(/(>)/g,'>'),
|
532 |
-
encoded = encoded.replace(/(<)/g,'<');
|
533 |
-
encoded = encoded.replace(/(<br\/>)/g,'<br>');
|
534 |
-
encoded = encoded.replace(/(<br>)/g,'<br>');
|
535 |
-
|
536 |
-
return encoded;
|
537 |
-
},
|
538 |
-
urlDetect: function(text) {
|
539 |
-
var urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g;
|
540 |
-
return text.match(urlRegex);
|
541 |
-
}
|
542 |
-
};
|
543 |
-
|
544 |
-
function SbyFeed(el, index, settings) {
|
545 |
-
this.el = el;
|
546 |
-
this.index = index;
|
547 |
-
this.settings = settings;
|
548 |
-
this.placeholderURL = window.sby.options.placeholder;
|
549 |
-
if (settings.narrowPlayer) {
|
550 |
-
this.placeholderURL = window.sby.options.placeholderNarrow
|
551 |
-
}
|
552 |
-
this.playerAPIReady = false;
|
553 |
-
this.consentGiven = true;
|
554 |
-
this.players = {};
|
555 |
-
this.minImageWidth = 0;
|
556 |
-
this.imageResolution = 150;
|
557 |
-
this.resizedImages = {};
|
558 |
-
this.needsResizing = [];
|
559 |
-
this.outOfPages = false;
|
560 |
-
this.isInitialized = false;
|
561 |
-
this.mostRecentlyLoadedPosts = [];
|
562 |
-
}
|
563 |
-
|
564 |
-
SbyFeed.prototype = {
|
565 |
-
init: function() {
|
566 |
-
var feed = this;
|
567 |
-
if ($(this.el).find('#sby_mod_error').length) {
|
568 |
-
$(this.el).prepend($(this.el).find('#sby_mod_error'));
|
569 |
-
}
|
570 |
-
if (this.settings.ajaxPostLoad) {
|
571 |
-
this.getNewPostSet();
|
572 |
-
} else {
|
573 |
-
this.afterInitialImagesLoaded();
|
574 |
-
//Only check the width once the resize event is over
|
575 |
-
}
|
576 |
-
var sby_delay = (function () {
|
577 |
-
var sby_timer = 0;
|
578 |
-
return function (sby_callback, sby_ms) {
|
579 |
-
clearTimeout(sby_timer);
|
580 |
-
sby_timer = setTimeout(sby_callback, sby_ms);
|
581 |
-
};
|
582 |
-
})();
|
583 |
-
jQuery(window).resize(function () {
|
584 |
-
sby_delay(function () {
|
585 |
-
feed.afterResize();
|
586 |
-
}, 500);
|
587 |
-
});
|
588 |
-
},
|
589 |
-
initLayout: function() {
|
590 |
-
this.initGalleryLayout();
|
591 |
-
this.initGrid();
|
592 |
-
|
593 |
-
},
|
594 |
-
initGalleryLayout: function() {
|
595 |
-
var $self = $(this.el),
|
596 |
-
feed = this;
|
597 |
-
if ($self.hasClass('sby_layout_gallery') && $self.find('.sby_player_outer_wrap').length) {
|
598 |
-
this.maybeRaiseSingleImageResolution($self.find('.sby_player_outer_wrap'), 0, true);
|
599 |
-
$self.find('.sby_player_outer_wrap .sby_video_thumbnail').off().click(function (event) {
|
600 |
-
event.preventDefault();
|
601 |
-
feed.onThumbnailClick($(this), true);
|
602 |
-
});
|
603 |
-
|
604 |
-
$self.mouseenter(function() {
|
605 |
-
if (!feed.canCreatePlayer()) {
|
606 |
-
return;
|
607 |
-
}
|
608 |
-
if (!$self.find('.sby_player_outer_wrap iframe').length) {
|
609 |
-
$self.addClass('sby_player_added').find('.sby_player_outer_wrap').addClass('sby_player_loading');
|
610 |
-
$self.find('.sby_player_outer_wrap .sby_video_thumbnail').find('.sby_loader').show().removeClass('sby_hidden');
|
611 |
-
feed.createPlayer('sby_player'+feed.index);
|
612 |
-
} else if (typeof feed.player === 'undefined' && feed.playerEagerLoaded()) {
|
613 |
-
feed.createPlayer('sby_player'+feed.index);
|
614 |
-
}
|
615 |
-
});
|
616 |
-
|
617 |
-
if (window.sbySemiEagerLoading) {
|
618 |
-
feed.createPlayer('sby_player'+feed.index);
|
619 |
-
}
|
620 |
-
|
621 |
-
}
|
622 |
-
},
|
623 |
-
initGrid: function() {
|
624 |
-
if (window.sbySemiEagerLoading && jQuery('#sby_lightbox').length) {
|
625 |
-
var feed = this;
|
626 |
-
playerID = 'sby_lb-player';
|
627 |
-
jQuery('#sby_lightbox').addClass('sby_video_lightbox');
|
628 |
-
|
629 |
-
var videoID = $(this.el).find('sby_item').first().attr('data-video-id'),
|
630 |
-
autoplay = sbyOptions.autoplay;
|
631 |
-
if (typeof window.sbyLightboxPlayer === 'undefined') {
|
632 |
-
var args = {
|
633 |
-
host: window.location.protocol + '//www.youtube-nocookie.com',
|
634 |
-
videoId: videoID,
|
635 |
-
playerVars: {
|
636 |
-
modestbranding: 1,
|
637 |
-
rel: 0,
|
638 |
-
autoplay: autoplay
|
639 |
-
},
|
640 |
-
events: {
|
641 |
-
'onStateChange': function (data) {
|
642 |
-
var videoID = data.target.getVideoData()['video_id'];
|
643 |
-
feed.afterStateChange(playerID, videoID, data, $('#' + playerID).closest('.sby_video_thumbnail_wrap'));
|
644 |
-
}
|
645 |
-
}
|
646 |
-
};
|
647 |
-
feed.maybeAddCTA(playerID);
|
648 |
-
|
649 |
-
window.sbyLightboxPlayer = new window.YT.Player(playerID, args);
|
650 |
-
}
|
651 |
-
}
|
652 |
-
},
|
653 |
-
createPlayer: function(playerID,videoID,autoplay,args) {
|
654 |
-
var $self = $(this.el),
|
655 |
-
feed = this;
|
656 |
-
videoID = typeof videoID !== 'undefined' ? videoID : this.getVideoID($self.find('.sby_item').first());
|
657 |
-
autoplay = typeof autoplay !== 'undefined' ? autoplay : 0;
|
658 |
-
|
659 |
-
if (typeof args === 'undefined') {
|
660 |
-
args = {
|
661 |
-
host: window.location.protocol + '//www.youtube-nocookie.com',
|
662 |
-
videoId: videoID,
|
663 |
-
playerVars: {
|
664 |
-
modestbranding: 1,
|
665 |
-
rel: 0,
|
666 |
-
autoplay: autoplay
|
667 |
-
},
|
668 |
-
}
|
669 |
-
}
|
670 |
-
if (typeof args.events === 'undefined') {
|
671 |
-
args.events = {
|
672 |
-
'onReady': function () {
|
673 |
-
$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');
|
674 |
-
if ($('#' + playerID).length && $('#' + playerID).closest('.sby_video_thumbnail_wrap').find('.sby_video_thumbnail').length) {
|
675 |
-
$('#' + playerID).closest('.sby_video_thumbnail_wrap').find('.sby_video_thumbnail').fadeTo(0, 'slow', function () {
|
676 |
-
$(this).css('z-index', -1);
|
677 |
-
$(this).find('.sby_loader').hide().addClass('sby_hidden');
|
678 |
-
$(this).closest('.sby_item').removeClass('sby_player_loading');
|
679 |
-
});
|
680 |
-
}
|
681 |
-
},
|
682 |
-
'onStateChange': function(data) {
|
683 |
-
$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');
|
684 |
-
feed.afterStateChange(playerID,videoID,data,$('#' + playerID).closest('.sby_video_thumbnail_wrap'));
|
685 |
-
if (data.data !== 1) return;
|
686 |
-
if (typeof feed.players !== 'undefined') {
|
687 |
-
$self.find('.sby_item').each(function() {
|
688 |
-
var itemVidID = feed.getVideoID($(this));
|
689 |
-
if ($(this).find('iframe').length && (itemVidID !== videoID)) {
|
690 |
-
if (typeof feed.players[itemVidID] !== 'undefined' && typeof feed.players[itemVidID].pauseVideo === 'function') {
|
691 |
-
feed.players[itemVidID].pauseVideo();
|
692 |
-
}
|
693 |
-
}
|
694 |
-
});
|
695 |
-
}
|
696 |
-
|
697 |
-
},
|
698 |
-
}
|
699 |
-
}
|
700 |
-
if (window.sbyEagerLoading) {
|
701 |
-
var newPlayer = YT.get(playerID);
|
702 |
-
} else {
|
703 |
-
var newPlayer = new window.YT.Player(playerID, args);
|
704 |
-
}
|
705 |
-
|
706 |
-
this.maybeAddCTA(playerID);
|
707 |
-
|
708 |
-
if ($self.hasClass('sby_layout_list') && typeof this.players[videoID] === 'undefined') {
|
709 |
-
this.players[videoID] = newPlayer;
|
710 |
-
} else if (typeof this.player === 'undefined') {
|
711 |
-
this.player = newPlayer;
|
712 |
-
}
|
713 |
-
|
714 |
-
return newPlayer;
|
715 |
-
},
|
716 |
-
afterStateChange: function(playerID,videoID,data,$player) {
|
717 |
-
},
|
718 |
-
afterInitialImagesLoaded: function() {
|
719 |
-
this.initLayout();
|
720 |
-
this.loadMoreButtonInit();
|
721 |
-
this.hideExtraItemsForWidth();
|
722 |
-
this.beforeNewImagesRevealed();
|
723 |
-
this.revealNewImages();
|
724 |
-
this.afterNewImagesRevealed();
|
725 |
-
this.afterFeedSet();
|
726 |
-
this.sizePlayer();
|
727 |
-
this.sizeItems();
|
728 |
-
},
|
729 |
-
afterResize: function() {
|
730 |
-
this.setImageHeight();
|
731 |
-
this.setImageResolution();
|
732 |
-
this.maybeRaiseImageResolution();
|
733 |
-
this.setImageSizeClass();
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
$button.
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
this.
|
744 |
-
|
745 |
-
this.
|
746 |
-
this.
|
747 |
-
this.
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
this.
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
newPlayerHeight = Math.floor(playerWidth *
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
newPlayerHeight = Math.floor(playerWidth *
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
$(this).
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
this.
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
$self.find('.
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
jQuery(this).
|
820 |
-
})
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
$self.find('.sby_video_thumbnail').attr('href',sbyOptions.
|
869 |
-
}
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
//
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
this.
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
$(this.el).find('.sby_resized_image_data').
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
var
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
feed.
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
$self
|
983 |
-
feed
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
var
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
feed.settings.checkWPPosts =
|
1009 |
-
}
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
feed.
|
1017 |
-
}
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
}
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
$self.find('.sby_items_wrap').
|
1039 |
-
}
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
},
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
//$(this).
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
}
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
var
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
case '
|
1228 |
-
this.imageResolution =
|
1229 |
-
break;
|
1230 |
-
|
1231 |
-
this.imageResolution =
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
&& this.resizedImages[id]
|
1243 |
-
&& this.resizedImages[id]
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
}
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
$self.find(
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
returnCols =
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
this.createPlayer('sby_player'+this.index
|
1399 |
-
}
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
this.
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
$sbyItem
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
this.
|
1429 |
-
}
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
$sbyItem
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
},
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
} else if (typeof
|
1470 |
-
&& typeof
|
1471 |
-
|
1472 |
-
|
1473 |
-
this.players
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
"<
|
1510 |
-
"<div class='sby_lb-
|
1511 |
-
"<div class='sby_lb-
|
1512 |
-
"<
|
1513 |
-
"
|
1514 |
-
"</div>"+
|
1515 |
-
"<div class='sby_lb-
|
1516 |
-
"
|
1517 |
-
"
|
1518 |
-
"<div class='sby_lb-
|
1519 |
-
"<div class='sby_lb-
|
1520 |
-
"<div class='sby_lb-
|
1521 |
-
"
|
1522 |
-
"
|
1523 |
-
"<div class='sby_lb-
|
1524 |
-
"</div>"+
|
1525 |
-
"</div>"+
|
1526 |
-
"
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
},
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
}
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
tag
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
$self.find('.
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
if (
|
1659 |
-
|
1660 |
-
}
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
feed.
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
feed.outOfPages =
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
$self.
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
$self.find('.sby_item').each(function() {
|
1731 |
-
var itemVidID = jQuery(this).attr('data-video-id');
|
1732 |
-
|
1733 |
-
if (jQuery(this).find('iframe').length && itemVidID !== jQuery(this).find('iframe').attr('id').replace('sby_player_','')) {
|
1734 |
-
YT.get('sby_player_'+itemVidID).pauseVideo();
|
1735 |
-
}
|
1736 |
-
});
|
1737 |
-
}
|
1738 |
-
}
|
1739 |
-
});
|
1740 |
-
});
|
1741 |
-
|
1742 |
-
} else if ($self.hasClass('sby_layout_gallery')) {
|
1743 |
-
jQuery(this).addClass('sby_player_loaded');
|
1744 |
-
|
1745 |
-
player = new YT.Player('sby_player'+index, {
|
1746 |
-
height: '100',
|
1747 |
-
width: '100',
|
1748 |
-
videoId: jQuery(this).find('.sby_item').first().attr('data-video-id'),
|
1749 |
-
playerVars: {
|
1750 |
-
modestbranding: 1,
|
1751 |
-
rel: 0,
|
1752 |
-
autoplay: autoplay
|
1753 |
-
},
|
1754 |
-
events: {
|
1755 |
-
'onStateChange': function(data) {
|
1756 |
-
var videoID = data.target.getVideoData()['video_id'];
|
1757 |
-
if (data.data !== 1) return;
|
1758 |
-
$self.find('.sby_item').each(function() {
|
1759 |
-
var itemVidID = jQuery(this).attr('data-video-id');
|
1760 |
-
|
1761 |
-
if (jQuery(this).find('iframe').length && jQuery(data.target.a).attr('id') !== jQuery(this).find('iframe').attr('id')) {
|
1762 |
-
YT.get('sby_player_'+itemVidID).pauseVideo();
|
1763 |
-
}
|
1764 |
-
});
|
1765 |
-
}
|
1766 |
-
}
|
1767 |
-
});
|
1768 |
-
} else {
|
1769 |
-
flagLightbox = true;
|
1770 |
-
}
|
1771 |
-
});
|
1772 |
-
|
1773 |
-
} else if (typeof window.sby !== 'undefined') {
|
1774 |
-
for (var i = 0; i < numFeeds; i++) {
|
1775 |
-
window.sby.feeds[i].playerAPIReady = true;
|
1776 |
-
}
|
1777 |
-
} else {
|
1778 |
-
window.sbyAPIReady = true;
|
1779 |
-
}
|
1780 |
-
}
|
1781 |
-
|
1782 |
-
if (flagLightbox) {
|
1783 |
-
if (!jQuery('#sby_lb-player').length) {
|
1784 |
-
jQuery('.sb_youtube').first().append('<div class="sby_lb-player-loaded sby_lb-player" id="sby_lb-player" style="display: none;"></div>');
|
1785 |
-
}
|
1786 |
-
player = new YT.Player('sby_lb-player', {
|
1787 |
-
height: '100',
|
1788 |
-
width: '100',
|
1789 |
-
videoId: jQuery(this).find('.sby_item').first().attr('data-video-id'),
|
1790 |
-
playerVars: {
|
1791 |
-
modestbranding: 1,
|
1792 |
-
rel: 0,
|
1793 |
-
autoplay: autoplay
|
1794 |
-
}
|
1795 |
-
});
|
1796 |
-
window.sbyLightboxPlayer = player;
|
1797 |
-
}
|
1798 |
-
|
1799 |
-
}
|
1800 |
-
|
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 |
+
}
|
396 |
+
}
|
397 |
+
}, b.prototype.preloadNeighboringImages = function() {
|
398 |
+
if (this.album.length > this.currentImageIndex + 1) {
|
399 |
+
var a = new Image;
|
400 |
+
a.src = this.album[this.currentImageIndex + 1].link
|
401 |
+
}
|
402 |
+
if (this.currentImageIndex > 0) {
|
403 |
+
var b = new Image;
|
404 |
+
b.src = this.album[this.currentImageIndex - 1].link
|
405 |
+
}
|
406 |
+
}, b.prototype.enableKeyboardNav = function() {
|
407 |
+
a(document).on("keyup.keyboard", a.proxy(this.keyboardAction, this))
|
408 |
+
}, b.prototype.disableKeyboardNav = function() {
|
409 |
+
a(document).off(".keyboard")
|
410 |
+
}, b.prototype.keyboardAction = function(a) {
|
411 |
+
|
412 |
+
var KEYCODE_ESC = 27;
|
413 |
+
var KEYCODE_LEFTARROW = 37;
|
414 |
+
var KEYCODE_RIGHTARROW = 39;
|
415 |
+
|
416 |
+
var keycode = event.keyCode;
|
417 |
+
var key = String.fromCharCode(keycode).toLowerCase();
|
418 |
+
if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) {
|
419 |
+
if( sby_supports_video() ) $('#sby_lightbox video.sby_video')[0].pause();
|
420 |
+
$('#sby_lightbox iframe').attr('src', '');
|
421 |
+
this.end();
|
422 |
+
} else if (key === 'p' || keycode === KEYCODE_LEFTARROW) {
|
423 |
+
if (this.currentImageIndex !== 0) {
|
424 |
+
this.changeImage(this.currentImageIndex - 1);
|
425 |
+
} else if (this.options.wrapAround && this.album.length > 1) {
|
426 |
+
this.changeImage(this.album.length - 1);
|
427 |
+
}
|
428 |
+
|
429 |
+
if( sby_supports_video() ) $('#sby_lightbox video.sby_video')[0].pause();
|
430 |
+
$('#sby_lightbox iframe').attr('src', '');
|
431 |
+
|
432 |
+
} else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) {
|
433 |
+
if (this.currentImageIndex !== this.album.length - 1) {
|
434 |
+
this.changeImage(this.currentImageIndex + 1);
|
435 |
+
} else if (this.options.wrapAround && this.album.length > 1) {
|
436 |
+
this.changeImage(0);
|
437 |
+
}
|
438 |
+
|
439 |
+
if (typeof window.sbyLightboxPlayer !== 'undefined') { YT.get('sby_lb-player').pauseVideo(); }
|
440 |
+
}
|
441 |
+
|
442 |
+
}, b.prototype.end = function() {
|
443 |
+
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({
|
444 |
+
visibility: "visible"
|
445 |
+
})
|
446 |
+
}, b
|
447 |
+
}();
|
448 |
+
a(function() {
|
449 |
+
{
|
450 |
+
var a = new b;
|
451 |
+
new c(a)
|
452 |
+
|
453 |
+
//Lightbox hide photo function
|
454 |
+
$('.sby_lightbox_action a').unbind().bind('click', function(){
|
455 |
+
$(this).parent().find('.sby_lightbox_tooltip').toggle();
|
456 |
+
});
|
457 |
+
}
|
458 |
+
})
|
459 |
+
}).call(this);
|
460 |
+
},
|
461 |
+
createFeeds: function (args) {
|
462 |
+
window.sby.createLightbox();
|
463 |
+
args.whenFeedsCreated(
|
464 |
+
$('.sb_youtube').each(function (index) {
|
465 |
+
$(this).attr('data-sby-index', index + 1);
|
466 |
+
$(this).find('.sby_player').replaceWith('<div id="sby_player'+index+'"></div>');
|
467 |
+
var $self = $(this),
|
468 |
+
flags = typeof $self.attr('data-sby-flags') !== 'undefined' ? $self.attr('data-sby-flags').split(',') : [],
|
469 |
+
general = typeof $self.attr('data-options') !== 'undefined' ? JSON.parse($self.attr('data-options')) : {};
|
470 |
+
if (flags.indexOf('testAjax') > -1) {
|
471 |
+
window.sby.triggeredTest = true;
|
472 |
+
var submitData = {
|
473 |
+
'action' : 'sby_on_ajax_test_trigger'
|
474 |
+
},
|
475 |
+
onSuccess = function(data) {
|
476 |
+
console.log('did test');
|
477 |
+
};
|
478 |
+
sbyAjax(submitData,onSuccess)
|
479 |
+
}
|
480 |
+
var feedOptions = {
|
481 |
+
cols : $self.attr('data-cols'),
|
482 |
+
colsmobile : $self.attr('data-colsmobile') !== 'same' ? $self.attr('data-colsmobile') : $self.attr('data-cols'),
|
483 |
+
num : $self.attr('data-num'),
|
484 |
+
imgRes : $self.attr('data-res'),
|
485 |
+
feedID : $self.attr('data-feedid'),
|
486 |
+
shortCodeAtts : $self.attr('data-shortcode-atts'),
|
487 |
+
resizingEnabled : (flags.indexOf('resizeDisable') === -1),
|
488 |
+
imageLoadEnabled : (flags.indexOf('imageLoadDisable') === -1),
|
489 |
+
debugEnabled : (flags.indexOf('debug') > -1),
|
490 |
+
favorLocal : (flags.indexOf('favorLocal') > -1),
|
491 |
+
ajaxPostLoad : (flags.indexOf('ajaxPostLoad') > -1),
|
492 |
+
checkWPPosts : (flags.indexOf('checkWPPosts') > -1),
|
493 |
+
cacheAll : (flags.indexOf('cacheAll') > -1),
|
494 |
+
lightboxEnabled : typeof $self.attr('data-sby-supports-lightbox') !== 'undefined',
|
495 |
+
autoMinRes : 1,
|
496 |
+
general : general
|
497 |
+
};
|
498 |
+
|
499 |
+
window.sby.feeds[index] = sbyGetNewFeed(this, index, feedOptions);
|
500 |
+
if (typeof window.sbyAPIReady !== 'undefined') {
|
501 |
+
window.sby.feeds[index].playerAPIReady = true;
|
502 |
+
}
|
503 |
+
window.sby.feeds[index].setResizedImages();
|
504 |
+
window.sby.feeds[index].init();
|
505 |
+
|
506 |
+
var evt = jQuery.Event('sbyafterfeedcreate');
|
507 |
+
evt.feed = window.sby.feeds[index];
|
508 |
+
jQuery(window).trigger(evt);
|
509 |
+
|
510 |
+
})
|
511 |
+
);
|
512 |
+
},
|
513 |
+
afterFeedsCreated: function () {
|
514 |
+
// enable header hover action
|
515 |
+
$('.sb_instagram_header').each(function () {
|
516 |
+
var $thisHeader = $(this);
|
517 |
+
$thisHeader.find('.sby_header_link').hover(function () {
|
518 |
+
$thisHeader.find('.sby_header_img_hover').addClass('sby_fade_in');
|
519 |
+
}, function () {
|
520 |
+
$thisHeader.find('.sby_header_img_hover').removeClass('sby_fade_in');
|
521 |
+
});
|
522 |
+
});
|
523 |
+
|
524 |
+
},
|
525 |
+
encodeHTML: function(raw) {
|
526 |
+
// make sure passed variable is defined
|
527 |
+
if (typeof raw === 'undefined') {
|
528 |
+
return '';
|
529 |
+
}
|
530 |
+
// replace greater than and less than symbols with html entity to disallow html in comments
|
531 |
+
var encoded = raw.replace(/(>)/g,'>'),
|
532 |
+
encoded = encoded.replace(/(<)/g,'<');
|
533 |
+
encoded = encoded.replace(/(<br\/>)/g,'<br>');
|
534 |
+
encoded = encoded.replace(/(<br>)/g,'<br>');
|
535 |
+
|
536 |
+
return encoded;
|
537 |
+
},
|
538 |
+
urlDetect: function(text) {
|
539 |
+
var urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g;
|
540 |
+
return text.match(urlRegex);
|
541 |
+
}
|
542 |
+
};
|
543 |
+
|
544 |
+
function SbyFeed(el, index, settings) {
|
545 |
+
this.el = el;
|
546 |
+
this.index = index;
|
547 |
+
this.settings = settings;
|
548 |
+
this.placeholderURL = window.sby.options.placeholder;
|
549 |
+
if (settings.narrowPlayer) {
|
550 |
+
this.placeholderURL = window.sby.options.placeholderNarrow
|
551 |
+
}
|
552 |
+
this.playerAPIReady = false;
|
553 |
+
this.consentGiven = true;
|
554 |
+
this.players = {};
|
555 |
+
this.minImageWidth = 0;
|
556 |
+
this.imageResolution = 150;
|
557 |
+
this.resizedImages = {};
|
558 |
+
this.needsResizing = [];
|
559 |
+
this.outOfPages = false;
|
560 |
+
this.isInitialized = false;
|
561 |
+
this.mostRecentlyLoadedPosts = [];
|
562 |
+
}
|
563 |
+
|
564 |
+
SbyFeed.prototype = {
|
565 |
+
init: function() {
|
566 |
+
var feed = this;
|
567 |
+
if ($(this.el).find('#sby_mod_error').length) {
|
568 |
+
$(this.el).prepend($(this.el).find('#sby_mod_error'));
|
569 |
+
}
|
570 |
+
if (this.settings.ajaxPostLoad) {
|
571 |
+
this.getNewPostSet();
|
572 |
+
} else {
|
573 |
+
this.afterInitialImagesLoaded();
|
574 |
+
//Only check the width once the resize event is over
|
575 |
+
}
|
576 |
+
var sby_delay = (function () {
|
577 |
+
var sby_timer = 0;
|
578 |
+
return function (sby_callback, sby_ms) {
|
579 |
+
clearTimeout(sby_timer);
|
580 |
+
sby_timer = setTimeout(sby_callback, sby_ms);
|
581 |
+
};
|
582 |
+
})();
|
583 |
+
jQuery(window).resize(function () {
|
584 |
+
sby_delay(function () {
|
585 |
+
feed.afterResize();
|
586 |
+
}, 500);
|
587 |
+
});
|
588 |
+
},
|
589 |
+
initLayout: function() {
|
590 |
+
this.initGalleryLayout();
|
591 |
+
this.initGrid();
|
592 |
+
|
593 |
+
},
|
594 |
+
initGalleryLayout: function() {
|
595 |
+
var $self = $(this.el),
|
596 |
+
feed = this;
|
597 |
+
if ($self.hasClass('sby_layout_gallery') && $self.find('.sby_player_outer_wrap').length) {
|
598 |
+
this.maybeRaiseSingleImageResolution($self.find('.sby_player_outer_wrap'), 0, true);
|
599 |
+
$self.find('.sby_player_outer_wrap .sby_video_thumbnail').off().click(function (event) {
|
600 |
+
event.preventDefault();
|
601 |
+
feed.onThumbnailClick($(this), true);
|
602 |
+
});
|
603 |
+
|
604 |
+
$self.mouseenter(function() {
|
605 |
+
if (!feed.canCreatePlayer()) {
|
606 |
+
return;
|
607 |
+
}
|
608 |
+
if (!$self.find('.sby_player_outer_wrap iframe').length) {
|
609 |
+
$self.addClass('sby_player_added').find('.sby_player_outer_wrap').addClass('sby_player_loading');
|
610 |
+
$self.find('.sby_player_outer_wrap .sby_video_thumbnail').find('.sby_loader').show().removeClass('sby_hidden');
|
611 |
+
feed.createPlayer('sby_player'+feed.index);
|
612 |
+
} else if (typeof feed.player === 'undefined' && feed.playerEagerLoaded()) {
|
613 |
+
feed.createPlayer('sby_player'+feed.index);
|
614 |
+
}
|
615 |
+
});
|
616 |
+
|
617 |
+
if (window.sbySemiEagerLoading) {
|
618 |
+
feed.createPlayer('sby_player'+feed.index);
|
619 |
+
}
|
620 |
+
|
621 |
+
}
|
622 |
+
},
|
623 |
+
initGrid: function() {
|
624 |
+
if (window.sbySemiEagerLoading && jQuery('#sby_lightbox').length) {
|
625 |
+
var feed = this;
|
626 |
+
playerID = 'sby_lb-player';
|
627 |
+
jQuery('#sby_lightbox').addClass('sby_video_lightbox');
|
628 |
+
|
629 |
+
var videoID = $(this.el).find('sby_item').first().attr('data-video-id'),
|
630 |
+
autoplay = sbyOptions.autoplay;
|
631 |
+
if (typeof window.sbyLightboxPlayer === 'undefined') {
|
632 |
+
var args = {
|
633 |
+
host: window.location.protocol + '//www.youtube-nocookie.com',
|
634 |
+
videoId: videoID,
|
635 |
+
playerVars: {
|
636 |
+
modestbranding: 1,
|
637 |
+
rel: 0,
|
638 |
+
autoplay: autoplay
|
639 |
+
},
|
640 |
+
events: {
|
641 |
+
'onStateChange': function (data) {
|
642 |
+
var videoID = data.target.getVideoData()['video_id'];
|
643 |
+
feed.afterStateChange(playerID, videoID, data, $('#' + playerID).closest('.sby_video_thumbnail_wrap'));
|
644 |
+
}
|
645 |
+
}
|
646 |
+
};
|
647 |
+
feed.maybeAddCTA(playerID);
|
648 |
+
|
649 |
+
window.sbyLightboxPlayer = new window.YT.Player(playerID, args);
|
650 |
+
}
|
651 |
+
}
|
652 |
+
},
|
653 |
+
createPlayer: function(playerID,videoID,autoplay,args) {
|
654 |
+
var $self = $(this.el),
|
655 |
+
feed = this;
|
656 |
+
videoID = typeof videoID !== 'undefined' ? videoID : this.getVideoID($self.find('.sby_item').first());
|
657 |
+
autoplay = typeof autoplay !== 'undefined' ? autoplay : 0;
|
658 |
+
|
659 |
+
if (typeof args === 'undefined') {
|
660 |
+
args = {
|
661 |
+
host: window.location.protocol + '//www.youtube-nocookie.com',
|
662 |
+
videoId: videoID,
|
663 |
+
playerVars: {
|
664 |
+
modestbranding: 1,
|
665 |
+
rel: 0,
|
666 |
+
autoplay: autoplay
|
667 |
+
},
|
668 |
+
}
|
669 |
+
}
|
670 |
+
if (typeof args.events === 'undefined') {
|
671 |
+
args.events = {
|
672 |
+
'onReady': function () {
|
673 |
+
$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');
|
674 |
+
if ($('#' + playerID).length && $('#' + playerID).closest('.sby_video_thumbnail_wrap').find('.sby_video_thumbnail').length) {
|
675 |
+
$('#' + playerID).closest('.sby_video_thumbnail_wrap').find('.sby_video_thumbnail').fadeTo(0, 'slow', function () {
|
676 |
+
$(this).css('z-index', -1);
|
677 |
+
$(this).find('.sby_loader').hide().addClass('sby_hidden');
|
678 |
+
$(this).closest('.sby_item').removeClass('sby_player_loading');
|
679 |
+
});
|
680 |
+
}
|
681 |
+
},
|
682 |
+
'onStateChange': function(data) {
|
683 |
+
$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');
|
684 |
+
feed.afterStateChange(playerID,videoID,data,$('#' + playerID).closest('.sby_video_thumbnail_wrap'));
|
685 |
+
if (data.data !== 1) return;
|
686 |
+
if (typeof feed.players !== 'undefined') {
|
687 |
+
$self.find('.sby_item').each(function() {
|
688 |
+
var itemVidID = feed.getVideoID($(this));
|
689 |
+
if ($(this).find('iframe').length && (itemVidID !== videoID)) {
|
690 |
+
if (typeof feed.players[itemVidID] !== 'undefined' && typeof feed.players[itemVidID].pauseVideo === 'function') {
|
691 |
+
feed.players[itemVidID].pauseVideo();
|
692 |
+
}
|
693 |
+
}
|
694 |
+
});
|
695 |
+
}
|
696 |
+
|
697 |
+
},
|
698 |
+
}
|
699 |
+
}
|
700 |
+
if (window.sbyEagerLoading) {
|
701 |
+
var newPlayer = YT.get(playerID);
|
702 |
+
} else {
|
703 |
+
var newPlayer = new window.YT.Player(playerID, args);
|
704 |
+
}
|
705 |
+
|
706 |
+
this.maybeAddCTA(playerID);
|
707 |
+
|
708 |
+
if ($self.hasClass('sby_layout_list') && typeof this.players[videoID] === 'undefined') {
|
709 |
+
this.players[videoID] = newPlayer;
|
710 |
+
} else if (typeof this.player === 'undefined') {
|
711 |
+
this.player = newPlayer;
|
712 |
+
}
|
713 |
+
|
714 |
+
return newPlayer;
|
715 |
+
},
|
716 |
+
afterStateChange: function(playerID,videoID,data,$player) {
|
717 |
+
},
|
718 |
+
afterInitialImagesLoaded: function() {
|
719 |
+
this.initLayout();
|
720 |
+
this.loadMoreButtonInit();
|
721 |
+
this.hideExtraItemsForWidth();
|
722 |
+
this.beforeNewImagesRevealed();
|
723 |
+
this.revealNewImages();
|
724 |
+
this.afterNewImagesRevealed();
|
725 |
+
this.afterFeedSet();
|
726 |
+
this.sizePlayer();
|
727 |
+
this.sizeItems();
|
728 |
+
},
|
729 |
+
afterResize: function() {
|
730 |
+
this.setImageHeight();
|
731 |
+
this.setImageResolution();
|
732 |
+
this.maybeRaiseImageResolution();
|
733 |
+
this.setImageSizeClass();
|
734 |
+
this.sizePlayer();
|
735 |
+
this.sizeItems();
|
736 |
+
},
|
737 |
+
afterLoadMoreClicked: function($button) {
|
738 |
+
$button.find('.sby_loader').removeClass('sby_hidden');
|
739 |
+
$button.find('.sby_btn_text').addClass('sby_hidden');
|
740 |
+
$button.closest('.sb_youtube').find('.sby_num_diff_hide').addClass('sby_transition').removeClass('sby_num_diff_hide');
|
741 |
+
},
|
742 |
+
afterNewImagesLoaded: function() {
|
743 |
+
var $self = $(this.el),
|
744 |
+
feed = this;
|
745 |
+
this.beforeNewImagesRevealed();
|
746 |
+
this.revealNewImages();
|
747 |
+
this.afterNewImagesRevealed();
|
748 |
+
this.sizePlayer();
|
749 |
+
this.sizeItems();
|
750 |
+
setTimeout(function () {
|
751 |
+
//Hide the loader in the load more button
|
752 |
+
$self.find('.sby_loader').addClass('sby_hidden');
|
753 |
+
$self.find('.sby_btn_text').removeClass('sby_hidden');
|
754 |
+
feed.maybeRaiseImageResolution();
|
755 |
+
}, 500);
|
756 |
+
},
|
757 |
+
beforeNewImagesRevealed: function() {
|
758 |
+
this.setImageHeight();
|
759 |
+
this.maybeRaiseImageResolution(true);
|
760 |
+
this.setImageSizeClass();
|
761 |
+
},
|
762 |
+
afterFeedSet: function() {
|
763 |
+
|
764 |
+
},
|
765 |
+
sizePlayer: function() {
|
766 |
+
var $self = $(this.el),
|
767 |
+
feed = this;
|
768 |
+
if ($self.hasClass('sby_layout_gallery')) {
|
769 |
+
$playerThumbnail = $self.find('.sby_player_item').find('.sby_player_video_thumbnail');
|
770 |
+
var playerWidth = $playerThumbnail.innerWidth(),
|
771 |
+
newPlayerHeight = Math.floor(playerWidth * 9 / 16);
|
772 |
+
if (feed.settings.narrowPlayer) {
|
773 |
+
newPlayerHeight = Math.floor(playerWidth * 3 / 4);
|
774 |
+
}
|
775 |
+
$playerThumbnail.css('height',newPlayerHeight+'px').css('overflow','hidden');
|
776 |
+
|
777 |
+
} else if ($self.hasClass('sby_layout_list')) {
|
778 |
+
$self.find('.sby_item').each(function(){
|
779 |
+
$playerThumbnail = $(this).find('.sby_item_video_thumbnail');
|
780 |
+
var playerWidth = $playerThumbnail.innerWidth(),
|
781 |
+
newPlayerHeight = Math.floor(playerWidth * 9 / 16);
|
782 |
+
if (feed.settings.narrowPlayer) {
|
783 |
+
newPlayerHeight = Math.floor(playerWidth * 3 / 4);
|
784 |
+
}
|
785 |
+
$playerThumbnail.css('height',newPlayerHeight+'px').css('overflow','hidden');
|
786 |
+
});
|
787 |
+
}
|
788 |
+
},
|
789 |
+
sizeItems: function() {
|
790 |
+
var $self = $(this.el),
|
791 |
+
feed = this;
|
792 |
+
if (!$self.hasClass('sby_layout_list')) {
|
793 |
+
$self.find('.sby_item').find('.sby_item_video_thumbnail').each(function() {
|
794 |
+
if ($(this).hasClass('sby_imgLiquid_ready')) {
|
795 |
+
var thumbWidth = $(this).innerWidth(),
|
796 |
+
newThumbHeight = Math.floor(thumbWidth * 9 / 16);
|
797 |
+
$(this).css('height',newThumbHeight+'px').css('overflow','hidden');
|
798 |
+
}
|
799 |
+
|
800 |
+
});
|
801 |
+
}
|
802 |
+
},
|
803 |
+
revealNewImages: function() {
|
804 |
+
var $self = $(this.el),
|
805 |
+
feed = this;
|
806 |
+
this.applyImageLiquid();
|
807 |
+
|
808 |
+
// Call Custom JS if it exists
|
809 |
+
if (typeof sbyCustomJS == 'function') setTimeout(function(){ sbyCustomJS(); }, 100);
|
810 |
+
|
811 |
+
$self.find('.sby-screenreader').find('img').remove();
|
812 |
+
|
813 |
+
$self.find('.sby_item.sby_new').each(function (index) {
|
814 |
+
var $self = jQuery(this);
|
815 |
+
|
816 |
+
//Photo links
|
817 |
+
//If lightbox is disabled
|
818 |
+
$self.find('.sby_video_thumbnail').hover(function () {
|
819 |
+
jQuery(this).fadeTo(200, 0.85);
|
820 |
+
}, function () {
|
821 |
+
jQuery(this).stop().fadeTo(500, 1);
|
822 |
+
});
|
823 |
+
videoID = $self.attr('data-video-id');
|
824 |
+
|
825 |
+
if (window.sbyEagerLoading && feed.canCreatePlayer() && $('#sby_player_'+videoID).length) {
|
826 |
+
player = new YT.Player('sby_player_'+videoID, {
|
827 |
+
height: '100',
|
828 |
+
width: '100',
|
829 |
+
videoId: videoID,
|
830 |
+
playerVars: {
|
831 |
+
modestbranding: 1,
|
832 |
+
rel: 0,
|
833 |
+
autoplay: 0
|
834 |
+
},
|
835 |
+
events: {
|
836 |
+
'onStateChange': function(data) {
|
837 |
+
var videoID = data.target.getVideoData()['video_id'];
|
838 |
+
if (data.data !== 1) return;
|
839 |
+
$self.find('.sby_item').each(function() {
|
840 |
+
var itemVidID = jQuery(this).attr('data-video-id');
|
841 |
+
|
842 |
+
if (jQuery(this).find('iframe').length && jQuery(data.target.a).attr('id') !== jQuery(this).find('iframe').attr('id')) {
|
843 |
+
YT.get('sby_player_'+itemVidID).pauseVideo();
|
844 |
+
}
|
845 |
+
});
|
846 |
+
}
|
847 |
+
}
|
848 |
+
});
|
849 |
+
}
|
850 |
+
|
851 |
+
$self.find('.sby_video_thumbnail').mouseenter(function() {
|
852 |
+
feed.onThumbnailEnter($(this), false);
|
853 |
+
});
|
854 |
+
$self.find('.sby_player_wrap').mouseleave(function() {
|
855 |
+
feed.onThumbnailLeave($(this), false);
|
856 |
+
});
|
857 |
+
//init click
|
858 |
+
$self.find('.sby_video_thumbnail').click(function(event) {
|
859 |
+
event.preventDefault();
|
860 |
+
feed.onThumbnailClick($(this), false);
|
861 |
+
});
|
862 |
+
|
863 |
+
// lightbox
|
864 |
+
if (feed.settings.lightboxEnabled) {
|
865 |
+
$self.find('.sby_video_thumbnail').attr('data-sby-lightbox',feed.index);
|
866 |
+
if (typeof sbyOptions !== 'undefined' && typeof sbyOptions.lightboxPlaceholder !== 'undefined') {
|
867 |
+
if (feed.settings.narrowPlayer) {
|
868 |
+
$self.find('.sby_video_thumbnail').attr('href',sbyOptions.lightboxPlaceholderNarrow);
|
869 |
+
} else {
|
870 |
+
$self.find('.sby_video_thumbnail').attr('href',sbyOptions.lightboxPlaceholder);
|
871 |
+
}
|
872 |
+
}
|
873 |
+
}
|
874 |
+
feed.afterItemRevealed($self);
|
875 |
+
|
876 |
+
// no info
|
877 |
+
if ($self.find('.sby_info_item').text().trim() === '') {
|
878 |
+
$self.find('.sby_info_item').addClass('sby_no_space');
|
879 |
+
}
|
880 |
+
}); //End .sby_item each
|
881 |
+
|
882 |
+
$self.find('.sby_player_item').each(function (index) {
|
883 |
+
var $self = jQuery(this);
|
884 |
+
|
885 |
+
feed.afterItemRevealed($self);
|
886 |
+
}); //End .sby_item each
|
887 |
+
|
888 |
+
//Remove the new class after 500ms, once the sorting is done
|
889 |
+
setTimeout(function () {
|
890 |
+
$self.find('.sby_item.sby_new').removeClass('sby_new');
|
891 |
+
//Loop through items and remove class to reveal them
|
892 |
+
var time = 10,
|
893 |
+
num = $self.find('.sby_transition').length;
|
894 |
+
$self.find('.sby_transition').each(function(index) {
|
895 |
+
var $sby_item_transition_el = jQuery(this);
|
896 |
+
|
897 |
+
setTimeout( function(){
|
898 |
+
$sby_item_transition_el.removeClass('sby_transition');
|
899 |
+
}, time);
|
900 |
+
time += 10;
|
901 |
+
});
|
902 |
+
}, 500);
|
903 |
+
|
904 |
+
|
905 |
+
},
|
906 |
+
afterItemRevealed: function() {
|
907 |
+
|
908 |
+
},
|
909 |
+
afterNewImagesRevealed: function() {
|
910 |
+
this.listenForVisibilityChange();
|
911 |
+
this.sendNeedsResizingToServer();
|
912 |
+
this.sendCheckWPPostsToServer();
|
913 |
+
if (!this.settings.imageLoadEnabled) {
|
914 |
+
$('.sby_no_resraise').removeClass('sby_no_resraise');
|
915 |
+
}
|
916 |
+
|
917 |
+
var evt = $.Event('sbyafterimagesloaded');
|
918 |
+
evt.el = $(this.el);
|
919 |
+
$(window).trigger(evt);
|
920 |
+
},
|
921 |
+
setResizedImages: function () {
|
922 |
+
if ($(this.el).find('.sby_resized_image_data').length
|
923 |
+
&& typeof $(this.el).find('.sby_resized_image_data').attr('data-resized') !== 'undefined'
|
924 |
+
&& $(this.el).find('.sby_resized_image_data').attr('data-resized').indexOf('{"') === 0) {
|
925 |
+
this.resizedImages = JSON.parse($(this.el).find('.sby_resized_image_data').attr('data-resized'));
|
926 |
+
$(this.el).find('.sby_resized_image_data').remove();
|
927 |
+
}
|
928 |
+
},
|
929 |
+
sendNeedsResizingToServer: function() {
|
930 |
+
var feed = this;
|
931 |
+
if (feed.needsResizing.length > 0 && feed.settings.resizingEnabled) {
|
932 |
+
var itemOffset = $(this.el).find('.sby_item').length;
|
933 |
+
|
934 |
+
var submitData = {
|
935 |
+
action: 'sby_resized_images_submit',
|
936 |
+
needs_resizing: feed.needsResizing,
|
937 |
+
offset: itemOffset,
|
938 |
+
feed_id: feed.settings.feedID,
|
939 |
+
atts: feed.settings.shortCodeAtts,
|
940 |
+
};
|
941 |
+
var onSuccess = function(data) {
|
942 |
+
if (data.trim().indexOf('{') === 0) {
|
943 |
+
var response = JSON.parse(data);
|
944 |
+
if (feed.settings.debugEnabled) {
|
945 |
+
console.log(response);
|
946 |
+
}
|
947 |
+
}
|
948 |
+
};
|
949 |
+
sbyAjax(submitData,onSuccess);
|
950 |
+
}
|
951 |
+
},
|
952 |
+
sendCheckWPPostsToServer: function() {
|
953 |
+
var feed = this;
|
954 |
+
if (feed.settings.checkWPPosts || feed.settings.singleCheckPosts) {
|
955 |
+
var feedID = typeof feed.settings.feedID !== 'undefined' ? feed.settings.feedID : 'sby_single',
|
956 |
+
posts = feed.mostRecentlyLoadedPosts;
|
957 |
+
feed.mostRecentlyLoadedPosts = [];
|
958 |
+
var submitData = {
|
959 |
+
action: 'sby_check_wp_submit',
|
960 |
+
feed_id: feedID,
|
961 |
+
atts: feed.settings.shortCodeAtts,
|
962 |
+
offset: ! $(this.el).hasClass('sby_layout_carousel') ? $(this.el).find('.sby_item').length : Math.floor(($(this.el).find('.sby_item').length / 2) -1),
|
963 |
+
posts: posts
|
964 |
+
};
|
965 |
+
var onSuccess = function(data) {
|
966 |
+
if (data.trim().indexOf('{') === 0) {
|
967 |
+
var response = JSON.parse(data);
|
968 |
+
if (feed.settings.debugEnabled) {
|
969 |
+
console.log(response);
|
970 |
+
}
|
971 |
+
feed.afterSendCheckWPPostsToServer(response);
|
972 |
+
|
973 |
+
}
|
974 |
+
};
|
975 |
+
sbyAjax(submitData,onSuccess);
|
976 |
+
}
|
977 |
+
},
|
978 |
+
afterSendCheckWPPostsToServer: function (response) {
|
979 |
+
|
980 |
+
},
|
981 |
+
loadMoreButtonInit: function () {
|
982 |
+
var $self = $(this.el),
|
983 |
+
feed = this;
|
984 |
+
$self.find('.sby_footer .sby_load_btn').off().on('click', function () {
|
985 |
+
feed.afterLoadMoreClicked(jQuery(this));
|
986 |
+
feed.getNewPostSet();
|
987 |
+
}); //End click event
|
988 |
+
},
|
989 |
+
getNewPostSet: function () {
|
990 |
+
var $self = $(this.el),
|
991 |
+
feed = this;
|
992 |
+
var itemOffset = $self.find('.sby_item').length,
|
993 |
+
submitData = {
|
994 |
+
action: 'sby_load_more_clicked',
|
995 |
+
offset: itemOffset,
|
996 |
+
feed_id: feed.settings.feedID,
|
997 |
+
atts: feed.settings.shortCodeAtts,
|
998 |
+
current_resolution: feed.imageResolution
|
999 |
+
};
|
1000 |
+
var onSuccess = function (data) {
|
1001 |
+
if (data.trim().indexOf('{') === 0) {
|
1002 |
+
var response = JSON.parse(data),
|
1003 |
+
checkWPPosts = typeof response.feedStatus.checkWPPosts !== 'undefined' ? response.feedStatus.checkWPPosts : false;;
|
1004 |
+
if (feed.settings.debugEnabled) {
|
1005 |
+
console.log(response);
|
1006 |
+
}
|
1007 |
+
if (checkWPPosts) {
|
1008 |
+
feed.settings.checkWPPosts = true;
|
1009 |
+
} else {
|
1010 |
+
feed.settings.checkWPPosts = false;
|
1011 |
+
}
|
1012 |
+
feed.appendNewPosts(response.html);
|
1013 |
+
feed.addResizedImages(response.resizedImages);
|
1014 |
+
if (feed.settings.ajaxPostLoad) {
|
1015 |
+
feed.settings.ajaxPostLoad = false;
|
1016 |
+
feed.afterInitialImagesLoaded();
|
1017 |
+
} else {
|
1018 |
+
feed.afterNewImagesLoaded();
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
if (!response.feedStatus.shouldPaginate) {
|
1022 |
+
feed.outOfPages = true;
|
1023 |
+
$self.find('.sby_load_btn').hide();
|
1024 |
+
} else {
|
1025 |
+
feed.outOfPages = false;
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
$('.sby_no_js').removeClass('sby_no_js');
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
};
|
1032 |
+
sbyAjax(submitData, onSuccess);
|
1033 |
+
},
|
1034 |
+
appendNewPosts: function (newPostsHtml) {
|
1035 |
+
var $self = $(this.el),
|
1036 |
+
feed = this;
|
1037 |
+
if ($self.find('.sby_items_wrap .sby_item').length) {
|
1038 |
+
$self.find('.sby_items_wrap .sby_item').last().after(newPostsHtml);
|
1039 |
+
} else {
|
1040 |
+
$self.find('.sby_items_wrap').append(newPostsHtml);
|
1041 |
+
}
|
1042 |
+
},
|
1043 |
+
addResizedImages: function (resizedImagesToAdd) {
|
1044 |
+
for (var imageID in resizedImagesToAdd) {
|
1045 |
+
this.resizedImages[imageID] = resizedImagesToAdd[imageID];
|
1046 |
+
}
|
1047 |
+
},
|
1048 |
+
setImageHeight: function() {
|
1049 |
+
},
|
1050 |
+
maybeRaiseSingleImageResolution: function ($item, index, forceChange) {
|
1051 |
+
var feed = this,
|
1052 |
+
imgSrcSet = feed.getImageUrls($item),
|
1053 |
+
currentUrl = $item.find('.sby_video_thumbnail > img').attr('src'),
|
1054 |
+
currentRes = 150,
|
1055 |
+
aspectRatio = 1, // all thumbnails are oriented the same so the best calculation uses 1
|
1056 |
+
forceChange = typeof forceChange !== 'undefined' ? forceChange : false;
|
1057 |
+
|
1058 |
+
if ($item.hasClass('sby_no_resraise')) {
|
1059 |
+
return;
|
1060 |
+
}
|
1061 |
+
|
1062 |
+
$.each(imgSrcSet, function (index, value) {
|
1063 |
+
if (value === currentUrl) {
|
1064 |
+
currentRes = parseInt(index);
|
1065 |
+
// If the image has already been changed to an existing real source, don't force the change
|
1066 |
+
forceChange = false;
|
1067 |
+
}
|
1068 |
+
});
|
1069 |
+
//Image res
|
1070 |
+
var newRes = 640;
|
1071 |
+
switch (feed.settings.imgRes) {
|
1072 |
+
case 'thumb':
|
1073 |
+
newRes = 120;
|
1074 |
+
break;
|
1075 |
+
case 'medium':
|
1076 |
+
newRes = 320;
|
1077 |
+
break;
|
1078 |
+
case 'large':
|
1079 |
+
newRes = 480;
|
1080 |
+
break;
|
1081 |
+
case 'full':
|
1082 |
+
newRes = 640;
|
1083 |
+
break;
|
1084 |
+
default:
|
1085 |
+
var minImageWidth = Math.max(feed.settings.autoMinRes,$item.find('.sby_video_thumbnail').innerWidth()),
|
1086 |
+
thisImageReplace = feed.getBestResolutionForAuto(minImageWidth, aspectRatio, $(this.el).find('sby_item').first());
|
1087 |
+
switch (thisImageReplace) {
|
1088 |
+
case 480:
|
1089 |
+
newRes = 480;
|
1090 |
+
break;
|
1091 |
+
case 320:
|
1092 |
+
newRes = 320;
|
1093 |
+
break;
|
1094 |
+
case 120:
|
1095 |
+
newRes = 120;
|
1096 |
+
break;
|
1097 |
+
}
|
1098 |
+
break;
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
if (newRes > currentRes || currentUrl === feed.placeholderURL || forceChange) {
|
1102 |
+
if (feed.settings.debugEnabled) {
|
1103 |
+
var reason = currentUrl === feed.placeholderURL ? 'was placeholder' : 'too small';
|
1104 |
+
console.log('rais res for ' + currentUrl, reason);
|
1105 |
+
}
|
1106 |
+
var newUrl = imgSrcSet[newRes];
|
1107 |
+
$item.find('.sby_video_thumbnail > img').attr('src', newUrl);
|
1108 |
+
if ($item.find('.sby_video_thumbnail').hasClass('sby_imgLiquid_ready')) {
|
1109 |
+
$item.find('.sby_video_thumbnail').css('background-image', 'url("' + newUrl + '")');
|
1110 |
+
}
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
$item.find('img').on('error', function () {
|
1114 |
+
if (!$(this).hasClass('sby_img_error')) {
|
1115 |
+
$(this).addClass('sby_img_error');
|
1116 |
+
var sourceFromAPI = ($(this).attr('src').indexOf('i.ytimg.com') > -1);
|
1117 |
+
|
1118 |
+
if (!sourceFromAPI) {
|
1119 |
+
if (typeof $(this).closest('.sby_video_thumbnail').attr('data-full-res') !== 'undefined') {
|
1120 |
+
//$(this).attr('src', $(this).closest('.sby_video_thumbnail').attr('data-full-res'));
|
1121 |
+
//$(this).closest('.sby_video_thumbnail').css('background-image', 'url(' + $(this).closest('.sby_video_thumbnail').attr('data-full-res') + ')');
|
1122 |
+
} else if ($(this).closest('.sby_video_thumbnail').attr('href') !== 'undefined') {
|
1123 |
+
//$(this).attr('src', $(this).closest('.sby_video_thumbnail').attr('href') + 'media?size=l');
|
1124 |
+
//$(this).closest('.sby_video_thumbnail').css('background-image', 'url(' + $(this).closest('.sby_video_thumbnail').attr('href') + 'media?size=l)');
|
1125 |
+
}
|
1126 |
+
} else {
|
1127 |
+
feed.settings.favorLocal = true;
|
1128 |
+
var srcSet = feed.getImageUrls($(this).closest('.sby_item'));
|
1129 |
+
if (typeof srcSet[640] !== 'undefined') {
|
1130 |
+
//$(this).attr('src', srcSet[640]);
|
1131 |
+
//$(this).closest('.sby_video_thumbnail').css('background-image', 'url(' + srcSet[640] + ')');
|
1132 |
+
}
|
1133 |
+
}
|
1134 |
+
setTimeout(function() {
|
1135 |
+
feed.afterResize();
|
1136 |
+
}, 1500)
|
1137 |
+
} else {
|
1138 |
+
console.log('unfixed error ' + $(this).attr('src'));
|
1139 |
+
}
|
1140 |
+
});
|
1141 |
+
},
|
1142 |
+
maybeRaiseImageResolution: function (justNew) {
|
1143 |
+
var feed = this,
|
1144 |
+
itemsSelector = typeof justNew !== 'undefined' && justNew === true ? '.sby_item.sby_new' : '.sby_item',
|
1145 |
+
forceChange = !feed.isInitialized ? true : false;
|
1146 |
+
$(feed.el).find(itemsSelector).each(function (index) {
|
1147 |
+
if (!$(this).hasClass('sby_num_diff_hide')
|
1148 |
+
&& $(this).find('.sby_video_thumbnail').length
|
1149 |
+
&& typeof $(this).find('.sby_video_thumbnail').attr('data-img-src-set') !== 'undefined') {
|
1150 |
+
feed.maybeRaiseSingleImageResolution($(this),index,forceChange);
|
1151 |
+
}
|
1152 |
+
}); //End .sby_item each
|
1153 |
+
feed.isInitialized = true;
|
1154 |
+
},
|
1155 |
+
getBestResolutionForAuto: function(colWidth, aspectRatio, $item) {
|
1156 |
+
if (isNaN(aspectRatio) || aspectRatio < 1) {
|
1157 |
+
aspectRatio = 1;
|
1158 |
+
}
|
1159 |
+
var bestWidth = colWidth * aspectRatio,
|
1160 |
+
bestWidthRounded = Math.ceil(bestWidth / 10) * 10,
|
1161 |
+
customSizes = [120, 320, 480, 640];
|
1162 |
+
|
1163 |
+
if ($item.hasClass('sby_highlighted')) {
|
1164 |
+
bestWidthRounded = bestWidthRounded *2;
|
1165 |
+
}
|
1166 |
+
|
1167 |
+
if (customSizes.indexOf(parseInt(bestWidthRounded)) === -1) {
|
1168 |
+
var done = false;
|
1169 |
+
$.each(customSizes, function (index, item) {
|
1170 |
+
if (item > parseInt(bestWidthRounded) && !done) {
|
1171 |
+
bestWidthRounded = item;
|
1172 |
+
done = true;
|
1173 |
+
}
|
1174 |
+
});
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
return bestWidthRounded;
|
1178 |
+
},
|
1179 |
+
hideExtraItemsForWidth: function() {
|
1180 |
+
if (this.layout === 'carousel') {
|
1181 |
+
return;
|
1182 |
+
}
|
1183 |
+
var $self = $(this.el),
|
1184 |
+
num = typeof $self.attr('data-num') !== 'undefined' && $self.attr('data-num') !== '' ? parseInt($self.attr('data-num')) : 1,
|
1185 |
+
nummobile = typeof $self.attr('data-nummobile') !== 'undefined' && $self.attr('data-nummobile') !== '' ? parseInt($self.attr('data-nummobile')) : num;
|
1186 |
+
|
1187 |
+
if (!$self.hasClass('.sby_layout_carousel')) {
|
1188 |
+
if ($(window).width() < 480) {
|
1189 |
+
if (nummobile < $self.find('.sby_item').length) {
|
1190 |
+
$self.find('.sby_item').slice(nummobile - $self.find('.sby_item').length).addClass('sby_num_diff_hide');
|
1191 |
+
}
|
1192 |
+
} else {
|
1193 |
+
if (num < $self.find('.sby_item').length) {
|
1194 |
+
$self.find('.sby_item').slice(num - $self.find('.sby_item').length).addClass('sby_num_diff_hide');
|
1195 |
+
}
|
1196 |
+
}
|
1197 |
+
}
|
1198 |
+
|
1199 |
+
},
|
1200 |
+
setImageSizeClass: function () {
|
1201 |
+
var $self = $(this.el);
|
1202 |
+
$self.removeClass('sby_small sby_medium');
|
1203 |
+
var feedWidth = $self.innerWidth(),
|
1204 |
+
photoPadding = parseInt(($self.find('.sby_items_wrap').outerWidth() - $self.find('.sby_items_wrap').width())) / 2,
|
1205 |
+
cols = this.getColumnCount(),
|
1206 |
+
feedWidthSansPadding = feedWidth - (photoPadding * (cols+2)),
|
1207 |
+
colWidth = (feedWidthSansPadding / cols);
|
1208 |
+
|
1209 |
+
if (colWidth > 140 && colWidth < 240) {
|
1210 |
+
$self.addClass('sby_medium');
|
1211 |
+
} else if (colWidth <= 140) {
|
1212 |
+
$self.addClass('sby_small');
|
1213 |
+
}
|
1214 |
+
},
|
1215 |
+
setMinImageWidth: function () {
|
1216 |
+
if ($(this.el).find('.sby_item .sby_video_thumbnail').first().length) {
|
1217 |
+
this.minImageWidth = $(this.el).find('.sby_item .sby_video_thumbnail').first().innerWidth();
|
1218 |
+
} else {
|
1219 |
+
this.minImageWidth = 150;
|
1220 |
+
}
|
1221 |
+
},
|
1222 |
+
setImageResolution: function () {
|
1223 |
+
if (this.settings.imgRes === 'auto') {
|
1224 |
+
this.imageResolution = 'auto';
|
1225 |
+
} else {
|
1226 |
+
switch (this.settings.imgRes) {
|
1227 |
+
case 'thumb':
|
1228 |
+
this.imageResolution = 150;
|
1229 |
+
break;
|
1230 |
+
case 'medium':
|
1231 |
+
this.imageResolution = 320;
|
1232 |
+
break;
|
1233 |
+
default:
|
1234 |
+
this.imageResolution = 640;
|
1235 |
+
}
|
1236 |
+
}
|
1237 |
+
},
|
1238 |
+
getImageUrls: function ($item) {
|
1239 |
+
var srcSet = JSON.parse($item.find('.sby_video_thumbnail').attr('data-img-src-set').replace(/\\\//g, '/')),
|
1240 |
+
id = $item.attr('id').replace('sby_', '').replace('player_','');
|
1241 |
+
if (typeof this.resizedImages[id] !== 'undefined'
|
1242 |
+
&& this.resizedImages[id] !== 'video'
|
1243 |
+
&& this.resizedImages[id] !== 'pending'
|
1244 |
+
&& this.resizedImages[id].id !== 'error'
|
1245 |
+
&& this.resizedImages[id].id !== 'video'
|
1246 |
+
&& this.resizedImages[id].id !== 'pending') {
|
1247 |
+
|
1248 |
+
if (typeof this.resizedImages[id]['sizes'] !== 'undefined') {
|
1249 |
+
var foundSizes = [];
|
1250 |
+
if (typeof this.resizedImages[id]['sizes']['full'] !== 'undefined') {
|
1251 |
+
foundSizes.push(640);
|
1252 |
+
srcSet[640] = sbyOptions.resized_url + this.resizedImages[id].id + 'full.jpg';
|
1253 |
+
$item.find('.sby_link_area').attr( 'href', sbyOptions.resized_url + this.resizedImages[id].id + 'full.jpg' );
|
1254 |
+
$item.find('.sby_video_thumbnail').attr( 'data-full-res', sbyOptions.resized_url + this.resizedImages[id].id + 'full.jpg' );
|
1255 |
+
}
|
1256 |
+
if (typeof this.resizedImages[id]['sizes']['low'] !== 'undefined') {
|
1257 |
+
foundSizes.push(320);
|
1258 |
+
srcSet[320] = sbyOptions.resized_url + this.resizedImages[id].id + 'low.jpg';
|
1259 |
+
if (this.settings.favorLocal && typeof this.resizedImages[id]['sizes']['full'] === 'undefined') {
|
1260 |
+
$item.find('.sby_link_area').attr( 'href', sbyOptions.resized_url + this.resizedImages[id].id + 'low.jpg' );
|
1261 |
+
$item.find('.sby_video_thumbnail').attr( 'data-full-res', sbyOptions.resized_url + this.resizedImages[id].id + 'low.jpg' );
|
1262 |
+
}
|
1263 |
+
}
|
1264 |
+
if (typeof this.resizedImages[id]['sizes']['thumb'] !== 'undefined') {
|
1265 |
+
foundSizes.push(150);
|
1266 |
+
srcSet[150] = sbyOptions.resized_url + this.resizedImages[id].id + 'thumb.jpg';
|
1267 |
+
}
|
1268 |
+
if (this.settings.favorLocal) {
|
1269 |
+
if (foundSizes.indexOf(640) === -1) {
|
1270 |
+
if (foundSizes.indexOf(320) > -1) {
|
1271 |
+
srcSet[640] = sbyOptions.resized_url + this.resizedImages[id].id + 'low.jpg';
|
1272 |
+
}
|
1273 |
+
}
|
1274 |
+
if (foundSizes.indexOf(320) === -1) {
|
1275 |
+
if (foundSizes.indexOf(640) > -1) {
|
1276 |
+
srcSet[320] = sbyOptions.resized_url + this.resizedImages[id].id + 'full.jpg';
|
1277 |
+
} else if (foundSizes.indexOf(150) > -1) {
|
1278 |
+
srcSet[320] = sbyOptions.resized_url + this.resizedImages[id].id + 'thumb.jpg';
|
1279 |
+
}
|
1280 |
+
}
|
1281 |
+
if (foundSizes.indexOf(150) === -1) {
|
1282 |
+
if (foundSizes.indexOf(320) > -1) {
|
1283 |
+
srcSet[150] = sbyOptions.resized_url + this.resizedImages[id].id + 'low.jpg';
|
1284 |
+
} else if (foundSizes.indexOf(640) > -1) {
|
1285 |
+
srcSet[150] = sbyOptions.resized_url + this.resizedImages[id].id + 'full.jpg';
|
1286 |
+
}
|
1287 |
+
}
|
1288 |
+
}
|
1289 |
+
}
|
1290 |
+
} else if (typeof this.resizedImages[id] === 'undefined'
|
1291 |
+
|| (typeof this.resizedImages[id]['id'] !== 'undefined' && this.resizedImages[id]['id'] !== 'pending' && this.resizedImages[id]['id'] !== 'error')) {
|
1292 |
+
this.addToNeedsResizing(id);
|
1293 |
+
}
|
1294 |
+
|
1295 |
+
return srcSet;
|
1296 |
+
},
|
1297 |
+
getVideoID: function ($el) {
|
1298 |
+
if ($el.hasClass('sby_item') || $el.hasClass('sby_player_item')) {
|
1299 |
+
if (typeof $el.find('.sby_video_thumbnail').attr('data-video-id') !== 'undefined') {
|
1300 |
+
return $el.find('.sby_video_thumbnail').attr('data-video-id');
|
1301 |
+
}
|
1302 |
+
} else if ($el.closest('sby_item').length || $el.closest('sby_player_item').length) {
|
1303 |
+
var $targeEl = $el.closest('sby_item').length ? $el.closest('sby_item') : $el.closest('sby_player_item');
|
1304 |
+
if (typeof $targeEl.find('.sby_video_thumbnail').attr('data-video-id') !== 'undefined') {
|
1305 |
+
return $targeEl.find('.sby_video_thumbnail').attr('data-video-id');
|
1306 |
+
}
|
1307 |
+
} else if ($el.hasClass('sb_youtube')) {
|
1308 |
+
return $el.find('.sby_item').first().find('.sby_video_thumbnail').attr('data-video-id');
|
1309 |
+
} else if ($(this.el).find('.sby_video_thumbnail').first().length && typeof $(this.el).find('.sby_video_thumbnail').first().attr('data-video-id') !== 'undefined'){
|
1310 |
+
return $(this.el).find('.sby_video_thumbnail').first().attr('data-video-id');
|
1311 |
+
}
|
1312 |
+
return '';
|
1313 |
+
},
|
1314 |
+
getAvatarUrl: function (username,favorType) {
|
1315 |
+
if (username === '') {
|
1316 |
+
return '';
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
var availableAvatars = this.settings.general.avatars,
|
1320 |
+
favorType = typeof favorType !== 'undefined' ? favorType : 'local';
|
1321 |
+
|
1322 |
+
if (favorType === 'local') {
|
1323 |
+
if (typeof availableAvatars['LCL'+username] !== 'undefined' && parseInt(availableAvatars['LCL'+username]) === 1) {
|
1324 |
+
return sbyOptions.resized_url + username + '.jpg';
|
1325 |
+
} else if (typeof availableAvatars[username] !== 'undefined') {
|
1326 |
+
return availableAvatars[username];
|
1327 |
+
} else {
|
1328 |
+
return '';
|
1329 |
+
}
|
1330 |
+
} else {
|
1331 |
+
if (typeof availableAvatars[username] !== 'undefined') {
|
1332 |
+
return availableAvatars[username];
|
1333 |
+
} else if (typeof availableAvatars['LCL'+username] !== 'undefined' && parseInt(availableAvatars['LCL'+username]) === 1) {
|
1334 |
+
return sbyOptions.resized_url + username + '.jpg';
|
1335 |
+
} else {
|
1336 |
+
return '';
|
1337 |
+
}
|
1338 |
+
}
|
1339 |
+
},
|
1340 |
+
addToNeedsResizing: function (id) {
|
1341 |
+
if (this.needsResizing.indexOf(id) === -1) {
|
1342 |
+
this.needsResizing.push(id);
|
1343 |
+
}
|
1344 |
+
},
|
1345 |
+
applyImageLiquid: function () {
|
1346 |
+
var $self = $(this.el),
|
1347 |
+
feed = this;
|
1348 |
+
sbyAddImgLiquid();
|
1349 |
+
if (typeof $self.find(".sby_player_item").sby_imgLiquid == 'function') {
|
1350 |
+
if ($self.find('.sby_player_item').length) {
|
1351 |
+
$self.find(".sby_player_item .sby_player_video_thumbnail").sby_imgLiquid({fill: true});
|
1352 |
+
}
|
1353 |
+
$self.find(".sby_item .sby_item_video_thumbnail").sby_imgLiquid({fill: true});
|
1354 |
+
}
|
1355 |
+
},
|
1356 |
+
listenForVisibilityChange: function() {
|
1357 |
+
var feed = this;
|
1358 |
+
sbyAddVisibilityListener();
|
1359 |
+
if (typeof $(this.el).filter(':hidden').sbyVisibilityChanged == 'function') {
|
1360 |
+
//If the feed is initially hidden (in a tab for example) then check for when it becomes visible and set then set the height
|
1361 |
+
$(this.el).filter(':hidden').sbyVisibilityChanged({
|
1362 |
+
callback: function (element, visible) {
|
1363 |
+
feed.afterResize();
|
1364 |
+
},
|
1365 |
+
runOnLoad: false
|
1366 |
+
});
|
1367 |
+
}
|
1368 |
+
},
|
1369 |
+
getColumnCount: function() {
|
1370 |
+
var $self = $(this.el),
|
1371 |
+
cols = this.settings.cols,
|
1372 |
+
colsmobile = this.settings.colsmobile,
|
1373 |
+
returnCols = cols;
|
1374 |
+
|
1375 |
+
sbyWindowWidth = window.innerWidth;
|
1376 |
+
|
1377 |
+
if ($self.hasClass('sby_mob_col_auto')) {
|
1378 |
+
if (sbyWindowWidth < 640 && (parseInt(cols) > 2 && parseInt(cols) < 7)) returnCols = 2;
|
1379 |
+
if (sbyWindowWidth < 640 && (parseInt(cols) > 6 && parseInt(cols) < 11)) returnCols = 4;
|
1380 |
+
if (sbyWindowWidth <= 480 && parseInt(cols) > 2) returnCols = 1;
|
1381 |
+
} else if (sbyWindowWidth <= 480) {
|
1382 |
+
returnCols = colsmobile;
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
return parseInt(returnCols);
|
1386 |
+
},
|
1387 |
+
onThumbnailClick: function($clicked,isPlayer,videoID) {
|
1388 |
+
if (!this.canCreatePlayer()) {
|
1389 |
+
return;
|
1390 |
+
}
|
1391 |
+
var $self = $(this.el);
|
1392 |
+
if ($self.hasClass('sby_layout_gallery')) {
|
1393 |
+
|
1394 |
+
$self.addClass('sby_player_added').find('.sby_player_outer_wrap').addClass('sby_player_loading');
|
1395 |
+
$self.find('.sby_player_outer_wrap .sby_video_thumbnail').find('.sby_loader').show().removeClass('sby_hidden');
|
1396 |
+
if (!$self.find('.sby_player_outer_wrap iframe').length) {
|
1397 |
+
if (isPlayer) {
|
1398 |
+
this.createPlayer('sby_player'+this.index);
|
1399 |
+
} else {
|
1400 |
+
var videoID = typeof videoID === 'undefined' ? this.getVideoID($clicked.closest('.sby_item')) : videoID;
|
1401 |
+
this.createPlayer('sby_player'+this.index,videoID);
|
1402 |
+
}
|
1403 |
+
} else {
|
1404 |
+
if (isPlayer) {
|
1405 |
+
var videoID = typeof videoID === 'undefined' ? this.getVideoID($self.find('.sby_item').first()) : videoID;
|
1406 |
+
|
1407 |
+
this.playVideoInPlayer(videoID);
|
1408 |
+
} else {
|
1409 |
+
var videoID = typeof videoID === 'undefined' ? this.getVideoID($clicked.closest('.sby_item')) : videoID;
|
1410 |
+
|
1411 |
+
this.changePlayerInfo($clicked.closest('.sby_item'));
|
1412 |
+
this.playVideoInPlayer(videoID);
|
1413 |
+
this.afterVideoChanged();
|
1414 |
+
}
|
1415 |
+
}
|
1416 |
+
|
1417 |
+
} else if ($(this.el).hasClass('sby_layout_grid') || $(this.el).hasClass('sby_layout_carousel')) {
|
1418 |
+
var $sbyItem = $clicked.closest('.sby_item'),
|
1419 |
+
videoID = typeof videoID === 'undefined' ? this.getVideoID($sbyItem) : videoID;
|
1420 |
+
this.playVideoInPlayer(videoID);
|
1421 |
+
this.afterVideoChanged();
|
1422 |
+
} else if ($(this.el).hasClass('sby_layout_list')) {
|
1423 |
+
var $sbyItem = $clicked.closest('.sby_item'),
|
1424 |
+
videoID = typeof videoID === 'undefined' ? this.getVideoID($sbyItem) : videoID;
|
1425 |
+
if ($sbyItem.length && !$sbyItem.find('iframe').length) {
|
1426 |
+
$sbyItem.find('.sby_loader').show().removeClass('sby_hidden');
|
1427 |
+
$sbyItem.addClass('sby_player_loading sby_player_loaded');
|
1428 |
+
this.createPlayer('sby_player_'+videoID,videoID);
|
1429 |
+
} else {
|
1430 |
+
this.playVideoInPlayer(videoID,$sbyItem.attr('data-video-id'));
|
1431 |
+
this.afterVideoChanged();
|
1432 |
+
}
|
1433 |
+
}
|
1434 |
+
},
|
1435 |
+
onThumbnailEnter: function($hovered) {
|
1436 |
+
if (!this.canCreatePlayer()) {
|
1437 |
+
return;
|
1438 |
+
}
|
1439 |
+
var $self = $(this.el);
|
1440 |
+
if ($self.hasClass('sby_layout_list')) {
|
1441 |
+
var $sbyItem = $hovered.closest('.sby_item'),
|
1442 |
+
videoID = this.getVideoID($sbyItem);
|
1443 |
+
if (!$sbyItem.find('iframe').length) {
|
1444 |
+
$sbyItem.find('.sby_loader').show().removeClass('sby_hidden');
|
1445 |
+
$sbyItem.addClass('sby_player_loading sby_player_loaded');
|
1446 |
+
this.createPlayer('sby_player_'+videoID,videoID,0);
|
1447 |
+
}
|
1448 |
+
}
|
1449 |
+
},
|
1450 |
+
onThumbnailLeave: function($hovered) {
|
1451 |
+
},
|
1452 |
+
changePlayerInfo: function($newItem) {
|
1453 |
+
|
1454 |
+
},
|
1455 |
+
playerEagerLoaded: function() {
|
1456 |
+
if (typeof this.player !== 'undefined' || $(this.el).hasClass('sby_player_loaded')) {
|
1457 |
+
return true;
|
1458 |
+
}
|
1459 |
+
},
|
1460 |
+
canCreatePlayer: function() {
|
1461 |
+
if ($(this.el).find('#sby_blank').length) {
|
1462 |
+
return false;
|
1463 |
+
}
|
1464 |
+
return this.playerEagerLoaded() || (this.playerAPIReady && this.consentGiven) || (window.sbyAPIReady && this.consentGiven);
|
1465 |
+
},
|
1466 |
+
playVideoInPlayer: function(videoID,playerID) {
|
1467 |
+
if (typeof this.player !== 'undefined' && typeof this.player.loadVideoById !== 'undefined') {
|
1468 |
+
this.player.loadVideoById(videoID);
|
1469 |
+
} else if (typeof window.sbyLightboxPlayer !== 'undefined'
|
1470 |
+
&& typeof window.sbyLightboxPlayer.loadVideoById !== 'undefined') {
|
1471 |
+
window.sbyLightboxPlayer.loadVideoById(videoID);
|
1472 |
+
} else if (typeof playerID !== 'undefined'
|
1473 |
+
&& typeof this.players !== 'undefined'
|
1474 |
+
&& typeof this.players[playerID] !== 'undefined'
|
1475 |
+
&& typeof this.players[playerID].loadVideoById !== 'undefined') {
|
1476 |
+
this.players[playerID].loadVideoById(videoID);
|
1477 |
+
}
|
1478 |
+
},
|
1479 |
+
afterVideoChanged: function() {
|
1480 |
+
if ($(this.el).hasClass('sby_layout_gallery')) {
|
1481 |
+
$(this.el).find('.sby_player_outer_wrap').removeClass('sby_player_loading');
|
1482 |
+
$(this.el).find('.sby_player_outer_wrap .sby_video_thumbnail').find('.sby_loader').hide().addClass('sby_hidden');
|
1483 |
+
|
1484 |
+
if ($(window).width() < 480) {
|
1485 |
+
$('html, body').animate({
|
1486 |
+
scrollTop: $(this.el).find('.sby_player_outer_wrap').offset().top
|
1487 |
+
}, 300);
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
}
|
1491 |
+
},
|
1492 |
+
maybeAddCTA: function(playerID,$el) {
|
1493 |
+
}
|
1494 |
+
};
|
1495 |
+
|
1496 |
+
function SbyLightboxBuilder() {}
|
1497 |
+
|
1498 |
+
SbyLightboxBuilder.prototype = {
|
1499 |
+
getData: function(a){
|
1500 |
+
var closestFeedIndex = parseInt(a.closest('.sb_youtube').attr('data-sby-index')-1);
|
1501 |
+
return {
|
1502 |
+
feedIndex : closestFeedIndex,
|
1503 |
+
link: a.attr("href"),
|
1504 |
+
video: a.attr("data-video-id")
|
1505 |
+
}
|
1506 |
+
},
|
1507 |
+
template: function () {
|
1508 |
+
return "<div id='sby_lightboxOverlay' class='sby_lightboxOverlay'></div>"+
|
1509 |
+
"<div id='sby_lightbox' class='sby_lightbox'>"+
|
1510 |
+
"<div class='sby_lb-outerContainer'>"+
|
1511 |
+
"<div class='sby_lb-container'>"+
|
1512 |
+
"<img class='sby_lb-image' alt='Lightbox image placeholder' src='' />"+
|
1513 |
+
"<div class='sby_lb-player sby_lb-player-placeholder' id='sby_lb-player'></div>" +
|
1514 |
+
"<div class='sby_lb-nav'><a class='sby_lb-prev' href='#' ><p class='sby-screenreader'>Previous Slide</p><span></span></a><a class='sby_lb-next' href='#' ><p class='sby-screenreader'>Next Slide</p><span></span></a></div>"+
|
1515 |
+
"<div class='sby_lb-loader'><a class='sby_lb-cancel'></a></div>"+
|
1516 |
+
"</div>"+
|
1517 |
+
"</div>"+
|
1518 |
+
"<div class='sby_lb-dataContainer'>"+
|
1519 |
+
"<div class='sby_lb-data'>"+
|
1520 |
+
"<div class='sby_lb-details'>"+
|
1521 |
+
"<div class='sby_lb-caption'></div>"+
|
1522 |
+
"<div class='sby_lb-info'>"+
|
1523 |
+
"<div class='sby_lb-number'></div>"+
|
1524 |
+
"</div>"+
|
1525 |
+
"</div>"+
|
1526 |
+
"<div class='sby_lb-closeContainer'><a class='sby_lb-close'></a></div>"+
|
1527 |
+
"</div>"+
|
1528 |
+
"</div>"+
|
1529 |
+
"</div>";
|
1530 |
+
},
|
1531 |
+
beforePlayerSetup: function($lightbox,data,index,album,feed){
|
1532 |
+
|
1533 |
+
},
|
1534 |
+
afterPlayerSetup: function ($lightbox,data,index,album) {
|
1535 |
+
},
|
1536 |
+
afterResize: function(){
|
1537 |
+
var playerHeight = $('#sby_lightbox .sby_lb-player').height();
|
1538 |
+
|
1539 |
+
if (playerHeight > 100) {
|
1540 |
+
var heightDif = $('#sby_lightbox .sby_lb-outerContainer').height() - playerHeight;
|
1541 |
+
if (heightDif > 10) {
|
1542 |
+
$('#sby_lightbox .sby_lb-player').css('top',heightDif/2);
|
1543 |
+
}
|
1544 |
+
}
|
1545 |
+
},
|
1546 |
+
pausePlayer: function () {
|
1547 |
+
if (typeof YT.get('sby_lb-player') !== 'undefined' && typeof YT.get('sby_lb-player').pauseVideo === 'function') {
|
1548 |
+
YT.get('sby_lb-player').pauseVideo()
|
1549 |
+
} else if (typeof window.sbyLightboxPlayer !== 'undefined' && typeof window.sbyLightboxPlayer.pauseVideo === 'function') {
|
1550 |
+
window.sbyLightboxPlayer.pauseVideo();
|
1551 |
+
}
|
1552 |
+
|
1553 |
+
}
|
1554 |
+
};
|
1555 |
+
|
1556 |
+
window.sby_init = function() {
|
1557 |
+
window.sby = new Sby();
|
1558 |
+
window.sby.createPage( window.sby.createFeeds, {whenFeedsCreated: window.sby.afterFeedsCreated});
|
1559 |
+
};
|
1560 |
+
|
1561 |
+
function sbyGetNewFeed(feed,index,feedOptions) {
|
1562 |
+
return new SbyFeed(feed,index,feedOptions);
|
1563 |
+
}
|
1564 |
+
|
1565 |
+
function sbyGetlightboxBuilder() {
|
1566 |
+
return new SbyLightboxBuilder();
|
1567 |
+
}
|
1568 |
+
|
1569 |
+
function sbyAjax(submitData,onSuccess) {
|
1570 |
+
$.ajax({
|
1571 |
+
url: sbyOptions.adminAjaxUrl,
|
1572 |
+
type: 'post',
|
1573 |
+
data: submitData,
|
1574 |
+
success: onSuccess
|
1575 |
+
});
|
1576 |
+
}
|
1577 |
+
|
1578 |
+
function sbyIsTouch() {
|
1579 |
+
if ("ontouchstart" in document.documentElement) {
|
1580 |
+
return true;
|
1581 |
+
}
|
1582 |
+
return false;
|
1583 |
+
}
|
1584 |
+
|
1585 |
+
})(jQuery);
|
1586 |
+
|
1587 |
+
if (typeof window.sbyEagerLoading === 'undefined') {
|
1588 |
+
window.sbyEagerLoading = typeof window.sbyOptions !== 'undefined' ? window.sbyOptions.eagerload : false;
|
1589 |
+
if (jQuery('div[data-vc-video-bg]').length) {
|
1590 |
+
window.sbyEagerLoading = true;
|
1591 |
+
}
|
1592 |
+
}
|
1593 |
+
if (typeof window.sbySemiEagerLoading === 'undefined') {
|
1594 |
+
window.sbySemiEagerLoading = typeof window.sbyOptions !== 'undefined' ? window.sbyOptions.semiEagerload : false;
|
1595 |
+
if (jQuery('div[data-vc-video-bg]').length || window.sbyEagerLoading) {
|
1596 |
+
window.sbySemiEagerLoading = false;
|
1597 |
+
}
|
1598 |
+
}
|
1599 |
+
|
1600 |
+
jQuery(document).ready(function($) {
|
1601 |
+
if (!window.sbySemiEagerLoading) {
|
1602 |
+
sby_init();
|
1603 |
+
}
|
1604 |
+
});
|
1605 |
+
|
1606 |
+
} // if sby_js_exists
|
1607 |
+
|
1608 |
+
if (window.sbySemiEagerLoading) {
|
1609 |
+
var sbyYScriptId = "sby-youtube-api";
|
1610 |
+
var sbyYScript = document.getElementById(sbyYScriptId);
|
1611 |
+
|
1612 |
+
if (sbyYScript === null) {
|
1613 |
+
var tag = document.createElement("script");
|
1614 |
+
var firstScript = document.getElementsByTagName("script")[0];
|
1615 |
+
|
1616 |
+
tag.src = "https://www.youtube.com/iframe_api";
|
1617 |
+
tag.id = sbyYScriptId;
|
1618 |
+
firstScript.parentNode.insertBefore(tag, firstScript);
|
1619 |
+
|
1620 |
+
}
|
1621 |
+
}
|
1622 |
+
|
1623 |
+
window.onYouTubeIframeAPIReady = function() {
|
1624 |
+
var numFeeds = document.getElementsByClassName('sb_youtube').length;
|
1625 |
+
if (numFeeds > 0) {
|
1626 |
+
if (window.sbySemiEagerLoading) {
|
1627 |
+
if (typeof window.sby !== 'undefined') {
|
1628 |
+
for (var i = 0; i < numFeeds; i++) {
|
1629 |
+
window.sby.feeds[i].playerAPIReady = true;
|
1630 |
+
}
|
1631 |
+
} else {
|
1632 |
+
window.sbyAPIReady = true;
|
1633 |
+
}
|
1634 |
+
sby_init();
|
1635 |
+
} else {
|
1636 |
+
jQuery('.sb_youtube').each(function(index) {
|
1637 |
+
var $self = jQuery(this);
|
1638 |
+
if ($self.find('.sby_live_player').length) {
|
1639 |
+
player = new YT.Player($self.find('.sby_live_player').attr('id'), {
|
1640 |
+
events: {
|
1641 |
+
'onReady': function () {
|
1642 |
+
$self.find('.sby_live_player').hide();
|
1643 |
+
$self.find('.sby_item').remove();
|
1644 |
+
var videoID = YT.get($self.find('.sby_live_player').attr('id')).getVideoData().video_id;
|
1645 |
+
$self.find('.sby_player_video_thumbnail').attr('data-video-id',videoID).css('z-index',-1);
|
1646 |
+
var itemOffset = $self.find('.sby_item').length,
|
1647 |
+
submitData = {
|
1648 |
+
action: 'sby_live_retrieve',
|
1649 |
+
video_id: videoID,
|
1650 |
+
feed_id: $self.attr('data-feedid'),
|
1651 |
+
atts: $self.attr('data-shortcode-atts'),
|
1652 |
+
};
|
1653 |
+
var onSuccess = function (data) {
|
1654 |
+
if (data.trim().indexOf('{') === 0) {
|
1655 |
+
var feed = window.sby.feeds[index],
|
1656 |
+
response = JSON.parse(data),
|
1657 |
+
checkWPPosts = typeof response.feedStatus.checkWPPosts !== 'undefined' ? response.feedStatus.checkWPPosts : false;
|
1658 |
+
if (feed.settings.debugEnabled) {
|
1659 |
+
console.log(response);
|
1660 |
+
}
|
1661 |
+
if (checkWPPosts) {
|
1662 |
+
feed.settings.checkWPPosts = true;
|
1663 |
+
} else {
|
1664 |
+
feed.settings.checkWPPosts = false;
|
1665 |
+
}
|
1666 |
+
feed.appendNewPosts(response.html);
|
1667 |
+
feed.addResizedImages(response.resizedImages);
|
1668 |
+
|
1669 |
+
feed.afterInitialImagesLoaded();
|
1670 |
+
|
1671 |
+
if (!response.feedStatus.shouldPaginate) {
|
1672 |
+
feed.outOfPages = true;
|
1673 |
+
$self.find('.sby_load_btn').hide();
|
1674 |
+
} else {
|
1675 |
+
feed.outOfPages = false;
|
1676 |
+
}
|
1677 |
+
|
1678 |
+
jQuery('.sby_no_js').removeClass('sby_no_js');
|
1679 |
+
$self.find('.sby_live_player').remove();
|
1680 |
+
if ($self.hasClass('sby_layout_gallery')) {
|
1681 |
+
feed.createPlayer('sby_player'+feed.index);
|
1682 |
+
}
|
1683 |
+
$self.find('.sby_player_item').css('opacity',1);
|
1684 |
+
$self.find('.sby_item').css('opacity',1);
|
1685 |
+
$self.find('.sby_player_loading').removeClass('sby_player_loading');
|
1686 |
+
if ($self.hasClass('sby_layout_list')) {
|
1687 |
+
$self.find('.sby_item_video_thumbnail').mouseenter(function() {
|
1688 |
+
jQuery(this).css('z-index',-1);
|
1689 |
+
})
|
1690 |
+
}
|
1691 |
+
|
1692 |
+
}
|
1693 |
+
|
1694 |
+
};
|
1695 |
+
jQuery.ajax({
|
1696 |
+
url: sbyOptions.adminAjaxUrl,
|
1697 |
+
type: 'post',
|
1698 |
+
data: submitData,
|
1699 |
+
success: onSuccess
|
1700 |
+
});
|
1701 |
+
}
|
1702 |
+
}
|
1703 |
+
});
|
1704 |
+
}
|
1705 |
+
});
|
1706 |
+
|
1707 |
+
if (window.sbyEagerLoading) {
|
1708 |
+
var flagLightbox = false,
|
1709 |
+
autoplay = false;
|
1710 |
+
|
1711 |
+
jQuery('.sb_youtube').each(function(index) {
|
1712 |
+
var $self = jQuery(this);
|
1713 |
+
|
1714 |
+
if ($self.hasClass('sby_layout_list')) {
|
1715 |
+
jQuery(this).addClass('sby_player_loaded');
|
1716 |
+
|
1717 |
+
$self.find('.sby_item').each(function() {
|
1718 |
+
videoID = jQuery(this).attr('data-video-id');
|
1719 |
+
//this.createPlayer(,videoID,0);
|
1720 |
+
player = new YT.Player('sby_player_'+videoID, {
|
1721 |
+
height: '100',
|
1722 |
+
width: '100',
|
1723 |
+
videoId: videoID,
|
1724 |
+
playerVars: {
|
1725 |
+
modestbranding: 1,
|
1726 |
+
rel: 0,
|
1727 |
+
autoplay: autoplay
|
1728 |
+
},
|
1729 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|