Instagram Feed - Version 2.4.7

Version Description

  • Important: Due to recent Instagram changes, private accounts will need to be manually refreshed every 60 days. If you have a private Instagram account, consider making it public to avoid needing to manually reconnect your account.
  • New: Added a notice for accounts that are private which lets you know how long until the account needs to be refreshed. You will also be alerted using our admin notice and email notification system if a private account will soon need to be refreshed.
Download this release

Release Info

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

Code changes from version 2.4.6 to 2.4.7

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.5
6
- Stable tag: 2.4.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -325,6 +325,10 @@ 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.6 =
329
  * New: Added a PHP hook "sbi_clear_page_caches" which allows you to dynamically disable the Instagram Feed code that clears caches created by common page caching plugins.
330
  * New: Added a PHP hook "sbi_resize_url" which allows you to change the default URL of locally stored images. This can be helpful for sites using CDNs.
3
  Tags: Instagram, Instagram feed, Instagram photos, Instagram widget, Instagram gallery
4
  Requires at least: 3.4
5
  Tested up to: 5.5
6
+ Stable tag: 2.4.7
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.7 =
329
+ * Important: Due to recent Instagram changes, private accounts will need to be manually refreshed every 60 days. If you have a private Instagram account, consider making it public to avoid needing to manually reconnect your account.
330
+ * New: Added a notice for accounts that are private which lets you know how long until the account needs to be refreshed. You will also be alerted using our admin notice and email notification system if a private account will soon need to be refreshed.
331
+
332
  = 2.4.6 =
333
  * New: Added a PHP hook "sbi_clear_page_caches" which allows you to dynamically disable the Instagram Feed code that clears caches created by common page caching plugins.
334
  * New: Added a PHP hook "sbi_resize_url" which allows you to change the default URL of locally stored images. This can be helpful for sites using CDNs.
css/sb-instagram-admin.css CHANGED
@@ -7,7 +7,8 @@
7
  #sbi_admin h3{
8
  padding: 15px 0 0 0;
9
  }
10
- #sbi_admin .sbi_tooltip{
 
11
  width: 80%;
12
  display: none;
13
 
@@ -16,7 +17,7 @@
16
  font-size: 13px;
17
  background: #f9f9f9;
18
  background: rgba(255,255,255,0.8);
19
-
20
  -moz-border-radius: 8px;
21
  -webkit-border-radius: 8px;
22
  border-radius: 8px;
@@ -324,6 +325,12 @@
324
  }
325
 
326
  /* Error notice */
 
 
 
 
 
 
327
  #sbi_admin .sbi_notice{
328
  margin-top: 5px;
329
  background: #f9ecda;
@@ -361,6 +368,11 @@
361
  -webkit-border-radius: 3px;
362
  border-radius: 3px;
363
  }
 
 
 
 
 
364
 
365
  /* Update notice */
366
  .sb_instagram_notice{
@@ -630,7 +642,7 @@
630
  #sbi_admin .sbi_connected_account {
631
  position: relative;
632
  box-sizing: border-box;
633
- padding: 10px 35px 10px 10px;
634
  border-radius: 5px;
635
  background: #fff;
636
  margin-bottom: 5px;
@@ -684,6 +696,34 @@
684
  display: none;
685
  }
686
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
687
  @-webkit-keyframes sbi_flash {
688
  0% {
689
  background-color: #cae2a5;
7
  #sbi_admin h3{
8
  padding: 15px 0 0 0;
9
  }
10
+ #sbi_admin .sbi_tooltip,
11
+ #sbi_admin .sbi_extra_info{
12
  width: 80%;
13
  display: none;
14
 
17
  font-size: 13px;
18
  background: #f9f9f9;
19
  background: rgba(255,255,255,0.8);
20
+
21
  -moz-border-radius: 8px;
22
  -webkit-border-radius: 8px;
23
  border-radius: 8px;
325
  }
326
 
327
  /* Error notice */
328
+ #sbi_admin .sbi_alert,
329
+ #sbi_admin .sbi_alert .sbi_tooltip {
330
+ background: #F7E6E6;
331
+ border-color: #BA7B7B;
332
+ color: #592626;
333
+ }
334
  #sbi_admin .sbi_notice{
335
  margin-top: 5px;
336
  background: #f9ecda;
368
  -webkit-border-radius: 3px;
369
  border-radius: 3px;
370
  }
371
+ .sbi_alert {
372
+ background: #F7E6E6;
373
+ border-color: #BA7B7B;
374
+ color: #592626;
375
+ }
376
 
377
  /* Update notice */
378
  .sb_instagram_notice{
642
  #sbi_admin .sbi_connected_account {
643
  position: relative;
644
  box-sizing: border-box;
645
+ padding: 10px 86px 10px 10px;
646
  border-radius: 5px;
647
  background: #fff;
648
  margin-bottom: 5px;
696
  display: none;
697
  }
698
 
699
+ #sbi_admin .sbi_is_private .sbi_tooltip_link{
700
+ top: 1px !important;
701
+ margin: 0 -5px 0 5px;
702
+ }
703
+
704
+ .sbi_is_private {
705
+ position: relative;
706
+ display: inline-block;
707
+ border: 1px solid #ccc;
708
+ font-size: 12px;
709
+ padding: 4px 4px 4px 8px;
710
+ vertical-align: top;
711
+ margin: 4px 5px 0 0;
712
+ border-radius: 4px;
713
+
714
+ background: #fdf4e5;
715
+ border: 1px solid #e6bc88;
716
+ color: #94570c;
717
+ }
718
+ .sbi_is_private > span {
719
+ display: inline-block;
720
+ padding-top: 3px;
721
+ }
722
+ #sbi_admin .sbi_is_private a.button.button-secondary {
723
+ margin: 0 0 0 5px;
724
+ padding: 2px 6px;
725
+ }
726
+
727
  @-webkit-keyframes sbi_flash {
728
  0% {
729
  background-color: #cae2a5;
inc/admin/actions.php CHANGED
@@ -441,15 +441,28 @@ function sbi_connect_new_account( $access_token, $account_id ) {
441
  return sbi_json_encode( $updated_options['connected_accounts'][ $new_data['id'] ] );
442
 
443
  } else {
444
- if ( $basic_account_access_token_connect->is_wp_error() ) {
445
- $error = $basic_account_access_token_connect->get_wp_error();
446
- } else {
447
- $error = $basic_account_access_token_connect->get_data();
448
- }
449
- return sbi_formatted_error( $error );
 
 
 
 
 
 
 
 
 
 
 
 
450
  }
451
 
452
  } else {
 
453
  if ( $basic_account_attempt->is_wp_error() ) {
454
  $error = $basic_account_attempt->get_wp_error();
455
  } else {
@@ -733,13 +746,22 @@ function sbi_connect_basic_account( $new_account_details ) {
733
  }
734
 
735
  delete_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $new_account_details['user_id'] );
736
- global $sb_instagram_posts_manager;
 
 
 
 
 
737
 
738
- $sb_instagram_posts_manager->remove_error( 'at_' . $new_account_details['username'] );
739
  $options['connected_accounts'] = $accounts_to_save;
740
  $options['sb_instagram_user_id'] = $ids_to_save;
741
 
742
  update_option( 'sb_instagram_settings', $options );
 
 
 
 
 
743
  return $options;
744
  }
745
 
@@ -832,9 +854,12 @@ function sbi_after_connection() {
832
  }
833
  add_action( 'wp_ajax_sbi_after_connection', 'sbi_after_connection' );
834
 
835
- function sbi_account_type_display( $type ) {
836
  if ( $type === 'basic' ) {
837
- return 'personal (new API)';
 
 
 
838
  }
839
  return $type;
840
  }
@@ -907,11 +932,12 @@ add_action( 'wp_ajax_sbi_reset_log', 'sbi_reset_log' );
907
  add_action('admin_notices', 'sbi_admin_error_notices');
908
  function sbi_admin_error_notices() {
909
 
910
-
911
- if ( isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'sb-instagram-feed' )) ) {
912
  global $sb_instagram_posts_manager;
913
 
914
  $errors = $sb_instagram_posts_manager->get_errors();
 
915
  if ( ! empty( $errors ) && ( isset( $errors['database_create_posts'] ) || isset( $errors['database_create_posts_feeds'] ) || isset( $errors['upload_dir'] ) || isset( $errors['ajax'] ) ) ) : ?>
916
  <div class="notice notice-warning is-dismissible sbi-admin-notice">
917
 
441
  return sbi_json_encode( $updated_options['connected_accounts'][ $new_data['id'] ] );
442
 
443
  } else {
444
+
445
+ $token_data = $basic_account_access_token_connect->get_data();
446
+ $expires_timestamp = time() + 60 * DAY_IN_SECONDS;
447
+ $account_type = isset( $new_data['account_type'] ) ? $new_data['account_type'] : 'personal';
448
+
449
+ $new_connected_account = array(
450
+ 'access_token' => $access_token,
451
+ 'account_type' => $account_type,
452
+ 'user_id' => $new_data['id'],
453
+ 'username' => $new_data['username'],
454
+ 'expires_timestamp' => $expires_timestamp,
455
+ 'type' => 'basic',
456
+ 'private' => true
457
+ );
458
+
459
+ $updated_options = sbi_connect_basic_account( $new_connected_account );
460
+
461
+ return sbi_json_encode( $updated_options['connected_accounts'][ $new_data['id'] ] );
462
  }
463
 
464
  } else {
465
+
466
  if ( $basic_account_attempt->is_wp_error() ) {
467
  $error = $basic_account_attempt->get_wp_error();
468
  } else {
746
  }
747
 
748
  delete_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $new_account_details['user_id'] );
749
+ $refresher = new SB_Instagram_Token_Refresher( $accounts_to_save[ $new_account_details['user_id'] ] );
750
+ $refresher->attempt_token_refresh();
751
+
752
+ if ( $refresher->get_last_error_code() === 10 ) {
753
+ $accounts_to_save[ $new_account_details['user_id'] ]['private'] = true;
754
+ }
755
 
 
756
  $options['connected_accounts'] = $accounts_to_save;
757
  $options['sb_instagram_user_id'] = $ids_to_save;
758
 
759
  update_option( 'sb_instagram_settings', $options );
760
+ global $sb_instagram_posts_manager;
761
+
762
+ $sb_instagram_posts_manager->remove_error( 'at_' . $new_account_details['username'] );
763
+ $sb_instagram_posts_manager->remove_error( 'api' );
764
+ $sb_instagram_posts_manager->remove_error( 'expiration_' . $new_account_details['user_id'] );
765
  return $options;
766
  }
767
 
854
  }
855
  add_action( 'wp_ajax_sbi_after_connection', 'sbi_after_connection' );
856
 
857
+ function sbi_account_type_display( $type, $private = false ) {
858
  if ( $type === 'basic' ) {
859
+ $type = 'personal';
860
+ if ( $private ) {
861
+ $type .= ' (private)';
862
+ }
863
  }
864
  return $type;
865
  }
932
  add_action('admin_notices', 'sbi_admin_error_notices');
