Version Description
- New: The locations of the Instagram feeds on your site will now be logged and listed on a single page for easier management. After this feature has been active for awhile, a "Feed Finder" link will appear next to the Feed Type setting on the plugin Settings page which allows you to see a list of all feeds on your site along with their locations.
- New: Local resized images will now include a 150x150 resolution version for each post.
- Tweak: Locally saved image quality set to 80% to increase feed performance without a noticeable visual difference.
- Tweak: Improved how posts are sorted by date when there are more than one user accounts in a feed.
- Fix: Old accounts from Instagram's deprecated, non-functioning API are ignored if still connected.
Download this release
Release Info
Developer | smashballoon |
Plugin | Instagram Feed |
Version | 2.8 |
Comparing to | |
See all releases |
Code changes from version 2.7 to 2.8
- README.txt +8 -1
- css/sb-instagram-admin.css +30 -0
- inc/admin/main.php +41 -3
- inc/admin/templates/locator-summary.php +84 -0
- inc/class-sb-instagram-connected-account.php +6 -4
- inc/class-sb-instagram-cron-updater.php +2 -2
- inc/class-sb-instagram-feed-locator.php +429 -0
- inc/class-sb-instagram-feed.php +75 -7
- inc/class-sb-instagram-post-set.php +1 -1
- inc/class-sb-instagram-post.php +2 -0
- inc/class-sb-instagram-settings.php +26 -4
- inc/if-functions.php +73 -4
- instagram-feed.php +34 -8
- js/sb-instagram-2-2.js +39 -1
- js/sb-instagram-2-2.min.js +1 -1
- js/sb-instagram-admin-2-2.js +92 -80
- js/sbi-scripts.js +39 -1
- js/sbi-scripts.min.js +1 -1
README.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: smashballoon, craig-at-smash-balloon
|
|
3 |
Tags: Instagram, Instagram feed, Instagram photos, Instagram widget, Instagram gallery
|
4 |
Requires at least: 3.4
|
5 |
Tested up to: 5.6
|
6 |
-
Stable tag: 2.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -332,6 +332,13 @@ We understand that sometimes you need help, have issues or just have questions.
|
|
332 |
* Plus more customization options added all the time!
|
333 |
|
334 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
= 2.7 =
|
336 |
* Tweak: Several performance improvements have been made in this update such as improved caching and fewer database queries when displaying feeds.
|
337 |
* Tweak: The limit of resized, local images created and stored were raised for the overall number and the rate at which they could be created.
|
3 |
Tags: Instagram, Instagram feed, Instagram photos, Instagram widget, Instagram gallery
|
4 |
Requires at least: 3.4
|
5 |
Tested up to: 5.6
|
6 |
+
Stable tag: 2.8
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
332 |
* Plus more customization options added all the time!
|
333 |
|
334 |
== Changelog ==
|
335 |
+
= 2.8 =
|
336 |
+
* New: The locations of the Instagram feeds on your site will now be logged and listed on a single page for easier management. After this feature has been active for awhile, a "Feed Finder" link will appear next to the Feed Type setting on the plugin Settings page which allows you to see a list of all feeds on your site along with their locations.
|
337 |
+
* New: Local resized images will now include a 150x150 resolution version for each post.
|
338 |
+
* Tweak: Locally saved image quality set to 80% to increase feed performance without a noticeable visual difference.
|
339 |
+
* Tweak: Improved how posts are sorted by date when there are more than one user accounts in a feed.
|
340 |
+
* Fix: Old accounts from Instagram's deprecated, non-functioning API are ignored if still connected.
|
341 |
+
|
342 |
= 2.7 =
|
343 |
* Tweak: Several performance improvements have been made in this update such as improved caching and fewer database queries when displaying feeds.
|
344 |
* Tweak: The limit of resized, local images created and stored were raised for the overall number and the rate at which they could be created.
|
css/sb-instagram-admin.css
CHANGED
@@ -2777,4 +2777,34 @@
|
|
2777 |
#sbi_admin .sbi-cols-4 .addon-container{
|
2778 |
width: 100%;
|
2779 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2780 |
}
|
2777 |
#sbi_admin .sbi-cols-4 .addon-container{
|
2778 |
width: 100%;
|
2779 |
}
|
2780 |
+
}
|
2781 |
+
|
2782 |
+
/* Locator Summary */
|
2783 |
+
.sbi-feed-locator-summary-wrap {
|
2784 |
+
max-width: 1100px;
|
2785 |
+
margin-bottom: 40px;
|
2786 |
+
}
|
2787 |
+
.sbi-full-wrap {
|
2788 |
+
display: none;
|
2789 |
+
}
|
2790 |
+
.sbi-locator-more {
|
2791 |
+
display: inline-block;
|
2792 |
+
margin: 0 0 0 1px;
|
2793 |
+
padding: 0 5px;
|
2794 |
+
border: 1px solid rgba(0,0,0,0.1);
|
2795 |
+
border-radius: 3px;
|
2796 |
+
line-height: 1.6;
|
2797 |
+
}
|
2798 |
+
|
2799 |
+
.sbi_shortcode_visible .sbi_locations_link {
|
2800 |
+
display: none;
|
2801 |
+
}
|
2802 |
+
.sbi_locations_link a {
|
2803 |
+
font-weight: normal;
|
2804 |
+
text-decoration: none;
|
2805 |
+
}
|
2806 |
+
.sbi_locations_link svg {
|
2807 |
+
width: 11px;
|
2808 |
+
position: relative;
|
2809 |
+
top: 1px;
|
2810 |
}
|
inc/admin/main.php
CHANGED
@@ -1017,9 +1017,16 @@ function sb_instagram_settings_page() {
|
|
1017 |
</tr>
|
1018 |
|
1019 |
<tr valign="top" class="sbi_feed_type">
|
1020 |
-
|
1021 |
-
Eg: type=user
|
1022 |
-
</code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1023 |
<td>
|
1024 |
<div class="sbi_row">
|
1025 |
<div class="sbi_col sbi_one">
|
@@ -1222,6 +1229,10 @@ function sb_instagram_settings_page() {
|
|
1222 |
|
1223 |
<?php } // End Configure tab ?>
|
1224 |
|
|
|
|
|
|
|
|
|
1225 |
|
1226 |
|
1227 |
<?php if( $sbi_active_tab == 'customize' ) { //Start Configure tab ?>
|
@@ -3171,6 +3182,33 @@ if ( $error_page ) {
|
|
3171 |
echo 'Feed with error: ' . esc_url( get_the_permalink( $error_page ) ). "\n";
|
3172 |
}*/?>
|
3173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3174 |
## GDPR: ##
|
3175 |
<?php
|
3176 |
if ( ! SB_Instagram_GDPR_Integrations::gdpr_tests_successful() ) :
|
1017 |
</tr>
|
1018 |
|
1019 |
<tr valign="top" class="sbi_feed_type">
|
1020 |
+
<th scope="row"><label><?php _e('Select a Feed Type', 'instagram-feed'); ?>:</label><code class="sbi_shortcode"> type
|
1021 |
+
Eg: type=user user=smashballoon
|
1022 |
+
</code>
|
1023 |
+
<?php if ( SB_Instagram_Feed_Locator::count_unique() > 1 ) : ?>
|
1024 |
+
<div class="sbi_locations_link">
|
1025 |
+
<a href="?page=sb-instagram-feed&tab=allfeeds"><svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="search" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" class="svg-inline--fa fa-search fa-w-16 fa-2x"><path fill="currentColor" d="M508.5 468.9L387.1 347.5c-2.3-2.3-5.3-3.5-8.5-3.5h-13.2c31.5-36.5 50.6-84 50.6-136C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c52 0 99.5-19.1 136-50.6v13.2c0 3.2 1.3 6.2 3.5 8.5l121.4 121.4c4.7 4.7 12.3 4.7 17 0l22.6-22.6c4.7-4.7 4.7-12.3 0-17zM208 368c-88.4 0-160-71.6-160-160S119.6 48 208 48s160 71.6 160 160-71.6 160-160 160z" class=""></path></svg> <?php _e('Feed Finder', 'instagram-feed'); ?></a>
|
1026 |
+
</div>
|
1027 |
+
<?php endif; ?>
|
1028 |
+
|
1029 |
+
</th>
|
1030 |
<td>
|
1031 |
<div class="sbi_row">
|
1032 |
<div class="sbi_col sbi_one">
|
1229 |
|
1230 |
<?php } // End Configure tab ?>
|
1231 |
|
1232 |
+
<?php if ( $sbi_active_tab == 'allfeeds' ) {
|
1233 |
+
$locator_summary = SB_Instagram_Feed_Locator::summary();
|
1234 |
+
include_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/admin/templates/locator-summary.php';
|
1235 |
+
} ?>
|
1236 |
|
1237 |
|
1238 |
<?php if( $sbi_active_tab == 'customize' ) { //Start Configure tab ?>
|
3182 |
echo 'Feed with error: ' . esc_url( get_the_permalink( $error_page ) ). "\n";
|
3183 |
}*/?>
|
3184 |
|
3185 |
+
## Location Summary: ##
|
3186 |
+
<?php
|
3187 |
+
$locator_summary = SB_Instagram_Feed_Locator::summary();
|
3188 |
+
$condensed_shortcode_atts = array( 'type', 'user', 'hashtag', 'tagged', 'num', 'cols', 'layout', 'whitelist', 'includewords' );
|
3189 |
+
|
3190 |
+
if ( ! empty( $locator_summary) ) {
|
3191 |
+
|
3192 |
+
foreach ( $locator_summary as $locator_section ) {
|
3193 |
+
if ( ! empty( $locator_section['results'] ) ) {
|
3194 |
+
$first_five = array_slice( $locator_section['results'], 0, 5 );
|
3195 |
+
foreach ( $first_five as $result ) {
|
3196 |
+
$condensed_shortcode_string = '[instagram-feed';
|
3197 |
+
$shortcode_atts = json_decode( $result['shortcode_atts'], true );
|
3198 |
+
$shortcode_atts = is_array( $shortcode_atts ) ? $shortcode_atts : array();
|
3199 |
+
foreach ( $shortcode_atts as $key => $value ) {
|
3200 |
+
if ( in_array( $key, $condensed_shortcode_atts, true ) ) {
|
3201 |
+
$condensed_shortcode_string .= ' ' . esc_html( $key ). '="' . esc_html( $value ) . '"';
|
3202 |
+
}
|
3203 |
+
}
|
3204 |
+
$condensed_shortcode_string .= ']';
|
3205 |
+
echo esc_url( get_the_permalink( $result['post_id'] ) ) . ' ' . $condensed_shortcode_string . "\n";
|
3206 |
+
}
|
3207 |
+
|
3208 |
+
}
|
3209 |
+
}
|
3210 |
+
}?>
|
3211 |
+
|
3212 |
## GDPR: ##
|
3213 |
<?php
|
3214 |
if ( ! SB_Instagram_GDPR_Integrations::gdpr_tests_successful() ) :
|
inc/admin/templates/locator-summary.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Custom Feeds for Instagram Feed Locator Summary Template
|
4 |
+
* Creates the HTML for the feed locator summary
|
5 |
+
*
|
6 |
+
* @version 5.11 Custom Feeds for Instagram Pro by Smash Balloon
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
// Don't load directly
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die( '-1' );
|
12 |
+
}
|
13 |
+
$database_settings = sbi_get_database_settings();
|
14 |
+
?>
|
15 |
+
<div class="sbi-feed-locator-summary-wrap">
|
16 |
+
<h3><?php esc_html_e( 'Feed Finder Summary', 'instagram-feed' ); ?></h3>
|
17 |
+
<p><?php esc_html_e( 'The table below shows a record of all feeds found on your site. A feed may not show up here immediately after being created.', 'instagram-feed' ); ?></p>
|
18 |
+
<?php
|
19 |
+
if ( ! empty( $locator_summary ) ) : ?>
|
20 |
+
|
21 |
+
<?php foreach ( $locator_summary as $locator_section ) :
|
22 |
+
if ( ! empty( $locator_section['results'] ) ) : ?>
|
23 |
+
<div class="sbi-single-location">
|
24 |
+
<h4><?php echo esc_html( $locator_section['label'] ); ?></h4>
|
25 |
+
<table class="widefat striped">
|
26 |
+
<thead>
|
27 |
+
<tr>
|
28 |
+
<th><?php esc_html_e( 'Type', 'instagram-feed' ); ?></th>
|
29 |
+
<th><?php esc_html_e( 'Sources', 'instagram-feed' ); ?></th>
|
30 |
+
<th><?php esc_html_e( 'Shortcode', 'instagram-feed' ); ?></th>
|
31 |
+
<th><?php esc_html_e( 'Location', 'instagram-feed' ); ?></th>
|
32 |
+
</tr>
|
33 |
+
</thead>
|
34 |
+
<tbody>
|
35 |
+
|
36 |
+
<?php foreach ( $locator_section['results'] as $result ) :
|
37 |
+
$shortcode_atts = json_decode( $result['shortcode_atts'], true );
|
38 |
+
$shortcode_atts = is_array( $shortcode_atts ) ? $shortcode_atts : array();
|
39 |
+
|
40 |
+
if ( class_exists( 'SB_Instagram_Settings_Pro' ) ) {
|
41 |
+
$settings_obj = new SB_Instagram_Settings_Pro( $shortcode_atts, $database_settings );
|
42 |
+
} else {
|
43 |
+
$settings_obj = new SB_Instagram_Settings( $shortcode_atts, $database_settings );
|
44 |
+
}
|
45 |
+
$settings = $settings_obj->get_settings();
|
46 |
+
$settings_obj->set_feed_type_and_terms();
|
47 |
+
$display_terms = $settings_obj->feed_type_and_terms_display();
|
48 |
+
$comma_separated = implode(', ', $display_terms );
|
49 |
+
$display = $comma_separated;
|
50 |
+
if ( strlen( $comma_separated ) > 31 ) {
|
51 |
+
$display = '<span class="sbi-condensed-wrap">' . substr( $comma_separated, 0, 30 ) . '<a class="sbi-locator-more" href="JavaScript:void(0);">...</a></span>';
|
52 |
+
$comma_separated = '<span class="sbi-full-wrap">' . esc_html( $comma_separated ) . '</span>';
|
53 |
+
} else {
|
54 |
+
$comma_separated = '';
|
55 |
+
}
|
56 |
+
$type = isset( $settings['type'] ) ? $settings['type'] : 'user';
|
57 |
+
$full_shortcode_string = '[instagram-feed';
|
58 |
+
foreach ( $shortcode_atts as $key => $value ) {
|
59 |
+
$full_shortcode_string .= ' ' . esc_html( $key ) . '="' . esc_html( $value ) . '"';
|
60 |
+
}
|
61 |
+
$full_shortcode_string .= ']';
|
62 |
+
?>
|
63 |
+
<tr>
|
64 |
+
<td><?php echo esc_html( $type ); ?></td>
|
65 |
+
<td><?php echo $display . $comma_separated; ?></td>
|
66 |
+
<td>
|
67 |
+
<span class="sbi-condensed-wrap"><a class="sbi-locator-more" href="JavaScript:void(0);"><?php esc_html_e( 'Show', 'instagram-feed' ); ?></a></span>
|
68 |
+
<span class="sbi-full-wrap"><?php echo $full_shortcode_string; ?></span>
|
69 |
+
</td>
|
70 |
+
<td><a href="<?php echo esc_url( get_the_permalink( $result['post_id'] ) ); ?>" target="_blank" rel="noopener"><?php echo esc_html( get_the_title( $result['post_id'] ) ); ?></a></td>
|
71 |
+
</tr>
|
72 |
+
<?php endforeach; ?>
|
73 |
+
|
74 |
+
|
75 |
+
</tbody>
|
76 |
+
</table>
|
77 |
+
</div>
|
78 |
+
|
79 |
+
<?php endif;
|
80 |
+
endforeach;
|
81 |
+
else: ?>
|
82 |
+
<p><?php esc_html_e( 'Locations of your feeds are currently being detected. You\'ll see more information posted here soon!', 'instagram-feed' ); ?></p>
|
83 |
+
<?php endif; ?>
|
84 |
+
</div>
|
inc/class-sb-instagram-connected-account.php
CHANGED
@@ -86,10 +86,12 @@ class SB_Instagram_Connected_Account {
|
|
86 |
return $connected_accounts[ $search_term ];
|
87 |
} else {
|
88 |
foreach ( $connected_accounts as $connected_account ) {
|
89 |
-
if (
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
93 |
}
|
94 |
}
|
95 |
}
|
86 |
return $connected_accounts[ $search_term ];
|
87 |
} else {
|
88 |
foreach ( $connected_accounts as $connected_account ) {
|
89 |
+
if ( strpos( $connected_account['access_token'], '.' ) === false ) {
|
90 |
+
if ( strtolower( $connected_account['username'] ) === trim( strtolower( $search_term ) ) ) {
|
91 |
+
return $connected_account;
|
92 |
+
} elseif ( $connected_account['access_token'] === trim( strtolower( $search_term ) ) ) {
|
93 |
+
return $connected_account;
|
94 |
+
}
|
95 |
}
|
96 |
}
|
97 |
}
|
inc/class-sb-instagram-cron-updater.php
CHANGED
@@ -136,8 +136,8 @@ class SB_Instagram_Cron_Updater
|
|
136 |
$post_data = array_slice( $post_data, 0, $settings['num'] );
|
137 |
|
138 |
$image_sizes = array(
|
139 |
-
'personal' => array( 'full' => 640, 'low' => 320 ),
|
140 |
-
'business' => array( 'full' => 640, 'low' => 320 )
|
141 |
);
|
142 |
|
143 |
$post_set = new SB_Instagram_Post_Set( $post_data, $transient_name, NULL, $image_sizes );
|
136 |
$post_data = array_slice( $post_data, 0, $settings['num'] );
|
137 |
|
138 |
$image_sizes = array(
|
139 |
+
'personal' => array( 'full' => 640, 'low' => 320, 'thumb' => 150 ),
|
140 |
+
'business' => array( 'full' => 640, 'low' => 320, 'thumb' => 150 )
|
141 |
);
|
142 |
|
143 |
$post_set = new SB_Instagram_Post_Set( $post_data, $transient_name, NULL, $image_sizes );
|
inc/class-sb-instagram-feed-locator.php
ADDED
@@ -0,0 +1,429 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class SB_Instagram_Feed_Locator
|
4 |
+
*
|
5 |
+
* Locates feeds on the site and logs information about them in the database.
|
6 |
+
*
|
7 |
+
* @since 5.11
|
8 |
+
*/
|
9 |
+
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die( '-1' );
|
12 |
+
}
|
13 |
+
|
14 |
+
class SB_Instagram_Feed_Locator
|
15 |
+
{
|
16 |
+
private $feed_details;
|
17 |
+
|
18 |
+
private $expiration_time;
|
19 |
+
|
20 |
+
private $matching_entries;
|
21 |
+
|
22 |
+
public function __construct( $feed_details ) {
|
23 |
+
/**
|
24 |
+
* Example of how $feed_details is structured
|
25 |
+
*
|
26 |
+
* $feed_details = array(
|
27 |
+
* 'feed_id' => $transient_name,
|
28 |
+
* 'atts' => $atts,
|
29 |
+
* 'location' => array(
|
30 |
+
* 'post_id' => get_the_ID(),
|
31 |
+
* 'html' => 'unknown'
|
32 |
+
* )
|
33 |
+
* );
|
34 |
+
*/
|
35 |
+
$this->feed_details = $feed_details;
|
36 |
+
|
37 |
+
$this->matching_entries = array();
|
38 |
+
|
39 |
+
$this->expiration_time = time() - 2 * WEEK_IN_SECONDS;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Returns records that match the post ID and feed ID
|
44 |
+
* of the feed being located
|
45 |
+
*
|
46 |
+
* @return array
|
47 |
+
*
|
48 |
+
* @since 5.11
|
49 |
+
*/
|
50 |
+
public function retrieve_matching_entries() {
|
51 |
+
global $wpdb;
|
52 |
+
$feed_locator_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEED_LOCATOR );
|
53 |
+
|
54 |
+
$results = $wpdb->get_results( $wpdb->prepare("
|
55 |
+
SELECT *
|
56 |
+
FROM $feed_locator_table_name
|
57 |
+
WHERE post_id = %d
|
58 |
+
AND feed_id = %s", $this->feed_details['location']['post_id'], $this->feed_details['feed_id'] ),ARRAY_A );
|
59 |
+
|
60 |
+
return $results;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Add feed being located to the database
|
65 |
+
*
|
66 |
+
* @since 5.11
|
67 |
+
*/
|
68 |
+
public function insert_entry() {
|
69 |
+
global $wpdb;
|
70 |
+
|
71 |
+
$feed_locator_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEED_LOCATOR );
|
72 |
+
|
73 |
+
$affected = $wpdb->query( $wpdb->prepare( "INSERT INTO $feed_locator_table_name
|
74 |
+
(feed_id,
|
75 |
+
post_id,
|
76 |
+
html_location,
|
77 |
+
shortcode_atts,
|
78 |
+
last_update)
|
79 |
+
VALUES (
|
80 |
+
%s,
|
81 |
+
%d,
|
82 |
+
%s,
|
83 |
+
%s,
|
84 |
+
%s);",
|
85 |
+
$this->feed_details['feed_id'],
|
86 |
+
$this->feed_details['location']['post_id'],
|
87 |
+
$this->feed_details['location']['html'],
|
88 |
+
sbi_json_encode( $this->feed_details['atts'] ),
|
89 |
+
date( 'Y-m-d H:i:s' ) ) );
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Update a record based on the existing "id" column. Location can change
|
94 |
+
* from "unknown" to one of footer, content, header, or sidebar.
|
95 |
+
*
|
96 |
+
* @param $id
|
97 |
+
* @param $location
|
98 |
+
*
|
99 |
+
* @since 5.11
|
100 |
+
*/
|
101 |
+
public function update_entry( $id, $location ) {
|
102 |
+
global $wpdb;
|
103 |
+
|
104 |
+
$feed_locator_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEED_LOCATOR );
|
105 |
+
|
106 |
+
$query = $wpdb->query( $wpdb->prepare( "
|
107 |
+
UPDATE $feed_locator_table_name
|
108 |
+
SET last_update = %s, html_location = %s
|
109 |
+
WHERE id = %d;", date( 'Y-m-d H:i:s' ), $location, $id ) );
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Processes a feed being located based on whether or not the record
|
114 |
+
* exists as well as whether or not an unknown location needs to be
|
115 |
+
* updated.
|
116 |
+
*
|
117 |
+
* @since 5.11
|
118 |
+
*/
|
119 |
+
public function add_or_update_entry() {
|
120 |
+
if ( empty( $this->feed_details['feed_id'] ) ) {
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
|
124 |
+
$this->matching_entries = $this->retrieve_matching_entries();
|
125 |
+
|
126 |
+
if ( empty( $this->matching_entries ) ) {
|
127 |
+
$this->insert_entry();
|
128 |
+
} else {
|
129 |
+
$matching_indices = array();
|
130 |
+
$matched_location = false;
|
131 |
+
$non_unknown_match = false;
|
132 |
+
$unknown_match = false;
|
133 |
+
|
134 |
+
foreach ( $this->matching_entries as $index => $matching_entry ) {
|
135 |
+
$atts = is_array( $this->feed_details['atts'] ) ? $this->feed_details['atts'] : array();
|
136 |
+
$atts_diff = array_diff( json_decode( $matching_entry['shortcode_atts'], true ), $atts ); // determines if the shortcode settings match the shortcode settings of an existing feed
|
137 |
+
if ( empty( $atts_diff ) ) {
|
138 |
+
$matching_indices[] = $matching_entry['id'];
|
139 |
+
if ( $matching_entry['html_location'] === $this->feed_details['location']['html'] ) {
|
140 |
+
$matched_location = $index;
|
141 |
+
$this->update_entry( $matching_entry['id'], $matching_entry['html_location'] );
|
142 |
+
}
|
143 |
+
if ( $matching_entry['html_location'] !== 'unknown' ) {
|
144 |
+
$non_unknown_match = $index;
|
145 |
+
} else {
|
146 |
+
$unknown_match = $index;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
if ( false === $matched_location ) {
|
152 |
+
// if there is no matched location, there is only one feed on the page, and the feed being checked has an unknown location, update the known location
|
153 |
+
if ( count( $matching_indices ) === 1
|
154 |
+
&& $this->feed_details['location']['html'] === 'unknown'
|
155 |
+
&& false !== $non_unknown_match ) {
|
156 |
+
$this->update_entry( $this->matching_entries[ $non_unknown_match ]['id'], $this->matching_entries[ $non_unknown_match ]['html_location'] );
|
157 |
+
} else {
|
158 |
+
if ( $this->feed_details['location']['html'] !== 'unknown'
|
159 |
+
&& false !== $unknown_match ) {
|
160 |
+
$this->update_entry( $this->matching_entries[ $unknown_match ]['id'], $this->feed_details['location']['html'] );
|
161 |
+
} else {
|
162 |
+
$this->insert_entry();
|
163 |
+
}
|
164 |
+
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Old feeds are only detected once a day to keep load on the server low.
|
173 |
+
*
|
174 |
+
* @return bool
|
175 |
+
*
|
176 |
+
* @since 5.11
|
177 |
+
*/
|
178 |
+
public static function should_clear_old_locations() {
|
179 |
+
$sbi_statuses_option = get_option( 'sbi_statuses', array() );
|
180 |
+
$last_old_feed_check = isset( $sbi_statuses_option['feed_locator']['last_check'] ) ? $sbi_statuses_option['feed_locator']['last_check'] : 0;
|
181 |
+
|
182 |
+
return $last_old_feed_check < time() - DAY_IN_SECONDS;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Old feeds are removed if they haven't been updated in two weeks.
|
187 |
+
*
|
188 |
+
* @since 5.11
|
189 |
+
*/
|
190 |
+
public static function delete_old_locations() {
|
191 |
+
global $wpdb;
|
192 |
+
|
193 |
+
$feed_locator_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEED_LOCATOR );
|
194 |
+
$two_weeks_ago = date( 'Y-m-d H:i:s', time() - 2 * WEEK_IN_SECONDS );
|
195 |
+
|
196 |
+
$affected = $wpdb->query( $wpdb->prepare(
|
197 |
+
"DELETE FROM $feed_locator_table_name WHERE last_update < %s;", $two_weeks_ago ) );
|
198 |
+
|
199 |
+
$sbi_statuses_option = get_option( 'sbi_statuses', array() );
|
200 |
+
$sbi_statuses_option['feed_locator']['last_check'] = time();
|
201 |
+
if ( ! isset( $sbi_statuses_option['feed_locator']['initialized'] ) ) {
|
202 |
+
$sbi_statuses_option['feed_locator']['initialized'] = time();
|
203 |
+
}
|
204 |
+
|
205 |
+
update_option( 'sbi_statuses', $sbi_statuses_option, true );
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Feeds are located with the page load randomly (5% or 1/30 loads)
|
210 |
+
* to decrease load on the server.
|
211 |
+
*
|
212 |
+
* If the locating just started (within 5 minutes) it is run more often
|
213 |
+
* to collect feed locations quickly.
|
214 |
+
*
|
215 |
+
* @return bool
|
216 |
+
*
|
217 |
+
* @since 5.11
|
218 |
+
*/
|
219 |
+
public static function should_do_locating() {
|
220 |
+
$sbi_statuses_option = get_option( 'sbi_statuses', array() );
|
221 |
+
if ( isset( $sbi_statuses_option['feed_locator']['initialized'] )
|
222 |
+
&& $sbi_statuses_option['feed_locator']['initialized'] < (time() - 300) ) {
|
223 |
+
$should_do_locating = rand( 1, 10 ) === 10;
|
224 |
+
} else {
|
225 |
+
$should_do_locating = rand( 1, 30 ) === 30;
|
226 |
+
}
|
227 |
+
$should_do_locating = apply_filters( 'sbi_should_do_locating', $should_do_locating );
|
228 |
+
|
229 |
+
return $should_do_locating;
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Simliar to the should_do_locating method but will add an additional
|
234 |
+
* database query to see if there is a feed with an unknown location that
|
235 |
+
* matches the details of the feed in question.
|
236 |
+
*
|
237 |
+
* @param $feed_id
|
238 |
+
* @param $post_id
|
239 |
+
*
|
240 |
+
* @return bool
|
241 |
+
*
|
242 |
+
* @since 5.11
|
243 |
+
*/
|
244 |
+
public static function should_do_ajax_locating( $feed_id, $post_id ) {
|
245 |
+
$sbi_statuses_option = get_option( 'sbi_statuses', array() );
|
246 |
+
if ( isset( $sbi_statuses_option['feed_locator']['initialized'] )
|
247 |
+
&& $sbi_statuses_option['feed_locator']['initialized'] < (time() - 300) ) {
|
248 |
+
$should_do_locating = rand( 1, 10 ) === 10;
|
249 |
+
} else {
|
250 |
+
$should_do_locating = rand( 1, 30 ) === 30;
|
251 |
+
}
|
252 |
+
if ( $should_do_locating ) {
|
253 |
+
$should_do_locating = SB_Instagram_Feed_Locator::entries_need_locating( $feed_id, $post_id );
|
254 |
+
}
|
255 |
+
|
256 |
+
$should_do_locating = apply_filters( 'sbi_should_do_ajax_locating', $should_do_locating );
|
257 |
+
|
258 |
+
return $should_do_locating;
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Feeds are located with the page load randomly (1/30 loads)
|
263 |
+
* to decrease load on the server.
|
264 |
+
*
|
265 |
+
* If the locating just started (within 5 minutes) it is run more often
|
266 |
+
* to collect feed locations quickly.
|
267 |
+
*
|
268 |
+
* @param $feed_id
|
269 |
+
* @param $post_id
|
270 |
+
*
|
271 |
+
* @return bool
|
272 |
+
*
|
273 |
+
* @since 5.11
|
274 |
+
*/
|
275 |
+
public static function entries_need_locating( $feed_id, $post_id ) {
|
276 |
+
global $wpdb;
|
277 |
+
$feed_locator_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEED_LOCATOR );
|
278 |
+
|
279 |
+
$one_day_ago = date( 'Y-m-d H:i:s', time() - DAY_IN_SECONDS );
|
280 |
+
|
281 |
+
$results = $wpdb->get_results( $wpdb->prepare("
|
282 |
+
SELECT id
|
283 |
+
FROM $feed_locator_table_name
|
284 |
+
WHERE html_location = 'unknown'
|
285 |
+
AND last_update < %s
|
286 |
+
AND feed_id = %s
|
287 |
+
AND post_id = %d
|
288 |
+
LIMIT 1;", $one_day_ago, $feed_id, $post_id ),ARRAY_A );
|
289 |
+
|
290 |
+
return isset( $results[0] );
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* A custom table stores locations
|
295 |
+
*
|
296 |
+
* @since 5.11
|
297 |
+
*/
|
298 |
+
public static function create_table() {
|
299 |
+
global $wpdb;
|
300 |
+
global $sb_instagram_posts_manager;
|
301 |
+
|
302 |
+
$feed_locator_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEED_LOCATOR );
|
303 |
+
|
304 |
+
if ( $wpdb->get_var( "show tables like '$feed_locator_table_name'" ) != $feed_locator_table_name ) {
|
305 |
+
$sql = "CREATE TABLE " . $feed_locator_table_name . " (
|
306 |
+
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
307 |
+
feed_id VARCHAR(50) DEFAULT '' NOT NULL,
|
308 |
+
post_id BIGINT(20) UNSIGNED NOT NULL,
|
309 |
+
html_location VARCHAR(50) DEFAULT 'unknown' NOT NULL,
|
310 |
+
shortcode_atts LONGTEXT NOT NULL,
|
311 |
+
last_update DATETIME
|
312 |
+
);";
|
313 |
+
$wpdb->query( $sql );
|
314 |
+
}
|
315 |
+
$error = $wpdb->last_error;
|
316 |
+
$query = $wpdb->last_query;
|
317 |
+
$had_error = false;
|
318 |
+
if ( $wpdb->get_var( "show tables like '$feed_locator_table_name'" ) != $feed_locator_table_name ) {
|
319 |
+
$had_error = true;
|
320 |
+
$sb_instagram_posts_manager->add_error( 'database_create', '<strong>' . __( 'There was an error when trying to create the database tables used to locate feeds.', 'instagram-feed' ) .'</strong><br>' . $error . '<br><code>' . $query . '</code>' );
|
321 |
+
}
|
322 |
+
|
323 |
+
if ( ! $had_error ) {
|
324 |
+
$wpdb->query( "ALTER TABLE $feed_locator_table_name ADD INDEX feed_id (feed_id)" );
|
325 |
+
$wpdb->query( "ALTER TABLE $feed_locator_table_name ADD INDEX post_id (post_id)" );
|
326 |
+
|
327 |
+
$sb_instagram_posts_manager->remove_error( 'database_create' );
|
328 |
+
}
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Counts the number of unique feeds in the database.
|
333 |
+
*
|
334 |
+
* @return int
|
335 |
+
*
|
336 |
+
* @since 5.11
|
337 |
+
*/
|
338 |
+
public static function count_unique() {
|
339 |
+
global $wpdb;
|
340 |
+
|
341 |
+
$feed_locator_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEED_LOCATOR );
|
342 |
+
$results_content = $wpdb->get_results( "
|
343 |
+
SELECT COUNT(*) AS num_entries
|
344 |
+
FROM $feed_locator_table_name
|
345 |
+
WHERE html_location = 'content'
|
346 |
+
", ARRAY_A );
|
347 |
+
//echo '<pre>';
|
348 |
+
//var_dump( $results_content );
|
349 |
+
|
350 |
+
$results_other = $wpdb->get_results( "
|
351 |
+
SELECT COUNT(*) AS num_entries
|
352 |
+
FROM $feed_locator_table_name
|
353 |
+
WHERE html_location != 'content'
|
354 |
+
AND html_location != 'unknown'
|
355 |
+
GROUP BY feed_id
|
356 |
+
", ARRAY_A );
|
357 |
+
//var_dump( $results_other );
|
358 |
+
|
359 |
+
$total = 0;
|
360 |
+
if ( isset( $results_content[0]['num_entries'] ) ) {
|
361 |
+
$total += (int)$results_content[0]['num_entries'];
|
362 |
+
}
|
363 |
+
if ( isset( $results_other[0]['num_entries'] ) ) {
|
364 |
+
$total += (int)$results_other[0]['num_entries'];
|
365 |
+
}
|
366 |
+
|
367 |
+
return $total;
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Creates a summary of the located feeds in an array
|
372 |
+
*
|
373 |
+
* @return array
|
374 |
+
*
|
375 |
+
* @since 5.11
|
376 |
+
*/
|
377 |
+
public static function summary() {
|
378 |
+
global $wpdb;
|
379 |
+
|
380 |
+
$feed_locator_table_name = esc_sql( $wpdb->prefix . SBI_INSTAGRAM_FEED_LOCATOR );
|
381 |
+
|
382 |
+
$locations = array(
|
383 |
+
array(
|
384 |
+
'label' => __( 'Content', 'instagram-feed' ),
|
385 |
+
'html_locations' => array( 'content', 'unknown' )
|
386 |
+
),
|
387 |
+
array(
|
388 |
+
'label' => __( 'Header', 'instagram-feed' ),
|
389 |
+
'html_locations' => array( 'header' ),
|
390 |
+
'group_by' => 'feed_id'
|
391 |
+
),
|
392 |
+
array(
|
393 |
+
'label' => __( 'Sidebar', 'instagram-feed' ),
|
394 |
+
'html_locations' => array( 'sidebar' ),
|
395 |
+
'group_by' => 'feed_id'
|
396 |
+
),
|
397 |
+
array(
|
398 |
+
'label' => __( 'Footer', 'instagram-feed' ),
|
399 |
+
'html_locations' => array( 'footer' ),
|
400 |
+
'group_by' => 'feed_id'
|
401 |
+
)
|
402 |
+
);
|
403 |
+
|
404 |
+
$one_result_found = false;
|
405 |
+
|
406 |
+
foreach ( $locations as $key => $location ) {
|
407 |
+
$in = implode( "', '", $location['html_locations'] );
|
408 |
+
$group_by = isset( $location['group_by'] ) ? "GROUP BY " . $location['group_by'] : "";
|
409 |
+
$results = $wpdb->get_results("
|
410 |
+
SELECT *
|
411 |
+
FROM $feed_locator_table_name
|
412 |
+
WHERE html_location IN ('$in')
|
413 |
+
$group_by
|
414 |
+
ORDER BY last_update ASC",ARRAY_A );
|
415 |
+
|
416 |
+
if ( isset( $results[0] ) ) {
|
417 |
+
$one_result_found = true;
|
418 |
+
}
|
419 |
+
|
420 |
+
$locations[ $key ]['results'] = $results;
|
421 |
+
}
|
422 |
+
|
423 |
+
if ( ! $one_result_found ) {
|
424 |
+
return array();
|
425 |
+
}
|
426 |
+
|
427 |
+
return $locations;
|
428 |
+
}
|
429 |
+
}
|
inc/class-sb-instagram-feed.php
CHANGED
@@ -99,6 +99,13 @@ class SB_Instagram_Feed
|
|
99 |
*/
|
100 |
private $cached_feed_error;
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
/**
|
103 |
* @var array
|
104 |
*
|
@@ -124,6 +131,7 @@ class SB_Instagram_Feed
|
|
124 |
$this->post_data = array();
|
125 |
$this->next_pages = array();
|
126 |
$this->cached_feed_error = array();
|
|
|
127 |
$this->should_paginate = true;
|
128 |
|
129 |
// this is a count of how many api calls have been made for each feed
|
@@ -191,6 +199,10 @@ class SB_Instagram_Feed
|
|
191 |
$this->resized_images = $resized_image_data;
|
192 |
}
|
193 |
|
|
|
|
|
|
|
|
|
194 |
/**
|
195 |
* Checks the database option related the transient expiration
|
196 |
* to ensure it will be available when the page loads
|
@@ -304,6 +316,7 @@ class SB_Instagram_Feed
|
|
304 |
$post_data = isset( $transient_data['data'] ) ? $transient_data['data'] : array();
|
305 |
$this->post_data = $post_data;
|
306 |
$this->next_pages = isset( $transient_data['pagination'] ) ? $transient_data['pagination'] : array();
|
|
|
307 |
|
308 |
if ( isset( $transient_data['atts'] ) ) {
|
309 |
$this->transient_atts = $transient_data['atts'];
|
@@ -313,6 +326,8 @@ class SB_Instagram_Feed
|
|
313 |
if ( isset( $transient_data['errors'] ) ) {
|
314 |
$this->cached_feed_error = $transient_data['errors'];
|
315 |
}
|
|
|
|
|
316 |
}
|
317 |
}
|
318 |
|
@@ -536,9 +551,15 @@ class SB_Instagram_Feed
|
|
536 |
*
|
537 |
* @since 2.0/5.0
|
538 |
*/
|
539 |
-
public function need_posts( $num, $offset = 0 ) {
|
540 |
$num_existing_posts = is_array( $this->post_data ) ? count( $this->post_data ) : 0;
|
541 |
$num_needed_for_page = (int)$num + (int)$offset;
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
|
543 |
($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' );
|
544 |
|
@@ -580,6 +601,8 @@ class SB_Instagram_Feed
|
|
580 |
* accounts if needed before using it in an API request
|
581 |
*/
|
582 |
public function add_remote_posts( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
|
|
|
|
|
583 |
$new_post_sets = array();
|
584 |
$next_pages = $this->next_pages;
|
585 |
global $sb_instagram_posts_manager;
|
@@ -770,18 +793,26 @@ class SB_Instagram_Feed
|
|
770 |
}
|
771 |
}
|
772 |
|
773 |
-
|
774 |
if ( ! $one_successful_connection || ($one_api_request_delayed && empty( $new_post_sets )) ) {
|
775 |
$this->should_use_backup = true;
|
776 |
}
|
777 |
$posts = $this->merge_posts( $new_post_sets, $settings );
|
778 |
|
|
|
|
|
|
|
|
|
|
|
|
|
779 |
$posts = $this->sort_posts( $posts, $settings );
|
780 |
|
|
|
|
|
|
|
|
|
|
|
781 |
|
782 |
-
if (
|
783 |
-
$posts = array_merge( $this->post_data, $posts );
|
784 |
-
} elseif ( $one_post_found ) {
|
785 |
$this->one_post_found = true;
|
786 |
}
|
787 |
|
@@ -874,7 +905,8 @@ class SB_Instagram_Feed
|
|
874 |
|
875 |
$to_cache = array(
|
876 |
'data' => $this->post_data,
|
877 |
-
'pagination' => $this->next_pages
|
|
|
878 |
);
|
879 |
|
880 |
global $sb_instagram_posts_manager;
|
@@ -1103,6 +1135,8 @@ class SB_Instagram_Feed
|
|
1103 |
$additional_classes = ' ' . implode( ' ', $classes );
|
1104 |
}
|
1105 |
|
|
|
|
|
1106 |
$other_atts = $this->add_other_atts( $other_atts, $settings );
|
1107 |
|
1108 |
$flags = array();
|
@@ -1125,6 +1159,11 @@ class SB_Instagram_Feed
|
|
1125 |
$flags[] = 'overrideBlockCDN';
|
1126 |
}
|
1127 |
}
|
|
|
|
|
|
|
|
|
|
|
1128 |
if ( isset( $_GET['sbi_debug'] ) ) {
|
1129 |
$flags[] = 'debug';
|
1130 |
}
|
@@ -1277,7 +1316,7 @@ class SB_Instagram_Feed
|
|
1277 |
* @return string
|
1278 |
*/
|
1279 |
protected function add_other_atts( $other_atts, $settings ) {
|
1280 |
-
return
|
1281 |
}
|
1282 |
|
1283 |
/**
|
@@ -1560,6 +1599,35 @@ class SB_Instagram_Feed
|
|
1560 |
return $merged_posts;
|
1561 |
}
|
1562 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1563 |
/**
|
1564 |
* Sorts a post set based on sorting settings. Sorting by "alternate"
|
1565 |
* is done when merging posts for efficiency's sake so the post set is
|
99 |
*/
|
100 |
private $cached_feed_error;
|
101 |
|
102 |
+
/**
|
103 |
+
* @var int
|
104 |
+
*
|
105 |
+
* @since 5.10.1
|
106 |
+
*/
|
107 |
+
protected $pages_created;
|
108 |
+
|
109 |
/**
|
110 |
* @var array
|
111 |
*
|
131 |
$this->post_data = array();
|
132 |
$this->next_pages = array();
|
133 |
$this->cached_feed_error = array();
|
134 |
+
$this->pages_created = 0;
|
135 |
$this->should_paginate = true;
|
136 |
|
137 |
// this is a count of how many api calls have been made for each feed
|
199 |
$this->resized_images = $resized_image_data;
|
200 |
}
|
201 |
|
202 |
+
public function set_pages_created( $num ) {
|
203 |
+
$this->pages_created = $num;
|
204 |
+
}
|
205 |
+
|
206 |
/**
|
207 |
* Checks the database option related the transient expiration
|
208 |
* to ensure it will be available when the page loads
|
316 |
$post_data = isset( $transient_data['data'] ) ? $transient_data['data'] : array();
|
317 |
$this->post_data = $post_data;
|
318 |
$this->next_pages = isset( $transient_data['pagination'] ) ? $transient_data['pagination'] : array();
|
319 |
+
$this->pages_created = isset( $transient_data['pages_created'] ) ? $transient_data['pages_created'] : 0;
|
320 |
|
321 |
if ( isset( $transient_data['atts'] ) ) {
|
322 |
$this->transient_atts = $transient_data['atts'];
|
326 |
if ( isset( $transient_data['errors'] ) ) {
|
327 |
$this->cached_feed_error = $transient_data['errors'];
|
328 |
}
|
329 |
+
|
330 |
+
$this->add_report( 'pages created: ' . $this->pages_created .', next pages exist: ' . ! empty( $this->next_pages ) );
|
331 |
}
|
332 |
}
|
333 |
|
551 |
*
|
552 |
* @since 2.0/5.0
|
553 |
*/
|
554 |
+
public function need_posts( $num, $offset = 0, $page = 0 ) {
|
555 |
$num_existing_posts = is_array( $this->post_data ) ? count( $this->post_data ) : 0;
|
556 |
$num_needed_for_page = (int)$num + (int)$offset;
|
557 |
+
$this->add_report( 'pages created ' .$this->pages_created . ' page on' . $page );
|
558 |
+
|
559 |
+
if ( $this->pages_created < $page ) {
|
560 |
+
$this->add_report( 'need another page' );
|
561 |
+
return true;
|
562 |
+
}
|
563 |
|
564 |
($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' );
|
565 |
|
601 |
* accounts if needed before using it in an API request
|
602 |
*/
|
603 |
public function add_remote_posts( $settings, $feed_types_and_terms, $connected_accounts_for_feed ) {
|
604 |
+
$this->pages_created ++;
|
605 |
+
|
606 |
$new_post_sets = array();
|
607 |
$next_pages = $this->next_pages;
|
608 |
global $sb_instagram_posts_manager;
|
793 |
}
|
794 |
}
|
795 |
|
|
|
796 |
if ( ! $one_successful_connection || ($one_api_request_delayed && empty( $new_post_sets )) ) {
|
797 |
$this->should_use_backup = true;
|
798 |
}
|
799 |
$posts = $this->merge_posts( $new_post_sets, $settings );
|
800 |
|
801 |
+
if ( ! $this->should_merge_after( $settings ) ) {
|
802 |
+
if ( ! empty( $this->post_data ) && is_array( $this->post_data ) ) {
|
803 |
+
$posts = array_merge( $this->post_data, $posts );
|
804 |
+
}
|
805 |
+
}
|
806 |
+
|
807 |
$posts = $this->sort_posts( $posts, $settings );
|
808 |
|
809 |
+
if ( $this->should_merge_after( $settings ) ) {
|
810 |
+
if ( ! empty( $this->post_data ) && is_array( $this->post_data ) ) {
|
811 |
+
$posts = array_merge( $this->post_data, $posts );
|
812 |
+
}
|
813 |
+
}
|
814 |
|
815 |
+
if ( $one_post_found ) {
|
|
|
|
|
816 |
$this->one_post_found = true;
|
817 |
}
|
818 |
|
905 |
|
906 |
$to_cache = array(
|
907 |
'data' => $this->post_data,
|
908 |
+
'pagination' => $this->next_pages,
|
909 |
+
'pages_created' => $this->pages_created
|
910 |
);
|
911 |
|
912 |
global $sb_instagram_posts_manager;
|
1135 |
$additional_classes = ' ' . implode( ' ', $classes );
|
1136 |
}
|
1137 |
|
1138 |
+
$other_atts .= ' data-postid="' . esc_attr( get_the_ID() ) . '"';
|
1139 |
+
|
1140 |
$other_atts = $this->add_other_atts( $other_atts, $settings );
|
1141 |
|
1142 |
$flags = array();
|
1159 |
$flags[] = 'overrideBlockCDN';
|
1160 |
}
|
1161 |
}
|
1162 |
+
if ( ! $settings['isgutenberg']
|
1163 |
+
&& SB_Instagram_Feed_Locator::should_do_ajax_locating( $this->regular_feed_transient_name, get_the_ID() ) ) {
|
1164 |
+
$this->add_report( 'doing feed locating' );
|
1165 |
+
$flags[] = 'locator';
|
1166 |
+
}
|
1167 |
if ( isset( $_GET['sbi_debug'] ) ) {
|
1168 |
$flags[] = 'debug';
|
1169 |
}
|
1316 |
* @return string
|
1317 |
*/
|
1318 |
protected function add_other_atts( $other_atts, $settings ) {
|
1319 |
+
return $other_atts;
|
1320 |
}
|
1321 |
|
1322 |
/**
|
1599 |
return $merged_posts;
|
1600 |
}
|
1601 |
|
1602 |
+
/**
|
1603 |
+
* Sorting by date will be more accurate for multi-term
|
1604 |
+
* feeds if posts are merged before sorting.
|
1605 |
+
*
|
1606 |
+
* @param array $settings
|
1607 |
+
*
|
1608 |
+
* @return bool
|
1609 |
+
*
|
1610 |
+
* @since 5.10.1
|
1611 |
+
*/
|
1612 |
+
protected function should_merge_after( $settings ) {
|
1613 |
+
if ( ! isset( $settings['sortby'] ) ) {
|
1614 |
+
return false;
|
1615 |
+
}
|
1616 |
+
|
1617 |
+
$merge_befores = array(
|
1618 |
+
'alternate',
|
1619 |
+
'api',
|
1620 |
+
'random',
|
1621 |
+
'likes'
|
1622 |
+
);
|
1623 |
+
|
1624 |
+
if ( ! in_array( $settings['sortby'], $merge_befores, true ) ) {
|
1625 |
+
return false;
|
1626 |
+
}
|
1627 |
+
|
1628 |
+
return true;
|
1629 |
+
}
|
1630 |
+
|
1631 |
/**
|
1632 |
* Sorts a post set based on sorting settings. Sorting by "alternate"
|
1633 |
* is done when merging posts for efficiency's sake so the post set is
|
inc/class-sb-instagram-post-set.php
CHANGED
@@ -62,7 +62,7 @@ class SB_Instagram_Post_Set {
|
|
62 |
*
|
63 |
* @since 2.0/4.0
|
64 |
*/
|
65 |
-
public function __construct( $post_data, $transient_name = false, $fill_in_timestamp = NULL, $image_sizes = array( 'personal' => array( 'low' => 320 ), 'business' => array( 'full' => 640, 'low' => 320 ) ), $upload_dir = NULL, $upload_url = NULL ) {
|
66 |
$this->post_data = $post_data;
|
67 |
|
68 |
$this->image_sizes = $image_sizes;
|
62 |
*
|
63 |
* @since 2.0/4.0
|
64 |
*/
|
65 |
+
public function __construct( $post_data, $transient_name = false, $fill_in_timestamp = NULL, $image_sizes = array( 'personal' => array( 'full' => 640, 'low' => 320, 'thumb' => 150 ), 'business' => array( 'full' => 640, 'low' => 320, 'thumb' => 150 ) ), $upload_dir = NULL, $upload_url = NULL ) {
|
66 |
$this->post_data = $post_data;
|
67 |
|
68 |
$this->image_sizes = $image_sizes;
|
inc/class-sb-instagram-post.php
CHANGED
@@ -241,6 +241,8 @@ class SB_Instagram_Post
|
|
241 |
|
242 |
// not uncommon for the image editor to not work using it this way
|
243 |
if ( ! is_wp_error( $image_editor ) ) {
|
|
|
|
|
244 |
$sizes = $image_editor->get_size();
|
245 |
|
246 |
$image_editor->resize( $image_size, null );
|
241 |
|
242 |
// not uncommon for the image editor to not work using it this way
|
243 |
if ( ! is_wp_error( $image_editor ) ) {
|
244 |
+
$image_editor->set_quality(80);
|
245 |
+
|
246 |
$sizes = $image_editor->get_size();
|
247 |
|
248 |
$image_editor->resize( $image_size, null );
|
inc/class-sb-instagram-settings.php
CHANGED
@@ -163,6 +163,31 @@ class SB_Instagram_Settings {
|
|
163 |
}
|
164 |
}
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
/**
|
167 |
* @return array
|
168 |
*
|
@@ -344,7 +369,7 @@ class SB_Instagram_Settings {
|
|
344 |
if ( ! $users ) {
|
345 |
$set = false;
|
346 |
foreach ( $this->connected_accounts as $connected_account ) {
|
347 |
-
if ( ! $set ) {
|
348 |
$set = true;
|
349 |
$this->settings['user'] = $connected_account['username'];
|
350 |
$this->connected_accounts_in_feed = array( $connected_account['user_id'] => $connected_account );
|
@@ -452,7 +477,6 @@ class SB_Instagram_Settings {
|
|
452 |
|
453 |
$sb_instagram_posts_manager->maybe_set_display_error( 'configuration', $error_message_return );
|
454 |
|
455 |
-
|
456 |
$this->atts['accesstoken'] = '';
|
457 |
}
|
458 |
|
@@ -481,7 +505,6 @@ class SB_Instagram_Settings {
|
|
481 |
$sb_instagram_posts_manager->maybe_set_display_error( 'configuration', $error_message_return );
|
482 |
}
|
483 |
|
484 |
-
|
485 |
foreach ( $this->connected_accounts_in_feed as $connected_account_in_feed ) {
|
486 |
if ( isset( $connected_account_in_feed['private'] )
|
487 |
&& sbi_private_account_near_expiration( $connected_account_in_feed ) ) {
|
@@ -495,7 +518,6 @@ class SB_Instagram_Settings {
|
|
495 |
);
|
496 |
|
497 |
$sb_instagram_posts_manager->maybe_set_display_error( 'configuration', $error_message_return );
|
498 |
-
|
499 |
}
|
500 |
}
|
501 |
}
|
163 |
}
|
164 |
}
|
165 |
|
166 |
+
public function feed_type_and_terms_display() {
|
167 |
+
|
168 |
+
if ( ! isset( $this->feed_type_and_terms ) ) {
|
169 |
+
return array();
|
170 |
+
}
|
171 |
+
$return = array();
|
172 |
+
foreach ( $this->feed_type_and_terms as $feed_type => $type_terms ) {
|
173 |
+
foreach ( $type_terms as $term ) {
|
174 |
+
if ( $feed_type === 'users'
|
175 |
+
|| $feed_type === 'tagged' ) {
|
176 |
+
if ( ! in_array( $this->connected_accounts_in_feed[ $term['term'] ]['username'], $return, true ) ) {
|
177 |
+
$return[] = $this->connected_accounts_in_feed[ $term['term'] ]['username'];
|
178 |
+
}
|
179 |
+
} elseif ( $feed_type === 'hashtags_recent'
|
180 |
+
|| $feed_type === 'hashtags_top' ) {
|
181 |
+
if ( ! in_array( $term['hashtag_name'], $return, true ) ) {
|
182 |
+
$return[] = $term['hashtag_name'];
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
return $return;
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
/**
|
192 |
* @return array
|
193 |
*
|
369 |
if ( ! $users ) {
|
370 |
$set = false;
|
371 |
foreach ( $this->connected_accounts as $connected_account ) {
|
372 |
+
if ( ! $set && strpos( $connected_account['accesstoken'], '.' ) === false ) {
|
373 |
$set = true;
|
374 |
$this->settings['user'] = $connected_account['username'];
|
375 |
$this->connected_accounts_in_feed = array( $connected_account['user_id'] => $connected_account );
|
477 |
|
478 |
$sb_instagram_posts_manager->maybe_set_display_error( 'configuration', $error_message_return );
|
479 |
|
|
|
480 |
$this->atts['accesstoken'] = '';
|
481 |
}
|
482 |
|
505 |
$sb_instagram_posts_manager->maybe_set_display_error( 'configuration', $error_message_return );
|
506 |
}
|
507 |
|
|
|
508 |
foreach ( $this->connected_accounts_in_feed as $connected_account_in_feed ) {
|
509 |
if ( isset( $connected_account_in_feed['private'] )
|
510 |
&& sbi_private_account_near_expiration( $connected_account_in_feed ) ) {
|
518 |
);
|
519 |
|
520 |
$sb_instagram_posts_manager->maybe_set_display_error( 'configuration', $error_message_return );
|
|
|
521 |
}
|
522 |
}
|
523 |
}
|
inc/if-functions.php
CHANGED
@@ -208,6 +208,7 @@ function sbi_get_next_post_set() {
|
|
208 |
$atts = $atts_raw; // now sanitized
|
209 |
|
210 |
$offset = isset( $_POST['offset'] ) ? (int)$_POST['offset'] : 0;
|
|
|
211 |
|
212 |
$database_settings = sbi_get_database_settings();
|
213 |
$instagram_feed_settings = new SB_Instagram_Settings( $atts, $database_settings );
|
@@ -226,6 +227,19 @@ function sbi_get_next_post_set() {
|
|
226 |
|
227 |
$settings = $instagram_feed_settings->get_settings();
|
228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
$feed_type_and_terms = $instagram_feed_settings->get_feed_type_and_terms();
|
230 |
|
231 |
$instagram_feed = new SB_Instagram_Feed( $transient_name );
|
@@ -236,8 +250,8 @@ function sbi_get_next_post_set() {
|
|
236 |
$instagram_feed->set_post_data_from_cache();
|
237 |
}
|
238 |
|
239 |
-
if ( $instagram_feed->need_posts( $settings['
|
240 |
-
while ( $instagram_feed->need_posts( $settings['
|
241 |
$instagram_feed->add_remote_posts( $settings, $feed_type_and_terms, $instagram_feed_settings->get_connected_accounts_in_feed() );
|
242 |
}
|
243 |
|
@@ -268,8 +282,8 @@ function sbi_get_next_post_set() {
|
|
268 |
$instagram_feed->add_report( 'regular cache exists' );
|
269 |
$instagram_feed->set_post_data_from_cache();
|
270 |
|
271 |
-
|
272 |
-
|
273 |
$instagram_feed->add_remote_posts( $settings, $feed_type_and_terms, $instagram_feed_settings->get_connected_accounts_in_feed() );
|
274 |
}
|
275 |
|
@@ -369,6 +383,19 @@ function sbi_process_submitted_resize_ids() {
|
|
369 |
$transient_name = $instagram_feed_settings->get_transient_name();
|
370 |
$settings = $instagram_feed_settings->get_settings();
|
371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
if ( $cache_all ) {
|
373 |
$settings['cache_all'] = true;
|
374 |
}
|
@@ -393,6 +420,48 @@ function sbi_process_submitted_resize_ids() {
|
|
393 |
add_action( 'wp_ajax_sbi_resized_images_submit', 'sbi_process_submitted_resize_ids' );
|
394 |
add_action( 'wp_ajax_nopriv_sbi_resized_images_submit', 'sbi_process_submitted_resize_ids' );
|
395 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
/**
|
397 |
* Outputs an organized error report for the front end.
|
398 |
* This hooks into the end of the feed before the closing div
|
208 |
$atts = $atts_raw; // now sanitized
|
209 |
|
210 |
$offset = isset( $_POST['offset'] ) ? (int)$_POST['offset'] : 0;
|
211 |
+
$page = isset( $_POST['page'] ) ? (int)$_POST['page'] : 1;
|
212 |
|
213 |
$database_settings = sbi_get_database_settings();
|
214 |
$instagram_feed_settings = new SB_Instagram_Settings( $atts, $database_settings );
|
227 |
|
228 |
$settings = $instagram_feed_settings->get_settings();
|
229 |
|
230 |
+
$location = isset( $_POST['location'] ) && in_array( $_POST['location'], array( 'header', 'footer', 'sidebar', 'content' ), true ) ? sanitize_text_field( $_POST['location'] ) : 'unknown';
|
231 |
+
$post_id = isset( $_POST['post_id'] ) && $_POST['post_id'] !== 'unknown' ? (int)$_POST['post_id'] : 'unknown';
|
232 |
+
$feed_details = array(
|
233 |
+
'feed_id' => $transient_name,
|
234 |
+
'atts' => $atts,
|
235 |
+
'location' => array(
|
236 |
+
'post_id' => $post_id,
|
237 |
+
'html' => $location
|
238 |
+
)
|
239 |
+
);
|
240 |
+
|
241 |
+
sbi_do_background_tasks( $feed_details );
|
242 |
+
|
243 |
$feed_type_and_terms = $instagram_feed_settings->get_feed_type_and_terms();
|
244 |
|
245 |
$instagram_feed = new SB_Instagram_Feed( $transient_name );
|
250 |
$instagram_feed->set_post_data_from_cache();
|
251 |
}
|
252 |
|
253 |
+
if ( $instagram_feed->need_posts( $settings['minnum'], $offset, $page ) && $instagram_feed->can_get_more_posts() ) {
|
254 |
+
while ( $instagram_feed->need_posts( $settings['minnum'], $offset, $page ) && $instagram_feed->can_get_more_posts() ) {
|
255 |
$instagram_feed->add_remote_posts( $settings, $feed_type_and_terms, $instagram_feed_settings->get_connected_accounts_in_feed() );
|
256 |
}
|
257 |
|
282 |
$instagram_feed->add_report( 'regular cache exists' );
|
283 |
$instagram_feed->set_post_data_from_cache();
|
284 |
|
285 |
+
if ( $instagram_feed->need_posts( $settings['minnum'], $offset, $page ) && $instagram_feed->can_get_more_posts() ) {
|
286 |
+
while ( $instagram_feed->need_posts( $settings['minnum'], $offset, $page ) && $instagram_feed->can_get_more_posts() ) {
|
287 |
$instagram_feed->add_remote_posts( $settings, $feed_type_and_terms, $instagram_feed_settings->get_connected_accounts_in_feed() );
|
288 |
}
|
289 |
|
383 |
$transient_name = $instagram_feed_settings->get_transient_name();
|
384 |
$settings = $instagram_feed_settings->get_settings();
|
385 |
|
386 |
+
$location = isset( $_POST['location'] ) && in_array( $_POST['location'], array( 'header', 'footer', 'sidebar', 'content' ), true ) ? sanitize_text_field( $_POST['location'] ) : 'unknown';
|
387 |
+
$post_id = isset( $_POST['post_id'] ) && $_POST['post_id'] !== 'unknown' ? (int)$_POST['post_id'] : 'unknown';
|
388 |
+
$feed_details = array(
|
389 |
+
'feed_id' => $transient_name,
|
390 |
+
'atts' => $atts,
|
391 |
+
'location' => array(
|
392 |
+
'post_id' => $post_id,
|
393 |
+
'html' => $location
|
394 |
+
)
|
395 |
+
);
|
396 |
+
|
397 |
+
sbi_do_background_tasks( $feed_details );
|
398 |
+
|
399 |
if ( $cache_all ) {
|
400 |
$settings['cache_all'] = true;
|
401 |
}
|
420 |
add_action( 'wp_ajax_sbi_resized_images_submit', 'sbi_process_submitted_resize_ids' );
|
421 |
add_action( 'wp_ajax_nopriv_sbi_resized_images_submit', 'sbi_process_submitted_resize_ids' );
|
422 |
|
423 |
+
function sbi_do_locator() {
|
424 |
+
if ( ! isset( $_POST['feed_id'] ) || strpos( $_POST['feed_id'], 'sbi' ) === false ) {
|
425 |
+
die( 'invalid feed ID');
|
426 |
+
}
|
427 |
+
|
428 |
+
$feed_id = sanitize_text_field( $_POST['feed_id'] );
|
429 |
+
|
430 |
+
|
431 |
+
$atts_raw = isset( $_POST['atts'] ) ? json_decode( stripslashes( $_POST['atts'] ), true ) : array();
|
432 |
+
if ( is_array( $atts_raw ) ) {
|
433 |
+
array_map( 'sanitize_text_field', $atts_raw );
|
434 |
+
} else {
|
435 |
+
$atts_raw = array();
|
436 |
+
}
|
437 |
+
$atts = $atts_raw; // now sanitized
|
438 |
+
|
439 |
+
$location = isset( $_POST['location'] ) && in_array( $_POST['location'], array( 'header', 'footer', 'sidebar', 'content' ), true ) ? sanitize_text_field( $_POST['location'] ) : 'unknown';
|
440 |
+
$post_id = isset( $_POST['post_id'] ) && $_POST['post_id'] !== 'unknown' ? (int)$_POST['post_id'] : 'unknown';
|
441 |
+
$feed_details = array(
|
442 |
+
'feed_id' => $feed_id,
|
443 |
+
'atts' => $atts,
|
444 |
+
'location' => array(
|
445 |
+
'post_id' => $post_id,
|
446 |
+
'html' => $location
|
447 |
+
)
|
448 |
+
);
|
449 |
+
|
450 |
+
sbi_do_background_tasks( $feed_details );
|
451 |
+
|
452 |
+
wp_die( 'locating success' );
|
453 |
+
}
|
454 |
+
add_action( 'wp_ajax_sbi_do_locator', 'sbi_do_locator' );
|
455 |
+
add_action( 'wp_ajax_nopriv_sbi_do_locator', 'sbi_do_locator' );
|
456 |
+
|
457 |
+
function sbi_do_background_tasks( $feed_details ) {
|
458 |
+
$locator = new SB_Instagram_Feed_Locator( $feed_details );
|
459 |
+
$locator->add_or_update_entry();
|
460 |
+
if ( $locator->should_clear_old_locations() ) {
|
461 |
+
$locator->delete_old_locations();
|
462 |
+
}
|
463 |
+
}
|
464 |
+
|
465 |
/**
|
466 |
* Outputs an organized error report for the front end.
|
467 |
* This hooks into the end of the feed before the closing div
|
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.
|
7 |
Author: Smash Balloon
|
8 |
Author URI: https://smashballoon.com/
|
9 |
License: GPLv2 or later
|
@@ -23,11 +23,11 @@ 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.
|
27 |
}
|
28 |
// Db version.
|
29 |
if ( ! defined( 'SBI_DBVERSION' ) ) {
|
30 |
-
define( 'SBI_DBVERSION', '1.
|
31 |
}
|
32 |
|
33 |
// Upload folder name for local image files for posts
|
@@ -42,6 +42,9 @@ if ( ! defined( 'SBI_INSTAGRAM_POSTS_TYPE' ) ) {
|
|
42 |
if ( ! defined( 'SBI_INSTAGRAM_FEEDS_POSTS' ) ) {
|
43 |
define( 'SBI_INSTAGRAM_FEEDS_POSTS', 'sbi_instagram_feeds_posts' );
|
44 |
}
|
|
|
|
|
|
|
45 |
if ( ! defined( 'SBI_REFRESH_THRESHOLD_OFFSET' ) ) {
|
46 |
define( 'SBI_REFRESH_THRESHOLD_OFFSET', 40 * 86400 );
|
47 |
}
|
@@ -98,6 +101,7 @@ if ( function_exists( 'sb_instagram_feed_init' ) ) {
|
|
98 |
require_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-cron-updater.php';
|
99 |
require_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-display-elements.php';
|
100 |
require_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-feed.php';
|
|
|
101 |
include_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-gdpr-integrations.php';
|
102 |
require_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-oembed.php';
|
103 |
require_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-parse.php';
|
@@ -396,6 +400,11 @@ if ( function_exists( 'sb_instagram_feed_init' ) ) {
|
|
396 |
INDEX feed_id (feed_id(100))
|
397 |
) $charset_collate;";
|
398 |
$wpdb->query( $sql );
|
|
|
|
|
|
|
|
|
|
|
399 |
}
|
400 |
$error = $wpdb->last_error;
|
401 |
$query = $wpdb->last_query;
|
@@ -563,17 +572,32 @@ if ( function_exists( 'sb_instagram_feed_init' ) ) {
|
|
563 |
}
|
564 |
|
565 |
if ( (float) $db_ver < 1.8 ) {
|
566 |
-
|
567 |
|
568 |
-
|
569 |
-
|
570 |
|
571 |
-
|
|
|
572 |
|
573 |
-
|
|
|
|
|
|
|
574 |
|
|
|
|
|
|
|
575 |
}
|
576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
}
|
578 |
|
579 |
add_action( 'wp_loaded', 'sbi_check_for_db_updates' );
|
@@ -649,6 +673,8 @@ if ( function_exists( 'sb_instagram_feed_init' ) ) {
|
|
649 |
//Delete tables
|
650 |
$wpdb->query( "DROP TABLE IF EXISTS $posts_table_name" );
|
651 |
$wpdb->query( "DROP TABLE IF EXISTS $feeds_posts_table_name" );
|
|
|
|
|
652 |
|
653 |
$table_name = $wpdb->prefix . "options";
|
654 |
$wpdb->query( "
|
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.8
|
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.8' );
|
27 |
}
|
28 |
// Db version.
|
29 |
if ( ! defined( 'SBI_DBVERSION' ) ) {
|
30 |
+
define( 'SBI_DBVERSION', '1.9' );
|
31 |
}
|
32 |
|
33 |
// Upload folder name for local image files for posts
|
42 |
if ( ! defined( 'SBI_INSTAGRAM_FEEDS_POSTS' ) ) {
|
43 |
define( 'SBI_INSTAGRAM_FEEDS_POSTS', 'sbi_instagram_feeds_posts' );
|
44 |
}
|
45 |
+
if ( ! defined( 'SBI_INSTAGRAM_FEED_LOCATOR' ) ) {
|
46 |
+
define( 'SBI_INSTAGRAM_FEED_LOCATOR', 'sbi_instagram_feed_locator' );
|
47 |
+
}
|
48 |
if ( ! defined( 'SBI_REFRESH_THRESHOLD_OFFSET' ) ) {
|
49 |
define( 'SBI_REFRESH_THRESHOLD_OFFSET', 40 * 86400 );
|
50 |
}
|
101 |
require_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-cron-updater.php';
|
102 |
require_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-display-elements.php';
|
103 |
require_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-feed.php';
|
104 |
+
include_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-feed-locator.php';
|
105 |
include_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-gdpr-integrations.php';
|
106 |
require_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-oembed.php';
|
107 |
require_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-parse.php';
|
400 |
INDEX feed_id (feed_id(100))
|
401 |
) $charset_collate;";
|
402 |
$wpdb->query( $sql );
|
403 |
+
$sbi_statuses_option = get_option( 'sbi_statuses', array() );
|
404 |
+
|
405 |
+
$sbi_statuses_option['database']['hashtag_column'] = true;
|
406 |
+
|
407 |
+
update_option( 'sbi_statuses', $sbi_statuses_option );
|
408 |
}
|
409 |
$error = $wpdb->last_error;
|
410 |
$query = $wpdb->last_query;
|
572 |
}
|
573 |
|
574 |
if ( (float) $db_ver < 1.8 ) {
|
575 |
+
$sbi_statuses_option = get_option( 'sbi_statuses', array() );
|
576 |
|
577 |
+
if ( empty( $sbi_statuses_option['database']['hashtag_column'] ) ) {
|
578 |
+
global $wpdb;
|
579 |
|
580 |
+
$table_name = $wpdb->prefix . SBI_INSTAGRAM_FEEDS_POSTS;
|
581 |
+
$wpdb->query( "ALTER TABLE $table_name ADD hashtag VARCHAR(1000) NOT NULL;" );
|
582 |
|
583 |
+
$wpdb->query( "ALTER TABLE $table_name ADD INDEX hashtag (hashtag(100))" );
|
584 |
+
|
585 |
+
$sbi_statuses_option['database']['hashtag_column'] = true;
|
586 |
+
update_option( 'sbi_statuses', $sbi_statuses_option );
|
587 |
|
588 |
+
}
|
589 |
+
|
590 |
+
update_option( 'sbi_db_version', SBI_DBVERSION );
|
591 |
}
|
592 |
|
593 |
+
if ( (float) $db_ver < 1.9 ) {
|
594 |
+
include_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-posts-manager.php';
|
595 |
+
include_once trailingslashit( SBI_PLUGIN_DIR ) . 'inc/class-sb-instagram-feed-locator.php';
|
596 |
+
|
597 |
+
SB_Instagram_Feed_Locator::create_table();
|
598 |
+
|
599 |
+
update_option( 'sbi_db_version', SBI_DBVERSION );
|
600 |
+
}
|
601 |
}
|
602 |
|
603 |
add_action( 'wp_loaded', 'sbi_check_for_db_updates' );
|
673 |
//Delete tables
|
674 |
$wpdb->query( "DROP TABLE IF EXISTS $posts_table_name" );
|
675 |
$wpdb->query( "DROP TABLE IF EXISTS $feeds_posts_table_name" );
|
676 |
+
$locator_table_name = $wpdb->prefix . SBI_INSTAGRAM_FEED_LOCATOR;
|
677 |
+
$wpdb->query( "DROP TABLE IF EXISTS $locator_table_name" );
|
678 |
|
679 |
$table_name = $wpdb->prefix . "options";
|
680 |
$wpdb->query( "
|
js/sb-instagram-2-2.js
CHANGED
@@ -190,6 +190,7 @@ if(!sbi_js_exists) {
|
|
190 |
num : $self.attr('data-num'),
|
191 |
imgRes : $self.attr('data-res'),
|
192 |
feedID : $self.attr('data-feedid'),
|
|
|
193 |
shortCodeAtts : $self.attr('data-shortcode-atts'),
|
194 |
resizingEnabled : (flags.indexOf('resizeDisable') === -1),
|
195 |
imageLoadEnabled : (flags.indexOf('imageLoadDisable') === -1),
|
@@ -199,6 +200,7 @@ if(!sbi_js_exists) {
|
|
199 |
gdpr : (flags.indexOf('gdpr') > -1),
|
200 |
overrideBlockCDN : (flags.indexOf('overrideBlockCDN') > -1),
|
201 |
consentGiven : false,
|
|
|
202 |
autoMinRes : 1,
|
203 |
general : general
|
204 |
};
|
@@ -254,6 +256,7 @@ if(!sbi_js_exists) {
|
|
254 |
this.resizedImages = {};
|
255 |
this.needsResizing = [];
|
256 |
this.outOfPages = false;
|
|
|
257 |
this.isInitialized = false;
|
258 |
}
|
259 |
|
@@ -434,6 +437,8 @@ if(!sbi_js_exists) {
|
|
434 |
offset: itemOffset,
|
435 |
feed_id: feed.settings.feedID,
|
436 |
atts: feed.settings.shortCodeAtts,
|
|
|
|
|
437 |
cache_all: cacheAll
|
438 |
};
|
439 |
var onSuccess = function(data) {
|
@@ -455,6 +460,18 @@ if(!sbi_js_exists) {
|
|
455 |
}
|
456 |
};
|
457 |
sbiAjax(submitData,onSuccess);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
}
|
459 |
},
|
460 |
loadMoreButtonInit: function () {
|
@@ -470,12 +487,17 @@ if(!sbi_js_exists) {
|
|
470 |
getNewPostSet: function () {
|
471 |
var $self = $(this.el),
|
472 |
feed = this;
|
|
|
|
|
473 |
var itemOffset = $self.find('.sbi_item').length,
|
474 |
submitData = {
|
475 |
action: 'sbi_load_more_clicked',
|
476 |
offset: itemOffset,
|
|
|
477 |
feed_id: feed.settings.feedID,
|
478 |
atts: feed.settings.shortCodeAtts,
|
|
|
|
|
479 |
current_resolution: feed.imageResolution
|
480 |
};
|
481 |
var onSuccess = function (data) {
|
@@ -963,7 +985,23 @@ if(!sbi_js_exists) {
|
|
963 |
feed.afterResize();
|
964 |
},500);
|
965 |
}
|
966 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
967 |
};
|
968 |
|
969 |
window.sbi_init = function() {
|
190 |
num : $self.attr('data-num'),
|
191 |
imgRes : $self.attr('data-res'),
|
192 |
feedID : $self.attr('data-feedid'),
|
193 |
+
postID : typeof $self.attr( 'data-postid' ) !== 'undefind' ? $self.attr( 'data-postid' ) : 'unknown',
|
194 |
shortCodeAtts : $self.attr('data-shortcode-atts'),
|
195 |
resizingEnabled : (flags.indexOf('resizeDisable') === -1),
|
196 |
imageLoadEnabled : (flags.indexOf('imageLoadDisable') === -1),
|
200 |
gdpr : (flags.indexOf('gdpr') > -1),
|
201 |
overrideBlockCDN : (flags.indexOf('overrideBlockCDN') > -1),
|
202 |
consentGiven : false,
|
203 |
+
locator : (flags.indexOf('locator') > -1),
|
204 |
autoMinRes : 1,
|
205 |
general : general
|
206 |
};
|
256 |
this.resizedImages = {};
|
257 |
this.needsResizing = [];
|
258 |
this.outOfPages = false;
|
259 |
+
this.page = 1;
|
260 |
this.isInitialized = false;
|
261 |
}
|
262 |
|
437 |
offset: itemOffset,
|
438 |
feed_id: feed.settings.feedID,
|
439 |
atts: feed.settings.shortCodeAtts,
|
440 |
+
location: feed.locationGuess(),
|
441 |
+
post_id: feed.settings.postID,
|
442 |
cache_all: cacheAll
|
443 |
};
|
444 |
var onSuccess = function(data) {
|
460 |
}
|
461 |
};
|
462 |
sbiAjax(submitData,onSuccess);
|
463 |
+
} else if (feed.settings.locator) {
|
464 |
+
var submitData = {
|
465 |
+
action: 'sbi_do_locator',
|
466 |
+
feed_id: feed.settings.feedID,
|
467 |
+
atts: feed.settings.shortCodeAtts,
|
468 |
+
location: feed.locationGuess(),
|
469 |
+
post_id: feed.settings.postID
|
470 |
+
};
|
471 |
+
var onSuccess = function(data) {
|
472 |
+
|
473 |
+
};
|
474 |
+
sbiAjax(submitData,onSuccess);
|
475 |
}
|
476 |
},
|
477 |
loadMoreButtonInit: function () {
|
487 |
getNewPostSet: function () {
|
488 |
var $self = $(this.el),
|
489 |
feed = this;
|
490 |
+
feed.page ++;
|
491 |
+
|
492 |
var itemOffset = $self.find('.sbi_item').length,
|
493 |
submitData = {
|
494 |
action: 'sbi_load_more_clicked',
|
495 |
offset: itemOffset,
|
496 |
+
page: feed.page,
|
497 |
feed_id: feed.settings.feedID,
|
498 |
atts: feed.settings.shortCodeAtts,
|
499 |
+
location: feed.locationGuess(),
|
500 |
+
post_id: feed.settings.postID,
|
501 |
current_resolution: feed.imageResolution
|
502 |
};
|
503 |
var onSuccess = function (data) {
|
985 |
feed.afterResize();
|
986 |
},500);
|
987 |
}
|
988 |
+
},
|
989 |
+
locationGuess: function() {
|
990 |
+
var $feed = $(this.el),
|
991 |
+
location = 'content';
|
992 |
+
|
993 |
+
if ($feed.closest('footer').length) {
|
994 |
+
location = 'footer';
|
995 |
+
} else if ($feed.closest('.header').length
|
996 |
+
|| $feed.closest('header').length) {
|
997 |
+
location = 'header';
|
998 |
+
} else if ($feed.closest('.sidebar').length
|
999 |
+
|| $feed.closest('aside').length) {
|
1000 |
+
location = 'sidebar';
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
return location;
|
1004 |
+
},
|
1005 |
};
|
1006 |
|
1007 |
window.sbi_init = function() {
|
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 n(){(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(n,r.responsiveCheckTime))}function a(){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,n,a,o,g,c,f=0,u=0,b=l.width(),_=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===b/_>=h.data("owidth")/h.data("oheight")?(i="100%",s="auto",t=Math.floor(b),n=Math.floor(b*(h.data("oheight")/h.data("owidth")))):(i="auto",s="100%",t=Math.floor(_*(h.data("owidth")/h.data("oheight"))),n=Math.floor(_)),g=b-t,"left"===(a=r.horizontalAlign.toLowerCase())&&(u=0),"center"===a&&(u=.5*g),"right"===a&&(u=g),-1!==a.indexOf("%")&&((a=parseInt(a.replace("%",""),10))>0&&(u=g*a*.01)),c=_-n,"left"===(o=r.verticalAlign.toLowerCase())&&(f=0),"center"===o&&(f=.5*c),"bottom"===o&&(f=c),-1!==o.indexOf("%")&&((o=parseInt(o.replace("%",""),10))>0&&(f=c*o*.01)),r.hardPixels&&(i=t,s=n),h.css({width:i,height:s,"margin-left":Math.floor(u),"margin-top":Math.floor(f)}),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"),n=l.attr("data-sbi_imgLiquid-horizontalAlign"),a=l.attr("data-sbi_imgLiquid-verticalAlign");("true"===e||"false"===e)&&(i.fill=Boolean("true"===e)),void 0===n||"left"!==n&&"center"!==n&&"right"!==n&&-1===n.indexOf("%")||(i.horizontalAlign=n),void 0===a||"top"!==a&&"bottom"!==a&&"center"!==a&&-1===a.indexOf("%")||(i.verticalAlign=a)}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",a),h[0].onerror=a,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 n())}())):void a()})}})}(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 n(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),a=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(a.indexOf("testAjax")>-1){window.sbi.triggeredTest=!0;n({action:"sbi_on_ajax_test_trigger"},function(i){console.log("did test")})}var d={cols:s.attr("data-cols"),colsmobile:void 0!==s.attr("data-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===a.indexOf("resizeDisable"),imageLoadEnabled:-1===a.indexOf("imageLoadDisable"),debugEnabled:a.indexOf("debug")>-1,favorLocal:a.indexOf("favorLocal")>-1,ajaxPostLoad:a.indexOf("ajaxPostLoad")>-1,gdpr:a.indexOf("gdpr")>-1,overrideBlockCDN:a.indexOf("overrideBlockCDN")>-1,consentGiven:!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,">").replace(/(<)/g,"<").replace(/(<br\/>)/g,"<br>").replace(/(<br>)/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;e.settings.consentGiven=e.checkConsent(),i(this.el).find(".sbi_photo").parent("p").length&&i(this.el).addClass("sbi_no_autop"),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)}),i(this.el).find(".sbi_item").each(function(){e.lazyLoadCheck(i(this))})},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)},lazyLoadCheck:function(e){if(e.find(".sbi_photo").length&&!e.closest(".sbi").hasClass("sbi-no-ll-check")){var s=this.getImageUrls(e),t=void 0!==s[640]?s[640]:e.find(".sbi_photo").attr("data-full-res");if(!this.settings.consentGiven&&t.indexOf("scontent")>-1)return;e.find(".sbi_photo img").each(function(){t&&void 0!==i(this).attr("data-src")&&i(this).attr("data-src",t),t&&void 0!==i(this).attr("data-orig-src")&&i(this).attr("data-orig-src",t),i(this).on("load",function(){!i(this).hasClass("sbi-replaced")&&i(this).attr("src").indexOf("placeholder")>-1&&(i(this).addClass("sbi-replaced"),t&&(i(this).attr("src",t),i(this).closest(".sbi_imgLiquid_bgSize").length&&i(this).closest(".sbi_imgLiquid_bgSize").css("background-image","url("+t+")")))})})}},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,t=void 0!==e.settings.general.cache_all&&e.settings.general.cache_all;n({action:"sbi_resized_images_submit",needs_resizing:e.needsResizing,offset:s,feed_id:e.settings.feedID,atts:e.settings.shortCodeAtts,cache_all:t},function(i){if(0===i.trim().indexOf("{")){var s=JSON.parse(i);for(var t in e.settings.debugEnabled&&console.log(s),s)s.hasOwnProperty(t)&&(e.resizedImages[t]=s[t]);e.maybeRaiseImageResolution(),setTimeout(function(){e.afterResize()},500)}})}},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;n({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 n=JSON.parse(t);s.settings.debugEnabled&&console.log(n),s.appendNewPosts(n.html),s.addResizedImages(n.resizedImages),s.settings.ajaxPostLoad?(s.settings.ajaxPostLoad=!1,s.afterInitialImagesLoaded()):s.afterNewImagesLoaded(),n.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(),n=e.find("#sbi_images").innerWidth()-e.find("#sbi_images").width(),a=n/2;sbi_photo_width_manual=e.find("#sbi_images").width()/t-n,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(a)*(2-i+2),e.find(".sbi-owl-nav div").css("top",s)},100)},maybeRaiseSingleImageResolution:function(e,s,t){var n=this,a=n.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")))if(a.length<1)e.find(".sbi_link_area").length&&e.find(".sbi_link_area").attr("href",window.sbi.options.placeholder.replace("placeholder.png","thumb-placeholder.png"));else{(e.find(".sbi_link_area").length&&e.find(".sbi_link_area").attr("href")===window.sbi.options.placeholder.replace("placeholder.png","thumb-placeholder.png")||!n.settings.consentGiven)&&e.find(".sbi_link_area").attr("href",a[a.length-1]),void 0!==a[640]&&e.find(".sbi_photo").attr("data-full-res",a[640]),i.each(a,function(i,e){e===o&&(d=parseInt(i),t=!1)});var h=640;switch(n.settings.imgRes){case"thumb":h=150;break;case"medium":h=320;break;case"full":h=640;break;default:var g=Math.max(n.settings.autoMinRes,e.find(".sbi_photo").innerWidth()),c=n.getBestResolutionForAuto(g,l,e);switch(c){case 320:h=320;break;case 150:h=150}}if(h>d||o===window.sbi.options.placeholder||t){if(n.settings.debugEnabled){var f=o===window.sbi.options.placeholder?"was placeholder":"too small";console.log("rais res for "+o,f)}var u=a[h].split("?ig_cache_key")[0];if(o!==u&&(e.find(".sbi_photo img").attr("src",u),e.find(".sbi_photo").css("background-image",'url("'+u+'")')),d=h,"auto"===n.settings.imgRes){var b=!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&&!b){switch(n.settings.debugEnabled&&console.log("rais res again for aspect ratio change "+o),b=!0,g=e.find(".sbi_photo").innerWidth(),c=n.getBestResolutionForAuto(g,t,e),h=640,c){case 320:h=320;break;case 150:h=150}h>d&&(u=a[h].split("?ig_cache_key")[0],s.attr("src",u),s.closest(".sbi_photo").css("background-image",'url("'+u+'")')),"masonry"!==n.layout&&"highlight"!==n.layout||(i(n.el).find("#sbi_images").smashotope(n.isotopeArgs),setTimeout(function(){i(n.el).find("#sbi_images").smashotope(n.isotopeArgs)},500))}else if(n.settings.debugEnabled){var r=b?"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)&&n.settings.consentGiven){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"))}else n.settings.favorLocal=!0,void 0!==(e=n.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"));setTimeout(function(){n.afterResize()},1500)}})}},maybeRaiseImageResolution:function(e){var s=this,t=void 0!==e&&!0===e?".sbi_item.sbi_new":".sbi_item",n=!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,n)}),s.isInitialized=!0},getBestResolutionForAuto:function(e,s,t){(isNaN(s)||s<1)&&(s=1);var n=e*s,a=10*Math.ceil(n/10),o=[150,320,640];if(t.hasClass("sbi_highlighted")&&(a*=2),-1===o.indexOf(parseInt(a))){var d=!1;i.each(o,function(i,e){e>parseInt(a)&&!d&&(a=e,d=!0)})}return a},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,n=this.getColumnCount(),a=(s-t*(n+2))/n;a>120&&a<240?e.addClass("sbi_medium"):a<=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(this.settings.consentGiven||this.settings.overrideBlockCDN||(e=[]),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,n=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,n=i.is(":visible");e.sbiPreviousVisibility=n,null==s?e.runOnLoad&&e.callback(i,n):s!==n&&e.callback(i,n),setTimeout(function(){t.sbiCheckVisibility(i,e)},e.frequency)}}},e.fn.sbiVisibilityChanged=function(i){var n=e.extend({},s,i);return this.each(function(){t.sbiCheckVisibility(e(this),n)})},"function"==typeof i(this.el).filter(":hidden").sbiVisibilityChanged&&i(this.el).filter(":hidden").sbiVisibilityChanged({callback:function(i,e){n.afterResize()},runOnLoad:!1})},getColumnCount:function(){var e=i(this.el),s=this.settings.cols,t=this.settings.colsmobile,n=s;return sbiWindowWidth=window.innerWidth,e.hasClass("sbi_mob_col_auto")?(sbiWindowWidth<640&&parseInt(s)>2&&parseInt(s)<7&&(n=2),sbiWindowWidth<640&&parseInt(s)>6&&parseInt(s)<11&&(n=4),sbiWindowWidth<=480&&parseInt(s)>2&&(n=1)):sbiWindowWidth<=480&&(n=t),parseInt(n)},checkConsent:function(){if(this.settings.consentGiven||!this.settings.gdpr)return!0;if("undefined"!=typeof CLI_Cookie)null!==CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)&&(this.settings.consentGiven="yes"===CLI_Cookie.read("cookielawinfo-checkbox-non-necessary"));else if(void 0!==window.cnArgs){var i=("; "+document.cookie).split("; cookie_notice_accepted=");if(2===i.length){var e=i.pop().split(";").shift();this.settings.consentGiven="true"===e}}else void 0!==window.cookieconsent?this.settings.consentGiven="allow"===function(i){for(var e=i+"=",s=window.document.cookie.split(";"),t=0;t<s.length;t++){var n=s[t].trim();if(0==n.indexOf(e))return n.substring(e.length,n.length)}return""}("complianz_consent_status"):void 0!==window.Cookiebot?this.settings.consentGiven=Cookiebot.consented:void 0!==window.BorlabsCookie&&(this.settings.consentGiven=window.BorlabsCookie.checkCookieConsent("instagram"));var s=jQuery.Event("sbicheckconsent");return s.feed=this,jQuery(window).trigger(s),this.settings.consentGiven},afterConsentToggled:function(){if(this.checkConsent()){var i=this;i.maybeRaiseImageResolution(),setTimeout(function(){i.afterResize()},500)}}},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("https:","http:"):window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("http:","https:")),sbi_init(),i("#cookie-notice a").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i("#cookie-law-info-bar a").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i(".cli-user-preference-checkbox").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i(window).on("CookiebotOnAccept",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!0,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("cmplzAcceptAll",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!0,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("cmplzRevoke",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("borlabs-cookie-consent-saved",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})})}));
|
1 |
+
var sbi_js_exists=void 0!==sbi_js_exists;sbi_js_exists||(!function(i){function e(){var i,e,t,s=s||{VER:"0.9.944"};s.bgs_Available=!1,s.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(!s.bgs_CheckRunned){s.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 t=window.getComputedStyle(i,null);t&&t.backgroundSize&&(s.bgs_Available="cover"===t.backgroundSize)}}(),e.remove()}}();var t=this;return this.options=e,this.settings=i.extend({},this.defaults,this.options),this.settings.onStart&&this.settings.onStart(),this.each(function(e){function n(){(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(n,r.responsiveCheckTime))}function a(){h.data("sbi_imgLiquid_error",!0),l.addClass("sbi_imgLiquid_error"),r.onItemError&&r.onItemError(e,l,h),d()}function o(){var i,t,s,n,a,o,g,c,f=0,u=0,b=l.width(),_=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===b/_>=h.data("owidth")/h.data("oheight")?(i="100%",t="auto",s=Math.floor(b),n=Math.floor(b*(h.data("oheight")/h.data("owidth")))):(i="auto",t="100%",s=Math.floor(_*(h.data("owidth")/h.data("oheight"))),n=Math.floor(_)),g=b-s,"left"===(a=r.horizontalAlign.toLowerCase())&&(u=0),"center"===a&&(u=.5*g),"right"===a&&(u=g),-1!==a.indexOf("%")&&((a=parseInt(a.replace("%",""),10))>0&&(u=g*a*.01)),c=_-n,"left"===(o=r.verticalAlign.toLowerCase())&&(f=0),"center"===o&&(f=.5*c),"bottom"===o&&(f=c),-1!==o.indexOf("%")&&((o=parseInt(o.replace("%",""),10))>0&&(f=c*o*.01)),r.hardPixels&&(i=s,t=n),h.css({width:i,height:t,"margin-left":Math.floor(u),"margin-top":Math.floor(f)}),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===t.length-1&&t.settings.onFinish&&t.settings.onFinish()}var r=t.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"),t.options)):r=i.extend({},t.settings,function(){var i={};if(t.settings.useDataHtmlAttr){var e=l.attr("data-sbi_imgLiquid-fill"),n=l.attr("data-sbi_imgLiquid-horizontalAlign"),a=l.attr("data-sbi_imgLiquid-verticalAlign");("true"===e||"false"===e)&&(i.fill=Boolean("true"===e)),void 0===n||"left"!==n&&"center"!==n&&"right"!==n&&-1===n.indexOf("%")||(i.horizontalAlign=n),void 0===a||"top"!==a&&"bottom"!==a&&"center"!==a&&-1===a.indexOf("%")||(i.verticalAlign=a)}return s.isIE&&t.settings.ieFadeInDisabled&&(i.fadeInTime=0),i}()),h.data("sbi_imgLiquid_settings",r),r.onItemStart&&r.onItemStart(e,l,h),void(s.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 t(){if(h.data("oldSrc")&&h.data("oldSrc")!==h.attr("src")){var s=h.clone().removeAttr("style");return s.data("sbi_imgLiquid_settings",h.data("sbi_imgLiquid_settings")),h.parent().prepend(s),h.remove(),(h=s)[0].width=0,void setTimeout(t,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",a),h[0].onerror=a,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 n())}())):void a()})}})}(jQuery),i=s.injectCss,e=document.getElementsByTagName("head")[0],(t=document.createElement("style")).type="text/css",t.styleSheet?t.styleSheet.cssText=i:t.appendChild(document.createTextNode(i)),e.appendChild(t)}function t(){this.feeds={},this.options=sb_instagram_js_options}function s(i,e,t){this.el=i,this.index=e,this.settings=t,this.minImageWidth=0,this.imageResolution=150,this.resizedImages={},this.needsResizing=[],this.outOfPages=!1,this.page=1,this.isInitialized=!1}function n(e,t){i.ajax({url:sbiajaxurl,type:"post",data:e,success:t})}t.prototype={createPage:function(e,t){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(t)},createFeeds:function(e){e.whenFeedsCreated(i(".sbi").each(function(e){i(this).attr("data-sbi-index",e+1);var t=i(this),a=void 0!==t.attr("data-sbi-flags")?t.attr("data-sbi-flags").split(","):[],o=void 0!==t.attr("data-options")?JSON.parse(t.attr("data-options")):{};if(a.indexOf("testAjax")>-1){window.sbi.triggeredTest=!0;n({action:"sbi_on_ajax_test_trigger"},function(i){console.log("did test")})}var d={cols:t.attr("data-cols"),colsmobile:void 0!==t.attr("data-colsmobile")&&"same"!==t.attr("data-colsmobile")?t.attr("data-colsmobile"):t.attr("data-cols"),num:t.attr("data-num"),imgRes:t.attr("data-res"),feedID:t.attr("data-feedid"),postID:"undefind"!=typeof t.attr("data-postid")?t.attr("data-postid"):"unknown",shortCodeAtts:t.attr("data-shortcode-atts"),resizingEnabled:-1===a.indexOf("resizeDisable"),imageLoadEnabled:-1===a.indexOf("imageLoadDisable"),debugEnabled:a.indexOf("debug")>-1,favorLocal:a.indexOf("favorLocal")>-1,ajaxPostLoad:a.indexOf("ajaxPostLoad")>-1,gdpr:a.indexOf("gdpr")>-1,overrideBlockCDN:a.indexOf("overrideBlockCDN")>-1,consentGiven:!1,locator:a.indexOf("locator")>-1,autoMinRes:1,general:o};window.sbi.feeds[e]=function(i,e,t){return new s(i,e,t)}(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,">").replace(/(<)/g,"<").replace(/(<br\/>)/g,"<br>").replace(/(<br>)/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)}},s.prototype={init:function(){var e=this;e.settings.consentGiven=e.checkConsent(),i(this.el).find(".sbi_photo").parent("p").length&&i(this.el).addClass("sbi_no_autop"),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 t,s=(t=0,function(i,e){clearTimeout(t),t=setTimeout(i,e)});jQuery(window).resize(function(){s(function(){e.afterResize()},500)}),i(this.el).find(".sbi_item").each(function(){e.lazyLoadCheck(i(this))})},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),t=this;this.beforeNewImagesRevealed(),this.revealNewImages(),this.afterNewImagesRevealed(),setTimeout(function(){e.find(".sbi_loader").addClass("sbi_hidden"),e.find(".sbi_btn_text").removeClass("sbi_hidden"),t.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)},lazyLoadCheck:function(e){if(e.find(".sbi_photo").length&&!e.closest(".sbi").hasClass("sbi-no-ll-check")){var t=this.getImageUrls(e),s=void 0!==t[640]?t[640]:e.find(".sbi_photo").attr("data-full-res");if(!this.settings.consentGiven&&s.indexOf("scontent")>-1)return;e.find(".sbi_photo img").each(function(){s&&void 0!==i(this).attr("data-src")&&i(this).attr("data-src",s),s&&void 0!==i(this).attr("data-orig-src")&&i(this).attr("data-orig-src",s),i(this).on("load",function(){!i(this).hasClass("sbi-replaced")&&i(this).attr("src").indexOf("placeholder")>-1&&(i(this).addClass("sbi-replaced"),s&&(i(this).attr("src",s),i(this).closest(".sbi_imgLiquid_bgSize").length&&i(this).closest(".sbi_imgLiquid_bgSize").css("background-image","url("+s+")")))})})}},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 t=i(this.el).find(".sbi_item").length,s=void 0!==e.settings.general.cache_all&&e.settings.general.cache_all;n({action:"sbi_resized_images_submit",needs_resizing:e.needsResizing,offset:t,feed_id:e.settings.feedID,atts:e.settings.shortCodeAtts,location:e.locationGuess(),post_id:e.settings.postID,cache_all:s},function(i){if(0===i.trim().indexOf("{")){var t=JSON.parse(i);for(var s in e.settings.debugEnabled&&console.log(t),t)t.hasOwnProperty(s)&&(e.resizedImages[s]=t[s]);e.maybeRaiseImageResolution(),setTimeout(function(){e.afterResize()},500)}})}else if(e.settings.locator){n({action:"sbi_do_locator",feed_id:e.settings.feedID,atts:e.settings.shortCodeAtts,location:e.locationGuess(),post_id:e.settings.postID},function(i){})}},loadMoreButtonInit:function(){var e=i(this.el),t=this;e.find("#sbi_load .sbi_load_btn").off().on("click",function(){t.afterLoadMoreClicked(jQuery(this)),t.getNewPostSet()})},getNewPostSet:function(){var e=i(this.el),t=this;t.page++;n({action:"sbi_load_more_clicked",offset:e.find(".sbi_item").length,page:t.page,feed_id:t.settings.feedID,atts:t.settings.shortCodeAtts,location:t.locationGuess(),post_id:t.settings.postID,current_resolution:t.imageResolution},function(s){if(0===s.trim().indexOf("{")){var n=JSON.parse(s);t.settings.debugEnabled&&console.log(n),t.appendNewPosts(n.html),t.addResizedImages(n.resizedImages),t.settings.ajaxPostLoad?(t.settings.ajaxPostLoad=!1,t.afterInitialImagesLoaded()):t.afterNewImagesLoaded(),n.feedStatus.shouldPaginate?t.outOfPages=!1:(t.outOfPages=!0,e.find(".sbi_load_btn").hide()),i(".sbi_no_js").removeClass("sbi_no_js")}})},appendNewPosts:function(e){var t=i(this.el);t.find("#sbi_images .sbi_item").length?t.find("#sbi_images .sbi_item").last().after(e):t.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),t=e.find(".sbi_photo").eq(0).innerWidth(),s=this.getColumnCount(),n=e.find("#sbi_images").innerWidth()-e.find("#sbi_images").width(),a=n/2;sbi_photo_width_manual=e.find("#sbi_images").width()/s-n,e.find(".sbi_photo").css("height",t),e.find(".sbi-owl-nav").length&&setTimeout(function(){var i=2;e.find(".sbi_owl2row-item").length&&(i=1);var t=e.find(".sbi_photo").eq(0).innerWidth()/i;t+=parseInt(a)*(2-i+2),e.find(".sbi-owl-nav div").css("top",t)},100)},maybeRaiseSingleImageResolution:function(e,t,s){var n=this,a=n.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;s=void 0!==s&&s;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")))if(a.length<1)e.find(".sbi_link_area").length&&e.find(".sbi_link_area").attr("href",window.sbi.options.placeholder.replace("placeholder.png","thumb-placeholder.png"));else{(e.find(".sbi_link_area").length&&e.find(".sbi_link_area").attr("href")===window.sbi.options.placeholder.replace("placeholder.png","thumb-placeholder.png")||!n.settings.consentGiven)&&e.find(".sbi_link_area").attr("href",a[a.length-1]),void 0!==a[640]&&e.find(".sbi_photo").attr("data-full-res",a[640]),i.each(a,function(i,e){e===o&&(d=parseInt(i),s=!1)});var h=640;switch(n.settings.imgRes){case"thumb":h=150;break;case"medium":h=320;break;case"full":h=640;break;default:var g=Math.max(n.settings.autoMinRes,e.find(".sbi_photo").innerWidth()),c=n.getBestResolutionForAuto(g,l,e);switch(c){case 320:h=320;break;case 150:h=150}}if(h>d||o===window.sbi.options.placeholder||s){if(n.settings.debugEnabled){var f=o===window.sbi.options.placeholder?"was placeholder":"too small";console.log("rais res for "+o,f)}var u=a[h].split("?ig_cache_key")[0];if(o!==u&&(e.find(".sbi_photo img").attr("src",u),e.find(".sbi_photo").css("background-image",'url("'+u+'")')),d=h,"auto"===n.settings.imgRes){var b=!1;e.find(".sbi_photo img").on("load",function(){var t=i(this),s=t.get(0).naturalWidth/t.get(0).naturalHeight;if(1e3!==t.get(0).naturalWidth&&s>l&&!b){switch(n.settings.debugEnabled&&console.log("rais res again for aspect ratio change "+o),b=!0,g=e.find(".sbi_photo").innerWidth(),c=n.getBestResolutionForAuto(g,s,e),h=640,c){case 320:h=320;break;case 150:h=150}h>d&&(u=a[h].split("?ig_cache_key")[0],t.attr("src",u),t.closest(".sbi_photo").css("background-image",'url("'+u+'")')),"masonry"!==n.layout&&"highlight"!==n.layout||(i(n.el).find("#sbi_images").smashotope(n.isotopeArgs),setTimeout(function(){i(n.el).find("#sbi_images").smashotope(n.isotopeArgs)},500))}else if(n.settings.debugEnabled){var r=b?"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)&&n.settings.consentGiven){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"))}else n.settings.favorLocal=!0,void 0!==(e=n.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"));setTimeout(function(){n.afterResize()},1500)}})}},maybeRaiseImageResolution:function(e){var t=this,s=void 0!==e&&!0===e?".sbi_item.sbi_new":".sbi_item",n=!t.isInitialized;i(t.el).find(s).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")&&t.maybeRaiseSingleImageResolution(i(this),e,n)}),t.isInitialized=!0},getBestResolutionForAuto:function(e,t,s){(isNaN(t)||t<1)&&(t=1);var n=e*t,a=10*Math.ceil(n/10),o=[150,320,640];if(s.hasClass("sbi_highlighted")&&(a*=2),-1===o.indexOf(parseInt(a))){var d=!1;i.each(o,function(i,e){e>parseInt(a)&&!d&&(a=e,d=!0)})}return a},hideExtraImagesForWidth:function(){if("carousel"!==this.layout){var e=i(this.el),t=void 0!==e.attr("data-num")&&""!==e.attr("data-num")?parseInt(e.attr("data-num")):1,s=void 0!==e.attr("data-nummobile")&&""!==e.attr("data-nummobile")?parseInt(e.attr("data-nummobile")):t;i(window).width()<480?s<e.find(".sbi_item").length&&e.find(".sbi_item").slice(s-e.find(".sbi_item").length).addClass("sbi_num_diff_hide"):t<e.find(".sbi_item").length&&e.find(".sbi_item").slice(t-e.find(".sbi_item").length).addClass("sbi_num_diff_hide")}},setImageSizeClass:function(){var e=i(this.el);e.removeClass("sbi_small sbi_medium");var t=e.innerWidth(),s=parseInt(e.find("#sbi_images").outerWidth()-e.find("#sbi_images").width())/2,n=this.getColumnCount(),a=(t-s*(n+2))/n;a>120&&a<240?e.addClass("sbi_medium"):a<=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,"/")),t=i.attr("id").replace("sbi_","");if(this.settings.consentGiven||this.settings.overrideBlockCDN||(e=[]),void 0!==this.resizedImages[t]&&"video"!==this.resizedImages[t]&&"pending"!==this.resizedImages[t]&&"error"!==this.resizedImages[t].id&&"video"!==this.resizedImages[t].id&&"pending"!==this.resizedImages[t].id){if(void 0!==this.resizedImages[t].sizes){var s=[];void 0!==this.resizedImages[t].sizes.full&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"full.jpg",s.push(640)),void 0!==this.resizedImages[t].sizes.low&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"low.jpg",s.push(320)),void 0!==this.resizedImages[t].sizes.thumb&&(s.push(150),e[150]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"thumb.jpg"),this.settings.favorLocal&&(-1===s.indexOf(640)&&s.indexOf(320)>-1&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"low.jpg"),-1===s.indexOf(320)&&(s.indexOf(640)>-1?e[320]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"full.jpg":s.indexOf(150)>-1&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"thumb.jpg")),-1===s.indexOf(150)&&(s.indexOf(320)>-1?e[150]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"low.jpg":s.indexOf(640)>-1&&(e[150]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"full.jpg")))}}else(void 0===this.resizedImages[t]||void 0!==this.resizedImages[t].id&&"pending"!==this.resizedImages[t].id&&"error"!==this.resizedImages[t].id)&&this.addToNeedsResizing(t);return e},getAvatarUrl:function(i,e){if(""===i)return"";var t=this.settings.general.avatars;return"local"===(e=void 0!==e?e:"local")?void 0!==t["LCL"+i]&&1===parseInt(t["LCL"+i])?sb_instagram_js_options.resized_url+i+".jpg":void 0!==t[i]?t[i]:"":void 0!==t[i]?t[i]:void 0!==t["LCL"+i]&&1===parseInt(t["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 t=i(this.el);e(),"function"==typeof t.find(".sbi_photo").sbi_imgLiquid&&t.find(".sbi_photo").sbi_imgLiquid({fill:!0})},listenForVisibilityChange:function(){var e,t,s,n=this;e=jQuery,t={callback:function(){},runOnLoad:!0,frequency:100,sbiPreviousVisibility:null},s={sbiCheckVisibility:function(i,e){if(jQuery.contains(document,i[0])){var t=e.sbiPreviousVisibility,n=i.is(":visible");e.sbiPreviousVisibility=n,null==t?e.runOnLoad&&e.callback(i,n):t!==n&&e.callback(i,n),setTimeout(function(){s.sbiCheckVisibility(i,e)},e.frequency)}}},e.fn.sbiVisibilityChanged=function(i){var n=e.extend({},t,i);return this.each(function(){s.sbiCheckVisibility(e(this),n)})},"function"==typeof i(this.el).filter(":hidden").sbiVisibilityChanged&&i(this.el).filter(":hidden").sbiVisibilityChanged({callback:function(i,e){n.afterResize()},runOnLoad:!1})},getColumnCount:function(){var e=i(this.el),t=this.settings.cols,s=this.settings.colsmobile,n=t;return sbiWindowWidth=window.innerWidth,e.hasClass("sbi_mob_col_auto")?(sbiWindowWidth<640&&parseInt(t)>2&&parseInt(t)<7&&(n=2),sbiWindowWidth<640&&parseInt(t)>6&&parseInt(t)<11&&(n=4),sbiWindowWidth<=480&&parseInt(t)>2&&(n=1)):sbiWindowWidth<=480&&(n=s),parseInt(n)},checkConsent:function(){if(this.settings.consentGiven||!this.settings.gdpr)return!0;if("undefined"!=typeof CLI_Cookie)null!==CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)&&(this.settings.consentGiven="yes"===CLI_Cookie.read("cookielawinfo-checkbox-non-necessary"));else if(void 0!==window.cnArgs){var i=("; "+document.cookie).split("; cookie_notice_accepted=");if(2===i.length){var e=i.pop().split(";").shift();this.settings.consentGiven="true"===e}}else void 0!==window.cookieconsent?this.settings.consentGiven="allow"===function(i){for(var e=i+"=",t=window.document.cookie.split(";"),s=0;s<t.length;s++){var n=t[s].trim();if(0==n.indexOf(e))return n.substring(e.length,n.length)}return""}("complianz_consent_status"):void 0!==window.Cookiebot?this.settings.consentGiven=Cookiebot.consented:void 0!==window.BorlabsCookie&&(this.settings.consentGiven=window.BorlabsCookie.checkCookieConsent("instagram"));var t=jQuery.Event("sbicheckconsent");return t.feed=this,jQuery(window).trigger(t),this.settings.consentGiven},afterConsentToggled:function(){if(this.checkConsent()){var i=this;i.maybeRaiseImageResolution(),setTimeout(function(){i.afterResize()},500)}},locationGuess:function(){var e=i(this.el),t="content";return e.closest("footer").length?t="footer":e.closest(".header").length||e.closest("header").length?t="header":(e.closest(".sidebar").length||e.closest("aside").length)&&(t="sidebar"),t}},window.sbi_init=function(){window.sbi=new t,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("https:","http:"):window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("http:","https:")),sbi_init(),i("#cookie-notice a").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i("#cookie-law-info-bar a").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i(".cli-user-preference-checkbox").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i(window).on("CookiebotOnAccept",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!0,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("cmplzAcceptAll",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!0,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("cmplzRevoke",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("borlabs-cookie-consent-saved",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})})}));
|
js/sb-instagram-admin-2-2.js
CHANGED
@@ -828,8 +828,8 @@ jQuery(document).ready(function($) {
|
|
828 |
}
|
829 |
}); // ajax call
|
830 |
}
|
831 |
-
|
832 |
-
|
833 |
jQuery('#sbi_admin').on('click', '.sbi_tooltip_link, .sbi_type_tooltip_link', function(){
|
834 |
if( jQuery(this).hasClass('sbi_type_tooltip_link') ){
|
835 |
jQuery(this).closest('.sbi_row').children('.sbi_tooltip').slideToggle();
|
@@ -840,113 +840,117 @@ jQuery(document).ready(function($) {
|
|
840 |
}
|
841 |
});
|
842 |
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
}
|
856 |
-
|
857 |
-
|
858 |
-
|
|
|
|
|
|
|
|
|
859 |
|
860 |
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
|
867 |
-
|
868 |
|
869 |
|
870 |
-
//Add the color picker
|
871 |
-
if( jQuery('.sbi_colorpick').length > 0 ) jQuery('.sbi_colorpick').wpColorPicker();
|
872 |
|
873 |
-
|
874 |
-
|
875 |
|
876 |
-
|
877 |
-
|
878 |
-
$sbi_other_user_error = $(this).closest('td').find('.sbi_other_user_error');
|
879 |
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
$sbi_user_id_error.fadeOut();
|
884 |
-
}
|
885 |
|
886 |
-
|
887 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
888 |
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
if(jQuery('#sb_instagram_at').val().indexOf(sbi_user_id) == -1 ){
|
893 |
$sbi_other_user_error.fadeIn();
|
894 |
} else {
|
895 |
$sbi_other_user_error.fadeOut();
|
896 |
}
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
|
907 |
-
|
908 |
|
909 |
-
|
910 |
-
|
911 |
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
|
923 |
-
|
924 |
|
925 |
-
|
926 |
jQuery('#sbi_admin a').click(function() {
|
927 |
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
}
|
937 |
});
|
938 |
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
|
949 |
-
|
950 |
function sbiUpdateLayoutTypeOptionsDisplay() {
|
951 |
setTimeout(function(){
|
952 |
jQuery('.sb_instagram_layout_settings').hide();
|
@@ -1155,6 +1159,14 @@ jQuery(document).ready(function($) {
|
|
1155 |
}
|
1156 |
}
|
1157 |
sbiCheckGdprSetting();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1158 |
});
|
1159 |
|
1160 |
|
828 |
}
|
829 |
}); // ajax call
|
830 |
}
|
831 |
+
|
832 |
+
//Tooltips
|
833 |
jQuery('#sbi_admin').on('click', '.sbi_tooltip_link, .sbi_type_tooltip_link', function(){
|
834 |
if( jQuery(this).hasClass('sbi_type_tooltip_link') ){
|
835 |
jQuery(this).closest('.sbi_row').children('.sbi_tooltip').slideToggle();
|
840 |
}
|
841 |
});
|
842 |
|
843 |
+
//Shortcode labels
|
844 |
+
jQuery('#sbi_admin label').click(function(){
|
845 |
+
var $sbi_shortcode = jQuery(this).siblings('.sbi_shortcode');
|
846 |
+
var $el = jQuery(this).parent();
|
847 |
+
|
848 |
+
if($sbi_shortcode.is(':visible')){
|
849 |
+
$el.removeClass('sbi_shortcode_visible');
|
850 |
+
$el.find('.sbi_shortcode').css('display','none');
|
851 |
+
} else {
|
852 |
+
$el.addClass('sbi_shortcode_visible');
|
853 |
+
$el.find('.sbi_shortcode').css('display','block');
|
854 |
+
}
|
855 |
+
});
|
856 |
+
jQuery('#sbi_admin label').hover(function(){
|
857 |
+
if( jQuery(this).siblings('.sbi_shortcode').length > 0 ){
|
858 |
+
jQuery(this).attr('title', 'Click for shortcode option').append('<code class="sbi_shortcode_symbol">[]</code>');
|
859 |
+
}
|
860 |
+
}, function(){
|
861 |
+
jQuery(this).find('.sbi_shortcode_symbol').remove();
|
862 |
+
});
|
863 |
|
864 |
|
865 |
+
jQuery('#sbi_admin .sbi_lock').hover(function(){
|
866 |
+
jQuery(this).siblings('.sbi_pro_tooltip').show();
|
867 |
+
}, function(){
|
868 |
+
jQuery('.sbi_pro_tooltip').hide();
|
869 |
+
});
|
870 |
|
|
|
871 |
|
872 |
|
|
|
|
|
873 |
|
874 |
+
//Add the color picker
|
875 |
+
if( jQuery('.sbi_colorpick').length > 0 ) jQuery('.sbi_colorpick').wpColorPicker();
|
876 |
|
877 |
+
//Check User ID is numeric
|
878 |
+
jQuery("#sb_instagram_user_id").change(function() {
|
|
|
879 |
|
880 |
+
var sbi_user_id = jQuery('#sb_instagram_user_id').val(),
|
881 |
+
$sbi_user_id_error = $(this).closest('td').find('.sbi_user_id_error'),
|
882 |
+
$sbi_other_user_error = $(this).closest('td').find('.sbi_other_user_error');
|
|
|
|
|
883 |
|
884 |
+
if (sbi_user_id.match(/[^0-9, _.-]/)) {
|
885 |
+
$sbi_user_id_error.fadeIn();
|
886 |
+
} else {
|
887 |
+
$sbi_user_id_error.fadeOut();
|
888 |
+
}
|
889 |
+
|
890 |
+
//Check whether an ID from another account is being used
|
891 |
+
sbi_check_other_user_id(sbi_user_id, $sbi_other_user_error);
|
892 |
|
893 |
+
});
|
894 |
+
function sbi_check_other_user_id(sbi_user_id, $sbi_other_user_error){
|
895 |
+
if (jQuery('#sb_instagram_at').length && jQuery('#sb_instagram_at').val() !== '' && sbi_user_id.length) {
|
896 |
if(jQuery('#sb_instagram_at').val().indexOf(sbi_user_id) == -1 ){
|
897 |
$sbi_other_user_error.fadeIn();
|
898 |
} else {
|
899 |
$sbi_other_user_error.fadeOut();
|
900 |
}
|
901 |
+
}
|
902 |
+
}
|
903 |
+
//Check initially when settings load
|
904 |
+
sbi_check_other_user_id( jQuery('#sb_instagram_user_id').val(), $('td').find('.sbi_other_user_error') );
|
905 |
|
906 |
+
//Mobile width
|
907 |
+
var sb_instagram_feed_width = jQuery('#sbi_admin #sb_instagram_width').val(),
|
908 |
+
sb_instagram_width_unit = jQuery('#sbi_admin #sb_instagram_width_unit').val(),
|
909 |
+
$sb_instagram_width_options = jQuery('#sbi_admin #sb_instagram_width_options');
|
910 |
|
911 |
+
if (typeof sb_instagram_feed_width !== 'undefined') {
|
912 |
|
913 |
+
//Show initially if a width is set
|
914 |
+
if( (sb_instagram_feed_width.length > 1 && sb_instagram_width_unit == 'px') || (sb_instagram_feed_width !== '100' && sb_instagram_width_unit == '%') ) $sb_instagram_width_options.show();
|
915 |
|
916 |
+
jQuery('#sbi_admin #sb_instagram_width, #sbi_admin #sb_instagram_width_unit').change(function(){
|
917 |
+
sb_instagram_feed_width = jQuery('#sbi_admin #sb_instagram_width').val();
|
918 |
+
sb_instagram_width_unit = jQuery('#sbi_admin #sb_instagram_width_unit').val();
|
919 |
|
920 |
+
if( sb_instagram_feed_width.length < 2 || (sb_instagram_feed_width == '100' && sb_instagram_width_unit == '%') ) {
|
921 |
+
$sb_instagram_width_options.slideUp();
|
922 |
+
} else {
|
923 |
+
$sb_instagram_width_options.slideDown();
|
924 |
+
}
|
925 |
+
});
|
926 |
|
927 |
+
}
|
928 |
|
929 |
+
//Scroll to hash for quick links
|
930 |
jQuery('#sbi_admin a').click(function() {
|
931 |
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
|
932 |
+
var target = jQuery(this.hash);
|
933 |
+
target = target.length ? target : this.hash.slice(1);
|
934 |
+
if (target.length) {
|
935 |
+
jQuery('html,body').animate({
|
936 |
+
scrollTop: target.offset().top
|
937 |
+
}, 500);
|
938 |
+
return false;
|
939 |
+
}
|
940 |
}
|
941 |
});
|
942 |
|
943 |
+
//Support tab show video
|
944 |
+
jQuery('#sbi-play-support-video').on('click', function(e){
|
945 |
+
e.preventDefault();
|
946 |
+
jQuery('#sbi-support-video').show().attr('src', jQuery('#sbi-support-video').attr('src')+'&autoplay=1' );
|
947 |
+
});
|
948 |
|
949 |
+
jQuery('#sbi_admin .sbi-show-pro').on('click', function(){
|
950 |
+
jQuery(this).parent().next('.sbi-pro-options').toggle();
|
951 |
+
});
|
952 |
|
953 |
+
/* Pro 3.0 JS */
|
954 |
function sbiUpdateLayoutTypeOptionsDisplay() {
|
955 |
setTimeout(function(){
|
956 |
jQuery('.sb_instagram_layout_settings').hide();
|
1159 |
}
|
1160 |
}
|
1161 |
sbiCheckGdprSetting();
|
1162 |
+
|
1163 |
+
// Locator
|
1164 |
+
jQuery('.sbi-locator-more').click(function(e) {
|
1165 |
+
e.preventDefault();
|
1166 |
+
jQuery(this).closest('td').find('.sbi-full-wrap').show();
|
1167 |
+
jQuery(this).closest('td').find('.sbi-condensed-wrap').hide();
|
1168 |
+
jQuery(this).remove();
|
1169 |
+
});
|
1170 |
});
|
1171 |
|
1172 |
|
js/sbi-scripts.js
CHANGED
@@ -190,6 +190,7 @@ if(!sbi_js_exists) {
|
|
190 |
num : $self.attr('data-num'),
|
191 |
imgRes : $self.attr('data-res'),
|
192 |
feedID : $self.attr('data-feedid'),
|
|
|
193 |
shortCodeAtts : $self.attr('data-shortcode-atts'),
|
194 |
resizingEnabled : (flags.indexOf('resizeDisable') === -1),
|
195 |
imageLoadEnabled : (flags.indexOf('imageLoadDisable') === -1),
|
@@ -199,6 +200,7 @@ if(!sbi_js_exists) {
|
|
199 |
gdpr : (flags.indexOf('gdpr') > -1),
|
200 |
overrideBlockCDN : (flags.indexOf('overrideBlockCDN') > -1),
|
201 |
consentGiven : false,
|
|
|
202 |
autoMinRes : 1,
|
203 |
general : general
|
204 |
};
|
@@ -254,6 +256,7 @@ if(!sbi_js_exists) {
|
|
254 |
this.resizedImages = {};
|
255 |
this.needsResizing = [];
|
256 |
this.outOfPages = false;
|
|
|
257 |
this.isInitialized = false;
|
258 |
}
|
259 |
|
@@ -434,6 +437,8 @@ if(!sbi_js_exists) {
|
|
434 |
offset: itemOffset,
|
435 |
feed_id: feed.settings.feedID,
|
436 |
atts: feed.settings.shortCodeAtts,
|
|
|
|
|
437 |
cache_all: cacheAll
|
438 |
};
|
439 |
var onSuccess = function(data) {
|
@@ -455,6 +460,18 @@ if(!sbi_js_exists) {
|
|
455 |
}
|
456 |
};
|
457 |
sbiAjax(submitData,onSuccess);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
}
|
459 |
},
|
460 |
loadMoreButtonInit: function () {
|
@@ -470,12 +487,17 @@ if(!sbi_js_exists) {
|
|
470 |
getNewPostSet: function () {
|
471 |
var $self = $(this.el),
|
472 |
feed = this;
|
|
|
|
|
473 |
var itemOffset = $self.find('.sbi_item').length,
|
474 |
submitData = {
|
475 |
action: 'sbi_load_more_clicked',
|
476 |
offset: itemOffset,
|
|
|
477 |
feed_id: feed.settings.feedID,
|
478 |
atts: feed.settings.shortCodeAtts,
|
|
|
|
|
479 |
current_resolution: feed.imageResolution
|
480 |
};
|
481 |
var onSuccess = function (data) {
|
@@ -963,7 +985,23 @@ if(!sbi_js_exists) {
|
|
963 |
feed.afterResize();
|
964 |
},500);
|
965 |
}
|
966 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
967 |
};
|
968 |
|
969 |
window.sbi_init = function() {
|
190 |
num : $self.attr('data-num'),
|
191 |
imgRes : $self.attr('data-res'),
|
192 |
feedID : $self.attr('data-feedid'),
|
193 |
+
postID : typeof $self.attr( 'data-postid' ) !== 'undefind' ? $self.attr( 'data-postid' ) : 'unknown',
|
194 |
shortCodeAtts : $self.attr('data-shortcode-atts'),
|
195 |
resizingEnabled : (flags.indexOf('resizeDisable') === -1),
|
196 |
imageLoadEnabled : (flags.indexOf('imageLoadDisable') === -1),
|
200 |
gdpr : (flags.indexOf('gdpr') > -1),
|
201 |
overrideBlockCDN : (flags.indexOf('overrideBlockCDN') > -1),
|
202 |
consentGiven : false,
|
203 |
+
locator : (flags.indexOf('locator') > -1),
|
204 |
autoMinRes : 1,
|
205 |
general : general
|
206 |
};
|
256 |
this.resizedImages = {};
|
257 |
this.needsResizing = [];
|
258 |
this.outOfPages = false;
|
259 |
+
this.page = 1;
|
260 |
this.isInitialized = false;
|
261 |
}
|
262 |
|
437 |
offset: itemOffset,
|
438 |
feed_id: feed.settings.feedID,
|
439 |
atts: feed.settings.shortCodeAtts,
|
440 |
+
location: feed.locationGuess(),
|
441 |
+
post_id: feed.settings.postID,
|
442 |
cache_all: cacheAll
|
443 |
};
|
444 |
var onSuccess = function(data) {
|
460 |
}
|
461 |
};
|
462 |
sbiAjax(submitData,onSuccess);
|
463 |
+
} else if (feed.settings.locator) {
|
464 |
+
var submitData = {
|
465 |
+
action: 'sbi_do_locator',
|
466 |
+
feed_id: feed.settings.feedID,
|
467 |
+
atts: feed.settings.shortCodeAtts,
|
468 |
+
location: feed.locationGuess(),
|
469 |
+
post_id: feed.settings.postID
|
470 |
+
};
|
471 |
+
var onSuccess = function(data) {
|
472 |
+
|
473 |
+
};
|
474 |
+
sbiAjax(submitData,onSuccess);
|
475 |
}
|
476 |
},
|
477 |
loadMoreButtonInit: function () {
|
487 |
getNewPostSet: function () {
|
488 |
var $self = $(this.el),
|
489 |
feed = this;
|
490 |
+
feed.page ++;
|
491 |
+
|
492 |
var itemOffset = $self.find('.sbi_item').length,
|
493 |
submitData = {
|
494 |
action: 'sbi_load_more_clicked',
|
495 |
offset: itemOffset,
|
496 |
+
page: feed.page,
|
497 |
feed_id: feed.settings.feedID,
|
498 |
atts: feed.settings.shortCodeAtts,
|
499 |
+
location: feed.locationGuess(),
|
500 |
+
post_id: feed.settings.postID,
|
501 |
current_resolution: feed.imageResolution
|
502 |
};
|
503 |
var onSuccess = function (data) {
|
985 |
feed.afterResize();
|
986 |
},500);
|
987 |
}
|
988 |
+
},
|
989 |
+
locationGuess: function() {
|
990 |
+
var $feed = $(this.el),
|
991 |
+
location = 'content';
|
992 |
+
|
993 |
+
if ($feed.closest('footer').length) {
|
994 |
+
location = 'footer';
|
995 |
+
} else if ($feed.closest('.header').length
|
996 |
+
|| $feed.closest('header').length) {
|
997 |
+
location = 'header';
|
998 |
+
} else if ($feed.closest('.sidebar').length
|
999 |
+
|| $feed.closest('aside').length) {
|
1000 |
+
location = 'sidebar';
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
return location;
|
1004 |
+
},
|
1005 |
};
|
1006 |
|
1007 |
window.sbi_init = function() {
|
js/sbi-scripts.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 n(){(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(n,r.responsiveCheckTime))}function a(){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,n,a,o,g,c,f=0,u=0,b=l.width(),_=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===b/_>=h.data("owidth")/h.data("oheight")?(i="100%",s="auto",t=Math.floor(b),n=Math.floor(b*(h.data("oheight")/h.data("owidth")))):(i="auto",s="100%",t=Math.floor(_*(h.data("owidth")/h.data("oheight"))),n=Math.floor(_)),g=b-t,"left"===(a=r.horizontalAlign.toLowerCase())&&(u=0),"center"===a&&(u=.5*g),"right"===a&&(u=g),-1!==a.indexOf("%")&&((a=parseInt(a.replace("%",""),10))>0&&(u=g*a*.01)),c=_-n,"left"===(o=r.verticalAlign.toLowerCase())&&(f=0),"center"===o&&(f=.5*c),"bottom"===o&&(f=c),-1!==o.indexOf("%")&&((o=parseInt(o.replace("%",""),10))>0&&(f=c*o*.01)),r.hardPixels&&(i=t,s=n),h.css({width:i,height:s,"margin-left":Math.floor(u),"margin-top":Math.floor(f)}),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"),n=l.attr("data-sbi_imgLiquid-horizontalAlign"),a=l.attr("data-sbi_imgLiquid-verticalAlign");("true"===e||"false"===e)&&(i.fill=Boolean("true"===e)),void 0===n||"left"!==n&&"center"!==n&&"right"!==n&&-1===n.indexOf("%")||(i.horizontalAlign=n),void 0===a||"top"!==a&&"bottom"!==a&&"center"!==a&&-1===a.indexOf("%")||(i.verticalAlign=a)}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",a),h[0].onerror=a,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 n())}())):void a()})}})}(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 n(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),a=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(a.indexOf("testAjax")>-1){window.sbi.triggeredTest=!0;n({action:"sbi_on_ajax_test_trigger"},function(i){console.log("did test")})}var d={cols:s.attr("data-cols"),colsmobile:void 0!==s.attr("data-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===a.indexOf("resizeDisable"),imageLoadEnabled:-1===a.indexOf("imageLoadDisable"),debugEnabled:a.indexOf("debug")>-1,favorLocal:a.indexOf("favorLocal")>-1,ajaxPostLoad:a.indexOf("ajaxPostLoad")>-1,gdpr:a.indexOf("gdpr")>-1,overrideBlockCDN:a.indexOf("overrideBlockCDN")>-1,consentGiven:!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,">").replace(/(<)/g,"<").replace(/(<br\/>)/g,"<br>").replace(/(<br>)/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;e.settings.consentGiven=e.checkConsent(),i(this.el).find(".sbi_photo").parent("p").length&&i(this.el).addClass("sbi_no_autop"),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)}),i(this.el).find(".sbi_item").each(function(){e.lazyLoadCheck(i(this))})},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)},lazyLoadCheck:function(e){if(e.find(".sbi_photo").length&&!e.closest(".sbi").hasClass("sbi-no-ll-check")){var s=this.getImageUrls(e),t=void 0!==s[640]?s[640]:e.find(".sbi_photo").attr("data-full-res");if(!this.settings.consentGiven&&t.indexOf("scontent")>-1)return;e.find(".sbi_photo img").each(function(){t&&void 0!==i(this).attr("data-src")&&i(this).attr("data-src",t),t&&void 0!==i(this).attr("data-orig-src")&&i(this).attr("data-orig-src",t),i(this).on("load",function(){!i(this).hasClass("sbi-replaced")&&i(this).attr("src").indexOf("placeholder")>-1&&(i(this).addClass("sbi-replaced"),t&&(i(this).attr("src",t),i(this).closest(".sbi_imgLiquid_bgSize").length&&i(this).closest(".sbi_imgLiquid_bgSize").css("background-image","url("+t+")")))})})}},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,t=void 0!==e.settings.general.cache_all&&e.settings.general.cache_all;n({action:"sbi_resized_images_submit",needs_resizing:e.needsResizing,offset:s,feed_id:e.settings.feedID,atts:e.settings.shortCodeAtts,cache_all:t},function(i){if(0===i.trim().indexOf("{")){var s=JSON.parse(i);for(var t in e.settings.debugEnabled&&console.log(s),s)s.hasOwnProperty(t)&&(e.resizedImages[t]=s[t]);e.maybeRaiseImageResolution(),setTimeout(function(){e.afterResize()},500)}})}},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;n({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 n=JSON.parse(t);s.settings.debugEnabled&&console.log(n),s.appendNewPosts(n.html),s.addResizedImages(n.resizedImages),s.settings.ajaxPostLoad?(s.settings.ajaxPostLoad=!1,s.afterInitialImagesLoaded()):s.afterNewImagesLoaded(),n.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(),n=e.find("#sbi_images").innerWidth()-e.find("#sbi_images").width(),a=n/2;sbi_photo_width_manual=e.find("#sbi_images").width()/t-n,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(a)*(2-i+2),e.find(".sbi-owl-nav div").css("top",s)},100)},maybeRaiseSingleImageResolution:function(e,s,t){var n=this,a=n.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")))if(a.length<1)e.find(".sbi_link_area").length&&e.find(".sbi_link_area").attr("href",window.sbi.options.placeholder.replace("placeholder.png","thumb-placeholder.png"));else{(e.find(".sbi_link_area").length&&e.find(".sbi_link_area").attr("href")===window.sbi.options.placeholder.replace("placeholder.png","thumb-placeholder.png")||!n.settings.consentGiven)&&e.find(".sbi_link_area").attr("href",a[a.length-1]),void 0!==a[640]&&e.find(".sbi_photo").attr("data-full-res",a[640]),i.each(a,function(i,e){e===o&&(d=parseInt(i),t=!1)});var h=640;switch(n.settings.imgRes){case"thumb":h=150;break;case"medium":h=320;break;case"full":h=640;break;default:var g=Math.max(n.settings.autoMinRes,e.find(".sbi_photo").innerWidth()),c=n.getBestResolutionForAuto(g,l,e);switch(c){case 320:h=320;break;case 150:h=150}}if(h>d||o===window.sbi.options.placeholder||t){if(n.settings.debugEnabled){var f=o===window.sbi.options.placeholder?"was placeholder":"too small";console.log("rais res for "+o,f)}var u=a[h].split("?ig_cache_key")[0];if(o!==u&&(e.find(".sbi_photo img").attr("src",u),e.find(".sbi_photo").css("background-image",'url("'+u+'")')),d=h,"auto"===n.settings.imgRes){var b=!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&&!b){switch(n.settings.debugEnabled&&console.log("rais res again for aspect ratio change "+o),b=!0,g=e.find(".sbi_photo").innerWidth(),c=n.getBestResolutionForAuto(g,t,e),h=640,c){case 320:h=320;break;case 150:h=150}h>d&&(u=a[h].split("?ig_cache_key")[0],s.attr("src",u),s.closest(".sbi_photo").css("background-image",'url("'+u+'")')),"masonry"!==n.layout&&"highlight"!==n.layout||(i(n.el).find("#sbi_images").smashotope(n.isotopeArgs),setTimeout(function(){i(n.el).find("#sbi_images").smashotope(n.isotopeArgs)},500))}else if(n.settings.debugEnabled){var r=b?"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)&&n.settings.consentGiven){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"))}else n.settings.favorLocal=!0,void 0!==(e=n.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"));setTimeout(function(){n.afterResize()},1500)}})}},maybeRaiseImageResolution:function(e){var s=this,t=void 0!==e&&!0===e?".sbi_item.sbi_new":".sbi_item",n=!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,n)}),s.isInitialized=!0},getBestResolutionForAuto:function(e,s,t){(isNaN(s)||s<1)&&(s=1);var n=e*s,a=10*Math.ceil(n/10),o=[150,320,640];if(t.hasClass("sbi_highlighted")&&(a*=2),-1===o.indexOf(parseInt(a))){var d=!1;i.each(o,function(i,e){e>parseInt(a)&&!d&&(a=e,d=!0)})}return a},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,n=this.getColumnCount(),a=(s-t*(n+2))/n;a>120&&a<240?e.addClass("sbi_medium"):a<=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(this.settings.consentGiven||this.settings.overrideBlockCDN||(e=[]),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,n=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,n=i.is(":visible");e.sbiPreviousVisibility=n,null==s?e.runOnLoad&&e.callback(i,n):s!==n&&e.callback(i,n),setTimeout(function(){t.sbiCheckVisibility(i,e)},e.frequency)}}},e.fn.sbiVisibilityChanged=function(i){var n=e.extend({},s,i);return this.each(function(){t.sbiCheckVisibility(e(this),n)})},"function"==typeof i(this.el).filter(":hidden").sbiVisibilityChanged&&i(this.el).filter(":hidden").sbiVisibilityChanged({callback:function(i,e){n.afterResize()},runOnLoad:!1})},getColumnCount:function(){var e=i(this.el),s=this.settings.cols,t=this.settings.colsmobile,n=s;return sbiWindowWidth=window.innerWidth,e.hasClass("sbi_mob_col_auto")?(sbiWindowWidth<640&&parseInt(s)>2&&parseInt(s)<7&&(n=2),sbiWindowWidth<640&&parseInt(s)>6&&parseInt(s)<11&&(n=4),sbiWindowWidth<=480&&parseInt(s)>2&&(n=1)):sbiWindowWidth<=480&&(n=t),parseInt(n)},checkConsent:function(){if(this.settings.consentGiven||!this.settings.gdpr)return!0;if("undefined"!=typeof CLI_Cookie)null!==CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)&&(this.settings.consentGiven="yes"===CLI_Cookie.read("cookielawinfo-checkbox-non-necessary"));else if(void 0!==window.cnArgs){var i=("; "+document.cookie).split("; cookie_notice_accepted=");if(2===i.length){var e=i.pop().split(";").shift();this.settings.consentGiven="true"===e}}else void 0!==window.cookieconsent?this.settings.consentGiven="allow"===function(i){for(var e=i+"=",s=window.document.cookie.split(";"),t=0;t<s.length;t++){var n=s[t].trim();if(0==n.indexOf(e))return n.substring(e.length,n.length)}return""}("complianz_consent_status"):void 0!==window.Cookiebot?this.settings.consentGiven=Cookiebot.consented:void 0!==window.BorlabsCookie&&(this.settings.consentGiven=window.BorlabsCookie.checkCookieConsent("instagram"));var s=jQuery.Event("sbicheckconsent");return s.feed=this,jQuery(window).trigger(s),this.settings.consentGiven},afterConsentToggled:function(){if(this.checkConsent()){var i=this;i.maybeRaiseImageResolution(),setTimeout(function(){i.afterResize()},500)}}},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("https:","http:"):window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("http:","https:")),sbi_init(),i("#cookie-notice a").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i("#cookie-law-info-bar a").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i(".cli-user-preference-checkbox").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i(window).on("CookiebotOnAccept",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!0,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("cmplzAcceptAll",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!0,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("cmplzRevoke",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("borlabs-cookie-consent-saved",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})})}));
|
1 |
+
var sbi_js_exists=void 0!==sbi_js_exists;sbi_js_exists||(!function(i){function e(){var i,e,t,s=s||{VER:"0.9.944"};s.bgs_Available=!1,s.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(!s.bgs_CheckRunned){s.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 t=window.getComputedStyle(i,null);t&&t.backgroundSize&&(s.bgs_Available="cover"===t.backgroundSize)}}(),e.remove()}}();var t=this;return this.options=e,this.settings=i.extend({},this.defaults,this.options),this.settings.onStart&&this.settings.onStart(),this.each(function(e){function n(){(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(n,r.responsiveCheckTime))}function a(){h.data("sbi_imgLiquid_error",!0),l.addClass("sbi_imgLiquid_error"),r.onItemError&&r.onItemError(e,l,h),d()}function o(){var i,t,s,n,a,o,g,c,f=0,u=0,b=l.width(),_=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===b/_>=h.data("owidth")/h.data("oheight")?(i="100%",t="auto",s=Math.floor(b),n=Math.floor(b*(h.data("oheight")/h.data("owidth")))):(i="auto",t="100%",s=Math.floor(_*(h.data("owidth")/h.data("oheight"))),n=Math.floor(_)),g=b-s,"left"===(a=r.horizontalAlign.toLowerCase())&&(u=0),"center"===a&&(u=.5*g),"right"===a&&(u=g),-1!==a.indexOf("%")&&((a=parseInt(a.replace("%",""),10))>0&&(u=g*a*.01)),c=_-n,"left"===(o=r.verticalAlign.toLowerCase())&&(f=0),"center"===o&&(f=.5*c),"bottom"===o&&(f=c),-1!==o.indexOf("%")&&((o=parseInt(o.replace("%",""),10))>0&&(f=c*o*.01)),r.hardPixels&&(i=s,t=n),h.css({width:i,height:t,"margin-left":Math.floor(u),"margin-top":Math.floor(f)}),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===t.length-1&&t.settings.onFinish&&t.settings.onFinish()}var r=t.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"),t.options)):r=i.extend({},t.settings,function(){var i={};if(t.settings.useDataHtmlAttr){var e=l.attr("data-sbi_imgLiquid-fill"),n=l.attr("data-sbi_imgLiquid-horizontalAlign"),a=l.attr("data-sbi_imgLiquid-verticalAlign");("true"===e||"false"===e)&&(i.fill=Boolean("true"===e)),void 0===n||"left"!==n&&"center"!==n&&"right"!==n&&-1===n.indexOf("%")||(i.horizontalAlign=n),void 0===a||"top"!==a&&"bottom"!==a&&"center"!==a&&-1===a.indexOf("%")||(i.verticalAlign=a)}return s.isIE&&t.settings.ieFadeInDisabled&&(i.fadeInTime=0),i}()),h.data("sbi_imgLiquid_settings",r),r.onItemStart&&r.onItemStart(e,l,h),void(s.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 t(){if(h.data("oldSrc")&&h.data("oldSrc")!==h.attr("src")){var s=h.clone().removeAttr("style");return s.data("sbi_imgLiquid_settings",h.data("sbi_imgLiquid_settings")),h.parent().prepend(s),h.remove(),(h=s)[0].width=0,void setTimeout(t,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",a),h[0].onerror=a,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 n())}())):void a()})}})}(jQuery),i=s.injectCss,e=document.getElementsByTagName("head")[0],(t=document.createElement("style")).type="text/css",t.styleSheet?t.styleSheet.cssText=i:t.appendChild(document.createTextNode(i)),e.appendChild(t)}function t(){this.feeds={},this.options=sb_instagram_js_options}function s(i,e,t){this.el=i,this.index=e,this.settings=t,this.minImageWidth=0,this.imageResolution=150,this.resizedImages={},this.needsResizing=[],this.outOfPages=!1,this.page=1,this.isInitialized=!1}function n(e,t){i.ajax({url:sbiajaxurl,type:"post",data:e,success:t})}t.prototype={createPage:function(e,t){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(t)},createFeeds:function(e){e.whenFeedsCreated(i(".sbi").each(function(e){i(this).attr("data-sbi-index",e+1);var t=i(this),a=void 0!==t.attr("data-sbi-flags")?t.attr("data-sbi-flags").split(","):[],o=void 0!==t.attr("data-options")?JSON.parse(t.attr("data-options")):{};if(a.indexOf("testAjax")>-1){window.sbi.triggeredTest=!0;n({action:"sbi_on_ajax_test_trigger"},function(i){console.log("did test")})}var d={cols:t.attr("data-cols"),colsmobile:void 0!==t.attr("data-colsmobile")&&"same"!==t.attr("data-colsmobile")?t.attr("data-colsmobile"):t.attr("data-cols"),num:t.attr("data-num"),imgRes:t.attr("data-res"),feedID:t.attr("data-feedid"),postID:"undefind"!=typeof t.attr("data-postid")?t.attr("data-postid"):"unknown",shortCodeAtts:t.attr("data-shortcode-atts"),resizingEnabled:-1===a.indexOf("resizeDisable"),imageLoadEnabled:-1===a.indexOf("imageLoadDisable"),debugEnabled:a.indexOf("debug")>-1,favorLocal:a.indexOf("favorLocal")>-1,ajaxPostLoad:a.indexOf("ajaxPostLoad")>-1,gdpr:a.indexOf("gdpr")>-1,overrideBlockCDN:a.indexOf("overrideBlockCDN")>-1,consentGiven:!1,locator:a.indexOf("locator")>-1,autoMinRes:1,general:o};window.sbi.feeds[e]=function(i,e,t){return new s(i,e,t)}(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,">").replace(/(<)/g,"<").replace(/(<br\/>)/g,"<br>").replace(/(<br>)/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)}},s.prototype={init:function(){var e=this;e.settings.consentGiven=e.checkConsent(),i(this.el).find(".sbi_photo").parent("p").length&&i(this.el).addClass("sbi_no_autop"),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 t,s=(t=0,function(i,e){clearTimeout(t),t=setTimeout(i,e)});jQuery(window).resize(function(){s(function(){e.afterResize()},500)}),i(this.el).find(".sbi_item").each(function(){e.lazyLoadCheck(i(this))})},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),t=this;this.beforeNewImagesRevealed(),this.revealNewImages(),this.afterNewImagesRevealed(),setTimeout(function(){e.find(".sbi_loader").addClass("sbi_hidden"),e.find(".sbi_btn_text").removeClass("sbi_hidden"),t.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)},lazyLoadCheck:function(e){if(e.find(".sbi_photo").length&&!e.closest(".sbi").hasClass("sbi-no-ll-check")){var t=this.getImageUrls(e),s=void 0!==t[640]?t[640]:e.find(".sbi_photo").attr("data-full-res");if(!this.settings.consentGiven&&s.indexOf("scontent")>-1)return;e.find(".sbi_photo img").each(function(){s&&void 0!==i(this).attr("data-src")&&i(this).attr("data-src",s),s&&void 0!==i(this).attr("data-orig-src")&&i(this).attr("data-orig-src",s),i(this).on("load",function(){!i(this).hasClass("sbi-replaced")&&i(this).attr("src").indexOf("placeholder")>-1&&(i(this).addClass("sbi-replaced"),s&&(i(this).attr("src",s),i(this).closest(".sbi_imgLiquid_bgSize").length&&i(this).closest(".sbi_imgLiquid_bgSize").css("background-image","url("+s+")")))})})}},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 t=i(this.el).find(".sbi_item").length,s=void 0!==e.settings.general.cache_all&&e.settings.general.cache_all;n({action:"sbi_resized_images_submit",needs_resizing:e.needsResizing,offset:t,feed_id:e.settings.feedID,atts:e.settings.shortCodeAtts,location:e.locationGuess(),post_id:e.settings.postID,cache_all:s},function(i){if(0===i.trim().indexOf("{")){var t=JSON.parse(i);for(var s in e.settings.debugEnabled&&console.log(t),t)t.hasOwnProperty(s)&&(e.resizedImages[s]=t[s]);e.maybeRaiseImageResolution(),setTimeout(function(){e.afterResize()},500)}})}else if(e.settings.locator){n({action:"sbi_do_locator",feed_id:e.settings.feedID,atts:e.settings.shortCodeAtts,location:e.locationGuess(),post_id:e.settings.postID},function(i){})}},loadMoreButtonInit:function(){var e=i(this.el),t=this;e.find("#sbi_load .sbi_load_btn").off().on("click",function(){t.afterLoadMoreClicked(jQuery(this)),t.getNewPostSet()})},getNewPostSet:function(){var e=i(this.el),t=this;t.page++;n({action:"sbi_load_more_clicked",offset:e.find(".sbi_item").length,page:t.page,feed_id:t.settings.feedID,atts:t.settings.shortCodeAtts,location:t.locationGuess(),post_id:t.settings.postID,current_resolution:t.imageResolution},function(s){if(0===s.trim().indexOf("{")){var n=JSON.parse(s);t.settings.debugEnabled&&console.log(n),t.appendNewPosts(n.html),t.addResizedImages(n.resizedImages),t.settings.ajaxPostLoad?(t.settings.ajaxPostLoad=!1,t.afterInitialImagesLoaded()):t.afterNewImagesLoaded(),n.feedStatus.shouldPaginate?t.outOfPages=!1:(t.outOfPages=!0,e.find(".sbi_load_btn").hide()),i(".sbi_no_js").removeClass("sbi_no_js")}})},appendNewPosts:function(e){var t=i(this.el);t.find("#sbi_images .sbi_item").length?t.find("#sbi_images .sbi_item").last().after(e):t.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),t=e.find(".sbi_photo").eq(0).innerWidth(),s=this.getColumnCount(),n=e.find("#sbi_images").innerWidth()-e.find("#sbi_images").width(),a=n/2;sbi_photo_width_manual=e.find("#sbi_images").width()/s-n,e.find(".sbi_photo").css("height",t),e.find(".sbi-owl-nav").length&&setTimeout(function(){var i=2;e.find(".sbi_owl2row-item").length&&(i=1);var t=e.find(".sbi_photo").eq(0).innerWidth()/i;t+=parseInt(a)*(2-i+2),e.find(".sbi-owl-nav div").css("top",t)},100)},maybeRaiseSingleImageResolution:function(e,t,s){var n=this,a=n.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;s=void 0!==s&&s;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")))if(a.length<1)e.find(".sbi_link_area").length&&e.find(".sbi_link_area").attr("href",window.sbi.options.placeholder.replace("placeholder.png","thumb-placeholder.png"));else{(e.find(".sbi_link_area").length&&e.find(".sbi_link_area").attr("href")===window.sbi.options.placeholder.replace("placeholder.png","thumb-placeholder.png")||!n.settings.consentGiven)&&e.find(".sbi_link_area").attr("href",a[a.length-1]),void 0!==a[640]&&e.find(".sbi_photo").attr("data-full-res",a[640]),i.each(a,function(i,e){e===o&&(d=parseInt(i),s=!1)});var h=640;switch(n.settings.imgRes){case"thumb":h=150;break;case"medium":h=320;break;case"full":h=640;break;default:var g=Math.max(n.settings.autoMinRes,e.find(".sbi_photo").innerWidth()),c=n.getBestResolutionForAuto(g,l,e);switch(c){case 320:h=320;break;case 150:h=150}}if(h>d||o===window.sbi.options.placeholder||s){if(n.settings.debugEnabled){var f=o===window.sbi.options.placeholder?"was placeholder":"too small";console.log("rais res for "+o,f)}var u=a[h].split("?ig_cache_key")[0];if(o!==u&&(e.find(".sbi_photo img").attr("src",u),e.find(".sbi_photo").css("background-image",'url("'+u+'")')),d=h,"auto"===n.settings.imgRes){var b=!1;e.find(".sbi_photo img").on("load",function(){var t=i(this),s=t.get(0).naturalWidth/t.get(0).naturalHeight;if(1e3!==t.get(0).naturalWidth&&s>l&&!b){switch(n.settings.debugEnabled&&console.log("rais res again for aspect ratio change "+o),b=!0,g=e.find(".sbi_photo").innerWidth(),c=n.getBestResolutionForAuto(g,s,e),h=640,c){case 320:h=320;break;case 150:h=150}h>d&&(u=a[h].split("?ig_cache_key")[0],t.attr("src",u),t.closest(".sbi_photo").css("background-image",'url("'+u+'")')),"masonry"!==n.layout&&"highlight"!==n.layout||(i(n.el).find("#sbi_images").smashotope(n.isotopeArgs),setTimeout(function(){i(n.el).find("#sbi_images").smashotope(n.isotopeArgs)},500))}else if(n.settings.debugEnabled){var r=b?"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)&&n.settings.consentGiven){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"))}else n.settings.favorLocal=!0,void 0!==(e=n.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"));setTimeout(function(){n.afterResize()},1500)}})}},maybeRaiseImageResolution:function(e){var t=this,s=void 0!==e&&!0===e?".sbi_item.sbi_new":".sbi_item",n=!t.isInitialized;i(t.el).find(s).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")&&t.maybeRaiseSingleImageResolution(i(this),e,n)}),t.isInitialized=!0},getBestResolutionForAuto:function(e,t,s){(isNaN(t)||t<1)&&(t=1);var n=e*t,a=10*Math.ceil(n/10),o=[150,320,640];if(s.hasClass("sbi_highlighted")&&(a*=2),-1===o.indexOf(parseInt(a))){var d=!1;i.each(o,function(i,e){e>parseInt(a)&&!d&&(a=e,d=!0)})}return a},hideExtraImagesForWidth:function(){if("carousel"!==this.layout){var e=i(this.el),t=void 0!==e.attr("data-num")&&""!==e.attr("data-num")?parseInt(e.attr("data-num")):1,s=void 0!==e.attr("data-nummobile")&&""!==e.attr("data-nummobile")?parseInt(e.attr("data-nummobile")):t;i(window).width()<480?s<e.find(".sbi_item").length&&e.find(".sbi_item").slice(s-e.find(".sbi_item").length).addClass("sbi_num_diff_hide"):t<e.find(".sbi_item").length&&e.find(".sbi_item").slice(t-e.find(".sbi_item").length).addClass("sbi_num_diff_hide")}},setImageSizeClass:function(){var e=i(this.el);e.removeClass("sbi_small sbi_medium");var t=e.innerWidth(),s=parseInt(e.find("#sbi_images").outerWidth()-e.find("#sbi_images").width())/2,n=this.getColumnCount(),a=(t-s*(n+2))/n;a>120&&a<240?e.addClass("sbi_medium"):a<=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,"/")),t=i.attr("id").replace("sbi_","");if(this.settings.consentGiven||this.settings.overrideBlockCDN||(e=[]),void 0!==this.resizedImages[t]&&"video"!==this.resizedImages[t]&&"pending"!==this.resizedImages[t]&&"error"!==this.resizedImages[t].id&&"video"!==this.resizedImages[t].id&&"pending"!==this.resizedImages[t].id){if(void 0!==this.resizedImages[t].sizes){var s=[];void 0!==this.resizedImages[t].sizes.full&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"full.jpg",s.push(640)),void 0!==this.resizedImages[t].sizes.low&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"low.jpg",s.push(320)),void 0!==this.resizedImages[t].sizes.thumb&&(s.push(150),e[150]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"thumb.jpg"),this.settings.favorLocal&&(-1===s.indexOf(640)&&s.indexOf(320)>-1&&(e[640]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"low.jpg"),-1===s.indexOf(320)&&(s.indexOf(640)>-1?e[320]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"full.jpg":s.indexOf(150)>-1&&(e[320]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"thumb.jpg")),-1===s.indexOf(150)&&(s.indexOf(320)>-1?e[150]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"low.jpg":s.indexOf(640)>-1&&(e[150]=sb_instagram_js_options.resized_url+this.resizedImages[t].id+"full.jpg")))}}else(void 0===this.resizedImages[t]||void 0!==this.resizedImages[t].id&&"pending"!==this.resizedImages[t].id&&"error"!==this.resizedImages[t].id)&&this.addToNeedsResizing(t);return e},getAvatarUrl:function(i,e){if(""===i)return"";var t=this.settings.general.avatars;return"local"===(e=void 0!==e?e:"local")?void 0!==t["LCL"+i]&&1===parseInt(t["LCL"+i])?sb_instagram_js_options.resized_url+i+".jpg":void 0!==t[i]?t[i]:"":void 0!==t[i]?t[i]:void 0!==t["LCL"+i]&&1===parseInt(t["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 t=i(this.el);e(),"function"==typeof t.find(".sbi_photo").sbi_imgLiquid&&t.find(".sbi_photo").sbi_imgLiquid({fill:!0})},listenForVisibilityChange:function(){var e,t,s,n=this;e=jQuery,t={callback:function(){},runOnLoad:!0,frequency:100,sbiPreviousVisibility:null},s={sbiCheckVisibility:function(i,e){if(jQuery.contains(document,i[0])){var t=e.sbiPreviousVisibility,n=i.is(":visible");e.sbiPreviousVisibility=n,null==t?e.runOnLoad&&e.callback(i,n):t!==n&&e.callback(i,n),setTimeout(function(){s.sbiCheckVisibility(i,e)},e.frequency)}}},e.fn.sbiVisibilityChanged=function(i){var n=e.extend({},t,i);return this.each(function(){s.sbiCheckVisibility(e(this),n)})},"function"==typeof i(this.el).filter(":hidden").sbiVisibilityChanged&&i(this.el).filter(":hidden").sbiVisibilityChanged({callback:function(i,e){n.afterResize()},runOnLoad:!1})},getColumnCount:function(){var e=i(this.el),t=this.settings.cols,s=this.settings.colsmobile,n=t;return sbiWindowWidth=window.innerWidth,e.hasClass("sbi_mob_col_auto")?(sbiWindowWidth<640&&parseInt(t)>2&&parseInt(t)<7&&(n=2),sbiWindowWidth<640&&parseInt(t)>6&&parseInt(t)<11&&(n=4),sbiWindowWidth<=480&&parseInt(t)>2&&(n=1)):sbiWindowWidth<=480&&(n=s),parseInt(n)},checkConsent:function(){if(this.settings.consentGiven||!this.settings.gdpr)return!0;if("undefined"!=typeof CLI_Cookie)null!==CLI_Cookie.read(CLI_ACCEPT_COOKIE_NAME)&&(this.settings.consentGiven="yes"===CLI_Cookie.read("cookielawinfo-checkbox-non-necessary"));else if(void 0!==window.cnArgs){var i=("; "+document.cookie).split("; cookie_notice_accepted=");if(2===i.length){var e=i.pop().split(";").shift();this.settings.consentGiven="true"===e}}else void 0!==window.cookieconsent?this.settings.consentGiven="allow"===function(i){for(var e=i+"=",t=window.document.cookie.split(";"),s=0;s<t.length;s++){var n=t[s].trim();if(0==n.indexOf(e))return n.substring(e.length,n.length)}return""}("complianz_consent_status"):void 0!==window.Cookiebot?this.settings.consentGiven=Cookiebot.consented:void 0!==window.BorlabsCookie&&(this.settings.consentGiven=window.BorlabsCookie.checkCookieConsent("instagram"));var t=jQuery.Event("sbicheckconsent");return t.feed=this,jQuery(window).trigger(t),this.settings.consentGiven},afterConsentToggled:function(){if(this.checkConsent()){var i=this;i.maybeRaiseImageResolution(),setTimeout(function(){i.afterResize()},500)}},locationGuess:function(){var e=i(this.el),t="content";return e.closest("footer").length?t="footer":e.closest(".header").length||e.closest("header").length?t="header":(e.closest(".sidebar").length||e.closest("aside").length)&&(t="sidebar"),t}},window.sbi_init=function(){window.sbi=new t,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("https:","http:"):window.sb_instagram_js_options.resized_url=window.sb_instagram_js_options.resized_url.replace("http:","https:")),sbi_init(),i("#cookie-notice a").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i("#cookie-law-info-bar a").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i(".cli-user-preference-checkbox").click(function(){setTimeout(function(){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})},1e3)}),i(window).on("CookiebotOnAccept",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!0,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("cmplzAcceptAll",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!0,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("cmplzRevoke",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})}),i(document).on("borlabs-cookie-consent-saved",function(e){i.each(window.sbi.feeds,function(i){window.sbi.feeds[i].settings.consentGiven=!1,window.sbi.feeds[i].afterConsentToggled()})})}));
|