BlossomThemes Social Feed - Version 2.0.0

Version Description

Released on: 17th March, 2020

Important:

  • BlossomThemes Social Feed discontinued with Instagram's old API and henceforth will be using the new Instagram Basic Display API. This will disrupt feeds created from personal connected accounts. You will need to reconnect the account on the BlossomThemes Social Feed Settings page. For help, please refer to this tutorial.

Features:

  • Support added for the new Instagram Basic Display API.

Fixes:

  • Minor bug fixes.
Download this release

Release Info

Developer blossomthemes
Plugin Icon 128x128 BlossomThemes Social Feed
Version 2.0.0
Comparing to
See all releases

Code changes from version 1.2.0 to 2.0.0

README.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: blossomthemes
3
  Donate link: https://blossomthemes.com
4
  Tags: instagram, popup, responsive, insta widget
5
  Requires at least: 4.3
6
- Tested up to: 5.3
7
  Requires PHP: 5.6
8
- Stable tag: 1.2.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -15,7 +15,7 @@ Show instagram feed on your website using shortcode and widget.
15
 
16
  BlossomThemes Social Feed plugin allows you to show your Instagram profile on your website. The plugin works best with BlossomThemes’ themes.
17
 
18
- You can display up to 20 photos with maximum 5 photos in each row.
19
 
20
  The plugin generates shortcode and widget. So, you can show your Instagram feed either inside your posts and/or on the sidebars.
21
 
@@ -25,7 +25,7 @@ The plugin is very easy to use.
25
 
26
  Once activated, a menu named “BlossomThemes Social Feed” will be created on the WordPress dashboard.
27
 
28
- Go to BlossomThemes Social Feed. Then, on the General tab, click Connect with Instagram, copy and enter the Access Token, enter your Instagram username, select number of photos to display (max. 20), select number of photos per row (max. 5 photos per row), select whether to enable or disable comments and likes and then click on “Save Changes”.
29
 
30
  Then, go to Usage tab, copy the shortcode and use it on your posts. As easy as that!
31
 
@@ -35,9 +35,9 @@ The plugin will create a widget called “BlossomThemes: Instagram”. So, go to
35
 
36
  If you do not enter the Instagram username in the widget, the username assigned on the main plugin page (on BlossomThemes Social Feed) will be used.
37
 
38
- = Video Link =
39
 
40
- [How to authorize Instagram account for BlossomThemes Social Feed Plugin?](https://www.youtube.com/watch?v=U4tkwdtgkt0)
41
 
42
  == Installation ==
43
  **From your WordPress dashboard**
@@ -66,6 +66,22 @@ If you do not enter the Instagram username in the widget, the username assigned
66
 
67
  == Changelog ==
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  = 1.2.0 =
70
 
71
  Released on: 18th November, 2019
3
  Donate link: https://blossomthemes.com
4
  Tags: instagram, popup, responsive, insta widget
5
  Requires at least: 4.3
6
+ Tested up to: 5.5
7
  Requires PHP: 5.6
8
+ Stable tag: 2.0.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
15
 
16
  BlossomThemes Social Feed plugin allows you to show your Instagram profile on your website. The plugin works best with BlossomThemes’ themes.
17
 
18
+ You can display up to 25 photos with maximum 10 photos in each row.
19
 
20
  The plugin generates shortcode and widget. So, you can show your Instagram feed either inside your posts and/or on the sidebars.
21
 
25
 
26
  Once activated, a menu named “BlossomThemes Social Feed” will be created on the WordPress dashboard.
27
 
28
+ Go to BlossomThemes Social Feed. Then, on the General tab, click Connect with Instagram, the Access Token, and your Instagram username gets captured automatically once you authorize the plugin to access your photos. Select number of photos to display (max. 25), select number of photos per row (max. 10 photos per row), and then click on “Save Changes”.
29
 
30
  Then, go to Usage tab, copy the shortcode and use it on your posts. As easy as that!
31
 
35
 
36
  If you do not enter the Instagram username in the widget, the username assigned on the main plugin page (on BlossomThemes Social Feed) will be used.
37
 
38
+ = Tutorial Link =
39
 
40
+ [How to authorize Instagram account for BlossomThemes Social Feed Plugin?](https://blossomthemes.com/authenticate-instagram-account/)
41
 
42
  == Installation ==
43
  **From your WordPress dashboard**
66
 
67
  == Changelog ==
68
 
69
+ = 2.0.0 =
70
+
71
+ Released on: 17th March, 2020
72
+
73
+ Important:
74
+
75
+ * BlossomThemes Social Feed discontinued with Instagram's old API and henceforth will be using the new Instagram Basic Display API. This will disrupt feeds created from personal connected accounts. You will need to reconnect the account on the BlossomThemes Social Feed Settings page. For help, please refer to [this](https://blossomthemes.com/authenticate-instagram-account/) tutorial.
76
+
77
+ Features:
78
+
79
+ * Support added for the new Instagram Basic Display API.
80
+
81
+ Fixes:
82
+
83
+ * Minor bug fixes.
84
+
85
  = 1.2.0 =
86
 
87
  Released on: 18th November, 2019
admin/class-blossomthemes-instagram-feed-admin.php CHANGED
@@ -131,19 +131,19 @@ class Blossomthemes_Instagram_Feed_Admin {
131
  * @since 1.0.0
132
  */
133
  function blossomthemes_instagram_feed_callback_function() {
134
- $blossom_themes_settings = new BlossomThemes_Instagram_Feed_Settings();
135
- $blossom_themes_settings->blossomthemes_instagram_feed_backend_settings();
136
  }
137
 
138
- public function sanitize( $input ) {
139
  $result = array();
140
 
141
  // Delete user feed cache.
142
  delete_option( 'blossomthemes_instagram_user_feed' );
143
 
144
- $result['access-token'] = sanitize_text_field( $input['access-token'] );
145
 
146
- $validation_result = Blossomthemes_Instagram_Feed_API::is_access_token_valid( $result['access-token'] );
147
 
148
  if ( $validation_result !== true ) {
149
  $access_token_error_message = __( 'Access Token rejected by Instagram API. Please add valid Access Token.', 'blossomthemes-instagram-feed' );
@@ -161,12 +161,12 @@ class Blossomthemes_Instagram_Feed_Admin {
161
  );
162
  }
163
 
164
- $input['access-token'] = '';
165
  }
166
 
167
  Blossomthemes_Instagram_Feed_API::reset_cache();
168
 
169
- return $input;
170
  }
171
 
172
  function blossomthemes_instagram_feed_admin_notice(){
@@ -209,7 +209,7 @@ class Blossomthemes_Instagram_Feed_Admin {
209
  $user_id = $current_user->ID;
210
 
211
  /* If user clicks to ignore the notice, add that to their user meta */
212
- if ( isset( $_GET['btif-dismiss'] ) && check_admin_referer( 'confirm=0' ) || ( Blossomthemes_Instagram_Feed_API::getInstance()->is_configured() ) ) {
213
 
214
  update_user_meta($user_id, 'blossomthemes_instagram_admin_notice', 1);
215
  }
131
  * @since 1.0.0
132
  */
133
  function blossomthemes_instagram_feed_callback_function() {
134
+ $settings = BlossomThemes_Instagram_Feed_Settings::get_instance();
135
+ $settings->render_backend_settings();
136
  }
137
 
138
+ public function sanitize( $settings ) {
139
  $result = array();
140
 
141
  // Delete user feed cache.
142
  delete_option( 'blossomthemes_instagram_user_feed' );
143
 
144
+ $result['access_token'] = sanitize_text_field( $settings['access_token'] );
145
 
146
+ $validation_result = Blossomthemes_Instagram_Feed_API::is_access_token_valid( $result['access_token'] );
147
 
148
  if ( $validation_result !== true ) {
149
  $access_token_error_message = __( 'Access Token rejected by Instagram API. Please add valid Access Token.', 'blossomthemes-instagram-feed' );
161
  );
162
  }
163
 
164
+ $settings['access_token'] = '';
165
  }
166
 
167
  Blossomthemes_Instagram_Feed_API::reset_cache();
168
 
169
+ return $settings;
170
  }
171
 
172
  function blossomthemes_instagram_feed_admin_notice(){
209
  $user_id = $current_user->ID;
210
 
211
  /* If user clicks to ignore the notice, add that to their user meta */
212
+ if ( isset( $_GET['btif-dismiss'] ) && check_admin_referer( 'confirm=0' ) || ( Blossomthemes_Instagram_Feed_API::get_instance()->is_configured() ) ) {
213
 
214
  update_user_meta($user_id, 'blossomthemes_instagram_admin_notice', 1);
215
  }
admin/partials/blossomthemes-instagram-feed-admin-display.php CHANGED
@@ -14,3 +14,50 @@
14
  ?>
15
 
16
  <!-- This file should primarily consist of HTML with a little bit of PHP. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  ?>
15
 
16
  <!-- This file should primarily consist of HTML with a little bit of PHP. -->
17
+ <p>
18
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
19
+ <?php esc_html_e( 'Title', 'blossomthemes-instagram-feed' ); ?>
20
+ </label>
21
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
22
+ name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text"
23
+ value="<?php echo esc_attr( $title ); ?>" />
24
+ </p>
25
+
26
+ <p>
27
+ <label for="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>">
28
+ <?php esc_html_e( 'Username', 'blossomthemes-instagram-feed' ); ?>
29
+ </label>
30
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>"
31
+ name="<?php echo esc_attr( $this->get_field_name( 'username' ) ); ?>" type="text"
32
+ value="<?php echo esc_attr( $username ); ?>" />
33
+ </p>
34
+
35
+ <p>
36
+ <label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>">
37
+ <?php esc_html_e( 'Number of photos', 'blossomthemes-instagram-feed' ); ?>
38
+ </label>
39
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"
40
+ name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="number"
41
+ min="1" step="1" max="25"
42
+ value="<?php echo esc_attr( $limit ); ?>" />
43
+ </p>
44
+
45
+ <p>
46
+ <label for="<?php echo esc_attr( $this->get_field_id( 'per_row' ) ); ?>">
47
+ <?php esc_html_e( 'Photos Per Row', 'blossomthemes-instagram-feed' ); ?>
48
+ </label>
49
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'per_row' ) ); ?>"
50
+ name="<?php echo esc_attr( $this->get_field_name( 'per_row' ) ); ?>" type="number"
51
+ min="1" max="5" step="1"
52
+ value="<?php echo esc_attr( $per_row ); ?>" />
53
+ </p>
54
+
55
+ <p>
56
+ <label for="<?php echo esc_attr( $this->get_field_id( 'profile_link_text' ) ); ?>">
57
+ <?php esc_html_e( 'Profile Link Text', 'blossomthemes-instagram-feed' ); ?>
58
+ </label>
59
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'profile_link_text' ) ); ?>"
60
+ name="<?php echo esc_attr( $this->get_field_name( 'profile_link_text' ) ); ?>" type="text"
61
+ value="<?php echo esc_attr( $profile_link_text ); ?>" />
62
+ </p>
63
+ <?php
blossomthemes-instagram-feed.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: BlossomThemes Social Feed
16
  * Plugin URI: https://wordpress.org/plugins/blossomthemes-instagram-feed
17
  * Description: Show instagram feed on your website using shortcode and widget.
18
- * Version: 1.2.0
19
  * Author: blossomthemes
20
  * Author URI: https://blossomthemes.com
21
  * License: GPL-2.0+
