Instagram Feed - Version 2.4.2

Version Description

  • New: To help us improve the plugin we've added the ability to opt-in to usage tracking so that we can understand what features and settings are being used, and which features matter to you the most. This is disabled by default and will only be enabled if you explictly choose to opt in. If opted in, the plugin will send a report in the background once per week with your plugin settings and basic information about your website environment. No personal or sensitive data is collected (such as email addresses, Instagram account information, license keys, etc). To enable or disable usage tracking at a later date use the setting at: Instagram Feed > Customize > Advanced > Misc > Enable Usage Tracking. See here for more information.
  • Tweak: Added additional checks to make sure the HTTP protocol matches when using resized image URLs from the uploads folder.
  • Tweak: More information is given when there is an account connection error when connecting an account on the "Configure" page.
  • Tweak: Connecting a business account will permanently remove any accounts from the same user that are from the legacy Instagram API that is expiring in June.
  • Fix: Added a workaround for sanitize_textarea_field for users using an older version of WordPress.
  • Fix: Fixed HTML error causing the manually connect an account feature to not work.
  • Fix: Access token and account ID are validated and formatted before trying to manually connect an account to prevent errors.
Download this release

Release Info

Developer smashballoon
Plugin Icon 128x128 Instagram Feed
Version 2.4.2
Comparing to
See all releases

Code changes from version 2.4.1 to 2.4.2

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.4
5
  Tested up to: 5.4
6
- Stable tag: 2.4.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -325,6 +325,15 @@ We understand that sometimes you need help, have issues or just have questions.
325
  * Plus more customization options added all the time!
326
 
327
  == Changelog ==
 
 
 
 
 
 
 
 
 
328
  = 2.4.1 =
329
  * Tweak: User feeds that do not have a user name or ID assigned to them will automatically use the first connected account for the feed.
330
  * Tweak: rel="nofollow" added to all external Instagram Feed links found in the source of the page.
3
  Tags: Instagram, Instagram feed, Instagram photos, Instagram widget, Instagram gallery
4
  Requires at least: 3.4
5
  Tested up to: 5.4
6
+ Stable tag: 2.4.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
325
  * Plus more customization options added all the time!
326
 
327
  == Changelog ==
328
+ = 2.4.2 =
329
+ * New: To help us improve the plugin we've added the ability to opt-in to usage tracking so that we can understand what features and settings are being used, and which features matter to you the most. This is disabled by default and will only be enabled if you explictly choose to opt in. If opted in, the plugin will send a report in the background once per week with your plugin settings and basic information about your website environment. No personal or sensitive data is collected (such as email addresses, Instagram account information, license keys, etc). To enable or disable usage tracking at a later date use the setting at: Instagram Feed > Customize > Advanced > Misc > Enable Usage Tracking. See [here](https://smashballoon.com/instagram-feed/usage-tracking/) for more information.
330
+ * Tweak: Added additional checks to make sure the HTTP protocol matches when using resized image URLs from the uploads folder.
331
+ * Tweak: More information is given when there is an account connection error when connecting an account on the "Configure" page.
332
+ * Tweak: Connecting a business account will permanently remove any accounts from the same user that are from the legacy Instagram API that is expiring in June.
333
+ * Fix: Added a workaround for sanitize_textarea_field for users using an older version of WordPress.
334
+ * Fix: Fixed HTML error causing the manually connect an account feature to not work.
335
+ * Fix: Access token and account ID are validated and formatted before trying to manually connect an account to prevent errors.
336
+
337
  = 2.4.1 =
338
  * Tweak: User feeds that do not have a user name or ID assigned to them will automatically use the first connected account for the feed.
339
  * Tweak: rel="nofollow" added to all external Instagram Feed links found in the source of the page.
css/sb-blocks.css CHANGED
@@ -1,3 +1,3 @@
1
- .sbi {
2
- pointer-events: none !important;
3
  }
1
+ .sbi {
2
+ pointer-events: none !important;
3
  }
css/sb-instagram-2-1.css ADDED
@@ -0,0 +1,744 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**************/
2
+ /*** LAYOUT ***/
3
+ /**************/
4
+
5
+ /* Feed container */
6
+ #sb_instagram {
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
+ #sb_instagram:after{
15
+ content: "";
16
+ display: table;
17
+ clear: both;
18
+ }
19
+
20
+ /*********************/
21
+ /*** STYLE OPTIONS ***/
22
+ /*********************/
23
+ #sb_instagram.sbi_fixed_height{
24
+ overflow: hidden;
25
+ overflow-y: auto;
26
+ -webkit-box-sizing: border-box;
27
+ -moz-box-sizing: border-box;
28
+ box-sizing: border-box;
29
+ }
30
+ #sb_instagram #sbi_images{
31
+ width: 100%;
32
+ float: left;
33
+ line-height: 0;
34
+
35
+ -webkit-box-sizing: border-box;
36
+ -moz-box-sizing: border-box;
37
+ box-sizing: border-box;
38
+ }
39
+
40
+ /* Items */
41
+ #sb_instagram #sbi_images .sbi_item{
42
+ display: -moz-inline-stack;
43
+ display: inline-block;
44
+ float: left;
45
+ vertical-align: top;
46
+ zoom: 1;
47
+ *display: inline;
48
+
49
+ max-height: 1000px;
50
+ padding: inherit !important;
51
+ margin: 0 !important;
52
+ text-decoration: none;
53
+ opacity: 1;
54
+ overflow: hidden;
55
+
56
+ -webkit-box-sizing: border-box;
57
+ -moz-box-sizing: border-box;
58
+ box-sizing: border-box;
59
+
60
+ -webkit-transition: all 0.5s ease;
61
+ -moz-transition: all 0.5s ease;
62
+ -o-transition: all 0.5s ease;
63
+ -ms-transition: all 0.5s ease;
64
+ transition: all 0.5s ease;
65
+ }
66
+ /* Transition items in */
67
+ #sb_instagram #sbi_images .sbi_item.sbi_transition{
68
+ opacity: 0;
69
+ max-height: 0;
70
+ }
71
+
72
+ /* Cols */
73
+ #sb_instagram.sbi_col_1 #sbi_images .sbi_item{ width: 100%; }
74
+ #sb_instagram.sbi_col_2 #sbi_images .sbi_item{ width: 50%; }
75
+ #sb_instagram.sbi_col_3 #sbi_images .sbi_item{ width: 33.33%; }
76
+ #sb_instagram.sbi_col_4 #sbi_images .sbi_item{ width: 25%; }
77
+ #sb_instagram.sbi_col_5 #sbi_images .sbi_item{ width: 20%; }
78
+ #sb_instagram.sbi_col_6 #sbi_images .sbi_item{ width: 16.66%; }
79
+ #sb_instagram.sbi_col_7 #sbi_images .sbi_item{ width: 14.28%; }
80
+ #sb_instagram.sbi_col_8 #sbi_images .sbi_item{ width: 12.5%; }
81
+ #sb_instagram.sbi_col_9 #sbi_images .sbi_item{ width: 11.11%; }
82
+ #sb_instagram.sbi_col_10 #sbi_images .sbi_item{ width: 10%; }
83
+
84
+ /* Disable mobile layout */
85
+ #sb_instagram.sbi_col_1.sbi_disable_mobile #sbi_images .sbi_item{ width: 100%; }
86
+ #sb_instagram.sbi_col_2.sbi_disable_mobile #sbi_images .sbi_item{ width: 50%; }
87
+ #sb_instagram.sbi_col_3.sbi_disable_mobile #sbi_images .sbi_item{ width: 33.33%; }
88
+ #sb_instagram.sbi_col_4.sbi_disable_mobile #sbi_images .sbi_item{ width: 25%; }
89
+ #sb_instagram.sbi_col_5.sbi_disable_mobile #sbi_images .sbi_item{ width: 20%; }
90
+ #sb_instagram.sbi_col_6.sbi_disable_mobile #sbi_images .sbi_item{ width: 16.66%; }
91
+ #sb_instagram.sbi_col_7.sbi_disable_mobile #sbi_images .sbi_item{ width: 14.28%; }
92
+ #sb_instagram.sbi_col_8.sbi_disable_mobile #sbi_images .sbi_item{ width: 12.5%; }
93
+ #sb_instagram.sbi_col_9.sbi_disable_mobile #sbi_images .sbi_item{ width: 11.11%; }
94
+ #sb_instagram.sbi_col_10.sbi_disable_mobile #sbi_images .sbi_item{ width: 10%; }
95
+
96
+ /* Photos */
97
+ #sb_instagram .sbi_photo_wrap{
98
+ position: relative;
99
+ }
100
+ #sb_instagram .sbi_photo{
101
+ display: block;
102
+ text-decoration: none;
103
+ }
104
+ #sb_instagram .sbi_photo img{
105
+ width: 100%;
106
+ height: auto;
107
+ }
108
+ #sb_instagram .sbi_no_js img{
109
+ display: none;
110
+ }
111
+ #sb_instagram a,
112
+ #sb_instagram a:hover,
113
+ #sb_instagram a:focus,
114
+ #sb_instagram a:active{
115
+ outline: none;
116
+ }
117
+ #sb_instagram img{
118
+ display: block;
119
+ padding: 0 !important;
120
+ margin: 0 !important;
121
+ max-width: 100% !important;
122
+ opacity: 1 !important;
123
+ }
124
+ #sb_instagram .sbi_link{
125
+ display: none;
126
+ position: absolute;
127
+ bottom: 0;
128
+ right: 0;
129
+
130
+ width: 100%;
131
+ padding: 10px 0;
132
+ background: rgba(0,0,0,0.5);
133
+ text-align: center;
134
+ color: #fff;
135
+ font-size: 12px;
136
+ line-height: 1.1;
137
+ }
138
+ #sb_instagram .sbi_link a{
139
+ padding: 0 6px;
140
+ text-decoration: none;
141
+ color: #fff;
142
+ font-size: 12px;
143
+ line-height: 1.1;
144
+
145
+ display: -moz-inline-stack;
146
+ display: inline-block;
147
+ vertical-align: top;
148
+ zoom: 1;
149
+ *display: inline;
150
+ }
151
+ #sb_instagram .sbi_link .sbi_lightbox_link{
152
+ padding-bottom: 5px;
153
+ }
154
+ #sb_instagram .sbi_link a:hover,
155
+ #sb_instagram .sbi_link a:focus{
156
+ text-decoration: underline;
157
+ }
158
+ #sb_instagram .sbi_photo_wrap:hover .sbi_link,
159
+ #sb_instagram .sbi_photo_wrap:focus .sbi_link{
160
+ display: block;
161
+ }
162
+
163
+ /* Videos */
164
+ #sb_instagram svg:not(:root).svg-inline--fa {
165
+ height: 1em;
166
+ display: inline-block;
167
+ }
168
+
169
+ #sb_instagram .sbi_type_video .sbi_playbtn,
170
+ #sb_instagram .sbi_type_carousel .sbi_playbtn,
171
+ .sbi_type_carousel .fa-clone,
172
+ #sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play,
173
+ #sb_instagram .sbi_type_video .svg-inline--fa.fa-play{
174
+ display: block !important;
175
+ position: absolute;
176
+ z-index: 1;
177
+
178
+ color: #fff;
179
+ color: rgba(255,255,255,0.9);
180
+ font-style: normal !important;
181
+ text-shadow: 0 0 8px rgba(0,0,0,0.8);
182
+ }
183
+ #sb_instagram .sbi_type_video .sbi_playbtn,
184
+ #sb_instagram .sbi_type_carousel .sbi_playbtn {
185
+ z-index: 2;
186
+ top: 50%;
187
+ left: 50%;
188
+ margin-top: -24px;
189
+ margin-left: -19px;
190
+ padding: 0;
191
+ font-size: 48px;
192
+ }
193
+ #sb_instagram .sbi_type_carousel .fa-clone{
194
+ right: 12px;
195
+ top: 12px;
196
+ font-size: 24px;
197
+ text-shadow: 0 0 8px rgba(0,0,0,0.3);
198
+ }
199
+ .sbi_type_carousel svg.fa-clone,
200
+ #sb_instagram .sbi_type_video .svg-inline--fa.fa-play,
201
+ #sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play{
202
+ -webkit-filter: drop-shadow( 0px 0px 2px rgba(0,0,0,.4) );
203
+ filter: drop-shadow( 0px 0px 2px rgba(0,0,0,.4) );
204
+ }
205
+
206
+ /* Loader */
207
+ #sb_instagram .sbi_loader{
208
+ width: 20px;
209
+ height: 20px;
210
+
211
+ position: relative;
212
+ top: 50%;
213
+ left: 50%;
214
+ margin: -10px 0 0 -10px;
215
+ background-color: #000;
216
+ background-color: rgba(0,0,0,0.5);
217
+
218
+ border-radius: 100%;
219
+ -webkit-animation: sbi-sk-scaleout 1.0s infinite ease-in-out;
220
+ animation: sbi-sk-scaleout 1.0s infinite ease-in-out;
221
+ }
222
+ #sb_instagram br {
223
+ display: none;
224
+ }
225
+ #sbi_load p {
226
+ display: inline;
227
+ padding: 0;
228
+ margin: 0;
229
+ }
230
+ /* Loader in button */
231
+ #sb_instagram #sbi_load .sbi_loader{
232
+ position: absolute;
233
+ margin-top: -11px;
234
+ background-color: #fff;
235
+ opacity: 1;
236
+ }
237
+ @-webkit-keyframes sbi-sk-scaleout {
238
+ 0% { -webkit-transform: scale(0) }
239
+ 100% {
240
+ -webkit-transform: scale(1.0);
241
+ opacity: 0;
242
+ }
243
+ }
244
+ @keyframes sbi-sk-scaleout {
245
+ 0% {
246
+ -webkit-transform: scale(0);
247
+ -ms-transform: scale(0);
248
+ transform: scale(0);
249
+ } 100% {
250
+ -webkit-transform: scale(1.0);
251
+ -ms-transform: scale(1.0);
252
+ transform: scale(1.0);
253
+ opacity: 0;
254
+ }
255
+ }
256
+
257
+ #sb_instagram .fa-spin,
258
+ #sbi_lightbox .fa-spin{
259
+ -webkit-animation: fa-spin 2s infinite linear;
260
+ animation: fa-spin 2s infinite linear
261
+ }
262
+
263
+ #sb_instagram .fa-pulse,
264
+ #sbi_lightbox .fa-pulse{
265
+ -webkit-animation: fa-spin 1s infinite steps(8);
266
+ animation: fa-spin 1s infinite steps(8)
267
+ }
268
+
269
+ @-webkit-keyframes fa-spin {
270
+ 0% {
271
+ -webkit-transform: rotate(0deg);
272
+ transform: rotate(0deg)
273
+ }
274
+ 100% {
275
+ -webkit-transform: rotate(359deg);
276
+ transform: rotate(359deg)
277
+ }
278
+ }
279
+
280
+ @keyframes fa-spin {
281
+ 0% {
282
+ -webkit-transform: rotate(0deg);
283
+ transform: rotate(0deg)
284
+ }
285
+ 100% {
286
+ -webkit-transform: rotate(359deg);
287
+ transform: rotate(359deg)
288
+ }
289
+ }
290
+ /* Screen reader */
291
+ .sbi-screenreader{text-indent: -9999px !important;display: block !important;width: 0 !important;height: 0 !important;line-height: 0 !important;text-align: left !important; }
292
+
293
+ /* HEADER */
294
+ #sb_instagram .sb_instagram_header{
295
+ float: left;
296
+ clear: both;
297
+ margin: 0 0 15px 0;
298
+ padding: 0;
299
+ line-height: 1.2;
300
+ width: 100%;
301
+ }
302
+ #sb_instagram .sb_instagram_header a{
303
+ float: left;
304
+ display: block;
305
+ /*width: 100%;*/
306
+ min-width: 100%\9;
307
+ text-decoration: none;
308
+ transition: color 0.5s ease;
309
+ }
310
+ /** Medium Header */
311
+ /* Only use medium & large headers on devices above 480px */
312
+ @media all and (min-width: 480px){
313
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img {
314
+ width: 80px;
315
+ height: 80px;
316
+ border-radius: 40px;
317
+ }
318
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img img {
319
+ width: 80px;
320
+ height: 80px;
321
+ border-radius: 40px;
322
+ }
323
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3 {
324
+ font-size: 20px;
325
+ }
326
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,
327
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio{
328
+ font-size: 14px;
329
+ }
330
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3,
331
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,
332
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio{
333
+ margin-left: 95px !important;
334
+ line-height: 1.4
335
+ }
336
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3{
337
+ margin-right: -85px !important;
338
+ }
339
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info{
340
+ margin-top: 4px !important;
341
+ }
342
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text.sbi_no_bio h3{
343
+ padding-top: 20px !important;
344
+ }
345
+ /** Large Header */
346
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_img {
347
+ width: 120px;
348
+ height: 120px;
349
+ border-radius: 60px;
350
+ }
351
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_img img {
352
+ width: 120px;
353
+ height: 120px;
354
+ border-radius: 60px;
355
+ }
356
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3 {
357
+ font-size: 28px;
358
+ }
359
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,
360
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio{
361
+ font-size: 16px;
362
+ }
363
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3,
364
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,
365
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio{
366
+ margin-left: 140px !important;
367
+ line-height: 1.5;
368
+ }
369
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3{
370
+ margin-right: -120px !important;
371
+ }
372
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info{
373
+ margin-top: 12px !important;
374
+ }
375
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text.sbi_no_bio h3{
376
+ padding-top: 32px !important;
377
+ }
378
+ }
379
+
380
+ /* Header profile pic */
381
+ #sb_instagram .sb_instagram_header .sbi_header_img{
382
+ float: left;
383
+ position: relative;
384
+ width: 50px;
385
+ margin: 0 0 0 -100% !important;
386
+ overflow: hidden;
387
+
388
+ -moz-border-radius: 40px;
389
+ -webkit-border-radius: 40px;
390
+ border-radius: 40px;
391
+ }
392
+ #sb_instagram .sb_instagram_header .sbi_header_img img{
393
+ float: left;
394
+ margin: 0 !important;
395
+ padding: 0 !important;
396
+ border: none !important;
397
+
398
+ -moz-border-radius: 40px;
399
+ -webkit-border-radius: 40px;
400
+ border-radius: 40px;
401
+ }
402
+ /* Profile pic hover */
403
+ /* Profile pic hover */
404
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover{
405
+ opacity: 0;
406
+ position: absolute;
407
+ width: 100%;
408
+ top: 0;
409
+ bottom: 0;
410
+ left: 0;
411
+ text-align: center;
412
+ color: #fff;
413
+ background: rgba(0,0,0,0.75);
414
+ }
415
+
416
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover .sbi_new_logo{
417
+ position: absolute;
418
+ top: 50%;
419
+ left: 50%;
420
+ margin-top: -12px;
421
+ margin-left: -12px;
422
+ width: 24px;
423
+ height: 24px;
424
+ font-size: 24px;
425
+ }
426
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover i {
427
+ overflow: hidden;
428
+ background: url('../img/small-logo.png') no-repeat 0 0;
429
+ }
430
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover{
431
+ z-index: 2;
432
+ transition: opacity 0.4s ease-in-out;
433
+ }
434
+ #sb_instagram .sb_instagram_header .sbi_fade_in{
435
+ opacity: 1;
436
+ transition: opacity 0.2s ease-in-out;
437
+ }
438
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover{
439
+ position: absolute;
440
+ width: 100%;
441
+ top: 0;
442
+ bottom: 0;
443
+ left: 0;
444
+ text-align: center;
445
+ color: #fff;
446
+ background: rgba(0,0,0,0.75);
447
+
448
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
449
+ filter: alpha(opacity=0);
450
+ -moz-opacity: 0;
451
+ -khtml-opacity: 0;
452
+ opacity: 0;
453
+ border-radius: 40px;
454
+ transition: opacity 0.2s;
455
+ }
456
+ /* Fade the Instagram icon in when hovering on the header */
457
+ #sb_instagram .sb_instagram_header a:hover .sbi_header_img_hover,
458
+ #sb_instagram .sb_instagram_header a:focus .sbi_header_img_hover{
459
+ opacity: 1;
460
+ }
461
+ /* Header text */
462
+ #sb_instagram .sb_instagram_header .sbi_header_text{
463
+ float: left;
464
+ width: 100%;
465
+ padding-top: 5px;
466
+ }
467
+ #sb_instagram .sb_instagram_header a{
468
+ text-decoration: none;
469
+ }
470
+ #sb_instagram .sb_instagram_header .sbi_header_text .sbi_bio,
471
+ #sb_instagram .sb_instagram_header .sbi_header_text h3{
472
+ float: left;
473
+ clear: both;
474
+ width: auto;
475
+ margin: 0 0 0 60px !important;
476
+ padding: 0 !important;
477
+ }
478
+ #sb_instagram .sb_instagram_header h3{
479
+ font-size: 16px;
480
+ line-height: 1.3;
481
+ }
482
+ #sb_instagram .sb_instagram_header p{
483
+ font-size: 13px;
484
+ line-height: 1.3;
485
+ margin: 0;
486
+ padding: 0;
487
+ }
488
+ #sb_instagram p:empty { display: none; }
489
+ #sb_instagram .sb_instagram_header .sbi_header_text img.emoji{
490
+ margin-right: 3px !important;
491
+ }
492
+
493
+ /* No bio */
494
+ #sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio h3{
495
+ padding-top: 9px !important;
496
+ }
497
+ #sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio .sbi_bio_info{
498
+ clear: both;
499
+ }
500
+
501
+
502
+ /* Buttons */
503
+ #sb_instagram #sbi_load{
504
+ float: left;
505
+ clear: both;
506
+ width: 100%;
507
+ text-align: center;
508
+ }
509
+ #sb_instagram #sbi_load .fa-spinner{
510
+ display: none;
511
+ position: absolute;
512
+ top: 50%;
513
+ left: 50%;
514
+ margin: -8px 0 0 -7px;
515
+ font-size: 15px;
516
+ }
517
+ #sb_instagram #sbi_load{
518
+ opacity: 1;
519
+ transition: all 0.5s ease-in;
520
+ }
521
+ #sb_instagram .sbi_load_btn .sbi_btn_text, #sb_instagram .sbi_load_btn .sbi_loader{
522
+ opacity: 1;
523
+ transition: all 0.1s ease-in;
524
+ }
525
+ #sb_instagram .sbi_hidden{
526
+ opacity: 0 !important;
527
+ }
528
+ #sb_instagram #sbi_load .sbi_load_btn,
529
+ #sb_instagram .sbi_follow_btn a{
530
+ display: -moz-inline-stack;
531
+ display: inline-block;
532
+ vertical-align: top;
533
+ zoom: 1;
534
+ *display: inline;
535
+
536
+ padding: 7px 14px;
537
+ margin: 5px auto 0 auto;
538
+ background: #333;
539
+ color: #eee;
540
+ border: none;
541
+ color: #fff;
542
+ text-decoration: none;
543
+ font-size: 13px;
544
+ line-height: 1.5;
545
+
546
+ -moz-border-radius: 4px;
547
+ -webkit-border-radius: 4px;
548
+ border-radius: 4px;
549
+
550
+ -webkit-box-sizing: border-box;
551
+ -moz-box-sizing: border-box;
552
+ box-sizing: border-box;
553
+ }
554
+ #sb_instagram #sbi_load .sbi_load_btn {
555
+ position: relative;
556
+ }
557
+ /* Follow button */
558
+ #sb_instagram .sbi_follow_btn{
559
+ display: -moz-inline-stack;
560
+ display: inline-block;
561
+ vertical-align: top;
562
+ zoom: 1;
563
+ *display: inline;
564
+ text-align: center;
565
+ }
566
+ #sb_instagram .sbi_follow_btn.sbi_top{
567
+ display: block;
568
+ margin-bottom: 5px;
569
+ }
570
+ #sb_instagram .sbi_follow_btn a{
571
+ background: #408bd1;
572
+ color: #fff;
573
+ }
574
+ #sb_instagram .sbi_follow_btn a,
575
+ #sb_instagram .sbi_follow_btn a,
576
+ #sb_instagram #sbi_load .sbi_load_btn{
577
+ transition: all 0.1s ease-in;
578
+ }
579
+ /* Hover state for default colors */
580
+ #sb_instagram #sbi_load .sbi_load_btn:hover{
581
+ outline: none;
582
+ box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.25);
583
+ }
584
+ #sb_instagram .sbi_follow_btn a:hover,
585
+ #sb_instagram .sbi_follow_btn a:focus{
586
+ outline: none;
587
+ box-shadow: inset 0 0 10px 20px #359dff;
588
+ }
589
+ /* If a custom color is applied then just use opacity for the hover effect */
590
+ #sb_instagram .sbi_follow_btn.sbi_custom a:hover,
591
+ #sb_instagram .sbi_follow_btn.sbi_custom a:focus,
592
+ #sb_instagram #sbi_load .sbi_load_btn.sbi_custom:hover{
593
+ box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.15);
594
+ }
595
+ /* Active state */
596
+ #sb_instagram .sbi_follow_btn a:active,
597
+ #sb_instagram #sbi_load .sbi_load_btn:active{
598
+ box-shadow: inset 0 0 10px 20px rgba(0,0,0,0.3);
599
+ }
600
+
601
+ #sb_instagram .sbi_follow_btn .fa,
602
+ #sb_instagram .sbi_follow_btn svg{
603
+ margin-bottom: -1px;
604
+ margin-right: 7px;
605
+ font-size: 15px;
606
+ }
607
+ #sb_instagram .sbi_follow_btn svg{
608
+ vertical-align: -.125em;
609
+ }
610
+ #sb_instagram #sbi_load .sbi_follow_btn{
611
+ margin-left: 5px;
612
+ }
613
+
614
+ /* Error messages */
615
+ #sb_instagram .sb_instagram_error{
616
+ width: 100%;
617
+ text-align: center;
618
+ line-height: 1.4;
619
+ }
620
+
621
+ /* Mod only error msgs */
622
+ #sbi_mod_error{
623
+ display: none;
624
+ border: 1px solid #ddd;
625
+ background: #eee;
626
+ color: #333;
627
+ margin: 10px 0 0;
628
+ padding: 10px 15px;
629
+ font-size: 13px;
630
+ text-align: center;
631
+ clear: both;
632
+
633
+ -moz-border-radius: 4px;
634
+ -webkit-border-radius: 4px;
635
+ border-radius: 4px;
636
+ }
637
+ #sbi_mod_error p{
638
+ padding: 5px 0 !important;
639
+ margin: 0 !important;
640
+ line-height: 1.3 !important;
641
+ }
642
+ #sbi_mod_error ol,
643
+ #sbi_mod_error ul{
644
+ padding: 5px 0 5px 20px !important;
645
+ margin: 0 !important;
646
+ }
647
+ #sbi_mod_error li{
648
+ padding: 1px 0 !important;
649
+ margin: 0 !important;
650
+ }
651
+ #sbi_mod_error span{
652
+ font-size: 12px;
653
+ }
654
+
655
+ /* Medium */
656
+ #sb_instagram.sbi_medium .sbi_playbtn,
657
+ #sb_instagram.sbi_medium .sbi_photo_wrap .svg-inline--fa.fa-play{
658
+ margin-top: -12px;
659
+ margin-left: -9px;
660
+ font-size: 23px;
661
+ }
662
+ #sb_instagram.sbi_medium .sbi_type_carousel .sbi_photo_wrap .fa-clone{
663
+ right: 8px;
664
+ top: 8px;
665
+ font-size: 18px;
666
+ }
667
+ /* Small */
668
+ #sb_instagram.sbi_small .sbi_playbtn,
669
+ #sb_instagram.sbi_small .sbi_photo_wrap .svg-inline--fa.fa-play{
670
+ margin-top: -9px;
671
+ margin-left: -7px;
672
+ font-size: 18px;
673
+ }
674
+ #sb_instagram.sbi_small .sbi_type_carousel .sbi_photo_wrap .fa-clone{
675
+ right: 5px;
676
+ top: 5px;
677
+ font-size: 12px;
678
+ }
679
+
680
+ /* Media queries */
681
+ @media all and (max-width: 640px){
682
+ /* Make 3-6 cols into 2 col */
683
+ #sb_instagram.sbi_col_3 #sbi_images .sbi_item,
684
+ #sb_instagram.sbi_col_4 #sbi_images .sbi_item,
685
+ #sb_instagram.sbi_col_5 #sbi_images .sbi_item,
686
+ #sb_instagram.sbi_col_6 #sbi_images .sbi_item{
687
+ width: 50%;
688
+ }
689
+ /* Make 7-10 cols into 4 col */
690
+ #sb_instagram.sbi_col_7 #sbi_images .sbi_item,
691
+ #sb_instagram.sbi_col_8 #sbi_images .sbi_item,
692
+ #sb_instagram.sbi_col_9 #sbi_images .sbi_item,
693
+ #sb_instagram.sbi_col_10 #sbi_images .sbi_item{
694
+ width: 25%;
695
+ }
696
+ /* On mobile make the min-width 100% */
697
+ #sb_instagram.sbi_width_resp{
698
+ width: 100% !important;
699
+ }
700
+ }
701
+ @media all and (max-width: 480px){
702
+ /* Make all cols into 1 col */
703
+ #sb_instagram.sbi_col_3 #sbi_images .sbi_item,
704
+ #sb_instagram.sbi_col_4 #sbi_images .sbi_item,
705
+ #sb_instagram.sbi_col_5 #sbi_images .sbi_item,
706
+ #sb_instagram.sbi_col_6 #sbi_images .sbi_item,
707
+ #sb_instagram.sbi_col_7 #sbi_images .sbi_item,
708
+ #sb_instagram.sbi_col_8 #sbi_images .sbi_item,
709
+ #sb_instagram.sbi_col_9 #sbi_images .sbi_item,
710
+ #sb_instagram.sbi_col_10 #sbi_images .sbi_item{
711
+ width: 100%;
712
+ }
713
+ }
714
+
715
+ /* NO JS */
716
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap{
717
+ box-sizing: border-box;
718
+ position: relative;
719
+ overflow: hidden;
720
+ }
721
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap:before {
722
+ content: "";
723
+ display: block;
724
+ padding-top: 100%;
725
+ z-index: -300;
726
+ }
727
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo {
728
+ position: absolute;
729
+ top: 0;
730
+ left: 0;
731
+ bottom: 0;
732
+ right: 0;
733
+ }
734
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item.sbi_transition {
735
+ opacity: 1;
736
+ max-height: 640px;
737
+ }
738
+ #sb_instagram.sbi_no_js .sbi_photo img,
739
+ #sb_instagram.sbi_no_js .sbi_load_btn{
740
+ display: none;
741
+ }
742
+ #sb_instagram #sbi_images .sbi_js_load_disabled .sbi_imgLiquid_ready.sbi_photo {
743
+ padding-bottom: 0 !important;
744
+ }
css/sb-instagram-2-1.min.css ADDED
@@ -0,0 +1 @@
 
1
+ #sb_instagram{width:100%;margin:0 auto;padding:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}#sb_instagram:after{content:"";display:table;clear:both}#sb_instagram.sbi_fixed_height{overflow:hidden;overflow-y:auto;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}#sb_instagram #sbi_images{width:100%;float:left;line-height:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}#sb_instagram #sbi_images .sbi_item{display:-moz-inline-stack;display:inline-block;float:left;vertical-align:top;zoom:1;max-height:1000px;padding:inherit!important;margin:0!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}#sb_instagram #sbi_images .sbi_item.sbi_transition{opacity:0;max-height:0}#sb_instagram.sbi_col_1 #sbi_images .sbi_item{width:100%}#sb_instagram.sbi_col_2 #sbi_images .sbi_item{width:50%}#sb_instagram.sbi_col_3 #sbi_images .sbi_item{width:33.33%}#sb_instagram.sbi_col_4 #sbi_images .sbi_item{width:25%}#sb_instagram.sbi_col_5 #sbi_images .sbi_item{width:20%}#sb_instagram.sbi_col_6 #sbi_images .sbi_item{width:16.66%}#sb_instagram.sbi_col_7 #sbi_images .sbi_item{width:14.28%}#sb_instagram.sbi_col_8 #sbi_images .sbi_item{width:12.5%}#sb_instagram.sbi_col_9 #sbi_images .sbi_item{width:11.11%}#sb_instagram.sbi_col_10 #sbi_images .sbi_item{width:10%}#sb_instagram.sbi_col_1.sbi_disable_mobile #sbi_images .sbi_item{width:100%}#sb_instagram.sbi_col_2.sbi_disable_mobile #sbi_images .sbi_item{width:50%}#sb_instagram.sbi_col_3.sbi_disable_mobile #sbi_images .sbi_item{width:33.33%}#sb_instagram.sbi_col_4.sbi_disable_mobile #sbi_images .sbi_item{width:25%}#sb_instagram.sbi_col_5.sbi_disable_mobile #sbi_images .sbi_item{width:20%}#sb_instagram.sbi_col_6.sbi_disable_mobile #sbi_images .sbi_item{width:16.66%}#sb_instagram.sbi_col_7.sbi_disable_mobile #sbi_images .sbi_item{width:14.28%}#sb_instagram.sbi_col_8.sbi_disable_mobile #sbi_images .sbi_item{width:12.5%}#sb_instagram.sbi_col_9.sbi_disable_mobile #sbi_images .sbi_item{width:11.11%}#sb_instagram.sbi_col_10.sbi_disable_mobile #sbi_images .sbi_item{width:10%}#sb_instagram .sbi_photo_wrap{position:relative}#sb_instagram .sbi_photo{display:block;text-decoration:none}#sb_instagram .sbi_photo img{width:100%;height:auto}#sb_instagram .sbi_no_js img{display:none}#sb_instagram a,#sb_instagram a:active,#sb_instagram a:focus,#sb_instagram a:hover{outline:0}#sb_instagram img{display:block;padding:0!important;margin:0!important;max-width:100%!important;opacity:1!important}#sb_instagram .sbi_link{display:none;position:absolute;bottom:0;right:0;width:100%;padding:10px 0;background:rgba(0,0,0,.5);text-align:center;color:#fff;font-size:12px;line-height:1.1}#sb_instagram .sbi_link a{padding:0 6px;text-decoration:none;color:#fff;font-size:12px;line-height:1.1;display:-moz-inline-stack;display:inline-block;vertical-align:top;zoom:1}#sb_instagram .sbi_link .sbi_lightbox_link{padding-bottom:5px}#sb_instagram .sbi_link a:focus,#sb_instagram .sbi_link a:hover{text-decoration:underline}#sb_instagram .sbi_photo_wrap:focus .sbi_link,#sb_instagram .sbi_photo_wrap:hover .sbi_link{display:block}#sb_instagram svg:not(:root).svg-inline--fa{height:1em;display:inline-block}#sb_instagram .sbi_type_carousel .sbi_playbtn,#sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play,#sb_instagram .sbi_type_video .sbi_playbtn,#sb_instagram .sbi_type_video .svg-inline--fa.fa-play,.sbi_type_carousel .fa-clone{display:block!important;position:absolute;z-index:1;color:#fff;color:rgba(255,255,255,.9);font-style:normal!important;text-shadow:0 0 8px rgba(0,0,0,.8)}#sb_instagram .sbi_type_carousel .sbi_playbtn,#sb_instagram .sbi_type_video .sbi_playbtn{z-index:2;top:50%;left:50%;margin-top:-24px;margin-left:-19px;padding:0;font-size:48px}#sb_instagram .sbi_type_carousel .fa-clone{right:12px;top:12px;font-size:24px;text-shadow:0 0 8px rgba(0,0,0,.3)}#sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play,#sb_instagram .sbi_type_video .svg-inline--fa.fa-play,.sbi_type_carousel svg.fa-clone{-webkit-filter:drop-shadow( 0 0 2px rgba(0,0,0,.4) );filter:drop-shadow( 0 0 2px rgba(0,0,0,.4) )}#sb_instagram .sbi_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:sbi-sk-scaleout 1s infinite ease-in-out;animation:sbi-sk-scaleout 1s infinite ease-in-out}#sb_instagram br{display:none}#sbi_load p{display:inline;padding:0;margin:0}#sb_instagram #sbi_load .sbi_loader{position:absolute;margin-top:-11px;background-color:#fff;opacity:1}@-webkit-keyframes sbi-sk-scaleout{0%{-webkit-transform:scale(0)}100%{-webkit-transform:scale(1);opacity:0}}@keyframes sbi-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}}#sb_instagram .fa-spin,#sbi_lightbox .fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}#sb_instagram .fa-pulse,#sbi_lightbox .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)}}.sbi-screenreader{text-indent:-9999px!important;display:block!important;width:0!important;height:0!important;line-height:0!important;text-align:left!important}#sb_instagram .sb_instagram_header{float:left;clear:both;margin:0 0 15px 0;padding:0;line-height:1.2;width:100%}#sb_instagram .sb_instagram_header a{float:left;display:block;text-decoration:none;transition:color .5s ease}@media all and (min-width:480px){#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img{width:80px;height:80px;border-radius:40px}#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img img{width:80px;height:80px;border-radius:40px}#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3{font-size:20px}#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio,#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info{font-size:14px}#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio,#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3{margin-left:95px!important;line-height:1.4}#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3{margin-right:-85px!important}#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info{margin-top:4px!important}#sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text.sbi_no_bio h3{padding-top:20px!important}#sb_instagram .sb_instagram_header.sbi_large .sbi_header_img{width:120px;height:120px;border-radius:60px}#sb_instagram .sb_instagram_header.sbi_large .sbi_header_img img{width:120px;height:120px;border-radius:60px}#sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3{font-size:28px}#sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio,#sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info{font-size:16px}#sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio,#sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,#sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3{margin-left:140px!important;line-height:1.5}#sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3{margin-right:-120px!important}#sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info{margin-top:12px!important}#sb_instagram .sb_instagram_header.sbi_large .sbi_header_text.sbi_no_bio h3{padding-top:32px!important}}#sb_instagram .sb_instagram_header .sbi_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}#sb_instagram .sb_instagram_header .sbi_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}#sb_instagram .sb_instagram_header .sbi_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)}#sb_instagram .sb_instagram_header .sbi_header_img_hover .sbi_new_logo{position:absolute;top:50%;left:50%;margin-top:-12px;margin-left:-12px;width:24px;height:24px;font-size:24px}#sb_instagram .sb_instagram_header .sbi_header_img_hover i{overflow:hidden;background:url(../img/small-logo.png) no-repeat 0 0}#sb_instagram .sb_instagram_header .sbi_header_img_hover{z-index:2;transition:opacity .4s ease-in-out}#sb_instagram .sb_instagram_header .sbi_fade_in{opacity:1;transition:opacity .2s ease-in-out}#sb_instagram .sb_instagram_header .sbi_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}#sb_instagram .sb_instagram_header a:focus .sbi_header_img_hover,#sb_instagram .sb_instagram_header a:hover .sbi_header_img_hover{opacity:1}#sb_instagram .sb_instagram_header .sbi_header_text{float:left;width:100%;padding-top:5px}#sb_instagram .sb_instagram_header a{text-decoration:none}#sb_instagram .sb_instagram_header .sbi_header_text .sbi_bio,#sb_instagram .sb_instagram_header .sbi_header_text h3{float:left;clear:both;width:auto;margin:0 0 0 60px!important;padding:0!important}#sb_instagram .sb_instagram_header h3{font-size:16px;line-height:1.3}#sb_instagram .sb_instagram_header p{font-size:13px;line-height:1.3;margin:0;padding:0}#sb_instagram p:empty{display:none}#sb_instagram .sb_instagram_header .sbi_header_text img.emoji{margin-right:3px!important}#sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio h3{padding-top:9px!important}#sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio .sbi_bio_info{clear:both}#sb_instagram #sbi_load{float:left;clear:both;width:100%;text-align:center}#sb_instagram #sbi_load .fa-spinner{display:none;position:absolute;top:50%;left:50%;margin:-8px 0 0 -7px;font-size:15px}#sb_instagram #sbi_load{opacity:1;transition:all .5s ease-in}#sb_instagram .sbi_load_btn .sbi_btn_text,#sb_instagram .sbi_load_btn .sbi_loader{opacity:1;transition:all .1s ease-in}#sb_instagram .sbi_hidden{opacity:0!important}#sb_instagram #sbi_load .sbi_load_btn,#sb_instagram .sbi_follow_btn a{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}#sb_instagram #sbi_load .sbi_load_btn{position:relative}#sb_instagram .sbi_follow_btn{display:-moz-inline-stack;display:inline-block;vertical-align:top;zoom:1;text-align:center}#sb_instagram .sbi_follow_btn.sbi_top{display:block;margin-bottom:5px}#sb_instagram .sbi_follow_btn a{background:#408bd1;color:#fff}#sb_instagram #sbi_load .sbi_load_btn,#sb_instagram .sbi_follow_btn a{transition:all .1s ease-in}#sb_instagram #sbi_load .sbi_load_btn:hover{outline:0;box-shadow:inset 0 0 20px 20px rgba(255,255,255,.25)}#sb_instagram .sbi_follow_btn a:focus,#sb_instagram .sbi_follow_btn a:hover{outline:0;box-shadow:inset 0 0 10px 20px #359dff}#sb_instagram #sbi_load .sbi_load_btn.sbi_custom:hover,#sb_instagram .sbi_follow_btn.sbi_custom a:focus,#sb_instagram .sbi_follow_btn.sbi_custom a:hover{box-shadow:inset 0 0 20px 20px rgba(255,255,255,.15)}#sb_instagram #sbi_load .sbi_load_btn:active,#sb_instagram .sbi_follow_btn a:active{box-shadow:inset 0 0 10px 20px rgba(0,0,0,.3)}#sb_instagram .sbi_follow_btn .fa,#sb_instagram .sbi_follow_btn svg{margin-bottom:-1px;margin-right:7px;font-size:15px}#sb_instagram .sbi_follow_btn svg{vertical-align:-.125em}#sb_instagram #sbi_load .sbi_follow_btn{margin-left:5px}#sb_instagram .sb_instagram_error{width:100%;text-align:center;line-height:1.4}#sbi_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}#sbi_mod_error p{padding:5px 0!important;margin:0!important;line-height:1.3!important}#sbi_mod_error ol,#sbi_mod_error ul{padding:5px 0 5px 20px!important;margin:0!important}#sbi_mod_error li{padding:1px 0!important;margin:0!important}#sbi_mod_error span{font-size:12px}#sb_instagram.sbi_medium .sbi_photo_wrap .svg-inline--fa.fa-play,#sb_instagram.sbi_medium .sbi_playbtn{margin-top:-12px;margin-left:-9px;font-size:23px}#sb_instagram.sbi_medium .sbi_type_carousel .sbi_photo_wrap .fa-clone{right:8px;top:8px;font-size:18px}#sb_instagram.sbi_small .sbi_photo_wrap .svg-inline--fa.fa-play,#sb_instagram.sbi_small .sbi_playbtn{margin-top:-9px;margin-left:-7px;font-size:18px}#sb_instagram.sbi_small .sbi_type_carousel .sbi_photo_wrap .fa-clone{right:5px;top:5px;font-size:12px}@media all and (max-width:640px){#sb_instagram.sbi_col_3 #sbi_images .sbi_item,#sb_instagram.sbi_col_4 #sbi_images .sbi_item,#sb_instagram.sbi_col_5 #sbi_images .sbi_item,#sb_instagram.sbi_col_6 #sbi_images .sbi_item{width:50%}#sb_instagram.sbi_col_10 #sbi_images .sbi_item,#sb_instagram.sbi_col_7 #sbi_images .sbi_item,#sb_instagram.sbi_col_8 #sbi_images .sbi_item,#sb_instagram.sbi_col_9 #sbi_images .sbi_item{width:25%}#sb_instagram.sbi_width_resp{width:100%!important}}@media all and (max-width:480px){#sb_instagram.sbi_col_10 #sbi_images .sbi_item,#sb_instagram.sbi_col_3 #sbi_images .sbi_item,#sb_instagram.sbi_col_4 #sbi_images .sbi_item,#sb_instagram.sbi_col_5 #sbi_images .sbi_item,#sb_instagram.sbi_col_6 #sbi_images .sbi_item,#sb_instagram.sbi_col_7 #sbi_images .sbi_item,#sb_instagram.sbi_col_8 #sbi_images .sbi_item,#sb_instagram.sbi_col_9 #sbi_images .sbi_item{width:100%}}#sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap{box-sizing:border-box;position:relative;overflow:hidden}#sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap:before{content:"";display:block;padding-top:100%;z-index:-300}#sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo{position:absolute;top:0;left:0;bottom:0;right:0}#sb_instagram.sbi_no_js #sbi_images .sbi_item.sbi_transition{opacity:1;max-height:640px}#sb_instagram.sbi_no_js .sbi_load_btn,#sb_instagram.sbi_no_js .sbi_photo img{display:none}#sb_instagram #sbi_images .sbi_js_load_disabled .sbi_imgLiquid_ready.sbi_photo{padding-bottom:0!important}
css/sb-instagram-2-2.css CHANGED
@@ -1,819 +1,819 @@
1
- /**************/
2
- /*** LAYOUT ***/
3
- /**************/
4
-
5
- /* Feed container */
6
- #sb_instagram {
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
- #sb_instagram:after{
15
- content: "";
16
- display: table;
17
- clear: both;
18
- }
19
-
20
- /*********************/
21
- /*** STYLE OPTIONS ***/
22
- /*********************/
23
- #sb_instagram.sbi_fixed_height{
24
- overflow: hidden;
25
- overflow-y: auto;
26
- -webkit-box-sizing: border-box;
27
- -moz-box-sizing: border-box;
28
- box-sizing: border-box;
29
- }
30
- #sb_instagram #sbi_images{
31
- width: 100%;
32
- float: left;
33
- line-height: 0;
34
-
35
- -webkit-box-sizing: border-box;
36
- -moz-box-sizing: border-box;
37
- box-sizing: border-box;
38
- }
39
- /* Remove header shadow/border */
40
- #sb_instagram .sbi_header_link {
41
- -webkit-box-shadow: none;
42
- box-shadow: none;
43
- }
44
- #sb_instagram .sbi_header_link:hover {
45
- border: none;
46
- }
47
-
48
- /* Items */
49
- #sb_instagram #sbi_images .sbi_item{
50
- display: -moz-inline-stack;
51
- display: inline-block;
52
- float: left;
53
- vertical-align: top;
54
- zoom: 1;
55
- *display: inline;
56
-
57
- max-height: 1000px;
58
- padding: inherit !important;
59
- margin: 0 !important;
60
- text-decoration: none;
61
- opacity: 1;
62
- overflow: hidden;
63
-
64
- -webkit-box-sizing: border-box;
65
- -moz-box-sizing: border-box;
66
- box-sizing: border-box;
67
-
68
- -webkit-transition: all 0.5s ease;
69
- -moz-transition: all 0.5s ease;
70
- -o-transition: all 0.5s ease;
71
- -ms-transition: all 0.5s ease;
72
- transition: all 0.5s ease;
73
- }
74
- /* Transition items in */
75
- #sb_instagram #sbi_images .sbi_item.sbi_transition{
76
- opacity: 0;
77
- max-height: 0;
78
- }
79
-
80
- /* Cols */
81
- #sb_instagram.sbi_col_1 #sbi_images .sbi_item{ width: 100%; }
82
- #sb_instagram.sbi_col_2 #sbi_images .sbi_item{ width: 50%; }
83
- #sb_instagram.sbi_col_3 #sbi_images .sbi_item{ width: 33.33%; }
84
- #sb_instagram.sbi_col_4 #sbi_images .sbi_item{ width: 25%; }
85
- #sb_instagram.sbi_col_5 #sbi_images .sbi_item{ width: 20%; }
86
- #sb_instagram.sbi_col_6 #sbi_images .sbi_item{ width: 16.66%; }
87
- #sb_instagram.sbi_col_7 #sbi_images .sbi_item{ width: 14.28%; }
88
- #sb_instagram.sbi_col_8 #sbi_images .sbi_item{ width: 12.5%; }
89
- #sb_instagram.sbi_col_9 #sbi_images .sbi_item{ width: 11.11%; }
90
- #sb_instagram.sbi_col_10 #sbi_images .sbi_item{ width: 10%; }
91
-
92
- /* Disable mobile layout */
93
- #sb_instagram.sbi_col_1.sbi_disable_mobile #sbi_images .sbi_item{ width: 100%; }
94
- #sb_instagram.sbi_col_2.sbi_disable_mobile #sbi_images .sbi_item{ width: 50%; }
95
- #sb_instagram.sbi_col_3.sbi_disable_mobile #sbi_images .sbi_item{ width: 33.33%; }
96
- #sb_instagram.sbi_col_4.sbi_disable_mobile #sbi_images .sbi_item{ width: 25%; }
97
- #sb_instagram.sbi_col_5.sbi_disable_mobile #sbi_images .sbi_item{ width: 20%; }
98
- #sb_instagram.sbi_col_6.sbi_disable_mobile #sbi_images .sbi_item{ width: 16.66%; }
99
- #sb_instagram.sbi_col_7.sbi_disable_mobile #sbi_images .sbi_item{ width: 14.28%; }
100
- #sb_instagram.sbi_col_8.sbi_disable_mobile #sbi_images .sbi_item{ width: 12.5%; }
101
- #sb_instagram.sbi_col_9.sbi_disable_mobile #sbi_images .sbi_item{ width: 11.11%; }
102
- #sb_instagram.sbi_col_10.sbi_disable_mobile #sbi_images .sbi_item{ width: 10%; }
103
-
104
- /* Photos */
105
- #sb_instagram .sbi_photo_wrap{
106
- position: relative;
107
- }
108
- #sb_instagram .sbi_photo{
109
- display: block;
110
- text-decoration: none;
111
- }
112
- #sb_instagram .sbi_photo img{
113
- width: 100%;
114
- height: auto;
115
- }
116
- #sb_instagram .sbi_no_js img{
117
- display: none;
118
- }
119
- #sb_instagram a,
120
- #sb_instagram a:hover,
121
- #sb_instagram a:focus,
122
- #sb_instagram a:active{
123
- outline: none;
124
- }
125
- #sb_instagram img{
126
- display: block;
127
- padding: 0 !important;
128
- margin: 0 !important;
129
- max-width: 100% !important;
130
- opacity: 1 !important;
131
- }
132
- #sb_instagram .sbi_link{
133
- display: none;
134
- position: absolute;
135
- bottom: 0;
136
- right: 0;
137
-
138
- width: 100%;
139
- padding: 10px 0;
140
- background: rgba(0,0,0,0.5);
141
- text-align: center;
142
- color: #fff;
143
- font-size: 12px;
144
- line-height: 1.1;
145
- }
146
- #sb_instagram .sbi_link a{
147
- padding: 0 6px;
148
- text-decoration: none;
149
- color: #fff;
150
- font-size: 12px;
151
- line-height: 1.1;
152
-
153
- display: -moz-inline-stack;
154
- display: inline-block;
155
- vertical-align: top;
156
- zoom: 1;
157
- *display: inline;
158
- }
159
- #sb_instagram .sbi_link .sbi_lightbox_link{
160
- padding-bottom: 5px;
161
- }
162
- #sb_instagram .sbi_link a:hover,
163
- #sb_instagram .sbi_link a:focus{
164
- text-decoration: underline;
165
- }
166
- #sb_instagram .sbi_photo_wrap:hover .sbi_link,
167
- #sb_instagram .sbi_photo_wrap:focus .sbi_link{
168
- display: block;
169
- }
170
-
171
- /* Videos */
172
- #sb_instagram svg:not(:root).svg-inline--fa {
173
- height: 1em;
174
- display: inline-block;
175
- }
176
-
177
- #sb_instagram .sbi_type_video .sbi_playbtn,
178
- #sb_instagram .sbi_type_carousel .sbi_playbtn,
179
- .sbi_type_carousel .fa-clone,
180
- #sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play,
181
- #sb_instagram .sbi_type_video .svg-inline--fa.fa-play{
182
- display: block !important;
183
- position: absolute;
184
- z-index: 1;
185
-
186
- color: #fff;
187
- color: rgba(255,255,255,0.9);
188
- font-style: normal !important;
189
- text-shadow: 0 0 8px rgba(0,0,0,0.8);
190
- }
191
- #sb_instagram .sbi_type_video .sbi_playbtn,
192
- #sb_instagram .sbi_type_carousel .sbi_playbtn {
193
- z-index: 2;
194
- top: 50%;
195
- left: 50%;
196
- margin-top: -24px;
197
- margin-left: -19px;
198
- padding: 0;
199
- font-size: 48px;
200
- }
201
- #sb_instagram .sbi_type_carousel .fa-clone{
202
- right: 12px;
203
- top: 12px;
204
- font-size: 24px;
205
- text-shadow: 0 0 8px rgba(0,0,0,0.3);
206
- }
207
- .sbi_type_carousel svg.fa-clone,
208
- #sb_instagram .sbi_type_video .svg-inline--fa.fa-play,
209
- #sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play{
210
- -webkit-filter: drop-shadow( 0px 0px 2px rgba(0,0,0,.4) );
211
- filter: drop-shadow( 0px 0px 2px rgba(0,0,0,.4) );
212
- }
213
-
214
- /* Loader */
215
- #sb_instagram .sbi_loader{
216
- width: 20px;
217
- height: 20px;
218
-
219
- position: relative;
220
- top: 50%;
221
- left: 50%;
222
- margin: -10px 0 0 -10px;
223
- background-color: #000;
224
- background-color: rgba(0,0,0,0.5);
225
-
226
- border-radius: 100%;
227
- -webkit-animation: sbi-sk-scaleout 1.0s infinite ease-in-out;
228
- animation: sbi-sk-scaleout 1.0s infinite ease-in-out;
229
- }
230
- #sb_instagram br {
231
- display: none;
232
- }
233
- #sbi_load p {
234
- display: inline;
235
- padding: 0;
236
- margin: 0;
237
- }
238
- /* Loader in button */
239
- #sb_instagram #sbi_load .sbi_loader{
240
- position: absolute;
241
- margin-top: -11px;
242
- background-color: #fff;
243
- opacity: 1;
244
- }
245
- @-webkit-keyframes sbi-sk-scaleout {
246
- 0% { -webkit-transform: scale(0) }
247
- 100% {
248
- -webkit-transform: scale(1.0);
249
- opacity: 0;
250
- }
251
- }
252
- @keyframes sbi-sk-scaleout {
253
- 0% {
254
- -webkit-transform: scale(0);
255
- -ms-transform: scale(0);
256
- transform: scale(0);
257
- } 100% {
258
- -webkit-transform: scale(1.0);
259
- -ms-transform: scale(1.0);
260
- transform: scale(1.0);
261
- opacity: 0;
262
- }
263
- }
264
-
265
- #sb_instagram .fa-spin,
266
- #sbi_lightbox .fa-spin{
267
- -webkit-animation: fa-spin 2s infinite linear;
268
- animation: fa-spin 2s infinite linear
269
- }
270
-
271
- #sb_instagram .fa-pulse,
272
- #sbi_lightbox .fa-pulse{
273
- -webkit-animation: fa-spin 1s infinite steps(8);
274
- animation: fa-spin 1s infinite steps(8)
275
- }
276
-
277
- @-webkit-keyframes fa-spin {
278
- 0% {
279
- -webkit-transform: rotate(0deg);
280
- transform: rotate(0deg)
281
- }
282
- 100% {
283
- -webkit-transform: rotate(359deg);
284
- transform: rotate(359deg)
285
- }
286
- }
287
-
288
- @keyframes fa-spin {
289
- 0% {
290
- -webkit-transform: rotate(0deg);
291
- transform: rotate(0deg)
292
- }
293
- 100% {
294
- -webkit-transform: rotate(359deg);
295
- transform: rotate(359deg)
296
- }
297
- }
298
- /* Screen reader */
299
- .sbi-screenreader{text-indent: -9999px !important;display: block !important;width: 0 !important;height: 0 !important;line-height: 0 !important;text-align: left !important; }
300
-
301
- /* HEADER */
302
- #sb_instagram .sb_instagram_header{
303
- float: left;
304
- clear: both;
305
- margin: 0 0 15px 0;
306
- padding: 0;
307
- line-height: 1.2;
308
- width: 100%;
309
- }
310
- #sb_instagram .sb_instagram_header a{
311
- float: left;
312
- display: block;
313
- /*width: 100%;*/
314
- min-width: 100%\9;
315
- text-decoration: none;
316
- transition: color 0.5s ease;
317
- }
318
- .sbi_no_avatar .sbi_header_img{
319
- background: #333;
320
- color: #fff;
321
- width: 50px;
322
- height: 50px;
323
- position: relative;
324
- }
325
- .sbi_no_avatar .sbi_header_hashtag_icon {
326
- display: block;
327
- color: #fff;
328
- opacity: .9;
329
- -webkit-transition: background .6s linear,color .6s linear;
330
- -moz-transition: background .6s linear,color .6s linear;
331
- -ms-transition: background .6s linear,color .6s linear;
332
- -o-transition: background .6s linear,color .6s linear;
333
- transition: background .6s linear,color .6s linear
334
- }
335
-
336
- .sbi_no_avatar:hover .sbi_header_hashtag_icon {
337
- display: block;
338
- opacity: 1;
339
- -webkit-transition: background .2s linear,color .2s linear;
340
- -moz-transition: background .2s linear,color .2s linear;
341
- -ms-transition: background .2s linear,color .2s linear;
342
- -o-transition: background .2s linear,color .2s linear;
343
- transition: background .2s linear,color .2s linear
344
- }
345
- /** Medium Header */
346
- /* Only use medium & large headers on devices above 480px */
347
- @media all and (min-width: 480px){
348
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img {
349
- width: 80px;
350
- height: 80px;
351
- border-radius: 40px;
352
- }
353
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img img {
354
- width: 80px;
355
- height: 80px;
356
- border-radius: 40px;
357
- }
358
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3 {
359
- font-size: 20px;
360
- }
361
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,
362
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio{
363
- font-size: 14px;
364
- }
365
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3,
366
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,
367
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio{
368
- margin-left: 95px !important;
369
- line-height: 1.4
370
- }
371
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3{
372
- margin-right: -85px !important;
373
- }
374
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info{
375
- margin-top: 4px !important;
376
- }
377
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text.sbi_no_bio h3{
378
- padding-top: 20px !important;
379
- }
380
- /** Large Header */
381
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_img {
382
- width: 120px;
383
- height: 120px;
384
- border-radius: 60px;
385
- }
386
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_img img {
387
- width: 120px;
388
- height: 120px;
389
- border-radius: 60px;
390
- }
391
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3 {
392
- font-size: 28px;
393
- }
394
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,
395
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio{
396
- font-size: 16px;
397
- }
398
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3,
399
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,
400
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio{
401
- margin-left: 140px !important;
402
- line-height: 1.5;
403
- }
404
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3{
405
- margin-right: -120px !important;
406
- }
407
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info{
408
- margin-top: 12px !important;
409
- }
410
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text.sbi_no_bio h3{
411
- padding-top: 32px !important;
412
- }
413
- }
414
-
415
- /* Header profile pic */
416
- #sb_instagram .sb_instagram_header .sbi_header_img{
417
- float: left;
418
- position: relative;
419
- width: 50px;
420
- margin: 0 0 0 -100% !important;
421
- overflow: hidden;
422
-
423
- -moz-border-radius: 40px;
424
- -webkit-border-radius: 40px;
425
- border-radius: 40px;
426
- }
427
- #sb_instagram .sb_instagram_header .sbi_header_img img{
428
- float: left;
429
- margin: 0 !important;
430
- padding: 0 !important;
431
- border: none !important;
432
-
433
- -moz-border-radius: 40px;
434
- -webkit-border-radius: 40px;
435
- border-radius: 40px;
436
- }
437
- /* Profile pic hover */
438
- /* Profile pic hover */
439
- #sb_instagram .sb_instagram_header .sbi_header_img_hover{
440
- opacity: 0;
441
- position: absolute;
442
- width: 100%;
443
- top: 0;
444
- bottom: 0;
445
- left: 0;
446
- text-align: center;
447
- color: #fff;
448
- background: rgba(0,0,0,0.75);
449
- }
450
-
451
- #sb_instagram .sb_instagram_header .sbi_header_img_hover .sbi_new_logo,
452
- #sb_instagram .sb_instagram_header .sbi_header_hashtag_icon .sbi_new_logo{
453
- position: absolute;
454
- top: 50%;
455
- left: 50%;
456
- margin-top: -12px;
457
- margin-left: -12px;
458
- width: 24px;
459
- height: 24px;
460
- font-size: 24px;
461
- }
462
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_hashtag_icon .sbi_new_logo,
463
- .sb_instagram_header.sbi_medium .sbi_header_hashtag_icon .sbi_new_logo{
464
- margin-top: -18px;
465
- margin-left: -18px;
466
- width: 36px;
467
- height: 36px;
468
- font-size: 36px
469
- }
470
-
471
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_hashtag_icon .sbi_new_logo,
472
- .sb_instagram_header.sbi_large .sbi_header_hashtag_icon .sbi_new_logo {
473
- margin-top: -24px;
474
- margin-left: -24px;
475
- width: 48px;
476
- height: 48px;
477
- font-size: 48px
478
- }
479
- #sb_instagram .sb_instagram_header .sbi_header_img_hover i {
480
- overflow: hidden;
481
- background: url('../img/small-logo.png') no-repeat 0 0;
482
- }
483
- #sb_instagram .sb_instagram_header .sbi_header_img_hover{
484
- z-index: 2;
485
- transition: opacity 0.4s ease-in-out;
486
- }
487
- #sb_instagram .sb_instagram_header .sbi_fade_in{
488
- opacity: 1;
489
- transition: opacity 0.2s ease-in-out;
490
- }
491
- #sb_instagram .sb_instagram_header .sbi_header_img_hover{
492
- position: absolute;
493
- width: 100%;
494
- top: 0;
495
- bottom: 0;
496
- left: 0;
497
- text-align: center;
498
- color: #fff;
499
- background: rgba(0,0,0,0.75);
500
-
501
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
502
- filter: alpha(opacity=0);
503
- -moz-opacity: 0;
504
- -khtml-opacity: 0;
505
- opacity: 0;
506
- border-radius: 40px;
507
- transition: opacity 0.2s;
508
- }
509
- /* Fade the Instagram icon in when hovering on the header */
510
- #sb_instagram .sb_instagram_header a:hover .sbi_header_img_hover,
511
- #sb_instagram .sb_instagram_header a:focus .sbi_header_img_hover{
512
- opacity: 1;
513
- }
514
- /* Header text */
515
- #sb_instagram .sb_instagram_header .sbi_header_text{
516
- float: left;
517
- width: 100%;
518
- padding-top: 5px;
519
- }
520
- #sb_instagram .sb_instagram_header a{
521
- text-decoration: none;
522
- }
523
- #sb_instagram .sb_instagram_header .sbi_header_text .sbi_bio,
524
- #sb_instagram .sb_instagram_header .sbi_header_text h3{
525
- float: left;
526
- clear: both;
527
- width: auto;
528
- margin: 0 0 0 60px !important;
529
- padding: 0 !important;
530
- }
531
- #sb_instagram .sb_instagram_header h3{
532
- font-size: 16px;
533
- line-height: 1.3;
534
- }
535
- #sb_instagram .sb_instagram_header p{
536
- font-size: 13px;
537
- line-height: 1.3;
538
- margin: 0;
539
- padding: 0;
540
- }
541
- #sb_instagram p:empty { display: none; }
542
- #sb_instagram .sb_instagram_header .sbi_header_text img.emoji{
543
- margin-right: 3px !important;
544
- }
545
-
546
- /* No bio */
547
- #sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio h3{
548
- padding-top: 9px !important;
549
- }
550
- #sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio .sbi_bio_info{
551
- clear: both;
552
- }
553
-
554
-
555
- /* Buttons */
556
- #sb_instagram #sbi_load{
557
- float: left;
558
- clear: both;
559
- width: 100%;
560
- text-align: center;
561
- }
562
- #sb_instagram #sbi_load .fa-spinner{
563
- display: none;
564
- position: absolute;
565
- top: 50%;
566
- left: 50%;
567
- margin: -8px 0 0 -7px;
568
- font-size: 15px;
569
- }
570
- #sb_instagram #sbi_load{
571
- opacity: 1;
572
- transition: all 0.5s ease-in;
573
- }
574
- #sb_instagram .sbi_load_btn .sbi_btn_text, #sb_instagram .sbi_load_btn .sbi_loader{
575
- opacity: 1;
576
- transition: all 0.1s ease-in;
577
- }
578
- #sb_instagram .sbi_hidden{
579
- opacity: 0 !important;
580
- }
581
- #sb_instagram #sbi_load .sbi_load_btn,
582
- #sb_instagram .sbi_follow_btn a{
583
- display: -moz-inline-stack;
584
- display: inline-block;
585
- vertical-align: top;
586
- zoom: 1;
587
- *display: inline;
588
-
589
- padding: 7px 14px;
590
- margin: 5px auto 0 auto;
591
- background: #333;
592
- color: #eee;
593
- border: none;
594
- color: #fff;
595
- text-decoration: none;
596
- font-size: 13px;
597
- line-height: 1.5;
598
-
599
- -moz-border-radius: 4px;
600
- -webkit-border-radius: 4px;
601
- border-radius: 4px;
602
-
603
- -webkit-box-sizing: border-box;
604
- -moz-box-sizing: border-box;
605
- box-sizing: border-box;
606
- }
607
- #sb_instagram #sbi_load .sbi_load_btn {
608
- position: relative;
609
- }
610
- /* Follow button */
611
- #sb_instagram .sbi_follow_btn{
612
- display: -moz-inline-stack;
613
- display: inline-block;
614
- vertical-align: top;
615
- zoom: 1;
616
- *display: inline;
617
- text-align: center;
618
- }
619
- #sb_instagram .sbi_follow_btn.sbi_top{
620
- display: block;
621
- margin-bottom: 5px;
622
- }
623
- #sb_instagram .sbi_follow_btn a{
624
- background: #408bd1;
625
- color: #fff;
626
- }
627
- #sb_instagram .sbi_follow_btn a,
628
- #sb_instagram .sbi_follow_btn a,
629
- #sb_instagram #sbi_load .sbi_load_btn{
630
- transition: all 0.1s ease-in;
631
- }
632
- /* Hover state for default colors */
633
- #sb_instagram #sbi_load .sbi_load_btn:hover{
634
- outline: none;
635
- box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.25);
636
- }
637
- #sb_instagram .sbi_follow_btn a:hover,
638
- #sb_instagram .sbi_follow_btn a:focus{
639
- outline: none;
640
- box-shadow: inset 0 0 10px 20px #359dff;
641
- }
642
- /* If a custom color is applied then just use opacity for the hover effect */
643
- #sb_instagram .sbi_follow_btn.sbi_custom a:hover,
644
- #sb_instagram .sbi_follow_btn.sbi_custom a:focus,
645
- #sb_instagram #sbi_load .sbi_load_btn.sbi_custom:hover{
646
- box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.15);
647
- }
648
- /* Active state */
649
- #sb_instagram .sbi_follow_btn a:active,
650
- #sb_instagram #sbi_load .sbi_load_btn:active{
651
- box-shadow: inset 0 0 10px 20px rgba(0,0,0,0.3);
652
- }
653
-
654
- #sb_instagram .sbi_follow_btn .fa,
655
- #sb_instagram .sbi_follow_btn svg{
656
- margin-bottom: -1px;
657
- margin-right: 7px;
658
- font-size: 15px;
659
- }
660
- #sb_instagram .sbi_follow_btn svg{
661
- vertical-align: -.125em;
662
- }
663
- #sb_instagram #sbi_load .sbi_follow_btn{
664
- margin-left: 5px;
665
- }
666
-
667
- /* Error messages */
668
- #sb_instagram .sb_instagram_error{
669
- width: 100%;
670
- text-align: center;
671
- line-height: 1.4;
672
- }
673
-
674
- /* Mod only error msgs */
675
- #sbi_mod_error{
676
- display: none;
677
- border: 1px solid #ddd;
678
- background: #eee;
679
- color: #333;
680
- margin: 10px 0 0;
681
- padding: 10px 15px;
682
- font-size: 13px;
683
- text-align: center;
684
- clear: both;
685
-
686
- -moz-border-radius: 4px;
687
- -webkit-border-radius: 4px;
688
- border-radius: 4px;
689
- }
690
- #sbi_mod_error br {
691
- display: initial !important;
692
- }
693
- #sbi_mod_error p{
694
- padding: 5px 0 !important;
695
- margin: 0 !important;
696
- line-height: 1.3 !important;
697
- }
698
- #sbi_mod_error ol,
699
- #sbi_mod_error ul{
700
- padding: 5px 0 5px 20px !important;
701
- margin: 0 !important;
702
- }
703
- #sbi_mod_error li{
704
- padding: 1px 0 !important;
705
- margin: 0 !important;
706
- }
707
- #sbi_mod_error span{
708
- font-size: 12px;
709
- }
710
-
711
- /* Medium */
712
- #sb_instagram.sbi_medium .sbi_playbtn,
713
- #sb_instagram.sbi_medium .sbi_photo_wrap .svg-inline--fa.fa-play{
714
- margin-top: -12px;
715
- margin-left: -9px;
716
- font-size: 23px;
717
- }
718
- #sb_instagram.sbi_medium .sbi_type_carousel .sbi_photo_wrap .fa-clone{
719
- right: 8px;
720
- top: 8px;
721
- font-size: 18px;
722
- }
723
- /* Small */
724
- #sb_instagram.sbi_small .sbi_playbtn,
725
- #sb_instagram.sbi_small .sbi_photo_wrap .svg-inline--fa.fa-play{
726
- margin-top: -9px;
727
- margin-left: -7px;
728
- font-size: 18px;
729
- }
730
- #sb_instagram.sbi_small .sbi_type_carousel .sbi_photo_wrap .fa-clone{
731
- right: 5px;
732
- top: 5px;
733
- font-size: 12px;
734
- }
735
-
736
- /* Media queries */
737
- @media all and (max-width: 640px){
738
- /* Make 3-6 cols into 2 col */
739
- #sb_instagram.sbi_col_3 #sbi_images .sbi_item,
740
- #sb_instagram.sbi_col_4 #sbi_images .sbi_item,
741
- #sb_instagram.sbi_col_5 #sbi_images .sbi_item,
742
- #sb_instagram.sbi_col_6 #sbi_images .sbi_item{
743
- width: 50%;
744
- }
745
- /* Make 7-10 cols into 4 col */
746
- #sb_instagram.sbi_col_7 #sbi_images .sbi_item,
747
- #sb_instagram.sbi_col_8 #sbi_images .sbi_item,
748
- #sb_instagram.sbi_col_9 #sbi_images .sbi_item,
749
- #sb_instagram.sbi_col_10 #sbi_images .sbi_item{
750
- width: 25%;
751
- }
752
- /* On mobile make the min-width 100% */
753
- #sb_instagram.sbi_width_resp{
754
- width: 100% !important;
755
- }
756
- }
757
- @media all and (max-width: 480px){
758
- /* Make all cols into 1 col */
759
- #sb_instagram.sbi_col_3 #sbi_images .sbi_item,
760
- #sb_instagram.sbi_col_4 #sbi_images .sbi_item,
761
- #sb_instagram.sbi_col_5 #sbi_images .sbi_item,
762
- #sb_instagram.sbi_col_6 #sbi_images .sbi_item,
763
- #sb_instagram.sbi_col_7 #sbi_images .sbi_item,
764
- #sb_instagram.sbi_col_8 #sbi_images .sbi_item,
765
- #sb_instagram.sbi_col_9 #sbi_images .sbi_item,
766
- #sb_instagram.sbi_col_10 #sbi_images .sbi_item{
767
- width: 100%;
768
- }
769
- }
770
-
771
- /* NO JS */
772
- #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap{
773
- box-sizing: border-box;
774
- position: relative;
775
- overflow: hidden;
776
- }
777
- #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap:before {
778
- content: "";
779
- display: block;
780
- padding-top: 100%;
781
- z-index: -300;
782
- }
783
- #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo {
784
- position: absolute;
785
- top: 0;
786
- left: 0;
787
- bottom: 0;
788
- right: 0;
789
- }
790
- #sb_instagram.sbi_no_js #sbi_images .sbi_item.sbi_transition {
791
- opacity: 1;
792
- max-height: 640px;
793
- }
794
- #sb_instagram.sbi_no_js .sbi_photo img,
795
- #sb_instagram.sbi_no_js .sbi_load_btn{
796
- display: none;
797
- }
798
- #sb_instagram #sbi_images .sbi_js_load_disabled .sbi_imgLiquid_ready.sbi_photo {
799
- padding-bottom: 0 !important;
800
- }
801
- #sb_instagram #sbi_mod_error .sb_frontend_btn {
802
- display: inline-block;
803
- padding: 6px 10px;
804
- background: #ddd;
805
- background: rgba(0,0,0,.1);
806
- text-decoration: none;
807
- border-radius: 5px;
808
- margin-top: 10px;
809
- color: #444
810
- }
811
-
812
- #sb_instagram #sbi_mod_error .sb_frontend_btn:hover {
813
- background: #ccc;
814
- background: rgba(0,0,0,.15)
815
- }
816
-
817
- #sb_instagram #sbi_mod_error .sb_frontend_btn .fa {
818
- margin-right: 2px
819
  }
1
+ /**************/
2
+ /*** LAYOUT ***/
3
+ /**************/
4
+
5
+ /* Feed container */
6
+ #sb_instagram {
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
+ #sb_instagram:after{
15
+ content: "";
16
+ display: table;
17
+ clear: both;
18
+ }
19
+
20
+ /*********************/
21
+ /*** STYLE OPTIONS ***/
22
+ /*********************/
23
+ #sb_instagram.sbi_fixed_height{
24
+ overflow: hidden;
25
+ overflow-y: auto;
26
+ -webkit-box-sizing: border-box;
27
+ -moz-box-sizing: border-box;
28
+ box-sizing: border-box;
29
+ }
30
+ #sb_instagram #sbi_images{
31
+ width: 100%;
32
+ float: left;
33
+ line-height: 0;
34
+
35
+ -webkit-box-sizing: border-box;
36
+ -moz-box-sizing: border-box;
37
+ box-sizing: border-box;
38
+ }
39
+ /* Remove header shadow/border */
40
+ #sb_instagram .sbi_header_link {
41
+ -webkit-box-shadow: none;
42
+ box-shadow: none;
43
+ }
44
+ #sb_instagram .sbi_header_link:hover {
45
+ border: none;
46
+ }
47
+
48
+ /* Items */
49
+ #sb_instagram #sbi_images .sbi_item{
50
+ display: -moz-inline-stack;
51
+ display: inline-block;
52
+ float: left;
53
+ vertical-align: top;
54
+ zoom: 1;
55
+ *display: inline;
56
+
57
+ max-height: 1000px;
58
+ padding: inherit !important;
59
+ margin: 0 !important;
60
+ text-decoration: none;
61
+ opacity: 1;
62
+ overflow: hidden;
63
+
64
+ -webkit-box-sizing: border-box;
65
+ -moz-box-sizing: border-box;
66
+ box-sizing: border-box;
67
+
68
+ -webkit-transition: all 0.5s ease;
69
+ -moz-transition: all 0.5s ease;
70
+ -o-transition: all 0.5s ease;
71
+ -ms-transition: all 0.5s ease;
72
+ transition: all 0.5s ease;
73
+ }
74
+ /* Transition items in */
75
+ #sb_instagram #sbi_images .sbi_item.sbi_transition{
76
+ opacity: 0;
77
+ max-height: 0;
78
+ }
79
+
80
+ /* Cols */
81
+ #sb_instagram.sbi_col_1 #sbi_images .sbi_item{ width: 100%; }
82
+ #sb_instagram.sbi_col_2 #sbi_images .sbi_item{ width: 50%; }
83
+ #sb_instagram.sbi_col_3 #sbi_images .sbi_item{ width: 33.33%; }
84
+ #sb_instagram.sbi_col_4 #sbi_images .sbi_item{ width: 25%; }
85
+ #sb_instagram.sbi_col_5 #sbi_images .sbi_item{ width: 20%; }
86
+ #sb_instagram.sbi_col_6 #sbi_images .sbi_item{ width: 16.66%; }
87
+ #sb_instagram.sbi_col_7 #sbi_images .sbi_item{ width: 14.28%; }
88
+ #sb_instagram.sbi_col_8 #sbi_images .sbi_item{ width: 12.5%; }
89
+ #sb_instagram.sbi_col_9 #sbi_images .sbi_item{ width: 11.11%; }
90
+ #sb_instagram.sbi_col_10 #sbi_images .sbi_item{ width: 10%; }
91
+
92
+ /* Disable mobile layout */
93
+ #sb_instagram.sbi_col_1.sbi_disable_mobile #sbi_images .sbi_item{ width: 100%; }
94
+ #sb_instagram.sbi_col_2.sbi_disable_mobile #sbi_images .sbi_item{ width: 50%; }
95
+ #sb_instagram.sbi_col_3.sbi_disable_mobile #sbi_images .sbi_item{ width: 33.33%; }
96
+ #sb_instagram.sbi_col_4.sbi_disable_mobile #sbi_images .sbi_item{ width: 25%; }
97
+ #sb_instagram.sbi_col_5.sbi_disable_mobile #sbi_images .sbi_item{ width: 20%; }
98
+ #sb_instagram.sbi_col_6.sbi_disable_mobile #sbi_images .sbi_item{ width: 16.66%; }
99
+ #sb_instagram.sbi_col_7.sbi_disable_mobile #sbi_images .sbi_item{ width: 14.28%; }
100
+ #sb_instagram.sbi_col_8.sbi_disable_mobile #sbi_images .sbi_item{ width: 12.5%; }
101
+ #sb_instagram.sbi_col_9.sbi_disable_mobile #sbi_images .sbi_item{ width: 11.11%; }
102
+ #sb_instagram.sbi_col_10.sbi_disable_mobile #sbi_images .sbi_item{ width: 10%; }
103
+
104
+ /* Photos */
105
+ #sb_instagram .sbi_photo_wrap{
106
+ position: relative;
107
+ }
108
+ #sb_instagram .sbi_photo{
109
+ display: block;
110
+ text-decoration: none;
111
+ }
112
+ #sb_instagram .sbi_photo img{
113
+ width: 100%;
114
+ height: auto;
115
+ }
116
+ #sb_instagram .sbi_no_js img{
117
+ display: none;
118
+ }
119
+ #sb_instagram a,
120
+ #sb_instagram a:hover,
121
+ #sb_instagram a:focus,
122
+ #sb_instagram a:active{
123
+ outline: none;
124
+ }
125
+ #sb_instagram img{
126
+ display: block;
127
+ padding: 0 !important;
128
+ margin: 0 !important;
129
+ max-width: 100% !important;
130
+ opacity: 1 !important;
131
+ }
132
+ #sb_instagram .sbi_link{
133
+ display: none;
134
+ position: absolute;
135
+ bottom: 0;
136
+ right: 0;
137
+
138
+ width: 100%;
139
+ padding: 10px 0;
140
+ background: rgba(0,0,0,0.5);
141
+ text-align: center;
142
+ color: #fff;
143
+ font-size: 12px;
144
+ line-height: 1.1;
145
+ }
146
+ #sb_instagram .sbi_link a{
147
+ padding: 0 6px;
148
+ text-decoration: none;
149
+ color: #fff;
150
+ font-size: 12px;
151
+ line-height: 1.1;
152
+
153
+ display: -moz-inline-stack;
154
+ display: inline-block;
155
+ vertical-align: top;
156
+ zoom: 1;
157
+ *display: inline;
158
+ }
159
+ #sb_instagram .sbi_link .sbi_lightbox_link{
160
+ padding-bottom: 5px;
161
+ }
162
+ #sb_instagram .sbi_link a:hover,
163
+ #sb_instagram .sbi_link a:focus{
164
+ text-decoration: underline;
165
+ }
166
+ #sb_instagram .sbi_photo_wrap:hover .sbi_link,
167
+ #sb_instagram .sbi_photo_wrap:focus .sbi_link{
168
+ display: block;
169
+ }
170
+
171
+ /* Videos */
172
+ #sb_instagram svg:not(:root).svg-inline--fa {
173
+ height: 1em;
174
+ display: inline-block;
175
+ }
176
+
177
+ #sb_instagram .sbi_type_video .sbi_playbtn,
178
+ #sb_instagram .sbi_type_carousel .sbi_playbtn,
179
+ .sbi_type_carousel .fa-clone,
180
+ #sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play,
181
+ #sb_instagram .sbi_type_video .svg-inline--fa.fa-play{
182
+ display: block !important;
183
+ position: absolute;
184
+ z-index: 1;
185
+
186
+ color: #fff;
187
+ color: rgba(255,255,255,0.9);
188
+ font-style: normal !important;
189
+ text-shadow: 0 0 8px rgba(0,0,0,0.8);
190
+ }
191
+ #sb_instagram .sbi_type_video .sbi_playbtn,
192
+ #sb_instagram .sbi_type_carousel .sbi_playbtn {
193
+ z-index: 2;
194
+ top: 50%;
195
+ left: 50%;
196
+ margin-top: -24px;
197
+ margin-left: -19px;
198
+ padding: 0;
199
+ font-size: 48px;
200
+ }
201
+ #sb_instagram .sbi_type_carousel .fa-clone{
202
+ right: 12px;
203
+ top: 12px;
204
+ font-size: 24px;
205
+ text-shadow: 0 0 8px rgba(0,0,0,0.3);
206
+ }
207
+ .sbi_type_carousel svg.fa-clone,
208
+ #sb_instagram .sbi_type_video .svg-inline--fa.fa-play,
209
+ #sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play{
210
+ -webkit-filter: drop-shadow( 0px 0px 2px rgba(0,0,0,.4) );
211
+ filter: drop-shadow( 0px 0px 2px rgba(0,0,0,.4) );
212
+ }
213
+
214
+ /* Loader */
215
+ #sb_instagram .sbi_loader{
216
+ width: 20px;
217
+ height: 20px;
218
+
219
+ position: relative;
220
+ top: 50%;
221
+ left: 50%;
222
+ margin: -10px 0 0 -10px;
223
+ background-color: #000;
224
+ background-color: rgba(0,0,0,0.5);
225
+
226
+ border-radius: 100%;
227
+ -webkit-animation: sbi-sk-scaleout 1.0s infinite ease-in-out;
228
+ animation: sbi-sk-scaleout 1.0s infinite ease-in-out;
229
+ }
230
+ #sb_instagram br {
231
+ display: none;
232
+ }
233
+ #sbi_load p {
234
+ display: inline;
235
+ padding: 0;
236
+ margin: 0;
237
+ }
238
+ /* Loader in button */
239
+ #sb_instagram #sbi_load .sbi_loader{
240
+ position: absolute;
241
+ margin-top: -11px;
242
+ background-color: #fff;
243
+ opacity: 1;
244
+ }
245
+ @-webkit-keyframes sbi-sk-scaleout {
246
+ 0% { -webkit-transform: scale(0) }
247
+ 100% {
248
+ -webkit-transform: scale(1.0);
249
+ opacity: 0;
250
+ }
251
+ }
252
+ @keyframes sbi-sk-scaleout {
253
+ 0% {
254
+ -webkit-transform: scale(0);
255
+ -ms-transform: scale(0);
256
+ transform: scale(0);
257
+ } 100% {
258
+ -webkit-transform: scale(1.0);
259
+ -ms-transform: scale(1.0);
260
+ transform: scale(1.0);
261
+ opacity: 0;
262
+ }
263
+ }
264
+
265
+ #sb_instagram .fa-spin,
266
+ #sbi_lightbox .fa-spin{
267
+ -webkit-animation: fa-spin 2s infinite linear;
268
+ animation: fa-spin 2s infinite linear
269
+ }
270
+
271
+ #sb_instagram .fa-pulse,
272
+ #sbi_lightbox .fa-pulse{
273
+ -webkit-animation: fa-spin 1s infinite steps(8);
274
+ animation: fa-spin 1s infinite steps(8)
275
+ }
276
+
277
+ @-webkit-keyframes fa-spin {
278
+ 0% {
279
+ -webkit-transform: rotate(0deg);
280
+ transform: rotate(0deg)
281
+ }
282
+ 100% {
283
+ -webkit-transform: rotate(359deg);
284
+ transform: rotate(359deg)
285
+ }
286
+ }
287
+
288
+ @keyframes fa-spin {
289
+ 0% {
290
+ -webkit-transform: rotate(0deg);
291
+ transform: rotate(0deg)
292
+ }
293
+ 100% {
294
+ -webkit-transform: rotate(359deg);
295
+ transform: rotate(359deg)
296
+ }
297
+ }
298
+ /* Screen reader */
299
+ .sbi-screenreader{text-indent: -9999px !important;display: block !important;width: 0 !important;height: 0 !important;line-height: 0 !important;text-align: left !important; }
300
+
301
+ /* HEADER */
302
+ #sb_instagram .sb_instagram_header{
303
+ float: left;
304
+ clear: both;
305
+ margin: 0 0 15px 0;
306
+ padding: 0;
307
+ line-height: 1.2;
308
+ width: 100%;
309
+ }
310
+ #sb_instagram .sb_instagram_header a{
311
+ float: left;
312
+ display: block;
313
+ /*width: 100%;*/
314
+ min-width: 100%\9;
315
+ text-decoration: none;
316
+ transition: color 0.5s ease;
317
+ }
318
+ .sbi_no_avatar .sbi_header_img{
319
+ background: #333;
320
+ color: #fff;
321
+ width: 50px;
322
+ height: 50px;
323
+ position: relative;
324
+ }
325
+ .sbi_no_avatar .sbi_header_hashtag_icon {
326
+ display: block;
327
+ color: #fff;
328
+ opacity: .9;
329
+ -webkit-transition: background .6s linear,color .6s linear;
330
+ -moz-transition: background .6s linear,color .6s linear;
331
+ -ms-transition: background .6s linear,color .6s linear;
332
+ -o-transition: background .6s linear,color .6s linear;
333
+ transition: background .6s linear,color .6s linear
334
+ }
335
+
336
+ .sbi_no_avatar:hover .sbi_header_hashtag_icon {
337
+ display: block;
338
+ opacity: 1;
339
+ -webkit-transition: background .2s linear,color .2s linear;
340
+ -moz-transition: background .2s linear,color .2s linear;
341
+ -ms-transition: background .2s linear,color .2s linear;
342
+ -o-transition: background .2s linear,color .2s linear;
343
+ transition: background .2s linear,color .2s linear
344
+ }
345
+ /** Medium Header */
346
+ /* Only use medium & large headers on devices above 480px */
347
+ @media all and (min-width: 480px){
348
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img {
349
+ width: 80px;
350
+ height: 80px;
351
+ border-radius: 40px;
352
+ }
353
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img img {
354
+ width: 80px;
355
+ height: 80px;
356
+ border-radius: 40px;
357
+ }
358
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3 {
359
+ font-size: 20px;
360
+ }
361
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,
362
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio{
363
+ font-size: 14px;
364
+ }
365
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3,
366
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,
367
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio{
368
+ margin-left: 95px !important;
369
+ line-height: 1.4
370
+ }
371
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3{
372
+ margin-right: -85px !important;
373
+ }
374
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info{
375
+ margin-top: 4px !important;
376
+ }
377
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text.sbi_no_bio h3{
378
+ padding-top: 20px !important;
379
+ }
380
+ /** Large Header */
381
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_img {
382
+ width: 120px;
383
+ height: 120px;
384
+ border-radius: 60px;
385
+ }
386
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_img img {
387
+ width: 120px;
388
+ height: 120px;
389
+ border-radius: 60px;
390
+ }
391
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3 {
392
+ font-size: 28px;
393
+ }
394
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,
395
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio{
396
+ font-size: 16px;
397
+ }
398
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3,
399
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,
400
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio{
401
+ margin-left: 140px !important;
402
+ line-height: 1.5;
403
+ }
404
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3{
405
+ margin-right: -120px !important;
406
+ }
407
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info{
408
+ margin-top: 12px !important;
409
+ }
410
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text.sbi_no_bio h3{
411
+ padding-top: 32px !important;
412
+ }
413
+ }
414
+
415
+ /* Header profile pic */
416
+ #sb_instagram .sb_instagram_header .sbi_header_img{
417
+ float: left;
418
+ position: relative;
419
+ width: 50px;
420
+ margin: 0 0 0 -100% !important;
421
+ overflow: hidden;
422
+
423
+ -moz-border-radius: 40px;
424
+ -webkit-border-radius: 40px;
425
+ border-radius: 40px;
426
+ }
427
+ #sb_instagram .sb_instagram_header .sbi_header_img img{
428
+ float: left;
429
+ margin: 0 !important;
430
+ padding: 0 !important;
431
+ border: none !important;
432
+
433
+ -moz-border-radius: 40px;
434
+ -webkit-border-radius: 40px;
435
+ border-radius: 40px;
436
+ }
437
+ /* Profile pic hover */
438
+ /* Profile pic hover */
439
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover{
440
+ opacity: 0;
441
+ position: absolute;
442
+ width: 100%;
443
+ top: 0;
444
+ bottom: 0;
445
+ left: 0;
446
+ text-align: center;
447
+ color: #fff;
448
+ background: rgba(0,0,0,0.75);
449
+ }
450
+
451
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover .sbi_new_logo,
452
+ #sb_instagram .sb_instagram_header .sbi_header_hashtag_icon .sbi_new_logo{
453
+ position: absolute;
454
+ top: 50%;
455
+ left: 50%;
456
+ margin-top: -12px;
457
+ margin-left: -12px;
458
+ width: 24px;
459
+ height: 24px;
460
+ font-size: 24px;
461
+ }
462
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_hashtag_icon .sbi_new_logo,
463
+ .sb_instagram_header.sbi_medium .sbi_header_hashtag_icon .sbi_new_logo{
464
+ margin-top: -18px;
465
+ margin-left: -18px;
466
+ width: 36px;
467
+ height: 36px;
468
+ font-size: 36px
469
+ }
470
+
471
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_hashtag_icon .sbi_new_logo,
472
+ .sb_instagram_header.sbi_large .sbi_header_hashtag_icon .sbi_new_logo {
473
+ margin-top: -24px;
474
+ margin-left: -24px;
475
+ width: 48px;
476
+ height: 48px;
477
+ font-size: 48px
478
+ }
479
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover i {
480
+ overflow: hidden;
481
+ background: url('../img/small-logo.png') no-repeat 0 0;
482
+ }
483
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover{
484
+ z-index: 2;
485
+ transition: opacity 0.4s ease-in-out;
486
+ }
487
+ #sb_instagram .sb_instagram_header .sbi_fade_in{
488
+ opacity: 1;
489
+ transition: opacity 0.2s ease-in-out;
490
+ }
491
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover{
492
+ position: absolute;
493
+ width: 100%;
494
+ top: 0;
495
+ bottom: 0;
496
+ left: 0;
497
+ text-align: center;
498
+ color: #fff;
499
+ background: rgba(0,0,0,0.75);
500
+
501
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
502
+ filter: alpha(opacity=0);
503
+ -moz-opacity: 0;
504
+ -khtml-opacity: 0;
505
+ opacity: 0;
506
+ border-radius: 40px;
507
+ transition: opacity 0.2s;
508
+ }
509
+ /* Fade the Instagram icon in when hovering on the header */
510
+ #sb_instagram .sb_instagram_header a:hover .sbi_header_img_hover,
511
+ #sb_instagram .sb_instagram_header a:focus .sbi_header_img_hover{
512
+ opacity: 1;
513
+ }
514
+ /* Header text */
515
+ #sb_instagram .sb_instagram_header .sbi_header_text{
516
+ float: left;
517
+ width: 100%;
518
+ padding-top: 5px;
519
+ }
520
+ #sb_instagram .sb_instagram_header a{
521
+ text-decoration: none;
522
+ }
523
+ #sb_instagram .sb_instagram_header .sbi_header_text .sbi_bio,
524
+ #sb_instagram .sb_instagram_header .sbi_header_text h3{
525
+ float: left;
526
+ clear: both;
527
+ width: auto;
528
+ margin: 0 0 0 60px !important;
529
+ padding: 0 !important;
530
+ }
531
+ #sb_instagram .sb_instagram_header h3{
532
+ font-size: 16px;
533
+ line-height: 1.3;
534
+ }
535
+ #sb_instagram .sb_instagram_header p{
536
+ font-size: 13px;
537
+ line-height: 1.3;
538
+ margin: 0;
539
+ padding: 0;
540
+ }
541
+ #sb_instagram p:empty { display: none; }
542
+ #sb_instagram .sb_instagram_header .sbi_header_text img.emoji{
543
+ margin-right: 3px !important;
544
+ }
545
+
546
+ /* No bio */
547
+ #sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio h3{
548
+ padding-top: 9px !important;
549
+ }
550
+ #sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio .sbi_bio_info{
551
+ clear: both;
552
+ }
553
+
554
+
555
+ /* Buttons */
556
+ #sb_instagram #sbi_load{
557
+ float: left;
558
+ clear: both;
559
+ width: 100%;
560
+ text-align: center;
561
+ }
562
+ #sb_instagram #sbi_load .fa-spinner{
563
+ display: none;
564
+ position: absolute;
565
+ top: 50%;
566
+ left: 50%;
567
+ margin: -8px 0 0 -7px;
568
+ font-size: 15px;
569
+ }
570
+ #sb_instagram #sbi_load{
571
+ opacity: 1;
572
+ transition: all 0.5s ease-in;
573
+ }
574
+ #sb_instagram .sbi_load_btn .sbi_btn_text, #sb_instagram .sbi_load_btn .sbi_loader{
575
+ opacity: 1;
576
+ transition: all 0.1s ease-in;
577
+ }
578
+ #sb_instagram .sbi_hidden{
579
+ opacity: 0 !important;
580
+ }
581
+ #sb_instagram #sbi_load .sbi_load_btn,
582
+ #sb_instagram .sbi_follow_btn a{
583
+ display: -moz-inline-stack;
584
+ display: inline-block;
585
+ vertical-align: top;
586
+ zoom: 1;
587
+ *display: inline;
588
+
589
+ padding: 7px 14px;
590
+ margin: 5px auto 0 auto;
591
+ background: #333;
592
+ color: #eee;
593
+ border: none;
594
+ color: #fff;
595
+ text-decoration: none;
596
+ font-size: 13px;
597
+ line-height: 1.5;
598
+
599
+ -moz-border-radius: 4px;
600
+ -webkit-border-radius: 4px;
601
+ border-radius: 4px;
602
+
603
+ -webkit-box-sizing: border-box;
604
+ -moz-box-sizing: border-box;
605
+ box-sizing: border-box;
606
+ }
607
+ #sb_instagram #sbi_load .sbi_load_btn {
608
+ position: relative;
609
+ }
610
+ /* Follow button */
611
+ #sb_instagram .sbi_follow_btn{
612
+ display: -moz-inline-stack;
613
+ display: inline-block;
614
+ vertical-align: top;
615
+ zoom: 1;
616
+ *display: inline;
617
+ text-align: center;
618
+ }
619
+ #sb_instagram .sbi_follow_btn.sbi_top{
620
+ display: block;
621
+ margin-bottom: 5px;
622
+ }
623
+ #sb_instagram .sbi_follow_btn a{
624
+ background: #408bd1;
625
+ color: #fff;
626
+ }
627
+ #sb_instagram .sbi_follow_btn a,
628
+ #sb_instagram .sbi_follow_btn a,
629
+ #sb_instagram #sbi_load .sbi_load_btn{
630
+ transition: all 0.1s ease-in;
631
+ }
632
+ /* Hover state for default colors */
633
+ #sb_instagram #sbi_load .sbi_load_btn:hover{
634
+ outline: none;
635
+ box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.25);
636
+ }
637
+ #sb_instagram .sbi_follow_btn a:hover,
638
+ #sb_instagram .sbi_follow_btn a:focus{
639
+ outline: none;
640
+ box-shadow: inset 0 0 10px 20px #359dff;
641
+ }
642
+ /* If a custom color is applied then just use opacity for the hover effect */
643
+ #sb_instagram .sbi_follow_btn.sbi_custom a:hover,
644
+ #sb_instagram .sbi_follow_btn.sbi_custom a:focus,
645
+ #sb_instagram #sbi_load .sbi_load_btn.sbi_custom:hover{
646
+ box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.15);
647
+ }
648
+ /* Active state */
649
+ #sb_instagram .sbi_follow_btn a:active,
650
+ #sb_instagram #sbi_load .sbi_load_btn:active{
651
+ box-shadow: inset 0 0 10px 20px rgba(0,0,0,0.3);
652
+ }
653
+
654
+ #sb_instagram .sbi_follow_btn .fa,
655
+ #sb_instagram .sbi_follow_btn svg{
656
+ margin-bottom: -1px;
657
+ margin-right: 7px;
658
+ font-size: 15px;
659
+ }
660
+ #sb_instagram .sbi_follow_btn svg{
661
+ vertical-align: -.125em;
662
+ }
663
+ #sb_instagram #sbi_load .sbi_follow_btn{
664
+ margin-left: 5px;
665
+ }
666
+
667
+ /* Error messages */
668
+ #sb_instagram .sb_instagram_error{
669
+ width: 100%;
670
+ text-align: center;
671
+ line-height: 1.4;
672
+ }
673
+
674
+ /* Mod only error msgs */
675
+ #sbi_mod_error{
676
+ display: none;
677
+ border: 1px solid #ddd;
678
+ background: #eee;
679
+ color: #333;
680
+ margin: 10px 0 0;
681
+ padding: 10px 15px;
682
+ font-size: 13px;
683
+ text-align: center;
684
+ clear: both;
685
+
686
+ -moz-border-radius: 4px;
687
+ -webkit-border-radius: 4px;
688
+ border-radius: 4px;
689
+ }
690
+ #sbi_mod_error br {
691
+ display: initial !important;
692
+ }
693
+ #sbi_mod_error p{
694
+ padding: 5px 0 !important;
695
+ margin: 0 !important;
696
+ line-height: 1.3 !important;
697
+ }
698
+ #sbi_mod_error ol,
699
+ #sbi_mod_error ul{
700
+ padding: 5px 0 5px 20px !important;
701
+ margin: 0 !important;
702
+ }
703
+ #sbi_mod_error li{
704
+ padding: 1px 0 !important;
705
+ margin: 0 !important;
706
+ }
707
+ #sbi_mod_error span{
708
+ font-size: 12px;
709
+ }
710
+
711
+ /* Medium */
712
+ #sb_instagram.sbi_medium .sbi_playbtn,
713
+ #sb_instagram.sbi_medium .sbi_photo_wrap .svg-inline--fa.fa-play{
714
+ margin-top: -12px;
715
+ margin-left: -9px;
716
+ font-size: 23px;
717
+ }
718
+ #sb_instagram.sbi_medium .sbi_type_carousel .sbi_photo_wrap .fa-clone{
719
+ right: 8px;
720
+ top: 8px;
721
+ font-size: 18px;
722
+ }
723
+ /* Small */
724
+ #sb_instagram.sbi_small .sbi_playbtn,
725
+ #sb_instagram.sbi_small .sbi_photo_wrap .svg-inline--fa.fa-play{
726
+ margin-top: -9px;
727
+ margin-left: -7px;
728
+ font-size: 18px;
729
+ }
730
+ #sb_instagram.sbi_small .sbi_type_carousel .sbi_photo_wrap .fa-clone{
731
+ right: 5px;
732
+ top: 5px;
733
+ font-size: 12px;
734
+ }
735
+
736
+ /* Media queries */
737
+ @media all and (max-width: 640px){
738
+ /* Make 3-6 cols into 2 col */
739
+ #sb_instagram.sbi_col_3 #sbi_images .sbi_item,
740
+ #sb_instagram.sbi_col_4 #sbi_images .sbi_item,
741
+ #sb_instagram.sbi_col_5 #sbi_images .sbi_item,
742
+ #sb_instagram.sbi_col_6 #sbi_images .sbi_item{
743
+ width: 50%;
744
+ }
745
+ /* Make 7-10 cols into 4 col */
746
+ #sb_instagram.sbi_col_7 #sbi_images .sbi_item,
747
+ #sb_instagram.sbi_col_8 #sbi_images .sbi_item,
748
+ #sb_instagram.sbi_col_9 #sbi_images .sbi_item,
749
+ #sb_instagram.sbi_col_10 #sbi_images .sbi_item{
750
+ width: 25%;
751
+ }
752
+ /* On mobile make the min-width 100% */
753
+ #sb_instagram.sbi_width_resp{
754
+ width: 100% !important;
755
+ }
756
+ }
757
+ @media all and (max-width: 480px){
758
+ /* Make all cols into 1 col */
759
+ #sb_instagram.sbi_col_3 #sbi_images .sbi_item,
760
+ #sb_instagram.sbi_col_4 #sbi_images .sbi_item,
761
+ #sb_instagram.sbi_col_5 #sbi_images .sbi_item,
762
+ #sb_instagram.sbi_col_6 #sbi_images .sbi_item,
763
+ #sb_instagram.sbi_col_7 #sbi_images .sbi_item,
764
+ #sb_instagram.sbi_col_8 #sbi_images .sbi_item,
765
+ #sb_instagram.sbi_col_9 #sbi_images .sbi_item,
766
+ #sb_instagram.sbi_col_10 #sbi_images .sbi_item{
767
+ width: 100%;
768
+ }
769
+ }
770
+
771
+ /* NO JS */
772
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap{
773
+ box-sizing: border-box;
774
+ position: relative;
775
+ overflow: hidden;
776
+ }
777
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap:before {
778
+ content: "";
779
+ display: block;
780
+ padding-top: 100%;
781
+ z-index: -300;
782
+ }
783
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo {
784
+ position: absolute;
785
+ top: 0;
786
+ left: 0;
787
+ bottom: 0;
788
+ right: 0;
789
+ }
790
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item.sbi_transition {
791
+ opacity: 1;
792
+ max-height: 640px;
793
+ }
794
+ #sb_instagram.sbi_no_js .sbi_photo img,
795
+ #sb_instagram.sbi_no_js .sbi_load_btn{
796
+ display: none;
797
+ }
798
+ #sb_instagram #sbi_images .sbi_js_load_disabled .sbi_imgLiquid_ready.sbi_photo {
799
+ padding-bottom: 0 !important;
800
+ }
801
+ #sb_instagram #sbi_mod_error .sb_frontend_btn {
802
+ display: inline-block;
803
+ padding: 6px 10px;
804
+ background: #ddd;
805
+ background: rgba(0,0,0,.1);
806
+ text-decoration: none;
807
+ border-radius: 5px;
808
+ margin-top: 10px;
809
+ color: #444
810
+ }
811
+
812
+ #sb_instagram #sbi_mod_error .sb_frontend_btn:hover {
813
+ background: #ccc;
814
+ background: rgba(0,0,0,.15)
815
+ }
816
+
817
+ #sb_instagram #sbi_mod_error .sb_frontend_btn .fa {
818
+ margin-right: 2px
819
  }
css/sb-instagram.css CHANGED
@@ -1,819 +1,819 @@
1
- /**************/
2
- /*** LAYOUT ***/
3
- /**************/
4
-
5
- /* Feed container */
6
- #sb_instagram {
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
- #sb_instagram:after{
15
- content: "";
16
- display: table;
17
- clear: both;
18
- }
19
-
20
- /*********************/
21
- /*** STYLE OPTIONS ***/
22
- /*********************/
23
- #sb_instagram.sbi_fixed_height{
24
- overflow: hidden;
25
- overflow-y: auto;
26
- -webkit-box-sizing: border-box;
27
- -moz-box-sizing: border-box;
28
- box-sizing: border-box;
29
- }
30
- #sb_instagram #sbi_images{
31
- width: 100%;
32
- float: left;
33
- line-height: 0;
34
-
35
- -webkit-box-sizing: border-box;
36
- -moz-box-sizing: border-box;
37
- box-sizing: border-box;
38
- }
39
- /* Remove header shadow/border */
40
- #sb_instagram .sbi_header_link {
41
- -webkit-box-shadow: none;
42
- box-shadow: none;
43
- }
44
- #sb_instagram .sbi_header_link:hover {
45
- border: none;
46
- }
47
-
48
- /* Items */
49
- #sb_instagram #sbi_images .sbi_item{
50
- display: -moz-inline-stack;
51
- display: inline-block;
52
- float: left;
53
- vertical-align: top;
54
- zoom: 1;
55
- *display: inline;
56
-
57
- max-height: 1000px;
58
- padding: inherit !important;
59
- margin: 0 !important;
60
- text-decoration: none;
61
- opacity: 1;
62
- overflow: hidden;
63
-
64
- -webkit-box-sizing: border-box;
65
- -moz-box-sizing: border-box;
66
- box-sizing: border-box;
67
-
68
- -webkit-transition: all 0.5s ease;
69
- -moz-transition: all 0.5s ease;
70
- -o-transition: all 0.5s ease;
71
- -ms-transition: all 0.5s ease;
72
- transition: all 0.5s ease;
73
- }
74
- /* Transition items in */
75
- #sb_instagram #sbi_images .sbi_item.sbi_transition{
76
- opacity: 0;
77
- max-height: 0;
78
- }
79
-
80
- /* Cols */
81
- #sb_instagram.sbi_col_1 #sbi_images .sbi_item{ width: 100%; }
82
- #sb_instagram.sbi_col_2 #sbi_images .sbi_item{ width: 50%; }
83
- #sb_instagram.sbi_col_3 #sbi_images .sbi_item{ width: 33.33%; }
84
- #sb_instagram.sbi_col_4 #sbi_images .sbi_item{ width: 25%; }
85
- #sb_instagram.sbi_col_5 #sbi_images .sbi_item{ width: 20%; }
86
- #sb_instagram.sbi_col_6 #sbi_images .sbi_item{ width: 16.66%; }
87
- #sb_instagram.sbi_col_7 #sbi_images .sbi_item{ width: 14.28%; }
88
- #sb_instagram.sbi_col_8 #sbi_images .sbi_item{ width: 12.5%; }
89
- #sb_instagram.sbi_col_9 #sbi_images .sbi_item{ width: 11.11%; }
90
- #sb_instagram.sbi_col_10 #sbi_images .sbi_item{ width: 10%; }
91
-
92
- /* Disable mobile layout */
93
- #sb_instagram.sbi_col_1.sbi_disable_mobile #sbi_images .sbi_item{ width: 100%; }
94
- #sb_instagram.sbi_col_2.sbi_disable_mobile #sbi_images .sbi_item{ width: 50%; }
95
- #sb_instagram.sbi_col_3.sbi_disable_mobile #sbi_images .sbi_item{ width: 33.33%; }
96
- #sb_instagram.sbi_col_4.sbi_disable_mobile #sbi_images .sbi_item{ width: 25%; }
97
- #sb_instagram.sbi_col_5.sbi_disable_mobile #sbi_images .sbi_item{ width: 20%; }
98
- #sb_instagram.sbi_col_6.sbi_disable_mobile #sbi_images .sbi_item{ width: 16.66%; }
99
- #sb_instagram.sbi_col_7.sbi_disable_mobile #sbi_images .sbi_item{ width: 14.28%; }
100
- #sb_instagram.sbi_col_8.sbi_disable_mobile #sbi_images .sbi_item{ width: 12.5%; }
101
- #sb_instagram.sbi_col_9.sbi_disable_mobile #sbi_images .sbi_item{ width: 11.11%; }
102
- #sb_instagram.sbi_col_10.sbi_disable_mobile #sbi_images .sbi_item{ width: 10%; }
103
-
104
- /* Photos */
105
- #sb_instagram .sbi_photo_wrap{
106
- position: relative;
107
- }
108
- #sb_instagram .sbi_photo{
109
- display: block;
110
- text-decoration: none;
111
- }
112
- #sb_instagram .sbi_photo img{
113
- width: 100%;
114
- height: auto;
115
- }
116
- #sb_instagram .sbi_no_js img{
117
- display: none;
118
- }
119
- #sb_instagram a,
120
- #sb_instagram a:hover,
121
- #sb_instagram a:focus,
122
- #sb_instagram a:active{
123
- outline: none;
124
- }
125
- #sb_instagram img{
126
- display: block;
127
- padding: 0 !important;
128
- margin: 0 !important;
129
- max-width: 100% !important;
130
- opacity: 1 !important;
131
- }
132
- #sb_instagram .sbi_link{
133
- display: none;
134
- position: absolute;
135
- bottom: 0;
136
- right: 0;
137
-
138
- width: 100%;
139
- padding: 10px 0;
140
- background: rgba(0,0,0,0.5);
141
- text-align: center;
142
- color: #fff;
143
- font-size: 12px;
144
- line-height: 1.1;
145
- }
146
- #sb_instagram .sbi_link a{
147
- padding: 0 6px;
148
- text-decoration: none;
149
- color: #fff;
150
- font-size: 12px;
151
- line-height: 1.1;
152
-
153
- display: -moz-inline-stack;
154
- display: inline-block;
155
- vertical-align: top;
156
- zoom: 1;
157
- *display: inline;
158
- }
159
- #sb_instagram .sbi_link .sbi_lightbox_link{
160
- padding-bottom: 5px;
161
- }
162
- #sb_instagram .sbi_link a:hover,
163
- #sb_instagram .sbi_link a:focus{
164
- text-decoration: underline;
165
- }
166
- #sb_instagram .sbi_photo_wrap:hover .sbi_link,
167
- #sb_instagram .sbi_photo_wrap:focus .sbi_link{
168
- display: block;
169
- }
170
-
171
- /* Videos */
172
- #sb_instagram svg:not(:root).svg-inline--fa {
173
- height: 1em;
174
- display: inline-block;
175
- }
176
-
177
- #sb_instagram .sbi_type_video .sbi_playbtn,
178
- #sb_instagram .sbi_type_carousel .sbi_playbtn,
179
- .sbi_type_carousel .fa-clone,
180
- #sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play,
181
- #sb_instagram .sbi_type_video .svg-inline--fa.fa-play{
182
- display: block !important;
183
- position: absolute;
184
- z-index: 1;
185
-
186
- color: #fff;
187
- color: rgba(255,255,255,0.9);
188
- font-style: normal !important;
189
- text-shadow: 0 0 8px rgba(0,0,0,0.8);
190
- }
191
- #sb_instagram .sbi_type_video .sbi_playbtn,
192
- #sb_instagram .sbi_type_carousel .sbi_playbtn {
193
- z-index: 2;
194
- top: 50%;
195
- left: 50%;
196
- margin-top: -24px;
197
- margin-left: -19px;
198
- padding: 0;
199
- font-size: 48px;
200
- }
201
- #sb_instagram .sbi_type_carousel .fa-clone{
202
- right: 12px;
203
- top: 12px;
204
- font-size: 24px;
205
- text-shadow: 0 0 8px rgba(0,0,0,0.3);
206
- }
207
- .sbi_type_carousel svg.fa-clone,
208
- #sb_instagram .sbi_type_video .svg-inline--fa.fa-play,
209
- #sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play{
210
- -webkit-filter: drop-shadow( 0px 0px 2px rgba(0,0,0,.4) );
211
- filter: drop-shadow( 0px 0px 2px rgba(0,0,0,.4) );
212
- }
213
-
214
- /* Loader */
215
- #sb_instagram .sbi_loader{
216
- width: 20px;
217
- height: 20px;
218
-
219
- position: relative;
220
- top: 50%;
221
- left: 50%;
222
- margin: -10px 0 0 -10px;
223
- background-color: #000;
224
- background-color: rgba(0,0,0,0.5);
225
-
226
- border-radius: 100%;
227
- -webkit-animation: sbi-sk-scaleout 1.0s infinite ease-in-out;
228
- animation: sbi-sk-scaleout 1.0s infinite ease-in-out;
229
- }
230
- #sb_instagram br {
231
- display: none;
232
- }
233
- #sbi_load p {
234
- display: inline;
235
- padding: 0;
236
- margin: 0;
237
- }
238
- /* Loader in button */
239
- #sb_instagram #sbi_load .sbi_loader{
240
- position: absolute;
241
- margin-top: -11px;
242
- background-color: #fff;
243
- opacity: 1;
244
- }
245
- @-webkit-keyframes sbi-sk-scaleout {
246
- 0% { -webkit-transform: scale(0) }
247
- 100% {
248
- -webkit-transform: scale(1.0);
249
- opacity: 0;
250
- }
251
- }
252
- @keyframes sbi-sk-scaleout {
253
- 0% {
254
- -webkit-transform: scale(0);
255
- -ms-transform: scale(0);
256
- transform: scale(0);
257
- } 100% {
258
- -webkit-transform: scale(1.0);
259
- -ms-transform: scale(1.0);
260
- transform: scale(1.0);
261
- opacity: 0;
262
- }
263
- }
264
-
265
- #sb_instagram .fa-spin,
266
- #sbi_lightbox .fa-spin{
267
- -webkit-animation: fa-spin 2s infinite linear;
268
- animation: fa-spin 2s infinite linear
269
- }
270
-
271
- #sb_instagram .fa-pulse,
272
- #sbi_lightbox .fa-pulse{
273
- -webkit-animation: fa-spin 1s infinite steps(8);
274
- animation: fa-spin 1s infinite steps(8)
275
- }
276
-
277
- @-webkit-keyframes fa-spin {
278
- 0% {
279
- -webkit-transform: rotate(0deg);
280
- transform: rotate(0deg)
281
- }
282
- 100% {
283
- -webkit-transform: rotate(359deg);
284
- transform: rotate(359deg)
285
- }
286
- }
287
-
288
- @keyframes fa-spin {
289
- 0% {
290
- -webkit-transform: rotate(0deg);
291
- transform: rotate(0deg)
292
- }
293
- 100% {
294
- -webkit-transform: rotate(359deg);
295
- transform: rotate(359deg)
296
- }
297
- }
298
- /* Screen reader */
299
- .sbi-screenreader{text-indent: -9999px !important;display: block !important;width: 0 !important;height: 0 !important;line-height: 0 !important;text-align: left !important; }
300
-
301
- /* HEADER */
302
- #sb_instagram .sb_instagram_header{
303
- float: left;
304
- clear: both;
305
- margin: 0 0 15px 0;
306
- padding: 0;
307
- line-height: 1.2;
308
- width: 100%;
309
- }
310
- #sb_instagram .sb_instagram_header a{
311
- float: left;
312
- display: block;
313
- /*width: 100%;*/
314
- min-width: 100%\9;
315
- text-decoration: none;
316
- transition: color 0.5s ease;
317
- }
318
- .sbi_no_avatar .sbi_header_img{
319
- background: #333;
320
- color: #fff;
321
- width: 50px;
322
- height: 50px;
323
- position: relative;
324
- }
325
- .sbi_no_avatar .sbi_header_hashtag_icon {
326
- display: block;
327
- color: #fff;
328
- opacity: .9;
329
- -webkit-transition: background .6s linear,color .6s linear;
330
- -moz-transition: background .6s linear,color .6s linear;
331
- -ms-transition: background .6s linear,color .6s linear;
332
- -o-transition: background .6s linear,color .6s linear;
333
- transition: background .6s linear,color .6s linear
334
- }
335
-
336
- .sbi_no_avatar:hover .sbi_header_hashtag_icon {
337
- display: block;
338
- opacity: 1;
339
- -webkit-transition: background .2s linear,color .2s linear;
340
- -moz-transition: background .2s linear,color .2s linear;
341
- -ms-transition: background .2s linear,color .2s linear;
342
- -o-transition: background .2s linear,color .2s linear;
343
- transition: background .2s linear,color .2s linear
344
- }
345
- /** Medium Header */
346
- /* Only use medium & large headers on devices above 480px */
347
- @media all and (min-width: 480px){
348
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img {
349
- width: 80px;
350
- height: 80px;
351
- border-radius: 40px;
352
- }
353
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img img {
354
- width: 80px;
355
- height: 80px;
356
- border-radius: 40px;
357
- }
358
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3 {
359
- font-size: 20px;
360
- }
361
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,
362
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio{
363
- font-size: 14px;
364
- }
365
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3,
366
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,
367
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio{
368
- margin-left: 95px !important;
369
- line-height: 1.4
370
- }
371
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3{
372
- margin-right: -85px !important;
373
- }
374
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info{
375
- margin-top: 4px !important;
376
- }
377
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text.sbi_no_bio h3{
378
- padding-top: 20px !important;
379
- }
380
- /** Large Header */
381
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_img {
382
- width: 120px;
383
- height: 120px;
384
- border-radius: 60px;
385
- }
386
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_img img {
387
- width: 120px;
388
- height: 120px;
389
- border-radius: 60px;
390
- }
391
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3 {
392
- font-size: 28px;
393
- }
394
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,
395
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio{
396
- font-size: 16px;
397
- }
398
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3,
399
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,
400
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio{
401
- margin-left: 140px !important;
402
- line-height: 1.5;
403
- }
404
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3{
405
- margin-right: -120px !important;
406
- }
407
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info{
408
- margin-top: 12px !important;
409
- }
410
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text.sbi_no_bio h3{
411
- padding-top: 32px !important;
412
- }
413
- }
414
-
415
- /* Header profile pic */
416
- #sb_instagram .sb_instagram_header .sbi_header_img{
417
- float: left;
418
- position: relative;
419
- width: 50px;
420
- margin: 0 0 0 -100% !important;
421
- overflow: hidden;
422
-
423
- -moz-border-radius: 40px;
424
- -webkit-border-radius: 40px;
425
- border-radius: 40px;
426
- }
427
- #sb_instagram .sb_instagram_header .sbi_header_img img{
428
- float: left;
429
- margin: 0 !important;
430
- padding: 0 !important;
431
- border: none !important;
432
-
433
- -moz-border-radius: 40px;
434
- -webkit-border-radius: 40px;
435
- border-radius: 40px;
436
- }
437
- /* Profile pic hover */
438
- /* Profile pic hover */
439
- #sb_instagram .sb_instagram_header .sbi_header_img_hover{
440
- opacity: 0;
441
- position: absolute;
442
- width: 100%;
443
- top: 0;
444
- bottom: 0;
445
- left: 0;
446
- text-align: center;
447
- color: #fff;
448
- background: rgba(0,0,0,0.75);
449
- }
450
-
451
- #sb_instagram .sb_instagram_header .sbi_header_img_hover .sbi_new_logo,
452
- #sb_instagram .sb_instagram_header .sbi_header_hashtag_icon .sbi_new_logo{
453
- position: absolute;
454
- top: 50%;
455
- left: 50%;
456
- margin-top: -12px;
457
- margin-left: -12px;
458
- width: 24px;
459
- height: 24px;
460
- font-size: 24px;
461
- }
462
- #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_hashtag_icon .sbi_new_logo,
463
- .sb_instagram_header.sbi_medium .sbi_header_hashtag_icon .sbi_new_logo{
464
- margin-top: -18px;
465
- margin-left: -18px;
466
- width: 36px;
467
- height: 36px;
468
- font-size: 36px
469
- }
470
-
471
- #sb_instagram .sb_instagram_header.sbi_large .sbi_header_hashtag_icon .sbi_new_logo,
472
- .sb_instagram_header.sbi_large .sbi_header_hashtag_icon .sbi_new_logo {
473
- margin-top: -24px;
474
- margin-left: -24px;
475
- width: 48px;
476
- height: 48px;
477
- font-size: 48px
478
- }
479
- #sb_instagram .sb_instagram_header .sbi_header_img_hover i {
480
- overflow: hidden;
481
- background: url('../img/small-logo.png') no-repeat 0 0;
482
- }
483
- #sb_instagram .sb_instagram_header .sbi_header_img_hover{
484
- z-index: 2;
485
- transition: opacity 0.4s ease-in-out;
486
- }
487
- #sb_instagram .sb_instagram_header .sbi_fade_in{
488
- opacity: 1;
489
- transition: opacity 0.2s ease-in-out;
490
- }
491
- #sb_instagram .sb_instagram_header .sbi_header_img_hover{
492
- position: absolute;
493
- width: 100%;
494
- top: 0;
495
- bottom: 0;
496
- left: 0;
497
- text-align: center;
498
- color: #fff;
499
- background: rgba(0,0,0,0.75);
500
-
501
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
502
- filter: alpha(opacity=0);
503
- -moz-opacity: 0;
504
- -khtml-opacity: 0;
505
- opacity: 0;
506
- border-radius: 40px;
507
- transition: opacity 0.2s;
508
- }
509
- /* Fade the Instagram icon in when hovering on the header */
510
- #sb_instagram .sb_instagram_header a:hover .sbi_header_img_hover,
511
- #sb_instagram .sb_instagram_header a:focus .sbi_header_img_hover{
512
- opacity: 1;
513
- }
514
- /* Header text */
515
- #sb_instagram .sb_instagram_header .sbi_header_text{
516
- float: left;
517
- width: 100%;
518
- padding-top: 5px;
519
- }
520
- #sb_instagram .sb_instagram_header a{
521
- text-decoration: none;
522
- }
523
- #sb_instagram .sb_instagram_header .sbi_header_text .sbi_bio,
524
- #sb_instagram .sb_instagram_header .sbi_header_text h3{
525
- float: left;
526
- clear: both;
527
- width: auto;
528
- margin: 0 0 0 60px !important;
529
- padding: 0 !important;
530
- }
531
- #sb_instagram .sb_instagram_header h3{
532
- font-size: 16px;
533
- line-height: 1.3;
534
- }
535
- #sb_instagram .sb_instagram_header p{
536
- font-size: 13px;
537
- line-height: 1.3;
538
- margin: 0;
539
- padding: 0;
540
- }
541
- #sb_instagram p:empty { display: none; }
542
- #sb_instagram .sb_instagram_header .sbi_header_text img.emoji{
543
- margin-right: 3px !important;
544
- }
545
-
546
- /* No bio */
547
- #sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio h3{
548
- padding-top: 9px !important;
549
- }
550
- #sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio .sbi_bio_info{
551
- clear: both;
552
- }
553
-
554
-
555
- /* Buttons */
556
- #sb_instagram #sbi_load{
557
- float: left;
558
- clear: both;
559
- width: 100%;
560
- text-align: center;
561
- }
562
- #sb_instagram #sbi_load .fa-spinner{
563
- display: none;
564
- position: absolute;
565
- top: 50%;
566
- left: 50%;
567
- margin: -8px 0 0 -7px;
568
- font-size: 15px;
569
- }
570
- #sb_instagram #sbi_load{
571
- opacity: 1;
572
- transition: all 0.5s ease-in;
573
- }
574
- #sb_instagram .sbi_load_btn .sbi_btn_text, #sb_instagram .sbi_load_btn .sbi_loader{
575
- opacity: 1;
576
- transition: all 0.1s ease-in;
577
- }
578
- #sb_instagram .sbi_hidden{
579
- opacity: 0 !important;
580
- }
581
- #sb_instagram #sbi_load .sbi_load_btn,
582
- #sb_instagram .sbi_follow_btn a{
583
- display: -moz-inline-stack;
584
- display: inline-block;
585
- vertical-align: top;
586
- zoom: 1;
587
- *display: inline;
588
-
589
- padding: 7px 14px;
590
- margin: 5px auto 0 auto;
591
- background: #333;
592
- color: #eee;
593
- border: none;
594
- color: #fff;
595
- text-decoration: none;
596
- font-size: 13px;
597
- line-height: 1.5;
598
-
599
- -moz-border-radius: 4px;
600
- -webkit-border-radius: 4px;
601
- border-radius: 4px;
602
-
603
- -webkit-box-sizing: border-box;
604
- -moz-box-sizing: border-box;
605
- box-sizing: border-box;
606
- }
607
- #sb_instagram #sbi_load .sbi_load_btn {
608
- position: relative;
609
- }
610
- /* Follow button */
611
- #sb_instagram .sbi_follow_btn{
612
- display: -moz-inline-stack;
613
- display: inline-block;
614
- vertical-align: top;
615
- zoom: 1;
616
- *display: inline;
617
- text-align: center;
618
- }
619
- #sb_instagram .sbi_follow_btn.sbi_top{
620
- display: block;
621
- margin-bottom: 5px;
622
- }
623
- #sb_instagram .sbi_follow_btn a{
624
- background: #408bd1;
625
- color: #fff;
626
- }
627
- #sb_instagram .sbi_follow_btn a,
628
- #sb_instagram .sbi_follow_btn a,
629
- #sb_instagram #sbi_load .sbi_load_btn{
630
- transition: all 0.1s ease-in;
631
- }
632
- /* Hover state for default colors */
633
- #sb_instagram #sbi_load .sbi_load_btn:hover{
634
- outline: none;
635
- box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.25);
636
- }
637
- #sb_instagram .sbi_follow_btn a:hover,
638
- #sb_instagram .sbi_follow_btn a:focus{
639
- outline: none;
640
- box-shadow: inset 0 0 10px 20px #359dff;
641
- }
642
- /* If a custom color is applied then just use opacity for the hover effect */
643
- #sb_instagram .sbi_follow_btn.sbi_custom a:hover,
644
- #sb_instagram .sbi_follow_btn.sbi_custom a:focus,
645
- #sb_instagram #sbi_load .sbi_load_btn.sbi_custom:hover{
646
- box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.15);
647
- }
648
- /* Active state */
649
- #sb_instagram .sbi_follow_btn a:active,
650
- #sb_instagram #sbi_load .sbi_load_btn:active{
651
- box-shadow: inset 0 0 10px 20px rgba(0,0,0,0.3);
652
- }
653
-
654
- #sb_instagram .sbi_follow_btn .fa,
655
- #sb_instagram .sbi_follow_btn svg{
656
- margin-bottom: -1px;
657
- margin-right: 7px;
658
- font-size: 15px;
659
- }
660
- #sb_instagram .sbi_follow_btn svg{
661
- vertical-align: -.125em;
662
- }
663
- #sb_instagram #sbi_load .sbi_follow_btn{
664
- margin-left: 5px;
665
- }
666
-
667
- /* Error messages */
668
- #sb_instagram .sb_instagram_error{
669
- width: 100%;
670
- text-align: center;
671
- line-height: 1.4;
672
- }
673
-
674
- /* Mod only error msgs */
675
- #sbi_mod_error{
676
- display: none;
677
- border: 1px solid #ddd;
678
- background: #eee;
679
- color: #333;
680
- margin: 10px 0 0;
681
- padding: 10px 15px;
682
- font-size: 13px;
683
- text-align: center;
684
- clear: both;
685
-
686
- -moz-border-radius: 4px;
687
- -webkit-border-radius: 4px;
688
- border-radius: 4px;
689
- }
690
- #sbi_mod_error br {
691
- display: initial !important;
692
- }
693
- #sbi_mod_error p{
694
- padding: 5px 0 !important;
695
- margin: 0 !important;
696
- line-height: 1.3 !important;
697
- }
698
- #sbi_mod_error ol,
699
- #sbi_mod_error ul{
700
- padding: 5px 0 5px 20px !important;
701
- margin: 0 !important;
702
- }
703
- #sbi_mod_error li{
704
- padding: 1px 0 !important;
705
- margin: 0 !important;
706
- }
707
- #sbi_mod_error span{
708
- font-size: 12px;
709
- }
710
-
711
- /* Medium */
712
- #sb_instagram.sbi_medium .sbi_playbtn,
713
- #sb_instagram.sbi_medium .sbi_photo_wrap .svg-inline--fa.fa-play{
714
- margin-top: -12px;
715
- margin-left: -9px;
716
- font-size: 23px;
717
- }
718
- #sb_instagram.sbi_medium .sbi_type_carousel .sbi_photo_wrap .fa-clone{
719
- right: 8px;
720
- top: 8px;
721
- font-size: 18px;
722
- }
723
- /* Small */
724
- #sb_instagram.sbi_small .sbi_playbtn,
725
- #sb_instagram.sbi_small .sbi_photo_wrap .svg-inline--fa.fa-play{
726
- margin-top: -9px;
727
- margin-left: -7px;
728
- font-size: 18px;
729
- }
730
- #sb_instagram.sbi_small .sbi_type_carousel .sbi_photo_wrap .fa-clone{
731
- right: 5px;
732
- top: 5px;
733
- font-size: 12px;
734
- }
735
-
736
- /* Media queries */
737
- @media all and (max-width: 640px){
738
- /* Make 3-6 cols into 2 col */
739
- #sb_instagram.sbi_col_3 #sbi_images .sbi_item,
740
- #sb_instagram.sbi_col_4 #sbi_images .sbi_item,
741
- #sb_instagram.sbi_col_5 #sbi_images .sbi_item,
742
- #sb_instagram.sbi_col_6 #sbi_images .sbi_item{
743
- width: 50%;
744
- }
745
- /* Make 7-10 cols into 4 col */
746
- #sb_instagram.sbi_col_7 #sbi_images .sbi_item,
747
- #sb_instagram.sbi_col_8 #sbi_images .sbi_item,
748
- #sb_instagram.sbi_col_9 #sbi_images .sbi_item,
749
- #sb_instagram.sbi_col_10 #sbi_images .sbi_item{
750
- width: 25%;
751
- }
752
- /* On mobile make the min-width 100% */
753
- #sb_instagram.sbi_width_resp{
754
- width: 100% !important;
755
- }
756
- }
757
- @media all and (max-width: 480px){
758
- /* Make all cols into 1 col */
759
- #sb_instagram.sbi_col_3 #sbi_images .sbi_item,
760
- #sb_instagram.sbi_col_4 #sbi_images .sbi_item,
761
- #sb_instagram.sbi_col_5 #sbi_images .sbi_item,
762
- #sb_instagram.sbi_col_6 #sbi_images .sbi_item,
763
- #sb_instagram.sbi_col_7 #sbi_images .sbi_item,
764
- #sb_instagram.sbi_col_8 #sbi_images .sbi_item,
765
- #sb_instagram.sbi_col_9 #sbi_images .sbi_item,
766
- #sb_instagram.sbi_col_10 #sbi_images .sbi_item{
767
- width: 100%;
768
- }
769
- }
770
-
771
- /* NO JS */
772
- #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap{
773
- box-sizing: border-box;
774
- position: relative;
775
- overflow: hidden;
776
- }
777
- #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap:before {
778
- content: "";
779
- display: block;
780
- padding-top: 100%;
781
- z-index: -300;
782
- }
783
- #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo {
784
- position: absolute;
785
- top: 0;
786
- left: 0;
787
- bottom: 0;
788
- right: 0;
789
- }
790
- #sb_instagram.sbi_no_js #sbi_images .sbi_item.sbi_transition {
791
- opacity: 1;
792
- max-height: 640px;
793
- }
794
- #sb_instagram.sbi_no_js .sbi_photo img,
795
- #sb_instagram.sbi_no_js .sbi_load_btn{
796
- display: none;
797
- }
798
- #sb_instagram #sbi_images .sbi_js_load_disabled .sbi_imgLiquid_ready.sbi_photo {
799
- padding-bottom: 0 !important;
800
- }
801
- #sb_instagram #sbi_mod_error .sb_frontend_btn {
802
- display: inline-block;
803
- padding: 6px 10px;
804
- background: #ddd;
805
- background: rgba(0,0,0,.1);
806
- text-decoration: none;
807
- border-radius: 5px;
808
- margin-top: 10px;
809
- color: #444
810
- }
811
-
812
- #sb_instagram #sbi_mod_error .sb_frontend_btn:hover {
813
- background: #ccc;
814
- background: rgba(0,0,0,.15)
815
- }
816
-
817
- #sb_instagram #sbi_mod_error .sb_frontend_btn .fa {
818
- margin-right: 2px
819
  }
1
+ /**************/
2
+ /*** LAYOUT ***/
3
+ /**************/
4
+
5
+ /* Feed container */
6
+ #sb_instagram {
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
+ #sb_instagram:after{
15
+ content: "";
16
+ display: table;
17
+ clear: both;
18
+ }
19
+
20
+ /*********************/
21
+ /*** STYLE OPTIONS ***/
22
+ /*********************/
23
+ #sb_instagram.sbi_fixed_height{
24
+ overflow: hidden;
25
+ overflow-y: auto;
26
+ -webkit-box-sizing: border-box;
27
+ -moz-box-sizing: border-box;
28
+ box-sizing: border-box;
29
+ }
30
+ #sb_instagram #sbi_images{
31
+ width: 100%;
32
+ float: left;
33
+ line-height: 0;
34
+
35
+ -webkit-box-sizing: border-box;
36
+ -moz-box-sizing: border-box;
37
+ box-sizing: border-box;
38
+ }
39
+ /* Remove header shadow/border */
40
+ #sb_instagram .sbi_header_link {
41
+ -webkit-box-shadow: none;
42
+ box-shadow: none;
43
+ }
44
+ #sb_instagram .sbi_header_link:hover {
45
+ border: none;
46
+ }
47
+
48
+ /* Items */
49
+ #sb_instagram #sbi_images .sbi_item{
50
+ display: -moz-inline-stack;
51
+ display: inline-block;
52
+ float: left;
53
+ vertical-align: top;
54
+ zoom: 1;
55
+ *display: inline;
56
+
57
+ max-height: 1000px;
58
+ padding: inherit !important;
59
+ margin: 0 !important;
60
+ text-decoration: none;
61
+ opacity: 1;
62
+ overflow: hidden;
63
+
64
+ -webkit-box-sizing: border-box;
65
+ -moz-box-sizing: border-box;
66
+ box-sizing: border-box;
67
+
68
+ -webkit-transition: all 0.5s ease;
69
+ -moz-transition: all 0.5s ease;
70
+ -o-transition: all 0.5s ease;
71
+ -ms-transition: all 0.5s ease;
72
+ transition: all 0.5s ease;
73
+ }
74
+ /* Transition items in */
75
+ #sb_instagram #sbi_images .sbi_item.sbi_transition{
76
+ opacity: 0;
77
+ max-height: 0;
78
+ }
79
+
80
+ /* Cols */
81
+ #sb_instagram.sbi_col_1 #sbi_images .sbi_item{ width: 100%; }
82
+ #sb_instagram.sbi_col_2 #sbi_images .sbi_item{ width: 50%; }
83
+ #sb_instagram.sbi_col_3 #sbi_images .sbi_item{ width: 33.33%; }
84
+ #sb_instagram.sbi_col_4 #sbi_images .sbi_item{ width: 25%; }
85
+ #sb_instagram.sbi_col_5 #sbi_images .sbi_item{ width: 20%; }
86
+ #sb_instagram.sbi_col_6 #sbi_images .sbi_item{ width: 16.66%; }
87
+ #sb_instagram.sbi_col_7 #sbi_images .sbi_item{ width: 14.28%; }
88
+ #sb_instagram.sbi_col_8 #sbi_images .sbi_item{ width: 12.5%; }
89
+ #sb_instagram.sbi_col_9 #sbi_images .sbi_item{ width: 11.11%; }
90
+ #sb_instagram.sbi_col_10 #sbi_images .sbi_item{ width: 10%; }
91
+
92
+ /* Disable mobile layout */
93
+ #sb_instagram.sbi_col_1.sbi_disable_mobile #sbi_images .sbi_item{ width: 100%; }
94
+ #sb_instagram.sbi_col_2.sbi_disable_mobile #sbi_images .sbi_item{ width: 50%; }
95
+ #sb_instagram.sbi_col_3.sbi_disable_mobile #sbi_images .sbi_item{ width: 33.33%; }
96
+ #sb_instagram.sbi_col_4.sbi_disable_mobile #sbi_images .sbi_item{ width: 25%; }
97
+ #sb_instagram.sbi_col_5.sbi_disable_mobile #sbi_images .sbi_item{ width: 20%; }
98
+ #sb_instagram.sbi_col_6.sbi_disable_mobile #sbi_images .sbi_item{ width: 16.66%; }
99
+ #sb_instagram.sbi_col_7.sbi_disable_mobile #sbi_images .sbi_item{ width: 14.28%; }
100
+ #sb_instagram.sbi_col_8.sbi_disable_mobile #sbi_images .sbi_item{ width: 12.5%; }
101
+ #sb_instagram.sbi_col_9.sbi_disable_mobile #sbi_images .sbi_item{ width: 11.11%; }
102
+ #sb_instagram.sbi_col_10.sbi_disable_mobile #sbi_images .sbi_item{ width: 10%; }
103
+
104
+ /* Photos */
105
+ #sb_instagram .sbi_photo_wrap{
106
+ position: relative;
107
+ }
108
+ #sb_instagram .sbi_photo{
109
+ display: block;
110
+ text-decoration: none;
111
+ }
112
+ #sb_instagram .sbi_photo img{
113
+ width: 100%;
114
+ height: auto;
115
+ }
116
+ #sb_instagram .sbi_no_js img{
117
+ display: none;
118
+ }
119
+ #sb_instagram a,
120
+ #sb_instagram a:hover,
121
+ #sb_instagram a:focus,
122
+ #sb_instagram a:active{
123
+ outline: none;
124
+ }
125
+ #sb_instagram img{
126
+ display: block;
127
+ padding: 0 !important;
128
+ margin: 0 !important;
129
+ max-width: 100% !important;
130
+ opacity: 1 !important;
131
+ }
132
+ #sb_instagram .sbi_link{
133
+ display: none;
134
+ position: absolute;
135
+ bottom: 0;
136
+ right: 0;
137
+
138
+ width: 100%;
139
+ padding: 10px 0;
140
+ background: rgba(0,0,0,0.5);
141
+ text-align: center;
142
+ color: #fff;
143
+ font-size: 12px;
144
+ line-height: 1.1;
145
+ }
146
+ #sb_instagram .sbi_link a{
147
+ padding: 0 6px;
148
+ text-decoration: none;
149
+ color: #fff;
150
+ font-size: 12px;
151
+ line-height: 1.1;
152
+
153
+ display: -moz-inline-stack;
154
+ display: inline-block;
155
+ vertical-align: top;
156
+ zoom: 1;
157
+ *display: inline;
158
+ }
159
+ #sb_instagram .sbi_link .sbi_lightbox_link{
160
+ padding-bottom: 5px;
161
+ }
162
+ #sb_instagram .sbi_link a:hover,
163
+ #sb_instagram .sbi_link a:focus{
164
+ text-decoration: underline;
165
+ }
166
+ #sb_instagram .sbi_photo_wrap:hover .sbi_link,
167
+ #sb_instagram .sbi_photo_wrap:focus .sbi_link{
168
+ display: block;
169
+ }
170
+
171
+ /* Videos */
172
+ #sb_instagram svg:not(:root).svg-inline--fa {
173
+ height: 1em;
174
+ display: inline-block;
175
+ }
176
+
177
+ #sb_instagram .sbi_type_video .sbi_playbtn,
178
+ #sb_instagram .sbi_type_carousel .sbi_playbtn,
179
+ .sbi_type_carousel .fa-clone,
180
+ #sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play,
181
+ #sb_instagram .sbi_type_video .svg-inline--fa.fa-play{
182
+ display: block !important;
183
+ position: absolute;
184
+ z-index: 1;
185
+
186
+ color: #fff;
187
+ color: rgba(255,255,255,0.9);
188
+ font-style: normal !important;
189
+ text-shadow: 0 0 8px rgba(0,0,0,0.8);
190
+ }
191
+ #sb_instagram .sbi_type_video .sbi_playbtn,
192
+ #sb_instagram .sbi_type_carousel .sbi_playbtn {
193
+ z-index: 2;
194
+ top: 50%;
195
+ left: 50%;
196
+ margin-top: -24px;
197
+ margin-left: -19px;
198
+ padding: 0;
199
+ font-size: 48px;
200
+ }
201
+ #sb_instagram .sbi_type_carousel .fa-clone{
202
+ right: 12px;
203
+ top: 12px;
204
+ font-size: 24px;
205
+ text-shadow: 0 0 8px rgba(0,0,0,0.3);
206
+ }
207
+ .sbi_type_carousel svg.fa-clone,
208
+ #sb_instagram .sbi_type_video .svg-inline--fa.fa-play,
209
+ #sb_instagram .sbi_type_carousel .svg-inline--fa.fa-play{
210
+ -webkit-filter: drop-shadow( 0px 0px 2px rgba(0,0,0,.4) );
211
+ filter: drop-shadow( 0px 0px 2px rgba(0,0,0,.4) );
212
+ }
213
+
214
+ /* Loader */
215
+ #sb_instagram .sbi_loader{
216
+ width: 20px;
217
+ height: 20px;
218
+
219
+ position: relative;
220
+ top: 50%;
221
+ left: 50%;
222
+ margin: -10px 0 0 -10px;
223
+ background-color: #000;
224
+ background-color: rgba(0,0,0,0.5);
225
+
226
+ border-radius: 100%;
227
+ -webkit-animation: sbi-sk-scaleout 1.0s infinite ease-in-out;
228
+ animation: sbi-sk-scaleout 1.0s infinite ease-in-out;
229
+ }
230
+ #sb_instagram br {
231
+ display: none;
232
+ }
233
+ #sbi_load p {
234
+ display: inline;
235
+ padding: 0;
236
+ margin: 0;
237
+ }
238
+ /* Loader in button */
239
+ #sb_instagram #sbi_load .sbi_loader{
240
+ position: absolute;
241
+ margin-top: -11px;
242
+ background-color: #fff;
243
+ opacity: 1;
244
+ }
245
+ @-webkit-keyframes sbi-sk-scaleout {
246
+ 0% { -webkit-transform: scale(0) }
247
+ 100% {
248
+ -webkit-transform: scale(1.0);
249
+ opacity: 0;
250
+ }
251
+ }
252
+ @keyframes sbi-sk-scaleout {
253
+ 0% {
254
+ -webkit-transform: scale(0);
255
+ -ms-transform: scale(0);
256
+ transform: scale(0);
257
+ } 100% {
258
+ -webkit-transform: scale(1.0);
259
+ -ms-transform: scale(1.0);
260
+ transform: scale(1.0);
261
+ opacity: 0;
262
+ }
263
+ }
264
+
265
+ #sb_instagram .fa-spin,
266
+ #sbi_lightbox .fa-spin{
267
+ -webkit-animation: fa-spin 2s infinite linear;
268
+ animation: fa-spin 2s infinite linear
269
+ }
270
+
271
+ #sb_instagram .fa-pulse,
272
+ #sbi_lightbox .fa-pulse{
273
+ -webkit-animation: fa-spin 1s infinite steps(8);
274
+ animation: fa-spin 1s infinite steps(8)
275
+ }
276
+
277
+ @-webkit-keyframes fa-spin {
278
+ 0% {
279
+ -webkit-transform: rotate(0deg);
280
+ transform: rotate(0deg)
281
+ }
282
+ 100% {
283
+ -webkit-transform: rotate(359deg);
284
+ transform: rotate(359deg)
285
+ }
286
+ }
287
+
288
+ @keyframes fa-spin {
289
+ 0% {
290
+ -webkit-transform: rotate(0deg);
291
+ transform: rotate(0deg)
292
+ }
293
+ 100% {
294
+ -webkit-transform: rotate(359deg);
295
+ transform: rotate(359deg)
296
+ }
297
+ }
298
+ /* Screen reader */
299
+ .sbi-screenreader{text-indent: -9999px !important;display: block !important;width: 0 !important;height: 0 !important;line-height: 0 !important;text-align: left !important; }
300
+
301
+ /* HEADER */
302
+ #sb_instagram .sb_instagram_header{
303
+ float: left;
304
+ clear: both;
305
+ margin: 0 0 15px 0;
306
+ padding: 0;
307
+ line-height: 1.2;
308
+ width: 100%;
309
+ }
310
+ #sb_instagram .sb_instagram_header a{
311
+ float: left;
312
+ display: block;
313
+ /*width: 100%;*/
314
+ min-width: 100%\9;
315
+ text-decoration: none;
316
+ transition: color 0.5s ease;
317
+ }
318
+ .sbi_no_avatar .sbi_header_img{
319
+ background: #333;
320
+ color: #fff;
321
+ width: 50px;
322
+ height: 50px;
323
+ position: relative;
324
+ }
325
+ .sbi_no_avatar .sbi_header_hashtag_icon {
326
+ display: block;
327
+ color: #fff;
328
+ opacity: .9;
329
+ -webkit-transition: background .6s linear,color .6s linear;
330
+ -moz-transition: background .6s linear,color .6s linear;
331
+ -ms-transition: background .6s linear,color .6s linear;
332
+ -o-transition: background .6s linear,color .6s linear;
333
+ transition: background .6s linear,color .6s linear
334
+ }
335
+
336
+ .sbi_no_avatar:hover .sbi_header_hashtag_icon {
337
+ display: block;
338
+ opacity: 1;
339
+ -webkit-transition: background .2s linear,color .2s linear;
340
+ -moz-transition: background .2s linear,color .2s linear;
341
+ -ms-transition: background .2s linear,color .2s linear;
342
+ -o-transition: background .2s linear,color .2s linear;
343
+ transition: background .2s linear,color .2s linear
344
+ }
345
+ /** Medium Header */
346
+ /* Only use medium & large headers on devices above 480px */
347
+ @media all and (min-width: 480px){
348
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img {
349
+ width: 80px;
350
+ height: 80px;
351
+ border-radius: 40px;
352
+ }
353
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_img img {
354
+ width: 80px;
355
+ height: 80px;
356
+ border-radius: 40px;
357
+ }
358
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3 {
359
+ font-size: 20px;
360
+ }
361
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,
362
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio{
363
+ font-size: 14px;
364
+ }
365
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3,
366
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info,
367
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio{
368
+ margin-left: 95px !important;
369
+ line-height: 1.4
370
+ }
371
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text h3{
372
+ margin-right: -85px !important;
373
+ }
374
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text .sbi_bio_info{
375
+ margin-top: 4px !important;
376
+ }
377
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_text.sbi_no_bio h3{
378
+ padding-top: 20px !important;
379
+ }
380
+ /** Large Header */
381
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_img {
382
+ width: 120px;
383
+ height: 120px;
384
+ border-radius: 60px;
385
+ }
386
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_img img {
387
+ width: 120px;
388
+ height: 120px;
389
+ border-radius: 60px;
390
+ }
391
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3 {
392
+ font-size: 28px;
393
+ }
394
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,
395
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio{
396
+ font-size: 16px;
397
+ }
398
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3,
399
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info,
400
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio{
401
+ margin-left: 140px !important;
402
+ line-height: 1.5;
403
+ }
404
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text h3{
405
+ margin-right: -120px !important;
406
+ }
407
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text .sbi_bio_info{
408
+ margin-top: 12px !important;
409
+ }
410
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_text.sbi_no_bio h3{
411
+ padding-top: 32px !important;
412
+ }
413
+ }
414
+
415
+ /* Header profile pic */
416
+ #sb_instagram .sb_instagram_header .sbi_header_img{
417
+ float: left;
418
+ position: relative;
419
+ width: 50px;
420
+ margin: 0 0 0 -100% !important;
421
+ overflow: hidden;
422
+
423
+ -moz-border-radius: 40px;
424
+ -webkit-border-radius: 40px;
425
+ border-radius: 40px;
426
+ }
427
+ #sb_instagram .sb_instagram_header .sbi_header_img img{
428
+ float: left;
429
+ margin: 0 !important;
430
+ padding: 0 !important;
431
+ border: none !important;
432
+
433
+ -moz-border-radius: 40px;
434
+ -webkit-border-radius: 40px;
435
+ border-radius: 40px;
436
+ }
437
+ /* Profile pic hover */
438
+ /* Profile pic hover */
439
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover{
440
+ opacity: 0;
441
+ position: absolute;
442
+ width: 100%;
443
+ top: 0;
444
+ bottom: 0;
445
+ left: 0;
446
+ text-align: center;
447
+ color: #fff;
448
+ background: rgba(0,0,0,0.75);
449
+ }
450
+
451
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover .sbi_new_logo,
452
+ #sb_instagram .sb_instagram_header .sbi_header_hashtag_icon .sbi_new_logo{
453
+ position: absolute;
454
+ top: 50%;
455
+ left: 50%;
456
+ margin-top: -12px;
457
+ margin-left: -12px;
458
+ width: 24px;
459
+ height: 24px;
460
+ font-size: 24px;
461
+ }
462
+ #sb_instagram .sb_instagram_header.sbi_medium .sbi_header_hashtag_icon .sbi_new_logo,
463
+ .sb_instagram_header.sbi_medium .sbi_header_hashtag_icon .sbi_new_logo{
464
+ margin-top: -18px;
465
+ margin-left: -18px;
466
+ width: 36px;
467
+ height: 36px;
468
+ font-size: 36px
469
+ }
470
+
471
+ #sb_instagram .sb_instagram_header.sbi_large .sbi_header_hashtag_icon .sbi_new_logo,
472
+ .sb_instagram_header.sbi_large .sbi_header_hashtag_icon .sbi_new_logo {
473
+ margin-top: -24px;
474
+ margin-left: -24px;
475
+ width: 48px;
476
+ height: 48px;
477
+ font-size: 48px
478
+ }
479
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover i {
480
+ overflow: hidden;
481
+ background: url('../img/small-logo.png') no-repeat 0 0;
482
+ }
483
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover{
484
+ z-index: 2;
485
+ transition: opacity 0.4s ease-in-out;
486
+ }
487
+ #sb_instagram .sb_instagram_header .sbi_fade_in{
488
+ opacity: 1;
489
+ transition: opacity 0.2s ease-in-out;
490
+ }
491
+ #sb_instagram .sb_instagram_header .sbi_header_img_hover{
492
+ position: absolute;
493
+ width: 100%;
494
+ top: 0;
495
+ bottom: 0;
496
+ left: 0;
497
+ text-align: center;
498
+ color: #fff;
499
+ background: rgba(0,0,0,0.75);
500
+
501
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
502
+ filter: alpha(opacity=0);
503
+ -moz-opacity: 0;
504
+ -khtml-opacity: 0;
505
+ opacity: 0;
506
+ border-radius: 40px;
507
+ transition: opacity 0.2s;
508
+ }
509
+ /* Fade the Instagram icon in when hovering on the header */
510
+ #sb_instagram .sb_instagram_header a:hover .sbi_header_img_hover,
511
+ #sb_instagram .sb_instagram_header a:focus .sbi_header_img_hover{
512
+ opacity: 1;
513
+ }
514
+ /* Header text */
515
+ #sb_instagram .sb_instagram_header .sbi_header_text{
516
+ float: left;
517
+ width: 100%;
518
+ padding-top: 5px;
519
+ }
520
+ #sb_instagram .sb_instagram_header a{
521
+ text-decoration: none;
522
+ }
523
+ #sb_instagram .sb_instagram_header .sbi_header_text .sbi_bio,
524
+ #sb_instagram .sb_instagram_header .sbi_header_text h3{
525
+ float: left;
526
+ clear: both;
527
+ width: auto;
528
+ margin: 0 0 0 60px !important;
529
+ padding: 0 !important;
530
+ }
531
+ #sb_instagram .sb_instagram_header h3{
532
+ font-size: 16px;
533
+ line-height: 1.3;
534
+ }
535
+ #sb_instagram .sb_instagram_header p{
536
+ font-size: 13px;
537
+ line-height: 1.3;
538
+ margin: 0;
539
+ padding: 0;
540
+ }
541
+ #sb_instagram p:empty { display: none; }
542
+ #sb_instagram .sb_instagram_header .sbi_header_text img.emoji{
543
+ margin-right: 3px !important;
544
+ }
545
+
546
+ /* No bio */
547
+ #sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio h3{
548
+ padding-top: 9px !important;
549
+ }
550
+ #sb_instagram .sb_instagram_header .sbi_header_text.sbi_no_bio .sbi_bio_info{
551
+ clear: both;
552
+ }
553
+
554
+
555
+ /* Buttons */
556
+ #sb_instagram #sbi_load{
557
+ float: left;
558
+ clear: both;
559
+ width: 100%;
560
+ text-align: center;
561
+ }
562
+ #sb_instagram #sbi_load .fa-spinner{
563
+ display: none;
564
+ position: absolute;
565
+ top: 50%;
566
+ left: 50%;
567
+ margin: -8px 0 0 -7px;
568
+ font-size: 15px;
569
+ }
570
+ #sb_instagram #sbi_load{
571
+ opacity: 1;
572
+ transition: all 0.5s ease-in;
573
+ }
574
+ #sb_instagram .sbi_load_btn .sbi_btn_text, #sb_instagram .sbi_load_btn .sbi_loader{
575
+ opacity: 1;
576
+ transition: all 0.1s ease-in;
577
+ }
578
+ #sb_instagram .sbi_hidden{
579
+ opacity: 0 !important;
580
+ }
581
+ #sb_instagram #sbi_load .sbi_load_btn,
582
+ #sb_instagram .sbi_follow_btn a{
583
+ display: -moz-inline-stack;
584
+ display: inline-block;
585
+ vertical-align: top;
586
+ zoom: 1;
587
+ *display: inline;
588
+
589
+ padding: 7px 14px;
590
+ margin: 5px auto 0 auto;
591
+ background: #333;
592
+ color: #eee;
593
+ border: none;
594
+ color: #fff;
595
+ text-decoration: none;
596
+ font-size: 13px;
597
+ line-height: 1.5;
598
+
599
+ -moz-border-radius: 4px;
600
+ -webkit-border-radius: 4px;
601
+ border-radius: 4px;
602
+
603
+ -webkit-box-sizing: border-box;
604
+ -moz-box-sizing: border-box;
605
+ box-sizing: border-box;
606
+ }
607
+ #sb_instagram #sbi_load .sbi_load_btn {
608
+ position: relative;
609
+ }
610
+ /* Follow button */
611
+ #sb_instagram .sbi_follow_btn{
612
+ display: -moz-inline-stack;
613
+ display: inline-block;
614
+ vertical-align: top;
615
+ zoom: 1;
616
+ *display: inline;
617
+ text-align: center;
618
+ }
619
+ #sb_instagram .sbi_follow_btn.sbi_top{
620
+ display: block;
621
+ margin-bottom: 5px;
622
+ }
623
+ #sb_instagram .sbi_follow_btn a{
624
+ background: #408bd1;
625
+ color: #fff;
626
+ }
627
+ #sb_instagram .sbi_follow_btn a,
628
+ #sb_instagram .sbi_follow_btn a,
629
+ #sb_instagram #sbi_load .sbi_load_btn{
630
+ transition: all 0.1s ease-in;
631
+ }
632
+ /* Hover state for default colors */
633
+ #sb_instagram #sbi_load .sbi_load_btn:hover{
634
+ outline: none;
635
+ box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.25);
636
+ }
637
+ #sb_instagram .sbi_follow_btn a:hover,
638
+ #sb_instagram .sbi_follow_btn a:focus{
639
+ outline: none;
640
+ box-shadow: inset 0 0 10px 20px #359dff;
641
+ }
642
+ /* If a custom color is applied then just use opacity for the hover effect */
643
+ #sb_instagram .sbi_follow_btn.sbi_custom a:hover,
644
+ #sb_instagram .sbi_follow_btn.sbi_custom a:focus,
645
+ #sb_instagram #sbi_load .sbi_load_btn.sbi_custom:hover{
646
+ box-shadow: inset 0 0 20px 20px rgba(255,255,255,0.15);
647
+ }
648
+ /* Active state */
649
+ #sb_instagram .sbi_follow_btn a:active,
650
+ #sb_instagram #sbi_load .sbi_load_btn:active{
651
+ box-shadow: inset 0 0 10px 20px rgba(0,0,0,0.3);
652
+ }
653
+
654
+ #sb_instagram .sbi_follow_btn .fa,
655
+ #sb_instagram .sbi_follow_btn svg{
656
+ margin-bottom: -1px;
657
+ margin-right: 7px;
658
+ font-size: 15px;
659
+ }
660
+ #sb_instagram .sbi_follow_btn svg{
661
+ vertical-align: -.125em;
662
+ }
663
+ #sb_instagram #sbi_load .sbi_follow_btn{
664
+ margin-left: 5px;
665
+ }
666
+
667
+ /* Error messages */
668
+ #sb_instagram .sb_instagram_error{
669
+ width: 100%;
670
+ text-align: center;
671
+ line-height: 1.4;
672
+ }
673
+
674
+ /* Mod only error msgs */
675
+ #sbi_mod_error{
676
+ display: none;
677
+ border: 1px solid #ddd;
678
+ background: #eee;
679
+ color: #333;
680
+ margin: 10px 0 0;
681
+ padding: 10px 15px;
682
+ font-size: 13px;
683
+ text-align: center;
684
+ clear: both;
685
+
686
+ -moz-border-radius: 4px;
687
+ -webkit-border-radius: 4px;
688
+ border-radius: 4px;
689
+ }
690
+ #sbi_mod_error br {
691
+ display: initial !important;
692
+ }
693
+ #sbi_mod_error p{
694
+ padding: 5px 0 !important;
695
+ margin: 0 !important;
696
+ line-height: 1.3 !important;
697
+ }
698
+ #sbi_mod_error ol,
699
+ #sbi_mod_error ul{
700
+ padding: 5px 0 5px 20px !important;
701
+ margin: 0 !important;
702
+ }
703
+ #sbi_mod_error li{
704
+ padding: 1px 0 !important;
705
+ margin: 0 !important;
706
+ }
707
+ #sbi_mod_error span{
708
+ font-size: 12px;
709
+ }
710
+
711
+ /* Medium */
712
+ #sb_instagram.sbi_medium .sbi_playbtn,
713
+ #sb_instagram.sbi_medium .sbi_photo_wrap .svg-inline--fa.fa-play{
714
+ margin-top: -12px;
715
+ margin-left: -9px;
716
+ font-size: 23px;
717
+ }
718
+ #sb_instagram.sbi_medium .sbi_type_carousel .sbi_photo_wrap .fa-clone{
719
+ right: 8px;
720
+ top: 8px;
721
+ font-size: 18px;
722
+ }
723
+ /* Small */
724
+ #sb_instagram.sbi_small .sbi_playbtn,
725
+ #sb_instagram.sbi_small .sbi_photo_wrap .svg-inline--fa.fa-play{
726
+ margin-top: -9px;
727
+ margin-left: -7px;
728
+ font-size: 18px;
729
+ }
730
+ #sb_instagram.sbi_small .sbi_type_carousel .sbi_photo_wrap .fa-clone{
731
+ right: 5px;
732
+ top: 5px;
733
+ font-size: 12px;
734
+ }
735
+
736
+ /* Media queries */
737
+ @media all and (max-width: 640px){
738
+ /* Make 3-6 cols into 2 col */
739
+ #sb_instagram.sbi_col_3 #sbi_images .sbi_item,
740
+ #sb_instagram.sbi_col_4 #sbi_images .sbi_item,
741
+ #sb_instagram.sbi_col_5 #sbi_images .sbi_item,
742
+ #sb_instagram.sbi_col_6 #sbi_images .sbi_item{
743
+ width: 50%;
744
+ }
745
+ /* Make 7-10 cols into 4 col */
746
+ #sb_instagram.sbi_col_7 #sbi_images .sbi_item,
747
+ #sb_instagram.sbi_col_8 #sbi_images .sbi_item,
748
+ #sb_instagram.sbi_col_9 #sbi_images .sbi_item,
749
+ #sb_instagram.sbi_col_10 #sbi_images .sbi_item{
750
+ width: 25%;
751
+ }
752
+ /* On mobile make the min-width 100% */
753
+ #sb_instagram.sbi_width_resp{
754
+ width: 100% !important;
755
+ }
756
+ }
757
+ @media all and (max-width: 480px){
758
+ /* Make all cols into 1 col */
759
+ #sb_instagram.sbi_col_3 #sbi_images .sbi_item,
760
+ #sb_instagram.sbi_col_4 #sbi_images .sbi_item,
761
+ #sb_instagram.sbi_col_5 #sbi_images .sbi_item,
762
+ #sb_instagram.sbi_col_6 #sbi_images .sbi_item,
763
+ #sb_instagram.sbi_col_7 #sbi_images .sbi_item,
764
+ #sb_instagram.sbi_col_8 #sbi_images .sbi_item,
765
+ #sb_instagram.sbi_col_9 #sbi_images .sbi_item,
766
+ #sb_instagram.sbi_col_10 #sbi_images .sbi_item{
767
+ width: 100%;
768
+ }
769
+ }
770
+
771
+ /* NO JS */
772
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap{
773
+ box-sizing: border-box;
774
+ position: relative;
775
+ overflow: hidden;
776
+ }
777
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo_wrap:before {
778
+ content: "";
779
+ display: block;
780
+ padding-top: 100%;
781
+ z-index: -300;
782
+ }
783
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item .sbi_photo {
784
+ position: absolute;
785
+ top: 0;
786
+ left: 0;
787
+ bottom: 0;
788
+ right: 0;
789
+ }
790
+ #sb_instagram.sbi_no_js #sbi_images .sbi_item.sbi_transition {
791
+ opacity: 1;
792
+ max-height: 640px;
793
+ }
794
+ #sb_instagram.sbi_no_js .sbi_photo img,
795
+ #sb_instagram.sbi_no_js .sbi_load_btn{
796
+ display: none;
797
+ }
798
+ #sb_instagram #sbi_images .sbi_js_load_disabled .sbi_imgLiquid_ready.sbi_photo {
799
+ padding-bottom: 0 !important;
800
+ }
801
+ #sb_instagram #sbi_mod_error .sb_frontend_btn {
802
+ display: inline-block;
803
+ padding: 6px 10px;
804
+ background: #ddd;
805
+ background: rgba(0,0,0,.1);
806
+ text-decoration: none;
807
+ border-radius: 5px;
808
+ margin-top: 10px;
809
+ color: #444
810
+ }
811
+
812
+ #sb_instagram #sbi_mod_error .sb_frontend_btn:hover {
813
+ background: #ccc;
814
+ background: rgba(0,0,0,.15)
815
+ }
816
+
817
+ #sb_instagram #sbi_mod_error .sb_frontend_btn .fa {
818
+ margin-right: 2px
819
  }
img/about/icon-full.svg CHANGED
File without changes
img/about/icon-none.svg CHANGED
File without changes
img/about/icon-partial.svg CHANGED
File without changes
img/about/plugin-mi.png CHANGED
File without changes
img/about/plugin-om.png CHANGED
File without changes
img/about/plugin-rp.png CHANGED
File without changes
img/about/plugin-smtp.png CHANGED
File without changes
img/about/plugin-wpforms.png CHANGED
File without changes
inc/admin/PluginSilentUpgrader.php CHANGED
@@ -1,576 +1,576 @@
1
- <?php
2
-
3
- namespace Sbi\Helpers;
4
-
5
- use WP_Error;
6
- use WP_Upgrader;
7
- use WP_Filesystem_Base;
8
-
9
- /** \WP_Upgrader class */
10
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
11
-
12
- /** \Plugin_Upgrader class */
13
- require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
14
-
15
- /**
16
- * In WP 5.3 a PHP 5.6 splat operator (...$args) was added to \WP_Upgrader_Skin::feedback().
17
- * We need to remove all calls to *Skin::feedback() method, as we can't override it in own Skins
18
- * without breaking support for PHP 5.3-5.5.
19
- *
20
- * @internal Please do not use this class outside of core WPForms development. May be removed at any time.
21
- *
22
- * @since 1.5.6.1
23
- */
24
- class PluginSilentUpgrader extends \Plugin_Upgrader {
25
-
26
- /**
27
- * Run an upgrade/installation.
28
- *
29
- * Attempts to download the package (if it is not a local file), unpack it, and
30
- * install it in the destination folder.
31
- *
32
- * @since 1.5.6.1
33
- *
34
- * @param array $options {
35
- * Array or string of arguments for upgrading/installing a package.
36
- *
37
- * @type string $package The full path or URI of the package to install.
38
- * Default empty.
39
- * @type string $destination The full path to the destination folder.
40
- * Default empty.
41
- * @type bool $clear_destination Whether to delete any files already in the
42
- * destination folder. Default false.
43
- * @type bool $clear_working Whether to delete the files form the working
44
- * directory after copying to the destination.
45
- * Default false.
46
- * @type bool $abort_if_destination_exists Whether to abort the installation if the destination
47
- * folder already exists. When true, `$clear_destination`
48
- * should be false. Default true.
49
- * @type bool $is_multi Whether this run is one of multiple upgrade/installation
50
- * actions being performed in bulk. When true, the skin
51
- * WP_Upgrader::header() and WP_Upgrader::footer()
52
- * aren't called. Default false.
53
- * @type array $hook_extra Extra arguments to pass to the filter hooks called by
54
- * WP_Upgrader::run().
55
- * }
56
- * @return array|false|WP_error The result from self::install_package() on success, otherwise a WP_Error,
57
- * or false if unable to connect to the filesystem.
58
- */
59
- public function run( $options ) {
60
-
61
- $defaults = array(
62
- 'package' => '', // Please always pass this.
63
- 'destination' => '', // And this
64
- 'clear_destination' => false,
65
- 'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please
66
- 'clear_working' => true,
67
- 'is_multi' => false,
68
- 'hook_extra' => array(), // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
69
- );
70
-
71
- $options = wp_parse_args( $options, $defaults );
72
-
73
- /**
74
- * Filters the package options before running an update.
75
- *
76
- * See also {@see 'upgrader_process_complete'}.
77
- *
78
- * @since 4.3.0
79
- *
80
- * @param array $options {
81
- * Options used by the upgrader.
82
- *
83
- * @type string $package Package for update.
84
- * @type string $destination Update location.
85
- * @type bool $clear_destination Clear the destination resource.
86
- * @type bool $clear_working Clear the working resource.
87
- * @type bool $abort_if_destination_exists Abort if the Destination directory exists.
88
- * @type bool $is_multi Whether the upgrader is running multiple times.
89
- * @type array $hook_extra {
90
- * Extra hook arguments.
91
- *
92
- * @type string $action Type of action. Default 'update'.
93
- * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'.
94
- * @type bool $bulk Whether the update process is a bulk update. Default true.
95
- * @type string $plugin Path to the plugin file relative to the plugins directory.
96
- * @type string $theme The stylesheet or template name of the theme.
97
- * @type string $language_update_type The language pack update type. Accepts 'plugin', 'theme',
98
- * or 'core'.
99
- * @type object $language_update The language pack update offer.
100
- * }
101
- * }
102
- */
103
- $options = apply_filters( 'upgrader_package_options', $options );
104
-
105
- if ( ! $options['is_multi'] ) { // call $this->header separately if running multiple times
106
- $this->skin->header();
107
- }
108
-
109
- // Connect to the Filesystem first.
110
- $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) );
111
- // Mainly for non-connected filesystem.
112
- if ( ! $res ) {
113
- if ( ! $options['is_multi'] ) {
114
- $this->skin->footer();
115
- }
116
- return false;
117
- }
118
-
119
- $this->skin->before();
120
-
121
- if ( is_wp_error( $res ) ) {
122
- $this->skin->error( $res );
123
- $this->skin->after();
124
- if ( ! $options['is_multi'] ) {
125
- $this->skin->footer();
126
- }
127
- return $res;
128
- }
129
-
130
- /*
131
- * Download the package (Note, This just returns the filename
132
- * of the file if the package is a local file)
133
- */
134
- $download = $this->download_package( $options['package'], true );
135
-
136
- // Allow for signature soft-fail.
137
- // WARNING: This may be removed in the future.
138
- if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
139
-
140
- // Don't output the 'no signature could be found' failure message for now.
141
- if ( 'signature_verification_no_signature' != $download->get_error_code() || WP_DEBUG ) {
142
- // Outout the failure error as a normal feedback, and not as an error:
143
- //$this->skin->feedback( $download->get_error_message() );
144
-
145
- // Report this failure back to WordPress.org for debugging purposes.
146
- wp_version_check(
147
- array(
148
- 'signature_failure_code' => $download->get_error_code(),
149
- 'signature_failure_data' => $download->get_error_data(),
150
- )
151
- );
152
- }
153
-
154
- // Pretend this error didn't happen.
155
- $download = $download->get_error_data( 'softfail-filename' );
156
- }
157
-
158
- if ( is_wp_error( $download ) ) {
159
- $this->skin->error( $download );
160
- $this->skin->after();
161
- if ( ! $options['is_multi'] ) {
162
- $this->skin->footer();
163
- }
164
- return $download;
165
- }
166
-
167
- $delete_package = ( $download != $options['package'] ); // Do not delete a "local" file
168
-
169
- // Unzips the file into a temporary directory.
170
- $working_dir = $this->unpack_package( $download, $delete_package );
171
- if ( is_wp_error( $working_dir ) ) {
172
- $this->skin->error( $working_dir );
173
- $this->skin->after();
174
- if ( ! $options['is_multi'] ) {
175
- $this->skin->footer();
176
- }
177
- return $working_dir;
178
- }
179
-
180
- // With the given options, this installs it to the destination directory.
181
- $result = $this->install_package(
182
- array(
183
- 'source' => $working_dir,
184
- 'destination' => $options['destination'],
185
- 'clear_destination' => $options['clear_destination'],
186
- 'abort_if_destination_exists' => $options['abort_if_destination_exists'],
187
- 'clear_working' => $options['clear_working'],
188
- 'hook_extra' => $options['hook_extra'],
189
- )
190
- );
191
-
192
- $this->skin->set_result( $result );
193
- if ( is_wp_error( $result ) ) {
194
- $this->skin->error( $result );
195
- //$this->skin->feedback( 'process_failed' );
196
- } else {
197
- // Installation succeeded.
198
- //$this->skin->feedback( 'process_success' );
199
- }
200
-
201
- $this->skin->after();
202
-
203
- if ( ! $options['is_multi'] ) {
204
-
205
- /**
206
- * Fires when the upgrader process is complete.
207
- *
208
- * See also {@see 'upgrader_package_options'}.
209
- *
210
- * @since 3.6.0
211
- * @since 3.7.0 Added to WP_Upgrader::run().
212
- * @since 4.6.0 `$translations` was added as a possible argument to `$hook_extra`.
213
- *
214
- * @param WP_Upgrader $this WP_Upgrader instance. In other contexts, $this, might be a
215
- * Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance.
216
- * @param array $hook_extra {
217
- * Array of bulk item update data.
218
- *
219
- * @type string $action Type of action. Default 'update'.
220
- * @type string $type Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
221
- * @type bool $bulk Whether the update process is a bulk update. Default true.
222
- * @type array $plugins Array of the basename paths of the plugins' main files.
223
- * @type array $themes The theme slugs.
224
- * @type array $translations {
225
- * Array of translations update data.
226
- *
227
- * @type string $language The locale the translation is for.
228
- * @type string $type Type of translation. Accepts 'plugin', 'theme', or 'core'.
229
- * @type string $slug Text domain the translation is for. The slug of a theme/plugin or
230
- * 'default' for core translations.
231
- * @type string $version The version of a theme, plugin, or core.
232
- * }
233
- * }
234
- */
235
- do_action( 'upgrader_process_complete', $this, $options['hook_extra'] );
236
-
237
- $this->skin->footer();
238
- }
239
-
240
- return $result;
241
- }
242
-
243
- /**
244
- * Toggle maintenance mode for the site.
245
- *
246
- * Create/delete the maintenance file to enable/disable maintenance mode.
247
- *
248
- * @since 2.8.0
249
- *
250
- * @global WP_Filesystem_Base $wp_filesystem Subclass
251
- *
252
- * @param bool $enable True to enable maintenance mode, false to disable.
253
- */
254
- public function maintenance_mode( $enable = false ) {
255
- global $wp_filesystem;
256
- $file = $wp_filesystem->abspath() . '.maintenance';
257
- if ( $enable ) {
258
- //$this->skin->feedback( 'maintenance_start' );
259
- // Create maintenance file to signal that we are upgrading
260
- $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
261
- $wp_filesystem->delete( $file );
262
- $wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE );
263
- } elseif ( ! $enable && $wp_filesystem->exists( $file ) ) {
264
- //$this->skin->feedback( 'maintenance_end' );
265
- $wp_filesystem->delete( $file );
266
- }
267
- }
268
-
269
- /**
270
- * Download a package.
271
- *
272
- * @since 2.8.0
273
- *
274
- * @param string $package The URI of the package. If this is the full path to an
275
- * existing local file, it will be returned untouched.
276
- * @param bool $check_signatures Whether to validate file signatures. Default false.
277
- * @return string|WP_Error The full path to the downloaded package file, or a WP_Error object.
278
- */
279
- public function download_package( $package, $check_signatures = false ) {
280
-
281
- /**
282
- * Filters whether to return the package.
283
- *
284
- * @since 3.7.0
285
- *
286
- * @param bool $reply Whether to bail without returning the package.
287
- * Default false.
288
- * @param string $package The package file name.
289
- * @param WP_Upgrader $this The WP_Upgrader instance.
290
- */
291
- $reply = apply_filters( 'upgrader_pre_download', false, $package, $this );
292
- if ( false !== $reply ) {
293
- return $reply;
294
- }
295
-
296
- if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { //Local file or remote?
297
- return $package; //must be a local file..
298
- }
299
-
300
- if ( empty( $package ) ) {
301
- return new WP_Error( 'no_package', $this->strings['no_package'] );
302
- }
303
-
304
- //$this->skin->feedback( 'downloading_package', $package );
305
-
306
- $download_file = download_url( $package, 300, $check_signatures );
307
-
308
- if ( is_wp_error( $download_file ) && ! $download_file->get_error_data( 'softfail-filename' ) ) {
309
- return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() );
310
- }
311
-
312
- return $download_file;
313
- }
314
-
315
- /**
316
- * Unpack a compressed package file.
317
- *
318
- * @since 2.8.0
319
- *
320
- * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
321
- *
322
- * @param string $package Full path to the package file.
323
- * @param bool $delete_package Optional. Whether to delete the package file after attempting
324
- * to unpack it. Default true.
325
- * @return string|WP_Error The path to the unpacked contents, or a WP_Error on failure.
326
- */
327
- public function unpack_package( $package, $delete_package = true ) {
328
- global $wp_filesystem;
329
-
330
- //$this->skin->feedback( 'unpack_package' );
331
-
332
- $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
333
-
334
- //Clean up contents of upgrade directory beforehand.
335
- $upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
336
- if ( ! empty( $upgrade_files ) ) {
337
- foreach ( $upgrade_files as $file ) {
338
- $wp_filesystem->delete( $upgrade_folder . $file['name'], true );
339
- }
340
- }
341
-
342
- // We need a working directory - Strip off any .tmp or .zip suffixes
343
- $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
344
-
345
- // Clean up working directory
346
- if ( $wp_filesystem->is_dir( $working_dir ) ) {
347
- $wp_filesystem->delete( $working_dir, true );
348
- }
349
-
350
- // Unzip package to working directory
351
- $result = unzip_file( $package, $working_dir );
352
-
353
- // Once extracted, delete the package if required.
354
- if ( $delete_package ) {
355
- unlink( $package );
356
- }
357
-
358
- if ( is_wp_error( $result ) ) {
359
- $wp_filesystem->delete( $working_dir, true );
360
- if ( 'incompatible_archive' == $result->get_error_code() ) {
361
- return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() );
362
- }
363
- return $result;
364
- }
365
-
366
- return $working_dir;
367
- }
368
-
369
- /**
370
- * Install a package.
371
- *
372
- * Copies the contents of a package form a source directory, and installs them in
373
- * a destination directory. Optionally removes the source. It can also optionally
374
- * clear out the destination folder if it already exists.
375
- *
376
- * @since 2.8.0
377
- *
378
- * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
379
- * @global array $wp_theme_directories
380
- *
381
- * @param array|string $args {
382
- * Optional. Array or string of arguments for installing a package. Default empty array.
383
- *
384
- * @type string $source Required path to the package source. Default empty.
385
- * @type string $destination Required path to a folder to install the package in.
386
- * Default empty.
387
- * @type bool $clear_destination Whether to delete any files already in the destination
388
- * folder. Default false.
389
- * @type bool $clear_working Whether to delete the files form the working directory
390
- * after copying to the destination. Default false.
391
- * @type bool $abort_if_destination_exists Whether to abort the installation if
392
- * the destination folder already exists. Default true.
393
- * @type array $hook_extra Extra arguments to pass to the filter hooks called by
394
- * WP_Upgrader::install_package(). Default empty array.
395
- * }
396
- *
397
- * @return array|WP_Error The result (also stored in `WP_Upgrader::$result`), or a WP_Error on failure.
398
- */
399
- public function install_package( $args = array() ) {
400
- global $wp_filesystem, $wp_theme_directories;
401
-
402
- $defaults = array(
403
- 'source' => '', // Please always pass this
404
- 'destination' => '', // and this
405
- 'clear_destination' => false,
406
- 'clear_working' => false,
407
- 'abort_if_destination_exists' => true,
408
- 'hook_extra' => array(),
409
- );
410
-
411
- $args = wp_parse_args( $args, $defaults );
412
-
413
- // These were previously extract()'d.
414
- $source = $args['source'];
415
- $destination = $args['destination'];
416
- $clear_destination = $args['clear_destination'];
417
-
418
- set_time_limit( 300 );
419
-
420
- if ( empty( $source ) || empty( $destination ) ) {
421
- return new WP_Error( 'bad_request', $this->strings['bad_request'] );
422
- }
423
- //$this->skin->feedback( 'installing_package' );
424
-
425
- /**
426
- * Filters the install response before the installation has started.
427
- *
428
- * Returning a truthy value, or one that could be evaluated as a WP_Error
429
- * will effectively short-circuit the installation, returning that value
430
- * instead.
431
- *
432
- * @since 2.8.0
433
- *
434
- * @param bool|WP_Error $response Response.
435
- * @param array $hook_extra Extra arguments passed to hooked filters.
436
- */
437
- $res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] );
438
-
439
- if ( is_wp_error( $res ) ) {
440
- return $res;
441
- }
442
-
443
- //Retain the Original source and destinations
444
- $remote_source = $args['source'];
445
- $local_destination = $destination;
446
-
447
- $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) );
448
- $remote_destination = $wp_filesystem->find_folder( $local_destination );
449
-
450
- //Locate which directory to copy to the new folder, This is based on the actual folder holding the files.
451
- if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { //Only one folder? Then we want its contents.
452
- $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
453
- } elseif ( count( $source_files ) == 0 ) {
454
- return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); // There are no files?
455
- } else { // It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename.
456
- $source = trailingslashit( $args['source'] );
457
- }
458
-
459
- /**
460
- * Filters the source file location for the upgrade package.
461
- *
462
- * @since 2.8.0
463
- * @since 4.4.0 The $hook_extra parameter became available.
464
- *
465
- * @param string $source File source location.
466
- * @param string $remote_source Remote file source location.
467
- * @param WP_Upgrader $this WP_Upgrader instance.
468
- * @param array $hook_extra Extra arguments passed to hooked filters.
469
- */
470
- $source = apply_filters( 'upgrader_source_selection', $source, $remote_source, $this, $args['hook_extra'] );
471
-
472
- if ( is_wp_error( $source ) ) {
473
- return $source;
474
- }
475
-
476
- // Has the source location changed? If so, we need a new source_files list.
477
- if ( $source !== $remote_source ) {
478
- $source_files = array_keys( $wp_filesystem->dirlist( $source ) );
479
- }
480
-
481
- /*
482
- * Protection against deleting files in any important base directories.
483
- * Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the
484
- * destination directory (WP_PLUGIN_DIR / wp-content/themes) intending
485
- * to copy the directory into the directory, whilst they pass the source
486
- * as the actual files to copy.
487
- */
488
- $protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' );
489
-
490
- if ( is_array( $wp_theme_directories ) ) {
491
- $protected_directories = array_merge( $protected_directories, $wp_theme_directories );
492
- }
493
-
494
- if ( in_array( $destination, $protected_directories ) ) {
495
- $remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) );
496
- $destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) );
497
- }
498
-
499
- if ( $clear_destination ) {
500
- // We're going to clear the destination if there's something there.
501
- //$this->skin->feedback( 'remove_old' );
502
-
503
- $removed = $this->clear_destination( $remote_destination );
504
-
505
- /**
506
- * Filters whether the upgrader cleared the destination.
507
- *
508
- * @since 2.8.0
509
- *
510
- * @param mixed $removed Whether the destination was cleared. true on success, WP_Error on failure
511
- * @param string $local_destination The local package destination.
512
- * @param string $remote_destination The remote package destination.
513
- * @param array $hook_extra Extra arguments passed to hooked filters.
514
- */
515
- $removed = apply_filters( 'upgrader_clear_destination', $removed, $local_destination, $remote_destination, $args['hook_extra'] );
516
-
517
- if ( is_wp_error( $removed ) ) {
518
- return $removed;
519
- }
520
- } elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) {
521
- //If we're not clearing the destination folder and something exists there already, Bail.
522
- //But first check to see if there are actually any files in the folder.
523
- $_files = $wp_filesystem->dirlist( $remote_destination );
524
- if ( ! empty( $_files ) ) {
525
- $wp_filesystem->delete( $remote_source, true ); //Clear out the source files.
526
- return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination );
527
- }
528
- }
529
-
530
- //Create destination if needed
531
- if ( ! $wp_filesystem->exists( $remote_destination ) ) {
532
- if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
533
- return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination );
534
- }
535
- }
536
- // Copy new version of item into place.
537
- $result = copy_dir( $source, $remote_destination );
538
- if ( is_wp_error( $result ) ) {
539
- if ( $args['clear_working'] ) {
540
- $wp_filesystem->delete( $remote_source, true );
541
- }
542
- return $result;
543
- }
544
-
545
- //Clear the Working folder?
546
- if ( $args['clear_working'] ) {
547
- $wp_filesystem->delete( $remote_source, true );
548
- }
549
-
550
- $destination_name = basename( str_replace( $local_destination, '', $destination ) );
551
- if ( '.' == $destination_name ) {
552
- $destination_name = '';
553
- }
554
-
555
- $this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' );
556
-
557
- /**
558
- * Filters the installation response after the installation has finished.
559
- *
560
- * @since 2.8.0
561
- *
562
- * @param bool $response Installation response.
563
- * @param array $hook_extra Extra arguments passed to hooked filters.
564
- * @param array $result Installation result data.
565
- */
566
- $res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result );
567
-
568
- if ( is_wp_error( $res ) ) {
569
- $this->result = $res;
570
- return $res;
571
- }
572
-
573
- //Bombard the calling function will all the info which we've just used.
574
- return $this->result;
575
- }
576
- }
1
+ <?php
2
+
3
+ namespace Sbi\Helpers;
4
+
5
+ use WP_Error;
6
+ use WP_Upgrader;
7
+ use WP_Filesystem_Base;
8
+
9
+ /** \WP_Upgrader class */
10
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
11
+
12
+ /** \Plugin_Upgrader class */
13
+ require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
14
+
15
+ /**
16
+ * In WP 5.3 a PHP 5.6 splat operator (...$args) was added to \WP_Upgrader_Skin::feedback().
17
+ * We need to remove all calls to *Skin::feedback() method, as we can't override it in own Skins
18
+ * without breaking support for PHP 5.3-5.5.
19
+ *
20
+ * @internal Please do not use this class outside of core WPForms development. May be removed at any time.
21
+ *
22
+ * @since 1.5.6.1
23
+ */
24
+ class PluginSilentUpgrader extends \Plugin_Upgrader {
25
+
26
+ /**
27
+ * Run an upgrade/installation.
28
+ *
29
+ * Attempts to download the package (if it is not a local file), unpack it, and
30
+ * install it in the destination folder.
31
+ *
32
+ * @since 1.5.6.1
33
+ *
34
+ * @param array $options {
35
+ * Array or string of arguments for upgrading/installing a package.
36
+ *
37
+ * @type string $package The full path or URI of the package to install.
38
+ * Default empty.
39
+ * @type string $destination The full path to the destination folder.
40
+ * Default empty.
41
+ * @type bool $clear_destination Whether to delete any files already in the
42
+ * destination folder. Default false.
43
+ * @type bool $clear_working Whether to delete the files form the working
44
+ * directory after copying to the destination.
45
+ * Default false.
46
+ * @type bool $abort_if_destination_exists Whether to abort the installation if the destination
47
+ * folder already exists. When true, `$clear_destination`
48
+ * should be false. Default true.
49
+ * @type bool $is_multi Whether this run is one of multiple upgrade/installation
50
+ * actions being performed in bulk. When true, the skin
51
+ * WP_Upgrader::header() and WP_Upgrader::footer()
52
+ * aren't called. Default false.
53
+ * @type array $hook_extra Extra arguments to pass to the filter hooks called by
54
+ * WP_Upgrader::run().
55
+ * }
56
+ * @return array|false|WP_error The result from self::install_package() on success, otherwise a WP_Error,
57
+ * or false if unable to connect to the filesystem.
58
+ */
59
+ public function run( $options ) {
60
+
61
+ $defaults = array(
62
+ 'package' => '', // Please always pass this.
63
+ 'destination' => '', // And this
64
+ 'clear_destination' => false,
65
+ 'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please
66
+ 'clear_working' => true,
67
+ 'is_multi' => false,
68
+ 'hook_extra' => array(), // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
69
+ );
70
+
71
+ $options = wp_parse_args( $options, $defaults );
72
+
73
+ /**
74
+ * Filters the package options before running an update.
75
+ *
76
+ * See also {@see 'upgrader_process_complete'}.
77
+ *
78
+ * @since 4.3.0
79
+ *
80
+ * @param array $options {
81
+ * Options used by the upgrader.
82
+ *
83
+ * @type string $package Package for update.
84
+ * @type string $destination Update location.
85
+ * @type bool $clear_destination Clear the destination resource.
86
+ * @type bool $clear_working Clear the working resource.
87
+ * @type bool $abort_if_destination_exists Abort if the Destination directory exists.
88
+ * @type bool $is_multi Whether the upgrader is running multiple times.
89
+ * @type array $hook_extra {
90
+ * Extra hook arguments.
91
+ *
92
+ * @type string $action Type of action. Default 'update'.
93
+ * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'.
94
+ * @type bool $bulk Whether the update process is a bulk update. Default true.
95
+ * @type string $plugin Path to the plugin file relative to the plugins directory.
96
+ * @type string $theme The stylesheet or template name of the theme.
97
+ * @type string $language_update_type The language pack update type. Accepts 'plugin', 'theme',
98
+ * or 'core'.
99
+ * @type object $language_update The language pack update offer.
100
+ * }
101
+ * }
102
+ */
103
+ $options = apply_filters( 'upgrader_package_options', $options );
104
+
105
+ if ( ! $options['is_multi'] ) { // call $this->header separately if running multiple times
106
+ $this->skin->header();
107
+ }
108
+
109
+ // Connect to the Filesystem first.
110
+ $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) );
111
+ // Mainly for non-connected filesystem.
112
+ if ( ! $res ) {
113
+ if ( ! $options['is_multi'] ) {
114
+ $this->skin->footer();
115
+ }
116
+ return false;
117
+ }
118
+
119
+ $this->skin->before();
120
+
121
+ if ( is_wp_error( $res ) ) {
122
+ $this->skin->error( $res );
123
+ $this->skin->after();
124
+ if ( ! $options['is_multi'] ) {
125
+ $this->skin->footer();
126
+ }
127
+ return $res;
128
+ }
129
+
130
+ /*
131
+ * Download the package (Note, This just returns the filename
132
+ * of the file if the package is a local file)
133
+ */
134
+ $download = $this->download_package( $options['package'], true );
135
+
136
+ // Allow for signature soft-fail.
137
+ // WARNING: This may be removed in the future.
138
+ if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
139
+
140
+ // Don't output the 'no signature could be found' failure message for now.
141
+ if ( 'signature_verification_no_signature' != $download->get_error_code() || WP_DEBUG ) {
142
+ // Outout the failure error as a normal feedback, and not as an error:
143
+ //$this->skin->feedback( $download->get_error_message() );
144
+
145
+ // Report this failure back to WordPress.org for debugging purposes.
146
+ wp_version_check(
147
+ array(
148
+ 'signature_failure_code' => $download->get_error_code(),
149
+ 'signature_failure_data' => $download->get_error_data(),
150
+ )
151
+ );
152
+ }
153
+
154
+ // Pretend this error didn't happen.
155
+ $download = $download->get_error_data( 'softfail-filename' );
156
+ }
157
+
158
+ if ( is_wp_error( $download ) ) {
159
+ $this->skin->error( $download );
160
+ $this->skin->after();
161
+ if ( ! $options['is_multi'] ) {
162
+ $this->skin->footer();
163
+ }
164
+ return $download;
165
+ }
166
+
167
+ $delete_package = ( $download != $options['package'] ); // Do not delete a "local" file
168
+
169
+ // Unzips the file into a temporary directory.
170
+ $working_dir = $this->unpack_package( $download, $delete_package );
171
+ if ( is_wp_error( $working_dir ) ) {
172
+ $this->skin->error( $working_dir );
173
+ $this->skin->after();
174
+ if ( ! $options['is_multi'] ) {
175
+ $this->skin->footer();
176
+ }
177
+ return $working_dir;
178
+ }
179
+
180
+ // With the given options, this installs it to the destination directory.
181
+ $result = $this->install_package(
182
+ array(
183
+ 'source' => $working_dir,
184
+ 'destination' => $options['destination'],
185
+ 'clear_destination' => $options['clear_destination'],
186
+ 'abort_if_destination_exists' => $options['abort_if_destination_exists'],
187
+ 'clear_working' => $options['clear_working'],
188
+ 'hook_extra' => $options['hook_extra'],
189
+ )
190
+ );
191
+
192
+ $this->skin->set_result( $result );
193
+ if ( is_wp_error( $result ) ) {
194
+ $this->skin->error( $result );
195
+ //$this->skin->feedback( 'process_failed' );
196
+ } else {
197
+ // Installation succeeded.
198
+ //$this->skin->feedback( 'process_success' );
199
+ }
200
+
201
+ $this->skin->after();
202
+
203
+ if ( ! $options['is_multi'] ) {
204
+
205
+ /**
206
+ * Fires when the upgrader process is complete.
207
+ *
208
+ * See also {@see 'upgrader_package_options'}.
209
+ *
210
+ * @since 3.6.0
211
+ * @since 3.7.0 Added to WP_Upgrader::run().
212
+ * @since 4.6.0 `$translations` was added as a possible argument to `$hook_extra`.
213
+ *
214
+ * @param WP_Upgrader $this WP_Upgrader instance. In other contexts, $this, might be a
215
+ * Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance.
216
+ * @param array $hook_extra {
217
+ * Array of bulk item update data.
218
+ *
219
+ * @type string $action Type of action. Default 'update'.
220
+ * @type string $type Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
221
+ * @type bool $bulk Whether the update process is a bulk update. Default true.
222
+ * @type array $plugins Array of the basename paths of the plugins' main files.
223
+ * @type array $themes The theme slugs.
224
+ * @type array $translations {
225
+ * Array of translations update data.
226
+ *
227
+ * @type string $language The locale the translation is for.
228
+ * @type string $type Type of translation. Accepts 'plugin', 'theme', or 'core'.
229
+ * @type string $slug Text domain the translation is for. The slug of a theme/plugin or
230
+ * 'default' for core translations.
231
+ * @type string $version The version of a theme, plugin, or core.
232
+ * }
233
+ * }
234
+ */
235
+ do_action( 'upgrader_process_complete', $this, $options['hook_extra'] );
236
+
237
+ $this->skin->footer();
238
+ }
239
+
240
+ return $result;
241
+ }
242
+
243
+ /**
244
+ * Toggle maintenance mode for the site.
245
+ *
246
+ * Create/delete the maintenance file to enable/disable maintenance mode.
247
+ *
248
+ * @since 2.8.0
249
+ *
250
+ * @global WP_Filesystem_Base $wp_filesystem Subclass
251
+ *
252
+ * @param bool $enable True to enable maintenance mode, false to disable.
253
+ */
254
+ public function maintenance_mode( $enable = false ) {
255
+ global $wp_filesystem;
256
+ $file = $wp_filesystem->abspath() . '.maintenance';
257
+ if ( $enable ) {
258
+ //$this->skin->feedback( 'maintenance_start' );
259
+ // Create maintenance file to signal that we are upgrading
260
+ $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
261
+ $wp_filesystem->delete( $file );
262
+ $wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE );
263
+ } elseif ( ! $enable && $wp_filesystem->exists( $file ) ) {
264
+ //$this->skin->feedback( 'maintenance_end' );
265
+ $wp_filesystem->delete( $file );
266
+ }
267
+ }
268
+
269
+ /**
270
+ * Download a package.
271
+ *
272
+ * @since 2.8.0
273
+ *
274
+ * @param string $package The URI of the package. If this is the full path to an
275
+ * existing local file, it will be returned untouched.
276
+ * @param bool $check_signatures Whether to validate file signatures. Default false.
277
+ * @return string|WP_Error The full path to the downloaded package file, or a WP_Error object.
278
+ */
279
+ public function download_package( $package, $check_signatures = false ) {
280
+
281
+ /**
282
+ * Filters whether to return the package.
283
+ *
284
+ * @since 3.7.0
285
+ *
286
+ * @param bool $reply Whether to bail without returning the package.
287
+ * Default false.
288
+ * @param string $package The package file name.
289
+ * @param WP_Upgrader $this The WP_Upgrader instance.
290
+ */
291
+ $reply = apply_filters( 'upgrader_pre_download', false, $package, $this );
292
+ if ( false !== $reply ) {
293
+ return $reply;
294
+ }
295
+
296
+ if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { //Local file or remote?
297
+ return $package; //must be a local file..
298
+ }
299
+
300
+ if ( empty( $package ) ) {
301
+ return new WP_Error( 'no_package', $this->strings['no_package'] );
302
+ }
303
+
304
+ //$this->skin->feedback( 'downloading_package', $package );
305
+
306
+ $download_file = download_url( $package, 300, $check_signatures );
307
+
308
+ if ( is_wp_error( $download_file ) && ! $download_file->get_error_data( 'softfail-filename' ) ) {
309
+ return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() );
310
+ }
311
+
312
+ return $download_file;
313
+ }
314
+
315
+ /**
316
+ * Unpack a compressed package file.
317
+ *
318
+ * @since 2.8.0
319
+ *
320
+ * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
321
+ *
322
+ * @param string $package Full path to the package file.
323
+ * @param bool $delete_package Optional. Whether to delete the package file after attempting
324
+ * to unpack it. Default true.
325
+ * @return string|WP_Error The path to the unpacked contents, or a WP_Error on failure.
326
+ */
327
+ public function unpack_package( $package, $delete_package = true ) {
328
+ global $wp_filesystem;
329
+
330
+ //$this->skin->feedback( 'unpack_package' );
331
+
332
+ $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
333
+
334
+ //Clean up contents of upgrade directory beforehand.
335
+ $upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
336
+ if ( ! empty( $upgrade_files ) ) {
337
+ foreach ( $upgrade_files as $file ) {
338
+ $wp_filesystem->delete( $upgrade_folder . $file['name'], true );
339
+ }
340
+ }
341
+
342
+ // We need a working directory - Strip off any .tmp or .zip suffixes
343
+ $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
344
+
345
+ // Clean up working directory
346
+ if ( $wp_filesystem->is_dir( $working_dir ) ) {
347
+ $wp_filesystem->delete( $working_dir, true );
348
+ }
349
+
350
+ // Unzip package to working directory
351
+ $result = unzip_file( $package, $working_dir );
352
+
353
+ // Once extracted, delete the package if required.
354
+ if ( $delete_package ) {
355
+ unlink( $package );
356
+ }
357
+
358
+ if ( is_wp_error( $result ) ) {
359
+ $wp_filesystem->delete( $working_dir, true );
360
+ if ( 'incompatible_archive' == $result->get_error_code() ) {
361
+ return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() );
362
+ }
363
+ return $result;
364
+ }
365
+
366
+ return $working_dir;
367
+ }
368
+
369
+ /**
370
+ * Install a package.
371
+ *
372
+ * Copies the contents of a package form a source directory, and installs them in
373
+ * a destination directory. Optionally removes the source. It can also optionally
374
+ * clear out the destination folder if it already exists.
375
+ *
376
+ * @since 2.8.0
377
+ *
378
+ * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
379
+ * @global array $wp_theme_directories
380
+ *
381
+ * @param array|string $args {
382
+ * Optional. Array or string of arguments for installing a package. Default empty array.
383
+ *
384
+ * @type string $source Required path to the package source. Default empty.
385
+ * @type string $destination Required path to a folder to install the package in.
386
+ * Default empty.
387
+ * @type bool $clear_destination Whether to delete any files already in the destination
388
+ * folder. Default false.
389
+ * @type bool $clear_working Whether to delete the files form the working directory
390
+ * after copying to the destination. Default false.
391
+ * @type bool $abort_if_destination_exists Whether to abort the installation if
392
+ * the destination folder already exists. Default true.
393
+ * @type array $hook_extra Extra arguments to pass to the filter hooks called by
394
+ * WP_Upgrader::install_package(). Default empty array.
395
+ * }
396
+ *
397
+ * @return array|WP_Error The result (also stored in `WP_Upgrader::$result`), or a WP_Error on failure.
398
+ */
399
+ public function install_package( $args = array() ) {
400
+ global $wp_filesystem, $wp_theme_directories;
401
+
402
+ $defaults = array(
403
+ 'source' => '', // Please always pass this
404
+ 'destination' => '', // and this
405
+ 'clear_destination' => false,
406
+ 'clear_working' => false,
407
+ 'abort_if_destination_exists' => true,
408
+ 'hook_extra' => array(),
409
+ );
410
+
411
+ $args = wp_parse_args( $args, $defaults );
412
+
413
+ // These were previously extract()'d.
414
+ $source = $args['source'];
415
+ $destination = $args['destination'];
416
+ $clear_destination = $args['clear_destination'];
417
+
418
+ set_time_limit( 300 );
419
+
420
+ if ( empty( $source ) || empty( $destination ) ) {
421
+ return new WP_Error( 'bad_request', $this->strings['bad_request'] );
422
+ }
423
+ //$this->skin->feedback( 'installing_package' );
424
+
425
+ /**
426
+ * Filters the install response before the installation has started.
427
+ *
428
+ * Returning a truthy value, or one that could be evaluated as a WP_Error
429
+ * will effectively short-circuit the installation, returning that value
430
+ * instead.
431
+ *
432
+ * @since 2.8.0
433
+ *
434
+ * @param bool|WP_Error $response Response.
435
+ * @param array $hook_extra Extra arguments passed to hooked filters.
436
+ */
437
+ $res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] );
438
+
439
+ if ( is_wp_error( $res ) ) {
440
+ return $res;
441
+ }
442
+
443
+ //Retain the Original source and destinations
444
+ $remote_source = $args['source'];
445
+ $local_destination = $destination;
446
+
447
+ $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) );
448
+ $remote_destination = $wp_filesystem->find_folder( $local_destination );
449
+
450
+ //Locate which directory to copy to the new folder, This is based on the actual folder holding the files.
451
+ if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { //Only one folder? Then we want its contents.
452
+ $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
453
+ } elseif ( count( $source_files ) == 0 ) {
454
+ return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); // There are no files?
455
+ } else { // It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename.
456
+ $source = trailingslashit( $args['source'] );
457
+ }
458
+
459
+ /**
460
+ * Filters the source file location for the upgrade package.
461
+ *
462
+ * @since 2.8.0
463
+ * @since 4.4.0 The $hook_extra parameter became available.
464
+ *
465
+ * @param string $source File source location.
466
+ * @param string $remote_source Remote file source location.
467
+ * @param WP_Upgrader $this WP_Upgrader instance.
468
+ * @param array $hook_extra Extra arguments passed to hooked filters.
469
+ */
470
+ $source = apply_filters( 'upgrader_source_selection', $source, $remote_source, $this, $args['hook_extra'] );
471
+
472
+ if ( is_wp_error( $source ) ) {
473
+ return $source;
474
+ }
475
+
476
+ // Has the source location changed? If so, we need a new source_files list.
477
+ if ( $source !== $remote_source ) {
478
+ $source_files = array_keys( $wp_filesystem->dirlist( $source ) );
479
+ }
480
+
481
+ /*
482
+ * Protection against deleting files in any important base directories.
483
+ * Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the
484
+ * destination directory (WP_PLUGIN_DIR / wp-content/themes) intending
485
+ * to copy the directory into the directory, whilst they pass the source
486
+ * as the actual files to copy.
487
+ */
488
+ $protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' );
489
+
490
+ if ( is_array( $wp_theme_directories ) ) {
491
+ $protected_directories = array_merge( $protected_directories, $wp_theme_directories );
492
+ }
493
+
494
+ if ( in_array( $destination, $protected_directories ) ) {
495
+ $remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) );
496
+ $destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) );
497
+ }
498
+
499
+ if ( $clear_destination ) {
500
+ // We're going to clear the destination if there's something there.
501
+ //$this->skin->feedback( 'remove_old' );
502
+
503
+ $removed = $this->clear_destination( $remote_destination );
504
+
505
+ /**
506
+ * Filters whether the upgrader cleared the destination.
507
+ *
508
+ * @since 2.8.0
509
+ *
510
+ * @param mixed $removed Whether the destination was cleared. true on success, WP_Error on failure
511
+ * @param string $local_destination The local package destination.
512
+ * @param string $remote_destination The remote package destination.
513
+ * @param array $hook_extra Extra arguments passed to hooked filters.
514
+ */
515
+ $removed = apply_filters( 'upgrader_clear_destination', $removed, $local_destination, $remote_destination, $args['hook_extra'] );
516
+
517
+ if ( is_wp_error( $removed ) ) {
518
+ return $removed;
519
+ }
520
+ } elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) {
521
+ //If we're not clearing the destination folder and something exists there already, Bail.
522
+ //But first check to see if there are actually any files in the folder.
523
+ $_files = $wp_filesystem->dirlist( $remote_destination );
524
+ if ( ! empty( $_files ) ) {
525
+ $wp_filesystem->delete( $remote_source, true ); //Clear out the source files.
526
+ return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination );
527
+ }
528
+ }
529
+
530
+ //Create destination if needed
531
+ if ( ! $wp_filesystem->exists( $remote_destination ) ) {
532
+ if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
533
+ return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination );
534
+ }
535
+ }
536
+ // Copy new version of item into place.
537
+ $result = copy_dir( $source, $remote_destination );
538
+ if ( is_wp_error( $result ) ) {
539
+ if ( $args['clear_working'] ) {
540
+ $wp_filesystem->delete( $remote_source, true );
541
+ }
542
+ return $result;
543
+ }
544
+
545
+ //Clear the Working folder?
546
+ if ( $args['clear_working'] ) {
547
+ $wp_filesystem->delete( $remote_source, true );
548
+ }
549
+
550
+ $destination_name = basename( str_replace( $local_destination, '', $destination ) );
551
+ if ( '.' == $destination_name ) {
552
+ $destination_name = '';
553
+ }
554
+
555
+ $this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' );
556
+
557
+ /**
558
+ * Filters the installation response after the installation has finished.
559
+ *
560
+ * @since 2.8.0
561
+ *
562
+ * @param bool $response Installation response.
563
+ * @param array $hook_extra Extra arguments passed to hooked filters.
564
+ * @param array $result Installation result data.
565
+ */
566
+ $res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result );
567
+
568
+ if ( is_wp_error( $res ) ) {
569
+ $this->result = $res;
570
+ return $res;
571
+ }
572
+
573
+ //Bombard the calling function will all the info which we've just used.
574
+ return $this->result;
575
+ }
576
+ }
inc/admin/PluginSilentUpgraderSkin.php CHANGED
@@ -1,57 +1,57 @@
1
- <?php
2
-
3
- namespace Sbi\Helpers;
4
-
5
- /** \WP_Upgrader_Skin class */
6
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader-skin.php';
7
-
8
- /**
9
- * Class PluginSilentUpgraderSkin.
10
- *
11
- * @internal Please do not use this class outside of core WPForms development. May be removed at any time.
12
- *
13
- * @since 1.5.6.1
14
- */
15
- class PluginSilentUpgraderSkin extends \WP_Upgrader_Skin {
16
-
17
- /**
18
- * Empty out the header of its HTML content and only check to see if it has
19
- * been performed or not.
20
- *
21
- * @since 1.5.6.1
22
- */
23
- public function header() {
24
- }
25
-
26
- /**
27
- * Empty out the footer of its HTML contents.
28
- *
29
- * @since 1.5.6.1
30
- */
31
- public function footer() {
32
- }
33
-
34
- /**
35
- * Instead of outputting HTML for errors, just return them.
36
- * Ajax request will just ignore it.
37
- *
38
- * @since 1.5.6.1
39
- *
40
- * @param array $errors Array of errors with the install process.
41
- *
42
- * @return array
43
- */
44
- public function error( $errors ) {
45
- return $errors;
46
- }
47
-
48
- /**
49
- * Empty out JavaScript output that calls function to decrement the update counts.
50
- *
51
- * @since 1.5.6.1
52
- *
53
- * @param string $type Type of update count to decrement.
54
- */
55
- public function decrement_update_count( $type ) {
56
- }
57
- }
1
+ <?php
2
+
3
+ namespace Sbi\Helpers;
4
+
5
+ /** \WP_Upgrader_Skin class */
6
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader-skin.php';
7
+
8
+ /**
9
+ * Class PluginSilentUpgraderSkin.
10
+ *
11
+ * @internal Please do not use this class outside of core WPForms development. May be removed at any time.
12
+ *
13
+ * @since 1.5.6.1
14
+ */
15
+ class PluginSilentUpgraderSkin extends \WP_Upgrader_Skin {
16
+
17
+ /**
18
+ * Empty out the header of its HTML content and only check to see if it has
19
+ * been performed or not.
20
+ *
21
+ * @since 1.5.6.1
22
+ */
23
+ public function header() {
24
+ }
25
+
26
+ /**
27
+ * Empty out the footer of its HTML contents.
28
+ *
29
+ * @since 1.5.6.1
30
+ */
31
+ public function footer() {
32
+ }
33
+
34
+ /**
35
+ * Instead of outputting HTML for errors, just return them.
36
+ * Ajax request will just ignore it.
37
+ *
38
+ * @since 1.5.6.1
39
+ *
40
+ * @param array $errors Array of errors with the install process.
41
+ *
42
+ * @return array
43
+ */
44
+ public function error( $errors ) {
45
+ return $errors;
46
+ }
47
+
48
+ /**
49
+ * Empty out JavaScript output that calls function to decrement the update counts.
50
+ *
51
+ * @since 1.5.6.1
52
+ *
53
+ * @param string $type Type of update count to decrement.
54
+ */
55
+ public function decrement_update_count( $type ) {
56
+ }
57
+ }
inc/admin/actions.php CHANGED
@@ -1,1270 +1,1340 @@
1
- <?php
2
- /**
3
- * Includes functions related to actions while in the admin area.
4
- *
5
- * - All AJAX related features
6
- * - Enqueueing of JS and CSS files
7
- * - Settings link on "Plugins" page
8
- * - Creation of local avatar image files
9
- * - Connecting accounts on the "Configure" tab
10
- * - Displaying admin notices
11
- * - Clearing caches
12
- */
13
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
-
15
- function sb_instagram_admin_style() {
16
- wp_register_style( 'sb_instagram_admin_css', SBI_PLUGIN_URL . 'css/sb-instagram-admin.css', array(), SBIVER );
17
- wp_enqueue_style( 'sb_instagram_font_awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' );
18
- wp_enqueue_style( 'sb_instagram_admin_css' );
19
- wp_enqueue_style( 'wp-color-picker' );
20
- }
21
- add_action( 'admin_enqueue_scripts', 'sb_instagram_admin_style' );
22
-
23
- function sb_instagram_admin_scripts() {
24
- wp_enqueue_script( 'sb_instagram_admin_js', SBI_PLUGIN_URL . 'js/sb-instagram-admin-2-2.js', array(), SBIVER );
25
- wp_localize_script( 'sb_instagram_admin_js', 'sbiA', array(
26
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
27
- 'sbi_nonce' => wp_create_nonce( 'sbi_nonce' )
28
- )
29
- );
30
- $strings = array(
31
- 'addon_activate' => esc_html__( 'Activate', 'instagram-feed' ),
32
- 'addon_activated' => esc_html__( 'Activated', 'instagram-feed' ),
33
- 'addon_active' => esc_html__( 'Active', 'instagram-feed' ),
34
- 'addon_deactivate' => esc_html__( 'Deactivate', 'instagram-feed' ),
35
- 'addon_inactive' => esc_html__( 'Inactive', 'instagram-feed' ),
36
- 'addon_install' => esc_html__( 'Install Addon', 'instagram-feed' ),
37
- 'addon_error' => esc_html__( 'Could not install addon. Please download from wpforms.com and install manually.', 'instagram-feed' ),
38
- 'plugin_error' => esc_html__( 'Could not install a plugin. Please download from WordPress.org and install manually.', 'instagram-feed' ),
39
- 'addon_search' => esc_html__( 'Searching Addons', 'instagram-feed' ),
40
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
41
- 'cancel' => esc_html__( 'Cancel', 'instagram-feed' ),
42
- 'close' => esc_html__( 'Close', 'instagram-feed' ),
43
- 'nonce' => wp_create_nonce( 'sbi-admin' ),
44
- 'almost_done' => esc_html__( 'Almost Done', 'instagram-feed' ),
45
- 'oops' => esc_html__( 'Oops!', 'instagram-feed' ),
46
- 'ok' => esc_html__( 'OK', 'instagram-feed' ),
47
- 'plugin_install_activate_btn' => esc_html__( 'Install and Activate', 'instagram-feed' ),
48
- 'plugin_install_activate_confirm' => esc_html__( 'needs to be installed and activated to import its forms. Would you like us to install and activate it for you?', 'instagram-feed' ),
49
- 'plugin_activate_btn' => esc_html__( 'Activate', 'instagram-feed' ),
50
- );
51
- $strings = apply_filters( 'sbi_admin_strings', $strings );
52
-
53
- wp_localize_script(
54
- 'sb_instagram_admin_js',
55
- 'sbi_admin',
56
- $strings
57
- );
58
- if( !wp_script_is('jquery-ui-draggable') ) {
59
- wp_enqueue_script(
60
- array(
61
- 'jquery',
62
- 'jquery-ui-core',
63
- 'jquery-ui-draggable'
64
- )
65
- );
66
- }
67
- wp_enqueue_script(
68
- array(
69
- 'hoverIntent',
70
- 'wp-color-picker'
71
- )
72
- );
73
- }
74
- add_action( 'admin_enqueue_scripts', 'sb_instagram_admin_scripts' );
75
-
76
- // Add a Settings link to the plugin on the Plugins page
77
- $sbi_plugin_file = 'instagram-feed/instagram-feed.php';
78
- add_filter( "plugin_action_links_{$sbi_plugin_file}", 'sbi_add_settings_link', 10, 2 );
79
-
80
- //modify the link by unshifting the array
81
- function sbi_add_settings_link( $links, $file ) {
82
- $sbi_settings_link = '<a href="' . admin_url( 'admin.php?page=sb-instagram-feed' ) . '">' . __( 'Settings', 'instagram-feed' ) . '</a>';
83
- array_unshift( $links, $sbi_settings_link );
84
-
85
- return $links;
86
- }
87
-
88
-
89
- /**
90
- * Called via ajax to automatically save access token and access token secret
91
- * retrieved with the big blue button
92
- */
93
- function sbi_auto_save_tokens() {
94
- $nonce = $_POST['sbi_nonce'];
95
-
96
- if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
97
- die ( 'You did not do this the right way!' );
98
- }
99
-
100
- wp_cache_delete ( 'alloptions', 'options' );
101
-
102
- $options = sbi_get_database_settings();
103
- $new_access_token = isset( $_POST['access_token'] ) ? sanitize_text_field( $_POST['access_token'] ) : false;
104
- $split_token = $new_access_token ? explode( '.', $new_access_token ) : array();
105
- $new_user_id = isset( $split_token[0] ) ? $split_token[0] : '';
106
-
107
- $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
108
- $test_connection_data = sbi_account_data_for_token( $new_access_token );
109
-
110
- $connected_accounts[ $new_user_id ] = array(
111
- 'access_token' => sbi_get_parts( $new_access_token ),
112
- 'user_id' => $test_connection_data['id'],
113
- 'username' => $test_connection_data['username'],
114
- 'is_valid' => $test_connection_data['is_valid'],
115
- 'last_checked' => $test_connection_data['last_checked'],
116
- 'profile_picture' => $test_connection_data['profile_picture'],
117
- );
118
-
119
- if ( !$options['sb_instagram_disable_resize'] ) {
120
- if ( sbi_create_local_avatar( $test_connection_data['username'], $test_connection_data['profile_picture'] ) ) {
121
- $connected_accounts[ $new_user_id ]['local_avatar'] = true;
122
- }
123
- } else {
124
- $connected_accounts[ $new_user_id ]['local_avatar'] = false;
125
- }
126
-
127
- $options['connected_accounts'] = $connected_accounts;
128
-
129
- update_option( 'sb_instagram_settings', $options );
130
-
131
- echo wp_json_encode( $connected_accounts[ $new_user_id ] );
132
-
133
- die();
134
- }
135
- add_action( 'wp_ajax_sbi_auto_save_tokens', 'sbi_auto_save_tokens' );
136
-
137
- function sbi_delete_local_avatar( $username ) {
138
- $upload = wp_upload_dir();
139
-
140
- $image_files = glob( trailingslashit( $upload['basedir'] ) . trailingslashit( SBI_UPLOADS_NAME ) . $username . '.jpg' ); // get all matching images
141
- foreach ( $image_files as $file ) { // iterate files
142
- if ( is_file( $file ) ) {
143
- unlink( $file );
144
- }
145
- }
146
- }
147
-
148
- function sbi_create_local_avatar( $username, $file_name ) {
149
- $image_editor = wp_get_image_editor( $file_name );
150
-
151
- if ( ! is_wp_error( $image_editor ) ) {
152
- $upload = wp_upload_dir();
153
-
154
- $full_file_name = trailingslashit( $upload['basedir'] ) . trailingslashit( SBI_UPLOADS_NAME ) . $username . '.jpg';
155
-
156
- $saved_image = $image_editor->save( $full_file_name );
157
-
158
- if ( ! $saved_image ) {
159
- global $sb_instagram_posts_manager;
160
-
161
- $sb_instagram_posts_manager->add_error( 'image_editor_save', array(
162
- __( 'Error saving edited image.', 'instagram-feed' ),
163
- $full_file_name
164
- ) );
165
- } else {
166
- return true;
167
- }
168
- } else {
169
- global $sb_instagram_posts_manager;
170
-
171
- $message = __( 'Error editing image.', 'instagram-feed' );
172
- if ( isset( $image_editor ) && isset( $image_editor->errors ) ) {
173
- foreach ( $image_editor->errors as $key => $item ) {
174
- $message .= ' ' . $key . '- ' . $item[0] . ' |';
175
- }
176
- }
177
-
178
- $sb_instagram_posts_manager->add_error( 'image_editor', array( $file_name, $message ) );
179
- }
180
- return false;
181
- }
182
-
183
- function sbi_connect_business_accounts() {
184
- $nonce = $_POST['sbi_nonce'];
185
-
186
- if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
187
- die ( 'You did not do this the right way!' );
188
- }
189
-
190
- $accounts = isset( $_POST['accounts'] ) ? json_decode( stripslashes( $_POST['accounts'] ), true ) : false;
191
- $options = sbi_get_database_settings();
192
- $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
193
-
194
- foreach ( $accounts as $account ) {
195
- $access_token = isset( $account['access_token'] ) ? $account['access_token'] : '';
196
- $page_access_token = isset( $account['page_access_token'] ) ? $account['page_access_token'] : '';
197
- $username = isset( $account['username'] ) ? $account['username'] : '';
198
- $name = isset( $account['name'] ) ? $account['name'] : '';
199
- $profile_picture = isset( $account['profile_picture_url'] ) ? $account['profile_picture_url'] : '';
200
- $user_id = isset( $account['id'] ) ? $account['id'] : '';
201
- $type = 'business';
202
-
203
- $connected_accounts[ $user_id ] = array(
204
- 'access_token' => $access_token,
205
- 'page_access_token' => $page_access_token,
206
- 'user_id' => $user_id,
207
- 'username' => $username,
208
- 'is_valid' => true,
209
- 'last_checked' => time(),
210
- 'profile_picture' => $profile_picture,
211
- 'name' => sbi_sanitize_emoji( $name ),
212
- 'type' => $type,
213
- 'use_tagged' => '1'
214
- );
215
-
216
- if ( !$options['sb_instagram_disable_resize'] ) {
217
- if ( sbi_create_local_avatar( $username, $profile_picture ) ) {
218
- $connected_accounts[ $user_id ]['local_avatar'] = true;
219
- }
220
- } else {
221
- $connected_accounts[ $user_id ]['local_avatar'] = false;
222
- }
223
- global $sb_instagram_posts_manager;
224
-
225
- $sb_instagram_posts_manager->remove_error( 'at_' . $username );
226
- delete_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $user_id );
227
- }
228
-
229
- $options['connected_accounts'] = $connected_accounts;
230
-
231
- update_option( 'sb_instagram_settings', $options );
232
-
233
- echo wp_json_encode( $connected_accounts );
234
-
235
- die();
236
- }
237
- add_action( 'wp_ajax_sbi_connect_business_accounts', 'sbi_connect_business_accounts' );
238
-
239
- function sbi_auto_save_id() {
240
- $nonce = $_POST['sbi_nonce'];
241
-
242
- if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
243
- die ( 'You did not do this the right way!' );
244
- }
245
- if ( current_user_can( 'edit_posts' ) && isset( $_POST['id'] ) ) {
246
- $options = get_option( 'sb_instagram_settings', array() );
247
-
248
- $options['sb_instagram_user_id'] = array( sanitize_text_field( $_POST['id'] ) );
249
-
250
- update_option( 'sb_instagram_settings', $options );
251
- }
252
- die();
253
- }
254
- add_action( 'wp_ajax_sbi_auto_save_id', 'sbi_auto_save_id' );
255
-
256
- function sbi_test_token() {
257
- $access_token = isset( $_POST['access_token'] ) ? sanitize_text_field( $_POST['access_token'] ) : false;
258
- $account_id = isset( $_POST['account_id'] ) ? sanitize_text_field( $_POST['account_id'] ) : false;
259
- $options = sbi_get_database_settings();
260
- $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
261
-
262
- if ( $access_token ) {
263
- wp_cache_delete ( 'alloptions', 'options' );
264
-
265
- $number_dots = substr_count ( $access_token , '.' );
266
- $test_connection_data = array( 'error_message' => 'A successful connection could not be made. Please make sure your Access Token is valid.');
267
-
268
- if ( $number_dots > 1 ) {
269
- $split_token = explode( '.', $access_token );
270
- $new_user_id = isset( $split_token[0] ) ? $split_token[0] : '';
271
-
272
- $test_connection_data = sbi_account_data_for_token( $access_token );
273
- } else if (! empty( $account_id ) ) {
274
-
275
- if ( sbi_code_check( $access_token ) ) {
276
- $data = array(
277
- 'access_token' => $access_token,
278
- 'user_id' => $account_id,
279
- 'type' => 'basic'
280
- );
281
- $basic_account_attempt = new SB_Instagram_API_Connect( $data, 'header', array() );
282
- $basic_account_attempt->connect();
283
-
284
- if ( !$basic_account_attempt->is_wp_error() && ! $basic_account_attempt->is_instagram_error() ) {
285
- $new_data = $basic_account_attempt->get_data();
286
-
287
- $basic_account_access_token_connect = new SB_Instagram_API_Connect( $data, 'access_token', array() );
288
- $basic_account_access_token_connect->connect();
289
- if ( !$basic_account_access_token_connect->is_wp_error() && ! $basic_account_access_token_connect->is_instagram_error() ) {
290
-
291
- $token_data = $basic_account_access_token_connect->get_data();
292
- $expires_in = $token_data['expires_in'];
293
- $expires_timestamp = time() + $expires_in;
294
-
295
- $new_connected_account = array(
296
- 'access_token' => $access_token,
297
- 'account_type' => $new_data['account_type'],
298
- 'user_id' => $new_data['id'],
299
- 'username' => $new_data['username'],
300
- 'expires_timestamp' => $expires_timestamp,
301
- 'type' => 'basic'
302
- );
303
-
304
- $updated_options = sbi_connect_basic_account( $new_connected_account );
305
-
306
- echo wp_json_encode( $updated_options['connected_accounts'][ $new_data['id'] ] );
307
- die();
308
-
309
- }
310
-
311
- }
312
- }
313
-
314
- $url = 'https://graph.facebook.com/'.$account_id.'?fields=biography,id,username,website,followers_count,media_count,profile_picture_url,name&access_token='.sbi_maybe_clean( $access_token );
315
- $json = json_decode( sbi_business_account_request( $url, array( 'access_token' => $access_token ) ), true );
316
-
317
- if ( isset( $json['error'] ) && $json['error']['type'] === 'OAuthException' ) {
318
- $data = array(
319
- 'access_token' => $access_token,
320
- 'user_id' => $account_id,
321
- 'type' => 'basic'
322
- );
323
- $basic_account_attempt = new SB_Instagram_API_Connect( $data, 'header', array() );
324
- $basic_account_attempt->connect();
325
-
326
- if ( !$basic_account_attempt->is_wp_error() && ! $basic_account_attempt->is_instagram_error() ) {
327
- $new_data = $basic_account_attempt->get_data();
328
-
329
- $basic_account_access_token_connect = new SB_Instagram_API_Connect( $data, 'access_token', array() );
330
- $basic_account_access_token_connect->connect();
331
- if ( !$basic_account_access_token_connect->is_wp_error() && ! $basic_account_access_token_connect->is_instagram_error() ) {
332
-
333
- $token_data = $basic_account_access_token_connect->get_data();
334
- $expires_in = $token_data['expires_in'];
335
- $expires_timestamp = time() + $expires_in;
336
-
337
- $new_connected_account = array(
338
- 'access_token' => $access_token,
339
- 'account_type' => $new_data['account_type'],
340
- 'user_id' => $new_data['id'],
341
- 'username' => $new_data['username'],
342
- 'expires_timestamp' => $expires_timestamp,
343
- 'type' => 'basic'
344
- );
345
-
346
- $updated_options = sbi_connect_basic_account( $new_connected_account );
347
-
348
- echo wp_json_encode( $updated_options['connected_accounts'][ $new_data['id'] ] );
349
- die();
350
-
351
- }
352
-
353
- }
354
-
355
- die();
356
-
357
- } else {
358
- if ( isset( $json['id'] ) ) {
359
- $new_user_id = $json['id'];
360
- $test_connection_data = array(
361
- 'access_token' => $access_token,
362
- 'id' => $json['id'],
363
- 'username' => $json['username'],
364
- 'type' => 'business',
365
- 'is_valid' => true,
366
- 'last_checked' => time(),
367
- 'profile_picture' => $json['profile_picture_url']
368
- );
369
- }
370
- }
371
-
372
-
373
- global $sb_instagram_posts_manager;
374
-
375
- $sb_instagram_posts_manager->remove_error( 'at_' . $json['username'] );
376
- delete_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $json['id'] );
377
-
378
- }
379
-
380
- if ( isset( $test_connection_data['error_message'] ) ) {
381
- echo $test_connection_data['error_message'];
382
- } elseif ( $test_connection_data !== false && ! empty( $new_user_id ) ) {
383
- $username = $test_connection_data['username'] ? $test_connection_data['username'] : $connected_accounts[ $new_user_id ]['username'];
384
- $user_id = $test_connection_data['id'] ? $test_connection_data['id'] : $connected_accounts[ $new_user_id ]['user_id'];
385
- $profile_picture = $test_connection_data['profile_picture'] ? $test_connection_data['profile_picture'] : $connected_accounts[ $new_user_id ]['profile_picture'];
386
- $type = isset( $test_connection_data['type'] ) ? $test_connection_data['type'] : 'personal';
387
- $connected_accounts[ $new_user_id ] = array(
388
- 'access_token' => sbi_get_parts( $access_token ),
389
- 'user_id' => $user_id,
390
- 'username' => $username,
391
- 'type' => $type,
392
- 'is_valid' => true,
393
- 'last_checked' => $test_connection_data['last_checked'],
394
- 'profile_picture' => $profile_picture
395
- );
396
-
397
- if ( !$options['sb_instagram_disable_resize'] ) {
398
- if ( sbi_create_local_avatar( $username, $profile_picture ) ) {
399
- $connected_accounts[ $new_user_id ]['local_avatar'] = true;
400
- }
401
- } else {
402
- $connected_accounts[ $new_user_id ]['local_avatar'] = false;
403
- }
404
-
405
- if ( $type === 'business' ) {
406
- $url = 'https://graph.facebook.com/'.$user_id.'/tags?user_id='.$user_id.'&fields=id&limit=1&access_token='.sbi_maybe_clean( $access_token );
407
- $args = array(
408
- 'timeout' => 60,
409
- 'sslverify' => false
410
- );
411
- $response = wp_remote_get( $url, $args );
412
-
413
- if ( ! is_wp_error( $response ) ) {
414
- // certain ways of representing the html for double quotes causes errors so replaced here.
415
- $response = json_decode( str_replace( '%22', '&rdquo;', $response['body'] ), true );
416
- if ( isset( $response['data'] ) ) {
417
- $connected_accounts[ $new_user_id ]['use_tagged'] = '1';
418
- }
419
- }
420
- }
421
-
422
- delete_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $user_id );
423
- global $sb_instagram_posts_manager;
424
-
425
- $sb_instagram_posts_manager->remove_error( 'at_' . $username );
426
- $options['connected_accounts'] = $connected_accounts;
427
-
428
- update_option( 'sb_instagram_settings', $options );
429
-
430
- echo wp_json_encode( $connected_accounts[ $new_user_id ] );
431
- } else {
432
- echo 'A successful connection could not be made. Please make sure your Access Token is valid.';
433
- }
434
-
435
- }
436
-
437
- die();
438
- }
439
- add_action( 'wp_ajax_sbi_test_token', 'sbi_test_token' );
440
-
441
- function sbi_delete_account() {
442
- $nonce = $_POST['sbi_nonce'];
443
-
444
- if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
445
- die ( 'You did not do this the right way!' );
446
- }
447
- $account_id = isset( $_POST['account_id'] ) ? sanitize_text_field( $_POST['account_id'] ) : false;
448
- $options = get_option( 'sb_instagram_settings', array() );
449
- $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
450
-
451
- wp_cache_delete ( 'alloptions', 'options' );
452
- $username = $connected_accounts[ $account_id ]['username'];
453
-
454
- $num_times_used = 0;
455
-
456
- $new_con_accounts = array();
457
- foreach ( $connected_accounts as $connected_account ) {
458
-
459
- if ( $connected_account['username'] === $username ) {
460
- $num_times_used++;
461
- }
462
-
463
- if ( $connected_account['username'] !== '' && $account_id !== $connected_account['user_id'] && ! empty( $connected_account['user_id'] ) ) {
464
- $new_con_accounts[ $connected_account['user_id'] ] = $connected_account;
465
- }
466
- }
467
-
468
- if ( $num_times_used < 2 ) {
469
- sbi_delete_local_avatar( $username );
470
- }
471
-
472
- $options['connected_accounts'] = $new_con_accounts;
473
-
474
- update_option( 'sb_instagram_settings', $options );
475
-
476
-
477
- die();
478
- }
479
- add_action( 'wp_ajax_sbi_delete_account', 'sbi_delete_account' );
480
-
481
- function sbi_account_data_for_token( $access_token ) {
482
- $return = array(
483
- 'id' => false,
484
- 'username' => false,
485
- 'is_valid' => false,
486
- 'last_checked' => time()
487
- );
488
- $url = 'https://api.instagram.com/v1/users/self/?access_token=' . sbi_maybe_clean( $access_token );
489
- $args = array(
490
- 'timeout' => 60,
491
- 'sslverify' => false
492
- );
493
- $result = wp_remote_get( $url, $args );
494
-
495
- if ( ! is_wp_error( $result ) ) {
496
- $data = json_decode( $result['body'] );
497
- } else {
498
- $data = array();
499
- }
500
-
501
- if ( isset( $data->data->id ) ) {
502
- $return['id'] = $data->data->id;
503
- $return['username'] = $data->data->username;
504
- $return['is_valid'] = true;
505
- $return['profile_picture'] = $data->data->profile_picture;
506
-
507
- } elseif ( isset( $data->error_type ) && $data->error_type === 'OAuthRateLimitException' ) {
508
- $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.';
509
- } else {
510
- $return = false;
511
- }
512
-
513
- $sbi_options = get_option( 'sb_instagram_settings', array() );
514
- $sbi_options['sb_instagram_at'] = '';
515
- update_option( 'sb_instagram_settings', $sbi_options );
516
-
517
- return $return;
518
- }
519
-
520
- function sbi_get_connected_accounts_data( $sb_instagram_at ) {
521
- $sbi_options = get_option( 'sb_instagram_settings' );
522
- $return = array();
523
- $return['connected_accounts'] = isset( $sbi_options['connected_accounts'] ) ? $sbi_options['connected_accounts'] : array();
524
-
525
- if ( ! empty( $return['connected_accounts'] ) ) {
526
- $return['access_token'] = '';
527
- } else {
528
- $return['access_token'] = $sb_instagram_at;
529
- }
530
-
531
- if ( ! sbi_is_after_deprecation_deadline() && empty( $connected_accounts ) && ! empty( $sb_instagram_at ) ) {
532
- $tokens = explode(',', $sb_instagram_at );
533
- $user_ids = array();
534
-
535
- foreach ( $tokens as $token ) {
536
- $account = sbi_account_data_for_token( $token );
537
- if ( isset( $account['is_valid'] ) ) {
538
- $split = explode( '.', $token );
539
- $return['connected_accounts'][ $split[0] ] = array(
540
- 'access_token' => sbi_get_parts( $token ),
541
- 'user_id' => $split[0],
542
- 'username' => '',
543
- 'is_valid' => true,
544
- 'last_checked' => time(),
545
- 'profile_picture' => ''
546
- );
547
- $user_ids[] = $split[0];
548
- }
549
-
550
- }
551
-
552
- $sbi_options['connected_accounts'] = $return['connected_accounts'];
553
- $sbi_options['sb_instagram_at'] = '';
554
- $sbi_options['sb_instagram_user_id'] = $user_ids;
555
-
556
- $return['user_ids'] = $user_ids;
557
-
558
- update_option( 'sb_instagram_settings', $sbi_options );
559
- }
560
-
561
- return $return;
562
- }
563
-
564
- function sbi_connect_basic_account( $new_account_details ) {
565
-
566
- $options = sbi_get_database_settings();
567
- $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
568
-
569
- $accounts_to_save = array();
570
- $old_account_user_id = '';
571
- $ids_to_save = array();
572
- $user_ids = is_array( $options[ 'sb_instagram_user_id' ] ) ? $options[ 'sb_instagram_user_id' ] : explode( ',', str_replace( ' ', '', $options[ 'sb_instagram_user_id' ] ) );
573
-
574
- $profile_picture = '';
575
-
576
- // do not connect as a basic display account if already connected as a business account
577
- if ( isset( $connected_accounts[ $new_account_details['user_id'] ] )
578
- && isset( $connected_accounts[ $new_account_details['user_id'] ]['type'] )
579
- && $connected_accounts[ $new_account_details['user_id'] ]['type'] === 'business' ) {
580
- return $options;
581
- }
582
-
583
- foreach ( $connected_accounts as $account ) {
584
- $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
585
- if ( ($account['username'] !== $new_account_details['username'])
586
- || $account_type === 'business' ) {
587
- $accounts_to_save[ $account['user_id'] ] = $account;
588
- } else {
589
- $old_account_user_id = $account['user_id'];
590
- $profile_picture = isset( $account['profile_picture'] ) ? $account['profile_picture'] : '';
591
- }
592
- }
593
-
594
- foreach ( $user_ids as $id ) {
595
- if ( $id === $old_account_user_id ) {
596
- $ids_to_save[] = $new_account_details['user_id'];
597
- } else {
598
- $ids_to_save[] = $id;
599
- }
600
- }
601
-
602
- $accounts_to_save[ $new_account_details['user_id'] ] = array(
603
- 'access_token' => sbi_fixer( $new_account_details['access_token'] ),
604
- 'user_id' => $new_account_details['user_id'],
605
- 'username' => $new_account_details['username'],
606
- 'is_valid' => true,
607
- 'last_checked' => time(),
608
- 'expires_timestamp' => $new_account_details['expires_timestamp'],
609
- 'profile_picture' => $profile_picture,
610
- 'account_type' => strtolower( $new_account_details['account_type'] ),
611
- 'type' => 'basic',
612
- );
613
-
614
- if ( ! empty( $old_account_user_id ) && $old_account_user_id !== $new_account_details['user_id'] ) {
615
- $accounts_to_save[ $new_account_details['user_id'] ]['old_user_id'] = $old_account_user_id;
616
-
617
- // get last saved header data
618
- $fuzzy_matches = sbi_fuzzy_matching_header_data( $old_account_user_id );
619
- if ( ! empty( $fuzzy_matches[0] ) ) {
620
- $header_data = sbi_find_matching_data_from_results( $fuzzy_matches, $old_account_user_id );
621
- $bio = SB_Instagram_Parse::get_bio( $header_data );
622
- $accounts_to_save[ $new_account_details['user_id'] ]['bio'] = sbi_sanitize_emoji( $bio );
623
- }
624
-
625
- }
626
-
627
- if ( ! empty( $profile_picture ) && !$options['sb_instagram_disable_resize'] ) {
628
- if ( sbi_create_local_avatar( $new_account_details['username'], $profile_picture ) ) {
629
- $accounts_to_save[ $new_account_details['user_id'] ]['local_avatar'] = true;
630
- }
631
- } else {
632
- $accounts_to_save[ $new_account_details['user_id'] ]['local_avatar'] = false;
633
- }
634
-
635
- delete_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $new_account_details['user_id'] );
636
- global $sb_instagram_posts_manager;
637
-
638
- $sb_instagram_posts_manager->remove_error( 'at_' . $new_account_details['username'] );
639
- $options['connected_accounts'] = $accounts_to_save;
640
- $options['sb_instagram_user_id'] = $ids_to_save;
641
-
642
- update_option( 'sb_instagram_settings', $options );
643
- return $options;
644
- }
645
-
646
- function sbi_fuzzy_matching_header_data( $user_id ) {
647
-
648
- if ( empty( $user_id ) || strlen( $user_id ) < 4 ) {
649
- return array();
650
- }
651
- global $wpdb;
652
- $escaped_id = esc_sql( $user_id );
653
-
654
- $values = $wpdb->get_results( "
655
- SELECT option_value
656
- FROM $wpdb->options
657
- WHERE option_name LIKE ('%!sbi\_header\_".$escaped_id."%')
658
- LIMIT 10", ARRAY_A );
659
-
660
- $regular_values = $wpdb->get_results( "
661
- SELECT option_value
662
- FROM $wpdb->options
663
- WHERE option_name LIKE ('%sbi\_header\_".$escaped_id."%')
664
- LIMIT 10", ARRAY_A );
665
-
666
- $values = array_merge( $values, $regular_values );
667
-
668
- return $values;
669
- }
670
-
671
- function sbi_find_matching_data_from_results( $results, $user_id ) {
672
-
673
- $match = array();
674
-
675
- $i = 0;
676
-
677
- while( empty( $match ) && isset( $results[ $i ] ) ) {
678
- if ( ! empty( $results[ $i ] ) ) {
679
- $header_data = json_decode( $results[ $i ]['option_value'], true );
680
- if ( isset( $header_data['id'] ) && (string)$header_data['id'] === (string)$user_id ) {
681
- $match = $header_data;
682
- }
683
- }
684
- $i++;
685
- }
686
-
687
- return $match;
688
- }
689
-
690
- function sbi_matches_existing_personal( $new_account_details ) {
691
-
692
- $options = sbi_get_database_settings();
693
- $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
694
-
695
- $matches_one_account = false;
696
- $accounts_to_save = array();
697
- foreach ( $connected_accounts as $account ) {
698
- $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
699
- if ( ($account_type === 'personal' || $account_type === 'basic')
700
- && $account['username'] == $new_account_details['username'] ) {
701
- $matches_one_account = true;
702
-
703
-
704
- }
705
- }
706
-
707
- return $matches_one_account;
708
-
709
- }
710
-
711
- function sbi_business_account_request( $url, $account, $remove_access_token = true ) {
712
- $args = array(
713
- 'timeout' => 60,
714
- 'sslverify' => false
715
- );
716
- $result = wp_remote_get( $url, $args );
717
-
718
- if ( ! is_wp_error( $result ) ) {
719
- $response_no_at = $remove_access_token ? str_replace( sbi_maybe_clean( $account['access_token'] ), '{accesstoken}', $result['body'] ) : $result['body'];
720
- return $response_no_at;
721
- } else {
722
- return wp_json_encode( $result );
723
- }
724
- }
725
-
726
- function sbi_after_connection() {
727
-
728
- if ( isset( $_POST['access_token'] ) ) {
729
- $access_token = sanitize_text_field( $_POST['access_token'] );
730
- $account_info = sbi_account_data_for_token( $access_token );
731
- echo wp_json_encode( $account_info );
732
- }
733
-
734
- die();
735
- }
736
- add_action( 'wp_ajax_sbi_after_connection', 'sbi_after_connection' );
737
-
738
- function sbi_account_type_display( $type ) {
739
- if ( $type === 'basic' ) {
740
- return 'personal (new API)';
741
- }
742
- return $type;
743
- }
744
-
745
- function sbi_clear_backups() {
746
- $nonce = isset( $_POST['sbi_nonce'] ) ? sanitize_text_field( $_POST['sbi_nonce'] ) : '';
747
-
748
- if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
749
- die ( 'You did not do this the right way!' );
750
- }
751
-
752
- //Delete all transients
753
- global $wpdb;
754
- $table_name = $wpdb->prefix . "options";
755
- $wpdb->query( "
756
- DELETE
757
- FROM $table_name
758
- WHERE `option_name` LIKE ('%!sbi\_%')
759
- " );
760
- $wpdb->query( "
761
- DELETE
762
- FROM $table_name
763
- WHERE `option_name` LIKE ('%\_transient\_&sbi\_%')
764
- " );
765
- $wpdb->query( "
766
- DELETE
767
- FROM $table_name
768
- WHERE `option_name` LIKE ('%\_transient\_timeout\_&sbi\_%')
769
- " );
770
-
771
- die();
772
- }
773
- add_action( 'wp_ajax_sbi_clear_backups', 'sbi_clear_backups' );
774
-
775
- function sbi_reset_resized() {
776
-
777
- global $sb_instagram_posts_manager;
778
- $sb_instagram_posts_manager->delete_all_sbi_instagram_posts();
779
-
780
- echo "1";
781
-
782
- die();
783
- }
784
- add_action( 'wp_ajax_sbi_reset_resized', 'sbi_reset_resized' );
785
-
786
- function sbi_lite_dismiss() {
787
- $nonce = isset( $_POST['sbi_nonce'] ) ? sanitize_text_field( $_POST['sbi_nonce'] ) : '';
788
-
789
- if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
790
- die ( 'You did not do this the right way!' );
791
- }
792
-
793
- set_transient( 'instagram_feed_dismiss_lite', 'dismiss', 1 * WEEK_IN_SECONDS );
794
-
795
- die();
796
- }
797
- add_action( 'wp_ajax_sbi_lite_dismiss', 'sbi_lite_dismiss' );
798
-
799
- function sbi_reset_log() {
800
- global $sb_instagram_posts_manager;
801
-
802
- $sb_instagram_posts_manager->remove_all_errors();
803
-
804
- echo "1";
805
-
806
- die();
807
- }
808
- add_action( 'wp_ajax_sbi_reset_log', 'sbi_reset_log' );
809
-
810
- add_action('admin_notices', 'sbi_admin_error_notices');
811
- function sbi_admin_error_notices() {
812
-
813
-
814
- if ( isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'sb-instagram-feed' )) ) {
815
- global $sb_instagram_posts_manager;
816
-
817
- $errors = $sb_instagram_posts_manager->get_errors();
818
- if ( ! empty( $errors ) && ( isset( $errors['database_create_posts'] ) || isset( $errors['database_create_posts_feeds'] ) || isset( $errors['upload_dir'] ) || isset( $errors['ajax'] ) ) ) : ?>
819
- <div class="notice notice-warning is-dismissible sbi-admin-notice">
820
-
821
- <?php foreach ( $sb_instagram_posts_manager->get_errors() as $type => $error ) : ?>
822
- <?php if ( (in_array( $type, array( 'database_create_posts', 'database_create_posts_feeds', 'upload_dir' ) ) && !$sb_instagram_posts_manager->image_resizing_disabled() ) ) : ?>
823
- <p><strong><?php echo $error[0]; ?></strong></p>
824
- <p><?php _e( 'Note for support', 'instagram-feed' ); ?>: <?php echo $error[1]; ?></p>
825
- <?php endif; ?>
826
- <?php endforeach; ?>
827
- <?php if ( ( isset( $errors['database_create_posts'] ) || isset( $errors['database_create_posts_feeds'] ) || isset( $errors['upload_dir'] ) ) && !$sb_instagram_posts_manager->image_resizing_disabled() ) : ?>
828
- <p><?php _e( sprintf( 'Visit our %s page for help', '<a href="https://smashballoon.com/instagram-feed/support/faq/" target="_blank">FAQ</a>' ), 'instagram-feed' ); ?></p>
829
- <?php endif; ?>
830
-
831
- <?php foreach ( $sb_instagram_posts_manager->get_errors() as $type => $error ) : ?>
832
- <?php if (in_array( $type, array( 'ajax' ) )) : ?>
833
- <p class="sbi-admin-error" data-sbi-type="ajax"><strong><?php echo $error[0]; ?></strong></p>
834
- <p><?php echo $error[1]; ?></p>
835
- <?php endif; ?>
836
- <?php endforeach; ?>
837
-
838
- </div>
839
-
840
- <?php endif;
841
- $errors = $sb_instagram_posts_manager->get_critical_errors();
842
- if ( $sb_instagram_posts_manager->are_critical_errors() && ! empty( $errors ) ) : ?>
843
- <div class="notice notice-warning is-dismissible sbi-admin-notice">
844
- <p><strong><?php echo esc_html__( 'Instagram Feed is encountering an error and your feeds may not be updating due to the following reasons:', 'instagram-feed') ; ?></strong></p>
845
-
846
- <?php echo $errors; ?>
847
-
848
- <?php
849
- $error_page = $sb_instagram_posts_manager->get_error_page();
850
- if ( $error_page ) {
851
- echo '<a href="' . get_the_permalink( $error_page ) . '" class="sbi-clear-errors-visit-page sbi-space-left button button-secondary">' . __( 'View Feed and Retry', 'instagram-feed' ) . '</a>';
852
- }
853
- ?>
854
- </div>
855
- <?php endif;
856
- }
857
-
858
- }
859
-
860
- function sbi_get_user_names_of_personal_accounts_not_also_already_updated() {
861
- $sbi_options = get_option( 'sb_instagram_settings', array() );
862
- $users_in_personal_accounts = array();
863
- $non_personal_account_users = array();
864
-
865
- $connected_accounts = isset( $sbi_options['connected_accounts'] ) ? $sbi_options['connected_accounts'] : array();
866
-
867
- if ( ! empty( $connected_accounts ) ) {
868
-
869
- foreach ( $connected_accounts as $account ) {
870
- $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
871
-
872
- if ( $account_type === 'personal' ) {
873
- $users_in_personal_accounts[] = $account['username'];
874
- } else {
875
- $non_personal_account_users[] = $account['username'];
876
- }
877
-
878
- }
879
-
880
- if ( ! empty( $users_in_personal_accounts ) ) {
881
- $user_accounts_that_need_updating = array();
882
- foreach ( $users_in_personal_accounts as $personal_user ) {
883
- if ( ! in_array( $personal_user, $non_personal_account_users, true ) && $personal_user !== '' ) {
884
- $user_accounts_that_need_updating[] = $personal_user;
885
- }
886
- }
887
-
888
- return $user_accounts_that_need_updating;
889
- }
890
- } elseif ( empty( $connected_accounts ) && ! empty( $sbi_options['sb_instagram_at'] ) ) {
891
- return array( 'your Instagram feed');
892
- }
893
-
894
- return array();
895
- }
896
-
897
- function sbi_reconnect_accounts_notice() {
898
- if( ! current_user_can( 'manage_options' ) ) return;
899
-
900
- $should_show_link = ! isset( $_GET['page'] ) || $_GET['page'] !== 'sb-instagram-feed';
901
- $personal_accounts_that_need_updating = sbi_get_user_names_of_personal_accounts_not_also_already_updated();
902
- if ( empty( $personal_accounts_that_need_updating ) ) {
903
- return;
904
- } else {
905
- $total = count( $personal_accounts_that_need_updating );
906
- if ( $total > 1 ) {
907
- $user_string = '';
908
- $i = 0;
909
-
910
- foreach ( $personal_accounts_that_need_updating as $username ) {
911
- if ( ($i + 1) === $total ) {
912
- $user_string .= ' and ' . $username;
913
- } else {
914
- if ( $i !== 0 ) {
915
- $user_string .= ', ' . $username;
916
- } else {
917
- $user_string .= $username;
918
- }
919
- }
920
- $i++;
921
- }
922
- } else {
923
- $user_string = $personal_accounts_that_need_updating[0];
924
- }
925
-
926
- if ( sbi_is_after_deprecation_deadline() ) {
927
- $notice_class = 'notice-error';
928
- $error = '<p><b>' . sprintf( __( 'Error: Instagram Feed plugin - account for %s needs to be reconnected.', 'instagram-feed' ), '<em>'.$user_string.'</em>' ) . '</b><br>' . __( 'Due to recent Instagram platform changes some Instagram accounts will need to be reconnected in the plugin in order for them to continue updating.', 'instagram-feed' );
929
- } else {
930
- $notice_class = 'notice-warning';
931
- $error = '<p><b>' . sprintf( __( 'Warning: Instagram Feed plugin - account for %s needs to be reconnected.', 'instagram-feed' ), '<em>'.$user_string.'</em>' ) . '</b><br>' . __( 'Due to Instagram platform changes on March 31, 2020, some Instagram accounts will need to be reconnected in the plugin to avoid disruption to your feeds.', 'instagram-feed' );
932
- }
933
- if( !$should_show_link ) $error .= __( ' Use the big blue button below to reconnect your account.', 'instagram-feed' );
934
- }
935
- $url = admin_url( '?page=sb-instagram-feed' );
936
-
937
- ?>
938
- <div class="notice <?php echo $notice_class; ?> is-dismissible">
939
- <?php echo $error; ?>
940
- <p>
941
- <?php if ( $should_show_link ) : ?>
942
- <a href="<?php echo $url; ?>" class="button-primary" style="margin-right:10px;"><i class="fa fa-instagram" aria-hidden="true"></i> &nbsp;Reconnect on Settings Page</a>
943
- <?php endif; ?>
944
- <a href="https://smashballoon.com/instagram-api-changes-march-2-2020/" target="_blank" rel="noopener">See more details</a>
945
- </p>
946
- </div>
947
-
948
- <?php
949
-
950
- }
951
- add_action( 'admin_notices', 'sbi_reconnect_accounts_notice' );
952
-
953
- function sbi_get_current_time() {
954
- $current_time = time();
955
-
956
- // where to do tests
957
- // $current_time = strtotime( 'November 25, 2022' ) + 1;
958
-
959
- return $current_time;
960
- }
961
-
962
- // generates the html for the admin notices
963
- function sbi_notices_html() {
964
-
965
- //Only show to admins
966
- $current_screen = get_current_screen();
967
- $is_plugins_page = isset( $current_screen->id ) && $current_screen->id === 'plugins';
968
- $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
969
- //Only show to admins
970
- if ( ! current_user_can( 'manage_options' ) ) {
971
- return;
972
- }
973
-
974
- $sbi_statuses_option = get_option( 'sbi_statuses', array() );
975
- $current_time = sbi_get_current_time();
976
- $sbi_bfcm_discount_code = 'happysmashgiving' . date('Y', $current_time );
977
-
978
- // reset everything for testing
979
- if ( false ) {
980
- global $current_user;
981
- $user_id = $current_user->ID;
982
- delete_user_meta( $user_id, 'sbi_ignore_bfcm_sale_notice' );
983
- //delete_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice' );
984
- //$sbi_statuses_option = array( 'first_install' => strtotime( 'December 8, 2019' ) );
985
- //$sbi_statuses_option = array( 'first_install' => time() );
986
-
987
- //update_option( 'sbi_statuses', $sbi_statuses_option, false );
988
- //delete_option( 'sbi_rating_notice');
989
- //delete_transient( 'instagram_feed_rating_notice_waiting' );
990
-
991
- //set_transient( 'instagram_feed_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS );
992
- //update_option( 'sbi_rating_notice', 'pending', false );
993
- }
994
-
995
- //$sbi_statuses_option['rating_notice_dismissed'] = time();
996
- //update_option( 'sbi_statuses', $sbi_statuses_option, false );
997
- // rating notice logic
998
- $sbi_rating_notice_option = get_option( 'sbi_rating_notice', false );
999
- $sbi_rating_notice_waiting = get_transient( 'instagram_feed_rating_notice_waiting' );
1000
- $should_show_rating_notice = ($sbi_rating_notice_waiting !== 'waiting' && $sbi_rating_notice_option !== 'dismissed');
1001
-
1002
- // black friday cyber monday logic
1003
- $thanksgiving_this_year = sbi_get_future_date( 11, date('Y', $current_time ), 4, 4, 1 );
1004
- $one_week_before_black_friday_this_year = $thanksgiving_this_year - 7*24*60*60;
1005
- $one_day_after_cyber_monday_this_year = $thanksgiving_this_year + 5*24*60*60;
1006
- $has_been_two_days_since_rating_dismissal = isset( $sbi_statuses_option['rating_notice_dismissed'] ) ? ((int)$sbi_statuses_option['rating_notice_dismissed'] + 2*24*60*60) < $current_time : true;
1007
-
1008
- $could_show_bfcm_discount = ($current_time > $one_week_before_black_friday_this_year && $current_time < $one_day_after_cyber_monday_this_year);
1009
- $should_show_bfcm_discount = false;
1010
- if ( $could_show_bfcm_discount && $has_been_two_days_since_rating_dismissal ) {
1011
- global $current_user;
1012
- $user_id = $current_user->ID;
1013
-
1014
- $ignore_bfcm_sale_notice_meta = get_user_meta( $user_id, 'sbi_ignore_bfcm_sale_notice' );
1015
- $ignore_bfcm_sale_notice_meta = isset( $ignore_bfcm_sale_notice_meta[0] ) ? $ignore_bfcm_sale_notice_meta[0] : '';
1016
-
1017
- /* Check that the user hasn't already clicked to ignore the message */
1018
- $should_show_bfcm_discount = ($ignore_bfcm_sale_notice_meta !== 'always' && $ignore_bfcm_sale_notice_meta !== date( 'Y', $current_time ));
1019
- }
1020
-
1021
- // new user discount logic
1022
- $in_new_user_month_range = true;
1023
- $should_show_new_user_discount = false;
1024
- $has_been_one_month_since_rating_dismissal = isset( $sbi_statuses_option['rating_notice_dismissed'] ) ? ((int)$sbi_statuses_option['rating_notice_dismissed'] + 30*24*60*60) < $current_time + 1: true;
1025
-
1026
- if ( isset( $sbi_statuses_option['first_install'] ) && $sbi_statuses_option['first_install'] === 'from_update' ) {
1027
- global $current_user;
1028
- $user_id = $current_user->ID;
1029
- $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice' );
1030
- $ignore_new_user_sale_notice_meta = isset( $ignore_new_user_sale_notice_meta[0] ) ? $ignore_new_user_sale_notice_meta[0] : '';
1031
- if ( $ignore_new_user_sale_notice_meta !== 'always' ) {
1032
- $should_show_new_user_discount = true;
1033
- }
1034
- } elseif ( $in_new_user_month_range && $has_been_one_month_since_rating_dismissal ) {
1035
- global $current_user;
1036
- $user_id = $current_user->ID;
1037
- $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice' );
1038
- $ignore_new_user_sale_notice_meta = isset( $ignore_new_user_sale_notice_meta[0] ) ? $ignore_new_user_sale_notice_meta[0] : '';
1039
-
1040
- if ( $ignore_new_user_sale_notice_meta !== 'always'
1041
- && isset( $sbi_statuses_option['first_install'] )
1042
- && $current_time > (int)$sbi_statuses_option['first_install'] + 60*60*24*30 ) {
1043
- $should_show_new_user_discount = true;
1044
- }
1045
- }
1046
-
1047
- // for debugging
1048
- if ( false ) {
1049
- global $current_user;
1050
- $user_id = $current_user->ID;
1051
- $ignore_bfcm_sale_notice_meta = get_user_meta( $user_id, 'sbi_ignore_bfcm_sale_notice' );
1052
- $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice' );
1053
-
1054
- var_dump( 'new user rating option', $sbi_rating_notice_option );
1055
- var_dump( 'new user rating transient', $sbi_rating_notice_waiting );
1056
-
1057
- var_dump( 'should show new user rating notice?', $should_show_rating_notice );
1058
-
1059
- var_dump( 'new user discount month range?', $in_new_user_month_range );
1060
- var_dump( 'should show new user discount?', $should_show_new_user_discount );
1061
-
1062
- var_dump( 'Thanksgiving this year?', date('m/d/Y', $thanksgiving_this_year ) );
1063
-
1064
- var_dump( 'could show bfcm discount?', $could_show_bfcm_discount );
1065
- var_dump( 'should show bfcm discount?', $should_show_bfcm_discount );
1066
-
1067
- var_dump( 'ignore_bfcm_sale_notice_meta', $ignore_bfcm_sale_notice_meta );
1068
- var_dump( 'ignore_new_user_sale_notice_meta', $ignore_new_user_sale_notice_meta );
1069
-
1070
- var_dump( $sbi_statuses_option );
1071
- }
1072
-
1073
-
1074
- if ( $should_show_rating_notice ) {
1075
- $other_notice_html = '';
1076
- $dismiss_url = add_query_arg( 'sbi_ignore_rating_notice_nag', '1' );
1077
- $later_url = add_query_arg( 'sbi_ignore_rating_notice_nag', 'later' );
1078
- if ( $should_show_bfcm_discount ) {
1079
- $other_notice_html = '<p class="sbi_other_notice">' . __( 'PS. We currently have a <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=notices&utm_medium=rating&discount='.$sbi_bfcm_discount_code.'" target="_blank"><b style="font-weight: 700;">Black Friday deal</b></a> for 60% off the Pro version!', 'instagram-feed' ) . '</a></p>';
1080
-
1081
- $dismiss_url = add_query_arg( array(
1082
- 'sbi_ignore_rating_notice_nag' => '1',
1083
- 'sbi_ignore_bfcm_sale_notice' => date( 'Y', $current_time )
1084
- )
1085
- );
1086
- $later_url = add_query_arg( array(
1087
- 'sbi_ignore_rating_notice_nag' => 'later',
1088
- 'sbi_ignore_bfcm_sale_notice' => date( 'Y', $current_time )
1089
- )
1090
- );
1091
- }
1092
-
1093
- echo "
1094
- <div class='sbi_notice sbi_review_notice'>
1095
- <img src='". SBI_PLUGIN_URL . 'img/sbi-icon.png' ."' alt='" . __( 'Instagram Feed', 'instagram-feed' ) . "'>
1096
- <div class='sbi-notice-text'>
1097
- <p style='padding-top: 4px;'>" . __( "It's great to see that you've been using the <strong style='font-weight: 700;'>Instagram Feed</strong> plugin for a while now. Hopefully you're happy with it!&nbsp; If so, would you consider leaving a positive review? It really helps to support the plugin and helps others to discover it too!", 'instagram-feed' ) . "</p>
1098
- <p class='links'";
1099
- if( $should_show_bfcm_discount ) echo " style='margin-top: 0 !important;'";
1100
- echo ">
1101
- <a class='sbi_notice_dismiss' href='https://wordpress.org/support/plugin/instagram-feed/reviews/' target='_blank'>" . __( 'Sure, I\'d love to!', 'instagram-feed' ) . "</a>
1102
- &middot;
1103
- <a class='sbi_notice_dismiss' href='" .esc_url( $dismiss_url ). "'>" . __( 'No thanks', 'instagram-feed' ) . "</a>
1104
- &middot;
1105
- <a class='sbi_notice_dismiss' href='" .esc_url( $dismiss_url ). "'>" . __( 'I\'ve already given a review', 'instagram-feed' ) . "</a>
1106
- &middot;
1107
- <a class='sbi_notice_dismiss' href='" .esc_url( $later_url ). "'>" . __( 'Ask Me Later', 'instagram-feed' ) . "</a>
1108
- </p>"
1109
- . $other_notice_html .
1110
- "</div>
1111
- <a class='sbi_notice_close' href='" .esc_url( $dismiss_url ). "'><i class='fa fa-close'></i></a>
1112
- </div>";
1113
-
1114
- } elseif ( $should_show_new_user_discount ) {
1115
- global $current_user;
1116
- $user_id = $current_user->ID;
1117
- $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice' );
1118
- if ( $ignore_new_user_sale_notice_meta !== 'always' ) {
1119
-
1120
- echo "
1121
- <div class='sbi_notice sbi_review_notice sbi_new_user_sale_notice'>
1122
- <img src='" . SBI_PLUGIN_URL . 'img/sbi-icon-offer.png' . "' alt='Instagram Feed'>
1123
- <div class='sbi-notice-text'>
1124
- <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 Instagram Feed plugin.', 'instagram-feed' ) . "</p>
1125
- <p class='sbi-links'>
1126
- <a class='sbi_notice_dismiss sbi_offer_btn' href='https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=notices&utm_medium=newuser&discount=instagramthankyou' target='_blank'><b>" . __( 'Get this offer', 'instagram-feed' ) . "</b></a>
1127
- <a class='sbi_notice_dismiss' style='margin-left: 5px;' href='" . esc_url( add_query_arg( 'sbi_ignore_new_user_sale_notice', 'always' ) ) . "'>" . __( 'I\'m not interested', 'instagram-feed' ) . "</a>
1128
-
1129
- </p>
1130
- </div>
1131
- <a class='sbi_new_user_sale_notice_close' href='" . esc_url( add_query_arg( 'sbi_ignore_new_user_sale_notice', 'always' ) ) . "'><i class='fa fa-close'></i></a>
1132
- </div>
1133
- ";
1134
- }
1135
-
1136
- } elseif ( $should_show_bfcm_discount ) {
1137
-
1138
- echo "
1139
- <div class='sbi_notice sbi_review_notice sbi_bfcm_sale_notice'>
1140
- <img src='". SBI_PLUGIN_URL . 'img/sbi-icon-offer.png' ."' alt='Instagram Feed'>
1141
- <div class='sbi-notice-text'>
1142
- <p>" . __( '<b style="font-weight: 700;">Black Friday/Cyber Monday Deal!</b> Thank you for using our free Instagram Feed plugin. For a limited time, we\'re offering <b style="font-weight: 700;">60% off</b> the Pro version for all of our users.', 'instagram-feed' ) . "</p>
1143
- <p class='sbi-links'>
1144
- <a class='sbi_notice_dismiss sbi_offer_btn' href='https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=notices&utm_medium=bfcm&discount=".$sbi_bfcm_discount_code."' target='_blank'>" . __( 'Get this offer!', 'instagram-feed' ) . "</a>
1145
- <a class='sbi_notice_dismiss' style='margin-left: 5px;' href='" .esc_url( add_query_arg( 'sbi_ignore_bfcm_sale_notice', date( 'Y', $current_time ) ) ). "'>" . __( 'I\'m not interested', 'instagram-feed' ) . "</a>
1146
- </p>
1147
- </div>
1148
- <a class='sbi_bfcm_sale_notice_close' href='" .esc_url( add_query_arg( 'sbi_ignore_bfcm_sale_notice', date( 'Y', $current_time ) ) ). "'><i class='fa fa-close'></i></a>
1149
- </div>
1150
- ";
1151
-
1152
- }
1153
-
1154
- }
1155
- add_action( 'admin_notices', 'sbi_notices_html', 8 ); // priority 12 for Twitter, priority 10 for Facebook
1156
-
1157
- function sbi_process_nags() {
1158
-
1159
- global $current_user;
1160
- $user_id = $current_user->ID;
1161
- $sbi_statuses_option = get_option( 'sbi_statuses', array() );
1162
-
1163
- if ( isset( $_GET['sbi_ignore_rating_notice_nag'] ) ) {
1164
- if ( (int)$_GET['sbi_ignore_rating_notice_nag'] === 1 ) {
1165
- update_option( 'sbi_rating_notice', 'dismissed', false );
1166
- $sbi_statuses_option['rating_notice_dismissed'] = sbi_get_current_time();
1167
- update_option( 'sbi_statuses', $sbi_statuses_option, false );
1168
-
1169
- } elseif ( $_GET['sbi_ignore_rating_notice_nag'] === 'later' ) {
1170
- set_transient( 'instagram_feed_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS );
1171
- update_option( 'sbi_rating_notice', 'pending', false );
1172
- }
1173
- }
1174
-
1175
- if ( isset( $_GET['sbi_ignore_new_user_sale_notice'] ) ) {
1176
- $response = sanitize_text_field( $_GET['sbi_ignore_new_user_sale_notice'] );
1177
- if ( $response === 'always' ) {
1178
- update_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice', 'always' );
1179
-
1180
- $current_month_number = (int)date('n', sbi_get_current_time() );
1181
- $not_early_in_the_year = ($current_month_number > 5);
1182
-
1183
- if ( $not_early_in_the_year ) {
1184
- update_user_meta( $user_id, 'sbi_ignore_bfcm_sale_notice', date( 'Y', sbi_get_current_time() ) );
1185
- }
1186
-
1187
- }
1188
- }
1189
-
1190
- if ( isset( $_GET['sbi_ignore_bfcm_sale_notice'] ) ) {
1191
- $response = sanitize_text_field( $_GET['sbi_ignore_bfcm_sale_notice'] );
1192
- if ( $response === 'always' ) {
1193
- update_user_meta( $user_id, 'sbi_ignore_bfcm_sale_notice', 'always' );
1194
- } elseif ( $response === date( 'Y', sbi_get_current_time() ) ) {
1195
- update_user_meta( $user_id, 'sbi_ignore_bfcm_sale_notice', date( 'Y', sbi_get_current_time() ) );
1196
- }
1197
- update_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice', 'always' );
1198
- }
1199
-
1200
- }
1201
- add_action( 'admin_init', 'sbi_process_nags' );
1202
-
1203
- function sbi_get_future_date( $month, $year, $week, $day, $direction ) {
1204
- if ( $direction > 0 ) {
1205
- $startday = 1;
1206
- } else {
1207
- $startday = date( 't', mktime(0, 0, 0, $month, 1, $year ) );
1208
- }
1209
-
1210
- $start = mktime( 0, 0, 0, $month, $startday, $year );
1211
- $weekday = date( 'N', $start );
1212
-
1213
- $offset = 0;
1214
- if ( $direction * $day >= $direction * $weekday ) {
1215
- $offset = -$direction * 7;
1216
- }
1217
-
1218
- $offset += $direction * ($week * 7) + ($day - $weekday);
1219
- return mktime( 0, 0, 0, $month, $startday + $offset, $year );
1220
- }
1221
-
1222
- function sbi_admin_hide_unrelated_notices() {
1223
-
1224
- // Bail if we're not on a sbi screen or page.
1225
- if ( ! isset( $_GET['page'] ) || strpos( $_GET['page'], 'sb-instagram-feed') === false ) {
1226
- return;
1227
- }
1228
-
1229
- // Extra banned classes and callbacks from third-party plugins.
1230
- $blacklist = array(
1231
- 'classes' => array(),
1232
- 'callbacks' => array(
1233
- 'sbidb_admin_notice', // 'Database for sbi' plugin.
1234
- ),
1235
- );
1236
-
1237
- global $wp_filter;
1238
-
1239
- foreach ( array( 'user_admin_notices', 'admin_notices', 'all_admin_notices' ) as $notices_type ) {
1240
- if ( empty( $wp_filter[ $notices_type ]->callbacks ) || ! is_array( $wp_filter[ $notices_type ]->callbacks ) ) {
1241
- continue;
1242
- }
1243
- foreach ( $wp_filter[ $notices_type ]->callbacks as $priority => $hooks ) {
1244
- foreach ( $hooks as $name => $arr ) {
1245
- if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
1246
- unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
1247
- continue;
1248
- }
1249
- $class = ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) ? strtolower( get_class( $arr['function'][0] ) ) : '';
1250
- if (
1251
- ! empty( $class ) &&
1252
- strpos( $class, 'sbi' ) !== false &&
1253
- ! in_array( $class, $blacklist['classes'], true )
1254
- ) {
1255
- continue;
1256
- }
1257
- if (
1258
- ! empty( $name ) && (
1259
- strpos( $name, 'sbi' ) === false ||
1260
- in_array( $class, $blacklist['classes'], true ) ||
1261
- in_array( $name, $blacklist['callbacks'], true )
1262
- )
1263
- ) {
1264
- unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
1265
- }
1266
- }
1267
- }
1268
- }
1269
- }
1270
- add_action( 'admin_print_scripts', 'sbi_admin_hide_unrelated_notices' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Includes functions related to actions while in the admin area.
4
+ *
5
+ * - All AJAX related features
6
+ * - Enqueueing of JS and CSS files
7
+ * - Settings link on "Plugins" page
8
+ * - Creation of local avatar image files
9
+ * - Connecting accounts on the "Configure" tab
10
+ * - Displaying admin notices
11
+ * - Clearing caches
12
+ */
13
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
+
15
+ function sb_instagram_admin_style() {
16
+ wp_register_style( 'sb_instagram_admin_css', SBI_PLUGIN_URL . 'css/sb-instagram-admin.css', array(), SBIVER );
17
+ wp_enqueue_style( 'sb_instagram_font_awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' );
18
+ wp_enqueue_style( 'sb_instagram_admin_css' );
19
+ wp_enqueue_style( 'wp-color-picker' );
20
+ }
21
+ add_action( 'admin_enqueue_scripts', 'sb_instagram_admin_style' );
22
+
23
+ function sb_instagram_admin_scripts() {
24
+ wp_enqueue_script( 'sb_instagram_admin_js', SBI_PLUGIN_URL . 'js/sb-instagram-admin-2-2.js', array(), SBIVER );
25
+ wp_localize_script( 'sb_instagram_admin_js', 'sbiA', array(
26
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
27
+ 'sbi_nonce' => wp_create_nonce( 'sbi_nonce' )
28
+ )
29
+ );
30
+ $strings = array(
31
+ 'addon_activate' => esc_html__( 'Activate', 'instagram-feed' ),
32
+ 'addon_activated' => esc_html__( 'Activated', 'instagram-feed' ),
33
+ 'addon_active' => esc_html__( 'Active', 'instagram-feed' ),
34
+ 'addon_deactivate' => esc_html__( 'Deactivate', 'instagram-feed' ),
35
+ 'addon_inactive' => esc_html__( 'Inactive', 'instagram-feed' ),
36
+ 'addon_install' => esc_html__( 'Install Addon', 'instagram-feed' ),
37
+ 'addon_error' => esc_html__( 'Could not install addon. Please download from wpforms.com and install manually.', 'instagram-feed' ),
38
+ 'plugin_error' => esc_html__( 'Could not install a plugin. Please download from WordPress.org and install manually.', 'instagram-feed' ),
39
+ 'addon_search' => esc_html__( 'Searching Addons', 'instagram-feed' ),
40
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
41
+ 'cancel' => esc_html__( 'Cancel', 'instagram-feed' ),
42
+ 'close' => esc_html__( 'Close', 'instagram-feed' ),
43
+ 'nonce' => wp_create_nonce( 'sbi-admin' ),
44
+ 'almost_done' => esc_html__( 'Almost Done', 'instagram-feed' ),
45
+ 'oops' => esc_html__( 'Oops!', 'instagram-feed' ),
46
+ 'ok' => esc_html__( 'OK', 'instagram-feed' ),
47
+ 'plugin_install_activate_btn' => esc_html__( 'Install and Activate', 'instagram-feed' ),
48
+ 'plugin_install_activate_confirm' => esc_html__( 'needs to be installed and activated to import its forms. Would you like us to install and activate it for you?', 'instagram-feed' ),
49
+ 'plugin_activate_btn' => esc_html__( 'Activate', 'instagram-feed' ),
50
+ );
51
+ $strings = apply_filters( 'sbi_admin_strings', $strings );
52
+
53
+ wp_localize_script(
54
+ 'sb_instagram_admin_js',
55
+ 'sbi_admin',
56
+ $strings
57
+ );
58
+ if( !wp_script_is('jquery-ui-draggable') ) {
59
+ wp_enqueue_script(
60
+ array(
61
+ 'jquery',
62
+ 'jquery-ui-core',
63
+ 'jquery-ui-draggable'
64
+ )
65
+ );
66
+ }
67
+ wp_enqueue_script(
68
+ array(
69
+ 'hoverIntent',
70
+ 'wp-color-picker'
71
+ )
72
+ );
73
+ }
74
+ add_action( 'admin_enqueue_scripts', 'sb_instagram_admin_scripts' );
75
+
76
+ // Add a Settings link to the plugin on the Plugins page
77
+ $sbi_plugin_file = 'instagram-feed/instagram-feed.php';
78
+ add_filter( "plugin_action_links_{$sbi_plugin_file}", 'sbi_add_settings_link', 10, 2 );
79
+
80
+ //modify the link by unshifting the array
81
+ function sbi_add_settings_link( $links, $file ) {
82
+ $sbi_settings_link = '<a href="' . admin_url( 'admin.php?page=sb-instagram-feed' ) . '">' . __( 'Settings', 'instagram-feed' ) . '</a>';
83
+ array_unshift( $links, $sbi_settings_link );
84
+
85
+ return $links;
86
+ }
87
+
88
+
89
+ /**
90
+ * Called via ajax to automatically save access token and access token secret
91
+ * retrieved with the big blue button
92
+ */
93
+ function sbi_auto_save_tokens() {
94
+ $nonce = $_POST['sbi_nonce'];
95
+
96
+ if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
97
+ die ( 'You did not do this the right way!' );
98
+ }
99
+
100
+ wp_cache_delete ( 'alloptions', 'options' );
101
+
102
+ $options = sbi_get_database_settings();
103
+ $new_access_token = isset( $_POST['access_token'] ) ? sanitize_text_field( $_POST['access_token'] ) : false;
104
+ $split_token = $new_access_token ? explode( '.', $new_access_token ) : array();
105
+ $new_user_id = isset( $split_token[0] ) ? $split_token[0] : '';
106
+
107
+ $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
108
+ $test_connection_data = sbi_account_data_for_token( $new_access_token );
109
+
110
+ $connected_accounts[ $new_user_id ] = array(
111
+ 'access_token' => sbi_get_parts( $new_access_token ),
112
+ 'user_id' => $test_connection_data['id'],
113
+ 'username' => $test_connection_data['username'],
114
+ 'is_valid' => $test_connection_data['is_valid'],
115
+ 'last_checked' => $test_connection_data['last_checked'],
116
+ 'profile_picture' => $test_connection_data['profile_picture'],
117
+ );
118
+
119
+ if ( !$options['sb_instagram_disable_resize'] ) {
120
+ if ( sbi_create_local_avatar( $test_connection_data['username'], $test_connection_data['profile_picture'] ) ) {
121
+ $connected_accounts[ $new_user_id ]['local_avatar'] = true;
122
+ }
123
+ } else {
124
+ $connected_accounts[ $new_user_id ]['local_avatar'] = false;
125
+ }
126
+
127
+ $options['connected_accounts'] = $connected_accounts;
128
+
129
+ update_option( 'sb_instagram_settings', $options );
130
+
131
+ echo wp_json_encode( $connected_accounts[ $new_user_id ] );
132
+
133
+ die();
134
+ }
135
+ add_action( 'wp_ajax_sbi_auto_save_tokens', 'sbi_auto_save_tokens' );
136
+
137
+ function sbi_delete_local_avatar( $username ) {
138
+ $upload = wp_upload_dir();
139
+
140
+ $image_files = glob( trailingslashit( $upload['basedir'] ) . trailingslashit( SBI_UPLOADS_NAME ) . $username . '.jpg' ); // get all matching images
141
+ foreach ( $image_files as $file ) { // iterate files
142
+ if ( is_file( $file ) ) {
143
+ unlink( $file );
144
+ }
145
+ }
146
+ }
147
+
148
+ function sbi_create_local_avatar( $username, $file_name ) {
149
+ $image_editor = wp_get_image_editor( $file_name );
150
+
151
+ if ( ! is_wp_error( $image_editor ) ) {
152
+ $upload = wp_upload_dir();
153
+
154
+ $full_file_name = trailingslashit( $upload['basedir'] ) . trailingslashit( SBI_UPLOADS_NAME ) . $username . '.jpg';
155
+
156
+ $saved_image = $image_editor->save( $full_file_name );
157
+
158
+ if ( ! $saved_image ) {
159
+ global $sb_instagram_posts_manager;
160
+
161
+ $sb_instagram_posts_manager->add_error( 'image_editor_save', array(
162
+ __( 'Error saving edited image.', 'instagram-feed' ),
163
+ $full_file_name
164
+ ) );
165
+ } else {
166
+ return true;
167
+ }
168
+ } else {
169
+ global $sb_instagram_posts_manager;
170
+
171
+ $message = __( 'Error editing image.', 'instagram-feed' );
172
+ if ( isset( $image_editor ) && isset( $image_editor->errors ) ) {
173
+ foreach ( $image_editor->errors as $key => $item ) {
174
+ $message .= ' ' . $key . '- ' . $item[0] . ' |';
175
+ }
176
+ }
177
+
178
+ $sb_instagram_posts_manager->add_error( 'image_editor', array( $file_name, $message ) );
179
+ }
180
+ return false;
181
+ }
182
+
183
+ function sbi_connect_business_accounts() {
184
+ $nonce = $_POST['sbi_nonce'];
185
+
186
+ if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
187
+ die ( 'You did not do this the right way!' );
188
+ }
189
+
190
+ $accounts = isset( $_POST['accounts'] ) ? json_decode( stripslashes( $_POST['accounts'] ), true ) : false;
191
+ $options = sbi_get_database_settings();
192
+ $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
193
+ $new_user_names = array();
194
+
195
+ foreach ( $accounts as $account ) {
196
+ $access_token = isset( $account['access_token'] ) ? $account['access_token'] : '';
197
+ $page_access_token = isset( $account['page_access_token'] ) ? $account['page_access_token'] : '';
198
+ $username = isset( $account['username'] ) ? $account['username'] : '';
199
+ $name = isset( $account['name'] ) ? $account['name'] : '';
200
+ $profile_picture = isset( $account['profile_picture_url'] ) ? $account['profile_picture_url'] : '';
201
+ $user_id = isset( $account['id'] ) ? $account['id'] : '';
202
+ $type = 'business';
203
+
204
+ $connected_accounts[ $user_id ] = array(
205
+ 'access_token' => $access_token,
206
+ 'page_access_token' => $page_access_token,
207
+ 'user_id' => $user_id,
208
+ 'username' => $username,
209
+ 'is_valid' => true,
210
+ 'last_checked' => time(),
211
+ 'profile_picture' => $profile_picture,
212
+ 'name' => sbi_sanitize_emoji( $name ),
213
+ 'type' => $type,
214
+ 'use_tagged' => '1'
215
+ );
216
+ $new_user_names[] = $username;
217
+
218
+ if ( !$options['sb_instagram_disable_resize'] ) {
219
+ if ( sbi_create_local_avatar( $username, $profile_picture ) ) {
220
+ $connected_accounts[ $user_id ]['local_avatar'] = true;
221
+ }
222
+ } else {
223
+ $connected_accounts[ $user_id ]['local_avatar'] = false;
224
+ }
225
+ global $sb_instagram_posts_manager;
226
+
227
+ $sb_instagram_posts_manager->remove_error( 'at_' . $username );
228
+ delete_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $user_id );
229
+ }
230
+
231
+ $accounts_to_save = array();
232
+ foreach ( $connected_accounts as $account ) {
233
+ $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
234
+ if ( $account_type !== 'personal' || ! in_array( $account['username'], $new_user_names, true ) ) {
235
+ $accounts_to_save[ $account['user_id'] ] = $account;
236
+ }
237
+ }
238
+
239
+ $options['connected_accounts'] = $accounts_to_save;
240
+
241
+ update_option( 'sb_instagram_settings', $options );
242
+
243
+ echo wp_json_encode( $accounts_to_save );
244
+
245
+ die();
246
+ }
247
+ add_action( 'wp_ajax_sbi_connect_business_accounts', 'sbi_connect_business_accounts' );
248
+
249
+ function sbi_auto_save_id() {
250
+ $nonce = $_POST['sbi_nonce'];
251
+
252
+ if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
253
+ die ( 'You did not do this the right way!' );
254
+ }
255
+ if ( current_user_can( 'edit_posts' ) && isset( $_POST['id'] ) ) {
256
+ $options = get_option( 'sb_instagram_settings', array() );
257
+
258
+ $options['sb_instagram_user_id'] = array( sanitize_text_field( $_POST['id'] ) );
259
+
260
+ update_option( 'sb_instagram_settings', $options );
261
+ }
262
+ die();
263
+ }
264
+ add_action( 'wp_ajax_sbi_auto_save_id', 'sbi_auto_save_id' );
265
+
266
+ function sbi_formatted_error( $response ) {
267
+ if ( isset( $response['error'] ) ) {
268
+ $error = '<p>' . sprintf( __( 'API error %s:', 'instagram-feed' ), $response['error']['code'] ) . ' ' . $response['error']['message'] . '</p>';
269
+ $error .= '<p class="sbi-error-directions"><a href="https://smashballoon.com/instagram-feed/docs/errors/" target="_blank" rel="noopener">' . __( 'Directions on how to resolve this issue', 'instagram-feed' ) . '</a></p>';
270
+
271
+ return $error;
272
+ } else {
273
+ $message = '<p>' . sprintf( __( 'Error connecting to %s.', 'instagram-feed' ), $response['url'] ). '</p>';
274
+ if ( isset( $response['response'] ) && isset( $response['response']->errors ) ) {
275
+ foreach ( $response['response']->errors as $key => $item ) {
276
+ '<p>' .$message .= ' '.$key . ' - ' . $item[0] . '</p>';
277
+ }
278
+ }
279
+ $message .= '<p class="sbi-error-directions"><a href="https://smashballoon.com/instagram-feed/docs/errors/" target="_blank" rel="noopener">' . __( 'Directions on how to resolve this issue', 'instagram-feed' ) . '</a></p>';
280
+
281
+ return $message;
282
+ }
283
+ }
284
+
285
+ function sbi_test_token() {
286
+ $access_token = isset( $_POST['access_token'] ) ? trim( sanitize_text_field( $_POST['access_token'] ) ) : false;
287
+ $account_id = isset( $_POST['account_id'] ) ? sanitize_text_field( $_POST['account_id'] ) : false;
288
+
289
+ $split_id = explode( ' ', trim( $account_id ) );
290
+ $account_id = preg_replace("/[^A-Za-z0-9 ]/", '', $split_id[0] );
291
+ if ( ! empty( $account_id ) ) {
292
+ $split_token = explode( ' ', trim( $access_token ) );
293
+ $access_token = preg_replace("/[^A-Za-z0-9 ]/", '', $split_token[0] );
294
+ }
295
+
296
+
297
+ $options = sbi_get_database_settings();
298
+ $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
299
+
300
+ if ( $access_token ) {
301
+ wp_cache_delete ( 'alloptions', 'options' );
302
+
303
+ $number_dots = substr_count ( $access_token , '.' );
304
+ $test_connection_data = array( 'error_message' => 'A successful connection could not be made. Please make sure your Access Token is valid.');
305
+
306
+ if ( $number_dots > 1 ) {
307
+ $split_token = explode( '.', $access_token );
308
+ $new_user_id = isset( $split_token[0] ) ? $split_token[0] : '';
309
+
310
+ $test_connection_data = sbi_account_data_for_token( $access_token );
311
+ } else if (! empty( $account_id ) ) {
312
+
313
+ if ( sbi_code_check( $access_token ) ) {
314
+ $data = array(
315
+ 'access_token' => $access_token,
316
+ 'user_id' => $account_id,
317
+ 'type' => 'basic'
318
+ );
319
+ $basic_account_attempt = new SB_Instagram_API_Connect( $data, 'header', array() );
320
+ $basic_account_attempt->connect();
321
+
322
+ if ( !$basic_account_attempt->is_wp_error() && ! $basic_account_attempt->is_instagram_error() ) {
323
+ $new_data = $basic_account_attempt->get_data();
324
+
325
+ $basic_account_access_token_connect = new SB_Instagram_API_Connect( $data, 'access_token', array() );
326
+ $basic_account_access_token_connect->connect();
327
+ if ( !$basic_account_access_token_connect->is_wp_error() && ! $basic_account_access_token_connect->is_instagram_error() ) {
328
+
329
+ $token_data = $basic_account_access_token_connect->get_data();
330
+ $expires_in = $token_data['expires_in'];
331
+ $expires_timestamp = time() + $expires_in;
332
+
333
+ $new_connected_account = array(
334
+ 'access_token' => $access_token,
335
+ 'account_type' => $new_data['account_type'],
336
+ 'user_id' => $new_data['id'],
337
+ 'username' => $new_data['username'],
338
+ 'expires_timestamp' => $expires_timestamp,
339
+ 'type' => 'basic'
340
+ );
341
+
342
+ $updated_options = sbi_connect_basic_account( $new_connected_account );
343
+
344
+ echo wp_json_encode( $updated_options['connected_accounts'][ $new_data['id'] ] );
345
+ die();
346
+
347
+ } else {
348
+ if ( $basic_account_access_token_connect->is_wp_error() ) {
349
+ $error = $basic_account_access_token_connect->get_wp_error();
350
+ } else {
351
+ $error = $basic_account_access_token_connect->get_data();
352
+ }
353
+ echo sbi_formatted_error( $error );
354
+ die();
355
+ }
356
+
357
+ } else {
358
+ if ( $basic_account_attempt->is_wp_error() ) {
359
+ $error = $basic_account_attempt->get_wp_error();
360
+ } else {
361
+ $error = $basic_account_attempt->get_data();
362
+ }
363
+ echo sbi_formatted_error( $error );
364
+ die();
365
+ }
366
+ }
367
+
368
+ $url = 'https://graph.facebook.com/'.$account_id.'?fields=biography,id,username,website,followers_count,media_count,profile_picture_url,name&access_token='.sbi_maybe_clean( $access_token );
369
+ $json = json_decode( sbi_business_account_request( $url, array( 'access_token' => $access_token ) ), true );
370
+
371
+ if ( isset( $json['error'] ) && $json['error']['type'] === 'OAuthException' ) {
372
+ $data = array(
373
+ 'access_token' => $access_token,
374
+ 'user_id' => $account_id,
375
+ 'type' => 'basic'
376
+ );
377
+ $basic_account_attempt = new SB_Instagram_API_Connect( $data, 'header', array() );
378
+ $basic_account_attempt->connect();
379
+
380
+ if ( !$basic_account_attempt->is_wp_error() && ! $basic_account_attempt->is_instagram_error() ) {
381
+ $new_data = $basic_account_attempt->get_data();
382
+
383
+ $basic_account_access_token_connect = new SB_Instagram_API_Connect( $data, 'access_token', array() );
384
+ $basic_account_access_token_connect->connect();
385
+ if ( !$basic_account_access_token_connect->is_wp_error() && ! $basic_account_access_token_connect->is_instagram_error() ) {
386
+
387
+ $token_data = $basic_account_access_token_connect->get_data();
388
+ $expires_in = $token_data['expires_in'];
389
+ $expires_timestamp = time() + $expires_in;
390
+
391
+ $new_connected_account = array(
392
+ 'access_token' => $access_token,
393
+ 'account_type' => $new_data['account_type'],
394
+ 'user_id' => $new_data['id'],
395
+ 'username' => $new_data['username'],
396
+ 'expires_timestamp' => $expires_timestamp,
397
+ 'type' => 'basic'
398
+ );
399
+
400
+ $updated_options = sbi_connect_basic_account( $new_connected_account );
401
+
402
+ echo wp_json_encode( $updated_options['connected_accounts'][ $new_data['id'] ] );
403
+ die();
404
+
405
+ } else {
406
+ if ( $basic_account_access_token_connect->is_wp_error() ) {
407
+ $error = $basic_account_access_token_connect->get_wp_error();
408
+ } else {
409
+ $error = $basic_account_access_token_connect->get_data();
410
+ }
411
+ echo sbi_formatted_error( $error );
412
+ die();
413
+ }
414
+
415
+ } else {
416
+ if ( $basic_account_attempt->is_wp_error() ) {
417
+ $error = $basic_account_attempt->get_wp_error();
418
+ } else {
419
+ $error = $basic_account_attempt->get_data();
420
+ }
421
+ echo sbi_formatted_error( $error );
422
+ die();
423
+ }
424
+
425
+ } else {
426
+ if ( isset( $json['id'] ) ) {
427
+ $new_user_id = $json['id'];
428
+ $test_connection_data = array(
429
+ 'access_token' => $access_token,
430
+ 'id' => $json['id'],
431
+ 'username' => $json['username'],
432
+ 'type' => 'business',
433
+ 'is_valid' => true,
434
+ 'last_checked' => time(),
435
+ 'profile_picture' => $json['profile_picture_url']
436
+ );
437
+ }
438
+ }
439
+
440
+
441
+ global $sb_instagram_posts_manager;
442
+
443
+ $sb_instagram_posts_manager->remove_error( 'at_' . $json['username'] );
444
+ delete_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $json['id'] );
445
+
446
+ }
447
+
448
+ if ( isset( $test_connection_data['error_message'] ) ) {
449
+ echo $test_connection_data['error_message'];
450
+ } elseif ( $test_connection_data !== false && ! empty( $new_user_id ) ) {
451
+ $username = $test_connection_data['username'] ? $test_connection_data['username'] : $connected_accounts[ $new_user_id ]['username'];
452
+ $user_id = $test_connection_data['id'] ? $test_connection_data['id'] : $connected_accounts[ $new_user_id ]['user_id'];
453
+ $profile_picture = $test_connection_data['profile_picture'] ? $test_connection_data['profile_picture'] : $connected_accounts[ $new_user_id ]['profile_picture'];
454
+ $type = isset( $test_connection_data['type'] ) ? $test_connection_data['type'] : 'personal';
455
+ $connected_accounts[ $new_user_id ] = array(
456
+ 'access_token' => sbi_get_parts( $access_token ),
457
+ 'user_id' => $user_id,
458
+ 'username' => $username,
459
+ 'type' => $type,
460
+ 'is_valid' => true,
461
+ 'last_checked' => $test_connection_data['last_checked'],
462
+ 'profile_picture' => $profile_picture
463
+ );
464
+
465
+ if ( !$options['sb_instagram_disable_resize'] ) {
466
+ if ( sbi_create_local_avatar( $username, $profile_picture ) ) {
467
+ $connected_accounts[ $new_user_id ]['local_avatar'] = true;
468
+ }
469
+ } else {
470
+ $connected_accounts[ $new_user_id ]['local_avatar'] = false;
471
+ }
472
+
473
+ if ( $type === 'business' ) {
474
+ $url = 'https://graph.facebook.com/'.$user_id.'/tags?user_id='.$user_id.'&fields=id&limit=1&access_token='.sbi_maybe_clean( $access_token );
475
+ $args = array(
476
+ 'timeout' => 60,
477
+ 'sslverify' => false
478
+ );
479
+ $response = wp_remote_get( $url, $args );
480
+
481
+ if ( ! is_wp_error( $response ) ) {
482
+ // certain ways of representing the html for double quotes causes errors so replaced here.
483
+ $response = json_decode( str_replace( '%22', '&rdquo;', $response['body'] ), true );
484
+ if ( isset( $response['data'] ) ) {
485
+ $connected_accounts[ $new_user_id ]['use_tagged'] = '1';
486
+ }
487
+ } else {
488
+ echo sbi_formatted_error( $response );
489
+ die();
490
+ }
491
+ }
492
+
493
+ delete_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $user_id );
494
+ global $sb_instagram_posts_manager;
495
+
496
+ $sb_instagram_posts_manager->remove_error( 'at_' . $username );
497
+ $options['connected_accounts'] = $connected_accounts;
498
+
499
+ update_option( 'sb_instagram_settings', $options );
500
+
501
+ echo wp_json_encode( $connected_accounts[ $new_user_id ] );
502
+ } else {
503
+ echo 'A successful connection could not be made. Please make sure your Access Token is valid.';
504
+ }
505
+
506
+ }
507
+
508
+ die();
509
+ }
510
+ add_action( 'wp_ajax_sbi_test_token', 'sbi_test_token' );
511
+
512
+ function sbi_delete_account() {
513
+ $nonce = $_POST['sbi_nonce'];
514
+
515
+ if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
516
+ die ( 'You did not do this the right way!' );
517
+ }
518
+ $account_id = isset( $_POST['account_id'] ) ? sanitize_text_field( $_POST['account_id'] ) : false;
519
+ $options = get_option( 'sb_instagram_settings', array() );
520
+ $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
521
+
522
+ wp_cache_delete ( 'alloptions', 'options' );
523
+ $username = $connected_accounts[ $account_id ]['username'];
524
+
525
+ $num_times_used = 0;
526
+
527
+ $new_con_accounts = array();
528
+ foreach ( $connected_accounts as $connected_account ) {
529
+
530
+ if ( $connected_account['username'] === $username ) {
531
+ $num_times_used++;
532
+ }
533
+
534
+ if ( $connected_account['username'] !== '' && $account_id !== $connected_account['user_id'] && ! empty( $connected_account['user_id'] ) ) {
535
+ $new_con_accounts[ $connected_account['user_id'] ] = $connected_account;
536
+ }
537
+ }
538
+
539
+ if ( $num_times_used < 2 ) {
540
+ sbi_delete_local_avatar( $username );
541
+ }
542
+
543
+ $options['connected_accounts'] = $new_con_accounts;
544
+
545
+ update_option( 'sb_instagram_settings', $options );
546
+
547
+
548
+ die();
549
+ }
550
+ add_action( 'wp_ajax_sbi_delete_account', 'sbi_delete_account' );
551
+
552
+ function sbi_account_data_for_token( $access_token ) {
553
+ $return = array(
554
+ 'id' => false,
555
+ 'username' => false,
556
+ 'is_valid' => false,
557
+ 'last_checked' => time()
558
+ );
559
+ $url = 'https://api.instagram.com/v1/users/self/?access_token=' . sbi_maybe_clean( $access_token );
560
+ $args = array(
561
+ 'timeout' => 60,
562
+ 'sslverify' => false
563
+ );
564
+ $result = wp_remote_get( $url, $args );
565
+
566
+ if ( ! is_wp_error( $result ) ) {
567
+ $data = json_decode( $result['body'] );
568
+ } else {
569
+ $data = array();
570
+ }
571
+
572
+ if ( isset( $data->data->id ) ) {
573
+ $return['id'] = $data->data->id;
574
+ $return['username'] = $data->data->username;
575
+ $return['is_valid'] = true;
576
+ $return['profile_picture'] = $data->data->profile_picture;
577
+
578
+ } elseif ( isset( $data->error_type ) && $data->error_type === 'OAuthRateLimitException' ) {
579
+ $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.';
580
+ } else {
581
+ $return = false;
582
+ }
583
+
584
+ $sbi_options = get_option( 'sb_instagram_settings', array() );
585
+ $sbi_options['sb_instagram_at'] = '';
586
+ update_option( 'sb_instagram_settings', $sbi_options );
587
+
588
+ return $return;
589
+ }
590
+
591
+ function sbi_get_connected_accounts_data( $sb_instagram_at ) {
592
+ $sbi_options = get_option( 'sb_instagram_settings' );
593
+ $return = array();
594
+ $return['connected_accounts'] = isset( $sbi_options['connected_accounts'] ) ? $sbi_options['connected_accounts'] : array();
595
+
596
+ if ( ! empty( $return['connected_accounts'] ) ) {
597
+ $return['access_token'] = '';
598
+ } else {
599
+ $return['access_token'] = $sb_instagram_at;
600
+ }
601
+
602
+ if ( ! sbi_is_after_deprecation_deadline() && empty( $connected_accounts ) && ! empty( $sb_instagram_at ) ) {
603
+ $tokens = explode(',', $sb_instagram_at );
604
+ $user_ids = array();
605
+
606
+ foreach ( $tokens as $token ) {
607
+ $account = sbi_account_data_for_token( $token );
608
+ if ( isset( $account['is_valid'] ) ) {
609
+ $split = explode( '.', $token );
610
+ $return['connected_accounts'][ $split[0] ] = array(
611
+ 'access_token' => sbi_get_parts( $token ),
612
+ 'user_id' => $split[0],
613
+ 'username' => '',
614
+ 'is_valid' => true,
615
+ 'last_checked' => time(),
616
+ 'profile_picture' => ''
617
+ );
618
+ $user_ids[] = $split[0];
619
+ }
620
+
621
+ }
622
+
623
+ $sbi_options['connected_accounts'] = $return['connected_accounts'];
624
+ $sbi_options['sb_instagram_at'] = '';
625
+ $sbi_options['sb_instagram_user_id'] = $user_ids;
626
+
627
+ $return['user_ids'] = $user_ids;
628
+
629
+ update_option( 'sb_instagram_settings', $sbi_options );
630
+ }
631
+
632
+ return $return;
633
+ }
634
+
635
+ function sbi_connect_basic_account( $new_account_details ) {
636
+
637
+ $options = sbi_get_database_settings();
638
+ $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
639
+
640
+ $accounts_to_save = array();
641
+ $old_account_user_id = '';
642
+ $ids_to_save = array();
643
+ $user_ids = is_array( $options[ 'sb_instagram_user_id' ] ) ? $options[ 'sb_instagram_user_id' ] : explode( ',', str_replace( ' ', '', $options[ 'sb_instagram_user_id' ] ) );
644
+
645
+ $profile_picture = '';
646
+
647
+ // do not connect as a basic display account if already connected as a business account
648
+ if ( isset( $connected_accounts[ $new_account_details['user_id'] ] )
649
+ && isset( $connected_accounts[ $new_account_details['user_id'] ]['type'] )
650
+ && $connected_accounts[ $new_account_details['user_id'] ]['type'] === 'business' ) {
651
+ return $options;
652
+ }
653
+
654
+ foreach ( $connected_accounts as $account ) {
655
+ $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
656
+ if ( ($account['username'] !== $new_account_details['username'])
657
+ || $account_type === 'business' ) {
658
+ $accounts_to_save[ $account['user_id'] ] = $account;
659
+ } else {
660
+ $old_account_user_id = $account['user_id'];
661
+ $profile_picture = isset( $account['profile_picture'] ) ? $account['profile_picture'] : '';
662
+ }
663
+ }
664
+
665
+ foreach ( $user_ids as $id ) {
666
+ if ( $id === $old_account_user_id ) {
667
+ $ids_to_save[] = $new_account_details['user_id'];
668
+ } else {
669
+ $ids_to_save[] = $id;
670
+ }
671
+ }
672
+
673
+ $accounts_to_save[ $new_account_details['user_id'] ] = array(
674
+ 'access_token' => sbi_fixer( $new_account_details['access_token'] ),
675
+ 'user_id' => $new_account_details['user_id'],
676
+ 'username' => $new_account_details['username'],
677
+ 'is_valid' => true,
678
+ 'last_checked' => time(),
679
+ 'expires_timestamp' => $new_account_details['expires_timestamp'],
680
+ 'profile_picture' => $profile_picture,
681
+ 'account_type' => strtolower( $new_account_details['account_type'] ),
682
+ 'type' => 'basic',
683
+ );
684
+
685
+ if ( ! empty( $old_account_user_id ) && $old_account_user_id !== $new_account_details['user_id'] ) {
686
+ $accounts_to_save[ $new_account_details['user_id'] ]['old_user_id'] = $old_account_user_id;
687
+
688
+ // get last saved header data
689
+ $fuzzy_matches = sbi_fuzzy_matching_header_data( $old_account_user_id );
690
+ if ( ! empty( $fuzzy_matches[0] ) ) {
691
+ $header_data = sbi_find_matching_data_from_results( $fuzzy_matches, $old_account_user_id );
692
+ $bio = SB_Instagram_Parse::get_bio( $header_data );
693
+ $accounts_to_save[ $new_account_details['user_id'] ]['bio'] = sbi_sanitize_emoji( $bio );
694
+ }
695
+
696
+ }
697
+
698
+ if ( ! empty( $profile_picture ) && !$options['sb_instagram_disable_resize'] ) {
699
+ if ( sbi_create_local_avatar( $new_account_details['username'], $profile_picture ) ) {
700
+ $accounts_to_save[ $new_account_details['user_id'] ]['local_avatar'] = true;
701
+ }
702
+ } else {
703
+ $accounts_to_save[ $new_account_details['user_id'] ]['local_avatar'] = false;
704
+ }
705
+
706
+ delete_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $new_account_details['user_id'] );
707
+ global $sb_instagram_posts_manager;
708
+
709
+ $sb_instagram_posts_manager->remove_error( 'at_' . $new_account_details['username'] );
710
+ $options['connected_accounts'] = $accounts_to_save;
711
+ $options['sb_instagram_user_id'] = $ids_to_save;
712
+
713
+ update_option( 'sb_instagram_settings', $options );
714
+ return $options;
715
+ }
716
+
717
+ function sbi_fuzzy_matching_header_data( $user_id ) {
718
+
719
+ if ( empty( $user_id ) || strlen( $user_id ) < 4 ) {
720
+ return array();
721
+ }
722
+ global $wpdb;
723
+ $escaped_id = esc_sql( $user_id );
724
+
725
+ $values = $wpdb->get_results( "
726
+ SELECT option_value
727
+ FROM $wpdb->options
728
+ WHERE option_name LIKE ('%!sbi\_header\_".$escaped_id."%')
729
+ LIMIT 10", ARRAY_A );
730
+
731
+ $regular_values = $wpdb->get_results( "
732
+ SELECT option_value
733
+ FROM $wpdb->options
734
+ WHERE option_name LIKE ('%sbi\_header\_".$escaped_id."%')
735
+ LIMIT 10", ARRAY_A );
736
+
737
+ $values = array_merge( $values, $regular_values );
738
+
739
+ return $values;
740
+ }
741
+
742
+ function sbi_find_matching_data_from_results( $results, $user_id ) {
743
+
744
+ $match = array();
745
+
746
+ $i = 0;
747
+
748
+ while( empty( $match ) && isset( $results[ $i ] ) ) {
749
+ if ( ! empty( $results[ $i ] ) ) {
750
+ $header_data = json_decode( $results[ $i ]['option_value'], true );
751
+ if ( isset( $header_data['id'] ) && (string)$header_data['id'] === (string)$user_id ) {
752
+ $match = $header_data;
753
+ }
754
+ }
755
+ $i++;
756
+ }
757
+
758
+ return $match;
759
+ }
760
+
761
+ function sbi_matches_existing_personal( $new_account_details ) {
762
+
763
+ $options = sbi_get_database_settings();
764
+ $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
765
+
766
+ $matches_one_account = false;
767
+ foreach ( $connected_accounts as $account ) {
768
+ $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
769
+ if ( ($account_type === 'personal' || $account_type === 'basic')
770
+ && $account['username'] == $new_account_details['username'] ) {
771
+ $matches_one_account = true;
772
+ }
773
+ }
774
+
775
+ return $matches_one_account;
776
+
777
+ }
778
+
779
+ function sbi_business_account_request( $url, $account, $remove_access_token = true ) {
780
+ $args = array(
781
+ 'timeout' => 60,
782
+ 'sslverify' => false
783
+ );
784
+ $result = wp_remote_get( $url, $args );
785
+
786
+ if ( ! is_wp_error( $result ) ) {
787
+ $response_no_at = $remove_access_token ? str_replace( sbi_maybe_clean( $account['access_token'] ), '{accesstoken}', $result['body'] ) : $result['body'];
788
+ return $response_no_at;
789
+ } else {
790
+ return wp_json_encode( $result );
791
+ }
792
+ }
793
+
794
+ function sbi_after_connection() {
795
+
796
+ if ( isset( $_POST['access_token'] ) ) {
797
+ $access_token = sanitize_text_field( $_POST['access_token'] );
798
+ $account_info = sbi_account_data_for_token( $access_token );
799
+ echo wp_json_encode( $account_info );
800
+ }
801
+
802
+ die();
803
+ }
804
+ add_action( 'wp_ajax_sbi_after_connection', 'sbi_after_connection' );
805
+
806
+ function sbi_account_type_display( $type ) {
807
+ if ( $type === 'basic' ) {
808
+ return 'personal (new API)';
809
+ }
810
+ return $type;
811
+ }
812
+
813
+ function sbi_clear_backups() {
814
+ $nonce = isset( $_POST['sbi_nonce'] ) ? sanitize_text_field( $_POST['sbi_nonce'] ) : '';
815
+
816
+ if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
817
+ die ( 'You did not do this the right way!' );
818
+ }
819
+
820
+ //Delete all transients
821
+ global $wpdb;
822
+ $table_name = $wpdb->prefix . "options";
823
+ $wpdb->query( "
824
+ DELETE
825
+ FROM $table_name
826
+ WHERE `option_name` LIKE ('%!sbi\_%')
827
+ " );
828
+ $wpdb->query( "
829
+ DELETE
830
+ FROM $table_name
831
+ WHERE `option_name` LIKE ('%\_transient\_&sbi\_%')
832
+ " );
833
+ $wpdb->query( "
834
+ DELETE
835
+ FROM $table_name
836
+ WHERE `option_name` LIKE ('%\_transient\_timeout\_&sbi\_%')
837
+ " );
838
+
839
+ die();
840
+ }
841
+ add_action( 'wp_ajax_sbi_clear_backups', 'sbi_clear_backups' );
842
+
843
+ function sbi_reset_resized() {
844
+
845
+ global $sb_instagram_posts_manager;
846
+ $sb_instagram_posts_manager->delete_all_sbi_instagram_posts();
847
+
848
+ echo "1";
849
+
850
+ die();
851
+ }
852
+ add_action( 'wp_ajax_sbi_reset_resized', 'sbi_reset_resized' );
853
+
854
+ function sbi_lite_dismiss() {
855
+ $nonce = isset( $_POST['sbi_nonce'] ) ? sanitize_text_field( $_POST['sbi_nonce'] ) : '';
856
+
857
+ if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
858
+ die ( 'You did not do this the right way!' );
859
+ }
860
+
861
+ set_transient( 'instagram_feed_dismiss_lite', 'dismiss', 1 * WEEK_IN_SECONDS );
862
+
863
+ die();
864
+ }
865
+ add_action( 'wp_ajax_sbi_lite_dismiss', 'sbi_lite_dismiss' );
866
+
867
+ function sbi_reset_log() {
868
+ global $sb_instagram_posts_manager;
869
+
870
+ $sb_instagram_posts_manager->remove_all_errors();
871
+
872
+ echo "1";
873
+
874
+ die();
875
+ }
876
+ add_action( 'wp_ajax_sbi_reset_log', 'sbi_reset_log' );
877
+
878
+ add_action('admin_notices', 'sbi_admin_error_notices');
879
+ function sbi_admin_error_notices() {
880
+
881
+
882
+ if ( isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'sb-instagram-feed' )) ) {
883
+ global $sb_instagram_posts_manager;
884
+
885
+ $errors = $sb_instagram_posts_manager->get_errors();
886
+ if ( ! empty( $errors ) && ( isset( $errors['database_create_posts'] ) || isset( $errors['database_create_posts_feeds'] ) || isset( $errors['upload_dir'] ) || isset( $errors['ajax'] ) ) ) : ?>
887
+ <div class="notice notice-warning is-dismissible sbi-admin-notice">
888
+
889
+ <?php foreach ( $sb_instagram_posts_manager->get_errors() as $type => $error ) : ?>
890
+ <?php if ( (in_array( $type, array( 'database_create_posts', 'database_create_posts_feeds', 'upload_dir' ) ) && !$sb_instagram_posts_manager->image_resizing_disabled() ) ) : ?>
891
+ <p><strong><?php echo $error[0]; ?></strong></p>
892
+ <p><?php _e( 'Note for support', 'instagram-feed' ); ?>: <?php echo $error[1]; ?></p>
893
+ <?php endif; ?>
894
+ <?php endforeach; ?>
895
+ <?php if ( ( isset( $errors['database_create_posts'] ) || isset( $errors['database_create_posts_feeds'] ) || isset( $errors['upload_dir'] ) ) && !$sb_instagram_posts_manager->image_resizing_disabled() ) : ?>
896
+ <p><?php _e( sprintf( 'Visit our %s page for help', '<a href="https://smashballoon.com/instagram-feed/support/faq/" target="_blank">FAQ</a>' ), 'instagram-feed' ); ?></p>
897
+ <?php endif; ?>
898
+
899
+ <?php foreach ( $sb_instagram_posts_manager->get_errors() as $type => $error ) : ?>
900
+ <?php if (in_array( $type, array( 'ajax' ) )) : ?>
901
+ <p class="sbi-admin-error" data-sbi-type="ajax"><strong><?php echo $error[0]; ?></strong></p>
902
+ <p><?php echo $error[1]; ?></p>
903
+ <?php endif; ?>
904
+ <?php endforeach; ?>
905
+
906
+ </div>
907
+
908
+ <?php endif;
909
+ $errors = $sb_instagram_posts_manager->get_critical_errors();
910
+ if ( $sb_instagram_posts_manager->are_critical_errors() && ! empty( $errors ) ) : ?>
911
+ <div class="notice notice-warning is-dismissible sbi-admin-notice">
912
+ <p><strong><?php echo esc_html__( 'Instagram Feed is encountering an error and your feeds may not be updating due to the following reasons:', 'instagram-feed') ; ?></strong></p>
913
+
914
+ <?php echo $errors; ?>
915
+
916
+ <?php
917
+ $error_page = $sb_instagram_posts_manager->get_error_page();
918
+ if ( $error_page ) {
919
+ echo '<a href="' . get_the_permalink( $error_page ) . '" class="sbi-clear-errors-visit-page sbi-space-left button button-secondary">' . __( 'View Feed and Retry', 'instagram-feed' ) . '</a>';
920
+ }
921
+ ?>
922
+ </div>
923
+ <?php endif;
924
+ }
925
+
926
+ }
927
+
928
+ function sbi_get_user_names_of_personal_accounts_not_also_already_updated() {
929
+ $sbi_options = get_option( 'sb_instagram_settings', array() );
930
+ $users_in_personal_accounts = array();
931
+ $non_personal_account_users = array();
932
+
933
+ $connected_accounts = isset( $sbi_options['connected_accounts'] ) ? $sbi_options['connected_accounts'] : array();
934
+
935
+ if ( ! empty( $connected_accounts ) ) {
936
+
937
+ foreach ( $connected_accounts as $account ) {
938
+ $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
939
+
940
+ if ( $account_type === 'personal' ) {
941
+ $users_in_personal_accounts[] = $account['username'];
942
+ } else {
943
+ $non_personal_account_users[] = $account['username'];
944
+ }
945
+
946
+ }
947
+
948
+ if ( ! empty( $users_in_personal_accounts ) ) {
949
+ $user_accounts_that_need_updating = array();
950
+ foreach ( $users_in_personal_accounts as $personal_user ) {
951
+ if ( ! in_array( $personal_user, $non_personal_account_users, true ) && $personal_user !== '' ) {
952
+ $user_accounts_that_need_updating[] = $personal_user;
953
+ }
954
+ }
955
+
956
+ return $user_accounts_that_need_updating;
957
+ }
958
+ } elseif ( empty( $connected_accounts ) && ! empty( $sbi_options['sb_instagram_at'] ) ) {
959
+ return array( 'your Instagram feed');
960
+ }
961
+
962
+ return array();
963
+ }
964
+
965
+ function sbi_reconnect_accounts_notice() {
966
+ if( ! current_user_can( 'manage_options' ) ) return;
967
+
968
+ $should_show_link = ! isset( $_GET['page'] ) || $_GET['page'] !== 'sb-instagram-feed';
969
+ $personal_accounts_that_need_updating = sbi_get_user_names_of_personal_accounts_not_also_already_updated();
970
+ if ( empty( $personal_accounts_that_need_updating ) ) {
971
+ return;
972
+ } else {
973
+ $total = count( $personal_accounts_that_need_updating );
974
+ if ( $total > 1 ) {
975
+ $user_string = '';
976
+ $i = 0;
977
+
978
+ foreach ( $personal_accounts_that_need_updating as $username ) {
979
+ if ( ($i + 1) === $total ) {
980
+ $user_string .= ' and ' . $username;
981
+ } else {
982
+ if ( $i !== 0 ) {
983
+ $user_string .= ', ' . $username;
984
+ } else {
985
+ $user_string .= $username;
986
+ }
987
+ }
988
+ $i++;
989
+ }
990
+ } else {
991
+ $user_string = $personal_accounts_that_need_updating[0];
992
+ }
993
+
994
+ if ( sbi_is_after_deprecation_deadline() ) {
995
+ $notice_class = 'notice-error';
996
+ $error = '<p><b>' . sprintf( __( 'Error: Instagram Feed plugin - account for %s needs to be reconnected.', 'instagram-feed' ), '<em>'.$user_string.'</em>' ) . '</b><br>' . __( 'Due to recent Instagram platform changes some Instagram accounts will need to be reconnected in the plugin in order for them to continue updating.', 'instagram-feed' );
997
+ } else {
998
+ $notice_class = 'notice-warning';
999
+ $error = '<p><b>' . sprintf( __( 'Warning: Instagram Feed plugin - account for %s needs to be reconnected.', 'instagram-feed' ), '<em>'.$user_string.'</em>' ) . '</b><br>' . __( 'Due to Instagram platform changes on June 1, 2020, some Instagram accounts will need to be reconnected in the plugin to avoid disruption to your feeds.', 'instagram-feed' );
1000
+ }
1001
+ if( !$should_show_link ) $error .= __( ' Use the big blue button below to reconnect your account.', 'instagram-feed' );
1002
+ }
1003
+ $url = admin_url( '?page=sb-instagram-feed' );
1004
+
1005
+ ?>
1006
+ <div class="notice <?php echo $notice_class; ?> is-dismissible">
1007
+ <?php echo $error; ?>
1008
+ <p>
1009
+ <?php if ( $should_show_link ) : ?>
1010
+ <a href="<?php echo $url; ?>" class="button-primary" style="margin-right:10px;"><i class="fa fa-instagram" aria-hidden="true"></i> &nbsp;Reconnect on Settings Page</a>
1011
+ <?php endif; ?>
1012
+ <a href="https://smashballoon.com/instagram-api-changes-march-2-2020/" target="_blank" rel="noopener">See more details</a>
1013
+ </p>
1014
+ </div>
1015
+
1016
+ <?php
1017
+
1018
+ }
1019
+ add_action( 'admin_notices', 'sbi_reconnect_accounts_notice' );
1020
+
1021
+ function sbi_get_current_time() {
1022
+ $current_time = time();
1023
+
1024
+ // where to do tests
1025
+ // $current_time = strtotime( 'November 25, 2022' ) + 1;
1026
+
1027
+ return $current_time;
1028
+ }
1029
+
1030
+ // generates the html for the admin notices
1031
+ function sbi_notices_html() {
1032
+
1033
+ //Only show to admins
1034
+ $current_screen = get_current_screen();
1035
+ $is_plugins_page = isset( $current_screen->id ) && $current_screen->id === 'plugins';
1036
+ $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
1037
+ //Only show to admins
1038
+ if ( ! current_user_can( 'manage_options' ) ) {
1039
+ return;
1040
+ }
1041
+
1042
+ $sbi_statuses_option = get_option( 'sbi_statuses', array() );
1043
+ $current_time = sbi_get_current_time();
1044
+ $sbi_bfcm_discount_code = 'happysmashgiving' . date('Y', $current_time );
1045
+
1046
+ // rating notice logic
1047
+ $sbi_rating_notice_option = get_option( 'sbi_rating_notice', false );
1048
+ $sbi_rating_notice_waiting = get_transient( 'instagram_feed_rating_notice_waiting' );
1049
+ $should_show_rating_notice = ($sbi_rating_notice_waiting !== 'waiting' && $sbi_rating_notice_option !== 'dismissed');
1050
+
1051
+ // black friday cyber monday logic
1052
+ $thanksgiving_this_year = sbi_get_future_date( 11, date('Y', $current_time ), 4, 4, 1 );
1053
+ $one_week_before_black_friday_this_year = $thanksgiving_this_year - 7*24*60*60;
1054
+ $one_day_after_cyber_monday_this_year = $thanksgiving_this_year + 5*24*60*60;
1055
+ $has_been_two_days_since_rating_dismissal = isset( $sbi_statuses_option['rating_notice_dismissed'] ) ? ((int)$sbi_statuses_option['rating_notice_dismissed'] + 2*24*60*60) < $current_time : true;
1056
+
1057
+ $could_show_bfcm_discount = ($current_time > $one_week_before_black_friday_this_year && $current_time < $one_day_after_cyber_monday_this_year);
1058
+ $should_show_bfcm_discount = false;
1059
+ if ( $could_show_bfcm_discount && $has_been_two_days_since_rating_dismissal ) {
1060
+ global $current_user;
1061
+ $user_id = $current_user->ID;
1062
+
1063
+ $ignore_bfcm_sale_notice_meta = get_user_meta( $user_id, 'sbi_ignore_bfcm_sale_notice' );
1064
+ $ignore_bfcm_sale_notice_meta = isset( $ignore_bfcm_sale_notice_meta[0] ) ? $ignore_bfcm_sale_notice_meta[0] : '';
1065
+
1066
+ /* Check that the user hasn't already clicked to ignore the message */
1067
+ $should_show_bfcm_discount = ($ignore_bfcm_sale_notice_meta !== 'always' && $ignore_bfcm_sale_notice_meta !== date( 'Y', $current_time ));
1068
+ }
1069
+
1070
+ // new user discount logic
1071
+ $in_new_user_month_range = true;
1072
+ $should_show_new_user_discount = false;
1073
+ $has_been_one_month_since_rating_dismissal = isset( $sbi_statuses_option['rating_notice_dismissed'] ) ? ((int)$sbi_statuses_option['rating_notice_dismissed'] + 30*24*60*60) < $current_time + 1: true;
1074
+
1075
+ if ( isset( $sbi_statuses_option['first_install'] ) && $sbi_statuses_option['first_install'] === 'from_update' ) {
1076
+ global $current_user;
1077
+ $user_id = $current_user->ID;
1078
+ $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice' );
1079
+ $ignore_new_user_sale_notice_meta = isset( $ignore_new_user_sale_notice_meta[0] ) ? $ignore_new_user_sale_notice_meta[0] : '';
1080
+ if ( $ignore_new_user_sale_notice_meta !== 'always' ) {
1081
+ $should_show_new_user_discount = true;
1082
+ }
1083
+ } elseif ( $in_new_user_month_range && $has_been_one_month_since_rating_dismissal ) {
1084
+ global $current_user;
1085
+ $user_id = $current_user->ID;
1086
+ $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice' );
1087
+ $ignore_new_user_sale_notice_meta = isset( $ignore_new_user_sale_notice_meta[0] ) ? $ignore_new_user_sale_notice_meta[0] : '';
1088
+
1089
+ if ( $ignore_new_user_sale_notice_meta !== 'always'
1090
+ && isset( $sbi_statuses_option['first_install'] )
1091
+ && $current_time > (int)$sbi_statuses_option['first_install'] + 60*60*24*30 ) {
1092
+ $should_show_new_user_discount = true;
1093
+ }
1094
+ }
1095
+
1096
+ if ( $should_show_rating_notice ) {
1097
+ $other_notice_html = '';
1098
+ $dismiss_url = add_query_arg( 'sbi_ignore_rating_notice_nag', '1' );
1099
+ $later_url = add_query_arg( 'sbi_ignore_rating_notice_nag', 'later' );
1100
+ if ( $should_show_bfcm_discount ) {
1101
+ $other_notice_html = '<p class="sbi_other_notice">' . sprintf( __( 'PS. We currently have a %sBlack Friday deal%s for 60%% off the Pro version!', 'instagram-feed' ), '<a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=notices&utm_medium=rating&discount='.$sbi_bfcm_discount_code.'" target="_blank"><b style="font-weight: 700;">', '</b></a>' ) . '</a></p>';
1102
+
1103
+ $dismiss_url = add_query_arg( array(
1104
+ 'sbi_ignore_rating_notice_nag' => '1',
1105
+ 'sbi_ignore_bfcm_sale_notice' => date( 'Y', $current_time )
1106
+ )
1107
+ );
1108
+ $later_url = add_query_arg( array(
1109
+ 'sbi_ignore_rating_notice_nag' => 'later',
1110
+ 'sbi_ignore_bfcm_sale_notice' => date( 'Y', $current_time )
1111
+ )
1112
+ );
1113
+ }
1114
+
1115
+ echo "
1116
+ <div class='sbi_notice sbi_review_notice'>
1117
+ <img src='". SBI_PLUGIN_URL . 'img/sbi-icon.png' ."' alt='" . __( 'Instagram Feed', 'instagram-feed' ) . "'>
1118
+ <div class='sbi-notice-text'>
1119
+ <p style='padding-top: 4px;'>" . sprintf( __( "It's great to see that you've been using the %sInstagram Feed%s plugin for a while now. Hopefully you're happy with it!&nbsp; If so, would you consider leaving a positive review? It really helps to support the plugin and helps others to discover it too!", 'instagram-feed' ), '<strong style=\'font-weight: 700;\'>', '</strong>' ) . "</p>
1120
+ <p class='links'";
1121
+ if( $should_show_bfcm_discount ) echo " style='margin-top: 0 !important;'";
1122
+ echo ">
1123
+ <a class='sbi_notice_dismiss' href='https://wordpress.org/support/plugin/instagram-feed/reviews/' target='_blank'>" . __( 'Sure, I\'d love to!', 'instagram-feed' ) . "</a>
1124
+ &middot;
1125
+ <a class='sbi_notice_dismiss' href='" .esc_url( $dismiss_url ). "'>" . __( 'No thanks', 'instagram-feed' ) . "</a>
1126
+ &middot;
1127
+ <a class='sbi_notice_dismiss' href='" .esc_url( $dismiss_url ). "'>" . __( 'I\'ve already given a review', 'instagram-feed' ) . "</a>
1128
+ &middot;
1129
+ <a class='sbi_notice_dismiss' href='" .esc_url( $later_url ). "'>" . __( 'Ask Me Later', 'instagram-feed' ) . "</a>
1130
+ </p>"
1131
+ . $other_notice_html .
1132
+ "</div>
1133
+ <a class='sbi_notice_close' href='" .esc_url( $dismiss_url ). "'><i class='fa fa-close'></i></a>
1134
+ </div>";
1135
+
1136
+ } elseif ( $should_show_new_user_discount ) {
1137
+ global $current_user;
1138
+ $user_id = $current_user->ID;
1139
+ $ignore_new_user_sale_notice_meta = get_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice' );
1140
+ if ( $ignore_new_user_sale_notice_meta !== 'always' ) {
1141
+
1142
+ echo "
1143
+ <div class='sbi_notice sbi_review_notice sbi_new_user_sale_notice'>
1144
+ <img src='" . SBI_PLUGIN_URL . 'img/sbi-icon-offer.png' . "' alt='Instagram Feed'>
1145
+ <div class='sbi-notice-text'>
1146
+ <p><b style'font-weight: 700;'>" . sprintf( __( 'Exclusive offer!%s We don\'t run promotions very often, but for a limited time we\'re offering %s60%% off%s our Pro version to all users of our free Instagram Feed plugin.', 'instagram-feed' ), '</b> ', '<b style="font-weight: 700;">', '</b>' ) . "</p>
1147
+ <p class='sbi-links'>
1148
+ <a class='sbi_notice_dismiss sbi_offer_btn' href='https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=notices&utm_medium=newuser&discount=instagramthankyou' target='_blank'><b>" . __( 'Get this offer', 'instagram-feed' ) . "</b></a>
1149
+ <a class='sbi_notice_dismiss' style='margin-left: 5px;' href='" . esc_url( add_query_arg( 'sbi_ignore_new_user_sale_notice', 'always' ) ) . "'>" . __( 'I\'m not interested', 'instagram-feed' ) . "</a>
1150
+
1151
+ </p>
1152
+ </div>
1153
+ <a class='sbi_new_user_sale_notice_close' href='" . esc_url( add_query_arg( 'sbi_ignore_new_user_sale_notice', 'always' ) ) . "'><i class='fa fa-close'></i></a>
1154
+ </div>
1155
+ ";
1156
+ }
1157
+
1158
+ } elseif ( $should_show_bfcm_discount ) {
1159
+
1160
+ echo "
1161
+ <div class='sbi_notice sbi_review_notice sbi_bfcm_sale_notice'>
1162
+ <img src='". SBI_PLUGIN_URL . 'img/sbi-icon-offer.png' ."' alt='Instagram Feed'>
1163
+ <div class='sbi-notice-text'>
1164
+ <p>" . sprintf( __( '%sBlack Friday/Cyber Monday Deal!%s Thank you for using our free Instagram Feed plugin. For a limited time, we\'re offering %s60%% off%s the Pro version for all of our users.', 'instagram-feed' ), '<b style="font-weight: 700;">', '</b>', '<b style="font-weight: 700;">', '</b>' ) . "</p>
1165
+ <p class='sbi-links'>
1166
+ <a class='sbi_notice_dismiss sbi_offer_btn' href='https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=notices&utm_medium=bfcm&discount=".$sbi_bfcm_discount_code."' target='_blank'>" . __( 'Get this offer!', 'instagram-feed' ) . "</a>
1167
+ <a class='sbi_notice_dismiss' style='margin-left: 5px;' href='" .esc_url( add_query_arg( 'sbi_ignore_bfcm_sale_notice', date( 'Y', $current_time ) ) ). "'>" . __( 'I\'m not interested', 'instagram-feed' ) . "</a>
1168
+ </p>
1169
+ </div>
1170
+ <a class='sbi_bfcm_sale_notice_close' href='" .esc_url( add_query_arg( 'sbi_ignore_bfcm_sale_notice', date( 'Y', $current_time ) ) ). "'><i class='fa fa-close'></i></a>
1171
+ </div>
1172
+ ";
1173
+
1174
+ }
1175
+
1176
+ }
1177
+ add_action( 'admin_notices', 'sbi_notices_html', 8 ); // priority 12 for Twitter, priority 10 for Facebook
1178
+
1179
+ function sbi_process_nags() {
1180
+
1181
+ global $current_user;
1182
+ $user_id = $current_user->ID;
1183
+ $sbi_statuses_option = get_option( 'sbi_statuses', array() );
1184
+
1185
+ if ( isset( $_GET['sbi_ignore_rating_notice_nag'] ) ) {
1186
+ if ( (int)$_GET['sbi_ignore_rating_notice_nag'] === 1 ) {
1187
+ update_option( 'sbi_rating_notice', 'dismissed', false );
1188
+ $sbi_statuses_option['rating_notice_dismissed'] = sbi_get_current_time();
1189
+ update_option( 'sbi_statuses', $sbi_statuses_option, false );
1190
+
1191
+ } elseif ( $_GET['sbi_ignore_rating_notice_nag'] === 'later' ) {
1192
+ set_transient( 'instagram_feed_rating_notice_waiting', 'waiting', 2 * WEEK_IN_SECONDS );
1193
+ update_option( 'sbi_rating_notice', 'pending', false );
1194
+ }
1195
+ }
1196
+
1197
+ if ( isset( $_GET['sbi_ignore_new_user_sale_notice'] ) ) {
1198
+ $response = sanitize_text_field( $_GET['sbi_ignore_new_user_sale_notice'] );
1199
+ if ( $response === 'always' ) {
1200
+ update_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice', 'always' );
1201
+
1202
+ $current_month_number = (int)date('n', sbi_get_current_time() );
1203
+ $not_early_in_the_year = ($current_month_number > 5);
1204
+
1205
+ if ( $not_early_in_the_year ) {
1206
+ update_user_meta( $user_id, 'sbi_ignore_bfcm_sale_notice', date( 'Y', sbi_get_current_time() ) );
1207
+ }
1208
+
1209
+ }
1210
+ }
1211
+
1212
+ if ( isset( $_GET['sbi_ignore_bfcm_sale_notice'] ) ) {
1213
+ $response = sanitize_text_field( $_GET['sbi_ignore_bfcm_sale_notice'] );
1214
+ if ( $response === 'always' ) {
1215
+ update_user_meta( $user_id, 'sbi_ignore_bfcm_sale_notice', 'always' );
1216
+ } elseif ( $response === date( 'Y', sbi_get_current_time() ) ) {
1217
+ update_user_meta( $user_id, 'sbi_ignore_bfcm_sale_notice', date( 'Y', sbi_get_current_time() ) );
1218
+ }
1219
+ update_user_meta( $user_id, 'sbi_ignore_new_user_sale_notice', 'always' );
1220
+ }
1221
+
1222
+ }
1223
+ add_action( 'admin_init', 'sbi_process_nags' );
1224
+
1225
+ function sbi_get_future_date( $month, $year, $week, $day, $direction ) {
1226
+ if ( $direction > 0 ) {
1227
+ $startday = 1;
1228
+ } else {
1229
+ $startday = date( 't', mktime(0, 0, 0, $month, 1, $year ) );
1230
+ }
1231
+
1232
+ $start = mktime( 0, 0, 0, $month, $startday, $year );
1233
+ $weekday = date( 'N', $start );
1234
+
1235
+ $offset = 0;
1236
+ if ( $direction * $day >= $direction * $weekday ) {
1237
+ $offset = -$direction * 7;
1238
+ }
1239
+
1240
+ $offset += $direction * ($week * 7) + ($day - $weekday);
1241
+ return mktime( 0, 0, 0, $month, $startday + $offset, $year );
1242
+ }
1243
+
1244
+ function sbi_admin_hide_unrelated_notices() {
1245
+
1246
+ // Bail if we're not on a sbi screen or page.
1247
+ if ( ! isset( $_GET['page'] ) || strpos( $_GET['page'], 'sb-instagram-feed') === false ) {
1248
+ return;
1249
+ }
1250
+
1251
+ // Extra banned classes and callbacks from third-party plugins.
1252
+ $blacklist = array(
1253
+ 'classes' => array(),
1254
+ 'callbacks' => array(
1255
+ 'sbidb_admin_notice', // 'Database for sbi' plugin.
1256
+ ),
1257
+ );
1258
+
1259
+ global $wp_filter;
1260
+
1261
+ foreach ( array( 'user_admin_notices', 'admin_notices', 'all_admin_notices' ) as $notices_type ) {
1262
+ if ( empty( $wp_filter[ $notices_type ]->callbacks ) || ! is_array( $wp_filter[ $notices_type ]->callbacks ) ) {
1263
+ continue;
1264
+ }
1265
+ foreach ( $wp_filter[ $notices_type ]->callbacks as $priority => $hooks ) {
1266
+ foreach ( $hooks as $name => $arr ) {
1267
+ if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
1268
+ unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
1269
+ continue;
1270
+ }
1271
+ $class = ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) ? strtolower( get_class( $arr['function'][0] ) ) : '';
1272
+ if (
1273
+ ! empty( $class ) &&
1274
+ strpos( $class, 'sbi' ) !== false &&
1275
+ ! in_array( $class, $blacklist['classes'], true )
1276
+ ) {
1277
+ continue;
1278
+ }
1279
+ if (
1280
+ ! empty( $name ) && (
1281
+ strpos( $name, 'sbi' ) === false ||
1282
+ in_array( $class, $blacklist['classes'], true ) ||
1283
+ in_array( $name, $blacklist['callbacks'], true )
1284
+ )
1285
+ ) {
1286
+ unset( $wp_filter[ $notices_type ]->callbacks[ $priority ][ $name ] );
1287
+ }
1288
+ }
1289
+ }
1290
+ }
1291
+ }
1292
+ add_action( 'admin_print_scripts', 'sbi_admin_hide_unrelated_notices' );
1293
+
1294
+ /* Usage */
1295
+ add_action( 'admin_notices', 'sbi_usage_opt_in' );
1296
+ function sbi_usage_opt_in() {
1297
+ $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
1298
+
1299
+ $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
1300
+ if ( ! current_user_can( $cap ) ) {
1301
+ return;
1302
+ }
1303
+ $usage_tracking = sbi_get_option( 'sbi_usage_tracking', false );
1304
+ if ( $usage_tracking ) {
1305
+ return;
1306
+ }
1307
+ ?>
1308
+ <div class="notice notice-warning is-dismissible sbi-admin-notice">
1309
+
1310
+ <p>
1311
+ <strong><?php echo __( 'Help us improve the Instagram Feed plugin', 'instagram-feed' ); ?></strong><br>
1312
+ <?php echo __( 'Understanding how you are using the plugin allows us to further improve it. Opt-in below to agree to send a weekly report of plugin usage data.', 'instagram-feed' ); ?>
1313
+ <a target="_blank" rel="noopener noreferrer" href="https://smashballoon.com/instagram-feed/usage-tracking/"><?php echo __( 'More information', 'instagram-feed' ); ?></a>
1314
+ </p>
1315
+ <p>
1316
+ <button class="button button-primary sb-opt-in"><?php echo __( 'Yes, I\'d like to help', 'instagram-feed' ); ?></button>
1317
+ <button class="sb-no-usage-opt-out sbi-space-left button button-secondary"><?php echo __( 'No, thanks', 'instagram-feed' ); ?></button>
1318
+ </p>
1319
+
1320
+ </div>
1321
+
1322
+ <?php
1323
+ }
1324
+
1325
+ function sbi_usage_opt_in_or_out() {
1326
+ $nonce = isset( $_POST['sbi_nonce'] ) ? sanitize_text_field( $_POST['sbi_nonce'] ) : '';
1327
+
1328
+ if ( ! wp_verify_nonce( $nonce, 'sbi_nonce' ) ) {
1329
+ die ( 'You did not do this the right way!' );
1330
+ }
1331
+
1332
+ $usage_tracking = sbi_get_option( 'sbi_usage_tracking', array( 'last_send' => 0, 'enabled' => false ) );
1333
+
1334
+ $usage_tracking['enabled'] = isset( $_POST['opted_in'] ) ? $_POST['opted_in'] === 'true' : false;
1335
+
1336
+ sbi_update_option( 'sbi_usage_tracking', $usage_tracking, false );
1337
+
1338
+ die();
1339
+ }
1340
+ add_action( 'wp_ajax_sbi_usage_opt_in_or_out', 'sbi_usage_opt_in_or_out' );
inc/admin/addon-functions.php CHANGED
@@ -1,175 +1,175 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
-
4
- /**
5
- * Deactivate addon.
6
- *
7
- * @since 1.0.0
8
- */
9
- function sbi_deactivate_addon() {
10
-
11
- // Run a security check.
12
- check_ajax_referer( 'sbi-admin', 'nonce' );
13
-
14
- // Check for permissions.
15
- if ( ! current_user_can( 'manage_instagram_feed_options' ) ) {
16
- wp_send_json_error();
17
- }
18
-
19
- $type = 'addon';
20
- if ( ! empty( $_POST['type'] ) ) {
21
- $type = sanitize_key( $_POST['type'] );
22
- }
23
-
24
- if ( isset( $_POST['plugin'] ) ) {
25
- deactivate_plugins( $_POST['plugin'] );
26
-
27
- if ( 'plugin' === $type ) {
28
- wp_send_json_success( esc_html__( 'Plugin deactivated.', 'instagram-feed' ) );
29
- } else {
30
- wp_send_json_success( esc_html__( 'Addon deactivated.', 'instagram-feed' ) );
31
- }
32
- }
33
-
34
- wp_send_json_error( esc_html__( 'Could not deactivate the addon. Please deactivate from the Plugins page.', 'instagram-feed' ) );
35
- }
36
- add_action( 'wp_ajax_sbi_deactivate_addon', 'sbi_deactivate_addon' );
37
-
38
- /**
39
- * Activate addon.
40
- *
41
- * @since 1.0.0
42
- */
43
- function sbi_activate_addon() {
44
-
45
- // Run a security check.
46
- check_ajax_referer( 'sbi-admin', 'nonce' );
47
-
48
- // Check for permissions.
49
- if ( ! current_user_can( 'manage_instagram_feed_options' ) ) {
50
- wp_send_json_error();
51
- }
52
-
53
- if ( isset( $_POST['plugin'] ) ) {
54
-
55
- $type = 'addon';
56
- if ( ! empty( $_POST['type'] ) ) {
57
- $type = sanitize_key( $_POST['type'] );
58
- }
59
-
60
- $activate = activate_plugins( $_POST['plugin'] );
61
-
62
- if ( ! is_wp_error( $activate ) ) {
63
- if ( 'plugin' === $type ) {
64
- wp_send_json_success( esc_html__( 'Plugin activated.', 'instagram-feed' ) );
65
- } else {
66
- wp_send_json_success( esc_html__( 'Addon activated.', 'instagram-feed' ) );
67
- }
68
- }
69
- }
70
-
71
- wp_send_json_error( esc_html__( 'Could not activate addon. Please activate from the Plugins page.', 'instagram-feed' ) );
72
- }
73
- add_action( 'wp_ajax_sbi_activate_addon', 'sbi_activate_addon' );
74
-
75
- /**
76
- * Install addon.
77
- *
78
- * @since 1.0.0
79
- */
80
- function sbi_install_addon() {
81
-
82
- // Run a security check.
83
- check_ajax_referer( 'sbi-admin', 'nonce' );
84
-
85
- // Check for permissions.
86
- if ( ! current_user_can( 'manage_instagram_feed_options' ) ) {
87
- wp_send_json_error();
88
- }
89
-
90
- $error = esc_html__( 'Could not install addon. Please download from wpforms.com and install manually.', 'instagram-feed' );
91
-
92
- if ( empty( $_POST['plugin'] ) ) {
93
- wp_send_json_error( $error );
94
- }
95
-
96
- // Set the current screen to avoid undefined notices.
97
- set_current_screen( 'sb-instagram-feed-about' );
98
-
99
- // Prepare variables.
100
- $url = esc_url_raw(
101
- add_query_arg(
102
- array(
103
- 'page' => 'sb-instagram-feed-about',
104
- ),
105
- admin_url( 'admin.php' )
106
- )
107
- );
108
-
109
- $creds = request_filesystem_credentials( $url, '', false, false, null );
110
-
111
- // Check for file system permissions.
112
- if ( false === $creds ) {
113
- wp_send_json_error( $error );
114
- }
115
-
116
- if ( ! WP_Filesystem( $creds ) ) {
117
- wp_send_json_error( $error );
118
- }
119
-
120
- /*
121
- * We do not need any extra credentials if we have gotten this far, so let's install the plugin.
122
- */
123
-
124
- require_once SBI_PLUGIN_DIR . 'inc/admin/class-install-skin.php';
125
-
126
- // Do not allow WordPress to search/download translations, as this will break JS output.
127
- remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
128
-
129
- // Create the plugin upgrader with our custom skin.
130
- $installer = new Sbi\Helpers\PluginSilentUpgrader( new Sbi_Install_Skin() );
131
-
132
- // Error check.
133
- if ( ! method_exists( $installer, 'install' ) || empty( $_POST['plugin'] ) ) {
134
- wp_send_json_error( $error );
135
- }
136
-
137
- $installer->install( $_POST['plugin'] ); // phpcs:ignore
138
-
139
- // Flush the cache and return the newly installed plugin basename.
140
- wp_cache_flush();
141
-
142
- $plugin_basename = $installer->plugin_info();
143
-
144
- if ( $plugin_basename ) {
145
-
146
- $type = 'addon';
147
- if ( ! empty( $_POST['type'] ) ) {
148
- $type = sanitize_key( $_POST['type'] );
149
- }
150
-
151
- // Activate the plugin silently.
152
- $activated = activate_plugin( $plugin_basename );
153
-
154
- if ( ! is_wp_error( $activated ) ) {
155
- wp_send_json_success(
156
- array(
157
- 'msg' => 'plugin' === $type ? esc_html__( 'Plugin installed & activated.', 'instagram-feed' ) : esc_html__( 'Addon installed & activated.', 'instagram-feed' ),
158
- 'is_activated' => true,
159
- 'basename' => $plugin_basename,
160
- )
161
- );
162
- } else {
163
- wp_send_json_success(
164
- array(
165
- 'msg' => 'plugin' === $type ? esc_html__( 'Plugin installed.', 'instagram-feed' ) : esc_html__( 'Addon installed.', 'instagram-feed' ),
166
- 'is_activated' => false,
167
- 'basename' => $plugin_basename,
168
- )
169
- );
170
- }
171
- }
172
-
173
- wp_send_json_error( $error );
174
- }
175
  add_action( 'wp_ajax_sbi_install_addon', 'sbi_install_addon' );
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+ /**
5
+ * Deactivate addon.
6
+ *
7
+ * @since 1.0.0
8
+ */
9
+ function sbi_deactivate_addon() {
10
+
11
+ // Run a security check.
12
+ check_ajax_referer( 'sbi-admin', 'nonce' );
13
+
14
+ // Check for permissions.
15
+ if ( ! current_user_can( 'manage_instagram_feed_options' ) ) {
16
+ wp_send_json_error();
17
+ }
18
+
19
+ $type = 'addon';
20
+ if ( ! empty( $_POST['type'] ) ) {
21
+ $type = sanitize_key( $_POST['type'] );
22
+ }
23
+
24
+ if ( isset( $_POST['plugin'] ) ) {
25
+ deactivate_plugins( $_POST['plugin'] );
26
+
27
+ if ( 'plugin' === $type ) {
28
+ wp_send_json_success( esc_html__( 'Plugin deactivated.', 'instagram-feed' ) );
29
+ } else {
30
+ wp_send_json_success( esc_html__( 'Addon deactivated.', 'instagram-feed' ) );
31
+ }
32
+ }
33
+
34
+ wp_send_json_error( esc_html__( 'Could not deactivate the addon. Please deactivate from the Plugins page.', 'instagram-feed' ) );
35
+ }
36
+ add_action( 'wp_ajax_sbi_deactivate_addon', 'sbi_deactivate_addon' );
37
+
38
+ /**
39
+ * Activate addon.
40
+ *
41
+ * @since 1.0.0
42
+ */
43
+ function sbi_activate_addon() {
44
+
45
+ // Run a security check.
46
+ check_ajax_referer( 'sbi-admin', 'nonce' );
47
+
48
+ // Check for permissions.
49
+ if ( ! current_user_can( 'manage_instagram_feed_options' ) ) {
50
+ wp_send_json_error();
51
+ }
52
+
53
+ if ( isset( $_POST['plugin'] ) ) {
54
+
55
+ $type = 'addon';
56
+ if ( ! empty( $_POST['type'] ) ) {
57
+ $type = sanitize_key( $_POST['type'] );
58
+ }
59
+
60
+ $activate = activate_plugins( $_POST['plugin'] );
61
+
62
+ if ( ! is_wp_error( $activate ) ) {
63
+ if ( 'plugin' === $type ) {
64
+ wp_send_json_success( esc_html__( 'Plugin activated.', 'instagram-feed' ) );
65
+ } else {
66
+ wp_send_json_success( esc_html__( 'Addon activated.', 'instagram-feed' ) );
67
+ }
68
+ }
69
+ }
70
+
71
+ wp_send_json_error( esc_html__( 'Could not activate addon. Please activate from the Plugins page.', 'instagram-feed' ) );
72
+ }
73
+ add_action( 'wp_ajax_sbi_activate_addon', 'sbi_activate_addon' );
74
+
75
+ /**
76
+ * Install addon.
77
+ *
78
+ * @since 1.0.0
79
+ */
80
+ function sbi_install_addon() {
81
+
82
+ // Run a security check.
83
+ check_ajax_referer( 'sbi-admin', 'nonce' );
84
+
85
+ // Check for permissions.
86
+ if ( ! current_user_can( 'manage_instagram_feed_options' ) ) {
87
+ wp_send_json_error();
88
+ }
89
+
90
+ $error = esc_html__( 'Could not install addon. Please download from wpforms.com and install manually.', 'instagram-feed' );
91
+
92
+ if ( empty( $_POST['plugin'] ) ) {
93
+ wp_send_json_error( $error );
94
+ }
95
+
96
+ // Set the current screen to avoid undefined notices.
97
+ set_current_screen( 'sb-instagram-feed-about' );
98
+
99
+ // Prepare variables.
100
+ $url = esc_url_raw(
101
+ add_query_arg(
102
+ array(
103
+ 'page' => 'sb-instagram-feed-about',
104
+ ),
105
+ admin_url( 'admin.php' )
106
+ )
107
+ );
108
+
109
+ $creds = request_filesystem_credentials( $url, '', false, false, null );
110
+
111
+ // Check for file system permissions.
112
+ if ( false === $creds ) {
113
+ wp_send_json_error( $error );
114
+ }
115
+
116
+ if ( ! WP_Filesystem( $creds ) ) {
117
+ wp_send_json_error( $error );
118
+ }
119
+
120
+ /*
121
+ * We do not need any extra credentials if we have gotten this far, so let's install the plugin.
122
+ */
123
+
124
+ require_once SBI_PLUGIN_DIR . 'inc/admin/class-install-skin.php';
125
+
126
+ // Do not allow WordPress to search/download translations, as this will break JS output.
127
+ remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
128
+
129
+ // Create the plugin upgrader with our custom skin.
130
+ $installer = new Sbi\Helpers\PluginSilentUpgrader( new Sbi_Install_Skin() );
131
+
132
+ // Error check.
133
+ if ( ! method_exists( $installer, 'install' ) || empty( $_POST['plugin'] ) ) {
134
+ wp_send_json_error( $error );
135
+ }
136
+
137
+ $installer->install( $_POST['plugin'] ); // phpcs:ignore
138
+
139
+ // Flush the cache and return the newly installed plugin basename.
140
+ wp_cache_flush();
141
+
142
+ $plugin_basename = $installer->plugin_info();
143
+
144
+ if ( $plugin_basename ) {
145
+
146
+ $type = 'addon';
147
+ if ( ! empty( $_POST['type'] ) ) {
148
+ $type = sanitize_key( $_POST['type'] );
149
+ }
150
+
151
+ // Activate the plugin silently.
152
+ $activated = activate_plugin( $plugin_basename );
153
+
154
+ if ( ! is_wp_error( $activated ) ) {
155
+ wp_send_json_success(
156
+ array(
157
+ 'msg' => 'plugin' === $type ? esc_html__( 'Plugin installed & activated.', 'instagram-feed' ) : esc_html__( 'Addon installed & activated.', 'instagram-feed' ),
158
+ 'is_activated' => true,
159
+ 'basename' => $plugin_basename,
160
+ )
161
+ );
162
+ } else {
163
+ wp_send_json_success(
164
+ array(
165
+ 'msg' => 'plugin' === $type ? esc_html__( 'Plugin installed.', 'instagram-feed' ) : esc_html__( 'Addon installed.', 'instagram-feed' ),
166
+ 'is_activated' => false,
167
+ 'basename' => $plugin_basename,
168
+ )
169
+ );
170
+ }
171
+ }
172
+
173
+ wp_send_json_error( $error );
174
+ }
175
  add_action( 'wp_ajax_sbi_install_addon', 'sbi_install_addon' );
inc/admin/blocks/class-sbi-blocks.php CHANGED
@@ -1,149 +1,149 @@
1
- <?php
2
- /**
3
- * Instagram Feed block with live preview.
4
- *
5
- * @since 2.3
6
- */
7
- class SB_Instagram_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 2.3
24
- */
25
- public function load() {
26
- $this->hooks();
27
- }
28
-
29
- /**
30
- * Integration hooks.
31
- *
32
- * @since 2.3
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 2.3
43
- */
44
- public function register_block() {
45
-
46
- wp_register_style(
47
- 'sbi-blocks-styles',
48
- trailingslashit( SBI_PLUGIN_URL ) . 'css/sb-blocks.css',
49
- array( 'wp-edit-blocks' ),
50
- SBIVER
51
- );
52
-
53
- $attributes = array(
54
- 'shortcodeSettings' => array(
55
- 'type' => 'string',
56
- ),
57
- 'noNewChanges' => array(
58
- 'type' => 'boolean',
59
- )
60
- );
61
-
62
- register_block_type(
63
- 'sbi/sbi-feed-block',
64
- array(
65
- 'attributes' => $attributes,
66
- 'render_callback' => array( $this, 'get_feed_html' ),
67
- )
68
- );
69
- }
70
-
71
- /**
72
- * Load Instagram Feed Gutenberg block scripts.
73
- *
74
- * @since 2.3
75
- */
76
- public function enqueue_block_editor_assets() {
77
- $db = sbi_get_database_settings();
78
-
79
- sb_instagram_scripts_enqueue();
80
-
81
- wp_enqueue_style( 'sbi-blocks-styles' );
82
- wp_enqueue_script(
83
- 'sbi-feed-block',
84
- trailingslashit( SBI_PLUGIN_URL ) . 'js/sb-blocks.js',
85
- array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
86
- SBIVER,
87
- true
88
- );
89
-
90
- $shortcodeSettings = '';
91
-
92
- $i18n = array(
93
- 'addSettings' => esc_html__( 'Add Settings', 'instagram-feed' ),
94
- 'shortcodeSettings' => esc_html__( 'Shortcode Settings', 'instagram-feed' ),
95
- 'example' => esc_html__( 'Example', 'instagram-feed' ),
96
- 'preview' => esc_html__( 'Apply Changes', 'instagram-feed' ),
97
-
98
- );
99
-
100
- wp_localize_script(
101
- 'sbi-feed-block',
102
- 'sbi_block_editor',
103
- array(
104
- 'wpnonce' => wp_create_nonce( 'sb-instagram-blocks' ),
105
- 'canShowFeed' => ! empty( $db['connected_accounts'] ),
106
- 'configureLink' => get_admin_url() . '?page=sb-instagram-feed',
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 2.3
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( '[instagram-feed', ']' ), '', $shortcode_settings );
129
-
130
- $return .= do_shortcode( '[instagram-feed '.$shortcode_settings.']' );
131
-
132
- return $return;
133
-
134
- }
135
-
136
- /**
137
- * Checking if is Gutenberg REST API call.
138
- *
139
- * @since 2.3
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 2.3
6
+ */
7
+ class SB_Instagram_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 2.3
24
+ */
25
+ public function load() {
26
+ $this->hooks();
27
+ }
28
+
29
+ /**
30
+ * Integration hooks.
31
+ *
32
+ * @since 2.3
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 2.3
43
+ */
44
+ public function register_block() {
45
+
46
+ wp_register_style(
47
+ 'sbi-blocks-styles',
48
+ trailingslashit( SBI_PLUGIN_URL ) . 'css/sb-blocks.css',
49
+ array( 'wp-edit-blocks' ),
50
+ SBIVER
51
+ );
52
+
53
+ $attributes = array(
54
+ 'shortcodeSettings' => array(
55
+ 'type' => 'string',
56
+ ),
57
+ 'noNewChanges' => array(
58
+ 'type' => 'boolean',
59
+ )
60
+ );
61
+
62
+ register_block_type(
63
+ 'sbi/sbi-feed-block',
64
+ array(
65
+ 'attributes' => $attributes,
66
+ 'render_callback' => array( $this, 'get_feed_html' ),
67
+ )
68
+ );
69
+ }
70
+
71
+ /**
72
+ * Load Instagram Feed Gutenberg block scripts.
73
+ *
74
+ * @since 2.3
75
+ */
76
+ public function enqueue_block_editor_assets() {
77
+ $db = sbi_get_database_settings();
78
+
79
+ sb_instagram_scripts_enqueue();
80
+
81
+ wp_enqueue_style( 'sbi-blocks-styles' );
82
+ wp_enqueue_script(
83
+ 'sbi-feed-block',
84
+ trailingslashit( SBI_PLUGIN_URL ) . 'js/sb-blocks.js',
85
+ array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
86
+ SBIVER,
87
+ true
88
+ );
89
+
90
+ $shortcodeSettings = '';
91
+
92
+ $i18n = array(
93
+ 'addSettings' => esc_html__( 'Add Settings', 'instagram-feed' ),
94
+ 'shortcodeSettings' => esc_html__( 'Shortcode Settings', 'instagram-feed' ),
95
+ 'example' => esc_html__( 'Example', 'instagram-feed' ),
96
+ 'preview' => esc_html__( 'Apply Changes', 'instagram-feed' ),
97
+
98
+ );
99
+
100
+ wp_localize_script(
101
+ 'sbi-feed-block',
102
+ 'sbi_block_editor',
103
+ array(
104
+ 'wpnonce' => wp_create_nonce( 'sb-instagram-blocks' ),
105
+ 'canShowFeed' => ! empty( $db['connected_accounts'] ),
106
+ 'configureLink' => get_admin_url() . '?page=sb-instagram-feed',
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 2.3
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( '[instagram-feed', ']' ), '', $shortcode_settings );
129
+
130
+ $return .= do_shortcode( '[instagram-feed '.$shortcode_settings.']' );
131
+
132
+ return $return;
133
+
134
+ }
135
+
136
+ /**
137
+ * Checking if is Gutenberg REST API call.
138
+ *
139
+ * @since 2.3
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/admin/class-install-skin.php CHANGED
@@ -1,27 +1,27 @@
1
- <?php
2
-
3
- use Sbi\Helpers\PluginSilentUpgraderSkin;
4
-
5
- /**
6
- * Skin for on-the-fly addon installations.
7
- *
8
- * @since 1.0.0
9
- * @since 1.5.6.1 Extend PluginSilentUpgraderSkin and clean up the class.
10
- */
11
- class Sbi_Install_Skin extends PluginSilentUpgraderSkin {
12
-
13
- /**
14
- * Instead of outputting HTML for errors, json_encode the errors and send them
15
- * back to the Ajax script for processing.
16
- *
17
- * @since 1.0.0
18
- *
19
- * @param array $errors Array of errors with the install process.
20
- */
21
- public function error( $errors ) {
22
-
23
- if ( ! empty( $errors ) ) {
24
- wp_send_json_error( $errors );
25
- }
26
- }
27
- }
1
+ <?php
2
+
3
+ use Sbi\Helpers\PluginSilentUpgraderSkin;
4
+
5
+ /**
6
+ * Skin for on-the-fly addon installations.
7
+ *
8
+ * @since 1.0.0
9
+ * @since 1.5.6.1 Extend PluginSilentUpgraderSkin and clean up the class.
10
+ */
11
+ class Sbi_Install_Skin extends PluginSilentUpgraderSkin {
12
+
13
+ /**
14
+ * Instead of outputting HTML for errors, json_encode the errors and send them
15
+ * back to the Ajax script for processing.
16
+ *
17
+ * @since 1.0.0
18
+ *
19
+ * @param array $errors Array of errors with the install process.
20
+ */
21
+ public function error( $errors ) {
22
+
23
+ if ( ! empty( $errors ) ) {
24
+ wp_send_json_error( $errors );
25
+ }
26
+ }
27
+ }
inc/admin/class-sbi-about.php CHANGED
@@ -1,1317 +1,1317 @@
1
- <?php
2
-
3
- /**
4
- * About Sbi admin page class.
5
- *
6
- * @since 2.4/5.5
7
- */
8
- class SB_Instagram_About {
9
-
10
- /**
11
- * Admin menu page slug.
12
- *
13
- * @since 2.4/5.5
14
- *
15
- * @var string
16
- */
17
- const SLUG = 'sb-instagram-feed-about';
18
-
19
- /**
20
- * Default view for a page.
21
- *
22
- * @since 2.4/5.5
23
- *
24
- * @var string
25
- */
26
- const DEFAULT_TAB = 'about';
27
-
28
- /**
29
- * Array of license types, that are considered being top level and has no features difference.
30
- *
31
- * @since 2.4/5.5
32
- *
33
- * @var array
34
- */
35
- public static $licenses_top = array( 'pro', 'agency', 'ultimate', 'elite' );
36
-
37
- /**
38
- * List of features that licenses are different with.
39
- *
40
- * @since 2.4/5.5
41
- *
42
- * @var array
43
- */
44
- public static $licenses_features = array();
45
-
46
- /**
47
- * The current active tab.
48
- *
49
- * @since 2.4/5.5
50
- *
51
- * @var string
52
- */
53
- public $view;
54
-
55
- /**
56
- * The core views.
57
- *
58
- * @since 2.4/5.5
59
- *
60
- * @var array
61
- */
62
- public $views = array();
63
-
64
- /**
65
- * Primary class constructor.
66
- *
67
- * @since 2.4/5.5
68
- */
69
- public function __construct() {
70
-
71
- // In old PHP we can't define this elsewhere.
72
- self::$licenses_features = array(
73
- 'entries' => esc_html__( 'Feed Types', 'instagram-feed' ),
74
- 'fields' => esc_html__( 'Layouts', 'instagram-feed' ),
75
- 'templates' => esc_html__( 'Post Information', 'instagram-feed' ),
76
- 'conditionals' => esc_html__( 'Image and Video Display', 'instagram-feed' ),
77
- 'addons' => esc_html__( 'Filtering', 'instagram-feed' ),
78
- //'marketing' => esc_html__( 'Filtering', 'instagram-feed' ),
79
- 'marketing' => esc_html__( 'Instagram Stories', 'instagram-feed' ),
80
- 'payments' => esc_html__( 'Feed Moderation', 'instagram-feed' ),
81
- 'surveys' => esc_html__( 'Header Display', 'instagram-feed' ),
82
- 'advanced' => esc_html__( 'Post Linking', 'instagram-feed' ),
83
- 'support' => esc_html__( 'Customer Support', 'instagram-feed' ),
84
- );
85
-
86
- // Maybe load tools page.
87
- add_action( 'admin_init', array( $this, 'init' ) );
88
- }
89
-
90
- /**
91
- * Determining if the user is viewing the our page, if so, party on.
92
- *
93
- * @since 2.4/5.5
94
- */
95
- public function init() {
96
-
97
- // Check what page we are on.
98
- $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
99
-
100
- // Only load if we are actually on the settings page.
101
- if ( self::SLUG !== $page ) {
102
- return;
103
- }
104
-
105
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueues' ) );
106
-
107
- /*
108
- * Define the core views for the our tab.
109
- */
110
- $this->views = apply_filters(
111
- 'sbi_admin_about_views',
112
- array(
113
- esc_html__( 'About Us', 'instagram-feed' ) => array( 'about' ),
114
- esc_html__( 'Getting Started', 'instagram-feed' ) => array( 'getting-started' ),
115
- )
116
- );
117
-
118
- $license = $this->get_license_type();
119
-
120
- if (
121
- (
122
- $license === 'pro' ||
123
- ! in_array( $license, self::$licenses_top, true )
124
- )
125
- //sbi_debug()
126
- ) {
127
- $vs_tab_name = sprintf( /* translators: %1$s - current license type, %2$s - suggested license type. */
128
- esc_html__( '%1$s vs %2$s', 'instagram-feed' ),
129
- ucfirst( $license ),
130
- $this->get_next_license( $license )
131
- );
132
-
133
- $this->views[ $vs_tab_name ] = array( 'versus' );
134
- }
135
-
136
- // Determine the current active settings tab.
137
- $this->view = ! empty( $_GET['view'] ) ? esc_html( $_GET['view'] ) : self::DEFAULT_TAB;
138
-
139
- // If the user tries to load an invalid view - fallback to About Us.
140
- if (
141
- ! in_array( $this->view, call_user_func_array( 'array_merge', $this->views ), true ) &&
142
- ! has_action( 'sbi_admin_about_display_tab_' . sanitize_key( $this->view ) )
143
- ) {
144
- $this->view = self::DEFAULT_TAB;
145
- }
146
-
147
- add_action( 'sbi_admin_page', array( $this, 'output' ) );
148
-
149
- // Hook for addons.
150
- do_action( 'sbi_admin_about_init' );
151
- }
152
-
153
- /**
154
- * Enqueue assets for the the page.
155
- *
156
- * @since 2.4/5.5
157
- */
158
- public function enqueues() {
159
-
160
- wp_enqueue_script(
161
- 'jquery-matchheight',
162
- SBI_PLUGIN_URL . 'js/jquery.matchHeight-min.js',
163
- array( 'jquery' ),
164
- '0.7.0',
165
- false
166
- );
167
- }
168
-
169
- /**
170
- * Output the basic page structure.
171
- *
172
- * @since 2.4/5.5
173
- */
174
- public function output() {
175
-
176
- $show_nav = false;
177
- foreach ( $this->views as $view ) {
178
- if ( in_array( $this->view, (array) $view, true ) ) {
179
- $show_nav = true;
180
- break;
181
- }
182
- }
183
- ?>
184
-
185
- <div id="sbi-admin-about" class="wrap sbi-admin-wrap">
186
-
187
- <?php
188
- if ( $show_nav ) {
189
- $license = $this->get_license_type();
190
- $next_license = $this->get_next_license( $license );
191
- echo '<ul class="sbi-admin-tabs">';
192
- foreach ( $this->views as $label => $view ) {
193
- $class = in_array( $this->view, $view, true ) ? 'active' : '';
194
- echo '<li>';
195
- printf(
196
- '<a href="%s" class="%s">%s</a>',
197
- esc_url( admin_url( 'admin.php?page=' . self::SLUG . '&view=' . sanitize_key( $view[0] ) ) ),
198
- esc_attr( $class ),
199
- esc_html( $label )
200
- );
201
- echo '</li>';
202
- }
203
- echo '</ul>';
204
- }
205
- ?>
206
-
207
- <h1 class="sbi-h1-placeholder"></h1>
208
-
209
- <?php
210
- switch ( $this->view ) {
211
- case 'about':
212
- $this->output_about();
213
- break;
214
- case 'getting-started':
215
- $this->output_getting_started();
216
- break;
217
- case 'versus':
218
- $this->output_versus();
219
- break;
220
- default:
221
- do_action( 'sbi_admin_about_display_tab_' . sanitize_key( $this->view ) );
222
- break;
223
- }
224
- ?>
225
-
226
- </div>
227
-
228
- <?php
229
- }
230
-
231
- /**
232
- * Display the About tab content.
233
- *
234
- * @since 2.4/5.5
235
- */
236
- protected function output_about() {
237
-
238
- $this->output_about_info();
239
- $this->output_about_addons();
240
- }
241
-
242
- /**
243
- * Display the General Info section of About tab.
244
- *
245
- * @since 1.5.8
246
- */
247
- protected function output_about_info() {
248
-
249
- ?>
250
-
251
- <div class="sbi-admin-about-section sbi-admin-columns">
252
-
253
- <div class="sbi-admin-about-text" style="min-height: 340px;">
254
- <h3>
255
- <?php esc_html_e( 'Hello and welcome to the Instagram Feed plugin, the most beautiful, clean, and reliable Instagram feed plugin in the world. At Smash Balloon, we build software that helps you create beautiful responsive social media feeds for your website in minutes.', 'instagram-feed' ); ?>
256
- </h3>
257
-
258
- <p>
259
- <?php esc_html_e( 'Smash Balloon is a fun-loving WordPress plugin development company birthed into existence in early 2013. We specialize in creating plugins that are not only intuitive and simple to use, but also designed to integrate seamlessly into your website and allow you to display your social media content in powerful and unique ways. Over 1 million awesome people have decided to actively use our plugins, which is an incredible honor that we don’t take lightly. This compels us to try to provide the quickest and most effective customer support that we can, blowing users away with the best customer service they’ve ever experienced.', 'instagram-feed' ); ?>
260
- </p>
261
- <p>
262
- <?php esc_html_e( 'We’re a small, but dedicated, team based in Minnesota in the USA.', 'instagram-feed' ); ?>
263
- </p>
264
- <!-- <p>
265
- <?php
266
- printf(
267
- wp_kses(
268
- /* translators: %1$s - WPBeginner URL, %2$s - OptinMonster URL, %3$s - MonsterInsights URL, %4$s - RafflePress URL. */
269
- __( 'Instagram Feed is brought to you by the same team that’s behind the largest WordPress resource site, <a href="%1$s" target="_blank" rel="noopener noreferrer">WPBeginner</a>, the most popular lead-generation software, <a href="%2$s" target="_blank" rel="noopener noreferrer">OptinMonster</a>, the best WordPress analytics plugin, <a href="%3$s" target="_blank" rel="noopener noreferrer">MonsterInsights</a>, and the most powerful WordPress contest plugin, <a href="%4$s" target="_blank" rel="noopener noreferrer">RafflePress</a>.', 'instagram-feed' ),
270
- array(
271
- 'a' => array(
272
- 'href' => array(),
273
- 'rel' => array(),
274
- 'target' => array(),
275
- ),
276
- )
277
- ),
278
- 'https://www.wpbeginner.com/?utm_source=sbiplugin&utm_medium=pluginaboutpage&utm_campaign=aboutsbi',
279
- 'https://optinmonster.com/?utm_source=sbiplugin&utm_medium=pluginaboutpage&utm_campaign=aboutsbi',
280
- 'https://www.monsterinsights.com/?utm_source=sbiplugin&utm_medium=pluginaboutpage&utm_campaign=aboutsbi',
281
- 'https://rafflepress.com/?utm_source=sbiplugin&utm_medium=pluginaboutpage&utm_campaign=aboutsbi'
282
- );
283
- ?>
284
- </p>
285
- <p>
286
- <?php esc_html_e( 'Yup, we know a thing or two about building awesome products that customers love.', 'instagram-feed' ); ?>
287
- </p> -->
288
- </div>
289
-
290
- <div class="sbi-admin-about-image sbi-admin-column-last">
291
- <figure>
292
- <img src="<?php echo SBI_PLUGIN_URL; ?>img/about/team.jpg" alt="<?php esc_attr_e( 'The Sbi Team photo', 'instagram-feed' ); ?>">
293
- <figcaption>
294
- <?php esc_html_e( 'The Smash Balloon Team', 'instagram-feed' ); ?><br>
295
- </figcaption>
296
- </figure>
297
- </div>
298
-
299
- </div>
300
- <?php
301
- }
302
-
303
- /**
304
- * Display the Addons section of About tab.
305
- *
306
- * @since 1.5.8
307
- */
308
- protected function output_about_addons() {
309
-
310
- if ( ! current_user_can( 'manage_instagram_feed_options' ) || version_compare( PHP_VERSION, '5.3.0' ) <= 0 ) {
311
- return;
312
- }
313
-
314
- $all_plugins = get_plugins();
315
- $am_plugins = $this->get_am_plugins();
316
-
317
- ?>
318
- <div id="sbi-admin-addons">
319
- <div class="addons-container">
320
- <h3><?php echo __( 'Our Other Plugins', 'instagram-feed' ); ?></h3>
321
- <?php
322
- foreach ( $am_plugins as $plugin => $details ) :
323
-
324
- $plugin_data = $this->get_plugin_data( $plugin, $details, $all_plugins );
325
-
326
- if ( $plugin === 'wpforms-lite/wpforms.php' ) {
327
- echo '<h3>' .__( 'Plugins We Recommend', 'instagram-feed' ). '</h3>';
328
- }
329
-
330
- ?>
331
- <div class="addon-container">
332
- <div class="addon-item">
333
- <div class="details sbi-clear">
334
- <img src="<?php echo esc_url( $plugin_data['details']['icon'] ); ?>">
335
- <h5 class="addon-name">
336
- <?php echo esc_html( $plugin_data['details']['name'] ); ?>
337
- </h5>
338
- <p class="addon-desc">
339
- <?php echo wp_kses_post( $plugin_data['details']['desc'] ); ?>
340
- </p>
341
- </div>
342
- <div class="actions sbi-clear">
343
- <div class="status">
344
- <strong>
345
- <?php
346
- printf(
347
- /* translators: %s - addon status label. */
348
- esc_html__( 'Status: %s', 'instagram-feed' ),
349
- '<span class="status-label ' . esc_attr( $plugin_data['status_class'] ) . '">' . wp_kses_post( $plugin_data['status_text'] ) . '</span>'
350
- );
351
- ?>
352
- </strong>
353
- </div>
354
- <div class="action-button">
355
- <button class="<?php echo esc_attr( $plugin_data['action_class'] ); ?>" data-plugin="<?php echo esc_attr( $plugin_data['plugin_src'] ); ?>" data-type="plugin">
356
- <?php echo wp_kses_post( $plugin_data['action_text'] ); ?>
357
- </button>
358
- </div>
359
- </div>
360
- </div>
361
- </div>
362
- <?php endforeach; ?>
363
- </div>
364
- </div>
365
- <?php
366
- }
367
-
368
- /**
369
- * Get AM plugin data to display in the Addons section of About tab.
370
- *
371
- * @since 1.5.8
372
- *
373
- * @param string $plugin Plugin slug.
374
- * @param array $details Plugin details.
375
- * @param array $all_plugins List of all plugins.
376
- *
377
- * @return array
378
- */
379
- protected function get_plugin_data( $plugin, $details, $all_plugins ) {
380
-
381
- $have_pro = ( ! empty( $details['pro'] ) && ! empty( $details['pro']['plug'] ) );
382
- $show_pro = false;
383
-
384
- $plugin_data = array();
385
-
386
- if ( $have_pro ) {
387
- if ( array_key_exists( $plugin, $all_plugins ) ) {
388
- if ( is_plugin_active( $plugin ) ) {
389
- $show_pro = true;
390
- }
391
- }
392
- if ( array_key_exists( $details['pro']['plug'], $all_plugins ) ) {
393
- $show_pro = true;
394
- }
395
- if ( $show_pro ) {
396
- $plugin = $details['pro']['plug'];
397
- $details = $details['pro'];
398
- }
399
- }
400
-
401
- if ( array_key_exists( $plugin, $all_plugins ) ) {
402
- if ( is_plugin_active( $plugin ) ) {
403
- // Status text/status.
404
- $plugin_data['status_class'] = 'status-active';
405
- $plugin_data['status_text'] = esc_html__( 'Active', 'instagram-feed' );
406
- // Button text/status.
407
- $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-secondary disabled';
408
- $plugin_data['action_text'] = esc_html__( 'Activated', 'instagram-feed' );
409
- $plugin_data['plugin_src'] = esc_attr( $plugin );
410
- } else {
411
- // Status text/status.
412
- $plugin_data['status_class'] = 'status-inactive';
413
- $plugin_data['status_text'] = esc_html__( 'Inactive', 'instagram-feed' );
414
- // Button text/status.
415
- $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-secondary';
416
- $plugin_data['action_text'] = esc_html__( 'Activate', 'instagram-feed' );
417
- $plugin_data['plugin_src'] = esc_attr( $plugin );
418
- }
419
- } else {
420
- // Doesn't exist, install.
421
- // Status text/status.
422
- $plugin_data['status_class'] = 'status-download';
423
- if ( isset( $details['act'] ) && 'go-to-url' === $details['act'] ) {
424
- $plugin_data['status_class'] = 'status-go-to-url';
425
- }
426
- $plugin_data['status_text'] = esc_html__( 'Not Installed', 'instagram-feed' );
427
- // Button text/status.
428
- $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-primary';
429
- $plugin_data['action_text'] = esc_html__( 'Install Plugin', 'instagram-feed' );
430
- $plugin_data['plugin_src'] = esc_url( $details['url'] );
431
- }
432
-
433
- $plugin_data['details'] = $details;
434
-
435
- return $plugin_data;
436
- }
437
-
438
- /**
439
- * Display the Getting Started tab content.
440
- *
441
- * @since 2.4/5.5
442
- */
443
- protected function output_getting_started() {
444
-
445
- $license = $this->get_license_type();
446
- ?>
447
-
448
- <div class="sbi-admin-about-section sbi-admin-about-section-first-form" style="display:flex;">
449
-
450
- <div class="sbi-admin-about-section-first-form-text">
451
-
452
- <h2>
453
- <?php esc_html_e( 'Creating Your First Feed', 'instagram-feed' ); ?>
454
- </h2>
455
-
456
- <p>
457
- <?php esc_html_e( 'Want to get started creating your first feed with Instagram Feed? By following the step by step instructions in this walkthrough, you can easily publish your first feed on your site.', 'instagram-feed' ); ?>
458
- </p>
459
-
460
- <p>
461
- <?php esc_html_e( 'Navigate to Instagram Feed in the admin sidebar to go the Configure page.', 'instagram-feed' ); ?>
462
- </p>
463
-
464
- <p>
465
- <?php esc_html_e( 'Click on the large blue button to connect your Instagram account. Select "Personal" if your Instagram account is a personal account, "Business" if it is a business or creator account.', 'instagram-feed' ); ?>
466
- </p>
467
-
468
- <p>
469
- <?php esc_html_e( 'Once you connect an Instagram account, you can display your feed on any post, page or widget using the shortcode [instagram-feed]. You can also use the Instagram Feed Gutenberg block if your site has the WordPress block editor enabled.', 'instagram-feed' ); ?>
470
- </p>
471
-
472
- <ul class="list-plain">
473
- <li>
474
- <a href="https://smashballoon.com/display-multiple-instagram-feeds/?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=multiplefeeds" target="_blank" rel="noopener noreferrer">
475
- <?php esc_html_e( 'How to Display Multiple Feeds', 'instagram-feed' ); ?>
476
- </a>
477
- </li>
478
- <li>
479
- <a href="https://smashballoon.com/get-access-token-from-another-account/?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=differentaccounts" target="_blank" rel="noopener noreferrer">
480
- <?php esc_html_e( 'Connect a Different Account', 'instagram-feed' ); ?>
481
- </a>
482
- </li>
483
- <li>
484
- <a href="https://smashballoon.com/differences-between-an-instagram-personal-and-business-account/?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=personalvbusiness" target="_blank" rel="noopener noreferrer">
485
- <?php esc_html_e( 'Personal Vs Business Accounts', 'instagram-feed' ); ?>
486
- </a>
487
- </li>
488
- </ul>
489
-
490
- </div>
491
-
492
- <div class="sbi-admin-about-section-first-form-video">
493
- <iframe src="https://www.youtube-nocookie.com/embed/q6ZXVU4g970?rel=0" width="540" height="304" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
494
- </div>
495
-
496
- </div>
497
-
498
- <?php if ( ! in_array( $license, self::$licenses_top, true ) ) { ?>
499
- <div class="sbi-admin-about-section sbi-admin-about-section-hero">
500
-
501
- <div class="sbi-admin-about-section-hero-main">
502
- <h2>
503
- <?php esc_html_e( 'Get Instagram Feed Pro and Unlock all the Powerful Features', 'instagram-feed' ); ?>
504
- </h2>
505
-
506
- <p class="bigger">
507
- <?php
508
- echo wp_kses(
509
- __( 'Thanks for being a loyal Instagram Feed Lite user. <strong>Upgrade to Instagram Feed Pro</strong> to unlock all the awesome features and experience<br>why Instagram Feed is the most popular Instagram plugin.', 'instagram-feed' ),
510
- array(
511
- 'br' => array(),
512
- 'strong' => array(),
513
- )
514
- );
515
- ?>
516
- </p>
517
-
518
- <p>
519
- <?php
520
- printf(
521
- wp_kses(
522
- /* translators: %s - stars. */
523
- __( 'We know that you will truly love Instagram Feed. It has over <strong>2500+ five star ratings</strong> (%s) and is active on over 1 million websites.', 'instagram-feed' ),
524
- array(
525
- 'strong' => array(),
526
- )
527
- ),
528
- '<i class="fa fa-star" aria-hidden="true"></i>' .
529
- '<i class="fa fa-star" aria-hidden="true"></i>' .
530
- '<i class="fa fa-star" aria-hidden="true"></i>' .
531
- '<i class="fa fa-star" aria-hidden="true"></i>' .
532
- '<i class="fa fa-star" aria-hidden="true"></i>'
533
- );
534
- ?>
535
- </p>
536
- </div>
537
-
538
- <div class="sbi-admin-about-section-hero-extra">
539
- <div class="sbi-admin-columns">
540
- <div class="sbi-admin-column-50">
541
- <ul class="list-features list-plain">
542
- <li>
543
- <i class="fa fa-check" aria-hidden="true"></i>
544
- <?php esc_html_e( 'Recent hashtag, top Hashtag, and tagged feeds.', 'instagram-feed' ); ?>
545
- </li>
546
- <li>
547
- <i class="fa fa-check" aria-hidden="true"></i>
548
- <?php esc_html_e( 'More layouts - masonry, highlight, and carousel.', 'instagram-feed' ); ?>
549
- </li>
550
- <li>
551
- <i class="fa fa-check" aria-hidden="true"></i>
552
- <?php esc_html_e( 'Captions, comments, dates, likes, and comment counts.', 'instagram-feed' ); ?>
553
- </li>
554
- <li>
555
- <i class="fa fa-check" aria-hidden="true"></i>
556
- <?php esc_html_e( 'Pop-up lightbox to view images and watch videos.', 'instagram-feed' ); ?>
557
- </li>
558
- <li>
559
- <i class="fa fa-check" aria-hidden="true"></i>
560
- <?php esc_html_e( 'Filter feeds by word or hashtag.', 'instagram-feed' ); ?>
561
- </li>
562
- </ul>
563
- </div>
564
- <div class="sbi-admin-column-50 sbi-admin-column-last">
565
- <ul class="list-features list-plain">
566
- <li>
567
- <i class="fa fa-check" aria-hidden="true"></i>
568
- <?php esc_html_e( 'Display Instagram stories.', 'instagram-feed' ); ?>
569
- </li>
570
- <li>
571
- <i class="fa fa-check" aria-hidden="true"></i>
572
- <?php esc_html_e( 'Powerful visual moderation system.', 'instagram-feed' ); ?>
573
- </li>
574
- <li>
575
- <i class="fa fa-check" aria-hidden="true"></i>
576
- <?php esc_html_e( 'More customization for feed headers.', 'instagram-feed' ); ?>
577
- </li>
578
- <li>
579
- <i class="fa fa-check" aria-hidden="true"></i>
580
- <?php esc_html_e( 'Even more customization options for your feed.', 'instagram-feed' ); ?>
581
- </li>
582
- <li>
583
- <i class="fa fa-check" aria-hidden="true"></i>
584
- <?php esc_html_e( '"Shoppable" feeds.', 'instagram-feed' ); ?>
585
- </li>
586
- </ul>
587
- </div>
588
- </div>
589
-
590
- <hr />
591
-
592
- <h3 class="call-to-action">
593
- <?php
594
- if ( 'lite' === $license ) {
595
- echo '<a href="https://smashballoon.com/instagram-feed/pricing?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=profeaturescompare" target="_blank" rel="noopener noreferrer">';
596
- } else {
597
- echo '<a href="https://smashballoon.com/instagram-feed/pricing?utm_campaign=instagram-pro&utm_source=gettingstarted&utm_medium=profeaturescompare" target="_blank" rel="noopener noreferrer">';
598
- }
599
- esc_html_e( 'Get Instagram Feed Pro Today and Unlock all the Powerful Features', 'instagram-feed' );
600
- ?>
601
- </a>
602
- </h3>
603
-
604
- <?php if ( 'lite' === $license ) { ?>
605
- <p>
606
- <?php
607
- echo wp_kses(
608
- __( 'Bonus: Instagram Feed Lite users get <span class="price-20-off">50% off regular price</span>, automatically applied at checkout.', 'instagram-feed' ),
609
- array(
610
- 'span' => array(
611
- 'class' => array(),
612
- ),
613
- )
614
- );
615
- ?>
616
- </p>
617
- <?php } ?>
618
- </div>
619
-
620
- </div>
621
- <?php } ?>
622
-
623
-
624
- <div class="sbi-admin-about-section sbi-admin-about-section-squashed sbi-admin-about-section-post sbi-admin-columns">
625
- <div class="sbi-admin-column-20">
626
- <img src="<?php echo SBI_PLUGIN_URL; ?>img/about/steps.png" alt="">
627
- </div>
628
- <div class="sbi-admin-column-80">
629
- <h2>
630
- <?php esc_html_e( 'Detailed Step-By-Step Guide', 'instagram-feed' ); ?>
631
- </h2>
632
-
633
- <p>
634
- <?php esc_html_e( 'View detailed steps with related images on our website. We have a comprehensive guide to getting up and running with Instagram Feed.', 'instagram-feed' ); ?>
635
- </p>
636
-
637
- <a href="https://smashballoon.com/instagram-feed/free/?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=readsetup" target="_blank" rel="noopener noreferrer" class="sbi-admin-about-section-post-link">
638
- <?php esc_html_e( 'Read Documentation', 'instagram-feed' ); ?><i class="fa fa-external-link" aria-hidden="true"></i>
639
- </a>
640
- </div>
641
- </div>
642
-
643
- <div class="sbi-admin-about-section sbi-admin-about-section-squashed sbi-admin-about-section-post sbi-admin-columns">
644
- <div class="sbi-admin-column-20">
645
- <img src="<?php echo SBI_PLUGIN_URL; ?>img/about/api-error.png" alt="">
646
- </div>
647
- <div class="sbi-admin-column-80">
648
- <h2>
649
- <?php esc_html_e( 'Troubleshoot Connection and API Errors', 'instagram-feed' ); ?>
650
- </h2>
651
-
652
- <p>
653
- <?php esc_html_e( 'Are you having trouble displaying your feed due to an error connecting an account or an Instagram API error? We have several articles to help you troubleshoot issues and help you solve them.', 'instagram-feed' ); ?>
654
- </p>
655
-
656
- <a href="https://smashballoon.com/instagram-feed/docs/errors/?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=readerrordoc" target="_blank" rel="noopener noreferrer" class="sbi-admin-about-section-post-link">
657
- <?php esc_html_e( 'Read Documentation', 'instagram-feed' ); ?><i class="fa fa-external-link" aria-hidden="true"></i>
658
- </a>
659
- </div>
660
- </div>
661
-
662
- <?php
663
- }
664
-
665
- /**
666
- * Get the next license type. Helper for Versus tab content.
667
- *
668
- * @since 1.5.5
669
- *
670
- * @param string $current Current license type slug.
671
- *
672
- * @return string Next license type slug.
673
- */
674
- protected function get_next_license( $current ) {
675
-
676
- $current = ucfirst( $current );
677
- $license_pairs = array(
678
- 'Lite' => 'Pro',
679
- 'Basic' => 'Pro',
680
- 'Plus' => 'Pro',
681
- 'Pro' => 'Elite',
682
- );
683
-
684
- return ! empty( $license_pairs[ $current ] ) ? $license_pairs[ $current ] : 'Elite';
685
- }
686
-
687
- /**
688
- * Display the Versus tab content.
689
- *
690
- * @since 2.4/5.5
691
- */
692
- protected function output_versus() {
693
-
694
- //$license = $this->get_license_type();
695
- //$next_license = $this->get_next_license( $license );
696
- $license = 'lite';
697
- $next_license = 'pro';
698
- ?>
699
-
700
- <div class="sbi-admin-about-section sbi-admin-about-section-squashed">
701
- <h1 class="centered">
702
- <strong><?php echo esc_html( ucfirst( $license ) ); ?></strong> vs <strong><?php echo esc_html( ucfirst( $next_license ) ); ?></strong>
703
- </h1>
704
-
705
- <p class="centered">
706
- <?php esc_html_e( 'Get the most out of your Instagram Feeds by upgrading to Pro and unlocking all of the powerful features.', 'instagram-feed' ); ?>
707
- </p>
708
- </div>
709
-
710
- <div class="sbi-admin-about-section sbi-admin-about-section-squashed sbi-admin-about-section-hero sbi-admin-about-section-table">
711
-
712
- <div class="sbi-admin-about-section-hero-main sbi-admin-columns">
713
- <div class="sbi-admin-column-33">
714
- <h3 class="no-margin">
715
- <?php esc_html_e( 'Feature', 'instagram-feed' ); ?>
716
- </h3>
717
- </div>
718
- <div class="sbi-admin-column-33">
719
- <h3 class="no-margin">
720
- <?php echo esc_html( ucfirst( $license ) ); ?>
721
- </h3>
722
- </div>
723
- <div class="sbi-admin-column-33">
724
- <h3 class="no-margin">
725
- <?php echo esc_html( ucfirst( $next_license ) ); ?>
726
- </h3>
727
- </div>
728
- </div>
729
- <div class="sbi-admin-about-section-hero-extra no-padding sbi-admin-columns">
730
-
731
- <table>
732
- <?php
733
- foreach ( self::$licenses_features as $slug => $name ) {
734
- $current = $this->get_license_data( $slug, $license );
735
- $next = $this->get_license_data( $slug, strtolower( $next_license ) );
736
-
737
- if ( empty( $current ) || empty( $next ) ) {
738
- continue;
739
- }
740
- ?>
741
- <tr class="sbi-admin-columns">
742
- <td class="sbi-admin-column-33">
743
- <p><?php echo esc_html( $name ); ?></p>
744
- </td>
745
- <td class="sbi-admin-column-33">
746
- <?php if ( is_array( $current ) ) : ?>
747
- <p class="features-<?php echo esc_attr( $current['status'] ); ?>">
748
- <?php echo wp_kses_post( implode( '<br>', $current['text'] ) ); ?>
749
- </p>
750
- <?php endif; ?>
751
- </td>
752
- <td class="sbi-admin-column-33">
753
- <?php if ( is_array( $current ) ) : ?>
754
- <p class="features-full">
755
- <?php echo wp_kses_post( implode( '<br>', $next['text'] ) ); ?>
756
- </p>
757
- <?php endif; ?>
758
- </td>
759
- </tr>
760
- <?php
761
- }
762
- ?>
763
- </table>
764
-
765
- </div>
766
-
767
- </div>
768
-
769
- <div class="sbi-admin-about-section sbi-admin-about-section-hero">
770
- <div class="sbi-admin-about-section-hero-main no-border">
771
- <h3 class="call-to-action centered">
772
- <?php
773
- if ( 'lite' === $license ) {
774
- echo '<a href="https://smashballoon.com/instagram-feed/pricing?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=profeaturescompare" target="_blank" rel="noopener noreferrer">';
775
- } else {
776
- echo '<a href="https://smashballoon.com/instagram-feed/pricing?utm_campaign=instagram-pro&utm_source=gettingstarted&utm_medium=profeaturescompare" target="_blank" rel="noopener noreferrer">';
777
- }
778
- printf( /* translators: %s - next license level. */
779
- esc_html__( 'Get Instagram Feed Pro Today and Unlock all the Powerful Features', 'instagram-feed' ),
780
- esc_html( $next_license )
781
- );
782
- ?>
783
- </a>
784
- </h3>
785
-
786
- <?php if ( 'lite' === $license ) { ?>
787
- <p class="centered">
788
- <?php
789
- echo wp_kses(
790
- __( 'Bonus: Instagram Feed Lite users get <span class="price-20-off">50% off regular price</span>, automatically applied at checkout.', 'instagram-feed' ),
791
- array(
792
- 'span' => array(
793
- 'class' => array(),
794
- ),
795
- )
796
- );
797
- ?>
798
- </p>
799
- <?php } ?>
800
- </div>
801
- </div>
802
-
803
- <?php
804
- }
805
-
806
- /**
807
- * List of AM plugins that we propose to install.
808
- *
809
- * @since 2.4/5.5
810
- *
811
- * @return array
812
- */
813
- protected function get_am_plugins() {
814
-
815
- $images_url = SBI_PLUGIN_URL . 'img/about/';
816
-
817
- return array(
818
- 'custom-facebook-feed/custom-facebook-feed.php' => array(
819
- 'icon' => $images_url . 'plugin-fb.png',
820
- 'name' => esc_html__( 'Custom Facebook Feed', 'instagram-feed' ),
821
- 'desc' => esc_html__( 'Custom Facebook Feed makes displaying your Facebook posts easy. Keep your site visitors informed and increase engagement with your Facebook page by displaying a feed on your website.', 'instagram-feed' ),
822
- 'url' => 'https://downloads.wordpress.org/plugin/custom-facebook-feed.zip',
823
- 'pro' => array(
824
- 'plug' => 'custom-facebook-feed-pro/custom-facebook-feed.php',
825
- 'icon' => $images_url . 'plugin-fb.png',
826
- 'name' => esc_html__( 'Custom Facebook Feed Pro', 'instagram-feed' ),
827
- 'desc' => esc_html__( 'Custom Facebook Feed makes displaying your Facebook posts easy. Keep your site visitors informed and increase engagement with your Facebook page by displaying a feed on your website.', 'instagram-feed' ),
828
- 'url' => 'https://smashballoon.com/custom-facebook-feed/?utm_campaign=instagram-free&utm_source=cross&utm_medium=cffinstaller',
829
- 'act' => 'go-to-url',
830
- ),
831
- ),
832
-
833
- 'custom-twitter-feeds/custom-twitter-feed.php' => array(
834
- 'icon' => $images_url . 'plugin-tw.jpg',
835
- 'name' => esc_html__( 'Custom Twitter Feeds', 'instagram-feed' ),
836
- 'desc' => esc_html__( 'Custom Twitter Feeds is a highly customizable way to display tweets from your Twitter account. Promote your latest content and update your site content automatically.', 'instagram-feed' ),
837
- 'url' => 'https://downloads.wordpress.org/plugin/custom-twitter-feeds.zip',
838
- 'pro' => array(
839
- 'plug' => 'custom-twitter-feeds-pro/custom-twitter-feed.php',
840
- 'icon' => $images_url . 'plugin-tw.jpg',
841
- 'name' => esc_html__( 'Custom Twitter Feeds Pro', 'instagram-feed' ),
842
- 'desc' => esc_html__( 'Custom Twitter Feeds is a highly customizable way to display tweets from your Twitter account. Promote your latest content and update your site content automatically.', 'instagram-feed' ),
843
- 'url' => 'https://smashballoon.com/custom-twitter-feeds/?utm_campaign=instagram-free&utm_source=cross&utm_medium=ctfinstaller',
844
- 'act' => 'go-to-url',
845
- ),
846
- ),
847
-
848
- 'feeds-for-youtube/youtube-feed.php' => array(
849
- 'icon' => $images_url . 'plugin-yt.png',
850
- 'name' => esc_html__( 'Feeds for YouTube', 'instagram-feed' ),
851
- 'desc' => esc_html__( 'Feeds for YouTube is a simple yet powerful way to display videos from YouTube on your website. Increase engagement with your channel while keeping visitors on your website.', 'instagram-feed' ),
852
- 'url' => 'https://downloads.wordpress.org/plugin/feeds-for-youtube.zip',
853
- 'pro' => array(
854
- 'plug' => 'youtube-feed-pro/youtube-feed.php',
855
- 'icon' => $images_url . 'plugin-yt.png',
856
- 'name' => esc_html__( 'Feeds for YouTube Pro', 'instagram-feed' ),
857
- 'desc' => esc_html__( 'Feeds for YouTube is a simple yet powerful way to display videos from YouTube on your website. Increase engagement with your channel while keeping visitors on your website.', 'instagram-feed' ),
858
- 'url' => 'https://smashballoon.com/youtube-feed/?utm_campaign=instagram-free&utm_source=cross&utm_medium=sbyinstaller',
859
- 'act' => 'go-to-url',
860
- ),
861
- ),
862
-
863
- 'wpforms-lite/wpforms.php' => array(
864
- 'icon' => $images_url . 'plugin-wpforms.png',
865
- 'name' => esc_html__( 'WPForms', 'instagram-feed' ),
866
- 'desc' => esc_html__( 'The most beginner friendly drag & drop WordPress forms plugin allowing you to create beautiful contact forms, subscription forms, payment forms, and more in minutes, not hours!', 'instagram-feed' ),
867
- 'url' => 'https://downloads.wordpress.org/plugin/wpforms-lite.zip',
868
- 'pro' => array(
869
- 'plug' => 'wpforms/wpforms.php',
870
- 'icon' => $images_url . 'plugin-wpforms.png',
871
- 'name' => esc_html__( 'WPForms', 'instagram-feed' ),
872
- 'desc' => esc_html__( 'The most beginner friendly drag & drop WordPress forms plugin allowing you to create beautiful contact forms, subscription forms, payment forms, and more in minutes, not hours!', 'instagram-feed' ),
873
- 'url' => 'https://wpforms.com/lite-upgrade/?utm_source=WordPress&utm_campaign=liteplugin&utm_medium=about-page',
874
- 'act' => 'go-to-url',
875
- ),
876
- ),
877
-
878
- 'google-analytics-for-wordpress/googleanalytics.php' => array(
879
- 'icon' => $images_url . 'plugin-mi.png',
880
- 'name' => esc_html__( 'MonsterInsights', 'instagram-feed' ),
881
- 'desc' => esc_html__( 'MonsterInsights makes it “effortless” to properly connect your WordPress site with Google Analytics, so you can start making data-driven decisions to grow your business.', 'instagram-feed' ),
882
- 'url' => 'https://downloads.wordpress.org/plugin/google-analytics-for-wordpress.zip',
883
- 'pro' => array(
884
- 'plug' => 'google-analytics-premium/googleanalytics-premium.php',
885
- 'icon' => $images_url . 'plugin-mi.png',
886
- 'name' => esc_html__( 'MonsterInsights Pro', 'instagram-feed' ),
887
- 'desc' => esc_html__( 'MonsterInsights makes it “effortless” to properly connect your WordPress site with Google Analytics, so you can start making data-driven decisions to grow your business.', 'instagram-feed' ),
888
- 'url' => 'https://www.monsterinsights.com/?utm_source=proplugin&utm_medium=about-page&utm_campaign=pluginurl&utm_content=7%2E0%2E0',
889
- 'act' => 'go-to-url',
890
- ),
891
- ),
892
-
893
- 'optinmonster/optin-monster-wp-api.php' => array(
894
- 'icon' => $images_url . 'plugin-om.png',
895
- 'name' => esc_html__( 'OptinMonster', 'instagram-feed' ),
896
- 'desc' => esc_html__( 'Our high-converting optin forms like Exit-Intent® popups, Fullscreen Welcome Mats, and Scroll boxes help you dramatically boost conversions and get more email subscribers.', 'instagram-feed' ),
897
- 'url' => 'https://downloads.wordpress.org/plugin/optinmonster.zip',
898
- ),
899
-
900
- 'wp-mail-smtp/wp_mail_smtp.php' => array(
901
- 'icon' => $images_url . 'plugin-smtp.png',
902
- 'name' => esc_html__( 'WP Mail SMTP', 'instagram-feed' ),
903
- 'desc' => esc_html__( 'Make sure your website\'s emails reach the inbox. Our goal is to make email deliverability easy and reliable. Trusted by over 1 million websites.', 'instagram-feed' ),
904
- 'url' => 'https://downloads.wordpress.org/plugin/wp-mail-smtp.zip',
905
- 'pro' => array(
906
- 'plug' => 'wp-mail-smtp-pro/wp_mail_smtp.php',
907
- 'icon' => $images_url . 'plugin-smtp.png',
908
- 'name' => esc_html__( 'WP Mail SMTP Pro', 'instagram-feed' ),
909
- 'desc' => esc_html__( 'Make sure your website\'s emails reach the inbox. Our goal is to make email deliverability easy and reliable. Trusted by over 1 million websites.', 'instagram-feed' ),
910
- 'url' => 'https://wpmailsmtp.com/pricing/',
911
- 'act' => 'go-to-url',
912
- ),
913
- ),
914
-
915
- 'rafflepress/rafflepress.php' => array(
916
- 'icon' => $images_url . 'plugin-rp.png',
917
- 'name' => esc_html__( 'RafflePress', 'instagram-feed' ),
918
- 'desc' => esc_html__( 'Turn your visitors into brand ambassadors! Easily grow your email list, website traffic, and social media followers with powerful viral giveaways & contests.', 'instagram-feed' ),
919
- 'url' => 'https://downloads.wordpress.org/plugin/rafflepress.zip',
920
- 'pro' => array(
921
- 'plug' => 'rafflepress-pro/rafflepress-pro.php',
922
- 'icon' => $images_url . 'plugin-rp.png',
923
- 'name' => esc_html__( 'RafflePress Pro', 'instagram-feed' ),
924
- 'desc' => esc_html__( 'Turn your visitors into brand ambassadors! Easily grow your email list, website traffic, and social media followers with powerful viral giveaways & contests.', 'instagram-feed' ),
925
- 'url' => 'https://rafflepress.com/pricing/',
926
- 'act' => 'go-to-url',
927
- ),
928
- ),
929
-
930
- 'all-in-one-seo-pack/all_in_one_seo_pack.php' => array(
931
- 'icon' => $images_url . 'plugin-seo.png',
932
- 'name' => esc_html__( 'All In One SEO Pack', 'instagram-feed' ),
933
- 'desc' => esc_html__( 'Out-of-the-box SEO for WordPress. Features like XML Sitemaps, SEO for custom post types, SEO for blogs or business sites, SEO for ecommerce sites, and much more. More than 50 million downloads since 2007.', 'instagram-feed' ),
934
- 'url' => 'https://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip',
935
- ),
936
- );
937
- }
938
-
939
- /**
940
- * Get the array of data that compared the license data.
941
- *
942
- * @since 2.4/5.5
943
- *
944
- * @param string $feature Feature name.
945
- * @param string $license License type to get data for.
946
- *
947
- * @return array|false
948
- */
949
- protected function get_license_data( $feature, $license ) {
950
-
951
- $data = array(
952
- 'entries' => array(
953
- 'lite' => array(
954
- 'status' => 'partial',
955
- 'text' => array(
956
- '<strong>' . esc_html__( 'User feeds only', 'instagram-feed' ) . '</strong>',
957
- ),
958
- ),
959
- 'basic' => array(
960
- 'status' => 'full',
961
- 'text' => array(
962
- '<strong>' . esc_html__( 'User, Hashtag, and Tagged Feeds', 'instagram-feed' ) . '</strong>',
963
- ),
964
- ),
965
- 'plus' => array(
966
- 'status' => 'full',
967
- 'text' => array(
968
- '<strong>' . esc_html__( 'Complete Entry Management inside WordPress', 'instagram-feed' ) . '</strong>',
969
- ),
970
- ),
971
- 'pro' => array(
972
- 'status' => 'full',
973
- 'text' => array(
974
- '<strong>' . esc_html__( 'User, hashtag, and tagged feeds', 'instagram-feed' ) . '</strong>',
975
- ),
976
- ),
977
- ),
978
- 'fields' => array(
979
- 'lite' => array(
980
- 'status' => 'partial',
981
- 'text' => array(
982
- '<strong>' . esc_html__( 'Grid layout only', 'instagram-feed' ) . '</strong>',
983
- ),
984
- ),
985
- 'basic' => array(
986
- 'status' => 'full',
987
- 'text' => array(
988
- '<strong>' . esc_html__( 'Access to all Standard and Fancy Fields', 'instagram-feed' ) . '</strong>',
989
- esc_html__( 'Address, Phone, Website URL, Date/Time, Password, File Upload, HTML, Pagebreaks, Section Dividers, Ratings, and Hidden Field', 'instagram-feed' ),
990
- ),
991
- ),
992
- 'plus' => array(
993
- 'status' => 'full',
994
- 'text' => array(
995
- '<strong>' . esc_html__( 'Access to all Standard and Fancy Fields', 'instagram-feed' ) . '</strong>',
996
- esc_html__( 'Address, Phone, Website URL, Date/Time, Password, File Upload, HTML, Pagebreaks, Section Dividers, Ratings, and Hidden Field', 'instagram-feed' ),
997
- ),
998
- ),
999
- 'pro' => array(
1000
- 'status' => 'full',
1001
- 'text' => array(
1002
- '<strong>' . esc_html__( 'Grid, highlight, masonry, and carousel layouts', 'instagram-feed' ) . '</strong>',
1003
- ),
1004
- ),
1005
- ),
1006
- 'conditionals' => array(
1007
- 'lite' => array(
1008
- 'status' => 'partial',
1009
- 'text' => array(
1010
- '<strong>' . esc_html__( 'Image, carousel, and video thumbnails', 'instagram-feed' ) . '</strong>',
1011
- ),
1012
- ),
1013
- 'basic' => array(
1014
- 'status' => 'full',
1015
- 'text' => array(
1016
- '<strong>' . esc_html__( 'Powerful Form Logic for Building Smart Forms', 'instagram-feed' ) . '</strong>',
1017
- ),
1018
- ),
1019
- 'plus' => array(
1020
- 'status' => 'full',
1021
- 'text' => array(
1022
- '<strong>' . esc_html__( 'Powerful Form Logic for Building Smart Forms', 'instagram-feed' ) . '</strong>',
1023
- ),
1024
- ),
1025
- 'pro' => array(
1026
- 'status' => 'full',
1027
- 'text' => array(
1028
- '<strong>' . esc_html__( 'Display images, swipe through carousel posts, and play videos in a pop-up lightbox', 'instagram-feed' ) . '</strong>',
1029
- ),
1030
- ),
1031
- ),
1032
- 'templates' => array(
1033
- 'lite' => array(
1034
- 'status' => 'partial',
1035
- 'text' => array(
1036
- '<strong>' . esc_html__( 'Images and link only', 'instagram-feed' ) . '</strong>',
1037
- ),
1038
- ),
1039
- 'basic' => array(
1040
- 'status' => 'partial',
1041
- 'text' => array(
1042
- '<strong>' . esc_html__( 'Basic Form Templates', 'instagram-feed' ) . '</strong>',
1043
- ),
1044
- ),
1045
- 'plus' => array(
1046
- 'status' => 'partial',
1047
- 'text' => array(
1048
- '<strong>' . esc_html__( 'Basic Form Templates', 'instagram-feed' ) . '</strong>',
1049
- ),
1050
- ),
1051
- 'pro' => array(
1052
- 'status' => 'full',
1053
- 'text' => array(
1054
- '<strong>' . esc_html__( 'Thumbnails, dates, caption, comments, like counts, and comment counts.', 'instagram-feed' ) . '</strong>',
1055
- ),
1056
- ),
1057
- ),
1058
- 'marketing' => array(
1059
- 'lite' => array(
1060
- 'status' => 'none',
1061
- 'text' => array(
1062
- '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1063
- ),
1064
- ),
1065
- 'basic' => array(
1066
- 'status' => 'partial',
1067
- 'text' => array(
1068
- '<strong>' . esc_html__( 'Limited Marketing Integration', 'instagram-feed' ) . '</strong>',
1069
- esc_html__( 'Constant Contact only', 'instagram-feed' ),
1070
- ),
1071
- ),
1072
- 'plus' => array(
1073
- 'status' => 'partial',
1074
- 'text' => array(
1075
- '<strong>' . esc_html__( '6 Email Marketing Integrations', 'instagram-feed' ) . '</strong>',
1076
- esc_html__( 'Constant Contact, Mailchimp, AWeber, GetResponse, Campaign Monitor, and Drip', 'instagram-feed' ),
1077
- ),
1078
- ),
1079
- 'pro' => array(
1080
- 'status' => 'full',
1081
- 'text' => array(
1082
- '<strong>' . esc_html__( 'Display your latest Instagram story in a pop-up lightbox', 'instagram-feed' ) . '</strong>',
1083
- ),
1084
- ),
1085
- ),
1086
- 'payments' => array(
1087
- 'lite' => array(
1088
- 'status' => 'none',
1089
- 'text' => array(
1090
- '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1091
- ),
1092
- ),
1093
- 'basic' => array(
1094
- 'status' => 'none',
1095
- 'text' => array(
1096
- '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1097
- ),
1098
- ),
1099
- 'plus' => array(
1100
- 'status' => 'none',
1101
- 'text' => array(
1102
- '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1103
- ),
1104
- ),
1105
- 'pro' => array(
1106
- 'status' => 'full',
1107
- 'text' => array(
1108
- '<strong>' . esc_html__( 'Visual moderation system for removing posts or creating a "white list" of selected posts', 'instagram-feed' ) . '</strong>',
1109
- ),
1110
- ),
1111
- ),
1112
- 'surveys' => array(
1113
- 'lite' => array(
1114
- 'status' => 'partial',
1115
- 'text' => array(
1116
- '<strong>' . esc_html__( 'Standard or centered header', 'instagram-feed' ) . '</strong>',
1117
- ),
1118
- ),
1119
- 'basic' => array(
1120
- 'status' => 'none',
1121
- 'text' => array(
1122
- '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1123
- ),
1124
- ),
1125
- 'plus' => array(
1126
- 'status' => 'none',
1127
- 'text' => array(
1128
- '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1129
- ),
1130
- ),
1131
- 'pro' => array(
1132
- 'status' => 'full',
1133
- 'text' => array(
1134
- '<strong>' . esc_html__( 'Standard, centered, or boxed header that includes follower and post counts', 'instagram-feed' ) . '</strong>',
1135
- ),
1136
- ),
1137
- ),
1138
- 'advanced' => array(
1139
- 'lite' => array(
1140
- 'status' => 'partial',
1141
- 'text' => array(
1142
- '<strong>' . esc_html__( 'Posts link to the same post on Instagram', 'instagram-feed' ) . '</strong>',
1143
- ),
1144
- ),
1145
- 'basic' => array(
1146
- 'status' => 'partial',
1147
- 'text' => array(
1148
- '<strong>' . esc_html__( 'Limited Advanced Features', 'instagram-feed' ) . '</strong>',
1149
- esc_html__( 'Multi-page Forms, File Upload Forms, Multiple Form Notifications, Conditional Form Confirmation', 'instagram-feed' ),
1150
- ),
1151
- ),
1152
- 'plus' => array(
1153
- 'status' => 'partial',
1154
- 'text' => array(
1155
- '<strong>' . esc_html__( 'Limited Advanced Features', 'instagram-feed' ) . '</strong>',
1156
- esc_html__( 'Multi-page Forms, File Upload Forms, Multiple Form Notifications, Conditional Form Confirmation', 'instagram-feed' ),
1157
- ),
1158
- ),
1159
- 'pro' => array(
1160
- 'status' => 'full',
1161
- 'text' => array(
1162
- '<strong>' . esc_html__( 'Allow your posts to link to a URL in the caption or view in a lightbox', 'instagram-feed' ) . '</strong>',
1163
- ),
1164
- ),
1165
- ),
1166
- 'addons' => array(
1167
- 'lite' => array(
1168
- 'status' => 'none',
1169
- 'text' => array(
1170
- '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1171
- ),
1172
- ),
1173
- 'basic' => array(
1174
- 'status' => 'partial',
1175
- 'text' => array(
1176
- '<strong>' . esc_html__( 'Custom Captcha Addon included', 'instagram-feed' ) . '</strong>',
1177
- ),
1178
- ),
1179
- 'plus' => array(
1180
- 'status' => 'partial',
1181
- 'text' => array(
1182
- '<strong>' . esc_html__( 'Email Marketing Addons included', 'instagram-feed' ) . '</strong>',
1183
- ),
1184
- ),
1185
- 'pro' => array(
1186
- 'status' => 'full',
1187
- 'text' => array(
1188
- '<strong>' . esc_html__( 'Filter by word or hashtag', 'instagram-feed' ) . '</strong>',
1189
- ),
1190
- ),
1191
- ),
1192
- 'support' => array(
1193
- 'lite' => array(
1194
- 'status' => 'partial',
1195
- 'text' => array(
1196
- '<strong>' . esc_html__( 'Limited support', 'instagram-feed' ) . '</strong>',
1197
- ),
1198
- ),
1199
- 'basic' => array(
1200
- 'status' => 'partial',
1201
- 'text' => array(
1202
- '<strong>' . esc_html__( 'Standard Support', 'instagram-feed' ) . '</strong>',
1203
- ),
1204
- ),
1205
- 'plus' => array(
1206
- 'status' => 'partial',
1207
- 'text' => array(
1208
- '<strong>' . esc_html__( 'Standard Support', 'instagram-feed' ) . '</strong>',
1209
- ),
1210
- ),
1211
- 'pro' => array(
1212
- 'status' => 'full',
1213
- 'text' => array(
1214
- '<strong>' . esc_html__( 'Priority support', 'instagram-feed' ) . '</strong>',
1215
- ),
1216
- ),
1217
- 'elite' => array(
1218
- 'status' => 'full',
1219
- 'text' => array(
1220
- '<strong>' . esc_html__( 'Premium Support', 'instagram-feed' ) . '</strong>',
1221
- ),
1222
- ),
1223
- 'ultimate' => array(
1224
- 'status' => 'full',
1225
- 'text' => array(
1226
- '<strong>' . esc_html__( 'Premium Support', 'instagram-feed' ) . '</strong>',
1227
- ),
1228
- ),
1229
- 'agency' => array(
1230
- 'status' => 'full',
1231
- 'text' => array(
1232
- '<strong>' . esc_html__( 'Premium Support', 'instagram-feed' ) . '</strong>',
1233
- ),
1234
- ),
1235
- ),
1236
- 'sites' => array(
1237
- 'basic' => array(
1238
- 'status' => 'partial',
1239
- 'text' => array(
1240
- '<strong>' . esc_html__( '1 Site', 'instagram-feed' ) . '</strong>',
1241
- ),
1242
- ),
1243
- 'plus' => array(
1244
- 'status' => 'partial',
1245
- 'text' => array(
1246
- '<strong>' . esc_html__( '3 Sites', 'instagram-feed' ) . '</strong>',
1247
- ),
1248
- ),
1249
- 'pro' => array(
1250
- 'status' => 'full',
1251
- 'text' => array(
1252
- '<strong>' . esc_html__( '5 Sites', 'instagram-feed' ) . '</strong>',
1253
- ),
1254
- ),
1255
- 'elite' => array(
1256
- 'status' => 'full',
1257
- 'text' => array(
1258
- '<strong>' . esc_html__( 'Unlimited Sites', 'instagram-feed' ) . '</strong>',
1259
- ),
1260
- ),
1261
- 'ultimate' => array(
1262
- 'status' => 'full',
1263
- 'text' => array(
1264
- '<strong>' . esc_html__( 'Unlimited Sites', 'instagram-feed' ) . '</strong>',
1265
- ),
1266
- ),
1267
- 'agency' => array(
1268
- 'status' => 'full',
1269
- 'text' => array(
1270
- '<strong>' . esc_html__( 'Unlimited Sites', 'instagram-feed' ) . '</strong>',
1271
- ),
1272
- ),
1273
- ),
1274
- );
1275
-
1276
- // Wrong feature?
1277
- if ( ! isset( $data[ $feature ] ) ) {
1278
- return false;
1279
- }
1280
-
1281
- // Is a top level license?
1282
- $is_licenses_top = in_array( $license, self::$licenses_top, true );
1283
-
1284
- // Wrong license type?
1285
- if ( ! isset( $data[ $feature ][ $license ] ) && ! $is_licenses_top ) {
1286
- return false;
1287
- }
1288
-
1289
- // Some licenses have partial data.
1290
- if ( isset( $data[ $feature ][ $license ] ) ) {
1291
- return $data[ $feature ][ $license ];
1292
- }
1293
-
1294
- // Top level plans has no feature difference with `pro` plan in most cases.
1295
- return $is_licenses_top ? $data[ $feature ]['pro'] : $data[ $feature ][ $license ];
1296
- }
1297
-
1298
- /**
1299
- * Get the current installation license type (always lowercase).
1300
- *
1301
- * @since 2.4/5.5
1302
- *
1303
- * @return string
1304
- */
1305
- protected function get_license_type() {
1306
-
1307
- //$type = sbi_setting( 'type', '', 'sbi_license' );
1308
-
1309
- //if ( empty( $type ) || ! sbi()->pro ) {
1310
- $type = 'lite';
1311
- //}
1312
-
1313
- return strtolower( $type );
1314
- }
1315
- }
1316
-
1317
- new SB_Instagram_About();
1
+ <?php
2
+
3
+ /**
4
+ * About Sbi admin page class.
5
+ *
6
+ * @since 2.4/5.5
7
+ */
8
+ class SB_Instagram_About {
9
+
10
+ /**
11
+ * Admin menu page slug.
12
+ *
13
+ * @since 2.4/5.5
14
+ *
15
+ * @var string
16
+ */
17
+ const SLUG = 'sb-instagram-feed-about';
18
+
19
+ /**
20
+ * Default view for a page.
21
+ *
22
+ * @since 2.4/5.5
23
+ *
24
+ * @var string
25
+ */
26
+ const DEFAULT_TAB = 'about';
27
+
28
+ /**
29
+ * Array of license types, that are considered being top level and has no features difference.
30
+ *
31
+ * @since 2.4/5.5
32
+ *
33
+ * @var array
34
+ */
35
+ public static $licenses_top = array( 'pro', 'agency', 'ultimate', 'elite' );
36
+
37
+ /**
38
+ * List of features that licenses are different with.
39
+ *
40
+ * @since 2.4/5.5
41
+ *
42
+ * @var array
43
+ */
44
+ public static $licenses_features = array();
45
+
46
+ /**
47
+ * The current active tab.
48
+ *
49
+ * @since 2.4/5.5
50
+ *
51
+ * @var string
52
+ */
53
+ public $view;
54
+
55
+ /**
56
+ * The core views.
57
+ *
58
+ * @since 2.4/5.5
59
+ *
60
+ * @var array
61
+ */
62
+ public $views = array();
63
+
64
+ /**
65
+ * Primary class constructor.
66
+ *
67
+ * @since 2.4/5.5
68
+ */
69
+ public function __construct() {
70
+
71
+ // In old PHP we can't define this elsewhere.
72
+ self::$licenses_features = array(
73
+ 'entries' => esc_html__( 'Feed Types', 'instagram-feed' ),
74
+ 'fields' => esc_html__( 'Layouts', 'instagram-feed' ),
75
+ 'templates' => esc_html__( 'Post Information', 'instagram-feed' ),
76
+ 'conditionals' => esc_html__( 'Image and Video Display', 'instagram-feed' ),
77
+ 'addons' => esc_html__( 'Filtering', 'instagram-feed' ),
78
+ //'marketing' => esc_html__( 'Filtering', 'instagram-feed' ),
79
+ 'marketing' => esc_html__( 'Instagram Stories', 'instagram-feed' ),
80
+ 'payments' => esc_html__( 'Feed Moderation', 'instagram-feed' ),
81
+ 'surveys' => esc_html__( 'Header Display', 'instagram-feed' ),
82
+ 'advanced' => esc_html__( 'Post Linking', 'instagram-feed' ),
83
+ 'support' => esc_html__( 'Customer Support', 'instagram-feed' ),
84
+ );
85
+
86
+ // Maybe load tools page.
87
+ add_action( 'admin_init', array( $this, 'init' ) );
88
+ }
89
+
90
+ /**
91
+ * Determining if the user is viewing the our page, if so, party on.
92
+ *
93
+ * @since 2.4/5.5
94
+ */
95
+ public function init() {
96
+
97
+ // Check what page we are on.
98
+ $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
99
+
100
+ // Only load if we are actually on the settings page.
101
+ if ( self::SLUG !== $page ) {
102
+ return;
103
+ }
104
+
105
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueues' ) );
106
+
107
+ /*
108
+ * Define the core views for the our tab.
109
+ */
110
+ $this->views = apply_filters(
111
+ 'sbi_admin_about_views',
112
+ array(
113
+ esc_html__( 'About Us', 'instagram-feed' ) => array( 'about' ),
114
+ esc_html__( 'Getting Started', 'instagram-feed' ) => array( 'getting-started' ),
115
+ )
116
+ );
117
+
118
+ $license = $this->get_license_type();
119
+
120
+ if (
121
+ (
122
+ $license === 'pro' ||
123
+ ! in_array( $license, self::$licenses_top, true )
124
+ )
125
+ //sbi_debug()
126
+ ) {
127
+ $vs_tab_name = sprintf( /* translators: %1$s - current license type, %2$s - suggested license type. */
128
+ esc_html__( '%1$s vs %2$s', 'instagram-feed' ),
129
+ ucfirst( $license ),
130
+ $this->get_next_license( $license )
131
+ );
132
+
133
+ $this->views[ $vs_tab_name ] = array( 'versus' );
134
+ }
135
+
136
+ // Determine the current active settings tab.
137
+ $this->view = ! empty( $_GET['view'] ) ? esc_html( $_GET['view'] ) : self::DEFAULT_TAB;
138
+
139
+ // If the user tries to load an invalid view - fallback to About Us.
140
+ if (
141
+ ! in_array( $this->view, call_user_func_array( 'array_merge', $this->views ), true ) &&
142
+ ! has_action( 'sbi_admin_about_display_tab_' . sanitize_key( $this->view ) )
143
+ ) {
144
+ $this->view = self::DEFAULT_TAB;
145
+ }
146
+
147
+ add_action( 'sbi_admin_page', array( $this, 'output' ) );
148
+
149
+ // Hook for addons.
150
+ do_action( 'sbi_admin_about_init' );
151
+ }
152
+
153
+ /**
154
+ * Enqueue assets for the the page.
155
+ *
156
+ * @since 2.4/5.5
157
+ */
158
+ public function enqueues() {
159
+
160
+ wp_enqueue_script(
161
+ 'jquery-matchheight',
162
+ SBI_PLUGIN_URL . 'js/jquery.matchHeight-min.js',
163
+ array( 'jquery' ),
164
+ '0.7.0',
165
+ false
166
+ );
167
+ }
168
+
169
+ /**
170
+ * Output the basic page structure.
171
+ *
172
+ * @since 2.4/5.5
173
+ */
174
+ public function output() {
175
+
176
+ $show_nav = false;
177
+ foreach ( $this->views as $view ) {
178
+ if ( in_array( $this->view, (array) $view, true ) ) {
179
+ $show_nav = true;
180
+ break;
181
+ }
182
+ }
183
+ ?>
184
+
185
+ <div id="sbi-admin-about" class="wrap sbi-admin-wrap">
186
+
187
+ <?php
188
+ if ( $show_nav ) {
189
+ $license = $this->get_license_type();
190
+ $next_license = $this->get_next_license( $license );
191
+ echo '<ul class="sbi-admin-tabs">';
192
+ foreach ( $this->views as $label => $view ) {
193
+ $class = in_array( $this->view, $view, true ) ? 'active' : '';
194
+ echo '<li>';
195
+ printf(
196
+ '<a href="%s" class="%s">%s</a>',
197
+ esc_url( admin_url( 'admin.php?page=' . self::SLUG . '&view=' . sanitize_key( $view[0] ) ) ),
198
+ esc_attr( $class ),
199
+ esc_html( $label )
200
+ );
201
+ echo '</li>';
202
+ }
203
+ echo '</ul>';
204
+ }
205
+ ?>
206
+
207
+ <h1 class="sbi-h1-placeholder"></h1>
208
+
209
+ <?php
210
+ switch ( $this->view ) {
211
+ case 'about':
212
+ $this->output_about();
213
+ break;
214
+ case 'getting-started':
215
+ $this->output_getting_started();
216
+ break;
217
+ case 'versus':
218
+ $this->output_versus();
219
+ break;
220
+ default:
221
+ do_action( 'sbi_admin_about_display_tab_' . sanitize_key( $this->view ) );
222
+ break;
223
+ }
224
+ ?>
225
+
226
+ </div>
227
+
228
+ <?php
229
+ }
230
+
231
+ /**
232
+ * Display the About tab content.
233
+ *
234
+ * @since 2.4/5.5
235
+ */
236
+ protected function output_about() {
237
+
238
+ $this->output_about_info();
239
+ $this->output_about_addons();
240
+ }
241
+
242
+ /**
243
+ * Display the General Info section of About tab.
244
+ *
245
+ * @since 1.5.8
246
+ */
247
+ protected function output_about_info() {
248
+
249
+ ?>
250
+
251
+ <div class="sbi-admin-about-section sbi-admin-columns">
252
+
253
+ <div class="sbi-admin-about-text" style="min-height: 340px;">
254
+ <h3>
255
+ <?php esc_html_e( 'Hello and welcome to the Instagram Feed plugin, the most beautiful, clean, and reliable Instagram feed plugin in the world. At Smash Balloon, we build software that helps you create beautiful responsive social media feeds for your website in minutes.', 'instagram-feed' ); ?>
256
+ </h3>
257
+
258
+ <p>
259
+ <?php esc_html_e( 'Smash Balloon is a fun-loving WordPress plugin development company birthed into existence in early 2013. We specialize in creating plugins that are not only intuitive and simple to use, but also designed to integrate seamlessly into your website and allow you to display your social media content in powerful and unique ways. Over 1 million awesome people have decided to actively use our plugins, which is an incredible honor that we don’t take lightly. This compels us to try to provide the quickest and most effective customer support that we can, blowing users away with the best customer service they’ve ever experienced.', 'instagram-feed' ); ?>
260
+ </p>
261
+ <p>
262
+ <?php esc_html_e( 'We’re a small, but dedicated, team based in Minnesota in the USA.', 'instagram-feed' ); ?>
263
+ </p>
264
+ <!-- <p>
265
+ <?php
266
+ printf(
267
+ wp_kses(
268
+ /* translators: %1$s - WPBeginner URL, %2$s - OptinMonster URL, %3$s - MonsterInsights URL, %4$s - RafflePress URL. */
269
+ __( 'Instagram Feed is brought to you by the same team that’s behind the largest WordPress resource site, <a href="%1$s" target="_blank" rel="noopener noreferrer">WPBeginner</a>, the most popular lead-generation software, <a href="%2$s" target="_blank" rel="noopener noreferrer">OptinMonster</a>, the best WordPress analytics plugin, <a href="%3$s" target="_blank" rel="noopener noreferrer">MonsterInsights</a>, and the most powerful WordPress contest plugin, <a href="%4$s" target="_blank" rel="noopener noreferrer">RafflePress</a>.', 'instagram-feed' ),
270
+ array(
271
+ 'a' => array(
272
+ 'href' => array(),
273
+ 'rel' => array(),
274
+ 'target' => array(),
275
+ ),
276
+ )
277
+ ),
278
+ 'https://www.wpbeginner.com/?utm_source=sbiplugin&utm_medium=pluginaboutpage&utm_campaign=aboutsbi',
279
+ 'https://optinmonster.com/?utm_source=sbiplugin&utm_medium=pluginaboutpage&utm_campaign=aboutsbi',
280
+ 'https://www.monsterinsights.com/?utm_source=sbiplugin&utm_medium=pluginaboutpage&utm_campaign=aboutsbi',
281
+ 'https://rafflepress.com/?utm_source=sbiplugin&utm_medium=pluginaboutpage&utm_campaign=aboutsbi'
282
+ );
283
+ ?>
284
+ </p>
285
+ <p>
286
+ <?php esc_html_e( 'Yup, we know a thing or two about building awesome products that customers love.', 'instagram-feed' ); ?>
287
+ </p> -->
288
+ </div>
289
+
290
+ <div class="sbi-admin-about-image sbi-admin-column-last">
291
+ <figure>
292
+ <img src="<?php echo SBI_PLUGIN_URL; ?>img/about/team.jpg" alt="<?php esc_attr_e( 'The Sbi Team photo', 'instagram-feed' ); ?>">
293
+ <figcaption>
294
+ <?php esc_html_e( 'The Smash Balloon Team', 'instagram-feed' ); ?><br>
295
+ </figcaption>
296
+ </figure>
297
+ </div>
298
+
299
+ </div>
300
+ <?php
301
+ }
302
+
303
+ /**
304
+ * Display the Addons section of About tab.
305
+ *
306
+ * @since 1.5.8
307
+ */
308
+ protected function output_about_addons() {
309
+
310
+ if ( ! current_user_can( 'manage_instagram_feed_options' ) || version_compare( PHP_VERSION, '5.3.0' ) <= 0 ) {
311
+ return;
312
+ }
313
+
314
+ $all_plugins = get_plugins();
315
+ $am_plugins = $this->get_am_plugins();
316
+
317
+ ?>
318
+ <div id="sbi-admin-addons">
319
+ <div class="addons-container">
320
+ <h3><?php echo __( 'Our Other Plugins', 'instagram-feed' ); ?></h3>
321
+ <?php
322
+ foreach ( $am_plugins as $plugin => $details ) :
323
+
324
+ $plugin_data = $this->get_plugin_data( $plugin, $details, $all_plugins );
325
+
326
+ if ( $plugin === 'wpforms-lite/wpforms.php' ) {
327
+ echo '<h3>' .__( 'Plugins We Recommend', 'instagram-feed' ). '</h3>';
328
+ }
329
+
330
+ ?>
331
+ <div class="addon-container">
332
+ <div class="addon-item">
333
+ <div class="details sbi-clear">
334
+ <img src="<?php echo esc_url( $plugin_data['details']['icon'] ); ?>">
335
+ <h5 class="addon-name">
336
+ <?php echo esc_html( $plugin_data['details']['name'] ); ?>
337
+ </h5>
338
+ <p class="addon-desc">
339
+ <?php echo wp_kses_post( $plugin_data['details']['desc'] ); ?>
340
+ </p>
341
+ </div>
342
+ <div class="actions sbi-clear">
343
+ <div class="status">
344
+ <strong>
345
+ <?php
346
+ printf(
347
+ /* translators: %s - addon status label. */
348
+ esc_html__( 'Status: %s', 'instagram-feed' ),
349
+ '<span class="status-label ' . esc_attr( $plugin_data['status_class'] ) . '">' . wp_kses_post( $plugin_data['status_text'] ) . '</span>'
350
+ );
351
+ ?>
352
+ </strong>
353
+ </div>
354
+ <div class="action-button">
355
+ <button class="<?php echo esc_attr( $plugin_data['action_class'] ); ?>" data-plugin="<?php echo esc_attr( $plugin_data['plugin_src'] ); ?>" data-type="plugin">
356
+ <?php echo wp_kses_post( $plugin_data['action_text'] ); ?>
357
+ </button>
358
+ </div>
359
+ </div>
360
+ </div>
361
+ </div>
362
+ <?php endforeach; ?>
363
+ </div>
364
+ </div>
365
+ <?php
366
+ }
367
+
368
+ /**
369
+ * Get AM plugin data to display in the Addons section of About tab.
370
+ *
371
+ * @since 1.5.8
372
+ *
373
+ * @param string $plugin Plugin slug.
374
+ * @param array $details Plugin details.
375
+ * @param array $all_plugins List of all plugins.
376
+ *
377
+ * @return array
378
+ */
379
+ protected function get_plugin_data( $plugin, $details, $all_plugins ) {
380
+
381
+ $have_pro = ( ! empty( $details['pro'] ) && ! empty( $details['pro']['plug'] ) );
382
+ $show_pro = false;
383
+
384
+ $plugin_data = array();
385
+
386
+ if ( $have_pro ) {
387
+ if ( array_key_exists( $plugin, $all_plugins ) ) {
388
+ if ( is_plugin_active( $plugin ) ) {
389
+ $show_pro = true;
390
+ }
391
+ }
392
+ if ( array_key_exists( $details['pro']['plug'], $all_plugins ) ) {
393
+ $show_pro = true;
394
+ }
395
+ if ( $show_pro ) {
396
+ $plugin = $details['pro']['plug'];
397
+ $details = $details['pro'];
398
+ }
399
+ }
400
+
401
+ if ( array_key_exists( $plugin, $all_plugins ) ) {
402
+ if ( is_plugin_active( $plugin ) ) {
403
+ // Status text/status.
404
+ $plugin_data['status_class'] = 'status-active';
405
+ $plugin_data['status_text'] = esc_html__( 'Active', 'instagram-feed' );
406
+ // Button text/status.
407
+ $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-secondary disabled';
408
+ $plugin_data['action_text'] = esc_html__( 'Activated', 'instagram-feed' );
409
+ $plugin_data['plugin_src'] = esc_attr( $plugin );
410
+ } else {
411
+ // Status text/status.
412
+ $plugin_data['status_class'] = 'status-inactive';
413
+ $plugin_data['status_text'] = esc_html__( 'Inactive', 'instagram-feed' );
414
+ // Button text/status.
415
+ $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-secondary';
416
+ $plugin_data['action_text'] = esc_html__( 'Activate', 'instagram-feed' );
417
+ $plugin_data['plugin_src'] = esc_attr( $plugin );
418
+ }
419
+ } else {
420
+ // Doesn't exist, install.
421
+ // Status text/status.
422
+ $plugin_data['status_class'] = 'status-download';
423
+ if ( isset( $details['act'] ) && 'go-to-url' === $details['act'] ) {
424
+ $plugin_data['status_class'] = 'status-go-to-url';
425
+ }
426
+ $plugin_data['status_text'] = esc_html__( 'Not Installed', 'instagram-feed' );
427
+ // Button text/status.
428
+ $plugin_data['action_class'] = $plugin_data['status_class'] . ' button button-primary';
429
+ $plugin_data['action_text'] = esc_html__( 'Install Plugin', 'instagram-feed' );
430
+ $plugin_data['plugin_src'] = esc_url( $details['url'] );
431
+ }
432
+
433
+ $plugin_data['details'] = $details;
434
+
435
+ return $plugin_data;
436
+ }
437
+
438
+ /**
439
+ * Display the Getting Started tab content.
440
+ *
441
+ * @since 2.4/5.5
442
+ */
443
+ protected function output_getting_started() {
444
+
445
+ $license = $this->get_license_type();
446
+ ?>
447
+
448
+ <div class="sbi-admin-about-section sbi-admin-about-section-first-form" style="display:flex;">
449
+
450
+ <div class="sbi-admin-about-section-first-form-text">
451
+
452
+ <h2>
453
+ <?php esc_html_e( 'Creating Your First Feed', 'instagram-feed' ); ?>
454
+ </h2>
455
+
456
+ <p>
457
+ <?php esc_html_e( 'Want to get started creating your first feed with Instagram Feed? By following the step by step instructions in this walkthrough, you can easily publish your first feed on your site.', 'instagram-feed' ); ?>
458
+ </p>
459
+
460
+ <p>
461
+ <?php esc_html_e( 'Navigate to Instagram Feed in the admin sidebar to go the Configure page.', 'instagram-feed' ); ?>
462
+ </p>
463
+
464
+ <p>
465
+ <?php esc_html_e( 'Click on the large blue button to connect your Instagram account. Select "Personal" if your Instagram account is a personal account, "Business" if it is a business or creator account.', 'instagram-feed' ); ?>
466
+ </p>
467
+
468
+ <p>
469
+ <?php esc_html_e( 'Once you connect an Instagram account, you can display your feed on any post, page or widget using the shortcode [instagram-feed]. You can also use the Instagram Feed Gutenberg block if your site has the WordPress block editor enabled.', 'instagram-feed' ); ?>
470
+ </p>
471
+
472
+ <ul class="list-plain">
473
+ <li>
474
+ <a href="https://smashballoon.com/display-multiple-instagram-feeds/?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=multiplefeeds" target="_blank" rel="noopener noreferrer">
475
+ <?php esc_html_e( 'How to Display Multiple Feeds', 'instagram-feed' ); ?>
476
+ </a>
477
+ </li>
478
+ <li>
479
+ <a href="https://smashballoon.com/get-access-token-from-another-account/?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=differentaccounts" target="_blank" rel="noopener noreferrer">
480
+ <?php esc_html_e( 'Connect a Different Account', 'instagram-feed' ); ?>
481
+ </a>
482
+ </li>
483
+ <li>
484
+ <a href="https://smashballoon.com/differences-between-an-instagram-personal-and-business-account/?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=personalvbusiness" target="_blank" rel="noopener noreferrer">
485
+ <?php esc_html_e( 'Personal Vs Business Accounts', 'instagram-feed' ); ?>
486
+ </a>
487
+ </li>
488
+ </ul>
489
+
490
+ </div>
491
+
492
+ <div class="sbi-admin-about-section-first-form-video">
493
+ <iframe src="https://www.youtube-nocookie.com/embed/q6ZXVU4g970?rel=0" width="540" height="304" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
494
+ </div>
495
+
496
+ </div>
497
+
498
+ <?php if ( ! in_array( $license, self::$licenses_top, true ) ) { ?>
499
+ <div class="sbi-admin-about-section sbi-admin-about-section-hero">
500
+
501
+ <div class="sbi-admin-about-section-hero-main">
502
+ <h2>
503
+ <?php esc_html_e( 'Get Instagram Feed Pro and Unlock all the Powerful Features', 'instagram-feed' ); ?>
504
+ </h2>
505
+
506
+ <p class="bigger">
507
+ <?php
508
+ echo wp_kses(
509
+ __( 'Thanks for being a loyal Instagram Feed Lite user. <strong>Upgrade to Instagram Feed Pro</strong> to unlock all the awesome features and experience<br>why Instagram Feed is the most popular Instagram plugin.', 'instagram-feed' ),
510
+ array(
511
+ 'br' => array(),
512
+ 'strong' => array(),
513
+ )
514
+ );
515
+ ?>
516
+ </p>
517
+
518
+ <p>
519
+ <?php
520
+ printf(
521
+ wp_kses(
522
+ /* translators: %s - stars. */
523
+ __( 'We know that you will truly love Instagram Feed. It has over <strong>2500+ five star ratings</strong> (%s) and is active on over 1 million websites.', 'instagram-feed' ),
524
+ array(
525
+ 'strong' => array(),
526
+ )
527
+ ),
528
+ '<i class="fa fa-star" aria-hidden="true"></i>' .
529
+ '<i class="fa fa-star" aria-hidden="true"></i>' .
530
+ '<i class="fa fa-star" aria-hidden="true"></i>' .
531
+ '<i class="fa fa-star" aria-hidden="true"></i>' .
532
+ '<i class="fa fa-star" aria-hidden="true"></i>'
533
+ );
534
+ ?>
535
+ </p>
536
+ </div>
537
+
538
+ <div class="sbi-admin-about-section-hero-extra">
539
+ <div class="sbi-admin-columns">
540
+ <div class="sbi-admin-column-50">
541
+ <ul class="list-features list-plain">
542
+ <li>
543
+ <i class="fa fa-check" aria-hidden="true"></i>
544
+ <?php esc_html_e( 'Recent hashtag, top Hashtag, and tagged feeds.', 'instagram-feed' ); ?>
545
+ </li>
546
+ <li>
547
+ <i class="fa fa-check" aria-hidden="true"></i>
548
+ <?php esc_html_e( 'More layouts - masonry, highlight, and carousel.', 'instagram-feed' ); ?>
549
+ </li>
550
+ <li>
551
+ <i class="fa fa-check" aria-hidden="true"></i>
552
+ <?php esc_html_e( 'Captions, comments, dates, likes, and comment counts.', 'instagram-feed' ); ?>
553
+ </li>
554
+ <li>
555
+ <i class="fa fa-check" aria-hidden="true"></i>
556
+ <?php esc_html_e( 'Pop-up lightbox to view images and watch videos.', 'instagram-feed' ); ?>
557
+ </li>
558
+ <li>
559
+ <i class="fa fa-check" aria-hidden="true"></i>
560
+ <?php esc_html_e( 'Filter feeds by word or hashtag.', 'instagram-feed' ); ?>
561
+ </li>
562
+ </ul>
563
+ </div>
564
+ <div class="sbi-admin-column-50 sbi-admin-column-last">
565
+ <ul class="list-features list-plain">
566
+ <li>
567
+ <i class="fa fa-check" aria-hidden="true"></i>
568
+ <?php esc_html_e( 'Display Instagram stories.', 'instagram-feed' ); ?>
569
+ </li>
570
+ <li>
571
+ <i class="fa fa-check" aria-hidden="true"></i>
572
+ <?php esc_html_e( 'Powerful visual moderation system.', 'instagram-feed' ); ?>
573
+ </li>
574
+ <li>
575
+ <i class="fa fa-check" aria-hidden="true"></i>
576
+ <?php esc_html_e( 'More customization for feed headers.', 'instagram-feed' ); ?>
577
+ </li>
578
+ <li>
579
+ <i class="fa fa-check" aria-hidden="true"></i>
580
+ <?php esc_html_e( 'Even more customization options for your feed.', 'instagram-feed' ); ?>
581
+ </li>
582
+ <li>
583
+ <i class="fa fa-check" aria-hidden="true"></i>
584
+ <?php esc_html_e( '"Shoppable" feeds.', 'instagram-feed' ); ?>
585
+ </li>
586
+ </ul>
587
+ </div>
588
+ </div>
589
+
590
+ <hr />
591
+
592
+ <h3 class="call-to-action">
593
+ <?php
594
+ if ( 'lite' === $license ) {
595
+ echo '<a href="https://smashballoon.com/instagram-feed/pricing?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=profeaturescompare" target="_blank" rel="noopener noreferrer">';
596
+ } else {
597
+ echo '<a href="https://smashballoon.com/instagram-feed/pricing?utm_campaign=instagram-pro&utm_source=gettingstarted&utm_medium=profeaturescompare" target="_blank" rel="noopener noreferrer">';
598
+ }
599
+ esc_html_e( 'Get Instagram Feed Pro Today and Unlock all the Powerful Features', 'instagram-feed' );
600
+ ?>
601
+ </a>
602
+ </h3>
603
+
604
+ <?php if ( 'lite' === $license ) { ?>
605
+ <p>
606
+ <?php
607
+ echo wp_kses(
608
+ __( 'Bonus: Instagram Feed Lite users get <span class="price-20-off">50% off regular price</span>, automatically applied at checkout.', 'instagram-feed' ),
609
+ array(
610
+ 'span' => array(
611
+ 'class' => array(),
612
+ ),
613
+ )
614
+ );
615
+ ?>
616
+ </p>
617
+ <?php } ?>
618
+ </div>
619
+
620
+ </div>
621
+ <?php } ?>
622
+
623
+
624
+ <div class="sbi-admin-about-section sbi-admin-about-section-squashed sbi-admin-about-section-post sbi-admin-columns">
625
+ <div class="sbi-admin-column-20">
626
+ <img src="<?php echo SBI_PLUGIN_URL; ?>img/about/steps.png" alt="">
627
+ </div>
628
+ <div class="sbi-admin-column-80">
629
+ <h2>
630
+ <?php esc_html_e( 'Detailed Step-By-Step Guide', 'instagram-feed' ); ?>
631
+ </h2>
632
+
633
+ <p>
634
+ <?php esc_html_e( 'View detailed steps with related images on our website. We have a comprehensive guide to getting up and running with Instagram Feed.', 'instagram-feed' ); ?>
635
+ </p>
636
+
637
+ <a href="https://smashballoon.com/instagram-feed/free/?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=readsetup" target="_blank" rel="noopener noreferrer" class="sbi-admin-about-section-post-link">
638
+ <?php esc_html_e( 'Read Documentation', 'instagram-feed' ); ?><i class="fa fa-external-link" aria-hidden="true"></i>
639
+ </a>
640
+ </div>
641
+ </div>
642
+
643
+ <div class="sbi-admin-about-section sbi-admin-about-section-squashed sbi-admin-about-section-post sbi-admin-columns">
644
+ <div class="sbi-admin-column-20">
645
+ <img src="<?php echo SBI_PLUGIN_URL; ?>img/about/api-error.png" alt="">
646
+ </div>
647
+ <div class="sbi-admin-column-80">
648
+ <h2>
649
+ <?php esc_html_e( 'Troubleshoot Connection and API Errors', 'instagram-feed' ); ?>
650
+ </h2>
651
+
652
+ <p>
653
+ <?php esc_html_e( 'Are you having trouble displaying your feed due to an error connecting an account or an Instagram API error? We have several articles to help you troubleshoot issues and help you solve them.', 'instagram-feed' ); ?>
654
+ </p>
655
+
656
+ <a href="https://smashballoon.com/instagram-feed/docs/errors/?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=readerrordoc" target="_blank" rel="noopener noreferrer" class="sbi-admin-about-section-post-link">
657
+ <?php esc_html_e( 'Read Documentation', 'instagram-feed' ); ?><i class="fa fa-external-link" aria-hidden="true"></i>
658
+ </a>
659
+ </div>
660
+ </div>
661
+
662
+ <?php
663
+ }
664
+
665
+ /**
666
+ * Get the next license type. Helper for Versus tab content.
667
+ *
668
+ * @since 1.5.5
669
+ *
670
+ * @param string $current Current license type slug.
671
+ *
672
+ * @return string Next license type slug.
673
+ */
674
+ protected function get_next_license( $current ) {
675
+
676
+ $current = ucfirst( $current );
677
+ $license_pairs = array(
678
+ 'Lite' => 'Pro',
679
+ 'Basic' => 'Pro',
680
+ 'Plus' => 'Pro',
681
+ 'Pro' => 'Elite',
682
+ );
683
+
684
+ return ! empty( $license_pairs[ $current ] ) ? $license_pairs[ $current ] : 'Elite';
685
+ }
686
+
687
+ /**
688
+ * Display the Versus tab content.
689
+ *
690
+ * @since 2.4/5.5
691
+ */
692
+ protected function output_versus() {
693
+
694
+ //$license = $this->get_license_type();
695
+ //$next_license = $this->get_next_license( $license );
696
+ $license = 'lite';
697
+ $next_license = 'pro';
698
+ ?>
699
+
700
+ <div class="sbi-admin-about-section sbi-admin-about-section-squashed">
701
+ <h1 class="centered">
702
+ <strong><?php echo esc_html( ucfirst( $license ) ); ?></strong> vs <strong><?php echo esc_html( ucfirst( $next_license ) ); ?></strong>
703
+ </h1>
704
+
705
+ <p class="centered">
706
+ <?php esc_html_e( 'Get the most out of your Instagram Feeds by upgrading to Pro and unlocking all of the powerful features.', 'instagram-feed' ); ?>
707
+ </p>
708
+ </div>
709
+
710
+ <div class="sbi-admin-about-section sbi-admin-about-section-squashed sbi-admin-about-section-hero sbi-admin-about-section-table">
711
+
712
+ <div class="sbi-admin-about-section-hero-main sbi-admin-columns">
713
+ <div class="sbi-admin-column-33">
714
+ <h3 class="no-margin">
715
+ <?php esc_html_e( 'Feature', 'instagram-feed' ); ?>
716
+ </h3>
717
+ </div>
718
+ <div class="sbi-admin-column-33">
719
+ <h3 class="no-margin">
720
+ <?php echo esc_html( ucfirst( $license ) ); ?>
721
+ </h3>
722
+ </div>
723
+ <div class="sbi-admin-column-33">
724
+ <h3 class="no-margin">
725
+ <?php echo esc_html( ucfirst( $next_license ) ); ?>
726
+ </h3>
727
+ </div>
728
+ </div>
729
+ <div class="sbi-admin-about-section-hero-extra no-padding sbi-admin-columns">
730
+
731
+ <table>
732
+ <?php
733
+ foreach ( self::$licenses_features as $slug => $name ) {
734
+ $current = $this->get_license_data( $slug, $license );
735
+ $next = $this->get_license_data( $slug, strtolower( $next_license ) );
736
+
737
+ if ( empty( $current ) || empty( $next ) ) {
738
+ continue;
739
+ }
740
+ ?>
741
+ <tr class="sbi-admin-columns">
742
+ <td class="sbi-admin-column-33">
743
+ <p><?php echo esc_html( $name ); ?></p>
744
+ </td>
745
+ <td class="sbi-admin-column-33">
746
+ <?php if ( is_array( $current ) ) : ?>
747
+ <p class="features-<?php echo esc_attr( $current['status'] ); ?>">
748
+ <?php echo wp_kses_post( implode( '<br>', $current['text'] ) ); ?>
749
+ </p>
750
+ <?php endif; ?>
751
+ </td>
752
+ <td class="sbi-admin-column-33">
753
+ <?php if ( is_array( $current ) ) : ?>
754
+ <p class="features-full">
755
+ <?php echo wp_kses_post( implode( '<br>', $next['text'] ) ); ?>
756
+ </p>
757
+ <?php endif; ?>
758
+ </td>
759
+ </tr>
760
+ <?php
761
+ }
762
+ ?>
763
+ </table>
764
+
765
+ </div>
766
+
767
+ </div>
768
+
769
+ <div class="sbi-admin-about-section sbi-admin-about-section-hero">
770
+ <div class="sbi-admin-about-section-hero-main no-border">
771
+ <h3 class="call-to-action centered">
772
+ <?php
773
+ if ( 'lite' === $license ) {
774
+ echo '<a href="https://smashballoon.com/instagram-feed/pricing?utm_campaign=instagram-free&utm_source=gettingstarted&utm_medium=profeaturescompare" target="_blank" rel="noopener noreferrer">';
775
+ } else {
776
+ echo '<a href="https://smashballoon.com/instagram-feed/pricing?utm_campaign=instagram-pro&utm_source=gettingstarted&utm_medium=profeaturescompare" target="_blank" rel="noopener noreferrer">';
777
+ }
778
+ printf( /* translators: %s - next license level. */
779
+ esc_html__( 'Get Instagram Feed Pro Today and Unlock all the Powerful Features', 'instagram-feed' ),
780
+ esc_html( $next_license )
781
+ );
782
+ ?>
783
+ </a>
784
+ </h3>
785
+
786
+ <?php if ( 'lite' === $license ) { ?>
787
+ <p class="centered">
788
+ <?php
789
+ echo wp_kses(
790
+ __( 'Bonus: Instagram Feed Lite users get <span class="price-20-off">50% off regular price</span>, automatically applied at checkout.', 'instagram-feed' ),
791
+ array(
792
+ 'span' => array(
793
+ 'class' => array(),
794
+ ),
795
+ )
796
+ );
797
+ ?>
798
+ </p>
799
+ <?php } ?>
800
+ </div>
801
+ </div>
802
+
803
+ <?php
804
+ }
805
+
806
+ /**
807
+ * List of AM plugins that we propose to install.
808
+ *
809
+ * @since 2.4/5.5
810
+ *
811
+ * @return array
812
+ */
813
+ protected function get_am_plugins() {
814
+
815
+ $images_url = SBI_PLUGIN_URL . 'img/about/';
816
+
817
+ return array(
818
+ 'custom-facebook-feed/custom-facebook-feed.php' => array(
819
+ 'icon' => $images_url . 'plugin-fb.png',
820
+ 'name' => esc_html__( 'Custom Facebook Feed', 'instagram-feed' ),
821
+ 'desc' => esc_html__( 'Custom Facebook Feed makes displaying your Facebook posts easy. Keep your site visitors informed and increase engagement with your Facebook page by displaying a feed on your website.', 'instagram-feed' ),
822
+ 'url' => 'https://downloads.wordpress.org/plugin/custom-facebook-feed.zip',
823
+ 'pro' => array(
824
+ 'plug' => 'custom-facebook-feed-pro/custom-facebook-feed.php',
825
+ 'icon' => $images_url . 'plugin-fb.png',
826
+ 'name' => esc_html__( 'Custom Facebook Feed Pro', 'instagram-feed' ),
827
+ 'desc' => esc_html__( 'Custom Facebook Feed makes displaying your Facebook posts easy. Keep your site visitors informed and increase engagement with your Facebook page by displaying a feed on your website.', 'instagram-feed' ),
828
+ 'url' => 'https://smashballoon.com/custom-facebook-feed/?utm_campaign=instagram-free&utm_source=cross&utm_medium=cffinstaller',
829
+ 'act' => 'go-to-url',
830
+ ),
831
+ ),
832
+
833
+ 'custom-twitter-feeds/custom-twitter-feed.php' => array(
834
+ 'icon' => $images_url . 'plugin-tw.jpg',
835
+ 'name' => esc_html__( 'Custom Twitter Feeds', 'instagram-feed' ),
836
+ 'desc' => esc_html__( 'Custom Twitter Feeds is a highly customizable way to display tweets from your Twitter account. Promote your latest content and update your site content automatically.', 'instagram-feed' ),
837
+ 'url' => 'https://downloads.wordpress.org/plugin/custom-twitter-feeds.zip',
838
+ 'pro' => array(
839
+ 'plug' => 'custom-twitter-feeds-pro/custom-twitter-feed.php',
840
+ 'icon' => $images_url . 'plugin-tw.jpg',
841
+ 'name' => esc_html__( 'Custom Twitter Feeds Pro', 'instagram-feed' ),
842
+ 'desc' => esc_html__( 'Custom Twitter Feeds is a highly customizable way to display tweets from your Twitter account. Promote your latest content and update your site content automatically.', 'instagram-feed' ),
843
+ 'url' => 'https://smashballoon.com/custom-twitter-feeds/?utm_campaign=instagram-free&utm_source=cross&utm_medium=ctfinstaller',
844
+ 'act' => 'go-to-url',
845
+ ),
846
+ ),
847
+
848
+ 'feeds-for-youtube/youtube-feed.php' => array(
849
+ 'icon' => $images_url . 'plugin-yt.png',
850
+ 'name' => esc_html__( 'Feeds for YouTube', 'instagram-feed' ),
851
+ 'desc' => esc_html__( 'Feeds for YouTube is a simple yet powerful way to display videos from YouTube on your website. Increase engagement with your channel while keeping visitors on your website.', 'instagram-feed' ),
852
+ 'url' => 'https://downloads.wordpress.org/plugin/feeds-for-youtube.zip',
853
+ 'pro' => array(
854
+ 'plug' => 'youtube-feed-pro/youtube-feed.php',
855
+ 'icon' => $images_url . 'plugin-yt.png',
856
+ 'name' => esc_html__( 'Feeds for YouTube Pro', 'instagram-feed' ),
857
+ 'desc' => esc_html__( 'Feeds for YouTube is a simple yet powerful way to display videos from YouTube on your website. Increase engagement with your channel while keeping visitors on your website.', 'instagram-feed' ),
858
+ 'url' => 'https://smashballoon.com/youtube-feed/?utm_campaign=instagram-free&utm_source=cross&utm_medium=sbyinstaller',
859
+ 'act' => 'go-to-url',
860
+ ),
861
+ ),
862
+
863
+ 'wpforms-lite/wpforms.php' => array(
864
+ 'icon' => $images_url . 'plugin-wpforms.png',
865
+ 'name' => esc_html__( 'WPForms', 'instagram-feed' ),
866
+ 'desc' => esc_html__( 'The most beginner friendly drag & drop WordPress forms plugin allowing you to create beautiful contact forms, subscription forms, payment forms, and more in minutes, not hours!', 'instagram-feed' ),
867
+ 'url' => 'https://downloads.wordpress.org/plugin/wpforms-lite.zip',
868
+ 'pro' => array(
869
+ 'plug' => 'wpforms/wpforms.php',
870
+ 'icon' => $images_url . 'plugin-wpforms.png',
871
+ 'name' => esc_html__( 'WPForms', 'instagram-feed' ),
872
+ 'desc' => esc_html__( 'The most beginner friendly drag & drop WordPress forms plugin allowing you to create beautiful contact forms, subscription forms, payment forms, and more in minutes, not hours!', 'instagram-feed' ),
873
+ 'url' => 'https://wpforms.com/lite-upgrade/?utm_source=WordPress&utm_campaign=liteplugin&utm_medium=about-page',
874
+ 'act' => 'go-to-url',
875
+ ),
876
+ ),
877
+
878
+ 'google-analytics-for-wordpress/googleanalytics.php' => array(
879
+ 'icon' => $images_url . 'plugin-mi.png',
880
+ 'name' => esc_html__( 'MonsterInsights', 'instagram-feed' ),
881
+ 'desc' => esc_html__( 'MonsterInsights makes it “effortless” to properly connect your WordPress site with Google Analytics, so you can start making data-driven decisions to grow your business.', 'instagram-feed' ),
882
+ 'url' => 'https://downloads.wordpress.org/plugin/google-analytics-for-wordpress.zip',
883
+ 'pro' => array(
884
+ 'plug' => 'google-analytics-premium/googleanalytics-premium.php',
885
+ 'icon' => $images_url . 'plugin-mi.png',
886
+ 'name' => esc_html__( 'MonsterInsights Pro', 'instagram-feed' ),
887
+ 'desc' => esc_html__( 'MonsterInsights makes it “effortless” to properly connect your WordPress site with Google Analytics, so you can start making data-driven decisions to grow your business.', 'instagram-feed' ),
888
+ 'url' => 'https://www.monsterinsights.com/?utm_source=proplugin&utm_medium=about-page&utm_campaign=pluginurl&utm_content=7%2E0%2E0',
889
+ 'act' => 'go-to-url',
890
+ ),
891
+ ),
892
+
893
+ 'optinmonster/optin-monster-wp-api.php' => array(
894
+ 'icon' => $images_url . 'plugin-om.png',
895
+ 'name' => esc_html__( 'OptinMonster', 'instagram-feed' ),
896
+ 'desc' => esc_html__( 'Our high-converting optin forms like Exit-Intent® popups, Fullscreen Welcome Mats, and Scroll boxes help you dramatically boost conversions and get more email subscribers.', 'instagram-feed' ),
897
+ 'url' => 'https://downloads.wordpress.org/plugin/optinmonster.zip',
898
+ ),
899
+
900
+ 'wp-mail-smtp/wp_mail_smtp.php' => array(
901
+ 'icon' => $images_url . 'plugin-smtp.png',
902
+ 'name' => esc_html__( 'WP Mail SMTP', 'instagram-feed' ),
903
+ 'desc' => esc_html__( 'Make sure your website\'s emails reach the inbox. Our goal is to make email deliverability easy and reliable. Trusted by over 1 million websites.', 'instagram-feed' ),
904
+ 'url' => 'https://downloads.wordpress.org/plugin/wp-mail-smtp.zip',
905
+ 'pro' => array(
906
+ 'plug' => 'wp-mail-smtp-pro/wp_mail_smtp.php',
907
+ 'icon' => $images_url . 'plugin-smtp.png',
908
+ 'name' => esc_html__( 'WP Mail SMTP Pro', 'instagram-feed' ),
909
+ 'desc' => esc_html__( 'Make sure your website\'s emails reach the inbox. Our goal is to make email deliverability easy and reliable. Trusted by over 1 million websites.', 'instagram-feed' ),
910
+ 'url' => 'https://wpmailsmtp.com/pricing/',
911
+ 'act' => 'go-to-url',
912
+ ),
913
+ ),
914
+
915
+ 'rafflepress/rafflepress.php' => array(
916
+ 'icon' => $images_url . 'plugin-rp.png',
917
+ 'name' => esc_html__( 'RafflePress', 'instagram-feed' ),
918
+ 'desc' => esc_html__( 'Turn your visitors into brand ambassadors! Easily grow your email list, website traffic, and social media followers with powerful viral giveaways & contests.', 'instagram-feed' ),
919
+ 'url' => 'https://downloads.wordpress.org/plugin/rafflepress.zip',
920
+ 'pro' => array(
921
+ 'plug' => 'rafflepress-pro/rafflepress-pro.php',
922
+ 'icon' => $images_url . 'plugin-rp.png',
923
+ 'name' => esc_html__( 'RafflePress Pro', 'instagram-feed' ),
924
+ 'desc' => esc_html__( 'Turn your visitors into brand ambassadors! Easily grow your email list, website traffic, and social media followers with powerful viral giveaways & contests.', 'instagram-feed' ),
925
+ 'url' => 'https://rafflepress.com/pricing/',
926
+ 'act' => 'go-to-url',
927
+ ),
928
+ ),
929
+
930
+ 'all-in-one-seo-pack/all_in_one_seo_pack.php' => array(
931
+ 'icon' => $images_url . 'plugin-seo.png',
932
+ 'name' => esc_html__( 'All In One SEO Pack', 'instagram-feed' ),
933
+ 'desc' => esc_html__( 'Out-of-the-box SEO for WordPress. Features like XML Sitemaps, SEO for custom post types, SEO for blogs or business sites, SEO for ecommerce sites, and much more. More than 50 million downloads since 2007.', 'instagram-feed' ),
934
+ 'url' => 'https://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip',
935
+ ),
936
+ );
937
+ }
938
+
939
+ /**
940
+ * Get the array of data that compared the license data.
941
+ *
942
+ * @since 2.4/5.5
943
+ *
944
+ * @param string $feature Feature name.
945
+ * @param string $license License type to get data for.
946
+ *
947
+ * @return array|false
948
+ */
949
+ protected function get_license_data( $feature, $license ) {
950
+
951
+ $data = array(
952
+ 'entries' => array(
953
+ 'lite' => array(
954
+ 'status' => 'partial',
955
+ 'text' => array(
956
+ '<strong>' . esc_html__( 'User feeds only', 'instagram-feed' ) . '</strong>',
957
+ ),
958
+ ),
959
+ 'basic' => array(
960
+ 'status' => 'full',
961
+ 'text' => array(
962
+ '<strong>' . esc_html__( 'User, Hashtag, and Tagged Feeds', 'instagram-feed' ) . '</strong>',
963
+ ),
964
+ ),
965
+ 'plus' => array(
966
+ 'status' => 'full',
967
+ 'text' => array(
968
+ '<strong>' . esc_html__( 'Complete Entry Management inside WordPress', 'instagram-feed' ) . '</strong>',
969
+ ),
970
+ ),
971
+ 'pro' => array(
972
+ 'status' => 'full',
973
+ 'text' => array(
974
+ '<strong>' . esc_html__( 'User, hashtag, and tagged feeds', 'instagram-feed' ) . '</strong>',
975
+ ),
976
+ ),
977
+ ),
978
+ 'fields' => array(
979
+ 'lite' => array(
980
+ 'status' => 'partial',
981
+ 'text' => array(
982
+ '<strong>' . esc_html__( 'Grid layout only', 'instagram-feed' ) . '</strong>',
983
+ ),
984
+ ),
985
+ 'basic' => array(
986
+ 'status' => 'full',
987
+ 'text' => array(
988
+ '<strong>' . esc_html__( 'Access to all Standard and Fancy Fields', 'instagram-feed' ) . '</strong>',
989
+ esc_html__( 'Address, Phone, Website URL, Date/Time, Password, File Upload, HTML, Pagebreaks, Section Dividers, Ratings, and Hidden Field', 'instagram-feed' ),
990
+ ),
991
+ ),
992
+ 'plus' => array(
993
+ 'status' => 'full',
994
+ 'text' => array(
995
+ '<strong>' . esc_html__( 'Access to all Standard and Fancy Fields', 'instagram-feed' ) . '</strong>',
996
+ esc_html__( 'Address, Phone, Website URL, Date/Time, Password, File Upload, HTML, Pagebreaks, Section Dividers, Ratings, and Hidden Field', 'instagram-feed' ),
997
+ ),
998
+ ),
999
+ 'pro' => array(
1000
+ 'status' => 'full',
1001
+ 'text' => array(
1002
+ '<strong>' . esc_html__( 'Grid, highlight, masonry, and carousel layouts', 'instagram-feed' ) . '</strong>',
1003
+ ),
1004
+ ),
1005
+ ),
1006
+ 'conditionals' => array(
1007
+ 'lite' => array(
1008
+ 'status' => 'partial',
1009
+ 'text' => array(
1010
+ '<strong>' . esc_html__( 'Image, carousel, and video thumbnails', 'instagram-feed' ) . '</strong>',
1011
+ ),
1012
+ ),
1013
+ 'basic' => array(
1014
+ 'status' => 'full',
1015
+ 'text' => array(
1016
+ '<strong>' . esc_html__( 'Powerful Form Logic for Building Smart Forms', 'instagram-feed' ) . '</strong>',
1017
+ ),
1018
+ ),
1019
+ 'plus' => array(
1020
+ 'status' => 'full',
1021
+ 'text' => array(
1022
+ '<strong>' . esc_html__( 'Powerful Form Logic for Building Smart Forms', 'instagram-feed' ) . '</strong>',
1023
+ ),
1024
+ ),
1025
+ 'pro' => array(
1026
+ 'status' => 'full',
1027
+ 'text' => array(
1028
+ '<strong>' . esc_html__( 'Display images, swipe through carousel posts, and play videos in a pop-up lightbox', 'instagram-feed' ) . '</strong>',
1029
+ ),
1030
+ ),
1031
+ ),
1032
+ 'templates' => array(
1033
+ 'lite' => array(
1034
+ 'status' => 'partial',
1035
+ 'text' => array(
1036
+ '<strong>' . esc_html__( 'Images and link only', 'instagram-feed' ) . '</strong>',
1037
+ ),
1038
+ ),
1039
+ 'basic' => array(
1040
+ 'status' => 'partial',
1041
+ 'text' => array(
1042
+ '<strong>' . esc_html__( 'Basic Form Templates', 'instagram-feed' ) . '</strong>',
1043
+ ),
1044
+ ),
1045
+ 'plus' => array(
1046
+ 'status' => 'partial',
1047
+ 'text' => array(
1048
+ '<strong>' . esc_html__( 'Basic Form Templates', 'instagram-feed' ) . '</strong>',
1049
+ ),
1050
+ ),
1051
+ 'pro' => array(
1052
+ 'status' => 'full',
1053
+ 'text' => array(
1054
+ '<strong>' . esc_html__( 'Thumbnails, dates, caption, comments, like counts, and comment counts.', 'instagram-feed' ) . '</strong>',
1055
+ ),
1056
+ ),
1057
+ ),
1058
+ 'marketing' => array(
1059
+ 'lite' => array(
1060
+ 'status' => 'none',
1061
+ 'text' => array(
1062
+ '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1063
+ ),
1064
+ ),
1065
+ 'basic' => array(
1066
+ 'status' => 'partial',
1067
+ 'text' => array(
1068
+ '<strong>' . esc_html__( 'Limited Marketing Integration', 'instagram-feed' ) . '</strong>',
1069
+ esc_html__( 'Constant Contact only', 'instagram-feed' ),
1070
+ ),
1071
+ ),
1072
+ 'plus' => array(
1073
+ 'status' => 'partial',
1074
+ 'text' => array(
1075
+ '<strong>' . esc_html__( '6 Email Marketing Integrations', 'instagram-feed' ) . '</strong>',
1076
+ esc_html__( 'Constant Contact, Mailchimp, AWeber, GetResponse, Campaign Monitor, and Drip', 'instagram-feed' ),
1077
+ ),
1078
+ ),
1079
+ 'pro' => array(
1080
+ 'status' => 'full',
1081
+ 'text' => array(
1082
+ '<strong>' . esc_html__( 'Display your latest Instagram story in a pop-up lightbox', 'instagram-feed' ) . '</strong>',
1083
+ ),
1084
+ ),
1085
+ ),
1086
+ 'payments' => array(
1087
+ 'lite' => array(
1088
+ 'status' => 'none',
1089
+ 'text' => array(
1090
+ '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1091
+ ),
1092
+ ),
1093
+ 'basic' => array(
1094
+ 'status' => 'none',
1095
+ 'text' => array(
1096
+ '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1097
+ ),
1098
+ ),
1099
+ 'plus' => array(
1100
+ 'status' => 'none',
1101
+ 'text' => array(
1102
+ '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1103
+ ),
1104
+ ),
1105
+ 'pro' => array(
1106
+ 'status' => 'full',
1107
+ 'text' => array(
1108
+ '<strong>' . esc_html__( 'Visual moderation system for removing posts or creating a "white list" of selected posts', 'instagram-feed' ) . '</strong>',
1109
+ ),
1110
+ ),
1111
+ ),
1112
+ 'surveys' => array(
1113
+ 'lite' => array(
1114
+ 'status' => 'partial',
1115
+ 'text' => array(
1116
+ '<strong>' . esc_html__( 'Standard or centered header', 'instagram-feed' ) . '</strong>',
1117
+ ),
1118
+ ),
1119
+ 'basic' => array(
1120
+ 'status' => 'none',
1121
+ 'text' => array(
1122
+ '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1123
+ ),
1124
+ ),
1125
+ 'plus' => array(
1126
+ 'status' => 'none',
1127
+ 'text' => array(
1128
+ '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1129
+ ),
1130
+ ),
1131
+ 'pro' => array(
1132
+ 'status' => 'full',
1133
+ 'text' => array(
1134
+ '<strong>' . esc_html__( 'Standard, centered, or boxed header that includes follower and post counts', 'instagram-feed' ) . '</strong>',
1135
+ ),
1136
+ ),
1137
+ ),
1138
+ 'advanced' => array(
1139
+ 'lite' => array(
1140
+ 'status' => 'partial',
1141
+ 'text' => array(
1142
+ '<strong>' . esc_html__( 'Posts link to the same post on Instagram', 'instagram-feed' ) . '</strong>',
1143
+ ),
1144
+ ),
1145
+ 'basic' => array(
1146
+ 'status' => 'partial',
1147
+ 'text' => array(
1148
+ '<strong>' . esc_html__( 'Limited Advanced Features', 'instagram-feed' ) . '</strong>',
1149
+ esc_html__( 'Multi-page Forms, File Upload Forms, Multiple Form Notifications, Conditional Form Confirmation', 'instagram-feed' ),
1150
+ ),
1151
+ ),
1152
+ 'plus' => array(
1153
+ 'status' => 'partial',
1154
+ 'text' => array(
1155
+ '<strong>' . esc_html__( 'Limited Advanced Features', 'instagram-feed' ) . '</strong>',
1156
+ esc_html__( 'Multi-page Forms, File Upload Forms, Multiple Form Notifications, Conditional Form Confirmation', 'instagram-feed' ),
1157
+ ),
1158
+ ),
1159
+ 'pro' => array(
1160
+ 'status' => 'full',
1161
+ 'text' => array(
1162
+ '<strong>' . esc_html__( 'Allow your posts to link to a URL in the caption or view in a lightbox', 'instagram-feed' ) . '</strong>',
1163
+ ),
1164
+ ),
1165
+ ),
1166
+ 'addons' => array(
1167
+ 'lite' => array(
1168
+ 'status' => 'none',
1169
+ 'text' => array(
1170
+ '<strong>' . esc_html__( 'Not available', 'instagram-feed' ) . '</strong>',
1171
+ ),
1172
+ ),
1173
+ 'basic' => array(
1174
+ 'status' => 'partial',
1175
+ 'text' => array(
1176
+ '<strong>' . esc_html__( 'Custom Captcha Addon included', 'instagram-feed' ) . '</strong>',
1177
+ ),
1178
+ ),
1179
+ 'plus' => array(
1180
+ 'status' => 'partial',
1181
+ 'text' => array(
1182
+ '<strong>' . esc_html__( 'Email Marketing Addons included', 'instagram-feed' ) . '</strong>',
1183
+ ),
1184
+ ),
1185
+ 'pro' => array(
1186
+ 'status' => 'full',
1187
+ 'text' => array(
1188
+ '<strong>' . esc_html__( 'Filter by word or hashtag', 'instagram-feed' ) . '</strong>',
1189
+ ),
1190
+ ),
1191
+ ),
1192
+ 'support' => array(
1193
+ 'lite' => array(
1194
+ 'status' => 'partial',
1195
+ 'text' => array(
1196
+ '<strong>' . esc_html__( 'Limited support', 'instagram-feed' ) . '</strong>',
1197
+ ),
1198
+ ),
1199
+ 'basic' => array(
1200
+ 'status' => 'partial',
1201
+ 'text' => array(
1202
+ '<strong>' . esc_html__( 'Standard Support', 'instagram-feed' ) . '</strong>',
1203
+ ),
1204
+ ),
1205
+ 'plus' => array(
1206
+ 'status' => 'partial',
1207
+ 'text' => array(
1208
+ '<strong>' . esc_html__( 'Standard Support', 'instagram-feed' ) . '</strong>',
1209
+ ),
1210
+ ),
1211
+ 'pro' => array(
1212
+ 'status' => 'full',
1213
+ 'text' => array(
1214
+ '<strong>' . esc_html__( 'Priority support', 'instagram-feed' ) . '</strong>',
1215
+ ),
1216
+ ),
1217
+ 'elite' => array(
1218
+ 'status' => 'full',
1219
+ 'text' => array(
1220
+ '<strong>' . esc_html__( 'Premium Support', 'instagram-feed' ) . '</strong>',
1221
+ ),
1222
+ ),
1223
+ 'ultimate' => array(
1224
+ 'status' => 'full',
1225
+ 'text' => array(
1226
+ '<strong>' . esc_html__( 'Premium Support', 'instagram-feed' ) . '</strong>',
1227
+ ),
1228
+ ),
1229
+ 'agency' => array(
1230
+ 'status' => 'full',
1231
+ 'text' => array(
1232
+ '<strong>' . esc_html__( 'Premium Support', 'instagram-feed' ) . '</strong>',
1233
+ ),
1234
+ ),
1235
+ ),
1236
+ 'sites' => array(
1237
+ 'basic' => array(
1238
+ 'status' => 'partial',
1239
+ 'text' => array(
1240
+ '<strong>' . esc_html__( '1 Site', 'instagram-feed' ) . '</strong>',
1241
+ ),
1242
+ ),
1243
+ 'plus' => array(
1244
+ 'status' => 'partial',
1245
+ 'text' => array(
1246
+ '<strong>' . esc_html__( '3 Sites', 'instagram-feed' ) . '</strong>',
1247
+ ),
1248
+ ),
1249
+ 'pro' => array(
1250
+ 'status' => 'full',
1251
+ 'text' => array(
1252
+ '<strong>' . esc_html__( '5 Sites', 'instagram-feed' ) . '</strong>',
1253
+ ),
1254
+ ),
1255
+ 'elite' => array(
1256
+ 'status' => 'full',
1257
+ 'text' => array(
1258
+ '<strong>' . esc_html__( 'Unlimited Sites', 'instagram-feed' ) . '</strong>',
1259
+ ),
1260
+ ),
1261
+ 'ultimate' => array(
1262
+ 'status' => 'full',
1263
+ 'text' => array(
1264
+ '<strong>' . esc_html__( 'Unlimited Sites', 'instagram-feed' ) . '</strong>',
1265
+ ),
1266
+ ),
1267
+ 'agency' => array(
1268
+ 'status' => 'full',
1269
+ 'text' => array(
1270
+ '<strong>' . esc_html__( 'Unlimited Sites', 'instagram-feed' ) . '</strong>',
1271
+ ),
1272
+ ),
1273
+ ),
1274
+ );
1275
+
1276
+ // Wrong feature?
1277
+ if ( ! isset( $data[ $feature ] ) ) {
1278
+ return false;
1279
+ }
1280
+
1281
+ // Is a top level license?
1282
+ $is_licenses_top = in_array( $license, self::$licenses_top, true );
1283
+
1284
+ // Wrong license type?
1285
+ if ( ! isset( $data[ $feature ][ $license ] ) && ! $is_licenses_top ) {
1286
+ return false;
1287
+ }
1288
+
1289
+ // Some licenses have partial data.
1290
+ if ( isset( $data[ $feature ][ $license ] ) ) {
1291
+ return $data[ $feature ][ $license ];
1292
+ }
1293
+
1294
+ // Top level plans has no feature difference with `pro` plan in most cases.
1295
+ return $is_licenses_top ? $data[ $feature ]['pro'] : $data[ $feature ][ $license ];
1296
+ }
1297
+
1298
+ /**
1299
+ * Get the current installation license type (always lowercase).
1300
+ *
1301
+ * @since 2.4/5.5
1302
+ *
1303
+ * @return string
1304
+ */
1305
+ protected function get_license_type() {
1306
+
1307
+ //$type = sbi_setting( 'type', '', 'sbi_license' );
1308
+
1309
+ //if ( empty( $type ) || ! sbi()->pro ) {
1310
+ $type = 'lite';
1311
+ //}
1312
+
1313
+ return strtolower( $type );
1314
+ }
1315
+ }
1316
+
1317
+ new SB_Instagram_About();
inc/admin/class-sbi-sitehealth.php CHANGED
@@ -1,82 +1,82 @@
1
- <?php
2
-
3
- class SB_Instagram_SiteHealth {
4
-
5
- /**
6
- * Indicates if current integration is allowed to load.
7
- *
8
- * @since 1.5.5
9
- *
10
- * @return bool
11
- */
12
- public function allow_load() {
13
-
14
- global $wp_version;
15
-
16
- return version_compare( $wp_version, '5.2', '>=' );
17
- }
18
-
19
- /**
20
- * Loads an integration.
21
- *
22
- * @since 1.5.5
23
- */
24
- public function load() {
25
-
26
- $this->hooks();
27
- }
28
-
29
- /**
30
- * Integration hooks.
31
- *
32
- * @since 1.5.5
33
- */
34
- protected function hooks() {
35
- add_filter( 'site_status_tests', array( $this, 'add_tests' ) );
36
- }
37
-
38
- /**
39
- * Add MonsterInsights WP Site Health tests.
40
- *
41
- * @param array $tests The current filters array.
42
- *
43
- * @return array
44
- */
45
- public function add_tests( $tests ) {
46
- $tests['direct']['sbi_test_check_errors'] = array(
47
- 'label' => __( 'Instagram Feed Errors', 'instagram-feed' ),
48
- 'test' => array( $this, 'test_check_errors' )
49
- );
50
-
51
- return $tests;
52
- }
53
-
54
- /**
55
- * Checks if there are Instagram API Errors
56
- */
57
- public function test_check_errors() {
58
- $result = array(
59
- 'label' => __( 'Instagram Feed has no critical errors', 'instagram-feed' ),
60
- 'status' => 'good',
61
- 'badge' => array(
62
- 'label' => __( 'Instagram Feed', 'instagram-feed' ),
63
- 'color' => 'blue',
64
- ),
65
- 'description' => __( 'No critical errors have been detected.', 'instagram-feed' ),
66
- 'test' => 'sbi_test_check_errors',
67
- );
68
-
69
- global $sb_instagram_posts_manager;
70
-
71
-
72
- if ( $sb_instagram_posts_manager->are_critical_errors() ) {
73
- $link = admin_url( '?page=sb-instagram-feed');
74
- $result['status'] = 'critical';
75
- $result['label'] = __( 'Your Instagram Feed is experiencing an error.', 'instagram-feed' );
76
- $result['description'] = sprintf( __( 'A critical issue has been detected with your Instagram Feed. Visit the %sInstagram Feed settings page%s to fix the issue.', 'instagram-feed' ), '<a href="' . esc_url( $link ) . '">', '</a>' );
77
- }
78
-
79
-
80
- return $result;
81
- }
82
  }
1
+ <?php
2
+
3
+ class SB_Instagram_SiteHealth {
4
+
5
+ /**
6
+ * Indicates if current integration is allowed to load.
7
+ *
8
+ * @since 1.5.5
9
+ *
10
+ * @return bool
11
+ */
12
+ public function allow_load() {
13
+
14
+ global $wp_version;
15
+
16
+ return version_compare( $wp_version, '5.2', '>=' );
17
+ }
18
+
19
+ /**
20
+ * Loads an integration.
21
+ *
22
+ * @since 1.5.5
23
+ */
24
+ public function load() {
25
+
26
+ $this->hooks();
27
+ }
28
+
29
+ /**
30
+ * Integration hooks.
31
+ *
32
+ * @since 1.5.5
33
+ */
34
+ protected function hooks() {
35
+ add_filter( 'site_status_tests', array( $this, 'add_tests' ) );
36
+ }
37
+
38
+ /**
39
+ * Add MonsterInsights WP Site Health tests.
40
+ *
41
+ * @param array $tests The current filters array.
42
+ *
43
+ * @return array
44
+ */
45
+ public function add_tests( $tests ) {
46
+ $tests['direct']['sbi_test_check_errors'] = array(
47
+ 'label' => __( 'Instagram Feed Errors', 'instagram-feed' ),
48
+ 'test' => array( $this, 'test_check_errors' )
49
+ );
50
+
51
+ return $tests;
52
+ }
53
+
54
+ /**
55
+ * Checks if there are Instagram API Errors
56
+ */
57
+ public function test_check_errors() {
58
+ $result = array(
59
+ 'label' => __( 'Instagram Feed has no critical errors', 'instagram-feed' ),
60
+ 'status' => 'good',
61
+ 'badge' => array(
62
+ 'label' => __( 'Instagram Feed', 'instagram-feed' ),
63
+ 'color' => 'blue',
64
+ ),
65
+ 'description' => __( 'No critical errors have been detected.', 'instagram-feed' ),
66
+ 'test' => 'sbi_test_check_errors',
67
+ );
68
+
69
+ global $sb_instagram_posts_manager;
70
+
71
+
72
+ if ( $sb_instagram_posts_manager->are_critical_errors() ) {
73
+ $link = admin_url( '?page=sb-instagram-feed');
74
+ $result['status'] = 'critical';
75
+ $result['label'] = __( 'Your Instagram Feed is experiencing an error.', 'instagram-feed' );
76
+ $result['description'] = sprintf( __( 'A critical issue has been detected with your Instagram Feed. Visit the %sInstagram Feed settings page%s to fix the issue.', 'instagram-feed' ), '<a href="' . esc_url( $link ) . '">', '</a>' );
77
+ }
78
+
79
+
80
+ return $result;
81
+ }
82
  }
inc/admin/class-sbi-tracking.php ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Tracking functions for reporting plugin usage to the Smash Balloon site for users that have opted in
4
+ *
5
+ * @copyright Copyright (c) 2018, Chris Christoff
6
+ * @since 5.6
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ /**
15
+ * Usage tracking
16
+ *
17
+ * @access public
18
+ * @since 5.6
19
+ * @return void
20
+ */
21
+ class SB_Instagram_Tracking {
22
+
23
+ public function __construct() {
24
+ add_action( 'init', array( $this, 'schedule_send' ) );
25
+ add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
26
+ add_action( 'sbi_usage_tracking_cron', array( $this, 'send_checkin' ) );
27
+ }
28
+
29
+ private function normalize_and_format( $key, $value ) {
30
+ $normal_bools = array(
31
+ 'sb_instagram_preserve_settings',
32
+ 'sb_instagram_ajax_theme',
33
+ 'enqueue_js_in_head',
34
+ 'disable_js_image_loading',
35
+ 'sb_instagram_disable_resize',
36
+ 'sb_instagram_favor_local',
37
+ 'sbi_hover_inc_username',
38
+ 'sbi_hover_inc_icon',
39
+ 'sbi_hover_inc_date',
40
+ 'sbi_hover_inc_instagram',
41
+ 'sbi_hover_inc_location',
42
+ 'sbi_hover_inc_caption',
43
+ 'sbi_hover_inc_likes',
44
+ 'sb_instagram_disable_lightbox',
45
+ 'sb_instagram_captionlinks',
46
+ 'sb_instagram_show_btn',
47
+ 'sb_instagram_show_caption',
48
+ 'sb_instagram_lightbox_comments',
49
+ 'sb_instagram_show_meta',
50
+ 'sb_instagram_show_header',
51
+ 'sb_instagram_show_followers',
52
+ 'sb_instagram_show_bio',
53
+ 'sb_instagram_outside_scrollable',
54
+ 'sb_instagram_stories',
55
+ 'sb_instagram_show_follow_btn',
56
+ 'sb_instagram_autoscroll',
57
+ 'sb_instagram_disable_font',
58
+ 'sb_instagram_backup',
59
+ 'sb_instagram_at',
60
+ 'sb_ajax_initial',
61
+ 'sbi_br_adjust',
62
+ 'sb_instagram_feed_width_resp',
63
+ 'enqueue_css_in_shortcode',
64
+ 'sb_instagram_disable_mob_swipe',
65
+ 'sb_instagram_disable_awesome',
66
+ 'sb_instagram_media_vine',
67
+ 'custom_template',
68
+ 'disable_admin_notice',
69
+ 'enable_email_report',
70
+ 'sb_instagram_carousel',
71
+ 'sb_instagram_carousel_arrows',
72
+ 'sb_instagram_carousel_pag',
73
+ 'sb_instagram_carousel_autoplay',
74
+ );
75
+ $custom_text_settings = array(
76
+ 'sb_instagram_btn_text',
77
+ 'sb_instagram_follow_btn_text',
78
+ 'sb_instagram_custom_bio',
79
+ 'sb_instagram_custom_avatar',
80
+ 'sb_instagram_custom_css',
81
+ 'sb_instagram_custom_js',
82
+ 'email_notification_addresses'
83
+ );
84
+ $comma_separate_counts_settings = array(
85
+ 'sb_instagram_user_id',
86
+ 'sb_instagram_tagged_ids',
87
+ 'sb_instagram_hashtag',
88
+ 'sb_instagram_highlight_ids',
89
+ 'sb_instagram_highlight_hashtag',
90
+ 'sb_instagram_hide_photos',
91
+ 'sb_instagram_exclude_words',
92
+ 'sb_instagram_include_words'
93
+ );
94
+ $defaults = class_exists( 'SB_Instagram_Settings_Pro' ) ? SB_Instagram_Settings_Pro::default_settings() : SB_Instagram_Settings::default_settings();
95
+
96
+ if ( is_array( $value ) ) {
97
+ if ( empty( $value ) ) {
98
+ return 0;
99
+ }
100
+ return count( $value );
101
+ // 0 for anything that might be false, 1 for everything else
102
+ } elseif ( in_array( $key, $normal_bools, true ) ) {
103
+ if ( in_array( $value, array( false, 0, '0', 'false', '' ), true ) ) {
104
+ return 0;
105
+ }
106
+ return 1;
107
+
108
+ // if a custom text setting, we just want to know if it's different than the default
109
+ } elseif ( in_array( $key, $custom_text_settings, true ) ) {
110
+ if ( $defaults[ $key ] === $value ) {
111
+ return 0;
112
+ }
113
+ return 1;
114
+ } elseif ( in_array( $key, $comma_separate_counts_settings, true ) ) {
115
+ if ( str_replace( ' ', '', $value ) === '' ) {
116
+ return 0;
117
+ }
118
+ $split_at_comma = explode( ',', $value );
119
+ return count( $split_at_comma );
120
+ }
121
+
122
+ return $value;
123
+
124
+ }
125
+
126
+ private function get_data() {
127
+ $data = array();
128
+
129
+ // Retrieve current theme info
130
+ $theme_data = wp_get_theme();
131
+
132
+ $count_b = 1;
133
+ if ( is_multisite() ) {
134
+ if ( function_exists( 'get_blog_count' ) ) {
135
+ $count_b = get_blog_count();
136
+ } else {
137
+ $count_b = 'Not Set';
138
+ }
139
+ }
140
+
141
+ $php_version = rtrim( ltrim( sanitize_text_field( phpversion() ) ) );
142
+ $php_version = ! empty( $php_version ) ? substr( $php_version, 0, strpos( $php_version, '.', strpos( $php_version, '.' ) + 1 ) ) : phpversion();
143
+
144
+ global $wp_version;
145
+ $data['this_plugin'] = 'if';
146
+ $data['php_version'] = $php_version;
147
+ $data['mi_version'] = SBIVER;
148
+ $data['wp_version'] = $wp_version;
149
+ $data['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '';
150
+ $data['multisite'] = is_multisite();
151
+ $data['url'] = home_url();
152
+ $data['themename'] = $theme_data->Name;
153
+ $data['themeversion'] = $theme_data->Version;
154
+ $data['settings'] = array();
155
+ $data['pro'] = (int) sbi_is_pro_version();
156
+ $data['sites'] = $count_b;
157
+ $data['usagetracking'] = get_option( 'sbi_usage_tracking_config', false );
158
+ $num_users = function_exists( 'count_users' ) ? count_users() : 'Not Set';
159
+ $data['usercount'] = is_array( $num_users ) ? $num_users['total_users'] : 1;
160
+ $data['timezoneoffset']= date('P');
161
+
162
+ $settings_to_send = array();
163
+ $raw_settings = get_option( 'sb_instagram_settings', array() );
164
+
165
+ foreach ( $raw_settings as $key => $value ) {
166
+ $value = $this->normalize_and_format( $key, $value );
167
+
168
+ if ( $value !== false ) {
169
+ $key = str_replace( array( 'sb_instagram_', 'sbi_' ), '', $key );
170
+ $settings_to_send[ $key ] = $value;
171
+ }
172
+ }
173
+ $con_bus_accounts = 0;
174
+ $recently_searched_hashtags = 0;
175
+ $access_tokens_tried = array();
176
+ if ( isset( $raw_settings['connected_accounts'] ) ) {
177
+ foreach ( $raw_settings['connected_accounts'] as $connected_account ) {
178
+ if ( isset( $connected_account['type'] ) && $connected_account['type'] === 'business') {
179
+ $con_bus_accounts++;
180
+
181
+ if ( ! in_array( $connected_account['access_token'], $access_tokens_tried, true ) && class_exists( 'SB_Instagram_API_Connect_Pro' ) ) {
182
+ $access_tokens_tried[] = $connected_account['access_token'];
183
+ $connection = new SB_Instagram_API_Connect_Pro( $connected_account, 'recently_searched_hashtags', array( 'hashtag' => '' ) );
184
+ $connection->connect();
185
+
186
+ $recently_searched_data = !$connection->is_wp_error() ? $connection->get_data() : false;
187
+ $num_hashatags_searched = $recently_searched_data && isset( $recently_searched_data ) && ! isset( $recently_searched_data['data'] ) && is_array( $recently_searched_data ) ? count( $recently_searched_data ) : 0;
188
+ $recently_searched_hashtags = $recently_searched_hashtags + $num_hashatags_searched;
189
+ }
190
+
191
+
192
+ }
193
+ }
194
+ }
195
+ $settings_to_send['business_accounts'] = $con_bus_accounts;
196
+ $settings_to_send['recently_searched_hashtags'] = $recently_searched_hashtags;
197
+
198
+ $feed_caches = SB_Instagram_Cron_Updater::get_feed_cache_option_names();
199
+ $settings_to_send['num_found_feed_caches'] = count( $feed_caches );
200
+
201
+
202
+ if ( isset( $settings_to_send['caching_type'] ) && $settings_to_send['caching_type'] !== 'background' ) {
203
+ $settings_to_send['recently_requested_caches'] = $settings_to_send['num_found_feed_caches'];
204
+ } else {
205
+ $settings_to_send['recently_requested_caches'] = 0;
206
+ foreach ( $feed_caches as $feed_cache ) {
207
+ $feed_id = str_replace( '_transient_', '', $feed_cache['option_name'] );
208
+
209
+ $transient = get_transient( $feed_id );
210
+
211
+ if ( $transient ) {
212
+ $feed_data = json_decode( $transient, true );
213
+ $last_requested = isset( $feed_data['last_requested'] ) ? (int) $feed_data['last_requested'] : false;
214
+
215
+ if ( !$last_requested || $last_requested > time() - 5 * 3600 * 24 ) {
216
+ $settings_to_send['recently_requested_caches']++;
217
+ }
218
+ }
219
+
220
+ }
221
+ }
222
+
223
+ $settings_to_send['custom_header_template'] = '' !== locate_template( 'sbi/header.php', false, false ) ? 1 : 0;
224
+ $settings_to_send['custom_header_boxed_template'] = '' !== locate_template( 'sbi/header-boxed.php', false, false ) ? 1 : 0;
225
+ $settings_to_send['custom_header_generic_template'] = '' !== locate_template( 'sbi/header-generic.php', false, false ) ? 1 : 0;
226
+ $settings_to_send['custom_item_template'] = '' !== locate_template( 'sbi/item.php', false, false ) ? 1 : 0;
227
+ $settings_to_send['custom_footer_template'] = '' !== locate_template( 'sbi/footer.php', false, false ) ? 1 : 0;
228
+ $settings_to_send['custom_feed_template'] = '' !== locate_template( 'sbi/feed.php', false, false ) ? 1 : 0;
229
+
230
+ $sbi_current_white_names = get_option( 'sb_instagram_white_list_names', array() );
231
+ if( empty( $sbi_current_white_names ) ){
232
+ $settings_to_send['num_white_lists'] = 0;
233
+ } else {
234
+ $settings_to_send['num_white_lists'] = count( $sbi_current_white_names );
235
+ }
236
+
237
+ $data['settings'] = $settings_to_send;
238
+
239
+ // Retrieve current plugin information
240
+ if( ! function_exists( 'get_plugins' ) ) {
241
+ include ABSPATH . '/wp-admin/includes/plugin.php';
242
+ }
243
+
244
+ $plugins = get_plugins();
245
+ $active_plugins = get_option( 'active_plugins', array() );
246
+ $plugins_to_send = array();
247
+
248
+ foreach ( $plugins as $plugin_path => $plugin ) {
249
+ // If the plugin isn't active, don't show it.
250
+ if ( ! in_array( $plugin_path, $active_plugins ) )
251
+ continue;
252
+
253
+ $plugins_to_send[] = $plugin['Name'];
254
+ }
255
+
256
+ $data['active_plugins'] = $plugins_to_send;
257
+ $data['locale'] = get_locale();
258
+
259
+ return $data;
260
+ }
261
+
262
+ public function send_checkin( $override = false, $ignore_last_checkin = false ) {
263
+
264
+ $home_url = trailingslashit( home_url() );
265
+ if ( strpos( $home_url, 'smashballoon.com' ) !== false ) {
266
+ return false;
267
+ }
268
+
269
+ if( ! $this->tracking_allowed() && ! $override ) {
270
+ return false;
271
+ }
272
+
273
+ // Send a maximum of once per week
274
+ $usage_tracking = get_option( 'sbi_usage_tracking', array( 'last_send' => 0, 'enabled' => sbi_is_pro_version() ) );
275
+ if ( is_numeric( $usage_tracking['last_send'] ) && $usage_tracking['last_send'] > strtotime( '-1 week' ) && ! $ignore_last_checkin ) {
276
+ return false;
277
+ }
278
+
279
+ $request = wp_remote_post( 'https://usage.smashballoon.com/v1/checkin/', array(
280
+ 'method' => 'POST',
281
+ 'timeout' => 5,
282
+ 'redirection' => 5,
283
+ 'httpversion' => '1.1',
284
+ 'blocking' => false,
285
+ 'body' => $this->get_data(),
286
+ 'user-agent' => 'MI/' . SBIVER . '; ' . get_bloginfo( 'url' )
287
+ ) );
288
+
289
+ // If we have completed successfully, recheck in 1 week
290
+ $usage_tracking['last_send'] = time();
291
+ update_option( 'sbi_usage_tracking', $usage_tracking, false );
292
+ return true;
293
+ }
294
+
295
+ private function tracking_allowed() {
296
+ $usage_tracking = sbi_get_option( 'sbi_usage_tracking', array( 'last_send' => 0, 'enabled' => sbi_is_pro_version() ) );
297
+ $tracking_allowed = isset( $usage_tracking['enabled'] ) ? $usage_tracking['enabled'] : sbi_is_pro_version();
298
+
299
+ return $tracking_allowed;
300
+ }
301
+
302
+ public function schedule_send() {
303
+ if ( ! wp_next_scheduled( 'sbi_usage_tracking_cron' ) ) {
304
+ $tracking = array();
305
+ $tracking['day'] = rand( 0, 6 );
306
+ $tracking['hour'] = rand( 0, 23 );
307
+ $tracking['minute'] = rand( 0, 59 );
308
+ $tracking['second'] = rand( 0, 59 );
309
+ $tracking['offset'] = ( $tracking['day'] * DAY_IN_SECONDS ) +
310
+ ( $tracking['hour'] * HOUR_IN_SECONDS ) +
311
+ ( $tracking['minute'] * MINUTE_IN_SECONDS ) +
312
+ $tracking['second'];
313
+ $last_sunday = strtotime("next sunday") - (7 * DAY_IN_SECONDS);
314
+ if ( ($last_sunday + $tracking['offset']) > time() + 6 * HOUR_IN_SECONDS ) {
315
+ $tracking['initsend'] = $last_sunday + $tracking['offset'];
316
+ } else {
317
+ $tracking['initsend'] = strtotime("next sunday") + $tracking['offset'];
318
+ }
319
+
320
+ wp_schedule_event( $tracking['initsend'], 'weekly', 'sbi_usage_tracking_cron' );
321
+ update_option( 'sbi_usage_tracking_config', $tracking );
322
+ }
323
+ }
324
+
325
+ public function add_schedules( $schedules = array() ) {
326
+ // Adds once weekly to the existing schedules.
327
+ $schedules['weekly'] = array(
328
+ 'interval' => 604800,
329
+ 'display' => __( 'Once Weekly', 'instagram-feed' )
330
+ );
331
+ return $schedules;
332
+ }
333
+ }
334
+ new SB_Instagram_Tracking();
inc/admin/main.php CHANGED
@@ -1,2854 +1,2887 @@
1
- <?php
2
- /**
3
- * Includes functions for all admin page templates and
4
- * functions that add menu pages in the dashboard. Also
5
- * has code for saving settings with defaults.
6
- */
7
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
8
-
9
- function sb_instagram_menu() {
10
- $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
11
-
12
- $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
13
-
14
- global $sb_instagram_posts_manager;
15
- $notice = '';
16
- if ( $sb_instagram_posts_manager->are_critical_errors() ) {
17
- $notice = ' <span class="update-plugins sbi-error-alert"><span>!</span></span>';
18
- }
19
-
20
- add_menu_page(
21
- __( 'Instagram Feed', 'instagram-feed' ),
22
- __( 'Instagram Feed', 'instagram-feed' ) . $notice,
23
- $cap,
24
- 'sb-instagram-feed',
25
- 'sb_instagram_settings_page'
26
- );
27
- add_submenu_page(
28
- 'sb-instagram-feed',
29
- __( 'Settings', 'instagram-feed' ),
30
- __( 'Settings', 'instagram-feed' ) . $notice,
31
- $cap,
32
- 'sb-instagram-feed',
33
- 'sb_instagram_settings_page'
34
- );
35
- add_submenu_page(
36
- 'sb-instagram-feed',
37
- __( 'About Us', 'instagram-feed' ),
38
- __( 'About Us', 'instagram-feed' ),
39
- $cap,
40
- 'sb-instagram-feed-about',
41
- 'sb_instagram_about_page'
42
- );
43
- }
44
- add_action('admin_menu', 'sb_instagram_menu');
45
-
46
- function sb_instagram_about_page() {
47
- do_action('sbi_admin_page' );
48
- }
49
-
50
- function sb_instagram_settings_page() {
51
-
52
- //Hidden fields
53
- $sb_instagram_settings_hidden_field = 'sb_instagram_settings_hidden_field';
54
- $sb_instagram_configure_hidden_field = 'sb_instagram_configure_hidden_field';
55
- $sb_instagram_customize_hidden_field = 'sb_instagram_customize_hidden_field';
56
-
57
- //Declare defaults
58
- $sb_instagram_settings_defaults = array(
59
- 'sb_instagram_at' => '',
60
- 'sb_instagram_user_id' => '',
61
- 'sb_instagram_preserve_settings' => '',
62
- 'sb_instagram_cache_time' => 1,
63
- 'sb_instagram_cache_time_unit' => 'hours',
64
- 'sbi_caching_type' => 'page',
65
- 'sbi_cache_cron_interval' => '12hours',
66
- 'sbi_cache_cron_time' => '1',
67
- 'sbi_cache_cron_am_pm' => 'am',
68
- 'sb_instagram_width' => '100',
69
- 'sb_instagram_width_unit' => '%',
70
- 'sb_instagram_feed_width_resp' => false,
71
- 'sb_instagram_height' => '',
72
- 'sb_instagram_num' => '20',
73
- 'sb_instagram_height_unit' => '',
74
- 'sb_instagram_cols' => '4',
75
- 'sb_instagram_disable_mobile' => false,
76
- 'sb_instagram_image_padding' => '5',
77
- 'sb_instagram_image_padding_unit' => 'px',
78
- 'sb_instagram_sort' => 'none',
79
- 'sb_instagram_background' => '',
80
- 'sb_instagram_show_btn' => true,
81
- 'sb_instagram_btn_background' => '',
82
- 'sb_instagram_btn_text_color' => '',
83
- 'sb_instagram_btn_text' => __( 'Load More...', 'instagram-feed' ),
84
- 'sb_instagram_image_res' => 'auto',
85
- //Header
86
- 'sb_instagram_show_header' => true,
87
- 'sb_instagram_header_size' => 'small',
88
- 'sb_instagram_header_color' => '',
89
- 'sb_instagram_custom_bio' => '',
90
- 'sb_instagram_custom_avatar' => '',
91
- //Follow button
92
- 'sb_instagram_show_follow_btn' => true,
93
- 'sb_instagram_folow_btn_background' => '',
94
- 'sb_instagram_follow_btn_text_color' => '',
95
- 'sb_instagram_follow_btn_text' => __( 'Follow on Instagram', 'instagram-feed' ),
96
- //Misc
97
- 'sb_instagram_custom_css' => '',
98
- 'sb_instagram_custom_js' => '',
99
- 'sb_instagram_cron' => 'no',
100
- 'sb_instagram_backup' => true,
101
- 'sb_ajax_initial' => false,
102
- 'enqueue_css_in_shortcode' => false,
103
- 'sb_instagram_ajax_theme' => false,
104
- 'sb_instagram_disable_resize' => false,
105
- 'sb_instagram_favor_local' => false,
106
- 'sb_instagram_minnum' => 0,
107
- 'disable_js_image_loading' => false,
108
- 'enqueue_js_in_head' => false,
109
- 'sb_instagram_disable_mob_swipe' => false,
110
- 'sbi_font_method' => 'svg',
111
- 'sb_instagram_disable_awesome' => false,
112
- 'custom_template' => false,
113
- 'disable_admin_notice' => false,
114
- 'enable_email_report' => 'on',
115
- 'email_notification' => 'monday',
116
- 'email_notification_addresses' => get_option( 'admin_email' ),
117
- );
118
- //Save defaults in an array
119
- $options = wp_parse_args(get_option('sb_instagram_settings'), $sb_instagram_settings_defaults);
120
- update_option( 'sb_instagram_settings', $options );
121
-
122
- //Set the page variables
123
- $sb_instagram_at = $options[ 'sb_instagram_at' ];
124
- $sb_instagram_user_id = $options[ 'sb_instagram_user_id' ];
125
- $sb_instagram_preserve_settings = $options[ 'sb_instagram_preserve_settings' ];
126
- $sb_instagram_ajax_theme = $options[ 'sb_instagram_ajax_theme' ];
127
- $enqueue_js_in_head = $options[ 'enqueue_js_in_head' ];
128
- $disable_js_image_loading = $options[ 'disable_js_image_loading' ];
129
- $sb_instagram_disable_resize = $options[ 'sb_instagram_disable_resize' ];
130
- $sb_instagram_favor_local = $options[ 'sb_instagram_favor_local' ];
131
- $sb_instagram_minnum = $options[ 'sb_instagram_minnum' ];
132
-
133
- $sb_instagram_cache_time = $options[ 'sb_instagram_cache_time' ];
134
- $sb_instagram_cache_time_unit = $options[ 'sb_instagram_cache_time_unit' ];
135
-
136
- $sbi_caching_type = $options[ 'sbi_caching_type' ];
137
- $sbi_cache_cron_interval = $options[ 'sbi_cache_cron_interval' ];
138
- $sbi_cache_cron_time = $options[ 'sbi_cache_cron_time' ];
139
- $sbi_cache_cron_am_pm = $options[ 'sbi_cache_cron_am_pm' ];
140
-
141
- $sb_instagram_width = $options[ 'sb_instagram_width' ];
142
- $sb_instagram_width_unit = $options[ 'sb_instagram_width_unit' ];
143
- $sb_instagram_feed_width_resp = $options[ 'sb_instagram_feed_width_resp' ];
144
- $sb_instagram_height = $options[ 'sb_instagram_height' ];
145
- $sb_instagram_height_unit = $options[ 'sb_instagram_height_unit' ];
146
- $sb_instagram_num = $options[ 'sb_instagram_num' ];
147
- $sb_instagram_cols = $options[ 'sb_instagram_cols' ];
148
- $sb_instagram_disable_mobile = $options[ 'sb_instagram_disable_mobile' ];
149
- $sb_instagram_image_padding = $options[ 'sb_instagram_image_padding' ];
150
- $sb_instagram_image_padding_unit = $options[ 'sb_instagram_image_padding_unit' ];
151
- $sb_instagram_sort = $options[ 'sb_instagram_sort' ];
152
- $sb_instagram_background = $options[ 'sb_instagram_background' ];
153
- $sb_instagram_show_btn = $options[ 'sb_instagram_show_btn' ];
154
- $sb_instagram_btn_background = $options[ 'sb_instagram_btn_background' ];
155
- $sb_instagram_btn_text_color = $options[ 'sb_instagram_btn_text_color' ];
156
- $sb_instagram_btn_text = $options[ 'sb_instagram_btn_text' ];
157
- $sb_instagram_image_res = $options[ 'sb_instagram_image_res' ];
158
- //Header
159
- $sb_instagram_show_header = $options[ 'sb_instagram_show_header' ];
160
- $sb_instagram_header_size = $options[ 'sb_instagram_header_size' ];
161
- $sb_instagram_show_bio = isset( $options[ 'sb_instagram_show_bio' ] ) ? $options[ 'sb_instagram_show_bio' ] : true;
162
- $sb_instagram_custom_bio = $options[ 'sb_instagram_custom_bio' ];
163
- $sb_instagram_custom_avatar = $options[ 'sb_instagram_custom_avatar' ];
164
- $sb_instagram_header_color = $options[ 'sb_instagram_header_color' ];
165
- //Follow button
166
- $sb_instagram_show_follow_btn = $options[ 'sb_instagram_show_follow_btn' ];
167
- $sb_instagram_folow_btn_background = $options[ 'sb_instagram_folow_btn_background' ];
168
- $sb_instagram_follow_btn_text_color = $options[ 'sb_instagram_follow_btn_text_color' ];
169
- $sb_instagram_follow_btn_text = $options[ 'sb_instagram_follow_btn_text' ];
170
- //Misc
171
- $sb_instagram_custom_css = $options[ 'sb_instagram_custom_css' ];
172
- $sb_instagram_custom_js = $options[ 'sb_instagram_custom_js' ];
173
- $sb_instagram_cron = $options[ 'sb_instagram_cron' ];
174
- $sb_instagram_backup = $options[ 'sb_instagram_backup' ];
175
- $sb_ajax_initial = $options[ 'sb_ajax_initial' ];
176
- $enqueue_css_in_shortcode = $options[ 'enqueue_css_in_shortcode' ];
177
- $sbi_font_method = $options[ 'sbi_font_method' ];
178
- $sb_instagram_disable_awesome = $options[ 'sb_instagram_disable_awesome' ];
179
- $sb_instagram_custom_template = $options[ 'custom_template' ];
180
- $sb_instagram_disable_admin_notice = $options[ 'disable_admin_notice' ];
181
- $sb_instagram_enable_email_report = $options[ 'enable_email_report' ];
182
- $sb_instagram_email_notification = $options[ 'email_notification' ];
183
- $sb_instagram_email_notification_addresses = $options[ 'email_notification_addresses' ];
184
- //Check nonce before saving data
185
- if ( ! isset( $_POST['sb_instagram_settings_nonce'] ) || ! wp_verify_nonce( $_POST['sb_instagram_settings_nonce'], 'sb_instagram_saving_settings' ) ) {
186
- //Nonce did not verify
187
- } else {
188
- // See if the user has posted us some information. If they did, this hidden field will be set to 'Y'.
189
- if( isset($_POST[ $sb_instagram_settings_hidden_field ]) && $_POST[ $sb_instagram_settings_hidden_field ] == 'Y' ) {
190
-
191
- if( isset($_POST[ $sb_instagram_configure_hidden_field ]) && $_POST[ $sb_instagram_configure_hidden_field ] == 'Y' ) {
192
-
193
- $sb_instagram_at = sanitize_text_field( $_POST[ 'sb_instagram_at' ] );
194
- $sb_instagram_user_id = array();
195
- if ( isset( $_POST[ 'sb_instagram_user_id' ] )) {
196
- if ( is_array( $_POST[ 'sb_instagram_user_id' ] ) ) {
197
- foreach( $_POST[ 'sb_instagram_user_id' ] as $user_id ) {
198
- $sb_instagram_user_id[] = sanitize_text_field( $user_id );
199
- }
200
- } else {
201
- $sb_instagram_user_id[] = sanitize_text_field( $_POST[ 'sb_instagram_user_id' ] );
202
- }
203
- }
204
- isset($_POST[ 'sb_instagram_preserve_settings' ]) ? $sb_instagram_preserve_settings = sanitize_text_field( $_POST[ 'sb_instagram_preserve_settings' ] ) : $sb_instagram_preserve_settings = '';
205
- isset($_POST[ 'sb_instagram_cache_time' ]) ? $sb_instagram_cache_time = sanitize_text_field( $_POST[ 'sb_instagram_cache_time' ] ) : $sb_instagram_cache_time = '';
206
- isset($_POST[ 'sb_instagram_cache_time_unit' ]) ? $sb_instagram_cache_time_unit = sanitize_text_field( $_POST[ 'sb_instagram_cache_time_unit' ] ) : $sb_instagram_cache_time_unit = '';
207
-
208
- isset($_POST[ 'sbi_caching_type' ]) ? $sbi_caching_type = sanitize_text_field( $_POST[ 'sbi_caching_type' ] ) : $sbi_caching_type = '';
209
- isset($_POST[ 'sbi_cache_cron_interval' ]) ? $sbi_cache_cron_interval = sanitize_text_field( $_POST[ 'sbi_cache_cron_interval' ] ) : $sbi_cache_cron_interval = '';
210
- isset($_POST[ 'sbi_cache_cron_time' ]) ? $sbi_cache_cron_time = sanitize_text_field( $_POST[ 'sbi_cache_cron_time' ] ) : $sbi_cache_cron_time = '';
211
- isset($_POST[ 'sbi_cache_cron_am_pm' ]) ? $sbi_cache_cron_am_pm = sanitize_text_field( $_POST[ 'sbi_cache_cron_am_pm' ] ) : $sbi_cache_cron_am_pm = '';
212
-
213
- $options[ 'sb_instagram_at' ] = $sb_instagram_at;
214
- $options[ 'sb_instagram_user_id' ] = $sb_instagram_user_id;
215
- $options[ 'sb_instagram_preserve_settings' ] = $sb_instagram_preserve_settings;
216
-
217
- $options[ 'sb_instagram_cache_time' ] = $sb_instagram_cache_time;
218
- $options[ 'sb_instagram_cache_time_unit' ] = $sb_instagram_cache_time_unit;
219
-
220
- $options[ 'sbi_caching_type' ] = $sbi_caching_type;
221
- $options[ 'sbi_cache_cron_interval' ] = $sbi_cache_cron_interval;
222
- $options[ 'sbi_cache_cron_time' ] = $sbi_cache_cron_time;
223
- $options[ 'sbi_cache_cron_am_pm' ] = $sbi_cache_cron_am_pm;
224
-
225
-
226
- //Delete all SBI transients
227
- global $wpdb;
228
- $table_name = $wpdb->prefix . "options";
229
- $wpdb->query( "
230
- DELETE
231
- FROM $table_name
232
- WHERE `option_name` LIKE ('%\_transient\_sbi\_%')
233
- " );
234
- $wpdb->query( "
235
- DELETE
236
- FROM $table_name
237
- WHERE `option_name` LIKE ('%\_transient\_timeout\_sbi\_%')
238
- " );
239
- $wpdb->query( "
240
- DELETE
241
- FROM $table_name
242
- WHERE `option_name` LIKE ('%\_transient\_&sbi\_%')
243
- " );
244
- $wpdb->query( "
245
- DELETE
246
- FROM $table_name
247
- WHERE `option_name` LIKE ('%\_transient\_timeout\_&sbi\_%')
248
- " );
249
-
250
- if ( $sbi_caching_type === 'background' ) {
251
- delete_option( 'sbi_cron_report' );
252
- SB_Instagram_Cron_Updater::start_cron_job( $sbi_cache_cron_interval, $sbi_cache_cron_time, $sbi_cache_cron_am_pm );
253
- }
254
-
255
- } //End config tab post
256
-
257
- if( isset($_POST[ $sb_instagram_customize_hidden_field ]) && $_POST[ $sb_instagram_customize_hidden_field ] == 'Y' ) {
258
-
259
- //Validate and sanitize width field
260
- $safe_width = intval( sanitize_text_field( $_POST['sb_instagram_width'] ) );
261
- if ( ! $safe_width ) $safe_width = '';
262
- if ( strlen( $safe_width ) > 4 ) $safe_width = substr( $safe_width, 0, 4 );
263
- $sb_instagram_width = $safe_width;
264
-
265
- $sb_instagram_width_unit = sanitize_text_field( $_POST[ 'sb_instagram_width_unit' ] );
266
- isset($_POST[ 'sb_instagram_feed_width_resp' ]) ? $sb_instagram_feed_width_resp = sanitize_text_field( $_POST[ 'sb_instagram_feed_width_resp' ] ) : $sb_instagram_feed_width_resp = '';
267
-
268
- //Validate and sanitize height field
269
- $safe_height = intval( sanitize_text_field( $_POST['sb_instagram_height'] ) );
270
- if ( ! $safe_height ) $safe_height = '';
271
- if ( strlen( $safe_height ) > 4 ) $safe_height = substr( $safe_height, 0, 4 );
272
- $sb_instagram_height = $safe_height;
273
-
274
- $sb_instagram_height_unit = sanitize_text_field( $_POST[ 'sb_instagram_height_unit' ] );
275
-
276
- //Validate and sanitize number of photos field
277
- $safe_num = intval( sanitize_text_field( $_POST['sb_instagram_num'] ) );
278
- if ( ! $safe_num ) $safe_num = '';
279
- if ( strlen( $safe_num ) > 4 ) $safe_num = substr( $safe_num, 0, 4 );
280
- $sb_instagram_num = $safe_num;
281
-
282
- $sb_instagram_cols = sanitize_text_field( $_POST[ 'sb_instagram_cols' ] );
283
- isset($_POST[ 'sb_instagram_disable_mobile' ]) ? $sb_instagram_disable_mobile = sanitize_text_field( $_POST[ 'sb_instagram_disable_mobile' ] ) : $sb_instagram_disable_mobile = '';
284
-
285
- //Validate and sanitize padding field
286
- $safe_padding = intval( sanitize_text_field( $_POST['sb_instagram_image_padding'] ) );
287
- if ( ! $safe_padding ) $safe_padding = '';
288
- if ( strlen( $safe_padding ) > 4 ) $safe_padding = substr( $safe_padding, 0, 4 );
289
- $sb_instagram_image_padding = $safe_padding;
290
-
291
- $sb_instagram_image_padding_unit = sanitize_text_field( $_POST[ 'sb_instagram_image_padding_unit' ] );
292
- $sb_instagram_sort = sanitize_text_field( $_POST[ 'sb_instagram_sort' ] );
293
- $sb_instagram_background = sanitize_text_field( $_POST[ 'sb_instagram_background' ] );
294
- isset($_POST[ 'sb_instagram_show_btn' ]) ? $sb_instagram_show_btn = sanitize_text_field( $_POST[ 'sb_instagram_show_btn' ] ) : $sb_instagram_show_btn = '';
295
- $sb_instagram_btn_background = sanitize_text_field( $_POST[ 'sb_instagram_btn_background' ] );
296
- $sb_instagram_btn_text_color = sanitize_text_field( $_POST[ 'sb_instagram_btn_text_color' ] );
297
- $sb_instagram_btn_text = sanitize_text_field( $_POST[ 'sb_instagram_btn_text' ] );
298
- $sb_instagram_image_res = sanitize_text_field( $_POST[ 'sb_instagram_image_res' ] );
299
- //Header
300
- isset($_POST[ 'sb_instagram_show_header' ]) ? $sb_instagram_show_header = sanitize_text_field( $_POST[ 'sb_instagram_show_header' ] ) : $sb_instagram_show_header = '';
301
- isset($_POST[ 'sb_instagram_show_bio' ]) ? $sb_instagram_show_bio = sanitize_text_field( $_POST[ 'sb_instagram_show_bio' ] ) : $sb_instagram_show_bio = '';
302
- isset($_POST[ 'sb_instagram_custom_bio' ]) ? $sb_instagram_custom_bio = sanitize_textarea_field( $_POST[ 'sb_instagram_custom_bio' ] ) : $sb_instagram_custom_bio = '';
303
- isset($_POST[ 'sb_instagram_custom_avatar' ]) ? $sb_instagram_custom_avatar = sanitize_text_field( $_POST[ 'sb_instagram_custom_avatar' ] ) : $sb_instagram_custom_avatar = '';
304
- if (isset($_POST[ 'sb_instagram_header_size' ]) ) $sb_instagram_header_size = $_POST[ 'sb_instagram_header_size' ];
305
-
306
- $sb_instagram_header_color = sanitize_text_field( $_POST[ 'sb_instagram_header_color' ] );
307
- //Follow button
308
- isset($_POST[ 'sb_instagram_show_follow_btn' ]) ? $sb_instagram_show_follow_btn = sanitize_text_field( $_POST[ 'sb_instagram_show_follow_btn' ] ) : $sb_instagram_show_follow_btn = '';
309
- $sb_instagram_folow_btn_background = sanitize_text_field( $_POST[ 'sb_instagram_folow_btn_background' ] );
310
- $sb_instagram_follow_btn_text_color = sanitize_text_field( $_POST[ 'sb_instagram_follow_btn_text_color' ] );
311
- $sb_instagram_follow_btn_text = sanitize_text_field( $_POST[ 'sb_instagram_follow_btn_text' ] );
312
- //Misc
313
- $sb_instagram_custom_css = $_POST[ 'sb_instagram_custom_css' ];
314
- $sb_instagram_custom_js = $_POST[ 'sb_instagram_custom_js' ];
315
- isset($_POST[ 'sb_instagram_ajax_theme' ]) ? $sb_instagram_ajax_theme = sanitize_text_field( $_POST[ 'sb_instagram_ajax_theme' ] ) : $sb_instagram_ajax_theme = '';
316
- isset($_POST[ 'enqueue_js_in_head' ]) ? $enqueue_js_in_head = $_POST[ 'enqueue_js_in_head' ] : $enqueue_js_in_head = '';
317
- isset($_POST[ 'disable_js_image_loading' ]) ? $disable_js_image_loading = $_POST[ 'disable_js_image_loading' ] : $disable_js_image_loading = '';
318
- isset($_POST[ 'sb_instagram_disable_resize' ]) ? $sb_instagram_disable_resize= sanitize_text_field( $_POST[ 'sb_instagram_disable_resize' ] ) : $sb_instagram_disable_resize = '';
319
- isset($_POST[ 'sb_instagram_favor_local' ]) ? $sb_instagram_favor_local = sanitize_text_field( $_POST[ 'sb_instagram_favor_local' ] ) : $sb_instagram_favor_local = '';
320
- isset($_POST[ 'sb_instagram_minnum' ]) ? $sb_instagram_minnum = sanitize_text_field( $_POST[ 'sb_instagram_minnum' ] ) : $sb_instagram_minnum = '';
321
-
322
- if (isset($_POST[ 'sb_instagram_cron' ]) ) $sb_instagram_cron = $_POST[ 'sb_instagram_cron' ];
323
- isset($_POST[ 'sb_instagram_backup' ]) ? $sb_instagram_backup = $_POST[ 'sb_instagram_backup' ] : $sb_instagram_backup = '';
324
- isset($_POST[ 'sb_ajax_initial' ]) ? $sb_ajax_initial = $_POST[ 'sb_ajax_initial' ] : $sb_ajax_initial = '';
325
- isset($_POST[ 'enqueue_css_in_shortcode' ]) ? $enqueue_css_in_shortcode = $_POST[ 'enqueue_css_in_shortcode' ] : $enqueue_css_in_shortcode = '';
326
- isset($_POST[ 'sbi_font_method' ]) ? $sbi_font_method = $_POST[ 'sbi_font_method' ] : $sbi_font_method = 'svg';
327
- isset($_POST[ 'sb_instagram_disable_awesome' ]) ? $sb_instagram_disable_awesome = sanitize_text_field( $_POST[ 'sb_instagram_disable_awesome' ] ) : $sb_instagram_disable_awesome = '';
328
-
329
- $options[ 'sb_instagram_width' ] = $sb_instagram_width;
330
- $options[ 'sb_instagram_width_unit' ] = $sb_instagram_width_unit;
331
- $options[ 'sb_instagram_feed_width_resp' ] = $sb_instagram_feed_width_resp;
332
- $options[ 'sb_instagram_height' ] = $sb_instagram_height;
333
- $options[ 'sb_instagram_height_unit' ] = $sb_instagram_height_unit;
334
- $options[ 'sb_instagram_num' ] = $sb_instagram_num;
335
- $options[ 'sb_instagram_cols' ] = $sb_instagram_cols;
336
- $options[ 'sb_instagram_disable_mobile' ] = $sb_instagram_disable_mobile;
337
- $options[ 'sb_instagram_image_padding' ] = $sb_instagram_image_padding;
338
- $options[ 'sb_instagram_image_padding_unit' ] = $sb_instagram_image_padding_unit;
339
- $options[ 'sb_instagram_sort' ] = $sb_instagram_sort;
340
- $options[ 'sb_instagram_background' ] = $sb_instagram_background;
341
- $options[ 'sb_instagram_show_btn' ] = $sb_instagram_show_btn;
342
- $options[ 'sb_instagram_btn_background' ] = $sb_instagram_btn_background;
343
- $options[ 'sb_instagram_btn_text_color' ] = $sb_instagram_btn_text_color;
344
- $options[ 'sb_instagram_btn_text' ] = $sb_instagram_btn_text;
345
- $options[ 'sb_instagram_image_res' ] = $sb_instagram_image_res;
346
- //Header
347
- $options[ 'sb_instagram_show_header' ] = $sb_instagram_show_header;
348
- $options[ 'sb_instagram_header_size' ] = $sb_instagram_header_size;
349
- $options[ 'sb_instagram_show_bio' ] = $sb_instagram_show_bio;
350
- $options[ 'sb_instagram_custom_bio' ] = $sb_instagram_custom_bio;
351
- $options[ 'sb_instagram_custom_avatar' ] = $sb_instagram_custom_avatar;
352
- $options[ 'sb_instagram_custom_bio' ] = $sb_instagram_custom_bio;
353
- $options[ 'sb_instagram_custom_avatar' ] = $sb_instagram_custom_avatar;
354
- $options[ 'sb_instagram_header_color' ] = $sb_instagram_header_color;
355
- //Follow button
356
- $options[ 'sb_instagram_show_follow_btn' ] = $sb_instagram_show_follow_btn;
357
- $options[ 'sb_instagram_folow_btn_background' ] = $sb_instagram_folow_btn_background;
358
- $options[ 'sb_instagram_follow_btn_text_color' ] = $sb_instagram_follow_btn_text_color;
359
- $options[ 'sb_instagram_follow_btn_text' ] = $sb_instagram_follow_btn_text;
360
- //Misc
361
- $options[ 'sb_instagram_custom_css' ] = $sb_instagram_custom_css;
362
- $options[ 'sb_instagram_custom_js' ] = $sb_instagram_custom_js;
363
- $options[ 'sb_instagram_ajax_theme' ] = $sb_instagram_ajax_theme;
364
- $options[ 'enqueue_js_in_head' ] = $enqueue_js_in_head;
365
- $options[ 'disable_js_image_loading' ] = $disable_js_image_loading;
366
- $options[ 'sb_instagram_disable_resize' ] = $sb_instagram_disable_resize;
367
- $options[ 'sb_instagram_favor_local' ] = $sb_instagram_favor_local;
368
- $options[ 'sb_instagram_minnum' ] = $sb_instagram_minnum;
369
-
370
- $options[ 'sb_ajax_initial' ] = $sb_ajax_initial;
371
- $options[ 'sb_instagram_cron' ] = $sb_instagram_cron;
372
- $options['sb_instagram_backup'] = $sb_instagram_backup;
373
- $options['enqueue_css_in_shortcode'] = $enqueue_css_in_shortcode;
374
-
375
- $options['sbi_font_method'] = $sbi_font_method;
376
- $options[ 'sb_instagram_disable_awesome' ] = $sb_instagram_disable_awesome;
377
-
378
- isset($_POST[ 'sb_instagram_custom_template' ]) ? $sb_instagram_custom_template = $_POST[ 'sb_instagram_custom_template' ] : $sb_instagram_custom_template = '';
379
- $options['custom_template'] = $sb_instagram_custom_template;
380
- isset($_POST[ 'sb_instagram_disable_admin_notice' ]) ? $sb_instagram_disable_admin_notice = $_POST[ 'sb_instagram_disable_admin_notice' ] : $sb_instagram_disable_admin_notice = '';
381
- $options['disable_admin_notice'] = $sb_instagram_disable_admin_notice;
382
- isset($_POST[ 'sb_instagram_enable_email_report' ]) ? $sb_instagram_enable_email_report = $_POST[ 'sb_instagram_enable_email_report' ] : $sb_instagram_enable_email_report = '';
383
- $options['enable_email_report'] = $sb_instagram_enable_email_report;
384
- isset($_POST[ 'sb_instagram_email_notification' ]) ? $sb_instagram_email_notification = $_POST[ 'sb_instagram_email_notification' ] : $sb_instagram_email_notification = '';
385
- $original = $options['email_notification'];
386
- $options['email_notification'] = $sb_instagram_email_notification;
387
- isset($_POST[ 'sb_instagram_email_notification_addresses' ]) ? $sb_instagram_email_notification_addresses = $_POST[ 'sb_instagram_email_notification_addresses' ] : $sb_instagram_email_notification_addresses = get_option( 'admin_email' );
388
- $options['email_notification_addresses'] = $sb_instagram_email_notification_addresses;
389
-
390
- if ( $original !== $sb_instagram_email_notification && $sb_instagram_enable_email_report === 'on' ){
391
- //Clear the existing cron event
392
- wp_clear_scheduled_hook('sb_instagram_feed_issue_email');
393
-
394
- $input = sanitize_text_field($_POST[ 'sb_instagram_email_notification' ] );
395
- $timestamp = strtotime( 'next ' . $input );
396
-
397
- if ( $timestamp - (3600 * 1) < time() ) {
398
- $timestamp = $timestamp + (3600 * 24 * 7);
399
- }
400
- $six_am_local = $timestamp + sbi_get_utc_offset() + (6*60*60);
401
-
402
- wp_schedule_event( $six_am_local, 'sbiweekly', 'sb_instagram_feed_issue_email' );
403
- }
404
-
405
-
406
- //Delete all SBI transients
407
- global $wpdb;
408
- $table_name = $wpdb->prefix . "options";
409
- $wpdb->query( "
410
- DELETE
411
- FROM $table_name
412
- WHERE `option_name` LIKE ('%\_transient\_sbi\_%')
413
- " );
414
- $wpdb->query( "
415
- DELETE
416
- FROM $table_name
417
- WHERE `option_name` LIKE ('%\_transient\_timeout\_sbi\_%')
418
- " );
419
- $wpdb->query( "
420
- DELETE
421
- FROM $table_name
422
- WHERE `option_name` LIKE ('%\_transient\_&sbi\_%')
423
- " );
424
- $wpdb->query( "
425
- DELETE
426
- FROM $table_name
427
- WHERE `option_name` LIKE ('%\_transient\_timeout\_&sbi\_%')
428
- " );
429
-
430
- if( $sb_instagram_cron == 'no' ) wp_clear_scheduled_hook('sb_instagram_cron_job');
431
-
432
- //Run cron when Misc settings are saved
433
- if( $sb_instagram_cron == 'yes' ){
434
- //Clear the existing cron event
435
- wp_clear_scheduled_hook('sb_instagram_cron_job');
436
-
437
- $sb_instagram_cache_time = $options[ 'sb_instagram_cache_time' ];
438
- $sb_instagram_cache_time_unit = $options[ 'sb_instagram_cache_time_unit' ];
439
-
440
- //Set the event schedule based on what the caching time is set to
441
- $sb_instagram_cron_schedule = 'hourly';
442
- if( $sb_instagram_cache_time_unit == 'hours' && $sb_instagram_cache_time > 5 ) $sb_instagram_cron_schedule = 'twicedaily';
443
- if( $sb_instagram_cache_time_unit == 'days' ) $sb_instagram_cron_schedule = 'daily';
444
-
445
- wp_schedule_event(time(), $sb_instagram_cron_schedule, 'sb_instagram_cron_job');
446
-
447
- sb_instagram_clear_page_caches();
448
- }
449
-
450
- } //End customize tab post
451
-
452
- //Save the settings to the settings array
453
- update_option( 'sb_instagram_settings', $options );
454
-
455
- ?>
456
- <div class="updated"><p><strong><?php _e( 'Settings saved.', 'instagram-feed' ); ?></strong></p></div>
457
- <?php } ?>
458
-
459
- <?php } //End nonce check ?>
460
-
461
-
462
- <div id="sbi_admin" class="wrap">
463
- <?php
464
- $lite_notice_dismissed = get_transient( 'instagram_feed_dismiss_lite' );
465
-
466
- if ( ! $lite_notice_dismissed ) :
467
- ?>
468
- <div id="sbi-notice-bar" style="display:none">
469
- <span class="sbi-notice-bar-message"><?php _e( 'You\'re using Instagram Feed Lite. To unlock more features consider <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=notices&utm_medium=litenotice" target="_blank" rel="noopener noreferrer">upgrading to Pro</a>.', 'instagram-feed'); ?></span>
470
- <button type="button" class="dismiss" title="<?php _e( 'Dismiss this message.', 'instagram-feed'); ?>" data-page="overview">
471
- </button>
472
- </div>
473
- <?php endif; ?>
474
- <div id="header">
475
- <h1><?php _e( 'Instagram Feed', 'instagram-feed' ); ?></h1>
476
- </div>
477
- <?php
478
- $sb_instagram_type = 'user';
479
- $returned_data = sbi_get_connected_accounts_data( $sb_instagram_at );
480
- $sb_instagram_at = $returned_data['access_token'];
481
- $connected_accounts = $returned_data['connected_accounts'];
482
- $user_feeds_returned = isset( $returned_data['user_ids'] ) ? $returned_data['user_ids'] : false;
483
- if ( $user_feeds_returned ) {
484
- $user_feed_ids = $user_feeds_returned;
485
- } else {
486
- $user_feed_ids = ! is_array( $sb_instagram_user_id ) ? explode( ',', $sb_instagram_user_id ) : $sb_instagram_user_id;
487
- }
488
-
489
- $new_user_name = false;
490
-
491
-
492
-
493
-
494
- if( isset($_GET['access_token']) && isset($_GET['graph_api']) && empty($_POST) ) { ?>
495
- <?php
496
- $access_token = sbi_maybe_clean(urldecode($_GET['access_token']));
497
- //
498
- $url = 'https://graph.facebook.com/me/accounts?fields=instagram_business_account,access_token&limit=500&access_token='.$access_token;
499
- $args = array(
500
- 'timeout' => 60,
501
- 'sslverify' => false
502
- );
503
- $result = wp_remote_get( $url, $args );
504
- $pages_data = '{}';
505
- if ( ! is_wp_error( $result ) ) {
506
- $pages_data = $result['body'];
507
- } else {
508
- $page_error = $result;
509
- }
510
-
511
- $pages_data_arr = json_decode($pages_data);
512
- $num_accounts = 0;
513
- if(isset($pages_data_arr)){
514
- $num_accounts = is_array( $pages_data_arr->data ) ? count( $pages_data_arr->data ) : 0;
515
- }
516
- ?>
517
- <div id="sbi_config_info" class="sb_list_businesses sbi_num_businesses_<?php echo $num_accounts; ?>">
518
- <div class="sbi_config_modal">
519
- <div class="sbi-managed-pages">
520
- <?php if ( isset( $page_error ) && isset( $page_error->errors ) ) {
521
- foreach ($page_error->errors as $key => $item) {
522
- echo '<div class="sbi_user_id_error" style="display:block;"><strong>Connection Error: </strong>' . $key . ': ' . $item[0] . '</div>';
523
- }
524
- }
525
- ?>
526
- <?php if( empty($pages_data_arr->data) ) : ?>
527
- <span id="sbi-bus-account-error">
528
- <p style="margin-top: 5px;"><b style="font-size: 16px">Couldn't find Business Profile</b><br />
529
- Uh oh. It looks like this Facebook account is not currently connected to an Instagram Business profile. Please check that you are logged into the <a href="https://www.facebook.com/" target="_blank">Facebook account</a> in this browser which is associated with your Instagram Business Profile.</p>
530
- <p><b style="font-size: 16px">Why do I need a Business Profile?</b><br />
531
- A Business Profile is only required if you are displaying a Hashtag feed. If you want to display a regular User feed then you can do this by selecting to connect a Personal account instead. For directions on how to convert your Personal profile into a Business profile please <a href="https://smashballoon.com/instagram-business-profiles" target="_blank">see here</a>.</p>
532
- </span>
533
-
534
- <?php elseif ( $num_accounts === 0 ): ?>
535
- <span id="sbi-bus-account-error">
536
- <p style="margin-top: 5px;"><b style="font-size: 16px">Couldn't find Business Profile</b><br />
537
- Uh oh. It looks like this Facebook account is not currently connected to an Instagram Business profile. Please check that you are logged into the <a href="https://www.facebook.com/" target="_blank">Facebook account</a> in this browser which is associated with your Instagram Business Profile.</p>
538
- <p>If you are, in fact, logged-in to the correct account please make sure you have Instagram accounts connected with your Facebook account by following <a href="https://smashballoon.com/reconnecting-an-instagram-business-profile/" target="_blank">this FAQ</a></p>
539
- </span>
540
- <?php else: ?>
541
- <p class="sbi-managed-page-intro"><b style="font-size: 16px;">Instagram Business profiles for this account</b><br /><i style="color: #666;">Note: In order to display a Hashtag feed you first need to select a Business profile below.</i></p>
542
- <?php if ( $num_accounts > 1 ) : ?>
543
- <div class="sbi-managed-page-select-all"><input type="checkbox" id="sbi-select-all" class="sbi-select-all"><label for="sbi-select-all">Select All</label></div>
544
- <?php endif; ?>
545
- <div class="sbi-scrollable-accounts">
546
-
547
- <?php foreach ( $pages_data_arr->data as $page => $page_data ) : ?>
548
-
549
- <?php if( isset( $page_data->instagram_business_account ) ) :
550
-
551
- $instagram_business_id = $page_data->instagram_business_account->id;
552
-
553
- $page_access_token = isset( $page_data->access_token ) ? $page_data->access_token : '';
554
-
555
- //Make another request to get page info
556
- $instagram_account_url = 'https://graph.facebook.com/'.$instagram_business_id.'?fields=name,username,profile_picture_url&access_token='.$access_token;
557
-
558
- $args = array(
559
- 'timeout' => 60,
560
- 'sslverify' => false
561
- );
562
- $result = wp_remote_get( $instagram_account_url, $args );
563
- $instagram_account_info = '{}';
564
- if ( ! is_wp_error( $result ) ) {
565
- $instagram_account_info = $result['body'];
566
- } else {
567
- $page_error = $result;
568
- }
569
-
570
- $instagram_account_data = json_decode($instagram_account_info);
571
-
572
- $instagram_biz_img = isset( $instagram_account_data->profile_picture_url ) ? $instagram_account_data->profile_picture_url : false;
573
- $selected_class = $instagram_business_id == $sb_instagram_user_id ? ' sbi-page-selected' : '';
574
-
575
- ?>
576
- <?php if ( isset( $page_error ) && isset( $page_error->errors ) ) :
577
- foreach ($page_error->errors as $key => $item) {
578
- echo '<div class="sbi_user_id_error" style="display:block;"><strong>Connection Error: </strong>' . $key . ': ' . $item[0] . '</div>';
579
- }
580
- else : ?>
581
- <div class="sbi-managed-page<?php echo $selected_class; ?>" data-page-token="<?php echo esc_attr( $page_access_token ); ?>" data-token="<?php echo esc_attr( $access_token ); ?>" data-page-id="<?php echo esc_attr( $instagram_business_id ); ?>">
582
- <div class="sbi-add-checkbox">
583
- <input id="sbi-<?php echo esc_attr( $instagram_business_id ); ?>" type="checkbox" name="sbi_managed_pages[]" value="<?php echo esc_attr( $instagram_account_info ); ?>">
584
- </div>
585
- <div class="sbi-managed-page-details">
586
- <label for="sbi-<?php echo esc_attr( $instagram_business_id ); ?>"><img class="sbi-page-avatar" border="0" height="50" width="50" src="<?php echo esc_url( $instagram_biz_img ); ?>"><b style="font-size: 16px;"><?php echo esc_html( $instagram_account_data->name ); ?></b>
587
- <br />@<?php echo esc_html( $instagram_account_data->username); ?><span style="font-size: 11px; margin-left: 5px;">(<?php echo esc_html( $instagram_business_id ); ?>)</span></label>
588
- </div>
589
- </div>
590
- <?php endif; ?>
591
-
592
- <?php endif; ?>
593
-
594
- <?php endforeach; ?>
595
-
596
- </div> <!-- end scrollable -->
597
- <a href="JavaScript:void(0);" id="sbi-connect-business-accounts" class="button button-primary" disabled="disabled" style="margin-top: 20px;">Connect Accounts</a>
598
-
599
- <?php endif; ?>
600
-
601
- <a href="JavaScript:void(0);" class="sbi_modal_close"><i class="fa fa-times"></i></a>
602
- </div>
603
- </div>
604
- </div>
605
- <?php } elseif ( isset( $_GET['access_token'] ) && isset( $_GET['account_type'] ) && empty( $_POST ) ) {
606
- $access_token = sanitize_text_field( $_GET['access_token'] );
607
- $account_type = sanitize_text_field( $_GET['account_type'] );
608
- $user_id = sanitize_text_field( $_GET['id'] );
609
- $user_name = sanitize_text_field( $_GET['username'] );
610
- $expires_in = (int)$_GET['expires_in'];
611
- $expires_timestamp = time() + $expires_in;
612
-
613
- $new_account_details = array(
614
- 'access_token' => $access_token,
615
- 'account_type' => $account_type,
616
- 'user_id' => $user_id,
617
- 'username' => $user_name,
618
- 'expires_timestamp' => $expires_timestamp,
619
- 'type' => 'basic'
620
- );
621
-
622
-
623
- $matches_existing_personal = sbi_matches_existing_personal( $new_account_details );
624
- $button_text = $matches_existing_personal ? __( 'Update This Account', 'instagram-feed' ) : __( 'Connect This Account', 'instagram-feed' );
625
-
626
- $account_json = wp_json_encode( $new_account_details );
627
-
628
- $already_connected_as_business_account = (isset( $connected_accounts[ $user_id ] ) && $connected_accounts[ $user_id ]['type'] === 'business');
629
-
630
- ?>
631
-
632
- <div id="sbi_config_info" class="sb_get_token">
633
- <div class="sbi_config_modal">
634
- <div class="sbi_ca_username"><strong><?php echo esc_html( $user_name ); ?></strong></div>
635
- <form action="<?php echo admin_url( 'admin.php?page=sb-instagram-feed' ); ?>" method="post">
636
- <p class="sbi_submit">
637
- <?php if ( $already_connected_as_business_account ) :
638
- _e( 'The Instagram account you are logged into is already connected as a "business" account. Remove the business account if you\'d like to connect as a basic account instead (not recommended).', 'instagram-feed' );
639
- ?>
640
- <?php else : ?>
641
- <input type="submit" name="sbi_submit" id="sbi_connect_account" class="button button-primary" value="<?php echo esc_html( $button_text ); ?>">
642
- <?php endif; ?>
643
- <input type="hidden" name="sbi_account_json" value="<?php echo esc_attr( $account_json ) ; ?>">
644
- <input type="hidden" name="sbi_connect_username" value="<?php echo esc_attr( $user_name ); ?>">
645
- <a href="JavaScript:void(0);" class="button button-secondary" id="sbi_switch_accounts"><?php esc_html_e( 'Switch Accounts', 'instagram-feed' ); ?></a>
646
- </p>
647
- </form>
648
- <a href="JavaScript:void(0);"><i class="sbi_modal_close fa fa-times"></i></a>
649
- </div>
650
- </div>
651
- <?php
652
- } elseif ( isset( $_POST['sbi_connect_username'] ) ) {
653
-
654
- $new_user_name = sanitize_text_field( $_POST['sbi_connect_username'] );
655
- $new_account_details = json_decode( stripslashes( $_POST['sbi_account_json'] ), true );
656
- array_map( 'sanitize_text_field', $new_account_details );
657
-
658
- $updated_options = sbi_connect_basic_account( $new_account_details );
659
- $connected_accounts = $updated_options['connected_accounts'];
660
- $user_feed_ids = $updated_options['sb_instagram_user_id'];
661
- }?>
662
-
663
- <?php //Display connected page
664
- if (isset( $sbi_connected_page ) && strpos($sbi_connected_page, ':') !== false) {
665
-
666
- $sbi_connected_page_pieces = explode(":", $sbi_connected_page);
667
- $sbi_connected_page_id = $sbi_connected_page_pieces[0];
668
- $sbi_connected_page_name = $sbi_connected_page_pieces[1];
669
- $sbi_connected_page_image = $sbi_connected_page_pieces[2];
670
-
671
- echo '&nbsp;';
672
- echo '<p style="font-weight: bold; margin-bottom: 5px;">Connected Business Profile:</p>';
673
- echo '<div class="sbi-managed-page sbi-no-select">';
674
- echo '<p><img class="sbi-page-avatar" border="0" height="50" width="50" src="'.$sbi_connected_page_image.'"><b>'.$sbi_connected_page_name.'</b> &nbsp; ('.$sbi_connected_page_id.')</p>';
675
- echo '</div>';
676
- }
677
-
678
- ?>
679
-
680
- <form name="form1" method="post" action="">
681
- <input type="hidden" name="<?php echo $sb_instagram_settings_hidden_field; ?>" value="Y">
682
- <?php wp_nonce_field( 'sb_instagram_saving_settings', 'sb_instagram_settings_nonce' ); ?>
683
-
684
- <?php $sbi_active_tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field( $_GET['tab'] ) : 'configure'; ?>
685
- <h2 class="nav-tab-wrapper">
686
- <a href="?page=sb-instagram-feed&amp;tab=configure" class="nav-tab <?php echo $sbi_active_tab == 'configure' ? 'nav-tab-active' : ''; ?>"><?php _e( '1. Configure', 'instagram-feed' ); ?></a>
687
- <a href="?page=sb-instagram-feed&amp;tab=customize" class="nav-tab <?php echo $sbi_active_tab == 'customize' ? 'nav-tab-active' : ''; ?>"><?php _e( '2. Customize', 'instagram-feed' ); ?></a>
688
- <a href="?page=sb-instagram-feed&amp;tab=display" class="nav-tab <?php echo $sbi_active_tab == 'display' ? 'nav-tab-active' : ''; ?>"><?php _e( '3. Display Your Feed', 'instagram-feed' ); ?></a>
689
- <a href="?page=sb-instagram-feed&amp;tab=support" class="nav-tab <?php echo $sbi_active_tab == 'support' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Support', 'instagram-feed' ); ?></a>
690
- </h2>
691
-
692
- <?php if( $sbi_active_tab == 'configure' ) { //Start Configure tab ?>
693
- <input type="hidden" name="<?php echo $sb_instagram_configure_hidden_field; ?>" value="Y">
694
-
695
- <table class="form-table">
696
- <tbody>
697
- <h3><?php _e( 'Configure', 'instagram-feed' ); ?></h3>
698
-
699
- <div id="sbi_config">
700
- <a data-personal-basic-api="https://api.instagram.com/oauth/authorize?app_id=423965861585747&redirect_uri=https://api.smashballoon.com/instagram-basic-display-redirect.php&response_type=code&scope=user_profile,user_media&state=<?php echo admin_url('admin.php?page=sb-instagram-feed'); ?>"
701
- data-new-api="https://www.facebook.com/dialog/oauth?client_id=254638078422287&redirect_uri=https://api.smashballoon.com/instagram-graph-api-redirect.php&scope=manage_pages,instagram_basic,instagram_manage_insights,instagram_manage_comments&state=<?php echo admin_url('admin.php?page=sb-instagram-feed'); ?>"
702
- data-old-api="https://instagram.com/oauth/authorize/?client_id=3a81a9fa2a064751b8c31385b91cc25c&scope=basic&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'); ?>&hl=en"
703
- href="https://instagram.com/oauth/authorize/?client_id=3a81a9fa2a064751b8c31385b91cc25c&scope=basic&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'); ?>&hl=en" class="sbi_admin_btn"><i class="fa fa-user-plus" aria-hidden="true" style="font-size: 20px;"></i>&nbsp; <?php _e('Connect an Instagram Account', 'instagram-feed' ); ?></a>
704
-
705
- <!--<a href="https://instagram.com/oauth/authorize/?client_id=3a81a9fa2a064751b8c31385b91cc25c&scope=basic&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>&nbsp; <?php _e('Connect an Instagram Account', 'instagram-feed' ); ?></a>
706
- -->
707
- <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>
708
- </div>
709
-
710
- <!-- Old Access Token -->
711
- <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" />
712
-
713
- <tr valign="top">
714
- <th scope="row"><label><?php _e( 'Instagram Accounts', 'instagram-feed' ); ?></label><span style="font-weight:normal; font-style:italic; font-size: 12px; display: block;"><?php _e('Use the button above to connect an Instagram account', 'instagram-feed'); ?></span></th>
715
- <td class="sbi_connected_accounts_wrap">
716
- <?php if ( empty( $connected_accounts ) ) : ?>
717
- <p class="sbi_no_accounts"><?php _e( 'No Instagram accounts connected. Click the button above to connect an account.', 'instagram-feed' ); ?></p><br />
718
- <?php else:
719
- if ( sbi_is_after_deprecation_deadline() ) {
720
- $deprecated_connected_account_message = __( '<b>Action Needed:</b> Reconnect this account to allow feed to update.', 'instagram-feed' );
721
- } else {
722
- $deprecated_connected_account_message = __( '<b>Action Needed:</b> Reconnect this account before March 31, 2020 to avoid disruption with this feed.', 'instagram-feed' );
723
- }
724
-
725
- $accounts_that_need_updating = sbi_get_user_names_of_personal_accounts_not_also_already_updated();
726
- ?>
727
- <?php foreach ( $connected_accounts as $account ) :
728
- $username = $account['username'] ? $account['username'] : $account['user_id'];
729
- if ( isset( $account['local_avatar'] ) && $account['local_avatar'] && isset( $options['sb_instagram_favor_local'] ) && $options['sb_instagram_favor_local' ] === 'on' ) {
730
- $upload = wp_upload_dir();
731
- $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBI_UPLOADS_NAME );
732
- $profile_picture = '<img class="sbi_ca_avatar" src="'.$resized_url . $account['username'].'.jpg" />'; //Could add placeholder avatar image
733
- } else {
734
- $profile_picture = $account['profile_picture'] ? '<img class="sbi_ca_avatar" src="'.$account['profile_picture'].'" />' : ''; //Could add placeholder avatar image
735
- }
736
-
737
- $is_invalid_class = ! $account['is_valid'] ? ' sbi_account_invalid' : '';
738
- $in_user_feed = in_array( $account['user_id'], $user_feed_ids, true );
739
- $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
740
- $use_tagged = isset( $account['use_tagged'] ) && $account['use_tagged'] == '1';
741
-
742
- if ( empty( $profile_picture ) && $account_type === 'personal' ) {
743
- $account_update = sbi_account_data_for_token( $account['access_token'] );
744
- if ( isset( $account['is_valid'] ) ) {
745
- $split = explode( '.', $account['access_token'] );
746
- $connected_accounts[ $split[0] ] = array(
747
- 'access_token' => $account['access_token'],
748
- 'user_id' => $split[0],
749
- 'username' => $account_update['username'],
750
- 'is_valid' => true,
751
- 'last_checked' => time(),
752
- 'profile_picture' => $account_update['profile_picture']
753
- );
754
-
755
- $sbi_options = get_option( 'sb_instagram_settings', array() );
756
- $sbi_options['connected_accounts'] = $connected_accounts;
757
- update_option( 'sb_instagram_settings', $sbi_options );
758
- }
759
-
760
- }
761
- $updated_or_new_account_class = $new_user_name === $username && $account_type !== 'business' ? ' sbi_ca_new_or_updated' : '';
762
-
763
- ?>
764
- <div class="sbi_connected_account<?php echo $is_invalid_class . $updated_or_new_account_class; ?><?php if ( $in_user_feed ) echo ' sbi_account_active' ?> sbi_account_type_<?php echo $account_type; ?>" 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'] ); ?>" data-type="<?php esc_attr_e( $account_type ); ?>" data-permissions="<?php if ( $use_tagged ) echo 'tagged'; ?>">
765
- <?php if ( $account_type === 'personal' && in_array( $username, $accounts_that_need_updating, true ) ) : ?>
766
- <div class="sbi_deprecated">
767
- <span><i class="fa fa-exclamation-circle" aria-hidden="true"></i><?php echo $deprecated_connected_account_message; ?> <button class="sbi_reconnect button-primary">Reconnect</button></span>
768
- </div>
769
- <?php endif; ?>
770
- <div class="sbi_ca_alert">
771
- <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>
772
- </div>
773
- <div class="sbi_ca_info">
774
-
775
- <div class="sbi_ca_delete">
776
- <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>
777
- </div>
778
-
779
- <div class="sbi_ca_username">
780
- <?php echo $profile_picture; ?>
781
- <strong><?php echo $username; ?><span><?php echo sbi_account_type_display( $account_type ); ?></span></strong>
782
- </div>
783
-
784
- <div class="sbi_ca_actions">
785
- <?php if ( ! $in_user_feed ) : ?>
786
- <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>
787
- <?php else : ?>
788
- <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>
789
- <?php endif; ?>
790
- <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>
791
- <a class="sbi_ca_show_token button-secondary" href="JavaScript:void(0);" title="<?php _e('Show access token and account info', 'instagram-feed'); ?>"><i class="fa fa-cog"></i></a>
792
-
793
- </div>
794
-
795
- <div class="sbi_ca_shortcode">
796
-
797
- <p><?php _e('Copy and paste this shortcode into your page or widget area', 'instagram-feed'); ?>:<br>
798
- <?php if ( !empty( $account['username'] ) ) : ?>
799
- <code>[instagram-feed user="<?php echo $account['username']; ?>"]</code>
800
- <?php else : ?>
801
- <code>[instagram-feed accesstoken="<?php echo $account['access_token']; ?>"]</code>
802
- <?php endif; ?>
803
- </p>
804
-
805
- <p><?php _e('To add multiple users in the same feed, simply separate them using commas', 'instagram-feed'); ?>:<br>
806
- <?php if ( !empty( $account['username'] ) ) : ?>
807
- <code>[instagram-feed user="<?php echo $account['username']; ?>, a_second_user, a_third_user"]</code>
808
- <?php else : ?>
809
- <code>[instagram-feed accesstoken="<?php echo $account['access_token']; ?>, another_access_token"]</code>
810
- <?php endif; ?>
811
-
812
- <p><?php echo sprintf( __('Click on the %s tab to learn more about shortcodes', 'instagram-feed'), '<a href="?page=sb-instagram-feed&tab=display" target="_blank">'. __( 'Display Your Feed', 'instagram-feed' ) . '</a>' ); ?></p>
813
- </div>
814
-
815
- <div class="sbi_ca_accesstoken">
816
- <span class="sbi_ca_token_label"><?php _e('Access Token', 'instagram-feed');?>:</span><input type="text" class="sbi_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).', 'instagram-feed');?>"><br>
817
- <span class="sbi_ca_token_label"><?php _e('User ID', 'instagram-feed');?>:</span><input type="text" class="sbi_ca_user_id" value="<?php echo $account['user_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).', 'instagram-feed');?>"><br>
818
- </div>
819
-
820
- </div>
821
-
822
- </div>
823
-
824
- <?php endforeach; ?>
825
- <?php endif; ?>
826
- <a href="JavaScript:void(0);" class="sbi_manually_connect button-secondary"><?php _e( 'Manually Connect an Account', 'instagram-feed' ); ?></a>
827
- <div class="sbi_manually_connect_wrap">
828
- <input name="sb_manual_at" id="sb_manual_at" type="text" value="" style="margin-top: 4px; padding: 5px 9px; margin-left: 0px;" size="64" minlength="15" maxlength="200" placeholder="Enter a valid Instagram Access Token" /><span class='sbi_business_profile_tag'><?php _e('Business or Basic Display', 'instagram-feed');?></span>
829
- <div class="sbi_manual_account_id_toggle">
830
- <label><?php _e('Please enter the User ID for this Profile:', 'instagram-feed');?></label>
831
- <input name="sb_manual_account_id" id="sb_manual_account_id" type="text" value="" style="margin-top: 4px; padding: 5px 9px; margin-left: 0px;" size="40" minlength="5" maxlength="100" placeholder="Eg: 15641403491391489" />
832
- </div>
833
- <p class="sbi_submit" style="display: inline-block;"><input type="sbi_submit" name="submit" id="sbi_manual_submit" class="button button-primary" style="text-align: center; padding: 0;" value="<?php _e('Connect This Account', 'instagram-feed' );?>"></p>
834
- </div>
835
- </td>
836
- </tr>
837
-
838
- <tr valign="top" class="sbi_feed_type">
839
- <th scope="row"><label><?php _e('Show Photos From:', 'instagram-feed'); ?></label><code class="sbi_shortcode"> type
840
- Eg: type=user id=12986477
841
- </code></th>
842
- <td>
843
- <div class="sbi_row">
844
- <div class="sbi_col sbi_one">
845
- <input type="radio" name="sb_instagram_type" id="sb_instagram_type_user" value="user" <?php if($sb_instagram_type == "user") echo "checked"; ?> />
846
- <label class="sbi_radio_label" for="sb_instagram_type_user"><?php _e( 'User Account:', 'instagram-feed' ); ?></label>
847
- </div>
848
- <div class="sbi_col sbi_two">
849
- <div class="sbi_user_feed_ids_wrap">
850
- <?php foreach ( $user_feed_ids as $feed_id ) : if ( $feed_id !== '' ) :?>
851
- <?php if( count($connected_accounts) > 0 ) { ?><div id="sbi_user_feed_id_<?php echo $feed_id; ?>" class="sbi_user_feed_account_wrap"><?php } ?>
852
-
853
- <?php if ( isset( $connected_accounts[ $feed_id ] ) && ! empty( $connected_accounts[ $feed_id ]['username'] ) ) : ?>
854
- <strong><?php echo $connected_accounts[ $feed_id ]['username']; ?></strong> <span>(<?php echo $feed_id; ?>)</span>
855
- <input name="sb_instagram_user_id[]" id="sb_instagram_user_id" type="hidden" value="<?php echo esc_attr( $feed_id ); ?>" />
856
- <?php elseif ( isset( $connected_accounts[ $feed_id ] ) && ! empty( $connected_accounts[ $feed_id ]['access_token'] ) ) : ?>
857
- <strong><?php echo $feed_id; ?></strong>
858
- <input name="sb_instagram_user_id[]" id="sb_instagram_user_id" type="hidden" value="<?php echo esc_attr( $feed_id ); ?>" />
859
- <?php endif; ?>
860
-
861
- <?php if( count($connected_accounts) > 0 ) { ?></div><?php } ?>
862
- <?php endif; endforeach; ?>
863
- </div>
864
-
865
- <?php if ( empty( $user_feed_ids ) ) : ?>
866
- <p class="sbi_no_accounts" style="margin-top: -3px; margin-right: 10px;"><?php _e( 'Connect a user account above', 'instagram-feed' ); ?></p>
867
- <?php endif; ?>
868
-
869
- <a class="sbi_tooltip_link" href="JavaScript:void(0);" style="margin: 5px 0 10px 0; display: inline-block; height: 19px;"><?php _e("How to display User feeds", 'instagram-feed' ); ?></a>
870
- <div class="sbi_tooltip"><?php _e("<p><b>Displaying Posts from Your User Account</b><br />Simply 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 />
871
- </div>
872
-
873
- </div>
874
-
875
- <div class="sbi_pro sbi_row">
876
- <div class="sbi_col sbi_one">
877
- <input disabled type="radio" name="sb_instagram_type" id="sb_instagram_type_hashtag" value="hashtag" <?php if($sb_instagram_type == "hashtag") echo "checked"; ?> />
878
- <label class="sbi_radio_label" for="sb_instagram_type_hashtag"><?php _e( 'Hashtag:', 'instagram-feed' ); ?></label>
879
- </div>
880
- <div class="sbi_col sbi_two">
881
-
882
- <p class="sbi_pro_tooltip"><?php _e( 'Upgrade to the Pro version to display Hashtag and Tagged feeds', 'instagram-feed' ); ?><i class="fa fa-caret-down" aria-hidden="true"></i></p>
883
- <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=hashtags" target="_blank" class="sbi_lock"><i class="fa fa-rocket"></i><?php _e('Pro', 'instagram-feed'); ?></a>
884
-
885
- <input readonly type="text" size="25" style="height: 32px; top: -2px; position: relative; box-shadow: none;" disabled />
886
- &nbsp;<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed' ); ?></a>
887
-
888
- <p class="sbi_tooltip"><?php _e( 'Display posts from a specific hashtag instead of from a user', 'instagram-feed' ); ?></p>
889
- </div>
890
- </div>
891
-
892
- <div class="sbi_pro sbi_row">
893
- <div class="sbi_col sbi_one">
894
- <input disabled type="radio" name="sb_instagram_type" id="sb_instagram_type_tagged" value="tagged" <?php if($sb_instagram_type == "tagged") echo "checked"; ?> />
895
- <label class="sbi_radio_label" for="sb_instagram_type_tagged"><?php _e( 'Tagged:', 'instagram-feed' ); ?></label>
896
- </div>
897
- <div class="sbi_col sbi_two">
898
- <input readonly type="text" size="25" style="height: 32px; top: -2px; position: relative; box-shadow: none;" disabled />
899
- &nbsp;<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed' ); ?></a>
900
-
901
- <p class="sbi_tooltip"><?php _e( 'Display posts that your account has been tagged in.', 'instagram-feed' ); ?></p>
902
- </div>
903
- </div>
904
-
905
- <div class="sbi_row sbi_pro">
906
- <br>
907
- <a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);" style="margin-left: 0;"><i class="fa fa-question-circle" aria-hidden="true" style="margin-right: 6px;"></i><?php _e('Combine multiple feed types into a single feed', 'instagram-feed'); ?></a>
908
- <p class="sbi_tooltip">
909
- <b><?php _e( 'Please note: this is only available in the <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=multipletypes" target="_blank">Pro version</a>', 'instagram-feed' ); ?>.</b><br />
910
- <?php echo sprintf( __('To display multiple feed types in a single feed, use %s in your shortcode and then add each user name or hashtag of each feed into the shortcode, like so: %s. This will combine a user feed and a hashtag feed into the same feed.', 'instagram-feed'), 'type="mixed"', '<code>[instagram-feed type="mixed" user="smashballoon" hashtag="#awesomeplugins"]</code>' ); ?>
911
- </p>
912
- </div>
913
-
914
- </td>
915
- </tr>
916
-
917
- <tr>
918
- <th class="bump-left"><label for="sb_instagram_preserve_settings" class="bump-left"><?php _e("Preserve settings when plugin is removed", 'instagram-feed'); ?></label></th>
919
- <td>
920
- <input name="sb_instagram_preserve_settings" type="checkbox" id="sb_instagram_preserve_settings" <?php if($sb_instagram_preserve_settings == true) echo "checked"; ?> />
921
- <label for="sb_instagram_preserve_settings"><?php _e('Yes', 'instagram-feed'); ?></label>
922
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
923
- <p class="sbi_tooltip"><?php _e('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.', 'instagram-feed'); ?></p>
924
- </td>
925
- </tr>
926
-
927
-
928
- <tr valign="top" class="sbi_cron_cache_opts">
929
- <th scope="row"><?php _e( 'Check for new posts', 'instagram-feed' ); ?></th>
930
- <td>
931
-
932
- <div class="sbi_row">
933
- <input type="radio" name="sbi_caching_type" id="sbi_caching_type_page" value="page" <?php if ( $sbi_caching_type === 'page' ) echo 'checked'; ?>>
934
- <label for="sbi_caching_type_page"><?php _e( 'When the page loads', 'instagram-feed' ); ?></label>
935
- <a class="sbi_tooltip_link" href="JavaScript:void(0);" style="position: relative; top: 2px;"><i class="fa fa-question-circle" aria-hidden="true"></i></a>
936
- <p class="sbi_tooltip sbi-more-info"><?php _e( 'Your Instagram post 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', 'instagram-feed' ); ?>:<br><br>
937
- <?php _e( '<b>1. When the page loads</b><br>Selecting this option means that when the cache expires then the plugin will check Facebook for new posts the next time that the feed is loaded. You can choose how long this data should be cached for. 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.', 'instagram-feed' ); ?>
938
- <br><br>
939
- <?php _e( '<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.</p>', 'instagram-feed' ); ?>
940
- </div>
941
- <div class="sbi_row sbi-caching-page-options" style="display: none;">
942
- <?php _e( 'Every', 'instagram-feed' ); ?>:
943
- <input name="sb_instagram_cache_time" type="text" value="<?php echo esc_attr( $sb_instagram_cache_time ); ?>" size="4" />
944
- <select name="sb_instagram_cache_time_unit">
945
- <option value="minutes" <?php if($sb_instagram_cache_time_unit == "minutes") echo 'selected="selected"' ?> ><?php _e('Minutes', 'instagram-feed'); ?></option>
946
- <option value="hours" <?php if($sb_instagram_cache_time_unit == "hours") echo 'selected="selected"' ?> ><?php _e('Hours', 'instagram-feed'); ?></option>
947
- <option value="days" <?php if($sb_instagram_cache_time_unit == "days") echo 'selected="selected"' ?> ><?php _e('Days', 'instagram-feed'); ?></option>
948
- </select>
949
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
950
- <p class="sbi_tooltip"><?php _e('Your Instagram 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 Instagram for posts again.', 'instagram-feed'); ?></p>
951
- </div>
952
-
953
- <div class="sbi_row">
954
- <input type="radio" name="sbi_caching_type" id="sbi_caching_type_cron" value="background" <?php if ( $sbi_caching_type === 'background' ) echo 'checked'; ?>>
955
- <label for="sbi_caching_type_cron"><?php _e( 'In the background', 'instagram-feed' ); ?></label>
956
- </div>
957
- <div class="sbi_row sbi-caching-cron-options" style="display: block;">
958
-
959
- <select name="sbi_cache_cron_interval" id="sbi_cache_cron_interval">
960
- <option value="30mins" <?php if ( $sbi_cache_cron_interval === '30mins' ) echo 'selected'; ?>><?php _e( 'Every 30 minutes', 'instagram-feed' ); ?></option>
961
- <option value="1hour" <?php if ( $sbi_cache_cron_interval === '1hour' ) echo 'selected'; ?>><?php _e( 'Every hour', 'instagram-feed' ); ?></option>
962
- <option value="12hours" <?php if ( $sbi_cache_cron_interval === '12hours' ) echo 'selected'; ?>><?php _e( 'Every 12 hours', 'instagram-feed' ); ?></option>
963
- <option value="24hours" <?php if ( $sbi_cache_cron_interval === '24hours' ) echo 'selected'; ?>><?php _e( 'Every 24 hours', 'instagram-feed' ); ?></option>
964
- </select>
965
-
966
- <div id="sbi-caching-time-settings" style="display: none;">
967
- <?php _e('at' ); ?>
968
-
969
- <select name="sbi_cache_cron_time" style="width: 80px">
970
- <option value="1" <?php if ( $sbi_cache_cron_time === '1' ) echo 'selected'; ?>>1:00</option>
971
- <option value="2" <?php if ( $sbi_cache_cron_time === '2' ) echo 'selected'; ?>>2:00</option>
972
- <option value="3" <?php if ( $sbi_cache_cron_time === '3' ) echo 'selected'; ?>>3:00</option>
973
- <option value="4" <?php if ( $sbi_cache_cron_time === '4' ) echo 'selected'; ?>>4:00</option>
974
- <option value="5" <?php if ( $sbi_cache_cron_time === '5' ) echo 'selected'; ?>>5:00</option>
975
- <option value="6" <?php if ( $sbi_cache_cron_time === '6' ) echo 'selected'; ?>>6:00</option>
976
- <option value="7" <?php if ( $sbi_cache_cron_time === '7' ) echo 'selected'; ?>>7:00</option>
977
- <option value="8" <?php if ( $sbi_cache_cron_time === '8' ) echo 'selected'; ?>>8:00</option>
978
- <option value="9" <?php if ( $sbi_cache_cron_time === '9' ) echo 'selected'; ?>>9:00</option>
979
- <option value="10" <?php if ( $sbi_cache_cron_time === '10' ) echo 'selected'; ?>>10:00</option>
980
- <option value="11" <?php if ( $sbi_cache_cron_time === '11' ) echo 'selected'; ?>>11:00</option>
981
- <option value="0" <?php if ( $sbi_cache_cron_time === '0' ) echo 'selected'; ?>>12:00</option>
982
- </select>
983
-
984
- <select name="sbi_cache_cron_am_pm" style="width: 50px">
985
- <option value="am" <?php if ( $sbi_cache_cron_am_pm === 'am' ) echo 'selected'; ?>>AM</option>
986
- <option value="pm" <?php if ( $sbi_cache_cron_am_pm === 'pm' ) echo 'selected'; ?>>PM</option>
987
- </select>
988
- </div>
989
-
990
- <?php
991
- if ( wp_next_scheduled( 'sbi_feed_update' ) ) {
992
- $time_format = get_option( 'time_format' );
993
- if ( ! $time_format ) {
994
- $time_format = 'g:i a';
995
- }
996
- //
997
- $schedule = wp_get_schedule( 'sbi_feed_update' );
998
- if ( $schedule == '30mins' ) $schedule = __( 'every 30 minutes', 'instagram-feed' );
999
- if ( $schedule == 'twicedaily' ) $schedule = __( 'every 12 hours', 'instagram-feed' );
1000
- $sbi_next_cron_event = wp_next_scheduled( 'sbi_feed_update' );
1001
- echo '<p class="sbi-caching-sched-notice"><span><b>' . __( 'Next check', 'instagram-feed' ) . ': ' . date( $time_format, $sbi_next_cron_event + sbi_get_utc_offset() ) . ' (' . $schedule . ')</b> - ' . __( 'Note: Saving the settings on this page will clear the cache and reset this schedule', 'instagram-feed' ) . '</span></p>';
1002
- } else {
1003
- echo '<p style="font-size: 11px; color: #666;">' . __( 'Nothing currently scheduled', 'instagram-feed' ) . '</p>';
1004
- }
1005
- ?>
1006
-
1007
- </div>
1008
-
1009
- </td>
1010
- </tr>
1011
-
1012
- </tbody>
1013
- </table>
1014
-
1015
- <?php submit_button(); ?>
1016
- </form>
1017
-
1018
- <p><i class="fa fa-chevron-circle-right" aria-hidden="true"></i>&nbsp; <?php _e('Next Step: <a href="?page=sb-instagram-feed&tab=customize">Customize your Feed</a>', 'instagram-feed'); ?></p>
1019
-
1020
- <p><i class="fa fa-life-ring" aria-hidden="true"></i>&nbsp; <?php _e('Need help setting up the plugin? Check out our <a href="https://smashballoon.com/instagram-feed/free/?utm_campaign=instagram-free&utm_source=supportpage&utm_medium=setupdirections" target="_blank">setup directions</a>', 'instagram-feed'); ?></p>
1021
-
1022
-
1023
- <?php } // End Configure tab ?>
1024
-
1025
-
1026
-
1027
- <?php if( $sbi_active_tab == 'customize' ) { //Start Configure tab ?>
1028
-
1029
- <p class="sb_instagram_contents_links" id="general">
1030
- <span><?php _e( 'Quick links:', 'instagram-feed' ); ?> </span>
1031
- <a href="#general"><?php _e( 'General', 'instagram-feed' ); ?></a>
1032
- <a href="#layout"><?php _e( 'Layout', 'instagram-feed' ); ?></a>
1033
- <a href="#photos"><?php _e( 'Photos', 'instagram-feed' ); ?></a>
1034
- <a href="#headeroptions"><?php _e( 'Header', 'instagram-feed' ); ?></a>
1035
- <a href="#loadmore"><?php _e( "'Load More' Button", 'instagram-feed' ); ?></a>
1036
- <a href="#follow"><?php _e( "'Follow' Button", 'instagram-feed' ); ?></a>
1037
- <a href="#customcss"><?php _e( 'Custom CSS', 'instagram-feed' ); ?></a>
1038
- <a href="#customjs"><?php _e( 'Custom JavaScript', 'instagram-feed' ); ?></a>
1039
- </p>
1040
-
1041
- <input type="hidden" name="<?php echo $sb_instagram_customize_hidden_field; ?>" value="Y">
1042
-
1043
- <h3><?php _e( 'General', 'instagram-feed' ); ?></h3>
1044
-
1045
- <table class="form-table">
1046
- <tbody>
1047
- <tr valign="top">
1048
- <th scope="row"><label><?php _e('Width of Feed', 'instagram-feed'); ?></label><code class="sbi_shortcode"> width widthunit
1049
- Eg: width=50 widthunit=%</code></th>
1050
- <td>
1051
- <input name="sb_instagram_width" type="text" value="<?php echo esc_attr( $sb_instagram_width ); ?>" id="sb_instagram_width" size="4" maxlength="4" />
1052
- <select name="sb_instagram_width_unit" id="sb_instagram_width_unit">
1053
- <option value="px" <?php if($sb_instagram_width_unit == "px") echo 'selected="selected"' ?> ><?php _e('px', 'instagram-feed'); ?></option>
1054
- <option value="%" <?php if($sb_instagram_width_unit == "%") echo 'selected="selected"' ?> ><?php _e('%', 'instagram-feed'); ?></option>
1055
- </select>
1056
- <div id="sb_instagram_width_options">
1057
- <input name="sb_instagram_feed_width_resp" type="checkbox" id="sb_instagram_feed_width_resp" <?php if($sb_instagram_feed_width_resp == true) echo "checked"; ?> /><label for="sb_instagram_feed_width_resp"><?php _e('Set to be 100% width on mobile?', 'instagram-feed'); ?></label>
1058
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e( 'What does this mean?', 'instagram-feed' ); ?></a>
1059
- <p class="sbi_tooltip"><?php _e("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.", 'instagram-feed'); ?></p>
1060
- </div>
1061
- </td>
1062
- </tr>
1063
- <tr valign="top">
1064
- <th scope="row"><label><?php _e('Height of Feed', 'instagram-feed'); ?></label><code class="sbi_shortcode"> height heightunit
1065
- Eg: height=500 heightunit=px</code></th>
1066
- <td>
1067
- <input name="sb_instagram_height" type="text" value="<?php echo esc_attr( $sb_instagram_height ); ?>" size="4" maxlength="4" />
1068
- <select name="sb_instagram_height_unit">
1069
- <option value="px" <?php if($sb_instagram_height_unit == "px") echo 'selected="selected"' ?> ><?php _e('px', 'instagram-feed'); ?></option>
1070
- <option value="%" <?php if($sb_instagram_height_unit == "%") echo 'selected="selected"' ?> ><?php _e('%', 'instagram-feed'); ?></option>
1071
- </select>
1072
- </td>
1073
- </tr>
1074
- <tr valign="top">
1075
- <th scope="row"><label><?php _e('Background Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> background
1076
- Eg: background=d89531</code></th>
1077
- <td>
1078
- <input name="sb_instagram_background" type="text" value="<?php echo esc_attr( $sb_instagram_background ); ?>" class="sbi_colorpick" />
1079
- </td>
1080
- </tr>
1081
- </tbody>
1082
- </table>
1083
-
1084
- <hr id="layout" />
1085
- <h3><?php _e('Layout', 'instagram-feed'); ?></h3>
1086
-
1087
- <table class="form-table">
1088
- <tbody>
1089
- <?php
1090
- $selected_type = isset( $sb_instagram_layout_type ) ? $sb_instagram_layout_type : 'grid';
1091
- $layout_types = array(
1092
- 'grid' => __( 'Grid', 'instagram-feed' ),
1093
- 'carousel' => __( 'Carousel', 'instagram-feed' ),
1094
- 'masonry' => __( 'Masonry', 'instagram-feed' ),
1095
- 'highlight' => __( 'Highlight', 'instagram-feed' )
1096
- );
1097
- $layout_images = array(
1098
- 'grid' => SBI_PLUGIN_URL . 'img/grid.png',
1099
- 'carousel' => SBI_PLUGIN_URL . 'img/carousel.png',
1100
- 'masonry' => SBI_PLUGIN_URL . 'img/masonry.png',
1101
- 'highlight' => SBI_PLUGIN_URL . 'img/highlight.png'
1102
- );
1103
- ?>
1104
- <tr valign="top">
1105
- <th scope="row" class="sbi_pro"><label title="<?php _e('Click for shortcode option', 'instagram-feed'); ?>"><?php _e('Layout Type', 'instagram-feed'); ?></label><br /><span class="sbi_note" style="margin: 5px 0 0 0; font-weight: normal;"><?php _e('Select a layout to see associated<br />options', 'instagram-feed'); ?></span></th>
1106
- <td>
1107
- <div class="sbi_layouts">
1108
- <?php foreach( $layout_types as $layout_type => $label ) : ?>
1109
- <div class="sbi_layout_cell sbi_pro">
1110
- <input class="sb_layout_type" id="sb_layout_type_<?php echo esc_attr( $layout_type ); ?>" name="sb_instagram_layout_type" type="radio" value="<?php echo esc_attr( $layout_type ); ?>" <?php if ( $selected_type === $layout_type ) echo 'checked'; ?>/><label for="sb_layout_type_<?php echo esc_attr( $layout_type ); ?>"><span class="sbi_label"><?php echo esc_html( $label ); ?></span><img src="<?php echo esc_url( $layout_images[ $layout_type ] ); ?>" /></label>
1111
- </div>
1112
- <?php endforeach; ?>
1113
-
1114
- <p class="sbi_pro_tooltip"><?php _e('Upgrade to the Pro version to unlock these layouts', 'instagram-feed'); ?><i class="fa fa-caret-down" aria-hidden="true"></i></p>
1115
- <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=layouts" target="_blank" class="sbi_lock"><i class="fa fa-rocket"></i><?php _e('Pro', 'instagram-feed'); ?></a>
1116
-
1117
- </div>
1118
- <div class="sb_layout_options_wrap sbi_pro">
1119
- <a href="JavaScript:void(0);" class="sbi_close_options"><i class="fa fa-close"></i></a>
1120
- <div class="sb_instagram_layout_settings sbi_layout_type_grid">
1121
- <i class="fa fa-info-circle" aria-hidden="true" style="margin-right: 8px;"></i><span class="sbi_note" style="margin-left: 0;"><?php _e('A uniform grid of square-cropped images.', 'instagram-feed'); ?></span>
1122
- </div>
1123
- <div class="sb_instagram_layout_settings sbi_layout_type_masonry">
1124
- <i class="fa fa-info-circle" aria-hidden="true" style="margin-right: 8px;"></i><span class="sbi_note" style="margin-left: 0;"><?php _e('Images in their original aspect ratios with no vertical space between posts.', 'instagram-feed'); ?></span>
1125
- </div>
1126
- <div class="sb_instagram_layout_settings sbi_layout_type_carousel">
1127
- <div class="sb_instagram_layout_setting">
1128
- <i class="fa fa-info-circle" aria-hidden="true" style="margin-right: 8px;"></i><span class="sbi_note" style="margin-left: 0;"><?php _e('Posts are displayed in a slideshow carousel.', 'instagram-feed'); ?></span>
1129
- </div>
1130
- <div class="sb_instagram_layout_setting">
1131
-
1132
- <label><?php _e('Number of Rows', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouselrows
1133
- Eg: carouselrows=2</code>
1134
- <br>
1135
- <span class="sbi_note" style="margin: -5px 0 -10px 0; display: block;"><?php _e('Use the "Number of Columns" setting below this section to set how many posts are visible in the carousel at a given time.', 'instagram-feed'); ?></span>
1136
- <br>
1137
- <select name="sb_instagram_carousel_rows" id="sb_instagram_carousel_rows">
1138
- <option value="1">1</option>
1139
- <option value="2" selected="selected">2</option>
1140
- </select>
1141
- </div>
1142
- <div class="sb_instagram_layout_setting">
1143
- <label><?php _e('Loop Type', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouselloop
1144
- Eg: carouselloop=rewind
1145
- carouselloop=infinity</code>
1146
- <br>
1147
- <select name="sb_instagram_carousel_loop" id="sb_instagram_carousel_loop">
1148
- <option value="rewind"><?php _e('Rewind', 'instagram-feed'); ?></option>
1149
- <option value="infinity" selected="selected"><?php _e('Infinity', 'instagram-feed'); ?></option>
1150
- </select>
1151
- </div>
1152
- <div class="sb_instagram_layout_setting">
1153
- <input type="checkbox" name="sb_instagram_carousel_arrows" id="sb_instagram_carousel_arrows" checked="checked">
1154
- <label><?php _e('Show Navigation Arrows', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouselarrows
1155
- Eg: carouselarrows=true</code>
1156
- </div>
1157
- <div class="sb_instagram_layout_setting">
1158
- <input type="checkbox" name="sb_instagram_carousel_pag" id="sb_instagram_carousel_pag">
1159
- <label><?php _e('Show Pagination', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouselpag
1160
- Eg: carouselpag=true</code>
1161
- </div>
1162
- <div class="sb_instagram_layout_setting">
1163
- <input type="checkbox" name="sb_instagram_carousel_autoplay" id="sb_instagram_carousel_autoplay">
1164
- <label><?php _e('Enable Autoplay', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouselautoplay
1165
- Eg: carouselautoplay=true</code>
1166
- </div>
1167
- <div class="sb_instagram_layout_setting">
1168
- <label><?php _e('Interval Time', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouseltime
1169
- Eg: carouseltime=8000</code>
1170
- <br>
1171
- <input name="sb_instagram_carousel_interval" type="text" value="5000" size="6"><?php _e("miliseconds", 'instagram-feed'); ?>
1172
- </div>
1173
- </div>
1174
-
1175
- <div class="sb_instagram_layout_settings sbi_layout_type_highlight">
1176
- <div class="sb_instagram_layout_setting">
1177
- <i class="fa fa-info-circle" aria-hidden="true" style="margin-right: 8px;"></i><span class="sbi_note" style="margin-left: 0;"><?php _e('Masonry style, square-cropped, image only (no captions or likes/comments below image). "Highlighted" posts are twice as large.', 'instagram-feed'); ?></span>
1178
- </div>
1179
- <div class="sb_instagram_layout_setting">
1180
- <label title="Click for shortcode option"><?php _e('Highlighting Type', 'instagram-feed'); ?></label><code class="sbi_shortcode"> highlighttype
1181
- Eg: highlighttype=pattern</code>
1182
- <br>
1183
- <select name="sb_instagram_highlight_type" id="sb_instagram_highlight_type">
1184
- <option value="pattern" selected="selected"><?php _e('Pattern', 'instagram-feed'); ?></option>
1185
- <option value="id"><?php _e('Post ID', 'instagram-feed'); ?></option>
1186
- <option value="hashtag"><?php _e('Hashtag', 'instagram-feed'); ?></option>
1187
- </select>
1188
- </div>
1189
- <div class="sb_instagram_highlight_sub_options sb_instagram_highlight_pattern sb_instagram_layout_setting" style="display: block;">
1190
- <label></label><code class="sbi_shortcode"> highlightoffset
1191
- Eg: highlightoffset=2</code>
1192
- <br>
1193
- <input name="sb_instagram_highlight_offset" type="number" min="0" value="0" style="width: 50px;">
1194
- </div>
1195
- <div class="sb_instagram_highlight_sub_options sb_instagram_highlight_pattern sb_instagram_layout_setting" style="display: block;">
1196
- <label><?php _e('Pattern', 'instagram-feed'); ?></label><code class="sbi_shortcode"> highlightpattern
1197
- Eg: highlightpattern=3</code>
1198
- <br>
1199
- <span><?php _e('Highlight every', 'instagram-feed'); ?></span><input name="sb_instagram_highlight_factor" type="number" min="2" value="6" style="width: 50px;"><span><?php _e('posts', 'instagram-feed'); ?></span>
1200
- </div>
1201
- <div class="sb_instagram_highlight_sub_options sb_instagram_highlight_hashtag sb_instagram_layout_setting" style="display: none;">
1202
- <label><?php _e('Highlight Posts with these Hashtags', 'instagram-feed'); ?></label>
1203
- <input name="sb_instagram_highlight_hashtag" id="sb_instagram_highlight_hashtag" type="text" size="40" value="#fishing">&nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What is this?', 'instagram-feed'); ?></a>
1204
- <br>
1205
- <span class="sbi_note" style="margin-left: 0;"><?php _e('Separate multiple hashtags using commas', 'instagram-feed'); ?></span>
1206
-
1207
-
1208
- <p class="sbi_tooltip"><?php _e('You can use this setting to highlight posts by a hashtag. Use a specified hashtag in your posts and they will be automatically highlighted in your feed.', 'instagram-feed'); ?></p>
1209
- </div>
1210
- <div class="sb_instagram_highlight_sub_options sb_instagram_highlight_ids sb_instagram_layout_setting" style="display: none;">
1211
- <label><?php _e('Highlight Posts by ID', 'instagram-feed'); ?></label>
1212
- <textarea name="sb_instagram_highlight_ids" id="sb_instagram_highlight_ids" style="width: 100%;" rows="3">sbi_1852317219231323590_3269008872</textarea>
1213
- <br>
1214
- <span class="sbi_note" style="margin-left: 0;"><?php _e('Separate IDs using commas', 'instagram-feed'); ?></span>
1215
-
1216
- &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What is this?', 'instagram-feed'); ?></a>
1217
- <p class="sbi_tooltip"><?php _e('You can use this setting to highlight posts by their ID. Enable and use "moderation mode", check the box to show post IDs underneath posts, then copy and paste IDs into this text box.', 'instagram-feed'); ?></p>
1218
- </div>
1219
- </div>
1220
-
1221
- </div>
1222
- </td>
1223
- </tr>
1224
- <tr valign="top">
1225
- <th scope="row"><label><?php _e('Number of Photos', 'instagram-feed'); ?></label><code class="sbi_shortcode"> num
1226
- Eg: num=6</code></th>
1227
- <td>
1228
- <input name="sb_instagram_num" type="text" value="<?php echo esc_attr( $sb_instagram_num ); ?>" size="4" maxlength="4" />
1229
- <span class="sbi_note"><?php _e('Number of photos to show initially.', 'instagram-feed'); ?></span>
1230
- </td>
1231
- </tr>
1232
- <tr valign="top">
1233
- <th scope="row"><label><?php _e('Number of Columns', 'instagram-feed'); ?></label><code class="sbi_shortcode"> cols
1234
- Eg: cols=3</code></th>
1235
- <td>
1236
- <select name="sb_instagram_cols">
1237
- <option value="1" <?php if($sb_instagram_cols == "1") echo 'selected="selected"' ?> ><?php _e('1', 'instagram-feed'); ?></option>
1238
- <option value="2" <?php if($sb_instagram_cols == "2") echo 'selected="selected"' ?> ><?php _e('2', 'instagram-feed'); ?></option>
1239
- <option value="3" <?php if($sb_instagram_cols == "3") echo 'selected="selected"' ?> ><?php _e('3', 'instagram-feed'); ?></option>
1240
- <option value="4" <?php if($sb_instagram_cols == "4") echo 'selected="selected"' ?> ><?php _e('4', 'instagram-feed'); ?></option>
1241
- <option value="5" <?php if($sb_instagram_cols == "5") echo 'selected="selected"' ?> ><?php _e('5', 'instagram-feed'); ?></option>
1242
- <option value="6" <?php if($sb_instagram_cols == "6") echo 'selected="selected"' ?> ><?php _e('6', 'instagram-feed'); ?></option>
1243
- <option value="7" <?php if($sb_instagram_cols == "7") echo 'selected="selected"' ?> ><?php _e('7', 'instagram-feed'); ?></option>
1244
- <option value="8" <?php if($sb_instagram_cols == "8") echo 'selected="selected"' ?> ><?php _e('8', 'instagram-feed'); ?></option>
1245
- <option value="9" <?php if($sb_instagram_cols == "9") echo 'selected="selected"' ?> ><?php _e('9', 'instagram-feed'); ?></option>
1246
- <option value="10" <?php if($sb_instagram_cols == "10") echo 'selected="selected"' ?> ><?php _e('10', 'instagram-feed'); ?></option>
1247
- </select>
1248
- </td>
1249
- </tr>
1250
- <tr valign="top">
1251
- <th scope="row"><label><?php _e('Padding around Images', 'instagram-feed'); ?></label><code class="sbi_shortcode"> imagepadding imagepaddingunit</code></th>
1252
- <td>
1253
- <input name="sb_instagram_image_padding" type="text" value="<?php echo esc_attr( $sb_instagram_image_padding ); ?>" size="4" maxlength="4" />
1254
- <select name="sb_instagram_image_padding_unit">
1255
- <option value="px" <?php if($sb_instagram_image_padding_unit == "px") echo 'selected="selected"' ?> ><?php _e('px', 'instagram-feed'); ?></option>
1256
- <option value="%" <?php if($sb_instagram_image_padding_unit == "%") echo 'selected="selected"' ?> ><?php _e('%', 'instagram-feed'); ?></option>
1257
- </select>
1258
- </td>
1259
- </tr>
1260
- <tr valign="top">
1261
- <th scope="row"><label><?php _e("Disable mobile layout", 'instagram-feed'); ?></label><code class="sbi_shortcode"> disablemobile
1262
- Eg: disablemobile=true</code></th>
1263
- <td>
1264
- <input type="checkbox" name="sb_instagram_disable_mobile" id="sb_instagram_disable_mobile" <?php if($sb_instagram_disable_mobile == true) echo 'checked="checked"' ?> />
1265
- &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e( 'What does this mean?', 'instagram-feed' ); ?></a>
1266
- <p class="sbi_tooltip"><?php _e("By default on mobile devices the layout automatically changes to use fewer columns. Checking this setting disables the mobile layout.", 'instagram-feed'); ?></p>
1267
- </td>
1268
- </tr>
1269
- </tbody>
1270
- </table>
1271
-
1272
- <?php submit_button(); ?>
1273
-
1274
- <hr id="photos" />
1275
- <h3><?php _e('Photos', 'instagram-feed'); ?></h3>
1276
-
1277
- <table class="form-table">
1278
- <tbody>
1279
- <tr valign="top">
1280
- <th scope="row"><label><?php _e('Sort Photos By', 'instagram-feed'); ?></label><code class="sbi_shortcode"> sortby
1281
- Eg: sortby=random</code></th>
1282
- <td>
1283
- <select name="sb_instagram_sort">
1284
- <option value="none" <?php if($sb_instagram_sort == "none") echo 'selected="selected"' ?> ><?php _e('Newest to oldest', 'instagram-feed'); ?></option>
1285
- <option value="random" <?php if($sb_instagram_sort == "random") echo 'selected="selected"' ?> ><?php _e('Random', 'instagram-feed'); ?></option>
1286
- </select>
1287
- </td>
1288
- </tr>
1289
- <tr valign="top">
1290
- <th scope="row"><label><?php _e('Image Resolution', 'instagram-feed'); ?></label><code class="sbi_shortcode"> imageres
1291
- Eg: imageres=thumb</code></th>
1292
- <td>
1293
-
1294
- <select name="sb_instagram_image_res">
1295
- <option value="auto" <?php if($sb_instagram_image_res == "auto") echo 'selected="selected"' ?> ><?php _e('Auto-detect (recommended)', 'instagram-feed'); ?></option>
1296
- <option value="thumb" <?php if($sb_instagram_image_res == "thumb") echo 'selected="selected"' ?> ><?php _e('Thumbnail (150x150)', 'instagram-feed'); ?></option>
1297
- <option value="medium" <?php if($sb_instagram_image_res == "medium") echo 'selected="selected"' ?> ><?php _e('Medium (320x320)', 'instagram-feed'); ?></option>
1298
- <option value="full" <?php if($sb_instagram_image_res == "full") echo 'selected="selected"' ?> ><?php _e('Full size (640x640)', 'instagram-feed'); ?></option>
1299
- </select>
1300
-
1301
- &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e( 'What does Auto-detect mean?', 'instagram-feed'); ?></a>
1302
- <p class="sbi_tooltip"><?php _e("Auto-detect means that the plugin automatically sets the image resolution based on the size of your feed.", 'instagram-feed'); ?></p>
1303
-
1304
- </td>
1305
- </tr>
1306
- </tbody>
1307
- </table>
1308
-
1309
- <span><a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a></span>
1310
-
1311
- <div class="sbi-pro-options">
1312
- <p class="sbi-upgrade-link">
1313
- <i class="fa fa-rocket" aria-hidden="true"></i>&nbsp; <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=general" target="_blank"><?php _e('Upgrade to Pro to enable these settings', 'instagram-feed'); ?></a>
1314
- </p>
1315
- <table class="form-table">
1316
- <tbody>
1317
- <tr valign="top" class="sbi_pro">
1318
- <th scope="row"><label><?php _e('Media Type to Display','instagram-feed'); ?></label></th>
1319
- <td>
1320
- <select name="sb_instagram_media_type" disabled>
1321
- <option value="all"><?php _e('All','instagram-feed'); ?></option>
1322
- <option value="photos"><?php _e('Photos only','instagram-feed'); ?></option>
1323
- <option value="videos"><?php _e('Videos only','instagram-feed'); ?></option>
1324
- </select>
1325
- </td>
1326
- </tr>
1327
-
1328
- <tr valign="top" class="sbi_pro">
1329
- <th scope="row"><label><?php _e("Enable Pop-up Lightbox", 'instagram-feed'); ?></label></th>
1330
- <td>
1331
- <input type="checkbox" name="sb_instagram_captionlinks" id="sb_instagram_captionlinks" disabled />
1332
- </td>
1333
- </tr>
1334
-
1335
- <tr valign="top" class="sbi_pro">
1336
- <th scope="row"><label><?php _e("Link Posts to URL in Caption (Shoppable feed)",'instagram-feed'); ?></label></th>
1337
- <td>
1338
- <input type="checkbox" name="sb_instagram_captionlinks" id="sb_instagram_captionlinks" disabled />
1339
- &nbsp;<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e("What will this do?",'instagram-feed'); ?></a>
1340
- <p class="sbi_tooltip"><?php _e("Checking this box will change the link for each post to any url included in the caption for that Instagram post. The lightbox will be disabled. Visit <a href='https://smashballoon.com/make-a-shoppable-feed?utm_campaign=instagram-free&utm_source=settings&utm_medium=shoppable'>this link</a> to learn how this works.",'instagram-feed'); ?></p>
1341
- </td>
1342
- </tr>
1343
- </tbody>
1344
- </table>
1345
- </div>
1346
-
1347
-
1348
- <hr />
1349
- <h3><?php _e('Photo Hover Style','instagram-feed'); ?></h3>
1350
-
1351
- <p style="padding-bottom: 18px;">
1352
- <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=photohover" target="_blank"><?php _e('Upgrade to Pro to enable Photo Hover styles','instagram-feed'); ?></a><br />
1353
- <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options','instagram-feed'); ?></a>
1354
- </p>
1355
-
1356
- <div class="sbi-pro-options" style="margin-top: -15px;">
1357
- <table class="form-table">
1358
- <tbody>
1359
- <tr valign="top" class="sbi_pro">
1360
- <th scope="row"><label><?php _e('Hover Background Color', 'instagram-feed'); ?></label></th>
1361
- <td>
1362
- <input name="sb_hover_background" type="text" disabled class="sbi_colorpick" />
1363
- </td>
1364
- </tr>
1365
- <tr valign="top" class="sbi_pro">
1366
- <th scope="row"><label><?php _e('Hover Text Color', 'instagram-feed'); ?></label></th>
1367
- <td>
1368
- <input name="sb_hover_text" type="text" disabled class="sbi_colorpick" />
1369
- </td>
1370
- </tr>
1371
- <tr valign="top" class="sbi_pro">
1372
- <th scope="row"><label><?php _e('Information to display', 'instagram-feed'); ?></label></th>
1373
- <td>
1374
- <div>
1375
- <input name="sbi_hover_inc_username" type="checkbox" disabled />
1376
- <label for="sbi_hover_inc_username"><?php _e('Username', 'instagram-feed'); ?></label>
1377
- </div>
1378
- <div>
1379
- <input name="sbi_hover_inc_icon" type="checkbox" disabled />
1380
- <label for="sbi_hover_inc_icon"><?php _e('Expand Icon', 'instagram-feed'); ?></label>
1381
- </div>
1382
- <div>
1383
- <input name="sbi_hover_inc_date" type="checkbox" disabled />
1384
- <label for="sbi_hover_inc_date"><?php _e('Date', 'instagram-feed'); ?></label>
1385
- </div>
1386
- <div>
1387
- <input name="sbi_hover_inc_instagram" type="checkbox" disabled />
1388
- <label for="sbi_hover_inc_instagram"><?php _e('Instagram Icon/Link', 'instagram-feed'); ?></label>
1389
- </div>
1390
- <div>
1391
- <input name="sbi_hover_inc_location" type="checkbox" disabled />
1392
- <label for="sbi_hover_inc_location"><?php _e('Location', 'instagram-feed'); ?></label>
1393
- </div>
1394
- <div>
1395
- <input name="sbi_hover_inc_caption" type="checkbox" disabled />
1396
- <label for="sbi_hover_inc_caption"><?php _e('Caption', 'instagram-feed'); ?></label>
1397
- </div>
1398
- <div>
1399
- <input name="sbi_hover_inc_likes" type="checkbox" disabled />
1400
- <label for="sbi_hover_inc_likes"><?php _e('Like/Comment Icons', 'instagram-feed'); ?></label>
1401
- </div>
1402
- </td>
1403
- </tr>
1404
-
1405
- </tbody>
1406
- </table>
1407
- </div>
1408
-
1409
-
1410
- <hr />
1411
- <h3><?php _e( 'Carousel', 'instagram-feed' ); ?></h3>
1412
- <p style="padding-bottom: 18px;">
1413
- <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=carousel" target="_blank"><?php _e('Upgrade to Pro to enable Carousels', 'instagram-feed'); ?></a><br />
1414
- <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a>
1415
- </p>
1416
-
1417
- <div class="sbi-pro-options" style="margin-top: -15px;">
1418
- <table class="form-table">
1419
- <tbody>
1420
- <tr valign="top" class="sbi_pro">
1421
- <th scope="row"><label><?php _e("Enable Carousel", 'instagram-feed'); ?></label></th>
1422
- <td>
1423
- <input type="checkbox" disabled />
1424
- &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e("What is this?", 'instagram-feed'); ?></a>
1425
- <p class="sbi_tooltip"><?php _e("Enable this setting to create a carousel slider out of your photos.", 'instagram-feed'); ?></p>
1426
- </td>
1427
- </tr>
1428
- <tr valign="top" class="sbi_pro">
1429
- <th scope="row"><label><?php _e("Show Navigation Arrows", 'instagram-feed'); ?></label></th>
1430
- <td>
1431
- <input type="checkbox" disabled />
1432
- </td>
1433
- </tr>
1434
- <tr valign="top" class="sbi_pro">
1435
- <th scope="row"><label><?php _e("Show Pagination", 'instagram-feed'); ?></label></th>
1436
- <td>
1437
- <input type="checkbox" disabled />
1438
- </td>
1439
- </tr>
1440
- <tr valign="top" class="sbi_pro">
1441
- <th scope="row"><label><?php _e("Enable Autoplay", 'instagram-feed'); ?></label></th>
1442
- <td>
1443
- <input type="checkbox" disabled />
1444
- </td>
1445
- </tr>
1446
- <tr valign="top" class="sbi_pro">
1447
- <th scope="row"><label><?php _e("Interval Time", 'instagram-feed'); ?></label></th>
1448
- <td>
1449
- <input name="sb_instagram_carousel_interval" type="text" disabled size="6" /><?php _e("milliseconds", 'instagram-feed'); ?>
1450
- </td>
1451
- </tr>
1452
- </tbody>
1453
- </table>
1454
- </div>
1455
-
1456
-
1457
-
1458
- <hr id="headeroptions" />
1459
- <h3><?php _e("Header", 'instagram-feed'); ?></h3>
1460
- <table class="form-table">
1461
- <tbody>
1462
- <tr valign="top">
1463
- <th scope="row"><label><?php _e("Show Feed Header", 'instagram-feed'); ?></label><code class="sbi_shortcode"> showheader
1464
- Eg: showheader=false</code></th>
1465
- <td>
1466
- <input type="checkbox" name="sb_instagram_show_header" id="sb_instagram_show_header" <?php if($sb_instagram_show_header == true) echo 'checked="checked"' ?> />
1467
- </td>
1468
- </tr>
1469
- <tr valign="top">
1470
- <th scope="row"><label><?php _e('Header Size', 'instagram-feed'); ?></label><code class="sbi_shortcode"> headersize
1471
- Eg: headersize=medium</code></th>
1472
- <td>
1473
- <select name="sb_instagram_header_size" id="sb_instagram_header_size" style="float: left;">
1474
- <option value="small" <?php if($sb_instagram_header_size == "small") echo 'selected="selected"' ?> ><?php _e('Small', 'instagram-feed'); ?></option>
1475
- <option value="medium" <?php if($sb_instagram_header_size == "medium") echo 'selected="selected"' ?> ><?php _e('Medium', 'instagram-feed'); ?></option>
1476
- <option value="large" <?php if($sb_instagram_header_size == "large") echo 'selected="selected"' ?> ><?php _e('Large', 'instagram-feed'); ?></option>
1477
- </select>
1478
- </td>
1479
- </tr>
1480
- <tr valign="top">
1481
- <th scope="row"><label><?php _e("Show Bio Text", 'instagram-feed'); ?></label><code class="sbi_shortcode"> showbio
1482
- Eg: showbio=false</code></th>
1483
- <td>
1484
- <?php $sb_instagram_show_bio = isset( $sb_instagram_show_bio ) ? $sb_instagram_show_bio : true; ?>
1485
- <input type="checkbox" name="sb_instagram_show_bio" id="sb_instagram_show_bio" <?php if($sb_instagram_show_bio == true) echo 'checked="checked"' ?> />
1486
- <span class="sbi_note"><?php _e("Only applies for Instagram accounts with bios", 'instagram-feed'); ?></span>
1487
- <div class="sb_instagram_box" style="display: block;">
1488
- <div class="sb_instagram_box_setting" style="display: block;">
1489
- <label style="padding-bottom: 0;"><?php _e("Add Custom Bio Text", 'instagram-feed'); ?></label><code class="sbi_shortcode" style="margin-top: 5px;"> custombio
1490
- Eg: custombio="My custom bio."</code>
1491
- <br>
1492
- <span class="sbi_aside" style="padding-bottom: 5px; display: block;"><?php _e("Use your own custom bio text in the feed header. Bio text is automatically retrieved from Instagram for Business accounts.", 'instagram-feed'); ?></span>
1493
-
1494
- <textarea type="text" name="sb_instagram_custom_bio" id="sb_instagram_custom_bio" ><?php echo esc_textarea( stripslashes( $sb_instagram_custom_bio ) ); ?></textarea>
1495
- &nbsp;<a class="sbi_tooltip_link sbi_tooltip_under" href="JavaScript:void(0);"><?php _e("Why is my bio not displaying automatically?", 'instagram-feed'); ?></a>
1496
- <p class="sbi_tooltip" style="padding: 10px 0 0 0; width: 99%;"><?php echo sprintf( __("Instagram is deprecating their old API for Personal accounts on March 31, 2020. The plugin supports their new API, however, their new API does not yet include the bio text for Personal accounts. If you require this feature then it is available if you convert your Instagram account from a Personal to a Business account by following %s. Note: If you previously had a Personal account connected then the plugin has saved the avatar for that feed and will continue to use it automatically.", 'instagram-feed'), '<a href="https://smashballoon.com/instagram-business-profiles/" target="_blank">these directions</a>' ); ?></p>
1497
- </div>
1498
- </div>
1499
-
1500
- </td>
1501
- </tr>
1502
-
1503
- <tr valign="top">
1504
- <th scope="row"><label><?php _e("Use Custom Avatar", 'instagram-feed'); ?></label><code class="sbi_shortcode"> customavatar
1505
- Eg: customavatar="https://my-website.com/avatar.jpg"</code></th>
1506
- <td>
1507
- <input type="text" name="sb_instagram_custom_avatar" class="large-text" id="sb_instagram_custom_avatar" value="<?php echo esc_attr( stripslashes( $sb_instagram_custom_avatar ) ); ?>" placeholder="https://example.com/avatar.jpg" />
1508
- <span class="sbi_aside"><?php _e("Avatar is automatically retrieved from Instagram for Business accounts", 'instagram-feed'); ?></span>
1509
- <br>
1510
- <a class="sbi_tooltip_link sbi_tooltip_under" href="JavaScript:void(0);"><?php _e("Why is my avatar not displaying automatically?", 'instagram-feed'); ?></a>
1511
-
1512
- <p class="sbi_tooltip sbi_tooltip_under_text" style="padding: 10px 0 0 0;"><?php echo sprintf( __("Instagram is deprecating their old API for Personal accounts on March 31, 2020. The plugin supports their new API, however, their new API does not yet include the avatar image for Personal accounts. If you require this feature then it is available if you convert your Instagram account from a Personal to a Business account by following %s. Note: If you previously had a Personal account connected then the plugin has saved the bio text for that feed and will continue to use it automatically.", 'instagram-feed'), '<a href="https://smashballoon.com/instagram-business-profiles/" target="_blank">these directions</a>' ); ?></p>
1513
-
1514
- </td>
1515
- </tr>
1516
- <tr valign="top">
1517
- <th scope="row"><label><?php _e('Header Text Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> headercolor
1518
- Eg: headercolor=fff</code></th>
1519
- <td>
1520
- <input name="sb_instagram_header_color" type="text" value="<?php echo esc_attr( $sb_instagram_header_color ); ?>" class="sbi_colorpick" />
1521
- </td>
1522
- </tr>
1523
- </tbody>
1524
- </table>
1525
-
1526
- <span><a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a></span>
1527
-
1528
- <div class="sbi-pro-options">
1529
- <p class="sbi-upgrade-link">
1530
- <i class="fa fa-rocket" aria-hidden="true"></i>&nbsp; <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=header" target="_blank"><?php _e('Upgrade to Pro to enable these settings', 'instagram-feed'); ?></a>
1531
- </p>
1532
- <table class="form-table">
1533
- <tbody>
1534
- <tr valign="top" class="sbi_pro">
1535
- <th scope="row"><label><?php _e('Header Style','instagram-feed'); ?></label></th>
1536
- <td>
1537
- <select name="sb_instagram_header_style" style="float: left;">
1538
- <option value="circle"><?php _e('Standard','instagram-feed'); ?></option>
1539
- <option value="boxed"><?php _e('Boxed','instagram-feed'); ?></option>
1540
- <option value="centered"><?php _e('Centered','instagram-feed'); ?></option>
1541
- </select>
1542
- </td>
1543
- </tr>
1544
- <tr valign="top" class="sbi_pro">
1545
- <th scope="row"><label><?php _e("Show Number of Followers",'instagram-feed'); ?></label></th>
1546
- <td>
1547
- <input type="checkbox" disabled />
1548
- <span class="sbi_note"><?php _e("This only applies when displaying photos from a User ID",'instagram-feed'); ?></span>
1549
- </td>
1550
- </tr>
1551
- </tbody>
1552
- </table>
1553
- </div>
1554
-
1555
- <?php submit_button(); ?>
1556
-
1557
-
1558
- <hr />
1559
- <h3><?php _e("Caption", 'instagram-feed'); ?></h3>
1560
- <p style="padding-bottom: 18px;">
1561
- <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=caption" target="_blank"><?php _e("Upgrade to Pro to enable Photo Captions", 'instagram-feed'); ?></a><br />
1562
- <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e("Show Pro Options", 'instagram-feed'); ?></a>
1563
- </p>
1564
-
1565
- <div class="sbi-pro-options" style="margin-top: -15px;">
1566
- <table class="form-table">
1567
- <tbody>
1568
- <tr valign="top" class="sbi_pro">
1569
- <th scope="row"><label><?php _e("Show Caption", 'instagram-feed'); ?></label></th>
1570
- <td>
1571
- <input type="checkbox" disabled />
1572
- </td>
1573
- </tr>
1574
- <tr valign="top" class="sbi_pro">
1575
- <th scope="row"><label><?php _e("Maximum Text Length", 'instagram-feed'); ?></label></th>
1576
- <td>
1577
- <input disabled size="4" />Characters
1578
- &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e("What is this?", 'instagram-feed'); ?></a>
1579
- <p class="sbi_tooltip"><?php _e("The number of characters of text to display in the caption. An elipsis link will be added to allow the user to reveal more text if desired.", 'instagram-feed'); ?></p>
1580
- </td>
1581
- </tr>
1582
- <tr valign="top" class="sbi_pro">
1583
- <th scope="row"><label><?php _e('Text Color', 'instagram-feed'); ?></label></th>
1584
- <td>
1585
- <input type="text" disabled class="sbi_colorpick" />
1586
- </td>
1587
- </tr>
1588
- <tr valign="top" class="sbi_pro">
1589
- <th scope="row"><label><?php _e('Text Size', 'instagram-feed'); ?></label></th>
1590
- <td>
1591
- <select name="sb_instagram_caption_size" style="width: 180px;" disabled>
1592
- <option value="inherit" ><?php _e('Inherit from theme', 'instagram-feed'); ?></option>
1593
- <option value="10" >10px</option>
1594
- <option value="11" >11px</option>
1595
- <option value="12" >12px</option>
1596
- <option value="13" >13px</option>
1597
- <option value="14" >14px</option>
1598
- <option value="16" >16px</option>
1599
- <option value="18" >18px</option>
1600
- <option value="20" >20px</option>
1601
- <option value="24" >24px</option>
1602
- <option value="28" >28px</option>
1603
- <option value="32" >32px</option>
1604
- <option value="36" >36px</option>
1605
- <option value="40" >40px</option>
1606
- </select>
1607
- </td>
1608
- </tr>
1609
- </tbody>
1610
- </table>
1611
- </div>
1612
-
1613
-
1614
- <hr />
1615
- <h3><?php _e("Likes &amp; Comments", 'instagram-feed'); ?></h3>
1616
- <p style="padding-bottom: 18px;">
1617
- <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=stats" target="_blank"><?php _e("Upgrade to Pro to enable Likes &amp; Comments", 'instagram-feed'); ?></a><br />
1618
- <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e("Show Pro Options", 'instagram-feed'); ?></a>
1619
- </p>
1620
-
1621
- <div class="sbi-pro-options" style="margin-top: -15px;">
1622
- <table class="form-table">
1623
- <tbody>
1624
- <tr valign="top" class="sbi_pro">
1625
- <th scope="row"><label><?php _e("Show Icons", 'instagram-feed'); ?></label></th>
1626
- <td>
1627
- <input type="checkbox" disabled />
1628
- </td>
1629
- </tr>
1630
- <tr valign="top" class="sbi_pro">
1631
- <th scope="row"><label><?php _e('Icon Color', 'instagram-feed'); ?></label></th>
1632
- <td>
1633
- <input type="text" disabled class="sbi_colorpick" />
1634
- </td>
1635
- </tr>
1636
- <tr valign="top" class="sbi_pro">
1637
- <th scope="row"><label><?php _e('Icon Size', 'instagram-feed'); ?></label></th>
1638
- <td>
1639
- <select disabled name="sb_instagram_meta_size" style="width: 180px;">
1640
- <option value="inherit"><?php _e('Inherit from theme', 'instagram-feed'); ?></option>
1641
- <option value="10" >10px</option>
1642
- <option value="11" >11px</option>
1643
- <option value="12" >12px</option>
1644
- <option value="13" >13px</option>
1645
- <option value="14" >14px</option>
1646
- <option value="16" >16px</option>
1647
- <option value="18" >18px</option>
1648
- <option value="20" >20px</option>
1649
- <option value="24" >24px</option>
1650
- <option value="28" >28px</option>
1651
- <option value="32" >32px</option>
1652
- <option value="36" >36px</option>
1653
- <option value="40" >40px</option>
1654
- </select>
1655
- </td>
1656
- </tr>
1657
- </tbody>
1658
- </table>
1659
- </div>
1660
-
1661
-
1662
- <hr />
1663
- <h3><?php _e('Lightbox Comments', 'instagram-feed'); ?></h3>
1664
-
1665
- <p style="padding-bottom: 18px;">
1666
- <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=comments" target="_blank"><?php _e('Upgrade to Pro to enable Comments', 'instagram-feed'); ?></a><br />
1667
- <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a>
1668
- </p>
1669
-
1670
- <div class="sbi-pro-options" style="margin-top: -15px;">
1671
- <table class="form-table">
1672
- <tbody>
1673
-
1674
- <tr valign="top" class="sbi_pro">
1675
- <th scope="row"><label><?php _e('Show Comments in Lightbox', 'instagram-feed'); ?></label></th>
1676
- <td style="padding: 5px 10px 0 10px;">
1677
- <input type="checkbox" disabled style="margin-right: 15px;" />
1678
- <input class="button-secondary" style="margin-top: -5px;" disabled value="<?php echo esc_attr( 'Clear Comment Cache', 'instagram-feed' ); ?>" />
1679
- &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e("What is this?", 'instagram-feed'); ?></a>
1680
- <p class="sbi_tooltip"><?php _e("This will remove the cached comments saved in the database", 'instagram-feed'); ?></p>
1681
- </td>
1682
- </tr>
1683
- <tr valign="top" class="sbi_pro">
1684
- <th scope="row"><label><?php _e('Number of Comments', 'instagram-feed'); ?></label></th>
1685
- <td>
1686
- <input name="sb_instagram_num_comments" type="text" disabled size="4" />
1687
- <span class="sbi_note"><?php _e('Max number of latest comments.', 'instagram-feed'); ?></span>
1688
- &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e("What is this?", 'instagram-feed'); ?></a>
1689
- <p class="sbi_tooltip"><?php _e("This is the maximum number of comments that will be shown in the lightbox. If there are more comments available than the number set, only the latest comments will be shown", 'instagram-feed'); ?></p>
1690
- </td>
1691
- </tr>
1692
-
1693
- </tbody>
1694
- </table>
1695
- </div>
1696
-
1697
-
1698
- <hr id="loadmore" />
1699
- <h3><?php _e("'Load More' Button", 'instagram-feed'); ?></h3>
1700
- <table class="form-table">
1701
- <tbody>
1702
- <tr valign="top">
1703
- <th scope="row"><label><?php _e("Show the 'Load More' button", 'instagram-feed'); ?></label><code class="sbi_shortcode"> showbutton
1704
- Eg: showbutton=false</code></th>
1705
- <td>
1706
- <input type="checkbox" name="sb_instagram_show_btn" id="sb_instagram_show_btn" <?php if($sb_instagram_show_btn == true) echo 'checked="checked"' ?> />
1707
- </td>
1708
- </tr>
1709
- <tr valign="top">
1710
- <th scope="row"><label><?php _e('Button Background Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> buttoncolor
1711
- Eg: buttoncolor=8224e3</code></th>
1712
- <td>
1713
- <input name="sb_instagram_btn_background" type="text" value="<?php echo esc_attr( $sb_instagram_btn_background ); ?>" class="sbi_colorpick" />
1714
- </td>
1715
- </tr>
1716
- <tr valign="top">
1717
- <th scope="row"><label><?php _e('Button Text Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> buttontextcolor
1718
- Eg: buttontextcolor=eeee22</code></th>
1719
- <td>
1720
- <input name="sb_instagram_btn_text_color" type="text" value="<?php echo esc_attr( $sb_instagram_btn_text_color ); ?>" class="sbi_colorpick" />
1721
- </td>
1722
- </tr>
1723
- <tr valign="top">
1724
- <th scope="row"><label><?php _e('Button Text', 'instagram-feed'); ?></label><code class="sbi_shortcode"> buttontext
1725
- Eg: buttontext="Show more.."</code></th>
1726
- <td>
1727
- <input name="sb_instagram_btn_text" type="text" value="<?php echo esc_attr( stripslashes( $sb_instagram_btn_text ) ); ?>" size="20" />
1728
- </td>
1729
- </tr>
1730
- </tbody>
1731
- </table>
1732
-
1733
- <?php submit_button(); ?>
1734
-
1735
- <hr id="follow" />
1736
- <h3><?php _e("'Follow' Button", 'instagram-feed'); ?></h3>
1737
- <table class="form-table">
1738
- <tbody>
1739
- <tr valign="top">
1740
- <th scope="row"><label><?php _e("Show the Follow button", 'instagram-feed'); ?></label><code class="sbi_shortcode"> showfollow
1741
- Eg: showfollow=true</code></th>
1742
- <td>
1743
- <input type="checkbox" name="sb_instagram_show_follow_btn" id="sb_instagram_show_follow_btn" <?php if($sb_instagram_show_follow_btn == true) echo 'checked="checked"' ?> />
1744
- </td>
1745
- </tr>
1746
-
1747
- <tr valign="top">
1748
- <th scope="row"><label><?php _e('Button Background Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> followcolor
1749
- Eg: followcolor=28a1bf</code></th>
1750
- <td>
1751
- <input name="sb_instagram_folow_btn_background" type="text" value="<?php echo esc_attr( $sb_instagram_folow_btn_background ); ?>" class="sbi_colorpick" />
1752
- </td>
1753
- </tr>
1754
- <tr valign="top">
1755
- <th scope="row"><label><?php _e('Button Text Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> followtextcolor
1756
- Eg: followtextcolor=000</code></th>
1757
- <td>
1758
- <input name="sb_instagram_follow_btn_text_color" type="text" value="<?php echo esc_attr( $sb_instagram_follow_btn_text_color ); ?>" class="sbi_colorpick" />
1759
- </td>
1760
- </tr>
1761
- <tr valign="top">
1762
- <th scope="row"><label><?php _e('Button Text', 'instagram-feed'); ?></label><code class="sbi_shortcode"> followtext
1763
- Eg: followtext="Follow me"</code></th>
1764
- <td>
1765
- <input name="sb_instagram_follow_btn_text" type="text" value="<?php echo esc_attr( stripslashes( $sb_instagram_follow_btn_text ) ); ?>" size="30" />
1766
- </td>
1767
- </tr>
1768
- </tbody>
1769
- </table>
1770
-
1771
- <hr id="filtering" />
1772
- <h3><?php _e('Post Filtering', 'instagram-feed'); ?></h3>
1773
-
1774
- <p style="padding-bottom: 18px;">
1775
- <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=filtering" target="_blank"><?php _e('Upgrade to Pro to enable Post Filtering options', 'instagram-feed'); ?></a><br />
1776
- <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a>
1777
- </p>
1778
-
1779
- <div class="sbi-pro-options" style="margin-top: -15px;">
1780
-
1781
- <table class="form-table">
1782
- <tbody>
1783
- <tr valign="top" class="sbi_pro">
1784
- <th scope="row"><label><?php _e('Remove photos containing these words or hashtags', 'instagram-feed'); ?></label></th>
1785
- <td>
1786
- <div class="sb_instagram_apply_labels">
1787
- <p><?php _e('Apply to:', 'instagram-feed'); ?></p>
1788
- <input class="sb_instagram_incex_one_all" type="radio" value="all" disabled /><label><?php _e('All feeds', 'instagram-feed'); ?></label>
1789
- <input class="sb_instagram_incex_one_all" type="radio" value="one" disabled /><label><?php _e('One feed', 'instagram-feed'); ?></label>
1790
- </div>
1791
-
1792
- <input disabled name="sb_instagram_exclude_words" id="sb_instagram_exclude_words" type="text" style="width: 70%;" value="" />
1793
- <br />
1794
- <span class="sbi_note" style="margin-left: 0;"><?php _e('Separate words/hashtags using commas', 'instagram-feed'); ?></span>
1795
- &nbsp;<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed'); ?></a>
1796
- <p class="sbi_tooltip"><?php _e("You can use this setting to remove photos which contain certain words or hashtags in the caption. Separate multiple words or hashtags using commas.", 'instagram-feed'); ?></p>
1797
- </td>
1798
- </tr>
1799
-
1800
- <tr valign="top" class="sbi_pro">
1801
- <th scope="row"><label><?php _e('Show photos containing these words or hashtags', 'instagram-feed'); ?></label></th>
1802
- <td>
1803
- <div class="sb_instagram_apply_labels">
1804
- <p><?php _e('Apply to:', 'instagram-feed'); ?></p>
1805
- <input class="sb_instagram_incex_one_all" type="radio" value="all" disabled /><label><?php _e('All feeds', 'instagram-feed'); ?></label>
1806
- <input class="sb_instagram_incex_one_all" type="radio" value="one" disabled /><label><?php _e('One feed', 'instagram-feed'); ?></label>
1807
- </div>
1808
-
1809
- <input disabled name="sb_instagram_include_words" id="sb_instagram_include_words" type="text" style="width: 70%;" value="" />
1810
- <br />
1811
- <span class="sbi_note" style="margin-left: 0;"><?php _e('Separate words/hashtags using commas', 'instagram-feed'); ?></span>
1812
- &nbsp;<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed'); ?></a>
1813
- <p class="sbi_tooltip"><?php _e("You can use this setting to only show photos which contain certain words or hashtags in the caption. For example, adding <code>sheep, cow, dog</code> will show any photos which contain either the word sheep, cow, or dog. Separate multiple words or hashtags using commas.", 'instagram-feed'); ?></p>
1814
- </td>
1815
- </tr>
1816
- </tbody>
1817
- </table>
1818
- </div>
1819
-
1820
-
1821
- <hr id="moderation" />
1822
- <h3><?php _e('Moderation', 'instagram-feed'); ?></h3>
1823
-
1824
- <p style="padding-bottom: 18px;">
1825
- <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=moderation" target="_blank"><?php _e('Upgrade to Pro to enable Moderation options', 'instagram-feed'); ?></a><br />
1826
- <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a>
1827
- </p>
1828
-
1829
- <div class="sbi-pro-options" style="margin-top: -15px;">
1830
- <table class="form-table">
1831
- <tbody>
1832
- <tr valign="top" class="sbi_pro">
1833
- <th scope="row"><label><?php _e('Moderation Type', 'instagram-feed'); ?></label></th>
1834
- <td>
1835
- <input class="sb_instagram_moderation_mode" checked="checked" disabled type="radio" value="visual" style="margin-top: 0;" /><label><?php _e('Visual', 'instagram-feed'); ?></label>
1836
- <input class="sb_instagram_moderation_mode" disabled type="radio" value="manual" style="margin-top: 0; margin-left: 10px;"/><label><?php _e('Manual', 'instagram-feed'); ?></label>
1837
-
1838
- <p class="sbi_tooltip" style="display: block;"><?php _e("<b>Visual Moderation Mode</b><br />This adds a button to each feed that will allow you to hide posts, block users, and create white lists from the front end using a visual interface. Visit <a href='https://smashballoon.com/guide-to-moderation-mode/?utm_campaign=instagram-free&utm_source=settings&utm_medium=moderationmode' target='_blank'>this page</a> for details", 'instagram-feed'); ?></p>
1839
-
1840
- </td>
1841
- </tr>
1842
-
1843
- <tr valign="top" class="sbi_pro">
1844
- <th scope="row"><label><?php _e('Only show posts by these users', 'instagram-feed'); ?></label></th>
1845
- <td>
1846
- <input type="text" style="width: 70%;" disabled /><br />
1847
- <span class="sbi_note" style="margin-left: 0;"><?php _e('Separate usernames using commas', 'instagram-feed'); ?></span>
1848
-
1849
- &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e("What is this?", 'instagram-feed'); ?></a>
1850
- <p class="sbi_tooltip"><?php _e("You can use this setting to show photos only from certain users in your feed. Just enter the usernames here which you want to show. Separate multiple usernames using commas.", 'instagram-feed'); ?></p>
1851
- </td>
1852
- </tr>
1853
- <tr valign="top" class="sbi_pro">
1854
- <th scope="row"><label><?php _e('White lists', 'instagram-feed'); ?></label></th>
1855
- <td>
1856
- <div class="sbi_white_list_names_wrapper">
1857
- <?php _e("No white lists currently created", 'instagram-feed'); ?>
1858
- </div>
1859
-
1860
- <input disabled class="button-secondary" type="submit" value="<?php esc_attr_e( 'Clear White Lists', 'instagram-feed' ); ?>" />
1861
- &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);" style="display: inline-block; margin-top: 5px;"><?php _e("What is this?", 'instagram-feed'); ?></a>
1862
- <p class="sbi_tooltip"><?php _e("This will remove all of the white lists from the database", 'instagram-feed'); ?></p>
1863
- </td>
1864
- </tr>
1865
-
1866
- </tbody>
1867
- </table>
1868
- </div>
1869
-
1870
-
1871
-
1872
- <hr id="customcss" />
1873
- <h3><?php _e('Misc', 'instagram-feed'); ?></h3>
1874
-
1875
- <table class="form-table">
1876
- <tbody>
1877
- <tr valign="top">
1878
- <td style="padding-bottom: 0;">
1879
- <?php _e('<strong style="font-size: 15px;">Custom CSS</strong><br />Enter your own custom CSS in the box below', 'instagram-feed'); ?>
1880
- </td>
1881
- </tr>
1882
- <tr valign="top">
1883
- <td>
1884
- <textarea name="sb_instagram_custom_css" id="sb_instagram_custom_css" style="width: 70%;" rows="7"><?php echo esc_textarea( stripslashes($sb_instagram_custom_css), 'instagram-feed' ); ?></textarea>
1885
- </td>
1886
- </tr>
1887
- <tr valign="top" id="customjs">
1888
- <td style="padding-bottom: 0;">
1889
- <?php _e('<strong style="font-size: 15px;">Custom JavaScript</strong><br />Enter your own custom JavaScript/jQuery in the box below', 'instagram-feed'); ?>
1890
- </td>
1891
- </tr>
1892
- <tr valign="top">
1893
- <td>
1894
- <textarea name="sb_instagram_custom_js" id="sb_instagram_custom_js" style="width: 70%;" rows="7"><?php echo esc_textarea( stripslashes($sb_instagram_custom_js), 'instagram-feed' ); ?></textarea>
1895
- </td>
1896
- </tr>
1897
- </tbody>
1898
- </table>
1899
- <table class="form-table">
1900
- <tbody>
1901
-
1902
- <tr valign="top">
1903
- <th scope="row"><label for="sb_instagram_ajax_theme" class="bump-left"><?php _e("Are you using an Ajax powered theme?", 'instagram-feed'); ?></label></th>
1904
- <td>
1905
- <input name="sb_instagram_ajax_theme" type="checkbox" id="sb_instagram_ajax_theme" <?php if($sb_instagram_ajax_theme == true) echo "checked"; ?> />
1906
- <label for="sb_instagram_ajax_theme"><?php _e('Yes', 'instagram-feed'); ?></label>
1907
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1908
- <p class="sbi_tooltip"><?php _e("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 please check with the theme author.", 'instagram-feed'); ?></p>
1909
- </td>
1910
- </tr>
1911
-
1912
- <tr>
1913
- <th class="bump-left"><label class="bump-left"><?php _e("Image Resizing", 'instagram-feed'); ?></label></th>
1914
- <td>
1915
- <input name="sb_instagram_disable_resize" type="checkbox" id="sb_instagram_disable_resize" <?php if($sb_instagram_disable_resize == true) echo "checked"; ?> />
1916
- <label for="sb_instagram_disable_resize"><?php _e('Disable Local Image Storing and Resizing', 'instagram-feed'); ?></label><br><br>
1917
- <input name="sb_instagram_favor_local" type="checkbox" id="sb_instagram_favor_local" <?php if($sb_instagram_favor_local == true) echo "checked"; ?> />
1918
- <label for="sb_instagram_favor_local"><?php _e('Favor Local Images', 'instagram-feed'); ?></label><br><br>
1919
-
1920
- <input id="sbi_reset_resized" class="button-secondary" type="submit" value="<?php esc_attr_e( 'Reset Resized Images' ); ?>" style="vertical-align: middle;"/>
1921
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1922
- <p class="sbi_tooltip"><?php _e("The plugin creates and stores resized versions of images in order to serve a more optimized resolution size in the feed. Click this button to clear all data related to resized images. Enable the setting to favor local images to always use a local, resized image if one is available.", 'instagram-feed'); ?></p>
1923
- </td>
1924
- </tr>
1925
-
1926
- <tr valign="top">
1927
- <th scope="row"><label><?php _e('API request size', 'instagram-feed'); ?></label><code class="sbi_shortcode"> minnum
1928
- Eg: minnum=25</code></th>
1929
- <td>
1930
- <input name="sb_instagram_minnum" type="number" min="0" max="100" value="<?php echo esc_attr( $sb_instagram_minnum ); ?>" />
1931
- <span class="sbi_note"><?php _e('Leave at "0" for default', 'instagram-feed'); ?></span>
1932
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1933
- <p class="sbi_tooltip"><?php _e("If your feed contains a lot of IG TV posts or your feed is not displaying any posts despite there being posts available on Instagram.com, try increasing this number to 25 or more.", 'instagram-feed'); ?></p>
1934
- </td>
1935
- </tr>
1936
-
1937
- <tr valign="top">
1938
- <th scope="row"><label><?php _e('Enqueue JS file in head', 'instagram-feed'); ?></label></th>
1939
- <td>
1940
- <input type="checkbox" name="enqueue_js_in_head" id="sb_instagram_enqueue_js_in_head" <?php if($enqueue_js_in_head == true) echo 'checked="checked"' ?> />
1941
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1942
- <p class="sbi_tooltip"><?php _e("Check this box if you'd like to enqueue the JavaScript file for the plugin in the head instead of the footer.", 'instagram-feed'); ?></p>
1943
- </td>
1944
- </tr>
1945
-
1946
- <tr valign="top">
1947
- <th scope="row"><label><?php _e('Enqueue CSS file with shortcode', 'instagram-feed'); ?></label></th>
1948
- <td>
1949
- <input type="checkbox" name="enqueue_css_in_shortcode" id="sb_instagram_enqueue_css_in_shortcode" <?php if($enqueue_css_in_shortcode == true) echo 'checked="checked"' ?> />
1950
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1951
- <p class="sbi_tooltip"><?php _e("Check this box if you'd like to only include the CSS file for the plugin when the feed is on the page.", 'instagram-feed'); ?></p>
1952
- </td>
1953
- </tr>
1954
-
1955
- <tr valign="top">
1956
- <th scope="row"><label><?php _e('Disable JS Image Loading', 'instagram-feed'); ?></label></th>
1957
- <td>
1958
- <input type="checkbox" name="disable_js_image_loading" id="sb_instagram_disable_js_image_loading" <?php if($disable_js_image_loading == true) echo 'checked="checked"' ?> />
1959
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1960
- <p class="sbi_tooltip"><?php _e("Check this box to have images loaded server side instead of with JS.", 'instagram-feed'); ?></p>
1961
- </td>
1962
- </tr>
1963
-
1964
- <tr valign="top">
1965
- <th><label><?php _e("Enable Backup Caching", 'instagram-feed'); ?></label></th>
1966
- <td class="sbi-customize-tab-opt">
1967
- <input name="sb_instagram_backup" type="checkbox" id="sb_instagram_backup" <?php if($sb_instagram_backup == true) echo "checked"; ?> />
1968
- <input id="sbi_clear_backups" class="button-secondary" type="submit" style="position: relative; top: -4px;" value="<?php esc_attr_e( 'Clear Backup Cache', 'instagram-feed' ); ?>" />
1969
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1970
- <p class="sbi_tooltip"><?php _e('Every feed will save a duplicate version of itself in the database to be used if the normal cache is not available.', 'instagram-feed'); ?></p>
1971
- </td>
1972
- </tr>
1973
-
1974
- <tr>
1975
- <th class="bump-left">
1976
- <label class="bump-left"><?php _e("Load initial posts with AJAX", 'instagram-feed'); ?></label>
1977
- </th>
1978
- <td>
1979
- <input name="sb_ajax_initial" type="checkbox" id="sb_ajax_initial" <?php if($sb_ajax_initial == true) echo "checked"; ?> />
1980
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1981
- <p class="sbi_tooltip"><?php _e("Initial posts will be loaded using AJAX instead of added to the page directly. If you use page caching, this will allow the feed to update according to the \"Check for new posts every\" setting on the \"Configure\" tab.", 'instagram-feed'); ?></p>
1982
- </td>
1983
- </tr>
1984
-
1985
- <tr>
1986
- <th class="bump-left">
1987
- <label for="sb_instagram_cron" class="bump-left"><?php _e("Force cache to clear on interval", 'instagram-feed'); ?></label>
1988
- </th>
1989
- <td>
1990
- <select name="sb_instagram_cron">
1991
- <option value="unset" <?php if($sb_instagram_cron == "unset") echo 'selected="selected"' ?> > - </option>
1992
- <option value="yes" <?php if($sb_instagram_cron == "yes") echo 'selected="selected"' ?> ><?php _e('Yes', 'instagram-feed'); ?></option>
1993
- <option value="no" <?php if($sb_instagram_cron == "no") echo 'selected="selected"' ?> ><?php _e('No', 'instagram-feed'); ?></option>
1994
- </select>
1995
-
1996
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1997
- <p class="sbi_tooltip"><?php _e("If you're experiencing an issue with the plugin not auto-updating then you can set this to 'Yes' to run a scheduled event behind the scenes which forces the plugin cache to clear on a regular basis and retrieve new data from Instagram.", 'instagram-feed'); ?></p>
1998
- </td>
1999
- </tr>
2000
- </tbody>
2001
- </table>
2002
- <table class="form-table">
2003
- <tbody>
2004
- <tr valign="top">
2005
- <th scope="row"><label><?php _e("Disable Icon Font", 'instagram-feed'); ?></label></th>
2006
- <td>
2007
- <input type="checkbox" name="sb_instagram_disable_awesome" id="sb_instagram_disable_awesome" <?php if($sb_instagram_disable_awesome == true) echo 'checked="checked"' ?> /> <?php _e( 'Yes', 'instagram-feed' ); ?>
2008
- </td>
2009
- </tr>
2010
- <tr>
2011
- <th scope="row"><label for="sbi_font_method"><?php _e("Icon Method", 'instagram-feed'); ?></label></th>
2012
- <td>
2013
- <select name="sbi_font_method" id="sbi_font_method" class="default-text">
2014
- <option value="svg" id="sbi-font_method" class="default-text" <?php if($sbi_font_method == 'svg') echo 'selected="selected"' ?>>SVG</option>
2015
- <option value="fontfile" id="sbi-font_method" class="default-text" <?php if($sbi_font_method == 'fontfile') echo 'selected="selected"' ?>><?php _e("Font File", 'instagram-feed'); ?></option>
2016
- </select>
2017
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
2018
- <p class="sbi_tooltip"><?php _e("This plugin uses SVGs for all icons in the feed. Use this setting to switch to font icons.", 'instagram-feed'); ?></p>
2019
- </td>
2020
- </tr>
2021
- <tr>
2022
- <th class="bump-left"><label class="bump-left"><?php _e("Enable Custom Templates", 'instagram-feed'); ?></label></th>
2023
- <td>
2024
- <input name="sb_instagram_custom_template" type="checkbox" id="sb_instagram_custom_template" <?php if($sb_instagram_custom_template == true) echo "checked"; ?> />
2025
- <label for="sb_instagram_custom_template"><?php _e('Yes', 'instagram-feed'); ?></label>
2026
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
2027
- <p class="sbi_tooltip"><?php _e("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/guide-to-creating-custom-templates/\" target=\"_blank\">this guide</a>", 'instagram-feed'); ?></p>
2028
- </td>
2029
- </tr>
2030
- <tr>
2031
- <th class="bump-left"><label class="bump-left"><?php _e("Disable Admin Error Notice", 'instagram-feed'); ?></label></th>
2032
- <td>
2033
- <input name="sb_instagram_disable_admin_notice" type="checkbox" id="sb_instagram_disable_admin_notice" <?php if($sb_instagram_disable_admin_notice == true) echo "checked"; ?> />
2034
- <label for="sb_instagram_disable_admin_notice"><?php _e('Yes', 'instagram-feed'); ?></label>
2035
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
2036
- <p class="sbi_tooltip"><?php _e("This will permanently disable the feed error notice that displays in the bottom right corner for admins on the front end of your site.", 'instagram-feed'); ?></p>
2037
- </td>
2038
- </tr>
2039
- <tr>
2040
- <th class="bump-left"><label class="bump-left"><?php _e("Feed Issue Email Report", 'instagram-feed'); ?></label></th>
2041
- <td>
2042
- <input name="sb_instagram_enable_email_report" type="checkbox" id="sb_instagram_enable_email_report" <?php if($sb_instagram_enable_email_report == 'on') echo "checked"; ?> />
2043
- <label for="sb_instagram_enable_email_report"><?php _e('Yes', 'instagram-feed'); ?></label>
2044
- <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
2045
- <p class="sbi_tooltip"><?php _e("Instagram Feed will send a weekly notification email using your site's wp_mail() function if one or more of your feeds is not updating or is not displaying. If you're not receiving the emails in your inbox, you may need to configure an SMTP service using another plugin like WP Mail SMTP.", 'instagram-feed'); ?></p>
2046
-
2047
- <div class="sb_instagram_box" style="display: block;">
2048
- <div class="sb_instagram_box_setting">
2049
- <label><?php _e('Schedule Weekly on', 'instagram-feed'); ?></label><br>
2050
- <?php
2051
- $schedule_options = array(
2052
- array(
2053
- 'val' => 'monday',
2054
- 'label' => __( 'Monday', 'instagram-feed' )
2055
- ),
2056
- array(
2057
- 'val' => 'tuesday',
2058
- 'label' => __( 'Tuesday', 'instagram-feed' )
2059
- ),
2060
- array(
2061
- 'val' => 'wednesday',
2062
- 'label' => __( 'Wednesday', 'instagram-feed' )
2063
- ),
2064
- array(
2065
- 'val' => 'thursday',
2066
- 'label' => __( 'Thursday', 'instagram-feed' )
2067
- ),
2068
- array(
2069
- 'val' => 'friday',
2070
- 'label' => __( 'Friday', 'instagram-feed' )
2071
- ),
2072
- array(
2073
- 'val' => 'saturday',
2074
- 'label' => __( 'Saturday', 'instagram-feed' )
2075
- ),
2076
- array(
2077
- 'val' => 'sunday',
2078
- 'label' => __( 'Sunday', 'instagram-feed' )
2079
- ),
2080
- );
2081
-
2082
- if ( isset( $_GET['flag'] ) ){
2083
- echo '<span id="sbi-goto"></span>';
2084
- }
2085
- ?>
2086
- <select name="sb_instagram_email_notification" id="sb_instagram_email_notification">
2087
- <?php foreach ( $schedule_options as $schedule_option ) : ?>
2088
- <option value="<?php echo esc_attr( $schedule_option['val'] ) ; ?>" <?php if ( $schedule_option['val'] === $sb_instagram_email_notification ) { echo 'selected';} ?>><?php echo esc_html( $schedule_option['label'] ) ; ?></option>
2089
- <?php endforeach; ?>
2090
- </select>
2091
- </div>
2092
- <div class="sb_instagram_box_setting">
2093
- <label><?php _e('Email Recipients', 'instagram-feed'); ?></label><br><input class="regular-text" type="text" name="sb_instagram_email_notification_addresses" value="<?php echo esc_attr( $sb_instagram_email_notification_addresses ); ?>"><span class="sbi_note"><?php _e('separate multiple emails with commas', 'instagram-feed'); ?></span>
2094
- <br><br><?php _e( 'Emails not working?', 'instagram-feed' ) ?> <a href="https://smashballoon.com/email-report-is-not-in-my-inbox/" target="_blank"><?php _e( 'See our related FAQ', 'instagram-feed' ) ?></a>
2095
- </div>
2096
- </div>
2097
-
2098
- </td>
2099
- </tr>
2100
- </tbody>
2101
- </table>
2102
-
2103
- <?php submit_button(); ?>
2104
-
2105
- </form>
2106
-
2107
- <p><i class="fa fa-chevron-circle-right" aria-hidden="true"></i>&nbsp; <?php _e('Next Step: <a href="?page=sb-instagram-feed&tab=display">Display your Feed</a>', 'instagram-feed'); ?></p>
2108
-
2109
- <p><i class="fa fa-life-ring" aria-hidden="true"></i>&nbsp; <?php _e('Need help setting up the plugin? Check out our <a href="https://smashballoon.com/instagram-feed/free/?utm_campaign=instagram-free&utm_source=settings&utm_medium=display" target="_blank">setup directions</a>', 'instagram-feed'); ?></p>
2110
-
2111
-
2112
- <?php } //End Customize tab ?>
2113
-
2114
-
2115
-
2116
- <?php if( $sbi_active_tab == 'display' ) { //Start Display tab ?>
2117
-
2118
- <h3><?php _e('Display your Feed', 'instagram-feed'); ?></h3>
2119
- <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:", 'instagram-feed'); ?></p>
2120
- <input type="text" value="[instagram-feed]" size="16" 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).', 'instagram-feed'); ?>" />
2121
-
2122
- <h3 style="padding-top: 10px;"><?php _e( 'Multiple Feeds', 'instagram-feed' ); ?></h3>
2123
- <p><?php _e("If you'd like to display multiple feeds then you can set different settings directly in the shortcode like so:", 'instagram-feed'); ?>
2124
- <code>[instagram-feed num=9 cols=3]</code></p>
2125
- <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:', 'instagram-feed' ); ?><br />
2126
- <code>[instagram-feed]</code><br />
2127
- <code>[instagram-feed num=4 cols=4 showfollow=false]</code><br />
2128
- <code>[instagram-feed accesstoken="ANOTHER_ACCESS_TOKEN"]</code>
2129
- </p>
2130
- <p><?php _e("See the table below for a full list of available shortcode options:", 'instagram-feed'); ?></p>
2131
-
2132
- <p><span class="sbi_table_key"></span><?php _e('Pro version only', 'instagram-feed'); ?></p>
2133
-
2134
- <table class="sbi_shortcode_table">
2135
- <tbody>
2136
- <tr valign="top">
2137
- <th scope="row"><?php _e('Shortcode option', 'instagram-feed'); ?></th>
2138
- <th scope="row"><?php _e('Description', 'instagram-feed'); ?></th>
2139
- <th scope="row"><?php _e('Example', 'instagram-feed'); ?></th>
2140
- </tr>
2141
-
2142
- <tr class="sbi_table_header"><td colspan=3><?php _e("Configure Options", 'instagram-feed'); ?></td></tr>
2143
- <tr class="sbi_pro">
2144
- <td>type</td>
2145
- <td><?php _e("Display photos from a User ID (user)<br />Display posts from a Hashtag (hashtag)", 'instagram-feed'); ?><br /><?php _e("Display photos that the account was tagged in (tagged)", 'instagram-feed'); ?></td>
2146
- <td><code>[instagram-feed type=user]</code><br /><code>[instagram-feed type=hashtag]</code><br /><code>[instagram-feed type=tagged]</code></td>
2147
- </tr>
2148
- <tr>
2149
- <td>user</td>
2150
- <td><?php _e('Your Instagram User Name. This must be from a connected account on the "Configure" tab.', 'instagram-feed'); ?></td>
2151
- <td><code>[instagram-feed user="smashballoon"]</code></td>
2152
- </tr>
2153
- <tr class="sbi_pro">
2154
- <td>hashtag</td>
2155
- <td><?php _e('Any hashtag. Separate multiple hashtags by commas.', 'instagram-feed'); ?></td>
2156
- <td><code>[instagram-feed hashtag="#awesome"]</code></td>
2157
- </tr>
2158
- <tr class="sbi_pro">
2159
- <td>tagged</td>
2160
- <td><?php _e('Your Instagram User Name. Separate multiple users by commas.', 'instagram-feed'); ?></td>
2161
- <td><code>[instagram-feed tagged="smashballoon"]</code></td>
2162
- </tr>
2163
-
2164
- <tr class="sbi_table_header"><td colspan=3><?php _e("Customize Options", 'instagram-feed'); ?></td></tr>
2165
- <tr>
2166
- <td>width</td>
2167
- <td><?php _e("The width of your feed. Any number.", 'instagram-feed'); ?></td>
2168
- <td><code>[instagram-feed width=50]</code></td>
2169
- </tr>
2170
- <tr>
2171
- <td>widthunit</td>
2172
- <td><?php _e("The unit of the width. 'px' or '%'", 'instagram-feed'); ?></td>
2173
- <td><code>[instagram-feed widthunit=%]</code></td>
2174
- </tr>
2175
- <tr>
2176
- <td>height</td>
2177
- <td><?php _e("The height of your feed. Any number.", 'instagram-feed'); ?></td>
2178
- <td><code>[instagram-feed height=250]</code></td>
2179
- </tr>
2180
- <tr>
2181
- <td>heightunit</td>
2182
- <td><?php _e("The unit of the height. 'px' or '%'", 'instagram-feed'); ?></td>
2183
- <td><code>[instagram-feed heightunit=px]</code></td>
2184
- </tr>
2185
- <tr>
2186
- <td>background</td>
2187
- <td><?php _e("The background color of the feed. Any hex color code.", 'instagram-feed'); ?></td>
2188
- <td><code>[instagram-feed background=#ffff00]</code></td>
2189
- </tr>
2190
- <tr>
2191
- <td>class</td>
2192
- <td><?php _e("Add a CSS class to the feed container", 'instagram-feed'); ?></td>
2193
- <td><code>[instagram-feed class=feedOne]</code></td>
2194
- </tr>
2195
-
2196
- <tr class="sbi_table_header"><td colspan=3><?php _e("Layout Options", 'instagram-feed'); ?></td></tr>
2197
- <tr class="sbi_pro">
2198
- <td>layout</td>
2199
- <td><?php _e("How posts are arranged visually in the feed. There are four layouts: Grid, Carousel Slider, Masonry Grid, or Highlight Grid. Options:", 'instagram-feed' ); ?> 'grid', 'carousel', 'masonry', or 'highlight'</td>
2200
- <td><code>[instagram-feed layout=grid]</code></td>
2201
- </tr>
2202
- <tr>
2203
- <td>num</td>
2204
- <td><?php _e("The number of photos to display initially. Maximum is 33.", 'instagram-feed'); ?></td>
2205
- <td><code>[instagram-feed num=10]</code></td>
2206
- </tr>
2207
- <tr class="sbi_pro">
2208
- <td>nummobile</td>
2209
- <td><?php _e("The number of photos to display initially for mobile screens (smaller than 480 pixels).", 'instagram-feed'); ?></td>
2210
- <td><code>[instagram-feed nummobile=6]</code></td>
2211
- </tr>
2212
- <tr>
2213
- <td>cols</td>
2214
- <td><?php _e("The number of columns in your feed. 1 - 10.", 'instagram-feed'); ?></td>
2215
- <td><code>[instagram-feed cols=5]</code></td>
2216
- </tr>
2217
- <tr class="sbi_pro">
2218
- <td>colsmobile</td>
2219
- <td><?php _e("The number of columns in your feed for mobile screens (smaller than 480 pixels).", 'instagram-feed'); ?></td>
2220
- <td><code>[instagram-feed colsmobile=2]</code></td>
2221
- </tr>
2222
- <tr>
2223
- <td>imagepadding</td>
2224
- <td><?php _e("The spacing around your photos", 'instagram-feed'); ?></td>
2225
- <td><code>[instagram-feed imagepadding=10]</code></td>
2226
- </tr>
2227
- <tr>
2228
- <td>imagepaddingunit</td>
2229
- <td><?php _e("The unit of the padding. 'px' or '%'", 'instagram-feed'); ?></td>
2230
- <td><code>[instagram-feed imagepaddingunit=px]</code></td>
2231
- </tr>
2232
-
2233
- <tr class="sbi_table_header"><td colspan=3><?php _e("Carousel Options", 'instagram-feed'); ?></td></tr>
2234
- <tr class="sbi_pro">
2235
- <td>carouselrows</td>
2236
- <td><?php _e("Choose 1 or 2 rows of posts in the carousel", 'instagram-feed'); ?></td>
2237
- <td><code>[instagram-feed carouselrows=1]</code></td>
2238
- </tr>
2239
- <tr class="sbi_pro">
2240
- <td>carouselloop</td>
2241
- <td><?php _e("Infinitely loop through posts or rewind", 'instagram-feed'); ?></td>
2242
- <td><code>[instagram-feed carouselloop=rewind]</code></td>
2243
- </tr>
2244
- <tr class="sbi_pro">
2245
- <td>carouselarrows</td>
2246
- <td><?php _e("Display directional arrows on the carousel", 'instagram-feed'); ?></td>
2247
- <td><code>[instagram-feed carouselarrows=true]</code></td>
2248
- </tr>
2249
- <tr class="sbi_pro">
2250
- <td>carouselpag</td>
2251
- <td><?php _e("Display pagination links below the carousel", 'instagram-feed'); ?></td>
2252
- <td><code>[instagram-feed carouselpag=true]</code></td>
2253
- </tr>
2254
- <tr class="sbi_pro">
2255
- <td>carouselautoplay</td>
2256
- <td><?php _e("Make the carousel autoplay", 'instagram-feed'); ?></td>
2257
- <td><code>[instagram-feed carouselautoplay=true]</code></td>
2258
- </tr>
2259
- <tr class="sbi_pro">
2260
- <td>carouseltime</td>
2261
- <td><?php _e("The interval time between slides for autoplay. Time in miliseconds.", 'instagram-feed'); ?></td>
2262
- <td><code>[instagram-feed carouseltime=8000]</code></td>
2263
- </tr>
2264
-
2265
- <tr class="sbi_table_header"><td colspan=3><?php _e("Highlight Options", 'instagram-feed'); ?></td></tr>
2266
- <tr class="sbi_pro">
2267
- <td>highlighttype</td>
2268
- <td><?php _e("Choose from 3 different ways of highlighting posts including by pattern, hashtag, post id or. Options:", 'instagram-feed'); ?> 'pattern', 'hashtag', 'id'.</td>
2269
- <td><code>[instagram-feed highlighttype=hashtag]</code></td>
2270
- </tr>
2271
- <tr class="sbi_pro">
2272
- <td>highlightpattern</td>
2273
- <td><?php _e("How often a post is highlighted.", 'instagram-feed'); ?></td>
2274
- <td><code>[instagram-feed highlightpattern=7]</code></td>
2275
- </tr>
2276
- <tr class="sbi_pro">
2277
- <td>highlightoffset</td>
2278
- <td><?php _e("When to start the highlight pattern.", 'instagram-feed'); ?></td>
2279
- <td><code>[instagram-feed highlightoffset=3]</code></td>
2280
- </tr>
2281
- <tr class="sbi_pro">
2282
- <td>highlighthashtag</td>
2283
- <td><?php _e("Highlight posts with these hashtags.", 'instagram-feed'); ?></td>
2284
- <td><code>[instagram-feed highlighthashtag=best]</code></td>
2285
- </tr>
2286
-
2287
-
2288
-
2289
-
2290
-
2291
- <tr class="sbi_table_header"><td colspan=3><?php _e("Photos Options", 'instagram-feed'); ?></td></tr>
2292
- <tr>
2293
- <td>sortby</td>
2294
- <td><?php _e("Sort the posts by Newest to Oldest (none) or Random (random)", 'instagram-feed'); ?></td>
2295
- <td><code>[instagram-feed sortby=random]</code></td>
2296
- </tr>
2297
- <tr>
2298
- <td>imageres</td>
2299
- <td><?php _e("The resolution/size of the photos including full, medium, thumbnail, and auto (based on size of image on page). Options:", 'instagram-feed'); ?> 'auto', full', 'medium' or 'thumb'.</td>
2300
- <td><code>[instagram-feed imageres=full]</code></td>
2301
- </tr>
2302
- <tr class="sbi_pro">
2303
- <td>media</td>
2304
- <td><?php _e("Display all media, only photos, or only videos", 'instagram-feed'); ?></td>
2305
- <td><code>[instagram-feed media=photos]</code></td>
2306
- </tr>
2307
- <tr class="sbi_pro">
2308
- <td>disablelightbox</td>
2309
- <td><?php _e("Whether to disable the photo Lightbox. It is enabled by default.", 'instagram-feed'); ?></td>
2310
- <td><code>[instagram-feed disablelightbox=true]</code></td>
2311
- </tr>
2312
- <tr>
2313
- <td>disablemobile</td>
2314
- <td><?php _e("Disable the mobile layout. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2315
- <td><code>[instagram-feed disablemobile=true]</code></td>
2316
- </tr>
2317
- <tr class="sbi_pro">
2318
- <td>captionlinks</td>
2319
- <td><?php _e("Whether to use urls in captions for the photo's link instead of linking to instagram.com.", 'instagram-feed'); ?></td>
2320
- <td><code>[instagram-feed captionlinks=true]</code></td>
2321
- </tr>
2322
-
2323
- <tr class="sbi_table_header"><td colspan=3><?php _e("Lightbox Comments Options", 'instagram-feed'); ?></td></tr>
2324
- <tr class="sbi_pro">
2325
- <td>lightboxcomments</td>
2326
- <td><?php _e("Whether to show comments in the lightbox for this feed.", 'instagram-feed'); ?></td>
2327
- <td><code>[instagram-feed lightboxcomments=true]</code></td>
2328
- </tr>
2329
- <tr class="sbi_pro">
2330
- <td>numcomments</td>
2331
- <td><?php _e("Number of comments to show starting from the most recent.", 'instagram-feed'); ?></td>
2332
- <td><code>[instagram-feed numcomments=10]</code></td>
2333
- </tr>
2334
-
2335
- <tr class="sbi_table_header"><td colspan=3><?php _e("Photos Hover Style Options", 'instagram-feed'); ?></td></tr>
2336
- <tr class="sbi_pro">
2337
- <td>hovercolor</td>
2338
- <td><?php _e("The background color when hovering over a photo. Any hex color code.", 'instagram-feed'); ?></td>
2339
- <td><code>[instagram-feed hovercolor=#ff0000]</code></td>
2340
- </tr>
2341
- <tr class="sbi_pro">
2342
- <td>hovertextcolor</td>
2343
- <td><?php _e("The text/icon color when hovering over a photo. Any hex color code.", 'instagram-feed'); ?></td>
2344
- <td><code>[instagram-feed hovertextcolor=#fff]</code></td>
2345
- </tr>
2346
- <tr class="sbi_pro">
2347
- <td>hoverdisplay</td>
2348
- <td><?php _e("The info to display when hovering over the photo such as the user name, post date, Instagram icon, location, caption, and like counts. Options:", 'instagram-feed'); ?><br />username, date, instagram, location, caption, likes</td>
2349
- <td><code>[instagram-feed hoverdisplay="date, location, likes"]</code></td>
2350
- </tr>
2351
-
2352
- <tr class="sbi_table_header"><td colspan=3><?php _e("Header Options", 'instagram-feed'); ?></td></tr>
2353
- <tr>
2354
- <td>showheader</td>
2355
- <td><?php _e("Whether to show the feed Header. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2356
- <td><code>[instagram-feed showheader=false]</code></td>
2357
- </tr>
2358
- <tr>
2359
- <td>showbio</td>
2360
- <td><?php _e("Display the bio in the header. Options:", 'instagram-feed'); ?> 'true' or 'false'</td>
2361
- <td><code>[instagram-feed showbio=true]</code></td>
2362
- </tr>
2363
- <tr>
2364
- <td>custombio</td>
2365
- <td><?php _e("Display a custom bio in the header", 'instagram-feed'); ?></td>
2366
- <td><code>[instagram-feed custombio="My custom bio."]</code></td>
2367
- </tr>
2368
- <tr>
2369
- <td>customavatar</td>
2370
- <td><?php _e("Display a custom avatar in the header. Enter the full URL of an image file.", 'instagram-feed'); ?></td>
2371
- <td><code>[instagram-feed customavatar="https://example.com/avatar.jpg"]</code></td>
2372
- </tr>
2373
- <tr>
2374
- <td>headersize</td>
2375
- <td><?php _e("Size of the header including small, medium and large. Options:", 'instagram-feed'); ?> small, medium, or large.</td>
2376
- <td><code>[instagram-feed headersize=medium]</code></td>
2377
- </tr>
2378
- <tr>
2379
- <td>headercolor</td>
2380
- <td><?php _e("The color of the Header text. Any hex color code.", 'instagram-feed'); ?></td>
2381
- <td><code>[instagram-feed headercolor=#333]</code></td>
2382
- </tr>
2383
-
2384
- <tr class="sbi_table_header"><td colspan=3><?php _e("'Load More' Button Options", 'instagram-feed'); ?></td></tr>
2385
- <tr>
2386
- <td>showbutton</td>
2387
- <td><?php _e("Whether to show the 'Load More' button. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2388
- <td><code>[instagram-feed showbutton=false]</code></td>
2389
- </tr>
2390
- <tr>
2391
- <td>buttoncolor</td>
2392
- <td><?php _e("The background color of the button. Any hex color code.", 'instagram-feed'); ?></td>
2393
- <td><code>[instagram-feed buttoncolor=#000]</code></td>
2394
- </tr>
2395
- <tr>
2396
- <td>buttontextcolor</td>
2397
- <td><?php _e("The text color of the button. Any hex color code.", 'instagram-feed'); ?></td>
2398
- <td><code>[instagram-feed buttontextcolor=#fff]</code></td>
2399
- </tr>
2400
- <tr>
2401
- <td>buttontext</td>
2402
- <td><?php _e("The text used for the button.", 'instagram-feed'); ?></td>
2403
- <td><code>[instagram-feed buttontext="Load More Photos"]</code></td>
2404
- </tr>
2405
-
2406
- <tr class="sbi_table_header"><td colspan=3><?php _e("'Follow on Instagram' Button Options", 'instagram-feed'); ?></td></tr>
2407
- <tr>
2408
- <td>showfollow</td>
2409
- <td><?php _e("Whether to show the 'Follow on Instagram' button. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2410
- <td><code>[instagram-feed showfollow=false]</code></td>
2411
- </tr>
2412
- <tr>
2413
- <td>followcolor</td>
2414
- <td><?php _e("The background color of the button. Any hex color code.", 'instagram-feed'); ?></td>
2415
- <td><code>[instagram-feed followcolor=#ff0000]</code></td>
2416
- </tr>
2417
- <tr>
2418
- <td>followtextcolor</td>
2419
- <td><?php _e("The text color of the button. Any hex color code.", 'instagram-feed'); ?></td>
2420
- <td><code>[instagram-feed followtextcolor=#fff]</code></td>
2421
- </tr>
2422
- <tr>
2423
- <td>followtext</td>
2424
- <td><?php _e("The text used for the button.", 'instagram-feed'); ?></td>
2425
- <td><code>[instagram-feed followtext="Follow me"]</code></td>
2426
- </tr>
2427
-
2428
- <tr class="sbi_table_header"><td colspan=3><?php _e("Caption Options", 'instagram-feed'); ?></td></tr>
2429
- <tr class="sbi_pro">
2430
- <td>showcaption</td>
2431
- <td><?php _e("Whether to show the photo caption. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2432
- <td><code>[instagram-feed showcaption=false]</code></td>
2433
- </tr>
2434
- <tr class="sbi_pro">
2435
- <td>captionlength</td>
2436
- <td><?php _e("The number of characters of the caption to display", 'instagram-feed'); ?></td>
2437
- <td><code>[instagram-feed captionlength=50]</code></td>
2438
- </tr>
2439
- <tr class="sbi_pro">
2440
- <td>captioncolor</td>
2441
- <td><?php _e("The text color of the caption. Any hex color code.", 'instagram-feed'); ?></td>
2442
- <td><code>[instagram-feed captioncolor=#000]</code></td>
2443
- </tr>
2444
- <tr class="sbi_pro">
2445
- <td>captionsize</td>
2446
- <td><?php _e("The size of the caption text. Any number.", 'instagram-feed'); ?></td>
2447
- <td><code>[instagram-feed captionsize=24]</code></td>
2448
- </tr>
2449
-
2450
- <tr class="sbi_table_header"><td colspan=3><?php _e("Likes &amp; Comments Options", 'instagram-feed'); ?></td></tr>
2451
- <tr class="sbi_pro">
2452
- <td>showlikes</td>
2453
- <td><?php _e("Whether to show the Likes &amp; Comments. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2454
- <td><code>[instagram-feed showlikes=false]</code></td>
2455
- </tr>
2456
- <tr class="sbi_pro">
2457
- <td>likescolor</td>
2458
- <td><?php _e("The color of the Likes &amp; Comments. Any hex color code.", 'instagram-feed'); ?></td>
2459
- <td><code>[instagram-feed likescolor=#FF0000]</code></td>
2460
- </tr>
2461
- <tr class="sbi_pro">
2462
- <td>likessize</td>
2463
- <td><?php _e("The size of the Likes &amp; Comments. Any number.", 'instagram-feed'); ?></td>
2464
- <td><code>[instagram-feed likessize=14]</code></td>
2465
- </tr>
2466
-
2467
- <tr class="sbi_table_header"><td colspan=3><?php _e("Post Filtering Options", 'instagram-feed'); ?></td></tr>
2468
- <tr class="sbi_pro">
2469
- <td>excludewords</td>
2470
- <td><?php _e("Remove posts which contain certain words or hashtags in the caption.", 'instagram-feed'); ?></td>
2471
- <td><code>[instagram-feed excludewords="bad, words"]</code></td>
2472
- </tr>
2473
- <tr class="sbi_pro">
2474
- <td>includewords</td>
2475
- <td><?php _e("Only display posts which contain certain words or hashtags in the caption.", 'instagram-feed'); ?></td>
2476
- <td><code>[instagram-feed includewords="sunshine"]</code></td>
2477
- </tr>
2478
-
2479
- <tr class="sbi_table_header"><td colspan=3><?php _e("Auto Load More on Scroll", 'instagram-feed'); ?></td></tr>
2480
- <tr class="sbi_pro">
2481
- <td>autoscroll</td>
2482
- <td><?php _e("Load more posts automatically as the user scrolls down the page.", 'instagram-feed'); ?></td>
2483
- <td><code>[instagram-feed autoscroll=true]</code></td>
2484
- </tr>
2485
- <tr class="sbi_pro">
2486
- <td>autoscrolldistance</td>
2487
- <td><?php _e("Distance before the end of feed or page that triggers the loading of more posts.", 'instagram-feed'); ?></td>
2488
- <td><code>[instagram-feed autoscrolldistance=200]</code></td>
2489
- </tr>
2490
-
2491
- </tbody>
2492
- </table>
2493
-
2494
- <p><i class="fa fa-life-ring" aria-hidden="true"></i>&nbsp; <?php _e('Need help setting up the plugin? Check out our <a href="https://smashballoon.com/instagram-feed/free/?utm_campaign=instagram-free&utm_source=display&utm_medium=supportsetup" target="_blank">setup directions</a>', 'instagram-feed'); ?></p>
2495
-
2496
- <?php } //End Display tab ?>
2497
-
2498
-
2499
- <?php if( $sbi_active_tab == 'support' ) { //Start Support tab ?>
2500
-
2501
- <div class="sbi_support">
2502
-
2503
- <br/>
2504
- <h3 style="padding-bottom: 10px;"><?php _e("Need help?", 'instagram-feed'); ?></h3>
2505
-
2506
- <p>
2507
- <span class="sbi-support-title"><i class="fa fa-life-ring" aria-hidden="true"></i>&nbsp; <a
2508
- href="https://smashballoon.com/instagram-feed/free/?utm_campaign=instagram-free&utm_source=settings&utm_medium=general"
2509
- target="_blank"><?php _e( 'Setup Directions', 'instagram-feed' ); ?></a></span>
2510
- <?php _e( 'A step-by-step guide on how to setup and use the plugin.', 'instagram-feed' ); ?>
2511
- </p>
2512
-
2513
- <p>
2514
- <span class="sbi-support-title"><i class="fa fa-youtube-play" aria-hidden="true"></i>&nbsp; <a
2515
- href="https://www.youtube.com/embed/q6ZXVU4g970" target="_blank"
2516
- id="sbi-play-support-video"><?php _e( 'Watch a Video', 'instagram-feed' ); ?></a></span>
2517
- <?php _e( "Watch a short video demonstrating how to set up, customize and use the plugin.<br /><b>Please note</b> that the video shows the set up and use of the <b><a href='https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=general' target='_blank'>Pro version</a></b> of the plugin, but the process is the same for this free version. The only difference is some of the features available.", 'instagram-feed' ); ?>
2518
-
2519
- <iframe id="sbi-support-video"
2520
- src="//www.youtube.com/embed/q6ZXVU4g970?theme=light&amp;showinfo=0&amp;controls=2" width="960"
2521
- height="540" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
2522
- </p>
2523
-
2524
- <p>
2525
- <span class="sbi-support-title"><i class="fa fa-question-circle" aria-hidden="true"></i>&nbsp; <a
2526
- href="https://smashballoon.com/instagram-feed/support/faq/?utm_campaign=instagram-free&utm_source=support&utm_medium=faqs"
2527
- target="_blank"><?php _e( 'FAQs and Docs', 'instagram-feed' ); ?></a></span>
2528
- <?php _e( 'View our expansive library of FAQs and documentation to help solve your problem as quickly as possible.', 'instagram-feed' ); ?>
2529
- </p>
2530
-
2531
- <div class="sbi-support-faqs">
2532
-
2533
- <ul>
2534
- <li><b><?php _e( 'FAQs', 'instagram-feed' ); ?></b></li>
2535
- <li>&bull;&nbsp; <?php _e( '<a href="https://smashballoon.com/my-photos-wont-load/?utm_campaign=instagram-free&utm_source=support&utm_medium=faqsnophotos" target="_blank">My Instagram Feed Won\'t Load</a>', 'instagram-feed' ); ?></li>
2536
- <li>&bull;&nbsp; <?php _e( '<a href="https://smashballoon.com/my-instagram-access-token-keep-expiring/?utm_campaign=instagram-free&utm_source=support&utm_medium=faqsexpiring" target="_blank">My Access Token Keeps Expiring</a>', 'instagram-feed' ); ?></li>
2537
- <li style="margin-top: 8px; font-size: 12px;"><a href="https://smashballoon.com/instagram-feed/support/faq/?utm_campaign=instagram-free&utm_source=support&utm_medium=faqs" target="_blank"><?php _e( 'See All', 'instagram-feed' ); ?><i class="fa fa-chevron-right" aria-hidden="true"></i></a></li>
2538
- </ul>
2539
-
2540
- <ul>
2541
- <li><b><?php _e("Documentation", 'instagram-feed'); ?></b></li>
2542
- <li>&bull;&nbsp; <?php _e( '<a href="https://smashballoon.com/instagram-feed/free?utm_campaign=instagram-free&utm_source=support&utm_medium=installation" target="_blank">Installation and Configuration</a>', 'instagram-feed' ); ?></li>
2543
- <li>&bull;&nbsp; <?php _e( '<a href="https://smashballoon.com/display-multiple-instagram-feeds/?utm_campaign=instagram-free&utm_source=support&utm_medium=multiple" target="_blank">Displaying multiple feeds</a>', 'instagram-feed' ); ?></li>
2544
- <li>&bull;&nbsp; <?php _e( '<a href="https://smashballoon.com/instagram-feed-faq/customization/?utm_campaign=instagram-free&utm_source=support&utm_medium=customizing" target="_blank">Customizing your Feed</a>', 'instagram-feed' ); ?></li>
2545
- </ul>
2546
- </div>
2547
-
2548
- <p>
2549
- <span class="sbi-support-title"><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp; <a
2550
- href="https://smashballoon.com/instagram-feed/support/?utm_campaign=instagram-free&utm_source=support&utm_medium=contact"
2551
- target="_blank"><?php _e( 'Request Support', 'instagram-feed' ); ?></a></span>
2552
- <?php _e( 'Still need help? Submit a ticket and one of our support experts will get back to you as soon as possible.<br /><b>Important:</b> Please include your <b>System Info</b> below with all support requests.', 'instagram-feed' ); ?>
2553
- </p>
2554
- </div>
2555
-
2556
- <hr />
2557
-
2558
- <h3><?php _e('System Info &nbsp; <i style="color: #666; font-size: 11px; font-weight: normal;">Click the text below to select all</i>', 'instagram-feed'); ?></h3>
2559
-
2560
-
2561
-
2562
-
2563
- <?php $sbi_options = get_option('sb_instagram_settings'); ?>
2564
- <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: 100%; max-width: 960px; height: 500px; white-space: pre; font-family: Menlo,Monaco,monospace;">
2565
- ## SITE/SERVER INFO: ##
2566
- Site URL: <?php echo site_url() . "\n"; ?>
2567
- Home URL: <?php echo home_url() . "\n"; ?>
2568
- WordPress Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
2569
- PHP Version: <?php echo PHP_VERSION . "\n"; ?>
2570
- Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
2571
-
2572
- ## ACTIVE PLUGINS: ##
2573
- <?php
2574
- $plugins = get_plugins();
2575
- $active_plugins = get_option( 'active_plugins', array() );
2576
-
2577
- foreach ( $plugins as $plugin_path => $plugin ) {
2578
- // If the plugin isn't active, don't show it.
2579
- if ( ! in_array( $plugin_path, $active_plugins ) )
2580
- continue;
2581
-
2582
- echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
2583
- }
2584
- ?>
2585
-
2586
- ## PLUGIN SETTINGS: ##
2587
- sb_instagram_plugin_type => Instagram Feed Free
2588
- <?php
2589
- global $wpdb;
2590
- foreach( $sbi_options as $key => $val ) {
2591
- if ( $key !== 'connected_accounts' ) {
2592
- if ( is_array( $val ) ) {
2593
- foreach ( $val as $item ) {
2594
- if ( is_array( $item ) ) {
2595
- foreach ( $item as $key2 => $val2 ) {
2596
- echo "$key2 => $val2\n";
2597
- }
2598
- } else {
2599
- echo "$key => $item\n";
2600
- }
2601
- }
2602
- } else {
2603
- echo "$key => $val\n";
2604
- }
2605
- }
2606
-
2607
- }
2608
- ?>
2609
-
2610
- ## CONNECTED ACCOUNTS: ##<?php echo "\n";
2611
- $con_accounts = isset( $sbi_options['connected_accounts'] ) ? $sbi_options['connected_accounts'] : array();
2612
- $business_accounts = array();
2613
- $basic_accounts = array();
2614
- if ( ! empty( $con_accounts ) ) {
2615
- foreach ( $con_accounts as $account ) {
2616
- $type = isset( $account['type'] ) ? $account['type'] : 'personal';
2617
-
2618
- if ( $type === 'business' ) {
2619
- $business_accounts[] = $account;
2620
- } elseif ( $type === 'basic' ) {
2621
- $basic_accounts[] = $account;
2622
- }
2623
- echo '*' . $account['user_id'] . '*' . "\n";
2624
- var_export( $account );
2625
- echo "\n";
2626
- }
2627
- }
2628
- ?>
2629
-
2630
- ## API RESPONSE: ##
2631
- <?php
2632
- $first_con_basic_account = isset( $basic_accounts[0] ) ? $basic_accounts[0] : array();
2633
- $first_con_business_account = isset( $business_accounts[0] ) ? $business_accounts[0] : array();
2634
-
2635
- if ( ! empty( $first_con_basic_account ) ) {
2636
- echo '*BASIC ACCOUNT*';
2637
- echo "\n";
2638
- $connection = new SB_Instagram_API_Connect( $first_con_basic_account, 'header' );
2639
- $connection->connect();
2640
- if ( ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
2641
- foreach ( $connection->get_data() as $key => $item ) {
2642
- if ( is_array ( $item ) ) {
2643
- foreach ( $item as $key2 => $item2 ) {
2644
- echo $key2 . ' => ' . esc_html( $item2 ) . "\n";
2645
- }
2646
- } else {
2647
- echo $key . ' => ' . esc_html( $item ) . "\n";
2648
- }
2649
- }
2650
- } else {
2651
- if ( $connection->is_wp_error() ) {
2652
- $response = $connection->get_wp_error();
2653
- if ( isset( $response ) && isset( $response->errors ) ) {
2654
- foreach ( $response->errors as $key => $item ) {
2655
- echo $key . ' => ' . $item[0] . "\n";
2656
- }
2657
- }
2658
- } else {
2659
- $error = $connection->get_data();
2660
- var_export( $error );
2661
- }
2662
- }
2663
- echo "\n";
2664
- } else {
2665
- echo 'no connected basic accounts';
2666
- echo "\n";
2667
- }
2668
- if ( ! empty( $first_con_business_account ) ) {
2669
- echo '*BUSINESS ACCOUNT*';
2670
- echo "\n";
2671
- $connection = new SB_Instagram_API_Connect( $first_con_business_account, 'header' );
2672
- $connection->connect();
2673
- if ( ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
2674
- foreach ( $connection->get_data() as $key => $item ) {
2675
- if ( is_array ( $item ) ) {
2676
- foreach ( $item as $key2 => $item2 ) {
2677
- echo $key2 . ' => ' . esc_html( $item2 ) . "\n";
2678
- }
2679
- } else {
2680
- echo $key . ' => ' . esc_html( $item ) . "\n";
2681
- }
2682
- }
2683
- } else {
2684
- if ( $connection->is_wp_error() ) {
2685
- $response = $connection->get_wp_error();
2686
- if ( isset( $response ) && isset( $response->errors ) ) {
2687
- foreach ( $response->errors as $key => $item ) {
2688
- echo $key . ' => ' . $item[0] . "\n";
2689
- }
2690
- }
2691
- } else {
2692
- $error = $connection->get_data();
2693
- var_export( $error );
2694
- }
2695
- }
2696
- } else {
2697
- echo 'no connected business accounts';
2698
- } ?>
2699
-
2700
- ## Cron Events: ##
2701
- <?php
2702
- $cron = _get_cron_array();
2703
- foreach ( $cron as $key => $data ) {
2704
- $is_target = false;
2705
- foreach ( $data as $key2 => $val ) {
2706
- if ( strpos( $key2, 'sbi' ) !== false || strpos( $key2, 'sb_instagram' ) !== false ) {
2707
- $is_target = true;
2708
- echo $key2;
2709
- echo "\n";
2710
- }
2711
- }
2712
- if ( $is_target) {
2713
- echo date( "Y-m-d H:i:s", $key );
2714
- echo "\n";
2715
- echo 'Next Scheduled: ' . ((int)$key - time())/60 . ' minutes';
2716
- echo "\n\n";
2717
- }
2718
- }
2719
- ?>
2720
- ## Cron Cache Report: ##
2721
- <?php $cron_report = get_option( 'sbi_cron_report', array() );
2722
- if ( ! empty( $cron_report ) ) {
2723
- var_export( $cron_report );
2724
- }
2725
- echo "\n";
2726
- ?>
2727
-
2728
- ## Access Token Refresh: ##
2729
- <?php $cron_report = get_option( 'sbi_refresh_report', array() );
2730
- if ( ! empty( $cron_report ) ) {
2731
- var_export( $cron_report );
2732
- }
2733
- echo "\n";
2734
- ?>
2735
-
2736
- ## Resizing: ##
2737
- <?php $upload = wp_upload_dir();
2738
- $upload_dir = $upload['basedir'];
2739
- $upload_dir = trailingslashit( $upload_dir ) . SBI_UPLOADS_NAME;
2740
- if ( file_exists( $upload_dir ) ) {
2741
- echo 'upload directory exists';
2742
- } else {
2743
- $created = wp_mkdir_p( $upload_dir );
2744
-
2745
- if ( ! $created ) {
2746
- echo 'cannot create upload directory';
2747
- }
2748
- }
2749
- echo "\n";
2750
- echo "\n";
2751
-
2752
- $table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE );
2753
- $feeds_posts_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS );
2754
-
2755
- if ( $wpdb->get_var( "show tables like '$feeds_posts_table_name'" ) != $feeds_posts_table_name ) {
2756
- echo 'no feeds posts table';
2757
- echo "\n";
2758
-
2759
- } else {
2760
- $last_result = $wpdb->get_results( "SELECT * FROM $feeds_posts_table_name ORDER BY id DESC LIMIT 1;" );
2761
- if ( is_array( $last_result ) && isset( $last_result[0] ) ) {
2762
- echo '*FEEDS POSTS TABLE*';
2763
- echo "\n";
2764
-
2765
- foreach ( $last_result as $column ) {
2766
-
2767
- foreach ( $column as $key => $value ) {
2768
- echo $key . ': ' . esc_html( $value ) . "\n";;
2769
- }
2770
- }
2771
-
2772
- } else {
2773
- echo 'feeds posts has no rows';
2774
- echo "\n";
2775
- }
2776
- }
2777
- echo "\n";
2778
-
2779
- if ( $wpdb->get_var( "show tables like '$table_name'" ) != $table_name ) {
2780
- echo 'no posts table';
2781
- echo "\n";
2782
-
2783
- } else {
2784
-
2785
-
2786
- $last_result = $wpdb->get_results( "SELECT * FROM $table_name ORDER BY id DESC LIMIT 1;" );
2787
- if ( is_array( $last_result ) && isset( $last_result[0] ) ) {
2788
- echo '*POSTS TABLE*';
2789
- echo "\n";
2790
- foreach ( $last_result as $column ) {
2791
-
2792
- foreach ( $column as $key => $value ) {
2793
- echo $key . ': ' . esc_html( $value ) . "\n";;
2794
- }
2795
- }
2796
-
2797
- } else {
2798
- echo 'feeds posts has no rows';
2799
- echo "\n";
2800
- }
2801
- }
2802
-
2803
- ?>
2804
-
2805
- ## Error Log: ##
2806
- <?php
2807
- global $sb_instagram_posts_manager;
2808
- $errors = $sb_instagram_posts_manager->get_errors();
2809
- if ( ! empty( $errors ) ) :
2810
- foreach ( $errors as $type => $error ) :
2811
- echo $type . ': ' . $error[1] . "\n";
2812
- endforeach;
2813
- endif;
2814
- $error_page = $sb_instagram_posts_manager->get_error_page();
2815
- if ( $error_page ) {
2816
- echo 'Feed with error: ' . esc_url( get_the_permalink( $error_page ) ). "\n";
2817
- }
2818
- $ajax_statuses = $sb_instagram_posts_manager->get_ajax_status();
2819
- if ( ! $ajax_statuses['successful'] ) {
2820
- ?>
2821
- ## AJAX Status ##
2822
- <?php
2823
- echo 'test not successful';
2824
- }
2825
- ?>
2826
- </textarea>
2827
- <div><input id="sbi_reset_log" class="button-secondary" type="submit" value="<?php esc_attr_e( 'Reset Error Log' ); ?>" style="vertical-align: middle;"/></div>
2828
-
2829
- <?php
2830
- } //End Support tab
2831
- ?>
2832
-
2833
-
2834
- <div class="sbi_quickstart">
2835
- <h3><i class="fa fa-rocket" aria-hidden="true"></i>&nbsp; <?php _e('Display your feed', 'instagram-feed'); ?></h3>
2836
- <p><?php _e('Copy and paste this shortcode directly into the page, post or widget where you\'d like to display the feed:', 'instagram-feed'); ?> <input type="text" value="[instagram-feed]" size="15" readonly="readonly" style="text-align: center;" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."></p>
2837
- <p><?php _e('Find out how to display <a href="?page=sb-instagram-feed&amp;tab=display">multiple feeds</a>.', 'instagram-feed'); ?></p>
2838
- </div>
2839
-
2840
- <a href="https://smashballoon.com/instagram-feed/demo/?utm_campaign=instagram-free&utm_source=footer&utm_medium=ad" target="_blank" class="sbi-pro-notice">
2841
- <img src="<?php echo SBI_PLUGIN_URL . 'img/instagram-pro-promo.png?2019'; ?>" alt="<?php esc_attr_e( 'Instagram Feed Pro', 'instagram-feed' ); ?>">
2842
- </a>
2843
-
2844
- <p class="sbi_plugins_promo dashicons-before dashicons-admin-plugins"> <?php _e('Check out our other free plugins: <a href="https://wordpress.org/plugins/custom-facebook-feed/" target="_blank">Facebook</a>, <a href="https://wordpress.org/plugins/custom-twitter-feeds/" target="_blank">Twitter</a>, and <a href="https://wordpress.org/plugins/feeds-for-youtube/" target="_blank">YouTube</a>.', 'instagram-feed' ); ?></p>
2845
-
2846
- <div class="sbi_share_plugin">
2847
- <h3><?php _e('Like the plugin? Help spread the word!', 'instagram-feed'); ?></h3>
2848
-
2849
- <button id="sbi_admin_show_share_links" class="button secondary" style="margin-bottom: 1px;"><i class="fa fa-share-alt" aria-hidden="true"></i>&nbsp;&nbsp;Share the plugin</button> <div id="sbi_admin_share_links"></div>
2850
- </div>
2851
-
2852
- </div> <!-- end #sbi_admin -->
2853
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2854
  <?php } //End Settings page
1
+ <?php
2
+ /**
3
+ * Includes functions for all admin page templates and
4
+ * functions that add menu pages in the dashboard. Also
5
+ * has code for saving settings with defaults.
6
+ */
7
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
8
+
9
+ function sb_instagram_menu() {
10
+ $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
11
+
12
+ $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
13
+
14
+ global $sb_instagram_posts_manager;
15
+ $notice = '';
16
+ if ( $sb_instagram_posts_manager->are_critical_errors() ) {
17
+ $notice = ' <span class="update-plugins sbi-error-alert"><span>!</span></span>';
18
+ }
19
+
20
+ add_menu_page(
21
+ __( 'Instagram Feed', 'instagram-feed' ),
22
+ __( 'Instagram Feed', 'instagram-feed' ) . $notice,
23
+ $cap,
24
+ 'sb-instagram-feed',
25
+ 'sb_instagram_settings_page'
26
+ );
27
+ add_submenu_page(
28
+ 'sb-instagram-feed',
29
+ __( 'Settings', 'instagram-feed' ),
30
+ __( 'Settings', 'instagram-feed' ) . $notice,
31
+ $cap,
32
+ 'sb-instagram-feed',
33
+ 'sb_instagram_settings_page'
34
+ );
35
+ add_submenu_page(
36
+ 'sb-instagram-feed',
37
+ __( 'About Us', 'instagram-feed' ),
38
+ __( 'About Us', 'instagram-feed' ),
39
+ $cap,
40
+ 'sb-instagram-feed-about',
41
+ 'sb_instagram_about_page'
42
+ );
43
+ }
44
+ add_action('admin_menu', 'sb_instagram_menu');
45
+
46
+ function sb_instagram_about_page() {
47
+ do_action('sbi_admin_page' );
48
+ }
49
+
50
+ function sb_instagram_settings_page() {
51
+
52
+ //Hidden fields
53
+ $sb_instagram_settings_hidden_field = 'sb_instagram_settings_hidden_field';
54
+ $sb_instagram_configure_hidden_field = 'sb_instagram_configure_hidden_field';
55
+ $sb_instagram_customize_hidden_field = 'sb_instagram_customize_hidden_field';
56
+
57
+ //Declare defaults
58
+ $sb_instagram_settings_defaults = array(
59
+ 'sb_instagram_at' => '',
60
+ 'sb_instagram_user_id' => '',
61
+ 'sb_instagram_preserve_settings' => '',
62
+ 'sb_instagram_cache_time' => 1,
63
+ 'sb_instagram_cache_time_unit' => 'hours',
64
+ 'sbi_caching_type' => 'page',
65
+ 'sbi_cache_cron_interval' => '12hours',
66
+ 'sbi_cache_cron_time' => '1',
67
+ 'sbi_cache_cron_am_pm' => 'am',
68
+ 'sb_instagram_width' => '100',
69
+ 'sb_instagram_width_unit' => '%',
70
+ 'sb_instagram_feed_width_resp' => false,
71
+ 'sb_instagram_height' => '',
72
+ 'sb_instagram_num' => '20',
73
+ 'sb_instagram_height_unit' => '',
74
+ 'sb_instagram_cols' => '4',
75
+ 'sb_instagram_disable_mobile' => false,
76
+ 'sb_instagram_image_padding' => '5',
77
+ 'sb_instagram_image_padding_unit' => 'px',
78
+ 'sb_instagram_sort' => 'none',
79
+ 'sb_instagram_background' => '',
80
+ 'sb_instagram_show_btn' => true,
81
+ 'sb_instagram_btn_background' => '',
82
+ 'sb_instagram_btn_text_color' => '',
83
+ 'sb_instagram_btn_text' => __( 'Load More...', 'instagram-feed' ),
84
+ 'sb_instagram_image_res' => 'auto',
85
+ //Header
86
+ 'sb_instagram_show_header' => true,
87
+ 'sb_instagram_header_size' => 'small',
88
+ 'sb_instagram_header_color' => '',
89
+ 'sb_instagram_custom_bio' => '',
90
+ 'sb_instagram_custom_avatar' => '',
91
+ //Follow button
92
+ 'sb_instagram_show_follow_btn' => true,
93
+ 'sb_instagram_folow_btn_background' => '',
94
+ 'sb_instagram_follow_btn_text_color' => '',
95
+ 'sb_instagram_follow_btn_text' => __( 'Follow on Instagram', 'instagram-feed' ),
96
+ //Misc
97
+ 'sb_instagram_custom_css' => '',
98
+ 'sb_instagram_custom_js' => '',
99
+ 'sb_instagram_cron' => 'no',
100
+ 'sb_instagram_backup' => true,
101
+ 'sb_ajax_initial' => false,
102
+ 'enqueue_css_in_shortcode' => false,
103
+ 'sb_instagram_ajax_theme' => false,
104
+ 'sb_instagram_disable_resize' => false,
105
+ 'sb_instagram_favor_local' => false,
106
+ 'sb_instagram_minnum' => 0,
107
+ 'disable_js_image_loading' => false,
108
+ 'enqueue_js_in_head' => false,
109
+ 'sb_instagram_disable_mob_swipe' => false,
110
+ 'sbi_font_method' => 'svg',
111
+ 'sb_instagram_disable_awesome' => false,
112
+ 'custom_template' => false,
113
+ 'disable_admin_notice' => false,
114
+ 'enable_email_report' => 'on',
115
+ 'email_notification' => 'monday',
116
+ 'email_notification_addresses' => get_option( 'admin_email' ),
117
+ );
118
+ //Save defaults in an array
119
+ $options = wp_parse_args(get_option('sb_instagram_settings'), $sb_instagram_settings_defaults);
120
+ update_option( 'sb_instagram_settings', $options );
121
+
122
+ //Set the page variables
123
+ $sb_instagram_at = $options[ 'sb_instagram_at' ];
124
+ $sb_instagram_user_id = $options[ 'sb_instagram_user_id' ];
125
+ $sb_instagram_preserve_settings = $options[ 'sb_instagram_preserve_settings' ];
126
+ $sb_instagram_ajax_theme = $options[ 'sb_instagram_ajax_theme' ];
127
+ $enqueue_js_in_head = $options[ 'enqueue_js_in_head' ];
128
+ $disable_js_image_loading = $options[ 'disable_js_image_loading' ];
129
+ $sb_instagram_disable_resize = $options[ 'sb_instagram_disable_resize' ];
130
+ $sb_instagram_favor_local = $options[ 'sb_instagram_favor_local' ];
131
+ $sb_instagram_minnum = $options[ 'sb_instagram_minnum' ];
132
+
133
+ $sb_instagram_cache_time = $options[ 'sb_instagram_cache_time' ];
134
+ $sb_instagram_cache_time_unit = $options[ 'sb_instagram_cache_time_unit' ];
135
+
136
+ $sbi_caching_type = $options[ 'sbi_caching_type' ];
137
+ $sbi_cache_cron_interval = $options[ 'sbi_cache_cron_interval' ];
138
+ $sbi_cache_cron_time = $options[ 'sbi_cache_cron_time' ];
139
+ $sbi_cache_cron_am_pm = $options[ 'sbi_cache_cron_am_pm' ];
140
+
141
+ $sb_instagram_width = $options[ 'sb_instagram_width' ];
142
+ $sb_instagram_width_unit = $options[ 'sb_instagram_width_unit' ];
143
+ $sb_instagram_feed_width_resp = $options[ 'sb_instagram_feed_width_resp' ];
144
+ $sb_instagram_height = $options[ 'sb_instagram_height' ];
145
+ $sb_instagram_height_unit = $options[ 'sb_instagram_height_unit' ];
146
+ $sb_instagram_num = $options[ 'sb_instagram_num' ];
147
+ $sb_instagram_cols = $options[ 'sb_instagram_cols' ];
148
+ $sb_instagram_disable_mobile = $options[ 'sb_instagram_disable_mobile' ];
149
+ $sb_instagram_image_padding = $options[ 'sb_instagram_image_padding' ];
150
+ $sb_instagram_image_padding_unit = $options[ 'sb_instagram_image_padding_unit' ];
151
+ $sb_instagram_sort = $options[ 'sb_instagram_sort' ];
152
+ $sb_instagram_background = $options[ 'sb_instagram_background' ];
153
+ $sb_instagram_show_btn = $options[ 'sb_instagram_show_btn' ];
154
+ $sb_instagram_btn_background = $options[ 'sb_instagram_btn_background' ];
155
+ $sb_instagram_btn_text_color = $options[ 'sb_instagram_btn_text_color' ];
156
+ $sb_instagram_btn_text = $options[ 'sb_instagram_btn_text' ];
157
+ $sb_instagram_image_res = $options[ 'sb_instagram_image_res' ];
158
+ //Header
159
+ $sb_instagram_show_header = $options[ 'sb_instagram_show_header' ];
160
+ $sb_instagram_header_size = $options[ 'sb_instagram_header_size' ];
161
+ $sb_instagram_show_bio = isset( $options[ 'sb_instagram_show_bio' ] ) ? $options[ 'sb_instagram_show_bio' ] : true;
162
+ $sb_instagram_custom_bio = $options[ 'sb_instagram_custom_bio' ];
163
+ $sb_instagram_custom_avatar = $options[ 'sb_instagram_custom_avatar' ];
164
+ $sb_instagram_header_color = $options[ 'sb_instagram_header_color' ];
165
+ //Follow button
166
+ $sb_instagram_show_follow_btn = $options[ 'sb_instagram_show_follow_btn' ];
167
+ $sb_instagram_folow_btn_background = $options[ 'sb_instagram_folow_btn_background' ];
168
+ $sb_instagram_follow_btn_text_color = $options[ 'sb_instagram_follow_btn_text_color' ];
169
+ $sb_instagram_follow_btn_text = $options[ 'sb_instagram_follow_btn_text' ];
170
+ //Misc
171
+ $sb_instagram_custom_css = $options[ 'sb_instagram_custom_css' ];
172
+ $sb_instagram_custom_js = $options[ 'sb_instagram_custom_js' ];
173
+ $sb_instagram_cron = $options[ 'sb_instagram_cron' ];
174
+ $sb_instagram_backup = $options[ 'sb_instagram_backup' ];
175
+ $sb_ajax_initial = $options[ 'sb_ajax_initial' ];
176
+ $enqueue_css_in_shortcode = $options[ 'enqueue_css_in_shortcode' ];
177
+ $sbi_font_method = $options[ 'sbi_font_method' ];
178
+ $sb_instagram_disable_awesome = $options[ 'sb_instagram_disable_awesome' ];
179
+ $sb_instagram_custom_template = $options[ 'custom_template' ];
180
+ $sb_instagram_disable_admin_notice = $options[ 'disable_admin_notice' ];
181
+ $sb_instagram_enable_email_report = $options[ 'enable_email_report' ];
182
+ $sb_instagram_email_notification = $options[ 'email_notification' ];
183
+ $sb_instagram_email_notification_addresses = $options[ 'email_notification_addresses' ];
184
+ //Check nonce before saving data
185
+ if ( ! isset( $_POST['sb_instagram_settings_nonce'] ) || ! wp_verify_nonce( $_POST['sb_instagram_settings_nonce'], 'sb_instagram_saving_settings' ) ) {
186
+ //Nonce did not verify
187
+ } else {
188
+ // See if the user has posted us some information. If they did, this hidden field will be set to 'Y'.
189
+ if( isset($_POST[ $sb_instagram_settings_hidden_field ]) && $_POST[ $sb_instagram_settings_hidden_field ] == 'Y' ) {
190
+
191
+ if( isset($_POST[ $sb_instagram_configure_hidden_field ]) && $_POST[ $sb_instagram_configure_hidden_field ] == 'Y' ) {
192
+
193
+ $sb_instagram_at = sanitize_text_field( $_POST[ 'sb_instagram_at' ] );
194
+ $sb_instagram_user_id = array();
195
+ if ( isset( $_POST[ 'sb_instagram_user_id' ] )) {
196
+ if ( is_array( $_POST[ 'sb_instagram_user_id' ] ) ) {
197
+ foreach( $_POST[ 'sb_instagram_user_id' ] as $user_id ) {
198
+ $sb_instagram_user_id[] = sanitize_text_field( $user_id );
199
+ }
200
+ } else {
201
+ $sb_instagram_user_id[] = sanitize_text_field( $_POST[ 'sb_instagram_user_id' ] );
202
+ }
203
+ }
204
+ isset($_POST[ 'sb_instagram_preserve_settings' ]) ? $sb_instagram_preserve_settings = sanitize_text_field( $_POST[ 'sb_instagram_preserve_settings' ] ) : $sb_instagram_preserve_settings = '';
205
+ isset($_POST[ 'sb_instagram_cache_time' ]) ? $sb_instagram_cache_time = sanitize_text_field( $_POST[ 'sb_instagram_cache_time' ] ) : $sb_instagram_cache_time = '';
206
+ isset($_POST[ 'sb_instagram_cache_time_unit' ]) ? $sb_instagram_cache_time_unit = sanitize_text_field( $_POST[ 'sb_instagram_cache_time_unit' ] ) : $sb_instagram_cache_time_unit = '';
207
+
208
+ isset($_POST[ 'sbi_caching_type' ]) ? $sbi_caching_type = sanitize_text_field( $_POST[ 'sbi_caching_type' ] ) : $sbi_caching_type = '';
209
+ isset($_POST[ 'sbi_cache_cron_interval' ]) ? $sbi_cache_cron_interval = sanitize_text_field( $_POST[ 'sbi_cache_cron_interval' ] ) : $sbi_cache_cron_interval = '';
210
+ isset($_POST[ 'sbi_cache_cron_time' ]) ? $sbi_cache_cron_time = sanitize_text_field( $_POST[ 'sbi_cache_cron_time' ] ) : $sbi_cache_cron_time = '';
211
+ isset($_POST[ 'sbi_cache_cron_am_pm' ]) ? $sbi_cache_cron_am_pm = sanitize_text_field( $_POST[ 'sbi_cache_cron_am_pm' ] ) : $sbi_cache_cron_am_pm = '';
212
+
213
+ $options[ 'sb_instagram_at' ] = $sb_instagram_at;
214
+ $options[ 'sb_instagram_user_id' ] = $sb_instagram_user_id;
215
+ $options[ 'sb_instagram_preserve_settings' ] = $sb_instagram_preserve_settings;
216
+
217
+ $options[ 'sb_instagram_cache_time' ] = $sb_instagram_cache_time;
218
+ $options[ 'sb_instagram_cache_time_unit' ] = $sb_instagram_cache_time_unit;
219
+
220
+ $options[ 'sbi_caching_type' ] = $sbi_caching_type;
221
+ $options[ 'sbi_cache_cron_interval' ] = $sbi_cache_cron_interval;
222
+ $options[ 'sbi_cache_cron_time' ] = $sbi_cache_cron_time;
223
+ $options[ 'sbi_cache_cron_am_pm' ] = $sbi_cache_cron_am_pm;
224
+
225
+
226
+ //Delete all SBI transients
227
+ global $wpdb;
228
+ $table_name = $wpdb->prefix . "options";
229
+ $wpdb->query( "
230
+ DELETE
231
+ FROM $table_name
232
+ WHERE `option_name` LIKE ('%\_transient\_sbi\_%')
233
+ " );
234
+ $wpdb->query( "
235
+ DELETE
236
+ FROM $table_name
237
+ WHERE `option_name` LIKE ('%\_transient\_timeout\_sbi\_%')
238
+ " );
239
+ $wpdb->query( "
240
+ DELETE
241
+ FROM $table_name
242
+ WHERE `option_name` LIKE ('%\_transient\_&sbi\_%')
243
+ " );
244
+ $wpdb->query( "
245
+ DELETE
246
+ FROM $table_name
247
+ WHERE `option_name` LIKE ('%\_transient\_timeout\_&sbi\_%')
248
+ " );
249
+
250
+ if ( $sbi_caching_type === 'background' ) {
251
+ delete_option( 'sbi_cron_report' );
252
+ SB_Instagram_Cron_Updater::start_cron_job( $sbi_cache_cron_interval, $sbi_cache_cron_time, $sbi_cache_cron_am_pm );
253
+ }
254
+
255
+ } //End config tab post
256
+
257
+ if( isset($_POST[ $sb_instagram_customize_hidden_field ]) && $_POST[ $sb_instagram_customize_hidden_field ] == 'Y' ) {
258
+
259
+ //Validate and sanitize width field
260
+ $safe_width = intval( sanitize_text_field( $_POST['sb_instagram_width'] ) );
261
+ if ( ! $safe_width ) $safe_width = '';
262
+ if ( strlen( $safe_width ) > 4 ) $safe_width = substr( $safe_width, 0, 4 );
263
+ $sb_instagram_width = $safe_width;
264
+
265
+ $sb_instagram_width_unit = sanitize_text_field( $_POST[ 'sb_instagram_width_unit' ] );
266
+ isset($_POST[ 'sb_instagram_feed_width_resp' ]) ? $sb_instagram_feed_width_resp = sanitize_text_field( $_POST[ 'sb_instagram_feed_width_resp' ] ) : $sb_instagram_feed_width_resp = '';
267
+
268
+ //Validate and sanitize height field
269
+ $safe_height = intval( sanitize_text_field( $_POST['sb_instagram_height'] ) );
270
+ if ( ! $safe_height ) $safe_height = '';
271
+ if ( strlen( $safe_height ) > 4 ) $safe_height = substr( $safe_height, 0, 4 );
272
+ $sb_instagram_height = $safe_height;
273
+
274
+ $sb_instagram_height_unit = sanitize_text_field( $_POST[ 'sb_instagram_height_unit' ] );
275
+
276
+ //Validate and sanitize number of photos field
277
+ $safe_num = intval( sanitize_text_field( $_POST['sb_instagram_num'] ) );
278
+ if ( ! $safe_num ) $safe_num = '';
279
+ if ( strlen( $safe_num ) > 4 ) $safe_num = substr( $safe_num, 0, 4 );
280
+ $sb_instagram_num = $safe_num;
281
+
282
+ $sb_instagram_cols = sanitize_text_field( $_POST[ 'sb_instagram_cols' ] );
283
+ isset($_POST[ 'sb_instagram_disable_mobile' ]) ? $sb_instagram_disable_mobile = sanitize_text_field( $_POST[ 'sb_instagram_disable_mobile' ] ) : $sb_instagram_disable_mobile = '';
284
+
285
+ //Validate and sanitize padding field
286
+ $safe_padding = intval( sanitize_text_field( $_POST['sb_instagram_image_padding'] ) );
287
+ if ( ! $safe_padding ) $safe_padding = '';
288
+ if ( strlen( $safe_padding ) > 4 ) $safe_padding = substr( $safe_padding, 0, 4 );
289
+ $sb_instagram_image_padding = $safe_padding;
290
+
291
+ $sb_instagram_image_padding_unit = sanitize_text_field( $_POST[ 'sb_instagram_image_padding_unit' ] );
292
+ $sb_instagram_sort = sanitize_text_field( $_POST[ 'sb_instagram_sort' ] );
293
+ $sb_instagram_background = sanitize_text_field( $_POST[ 'sb_instagram_background' ] );
294
+ isset($_POST[ 'sb_instagram_show_btn' ]) ? $sb_instagram_show_btn = sanitize_text_field( $_POST[ 'sb_instagram_show_btn' ] ) : $sb_instagram_show_btn = '';
295
+ $sb_instagram_btn_background = sanitize_text_field( $_POST[ 'sb_instagram_btn_background' ] );
296
+ $sb_instagram_btn_text_color = sanitize_text_field( $_POST[ 'sb_instagram_btn_text_color' ] );
297
+ $sb_instagram_btn_text = sanitize_text_field( $_POST[ 'sb_instagram_btn_text' ] );
298
+ $sb_instagram_image_res = sanitize_text_field( $_POST[ 'sb_instagram_image_res' ] );
299
+ //Header
300
+ isset($_POST[ 'sb_instagram_show_header' ]) ? $sb_instagram_show_header = sanitize_text_field( $_POST[ 'sb_instagram_show_header' ] ) : $sb_instagram_show_header = '';
301
+ isset($_POST[ 'sb_instagram_show_bio' ]) ? $sb_instagram_show_bio = sanitize_text_field( $_POST[ 'sb_instagram_show_bio' ] ) : $sb_instagram_show_bio = '';
302
+ if ( function_exists( 'sanitize_textarea_field' ) ) {
303
+ isset($_POST[ 'sb_instagram_custom_bio' ]) ? $sb_instagram_custom_bio = sanitize_textarea_field( $_POST[ 'sb_instagram_custom_bio' ] ) : $sb_instagram_custom_bio = '';
304
+ } else {
305
+ isset($_POST[ 'sb_instagram_custom_bio' ]) ? $sb_instagram_custom_bio = sanitize_text_field( $_POST[ 'sb_instagram_custom_bio' ] ) : $sb_instagram_custom_bio = '';
306
+ }
307
+ isset($_POST[ 'sb_instagram_custom_avatar' ]) ? $sb_instagram_custom_avatar = sanitize_text_field( $_POST[ 'sb_instagram_custom_avatar' ] ) : $sb_instagram_custom_avatar = '';
308
+ if (isset($_POST[ 'sb_instagram_header_size' ]) ) $sb_instagram_header_size = $_POST[ 'sb_instagram_header_size' ];
309
+
310
+ $sb_instagram_header_color = sanitize_text_field( $_POST[ 'sb_instagram_header_color' ] );
311
+ //Follow button
312
+ isset($_POST[ 'sb_instagram_show_follow_btn' ]) ? $sb_instagram_show_follow_btn = sanitize_text_field( $_POST[ 'sb_instagram_show_follow_btn' ] ) : $sb_instagram_show_follow_btn = '';
313
+ $sb_instagram_folow_btn_background = sanitize_text_field( $_POST[ 'sb_instagram_folow_btn_background' ] );
314
+ $sb_instagram_follow_btn_text_color = sanitize_text_field( $_POST[ 'sb_instagram_follow_btn_text_color' ] );
315
+ $sb_instagram_follow_btn_text = sanitize_text_field( $_POST[ 'sb_instagram_follow_btn_text' ] );
316
+ //Misc
317
+ $sb_instagram_custom_css = $_POST[ 'sb_instagram_custom_css' ];
318
+ $sb_instagram_custom_js = $_POST[ 'sb_instagram_custom_js' ];
319
+ isset($_POST[ 'sb_instagram_ajax_theme' ]) ? $sb_instagram_ajax_theme = sanitize_text_field( $_POST[ 'sb_instagram_ajax_theme' ] ) : $sb_instagram_ajax_theme = '';
320
+ isset($_POST[ 'enqueue_js_in_head' ]) ? $enqueue_js_in_head = $_POST[ 'enqueue_js_in_head' ] : $enqueue_js_in_head = '';
321
+ isset($_POST[ 'disable_js_image_loading' ]) ? $disable_js_image_loading = $_POST[ 'disable_js_image_loading' ] : $disable_js_image_loading = '';
322
+ isset($_POST[ 'sb_instagram_disable_resize' ]) ? $sb_instagram_disable_resize= sanitize_text_field( $_POST[ 'sb_instagram_disable_resize' ] ) : $sb_instagram_disable_resize = '';
323
+ isset($_POST[ 'sb_instagram_favor_local' ]) ? $sb_instagram_favor_local = sanitize_text_field( $_POST[ 'sb_instagram_favor_local' ] ) : $sb_instagram_favor_local = '';
324
+ isset($_POST[ 'sb_instagram_minnum' ]) ? $sb_instagram_minnum = sanitize_text_field( $_POST[ 'sb_instagram_minnum' ] ) : $sb_instagram_minnum = '';
325
+
326
+ if (isset($_POST[ 'sb_instagram_cron' ]) ) $sb_instagram_cron = $_POST[ 'sb_instagram_cron' ];
327
+ isset($_POST[ 'sb_instagram_backup' ]) ? $sb_instagram_backup = $_POST[ 'sb_instagram_backup' ] : $sb_instagram_backup = '';
328
+ isset($_POST[ 'sb_ajax_initial' ]) ? $sb_ajax_initial = $_POST[ 'sb_ajax_initial' ] : $sb_ajax_initial = '';
329
+ isset($_POST[ 'enqueue_css_in_shortcode' ]) ? $enqueue_css_in_shortcode = $_POST[ 'enqueue_css_in_shortcode' ] : $enqueue_css_in_shortcode = '';
330
+ isset($_POST[ 'sbi_font_method' ]) ? $sbi_font_method = $_POST[ 'sbi_font_method' ] : $sbi_font_method = 'svg';
331
+ isset($_POST[ 'sb_instagram_disable_awesome' ]) ? $sb_instagram_disable_awesome = sanitize_text_field( $_POST[ 'sb_instagram_disable_awesome' ] ) : $sb_instagram_disable_awesome = '';
332
+
333
+ $options[ 'sb_instagram_width' ] = $sb_instagram_width;
334
+ $options[ 'sb_instagram_width_unit' ] = $sb_instagram_width_unit;
335
+ $options[ 'sb_instagram_feed_width_resp' ] = $sb_instagram_feed_width_resp;
336
+ $options[ 'sb_instagram_height' ] = $sb_instagram_height;
337
+ $options[ 'sb_instagram_height_unit' ] = $sb_instagram_height_unit;
338
+ $options[ 'sb_instagram_num' ] = $sb_instagram_num;
339
+ $options[ 'sb_instagram_cols' ] = $sb_instagram_cols;
340
+ $options[ 'sb_instagram_disable_mobile' ] = $sb_instagram_disable_mobile;
341
+ $options[ 'sb_instagram_image_padding' ] = $sb_instagram_image_padding;
342
+ $options[ 'sb_instagram_image_padding_unit' ] = $sb_instagram_image_padding_unit;
343
+ $options[ 'sb_instagram_sort' ] = $sb_instagram_sort;
344
+ $options[ 'sb_instagram_background' ] = $sb_instagram_background;
345
+ $options[ 'sb_instagram_show_btn' ] = $sb_instagram_show_btn;
346
+ $options[ 'sb_instagram_btn_background' ] = $sb_instagram_btn_background;
347
+ $options[ 'sb_instagram_btn_text_color' ] = $sb_instagram_btn_text_color;
348
+ $options[ 'sb_instagram_btn_text' ] = $sb_instagram_btn_text;
349
+ $options[ 'sb_instagram_image_res' ] = $sb_instagram_image_res;
350
+ //Header
351
+ $options[ 'sb_instagram_show_header' ] = $sb_instagram_show_header;
352
+ $options[ 'sb_instagram_header_size' ] = $sb_instagram_header_size;
353
+ $options[ 'sb_instagram_show_bio' ] = $sb_instagram_show_bio;
354
+ $options[ 'sb_instagram_custom_bio' ] = $sb_instagram_custom_bio;
355
+ $options[ 'sb_instagram_custom_avatar' ] = $sb_instagram_custom_avatar;
356
+ $options[ 'sb_instagram_custom_bio' ] = $sb_instagram_custom_bio;
357
+ $options[ 'sb_instagram_custom_avatar' ] = $sb_instagram_custom_avatar;
358
+ $options[ 'sb_instagram_header_color' ] = $sb_instagram_header_color;
359
+ //Follow button
360
+ $options[ 'sb_instagram_show_follow_btn' ] = $sb_instagram_show_follow_btn;
361
+ $options[ 'sb_instagram_folow_btn_background' ] = $sb_instagram_folow_btn_background;
362
+ $options[ 'sb_instagram_follow_btn_text_color' ] = $sb_instagram_follow_btn_text_color;
363
+ $options[ 'sb_instagram_follow_btn_text' ] = $sb_instagram_follow_btn_text;
364
+ //Misc
365
+ $options[ 'sb_instagram_custom_css' ] = $sb_instagram_custom_css;
366
+ $options[ 'sb_instagram_custom_js' ] = $sb_instagram_custom_js;
367
+ $options[ 'sb_instagram_ajax_theme' ] = $sb_instagram_ajax_theme;
368
+ $options[ 'enqueue_js_in_head' ] = $enqueue_js_in_head;
369
+ $options[ 'disable_js_image_loading' ] = $disable_js_image_loading;
370
+ $options[ 'sb_instagram_disable_resize' ] = $sb_instagram_disable_resize;
371
+ $options[ 'sb_instagram_favor_local' ] = $sb_instagram_favor_local;
372
+ $options[ 'sb_instagram_minnum' ] = $sb_instagram_minnum;
373
+
374
+ $options[ 'sb_ajax_initial' ] = $sb_ajax_initial;
375
+ $options[ 'sb_instagram_cron' ] = $sb_instagram_cron;
376
+ $options['sb_instagram_backup'] = $sb_instagram_backup;
377
+ $options['enqueue_css_in_shortcode'] = $enqueue_css_in_shortcode;
378
+
379
+ $options['sbi_font_method'] = $sbi_font_method;
380
+ $options[ 'sb_instagram_disable_awesome' ] = $sb_instagram_disable_awesome;
381
+
382
+ isset($_POST[ 'sb_instagram_custom_template' ]) ? $sb_instagram_custom_template = $_POST[ 'sb_instagram_custom_template' ] : $sb_instagram_custom_template = '';
383
+ $options['custom_template'] = $sb_instagram_custom_template;
384
+ isset($_POST[ 'sb_instagram_disable_admin_notice' ]) ? $sb_instagram_disable_admin_notice = $_POST[ 'sb_instagram_disable_admin_notice' ] : $sb_instagram_disable_admin_notice = '';
385
+ $options['disable_admin_notice'] = $sb_instagram_disable_admin_notice;
386
+ isset($_POST[ 'sb_instagram_enable_email_report' ]) ? $sb_instagram_enable_email_report = $_POST[ 'sb_instagram_enable_email_report' ] : $sb_instagram_enable_email_report = '';
387
+ $options['enable_email_report'] = $sb_instagram_enable_email_report;
388
+ isset($_POST[ 'sb_instagram_email_notification' ]) ? $sb_instagram_email_notification = $_POST[ 'sb_instagram_email_notification' ] : $sb_instagram_email_notification = '';
389
+ $original = $options['email_notification'];
390
+ $options['email_notification'] = $sb_instagram_email_notification;
391
+ isset($_POST[ 'sb_instagram_email_notification_addresses' ]) ? $sb_instagram_email_notification_addresses = $_POST[ 'sb_instagram_email_notification_addresses' ] : $sb_instagram_email_notification_addresses = get_option( 'admin_email' );
392
+ $options['email_notification_addresses'] = $sb_instagram_email_notification_addresses;
393
+
394
+ if ( $original !== $sb_instagram_email_notification && $sb_instagram_enable_email_report === 'on' ){
395
+ //Clear the existing cron event
396
+ wp_clear_scheduled_hook('sb_instagram_feed_issue_email');
397
+
398
+ $input = sanitize_text_field($_POST[ 'sb_instagram_email_notification' ] );
399
+ $timestamp = strtotime( 'next ' . $input );
400
+
401
+ if ( $timestamp - (3600 * 1) < time() ) {
402
+ $timestamp = $timestamp + (3600 * 24 * 7);
403
+ }
404
+ $six_am_local = $timestamp + sbi_get_utc_offset() + (6*60*60);
405
+
406
+ wp_schedule_event( $six_am_local, 'sbiweekly', 'sb_instagram_feed_issue_email' );
407
+ }
408
+
409
+
410
+ //Delete all SBI transients
411
+ global $wpdb;
412
+ $table_name = $wpdb->prefix . "options";
413
+ $wpdb->query( "
414
+ DELETE
415
+ FROM $table_name
416
+ WHERE `option_name` LIKE ('%\_transient\_sbi\_%')
417
+ " );
418
+ $wpdb->query( "
419
+ DELETE
420
+ FROM $table_name
421
+ WHERE `option_name` LIKE ('%\_transient\_timeout\_sbi\_%')
422
+ " );
423
+ $wpdb->query( "
424
+ DELETE
425
+ FROM $table_name
426
+ WHERE `option_name` LIKE ('%\_transient\_&sbi\_%')
427
+ " );
428
+ $wpdb->query( "
429
+ DELETE
430
+ FROM $table_name
431
+ WHERE `option_name` LIKE ('%\_transient\_timeout\_&sbi\_%')
432
+ " );
433
+
434
+ if( $sb_instagram_cron == 'no' ) wp_clear_scheduled_hook('sb_instagram_cron_job');
435
+
436
+ //Run cron when Misc settings are saved
437
+ if( $sb_instagram_cron == 'yes' ){
438
+ //Clear the existing cron event
439
+ wp_clear_scheduled_hook('sb_instagram_cron_job');
440
+
441
+ $sb_instagram_cache_time = $options[ 'sb_instagram_cache_time' ];
442
+ $sb_instagram_cache_time_unit = $options[ 'sb_instagram_cache_time_unit' ];
443
+
444
+ //Set the event schedule based on what the caching time is set to
445
+ $sb_instagram_cron_schedule = 'hourly';
446
+ if( $sb_instagram_cache_time_unit == 'hours' && $sb_instagram_cache_time > 5 ) $sb_instagram_cron_schedule = 'twicedaily';
447
+ if( $sb_instagram_cache_time_unit == 'days' ) $sb_instagram_cron_schedule = 'daily';
448
+
449
+ wp_schedule_event(time(), $sb_instagram_cron_schedule, 'sb_instagram_cron_job');
450
+
451
+ sb_instagram_clear_page_caches();
452
+ }
453
+
454
+ } //End customize tab post
455
+
456
+ //Save the settings to the settings array
457
+ update_option( 'sb_instagram_settings', $options );
458
+
459
+ ?>
460
+ <div class="updated"><p><strong><?php _e( 'Settings saved.', 'instagram-feed' ); ?></strong></p></div>
461
+ <?php } ?>
462
+
463
+ <?php } //End nonce check ?>
464
+
465
+
466
+ <div id="sbi_admin" class="wrap">
467
+ <?php
468
+ $lite_notice_dismissed = get_transient( 'instagram_feed_dismiss_lite' );
469
+
470
+ if ( ! $lite_notice_dismissed ) :
471
+ ?>
472
+ <div id="sbi-notice-bar" style="display:none">
473
+ <span class="sbi-notice-bar-message"><?php _e( 'You\'re using Instagram Feed Lite. To unlock more features consider <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=notices&utm_medium=litenotice" target="_blank" rel="noopener noreferrer">upgrading to Pro</a>.', 'instagram-feed'); ?></span>
474
+ <button type="button" class="dismiss" title="<?php _e( 'Dismiss this message.', 'instagram-feed'); ?>" data-page="overview">
475
+ </button>
476
+ </div>
477
+ <?php endif; ?>
478
+ <div id="header">
479
+ <h1><?php _e( 'Instagram Feed', 'instagram-feed' ); ?></h1>
480
+ </div>
481
+ <?php
482
+ $sb_instagram_type = 'user';
483
+ $returned_data = sbi_get_connected_accounts_data( $sb_instagram_at );
484
+ $sb_instagram_at = $returned_data['access_token'];
485
+ $connected_accounts = $returned_data['connected_accounts'];
486
+ $user_feeds_returned = isset( $returned_data['user_ids'] ) ? $returned_data['user_ids'] : false;
487
+ if ( $user_feeds_returned ) {
488
+ $user_feed_ids = $user_feeds_returned;
489
+ } else {
490
+ $user_feed_ids = ! is_array( $sb_instagram_user_id ) ? explode( ',', $sb_instagram_user_id ) : $sb_instagram_user_id;
491
+ }
492
+
493
+ $new_user_name = false;
494
+
495
+
496
+
497
+
498
+ if( isset($_GET['access_token']) && isset($_GET['graph_api']) && empty($_POST) ) { ?>
499
+ <?php
500
+ $access_token = sbi_maybe_clean(urldecode($_GET['access_token']));
501
+ //
502
+ $url = 'https://graph.facebook.com/me/accounts?fields=instagram_business_account,access_token&limit=500&access_token='.$access_token;
503
+ $args = array(
504
+ 'timeout' => 60,
505
+ 'sslverify' => false
506
+ );
507
+ $result = wp_remote_get( $url, $args );
508
+ $pages_data = '{}';
509
+ if ( ! is_wp_error( $result ) ) {
510
+ $pages_data = $result['body'];
511
+ } else {
512
+ $page_error = $result;
513
+ }
514
+
515
+ $pages_data_arr = json_decode($pages_data);
516
+ $num_accounts = 0;
517
+ if(isset($pages_data_arr)){
518
+ $num_accounts = is_array( $pages_data_arr->data ) ? count( $pages_data_arr->data ) : 0;
519
+ }
520
+ ?>
521
+ <div id="sbi_config_info" class="sb_list_businesses sbi_num_businesses_<?php echo $num_accounts; ?>">
522
+ <div class="sbi_config_modal">
523
+ <div class="sbi-managed-pages">
524
+ <?php if ( isset( $page_error ) && isset( $page_error->errors ) ) {
525
+ foreach ($page_error->errors as $key => $item) {
526
+ echo '<div class="sbi_user_id_error" style="display:block;"><strong>Connection Error: </strong>' . $key . ': ' . $item[0] . '</div>';
527
+ }
528
+ }
529
+ ?>
530
+ <?php if( empty($pages_data_arr->data) ) : ?>
531
+ <span id="sbi-bus-account-error">
532
+ <p style="margin-top: 5px;"><b style="font-size: 16px">Couldn't find Business Profile</b><br />
533
+ Uh oh. It looks like this Facebook account is not currently connected to an Instagram Business profile. Please check that you are logged into the <a href="https://www.facebook.com/" target="_blank">Facebook account</a> in this browser which is associated with your Instagram Business Profile.</p>
534
+ <p><b style="font-size: 16px">Why do I need a Business Profile?</b><br />
535
+ A Business Profile is only required if you are displaying a Hashtag feed. If you want to display a regular User feed then you can do this by selecting to connect a Personal account instead. For directions on how to convert your Personal profile into a Business profile please <a href="https://smashballoon.com/instagram-business-profiles" target="_blank">see here</a>.</p>
536
+ </span>
537
+
538
+ <?php elseif ( $num_accounts === 0 ): ?>
539
+ <span id="sbi-bus-account-error">
540
+ <p style="margin-top: 5px;"><b style="font-size: 16px">Couldn't find Business Profile</b><br />
541
+ Uh oh. It looks like this Facebook account is not currently connected to an Instagram Business profile. Please check that you are logged into the <a href="https://www.facebook.com/" target="_blank">Facebook account</a> in this browser which is associated with your Instagram Business Profile.</p>
542
+ <p>If you are, in fact, logged-in to the correct account please make sure you have Instagram accounts connected with your Facebook account by following <a href="https://smashballoon.com/reconnecting-an-instagram-business-profile/" target="_blank">this FAQ</a></p>
543
+ </span>
544
+ <?php else: ?>
545
+ <p class="sbi-managed-page-intro"><b style="font-size: 16px;">Instagram Business profiles for this account</b><br /><i style="color: #666;">Note: In order to display a Hashtag feed you first need to select a Business profile below.</i></p>
546
+ <?php if ( $num_accounts > 1 ) : ?>
547
+ <div class="sbi-managed-page-select-all"><input type="checkbox" id="sbi-select-all" class="sbi-select-all"><label for="sbi-select-all">Select All</label></div>
548
+ <?php endif; ?>
549
+ <div class="sbi-scrollable-accounts">
550
+
551
+ <?php foreach ( $pages_data_arr->data as $page => $page_data ) : ?>
552
+
553
+ <?php if( isset( $page_data->instagram_business_account ) ) :
554
+
555
+ $instagram_business_id = $page_data->instagram_business_account->id;
556
+
557
+ $page_access_token = isset( $page_data->access_token ) ? $page_data->access_token : '';
558
+
559
+ //Make another request to get page info
560
+ $instagram_account_url = 'https://graph.facebook.com/'.$instagram_business_id.'?fields=name,username,profile_picture_url&access_token='.$access_token;
561
+
562
+ $args = array(
563
+ 'timeout' => 60,
564
+ 'sslverify' => false
565
+ );
566
+ $result = wp_remote_get( $instagram_account_url, $args );
567
+ $instagram_account_info = '{}';
568
+ if ( ! is_wp_error( $result ) ) {
569
+ $instagram_account_info = $result['body'];
570
+ } else {
571
+ $page_error = $result;
572
+ }
573
+
574
+ $instagram_account_data = json_decode($instagram_account_info);
575
+
576
+ $instagram_biz_img = isset( $instagram_account_data->profile_picture_url ) ? $instagram_account_data->profile_picture_url : false;
577
+ $selected_class = $instagram_business_id == $sb_instagram_user_id ? ' sbi-page-selected' : '';
578
+
579
+ ?>
580
+ <?php if ( isset( $page_error ) && isset( $page_error->errors ) ) :
581
+ foreach ($page_error->errors as $key => $item) {
582
+ echo '<div class="sbi_user_id_error" style="display:block;"><strong>Connection Error: </strong>' . $key . ': ' . $item[0] . '</div>';
583
+ }
584
+ else : ?>
585
+ <div class="sbi-managed-page<?php echo $selected_class; ?>" data-page-token="<?php echo esc_attr( $page_access_token ); ?>" data-token="<?php echo esc_attr( $access_token ); ?>" data-page-id="<?php echo esc_attr( $instagram_business_id ); ?>">
586
+ <div class="sbi-add-checkbox">
587
+ <input id="sbi-<?php echo esc_attr( $instagram_business_id ); ?>" type="checkbox" name="sbi_managed_pages[]" value="<?php echo esc_attr( $instagram_account_info ); ?>">
588
+ </div>
589
+ <div class="sbi-managed-page-details">
590
+ <label for="sbi-<?php echo esc_attr( $instagram_business_id ); ?>"><img class="sbi-page-avatar" border="0" height="50" width="50" src="<?php echo esc_url( $instagram_biz_img ); ?>"><b style="font-size: 16px;"><?php echo esc_html( $instagram_account_data->name ); ?></b>
591
+ <br />@<?php echo esc_html( $instagram_account_data->username); ?><span style="font-size: 11px; margin-left: 5px;">(<?php echo esc_html( $instagram_business_id ); ?>)</span></label>
592
+ </div>
593
+ </div>
594
+ <?php endif; ?>
595
+
596
+ <?php endif; ?>
597
+
598
+ <?php endforeach; ?>
599
+
600
+ </div> <!-- end scrollable -->
601
+ <p style="font-size: 11px; line-height: 1.5; margin-bottom: 0;"><b><i style="color: #666;">*<?php echo sprintf( __( 'Changing the password, updating privacy settings, or removing page admins for the related Facebook page may require %smanually reauthorizing our app%s to reconnect an account.', 'instagram-feed' ), '<a href="https://smashballoon.com/reauthorizing-our-instagram-facebook-app/" target="_blank" rel="noopener noreferrer">', '</a>' ); ?></i></p>
602
+
603
+ <a href="JavaScript:void(0);" id="sbi-connect-business-accounts" class="button button-primary" disabled="disabled" style="margin-top: 20px;">Connect Accounts</a>
604
+
605
+ <?php endif; ?>
606
+
607
+ <a href="JavaScript:void(0);" class="sbi_modal_close"><i class="fa fa-times"></i></a>
608
+ </div>
609
+ </div>
610
+ </div>
611
+ <?php } elseif ( isset( $_GET['access_token'] ) && isset( $_GET['account_type'] ) && empty( $_POST ) ) {
612
+ $access_token = sanitize_text_field( $_GET['access_token'] );
613
+ $account_type = sanitize_text_field( $_GET['account_type'] );
614
+ $user_id = sanitize_text_field( $_GET['id'] );
615
+ $user_name = sanitize_text_field( $_GET['username'] );
616
+ $expires_in = (int)$_GET['expires_in'];
617
+ $expires_timestamp = time() + $expires_in;
618
+
619
+ $new_account_details = array(
620
+ 'access_token' => $access_token,
621
+ 'account_type' => $account_type,
622
+ 'user_id' => $user_id,
623
+ 'username' => $user_name,
624
+ 'expires_timestamp' => $expires_timestamp,
625
+ 'type' => 'basic'
626
+ );
627
+
628
+
629
+ $matches_existing_personal = sbi_matches_existing_personal( $new_account_details );
630
+ $button_text = $matches_existing_personal ? __( 'Update This Account', 'instagram-feed' ) : __( 'Connect This Account', 'instagram-feed' );
631
+
632
+ $account_json = wp_json_encode( $new_account_details );
633
+
634
+ $already_connected_as_business_account = (isset( $connected_accounts[ $user_id ] ) && $connected_accounts[ $user_id ]['type'] === 'business');
635
+
636
+ ?>
637
+
638
+ <div id="sbi_config_info" class="sb_get_token">
639
+ <div class="sbi_config_modal">
640
+ <div class="sbi_ca_username"><strong><?php echo esc_html( $user_name ); ?></strong></div>
641
+ <form action="<?php echo admin_url( 'admin.php?page=sb-instagram-feed' ); ?>" method="post">
642
+ <p class="sbi_submit">
643
+ <?php if ( $already_connected_as_business_account ) :
644
+ _e( 'The Instagram account you are logged into is already connected as a "business" account. Remove the business account if you\'d like to connect as a basic account instead (not recommended).', 'instagram-feed' );
645
+ ?>
646
+ <?php else : ?>
647
+ <input type="submit" name="sbi_submit" id="sbi_connect_account" class="button button-primary" value="<?php echo esc_html( $button_text ); ?>">
648
+ <?php endif; ?>
649
+ <input type="hidden" name="sbi_account_json" value="<?php echo esc_attr( $account_json ) ; ?>">
650
+ <input type="hidden" name="sbi_connect_username" value="<?php echo esc_attr( $user_name ); ?>">
651
+ <a href="JavaScript:void(0);" class="button button-secondary" id="sbi_switch_accounts"><?php esc_html_e( 'Switch Accounts', 'instagram-feed' ); ?></a>
652
+ </p>
653
+ </form>
654
+ <a href="JavaScript:void(0);"><i class="sbi_modal_close fa fa-times"></i></a>
655
+ </div>
656
+ </div>
657
+ <?php
658
+ } elseif ( isset( $_POST['sbi_connect_username'] ) ) {
659
+
660
+ $new_user_name = sanitize_text_field( $_POST['sbi_connect_username'] );
661
+ $new_account_details = json_decode( stripslashes( $_POST['sbi_account_json'] ), true );
662
+ array_map( 'sanitize_text_field', $new_account_details );
663
+
664
+ $updated_options = sbi_connect_basic_account( $new_account_details );
665
+ $connected_accounts = $updated_options['connected_accounts'];
666
+ $user_feed_ids = $updated_options['sb_instagram_user_id'];
667
+ }?>
668
+
669
+ <?php //Display connected page
670
+ if (isset( $sbi_connected_page ) && strpos($sbi_connected_page, ':') !== false) {
671
+
672
+ $sbi_connected_page_pieces = explode(":", $sbi_connected_page);
673
+ $sbi_connected_page_id = $sbi_connected_page_pieces[0];
674
+ $sbi_connected_page_name = $sbi_connected_page_pieces[1];
675
+ $sbi_connected_page_image = $sbi_connected_page_pieces[2];
676
+
677
+ echo '&nbsp;';
678
+ echo '<p style="font-weight: bold; margin-bottom: 5px;">Connected Business Profile:</p>';
679
+ echo '<div class="sbi-managed-page sbi-no-select">';
680
+ echo '<p><img class="sbi-page-avatar" border="0" height="50" width="50" src="'.$sbi_connected_page_image.'"><b>'.$sbi_connected_page_name.'</b> &nbsp; ('.$sbi_connected_page_id.')</p>';
681
+ echo '</div>';
682
+ }
683
+
684
+ ?>
685
+
686
+ <form name="form1" method="post" action="">
687
+ <input type="hidden" name="<?php echo $sb_instagram_settings_hidden_field; ?>" value="Y">
688
+ <?php wp_nonce_field( 'sb_instagram_saving_settings', 'sb_instagram_settings_nonce' ); ?>
689
+
690
+ <?php $sbi_active_tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field( $_GET['tab'] ) : 'configure'; ?>
691
+ <h2 class="nav-tab-wrapper">
692
+ <a href="?page=sb-instagram-feed&amp;tab=configure" class="nav-tab <?php echo $sbi_active_tab == 'configure' ? 'nav-tab-active' : ''; ?>"><?php _e( '1. Configure', 'instagram-feed' ); ?></a>
693
+ <a href="?page=sb-instagram-feed&amp;tab=customize" class="nav-tab <?php echo $sbi_active_tab == 'customize' ? 'nav-tab-active' : ''; ?>"><?php _e( '2. Customize', 'instagram-feed' ); ?></a>
694
+ <a href="?page=sb-instagram-feed&amp;tab=display" class="nav-tab <?php echo $sbi_active_tab == 'display' ? 'nav-tab-active' : ''; ?>"><?php _e( '3. Display Your Feed', 'instagram-feed' ); ?></a>
695
+ <a href="?page=sb-instagram-feed&amp;tab=support" class="nav-tab <?php echo $sbi_active_tab == 'support' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Support', 'instagram-feed' ); ?></a>
696
+ </h2>
697
+
698
+ <?php if( $sbi_active_tab == 'configure' ) { //Start Configure tab ?>
699
+ <input type="hidden" name="<?php echo $sb_instagram_configure_hidden_field; ?>" value="Y">
700
+
701
+ <table class="form-table">
702
+ <tbody>
703
+ <h3><?php _e( 'Configure', 'instagram-feed' ); ?></h3>
704
+
705
+ <div id="sbi_config">
706
+ <a data-personal-basic-api="https://api.instagram.com/oauth/authorize?app_id=423965861585747&redirect_uri=https://api.smashballoon.com/instagram-basic-display-redirect.php&response_type=code&scope=user_profile,user_media&state=<?php echo admin_url('admin.php?page=sb-instagram-feed'); ?>"
707
+ data-new-api="https://www.facebook.com/dialog/oauth?client_id=254638078422287&redirect_uri=https://api.smashballoon.com/instagram-graph-api-redirect.php&scope=manage_pages,instagram_basic,instagram_manage_insights,instagram_manage_comments&state=<?php echo admin_url('admin.php?page=sb-instagram-feed'); ?>"
708
+ data-old-api="https://instagram.com/oauth/authorize/?client_id=3a81a9fa2a064751b8c31385b91cc25c&scope=basic&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'); ?>&hl=en"
709
+ href="https://instagram.com/oauth/authorize/?client_id=3a81a9fa2a064751b8c31385b91cc25c&scope=basic&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'); ?>&hl=en" class="sbi_admin_btn"><i class="fa fa-user-plus" aria-hidden="true" style="font-size: 20px;"></i>&nbsp; <?php _e('Connect an Instagram Account', 'instagram-feed' ); ?></a>
710
+
711
+ <!--<a href="https://instagram.com/oauth/authorize/?client_id=3a81a9fa2a064751b8c31385b91cc25c&scope=basic&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>&nbsp; <?php _e('Connect an Instagram Account', 'instagram-feed' ); ?></a>
712
+ -->
713
+ <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>
714
+ </div>
715
+
716
+ <!-- Old Access Token -->
717
+ <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" />
718
+
719
+ <tr valign="top">
720
+ <th scope="row"><label><?php _e( 'Instagram Accounts', 'instagram-feed' ); ?></label><span style="font-weight:normal; font-style:italic; font-size: 12px; display: block;"><?php _e('Use the button above to connect an Instagram account', 'instagram-feed'); ?></span></th>
721
+ <td class="sbi_connected_accounts_wrap">
722
+ <?php if ( empty( $connected_accounts ) ) : ?>
723
+ <p class="sbi_no_accounts"><?php _e( 'No Instagram accounts connected. Click the button above to connect an account.', 'instagram-feed' ); ?></p><br />
724
+ <?php else:
725
+ if ( sbi_is_after_deprecation_deadline() ) {
726
+ $deprecated_connected_account_message = __( '<b>Action Needed:</b> Reconnect this account to allow feed to update.', 'instagram-feed' );
727
+ } else {
728
+ $deprecated_connected_account_message = __( '<b>Action Needed:</b> Reconnect this account before June 1, 2020 to avoid disruption with this feed.', 'instagram-feed' );
729
+ }
730
+
731
+ $accounts_that_need_updating = sbi_get_user_names_of_personal_accounts_not_also_already_updated();
732
+ ?>
733
+ <?php foreach ( $connected_accounts as $account ) :
734
+ $username = $account['username'] ? $account['username'] : $account['user_id'];
735
+ if ( isset( $account['local_avatar'] ) && $account['local_avatar'] && isset( $options['sb_instagram_favor_local'] ) && $options['sb_instagram_favor_local' ] === 'on' ) {
736
+ $upload = wp_upload_dir();
737
+ $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBI_UPLOADS_NAME );
738
+ $profile_picture = '<img class="sbi_ca_avatar" src="'.$resized_url . $account['username'].'.jpg" />'; //Could add placeholder avatar image
739
+ } else {
740
+ $profile_picture = $account['profile_picture'] ? '<img class="sbi_ca_avatar" src="'.$account['profile_picture'].'" />' : ''; //Could add placeholder avatar image
741
+ }
742
+
743
+ $is_invalid_class = ! $account['is_valid'] ? ' sbi_account_invalid' : '';
744
+ $in_user_feed = in_array( $account['user_id'], $user_feed_ids, true );
745
+ $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
746
+ $use_tagged = isset( $account['use_tagged'] ) && $account['use_tagged'] == '1';
747
+
748
+ if ( empty( $profile_picture ) && $account_type === 'personal' ) {
749
+ $account_update = sbi_account_data_for_token( $account['access_token'] );
750
+ if ( isset( $account['is_valid'] ) ) {
751
+ $split = explode( '.', $account['access_token'] );
752
+ $connected_accounts[ $split[0] ] = array(
753
+ 'access_token' => $account['access_token'],
754
+ 'user_id' => $split[0],
755
+ 'username' => $account_update['username'],
756
+ 'is_valid' => true,
757
+ 'last_checked' => time(),
758
+ 'profile_picture' => $account_update['profile_picture']
759
+ );
760
+
761
+ $sbi_options = get_option( 'sb_instagram_settings', array() );
762
+ $sbi_options['connected_accounts'] = $connected_accounts;
763
+ update_option( 'sb_instagram_settings', $sbi_options );
764
+ }
765
+
766
+ }
767
+ $updated_or_new_account_class = $new_user_name === $username && $account_type !== 'business' ? ' sbi_ca_new_or_updated' : '';
768
+
769
+ ?>
770
+ <div class="sbi_connected_account<?php echo $is_invalid_class . $updated_or_new_account_class; ?><?php if ( $in_user_feed ) echo ' sbi_account_active' ?> sbi_account_type_<?php echo $account_type; ?>" 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'] ); ?>" data-type="<?php esc_attr_e( $account_type ); ?>" data-permissions="<?php if ( $use_tagged ) echo 'tagged'; ?>">
771
+ <?php if ( $account_type === 'personal' && in_array( $username, $accounts_that_need_updating, true ) ) : ?>
772
+ <div class="sbi_deprecated">
773
+ <span><i class="fa fa-exclamation-circle" aria-hidden="true"></i><?php echo $deprecated_connected_account_message; ?> <button class="sbi_reconnect button-primary">Reconnect</button></span>
774
+ </div>
775
+ <?php endif; ?>
776
+ <div class="sbi_ca_alert">
777
+ <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>
778
+ </div>
779
+ <div class="sbi_ca_info">
780
+
781
+ <div class="sbi_ca_delete">
782
+ <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>
783
+ </div>
784
+
785
+ <div class="sbi_ca_username">
786
+ <?php echo $profile_picture; ?>
787
+ <strong><?php echo $username; ?><span><?php echo sbi_account_type_display( $account_type ); ?></span></strong>
788
+ </div>
789
+
790
+ <div class="sbi_ca_actions">
791
+ <?php if ( ! $in_user_feed ) : ?>
792
+ <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>
793
+ <?php else : ?>
794
+ <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>
795
+ <?php endif; ?>
796
+ <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>
797
+ <a class="sbi_ca_show_token button-secondary" href="JavaScript:void(0);" title="<?php _e('Show access token and account info', 'instagram-feed'); ?>"><i class="fa fa-cog"></i></a>
798
+
799
+ </div>
800
+
801
+ <div class="sbi_ca_shortcode">
802
+
803
+ <p><?php _e('Copy and paste this shortcode into your page or widget area', 'instagram-feed'); ?>:<br>
804
+ <?php if ( !empty( $account['username'] ) ) : ?>
805
+ <code>[instagram-feed user="<?php echo $account['username']; ?>"]</code>
806
+ <?php else : ?>
807
+ <code>[instagram-feed accesstoken="<?php echo $account['access_token']; ?>"]</code>
808
+ <?php endif; ?>
809
+ </p>
810
+
811
+ <p><?php _e('To add multiple users in the same feed, simply separate them using commas', 'instagram-feed'); ?>:<br>
812
+ <?php if ( !empty( $account['username'] ) ) : ?>
813
+ <code>[instagram-feed user="<?php echo $account['username']; ?>, a_second_user, a_third_user"]</code>
814
+ <?php else : ?>
815
+ <code>[instagram-feed accesstoken="<?php echo $account['access_token']; ?>, another_access_token"]</code>
816
+ <?php endif; ?>
817
+
818
+ <p><?php echo sprintf( __('Click on the %s tab to learn more about shortcodes', 'instagram-feed'), '<a href="?page=sb-instagram-feed&tab=display" target="_blank">'. __( 'Display Your Feed', 'instagram-feed' ) . '</a>' ); ?></p>
819
+ </div>
820
+
821
+ <div class="sbi_ca_accesstoken">
822
+ <span class="sbi_ca_token_label"><?php _e('Access Token', 'instagram-feed');?>:</span><input type="text" class="sbi_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).', 'instagram-feed');?>"><br>
823
+ <span class="sbi_ca_token_label"><?php _e('User ID', 'instagram-feed');?>:</span><input type="text" class="sbi_ca_user_id" value="<?php echo $account['user_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).', 'instagram-feed');?>"><br>
824
+ </div>
825
+
826
+ </div>
827
+
828
+ </div>
829
+
830
+ <?php endforeach; ?>
831
+ <?php endif; ?>
832
+ <a href="JavaScript:void(0);" class="sbi_manually_connect button-secondary"><?php _e( 'Manually Connect an Account', 'instagram-feed' ); ?></a>
833
+ <div class="sbi_manually_connect_wrap">
834
+ <input name="sb_manual_at" id="sb_manual_at" type="text" value="" style="margin-top: 4px; padding: 5px 9px; margin-left: 0px;" size="64" minlength="15" maxlength="200" placeholder="<?php esc_attr_e( 'Enter a valid Instagram Access Token', 'instagram-feed' ); ?>" /><span class='sbi_business_profile_tag'><?php _e('Business or Basic Display', 'instagram-feed');?></span>
835
+ <div class="sbi_manual_account_id_toggle">
836
+ <label><?php _e('Please enter the User ID for this Profile:', 'instagram-feed');?></label>
837
+ <input name="sb_manual_account_id" id="sb_manual_account_id" type="text" value="" style="margin-top: 4px; padding: 5px 9px; margin-left: 0px;" size="40" minlength="5" maxlength="100" placeholder="Eg: 15641403491391489" />
838
+ </div>
839
+ <p class="sbi_submit" style="display: inline-block;"><input type="submit" name="sbi_submit" id="sbi_manual_submit" class="button button-primary" value="<?php _e('Connect This Account', 'instagram-feed' );?>"></p>
840
+ </div>
841
+ </td>
842
+ </tr>
843
+
844
+ <tr valign="top" class="sbi_feed_type">
845
+ <th scope="row"><label><?php _e('Show Photos From:', 'instagram-feed'); ?></label><code class="sbi_shortcode"> type
846
+ Eg: type=user id=12986477
847
+ </code></th>
848
+ <td>
849
+ <div class="sbi_row">
850
+ <div class="sbi_col sbi_one">
851
+ <input type="radio" name="sb_instagram_type" id="sb_instagram_type_user" value="user" <?php if($sb_instagram_type == "user") echo "checked"; ?> />
852
+ <label class="sbi_radio_label" for="sb_instagram_type_user"><?php _e( 'User Account:', 'instagram-feed' ); ?></label>
853
+ </div>
854
+ <div class="sbi_col sbi_two">
855
+ <div class="sbi_user_feed_ids_wrap">
856
+ <?php foreach ( $user_feed_ids as $feed_id ) : if ( $feed_id !== '' ) :?>
857
+ <?php if( count($connected_accounts) > 0 ) { ?><div id="sbi_user_feed_id_<?php echo $feed_id; ?>" class="sbi_user_feed_account_wrap"><?php } ?>
858
+
859
+ <?php if ( isset( $connected_accounts[ $feed_id ] ) && ! empty( $connected_accounts[ $feed_id ]['username'] ) ) : ?>
860
+ <strong><?php echo $connected_accounts[ $feed_id ]['username']; ?></strong> <span>(<?php echo $feed_id; ?>)</span>
861
+ <input name="sb_instagram_user_id[]" id="sb_instagram_user_id" type="hidden" value="<?php echo esc_attr( $feed_id ); ?>" />
862
+ <?php elseif ( isset( $connected_accounts[ $feed_id ] ) && ! empty( $connected_accounts[ $feed_id ]['access_token'] ) ) : ?>
863
+ <strong><?php echo $feed_id; ?></strong>
864
+ <input name="sb_instagram_user_id[]" id="sb_instagram_user_id" type="hidden" value="<?php echo esc_attr( $feed_id ); ?>" />
865
+ <?php endif; ?>
866
+
867
+ <?php if( count($connected_accounts) > 0 ) { ?></div><?php } ?>
868
+ <?php endif; endforeach; ?>
869
+ </div>
870
+
871
+ <?php if ( empty( $user_feed_ids ) ) : ?>
872
+ <p class="sbi_no_accounts" style="margin-top: -3px; margin-right: 10px;"><?php _e( 'Connect a user account above', 'instagram-feed' ); ?></p>
873
+ <?php endif; ?>
874
+
875
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);" style="margin: 5px 0 10px 0; display: inline-block; height: 19px;"><?php _e("How to display User feeds", 'instagram-feed' ); ?></a>
876
+ <div class="sbi_tooltip"><?php _e("<p><b>Displaying Posts from Your User Account</b><br />Simply 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 />
877
+ </div>
878
+
879
+ </div>
880
+
881
+ <div class="sbi_pro sbi_row">
882
+ <div class="sbi_col sbi_one">
883
+ <input disabled type="radio" name="sb_instagram_type" id="sb_instagram_type_hashtag" value="hashtag" <?php if($sb_instagram_type == "hashtag") echo "checked"; ?> />
884
+ <label class="sbi_radio_label" for="sb_instagram_type_hashtag"><?php _e( 'Hashtag:', 'instagram-feed' ); ?></label>
885
+ </div>
886
+ <div class="sbi_col sbi_two">
887
+
888
+ <p class="sbi_pro_tooltip"><?php _e( 'Upgrade to the Pro version to display Hashtag and Tagged feeds', 'instagram-feed' ); ?><i class="fa fa-caret-down" aria-hidden="true"></i></p>
889
+ <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=hashtags" target="_blank" class="sbi_lock"><i class="fa fa-rocket"></i><?php _e('Pro', 'instagram-feed'); ?></a>
890
+
891
+ <input readonly type="text" size="25" style="height: 32px; top: -2px; position: relative; box-shadow: none;" disabled />
892
+ &nbsp;<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed' ); ?></a>
893
+
894
+ <p class="sbi_tooltip"><?php _e( 'Display posts from a specific hashtag instead of from a user', 'instagram-feed' ); ?></p>
895
+ </div>
896
+ </div>
897
+
898
+ <div class="sbi_pro sbi_row">
899
+ <div class="sbi_col sbi_one">
900
+ <input disabled type="radio" name="sb_instagram_type" id="sb_instagram_type_tagged" value="tagged" <?php if($sb_instagram_type == "tagged") echo "checked"; ?> />
901
+ <label class="sbi_radio_label" for="sb_instagram_type_tagged"><?php _e( 'Tagged:', 'instagram-feed' ); ?></label>
902
+ </div>
903
+ <div class="sbi_col sbi_two">
904
+ <input readonly type="text" size="25" style="height: 32px; top: -2px; position: relative; box-shadow: none;" disabled />
905
+ &nbsp;<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed' ); ?></a>
906
+
907
+ <p class="sbi_tooltip"><?php _e( 'Display posts that your account has been tagged in.', 'instagram-feed' ); ?></p>
908
+ </div>
909
+ </div>
910
+
911
+ <div class="sbi_row sbi_pro">
912
+ <br>
913
+ <a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);" style="margin-left: 0;"><i class="fa fa-question-circle" aria-hidden="true" style="margin-right: 6px;"></i><?php _e('Combine multiple feed types into a single feed', 'instagram-feed'); ?></a>
914
+ <p class="sbi_tooltip">
915
+ <b><?php _e( 'Please note: this is only available in the <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=multipletypes" target="_blank">Pro version</a>', 'instagram-feed' ); ?>.</b><br />
916
+ <?php echo sprintf( __('To display multiple feed types in a single feed, use %s in your shortcode and then add each user name or hashtag of each feed into the shortcode, like so: %s. This will combine a user feed and a hashtag feed into the same feed.', 'instagram-feed'), 'type="mixed"', '<code>[instagram-feed type="mixed" user="smashballoon" hashtag="#awesomeplugins"]</code>' ); ?>
917
+ </p>
918
+ </div>
919
+
920
+ </td>
921
+ </tr>
922
+
923
+ <tr>
924
+ <th class="bump-left"><label for="sb_instagram_preserve_settings" class="bump-left"><?php _e("Preserve settings when plugin is removed", 'instagram-feed'); ?></label></th>
925
+ <td>
926
+ <input name="sb_instagram_preserve_settings" type="checkbox" id="sb_instagram_preserve_settings" <?php if($sb_instagram_preserve_settings == true) echo "checked"; ?> />
927
+ <label for="sb_instagram_preserve_settings"><?php _e('Yes', 'instagram-feed'); ?></label>
928
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
929
+ <p class="sbi_tooltip"><?php _e('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.', 'instagram-feed'); ?></p>
930
+ </td>
931
+ </tr>
932
+
933
+
934
+ <tr valign="top" class="sbi_cron_cache_opts">
935
+ <th scope="row"><?php _e( 'Check for new posts', 'instagram-feed' ); ?></th>
936
+ <td>
937
+
938
+ <div class="sbi_row">
939
+ <input type="radio" name="sbi_caching_type" id="sbi_caching_type_page" value="page" <?php if ( $sbi_caching_type === 'page' ) echo 'checked'; ?>>
940
+ <label for="sbi_caching_type_page"><?php _e( 'When the page loads', 'instagram-feed' ); ?></label>
941
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);" style="position: relative; top: 2px;"><i class="fa fa-question-circle" aria-hidden="true"></i></a>
942
+ <p class="sbi_tooltip sbi-more-info"><?php _e( 'Your Instagram post 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', 'instagram-feed' ); ?>:<br><br>
943
+ <?php _e( '<b>1. When the page loads</b><br>Selecting this option means that when the cache expires then the plugin will check Instagram for new posts the next time that the feed is loaded. You can choose how long this data should be cached for. 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.', 'instagram-feed' ); ?>
944
+ <br><br>
945
+ <?php _e( '<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.</p>', 'instagram-feed' ); ?>
946
+ </div>
947
+ <div class="sbi_row sbi-caching-page-options" style="display: none;">
948
+ <?php _e( 'Every', 'instagram-feed' ); ?>:
949
+ <input name="sb_instagram_cache_time" type="text" value="<?php echo esc_attr( $sb_instagram_cache_time ); ?>" size="4" />
950
+ <select name="sb_instagram_cache_time_unit">
951
+ <option value="minutes" <?php if($sb_instagram_cache_time_unit == "minutes") echo 'selected="selected"' ?> ><?php _e('Minutes', 'instagram-feed'); ?></option>
952
+ <option value="hours" <?php if($sb_instagram_cache_time_unit == "hours") echo 'selected="selected"' ?> ><?php _e('Hours', 'instagram-feed'); ?></option>
953
+ <option value="days" <?php if($sb_instagram_cache_time_unit == "days") echo 'selected="selected"' ?> ><?php _e('Days', 'instagram-feed'); ?></option>
954
+ </select>
955
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
956
+ <p class="sbi_tooltip"><?php _e('Your Instagram 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 Instagram for posts again.', 'instagram-feed'); ?></p>
957
+ </div>
958
+
959
+ <div class="sbi_row">
960
+ <input type="radio" name="sbi_caching_type" id="sbi_caching_type_cron" value="background" <?php if ( $sbi_caching_type === 'background' ) echo 'checked'; ?>>
961
+ <label for="sbi_caching_type_cron"><?php _e( 'In the background', 'instagram-feed' ); ?></label>
962
+ </div>
963
+ <div class="sbi_row sbi-caching-cron-options" style="display: block;">
964
+
965
+ <select name="sbi_cache_cron_interval" id="sbi_cache_cron_interval">
966
+ <option value="30mins" <?php if ( $sbi_cache_cron_interval === '30mins' ) echo 'selected'; ?>><?php _e( 'Every 30 minutes', 'instagram-feed' ); ?></option>
967
+ <option value="1hour" <?php if ( $sbi_cache_cron_interval === '1hour' ) echo 'selected'; ?>><?php _e( 'Every hour', 'instagram-feed' ); ?></option>
968
+ <option value="12hours" <?php if ( $sbi_cache_cron_interval === '12hours' ) echo 'selected'; ?>><?php _e( 'Every 12 hours', 'instagram-feed' ); ?></option>
969
+ <option value="24hours" <?php if ( $sbi_cache_cron_interval === '24hours' ) echo 'selected'; ?>><?php _e( 'Every 24 hours', 'instagram-feed' ); ?></option>
970
+ </select>
971
+
972
+ <div id="sbi-caching-time-settings" style="display: none;">
973
+ <?php _e('at' ); ?>
974
+
975
+ <select name="sbi_cache_cron_time" style="width: 80px">
976
+ <option value="1" <?php if ( $sbi_cache_cron_time === '1' ) echo 'selected'; ?>>1:00</option>
977
+ <option value="2" <?php if ( $sbi_cache_cron_time === '2' ) echo 'selected'; ?>>2:00</option>
978
+ <option value="3" <?php if ( $sbi_cache_cron_time === '3' ) echo 'selected'; ?>>3:00</option>
979
+ <option value="4" <?php if ( $sbi_cache_cron_time === '4' ) echo 'selected'; ?>>4:00</option>
980
+ <option value="5" <?php if ( $sbi_cache_cron_time === '5' ) echo 'selected'; ?>>5:00</option>
981
+ <option value="6" <?php if ( $sbi_cache_cron_time === '6' ) echo 'selected'; ?>>6:00</option>
982
+ <option value="7" <?php if ( $sbi_cache_cron_time === '7' ) echo 'selected'; ?>>7:00</option>
983
+ <option value="8" <?php if ( $sbi_cache_cron_time === '8' ) echo 'selected'; ?>>8:00</option>
984
+ <option value="9" <?php if ( $sbi_cache_cron_time === '9' ) echo 'selected'; ?>>9:00</option>
985
+ <option value="10" <?php if ( $sbi_cache_cron_time === '10' ) echo 'selected'; ?>>10:00</option>
986
+ <option value="11" <?php if ( $sbi_cache_cron_time === '11' ) echo 'selected'; ?>>11:00</option>
987
+ <option value="0" <?php if ( $sbi_cache_cron_time === '0' ) echo 'selected'; ?>>12:00</option>
988
+ </select>
989
+
990
+ <select name="sbi_cache_cron_am_pm" style="width: 50px">
991
+ <option value="am" <?php if ( $sbi_cache_cron_am_pm === 'am' ) echo 'selected'; ?>>AM</option>
992
+ <option value="pm" <?php if ( $sbi_cache_cron_am_pm === 'pm' ) echo 'selected'; ?>>PM</option>
993
+ </select>
994
+ </div>
995
+
996
+ <?php
997
+ if ( wp_next_scheduled( 'sbi_feed_update' ) ) {
998
+ $time_format = get_option( 'time_format' );
999
+ if ( ! $time_format ) {
1000
+ $time_format = 'g:i a';
1001
+ }
1002
+ //
1003
+ $schedule = wp_get_schedule( 'sbi_feed_update' );
1004
+ if ( $schedule == '30mins' ) $schedule = __( 'every 30 minutes', 'instagram-feed' );
1005
+ if ( $schedule == 'twicedaily' ) $schedule = __( 'every 12 hours', 'instagram-feed' );
1006
+ $sbi_next_cron_event = wp_next_scheduled( 'sbi_feed_update' );
1007
+ echo '<p class="sbi-caching-sched-notice"><span><b>' . __( 'Next check', 'instagram-feed' ) . ': ' . date( $time_format, $sbi_next_cron_event + sbi_get_utc_offset() ) . ' (' . $schedule . ')</b> - ' . __( 'Note: Saving the settings on this page will clear the cache and reset this schedule', 'instagram-feed' ) . '</span></p>';
1008
+ } else {
1009
+ echo '<p style="font-size: 11px; color: #666;">' . __( 'Nothing currently scheduled', 'instagram-feed' ) . '</p>';
1010
+ }
1011
+ ?>
1012
+
1013
+ </div>
1014
+
1015
+ </td>
1016
+ </tr>
1017
+
1018
+ </tbody>
1019
+ </table>
1020
+
1021
+ <?php submit_button(); ?>
1022
+ </form>
1023
+
1024
+ <p><i class="fa fa-chevron-circle-right" aria-hidden="true"></i>&nbsp; <?php _e('Next Step: <a href="?page=sb-instagram-feed&tab=customize">Customize your Feed</a>', 'instagram-feed'); ?></p>
1025
+
1026
+ <p><i class="fa fa-life-ring" aria-hidden="true"></i>&nbsp; <?php _e('Need help setting up the plugin? Check out our <a href="https://smashballoon.com/instagram-feed/free/?utm_campaign=instagram-free&utm_source=supportpage&utm_medium=setupdirections" target="_blank">setup directions</a>', 'instagram-feed'); ?></p>
1027
+
1028
+
1029
+ <?php } // End Configure tab ?>
1030
+
1031
+
1032
+
1033
+ <?php if( $sbi_active_tab == 'customize' ) { //Start Configure tab ?>
1034
+
1035
+ <p class="sb_instagram_contents_links" id="general">
1036
+ <span><?php _e( 'Quick links:', 'instagram-feed' ); ?> </span>
1037
+ <a href="#general"><?php _e( 'General', 'instagram-feed' ); ?></a>
1038
+ <a href="#layout"><?php _e( 'Layout', 'instagram-feed' ); ?></a>
1039
+ <a href="#photos"><?php _e( 'Photos', 'instagram-feed' ); ?></a>
1040
+ <a href="#headeroptions"><?php _e( 'Header', 'instagram-feed' ); ?></a>
1041
+ <a href="#loadmore"><?php _e( "'Load More' Button", 'instagram-feed' ); ?></a>
1042
+ <a href="#follow"><?php _e( "'Follow' Button", 'instagram-feed' ); ?></a>
1043
+ <a href="#customcss"><?php _e( 'Custom CSS', 'instagram-feed' ); ?></a>
1044
+ <a href="#customjs"><?php _e( 'Custom JavaScript', 'instagram-feed' ); ?></a>
1045
+ </p>
1046
+
1047
+ <input type="hidden" name="<?php echo $sb_instagram_customize_hidden_field; ?>" value="Y">
1048
+
1049
+ <h3><?php _e( 'General', 'instagram-feed' ); ?></h3>
1050
+
1051
+ <table class="form-table">
1052
+ <tbody>
1053
+ <tr valign="top">
1054
+ <th scope="row"><label><?php _e('Width of Feed', 'instagram-feed'); ?></label><code class="sbi_shortcode"> width widthunit
1055
+ Eg: width=50 widthunit=%</code></th>
1056
+ <td>
1057
+ <input name="sb_instagram_width" type="text" value="<?php echo esc_attr( $sb_instagram_width ); ?>" id="sb_instagram_width" size="4" maxlength="4" />
1058
+ <select name="sb_instagram_width_unit" id="sb_instagram_width_unit">
1059
+ <option value="px" <?php if($sb_instagram_width_unit == "px") echo 'selected="selected"' ?> ><?php _e('px', 'instagram-feed'); ?></option>
1060
+ <option value="%" <?php if($sb_instagram_width_unit == "%") echo 'selected="selected"' ?> ><?php _e('%', 'instagram-feed'); ?></option>
1061
+ </select>
1062
+ <div id="sb_instagram_width_options">
1063
+ <input name="sb_instagram_feed_width_resp" type="checkbox" id="sb_instagram_feed_width_resp" <?php if($sb_instagram_feed_width_resp == true) echo "checked"; ?> /><label for="sb_instagram_feed_width_resp"><?php _e('Set to be 100% width on mobile?', 'instagram-feed'); ?></label>
1064
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e( 'What does this mean?', 'instagram-feed' ); ?></a>
1065
+ <p class="sbi_tooltip"><?php _e("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.", 'instagram-feed'); ?></p>
1066
+ </div>
1067
+ </td>
1068
+ </tr>
1069
+ <tr valign="top">
1070
+ <th scope="row"><label><?php _e('Height of Feed', 'instagram-feed'); ?></label><code class="sbi_shortcode"> height heightunit
1071
+ Eg: height=500 heightunit=px</code></th>
1072
+ <td>
1073
+ <input name="sb_instagram_height" type="text" value="<?php echo esc_attr( $sb_instagram_height ); ?>" size="4" maxlength="4" />
1074
+ <select name="sb_instagram_height_unit">
1075
+ <option value="px" <?php if($sb_instagram_height_unit == "px") echo 'selected="selected"' ?> ><?php _e('px', 'instagram-feed'); ?></option>
1076
+ <option value="%" <?php if($sb_instagram_height_unit == "%") echo 'selected="selected"' ?> ><?php _e('%', 'instagram-feed'); ?></option>
1077
+ </select>
1078
+ </td>
1079
+ </tr>
1080
+ <tr valign="top">
1081
+ <th scope="row"><label><?php _e('Background Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> background
1082
+ Eg: background=d89531</code></th>
1083
+ <td>
1084
+ <input name="sb_instagram_background" type="text" value="<?php echo esc_attr( $sb_instagram_background ); ?>" class="sbi_colorpick" />
1085
+ </td>
1086
+ </tr>
1087
+ </tbody>
1088
+ </table>
1089
+
1090
+ <hr id="layout" />
1091
+ <h3><?php _e('Layout', 'instagram-feed'); ?></h3>
1092
+
1093
+ <table class="form-table">
1094
+ <tbody>
1095
+ <?php
1096
+ $selected_type = isset( $sb_instagram_layout_type ) ? $sb_instagram_layout_type : 'grid';
1097
+ $layout_types = array(
1098
+ 'grid' => __( 'Grid', 'instagram-feed' ),
1099
+ 'carousel' => __( 'Carousel', 'instagram-feed' ),
1100
+ 'masonry' => __( 'Masonry', 'instagram-feed' ),
1101
+ 'highlight' => __( 'Highlight', 'instagram-feed' )
1102
+ );
1103
+ $layout_images = array(
1104
+ 'grid' => SBI_PLUGIN_URL . 'img/grid.png',
1105
+ 'carousel' => SBI_PLUGIN_URL . 'img/carousel.png',
1106
+ 'masonry' => SBI_PLUGIN_URL . 'img/masonry.png',
1107
+ 'highlight' => SBI_PLUGIN_URL . 'img/highlight.png'
1108
+ );
1109
+ ?>
1110
+ <tr valign="top">
1111
+ <th scope="row" class="sbi_pro"><label title="<?php _e('Click for shortcode option', 'instagram-feed'); ?>"><?php _e('Layout Type', 'instagram-feed'); ?></label><br /><span class="sbi_note" style="margin: 5px 0 0 0; font-weight: normal;"><?php _e('Select a layout to see associated<br />options', 'instagram-feed'); ?></span></th>
1112
+ <td>
1113
+ <div class="sbi_layouts">
1114
+ <?php foreach( $layout_types as $layout_type => $label ) : ?>
1115
+ <div class="sbi_layout_cell sbi_pro">
1116
+ <input class="sb_layout_type" id="sb_layout_type_<?php echo esc_attr( $layout_type ); ?>" name="sb_instagram_layout_type" type="radio" value="<?php echo esc_attr( $layout_type ); ?>" <?php if ( $selected_type === $layout_type ) echo 'checked'; ?>/><label for="sb_layout_type_<?php echo esc_attr( $layout_type ); ?>"><span class="sbi_label"><?php echo esc_html( $label ); ?></span><img src="<?php echo esc_url( $layout_images[ $layout_type ] ); ?>" /></label>
1117
+ </div>
1118
+ <?php endforeach; ?>
1119
+
1120
+ <p class="sbi_pro_tooltip"><?php _e('Upgrade to the Pro version to unlock these layouts', 'instagram-feed'); ?><i class="fa fa-caret-down" aria-hidden="true"></i></p>
1121
+ <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=layouts" target="_blank" class="sbi_lock"><i class="fa fa-rocket"></i><?php _e('Pro', 'instagram-feed'); ?></a>
1122
+
1123
+ </div>
1124
+ <div class="sb_layout_options_wrap sbi_pro">
1125
+ <a href="JavaScript:void(0);" class="sbi_close_options"><i class="fa fa-close"></i></a>
1126
+ <div class="sb_instagram_layout_settings sbi_layout_type_grid">
1127
+ <i class="fa fa-info-circle" aria-hidden="true" style="margin-right: 8px;"></i><span class="sbi_note" style="margin-left: 0;"><?php _e('A uniform grid of square-cropped images.', 'instagram-feed'); ?></span>
1128
+ </div>
1129
+ <div class="sb_instagram_layout_settings sbi_layout_type_masonry">
1130
+ <i class="fa fa-info-circle" aria-hidden="true" style="margin-right: 8px;"></i><span class="sbi_note" style="margin-left: 0;"><?php _e('Images in their original aspect ratios with no vertical space between posts.', 'instagram-feed'); ?></span>
1131
+ </div>
1132
+ <div class="sb_instagram_layout_settings sbi_layout_type_carousel">
1133
+ <div class="sb_instagram_layout_setting">
1134
+ <i class="fa fa-info-circle" aria-hidden="true" style="margin-right: 8px;"></i><span class="sbi_note" style="margin-left: 0;"><?php _e('Posts are displayed in a slideshow carousel.', 'instagram-feed'); ?></span>
1135
+ </div>
1136
+ <div class="sb_instagram_layout_setting">
1137
+
1138
+ <label><?php _e('Number of Rows', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouselrows
1139
+ Eg: carouselrows=2</code>
1140
+ <br>
1141
+ <span class="sbi_note" style="margin: -5px 0 -10px 0; display: block;"><?php _e('Use the "Number of Columns" setting below this section to set how many posts are visible in the carousel at a given time.', 'instagram-feed'); ?></span>
1142
+ <br>
1143
+ <select name="sb_instagram_carousel_rows" id="sb_instagram_carousel_rows">
1144
+ <option value="1">1</option>
1145
+ <option value="2" selected="selected">2</option>
1146
+ </select>
1147
+ </div>
1148
+ <div class="sb_instagram_layout_setting">
1149
+ <label><?php _e('Loop Type', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouselloop
1150
+ Eg: carouselloop=rewind
1151
+ carouselloop=infinity</code>
1152
+ <br>
1153
+ <select name="sb_instagram_carousel_loop" id="sb_instagram_carousel_loop">
1154
+ <option value="rewind"><?php _e('Rewind', 'instagram-feed'); ?></option>
1155
+ <option value="infinity" selected="selected"><?php _e('Infinity', 'instagram-feed'); ?></option>
1156
+ </select>
1157
+ </div>
1158
+ <div class="sb_instagram_layout_setting">
1159
+ <input type="checkbox" name="sb_instagram_carousel_arrows" id="sb_instagram_carousel_arrows" checked="checked">
1160
+ <label><?php _e('Show Navigation Arrows', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouselarrows
1161
+ Eg: carouselarrows=true</code>
1162
+ </div>
1163
+ <div class="sb_instagram_layout_setting">
1164
+ <input type="checkbox" name="sb_instagram_carousel_pag" id="sb_instagram_carousel_pag">
1165
+ <label><?php _e('Show Pagination', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouselpag
1166
+ Eg: carouselpag=true</code>
1167
+ </div>
1168
+ <div class="sb_instagram_layout_setting">
1169
+ <input type="checkbox" name="sb_instagram_carousel_autoplay" id="sb_instagram_carousel_autoplay">
1170
+ <label><?php _e('Enable Autoplay', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouselautoplay
1171
+ Eg: carouselautoplay=true</code>
1172
+ </div>
1173
+ <div class="sb_instagram_layout_setting">
1174
+ <label><?php _e('Interval Time', 'instagram-feed'); ?></label><code class="sbi_shortcode"> carouseltime
1175
+ Eg: carouseltime=8000</code>
1176
+ <br>
1177
+ <input name="sb_instagram_carousel_interval" type="text" value="5000" size="6"><?php _e("miliseconds", 'instagram-feed'); ?>
1178
+ </div>
1179
+ </div>
1180
+
1181
+ <div class="sb_instagram_layout_settings sbi_layout_type_highlight">
1182
+ <div class="sb_instagram_layout_setting">
1183
+ <i class="fa fa-info-circle" aria-hidden="true" style="margin-right: 8px;"></i><span class="sbi_note" style="margin-left: 0;"><?php _e('Masonry style, square-cropped, image only (no captions or likes/comments below image). "Highlighted" posts are twice as large.', 'instagram-feed'); ?></span>
1184
+ </div>
1185
+ <div class="sb_instagram_layout_setting">
1186
+ <label title="Click for shortcode option"><?php _e('Highlighting Type', 'instagram-feed'); ?></label><code class="sbi_shortcode"> highlighttype
1187
+ Eg: highlighttype=pattern</code>
1188
+ <br>
1189
+ <select name="sb_instagram_highlight_type" id="sb_instagram_highlight_type">
1190
+ <option value="pattern" selected="selected"><?php _e('Pattern', 'instagram-feed'); ?></option>
1191
+ <option value="id"><?php _e('Post ID', 'instagram-feed'); ?></option>
1192
+ <option value="hashtag"><?php _e('Hashtag', 'instagram-feed'); ?></option>
1193
+ </select>
1194
+ </div>
1195
+ <div class="sb_instagram_highlight_sub_options sb_instagram_highlight_pattern sb_instagram_layout_setting" style="display: block;">
1196
+ <label></label><code class="sbi_shortcode"> highlightoffset
1197
+ Eg: highlightoffset=2</code>
1198
+ <br>
1199
+ <input name="sb_instagram_highlight_offset" type="number" min="0" value="0" style="width: 50px;">
1200
+ </div>
1201
+ <div class="sb_instagram_highlight_sub_options sb_instagram_highlight_pattern sb_instagram_layout_setting" style="display: block;">
1202
+ <label><?php _e('Pattern', 'instagram-feed'); ?></label><code class="sbi_shortcode"> highlightpattern
1203
+ Eg: highlightpattern=3</code>
1204
+ <br>
1205
+ <span><?php _e('Highlight every', 'instagram-feed'); ?></span><input name="sb_instagram_highlight_factor" type="number" min="2" value="6" style="width: 50px;"><span><?php _e('posts', 'instagram-feed'); ?></span>
1206
+ </div>
1207
+ <div class="sb_instagram_highlight_sub_options sb_instagram_highlight_hashtag sb_instagram_layout_setting" style="display: none;">
1208
+ <label><?php _e('Highlight Posts with these Hashtags', 'instagram-feed'); ?></label>
1209
+ <input name="sb_instagram_highlight_hashtag" id="sb_instagram_highlight_hashtag" type="text" size="40" value="#fishing">&nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What is this?', 'instagram-feed'); ?></a>
1210
+ <br>
1211
+ <span class="sbi_note" style="margin-left: 0;"><?php _e('Separate multiple hashtags using commas', 'instagram-feed'); ?></span>
1212
+
1213
+
1214
+ <p class="sbi_tooltip"><?php _e('You can use this setting to highlight posts by a hashtag. Use a specified hashtag in your posts and they will be automatically highlighted in your feed.', 'instagram-feed'); ?></p>
1215
+ </div>
1216
+ <div class="sb_instagram_highlight_sub_options sb_instagram_highlight_ids sb_instagram_layout_setting" style="display: none;">
1217
+ <label><?php _e('Highlight Posts by ID', 'instagram-feed'); ?></label>
1218
+ <textarea name="sb_instagram_highlight_ids" id="sb_instagram_highlight_ids" style="width: 100%;" rows="3">sbi_1852317219231323590_3269008872</textarea>
1219
+ <br>
1220
+ <span class="sbi_note" style="margin-left: 0;"><?php _e('Separate IDs using commas', 'instagram-feed'); ?></span>
1221
+
1222
+ &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What is this?', 'instagram-feed'); ?></a>
1223
+ <p class="sbi_tooltip"><?php _e('You can use this setting to highlight posts by their ID. Enable and use "moderation mode", check the box to show post IDs underneath posts, then copy and paste IDs into this text box.', 'instagram-feed'); ?></p>
1224
+ </div>
1225
+ </div>
1226
+
1227
+ </div>
1228
+ </td>
1229
+ </tr>
1230
+ <tr valign="top">
1231
+ <th scope="row"><label><?php _e('Number of Photos', 'instagram-feed'); ?></label><code class="sbi_shortcode"> num
1232
+ Eg: num=6</code></th>
1233
+ <td>
1234
+ <input name="sb_instagram_num" type="text" value="<?php echo esc_attr( $sb_instagram_num ); ?>" size="4" maxlength="4" />
1235
+ <span class="sbi_note"><?php _e('Number of photos to show initially.', 'instagram-feed'); ?></span>
1236
+ </td>
1237
+ </tr>
1238
+ <tr valign="top">
1239
+ <th scope="row"><label><?php _e('Number of Columns', 'instagram-feed'); ?></label><code class="sbi_shortcode"> cols
1240
+ Eg: cols=3</code></th>
1241
+ <td>
1242
+ <select name="sb_instagram_cols">
1243
+ <option value="1" <?php if($sb_instagram_cols == "1") echo 'selected="selected"' ?> ><?php _e('1', 'instagram-feed'); ?></option>
1244
+ <option value="2" <?php if($sb_instagram_cols == "2") echo 'selected="selected"' ?> ><?php _e('2', 'instagram-feed'); ?></option>
1245
+ <option value="3" <?php if($sb_instagram_cols == "3") echo 'selected="selected"' ?> ><?php _e('3', 'instagram-feed'); ?></option>
1246
+ <option value="4" <?php if($sb_instagram_cols == "4") echo 'selected="selected"' ?> ><?php _e('4', 'instagram-feed'); ?></option>
1247
+ <option value="5" <?php if($sb_instagram_cols == "5") echo 'selected="selected"' ?> ><?php _e('5', 'instagram-feed'); ?></option>
1248
+ <option value="6" <?php if($sb_instagram_cols == "6") echo 'selected="selected"' ?> ><?php _e('6', 'instagram-feed'); ?></option>
1249
+ <option value="7" <?php if($sb_instagram_cols == "7") echo 'selected="selected"' ?> ><?php _e('7', 'instagram-feed'); ?></option>
1250
+ <option value="8" <?php if($sb_instagram_cols == "8") echo 'selected="selected"' ?> ><?php _e('8', 'instagram-feed'); ?></option>
1251
+ <option value="9" <?php if($sb_instagram_cols == "9") echo 'selected="selected"' ?> ><?php _e('9', 'instagram-feed'); ?></option>
1252
+ <option value="10" <?php if($sb_instagram_cols == "10") echo 'selected="selected"' ?> ><?php _e('10', 'instagram-feed'); ?></option>
1253
+ </select>
1254
+ </td>
1255
+ </tr>
1256
+ <tr valign="top">
1257
+ <th scope="row"><label><?php _e('Padding around Images', 'instagram-feed'); ?></label><code class="sbi_shortcode"> imagepadding imagepaddingunit</code></th>
1258
+ <td>
1259
+ <input name="sb_instagram_image_padding" type="text" value="<?php echo esc_attr( $sb_instagram_image_padding ); ?>" size="4" maxlength="4" />
1260
+ <select name="sb_instagram_image_padding_unit">
1261
+ <option value="px" <?php if($sb_instagram_image_padding_unit == "px") echo 'selected="selected"' ?> ><?php _e('px', 'instagram-feed'); ?></option>
1262
+ <option value="%" <?php if($sb_instagram_image_padding_unit == "%") echo 'selected="selected"' ?> ><?php _e('%', 'instagram-feed'); ?></option>
1263
+ </select>
1264
+ </td>
1265
+ </tr>
1266
+ <tr valign="top">
1267
+ <th scope="row"><label><?php _e("Disable mobile layout", 'instagram-feed'); ?></label><code class="sbi_shortcode"> disablemobile
1268
+ Eg: disablemobile=true</code></th>
1269
+ <td>
1270
+ <input type="checkbox" name="sb_instagram_disable_mobile" id="sb_instagram_disable_mobile" <?php if($sb_instagram_disable_mobile == true) echo 'checked="checked"' ?> />
1271
+ &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e( 'What does this mean?', 'instagram-feed' ); ?></a>
1272
+ <p class="sbi_tooltip"><?php _e("By default on mobile devices the layout automatically changes to use fewer columns. Checking this setting disables the mobile layout.", 'instagram-feed'); ?></p>
1273
+ </td>
1274
+ </tr>
1275
+ </tbody>
1276
+ </table>
1277
+
1278
+ <?php submit_button(); ?>
1279
+
1280
+ <hr id="photos" />
1281
+ <h3><?php _e('Photos', 'instagram-feed'); ?></h3>
1282
+
1283
+ <table class="form-table">
1284
+ <tbody>
1285
+ <tr valign="top">
1286
+ <th scope="row"><label><?php _e('Sort Photos By', 'instagram-feed'); ?></label><code class="sbi_shortcode"> sortby
1287
+ Eg: sortby=random</code></th>
1288
+ <td>
1289
+ <select name="sb_instagram_sort">
1290
+ <option value="none" <?php if($sb_instagram_sort == "none") echo 'selected="selected"' ?> ><?php _e('Newest to oldest', 'instagram-feed'); ?></option>
1291
+ <option value="random" <?php if($sb_instagram_sort == "random") echo 'selected="selected"' ?> ><?php _e('Random', 'instagram-feed'); ?></option>
1292
+ </select>
1293
+ </td>
1294
+ </tr>
1295
+ <tr valign="top">
1296
+ <th scope="row"><label><?php _e('Image Resolution', 'instagram-feed'); ?></label><code class="sbi_shortcode"> imageres
1297
+ Eg: imageres=thumb</code></th>
1298
+ <td>
1299
+
1300
+ <select name="sb_instagram_image_res">
1301
+ <option value="auto" <?php if($sb_instagram_image_res == "auto") echo 'selected="selected"' ?> ><?php _e('Auto-detect (recommended)', 'instagram-feed'); ?></option>
1302
+ <option value="thumb" <?php if($sb_instagram_image_res == "thumb") echo 'selected="selected"' ?> ><?php _e('Thumbnail (150x150)', 'instagram-feed'); ?></option>
1303
+ <option value="medium" <?php if($sb_instagram_image_res == "medium") echo 'selected="selected"' ?> ><?php _e('Medium (320x320)', 'instagram-feed'); ?></option>
1304
+ <option value="full" <?php if($sb_instagram_image_res == "full") echo 'selected="selected"' ?> ><?php _e('Full size (640x640)', 'instagram-feed'); ?></option>
1305
+ </select>
1306
+
1307
+ &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e( 'What does Auto-detect mean?', 'instagram-feed'); ?></a>
1308
+ <p class="sbi_tooltip"><?php _e("Auto-detect means that the plugin automatically sets the image resolution based on the size of your feed.", 'instagram-feed'); ?></p>
1309
+
1310
+ </td>
1311
+ </tr>
1312
+ </tbody>
1313
+ </table>
1314
+
1315
+ <span><a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a></span>
1316
+
1317
+ <div class="sbi-pro-options">
1318
+ <p class="sbi-upgrade-link">
1319
+ <i class="fa fa-rocket" aria-hidden="true"></i>&nbsp; <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=general" target="_blank"><?php _e('Upgrade to Pro to enable these settings', 'instagram-feed'); ?></a>
1320
+ </p>
1321
+ <table class="form-table">
1322
+ <tbody>
1323
+ <tr valign="top" class="sbi_pro">
1324
+ <th scope="row"><label><?php _e('Media Type to Display','instagram-feed'); ?></label></th>
1325
+ <td>
1326
+ <select name="sb_instagram_media_type" disabled>
1327
+ <option value="all"><?php _e('All','instagram-feed'); ?></option>
1328
+ <option value="photos"><?php _e('Photos only','instagram-feed'); ?></option>
1329
+ <option value="videos"><?php _e('Videos only','instagram-feed'); ?></option>
1330
+ </select>
1331
+ </td>
1332
+ </tr>
1333
+
1334
+ <tr valign="top" class="sbi_pro">
1335
+ <th scope="row"><label><?php _e("Enable Pop-up Lightbox", 'instagram-feed'); ?></label></th>
1336
+ <td>
1337
+ <input type="checkbox" name="sb_instagram_captionlinks" id="sb_instagram_captionlinks" disabled />
1338
+ </td>
1339
+ </tr>
1340
+
1341
+ <tr valign="top" class="sbi_pro">
1342
+ <th scope="row"><label><?php _e("Link Posts to URL in Caption (Shoppable feed)",'instagram-feed'); ?></label></th>
1343
+ <td>
1344
+ <input type="checkbox" name="sb_instagram_captionlinks" id="sb_instagram_captionlinks" disabled />
1345
+ &nbsp;<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e("What will this do?",'instagram-feed'); ?></a>
1346
+ <p class="sbi_tooltip"><?php _e("Checking this box will change the link for each post to any url included in the caption for that Instagram post. The lightbox will be disabled. Visit <a href='https://smashballoon.com/make-a-shoppable-feed?utm_campaign=instagram-free&utm_source=settings&utm_medium=shoppable'>this link</a> to learn how this works.",'instagram-feed'); ?></p>
1347
+ </td>
1348
+ </tr>
1349
+ </tbody>
1350
+ </table>
1351
+ </div>
1352
+
1353
+
1354
+ <hr />
1355
+ <h3><?php _e('Photo Hover Style','instagram-feed'); ?></h3>
1356
+
1357
+ <p style="padding-bottom: 18px;">
1358
+ <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=photohover" target="_blank"><?php _e('Upgrade to Pro to enable Photo Hover styles','instagram-feed'); ?></a><br />
1359
+ <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options','instagram-feed'); ?></a>
1360
+ </p>
1361
+
1362
+ <div class="sbi-pro-options" style="margin-top: -15px;">
1363
+ <table class="form-table">
1364
+ <tbody>
1365
+ <tr valign="top" class="sbi_pro">
1366
+ <th scope="row"><label><?php _e('Hover Background Color', 'instagram-feed'); ?></label></th>
1367
+ <td>
1368
+ <input name="sb_hover_background" type="text" disabled class="sbi_colorpick" />
1369
+ </td>
1370
+ </tr>
1371
+ <tr valign="top" class="sbi_pro">
1372
+ <th scope="row"><label><?php _e('Hover Text Color', 'instagram-feed'); ?></label></th>
1373
+ <td>
1374
+ <input name="sb_hover_text" type="text" disabled class="sbi_colorpick" />
1375
+ </td>
1376
+ </tr>
1377
+ <tr valign="top" class="sbi_pro">
1378
+ <th scope="row"><label><?php _e('Information to display', 'instagram-feed'); ?></label></th>
1379
+ <td>
1380
+ <div>
1381
+ <input name="sbi_hover_inc_username" type="checkbox" disabled />
1382
+ <label for="sbi_hover_inc_username"><?php _e('Username', 'instagram-feed'); ?></label>
1383
+ </div>
1384
+ <div>
1385
+ <input name="sbi_hover_inc_icon" type="checkbox" disabled />
1386
+ <label for="sbi_hover_inc_icon"><?php _e('Expand Icon', 'instagram-feed'); ?></label>
1387
+ </div>
1388
+ <div>
1389
+ <input name="sbi_hover_inc_date" type="checkbox" disabled />
1390
+ <label for="sbi_hover_inc_date"><?php _e('Date', 'instagram-feed'); ?></label>
1391
+ </div>
1392
+ <div>
1393
+ <input name="sbi_hover_inc_instagram" type="checkbox" disabled />
1394
+ <label for="sbi_hover_inc_instagram"><?php _e('Instagram Icon/Link', 'instagram-feed'); ?></label>
1395
+ </div>
1396
+ <div>
1397
+ <input name="sbi_hover_inc_location" type="checkbox" disabled />
1398
+ <label for="sbi_hover_inc_location"><?php _e('Location', 'instagram-feed'); ?></label>
1399
+ </div>
1400
+ <div>
1401
+ <input name="sbi_hover_inc_caption" type="checkbox" disabled />
1402
+ <label for="sbi_hover_inc_caption"><?php _e('Caption', 'instagram-feed'); ?></label>
1403
+ </div>
1404
+ <div>
1405
+ <input name="sbi_hover_inc_likes" type="checkbox" disabled />
1406
+ <label for="sbi_hover_inc_likes"><?php _e('Like/Comment Icons', 'instagram-feed'); ?></label>
1407
+ </div>
1408
+ </td>
1409
+ </tr>
1410
+
1411
+ </tbody>
1412
+ </table>
1413
+ </div>
1414
+
1415
+
1416
+ <hr />
1417
+ <h3><?php _e( 'Carousel', 'instagram-feed' ); ?></h3>
1418
+ <p style="padding-bottom: 18px;">
1419
+ <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=carousel" target="_blank"><?php _e('Upgrade to Pro to enable Carousels', 'instagram-feed'); ?></a><br />
1420
+ <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a>
1421
+ </p>
1422
+
1423
+ <div class="sbi-pro-options" style="margin-top: -15px;">
1424
+ <table class="form-table">
1425
+ <tbody>
1426
+ <tr valign="top" class="sbi_pro">
1427
+ <th scope="row"><label><?php _e("Enable Carousel", 'instagram-feed'); ?></label></th>
1428
+ <td>
1429
+ <input type="checkbox" disabled />
1430
+ &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e("What is this?", 'instagram-feed'); ?></a>
1431
+ <p class="sbi_tooltip"><?php _e("Enable this setting to create a carousel slider out of your photos.", 'instagram-feed'); ?></p>
1432
+ </td>
1433
+ </tr>
1434
+ <tr valign="top" class="sbi_pro">
1435
+ <th scope="row"><label><?php _e("Show Navigation Arrows", 'instagram-feed'); ?></label></th>
1436
+ <td>
1437
+ <input type="checkbox" disabled />
1438
+ </td>
1439
+ </tr>
1440
+ <tr valign="top" class="sbi_pro">
1441
+ <th scope="row"><label><?php _e("Show Pagination", 'instagram-feed'); ?></label></th>
1442
+ <td>
1443
+ <input type="checkbox" disabled />
1444
+ </td>
1445
+ </tr>
1446
+ <tr valign="top" class="sbi_pro">
1447
+ <th scope="row"><label><?php _e("Enable Autoplay", 'instagram-feed'); ?></label></th>
1448
+ <td>
1449
+ <input type="checkbox" disabled />
1450
+ </td>
1451
+ </tr>
1452
+ <tr valign="top" class="sbi_pro">
1453
+ <th scope="row"><label><?php _e("Interval Time", 'instagram-feed'); ?></label></th>
1454
+ <td>
1455
+ <input name="sb_instagram_carousel_interval" type="text" disabled size="6" /><?php _e("milliseconds", 'instagram-feed'); ?>
1456
+ </td>
1457
+ </tr>
1458
+ </tbody>
1459
+ </table>
1460
+ </div>
1461
+
1462
+
1463
+
1464
+ <hr id="headeroptions" />
1465
+ <h3><?php _e("Header", 'instagram-feed'); ?></h3>
1466
+ <table class="form-table">
1467
+ <tbody>
1468
+ <tr valign="top">
1469
+ <th scope="row"><label><?php _e("Show Feed Header", 'instagram-feed'); ?></label><code class="sbi_shortcode"> showheader
1470
+ Eg: showheader=false</code></th>
1471
+ <td>
1472
+ <input type="checkbox" name="sb_instagram_show_header" id="sb_instagram_show_header" <?php if($sb_instagram_show_header == true) echo 'checked="checked"' ?> />
1473
+ </td>
1474
+ </tr>
1475
+ <tr valign="top">
1476
+ <th scope="row"><label><?php _e('Header Size', 'instagram-feed'); ?></label><code class="sbi_shortcode"> headersize
1477
+ Eg: headersize=medium</code></th>
1478
+ <td>
1479
+ <select name="sb_instagram_header_size" id="sb_instagram_header_size" style="float: left;">
1480
+ <option value="small" <?php if($sb_instagram_header_size == "small") echo 'selected="selected"' ?> ><?php _e('Small', 'instagram-feed'); ?></option>
1481
+ <option value="medium" <?php if($sb_instagram_header_size == "medium") echo 'selected="selected"' ?> ><?php _e('Medium', 'instagram-feed'); ?></option>
1482
+ <option value="large" <?php if($sb_instagram_header_size == "large") echo 'selected="selected"' ?> ><?php _e('Large', 'instagram-feed'); ?></option>
1483
+ </select>
1484
+ </td>
1485
+ </tr>
1486
+ <tr valign="top">
1487
+ <th scope="row"><label><?php _e("Show Bio Text", 'instagram-feed'); ?></label><code class="sbi_shortcode"> showbio
1488
+ Eg: showbio=false</code></th>
1489
+ <td>
1490
+ <?php $sb_instagram_show_bio = isset( $sb_instagram_show_bio ) ? $sb_instagram_show_bio : true; ?>
1491
+ <input type="checkbox" name="sb_instagram_show_bio" id="sb_instagram_show_bio" <?php if($sb_instagram_show_bio == true) echo 'checked="checked"' ?> />
1492
+ <span class="sbi_note"><?php _e("Only applies for Instagram accounts with bios", 'instagram-feed'); ?></span>
1493
+ <div class="sb_instagram_box" style="display: block;">
1494
+ <div class="sb_instagram_box_setting" style="display: block;">
1495
+ <label style="padding-bottom: 0;"><?php _e("Add Custom Bio Text", 'instagram-feed'); ?></label><code class="sbi_shortcode" style="margin-top: 5px;"> custombio
1496
+ Eg: custombio="My custom bio."</code>
1497
+ <br>
1498
+ <span class="sbi_aside" style="padding-bottom: 5px; display: block;"><?php _e("Use your own custom bio text in the feed header. Bio text is automatically retrieved from Instagram for Business accounts.", 'instagram-feed'); ?></span>
1499
+
1500
+ <textarea type="text" name="sb_instagram_custom_bio" id="sb_instagram_custom_bio" ><?php echo esc_textarea( stripslashes( $sb_instagram_custom_bio ) ); ?></textarea>
1501
+ &nbsp;<a class="sbi_tooltip_link sbi_tooltip_under" href="JavaScript:void(0);"><?php _e("Why is my bio not displaying automatically?", 'instagram-feed'); ?></a>
1502
+ <p class="sbi_tooltip" style="padding: 10px 0 0 0; width: 99%;"><?php echo sprintf( __("Instagram is deprecating their old API for Personal accounts on June 1, 2020. The plugin supports their new API, however, their new API does not yet include the bio text for Personal accounts. If you require this feature then it is available if you convert your Instagram account from a Personal to a Business account by following %s. Note: If you previously had a Personal account connected then the plugin has saved the avatar for that feed and will continue to use it automatically.", 'instagram-feed'), '<a href="https://smashballoon.com/instagram-business-profiles/" target="_blank">these directions</a>' ); ?></p>
1503
+ </div>
1504
+ </div>
1505
+
1506
+ </td>
1507
+ </tr>
1508
+
1509
+ <tr valign="top">
1510
+ <th scope="row"><label><?php _e("Use Custom Avatar", 'instagram-feed'); ?></label><code class="sbi_shortcode"> customavatar
1511
+ Eg: customavatar="https://my-website.com/avatar.jpg"</code></th>
1512
+ <td>
1513
+ <input type="text" name="sb_instagram_custom_avatar" class="large-text" id="sb_instagram_custom_avatar" value="<?php echo esc_attr( stripslashes( $sb_instagram_custom_avatar ) ); ?>" placeholder="https://example.com/avatar.jpg" />
1514
+ <span class="sbi_aside"><?php _e("Avatar is automatically retrieved from Instagram for Business accounts", 'instagram-feed'); ?></span>
1515
+ <br>
1516
+ <a class="sbi_tooltip_link sbi_tooltip_under" href="JavaScript:void(0);"><?php _e("Why is my avatar not displaying automatically?", 'instagram-feed'); ?></a>
1517
+
1518
+ <p class="sbi_tooltip sbi_tooltip_under_text" style="padding: 10px 0 0 0;"><?php echo sprintf( __("Instagram is deprecating their old API for Personal accounts on June 1, 2020. The plugin supports their new API, however, their new API does not yet include the avatar image for Personal accounts. If you require this feature then it is available if you convert your Instagram account from a Personal to a Business account by following %s. Note: If you previously had a Personal account connected then the plugin has saved the bio text for that feed and will continue to use it automatically.", 'instagram-feed'), '<a href="https://smashballoon.com/instagram-business-profiles/" target="_blank">these directions</a>' ); ?></p>
1519
+
1520
+ </td>
1521
+ </tr>
1522
+ <tr valign="top">
1523
+ <th scope="row"><label><?php _e('Header Text Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> headercolor
1524
+ Eg: headercolor=fff</code></th>
1525
+ <td>
1526
+ <input name="sb_instagram_header_color" type="text" value="<?php echo esc_attr( $sb_instagram_header_color ); ?>" class="sbi_colorpick" />
1527
+ </td>
1528
+ </tr>
1529
+ </tbody>
1530
+ </table>
1531
+
1532
+ <span><a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a></span>
1533
+
1534
+ <div class="sbi-pro-options">
1535
+ <p class="sbi-upgrade-link">
1536
+ <i class="fa fa-rocket" aria-hidden="true"></i>&nbsp; <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=header" target="_blank"><?php _e('Upgrade to Pro to enable these settings', 'instagram-feed'); ?></a>
1537
+ </p>
1538
+ <table class="form-table">
1539
+ <tbody>
1540
+ <tr valign="top" class="sbi_pro">
1541
+ <th scope="row"><label><?php _e('Header Style','instagram-feed'); ?></label></th>
1542
+ <td>
1543
+ <select name="sb_instagram_header_style" style="float: left;">
1544
+ <option value="circle"><?php _e('Standard','instagram-feed'); ?></option>
1545
+ <option value="boxed"><?php _e('Boxed','instagram-feed'); ?></option>
1546
+ <option value="centered"><?php _e('Centered','instagram-feed'); ?></option>
1547
+ </select>
1548
+ </td>
1549
+ </tr>
1550
+ <tr valign="top" class="sbi_pro">
1551
+ <th scope="row"><label><?php _e("Show Number of Followers",'instagram-feed'); ?></label></th>
1552
+ <td>
1553
+ <input type="checkbox" disabled />
1554
+ <span class="sbi_note"><?php _e("This only applies when displaying photos from a User ID",'instagram-feed'); ?></span>
1555
+ </td>
1556
+ </tr>
1557
+ </tbody>
1558
+ </table>
1559
+ </div>
1560
+
1561
+ <?php submit_button(); ?>
1562
+
1563
+
1564
+ <hr />
1565
+ <h3><?php _e("Caption", 'instagram-feed'); ?></h3>
1566
+ <p style="padding-bottom: 18px;">
1567
+ <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=caption" target="_blank"><?php _e("Upgrade to Pro to enable Photo Captions", 'instagram-feed'); ?></a><br />
1568
+ <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e("Show Pro Options", 'instagram-feed'); ?></a>
1569
+ </p>
1570
+
1571
+ <div class="sbi-pro-options" style="margin-top: -15px;">
1572
+ <table class="form-table">
1573
+ <tbody>
1574
+ <tr valign="top" class="sbi_pro">
1575
+ <th scope="row"><label><?php _e("Show Caption", 'instagram-feed'); ?></label></th>
1576
+ <td>
1577
+ <input type="checkbox" disabled />
1578
+ </td>
1579
+ </tr>
1580
+ <tr valign="top" class="sbi_pro">
1581
+ <th scope="row"><label><?php _e("Maximum Text Length", 'instagram-feed'); ?></label></th>
1582
+ <td>
1583
+ <input disabled size="4" />Characters
1584
+ &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e("What is this?", 'instagram-feed'); ?></a>
1585
+ <p class="sbi_tooltip"><?php _e("The number of characters of text to display in the caption. An elipsis link will be added to allow the user to reveal more text if desired.", 'instagram-feed'); ?></p>
1586
+ </td>
1587
+ </tr>
1588
+ <tr valign="top" class="sbi_pro">
1589
+ <th scope="row"><label><?php _e('Text Color', 'instagram-feed'); ?></label></th>
1590
+ <td>
1591
+ <input type="text" disabled class="sbi_colorpick" />
1592
+ </td>
1593
+ </tr>
1594
+ <tr valign="top" class="sbi_pro">
1595
+ <th scope="row"><label><?php _e('Text Size', 'instagram-feed'); ?></label></th>
1596
+ <td>
1597
+ <select name="sb_instagram_caption_size" style="width: 180px;" disabled>
1598
+ <option value="inherit" ><?php _e('Inherit from theme', 'instagram-feed'); ?></option>
1599
+ <option value="10" >10px</option>
1600
+ <option value="11" >11px</option>
1601
+ <option value="12" >12px</option>
1602
+ <option value="13" >13px</option>
1603
+ <option value="14" >14px</option>
1604
+ <option value="16" >16px</option>
1605
+ <option value="18" >18px</option>
1606
+ <option value="20" >20px</option>
1607
+ <option value="24" >24px</option>
1608
+ <option value="28" >28px</option>
1609
+ <option value="32" >32px</option>
1610
+ <option value="36" >36px</option>
1611
+ <option value="40" >40px</option>
1612
+ </select>
1613
+ </td>
1614
+ </tr>
1615
+ </tbody>
1616
+ </table>
1617
+ </div>
1618
+
1619
+
1620
+ <hr />
1621
+ <h3><?php _e("Likes &amp; Comments", 'instagram-feed'); ?></h3>
1622
+ <p style="padding-bottom: 18px;">
1623
+ <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=stats" target="_blank"><?php _e("Upgrade to Pro to enable Likes &amp; Comments", 'instagram-feed'); ?></a><br />
1624
+ <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e("Show Pro Options", 'instagram-feed'); ?></a>
1625
+ </p>
1626
+
1627
+ <div class="sbi-pro-options" style="margin-top: -15px;">
1628
+ <table class="form-table">
1629
+ <tbody>
1630
+ <tr valign="top" class="sbi_pro">
1631
+ <th scope="row"><label><?php _e("Show Icons", 'instagram-feed'); ?></label></th>
1632
+ <td>
1633
+ <input type="checkbox" disabled />
1634
+ </td>
1635
+ </tr>
1636
+ <tr valign="top" class="sbi_pro">
1637
+ <th scope="row"><label><?php _e('Icon Color', 'instagram-feed'); ?></label></th>
1638
+ <td>
1639
+ <input type="text" disabled class="sbi_colorpick" />
1640
+ </td>
1641
+ </tr>
1642
+ <tr valign="top" class="sbi_pro">
1643
+ <th scope="row"><label><?php _e('Icon Size', 'instagram-feed'); ?></label></th>
1644
+ <td>
1645
+ <select disabled name="sb_instagram_meta_size" style="width: 180px;">
1646
+ <option value="inherit"><?php _e('Inherit from theme', 'instagram-feed'); ?></option>
1647
+ <option value="10" >10px</option>
1648
+ <option value="11" >11px</option>
1649
+ <option value="12" >12px</option>
1650
+ <option value="13" >13px</option>
1651
+ <option value="14" >14px</option>
1652
+ <option value="16" >16px</option>
1653
+ <option value="18" >18px</option>
1654
+ <option value="20" >20px</option>
1655
+ <option value="24" >24px</option>
1656
+ <option value="28" >28px</option>
1657
+ <option value="32" >32px</option>
1658
+ <option value="36" >36px</option>
1659
+ <option value="40" >40px</option>
1660
+ </select>
1661
+ </td>
1662
+ </tr>
1663
+ </tbody>
1664
+ </table>
1665
+ </div>
1666
+
1667
+
1668
+ <hr />
1669
+ <h3><?php _e('Lightbox Comments', 'instagram-feed'); ?></h3>
1670
+
1671
+ <p style="padding-bottom: 18px;">
1672
+ <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=comments" target="_blank"><?php _e('Upgrade to Pro to enable Comments', 'instagram-feed'); ?></a><br />
1673
+ <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a>
1674
+ </p>
1675
+
1676
+ <div class="sbi-pro-options" style="margin-top: -15px;">
1677
+ <table class="form-table">
1678
+ <tbody>
1679
+
1680
+ <tr valign="top" class="sbi_pro">
1681
+ <th scope="row"><label><?php _e('Show Comments in Lightbox', 'instagram-feed'); ?></label></th>
1682
+ <td style="padding: 5px 10px 0 10px;">
1683
+ <input type="checkbox" disabled style="margin-right: 15px;" />
1684
+ <input class="button-secondary" style="margin-top: -5px;" disabled value="<?php echo esc_attr( 'Clear Comment Cache', 'instagram-feed' ); ?>" />
1685
+ &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e("What is this?", 'instagram-feed'); ?></a>
1686
+ <p class="sbi_tooltip"><?php _e("This will remove the cached comments saved in the database", 'instagram-feed'); ?></p>
1687
+ </td>
1688
+ </tr>
1689
+ <tr valign="top" class="sbi_pro">
1690
+ <th scope="row"><label><?php _e('Number of Comments', 'instagram-feed'); ?></label></th>
1691
+ <td>
1692
+ <input name="sb_instagram_num_comments" type="text" disabled size="4" />
1693
+ <span class="sbi_note"><?php _e('Max number of latest comments.', 'instagram-feed'); ?></span>
1694
+ &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e("What is this?", 'instagram-feed'); ?></a>
1695
+ <p class="sbi_tooltip"><?php _e("This is the maximum number of comments that will be shown in the lightbox. If there are more comments available than the number set, only the latest comments will be shown", 'instagram-feed'); ?></p>
1696
+ </td>
1697
+ </tr>
1698
+
1699
+ </tbody>
1700
+ </table>
1701
+ </div>
1702
+
1703
+
1704
+ <hr id="loadmore" />
1705
+ <h3><?php _e("'Load More' Button", 'instagram-feed'); ?></h3>
1706
+ <table class="form-table">
1707
+ <tbody>
1708
+ <tr valign="top">
1709
+ <th scope="row"><label><?php _e("Show the 'Load More' button", 'instagram-feed'); ?></label><code class="sbi_shortcode"> showbutton
1710
+ Eg: showbutton=false</code></th>
1711
+ <td>
1712
+ <input type="checkbox" name="sb_instagram_show_btn" id="sb_instagram_show_btn" <?php if($sb_instagram_show_btn == true) echo 'checked="checked"' ?> />
1713
+ </td>
1714
+ </tr>
1715
+ <tr valign="top">
1716
+ <th scope="row"><label><?php _e('Button Background Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> buttoncolor
1717
+ Eg: buttoncolor=8224e3</code></th>
1718
+ <td>
1719
+ <input name="sb_instagram_btn_background" type="text" value="<?php echo esc_attr( $sb_instagram_btn_background ); ?>" class="sbi_colorpick" />
1720
+ </td>
1721
+ </tr>
1722
+ <tr valign="top">
1723
+ <th scope="row"><label><?php _e('Button Text Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> buttontextcolor
1724
+ Eg: buttontextcolor=eeee22</code></th>
1725
+ <td>
1726
+ <input name="sb_instagram_btn_text_color" type="text" value="<?php echo esc_attr( $sb_instagram_btn_text_color ); ?>" class="sbi_colorpick" />
1727
+ </td>
1728
+ </tr>
1729
+ <tr valign="top">
1730
+ <th scope="row"><label><?php _e('Button Text', 'instagram-feed'); ?></label><code class="sbi_shortcode"> buttontext
1731
+ Eg: buttontext="Show more.."</code></th>
1732
+ <td>
1733
+ <input name="sb_instagram_btn_text" type="text" value="<?php echo esc_attr( stripslashes( $sb_instagram_btn_text ) ); ?>" size="20" />
1734
+ </td>
1735
+ </tr>
1736
+ </tbody>
1737
+ </table>
1738
+
1739
+ <?php submit_button(); ?>
1740
+
1741
+ <hr id="follow" />
1742
+ <h3><?php _e("'Follow' Button", 'instagram-feed'); ?></h3>
1743
+ <table class="form-table">
1744
+ <tbody>
1745
+ <tr valign="top">
1746
+ <th scope="row"><label><?php _e("Show the Follow button", 'instagram-feed'); ?></label><code class="sbi_shortcode"> showfollow
1747
+ Eg: showfollow=true</code></th>
1748
+ <td>
1749
+ <input type="checkbox" name="sb_instagram_show_follow_btn" id="sb_instagram_show_follow_btn" <?php if($sb_instagram_show_follow_btn == true) echo 'checked="checked"' ?> />
1750
+ </td>
1751
+ </tr>
1752
+
1753
+ <tr valign="top">
1754
+ <th scope="row"><label><?php _e('Button Background Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> followcolor
1755
+ Eg: followcolor=28a1bf</code></th>
1756
+ <td>
1757
+ <input name="sb_instagram_folow_btn_background" type="text" value="<?php echo esc_attr( $sb_instagram_folow_btn_background ); ?>" class="sbi_colorpick" />
1758
+ </td>
1759
+ </tr>
1760
+ <tr valign="top">
1761
+ <th scope="row"><label><?php _e('Button Text Color', 'instagram-feed'); ?></label><code class="sbi_shortcode"> followtextcolor
1762
+ Eg: followtextcolor=000</code></th>
1763
+ <td>
1764
+ <input name="sb_instagram_follow_btn_text_color" type="text" value="<?php echo esc_attr( $sb_instagram_follow_btn_text_color ); ?>" class="sbi_colorpick" />
1765
+ </td>
1766
+ </tr>
1767
+ <tr valign="top">
1768
+ <th scope="row"><label><?php _e('Button Text', 'instagram-feed'); ?></label><code class="sbi_shortcode"> followtext
1769
+ Eg: followtext="Follow me"</code></th>
1770
+ <td>
1771
+ <input name="sb_instagram_follow_btn_text" type="text" value="<?php echo esc_attr( stripslashes( $sb_instagram_follow_btn_text ) ); ?>" size="30" />
1772
+ </td>
1773
+ </tr>
1774
+ </tbody>
1775
+ </table>
1776
+
1777
+ <hr id="filtering" />
1778
+ <h3><?php _e('Post Filtering', 'instagram-feed'); ?></h3>
1779
+
1780
+ <p style="padding-bottom: 18px;">
1781
+ <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=filtering" target="_blank"><?php _e('Upgrade to Pro to enable Post Filtering options', 'instagram-feed'); ?></a><br />
1782
+ <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a>
1783
+ </p>
1784
+
1785
+ <div class="sbi-pro-options" style="margin-top: -15px;">
1786
+
1787
+ <table class="form-table">
1788
+ <tbody>
1789
+ <tr valign="top" class="sbi_pro">
1790
+ <th scope="row"><label><?php _e('Remove photos containing these words or hashtags', 'instagram-feed'); ?></label></th>
1791
+ <td>
1792
+ <div class="sb_instagram_apply_labels">
1793
+ <p><?php _e('Apply to:', 'instagram-feed'); ?></p>
1794
+ <input class="sb_instagram_incex_one_all" type="radio" value="all" disabled /><label><?php _e('All feeds', 'instagram-feed'); ?></label>
1795
+ <input class="sb_instagram_incex_one_all" type="radio" value="one" disabled /><label><?php _e('One feed', 'instagram-feed'); ?></label>
1796
+ </div>
1797
+
1798
+ <input disabled name="sb_instagram_exclude_words" id="sb_instagram_exclude_words" type="text" style="width: 70%;" value="" />
1799
+ <br />
1800
+ <span class="sbi_note" style="margin-left: 0;"><?php _e('Separate words/hashtags using commas', 'instagram-feed'); ?></span>
1801
+ &nbsp;<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed'); ?></a>
1802
+ <p class="sbi_tooltip"><?php _e("You can use this setting to remove photos which contain certain words or hashtags in the caption. Separate multiple words or hashtags using commas.", 'instagram-feed'); ?></p>
1803
+ </td>
1804
+ </tr>
1805
+
1806
+ <tr valign="top" class="sbi_pro">
1807
+ <th scope="row"><label><?php _e('Show photos containing these words or hashtags', 'instagram-feed'); ?></label></th>
1808
+ <td>
1809
+ <div class="sb_instagram_apply_labels">
1810
+ <p><?php _e('Apply to:', 'instagram-feed'); ?></p>
1811
+ <input class="sb_instagram_incex_one_all" type="radio" value="all" disabled /><label><?php _e('All feeds', 'instagram-feed'); ?></label>
1812
+ <input class="sb_instagram_incex_one_all" type="radio" value="one" disabled /><label><?php _e('One feed', 'instagram-feed'); ?></label>
1813
+ </div>
1814
+
1815
+ <input disabled name="sb_instagram_include_words" id="sb_instagram_include_words" type="text" style="width: 70%;" value="" />
1816
+ <br />
1817
+ <span class="sbi_note" style="margin-left: 0;"><?php _e('Separate words/hashtags using commas', 'instagram-feed'); ?></span>
1818
+ &nbsp;<a class="sbi_tooltip_link sbi_pro" href="JavaScript:void(0);"><?php _e( 'What is this?', 'instagram-feed'); ?></a>
1819
+ <p class="sbi_tooltip"><?php _e("You can use this setting to only show photos which contain certain words or hashtags in the caption. For example, adding <code>sheep, cow, dog</code> will show any photos which contain either the word sheep, cow, or dog. Separate multiple words or hashtags using commas.", 'instagram-feed'); ?></p>
1820
+ </td>
1821
+ </tr>
1822
+ </tbody>
1823
+ </table>
1824
+ </div>
1825
+
1826
+
1827
+ <hr id="moderation" />
1828
+ <h3><?php _e('Moderation', 'instagram-feed'); ?></h3>
1829
+
1830
+ <p style="padding-bottom: 18px;">
1831
+ <a href="https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=moderation" target="_blank"><?php _e('Upgrade to Pro to enable Moderation options', 'instagram-feed'); ?></a><br />
1832
+ <a href="javascript:void(0);" class="button button-secondary sbi-show-pro"><b>+</b> <?php _e('Show Pro Options', 'instagram-feed'); ?></a>
1833
+ </p>
1834
+
1835
+ <div class="sbi-pro-options" style="margin-top: -15px;">
1836
+ <table class="form-table">
1837
+ <tbody>
1838
+ <tr valign="top" class="sbi_pro">
1839
+ <th scope="row"><label><?php _e('Moderation Type', 'instagram-feed'); ?></label></th>
1840
+ <td>
1841
+ <input class="sb_instagram_moderation_mode" checked="checked" disabled type="radio" value="visual" style="margin-top: 0;" /><label><?php _e('Visual', 'instagram-feed'); ?></label>
1842
+ <input class="sb_instagram_moderation_mode" disabled type="radio" value="manual" style="margin-top: 0; margin-left: 10px;"/><label><?php _e('Manual', 'instagram-feed'); ?></label>
1843
+
1844
+ <p class="sbi_tooltip" style="display: block;"><?php _e("<b>Visual Moderation Mode</b><br />This adds a button to each feed that will allow you to hide posts, block users, and create white lists from the front end using a visual interface. Visit <a href='https://smashballoon.com/guide-to-moderation-mode/?utm_campaign=instagram-free&utm_source=settings&utm_medium=moderationmode' target='_blank'>this page</a> for details", 'instagram-feed'); ?></p>
1845
+
1846
+ </td>
1847
+ </tr>
1848
+
1849
+ <tr valign="top" class="sbi_pro">
1850
+ <th scope="row"><label><?php _e('Only show posts by these users', 'instagram-feed'); ?></label></th>
1851
+ <td>
1852
+ <input type="text" style="width: 70%;" disabled /><br />
1853
+ <span class="sbi_note" style="margin-left: 0;"><?php _e('Separate usernames using commas', 'instagram-feed'); ?></span>
1854
+
1855
+ &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e("What is this?", 'instagram-feed'); ?></a>
1856
+ <p class="sbi_tooltip"><?php _e("You can use this setting to show photos only from certain users in your feed. Just enter the usernames here which you want to show. Separate multiple usernames using commas.", 'instagram-feed'); ?></p>
1857
+ </td>
1858
+ </tr>
1859
+ <tr valign="top" class="sbi_pro">
1860
+ <th scope="row"><label><?php _e('White lists', 'instagram-feed'); ?></label></th>
1861
+ <td>
1862
+ <div class="sbi_white_list_names_wrapper">
1863
+ <?php _e("No white lists currently created", 'instagram-feed'); ?>
1864
+ </div>
1865
+
1866
+ <input disabled class="button-secondary" type="submit" value="<?php esc_attr_e( 'Clear White Lists', 'instagram-feed' ); ?>" />
1867
+ &nbsp;<a class="sbi_tooltip_link" href="JavaScript:void(0);" style="display: inline-block; margin-top: 5px;"><?php _e("What is this?", 'instagram-feed'); ?></a>
1868
+ <p class="sbi_tooltip"><?php _e("This will remove all of the white lists from the database", 'instagram-feed'); ?></p>
1869
+ </td>
1870
+ </tr>
1871
+
1872
+ </tbody>
1873
+ </table>
1874
+ </div>
1875
+
1876
+
1877
+
1878
+ <hr id="customcss" />
1879
+ <h3><?php _e('Misc', 'instagram-feed'); ?></h3>
1880
+
1881
+ <table class="form-table">
1882
+ <tbody>
1883
+ <tr valign="top">
1884
+ <td style="padding-bottom: 0;">
1885
+ <?php _e('<strong style="font-size: 15px;">Custom CSS</strong><br />Enter your own custom CSS in the box below', 'instagram-feed'); ?>
1886
+ </td>
1887
+ </tr>
1888
+ <tr valign="top">
1889
+ <td>
1890
+ <textarea name="sb_instagram_custom_css" id="sb_instagram_custom_css" style="width: 70%;" rows="7"><?php echo esc_textarea( stripslashes($sb_instagram_custom_css), 'instagram-feed' ); ?></textarea>
1891
+ </td>
1892
+ </tr>
1893
+ <tr valign="top" id="customjs">
1894
+ <td style="padding-bottom: 0;">
1895
+ <?php _e('<strong style="font-size: 15px;">Custom JavaScript</strong><br />Enter your own custom JavaScript/jQuery in the box below', 'instagram-feed'); ?>
1896
+ </td>
1897
+ </tr>
1898
+ <tr valign="top">
1899
+ <td>
1900
+ <textarea name="sb_instagram_custom_js" id="sb_instagram_custom_js" style="width: 70%;" rows="7"><?php echo esc_textarea( stripslashes($sb_instagram_custom_js), 'instagram-feed' ); ?></textarea>
1901
+ </td>
1902
+ </tr>
1903
+ </tbody>
1904
+ </table>
1905
+ <table class="form-table">
1906
+ <tbody>
1907
+
1908
+ <tr valign="top">
1909
+ <th scope="row"><label for="sb_instagram_ajax_theme" class="bump-left"><?php _e("Are you using an Ajax powered theme?", 'instagram-feed'); ?></label></th>
1910
+ <td>
1911
+ <input name="sb_instagram_ajax_theme" type="checkbox" id="sb_instagram_ajax_theme" <?php if($sb_instagram_ajax_theme == true) echo "checked"; ?> />
1912
+ <label for="sb_instagram_ajax_theme"><?php _e('Yes', 'instagram-feed'); ?></label>
1913
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1914
+ <p class="sbi_tooltip"><?php _e("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 please check with the theme author.", 'instagram-feed'); ?></p>
1915
+ </td>
1916
+ </tr>
1917
+
1918
+ <tr>
1919
+ <th class="bump-left"><label class="bump-left"><?php _e("Image Resizing", 'instagram-feed'); ?></label></th>
1920
+ <td>
1921
+ <input name="sb_instagram_disable_resize" type="checkbox" id="sb_instagram_disable_resize" <?php if($sb_instagram_disable_resize == true) echo "checked"; ?> />
1922
+ <label for="sb_instagram_disable_resize"><?php _e('Disable Local Image Storing and Resizing', 'instagram-feed'); ?></label><br><br>
1923
+ <input name="sb_instagram_favor_local" type="checkbox" id="sb_instagram_favor_local" <?php if($sb_instagram_favor_local == true) echo "checked"; ?> />
1924
+ <label for="sb_instagram_favor_local"><?php _e('Favor Local Images', 'instagram-feed'); ?></label><br><br>
1925
+
1926
+ <input id="sbi_reset_resized" class="button-secondary" type="submit" value="<?php esc_attr_e( 'Reset Resized Images' ); ?>" style="vertical-align: middle;"/>
1927
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1928
+ <p class="sbi_tooltip"><?php _e("The plugin creates and stores resized versions of images in order to serve a more optimized resolution size in the feed. Click this button to clear all data related to resized images. Enable the setting to favor local images to always use a local, resized image if one is available.", 'instagram-feed'); ?></p>
1929
+ </td>
1930
+ </tr>
1931
+
1932
+ <tr valign="top">
1933
+ <th scope="row"><label><?php _e('API request size', 'instagram-feed'); ?></label><code class="sbi_shortcode"> minnum
1934
+ Eg: minnum=25</code></th>
1935
+ <td>
1936
+ <input name="sb_instagram_minnum" type="number" min="0" max="100" value="<?php echo esc_attr( $sb_instagram_minnum ); ?>" />
1937
+ <span class="sbi_note"><?php _e('Leave at "0" for default', 'instagram-feed'); ?></span>
1938
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1939
+ <p class="sbi_tooltip"><?php _e("If your feed contains a lot of IG TV posts or your feed is not displaying any posts despite there being posts available on Instagram.com, try increasing this number to 25 or more.", 'instagram-feed'); ?></p>
1940
+ </td>
1941
+ </tr>
1942
+
1943
+ <tr valign="top">
1944
+ <th scope="row"><label><?php _e('Enqueue JS file in head', 'instagram-feed'); ?></label></th>
1945
+ <td>
1946
+ <input type="checkbox" name="enqueue_js_in_head" id="sb_instagram_enqueue_js_in_head" <?php if($enqueue_js_in_head == true) echo 'checked="checked"' ?> />
1947
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1948
+ <p class="sbi_tooltip"><?php _e("Check this box if you'd like to enqueue the JavaScript file for the plugin in the head instead of the footer.", 'instagram-feed'); ?></p>
1949
+ </td>
1950
+ </tr>
1951
+
1952
+ <tr valign="top">
1953
+ <th scope="row"><label><?php _e('Enqueue CSS file with shortcode', 'instagram-feed'); ?></label></th>
1954
+ <td>
1955
+ <input type="checkbox" name="enqueue_css_in_shortcode" id="sb_instagram_enqueue_css_in_shortcode" <?php if($enqueue_css_in_shortcode == true) echo 'checked="checked"' ?> />
1956
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1957
+ <p class="sbi_tooltip"><?php _e("Check this box if you'd like to only include the CSS file for the plugin when the feed is on the page.", 'instagram-feed'); ?></p>
1958
+ </td>
1959
+ </tr>
1960
+
1961
+ <tr valign="top">
1962
+ <th scope="row"><label><?php _e('Disable JS Image Loading', 'instagram-feed'); ?></label></th>
1963
+ <td>
1964
+ <input type="checkbox" name="disable_js_image_loading" id="sb_instagram_disable_js_image_loading" <?php if($disable_js_image_loading == true) echo 'checked="checked"' ?> />
1965
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1966
+ <p class="sbi_tooltip"><?php _e("Check this box to have images loaded server side instead of with JS.", 'instagram-feed'); ?></p>
1967
+ </td>
1968
+ </tr>
1969
+
1970
+ <tr valign="top">
1971
+ <th><label><?php _e("Enable Backup Caching", 'instagram-feed'); ?></label></th>
1972
+ <td class="sbi-customize-tab-opt">
1973
+ <input name="sb_instagram_backup" type="checkbox" id="sb_instagram_backup" <?php if($sb_instagram_backup == true) echo "checked"; ?> />
1974
+ <input id="sbi_clear_backups" class="button-secondary" type="submit" style="position: relative; top: -4px;" value="<?php esc_attr_e( 'Clear Backup Cache', 'instagram-feed' ); ?>" />
1975
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1976
+ <p class="sbi_tooltip"><?php _e('Every feed will save a duplicate version of itself in the database to be used if the normal cache is not available.', 'instagram-feed'); ?></p>
1977
+ </td>
1978
+ </tr>
1979
+
1980
+ <tr>
1981
+ <th class="bump-left">
1982
+ <label class="bump-left"><?php _e("Load initial posts with AJAX", 'instagram-feed'); ?></label>
1983
+ </th>
1984
+ <td>
1985
+ <input name="sb_ajax_initial" type="checkbox" id="sb_ajax_initial" <?php if($sb_ajax_initial == true) echo "checked"; ?> />
1986
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
1987
+ <p class="sbi_tooltip"><?php _e("Initial posts will be loaded using AJAX instead of added to the page directly. If you use page caching, this will allow the feed to update according to the \"Check for new posts every\" setting on the \"Configure\" tab.", 'instagram-feed'); ?></p>
1988
+ </td>
1989
+ </tr>
1990
+
1991
+ <tr>
1992
+ <th class="bump-left">
1993
+ <label for="sb_instagram_cron" class="bump-left"><?php _e("Force cache to clear on interval", 'instagram-feed'); ?></label>
1994
+ </th>
1995
+ <td>
1996
+ <select name="sb_instagram_cron">
1997
+ <option value="unset" <?php if($sb_instagram_cron == "unset") echo 'selected="selected"' ?> > - </option>
1998
+ <option value="yes" <?php if($sb_instagram_cron == "yes") echo 'selected="selected"' ?> ><?php _e('Yes', 'instagram-feed'); ?></option>
1999
+ <option value="no" <?php if($sb_instagram_cron == "no") echo 'selected="selected"' ?> ><?php _e('No', 'instagram-feed'); ?></option>
2000
+ </select>
2001
+
2002
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
2003
+ <p class="sbi_tooltip"><?php _e("If you're experiencing an issue with the plugin not auto-updating then you can set this to 'Yes' to run a scheduled event behind the scenes which forces the plugin cache to clear on a regular basis and retrieve new data from Instagram.", 'instagram-feed'); ?></p>
2004
+ </td>
2005
+ </tr>
2006
+ </tbody>
2007
+ </table>
2008
+ <table class="form-table">
2009
+ <tbody>
2010
+ <tr valign="top">
2011
+ <th scope="row"><label><?php _e("Disable Icon Font", 'instagram-feed'); ?></label></th>
2012
+ <td>
2013
+ <input type="checkbox" name="sb_instagram_disable_awesome" id="sb_instagram_disable_awesome" <?php if($sb_instagram_disable_awesome == true) echo 'checked="checked"' ?> /> <?php _e( 'Yes', 'instagram-feed' ); ?>
2014
+ </td>
2015
+ </tr>
2016
+ <tr>
2017
+ <th scope="row"><label for="sbi_font_method"><?php _e("Icon Method", 'instagram-feed'); ?></label></th>
2018
+ <td>
2019
+ <select name="sbi_font_method" id="sbi_font_method" class="default-text">
2020
+ <option value="svg" id="sbi-font_method" class="default-text" <?php if($sbi_font_method == 'svg') echo 'selected="selected"' ?>>SVG</option>
2021
+ <option value="fontfile" id="sbi-font_method" class="default-text" <?php if($sbi_font_method == 'fontfile') echo 'selected="selected"' ?>><?php _e("Font File", 'instagram-feed'); ?></option>
2022
+ </select>
2023
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
2024
+ <p class="sbi_tooltip"><?php _e("This plugin uses SVGs for all icons in the feed. Use this setting to switch to font icons.", 'instagram-feed'); ?></p>
2025
+ </td>
2026
+ </tr>
2027
+ <tr>
2028
+ <th class="bump-left"><label class="bump-left"><?php _e("Enable Custom Templates", 'instagram-feed'); ?></label></th>
2029
+ <td>
2030
+ <input name="sb_instagram_custom_template" type="checkbox" id="sb_instagram_custom_template" <?php if($sb_instagram_custom_template == true) echo "checked"; ?> />
2031
+ <label for="sb_instagram_custom_template"><?php _e('Yes', 'instagram-feed'); ?></label>
2032
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
2033
+ <p class="sbi_tooltip"><?php _e("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/guide-to-creating-custom-templates/\" target=\"_blank\">this guide</a>", 'instagram-feed'); ?></p>
2034
+ </td>
2035
+ </tr>
2036
+ <tr>
2037
+ <th class="bump-left"><label class="bump-left"><?php _e("Disable Admin Error Notice", 'instagram-feed'); ?></label></th>
2038
+ <td>
2039
+ <input name="sb_instagram_disable_admin_notice" type="checkbox" id="sb_instagram_disable_admin_notice" <?php if($sb_instagram_disable_admin_notice == true) echo "checked"; ?> />
2040
+ <label for="sb_instagram_disable_admin_notice"><?php _e('Yes', 'instagram-feed'); ?></label>
2041
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
2042
+ <p class="sbi_tooltip"><?php _e("This will permanently disable the feed error notice that displays in the bottom right corner for admins on the front end of your site.", 'instagram-feed'); ?></p>
2043
+ </td>
2044
+ </tr>
2045
+ <tr>
2046
+ <th class="bump-left"><label class="bump-left"><?php _e("Feed Issue Email Report", 'instagram-feed'); ?></label></th>
2047
+ <td>
2048
+ <input name="sb_instagram_enable_email_report" type="checkbox" id="sb_instagram_enable_email_report" <?php if($sb_instagram_enable_email_report == 'on') echo "checked"; ?> />
2049
+ <label for="sb_instagram_enable_email_report"><?php _e('Yes', 'instagram-feed'); ?></label>
2050
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What does this mean?', 'instagram-feed'); ?></a>
2051
+ <p class="sbi_tooltip"><?php _e("Instagram Feed will send a weekly notification email using your site's wp_mail() function if one or more of your feeds is not updating or is not displaying. If you're not receiving the emails in your inbox, you may need to configure an SMTP service using another plugin like WP Mail SMTP.", 'instagram-feed'); ?></p>
2052
+
2053
+ <div class="sb_instagram_box" style="display: block;">
2054
+ <div class="sb_instagram_box_setting">
2055
+ <label><?php _e('Schedule Weekly on', 'instagram-feed'); ?></label><br>
2056
+ <?php
2057
+ $schedule_options = array(
2058
+ array(
2059
+ 'val' => 'monday',
2060
+ 'label' => __( 'Monday', 'instagram-feed' )
2061
+ ),
2062
+ array(
2063
+ 'val' => 'tuesday',
2064
+ 'label' => __( 'Tuesday', 'instagram-feed' )
2065
+ ),
2066
+ array(
2067
+ 'val' => 'wednesday',
2068
+ 'label' => __( 'Wednesday', 'instagram-feed' )
2069
+ ),
2070
+ array(
2071
+ 'val' => 'thursday',
2072
+ 'label' => __( 'Thursday', 'instagram-feed' )
2073
+ ),
2074
+ array(
2075
+ 'val' => 'friday',
2076
+ 'label' => __( 'Friday', 'instagram-feed' )
2077
+ ),
2078
+ array(
2079
+ 'val' => 'saturday',
2080
+ 'label' => __( 'Saturday', 'instagram-feed' )
2081
+ ),
2082
+ array(
2083
+ 'val' => 'sunday',
2084
+ 'label' => __( 'Sunday', 'instagram-feed' )
2085
+ ),
2086
+ );
2087
+
2088
+ if ( isset( $_GET['flag'] ) ){
2089
+ echo '<span id="sbi-goto"></span>';
2090
+ }
2091
+ ?>
2092
+ <select name="sb_instagram_email_notification" id="sb_instagram_email_notification">
2093
+ <?php foreach ( $schedule_options as $schedule_option ) : ?>
2094
+ <option value="<?php echo esc_attr( $schedule_option['val'] ) ; ?>" <?php if ( $schedule_option['val'] === $sb_instagram_email_notification ) { echo 'selected';} ?>><?php echo esc_html( $schedule_option['label'] ) ; ?></option>
2095
+ <?php endforeach; ?>
2096
+ </select>
2097
+ </div>
2098
+ <div class="sb_instagram_box_setting">
2099
+ <label><?php _e('Email Recipients', 'instagram-feed'); ?></label><br><input class="regular-text" type="text" name="sb_instagram_email_notification_addresses" value="<?php echo esc_attr( $sb_instagram_email_notification_addresses ); ?>"><span class="sbi_note"><?php _e('separate multiple emails with commas', 'instagram-feed'); ?></span>
2100
+ <br><br><?php _e( 'Emails not working?', 'instagram-feed' ) ?> <a href="https://smashballoon.com/email-report-is-not-in-my-inbox/" target="_blank"><?php _e( 'See our related FAQ', 'instagram-feed' ) ?></a>
2101
+ </div>
2102
+ </div>
2103
+
2104
+ </td>
2105
+ </tr>
2106
+ <?php
2107
+ $usage_tracking = get_option( 'sbi_usage_tracking', false );
2108
+ if ( $usage_tracking !== false ) :
2109
+
2110
+ if ( isset( $_POST['sb_instagram_enable_email_report'] ) ) {
2111
+ $usage_tracking['enabled'] = false;
2112
+ if ( isset( $_POST['sbi_usage_tracking_enable'] ) ) {
2113
+ $usage_tracking['enabled'] = true;
2114
+ }
2115
+ update_option( 'sbi_usage_tracking', $usage_tracking, false );
2116
+ }
2117
+ $sbi_usage_tracking_enable = isset( $usage_tracking['enabled'] ) ? $usage_tracking['enabled'] : true;
2118
+
2119
+ // only show this setting after they have opted in or opted out using the admin notice
2120
+ ?>
2121
+ <tr>
2122
+
2123
+ <th class="bump-left"><label class="bump-left"><?php _e("Enable Usage Tracking", 'instagram-feed'); ?></label></th>
2124
+ <td>
2125
+ <input name="sbi_usage_tracking_enable" type="checkbox" id="sbi_usage_tracking_enable" <?php if( $sbi_usage_tracking_enable ) echo "checked"; ?> />
2126
+ <label for="sbi_usage_tracking_enable"><?php _e('Yes', 'instagram-feed'); ?></label>
2127
+ <a class="sbi_tooltip_link" href="JavaScript:void(0);"><?php _e('What is usage tracking?', 'instagram-feed'); ?></a>
2128
+ <p class="sbi_tooltip"><?php _e("Instagram Feed will record information and statistics about your site in order for the team at Smash Balloon to learn more about how our plugins are used. The plugin will never collect any sensitive information like access tokens, email addresses, or user information.", 'instagram-feed'); ?></p>
2129
+ </td>
2130
+ </tr>
2131
+ <?php endif; ?>
2132
+
2133
+ </tbody>
2134
+ </table>
2135
+
2136
+ <?php submit_button(); ?>
2137
+
2138
+ </form>
2139
+
2140
+ <p><i class="fa fa-chevron-circle-right" aria-hidden="true"></i>&nbsp; <?php _e('Next Step: <a href="?page=sb-instagram-feed&tab=display">Display your Feed</a>', 'instagram-feed'); ?></p>
2141
+
2142
+ <p><i class="fa fa-life-ring" aria-hidden="true"></i>&nbsp; <?php _e('Need help setting up the plugin? Check out our <a href="https://smashballoon.com/instagram-feed/free/?utm_campaign=instagram-free&utm_source=settings&utm_medium=display" target="_blank">setup directions</a>', 'instagram-feed'); ?></p>
2143
+
2144
+
2145
+ <?php } //End Customize tab ?>
2146
+
2147
+
2148
+
2149
+ <?php if( $sbi_active_tab == 'display' ) { //Start Display tab ?>
2150
+
2151
+ <h3><?php _e('Display your Feed', 'instagram-feed'); ?></h3>
2152
+ <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:", 'instagram-feed'); ?></p>
2153
+ <input type="text" value="[instagram-feed]" size="16" 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).', 'instagram-feed'); ?>" />
2154
+
2155
+ <h3 style="padding-top: 10px;"><?php _e( 'Multiple Feeds', 'instagram-feed' ); ?></h3>
2156
+ <p><?php _e("If you'd like to display multiple feeds then you can set different settings directly in the shortcode like so:", 'instagram-feed'); ?>
2157
+ <code>[instagram-feed num=9 cols=3]</code></p>
2158
+ <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:', 'instagram-feed' ); ?><br />
2159
+ <code>[instagram-feed]</code><br />
2160
+ <code>[instagram-feed num=4 cols=4 showfollow=false]</code><br />
2161
+ <code>[instagram-feed accesstoken="ANOTHER_ACCESS_TOKEN"]</code>
2162
+ </p>
2163
+ <p><?php _e("See the table below for a full list of available shortcode options:", 'instagram-feed'); ?></p>
2164
+
2165
+ <p><span class="sbi_table_key"></span><?php _e('Pro version only', 'instagram-feed'); ?></p>
2166
+
2167
+ <table class="sbi_shortcode_table">
2168
+ <tbody>
2169
+ <tr valign="top">
2170
+ <th scope="row"><?php _e('Shortcode option', 'instagram-feed'); ?></th>
2171
+ <th scope="row"><?php _e('Description', 'instagram-feed'); ?></th>
2172
+ <th scope="row"><?php _e('Example', 'instagram-feed'); ?></th>
2173
+ </tr>
2174
+
2175
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Configure Options", 'instagram-feed'); ?></td></tr>
2176
+ <tr class="sbi_pro">
2177
+ <td>type</td>
2178
+ <td><?php _e("Display photos from a User ID (user)<br />Display posts from a Hashtag (hashtag)", 'instagram-feed'); ?><br /><?php _e("Display photos that the account was tagged in (tagged)", 'instagram-feed'); ?></td>
2179
+ <td><code>[instagram-feed type=user]</code><br /><code>[instagram-feed type=hashtag]</code><br /><code>[instagram-feed type=tagged]</code></td>
2180
+ </tr>
2181
+ <tr>
2182
+ <td>user</td>
2183
+ <td><?php _e('Your Instagram User Name. This must be from a connected account on the "Configure" tab.', 'instagram-feed'); ?></td>
2184
+ <td><code>[instagram-feed user="smashballoon"]</code></td>
2185
+ </tr>
2186
+ <tr class="sbi_pro">
2187
+ <td>hashtag</td>
2188
+ <td><?php _e('Any hashtag. Separate multiple hashtags by commas.', 'instagram-feed'); ?></td>
2189
+ <td><code>[instagram-feed hashtag="#awesome"]</code></td>
2190
+ </tr>
2191
+ <tr class="sbi_pro">
2192
+ <td>tagged</td>
2193
+ <td><?php _e('Your Instagram User Name. Separate multiple users by commas.', 'instagram-feed'); ?></td>
2194
+ <td><code>[instagram-feed tagged="smashballoon"]</code></td>
2195
+ </tr>
2196
+
2197
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Customize Options", 'instagram-feed'); ?></td></tr>
2198
+ <tr>
2199
+ <td>width</td>
2200
+ <td><?php _e("The width of your feed. Any number.", 'instagram-feed'); ?></td>
2201
+ <td><code>[instagram-feed width=50]</code></td>
2202
+ </tr>
2203
+ <tr>
2204
+ <td>widthunit</td>
2205
+ <td><?php _e("The unit of the width. 'px' or '%'", 'instagram-feed'); ?></td>
2206
+ <td><code>[instagram-feed widthunit=%]</code></td>
2207
+ </tr>
2208
+ <tr>
2209
+ <td>height</td>
2210
+ <td><?php _e("The height of your feed. Any number.", 'instagram-feed'); ?></td>
2211
+ <td><code>[instagram-feed height=250]</code></td>
2212
+ </tr>
2213
+ <tr>
2214
+ <td>heightunit</td>
2215
+ <td><?php _e("The unit of the height. 'px' or '%'", 'instagram-feed'); ?></td>
2216
+ <td><code>[instagram-feed heightunit=px]</code></td>
2217
+ </tr>
2218
+ <tr>
2219
+ <td>background</td>
2220
+ <td><?php _e("The background color of the feed. Any hex color code.", 'instagram-feed'); ?></td>
2221
+ <td><code>[instagram-feed background=#ffff00]</code></td>
2222
+ </tr>
2223
+ <tr>
2224
+ <td>class</td>
2225
+ <td><?php _e("Add a CSS class to the feed container", 'instagram-feed'); ?></td>
2226
+ <td><code>[instagram-feed class=feedOne]</code></td>
2227
+ </tr>
2228
+
2229
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Layout Options", 'instagram-feed'); ?></td></tr>
2230
+ <tr class="sbi_pro">
2231
+ <td>layout</td>
2232
+ <td><?php _e("How posts are arranged visually in the feed. There are four layouts: Grid, Carousel Slider, Masonry Grid, or Highlight Grid. Options:", 'instagram-feed' ); ?> 'grid', 'carousel', 'masonry', or 'highlight'</td>
2233
+ <td><code>[instagram-feed layout=grid]</code></td>
2234
+ </tr>
2235
+ <tr>
2236
+ <td>num</td>
2237
+ <td><?php _e("The number of photos to display initially. Maximum is 33.", 'instagram-feed'); ?></td>
2238
+ <td><code>[instagram-feed num=10]</code></td>
2239
+ </tr>
2240
+ <tr class="sbi_pro">
2241
+ <td>nummobile</td>
2242
+ <td><?php _e("The number of photos to display initially for mobile screens (smaller than 480 pixels).", 'instagram-feed'); ?></td>
2243
+ <td><code>[instagram-feed nummobile=6]</code></td>
2244
+ </tr>
2245
+ <tr>
2246
+ <td>cols</td>
2247
+ <td><?php _e("The number of columns in your feed. 1 - 10.", 'instagram-feed'); ?></td>
2248
+ <td><code>[instagram-feed cols=5]</code></td>
2249
+ </tr>
2250
+ <tr class="sbi_pro">
2251
+ <td>colsmobile</td>
2252
+ <td><?php _e("The number of columns in your feed for mobile screens (smaller than 480 pixels).", 'instagram-feed'); ?></td>
2253
+ <td><code>[instagram-feed colsmobile=2]</code></td>
2254
+ </tr>
2255
+ <tr>
2256
+ <td>imagepadding</td>
2257
+ <td><?php _e("The spacing around your photos", 'instagram-feed'); ?></td>
2258
+ <td><code>[instagram-feed imagepadding=10]</code></td>
2259
+ </tr>
2260
+ <tr>
2261
+ <td>imagepaddingunit</td>
2262
+ <td><?php _e("The unit of the padding. 'px' or '%'", 'instagram-feed'); ?></td>
2263
+ <td><code>[instagram-feed imagepaddingunit=px]</code></td>
2264
+ </tr>
2265
+
2266
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Carousel Options", 'instagram-feed'); ?></td></tr>
2267
+ <tr class="sbi_pro">
2268
+ <td>carouselrows</td>
2269
+ <td><?php _e("Choose 1 or 2 rows of posts in the carousel", 'instagram-feed'); ?></td>
2270
+ <td><code>[instagram-feed carouselrows=1]</code></td>
2271
+ </tr>
2272
+ <tr class="sbi_pro">
2273
+ <td>carouselloop</td>
2274
+ <td><?php _e("Infinitely loop through posts or rewind", 'instagram-feed'); ?></td>
2275
+ <td><code>[instagram-feed carouselloop=rewind]</code></td>
2276
+ </tr>
2277
+ <tr class="sbi_pro">
2278
+ <td>carouselarrows</td>
2279
+ <td><?php _e("Display directional arrows on the carousel", 'instagram-feed'); ?></td>
2280
+ <td><code>[instagram-feed carouselarrows=true]</code></td>
2281
+ </tr>
2282
+ <tr class="sbi_pro">
2283
+ <td>carouselpag</td>
2284
+ <td><?php _e("Display pagination links below the carousel", 'instagram-feed'); ?></td>
2285
+ <td><code>[instagram-feed carouselpag=true]</code></td>
2286
+ </tr>
2287
+ <tr class="sbi_pro">
2288
+ <td>carouselautoplay</td>
2289
+ <td><?php _e("Make the carousel autoplay", 'instagram-feed'); ?></td>
2290
+ <td><code>[instagram-feed carouselautoplay=true]</code></td>
2291
+ </tr>
2292
+ <tr class="sbi_pro">
2293
+ <td>carouseltime</td>
2294
+ <td><?php _e("The interval time between slides for autoplay. Time in miliseconds.", 'instagram-feed'); ?></td>
2295
+ <td><code>[instagram-feed carouseltime=8000]</code></td>
2296
+ </tr>
2297
+
2298
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Highlight Options", 'instagram-feed'); ?></td></tr>
2299
+ <tr class="sbi_pro">
2300
+ <td>highlighttype</td>
2301
+ <td><?php _e("Choose from 3 different ways of highlighting posts including by pattern, hashtag, post id or. Options:", 'instagram-feed'); ?> 'pattern', 'hashtag', 'id'.</td>
2302
+ <td><code>[instagram-feed highlighttype=hashtag]</code></td>
2303
+ </tr>
2304
+ <tr class="sbi_pro">
2305
+ <td>highlightpattern</td>
2306
+ <td><?php _e("How often a post is highlighted.", 'instagram-feed'); ?></td>
2307
+ <td><code>[instagram-feed highlightpattern=7]</code></td>
2308
+ </tr>
2309
+ <tr class="sbi_pro">
2310
+ <td>highlightoffset</td>
2311
+ <td><?php _e("When to start the highlight pattern.", 'instagram-feed'); ?></td>
2312
+ <td><code>[instagram-feed highlightoffset=3]</code></td>
2313
+ </tr>
2314
+ <tr class="sbi_pro">
2315
+ <td>highlighthashtag</td>
2316
+ <td><?php _e("Highlight posts with these hashtags.", 'instagram-feed'); ?></td>
2317
+ <td><code>[instagram-feed highlighthashtag=best]</code></td>
2318
+ </tr>
2319
+
2320
+
2321
+
2322
+
2323
+
2324
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Photos Options", 'instagram-feed'); ?></td></tr>
2325
+ <tr>
2326
+ <td>sortby</td>
2327
+ <td><?php _e("Sort the posts by Newest to Oldest (none) or Random (random)", 'instagram-feed'); ?></td>
2328
+ <td><code>[instagram-feed sortby=random]</code></td>
2329
+ </tr>
2330
+ <tr>
2331
+ <td>imageres</td>
2332
+ <td><?php _e("The resolution/size of the photos including full, medium, thumbnail, and auto (based on size of image on page). Options:", 'instagram-feed'); ?> 'auto', full', 'medium' or 'thumb'.</td>
2333
+ <td><code>[instagram-feed imageres=full]</code></td>
2334
+ </tr>
2335
+ <tr class="sbi_pro">
2336
+ <td>media</td>
2337
+ <td><?php _e("Display all media, only photos, or only videos", 'instagram-feed'); ?></td>
2338
+ <td><code>[instagram-feed media=photos]</code></td>
2339
+ </tr>
2340
+ <tr class="sbi_pro">
2341
+ <td>disablelightbox</td>
2342
+ <td><?php _e("Whether to disable the photo Lightbox. It is enabled by default.", 'instagram-feed'); ?></td>
2343
+ <td><code>[instagram-feed disablelightbox=true]</code></td>
2344
+ </tr>
2345
+ <tr>
2346
+ <td>disablemobile</td>
2347
+ <td><?php _e("Disable the mobile layout. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2348
+ <td><code>[instagram-feed disablemobile=true]</code></td>
2349
+ </tr>
2350
+ <tr class="sbi_pro">
2351
+ <td>captionlinks</td>
2352
+ <td><?php _e("Whether to use urls in captions for the photo's link instead of linking to instagram.com.", 'instagram-feed'); ?></td>
2353
+ <td><code>[instagram-feed captionlinks=true]</code></td>
2354
+ </tr>
2355
+
2356
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Lightbox Comments Options", 'instagram-feed'); ?></td></tr>
2357
+ <tr class="sbi_pro">
2358
+ <td>lightboxcomments</td>
2359
+ <td><?php _e("Whether to show comments in the lightbox for this feed.", 'instagram-feed'); ?></td>
2360
+ <td><code>[instagram-feed lightboxcomments=true]</code></td>
2361
+ </tr>
2362
+ <tr class="sbi_pro">
2363
+ <td>numcomments</td>
2364
+ <td><?php _e("Number of comments to show starting from the most recent.", 'instagram-feed'); ?></td>
2365
+ <td><code>[instagram-feed numcomments=10]</code></td>
2366
+ </tr>
2367
+
2368
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Photos Hover Style Options", 'instagram-feed'); ?></td></tr>
2369
+ <tr class="sbi_pro">
2370
+ <td>hovercolor</td>
2371
+ <td><?php _e("The background color when hovering over a photo. Any hex color code.", 'instagram-feed'); ?></td>
2372
+ <td><code>[instagram-feed hovercolor=#ff0000]</code></td>
2373
+ </tr>
2374
+ <tr class="sbi_pro">
2375
+ <td>hovertextcolor</td>
2376
+ <td><?php _e("The text/icon color when hovering over a photo. Any hex color code.", 'instagram-feed'); ?></td>
2377
+ <td><code>[instagram-feed hovertextcolor=#fff]</code></td>
2378
+ </tr>
2379
+ <tr class="sbi_pro">
2380
+ <td>hoverdisplay</td>
2381
+ <td><?php _e("The info to display when hovering over the photo such as the user name, post date, Instagram icon, location, caption, and like counts. Options:", 'instagram-feed'); ?><br />username, date, instagram, location, caption, likes</td>
2382
+ <td><code>[instagram-feed hoverdisplay="date, location, likes"]</code></td>
2383
+ </tr>
2384
+
2385
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Header Options", 'instagram-feed'); ?></td></tr>
2386
+ <tr>
2387
+ <td>showheader</td>
2388
+ <td><?php _e("Whether to show the feed Header. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2389
+ <td><code>[instagram-feed showheader=false]</code></td>
2390
+ </tr>
2391
+ <tr>
2392
+ <td>showbio</td>
2393
+ <td><?php _e("Display the bio in the header. Options:", 'instagram-feed'); ?> 'true' or 'false'</td>
2394
+ <td><code>[instagram-feed showbio=true]</code></td>
2395
+ </tr>
2396
+ <tr>
2397
+ <td>custombio</td>
2398
+ <td><?php _e("Display a custom bio in the header", 'instagram-feed'); ?></td>
2399
+ <td><code>[instagram-feed custombio="My custom bio."]</code></td>
2400
+ </tr>
2401
+ <tr>
2402
+ <td>customavatar</td>
2403
+ <td><?php _e("Display a custom avatar in the header. Enter the full URL of an image file.", 'instagram-feed'); ?></td>
2404
+ <td><code>[instagram-feed customavatar="https://example.com/avatar.jpg"]</code></td>
2405
+ </tr>
2406
+ <tr>
2407
+ <td>headersize</td>
2408
+ <td><?php _e("Size of the header including small, medium and large. Options:", 'instagram-feed'); ?> small, medium, or large.</td>
2409
+ <td><code>[instagram-feed headersize=medium]</code></td>
2410
+ </tr>
2411
+ <tr>
2412
+ <td>headercolor</td>
2413
+ <td><?php _e("The color of the Header text. Any hex color code.", 'instagram-feed'); ?></td>
2414
+ <td><code>[instagram-feed headercolor=#333]</code></td>
2415
+ </tr>
2416
+
2417
+ <tr class="sbi_table_header"><td colspan=3><?php _e("'Load More' Button Options", 'instagram-feed'); ?></td></tr>
2418
+ <tr>
2419
+ <td>showbutton</td>
2420
+ <td><?php _e("Whether to show the 'Load More' button. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2421
+ <td><code>[instagram-feed showbutton=false]</code></td>
2422
+ </tr>
2423
+ <tr>
2424
+ <td>buttoncolor</td>
2425
+ <td><?php _e("The background color of the button. Any hex color code.", 'instagram-feed'); ?></td>
2426
+ <td><code>[instagram-feed buttoncolor=#000]</code></td>
2427
+ </tr>
2428
+ <tr>
2429
+ <td>buttontextcolor</td>
2430
+ <td><?php _e("The text color of the button. Any hex color code.", 'instagram-feed'); ?></td>
2431
+ <td><code>[instagram-feed buttontextcolor=#fff]</code></td>
2432
+ </tr>
2433
+ <tr>
2434
+ <td>buttontext</td>
2435
+ <td><?php _e("The text used for the button.", 'instagram-feed'); ?></td>
2436
+ <td><code>[instagram-feed buttontext="Load More Photos"]</code></td>
2437
+ </tr>
2438
+
2439
+ <tr class="sbi_table_header"><td colspan=3><?php _e("'Follow on Instagram' Button Options", 'instagram-feed'); ?></td></tr>
2440
+ <tr>
2441
+ <td>showfollow</td>
2442
+ <td><?php _e("Whether to show the 'Follow on Instagram' button. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2443
+ <td><code>[instagram-feed showfollow=false]</code></td>
2444
+ </tr>
2445
+ <tr>
2446
+ <td>followcolor</td>
2447
+ <td><?php _e("The background color of the button. Any hex color code.", 'instagram-feed'); ?></td>
2448
+ <td><code>[instagram-feed followcolor=#ff0000]</code></td>
2449
+ </tr>
2450
+ <tr>
2451
+ <td>followtextcolor</td>
2452
+ <td><?php _e("The text color of the button. Any hex color code.", 'instagram-feed'); ?></td>
2453
+ <td><code>[instagram-feed followtextcolor=#fff]</code></td>
2454
+ </tr>
2455
+ <tr>
2456
+ <td>followtext</td>
2457
+ <td><?php _e("The text used for the button.", 'instagram-feed'); ?></td>
2458
+ <td><code>[instagram-feed followtext="Follow me"]</code></td>
2459
+ </tr>
2460
+
2461
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Caption Options", 'instagram-feed'); ?></td></tr>
2462
+ <tr class="sbi_pro">
2463
+ <td>showcaption</td>
2464
+ <td><?php _e("Whether to show the photo caption. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2465
+ <td><code>[instagram-feed showcaption=false]</code></td>
2466
+ </tr>
2467
+ <tr class="sbi_pro">
2468
+ <td>captionlength</td>
2469
+ <td><?php _e("The number of characters of the caption to display", 'instagram-feed'); ?></td>
2470
+ <td><code>[instagram-feed captionlength=50]</code></td>
2471
+ </tr>
2472
+ <tr class="sbi_pro">
2473
+ <td>captioncolor</td>
2474
+ <td><?php _e("The text color of the caption. Any hex color code.", 'instagram-feed'); ?></td>
2475
+ <td><code>[instagram-feed captioncolor=#000]</code></td>
2476
+ </tr>
2477
+ <tr class="sbi_pro">
2478
+ <td>captionsize</td>
2479
+ <td><?php _e("The size of the caption text. Any number.", 'instagram-feed'); ?></td>
2480
+ <td><code>[instagram-feed captionsize=24]</code></td>
2481
+ </tr>
2482
+
2483
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Likes &amp; Comments Options", 'instagram-feed'); ?></td></tr>
2484
+ <tr class="sbi_pro">
2485
+ <td>showlikes</td>
2486
+ <td><?php _e("Whether to show the Likes &amp; Comments. Options:", 'instagram-feed'); ?> 'true' or 'false'.</td>
2487
+ <td><code>[instagram-feed showlikes=false]</code></td>
2488
+ </tr>
2489
+ <tr class="sbi_pro">
2490
+ <td>likescolor</td>
2491
+ <td><?php _e("The color of the Likes &amp; Comments. Any hex color code.", 'instagram-feed'); ?></td>
2492
+ <td><code>[instagram-feed likescolor=#FF0000]</code></td>
2493
+ </tr>
2494
+ <tr class="sbi_pro">
2495
+ <td>likessize</td>
2496
+ <td><?php _e("The size of the Likes &amp; Comments. Any number.", 'instagram-feed'); ?></td>
2497
+ <td><code>[instagram-feed likessize=14]</code></td>
2498
+ </tr>
2499
+
2500
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Post Filtering Options", 'instagram-feed'); ?></td></tr>
2501
+ <tr class="sbi_pro">
2502
+ <td>excludewords</td>
2503
+ <td><?php _e("Remove posts which contain certain words or hashtags in the caption.", 'instagram-feed'); ?></td>
2504
+ <td><code>[instagram-feed excludewords="bad, words"]</code></td>
2505
+ </tr>
2506
+ <tr class="sbi_pro">
2507
+ <td>includewords</td>
2508
+ <td><?php _e("Only display posts which contain certain words or hashtags in the caption.", 'instagram-feed'); ?></td>
2509
+ <td><code>[instagram-feed includewords="sunshine"]</code></td>
2510
+ </tr>
2511
+
2512
+ <tr class="sbi_table_header"><td colspan=3><?php _e("Auto Load More on Scroll", 'instagram-feed'); ?></td></tr>
2513
+ <tr class="sbi_pro">
2514
+ <td>autoscroll</td>
2515
+ <td><?php _e("Load more posts automatically as the user scrolls down the page.", 'instagram-feed'); ?></td>
2516
+ <td><code>[instagram-feed autoscroll=true]</code></td>
2517
+ </tr>
2518
+ <tr class="sbi_pro">
2519
+ <td>autoscrolldistance</td>
2520
+ <td><?php _e("Distance before the end of feed or page that triggers the loading of more posts.", 'instagram-feed'); ?></td>
2521
+ <td><code>[instagram-feed autoscrolldistance=200]</code></td>
2522
+ </tr>
2523
+
2524
+ </tbody>
2525
+ </table>
2526
+
2527
+ <p><i class="fa fa-life-ring" aria-hidden="true"></i>&nbsp; <?php _e('Need help setting up the plugin? Check out our <a href="https://smashballoon.com/instagram-feed/free/?utm_campaign=instagram-free&utm_source=display&utm_medium=supportsetup" target="_blank">setup directions</a>', 'instagram-feed'); ?></p>
2528
+
2529
+ <?php } //End Display tab ?>
2530
+
2531
+
2532
+ <?php if( $sbi_active_tab == 'support' ) { //Start Support tab ?>
2533
+
2534
+ <div class="sbi_support">
2535
+
2536
+ <br/>
2537
+ <h3 style="padding-bottom: 10px;"><?php _e("Need help?", 'instagram-feed'); ?></h3>
2538
+
2539
+ <p>
2540
+ <span class="sbi-support-title"><i class="fa fa-life-ring" aria-hidden="true"></i>&nbsp; <a
2541
+ href="https://smashballoon.com/instagram-feed/free/?utm_campaign=instagram-free&utm_source=settings&utm_medium=general"
2542
+ target="_blank"><?php _e( 'Setup Directions', 'instagram-feed' ); ?></a></span>
2543
+ <?php _e( 'A step-by-step guide on how to setup and use the plugin.', 'instagram-feed' ); ?>
2544
+ </p>
2545
+
2546
+ <p>
2547
+ <span class="sbi-support-title"><i class="fa fa-youtube-play" aria-hidden="true"></i>&nbsp; <a
2548
+ href="https://www.youtube.com/embed/q6ZXVU4g970" target="_blank"
2549
+ id="sbi-play-support-video"><?php _e( 'Watch a Video', 'instagram-feed' ); ?></a></span>
2550
+ <?php _e( "Watch a short video demonstrating how to set up, customize and use the plugin.<br /><b>Please note</b> that the video shows the set up and use of the <b><a href='https://smashballoon.com/instagram-feed/?utm_campaign=instagram-free&utm_source=settings&utm_medium=general' target='_blank'>Pro version</a></b> of the plugin, but the process is the same for this free version. The only difference is some of the features available.", 'instagram-feed' ); ?>
2551
+
2552
+ <iframe id="sbi-support-video"
2553
+ src="//www.youtube.com/embed/q6ZXVU4g970?theme=light&amp;showinfo=0&amp;controls=2" width="960"
2554
+ height="540" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
2555
+ </p>
2556
+
2557
+ <p>
2558
+ <span class="sbi-support-title"><i class="fa fa-question-circle" aria-hidden="true"></i>&nbsp; <a
2559
+ href="https://smashballoon.com/instagram-feed/support/faq/?utm_campaign=instagram-free&utm_source=support&utm_medium=faqs"
2560
+ target="_blank"><?php _e( 'FAQs and Docs', 'instagram-feed' ); ?></a></span>
2561
+ <?php _e( 'View our expansive library of FAQs and documentation to help solve your problem as quickly as possible.', 'instagram-feed' ); ?>
2562
+ </p>
2563
+
2564
+ <div class="sbi-support-faqs">
2565
+
2566
+ <ul>
2567
+ <li><b><?php _e( 'FAQs', 'instagram-feed' ); ?></b></li>
2568
+ <li>&bull;&nbsp; <?php _e( '<a href="https://smashballoon.com/my-photos-wont-load/?utm_campaign=instagram-free&utm_source=support&utm_medium=faqsnophotos" target="_blank">My Instagram Feed Won\'t Load</a>', 'instagram-feed' ); ?></li>
2569
+ <li>&bull;&nbsp; <?php _e( '<a href="https://smashballoon.com/my-instagram-access-token-keep-expiring/?utm_campaign=instagram-free&utm_source=support&utm_medium=faqsexpiring" target="_blank">My Access Token Keeps Expiring</a>', 'instagram-feed' ); ?></li>
2570
+ <li style="margin-top: 8px; font-size: 12px;"><a href="https://smashballoon.com/instagram-feed/support/faq/?utm_campaign=instagram-free&utm_source=support&utm_medium=faqs" target="_blank"><?php _e( 'See All', 'instagram-feed' ); ?><i class="fa fa-chevron-right" aria-hidden="true"></i></a></li>
2571
+ </ul>
2572
+
2573
+ <ul>
2574
+ <li><b><?php _e("Documentation", 'instagram-feed'); ?></b></li>
2575
+ <li>&bull;&nbsp; <?php _e( '<a href="https://smashballoon.com/instagram-feed/free?utm_campaign=instagram-free&utm_source=support&utm_medium=installation" target="_blank">Installation and Configuration</a>', 'instagram-feed' ); ?></li>
2576
+ <li>&bull;&nbsp; <?php _e( '<a href="https://smashballoon.com/display-multiple-instagram-feeds/?utm_campaign=instagram-free&utm_source=support&utm_medium=multiple" target="_blank">Displaying multiple feeds</a>', 'instagram-feed' ); ?></li>
2577
+ <li>&bull;&nbsp; <?php _e( '<a href="https://smashballoon.com/instagram-feed-faq/customization/?utm_campaign=instagram-free&utm_source=support&utm_medium=customizing" target="_blank">Customizing your Feed</a>', 'instagram-feed' ); ?></li>
2578
+ </ul>
2579
+ </div>
2580
+
2581
+ <p>
2582
+ <span class="sbi-support-title"><i class="fa fa-envelope" aria-hidden="true"></i>&nbsp; <a
2583
+ href="https://smashballoon.com/instagram-feed/support/?utm_campaign=instagram-free&utm_source=support&utm_medium=contact"
2584
+ target="_blank"><?php _e( 'Request Support', 'instagram-feed' ); ?></a></span>
2585
+ <?php _e( 'Still need help? Submit a ticket and one of our support experts will get back to you as soon as possible.<br /><b>Important:</b> Please include your <b>System Info</b> below with all support requests.', 'instagram-feed' ); ?>
2586
+ </p>
2587
+ </div>
2588
+
2589
+ <hr />
2590
+
2591
+ <h3><?php _e('System Info &nbsp; <i style="color: #666; font-size: 11px; font-weight: normal;">Click the text below to select all</i>', 'instagram-feed'); ?></h3>
2592
+
2593
+
2594
+
2595
+
2596
+ <?php $sbi_options = get_option('sb_instagram_settings'); ?>
2597
+ <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: 100%; max-width: 960px; height: 500px; white-space: pre; font-family: Menlo,Monaco,monospace;">
2598
+ ## SITE/SERVER INFO: ##
2599
+ Site URL: <?php echo site_url() . "\n"; ?>
2600
+ Home URL: <?php echo home_url() . "\n"; ?>
2601
+ WordPress Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
2602
+ PHP Version: <?php echo PHP_VERSION . "\n"; ?>
2603
+ Web Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
2604
+
2605
+ ## ACTIVE PLUGINS: ##
2606
+ <?php
2607
+ $plugins = get_plugins();
2608
+ $active_plugins = get_option( 'active_plugins', array() );
2609
+
2610
+ foreach ( $plugins as $plugin_path => $plugin ) {
2611
+ // If the plugin isn't active, don't show it.
2612
+ if ( ! in_array( $plugin_path, $active_plugins ) )
2613
+ continue;
2614
+
2615
+ echo $plugin['Name'] . ': ' . $plugin['Version'] ."\n";
2616
+ }
2617
+ ?>
2618
+
2619
+ ## PLUGIN SETTINGS: ##
2620
+ sb_instagram_plugin_type => Instagram Feed Free
2621
+ <?php
2622
+ global $wpdb;
2623
+ foreach( $sbi_options as $key => $val ) {
2624
+ if ( $key !== 'connected_accounts' ) {
2625
+ if ( is_array( $val ) ) {
2626
+ foreach ( $val as $item ) {
2627
+ if ( is_array( $item ) ) {
2628
+ foreach ( $item as $key2 => $val2 ) {
2629
+ echo "$key2 => $val2\n";
2630
+ }
2631
+ } else {
2632
+ echo "$key => $item\n";
2633
+ }
2634
+ }
2635
+ } else {
2636
+ echo "$key => $val\n";
2637
+ }
2638
+ }
2639
+
2640
+ }
2641
+ ?>
2642
+
2643
+ ## CONNECTED ACCOUNTS: ##<?php echo "\n";
2644
+ $con_accounts = isset( $sbi_options['connected_accounts'] ) ? $sbi_options['connected_accounts'] : array();
2645
+ $business_accounts = array();
2646
+ $basic_accounts = array();
2647
+ if ( ! empty( $con_accounts ) ) {
2648
+ foreach ( $con_accounts as $account ) {
2649
+ $type = isset( $account['type'] ) ? $account['type'] : 'personal';
2650
+
2651
+ if ( $type === 'business' ) {
2652
+ $business_accounts[] = $account;
2653
+ } elseif ( $type === 'basic' ) {
2654
+ $basic_accounts[] = $account;
2655
+ }
2656
+ echo '*' . $account['user_id'] . '*' . "\n";
2657
+ var_export( $account );
2658
+ echo "\n";
2659
+ }
2660
+ }
2661
+ ?>
2662
+
2663
+ ## API RESPONSE: ##
2664
+ <?php
2665
+ $first_con_basic_account = isset( $basic_accounts[0] ) ? $basic_accounts[0] : array();
2666
+ $first_con_business_account = isset( $business_accounts[0] ) ? $business_accounts[0] : array();
2667
+
2668
+ if ( ! empty( $first_con_basic_account ) ) {
2669
+ echo '*BASIC ACCOUNT*';
2670
+ echo "\n";
2671
+ $connection = new SB_Instagram_API_Connect( $first_con_basic_account, 'header' );
2672
+ $connection->connect();
2673
+ if ( ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
2674
+ foreach ( $connection->get_data() as $key => $item ) {
2675
+ if ( is_array ( $item ) ) {
2676
+ foreach ( $item as $key2 => $item2 ) {
2677
+ echo $key2 . ' => ' . esc_html( $item2 ) . "\n";
2678
+ }
2679
+ } else {
2680
+ echo $key . ' => ' . esc_html( $item ) . "\n";
2681
+ }
2682
+ }
2683
+ } else {
2684
+ if ( $connection->is_wp_error() ) {
2685
+ $response = $connection->get_wp_error();
2686
+ if ( isset( $response ) && isset( $response->errors ) ) {
2687
+ foreach ( $response->errors as $key => $item ) {
2688
+ echo $key . ' => ' . $item[0] . "\n";
2689
+ }
2690
+ }
2691
+ } else {
2692
+ $error = $connection->get_data();
2693
+ var_export( $error );
2694
+ }
2695
+ }
2696
+ echo "\n";
2697
+ } else {
2698
+ echo 'no connected basic accounts';
2699
+ echo "\n";
2700
+ }
2701
+ if ( ! empty( $first_con_business_account ) ) {
2702
+ echo '*BUSINESS ACCOUNT*';
2703
+ echo "\n";
2704
+ $connection = new SB_Instagram_API_Connect( $first_con_business_account, 'header' );
2705
+ $connection->connect();
2706
+ if ( ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
2707
+ foreach ( $connection->get_data() as $key => $item ) {
2708
+ if ( is_array ( $item ) ) {
2709
+ foreach ( $item as $key2 => $item2 ) {
2710
+ echo $key2 . ' => ' . esc_html( $item2 ) . "\n";
2711
+ }
2712
+ } else {
2713
+ echo $key . ' => ' . esc_html( $item ) . "\n";
2714
+ }
2715
+ }
2716
+ } else {
2717
+ if ( $connection->is_wp_error() ) {
2718
+ $response = $connection->get_wp_error();
2719
+ if ( isset( $response ) && isset( $response->errors ) ) {
2720
+ foreach ( $response->errors as $key => $item ) {
2721
+ echo $key . ' => ' . $item[0] . "\n";
2722
+ }
2723
+ }
2724
+ } else {
2725
+ $error = $connection->get_data();
2726
+ var_export( $error );
2727
+ }
2728
+ }
2729
+ } else {
2730
+ echo 'no connected business accounts';
2731
+ } ?>
2732
+
2733
+ ## Cron Events: ##
2734
+ <?php
2735
+ $cron = _get_cron_array();
2736
+ foreach ( $cron as $key => $data ) {
2737
+ $is_target = false;
2738
+ foreach ( $data as $key2 => $val ) {
2739
+ if ( strpos( $key2, 'sbi' ) !== false || strpos( $key2, 'sb_instagram' ) !== false ) {
2740
+ $is_target = true;
2741
+ echo $key2;
2742
+ echo "\n";
2743
+ }
2744
+ }
2745
+ if ( $is_target) {
2746
+ echo date( "Y-m-d H:i:s", $key );
2747
+ echo "\n";
2748
+ echo 'Next Scheduled: ' . ((int)$key - time())/60 . ' minutes';
2749
+ echo "\n\n";
2750
+ }
2751
+ }
2752
+ ?>
2753
+ ## Cron Cache Report: ##
2754
+ <?php $cron_report = get_option( 'sbi_cron_report', array() );
2755
+ if ( ! empty( $cron_report ) ) {
2756
+ var_export( $cron_report );
2757
+ }
2758
+ echo "\n";
2759
+ ?>
2760
+
2761
+ ## Access Token Refresh: ##
2762
+ <?php $cron_report = get_option( 'sbi_refresh_report', array() );
2763
+ if ( ! empty( $cron_report ) ) {
2764
+ var_export( $cron_report );
2765
+ }
2766
+ echo "\n";
2767
+ ?>
2768
+
2769
+ ## Resizing: ##
2770
+ <?php $upload = wp_upload_dir();
2771
+ $upload_dir = $upload['basedir'];
2772
+ $upload_dir = trailingslashit( $upload_dir ) . SBI_UPLOADS_NAME;
2773
+ if ( file_exists( $upload_dir ) ) {
2774
+ echo 'upload directory exists';
2775
+ } else {
2776
+ $created = wp_mkdir_p( $upload_dir );
2777
+
2778
+ if ( ! $created ) {
2779
+ echo 'cannot create upload directory';
2780
+ }
2781
+ }
2782
+ echo "\n";
2783
+ echo "\n";
2784
+
2785
+ $table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE );
2786
+ $feeds_posts_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS );
2787
+
2788
+ if ( $wpdb->get_var( "show tables like '$feeds_posts_table_name'" ) != $feeds_posts_table_name ) {
2789
+ echo 'no feeds posts table';
2790
+ echo "\n";
2791
+
2792
+ } else {
2793
+ $last_result = $wpdb->get_results( "SELECT * FROM $feeds_posts_table_name ORDER BY id DESC LIMIT 1;" );
2794
+ if ( is_array( $last_result ) && isset( $last_result[0] ) ) {
2795
+ echo '*FEEDS POSTS TABLE*';
2796
+ echo "\n";
2797
+
2798
+ foreach ( $last_result as $column ) {
2799
+
2800
+ foreach ( $column as $key => $value ) {
2801
+ echo $key . ': ' . esc_html( $value ) . "\n";;
2802
+ }
2803
+ }
2804
+
2805
+ } else {
2806
+ echo 'feeds posts has no rows';
2807
+ echo "\n";
2808
+ }
2809
+ }
2810
+ echo "\n";
2811
+
2812
+ if ( $wpdb->get_var( "show tables like '$table_name'" ) != $table_name ) {
2813
+ echo 'no posts table';
2814
+ echo "\n";
2815
+
2816
+ } else {
2817
+
2818
+
2819
+ $last_result = $wpdb->get_results( "SELECT * FROM $table_name ORDER BY id DESC LIMIT 1;" );
2820
+ if ( is_array( $last_result ) && isset( $last_result[0] ) ) {
2821
+ echo '*POSTS TABLE*';
2822
+ echo "\n";
2823
+ foreach ( $last_result as $column ) {
2824
+
2825
+ foreach ( $column as $key => $value ) {
2826
+ echo $key . ': ' . esc_html( $value ) . "\n";;
2827
+ }
2828
+ }
2829
+
2830
+ } else {
2831
+ echo 'feeds posts has no rows';
2832
+ echo "\n";
2833
+ }
2834
+ }
2835
+
2836
+ ?>
2837
+
2838
+ ## Error Log: ##
2839
+ <?php
2840
+ global $sb_instagram_posts_manager;
2841
+ $errors = $sb_instagram_posts_manager->get_errors();
2842
+ if ( ! empty( $errors ) ) :
2843
+ foreach ( $errors as $type => $error ) :
2844
+ echo $type . ': ' . $error[1] . "\n";
2845
+ endforeach;
2846
+ endif;
2847
+ $error_page = $sb_instagram_posts_manager->get_error_page();
2848
+ if ( $error_page ) {
2849
+ echo 'Feed with error: ' . esc_url( get_the_permalink( $error_page ) ). "\n";
2850
+ }
2851
+ $ajax_statuses = $sb_instagram_posts_manager->get_ajax_status();
2852
+ if ( ! $ajax_statuses['successful'] ) {
2853
+ ?>
2854
+ ## AJAX Status ##
2855
+ <?php
2856
+ echo 'test not successful';
2857
+ }
2858
+ ?>
2859
+ </textarea>
2860
+ <div><input id="sbi_reset_log" class="button-secondary" type="submit" value="<?php esc_attr_e( 'Reset Error Log' ); ?>" style="vertical-align: middle;"/></div>
2861
+
2862
+ <?php
2863
+ } //End Support tab
2864
+ ?>
2865
+
2866
+
2867
+ <div class="sbi_quickstart">
2868
+ <h3><i class="fa fa-rocket" aria-hidden="true"></i>&nbsp; <?php _e('Display your feed', 'instagram-feed'); ?></h3>
2869
+ <p><?php _e('Copy and paste this shortcode directly into the page, post or widget where you\'d like to display the feed:', 'instagram-feed'); ?> <input type="text" value="[instagram-feed]" size="15" readonly="readonly" style="text-align: center;" onclick="this.focus();this.select()" title="To copy, click the field then press Ctrl + C (PC) or Cmd + C (Mac)."></p>
2870
+ <p><?php _e('Find out how to display <a href="?page=sb-instagram-feed&amp;tab=display">multiple feeds</a>.', 'instagram-feed'); ?></p>
2871
+ </div>
2872
+
2873
+ <a href="https://smashballoon.com/instagram-feed/demo/?utm_campaign=instagram-free&utm_source=footer&utm_medium=ad" target="_blank" class="sbi-pro-notice">
2874
+ <img src="<?php echo SBI_PLUGIN_URL . 'img/instagram-pro-promo.png?2019'; ?>" alt="<?php esc_attr_e( 'Instagram Feed Pro', 'instagram-feed' ); ?>">
2875
+ </a>
2876
+
2877
+ <p class="sbi_plugins_promo dashicons-before dashicons-admin-plugins"> <?php _e('Check out our other free plugins: <a href="https://wordpress.org/plugins/custom-facebook-feed/" target="_blank">Facebook</a>, <a href="https://wordpress.org/plugins/custom-twitter-feeds/" target="_blank">Twitter</a>, and <a href="https://wordpress.org/plugins/feeds-for-youtube/" target="_blank">YouTube</a>.', 'instagram-feed' ); ?></p>
2878
+
2879
+ <div class="sbi_share_plugin">
2880
+ <h3><?php _e('Like the plugin? Help spread the word!', 'instagram-feed'); ?></h3>
2881
+
2882
+ <button id="sbi_admin_show_share_links" class="button secondary" style="margin-bottom: 1px;"><i class="fa fa-share-alt" aria-hidden="true"></i>&nbsp;&nbsp;Share the plugin</button> <div id="sbi_admin_share_links"></div>
2883
+ </div>
2884
+
2885
+ </div> <!-- end #sbi_admin -->
2886
+
2887
  <?php } //End Settings page
inc/class-sb-instagram-api-connect.php CHANGED
@@ -1,381 +1,381 @@
1
- <?php
2
- /**
3
- * Class SB_Instagram_API_Connect
4
- *
5
- * Connect to the Instagram API and return the results. It's possible
6
- * to build the url from a connected account (includes access token,
7
- * account id, account type), endpoint and parameters (hashtag, etc..)
8
- * as well as a full url such as from the pagination data from some Instagram API requests.
9
- *
10
- * Errors from either the Instagram API or from the HTTP request are detected
11
- * and can be handled.
12
- *
13
- * Primarily used in the SB_Instagram_Feed class to collect posts and data for
14
- * the header. Can also be used for comments in the Pro version
15
- *
16
- * @since 2.0/5.0
17
- */
18
-
19
- if ( ! defined( 'ABSPATH' ) ) {
20
- die( '-1' );
21
- }
22
-
23
- class SB_Instagram_API_Connect
24
- {
25
- /**
26
- * @var string
27
- */
28
- private $url;
29
-
30
- /**
31
- * @var object
32
- */
33
- protected $response;
34
-
35
- /**
36
- * SB_Instagram_API_Connect constructor.
37
- *
38
- * @param mixed|array|string $connected_account_or_url either the connected account
39
- * data for this request or the complete url for the request
40
- * @param string $endpoint (optional) is optional only if the complete url is provided
41
- * otherwise is they key for the endpoint needed for the request (ex. "header")
42
- * @param array $params (optional) used with the connected account and endpoint to add
43
- * additional query parameters to the url if needed
44
- *
45
- * @since 2.0/5.0
46
- */
47
- public function __construct( $connected_account_or_url, $endpoint = '', $params = array() ) {
48
- if ( is_array( $connected_account_or_url ) && isset( $connected_account_or_url['access_token'] ) ) {
49
- $this->set_url( $connected_account_or_url, $endpoint, $params );
50
- } elseif ( strpos( $connected_account_or_url, 'https' ) !== false ) {
51
- $this->url = $connected_account_or_url;
52
- } else {
53
- $this->url = '';
54
- }
55
- }
56
-
57
- /**
58
- * Returns the response from Instagram
59
- *
60
- * @return object
61
- *
62
- * @since 2.0/5.0
63
- */
64
- public function get_data() {
65
- if (!empty($this->response['data'])) {
66
- return $this->response['data'];
67
- } else {
68
- return $this->response;
69
- }
70
- }
71
-
72
- /**
73
- * Returns the error response and the url that was trying to be connected to
74
- * or false if no error
75
- *
76
- * @return array|bool
77
- *
78
- * @since 2.0/5.0
79
- */
80
- public function get_wp_error() {
81
- if ( $this->is_wp_error() ) {
82
- return array( 'response' => $this->response, 'url' => $this->url );
83
- } else {
84
- return false;
85
- }
86
- }
87
-
88
- /**
89
- * Certain endpoints don't include the "next" URL so
90
- * this method allows using the "cursors->after" data instead
91
- *
92
- * @param $type
93
- *
94
- * @return bool
95
- *
96
- * @since 2.2.2/5.3.3
97
- */
98
- public function type_allows_after_paging( $type ) {
99
- return false;
100
- }
101
-
102
- /**
103
- * Returns the full url for the next page of the API request
104
- *
105
- * @param $type
106
- *
107
- * @return string
108
- *
109
- * @since 2.0/5.0
110
- */
111
- public function get_next_page( $type = '' ) {
112
- if ( ! empty( $this->response['pagination']['next_url'] ) ) {
113
- return $this->response['pagination']['next_url'];
114
- } elseif ( ! empty( $this->response['paging']['next'] ) ) {
115
- return $this->response['paging']['next'];
116
- } else {
117
- if ( $this->type_allows_after_paging( $type ) ) {
118
- if ( isset( $this->response['paging']['cursors']['after'] ) ) {
119
- return $this->response['paging']['cursors']['after'];
120
- }
121
- }
122
- return '';
123
- }
124
- }
125
-
126
- /**
127
- * If url needs to be generated from the connected account, endpoint,
128
- * and params, this function is used to do so.
129
- *
130
- * @param $url
131
- */
132
- public function set_url_from_args( $url ) {
133
- $this->url = $url;
134
- }
135
-
136
- /**
137
- * @return string
138
- *
139
- * @since 2.0/5.0
140
- */
141
- public function get_url() {
142
- return $this->url;
143
- }
144
-
145
- /**
146
- * If the server is unable to connect to the url, returns true
147
- *
148
- * @return bool
149
- *
150
- * @since 2.0/5.0
151
- */
152
- public function is_wp_error() {
153
- return is_wp_error( $this->response );
154
- }
155
-
156
- /**
157
- * If the server can connect but Instagram returns an error, returns true
158
- *
159
- * @return bool
160
- *
161
- * @since 2.0/5.0
162
- */
163
- public function is_instagram_error() {
164
- return (isset( $this->response['meta']['error_type'] ) || isset( $this->response['error']['message'] ));
165
- }
166
-
167
- /**
168
- * Connect to the Instagram API and record the response
169
- *
170
- * @since 2.0/5.0
171
- */
172
- public function connect() {
173
- $args = array(
174
- 'timeout' => 60,
175
- 'sslverify' => false
176
- );
177
- $response = wp_remote_get( $this->url, $args );
178
-
179
- if ( ! is_wp_error( $response ) ) {
180
- // certain ways of representing the html for double quotes causes errors so replaced here.
181
- $response = json_decode( str_replace( '%22', '&rdquo;', $response['body'] ), true );
182
- }
183
-
184
- $this->response = $response;
185
- }
186
-
187
- /**
188
- * Determines how and where to record an error from Instagram's API response
189
- *
190
- * @param array $response response from the API request
191
- * @param array $error_connected_account the connected account that is associated
192
- * with the error
193
- * @param string $request_type key used to determine the endpoint (ex. "header")
194
- *
195
- * @since 2.0/5.0
196
- */
197
- public static function handle_instagram_error( $response, $error_connected_account, $request_type ) {
198
- global $sb_instagram_posts_manager;
199
- delete_option( 'sbi_dismiss_critical_notice' );
200
-
201
- $sb_instagram_posts_manager->update_error_page( get_the_ID() );
202
-
203
- $error_time = 300;
204
- if ( isset( $response['error']['message'] ) ) {
205
- if ( (int)$response['error']['code'] === 100 ) {
206
- $options = get_option( 'sb_instagram_settings', array() );
207
-
208
- $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
209
- $user_name = '';
210
- foreach ( $connected_accounts as $connected_account ) {
211
- if ( $connected_account['access_token'] === $error_connected_account['access_token'] ) {
212
- $connected_accounts[ $connected_account['user_id'] ]['is_valid'] = false;
213
- $connected_accounts[ $connected_account['user_id'] ]['last_checked'] = time();
214
- if ( isset( $connected_account['username'] ) ) {
215
- $user_name = $connected_account['username'];
216
- } else {
217
- $user_name = $connected_account['user_id'];
218
- }
219
- }
220
- }
221
-
222
- $options['connected_accounts'] = $connected_accounts;
223
-
224
- update_option( 'sb_instagram_settings', $options );
225
- $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
226
- $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
227
- if ( (int)$response['error']['code'] === 100 && $error_connected_account['type'] === 'business' ) {
228
- $error = '<p><b>' . sprintf( __( 'Error: Permission for the Smash Balloon App is not valid or has expired.', 'instagram-feed' ), $user_name ) . ' ' . __( 'Feed will not update.', 'instagram-feed' ) . '</b></p>';
229
- $error .= '<p>' . sprintf( __( 'API error %s:', 'instagram-feed' ), $response['error']['code'] ) . ' ' . $response['error']['message'] . '</p>';
230
- $sb_instagram_posts_manager->add_error( 'at_100_' . $user_name, array( 'Business 100 Error', $error, $response['error']['code'] ) );
231
- if ( current_user_can( $cap ) ) {
232
- $error .= '<p class="sbi-error-directions"><a href="https://smashballoon.com/instagram-feed/docs/errors/" target="_blank" rel="noopener">' . __( 'Directions on how to resolve this issue', 'instagram-feed' ) . '</a></p>';
233
- }
234
- $sb_instagram_posts_manager->add_frontend_error( 'at_100_' . $user_name, $error );
235
-
236
- } else {
237
- //set here
238
- $error = '<p><b>' . sprintf( __( 'Error: Access Token for %s is not valid or has expired.', 'instagram-feed' ), $user_name ) . ' ' . __( 'Feed will not update.', 'instagram-feed' ) . '</b></p>';
239
- $error .= '<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.', 'instagram-feed' );
240
- $error .= '<p>' . sprintf( __( 'API error %s:', 'instagram-feed' ), $response['error']['code'] ) . ' ' . $response['error']['message'] . '</p>';
241
- $sb_instagram_posts_manager->add_error( 'at_' . $user_name, array( 'Access Token Error', $error, $response['error']['code'] ) );
242
- $link = admin_url( '?page=sb-instagram-feed' );
243
- if ( current_user_can( $cap ) ) {
244
- $error .= '<p class="sbi-error-directions sbi-reconnect"><a href="' . esc_url( $link ) . '" target="_blank" rel="noopener">' . __( 'Reconnect your account in the admin area', 'instagram-feed' ) . '</a></p>';
245
- }
246
- $sb_instagram_posts_manager->add_frontend_error( 'at_' . $user_name, $error );
247
- }
248
-
249
- $error_time = 3600;
250
- $account_id = $error_connected_account['user_id'];
251
- } elseif ( (int)$response['error']['code'] === 18 ) {
252
- $options = get_option( 'sb_instagram_settings', array() );
253
-
254
- $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
255
- $user_name = '';
256
- $hashtag_refresh_time = time() + (7*24*60*60);
257
- foreach ( $connected_accounts as $connected_account ) {
258
- if ( $connected_account['access_token'] === $error_connected_account['access_token'] ) {
259
- if ( ! isset( $connected_accounts[ $connected_account['user_id'] ]['hashtag_limit_reached'] ) ) {
260
- $connected_accounts[ $connected_account['user_id'] ]['hashtag_limit_reached'] = time();
261
- } else {
262
- $hashtag_refresh_time = $connected_accounts[ $connected_account['user_id'] ]['hashtag_limit_reached'];
263
- }
264
- if ( isset( $connected_account['username'] ) ) {
265
- $user_name = $connected_account['username'];
266
- } else {
267
- $user_name = $connected_account['user_id'];
268
- }
269
- }
270
- }
271
-
272
- $options['connected_accounts'] = $connected_accounts;
273
-
274
- update_option( 'sb_instagram_settings', $options );
275
-
276
- global $sb_instagram_posts_manager;
277
- $sb_instagram_posts_manager->add_error( 'error_18', array( 'Too many hashtags', $response['error']['error_user_msg'] ) );
278
-
279
- } elseif ( (int)$response['error']['code'] === 10 ) {
280
- $user_name = $error_connected_account['username'];
281
-
282
- $error = '<p><b>' . sprintf( __( 'Error: Connected account for the user %s does not have permission to use this feed type.', 'instagram-feed' ), $user_name ) .'</b></p>';
283
- $error .= '<p>' . __( 'Try using the big blue button on the "Configure" tab to reconnect the account and update its permissions.', 'instagram-feed' ) . '</p>';
284
-
285
- $sb_instagram_posts_manager->add_frontend_error( 'hashtag_limit_reached', $error );
286
-
287
- } elseif ( (int)$response['error']['code'] === 24 ) {
288
- $error = '<p><b>' . __( 'Error: Cannot retrieve posts for this hashtag.', 'instagram-feed' ) .'</b></p>';
289
- $error .= '<p>' . $response['error']['error_user_msg'] . '</p>';
290
-
291
- $sb_instagram_posts_manager->add_frontend_error( 'hashtag_error', $error );
292
- } else {
293
-
294
- $error = '<p>' .sprintf( __( 'API error %s:', 'instagram-feed' ), $response['error']['code'] ) . ' ' . $response['error']['message'] . '</p>';
295
-
296
- $sb_instagram_posts_manager->add_frontend_error( $response['error']['type'], $error );
297
- $sb_instagram_posts_manager->add_error( 'api', array( 'Api Error', $error, $response['error']['code'] ) );
298
- }
299
-
300
- if ( ! empty( $account_id ) ) {
301
- $sb_instagram_posts_manager->add_api_request_delay( $error_time, $account_id );
302
- } else {
303
- $sb_instagram_posts_manager->add_api_request_delay( $error_time );
304
- }
305
-
306
- }
307
-
308
-
309
-
310
- }
311
-
312
- /**
313
- * Determines how and where to record an error connecting to a specified url
314
- *
315
- * @param $response
316
- *
317
- * @since 2.0/5.0
318
- */
319
- public static function handle_wp_remote_get_error( $response ) {
320
- global $sb_instagram_posts_manager;
321
- delete_option( 'sbi_dismiss_critical_notice' );
322
- $sb_instagram_posts_manager->update_error_page( get_the_ID() );
323
-
324
- $message = sprintf( __( 'Error connecting to %s.', 'instagram-feed' ), $response['url'] ). ' ';
325
- if ( isset( $response['response'] ) && isset( $response['response']->errors ) ) {
326
- foreach ( $response['response']->errors as $key => $item ) {
327
- $message .= ' '.$key . ' - ' . $item[0] . ' |';
328
- }
329
- }
330
-
331
- $sb_instagram_posts_manager->add_api_request_delay( 300 );
332
-
333
- $sb_instagram_posts_manager->add_error( 'connection', array( 'Error connecting', $message ) );
334
- }
335
-
336
- /**
337
- * Sets the url for the API request based on the account information,
338
- * type of data needed, and additional parameters.
339
- *
340
- * Overwritten in the Pro version.
341
- *
342
- * @param array $connected_account connected account to be used in the request
343
- * @param string $endpoint_slug header or user
344
- * @param array $params additional params related to the request
345
- *
346
- * @since 2.0/5.0
347
- * @since 2.2/5.3 added endpoints for the basic display API
348
- */
349
- protected function set_url( $connected_account, $endpoint_slug, $params ) {
350
- $account_type = isset( $connected_account['type'] ) ? $connected_account['type'] : 'personal';
351
- $num = ! empty( $params['num'] ) ? (int)$params['num'] : 33;
352
-
353
- if ( $account_type === 'basic' ) {
354
- if ( $endpoint_slug === 'access_token' ) {
355
- $url = 'https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
356
- } elseif ( $endpoint_slug === 'header' ) {
357
- $url = 'https://graph.instagram.com/me?fields=id,username,media_count&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
358
- } else {
359
- $num = min( $num, 200 );
360
- $url = 'https://graph.instagram.com/' . sbi_maybe_clean( $connected_account['user_id'] ) . '/media?fields=media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}&limit='.$num.'&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
361
- }
362
- } elseif ( $account_type === 'personal' ) {
363
- if ( $endpoint_slug === 'header' ) {
364
- $url = 'https://api.instagram.com/v1/users/' . $connected_account['user_id'] . '?access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
365
- } else {
366
- $num = $num > 20 ? min( $num, 33 ) : 20; // minimum set at 20 due to IG TV bug
367
- $url = 'https://api.instagram.com/v1/users/' . $connected_account['user_id'] . '/media/recent?count='.$num.'&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
368
- }
369
- } else {
370
- if ( $endpoint_slug === 'header' ) {
371
- $url = 'https://graph.facebook.com/' . $connected_account['user_id'] . '?fields=biography,id,username,website,followers_count,media_count,profile_picture_url,name&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
372
- } else {
373
- $num = min( $num, 200 );
374
- $url = 'https://graph.facebook.com/' . $connected_account['user_id'] . '/media?fields=media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}&limit='.$num.'&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
375
- }
376
- }
377
-
378
- $this->set_url_from_args( $url );
379
- }
380
-
381
  }
1
+ <?php
2
+ /**
3
+ * Class SB_Instagram_API_Connect
4
+ *
5
+ * Connect to the Instagram API and return the results. It's possible
6
+ * to build the url from a connected account (includes access token,
7
+ * account id, account type), endpoint and parameters (hashtag, etc..)
8
+ * as well as a full url such as from the pagination data from some Instagram API requests.
9
+ *
10
+ * Errors from either the Instagram API or from the HTTP request are detected
11
+ * and can be handled.
12
+ *
13
+ * Primarily used in the SB_Instagram_Feed class to collect posts and data for
14
+ * the header. Can also be used for comments in the Pro version
15
+ *
16
+ * @since 2.0/5.0
17
+ */
18
+
19
+ if ( ! defined( 'ABSPATH' ) ) {
20
+ die( '-1' );
21
+ }
22
+
23
+ class SB_Instagram_API_Connect
24
+ {
25
+ /**
26
+ * @var string
27
+ */
28
+ private $url;
29
+
30
+ /**
31
+ * @var object
32
+ */
33
+ protected $response;
34
+
35
+ /**
36
+ * SB_Instagram_API_Connect constructor.
37
+ *
38
+ * @param mixed|array|string $connected_account_or_url either the connected account
39
+ * data for this request or the complete url for the request
40
+ * @param string $endpoint (optional) is optional only if the complete url is provided
41
+ * otherwise is they key for the endpoint needed for the request (ex. "header")
42
+ * @param array $params (optional) used with the connected account and endpoint to add
43
+ * additional query parameters to the url if needed
44
+ *
45
+ * @since 2.0/5.0
46
+ */
47
+ public function __construct( $connected_account_or_url, $endpoint = '', $params = array() ) {
48
+ if ( is_array( $connected_account_or_url ) && isset( $connected_account_or_url['access_token'] ) ) {
49
+ $this->set_url( $connected_account_or_url, $endpoint, $params );
50
+ } elseif ( strpos( $connected_account_or_url, 'https' ) !== false ) {
51
+ $this->url = $connected_account_or_url;
52
+ } else {
53
+ $this->url = '';
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Returns the response from Instagram
59
+ *
60
+ * @return object
61
+ *
62
+ * @since 2.0/5.0
63
+ */
64
+ public function get_data() {
65
+ if (!empty($this->response['data'])) {
66
+ return $this->response['data'];
67
+ } else {
68
+ return $this->response;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Returns the error response and the url that was trying to be connected to
74
+ * or false if no error
75
+ *
76
+ * @return array|bool
77
+ *
78
+ * @since 2.0/5.0
79
+ */
80
+ public function get_wp_error() {
81
+ if ( $this->is_wp_error() ) {
82
+ return array( 'response' => $this->response, 'url' => $this->url );
83
+ } else {
84
+ return false;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Certain endpoints don't include the "next" URL so
90
+ * this method allows using the "cursors->after" data instead
91
+ *
92
+ * @param $type
93
+ *
94
+ * @return bool
95
+ *
96
+ * @since 2.2.2/5.3.3
97
+ */
98
+ public function type_allows_after_paging( $type ) {
99
+ return false;
100
+ }
101
+
102
+ /**
103
+ * Returns the full url for the next page of the API request
104
+ *
105
+ * @param $type
106
+ *
107
+ * @return string
108
+ *
109
+ * @since 2.0/5.0
110
+ */
111
+ public function get_next_page( $type = '' ) {
112
+ if ( ! empty( $this->response['pagination']['next_url'] ) ) {
113
+ return $this->response['pagination']['next_url'];
114
+ } elseif ( ! empty( $this->response['paging']['next'] ) ) {
115
+ return $this->response['paging']['next'];
116
+ } else {
117
+ if ( $this->type_allows_after_paging( $type ) ) {
118
+ if ( isset( $this->response['paging']['cursors']['after'] ) ) {
119
+ return $this->response['paging']['cursors']['after'];
120
+ }
121
+ }
122
+ return '';
123
+ }
124
+ }
125
+
126
+ /**
127
+ * If url needs to be generated from the connected account, endpoint,
128
+ * and params, this function is used to do so.
129
+ *
130
+ * @param $url
131
+ */
132
+ public function set_url_from_args( $url ) {
133
+ $this->url = $url;
134
+ }
135
+
136
+ /**
137
+ * @return string
138
+ *
139
+ * @since 2.0/5.0
140
+ */
141
+ public function get_url() {
142
+ return $this->url;
143
+ }
144
+
145
+ /**
146
+ * If the server is unable to connect to the url, returns true
147
+ *
148
+ * @return bool
149
+ *
150
+ * @since 2.0/5.0
151
+ */
152
+ public function is_wp_error() {
153
+ return is_wp_error( $this->response );
154
+ }
155
+
156
+ /**
157
+ * If the server can connect but Instagram returns an error, returns true
158
+ *
159
+ * @return bool
160
+ *
161
+ * @since 2.0/5.0
162
+ */
163
+ public function is_instagram_error() {
164
+ return (isset( $this->response['meta']['error_type'] ) || isset( $this->response['error']['message'] ));
165
+ }
166
+
167
+ /**
168
+ * Connect to the Instagram API and record the response
169
+ *
170
+ * @since 2.0/5.0
171
+ */
172
+ public function connect() {
173
+ $args = array(
174
+ 'timeout' => 60,
175
+ 'sslverify' => false
176
+ );
177
+ $response = wp_remote_get( $this->url, $args );
178
+
179
+ if ( ! is_wp_error( $response ) ) {
180
+ // certain ways of representing the html for double quotes causes errors so replaced here.
181
+ $response = json_decode( str_replace( '%22', '&rdquo;', $response['body'] ), true );
182
+ }
183
+
184
+ $this->response = $response;
185
+ }
186
+
187
+ /**
188
+ * Determines how and where to record an error from Instagram's API response
189
+ *
190
+ * @param array $response response from the API request
191
+ * @param array $error_connected_account the connected account that is associated
192
+ * with the error
193
+ * @param string $request_type key used to determine the endpoint (ex. "header")
194
+ *
195
+ * @since 2.0/5.0
196
+ */
197
+ public static function handle_instagram_error( $response, $error_connected_account, $request_type ) {
198
+ global $sb_instagram_posts_manager;
199
+ delete_option( 'sbi_dismiss_critical_notice' );
200
+
201
+ $sb_instagram_posts_manager->update_error_page( get_the_ID() );
202
+
203
+ $error_time = 300;
204
+ if ( isset( $response['error']['message'] ) ) {
205
+ if ( (int)$response['error']['code'] === 100 ) {
206
+ $options = get_option( 'sb_instagram_settings', array() );
207
+
208
+ $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
209
+ $user_name = '';
210
+ foreach ( $connected_accounts as $connected_account ) {
211
+ if ( $connected_account['access_token'] === $error_connected_account['access_token'] ) {
212
+ $connected_accounts[ $connected_account['user_id'] ]['is_valid'] = false;
213
+ $connected_accounts[ $connected_account['user_id'] ]['last_checked'] = time();
214
+ if ( isset( $connected_account['username'] ) ) {
215
+ $user_name = $connected_account['username'];
216
+ } else {
217
+ $user_name = $connected_account['user_id'];
218
+ }
219
+ }
220
+ }
221
+
222
+ $options['connected_accounts'] = $connected_accounts;
223
+
224
+ update_option( 'sb_instagram_settings', $options );
225
+ $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
226
+ $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
227
+ if ( (int)$response['error']['code'] === 100 && $error_connected_account['type'] === 'business' ) {
228
+ $error = '<p><b>' . sprintf( __( 'Error: Permission for the Smash Balloon App is not valid or has expired.', 'instagram-feed' ), $user_name ) . ' ' . __( 'Feed will not update.', 'instagram-feed' ) . '</b></p>';
229
+ $error .= '<p>' . sprintf( __( 'API error %s:', 'instagram-feed' ), $response['error']['code'] ) . ' ' . $response['error']['message'] . '</p>';
230
+ $sb_instagram_posts_manager->add_error( 'at_100_' . $user_name, array( 'Business 100 Error', $error, $response['error']['code'] ) );
231
+ if ( current_user_can( $cap ) ) {
232
+ $error .= '<p class="sbi-error-directions"><a href="https://smashballoon.com/instagram-feed/docs/errors/" target="_blank" rel="noopener">' . __( 'Directions on how to resolve this issue', 'instagram-feed' ) . '</a></p>';
233
+ }
234
+ $sb_instagram_posts_manager->add_frontend_error( 'at_100_' . $user_name, $error );
235
+
236
+ } else {
237
+ //set here
238
+ $error = '<p><b>' . sprintf( __( 'Error: Access Token for %s is not valid or has expired.', 'instagram-feed' ), $user_name ) . ' ' . __( 'Feed will not update.', 'instagram-feed' ) . '</b></p>';
239
+ $error .= '<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.', 'instagram-feed' );
240
+ $error .= '<p>' . sprintf( __( 'API error %s:', 'instagram-feed' ), $response['error']['code'] ) . ' ' . $response['error']['message'] . '</p>';
241
+ $sb_instagram_posts_manager->add_error( 'at_' . $user_name, array( 'Access Token Error', $error, $response['error']['code'] ) );
242
+ $link = admin_url( '?page=sb-instagram-feed' );
243
+ if ( current_user_can( $cap ) ) {
244
+ $error .= '<p class="sbi-error-directions sbi-reconnect"><a href="' . esc_url( $link ) . '" target="_blank" rel="noopener">' . __( 'Reconnect your account in the admin area', 'instagram-feed' ) . '</a></p>';
245
+ }
246
+ $sb_instagram_posts_manager->add_frontend_error( 'at_' . $user_name, $error );
247
+ }
248
+
249
+ $error_time = 3600;
250
+ $account_id = $error_connected_account['user_id'];
251
+ } elseif ( (int)$response['error']['code'] === 18 ) {
252
+ $options = get_option( 'sb_instagram_settings', array() );
253
+
254
+ $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
255
+ $user_name = '';
256
+ $hashtag_refresh_time = time() + (7*24*60*60);
257
+ foreach ( $connected_accounts as $connected_account ) {
258
+ if ( $connected_account['access_token'] === $error_connected_account['access_token'] ) {
259
+ if ( ! isset( $connected_accounts[ $connected_account['user_id'] ]['hashtag_limit_reached'] ) ) {
260
+ $connected_accounts[ $connected_account['user_id'] ]['hashtag_limit_reached'] = time();
261
+ } else {
262
+ $hashtag_refresh_time = $connected_accounts[ $connected_account['user_id'] ]['hashtag_limit_reached'];
263
+ }
264
+ if ( isset( $connected_account['username'] ) ) {
265
+ $user_name = $connected_account['username'];
266
+ } else {
267
+ $user_name = $connected_account['user_id'];
268
+ }
269
+ }
270
+ }
271
+
272
+ $options['connected_accounts'] = $connected_accounts;
273
+
274
+ update_option( 'sb_instagram_settings', $options );
275
+
276
+ global $sb_instagram_posts_manager;
277
+ $sb_instagram_posts_manager->add_error( 'error_18', array( 'Too many hashtags', $response['error']['error_user_msg'] ) );
278
+
279
+ } elseif ( (int)$response['error']['code'] === 10 ) {
280
+ $user_name = $error_connected_account['username'];
281
+
282
+ $error = '<p><b>' . sprintf( __( 'Error: Connected account for the user %s does not have permission to use this feed type.', 'instagram-feed' ), $user_name ) .'</b></p>';
283
+ $error .= '<p>' . __( 'Try using the big blue button on the "Configure" tab to reconnect the account and update its permissions.', 'instagram-feed' ) . '</p>';
284
+
285
+ $sb_instagram_posts_manager->add_frontend_error( 'hashtag_limit_reached', $error );
286
+
287
+ } elseif ( (int)$response['error']['code'] === 24 ) {
288
+ $error = '<p><b>' . __( 'Error: Cannot retrieve posts for this hashtag.', 'instagram-feed' ) .'</b></p>';
289
+ $error .= '<p>' . $response['error']['error_user_msg'] . '</p>';
290
+
291
+ $sb_instagram_posts_manager->add_frontend_error( 'hashtag_error', $error );
292
+ } else {
293
+
294
+ $error = '<p>' .sprintf( __( 'API error %s:', 'instagram-feed' ), $response['error']['code'] ) . ' ' . $response['error']['message'] . '</p>';
295
+
296
+ $sb_instagram_posts_manager->add_frontend_error( $response['error']['type'], $error );
297
+ $sb_instagram_posts_manager->add_error( 'api', array( 'Api Error', $error, $response['error']['code'] ) );
298
+ }
299
+
300
+ if ( ! empty( $account_id ) ) {
301
+ $sb_instagram_posts_manager->add_api_request_delay( $error_time, $account_id );
302
+ } else {
303
+ $sb_instagram_posts_manager->add_api_request_delay( $error_time );
304
+ }
305
+
306
+ }
307
+
308
+
309
+
310
+ }
311
+
312
+ /**
313
+ * Determines how and where to record an error connecting to a specified url
314
+ *
315
+ * @param $response
316
+ *
317
+ * @since 2.0/5.0
318
+ */
319
+ public static function handle_wp_remote_get_error( $response ) {
320
+ global $sb_instagram_posts_manager;
321
+ delete_option( 'sbi_dismiss_critical_notice' );
322
+ $sb_instagram_posts_manager->update_error_page( get_the_ID() );
323
+
324
+ $message = sprintf( __( 'Error connecting to %s.', 'instagram-feed' ), $response['url'] ). ' ';
325
+ if ( isset( $response['response'] ) && isset( $response['response']->errors ) ) {
326
+ foreach ( $response['response']->errors as $key => $item ) {
327
+ $message .= ' '.$key . ' - ' . $item[0] . ' |';
328
+ }
329
+ }
330
+
331
+ $sb_instagram_posts_manager->add_api_request_delay( 300 );
332
+
333
+ $sb_instagram_posts_manager->add_error( 'connection', array( 'Error connecting', $message ) );
334
+ }
335
+
336
+ /**
337
+ * Sets the url for the API request based on the account information,
338
+ * type of data needed, and additional parameters.
339
+ *
340
+ * Overwritten in the Pro version.
341
+ *
342
+ * @param array $connected_account connected account to be used in the request
343
+ * @param string $endpoint_slug header or user
344
+ * @param array $params additional params related to the request
345
+ *
346
+ * @since 2.0/5.0
347
+ * @since 2.2/5.3 added endpoints for the basic display API
348
+ */
349
+ protected function set_url( $connected_account, $endpoint_slug, $params ) {
350
+ $account_type = isset( $connected_account['type'] ) ? $connected_account['type'] : 'personal';
351
+ $num = ! empty( $params['num'] ) ? (int)$params['num'] : 33;
352
+
353
+ if ( $account_type === 'basic' ) {
354
+ if ( $endpoint_slug === 'access_token' ) {
355
+ $url = 'https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
356
+ } elseif ( $endpoint_slug === 'header' ) {
357
+ $url = 'https://graph.instagram.com/me?fields=id,username,media_count&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
358
+ } else {
359
+ $num = min( $num, 200 );
360
+ $url = 'https://graph.instagram.com/' . sbi_maybe_clean( $connected_account['user_id'] ) . '/media?fields=media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}&limit='.$num.'&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
361
+ }
362
+ } elseif ( $account_type === 'personal' ) {
363
+ if ( $endpoint_slug === 'header' ) {
364
+ $url = 'https://api.instagram.com/v1/users/' . $connected_account['user_id'] . '?access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
365
+ } else {
366
+ $num = $num > 20 ? min( $num, 33 ) : 20; // minimum set at 20 due to IG TV bug
367
+ $url = 'https://api.instagram.com/v1/users/' . $connected_account['user_id'] . '/media/recent?count='.$num.'&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
368
+ }
369
+ } else {
370
+ if ( $endpoint_slug === 'header' ) {
371
+ $url = 'https://graph.facebook.com/' . $connected_account['user_id'] . '?fields=biography,id,username,website,followers_count,media_count,profile_picture_url,name&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
372
+ } else {
373
+ $num = min( $num, 200 );
374
+ $url = 'https://graph.facebook.com/' . $connected_account['user_id'] . '/media?fields=media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children{media_url,id,media_type,timestamp,permalink,thumbnail_url}&limit='.$num.'&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
375
+ }
376
+ }
377
+
378
+ $this->set_url_from_args( $url );
379
+ }
380
+
381
  }
inc/class-sb-instagram-cron-updater.php CHANGED
@@ -1,226 +1,226 @@
1
- <?php
2
- /**
3
- * Class SB_Instagram_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
- * "sbi_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 2.0/5.0
12
- */
13
-
14
- if ( ! defined( 'ABSPATH' ) ) {
15
- die( '-1' );
16
- }
17
-
18
- class SB_Instagram_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 2.0/5.0
27
- */
28
- public static function do_feed_updates() {
29
- $feed_caches = SB_Instagram_Cron_Updater::get_feed_cache_option_names();
30
- shuffle( $feed_caches );
31
- $settings = sbi_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
- $instagram_feed_settings = new SB_Instagram_Settings( $atts, $settings );
62
-
63
- if ( empty( $settings['connected_accounts'] ) && empty( $atts['accesstoken'] ) ) {
64
- $report[ $feed_id ]['did_update'] = 'no - no connected account';
65
- } else {
66
- SB_Instagram_Cron_Updater::do_single_feed_cron_update( $instagram_feed_settings, $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( 'sbi_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 array $instagram_feed_settings associative array generated from
96
- * the sb_instagram_settings class
97
- * @param array $feed_data post, header, shortcode settings, and other info
98
- * associated with the feed that is saved in the cache
99
- * @param array $atts shortcode settings
100
- * @param bool $include_resize whether or not to resize images during the update since
101
- * images can also be resized with an ajax call when the feed is viewed on the frontend
102
- *
103
- * @return object
104
- *
105
- * @since 2.0/5.0
106
- */
107
- public static function do_single_feed_cron_update( $instagram_feed_settings, $feed_data, $atts, $include_resize = true ) {
108
- $instagram_feed_settings->set_feed_type_and_terms();
109
- $instagram_feed_settings->set_transient_name();
110
- $transient_name = $instagram_feed_settings->get_transient_name();
111
- $settings = $instagram_feed_settings->get_settings();
112
- $feed_type_and_terms = $instagram_feed_settings->get_feed_type_and_terms();
113
-
114
- $instagram_feed = new SB_Instagram_Feed( $transient_name );
115
-
116
- while ( $instagram_feed->need_posts( $settings['num'] ) && $instagram_feed->can_get_more_posts() ) {
117
- $instagram_feed->add_remote_posts( $settings, $feed_type_and_terms, $instagram_feed_settings->get_connected_accounts_in_feed() );
118
- }
119
-
120
- $to_cache = array(
121
- 'atts' => $atts,
122
- 'last_requested' => $feed_data['last_requested'],
123
- 'last_retrieve' => time()
124
- );
125
-
126
- $instagram_feed->set_cron_cache( $to_cache, $instagram_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
127
-
128
- if ( $instagram_feed->need_header( $settings, $feed_type_and_terms ) ) {
129
- $instagram_feed->set_remote_header_data( $settings, $feed_type_and_terms, $instagram_feed_settings->get_connected_accounts_in_feed() );
130
-
131
- $instagram_feed->cache_header_data( $instagram_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
132
- }
133
-
134
- if ( $include_resize ) {
135
- $post_data = $instagram_feed->get_post_data();
136
- $post_data = array_slice( $post_data, 0, $settings['num'] );
137
-
138
- if ( $settings['favor_local'] ) {
139
- $image_sizes = array(
140
- 'personal' => array( 'full' => 640, 'low' => 320 ),
141
- 'business' => array( 'full' => 640, 'low' => 320 )
142
- );
143
- } else {
144
- $image_sizes = array(
145
- 'personal' => array( 'low' => 320 ),
146
- 'business' => array( 'full' => 640, 'low' => 320 )
147
- );
148
- }
149
- $post_set = new SB_Instagram_Post_Set( $post_data, $transient_name, NULL, $image_sizes );
150
-
151
- $post_set->maybe_save_update_and_resize_images_for_posts();
152
- }
153
-
154
- return $instagram_feed;
155
- }
156
-
157
- /**
158
- * Retrieve option name column values for all feed cache transients
159
- *
160
- * @return array
161
- *
162
- * @since 2.0/5.0
163
- */
164
- public static function get_feed_cache_option_names() {
165
- global $wpdb;
166
- $feed_caches = array();
167
-
168
- $results = $wpdb->get_results( "
169
- SELECT option_name
170
- FROM $wpdb->options
171
- WHERE `option_name` LIKE ('%\_transient\_sbi\_%')
172
- AND `option_name` NOT LIKE ('%\_transient\_sbi\_header%');", ARRAY_A );
173
-
174
- if ( isset( $results[0] ) ) {
175
- $feed_caches = $results;
176
- }
177
-
178
- return $feed_caches;
179
- }
180
-
181
- /**
182
- * Start cron jobs based on user's settings for cron cache update frequency.
183
- * This is triggered when settings are saved on the "Configure" tab.
184
- *
185
- * @param string $sbi_cache_cron_interval arbitrary name from one of the
186
- * settings on the "Configure" tab
187
- * @param string $sbi_cache_cron_time hour of the day (1 = 1:00)
188
- * @param string $sbi_cache_cron_am_pm am or pm (time of day)
189
- *
190
- * @since 2.0/5.0
191
- */
192
- public static function start_cron_job( $sbi_cache_cron_interval, $sbi_cache_cron_time, $sbi_cache_cron_am_pm ) {
193
- wp_clear_scheduled_hook( 'sbi_feed_update' );
194
-
195
- if ( $sbi_cache_cron_interval === '12hours' || $sbi_cache_cron_interval === '24hours' ) {
196
- $relative_time_now = time() + sbi_get_utc_offset();
197
- $base_day = strtotime( date( 'Y-m-d', $relative_time_now ) );
198
- $add_time = $sbi_cache_cron_am_pm === 'pm' ? (int)$sbi_cache_cron_time + 12 : (int)$sbi_cache_cron_time;
199
- $utc_start_time = $base_day + (($add_time * 60 * 60) - sbi_get_utc_offset());
200
-
201
- if ( $utc_start_time < time() ) {
202
- if ( $sbi_cache_cron_interval === '12hours' ) {
203
- $utc_start_time += 60*60*12;
204
- } else {
205
- $utc_start_time += 60*60*24;
206
- }
207
- }
208
-
209
- if ( $sbi_cache_cron_interval === '12hours' ) {
210
- wp_schedule_event( $utc_start_time, 'twicedaily', 'sbi_feed_update' );
211
- } else {
212
- wp_schedule_event( $utc_start_time, 'daily', 'sbi_feed_update' );
213
- }
214
-
215
- } else {
216
-
217
- if ( $sbi_cache_cron_interval === '30mins' ) {
218
- wp_schedule_event( time(), 'sbi30mins', 'sbi_feed_update' );
219
- } else {
220
- wp_schedule_event( time(), 'hourly', 'sbi_feed_update' );
221
- }
222
- }
223
-
224
- }
225
-
226
  }
1
+ <?php
2
+ /**
3
+ * Class SB_Instagram_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
+ * "sbi_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 2.0/5.0
12
+ */
13
+
14
+ if ( ! defined( 'ABSPATH' ) ) {
15
+ die( '-1' );
16
+ }
17
+
18
+ class SB_Instagram_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 2.0/5.0
27
+ */
28
+ public static function do_feed_updates() {
29
+ $feed_caches = SB_Instagram_Cron_Updater::get_feed_cache_option_names();
30
+ shuffle( $feed_caches );
31
+ $settings = sbi_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
+ $instagram_feed_settings = new SB_Instagram_Settings( $atts, $settings );
62
+
63
+ if ( empty( $settings['connected_accounts'] ) && empty( $atts['accesstoken'] ) ) {
64
+ $report[ $feed_id ]['did_update'] = 'no - no connected account';
65
+ } else {
66
+ SB_Instagram_Cron_Updater::do_single_feed_cron_update( $instagram_feed_settings, $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( 'sbi_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 array $instagram_feed_settings associative array generated from
96
+ * the sb_instagram_settings class
97
+ * @param array $feed_data post, header, shortcode settings, and other info
98
+ * associated with the feed that is saved in the cache
99
+ * @param array $atts shortcode settings
100
+ * @param bool $include_resize whether or not to resize images during the update since
101
+ * images can also be resized with an ajax call when the feed is viewed on the frontend
102
+ *
103
+ * @return object
104
+ *
105
+ * @since 2.0/5.0
106
+ */
107
+ public static function do_single_feed_cron_update( $instagram_feed_settings, $feed_data, $atts, $include_resize = true ) {
108
+ $instagram_feed_settings->set_feed_type_and_terms();
109
+ $instagram_feed_settings->set_transient_name();
110
+ $transient_name = $instagram_feed_settings->get_transient_name();
111
+ $settings = $instagram_feed_settings->get_settings();
112
+ $feed_type_and_terms = $instagram_feed_settings->get_feed_type_and_terms();
113
+
114
+ $instagram_feed = new SB_Instagram_Feed( $transient_name );
115
+
116
+ while ( $instagram_feed->need_posts( $settings['num'] ) && $instagram_feed->can_get_more_posts() ) {
117
+ $instagram_feed->add_remote_posts( $settings, $feed_type_and_terms, $instagram_feed_settings->get_connected_accounts_in_feed() );
118
+ }
119
+
120
+ $to_cache = array(
121
+ 'atts' => $atts,
122
+ 'last_requested' => $feed_data['last_requested'],
123
+ 'last_retrieve' => time()
124
+ );
125
+
126
+ $instagram_feed->set_cron_cache( $to_cache, $instagram_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
127
+
128
+ if ( $instagram_feed->need_header( $settings, $feed_type_and_terms ) ) {
129
+ $instagram_feed->set_remote_header_data( $settings, $feed_type_and_terms, $instagram_feed_settings->get_connected_accounts_in_feed() );
130
+
131
+ $instagram_feed->cache_header_data( $instagram_feed_settings->get_cache_time_in_seconds(), $settings['backup_cache_enabled'] );
132
+ }
133
+
134
+ if ( $include_resize ) {
135
+ $post_data = $instagram_feed->get_post_data();
136
+ $post_data = array_slice( $post_data, 0, $settings['num'] );
137
+
138
+ if ( $settings['favor_local'] ) {
139
+ $image_sizes = array(
140
+ 'personal' => array( 'full' => 640, 'low' => 320 ),
141
+ 'business' => array( 'full' => 640, 'low' => 320 )
142
+ );
143
+ } else {
144
+ $image_sizes = array(
145
+ 'personal' => array( 'low' => 320 ),
146
+ 'business' => array( 'full' => 640, 'low' => 320 )
147
+ );
148
+ }
149
+ $post_set = new SB_Instagram_Post_Set( $post_data, $transient_name, NULL, $image_sizes );
150
+
151
+ $post_set->maybe_save_update_and_resize_images_for_posts();
152
+ }
153
+
154
+ return $instagram_feed;
155
+ }
156
+
157
+ /**
158
+ * Retrieve option name column values for all feed cache transients
159
+ *
160
+ * @return array
161
+ *
162
+ * @since 2.0/5.0
163
+ */
164
+ public static function get_feed_cache_option_names() {
165
+ global $wpdb;
166
+ $feed_caches = array();
167
+
168
+ $results = $wpdb->get_results( "
169
+ SELECT option_name
170
+ FROM $wpdb->options
171
+ WHERE `option_name` LIKE ('%\_transient\_sbi\_%')
172
+ AND `option_name` NOT LIKE ('%\_transient\_sbi\_header%');", ARRAY_A );
173
+
174
+ if ( isset( $results[0] ) ) {
175
+ $feed_caches = $results;
176
+ }
177
+
178
+ return $feed_caches;
179
+ }
180
+
181
+ /**
182
+ * Start cron jobs based on user's settings for cron cache update frequency.
183
+ * This is triggered when settings are saved on the "Configure" tab.
184
+ *
185
+ * @param string $sbi_cache_cron_interval arbitrary name from one of the
186
+ * settings on the "Configure" tab
187
+ * @param string $sbi_cache_cron_time hour of the day (1 = 1:00)
188
+ * @param string $sbi_cache_cron_am_pm am or pm (time of day)
189
+ *
190
+ * @since 2.0/5.0
191
+ */
192
+ public static function start_cron_job( $sbi_cache_cron_interval, $sbi_cache_cron_time, $sbi_cache_cron_am_pm ) {
193
+ wp_clear_scheduled_hook( 'sbi_feed_update' );
194
+
195
+ if ( $sbi_cache_cron_interval === '12hours' || $sbi_cache_cron_interval === '24hours' ) {
196
+ $relative_time_now = time() + sbi_get_utc_offset();
197
+ $base_day = strtotime( date( 'Y-m-d', $relative_time_now ) );
198
+ $add_time = $sbi_cache_cron_am_pm === 'pm' ? (int)$sbi_cache_cron_time + 12 : (int)$sbi_cache_cron_time;
199
+ $utc_start_time = $base_day + (($add_time * 60 * 60) - sbi_get_utc_offset());
200
+
201
+ if ( $utc_start_time < time() ) {
202
+ if ( $sbi_cache_cron_interval === '12hours' ) {
203
+ $utc_start_time += 60*60*12;
204
+ } else {
205
+ $utc_start_time += 60*60*24;
206
+ }
207
+ }
208
+
209
+ if ( $sbi_cache_cron_interval === '12hours' ) {
210
+ wp_schedule_event( $utc_start_time, 'twicedaily', 'sbi_feed_update' );
211
+ } else {
212
+ wp_schedule_event( $utc_start_time, 'daily', 'sbi_feed_update' );
213
+ }
214
+
215
+ } else {
216
+
217
+ if ( $sbi_cache_cron_interval === '30mins' ) {
218
+ wp_schedule_event( time(), 'sbi30mins', 'sbi_feed_update' );
219
+ } else {
220
+ wp_schedule_event( time(), 'hourly', 'sbi_feed_update' );
221
+ }
222
+ }
223
+
224
+ }
225
+
226
  }
inc/class-sb-instagram-display-elements.php CHANGED
@@ -1,361 +1,361 @@
1
- <?php
2
- /**
3
- * Class SB_Instagram_Display_Elements
4
- *
5
- * Used to make certain parts of the html in the feed templates
6
- * abstract.
7
- *
8
- * @since 2.0/5.0
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- die( '-1' );
13
- }
14
-
15
- class SB_Instagram_Display_Elements
16
- {
17
- /**
18
- * Images are hidden initially with the new/transition classes
19
- * except if the js image loading is disabled using the plugin
20
- * settings
21
- *
22
- * @param $settings
23
- *
24
- * @return string
25
- *
26
- * @since 2.0/5.0
27
- */
28
- public static function get_item_classes( $settings ) {
29
- if ( !$settings['disable_js_image_loading'] ) {
30
- return ' sbi_new sbi_transition';
31
- } else {
32
- return ' sbi_new sbi_no_js sbi_no_resraise sbi_js_load_disabled';
33
- }
34
- }
35
-
36
- /**
37
- * Overwritten in the Pro version.
38
- *
39
- * @param string $type key of the kind of icon needed
40
- * @param string $icon_type svg or font
41
- *
42
- * @return string the complete html for the icon
43
- *
44
- * @since 2.0/5.0
45
- */
46
- public static function get_icon( $type, $icon_type ) {
47
- return self::get_basic_icons( $type, $icon_type );
48
- }
49
-
50
- /**
51
- * Returns the best media url for an image based on settings.
52
- * By default a white placeholder image is loaded and replaced
53
- * with the most optimal image size based on the actual dimensions
54
- * of the image element in the feed.
55
- *
56
- * @param array $post data for an individual post
57
- * @param array $settings
58
- * @param array $resized_images (optional) not yet used but
59
- * can pass in existing resized images to use in the source
60
- *
61
- * @return string
62
- *
63
- * @since 2.0/5.0
64
- */
65
- public static function get_optimum_media_url( $post, $settings, $resized_images = array() ) {
66
- $media_url = '';
67
- $optimum_res = $settings['imageres'];
68
- $account_type = isset( $post['images'] ) ? 'personal' : 'business';
69
-
70
- // only use the placeholder if it will be replaced using JS
71
- if ( !$settings['disable_js_image_loading'] ) {
72
- return trailingslashit( SBI_PLUGIN_URL ) . 'img/placeholder.png';
73
- } elseif ( $settings['imageres'] === 'auto' ) {
74
- $optimum_res = 'full';
75
- $settings['imageres'] = 'full';
76
- } else {
77
- if ( $settings['imageres'] !== 'thumb' && ! empty( $resized_images ) ) {
78
- $resolution = $settings['imageres'];
79
- $post_id = SB_Instagram_Parse::get_post_id( $post );
80
- if ( isset( $resized_images[ $post_id ] )
81
- && $resized_images[ $post_id ]['id'] !== 'error'
82
- && $resized_images[ $post_id ]['id'] !== 'pending'
83
- && $resized_images[ $post_id ]['id'] !== 'video' ) {
84
- if ( $resolution === 'medium' ) {
85
- if ( isset( $resized_images[ $post_id ]['sizes']['low'] ) ) {
86
- $suffix = 'low';
87
- } elseif ( isset( $resized_images[ $post_id ]['sizes']['full'] ) ) {
88
- $suffix = 'full';
89
- }
90
- } elseif ( $resolution === 'full' ) {
91
- if ( isset( $resized_images[ $post_id ]['sizes']['full'] ) ) {
92
- $suffix = 'full';
93
- } elseif ( isset( $resized_images[ $post_id ]['sizes']['low'] ) ) {
94
- $suffix = 'low';
95
- }
96
- } elseif ( $resolution === 'lightbox' ) {
97
- if ( isset( $resized_images[ $post_id ]['sizes']['full'] ) ) {
98
- $suffix = 'full';
99
- }
100
- }
101
- if ( isset( $suffix ) ) {
102
- $media_url = sbi_get_resized_uploads_url() . $resized_images[ $post_id ]['id'] . $suffix . '.jpg';
103
- return $media_url;
104
- }
105
- }
106
- }
107
- }
108
-
109
- if ( $account_type === 'personal' ) {
110
- switch ( $optimum_res ) {
111
- case 'thumb' :
112
- $media_url = $post['images']['thumbnail']['url'];
113
- break;
114
- case 'medium' :
115
- $media_url = $post['images']['low_resolution']['url'];
116
- break;
117
- default :
118
- $media_url = $post['images']['standard_resolution']['url'];
119
- }
120
- } else {
121
- $post_id = SB_Instagram_Parse::get_post_id( $post );
122
-
123
- // use resized images if exists
124
- if ( $optimum_res === 'full' && isset( $resized_images[ $post_id ]['id'] )
125
- && $resized_images[ $post_id ]['id'] !== 'pending'
126
- && $resized_images[ $post_id ]['id'] !== 'video'
127
- && $resized_images[ $post_id ]['id'] !== 'error' ) {
128
- $media_url = sbi_get_resized_uploads_url() . $resized_images[ $post_id ]['id'] . 'full.jpg';
129
- } else {
130
- $permalink = SB_Instagram_Parse::get_permalink( $post );
131
- if ( substr_count( $permalink, '/' ) > 5 ) {
132
- $permalink_array = explode( '/', $permalink );
133
- $perm_id = $permalink_array[ count( $permalink_array ) - 2 ];
134
- $permalink = 'https://www.instagram.com/p/' . $perm_id . '/';
135
- }
136
-
137
- if ( ($post['media_type'] === 'CAROUSEL_ALBUM' || $post['media_type'] === 'VIDEO') && ($optimum_res === 'lightbox' || $optimum_res === 'full')) {
138
- $media_url = $permalink . 'media?size=l';
139
- } else {
140
- switch ($optimum_res) {
141
- case 'thumb' :
142
- $media_url = $permalink . 'media?size=t';
143
- break;
144
- case 'medium' :
145
- $media_url = $permalink . 'media?size=m';
146
- break;
147
- default :
148
- $media_url = $post['media_url'];
149
- }
150
- }
151
- }
152
-
153
- }
154
-
155
- return $media_url;
156
- }
157
-
158
- /**
159
- * Images are normally styles with the imgLiquid plugin
160
- * with JavaScript. If this is disabled, the plugin will
161
- * attempt to square all images using CSS.
162
- *
163
- * @param array $post
164
- * @param array $settings
165
- * @param array $resized_images
166
- *
167
- * @return string
168
- *
169
- * @since 2.0/5.0
170
- * @since 2.1.1/5.2.1 added support for resized images
171
- */
172
- public static function get_sbi_photo_style_element( $post, $settings, $resized_images = array() ) {
173
- if ( !$settings['disable_js_image_loading'] ) {
174
- return '';
175
- } else {
176
- $full_res_image = SB_Instagram_Display_Elements::get_optimum_media_url( $post, $settings, $resized_images );
177
- /*
178
- * By setting the height to "0" the bottom padding can be used
179
- * as a percent to square the images. Since it needs to be a percent
180
- * this guesses what the percent would be based on static padding.
181
- */
182
- $padding_bottom = '100%';
183
- if ( $settings['imagepaddingunit'] === '%' ) {
184
- $padding_bottom = 100 - ($settings['imagepadding'] * 2) . '%';
185
- } else {
186
- $padding_percent = $settings['imagepadding'] > 0 ? 100 - ($settings['cols'] / 2 * $settings['imagepadding'] / 5) : 100;
187
- $padding_bottom = $padding_percent . '%';
188
- }
189
- return ' style="background-image: url(&quot;' . esc_url( $full_res_image ) . '&quot;); background-size: cover; background-position: center center; background-repeat: no-repeat; opacity: 1;height: 0;padding-bottom: ' . esc_attr( $padding_bottom ) . ';"';
190
- }
191
- }
192
-
193
- /**
194
- * Creates a style attribute that contains all of the styles for
195
- * the main feed div.
196
- *
197
- * @param $settings
198
- *
199
- * @return string
200
- */
201
- public static function get_feed_style( $settings ) {
202
-
203
- $styles = '';
204
- if ( ! empty( $settings['imagepadding'] )
205
- || ! empty( $settings['background'] )
206
- || ! empty( $settings['width'] )
207
- || ! empty( $settings['height'] ) ) {
208
- $styles = ' style="';
209
- if ( ! empty( $settings['imagepadding'] ) ) {
210
- $styles .= 'padding-bottom: ' . ((int)$settings['imagepadding'] * 2) . esc_attr( $settings['imagepaddingunit'] ) . ';';
211
- }
212
- if ( ! empty( $settings['background'] ) ) {
213
- $styles .= 'background-color: rgb(' . esc_attr( sbi_hextorgb( $settings['background'] ) ). ');';
214
- }
215
- if ( ! empty( $settings['width'] ) ) {
216
- $styles .= 'width: ' . (int)$settings['width'] . esc_attr( $settings['widthunit'] ) . ';';
217
- }
218
- if ( ! empty( $settings['height'] ) ) {
219
- $styles .= 'height: ' . (int)$settings['height'] . esc_attr( $settings['heightunit'] ) . ';';
220
- }
221
- $styles .= '"';
222
- }
223
- return $styles;
224
- }
225
-
226
- /**
227
- * Creates a style attribute for the sbi_images div
228
- *
229
- * @param $settings
230
- *
231
- * @return string
232
- */
233
- public static function get_sbi_images_style( $settings ) {
234
- if ( ! empty ( $settings['imagepadding'] ) ) {
235
- return 'style="padding: '.(int)$settings['imagepadding'] . esc_attr( $settings['imagepaddingunit'] ) . ';"';
236
- }
237
- return '';
238
- }
239
-
240
- /**
241
- * Creates a style attribute for the header. Can be used in
242
- * several places based on the header style
243
- *
244
- * @param $settings
245
- *
246
- * @return string
247
- */
248
- public static function get_header_text_color_styles( $settings ) {
249
- if ( ! empty( $settings['headercolor'] ) ) {
250
- return 'style="color: rgb(' . esc_attr( sbi_hextorgb( $settings['headercolor'] ) ). ');"';
251
- }
252
- return '';
253
- }
254
-
255
- /**
256
- * Header icon and text size is styled using the class added here.
257
- *
258
- * @param $settings
259
- *
260
- * @return string
261
- *
262
- * @since 2.0.1/5.0
263
- */
264
- public static function get_header_size_class( $settings ) {
265
- $header_size_class = in_array( strtolower( $settings['headersize'] ), array( 'medium', 'large' ) ) ? ' sbi_'.strtolower( $settings['headersize'] ) : '';
266
- return $header_size_class;
267
- }
268
-
269
- /**
270
- * Creates a style attribute for the follow button. Can be in
271
- * the feed footer or in a boxed header.
272
- *
273
- * @param $settings
274
- *
275
- * @return string
276
- */
277
- public static function get_follow_styles( $settings ) {
278
- $styles = '';
279
- if ( ! empty( $settings['followcolor'] ) || ! empty( $settings['followtextcolor'] ) ) {
280
- $styles = 'style="';
281
- if ( ! empty( $settings['followcolor'] ) ) {
282
- $styles .= 'background: rgb(' . esc_attr( sbi_hextorgb( $settings['followcolor'] ) ) . ');';
283
- }
284
- if ( ! empty( $settings['followtextcolor'] ) ) {
285
- $styles .= 'color: rgb(' . esc_attr( sbi_hextorgb( $settings['followtextcolor'] ) ). ');';
286
- }
287
- $styles .= '"';
288
- }
289
- return $styles;
290
- }
291
-
292
- /**
293
- * Creates a style attribute for styling the load more button.
294
- *
295
- * @param $settings
296
- *
297
- * @return string
298
- */
299
- public static function get_load_button_styles( $settings ) {
300
- $styles = '';
301
- if ( ! empty( $settings['buttoncolor'] ) || ! empty( $settings['buttontextcolor'] ) ) {
302
- $styles = 'style="';
303
- if ( ! empty( $settings['buttoncolor'] ) ) {
304
- $styles .= 'background: rgb(' . esc_attr( sbi_hextorgb( $settings['buttoncolor'] ) ) . ');';
305
- }
306
- if ( ! empty( $settings['buttontextcolor'] ) ) {
307
- $styles .= 'color: rgb(' . esc_attr( sbi_hextorgb( $settings['buttontextcolor'] ) ). ');';
308
- }
309
- $styles .= '"';
310
- }
311
- return $styles;
312
- }
313
-
314
- /**
315
- * Returns the html for an icon based on the kind requested
316
- *
317
- * @param string $type kind of icon needed (ex "video" is a play button
318
- * @param string $icon_type svg or font
319
- *
320
- * @return string
321
- *
322
- * @since 2.0/5.0
323
- */
324
- protected static function get_basic_icons( $type, $icon_type ) {
325
- if ( $type === 'carousel' ) {
326
- if ( $icon_type === 'svg' ) {
327
- return '<svg class="svg-inline--fa fa-clone fa-w-16 sbi_lightbox_carousel_icon" aria-hidden="true" aria-label="Clone" data-fa-proƒcessed="" data-prefix="far" data-icon="clone" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
328
- <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>
329
- </svg>';
330
- } else {
331
- return '<i class="fa fa-clone sbi_carousel_icon" aria-hidden="true"></i>';
332
- }
333
-
334
- } elseif ( $type === 'video' ) {
335
- if ( $icon_type === 'svg' ) {
336
- return '<svg style="color: rgba(255,255,255,1)" class="svg-inline--fa fa-play fa-w-14 sbi_playbtn" aria-label="Play" 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>';
337
- } else {
338
- return '<i class="fa fa-play sbi_playbtn" aria-hidden="true"></i>';
339
- }
340
- } elseif ( $type === 'instagram' ) {
341
- if ( $icon_type === 'svg' ) {
342
- return '<svg class="svg-inline--fa fa-instagram fa-w-14" aria-hidden="true" data-fa-processed="" aria-label="Instagram" data-prefix="fab" data-icon="instagram" role="img" viewBox="0 0 448 512">
343
- <path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path>
344
- </svg>';
345
- } else {
346
- return '<i class="fa fab fa-instagram" aria-hidden="true"></i>';
347
- }
348
- } elseif ( $type === 'newlogo' ) {
349
- if ( $icon_type === 'svg' ) {
350
- return '<svg class="sbi_new_logo fa-instagram fa-w-14" aria-hidden="true" data-fa-processed="" aria-label="Instagram" data-prefix="fab" data-icon="instagram" role="img" viewBox="0 0 448 512">
351
- <path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path>
352
- </svg>';
353
- } else {
354
- return '<i class="sbi_new_logo"></i>';
355
- }
356
- } else {
357
- return '';
358
- }
359
- }
360
-
361
  }
1
+ <?php
2
+ /**
3
+ * Class SB_Instagram_Display_Elements
4
+ *
5
+ * Used to make certain parts of the html in the feed templates
6
+ * abstract.
7
+ *
8
+ * @since 2.0/5.0
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ die( '-1' );
13
+ }
14
+
15
+ class SB_Instagram_Display_Elements
16
+ {
17
+ /**
18
+ * Images are hidden initially with the new/transition classes
19
+ * except if the js image loading is disabled using the plugin
20
+ * settings
21
+ *
22
+ * @param $settings
23
+ *
24
+ * @return string
25
+ *
26
+ * @since 2.0/5.0
27
+ */
28
+ public static function get_item_classes( $settings ) {
29
+ if ( !$settings['disable_js_image_loading'] ) {
30
+ return ' sbi_new sbi_transition';
31
+ } else {
32
+ return ' sbi_new sbi_no_js sbi_no_resraise sbi_js_load_disabled';
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Overwritten in the Pro version.
38
+ *
39
+ * @param string $type key of the kind of icon needed
40
+ * @param string $icon_type svg or font
41
+ *
42
+ * @return string the complete html for the icon
43
+ *
44
+ * @since 2.0/5.0
45
+ */
46
+ public static function get_icon( $type, $icon_type ) {
47
+ return self::get_basic_icons( $type, $icon_type );
48
+ }
49
+
50
+ /**
51
+ * Returns the best media url for an image based on settings.
52
+ * By default a white placeholder image is loaded and replaced
53
+ * with the most optimal image size based on the actual dimensions
54
+ * of the image element in the feed.
55
+ *
56
+ * @param array $post data for an individual post
57
+ * @param array $settings
58
+ * @param array $resized_images (optional) not yet used but
59
+ * can pass in existing resized images to use in the source
60
+ *
61
+ * @return string
62
+ *
63
+ * @since 2.0/5.0
64
+ */
65
+ public static function get_optimum_media_url( $post, $settings, $resized_images = array() ) {
66
+ $media_url = '';
67
+ $optimum_res = $settings['imageres'];
68
+ $account_type = isset( $post['images'] ) ? 'personal' : 'business';
69
+
70
+ // only use the placeholder if it will be replaced using JS
71
+ if ( !$settings['disable_js_image_loading'] ) {
72
+ return trailingslashit( SBI_PLUGIN_URL ) . 'img/placeholder.png';
73
+ } elseif ( $settings['imageres'] === 'auto' ) {
74
+ $optimum_res = 'full';
75
+ $settings['imageres'] = 'full';
76
+ } else {
77
+ if ( $settings['imageres'] !== 'thumb' && ! empty( $resized_images ) ) {
78
+ $resolution = $settings['imageres'];
79
+ $post_id = SB_Instagram_Parse::get_post_id( $post );
80
+ if ( isset( $resized_images[ $post_id ] )
81
+ && $resized_images[ $post_id ]['id'] !== 'error'
82
+ && $resized_images[ $post_id ]['id'] !== 'pending'
83
+ && $resized_images[ $post_id ]['id'] !== 'video' ) {
84
+ if ( $resolution === 'medium' ) {
85
+ if ( isset( $resized_images[ $post_id ]['sizes']['low'] ) ) {
86
+ $suffix = 'low';
87
+ } elseif ( isset( $resized_images[ $post_id ]['sizes']['full'] ) ) {
88
+ $suffix = 'full';
89
+ }
90
+ } elseif ( $resolution === 'full' ) {
91
+ if ( isset( $resized_images[ $post_id ]['sizes']['full'] ) ) {
92
+ $suffix = 'full';
93
+ } elseif ( isset( $resized_images[ $post_id ]['sizes']['low'] ) ) {
94
+ $suffix = 'low';
95
+ }
96
+ } elseif ( $resolution === 'lightbox' ) {
97
+ if ( isset( $resized_images[ $post_id ]['sizes']['full'] ) ) {
98
+ $suffix = 'full';
99
+ }
100
+ }
101
+ if ( isset( $suffix ) ) {
102
+ $media_url = sbi_get_resized_uploads_url() . $resized_images[ $post_id ]['id'] . $suffix . '.jpg';
103
+ return $media_url;
104
+ }
105
+ }
106
+ }
107
+ }
108
+
109
+ if ( $account_type === 'personal' ) {
110
+ switch ( $optimum_res ) {
111
+ case 'thumb' :
112
+ $media_url = $post['images']['thumbnail']['url'];
113
+ break;
114
+ case 'medium' :
115
+ $media_url = $post['images']['low_resolution']['url'];
116
+ break;
117
+ default :
118
+ $media_url = $post['images']['standard_resolution']['url'];
119
+ }
120
+ } else {
121
+ $post_id = SB_Instagram_Parse::get_post_id( $post );
122
+
123
+ // use resized images if exists
124
+ if ( $optimum_res === 'full' && isset( $resized_images[ $post_id ]['id'] )
125
+ && $resized_images[ $post_id ]['id'] !== 'pending'
126
+ && $resized_images[ $post_id ]['id'] !== 'video'
127
+ && $resized_images[ $post_id ]['id'] !== 'error' ) {
128
+ $media_url = sbi_get_resized_uploads_url() . $resized_images[ $post_id ]['id'] . 'full.jpg';
129
+ } else {
130
+ $permalink = SB_Instagram_Parse::get_permalink( $post );
131
+ if ( substr_count( $permalink, '/' ) > 5 ) {
132
+ $permalink_array = explode( '/', $permalink );
133
+ $perm_id = $permalink_array[ count( $permalink_array ) - 2 ];
134
+ $permalink = 'https://www.instagram.com/p/' . $perm_id . '/';
135
+ }
136
+
137
+ if ( ($post['media_type'] === 'CAROUSEL_ALBUM' || $post['media_type'] === 'VIDEO') && ($optimum_res === 'lightbox' || $optimum_res === 'full')) {
138
+ $media_url = $permalink . 'media?size=l';
139
+ } else {
140
+ switch ($optimum_res) {
141
+ case 'thumb' :
142
+ $media_url = $permalink . 'media?size=t';
143
+ break;
144
+ case 'medium' :
145
+ $media_url = $permalink . 'media?size=m';
146
+ break;
147
+ default :
148
+ $media_url = $post['media_url'];
149
+ }
150
+ }
151
+ }
152
+
153
+ }
154
+
155
+ return $media_url;
156
+ }
157
+
158
+ /**
159
+ * Images are normally styles with the imgLiquid plugin
160
+ * with JavaScript. If this is disabled, the plugin will
161
+ * attempt to square all images using CSS.
162
+ *
163
+ * @param array $post
164
+ * @param array $settings
165
+ * @param array $resized_images
166
+ *
167
+ * @return string
168
+ *
169
+ * @since 2.0/5.0
170
+ * @since 2.1.1/5.2.1 added support for resized images
171
+ */
172
+ public static function get_sbi_photo_style_element( $post, $settings, $resized_images = array() ) {
173
+ if ( !$settings['disable_js_image_loading'] ) {
174
+ return '';
175
+ } else {
176
+ $full_res_image = SB_Instagram_Display_Elements::get_optimum_media_url( $post, $settings, $resized_images );
177
+ /*
178
+ * By setting the height to "0" the bottom padding can be used
179
+ * as a percent to square the images. Since it needs to be a percent
180
+ * this guesses what the percent would be based on static padding.
181
+ */
182
+ $padding_bottom = '100%';
183
+ if ( $settings['imagepaddingunit'] === '%' ) {
184
+ $padding_bottom = 100 - ($settings['imagepadding'] * 2) . '%';
185
+ } else {
186
+ $padding_percent = $settings['imagepadding'] > 0 ? 100 - ($settings['cols'] / 2 * $settings['imagepadding'] / 5) : 100;
187
+ $padding_bottom = $padding_percent . '%';
188
+ }
189
+ return ' style="background-image: url(&quot;' . esc_url( $full_res_image ) . '&quot;); background-size: cover; background-position: center center; background-repeat: no-repeat; opacity: 1;height: 0;padding-bottom: ' . esc_attr( $padding_bottom ) . ';"';
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Creates a style attribute that contains all of the styles for
195
+ * the main feed div.
196
+ *
197
+ * @param $settings
198
+ *
199
+ * @return string
200
+ */
201
+ public static function get_feed_style( $settings ) {
202
+
203
+ $styles = '';
204
+ if ( ! empty( $settings['imagepadding'] )
205
+ || ! empty( $settings['background'] )
206
+ || ! empty( $settings['width'] )
207
+ || ! empty( $settings['height'] ) ) {
208
+ $styles = ' style="';
209
+ if ( ! empty( $settings['imagepadding'] ) ) {
210
+ $styles .= 'padding-bottom: ' . ((int)$settings['imagepadding'] * 2) . esc_attr( $settings['imagepaddingunit'] ) . ';';
211
+ }
212
+ if ( ! empty( $settings['background'] ) ) {
213
+ $styles .= 'background-color: rgb(' . esc_attr( sbi_hextorgb( $settings['background'] ) ). ');';
214
+ }
215
+ if ( ! empty( $settings['width'] ) ) {
216
+ $styles .= 'width: ' . (int)$settings['width'] . esc_attr( $settings['widthunit'] ) . ';';
217
+ }
218
+ if ( ! empty( $settings['height'] ) ) {
219
+ $styles .= 'height: ' . (int)$settings['height'] . esc_attr( $settings['heightunit'] ) . ';';
220
+ }
221
+ $styles .= '"';
222
+ }
223
+ return $styles;
224
+ }
225
+
226
+ /**
227
+ * Creates a style attribute for the sbi_images div
228
+ *
229
+ * @param $settings
230
+ *
231
+ * @return string
232
+ */
233
+ public static function get_sbi_images_style( $settings ) {
234
+ if ( ! empty ( $settings['imagepadding'] ) ) {
235
+ return 'style="padding: '.(int)$settings['imagepadding'] . esc_attr( $settings['imagepaddingunit'] ) . ';"';
236
+ }
237
+ return '';
238
+ }
239
+
240
+ /**
241
+ * Creates a style attribute for the header. Can be used in
242
+ * several places based on the header style
243
+ *
244
+ * @param $settings
245
+ *
246
+ * @return string
247
+ */
248
+ public static function get_header_text_color_styles( $settings ) {
249
+ if ( ! empty( $settings['headercolor'] ) ) {
250
+ return 'style="color: rgb(' . esc_attr( sbi_hextorgb( $settings['headercolor'] ) ). ');"';
251
+ }
252
+ return '';
253
+ }
254
+
255
+ /**
256
+ * Header icon and text size is styled using the class added here.
257
+ *
258
+ * @param $settings
259
+ *
260
+ * @return string
261
+ *
262
+ * @since 2.0.1/5.0
263
+ */
264
+ public static function get_header_size_class( $settings ) {
265
+ $header_size_class = in_array( strtolower( $settings['headersize'] ), array( 'medium', 'large' ) ) ? ' sbi_'.strtolower( $settings['headersize'] ) : '';
266
+ return $header_size_class;
267
+ }
268
+
269
+ /**
270
+ * Creates a style attribute for the follow button. Can be in
271
+ * the feed footer or in a boxed header.
272
+ *
273
+ * @param $settings
274
+ *
275
+ * @return string
276
+ */
277
+ public static function get_follow_styles( $settings ) {
278
+ $styles = '';
279
+ if ( ! empty( $settings['followcolor'] ) || ! empty( $settings['followtextcolor'] ) ) {
280
+ $styles = 'style="';
281
+ if ( ! empty( $settings['followcolor'] ) ) {
282
+ $styles .= 'background: rgb(' . esc_attr( sbi_hextorgb( $settings['followcolor'] ) ) . ');';
283
+ }
284
+ if ( ! empty( $settings['followtextcolor'] ) ) {
285
+ $styles .= 'color: rgb(' . esc_attr( sbi_hextorgb( $settings['followtextcolor'] ) ). ');';
286
+ }
287
+ $styles .= '"';
288
+ }
289
+ return $styles;
290
+ }
291
+
292
+ /**
293
+ * Creates a style attribute for styling the load more button.
294
+ *
295
+ * @param $settings
296
+ *
297
+ * @return string
298
+ */
299
+ public static function get_load_button_styles( $settings ) {
300
+ $styles = '';
301
+ if ( ! empty( $settings['buttoncolor'] ) || ! empty( $settings['buttontextcolor'] ) ) {
302
+ $styles = 'style="';
303
+ if ( ! empty( $settings['buttoncolor'] ) ) {
304
+ $styles .= 'background: rgb(' . esc_attr( sbi_hextorgb( $settings['buttoncolor'] ) ) . ');';
305
+ }
306
+ if ( ! empty( $settings['buttontextcolor'] ) ) {
307
+ $styles .= 'color: rgb(' . esc_attr( sbi_hextorgb( $settings['buttontextcolor'] ) ). ');';
308
+ }
309
+ $styles .= '"';
310
+ }
311
+ return $styles;
312
+ }
313
+
314
+ /**
315
+ * Returns the html for an icon based on the kind requested
316
+ *
317
+ * @param string $type kind of icon needed (ex "video" is a play button
318
+ * @param string $icon_type svg or font
319
+ *
320
+ * @return string
321
+ *
322
+ * @since 2.0/5.0
323
+ */
324
+ protected static function get_basic_icons( $type, $icon_type ) {
325
+ if ( $type === 'carousel' ) {
326
+ if ( $icon_type === 'svg' ) {
327
+ return '<svg class="svg-inline--fa fa-clone fa-w-16 sbi_lightbox_carousel_icon" aria-hidden="true" aria-label="Clone" data-fa-proƒcessed="" data-prefix="far" data-icon="clone" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
328
+ <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>
329
+ </svg>';
330
+ } else {
331
+ return '<i class="fa fa-clone sbi_carousel_icon" aria-hidden="true"></i>';
332
+ }
333
+
334
+ } elseif ( $type === 'video' ) {
335
+ if ( $icon_type === 'svg' ) {
336
+ return '<svg style="color: rgba(255,255,255,1)" class="svg-inline--fa fa-play fa-w-14 sbi_playbtn" aria-label="Play" 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>';
337
+ } else {
338
+ return '<i class="fa fa-play sbi_playbtn" aria-hidden="true"></i>';
339
+ }
340
+ } elseif ( $type === 'instagram' ) {
341
+ if ( $icon_type === 'svg' ) {
342
+ return '<svg class="svg-inline--fa fa-instagram fa-w-14" aria-hidden="true" data-fa-processed="" aria-label="Instagram" data-prefix="fab" data-icon="instagram" role="img" viewBox="0 0 448 512">
343
+ <path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path>
344
+ </svg>';
345
+ } else {
346
+ return '<i class="fa fab fa-instagram" aria-hidden="true"></i>';
347
+ }
348
+ } elseif ( $type === 'newlogo' ) {
349
+ if ( $icon_type === 'svg' ) {
350
+ return '<svg class="sbi_new_logo fa-instagram fa-w-14" aria-hidden="true" data-fa-processed="" aria-label="Instagram" data-prefix="fab" data-icon="instagram" role="img" viewBox="0 0 448 512">
351
+ <path fill="currentColor" d="M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"></path>
352
+ </svg>';
353
+ } else {
354
+ return '<i class="sbi_new_logo"></i>';
355
+ }
356
+ } else {
357
+ return '';
358
+ }
359
+ }
360
+
361
  }
inc/class-sb-instagram-education.php CHANGED
@@ -1,130 +1,130 @@
1
- <?php
2
-
3
- /**
4
- *
5
- * @since 5.5
6
- */
7
- class SB_Instagram_Education {
8
-
9
- var $plugin_version;
10
-
11
- /**
12
- * Constructor.
13
- *
14
- * @since 5.5
15
- */
16
- public function __construct() {
17
-
18
- $this->hooks();
19
- }
20
-
21
- /**
22
- * Hooks.
23
- *
24
- * @since 5.5
25
- */
26
- public function hooks() {
27
- $this->plugin_version = defined( 'SBI_STORE_URL' ) ? 'pro' : 'free';
28
- }
29
-
30
- /**
31
- * "Did You Know?" messages.
32
- *
33
- * @since 5.5
34
- */
35
- public function dyk_messages() {
36
-
37
- $free_messages = array(
38
- array(
39
- 'title' => esc_html__( 'Get the Most out of Hashtags', 'instagram-feed' ),
40
- 'content' => esc_html__( 'You can use hashtags on Instagram for so many things; targeted promotions, engaging with your audience, running contests, or just for categorizing posts. Learn more about how you can display Instagram hashtag feeds on your website using the Instagram Feed Pro plugin.', 'instagram-feed' ),
41
- 'more' => 'https://smashballoon.com/instagram-feed/features/#hashtag',
42
- 'item' => 1,
43
- ),
44
- array(
45
- 'title' => esc_html__( 'Keep Visitors on Your Site', 'instagram-feed' ),
46
- 'content' => esc_html__( "You've done the hard work of getting a visitor onto your site, now keep them there by displaying your Instagram content inside a pop-up lightbox, rather than sending your visitors away to Instagram. Learn more about the Instagram Feed Pro lightbox feature.", 'instagram-feed' ),
47
- 'more' => 'https://smashballoon.com/instagram-feed/features/#popuplightbox',
48
- 'item' => 2,
49
- ),
50
- array(
51
- 'title' => esc_html__( 'Highlight Your Posts and Create Carousels', 'instagram-feed' ),
52
- 'content' => esc_html__( "Feature specific Instagram posts in your feeds by using the Highlight layout to feature specific posts, either by using their ID or a hashtag in their caption. Also create rotating carousels of your photos and videos to best utilize the space on your site. These layouts and more are available in our Pro version.", 'instagram-feed' ),
53
- 'more' => 'https://smashballoon.com/instagram-feed/features/#highlight',
54
- 'item' => 3,
55
- ),
56
- array(
57
- 'title' => esc_html__( 'Moderate your Feed Content', 'instagram-feed' ),
58
- 'content' => esc_html__( "Control exactly which posts show up in your feed by using the Visual Moderation Mode feature to pick and choose what to display. Remove specific posts or create a whitelist of approved content using Instagram Feed Pro.", 'instagram-feed' ),
59
- 'more' => 'https://smashballoon.com/instagram-feed/features/#moderation',
60
- 'item' => 4,
61
- ),
62
- );
63
-
64
- $pro_messages = array(
65
- array(
66
- 'title' => esc_html__( 'Automated YouTube Live Streaming', 'instagram-feed' ),
67
- 'content' => esc_html__( 'You can automatically feed live YouTube videos to your website using our Feeds For YouTube Pro plugin. It takes all the hassle out of publishing live videos to your site by automating the process.', 'instagram-feed' ),
68
- 'more' => 'https://smashballoon.com/youtube-feed/',
69
- 'item' => 1,
70
- ),
71
- array(
72
- 'title' => esc_html__( 'Display Facebook Pages and Groups', 'instagram-feed' ),
73
- 'content' => esc_html__( 'Have a Facebook Page or Group? Easily embed a feed of posts into your website, delivering fresh content automatically to your site from Facebook. Posts, Photos, Events, Videos, Albums, Reviews, and more!', 'instagram-feed' ),
74
- 'more' => 'https://smashballoon.com/custom-facebook-feed/',
75
- 'item' => 2,
76
- ),
77
- array(
78
- 'title' => esc_html__( 'Adding Social Proof with Twitter Feeds', 'instagram-feed' ),
79
- 'content' => esc_html__( 'Twitter testimonials are one of the best ways to add verifiable social proof to your website. They add credibility to your brand, product, or service by displaying reviews from real people to your site, helping to convert more visitors into customers. Our free Custom Twitter Feeds plugin makes displaying Tweets on your website a breeze.', 'instagram-feed' ),
80
- 'more' => 'https://wordpress.org/plugins/custom-twitter-feeds/',
81
- 'item' => 3,
82
- ),
83
- );
84
-
85
- if ( $this->plugin_version === 'pro' ) {
86
- return $pro_messages;
87
- }
88
- return $free_messages;
89
-
90
- }
91
-
92
- /**
93
- * "Did You Know?" random message.
94
- *
95
- * @since 5.5
96
- */
97
- public function dyk_message_rnd() {
98
-
99
- $messages = $this->dyk_messages();
100
-
101
- $index = array_rand( $messages );
102
-
103
- return $messages[ $index ];
104
- }
105
-
106
- /**
107
- * "Did You Know?" display message.
108
- *
109
- * @since 5.5
110
- *
111
- */
112
- public function dyk_display() {
113
-
114
- $dyk_message = $this->dyk_message_rnd();
115
-
116
- if ( ! empty( $dyk_message['more'] ) ) {
117
- //utm_source=plugin-pro&utm_campaign=
118
- $dyk_message['more'] = add_query_arg(
119
- array(
120
- 'utm_source' => 'issueemail',
121
- 'utm_campaign' => 'instagram-'.$this->plugin_version,
122
- 'utm_medium' => $dyk_message['item'],
123
- ),
124
- $dyk_message['more']
125
- );
126
- }
127
-
128
- return $dyk_message;
129
- }
130
- }
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @since 5.5
6
+ */
7
+ class SB_Instagram_Education {
8
+
9
+ var $plugin_version;
10
+
11
+ /**
12
+ * Constructor.
13
+ *
14
+ * @since 5.5
15
+ */
16
+ public function __construct() {
17
+
18
+ $this->hooks();
19
+ }
20
+
21
+ /**
22
+ * Hooks.
23
+ *
24
+ * @since 5.5
25
+ */
26
+ public function hooks() {
27
+ $this->plugin_version = defined( 'SBI_STORE_URL' ) ? 'pro' : 'free';
28
+ }
29
+
30
+ /**
31
+ * "Did You Know?" messages.
32
+ *
33
+ * @since 5.5
34
+ */
35
+ public function dyk_messages() {
36
+
37
+ $free_messages = array(
38
+ array(
39
+ 'title' => esc_html__( 'Get the Most out of Hashtags', 'instagram-feed' ),
40
+ 'content' => esc_html__( 'You can use hashtags on Instagram for so many things; targeted promotions, engaging with your audience, running contests, or just for categorizing posts. Learn more about how you can display Instagram hashtag feeds on your website using the Instagram Feed Pro plugin.', 'instagram-feed' ),
41
+ 'more' => 'https://smashballoon.com/instagram-feed/features/#hashtag',
42
+ 'item' => 1,
43
+ ),
44
+ array(
45
+ 'title' => esc_html__( 'Keep Visitors on Your Site', 'instagram-feed' ),
46
+ 'content' => esc_html__( "You've done the hard work of getting a visitor onto your site, now keep them there by displaying your Instagram content inside a pop-up lightbox, rather than sending your visitors away to Instagram. Learn more about the Instagram Feed Pro lightbox feature.", 'instagram-feed' ),
47
+ 'more' => 'https://smashballoon.com/instagram-feed/features/#popuplightbox',
48
+ 'item' => 2,
49
+ ),
50
+ array(
51
+ 'title' => esc_html__( 'Highlight Your Posts and Create Carousels', 'instagram-feed' ),
52
+ 'content' => esc_html__( "Feature specific Instagram posts in your feeds by using the Highlight layout to feature specific posts, either by using their ID or a hashtag in their caption. Also create rotating carousels of your photos and videos to best utilize the space on your site. These layouts and more are available in our Pro version.", 'instagram-feed' ),
53
+ 'more' => 'https://smashballoon.com/instagram-feed/features/#highlight',
54
+ 'item' => 3,
55
+ ),
56
+ array(
57
+ 'title' => esc_html__( 'Moderate your Feed Content', 'instagram-feed' ),
58
+ 'content' => esc_html__( "Control exactly which posts show up in your feed by using the Visual Moderation Mode feature to pick and choose what to display. Remove specific posts or create a whitelist of approved content using Instagram Feed Pro.", 'instagram-feed' ),
59
+ 'more' => 'https://smashballoon.com/instagram-feed/features/#moderation',
60
+ 'item' => 4,
61
+ ),
62
+ );
63
+
64
+ $pro_messages = array(
65
+ array(
66
+ 'title' => esc_html__( 'Automated YouTube Live Streaming', 'instagram-feed' ),
67
+ 'content' => esc_html__( 'You can automatically feed live YouTube videos to your website using our Feeds For YouTube Pro plugin. It takes all the hassle out of publishing live videos to your site by automating the process.', 'instagram-feed' ),
68
+ 'more' => 'https://smashballoon.com/youtube-feed/',
69
+ 'item' => 1,
70
+ ),
71
+ array(
72
+ 'title' => esc_html__( 'Display Facebook Pages and Groups', 'instagram-feed' ),
73
+ 'content' => esc_html__( 'Have a Facebook Page or Group? Easily embed a feed of posts into your website, delivering fresh content automatically to your site from Facebook. Posts, Photos, Events, Videos, Albums, Reviews, and more!', 'instagram-feed' ),
74
+ 'more' => 'https://smashballoon.com/custom-facebook-feed/',
75
+ 'item' => 2,
76
+ ),
77
+ array(
78
+ 'title' => esc_html__( 'Adding Social Proof with Twitter Feeds', 'instagram-feed' ),
79
+ 'content' => esc_html__( 'Twitter testimonials are one of the best ways to add verifiable social proof to your website. They add credibility to your brand, product, or service by displaying reviews from real people to your site, helping to convert more visitors into customers. Our free Custom Twitter Feeds plugin makes displaying Tweets on your website a breeze.', 'instagram-feed' ),
80
+ 'more' => 'https://wordpress.org/plugins/custom-twitter-feeds/',
81
+ 'item' => 3,
82
+ ),
83
+ );
84
+
85
+ if ( $this->plugin_version === 'pro' ) {
86
+ return $pro_messages;
87
+ }
88
+ return $free_messages;
89
+
90
+ }
91
+
92
+ /**
93
+ * "Did You Know?" random message.
94
+ *
95
+ * @since 5.5
96
+ */
97
+ public function dyk_message_rnd() {
98
+
99
+ $messages = $this->dyk_messages();
100
+
101
+ $index = array_rand( $messages );
102
+
103
+ return $messages[ $index ];
104
+ }
105
+
106
+ /**
107
+ * "Did You Know?" display message.
108
+ *
109
+ * @since 5.5
110
+ *
111
+ */
112
+ public function dyk_display() {
113
+
114
+ $dyk_message = $this->dyk_message_rnd();
115
+
116
+ if ( ! empty( $dyk_message['more'] ) ) {
117
+ //utm_source=plugin-pro&utm_campaign=
118
+ $dyk_message['more'] = add_query_arg(
119
+ array(
120
+ 'utm_source' => 'issueemail',
121
+ 'utm_campaign' => 'instagram-'.$this->plugin_version,
122
+ 'utm_medium' => $dyk_message['item'],
123
+ ),
124
+ $dyk_message['more']
125
+ );
126
+ }
127
+
128
+ return $dyk_message;
129
+ }
130
+ }
inc/class-sb-instagram-feed.php CHANGED
@@ -1,1477 +1,1477 @@
1
- <?php
2
- /**
3
- * Class SB_Instagram_Feed
4
- *
5
- * Retrieves data and generates the html for each feed. The
6
- * "display_instagram" function in the if-functions.php file
7
- * is where this class is primarily used.
8
- *
9
- * @since 2.0/4.0
10
- */
11
-
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- die( '-1' );
14
- }
15
-
16
- class SB_Instagram_Feed
17
- {
18
- /**
19
- * @var string
20
- */
21
- private $regular_feed_transient_name;
22
-
23
- /**
24
- * @var string
25
- */
26
- private $header_transient_name;
27
-
28
- /**
29
- * @var string
30
- */
31
- private $backup_feed_transient_name;
32
-
33
- /**
34
- * @var string
35
- */
36
- private $backup_header_transient_name;
37
-
38
- /**
39
- * @var array
40
- */
41
- private $post_data;
42
-
43
- /**
44
- * @var
45
- */
46
- private $header_data;
47
-
48
- /**
49
- * @var array
50
- */
51
- private $next_pages;
52
-
53
- /**
54
- * @var array
55
- */
56
- private $transient_atts;
57
-
58
- /**
59
- * @var int
60
- */
61
- private $last_retrieve;
62
-
63
- /**
64
- * @var bool
65
- */
66
- private $should_paginate;
67
-
68
- /**
69
- * @var int
70
- */
71
- private $num_api_calls;
72
-
73
- /**
74
- * @var array
75
- */
76
- private $image_ids_post_set;
77
-
78
- /**
79
- * @var bool
80
- */
81
- private $should_use_backup;
82
-
83
- /**
84
- * @var array
85
- */
86
- private $report;
87
-
88
- /**
89
- * @var array
90
- *
91
- * @since 2.1.1/5.2.1
92
- */
93
- private $resized_images;
94
-
95
- /**
96
- * @var array
97
- *
98
- * @since 2.1.3/5.2.3
99
- */
100
- protected $one_post_found;
101
-
102
- /**
103
- * SB_Instagram_Feed constructor.
104
- *
105
- * @param string $transient_name ID of this feed
106
- * generated in the SB_Instagram_Settings class
107
- */
108
- public function __construct( $transient_name ) {
109
- $this->regular_feed_transient_name = $transient_name;
110
- $this->backup_feed_transient_name = SBI_BACKUP_PREFIX . $transient_name;
111
-
112
- $sbi_header_transient_name = str_replace( 'sbi_', 'sbi_header_', $transient_name );
113
- $sbi_header_transient_name = substr($sbi_header_transient_name, 0, 44);
114
- $this->header_transient_name = $sbi_header_transient_name;
115
- $this->backup_header_transient_name = SBI_BACKUP_PREFIX . $sbi_header_transient_name;
116
-
117
- $this->post_data = array();
118
- $this->next_pages = array();
119
- $this->should_paginate = true;
120
-
121
- // this is a count of how many api calls have been made for each feed
122
- // type and term.
123
- // By default the limit is 10
124
- $this->num_api_calls = 0;
125
- $this->max_api_calls = apply_filters( 'sbi_max_concurrent_api_calls', 10 );
126
- $this->should_use_backup = false;
127
-
128
- // used for errors and the sbi_debug report
129
- $this->report = array();
130
-
131
- $this->resized_images = array();
132
-
133
- $this->one_post_found = false;
134
- }
135
-
136
- /**
137
- * @return array
138
- *
139
- * @since 2.0/5.0
140
- */
141
- public function get_post_data() {
142
- return $this->post_data;
143
- }
144
-
145
- /**
146
- * @return array
147
- *
148
- * @since 2.0/5.0
149
- */
150
- public function set_post_data( $post_data ) {
151
- $this->post_data = $post_data;
152
- }
153
-
154
- /**
155
- * @return array
156
- *
157
- * @since 2.1.1/5.2.1
158
- */
159
- public function set_resized_images( $resized_image_data ) {
160
- $this->resized_images = $resized_image_data;
161
- }
162
-
163
- /**
164
- * @return array
165
- *
166
- * @since 2.0/5.0
167
- */
168
- public function get_next_pages() {
169
- return $this->next_pages;
170
- }
171
-
172
- /**
173
- * @return array
174
- *
175
- * @since 2.1.1/5.2.1
176
- */
177
- public function get_resized_images() {
178
- return $this->resized_images;
179
- }
180
-
181
- /**
182
- * Checks the database option related the transient expiration
183
- * to ensure it will be available when the page loads
184
- *
185
- * @return bool
186
- *
187
- * @since 2.0/4.0
188
- */
189
- public function regular_cache_exists() {
190
- //Check whether the cache transient exists in the database and is available for more than one more minute
191
- $transient_exists = get_transient( $this->regular_feed_transient_name );
192
-
193
- return $transient_exists;
194
- }
195
-
196
- /**
197
- * Checks the database option related the header transient
198
- * expiration to ensure it will be available when the page loads
199
- *
200
- * @return bool
201
- *
202
- * @since 2.0/5.0
203
- */
204
- public function regular_header_cache_exists() {
205
- $header_transient = get_transient( $this->header_transient_name );
206
-
207
- return $header_transient;
208
- }
209
-
210
- /**
211
- * @return bool
212
- *
213
- * @since 2.0/5.0
214
- */
215
- public function should_use_backup() {
216
- return $this->should_use_backup || empty( $this->post_data );
217
- }
218
-
219
- /**
220
- * The header is only displayed when the setting is enabled and
221
- * an account has been connected
222
- *
223
- * Overwritten in the Pro version
224
- *
225
- * @param array $settings settings specific to this feed
226
- * @param array $feed_types_and_terms organized settings related to feed data
227
- * (ex. 'user' => array( 'smashballoon', 'custominstagramfeed' )
228
- *
229
- * @return bool
230
- *
231
- * @since 2.0/5.0
232
- */
233
- public function need_header( $settings, $feed_types_and_terms ) {
234
- $showheader = ($settings['showheader'] === 'on' || $settings['showheader'] === 'true' || $settings['showheader'] === true);
235
- return ($showheader && isset( $feed_types_and_terms['users'] ));
236
- }
237
-
238
- /**
239
- * Use the transient name to retrieve cached data for header
240
- *
241
- * @since 2.0/5.0
242
- */
243
- public function set_header_data_from_cache() {
244
- $header_cache = get_transient( $this->header_transient_name );
245
-
246
- $header_cache = json_decode( $header_cache, true );
247
-
248
- if ( ! empty( $header_cache ) ) {
249
- $this->header_data = $header_cache;
250
- }
251
- }
252
-
253
- public function set_header_data( $header_data ) {
254
- $this->header_data = $header_data;
255
- }
256
-
257
- /**
258
- * @since 2.0/5.0
259
- */
260
- public function get_header_data() {
261
- return $this->header_data;
262
- }
263
-
264
- /**
265
- * Sets the post data, pagination data, shortcode atts used (cron cache),
266
- * and timestamp of last retrieval from transient (cron cache)
267
- *
268
- * @param array $atts available for cron caching
269
- *
270
- * @since 2.0/5.0
271
- */
272
- public function set_post_data_from_cache( $atts = array() ) {
273
- $transient_data = get_transient( $this->regular_feed_transient_name );
274
-
275
- $transient_data = json_decode( $transient_data, true );
276
-
277
- if ( $transient_data ) {
278
- $post_data = isset( $transient_data['data'] ) ? $transient_data['data'] : array();
279
- $this->post_data = $post_data;
280
- $this->next_pages = isset( $transient_data['pagination'] ) ? $transient_data['pagination'] : array();
281
-
282
- if ( isset( $transient_data['atts'] ) ) {
283
- $this->transient_atts = $transient_data['atts'];
284
- $this->last_retrieve = $transient_data['last_retrieve'];
285
- }
286
- }
287
- }
288
-
289
- /**
290
- * Sets post data from a permanent database backup of feed
291
- * if it was created
292
- *
293
- * @since 2.0/5.0
294
- * @since 2.0/5.1.2 if backup feed data used, header data also set from backup
295
- */
296
- public function maybe_set_post_data_from_backup() {
297
- $backup_data = get_option( $this->backup_feed_transient_name, false );
298
-
299
- if ( $backup_data ) {
300
- $backup_data = json_decode( $backup_data, true );
301
-
302
- $post_data = isset( $backup_data['data'] ) ? $backup_data['data'] : array();
303
- $this->post_data = $post_data;
304
- $this->next_pages = isset( $backup_data['pagination'] ) ? $backup_data['pagination'] : array();
305
-
306
- if ( isset( $backup_data['atts'] ) ) {
307
- $this->transient_atts = $backup_data['atts'];
308
- $this->last_retrieve = $backup_data['last_retrieve'];
309
- }
310
-
311
- $this->maybe_set_header_data_from_backup();
312
-
313
- return true;
314
- } else {
315
- $this->add_report( 'no backup post data found' );
316
-
317
- return false;
318
- }
319
- }
320
-
321
- /**
322
- * Sets header data from a permanent database backup of feed
323
- * if it was created
324
- *
325
- * @since 2.0/5.0
326
- */
327
- public function maybe_set_header_data_from_backup() {
328
- $backup_header_data = get_option( $this->backup_header_transient_name, false );
329
-
330
- if ( ! empty( $backup_header_data ) ) {
331
- $backup_header_data = json_decode( $backup_header_data, true );
332
- $this->header_data = $backup_header_data;
333
-
334
- return true;
335
- } else {
336
- $this->add_report( 'no backup header data found' );
337
-
338
- return false;
339
- }
340
- }
341
-
342
- /**
343
- * Returns recorded image IDs for this post set
344
- * for use with image resizing
345
- *
346
- * @return array
347
- *
348
- * @since 2.0/5.0
349
- */
350
- public function get_image_ids_post_set() {
351
- return $this->image_ids_post_set;
352
- }
353
-
354
- /**
355
- * Retrieves data related to resized images from custom
356
- * tables using either a number, offset, and transient name
357
- * or the ids of the posts.
358
- *
359
- * Retrieving by offset and transient name not used currently
360
- * but may be needed in future updates.
361
- *
362
- * @param array/int $num_or_array_of_ids post ids from the Instagram
363
- * API
364
- * @param int $offset number of records to skip
365
- * @param string $transient_name ID of the feed
366
- *
367
- * @return array
368
- *
369
- * @since 2.0/5.0
370
- */
371
- public static function get_resized_images_source_set( $num_or_array_of_ids, $offset = 0, $transient_name = '' ) {
372
- global $sb_instagram_posts_manager;
373
-
374
- if ( $sb_instagram_posts_manager->image_resizing_disabled() ) {
375
- return array();
376
- }
377
-
378
- global $wpdb;
379
-
380
- $posts_table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
381
- $feeds_posts_table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
382
-
383
- $feed_id_array = explode( '#', $transient_name );
384
- $feed_id = $feed_id_array[0];
385
-
386
- if ( is_array( $num_or_array_of_ids ) ) {
387
- $ids = $num_or_array_of_ids;
388
-
389
- $id_string = "'" . implode( "','", $ids ) . "'";
390
- $results = $wpdb->get_results( $wpdb->prepare( "
391
- SELECT p.media_id, p.instagram_id, p.aspect_ratio, p.sizes
392
- FROM $posts_table_name AS p
393
- INNER JOIN $feeds_posts_table_name AS f ON p.id = f.id
394
- WHERE f.feed_id = %s
395
- AND p.instagram_id IN($id_string)
396
- AND p.images_done = 1", $feed_id ), ARRAY_A );
397
-
398
- $return = array();
399
- if ( !empty( $results ) && is_array( $results ) ) {
400
-
401
- foreach ( $results as $result ) {
402
- $sizes = maybe_unserialize( $result['sizes'] );
403
- if ( ! is_array( $sizes ) ) {
404
- $sizes = array( 'full' => 640 );
405
- }
406
- $return[ $result['instagram_id'] ] = array(
407
- 'id' => $result['media_id'],
408
- 'ratio' => $result['aspect_ratio'],
409
- 'sizes' => $sizes
410
- );
411
- }
412
-
413
- }
414
- } else {
415
- $num = $num_or_array_of_ids;
416
-
417
- $results = $wpdb->get_results( $wpdb->prepare( "
418
- SELECT p.media_id, p.instagram_id, p.aspect_ratio, p.sizes
419
- FROM $posts_table_name AS p
420
- INNER JOIN $feeds_posts_table_name AS f ON p.id = f.id
421
- WHERE f.feed_id = %s
422
- AND p.images_done = 1
423
- ORDER BY p.time_stamp
424
- DESC LIMIT %d, %d", $feed_id, $offset, (int)$num ), ARRAY_A );
425
-
426
- $return = array();
427
- if ( !empty( $results ) && is_array( $results ) ) {
428
-
429
- foreach ( $results as $result ) {
430
- $sizes = maybe_unserialize( $result['sizes'] );
431
- if ( ! is_array( $sizes ) ) {
432
- $sizes = array( 'full' => 640 );
433
- }
434
- $return[ $result['instagram_id'] ] = array(
435
- 'id' => $result['media_id'],
436
- 'ratio' => $result['aspect_ratio'],
437
- 'sizes' => $sizes
438
- );
439
- }
440
-
441
- }
442
- }
443
-
444
-
445
- return $return;
446
- }
447
-
448
- /**
449
- * The plugin tracks when a post was last requested so only the most
450
- * recently displayed posts are kept in the database.
451
- * This function updates the timestamp for a set of posts
452
- * on the page.
453
- *
454
- * @param $array_of_ids
455
- *
456
- * @since 2.0/5.0
457
- */
458
- public static function update_last_requested( $array_of_ids ) {
459
- if ( empty( $array_of_ids ) ) {
460
- return;
461
- }
462
-
463
- global $wpdb;
464
- $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
465
- $id_string = "'" . implode( "','", $array_of_ids ) . "'";
466
-
467
- $query = $wpdb->query( $wpdb->prepare( "UPDATE $table_name
468
- SET last_requested = %s
469
- WHERE instagram_id IN ({$id_string});", date( 'Y-m-d H:i:s' ) ) );
470
- }
471
-
472
- /**
473
- * Cron caching needs additional data saved in the transient
474
- * to work properly. This function checks to make sure it's present
475
- *
476
- * @return bool
477
- *
478
- * @since 2.0/5.0
479
- */
480
- public function need_to_start_cron_job() {
481
- return (( ! empty( $this->post_data ) && ! isset( $this->transient_atts )) || empty( $this->post_data ));
482
- }
483
-
484
- /**
485
- * Checks to see if there are enough posts available to create
486
- * the current page of the feed
487
- *
488
- * @param int $num
489
- * @param int $offset
490
- *
491
- * @return bool
492
- *
493
- * @since 2.0/5.0
494
- */
495
- public function need_posts( $num, $offset = 0 ) {
496
- $num_existing_posts = is_array( $this->post_data ) ? count( $this->post_data ) : 0;
497
- $num_needed_for_page = (int)$num + (int)$offset;
498
-
499
- ($num_existing_posts < $num_needed_for_page) ? $this->add_report( 'need more posts' ) : $this->add_report( 'have enough posts' );
500
-
501
- return ($num_existing_posts < $num_needed_for_page);
502
- }
503
-
504
- /**
505
- * Checks to see if there are additional pages available for any of the
506
- * accounts in the feed and that the max conccurrent api request limit
507
- * has not been reached
508
- *
509
- * @return bool
510
- *
511
- * @since 2.0/5.0
512
- */
513
- public function can_get_more_posts() {
514
- $one_type_and_term_has_more_ages = $this->next_pages !== false;
515
- $max_concurrent_api_calls_not_met = $this->num_api_calls < $this->max_api_calls;
516
- $max_concurrent_api_calls_not_met ? $this->add_report( 'max conccurrent requests not met' ) : $this->add_report( 'max concurrent met' );
517
- $one_type_and_term_has_more_ages ? $this->add_report( 'more pages available' ) : $this->add_report( 'no next page' );
518
-
519
- return ($one_type_and_term_has_more_ages && $max_concurrent_api_calls_not_met);
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', 'custominstagramfeed' )
528
- * @param array $connected_accounts_for_feed connected account data for the
529
- * feed types and terms
530
- *
531
- * @since 2.0/5.0
532
- * @since 2.0/5.1 added logic to make a second attempt at an API connection
533
- * @since 2.0/5.1.2 remote posts only retrieved if API requests are not
534
- * delayed, terms shuffled if there are more than 5
535
- * @since 2.2/5.3 added logic to refresh the access token for basic display
536
- * accounts if needed before using it in an API request
537
- */
538
- public function add_remote_posts( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
539
- $new_post_sets = array();
540
- $next_pages = $this->next_pages;
541
- global $sb_instagram_posts_manager;
542
-
543
- /**
544
- * Number of posts to retrieve in each API call
545
- *
546
- * @param int Minimum number of posts needed in each API request
547
- * @param array $settings Settings for this feed
548
- *
549
- * @since 2.0/5.0
550
- */
551
- $num = apply_filters( 'sbi_num_in_request', $settings['minnum'], $settings );
552
- $num = max( $num, (int)$settings['apinum'] );
553
- $params = array(
554
- 'num' => $num
555
- );
556
-
557
- $one_successful_connection = false;
558
- $one_post_found = false;
559
- $next_page_found = false;
560
- $one_api_request_delayed = false;
561
-
562
- foreach ( $feed_types_and_terms as $type => $terms ) {
563
- if ( is_array( $terms ) && count( $terms ) > 5 ) {
564
- shuffle( $terms );
565
- }
566
- foreach ( $terms as $term_and_params ) {
567
- $term = $term_and_params['term'];
568
- $params = array_merge( $params, $term_and_params['params'] );
569
- $connected_account_for_term = $connected_accounts_for_feed[ $term ];
570
-
571
- $api_requests_delayed = $sb_instagram_posts_manager->are_current_api_request_delays( $connected_account_for_term['user_id'] );
572
-
573
- if ( ! $api_requests_delayed
574
- && (! isset( $next_pages[ $term . '_' . $type ] ) || $next_pages[ $term . '_' . $type ] !== false) ) {
575
-
576
- $account_type = isset( $connected_account_for_term['type'] ) ? $connected_account_for_term['type'] : 'personal';
577
- $skip_connection = false;
578
-
579
- // basic account access tokens need to be refreshed every 60 days
580
- // normally done using WP Cron but can be done here as a fail safe
581
- if ( $account_type === 'basic' ) {
582
- if ( SB_Instagram_Token_Refresher::refresh_time_has_passed_threshold( $connected_account_for_term )
583
- && SB_Instagram_Token_Refresher::minimum_time_interval_since_last_attempt_has_passed( $connected_account_for_term ) ) {
584
- $refresher = new SB_Instagram_Token_Refresher( $connected_account_for_term );
585
- $refresher->attempt_token_refresh();
586
- $this->add_report( 'trying to refresh token ' . $term . '_' . $type );
587
- }
588
- } elseif( $account_type === 'personal' && sbi_is_after_deprecation_deadline() ) {
589
- $skip_connection = true;
590
- }
591
-
592
- if ( ! empty( $next_pages[ $term . '_' . $type ] ) ) {
593
- $next_page_term = $next_pages[ $term . '_' . $type ];
594
- if ( strpos( $next_page_term, 'https://' ) !== false ) {
595
- $connection = $this->make_api_connection( $next_page_term );
596
- } else {
597
- $params['cursor'] = $next_page_term;
598
- $connection = $this->make_api_connection( $connected_account_for_term, $type, $params );
599
- }
600
- } else {
601
- $connection = $this->make_api_connection( $connected_account_for_term, $type, $params );
602
- }
603
- $this->add_report( 'api call made for ' . $term . ' - ' . $type );
604
-
605
- if ( ! $skip_connection ) {
606
- $connection->connect();
607
- }
608
- $this->num_api_calls++;
609
-
610
- if ( ! $skip_connection && ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
611
- $one_successful_connection = true;
612
-
613
- $sb_instagram_posts_manager->remove_error( 'connection' );
614
- $sb_instagram_posts_manager->remove_error( 'api' );
615
- $sb_instagram_posts_manager->remove_error( 'at_' . $term );
616
-
617
- $data = $connection->get_data();
618
-
619
- if ( !$connected_account_for_term['is_valid'] ) {
620
- $this->add_report( 'clearing invalid token' );
621
- $this->clear_expired_access_token_notice( $connected_account_for_term );
622
- }
623
-
624
- if ( isset( $data[0]['id'] ) ) {
625
- $one_post_found = true;
626
-
627
- $post_set = $this->filter_posts( $data, $settings );
628
-
629
- $new_post_sets[] = $post_set;
630
- }
631
-
632
- $next_page = $connection->get_next_page( $type );
633
- if ( ! empty( $next_page ) ) {
634
- $next_pages[ $term . '_' . $type ] = $next_page;
635
- $next_page_found = true;
636
- } else {
637
- $next_pages[ $term . '_' . $type ] = false;
638
- }
639
- } else {
640
-
641
- if ( $this->can_try_another_request( $type, $connected_accounts_for_feed[ $term ] ) ) {
642
- $this->add_report( 'trying other accounts' );
643
- $i = 0;
644
- $attempted = array( $connected_accounts_for_feed[ $term ]['user_id'] );
645
- $success = false;
646
- $different = true;
647
- $error = false;
648
-
649
- while ( $different
650
- && ! $success
651
- && $this->can_try_another_request( $type, $connected_accounts_for_feed[ $term ], $i ) ) {
652
- $different = $this->get_different_connected_account( $type, $attempted );
653
- $this->add_report( 'trying the account ' . $different['user_id'] );
654
-
655
- if ( $different ) {
656
- $connected_accounts_for_feed[ $term ] = $this->get_different_connected_account( $type, $attempted );
657
- $attempted[] = $connected_accounts_for_feed[ $term ]['user_id'];
658
- if ( ! empty( $next_pages[ $term . '_' . $type ] ) ) {
659
- $connection = $this->make_api_connection( $next_pages[ $term . '_' . $type ] );
660
- } else {
661
- $connection = $this->make_api_connection( $connected_accounts_for_feed[ $term ], $type, $params );
662
- }
663
- $connection->connect();
664
- $this->num_api_calls++;
665
- if ( ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
666
- $one_successful_connection = true;
667
-
668
- $sb_instagram_posts_manager->remove_error( 'connection' );
669
- $sb_instagram_posts_manager->remove_error( 'api' );
670
- $sb_instagram_posts_manager->remove_error( 'at_' . $term );
671
-
672
- $data = $connection->get_data();
673
- if ( isset( $data[0]['id'] ) ) {
674
- $one_post_found = true;
675
- $post_set = $this->filter_posts( $data, $settings );
676
- $new_post_sets[] = $post_set;
677
- }
678
- $next_page = $connection->get_next_page( $type );
679
- if ( ! empty( $next_page ) ) {
680
- $next_pages[ $term . '_' . $type ] = $next_page;
681
- $next_page_found = true;
682
- } else {
683
- $next_pages[ $term . '_' . $type ] = false;
684
- }
685
- } else {
686
- if ( $connection->is_wp_error() ) {
687
- $error = $connection->get_wp_error();
688
- } else {
689
- $error = $connection->get_data();
690
- }
691
- }
692
- $i++;
693
- }
694
- }
695
-
696
- if ( ! $success && $error ) {
697
- if ( $connection->is_wp_error() ) {
698
- SB_Instagram_API_Connect::handle_wp_remote_get_error( $error );
699
- } else {
700
- SB_Instagram_API_Connect::handle_instagram_error( $error, $connected_accounts_for_feed[ $term ], $type );
701
- }
702
- $next_pages[ $term . '_' . $type ] = false;
703
- $show_error_message = true;
704
-
705
- }
706
- } else {
707
- if ( $skip_connection ) {
708
-
709
- } elseif ( $connection->is_wp_error() ) {
710
- SB_Instagram_API_Connect::handle_wp_remote_get_error( $connection->get_wp_error() );
711
- } else {
712
- SB_Instagram_API_Connect::handle_instagram_error( $connection->get_data(), $connected_accounts_for_feed[ $term ], $type );
713
- }
714
- $show_error_message = true;
715
-
716
- $next_pages[ $term . '_' . $type ] = false;
717
- }
718
- }
719
- } elseif ( $api_requests_delayed ) {
720
- $one_api_request_delayed = true;
721
-
722
- $this->add_report( 'delaying API request for ' . $term . ' - ' . $type );
723
- $show_error_message = true;
724
- }
725
-
726
- if ( isset( $show_error_message ) ) {
727
- $error = '';
728
- if ( $sb_instagram_posts_manager->are_critical_errors() ) {
729
- $error .= $sb_instagram_posts_manager->get_critical_errors();
730
- } else {
731
- $errors = $sb_instagram_posts_manager->get_frontend_errors();
732
- $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
733
- $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
734
- if ( current_user_can( $cap ) ) {
735
- foreach ( $errors as $error_message ) {
736
- $error .= $error_message;
737
- }
738
- $error .= '<p class="sbi-error-directions"><a href="https://smashballoon.com/instagram-feed/docs/errors/" target="_blank" rel="noopener">' . __( 'Directions on how to resolve this issue.', 'instagram-feed' ) . '</a></p>';
739
- } else {
740
- $error = '<p><b>' . sprintf( __( 'Error: API requests are being delayed for this account.', 'instagram-feed' ), $connected_account_for_term['username'] ) . ' ' . __( 'New posts will not be retrieved.', 'instagram-feed' ) . '</b></p>';
741
- $error .= '<p>' . __( 'Log in as an administrator and view the Instagram Feed settings page for more details.', 'instagram-feed' ) . '</p>';
742
- }
743
- }
744
-
745
- $sb_instagram_posts_manager->add_frontend_error( 'at_' . $connected_account_for_term['username'], $error );
746
- }
747
-
748
- }
749
- }
750
-
751
- if ( ! $one_successful_connection || ($one_api_request_delayed && empty( $new_post_sets )) ) {
752
- $this->should_use_backup = true;
753
- }
754
- $posts = $this->merge_posts( $new_post_sets, $settings );
755
-
756
- $posts = $this->sort_posts( $posts, $settings );
757
-
758
- if ( ! empty( $this->post_data ) && is_array( $this->post_data ) ) {
759
- $posts = array_merge( $this->post_data, $posts );
760
- } elseif ( $one_post_found ) {
761
- $this->one_post_found = true;
762
- }
763
-
764
- $this->post_data = $posts;
765
-
766
- if ( isset( $next_page_found ) && $next_page_found ) {
767
- $this->next_pages = $next_pages;
768
- } else {
769
- $this->next_pages = false;
770
- }
771
- }
772
-
773
- /**
774
- * Connects to the Instagram API and records returned data
775
- *
776
- * @param $settings
777
- * @param array $feed_types_and_terms organized settings related to feed data
778
- * (ex. 'user' => array( 'smashballoon', 'custominstagramfeed' )
779
- * @param array $connected_accounts_for_feed connected account data for the
780
- * feed types and terms
781
- *
782
- * @since 2.0/5.0
783
- * @since 2.2/5.3 added logic to append bio data from the related
784
- * connected account if not available in the API response
785
- */
786
- public function set_remote_header_data( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
787
- $first_user = $this->get_first_user( $feed_types_and_terms );
788
- $this->header_data = false;
789
- global $sb_instagram_posts_manager;
790
-
791
- $api_requests_delayed = isset( $connected_accounts_for_feed[ $first_user ]['user_id'] ) ? $sb_instagram_posts_manager->are_current_api_request_delays( $connected_accounts_for_feed[ $first_user ]['user_id'] ) : $sb_instagram_posts_manager->are_current_api_request_delays();
792
-
793
- if ( isset( $connected_accounts_for_feed[ $first_user ] ) && ! $api_requests_delayed ) {
794
- $connection = new SB_Instagram_API_Connect( $connected_accounts_for_feed[ $first_user ], 'header', array() );
795
-
796
- $connection->connect();
797
-
798
- if ( ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
799
- $this->header_data = $connection->get_data();
800
-
801
- $sb_instagram_posts_manager->remove_error( 'connection' );
802
- $sb_instagram_posts_manager->remove_error( 'api' );
803
- $sb_instagram_posts_manager->remove_error( 'at_' . $first_user );
804
-
805
- if ( isset( $connected_accounts_for_feed[ $first_user ]['local_avatar'] ) && $connected_accounts_for_feed[ $first_user ]['local_avatar'] ) {
806
- $upload = wp_upload_dir();
807
- $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBI_UPLOADS_NAME );
808
-
809
- $full_file_name = $resized_url . $this->header_data['username'] . '.jpg';
810
- $this->header_data['local_avatar'] = $full_file_name;
811
- }
812
- if ( empty( $this->header_data['bio'] )
813
- && isset( $connected_accounts_for_feed[ $first_user ]['bio'] ) ) {
814
-
815
- $this->header_data['bio'] = sbi_decode_emoji( $connected_accounts_for_feed[ $first_user ]['bio'] );
816
- }
817
- } else {
818
- if ( $connection->is_wp_error() ) {
819
- SB_Instagram_API_Connect::handle_wp_remote_get_error( $connection->get_wp_error() );
820
- } else {
821
- SB_Instagram_API_Connect::handle_instagram_error( $connection->get_data(), $connected_accounts_for_feed[ $first_user ], 'header' );
822
- }
823
- }
824
- }
825
- }
826
-
827
- /**
828
- * Stores feed data in a transient for a specified time
829
- *
830
- * @param int $cache_time
831
- * @param bool $save_backup
832
- *
833
- * @since 2.0/5.0
834
- * @since 2.0/5.1 duplicate posts removed
835
- */
836
- public function cache_feed_data( $cache_time, $save_backup = true ) {
837
- if ( ! empty( $this->post_data ) || ! empty( $this->next_pages ) ) {
838
- $this->remove_duplicate_posts();
839
- $this->trim_posts_to_max();
840
-
841
- $to_cache = array(
842
- 'data' => $this->post_data,
843
- 'pagination' => $this->next_pages
844
- );
845
-
846
- set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
847
-
848
- if ( $save_backup ) {
849
- update_option( $this->backup_feed_transient_name, wp_json_encode( $to_cache ), false );
850
- }
851
- } else {
852
- $this->add_report( 'no data not caching' );
853
- }
854
- }
855
-
856
- /**
857
- * Stores feed data with additional data specifically for cron caching
858
- *
859
- * @param array $to_cache feed data with additional things like the shortcode
860
- * settings, when the cache was last requested, when new posts were last retrieved
861
- * @param int $cache_time how long the cache will last
862
- * @param bool $save_backup whether or not to also save this as a permanent cache
863
- *
864
- * @since 2.0/5.0
865
- * @since 2.0/5.1 duplicate posts removed, cache set trimmed to a maximum
866
- */
867
- public function set_cron_cache( $to_cache, $cache_time, $save_backup = true ) {
868
- if ( ! empty( $this->post_data )
869
- || ! empty( $this->next_pages )
870
- || ! empty( $to_cache['data'] ) ) {
871
- $this->remove_duplicate_posts();
872
- $this->trim_posts_to_max();
873
-
874
- $to_cache['data'] = isset( $to_cache['data'] ) ? $to_cache['data'] : $this->post_data;
875
- $to_cache['pagination'] = isset( $to_cache['next_pages'] ) ? $to_cache['next_pages'] : $this->next_pages;
876
- $to_cache['atts'] = isset( $to_cache['atts'] ) ? $to_cache['atts'] : $this->transient_atts;
877
- $to_cache['last_requested'] = isset( $to_cache['last_requested'] ) ? $to_cache['last_requested'] : time();
878
- $to_cache['last_retrieve'] = isset( $to_cache['last_retrieve'] ) ? $to_cache['last_retrieve'] : $this->last_retrieve;
879
-
880
- set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
881
-
882
- if ( $save_backup ) {
883
- update_option( $this->backup_feed_transient_name, wp_json_encode( $to_cache ), false );
884
- }
885
- } else {
886
- $this->add_report( 'no data not caching' );
887
- }
888
-
889
- }
890
-
891
- /**
892
- * Stores header data for a specified time as a transient
893
- *
894
- * @param int $cache_time
895
- * @param bool $save_backup
896
- *
897
- * @since 2.0/5.0
898
- */
899
- public function cache_header_data( $cache_time, $save_backup = true ) {
900
- if ( $this->header_data ) {
901
- set_transient( $this->header_transient_name, wp_json_encode( $this->header_data ), $cache_time );
902
-
903
- if ( $save_backup ) {
904
- update_option( $this->backup_header_transient_name, wp_json_encode( $this->header_data ), false );
905
- }
906
- }
907
- }
908
-
909
- /**
910
- * Used to randomly trigger an updating of the last requested data for cron caching
911
- *
912
- * @return bool
913
- *
914
- * @since 2.0/5.0
915
- */
916
- public function should_update_last_requested() {
917
- return (rand( 1, 20 ) === 20);
918
- }
919
-
920
- /**
921
- * Determines if pagination can and should be used based on settings and available feed data
922
- *
923
- * @param array $settings
924
- * @param int $offset
925
- *
926
- * @return bool
927
- *
928
- * @since 2.0/5.0
929
- */
930
- public function should_use_pagination( $settings, $offset = 0 ) {
931
- if ( $settings['minnum'] < 1 ) {
932
- return false;
933
- }
934
- $posts_available = count( $this->post_data ) - ($offset + $settings['num']);
935
- $show_loadmore_button_by_settings = ($settings['showbutton'] == 'on' || $settings['showbutton'] == 'true' || $settings['showbutton'] == true ) && $settings['showbutton'] !== 'false';
936
-
937
- if ( $show_loadmore_button_by_settings ) {
938
- // used for permanent and whitelist feeds
939
- if ( $this->feed_is_complete( $settings, $offset ) ) {
940
- $this->add_report( 'no pagination, feed complete' );
941
- return false;
942
- }
943
- if ( $posts_available > 0 ) {
944
- $this->add_report( 'do pagination, posts available' );
945
- return true;
946
- }
947
- $pages = $this->next_pages;
948
-
949
- if ( $pages && ! $this->should_use_backup() ) {
950
- foreach ( $pages as $page ) {
951
- if ( ! empty( $page ) ) {
952
- return true;
953
- }
954
- }
955
- }
956
-
957
- }
958
-
959
-
960
- $this->add_report( 'no pagination, no posts available' );
961
-
962
- return false;
963
- }
964
-
965
- /**
966
- * Generates the HTML for the feed if post data is available. Although it seems
967
- * some of the variables ar not used they are set here to hide where they
968
- * come from when used in the feed templates.
969
- *
970
- * @param array $settings
971
- * @param array $atts
972
- * @param array $feed_types_and_terms organized settings related to feed data
973
- * (ex. 'user' => array( 'smashballoon', 'custominstagramfeed' )
974
- * @param array $connected_accounts_for_feed connected account data for the
975
- * feed types and terms
976
- *
977
- * @return false|string
978
- *
979
- * @since 2.0/5.0
980
- */
981
- public function get_the_feed_html( $settings, $atts, $feed_types_and_terms, $connected_accounts_for_feed ) {
982
- global $sb_instagram_posts_manager;
983
-
984
- if ( empty( $this->post_data ) && ! empty( $connected_accounts_for_feed ) && $settings['minnum'] > 0 ) {
985
- $this->handle_no_posts_found( $settings, $feed_types_and_terms );
986
- }
987
- $posts = array_slice( $this->post_data, 0, $settings['minnum'] );
988
- $header_data = ! empty( $this->header_data ) ? $this->header_data : false;
989
-
990
- $first_user = ! empty( $feed_types_and_terms['users'][0] ) ? $feed_types_and_terms['users'][0]['term'] : false;
991
- $first_username = false;
992
- if ( $first_user ) {
993
- $first_username = isset( $connected_accounts_for_feed[ $first_user ]['username'] ) ? $connected_accounts_for_feed[ $first_user ]['username'] : $first_user;
994
- } elseif ( $header_data ) { // in case no connected account for feed
995
- $first_username = SB_Instagram_Parse::get_username( $header_data );
996
- } elseif ( isset( $feed_types_and_terms['users'] ) && isset( $this->post_data[0] ) ) { // in case no connected account and no header
997
- $first_username = SB_Instagram_Parse::get_username( $this->post_data[0] );
998
- }
999
- $use_pagination = $this->should_use_pagination( $settings, 0 );
1000
-
1001
- $feed_id = $this->regular_feed_transient_name;
1002
- $shortcode_atts = ! empty( $atts ) ? wp_json_encode( $atts ) : '{}';
1003
-
1004
- $settings['header_outside'] = false;
1005
- $settings['header_inside'] = false;
1006
- if ( $header_data && $settings['showheader'] ) {
1007
- $settings['header_inside'] = true;
1008
- }
1009
-
1010
- $other_atts = '';
1011
-
1012
- $classes = array();
1013
- if ( empty( $settings['widthresp'] ) || $settings['widthresp'] == 'on' || $settings['widthresp'] == 'true' || $settings['widthresp'] === true ) {
1014
- if ( $settings['widthresp'] !== 'false' ) {
1015
- $classes[] = 'sbi_width_resp';
1016
- }
1017
- }
1018
- if ( ! empty( $settings['class'] ) ) {
1019
- $classes[] = esc_attr( $settings['class'] );
1020
- }
1021
- if ( ! empty( $settings['height'] )
1022
- && (((int)$settings['height'] < 100 && $settings['heightunit'] === '%') || $settings['heightunit'] === 'px') ) {
1023
- $classes[] = 'sbi_fixed_height';
1024
- }
1025
- if ( ! empty( $settings['disablemobile'] )
1026
- && ($settings['disablemobile'] == 'on' || $settings['disablemobile'] == 'true' || $settings['disablemobile'] == true) ) {
1027
- if ( $settings['disablemobile'] !== 'false' ) {
1028
- $classes[] = 'sbi_disable_mobile';
1029
- }
1030
- }
1031
-
1032
- $additional_classes = '';
1033
- if ( ! empty( $classes ) ) {
1034
- $additional_classes = ' ' . implode( ' ', $classes );
1035
- }
1036
-
1037
- $other_atts = $this->add_other_atts( $other_atts, $settings );
1038
-
1039
- $flags = array();
1040
-
1041
- if ( $settings['disable_resize'] || $settings['isgutenberg'] ) {
1042
- $flags[] = 'resizeDisable';
1043
- } elseif ( $settings['favor_local'] ) {
1044
- $flags[] = 'favorLocal';
1045
- }
1046
-
1047
- if ( $settings['disable_js_image_loading'] ) {
1048
- $flags[] = 'imageLoadDisable';
1049
- }
1050
- if ( $settings['ajax_post_load'] ) {
1051
- $flags[] = 'ajaxPostLoad';
1052
- }
1053
- if ( isset( $_GET['sbi_debug'] ) ) {
1054
- $flags[] = 'debug';
1055
- }
1056
-
1057
- $ajax_test_status = $sb_instagram_posts_manager->get_ajax_status();
1058
-
1059
- if ( $sb_instagram_posts_manager->maybe_start_ajax_test() && ! $ajax_test_status['successful'] ) {
1060
- $flags[] = 'testAjax';
1061
- }
1062
-
1063
- if ( ! empty( $flags ) ) {
1064
- $other_atts .= ' data-sbi-flags="' . implode(',', $flags ) . '"';
1065
- }
1066
-
1067
- ob_start();
1068
- include sbi_get_feed_template_part( 'feed', $settings );
1069
- $html = ob_get_contents();
1070
- ob_get_clean();
1071
-
1072
- if ( $settings['ajaxtheme'] ) {
1073
- $html .= $this->get_ajax_page_load_html();
1074
- }
1075
-
1076
- return $html;
1077
- }
1078
-
1079
- /**
1080
- * Generates HTML for individual sbi_item elements
1081
- *
1082
- * @param array $settings
1083
- * @param int $offset
1084
- * @param array $feed_types_and_terms organized settings related to feed data
1085
- * (ex. 'user' => array( 'smashballoon', 'custominstagramfeed' )
1086
- * @param array $connected_accounts_for_feed connected account data for the
1087
- * feed types and terms
1088
- *
1089
- * @return false|string
1090
- *
1091
- * @since 2.0/5.0
1092
- */
1093
- public function get_the_items_html( $settings, $offset, $feed_types_and_terms, $connected_accounts_for_feed ) {
1094
- if ( empty( $this->post_data ) ) {
1095
- ob_start();
1096
- $html = ob_get_contents();
1097
- ob_get_clean(); ?>
1098
- <p><?php _e( 'No posts found.', 'instagram-feed' ); ?></p>
1099
- <?php
1100
- $html = ob_get_contents();
1101
- ob_get_clean();
1102
- return $html;
1103
- }
1104
-
1105
- $posts = array_slice( $this->post_data, $offset, $settings['num'] );
1106
-
1107
- ob_start();
1108
-
1109
- $this->posts_loop( $posts, $settings, $offset );
1110
-
1111
- $html = ob_get_contents();
1112
- ob_get_clean();
1113
-
1114
- return $html;
1115
- }
1116
-
1117
- /**
1118
- * Overwritten in the Pro version
1119
- *
1120
- * @return object
1121
- */
1122
- public function make_api_connection( $connected_account_or_page, $type = NULL, $params = NULL ) {
1123
- return new SB_Instagram_API_Connect( $connected_account_or_page, $type, $params );
1124
- }
1125
-
1126
- /**
1127
- * When the feed is loaded with AJAX, the JavaScript for the plugin
1128
- * needs to be triggered again. This function is a workaround that adds
1129
- * the file and settings to the page whenever the feed is generated.
1130
- *
1131
- * @return string
1132
- *
1133
- * @since 2.0/5.0
1134
- */
1135
- public static function get_ajax_page_load_html() {
1136
- if ( SB_Instagram_Blocks::is_gb_editor() ) {
1137
- return '';
1138
- }
1139
- $sbi_options = sbi_get_database_settings();
1140
- $font_method = isset( $sbi_options['sbi_font_method'] ) ? $sbi_options['sbi_font_method'] : 'svg';
1141
- $upload = wp_upload_dir();
1142
- $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBI_UPLOADS_NAME );
1143
-
1144
- $js_options = array(
1145
- 'font_method' => $font_method,
1146
- 'placeholder' => trailingslashit( SBI_PLUGIN_URL ) . 'img/placeholder.png',
1147
- 'resized_url' => $resized_url
1148
- );
1149
-
1150
- $encoded_options = wp_json_encode( $js_options );
1151
-
1152
- $js_option_html = '<script type="text/javascript">var sb_instagram_js_options = ' . $encoded_options . ';</script>';
1153
- $js_option_html .= "<script type='text/javascript' src='" . trailingslashit( SBI_PLUGIN_URL ) . 'js/sb-instagram.min.js?ver=' . SBIVER . "'></script>";
1154
-
1155
- return $js_option_html;
1156
- }
1157
-
1158
- /**
1159
- * Overwritten in the Pro version
1160
- *
1161
- * @param $feed_types_and_terms
1162
- *
1163
- * @return string
1164
- *
1165
- * @since 2.1/5.2
1166
- */
1167
- public function get_first_user( $feed_types_and_terms ) {
1168
- if ( isset( $feed_types_and_terms['users'][0] ) ) {
1169
- return $feed_types_and_terms['users'][0]['term'];
1170
- } else {
1171
- return '';
1172
- }
1173
- }
1174
-
1175
- /**
1176
- * Adds recorded strings to an array
1177
- *
1178
- * @param $to_add
1179
- *
1180
- * @since 2.0/5.0
1181
- */
1182
- public function add_report( $to_add ) {
1183
- $this->report[] = $to_add;
1184
- }
1185
-
1186
- /**
1187
- * @return array
1188
- *
1189
- * @since 2.0/5.0
1190
- */
1191
- public function get_report() {
1192
- return $this->report;
1193
- }
1194
-
1195
- /**
1196
- * Additional options/settings added to the main div
1197
- * for the feed
1198
- *
1199
- * Overwritten in the Pro version
1200
- *
1201
- * @param $other_atts
1202
- * @param $settings
1203
- *
1204
- * @return string
1205
- */
1206
- protected function add_other_atts( $other_atts, $settings ) {
1207
- return '';
1208
- }
1209
-
1210
- /**
1211
- * Used for filtering a single API request worth of posts
1212
- *
1213
- * Overwritten in the Pro version
1214
- *
1215
- * @param array $post_set a single set of post data from the api
1216
- *
1217
- * @return mixed|array
1218
- *
1219
- * @since 2.0/5.0
1220
- */
1221
- protected function filter_posts( $post_set, $settings = array() ) {
1222
- // array_unique( $post_set, SORT_REGULAR);
1223
-
1224
- return $post_set;
1225
- }
1226
-
1227
- protected function handle_no_posts_found( $settings = array(), $feed_types_and_terms = array() ) {
1228
- global $sb_instagram_posts_manager;
1229
-
1230
- $error = '<p><b>' . __( 'Error: No posts found.', 'instagram-feed' ) . '</b>';
1231
- $error .= '<p>' . __( 'Make sure this account has posts available on instagram.com.', 'instagram-feed' ) . '</p>';
1232
- $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
1233
- $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
1234
- if ( current_user_can( $cap ) ) {
1235
- $error .= '<p><a href="https://smashballoon.com/instagram-feed/docs/errors/">' . __( 'Click here to troubleshoot', 'instagram-feed' ) . '</a></p>';
1236
- }
1237
-
1238
- $sb_instagram_posts_manager->add_frontend_error( 'noposts', $error );
1239
- }
1240
-
1241
- protected function remove_duplicate_posts() {
1242
- $posts = $this->post_data;
1243
- $ids_in_feed = array();
1244
- $non_duplicate_posts = array();
1245
- $removed = array();
1246
-
1247
- foreach ( $posts as $post ) {
1248
- $post_id = SB_Instagram_Parse::get_post_id( $post );
1249
- if ( ! in_array( $post_id, $ids_in_feed, true ) ) {
1250
- $ids_in_feed[] = $post_id;
1251
- $non_duplicate_posts[] = $post;
1252
- } else {
1253
- $removed[] = $post_id;
1254
- }
1255
- }
1256
-
1257
- $this->add_report( 'removed duplicates: ' . implode(', ', $removed ) );
1258
- $this->set_post_data( $non_duplicate_posts );
1259
- }
1260
-
1261
- /**
1262
- * Used for limiting the cache size
1263
- *
1264
- * @since 2.0/5.1.1
1265
- */
1266
- protected function trim_posts_to_max() {
1267
- if ( ! is_array( $this->post_data ) ) {
1268
- return;
1269
- }
1270
-
1271
- $max = apply_filters( 'sbi_max_cache_size', 500 );
1272
- $this->set_post_data( array_slice( $this->post_data , 0, $max ) );
1273
-
1274
- }
1275
-
1276
- /**
1277
- * Used for permanent feeds or white list feeds to
1278
- * stop pagination if all posts are already added
1279
- *
1280
- * Overwritten in the Pro version
1281
- *
1282
- * @param array $settings
1283
- * @param int $offset
1284
- *
1285
- * @return bool
1286
- *
1287
- * @since 2.0/5.0
1288
- */
1289
- protected function feed_is_complete( $settings, $offset = 0 ) {
1290
- return false;
1291
- }
1292
-
1293
- /**
1294
- * @param $connected_account_for_term
1295
- *
1296
- * @since 2.0/5.1.2
1297
- */
1298
- private function clear_expired_access_token_notice( $connected_account_for_term ) {
1299
- $sbi_options = get_option( 'sb_instagram_settings' );
1300
- $ca_to_save = isset( $sbi_options['connected_accounts'] ) ? $sbi_options['connected_accounts'] : array();
1301
-
1302
- if ( ! empty( $ca_to_save ) && ! empty( $connected_account_for_term ) ) {
1303
-
1304
- foreach ( $ca_to_save as $account ) {
1305
- if ( $connected_account_for_term['access_token'] === $account['access_token'] ) {
1306
- $ca_to_save[ $account['user_id'] ]['is_valid'] = true;
1307
- }
1308
- }
1309
-
1310
- $sbi_options['connected_accounts'] = $ca_to_save;
1311
-
1312
- update_option( 'sb_instagram_settings', $sbi_options );
1313
- }
1314
- }
1315
-
1316
- /**
1317
- * Iterates through post data and tracks the index of the current post.
1318
- * The actual post ids of the posts are stored in an array so the plugin
1319
- * can search for local images that may be available.
1320
- *
1321
- * @param array $posts final filtered post data for the feed
1322
- * @param array $settings
1323
- * @param int $offset
1324
- *
1325
- * @since 2.0/5.0
1326
- */
1327
- private function posts_loop( $posts, $settings, $offset = 0 ) {
1328
-
1329
- $image_ids = array();
1330
- $post_index = $offset;
1331
- $icon_type = $settings['font_method'];
1332
- $resized_images = $this->get_resized_images();
1333
-
1334
- foreach ( $posts as $post ) {
1335
- $image_ids[] = SB_Instagram_Parse::get_post_id( $post );
1336
- $account_type = SB_Instagram_Parse::get_account_type( $post );
1337
- include sbi_get_feed_template_part( 'item', $settings );
1338
- $post_index++;
1339
- }
1340
-
1341
- $this->image_ids_post_set = $image_ids;
1342
- }
1343
-
1344
- /**
1345
- * Uses array of API request results and merges them based on how
1346
- * the feed should be sorted. Mixed feeds are always sorted alternating
1347
- * since there is no post date for hashtag feeds.
1348
- *
1349
- * @param array $post_sets an array of single API request worth
1350
- * of posts
1351
- * @param array $settings
1352
- *
1353
- * @return array
1354
- *
1355
- * @since 2.0/5.0
1356
- */
1357
- private function merge_posts( $post_sets, $settings ) {
1358
- $merged_posts = array();
1359
- if ( $settings['sortby'] === 'alternate' ) {
1360
- // don't bother merging posts if there is only one post set
1361
- if ( isset( $post_sets[1] ) ) {
1362
- $min_cycles = max( 1, (int)$settings['num'] );
1363
- for( $i = 0; $i <= $min_cycles; $i++ ) {
1364
- foreach ( $post_sets as $post_set ) {
1365
- if ( isset( $post_set[ $i ] ) && isset( $post_set[ $i ]['id'] ) ) {
1366
- $merged_posts[] = $post_set[ $i ];
1367
- }
1368
- }
1369
- }
1370
- } else {
1371
- $merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
1372
- }
1373
- } elseif ( $settings['sortby'] === 'api' ) {
1374
- if ( isset( $post_sets[0] ) ) {
1375
- foreach ( $post_sets as $post_set ) {
1376
- $merged_posts = array_merge( $merged_posts, $post_set );
1377
- }
1378
- }
1379
- } else {
1380
- // don't bother merging posts if there is only one post set
1381
- if ( isset( $post_sets[1] ) ) {
1382
- foreach ( $post_sets as $post_set ) {
1383
- if ( isset( $post_set[0]['id'] ) ) {
1384
- $merged_posts = array_merge( $merged_posts, $post_set );
1385
- }
1386
- }
1387
- } else {
1388
- $merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
1389
- }
1390
- }
1391
-
1392
-
1393
- return $merged_posts;
1394
- }
1395
-
1396
- /**
1397
- * Sorts a post set based on sorting settings. Sorting by "alternate"
1398
- * is done when merging posts for efficiency's sake so the post set is
1399
- * just returned as it is.
1400
- *
1401
- * @param array $post_set
1402
- * @param array $settings
1403
- *
1404
- * @return mixed|array
1405
- *
1406
- * @since 2.0/5.0
1407
- * @since 2.1/5.2 added filter hook for applying custom sorting
1408
- */
1409
- private function sort_posts( $post_set, $settings ) {
1410
- if ( empty( $post_set ) ) {
1411
- return $post_set;
1412
- }
1413
-
1414
- // sorting done with "merge_posts" to be more efficient
1415
- if ( $settings['sortby'] === 'alternate' || $settings['sortby'] === 'api' ) {
1416
- $return_post_set = $post_set;
1417
- } elseif ( $settings['sortby'] === 'random' ) {
1418
- /*
1419
- * randomly selects posts in a random order. Cache saves posts
1420
- * in this random order so paginating does not cause some posts to show up
1421
- * twice or not at all
1422
- */
1423
- usort($post_set, 'sbi_rand_sort' );
1424
- $return_post_set = $post_set;
1425
-
1426
- } else {
1427
- // compares posted on dates of posts
1428
- usort($post_set, 'sbi_date_sort' );
1429
- $return_post_set = $post_set;
1430
- }
1431
-
1432
- /**
1433
- * Apply a custom sorting of posts
1434
- *
1435
- * @param array $return_post_set Ordered set of filtered posts
1436
- * @param array $settings Settings for this feed
1437
- *
1438
- * @since 2.1/5.2
1439
- */
1440
-
1441
- return apply_filters( 'sbi_sorted_posts', $return_post_set, $settings );
1442
- }
1443
-
1444
- /**
1445
- * Can trigger a second attempt at getting posts from the API
1446
- *
1447
- * Overwritten in the Pro version
1448
- *
1449
- * @param string $type
1450
- * @param array $connected_account_with_error
1451
- * @param int $attempts
1452
- *
1453
- * @return bool
1454
- *
1455
- * @since 2.0/5.1.1
1456
- */
1457
- protected function can_try_another_request( $type, $connected_account_with_error, $attempts = 0 ) {
1458
- return false;
1459
- }
1460
-
1461
- /**
1462
- * returns a second connected account if it exists
1463
- *
1464
- * Overwritten in the Pro version
1465
- *
1466
- * @param string $type
1467
- * @param array $attempted_connected_accounts
1468
- *
1469
- * @return bool
1470
- *
1471
- * @since 2.0/5.1.1
1472
- */
1473
- protected function get_different_connected_account( $type, $attempted_connected_accounts ) {
1474
- return false;
1475
- }
1476
-
1477
  }
1
+ <?php
2
+ /**
3
+ * Class SB_Instagram_Feed
4
+ *
5
+ * Retrieves data and generates the html for each feed. The
6
+ * "display_instagram" function in the if-functions.php file
7
+ * is where this class is primarily used.
8
+ *
9
+ * @since 2.0/4.0
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ die( '-1' );
14
+ }
15
+
16
+ class SB_Instagram_Feed
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ private $regular_feed_transient_name;
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ private $header_transient_name;
27
+
28
+ /**
29
+ * @var string
30
+ */
31
+ private $backup_feed_transient_name;
32
+
33
+ /**
34
+ * @var string
35
+ */
36
+ private $backup_header_transient_name;
37
+
38
+ /**
39
+ * @var array
40
+ */
41
+ private $post_data;
42
+
43
+ /**
44
+ * @var
45
+ */
46
+ private $header_data;
47
+
48
+ /**
49
+ * @var array
50
+ */
51
+ private $next_pages;
52
+
53
+ /**
54
+ * @var array
55
+ */
56
+ private $transient_atts;
57
+
58
+ /**
59
+ * @var int
60
+ */
61
+ private $last_retrieve;
62
+
63
+ /**
64
+ * @var bool
65
+ */
66
+ private $should_paginate;
67
+
68
+ /**
69
+ * @var int
70
+ */
71
+ private $num_api_calls;
72
+
73
+ /**
74
+ * @var array
75
+ */
76
+ private $image_ids_post_set;
77
+
78
+ /**
79
+ * @var bool
80
+ */
81
+ private $should_use_backup;
82
+
83
+ /**
84
+ * @var array
85
+ */
86
+ private $report;
87
+
88
+ /**
89
+ * @var array
90
+ *
91
+ * @since 2.1.1/5.2.1
92
+ */
93
+ private $resized_images;
94
+
95
+ /**
96
+ * @var array
97
+ *
98
+ * @since 2.1.3/5.2.3
99
+ */
100
+ protected $one_post_found;
101
+
102
+ /**
103
+ * SB_Instagram_Feed constructor.
104
+ *
105
+ * @param string $transient_name ID of this feed
106
+ * generated in the SB_Instagram_Settings class
107
+ */
108
+ public function __construct( $transient_name ) {
109
+ $this->regular_feed_transient_name = $transient_name;
110
+ $this->backup_feed_transient_name = SBI_BACKUP_PREFIX . $transient_name;
111
+
112
+ $sbi_header_transient_name = str_replace( 'sbi_', 'sbi_header_', $transient_name );
113
+ $sbi_header_transient_name = substr($sbi_header_transient_name, 0, 44);
114
+ $this->header_transient_name = $sbi_header_transient_name;
115
+ $this->backup_header_transient_name = SBI_BACKUP_PREFIX . $sbi_header_transient_name;
116
+
117
+ $this->post_data = array();
118
+ $this->next_pages = array();
119
+ $this->should_paginate = true;
120
+
121
+ // this is a count of how many api calls have been made for each feed
122
+ // type and term.
123
+ // By default the limit is 10
124
+ $this->num_api_calls = 0;
125
+ $this->max_api_calls = apply_filters( 'sbi_max_concurrent_api_calls', 10 );
126
+ $this->should_use_backup = false;
127
+
128
+ // used for errors and the sbi_debug report
129
+ $this->report = array();
130
+
131
+ $this->resized_images = array();
132
+
133
+ $this->one_post_found = false;
134
+ }
135
+
136
+ /**
137
+ * @return array
138
+ *
139
+ * @since 2.0/5.0
140
+ */
141
+ public function get_post_data() {
142
+ return $this->post_data;
143
+ }
144
+
145
+ /**
146
+ * @return array
147
+ *
148
+ * @since 2.0/5.0
149
+ */
150
+ public function set_post_data( $post_data ) {
151
+ $this->post_data = $post_data;
152
+ }
153
+
154
+ /**
155
+ * @return array
156
+ *
157
+ * @since 2.1.1/5.2.1
158
+ */
159
+ public function set_resized_images( $resized_image_data ) {
160
+ $this->resized_images = $resized_image_data;
161
+ }
162
+
163
+ /**
164
+ * @return array
165
+ *
166
+ * @since 2.0/5.0
167
+ */
168
+ public function get_next_pages() {
169
+ return $this->next_pages;
170
+ }
171
+
172
+ /**
173
+ * @return array
174
+ *
175
+ * @since 2.1.1/5.2.1
176
+ */
177
+ public function get_resized_images() {
178
+ return $this->resized_images;
179
+ }
180
+
181
+ /**
182
+ * Checks the database option related the transient expiration
183
+ * to ensure it will be available when the page loads
184
+ *
185
+ * @return bool
186
+ *
187
+ * @since 2.0/4.0
188
+ */
189
+ public function regular_cache_exists() {
190
+ //Check whether the cache transient exists in the database and is available for more than one more minute
191
+ $transient_exists = get_transient( $this->regular_feed_transient_name );
192
+
193
+ return $transient_exists;
194
+ }
195
+
196
+ /**
197
+ * Checks the database option related the header transient
198
+ * expiration to ensure it will be available when the page loads
199
+ *
200
+ * @return bool
201
+ *
202
+ * @since 2.0/5.0
203
+ */
204
+ public function regular_header_cache_exists() {
205
+ $header_transient = get_transient( $this->header_transient_name );
206
+
207
+ return $header_transient;
208
+ }
209
+
210
+ /**
211
+ * @return bool
212
+ *
213
+ * @since 2.0/5.0
214
+ */
215
+ public function should_use_backup() {
216
+ return $this->should_use_backup || empty( $this->post_data );
217
+ }
218
+
219
+ /**
220
+ * The header is only displayed when the setting is enabled and
221
+ * an account has been connected
222
+ *
223
+ * Overwritten in the Pro version
224
+ *
225
+ * @param array $settings settings specific to this feed
226
+ * @param array $feed_types_and_terms organized settings related to feed data
227
+ * (ex. 'user' => array( 'smashballoon', 'custominstagramfeed' )
228
+ *
229
+ * @return bool
230
+ *
231
+ * @since 2.0/5.0
232
+ */
233
+ public function need_header( $settings, $feed_types_and_terms ) {
234
+ $showheader = ($settings['showheader'] === 'on' || $settings['showheader'] === 'true' || $settings['showheader'] === true);
235
+ return ($showheader && isset( $feed_types_and_terms['users'] ));
236
+ }
237
+
238
+ /**
239
+ * Use the transient name to retrieve cached data for header
240
+ *
241
+ * @since 2.0/5.0
242
+ */
243
+ public function set_header_data_from_cache() {
244
+ $header_cache = get_transient( $this->header_transient_name );
245
+
246
+ $header_cache = json_decode( $header_cache, true );
247
+
248
+ if ( ! empty( $header_cache ) ) {
249
+ $this->header_data = $header_cache;
250
+ }
251
+ }
252
+
253
+ public function set_header_data( $header_data ) {
254
+ $this->header_data = $header_data;
255
+ }
256
+
257
+ /**
258
+ * @since 2.0/5.0
259
+ */
260
+ public function get_header_data() {
261
+ return $this->header_data;
262
+ }
263
+
264
+ /**
265
+ * Sets the post data, pagination data, shortcode atts used (cron cache),
266
+ * and timestamp of last retrieval from transient (cron cache)
267
+ *
268
+ * @param array $atts available for cron caching
269
+ *
270
+ * @since 2.0/5.0
271
+ */
272
+ public function set_post_data_from_cache( $atts = array() ) {
273
+ $transient_data = get_transient( $this->regular_feed_transient_name );
274
+
275
+ $transient_data = json_decode( $transient_data, true );
276
+
277
+ if ( $transient_data ) {
278
+ $post_data = isset( $transient_data['data'] ) ? $transient_data['data'] : array();
279
+ $this->post_data = $post_data;
280
+ $this->next_pages = isset( $transient_data['pagination'] ) ? $transient_data['pagination'] : array();
281
+
282
+ if ( isset( $transient_data['atts'] ) ) {
283
+ $this->transient_atts = $transient_data['atts'];
284
+ $this->last_retrieve = $transient_data['last_retrieve'];
285
+ }
286
+ }
287
+ }
288
+
289
+ /**
290
+ * Sets post data from a permanent database backup of feed
291
+ * if it was created
292
+ *
293
+ * @since 2.0/5.0
294
+ * @since 2.0/5.1.2 if backup feed data used, header data also set from backup
295
+ */
296
+ public function maybe_set_post_data_from_backup() {
297
+ $backup_data = get_option( $this->backup_feed_transient_name, false );
298
+
299
+ if ( $backup_data ) {
300
+ $backup_data = json_decode( $backup_data, true );
301
+
302
+ $post_data = isset( $backup_data['data'] ) ? $backup_data['data'] : array();
303
+ $this->post_data = $post_data;
304
+ $this->next_pages = isset( $backup_data['pagination'] ) ? $backup_data['pagination'] : array();
305
+
306
+ if ( isset( $backup_data['atts'] ) ) {
307
+ $this->transient_atts = $backup_data['atts'];
308
+ $this->last_retrieve = $backup_data['last_retrieve'];
309
+ }
310
+
311
+ $this->maybe_set_header_data_from_backup();
312
+
313
+ return true;
314
+ } else {
315
+ $this->add_report( 'no backup post data found' );
316
+
317
+ return false;
318
+ }
319
+ }
320
+
321
+ /**
322
+ * Sets header data from a permanent database backup of feed
323
+ * if it was created
324
+ *
325
+ * @since 2.0/5.0
326
+ */
327
+ public function maybe_set_header_data_from_backup() {
328
+ $backup_header_data = get_option( $this->backup_header_transient_name, false );
329
+
330
+ if ( ! empty( $backup_header_data ) ) {
331
+ $backup_header_data = json_decode( $backup_header_data, true );
332
+ $this->header_data = $backup_header_data;
333
+
334
+ return true;
335
+ } else {
336
+ $this->add_report( 'no backup header data found' );
337
+
338
+ return false;
339
+ }
340
+ }
341
+
342
+ /**
343
+ * Returns recorded image IDs for this post set
344
+ * for use with image resizing
345
+ *
346
+ * @return array
347
+ *
348
+ * @since 2.0/5.0
349
+ */
350
+ public function get_image_ids_post_set() {
351
+ return $this->image_ids_post_set;
352
+ }
353
+
354
+ /**
355
+ * Retrieves data related to resized images from custom
356
+ * tables using either a number, offset, and transient name
357
+ * or the ids of the posts.
358
+ *
359
+ * Retrieving by offset and transient name not used currently
360
+ * but may be needed in future updates.
361
+ *
362
+ * @param array/int $num_or_array_of_ids post ids from the Instagram
363
+ * API
364
+ * @param int $offset number of records to skip
365
+ * @param string $transient_name ID of the feed
366
+ *
367
+ * @return array
368
+ *
369
+ * @since 2.0/5.0
370
+ */
371
+ public static function get_resized_images_source_set( $num_or_array_of_ids, $offset = 0, $transient_name = '' ) {
372
+ global $sb_instagram_posts_manager;
373
+
374
+ if ( $sb_instagram_posts_manager->image_resizing_disabled() ) {
375
+ return array();
376
+ }
377
+
378
+ global $wpdb;
379
+
380
+ $posts_table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
381
+ $feeds_posts_table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
382
+
383
+ $feed_id_array = explode( '#', $transient_name );
384
+ $feed_id = $feed_id_array[0];
385
+
386
+ if ( is_array( $num_or_array_of_ids ) ) {
387
+ $ids = $num_or_array_of_ids;
388
+
389
+ $id_string = "'" . implode( "','", $ids ) . "'";
390
+ $results = $wpdb->get_results( $wpdb->prepare( "
391
+ SELECT p.media_id, p.instagram_id, p.aspect_ratio, p.sizes
392
+ FROM $posts_table_name AS p
393
+ INNER JOIN $feeds_posts_table_name AS f ON p.id = f.id
394
+ WHERE f.feed_id = %s
395
+ AND p.instagram_id IN($id_string)
396
+ AND p.images_done = 1", $feed_id ), ARRAY_A );
397
+
398
+ $return = array();
399
+ if ( !empty( $results ) && is_array( $results ) ) {
400
+
401
+ foreach ( $results as $result ) {
402
+ $sizes = maybe_unserialize( $result['sizes'] );
403
+ if ( ! is_array( $sizes ) ) {
404
+ $sizes = array( 'full' => 640 );
405
+ }
406
+ $return[ $result['instagram_id'] ] = array(
407
+ 'id' => $result['media_id'],
408
+ 'ratio' => $result['aspect_ratio'],
409
+ 'sizes' => $sizes
410
+ );
411
+ }
412
+
413
+ }
414
+ } else {
415
+ $num = $num_or_array_of_ids;
416
+
417
+ $results = $wpdb->get_results( $wpdb->prepare( "
418
+ SELECT p.media_id, p.instagram_id, p.aspect_ratio, p.sizes
419
+ FROM $posts_table_name AS p
420
+ INNER JOIN $feeds_posts_table_name AS f ON p.id = f.id
421
+ WHERE f.feed_id = %s
422
+ AND p.images_done = 1
423
+ ORDER BY p.time_stamp
424
+ DESC LIMIT %d, %d", $feed_id, $offset, (int)$num ), ARRAY_A );
425
+
426
+ $return = array();
427
+ if ( !empty( $results ) && is_array( $results ) ) {
428
+
429
+ foreach ( $results as $result ) {
430
+ $sizes = maybe_unserialize( $result['sizes'] );
431
+ if ( ! is_array( $sizes ) ) {
432
+ $sizes = array( 'full' => 640 );
433
+ }
434
+ $return[ $result['instagram_id'] ] = array(
435
+ 'id' => $result['media_id'],
436
+ 'ratio' => $result['aspect_ratio'],
437
+ 'sizes' => $sizes
438
+ );
439
+ }
440
+
441
+ }
442
+ }
443
+
444
+
445
+ return $return;
446
+ }
447
+
448
+ /**
449
+ * The plugin tracks when a post was last requested so only the most
450
+ * recently displayed posts are kept in the database.
451
+ * This function updates the timestamp for a set of posts
452
+ * on the page.
453
+ *
454
+ * @param $array_of_ids
455
+ *
456
+ * @since 2.0/5.0
457
+ */
458
+ public static function update_last_requested( $array_of_ids ) {
459
+ if ( empty( $array_of_ids ) ) {
460
+ return;
461
+ }
462
+
463
+ global $wpdb;
464
+ $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
465
+ $id_string = "'" . implode( "','", $array_of_ids ) . "'";
466
+
467
+ $query = $wpdb->query( $wpdb->prepare( "UPDATE $table_name
468
+ SET last_requested = %s
469
+ WHERE instagram_id IN ({$id_string});", date( 'Y-m-d H:i:s' ) ) );
470
+ }
471
+
472
+ /**
473
+ * Cron caching needs additional data saved in the transient
474
+ * to work properly. This function checks to make sure it's present
475
+ *
476
+ * @return bool
477
+ *
478
+ * @since 2.0/5.0
479
+ */
480
+ public function need_to_start_cron_job() {
481
+ return (( ! empty( $this->post_data ) && ! isset( $this->transient_atts )) || empty( $this->post_data ));
482
+ }
483
+
484
+ /**
485
+ * Checks to see if there are enough posts available to create
486
+ * the current page of the feed
487
+ *
488
+ * @param int $num
489
+ * @param int $offset
490
+ *
491
+ * @return bool
492
+ *
493
+ * @since 2.0/5.0
494
+ */
495
+ public function need_posts( $num, $offset = 0 ) {
496
+ $num_existing_posts = is_array( $this->post_data ) ? count( $this->post_data ) : 0;
497
+ $num_needed_for_page = (int)$num + (int)$offset;
498
+
499
+ ($num_existing_posts < $num_needed_for_page) ? $this->add_report( 'need more posts' ) : $this->add_report( 'have enough posts' );
500
+
501
+ return ($num_existing_posts < $num_needed_for_page);
502
+ }
503
+
504
+ /**
505
+ * Checks to see if there are additional pages available for any of the
506
+ * accounts in the feed and that the max conccurrent api request limit
507
+ * has not been reached
508
+ *
509
+ * @return bool
510
+ *
511
+ * @since 2.0/5.0
512
+ */
513
+ public function can_get_more_posts() {
514
+ $one_type_and_term_has_more_ages = $this->next_pages !== false;
515
+ $max_concurrent_api_calls_not_met = $this->num_api_calls < $this->max_api_calls;
516
+ $max_concurrent_api_calls_not_met ? $this->add_report( 'max conccurrent requests not met' ) : $this->add_report( 'max concurrent met' );
517
+ $one_type_and_term_has_more_ages ? $this->add_report( 'more pages available' ) : $this->add_report( 'no next page' );
518
+
519
+ return ($one_type_and_term_has_more_ages && $max_concurrent_api_calls_not_met);
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', 'custominstagramfeed' )
528
+ * @param array $connected_accounts_for_feed connected account data for the
529
+ * feed types and terms
530
+ *
531
+ * @since 2.0/5.0
532
+ * @since 2.0/5.1 added logic to make a second attempt at an API connection
533
+ * @since 2.0/5.1.2 remote posts only retrieved if API requests are not
534
+ * delayed, terms shuffled if there are more than 5
535
+ * @since 2.2/5.3 added logic to refresh the access token for basic display
536
+ * accounts if needed before using it in an API request
537
+ */
538
+ public function add_remote_posts( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
539
+ $new_post_sets = array();
540
+ $next_pages = $this->next_pages;
541
+ global $sb_instagram_posts_manager;
542
+
543
+ /**
544
+ * Number of posts to retrieve in each API call
545
+ *
546
+ * @param int Minimum number of posts needed in each API request
547
+ * @param array $settings Settings for this feed
548
+ *
549
+ * @since 2.0/5.0
550
+ */
551
+ $num = apply_filters( 'sbi_num_in_request', $settings['minnum'], $settings );
552
+ $num = max( $num, (int)$settings['apinum'] );
553
+ $params = array(
554
+ 'num' => $num
555
+ );
556
+
557
+ $one_successful_connection = false;
558
+ $one_post_found = false;
559
+ $next_page_found = false;
560
+ $one_api_request_delayed = false;
561
+
562
+ foreach ( $feed_types_and_terms as $type => $terms ) {
563
+ if ( is_array( $terms ) && count( $terms ) > 5 ) {
564
+ shuffle( $terms );
565
+ }
566
+ foreach ( $terms as $term_and_params ) {
567
+ $term = $term_and_params['term'];
568
+ $params = array_merge( $params, $term_and_params['params'] );
569
+ $connected_account_for_term = $connected_accounts_for_feed[ $term ];
570
+
571
+ $api_requests_delayed = $sb_instagram_posts_manager->are_current_api_request_delays( $connected_account_for_term['user_id'] );
572
+
573
+ if ( ! $api_requests_delayed
574
+ && (! isset( $next_pages[ $term . '_' . $type ] ) || $next_pages[ $term . '_' . $type ] !== false) ) {
575
+
576
+ $account_type = isset( $connected_account_for_term['type'] ) ? $connected_account_for_term['type'] : 'personal';
577
+ $skip_connection = false;
578
+
579
+ // basic account access tokens need to be refreshed every 60 days
580
+ // normally done using WP Cron but can be done here as a fail safe
581
+ if ( $account_type === 'basic' ) {
582
+ if ( SB_Instagram_Token_Refresher::refresh_time_has_passed_threshold( $connected_account_for_term )
583
+ && SB_Instagram_Token_Refresher::minimum_time_interval_since_last_attempt_has_passed( $connected_account_for_term ) ) {
584
+ $refresher = new SB_Instagram_Token_Refresher( $connected_account_for_term );
585
+ $refresher->attempt_token_refresh();
586
+ $this->add_report( 'trying to refresh token ' . $term . '_' . $type );
587
+ }
588
+ } elseif( $account_type === 'personal' && sbi_is_after_deprecation_deadline() ) {
589
+ $skip_connection = true;
590
+ }
591
+
592
+ if ( ! empty( $next_pages[ $term . '_' . $type ] ) ) {
593
+ $next_page_term = $next_pages[ $term . '_' . $type ];
594
+ if ( strpos( $next_page_term, 'https://' ) !== false ) {
595
+ $connection = $this->make_api_connection( $next_page_term );
596
+ } else {
597
+ $params['cursor'] = $next_page_term;
598
+ $connection = $this->make_api_connection( $connected_account_for_term, $type, $params );
599
+ }
600
+ } else {
601
+ $connection = $this->make_api_connection( $connected_account_for_term, $type, $params );
602
+ }
603
+ $this->add_report( 'api call made for ' . $term . ' - ' . $type );
604
+
605
+ if ( ! $skip_connection ) {
606
+ $connection->connect();
607
+ }
608
+ $this->num_api_calls++;
609
+
610
+ if ( ! $skip_connection && ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
611
+ $one_successful_connection = true;
612
+
613
+ $sb_instagram_posts_manager->remove_error( 'connection' );
614
+ $sb_instagram_posts_manager->remove_error( 'api' );
615
+ $sb_instagram_posts_manager->remove_error( 'at_' . $term );
616
+
617
+ $data = $connection->get_data();
618
+
619
+ if ( !$connected_account_for_term['is_valid'] ) {
620
+ $this->add_report( 'clearing invalid token' );
621
+ $this->clear_expired_access_token_notice( $connected_account_for_term );
622
+ }
623
+
624
+ if ( isset( $data[0]['id'] ) ) {
625
+ $one_post_found = true;
626
+
627
+ $post_set = $this->filter_posts( $data, $settings );
628
+
629
+ $new_post_sets[] = $post_set;
630
+ }
631
+
632
+ $next_page = $connection->get_next_page( $type );
633
+ if ( ! empty( $next_page ) ) {
634
+ $next_pages[ $term . '_' . $type ] = $next_page;
635
+ $next_page_found = true;
636
+ } else {
637
+ $next_pages[ $term . '_' . $type ] = false;
638
+ }
639
+ } else {
640
+
641
+ if ( $this->can_try_another_request( $type, $connected_accounts_for_feed[ $term ] ) ) {
642
+ $this->add_report( 'trying other accounts' );
643
+ $i = 0;
644
+ $attempted = array( $connected_accounts_for_feed[ $term ]['user_id'] );
645
+ $success = false;
646
+ $different = true;
647
+ $error = false;
648
+
649
+ while ( $different
650
+ && ! $success
651
+ && $this->can_try_another_request( $type, $connected_accounts_for_feed[ $term ], $i ) ) {
652
+ $different = $this->get_different_connected_account( $type, $attempted );
653
+ $this->add_report( 'trying the account ' . $different['user_id'] );
654
+
655
+ if ( $different ) {
656
+ $connected_accounts_for_feed[ $term ] = $this->get_different_connected_account( $type, $attempted );
657
+ $attempted[] = $connected_accounts_for_feed[ $term ]['user_id'];
658
+ if ( ! empty( $next_pages[ $term . '_' . $type ] ) ) {
659
+ $connection = $this->make_api_connection( $next_pages[ $term . '_' . $type ] );
660
+ } else {
661
+ $connection = $this->make_api_connection( $connected_accounts_for_feed[ $term ], $type, $params );
662
+ }
663
+ $connection->connect();
664
+ $this->num_api_calls++;
665
+ if ( ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
666
+ $one_successful_connection = true;
667
+
668
+ $sb_instagram_posts_manager->remove_error( 'connection' );
669
+ $sb_instagram_posts_manager->remove_error( 'api' );
670
+ $sb_instagram_posts_manager->remove_error( 'at_' . $term );
671
+
672
+ $data = $connection->get_data();
673
+ if ( isset( $data[0]['id'] ) ) {
674
+ $one_post_found = true;
675
+ $post_set = $this->filter_posts( $data, $settings );
676
+ $new_post_sets[] = $post_set;
677
+ }
678
+ $next_page = $connection->get_next_page( $type );
679
+ if ( ! empty( $next_page ) ) {
680
+ $next_pages[ $term . '_' . $type ] = $next_page;
681
+ $next_page_found = true;
682
+ } else {
683
+ $next_pages[ $term . '_' . $type ] = false;
684
+ }
685
+ } else {
686
+ if ( $connection->is_wp_error() ) {
687
+ $error = $connection->get_wp_error();
688
+ } else {
689
+ $error = $connection->get_data();
690
+ }
691
+ }
692
+ $i++;
693
+ }
694
+ }
695
+
696
+ if ( ! $success && $error ) {
697
+ if ( $connection->is_wp_error() ) {
698
+ SB_Instagram_API_Connect::handle_wp_remote_get_error( $error );
699
+ } else {
700
+ SB_Instagram_API_Connect::handle_instagram_error( $error, $connected_accounts_for_feed[ $term ], $type );
701
+ }
702
+ $next_pages[ $term . '_' . $type ] = false;
703
+ $show_error_message = true;
704
+
705
+ }
706
+ } else {
707
+ if ( $skip_connection ) {
708
+
709
+ } elseif ( $connection->is_wp_error() ) {
710
+ SB_Instagram_API_Connect::handle_wp_remote_get_error( $connection->get_wp_error() );
711
+ } else {
712
+ SB_Instagram_API_Connect::handle_instagram_error( $connection->get_data(), $connected_accounts_for_feed[ $term ], $type );
713
+ }
714
+ $show_error_message = true;
715
+
716
+ $next_pages[ $term . '_' . $type ] = false;
717
+ }
718
+ }
719
+ } elseif ( $api_requests_delayed ) {
720
+ $one_api_request_delayed = true;
721
+
722
+ $this->add_report( 'delaying API request for ' . $term . ' - ' . $type );
723
+ $show_error_message = true;
724
+ }
725
+
726
+ if ( isset( $show_error_message ) ) {
727
+ $error = '';
728
+ if ( $sb_instagram_posts_manager->are_critical_errors() ) {
729
+ $error .= $sb_instagram_posts_manager->get_critical_errors();
730
+ } else {
731
+ $errors = $sb_instagram_posts_manager->get_frontend_errors();
732
+ $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
733
+ $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
734
+ if ( current_user_can( $cap ) ) {
735
+ foreach ( $errors as $error_message ) {
736
+ $error .= $error_message;
737
+ }
738
+ $error .= '<p class="sbi-error-directions"><a href="https://smashballoon.com/instagram-feed/docs/errors/" target="_blank" rel="noopener">' . __( 'Directions on how to resolve this issue.', 'instagram-feed' ) . '</a></p>';
739
+ } else {
740
+ $error = '<p><b>' . sprintf( __( 'Error: API requests are being delayed for this account.', 'instagram-feed' ), $connected_account_for_term['username'] ) . ' ' . __( 'New posts will not be retrieved.', 'instagram-feed' ) . '</b></p>';
741
+ $error .= '<p>' . __( 'Log in as an administrator and view the Instagram Feed settings page for more details.', 'instagram-feed' ) . '</p>';
742
+ }
743
+ }
744
+
745
+ $sb_instagram_posts_manager->add_frontend_error( 'at_' . $connected_account_for_term['username'], $error );
746
+ }
747
+
748
+ }
749
+ }
750
+
751
+ if ( ! $one_successful_connection || ($one_api_request_delayed && empty( $new_post_sets )) ) {
752
+ $this->should_use_backup = true;
753
+ }
754
+ $posts = $this->merge_posts( $new_post_sets, $settings );
755
+
756
+ $posts = $this->sort_posts( $posts, $settings );
757
+
758
+ if ( ! empty( $this->post_data ) && is_array( $this->post_data ) ) {
759
+ $posts = array_merge( $this->post_data, $posts );
760
+ } elseif ( $one_post_found ) {
761
+ $this->one_post_found = true;
762
+ }
763
+
764
+ $this->post_data = $posts;
765
+
766
+ if ( isset( $next_page_found ) && $next_page_found ) {
767
+ $this->next_pages = $next_pages;
768
+ } else {
769
+ $this->next_pages = false;
770
+ }
771
+ }
772
+
773
+ /**
774
+ * Connects to the Instagram API and records returned data
775
+ *
776
+ * @param $settings
777
+ * @param array $feed_types_and_terms organized settings related to feed data
778
+ * (ex. 'user' => array( 'smashballoon', 'custominstagramfeed' )
779
+ * @param array $connected_accounts_for_feed connected account data for the
780
+ * feed types and terms
781
+ *
782
+ * @since 2.0/5.0
783
+ * @since 2.2/5.3 added logic to append bio data from the related
784
+ * connected account if not available in the API response
785
+ */
786
+ public function set_remote_header_data( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
787
+ $first_user = $this->get_first_user( $feed_types_and_terms );
788
+ $this->header_data = false;
789
+ global $sb_instagram_posts_manager;
790
+
791
+ $api_requests_delayed = isset( $connected_accounts_for_feed[ $first_user ]['user_id'] ) ? $sb_instagram_posts_manager->are_current_api_request_delays( $connected_accounts_for_feed[ $first_user ]['user_id'] ) : $sb_instagram_posts_manager->are_current_api_request_delays();
792
+
793
+ if ( isset( $connected_accounts_for_feed[ $first_user ] ) && ! $api_requests_delayed ) {
794
+ $connection = new SB_Instagram_API_Connect( $connected_accounts_for_feed[ $first_user ], 'header', array() );
795
+
796
+ $connection->connect();
797
+
798
+ if ( ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
799
+ $this->header_data = $connection->get_data();
800
+
801
+ $sb_instagram_posts_manager->remove_error( 'connection' );
802
+ $sb_instagram_posts_manager->remove_error( 'api' );
803
+ $sb_instagram_posts_manager->remove_error( 'at_' . $first_user );
804
+
805
+ if ( isset( $connected_accounts_for_feed[ $first_user ]['local_avatar'] ) && $connected_accounts_for_feed[ $first_user ]['local_avatar'] ) {
806
+ $upload = wp_upload_dir();
807
+ $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBI_UPLOADS_NAME );
808
+
809
+ $full_file_name = $resized_url . $this->header_data['username'] . '.jpg';
810
+ $this->header_data['local_avatar'] = $full_file_name;
811
+ }
812
+ if ( empty( $this->header_data['bio'] )
813
+ && isset( $connected_accounts_for_feed[ $first_user ]['bio'] ) ) {
814
+
815
+ $this->header_data['bio'] = sbi_decode_emoji( $connected_accounts_for_feed[ $first_user ]['bio'] );
816
+ }
817
+ } else {
818
+ if ( $connection->is_wp_error() ) {
819
+ SB_Instagram_API_Connect::handle_wp_remote_get_error( $connection->get_wp_error() );
820
+ } else {
821
+ SB_Instagram_API_Connect::handle_instagram_error( $connection->get_data(), $connected_accounts_for_feed[ $first_user ], 'header' );
822
+ }
823
+ }
824
+ }
825
+ }
826
+
827
+ /**
828
+ * Stores feed data in a transient for a specified time
829
+ *
830
+ * @param int $cache_time
831
+ * @param bool $save_backup
832
+ *
833
+ * @since 2.0/5.0
834
+ * @since 2.0/5.1 duplicate posts removed
835
+ */
836
+ public function cache_feed_data( $cache_time, $save_backup = true ) {
837
+ if ( ! empty( $this->post_data ) || ! empty( $this->next_pages ) ) {
838
+ $this->remove_duplicate_posts();
839
+ $this->trim_posts_to_max();
840
+
841
+ $to_cache = array(
842
+ 'data' => $this->post_data,
843
+ 'pagination' => $this->next_pages
844
+ );
845
+
846
+ set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
847
+
848
+ if ( $save_backup ) {
849
+ update_option( $this->backup_feed_transient_name, wp_json_encode( $to_cache ), false );
850
+ }
851
+ } else {
852
+ $this->add_report( 'no data not caching' );
853
+ }
854
+ }
855
+
856
+ /**
857
+ * Stores feed data with additional data specifically for cron caching
858
+ *
859
+ * @param array $to_cache feed data with additional things like the shortcode
860
+ * settings, when the cache was last requested, when new posts were last retrieved
861
+ * @param int $cache_time how long the cache will last
862
+ * @param bool $save_backup whether or not to also save this as a permanent cache
863
+ *
864
+ * @since 2.0/5.0
865
+ * @since 2.0/5.1 duplicate posts removed, cache set trimmed to a maximum
866
+ */
867
+ public function set_cron_cache( $to_cache, $cache_time, $save_backup = true ) {
868
+ if ( ! empty( $this->post_data )
869
+ || ! empty( $this->next_pages )
870
+ || ! empty( $to_cache['data'] ) ) {
871
+ $this->remove_duplicate_posts();
872
+ $this->trim_posts_to_max();
873
+
874
+ $to_cache['data'] = isset( $to_cache['data'] ) ? $to_cache['data'] : $this->post_data;
875
+ $to_cache['pagination'] = isset( $to_cache['next_pages'] ) ? $to_cache['next_pages'] : $this->next_pages;
876
+ $to_cache['atts'] = isset( $to_cache['atts'] ) ? $to_cache['atts'] : $this->transient_atts;
877
+ $to_cache['last_requested'] = isset( $to_cache['last_requested'] ) ? $to_cache['last_requested'] : time();
878
+ $to_cache['last_retrieve'] = isset( $to_cache['last_retrieve'] ) ? $to_cache['last_retrieve'] : $this->last_retrieve;
879
+
880
+ set_transient( $this->regular_feed_transient_name, wp_json_encode( $to_cache ), $cache_time );
881
+
882
+ if ( $save_backup ) {
883
+ update_option( $this->backup_feed_transient_name, wp_json_encode( $to_cache ), false );
884
+ }
885
+ } else {
886
+ $this->add_report( 'no data not caching' );
887
+ }
888
+
889
+ }
890
+
891
+ /**
892
+ * Stores header data for a specified time as a transient
893
+ *
894
+ * @param int $cache_time
895
+ * @param bool $save_backup
896
+ *
897
+ * @since 2.0/5.0
898
+ */
899
+ public function cache_header_data( $cache_time, $save_backup = true ) {
900
+ if ( $this->header_data ) {
901
+ set_transient( $this->header_transient_name, wp_json_encode( $this->header_data ), $cache_time );
902
+
903
+ if ( $save_backup ) {
904
+ update_option( $this->backup_header_transient_name, wp_json_encode( $this->header_data ), false );
905
+ }
906
+ }
907
+ }
908
+
909
+ /**
910
+ * Used to randomly trigger an updating of the last requested data for cron caching
911
+ *
912
+ * @return bool
913
+ *
914
+ * @since 2.0/5.0
915
+ */
916
+ public function should_update_last_requested() {
917
+ return (rand( 1, 20 ) === 20);
918
+ }
919
+
920
+ /**
921
+ * Determines if pagination can and should be used based on settings and available feed data
922
+ *
923
+ * @param array $settings
924
+ * @param int $offset
925
+ *
926
+ * @return bool
927
+ *
928
+ * @since 2.0/5.0
929
+ */
930
+ public function should_use_pagination( $settings, $offset = 0 ) {
931
+ if ( $settings['minnum'] < 1 ) {
932
+ return false;
933
+ }
934
+ $posts_available = count( $this->post_data ) - ($offset + $settings['num']);
935
+ $show_loadmore_button_by_settings = ($settings['showbutton'] == 'on' || $settings['showbutton'] == 'true' || $settings['showbutton'] == true ) && $settings['showbutton'] !== 'false';
936
+
937
+ if ( $show_loadmore_button_by_settings ) {
938
+ // used for permanent and whitelist feeds
939
+ if ( $this->feed_is_complete( $settings, $offset ) ) {
940
+ $this->add_report( 'no pagination, feed complete' );
941
+ return false;
942
+ }
943
+ if ( $posts_available > 0 ) {
944
+ $this->add_report( 'do pagination, posts available' );
945
+ return true;
946
+ }
947
+ $pages = $this->next_pages;
948
+
949
+ if ( $pages && ! $this->should_use_backup() ) {
950
+ foreach ( $pages as $page ) {
951
+ if ( ! empty( $page ) ) {
952
+ return true;
953
+ }
954
+ }
955
+ }
956
+
957
+ }
958
+
959
+
960
+ $this->add_report( 'no pagination, no posts available' );
961
+
962
+ return false;
963
+ }
964
+
965
+ /**
966
+ * Generates the HTML for the feed if post data is available. Although it seems
967
+ * some of the variables ar not used they are set here to hide where they
968
+ * come from when used in the feed templates.
969
+ *
970
+ * @param array $settings
971
+ * @param array $atts
972
+ * @param array $feed_types_and_terms organized settings related to feed data
973
+ * (ex. 'user' => array( 'smashballoon', 'custominstagramfeed' )
974
+ * @param array $connected_accounts_for_feed connected account data for the
975
+ * feed types and terms
976
+ *
977
+ * @return false|string
978
+ *
979
+ * @since 2.0/5.0
980
+ */
981
+ public function get_the_feed_html( $settings, $atts, $feed_types_and_terms, $connected_accounts_for_feed ) {
982
+ global $sb_instagram_posts_manager;
983
+
984
+ if ( empty( $this->post_data ) && ! empty( $connected_accounts_for_feed ) && $settings['minnum'] > 0 ) {
985
+ $this->handle_no_posts_found( $settings, $feed_types_and_terms );
986
+ }
987
+ $posts = array_slice( $this->post_data, 0, $settings['minnum'] );
988
+ $header_data = ! empty( $this->header_data ) ? $this->header_data : false;
989
+
990
+ $first_user = ! empty( $feed_types_and_terms['users'][0] ) ? $feed_types_and_terms['users'][0]['term'] : false;
991
+ $first_username = false;
992
+ if ( $first_user ) {
993
+ $first_username = isset( $connected_accounts_for_feed[ $first_user ]['username'] ) ? $connected_accounts_for_feed[ $first_user ]['username'] : $first_user;
994
+ } elseif ( $header_data ) { // in case no connected account for feed
995
+ $first_username = SB_Instagram_Parse::get_username( $header_data );
996
+ } elseif ( isset( $feed_types_and_terms['users'] ) && isset( $this->post_data[0] ) ) { // in case no connected account and no header
997
+ $first_username = SB_Instagram_Parse::get_username( $this->post_data[0] );
998
+ }
999
+ $use_pagination = $this->should_use_pagination( $settings, 0 );
1000
+
1001
+ $feed_id = $this->regular_feed_transient_name;
1002
+ $shortcode_atts = ! empty( $atts ) ? wp_json_encode( $atts ) : '{}';
1003
+
1004
+ $settings['header_outside'] = false;
1005
+ $settings['header_inside'] = false;
1006
+ if ( $header_data && $settings['showheader'] ) {
1007
+ $settings['header_inside'] = true;
1008
+ }
1009
+
1010
+ $other_atts = '';
1011
+
1012
+ $classes = array();
1013
+ if ( empty( $settings['widthresp'] ) || $settings['widthresp'] == 'on' || $settings['widthresp'] == 'true' || $settings['widthresp'] === true ) {
1014
+ if ( $settings['widthresp'] !== 'false' ) {
1015
+ $classes[] = 'sbi_width_resp';
1016
+ }
1017
+ }
1018
+ if ( ! empty( $settings['class'] ) ) {
1019
+ $classes[] = esc_attr( $settings['class'] );
1020
+ }
1021
+ if ( ! empty( $settings['height'] )
1022
+ && (((int)$settings['height'] < 100 && $settings['heightunit'] === '%') || $settings['heightunit'] === 'px') ) {
1023
+ $classes[] = 'sbi_fixed_height';
1024
+ }
1025
+ if ( ! empty( $settings['disablemobile'] )
1026
+ && ($settings['disablemobile'] == 'on' || $settings['disablemobile'] == 'true' || $settings['disablemobile'] == true) ) {
1027
+ if ( $settings['disablemobile'] !== 'false' ) {
1028
+ $classes[] = 'sbi_disable_mobile';
1029
+ }
1030
+ }
1031
+
1032
+ $additional_classes = '';
1033
+ if ( ! empty( $classes ) ) {
1034
+ $additional_classes = ' ' . implode( ' ', $classes );
1035
+ }
1036
+
1037
+ $other_atts = $this->add_other_atts( $other_atts, $settings );
1038
+
1039
+ $flags = array();
1040
+
1041
+ if ( $settings['disable_resize'] || $settings['isgutenberg'] ) {
1042
+ $flags[] = 'resizeDisable';
1043
+ } elseif ( $settings['favor_local'] ) {
1044
+ $flags[] = 'favorLocal';
1045
+ }
1046
+
1047
+ if ( $settings['disable_js_image_loading'] ) {
1048
+ $flags[] = 'imageLoadDisable';
1049
+ }
1050
+ if ( $settings['ajax_post_load'] ) {
1051
+ $flags[] = 'ajaxPostLoad';
1052
+ }
1053
+ if ( isset( $_GET['sbi_debug'] ) ) {
1054
+ $flags[] = 'debug';
1055
+ }
1056
+
1057
+ $ajax_test_status = $sb_instagram_posts_manager->get_ajax_status();
1058
+
1059
+ if ( $sb_instagram_posts_manager->maybe_start_ajax_test() && ! $ajax_test_status['successful'] ) {
1060
+ $flags[] = 'testAjax';
1061
+ }
1062
+
1063
+ if ( ! empty( $flags ) ) {
1064
+ $other_atts .= ' data-sbi-flags="' . implode(',', $flags ) . '"';
1065
+ }
1066
+
1067
+ ob_start();
1068
+ include sbi_get_feed_template_part( 'feed', $settings );
1069
+ $html = ob_get_contents();
1070
+ ob_get_clean();
1071
+
1072
+ if ( $settings['ajaxtheme'] ) {
1073
+ $html .= $this->get_ajax_page_load_html();
1074
+ }
1075
+
1076
+ return $html;
1077
+ }
1078
+
1079
+ /**
1080
+ * Generates HTML for individual sbi_item elements
1081
+ *
1082
+ * @param array $settings
1083
+ * @param int $offset
1084
+ * @param array $feed_types_and_terms organized settings related to feed data
1085
+ * (ex. 'user' => array( 'smashballoon', 'custominstagramfeed' )
1086
+ * @param array $connected_accounts_for_feed connected account data for the
1087
+ * feed types and terms
1088
+ *
1089
+ * @return false|string
1090
+ *
1091
+ * @since 2.0/5.0
1092
+ */
1093
+ public function get_the_items_html( $settings, $offset, $feed_types_and_terms, $connected_accounts_for_feed ) {
1094
+ if ( empty( $this->post_data ) ) {
1095
+ ob_start();
1096
+ $html = ob_get_contents();
1097
+ ob_get_clean(); ?>
1098
+ <p><?php _e( 'No posts found.', 'instagram-feed' ); ?></p>
1099
+ <?php
1100
+ $html = ob_get_contents();
1101
+ ob_get_clean();
1102
+ return $html;
1103
+ }
1104
+
1105
+ $posts = array_slice( $this->post_data, $offset, $settings['num'] );
1106
+
1107
+ ob_start();
1108
+
1109
+ $this->posts_loop( $posts, $settings, $offset );
1110
+
1111
+ $html = ob_get_contents();
1112
+ ob_get_clean();
1113
+
1114
+ return $html;
1115
+ }
1116
+
1117
+ /**
1118
+ * Overwritten in the Pro version
1119
+ *
1120
+ * @return object
1121
+ */
1122
+ public function make_api_connection( $connected_account_or_page, $type = NULL, $params = NULL ) {
1123
+ return new SB_Instagram_API_Connect( $connected_account_or_page, $type, $params );
1124
+ }
1125
+
1126
+ /**
1127
+ * When the feed is loaded with AJAX, the JavaScript for the plugin
1128
+ * needs to be triggered again. This function is a workaround that adds
1129
+ * the file and settings to the page whenever the feed is generated.
1130
+ *
1131
+ * @return string
1132
+ *
1133
+ * @since 2.0/5.0
1134
+ */
1135
+ public static function get_ajax_page_load_html() {
1136
+ if ( SB_Instagram_Blocks::is_gb_editor() ) {
1137
+ return '';
1138
+ }
1139
+ $sbi_options = sbi_get_database_settings();
1140
+ $font_method = isset( $sbi_options['sbi_font_method'] ) ? $sbi_options['sbi_font_method'] : 'svg';
1141
+ $upload = wp_upload_dir();
1142
+ $resized_url = trailingslashit( $upload['baseurl'] ) . trailingslashit( SBI_UPLOADS_NAME );
1143
+
1144
+ $js_options = array(
1145
+ 'font_method' => $font_method,
1146
+ 'placeholder' => trailingslashit( SBI_PLUGIN_URL ) . 'img/placeholder.png',
1147
+ 'resized_url' => $resized_url
1148
+ );
1149
+
1150
+ $encoded_options = wp_json_encode( $js_options );
1151
+
1152
+ $js_option_html = '<script type="text/javascript">var sb_instagram_js_options = ' . $encoded_options . ';</script>';
1153
+ $js_option_html .= "<script type='text/javascript' src='" . trailingslashit( SBI_PLUGIN_URL ) . 'js/sb-instagram.min.js?ver=' . SBIVER . "'></script>";
1154
+
1155
+ return $js_option_html;
1156
+ }
1157
+
1158
+ /**
1159
+ * Overwritten in the Pro version
1160
+ *
1161
+ * @param $feed_types_and_terms
1162
+ *
1163
+ * @return string
1164
+ *
1165
+ * @since 2.1/5.2
1166
+ */
1167
+ public function get_first_user( $feed_types_and_terms ) {
1168
+ if ( isset( $feed_types_and_terms['users'][0] ) ) {
1169
+ return $feed_types_and_terms['users'][0]['term'];
1170
+ } else {
1171
+ return '';
1172
+ }
1173
+ }
1174
+
1175
+ /**
1176
+ * Adds recorded strings to an array
1177
+ *
1178
+ * @param $to_add
1179
+ *
1180
+ * @since 2.0/5.0
1181
+ */
1182
+ public function add_report( $to_add ) {
1183
+ $this->report[] = $to_add;
1184
+ }
1185
+
1186
+ /**
1187
+ * @return array
1188
+ *
1189
+ * @since 2.0/5.0
1190
+ */
1191
+ public function get_report() {
1192
+ return $this->report;
1193
+ }
1194
+
1195
+ /**
1196
+ * Additional options/settings added to the main div
1197
+ * for the feed
1198
+ *
1199
+ * Overwritten in the Pro version
1200
+ *
1201
+ * @param $other_atts
1202
+ * @param $settings
1203
+ *
1204
+ * @return string
1205
+ */
1206
+ protected function add_other_atts( $other_atts, $settings ) {
1207
+ return '';
1208
+ }
1209
+
1210
+ /**
1211
+ * Used for filtering a single API request worth of posts
1212
+ *
1213
+ * Overwritten in the Pro version
1214
+ *
1215
+ * @param array $post_set a single set of post data from the api
1216
+ *
1217
+ * @return mixed|array
1218
+ *
1219
+ * @since 2.0/5.0
1220
+ */
1221
+ protected function filter_posts( $post_set, $settings = array() ) {
1222
+ // array_unique( $post_set, SORT_REGULAR);
1223
+
1224
+ return $post_set;
1225
+ }
1226
+
1227
+ protected function handle_no_posts_found( $settings = array(), $feed_types_and_terms = array() ) {
1228
+ global $sb_instagram_posts_manager;
1229
+
1230
+ $error = '<p><b>' . __( 'Error: No posts found.', 'instagram-feed' ) . '</b>';
1231
+ $error .= '<p>' . __( 'Make sure this account has posts available on instagram.com.', 'instagram-feed' ) . '</p>';
1232
+ $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
1233
+ $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
1234
+ if ( current_user_can( $cap ) ) {
1235
+ $error .= '<p><a href="https://smashballoon.com/instagram-feed/docs/errors/">' . __( 'Click here to troubleshoot', 'instagram-feed' ) . '</a></p>';
1236
+ }
1237
+
1238
+ $sb_instagram_posts_manager->add_frontend_error( 'noposts', $error );
1239
+ }
1240
+
1241
+ protected function remove_duplicate_posts() {
1242
+ $posts = $this->post_data;
1243
+ $ids_in_feed = array();
1244
+ $non_duplicate_posts = array();
1245
+ $removed = array();
1246
+
1247
+ foreach ( $posts as $post ) {
1248
+ $post_id = SB_Instagram_Parse::get_post_id( $post );
1249
+ if ( ! in_array( $post_id, $ids_in_feed, true ) ) {
1250
+ $ids_in_feed[] = $post_id;
1251
+ $non_duplicate_posts[] = $post;
1252
+ } else {
1253
+ $removed[] = $post_id;
1254
+ }
1255
+ }
1256
+
1257
+ $this->add_report( 'removed duplicates: ' . implode(', ', $removed ) );
1258
+ $this->set_post_data( $non_duplicate_posts );
1259
+ }
1260
+
1261
+ /**
1262
+ * Used for limiting the cache size
1263
+ *
1264
+ * @since 2.0/5.1.1
1265
+ */
1266
+ protected function trim_posts_to_max() {
1267
+ if ( ! is_array( $this->post_data ) ) {
1268
+ return;
1269
+ }
1270
+
1271
+ $max = apply_filters( 'sbi_max_cache_size', 500 );
1272
+ $this->set_post_data( array_slice( $this->post_data , 0, $max ) );
1273
+
1274
+ }
1275
+
1276
+ /**
1277
+ * Used for permanent feeds or white list feeds to
1278
+ * stop pagination if all posts are already added
1279
+ *
1280
+ * Overwritten in the Pro version
1281
+ *
1282
+ * @param array $settings
1283
+ * @param int $offset
1284
+ *
1285
+ * @return bool
1286
+ *
1287
+ * @since 2.0/5.0
1288
+ */
1289
+ protected function feed_is_complete( $settings, $offset = 0 ) {
1290
+ return false;
1291
+ }
1292
+
1293
+ /**
1294
+ * @param $connected_account_for_term
1295
+ *
1296
+ * @since 2.0/5.1.2
1297
+ */
1298
+ private function clear_expired_access_token_notice( $connected_account_for_term ) {
1299
+ $sbi_options = get_option( 'sb_instagram_settings' );
1300
+ $ca_to_save = isset( $sbi_options['connected_accounts'] ) ? $sbi_options['connected_accounts'] : array();
1301
+
1302
+ if ( ! empty( $ca_to_save ) && ! empty( $connected_account_for_term ) ) {
1303
+
1304
+ foreach ( $ca_to_save as $account ) {
1305
+ if ( $connected_account_for_term['access_token'] === $account['access_token'] ) {
1306
+ $ca_to_save[ $account['user_id'] ]['is_valid'] = true;
1307
+ }
1308
+ }
1309
+
1310
+ $sbi_options['connected_accounts'] = $ca_to_save;
1311
+
1312
+ update_option( 'sb_instagram_settings', $sbi_options );
1313
+ }
1314
+ }
1315
+
1316
+ /**
1317
+ * Iterates through post data and tracks the index of the current post.
1318
+ * The actual post ids of the posts are stored in an array so the plugin
1319
+ * can search for local images that may be available.
1320
+ *
1321
+ * @param array $posts final filtered post data for the feed
1322
+ * @param array $settings
1323
+ * @param int $offset
1324
+ *
1325
+ * @since 2.0/5.0
1326
+ */
1327
+ private function posts_loop( $posts, $settings, $offset = 0 ) {
1328
+
1329
+ $image_ids = array();
1330
+ $post_index = $offset;
1331
+ $icon_type = $settings['font_method'];
1332
+ $resized_images = $this->get_resized_images();
1333
+
1334
+ foreach ( $posts as $post ) {
1335
+ $image_ids[] = SB_Instagram_Parse::get_post_id( $post );
1336
+ $account_type = SB_Instagram_Parse::get_account_type( $post );
1337
+ include sbi_get_feed_template_part( 'item', $settings );
1338
+ $post_index++;
1339
+ }
1340
+
1341
+ $this->image_ids_post_set = $image_ids;
1342
+ }
1343
+
1344
+ /**
1345
+ * Uses array of API request results and merges them based on how
1346
+ * the feed should be sorted. Mixed feeds are always sorted alternating
1347
+ * since there is no post date for hashtag feeds.
1348
+ *
1349
+ * @param array $post_sets an array of single API request worth
1350
+ * of posts
1351
+ * @param array $settings
1352
+ *
1353
+ * @return array
1354
+ *
1355
+ * @since 2.0/5.0
1356
+ */
1357
+ private function merge_posts( $post_sets, $settings ) {
1358
+ $merged_posts = array();
1359
+ if ( $settings['sortby'] === 'alternate' ) {
1360
+ // don't bother merging posts if there is only one post set
1361
+ if ( isset( $post_sets[1] ) ) {
1362
+ $min_cycles = max( 1, (int)$settings['num'] );
1363
+ for( $i = 0; $i <= $min_cycles; $i++ ) {
1364
+ foreach ( $post_sets as $post_set ) {
1365
+ if ( isset( $post_set[ $i ] ) && isset( $post_set[ $i ]['id'] ) ) {
1366
+ $merged_posts[] = $post_set[ $i ];
1367
+ }
1368
+ }
1369
+ }
1370
+ } else {
1371
+ $merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
1372
+ }
1373
+ } elseif ( $settings['sortby'] === 'api' ) {
1374
+ if ( isset( $post_sets[0] ) ) {
1375
+ foreach ( $post_sets as $post_set ) {
1376
+ $merged_posts = array_merge( $merged_posts, $post_set );
1377
+ }
1378
+ }
1379
+ } else {
1380
+ // don't bother merging posts if there is only one post set
1381
+ if ( isset( $post_sets[1] ) ) {
1382
+ foreach ( $post_sets as $post_set ) {
1383
+ if ( isset( $post_set[0]['id'] ) ) {
1384
+ $merged_posts = array_merge( $merged_posts, $post_set );
1385
+ }
1386
+ }
1387
+ } else {
1388
+ $merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
1389
+ }
1390
+ }
1391
+
1392
+
1393
+ return $merged_posts;
1394
+ }
1395
+
1396
+ /**
1397
+ * Sorts a post set based on sorting settings. Sorting by "alternate"
1398
+ * is done when merging posts for efficiency's sake so the post set is
1399
+ * just returned as it is.
1400
+ *
1401
+ * @param array $post_set
1402
+ * @param array $settings
1403
+ *
1404
+ * @return mixed|array
1405
+ *
1406
+ * @since 2.0/5.0
1407
+ * @since 2.1/5.2 added filter hook for applying custom sorting
1408
+ */
1409
+ private function sort_posts( $post_set, $settings ) {
1410
+ if ( empty( $post_set ) ) {
1411
+ return $post_set;
1412
+ }
1413
+
1414
+ // sorting done with "merge_posts" to be more efficient
1415
+ if ( $settings['sortby'] === 'alternate' || $settings['sortby'] === 'api' ) {
1416
+ $return_post_set = $post_set;
1417
+ } elseif ( $settings['sortby'] === 'random' ) {
1418
+ /*
1419
+ * randomly selects posts in a random order. Cache saves posts
1420
+ * in this random order so paginating does not cause some posts to show up
1421
+ * twice or not at all
1422
+ */
1423
+ usort($post_set, 'sbi_rand_sort' );
1424
+ $return_post_set = $post_set;
1425
+
1426
+ } else {
1427
+ // compares posted on dates of posts
1428
+ usort($post_set, 'sbi_date_sort' );
1429
+ $return_post_set = $post_set;
1430
+ }
1431
+
1432
+ /**
1433
+ * Apply a custom sorting of posts
1434
+ *
1435
+ * @param array $return_post_set Ordered set of filtered posts
1436
+ * @param array $settings Settings for this feed
1437
+ *
1438
+ * @since 2.1/5.2
1439
+ */
1440
+
1441
+ return apply_filters( 'sbi_sorted_posts', $return_post_set, $settings );
1442
+ }
1443
+
1444
+ /**
1445
+ * Can trigger a second attempt at getting posts from the API
1446
+ *
1447
+ * Overwritten in the Pro version
1448
+ *
1449
+ * @param string $type
1450
+ * @param array $connected_account_with_error
1451
+ * @param int $attempts
1452
+ *
1453
+ * @return bool
1454
+ *
1455
+ * @since 2.0/5.1.1
1456
+ */
1457
+ protected function can_try_another_request( $type, $connected_account_with_error, $attempts = 0 ) {
1458
+ return false;
1459
+ }
1460
+
1461
+ /**
1462
+ * returns a second connected account if it exists
1463
+ *
1464
+ * Overwritten in the Pro version
1465
+ *
1466
+ * @param string $type
1467
+ * @param array $attempted_connected_accounts
1468
+ *
1469
+ * @return bool
1470
+ *
1471
+ * @since 2.0/5.1.1
1472
+ */
1473
+ protected function get_different_connected_account( $type, $attempted_connected_accounts ) {
1474
+ return false;
1475
+ }
1476
+
1477
  }
inc/class-sb-instagram-parse.php CHANGED
@@ -1,314 +1,314 @@
1
- <?php
2
- /**
3
- * Class SB_Instagram_Parse
4
- *
5
- * The structure of the data coming from the Instagram API is different
6
- * for the old API vs the new graph API. This class is used to parse
7
- * whatever structure the data has as well as use this to generate
8
- * parts of the html used for image sources.
9
- *
10
- * @since 2.0/5.0
11
- */
12
-
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- die( '-1' );
15
- }
16
-
17
- class SB_Instagram_Parse
18
- {
19
- /**
20
- * @param $post array
21
- *
22
- * @return mixed
23
- *
24
- * @since 2.0/5.0
25
- */
26
- public static function get_post_id( $post ) {
27
- return $post['id'];
28
- }
29
-
30
- /**
31
- * @param $post array
32
- *
33
- * @return string
34
- *
35
- * @since 2.0/5.0
36
- */
37
- public static function get_account_type( $post ) {
38
- if (isset( $post['media_type'] ) ) {
39
- return 'business';
40
- } else {
41
- return 'personal';
42
- }
43
- }
44
-
45
- /**
46
- * @param $post array
47
- *
48
- * @return false|int
49
- *
50
- * @since 2.0/5.0
51
- */
52
- public static function get_timestamp( $post ) {
53
- $timestamp = 0;
54
- if ( isset( $post['created_time'] ) ) {
55
- $timestamp = $post['created_time'];
56
- } else if ( isset( $post['timestamp'] ) ) {
57
- // some date formatting functions have trouble with the "T", "+", and extra zeroes added by Instagram
58
- $remove_plus = trim( str_replace( array('T', '+', ' 0000' ), ' ', $post['timestamp'] ) );
59
- $timestamp = strtotime( $remove_plus );
60
- }
61
-
62
- return $timestamp;
63
- }
64
-
65
- /**
66
- * @param $post array
67
- *
68
- * @return string
69
- *
70
- * @since 2.0/5.0
71
- */
72
- public static function get_media_type( $post ) {
73
- if ( isset( $post['type'] ) ) {
74
- return $post['type'];
75
- }
76
-
77
- return strtolower( str_replace( '_ALBUM','', $post['media_type'] ) );
78
- }
79
-
80
- /**
81
- * @param $post array
82
- *
83
- * @return mixed
84
- *
85
- * @since 2.0/5.0
86
- */
87
- public static function get_permalink( $post ) {
88
- if ( isset( $post['permalink'] ) ) {
89
- return $post['permalink'];
90
- }
91
-
92
- return $post['link'];
93
- }
94
-
95
- /**
96
- * @param array $post
97
- * @param string $resolution
98
- *
99
- * @return string
100
- *
101
- * @since 2.0/5.0
102
- */
103
- public static function get_media_url( $post, $resolution = 'lightbox' ) {
104
- $account_type = isset( $post['images'] ) ? 'personal' : 'business';
105
-
106
- if ( $account_type === 'personal' ) {
107
- return $post['images']['standard_resolution']['url'];
108
- } else {
109
- if ($post['media_type'] === 'CAROUSEL_ALBUM' || $post['media_type'] === 'VIDEO') {
110
- if ( isset( $post['thumbnail_url'] ) ) {
111
- return $post['thumbnail_url'];
112
- } elseif ( $post['media_type'] === 'CAROUSEL_ALBUM' && isset( $post['media_url'] ) ) {
113
- return $post['media_url'];
114
- } else {
115
- $permalink = SB_Instagram_Parse::fix_permalink( SB_Instagram_Parse::get_permalink( $post ) );
116
-
117
- return $permalink . 'media?size=l';
118
- }
119
- } else {
120
- return $post['media_url'];
121
- }
122
- }
123
-
124
- }
125
-
126
- /**
127
- * Uses the existing data for the indvidual instagram post to
128
- * set the best image sources for each resolution size. Due to
129
- * random bugs or just how the API works, different post types
130
- * need special treatment.
131
- *
132
- * @param array $post
133
- * @param array $resized_images
134
- *
135
- * @return array
136
- *
137
- * @since 2.0/5.0
138
- * @since 2.1.3/5.2.3 added 'd' element as a default backup from the API
139
- */
140
- public static function get_media_src_set( $post, $resized_images = array() ) {
141
- $media_urls = array(
142
- 'd' => SB_Instagram_Parse::get_media_url( $post ),
143
- '150' => '',
144
- '320' => '',
145
- '640' => ''
146
- );
147
- $account_type = isset( $post['images'] ) ? 'personal' : 'business';
148
-
149
-
150
- if ( $account_type === 'personal' ) {
151
- $media_urls['150'] = $post['images']['thumbnail']['url'];
152
- $media_urls['320'] = $post['images']['low_resolution']['url'];
153
- $media_urls['640'] = $post['images']['standard_resolution']['url'];
154
- } else {
155
- $post_id = SB_Instagram_Parse::get_post_id( $post );
156
-
157
- $permalink = SB_Instagram_Parse::fix_permalink( SB_Instagram_Parse::get_permalink( $post ) );
158
-
159
- if ( ($post['media_type'] === 'CAROUSEL_ALBUM' || $post['media_type'] === 'VIDEO') && ($media_urls['640'] === '' || $media_urls['640'] === 'video' || $media_urls['640'] === 'pending')) {
160
- $media_urls['640'] = $permalink . 'media?size=l';
161
- } else {
162
- $media_urls['640'] = $post['media_url'];
163
- }
164
- $media_urls['150'] = $permalink . 'media?size=t';
165
- $media_urls['320'] = $permalink . 'media?size=m';
166
-
167
- // use resized images if exists
168
- if ( isset( $resized_images[ $post_id ]['id'] )
169
- && $resized_images[ $post_id ]['id'] !== 'pending'
170
- && $resized_images[ $post_id ]['id'] !== 'video'
171
- && $resized_images[ $post_id ]['id'] !== 'error' ) {
172
- if ( isset( $resized_images[ $post_id ]['sizes']['full'] ) ) {
173
- $media_urls['640'] = $resized_images[ $post_id ]['id'];
174
- }
175
- if ( isset( $resized_images[ $post_id ]['sizes']['low'] ) ) {
176
- $media_urls['320'] = $resized_images[ $post_id ]['id'];
177
- }
178
- }
179
-
180
- }
181
-
182
- return $media_urls;
183
- }
184
-
185
- /**
186
- * A default can be set in the case that the user doesn't use captions
187
- * for posts as this is also used as the alt text for the image.
188
- *
189
- * @param $post
190
- * @param string $default
191
- *
192
- * @return string
193
- *
194
- * @since 2.0/5.0
195
- */
196
- public static function get_caption( $post, $default = '' ) {
197
- $caption = $default;
198
- if ( ! empty( $post['caption'] ) && ! is_array( $post['caption'] ) ) {
199
- $caption = $post['caption'];
200
- } elseif ( ! empty( $post['caption']['text'] ) ) {
201
- $caption = $post['caption']['text'];
202
- }
203
-
204
- return $caption;
205
- }
206
-
207
- /**
208
- * @param array $header_data
209
- *
210
- * @return string
211
- *
212
- * @since 2.0/5.0
213
- */
214
- public static function get_username( $header_data ) {
215
- if ( isset( $header_data['username'] ) ) {
216
- return $header_data['username'];
217
- } elseif ( isset( $header_data['user'] ) ) {
218
- return $header_data['user']['username'];
219
- } elseif ( isset( $header_data['data'] ) ) {
220
- return $header_data['data']['username'];
221
- }
222
- return '';
223
- }
224
-
225
- /**
226
- * @param array $header_data
227
- * @param array $settings
228
- *
229
- * @return string
230
- *
231
- * @since 2.0/5.0
232
- * @since 2.2/5.3 added support for a custom avatar in settings
233
- */
234
- public static function get_avatar( $header_data, $settings = array( 'favor_local' => false ) ) {
235
- if ( ! empty( $settings['customavatar'] ) ) {
236
- return $settings['customavatar'];
237
- } elseif ( ! empty( $header_data['local_avatar'] ) ) {
238
- return $header_data['local_avatar'];
239
- } else {
240
- if ( isset( $header_data['profile_picture'] ) ) {
241
- return $header_data['profile_picture'];
242
- } elseif ( isset( $header_data['profile_picture_url'] ) ) {
243
- return $header_data['profile_picture_url'];
244
- } elseif ( isset( $header_data['user'] ) ) {
245
- return $header_data['user']['profile_picture'];
246
- } elseif ( isset( $header_data['data'] ) ) {
247
- return $header_data['data']['profile_picture'];
248
- }
249
- }
250
-
251
- return '';
252
- }
253
-
254
- /**
255
- * The full name attached to the user account
256
- *
257
- * @param array $header_data
258
- *
259
- * @return string
260
- *
261
- * @since 2.0/5.0
262
- */
263
- public static function get_name( $header_data ) {
264
- if ( isset( $header_data['name'] ) ) {
265
- return $header_data['name'];
266
- } elseif ( isset( $header_data['data'] ) ) {
267
- return $header_data['data']['full_name'];
268
- }
269
- return '';
270
- }
271
-
272
- /**
273
- * Account bio/description used in header
274
- *
275
- * @param $header_data
276
- *
277
- * @return string
278
- *
279
- * @since 2.0.1/5.0
280
- * @since 2.2/5.3 added support for a custom bio in settings
281
- */
282
- public static function get_bio( $header_data, $settings = array() ) {
283
- if ( ! empty( $settings['custombio'] ) ) {
284
- return $settings['custombio'];
285
- } elseif ( isset( $header_data['data']['bio'] ) ) {
286
- return $header_data['data']['bio'];
287
- } elseif ( isset( $header_data['bio'] ) ){
288
- return $header_data['bio'];
289
- } elseif ( isset( $header_data['biography'] ) ){
290
- return $header_data['biography'];
291
- }
292
- return '';
293
- }
294
-
295
- /**
296
- * There seems to be occasional bugs with the Instagram API
297
- * and permalinks. This corrects it.
298
- *
299
- * @param string $permalink
300
- *
301
- * @return string
302
- *
303
- * @since 2.0/5.0
304
- */
305
- protected static function fix_permalink( $permalink ) {
306
- if ( substr_count( $permalink, '/' ) > 5 ) {
307
- $permalink_array = explode( '/', $permalink );
308
- $perm_id = $permalink_array[ count( $permalink_array ) - 2 ];
309
- $permalink = 'https://www.instagram.com/p/' . $perm_id . '/';
310
- }
311
-
312
- return $permalink;
313
- }
314
  }
1
+ <?php
2
+ /**
3
+ * Class SB_Instagram_Parse
4
+ *
5
+ * The structure of the data coming from the Instagram API is different
6
+ * for the old API vs the new graph API. This class is used to parse
7
+ * whatever structure the data has as well as use this to generate
8
+ * parts of the html used for image sources.
9
+ *
10
+ * @since 2.0/5.0
11
+ */
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ die( '-1' );
15
+ }
16
+
17
+ class SB_Instagram_Parse
18
+ {
19
+ /**
20
+ * @param $post array
21
+ *
22
+ * @return mixed
23
+ *
24
+ * @since 2.0/5.0
25
+ */
26
+ public static function get_post_id( $post ) {
27
+ return $post['id'];
28
+ }
29
+
30
+ /**
31
+ * @param $post array
32
+ *
33
+ * @return string
34
+ *
35
+ * @since 2.0/5.0
36
+ */
37
+ public static function get_account_type( $post ) {
38
+ if (isset( $post['media_type'] ) ) {
39
+ return 'business';
40
+ } else {
41
+ return 'personal';
42
+ }
43
+ }
44
+
45
+ /**
46
+ * @param $post array
47
+ *
48
+ * @return false|int
49
+ *
50
+ * @since 2.0/5.0
51
+ */
52
+ public static function get_timestamp( $post ) {
53
+ $timestamp = 0;
54
+ if ( isset( $post['created_time'] ) ) {
55
+ $timestamp = $post['created_time'];
56
+ } else if ( isset( $post['timestamp'] ) ) {
57
+ // some date formatting functions have trouble with the "T", "+", and extra zeroes added by Instagram
58
+ $remove_plus = trim( str_replace( array('T', '+', ' 0000' ), ' ', $post['timestamp'] ) );
59
+ $timestamp = strtotime( $remove_plus );
60
+ }
61
+
62
+ return $timestamp;
63
+ }
64
+
65
+ /**
66
+ * @param $post array
67
+ *
68
+ * @return string
69
+ *
70
+ * @since 2.0/5.0
71
+ */
72
+ public static function get_media_type( $post ) {
73
+ if ( isset( $post['type'] ) ) {
74
+ return $post['type'];
75
+ }
76
+
77
+ return strtolower( str_replace( '_ALBUM','', $post['media_type'] ) );
78
+ }
79
+
80
+ /**
81
+ * @param $post array
82
+ *
83
+ * @return mixed
84
+ *
85
+ * @since 2.0/5.0
86
+ */
87
+ public static function get_permalink( $post ) {
88
+ if ( isset( $post['permalink'] ) ) {
89
+ return $post['permalink'];
90
+ }
91
+
92
+ return $post['link'];
93
+ }
94
+
95
+ /**
96
+ * @param array $post
97
+ * @param string $resolution
98
+ *
99
+ * @return string
100
+ *
101
+ * @since 2.0/5.0
102
+ */
103
+ public static function get_media_url( $post, $resolution = 'lightbox' ) {
104
+ $account_type = isset( $post['images'] ) ? 'personal' : 'business';
105
+
106
+ if ( $account_type === 'personal' ) {
107
+ return $post['images']['standard_resolution']['url'];
108
+ } else {
109
+ if ($post['media_type'] === 'CAROUSEL_ALBUM' || $post['media_type'] === 'VIDEO') {
110
+ if ( isset( $post['thumbnail_url'] ) ) {
111
+ return $post['thumbnail_url'];
112
+ } elseif ( $post['media_type'] === 'CAROUSEL_ALBUM' && isset( $post['media_url'] ) ) {
113
+ return $post['media_url'];
114
+ } else {
115
+ $permalink = SB_Instagram_Parse::fix_permalink( SB_Instagram_Parse::get_permalink( $post ) );
116
+
117
+ return $permalink . 'media?size=l';
118
+ }
119
+ } else {
120
+ return $post['media_url'];
121
+ }
122
+ }
123
+
124
+ }
125
+
126
+ /**
127
+ * Uses the existing data for the indvidual instagram post to
128
+ * set the best image sources for each resolution size. Due to
129
+ * random bugs or just how the API works, different post types
130
+ * need special treatment.
131
+ *
132
+ * @param array $post
133
+ * @param array $resized_images
134
+ *
135
+ * @return array
136
+ *
137
+ * @since 2.0/5.0
138
+ * @since 2.1.3/5.2.3 added 'd' element as a default backup from the API
139
+ */
140
+ public static function get_media_src_set( $post, $resized_images = array() ) {
141
+ $media_urls = array(
142
+ 'd' => SB_Instagram_Parse::get_media_url( $post ),
143
+ '150' => '',
144
+ '320' => '',
145
+ '640' => ''
146
+ );
147
+ $account_type = isset( $post['images'] ) ? 'personal' : 'business';
148
+
149
+
150
+ if ( $account_type === 'personal' ) {
151
+ $media_urls['150'] = $post['images']['thumbnail']['url'];
152
+ $media_urls['320'] = $post['images']['low_resolution']['url'];
153
+ $media_urls['640'] = $post['images']['standard_resolution']['url'];
154
+ } else {
155
+ $post_id = SB_Instagram_Parse::get_post_id( $post );
156
+
157
+ $permalink = SB_Instagram_Parse::fix_permalink( SB_Instagram_Parse::get_permalink( $post ) );
158
+
159
+ if ( ($post['media_type'] === 'CAROUSEL_ALBUM' || $post['media_type'] === 'VIDEO') && ($media_urls['640'] === '' || $media_urls['640'] === 'video' || $media_urls['640'] === 'pending')) {
160
+ $media_urls['640'] = $permalink . 'media?size=l';
161
+ } else {
162
+ $media_urls['640'] = $post['media_url'];
163
+ }
164
+ $media_urls['150'] = $permalink . 'media?size=t';
165
+ $media_urls['320'] = $permalink . 'media?size=m';
166
+
167
+ // use resized images if exists
168
+ if ( isset( $resized_images[ $post_id ]['id'] )
169
+ && $resized_images[ $post_id ]['id'] !== 'pending'
170
+ && $resized_images[ $post_id ]['id'] !== 'video'
171
+ && $resized_images[ $post_id ]['id'] !== 'error' ) {
172
+ if ( isset( $resized_images[ $post_id ]['sizes']['full'] ) ) {
173
+ $media_urls['640'] = $resized_images[ $post_id ]['id'];
174
+ }
175
+ if ( isset( $resized_images[ $post_id ]['sizes']['low'] ) ) {
176
+ $media_urls['320'] = $resized_images[ $post_id ]['id'];
177
+ }
178
+ }
179
+
180
+ }
181
+
182
+ return $media_urls;
183
+ }
184
+
185
+ /**
186
+ * A default can be set in the case that the user doesn't use captions
187
+ * for posts as this is also used as the alt text for the image.
188
+ *
189
+ * @param $post
190
+ * @param string $default
191
+ *
192
+ * @return string
193
+ *
194
+ * @since 2.0/5.0
195
+ */
196
+ public static function get_caption( $post, $default = '' ) {
197
+ $caption = $default;
198
+ if ( ! empty( $post['caption'] ) && ! is_array( $post['caption'] ) ) {
199
+ $caption = $post['caption'];
200
+ } elseif ( ! empty( $post['caption']['text'] ) ) {
201
+ $caption = $post['caption']['text'];
202
+ }
203
+
204
+ return $caption;
205
+ }
206
+
207
+ /**
208
+ * @param array $header_data
209
+ *
210
+ * @return string
211
+ *
212
+ * @since 2.0/5.0
213
+ */
214
+ public static function get_username( $header_data ) {
215
+ if ( isset( $header_data['username'] ) ) {
216
+ return $header_data['username'];
217
+ } elseif ( isset( $header_data['user'] ) ) {
218
+ return $header_data['user']['username'];
219
+ } elseif ( isset( $header_data['data'] ) ) {
220
+ return $header_data['data']['username'];
221
+ }
222
+ return '';
223
+ }
224
+
225
+ /**
226
+ * @param array $header_data
227
+ * @param array $settings
228
+ *
229
+ * @return string
230
+ *
231
+ * @since 2.0/5.0
232
+ * @since 2.2/5.3 added support for a custom avatar in settings
233
+ */
234
+ public static function get_avatar( $header_data, $settings = array( 'favor_local' => false ) ) {
235
+ if ( ! empty( $settings['customavatar'] ) ) {
236
+ return $settings['customavatar'];
237
+ } elseif ( ! empty( $header_data['local_avatar'] ) ) {
238
+ return $header_data['local_avatar'];
239
+ } else {
240
+ if ( isset( $header_data['profile_picture'] ) ) {
241
+ return $header_data['profile_picture'];
242
+ } elseif ( isset( $header_data['profile_picture_url'] ) ) {
243
+ return $header_data['profile_picture_url'];
244
+ } elseif ( isset( $header_data['user'] ) ) {
245
+ return $header_data['user']['profile_picture'];
246
+ } elseif ( isset( $header_data['data'] ) ) {
247
+ return $header_data['data']['profile_picture'];
248
+ }
249
+ }
250
+
251
+ return '';
252
+ }
253
+
254
+ /**
255
+ * The full name attached to the user account
256
+ *
257
+ * @param array $header_data
258
+ *
259
+ * @return string
260
+ *
261
+ * @since 2.0/5.0
262
+ */
263
+ public static function get_name( $header_data ) {
264
+ if ( isset( $header_data['name'] ) ) {
265
+ return $header_data['name'];
266
+ } elseif ( isset( $header_data['data'] ) ) {
267
+ return $header_data['data']['full_name'];
268
+ }
269
+ return '';
270
+ }
271
+
272
+ /**
273
+ * Account bio/description used in header
274
+ *
275
+ * @param $header_data
276
+ *
277
+ * @return string
278
+ *
279
+ * @since 2.0.1/5.0
280
+ * @since 2.2/5.3 added support for a custom bio in settings
281
+ */
282
+ public static function get_bio( $header_data, $settings = array() ) {
283
+ if ( ! empty( $settings['custombio'] ) ) {
284
+ return $settings['custombio'];
285
+ } elseif ( isset( $header_data['data']['bio'] ) ) {
286
+ return $header_data['data']['bio'];
287
+ } elseif ( isset( $header_data['bio'] ) ){
288
+ return $header_data['bio'];
289
+ } elseif ( isset( $header_data['biography'] ) ){
290
+ return $header_data['biography'];
291
+ }
292
+ return '';
293
+ }
294
+
295
+ /**
296
+ * There seems to be occasional bugs with the Instagram API
297
+ * and permalinks. This corrects it.
298
+ *
299
+ * @param string $permalink
300
+ *
301
+ * @return string
302
+ *
303
+ * @since 2.0/5.0
304
+ */
305
+ protected static function fix_permalink( $permalink ) {
306
+ if ( substr_count( $permalink, '/' ) > 5 ) {
307
+ $permalink_array = explode( '/', $permalink );
308
+ $perm_id = $permalink_array[ count( $permalink_array ) - 2 ];
309
+ $permalink = 'https://www.instagram.com/p/' . $perm_id . '/';
310
+ }
311
+
312
+ return $permalink;
313
+ }
314
  }
inc/class-sb-instagram-post-set.php CHANGED
@@ -1,188 +1,188 @@
1
- <?php
2
- /**
3
- * Class SB_Instagram_Post_Set
4
- *
5
- * Useful for iterating over an array of posts and resizing images for
6
- * them or updating data in the custom database tables.
7
- *
8
- * @since 2.0/4.0
9
- */
10
-
11
- // Don't load directly
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- die( '-1' );
14
- }
15
-
16
- class SB_Instagram_Post_Set {
17
- /**
18
- * @var array
19
- */
20
- private $post_data;
21
-
22
- /**
23
- * @var array
24
- */
25
- private $resized_image_data_for_set;
26
-
27
- /**
28
- * @var string|null
29
- */
30
- private $upload_dir;
31
-
32
- /**
33
- * @var string|null
34
- */
35
- private $upload_url;
36
-
37
- /**
38
- * @var bool
39
- */
40
- private $transient_name;
41
-
42
- /**
43
- * @var null
44
- */
45
- private $fill_in_timestamp;
46
-
47
- /**
48
- * @var
49
- */
50
- private $first_post_top_time_stamp;
51
-
52
- /**
53
- * SB_Instagram_Post_Set constructor.
54
- *
55
- * @param array $post_data
56
- * @param bool $transient_name
57
- * @param null $fill_in_timestamp (optional)
58
- * @param array $image_sizes (optional) sizes to create for personal and business account
59
- * currently thumb, low, and full can be set
60
- * @param null $upload_dir (optional)
61
- * @param null $upload_url (optional)
62
- *
63
- * @since 2.0/4.0
64
- */
65
- public function __construct( $post_data, $transient_name = false, $fill_in_timestamp = NULL, $image_sizes = array( 'personal' => array( 'low' => 320 ), 'business' => array( 'full' => 640, 'low' => 320 ) ), $upload_dir = NULL, $upload_url = NULL ) {
66
- $this->post_data = $post_data;
67
-
68
- $this->image_sizes = $image_sizes;
69
-
70
- if ( ! isset( $upload_dir ) || ! isset( $upload_url ) ) {
71
- $upload = wp_upload_dir();
72
- $upload_dir = $upload['basedir'];
73
- $upload_dir = trailingslashit( $upload_dir ) . SBI_UPLOADS_NAME;
74
-
75
- $upload_url = trailingslashit( $upload['baseurl'] ) . SBI_UPLOADS_NAME;
76
- }
77
-
78
- $this->upload_dir = $upload_dir;
79
-
80
- $this->upload_url = $upload_url;
81
-
82
- $this->transient_name = $transient_name;
83
-
84
- $this->fill_in_timestamp = $fill_in_timestamp;
85
- }
86
-
87
- /**
88
- * @return array
89
- *
90
- * @since 2.0/4.0
91
- */
92
- public function get_post_data() {
93
- if ( is_array( $this->post_data ) ) {
94
- return $this->post_data;
95
- } else {
96
- return array();
97
- }
98
- }
99
-
100
- /**
101
- * @return array
102
- *
103
- * @since 2.0/4.0
104
- */
105
- public function get_resized_image_data_for_set() {
106
- return $this->resized_image_data_for_set;
107
- }
108
-
109
- /**
110
- * Loop through set of posts and update or create resized images based on
111
- * whether or not they have been created and whether or not a record has been
112
- * saved for this feed id
113
- *
114
- * @since 2.0/4.0
115
- */
116
- public function maybe_save_update_and_resize_images_for_posts() {
117
- global $sb_instagram_posts_manager;
118
-
119
- $posts_iterated_through = 0;
120
- $number_resized = 0;
121
- $number_updated = 0;
122
- $resized_image_data_for_set = array();
123
- $resizing_disabled = $sb_instagram_posts_manager->image_resizing_disabled() || $sb_instagram_posts_manager->max_resizing_per_time_period_reached();
124
- $is_top_post_feed = (substr( $this->transient_name, 4, 1 ) === '+');
125
-
126
- foreach ( $this->post_data as $single_instagram_post_data ) {
127
-
128
- if ( $posts_iterated_through < 60 ) {
129
- $single_post = new SB_Instagram_Post( $single_instagram_post_data['id'] );
130
- $single_post->set_instagram_api_data( $single_instagram_post_data );
131
- $resized_image_data_for_set[ $single_instagram_post_data['id'] ] = array();
132
-
133
- if ( $is_top_post_feed ) {
134
- if ( empty( $this->first_post_top_time_stamp ) ) {
135
- $this_post_top_time_stamp = $single_post->get_top_time_stamp();
136
- if ( empty( $this_post_top_time_stamp ) ) {
137
- $this->first_post_top_time_stamp = $this->fill_in_timestamp;
138
- } else {
139
- $this->first_post_top_time_stamp = $single_post->get_top_time_stamp();
140
- }
141
- }
142
- }
143
-
144
- if ( ! $resizing_disabled ) {
145
- if ( (! $single_post->exists_in_posts_table() || ! $single_post->images_done_resizing()) && $number_resized < 30 ) {
146
-
147
- if ( $sb_instagram_posts_manager->max_total_records_reached() ) {
148
- $sb_instagram_posts_manager->delete_least_used_image();
149
- }
150
-
151
- if ( ! $single_post->images_done_resizing() && $single_post->exists_in_posts_table() ) {
152
- $single_post->resize_and_save_image( $this->image_sizes, $this->upload_dir, $this->upload_url );
153
- } else {
154
- if ( $is_top_post_feed ) {
155
- if ( $single_post->save_in_db( $this->transient_name, date( 'Y-m-d H:i:s', strtotime( $this->first_post_top_time_stamp ) - (120 * $posts_iterated_through) - 1 ) ) ) {
156
- $single_post->resize_and_save_image( $this->image_sizes, $this->upload_dir, $this->upload_url );
157
- }
158
- } else {
159
- if ( $single_post->save_in_db( $this->transient_name, date( 'Y-m-d H:i:s', strtotime( $this->fill_in_timestamp ) - (120 * $posts_iterated_through) ) ) ) {
160
- $single_post->resize_and_save_image( $this->image_sizes, $this->upload_dir, $this->upload_url );
161
- }
162
- }
163
- }
164
-
165
- $number_resized++;
166
- } else {
167
- if ( $is_top_post_feed ) {
168
- $single_post->update_db_data( true, $this->transient_name, $this->image_sizes, $this->upload_dir, $this->upload_url, date( 'Y-m-d H:i:s', strtotime( $this->first_post_top_time_stamp ) - (120 * $posts_iterated_through) ) );
169
- } else {
170
- $single_post->update_db_data( true, $this->transient_name, $this->image_sizes, $this->upload_dir, $this->upload_url );
171
- }
172
- if ( ! $single_post->exists_in_feeds_posts_table( $this->transient_name ) ) {
173
- $single_post->insert_sbi_instagram_feeds_posts( $this->transient_name );
174
- }
175
- $number_updated++;
176
- }
177
-
178
- $resized_image_data_for_set[ $single_instagram_post_data['id'] ] = $single_post->get_resized_image_array();
179
- }
180
- }
181
-
182
- $posts_iterated_through++;
183
- }
184
-
185
- $this->resized_image_data_for_set = $resized_image_data_for_set;
186
- }
187
-
188
  }
1
+ <?php
2
+ /**
3
+ * Class SB_Instagram_Post_Set
4
+ *
5
+ * Useful for iterating over an array of posts and resizing images for
6
+ * them or updating data in the custom database tables.
7
+ *
8
+ * @since 2.0/4.0
9
+ */
10
+
11
+ // Don't load directly
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ die( '-1' );
14
+ }
15
+
16
+ class SB_Instagram_Post_Set {
17
+ /**
18
+ * @var array
19
+ */
20
+ private $post_data;
21
+
22
+ /**
23
+ * @var array
24
+ */
25
+ private $resized_image_data_for_set;
26
+
27
+ /**
28
+ * @var string|null
29
+ */
30
+ private $upload_dir;
31
+
32
+ /**
33
+ * @var string|null
34
+ */
35
+ private $upload_url;
36
+
37
+ /**
38
+ * @var bool
39
+ */
40
+ private $transient_name;
41
+
42
+ /**
43
+ * @var null
44
+ */
45
+ private $fill_in_timestamp;
46
+
47
+ /**
48
+ * @var
49
+ */
50
+ private $first_post_top_time_stamp;
51
+
52
+ /**
53
+ * SB_Instagram_Post_Set constructor.
54
+ *
55
+ * @param array $post_data
56
+ * @param bool $transient_name
57
+ * @param null $fill_in_timestamp (optional)
58
+ * @param array $image_sizes (optional) sizes to create for personal and business account
59
+ * currently thumb, low, and full can be set
60
+ * @param null $upload_dir (optional)
61
+ * @param null $upload_url (optional)
62
+ *
63
+ * @since 2.0/4.0
64
+ */
65
+ public function __construct( $post_data, $transient_name = false, $fill_in_timestamp = NULL, $image_sizes = array( 'personal' => array( 'low' => 320 ), 'business' => array( 'full' => 640, 'low' => 320 ) ), $upload_dir = NULL, $upload_url = NULL ) {
66
+ $this->post_data = $post_data;
67
+
68
+ $this->image_sizes = $image_sizes;
69
+
70
+ if ( ! isset( $upload_dir ) || ! isset( $upload_url ) ) {
71
+ $upload = wp_upload_dir();
72
+ $upload_dir = $upload['basedir'];
73
+ $upload_dir = trailingslashit( $upload_dir ) . SBI_UPLOADS_NAME;
74
+
75
+ $upload_url = trailingslashit( $upload['baseurl'] ) . SBI_UPLOADS_NAME;
76
+ }
77
+
78
+ $this->upload_dir = $upload_dir;
79
+
80
+ $this->upload_url = $upload_url;
81
+
82
+ $this->transient_name = $transient_name;
83
+
84
+ $this->fill_in_timestamp = $fill_in_timestamp;
85
+ }
86
+
87
+ /**
88
+ * @return array
89
+ *
90
+ * @since 2.0/4.0
91
+ */
92
+ public function get_post_data() {
93
+ if ( is_array( $this->post_data ) ) {
94
+ return $this->post_data;
95
+ } else {
96
+ return array();
97
+ }
98
+ }
99
+
100
+ /**
101
+ * @return array
102
+ *
103
+ * @since 2.0/4.0
104
+ */
105
+ public function get_resized_image_data_for_set() {
106
+ return $this->resized_image_data_for_set;
107
+ }
108
+
109
+ /**
110
+ * Loop through set of posts and update or create resized images based on
111
+ * whether or not they have been created and whether or not a record has been
112
+ * saved for this feed id
113
+ *
114
+ * @since 2.0/4.0
115
+ */
116
+ public function maybe_save_update_and_resize_images_for_posts() {
117
+ global $sb_instagram_posts_manager;
118
+
119
+ $posts_iterated_through = 0;
120
+ $number_resized = 0;
121
+ $number_updated = 0;
122
+ $resized_image_data_for_set = array();
123
+ $resizing_disabled = $sb_instagram_posts_manager->image_resizing_disabled() || $sb_instagram_posts_manager->max_resizing_per_time_period_reached();
124
+ $is_top_post_feed = (substr( $this->transient_name, 4, 1 ) === '+');
125
+
126
+ foreach ( $this->post_data as $single_instagram_post_data ) {
127
+
128
+ if ( $posts_iterated_through < 60 ) {
129
+ $single_post = new SB_Instagram_Post( $single_instagram_post_data['id'] );
130
+ $single_post->set_instagram_api_data( $single_instagram_post_data );
131
+ $resized_image_data_for_set[ $single_instagram_post_data['id'] ] = array();
132
+
133
+ if ( $is_top_post_feed ) {
134
+ if ( empty( $this->first_post_top_time_stamp ) ) {
135
+ $this_post_top_time_stamp = $single_post->get_top_time_stamp();
136
+ if ( empty( $this_post_top_time_stamp ) ) {
137
+ $this->first_post_top_time_stamp = $this->fill_in_timestamp;
138
+ } else {
139
+ $this->first_post_top_time_stamp = $single_post->get_top_time_stamp();
140
+ }
141
+ }
142
+ }
143
+
144
+ if ( ! $resizing_disabled ) {
145
+ if ( (! $single_post->exists_in_posts_table() || ! $single_post->images_done_resizing()) && $number_resized < 30 ) {
146
+
147
+ if ( $sb_instagram_posts_manager->max_total_records_reached() ) {
148
+ $sb_instagram_posts_manager->delete_least_used_image();
149
+ }
150
+
151
+ if ( ! $single_post->images_done_resizing() && $single_post->exists_in_posts_table() ) {
152
+ $single_post->resize_and_save_image( $this->image_sizes, $this->upload_dir, $this->upload_url );
153
+ } else {
154
+ if ( $is_top_post_feed ) {
155
+ if ( $single_post->save_in_db( $this->transient_name, date( 'Y-m-d H:i:s', strtotime( $this->first_post_top_time_stamp ) - (120 * $posts_iterated_through) - 1 ) ) ) {
156
+ $single_post->resize_and_save_image( $this->image_sizes, $this->upload_dir, $this->upload_url );
157
+ }
158
+ } else {
159
+ if ( $single_post->save_in_db( $this->transient_name, date( 'Y-m-d H:i:s', strtotime( $this->fill_in_timestamp ) - (120 * $posts_iterated_through) ) ) ) {
160
+ $single_post->resize_and_save_image( $this->image_sizes, $this->upload_dir, $this->upload_url );
161
+ }
162
+ }
163
+ }
164
+
165
+ $number_resized++;
166
+ } else {
167
+ if ( $is_top_post_feed ) {
168
+ $single_post->update_db_data( true, $this->transient_name, $this->image_sizes, $this->upload_dir, $this->upload_url, date( 'Y-m-d H:i:s', strtotime( $this->first_post_top_time_stamp ) - (120 * $posts_iterated_through) ) );
169
+ } else {
170
+ $single_post->update_db_data( true, $this->transient_name, $this->image_sizes, $this->upload_dir, $this->upload_url );
171
+ }
172
+ if ( ! $single_post->exists_in_feeds_posts_table( $this->transient_name ) ) {
173
+ $single_post->insert_sbi_instagram_feeds_posts( $this->transient_name );
174
+ }
175
+ $number_updated++;
176
+ }
177
+
178
+ $resized_image_data_for_set[ $single_instagram_post_data['id'] ] = $single_post->get_resized_image_array();
179
+ }
180
+ }
181
+
182
+ $posts_iterated_through++;
183
+ }
184
+
185
+ $this->resized_image_data_for_set = $resized_image_data_for_set;
186
+ }
187
+
188
  }
inc/class-sb-instagram-post.php CHANGED
@@ -1,547 +1,547 @@
1
- <?php
2
- /**
3
- * Class SB_Instagram_Post
4
- *
5
- * Primarily used for resizing and storing images, this class
6
- * performs certain tasks with data for a single post.
7
- *
8
- * Currently used only by the SB_Instagram_Post_Set class
9
- *
10
- * @since 2.0/4.0
11
- */
12
-
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- die( '-1' );
15
- }
16
-
17
- class SB_Instagram_Post
18
- {
19
- /**
20
- * @var string
21
- */
22
- private $instagram_post_id;
23
-
24
- /**
25
- * @var array
26
- */
27
- private $instagram_api_data;
28
-
29
- /**
30
- * @var string
31
- */
32
- private $db_id;
33
-
34
- /**
35
- * @var string
36
- */
37
- private $media_id;
38
-
39
- /**
40
- * @var string
41
- */
42
- private $top_time_stamp;
43
-
44
- /**
45
- * @var bool|int
46
- */
47
- private $images_done;
48
-
49
- /**
50
- * @var array
51
- */
52
- private $resized_image_array;
53
-
54
- /**
55
- * SB_Instagram_Post constructor.
56
- *
57
- * @param string $instagram_post_id from the Instagram API
58
- */
59
- public function __construct( $instagram_post_id ) {
60
- global $wpdb;
61
- $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
62
-
63
- $feed_id_match = $wpdb->get_results( $wpdb->prepare( "SELECT id, media_id, top_time_stamp, images_done FROM $table_name WHERE instagram_id = %s LIMIT 1", $instagram_post_id ), ARRAY_A );
64
-
65
- $this->db_id = ! empty( $feed_id_match ) ? $feed_id_match[0]['id'] : '';
66
- $this->media_id = ! empty( $feed_id_match ) ? $feed_id_match[0]['media_id'] : '';
67
- $this->top_time_stamp = ! empty( $feed_id_match ) && isset( $feed_id_match[0]['top_time_stamp'] ) ? $feed_id_match[0]['top_time_stamp'] : '';
68
- $this->images_done = ! empty( $feed_id_match ) && isset( $feed_id_match[0]['images_done'] ) ? $feed_id_match[0]['images_done'] === '1' : 0;
69
-
70
- $this->instagram_post_id = $instagram_post_id;
71
- }
72
-
73
- /**
74
- * Whether or not this post has already been saved in the custom table
75
- *
76
- * @return bool
77
- *
78
- * @since 2.0/4.0
79
- */
80
- public function exists_in_posts_table() {
81
- return ! empty( $this->db_id );
82
- }
83
-
84
- /**
85
- * Whether or not resized image files have already been recorded as being created
86
- * in the database table
87
- *
88
- * @return bool|int
89
- *
90
- * @since 2.0/4.0
91
- */
92
- public function images_done_resizing() {
93
- return $this->images_done;
94
- }
95
-
96
- /**
97
- * @param array $instagram_api_data
98
- *
99
- * @since 2.0/4.0
100
- */
101
- public function set_instagram_api_data( $instagram_api_data ) {
102
- $this->instagram_api_data = $instagram_api_data;
103
- }
104
-
105
- /**
106
- * Used for sorting top posts since they don't have a posted on date
107
- *
108
- * @return string
109
- *
110
- * @since 2.0/4.0
111
- */
112
- public function get_top_time_stamp() {
113
- return $this->top_time_stamp;
114
- }
115
-
116
- /**
117
- * Record newly created images so they can be returned and used right away.
118
- *
119
- * Not used in version 2.0/5.0 but can be used to resize and use
120
- * images "on the fly" when the feed is being displayed.
121
- *
122
- * @param string $key
123
- * @param string $val
124
- *
125
- * @since 2.0/4.0
126
- */
127
- public function add_resized_image_to_obj_array( $key, $val ) {
128
- $this->resized_image_array[ $key ] = $val;
129
- }
130
-
131
- /**
132
- * Used to save information about the post before image resizing is done to
133
- * prevent a potentially storing multiple entries for the same post
134
- *
135
- * @param mixed|string|bool $transient_name (optional)
136
- * @param null $timestamp_override (optional)
137
- *
138
- * @return bool
139
- *
140
- * @since 2.0/4.0
141
- */
142
- public function save_in_db( $transient_name = false, $timestamp_override = NULL ) {
143
- global $wpdb;
144
-
145
- $parsed_data = $this->get_parsed_post_data();
146
-
147
- $timestamp = ! empty( $timestamp_override ) && empty( $parsed_data['timestamp'] ) ? $timestamp_override : $parsed_data['timestamp'];
148
-
149
- $entry_data = array(
150
- "'" . date( 'Y-m-d H:i:s' ) . "'",
151
- "'" . esc_sql( $parsed_data['id'] ) . "'",
152
- "'" . esc_sql( $timestamp ) . "'",
153
- "'" . esc_sql( wp_json_encode( $this->instagram_api_data ) ) . "'",
154
- "'pending'",
155
- "'pending'",
156
- 0,
157
- "'".date( 'Y-m-d H:i:s' )."'"
158
- );
159
-
160
- $entry_string = implode( ',',$entry_data );
161
- $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
162
-
163
- $timestamp_column = 'time_stamp';
164
- if ( substr( $transient_name, 4, 1 ) === '+') {
165
- $timestamp_column = 'top_time_stamp';
166
- }
167
-
168
- $error = $wpdb->query( "INSERT INTO $table_name
169
- (created_on,instagram_id,$timestamp_column,json_data,media_id,sizes,images_done,last_requested) VALUES ($entry_string);" );
170
-
171
- if ( $error !== false ) {
172
- $this->db_id = $wpdb->insert_id;
173
- $this->insert_sbi_instagram_feeds_posts( $transient_name );
174
- } else {
175
- // log error
176
- }
177
-
178
- return true;
179
- }
180
-
181
- /**
182
- * Uses the post's data to get a relevant full size image url and resize it
183
- *
184
- * @param array $image_sizes
185
- * @param string $upload_dir
186
- * @param string $upload_url
187
- *
188
- * @since 2.0/4.0
189
- * @since 2.0/5.0 loop through assoc array (res setting => desired width of image) to
190
- * accommodate personal accounts and possible
191
- * custom sizes in the future
192
- */
193
- public function resize_and_save_image( $image_sizes, $upload_dir, $upload_url ) {
194
- if ( isset( $this->instagram_api_data['id'] ) ) {
195
- $image_source_set = SB_Instagram_Parse::get_media_src_set( $this->instagram_api_data );
196
- $account_type = SB_Instagram_Parse::get_account_type( $this->instagram_api_data );
197
- $image_sizes_to_make = isset( $image_sizes[ $account_type ] ) ? $image_sizes[ $account_type ] : array();
198
- // if it's a personal account or a weird url, the post id is used, otherwise the last part of the image url is used
199
- if ( $account_type === 'business' ) {
200
- $new_file_name = explode( '?', SB_Instagram_Parse::get_media_url( $this->instagram_api_data, 'lightbox' ) );
201
- if ( strlen( basename( $new_file_name[0], '.jpg' ) ) > 10 ) {
202
- $new_file_name = basename( $new_file_name[0], '.jpg' );
203
- } else {
204
- $new_file_name = $this->instagram_api_data['id'];
205
- }
206
- } else {
207
- $new_file_name = $this->instagram_api_data['id'];
208
- }
209
-
210
- // the process is considered a success if one image is successfully resized
211
- $one_successful_image_resize = false;
212
-
213
- foreach ( $image_sizes_to_make as $res_setting => $image_size ) {
214
- if ( $account_type === 'business' ) {
215
- $file_name = SB_Instagram_Parse::get_media_url( $this->instagram_api_data, 'lightbox' );
216
- } else {
217
- $file_name = isset( $image_source_set[ $image_size ] ) ? $image_source_set[ $image_size ] : SB_Instagram_Parse::get_media_url( $this->instagram_api_data, 'lightbox' );
218
- }
219
- if ( ! empty( $file_name ) ) {
220
-
221
- $sizes = array(
222
- 'height' => 1,
223
- 'width' => 1
224
- );
225
-
226
-
227
- $suffix = $res_setting;
228
-
229
- $this_image_file_name = $new_file_name . $suffix . '.jpg';
230
-
231
- $image_editor = wp_get_image_editor( $file_name );
232
-
233
- // not uncommon for the image editor to not work using it this way
234
- if ( ! is_wp_error( $image_editor ) ) {
235
- $sizes = $image_editor->get_size();
236
-
237
- $image_editor->resize( $image_size, null );
238
-
239
- $full_file_name = trailingslashit( $upload_dir ) . $this_image_file_name;
240
-
241
- $saved_image = $image_editor->save( $full_file_name );
242
-
243
- if ( ! $saved_image ) {
244
- global $sb_instagram_posts_manager;
245
-
246
- $sb_instagram_posts_manager->add_error( 'image_editor_save', array(
247
- __( 'Error saving edited image.', 'instagram-feed' ),
248
- $full_file_name
249
- ) );
250
- } else {
251
- $one_successful_image_resize = true;
252
- }
253
- } else {
254
- global $sb_instagram_posts_manager;
255
-
256
- $message = __( 'Error editing image.', 'instagram-feed' );
257
- if ( isset( $image_editor ) && isset( $image_editor->errors ) ) {
258
- foreach ( $image_editor->errors as $key => $item ) {
259
- $message .= ' ' . $key . '- ' . $item[0] . ' |';
260
- }
261
- }
262
-
263
- $sb_instagram_posts_manager->add_error( 'image_editor', array( $file_name, $message ) );
264
- }
265
-
266
- }
267
-
268
-
269
- }
270
-
271
- if ( $one_successful_image_resize ) {
272
- $aspect_ratio = round( $sizes['width'] / $sizes['height'], 2 );
273
-
274
- $this->update_sbi_instagram_posts( array(
275
- 'media_id' => $new_file_name,
276
- 'sizes' => maybe_serialize( $image_sizes_to_make ),
277
- 'aspect_ratio' => $aspect_ratio,
278
- 'images_done' => 1
279
- ) );
280
-
281
- $this->add_resized_image_to_obj_array( 'id', $new_file_name );
282
- } else {
283
- // an error status means that image resizing won't be attempted again for this post
284
- $this->update_sbi_instagram_posts( array(
285
- 'media_id' => 'error',
286
- 'sizes' => maybe_serialize( $image_sizes_to_make ),
287
- 'aspect_ratio' => 1,
288
- 'images_done' => 1
289
- ) );
290
- }
291
-
292
- }
293
- }
294
-
295
- /**
296
- * Return relevant data for resized images for this post
297
- *
298
- * @return array
299
- *
300
- * @since 2.0/4.0
301
- */
302
- public function get_resized_image_array() {
303
- if ( empty( $this->resized_image_array ) ) {
304
- global $wpdb;
305
-
306
- $posts_table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
307
- $stored = $wpdb->get_results( $wpdb->prepare( "SELECT media_id, aspect_ratio FROM $posts_table_name
308
- WHERE instagram_id = %s
309
- LIMIT 1", $this->instagram_post_id ), ARRAY_A );
310
-
311
- if ( isset( $stored[0] ) ) {
312
- $return = array(
313
- 'id' => $stored[0]['media_id'],
314
- 'ratio' => $stored[0]['aspect_ratio']
315
- );
316
- $this->resized_image_array = $return;
317
- return $return;
318
- } else {
319
- return array();
320
- }
321
- } else {
322
- return $this->resized_image_array;
323
- }
324
- }
325
-
326
- /**
327
- * Controls whether or not the database record will be updated for this post.
328
- * Called after images are successfully created.
329
- *
330
- * @param bool $update_last_requested
331
- * @param bool $transient_name
332
- * @param array $image_sizes
333
- * @param string $upload_dir
334
- * @param string $upload_url
335
- * @param bool $timestamp_for_update
336
- *
337
- * @return bool
338
- *
339
- * @since 2.0/4.0
340
- */
341
- public function update_db_data( $update_last_requested = true, $transient_name = false, $image_sizes, $upload_dir, $upload_url, $timestamp_for_update = false ) {
342
-
343
- if ( empty( $this->db_id ) ) {
344
- return false;
345
- }
346
-
347
- $to_update = array(
348
- 'json_data' => wp_json_encode( $this->instagram_api_data )
349
- );
350
-
351
- if ( $update_last_requested ) {
352
- $to_update['last_requested'] = date( 'Y-m-d H:i:s' );
353
- }
354
-
355
- if ( $timestamp_for_update ) {
356
- $to_update['top_time_stamp'] = $timestamp_for_update;
357
- }
358
-
359
- if ( $transient_name ) {
360
- $this->maybe_add_feed_id( $transient_name );
361
- }
362
-
363
- if ( $this->media_id === 'pending' ) {
364
- $this->resize_and_save_image( $image_sizes, $upload_dir, $upload_url );
365
- } else {
366
- $this->update_sbi_instagram_posts( $to_update );
367
- }
368
-
369
- return true;
370
- }
371
-
372
- /**
373
- * Updates columns that need to be updated in the posts types table.
374
- * Called after images successfully resized and if any information
375
- * needs to be updated.
376
- *
377
- * @param array $to_update assoc array of columns and values to update
378
- *
379
- * @since 2.0/4.0
380
- */
381
- public function update_sbi_instagram_posts( $to_update ) {
382
- global $wpdb;
383
- $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
384
-
385
- foreach ( $to_update as $column => $value ) {
386
- $query = $wpdb->query( $wpdb->prepare( "UPDATE $table_name
387
- SET $column = %s
388
- WHERE id = %d;", $value, $this->db_id ) );
389
-
390
- if ( $query === false ) {
391
- global $sb_instagram_posts_manager;
392
- $error = $wpdb->last_error;
393
- $query = $wpdb->last_query;
394
-
395
- $sb_instagram_posts_manager->add_error( 'database_update_post', array( __( 'Error updating post.', 'instagram-feed' ), $error . '<br><code>' . $query . '</code>' ) );
396
- }
397
- }
398
-
399
- }
400
-
401
- /**
402
- * Checks database for matching record for post and feed ID.
403
- * There shouldn't be duplicate records
404
- *
405
- * @param string $transient_name
406
- *
407
- * @return bool
408
- *
409
- * @since 2.0/4.1
410
- */
411
- public function exists_in_feeds_posts_table( $transient_name ) {
412
- global $wpdb;
413
- $table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
414
- $feed_id_array = explode( '#', $transient_name );
415
- $feed_id = $feed_id_array[0];
416
- $results = $wpdb->get_results( $wpdb->prepare( "SELECT feed_id FROM $table_name WHERE instagram_id = %s AND feed_id = %s LIMIT 1", $this->instagram_post_id, $feed_id ), ARRAY_A );
417
-
418
- return isset( $results[0]['feed_id'] );
419
- }
420
-
421
- /**
422
- * Add a record of this post being used for the specified transient name (feed id)
423
- *
424
- * @param string $transient_name
425
- *
426
- * @return int
427
- *
428
- * @since 2.0/4.0
429
- */
430
- public function insert_sbi_instagram_feeds_posts( $transient_name ) {
431
- global $wpdb;
432
- $table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
433
- // the number is removed from the transient name for backwards compatibilty.
434
- $feed_id_array = explode( '#', $transient_name );
435
- $feed_id = $feed_id_array[0];
436
-
437
- if ( ! empty( $this->db_id ) ) {
438
- $entry_data = array(
439
- $this->db_id,
440
- "'" . esc_sql( $this->instagram_api_data['id'] ) . "'",
441
- "'" . esc_sql( $feed_id ) . "'"
442
- );
443
- $entry_string = implode( ',',$entry_data );
444
-
445
- $error = $wpdb->query( "INSERT INTO $table_name
446
- (id,instagram_id,feed_id) VALUES ($entry_string);" );
447
- } else {
448
- global $sb_instagram_posts_manager;
449
-
450
- $sb_instagram_posts_manager->add_error( 'database_insert_post', array( __( 'Error inserting post.', 'instagram-feed' ), __( 'No database ID.', 'instagram-feed' ) ) );
451
- return false;
452
- }
453
-
454
-
455
- if ( $error !== false ) {
456
- return $wpdb->insert_id;
457
- } else {
458
- global $sb_instagram_posts_manager;
459
- $error = $wpdb->last_error;
460
- $query = $wpdb->last_query;
461
-
462
- $sb_instagram_posts_manager->add_error( 'database_insert_post', array( __( 'Error inserting post.', 'instagram-feed' ), $error . '<br><code>' . $query . '</code>' ) );
463
- }
464
- }
465
-
466
- /**
467
- * Uses the saved json for the post to be used for updating records
468
- *
469
- * @param bool $all
470
- *
471
- * @return array
472
- *
473
- * @since 2.0/4.0
474
- */
475
- private function get_parsed_post_data( $all = true ) {
476
-
477
- $instagram_post_id = isset( $this->instagram_api_data['id'] ) ? $this->instagram_api_data['id'] : '';
478
- $comments_count = isset( $this->instagram_api_data['comments_count'] ) ? $this->instagram_api_data['comments_count'] : '';
479
- $like_count = isset( $this->instagram_api_data['like_count'] ) ? $this->instagram_api_data['like_count'] : '';
480
-
481
- $parsed_data = array(
482
- 'comments_count' => $comments_count,
483
- 'like_count' => $like_count
484
- );
485
-
486
- if ( $all ) {
487
- $caption = isset( $this->instagram_api_data['caption'] ) ? $this->instagram_api_data['caption'] : '';
488
- $media_url = isset( $this->instagram_api_data['media_url'] ) ? $this->instagram_api_data['media_url'] : '';
489
- $media_type = isset( $this->instagram_api_data['media_type'] ) ? $this->instagram_api_data['media_type'] : '';
490
-
491
- $timestamp = '';
492
- if ( isset( $this->instagram_api_data['timestamp'] ) ) {
493
- $timestamp_parts = explode( ' ', $this->instagram_api_data['timestamp'] );
494
- $timestamp = str_replace( 'T', ' ', $timestamp_parts[0] );
495
- }
496
-
497
- $username = isset( $this->instagram_api_data['username'] ) ? $this->instagram_api_data['username'] : '';
498
- $permalink = isset( $this->instagram_api_data['permalink'] ) ? $this->instagram_api_data['permalink'] : '';
499
- $children = isset( $this->instagram_api_data['children'] ) ? wp_json_encode( $this->instagram_api_data['children'] ) : '';
500
-
501
- $parsed_data['caption'] = $caption;
502
- $parsed_data['media_url'] = $media_url;
503
- $parsed_data['id'] = $instagram_post_id;
504
- $parsed_data['media_type'] = $media_type;
505
- $parsed_data['timestamp'] = $timestamp;
506
- $parsed_data['username'] = $username;
507
- $parsed_data['permalink'] = $permalink;
508
- $parsed_data['children'] = $children;
509
- }
510
-
511
- return $parsed_data;
512
- }
513
-
514
- /**
515
- * If a record hasn't been made for this transient name/feed id,
516
- * make a record
517
- *
518
- * @param string $feed_id
519
- *
520
- * @since 2.0/4.0
521
- */
522
- private function maybe_add_feed_id( $feed_id ) {
523
-
524
- if ( empty( $this->instagram_post_id ) ) {
525
- return;
526
- }
527
-
528
- global $wpdb;
529
- $table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
530
- // the number is removed from the transient name for backwards compatibilty.
531
- $feed_id_array = explode( '#', $feed_id );
532
- $feed_id = $feed_id_array[0];
533
-
534
- $feed_id_match = $wpdb->get_col( $wpdb->prepare( "SELECT feed_id FROM $table_name WHERE feed_id = %s AND instagram_id = %s", $feed_id, $this->instagram_post_id ) );
535
-
536
- if ( ! isset( $feed_id_match[0] ) ) {
537
- $entry_data = array(
538
- $this->db_id,
539
- "'" . esc_sql( $this->instagram_post_id ) . "'",
540
- "'" . esc_sql( $feed_id ) . "'"
541
- );
542
- $entry_string = implode( ',',$entry_data );
543
- $error = $wpdb->query( "INSERT INTO $table_name
544
- (id,instagram_id,feed_id) VALUES ($entry_string);" );
545
- }
546
- }
547
  }
1
+ <?php
2
+ /**
3
+ * Class SB_Instagram_Post
4
+ *
5
+ * Primarily used for resizing and storing images, this class
6
+ * performs certain tasks with data for a single post.
7
+ *
8
+ * Currently used only by the SB_Instagram_Post_Set class
9
+ *
10
+ * @since 2.0/4.0
11
+ */
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ die( '-1' );
15
+ }
16
+
17
+ class SB_Instagram_Post
18
+ {
19
+ /**
20
+ * @var string
21
+ */
22
+ private $instagram_post_id;
23
+
24
+ /**
25
+ * @var array
26
+ */
27
+ private $instagram_api_data;
28
+
29
+ /**
30
+ * @var string
31
+ */
32
+ private $db_id;
33
+
34
+ /**
35
+ * @var string
36
+ */
37
+ private $media_id;
38
+
39
+ /**
40
+ * @var string
41
+ */
42
+ private $top_time_stamp;
43
+
44
+ /**
45
+ * @var bool|int
46
+ */
47
+ private $images_done;
48
+
49
+ /**
50
+ * @var array
51
+ */
52
+ private $resized_image_array;
53
+
54
+ /**
55
+ * SB_Instagram_Post constructor.
56
+ *
57
+ * @param string $instagram_post_id from the Instagram API
58
+ */
59
+ public function __construct( $instagram_post_id ) {
60
+ global $wpdb;
61
+ $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
62
+
63
+ $feed_id_match = $wpdb->get_results( $wpdb->prepare( "SELECT id, media_id, top_time_stamp, images_done FROM $table_name WHERE instagram_id = %s LIMIT 1", $instagram_post_id ), ARRAY_A );
64
+
65
+ $this->db_id = ! empty( $feed_id_match ) ? $feed_id_match[0]['id'] : '';
66
+ $this->media_id = ! empty( $feed_id_match ) ? $feed_id_match[0]['media_id'] : '';
67
+ $this->top_time_stamp = ! empty( $feed_id_match ) && isset( $feed_id_match[0]['top_time_stamp'] ) ? $feed_id_match[0]['top_time_stamp'] : '';
68
+ $this->images_done = ! empty( $feed_id_match ) && isset( $feed_id_match[0]['images_done'] ) ? $feed_id_match[0]['images_done'] === '1' : 0;
69
+
70
+ $this->instagram_post_id = $instagram_post_id;
71
+ }
72
+
73
+ /**
74
+ * Whether or not this post has already been saved in the custom table
75
+ *
76
+ * @return bool
77
+ *
78
+ * @since 2.0/4.0
79
+ */
80
+ public function exists_in_posts_table() {
81
+ return ! empty( $this->db_id );
82
+ }
83
+
84
+ /**
85
+ * Whether or not resized image files have already been recorded as being created
86
+ * in the database table
87
+ *
88
+ * @return bool|int
89
+ *
90
+ * @since 2.0/4.0
91
+ */
92
+ public function images_done_resizing() {
93
+ return $this->images_done;
94
+ }
95
+
96
+ /**
97
+ * @param array $instagram_api_data
98
+ *
99
+ * @since 2.0/4.0
100
+ */
101
+ public function set_instagram_api_data( $instagram_api_data ) {
102
+ $this->instagram_api_data = $instagram_api_data;
103
+ }
104
+
105
+ /**
106
+ * Used for sorting top posts since they don't have a posted on date
107
+ *
108
+ * @return string
109
+ *
110
+ * @since 2.0/4.0
111
+ */
112
+ public function get_top_time_stamp() {
113
+ return $this->top_time_stamp;
114
+ }
115
+
116
+ /**
117
+ * Record newly created images so they can be returned and used right away.
118
+ *
119
+ * Not used in version 2.0/5.0 but can be used to resize and use
120
+ * images "on the fly" when the feed is being displayed.
121
+ *
122
+ * @param string $key
123
+ * @param string $val
124
+ *
125
+ * @since 2.0/4.0
126
+ */
127
+ public function add_resized_image_to_obj_array( $key, $val ) {
128
+ $this->resized_image_array[ $key ] = $val;
129
+ }
130
+
131
+ /**
132
+ * Used to save information about the post before image resizing is done to
133
+ * prevent a potentially storing multiple entries for the same post
134
+ *
135
+ * @param mixed|string|bool $transient_name (optional)
136
+ * @param null $timestamp_override (optional)
137
+ *
138
+ * @return bool
139
+ *
140
+ * @since 2.0/4.0
141
+ */
142
+ public function save_in_db( $transient_name = false, $timestamp_override = NULL ) {
143
+ global $wpdb;
144
+
145
+ $parsed_data = $this->get_parsed_post_data();
146
+
147
+ $timestamp = ! empty( $timestamp_override ) && empty( $parsed_data['timestamp'] ) ? $timestamp_override : $parsed_data['timestamp'];
148
+
149
+ $entry_data = array(
150
+ "'" . date( 'Y-m-d H:i:s' ) . "'",
151
+ "'" . esc_sql( $parsed_data['id'] ) . "'",
152
+ "'" . esc_sql( $timestamp ) . "'",
153
+ "'" . esc_sql( wp_json_encode( $this->instagram_api_data ) ) . "'",
154
+ "'pending'",
155
+ "'pending'",
156
+ 0,
157
+ "'".date( 'Y-m-d H:i:s' )."'"
158
+ );
159
+
160
+ $entry_string = implode( ',',$entry_data );
161
+ $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
162
+
163
+ $timestamp_column = 'time_stamp';
164
+ if ( substr( $transient_name, 4, 1 ) === '+') {
165
+ $timestamp_column = 'top_time_stamp';
166
+ }
167
+
168
+ $error = $wpdb->query( "INSERT INTO $table_name
169
+ (created_on,instagram_id,$timestamp_column,json_data,media_id,sizes,images_done,last_requested) VALUES ($entry_string);" );
170
+
171
+ if ( $error !== false ) {
172
+ $this->db_id = $wpdb->insert_id;
173
+ $this->insert_sbi_instagram_feeds_posts( $transient_name );
174
+ } else {
175
+ // log error
176
+ }
177
+
178
+ return true;
179
+ }
180
+
181
+ /**
182
+ * Uses the post's data to get a relevant full size image url and resize it
183
+ *
184
+ * @param array $image_sizes
185
+ * @param string $upload_dir
186
+ * @param string $upload_url
187
+ *
188
+ * @since 2.0/4.0
189
+ * @since 2.0/5.0 loop through assoc array (res setting => desired width of image) to
190
+ * accommodate personal accounts and possible
191
+ * custom sizes in the future
192
+ */
193
+ public function resize_and_save_image( $image_sizes, $upload_dir, $upload_url ) {
194
+ if ( isset( $this->instagram_api_data['id'] ) ) {
195
+ $image_source_set = SB_Instagram_Parse::get_media_src_set( $this->instagram_api_data );
196
+ $account_type = SB_Instagram_Parse::get_account_type( $this->instagram_api_data );
197
+ $image_sizes_to_make = isset( $image_sizes[ $account_type ] ) ? $image_sizes[ $account_type ] : array();
198
+ // if it's a personal account or a weird url, the post id is used, otherwise the last part of the image url is used
199
+ if ( $account_type === 'business' ) {
200
+ $new_file_name = explode( '?', SB_Instagram_Parse::get_media_url( $this->instagram_api_data, 'lightbox' ) );
201
+ if ( strlen( basename( $new_file_name[0], '.jpg' ) ) > 10 ) {
202
+ $new_file_name = basename( $new_file_name[0], '.jpg' );
203
+ } else {
204
+ $new_file_name = $this->instagram_api_data['id'];
205
+ }
206
+ } else {
207
+ $new_file_name = $this->instagram_api_data['id'];
208
+ }
209
+
210
+ // the process is considered a success if one image is successfully resized
211
+ $one_successful_image_resize = false;
212
+
213
+ foreach ( $image_sizes_to_make as $res_setting => $image_size ) {
214
+ if ( $account_type === 'business' ) {
215
+ $file_name = SB_Instagram_Parse::get_media_url( $this->instagram_api_data, 'lightbox' );
216
+ } else {
217
+ $file_name = isset( $image_source_set[ $image_size ] ) ? $image_source_set[ $image_size ] : SB_Instagram_Parse::get_media_url( $this->instagram_api_data, 'lightbox' );
218
+ }
219
+ if ( ! empty( $file_name ) ) {
220
+
221
+ $sizes = array(
222
+ 'height' => 1,
223
+ 'width' => 1
224
+ );
225
+
226
+
227
+ $suffix = $res_setting;
228
+
229
+ $this_image_file_name = $new_file_name . $suffix . '.jpg';
230
+
231
+ $image_editor = wp_get_image_editor( $file_name );
232
+
233
+ // not uncommon for the image editor to not work using it this way
234
+ if ( ! is_wp_error( $image_editor ) ) {
235
+ $sizes = $image_editor->get_size();
236
+
237
+ $image_editor->resize( $image_size, null );
238
+
239
+ $full_file_name = trailingslashit( $upload_dir ) . $this_image_file_name;
240
+
241
+ $saved_image = $image_editor->save( $full_file_name );
242
+
243
+ if ( ! $saved_image ) {
244
+ global $sb_instagram_posts_manager;
245
+
246
+ $sb_instagram_posts_manager->add_error( 'image_editor_save', array(
247
+ __( 'Error saving edited image.', 'instagram-feed' ),
248
+ $full_file_name
249
+ ) );
250
+ } else {
251
+ $one_successful_image_resize = true;
252
+ }
253
+ } else {
254
+ global $sb_instagram_posts_manager;
255
+
256
+ $message = __( 'Error editing image.', 'instagram-feed' );
257
+ if ( isset( $image_editor ) && isset( $image_editor->errors ) ) {
258
+ foreach ( $image_editor->errors as $key => $item ) {
259
+ $message .= ' ' . $key . '- ' . $item[0] . ' |';
260
+ }
261
+ }
262
+
263
+ $sb_instagram_posts_manager->add_error( 'image_editor', array( $file_name, $message ) );
264
+ }
265
+
266
+ }
267
+
268
+
269
+ }
270
+
271
+ if ( $one_successful_image_resize ) {
272
+ $aspect_ratio = round( $sizes['width'] / $sizes['height'], 2 );
273
+
274
+ $this->update_sbi_instagram_posts( array(
275
+ 'media_id' => $new_file_name,
276
+ 'sizes' => maybe_serialize( $image_sizes_to_make ),
277
+ 'aspect_ratio' => $aspect_ratio,
278
+ 'images_done' => 1
279
+ ) );
280
+
281
+ $this->add_resized_image_to_obj_array( 'id', $new_file_name );
282
+ } else {
283
+ // an error status means that image resizing won't be attempted again for this post
284
+ $this->update_sbi_instagram_posts( array(
285
+ 'media_id' => 'error',
286
+ 'sizes' => maybe_serialize( $image_sizes_to_make ),
287
+ 'aspect_ratio' => 1,
288
+ 'images_done' => 1
289
+ ) );
290
+ }
291
+
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Return relevant data for resized images for this post
297
+ *
298
+ * @return array
299
+ *
300
+ * @since 2.0/4.0
301
+ */
302
+ public function get_resized_image_array() {
303
+ if ( empty( $this->resized_image_array ) ) {
304
+ global $wpdb;
305
+
306
+ $posts_table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
307
+ $stored = $wpdb->get_results( $wpdb->prepare( "SELECT media_id, aspect_ratio FROM $posts_table_name
308
+ WHERE instagram_id = %s
309
+ LIMIT 1", $this->instagram_post_id ), ARRAY_A );
310
+
311
+ if ( isset( $stored[0] ) ) {
312
+ $return = array(
313
+ 'id' => $stored[0]['media_id'],
314
+ 'ratio' => $stored[0]['aspect_ratio']
315
+ );
316
+ $this->resized_image_array = $return;
317
+ return $return;
318
+ } else {
319
+ return array();
320
+ }
321
+ } else {
322
+ return $this->resized_image_array;
323
+ }
324
+ }
325
+
326
+ /**
327
+ * Controls whether or not the database record will be updated for this post.
328
+ * Called after images are successfully created.
329
+ *
330
+ * @param bool $update_last_requested
331
+ * @param bool $transient_name
332
+ * @param array $image_sizes
333
+ * @param string $upload_dir
334
+ * @param string $upload_url
335
+ * @param bool $timestamp_for_update
336
+ *
337
+ * @return bool
338
+ *
339
+ * @since 2.0/4.0
340
+ */
341
+ public function update_db_data( $update_last_requested = true, $transient_name = false, $image_sizes, $upload_dir, $upload_url, $timestamp_for_update = false ) {
342
+
343
+ if ( empty( $this->db_id ) ) {
344
+ return false;
345
+ }
346
+
347
+ $to_update = array(
348
+ 'json_data' => wp_json_encode( $this->instagram_api_data )
349
+ );
350
+
351
+ if ( $update_last_requested ) {
352
+ $to_update['last_requested'] = date( 'Y-m-d H:i:s' );
353
+ }
354
+
355
+ if ( $timestamp_for_update ) {
356
+ $to_update['top_time_stamp'] = $timestamp_for_update;
357
+ }
358
+
359
+ if ( $transient_name ) {
360
+ $this->maybe_add_feed_id( $transient_name );
361
+ }
362
+
363
+ if ( $this->media_id === 'pending' ) {
364
+ $this->resize_and_save_image( $image_sizes, $upload_dir, $upload_url );
365
+ } else {
366
+ $this->update_sbi_instagram_posts( $to_update );
367
+ }
368
+
369
+ return true;
370
+ }
371
+
372
+ /**
373
+ * Updates columns that need to be updated in the posts types table.
374
+ * Called after images successfully resized and if any information
375
+ * needs to be updated.
376
+ *
377
+ * @param array $to_update assoc array of columns and values to update
378
+ *
379
+ * @since 2.0/4.0
380
+ */
381
+ public function update_sbi_instagram_posts( $to_update ) {
382
+ global $wpdb;
383
+ $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
384
+
385
+ foreach ( $to_update as $column => $value ) {
386
+ $query = $wpdb->query( $wpdb->prepare( "UPDATE $table_name
387
+ SET $column = %s
388
+ WHERE id = %d;", $value, $this->db_id ) );
389
+
390
+ if ( $query === false ) {
391
+ global $sb_instagram_posts_manager;
392
+ $error = $wpdb->last_error;
393
+ $query = $wpdb->last_query;
394
+
395
+ $sb_instagram_posts_manager->add_error( 'database_update_post', array( __( 'Error updating post.', 'instagram-feed' ), $error . '<br><code>' . $query . '</code>' ) );
396
+ }
397
+ }
398
+
399
+ }
400
+
401
+ /**
402
+ * Checks database for matching record for post and feed ID.
403
+ * There shouldn't be duplicate records
404
+ *
405
+ * @param string $transient_name
406
+ *
407
+ * @return bool
408
+ *
409
+ * @since 2.0/4.1
410
+ */
411
+ public function exists_in_feeds_posts_table( $transient_name ) {
412
+ global $wpdb;
413
+ $table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
414
+ $feed_id_array = explode( '#', $transient_name );
415
+ $feed_id = $feed_id_array[0];
416
+ $results = $wpdb->get_results( $wpdb->prepare( "SELECT feed_id FROM $table_name WHERE instagram_id = %s AND feed_id = %s LIMIT 1", $this->instagram_post_id, $feed_id ), ARRAY_A );
417
+
418
+ return isset( $results[0]['feed_id'] );
419
+ }
420
+
421
+ /**
422
+ * Add a record of this post being used for the specified transient name (feed id)
423
+ *
424
+ * @param string $transient_name
425
+ *
426
+ * @return int
427
+ *
428
+ * @since 2.0/4.0
429
+ */
430
+ public function insert_sbi_instagram_feeds_posts( $transient_name ) {
431
+ global $wpdb;
432
+ $table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
433
+ // the number is removed from the transient name for backwards compatibilty.
434
+ $feed_id_array = explode( '#', $transient_name );
435
+ $feed_id = $feed_id_array[0];
436
+
437
+ if ( ! empty( $this->db_id ) ) {
438
+ $entry_data = array(
439
+ $this->db_id,
440
+ "'" . esc_sql( $this->instagram_api_data['id'] ) . "'",
441
+ "'" . esc_sql( $feed_id ) . "'"
442
+ );
443
+ $entry_string = implode( ',',$entry_data );
444
+
445
+ $error = $wpdb->query( "INSERT INTO $table_name
446
+ (id,instagram_id,feed_id) VALUES ($entry_string);" );
447
+ } else {
448
+ global $sb_instagram_posts_manager;
449
+
450
+ $sb_instagram_posts_manager->add_error( 'database_insert_post', array( __( 'Error inserting post.', 'instagram-feed' ), __( 'No database ID.', 'instagram-feed' ) ) );
451
+ return false;
452
+ }
453
+
454
+
455
+ if ( $error !== false ) {
456
+ return $wpdb->insert_id;
457
+ } else {
458
+ global $sb_instagram_posts_manager;
459
+ $error = $wpdb->last_error;
460
+ $query = $wpdb->last_query;
461
+
462
+ $sb_instagram_posts_manager->add_error( 'database_insert_post', array( __( 'Error inserting post.', 'instagram-feed' ), $error . '<br><code>' . $query . '</code>' ) );
463
+ }
464
+ }
465
+
466
+ /**
467
+ * Uses the saved json for the post to be used for updating records
468
+ *
469
+ * @param bool $all
470
+ *
471
+ * @return array
472
+ *
473
+ * @since 2.0/4.0
474
+ */
475
+ private function get_parsed_post_data( $all = true ) {
476
+
477
+ $instagram_post_id = isset( $this->instagram_api_data['id'] ) ? $this->instagram_api_data['id'] : '';
478
+ $comments_count = isset( $this->instagram_api_data['comments_count'] ) ? $this->instagram_api_data['comments_count'] : '';
479
+ $like_count = isset( $this->instagram_api_data['like_count'] ) ? $this->instagram_api_data['like_count'] : '';
480
+
481
+ $parsed_data = array(
482
+ 'comments_count' => $comments_count,
483
+ 'like_count' => $like_count
484
+ );
485
+
486
+ if ( $all ) {
487
+ $caption = isset( $this->instagram_api_data['caption'] ) ? $this->instagram_api_data['caption'] : '';
488
+ $media_url = isset( $this->instagram_api_data['media_url'] ) ? $this->instagram_api_data['media_url'] : '';
489
+ $media_type = isset( $this->instagram_api_data['media_type'] ) ? $this->instagram_api_data['media_type'] : '';
490
+
491
+ $timestamp = '';
492
+ if ( isset( $this->instagram_api_data['timestamp'] ) ) {
493
+ $timestamp_parts = explode( ' ', $this->instagram_api_data['timestamp'] );
494
+ $timestamp = str_replace( 'T', ' ', $timestamp_parts[0] );
495
+ }
496
+
497
+ $username = isset( $this->instagram_api_data['username'] ) ? $this->instagram_api_data['username'] : '';
498
+ $permalink = isset( $this->instagram_api_data['permalink'] ) ? $this->instagram_api_data['permalink'] : '';
499
+ $children = isset( $this->instagram_api_data['children'] ) ? wp_json_encode( $this->instagram_api_data['children'] ) : '';
500
+
501
+ $parsed_data['caption'] = $caption;
502
+ $parsed_data['media_url'] = $media_url;
503
+ $parsed_data['id'] = $instagram_post_id;
504
+ $parsed_data['media_type'] = $media_type;
505
+ $parsed_data['timestamp'] = $timestamp;
506
+ $parsed_data['username'] = $username;
507
+ $parsed_data['permalink'] = $permalink;
508
+ $parsed_data['children'] = $children;
509
+ }
510
+
511
+ return $parsed_data;
512
+ }
513
+
514
+ /**
515
+ * If a record hasn't been made for this transient name/feed id,
516
+ * make a record
517
+ *
518
+ * @param string $feed_id
519
+ *
520
+ * @since 2.0/4.0
521
+ */
522
+ private function maybe_add_feed_id( $feed_id ) {
523
+
524
+ if ( empty( $this->instagram_post_id ) ) {
525
+ return;
526
+ }
527
+
528
+ global $wpdb;
529
+ $table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
530
+ // the number is removed from the transient name for backwards compatibilty.
531
+ $feed_id_array = explode( '#', $feed_id );
532
+ $feed_id = $feed_id_array[0];
533
+
534
+ $feed_id_match = $wpdb->get_col( $wpdb->prepare( "SELECT feed_id FROM $table_name WHERE feed_id = %s AND instagram_id = %s", $feed_id, $this->instagram_post_id ) );
535
+
536
+ if ( ! isset( $feed_id_match[0] ) ) {
537
+ $entry_data = array(
538
+ $this->db_id,
539
+ "'" . esc_sql( $this->instagram_post_id ) . "'",
540
+ "'" . esc_sql( $feed_id ) . "'"
541
+ );
542
+ $entry_string = implode( ',',$entry_data );
543
+ $error = $wpdb->query( "INSERT INTO $table_name
544
+ (id,instagram_id,feed_id) VALUES ($entry_string);" );
545
+ }
546
+ }
547
  }
inc/class-sb-instagram-posts-manager.php CHANGED
@@ -1,534 +1,534 @@
1
- <?php
2
- /**
3
- * Class SB_Instagram_Posts_Manager
4
- *
5
- * Set as a global object to record and report errors as well
6
- * as control aspects of image resizing
7
- *
8
- * @since 2.0/4.0
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- die( '-1' );
13
- }
14
-
15
- class SB_Instagram_Posts_Manager
16
- {
17
- /**
18
- * @var mixed|void
19
- */
20
- var $sbi_options;
21
-
22
- /**
23
- * @var int
24
- */
25
- var $limit;
26
-
27
- /**
28
- * @var array
29
- */
30
- var $errors;
31
-
32
- /**
33
- * @var array
34
- */
35
- var $frontend_errors;
36
-
37
- /**
38
- * @var bool
39
- */
40
- var $resizing_tables_exist;
41
-
42
- /**
43
- * SB_Instagram_Posts_Manager constructor.
44
- */
45
- public function __construct() {
46
- $this->sbi_options = get_option( 'sb_instagram_settings' );
47
- $this->errors = get_option( 'sb_instagram_errors', array() );
48
- $this->ajax_status = get_option( 'sb_instagram_ajax_status', array( 'tested' => false, 'successful' => false ) );
49
- $this->frontend_errors = array();
50
- }
51
-
52
- /**
53
- * @return array
54
- *
55
- * @since 2.0/5.0
56
- */
57
- public function get_ajax_status() {
58
- return $this->ajax_status;
59
- }
60
-
61
- /**
62
- * @param $to_update
63
- *
64
- * @since 2.0/5.0
65
- */
66
- public function update_ajax_status( $to_update ) {
67
- foreach ( $to_update as $key => $value ) {
68
- $this->ajax_status[ $key ] = $value;
69
- }
70
-
71
- update_option( 'sb_instagram_ajax_status', $this->ajax_status );
72
- }
73
-
74
- /**
75
- * When the plugin is first installed and used, an AJAX call to admin-ajax.php
76
- * is made to verify that it's available
77
- *
78
- * @param bool $force_check
79
- *
80
- * @return bool
81
- *
82
- * @since 2.0/5.0
83
- */
84
- public function maybe_start_ajax_test( $force_check = false ) {
85
- if ( ! $this->ajax_status['tested'] || $force_check ) {
86
- set_transient( 'sb_instagram_doing_ajax_test', 'yes', 60*60 );
87
- $this->update_ajax_status( array( 'tested' => true ) );
88
- return true;
89
- }
90
-
91
- return false;
92
- }
93
-
94
- /**
95
- * Called if a successful admin ajax request is made
96
- *
97
- * @since 2.0/5.0
98
- */
99
- public function update_successful_ajax_test() {
100
- $this->update_ajax_status( array( 'successful' => true ) );
101
- }
102
-
103
- /**
104
- * @return bool
105
- *
106
- * @since 2.0/5.0
107
- */
108
- public function should_add_ajax_test_notice() {
109
- return ($this->ajax_status['tested'] && ! $this->ajax_status['successful'] && get_transient( 'sb_instagram_doing_ajax_test' ) !== 'yes');
110
- }
111
-
112
- /**
113
- * The plugin has a limit on how many post records can be stored and
114
- * images resized to avoid overloading servers. This function deletes the post that
115
- * has the longest time passed since it was retrieved.
116
- *
117
- * @since 2.0/4.0
118
- */
119
- public function delete_least_used_image() {
120
- global $wpdb;
121
- $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
122
- $feeds_posts_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS );
123
-
124
- $max = isset( $this->limit ) && $this->limit > 1 ? $this->limit : 1;
125
-
126
- $oldest_posts = $wpdb->get_results( "SELECT id, media_id FROM $table_name ORDER BY last_requested ASC LIMIT $max", ARRAY_A );
127
-
128
- $upload = wp_upload_dir();
129
- $file_suffixes = array( 'thumb', 'low', 'full' );
130
-
131
- foreach ( $oldest_posts as $post ) {
132
-
133
- foreach ( $file_suffixes as $file_suffix ) {
134
- $file_name = trailingslashit( $upload['basedir'] ) . trailingslashit( SBI_UPLOADS_NAME ) . $post['media_id'] . $file_suffix . '.jpg';
135
- if ( is_file( $file_name ) ) {
136
- unlink( $file_name );
137
- }
138
- }
139
-
140
- $wpdb->query( $wpdb->prepare( "DELETE FROM $table_name WHERE id = %d", $post['id'] ) );
141
- $wpdb->query( $wpdb->prepare( "DELETE FROM $feeds_posts_table_name WHERE record_id = %d", $post['id'] ) );
142
- }
143
-
144
- }
145
-
146
- /**
147
- * Calculates how many records are in the database and whether or not it exceeds the limit
148
- *
149
- * @return bool
150
- *
151
- * @since 2.0/4.0
152
- */
153
- public function max_total_records_reached() {
154
- global $wpdb;
155
- $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
156
-
157
- $num_records = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
158
-
159
- if ( !isset( $this->limit ) && (int)$num_records > SBI_MAX_RECORDS ) {
160
- $this->limit = (int)$num_records - SBI_MAX_RECORDS;
161
- }
162
-
163
- return ((int)$num_records > SBI_MAX_RECORDS);
164
- }
165
-
166
- /**
167
- * The plugin caps how many new images are created in a 15 minute window to
168
- * avoid overloading servers
169
- *
170
- * @return bool
171
- *
172
- * @since 2.0/4.0
173
- */
174
- public function max_resizing_per_time_period_reached() {
175
- global $wpdb;
176
- $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
177
-
178
- $fifteen_minutes_ago = date( 'Y-m-d H:i:s', time() - 15 * 60 );
179
-
180
- $num_new_records = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name WHERE created_on > '$fifteen_minutes_ago'" );
181
-
182
- return ((int)$num_new_records > 100);
183
- }
184
-
185
- /**
186
- * @return bool
187
- *
188
- * @since 2.0/4.0
189
- */
190
- public function image_resizing_disabled() {
191
- $disable_resizing = isset( $this->sbi_options['sb_instagram_disable_resize'] ) ? $this->sbi_options['sb_instagram_disable_resize'] === 'on' || $this->sbi_options['sb_instagram_disable_resize'] === true : false;
192
-
193
- if ( ! $disable_resizing ) {
194
- $disable_resizing = isset( $this->resizing_tables_exist ) ? ! $this->resizing_tables_exist : ! $this->does_resizing_tables_exist();
195
- }
196
-
197
- return $disable_resizing;
198
- }
199
-
200
- /**
201
- * Used to skip image resizing if the tables were never successfully
202
- * created
203
- *
204
- * @return bool
205
- *
206
- * @since 2.0/5.0
207
- */
208
- public function does_resizing_tables_exist() {
209
- global $wpdb;
210
-
211
- $table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE );
212
-
213
- if ( $wpdb->get_var( "show tables like '$table_name'" ) != $table_name ) {
214
- $this->resizing_tables_exist = false;
215
-
216
- return false;
217
- }
218
-
219
- $feeds_posts_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS );
220
-
221
- if ( $wpdb->get_var( "show tables like '$feeds_posts_table_name'" ) != $feeds_posts_table_name ) {
222
- $this->resizing_tables_exist = false;
223
-
224
- return false;
225
- }
226
-
227
- return true;
228
- }
229
-
230
- /**
231
- * Resets the custom tables and deletes all image files
232
- *
233
- * @since 2.0/4.0
234
- */
235
- public function delete_all_sbi_instagram_posts() {
236
- $upload = wp_upload_dir();
237
-
238
- global $wpdb;
239
-
240
- $posts_table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
241
-
242
- $image_files = glob( trailingslashit( $upload['basedir'] ) . trailingslashit( SBI_UPLOADS_NAME ) . '*' ); // get all file names
243
- foreach ( $image_files as $file ) { // iterate files
244
- if ( is_file( $file ) ) {
245
- unlink( $file );
246
- }
247
- }
248
-
249
- $options = get_option( 'sb_instagram_settings', array() );
250
- $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
251
-
252
- foreach ( $connected_accounts as $account_id => $data ) {
253
-
254
- if ( isset( $data['local_avatar'] ) ) {
255
- $connected_accounts[ $account_id ]['local_avatar'] = false;
256
- }
257
-
258
- }
259
-
260
- $options['connected_accounts'] = $connected_accounts;
261
-
262
- update_option( 'sb_instagram_settings', $options );
263
-
264
- //Delete tables
265
- $wpdb->query( "DROP TABLE IF EXISTS $posts_table_name" );
266
-
267
- $feeds_posts_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS );
268
- $wpdb->query( "DROP TABLE IF EXISTS $feeds_posts_table_name" );
269
-
270
- $table_name = $wpdb->prefix . "options";
271
-
272
- $wpdb->query( "
273
- DELETE
274
- FROM $table_name
275
- WHERE `option_name` LIKE ('%\_transient\_\$sbi\_%')
276
- " );
277
- $wpdb->query( "
278
- DELETE
279
- FROM $table_name
280
- WHERE `option_name` LIKE ('%\_transient\_timeout\_\$sbi\_%')
281
- " );
282
- delete_option( 'sbi_hashtag_ids' );
283
-
284
- $upload = wp_upload_dir();
285
- $upload_dir = $upload['basedir'];
286
- $upload_dir = trailingslashit( $upload_dir ) . SBI_UPLOADS_NAME;
287
- if ( ! file_exists( $upload_dir ) ) {
288
- $created = wp_mkdir_p( $upload_dir );
289
- if ( $created ) {
290
- $this->remove_error( 'upload_dir' );
291
- } else {
292
- $this->add_error( 'upload_dir', array( __( 'There was an error creating the folder for storing resized images.', 'instagram-feed' ), $upload_dir ) );
293
- }
294
- } else {
295
- $this->remove_error( 'upload_dir' );
296
- }
297
-
298
- sbi_create_database_table();
299
- }
300
-
301
- /**
302
- * @return array
303
- *
304
- * @since 2.0/4.0
305
- */
306
- public function get_errors() {
307
- return $this->errors;
308
- }
309
-
310
- /**
311
- * @param $type
312
- * @param $message_array
313
- *
314
- * @since 2.0/4.0
315
- */
316
- public function add_error( $type, $message_array ) {
317
- $this->errors[ $type ] = $message_array;
318
-
319
- update_option( 'sb_instagram_errors', $this->errors, false );
320
- }
321
-
322
- /**
323
- * @param $type
324
- *
325
- * @since 2.0/4.0
326
- */
327
- public function remove_error( $type ) {
328
- if ( isset( $this->errors[ $type ] ) ) {
329
- unset( $this->errors[ $type ] );
330
-
331
- update_option( 'sb_instagram_errors', $this->errors, false );
332
- } else {
333
- delete_option( 'sb_instagram_error_page' );
334
- delete_option( 'sb_instagram_errors' );
335
- }
336
- }
337
-
338
- public function remove_all_errors() {
339
- delete_option( 'sb_instagram_errors' );
340
- delete_option( 'sb_instagram_error_page' );
341
- sb_instagram_cron_clear_cache();
342
- }
343
-
344
- public function update_error_page( $id ) {
345
- if ( $id !== 0 ) {
346
- update_option( 'sb_instagram_error_page', $id, false );
347
- }
348
- }
349
-
350
- public function get_error_page() {
351
- return get_option( 'sb_instagram_error_page', false );
352
- }
353
-
354
- /**
355
- * @param $type
356
- * @param $message
357
- *
358
- * @since 2.0/5.0
359
- */
360
- public function add_frontend_error( $type, $message ) {
361
- $this->frontend_errors = array();
362
- $this->frontend_errors[ $type ] = $message;
363
- }
364
-
365
- public function remove_frontend_error( $type ) {
366
- if ( isset( $this->frontend_errors[ $type ] ) ) {
367
- unset( $this->frontend_errors[ $type ] );
368
- }
369
- }
370
-
371
- /**
372
- * @return array
373
- *
374
- * @since 2.0/5.0
375
- */
376
- public function get_frontend_errors() {
377
- if ( isset( $this->frontend_errors['api_delay'] ) ) {
378
- return array( 'api_delay' => $this->frontend_errors['api_delay'] );
379
- }
380
- return $this->frontend_errors;
381
- }
382
-
383
- public function get_critical_errors() {
384
- $errors = $this->get_errors();
385
- $error = '';
386
- $error_100_found = false;
387
- $reconnect_instructions_needed = false;
388
- $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
389
- $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
390
- $hash = '';
391
- if ( ! empty( $errors ) && current_user_can( $cap ) ) {
392
- if ( isset( $errors['api'] ) ) {
393
- $error .= '<p>' . $errors['api'][1] . '</p>';
394
- if ( isset( $errors['api'][2] ) ) {
395
- $hash = '#' . $errors['api'][2];
396
- }
397
- } elseif ( isset( $errors['connection'] ) ) {
398
- $error .= '<p>' . $errors['connection'][1] . '</p>';
399
- if ( isset( $errors['connection'][2] ) ) {
400
- $hash = '#' . $errors['connection'][2];
401
- }
402
- } else {
403
- foreach ( $errors as $key => $value ) {
404
- if ( strpos( $key, 'at_' ) !== false ) {
405
- $reconnect_instructions_needed = true;
406
-
407
- $error = '<p>' . $value[1] . '</p>';
408
- if ( strpos( $key, 'at_100' ) !== false ) {
409
- $error_100_found = true;
410
- }
411
- }
412
- if ( isset( $value[2] ) ) {
413
- $hash = '#' . $value[2];
414
- }
415
- }
416
- }
417
- } else {
418
- return '';
419
- }
420
-
421
- foreach ( $errors as $error_key => $message ) {
422
- if ( strpos( $error_key, 'ig_no_posts_for_' ) !== false ) {
423
- if ( (int)$message[0] < (time() - 12 * 60 * 60) ) {
424
- $this->remove_error( $error_key );
425
- } else {
426
- $error .= '<p>' . $message[1] . '</p>';
427
- }
428
- } elseif ( strpos( $error_key, 'error_18' ) !== false ) {
429
- if ( (int)$message[0] < (time() - 24 * 60 * 60) ) {
430
- $this->remove_error( $error_key );
431
- } else {
432
- $error .= '<p>' . $message[1] . '</p>';
433
- }
434
- }
435
- }
436
-
437
-
438
- if ( current_user_can( $cap ) ) {
439
- if ( $reconnect_instructions_needed && ! $error_100_found ) {
440
- $on_configure_page = (is_admin() && (! isset( $_GET['tab']) || $_GET['tab'] === 'configure'));
441
- if ( $on_configure_page ) {
442
- $error .= '<p class="sbi-error-directions sbi-reconnect"><a href="https://smashballoon.com/instagram-feed/docs/errors/' . $hash . '" target="_blank" rel="noopener">' . __( 'Reconnect Account and Refresh Token', 'instagram-feed' ) . '</a></p>';
443
- } else {
444
- $link = admin_url( '?page=sb-instagram-feed' );
445
- $error .= '<p class="sbi-error-directions sbi-reconnect"><a href="'. esc_url( $link ).'" target="_blank" rel="noopener">' . __( 'Reconnect Your Account in the Admin Area', 'instagram-feed' ) . '</a></p>';
446
- }
447
- } else {
448
- $error .= '<p class="sbi-error-directions"><a href="https://smashballoon.com/instagram-feed/docs/errors/' . $hash . '" target="_blank" rel="noopener">' . __( 'Directions on How to Resolve This Issue', 'instagram-feed' ) . '</a></p>';
449
- }
450
- }
451
-
452
- // remove link to FB docs
453
- $error = str_replace( 'Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api', '', $error );
454
-
455
- return $error;
456
- }
457
-
458
- /**
459
- * @return array
460
- *
461
- * @since 2.0/5.0
462
- */
463
- public function reset_frontend_errors() {
464
- return $this->frontend_errors = array();
465
- }
466
-
467
-
468
- public function clear_hashtag_errors() {
469
- $errors = $this->get_errors();
470
-
471
- foreach ( $errors as $error_key => $message ) {
472
- if ( strpos( $error_key, 'ig_no_posts_for_' ) !== false || strpos( $error_key, 'error_18' ) !== false ) {
473
- $this->remove_error( $error_key );
474
- }
475
- }
476
- }
477
-
478
- /**
479
- * @since 2.0/5.1.2
480
- */
481
- public function add_api_request_delay( $time_in_seconds = 300, $account_id = false ) {
482
- if ( $account_id ) {
483
- set_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $account_id, '1', $time_in_seconds );
484
- } else {
485
- set_transient( SBI_USE_BACKUP_PREFIX . 'sbi_delay_requests', '1', $time_in_seconds );
486
- }
487
- }
488
-
489
- /**
490
- * @since 2.0/5.1.2
491
- */
492
- public function are_current_api_request_delays( $account_id = false ) {
493
- $is_delay = (get_transient( SBI_USE_BACKUP_PREFIX . 'sbi_delay_requests' ) !== false);
494
-
495
- if ( $is_delay ) {
496
- $this->reset_frontend_errors();
497
- $error = '<p><b>' . sprintf( __( 'Error: API requests are being delayed.', 'instagram-feed' ) ) . ' ' . __( 'New posts will not be retrieved for at least 5 minutes.', 'instagram-feed' ) . '</b></p>';
498
- $error .= $this->get_critical_errors();
499
-
500
- $this->add_frontend_error( 'api_delay', $error );
501
-
502
- }
503
-
504
- if ( ! $is_delay && $account_id ) {
505
- $is_delay = (get_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $account_id ) !== false);
506
- }
507
-
508
- return $is_delay;
509
- }
510
-
511
- public function are_critical_errors() {
512
-
513
- $critical_error_numbers = array( 100, 400, 24, 18 );
514
- $errors = $this->get_errors();
515
-
516
- $are_errors = false;
517
-
518
- foreach ( $errors as $error_key => $message ) {
519
- if ( strpos( $error_key, 'connection' ) !== false ) {
520
- $are_errors = true;
521
- } elseif ( strpos( $error_key, 'api' ) !== false ) {
522
-
523
- if ( in_array( (int)$errors['api'][2], $critical_error_numbers, true ) ) {
524
- $are_errors = true;
525
-
526
- }
527
- } elseif ( strpos( $error_key, 'at_' ) !== false ) {
528
- $are_errors = true;
529
- }
530
- }
531
-
532
- return $are_errors;
533
- }
534
  }
1
+ <?php
2
+ /**
3
+ * Class SB_Instagram_Posts_Manager
4
+ *
5
+ * Set as a global object to record and report errors as well
6
+ * as control aspects of image resizing
7
+ *
8
+ * @since 2.0/4.0
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ die( '-1' );
13
+ }
14
+
15
+ class SB_Instagram_Posts_Manager
16
+ {
17
+ /**
18
+ * @var mixed|void
19
+ */
20
+ var $sbi_options;
21
+
22
+ /**
23
+ * @var int
24
+ */
25
+ var $limit;
26
+
27
+ /**
28
+ * @var array
29
+ */
30
+ var $errors;
31
+
32
+ /**
33
+ * @var array
34
+ */
35
+ var $frontend_errors;
36
+
37
+ /**
38
+ * @var bool
39
+ */
40
+ var $resizing_tables_exist;
41
+
42
+ /**
43
+ * SB_Instagram_Posts_Manager constructor.
44
+ */
45
+ public function __construct() {
46
+ $this->sbi_options = get_option( 'sb_instagram_settings' );
47
+ $this->errors = get_option( 'sb_instagram_errors', array() );
48
+ $this->ajax_status = get_option( 'sb_instagram_ajax_status', array( 'tested' => false, 'successful' => false ) );
49
+ $this->frontend_errors = array();
50
+ }
51
+
52
+ /**
53
+ * @return array
54
+ *
55
+ * @since 2.0/5.0
56
+ */
57
+ public function get_ajax_status() {
58
+ return $this->ajax_status;
59
+ }
60
+
61
+ /**
62
+ * @param $to_update
63
+ *
64
+ * @since 2.0/5.0
65
+ */
66
+ public function update_ajax_status( $to_update ) {
67
+ foreach ( $to_update as $key => $value ) {
68
+ $this->ajax_status[ $key ] = $value;
69
+ }
70
+
71
+ update_option( 'sb_instagram_ajax_status', $this->ajax_status );
72
+ }
73
+
74
+ /**
75
+ * When the plugin is first installed and used, an AJAX call to admin-ajax.php
76
+ * is made to verify that it's available
77
+ *
78
+ * @param bool $force_check
79
+ *
80
+ * @return bool
81
+ *
82
+ * @since 2.0/5.0
83
+ */
84
+ public function maybe_start_ajax_test( $force_check = false ) {
85
+ if ( ! $this->ajax_status['tested'] || $force_check ) {
86
+ set_transient( 'sb_instagram_doing_ajax_test', 'yes', 60*60 );
87
+ $this->update_ajax_status( array( 'tested' => true ) );
88
+ return true;
89
+ }
90
+
91
+ return false;
92
+ }
93
+
94
+ /**
95
+ * Called if a successful admin ajax request is made
96
+ *
97
+ * @since 2.0/5.0
98
+ */
99
+ public function update_successful_ajax_test() {
100
+ $this->update_ajax_status( array( 'successful' => true ) );
101
+ }
102
+
103
+ /**
104
+ * @return bool
105
+ *
106
+ * @since 2.0/5.0
107
+ */
108
+ public function should_add_ajax_test_notice() {
109
+ return ($this->ajax_status['tested'] && ! $this->ajax_status['successful'] && get_transient( 'sb_instagram_doing_ajax_test' ) !== 'yes');
110
+ }
111
+
112
+ /**
113
+ * The plugin has a limit on how many post records can be stored and
114
+ * images resized to avoid overloading servers. This function deletes the post that
115
+ * has the longest time passed since it was retrieved.
116
+ *
117
+ * @since 2.0/4.0
118
+ */
119
+ public function delete_least_used_image() {
120
+ global $wpdb;
121
+ $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
122
+ $feeds_posts_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS );
123
+
124
+ $max = isset( $this->limit ) && $this->limit > 1 ? $this->limit : 1;
125
+
126
+ $oldest_posts = $wpdb->get_results( "SELECT id, media_id FROM $table_name ORDER BY last_requested ASC LIMIT $max", ARRAY_A );
127
+
128
+ $upload = wp_upload_dir();
129
+ $file_suffixes = array( 'thumb', 'low', 'full' );
130
+
131
+ foreach ( $oldest_posts as $post ) {
132
+
133
+ foreach ( $file_suffixes as $file_suffix ) {
134
+ $file_name = trailingslashit( $upload['basedir'] ) . trailingslashit( SBI_UPLOADS_NAME ) . $post['media_id'] . $file_suffix . '.jpg';
135
+ if ( is_file( $file_name ) ) {
136
+ unlink( $file_name );
137
+ }
138
+ }
139
+
140
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $table_name WHERE id = %d", $post['id'] ) );
141
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $feeds_posts_table_name WHERE record_id = %d", $post['id'] ) );
142
+ }
143
+
144
+ }
145
+
146
+ /**
147
+ * Calculates how many records are in the database and whether or not it exceeds the limit
148
+ *
149
+ * @return bool
150
+ *
151
+ * @since 2.0/4.0
152
+ */
153
+ public function max_total_records_reached() {
154
+ global $wpdb;
155
+ $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
156
+
157
+ $num_records = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
158
+
159
+ if ( !isset( $this->limit ) && (int)$num_records > SBI_MAX_RECORDS ) {
160
+ $this->limit = (int)$num_records - SBI_MAX_RECORDS;
161
+ }
162
+
163
+ return ((int)$num_records > SBI_MAX_RECORDS);
164
+ }
165
+
166
+ /**
167
+ * The plugin caps how many new images are created in a 15 minute window to
168
+ * avoid overloading servers
169
+ *
170
+ * @return bool
171
+ *
172
+ * @since 2.0/4.0
173
+ */
174
+ public function max_resizing_per_time_period_reached() {
175
+ global $wpdb;
176
+ $table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
177
+
178
+ $fifteen_minutes_ago = date( 'Y-m-d H:i:s', time() - 15 * 60 );
179
+
180
+ $num_new_records = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name WHERE created_on > '$fifteen_minutes_ago'" );
181
+
182
+ return ((int)$num_new_records > 100);
183
+ }
184
+
185
+ /**
186
+ * @return bool
187
+ *
188
+ * @since 2.0/4.0
189
+ */
190
+ public function image_resizing_disabled() {
191
+ $disable_resizing = isset( $this->sbi_options['sb_instagram_disable_resize'] ) ? $this->sbi_options['sb_instagram_disable_resize'] === 'on' || $this->sbi_options['sb_instagram_disable_resize'] === true : false;
192
+
193
+ if ( ! $disable_resizing ) {
194
+ $disable_resizing = isset( $this->resizing_tables_exist ) ? ! $this->resizing_tables_exist : ! $this->does_resizing_tables_exist();
195
+ }
196
+
197
+ return $disable_resizing;
198
+ }
199
+
200
+ /**
201
+ * Used to skip image resizing if the tables were never successfully
202
+ * created
203
+ *
204
+ * @return bool
205
+ *
206
+ * @since 2.0/5.0
207
+ */
208
+ public function does_resizing_tables_exist() {
209
+ global $wpdb;
210
+
211
+ $table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE );
212
+
213
+ if ( $wpdb->get_var( "show tables like '$table_name'" ) != $table_name ) {
214
+ $this->resizing_tables_exist = false;
215
+
216
+ return false;
217
+ }
218
+
219
+ $feeds_posts_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS );
220
+
221
+ if ( $wpdb->get_var( "show tables like '$feeds_posts_table_name'" ) != $feeds_posts_table_name ) {
222
+ $this->resizing_tables_exist = false;
223
+
224
+ return false;
225
+ }
226
+
227
+ return true;
228
+ }
229
+
230
+ /**
231
+ * Resets the custom tables and deletes all image files
232
+ *
233
+ * @since 2.0/4.0
234
+ */
235
+ public function delete_all_sbi_instagram_posts() {
236
+ $upload = wp_upload_dir();
237
+
238
+ global $wpdb;
239
+
240
+ $posts_table_name = $wpdb->prefix . SBI_INSTAGRAM_POSTS_TYPE;
241
+
242
+ $image_files = glob( trailingslashit( $upload['basedir'] ) . trailingslashit( SBI_UPLOADS_NAME ) . '*' ); // get all file names
243
+ foreach ( $image_files as $file ) { // iterate files
244
+ if ( is_file( $file ) ) {
245
+ unlink( $file );
246
+ }
247
+ }
248
+
249
+ $options = get_option( 'sb_instagram_settings', array() );
250
+ $connected_accounts = isset( $options['connected_accounts'] ) ? $options['connected_accounts'] : array();
251
+
252
+ foreach ( $connected_accounts as $account_id => $data ) {
253
+
254
+ if ( isset( $data['local_avatar'] ) ) {
255
+ $connected_accounts[ $account_id ]['local_avatar'] = false;
256
+ }
257
+
258
+ }
259
+
260
+ $options['connected_accounts'] = $connected_accounts;
261
+
262
+ update_option( 'sb_instagram_settings', $options );
263
+
264
+ //Delete tables
265
+ $wpdb->query( "DROP TABLE IF EXISTS $posts_table_name" );
266
+
267
+ $feeds_posts_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS );
268
+ $wpdb->query( "DROP TABLE IF EXISTS $feeds_posts_table_name" );
269
+
270
+ $table_name = $wpdb->prefix . "options";
271
+
272
+ $wpdb->query( "
273
+ DELETE
274
+ FROM $table_name
275
+ WHERE `option_name` LIKE ('%\_transient\_\$sbi\_%')
276
+ " );
277
+ $wpdb->query( "
278
+ DELETE
279
+ FROM $table_name
280
+ WHERE `option_name` LIKE ('%\_transient\_timeout\_\$sbi\_%')
281
+ " );
282
+ delete_option( 'sbi_hashtag_ids' );
283
+
284
+ $upload = wp_upload_dir();
285
+ $upload_dir = $upload['basedir'];
286
+ $upload_dir = trailingslashit( $upload_dir ) . SBI_UPLOADS_NAME;
287
+ if ( ! file_exists( $upload_dir ) ) {
288
+ $created = wp_mkdir_p( $upload_dir );
289
+ if ( $created ) {
290
+ $this->remove_error( 'upload_dir' );
291
+ } else {
292
+ $this->add_error( 'upload_dir', array( __( 'There was an error creating the folder for storing resized images.', 'instagram-feed' ), $upload_dir ) );
293
+ }
294
+ } else {
295
+ $this->remove_error( 'upload_dir' );
296
+ }
297
+
298
+ sbi_create_database_table();
299
+ }
300
+
301
+ /**
302
+ * @return array
303
+ *
304
+ * @since 2.0/4.0
305
+ */
306
+ public function get_errors() {
307
+ return $this->errors;
308
+ }
309
+
310
+ /**
311
+ * @param $type
312
+ * @param $message_array
313
+ *
314
+ * @since 2.0/4.0
315
+ */
316
+ public function add_error( $type, $message_array ) {
317
+ $this->errors[ $type ] = $message_array;
318
+
319
+ update_option( 'sb_instagram_errors', $this->errors, false );
320
+ }
321
+
322
+ /**
323
+ * @param $type
324
+ *
325
+ * @since 2.0/4.0
326
+ */
327
+ public function remove_error( $type ) {
328
+ if ( isset( $this->errors[ $type ] ) ) {
329
+ unset( $this->errors[ $type ] );
330
+
331
+ update_option( 'sb_instagram_errors', $this->errors, false );
332
+ } else {
333
+ delete_option( 'sb_instagram_error_page' );
334
+ delete_option( 'sb_instagram_errors' );
335
+ }
336
+ }
337
+
338
+ public function remove_all_errors() {
339
+ delete_option( 'sb_instagram_errors' );
340
+ delete_option( 'sb_instagram_error_page' );
341
+ sb_instagram_cron_clear_cache();
342
+ }
343
+
344
+ public function update_error_page( $id ) {
345
+ if ( $id !== 0 ) {
346
+ update_option( 'sb_instagram_error_page', $id, false );
347
+ }
348
+ }
349
+
350
+ public function get_error_page() {
351
+ return get_option( 'sb_instagram_error_page', false );
352
+ }
353
+
354
+ /**
355
+ * @param $type
356
+ * @param $message
357
+ *
358
+ * @since 2.0/5.0
359
+ */
360
+ public function add_frontend_error( $type, $message ) {
361
+ $this->frontend_errors = array();
362
+ $this->frontend_errors[ $type ] = $message;
363
+ }
364
+
365
+ public function remove_frontend_error( $type ) {
366
+ if ( isset( $this->frontend_errors[ $type ] ) ) {
367
+ unset( $this->frontend_errors[ $type ] );
368
+ }
369
+ }
370
+
371
+ /**
372
+ * @return array
373
+ *
374
+ * @since 2.0/5.0
375
+ */
376
+ public function get_frontend_errors() {
377
+ if ( isset( $this->frontend_errors['api_delay'] ) ) {
378
+ return array( 'api_delay' => $this->frontend_errors['api_delay'] );
379
+ }
380
+ return $this->frontend_errors;
381
+ }
382
+
383
+ public function get_critical_errors() {
384
+ $errors = $this->get_errors();
385
+ $error = '';
386
+ $error_100_found = false;
387
+ $reconnect_instructions_needed = false;
388
+ $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
389
+ $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
390
+ $hash = '';
391
+ if ( ! empty( $errors ) && current_user_can( $cap ) ) {
392
+ if ( isset( $errors['api'] ) ) {
393
+ $error .= '<p>' . $errors['api'][1] . '</p>';
394
+ if ( isset( $errors['api'][2] ) ) {
395
+ $hash = '#' . $errors['api'][2];
396
+ }
397
+ } elseif ( isset( $errors['connection'] ) ) {
398
+ $error .= '<p>' . $errors['connection'][1] . '</p>';
399
+ if ( isset( $errors['connection'][2] ) ) {
400
+ $hash = '#' . $errors['connection'][2];
401
+ }
402
+ } else {
403
+ foreach ( $errors as $key => $value ) {
404
+ if ( strpos( $key, 'at_' ) !== false ) {
405
+ $reconnect_instructions_needed = true;
406
+
407
+ $error = '<p>' . $value[1] . '</p>';
408
+ if ( strpos( $key, 'at_100' ) !== false ) {
409
+ $error_100_found = true;
410
+ }
411
+ }
412
+ if ( isset( $value[2] ) ) {
413
+ $hash = '#' . $value[2];
414
+ }
415
+ }
416
+ }
417
+ } else {
418
+ return '';
419
+ }
420
+
421
+ foreach ( $errors as $error_key => $message ) {
422
+ if ( strpos( $error_key, 'ig_no_posts_for_' ) !== false ) {
423
+ if ( (int)$message[0] < (time() - 12 * 60 * 60) ) {
424
+ $this->remove_error( $error_key );
425
+ } else {
426
+ $error .= '<p>' . $message[1] . '</p>';
427
+ }
428
+ } elseif ( strpos( $error_key, 'error_18' ) !== false ) {
429
+ if ( (int)$message[0] < (time() - 24 * 60 * 60) ) {
430
+ $this->remove_error( $error_key );
431
+ } else {
432
+ $error .= '<p>' . $message[1] . '</p>';
433
+ }
434
+ }
435
+ }
436
+
437
+
438
+ if ( current_user_can( $cap ) ) {
439
+ if ( $reconnect_instructions_needed && ! $error_100_found ) {
440
+ $on_configure_page = (is_admin() && (! isset( $_GET['tab']) || $_GET['tab'] === 'configure'));
441
+ if ( $on_configure_page ) {
442
+ $error .= '<p class="sbi-error-directions sbi-reconnect"><a href="https://smashballoon.com/instagram-feed/docs/errors/' . $hash . '" target="_blank" rel="noopener">' . __( 'Reconnect Account and Refresh Token', 'instagram-feed' ) . '</a></p>';
443
+ } else {
444
+ $link = admin_url( '?page=sb-instagram-feed' );
445
+ $error .= '<p class="sbi-error-directions sbi-reconnect"><a href="'. esc_url( $link ).'" target="_blank" rel="noopener">' . __( 'Reconnect Your Account in the Admin Area', 'instagram-feed' ) . '</a></p>';
446
+ }
447
+ } else {
448
+ $error .= '<p class="sbi-error-directions"><a href="https://smashballoon.com/instagram-feed/docs/errors/' . $hash . '" target="_blank" rel="noopener">' . __( 'Directions on How to Resolve This Issue', 'instagram-feed' ) . '</a></p>';
449
+ }
450
+ }
451
+
452
+ // remove link to FB docs
453
+ $error = str_replace( 'Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api', '', $error );
454
+
455
+ return $error;
456
+ }
457
+
458
+ /**
459
+ * @return array
460
+ *
461
+ * @since 2.0/5.0
462
+ */
463
+ public function reset_frontend_errors() {
464
+ return $this->frontend_errors = array();
465
+ }
466
+
467
+
468
+ public function clear_hashtag_errors() {
469
+ $errors = $this->get_errors();
470
+
471
+ foreach ( $errors as $error_key => $message ) {
472
+ if ( strpos( $error_key, 'ig_no_posts_for_' ) !== false || strpos( $error_key, 'error_18' ) !== false ) {
473
+ $this->remove_error( $error_key );
474
+ }
475
+ }
476
+ }
477
+
478
+ /**
479
+ * @since 2.0/5.1.2
480
+ */
481
+ public function add_api_request_delay( $time_in_seconds = 300, $account_id = false ) {
482
+ if ( $account_id ) {
483
+ set_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $account_id, '1', $time_in_seconds );
484
+ } else {
485
+ set_transient( SBI_USE_BACKUP_PREFIX . 'sbi_delay_requests', '1', $time_in_seconds );
486
+ }
487
+ }
488
+
489
+ /**
490
+ * @since 2.0/5.1.2
491
+ */
492
+ public function are_current_api_request_delays( $account_id = false ) {
493
+ $is_delay = (get_transient( SBI_USE_BACKUP_PREFIX . 'sbi_delay_requests' ) !== false);
494
+
495
+ if ( $is_delay ) {
496
+ $this->reset_frontend_errors();
497
+ $error = '<p><b>' . sprintf( __( 'Error: API requests are being delayed.', 'instagram-feed' ) ) . ' ' . __( 'New posts will not be retrieved for at least 5 minutes.', 'instagram-feed' ) . '</b></p>';
498
+ $error .= $this->get_critical_errors();
499
+
500
+ $this->add_frontend_error( 'api_delay', $error );
501
+
502
+ }
503
+
504
+ if ( ! $is_delay && $account_id ) {
505
+ $is_delay = (get_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $account_id ) !== false);
506
+ }
507
+
508
+ return $is_delay;
509
+ }
510
+
511
+ public function are_critical_errors() {
512
+
513
+ $critical_error_numbers = array( 100, 400, 24, 18 );
514
+ $errors = $this->get_errors();
515
+
516
+ $are_errors = false;
517
+
518
+ foreach ( $errors as $error_key => $message ) {
519
+ if ( strpos( $error_key, 'connection' ) !== false ) {
520
+ $are_errors = true;
521
+ } elseif ( strpos( $error_key, 'api' ) !== false ) {
522
+
523
+ if ( in_array( (int)$errors['api'][2], $critical_error_numbers, true ) ) {
524
+ $are_errors = true;
525
+
526
+ }
527
+ } elseif ( strpos( $error_key, 'at_' ) !== false ) {
528
+ $are_errors = true;
529
+ }
530
+ }
531
+
532
+ return $are_errors;
533
+ }
534
  }
inc/class-sb-instagram-settings.php CHANGED
@@ -1,616 +1,752 @@
1
- <?php
2
- /**
3
- * Class SB_Instagram_Settings
4
- *
5
- * Creates organized settings from shortcode settings and settings
6
- * from the options table.
7
- *
8
- * Also responsible for creating transient names/feed ids based on
9
- * feed settings
10
- *
11
- * @since 2.0/5.0
12
- */
13
-
14
- if ( ! defined( 'ABSPATH' ) ) {
15
- die( '-1' );
16
- }
17
-
18
- class SB_Instagram_Settings {
19
- /**
20
- * @var array
21
- */
22
- protected $atts;
23
-
24
- /**
25
- * @var array
26
- */
27
- protected $db;
28
-
29
- /**
30
- * @var array
31
- */
32
- protected $settings;
33
-
34
- /**
35
- * @var array
36
- */
37
- protected $feed_type_and_terms;
38
-
39
- /**
40
- * @var array
41
- */
42
- protected $connected_accounts;
43
-
44
- /**
45
- * @var array
46
- */
47
- protected $connected_accounts_in_feed;
48
-
49
- /**
50
- * @var string
51
- */
52
- protected $transient_name;
53
-
54
- /**
55
- * SB_Instagram_Settings constructor.
56
- *
57
- * Overwritten in the Pro version.
58
- *
59
- * @param array $atts shortcode settings
60
- * @param array $db settings from the wp_options table
61
- */
62
- public function __construct( $atts, $db ) {
63
- $this->atts = $atts;
64
- $this->db = $db;
65
-
66
- $this->connected_accounts = isset( $db['connected_accounts'] ) ? $db['connected_accounts'] : array();
67
-
68
- $this->settings = shortcode_atts(
69
- array(
70
- 'id' => isset( $db['sb_instagram_user_id'] ) ? $db['sb_instagram_user_id'] : '',
71
- 'width' => isset( $db['sb_instagram_width'] ) ? $db['sb_instagram_width'] : '',
72
- 'widthunit' => isset( $db['sb_instagram_width_unit'] ) ? $db['sb_instagram_width_unit'] : '',
73
- 'widthresp' => isset( $db['sb_instagram_feed_width_resp'] ) ? $db['sb_instagram_feed_width_resp'] : '',
74
- 'height' => isset( $db['sb_instagram_height'] ) ? $db['sb_instagram_height'] : '',
75
- 'heightunit' => isset( $db['sb_instagram_height_unit'] ) ? $db['sb_instagram_height_unit'] : '',
76
- 'sortby' => isset( $db['sb_instagram_sort'] ) ? $db['sb_instagram_sort'] : '',
77
- 'num' => isset( $db['sb_instagram_num'] ) ? $db['sb_instagram_num'] : '',
78
- 'apinum' => isset( $db['sb_instagram_minnum'] ) ? $db['sb_instagram_minnum'] : '',
79
- 'nummobile' => isset($db[ 'sb_instagram_nummobile' ]) ? $db[ 'sb_instagram_nummobile' ] : '',
80
- 'cols' => isset( $db['sb_instagram_cols'] ) ? $db['sb_instagram_cols'] : '',
81
- 'disablemobile' => isset( $db['sb_instagram_disable_mobile'] ) ? $db['sb_instagram_disable_mobile'] : '',
82
- 'imagepadding' => isset( $db['sb_instagram_image_padding'] ) ? $db['sb_instagram_image_padding'] : '',
83
- 'imagepaddingunit' => isset( $db['sb_instagram_image_padding_unit'] ) ? $db['sb_instagram_image_padding_unit'] : '',
84
- 'background' => isset( $db['sb_instagram_background'] ) ? $db['sb_instagram_background'] : '',
85
- 'showbutton' => isset( $db['sb_instagram_show_btn'] ) ? $db['sb_instagram_show_btn'] : '',
86
- 'buttoncolor' => isset( $db['sb_instagram_btn_background'] ) ? $db['sb_instagram_btn_background'] : '',
87
- 'buttontextcolor' => isset( $db['sb_instagram_btn_text_color'] ) ? $db['sb_instagram_btn_text_color'] : '',
88
- 'buttontext' => isset( $db['sb_instagram_btn_text'] ) ? $db['sb_instagram_btn_text'] : '',
89
- 'imageres' => isset( $db['sb_instagram_image_res'] ) ? $db['sb_instagram_image_res'] : '',
90
- 'showfollow' => isset( $db['sb_instagram_show_follow_btn'] ) ? $db['sb_instagram_show_follow_btn'] : '',
91
- 'followcolor' => isset( $db['sb_instagram_folow_btn_background'] ) ? $db['sb_instagram_folow_btn_background'] : '',
92
- 'followtextcolor' => isset( $db['sb_instagram_follow_btn_text_color'] ) ? $db['sb_instagram_follow_btn_text_color'] : '',
93
- 'followtext' => isset( $db['sb_instagram_follow_btn_text'] ) ? $db['sb_instagram_follow_btn_text'] : '',
94
- 'showheader' => isset( $db['sb_instagram_show_header'] ) ? $db['sb_instagram_show_header'] : '',
95
- 'headersize' => isset( $db['sb_instagram_header_size'] ) ? $db['sb_instagram_header_size'] : '',
96
- 'showbio' => isset( $db['sb_instagram_show_bio'] ) ? $db['sb_instagram_show_bio'] : '',
97
- 'custombio' => isset($db[ 'sb_instagram_custom_bio' ]) ? $db[ 'sb_instagram_custom_bio' ] : '',
98
- 'customavatar' => isset($db[ 'sb_instagram_custom_avatar' ]) ? $db[ 'sb_instagram_custom_avatar' ] : '',
99
- 'headercolor' => isset( $db['sb_instagram_header_color'] ) ? $db['sb_instagram_header_color'] : '',
100
- 'class' => '',
101
- 'ajaxtheme' => isset( $db['sb_instagram_ajax_theme'] ) ? $db['sb_instagram_ajax_theme'] : '',
102
- 'cachetime' => isset( $db['sb_instagram_cache_time'] ) ? $db['sb_instagram_cache_time'] : '',
103
- 'media' => isset( $db['sb_instagram_media_type'] ) ? $db['sb_instagram_media_type'] : '',
104
- 'headeroutside' => isset($db[ 'sb_instagram_outside_scrollable' ]) ? $db[ 'sb_instagram_outside_scrollable' ] : '',
105
- 'accesstoken' => '',
106
- 'user' => isset( $db['sb_instagram_user'] ) ? $db['sb_instagram_user'] : false,
107
- 'feedid' => isset( $db['sb_instagram_feed_id'] ) ? $db['sb_instagram_feed_id'] : false,
108
- 'resizeprocess' => isset( $db['sb_instagram_resizeprocess'] ) ? $db['sb_instagram_resizeprocess'] : 'background',
109
- 'customtemplates' => isset( $db['custom_template'] ) ? $db['custom_template'] : '',
110
-
111
- ), $atts );
112
-
113
- $this->settings['customtemplates'] = $this->settings['customtemplates'] === 'true' || $this->settings['customtemplates'] === 'on';
114
- if ( isset( $_GET['sbi_debug'] ) ) {
115
- $this->settings['customtemplates'] = false;
116
- }
117
- $this->settings['minnum'] = max( (int)$this->settings['num'], (int)$this->settings['nummobile'] );
118
- $this->settings['showbio'] = $this->settings['showbio'] === 'true' || $this->settings['showbio'] === 'on' || $this->settings['showbio'] === true;
119
- if ( isset( $atts['showbio'] ) && $atts['showbio'] === 'false' ) {
120
- $this->settings['showbio'] = false;
121
- }
122
- if ( isset( $atts['showheader'] ) && $atts['showheader'] === 'false' ) {
123
- $this->settings['showheader'] = false;
124
- }
125
- $this->settings['disable_resize'] = isset( $db['sb_instagram_disable_resize'] ) && ($db['sb_instagram_disable_resize'] === 'on');
126
- $this->settings['favor_local'] = isset( $db['sb_instagram_favor_local'] ) && ($db['sb_instagram_favor_local'] === 'on');
127
- $this->settings['backup_cache_enabled'] = ! isset( $db['sb_instagram_backup'] ) || ($db['sb_instagram_backup'] === 'on');
128
- $this->settings['font_method'] = isset( $db['sbi_font_method'] ) ? $db['sbi_font_method'] : 'svg';
129
- $this->settings['headeroutside'] = ($this->settings['headeroutside'] === true || $this->settings['headeroutside'] === 'on' || $this->settings['headeroutside'] === 'true');
130
- $this->settings['disable_js_image_loading'] = isset( $db['disable_js_image_loading'] ) && ($db['disable_js_image_loading'] === 'on');
131
- $this->settings['ajax_post_load'] = isset( $db['sb_ajax_initial'] ) && ($db['sb_ajax_initial'] === 'on');
132
-
133
- switch ( $db['sbi_cache_cron_interval'] ) {
134
- case '30mins' :
135
- $this->settings['sbi_cache_cron_interval'] = 60*30;
136
- break;
137
- case '1hour' :
138
- $this->settings['sbi_cache_cron_interval'] = 60*60;
139
- break;
140
- default :
141
- $this->settings['sbi_cache_cron_interval'] = 60*60*12;
142
- }
143
-
144
- $this->settings['sb_instagram_cache_time'] = isset( $this->db['sb_instagram_cache_time'] ) ? $this->db['sb_instagram_cache_time'] : 1;
145
- $this->settings['sb_instagram_cache_time_unit'] = isset( $this->db['sb_instagram_cache_time_unit'] ) ? $this->db['sb_instagram_cache_time_unit'] : 'hours';
146
-
147
- global $sb_instagram_posts_manager;
148
-
149
- if ( $sb_instagram_posts_manager->are_current_api_request_delays() ) {
150
- $this->settings['alwaysUseBackup'] = true;
151
- }
152
-
153
- $this->settings['isgutenberg'] = SB_Instagram_Blocks::is_gb_editor();
154
- if ( $this->settings['isgutenberg'] ) {
155
- $this->settings['ajax_post_load'] = false;
156
- $this->settings['disable_js_image_loading'] = true;
157
- }
158
- }
159
-
160
- /**
161
- * @return array
162
- *
163
- * @since 2.0/5.0
164
- */
165
- public function get_settings() {
166
- return $this->settings;
167
- }
168
-
169
- /**
170
- * The plugin will output settings on the frontend for debugging purposes.
171
- * Safe settings to display are added here.
172
- *
173
- * Overwritten in the Pro version.
174
- *
175
- * @return array
176
- *
177
- * @since 2.0/5.0
178
- */
179
- public static function get_public_db_settings_keys() {
180
- $public = array(
181
- 'sb_instagram_user_id',
182
- 'sb_instagram_cache_time',
183
- 'sb_instagram_cache_time_unit',
184
- 'sbi_caching_type',
185
- 'sbi_cache_cron_interval',
186
- 'sbi_cache_cron_time',
187
- 'sbi_cache_cron_am_pm',
188
- 'sb_instagram_width',
189
- 'sb_instagram_width_unit',
190
- 'sb_instagram_feed_width_resp',
191
- 'sb_instagram_height',
192
- 'sb_instagram_num',
193
- 'sb_instagram_height_unit',
194
- 'sb_instagram_cols',
195
- 'sb_instagram_disable_mobile',
196
- 'sb_instagram_image_padding',
197
- 'sb_instagram_image_padding_unit',
198
- 'sb_instagram_sort',
199
- 'sb_instagram_background',
200
- 'sb_instagram_show_btn',
201
- 'sb_instagram_btn_background',
202
- 'sb_instagram_btn_text_color',
203
- 'sb_instagram_btn_text',
204
- 'sb_instagram_image_res',
205
- //Header
206
- 'sb_instagram_show_header',
207
- 'sb_instagram_header_size',
208
- 'sb_instagram_header_color',
209
- //Follow button
210
- 'sb_instagram_show_follow_btn',
211
- 'sb_instagram_folow_btn_background',
212
- 'sb_instagram_follow_btn_text_color',
213
- 'sb_instagram_follow_btn_text',
214
- //Misc
215
- 'sb_instagram_cron',
216
- 'sb_instagram_backup',
217
- 'sb_instagram_ajax_theme',
218
- 'sb_instagram_disable_resize',
219
- 'disable_js_image_loading',
220
- 'enqueue_js_in_head',
221
- 'sbi_font_method',
222
- 'sb_instagram_disable_awesome',
223
- 'sb_ajax_initial',
224
- 'use_custom'
225
- );
226
-
227
- return $public;
228
- }
229
-
230
- /**
231
- * @return array
232
- *
233
- * @since 2.0/5.0
234
- */
235
- public function get_connected_accounts() {
236
- return $this->connected_accounts;
237
- }
238
-
239
- /**
240
- * @return array|bool
241
- *
242
- * @since 2.0/5.0
243
- */
244
- public function get_connected_accounts_in_feed() {
245
- if ( isset( $this->connected_accounts_in_feed ) ) {
246
- return $this->connected_accounts_in_feed;
247
- } else {
248
- return false;
249
- }
250
- }
251
-
252
- /**
253
- * @return bool|string
254
- *
255
- * @since 2.0/5.0
256
- */
257
- public function get_transient_name() {
258
- if ( isset( $this->transient_name ) ) {
259
- return $this->transient_name;
260
- } else {
261
- return false;
262
- }
263
- }
264
-
265
- /**
266
- * Uses the feed types and terms as well as as some
267
- * settings to create a semi-unique feed id used for
268
- * caching and other features.
269
- *
270
- * Overwritten in the Pro version.
271
- *
272
- * @param string $transient_name
273
- *
274
- * @since 2.0/5.0
275
- */
276
- public function set_transient_name( $transient_name = '' ) {
277
-
278
- if ( ! empty( $transient_name ) ) {
279
- $this->transient_name = $transient_name;
280
- } elseif ( ! empty( $this->settings['feedid'] ) ) {
281
- $this->transient_name = 'sbi_' . $this->settings['feedid'];
282
- } else {
283
- $feed_type_and_terms = $this->feed_type_and_terms;
284
-
285
- $sbi_transient_name = 'sbi_';
286
-
287
- if ( isset( $feed_type_and_terms['users'] ) ) {
288
- foreach ( $feed_type_and_terms['users'] as $term_and_params ) {
289
- $user = $term_and_params['term'];
290
- $connected_account = $this->connected_accounts_in_feed[ $user ];
291
- if ( isset( $connected_account['type'] ) && $connected_account['type'] === 'business' ) {
292
- $sbi_transient_name .= $connected_account['username'];
293
- } else {
294
- $sbi_transient_name .= $user;
295
- }
296
- }
297
- }
298
-
299
- $num = $this->settings['num'];
300
-
301
- $num_length = strlen( $num ) + 1;
302
-
303
- //Add both parts of the caching string together and make sure it doesn't exceed 45
304
- $sbi_transient_name = substr( $sbi_transient_name, 0, 45 - $num_length );
305
-
306
- $sbi_transient_name .= '#' . $num;
307
-
308
- $this->transient_name = $sbi_transient_name;
309
- }
310
-
311
- }
312
-
313
- /**
314
- * @return array|bool
315
- *
316
- * @since 2.0/5.0
317
- */
318
- public function get_feed_type_and_terms() {
319
- if ( isset( $this->feed_type_and_terms ) ) {
320
- return $this->feed_type_and_terms;
321
- } else {
322
- return false;
323
- }
324
- }
325
-
326
- /**
327
- * Based on the settings related to retrieving post data from the API,
328
- * this setting is used to make sure all endpoints needed for the feed are
329
- * connected and stored for easily looping through when adding posts
330
- *
331
- * Overwritten in the Pro version.
332
- *
333
- * @since 2.0/5.0
334
- */
335
- public function set_feed_type_and_terms() {
336
- global $sb_instagram_posts_manager;
337
-
338
- $connected_accounts_in_feed = array();
339
- $feed_type_and_terms = array(
340
- 'users' => array()
341
- );
342
- $usernames_included = array();
343
- $is_after_deprecation_deadline = sbi_is_after_deprecation_deadline();
344
- $is_using_access_token_in_shortcode = ! empty( $this->atts['accesstoken'] ) && strpos( $this->atts['accesstoken'], '.' ) !== false;
345
- $users_connected_to_old_api_only = array();
346
- $settings_link = '<a href="'.get_admin_url().'?page=sb-instagram-feed" target="_blank">' . __( 'plugin Settings page', 'instagram-feed' ) . '</a>';
347
-
348
- // if using an access token in the shortcode and after the deadline, try to use a connected account by collecting the user IDs
349
- if ( $is_after_deprecation_deadline && $is_using_access_token_in_shortcode ) {
350
- $error = '<p><b>' . __( 'Error: Cannot add access token directly to the shortcode.', 'instagram-feed' ) . '</b><br>' . sprintf( __( 'Due to recent Instagram platform changes, it\'s no longer possible to create a feed by adding the access token to the shortcode. Remove the access token from the shortcode and connect an account on the %s instead.', 'instagram-feed' ), $settings_link );
351
-
352
- $sb_instagram_posts_manager->add_frontend_error( 'deprecation_warning', $error );
353
-
354
- $this->settings['id'] = array();
355
- $access_tokens = explode( ',', str_replace( ' ', '', $this->atts['accesstoken'] ) );
356
-
357
- foreach ( $access_tokens as $access_token ) {
358
- $split_token = explode( '.', $access_token );
359
- $this->settings['id'][] = $split_token[0];
360
- }
361
- }
362
-
363
- if ( empty( $this->settings['id'] )
364
- && empty( $this->settings['user'] )
365
- && ! empty ( $this->connected_accounts ) ) {
366
- $set = false;
367
- foreach ( $this->connected_accounts as $connected_account ) {
368
- if ( ! $set ) {
369
- $set = true;
370
- $this->settings['user'] = $connected_account['username'];
371
- }
372
- }
373
- }
374
-
375
- if ( ! $is_after_deprecation_deadline && $is_using_access_token_in_shortcode ) {
376
- $error = '<p><b>' . __( 'Warning: Cannot add access token directly to the shortcode.', 'instagram-feed' ) . '</b><br>' . sprintf( __( 'Due to upcoming Instagram platform changes on March 31, 2020, it will no longer be possible for feeds to use access tokens directly in the shortcode. Remove the access token from the shortcode and connect an account on the %s instead.', 'instagram-feed' ), $settings_link );
377
-
378
- $sb_instagram_posts_manager->add_frontend_error( 'deprecation_warning', $error );
379
- $access_tokens = explode( ',', str_replace( ' ', '', $this->atts['accesstoken'] ) );
380
-
381
- foreach ( $access_tokens as $access_token ) {
382
- $split_token = explode( '.', $access_token );
383
- $connected_accounts_in_feed[ $split_token[0] ] = array(
384
- 'access_token' => $access_token,
385
- 'user_id' => $split_token[0]
386
- );
387
- $feed_type_and_terms['users'][] = array(
388
- 'term' => $split_token[0],
389
- 'params' => array()
390
- );
391
- }
392
-
393
- } elseif ( ! empty( $this->settings['user'] ) ) {
394
- $user_array = is_array( $this->settings['user'] ) ? $this->settings['user'] : explode( ',', str_replace( ' ', '', $this->settings['user'] ) );
395
- foreach ( $user_array as $user ) {
396
- $user_found = false;
397
- $user_for_deprecated_personal_account_only_found = false;
398
- $term_for_this_user = array();
399
- $username_to_match = $user;
400
-
401
- if ( isset( $this->connected_accounts[ $user ] ) ) {
402
- if ( ! in_array( $this->connected_accounts[ $user ]['username'], $usernames_included, true ) ) {
403
- $term_for_this_user = array(
404
- 'term' => $this->connected_accounts[ $user ]['user_id'],
405
- 'params' => array()
406
- );
407
- $connected_accounts_in_feed[ $this->connected_accounts[ $user ]['user_id'] ] = $this->connected_accounts[ $user ];
408
- $usernames_included[] = $this->connected_accounts[ $user ]['username'];
409
- $username_to_match = $this->connected_accounts[ $user ]['username'];
410
- $user_found = true;
411
- if ( ! isset( $this->connected_accounts[ $user ]['type'] ) || $this->connected_accounts[ $user ]['type'] === 'personal' ) {
412
- $user_for_deprecated_personal_account_only_found = true;
413
- }
414
- }
415
- }
416
-
417
- if ( ! $user_found || $user_for_deprecated_personal_account_only_found ) {
418
- foreach ( $this->connected_accounts as $connected_account ) {
419
- $account_type = isset( $connected_account['type'] ) ? $connected_account['type'] : 'personal';
420
- if ( strtolower( $username_to_match ) === strtolower( $connected_account['username'] ) ) {
421
- if ( $user_for_deprecated_personal_account_only_found || ! in_array( $connected_account['username'], $usernames_included, true ) ) {
422
- if ( $account_type !== 'personal' ) {
423
- $term_for_this_user = array(
424
- 'term' => $user,
425
- 'params' => array()
426
- );
427
- $connected_accounts_in_feed[ $user ] = $connected_account;
428
- $user_for_deprecated_personal_account_only_found = false;
429
- } else {
430
- $term_for_this_user = array(
431
- 'term' => $connected_account['user_id'],
432
- 'params' => array()
433
- );
434
- $connected_accounts_in_feed[ $connected_account['user_id'] ] = $connected_account;
435
- }
436
- $usernames_included[] = $connected_account['username'];
437
- $user_found = true;
438
- }
439
- }
440
- }
441
- }
442
-
443
- if ( ! empty( $term_for_this_user ) ) {
444
- $feed_type_and_terms['users'][] = $term_for_this_user;
445
- }
446
-
447
- if ( ! $user_found ) {
448
- $error = '<p><b>' . sprintf( __( 'Error: There is no connected account for the user %s.', 'instagram-feed' ), $user ) . ' ' . __( 'Feed will not update.', 'instagram-feed' ) . '</b>';
449
-
450
- $sb_instagram_posts_manager->add_frontend_error( 'no_connection_' . $user, $error );
451
- }
452
-
453
- if ( $user_for_deprecated_personal_account_only_found
454
- && ! in_array( $user, $users_connected_to_old_api_only, true ) ) {
455
- $users_connected_to_old_api_only[] = $connected_accounts_in_feed[ $user ]['username'];
456
- }
457
-
458
- }
459
-
460
- } elseif ( ! empty( $this->settings['id'] ) ) {
461
- $user_id_array = is_array( $this->settings['id'] ) ? $this->settings['id'] : explode( ',', str_replace( ' ', '', $this->settings['id'] ) );
462
-
463
- foreach ( $user_id_array as $user ) {
464
- $user_found = false;
465
- $user_for_deprecated_personal_account_only_found = false;
466
- $term_for_this_user = array();
467
- $username_to_match = '';
468
-
469
- if ( isset( $this->connected_accounts[ $user ] ) ) {
470
- if ( ! in_array( $this->connected_accounts[ $user ]['username'], $usernames_included, true ) ) {
471
- $term_for_this_user