Instagram Feed - Version 2.9

Version Description

  • New: Added support for IGTV posts. When creating an IGTV post, keep the "Post a Preview" setting enabled and the IGTV post will appear in your feed. IGTV posts are only available for connected Instagram business profiles and aren't available if you're using a personal Instagram profile in the plugin.
  • Fix: Fixed a PHP error when the HTTP request to refresh an access token resulted in an error.
Download this release

Release Info

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

Code changes from version 2.8.2 to 2.9

README.txt CHANGED
@@ -2,8 +2,8 @@
2
  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.8.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -332,6 +332,10 @@ 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.8.2 =
336
  * Fix: Changed how access tokens are retrieved to prevent conflict with the "Rank Math SEO" plugin when connecting an account.
337
  * Fix: Updated jQuery methods for compatibility with WordPress 5.7.
2
  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.7
6
+ Stable tag: 2.9
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.9 =
336
+ * New: Added support for IGTV posts. When creating an IGTV post, keep the "Post a Preview" setting enabled and the IGTV post will appear in your feed. IGTV posts are only available for connected Instagram business profiles and aren't available if you're using a personal Instagram profile in the plugin.
337
+ * Fix: Fixed a PHP error when the HTTP request to refresh an access token resulted in an error.
338
+
339
  = 2.8.2 =
340
  * Fix: Changed how access tokens are retrieved to prevent conflict with the "Rank Math SEO" plugin when connecting an account.
341
  * Fix: Updated jQuery methods for compatibility with WordPress 5.7.
inc/class-sb-instagram-api-connect.php CHANGED
@@ -57,11 +57,14 @@ class SB_Instagram_API_Connect
57
  /**
58
  * Returns the response from Instagram
59
  *
60
- * @return object
61
  *
62
  * @since 2.0/5.0
63
  */
64
  public function get_data() {
 
 
 
65
  if (!empty($this->response['data'])) {
66
  return $this->response['data'];
67
  } else {
@@ -265,7 +268,7 @@ class SB_Instagram_API_Connect
265
  $url = 'https://graph.facebook.com/' . $connected_account['user_id'] . '?fields=biography,id,username,website,followers_count,media_count,profile_picture_url,name&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
266
  } else {
267
  $num = min( $num, 200 );
268
- $url = 'https://graph.facebook.com/' . $connected_account['user_id'] . '/media?fields=media_url,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children%7Bmedia_url,id,media_type,timestamp,permalink,thumbnail_url%7D&limit='.$num.'&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
269
  }
270
  }
271
 
57
  /**
58
  * Returns the response from Instagram
59
  *
60
+ * @return array|object
61
  *
62
  * @since 2.0/5.0
63
  */
64
  public function get_data() {
65
+ if ( $this->is_wp_error() ) {
66
+ return array();
67
+ }
68
  if (!empty($this->response['data'])) {
69
  return $this->response['data'];
70
  } else {
268
  $url = 'https://graph.facebook.com/' . $connected_account['user_id'] . '?fields=biography,id,username,website,followers_count,media_count,profile_picture_url,name&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
269
  } else {
270
  $num = min( $num, 200 );
271
+ $url = 'https://graph.facebook.com/v10.0/' . $connected_account['user_id'] . '/media?fields=media_url,media_product_type,video_title,thumbnail_url,caption,id,media_type,timestamp,username,comments_count,like_count,permalink,children%7Bmedia_url,id,media_type,timestamp,permalink,thumbnail_url%7D&limit='.$num.'&access_token=' . sbi_maybe_clean( $connected_account['access_token'] );
272
  }
273
  }
274
 
inc/class-sb-instagram-display-elements.php CHANGED
@@ -19,18 +19,26 @@ class SB_Instagram_Display_Elements
19
  * except if the js image loading is disabled using the plugin
20
  * settings
21
  *
22
- * @param $settings
 
23
  *
24
  * @return string
25
  *
26
  * @since 2.0/5.0
27
  */
28
- public static function get_item_classes( $settings ) {
 
29
  if ( !$settings['disable_js_image_loading'] ) {
30
- return ' sbi_new sbi_transition';
31
  } else {
32
- return ' sbi_new sbi_no_js sbi_no_resraise sbi_js_load_disabled';
33
  }
 
 
 
 
 
 
34
  }
35
 
36
  /**
19
  * except if the js image loading is disabled using the plugin
20
  * settings
21
  *
22
+ * @param array $settings
23
+ * @param array|bool $post
24
  *
25
  * @return string
26
  *
27
  * @since 2.0/5.0
28
  */
29
+ public static function get_item_classes( $settings, $post = false ) {
30
+ $classes = '';
31
  if ( !$settings['disable_js_image_loading'] ) {
32
+ $classes .= ' sbi_new sbi_transition';
33
  } else {
34
+ $classes .= ' sbi_new sbi_no_js sbi_no_resraise sbi_js_load_disabled';
35
  }
36
+
37
+ if ( $post && SB_Instagram_Parse::get_media_product_type( $post ) === 'igtv' ) {
38
+ $classes .= ' sbi_igtv';
39
+ }
40
+
41
+ return $classes;
42
  }
43
 