933
  function sbi_admin_error_notices() {
934
 
935
+ $is_reconnecting = ! empty( $_POST['sbi_account_json'] );
936
+ if ( ! $is_reconnecting && isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'sb-instagram-feed' )) ) {
937
  global $sb_instagram_posts_manager;
938
 
939
  $errors = $sb_instagram_posts_manager->get_errors();
940
+
941
  if ( ! empty( $errors ) && ( isset( $errors['database_create_posts'] ) || isset( $errors['database_create_posts_feeds'] ) || isset( $errors['upload_dir'] ) || isset( $errors['ajax'] ) ) ) : ?>
942
  <div class="notice notice-warning is-dismissible sbi-admin-notice">
943
 
inc/admin/main.php CHANGED
@@ -740,6 +740,7 @@ function sb_instagram_settings_page() {
740
  $in_user_feed = in_array( $account['user_id'], $user_feed_ids, true );
741
  $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
742
  $use_tagged = isset( $account['use_tagged'] ) && $account['use_tagged'] == '1';
 
743
 
744
  if ( empty( $profile_picture ) && $account_type === 'personal' ) {
745
  $account_update = sbi_account_data_for_token( $account['access_token'] );
@@ -779,18 +780,31 @@ function sb_instagram_settings_page() {
779
  </div>
780
 
781
  <div class="sbi_ca_username">
782
- <?php echo $profile_picture; ?>
783
- <strong><?php echo $username; ?><span><?php echo sbi_account_type_display( $account_type ); ?></span></strong>
784
  </div>
785
 
786
  <div class="sbi_ca_actions">
787
- <?php if ( ! $in_user_feed ) : ?>
788
  <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>
789
- <?php else : ?>
790
  <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>
791
- <?php endif; ?>
792
  <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>
793
  <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>
 
 
 
 
 
 
 
 
 
 
 
 
 
794
 
795
  </div>
796
 
@@ -799,16 +813,12 @@ function sb_instagram_settings_page() {
799
  <p><?php _e('Copy and paste this shortcode into your page or widget area', 'instagram-feed'); ?>:<br>
800
  <?php if ( !empty( $account['username'] ) ) : ?>
801
  <code>[instagram-feed user="<?php echo $account['username']; ?>"]</code>
802
- <?php else : ?>
803
- <code>[instagram-feed accesstoken="<?php echo $account['access_token']; ?>"]</code>
804
  <?php endif; ?>
805
  </p>
806
 
807
  <p><?php _e('To add multiple users in the same feed, simply separate them using commas', 'instagram-feed'); ?>:<br>
808
  <?php if ( !empty( $account['username'] ) ) : ?>
809
  <code>[instagram-feed user="<?php echo $account['username']; ?>, a_second_user, a_third_user"]</code>
810
- <?php else : ?>
811
- <code>[instagram-feed accesstoken="<?php echo $account['access_token']; ?>, another_access_token"]</code>
812
  <?php endif; ?>
813
 
814
  <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>
@@ -2175,7 +2185,6 @@ function sb_instagram_settings_page() {
2175
  <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 />
2176
  <code>[instagram-feed]</code><br />
2177
  <code>[instagram-feed num=4 cols=4 showfollow=false]</code><br />
2178
- <code>[instagram-feed accesstoken="ANOTHER_ACCESS_TOKEN"]</code>
2179
  </p>
2180
  <p><?php _e("See the table below for a full list of available shortcode options:", 'instagram-feed'); ?></p>
2181
 
740
  $in_user_feed = in_array( $account['user_id'], $user_feed_ids, true );
741
  $account_type = isset( $account['type'] ) ? $account['type'] : 'personal';
742
  $use_tagged = isset( $account['use_tagged'] ) && $account['use_tagged'] == '1';
743
+ $is_private = isset( $account['private'] ) && $account['private'] !== false;
744
 
745
  if ( empty( $profile_picture ) && $account_type === 'personal' ) {
746
  $account_update = sbi_account_data_for_token( $account['access_token'] );
780
  </div>
781
 
782
  <div class="sbi_ca_username">
783
+ <?php echo $profile_picture; ?>
784
+ <strong><?php echo $username; ?><span><?php echo sbi_account_type_display( $account_type, isset( $account['private'] ) ); ?></span></strong>
785
  </div>
786
 
787
  <div class="sbi_ca_actions">
788
+ <?php if ( ! $in_user_feed ) : ?>
789
  <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>
790
+ <?php else : ?>
791
  <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>
792
+ <?php endif; ?>
793
  <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>
794
  <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>
795
+ <?php if ( $is_private ) :
796
+ $expires_in = max( 0, floor( ($account['expires_timestamp'] - time()) / DAY_IN_SECONDS ) );
797
+ $message = $expires_in > 0 ? sprintf( __( 'Expires in %s days', 'instagram-feed' ), $expires_in ) : __( 'Access Token Expired', 'instagram-feed' );
798
+ $alert_class = $expires_in < 10 ? ' sbi_alert' : '';
799
+ ?>
800
+ <div class="sbi_is_private<?php echo esc_attr( $alert_class ); ?>">
801
+ <span><?php echo esc_html( $message ); ?></span>
802
+ <a class="sbi_tooltip_link sbi_tooltip_outside" href="JavaScript:void(0);" style="position: relative; top: 2px;"><i class="fa fa-question-circle" aria-hidden="true"></i></a>
803
+
804
+ <a href="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' ); ?>" class="button button-secondary"><?php _e( 'Refresh now', 'instagram-feed' ); ?></a>
805
+ </div>
806
+ <p class="sbi_tooltip sbi-more-info" style="display: none; width: 100%; box-sizing: border-box;"><?php echo sprintf( __( 'This account is a "private" account on Instagram. It needs to be manually reconnected every 60 days. %sChange this account to be "public"%s to have access tokens that are automatically refreshed.', 'instagram-feed' ), '<a href="https://help.instagram.com/116024195217477/In" target="_blank">', '</a>' ); ?></p>
807
+ <?php endif; ?>
808
 
809
  </div>
810
 
813
  <p><?php _e('Copy and paste this shortcode into your page or widget area', 'instagram-feed'); ?>:<br>
814
  <?php if ( !empty( $account['username'] ) ) : ?>
815
  <code>[instagram-feed user="<?php echo $account['username']; ?>"]</code>
 
 
816
  <?php endif; ?>
817
  </p>
818
 
819
  <p><?php _e('To add multiple users in the same feed, simply separate them using commas', 'instagram-feed'); ?>:<br>
820
  <?php if ( !empty( $account['username'] ) ) : ?>
821
  <code>[instagram-feed user="<?php echo $account['username']; ?>, a_second_user, a_third_user"]</code>
 
 
822
  <?php endif; ?>
823
 
824
  <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>
2185
  <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 />
2186
  <code>[instagram-feed]</code><br />
2187
  <code>[instagram-feed num=4 cols=4 showfollow=false]</code><br />
 
2188
  </p>
2189
  <p><?php _e("See the table below for a full list of available shortcode options:", 'instagram-feed'); ?></p>
2190
 
inc/class-sb-instagram-api-connect.php CHANGED
@@ -228,9 +228,6 @@ class SB_Instagram_API_Connect
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 {
@@ -352,7 +349,7 @@ class SB_Instagram_API_Connect
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 {
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
  $sb_instagram_posts_manager->add_frontend_error( 'at_100_' . $user_name, $error );
232
 
233
  } else {
349
 
350
  if ( $account_type === 'basic' ) {
351
  if ( $endpoint_slug === 'access_token' ) {
352
+ $url = 'https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
353
  } elseif ( $endpoint_slug === 'header' ) {
354
  $url = 'https://graph.instagram.com/me?fields=id,username,media_count&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
355
  } else {
inc/class-sb-instagram-feed.php CHANGED
@@ -48,7 +48,7 @@ class SB_Instagram_Feed
48
  /**
49
  * @var array
50
  */
51
- private $next_pages;
52
 
53
  /**
54
  * @var array
@@ -496,7 +496,7 @@ class SB_Instagram_Feed
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
  }
@@ -564,6 +564,11 @@ class SB_Instagram_Feed
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 ];
@@ -583,8 +588,14 @@ class SB_Instagram_Feed
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
  }
@@ -610,6 +621,10 @@ class SB_Instagram_Feed
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 );
@@ -625,7 +640,7 @@ class SB_Instagram_Feed
625
  $one_post_found = true;
626
 
627
  $post_set = $this->filter_posts( $data, $settings );
628
-
629
  $new_post_sets[] = $post_set;
630
  }
631
 
@@ -673,6 +688,8 @@ class SB_Instagram_Feed
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 );
@@ -743,11 +760,12 @@ class SB_Instagram_Feed
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
  }
@@ -755,6 +773,7 @@ class SB_Instagram_Feed
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 ) {
@@ -1167,6 +1186,8 @@ class SB_Instagram_Feed
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
  }
@@ -1341,11 +1362,21 @@ class SB_Instagram_Feed
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
@@ -1356,22 +1387,39 @@ class SB_Instagram_Feed
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
  }
@@ -1379,16 +1427,37 @@ class SB_Instagram_Feed
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
  }
@@ -1398,6 +1467,8 @@ class SB_Instagram_Feed
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
  *
@@ -1406,7 +1477,7 @@ class SB_Instagram_Feed
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
  }
48
  /**
49
  * @var array
50
  */
51
+ protected $next_pages;
52
 
53
  /**
54
  * @var array
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 ' . $num_existing_posts . ' ' . $num_needed_for_page ) : $this->add_report( 'have enough posts' );
500
 
501
  return ($num_existing_posts < $num_needed_for_page);
502
  }
564
  shuffle( $terms );
565
  }
566
  foreach ( $terms as $term_and_params ) {
567
+
568
+ if ( isset( $term_and_params['one_time_request'] ) ) {
569
+ $params['num'] = 200;
570
+ }
571
+
572
  $term = $term_and_params['term'];
573
  $params = array_merge( $params, $term_and_params['params'] );
574
  $connected_account_for_term = $connected_accounts_for_feed[ $term ];
588
  && SB_Instagram_Token_Refresher::minimum_time_interval_since_last_attempt_has_passed( $connected_account_for_term ) ) {
589
  $refresher = new SB_Instagram_Token_Refresher( $connected_account_for_term );
590
  $refresher->attempt_token_refresh();
591
+ if ( $refresher->get_last_error_code() === 10 ) {
592
+ sbi_update_connected_account( $connected_accounts_for_feed[ $term ]['user_id'], array( 'private' => true ) );
593
+ $this->add_report( 'token needs refreshing ' . $term . '_' . $type );
594
+ } else {
595
+ $this->add_report( 'trying to refresh token ' . $term . '_' . $type );
596
+ }
597
  }
598
+
599
  } elseif( $account_type === 'personal' && sbi_is_after_deprecation_deadline() ) {
600
  $skip_connection = true;
601
  }
621
  if ( ! $skip_connection && ! $connection->is_wp_error() && ! $connection->is_instagram_error() ) {
622
  $one_successful_connection = true;
623
 
624
+ if ( $type === 'hashtags_top' ) {
625
+ SB_Instagram_Posts_Manager::maybe_update_list_of_top_hashtags( $term_and_params['hashtag_name'] );
626
+ }
627
+
628
  $sb_instagram_posts_manager->remove_error( 'connection' );
629
  $sb_instagram_posts_manager->remove_error( 'api' );
630
  $sb_instagram_posts_manager->remove_error( 'at_' . $term );
640
  $one_post_found = true;
641
 
642
  $post_set = $this->filter_posts( $data, $settings );
643
+ $post_set['term'] = $this->get_account_term( $term_and_params );
644
  $new_post_sets[] = $post_set;
645
  }
646
 
688
  if ( isset( $data[0]['id'] ) ) {
689
  $one_post_found = true;
690
  $post_set = $this->filter_posts( $data, $settings );
691
+ $post_set['term'] = $this->get_account_term( $term_and_params );
692
+
693
  $new_post_sets[] = $post_set;
694
  }
695
  $next_page = $connection->get_next_page( $type );
760
  }
761
 
762
  $sb_instagram_posts_manager->add_frontend_error( 'at_' . $connected_account_for_term['username'], $error );
763
+ }
764
 
765
  }
766
  }
767
 
768
+
769
  if ( ! $one_successful_connection || ($one_api_request_delayed && empty( $new_post_sets )) ) {
770
  $this->should_use_backup = true;
771
  }
773
 
774
  $posts = $this->sort_posts( $posts, $settings );
775
 
776
+
777
  if ( ! empty( $this->post_data ) && is_array( $this->post_data ) ) {
778
  $posts = array_merge( $this->post_data, $posts );
779
  } elseif ( $one_post_found ) {
1186
  public function get_first_user( $feed_types_and_terms ) {
1187
  if ( isset( $feed_types_and_terms['users'][0] ) ) {
1188
  return $feed_types_and_terms['users'][0]['term'];
1189
+ } if ( isset( $feed_types_and_terms['tagged'][0] ) ) {
1190
+ return $feed_types_and_terms['tagged'][0]['term'];
1191
  } else {
1192
  return '';
1193
  }
1362
  $this->image_ids_post_set = $image_ids;
1363
  }
1364
 
1365
+ private function get_account_term( $term_and_params ) {
1366
+
1367
+ if ( isset( $term_and_params['hashtag_name'] ) ) {
1368
+ return '#' . $term_and_params['hashtag_name'];
1369
+ } else {
1370
+ return '';
1371
+ }
1372
+ }
1373
+
1374
  /**
1375
  * Uses array of API request results and merges them based on how
1376
  * the feed should be sorted. Mixed feeds are always sorted alternating
1377
  * since there is no post date for hashtag feeds.
1378
  *
1379
+ *
1380
  * @param array $post_sets an array of single API request worth
1381
  * of posts
1382
  * @param array $settings
1387
  */
1388
  private function merge_posts( $post_sets, $settings ) {
1389
  $merged_posts = array();
1390
+ if ( $settings['sortby'] === 'alternate'
1391
+ || $settings['sortby'] === 'api' && isset( $post_sets[1] ) ) {
1392
  // don't bother merging posts if there is only one post set
1393
  if ( isset( $post_sets[1] ) ) {
1394
+ $min_cycles = $settings['sortby'] === 'api' ? min( 200 / count( $post_sets ) + 5, 50 ) : max( 1, (int)$settings['minnum'] );
1395
+ $terms = array();
1396
  for( $i = 0; $i <= $min_cycles; $i++ ) {
1397
+ $ii = 0;
1398
  foreach ( $post_sets as $post_set ) {
1399
+ if ( isset( $post_sets[ $ii ]['term'] ) ) {
1400
+ if ( ! isset( $terms[ $ii ] ) ) {
1401
+ $terms[ $ii ] = $post_set['term'];
1402
+ unset( $post_sets[ $ii ]['term'] );
1403
+ }
1404
+ }
1405
  if ( isset( $post_set[ $i ] ) && isset( $post_set[ $i ]['id'] ) ) {
1406
+ $post_set[ $i ]['term'] = $terms[ $ii ];
1407
  $merged_posts[] = $post_set[ $i ];
1408
  }
1409
+ $ii++;
1410
  }
1411
  }
1412
  } else {
1413
+ if ( isset( $post_sets[0]['term'] ) ) {
1414
+ unset( $post_sets[0]['term'] );
1415
+ }
1416
  $merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
1417
  }
1418
  } elseif ( $settings['sortby'] === 'api' ) {
1419
  if ( isset( $post_sets[0] ) ) {
1420
+ if ( isset( $post_sets[0]['term'] ) ) {
1421
+ unset( $post_sets[0]['term'] );
1422
+ }
1423
  foreach ( $post_sets as $post_set ) {
1424
  $merged_posts = array_merge( $merged_posts, $post_set );
1425
  }
1427
  } else {
1428
  // don't bother merging posts if there is only one post set
1429
  if ( isset( $post_sets[1] ) ) {
1430
+
1431
+ $terms = array();
1432
+ $ii = 0;
1433
  foreach ( $post_sets as $post_set ) {
1434
  if ( isset( $post_set[0]['id'] ) ) {
1435
+ if ( isset( $post_sets[ $ii ]['term'] ) ) {
1436
+ if ( ! isset( $terms[ $ii ] ) ) {
1437
+ $terms[ $ii ] = $post_set['term'];
1438
+ }
1439
+ unset( $post_sets[ $ii ]['term'] );
1440
+ $iii = 0;
1441
+ foreach ( $post_sets[ $ii ] as $post ) {
1442
+ $post_sets[ $ii ][ $iii ]['term'] = $terms[ $ii ];
1443
+ $iii++;
1444
+ }
1445
+ }
1446
+ $merged_posts = array_merge( $merged_posts, $post_sets[ $ii ] );
1447
+ $ii++;
1448
  }
1449
  }
1450
  } else {
1451
+ if ( isset( $post_sets[0]['term'] ) ) {
1452
+ unset( $post_sets[0]['term'] );
1453
+ }
1454
  $merged_posts = isset( $post_sets[0] ) ? $post_sets[0] : array();
1455
  }
1456
  }
1457
 
1458
+ if ( isset( $merged_posts['term'] ) ) {
1459
+ unset( $merged_posts['term'] );
1460
+ }
1461
 
1462
  return $merged_posts;
1463
  }
1467
  * is done when merging posts for efficiency's sake so the post set is
1468
  * just returned as it is.
1469
  *
1470
+ * Overwritten in the Pro version.
1471
+ *
1472
  * @param array $post_set
1473
  * @param array $settings
1474
  *
1477
  * @since 2.0/5.0
1478
  * @since 2.1/5.2 added filter hook for applying custom sorting
1479
  */
1480
+ protected function sort_posts( $post_set, $settings ) {
1481
  if ( empty( $post_set ) ) {
1482
  return $post_set;
1483
  }
inc/class-sb-instagram-parse.php CHANGED
@@ -268,10 +268,10 @@ class SB_Instagram_Parse
268
  public static function get_name( $header_data ) {
269
  if ( isset( $header_data['name'] ) ) {
270
  return $header_data['name'];
271
- } elseif ( isset( $header_data['data'] ) ) {
272
  return $header_data['data']['full_name'];
273
  }
274
- return '';
275
  }
276
 
277
  /**
268
  public static function get_name( $header_data ) {
269
  if ( isset( $header_data['name'] ) ) {
270
  return $header_data['name'];
271
+ } elseif ( isset( $header_data['data']['full_name'] ) ) {
272
  return $header_data['data']['full_name'];
273
  }
274
+ return SB_Instagram_Parse::get_username( $header_data );
275
  }
276
 
277
  /**
inc/class-sb-instagram-post.php CHANGED
@@ -150,6 +150,7 @@ class SB_Instagram_Post
150
  "'" . date( 'Y-m-d H:i:s' ) . "'",
151
  "'" . esc_sql( $parsed_data['id'] ) . "'",
152
  "'" . esc_sql( $timestamp ) . "'",
 
153
  "'" . esc_sql( sbi_json_encode( $this->instagram_api_data ) ) . "'",
154
  "'pending'",
155
  "'pending'",
@@ -166,7 +167,7 @@ class SB_Instagram_Post
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;
@@ -210,8 +211,6 @@ class SB_Instagram_Post
210
  // the process is considered a success if one image is successfully resized
211
  $one_successful_image_resize = false;
212
 
213
- $ratio = 1;
214
-
215
  foreach ( $image_sizes_to_make as $res_setting => $image_size ) {
216
  if ( $account_type === 'business' ) {
217
  $file_name = SB_Instagram_Parse::get_media_url( $this->instagram_api_data, 'lightbox' );
@@ -220,6 +219,10 @@ class SB_Instagram_Post
220
  }
221
  if ( ! empty( $file_name ) ) {
222
 
 
 
 
 
223
 
224
 
225
  $suffix = $res_setting;
@@ -230,9 +233,7 @@ class SB_Instagram_Post
230
 
231
  // not uncommon for the image editor to not work using it this way
232
  if ( ! is_wp_error( $image_editor ) ) {
233
- $old_sizes = $image_editor->get_size();
234
-
235
- $ratio = $old_sizes['width'] / $old_sizes['height'];
236
 
237
  $image_editor->resize( $image_size, null );
238
 
@@ -265,10 +266,11 @@ class SB_Instagram_Post
265
 
266
  }
267
 
 
268
  }
269
 
270
  if ( $one_successful_image_resize ) {
271
- $aspect_ratio = round( $ratio, 2 );
272
 
273
  $this->update_sbi_instagram_posts( array(
274
  'media_id' => $new_file_name,
@@ -528,7 +530,7 @@ class SB_Instagram_Post
528
  $table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
529
  // the number is removed from the transient name for backwards compatibilty.
530
  $feed_id_array = explode( '#', $feed_id );
531
- $feed_id = $feed_id_array[0];
532
 
533
  $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 ) );
534
 
150
  "'" . date( 'Y-m-d H:i:s' ) . "'",
151
  "'" . esc_sql( $parsed_data['id'] ) . "'",
152
  "'" . esc_sql( $timestamp ) . "'",
153
+ "'" . esc_sql( $timestamp ) . "'",
154
  "'" . esc_sql( sbi_json_encode( $this->instagram_api_data ) ) . "'",
155
  "'pending'",
156
  "'pending'",
167
  }
168
 
169
  $error = $wpdb->query( "INSERT INTO $table_name
170
+ (created_on,instagram_id,time_stamp,top_time_stamp,json_data,media_id,sizes,images_done,last_requested) VALUES ($entry_string);" );
171
 
172
  if ( $error !== false ) {
173
  $this->db_id = $wpdb->insert_id;
211
  // the process is considered a success if one image is successfully resized
212
  $one_successful_image_resize = false;
213
 
 
 
214
  foreach ( $image_sizes_to_make as $res_setting => $image_size ) {
215
  if ( $account_type === 'business' ) {
216
  $file_name = SB_Instagram_Parse::get_media_url( $this->instagram_api_data, 'lightbox' );
219
  }
220
  if ( ! empty( $file_name ) ) {
221
 
222
+ $sizes = array(
223
+ 'height' => 1,
224
+ 'width' => 1
225
+ );
226
 
227
 
228
  $suffix = $res_setting;
233
 
234
  // not uncommon for the image editor to not work using it this way
235
  if ( ! is_wp_error( $image_editor ) ) {
236
+ $sizes = $image_editor->get_size();
 
 
237
 
238
  $image_editor->resize( $image_size, null );
239
 
266
 
267
  }
268
 
269
+
270
  }
271
 
272
  if ( $one_successful_image_resize ) {
273
+ $aspect_ratio = round( $sizes['width'] / $sizes['height'], 2 );
274
 
275
  $this->update_sbi_instagram_posts( array(
276
  'media_id' => $new_file_name,
530
  $table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
531
  // the number is removed from the transient name for backwards compatibilty.
532
  $feed_id_array = explode( '#', $feed_id );
533
+ $feed_id = str_replace( '+', '', $feed_id_array[0] );
534
 
535
  $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 ) );
536
 
inc/class-sb-instagram-posts-manager.php CHANGED
@@ -298,6 +298,22 @@ class SB_Instagram_Posts_Manager
298
  sbi_create_database_table();
299
  }
300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  /**
302
  * @return array
303
  *
@@ -330,14 +346,29 @@ class SB_Instagram_Posts_Manager
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
 
@@ -408,6 +439,10 @@ class SB_Instagram_Posts_Manager
408
  if ( strpos( $key, 'at_100' ) !== false ) {
409
  $error_100_found = true;
410
  }
 
 
 
 
411
  }
412
  if ( isset( $value[2] ) ) {
413
  $hash = '#' . $value[2];
@@ -505,6 +540,8 @@ class SB_Instagram_Posts_Manager
505
  $is_delay = (get_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $account_id ) !== false);
506
  }
507
 
 
 
508
  return $is_delay;
509
  }
510
 
@@ -526,6 +563,8 @@ class SB_Instagram_Posts_Manager
526
  }
527
  } elseif ( strpos( $error_key, 'at_' ) !== false ) {
528
  $are_errors = true;
 
 
529
  }
530
  }
531
 
298
  sbi_create_database_table();
299
  }
300
 
301
+ public static function top_post_request_already_made( $hashtag ) {
302
+ $list_of_top_hashtags = get_option( 'sbi_top_api_calls', array() );
303
+
304
+ return in_array( $hashtag, $list_of_top_hashtags, true );
305
+ }
306
+
307
+ public static function maybe_update_list_of_top_hashtags( $hashtag ) {
308
+ $list_of_top_hashtags = get_option( 'sbi_top_api_calls', array() );
309
+
310
+ if ( ! in_array( $hashtag, $list_of_top_hashtags, true ) ) {
311
+ $list_of_top_hashtags[] = $hashtag;
312
+ update_option( 'sbi_top_api_calls', $list_of_top_hashtags );
313
+ }
314
+
315
+ }
316
+
317
  /**
318
  * @return array
319
  *
346
 
347
  update_option( 'sb_instagram_errors', $this->errors, false );
348
  } else {
349
+
350
+ foreach ( $this->errors as $type => $error ) {
351
+ if ( strpos( $type, 'expiration_' ) !== false ) {
352
+ unset( $this->errors[ $type ] );
353
+ }
354
+ }
355
+
356
  delete_option( 'sb_instagram_error_page' );
357
+ update_option( 'sb_instagram_errors', $this->errors, false );
358
  }
359
  }
360
 
361
  public function remove_all_errors() {
362
+ if ( empty( $this->errors ) ) {
363
+ return;
364
+ }
365
+ foreach ( $this->errors as $type => $error ) {
366
+ if ( strpos( $type, 'expiration_' ) !== false ) {
367
+ unset( $this->errors[ $type ] );
368
+ }
369
+ }
370
  delete_option( 'sb_instagram_error_page' );
371
+ update_option( 'sb_instagram_errors', $this->errors, false );
372
  sb_instagram_cron_clear_cache();
373
  }
374
 
439
  if ( strpos( $key, 'at_100' ) !== false ) {
440
  $error_100_found = true;
441
  }
442
+ } elseif ( strpos( $key, 'expiration_' ) !== false ) {
443
+ $reconnect_instructions_needed = true;
444
+
445
+ $error = '<p>' . $value[1] . '</p>';
446
  }
447
  if ( isset( $value[2] ) ) {
448
  $hash = '#' . $value[2];
540
  $is_delay = (get_transient( SBI_USE_BACKUP_PREFIX . 'sbi_' . $account_id ) !== false);
541
  }
542
 
543
+ $is_delay = apply_filters( 'sbi_is_api_delay', $is_delay );
544
+
545
  return $is_delay;
546
  }
547
 
563
  }
564
  } elseif ( strpos( $error_key, 'at_' ) !== false ) {
565
  $are_errors = true;
566
+ } elseif ( strpos( $error_key, 'expiration_' ) !== false ) {
567
+ $are_errors = true;
568
  }
569
  }
570
 
inc/class-sb-instagram-settings.php CHANGED
@@ -360,8 +360,20 @@ class SB_Instagram_Settings {
360
  }
361
  }
362
 
 
 
 
 
 
 
 
 
 
 
 
 
363
  if ( ! $is_after_deprecation_deadline && $is_using_access_token_in_shortcode ) {
364
- $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 );
365
 
366
  $sb_instagram_posts_manager->add_frontend_error( 'deprecation_warning', $error );
367
  $access_tokens = explode( ',', str_replace( ' ', '', $this->atts['accesstoken'] ) );
@@ -399,21 +411,67 @@ class SB_Instagram_Settings {
399
  if ( ! isset( $this->connected_accounts[ $user ]['type'] ) || $this->connected_accounts[ $user ]['type'] === 'personal' ) {
400
  $user_for_deprecated_personal_account_only_found = true;
401
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
402
  }
403
  }
404
 
405
  if ( ! $user_found || $user_for_deprecated_personal_account_only_found ) {
 
406
  foreach ( $this->connected_accounts as $connected_account ) {
407
  $account_type = isset( $connected_account['type'] ) ? $connected_account['type'] : 'personal';
408
  if ( strtolower( $username_to_match ) === strtolower( $connected_account['username'] ) ) {
 
409
  if ( $user_for_deprecated_personal_account_only_found || ! in_array( $connected_account['username'], $usernames_included, true ) ) {
410
  if ( $account_type !== 'personal' ) {
 
411
  $term_for_this_user = array(
412
  'term' => $user,
413
  'params' => array()
414
  );
415
  $connected_accounts_in_feed[ $user ] = $connected_account;
416
  $user_for_deprecated_personal_account_only_found = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  } else {
418
  $term_for_this_user = array(
419
  'term' => $connected_account['user_id'],
@@ -464,6 +522,28 @@ class SB_Instagram_Settings {
464
  if ( ! in_array( $this->connected_accounts[ $user ]['username'], $usernames_included, true ) ) {
465
  $usernames_included[] = $this->connected_accounts[ $user ]['username'];
466
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  $username_to_match = $this->connected_accounts[ $user ]['username'];
468
  $user_found = true;
469
  if ( ! isset( $this->connected_accounts[ $user ]['type'] ) || $this->connected_accounts[ $user ]['type'] === 'personal' ) {
@@ -494,6 +574,7 @@ class SB_Instagram_Settings {
494
  'params' => array()
495
  );
496
  $connected_accounts_in_feed[ $connected_account['user_id'] ] = $connected_account;
 
497
  }
498
  if ( ! in_array( $connected_account['username'], $usernames_included, true ) ) {
499
  $usernames_included[] = $connected_account['username'];
@@ -539,6 +620,27 @@ class SB_Instagram_Settings {
539
  'params' => array()
540
  );
541
  $connected_accounts_in_feed[ $connected_account['user_id'] ] = $connected_account;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
542
  }
543
  }
544
 
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 June 1, 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'] ) );
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
+ if ( isset( $this->connected_accounts[ $user ]['private'] ) && sbi_private_account_near_expiration( $this->connected_accounts[ $user ] ) ) {
416
+ $link_1 = '<a href="https://help.instagram.com/116024195217477/In">';
417
+ $link_2 = '</a>';
418
+ $sb_instagram_posts_manager->add_error( 'expiration_' . $this->connected_accounts[ $user ]['user_id'], array( 'Private Instagram Account Needs Reauthentication', sprintf( __( 'It looks like your Instagram account is private. Instagram requires private accounts to be reauthenticated every 60 days. Refresh your account to allow it to continue updating, or %smake your Instagram account public%s.', 'instagram-feed' ), $link_1, $link_2 ), 10 ) );
419
+
420
+ $error = '<p><b>' . __( 'Error: Private Instagram Account.', 'instagram-feed' ) . '</b>';
421
+ $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
422
+ $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
423
+ if ( current_user_can( $cap ) ) {
424
+ $error_link = '<p><a href="https://smashballoon.com/instagram-feed/docs/errors/#10">' . __( 'Click here to troubleshoot', 'instagram-feed' ) . '</a></p>';
425
+
426
+ } else {
427
+ $error_link = '';
428
+ $link_1 = '';
429
+ $link_2 = '';
430
+ }
431
+ $error .= '<p>' . sprintf( __( 'It looks like your Instagram account is private. Instagram requires private accounts to be reauthenticated every 60 days. Refresh your account to allow it to continue updating, or %smake your Instagram account public%s.', 'instagram-feed' ), $link_1, $link_2 ) . '</p>';
432
+
433
+ $error .= $error_link;
434
+ $sb_instagram_posts_manager->add_frontend_error( 'noposts', $error );
435
+ }
436
  }
437
  }
438
 
439
  if ( ! $user_found || $user_for_deprecated_personal_account_only_found ) {
440
+
441
  foreach ( $this->connected_accounts as $connected_account ) {
442
  $account_type = isset( $connected_account['type'] ) ? $connected_account['type'] : 'personal';
443
  if ( strtolower( $username_to_match ) === strtolower( $connected_account['username'] ) ) {
444
+
445
  if ( $user_for_deprecated_personal_account_only_found || ! in_array( $connected_account['username'], $usernames_included, true ) ) {
446
  if ( $account_type !== 'personal' ) {
447
+
448
  $term_for_this_user = array(
449
  'term' => $user,
450
  'params' => array()
451
  );
452
  $connected_accounts_in_feed[ $user ] = $connected_account;
453
  $user_for_deprecated_personal_account_only_found = false;
454
+ if ( isset( $this->connected_accounts[ $connected_account['user_id'] ]['private'] ) && sbi_private_account_near_expiration( $this->connected_accounts[ $connected_account['user_id'] ] ) ) {
455
+ $link_1 = '<a href="https://help.instagram.com/116024195217477/In">';
456
+ $link_2 = '</a>';
457
+ $sb_instagram_posts_manager->add_error( 'expiration_' . $this->connected_accounts[ $connected_account['user_id'] ]['user_id'], array( 'Private Instagram Account Needs Reauthentication', sprintf( __( 'It looks like your Instagram account is private. Instagram requires private accounts to be reauthenticated every 60 days. Refresh your account to allow it to continue updating, or %smake your Instagram account public%s.', 'instagram-feed' ), $link_1, $link_2 ), 10 ) );
458
+
459
+ $error = '<p><b>' . __( 'Error: Private Instagram Account.', 'instagram-feed' ) . '</b>';
460
+ $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
461
+ $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
462
+ if ( current_user_can( $cap ) ) {
463
+ $error_link = '<p><a href="https://smashballoon.com/instagram-feed/docs/errors/#10">' . __( 'Click here to troubleshoot', 'instagram-feed' ) . '</a></p>';
464
+
465
+ } else {
466
+ $error_link = '';
467
+ $link_1 = '';
468
+ $link_2 = '';
469
+ }
470
+ $error .= '<p>' . sprintf( __( 'It looks like your Instagram account is private. Instagram requires private accounts to be reauthenticated every 60 days. Refresh your account to allow it to continue updating, or %smake your Instagram account public%s.', 'instagram-feed' ), $link_1, $link_2 ) . '</p>';
471
+
472
+ $error .= $error_link;
473
+ $sb_instagram_posts_manager->add_frontend_error( 'noposts', $error );
474
+ }
475
  } else {
476
  $term_for_this_user = array(
477
  'term' => $connected_account['user_id'],
522
  if ( ! in_array( $this->connected_accounts[ $user ]['username'], $usernames_included, true ) ) {
523
  $usernames_included[] = $this->connected_accounts[ $user ]['username'];
524
  }
525
+
526
+ if ( isset( $this->connected_accounts[ $user ]['private'] ) && sbi_private_account_near_expiration( $this->connected_accounts[ $user ] ) ) {
527
+ $link_1 = '<a href="https://help.instagram.com/116024195217477/In">';
528
+ $link_2 = '</a>';
529
+ $sb_instagram_posts_manager->add_error( 'expiration_' . $this->connected_accounts[ $user ]['user_id'], array( 'Private Instagram Account Needs Reauthentication', sprintf( __( 'It looks like your Instagram account is private. Instagram requires private accounts to be reauthenticated every 60 days. Refresh your account to allow it to continue updating, or %smake your Instagram account public%s.', 'instagram-feed' ), $link_1, $link_2 ), 10 ) );
530
+
531
+ $error = '<p><b>' . __( 'Error: Private Instagram Account.', 'instagram-feed' ) . '</b>';
532
+ $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
533
+ $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
534
+ if ( current_user_can( $cap ) ) {
535
+ $error_link = '<p><a href="https://smashballoon.com/instagram-feed/docs/errors/#10">' . __( 'Click here to troubleshoot', 'instagram-feed' ) . '</a></p>';
536
+
537
+ } else {
538
+ $error_link = '';
539
+ $link_1 = '';
540
+ $link_2 = '';
541
+ }
542
+ $error .= '<p>' . sprintf( __( 'It looks like your Instagram account is private. Instagram requires private accounts to be reauthenticated every 60 days. Refresh your account to allow it to continue updating, or %smake your Instagram account public%s.', 'instagram-feed' ), $link_1, $link_2 ) . '</p>';
543
+
544
+ $error .= $error_link;
545
+ $sb_instagram_posts_manager->add_frontend_error( 'noposts', $error );
546
+ }
547
  $username_to_match = $this->connected_accounts[ $user ]['username'];
548
  $user_found = true;
549
  if ( ! isset( $this->connected_accounts[ $user ]['type'] ) || $this->connected_accounts[ $user ]['type'] === 'personal' ) {
574
  'params' => array()
575
  );
576
  $connected_accounts_in_feed[ $connected_account['user_id'] ] = $connected_account;
577
+
578
  }
579
  if ( ! in_array( $connected_account['username'], $usernames_included, true ) ) {
580
  $usernames_included[] = $connected_account['username'];
620
  'params' => array()
621
  );
622
  $connected_accounts_in_feed[ $connected_account['user_id'] ] = $connected_account;
623
+ if ( isset( $this->connected_accounts[ $connected_account['user_id'] ]['private'] ) && sbi_private_account_near_expiration( $this->connected_accounts[ $connected_account['user_id'] ] ) ) {
624
+ $link_1 = '<a href="https://help.instagram.com/116024195217477/In">';
625
+ $link_2 = '</a>';
626
+ $sb_instagram_posts_manager->add_error( 'expiration_' . $this->connected_accounts[ $connected_account['user_id'] ]['user_id'], array( 'Private Instagram Account Needs Reauthentication', sprintf( __( 'It looks like your Instagram account is private. Instagram requires private accounts to be reauthenticated every 60 days. Refresh your account to allow it to continue updating, or %smake your Instagram account public%s.', 'instagram-feed' ), $link_1, $link_2 ), 10 ) );
627
+
628
+ $error = '<p><b>' . __( 'Error: Private Instagram Account.', 'instagram-feed' ) . '</b>';
629
+ $cap = current_user_can( 'manage_instagram_feed_options' ) ? 'manage_instagram_feed_options' : 'manage_options';
630
+ $cap = apply_filters( 'sbi_settings_pages_capability', $cap );
631
+ if ( current_user_can( $cap ) ) {
632
+ $error_link = '<p><a href="https://smashballoon.com/instagram-feed/docs/errors/#10">' . __( 'Click here to troubleshoot', 'instagram-feed' ) . '</a></p>';
633
+
634
+ } else {
635
+ $error_link = '';
636
+ $link_1 = '';
637
+ $link_2 = '';
638
+ }
639
+ $error .= '<p>' . sprintf( __( 'It looks like your Instagram account is private. Instagram requires private accounts to be reauthenticated every 60 days. Refresh your account to allow it to continue updating, or %smake your Instagram account public%s.', 'instagram-feed' ), $link_1, $link_2 ) . '</p>';
640
+
641
+ $error .= $error_link;
642
+ $sb_instagram_posts_manager->add_frontend_error( 'noposts', $error );
643
+ }
644
  }
645
  }
646
 
inc/class-sb-instagram-token-refresher.php CHANGED
@@ -69,7 +69,6 @@ class SB_Instagram_Token_Refresher
69
  public static function minimum_time_interval_since_last_attempt_has_passed( $connected_account ) {
70
  $last_attempt = isset( $connected_account['last_refresh_attempt'] ) ? (int)$connected_account['last_refresh_attempt'] : 0;
71
  $current_time = sbi_get_current_timestamp();
72
-
73
  if ( $current_time > $last_attempt + SBI_MINIMUM_INTERVAL ) {
74
  return true;
75
  }
@@ -152,6 +151,14 @@ class SB_Instagram_Token_Refresher
152
  update_option( 'sb_instagram_settings', $options );
153
  }
154
 
 
 
 
 
 
 
 
 
155
  /**
156
  * Updates data related to the renewed access token
157
  * for a connected account and saves it in the database.
69
  public static function minimum_time_interval_since_last_attempt_has_passed( $connected_account ) {
70
  $last_attempt = isset( $connected_account['last_refresh_attempt'] ) ? (int)$connected_account['last_refresh_attempt'] : 0;
71
  $current_time = sbi_get_current_timestamp();
 
72
  if ( $current_time > $last_attempt + SBI_MINIMUM_INTERVAL ) {
73
  return true;
74
  }
151
  update_option( 'sb_instagram_settings', $options );
152
  }
153
 
154
+ public function get_last_error_code() {
155
+ if ( isset( $this->report['error_log'] ) ) {
156
+ $error = $this->report['error_log']->get_data();
157
+ return $error['error']['code'];
158
+ }
159
+ return false;
160
+ }
161
+
162
  /**
163
  * Updates data related to the renewed access token
164
  * for a connected account and saves it in the database.
inc/if-functions.php CHANGED
@@ -828,6 +828,28 @@ function sbi_json_encode( $thing ) {
828
  }
829
  }
830
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
831
  /**
832
  * Used to clear caches when transients aren't working
833
  * properly
@@ -1266,12 +1288,34 @@ function sbi_send_report_email() {
1266
  $headers = array( 'Content-Type: text/html; charset=utf-8', $header_from );
1267
 
1268
  $header_image = SBI_PLUGIN_URL . 'img/balloon-120.png';
1269
- $title = __( 'Instagram Feed Report for ' . home_url() );
1270
  $link = admin_url( '?page=sb-instagram-feed');
1271
- $footer_link = admin_url('admin.php?page=sb-instagram-feed&tab=customize&flag=emails');
1272
- $bold = __( 'There\'s an Issue with an Instagram Feed on Your Website', 'instagram-feed' );
1273
- $details = '<p>' . __( 'An Instagram feed on your website is currently unable to connect to Instagram to retrieve new posts. Don\'t worry, your feed is still being displayed using a cached version, but is no longer able to display new posts.', 'instagram-feed' ) . '</p>';
1274
- $details .= '<p>' . sprintf( __( 'This is caused by an issue with your Instagram account connecting to the Instagram API. For information on the exact issue and directions on how to resolve it, please visit the %sInstagram Feed settings page%s on your website.', 'instagram-feed' ), '<a href="' . esc_url( $link ) . '">', '</a>' ). '</p>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1275
  $message_content = '<h6 style="padding:0;word-wrap:normal;font-family:\'Helvetica Neue\',Helvetica,Arial,sans-serif;font-weight:bold;line-height:130%;font-size: 16px;color:#444444;text-align:inherit;margin:0 0 20px 0;Margin:0 0 20px 0;">' . $bold . '</h6>' . $details;
1276
  include_once SBI_PLUGIN_DIR . 'inc/class-sb-instagram-education.php';
1277
  $educator = new SB_Instagram_Education();
@@ -1280,6 +1324,7 @@ function sbi_send_report_email() {
1280
  include SBI_PLUGIN_DIR . 'inc/email.php';
1281
  $email_body = ob_get_contents();
1282
  ob_get_clean();
 
1283
  $sent = wp_mail( $to_array, $title, $email_body, $headers );
1284
 
1285
  return $sent;
828
  }
829
  }
830
 
831
+ function sbi_private_account_near_expiration( $connected_account ) {
832
+ $expires_in = max( 0, floor( ($connected_account['expires_timestamp'] - time()) / DAY_IN_SECONDS ) );
833
+ return $expires_in < 10;
834
+ }
835
+
836
+ function sbi_update_connected_account( $account_id, $to_update ) {
837
+ $if_database_settings = sbi_get_database_settings();
838
+
839
+ $connected_accounts = $if_database_settings['connected_accounts'];
840
+
841
+ if ( isset( $connected_accounts[ $account_id ] ) ) {
842
+
843
+ foreach ( $to_update as $key => $value ) {
844
+ $connected_accounts[ $account_id ][ $key ] = $value;
845
+ }
846
+
847
+ $if_database_settings['connected_accounts'] = $connected_accounts;
848
+
849
+ update_option( 'sb_instagram_settings', $if_database_settings );
850
+ }
851
+ }
852
+
853
  /**
854
  * Used to clear caches when transients aren't working
855
  * properly
1288
  $headers = array( 'Content-Type: text/html; charset=utf-8', $header_from );
1289
 
1290
  $header_image = SBI_PLUGIN_URL . 'img/balloon-120.png';
1291
+
1292
  $link = admin_url( '?page=sb-instagram-feed');
1293
+ //&tab=customize-advanced
1294
+ $footer_link = admin_url('admin.php?page=sb-instagram-feed&tab=customize-advanced&flag=emails');
1295
+
1296
+ $is_expiration_notice = false;
1297
+
1298
+ if ( isset( $options['connected_accounts'] ) ) {
1299
+ foreach ( $options['connected_accounts'] as $account ) {
1300
+ if ( $account['type'] === 'basic'
1301
+ && isset( $account['private'] )
1302
+ && sbi_private_account_near_expiration( $account ) ) {
1303
+ $is_expiration_notice = true;
1304
+ }
1305
+ }
1306
+ }
1307
+
1308
+ if ( ! $is_expiration_notice ) {
1309
+ $title = sprintf( __( 'Instagram Feed Report for %s', 'instagram-feed' ), str_replace( array( 'http://', 'https://' ), '', home_url() ) );
1310
+ $bold = __( 'There\'s an Issue with an Instagram Feed on Your Website', 'instagram-feed' );
1311
+ $details = '<p>' . __( 'An Instagram feed on your website is currently unable to connect to Instagram to retrieve new posts. Don\'t worry, your feed is still being displayed using a cached version, but is no longer able to display new posts.', 'instagram-feed' ) . '</p>';
1312
+ $details .= '<p>' . sprintf( __( 'This is caused by an issue with your Instagram account connecting to the Instagram API. For information on the exact issue and directions on how to resolve it, please visit the %sInstagram Feed settings page%s on your website.', 'instagram-feed' ), '<a href="' . esc_url( $link ) . '">', '</a>' ). '</p>';
1313
+ } else {
1314
+ $title = __( 'Your Private Instagram Feed Account Needs to be Reauthenticated', 'instagram-feed' );
1315
+ $bold = __( 'Access Token Refresh Needed', 'instagram-feed' );
1316
+ $details = '<p>' . __( 'As your Instagram account is set to be "Private", Instagram requires that you reauthenticate your account every 60 days. This a courtesy email to let you know that you need to take action to allow the Instagram feed on your website to continue updating. If you don\'t refresh your account, then a backup cache will be displayed instead.', 'instagram-feed' ) . '</p>';
1317
+ $details .= '<p>' . sprintf( __( 'To prevent your account expiring every 60 days %sswitch your account to be public%s. For more information and to refresh your account, click here to visit the %sInstagram Feed settings page%s on your website.', 'instagram-feed' ), '<a href="https://help.instagram.com/116024195217477/In">', '</a>', '<a href="' . esc_url( $link ) . '">', '</a>' ). '</p>';
1318
+ }
1319
  $message_content = '<h6 style="padding:0;word-wrap:normal;font-family:\'Helvetica Neue\',Helvetica,Arial,sans-serif;font-weight:bold;line-height:130%;font-size: 16px;color:#444444;text-align:inherit;margin:0 0 20px 0;Margin:0 0 20px 0;">' . $bold . '</h6>' . $details;
1320
  include_once SBI_PLUGIN_DIR . 'inc/class-sb-instagram-education.php';
1321
  $educator = new SB_Instagram_Education();
1324
  include SBI_PLUGIN_DIR . 'inc/email.php';
1325
  $email_body = ob_get_contents();
1326
  ob_get_clean();
1327
+
1328
  $sent = wp_mail( $to_array, $title, $email_body, $headers );
1329
 
1330
  return $sent;
instagram-feed.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Smash Balloon Instagram Feed
4
  Plugin URI: https://smashballoon.com/instagram-feed
5
  Description: Display beautifully clean, customizable, and responsive Instagram feeds.
6
- Version: 2.4.6
7
  Author: Smash Balloon
8
  Author URI: https://smashballoon.com/
9
  License: GPLv2 or later
@@ -23,7 +23,7 @@ along with this program; if not, write to the Free Software
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
  if ( ! defined( 'SBIVER' ) ) {
26
- define( 'SBIVER', '2.4.6' );
27
  }
28
  // Db version.
29
  if ( ! defined( 'SBI_DBVERSION' ) ) {
3
  Plugin Name: Smash Balloon Instagram Feed
4
  Plugin URI: https://smashballoon.com/instagram-feed
5
  Description: Display beautifully clean, customizable, and responsive Instagram feeds.
6
+ Version: 2.4.7
7
  Author: Smash Balloon
8
  Author URI: https://smashballoon.com/
9
  License: GPLv2 or later
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
  if ( ! defined( 'SBIVER' ) ) {
26
+ define( 'SBIVER', '2.4.7' );
27
  }
28
  // Db version.
29
  if ( ! defined( 'SBI_DBVERSION' ) ) {
js/sb-instagram-2-2.js CHANGED
@@ -545,7 +545,7 @@ if(!sbi_js_exists) {
545
  if (newRes > currentRes || currentUrl === window.sbi.options.placeholder || forceChange) {
546
  if (feed.settings.debugEnabled) {
547
  var reason = currentUrl === window.sbi.options.placeholder ? 'was placeholder' : 'too small';
548
- console.log('rais res for ' + currentUrl, reason);
549
  }
550
  var newUrl = imgSrcSet[newRes].split("?ig_cache_key")[0];
551
  $item.find('.sbi_photo img').attr('src', newUrl);
@@ -561,7 +561,7 @@ if(!sbi_js_exists) {
561
 
562
  if ($this_image.get(0).naturalWidth !== 1000 && newAspectRatio > aspectRatio && !checked) {
563
  if (feed.settings.debugEnabled) {
564
- console.log('rais res again for aspect ratio change ' + currentUrl);
565
  }
566
  checked = true;
567
  minImageWidth = $item.find('.sbi_photo').innerWidth();
545
  if (newRes > currentRes || currentUrl === window.sbi.options.placeholder || forceChange) {
546
  if (feed.settings.debugEnabled) {
547
  var reason = currentUrl === window.sbi.options.placeholder ? 'was placeholder' : 'too small';
548
+ console.log('raise res for ' + currentUrl, reason);
549
  }
550
  var newUrl = imgSrcSet[newRes].split("?ig_cache_key")[0];
551
  $item.find('.sbi_photo img').attr('src', newUrl);
561
 
562
  if ($this_image.get(0).naturalWidth !== 1000 && newAspectRatio > aspectRatio && !checked) {
563
  if (feed.settings.debugEnabled) {
564
+ console.log('raise res again for aspect ratio change ' + currentUrl);
565
  }
566
  checked = true;
567
  minImageWidth = $item.find('.sbi_photo').innerWidth();
js/sb-instagram-2-2.min.js CHANGED
@@ -1 +1 @@
1
- var sbi_js_exists=void 0!==sbi_js_exists;sbi_js_exists||(!function(i){function e(){var i,e,s,t=t||{VER:"0.9.944"};t.bgs_Available=!1,t.bgs_CheckRunned=!1,function(i){i.fn.extend({sbi_imgLiquid:function(e){this.defaults={fill:!0,verticalAlign:"center",horizontalAlign:"center",useBackgroundSize:!0,useDataHtmlAttr:!0,responsive:!0,delay:0,fadeInTime:0,removeBoxBackground:!0,hardPixels:!0,responsiveCheckTime:500,timecheckvisibility:500,onStart:null,onFinish:null,onItemStart:null,onItemFinish:null,onItemError:null},function(){if(!t.bgs_CheckRunned){t.bgs_CheckRunned=!0;var e=i('<span style="background-size:cover" />');i("body").append(e),function(){var i=e[0];if(i&&window.getComputedStyle){var s=window.getComputedStyle(i,null);s&&s.backgroundSize&&(t.bgs_Available="cover"===s.backgroundSize)}}(),e.remove()}}();var s=this;return this.options=e,this.settings=i.extend({},this.defaults,this.options),this.settings.onStart&&this.settings.onStart(),this.each(function(e){function a(){(r.responsive||h.data("sbi_imgLiquid_oldProcessed"))&&h.data("sbi_imgLiquid_settings")&&(r=h.data("sbi_imgLiquid_settings"),l.actualSize=l.get(0).offsetWidth+l.get(0).offsetHeight/1e4,l.sizeOld&&l.actualSize!==l.sizeOld&&o(),l.sizeOld=l.actualSize,setTimeout(a,r.responsiveCheckTime))}function n(){h.data("sbi_imgLiquid_error",!0),l.addClass("sbi_imgLiquid_error"),r.onItemError&&r.onItemError(e,l,h),d()}function o(){var i,s,t,a,n,o,g,u,m=0,_=0,f=l.width(),c=l.height();void 0===h.data("owidth")&&h.data("owidth",h[0].width),void 0===h.data("oheight")&&h.data("oheight",h[0].height),r.fill===f/c>=h.data("owidth")/h.data("oheight")?(i="100%",s="auto",t=Math.floor(f),a=Math.floor(f*(h.data("oheight")/h.data("owidth")))):(i="auto",s="100%",t=Math.floor(c*(h.data("owidth")/h.data("oheight"))),a=Math.floor(c)),g=f-t,"left"===(n=r.horizontalAlign.toLowerCase())&&(_=0),"center"===n&&(_=.5*g),"right"===n&&(_=g),-1!==n.indexOf("%")&&((n=parseInt(n.replace("%",""),10))>0&&(_=g*n*.01)),u=c-a,"left"===(o=r.verticalAlign.toLowerCase())&&(m=0),"center"===o&&(m=.5*u),"bottom"===o&&(m=u),-1!==o.indexOf("%")&&((o=parseInt(o.replace("%",""),10))>0&&(m=u*o*.01)),r.hardPixels&&(i=t,s=a),h.css({width:i,height:s,"margin-left":Math.floor(_),"margin-top":Math.floor(m)}),h.data("sbi_imgLiquid_oldProcessed")||(h.fadeTo(r.fadeInTime,1),h.data("sbi_imgLiquid_oldProcessed",!0),r.removeBoxBackground&&l.css("background-image","none"),l.addClass("sbi_imgLiquid_nobgSize"),l.addClass("sbi_imgLiquid_ready")),r.onItemFinish&&r.onItemFinish(e,l,h),d()}function d(){e===s.length-1&&s.settings.onFinish&&s.settings.onFinish()}var r=s.settings,l=i(this),h=i("img:first",l);return h.length?(h.data("sbi_imgLiquid_settings")?(l.removeClass("sbi_imgLiquid_error").removeClass("sbi_imgLiquid_ready"),r=i.extend({},h.data("sbi_imgLiquid_settings"),s.options)):r=i.extend({},s.settings,function(){var i={};if(s.settings.useDataHtmlAttr){var e=l.attr("data-sbi_imgLiquid-fill"),a=l.attr("data-sbi_imgLiquid-horizontalAlign"),n=l.attr("data-sbi_imgLiquid-verticalAlign");("true"===e||"false"===e)&&(i.fill=Boolean("true"===e)),void 0===a||"left"!==a&&"center"!==a&&"right"!==a&&-1===a.indexOf("%")||(i.horizontalAlign=a),void 0===n||"top"!==n&&"bottom"!==n&&"center"!==n&&-1===n.indexOf("%")||(i.verticalAlign=n)}return t.isIE&&s.settings.ieFadeInDisabled&&(i.fadeInTime=0),i}()),h.data("sbi_imgLiquid_settings",r),r.onItemStart&&r.onItemStart(e,l,h),void(t.bgs_Available&&r.useBackgroundSize?(-1===l.css("background-image").indexOf(encodeURI(h.attr("src")))&&l.css({"background-image":'url("'+encodeURI(h.attr("src"))+'")'}),l.css({"background-size":r.fill?"cover":"contain","background-position":(r.horizontalAlign+" "+r.verticalAlign).toLowerCase(),"background-repeat":"no-repeat"}),i("a:first",l).css({display:"block",width:"100%",height:"100%"}),i("img",l).css({display:"none"}),r.onItemFinish&&r.onItemFinish(e,l,h),l.addClass("sbi_imgLiquid_bgSize"),l.addClass("sbi_imgLiquid_ready"),d()):function s(){if(h.data("oldSrc")&&h.data("oldSrc")!==h.attr("src")){var t=h.clone().removeAttr("style");return t.data("sbi_imgLiquid_settings",h.data("sbi_imgLiquid_settings")),h.parent().prepend(t),h.remove(),(h=t)[0].width=0,void setTimeout(s,10)}return h.data("sbi_imgLiquid_oldProcessed")?void o():(h.data("sbi_imgLiquid_oldProcessed",!1),h.data("oldSrc",h.attr("src")),i("img:not(:first)",l).css("display","none"),l.css({overflow:"hidden"}),h.fadeTo(0,0).removeAttr("width").removeAttr("height").css({visibility:"visible","max-width":"none","max-height":"none",width:"auto",height:"auto",display:"block"}),h.on("error",n),h[0].onerror=n,function i(){h.data("sbi_imgLiquid_error")||h.data("sbi_imgLiquid_loaded")||h.data("sbi_imgLiquid_oldProcessed")||(l.is(":visible")&&h[0].complete&&h[0].width>0&&h[0].height>0?(h.data("sbi_imgLiquid_loaded",!0),setTimeout(o,e*r.delay)):setTimeout(i,r.timecheckvisibility))}(),void a())}())):void n()})}})}(jQuery),i=t.injectCss,e=document.getElementsByTagName("head")[0],(s=document.createElement("style")).type="text/css",s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i)),e.appendChild(s)}function s(){this.feeds={},this.options=sb_instagram_js_options}function t(i,e,s){this.el=i,this.index=e,this.settings=s,this.minImageWidth=0,this.imageResolution=150,this.resizedImages={},this.needsResizing=[],this.outOfPages=!1,this.isInitialized=!1}function a(e,s){i.ajax({url:sbiajaxurl,type:"post",data:e,success:s})}s.prototype={createPage:function(e,s){void 0!==window.sbiajaxurl&&-1!==window.sbiajaxurl.indexOf(window.location.hostname)||(window.sbiajaxurl=location.protocol+"//"+window.location.hostname+"/wp-admin/admin-ajax.php"),i(".sbi_no_js_error_message").remove(),i(".sbi_no_js").removeClass("sbi_no_js"),e(s)},createFeeds:function(e){e.whenFeedsCreated(i(".sbi").each(function(e){i(this).attr("data-sbi-index",e+1);var s=i(this),n=void 0!==s.attr("data-sbi-flags")?s.attr("data-sbi-flags").split(","):[],o=void 0!==s.attr("data-options")?JSON.parse(s.attr("data-options")):{};if(n.indexOf("testAjax")>-1){window.sbi.triggeredTest=!0;a({action:"sbi_on_ajax_test_trigger"},function(i){console.log("did test")})}var d={cols:s.attr("data-cols"),colsmobile:"same"!==s.attr("data-colsmobile")?s.attr("data-colsmobile"):s.attr("data-cols"),num:s.attr("data-num"),imgRes:s.attr("data-res"),feedID:s.attr("data-feedid"),shortCodeAtts:s.attr("data-shortcode-atts"),resizingEnabled:-1===n.indexOf("resizeDisable"),imageLoadEnabled:-1===n.indexOf("imageLoadDisable"),debugEnabled:n.indexOf("debug")>-1,favorLocal:n.indexOf("favorLocal")>-1,ajaxPostLoad:n.indexOf("ajaxPostLoad")>-1,autoMinRes:1,general:o};window.sbi.feeds[e]=function(i,e,s){return new t(i,e,s)}(this,e,d),window.sbi.feeds[e].setResizedImages(),window.sbi.feeds[e].init();var r=jQuery.Event("sbiafterfeedcreate");r.feed=window.sbi.feeds[e],jQuery(window).trigger(r)}))},afterFeedsCreated:function(){i(".sb_instagram_header").each(function(){var e=i(this);e.find(".sbi_header_link").hover(function(){e.find(".sbi_header_img_hover").addClass("sbi_fade_in")},function(){e.find(".sbi_header_img_hover").removeClass("sbi_fade_in")})})},encodeHTML:function(i){return void 0===i?"":i.replace(/(>)/g,"&gt;").replace(/(<)/g,"&lt;").replace(/(&lt;br\/&gt;)/g,"<br>").replace(/(&lt;br&gt;)/g,"<br>")},urlDetect:function(i){return i.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/g)}},t.prototype={init:function(){var e=this;i(this.el).find("#sbi_mod_error").length&&i(this.el).prepend(i(this.el).find("#sbi_mod_error")),this.settings.ajaxPostLoad?this.getNewPostSet():this.afterInitialImagesLoaded();var s,t=(s=0,function(i,e){clearTimeout(s),s=setTimeout(i,e)});jQuery(window).resize(function(){t(function(){e.afterResize()},500)})},initLayout:function(){},afterInitialImagesLoaded:function(){this.initLayout(),this.loadMoreButtonInit(),this.hideExtraImagesForWidth(),this.beforeNewImagesRevealed(),this.revealNewImages(),this.afterNewImagesRevealed()},afterResize:function(){this.setImageHeight(),this.setImageResolution(),this.maybeRaiseImageResolution(),this.setImageSizeClass()},afterLoadMoreClicked:function(i){i.find(".sbi_loader").removeClass("sbi_hidden"),i.find(".sbi_btn_text").addClass("sbi_hidden"),i.closest(".sbi").find(".sbi_num_diff_hide").addClass("sbi_transition").removeClass("sbi_num_diff_hide")},afterNewImagesLoaded:function(){var e=i(this.el),s=this;this.beforeNewImagesRevealed(),this.revealNewImages(),this.afterNewImagesRevealed(),setTimeout(function(){e.find(".sbi_loader").addClass("sbi_hidden"),e.find(".sbi_btn_text").removeClass("sbi_hidden"),s.maybeRaiseImageResolution()},500)},beforeNewImagesRevealed:function(){this.setImageHeight(),this.maybeRaiseImageResolution(!0),this.setImageSizeClass()},revealNewImages:function(){var e=i(this.el);e.find(".sbi-screenreader").each(function(){i(this).find("img").remove()}),"function"==typeof sbi_custom_js&&setTimeout(function(){sbi_custom_js()},100),this.applyImageLiquid(),e.find(".sbi_item").each(function(i){jQuery(this).find(".sbi_photo").hover(function(){jQuery(this).fadeTo(200,.85)},function(){jQuery(this).stop().fadeTo(500,1)})}),setTimeout(function(){jQuery("#sbi_images .sbi_item.sbi_new").removeClass("sbi_new");var i=10;e.find(".sbi_transition").each(function(){var e=jQuery(this);setTimeout(function(){e.removeClass("sbi_transition")},i),i+=10})},500)},afterNewImagesRevealed:function(){this.listenForVisibilityChange(),this.sendNeedsResizingToServer(),this.settings.imageLoadEnabled||i(".sbi_no_resraise").removeClass("sbi_no_resraise");var e=i.Event("sbiafterimagesloaded");e.el=i(this.el),i(window).trigger(e)},setResizedImages:function(){i(this.el).find(".sbi_resized_image_data").length&&void 0!==i(this.el).find(".sbi_resized_image_data").attr("data-resized")&&0===i(this.el).find(".sbi_resized_image_data").attr("data-resized").indexOf('{"')&&(this.resizedImages=JSON.parse(i(this.el).find(".sbi_resized_image_data").attr("data-resized")),i(this.el).find(".sbi_resized_image_data").remove())},sendNeedsResizingToServer:function(){var e=this;if(e.needsResizing.length>0&&e.settings.resizingEnabled){var s=i(this.el).find(".sbi_item").length;a({action:"sbi_resized_images_submit",needs_resizing:e.needsResizing,offset:s,feed_id:e.settings.feedID,atts:e.settings.shortCodeAtts},function(i){if(0===i.trim().indexOf("{")){var s=JSON.parse(i);e.settings.debugEnabled&&console.log(s)}})}},loadMoreButtonInit:function(){var e=i(this.el),s=this;e.find("#sbi_load .sbi_load_btn").off().on("click",function(){s.afterLoadMoreClicked(jQuery(this)),s.getNewPostSet()})},getNewPostSet:function(){var e=i(this.el),s=this;a({action:"sbi_load_more_clicked",offset:e.find(".sbi_item").length,feed_id:s.settings.feedID,atts:s.settings.shortCodeAtts,current_resolution:s.imageResolution},function(t){if(0===t.trim().indexOf("{")){var a=JSON.parse(t);s.settings.debugEnabled&&console.log(a),s.appendNewPosts(a.html),s.addResizedImages(a.resizedImages),s.settings.ajaxPostLoad?(s.settings.ajaxPostLoad=!1,s.afterInitialImagesLoaded()):s.afterNewImagesLoaded(),a.feedStatus.shouldPaginate?s.outOfPages=!1:(s.outOfPages=!0,e.find(".sbi_load_btn").hide()),i(".sbi_no_js").removeClass("sbi_no_js")}})},appendNewPosts:function(e){var s=i(this.el);s.find("#sbi_images .sbi_item").length?s.find("#sbi_images .sbi_item").last().after(e):s.find("#sbi_images").append(e)},addResizedImages:function(i){for(var e in i)this.resizedImages[e]=i[e]},setImageHeight:function(){var e=i(this.el),s=e.find(".sbi_photo").eq(0).innerWidth(),t=this.getColumnCount(),a=e.find("#sbi_images").innerWidth()-e.find("#sbi_images").width(),n=a/2;sbi_photo_width_manual=e.find("#sbi_images").width()/t-a,e.find(".sbi_photo").css("height",s),e.find(".sbi-owl-nav").length&&setTimeout(function(){var i=2;e.find(".sbi_owl2row-item").length&&(i=1);var s=e.find(".sbi_photo").eq(0).innerWidth()/i;s+=parseInt(n)*(2-i+2),e.find(".sbi-owl-nav div").css("top",s)},100)},maybeRaiseSingleImageResolution:function(e,s,t){var a=this,n=a.getImageUrls(e),o=e.find(".sbi_photo img").attr("src"),d=150,r=e.find("img").get(0),l=o===window.sbi.options.placeholder?1:r.naturalWidth/r.naturalHeight;t=void 0!==t&&t;if(!(e.hasClass("sbi_no_resraise")||e.hasClass("sbi_had_error")||e.find(".sbi_link_area").length&&e.find(".sbi_link_area").hasClass("sbi_had_error"))){i.each(n,function(i,e){e===o&&(d=parseInt(i),t=!1)});var h=640;switch(a.settings.imgRes){case"thumb":h=150;break;case"medium":h=320;break;case"full":h=640;break;default:var g=Math.max(a.settings.autoMinRes,e.find(".sbi_photo").innerWidth()),u=a.getBestResolutionForAuto(g,l,e);switch(u){case 320:h=320;break;case 150:h=150}}if(h>d||o===window.sbi.options.placeholder||t){if(a.settings.debugEnabled){var m=o===window.sbi.options.placeholder?"was placeholder":"too small";console.log("rais res for "+o,m)}var _=n[h].split("?ig_cache_key")[0];if(e.find(".sbi_photo img").attr("src",_),e.find(".sbi_photo").css("background-image",'url("'+_+'")'),d=h,"auto"===a.settings.imgRes){var f=!1;e.find(".sbi_photo img").on("load",function(){var s=i(this),t=s.get(0).naturalWidth/s.get(0).naturalHeight;if(1e3!==s.get(0).naturalWidth&&t>l&&!f){switch(a.settings.debugEnabled&&console.log("rais res again for aspect ratio change "+o),f=!0,g=e.find(".sbi_photo").innerWidth(),u=a.getBestResolutionForAuto(g,t,e),h=640,u){case 320:h=320;break;case 150:h=150}h>d&&(_=n[h].split("?ig_cache_key")[0],s.attr("src",_),s.closest(".sbi_photo").css("background-image",'url("'+_+'")')),"masonry"!==a.layout&&"highlight"!==a.layout||(i(a.el).find("#sbi_images").smashotope(a.isotopeArgs),setTimeout(function(){i(a.el).find("#sbi_images").smashotope(a.isotopeArgs)},500))}else if(a.settings.debugEnabled){var r=f?"already checked":"no aspect ratio change";console.log("not raising res for replacement "+o,r)}})}}e.find("img").on("error",function(){if(i(this).hasClass("sbi_img_error"))console.log("unfixed error "+i(this).attr("src"));else{var e;if(i(this).addClass("sbi_img_error"),i(this).attr("src").indexOf("media/?size=")>-1||i(this).attr("src").indexOf("cdninstagram")>-1||i(this).attr("src").indexOf("fbcdn")>-1)a.settings.favorLocal=!0,void 0!==(e=a.getImageUrls(i(this).closest(".sbi_item")))[640]&&(i(this).attr("src",e[640]),i(this).closest(".sbi_photo").css("background-image","url("+e[640]+")"),i(this).closest(".sbi_item").addClass("sbi_had_error").find(".sbi_link_area").attr("href",e[640]).addClass("sbi_had_error"));else if("undefined"!==i(this).closest(".sbi_photo").attr("data-img-src-set"))void 0!==(e=JSON.parse(i(this).closest(".sbi_photo").attr("data-img-src-set").replace(/\\\//g,"/"))).d&&(i(this).attr("src",e.d),i(this).closest(".sbi_photo").css("background-image","url("+e.d+")"),i(this).closest(".sbi_item").addClass("sbi_had_error").find(".sbi_link_area").attr("href",e[640]).addClass("sbi_had_error"));setTimeout(function(){a.afterResize()},1500)}})}},maybeRaiseImageResolution:function(e){var s=this,t=void 0!==e&&!0===e?".sbi_item.sbi_new":".sbi_item",a=!s.isInitialized;i(s.el).find(t).each(function(e){!i(this).hasClass("sbi_num_diff_hide")&&i(this).find(".sbi_photo").length&&void 0!==i(this).find(".sbi_photo").attr("data-img-src-set")&&s.maybeRaiseSingleImageResolution(i(this),e,a)}),s.isInitialized=!0},getBestResolutionForAuto:function(e,s,t){(isNaN(s)||s<1)&&(s=1);var a=e*s,n=10*Math.ceil(a/10),o=[150,320,640];if(t.hasClass("sbi_highlighted")&&(n*=2),-1===o.indexOf(parseInt(n))){var d=!1;i.each(o,function(i,e){e>parseInt(n)&&!d&&(n=e,d=!0)})}return n},hideExtraImagesForWidth:function(){if("carousel"!==this.layout){var e=i(this.el),s=void 0!==e.attr("data-num")&&""!==e.attr("data-num")?parseInt(e.attr("data-num")):1,t=void 0!==e.attr("data-nummobile")&&""!==e.attr("data-nummobile")?parseInt(e.attr("data-nummobile")):s;i(window).width()<480?t<e.find(".sbi_item").length&&e.find(".sbi_item").slice(t-e.find(".sbi_item").length).addClass("sbi_num_diff_hide"):s<e.find(".sbi_item").length&&e.find(".sbi_item").slice(s-e.find(".sbi_item").length).addClass("sbi_num_diff_hide")}},setImageSizeClass:function(){var e=i(this.el);e.removeClass("sbi_small sbi_medium");var s=e.innerWidth(),t=parseInt(e.find("#sbi_images").outerWidth()-e.find("#sbi_images").width())/2,a=this.getColumnCount(),n=(s-t*(a+2))/a;n>120&&n<240?e.addClass("sbi_medium"):n<=120&&e.addClass("sbi_small")},setMinImageWidth:function(){i(this.el).find(".sbi_item .sbi_photo").first().length?this.minImageWidth=i(this.el).find(".sbi_item .sbi_photo").first().innerWidth():this.minImageWidth=150},setImageResolution:function(){if("auto"===this.settings.imgRes)this.imageResolution="auto";else switch(this.settings.imgRes){case"thumb":this.imageResolution=150;break;case"medium":this.imageResolution=320;break;default:this.imageResolution=640}},getImageUrls:function(i){var e=JSON.parse(i.find(".sbi_photo").attr("data-img-src-set").replace(/\\\//g,"/")),s=i.attr("id").replace("sbi_","");if(void 0!==this.resizedImages[s]&&"video"!==this.resizedImages[s]&&"pending"!==this.resizedImages[s]&&"error"!==this.resizedImages[s].id&&"video"!==this.resizedImages[s].id&&"pending"!==this.resizedImages[s].id){if(void 0!==this.resizedImages[s].sizes){var t=[];void 0!==this.resizedImages[s].sizes.full&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg",t.push(640)),void 0!==this.resizedImages[s].sizes.low&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg",t.push(320)),void 0!==this.resizedImages[s].sizes.thumb&&(t.push(150),e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"thumb.jpg"),this.settings.favorLocal&&(-1===t.indexOf(640)&&t.indexOf(320)>-1&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg"),-1===t.indexOf(320)&&(t.indexOf(640)>-1?e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg":t.indexOf(150)>-1&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"thumb.jpg")),-1===t.indexOf(150)&&(t.indexOf(320)>-1?e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg":t.indexOf(640)>-1&&(e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg")))}}else(void 0===this.resizedImages[s]||void 0!==this.resizedImages[s].id&&"pending"!==this.resizedImages[s].id&&"error"!==this.resizedImages[s].id)&&this.addToNeedsResizing(s);return e},getAvatarUrl:function(i,e){if(""===i)return"";var s=this.settings.general.avatars;return"local"===(e=void 0!==e?e:"local")?void 0!==s["LCL"+i]&&1===parseInt(s["LCL"+i])?sb_instagram_js_options.resized_url+i+".jpg":void 0!==s[i]?s[i]:"":void 0!==s[i]?s[i]:void 0!==s["LCL"+i]&&1===parseInt(s["LCL"+i])?sb_instagram_js_options.resized_url+i+".jpg":""},addToNeedsResizing:function(i){-1===this.needsResizing.indexOf(i)&&this.needsResizing.push(i)},applyImageLiquid:function(){var s=i(this.el);e(),"function"==typeof s.find(".sbi_photo").sbi_imgLiquid&&s.find(".sbi_photo").sbi_imgLiquid({fill:!0})},listenForVisibilityChange:function(){var e,s,t,a=this;e=jQuery,s={callback:function(){},runOnLoad:!0,frequency:100,sbiPreviousVisibility:null},t={sbiCheckVisibility:function(i,e){if(jQuery.contains(document,i[0])){var s=e.sbiPreviousVisibility,a=i.is(":visible");e.sbiPreviousVisibility=a,null==s?e.runOnLoad&&e.callback(i,a):s!==a&&e.callback(i,a),setTimeout(function(){t.sbiCheckVisibility(i,e)},e.frequency)}}},e.fn.sbiVisibilityChanged=function(i){var a=e.extend({},s,i);return this.each(function(){t.sbiCheckVisibility(e(this),a)})},"function"==typeof i(this.el).filter(":hidden").sbiVisibilityChanged&&i(this.el).filter(":hidden").sbiVisibilityChanged({callback:function(i,e){a.afterResize()},runOnLoad:!1})},getColumnCount:function(){var e=i(this.el),s=this.settings.cols,t=this.settings.colsmobile,a=s;return sbiWindowWidth=window.innerWidth,e.hasClass("sbi_mob_col_auto")?(sbiWindowWidth<640&&parseInt(s)>2&&parseInt(s)<7&&(a=2),sbiWindowWidth<640&&parseInt(s)>6&&parseInt(s)<11&&(a=4),sbiWindowWidth<=480&&parseInt(s)>2&&(a=1)):sbiWindowWidth<=480&&(a=t),parseInt(a)}},window.sbi_init=function(){window.sbi=new s,window.sbi.createPage(window.sbi.createFeeds,{whenFeedsCreated:window.sbi.afterFeedsCreated})}}(jQuery),jQuery(document).ready(function(i){void 0===window.sb_instagram_js_options&&(window.sb_instagram_js_options={font_method:"svg",resized_url:location.protocol+"//"+window.location.hostname+"/wp-content/uploads/sb-instagram-feed-images/",placeholder:location.protocol+"//"+window.location.hostname+"/wp-content/plugins/instagram-feed/img/placeholder.png"}),void 0!==window.sb_instagram_js_options.resized_url&&-1===window.sb_instagram_js_options.resized_url.indexOf(location.protocol)&&("http:"===location.protocol?window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("http:","https:"):window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("https:","http:")),sbi_init()}));
1
+ var sbi_js_exists=void 0!==sbi_js_exists;sbi_js_exists||(!function(i){function e(){var i,e,s,t=t||{VER:"0.9.944"};t.bgs_Available=!1,t.bgs_CheckRunned=!1,function(i){i.fn.extend({sbi_imgLiquid:function(e){this.defaults={fill:!0,verticalAlign:"center",horizontalAlign:"center",useBackgroundSize:!0,useDataHtmlAttr:!0,responsive:!0,delay:0,fadeInTime:0,removeBoxBackground:!0,hardPixels:!0,responsiveCheckTime:500,timecheckvisibility:500,onStart:null,onFinish:null,onItemStart:null,onItemFinish:null,onItemError:null},function(){if(!t.bgs_CheckRunned){t.bgs_CheckRunned=!0;var e=i('<span style="background-size:cover" />');i("body").append(e),function(){var i=e[0];if(i&&window.getComputedStyle){var s=window.getComputedStyle(i,null);s&&s.backgroundSize&&(t.bgs_Available="cover"===s.backgroundSize)}}(),e.remove()}}();var s=this;return this.options=e,this.settings=i.extend({},this.defaults,this.options),this.settings.onStart&&this.settings.onStart(),this.each(function(e){function a(){(r.responsive||h.data("sbi_imgLiquid_oldProcessed"))&&h.data("sbi_imgLiquid_settings")&&(r=h.data("sbi_imgLiquid_settings"),l.actualSize=l.get(0).offsetWidth+l.get(0).offsetHeight/1e4,l.sizeOld&&l.actualSize!==l.sizeOld&&o(),l.sizeOld=l.actualSize,setTimeout(a,r.responsiveCheckTime))}function n(){h.data("sbi_imgLiquid_error",!0),l.addClass("sbi_imgLiquid_error"),r.onItemError&&r.onItemError(e,l,h),d()}function o(){var i,s,t,a,n,o,g,u,m=0,_=0,f=l.width(),c=l.height();void 0===h.data("owidth")&&h.data("owidth",h[0].width),void 0===h.data("oheight")&&h.data("oheight",h[0].height),r.fill===f/c>=h.data("owidth")/h.data("oheight")?(i="100%",s="auto",t=Math.floor(f),a=Math.floor(f*(h.data("oheight")/h.data("owidth")))):(i="auto",s="100%",t=Math.floor(c*(h.data("owidth")/h.data("oheight"))),a=Math.floor(c)),g=f-t,"left"===(n=r.horizontalAlign.toLowerCase())&&(_=0),"center"===n&&(_=.5*g),"right"===n&&(_=g),-1!==n.indexOf("%")&&((n=parseInt(n.replace("%",""),10))>0&&(_=g*n*.01)),u=c-a,"left"===(o=r.verticalAlign.toLowerCase())&&(m=0),"center"===o&&(m=.5*u),"bottom"===o&&(m=u),-1!==o.indexOf("%")&&((o=parseInt(o.replace("%",""),10))>0&&(m=u*o*.01)),r.hardPixels&&(i=t,s=a),h.css({width:i,height:s,"margin-left":Math.floor(_),"margin-top":Math.floor(m)}),h.data("sbi_imgLiquid_oldProcessed")||(h.fadeTo(r.fadeInTime,1),h.data("sbi_imgLiquid_oldProcessed",!0),r.removeBoxBackground&&l.css("background-image","none"),l.addClass("sbi_imgLiquid_nobgSize"),l.addClass("sbi_imgLiquid_ready")),r.onItemFinish&&r.onItemFinish(e,l,h),d()}function d(){e===s.length-1&&s.settings.onFinish&&s.settings.onFinish()}var r=s.settings,l=i(this),h=i("img:first",l);return h.length?(h.data("sbi_imgLiquid_settings")?(l.removeClass("sbi_imgLiquid_error").removeClass("sbi_imgLiquid_ready"),r=i.extend({},h.data("sbi_imgLiquid_settings"),s.options)):r=i.extend({},s.settings,function(){var i={};if(s.settings.useDataHtmlAttr){var e=l.attr("data-sbi_imgLiquid-fill"),a=l.attr("data-sbi_imgLiquid-horizontalAlign"),n=l.attr("data-sbi_imgLiquid-verticalAlign");("true"===e||"false"===e)&&(i.fill=Boolean("true"===e)),void 0===a||"left"!==a&&"center"!==a&&"right"!==a&&-1===a.indexOf("%")||(i.horizontalAlign=a),void 0===n||"top"!==n&&"bottom"!==n&&"center"!==n&&-1===n.indexOf("%")||(i.verticalAlign=n)}return t.isIE&&s.settings.ieFadeInDisabled&&(i.fadeInTime=0),i}()),h.data("sbi_imgLiquid_settings",r),r.onItemStart&&r.onItemStart(e,l,h),void(t.bgs_Available&&r.useBackgroundSize?(-1===l.css("background-image").indexOf(encodeURI(h.attr("src")))&&l.css({"background-image":'url("'+encodeURI(h.attr("src"))+'")'}),l.css({"background-size":r.fill?"cover":"contain","background-position":(r.horizontalAlign+" "+r.verticalAlign).toLowerCase(),"background-repeat":"no-repeat"}),i("a:first",l).css({display:"block",width:"100%",height:"100%"}),i("img",l).css({display:"none"}),r.onItemFinish&&r.onItemFinish(e,l,h),l.addClass("sbi_imgLiquid_bgSize"),l.addClass("sbi_imgLiquid_ready"),d()):function s(){if(h.data("oldSrc")&&h.data("oldSrc")!==h.attr("src")){var t=h.clone().removeAttr("style");return t.data("sbi_imgLiquid_settings",h.data("sbi_imgLiquid_settings")),h.parent().prepend(t),h.remove(),(h=t)[0].width=0,void setTimeout(s,10)}return h.data("sbi_imgLiquid_oldProcessed")?void o():(h.data("sbi_imgLiquid_oldProcessed",!1),h.data("oldSrc",h.attr("src")),i("img:not(:first)",l).css("display","none"),l.css({overflow:"hidden"}),h.fadeTo(0,0).removeAttr("width").removeAttr("height").css({visibility:"visible","max-width":"none","max-height":"none",width:"auto",height:"auto",display:"block"}),h.on("error",n),h[0].onerror=n,function i(){h.data("sbi_imgLiquid_error")||h.data("sbi_imgLiquid_loaded")||h.data("sbi_imgLiquid_oldProcessed")||(l.is(":visible")&&h[0].complete&&h[0].width>0&&h[0].height>0?(h.data("sbi_imgLiquid_loaded",!0),setTimeout(o,e*r.delay)):setTimeout(i,r.timecheckvisibility))}(),void a())}())):void n()})}})}(jQuery),i=t.injectCss,e=document.getElementsByTagName("head")[0],(s=document.createElement("style")).type="text/css",s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i)),e.appendChild(s)}function s(){this.feeds={},this.options=sb_instagram_js_options}function t(i,e,s){this.el=i,this.index=e,this.settings=s,this.minImageWidth=0,this.imageResolution=150,this.resizedImages={},this.needsResizing=[],this.outOfPages=!1,this.isInitialized=!1}function a(e,s){i.ajax({url:sbiajaxurl,type:"post",data:e,success:s})}s.prototype={createPage:function(e,s){void 0!==window.sbiajaxurl&&-1!==window.sbiajaxurl.indexOf(window.location.hostname)||(window.sbiajaxurl=location.protocol+"//"+window.location.hostname+"/wp-admin/admin-ajax.php"),i(".sbi_no_js_error_message").remove(),i(".sbi_no_js").removeClass("sbi_no_js"),e(s)},createFeeds:function(e){e.whenFeedsCreated(i(".sbi").each(function(e){i(this).attr("data-sbi-index",e+1);var s=i(this),n=void 0!==s.attr("data-sbi-flags")?s.attr("data-sbi-flags").split(","):[],o=void 0!==s.attr("data-options")?JSON.parse(s.attr("data-options")):{};if(n.indexOf("testAjax")>-1){window.sbi.triggeredTest=!0;a({action:"sbi_on_ajax_test_trigger"},function(i){console.log("did test")})}var d={cols:s.attr("data-cols"),colsmobile:"same"!==s.attr("data-colsmobile")?s.attr("data-colsmobile"):s.attr("data-cols"),num:s.attr("data-num"),imgRes:s.attr("data-res"),feedID:s.attr("data-feedid"),shortCodeAtts:s.attr("data-shortcode-atts"),resizingEnabled:-1===n.indexOf("resizeDisable"),imageLoadEnabled:-1===n.indexOf("imageLoadDisable"),debugEnabled:n.indexOf("debug")>-1,favorLocal:n.indexOf("favorLocal")>-1,ajaxPostLoad:n.indexOf("ajaxPostLoad")>-1,autoMinRes:1,general:o};window.sbi.feeds[e]=function(i,e,s){return new t(i,e,s)}(this,e,d),window.sbi.feeds[e].setResizedImages(),window.sbi.feeds[e].init();var r=jQuery.Event("sbiafterfeedcreate");r.feed=window.sbi.feeds[e],jQuery(window).trigger(r)}))},afterFeedsCreated:function(){i(".sb_instagram_header").each(function(){var e=i(this);e.find(".sbi_header_link").hover(function(){e.find(".sbi_header_img_hover").addClass("sbi_fade_in")},function(){e.find(".sbi_header_img_hover").removeClass("sbi_fade_in")})})},encodeHTML:function(i){return void 0===i?"":i.replace(/(>)/g,"&gt;").replace(/(<)/g,"&lt;").replace(/(&lt;br\/&gt;)/g,"<br>").replace(/(&lt;br&gt;)/g,"<br>")},urlDetect:function(i){return i.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/g)}},t.prototype={init:function(){var e=this;i(this.el).find("#sbi_mod_error").length&&i(this.el).prepend(i(this.el).find("#sbi_mod_error")),this.settings.ajaxPostLoad?this.getNewPostSet():this.afterInitialImagesLoaded();var s,t=(s=0,function(i,e){clearTimeout(s),s=setTimeout(i,e)});jQuery(window).resize(function(){t(function(){e.afterResize()},500)})},initLayout:function(){},afterInitialImagesLoaded:function(){this.initLayout(),this.loadMoreButtonInit(),this.hideExtraImagesForWidth(),this.beforeNewImagesRevealed(),this.revealNewImages(),this.afterNewImagesRevealed()},afterResize:function(){this.setImageHeight(),this.setImageResolution(),this.maybeRaiseImageResolution(),this.setImageSizeClass()},afterLoadMoreClicked:function(i){i.find(".sbi_loader").removeClass("sbi_hidden"),i.find(".sbi_btn_text").addClass("sbi_hidden"),i.closest(".sbi").find(".sbi_num_diff_hide").addClass("sbi_transition").removeClass("sbi_num_diff_hide")},afterNewImagesLoaded:function(){var e=i(this.el),s=this;this.beforeNewImagesRevealed(),this.revealNewImages(),this.afterNewImagesRevealed(),setTimeout(function(){e.find(".sbi_loader").addClass("sbi_hidden"),e.find(".sbi_btn_text").removeClass("sbi_hidden"),s.maybeRaiseImageResolution()},500)},beforeNewImagesRevealed:function(){this.setImageHeight(),this.maybeRaiseImageResolution(!0),this.setImageSizeClass()},revealNewImages:function(){var e=i(this.el);e.find(".sbi-screenreader").each(function(){i(this).find("img").remove()}),"function"==typeof sbi_custom_js&&setTimeout(function(){sbi_custom_js()},100),this.applyImageLiquid(),e.find(".sbi_item").each(function(i){jQuery(this).find(".sbi_photo").hover(function(){jQuery(this).fadeTo(200,.85)},function(){jQuery(this).stop().fadeTo(500,1)})}),setTimeout(function(){jQuery("#sbi_images .sbi_item.sbi_new").removeClass("sbi_new");var i=10;e.find(".sbi_transition").each(function(){var e=jQuery(this);setTimeout(function(){e.removeClass("sbi_transition")},i),i+=10})},500)},afterNewImagesRevealed:function(){this.listenForVisibilityChange(),this.sendNeedsResizingToServer(),this.settings.imageLoadEnabled||i(".sbi_no_resraise").removeClass("sbi_no_resraise");var e=i.Event("sbiafterimagesloaded");e.el=i(this.el),i(window).trigger(e)},setResizedImages:function(){i(this.el).find(".sbi_resized_image_data").length&&void 0!==i(this.el).find(".sbi_resized_image_data").attr("data-resized")&&0===i(this.el).find(".sbi_resized_image_data").attr("data-resized").indexOf('{"')&&(this.resizedImages=JSON.parse(i(this.el).find(".sbi_resized_image_data").attr("data-resized")),i(this.el).find(".sbi_resized_image_data").remove())},sendNeedsResizingToServer:function(){var e=this;if(e.needsResizing.length>0&&e.settings.resizingEnabled){var s=i(this.el).find(".sbi_item").length;a({action:"sbi_resized_images_submit",needs_resizing:e.needsResizing,offset:s,feed_id:e.settings.feedID,atts:e.settings.shortCodeAtts},function(i){if(0===i.trim().indexOf("{")){var s=JSON.parse(i);e.settings.debugEnabled&&console.log(s)}})}},loadMoreButtonInit:function(){var e=i(this.el),s=this;e.find("#sbi_load .sbi_load_btn").off().on("click",function(){s.afterLoadMoreClicked(jQuery(this)),s.getNewPostSet()})},getNewPostSet:function(){var e=i(this.el),s=this;a({action:"sbi_load_more_clicked",offset:e.find(".sbi_item").length,feed_id:s.settings.feedID,atts:s.settings.shortCodeAtts,current_resolution:s.imageResolution},function(t){if(0===t.trim().indexOf("{")){var a=JSON.parse(t);s.settings.debugEnabled&&console.log(a),s.appendNewPosts(a.html),s.addResizedImages(a.resizedImages),s.settings.ajaxPostLoad?(s.settings.ajaxPostLoad=!1,s.afterInitialImagesLoaded()):s.afterNewImagesLoaded(),a.feedStatus.shouldPaginate?s.outOfPages=!1:(s.outOfPages=!0,e.find(".sbi_load_btn").hide()),i(".sbi_no_js").removeClass("sbi_no_js")}})},appendNewPosts:function(e){var s=i(this.el);s.find("#sbi_images .sbi_item").length?s.find("#sbi_images .sbi_item").last().after(e):s.find("#sbi_images").append(e)},addResizedImages:function(i){for(var e in i)this.resizedImages[e]=i[e]},setImageHeight:function(){var e=i(this.el),s=e.find(".sbi_photo").eq(0).innerWidth(),t=this.getColumnCount(),a=e.find("#sbi_images").innerWidth()-e.find("#sbi_images").width(),n=a/2;sbi_photo_width_manual=e.find("#sbi_images").width()/t-a,e.find(".sbi_photo").css("height",s),e.find(".sbi-owl-nav").length&&setTimeout(function(){var i=2;e.find(".sbi_owl2row-item").length&&(i=1);var s=e.find(".sbi_photo").eq(0).innerWidth()/i;s+=parseInt(n)*(2-i+2),e.find(".sbi-owl-nav div").css("top",s)},100)},maybeRaiseSingleImageResolution:function(e,s,t){var a=this,n=a.getImageUrls(e),o=e.find(".sbi_photo img").attr("src"),d=150,r=e.find("img").get(0),l=o===window.sbi.options.placeholder?1:r.naturalWidth/r.naturalHeight;t=void 0!==t&&t;if(!(e.hasClass("sbi_no_resraise")||e.hasClass("sbi_had_error")||e.find(".sbi_link_area").length&&e.find(".sbi_link_area").hasClass("sbi_had_error"))){i.each(n,function(i,e){e===o&&(d=parseInt(i),t=!1)});var h=640;switch(a.settings.imgRes){case"thumb":h=150;break;case"medium":h=320;break;case"full":h=640;break;default:var g=Math.max(a.settings.autoMinRes,e.find(".sbi_photo").innerWidth()),u=a.getBestResolutionForAuto(g,l,e);switch(u){case 320:h=320;break;case 150:h=150}}if(h>d||o===window.sbi.options.placeholder||t){if(a.settings.debugEnabled){var m=o===window.sbi.options.placeholder?"was placeholder":"too small";console.log("raise res for "+o,m)}var _=n[h].split("?ig_cache_key")[0];if(e.find(".sbi_photo img").attr("src",_),e.find(".sbi_photo").css("background-image",'url("'+_+'")'),d=h,"auto"===a.settings.imgRes){var f=!1;e.find(".sbi_photo img").on("load",function(){var s=i(this),t=s.get(0).naturalWidth/s.get(0).naturalHeight;if(1e3!==s.get(0).naturalWidth&&t>l&&!f){switch(a.settings.debugEnabled&&console.log("raise res again for aspect ratio change "+o),f=!0,g=e.find(".sbi_photo").innerWidth(),u=a.getBestResolutionForAuto(g,t,e),h=640,u){case 320:h=320;break;case 150:h=150}h>d&&(_=n[h].split("?ig_cache_key")[0],s.attr("src",_),s.closest(".sbi_photo").css("background-image",'url("'+_+'")')),"masonry"!==a.layout&&"highlight"!==a.layout||(i(a.el).find("#sbi_images").smashotope(a.isotopeArgs),setTimeout(function(){i(a.el).find("#sbi_images").smashotope(a.isotopeArgs)},500))}else if(a.settings.debugEnabled){var r=f?"already checked":"no aspect ratio change";console.log("not raising res for replacement "+o,r)}})}}e.find("img").on("error",function(){if(i(this).hasClass("sbi_img_error"))console.log("unfixed error "+i(this).attr("src"));else{var e;if(i(this).addClass("sbi_img_error"),i(this).attr("src").indexOf("media/?size=")>-1||i(this).attr("src").indexOf("cdninstagram")>-1||i(this).attr("src").indexOf("fbcdn")>-1)a.settings.favorLocal=!0,void 0!==(e=a.getImageUrls(i(this).closest(".sbi_item")))[640]&&(i(this).attr("src",e[640]),i(this).closest(".sbi_photo").css("background-image","url("+e[640]+")"),i(this).closest(".sbi_item").addClass("sbi_had_error").find(".sbi_link_area").attr("href",e[640]).addClass("sbi_had_error"));else if("undefined"!==i(this).closest(".sbi_photo").attr("data-img-src-set"))void 0!==(e=JSON.parse(i(this).closest(".sbi_photo").attr("data-img-src-set").replace(/\\\//g,"/"))).d&&(i(this).attr("src",e.d),i(this).closest(".sbi_photo").css("background-image","url("+e.d+")"),i(this).closest(".sbi_item").addClass("sbi_had_error").find(".sbi_link_area").attr("href",e[640]).addClass("sbi_had_error"));setTimeout(function(){a.afterResize()},1500)}})}},maybeRaiseImageResolution:function(e){var s=this,t=void 0!==e&&!0===e?".sbi_item.sbi_new":".sbi_item",a=!s.isInitialized;i(s.el).find(t).each(function(e){!i(this).hasClass("sbi_num_diff_hide")&&i(this).find(".sbi_photo").length&&void 0!==i(this).find(".sbi_photo").attr("data-img-src-set")&&s.maybeRaiseSingleImageResolution(i(this),e,a)}),s.isInitialized=!0},getBestResolutionForAuto:function(e,s,t){(isNaN(s)||s<1)&&(s=1);var a=e*s,n=10*Math.ceil(a/10),o=[150,320,640];if(t.hasClass("sbi_highlighted")&&(n*=2),-1===o.indexOf(parseInt(n))){var d=!1;i.each(o,function(i,e){e>parseInt(n)&&!d&&(n=e,d=!0)})}return n},hideExtraImagesForWidth:function(){if("carousel"!==this.layout){var e=i(this.el),s=void 0!==e.attr("data-num")&&""!==e.attr("data-num")?parseInt(e.attr("data-num")):1,t=void 0!==e.attr("data-nummobile")&&""!==e.attr("data-nummobile")?parseInt(e.attr("data-nummobile")):s;i(window).width()<480?t<e.find(".sbi_item").length&&e.find(".sbi_item").slice(t-e.find(".sbi_item").length).addClass("sbi_num_diff_hide"):s<e.find(".sbi_item").length&&e.find(".sbi_item").slice(s-e.find(".sbi_item").length).addClass("sbi_num_diff_hide")}},setImageSizeClass:function(){var e=i(this.el);e.removeClass("sbi_small sbi_medium");var s=e.innerWidth(),t=parseInt(e.find("#sbi_images").outerWidth()-e.find("#sbi_images").width())/2,a=this.getColumnCount(),n=(s-t*(a+2))/a;n>120&&n<240?e.addClass("sbi_medium"):n<=120&&e.addClass("sbi_small")},setMinImageWidth:function(){i(this.el).find(".sbi_item .sbi_photo").first().length?this.minImageWidth=i(this.el).find(".sbi_item .sbi_photo").first().innerWidth():this.minImageWidth=150},setImageResolution:function(){if("auto"===this.settings.imgRes)this.imageResolution="auto";else switch(this.settings.imgRes){case"thumb":this.imageResolution=150;break;case"medium":this.imageResolution=320;break;default:this.imageResolution=640}},getImageUrls:function(i){var e=JSON.parse(i.find(".sbi_photo").attr("data-img-src-set").replace(/\\\//g,"/")),s=i.attr("id").replace("sbi_","");if(void 0!==this.resizedImages[s]&&"video"!==this.resizedImages[s]&&"pending"!==this.resizedImages[s]&&"error"!==this.resizedImages[s].id&&"video"!==this.resizedImages[s].id&&"pending"!==this.resizedImages[s].id){if(void 0!==this.resizedImages[s].sizes){var t=[];void 0!==this.resizedImages[s].sizes.full&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg",t.push(640)),void 0!==this.resizedImages[s].sizes.low&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg",t.push(320)),void 0!==this.resizedImages[s].sizes.thumb&&(t.push(150),e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"thumb.jpg"),this.settings.favorLocal&&(-1===t.indexOf(640)&&t.indexOf(320)>-1&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg"),-1===t.indexOf(320)&&(t.indexOf(640)>-1?e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg":t.indexOf(150)>-1&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"thumb.jpg")),-1===t.indexOf(150)&&(t.indexOf(320)>-1?e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg":t.indexOf(640)>-1&&(e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg")))}}else(void 0===this.resizedImages[s]||void 0!==this.resizedImages[s].id&&"pending"!==this.resizedImages[s].id&&"error"!==this.resizedImages[s].id)&&this.addToNeedsResizing(s);return e},getAvatarUrl:function(i,e){if(""===i)return"";var s=this.settings.general.avatars;return"local"===(e=void 0!==e?e:"local")?void 0!==s["LCL"+i]&&1===parseInt(s["LCL"+i])?sb_instagram_js_options.resized_url+i+".jpg":void 0!==s[i]?s[i]:"":void 0!==s[i]?s[i]:void 0!==s["LCL"+i]&&1===parseInt(s["LCL"+i])?sb_instagram_js_options.resized_url+i+".jpg":""},addToNeedsResizing:function(i){-1===this.needsResizing.indexOf(i)&&this.needsResizing.push(i)},applyImageLiquid:function(){var s=i(this.el);e(),"function"==typeof s.find(".sbi_photo").sbi_imgLiquid&&s.find(".sbi_photo").sbi_imgLiquid({fill:!0})},listenForVisibilityChange:function(){var e,s,t,a=this;e=jQuery,s={callback:function(){},runOnLoad:!0,frequency:100,sbiPreviousVisibility:null},t={sbiCheckVisibility:function(i,e){if(jQuery.contains(document,i[0])){var s=e.sbiPreviousVisibility,a=i.is(":visible");e.sbiPreviousVisibility=a,null==s?e.runOnLoad&&e.callback(i,a):s!==a&&e.callback(i,a),setTimeout(function(){t.sbiCheckVisibility(i,e)},e.frequency)}}},e.fn.sbiVisibilityChanged=function(i){var a=e.extend({},s,i);return this.each(function(){t.sbiCheckVisibility(e(this),a)})},"function"==typeof i(this.el).filter(":hidden").sbiVisibilityChanged&&i(this.el).filter(":hidden").sbiVisibilityChanged({callback:function(i,e){a.afterResize()},runOnLoad:!1})},getColumnCount:function(){var e=i(this.el),s=this.settings.cols,t=this.settings.colsmobile,a=s;return sbiWindowWidth=window.innerWidth,e.hasClass("sbi_mob_col_auto")?(sbiWindowWidth<640&&parseInt(s)>2&&parseInt(s)<7&&(a=2),sbiWindowWidth<640&&parseInt(s)>6&&parseInt(s)<11&&(a=4),sbiWindowWidth<=480&&parseInt(s)>2&&(a=1)):sbiWindowWidth<=480&&(a=t),parseInt(a)}},window.sbi_init=function(){window.sbi=new s,window.sbi.createPage(window.sbi.createFeeds,{whenFeedsCreated:window.sbi.afterFeedsCreated})}}(jQuery),jQuery(document).ready(function(i){void 0===window.sb_instagram_js_options&&(window.sb_instagram_js_options={font_method:"svg",resized_url:location.protocol+"//"+window.location.hostname+"/wp-content/uploads/sb-instagram-feed-images/",placeholder:location.protocol+"//"+window.location.hostname+"/wp-content/plugins/instagram-feed/img/placeholder.png"}),void 0!==window.sb_instagram_js_options.resized_url&&-1===window.sb_instagram_js_options.resized_url.indexOf(location.protocol)&&("http:"===location.protocol?window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("http:","https:"):window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("https:","http:")),sbi_init()}));
js/sb-instagram-admin-2-2.js CHANGED
@@ -268,7 +268,7 @@ jQuery(document).ready(function($) {
268
  $('#sbi_connected_account_'+savedToken.user_id + ' .sbi_ca_username').prepend('<img class="sbi_ca_avatar" src="'+savedToken.profile_picture+'">');
269
  }
270
  }
271
- $('#sbi_connected_account_'+savedToken.user_id + ' .sbi_ca_username').find('span').text(sbiAccountType(savedToken.type));
272
 
273
  $('#sbi_connected_account_'+savedToken.user_id).find('.sbi_ca_accesstoken .sbi_ca_token').text(savedToken.access_token);
274
  $('#sbi_connected_account_'+savedToken.user_id).find('.sbi_tooltip code').text('[instagram-feed accesstoken="'+savedToken.access_token+'"]');
@@ -281,6 +281,7 @@ jQuery(document).ready(function($) {
281
  } else {
282
  var accountType = 'personal';
283
  }
 
284
 
285
  var avatarHTML = '';
286
  if (savedToken.profile_picture !== '') {
@@ -299,7 +300,7 @@ jQuery(document).ready(function($) {
299
 
300
  '<div class="sbi_ca_username">'+
301
  avatarHTML+
302
- '<strong>'+savedToken.username+'<span>'+sbiAccountType(accountType)+'</span></strong>'+
303
  '</div>'+
304
 
305
  '<div class="sbi_ca_actions">'+
@@ -358,9 +359,13 @@ jQuery(document).ready(function($) {
358
  });
359
  }
360
 
361
- function sbiAccountType(accountType) {
362
  if (accountType === 'basic') {
363
- return 'personal (new API)';
 
 
 
 
364
  }
365
  return accountType;
366
  }
@@ -798,7 +803,9 @@ jQuery(document).ready(function($) {
798
  if( jQuery(this).hasClass('sbi_type_tooltip_link') ){
799
  jQuery(this).closest('.sbi_row').children('.sbi_tooltip').slideToggle();
800
  } else {
801
- jQuery(this).siblings('.sbi_tooltip').slideToggle();
 
 
802
  }
803
  });
804
 
268
  $('#sbi_connected_account_'+savedToken.user_id + ' .sbi_ca_username').prepend('<img class="sbi_ca_avatar" src="'+savedToken.profile_picture+'">');
269
  }
270
  }
271
+ $('#sbi_connected_account_'+savedToken.user_id + ' .sbi_ca_username').find('span').text(sbiAccountType(savedToken.type,false));
272
 
273
  $('#sbi_connected_account_'+savedToken.user_id).find('.sbi_ca_accesstoken .sbi_ca_token').text(savedToken.access_token);
274
  $('#sbi_connected_account_'+savedToken.user_id).find('.sbi_tooltip code').text('[instagram-feed accesstoken="'+savedToken.access_token+'"]');
281
  } else {
282
  var accountType = 'personal';
283
  }
284
+ var isPrivate = (typeof savedToken.private !== 'undefined');
285
 
286
  var avatarHTML = '';
287
  if (savedToken.profile_picture !== '') {
300
 
301
  '<div class="sbi_ca_username">'+
302
  avatarHTML+
303
+ '<strong>'+savedToken.username+'<span>'+sbiAccountType(accountType,isPrivate)+'</span></strong>'+
304
  '</div>'+
305
 
306
  '<div class="sbi_ca_actions">'+
359
  });
360
  }
361
 
362
+ function sbiAccountType(accountType,isPrivate) {
363
  if (accountType === 'basic') {
364
+ var returnText = 'personal';
365
+ if (isPrivate) {
366
+ returnText += ' (private)'
367
+ }
368
+ return returnText;
369
  }
370
  return accountType;
371
  }
803
  if( jQuery(this).hasClass('sbi_type_tooltip_link') ){
804
  jQuery(this).closest('.sbi_row').children('.sbi_tooltip').slideToggle();
805
  } else {
806
+ $el = jQuery(this);
807
+ if( jQuery(this).hasClass('sbi_tooltip_outside') ) $el = jQuery(this).parent();
808
+ $el.siblings('.sbi_tooltip').slideToggle();
809
  }
810
  });
811
 
js/sb-instagram.js CHANGED
@@ -541,7 +541,7 @@ if(!sbi_js_exists) {
541
  if (newRes > currentRes || currentUrl === window.sbi.options.placeholder || forceChange) {
542
  if (feed.settings.debugEnabled) {
543
  var reason = currentUrl === window.sbi.options.placeholder ? 'was placeholder' : 'too small';
544
- console.log('rais res for ' + currentUrl, reason);
545
  }
546
  var newUrl = imgSrcSet[newRes].split("?ig_cache_key")[0];
547
  $item.find('.sbi_photo img').attr('src', newUrl);
@@ -557,7 +557,7 @@ if(!sbi_js_exists) {
557
 
558
  if ($this_image.get(0).naturalWidth !== 1000 && newAspectRatio > aspectRatio && !checked) {
559
  if (feed.settings.debugEnabled) {
560
- console.log('rais res again for aspect ratio change ' + currentUrl);
561
  }
562
  checked = true;
563
  minImageWidth = $item.find('.sbi_photo').innerWidth();
541
  if (newRes > currentRes || currentUrl === window.sbi.options.placeholder || forceChange) {
542
  if (feed.settings.debugEnabled) {
543
  var reason = currentUrl === window.sbi.options.placeholder ? 'was placeholder' : 'too small';
544
+ console.log('raise res for ' + currentUrl, reason);
545
  }
546
  var newUrl = imgSrcSet[newRes].split("?ig_cache_key")[0];
547
  $item.find('.sbi_photo img').attr('src', newUrl);
557
 
558
  if ($this_image.get(0).naturalWidth !== 1000 && newAspectRatio > aspectRatio && !checked) {
559
  if (feed.settings.debugEnabled) {
560
+ console.log('raise res again for aspect ratio change ' + currentUrl);
561
  }
562
  checked = true;
563
  minImageWidth = $item.find('.sbi_photo').innerWidth();
js/sb-instagram.min.js CHANGED
@@ -1 +1 @@
1
- var sbi_js_exists=void 0!==sbi_js_exists;sbi_js_exists||(!function(i){function e(){var i,e,s,t=t||{VER:"0.9.944"};t.bgs_Available=!1,t.bgs_CheckRunned=!1,function(i){i.fn.extend({sbi_imgLiquid:function(e){this.defaults={fill:!0,verticalAlign:"center",horizontalAlign:"center",useBackgroundSize:!0,useDataHtmlAttr:!0,responsive:!0,delay:0,fadeInTime:0,removeBoxBackground:!0,hardPixels:!0,responsiveCheckTime:500,timecheckvisibility:500,onStart:null,onFinish:null,onItemStart:null,onItemFinish:null,onItemError:null},function(){if(!t.bgs_CheckRunned){t.bgs_CheckRunned=!0;var e=i('<span style="background-size:cover" />');i("body").append(e),function(){var i=e[0];if(i&&window.getComputedStyle){var s=window.getComputedStyle(i,null);s&&s.backgroundSize&&(t.bgs_Available="cover"===s.backgroundSize)}}(),e.remove()}}();var s=this;return this.options=e,this.settings=i.extend({},this.defaults,this.options),this.settings.onStart&&this.settings.onStart(),this.each(function(e){function a(){(r.responsive||h.data("sbi_imgLiquid_oldProcessed"))&&h.data("sbi_imgLiquid_settings")&&(r=h.data("sbi_imgLiquid_settings"),l.actualSize=l.get(0).offsetWidth+l.get(0).offsetHeight/1e4,l.sizeOld&&l.actualSize!==l.sizeOld&&o(),l.sizeOld=l.actualSize,setTimeout(a,r.responsiveCheckTime))}function n(){h.data("sbi_imgLiquid_error",!0),l.addClass("sbi_imgLiquid_error"),r.onItemError&&r.onItemError(e,l,h),d()}function o(){var i,s,t,a,n,o,g,u,m=0,_=0,f=l.width(),c=l.height();void 0===h.data("owidth")&&h.data("owidth",h[0].width),void 0===h.data("oheight")&&h.data("oheight",h[0].height),r.fill===f/c>=h.data("owidth")/h.data("oheight")?(i="100%",s="auto",t=Math.floor(f),a=Math.floor(f*(h.data("oheight")/h.data("owidth")))):(i="auto",s="100%",t=Math.floor(c*(h.data("owidth")/h.data("oheight"))),a=Math.floor(c)),g=f-t,"left"===(n=r.horizontalAlign.toLowerCase())&&(_=0),"center"===n&&(_=.5*g),"right"===n&&(_=g),-1!==n.indexOf("%")&&((n=parseInt(n.replace("%",""),10))>0&&(_=g*n*.01)),u=c-a,"left"===(o=r.verticalAlign.toLowerCase())&&(m=0),"center"===o&&(m=.5*u),"bottom"===o&&(m=u),-1!==o.indexOf("%")&&((o=parseInt(o.replace("%",""),10))>0&&(m=u*o*.01)),r.hardPixels&&(i=t,s=a),h.css({width:i,height:s,"margin-left":Math.floor(_),"margin-top":Math.floor(m)}),h.data("sbi_imgLiquid_oldProcessed")||(h.fadeTo(r.fadeInTime,1),h.data("sbi_imgLiquid_oldProcessed",!0),r.removeBoxBackground&&l.css("background-image","none"),l.addClass("sbi_imgLiquid_nobgSize"),l.addClass("sbi_imgLiquid_ready")),r.onItemFinish&&r.onItemFinish(e,l,h),d()}function d(){e===s.length-1&&s.settings.onFinish&&s.settings.onFinish()}var r=s.settings,l=i(this),h=i("img:first",l);return h.length?(h.data("sbi_imgLiquid_settings")?(l.removeClass("sbi_imgLiquid_error").removeClass("sbi_imgLiquid_ready"),r=i.extend({},h.data("sbi_imgLiquid_settings"),s.options)):r=i.extend({},s.settings,function(){var i={};if(s.settings.useDataHtmlAttr){var e=l.attr("data-sbi_imgLiquid-fill"),a=l.attr("data-sbi_imgLiquid-horizontalAlign"),n=l.attr("data-sbi_imgLiquid-verticalAlign");("true"===e||"false"===e)&&(i.fill=Boolean("true"===e)),void 0===a||"left"!==a&&"center"!==a&&"right"!==a&&-1===a.indexOf("%")||(i.horizontalAlign=a),void 0===n||"top"!==n&&"bottom"!==n&&"center"!==n&&-1===n.indexOf("%")||(i.verticalAlign=n)}return t.isIE&&s.settings.ieFadeInDisabled&&(i.fadeInTime=0),i}()),h.data("sbi_imgLiquid_settings",r),r.onItemStart&&r.onItemStart(e,l,h),void(t.bgs_Available&&r.useBackgroundSize?(-1===l.css("background-image").indexOf(encodeURI(h.attr("src")))&&l.css({"background-image":'url("'+encodeURI(h.attr("src"))+'")'}),l.css({"background-size":r.fill?"cover":"contain","background-position":(r.horizontalAlign+" "+r.verticalAlign).toLowerCase(),"background-repeat":"no-repeat"}),i("a:first",l).css({display:"block",width:"100%",height:"100%"}),i("img",l).css({display:"none"}),r.onItemFinish&&r.onItemFinish(e,l,h),l.addClass("sbi_imgLiquid_bgSize"),l.addClass("sbi_imgLiquid_ready"),d()):function s(){if(h.data("oldSrc")&&h.data("oldSrc")!==h.attr("src")){var t=h.clone().removeAttr("style");return t.data("sbi_imgLiquid_settings",h.data("sbi_imgLiquid_settings")),h.parent().prepend(t),h.remove(),(h=t)[0].width=0,void setTimeout(s,10)}return h.data("sbi_imgLiquid_oldProcessed")?void o():(h.data("sbi_imgLiquid_oldProcessed",!1),h.data("oldSrc",h.attr("src")),i("img:not(:first)",l).css("display","none"),l.css({overflow:"hidden"}),h.fadeTo(0,0).removeAttr("width").removeAttr("height").css({visibility:"visible","max-width":"none","max-height":"none",width:"auto",height:"auto",display:"block"}),h.on("error",n),h[0].onerror=n,function i(){h.data("sbi_imgLiquid_error")||h.data("sbi_imgLiquid_loaded")||h.data("sbi_imgLiquid_oldProcessed")||(l.is(":visible")&&h[0].complete&&h[0].width>0&&h[0].height>0?(h.data("sbi_imgLiquid_loaded",!0),setTimeout(o,e*r.delay)):setTimeout(i,r.timecheckvisibility))}(),void a())}())):void n()})}})}(jQuery),i=t.injectCss,e=document.getElementsByTagName("head")[0],(s=document.createElement("style")).type="text/css",s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i)),e.appendChild(s)}function s(){this.feeds={},this.options=sb_instagram_js_options}function t(i,e,s){this.el=i,this.index=e,this.settings=s,this.minImageWidth=0,this.imageResolution=150,this.resizedImages={},this.needsResizing=[],this.outOfPages=!1,this.isInitialized=!1}function a(e,s){i.ajax({url:sbiajaxurl,type:"post",data:e,success:s})}s.prototype={createPage:function(e,s){void 0!==window.sbiajaxurl&&-1!==window.sbiajaxurl.indexOf(window.location.hostname)||(window.sbiajaxurl=location.protocol+"//"+window.location.hostname+"/wp-admin/admin-ajax.php"),i(".sbi_no_js_error_message").remove(),i(".sbi_no_js").removeClass("sbi_no_js"),e(s)},createFeeds:function(e){e.whenFeedsCreated(i(".sbi").each(function(e){i(this).attr("data-sbi-index",e+1);var s=i(this),n=void 0!==s.attr("data-sbi-flags")?s.attr("data-sbi-flags").split(","):[],o=void 0!==s.attr("data-options")?JSON.parse(s.attr("data-options")):{};if(n.indexOf("testAjax")>-1){window.sbi.triggeredTest=!0;a({action:"sbi_on_ajax_test_trigger"},function(i){console.log("did test")})}var d={cols:s.attr("data-cols"),colsmobile:"same"!==s.attr("data-colsmobile")?s.attr("data-colsmobile"):s.attr("data-cols"),num:s.attr("data-num"),imgRes:s.attr("data-res"),feedID:s.attr("data-feedid"),shortCodeAtts:s.attr("data-shortcode-atts"),resizingEnabled:-1===n.indexOf("resizeDisable"),imageLoadEnabled:-1===n.indexOf("imageLoadDisable"),debugEnabled:n.indexOf("debug")>-1,favorLocal:n.indexOf("favorLocal")>-1,ajaxPostLoad:n.indexOf("ajaxPostLoad")>-1,autoMinRes:1,general:o};window.sbi.feeds[e]=function(i,e,s){return new t(i,e,s)}(this,e,d),window.sbi.feeds[e].setResizedImages(),window.sbi.feeds[e].init();var r=jQuery.Event("sbiafterfeedcreate");r.feed=window.sbi.feeds[e],jQuery(window).trigger(r)}))},afterFeedsCreated:function(){i(".sb_instagram_header").each(function(){var e=i(this);e.find(".sbi_header_link").hover(function(){e.find(".sbi_header_img_hover").addClass("sbi_fade_in")},function(){e.find(".sbi_header_img_hover").removeClass("sbi_fade_in")})})},encodeHTML:function(i){return void 0===i?"":i.replace(/(>)/g,"&gt;").replace(/(<)/g,"&lt;").replace(/(&lt;br\/&gt;)/g,"<br>").replace(/(&lt;br&gt;)/g,"<br>")},urlDetect:function(i){return i.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/g)}},t.prototype={init:function(){var e=this;i(this.el).find("#sbi_mod_error").length&&i(this.el).prepend(i(this.el).find("#sbi_mod_error")),this.settings.ajaxPostLoad?this.getNewPostSet():this.afterInitialImagesLoaded();var s,t=(s=0,function(i,e){clearTimeout(s),s=setTimeout(i,e)});jQuery(window).resize(function(){t(function(){e.afterResize()},500)})},initLayout:function(){},afterInitialImagesLoaded:function(){this.initLayout(),this.loadMoreButtonInit(),this.hideExtraImagesForWidth(),this.beforeNewImagesRevealed(),this.revealNewImages(),this.afterNewImagesRevealed()},afterResize:function(){this.setImageHeight(),this.setImageResolution(),this.maybeRaiseImageResolution(),this.setImageSizeClass()},afterLoadMoreClicked:function(i){i.find(".sbi_loader").removeClass("sbi_hidden"),i.find(".sbi_btn_text").addClass("sbi_hidden"),i.closest(".sbi").find(".sbi_num_diff_hide").addClass("sbi_transition").removeClass("sbi_num_diff_hide")},afterNewImagesLoaded:function(){var e=i(this.el),s=this;this.beforeNewImagesRevealed(),this.revealNewImages(),this.afterNewImagesRevealed(),setTimeout(function(){e.find(".sbi_loader").addClass("sbi_hidden"),e.find(".sbi_btn_text").removeClass("sbi_hidden"),s.maybeRaiseImageResolution()},500)},beforeNewImagesRevealed:function(){this.setImageHeight(),this.maybeRaiseImageResolution(!0),this.setImageSizeClass()},revealNewImages:function(){var e=i(this.el);e.find(".sbi-screenreader").each(function(){i(this).find("img").remove()}),"function"==typeof sbi_custom_js&&setTimeout(function(){sbi_custom_js()},100),this.applyImageLiquid(),e.find(".sbi_item").each(function(i){jQuery(this).find(".sbi_photo").hover(function(){jQuery(this).fadeTo(200,.85)},function(){jQuery(this).stop().fadeTo(500,1)})}),setTimeout(function(){jQuery("#sbi_images .sbi_item.sbi_new").removeClass("sbi_new");var i=10;e.find(".sbi_transition").each(function(){var e=jQuery(this);setTimeout(function(){e.removeClass("sbi_transition")},i),i+=10})},500)},afterNewImagesRevealed:function(){this.listenForVisibilityChange(),this.sendNeedsResizingToServer(),this.settings.imageLoadEnabled||i(".sbi_no_resraise").removeClass("sbi_no_resraise");var e=i.Event("sbiafterimagesloaded");e.el=i(this.el),i(window).trigger(e)},setResizedImages:function(){i(this.el).find(".sbi_resized_image_data").length&&void 0!==i(this.el).find(".sbi_resized_image_data").attr("data-resized")&&0===i(this.el).find(".sbi_resized_image_data").attr("data-resized").indexOf('{"')&&(this.resizedImages=JSON.parse(i(this.el).find(".sbi_resized_image_data").attr("data-resized")),i(this.el).find(".sbi_resized_image_data").remove())},sendNeedsResizingToServer:function(){var e=this;if(e.needsResizing.length>0&&e.settings.resizingEnabled){var s=i(this.el).find(".sbi_item").length;a({action:"sbi_resized_images_submit",needs_resizing:e.needsResizing,offset:s,feed_id:e.settings.feedID,atts:e.settings.shortCodeAtts},function(i){if(0===i.trim().indexOf("{")){var s=JSON.parse(i);e.settings.debugEnabled&&console.log(s)}})}},loadMoreButtonInit:function(){var e=i(this.el),s=this;e.find("#sbi_load .sbi_load_btn").off().on("click",function(){s.afterLoadMoreClicked(jQuery(this)),s.getNewPostSet()})},getNewPostSet:function(){var e=i(this.el),s=this;a({action:"sbi_load_more_clicked",offset:e.find(".sbi_item").length,feed_id:s.settings.feedID,atts:s.settings.shortCodeAtts,current_resolution:s.imageResolution},function(t){if(0===t.trim().indexOf("{")){var a=JSON.parse(t);s.settings.debugEnabled&&console.log(a),s.appendNewPosts(a.html),s.addResizedImages(a.resizedImages),s.settings.ajaxPostLoad?(s.settings.ajaxPostLoad=!1,s.afterInitialImagesLoaded()):s.afterNewImagesLoaded(),a.feedStatus.shouldPaginate?s.outOfPages=!1:(s.outOfPages=!0,e.find(".sbi_load_btn").hide()),i(".sbi_no_js").removeClass("sbi_no_js")}})},appendNewPosts:function(e){var s=i(this.el);s.find("#sbi_images .sbi_item").length?s.find("#sbi_images .sbi_item").last().after(e):s.find("#sbi_images").append(e)},addResizedImages:function(i){for(var e in i)this.resizedImages[e]=i[e]},setImageHeight:function(){var e=i(this.el),s=e.find(".sbi_photo").eq(0).innerWidth(),t=this.getColumnCount(),a=e.find("#sbi_images").innerWidth()-e.find("#sbi_images").width(),n=a/2;sbi_photo_width_manual=e.find("#sbi_images").width()/t-a,e.find(".sbi_photo").css("height",s),e.find(".sbi-owl-nav").length&&setTimeout(function(){var i=2;e.find(".sbi_owl2row-item").length&&(i=1);var s=e.find(".sbi_photo").eq(0).innerWidth()/i;s+=parseInt(n)*(2-i+2),e.find(".sbi-owl-nav div").css("top",s)},100)},maybeRaiseSingleImageResolution:function(e,s,t){var a=this,n=a.getImageUrls(e),o=e.find(".sbi_photo img").attr("src"),d=150,r=e.find("img").get(0),l=o===window.sbi.options.placeholder?1:r.naturalWidth/r.naturalHeight;t=void 0!==t&&t;if(!(e.hasClass("sbi_no_resraise")||e.hasClass("sbi_had_error")||e.find(".sbi_link_area").length&&e.find(".sbi_link_area").hasClass("sbi_had_error"))){i.each(n,function(i,e){e===o&&(d=parseInt(i),t=!1)});var h=640;switch(a.settings.imgRes){case"thumb":h=150;break;case"medium":h=320;break;case"full":h=640;break;default:var g=Math.max(a.settings.autoMinRes,e.find(".sbi_photo").innerWidth()),u=a.getBestResolutionForAuto(g,l,e);switch(u){case 320:h=320;break;case 150:h=150}}if(h>d||o===window.sbi.options.placeholder||t){if(a.settings.debugEnabled){var m=o===window.sbi.options.placeholder?"was placeholder":"too small";console.log("rais res for "+o,m)}var _=n[h].split("?ig_cache_key")[0];if(e.find(".sbi_photo img").attr("src",_),e.find(".sbi_photo").css("background-image",'url("'+_+'")'),d=h,"auto"===a.settings.imgRes){var f=!1;e.find(".sbi_photo img").on("load",function(){var s=i(this),t=s.get(0).naturalWidth/s.get(0).naturalHeight;if(1e3!==s.get(0).naturalWidth&&t>l&&!f){switch(a.settings.debugEnabled&&console.log("rais res again for aspect ratio change "+o),f=!0,g=e.find(".sbi_photo").innerWidth(),u=a.getBestResolutionForAuto(g,t,e),h=640,u){case 320:h=320;break;case 150:h=150}h>d&&(_=n[h].split("?ig_cache_key")[0],s.attr("src",_),s.closest(".sbi_photo").css("background-image",'url("'+_+'")')),"masonry"!==a.layout&&"highlight"!==a.layout||(i(a.el).find("#sbi_images").smashotope(a.isotopeArgs),setTimeout(function(){i(a.el).find("#sbi_images").smashotope(a.isotopeArgs)},500))}else if(a.settings.debugEnabled){var r=f?"already checked":"no aspect ratio change";console.log("not raising res for replacement "+o,r)}})}}e.find("img").on("error",function(){if(i(this).hasClass("sbi_img_error"))console.log("unfixed error "+i(this).attr("src"));else{var e;if(i(this).addClass("sbi_img_error"),i(this).attr("src").indexOf("media/?size=")>-1||i(this).attr("src").indexOf("cdninstagram")>-1||i(this).attr("src").indexOf("fbcdn")>-1)a.settings.favorLocal=!0,void 0!==(e=a.getImageUrls(i(this).closest(".sbi_item")))[640]&&(i(this).attr("src",e[640]),i(this).closest(".sbi_photo").css("background-image","url("+e[640]+")"),i(this).closest(".sbi_item").addClass("sbi_had_error").find(".sbi_link_area").attr("href",e[640]).addClass("sbi_had_error"));else if("undefined"!==i(this).closest(".sbi_photo").attr("data-img-src-set"))void 0!==(e=JSON.parse(i(this).closest(".sbi_photo").attr("data-img-src-set").replace(/\\\//g,"/"))).d&&(i(this).attr("src",e.d),i(this).closest(".sbi_photo").css("background-image","url("+e.d+")"),i(this).closest(".sbi_item").addClass("sbi_had_error").find(".sbi_link_area").attr("href",e[640]).addClass("sbi_had_error"));setTimeout(function(){a.afterResize()},1500)}})}},maybeRaiseImageResolution:function(e){var s=this,t=void 0!==e&&!0===e?".sbi_item.sbi_new":".sbi_item",a=!s.isInitialized;i(s.el).find(t).each(function(e){!i(this).hasClass("sbi_num_diff_hide")&&i(this).find(".sbi_photo").length&&void 0!==i(this).find(".sbi_photo").attr("data-img-src-set")&&s.maybeRaiseSingleImageResolution(i(this),e,a)}),s.isInitialized=!0},getBestResolutionForAuto:function(e,s,t){(isNaN(s)||s<1)&&(s=1);var a=e*s,n=10*Math.ceil(a/10),o=[150,320,640];if(t.hasClass("sbi_highlighted")&&(n*=2),-1===o.indexOf(parseInt(n))){var d=!1;i.each(o,function(i,e){e>parseInt(n)&&!d&&(n=e,d=!0)})}return n},hideExtraImagesForWidth:function(){if("carousel"!==this.layout){var e=i(this.el),s=void 0!==e.attr("data-num")&&""!==e.attr("data-num")?parseInt(e.attr("data-num")):1,t=void 0!==e.attr("data-nummobile")&&""!==e.attr("data-nummobile")?parseInt(e.attr("data-nummobile")):s;i(window).width()<480?t<e.find(".sbi_item").length&&e.find(".sbi_item").slice(t-e.find(".sbi_item").length).addClass("sbi_num_diff_hide"):s<e.find(".sbi_item").length&&e.find(".sbi_item").slice(s-e.find(".sbi_item").length).addClass("sbi_num_diff_hide")}},setImageSizeClass:function(){var e=i(this.el);e.removeClass("sbi_small sbi_medium");var s=e.innerWidth(),t=parseInt(e.find("#sbi_images").outerWidth()-e.find("#sbi_images").width())/2,a=this.getColumnCount(),n=(s-t*(a+2))/a;n>120&&n<240?e.addClass("sbi_medium"):n<=120&&e.addClass("sbi_small")},setMinImageWidth:function(){i(this.el).find(".sbi_item .sbi_photo").first().length?this.minImageWidth=i(this.el).find(".sbi_item .sbi_photo").first().innerWidth():this.minImageWidth=150},setImageResolution:function(){if("auto"===this.settings.imgRes)this.imageResolution="auto";else switch(this.settings.imgRes){case"thumb":this.imageResolution=150;break;case"medium":this.imageResolution=320;break;default:this.imageResolution=640}},getImageUrls:function(i){var e=JSON.parse(i.find(".sbi_photo").attr("data-img-src-set").replace(/\\\//g,"/")),s=i.attr("id").replace("sbi_","");if(void 0!==this.resizedImages[s]&&"video"!==this.resizedImages[s]&&"pending"!==this.resizedImages[s]&&"error"!==this.resizedImages[s].id&&"video"!==this.resizedImages[s].id&&"pending"!==this.resizedImages[s].id){if(void 0!==this.resizedImages[s].sizes){var t=[];void 0!==this.resizedImages[s].sizes.full&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg",t.push(640)),void 0!==this.resizedImages[s].sizes.low&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg",t.push(320)),void 0!==this.resizedImages[s].sizes.thumb&&(t.push(150),e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"thumb.jpg"),this.settings.favorLocal&&(-1===t.indexOf(640)&&t.indexOf(320)>-1&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg"),-1===t.indexOf(320)&&(t.indexOf(640)>-1?e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg":t.indexOf(150)>-1&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"thumb.jpg")),-1===t.indexOf(150)&&(t.indexOf(320)>-1?e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg":t.indexOf(640)>-1&&(e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg")))}}else(void 0===this.resizedImages[s]||void 0!==this.resizedImages[s].id&&"pending"!==this.resizedImages[s].id&&"error"!==this.resizedImages[s].id)&&this.addToNeedsResizing(s);return e},getAvatarUrl:function(i,e){if(""===i)return"";var s=this.settings.general.avatars;return"local"===(e=void 0!==e?e:"local")?void 0!==s["LCL"+i]&&1===parseInt(s["LCL"+i])?sb_instagram_js_options.resized_url+i+".jpg":void 0!==s[i]?s[i]:"":void 0!==s[i]?s[i]:void 0!==s["LCL"+i]&&1===parseInt(s["LCL"+i])?sb_instagram_js_options.resized_url+i+".jpg":""},addToNeedsResizing:function(i){-1===this.needsResizing.indexOf(i)&&this.needsResizing.push(i)},applyImageLiquid:function(){var s=i(this.el);e(),"function"==typeof s.find(".sbi_photo").sbi_imgLiquid&&s.find(".sbi_photo").sbi_imgLiquid({fill:!0})},listenForVisibilityChange:function(){var e,s,t,a=this;e=jQuery,s={callback:function(){},runOnLoad:!0,frequency:100,sbiPreviousVisibility:null},t={sbiCheckVisibility:function(i,e){if(jQuery.contains(document,i[0])){var s=e.sbiPreviousVisibility,a=i.is(":visible");e.sbiPreviousVisibility=a,null==s?e.runOnLoad&&e.callback(i,a):s!==a&&e.callback(i,a),setTimeout(function(){t.sbiCheckVisibility(i,e)},e.frequency)}}},e.fn.sbiVisibilityChanged=function(i){var a=e.extend({},s,i);return this.each(function(){t.sbiCheckVisibility(e(this),a)})},"function"==typeof i(this.el).filter(":hidden").sbiVisibilityChanged&&i(this.el).filter(":hidden").sbiVisibilityChanged({callback:function(i,e){a.afterResize()},runOnLoad:!1})},getColumnCount:function(){var e=i(this.el),s=this.settings.cols,t=this.settings.colsmobile,a=s;return sbiWindowWidth=window.innerWidth,e.hasClass("sbi_mob_col_auto")?(sbiWindowWidth<640&&parseInt(s)>2&&parseInt(s)<7&&(a=2),sbiWindowWidth<640&&parseInt(s)>6&&parseInt(s)<11&&(a=4),sbiWindowWidth<=480&&parseInt(s)>2&&(a=1)):sbiWindowWidth<=480&&(a=t),parseInt(a)}},window.sbi_init=function(){window.sbi=new s,window.sbi.createPage(window.sbi.createFeeds,{whenFeedsCreated:window.sbi.afterFeedsCreated})}}(jQuery),jQuery(document).ready(function(i){void 0===window.sb_instagram_js_options&&(window.sb_instagram_js_options={font_method:"svg",resized_url:location.protocol+"//"+window.location.hostname+"/wp-content/uploads/sb-instagram-feed-images/",placeholder:location.protocol+"//"+window.location.hostname+"/wp-content/plugins/instagram-feed/img/placeholder.png"}),void 0!==window.sb_instagram_js_options.resized_url&&-1===window.sb_instagram_js_options.resized_url.indexOf(location.protocol)&&("http:"===location.protocol?window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("http:","https:"):window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("https:","http:")),sbi_init()}));
1
+ var sbi_js_exists=void 0!==sbi_js_exists;sbi_js_exists||(!function(i){function e(){var i,e,s,t=t||{VER:"0.9.944"};t.bgs_Available=!1,t.bgs_CheckRunned=!1,function(i){i.fn.extend({sbi_imgLiquid:function(e){this.defaults={fill:!0,verticalAlign:"center",horizontalAlign:"center",useBackgroundSize:!0,useDataHtmlAttr:!0,responsive:!0,delay:0,fadeInTime:0,removeBoxBackground:!0,hardPixels:!0,responsiveCheckTime:500,timecheckvisibility:500,onStart:null,onFinish:null,onItemStart:null,onItemFinish:null,onItemError:null},function(){if(!t.bgs_CheckRunned){t.bgs_CheckRunned=!0;var e=i('<span style="background-size:cover" />');i("body").append(e),function(){var i=e[0];if(i&&window.getComputedStyle){var s=window.getComputedStyle(i,null);s&&s.backgroundSize&&(t.bgs_Available="cover"===s.backgroundSize)}}(),e.remove()}}();var s=this;return this.options=e,this.settings=i.extend({},this.defaults,this.options),this.settings.onStart&&this.settings.onStart(),this.each(function(e){function a(){(r.responsive||h.data("sbi_imgLiquid_oldProcessed"))&&h.data("sbi_imgLiquid_settings")&&(r=h.data("sbi_imgLiquid_settings"),l.actualSize=l.get(0).offsetWidth+l.get(0).offsetHeight/1e4,l.sizeOld&&l.actualSize!==l.sizeOld&&o(),l.sizeOld=l.actualSize,setTimeout(a,r.responsiveCheckTime))}function n(){h.data("sbi_imgLiquid_error",!0),l.addClass("sbi_imgLiquid_error"),r.onItemError&&r.onItemError(e,l,h),d()}function o(){var i,s,t,a,n,o,g,u,m=0,_=0,f=l.width(),c=l.height();void 0===h.data("owidth")&&h.data("owidth",h[0].width),void 0===h.data("oheight")&&h.data("oheight",h[0].height),r.fill===f/c>=h.data("owidth")/h.data("oheight")?(i="100%",s="auto",t=Math.floor(f),a=Math.floor(f*(h.data("oheight")/h.data("owidth")))):(i="auto",s="100%",t=Math.floor(c*(h.data("owidth")/h.data("oheight"))),a=Math.floor(c)),g=f-t,"left"===(n=r.horizontalAlign.toLowerCase())&&(_=0),"center"===n&&(_=.5*g),"right"===n&&(_=g),-1!==n.indexOf("%")&&((n=parseInt(n.replace("%",""),10))>0&&(_=g*n*.01)),u=c-a,"left"===(o=r.verticalAlign.toLowerCase())&&(m=0),"center"===o&&(m=.5*u),"bottom"===o&&(m=u),-1!==o.indexOf("%")&&((o=parseInt(o.replace("%",""),10))>0&&(m=u*o*.01)),r.hardPixels&&(i=t,s=a),h.css({width:i,height:s,"margin-left":Math.floor(_),"margin-top":Math.floor(m)}),h.data("sbi_imgLiquid_oldProcessed")||(h.fadeTo(r.fadeInTime,1),h.data("sbi_imgLiquid_oldProcessed",!0),r.removeBoxBackground&&l.css("background-image","none"),l.addClass("sbi_imgLiquid_nobgSize"),l.addClass("sbi_imgLiquid_ready")),r.onItemFinish&&r.onItemFinish(e,l,h),d()}function d(){e===s.length-1&&s.settings.onFinish&&s.settings.onFinish()}var r=s.settings,l=i(this),h=i("img:first",l);return h.length?(h.data("sbi_imgLiquid_settings")?(l.removeClass("sbi_imgLiquid_error").removeClass("sbi_imgLiquid_ready"),r=i.extend({},h.data("sbi_imgLiquid_settings"),s.options)):r=i.extend({},s.settings,function(){var i={};if(s.settings.useDataHtmlAttr){var e=l.attr("data-sbi_imgLiquid-fill"),a=l.attr("data-sbi_imgLiquid-horizontalAlign"),n=l.attr("data-sbi_imgLiquid-verticalAlign");("true"===e||"false"===e)&&(i.fill=Boolean("true"===e)),void 0===a||"left"!==a&&"center"!==a&&"right"!==a&&-1===a.indexOf("%")||(i.horizontalAlign=a),void 0===n||"top"!==n&&"bottom"!==n&&"center"!==n&&-1===n.indexOf("%")||(i.verticalAlign=n)}return t.isIE&&s.settings.ieFadeInDisabled&&(i.fadeInTime=0),i}()),h.data("sbi_imgLiquid_settings",r),r.onItemStart&&r.onItemStart(e,l,h),void(t.bgs_Available&&r.useBackgroundSize?(-1===l.css("background-image").indexOf(encodeURI(h.attr("src")))&&l.css({"background-image":'url("'+encodeURI(h.attr("src"))+'")'}),l.css({"background-size":r.fill?"cover":"contain","background-position":(r.horizontalAlign+" "+r.verticalAlign).toLowerCase(),"background-repeat":"no-repeat"}),i("a:first",l).css({display:"block",width:"100%",height:"100%"}),i("img",l).css({display:"none"}),r.onItemFinish&&r.onItemFinish(e,l,h),l.addClass("sbi_imgLiquid_bgSize"),l.addClass("sbi_imgLiquid_ready"),d()):function s(){if(h.data("oldSrc")&&h.data("oldSrc")!==h.attr("src")){var t=h.clone().removeAttr("style");return t.data("sbi_imgLiquid_settings",h.data("sbi_imgLiquid_settings")),h.parent().prepend(t),h.remove(),(h=t)[0].width=0,void setTimeout(s,10)}return h.data("sbi_imgLiquid_oldProcessed")?void o():(h.data("sbi_imgLiquid_oldProcessed",!1),h.data("oldSrc",h.attr("src")),i("img:not(:first)",l).css("display","none"),l.css({overflow:"hidden"}),h.fadeTo(0,0).removeAttr("width").removeAttr("height").css({visibility:"visible","max-width":"none","max-height":"none",width:"auto",height:"auto",display:"block"}),h.on("error",n),h[0].onerror=n,function i(){h.data("sbi_imgLiquid_error")||h.data("sbi_imgLiquid_loaded")||h.data("sbi_imgLiquid_oldProcessed")||(l.is(":visible")&&h[0].complete&&h[0].width>0&&h[0].height>0?(h.data("sbi_imgLiquid_loaded",!0),setTimeout(o,e*r.delay)):setTimeout(i,r.timecheckvisibility))}(),void a())}())):void n()})}})}(jQuery),i=t.injectCss,e=document.getElementsByTagName("head")[0],(s=document.createElement("style")).type="text/css",s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i)),e.appendChild(s)}function s(){this.feeds={},this.options=sb_instagram_js_options}function t(i,e,s){this.el=i,this.index=e,this.settings=s,this.minImageWidth=0,this.imageResolution=150,this.resizedImages={},this.needsResizing=[],this.outOfPages=!1,this.isInitialized=!1}function a(e,s){i.ajax({url:sbiajaxurl,type:"post",data:e,success:s})}s.prototype={createPage:function(e,s){void 0!==window.sbiajaxurl&&-1!==window.sbiajaxurl.indexOf(window.location.hostname)||(window.sbiajaxurl=location.protocol+"//"+window.location.hostname+"/wp-admin/admin-ajax.php"),i(".sbi_no_js_error_message").remove(),i(".sbi_no_js").removeClass("sbi_no_js"),e(s)},createFeeds:function(e){e.whenFeedsCreated(i(".sbi").each(function(e){i(this).attr("data-sbi-index",e+1);var s=i(this),n=void 0!==s.attr("data-sbi-flags")?s.attr("data-sbi-flags").split(","):[],o=void 0!==s.attr("data-options")?JSON.parse(s.attr("data-options")):{};if(n.indexOf("testAjax")>-1){window.sbi.triggeredTest=!0;a({action:"sbi_on_ajax_test_trigger"},function(i){console.log("did test")})}var d={cols:s.attr("data-cols"),colsmobile:"same"!==s.attr("data-colsmobile")?s.attr("data-colsmobile"):s.attr("data-cols"),num:s.attr("data-num"),imgRes:s.attr("data-res"),feedID:s.attr("data-feedid"),shortCodeAtts:s.attr("data-shortcode-atts"),resizingEnabled:-1===n.indexOf("resizeDisable"),imageLoadEnabled:-1===n.indexOf("imageLoadDisable"),debugEnabled:n.indexOf("debug")>-1,favorLocal:n.indexOf("favorLocal")>-1,ajaxPostLoad:n.indexOf("ajaxPostLoad")>-1,autoMinRes:1,general:o};window.sbi.feeds[e]=function(i,e,s){return new t(i,e,s)}(this,e,d),window.sbi.feeds[e].setResizedImages(),window.sbi.feeds[e].init();var r=jQuery.Event("sbiafterfeedcreate");r.feed=window.sbi.feeds[e],jQuery(window).trigger(r)}))},afterFeedsCreated:function(){i(".sb_instagram_header").each(function(){var e=i(this);e.find(".sbi_header_link").hover(function(){e.find(".sbi_header_img_hover").addClass("sbi_fade_in")},function(){e.find(".sbi_header_img_hover").removeClass("sbi_fade_in")})})},encodeHTML:function(i){return void 0===i?"":i.replace(/(>)/g,"&gt;").replace(/(<)/g,"&lt;").replace(/(&lt;br\/&gt;)/g,"<br>").replace(/(&lt;br&gt;)/g,"<br>")},urlDetect:function(i){return i.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/g)}},t.prototype={init:function(){var e=this;i(this.el).find("#sbi_mod_error").length&&i(this.el).prepend(i(this.el).find("#sbi_mod_error")),this.settings.ajaxPostLoad?this.getNewPostSet():this.afterInitialImagesLoaded();var s,t=(s=0,function(i,e){clearTimeout(s),s=setTimeout(i,e)});jQuery(window).resize(function(){t(function(){e.afterResize()},500)})},initLayout:function(){},afterInitialImagesLoaded:function(){this.initLayout(),this.loadMoreButtonInit(),this.hideExtraImagesForWidth(),this.beforeNewImagesRevealed(),this.revealNewImages(),this.afterNewImagesRevealed()},afterResize:function(){this.setImageHeight(),this.setImageResolution(),this.maybeRaiseImageResolution(),this.setImageSizeClass()},afterLoadMoreClicked:function(i){i.find(".sbi_loader").removeClass("sbi_hidden"),i.find(".sbi_btn_text").addClass("sbi_hidden"),i.closest(".sbi").find(".sbi_num_diff_hide").addClass("sbi_transition").removeClass("sbi_num_diff_hide")},afterNewImagesLoaded:function(){var e=i(this.el),s=this;this.beforeNewImagesRevealed(),this.revealNewImages(),this.afterNewImagesRevealed(),setTimeout(function(){e.find(".sbi_loader").addClass("sbi_hidden"),e.find(".sbi_btn_text").removeClass("sbi_hidden"),s.maybeRaiseImageResolution()},500)},beforeNewImagesRevealed:function(){this.setImageHeight(),this.maybeRaiseImageResolution(!0),this.setImageSizeClass()},revealNewImages:function(){var e=i(this.el);e.find(".sbi-screenreader").each(function(){i(this).find("img").remove()}),"function"==typeof sbi_custom_js&&setTimeout(function(){sbi_custom_js()},100),this.applyImageLiquid(),e.find(".sbi_item").each(function(i){jQuery(this).find(".sbi_photo").hover(function(){jQuery(this).fadeTo(200,.85)},function(){jQuery(this).stop().fadeTo(500,1)})}),setTimeout(function(){jQuery("#sbi_images .sbi_item.sbi_new").removeClass("sbi_new");var i=10;e.find(".sbi_transition").each(function(){var e=jQuery(this);setTimeout(function(){e.removeClass("sbi_transition")},i),i+=10})},500)},afterNewImagesRevealed:function(){this.listenForVisibilityChange(),this.sendNeedsResizingToServer(),this.settings.imageLoadEnabled||i(".sbi_no_resraise").removeClass("sbi_no_resraise");var e=i.Event("sbiafterimagesloaded");e.el=i(this.el),i(window).trigger(e)},setResizedImages:function(){i(this.el).find(".sbi_resized_image_data").length&&void 0!==i(this.el).find(".sbi_resized_image_data").attr("data-resized")&&0===i(this.el).find(".sbi_resized_image_data").attr("data-resized").indexOf('{"')&&(this.resizedImages=JSON.parse(i(this.el).find(".sbi_resized_image_data").attr("data-resized")),i(this.el).find(".sbi_resized_image_data").remove())},sendNeedsResizingToServer:function(){var e=this;if(e.needsResizing.length>0&&e.settings.resizingEnabled){var s=i(this.el).find(".sbi_item").length;a({action:"sbi_resized_images_submit",needs_resizing:e.needsResizing,offset:s,feed_id:e.settings.feedID,atts:e.settings.shortCodeAtts},function(i){if(0===i.trim().indexOf("{")){var s=JSON.parse(i);e.settings.debugEnabled&&console.log(s)}})}},loadMoreButtonInit:function(){var e=i(this.el),s=this;e.find("#sbi_load .sbi_load_btn").off().on("click",function(){s.afterLoadMoreClicked(jQuery(this)),s.getNewPostSet()})},getNewPostSet:function(){var e=i(this.el),s=this;a({action:"sbi_load_more_clicked",offset:e.find(".sbi_item").length,feed_id:s.settings.feedID,atts:s.settings.shortCodeAtts,current_resolution:s.imageResolution},function(t){if(0===t.trim().indexOf("{")){var a=JSON.parse(t);s.settings.debugEnabled&&console.log(a),s.appendNewPosts(a.html),s.addResizedImages(a.resizedImages),s.settings.ajaxPostLoad?(s.settings.ajaxPostLoad=!1,s.afterInitialImagesLoaded()):s.afterNewImagesLoaded(),a.feedStatus.shouldPaginate?s.outOfPages=!1:(s.outOfPages=!0,e.find(".sbi_load_btn").hide()),i(".sbi_no_js").removeClass("sbi_no_js")}})},appendNewPosts:function(e){var s=i(this.el);s.find("#sbi_images .sbi_item").length?s.find("#sbi_images .sbi_item").last().after(e):s.find("#sbi_images").append(e)},addResizedImages:function(i){for(var e in i)this.resizedImages[e]=i[e]},setImageHeight:function(){var e=i(this.el),s=e.find(".sbi_photo").eq(0).innerWidth(),t=this.getColumnCount(),a=e.find("#sbi_images").innerWidth()-e.find("#sbi_images").width(),n=a/2;sbi_photo_width_manual=e.find("#sbi_images").width()/t-a,e.find(".sbi_photo").css("height",s),e.find(".sbi-owl-nav").length&&setTimeout(function(){var i=2;e.find(".sbi_owl2row-item").length&&(i=1);var s=e.find(".sbi_photo").eq(0).innerWidth()/i;s+=parseInt(n)*(2-i+2),e.find(".sbi-owl-nav div").css("top",s)},100)},maybeRaiseSingleImageResolution:function(e,s,t){var a=this,n=a.getImageUrls(e),o=e.find(".sbi_photo img").attr("src"),d=150,r=e.find("img").get(0),l=o===window.sbi.options.placeholder?1:r.naturalWidth/r.naturalHeight;t=void 0!==t&&t;if(!(e.hasClass("sbi_no_resraise")||e.hasClass("sbi_had_error")||e.find(".sbi_link_area").length&&e.find(".sbi_link_area").hasClass("sbi_had_error"))){i.each(n,function(i,e){e===o&&(d=parseInt(i),t=!1)});var h=640;switch(a.settings.imgRes){case"thumb":h=150;break;case"medium":h=320;break;case"full":h=640;break;default:var g=Math.max(a.settings.autoMinRes,e.find(".sbi_photo").innerWidth()),u=a.getBestResolutionForAuto(g,l,e);switch(u){case 320:h=320;break;case 150:h=150}}if(h>d||o===window.sbi.options.placeholder||t){if(a.settings.debugEnabled){var m=o===window.sbi.options.placeholder?"was placeholder":"too small";console.log("raise res for "+o,m)}var _=n[h].split("?ig_cache_key")[0];if(e.find(".sbi_photo img").attr("src",_),e.find(".sbi_photo").css("background-image",'url("'+_+'")'),d=h,"auto"===a.settings.imgRes){var f=!1;e.find(".sbi_photo img").on("load",function(){var s=i(this),t=s.get(0).naturalWidth/s.get(0).naturalHeight;if(1e3!==s.get(0).naturalWidth&&t>l&&!f){switch(a.settings.debugEnabled&&console.log("raise res again for aspect ratio change "+o),f=!0,g=e.find(".sbi_photo").innerWidth(),u=a.getBestResolutionForAuto(g,t,e),h=640,u){case 320:h=320;break;case 150:h=150}h>d&&(_=n[h].split("?ig_cache_key")[0],s.attr("src",_),s.closest(".sbi_photo").css("background-image",'url("'+_+'")')),"masonry"!==a.layout&&"highlight"!==a.layout||(i(a.el).find("#sbi_images").smashotope(a.isotopeArgs),setTimeout(function(){i(a.el).find("#sbi_images").smashotope(a.isotopeArgs)},500))}else if(a.settings.debugEnabled){var r=f?"already checked":"no aspect ratio change";console.log("not raising res for replacement "+o,r)}})}}e.find("img").on("error",function(){if(i(this).hasClass("sbi_img_error"))console.log("unfixed error "+i(this).attr("src"));else{var e;if(i(this).addClass("sbi_img_error"),i(this).attr("src").indexOf("media/?size=")>-1||i(this).attr("src").indexOf("cdninstagram")>-1||i(this).attr("src").indexOf("fbcdn")>-1)a.settings.favorLocal=!0,void 0!==(e=a.getImageUrls(i(this).closest(".sbi_item")))[640]&&(i(this).attr("src",e[640]),i(this).closest(".sbi_photo").css("background-image","url("+e[640]+")"),i(this).closest(".sbi_item").addClass("sbi_had_error").find(".sbi_link_area").attr("href",e[640]).addClass("sbi_had_error"));else if("undefined"!==i(this).closest(".sbi_photo").attr("data-img-src-set"))void 0!==(e=JSON.parse(i(this).closest(".sbi_photo").attr("data-img-src-set").replace(/\\\//g,"/"))).d&&(i(this).attr("src",e.d),i(this).closest(".sbi_photo").css("background-image","url("+e.d+")"),i(this).closest(".sbi_item").addClass("sbi_had_error").find(".sbi_link_area").attr("href",e[640]).addClass("sbi_had_error"));setTimeout(function(){a.afterResize()},1500)}})}},maybeRaiseImageResolution:function(e){var s=this,t=void 0!==e&&!0===e?".sbi_item.sbi_new":".sbi_item",a=!s.isInitialized;i(s.el).find(t).each(function(e){!i(this).hasClass("sbi_num_diff_hide")&&i(this).find(".sbi_photo").length&&void 0!==i(this).find(".sbi_photo").attr("data-img-src-set")&&s.maybeRaiseSingleImageResolution(i(this),e,a)}),s.isInitialized=!0},getBestResolutionForAuto:function(e,s,t){(isNaN(s)||s<1)&&(s=1);var a=e*s,n=10*Math.ceil(a/10),o=[150,320,640];if(t.hasClass("sbi_highlighted")&&(n*=2),-1===o.indexOf(parseInt(n))){var d=!1;i.each(o,function(i,e){e>parseInt(n)&&!d&&(n=e,d=!0)})}return n},hideExtraImagesForWidth:function(){if("carousel"!==this.layout){var e=i(this.el),s=void 0!==e.attr("data-num")&&""!==e.attr("data-num")?parseInt(e.attr("data-num")):1,t=void 0!==e.attr("data-nummobile")&&""!==e.attr("data-nummobile")?parseInt(e.attr("data-nummobile")):s;i(window).width()<480?t<e.find(".sbi_item").length&&e.find(".sbi_item").slice(t-e.find(".sbi_item").length).addClass("sbi_num_diff_hide"):s<e.find(".sbi_item").length&&e.find(".sbi_item").slice(s-e.find(".sbi_item").length).addClass("sbi_num_diff_hide")}},setImageSizeClass:function(){var e=i(this.el);e.removeClass("sbi_small sbi_medium");var s=e.innerWidth(),t=parseInt(e.find("#sbi_images").outerWidth()-e.find("#sbi_images").width())/2,a=this.getColumnCount(),n=(s-t*(a+2))/a;n>120&&n<240?e.addClass("sbi_medium"):n<=120&&e.addClass("sbi_small")},setMinImageWidth:function(){i(this.el).find(".sbi_item .sbi_photo").first().length?this.minImageWidth=i(this.el).find(".sbi_item .sbi_photo").first().innerWidth():this.minImageWidth=150},setImageResolution:function(){if("auto"===this.settings.imgRes)this.imageResolution="auto";else switch(this.settings.imgRes){case"thumb":this.imageResolution=150;break;case"medium":this.imageResolution=320;break;default:this.imageResolution=640}},getImageUrls:function(i){var e=JSON.parse(i.find(".sbi_photo").attr("data-img-src-set").replace(/\\\//g,"/")),s=i.attr("id").replace("sbi_","");if(void 0!==this.resizedImages[s]&&"video"!==this.resizedImages[s]&&"pending"!==this.resizedImages[s]&&"error"!==this.resizedImages[s].id&&"video"!==this.resizedImages[s].id&&"pending"!==this.resizedImages[s].id){if(void 0!==this.resizedImages[s].sizes){var t=[];void 0!==this.resizedImages[s].sizes.full&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg",t.push(640)),void 0!==this.resizedImages[s].sizes.low&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg",t.push(320)),void 0!==this.resizedImages[s].sizes.thumb&&(t.push(150),e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"thumb.jpg"),this.settings.favorLocal&&(-1===t.indexOf(640)&&t.indexOf(320)>-1&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg"),-1===t.indexOf(320)&&(t.indexOf(640)>-1?e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg":t.indexOf(150)>-1&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"thumb.jpg")),-1===t.indexOf(150)&&(t.indexOf(320)>-1?e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"low.jpg":t.indexOf(640)>-1&&(e[150]=sb_instagram_js_options.resized_url+this.resizedImages[s].id+"full.jpg")))}}else(void 0===this.resizedImages[s]||void 0!==this.resizedImages[s].id&&"pending"!==this.resizedImages[s].id&&"error"!==this.resizedImages[s].id)&&this.addToNeedsResizing(s);return e},getAvatarUrl:function(i,e){if(""===i)return"";var s=this.settings.general.avatars;return"local"===(e=void 0!==e?e:"local")?void 0!==s["LCL"+i]&&1===parseInt(s["LCL"+i])?sb_instagram_js_options.resized_url+i+".jpg":void 0!==s[i]?s[i]:"":void 0!==s[i]?s[i]:void 0!==s["LCL"+i]&&1===parseInt(s["LCL"+i])?sb_instagram_js_options.resized_url+i+".jpg":""},addToNeedsResizing:function(i){-1===this.needsResizing.indexOf(i)&&this.needsResizing.push(i)},applyImageLiquid:function(){var s=i(this.el);e(),"function"==typeof s.find(".sbi_photo").sbi_imgLiquid&&s.find(".sbi_photo").sbi_imgLiquid({fill:!0})},listenForVisibilityChange:function(){var e,s,t,a=this;e=jQuery,s={callback:function(){},runOnLoad:!0,frequency:100,sbiPreviousVisibility:null},t={sbiCheckVisibility:function(i,e){if(jQuery.contains(document,i[0])){var s=e.sbiPreviousVisibility,a=i.is(":visible");e.sbiPreviousVisibility=a,null==s?e.runOnLoad&&e.callback(i,a):s!==a&&e.callback(i,a),setTimeout(function(){t.sbiCheckVisibility(i,e)},e.frequency)}}},e.fn.sbiVisibilityChanged=function(i){var a=e.extend({},s,i);return this.each(function(){t.sbiCheckVisibility(e(this),a)})},"function"==typeof i(this.el).filter(":hidden").sbiVisibilityChanged&&i(this.el).filter(":hidden").sbiVisibilityChanged({callback:function(i,e){a.afterResize()},runOnLoad:!1})},getColumnCount:function(){var e=i(this.el),s=this.settings.cols,t=this.settings.colsmobile,a=s;return sbiWindowWidth=window.innerWidth,e.hasClass("sbi_mob_col_auto")?(sbiWindowWidth<640&&parseInt(s)>2&&parseInt(s)<7&&(a=2),sbiWindowWidth<640&&parseInt(s)>6&&parseInt(s)<11&&(a=4),sbiWindowWidth<=480&&parseInt(s)>2&&(a=1)):sbiWindowWidth<=480&&(a=t),parseInt(a)}},window.sbi_init=function(){window.sbi=new s,window.sbi.createPage(window.sbi.createFeeds,{whenFeedsCreated:window.sbi.afterFeedsCreated})}}(jQuery),jQuery(document).ready(function(i){void 0===window.sb_instagram_js_options&&(window.sb_instagram_js_options={font_method:"svg",resized_url:location.protocol+"//"+window.location.hostname+"/wp-content/uploads/sb-instagram-feed-images/",placeholder:location.protocol+"//"+window.location.hostname+"/wp-content/plugins/instagram-feed/img/placeholder.png"}),void 0!==window.sb_instagram_js_options.resized_url&&-1===window.sb_instagram_js_options.resized_url.indexOf(location.protocol)&&("http:"===location.protocol?window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("http:","https:"):window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("https:","http:")),sbi_init()}));