@@ -32,16 +32,11 @@ if ( ! defined( 'WPINC' ) ) {
32
  define( 'BTIF_BASE_PATH', dirname( __FILE__ ) );
33
  define( 'BTIF_FILE_PATH', __FILE__ );
34
  define( 'BTIF_FILE_URL', rtrim( plugin_dir_url( __FILE__ ), '/' ) );
35
- define( 'BTIF_PLUGIN_VERSION', '1.2.0' );
36
 
37
  // Instagram API image limit.
38
  if ( ! defined( 'BTIF_INSTAGRAM_API_IMAGE_LIMIT' ) ) {
39
- define( 'BTIF_INSTAGRAM_API_IMAGE_LIMIT', 30 );
40
- }
41
-
42
- // Instagram media access URL.
43
- if ( ! defined ( 'BTIF_INSTAGRAM_API_MEDIA_ACCESS_URL' ) ) {
44
- define( 'BTIF_INSTAGRAM_API_MEDIA_ACCESS_URL', 'https://api.instagram.com/v1/users/self/media/recent/?access_token=%s&count=%s' );
45
  }
46
 
47
  /**
15
  * Plugin Name: BlossomThemes Social Feed
16
  * Plugin URI: https://wordpress.org/plugins/blossomthemes-instagram-feed
17
  * Description: Show instagram feed on your website using shortcode and widget.
18
+ * Version: 2.0.0
19
  * Author: blossomthemes
20
  * Author URI: https://blossomthemes.com
21
  * License: GPL-2.0+
32
  define( 'BTIF_BASE_PATH', dirname( __FILE__ ) );
33
  define( 'BTIF_FILE_PATH', __FILE__ );
34
  define( 'BTIF_FILE_URL', rtrim( plugin_dir_url( __FILE__ ), '/' ) );
35
+ define( 'BTIF_PLUGIN_VERSION', '2.0.0' );
36
 
37
  // Instagram API image limit.
38
  if ( ! defined( 'BTIF_INSTAGRAM_API_IMAGE_LIMIT' ) ) {
39
+ define( 'BTIF_INSTAGRAM_API_IMAGE_LIMIT', 25 );
 
 
 
 
 
40
  }
41
 
42
  /**
includes/class-blossomthemes-instagram-feed-activator.php CHANGED
@@ -30,7 +30,13 @@ class Blossomthemes_Instagram_Feed_Activator {
30
  * @since 1.0.0
31
  */
32
  public static function activate() {
33
-
 
 
 
 
 
 
 
34
  }
35
-
36
  }
30
  * @since 1.0.0
31
  */
32
  public static function activate() {
33
+ $settings = get_option( 'blossomthemes_instagram_feed_settings ' );
34
+ if( isset( $settings['access-token'] ) ) {
35
+ delete_option( 'blossomthemes_instagram_feed_settings' );
36
+ delete_option( 'blossomthemes_instagram_invalid_token' );
37
+ delete_option( 'blossomthemes_instagram_user_feed' );
38
+ delete_transient( 'blossomthemes_instagram_data_fetch' );
39
+ delete_transient( 'blossomthemes_instagram_is_configured' );
40
+ }
41
  }
 
42
  }
includes/class-blossomthemes-instagram-feed-ajax.php CHANGED
@@ -34,25 +34,24 @@ class Blossomthemes_Instagram_Feed_Ajax {
34
  }
35
 
36
  // Get feed settings.
37
- $options = get_option( 'blossomthemes_instagram_feed_settings' );
38
 
39
  $photos = isset( $options['photos'] ) ? absint( $options['photos'] ) : 5;
40
- $photo_size = isset( $options['photo_size'] ) ? $options['photo_size'] : 'low_resolution';
41
 
42
  // Delete fetch already to fetch again.
43
  delete_transient( 'blossomthemes_instagram_data_fetch' );
44
 
45
  // Get instance.
46
- $feed_api = Blossomthemes_Instagram_Feed_API::getInstance();
47
 
48
  // Get images.
49
- $feed_api->get_items( $photos, $photo_size );
50
 
51
  // Send response.
52
- if ( false === $feed_api ) {
53
  wp_send_json_error();
54
  } else {
55
  wp_send_json_success();
56
  }
57
  }
58
- }
34
  }
35
 
36
  // Get feed settings.
37
+ $options = BlossomThemes_Instagram_Feed_Settings::get_settings();
38
 
39
  $photos = isset( $options['photos'] ) ? absint( $options['photos'] ) : 5;
 
40
 
41
  // Delete fetch already to fetch again.
42
  delete_transient( 'blossomthemes_instagram_data_fetch' );
43
 
44
  // Get instance.
45
+ $feed_api = Blossomthemes_Instagram_Feed_API::get_instance();
46
 
47
  // Get images.
48
+ $feed = $feed_api->get_items( $photos );
49
 
50
  // Send response.
51
+ if ( false === $feed) {
52
  wp_send_json_error();
53
  } else {
54
  wp_send_json_success();
55
  }
56
  }
57
+ }
includes/class-blossomthemes-instagram-feed-api.php CHANGED
@@ -1,75 +1,70 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
3
  class Blossomthemes_Instagram_Feed_API {
4
  /**
5
  * @var Blossomthemes_Instagram_Feed_API The reference to *Singleton* instance of this class
6
  */
7
- private static $instance;
8
 
9
- /**
10
- * Instagram Access Token
11
- *
12
- * @var string
13
- */
14
- protected $access_token;
15
 
16
  /**
17
  * Returns the *Singleton* instance of this class.
18
  *
19
  * @return Blossomthemes_Instagram_Feed_API The *Singleton* instance.
20
  */
21
- public static function getInstance()
22
  {
23
  if ( null === self::$instance ) {
24
- self::$instance = new self();
25
  }
26
  return self::$instance;
27
  }
28
 
29
- protected function __construct() {
30
- $options = get_option( 'blossomthemes_instagram_feed_settings' );
31
- $this->access_token = !empty( $options['access-token'] ) ? $options['access-token'] : '';
32
- $this->username = !empty( $options['username'] ) ? $options['username'] : '';
33
- $this->pull_duration = !empty( $options['pull_duration'] ) ? $options['pull_duration'] : 1;
34
- $this->pull_unit = !empty( $options['pull_unit'] ) ? $options['pull_unit'] : 'days';
35
-
36
- }
37
-
38
- /**
39
- * Calculate posts fetch interval.
40
- */
41
- function get_transient_lifetime() {
42
-
43
- $values = array( 'minutes' => MINUTE_IN_SECONDS, 'hours' => HOUR_IN_SECONDS, 'days' => DAY_IN_SECONDS );
44
- $keys = array_keys( $values );
45
- $type = in_array( $this->pull_unit, $keys ) ? $values[ $this->pull_unit ] : $values['minutes'];
46
 
47
- return $type * $this->pull_duration;
 
48
  }
49
 
50
  /**
51
  * @param int $image_limit Number of images to retrieve
52
- * @param string $photo_size Desired image size to retrieve
53
  *
54
  * @return array|bool Array of tweets or false if method fails
55
  */
56
- public function get_items( $image_limit, $photo_size ) {
57
  // Check if the user feed is already fetched.
58
  $fetch_already = get_transient( 'blossomthemes_instagram_data_fetch' );
59
  $feed = get_option( 'blossomthemes_instagram_user_feed' );
60
 
61
  // Return data from cache if the images are already fetched and data is in the cache.
62
  if ( $fetch_already && ! empty( $feed )) {
63
- return $this->processing_response_data( $feed, $photo_size, $image_limit );
64
  }
65
 
 
 
 
 
 
66
  // Get the new images if the images are not fetched.
67
- $response = wp_remote_get( sprintf( BTIF_INSTAGRAM_API_MEDIA_ACCESS_URL, $this->access_token, BTIF_INSTAGRAM_API_IMAGE_LIMIT ) );
68
 
69
  // Return the images from cache if new images cannot be fetched.
70
  if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
71
  update_option( 'blossomthemes_instagram_invalid_token', true, false );
72
- return $this->processing_response_data( $feed, $photo_size, $image_limit );
73
  }
74
 
75
  $data = json_decode( wp_remote_retrieve_body( $response ) );
@@ -80,64 +75,51 @@ class Blossomthemes_Instagram_Feed_API {
80
  return false;
81
  }
82
 
83
- // Set the data fetch to true and update the cache with new posts.
84
- set_transient( 'blossomthemes_instagram_data_fetch', true, $this->get_transient_lifetime() );
85
- update_option( 'blossomthemes_instagram_user_feed', $data, false );
86
- return $this->processing_response_data( $data, $photo_size, $image_limit );
87
- }
88
-
89
- public function processing_response_data( $data, $photo_size, $image_limit ) {
90
-
91
- // Bail early if the data is false.
92
- if ( false === $data ) {
93
- return false;
94
- }
95
-
96
- $result = array();
97
- $username = '';
98
-
99
- $i = 0;
100
- foreach ( $data->data as $key => $item ) {
101
-
102
- if ( empty( $username ) ) {
103
- $username = $item->user->username;
104
- }
105
-
106
- if ( $i < $image_limit ) {
107
-
108
- $result[] = array(
109
- 'link' => $item->link,
110
- 'image-standard' => $item->images->standard_resolution->url,
111
- 'image-url' => $item->images->$photo_size->url,
112
- 'likes_count' => ! empty( $item->likes->count ) ? esc_attr( $item->likes->count ) : 0,
113
- 'comments_count' => ! empty( $item->comments->count ) ? esc_attr( $item->comments->count ) : 0,
114
- 'caption' => ! empty( $item->caption->text ) ? html_entity_decode( $item->caption->text ) : 'Instagram-Caption',
115
- );
116
- }
117
- $i++;
118
- }
119
 
120
- $result = array( 'items' => $result, 'username' => $username );
 
 
121
 
122
- return $result;
123
  }
124
 
 
 
 
 
 
 
 
 
 
125
  /**
126
  * Check if given access token is valid for Instagram Api.
127
  */
128
  public static function is_access_token_valid( $access_token ) {
129
- $response = wp_remote_get( sprintf( 'https://api.instagram.com/v1/users/self/?access_token=%s', $access_token ) );
 
 
 
 
 
 
 
130
 
131
  if ( is_wp_error( $response ) ) {
132
- return $response;
 
133
  }
134
 
135
  if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
 
136
  return false;
137
  }
138
 
139
- // Set invalid token to false.
140
- update_option( 'blossomthemes_instagram_invalid_token', false, false );
141
  return true;
142
  }
143
 
@@ -155,7 +137,7 @@ class Blossomthemes_Instagram_Feed_API {
155
  }
156
  }
157
 
158
- $condition = $this->is_access_token_valid( $this->access_token );
159
 
