Version Description
- New: Retrieving Access Tokens and connecting multiple Instagram accounts is now easier using our improved interface for managing account information. While on the Configure tab, click on the big blue button to connect an account, or use the "Manually Connect an Account" option to connect one using an existing Access Token. Once an account is connected, you can use the associated buttons to either add it to your primary User feed or to a different feed on your site using the
user
shortcode option, eg:user=smashballoon
. - Tweak: Disabled auto load in the database for backup caches
- Fix: Fixed an occasional issue with the Instagram login flow which would result in an "Unauthorized redirect URL" error
Download this release
Release Info
Developer | smashballoon |
Plugin | Instagram Feed |
Version | 1.9 |
Comparing to | |
See all releases |
Code changes from version 1.8.3 to 1.9
- README.txt +6 -1
- css/sb-instagram-admin.css +348 -2
- instagram-feed-admin.php +379 -49
- instagram-feed.php +82 -20
- js/sb-instagram-admin.js +299 -37
- js/sb-instagram.min.js +1 -1
README.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: smashballoon, craig-at-smash-balloon
|
|
3 |
Tags: Instagram, Instagram feed, Instagram photos, Instagram widget, Instagram gallery
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.9
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -310,6 +310,11 @@ We understand that sometimes you need help, have issues or just have questions.
|
|
310 |
* Plus more customization options added all the time!
|
311 |
|
312 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
313 |
= 1.8.3 =
|
314 |
* Fix: SVG icons caused some display problems in IE 11
|
315 |
* Fix: Removed support for using usernames in the User ID setting due to recent API changes. Will now default to the User ID attached to the Access Token.
|
3 |
Tags: Instagram, Instagram feed, Instagram photos, Instagram widget, Instagram gallery
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.9
|
6 |
+
Stable tag: 1.9
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
310 |
* Plus more customization options added all the time!
|
311 |
|
312 |
== Changelog ==
|
313 |
+
= 1.9 =
|
314 |
+
* New: Retrieving Access Tokens and connecting multiple Instagram accounts is now easier using our improved interface for managing account information. While on the Configure tab, click on the big blue button to connect an account, or use the "Manually Connect an Account" option to connect one using an existing Access Token. Once an account is connected, you can use the associated buttons to either add it to your primary User feed or to a different feed on your site using the `user` shortcode option, eg: `user=smashballoon`.
|
315 |
+
* Tweak: Disabled auto load in the database for backup caches
|
316 |
+
* Fix: Fixed an occasional issue with the Instagram login flow which would result in an "Unauthorized redirect URL" error
|
317 |
+
|
318 |
= 1.8.3 =
|
319 |
* Fix: SVG icons caused some display problems in IE 11
|
320 |
* Fix: Removed support for using usernames in the User ID setting due to recent API changes. Will now default to the User ID attached to the Access Token.
|
css/sb-instagram-admin.css
CHANGED
@@ -50,6 +50,7 @@
|
|
50 |
padding: 0 21px 0 160px;
|
51 |
height: 47px;
|
52 |
line-height: 47px;
|
|
|
53 |
|
54 |
background: #386793 url('../img/small-logo.png') no-repeat 16px 11px;
|
55 |
|
@@ -122,7 +123,7 @@
|
|
122 |
}
|
123 |
|
124 |
#sbi_admin .sbi_radio_label{
|
125 |
-
width:
|
126 |
padding-top: 5px;
|
127 |
|
128 |
display: -moz-inline-stack;
|
@@ -176,6 +177,7 @@
|
|
176 |
#sbi_admin .sbi_row{
|
177 |
display: block;
|
178 |
width: 100%;
|
|
|
179 |
}
|
180 |
#sbi_admin .sbi_pro,
|
181 |
#sbi_admin .sbi_pro label{
|
@@ -572,4 +574,348 @@
|
|
572 |
-webkit-transition: all 0.1s ease-in-out;
|
573 |
-o-transition: all 0.1s ease-in-out;
|
574 |
transition: all 0.1s ease-in-out;
|
575 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
padding: 0 21px 0 160px;
|
51 |
height: 47px;
|
52 |
line-height: 47px;
|
53 |
+
font-size: 14px;
|
54 |
|
55 |
background: #386793 url('../img/small-logo.png') no-repeat 16px 11px;
|
56 |
|
123 |
}
|
124 |
|
125 |
#sbi_admin .sbi_radio_label{
|
126 |
+
width: 90px;
|
127 |
padding-top: 5px;
|
128 |
|
129 |
display: -moz-inline-stack;
|
177 |
#sbi_admin .sbi_row{
|
178 |
display: block;
|
179 |
width: 100%;
|
180 |
+
clear: left;
|
181 |
}
|
182 |
#sbi_admin .sbi_pro,
|
183 |
#sbi_admin .sbi_pro label{
|
574 |
-webkit-transition: all 0.1s ease-in-out;
|
575 |
-o-transition: all 0.1s ease-in-out;
|
576 |
transition: all 0.1s ease-in-out;
|
577 |
+
}
|
578 |
+
/* Connected Accounts */
|
579 |
+
#sbi_admin .sbi_connected_account {
|
580 |
+
position: relative;
|
581 |
+
box-sizing: border-box;
|
582 |
+
padding: 10px 35px 10px 10px;;
|
583 |
+
border-radius: 5px;
|
584 |
+
background: #fff;
|
585 |
+
margin-bottom: 5px;
|
586 |
+
overflow: hidden;
|
587 |
+
clear: both;
|
588 |
+
border: 1px solid #ddd;
|
589 |
+
}
|
590 |
+
#sbi_admin .sbi_connected_account .sbi_ca_avatar{
|
591 |
+
margin-right: 15px;
|
592 |
+
}
|
593 |
+
#sbi_admin .sbi_connected_account .sbi_ca_username {
|
594 |
+
margin-left: 0;
|
595 |
+
margin-right: 15px;
|
596 |
+
}
|
597 |
+
#sbi_admin .sbi_ca_username {
|
598 |
+
line-height: 38px;
|
599 |
+
margin-left: 15px;
|
600 |
+
float: left;
|
601 |
+
font-size: 18px;
|
602 |
+
}
|
603 |
+
#sbi_admin .sbi_ca_actions {
|
604 |
+
display: inline-block;
|
605 |
+
}
|
606 |
+
#sbi_admin .sbi_ca_actions .fa{
|
607 |
+
margin-right: 5px;
|
608 |
+
}
|
609 |
+
#sbi_admin .sbi_delete_account .sbi_remove_text{
|
610 |
+
display: inline-block;
|
611 |
+
margin-left: 5px;
|
612 |
+
padding: 5px 10px 5px 0;
|
613 |
+
}
|
614 |
+
#sbi_admin .sbi_ca_actions a.button-primary,
|
615 |
+
#sbi_admin .sbi_ca_actions a.button-secondary,
|
616 |
+
#sbi_admin .sbi_ca_accesstoken a.sbi_ca_token_shortcode {
|
617 |
+
font-size: 12px;
|
618 |
+
padding: 6px;
|
619 |
+
height: auto;
|
620 |
+
line-height: 1;
|
621 |
+
margin: 7px 5px 0 0;
|
622 |
+
vertical-align: top;
|
623 |
+
}
|
624 |
+
#sbi_admin .sbi_ca_at_is_valid {
|
625 |
+
margin-top: 10px;
|
626 |
+
display: none;
|
627 |
+
}
|
628 |
+
|
629 |
+
@-webkit-keyframes sbi_flash {
|
630 |
+
0% {
|
631 |
+
background-color: #cae2a5;
|
632 |
+
opacity:1;
|
633 |
+
border: 1px solid #b2ce88;
|
634 |
+
}
|
635 |
+
100% {
|
636 |
+
background-color: #fff;
|
637 |
+
}
|
638 |
+
}
|
639 |
+
#sbi_admin .sbi_account_updated{
|
640 |
+
border: 1px solid #ddd;
|
641 |
+
background: #fff;
|
642 |
+
|
643 |
+
-webkit-animation-name: sbi_flash;
|
644 |
+
-webkit-animation-duration: 700ms;
|
645 |
+
-webkit-animation-iteration-count: 1;
|
646 |
+
-webkit-animation-timing-function: linear;
|
647 |
+
-moz-animation-name: sbi_flash;
|
648 |
+
-moz-animation-duration: 700ms;
|
649 |
+
-moz-animation-iteration-count: 1;
|
650 |
+
-moz-animation-timing-function: linear;
|
651 |
+
}
|
652 |
+
|
653 |
+
#sbi_admin .sbi_account_active{
|
654 |
+
border: 1px solid #b2ce88;
|
655 |
+
background: #ecf2e3;
|
656 |
+
}
|
657 |
+
|
658 |
+
#sbi_admin .sbi_ca_alert {
|
659 |
+
display: none;
|
660 |
+
}
|
661 |
+
#sbi_admin .sbi_account_invalid .sbi_ca_alert {
|
662 |
+
display: block;
|
663 |
+
}
|
664 |
+
#sbi_admin .sbi_ca_avatar{
|
665 |
+
float: left;
|
666 |
+
width: 40px;
|
667 |
+
height: 40px;
|
668 |
+
border-radius: 5px;
|
669 |
+
}
|
670 |
+
#sbi_admin .sbi_ca_accesstoken{
|
671 |
+
display: none;
|
672 |
+
width: 100%;
|
673 |
+
float: left;
|
674 |
+
clear: both;
|
675 |
+
margin-top: 10px;
|
676 |
+
}
|
677 |
+
#sbi_admin .sbi_ca_token_label{
|
678 |
+
display: inline-block;
|
679 |
+
position: relative;
|
680 |
+
background: #f9f9f9;
|
681 |
+
color: #555;
|
682 |
+
padding: 3px 5px;
|
683 |
+
font-size: 12px;
|
684 |
+
border: 1px solid #d6d6d6;
|
685 |
+
height: 16px;
|
686 |
+
line-height: 15px;
|
687 |
+
border-radius: 4px 0 0 4px;
|
688 |
+
}
|
689 |
+
#sbi_admin .sbi_ca_token{
|
690 |
+
position: relative;
|
691 |
+
top: 1px;
|
692 |
+
padding: 3px 10px;
|
693 |
+
border: 1px solid #d6d6d6;
|
694 |
+
border-left: none;
|
695 |
+
font-size: 12px;
|
696 |
+
border-radius: 0 4px 4px 0;
|
697 |
+
background: rgba(255,255,255,0.8);
|
698 |
+
width: 510px;
|
699 |
+
display: inline-block;
|
700 |
+
margin-left: 0;
|
701 |
+
}
|
702 |
+
#sbi_admin .sbi_ca_accesstoken a.sbi_ca_token_shortcode{
|
703 |
+
margin-top: 0;
|
704 |
+
margin: 8px;
|
705 |
+
padding: 6px;
|
706 |
+
height: auto;
|
707 |
+
line-height: 1;
|
708 |
+
}
|
709 |
+
|
710 |
+
#sbi_admin .sbi_delete_account{
|
711 |
+
position: absolute;
|
712 |
+
right: 10px;
|
713 |
+
top: 10px;
|
714 |
+
|
715 |
+
padding: 0;
|
716 |
+
background: rgba(0,0,0,0.05);
|
717 |
+
color: #666;
|
718 |
+
border-radius: 50px;
|
719 |
+
text-decoration: none;
|
720 |
+
font-size: 12px;
|
721 |
+
}
|
722 |
+
#sbi_admin .sbi_delete_account:hover,
|
723 |
+
#sbi_admin .sbi_delete_account:focus{
|
724 |
+
background: #333;
|
725 |
+
color: #ddd;
|
726 |
+
}
|
727 |
+
#sbi_admin .sbi_delete_account .fa{
|
728 |
+
padding: 5px 0 5px 10px;
|
729 |
+
}
|
730 |
+
|
731 |
+
.sbi_connected_accounts_wrap{
|
732 |
+
vertical-align: top;
|
733 |
+
}
|
734 |
+
#sbi_admin .sbi_no_accounts{
|
735 |
+
display: inline-block;
|
736 |
+
padding: 6px 12px;
|
737 |
+
border-radius: 8px;
|
738 |
+
background: rgba(255,255,255,0.8);
|
739 |
+
margin-bottom: 5px;
|
740 |
+
}
|
741 |
+
#sbi_admin #sbi_manual_submit:active{
|
742 |
+
vertical-align: unset;
|
743 |
+
}
|
744 |
+
#sbi_admin .sbi_manually_connect_wrap{
|
745 |
+
padding-top: 5px;
|
746 |
+
}
|
747 |
+
#sbi_admin .sbi_user_feed_account_wrap:first-child{
|
748 |
+
padding-top: 5px;
|
749 |
+
}
|
750 |
+
#sbi_admin .sbi_user_feed_account_wrap:last-child{
|
751 |
+
padding-bottom: 15px;
|
752 |
+
}
|
753 |
+
#sbi_admin .sbi_user_feed_account_wrap{
|
754 |
+
padding-bottom: 5px;
|
755 |
+
}
|
756 |
+
#sbi_admin .sbi_user_feed_account_wrap span{
|
757 |
+
font-size: 13px;
|
758 |
+
}
|
759 |
+
/*#sbi_admin .sbi_remove_from_user_feed{
|
760 |
+
background: #71ad26;
|
761 |
+
color: #fff;
|
762 |
+
border: none;
|
763 |
+
box-shadow: none;
|
764 |
+
}*/
|
765 |
+
#sbi_admin .sbi_ca_info{
|
766 |
+
overflow: hidden;
|
767 |
+
}
|
768 |
+
#sbi_admin .sbi_ca_show_token{
|
769 |
+
display: inline-block;
|
770 |
+
padding: 10px 5px 0px 5px;
|
771 |
+
margin: 0;
|
772 |
+
font-size: 12px;
|
773 |
+
vertical-align: top;
|
774 |
+
}
|
775 |
+
#sbi_admin .sbi_ca_shortcode{
|
776 |
+
display: none;
|
777 |
+
padding: 0;
|
778 |
+
width: 100%;
|
779 |
+
float: left;
|
780 |
+
clear: both;
|
781 |
+
margin: 10px 0 0 0;
|
782 |
+
}
|
783 |
+
#sbi_admin .sbi_ca_shortcode p{
|
784 |
+
padding-bottom: 10px;
|
785 |
+
font-size: 13px;
|
786 |
+
}
|
787 |
+
#sbi_admin .sbi_ca_shortcode code{
|
788 |
+
margin-top: 5px;
|
789 |
+
display: inline-block;
|
790 |
+
}
|
791 |
+
#sbi_admin .sbi_user_feed_ids_wrap .sbi_ca_avatar{
|
792 |
+
width: 20px;
|
793 |
+
height: 20px;
|
794 |
+
position: relative;
|
795 |
+
top: 5px;
|
796 |
+
margin-right: 8px;
|
797 |
+
border-radius: 4px;
|
798 |
+
}
|
799 |
+
|
800 |
+
#sbi_admin .sbi_col {
|
801 |
+
float: left;
|
802 |
+
}
|
803 |
+
#sbi_admin .sbi_col.sbi_one{
|
804 |
+
width: 118px;
|
805 |
+
}
|
806 |
+
#sbi_admin #sb_instagram_coordinates_options .sbi_col.sbi_one{
|
807 |
+
width: 70px;
|
808 |
+
}
|
809 |
+
#sbi_admin .sbi_col.sbi_two{
|
810 |
+
/*width: 600px;*/
|
811 |
+
width: 75%;
|
812 |
+
}
|
813 |
+
#sbi_admin .sbi_row input[type=radio]{
|
814 |
+
margin: 5px 2px 0 0;
|
815 |
+
}
|
816 |
+
|
817 |
+
|
818 |
+
@media all and (max-width: 1200px){
|
819 |
+
#sbi_admin .sbi_delete_account .sbi_remove_text{
|
820 |
+
display: none;
|
821 |
+
}
|
822 |
+
#sbi_admin .sbi_ca_token_label{
|
823 |
+
display: none;
|
824 |
+
}
|
825 |
+
#sbi_admin .sbi_ca_token{
|
826 |
+
border-left: 1px solid #d6d6d6;
|
827 |
+
border-radius: 4px;
|
828 |
+
}
|
829 |
+
}
|
830 |
+
@media all and (max-width: 800px){
|
831 |
+
#sbi_admin .sbi_col.sbi_one {
|
832 |
+
width: 25%;
|
833 |
+
margin-right: 5%;
|
834 |
+
}
|
835 |
+
#sbi_admin .sbi_col.sbi_two{
|
836 |
+
width: 70%;
|
837 |
+
}
|
838 |
+
}
|
839 |
+
|
840 |
+
/* Config info */
|
841 |
+
#sbi_config{
|
842 |
+
float: left;
|
843 |
+
width: 100%;
|
844 |
+
clear: both;
|
845 |
+
margin: 10px 0 10px 0;
|
846 |
+
}
|
847 |
+
#sbi_config_info{
|
848 |
+
position: fixed;
|
849 |
+
z-index: 999;
|
850 |
+
width: 100%;
|
851 |
+
top: 0;
|
852 |
+
right: 0;
|
853 |
+
bottom: 0;
|
854 |
+
left: 0;
|
855 |
+
|
856 |
+
background: rgba(0,0,0,0.3);
|
857 |
+
}
|
858 |
+
#sbi_config_info .sbi_config_modal{
|
859 |
+
position: absolute;
|
860 |
+
top: 180px;
|
861 |
+
left: 50%;
|
862 |
+
width: 350px;
|
863 |
+
|
864 |
+
margin: 0 0 0 -195px;
|
865 |
+
padding: 20px;
|
866 |
+
background: #fff;
|
867 |
+
text-align: center;
|
868 |
+
|
869 |
+
-webkit-box-shadow: 0 1px 20px rgba(0,0,0,0.2);
|
870 |
+
box-shadow: 0 1px 20px rgba(0,0,0,0.2);
|
871 |
+
|
872 |
+
-moz-border-radius: 3px;
|
873 |
+
-webkit-border-radius: 3px;
|
874 |
+
border-radius: 3px;
|
875 |
+
}
|
876 |
+
.sb_get_token .submit {
|
877 |
+
display: inline-block;
|
878 |
+
margin: 0 0 0 10px;
|
879 |
+
padding: 0;
|
880 |
+
}
|
881 |
+
.sbi_config_modal .sbi_submit{
|
882 |
+
clear: both;
|
883 |
+
width: 100%;
|
884 |
+
margin: 15px 0 5px 0;
|
885 |
+
text-align: center;
|
886 |
+
}
|
887 |
+
.sbi_config_modal .button{
|
888 |
+
margin: 0 5px;
|
889 |
+
}
|
890 |
+
#sbi_admin #sbi_connect_account:active{
|
891 |
+
margin-top: 0;
|
892 |
+
}
|
893 |
+
.sbi_config_modal .sbi_ca_username {
|
894 |
+
float: none;
|
895 |
+
margin: 10px 0 0 10px;
|
896 |
+
font-size: 18px;
|
897 |
+
line-height: 1.2;
|
898 |
+
|
899 |
+
display: inline-block;
|
900 |
+
position: relative;
|
901 |
+
top: -13px;
|
902 |
+
}
|
903 |
+
.sbi_config_modal .sbi_ca_avatar{
|
904 |
+
float: none;
|
905 |
+
width: 40px;
|
906 |
+
height: 40px;
|
907 |
+
border-radius: 5px;
|
908 |
+
}
|
909 |
+
.sbi_config_modal .sbi_modal_close{
|
910 |
+
position: absolute;
|
911 |
+
top: 0;
|
912 |
+
right: 0;
|
913 |
+
padding: 10px;
|
914 |
+
font-size: 14px;
|
915 |
+
color: #ccc;
|
916 |
+
margin: 0;
|
917 |
+
}
|
918 |
+
.sbi_config_modal .sbi_modal_close:focus,
|
919 |
+
.sbi_config_modal .sbi_modal_close:hover{
|
920 |
+
color: #333;
|
921 |
+
}
|
instagram-feed-admin.php
CHANGED
@@ -129,8 +129,16 @@ function sb_instagram_settings_page() {
|
|
129 |
if( isset($_POST[ $sb_instagram_configure_hidden_field ]) && $_POST[ $sb_instagram_configure_hidden_field ] == 'Y' ) {
|
130 |
|
131 |
$sb_instagram_at = sanitize_text_field( $_POST[ 'sb_instagram_at' ] );
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
isset($_POST[ 'sb_instagram_preserve_settings' ]) ? $sb_instagram_preserve_settings = sanitize_text_field( $_POST[ 'sb_instagram_preserve_settings' ] ) : $sb_instagram_preserve_settings = '';
|
135 |
isset($_POST[ 'sb_instagram_ajax_theme' ]) ? $sb_instagram_ajax_theme = sanitize_text_field( $_POST[ 'sb_instagram_ajax_theme' ] ) : $sb_instagram_ajax_theme = '';
|
136 |
isset($_POST[ 'sb_instagram_cache_time' ]) ? $sb_instagram_cache_time = sanitize_text_field( $_POST[ 'sb_instagram_cache_time' ] ) : $sb_instagram_cache_time = '';
|
@@ -265,6 +273,9 @@ function sb_instagram_settings_page() {
|
|
265 |
$options['sbi_font_method'] = $sbi_font_method;
|
266 |
$options[ 'sb_instagram_disable_awesome' ] = $sb_instagram_disable_awesome;
|
267 |
|
|
|
|
|
|
|
268 |
//Delete all SBI transients
|
269 |
global $wpdb;
|
270 |
$table_name = $wpdb->prefix . "options";
|
@@ -348,18 +359,102 @@ function sb_instagram_settings_page() {
|
|
348 |
|
349 |
<div id="sbi_config">
|
350 |
<!-- <a href="https://instagram.com/oauth/authorize/?client_id=1654d0c81ad04754a898d89315bec227&redirect_uri=https://smashballoon.com/instagram-feed/instagram-token-plugin/?return_uri=<?php echo admin_url('admin.php?page=sb-instagram-feed'); ?>&response_type=token" class="sbi_admin_btn"><?php _e( 'Log in and get my Access Token and User ID', 'instagram-feed' ); ?></a> -->
|
351 |
-
<a href="https://instagram.com/oauth/authorize/?client_id=3a81a9fa2a064751b8c31385b91cc25c&scope=basic+public_content&redirect_uri=https://smashballoon.com/instagram-feed/instagram-token-plugin/?return_uri=<?php echo admin_url('admin.php?page=sb-instagram-feed'); ?>&response_type=token" class="sbi_admin_btn"
|
352 |
<a href="https://smashballoon.com/instagram-feed/token/" target="_blank" style="position: relative; top: 14px; left: 15px;"><?php _e( 'Button not working?', 'instagram-feed' ); ?></a>
|
353 |
</div>
|
354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
<tr valign="top">
|
356 |
-
<th scope="row"><label><?php _e( '
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
</td>
|
364 |
</tr>
|
365 |
|
@@ -368,46 +463,74 @@ function sb_instagram_settings_page() {
|
|
368 |
Eg: type=user id=12986477
|
369 |
</code></th>
|
370 |
<td>
|
371 |
-
<
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
|
384 |
-
<div class="sbi_notice sbi_other_user_error">
|
385 |
-
<?php _e("<p>Due to <a href='https://smashballoon.com/instagram-api-changes-april-4-2018/' target='_blank'>recent changes</a> in the Instagram API it's no longer possible to display feeds from user accounts which are not your own. You can find your user ID by clicking the Instagram login button above, or by using the first part of your Access Token before the dot. Eg: <b><span style='background: yellow;'>1234567890</span>.xxxxxxxxxxxxxxxxxxxxx</b>.</p>", 'instagram-feed'); ?>
|
386 |
</div>
|
387 |
|
388 |
-
<
|
389 |
-
<
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
<
|
394 |
-
|
|
|
|
|
|
|
|
|
395 |
|
396 |
<div class="sbi_pro sbi_row">
|
397 |
-
<
|
398 |
-
|
399 |
-
|
|
|
|
|
|
|
|
|
400 |
<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed' ); ?></a><span class="sbi_note"> - <a href="https://smashballoon.com/instagram-feed/" target="_blank">Upgrade to Pro to show single posts</a></span>
|
401 |
-
|
|
|
402 |
</div>
|
403 |
|
404 |
-
<
|
405 |
-
<
|
406 |
-
|
407 |
-
|
|
|
|
|
|
|
408 |
<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed' ); ?></a><span class="sbi_note"> - <a href="https://smashballoon.com/instagram-feed/" target="_blank">Upgrade to Pro to show posts by Location</a></span>
|
409 |
<p class="sbi_tooltip"><?php _e( 'Display posts from an Instagram location ID or location coordinates.', 'instagram-feed' ); ?></p>
|
410 |
-
|
|
|
411 |
</td>
|
412 |
</tr>
|
413 |
|
@@ -1656,7 +1779,12 @@ if ( $url !== 'no_at' ) {
|
|
1656 |
} else {
|
1657 |
echo 'No Access Token';
|
1658 |
}?>
|
1659 |
-
|
|
|
|
|
|
|
|
|
|
|
1660 |
|
1661 |
<?php
|
1662 |
} //End Support tab
|
@@ -1848,18 +1976,220 @@ function sb_instagram_clear_page_caches() {
|
|
1848 |
* retrieved with the big blue button
|
1849 |
*/
|
1850 |
function sbi_auto_save_tokens() {
|
1851 |
-
|
1852 |
-
|
1853 |
|
1854 |
-
|
1855 |
-
|
|
|
|
|
1856 |
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1860 |
}
|
1861 |
add_action( 'wp_ajax_sbi_auto_save_tokens', 'sbi_auto_save_tokens' );
|
1862 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1863 |
// variables to define certain terms
|
1864 |
$transient = 'instagram_feed_rating_notice_waiting';
|
1865 |
$option = 'sbi_rating_notice';
|
129 |
if( isset($_POST[ $sb_instagram_configure_hidden_field ]) && $_POST[ $sb_instagram_configure_hidden_field ] == 'Y' ) {
|
130 |
|
131 |
$sb_instagram_at = sanitize_text_field( $_POST[ 'sb_instagram_at' ] );
|
132 |
+
$sb_instagram_user_id = array();
|
133 |
+
if ( isset( $_POST[ 'sb_instagram_user_id' ] )) {
|
134 |
+
if ( is_array( $_POST[ 'sb_instagram_user_id' ] ) ) {
|
135 |
+
foreach( $_POST[ 'sb_instagram_user_id' ] as $user_id ) {
|
136 |
+
$sb_instagram_user_id[] = sanitize_text_field( $user_id );
|
137 |
+
}
|
138 |
+
} else {
|
139 |
+
$sb_instagram_user_id[] = sanitize_text_field( $_POST[ 'sb_instagram_user_id' ] );
|
140 |
+
}
|
141 |
+
}
|
142 |
isset($_POST[ 'sb_instagram_preserve_settings' ]) ? $sb_instagram_preserve_settings = sanitize_text_field( $_POST[ 'sb_instagram_preserve_settings' ] ) : $sb_instagram_preserve_settings = '';
|
143 |
isset($_POST[ 'sb_instagram_ajax_theme' ]) ? $sb_instagram_ajax_theme = sanitize_text_field( $_POST[ 'sb_instagram_ajax_theme' ] ) : $sb_instagram_ajax_theme = '';
|
144 |
isset($_POST[ 'sb_instagram_cache_time' ]) ? $sb_instagram_cache_time = sanitize_text_field( $_POST[ 'sb_instagram_cache_time' ] ) : $sb_instagram_cache_time = '';
|
273 |
$options['sbi_font_method'] = $sbi_font_method;
|
274 |
$options[ 'sb_instagram_disable_awesome' ] = $sb_instagram_disable_awesome;
|
275 |
|
276 |
+
//clear expired tokens
|
277 |
+
delete_option( 'sb_expired_tokens' );
|
278 |
+
|
279 |
//Delete all SBI transients
|
280 |
global $wpdb;
|
281 |
$table_name = $wpdb->prefix . "options";
|
359 |
|
360 |
<div id="sbi_config">
|
361 |
<!-- <a href="https://instagram.com/oauth/authorize/?client_id=1654d0c81ad04754a898d89315bec227&redirect_uri=https://smashballoon.com/instagram-feed/instagram-token-plugin/?return_uri=<?php echo admin_url('admin.php?page=sb-instagram-feed'); ?>&response_type=token" class="sbi_admin_btn"><?php _e( 'Log in and get my Access Token and User ID', 'instagram-feed' ); ?></a> -->
|
362 |
+
<a href="https://instagram.com/oauth/authorize/?client_id=3a81a9fa2a064751b8c31385b91cc25c&scope=basic+public_content&redirect_uri=https://smashballoon.com/instagram-feed/instagram-token-plugin/?return_uri=<?php echo admin_url('admin.php?page=sb-instagram-feed'); ?>&response_type=token&state=<?php echo admin_url('admin.php?page-sb-instagram-feed'); ?>" class="sbi_admin_btn"><i class="fa fa-user-plus" aria-hidden="true" style="font-size: 20px;"></i> <?php _e( 'Connect an Instagram Account', 'instagram-feed' ); ?></a>
|
363 |
<a href="https://smashballoon.com/instagram-feed/token/" target="_blank" style="position: relative; top: 14px; left: 15px;"><?php _e( 'Button not working?', 'instagram-feed' ); ?></a>
|
364 |
</div>
|
365 |
+
|
366 |
+
<!-- Old Access Token -->
|
367 |
+
<input name="sb_instagram_at" id="sb_instagram_at" type="hidden" value="<?php echo esc_attr( $sb_instagram_at ); ?>" size="80" maxlength="100" placeholder="Click button above to get your Access Token" />
|
368 |
+
|
369 |
+
<?php
|
370 |
+
|
371 |
+
$returned_data = sbi_get_connected_accounts_data( $sb_instagram_at );
|
372 |
+
$connected_accounts = $returned_data['connected_accounts'];
|
373 |
+
$user_feeds_returned = isset( $returned_data['user_ids'] ) ? $returned_data['user_ids'] : false;
|
374 |
+
if ( $user_feeds_returned ) {
|
375 |
+
$user_feed_ids = $user_feeds_returned;
|
376 |
+
} else {
|
377 |
+
$user_feed_ids = ! is_array( $sb_instagram_user_id ) ? explode( ',', $sb_instagram_user_id ) : $sb_instagram_user_id;
|
378 |
+
}
|
379 |
+
$expired_tokens = get_option( 'sb_expired_tokens', array() );
|
380 |
+
$sb_instagram_type = 'user';
|
381 |
+
?>
|
382 |
+
|
383 |
<tr valign="top">
|
384 |
+
<th scope="row"><label><?php _e( 'Instagram Accounts', 'instagram-feed' ); ?></label><span style="font-weight:normal; font-style:italic; font-size: 12px; display: block;">Use the button above to connect an Instagram account</span></th>
|
385 |
+
<td class="sbi_connected_accounts_wrap">
|
386 |
+
<?php if ( empty( $connected_accounts ) ) : ?>
|
387 |
+
<p class="sbi_no_accounts"><?php _e( 'No Instagram accounts connected. Click the button above to connect an account.', 'instagram-feed' ); ?></p><br />
|
388 |
+
<?php else: ?>
|
389 |
+
<?php foreach ( $connected_accounts as $account ) :
|
390 |
+
$username = $account['username'] ? $account['username'] : $account['user_id'];
|
391 |
+
$profile_picture = $account['profile_picture'] ? '<img class="sbi_ca_avatar" src="'.$account['profile_picture'].'" />' : ''; //Could add placeholder avatar image
|
392 |
+
$access_token_expired = (in_array( $account['access_token'], $expired_tokens, true ) || in_array( sbi_maybe_clean( $account['access_token'] ), $expired_tokens, true ));
|
393 |
+
$is_invalid_class = ! $account['is_valid'] || $access_token_expired ? ' sbi_account_invalid' : '';
|
394 |
+
$in_user_feed = in_array( $account['user_id'], $user_feed_ids, true );
|
395 |
+
?>
|
396 |
+
<div class="sbi_connected_account<?php echo $is_invalid_class; ?><?php if ( $in_user_feed ) echo ' sbi_account_active' ?>" id="sbi_connected_account_<?php esc_attr_e( $account['user_id'] ); ?>" data-accesstoken="<?php esc_attr_e( $account['access_token'] ); ?>" data-userid="<?php esc_attr_e( $account['user_id'] ); ?>" data-username="<?php esc_attr_e( $account['username'] ); ?>">
|
397 |
+
|
398 |
+
<div class="sbi_ca_alert">
|
399 |
+
<span><?php _e( 'The Access Token for this account is expired or invalid. Click the button above to attempt to renew it.', 'instagram-feed' ) ?></span>
|
400 |
+
</div>
|
401 |
+
<div class="sbi_ca_info">
|
402 |
+
|
403 |
+
<div class="sbi_ca_delete">
|
404 |
+
<a href="JavaScript:void(0);" class="sbi_delete_account"><i class="fa fa-times"></i><span class="sbi_remove_text"><?php _e( 'Remove', 'instagram-feed' ); ?></span></a>
|
405 |
+
</div>
|
406 |
+
|
407 |
+
<div class="sbi_ca_username">
|
408 |
+
<?php echo $profile_picture; ?>
|
409 |
+
<strong><?php echo $username; ?></strong>
|
410 |
+
</div>
|
411 |
+
|
412 |
+
<div class="sbi_ca_actions">
|
413 |
+
<?php if ( ! $in_user_feed ) : ?>
|
414 |
+
<a href="JavaScript:void(0);" class="sbi_use_in_user_feed button-primary"><i class="fa fa-plus-circle" aria-hidden="true"></i><?php _e( 'Add to Primary Feed', 'instagram-feed' ); ?></a>
|
415 |
+
<?php else : ?>
|
416 |
+
<a href="JavaScript:void(0);" class="sbi_remove_from_user_feed button-primary"><i class="fa fa-minus-circle" aria-hidden="true"></i><?php _e( 'Remove from Primary Feed', 'instagram-feed' ); ?></a>
|
417 |
+
<?php endif; ?>
|
418 |
+
<a class="sbi_ca_token_shortcode button-secondary" href="JavaScript:void(0);"><i class="fa fa-chevron-circle-right" aria-hidden="true"></i><?php _e( 'Add to another Feed', 'instagram-feed' ); ?></a>
|
419 |
+
<p class="sbi_ca_show_token"><input type="checkbox" id="sbi_ca_show_token_<?php esc_attr_e( $account['user_id'] ); ?>" /><label for="sbi_ca_show_token_<?php esc_attr_e( $account['user_id'] ); ?>">Show Access Token</label></p>
|
420 |
+
|
421 |
+
</div>
|
422 |
+
|
423 |
+
<div class="sbi_ca_shortcode">
|
424 |
+
|
425 |
+
<p>Copy and paste this shortcode into your page or widget area:<br>
|
426 |
+
<?php if ( !empty( $account['username'] ) ) : ?>
|
427 |
+
<code>[instagram-feed user="<?php echo $account['username']; ?>"]</code>
|
428 |
+
<?php else : ?>
|
429 |
+
<code>[instagram-feed accesstoken="<?php echo $account['access_token']; ?>"]</code>
|
430 |
+
<?php endif; ?>
|
431 |
+
</p>
|
432 |
+
|
433 |
+
<p>To add multiple users in the same feed, simply separate them using commas:<br>
|
434 |
+
<?php if ( !empty( $account['username'] ) ) : ?>
|
435 |
+
<code>[instagram-feed user="<?php echo $account['username']; ?>, a_second_user, a_third_user"]</code>
|
436 |
+
<?php else : ?>
|
437 |
+
<code>[instagram-feed accesstoken="<?php echo $account['access_token']; ?>, another_access_token"]</code>
|
438 |
+
<?php endif; ?>
|
439 |
+
|
440 |
+
<p>Click on the <a href="?page=sb-instagram-feed&tab=display" target="_blank">Display Your Feed</a> tab to learn more about shortcodes</p>
|
441 |
+
</div>
|
442 |
+
|
443 |
+
<div class="sbi_ca_accesstoken">
|
444 |
+
<span class="sbi_ca_token_label">Access Token:</span><input type="text" class="sbi_ca_token" value="<?php echo $account['access_token']; ?>" readonly="readonly" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).">
|
445 |
+
</div>
|
446 |
+
|
447 |
+
</div>
|
448 |
+
|
449 |
+
</div>
|
450 |
+
|
451 |
+
<?php endforeach; ?>
|
452 |
+
<?php endif; ?>
|
453 |
+
<a href="JavaScript:void(0);" class="sbi_manually_connect button-secondary"><?php _e( 'Manually Connect an Account', 'instagram-feed' ); ?></a>
|
454 |
+
<div class="sbi_manually_connect_wrap">
|
455 |
+
<input name="sb_manual_at" id="sb_manual_at" type="text" value="" style="margin-top: 4px; padding: 5px 9px; margin-left: 0px;" size="64" maxlength="100" placeholder="Enter a valid Instagram Access Token" />
|
456 |
+
<p class="sbi_submit" style="display: inline-block;"><button name="submit" id="sbi_manual_submit" class="button button-primary">Connect This Account</button></p>
|
457 |
+
</div>
|
458 |
</td>
|
459 |
</tr>
|
460 |
|
463 |
Eg: type=user id=12986477
|
464 |
</code></th>
|
465 |
<td>
|
466 |
+
<div class="sbi_row">
|
467 |
+
<div class="sbi_col sbi_one">
|
468 |
+
<input type="radio" name="sb_instagram_type" id="sb_instagram_type_user" value="user" <?php if($sb_instagram_type == "user") echo "checked"; ?> />
|
469 |
+
<label class="sbi_radio_label" for="sb_instagram_type_user"><?php _e( 'User Account:', 'instagram-feed' ); ?></label>
|
470 |
+
</div>
|
471 |
+
<div class="sbi_col sbi_two">
|
472 |
+
<div class="sbi_user_feed_ids_wrap">
|
473 |
+
<?php foreach ( $user_feed_ids as $feed_id ) : if ( $feed_id !== '' ) :?>
|
474 |
+
<div id="sbi_user_feed_id_<?php echo $feed_id; ?>" class="sbi_user_feed_account_wrap">
|
475 |
+
|
476 |
+
<?php if ( isset( $connected_accounts[ $feed_id ] ) && ! empty( $connected_accounts[ $feed_id ]['username'] ) ) : ?>
|
477 |
+
<strong><?php echo $connected_accounts[ $feed_id ]['username']; ?></strong> <span>(<?php echo $feed_id; ?>)</span>
|
478 |
+
<input name="sb_instagram_user_id[]" id="sb_instagram_user_id" type="hidden" value="<?php esc_attr_e( $feed_id ); ?>" />
|
479 |
+
<?php elseif ( isset( $connected_accounts[ $feed_id ] ) && ! empty( $connected_accounts[ $feed_id ]['access_token'] ) ) : ?>
|
480 |
+
<strong><?php echo $feed_id; ?></strong>
|
481 |
+
<input name="sb_instagram_user_id[]" id="sb_instagram_user_id" type="hidden" value="<?php esc_attr_e( $feed_id ); ?>" />
|
482 |
+
<?php endif; ?>
|
483 |
+
|
484 |
+
</div>
|
485 |
+
<?php endif; endforeach; ?>
|
486 |
+
</div>
|
487 |
+
|
488 |
+
<?php if ( empty( $user_feed_ids ) ) : ?>
|
489 |
+
<p class="sbi_no_accounts" style="margin-top: -3px; margin-right: 10px;">Connect a user account above</p>
|
490 |
+
<?php endif; ?>
|
491 |
+
|
492 |
+
<a class="sbi_tooltip_link" href="JavaScript:void(0);" style="margin: 0 0 10px 0; display: inline-block; height: 19px;"><?php _e("How to display User feeds"); ?></a>
|
493 |
+
<div class="sbi_tooltip"><?php _e("<p>In order to display posts from a User account, first connect an account using the button above.</p><p style='padding-top:8px;'><b>Displaying Posts from Other Instagram Accounts</b><br />Due to recent changes in the Instagram API it is no longer possible to display photos from other Instagram accounts which you do not have access to. You can only display the user feed of an account which you connect above. You can connect as many account as you like by logging in using the button above, or manually copy/pasting an Access Token by selecting the 'Manually Connect an Account' option.</p><p style='padding-top:10px;'><b>Multiple Acounts</b><br />It is only possible to display feeds from Instagram accounts which you own. In order to display feeds from multiple accounts, first connect them above and then use the buttons to add the account either to your primary feed or to another feed on your site.</p>", 'instagram-feed'); ?></div><br />
|
494 |
+
</div>
|
495 |
|
|
|
|
|
496 |
</div>
|
497 |
|
498 |
+
<div class="sbi_pro sbi_row">
|
499 |
+
<div class="sbi_col sbi_one">
|
500 |
+
<input disabled type="radio" name="sb_instagram_type" id="sb_instagram_type_hashtag" value="hashtag" <?php if($sb_instagram_type == "hashtag") echo "checked"; ?> />
|
501 |
+
<label class="sbi_radio_label" for="sb_instagram_type_hashtag"><?php _e( 'Hashtag:', 'instagram-feed' ); ?></label>
|
502 |
+
</div>
|
503 |
+
<div class="sbi_col sbi_two">
|
504 |
+
<input readonly type="text" size="25" />
|
505 |
+
<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed' ); ?></a><span class="sbi_note"> - <a href="https://smashballoon.com/instagram-feed/" target="_blank">Upgrade to Pro to show posts by Hashtag</a></span>
|
506 |
+
<p class="sbi_tooltip"><?php _e( 'Display posts from a specific hashtag instead of from a user', 'instagram-feed' ); ?></p>
|
507 |
+
</div>
|
508 |
+
</div>
|
509 |
|
510 |
<div class="sbi_pro sbi_row">
|
511 |
+
<div class="sbi_col sbi_one">
|
512 |
+
<input type="radio" name="sb_instagram_type" disabled="">
|
513 |
+
<label class="sbi_radio_label"><?php _e( 'Single:', 'instagram-feed' ); ?></label>
|
514 |
+
</div>
|
515 |
+
<div class="sbi_col sbi_two">
|
516 |
+
|
517 |
+
<input readonly type="text" size="25" />
|
518 |
<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed' ); ?></a><span class="sbi_note"> - <a href="https://smashballoon.com/instagram-feed/" target="_blank">Upgrade to Pro to show single posts</a></span>
|
519 |
+
<p class="sbi_tooltip"><?php _e("Display a feed comprised of specific single posts."); ?></p>
|
520 |
+
</div>
|
521 |
</div>
|
522 |
|
523 |
+
<div class="sbi_pro sbi_row">
|
524 |
+
<div class="sbi_col sbi_one">
|
525 |
+
<input disabled type="radio" name="sb_instagram_type" id="sb_instagram_type_location" value="location" <?php if($sb_instagram_type == "location") echo "checked"; ?> />
|
526 |
+
<label class="sbi_radio_label" for="sb_instagram_type_location"><?php _e( 'Location:', 'instagram-feed' ); ?></label>
|
527 |
+
</div>
|
528 |
+
<div class="sbi_col sbi_two">
|
529 |
+
<input readonly type="text" size="25" />
|
530 |
<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed' ); ?></a><span class="sbi_note"> - <a href="https://smashballoon.com/instagram-feed/" target="_blank">Upgrade to Pro to show posts by Location</a></span>
|
531 |
<p class="sbi_tooltip"><?php _e( 'Display posts from an Instagram location ID or location coordinates.', 'instagram-feed' ); ?></p>
|
532 |
+
</div>
|
533 |
+
</div>
|
534 |
</td>
|
535 |
</tr>
|
536 |
|
1779 |
} else {
|
1780 |
echo 'No Access Token';
|
1781 |
}?>
|
1782 |
+
|
1783 |
+
## Invalid Tokens: ##
|
1784 |
+
<?php
|
1785 |
+
var_dump( get_option( 'sb_expired_tokens' ) );
|
1786 |
+
?>
|
1787 |
+
</textarea>
|
1788 |
|
1789 |
<?php
|
1790 |
} //End Support tab
|
1976 |
* retrieved with the big blue button
|
1977 |
*/
|
1978 |
function sbi_auto_save_tokens() {
|
1979 |
+
if ( current_user_can( 'edit_posts' ) ) {
|
1980 |
+
wp_cache_delete ( 'alloptions', 'options' );
|
1981 |
|
1982 |
+
$options = get_option( 'sb_instagram_settings', array() );
|
1983 |
+
$new_access_token = isset( $_POST['access_token'] ) ? sanitize_text_field( $_POST['access_token'] ) : false;
|
1984 |
+
$split_token = $new_access_token ? explode( '.', $new_access_token ) : array();
|
1985 |
+
$new_user_id = isset( $split_token[0] ) ? $split_token[0] : '';
|
1986 |
|
1987 |
+
$connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
|
1988 |
+
$test_connection_data = sbi_account_data_for_token( $new_access_token );
|
1989 |
+
|
1990 |
+
$connected_accounts[ $new_user_id ] = array(
|
1991 |
+
'access_token' => sbi_get_parts( $new_access_token ),
|
1992 |
+
'user_id' => $test_connection_data['id'],
|
1993 |
+
'username' => $test_connection_data['username'],
|
1994 |
+
'is_valid' => $test_connection_data['is_valid'],
|
1995 |
+
'last_checked' => $test_connection_data['last_checked'],
|
1996 |
+
'profile_picture' => $test_connection_data['profile_picture']
|
1997 |
+
);
|
1998 |
+
|
1999 |
+
$options['connected_accounts'] = $connected_accounts;
|
2000 |
+
|
2001 |
+
update_option( 'sb_instagram_settings', $options );
|
2002 |
+
|
2003 |
+
echo json_encode( $connected_accounts[ $new_user_id ] );
|
2004 |
+
}
|
2005 |
+
die();
|
2006 |
}
|
2007 |
add_action( 'wp_ajax_sbi_auto_save_tokens', 'sbi_auto_save_tokens' );
|
2008 |
|
2009 |
+
function sbi_auto_save_id() {
|
2010 |
+
if ( current_user_can( 'edit_posts' ) && isset( $_POST['id'] ) ) {
|
2011 |
+
$options = get_option( 'sb_instagram_settings', array() );
|
2012 |
+
|
2013 |
+
$options['sb_instagram_user_id'] = array( sanitize_text_field( $_POST['id'] ) );
|
2014 |
+
|
2015 |
+
update_option( 'sb_instagram_settings', $options );
|
2016 |
+
}
|
2017 |
+
die();
|
2018 |
+
}
|
2019 |
+
add_action( 'wp_ajax_sbi_auto_save_id', 'sbi_auto_save_id' );
|
2020 |
+
|
2021 |
+
function sbi_test_token() {
|
2022 |
+
$access_token = isset( $_POST['access_token'] ) ? sanitize_text_field( $_POST['access_token'] ) : false;
|
2023 |
+
$options = get_option( 'sb_instagram_settings', array() );
|
2024 |
+
$connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
|
2025 |
+
|
2026 |
+
if ( $access_token ) {
|
2027 |
+
wp_cache_delete ( 'alloptions', 'options' );
|
2028 |
+
|
2029 |
+
$split_token = explode( '.', $access_token );
|
2030 |
+
$new_user_id = isset( $split_token[0] ) ? $split_token[0] : '';
|
2031 |
+
|
2032 |
+
$test_connection_data = sbi_account_data_for_token( $access_token );
|
2033 |
+
|
2034 |
+
if ( isset( $test_connection_data['error_message'] ) ) {
|
2035 |
+
echo $test_connection_data['error_message'];
|
2036 |
+
} elseif ( $test_connection_data !== false ) {
|
2037 |
+
$username = $test_connection_data['username'] ? $test_connection_data['username'] : $connected_accounts[ $new_user_id ]['username'];
|
2038 |
+
$user_id = $test_connection_data['id'] ? $test_connection_data['id'] : $connected_accounts[ $new_user_id ]['user_id'];
|
2039 |
+
$profile_picture = $test_connection_data['profile_picture'] ? $test_connection_data['profile_picture'] : $connected_accounts[ $new_user_id ]['profile_picture'];
|
2040 |
+
|
2041 |
+
$connected_accounts[ $new_user_id ] = array(
|
2042 |
+
'access_token' => sbi_get_parts( $access_token ),
|
2043 |
+
'user_id' => $user_id,
|
2044 |
+
'username' => $username,
|
2045 |
+
'is_valid' => $test_connection_data['is_valid'],
|
2046 |
+
'last_checked' => $test_connection_data['last_checked'],
|
2047 |
+
'profile_picture' => $profile_picture
|
2048 |
+
);
|
2049 |
+
|
2050 |
+
$options['connected_accounts'] = $connected_accounts;
|
2051 |
+
|
2052 |
+
update_option( 'sb_instagram_settings', $options );
|
2053 |
+
|
2054 |
+
$expired = get_option( 'sb_expired_tokens', array() );
|
2055 |
+
$new_expired = array();
|
2056 |
+
foreach ( $expired as $expired_token ) {
|
2057 |
+
$split_token = explode( '.', $expired_token );
|
2058 |
+
$old_user_id = isset( $split_token[0] ) ? $split_token[0] : '';
|
2059 |
+
if ( $old_user_id !== $new_user_id ) {
|
2060 |
+
$new_expired[] = $expired_token;
|
2061 |
+
}
|
2062 |
+
}
|
2063 |
+
update_option( 'sb_expired_tokens', $new_expired );
|
2064 |
+
//Delete all SBI transients
|
2065 |
+
global $wpdb;
|
2066 |
+
$table_name = $wpdb->prefix . "options";
|
2067 |
+
$wpdb->query( "
|
2068 |
+
DELETE
|
2069 |
+
FROM $table_name
|
2070 |
+
WHERE `option_name` LIKE ('%\_transient\_sbi\_%')
|
2071 |
+
" );
|
2072 |
+
$wpdb->query( "
|
2073 |
+
DELETE
|
2074 |
+
FROM $table_name
|
2075 |
+
WHERE `option_name` LIKE ('%\_transient\_timeout\_sbi\_%')
|
2076 |
+
" );
|
2077 |
+
$wpdb->query( "
|
2078 |
+
DELETE
|
2079 |
+
FROM $table_name
|
2080 |
+
WHERE `option_name` LIKE ('%\_transient\_&sbi\_%')
|
2081 |
+
" );
|
2082 |
+
$wpdb->query( "
|
2083 |
+
DELETE
|
2084 |
+
FROM $table_name
|
2085 |
+
WHERE `option_name` LIKE ('%\_transient\_timeout\_&sbi\_%')
|
2086 |
+
" );
|
2087 |
+
|
2088 |
+
echo json_encode( $connected_accounts[ $new_user_id ] );
|
2089 |
+
} else {
|
2090 |
+
echo 'A successful connection could not be made. Please make sure your Access Token is valid.';
|
2091 |
+
}
|
2092 |
+
|
2093 |
+
}
|
2094 |
+
|
2095 |
+
die();
|
2096 |
+
}
|
2097 |
+
add_action( 'wp_ajax_sbi_test_token', 'sbi_test_token' );
|
2098 |
+
|
2099 |
+
function sbi_delete_account() {
|
2100 |
+
$access_token = isset( $_POST['access_token'] ) ? sanitize_text_field( $_POST['access_token'] ) : false;
|
2101 |
+
$options = get_option( 'sb_instagram_settings', array() );
|
2102 |
+
$connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
|
2103 |
+
|
2104 |
+
if ( $access_token ) {
|
2105 |
+
wp_cache_delete ( 'alloptions', 'options' );
|
2106 |
+
|
2107 |
+
$split_token = explode( '.', $access_token );
|
2108 |
+
$new_user_id = isset( $split_token[0] ) ? $split_token[0] : '';
|
2109 |
+
|
2110 |
+
unset( $connected_accounts[ $new_user_id ] );
|
2111 |
+
|
2112 |
+
$options['connected_accounts'] = $connected_accounts;
|
2113 |
+
|
2114 |
+
update_option( 'sb_instagram_settings', $options );
|
2115 |
+
|
2116 |
+
}
|
2117 |
+
|
2118 |
+
die();
|
2119 |
+
}
|
2120 |
+
add_action( 'wp_ajax_sbi_delete_account', 'sbi_delete_account' );
|
2121 |
+
|
2122 |
+
function sbi_account_data_for_token( $access_token ) {
|
2123 |
+
$return = array(
|
2124 |
+
'id' => false,
|
2125 |
+
'username' => false,
|
2126 |
+
'is_valid' => false,
|
2127 |
+
'last_checked' => time()
|
2128 |
+
);
|
2129 |
+
$url = 'https://api.instagram.com/v1/users/self/?access_token=' . sbi_maybe_clean( $access_token );
|
2130 |
+
$args = array(
|
2131 |
+
'timeout' => 60,
|
2132 |
+
'sslverify' => false
|
2133 |
+
);
|
2134 |
+
$result = wp_remote_get( $url, $args );
|
2135 |
+
|
2136 |
+
$data = json_decode( $result['body'] );
|
2137 |
+
|
2138 |
+
if ( isset( $data->data->id ) ) {
|
2139 |
+
$return['id'] = $data->data->id;
|
2140 |
+
$return['username'] = $data->data->username;
|
2141 |
+
$return['is_valid'] = true;
|
2142 |
+
$return['profile_picture'] = $data->data->profile_picture;
|
2143 |
+
|
2144 |
+
} elseif ( isset( $data->error_type ) && $data->error_type === 'OAuthRateLimitException' ) {
|
2145 |
+
$return['error_message'] = 'This account\'s access token is currently over the rate limit. Try removing this access token from all feeds and wait an hour before reconnecting.';
|
2146 |
+
} else {
|
2147 |
+
$return = false;
|
2148 |
+
|
2149 |
+
}
|
2150 |
+
|
2151 |
+
return $return;
|
2152 |
+
}
|
2153 |
+
|
2154 |
+
function sbi_get_connected_accounts_data( $sb_instagram_at ) {
|
2155 |
+
$sbi_options = get_option( 'sb_instagram_settings' );
|
2156 |
+
$return = array();
|
2157 |
+
$return['connected_accounts'] = isset( $sbi_options['connected_accounts'] ) ? $sbi_options['connected_accounts'] : array();
|
2158 |
+
|
2159 |
+
if ( empty( $connected_accounts ) && ! empty( $sb_instagram_at ) ) {
|
2160 |
+
$tokens = explode(',', $sb_instagram_at );
|
2161 |
+
$user_ids = array();
|
2162 |
+
|
2163 |
+
foreach ( $tokens as $token ) {
|
2164 |
+
$account = sbi_account_data_for_token( $token );
|
2165 |
+
if ( isset( $account['is_valid'] ) ) {
|
2166 |
+
$split = explode( '.', $token );
|
2167 |
+
$return['connected_accounts'][ $split[0] ] = array(
|
2168 |
+
'access_token' => sbi_get_parts( $token ),
|
2169 |
+
'user_id' => $split[0],
|
2170 |
+
'username' => '',
|
2171 |
+
'is_valid' => true,
|
2172 |
+
'last_checked' => time(),
|
2173 |
+
'profile_picture' => ''
|
2174 |
+
);
|
2175 |
+
$user_ids[] = $split[0];
|
2176 |
+
}
|
2177 |
+
|
2178 |
+
}
|
2179 |
+
|
2180 |
+
$sbi_options['connected_accounts'] = $return['connected_accounts'];
|
2181 |
+
$sbi_options['sb_instagram_at'] = '';
|
2182 |
+
$sbi_options['sb_instagram_user_id'] = $user_ids;
|
2183 |
+
|
2184 |
+
$return['user_ids'] = $user_ids;
|
2185 |
+
|
2186 |
+
update_option( 'sb_instagram_settings', $sbi_options );
|
2187 |
+
delete_option( 'sb_expired_tokens' );
|
2188 |
+
}
|
2189 |
+
|
2190 |
+
return $return;
|
2191 |
+
}
|
2192 |
+
|
2193 |
// variables to define certain terms
|
2194 |
$transient = 'instagram_feed_rating_notice_waiting';
|
2195 |
$option = 'sbi_rating_notice';
|
instagram-feed.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Instagram Feed
|
4 |
Plugin URI: https://smashballoon.com/instagram-feed
|
5 |
Description: Display beautifully clean, customizable, and responsive Instagram feeds
|
6 |
-
Version: 1.
|
7 |
Author: Smash Balloon
|
8 |
Author URI: https://smashballoon.com/
|
9 |
License: GPLv2 or later
|
@@ -23,7 +23,7 @@ along with this program; if not, write to the Free Software
|
|
23 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
24 |
*/
|
25 |
|
26 |
-
define( 'SBIVER', '1.
|
27 |
|
28 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
29 |
|
@@ -70,34 +70,97 @@ function display_instagram($atts, $content = null) {
|
|
70 |
'ajaxtheme' => isset($options[ 'sb_instagram_ajax_theme' ]) ? $options[ 'sb_instagram_ajax_theme' ] : '',
|
71 |
'cachetime' => isset($options[ 'sb_instagram_cache_time' ]) ? $options[ 'sb_instagram_cache_time' ] : '',
|
72 |
'media' => isset($options[ 'sb_instagram_media_type' ]) ? $options[ 'sb_instagram_media_type' ] : '',
|
73 |
-
|
74 |
-
|
|
|
75 |
|
76 |
|
77 |
/******************* VARS ********************/
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
if ( empty( $sb_instagram_user_id ) || preg_match('([a-zA-Z])', $sb_instagram_user_id ) ) {
|
83 |
-
$sb_instagram_settings = get_option( 'sb_instagram_settings' );
|
84 |
-
$at_arr = isset( $sb_instagram_settings[ 'sb_instagram_at' ] ) ? explode( '.', trim( $sb_instagram_settings[ 'sb_instagram_at' ] ), 2) : array();
|
85 |
-
$sb_instagram_user_id = isset( $at_arr[0] ) ? $at_arr[0] : '';
|
86 |
-
}
|
87 |
|
88 |
// Access Token
|
89 |
$at_front_string = '';
|
90 |
$at_middle_string = '';
|
91 |
$at_back_string = '';
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
$at_front_string = '"feedID": "';
|
97 |
$at_middle_string = '"mid": "';
|
98 |
$at_back_string = '"callback": "';
|
99 |
$sb_instagram_user_id = '';
|
100 |
-
foreach ( $
|
101 |
$parts = explode('.', $token );
|
102 |
$sb_instagram_user_id .= $parts[0].',';
|
103 |
$at_front_string .= $parts[0].',';
|
@@ -112,9 +175,7 @@ function display_instagram($atts, $content = null) {
|
|
112 |
$at_front_string = substr( $at_front_string, 0, -1 ) . '",';
|
113 |
$at_middle_string = substr( $at_middle_string, 0, -1 ) . '",';
|
114 |
$at_back_string = substr( $at_back_string, 0, -1 ) . '",';
|
115 |
-
$access_token = $
|
116 |
-
} else {
|
117 |
-
$access_token = isset( $options['sb_instagram_at'] ) ? trim( $options['sb_instagram_at'] ) : '';
|
118 |
}
|
119 |
|
120 |
//Container styles
|
@@ -445,7 +506,7 @@ function sbi_set_expired_token() {
|
|
445 |
$expired_tokens[] = sbi_maybe_clean( $access_token );
|
446 |
}
|
447 |
|
448 |
-
update_option( 'sb_expired_tokens', $expired_tokens );
|
449 |
}
|
450 |
|
451 |
die();
|
@@ -743,6 +804,7 @@ function sb_instagram_activate() {
|
|
743 |
$options[ 'sb_instagram_show_header' ] = true;
|
744 |
$options[ 'sb_instagram_show_follow_btn' ] = true;
|
745 |
update_option( 'sb_instagram_settings', $options );
|
|
|
746 |
}
|
747 |
register_activation_hook( __FILE__, 'sb_instagram_activate' );
|
748 |
|
3 |
Plugin Name: Instagram Feed
|
4 |
Plugin URI: https://smashballoon.com/instagram-feed
|
5 |
Description: Display beautifully clean, customizable, and responsive Instagram feeds
|
6 |
+
Version: 1.9
|
7 |
Author: Smash Balloon
|
8 |
Author URI: https://smashballoon.com/
|
9 |
License: GPLv2 or later
|
23 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
24 |
*/
|
25 |
|
26 |
+
define( 'SBIVER', '1.9' );
|
27 |
|
28 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
29 |
|
70 |
'ajaxtheme' => isset($options[ 'sb_instagram_ajax_theme' ]) ? $options[ 'sb_instagram_ajax_theme' ] : '',
|
71 |
'cachetime' => isset($options[ 'sb_instagram_cache_time' ]) ? $options[ 'sb_instagram_cache_time' ] : '',
|
72 |
'media' => isset($options[ 'sb_instagram_media_type' ]) ? $options[ 'sb_instagram_media_type' ] : '',
|
73 |
+
'accesstoken' => '',
|
74 |
+
'user' => isset($options[ 'sb_instagram_user' ]) ? $options[ 'sb_instagram_user' ] : false,
|
75 |
+
), $atts);
|
76 |
|
77 |
|
78 |
/******************* VARS ********************/
|
79 |
|
80 |
+
$sb_instagram_user_id = is_array( $atts['id'] ) ? implode( ',', $atts['id'] ) : trim($atts['id'], " ,");
|
81 |
+
$sb_instagram_users = !empty($atts['user']) ? explode( ',', trim( $atts['user'] ) ) : false;
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
// Access Token
|
84 |
$at_front_string = '';
|
85 |
$at_middle_string = '';
|
86 |
$at_back_string = '';
|
87 |
|
88 |
+
//$db_access_token = isset( $options['sb_instagram_at'] ) ? trim( $options['sb_instagram_at'] ) : '';
|
89 |
+
$existing_shortcode_tokens = ! empty( $atts['accesstoken'] ) ? explode(',', str_replace(' ', '', $atts['accesstoken'] ) ) : '';
|
90 |
+
$existing_shortcode_tokens = apply_filters( 'sbi_access_tokens', $existing_shortcode_tokens );
|
91 |
+
|
92 |
+
$usable_tokens = array();
|
93 |
+
$all_valid_tokens = array();
|
94 |
+
|
95 |
+
|
96 |
+
if ( ! empty ( $existing_shortcode_tokens ) ) {
|
97 |
+
foreach ( $existing_shortcode_tokens as $existing_shortcode_token ) {
|
98 |
+
if ( ! empty( $existing_shortcode_token ) ) {
|
99 |
+
$usable_tokens[] = $existing_shortcode_token;
|
100 |
+
$all_valid_tokens[] = $existing_shortcode_tokens;
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
104 |
+
}
|
105 |
+
if ( $sb_instagram_users !== false && ! empty ( $options[ 'connected_accounts' ] ) ) {
|
106 |
+
foreach ( $options[ 'connected_accounts' ] as $connected_account ) {
|
107 |
+
if ( in_array( $connected_account['username'], $sb_instagram_users ) ) {
|
108 |
+
$usable_tokens[] = sbi_get_parts( $connected_account['access_token'] );
|
109 |
+
}
|
110 |
+
if ( ! in_array( sbi_get_parts( $connected_account['access_token'] ), $all_valid_tokens ) && ! in_array( sbi_maybe_clean( $connected_account['access_token'] ), $all_valid_tokens ) ) {
|
111 |
+
$all_valid_tokens[] = sbi_get_parts( $connected_account['access_token'] );
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
116 |
+
if ( empty( $usable_tokens ) && ! empty( $options[ 'connected_accounts' ] ) ) {
|
117 |
+
$feed_id_array = is_array( $sb_instagram_user_id ) ? $sb_instagram_user_id : explode( ',', $sb_instagram_user_id );
|
118 |
+
if ( ! empty( $feed_id_array ) && ! empty( $feed_id_array[0] ) ) {
|
119 |
+
foreach ( $options[ 'connected_accounts' ] as $connected_account ) {
|
120 |
+
if ( isset( $connected_account['access_token'] ) && in_array( $connected_account['user_id'], $feed_id_array, true ) ) {
|
121 |
+
$usable_tokens[] = $connected_account['access_token'];
|
122 |
+
} elseif ( isset( $connected_account['access_token'] ) ) {
|
123 |
+
if ( ! in_array( sbi_get_parts( $connected_account['access_token'] ), $all_valid_tokens ) && ! in_array( sbi_maybe_clean( $connected_account['access_token'] ), $all_valid_tokens ) ) {
|
124 |
+
$all_valid_tokens[] = sbi_get_parts( $connected_account['access_token'] );
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
} else {
|
129 |
+
foreach ( $options[ 'connected_accounts' ] as $connected_account ) {
|
130 |
+
if ( empty( $usable_tokens ) ) {
|
131 |
+
$usable_tokens = array( $connected_account['access_token'] );
|
132 |
+
$user_for_token = explode( '.', $connected_account['access_token'] );
|
133 |
+
$sb_instagram_user_id = $user_for_token[0];
|
134 |
+
}
|
135 |
+
|
136 |
+
if ( ! in_array( sbi_get_parts( $connected_account['access_token'] ), $all_valid_tokens ) && ! in_array( sbi_maybe_clean( $connected_account['access_token'] ), $all_valid_tokens ) ) {
|
137 |
+
$all_valid_tokens[] = sbi_get_parts( $connected_account['access_token'] );
|
138 |
+
}
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
} elseif ( empty ( $all_valid_tokens ) ) {
|
143 |
+
|
144 |
+
$db_access_tokens = isset( $options['sb_instagram_at'] ) ? explode( ',', trim( $options['sb_instagram_at'] ) ) : array();
|
145 |
+
foreach ( $db_access_tokens as $db_access_token ) {
|
146 |
+
if ( ! empty( $db_access_token ) ) {
|
147 |
+
$usable_tokens[] = sbi_get_parts( $db_access_token );
|
148 |
+
$all_valid_tokens[] = sbi_get_parts( $db_access_token );
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
$the_token_array = ! empty( $usable_tokens ) ? $usable_tokens : $all_valid_tokens;
|
154 |
+
if ( empty( $the_token_array ) && ! empty( $all_valid_tokens ) ) {
|
155 |
+
$the_token_array = $all_valid_tokens;
|
156 |
+
}
|
157 |
+
|
158 |
+
if ( ! empty( $the_token_array ) ) {
|
159 |
$at_front_string = '"feedID": "';
|
160 |
$at_middle_string = '"mid": "';
|
161 |
$at_back_string = '"callback": "';
|
162 |
$sb_instagram_user_id = '';
|
163 |
+
foreach ( $usable_tokens as $token ) {
|
164 |
$parts = explode('.', $token );
|
165 |
$sb_instagram_user_id .= $parts[0].',';
|
166 |
$at_front_string .= $parts[0].',';
|
175 |
$at_front_string = substr( $at_front_string, 0, -1 ) . '",';
|
176 |
$at_middle_string = substr( $at_middle_string, 0, -1 ) . '",';
|
177 |
$at_back_string = substr( $at_back_string, 0, -1 ) . '",';
|
178 |
+
$access_token = $the_token_array[0];
|
|
|
|
|
179 |
}
|
180 |
|
181 |
//Container styles
|
506 |
$expired_tokens[] = sbi_maybe_clean( $access_token );
|
507 |
}
|
508 |
|
509 |
+
update_option( 'sb_expired_tokens', $expired_tokens, false );
|
510 |
}
|
511 |
|
512 |
die();
|
804 |
$options[ 'sb_instagram_show_header' ] = true;
|
805 |
$options[ 'sb_instagram_show_follow_btn' ] = true;
|
806 |
update_option( 'sb_instagram_settings', $options );
|
807 |
+
delete_option( 'sb_expired_tokens' );
|
808 |
}
|
809 |
register_activation_hook( __FILE__, 'sb_instagram_activate' );
|
810 |
|
js/sb-instagram-admin.js
CHANGED
@@ -1,44 +1,306 @@
|
|
1 |
jQuery(document).ready(function($) {
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
id = token.split('.')[0];
|
7 |
-
|
8 |
-
function sbSaveToken(token) {
|
9 |
-
jQuery.ajax({
|
10 |
-
url: sbiA.ajax_url,
|
11 |
-
type: 'post',
|
12 |
-
data: {
|
13 |
-
action: 'sbi_auto_save_tokens',
|
14 |
-
access_token: token,
|
15 |
-
just_tokens: true
|
16 |
-
},
|
17 |
-
success: function (data) {
|
18 |
-
jQuery('.sb_get_token').append('<span class="sbi-success"><i class="fa fa-check-circle"></i> saved</span>');
|
19 |
-
jQuery('#sb_instagram_at').after('<span class="sbi-success"><i class="fa fa-check-circle"></i> saved</span>');
|
20 |
-
}
|
21 |
-
});
|
22 |
-
}
|
23 |
-
//If there's a hash then autofill the token and id
|
24 |
-
if(hash && !jQuery('#sbi_just_saved').length){
|
25 |
-
//$('#sbi_config').append('<div id="sbi_config_info"><p><b>Access Token: </b><input type="text" size=58 readonly value="'+token+'" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."></p><p><b>User ID: </b><input type="text" size=12 readonly value="'+id+'" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."></p><p><i class="fa fa-clipboard" aria-hidden="true"></i> <b><span style="color: red;">Important:</span> Copy and paste</b> these into the fields below and click <b>"Save Changes"</b>.</p></div>');
|
26 |
-
$('#sbi_config').append('<div id="sbi_config_info"><p class="sb_get_token"><b>Access Token: </b><input type="text" size=58 readonly value="'+token+'" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."></p><p><b>User ID: </b><input type="text" size=12 readonly value="'+id+'" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."></p></div>');
|
27 |
-
if(jQuery('#sb_instagram_at').val() == '' && token.length > 40) {
|
28 |
-
jQuery('#sb_instagram_at').val(token);
|
29 |
-
sbSaveToken(token);
|
30 |
-
} else {
|
31 |
-
jQuery('.sb_get_token').append('<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Use This Token"></p>');
|
32 |
-
}
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
//clear backup caches
|
44 |
jQuery('#sbi_clear_backups').click(function(event) {
|
1 |
jQuery(document).ready(function($) {
|
2 |
|
3 |
+
var hash = window.location.hash,
|
4 |
+
token = hash.substring(14),
|
5 |
+
id = token.split('.')[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
if (token.length > 40) {
|
8 |
+
//https://api.instagram.com/v1/users/self/?access_token=' . sbi_maybe_clean( $access_token )
|
9 |
+
$('.sbi_admin_btn').css('opacity','.5').after('<div class="spinner" style="visibility: visible; position: relative;float: left;margin-top: 15px;"></div>');
|
10 |
+
var url = 'https://api.instagram.com/v1/users/self/?access_token=' + token;
|
11 |
+
jQuery.ajax({
|
12 |
+
method: "GET",
|
13 |
+
url: url,
|
14 |
+
success: function(data) {
|
15 |
+
$('.sbi_admin_btn').css('opacity','1');
|
16 |
+
$('#sbi_config').find('.spinner').remove();
|
17 |
+
if (!$('.sbi_connected_account ').length) {
|
18 |
+
$('.sbi_no_accounts').remove();
|
19 |
+
sbSaveToken(token,true);
|
20 |
+
} else {
|
21 |
+
var buttonText = 'Connect This Account';
|
22 |
+
// if the account is connected, offer to update in case information has changed.
|
23 |
+
if ($('#sbi_connected_account_'+id).length) {
|
24 |
+
buttonText = 'Update This Account';
|
25 |
+
}
|
26 |
+
$('#sbi_config').append('<div id="sbi_config_info" class="sb_get_token">' +
|
27 |
+
'<div class="sbi_config_modal">' +
|
28 |
+
'<img class="sbi_ca_avatar" src="'+data.data.profile_picture+'" />' +
|
29 |
+
'<div class="sbi_ca_username"><strong>'+data.data.username+'</strong></div>' +
|
30 |
+
'<p class="sbi_submit"><input type="submit" name="sbi_submit" id="sbi_connect_account" class="button button-primary" value="'+buttonText+'">' +
|
31 |
+
'<a href="JavaScript:void(0);" class="button button-secondary" id="sbi_switch_accounts">Switch Accounts</a></p>' +
|
32 |
+
'<a href="JavaScript:void(0);"><i class="sbi_modal_close fa fa-times"></i></a>' +
|
33 |
+
'</div>' +
|
34 |
+
'</div>');
|
35 |
|
36 |
+
$('#sbi_connect_account').click(function(event) {
|
37 |
+
event.preventDefault();
|
38 |
+
$('#sbi_config_info').fadeOut(200);
|
39 |
+
sbSaveToken(token,false);
|
40 |
+
});
|
41 |
+
|
42 |
+
sbiSwitchAccounts();
|
43 |
+
}
|
44 |
+
|
45 |
+
},
|
46 |
+
error: function(data) {
|
47 |
+
$('.sbi_admin_btn').css('opacity','1');
|
48 |
+
$('#sbi_config').find('.spinner').remove();
|
49 |
+
var message = typeof data.responseJSON !== 'undefined' && data.responseJSON.error_type === 'OAuthRateLimitException' ? 'This account\'s access token is currently over the rate limit. Try removing this access token from all feeds and wait an hour before reconnecting.' : 'There was an error connecting your account';
|
50 |
+
|
51 |
+
$('#sbi_config').append('<div id="sbi_config_info" class="sb_get_token">' +
|
52 |
+
'<div class="sbi_config_modal">' +
|
53 |
+
'<p>'+message+'</p>' +
|
54 |
+
'<p class="sbi_submit"><a href="JavaScript:void(0);" class="button button-secondary" id="sbi_switch_accounts">Switch Accounts</a></p>' +
|
55 |
+
'<a href="JavaScript:void(0);"><i class="sbi_modal_close fa fa-times"></i></a>' +
|
56 |
+
'</div>' +
|
57 |
+
'</div>');
|
58 |
+
|
59 |
+
sbiSwitchAccounts();
|
60 |
+
}
|
61 |
+
});
|
62 |
+
|
63 |
+
function sbiSwitchAccounts(){
|
64 |
+
$('#sbi_switch_accounts').on('click', function(){
|
65 |
+
//Log user out of Instagram by hitting the logout URL in an iframe
|
66 |
+
$('body').append('<iframe style="display: none;" src="https://www.instagram.com/accounts/logout"></iframe>');
|
67 |
+
|
68 |
+
$(this).text('Please wait...').after('<div class="spinner" style="visibility: visible; float: none; margin: -3px 0 0 3px;"></div>');
|
69 |
+
|
70 |
+
//Wait a couple seconds for the logout to occur, then connect a new account
|
71 |
+
setTimeout(function(){
|
72 |
+
window.location.href = $('.sbi_admin_btn').attr('href');
|
73 |
+
}, 2000);
|
74 |
+
});
|
75 |
+
|
76 |
+
$('.sbi_modal_close').on('click', function(){
|
77 |
+
$('#sbi_config_info').remove();
|
78 |
+
});
|
79 |
+
}
|
80 |
+
|
81 |
+
window.location.hash = '';
|
82 |
+
}
|
83 |
+
|
84 |
+
function sbiAfterUpdateToken(savedToken,saveID){
|
85 |
+
if (saveID) {
|
86 |
+
sbSaveID(savedToken.user_id);
|
87 |
+
$('.sbi_user_feed_ids_wrap').prepend(
|
88 |
+
'<div id="sbi_user_feed_id_'+savedToken.user_id+'" class="sbi_user_feed_account_wrap">'+
|
89 |
+
'<strong>'+savedToken.username+'</strong> <span>('+savedToken.user_id+')</span>' +
|
90 |
+
'<input type="hidden" name="sb_instagram_user_id[]" value="'+savedToken.user_id+'">' +
|
91 |
+
'</div>'
|
92 |
+
);
|
93 |
+
}
|
94 |
+
if ($('#sbi_connected_account_'+savedToken.user_id).length) {
|
95 |
+
if (savedToken.is_valid) {
|
96 |
+
$('#sbi_connected_account_'+savedToken.user_id).addClass('sbi_account_updated');
|
97 |
+
} else {
|
98 |
+
$('#sbi_connected_account_'+savedToken.user_id).addClass('sbi_account_invalid');
|
99 |
+
}
|
100 |
+
$('#sbi_connected_account_'+savedToken.user_id).attr('data-accesstoken',savedToken.access_token);
|
101 |
+
$('#sbi_connected_account_'+savedToken.user_id).find('.sbi_ca_accesstoken .sbi_ca_token').text(savedToken.access_token);
|
102 |
+
$('#sbi_connected_account_'+savedToken.user_id).find('.sbi_tooltip code').text('[instagram-feed accesstoken="'+savedToken.access_token+'"]');
|
103 |
+
$('#sbi_connected_account_'+savedToken.user_id).find('.sbi_ca_at_is_valid span').text('Last Tested: Now');
|
104 |
+
} else {
|
105 |
+
var removeOrSaveHTML = saveID ? '<a href="JavaScript:void(0);" class="sbi_remove_from_user_feed button-primary"><i class="fa fa-minus-circle" aria-hidden="true"></i>Remove from Primary Feed</a>' : '<a href="JavaScript:void(0);" class="sbi_use_in_user_feed button-primary"><i class="fa fa-plus-circle" aria-hidden="true"></i>Add to Primary Feed</a>',
|
106 |
+
statusClass = saveID ? 'sbi_account_active' : 'sbi_account_updated',
|
107 |
+
html = '<div class="sbi_connected_account '+statusClass+'" id="sbi_connected_account_'+savedToken.user_id+'" data-accesstoken="'+savedToken.access_token+'" data-userid="'+savedToken.user_id+'" data-username="'+savedToken.username+'">'+
|
108 |
+
'<div class="sbi_ca_info">'+
|
109 |
+
|
110 |
+
'<div class="sbi_ca_delete">'+
|
111 |
+
'<a href="JavaScript:void(0);" class="sbi_delete_account"><i class="fa fa-times"></i><span class="sbi_remove_text">Remove</span></a>'+
|
112 |
+
'</div>'+
|
113 |
+
|
114 |
+
'<div class="sbi_ca_username">'+
|
115 |
+
'<img class="sbi_ca_avatar" src="'+savedToken.profile_picture+'" />'+
|
116 |
+
'<strong>'+savedToken.username+'</strong>'+
|
117 |
+
'</div>'+
|
118 |
+
|
119 |
+
'<div class="sbi_ca_actions">'+
|
120 |
+
removeOrSaveHTML +
|
121 |
+
'<a class="sbi_ca_token_shortcode button-secondary" href="JavaScript:void(0);"><i class="fa fa-chevron-circle-right" aria-hidden="true"></i>Add to another Feed</a>'+
|
122 |
+
'<p class="sbi_ca_show_token"><input type="checkbox" id="sbi_ca_show_token_'+savedToken.user_id+'" /><label for="sbi_ca_show_token_'+savedToken.user_id+'">Show Access Token</label></p>'+
|
123 |
+
'</div>'+
|
124 |
+
|
125 |
+
'<div class="sbi_ca_shortcode">'+
|
126 |
+
'<p>Copy and paste this shortcode into your page or widget area:<br>'+
|
127 |
+
'<code>[instagram-feed user="'+savedToken.username+'"]</code>'+
|
128 |
+
'</p>'+
|
129 |
+
'<p>To add multiple users in the same feed, simply separate them using commas:<br>'+
|
130 |
+
'<code>[instagram-feed user="'+savedToken.username+', a_second_user, a_third_user"]</code>'+
|
131 |
+
'<p>Click on the <a href="?page=sb-instagram-feed&tab=display" target="_blank">Display Your Feed</a> tab to learn more about shortcodes</p>'+
|
132 |
+
'</div>'+
|
133 |
+
|
134 |
+
'<div class="sbi_ca_accesstoken">' +
|
135 |
+
'<span class="sbi_ca_token_label">Access Token:</span><input type="text" class="sbi_ca_token" value="'+savedToken.access_token+'" readonly="readonly" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac).">' +
|
136 |
+
'</div>' +
|
137 |
+
|
138 |
+
'</div>'+
|
139 |
+
'</div>';
|
140 |
+
$('.sbi_connected_accounts_wrap').prepend(html);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
function sbSaveToken(token,saveID) {
|
145 |
+
$('.sbi_connected_accounts_wrap').fadeTo("slow" , 0.5);
|
146 |
+
jQuery.ajax({
|
147 |
+
url: sbiA.ajax_url,
|
148 |
+
type: 'post',
|
149 |
+
data: {
|
150 |
+
action: 'sbi_auto_save_tokens',
|
151 |
+
access_token: token,
|
152 |
+
just_tokens: true
|
153 |
+
},
|
154 |
+
success: function (data) {
|
155 |
+
var savedToken = JSON.parse(data);
|
156 |
+
$('.sbi_connected_accounts_wrap').fadeTo("slow" , 1);
|
157 |
+
sbiAfterUpdateToken(savedToken,saveID);
|
158 |
+
}
|
159 |
+
});
|
160 |
+
}
|
161 |
+
|
162 |
+
function sbSaveID(ID) {
|
163 |
+
jQuery.ajax({
|
164 |
+
url: sbiA.ajax_url,
|
165 |
+
type: 'post',
|
166 |
+
data: {
|
167 |
+
action: 'sbi_auto_save_id',
|
168 |
+
id: ID,
|
169 |
+
just_tokens: true
|
170 |
+
},
|
171 |
+
success: function (data) {
|
172 |
+
}
|
173 |
+
});
|
174 |
+
}
|
175 |
+
|
176 |
+
// connect accounts
|
177 |
+
$('.sbi_manually_connect_wrap').hide();
|
178 |
+
$('.sbi_manually_connect').click(function(event) {
|
179 |
+
event.preventDefault();
|
180 |
+
if ( $('.sbi_manually_connect_wrap').is(':visible') ) {
|
181 |
+
$('.sbi_manually_connect_wrap').slideUp(200);
|
182 |
+
} else {
|
183 |
+
$('.sbi_manually_connect_wrap').slideDown(200);
|
184 |
+
$('#sb_manual_at').focus();
|
185 |
+
}
|
186 |
+
});
|
187 |
+
var $body = $('body');
|
188 |
+
$body.on('click', '.sbi_remove_from_user_feed, .sbi_use_in_user_feed, .sbi_test_token, .sbi_delete_account *, .sbi_ca_token_shortcode', function (event) {
|
189 |
+
event.preventDefault();
|
190 |
+
var $clicked = $(event.target),
|
191 |
+
accessToken = $clicked.closest('.sbi_connected_account').attr('data-accesstoken'),
|
192 |
+
action = false,
|
193 |
+
atParts = accessToken.split('.'),
|
194 |
+
username = $clicked.closest('.sbi_connected_account').attr('data-username');
|
195 |
+
|
196 |
+
if ($clicked.hasClass('sbi_remove_from_user_feed')) {
|
197 |
+
$clicked.removeClass('sbi_remove_from_user_feed');
|
198 |
+
$clicked.addClass('sbi_use_in_user_feed');
|
199 |
+
$clicked.closest('.sbi_connected_account').removeClass('sbi_account_active');
|
200 |
+
$clicked.html('<i class="fa fa-plus-circle" aria-hidden="true"></i>Add to Primary Feed');
|
201 |
+
$('#sbi_user_feed_id_'+atParts[0]).remove();
|
202 |
+
} else if ($clicked.hasClass('sbi_use_in_user_feed')) {
|
203 |
+
$clicked.removeClass('sbi_use_in_user_feed');
|
204 |
+
$clicked.addClass('sbi_remove_from_user_feed');
|
205 |
+
$clicked.closest('.sbi_connected_account').removeClass('sbi_account_updated');
|
206 |
+
$clicked.closest('.sbi_connected_account').addClass('sbi_account_active');
|
207 |
+
$clicked.html('<i class="fa fa-minus-circle" aria-hidden="true" style="margin-right: 5px;"></i>Remove from Primary Feed');
|
208 |
+
var name = '<strong>'+atParts[0]+'</strong>';
|
209 |
+
if (username !== '') {
|
210 |
+
name = '<strong>'+username+'</strong> <span>('+atParts[0]+')</span>';
|
211 |
+
}
|
212 |
+
$('.sbi_user_feed_ids_wrap').prepend(
|
213 |
+
'<div id="sbi_user_feed_id_'+atParts[0]+'" class="sbi_user_feed_account_wrap">'+
|
214 |
+
name +
|
215 |
+
'<input type="hidden" name="sb_instagram_user_id[]" value="'+atParts[0]+'">' +
|
216 |
+
'</div>'
|
217 |
+
);
|
218 |
+
} else if ($clicked.parent().hasClass('sbi_delete_account')) {
|
219 |
+
if (window.confirm("Delete this connected account?")) {
|
220 |
+
action = 'sbi_delete_account';
|
221 |
+
$('#sbi_user_feed_id_' + atParts[0] + ',#sbi_connected_account_' + atParts[0]).remove();
|
222 |
+
jQuery.ajax({
|
223 |
+
url: sbiA.ajax_url,
|
224 |
+
type: 'post',
|
225 |
+
data: {
|
226 |
+
action: action,
|
227 |
+
access_token: accessToken
|
228 |
+
},
|
229 |
+
success: function (data) {
|
230 |
+
console.log(data);
|
231 |
+
}
|
232 |
+
});
|
233 |
+
}
|
234 |
+
} else if ($clicked.hasClass('sbi_ca_token_shortcode')) {
|
235 |
+
jQuery(this).closest('.sbi_ca_info').find('.sbi_ca_shortcode').slideToggle(200);
|
236 |
+
} //
|
237 |
+
|
238 |
+
});
|
239 |
+
|
240 |
+
$body.on('change', '.sbi_ca_show_token input[type=checkbox]', function(event) {
|
241 |
+
jQuery(this).closest('.sbi_ca_info').find('.sbi_ca_accesstoken').slideToggle(200);
|
242 |
+
});
|
243 |
+
|
244 |
+
|
245 |
+
//If there's a hash then autofill the token and id
|
246 |
+
/*
|
247 |
+
if(hash && !jQuery('#sbi_just_saved').length){
|
248 |
+
//$('#sbi_config').append('<div id="sbi_config_info"><p><b>Access Token: </b><input type="text" size=58 readonly value="'+token+'" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."></p><p><b>User ID: </b><input type="text" size=12 readonly value="'+id+'" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."></p><p><i class="fa fa-clipboard" aria-hidden="true"></i> <b><span style="color: red;">Important:</span> Copy and paste</b> these into the fields below and click <b>"Save Changes"</b>.</p></div>');
|
249 |
+
$('#sbi_config').append('<div id="sbi_config_info"><p class="sb_get_token"><b>Access Token: </b><input type="text" size=58 readonly value="'+token+'" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."></p><p><b>User ID: </b><input type="text" size=12 readonly value="'+id+'" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."></p></div>');
|
250 |
+
if(jQuery('#sb_instagram_at').val() == '' && token.length > 40) {
|
251 |
+
jQuery('#sb_instagram_at').val(token);
|
252 |
+
sbSaveToken(token);
|
253 |
+
} else {
|
254 |
+
jQuery('.sb_get_token').append('<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Connect This Account"></p>');
|
255 |
+
}
|
256 |
+
|
257 |
+
}
|
258 |
+
|
259 |
+
$('.sb_get_token #submit').click(function(event) {
|
260 |
+
event.preventDefault();
|
261 |
+
$(this).closest('.submit').fadeOut();
|
262 |
+
jQuery('#sb_instagram_at').val(token);
|
263 |
+
sbSaveToken(token);
|
264 |
+
});
|
265 |
+
*/
|
266 |
+
|
267 |
+
$('#sbi_manual_submit').click(function(event) {
|
268 |
+
event.preventDefault();
|
269 |
+
var $self = $(this);
|
270 |
+
var accessToken = $('#sb_manual_at').val();
|
271 |
+
if (accessToken.length < 15) {
|
272 |
+
if (!$('.sbi_manually_connect_wrap').find('.sbi_user_id_error').length) {
|
273 |
+
$('.sbi_manually_connect_wrap').show().prepend('<div class="sbi_user_id_error" style="display:block;">Please enter a valid access token</div>');
|
274 |
+
}
|
275 |
+
} else {
|
276 |
+
$(this).attr('disabled',true);
|
277 |
+
$(this).closest('.sbi_manually_connect_wrap').fadeOut();
|
278 |
+
$('.sbi_connected_accounts_wrap').fadeTo("slow" , 0.5).find('.sbi_user_id_error').remove();
|
279 |
+
|
280 |
+
jQuery.ajax({
|
281 |
+
url: sbiA.ajax_url,
|
282 |
+
type: 'post',
|
283 |
+
data: {
|
284 |
+
action: 'sbi_test_token',
|
285 |
+
access_token: accessToken
|
286 |
+
},
|
287 |
+
success: function (data) {
|
288 |
+
$('.sbi_connected_accounts_wrap').fadeTo("slow" , 1);
|
289 |
+
$self.removeAttr('disabled');
|
290 |
+
if ( data.indexOf('{') > -1) {
|
291 |
+
var savedToken = JSON.parse(data);
|
292 |
+
$(this).closest('.sbi_manually_connect_wrap').fadeOut();
|
293 |
+
$('#sb_manual_at').val('');
|
294 |
+
sbiAfterUpdateToken(savedToken,false);
|
295 |
+
} else {
|
296 |
+
$('.sbi_manually_connect_wrap').show().prepend('<div class="sbi_user_id_error" style="display:block;">'+data+'</div>');
|
297 |
+
}
|
298 |
+
|
299 |
+
}
|
300 |
+
});
|
301 |
+
}
|
302 |
+
|
303 |
+
});
|
304 |
|
305 |
//clear backup caches
|
306 |
jQuery('#sbi_clear_backups').click(function(event) {
|
js/sb-instagram.min.js
CHANGED
@@ -38,7 +38,7 @@ var sbi_js_exists=(typeof sbi_js_exists!=='undefined')?!0:!1;if(!sbi_js_exists){
|
|
38 |
function sbiBuildHeader(data,sbiSettings){if(typeof data.meta.error_message!=='undefined')return;var feedOptions=sbiSettings.feedOptions,headerStyles='';if(feedOptions.headercolor.length)headerStyles='style="color: #'+feedOptions.headercolor+'"';$header='<a href="https://www.instagram.com/'+data.data.username+'" target="_blank" title="@'+data.data.username+'" class="sbi_header_link" '+headerStyles+'>';$header+='<div class="sbi_header_text">';var classheader='';if((typeof data.data.bio!=='undefined'&&data.data.bio.length<1)||feedOptions.showbio!='true')classheader=' class="sbi_no_bio"';$header+='<h3 '+headerStyles+classheader+'>'+data.data.username+'</h3>';var $headerInfo='<p class="sbi_bio_info" ';if(feedOptions.headerstyle=='boxed'){$headerInfo+='style="color: #'+feedOptions.headerprimarycolor+';"'}else{$headerInfo+=headerStyles}
|
39 |
if(typeof data.data.bio!=='undefined'&&data.data.bio.length>1&&feedOptions.showbio!=''&&feedOptions.showbio!='false')$header+='<p class="sbi_bio" '+headerStyles+'>'+data.data.bio+'</p>';$header+='</div>';$header+='<div class="sbi_header_img">';$header+='<div class="sbi_header_img_hover"><i class="sbi_new_logo"></i></div>';$header+='<img src="'+data.data.profile_picture+'" alt="'+data.data.full_name+'" width="50" height="50">';$header+='</div>';$header+='</a>';if(feedOptions.headerstyle=='boxed'){$header+='<div class="sbi_header_bar" style="background: #'+feedOptions.headersecondarycolor+'">';if(feedOptions.showbio!='false')$header+=$headerInfo;$header+='<a class="sbi_header_follow_btn" href="https://www.instagram.com/'+data.data.username+'" target="_blank" style="color: #'+feedOptions.headercolor+'; background: #'+feedOptions.headerprimarycolor+';"><i class="sbi_new_logo"></i><span></span></div></div>'}
|
40 |
if($self.find('.sbi_header_link').length==0)$self.find('.sb_instagram_header').prepend($header);if($self.find('.sbi_follow_btn').length)$self.find('.sbi_follow_btn a').attr('href','https://www.instagram.com/'+data.data.username);if(feedOptions.headerstyle=='boxed'&&$self.find('.sbi_header_follow_btn').length)$self.find('.sbi_header_follow_btn span').text($self.find('.sb_instagram_header').attr('data-follow-text').replace(/\\/g,""));$self.find('.sb_instagram_header .sbi_header_link').hover(function(){$self.find('.sb_instagram_header .sbi_header_img_hover').fadeIn(200)},function(){$self.find('.sb_instagram_header .sbi_header_img_hover').stop().fadeOut(600)});sbSVGify($self.find('.sb_instagram_header'))}
|
41 |
-
function sbiFetchData(next_url,transientName,sbiSettings,$self){apiURLs=next_url;var urlCount=apiURLs.length,getType=sbiSettings.getType;if(urlCount==0){if(imagesArrCount+parseInt(sbiSettings.num)>=imagesArr.data.length){jQuery('#sbi_load .sbi_load_btn').hide()}}else{var returnedImages=[],numberOfRequests=urlCount;jQuery.each(apiURLs,function(index,entry){jQuery.ajax({method:"GET",url:entry,dataType:"jsonp",success:function(data){var sbiErrorResponse=data.meta.error_message,sbiErrorMsg='',sbiErrorDir='';if(typeof sbiErrorResponse!=='undefined'){sbiErrorMsg+='<p><i class="fa fab fa-instagram" style="font-size: 16px; position: relative; top: 1px;"></i> Instagram Feed Error</p>';if(sbiErrorResponse.indexOf('access_token')>-1){sbiErrorMsg+='<p><b>Error: Access Token is not valid or has expired</b><br /><span>This error message is only visible to WordPress admins</span></p>';sbiErrorDir="<p>There's an issue with the Instagram Access Token that you are using. Please obtain a new Access Token on the plugin's Settings page.<br />If you continue to have an issue with your Access Token then please see <a href='https://smashballoon.com/my-instagram-access-token-keep-expiring/' target='_blank'>this FAQ</a> for more information.</p>";jQuery('#sb_instagram').empty().append('<p style="text-align: center;">Unable to show Instagram photos</p><div id="sbi_mod_error">'+sbiErrorMsg+sbiErrorDir+'</div>');sbiAddTokenToExpiredList(sb_instagram_js_options.sb_instagram_at,transientName);return}else if(sbiErrorResponse.indexOf('retired')>-1){sbiErrorMsg+='<p><b>No longer possible to display this feed</b><br /><span>This error message is only visible to WordPress admins</span></p>';sbiErrorDir="<p>Due to changes in the Instagram API, it is no longer possible to display a feed from an Instagram account which is not your own. You can now only display your own Instagram account. Please see <a href='https://smashballoon.com/instagram-api-changes-april-4-2018/' target='_blank'>this post</a> for more information.</p>";jQuery('#sb_instagram').empty().append('<p style="text-align: center;">Unable to show Instagram photos</p><div id="sbi_mod_error">'+sbiErrorMsg+sbiErrorDir+'</div>');return}else if(typeof data.code!=='undefined'&&data.code=='429'){window.sbiFeedMeta[$i].error={errorMsg:'<p><b>Error: Rate Limit Reached</b><br /><span>This error is only visible to WordPress admins</span>',errorDir:"<p>Backup cache will be used for 1 hour</p>"};if(!$self.find('#sbi_mod_error').length){$self.prepend('<div id="sbi_mod_error">'+window.sbiFeedMeta[$i].error.errorMsg+window.sbiFeedMeta[$i].error.errorDir+'</div>')}else if($self.find('.sbiErrorIds').text().indexOf(window.sbiFeedMeta[$i].idsInFeed[index])==-1){$self.find('.sbiErrorIds').append(','+window.sbiFeedMeta[$i].idsInFeed[index])}
|
42 |
var submittedData={action:'sbi_set_use_backup',transientName:transientName,context:'falsecache'};jQuery.ajax({url:sbiajaxurl,type:'post',data:submittedData,success:function(data){}});data='error'}else if(sbiErrorResponse.indexOf('user does not exist')>-1||sbiErrorResponse.indexOf('you cannot view this resource')>-1){window.sbiFeedMeta[$i].error={errorMsg:'<p><b>Error: User ID <span class="sbiErrorIds">'+window.sbiFeedMeta[$i].idsInFeed[index]+'</span> does not exist, is invalid, or is private</b><br /><span>This error is only visible to WordPress admins</span>',errorDir:"<p>Please double check that the Instagram User ID you are using is valid and not from a private account. To find your User ID simply enter your Instagram user name into this <a href='https://smashballoon.com/instagram-feed/find-instagram-user-id/' target='_blank'>tool</a>.</p>"};if(!$self.find('#sbi_mod_error').length){$self.prepend('<div id="sbi_mod_error">'+window.sbiFeedMeta[$i].error.errorMsg+window.sbiFeedMeta[$i].error.errorDir+'</div>')}else if($self.find('.sbiErrorIds').text().indexOf(window.sbiFeedMeta[$i].idsInFeed[index])==-1){$self.find('.sbiErrorIds').append(','+window.sbiFeedMeta[$i].idsInFeed[index])}
|
43 |
data='error'}else if(sbiErrorResponse.indexOf('invalid media id')>-1){window.sbiFeedMeta[$i].error={errorMsg:'<p><b>Error: Post Id <span class="sbiErrorIds">'+window.sbiFeedMeta[$i].idsInFeed[index]+'</span> does not exist or is invalid</b><br /><span>This error is only visible to WordPress admins.</span>',errorDir:"<p>Please double check the media (post) id is correct.</p>"};if(!$self.find('#sbi_mod_error').length){$self.prepend('<div id="sbi_mod_error">'+window.sbiFeedMeta[$i].error.errorMsg+window.sbiFeedMeta[$i].error.errorDir+'</div>')}else if($self.find('.sbiErrorIds').text().indexOf(window.sbiFeedMeta[$i].idsInFeed[index])==-1){$self.find('.sbiErrorIds').append(','+window.sbiFeedMeta[$i].idsInFeed[index])}
|
44 |
data='error'}}
|
38 |
function sbiBuildHeader(data,sbiSettings){if(typeof data.meta.error_message!=='undefined')return;var feedOptions=sbiSettings.feedOptions,headerStyles='';if(feedOptions.headercolor.length)headerStyles='style="color: #'+feedOptions.headercolor+'"';$header='<a href="https://www.instagram.com/'+data.data.username+'" target="_blank" title="@'+data.data.username+'" class="sbi_header_link" '+headerStyles+'>';$header+='<div class="sbi_header_text">';var classheader='';if((typeof data.data.bio!=='undefined'&&data.data.bio.length<1)||feedOptions.showbio!='true')classheader=' class="sbi_no_bio"';$header+='<h3 '+headerStyles+classheader+'>'+data.data.username+'</h3>';var $headerInfo='<p class="sbi_bio_info" ';if(feedOptions.headerstyle=='boxed'){$headerInfo+='style="color: #'+feedOptions.headerprimarycolor+';"'}else{$headerInfo+=headerStyles}
|
39 |
if(typeof data.data.bio!=='undefined'&&data.data.bio.length>1&&feedOptions.showbio!=''&&feedOptions.showbio!='false')$header+='<p class="sbi_bio" '+headerStyles+'>'+data.data.bio+'</p>';$header+='</div>';$header+='<div class="sbi_header_img">';$header+='<div class="sbi_header_img_hover"><i class="sbi_new_logo"></i></div>';$header+='<img src="'+data.data.profile_picture+'" alt="'+data.data.full_name+'" width="50" height="50">';$header+='</div>';$header+='</a>';if(feedOptions.headerstyle=='boxed'){$header+='<div class="sbi_header_bar" style="background: #'+feedOptions.headersecondarycolor+'">';if(feedOptions.showbio!='false')$header+=$headerInfo;$header+='<a class="sbi_header_follow_btn" href="https://www.instagram.com/'+data.data.username+'" target="_blank" style="color: #'+feedOptions.headercolor+'; background: #'+feedOptions.headerprimarycolor+';"><i class="sbi_new_logo"></i><span></span></div></div>'}
|
40 |
if($self.find('.sbi_header_link').length==0)$self.find('.sb_instagram_header').prepend($header);if($self.find('.sbi_follow_btn').length)$self.find('.sbi_follow_btn a').attr('href','https://www.instagram.com/'+data.data.username);if(feedOptions.headerstyle=='boxed'&&$self.find('.sbi_header_follow_btn').length)$self.find('.sbi_header_follow_btn span').text($self.find('.sb_instagram_header').attr('data-follow-text').replace(/\\/g,""));$self.find('.sb_instagram_header .sbi_header_link').hover(function(){$self.find('.sb_instagram_header .sbi_header_img_hover').fadeIn(200)},function(){$self.find('.sb_instagram_header .sbi_header_img_hover').stop().fadeOut(600)});sbSVGify($self.find('.sb_instagram_header'))}
|
41 |
+
function sbiFetchData(next_url,transientName,sbiSettings,$self){apiURLs=next_url;var urlCount=apiURLs.length,getType=sbiSettings.getType;if(urlCount==0){if(imagesArrCount+parseInt(sbiSettings.num)>=imagesArr.data.length){jQuery('#sbi_load .sbi_load_btn').hide()}}else{var returnedImages=[],numberOfRequests=urlCount;jQuery.each(apiURLs,function(index,entry){jQuery.ajax({method:"GET",url:entry,dataType:"jsonp",success:function(data){var sbiErrorResponse=data.meta.error_message,sbiErrorMsg='',sbiErrorDir='';if(typeof sbiErrorResponse!=='undefined'){sbiErrorMsg+='<p><i class="fa fab fa-instagram" style="font-size: 16px; position: relative; top: 1px;"></i> Instagram Feed Error</p>';if(sbiErrorResponse.indexOf('access_token')>-1){sbiErrorMsg+='<p><b>Error: Access Token is not valid or has expired</b><br /><span>This error message is only visible to WordPress admins</span></p>';sbiErrorDir="<p>There's an issue with the Instagram Access Token that you are using. Please obtain a new Access Token on the plugin's Settings page.<br />If you continue to have an issue with your Access Token then please see <a href='https://smashballoon.com/my-instagram-access-token-keep-expiring/' target='_blank'>this FAQ</a> for more information.</p>";jQuery('#sb_instagram').empty().append('<p style="text-align: center;">Unable to show Instagram photos</p><div id="sbi_mod_error">'+sbiErrorMsg+sbiErrorDir+'</div>');sbiAddTokenToExpiredList(sb_instagram_js_options.sb_instagram_at,transientName);var submittedData={action:'sbi_set_use_backup',transientName:transientName,context:'falsecache'};jQuery.ajax({url:sbiajaxurl,type:'post',data:submittedData,success:function(data){}});return}else if(sbiErrorResponse.indexOf('retired')>-1){sbiErrorMsg+='<p><b>No longer possible to display this feed</b><br /><span>This error message is only visible to WordPress admins</span></p>';sbiErrorDir="<p>Due to changes in the Instagram API, it is no longer possible to display a feed from an Instagram account which is not your own. You can now only display your own Instagram account. Please see <a href='https://smashballoon.com/instagram-api-changes-april-4-2018/' target='_blank'>this post</a> for more information.</p>";jQuery('#sb_instagram').empty().append('<p style="text-align: center;">Unable to show Instagram photos</p><div id="sbi_mod_error">'+sbiErrorMsg+sbiErrorDir+'</div>');return}else if(typeof data.code!=='undefined'&&data.code=='429'){window.sbiFeedMeta[$i].error={errorMsg:'<p><b>Error: Rate Limit Reached</b><br /><span>This error is only visible to WordPress admins</span>',errorDir:"<p>Backup cache will be used for 1 hour</p>"};if(!$self.find('#sbi_mod_error').length){$self.prepend('<div id="sbi_mod_error">'+window.sbiFeedMeta[$i].error.errorMsg+window.sbiFeedMeta[$i].error.errorDir+'</div>')}else if($self.find('.sbiErrorIds').text().indexOf(window.sbiFeedMeta[$i].idsInFeed[index])==-1){$self.find('.sbiErrorIds').append(','+window.sbiFeedMeta[$i].idsInFeed[index])}
|
42 |
var submittedData={action:'sbi_set_use_backup',transientName:transientName,context:'falsecache'};jQuery.ajax({url:sbiajaxurl,type:'post',data:submittedData,success:function(data){}});data='error'}else if(sbiErrorResponse.indexOf('user does not exist')>-1||sbiErrorResponse.indexOf('you cannot view this resource')>-1){window.sbiFeedMeta[$i].error={errorMsg:'<p><b>Error: User ID <span class="sbiErrorIds">'+window.sbiFeedMeta[$i].idsInFeed[index]+'</span> does not exist, is invalid, or is private</b><br /><span>This error is only visible to WordPress admins</span>',errorDir:"<p>Please double check that the Instagram User ID you are using is valid and not from a private account. To find your User ID simply enter your Instagram user name into this <a href='https://smashballoon.com/instagram-feed/find-instagram-user-id/' target='_blank'>tool</a>.</p>"};if(!$self.find('#sbi_mod_error').length){$self.prepend('<div id="sbi_mod_error">'+window.sbiFeedMeta[$i].error.errorMsg+window.sbiFeedMeta[$i].error.errorDir+'</div>')}else if($self.find('.sbiErrorIds').text().indexOf(window.sbiFeedMeta[$i].idsInFeed[index])==-1){$self.find('.sbiErrorIds').append(','+window.sbiFeedMeta[$i].idsInFeed[index])}
|
43 |
data='error'}else if(sbiErrorResponse.indexOf('invalid media id')>-1){window.sbiFeedMeta[$i].error={errorMsg:'<p><b>Error: Post Id <span class="sbiErrorIds">'+window.sbiFeedMeta[$i].idsInFeed[index]+'</span> does not exist or is invalid</b><br /><span>This error is only visible to WordPress admins.</span>',errorDir:"<p>Please double check the media (post) id is correct.</p>"};if(!$self.find('#sbi_mod_error').length){$self.prepend('<div id="sbi_mod_error">'+window.sbiFeedMeta[$i].error.errorMsg+window.sbiFeedMeta[$i].error.errorDir+'</div>')}else if($self.find('.sbiErrorIds').text().indexOf(window.sbiFeedMeta[$i].idsInFeed[index])==-1){$self.find('.sbiErrorIds').append(','+window.sbiFeedMeta[$i].idsInFeed[index])}
|
44 |
data='error'}}
|