44
  /**
inc/class-sb-instagram-parse.php CHANGED
@@ -246,6 +246,12 @@ class SB_Instagram_Parse
246
  $caption = $post['caption']['text'];
247
  }
248
 
 
 
 
 
 
 
249
  return $caption;
250
  }
251
 
@@ -360,4 +366,38 @@ class SB_Instagram_Parse
360
  return $permalink;
361
 
362
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
  }
246
  $caption = $post['caption']['text'];
247
  }
248
 
249
+ $video_title = SB_Instagram_Parse::get_video_title( $post );
250
+
251
+ if ( ! empty( $video_title ) ) {
252
+ $caption = $video_title .'. ' . $caption;
253
+ }
254
+
255
  return $caption;
256
  }
257
 
366
  return $permalink;
367
 
368
  }
369
+
370
+ /**
371
+ * New in IG Graph API 10.0. A title for IGTV posts
372
+ *
373
+ * @param array $post
374
+ *
375
+ * @return string
376
+ *
377
+ * @since 2.9/5.12
378
+ */
379
+ public static function get_video_title( $post ) {
380
+ if ( isset( $post['video_title'] ) ) {
381
+ return $post['video_title'];
382
+ }
383
+
384
+ return '';
385
+ }
386
+
387
+ /**
388
+ * New in IG Graph API 10.0
389
+ *
390
+ * @param array $post
391
+ *
392
+ * @return string
393
+ *
394
+ * @since 2.9/5.12
395
+ */
396
+ public static function get_media_product_type( $post ) {
397
+ if ( isset( $post['media_product_type'] ) ) {
398
+ return strtolower( $post['media_product_type'] );
399
+ }
400
+
401
+ return 'feed';
402
+ }
403
  }
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.8.2
7
  Author: Smash Balloon
8
  Author URI: https://smashballoon.com/
9
  License: GPLv2 or later
@@ -23,7 +23,7 @@ along with this program; if not, write to the Free Software
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
  if ( ! defined( 'SBIVER' ) ) {
26
- define( 'SBIVER', '2.8.2' );
27
  }
28
  // Db version.
29
  if ( ! defined( 'SBI_DBVERSION' ) ) {
3
  Plugin Name: Smash Balloon Instagram Feed
4
  Plugin URI: https://smashballoon.com/instagram-feed
5
  Description: Display beautifully clean, customizable, and responsive Instagram feeds.
6
+ Version: 2.9
7
  Author: Smash Balloon
8
  Author URI: https://smashballoon.com/
9
  License: GPLv2 or later
23
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
  */
25
  if ( ! defined( 'SBIVER' ) ) {
26
+ define( 'SBIVER', '2.9' );
27
  }
28
  // Db version.
29
  if ( ! defined( 'SBI_DBVERSION' ) ) {
templates/feed.php CHANGED
@@ -3,7 +3,7 @@
3
  * Smash Balloon Instagram Feed Main Template
4
  * Creates the wrapping HTML and adds settings as attributes
5
  *
6
- * @version 2.5 Instagram Feed by Smash Balloon
7
  *
8
  */
9
  // Don't load directly
3
  * Smash Balloon Instagram Feed Main Template
4
  * Creates the wrapping HTML and adds settings as attributes
5
  *
6
+ * @version 2.9 Instagram Feed by Smash Balloon
7
  *
8
  */
9
  // Don't load directly
templates/footer.php CHANGED
@@ -3,7 +3,7 @@
3
  * Smash Balloon Instagram Feed Footer Template
4
  * Adds pagination and html for errors and resized images
5
  *
6
- * @version 2.5 Instagram Feed by Smash Balloon
7
  *
8
  */
9
 
3
  * Smash Balloon Instagram Feed Footer Template
4
  * Adds pagination and html for errors and resized images
5
  *
6
+ * @version 2.9 Instagram Feed by Smash Balloon
7
  *
8
  */
9
 
templates/header.php CHANGED
@@ -3,7 +3,7 @@
3
  * Smash Balloon Instagram Feed Header Template
4
  * Adds account information and an avatar to the top of the feed
5
  *
6
- * @version 2.5 Instagram Feed by Smash Balloon
7
  *
8
  */
9
 
3
  * Smash Balloon Instagram Feed Header Template
4
  * Adds account information and an avatar to the top of the feed
5
  *
6
+ * @version 2.9 Instagram Feed by Smash Balloon
7
  *
8
  */
9
 
templates/item.php CHANGED
@@ -3,7 +3,7 @@
3
  * Smash Balloon Instagram Feed Item Template
4
  * Adds an image, link, and other data for each post in the feed
5
  *
6
- * @version 2.5 Instagram Feed by Smash Balloon
7
  *
8
  */
9
 
@@ -11,7 +11,7 @@
11
  if ( ! defined( 'ABSPATH' ) ) {
12
  die( '-1' );
13
  }
14
- $classes = SB_Instagram_Display_Elements::get_item_classes( $settings, $offset );
15
  $post_id = SB_Instagram_Parse::get_post_id( $post );
16
  $timestamp = SB_Instagram_Parse::get_timestamp( $post );
17
  $media_type = SB_Instagram_Parse::get_media_type( $post );
3
  * Smash Balloon Instagram Feed Item Template
4
  * Adds an image, link, and other data for each post in the feed
5
  *
6
+ * @version 2.9 Instagram Feed by Smash Balloon
7
  *
8
  */
9
 
11
  if ( ! defined( 'ABSPATH' ) ) {
12
  die( '-1' );
13
  }
14
+ $classes = SB_Instagram_Display_Elements::get_item_classes( $settings, $post );
15
  $post_id = SB_Instagram_Parse::get_post_id( $post );
16
  $timestamp = SB_Instagram_Parse::get_timestamp( $post );
17
  $media_type = SB_Instagram_Parse::get_media_type( $post );