160
  if ( true === $condition ) {
161
  set_transient( $transient, 'yes', DAY_IN_SECONDS );
@@ -173,22 +155,45 @@ class Blossomthemes_Instagram_Feed_API {
173
  */
174
  public static function reset_cache() {
175
  delete_transient( 'blossomthemes_instagram_is_configured' );
 
176
  }
177
 
178
  /**
179
- * Get access token.
180
  */
181
- public function get_access_token() {
182
- return $this->access_token;
 
 
 
 
 
183
  }
184
 
185
  /**
186
- * Set access token.
187
- *
188
- * @param string $access_token Instagram access token.
189
  */
190
- public function set_access_token( $access_token ) {
191
- $this->access_token = $access_token;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  }
193
 
194
  }
1
  <?php
2
+ /**
3
+ * Instagram API section of the plugin.
4
+ *
5
+ * Maintain a list of functions that are used for fetching items from Instagram API
6
+ *
7
+ * @package BlossomThemes_Instagram_Feed
8
+ * @subpackage BlossomThemes_Instagram_Feed/includes
9
+ * @author blossomthemes
10
+ */
11
  class Blossomthemes_Instagram_Feed_API {
12
  /**
13
  * @var Blossomthemes_Instagram_Feed_API The reference to *Singleton* instance of this class
14
  */
15
+ private static $instance = null;
16
 
17
+ private $media_url = 'https://graph.instagram.com/me/media';
18
+
19
+ private $settings;
 
 
 
20
 
21
  /**
22
  * Returns the *Singleton* instance of this class.
23
  *
24
  * @return Blossomthemes_Instagram_Feed_API The *Singleton* instance.
25
  */
26
+ public static function get_instance($settings=null)
27
  {
28
  if ( null === self::$instance ) {
29
+ self::$instance = new self($settings);
30
  }
31
  return self::$instance;
32
  }
33
 
34
+ private function __construct($settings) {
35
+ $this->settings = $settings;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ add_action( 'btif_refresh_token_cron_hook', array( $this, 'btif_refresh_token_cron_exec' ) );
38
+ add_filter( 'cron_schedules', array( $this, 'add_fifty_days_cron_interval' ) );
39
  }
40
 
41
  /**
42
  * @param int $image_limit Number of images to retrieve
 
43
  *
44
  * @return array|bool Array of tweets or false if method fails
45
  */
46
+ public function get_items( $image_limit ) {
47
  // Check if the user feed is already fetched.
48
  $fetch_already = get_transient( 'blossomthemes_instagram_data_fetch' );
49
  $feed = get_option( 'blossomthemes_instagram_user_feed' );
50
 
51
  // Return data from cache if the images are already fetched and data is in the cache.
52
  if ( $fetch_already && ! empty( $feed )) {
53
+ return $this->slice_images( $feed, $image_limit );
54
  }
55
 
56
+ $url = add_query_arg( array(
57
+ 'fields' => 'caption, id, media_type, media_url, permalink, thumbnail_url, timestamp, username',
58
+ 'access_token' => $this->settings->get_access_token(),
59
+ ), $this->media_url );
60
+
61
  // Get the new images if the images are not fetched.
62
+ $response = wp_remote_get( $url );
63
 
64
  // Return the images from cache if new images cannot be fetched.
65
  if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
66
  update_option( 'blossomthemes_instagram_invalid_token', true, false );
67
+ return $this->slice_images( $feed, $image_limit );
68
  }
69
 
70
  $data = json_decode( wp_remote_retrieve_body( $response ) );
75
  return false;
76
  }
77
 
78
+ $data->data = array_map( function ($item) {
79
+ return (object) wp_parse_args( $item, array(
80
+ 'caption' => 'Instagram-Caption'
81
+ ) );
82
+ }, $data->data );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
+ // Set the data fetch to true and update the cache with new posts.
85
+ set_transient( 'blossomthemes_instagram_data_fetch', true, $this->settings->get_transient_lifetime() );
86
+ update_option( 'blossomthemes_instagram_user_feed', $data->data, false );
87
 
88
+ return $this->slice_images( $data->data, $image_limit );
89
  }
90
 
91
+ private function slice_images( $data, $count ){
92
+
93
+ if( ! is_array( $data ) ) return array();
94
+ $data_length = count( $data );
95
+ $min = min( $data_length, $count );
96
+
97
+ return array_slice( $data, 0, $min );
98
+ }
99
+
100
  /**
101
  * Check if given access token is valid for Instagram Api.
102
  */
103
  public static function is_access_token_valid( $access_token ) {
104
+
105
+ $url = add_query_arg( array(
106
+ 'fields' => 'username',
107
+ 'access_token' => $access_token,
108
+
109
+ ), 'https://graph.instagram.com/me' );
110
+
111
+ $response = wp_remote_get( $url );
112
 
113
  if ( is_wp_error( $response ) ) {
114
+ update_option( 'blossomthemes_instagram_invalid_token', true, false );
115
+ return false;
116
  }
117
 
118
  if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
119
+ update_option( 'blossomthemes_instagram_invalid_token', true, false );
120
  return false;
121
  }
122
 
 
 
123
  return true;
124
  }
125
 
137
  }
138
  }
139
 
140
+ $condition = $this->is_access_token_valid( $this->settings->get_access_token() );
141
 
142
  if ( true === $condition ) {
143
  set_transient( $transient, 'yes', DAY_IN_SECONDS );
155
  */
156
  public static function reset_cache() {
157
  delete_transient( 'blossomthemes_instagram_is_configured' );
158
+ delete_option( 'blossomthemes_instagram_invalid_token' );
159
  }
160
 
161
  /**
162
+ * Add 50 days interval.
163
  */
164
+ public function add_fifty_days_cron_interval( $schedules ) {
165
+ $schedules['fifty_days'] = array(
166
+ 'interval' => 50 * DAY_IN_SECONDS,
167
+ 'display' => esc_html__( 'Every Fifty Days', 'blossomthemes-instagram-feed' ),
168
+ );
169
+
170
+ return $schedules;
171
  }
172
 
173
  /**
174
+ * Add Instagra Refresh Token cron job execution function.
 
 
175
  */
176
+ public function btif_refresh_token_cron_exec(){
177
+ $access_token = $this->settings->get_access_token();
178
+ $settings = $this->settings->get_settings();
179
+
180
+ $refresh_token_url = add_query_arg( array(
181
+ 'grant_type' => 'ig_refresh_token',
182
+ 'access_token' => $access_token,
183
+ ), 'https://graph.instagram.com/refresh_access_token' );
184
+
185
+ $response = wp_remote_get( $refresh_token_url );
186
+
187
+ if( is_wp_error( $response ) ) return;
188
+
189
+ if( 200 !== wp_remote_retrieve_response_code( $response ) ) return;
190
+
191
+ $body = json_decode( wp_remote_retrieve_body($response) );
192
+
193
+ $settings['access_token'] = $body->access_token;
194
+
195
+ update_option( 'blossomthemes_instagram_feed_settings', $settings );
196
+
197
  }
198
 
199
  }
