WP Instagram Widget - Version 2.0.2

Version Description

  • Use image sizes from JSON due to errors loading images
Download this release

Release Info

Developer scottsweb
Plugin Icon 128x128 WP Instagram Widget
Version 2.0.2
Comparing to
See all releases

Code changes from version 2.0.1 to 2.0.2

Files changed (3) hide show
  1. readme.md +3 -0
  2. readme.txt +4 -1
  3. wp-instagram-widget.php +10 -27
readme.md CHANGED
@@ -84,6 +84,9 @@ In version 1.9.6 you can now use a filter to change the location of your custom
84
 
85
  ## Changelog
86
 
 
 
 
87
  #### 2.0.1
88
  * Fix hashtag support
89
 
84
 
85
  ## Changelog
86
 
87
+ #### 2.0.2
88
+ * Use image sizes from JSON due to errors loading images
89
+
90
  #### 2.0.1
91
  * Fix hashtag support
92
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: scottsweb, codeforthepeople
3
  Tags: instagram, widget, photos, photography, hipster, sidebar, widgets, simple
4
  Requires at least: 4.4
5
  Tested up to: 4.9.1
6
- Stable tag: 2.0.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -80,6 +80,9 @@ In version 1.9.6 you can now use a filter to change the location of your custom
80
 
81
  == Changelog ==
82
 
 
 
 
83
  = 2.0.1 =
84
  * Fix hashtag support
85
 
3
  Tags: instagram, widget, photos, photography, hipster, sidebar, widgets, simple
4
  Requires at least: 4.4
5
  Tested up to: 4.9.1
6
+ Stable tag: 2.0.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
80
 
81
  == Changelog ==
82
 
83
+ = 2.0.2 =
84
+ * Use image sizes from JSON due to errors loading images
85
+
86
  = 2.0.1 =
87
  * Fix hashtag support
88
 
wp-instagram-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Instagram Widget
4
  Plugin URI: https://github.com/scottsweb/wp-instagram-widget
5
  Description: A WordPress widget for showing your latest Instagram photos.
6
- Version: 2.0.1
7
  Author: Scott Evans
8
  Author URI: https://scott.ee
9
  Text Domain: wp-instagram-widget
