Instagram Widget by WPZOOM - Version 2.0.4

Version Description

  • Fixed an issue with some feeds not showing new posts
Download this release

Release Info

Developer WPZOOM
Plugin Icon 128x128 Instagram Widget by WPZOOM
Version 2.0.4
Comparing to
See all releases

Code changes from version 2.0.3 to 2.0.4

class-wpzoom-instagram-assets.php CHANGED
@@ -258,13 +258,40 @@ if ( ! class_exists( 'WPZOOM_Instagram_Widget_Assets ' ) ) {
258
  */
259
  public static function is_active_block_widget( $blockname ) {
260
 
 
 
261
  $widget_blocks = get_option( 'widget_block' );
262
- $text_widgets = get_option( 'widget_text' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
 
264
- foreach( (array) $text_widgets as $text_widget ) {
265
- if ( ! empty( $text_widget['text'] ) && has_shortcode( $text_widget['text'], 'instagram' ) ) {
266
- return true;
 
 
 
 
267
  }
 
268
  }
269
 
270
  foreach( (array) $widget_blocks as $widget_block ) {
258
  */
259
  public static function is_active_block_widget( $blockname ) {
260
 
261
+ $allwidgets = [];
262
+
263
  $widget_blocks = get_option( 'widget_block' );
264
+ $sidebars_widgets = get_option('sidebars_widgets');
265
+
266
+ if( is_array( $sidebars_widgets ) ) {
267
+ foreach ( $sidebars_widgets as $key => $value ) {
268
+
269
+ if( is_array( $value ) ) {
270
+ foreach ($value as $widget_id) {
271
+ $pieces = explode( '-', $widget_id );
272
+ $multi_number = array_pop( $pieces );
273
+ $id_base = implode( '-', $pieces );
274
+ $widget_data = get_option( 'widget_' . $id_base );
275
+
276
+ // Remove inactive widgets
277
+ if( $key != 'wp_inactive_widgets' ) {
278
+ unset( $widget_data['_multiwidget'] );
279
+ $allwidgets[ $key ] = $widget_data;
280
+ }
281
+ }
282
+ }
283
+ }
284
+ }
285
 
286
+ foreach( (array) $allwidgets as $widget ) {
287
+ foreach( (array) $widget as $widget_element ) {
288
+ foreach( (array)$widget_element as $value ) {
289
+ if( has_shortcode( $value, 'instagram' ) ) {
290
+ return true;
291
+ }
292
+ }
293
  }
294
+
295
  }
296
 
297
  foreach( (array) $widget_blocks as $widget_block ) {
class-wpzoom-instagram-widget-after-setup.php CHANGED
@@ -34,10 +34,12 @@ class Wpzoom_Instagram_Widget_After_Setup {
34
  public function __construct() {
35
 
36
  add_action( 'init', array( $this, 'init' ) );
37
- }
38
 
 
 
39
  public function init() {
40
-
41
  //Run only once
42
  $run_once = get_option( 'wpzoom_run_only_once_01' );
43
  if ( !empty( $run_once ) ) {
@@ -86,6 +88,39 @@ class Wpzoom_Instagram_Widget_After_Setup {
86
 
87
  }
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
90
 
91
  Wpzoom_Instagram_Widget_After_Setup::get_instance();
34
  public function __construct() {
35
 
36
  add_action( 'init', array( $this, 'init' ) );
37
+ add_action( 'init', array( $this, 'delete_old_transients' ) );
38
 
39
+ }
40
+
41
  public function init() {
42
+
43
  //Run only once
44
  $run_once = get_option( 'wpzoom_run_only_once_01' );
45
  if ( !empty( $run_once ) ) {
88
 
89
  }
90
 
91
+ public function delete_old_transients() {
92
+
93
+ //Run only once
94
+ $run_once = get_option( 'wpzoom_run_only_once_02' );
95
+ if ( !empty( $run_once ) ) {
96
+ return;
97
+ }
98
+
99
+ $get_users = get_posts(
100
+ array(
101
+ 'numberposts' => -1,
102
+ 'orderby' => 'date',
103
+ 'order' => 'ASC',
104
+ 'post_type' => 'wpz-insta_user'
105
+ )
106
+ );
107
+
108
+ $transient = 'zoom_instagram_is_configured_';
109
+
110
+ foreach( (array)$get_users as $user ) {
111
+
112
+ $user_id = isset( $user->ID ) ? intval( $user->ID ) : -1;
113
+ $user_account_token = get_post_meta( $user_id, '_wpz-insta_token', true ) ?: '-1';
114
+
115
+ if( get_transient( $transient . $user_account_token ) ) {
116
+ delete_transient( $transient . $user_account_token );
117
+ }
118
+ }
119
+
120
+ add_option( 'wpzoom_run_only_once_02', true );
121
+
122
+ }
123
+
124
  }
125
 
126
  Wpzoom_Instagram_Widget_After_Setup::get_instance();
class-wpzoom-instagram-widget-api.php CHANGED
@@ -40,6 +40,13 @@ class Wpzoom_Instagram_Widget_API {
40
  */
41
  protected $access_token;
42
 
 
 
 
 
 
 
 
43
  /**
44
  * Class constructor
45
  */
@@ -88,6 +95,18 @@ class Wpzoom_Instagram_Widget_API {
88
  $this->access_token = $token;
89
  }
90
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  /**
92
  * Register custom cron intervals
93
  *
@@ -211,6 +230,8 @@ class Wpzoom_Instagram_Widget_API {
211
  * @return array|bool Array of tweets or false if method fails
212
  */
213
  public function get_items( $instance ) {
 
 
214
  $sliced = wp_array_slice_assoc(
215
  $instance,
216
  array(
@@ -279,9 +300,11 @@ class Wpzoom_Instagram_Widget_API {
279
  }
280
  }
281
 
 
 
282
  if ( ! empty( $data->data ) ) {
283
  if ( ! $bypass_transient ) {
284
- set_transient( $transient, wp_json_encode( $data ), $this->get_transient_lifetime() );
285
  }
286
  } else {
287
  if ( ! $bypass_transient ) {
@@ -515,9 +538,12 @@ class Wpzoom_Instagram_Widget_API {
515
  return $converted;
516
  }
517
 
518
- function get_transient_lifetime() {
519
- $interval = (int) WPZOOM_Instagram_Widget_Settings::get_feed_setting_value( get_the_ID(), 'check-new-posts-interval-number' );
520
- $interval_suffix = (int) WPZOOM_Instagram_Widget_Settings::get_feed_setting_value( get_the_ID(), 'check-new-posts-interval-suffix' );
 
 
 
521
 
522
  $values = array(
523
  MINUTE_IN_SECONDS,
@@ -566,7 +592,7 @@ class Wpzoom_Instagram_Widget_API {
566
  }
567
 
568
  if ( ! empty( $data->data ) ) {
569
- set_transient( $transient, wp_json_encode( $data ), $this->get_transient_lifetime() );
570
  } else {
571
  set_transient( $transient, wp_json_encode( false ), MINUTE_IN_SECONDS );
572
 
40
  */
41
  protected $access_token;
42
 
43
+ /**
44
+ * Feed ID
45
+ *
46
+ * @var string
47
+ */
48
+ protected $feed_id;
49
+
50
  /**
51
  * Class constructor
52
  */
95
  $this->access_token = $token;
96
  }
97
 
98
+ /**
99
+ * Manually set the access token.
100
+ *
101
+ * @since 2.0.0
102
+ *
103
+ * @param string $token The access token to set.
104
+ * @return void
105
+ */
106
+ public function set_feed_id( $id ) {
107
+ $this->feed_id = $id;
108
+ }
109
+
110
  /**
111
  * Register custom cron intervals
112
  *
230
  * @return array|bool Array of tweets or false if method fails
231
  */
232
  public function get_items( $instance ) {
233
+
234
+
235
  $sliced = wp_array_slice_assoc(
236
  $instance,
237
  array(
300
  }
301
  }
302
 
303
+
304
+
305
  if ( ! empty( $data->data ) ) {
306
  if ( ! $bypass_transient ) {
307
+ set_transient( $transient, wp_json_encode( $data ), $this->get_transient_lifetime( $this->feed_id ) );
308
  }
309
  } else {
310
  if ( ! $bypass_transient ) {
538
  return $converted;
539
  }
540
 
541
+ function get_transient_lifetime( $id ) {
542
+
543
+ $feed_id = isset( $id ) ? $id : 0;
544
+
545
+ $interval = (int) WPZOOM_Instagram_Widget_Settings::get_feed_setting_value( $feed_id, 'check-new-posts-interval-number' );
546
+ $interval_suffix = (int) WPZOOM_Instagram_Widget_Settings::get_feed_setting_value( $feed_id, 'check-new-posts-interval-suffix' );
547
 
548
  $values = array(
549
  MINUTE_IN_SECONDS,
592
  }
593
 
594
  if ( ! empty( $data->data ) ) {
595
+ set_transient( $transient, wp_json_encode( $data ), $this->get_transient_lifetime( $this->feed_id ) );
596
  } else {
597
  set_transient( $transient, wp_json_encode( false ), MINUTE_IN_SECONDS );
598
 
class-wpzoom-instagram-widget-display.php CHANGED
@@ -210,6 +210,10 @@ class Wpzoom_Instagram_Widget_Display {
210
 
211
  $this->api->set_access_token( $user_account_token );
212
 
 
 
 
 
213
  $items = $this->api->get_items( array( 'image-limit' => $amount, 'image-resolution' => $image_size, 'image-width' => $image_width, 'include-pagination' => true, 'bypass-transient' => $preview ) );
214
  $errors = $this->api->errors->get_error_messages();
215
 
210
 
211
  $this->api->set_access_token( $user_account_token );
212
 
213
+ if( isset( $args['feed-id'] ) ) {
214
+ $this->api->set_feed_id( $args['feed-id'] );
215
+ }
216
+
217
  $items = $this->api->get_items( array( 'image-limit' => $amount, 'image-resolution' => $image_size, 'image-width' => $image_width, 'include-pagination' => true, 'bypass-transient' => $preview ) );
218
  $errors = $this->api->errors->get_error_messages();
219
 
class-wpzoom-instagram-widget.php CHANGED
@@ -125,6 +125,7 @@ class Wpzoom_Instagram_Widget extends WP_Widget {
125
 
126
  //Set token from first created user
127
  $this->api->set_access_token( $user_account_token );
 
128
 
129
  $items = $this->api->get_items( $instance );
130
  $errors = $this->api->errors->get_error_messages();
125
 
126
  //Set token from first created user
127
  $this->api->set_access_token( $user_account_token );
128
+ $this->api->set_feed_id( $user_id );
129
 
130
  $items = $this->api->get_items( $instance );
131
  $errors = $this->api->errors->get_error_messages();
instagram-widget-by-wpzoom.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WPZOOM Instagram Widget & Block
4
  * Plugin URI: https://www.wpzoom.com/plugins/instagram-widget/
5
  * Description: Instagram Widget is a customizable and responsive plugin, made to help you gain even more followers by showcasing your Instagram feed on your WordPress website.
6
- * Version: 2.0.3
7
  * Author: WPZOOM
8
  * Author URI: https://www.wpzoom.com/
9
  * Text Domain: instagram-widget-by-wpzoom
@@ -19,7 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) {
19
  }
20
 
21
  if ( ! defined( 'WPZOOM_INSTAGRAM_VERSION' ) ) {
22
- define( 'WPZOOM_INSTAGRAM_VERSION', '2.0.3' );
23
  }
24
 
25
  require_once plugin_dir_path( __FILE__ ) . 'class-wpzoom-instagram-image-uploader.php';
3
  * Plugin Name: WPZOOM Instagram Widget & Block
4
  * Plugin URI: https://www.wpzoom.com/plugins/instagram-widget/
5
  * Description: Instagram Widget is a customizable and responsive plugin, made to help you gain even more followers by showcasing your Instagram feed on your WordPress website.
6
+ * Version: 2.0.4
7
  * Author: WPZOOM
8
  * Author URI: https://www.wpzoom.com/
9
  * Text Domain: instagram-widget-by-wpzoom
19
  }
20
 
21
  if ( ! defined( 'WPZOOM_INSTAGRAM_VERSION' ) ) {
22
+ define( 'WPZOOM_INSTAGRAM_VERSION', '2.0.4' );
23
  }
24
 
25
  require_once plugin_dir_path( __FILE__ ) . 'class-wpzoom-instagram-image-uploader.php';
readme.txt CHANGED
@@ -96,6 +96,9 @@ Yes, you can find the documentation for this plugin with more instructions on ou
96
 
97
  == Changelog ==
98
 
 
 
 
99
  = 2.0.3 =
100
  * JS and CSS assets from the plugin will be loaded only on pages showing an Instagram feed
101
  * Minor bug fixes and improvements
96
 
97
  == Changelog ==
98
 
99
+ = 2.0.4 =
100
+ * Fixed an issue with some feeds not showing new posts
101
+
102
  = 2.0.3 =
103
  * JS and CSS assets from the plugin will be loaded only on pages showing an Instagram feed
104
  * Minor bug fixes and improvements