includes/class-blossomthemes-instagram-feed-deactivator.php CHANGED
@@ -30,6 +30,8 @@ class Blossomthemes_Instagram_Feed_Deactivator {
30
  * @since 1.0.0
31
  */
32
  public static function deactivate() {
 
 
33
 
34
  }
35
 
30
  * @since 1.0.0
31
  */
32
  public static function deactivate() {
33
+ $timestamp = wp_next_scheduled( 'btif_refresh_token_cron_hook' );
34
+ wp_unschedule_event( $timestamp, 'btif_refresh_token_cron_hook' );
35
 
36
  }
37
 
includes/class-blossomthemes-instagram-feed-settings.php CHANGED
@@ -9,88 +9,240 @@
9
  * @author blossomthemes
10
  */
11
  class BlossomThemes_Instagram_Feed_Settings {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  /**
13
  * Instagram 0auth URL.
14
  * @var string $auth_url Instagram Oauth URL with callback.
15
  */
16
- private $oauth_url = 'https://instagram.com/oauth/authorize/?client_id=8dc488eba3d54eb9806eb27eabb8cd03&response_type=token&redirect_uri=https://blossomthemes.com/instagram/';
17
- /**
18
- * Map of old instagram image size to new image size.
19
- *
20
- * @var array $photo_sizes Map of old instagram image to new image size.
21
- */
22
- private $photo_sizes = array(
23
- 'img_thumb' => 'thumbnail',
24
- 'img_low' => 'low_resolution',
25
- 'img_standard' => 'standard_resolution'
26
- );
27
-
28
- public function __construct() {
29
- add_action( 'btif_settings_general_tab_content', array( $this, 'btif_settings_general_tab_content' ) );
30
- add_action( 'btif_settings_usage_tab_content', array( $this, 'btif_settings_usage_tab_content' ) );
31
- add_action( 'btif_settings_sidebar', array( $this, 'btif_settings_sidebar' ) );
 
 
 
 
 
 
 
32
  }
33
 
34
  /**
35
  * Include settings sidebar.
36
  */
37
- public function btif_settings_sidebar() {
38
  require_once BTIF_BASE_PATH . '/includes/template/backend/sidebar.php';
39
  }
40
 
41
  /**
42
  * Include the settings usage tab content template.
43
  */
44
- public function btif_settings_usage_tab_content() {
45
  require_once BTIF_BASE_PATH . '/includes/template/backend/usage.php';
46
  }
47
 
48
  /**
49
  * Include the settings general tab content template.
50
  */
51
- public function btif_settings_general_tab_content() {
52
- // $oauth_url = 'https://instagram.com/oauth/authorize/?client_id=291228964f8746a9933b6a51c6dcb750&response_type=token&redirect_uri=http://localhost/blossom/wordpress/blossom-insta-check/';
53
-
54
  // Authorize URL with client site redirect link
55
  $oauth_url = $this->oauth_url;
56
- $oauth_url .= '?auth_site=' . esc_url( admin_url( 'admin.php?page=class-blossomthemes-instagram-feed-admin.php' ) );
57
- $oauth_url.='&hl=en';
58
 
59
- $options = get_option( 'blossomthemes_instagram_feed_settings' );
60
- $photo_size = isset( $options['photo_size'] ) ? esc_attr( $options['photo_size'] ) : 'low_resolution';
61
 
62
- // Changed to the new instagram image size.
63
- if ( array_key_exists( $photo_size, $this->photo_sizes ) ) {
64
- $photo_size = $this->photo_sizes[ $photo_size ];
65
- }
66
-
67
  // Override options Access Token if received new access token by POST method
68
  if ( isset( $_POST['access_token'] ) ) {
69
- $options['access-token'] = $_POST['access_token'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
- // Prepare array to be passed to the template.
73
- $args = array(
74
- 'oauth_url' => $oauth_url,
75
- 'access_token' => isset( $options['access-token'] ) ? $options['access-token'] : '',
76
- 'username' => isset( $options['username'] ) ? $options['username'] : '',
77
- 'photos' => isset( $options['photos'] ) ? $options['photos'] : 5,
78
- 'size' => $photo_size,
79
- 'photos_row' => isset( $options['photos_row'] ) ? $options['photos_row'] : 5,
80
- 'follow_me' => isset( $options['follow_me'] ) ? $options['follow_me'] : '',
81
- 'pull_duration' => isset( $options['pull_duration'] ) ? $options['pull_duration'] : 1,
82
- 'pull_unit' => isset( $options['pull_unit'] ) ? $options['pull_unit'] : 'days',
83
- 'meta' => isset( $options['meta'] ) ? $options['meta'] : true,
84
- );
85
-
86
- // Extrat the variables from the array.
87
- extract( $args );
88
 
89
  require_once BTIF_BASE_PATH . '/includes/template/backend/general.php';
90
  }
91
 
92
- function blossomthemes_instagram_feed_backend_settings() {
93
  require_once BTIF_BASE_PATH . '/includes/template/backend/settings.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
  }
96
- new BlossomThemes_Instagram_Feed_Settings;
9
  * @author blossomthemes
10
  */
11
  class BlossomThemes_Instagram_Feed_Settings {
12
+
13
+ private static $_instance = null;
14
+
15
+ private $base_url = 'https://api.instagram.com/oauth/authorize';
16
+
17
+ private $client_id = '1236030103272716';
18
+
19
+ private $redirect_uri = 'https://blossomthemes.com/blossomthemes-social-feed-oauth/';
20
+ // private $redirect_uri = 'https://blossom.test/instagram-api-test/';
21
+
22
+ private $response_type = 'code';
23
+
24
+ private $scope = 'user_profile,user_media';
25
+
26
  /**
27
  * Instagram 0auth URL.
28
  * @var string $auth_url Instagram Oauth URL with callback.
29
  */
30
+ private $oauth_url = "";
31
+
32
+ public static function get_instance() {
33
+ if( null === self::$_instance ) {
34
+ self::$_instance = new self;
35
+ }
36
+ return self::$_instance;
37
+ }
38
+
39
+ private function __construct() {
40
+ add_action( 'btif_settings_general_tab_content', array( $this, 'render_general_tab_content' ) );
41
+ add_action( 'btif_settings_usage_tab_content', array( $this, 'render_usage_tab_content' ) );
42
+ add_action( 'btif_settings_sidebar', array( $this, 'render_sidebar' ) );
43
+ // add_shortcode( 'btif_instagram_new_accesscode', array( $this, 'btif_get_instagram_accesscode' ) );
44
+
45
+ $this->oauth_url = add_query_arg( array(
46
+ 'client_id' => $this->client_id,
47
+ 'response_type' => $this->response_type,
48
+ 'redirect_uri' => $this->redirect_uri,
49
+ 'scope' => $this->scope,
50
+ 'state' => admin_url( 'admin.php?page=class-blossomthemes-instagram-feed-admin.php' )
51
+
52
+ ), $this->base_url );
53
  }
54
 
55
  /**
56
  * Include settings sidebar.
57
  */
58
+ public function render_sidebar() {
59
  require_once BTIF_BASE_PATH . '/includes/template/backend/sidebar.php';
60
  }
61
 
62
  /**
63
  * Include the settings usage tab content template.
64
  */
65
+ public function render_usage_tab_content() {
66
  require_once BTIF_BASE_PATH . '/includes/template/backend/usage.php';
67
  }
68
 
69
  /**
70
  * Include the settings general tab content template.
71
  */
72
+ public function render_general_tab_content() {
 
 
73
  // Authorize URL with client site redirect link
74
  $oauth_url = $this->oauth_url;
 
 
75
 
76
+ $options = self::get_settings();
 
77
 
 
 
 
 
 
78
  // Override options Access Token if received new access token by POST method
79
  if ( isset( $_POST['access_token'] ) ) {
80
+ $options['access_token'] = $_POST['access_token'];
81
+
82
+ $user_node = add_query_arg( array(
83
+ 'fields' => 'username',
84
+ 'access_token' => $options['access_token'],
85
+
86
+ ), 'https://graph.instagram.com/me' );
87
+
88
+ $response = wp_remote_get( $user_node );
89
+
90
+ if( ! is_wp_error( $response ) && 200 === wp_remote_retrieve_response_code( $response ) ) {
91
+ $body = json_decode( wp_remote_retrieve_body($response) );
92
+
93
+ $options['username'] = $body->username;
94
+
95
+ if( ! defined( 'DISABLE_WP_CRON' ) ||
96
+ ( defined( 'DISABLE_WP_CRON') && false === DISABLE_WP_CRON ) ){
97
+ if ( ! wp_next_scheduled( 'btif_refresh_token_cron_hook' ) ) {
98
+ wp_schedule_event( time(), 'fifty_days', 'btif_refresh_token_cron_hook' );
99
+ }
100
+ }
101
+ } else {
102
+ update_option( 'blossomthemes_instagram_invalid_token', true, false );
103
+ }
104
+
105
  }
106
 
107
+ // If user denies the authorization
108
+ if ( isset( $_GET['error_reason'] ) ) {
109
+ update_option( 'blossomthemes_instagram_invalid_token', true, false );
110
+ }
111
+
112
+ extract( $options );
 
 
 
 
 
 
 
 
 
 
113
 
114
  require_once BTIF_BASE_PATH . '/includes/template/backend/general.php';
115
  }
116
 
117
+ function render_backend_settings() {
118
  require_once BTIF_BASE_PATH . '/includes/template/backend/settings.php';
119
+ }
120
+
121
+ public static function get_settings(){
122
+ $settings = get_option( 'blossomthemes_instagram_feed_settings' );
123
+
124
+ $settings = wp_parse_args( $settings, array(
125
+ 'access_token' => '',
126
+ 'username' => '',
127
+ 'photos' => 5,
128
+ 'photos_row' => 5,
129
+ 'follow_me' => 'Follow Me!',
130
+ 'pull_duration' => 1,
131
+ 'pull_unit' => 'days',
132
+ ) );
133
+
134
+ return $settings;
135
+ }
136
+
137
+ /**
138
+ * Get access token.
139
+ */
140
+ public function get_access_token() {
141
+ $settings = self::get_settings();
142
+ return $settings['access_token'];
143
+ }
144
+
145
+ /**
146
+ * Calculate posts fetch interval.
147
+ */
148
+ public function get_transient_lifetime() {
149
+ $settings = self::get_settings();
150
+
151
+ $values = array( 'minutes' => MINUTE_IN_SECONDS, 'hours' => HOUR_IN_SECONDS, 'days' => DAY_IN_SECONDS );
152
+ $keys = array_keys( $values );
153
+ $type = in_array( $settings['pull_unit'], $keys ) ? $values[ $settings['pull_unit'] ] : $values['minutes'];
154
+
155
+ return $type * $settings['pull_duration'];
156
+ }
157
+
158
+ /*
159
+ * Shortcode to fetch Access Token from Instagram using Instagram API
160
+ * and redirect to client URL
161
+ */
162
+ function btif_get_instagram_accesscode(){
163
+ if( is_admin() ) return;
164
+
165
+ if( isset( $_GET['state'] ) ) {
166
+ $page = stristr( $_GET['state'], 'page' );
167
+ if( 'page=class-blossomthemes-instagram-feed-admin.php' !== $page ) {
168
+ $_GET['state'] = str_replace( 'page', 'page=class-blossomthemes-instagram-feed-admin.php', $_GET['state'] );
169
+ }
170
+ }
171
+
172
+ if( isset( $_GET['error_reason'] ) && 'user_denied' === $_GET['error_reason'] ) {
173
+ echo $_GET['error_description'];
174
+
175
+ $url = add_query_arg( array(
176
+ 'error_reason' => $_GET['error_reason'],
177
+ 'error_description' => $_GET['error_description']
178
+ ), esc_url( $_GET['state'] ) );
179
+ ?>
180
+ <script>
181
+ jQuery(document).ready(function($){
182
+ setTimeout(function () {
183
+ window.location.href = "<?php echo $url;?>";
184
+ }, 2000);
185
+ });
186
+ </script>
187
+ <?php
188
+ return;
189
+ }
190
+
191
+ if( !isset( $_GET['code'] ) && !isset( $_GET['state'] ) ) return;
192
+
193
+ $url = 'https://api.instagram.com/oauth/access_token';
194
+
195
+ $response = wp_remote_post( $url, array(
196
+ 'method' => 'POST',
197
+ 'timeout' => 45,
198
+ 'redirection' => 5,
199
+ 'blocking' => true,
200
+ 'body' => array(
201
+ 'client_id' => $this->client_id,
202
+ 'client_secret' => 'ed9157ed049b42369d8931b95f877077',
203
+ 'grant_type' => 'authorization_code',
204
+ 'redirect_uri' => $this->redirect_uri,
205
+ 'code' => $_GET['code'],
206
+ )
207
+
208
+ ) );
209
+
210
+ if( is_wp_error( $response ) ) return;
211
+
212
+ if( 200 !== wp_remote_retrieve_response_code( $response ) ) return;
213
+
214
+ $body = json_decode( wp_remote_retrieve_body($response) );
215
+
216
+ $long_live_token_url = add_query_arg( array(
217
+ 'client_secret' => 'ed9157ed049b42369d8931b95f877077',
218
+ 'access_token' => $body->access_token,
219
+ 'grant_type' => 'ig_exchange_token',
220
+
221
+ ), 'https://graph.instagram.com/access_token' );
222
+
223
+ $response = wp_remote_get( $long_live_token_url );
224
+
225
+ if( is_wp_error( $response ) ) return;
226
+
227
+ if( 200 !== wp_remote_retrieve_response_code( $response ) ) return;
228
+
229
+ $body = json_decode( wp_remote_retrieve_body($response) );
230
+
231
+ ?>
232
+ <form id="btif_instagram_form" method="post" action="<?php echo $_GET['state'];?>">
233
+ <input type="hidden" name="access_token" id="access_token" value="<?php echo $body->access_token;?>">
234
+ </form>
235
+
236
+ <script>
237
+
238
+ jQuery(document).ready(function($){
239
+
240
+ $("#btif_instagram_form").submit();
241
+
242
+ });
243
+
244
+ </script>
245
+
246
+ <?php
247
  }
248
  }
 
includes/class-blossomthemes-instagram-feed-shortcodes.php CHANGED
@@ -10,94 +10,36 @@
10
  class BlossomThemes_Instagram_Feed_Shortcodes
11
  {
12
  public function init(){
13
- add_shortcode( 'blossomthemes_instagram_feed', array( $this, 'blossomthemes_instagram_feed_sc' ) );
14
  }
15
 
16
- function blossomthemes_instagram_feed_sc(){
 
 
 
17
  ob_start();
18
 
19
- $options = get_option( 'blossomthemes_instagram_feed_settings', true );
20
- $photos = absint($options['photos']);
21
- $photo_size = isset( $options['photo_size'] ) ? esc_attr( $options['photo_size'] ) :'low_resolution';
22
- $photos_row = isset( $options['photos_row'] ) ? esc_attr( $options['photos_row'] ) :'5';
23
  $instaUrl = 'https://www.instagram.com/';
24
- $instaUrl .= $options['username'];
25
- $profile_link_text = isset( $options['follow_me'] ) ? esc_attr( $options['follow_me'] ):'Follow Me!';
26
 
27
- $this->api = Blossomthemes_Instagram_Feed_API::getInstance();
28
 
29
- $items = $this->api->get_items( $photos, $photo_size );
30
 
31
  if ( ! is_array( $items ) ) {
32
  if ( current_user_can( 'edit_theme_options' ) ) {
33
- ?>
34
- <p>
35
- <?php _e( 'BlossomThemes Social Feed misconfigured, check plugin &amp; widget settings.', 'blossomthemes-instagram-feed' ); ?>
36
- </p>
37
- <?php
38
  } else {
39
  echo '<b style="color:red;">'.__('No posts available!','blossomthemes-instagram-feed').'</b>';
40
  }
41
  } else {
42
-
43
- $count = 0;
44
- ?>
45
- <ul class="popup-gallery photos-<?php echo $photos_row;?>">
46
-
47
- <?php foreach ( $items['items'] as $item ) : ?>
48
- <?php
49
- $link = $item['link'];
50
- $img_standard = $item['image-standard'];
51
- $src = $item['image-url'];
52
- $likes = $item['likes_count'];
53
- $comments = $item['comments_count'];
54
- $caption = $item['caption'];
55
- ?>
56
-
57
- <li>
58
-
59
- <a href="<?php echo esc_url($img_standard); ?>">
60
- <img src="<?php echo esc_url($src); ?>" alt="<?php echo html_entity_decode($caption); ?>">
61
- </a>
62
- <?php if( isset( $options['meta'] ) )
63
- {
64
- echo '<div class="instagram-meta"><span class="like"><i class="fa fa-heart"></i>'.$likes.'</span>'.'<span class="comment"><i class="fa fa-comment"></i>'.$comments.'</span>'.'</div>';
65
- }?>
66
- </li>
67
-
68
- <?php if ( ++$count === $photos ) break; ?>
69
-
70
- <?php endforeach; ?>
71
-
72
- </ul>
73
- <?php echo
74
- '<script>
75
- jQuery(document).ready(function($){
76
- $(".popup-gallery").magnificPopup({
77
- delegate: "a",
78
- type: "image",
79
- gallery:{
80
- enabled:true
81
- }
82
- });
83
-
84
- $(".popup-modal").magnificPopup({
85
- type: "inline",
86
- preloader: false,
87
- focus: "#username",
88
- modal: true
89
- });
90
- $(document).on("click", ".popup-modal-dismiss", function (e) {
91
- e.preventDefault();
92
- $.magnificPopup.close();
93
- });
94
- });
95
- </script>';
96
- echo ' <a class="profile-link" href="'.esc_url($instaUrl).'" target="_blank" rel="noreferrer"><span class="insta-icon"><i class="fab fa-instagram"></i></span>'.esc_attr($profile_link_text).'</a>';
97
  }
98
 
99
  $output = ob_get_contents();
100
- ob_end_clean();
101
- return apply_filters( 'btif_instagram_shortcode_filter', $output );
102
  }
103
  }
10
  class BlossomThemes_Instagram_Feed_Shortcodes
11
  {
12
  public function init(){
13
+ add_shortcode( 'blossomthemes_instagram_feed', array( $this, 'display' ) );
14
  }
15
 
16
+ function display(){
17
+
18
+ if( is_admin() ) return;
19
+
20
  ob_start();
21
 
22
+ $settings = BlossomThemes_Instagram_Feed_Settings::get_settings();
 
 
 
23
  $instaUrl = 'https://www.instagram.com/';
24
+ $instaUrl .= $settings['username'];
 
25
 
26
+ $this->api = Blossomthemes_Instagram_Feed_API::get_instance();
27
 
28
+ $items = $this->api->get_items( $settings['photos'] );
29
 
30
  if ( ! is_array( $items ) ) {
31
  if ( current_user_can( 'edit_theme_options' ) ) {
32
+ echo '<p>'.__( 'BlossomThemes Social Feed misconfigured, check plugin &amp; widget settings.',
33
+ 'blossomthemes-instagram-feed' ).'</p>';
 
 
 
34
  } else {
35
  echo '<b style="color:red;">'.__('No posts available!','blossomthemes-instagram-feed').'</b>';
36
  }
37
  } else {
38
+ require plugin_dir_path( BTIF_FILE_PATH ) . 'public/partials/blossomthemes-instagram-feed-public-display.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  }
40
 
41
  $output = ob_get_contents();
42
+ ob_end_clean();
43
+ return apply_filters( 'btif_instagram_shortcode_filter', $output );
44
  }
45
  }
includes/class-blossomthemes-instagram-feed.php CHANGED
@@ -199,7 +199,8 @@ class Blossomthemes_Instagram_Feed {
199
  private function define_public_hooks() {
200
 
201
  $plugin_public = new Blossomthemes_Instagram_Feed_Public( $this->get_plugin_name(), $this->get_version() );
202
-
 
203
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
204
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
205
  $this->loader->add_filter( 'script_loader_tag', $plugin_public, 'btif_js_defer_files', 10 );
199
  private function define_public_hooks() {
200
 
201
  $plugin_public = new Blossomthemes_Instagram_Feed_Public( $this->get_plugin_name(), $this->get_version() );
202
+ $settings = BlossomThemes_Instagram_Feed_Settings::get_instance();
203
+ $api = Blossomthemes_Instagram_Feed_API::get_instance($settings);
204
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
205
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
206
  $this->loader->add_filter( 'script_loader_tag', $plugin_public, 'btif_js_defer_files', 10 );
includes/template/backend/general.php CHANGED
@@ -3,13 +3,14 @@
3
  * Settings general tab content template.
4
  */
5
  ?>
6
- <div class="blossomthemes-instagram-feed-settings general" id="blossomthemes-instagram-feed-settings-general">
 
7
  <div class="btif-option-field-wrap">
8
  <h2><?php _e('Connect with Instagram', 'blossomthemes-instagram-feed'); ?></h2>
9
  <p>
10
  <?php _e( 'To get started click the button below. You’ll be prompted to authorize BlossomThemes Social Feed to access your Instagram photos.', 'blossomthemes-instagram-feed' ); ?>
11
- <a href="https://www.youtube.com/watch?v=U4tkwdtgkt0" target="_blank">
12
- <?php _e('For help, please refer to this video tutorial.', 'blossomthemes-instagram-feed');?>
13
  </a>
14
  </p>
15
 
@@ -21,7 +22,7 @@
21
 
22
  <!-- Connect with Instagram button -->
23
  <a class="button button-connect" target="_blank" href="<?php echo esc_url( $oauth_url ); ?>">
24
- <?php if ( ! Blossomthemes_Instagram_Feed_API::getInstance()->is_configured() ) : ?>
25
  <span><?php _e( 'Connect with Instagram', 'blossomthemes-instagram-feed' ); ?></span>
26
  <?php else: ?>
27
  <span class="btif-instagarm-connected"><?php _e( 'Re-connect with Instagram', 'blossomthemes-instagram-feed' ); ?></span>
@@ -31,11 +32,11 @@
31
 
32
  <!-- Access token input -->
33
  <p>
34
- <label for="blossomthemes_instagram_feed_settings[access-token]">
35
  <?php _e('Access Token', 'blossomthemes-instagram-feed'); ?>
36
  </label>
37
- <input class="" id="blossomthemes_instagram_feed_settings[access-token]"
38
- name="blossomthemes_instagram_feed_settings[access-token]" type="text"
39
  value="<?php echo esc_attr( $access_token ); ?>" />
40
  </p>
41
  <!-- ./ Access token input -->
@@ -61,37 +62,18 @@
61
  <label for="blossomthemes_instagram_feed_settings[photos]">
62
  <?php _e('Number of Photos', 'blossomthemes-instagram-feed'); ?>
63
  </label>
64
- <input min="1" max="30" id="blossomthemes_instagram_feed_settings[photos]"
65
  name="blossomthemes_instagram_feed_settings[photos]" type="number"
66
  value="<?php echo esc_attr( $photos ); ?>" />
67
  </div>
68
  <!-- ./ Number of photos -->
69
 
70
- <!-- Photo size -->
71
- <div class="btif-option-field-wrap">
72
- <label for="blossomthemes_instagram_feed_settings[photo_size]">
73
- <?php esc_html_e( 'Photo size', 'blossomthemes-instagram-feed' ); ?>
74
- </label>
75
- <select id="blossomthemes_instagram_feed_settings[photo_size]" name="blossomthemes_instagram_feed_settings[photo_size]">
76
- <option value="thumbnail" <?php selected( 'thumbnail', $size ) ?>>
77
- <?php esc_html_e( 'Thumbnail', 'blossomthemes-instagram-feed' ); ?>
78
- </option>
79
- <option value="low_resolution" <?php selected( 'low_resolution', $size ) ?>>
80
- <?php esc_html_e( 'Small', 'blossomthemes-instagram-feed' ); ?>
81
- </option>
82
- <option value="standard_resolution" <?php selected( 'standard_resolution', $size ) ?>>
83
- <?php esc_html_e( 'Large', 'blossomthemes-instagram-feed' ); ?>
84
- </option>
85
- </select>
86
- </div>
87
- <!-- ./ Photo size -->
88
-
89
  <!-- Photos per row -->
90
  <div class="btif-option-field-wrap">
91
  <label for="blossomthemes_instagram_feed_settings[photos_row]">
92
  <?php _e('Photos Per Row', 'blossomthemes-instagram-feed'); ?>
93
  </label>
94
- <input min="1" max="20" id="blossomthemes_instagram_feed_settings[photos_row]"
95
  name="blossomthemes_instagram_feed_settings[photos_row]" type="number"
96
  value="<?php echo esc_attr( $photos_row); ?>">
97
  </div>
@@ -108,15 +90,6 @@
108
  </div>
109
  <!-- ./ Profile link text -->
110
 
111
- <!-- Show likes comments -->
112
- <div class="btif-option-field-wrap">
113
- <label for="likes-comments">
114
- <?php _e( 'Show Likes/Comments', 'blossomthemes-instagram-feed' ); ?>
115
- </label>
116
- <input type="checkbox" value="1" id="likes-comments"
117
- name="blossomthemes_instagram_feed_settings[meta]" <?php checked( $meta, true ); ?>>
118
- </div>
119
-
120
  <!-- Check for New Posts -->
121
  <div class="btif-option-field-wrap">
122
  <label for="transient-pull-interval">
@@ -134,7 +107,6 @@
134
  name="blossomthemes_instagram_feed_settings[pull_unit]">
135
  <option <?php selected( $pull_unit, 'hours' ); ?> value="hours"><?php _e( 'Hours', 'blossomthemes-instagram-feed' ) ?></option>
136
  <option <?php selected( $pull_unit, 'days' ); ?> value="days"><?php _e( 'Days', 'blossomthemes-instagram-feed' ) ?></option>
137
- <option <?php selected( $pull_unit, 'minutes' ); ?> value="minutes"><?php _e( 'Minutes', 'blossomthemes-instagram-feed' ) ?></option>
138
  </select>
139
  <button type="button" id="btif-fetch-new-posts"
140
  class="button button-large">
@@ -185,4 +157,5 @@
185
  </span>
186
  </button>
187
  </div>
188
- </div>
 
3
  * Settings general tab content template.
4
  */
5
  ?>
6
+ <div class="blossomthemes-instagram-feed-settings general"
7
+ id="blossomthemes-instagram-feed-settings-general">
8
  <div class="btif-option-field-wrap">
9
  <h2><?php _e('Connect with Instagram', 'blossomthemes-instagram-feed'); ?></h2>
10
  <p>
11
  <?php _e( 'To get started click the button below. You’ll be prompted to authorize BlossomThemes Social Feed to access your Instagram photos.', 'blossomthemes-instagram-feed' ); ?>
12
+ <a href="https://blossomthemes.com/authenticate-instagram-account/" target="_blank">
13
+ <?php _e('For help, please refer to this tutorial.', 'blossomthemes-instagram-feed');?>
14
  </a>
15
  </p>
16
 
22
 
23
  <!-- Connect with Instagram button -->
24
  <a class="button button-connect" target="_blank" href="<?php echo esc_url( $oauth_url ); ?>">
25
+ <?php if ( ! Blossomthemes_Instagram_Feed_API::get_instance()->is_configured() ) : ?>
26
  <span><?php _e( 'Connect with Instagram', 'blossomthemes-instagram-feed' ); ?></span>
27
  <?php else: ?>
28
  <span class="btif-instagarm-connected"><?php _e( 'Re-connect with Instagram', 'blossomthemes-instagram-feed' ); ?></span>
32
 
33
  <!-- Access token input -->
34
  <p>
35
+ <label for="blossomthemes_instagram_feed_settings[access_token]">
36
  <?php _e('Access Token', 'blossomthemes-instagram-feed'); ?>
37
  </label>
38
+ <input class="" id="blossomthemes_instagram_feed_settings[access_token]"
39
+ name="blossomthemes_instagram_feed_settings[access_token]" type="text"
40
  value="<?php echo esc_attr( $access_token ); ?>" />
41
  </p>
42
  <!-- ./ Access token input -->
62
  <label for="blossomthemes_instagram_feed_settings[photos]">
63
  <?php _e('Number of Photos', 'blossomthemes-instagram-feed'); ?>
64
  </label>
65
+ <input min="1" max="25" id="blossomthemes_instagram_feed_settings[photos]"
66
  name="blossomthemes_instagram_feed_settings[photos]" type="number"
67
  value="<?php echo esc_attr( $photos ); ?>" />
68
  </div>
69
  <!-- ./ Number of photos -->
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  <!-- Photos per row -->
72
  <div class="btif-option-field-wrap">
73
  <label for="blossomthemes_instagram_feed_settings[photos_row]">
74
  <?php _e('Photos Per Row', 'blossomthemes-instagram-feed'); ?>
75
  </label>
76
+ <input min="1" max="10" id="blossomthemes_instagram_feed_settings[photos_row]"
77
  name="blossomthemes_instagram_feed_settings[photos_row]" type="number"
78
  value="<?php echo esc_attr( $photos_row); ?>">
79
  </div>
90
  </div>
91
  <!-- ./ Profile link text -->
92
 
 
 
 
 
 
 
 
 
 
93
  <!-- Check for New Posts -->
94
  <div class="btif-option-field-wrap">
95
  <label for="transient-pull-interval">
107
  name="blossomthemes_instagram_feed_settings[pull_unit]">
108
  <option <?php selected( $pull_unit, 'hours' ); ?> value="hours"><?php _e( 'Hours', 'blossomthemes-instagram-feed' ) ?></option>
109
  <option <?php selected( $pull_unit, 'days' ); ?> value="days"><?php _e( 'Days', 'blossomthemes-instagram-feed' ) ?></option>
 
110
  </select>
111
  <button type="button" id="btif-fetch-new-posts"
112
  class="button button-large">
157
  </span>
158
  </button>
159
  </div>
160
+ </div>
161
+ <?php
includes/template/backend/settings.php CHANGED
@@ -8,7 +8,7 @@
8
  <div class="btif-header">
9
  <h3><?php _e( 'BlossomThemes Social Feed', 'blossomthemes-instagram-feed' ); ?></h3>
10
  </div>
11
-
12
  <div class="btif-inner-wrap">
13
  <h2 class="nav-tab-wrapper">
14
  <a href="#" class="btss-tab-trigger nav-tab nav-tab-active" data-configuration="general">
@@ -56,4 +56,5 @@
56
  */
57
  do_action( 'btif_settings_sidebar' );
58
  ?>
59
- </div>
 
8
  <div class="btif-header">
9
  <h3><?php _e( 'BlossomThemes Social Feed', 'blossomthemes-instagram-feed' ); ?></h3>
10
  </div>
11
+
12
  <div class="btif-inner-wrap">
13
  <h2 class="nav-tab-wrapper">
14
  <a href="#" class="btss-tab-trigger nav-tab nav-tab-active" data-configuration="general">
56
  */
57
  do_action( 'btif_settings_sidebar' );
58
  ?>
59
+ </div>
60
+ <?php
includes/template/backend/sidebar.php CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  <div class="btss-backend-sidebar">
2
  <div class="thumbnail">
3
  <h4><?php _e('More WordPress Themes and Plugins?', 'blossomthemes-instagram-feed');?></h4>
@@ -9,4 +14,5 @@
9
  <p class="text-justify"><?php _e("Please fill free to leave us a review, if you found this plugin helpful.","blossomthemes-instagram-feed");?></p>
10
  <p class="text-center"><a href="https://wordpress.org/support/plugin/blossomthemes-instagram-feed/reviews" target="_blank" class="button button-primary"><?php _e( 'Leave a Review', 'blossomthemes-instagram-feed' ); ?></a></p>
11
  </div>
12
- </div>
 
1
+ <?php
2
+ /**
3
+ * Sidebar template.
4
+ */
5
+ ?>
6
  <div class="btss-backend-sidebar">
7
  <div class="thumbnail">
8
  <h4><?php _e('More WordPress Themes and Plugins?', 'blossomthemes-instagram-feed');?></h4>
14
  <p class="text-justify"><?php _e("Please fill free to leave us a review, if you found this plugin helpful.","blossomthemes-instagram-feed");?></p>
15
  <p class="text-center"><a href="https://wordpress.org/support/plugin/blossomthemes-instagram-feed/reviews" target="_blank" class="button button-primary"><?php _e( 'Leave a Review', 'blossomthemes-instagram-feed' ); ?></a></p>
16
  </div>
17
+ </div>
18
+ <?php
includes/template/backend/usage.php CHANGED
@@ -38,4 +38,5 @@
38
  </div>
39
  </div>
40
  </div>
41
- </div>
 
38
  </div>
39
  </div>
40
  </div>
41
+ </div>
42
+ <?php
includes/widgets/widget-blossomthemes-instagram-feed.php CHANGED
@@ -10,7 +10,7 @@ function btif_register_instagram_widget() {
10
  register_widget( 'BlossomThemes_Instagram_Widget' );
11
  }
12
  add_action( 'widgets_init', 'btif_register_instagram_widget' );
13
-
14
  /**
15
  * Adds BlossomThemes_Instagram_Widget widget.
16
  */
@@ -37,108 +37,39 @@ class BlossomThemes_Instagram_Widget extends WP_Widget {
37
  */
38
  function widget( $args, $instance ) {
39
 
40
- $title = empty( $instance['title'] ) ? '' : $instance['title'];
41
- $limit = empty( $instance['number'] ) ? 6 : $instance['number'];
42
- $per_row = empty( $instance['per_row'] ) ? 5 : $instance['per_row'];
43
- $options = get_option( 'blossomthemes_instagram_feed_settings', true );
44
- $username = empty( $instance['username'] ) ? $options['username'] : $instance['username'];
45
- $profile_link = 'https://www.instagram.com/'.$username ;
46
- $profile_link_text = 'Follow Me!';
47
-
48
- $size = empty( $instance['size'] ) ? 'low_resolution' : $instance['size'];
49
- $sizes = array(
50
- 'img_thumb' => 'thumbnail',
51
- 'img_low' => 'low_resolution',
52
- 'img_standard' => 'standard_resolution'
53
- );
54
 
55
- if ( array_key_exists( $size, $sizes ) )
56
- {
57
- foreach ( $sizes as $key => $value )
58
- {
59
- if($size == $key)
60
- $size = $value;
61
- }
62
- }
63
-
64
- if( isset( $instance['profile_link_text'] ) && $instance['profile_link_text']!='' )
65
- {
66
- $profile_link_text = $instance['profile_link_text'];
67
  }
68
- $meta = isset( $instance['meta'] ) ? 'true' : 'false';
69
 
70
  echo $args['before_widget'];
71
 
72
- if ( $title ) echo $args['before_title'] . apply_filters( 'widget_title', $title, $instance, $this->id_base ) . $args['after_title'];
 
73
 
74
  ob_start();
75
 
76
- $ran = rand(1,100); $ran++;
77
-
78
- $this->api = Blossomthemes_Instagram_Feed_API::getInstance();
79
- $items = $this->api->get_items( $limit, $size );
80
 
81
  add_filter('widget_text','do_shortcode');
82
 
83
  if ( ! is_array( $items ) ) {
84
- if ( current_user_can( 'edit_theme_options' ) ) {
85
- ?>
86
- <p>
87
- <?php _e( 'BlossomThemes Social Feed misconfigured, check plugin &amp; widget settings.', 'blossomthemes-instagram-feed' ); ?>
88
- </p>
89
- <?php
90
  } else {
91
  echo '<b style="color:red;">'.__('No posts available!','blossomthemes-instagram-feed').'</b>';
92
  }
93
  } else {
94
- $count = 0;
95
- echo '<ul class="popup-gallery-'.$ran.' photos-'.$per_row.'">';
96
-
97
- foreach ( $items['items'] as $item )
98
- {
99
- $link = $item['link'];
100
- $img_standard = $item['image-standard'];
101
- $src = $item['image-url'];
102
- $likes = $item['likes_count'];
103
- $comments = $item['comments_count'];
104
- $caption = $item['caption'];
105
-
106
- echo '<li><a href="'.esc_url($img_standard).'"><img src="'.esc_url($src).'" alt="'.html_entity_decode($caption).'"></a>';
107
-
108
- if( isset( $meta ) && $meta == 'true' )
109
- {
110
- echo '<div class="instagram-meta"><span class="like"><i class="fa fa-heart"></i>'.$likes.'</span>'.'<span class="comment"><i class="fa fa-comment"></i>'.$comments.'</span>'.'</div>';
111
- }
112
- echo '</li>';
113
-
114
- if ( ++$count === $limit ) break;
115
- }
116
-
117
- echo '</ul>';
118
- echo
119
- '<script>
120
- jQuery(document).ready(function($){
121
- $(".popup-gallery-'.$ran.'").magnificPopup({
122
- delegate: "a",
123
- type: "image",
124
- gallery:{
125
- enabled:true
126
- }
127
- });
128
-
129
- $(".popup-modal").magnificPopup({
130
- type: "inline",
131
- preloader: false,
132
- focus: "#username",
133
- modal: true
134
- });
135
- $(document).on("click", ".popup-modal-dismiss", function (e) {
136
- e.preventDefault();
137
- $.magnificPopup.close();
138
- });
139
- });
140
- </script>';
141
- echo '<a class="profile-link" href="'.esc_url($profile_link).'" target="_blank" rel="noreferrer">'.esc_attr($profile_link_text).'</a>';
142
  }
143
 
144
  $output = ob_get_clean();
@@ -157,92 +88,31 @@ class BlossomThemes_Instagram_Widget extends WP_Widget {
157
  $default = array(
158
  'title' => __( 'Instagram', 'blossomthemes-instagram-feed' ),
159
  'number' => 6,
160
- 'size' => 'low_resolution',
161
  'per_row' => 5
162
  );
163
  $instance = wp_parse_args( (array) $instance, $default );
164
- $options = get_option( 'blossomthemes_instagram_feed_settings', true );
165
  $username = empty( $instance['username'] ) ? $options['username'] : $instance['username'];
166
  $title = empty( $instance['title'] ) ? '' : $instance['title'];
167
  $limit = empty( $instance['number'] ) ? 6 : $instance['number'];
168
  $per_row = empty( $instance['per_row'] ) ? 5 : $instance['per_row'];
169
- $profile_link = 'https://www.instagram.com/'.$username;
170
  $profile_link_text = 'Follow Me!';
171
- if( isset( $instance['profile_link_text'] ) && $instance['profile_link_text']!='' )
172
- {
173
  $profile_link_text = $instance['profile_link_text'];
174
  }
175
 
176
- $meta = !isset( $instance['meta'] ) ? '' : $instance['meta'];
177
-
178
- $size = empty( $instance['size'] ) ? 'low_resolution' : $instance['size'];
179
- $sizes = array(
180
- 'img_thumb' => 'thumbnail',
181
- 'img_low' => 'low_resolution',
182
- 'img_standard' => 'standard_resolution'
183
- );
184
-
185
- if ( array_key_exists( $size, $sizes ) )
186
- {
187
- foreach ( $sizes as $key => $value )
188
- {
189
- if($size == $key)
190
- $size = $value;
191
- }
192
- }
193
- ?>
194
-
195
- <?php if ( ! Blossomthemes_Instagram_Feed_API::getInstance()->is_configured() ) : ?>
196
 
197
  <p><b style="color: red;">
198
  <?php
199
  printf( __( 'Please configure <a href="%1$s">Plugin Settings</a> before using this widget.', 'blossomthemes-instagram-feed' ),
200
  admin_url( 'admin.php?page=class-blossomthemes-instagram-feed-admin.php' ) );
201
- ?>
202
  </b></p>
203
 
204
- <?php endif; ?>
205
 
206
- <p>
207
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'blossomthemes-instagram-feed' ); ?></label>
208
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
209
- </p>
210
-
211
- <p>
212
- <label for="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>"><?php esc_html_e( 'Username', 'blossomthemes-instagram-feed' ); ?></label>
213
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'username' ) ); ?>" type="text" value="<?php echo esc_attr( $username ); ?>" />
214
- </p>
215
-
216
- <p>
217
- <label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number of photos', 'blossomthemes-instagram-feed' ); ?></label>
218
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="number" min="1" step="1" max="20" value="<?php echo esc_attr( $limit ); ?>" />
219
- </p>
220
-
221
- <p>
222
- <label for="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>"><?php esc_html_e( 'Photo size', 'blossomthemes-instagram-feed' ); ?></label>
223
- <select id="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'size' ) ); ?>" class="widefat">
224
- <option value="thumbnail" <?php selected( 'thumbnail', $size ) ?>><?php esc_html_e( 'Thumbnail', 'blossomthemes-instagram-feed' ); ?></option>
225
- <option value="low_resolution" <?php selected( 'low_resolution', $size ) ?>><?php esc_html_e( 'Small', 'blossomthemes-instagram-feed' ); ?></option>
226
- <option value="standard_resolution" <?php selected( 'standard_resolution', $size ) ?>><?php esc_html_e( 'Large', 'blossomthemes-instagram-feed' ); ?></option>
227
- </select>
228
- </p>
229
-
230
- <p>
231
- <label for="<?php echo esc_attr( $this->get_field_id( 'per_row' ) ); ?>"><?php esc_html_e( 'Photos Per Row', 'blossomthemes-instagram-feed' ); ?></label>
232
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'per_row' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'per_row' ) ); ?>" type="number" min="1" max="5" step="1" value="<?php echo esc_attr( $per_row ); ?>" />
233
- </p>
234
-
235
- <p>
236
- <input type="checkbox" value="1" id="<?php echo esc_attr( $this->get_field_id( 'meta' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'meta' ) ); ?>" <?php if ( isset( $meta ) ) { checked( $meta, true );} ?>>
237
- <label for="<?php echo esc_attr( $this->get_field_id( 'meta' ) ); ?>"><?php esc_html_e( 'Display Comments/Likes', 'blossomthemes-instagram-feed' ); ?></label>
238
- </p>
239
-
240
- <p>
241
- <label for="<?php echo esc_attr( $this->get_field_id( 'profile_link_text' ) ); ?>"><?php esc_html_e( 'Profile Link Text', 'blossomthemes-instagram-feed' ); ?></label>
242
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'profile_link_text' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'profile_link_text' ) ); ?>" type="text" value="<?php echo esc_attr( $profile_link_text ); ?>" />
243
- </p>
244
-
245
- <?php
246
  }
247
 
248
  /**
@@ -258,14 +128,11 @@ class BlossomThemes_Instagram_Widget extends WP_Widget {
258
  function update( $new_instance, $old_instance ) {
259
  $instance = $old_instance;
260
 
261
- $instance['title'] = strip_tags( $new_instance['title'] );
262
- $instance['number'] = ! absint( $new_instance['number'] ) ? 6 : $new_instance['number'];
263
- $instance['size'] = $new_instance['size'];
264
- $instance['per_row'] = ! absint( $new_instance['per_row'] ) ? 5 : $new_instance['per_row'];
265
- $instance['meta'] = $new_instance['meta'];
266
- $instance['username'] = $new_instance['username'] ;
267
- $instance['profile_link'] = 'https://www.instagram.com/'. $instance['username'];
268
- $instance['profile_link_text'] = $new_instance['profile_link_text'] ;
269
 
270
  return $instance;
271
  }
10
  register_widget( 'BlossomThemes_Instagram_Widget' );
11
  }
12
  add_action( 'widgets_init', 'btif_register_instagram_widget' );
13
+
14
  /**
15
  * Adds BlossomThemes_Instagram_Widget widget.
16
  */
37
  */
38
  function widget( $args, $instance ) {
39
 
40
+ $settings = BlossomThemes_Instagram_Feed_Settings::get_settings();
41
+ $title = empty( $instance['title'] ) ? '' : $instance['title'];
42
+ $settings['photos'] = empty( $instance['number'] ) ? 6 : $instance['number'];
43
+ $settings['photos_row'] = empty( $instance['per_row'] ) ? 5 : $instance['per_row'];
44
+ $username = empty( $instance['username'] ) ? $options['username'] : $instance['username'];
45
+ $instaUrl = 'https://www.instagram.com/'.$username ;
46
+ $settings['follow_me'] = 'Follow Me!';
 
 
 
 
 
 
 
47
 
48
+ if( isset( $instance['profile_link_text'] ) && $instance['profile_link_text']!='' ){
49
+ $settings['follow_me'] = $instance['profile_link_text'];
 
 
 
 
 
 
 
 
 
 
50
  }
 
51
 
52
  echo $args['before_widget'];
53
 
54
+ if ( $title )
55
+ echo $args['before_title'] . apply_filters( 'widget_title', $title, $instance, $this->id_base ) . $args['after_title'];
56
 
57
  ob_start();
58
 
59
+ $this->api = Blossomthemes_Instagram_Feed_API::get_instance();
60
+ $items = $this->api->get_items( $settings['photos'] );
 
 
61
 
62
  add_filter('widget_text','do_shortcode');
63
 
64
  if ( ! is_array( $items ) ) {
65
+ if ( current_user_can( 'edit_theme_options' ) ) {
66
+ echo '<p>'.__( 'BlossomThemes Social Feed misconfigured, check plugin &amp; widget settings.',
67
+ 'blossomthemes-instagram-feed' ).'</p>';
 
 
 
68
  } else {
69
  echo '<b style="color:red;">'.__('No posts available!','blossomthemes-instagram-feed').'</b>';
70
  }
71
  } else {
72
+ require plugin_dir_path( BTIF_FILE_PATH ) . 'public/partials/blossomthemes-instagram-feed-public-display.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
 
75
  $output = ob_get_clean();
88
  $default = array(
89
  'title' => __( 'Instagram', 'blossomthemes-instagram-feed' ),
90
  'number' => 6,
 
91
  'per_row' => 5
92
  );
93
  $instance = wp_parse_args( (array) $instance, $default );
94
+ $options = BlossomThemes_Instagram_Feed_Settings::get_settings();
95
  $username = empty( $instance['username'] ) ? $options['username'] : $instance['username'];
96
  $title = empty( $instance['title'] ) ? '' : $instance['title'];
97
  $limit = empty( $instance['number'] ) ? 6 : $instance['number'];
98
  $per_row = empty( $instance['per_row'] ) ? 5 : $instance['per_row'];
 
99
  $profile_link_text = 'Follow Me!';
100
+ if( isset( $instance['profile_link_text'] ) && $instance['profile_link_text']!='' ){
 
101
  $profile_link_text = $instance['profile_link_text'];
102
  }
103
 
104
+ if ( ! Blossomthemes_Instagram_Feed_API::get_instance()->is_configured() ) : ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  <p><b style="color: red;">
107
  <?php
108
  printf( __( 'Please configure <a href="%1$s">Plugin Settings</a> before using this widget.', 'blossomthemes-instagram-feed' ),
109
  admin_url( 'admin.php?page=class-blossomthemes-instagram-feed-admin.php' ) );
110
+ ?>
111
  </b></p>
112
 
113
+ <?php endif;
114
 
115
+ require plugin_dir_path( BTIF_FILE_PATH ) . 'admin/partials/blossomthemes-instagram-feed-admin-display.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
 
118
  /**
128
  function update( $new_instance, $old_instance ) {
129
  $instance = $old_instance;
130
 
131
+ $instance['title'] = strip_tags( $new_instance['title'] );
132
+ $instance['number'] = ! absint( $new_instance['number'] ) ? 6 : $new_instance['number'];
133
+ $instance['per_row'] = ! absint( $new_instance['per_row'] ) ? 5 : $new_instance['per_row'];
134
+ $instance['username'] = $new_instance['username'] ;
135
+ $instance['profile_link_text'] = $new_instance['profile_link_text'] ;
 
 
 
136
 
137
  return $instance;
138
  }
languages/blossomthemes-instagram-feed.pot CHANGED
@@ -1,14 +1,14 @@
1
- # Copyright (C) 2019 blossomthemes
2
  # This file is distributed under the GPL-2.0+.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: BlossomThemes Social Feed 1.2.0\n"
6
  "Report-Msgid-Bugs-To: \n"
7
- "POT-Creation-Date: 2019-11-18 09:50:39+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2019-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: WP Travel Engine\n"
13
  "Language-Team: \n"
14
  "X-Poedit-KeywordsList: "
@@ -53,32 +53,59 @@ msgstr ""
53
  msgid "Dismiss this notice"
54
  msgstr ""
55
 
56
- #: includes/class-blossomthemes-instagram-feed-shortcodes.php:35
57
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  msgid "BlossomThemes Social Feed misconfigured, check plugin &amp; widget settings."
59
  msgstr ""
60
 
61
- #: includes/class-blossomthemes-instagram-feed-shortcodes.php:39
62
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:91
63
  msgid "No posts available!"
64
  msgstr ""
65
 
66
- #: includes/template/backend/general.php:8
67
- #: includes/template/backend/general.php:25
68
  msgid "Connect with Instagram"
69
  msgstr ""
70
 
71
- #: includes/template/backend/general.php:10
72
  msgid ""
73
  "To get started click the button below. You’ll be prompted to authorize "
74
  "BlossomThemes Social Feed to access your Instagram photos."
75
  msgstr ""
76
 
77
- #: includes/template/backend/general.php:12
78
- msgid "For help, please refer to this video tutorial."
79
  msgstr ""
80
 
81
- #: includes/template/backend/general.php:17
82
  msgid ""
83
  "Due to recent Instagram API changes it is no longer possible to display "
84
  "photos from a different Instagram account than yours. The widget will "
@@ -86,80 +113,37 @@ msgid ""
86
  "on this page."
87
  msgstr ""
88
 
89
- #: includes/template/backend/general.php:27
90
  msgid "Re-connect with Instagram"
91
  msgstr ""
92
 
93
- #: includes/template/backend/general.php:35
94
  msgid "Access Token"
95
  msgstr ""
96
 
97
- #: includes/template/backend/general.php:44
98
  msgid ""
99
  "Access Token is used as key to access your photos from Instagram so they "
100
  "can be displayed."
101
  msgstr ""
102
 
103
- #: includes/template/backend/general.php:51
104
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:212
105
- msgid "Username"
106
- msgstr ""
107
-
108
- #: includes/template/backend/general.php:62
109
  msgid "Number of Photos"
110
  msgstr ""
111
 
112
- #: includes/template/backend/general.php:73
113
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:222
114
- msgid "Photo size"
115
- msgstr ""
116
-
117
- #: includes/template/backend/general.php:77
118
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:224
119
- msgid "Thumbnail"
120
- msgstr ""
121
-
122
- #: includes/template/backend/general.php:80
123
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:225
124
- msgid "Small"
125
- msgstr ""
126
-
127
- #: includes/template/backend/general.php:83
128
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:226
129
- msgid "Large"
130
- msgstr ""
131
-
132
- #: includes/template/backend/general.php:92
133
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:231
134
- msgid "Photos Per Row"
135
- msgstr ""
136
-
137
- #: includes/template/backend/general.php:103
138
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:241
139
- msgid "Profile Link Text"
140
- msgstr ""
141
-
142
- #: includes/template/backend/general.php:114
143
- msgid "Show Likes/Comments"
144
- msgstr ""
145
-
146
- #: includes/template/backend/general.php:123
147
  msgid "Check for new posts every"
148
  msgstr ""
149
 
150
- #: includes/template/backend/general.php:135
151
  msgid "Hours"
152
  msgstr ""
153
 
154
- #: includes/template/backend/general.php:136
155
  msgid "Days"
156
  msgstr ""
157
 
158
- #: includes/template/backend/general.php:137
159
- msgid "Minutes"
160
- msgstr ""
161
-
162
- #: includes/template/backend/general.php:141
163
  msgid "Fetch new posts"
164
  msgstr ""
165
 
@@ -175,23 +159,23 @@ msgstr ""
175
  msgid "Usage"
176
  msgstr ""
177
 
178
- #: includes/template/backend/sidebar.php:3
179
  msgid "More WordPress Themes and Plugins?"
180
  msgstr ""
181
 
182
- #: includes/template/backend/sidebar.php:5
183
  msgid "Visit us at: "
184
  msgstr ""
185
 
186
- #: includes/template/backend/sidebar.php:6
187
  msgid "Blossom Themes"
188
  msgstr ""
189
 
190
- #: includes/template/backend/sidebar.php:9
191
  msgid "Please fill free to leave us a review, if you found this plugin helpful."
192
  msgstr ""
193
 
194
- #: includes/template/backend/sidebar.php:10
195
  msgid "Leave a Review"
196
  msgstr ""
197
 
@@ -223,28 +207,16 @@ msgstr ""
223
  msgid "A widget that displays your latest Instagram photos."
224
  msgstr ""
225
 
226
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:158
227
  msgid "Instagram"
228
  msgstr ""
229
 
230
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:199
231
  msgid ""
232
  "Please configure <a href=\"%1$s\">Plugin Settings</a> before using this "
233
  "widget."
234
  msgstr ""
235
 
236
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:207
237
- msgid "Title"
238
- msgstr ""
239
-
240
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:217
241
- msgid "Number of photos"
242
- msgstr ""
243
-
244
- #: includes/widgets/widget-blossomthemes-instagram-feed.php:237
245
- msgid "Display Comments/Likes"
246
- msgstr ""
247
-
248
  #. Plugin URI of the plugin/theme
249
  msgid "https://wordpress.org/plugins/blossomthemes-instagram-feed"
250
  msgstr ""
1
+ # Copyright (C) 2020 blossomthemes
2
  # This file is distributed under the GPL-2.0+.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: BlossomThemes Social Feed 2.0.0\n"
6
  "Report-Msgid-Bugs-To: \n"
7
+ "POT-Creation-Date: 2020-03-17 07:11:08+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: WP Travel Engine\n"
13
  "Language-Team: \n"
14
  "X-Poedit-KeywordsList: "
53
  msgid "Dismiss this notice"
54
  msgstr ""
55
 
56
+ #: admin/partials/blossomthemes-instagram-feed-admin-display.php:19
57
+ msgid "Title"
58
+ msgstr ""
59
+
60
+ #: admin/partials/blossomthemes-instagram-feed-admin-display.php:28
61
+ #: includes/template/backend/general.php:52
62
+ msgid "Username"
63
+ msgstr ""
64
+
65
+ #: admin/partials/blossomthemes-instagram-feed-admin-display.php:37
66
+ msgid "Number of photos"
67
+ msgstr ""
68
+
69
+ #: admin/partials/blossomthemes-instagram-feed-admin-display.php:47
70
+ #: includes/template/backend/general.php:74
71
+ msgid "Photos Per Row"
72
+ msgstr ""
73
+
74
+ #: admin/partials/blossomthemes-instagram-feed-admin-display.php:57
75
+ #: includes/template/backend/general.php:85
76
+ msgid "Profile Link Text"
77
+ msgstr ""
78
+
79
+ #: includes/class-blossomthemes-instagram-feed-api.php:167
80
+ msgid "Every Fifty Days"
81
+ msgstr ""
82
+
83
+ #: includes/class-blossomthemes-instagram-feed-shortcodes.php:32
84
+ #: includes/widgets/widget-blossomthemes-instagram-feed.php:66
85
  msgid "BlossomThemes Social Feed misconfigured, check plugin &amp; widget settings."
86
  msgstr ""
87
 
88
+ #: includes/class-blossomthemes-instagram-feed-shortcodes.php:35
89
+ #: includes/widgets/widget-blossomthemes-instagram-feed.php:69
90
  msgid "No posts available!"
91
  msgstr ""
92
 
93
+ #: includes/template/backend/general.php:9
94
+ #: includes/template/backend/general.php:26
95
  msgid "Connect with Instagram"
96
  msgstr ""
97
 
98
+ #: includes/template/backend/general.php:11
99
  msgid ""
100
  "To get started click the button below. You’ll be prompted to authorize "
101
  "BlossomThemes Social Feed to access your Instagram photos."
102
  msgstr ""
103
 
104
+ #: includes/template/backend/general.php:13
105
+ msgid "For help, please refer to this tutorial."
106
  msgstr ""
107
 
108
+ #: includes/template/backend/general.php:18
109
  msgid ""
110
  "Due to recent Instagram API changes it is no longer possible to display "
111
  "photos from a different Instagram account than yours. The widget will "
113
  "on this page."
114
  msgstr ""
115
 
116
+ #: includes/template/backend/general.php:28
117
  msgid "Re-connect with Instagram"
118
  msgstr ""
119
 
120
+ #: includes/template/backend/general.php:36
121
  msgid "Access Token"
122
  msgstr ""
123
 
124
+ #: includes/template/backend/general.php:45
125
  msgid ""
126
  "Access Token is used as key to access your photos from Instagram so they "
127
  "can be displayed."
128
  msgstr ""
129
 
130
+ #: includes/template/backend/general.php:63
 
 
 
 
 
131
  msgid "Number of Photos"
132
  msgstr ""
133
 
134
+ #: includes/template/backend/general.php:96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  msgid "Check for new posts every"
136
  msgstr ""
137
 
138
+ #: includes/template/backend/general.php:108
139
  msgid "Hours"
140
  msgstr ""
141
 
142
+ #: includes/template/backend/general.php:109
143
  msgid "Days"
144
  msgstr ""
145
 
146
+ #: includes/template/backend/general.php:113
 
 
 
 
147
  msgid "Fetch new posts"
148
  msgstr ""
149
 
159
  msgid "Usage"
160
  msgstr ""
161
 
162
+ #: includes/template/backend/sidebar.php:8
163
  msgid "More WordPress Themes and Plugins?"
164
  msgstr ""
165
 
166
+ #: includes/template/backend/sidebar.php:10
167
  msgid "Visit us at: "
168
  msgstr ""
169
 
170
+ #: includes/template/backend/sidebar.php:11
171
  msgid "Blossom Themes"
172
  msgstr ""
173
 
174
+ #: includes/template/backend/sidebar.php:14
175
  msgid "Please fill free to leave us a review, if you found this plugin helpful."
176
  msgstr ""
177
 
178
+ #: includes/template/backend/sidebar.php:15
179
  msgid "Leave a Review"
180
  msgstr ""
181
 
207
  msgid "A widget that displays your latest Instagram photos."
208
  msgstr ""
209
 
210
+ #: includes/widgets/widget-blossomthemes-instagram-feed.php:89
211
  msgid "Instagram"
212
  msgstr ""
213
 
214
+ #: includes/widgets/widget-blossomthemes-instagram-feed.php:108
215
  msgid ""
216
  "Please configure <a href=\"%1$s\">Plugin Settings</a> before using this "
217
  "widget."
218
  msgstr ""
219
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  #. Plugin URI of the plugin/theme
221
  msgid "https://wordpress.org/plugins/blossomthemes-instagram-feed"
222
  msgstr ""
public/css/blossomthemes-instagram-feed-public.min.css CHANGED
@@ -1 +1,47 @@
1
- #primary .page .entry-content .popup-gallery li .instagram-meta,#primary .post .entry-content .popup-gallery li .instagram-meta,.widget_btif_instagram_widget ul li .instagram-meta{left:0;bottom:0;color:#fff;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000',endColorstr='#a6000000',GradientType=0)}.white-popup-block{background:#FFF;padding:20px 30px;text-align:left;max-width:650px;margin:40px auto;position:relative}.widget_btif_instagram_widget ul:after{content:'';display:block;clear:both}.widget_btif_instagram_widget ul{margin:0 -1px!important}.widget_btif_instagram_widget ul li{float:left;width:33.3333%;padding:0 1px!important;margin:0 0 2px!important;position:relative}.widget_btif_instagram_widget ul li .instagram-meta{position:absolute;width:100%;padding:5px 10px;opacity:0;-webkit-transition:linear .2s;-moz-transition:linear .2s;transition:linear .2s;background:-moz-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,.65) 100%);background:-webkit-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,.65) 100%);background:linear-gradient(to bottom,rgba(0,0,0,0) 0,rgba(0,0,0,.65) 100%)}.widget_btif_instagram_widget ul.photos-4 li .instagram-meta,.widget_btif_instagram_widget ul.photos-5 li .instagram-meta{display:none}.widget_btif_instagram_widget ul li:hover .instagram-meta{opacity:1}.widget_btif_instagram_widget ul li .instagram-meta .fa-comment{float:right}.widget_btif_instagram_widget ul li img{vertical-align:top;width:100%}.widget_btif_instagram_widget ul.photos-1 li{width:100%}.widget_btif_instagram_widget ul.photos-2 li{width:50%}.widget_btif_instagram_widget ul.photos-4 li{width:25%}.widget_btif_instagram_widget ul.photos-5 li{width:20%}#primary .page .entry-content .popup-gallery,#primary .post .entry-content .popup-gallery{margin:0 -1px;padding:0;list-style:none}#primary .page .entry-content .popup-gallery:after,#primary .post .entry-content .popup-gallery:after{content:'';display:block;clear:both}#primary .page .entry-content .popup-gallery li,#primary .post .entry-content .popup-gallery li{float:left;width:33.3333%;padding:0 1px;margin:0 0 2px;position:relative}#primary .page .entry-content .popup-gallery li .instagram-meta,#primary .post .entry-content .popup-gallery li .instagram-meta{position:absolute;width:100%;padding:5px 10px;opacity:0;-webkit-transition:linear .2s;-moz-transition:linear .2s;transition:linear .2s;background:-moz-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,.65) 100%);background:-webkit-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,.65) 100%);background:linear-gradient(to bottom,rgba(0,0,0,0) 0,rgba(0,0,0,.65) 100%);display:flex;flex:1;flex-wrap:wrap;justify-content:flex-end;align-items:center}#primary .page .entry-content .popup-gallery li:hover .instagram-meta,#primary .post .entry-content .popup-gallery li:hover .instagram-meta{opacity:1}#primary .page .entry-content .popup-gallery li .instagram-meta span,#primary .post .entry-content .popup-gallery li .instagram-meta span{display:flex;flex:auto;align-items:center}#primary .page .entry-content .popup-gallery li .instagram-meta span.comment,#primary .post .entry-content .popup-gallery li .instagram-meta span.comment{justify-content:flex-end}#primary .page .entry-content .popup-gallery li .instagram-meta span svg,#primary .post .entry-content .popup-gallery li .instagram-meta span svg{margin-right:5px}#primary .page .entry-content .popup-gallery li img,#primary .post .entry-content .popup-gallery li img{vertical-align:top;width:100%}#primary .page .entry-content .popup-gallery.photos-1 li,#primary .post .entry-content .popup-gallery.photos-1 li{width:100%}#primary .page .entry-content .popup-gallery.photos-2 li,#primary .post .entry-content .popup-gallery.photos-2 li{width:50%}#primary .page .entry-content .popup-gallery.photos-4 li,#primary .post .entry-content .popup-gallery.photos-4 li{width:25%}#primary .page .entry-content .popup-gallery.photos-5 li,#primary .post .entry-content .popup-gallery.photos-5 li{width:20%}@media only screen and (max-width:767px){#primary .page .entry-content .popup-gallery.photos-2 li,#primary .page .entry-content .popup-gallery.photos-4 li,#primary .page .entry-content .popup-gallery.photos-5 li,#primary .post .entry-content .popup-gallery.photos-2 li,#primary .post .entry-content .popup-gallery.photos-4 li,#primary .post .entry-content .popup-gallery.photos-5 li,.widget_btif_instagram_widget ul.photos-2 li,.widget_btif_instagram_widget ul.photos-4 li,.widget_btif_instagram_widget ul.photos-5 li{width:100%}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .popup-gallery:not(.photos-1) {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ margin: 0;
5
+ padding: 0;
6
+ list-style: none;
7
+ }
8
+
9
+ .popup-gallery.photos-2 li {
10
+ width: 50%;
11
+ }
12
+
13
+ .popup-gallery.photos-3 li {
14
+ width: 33.33%;
15
+ }
16
+
17
+ .popup-gallery.photos-4 li {
18
+ width: 25%;
19
+ }
20
+
21
+ .popup-gallery.photos-5 li {
22
+ width: 20%;
23
+ }
24
+
25
+ .popup-gallery.photos-6 li {
26
+ width: 16.66%;
27
+ }
28
+
29
+ .popup-gallery.photos-7 li {
30
+ width: 14.25%;
31
+ }
32
+
33
+ .popup-gallery.photos-8 li {
34
+ width: 12.5%;
35
+ }
36
+
37
+ .popup-gallery.photos-9 li {
38
+ width: 11.11%;
39
+ }
40
+
41
+ .popup-gallery.photos-10 li {
42
+ width: 10%;
43
+ }
44
+
45
+ .popup-gallery:not(.photos-1) ul li img {
46
+ vertical-align: top;
47
+ }
public/partials/blossomthemes-instagram-feed-public-display.php CHANGED
@@ -14,3 +14,25 @@
14
  ?>
15
 
16
  <!-- This file should primarily consist of HTML with a little bit of PHP. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  ?>
15
 
16
  <!-- This file should primarily consist of HTML with a little bit of PHP. -->
17
+ <ul class="popup-gallery photos-<?php echo $settings['photos_row'];?>">
18
+ <?php foreach ( $items as $item ) : ?>
19
+ <li>
20
+ <?php if( 'VIDEO' === $item->media_type ) : ?>
21
+ <a href="<?php echo esc_url($item->media_url); ?>" class="mfp-iframe">
22
+ <img src="<?php echo esc_url($item->thumbnail_url); ?>"
23
+ alt="<?php echo html_entity_decode($item->caption); ?>">
24
+ </a>
25
+ <?php else: ?>
26
+ <a href="<?php echo esc_url($item->media_url); ?>">
27
+ <img src="<?php echo esc_url($item->media_url); ?>"
28
+ alt="<?php echo html_entity_decode($item->caption); ?>">
29
+ </a>
30
+ <?php endif; ?>
31
+ </li>
32
+ <?php endforeach; ?>
33
+ </ul>
34
+
35
+ <a class="profile-link" href="<?php echo esc_url($instaUrl);?>" target="_blank" rel="noreferrer">
36
+ <span class="insta-icon"><i class="fab fa-instagram"></i></span><?php echo esc_html( $settings['follow_me'] );?>
37
+ </a>
38
+ <?php