@@ -188,7 +188,7 @@ Class null_instagram_widget extends WP_Widget {
188
 
189
  $username = trim( strtolower( $username ) );
190
 
191
- if ( false === ( $instagram = get_transient( 'instagram-a8-' . sanitize_title_with_dashes( $username ) ) ) ) {
192
 
193
  switch ( substr( $username, 0, 1 ) ) {
194
  case '#':
@@ -233,7 +233,8 @@ Class null_instagram_widget extends WP_Widget {
233
  $instagram = array();
234
 
235
  foreach ( $images as $image ) {
236
- // the hashtag json is now completely different
 
237
  switch ( substr( $username, 0, 1 ) ) {
238
  case '#':
239
  if ( true === $image['node']['is_video'] ) {
@@ -253,7 +254,7 @@ Class null_instagram_widget extends WP_Widget {
253
  'time' => $image['node']['taken_at_timestamp'],
254
  'comments' => $image['node']['edge_media_to_comment']['count'],
255
  'likes' => $image['node']['edge_liked_by']['count'],
256
- 'thumbnail' => str_replace( 's150x150', 's160x160', preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][0]['src'] ) ),
257
  'small' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][2]['src'] ),
258
  'large' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][4]['src'] ),
259
  'original' => preg_replace( '/^https?\:/i', '', $image['node']['display_url'] ),
@@ -261,24 +262,6 @@ Class null_instagram_widget extends WP_Widget {
261
  );
262
  break;
263
  default:
264
- $image['thumbnail_src'] = preg_replace( '/^https?\:/i', '', $image['thumbnail_src'] );
265
- $image['display_src'] = preg_replace( '/^https?\:/i', '', $image['display_src'] );
266
-
267
- // handle both types of CDN url.
268
- if ( ( strpos( $image['thumbnail_src'], 's640x640' ) !== false ) ) {
269
- $image['thumbnail'] = str_replace( 's640x640', 's160x160', $image['thumbnail_src'] );
270
- $image['small'] = str_replace( 's640x640', 's320x320', $image['thumbnail_src'] );
271
- } else {
272
- $urlparts = wp_parse_url( $image['thumbnail_src'] );
273
- $pathparts = explode( '/', $urlparts['path'] );
274
- array_splice( $pathparts, 3, 0, array( 's160x160' ) );
275
- $image['thumbnail'] = '//' . $urlparts['host'] . implode( '/', $pathparts );
276
- $pathparts[3] = 's320x320';
277
- $image['small'] = '//' . $urlparts['host'] . implode( '/', $pathparts );
278
- }
279
-
280
- $image['large'] = $image['thumbnail_src'];
281
-
282
  if ( true === $image['is_video'] ) {
283
  $type = 'video';
284
  } else {
@@ -296,10 +279,10 @@ Class null_instagram_widget extends WP_Widget {
296
  'time' => $image['date'],
297
  'comments' => $image['comments']['count'],
298
  'likes' => $image['likes']['count'],
299
- 'thumbnail' => $image['thumbnail'],
300
- 'small' => $image['small'],
301
- 'large' => $image['large'],
302
- 'original' => $image['display_src'],
303
  'type' => $type,
304
  );
305
 
@@ -310,7 +293,7 @@ Class null_instagram_widget extends WP_Widget {
310
  // do not set an empty transient - should help catch private or empty accounts.
311
  if ( ! empty( $instagram ) ) {
312
  $instagram = base64_encode( serialize( $instagram ) );
313
- set_transient( 'instagram-a8-' . sanitize_title_with_dashes( $username ), $instagram, apply_filters( 'null_instagram_cache_time', HOUR_IN_SECONDS * 2 ) );
314
  }
315
  }
316
 
3
  Plugin Name: WP Instagram Widget
4
  Plugin URI: https://github.com/scottsweb/wp-instagram-widget
5
  Description: A WordPress widget for showing your latest Instagram photos.
6
+ Version: 2.0.2
7
  Author: Scott Evans
8
  Author URI: https://scott.ee
9
  Text Domain: wp-instagram-widget
188
 
189
  $username = trim( strtolower( $username ) );
190
 
191
+ if ( false === ( $instagram = get_transient( 'instagram-a9-' . sanitize_title_with_dashes( $username ) ) ) ) {
192
 
193
  switch ( substr( $username, 0, 1 ) ) {
194
  case '#':
233
  $instagram = array();
234
 
235
  foreach ( $images as $image ) {
236
+ // Note: keep hashtag support different until these JSON changes stabalise
237
+ // these are mostly the same again now
238
  switch ( substr( $username, 0, 1 ) ) {
239
  case '#':
240
  if ( true === $image['node']['is_video'] ) {
254
  'time' => $image['node']['taken_at_timestamp'],
255
  'comments' => $image['node']['edge_media_to_comment']['count'],
256
  'likes' => $image['node']['edge_liked_by']['count'],
257
+ 'thumbnail' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][0]['src'] ),
258
  'small' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][2]['src'] ),
259
  'large' => preg_replace( '/^https?\:/i', '', $image['node']['thumbnail_resources'][4]['src'] ),
260
  'original' => preg_replace( '/^https?\:/i', '', $image['node']['display_url'] ),
262
  );
263
  break;
264
  default:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  if ( true === $image['is_video'] ) {
266
  $type = 'video';
267
  } else {
279
  'time' => $image['date'],
280
  'comments' => $image['comments']['count'],
281
  'likes' => $image['likes']['count'],
282
+ 'thumbnail' => preg_replace( '/^https?\:/i', '', $image['thumbnail_resources'][0]['src'] ),
283
+ 'small' => preg_replace( '/^https?\:/i', '', $image['thumbnail_resources'][2]['src'] ),
284
+ 'large' => preg_replace( '/^https?\:/i', '', $image['thumbnail_resources'][4]['src'] ),
285
+ 'original' => preg_replace( '/^https?\:/i', '', $image['display_src'] ),
286
  'type' => $type,
287
  );
288
 
293
  // do not set an empty transient - should help catch private or empty accounts.
294
  if ( ! empty( $instagram ) ) {
295
  $instagram = base64_encode( serialize( $instagram ) );
296
+ set_transient( 'instagram-a9-' . sanitize_title_with_dashes( $username ), $instagram, apply_filters( 'null_instagram_cache_time', HOUR_IN_SECONDS * 2 ) );
297
  }
298
  }
299