WD Instagram Feed – Instagram Gallery - Version 1.4.23

Version Description

Improved: Cache logic. Fixed: Share to Twitter. Fixed: XSS vulnerabilities on widget title. Fixed: Pagination. Fixed: Show error message if "hashtag" is not found.

Download this release

Release Info

Developer 10web
Plugin Icon 128x128 WD Instagram Feed – Instagram Gallery
Version 1.4.23
Comparing to
See all releases

Code changes from version 1.4.22 to 1.4.23

admin/controllers/feeds.php CHANGED
@@ -1,16 +1,9 @@
1
  <?php
2
 
3
  class Feeds_controller_wdi {
4
- // private $model;
5
- // private $view;
6
  private $dataFormat;
7
 
8
  public function __construct() {
9
- // require_once (WDI_DIR . '/admin/models/feeds.php');
10
- // $this->model = new Feeds_model_wdi();
11
- //
12
- // require_once (WDI_DIR . '/admin/views/feeds.php');
13
- // $this->view = new Feeds_view_wdi($model);
14
  $this->setDataFormat();
15
  }
16
 
@@ -168,12 +161,6 @@ class Feeds_controller_wdi {
168
  }
169
  $view->edit($id);
170
  }
171
- // @todo not used remove ?
172
- private function apply() {
173
- $this->save_slider_db();
174
- $this->save_slide_db();
175
- $this->edit();
176
- }
177
 
178
  private function save_feed() {
179
  require_once WDI_DIR . '/admin/models/feeds.php';
@@ -212,8 +199,7 @@ class Feeds_controller_wdi {
212
  $settings = $this->sanitize_input($posts, $defaults);
213
  $settings = wp_parse_args($settings, $defaults);
214
  $action = WDILibrary::get('add_or_edit');
215
- require_once (WDI_DIR."/framework/WDIInstagram.php");
216
-
217
  $message_id = 23;
218
  $need_cache = 1;
219
  if ( $action == '' ) {
@@ -501,12 +487,26 @@ class Feeds_controller_wdi {
501
  $sanitized_output[$setting_name] = $sanitized_val;
502
  break;
503
  }
 
 
 
 
 
 
504
  }
505
  }
506
 
507
  return $sanitized_output;
508
  }
509
 
 
 
 
 
 
 
 
 
510
  private function sanitize_bool( $value, $default ) {
511
  if ( $value == 1 || $value == 0 ) {
512
  return $value;
@@ -516,6 +516,14 @@ class Feeds_controller_wdi {
516
  }
517
  }
518
 
 
 
 
 
 
 
 
 
519
  private function sanitize_string( $value, $default ) {
520
  $sanitized_val = strip_tags(stripslashes(esc_html($value)));
521
  if ( $sanitized_val == '' ) {
@@ -526,6 +534,14 @@ class Feeds_controller_wdi {
526
  }
527
  }
528
 
 
 
 
 
 
 
 
 
529
  private function sanitize_number( $value, $default ) {
530
  if ( is_numeric($value) && $value > 0 ) {
531
  return $value;
@@ -535,6 +551,14 @@ class Feeds_controller_wdi {
535
  }
536
  }
537
 
 
 
 
 
 
 
 
 
538
  private function sanitize_url( $value, $default ) {
539
  if ( function_exists('filter_var') && !filter_var($value, FILTER_VALIDATE_URL) === FALSE ) {
540
  return $value;
@@ -544,6 +568,29 @@ class Feeds_controller_wdi {
544
  }
545
  }
546
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
547
  private function message( $text, $type ) {
548
  require_once(WDI_DIR . '/framework/WDILibrary.php');
549
  echo WDILibrary::message($text, $type);
1
  <?php
2
 
3
  class Feeds_controller_wdi {
 
 
4
  private $dataFormat;
5
 
6
  public function __construct() {
 
 
 
 
 
7
  $this->setDataFormat();
8
  }
9
 
161
  }
162
  $view->edit($id);
163
  }
 
 
 
 
 
 
164
 
165
  private function save_feed() {
166
  require_once WDI_DIR . '/admin/models/feeds.php';
199
  $settings = $this->sanitize_input($posts, $defaults);
200
  $settings = wp_parse_args($settings, $defaults);
201
  $action = WDILibrary::get('add_or_edit');
202
+ require_once (WDI_DIR . '/framework/WDIInstagram.php');
 
203
  $message_id = 23;
204
  $need_cache = 1;
205
  if ( $action == '' ) {
487
  $sanitized_output[$setting_name] = $sanitized_val;
488
  break;
489
  }
490
+ case 'json':
491
+ {
492
+ $sanitized_val = $this->sanitize_json($value, $defaults[$setting_name]);
493
+ $sanitized_output[$setting_name] = $sanitized_val;
494
+ break;
495
+ }
496
  }
497
  }
498
 
499
  return $sanitized_output;
500
  }
501
 
502
+ /**
503
+ * Sanitize bool.
504
+ *
505
+ * @param $value
506
+ * @param $default
507
+ *
508
+ * @return mixed
509
+ */
510
  private function sanitize_bool( $value, $default ) {
511
  if ( $value == 1 || $value == 0 ) {
512
  return $value;
516
  }
517
  }
518
 
519
+ /**
520
+ * Sanitize string
521
+ *
522
+ * @param $value
523
+ * @param $default
524
+ *
525
+ * @return string
526
+ */
527
  private function sanitize_string( $value, $default ) {
528
  $sanitized_val = strip_tags(stripslashes(esc_html($value)));
529
  if ( $sanitized_val == '' ) {
534
  }
535
  }
536
 
537
+ /**
538
+ * Sanitize number field.
539
+ *
540
+ * @param $value
541
+ * @param $default
542
+ *
543
+ * @return mixed
544
+ */
545
  private function sanitize_number( $value, $default ) {
546
  if ( is_numeric($value) && $value > 0 ) {
547
  return $value;
551
  }
552
  }
553
 
554
+ /**
555
+ * Sanitize url field.
556
+ *
557
+ * @param $value
558
+ * @param $default
559
+ *
560
+ * @return mixed
561
+ */
562
  private function sanitize_url( $value, $default ) {
563
  if ( function_exists('filter_var') && !filter_var($value, FILTER_VALIDATE_URL) === FALSE ) {
564
  return $value;
568
  }
569
  }
570
 
571
+ /**
572
+ * Sanitize json field.
573
+ * @param $value
574
+ * @param $default
575
+ *
576
+ * @return false|string
577
+ */
578
+ private function sanitize_json( $value, $default ) {
579
+ $json = $default;
580
+ $items = json_decode($value, TRUE);
581
+ $data = array();
582
+ if ( !empty($items) ) {
583
+ foreach ( $items as $index => $values ) {
584
+ foreach ( $values as $key => $val ) {
585
+ $data[$index][$key] = sanitize_text_field($val);
586
+ }
587
+ }
588
+ $json = json_encode($data);
589
+ }
590
+
591
+ return $json;
592
+ }
593
+
594
  private function message( $text, $type ) {
595
  require_once(WDI_DIR . '/framework/WDILibrary.php');
596
  echo WDILibrary::message($text, $type);
admin/controllers/uninstall.php CHANGED
@@ -78,6 +78,8 @@ class Uninstall_controller_wdi {
78
  delete_option('wdi_redirect_to_settings');
79
  delete_option('wdi_token_error_flag');
80
  delete_option('widget_wdi_instagram_widget');
 
 
81
  $this->remove_theme_files();
82
 
83
  // remove all cache.
78
  delete_option('wdi_redirect_to_settings');
79
  delete_option('wdi_token_error_flag');
80
  delete_option('widget_wdi_instagram_widget');
81
+ delete_option('wdi_current_cache_time');
82
+
83
  $this->remove_theme_files();
84
 
85
  // remove all cache.
admin/models/feeds.php CHANGED
@@ -138,11 +138,11 @@ class Feeds_model_wdi {
138
  'feed_resolution' => 'optimal',
139
  'hashtag_top_recent' => '0',
140
  );
141
- if(WDI_IS_FREE){
142
- $settings["show_description"] = "0";
143
- $settings["show_likes"] = "0";
144
- $settings["show_comments"] = "0";
145
- $settings["show_username_on_thumb"] = "0";
146
  $settings['popup_enable_filmstrip'] = '0';
147
  $settings['popup_info_always_show'] = '0';
148
  $settings['popup_info_full_width'] = '0';
@@ -160,7 +160,7 @@ class Feeds_model_wdi {
160
  'feed_thumb'=> 'url',
161
  'published' => 'bool',
162
  'theme_id'=> 'number'/*$options['wdi_default_theme']*/,
163
- 'feed_users'=> 'string',
164
  'feed_display_view' =>'string',
165
  'sort_images_by' => 'string',
166
  'display_order'=> 'string',
@@ -214,7 +214,7 @@ class Feeds_model_wdi {
214
  'enable_loop'=>'bool',
215
  'popup_image_right_click'=>'bool',
216
 
217
- 'conditional_filters' => 'string',
218
  'conditional_filter_enable'=>'number',
219
  'conditional_filter_type' => 'string',
220
 
@@ -309,7 +309,7 @@ class Feeds_model_wdi {
309
  return 1;
310
  } else {
311
  $transient_key = "wdi_cache_" . md5($feed_id."_0");
312
- $cache_data = get_transient($transient_key);
313
  $wdi_requests_success = intval(get_option('wdi_cache_success_'.$feed_id, 0));
314
  if ( isset($cache_data) && $cache_data != FALSE && isset($cache_data["cache_response"]) && $wdi_requests_success) {
315
  return 0;
138
  'feed_resolution' => 'optimal',
139
  'hashtag_top_recent' => '0',
140
  );
141
+ if ( WDI_IS_FREE ) {
142
+ $settings['show_description'] = '0';
143
+ $settings['show_likes'] = '0';
144
+ $settings['show_comments'] = '0';
145
+ $settings['show_username_on_thumb'] = '0';
146
  $settings['popup_enable_filmstrip'] = '0';
147
  $settings['popup_info_always_show'] = '0';
148
  $settings['popup_info_full_width'] = '0';
160
  'feed_thumb'=> 'url',
161
  'published' => 'bool',
162
  'theme_id'=> 'number'/*$options['wdi_default_theme']*/,
163
+ 'feed_users'=> 'json',
164
  'feed_display_view' =>'string',
165
  'sort_images_by' => 'string',
166
  'display_order'=> 'string',
214
  'enable_loop'=>'bool',
215
  'popup_image_right_click'=>'bool',
216
 
217
+ 'conditional_filters' => 'json',
218
  'conditional_filter_enable'=>'number',
219
  'conditional_filter_type' => 'string',
220
 
309
  return 1;
310
  } else {
311
  $transient_key = "wdi_cache_" . md5($feed_id."_0");
312
+ $cache_data = get_option($transient_key);
313
  $wdi_requests_success = intval(get_option('wdi_cache_success_'.$feed_id, 0));
314
  if ( isset($cache_data) && $cache_data != FALSE && isset($cache_data["cache_response"]) && $wdi_requests_success) {
315
  return 0;
admin/views/feeds.php CHANGED
@@ -110,7 +110,7 @@ class Feeds_view_wdi {
110
  $instagram_preview_post = $this->model->get_instagram_preview_post();
111
  foreach ($rows_data as $row_data) {
112
  $prev_img_url = WDI_URL . '/images/no-image.png';
113
- $feed_users = json_decode(htmlspecialchars_decode($row_data->feed_users), TRUE);
114
  foreach ( $feed_users as $user ) {
115
  if ( empty($users['tag_id']) ) {
116
  $username = $user['username'];
@@ -803,7 +803,7 @@ class Feeds_view_wdi {
803
 
804
  if ($current_id != '') {
805
  $feed_row = WDILibrary::objectToarray($this->model->get_feed_row($current_id));
806
- $users = (array) json_decode(htmlspecialchars_decode($feed_row['feed_users']), TRUE);
807
  if ( !empty($users) ) {
808
  foreach($users as $user) {
809
  if( substr($user['username'], 0, 1) === '#' ) {
110
  $instagram_preview_post = $this->model->get_instagram_preview_post();
111
  foreach ($rows_data as $row_data) {
112
  $prev_img_url = WDI_URL . '/images/no-image.png';
113
+ $feed_users = json_decode($row_data->feed_users, TRUE);
114
  foreach ( $feed_users as $user ) {
115
  if ( empty($users['tag_id']) ) {
116
  $username = $user['username'];
803
 
804
  if ($current_id != '') {
805
  $feed_row = WDILibrary::objectToarray($this->model->get_feed_row($current_id));
806
+ $users = json_decode($feed_row['feed_users'], TRUE);
807
  if ( !empty($users) ) {
808
  foreach($users as $user) {
809
  if( substr($user['username'], 0, 1) === '#' ) {
config.php CHANGED
@@ -3,7 +3,7 @@ if ( !defined('ABSPATH') ) {
3
  exit;
4
  }
5
 
6
- define('WDI_VERSION', '1.4.22');
7
  define('WDI_IS_FREE', TRUE);
8
  define('WDI_PREFIX', 'wdi');
9
  define('WDI_DIR', WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__)));
3
  exit;
4
  }
5
 
6
+ define('WDI_VERSION', '1.4.23');
7
  define('WDI_IS_FREE', TRUE);
8
  define('WDI_PREFIX', 'wdi');
9
  define('WDI_DIR', WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__)));
framework/WDICache.php CHANGED
@@ -27,7 +27,7 @@ class WDICache {
27
  */
28
  public function get_cache_data( $name, $debug = FALSE ) {
29
  $transient_key = "wdi_cache_" . md5($name);
30
- $cache_data = get_transient($transient_key);
31
  if ( isset($cache_data) && $cache_data != FALSE && isset($cache_data["cache_response"]) ) {
32
  $wdi_debugging = FALSE;
33
  $wdi_debugging_data = array();
@@ -81,7 +81,6 @@ class WDICache {
81
  $cache_date = (date('Y-m-d H:i:s'));
82
  $wdi_cache_response = $response;
83
  $transient_key = "wdi_cache_" . md5($name);
84
- $expiration_time = $wdi_transient_time * 60;
85
  if ( !seems_utf8($wdi_cache_response) ) {
86
  $wdi_cache_response = utf8_encode($wdi_cache_response);
87
  }
@@ -92,8 +91,9 @@ class WDICache {
92
  'wdi_transient_time' => $wdi_transient_time,
93
  ),
94
  );
95
- $data = set_transient($transient_key, $data, $expiration_time);
96
-
 
97
  return $data;
98
  }
99
 
27
  */
28
  public function get_cache_data( $name, $debug = FALSE ) {
29
  $transient_key = "wdi_cache_" . md5($name);
30
+ $cache_data = get_option($transient_key);
31
  if ( isset($cache_data) && $cache_data != FALSE && isset($cache_data["cache_response"]) ) {
32
  $wdi_debugging = FALSE;
33
  $wdi_debugging_data = array();
81
  $cache_date = (date('Y-m-d H:i:s'));
82
  $wdi_cache_response = $response;
83
  $transient_key = "wdi_cache_" . md5($name);
 
84
  if ( !seems_utf8($wdi_cache_response) ) {
85
  $wdi_cache_response = utf8_encode($wdi_cache_response);
86
  }
91
  'wdi_transient_time' => $wdi_transient_time,
92
  ),
93
  );
94
+ $data = update_option($transient_key, $data);
95
+ $current_time = current_time('timestamp',1);
96
+ add_option('wdi_current_cache_time', $current_time, 0);
97
  return $data;
98
  }
99
 
framework/WDIInstagram.php CHANGED
@@ -179,24 +179,29 @@ class WDIInstagram {
179
  }
180
  }
181
 
182
- public function wdi_getHashtagId( $tagname = '', $user_name='' ) {
183
  $this->account_data = $this->wdi_authenticated_users_list[$user_name];
184
  $url = 'https://graph.facebook.com/v10.0/ig_hashtag_search/?user_id=' . $this->account_data["user_id"] . '&q=' . $tagname . '&access_token=' . $this->account_data["access_token"];
185
  $args = array();
186
  $response = wp_remote_get($url, $args);
187
-
188
  $hashtag_id = '';
189
- if ( !isset($response->errors) && is_array($response) && isset($response["body"]) ) {
190
- $response = json_decode($response["body"], true);
191
  if ( !empty($response['data']) && !empty($response['data'][0]) && !empty($response['data'][0]['id']) ) {
192
- $hashtag_id = $response['data'][0]['id'];
193
  $return_data['meta']['code'] = 200;
 
 
 
 
 
194
  }
195
- } else {
196
-
197
  }
198
- $return_data["tag_id"] = $hashtag_id;
199
- //$return_data['meta']['code'] = $hashtag_id;
 
 
 
 
200
  return $return_data;
201
  }
202
 
@@ -475,18 +480,21 @@ class WDIInstagram {
475
  }
476
  }
477
  else if ($ig_object['media_type'] === "CAROUSEL_ALBUM") {
478
- foreach ($ig_object['children']['data'] as $carousel_key => $carousel_child) {
479
- if ($carousel_child['media_type'] === "VIDEO") {
480
- $childOembedApiUrl = "https://graph.facebook.com/v10.0/instagram_oembed?url=" . $carousel_child['permalink'] . "&access_token=" . $this->account_data["access_token"];
481
- $childOembedData = wp_remote_get($childOembedApiUrl, $args);
482
- if ( !isset($childOembedData->errors) && is_array($childOembedData) && isset($childOembedData["body"]) ) {
483
- $childOembedData = json_decode($childOembedData["body"], TRUE);
484
- if ( !empty($childOembedData['thumbnail_url']) ) {
485
- if (!array_key_exists('media_url', $carousel_child)) { // if no media url(Copyright) change type to image
486
- $data['data'][$key]['children']['data'][$carousel_key]['media_type'] = "IMAGE";
487
- $data['data'][$key]['children']['data'][$carousel_key]['media_url'] = $childOembedData['thumbnail_url'];
488
- } else { // if ok just add thumb url for VIDEO type
489
- $data['data'][$key]['children']['data'][$carousel_key]['thumbnail'] = $childOembedData['thumbnail_url'];
 
 
 
490
  }
491
  }
492
  }
179
  }
180
  }
181
 
182
+ public function wdi_getHashtagId( $tagname = '', $user_name = '' ) {
183
  $this->account_data = $this->wdi_authenticated_users_list[$user_name];
184
  $url = 'https://graph.facebook.com/v10.0/ig_hashtag_search/?user_id=' . $this->account_data["user_id"] . '&q=' . $tagname . '&access_token=' . $this->account_data["access_token"];
185
  $args = array();
186
  $response = wp_remote_get($url, $args);
 
187
  $hashtag_id = '';
188
+ if ( !isset($response->errors) && is_array($response) && isset($response['body']) ) {
189
+ $response = json_decode($response['body'], TRUE);
190
  if ( !empty($response['data']) && !empty($response['data'][0]) && !empty($response['data'][0]['id']) ) {
 
191
  $return_data['meta']['code'] = 200;
192
+ $hashtag_id = $response['data'][0]['id'];
193
+ }
194
+ else {
195
+ $return_data['meta']['code'] = 400;
196
+ $return_data['meta']['message'] = $response['error']['error_user_msg'];
197
  }
 
 
198
  }
199
+ else {
200
+ $return_data['meta']['code'] = 400;
201
+ $return_data['meta']['message'] = 'Bad Request';
202
+ }
203
+ $return_data['tag_id'] = $hashtag_id;
204
+
205
  return $return_data;
206
  }
207
 
480
  }
481
  }
482
  else if ($ig_object['media_type'] === "CAROUSEL_ALBUM") {
483
+ if ( !empty($ig_object['children']['data']) ) {
484
+ foreach ( $ig_object['children']['data'] as $carousel_key => $carousel_child ) {
485
+ if ( $carousel_child['media_type'] === "VIDEO" ) {
486
+ $childOembedApiUrl = "https://graph.facebook.com/v10.0/instagram_oembed?url=" . $carousel_child['permalink'] . "&access_token=" . $this->account_data["access_token"];
487
+ $childOembedData = wp_remote_get($childOembedApiUrl, $args);
488
+ if ( !isset($childOembedData->errors) && is_array($childOembedData) && isset($childOembedData["body"]) ) {
489
+ $childOembedData = json_decode($childOembedData["body"], TRUE);
490
+ if ( !empty($childOembedData['thumbnail_url']) ) {
491
+ if ( !array_key_exists('media_url', $carousel_child) ) { // if no media url(Copyright) change type to image
492
+ $data['data'][$key]['children']['data'][$carousel_key]['media_type'] = "IMAGE";
493
+ $data['data'][$key]['children']['data'][$carousel_key]['media_url'] = $childOembedData['thumbnail_url'];
494
+ }
495
+ else { // if ok just add thumb url for VIDEO type
496
+ $data['data'][$key]['children']['data'][$carousel_key]['thumbnail'] = $childOembedData['thumbnail_url'];
497
+ }
498
  }
499
  }
500
  }
framework/WDILibrary.php CHANGED
@@ -892,12 +892,12 @@ class WDILibrary {
892
  return $feed_row;
893
  }
894
 
895
- $users = json_decode(htmlspecialchars_decode($feed_row['feed_users']));
896
  $new_users_list = array();
897
  $users_list = self::get_users_list();
898
  if(is_array($users)) {
899
  foreach($users as $i => $user) {
900
- if(substr($user->username, 0, 1) === '#' || $user->username === $wdi_options['wdi_user_name'] || !empty($users_list[$user->username])) {
901
  $new_users_list[] = $user;
902
  }
903
  }
@@ -1036,28 +1036,32 @@ class WDILibrary {
1036
  return rmdir($dir);
1037
  }
1038
 
 
 
 
 
 
1039
  public static function get_shortcode_data() {
1040
- global $wpdb;
1041
- require_once WDI_DIR . "/admin/models/WDIModelEditorShortcode.php";
1042
  $model = new WDIModelEditorShortcode();
1043
-
1044
  $rows = $model->get_row_data();
1045
  $gb_row = array();
1046
- foreach ($rows as $row){
1047
  $obj = new stdClass();
1048
  $obj->id = $row->id;
1049
- $obj->name = $row->feed_name;
1050
  $gb_row[] = $obj;
1051
  }
1052
  $data = array();
1053
- $data['shortcode_prefix'] = "wdi_feed";
1054
  $data['inputs'][] = array(
1055
  'type' => 'select',
1056
  'id' => 'wdi_id',
1057
  'name' => 'wdi_id',
1058
  'shortcode_attibute_name' => 'id',
1059
- 'options' => $gb_row,
1060
  );
 
1061
  return json_encode($data);
1062
  }
1063
 
892
  return $feed_row;
893
  }
894
 
895
+ $users = json_decode($feed_row['feed_users'], true);
896
  $new_users_list = array();
897
  $users_list = self::get_users_list();
898
  if(is_array($users)) {
899
  foreach($users as $i => $user) {
900
+ if(substr($user['username'], 0, 1) === '#' || $user['username'] === $wdi_options['wdi_user_name'] || !empty($users_list[$user['username']])) {
901
  $new_users_list[] = $user;
902
  }
903
  }
1036
  return rmdir($dir);
1037
  }
1038
 
1039
+ /**
1040
+ * Get shortcode data.
1041
+ *
1042
+ * @return false|string
1043
+ */
1044
  public static function get_shortcode_data() {
1045
+ require_once WDI_DIR . '/admin/models/WDIModelEditorShortcode.php';
 
1046
  $model = new WDIModelEditorShortcode();
 
1047
  $rows = $model->get_row_data();
1048
  $gb_row = array();
1049
+ foreach ( $rows as $row ) {
1050
  $obj = new stdClass();
1051
  $obj->id = $row->id;
1052
+ $obj->name = htmlspecialchars_decode($row->feed_name, ENT_QUOTES);
1053
  $gb_row[] = $obj;
1054
  }
1055
  $data = array();
1056
+ $data['shortcode_prefix'] = 'wdi_feed';
1057
  $data['inputs'][] = array(
1058
  'type' => 'select',
1059
  'id' => 'wdi_id',
1060
  'name' => 'wdi_id',
1061
  'shortcode_attibute_name' => 'id',
1062
+ 'options' => $gb_row,
1063
  );
1064
+
1065
  return json_encode($data);
1066
  }
1067
 
frontend/shortcode.php CHANGED
@@ -66,7 +66,7 @@ function wdi_feed($atts, $widget_params = '') {
66
  //getting all feed information from db
67
  $feed_row = WDILibrary::objectToArray( $feed_model->get_feed_row( $attributes['id'] ) );
68
  $feed_row = WDILibrary::keep_only_self_user($feed_row);
69
-
70
  if ( !isset($feed_row) || $feed_row == NULL ) {
71
  ob_get_clean();
72
 
66
  //getting all feed information from db
67
  $feed_row = WDILibrary::objectToArray( $feed_model->get_feed_row( $attributes['id'] ) );
68
  $feed_row = WDILibrary::keep_only_self_user($feed_row);
69
+
70
  if ( !isset($feed_row) || $feed_row == NULL ) {
71
  ob_get_clean();
72
 
frontend/views/WDIViewGalleryBox.php CHANGED
@@ -18,6 +18,7 @@ class WDIViewGalleryBox {
18
 
19
  $feed_id = WDILibrary::get('feed_id', 0, 'intval', 'POST');
20
  $current_feed = $this->model->get_feed_row_data( $feed_id );
 
21
  if ( !empty($current_feed['feed_users']) ) {
22
  $feed_users = json_decode($current_feed['feed_users'], TRUE);
23
  if ( !empty($feed_users) ) {
@@ -27,6 +28,12 @@ class WDIViewGalleryBox {
27
  break;
28
  }
29
  }
 
 
 
 
 
 
30
  }
31
  }
32
  if ( !empty($wdi_options['wdi_authenticated_users_list']) ) {
@@ -37,15 +44,6 @@ class WDIViewGalleryBox {
37
  }
38
  }
39
  $business = (!empty($user_feed_header_args['user']['type']) && $user_feed_header_args['user']['type'] === 'business') ? TRUE : FALSE;
40
- $is_hashtag = FALSE;
41
- if ( isset($current_feed['feed_users']) && !empty($current_feed['feed_users']) ) {
42
- foreach ( json_decode($current_feed['feed_users']) as $user ) {
43
- $first_char = mb_substr($user->id, 0, 1);
44
- if ( $first_char === '#' ) {
45
- $is_hashtag = TRUE;
46
- }
47
- }
48
- }
49
  $theme_row = WDILibrary::arrayToObject($this->model->get_theme_row_data($current_feed['theme_id']));
50
  $option_row = WDILibrary::arrayToObject($current_feed);
51
  $option_row->preload_images_count = 0;
@@ -343,7 +341,6 @@ class WDIViewGalleryBox {
343
  $instaDesc = str_replace('#', ' #', $instaDesc);
344
  }
345
  ?>
346
-
347
  </script>
348
  <?php
349
  if (!$image_id_exist) {
@@ -367,7 +364,7 @@ class WDIViewGalleryBox {
367
  }
368
 
369
  if ($enable_image_ctrl_btn) {
370
- $share_url = add_query_arg(array('action' => 'Share', 'curr_url' => $current_url, 'image_id' => $current_image_id), admin_url('admin-ajax.php')) . '#wdi' . $gallery_id . '/' . $current_image_id;
371
  ?>
372
  <div class="wdi_ctrl_btn_container">
373
  <?php
@@ -413,7 +410,7 @@ class WDIViewGalleryBox {
413
  }
414
  if ($enable_image_twitter) {
415
  ?>
416
- <a id="wdi_twitter_a" href="https://twitter.com/share?url=<?php echo urlencode($share_url); ?>" target="_blank" title="<?php echo __('Share on Twitter', "wd-instagram-feed"); ?>">
417
  <i title="<?php echo __('Share on Twitter', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_twitter tenweb-i tenweb-i-twitter-square"></i>
418
  </a>
419
  <?php
@@ -438,7 +435,7 @@ class WDIViewGalleryBox {
438
  <i onclick="jQuery(this).parent().find('.wdi_share_btns').toggleClass('wdi_share_toggler');jQuery(this).parent().find('.wdi_share_caret').toggleClass('wdi_share_toggler')" title="<?php echo __('Share', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn tenweb-i tenweb-i-share"></i>
439
  <p class="wdi_share_btns" style="display:none">
440
  <a id="wdi_popup_fb" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $current_image_url;?>" target="_blank" class='wdi_share_popup_btn wdi_facebook tenweb-i tenweb-i-facebook-square'></a>
441
- <a id="wdi_popup_tw" href="https://twitter.com/home?status=<?php echo $current_image_url;?>" target="_blank" class='wdi_share_popup_btn wdi_twitter tenweb-i tenweb-i-twitter-square'></a>
442
  <a id="wdi_popup_li" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo $current_image_url;?>&title=<?php echo $current_image_description?>" target="_blank" class='wdi_share_popup_btn wdi_linkedin tenweb-i tenweb-i-linkedin'></a>
443
  <a id="wdi_popup_pt" href="https://pinterest.com/pin/create/button/?url=<?php echo $current_image_url;?>&media=<?php echo $current_image_url;?>media/?size=l&description=<?php echo $current_image_description?>" target="_blank" class='wdi_share_popup_btn wdi_pinterest tenweb-i tenweb-i-pinterest-square'></a>
444
  </p>
@@ -570,6 +567,23 @@ class WDIViewGalleryBox {
570
  </div>
571
  <a class="wdi_spider_popup_close" onclick="wdi_spider_destroypopup(1000); return false;" ontouchend="wdi_spider_destroypopup(1000); return false;"><span><i class="wdi_close_btn tenweb-i tenweb-i-times"></i></span></a>
572
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
573
  var wdi_trans_in_progress = false;
574
  var wdi_transition_duration = <?php echo (($slideshow_interval < 4) && ($slideshow_interval != 0)) ? ($slideshow_interval * 1000) / 4 : 800; ?>;
575
  var wdi_playInterval;
@@ -840,7 +854,7 @@ class WDIViewGalleryBox {
840
  addthis_share.url = wdi_share_url;
841
  }
842
  jQuery("#wdi_facebook_a").attr("href", "https://www.facebook.com/sharer/sharer.php?u=" + wdi_share_url);
843
- jQuery("#wdi_twitter_a").attr("href", "https://twitter.com/share?url=" + wdi_share_url);
844
  jQuery("#wdi_google_a").attr("href", "https://plus.google.com/share?url=" + wdi_share_url);
845
  jQuery("#wdi_pinterest_a").attr("href", "http://pinterest.com/pin/create/button/?s=100&url=" + wdi_share_url + "&media=" + wdi_share_image_url + "&description=" + wdi_data[key]['description']);
846
  jQuery("#wdi_tumblr_a").attr("href", "https://www.tumblr.com/share/photo?source=" + wdi_share_image_url + "&caption=" + wdi_data[key]['alt'] + "&clickthru=" + wdi_share_url);
@@ -848,7 +862,7 @@ class WDIViewGalleryBox {
848
 
849
  //share popup urls
850
  jQuery("#wdi_popup_fb").attr('href',"https://www.facebook.com/sharer/sharer.php?u="+wdi_image_url);
851
- jQuery("#wdi_popup_tw").attr('href',"https://twitter.com/share?url=" + wdi_image_url);
852
  jQuery('#wdi_popup_li').attr('href',"https://www.linkedin.com/shareArticle?mini=true&url="+wdi_image_url+"&title="+wdi_image_description);
853
  jQuery('#wdi_popup_pt').attr('href',"https://pinterest.com/pin/create/button/?url="+wdi_image_url+"&media="+wdi_image_url+"media/?size=l&description="+wdi_image_description);
854
  /* Load comments.*/
18
 
19
  $feed_id = WDILibrary::get('feed_id', 0, 'intval', 'POST');
20
  $current_feed = $this->model->get_feed_row_data( $feed_id );
21
+ $is_hashtag = FALSE;
22
  if ( !empty($current_feed['feed_users']) ) {
23
  $feed_users = json_decode($current_feed['feed_users'], TRUE);
24
  if ( !empty($feed_users) ) {
28
  break;
29
  }
30
  }
31
+ foreach ( $feed_users as $user ) {
32
+ $first_char = mb_substr($user['id'], 0, 1);
33
+ if ( $first_char === '#' ) {
34
+ $is_hashtag = TRUE;
35
+ }
36
+ }
37
  }
38
  }
39
  if ( !empty($wdi_options['wdi_authenticated_users_list']) ) {
44
  }
45
  }
46
  $business = (!empty($user_feed_header_args['user']['type']) && $user_feed_header_args['user']['type'] === 'business') ? TRUE : FALSE;
 
 
 
 
 
 
 
 
 
47
  $theme_row = WDILibrary::arrayToObject($this->model->get_theme_row_data($current_feed['theme_id']));
48
  $option_row = WDILibrary::arrayToObject($current_feed);
49
  $option_row->preload_images_count = 0;
341
  $instaDesc = str_replace('#', ' #', $instaDesc);
342
  }
343
  ?>
 
344
  </script>
345
  <?php
346
  if (!$image_id_exist) {
364
  }
365
 
366
  if ($enable_image_ctrl_btn) {
367
+ $share_url = add_query_arg(array('action' => 'Share', 'curr_url' => $current_url, 'image_id' => $current_image_id), admin_url('admin-ajax.php')) . '#wdi' . $gallery_id . '/' . $current_image_id;
368
  ?>
369
  <div class="wdi_ctrl_btn_container">
370
  <?php
410
  }
411
  if ($enable_image_twitter) {
412
  ?>
413
+ <a id="wdi_twitter_a" href="https://twitter.com/intent/tweet?url=<?php echo urlencode($share_url); ?>" target="_blank" title="<?php echo __('Share on Twitter', "wd-instagram-feed"); ?>">
414
  <i title="<?php echo __('Share on Twitter', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_twitter tenweb-i tenweb-i-twitter-square"></i>
415
  </a>
416
  <?php
435
  <i onclick="jQuery(this).parent().find('.wdi_share_btns').toggleClass('wdi_share_toggler');jQuery(this).parent().find('.wdi_share_caret').toggleClass('wdi_share_toggler')" title="<?php echo __('Share', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn tenweb-i tenweb-i-share"></i>
436
  <p class="wdi_share_btns" style="display:none">
437
  <a id="wdi_popup_fb" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $current_image_url;?>" target="_blank" class='wdi_share_popup_btn wdi_facebook tenweb-i tenweb-i-facebook-square'></a>
438
+ <a id="wdi_popup_tw" href="https://twitter.com/intent/tweet?url=<?php echo $current_image_url;?>" target="_blank" class='wdi_share_popup_btn wdi_twitter tenweb-i tenweb-i-twitter-square'></a>
439
  <a id="wdi_popup_li" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo $current_image_url;?>&title=<?php echo $current_image_description?>" target="_blank" class='wdi_share_popup_btn wdi_linkedin tenweb-i tenweb-i-linkedin'></a>
440
  <a id="wdi_popup_pt" href="https://pinterest.com/pin/create/button/?url=<?php echo $current_image_url;?>&media=<?php echo $current_image_url;?>media/?size=l&description=<?php echo $current_image_description?>" target="_blank" class='wdi_share_popup_btn wdi_pinterest tenweb-i tenweb-i-pinterest-square'></a>
441
  </p>
567
  </div>
568
  <a class="wdi_spider_popup_close" onclick="wdi_spider_destroypopup(1000); return false;" ontouchend="wdi_spider_destroypopup(1000); return false;"><span><i class="wdi_close_btn tenweb-i tenweb-i-times"></i></span></a>
569
  <script>
570
+ function checkNeedToDisableRightArrow() {
571
+ window.setTimeout(function(){
572
+ if( ( -(jQuery(".wdi_filmstrip_thumbnails").<?php echo $width_or_height; ?>() - jQuery(".wdi_filmstrip").<?php echo $width_or_height; ?>()) ==
573
+ jQuery(".wdi_filmstrip_thumbnails").position().<?php echo $left_or_top; ?> ) ) {
574
+ jQuery(".wdi_filmstrip_right").css({opacity: 0.3, filter: "Alpha(opacity=30)"});
575
+ }
576
+ }, 600); // after lightbox open animation
577
+ }
578
+ function checkNeedToDisableLeftArrow() {
579
+ window.setTimeout(function(){
580
+ if (jQuery(".wdi_filmstrip_thumbnails").position().<?php echo $left_or_top; ?> == 0) {
581
+ jQuery(".wdi_filmstrip_left").css({opacity: 0.3, filter: "Alpha(opacity=30)"});
582
+ }
583
+ }, 600); // after lightbox open animation
584
+ }
585
+ checkNeedToDisableRightArrow();
586
+ checkNeedToDisableLeftArrow();
587
  var wdi_trans_in_progress = false;
588
  var wdi_transition_duration = <?php echo (($slideshow_interval < 4) && ($slideshow_interval != 0)) ? ($slideshow_interval * 1000) / 4 : 800; ?>;
589
  var wdi_playInterval;
854
  addthis_share.url = wdi_share_url;
855
  }
856
  jQuery("#wdi_facebook_a").attr("href", "https://www.facebook.com/sharer/sharer.php?u=" + wdi_share_url);
857
+ jQuery("#wdi_twitter_a").attr("href", "https://twitter.com/intent/tweet?url=" + wdi_share_url);
858
  jQuery("#wdi_google_a").attr("href", "https://plus.google.com/share?url=" + wdi_share_url);
859
  jQuery("#wdi_pinterest_a").attr("href", "http://pinterest.com/pin/create/button/?s=100&url=" + wdi_share_url + "&media=" + wdi_share_image_url + "&description=" + wdi_data[key]['description']);
860
  jQuery("#wdi_tumblr_a").attr("href", "https://www.tumblr.com/share/photo?source=" + wdi_share_image_url + "&caption=" + wdi_data[key]['alt'] + "&clickthru=" + wdi_share_url);
862
 
863
  //share popup urls
864
  jQuery("#wdi_popup_fb").attr('href',"https://www.facebook.com/sharer/sharer.php?u="+wdi_image_url);
865
+ jQuery("#wdi_popup_tw").attr('href',"https://twitter.com/intent/tweet?url=" + wdi_image_url);
866
  jQuery('#wdi_popup_li').attr('href',"https://www.linkedin.com/shareArticle?mini=true&url="+wdi_image_url+"&title="+wdi_image_description);
867
  jQuery('#wdi_popup_pt').attr('href',"https://pinterest.com/pin/create/button/?url="+wdi_image_url+"&media="+wdi_image_url+"media/?size=l&description="+wdi_image_description);
868
  /* Load comments.*/
js/wdi_admin.js CHANGED
@@ -565,12 +565,11 @@ var comlete_redirect_url = '';
565
 
566
  function submit_ajax() {
567
  var data = jQuery("#wdi_save_feed").serialize();
568
- data = data + '&action=wdi_apply_changes&page=wdi_feeds';
569
-
570
  jQuery("#wdi_save_loading").removeClass("wdi_hidden");
571
  jQuery.ajax({
572
- type: "POST",
573
  url: wdi_ajax.ajax_url,
 
574
  dataType: 'json',
575
  data: data,
576
  success: function (response) {
@@ -581,7 +580,7 @@ function submit_ajax() {
581
  jQuery(".caching-process-message").removeClass("wdi_hidden");
582
  /* TODO Timeout need as loader not appear without timeout, need to fix */
583
  setTimeout(function(){
584
- wdi_controller.instagram.set_cache_data(comlete_redirect_url, '', feed_id, '', 0, 0, '', '', '', '');
585
  }, 1000);
586
  }
587
  else {
@@ -653,6 +652,9 @@ wdi_controller.makeInstagramUserRequest = function ( user_input, ignoreConfirm )
653
  if ( vObj.valid ) {
654
  _this.addHashtag(tagname, response);
655
  }
 
 
 
656
  },
657
  error: function (xhr, status, error) {
658
  }
@@ -894,7 +896,7 @@ wdi_controller.isValidResponse = function (response) {
894
  obj.msg = wdi_messages.instagram_server_error;
895
  }
896
  else if (response['meta']['code'] !== 200) {
897
- obj.msg = response['meta']['error_message'];
898
  }
899
  else {
900
  obj.msg = '';
565
 
566
  function submit_ajax() {
567
  var data = jQuery("#wdi_save_feed").serialize();
568
+ data = data + '&action=wdi_apply_changes&page=wdi_feeds';
 
569
  jQuery("#wdi_save_loading").removeClass("wdi_hidden");
570
  jQuery.ajax({
 
571
  url: wdi_ajax.ajax_url,
572
+ type: 'POST',
573
  dataType: 'json',
574
  data: data,
575
  success: function (response) {
580
  jQuery(".caching-process-message").removeClass("wdi_hidden");
581
  /* TODO Timeout need as loader not appear without timeout, need to fix */
582
  setTimeout(function(){
583
+ wdi_controller.instagram.set_cache_data(comlete_redirect_url, '', feed_id, '', 0, 0, '', '', '', '');
584
  }, 1000);
585
  }
586
  else {
652
  if ( vObj.valid ) {
653
  _this.addHashtag(tagname, response);
654
  }
655
+ else {
656
+ alert( vObj.msg )
657
+ }
658
  },
659
  error: function (xhr, status, error) {
660
  }
896
  obj.msg = wdi_messages.instagram_server_error;
897
  }
898
  else if (response['meta']['code'] !== 200) {
899
+ obj.msg = response['meta']['message'];
900
  }
901
  else {
902
  obj.msg = '';
js/wdi_admin.min.js CHANGED
@@ -1 +1 @@
1
- function wdi_multiple_accounts_option_controller(){var e=jQuery(jQuery("#wdi_user_id").closest("form").find(".form-table").get(1));e.addClass("wdi_multiple_accounts_section");var t="";if(wdi_options.wdi_authenticated_users_list){var i,r=JSON.parse(wdi_options.wdi_authenticated_users_list),a=0;for(i in r)t+="<tr data-multiple-account='"+a+"'>",t+="<th>Access Token</th>",t+='<td><input type="text" name="wdi_instagram_options[wdi_authenticated_users_list][access_token][]" size="53" required="" value="'+r[i].access_token+'"></td>',t+="</tr>",t+="<tr data-multiple-account='"+a+"' class='wdi_username_tr'>",t+="<th>Username</th>",t+='<td><div class="wdi_input_wrapper"><input type="text" name="wdi_instagram_options[wdi_authenticated_users_list][user_name][]" size="53" required="" value="'+r[i].user_name+'"></div><div class="wdi_remove_auth_user">Delete</div></td>',t+='<input type="hidden" name="wdi_instagram_options[wdi_authenticated_users_list][user_id][]" size="53" required="" value="'+r[i].user_id+'">',t+="</tr>",a++;e.append(t)}jQuery(".wdi_remove_auth_user").on("click",function(e){e.preventDefault();e=jQuery(this).closest(".wdi_username_tr").data("multiple-account");return jQuery(this).closest(".wdi_multiple_accounts_section").find('tr[data-multiple-account="'+e+'"]').remove(),!1})}function wdi_advanced_option_controller(){var e=jQuery(jQuery("#wdi_user_id").closest("form").find(".form-table").get(1));e.addClass("wdi_advanced_option wdi_advanced_option_close");$tr=jQuery("<tr class='wdi_advanced_option_head'><th style='width: 100%;'>ADVANCED OPTIONS AND MULTIPLE INSTAGRAM ACCOUNTS</th><td><div class='wdi_advanced_option_icon'></div></td></tr>"),e.prepend($tr),$tr.on("click",function(){e.hasClass("wdi_advanced_option_open")?(e.removeClass("wdi_advanced_option_open"),e.addClass("wdi_advanced_option_close")):(e.removeClass("wdi_advanced_option_close"),e.addClass("wdi_advanced_option_open"))})}function wdi_controller(){}jQuery(document).ready(function(){function e(e){if(!1===e){var t=JSON.parse(localStorage.getItem("wdi_sections"));for(i in null!==t&&!1!==t||(t={wdi_layout_section:"show",wdi_media:"show",wdi_layout:"hide",wdi_advanced:"hide",wdi_lightbox_general:"show",wdi_lightbox_advanced:"hide",wdi_conditional_filters:"show",wdi_how_to_publish:"show"},localStorage.setItem("wdi_sections",JSON.stringify(t))),t){var r=jQuery("#wdi_save_feed").find("[data-section_name='"+i+"']");n(t[i],r)}}else{var a=jQuery(e).data("section_name"),s=null;e.hasClass("wdi_section_open")?(n("show",e),s="show"):e.hasClass("wdi_section_close")&&(n("hide",e),s="hide"),null!=s&&((e=JSON.parse(localStorage.getItem("wdi_sections"))||{})[a]=s,localStorage.setItem("wdi_sections",JSON.stringify(e)))}}function n(e,t){"show"===e?("table"===(e=t.closest(".wdi_section").find(".wdi_elements")).data("display")?e.css({display:"table"}):e.css({display:"block"}),t.css({"border-bottom":"1px solid #f1f1f1",margin:"0 auto 15px"}),t.removeClass("wdi_section_open"),t.addClass("wdi_section_close")):(t.closest(".wdi_section").find(".wdi_elements").css({display:"none"}),t.css({"border-bottom":"0px",margin:"0 auto 0px"}),t.removeClass("wdi_section_close"),t.addClass("wdi_section_open"))}jQuery("#wdi_reset_cache").click(function(e){jQuery(".wdi_reset_cache_success").remove(),jQuery("#wdi_save_loading").removeClass("wdi_hidden"),e.preventDefault(),jQuery.ajax({type:"POST",url:wdi_ajax.ajax_url,dataType:"json",data:{wdi_nonce:wdi_ajax.wdi_nonce,task:"reset",action:"wdi_cache"},success:function(e){!1===e.success?jQuery("#wdi_reset_cache").after("<span class='wdi_reset_cache_success' style='color: #fc0000; margin-left: 15px; line-height: 2;'>Failed</span>"):(wdi_controller.instagram=new WDIInstagram,jQuery.each(e.data,function(e,t){var i=JSON.parse(t.users),r="",a="",s="",n=t.endpoint;jQuery.each(i,function(e,t){""!==t.tag_id?(a=(a=(a=t.username).substr(1,a.length)).replace(" ",""),s=t.tag_id):r=(r=wdi_controller.getUserObj(t.username))&&r.user_name});t=t.feed_id;wdi_controller.instagram.set_cache_data("",r,t,"",0,0,a,s,n,"")}),jQuery("#wdi_reset_cache").after("<span class='wdi_reset_cache_success' style='color: #029117; margin-left: 15px; line-height: 2;'>Success</span>"))}})}),jQuery(".wdi_account_refresh").click(function(){var t=jQuery(this),e=t.data("wdi_account");jQuery.ajax({type:"POST",url:wdi_ajax.ajax_url,dataType:"json",data:{page:"wdi_settings",action:"wdi_account_refresh",nonce:wdi_ajax.wdi_nonce,user_name:e},success:function(e){t.closest("div").find(".wdi_reset_cache_success").remove(),!0===e.success?(t.after("<span class='wdi_reset_cache_success' style='color: #029117; margin-left: 15px; line-height: 2;'>Success</span>"),t.closest("div").find(".wdi_user_token").val(e.token)):t.after("<span class='wdi_reset_cache_success' style='color: #fc0000; margin-left: 15px; line-height: 2;'>Failed</span>")}})}),wdi_controller.bindSaveFeedEvent(),wdi_controller.bindAddNewUserOrHashtagEvent(),jQuery(".display_type input").on("click",function(){wdi_controller.displaySettingsSection(jQuery(this))}),wdi_controller.conditionalFiltersTabInit(),wdi_controller.bindSaveThemeEvent(),jQuery("body").hasClass("instagram-feed_page_wdi_settings")&&wdi_advanced_option_controller(),jQuery(".wdi_section_name").click(function(){e(jQuery(this))}),e(!1),jQuery(document).on("click",".wdi-account-show-token",function(){jQuery(this).find("i").toggleClass("dashicons-arrow-up-alt2 dashicons-arrow-down-alt2"),jQuery(this).parents("li").find(".wdi-account-accesstoken").slideToggle(300)}),jQuery(document).on("click",".wdi-advanced-options .wdi-advanced-headline",function(){jQuery(this).find("i").toggleClass("dashicons-arrow-up-alt2 dashicons-arrow-down-alt2"),jQuery(this).parents(".wdi-advanced-options").find(".wdi-advanced-body").slideToggle(500)}),jQuery(document).on("click","#wdi_verify",function(){jQuery("#wdi_submit").prop("disabled",!0),jQuery(this).is(":checked")&&jQuery("#wdi_submit").prop("disabled",!1)}),jQuery(document).on("click","#wdi_submit",function(){return confirm(wdi_messages.uninstall_plugin)&&jQuery("#wdi_uninstall_form").submit(),!1}),jQuery("#WDI_feed_name").on("keypress",function(){jQuery(this).removeAttr("style")})}),wdi_controller.getParameterByName=function(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");e=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(location.search);return null===e?"":decodeURIComponent(e[1].replace(/\+/g," "))},wdi_controller.apiRedirected=function(){var e=this.getParameterByName("access_token").split("."),t=/^[^\\\/&?><"']*$/;for(i=0;i<e.length;i++)if(null===e[i].match(t))return;var r=e.join(".");jQuery(document).ready(function(){""===wdi_options.wdi_access_token?jQuery("#wdi_access_token").attr("value",r):(jQuery(".wdi_more_token_template .wdi_more_access_token").prop("disabled",!1),jQuery(".wdi_more_token_template .wdi_more_access_token").attr("value",r))}),wdi_controller.instagram.addToken(r),wdi_controller.getUserInfo(r)},wdi_controller.getUserInfo=function(e){this.instagram.getSelfInfo({success:function(e){""===wdi_options.wdi_access_token?(jQuery("#wdi_user_name").attr("value",e.data.username),jQuery("#wdi_user_id").attr("value",e.data.id)):(jQuery(".wdi_more_token_template .wdi_more_user_name").prop("disabled",!1),jQuery(".wdi_more_token_template .wdi_more_user_id").prop("disabled",!1),jQuery(".wdi_more_token_template .wdi_more_user_name").attr("value",e.data.username),jQuery(".wdi_more_token_template .wdi_more_user_id").attr("value",e.data.id)),jQuery(document).trigger("wdi_settings_filled")}})},wdi_controller.oldDisplayType={},wdi_controller.displayTypeMemory={},wdi_controller.switchFeedTabs=function(e,t){jQuery("#wdi_refresh_tab").attr("value",e),jQuery(".wdi_tab").hide(),jQuery("#"+e+"_tab").show(),jQuery(".wdi_element_name_popup_enable_comment").hide(),"business"===jQuery("#WDI_user_name option:selected").data("type")&&jQuery(".wdi_element_name_popup_enable_comment").show(),jQuery(".display_type").css("display","none"),jQuery('.display_type[tab="'+e+'"]').css("display","block"),jQuery('.display_type[tab="'+e+'"]').length?jQuery(".display_type_content").show():jQuery(".display_type_content").hide(),jQuery(".wdi_feed_tabs").filter(".wdi_feed_tab_active").each(function(){jQuery(this).removeClass("wdi_feed_tab_active")}),jQuery("#wdi_"+e).addClass("wdi_feed_tab_active");var i=jQuery(),r=!1;null!=t&&""!=t&&(i=jQuery(".display_type #"+t).prop("checked",!0),jQuery("#wdi_feed_type").attr("value",t)),r||0!=(i=jQuery('.display_type[tab="'+e+'"] input[name="feed_type"]:checked')).length&&(r=!0),r||0!=(i=jQuery('.display_type[tab="'+e+'"] #thumbnails')).length&&(r=!0,i.prop("checked",!0),jQuery("#wdi_feed_type").attr("value","thumbnails")),r&&wdi_controller.displaySettingsSection(i),"conditional_filters"==e&&wdi_controller.updateConditionalFiltersUi()},wdi_controller.displaySettingsSection=function(e){var i=e.attr("id").toLowerCase().trim(),t=e.parent().parent().attr("tab"),e=jQuery("#wdi_refresh_section");wdi_controller.oldDisplayType={section:i,tab:t},wdi_controller.displayTypeMemory[t]=wdi_controller.oldDisplayType,null!=e&&e.attr("value",i);e=jQuery(".wdi_border_wrapper .form-table");jQuery("#wdi_feed_type").attr("value",i);var r=0,a=!1;e.find(".wdi_element").each(function(){0;var e=jQuery(this).find(".wdwt_param").children().children().children().attr("section");if(void 0!==e){a=!1;var t=e.toLowerCase().trim().split(",");for(r=0;r<t.length;r++)t[r]===i&&(jQuery(this).css("display","block"),a=!0);!1===a&&jQuery(this).css("display","none")}})},wdi_controller.switchThemeTabs=function(e,t){jQuery(".wdi_feed_tabs").filter(".wdi_feed_tab_active").each(function(){jQuery(this).removeClass("wdi_feed_tab_active")}),jQuery("#wdi_"+e).addClass("wdi_feed_tab_active"),jQuery("[tab]").each(function(){jQuery(this).attr("tab")!=e?jQuery(this).parent().parent().parent().parent().parent().filter("tr").css("display","none"):jQuery(this).parent().parent().parent().parent().parent().filter("tr").css("display","block")}),jQuery(".display_type").css("display","none"),jQuery('.display_type[tab="'+e+'"]').css("display","block"),jQuery("#wdi_refresh_tab").attr("value",e),null!=t&&""!=t&&jQuery("#wdi_refresh_section").attr("value",t),(null==t&&""!=t?null!=wdi_controller.displayTypeMemory[e]?jQuery(".display_type #"+wdi_controller.displayTypeMemory[e].section):jQuery('.display_type[tab="'+e+'"]').first().find("input"):jQuery(".display_type #"+t)).trigger("click")},wdi_controller.bindSaveFeedEvent=function(){var e=this;jQuery("#wdi_save_feed_submit").on("click",function(){e.save_feed("save_feed")}),jQuery("#wdi_save_feed_apply").on("click",function(){e.save_feed("apply_changes")}),jQuery("#wdi_cancel_changes").on("click",function(){e.save_feed("cancel")})},wdi_controller.save_feed=function(e){var t,i,r,a=[],s={};"cancel"==e&&(window.location=window.location.href),t=jQuery("#WDI_user_name option:selected").data("type"),n=jQuery("#WDI_user_name option:selected").val(),i=jQuery("#WDI_feed_name");var n=wdi_controller.getUserObj(n);if(""==i.val())return alert(wdi_messages.feed_title_field_required),i.focus().attr("style","border-color: #FF0000;"),!1;if(!n)return alert(wdi_messages.user_field_required),!1;if(r={id:n.user_id,username:n.user_name},wdi_controller.checkIfUserNotSaved(e),0==wdi_controller.waitingAjaxRequestEnd.button){if(s=jQuery("#WDI_feed_users").val(),this.isJsonString(s)){for(var d in s=JSON.parse(s))"business"==t&&"#"===s[d].username.charAt(0)&&a.push(s[d]);a.push(r)}else a.push(r);users=this.stringifyUserData(a),jQuery("#WDI_feed_users").val(users),jQuery("#wdi_feed_thumb").val(""),"business"==t&&jQuery("#wdi_feed_thumb").val(n.profile_picture_url),"apply_changes"!=e&&"save_feed"!=e||(n=jQuery("#wdi_add_or_edit").val(),jQuery("#wdi_current_id").val(n)),jQuery("#task").attr("value",e),submit_ajax()}};var comlete_redirect_url="";function submit_ajax(){var e=jQuery("#wdi_save_feed").serialize();e+="&action=wdi_apply_changes&page=wdi_feeds",jQuery("#wdi_save_loading").removeClass("wdi_hidden"),jQuery.ajax({type:"POST",url:wdi_ajax.ajax_url,dataType:"json",data:e,success:function(e){comlete_redirect_url=e.url;var t=e.feed_id;1==e.need_cache?(jQuery(".caching-process-message").removeClass("wdi_hidden"),setTimeout(function(){wdi_controller.instagram.set_cache_data(comlete_redirect_url,"",t,"",0,0,"","","","")},1e3)):(jQuery("#wdi_save_loading").addClass("wdi_hidden"),window.location=comlete_redirect_url)},error:function(e,t,i){window.location=comlete_redirect_url}})}function wdi_spider_select_value(e){e.focus(),e.select()}function wdi_spider_set_input_value(e,t){"add"===t&&""==jQuery("#wdi_access_token").attr("value")&&alert("Please get your access token"),document.getElementById(e)&&(document.getElementById(e).value=t)}function wdi_spider_form_submit(e,t){document.getElementById(t)&&document.getElementById(t).submit(),e.preventDefault?e.preventDefault():e.returnValue=!1}function wdi_bulk_actions(e){e=jQuery(e).val();return""!=e&&(!("delete_all"==e&&!confirm(wdi_messages.do_you_want_to_delete_selected_items))&&(wdi_spider_set_input_value("task",e),jQuery("#wdi_feed_form").submit(),!0))}function wdi_spider_check_all_items(){wdi_spider_check_all_items_checkbox(),jQuery("#check_all").trigger("click")}function wdi_spider_check_all_items_checkbox(){var e;jQuery("#check_all_items").prop("checked")?(jQuery("#check_all_items").prop("checked",!1),jQuery("#draganddrop").hide()):(e=parseInt(jQuery(".displaying-num").html())?parseInt(jQuery(".displaying-num").html()):0,e=(jQuery('input[id^="check_pr_"]').length?parseInt(jQuery('input[id^="check_pr_"]').length):0)+e,jQuery("#check_all_items").prop("checked",!0),e&&(jQuery("#draganddrop").html("<strong><p>Selected "+e+" item"+(1<e?"s":"")+".</p></strong>"),jQuery("#draganddrop").show()))}function wdi_spider_check_all(e){jQuery(e).prop("checked")||(jQuery("#check_all_items").prop("checked",!1),jQuery("#draganddrop").hide())}function wdi_spider_set_input_value(e,t){"add"===t&&""==jQuery("#wdi_access_token").attr("value")&&alert("Please get your access token"),document.getElementById(e)&&(document.getElementById(e).value=t)}function wdi_account_remove(e,t){jQuery.ajax({type:"POST",url:wdi_ajax.ajax_url,dataType:"json",data:{page:"wdi_settings",action:"wdi_account_disconnect",nonce:wdi_ajax.wdi_nonce,user_name:e,user_id:t},success:function(e){e.success&&(1==jQuery('[class*="wdi-account-list"]').length?((e=jQuery(".wdi-account-list-"+t).parent()).prev().remove(),e.remove(),jQuery("#toplevel_page_wdi_feeds ul").remove(),jQuery("#toplevel_page_wdi_feeds a").attr("href","admin.php?page=wdi_settings")):jQuery(".wdi-account-list-"+t).remove())}})}function wdi_popup_open(){jQuery(".wdi-popup").show()}function wdi_popup_close(){jQuery(".wdi-popup").hide()}wdi_controller.makeInstagramUserRequest=function(e,t){var i,r=this,a=this.getInputType(e),s="hashtag"===a;if(""==e)return alert(wdi_messages.please_write_hashtag),!1;if(""!=e&&!s)return alert(wdi_messages.invalid_hashtag),!1;if(r.checkForDuplicateUser(e))return alert(e+" "+wdi_messages.already_added),!1;switch(i=jQuery("#WDI_user_name option:selected").val(),(s=wdi_controller.getUserObj(i))&&(this.instagram.user=s),a){case"user":break;case"hashtag":var n=(n=e.substr(1,e.length)).replace(" ",""),d=(jQuery("input[name='wdi_feed_settings[hashtag_top_recent]']:checked").val(),{tagname:n,action:"wdi_getHashtagId",wdi_nonce:wdi_ajax.wdi_nonce,user_name:i});jQuery.ajax({type:"POST",url:wdi_ajax.ajax_url,dataType:"json",data:d,success:function(e){jQuery("#wdi_add_user_ajax").removeAttr("disabled"),r.isValidResponse(e).valid&&r.addHashtag(n,e)},error:function(e,t,i){}})}},wdi_controller.checkForDuplicateUser=function(e){var t=jQuery("#WDI_feed_users").val();if(this.isJsonString(t)){t=JSON.parse(t);for(var i=0;i<t.length;i++)if(e==t[i].username)return!0}return!1},wdi_controller.getInputType=function(e){switch(e[0]){case"#":return"hashtag";case"%":return"location";default:return"user"}},wdi_controller.stringifyUserData=function(e){for(var t=[],i=0;i<e.length;i++)t.push({id:e[i].id,username:e[i].username,tag_id:void 0!==e[i].tag_id?e[i].tag_id:""});return JSON.stringify(t)},wdi_controller.bindAddNewUserOrHashtagEvent=function(){jQuery("#wdi_add_user_ajax").on("click",function(){void 0!==jQuery(this).prop("disabled")||jQuery(this).prop("disabled",!0);var e=jQuery("#wdi_add_user_ajax_input").val().trim().toLowerCase();!1===wdi_controller.makeInstagramUserRequest(e)&&jQuery(this).removeAttr("disabled","disabled")}),jQuery("#wdi_add_user_ajax_input").on("keypress",function(e){if(13==e.keyCode){void 0!==jQuery("#wdi_add_user_ajax").prop("disabled")||jQuery("#wdi_add_user_ajax").prop("disabled",!0);e=jQuery("#wdi_add_user_ajax_input").val().trim().toLowerCase();return!1===wdi_controller.makeInstagramUserRequest(e)&&jQuery("#wdi_add_user_ajax").removeAttr("disabled","disabled"),!1}})},wdi_controller.removeFeedUser=function(e){var t,i=e.parent().find("a span").text();e.parent().find("a span").hasClass("wdi_hashtag")&&(i="#"+i),0!=this.feed_users.length||void 0!==(t=jQuery("#WDI_feed_users").val())&&this.isJsonString(t)&&(this.feed_users=JSON.parse(t));for(var r=0;r<this.feed_users.length;r++)if(this.feed_users[r].username==i){this.feed_users.splice(r,1);break}for(r=0;r<this.feed_users.length;r++)"#"!==this.feed_users[r].username.charAt(0)&&this.feed_users.splice(r,1);jQuery("#WDI_feed_users").val(this.stringifyUserData(this.feed_users)),e.parent().remove(),wdi_controller.changed_users()},wdi_controller.bindSaveThemeEvent=function(){jQuery("#wdi_save_theme_submit").on("click",function(){jQuery("#task").attr("value","save_feed"),jQuery("#wdi_save_feed").submit()}),jQuery("#wdi_save_theme_apply").on("click",function(){jQuery("#task").attr("value","apply_changes");var e=jQuery("#wdi_add_or_edit").attr("value");jQuery("#wdi_current_id").attr("value",e),jQuery("#wdi_save_feed").submit()}),jQuery("#wdi_save_theme_reset").on("click",function(){jQuery("#task").attr("value","reset_changes");var e=jQuery("#wdi_add_or_edit").attr("value");jQuery("#wdi_current_id").attr("value",e),jQuery("#wdi_save_feed").submit()})},wdi_controller.checkIfUserNotSaved=function(e){switch(e){case"save_feed":e="submit";break;case"apply_changes":e="apply";break;case"reset_changes":e="reset"}if(""==jQuery("#wdi_add_user_ajax_input").val().trim())return wdi_controller.waitingAjaxRequestEnd={button:0},0;var t=jQuery("#wdi_add_user_ajax_input").val().trim().toLowerCase();return wdi_controller.waitingAjaxRequestEnd={button:e},wdi_controller.makeInstagramUserRequest(t),1},wdi_controller.saveFeedAfterAjaxWait=function(e){var t;null!=wdi_controller.waitingAjaxRequestEnd&&(t=wdi_controller.waitingAjaxRequestEnd.button,e&&0!=t&&jQuery("#wdi_save_feed_"+t).trigger("click"),wdi_controller.waitingAjaxRequestEnd=void 0)},wdi_controller.getCookie=function(e){e=("; "+document.cookie).split("; "+e+"=");if(2==e.length)return e.pop().split(";").shift()},wdi_controller.isValidResponse=function(e){var t={};return void 0===e||void 0===e.meta.code||200!=e.meta.code?(t.valid=!1,void 0===e?t.msg=wdi_messages.instagram_server_error:200!==e.meta.code?t.msg=e.meta.error_message:t.msg=""):(t.valid=!0,t.msg="success"),t},wdi_controller.hasData=function(e){return void 0!==e&&void 0!==e.data&&0!=e.data.length},wdi_controller.thumbUser=function(e){return 0<this.feed_users.length&&this.feed_users[0].username===e},wdi_controller.findUser=function(e,t){var i=[];void 0!==t&&void 0!==t.data&&(i=t.data);for(var r=0;r<i.length;r++)if(i[r].username==e)return i[r];return!1},wdi_controller.addHashtag=function(e,t){if(null==e.match(/[~!@$%&*#^()<>?]/)){var i=jQuery('<div class="wdi_user"><a target="_blank" href="https://instagram.com/explore/tags/'+e+'"><img class="wdi_profile_pic" src="'+wdi_url.plugin_url+'images/hashtag.png"><span class="wdi_hashtag">'+e+'</span><i style="display:table-cell;width:25px;"></i></a><img class="wdi_remove_user" onclick="wdi_controller.removeFeedUser(jQuery(this))" src="'+wdi_url.plugin_url+'/images/delete_user.png"></div>');jQuery("#wdi_feed_users_ajax").append(i),jQuery("#wdi_add_user_ajax_input").val("");var r=jQuery("#WDI_feed_users").val();if(this.isJsonString(r)){r=JSON.parse(r);for(var a=0;a<r.length;a++)"#"!==r[a].username.charAt(0)&&r.splice(a,1)}else r=[];t={id:"#"+e,username:"#"+e,profile_picture:"",tag_id:t.tag_id};r.push(t),this.feed_users=r,jQuery("#WDI_feed_users").val(this.stringifyUserData(this.feed_users))}else alert(wdi_messages.invalid_hashtag);this.updateConditionalFiltersUi(),wdi_controller.saveFeedAfterAjaxWait(!0),wdi_controller.changed_users()},wdi_controller.changed_users=function(){for(var e=!1,t=0;t<this.feed_users.length;t++)if("#"===this.feed_users[t].username[0]){e=!0;break}e?(jQuery(".wdi_element_name_hashtag_top_recent").show(),jQuery(".wdi_element_name_show_username_on_thumb").hide()):(jQuery(".wdi_element_name_hashtag_top_recent").hide(),jQuery(".wdi_element_name_show_username_on_thumb").show())},wdi_controller.addUser=function(e){e.username=e.user_name,0==this.checkForDuplicateUser(e.username)?(newUser=jQuery('<div class="wdi_user"><a target="_blank" href="http://www.instagram.com/'+e.username+'"><span class="wdi_username">'+e.username+'</span><i style="display:table-cell;width:25px;"></i></a><img class="wdi_remove_user" onclick="wdi_controller.removeFeedUser(jQuery(this))" src="'+wdi_url.plugin_url+'images/delete_user.png"></div>'),jQuery("#wdi_feed_users_ajax").append(newUser),jQuery("#wdi_add_user_ajax_input").val(""),this.feed_users.push({id:e.id,username:e.username,profile_picture:""})):alert(e.username+" "+wdi_messages.already_added),this.updateConditionalFiltersUi(),wdi_controller.saveFeedAfterAjaxWait(!0)},wdi_controller.getUserProfilePic=function(e){for(var t=0;t<this.feed_users.length;t++)if(e==this.feed_users[t].username)return this.feed_users[t].profile_picture;return"false"},wdi_controller.conditionalFiltersTabInit=function(){this.setInitialFilters(),this.updateFiltersUi();var t=this;function e(){switch(jQuery("#WDI_wrap_conditional_filter_enable input:checked").val()){case"0":jQuery("#WDI_conditional_filters").parent().parent().addClass("wdi_hidden"),jQuery("#WDI_conditional_filter_type").parent().parent().parent().parent().parent().addClass("wdi_hidden"),jQuery("#wdi_final_condition").addClass("wdi_hidden"),jQuery("#WDI_filter_source").addClass("wdi_hidden");break;case"1":jQuery("#WDI_conditional_filters").parent().parent().removeClass("wdi_hidden"),jQuery("#WDI_conditional_filter_type").parent().parent().parent().parent().parent().removeClass("wdi_hidden"),jQuery("#wdi_final_condition").removeClass("wdi_hidden"),jQuery("#WDI_filter_source").removeClass("wdi_hidden")}}jQuery("#wdi_add_filter").on("click",function(){t.addConditionalFilter()&&jQuery("#wdi_filter_input").val("")}),jQuery(".wdi_filter_radio").on("click",function(){jQuery("#wdi_filter_input").trigger("focus")}),jQuery("#wdi_filter_input").on("keypress",function(e){if(13==e.keyCode)return t.addConditionalFilter()&&jQuery(this).val(""),!1}),e(),jQuery("#WDI_wrap_conditional_filter_enable input").on("change",function(){e()}),jQuery("#WDI_conditional_filter_type").on("change",function(){switch("none"==jQuery(this).val()||jQuery("#WDI_conditional_filters").css("display","block"),jQuery(this).parent().find("label").css({display:"inline-block"}),jQuery(this).val()){case"AND":jQuery("#WDI_conditional_filters").css("display","block"),jQuery(this).parent().find("label").html(wdi_messages.and_descr);break;case"OR":jQuery("#WDI_conditional_filters").css("display","block"),jQuery(this).parent().find("label").html(wdi_messages.or_descr);break;case"NOR":jQuery("#WDI_conditional_filters").css("display","block"),jQuery(this).parent().find("label").html(wdi_messages.nor_descr)}wdi_controller.updateFiltersUi()}),jQuery("#WDI_conditional_filter_type").trigger("change")},wdi_controller.addConditionalFilter=function(){var e=jQuery("#wdi_filter_input").val(),t=jQuery("#wdi_filter_type").val();if(filter={},""==e)return!1;switch(e=e.trim(),null==t&&("@"==e[0]?t="mention":"#"==e[0]?t="hashtag":"http"!=e.split("://")[0]&&"https"!=e.split("://")[0]||(t="url")),t){case"username":case"mention":"@"==e[0]&&(e=e.substr(1,e.length));break;case"hashtag":"#"==e[0]&&(e=e.substr(1,e.length));break;case"url":if(!/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(e))return alert(wdi_messages.invalid_url),!1}return filter={filter_type:t,filter_by:e,id:this.randomId()},null!=t?this.filterExists(filter)?(alert(e+" "+wdi_messages.already_added),!1):(this.conditionalFilters.push(filter),this.updateFiltersUi(),!0):(alert(wdi_messages.selectConditionType),!1)},wdi_controller.filterExists=function(e){for(var t=0;t<this.conditionalFilters.length;t++)if(this.conditionalFilters[t].filter_type==e.filter_type&&this.conditionalFilters[t].filter_by==e.filter_by)return!0;return!1},wdi_controller.updateFiltersUi=function(){for(var e,t=jQuery("#wdi_filters_ui").html(""),i=0;i<this.conditionalFilters.length;i++){if(0==i)if(1!=this.conditionalFilters.length)switch(jQuery("#WDI_conditional_filter_type").val()){case"AND":break;case"OR":t.append(jQuery('<span class="wdi_logic">'+wdi_messages.either+"</span>"));break;case"NOR":t.append(jQuery('<span class="wdi_logic">'+wdi_messages.neither+"</span>"))}else switch(jQuery("#WDI_conditional_filter_type").val()){case"AND":case"OR":break;case"NOR":t.append(jQuery('<span class="wdi_logic">'+wdi_messages.not+"</span>"))}switch(jQuery("#WDI_conditional_filter_type").val()){case"AND":e=wdi_messages.and;break;case"OR":e=wdi_messages.or;break;case"NOR":e=wdi_messages.nor}1<=i&&t.append(jQuery('<span class="wdi_logic">'+e+"</span>")),t.append(this.createUiElement(this.conditionalFilters[i]))}this.updateFilterTextarea()},wdi_controller.createUiElement=function(e){var t;switch(e.filter_type){case"mention":t="@";break;case"hashtag":t="#";break;case"location":t="%";break;default:t=""}return jQuery('<span data-id="'+e.id+'" class="wdi_filter_item wdi_filter_by_'+e.filter_type+'"></span>').html(t+e.filter_by+'<span onclick="wdi_controller.removeConditionalFilter(jQuery(this));" class="wdi_remove_filter">X</span>')},wdi_controller.randomId=function(){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=0;i<5;i++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},wdi_controller.removeConditionalFilter=function(e){for(var t=e.parent().attr("data-id"),i=0;i<this.conditionalFilters.length;i++)this.conditionalFilters[i].id==t&&this.conditionalFilters.splice(i,1);this.updateFiltersUi()},wdi_controller.updateFilterTextarea=function(){var e=this.conditionalFilters,e=JSON.stringify(e);jQuery("#wdi_conditional_filters_textarea").val(e)},wdi_controller.setInitialFilters=function(){var e=[],t=jQuery("#wdi_conditional_filters_textarea").val();this.isJsonString(t)&&(e=JSON.parse(t)),this.conditionalFilters=e},wdi_controller.updateConditionalFiltersUi=function(){wdi_controller.updateFilterSource()},wdi_controller.updateFilterSource=function(){if("liked"!=jQuery('input[name="wdi_feed_settings[liked_feed]"]:checked').val()){var e,t,i=[];jQuery(".wdi_user").each(function(){e=(0!=jQuery(this).find(".wdi_username").length?jQuery(this).find(".wdi_username"):jQuery(this).find(".wdi_hashtag")).text(),t=jQuery(this).find("img").attr("src"),i.push({username:e,image:t})});for(var r=jQuery("#wdi_filter_source").html(""),a=0;a<i.length;a++){s="<div class='wdi_source_user'><span class='wdi_source_img'><img src='"+i[a].image+"'></span><span class='wdi_source_username'>"+i[a].username+"</span></div>";r.html(r.html()+s)}}else{var r,s="<div class='wdi_source_user'><span class='wdi_source_username'>Media I liked</span></div>";(r=jQuery("#wdi_filter_source").html("")).html(r.html()+s)}},wdi_controller.isJsonString=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},wdi_controller.getUserObj=function(e){var t=JSON.parse(wdi_options.wdi_authenticated_users_list);if("object"==typeof t){if("object"==typeof t[e]&&""!=t[e])return t[e];console.log("Error: User not exist on Users object")}else console.log("Error: Wrong response when parsed on users (JSON.parse)");return!1};
1
+ function wdi_multiple_accounts_option_controller(){var e=jQuery(jQuery("#wdi_user_id").closest("form").find(".form-table").get(1));e.addClass("wdi_multiple_accounts_section");var t="";if(wdi_options.wdi_authenticated_users_list){var i,r=JSON.parse(wdi_options.wdi_authenticated_users_list),a=0;for(i in r)t+="<tr data-multiple-account='"+a+"'>",t+="<th>Access Token</th>",t+='<td><input type="text" name="wdi_instagram_options[wdi_authenticated_users_list][access_token][]" size="53" required="" value="'+r[i].access_token+'"></td>',t+="</tr>",t+="<tr data-multiple-account='"+a+"' class='wdi_username_tr'>",t+="<th>Username</th>",t+='<td><div class="wdi_input_wrapper"><input type="text" name="wdi_instagram_options[wdi_authenticated_users_list][user_name][]" size="53" required="" value="'+r[i].user_name+'"></div><div class="wdi_remove_auth_user">Delete</div></td>',t+='<input type="hidden" name="wdi_instagram_options[wdi_authenticated_users_list][user_id][]" size="53" required="" value="'+r[i].user_id+'">',t+="</tr>",a++;e.append(t)}jQuery(".wdi_remove_auth_user").on("click",function(e){e.preventDefault();e=jQuery(this).closest(".wdi_username_tr").data("multiple-account");return jQuery(this).closest(".wdi_multiple_accounts_section").find('tr[data-multiple-account="'+e+'"]').remove(),!1})}function wdi_advanced_option_controller(){var e=jQuery(jQuery("#wdi_user_id").closest("form").find(".form-table").get(1));e.addClass("wdi_advanced_option wdi_advanced_option_close");$tr=jQuery("<tr class='wdi_advanced_option_head'><th style='width: 100%;'>ADVANCED OPTIONS AND MULTIPLE INSTAGRAM ACCOUNTS</th><td><div class='wdi_advanced_option_icon'></div></td></tr>"),e.prepend($tr),$tr.on("click",function(){e.hasClass("wdi_advanced_option_open")?(e.removeClass("wdi_advanced_option_open"),e.addClass("wdi_advanced_option_close")):(e.removeClass("wdi_advanced_option_close"),e.addClass("wdi_advanced_option_open"))})}function wdi_controller(){}jQuery(document).ready(function(){function e(e){if(!1===e){var t=JSON.parse(localStorage.getItem("wdi_sections"));for(i in null!==t&&!1!==t||(t={wdi_layout_section:"show",wdi_media:"show",wdi_layout:"hide",wdi_advanced:"hide",wdi_lightbox_general:"show",wdi_lightbox_advanced:"hide",wdi_conditional_filters:"show",wdi_how_to_publish:"show"},localStorage.setItem("wdi_sections",JSON.stringify(t))),t){var r=jQuery("#wdi_save_feed").find("[data-section_name='"+i+"']");n(t[i],r)}}else{var a=jQuery(e).data("section_name"),s=null;e.hasClass("wdi_section_open")?(n("show",e),s="show"):e.hasClass("wdi_section_close")&&(n("hide",e),s="hide"),null!=s&&((e=JSON.parse(localStorage.getItem("wdi_sections"))||{})[a]=s,localStorage.setItem("wdi_sections",JSON.stringify(e)))}}function n(e,t){"show"===e?("table"===(e=t.closest(".wdi_section").find(".wdi_elements")).data("display")?e.css({display:"table"}):e.css({display:"block"}),t.css({"border-bottom":"1px solid #f1f1f1",margin:"0 auto 15px"}),t.removeClass("wdi_section_open"),t.addClass("wdi_section_close")):(t.closest(".wdi_section").find(".wdi_elements").css({display:"none"}),t.css({"border-bottom":"0px",margin:"0 auto 0px"}),t.removeClass("wdi_section_close"),t.addClass("wdi_section_open"))}jQuery("#wdi_reset_cache").click(function(e){jQuery(".wdi_reset_cache_success").remove(),jQuery("#wdi_save_loading").removeClass("wdi_hidden"),e.preventDefault(),jQuery.ajax({type:"POST",url:wdi_ajax.ajax_url,dataType:"json",data:{wdi_nonce:wdi_ajax.wdi_nonce,task:"reset",action:"wdi_cache"},success:function(e){!1===e.success?jQuery("#wdi_reset_cache").after("<span class='wdi_reset_cache_success' style='color: #fc0000; margin-left: 15px; line-height: 2;'>Failed</span>"):(wdi_controller.instagram=new WDIInstagram,jQuery.each(e.data,function(e,t){var i=JSON.parse(t.users),r="",a="",s="",n=t.endpoint;jQuery.each(i,function(e,t){""!==t.tag_id?(a=(a=(a=t.username).substr(1,a.length)).replace(" ",""),s=t.tag_id):r=(r=wdi_controller.getUserObj(t.username))&&r.user_name});t=t.feed_id;wdi_controller.instagram.set_cache_data("",r,t,"",0,0,a,s,n,"")}),jQuery("#wdi_reset_cache").after("<span class='wdi_reset_cache_success' style='color: #029117; margin-left: 15px; line-height: 2;'>Success</span>"))}})}),jQuery(".wdi_account_refresh").click(function(){var t=jQuery(this),e=t.data("wdi_account");jQuery.ajax({type:"POST",url:wdi_ajax.ajax_url,dataType:"json",data:{page:"wdi_settings",action:"wdi_account_refresh",nonce:wdi_ajax.wdi_nonce,user_name:e},success:function(e){t.closest("div").find(".wdi_reset_cache_success").remove(),!0===e.success?(t.after("<span class='wdi_reset_cache_success' style='color: #029117; margin-left: 15px; line-height: 2;'>Success</span>"),t.closest("div").find(".wdi_user_token").val(e.token)):t.after("<span class='wdi_reset_cache_success' style='color: #fc0000; margin-left: 15px; line-height: 2;'>Failed</span>")}})}),wdi_controller.bindSaveFeedEvent(),wdi_controller.bindAddNewUserOrHashtagEvent(),jQuery(".display_type input").on("click",function(){wdi_controller.displaySettingsSection(jQuery(this))}),wdi_controller.conditionalFiltersTabInit(),wdi_controller.bindSaveThemeEvent(),jQuery("body").hasClass("instagram-feed_page_wdi_settings")&&wdi_advanced_option_controller(),jQuery(".wdi_section_name").click(function(){e(jQuery(this))}),e(!1),jQuery(document).on("click",".wdi-account-show-token",function(){jQuery(this).find("i").toggleClass("dashicons-arrow-up-alt2 dashicons-arrow-down-alt2"),jQuery(this).parents("li").find(".wdi-account-accesstoken").slideToggle(300)}),jQuery(document).on("click",".wdi-advanced-options .wdi-advanced-headline",function(){jQuery(this).find("i").toggleClass("dashicons-arrow-up-alt2 dashicons-arrow-down-alt2"),jQuery(this).parents(".wdi-advanced-options").find(".wdi-advanced-body").slideToggle(500)}),jQuery(document).on("click","#wdi_verify",function(){jQuery("#wdi_submit").prop("disabled",!0),jQuery(this).is(":checked")&&jQuery("#wdi_submit").prop("disabled",!1)}),jQuery(document).on("click","#wdi_submit",function(){return confirm(wdi_messages.uninstall_plugin)&&jQuery("#wdi_uninstall_form").submit(),!1}),jQuery("#WDI_feed_name").on("keypress",function(){jQuery(this).removeAttr("style")})}),wdi_controller.getParameterByName=function(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");e=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(location.search);return null===e?"":decodeURIComponent(e[1].replace(/\+/g," "))},wdi_controller.apiRedirected=function(){var e=this.getParameterByName("access_token").split("."),t=/^[^\\\/&?><"']*$/;for(i=0;i<e.length;i++)if(null===e[i].match(t))return;var r=e.join(".");jQuery(document).ready(function(){""===wdi_options.wdi_access_token?jQuery("#wdi_access_token").attr("value",r):(jQuery(".wdi_more_token_template .wdi_more_access_token").prop("disabled",!1),jQuery(".wdi_more_token_template .wdi_more_access_token").attr("value",r))}),wdi_controller.instagram.addToken(r),wdi_controller.getUserInfo(r)},wdi_controller.getUserInfo=function(e){this.instagram.getSelfInfo({success:function(e){""===wdi_options.wdi_access_token?(jQuery("#wdi_user_name").attr("value",e.data.username),jQuery("#wdi_user_id").attr("value",e.data.id)):(jQuery(".wdi_more_token_template .wdi_more_user_name").prop("disabled",!1),jQuery(".wdi_more_token_template .wdi_more_user_id").prop("disabled",!1),jQuery(".wdi_more_token_template .wdi_more_user_name").attr("value",e.data.username),jQuery(".wdi_more_token_template .wdi_more_user_id").attr("value",e.data.id)),jQuery(document).trigger("wdi_settings_filled")}})},wdi_controller.oldDisplayType={},wdi_controller.displayTypeMemory={},wdi_controller.switchFeedTabs=function(e,t){jQuery("#wdi_refresh_tab").attr("value",e),jQuery(".wdi_tab").hide(),jQuery("#"+e+"_tab").show(),jQuery(".wdi_element_name_popup_enable_comment").hide(),"business"===jQuery("#WDI_user_name option:selected").data("type")&&jQuery(".wdi_element_name_popup_enable_comment").show(),jQuery(".display_type").css("display","none"),jQuery('.display_type[tab="'+e+'"]').css("display","block"),jQuery('.display_type[tab="'+e+'"]').length?jQuery(".display_type_content").show():jQuery(".display_type_content").hide(),jQuery(".wdi_feed_tabs").filter(".wdi_feed_tab_active").each(function(){jQuery(this).removeClass("wdi_feed_tab_active")}),jQuery("#wdi_"+e).addClass("wdi_feed_tab_active");var i=jQuery(),r=!1;null!=t&&""!=t&&(i=jQuery(".display_type #"+t).prop("checked",!0),jQuery("#wdi_feed_type").attr("value",t)),r||0!=(i=jQuery('.display_type[tab="'+e+'"] input[name="feed_type"]:checked')).length&&(r=!0),r||0!=(i=jQuery('.display_type[tab="'+e+'"] #thumbnails')).length&&(r=!0,i.prop("checked",!0),jQuery("#wdi_feed_type").attr("value","thumbnails")),r&&wdi_controller.displaySettingsSection(i),"conditional_filters"==e&&wdi_controller.updateConditionalFiltersUi()},wdi_controller.displaySettingsSection=function(e){var i=e.attr("id").toLowerCase().trim(),t=e.parent().parent().attr("tab"),e=jQuery("#wdi_refresh_section");wdi_controller.oldDisplayType={section:i,tab:t},wdi_controller.displayTypeMemory[t]=wdi_controller.oldDisplayType,null!=e&&e.attr("value",i);e=jQuery(".wdi_border_wrapper .form-table");jQuery("#wdi_feed_type").attr("value",i);var r=0,a=!1;e.find(".wdi_element").each(function(){0;var e=jQuery(this).find(".wdwt_param").children().children().children().attr("section");if(void 0!==e){a=!1;var t=e.toLowerCase().trim().split(",");for(r=0;r<t.length;r++)t[r]===i&&(jQuery(this).css("display","block"),a=!0);!1===a&&jQuery(this).css("display","none")}})},wdi_controller.switchThemeTabs=function(e,t){jQuery(".wdi_feed_tabs").filter(".wdi_feed_tab_active").each(function(){jQuery(this).removeClass("wdi_feed_tab_active")}),jQuery("#wdi_"+e).addClass("wdi_feed_tab_active"),jQuery("[tab]").each(function(){jQuery(this).attr("tab")!=e?jQuery(this).parent().parent().parent().parent().parent().filter("tr").css("display","none"):jQuery(this).parent().parent().parent().parent().parent().filter("tr").css("display","block")}),jQuery(".display_type").css("display","none"),jQuery('.display_type[tab="'+e+'"]').css("display","block"),jQuery("#wdi_refresh_tab").attr("value",e),null!=t&&""!=t&&jQuery("#wdi_refresh_section").attr("value",t),(null==t&&""!=t?null!=wdi_controller.displayTypeMemory[e]?jQuery(".display_type #"+wdi_controller.displayTypeMemory[e].section):jQuery('.display_type[tab="'+e+'"]').first().find("input"):jQuery(".display_type #"+t)).trigger("click")},wdi_controller.bindSaveFeedEvent=function(){var e=this;jQuery("#wdi_save_feed_submit").on("click",function(){e.save_feed("save_feed")}),jQuery("#wdi_save_feed_apply").on("click",function(){e.save_feed("apply_changes")}),jQuery("#wdi_cancel_changes").on("click",function(){e.save_feed("cancel")})},wdi_controller.save_feed=function(e){var t,i,r,a=[],s={};"cancel"==e&&(window.location=window.location.href),t=jQuery("#WDI_user_name option:selected").data("type"),n=jQuery("#WDI_user_name option:selected").val(),i=jQuery("#WDI_feed_name");var n=wdi_controller.getUserObj(n);if(""==i.val())return alert(wdi_messages.feed_title_field_required),i.focus().attr("style","border-color: #FF0000;"),!1;if(!n)return alert(wdi_messages.user_field_required),!1;if(r={id:n.user_id,username:n.user_name},wdi_controller.checkIfUserNotSaved(e),0==wdi_controller.waitingAjaxRequestEnd.button){if(s=jQuery("#WDI_feed_users").val(),this.isJsonString(s)){for(var d in s=JSON.parse(s))"business"==t&&"#"===s[d].username.charAt(0)&&a.push(s[d]);a.push(r)}else a.push(r);users=this.stringifyUserData(a),jQuery("#WDI_feed_users").val(users),jQuery("#wdi_feed_thumb").val(""),"business"==t&&jQuery("#wdi_feed_thumb").val(n.profile_picture_url),"apply_changes"!=e&&"save_feed"!=e||(n=jQuery("#wdi_add_or_edit").val(),jQuery("#wdi_current_id").val(n)),jQuery("#task").attr("value",e),submit_ajax()}};var comlete_redirect_url="";function submit_ajax(){var e=jQuery("#wdi_save_feed").serialize();e+="&action=wdi_apply_changes&page=wdi_feeds",jQuery("#wdi_save_loading").removeClass("wdi_hidden"),jQuery.ajax({url:wdi_ajax.ajax_url,type:"POST",dataType:"json",data:e,success:function(e){comlete_redirect_url=e.url;var t=e.feed_id;1==e.need_cache?(jQuery(".caching-process-message").removeClass("wdi_hidden"),setTimeout(function(){wdi_controller.instagram.set_cache_data(comlete_redirect_url,"",t,"",0,0,"","","","")},1e3)):(jQuery("#wdi_save_loading").addClass("wdi_hidden"),window.location=comlete_redirect_url)},error:function(e,t,i){window.location=comlete_redirect_url}})}function wdi_spider_select_value(e){e.focus(),e.select()}function wdi_spider_set_input_value(e,t){"add"===t&&""==jQuery("#wdi_access_token").attr("value")&&alert("Please get your access token"),document.getElementById(e)&&(document.getElementById(e).value=t)}function wdi_spider_form_submit(e,t){document.getElementById(t)&&document.getElementById(t).submit(),e.preventDefault?e.preventDefault():e.returnValue=!1}function wdi_bulk_actions(e){e=jQuery(e).val();return""!=e&&(!("delete_all"==e&&!confirm(wdi_messages.do_you_want_to_delete_selected_items))&&(wdi_spider_set_input_value("task",e),jQuery("#wdi_feed_form").submit(),!0))}function wdi_spider_check_all_items(){wdi_spider_check_all_items_checkbox(),jQuery("#check_all").trigger("click")}function wdi_spider_check_all_items_checkbox(){var e;jQuery("#check_all_items").prop("checked")?(jQuery("#check_all_items").prop("checked",!1),jQuery("#draganddrop").hide()):(e=parseInt(jQuery(".displaying-num").html())?parseInt(jQuery(".displaying-num").html()):0,e=(jQuery('input[id^="check_pr_"]').length?parseInt(jQuery('input[id^="check_pr_"]').length):0)+e,jQuery("#check_all_items").prop("checked",!0),e&&(jQuery("#draganddrop").html("<strong><p>Selected "+e+" item"+(1<e?"s":"")+".</p></strong>"),jQuery("#draganddrop").show()))}function wdi_spider_check_all(e){jQuery(e).prop("checked")||(jQuery("#check_all_items").prop("checked",!1),jQuery("#draganddrop").hide())}function wdi_spider_set_input_value(e,t){"add"===t&&""==jQuery("#wdi_access_token").attr("value")&&alert("Please get your access token"),document.getElementById(e)&&(document.getElementById(e).value=t)}function wdi_account_remove(e,t){jQuery.ajax({type:"POST",url:wdi_ajax.ajax_url,dataType:"json",data:{page:"wdi_settings",action:"wdi_account_disconnect",nonce:wdi_ajax.wdi_nonce,user_name:e,user_id:t},success:function(e){e.success&&(1==jQuery('[class*="wdi-account-list"]').length?((e=jQuery(".wdi-account-list-"+t).parent()).prev().remove(),e.remove(),jQuery("#toplevel_page_wdi_feeds ul").remove(),jQuery("#toplevel_page_wdi_feeds a").attr("href","admin.php?page=wdi_settings")):jQuery(".wdi-account-list-"+t).remove())}})}function wdi_popup_open(){jQuery(".wdi-popup").show()}function wdi_popup_close(){jQuery(".wdi-popup").hide()}wdi_controller.makeInstagramUserRequest=function(e,t){var i,r=this,a=this.getInputType(e),s="hashtag"===a;if(""==e)return alert(wdi_messages.please_write_hashtag),!1;if(""!=e&&!s)return alert(wdi_messages.invalid_hashtag),!1;if(r.checkForDuplicateUser(e))return alert(e+" "+wdi_messages.already_added),!1;switch(i=jQuery("#WDI_user_name option:selected").val(),(s=wdi_controller.getUserObj(i))&&(this.instagram.user=s),a){case"user":break;case"hashtag":var n=(n=e.substr(1,e.length)).replace(" ",""),d=(jQuery("input[name='wdi_feed_settings[hashtag_top_recent]']:checked").val(),{tagname:n,action:"wdi_getHashtagId",wdi_nonce:wdi_ajax.wdi_nonce,user_name:i});jQuery.ajax({type:"POST",url:wdi_ajax.ajax_url,dataType:"json",data:d,success:function(e){jQuery("#wdi_add_user_ajax").removeAttr("disabled");var t=r.isValidResponse(e);t.valid?r.addHashtag(n,e):alert(t.msg)},error:function(e,t,i){}})}},wdi_controller.checkForDuplicateUser=function(e){var t=jQuery("#WDI_feed_users").val();if(this.isJsonString(t)){t=JSON.parse(t);for(var i=0;i<t.length;i++)if(e==t[i].username)return!0}return!1},wdi_controller.getInputType=function(e){switch(e[0]){case"#":return"hashtag";case"%":return"location";default:return"user"}},wdi_controller.stringifyUserData=function(e){for(var t=[],i=0;i<e.length;i++)t.push({id:e[i].id,username:e[i].username,tag_id:void 0!==e[i].tag_id?e[i].tag_id:""});return JSON.stringify(t)},wdi_controller.bindAddNewUserOrHashtagEvent=function(){jQuery("#wdi_add_user_ajax").on("click",function(){void 0!==jQuery(this).prop("disabled")||jQuery(this).prop("disabled",!0);var e=jQuery("#wdi_add_user_ajax_input").val().trim().toLowerCase();!1===wdi_controller.makeInstagramUserRequest(e)&&jQuery(this).removeAttr("disabled","disabled")}),jQuery("#wdi_add_user_ajax_input").on("keypress",function(e){if(13==e.keyCode){void 0!==jQuery("#wdi_add_user_ajax").prop("disabled")||jQuery("#wdi_add_user_ajax").prop("disabled",!0);e=jQuery("#wdi_add_user_ajax_input").val().trim().toLowerCase();return!1===wdi_controller.makeInstagramUserRequest(e)&&jQuery("#wdi_add_user_ajax").removeAttr("disabled","disabled"),!1}})},wdi_controller.removeFeedUser=function(e){var t,i=e.parent().find("a span").text();e.parent().find("a span").hasClass("wdi_hashtag")&&(i="#"+i),0!=this.feed_users.length||void 0!==(t=jQuery("#WDI_feed_users").val())&&this.isJsonString(t)&&(this.feed_users=JSON.parse(t));for(var r=0;r<this.feed_users.length;r++)if(this.feed_users[r].username==i){this.feed_users.splice(r,1);break}for(r=0;r<this.feed_users.length;r++)"#"!==this.feed_users[r].username.charAt(0)&&this.feed_users.splice(r,1);jQuery("#WDI_feed_users").val(this.stringifyUserData(this.feed_users)),e.parent().remove(),wdi_controller.changed_users()},wdi_controller.bindSaveThemeEvent=function(){jQuery("#wdi_save_theme_submit").on("click",function(){jQuery("#task").attr("value","save_feed"),jQuery("#wdi_save_feed").submit()}),jQuery("#wdi_save_theme_apply").on("click",function(){jQuery("#task").attr("value","apply_changes");var e=jQuery("#wdi_add_or_edit").attr("value");jQuery("#wdi_current_id").attr("value",e),jQuery("#wdi_save_feed").submit()}),jQuery("#wdi_save_theme_reset").on("click",function(){jQuery("#task").attr("value","reset_changes");var e=jQuery("#wdi_add_or_edit").attr("value");jQuery("#wdi_current_id").attr("value",e),jQuery("#wdi_save_feed").submit()})},wdi_controller.checkIfUserNotSaved=function(e){switch(e){case"save_feed":e="submit";break;case"apply_changes":e="apply";break;case"reset_changes":e="reset"}if(""==jQuery("#wdi_add_user_ajax_input").val().trim())return wdi_controller.waitingAjaxRequestEnd={button:0},0;var t=jQuery("#wdi_add_user_ajax_input").val().trim().toLowerCase();return wdi_controller.waitingAjaxRequestEnd={button:e},wdi_controller.makeInstagramUserRequest(t),1},wdi_controller.saveFeedAfterAjaxWait=function(e){var t;null!=wdi_controller.waitingAjaxRequestEnd&&(t=wdi_controller.waitingAjaxRequestEnd.button,e&&0!=t&&jQuery("#wdi_save_feed_"+t).trigger("click"),wdi_controller.waitingAjaxRequestEnd=void 0)},wdi_controller.getCookie=function(e){e=("; "+document.cookie).split("; "+e+"=");if(2==e.length)return e.pop().split(";").shift()},wdi_controller.isValidResponse=function(e){var t={};return void 0===e||void 0===e.meta.code||200!=e.meta.code?(t.valid=!1,void 0===e?t.msg=wdi_messages.instagram_server_error:200!==e.meta.code?t.msg=e.meta.message:t.msg=""):(t.valid=!0,t.msg="success"),t},wdi_controller.hasData=function(e){return void 0!==e&&void 0!==e.data&&0!=e.data.length},wdi_controller.thumbUser=function(e){return 0<this.feed_users.length&&this.feed_users[0].username===e},wdi_controller.findUser=function(e,t){var i=[];void 0!==t&&void 0!==t.data&&(i=t.data);for(var r=0;r<i.length;r++)if(i[r].username==e)return i[r];return!1},wdi_controller.addHashtag=function(e,t){if(null==e.match(/[~!@$%&*#^()<>?]/)){var i=jQuery('<div class="wdi_user"><a target="_blank" href="https://instagram.com/explore/tags/'+e+'"><img class="wdi_profile_pic" src="'+wdi_url.plugin_url+'images/hashtag.png"><span class="wdi_hashtag">'+e+'</span><i style="display:table-cell;width:25px;"></i></a><img class="wdi_remove_user" onclick="wdi_controller.removeFeedUser(jQuery(this))" src="'+wdi_url.plugin_url+'/images/delete_user.png"></div>');jQuery("#wdi_feed_users_ajax").append(i),jQuery("#wdi_add_user_ajax_input").val("");var r=jQuery("#WDI_feed_users").val();if(this.isJsonString(r)){r=JSON.parse(r);for(var a=0;a<r.length;a++)"#"!==r[a].username.charAt(0)&&r.splice(a,1)}else r=[];t={id:"#"+e,username:"#"+e,profile_picture:"",tag_id:t.tag_id};r.push(t),this.feed_users=r,jQuery("#WDI_feed_users").val(this.stringifyUserData(this.feed_users))}else alert(wdi_messages.invalid_hashtag);this.updateConditionalFiltersUi(),wdi_controller.saveFeedAfterAjaxWait(!0),wdi_controller.changed_users()},wdi_controller.changed_users=function(){for(var e=!1,t=0;t<this.feed_users.length;t++)if("#"===this.feed_users[t].username[0]){e=!0;break}e?(jQuery(".wdi_element_name_hashtag_top_recent").show(),jQuery(".wdi_element_name_show_username_on_thumb").hide()):(jQuery(".wdi_element_name_hashtag_top_recent").hide(),jQuery(".wdi_element_name_show_username_on_thumb").show())},wdi_controller.addUser=function(e){e.username=e.user_name,0==this.checkForDuplicateUser(e.username)?(newUser=jQuery('<div class="wdi_user"><a target="_blank" href="http://www.instagram.com/'+e.username+'"><span class="wdi_username">'+e.username+'</span><i style="display:table-cell;width:25px;"></i></a><img class="wdi_remove_user" onclick="wdi_controller.removeFeedUser(jQuery(this))" src="'+wdi_url.plugin_url+'images/delete_user.png"></div>'),jQuery("#wdi_feed_users_ajax").append(newUser),jQuery("#wdi_add_user_ajax_input").val(""),this.feed_users.push({id:e.id,username:e.username,profile_picture:""})):alert(e.username+" "+wdi_messages.already_added),this.updateConditionalFiltersUi(),wdi_controller.saveFeedAfterAjaxWait(!0)},wdi_controller.getUserProfilePic=function(e){for(var t=0;t<this.feed_users.length;t++)if(e==this.feed_users[t].username)return this.feed_users[t].profile_picture;return"false"},wdi_controller.conditionalFiltersTabInit=function(){this.setInitialFilters(),this.updateFiltersUi();var t=this;function e(){switch(jQuery("#WDI_wrap_conditional_filter_enable input:checked").val()){case"0":jQuery("#WDI_conditional_filters").parent().parent().addClass("wdi_hidden"),jQuery("#WDI_conditional_filter_type").parent().parent().parent().parent().parent().addClass("wdi_hidden"),jQuery("#wdi_final_condition").addClass("wdi_hidden"),jQuery("#WDI_filter_source").addClass("wdi_hidden");break;case"1":jQuery("#WDI_conditional_filters").parent().parent().removeClass("wdi_hidden"),jQuery("#WDI_conditional_filter_type").parent().parent().parent().parent().parent().removeClass("wdi_hidden"),jQuery("#wdi_final_condition").removeClass("wdi_hidden"),jQuery("#WDI_filter_source").removeClass("wdi_hidden")}}jQuery("#wdi_add_filter").on("click",function(){t.addConditionalFilter()&&jQuery("#wdi_filter_input").val("")}),jQuery(".wdi_filter_radio").on("click",function(){jQuery("#wdi_filter_input").trigger("focus")}),jQuery("#wdi_filter_input").on("keypress",function(e){if(13==e.keyCode)return t.addConditionalFilter()&&jQuery(this).val(""),!1}),e(),jQuery("#WDI_wrap_conditional_filter_enable input").on("change",function(){e()}),jQuery("#WDI_conditional_filter_type").on("change",function(){switch("none"==jQuery(this).val()||jQuery("#WDI_conditional_filters").css("display","block"),jQuery(this).parent().find("label").css({display:"inline-block"}),jQuery(this).val()){case"AND":jQuery("#WDI_conditional_filters").css("display","block"),jQuery(this).parent().find("label").html(wdi_messages.and_descr);break;case"OR":jQuery("#WDI_conditional_filters").css("display","block"),jQuery(this).parent().find("label").html(wdi_messages.or_descr);break;case"NOR":jQuery("#WDI_conditional_filters").css("display","block"),jQuery(this).parent().find("label").html(wdi_messages.nor_descr)}wdi_controller.updateFiltersUi()}),jQuery("#WDI_conditional_filter_type").trigger("change")},wdi_controller.addConditionalFilter=function(){var e=jQuery("#wdi_filter_input").val(),t=jQuery("#wdi_filter_type").val();if(filter={},""==e)return!1;switch(e=e.trim(),null==t&&("@"==e[0]?t="mention":"#"==e[0]?t="hashtag":"http"!=e.split("://")[0]&&"https"!=e.split("://")[0]||(t="url")),t){case"username":case"mention":"@"==e[0]&&(e=e.substr(1,e.length));break;case"hashtag":"#"==e[0]&&(e=e.substr(1,e.length));break;case"url":if(!/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(e))return alert(wdi_messages.invalid_url),!1}return filter={filter_type:t,filter_by:e,id:this.randomId()},null!=t?this.filterExists(filter)?(alert(e+" "+wdi_messages.already_added),!1):(this.conditionalFilters.push(filter),this.updateFiltersUi(),!0):(alert(wdi_messages.selectConditionType),!1)},wdi_controller.filterExists=function(e){for(var t=0;t<this.conditionalFilters.length;t++)if(this.conditionalFilters[t].filter_type==e.filter_type&&this.conditionalFilters[t].filter_by==e.filter_by)return!0;return!1},wdi_controller.updateFiltersUi=function(){for(var e,t=jQuery("#wdi_filters_ui").html(""),i=0;i<this.conditionalFilters.length;i++){if(0==i)if(1!=this.conditionalFilters.length)switch(jQuery("#WDI_conditional_filter_type").val()){case"AND":break;case"OR":t.append(jQuery('<span class="wdi_logic">'+wdi_messages.either+"</span>"));break;case"NOR":t.append(jQuery('<span class="wdi_logic">'+wdi_messages.neither+"</span>"))}else switch(jQuery("#WDI_conditional_filter_type").val()){case"AND":case"OR":break;case"NOR":t.append(jQuery('<span class="wdi_logic">'+wdi_messages.not+"</span>"))}switch(jQuery("#WDI_conditional_filter_type").val()){case"AND":e=wdi_messages.and;break;case"OR":e=wdi_messages.or;break;case"NOR":e=wdi_messages.nor}1<=i&&t.append(jQuery('<span class="wdi_logic">'+e+"</span>")),t.append(this.createUiElement(this.conditionalFilters[i]))}this.updateFilterTextarea()},wdi_controller.createUiElement=function(e){var t;switch(e.filter_type){case"mention":t="@";break;case"hashtag":t="#";break;case"location":t="%";break;default:t=""}return jQuery('<span data-id="'+e.id+'" class="wdi_filter_item wdi_filter_by_'+e.filter_type+'"></span>').html(t+e.filter_by+'<span onclick="wdi_controller.removeConditionalFilter(jQuery(this));" class="wdi_remove_filter">X</span>')},wdi_controller.randomId=function(){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=0;i<5;i++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},wdi_controller.removeConditionalFilter=function(e){for(var t=e.parent().attr("data-id"),i=0;i<this.conditionalFilters.length;i++)this.conditionalFilters[i].id==t&&this.conditionalFilters.splice(i,1);this.updateFiltersUi()},wdi_controller.updateFilterTextarea=function(){var e=this.conditionalFilters,e=JSON.stringify(e);jQuery("#wdi_conditional_filters_textarea").val(e)},wdi_controller.setInitialFilters=function(){var e=[],t=jQuery("#wdi_conditional_filters_textarea").val();this.isJsonString(t)&&(e=JSON.parse(t)),this.conditionalFilters=e},wdi_controller.updateConditionalFiltersUi=function(){wdi_controller.updateFilterSource()},wdi_controller.updateFilterSource=function(){if("liked"!=jQuery('input[name="wdi_feed_settings[liked_feed]"]:checked').val()){var e,t,i=[];jQuery(".wdi_user").each(function(){e=(0!=jQuery(this).find(".wdi_username").length?jQuery(this).find(".wdi_username"):jQuery(this).find(".wdi_hashtag")).text(),t=jQuery(this).find("img").attr("src"),i.push({username:e,image:t})});for(var r=jQuery("#wdi_filter_source").html(""),a=0;a<i.length;a++){s="<div class='wdi_source_user'><span class='wdi_source_img'><img src='"+i[a].image+"'></span><span class='wdi_source_username'>"+i[a].username+"</span></div>";r.html(r.html()+s)}}else{var r,s="<div class='wdi_source_user'><span class='wdi_source_username'>Media I liked</span></div>";(r=jQuery("#wdi_filter_source").html("")).html(r.html()+s)}},wdi_controller.isJsonString=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},wdi_controller.getUserObj=function(e){var t=JSON.parse(wdi_options.wdi_authenticated_users_list);if("object"==typeof t){if("object"==typeof t[e]&&""!=t[e])return t[e];console.log("Error: User not exist on Users object")}else console.log("Error: Wrong response when parsed on users (JSON.parse)");return!1};
js/wdi_frontend.js CHANGED
@@ -547,56 +547,58 @@ wdi_front.appendRequestHashtag = function (data, hashtag) {
547
  * also checks if one request is not enough for displaying all images user wanted
548
  * it recursively calls wdi_front.loadMore() until the desired number of photos is reached
549
  */
550
- wdi_front.displayFeed = function (currentFeed, page_number) {
551
-
552
- if( typeof page_number === 'undefined') {
553
  page_number = 1;
554
  }
555
-
556
- for( var i = 0; i < currentFeed['usersData'].length; i++ ) {
557
  currentFeed['dataStorageList'] = currentFeed['usersData'][i]['data'];
558
  /* Using in parsed lightbox function */
559
- currentFeed['dataStorage'][i] = currentFeed['usersData'][i]['data'];
560
  }
561
  var first_page_img_count = currentFeed['feed_row']['number_of_photos'];
562
  var load_more_count = currentFeed['feed_row']['load_more_number'];
563
-
564
  var start_index = 0;
565
  var end_index = first_page_img_count;
566
  var data = '';
567
 
568
  /* Type of simple pagination */
569
- if (currentFeed.feed_row.feed_display_view == 'pagination') {
570
- if( currentFeed.allResponseLength > 1 ) {
571
- jQuery("#wdi_pagination").removeClass("wdi_hidden");
572
  }
573
  currentFeed.feed_row.number_of_photos = currentFeed.allResponseLength;
574
- if(currentFeed.feed_row.feed_type == 'image_browser') {
575
  currentFeed.paginator = parseInt(currentFeed.feed_row.number_of_photos);
576
- } else {
 
577
  currentFeed.paginator = Math.ceil(parseInt(currentFeed.feed_row.number_of_photos) / parseInt(load_more_count));
578
  }
579
- if(page_number === 1) {
580
- start_index = 0;
581
- if(currentFeed.feed_row.feed_type == 'image_browser') {
582
- end_index = 1;
583
- } else {
584
- end_index = load_more_count;
585
- }
 
 
 
 
 
 
 
586
  data = currentFeed['dataStorageList'].slice(start_index, end_index);
587
- } else {
588
- if(currentFeed.feed_row.feed_type == 'image_browser') {
589
- start_index = (page_number-1);
590
- end_index = start_index+1;
591
- data = currentFeed['dataStorageList'].slice(start_index, end_index);
592
- } else {
593
- start_index = (page_number-1)*load_more_count;
594
- end_index = start_index+load_more_count;
595
- data = currentFeed['dataStorageList'].slice(start_index, end_index);
596
- }
597
  }
598
- } else {
599
- if (typeof currentFeed['already_loaded_count'] !== 'undefined') {
 
600
  start_index = parseInt(currentFeed['already_loaded_count']);
601
  end_index = currentFeed['already_loaded_count'] + parseInt(load_more_count);
602
  data = currentFeed['dataStorageList'].slice(start_index, end_index);
@@ -607,25 +609,20 @@ wdi_front.displayFeed = function (currentFeed, page_number) {
607
  currentFeed['already_loaded_count'] = data.length;
608
  }
609
  }
610
-
611
- //parsing data for lightbox
612
  currentFeed.parsedData = wdi_front.parseLighboxData(currentFeed, true);
613
-
614
- //checking feed_type and calling proper rendering functions
615
- if (currentFeed.feed_row.feed_type == 'masonry') {
616
  wdi_front.masonryDisplayFeedItems(data, currentFeed);
617
  }
618
-
619
- if (currentFeed.feed_row.feed_type == 'thumbnails' || currentFeed.feed_row.feed_type == 'blog_style' || currentFeed.feed_row.feed_type == 'image_browser') {
620
  wdi_front.displayFeedItems(data, currentFeed);
621
  }
622
-
623
- //checking if display_view is pagination and we are not on the last page then enable
624
- //last page button
625
- if (currentFeed.feed_row.feed_display_view == 'pagination' && currentFeed.currentPage < currentFeed.paginator) {
626
  jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter).find('#wdi_last_page').removeClass('wdi_disabled');
627
  }
628
-
629
  //if there are any missing images in header then replace them with new ones if possible
630
  wdi_front.updateUsersImages(currentFeed);
631
  }
@@ -832,10 +829,10 @@ wdi_front.getArrayContentLength = function (array, data) {
832
  */
833
  wdi_front.displayFeedItems = function ( data, currentFeed ) {
834
  if ( jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper").length == 0 ) {
835
- //no feed in DOM, ignore
836
  return;
837
  }
838
- //gets ready data, gets data template, and appens it into feed_wrapper
839
  var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
840
  var feed_wrapper = jQuery('#wdi_feed_' + wdi_feed_counter + ' .wdi_feed_wrapper');
841
  /*
@@ -858,9 +855,9 @@ wdi_front.displayFeedItems = function ( data, currentFeed ) {
858
  continue;
859
  }
860
  }
861
- var wdi_media_type = "";
862
- if ( typeof data[i]["wdi_hashtag"] != "undefined" ) {
863
- wdi_media_type = data[i]["wdi_hashtag"];
864
  }
865
  if ( data[i]['type'] == 'image' ) {
866
  var photoTemplate = wdi_front.getPhotoTemplate(currentFeed, wdi_media_type);
@@ -874,13 +871,13 @@ wdi_front.displayFeedItems = function ( data, currentFeed ) {
874
  var rawItem = data[i];
875
  var item = wdi_front.createObject(rawItem, currentFeed);
876
  var html = '';
877
- /* undefined when carousel media not defined */
878
  if ( typeof item !== 'undefined' ) {
879
  html = photoTemplate(item);
880
  }
881
  feed_wrapper.html(feed_wrapper.html() + html);
882
  currentFeed.imageIndex++;
883
- //changing responsive indexes for pagination
884
  if ( currentFeed.feed_row.feed_display_view == 'pagination' ) {
885
  if ( (i + 1) % currentFeed.feed_row.pagination_per_page_number === 0 ) {
886
  currentFeed.resIndex += currentFeed.freeSpaces + 1;
@@ -1074,12 +1071,30 @@ wdi_front.getPhotoTemplate = function (currentFeed , type) {
1074
  var imageIndex = currentFeed['imageIndex'];
1075
  if (currentFeed['feed_row']['show_likes'] === '1' || currentFeed['feed_row']['show_comments'] === '1' || currentFeed['feed_row']['show_description'] === '1') {
1076
  source += '<div class="wdi_photo_meta">';
1077
- var likes_count = ( typeof currentFeed['dataStorageList'][imageIndex] !== 'undefined' && typeof currentFeed['dataStorageList'][imageIndex]['likes'] !== 'undefined' && typeof currentFeed['dataStorageList'][imageIndex]['likes']['count'] !== 'undefined' ) ? currentFeed['dataStorageList'][imageIndex]['likes']['count'] : 0;
1078
- if (currentFeed['feed_row']['show_likes'] === '1' && likes_count !== 0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1079
  source += '<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>';
1080
  }
1081
- var comments_count = ( typeof currentFeed['dataStorageList'][imageIndex] !== 'undefined' && typeof currentFeed['dataStorageList'][imageIndex]['comments'] !== 'undefined' && typeof currentFeed['dataStorageList'][imageIndex]['comments']['count'] !== 'undefined' ) ? currentFeed['dataStorageList'][imageIndex]['comments']['count'] : 0;
1082
- if (currentFeed['feed_row']['show_comments'] === '1' && comments_count !== 0) {
1083
  source += '<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>';
1084
  }
1085
  source += '<div class="wdi_clear"></div>';
@@ -1128,10 +1143,7 @@ wdi_front.getSliderTemplate = function (currentFeed, type) {
1128
  } else {
1129
  onclickevent = "wdi_responsive.showCaption(jQuery(this)," + currentFeed.feed_row.wdi_feed_counter + ");";
1130
  }
1131
-
1132
  }
1133
-
1134
-
1135
  //creating onclick string for different options
1136
  switch (currentFeed.feed_row.feed_item_onclick) {
1137
  case 'lightbox':
@@ -1181,16 +1193,34 @@ wdi_front.getSliderTemplate = function (currentFeed, type) {
1181
  var imageIndex = currentFeed['imageIndex'];
1182
  if (currentFeed['feed_row']['show_likes'] === '1' || currentFeed['feed_row']['show_comments'] === '1' || currentFeed['feed_row']['show_description'] === '1') {
1183
  source += '<div class="wdi_photo_meta">';
1184
- var likes_count = ( typeof currentFeed['dataStorageList'][imageIndex] !== 'undefined' && typeof currentFeed['dataStorageList'][imageIndex]['likes'] !== 'undefined' && typeof currentFeed['dataStorageList'][imageIndex]['likes']['count'] !== 'undefined' ) ? currentFeed['dataStorageList'][imageIndex]['likes']['count'] : currentFeed['dataStorageList'][imageIndex]['likes'];
1185
- if (currentFeed['feed_row']['show_likes'] === '1' && likes_count !== 0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1186
  source += '<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>';
1187
  }
1188
- var comments_count = ( typeof currentFeed['dataStorageList'][imageIndex]['comments']['count'] !== 'undefined' ) ? currentFeed['dataStorageList'][imageIndex]['comments']['count'] : currentFeed['dataStorageList'][imageIndex]['comments'];
1189
- if (currentFeed['feed_row']['show_comments'] === '1' && comments_count !== 0) {
1190
  source += '<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>';
1191
  }
1192
  source += '<div class="wdi_clear"></div>';
1193
- if (currentFeed['feed_row']['show_description'] === '1') {
1194
  source += '<div class="wdi_photo_title" onclick=' + onclickevent + ' >' +
1195
  '<%=caption%>' +
1196
  '</div>';
@@ -1203,16 +1233,6 @@ wdi_front.getSliderTemplate = function (currentFeed, type) {
1203
  return template;
1204
  }
1205
 
1206
- wdi_front.replaceToVideo = function (url, index, feed_counter) {
1207
-
1208
- overlayHtml = "<video style='width:auto !important; height:auto !important; max-width:100% !important; max-height:100% !important; margin:0 !important;' controls=''>" +
1209
- "<source src='" + url + "' type='video/mp4'>" +
1210
- "Your browser does not support the video tag. </video>";
1211
-
1212
- jQuery('#wdi_feed_' + feed_counter + ' [wdi_index="' + index + '"] .wdi_photo_wrap_inner').html(overlayHtml);
1213
- jQuery('#wdi_feed_' + feed_counter + ' [wdi_index="' + index + '"] .wdi_photo_wrap_inner video').get(0).play();
1214
- }
1215
-
1216
  /*
1217
  * Template for all feed items which have type=video
1218
  */
@@ -1242,7 +1262,6 @@ wdi_front.getVideoTemplate = function (currentFeed, type) {
1242
  } else {
1243
  onclickevent = "wdi_responsive.showCaption(jQuery(this)," + currentFeed.feed_row.wdi_feed_counter + ");";
1244
  }
1245
-
1246
  }
1247
 
1248
  //creating onclick string for different options
@@ -1297,12 +1316,30 @@ wdi_front.getVideoTemplate = function (currentFeed, type) {
1297
  var imageIndex = currentFeed['imageIndex'];
1298
  if (currentFeed['feed_row']['show_likes'] === '1' || currentFeed['feed_row']['show_comments'] === '1' || currentFeed['feed_row']['show_description'] === '1') {
1299
  source += '<div class="wdi_photo_meta">';
1300
- var likes_count = ( typeof currentFeed['dataStorageList'][imageIndex] !== 'undefined' && typeof currentFeed['dataStorageList'][imageIndex]['likes'] !== 'undefined' && typeof currentFeed['dataStorageList'][imageIndex]['likes']['count'] !== 'undefined' ) ? currentFeed['dataStorageList'][imageIndex]['likes']['count'] : currentFeed['dataStorageList'][imageIndex]['likes'];
1301
- if (currentFeed['feed_row']['show_likes'] === '1' && likes_count !== 0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1302
  source += '<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>';
1303
  }
1304
- var comments_count = ( typeof currentFeed['dataStorageList'][imageIndex]['comments']['count'] !== 'undefined' ) ? currentFeed['dataStorageList'][imageIndex]['comments']['count'] : currentFeed['dataStorageList'][imageIndex]['comments'];
1305
- if (currentFeed['feed_row']['show_comments'] === '1' && comments_count !== 0) {
1306
  source += '<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>';
1307
  }
1308
  source += '<div class="wdi_clear"></div>';
@@ -1318,6 +1355,16 @@ wdi_front.getVideoTemplate = function (currentFeed, type) {
1318
  return template;
1319
  }
1320
 
 
 
 
 
 
 
 
 
 
 
1321
  wdi_front.bindEvents = function (currentFeed) {
1322
 
1323
  if (jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper").length == 0) {
@@ -1337,24 +1384,22 @@ wdi_front.bindEvents = function (currentFeed) {
1337
  });
1338
  }
1339
 
1340
- if (currentFeed.feed_row.feed_display_view == 'pagination') {
1341
  //binding pagination events
1342
- jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_next').on(wdi_front.clickOrTouch, function ()
1343
- {
1344
- //wdi_front.paginatorNext(jQuery(this), currentFeed)
1345
- if( (parseInt(jQuery("#wdi_current_page").text()) + 1) > currentFeed.paginator ) {
1346
  return;
1347
  }
1348
- currentFeed.currentPage = (parseInt(jQuery("#wdi_current_page").text()) + 1);
1349
  wdi_front.changePage(jQuery(this), currentFeed);
1350
  });
1351
- jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_prev').on(wdi_front.clickOrTouch, function ()
1352
- {
1353
-
1354
- if( (parseInt(jQuery("#wdi_current_page").text()) - 1) <= 0 ) {
1355
  return;
1356
  }
1357
- currentFeed.currentPage = (parseInt(jQuery("#wdi_current_page").text()) - 1);
1358
  wdi_front.changePage(jQuery(this), currentFeed);
1359
  });
1360
  jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_last_page').on(wdi_front.clickOrTouch, function ()
@@ -1367,7 +1412,7 @@ wdi_front.bindEvents = function (currentFeed) {
1367
  currentFeed.currentPage = 1;
1368
  wdi_front.changePage(jQuery(this), currentFeed);
1369
  });
1370
- //setting pagiantion flags
1371
  currentFeed.paginatorNextFlag = false;
1372
  }
1373
  if (currentFeed.feed_row.feed_display_view == 'infinite_scroll') {
@@ -1396,16 +1441,16 @@ wdi_front.infiniteScroll = function (currentFeed) {
1396
  wdi_front.changePage = function ( btn, currentFeed ) {
1397
  new_page_number = currentFeed.currentPage;
1398
  if ( new_page_number > 1 ) {
1399
- jQuery("#wdi_first_page").removeClass("wdi_disabled");
1400
  }
1401
  else if ( new_page_number === 1 ) {
1402
- jQuery("#wdi_first_page").addClass("wdi_disabled");
1403
  }
1404
  if ( new_page_number == parseInt(currentFeed.paginator) ) {
1405
- jQuery("#wdi_last_page").addClass("wdi_disabled");
1406
  }
1407
  else if ( new_page_number < parseInt(currentFeed.paginator) ) {
1408
- jQuery("#wdi_last_page").removeClass("wdi_disabled");
1409
  }
1410
  if ( currentFeed.feed_row.feed_type == 'masonry' ) {
1411
  btn.parent().parent().parent().find(".wdi_feed_wrapper .wdi_masonry_column").empty();
547
  * also checks if one request is not enough for displaying all images user wanted
548
  * it recursively calls wdi_front.loadMore() until the desired number of photos is reached
549
  */
550
+ wdi_front.displayFeed = function ( currentFeed, page_number ) {
551
+ if ( typeof page_number === 'undefined' ) {
 
552
  page_number = 1;
553
  }
554
+ for ( var i = 0; i < currentFeed['usersData'].length; i++ ) {
 
555
  currentFeed['dataStorageList'] = currentFeed['usersData'][i]['data'];
556
  /* Using in parsed lightbox function */
557
+ currentFeed['dataStorage'][i] = currentFeed['usersData'][i]['data'];
558
  }
559
  var first_page_img_count = currentFeed['feed_row']['number_of_photos'];
560
  var load_more_count = currentFeed['feed_row']['load_more_number'];
 
561
  var start_index = 0;
562
  var end_index = first_page_img_count;
563
  var data = '';
564
 
565
  /* Type of simple pagination */
566
+ if ( currentFeed.feed_row.feed_display_view == 'pagination' ) {
567
+ if ( currentFeed.allResponseLength > 1 ) {
568
+ jQuery('.wdi_pagination').removeClass('wdi_hidden');
569
  }
570
  currentFeed.feed_row.number_of_photos = currentFeed.allResponseLength;
571
+ if ( currentFeed.feed_row.feed_type == 'image_browser' ) {
572
  currentFeed.paginator = parseInt(currentFeed.feed_row.number_of_photos);
573
+ }
574
+ else {
575
  currentFeed.paginator = Math.ceil(parseInt(currentFeed.feed_row.number_of_photos) / parseInt(load_more_count));
576
  }
577
+ if ( page_number === 1 ) {
578
+ start_index = 0;
579
+ if ( currentFeed.feed_row.feed_type == 'image_browser' ) {
580
+ end_index = 1;
581
+ }
582
+ else {
583
+ end_index = load_more_count;
584
+ }
585
+ data = currentFeed['dataStorageList'].slice(start_index, end_index);
586
+ }
587
+ else {
588
+ if ( currentFeed.feed_row.feed_type == 'image_browser' ) {
589
+ start_index = (page_number - 1);
590
+ end_index = start_index + 1;
591
  data = currentFeed['dataStorageList'].slice(start_index, end_index);
592
+ }
593
+ else {
594
+ start_index = (page_number - 1) * load_more_count;
595
+ end_index = start_index + load_more_count;
596
+ data = currentFeed['dataStorageList'].slice(start_index, end_index);
597
+ }
 
 
 
 
598
  }
599
+ }
600
+ else {
601
+ if ( typeof currentFeed['already_loaded_count'] !== 'undefined' ) {
602
  start_index = parseInt(currentFeed['already_loaded_count']);
603
  end_index = currentFeed['already_loaded_count'] + parseInt(load_more_count);
604
  data = currentFeed['dataStorageList'].slice(start_index, end_index);
609
  currentFeed['already_loaded_count'] = data.length;
610
  }
611
  }
612
+ // parsing data for lightbox
 
613
  currentFeed.parsedData = wdi_front.parseLighboxData(currentFeed, true);
614
+ // checking feed_type and calling proper rendering functions
615
+ if ( currentFeed.feed_row.feed_type == 'masonry' ) {
 
616
  wdi_front.masonryDisplayFeedItems(data, currentFeed);
617
  }
618
+ if ( currentFeed.feed_row.feed_type == 'thumbnails' || currentFeed.feed_row.feed_type == 'blog_style' || currentFeed.feed_row.feed_type == 'image_browser' ) {
 
619
  wdi_front.displayFeedItems(data, currentFeed);
620
  }
621
+ // checking if display_view is pagination and we are not on the last page then enable
622
+ // last page button
623
+ if ( currentFeed.feed_row.feed_display_view == 'pagination' && currentFeed.currentPage < currentFeed.paginator ) {
 
624
  jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter).find('#wdi_last_page').removeClass('wdi_disabled');
625
  }
 
626
  //if there are any missing images in header then replace them with new ones if possible
627
  wdi_front.updateUsersImages(currentFeed);
628
  }
829
  */
830
  wdi_front.displayFeedItems = function ( data, currentFeed ) {
831
  if ( jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper").length == 0 ) {
832
+ // no feed in DOM, ignore
833
  return;
834
  }
835
+ // gets ready data, gets data template, and appens it into feed_wrapper
836
  var wdi_feed_counter = currentFeed.feed_row['wdi_feed_counter'];
837
  var feed_wrapper = jQuery('#wdi_feed_' + wdi_feed_counter + ' .wdi_feed_wrapper');
838
  /*
855
  continue;
856
  }
857
  }
858
+ var wdi_media_type = '';
859
+ if ( typeof data[i]['wdi_hashtag'] != 'undefined' ) {
860
+ wdi_media_type = data[i]['wdi_hashtag'];
861
  }
862
  if ( data[i]['type'] == 'image' ) {
863
  var photoTemplate = wdi_front.getPhotoTemplate(currentFeed, wdi_media_type);
871
  var rawItem = data[i];
872
  var item = wdi_front.createObject(rawItem, currentFeed);
873
  var html = '';
874
+ // undefined when carousel media not defined
875
  if ( typeof item !== 'undefined' ) {
876
  html = photoTemplate(item);
877
  }
878
  feed_wrapper.html(feed_wrapper.html() + html);
879
  currentFeed.imageIndex++;
880
+ // changing responsive indexes for pagination
881
  if ( currentFeed.feed_row.feed_display_view == 'pagination' ) {
882
  if ( (i + 1) % currentFeed.feed_row.pagination_per_page_number === 0 ) {
883
  currentFeed.resIndex += currentFeed.freeSpaces + 1;
1071
  var imageIndex = currentFeed['imageIndex'];
1072
  if (currentFeed['feed_row']['show_likes'] === '1' || currentFeed['feed_row']['show_comments'] === '1' || currentFeed['feed_row']['show_description'] === '1') {
1073
  source += '<div class="wdi_photo_meta">';
1074
+ var likes_count = 0;
1075
+ var comments_count = 0;
1076
+ if ( typeof currentFeed['dataStorageList'][imageIndex] !== 'undefined' ) {
1077
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['likes'] !== 'undefined' ) {
1078
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['likes']['count'] !== 'undefined' ) {
1079
+ likes_count = currentFeed['dataStorageList'][imageIndex]['likes']['count'];
1080
+ }
1081
+ else {
1082
+ likes_count = currentFeed['dataStorageList'][imageIndex]['likes'];
1083
+ }
1084
+ }
1085
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['comments'] !== 'undefined' ) {
1086
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['comments']['count'] !== 'undefined' ) {
1087
+ comments_count = currentFeed['dataStorageList'][imageIndex]['comments']['count'];
1088
+ }
1089
+ else {
1090
+ comments_count = currentFeed['dataStorageList'][imageIndex]['comments'];
1091
+ }
1092
+ }
1093
+ }
1094
+ if ( currentFeed['feed_row']['show_likes'] === '1' && likes_count !== 0 ) {
1095
  source += '<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>';
1096
  }
1097
+ if ( currentFeed['feed_row']['show_comments'] === '1' && comments_count !== 0 ) {
 
1098
  source += '<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>';
1099
  }
1100
  source += '<div class="wdi_clear"></div>';
1143
  } else {
1144
  onclickevent = "wdi_responsive.showCaption(jQuery(this)," + currentFeed.feed_row.wdi_feed_counter + ");";
1145
  }
 
1146
  }
 
 
1147
  //creating onclick string for different options
1148
  switch (currentFeed.feed_row.feed_item_onclick) {
1149
  case 'lightbox':
1193
  var imageIndex = currentFeed['imageIndex'];
1194
  if (currentFeed['feed_row']['show_likes'] === '1' || currentFeed['feed_row']['show_comments'] === '1' || currentFeed['feed_row']['show_description'] === '1') {
1195
  source += '<div class="wdi_photo_meta">';
1196
+ var likes_count = 0;
1197
+ var comments_count = 0;
1198
+ if ( typeof currentFeed['dataStorageList'][imageIndex] !== 'undefined' ) {
1199
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['likes'] !== 'undefined' ) {
1200
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['likes']['count'] !== 'undefined' ) {
1201
+ likes_count = currentFeed['dataStorageList'][imageIndex]['likes']['count'];
1202
+ }
1203
+ else {
1204
+ likes_count = currentFeed['dataStorageList'][imageIndex]['likes'];
1205
+ }
1206
+ }
1207
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['comments'] !== 'undefined' ) {
1208
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['comments']['count'] !== 'undefined' ) {
1209
+ comments_count = currentFeed['dataStorageList'][imageIndex]['comments']['count'];
1210
+ }
1211
+ else {
1212
+ comments_count = currentFeed['dataStorageList'][imageIndex]['comments'];
1213
+ }
1214
+ }
1215
+ }
1216
+ if ( currentFeed['feed_row']['show_likes'] === '1' && likes_count !== 0 ) {
1217
  source += '<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>';
1218
  }
1219
+ if ( currentFeed['feed_row']['show_comments'] === '1' && comments_count !== 0 ) {
 
1220
  source += '<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>';
1221
  }
1222
  source += '<div class="wdi_clear"></div>';
1223
+ if ( currentFeed['feed_row']['show_description'] === '1' ) {
1224
  source += '<div class="wdi_photo_title" onclick=' + onclickevent + ' >' +
1225
  '<%=caption%>' +
1226
  '</div>';
1233
  return template;
1234
  }
1235
 
 
 
 
 
 
 
 
 
 
 
1236
  /*
1237
  * Template for all feed items which have type=video
1238
  */
1262
  } else {
1263
  onclickevent = "wdi_responsive.showCaption(jQuery(this)," + currentFeed.feed_row.wdi_feed_counter + ");";
1264
  }
 
1265
  }
1266
 
1267
  //creating onclick string for different options
1316
  var imageIndex = currentFeed['imageIndex'];
1317
  if (currentFeed['feed_row']['show_likes'] === '1' || currentFeed['feed_row']['show_comments'] === '1' || currentFeed['feed_row']['show_description'] === '1') {
1318
  source += '<div class="wdi_photo_meta">';
1319
+ var likes_count = 0;
1320
+ var comments_count = 0;
1321
+ if ( typeof currentFeed['dataStorageList'][imageIndex] !== 'undefined' ) {
1322
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['likes'] !== 'undefined' ) {
1323
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['likes']['count'] !== 'undefined' ) {
1324
+ likes_count = currentFeed['dataStorageList'][imageIndex]['likes']['count'];
1325
+ }
1326
+ else {
1327
+ likes_count = currentFeed['dataStorageList'][imageIndex]['likes'];
1328
+ }
1329
+ }
1330
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['comments'] !== 'undefined' ) {
1331
+ if ( typeof currentFeed['dataStorageList'][imageIndex]['comments']['count'] !== 'undefined' ) {
1332
+ comments_count = currentFeed['dataStorageList'][imageIndex]['comments']['count'];
1333
+ }
1334
+ else {
1335
+ comments_count = currentFeed['dataStorageList'][imageIndex]['comments'];
1336
+ }
1337
+ }
1338
+ }
1339
+ if ( currentFeed['feed_row']['show_likes'] === '1' && likes_count !== 0 ) {
1340
  source += '<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>';
1341
  }
1342
+ if ( currentFeed['feed_row']['show_comments'] === '1' && comments_count !== 0 ) {
 
1343
  source += '<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>';
1344
  }
1345
  source += '<div class="wdi_clear"></div>';
1355
  return template;
1356
  }
1357
 
1358
+ wdi_front.replaceToVideo = function (url, index, feed_counter) {
1359
+
1360
+ overlayHtml = "<video style='width:auto !important; height:auto !important; max-width:100% !important; max-height:100% !important; margin:0 !important;' controls=''>" +
1361
+ "<source src='" + url + "' type='video/mp4'>" +
1362
+ "Your browser does not support the video tag. </video>";
1363
+
1364
+ jQuery('#wdi_feed_' + feed_counter + ' [wdi_index="' + index + '"] .wdi_photo_wrap_inner').html(overlayHtml);
1365
+ jQuery('#wdi_feed_' + feed_counter + ' [wdi_index="' + index + '"] .wdi_photo_wrap_inner video').get(0).play();
1366
+ }
1367
+
1368
  wdi_front.bindEvents = function (currentFeed) {
1369
 
1370
  if (jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper").length == 0) {
1384
  });
1385
  }
1386
 
1387
+ if ( currentFeed.feed_row.feed_display_view == 'pagination' ) {
1388
  //binding pagination events
1389
+ jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_next').on(wdi_front.clickOrTouch, function () {
1390
+ var wdi_current_page = parseInt(jQuery(this).parents('.wdi_pagination_container').find('#wdi_current_page').text()) + 1;
1391
+ if( parseInt(wdi_current_page) > currentFeed.paginator ) {
 
1392
  return;
1393
  }
1394
+ currentFeed.currentPage = parseInt(wdi_current_page);
1395
  wdi_front.changePage(jQuery(this), currentFeed);
1396
  });
1397
+ jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_prev').on(wdi_front.clickOrTouch, function (){
1398
+ var wdi_current_page = parseInt(jQuery(this).parents('.wdi_pagination_container').find('#wdi_current_page').text()) - 1;
1399
+ if( parseInt(wdi_current_page) <= 0 ) {
 
1400
  return;
1401
  }
1402
+ currentFeed.currentPage = parseInt(wdi_current_page);
1403
  wdi_front.changePage(jQuery(this), currentFeed);
1404
  });
1405
  jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_last_page').on(wdi_front.clickOrTouch, function ()
1412
  currentFeed.currentPage = 1;
1413
  wdi_front.changePage(jQuery(this), currentFeed);
1414
  });
1415
+ // setting pagiantion flags
1416
  currentFeed.paginatorNextFlag = false;
1417
  }
1418
  if (currentFeed.feed_row.feed_display_view == 'infinite_scroll') {
1441
  wdi_front.changePage = function ( btn, currentFeed ) {
1442
  new_page_number = currentFeed.currentPage;
1443
  if ( new_page_number > 1 ) {
1444
+ btn.parents('.wdi_pagination').find("#wdi_first_page").removeClass("wdi_disabled");
1445
  }
1446
  else if ( new_page_number === 1 ) {
1447
+ btn.parents('.wdi_pagination').find("#wdi_first_page").addClass("wdi_disabled");
1448
  }
1449
  if ( new_page_number == parseInt(currentFeed.paginator) ) {
1450
+ btn.parents('.wdi_pagination').find("#wdi_last_page").addClass("wdi_disabled");
1451
  }
1452
  else if ( new_page_number < parseInt(currentFeed.paginator) ) {
1453
+ btn.parents('.wdi_pagination').find("#wdi_last_page").removeClass("wdi_disabled");
1454
  }
1455
  if ( currentFeed.feed_row.feed_type == 'masonry' ) {
1456
  btn.parent().parent().parent().find(".wdi_feed_wrapper .wdi_masonry_column").empty();
js/wdi_frontend.min.js CHANGED
@@ -1 +1 @@
1
- "undefined"==typeof wdi_front&&(wdi_front={type:"not_declared"});var wdi_error_show=!(wdi_front.detectEvent=function(){var e="click";return/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase())&&(e="touchend"),e}),wdi_error_init=!1;function wdi_baseName(e){var i=e.substr(e.lastIndexOf("/"));return e.replace(i,"")}wdi_front.escape_tags=function(e){return void 0===e&&(e=""),e=e.toString().replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&#34;")},wdi_front.show_alert=function(e,i,d){var r,t;void 0!==(d=jQuery("#wdi_feed_"+d.feed_row.wdi_feed_counter))&&(wdi_error_show=!0,d.find(".wdi_spinner").remove(),r=d.find(".wdi_js_error"),t=d.find(".wdi_token_error"),0!=i&&(void 0!==i.meta&&1==i.meta.error&&"OAuthException"===i.meta.error_type||void 0!==i.error&&"OAuthException"===i.error.type)?(d.find(".wdi_single_user").remove(),t.removeClass("wdi_hidden"),"1"!=wdi_front_messages.wdi_token_error_flag&&jQuery.ajax({type:"POST",url:wdi_url.ajax_url,dataType:"json",data:{action:"wdi_token_flag",wdi_token_flag_nonce:wdi_front_messages.wdi_token_flag_nonce},success:function(e){}})):void 0!==i.error&&void 0!==i.error.message&&(r.html(i.error.message),d.find(".wdi_single_user").remove(),r.removeClass("wdi_js_error"),r.addClass("wdi_js_error_no_animate"),jQuery(".wdi_js_error_no_animate").show()),wdi_front_messages.show_alerts||console.log("%c"+e,"color:#cc0000;")),wdi_error_show=!0},wdi_front.globalInit=function(){var e=wdi_front.feed_counter,i=0;void 0!==wdi_ajax.ajax_response&&(i=wdi_feed_counter_init.wdi_feed_counter_init);for(var d,r=i;r<=e;r++)0!==jQuery("#wdi_feed_"+r).length&&((d=new WDIFeed(window["wdi_feed_"+r])).instagram=new WDIInstagram,d.instagram.filterArguments={feed:d},d.instagram.addToken(d.feed_row.access_token),wdi_front.access_token=d.feed_row.access_token,d.dataLoaded=0,d.dataStorageRaw=[],d.dataStorage=[],d.dataStorageList=[],d.allResponseLength=0,d.currentResponseLength=0,d.temproraryUsersData=[],d.removedUsers=0,d.nowLoadingImages=!0,d.imageIndex=0,d.resIndex=0,d.currentPage=1,d.currentPageLoadMore=0,d.userSortFlags=[],d.customFilterChanged=!1,d.maxConditionalFiltersRequestCount=10,d.instagramRequestCounter=0,d.mediaRequestsDone=!1,d.conditionalFilterBuffer=[],d.stopInfiniteScrollFlag=!1,"masonry"==d.feed_row.feed_type&&(d.displayedData=[]),"pagination"==d.feed_row.feed_display_view?(d.feed_row.resort_after_load_more=0,"image_browser"!=d.feed_row.feed_type?(d.feed_row.load_more_number=parseInt(d.feed_row.pagination_per_page_number),d.feed_row.number_of_photos=d.allResponseLength):(d.feed_row.number_of_photos=1+parseInt(d.feed_row.image_browser_preload_number),d.feed_row.load_more_number=parseInt(d.feed_row.image_browser_load_number)),d.freeSpaces=(Math.floor(d.feed_row.pagination_per_page_number/d.feed_row.number_of_columns)+1)*d.feed_row.number_of_columns-d.feed_row.pagination_per_page_number):d.freeSpaces=0,d.galleryBox=function(e){wdi_spider_createpopup(wdi_url.ajax_url+"?gallery_id="+this.feed_row.id+"&image_id="+e,this.feed_row.wdi_feed_counter,this.feed_row.lightbox_width,this.feed_row.lightbox_height,1,"testpopup",5,this,e)},wdi_responsive.columnControl(d),"masonry"==d.feed_row.feed_type&&jQuery(window).trigger("resize"),wdi_front.bindEvents(d),window["wdi_feed_"+r]=d,wdi_front.init(d))},wdi_front.init=function(e){if(jQuery(".wdi_js_error").hide(),e.photoCounter=e.feed_row.number_of_photos,"liked"==e.feed_row.liked_feed)e.feed_users=["self"];else{if(!wdi_front.isJsonString(e.feed_row.feed_users))return void wdi_front.show_alert(wdi_front_messages.invalid_users_format,!1,e);e.feed_users=JSON.parse(e.feed_row.feed_users)}var i=[],d=[],r=[];void 0!==window.wdi_all_tags&&(i=window.wdi_all_tags);for(var t=0;t<e.feed_users.length;t++)"#"===e.feed_users[t].username[0]&&void 0!==e.feed_users[t].tag_id?(i[e.feed_users[t].tag_id]=e.feed_users[t],r[t]=e.feed_users[t]):d[0]=e.feed_users[t];window.wdi_all_tags=i,e.feed_users=void 0===r||wdi_front.isEmpty(r)?d:r;var a=wdi_front.getFeedItemResolution(e);e.feedImageResolution=a.image,e.feedVideoResolution=a.video,e.dataCount=e.feed_users.length;for(var o=0;o<e.dataCount;o++)wdi_front.instagramRequest(o,e);0<e.feed_row.number_of_photos&&wdi_front.ajaxLoader(e),"1"===e.feed_row.display_header&&wdi_front.show("header",e),"1"===e.feed_row.show_usernames&&wdi_front.show("users",e)},wdi_front.getFeedItemResolution=function(e){var i={image:"standard_resolution",video:"standard_resolution"};if("thumbnail"===e.feed_row.feed_resolution)return{image:"thumbnail",video:"low_bandwidth"};if("low"===e.feed_row.feed_resolution)return{image:"low_resolution",video:"low_resolution"};if("standard"===e.feed_row.feed_resolution)return{image:"standard_resolution",video:"standard_resolution"};var d=jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter).find(".wdi_feed_wrapper");d.append('<div class="wdi_feed_item" id="wdi_feed_item_example"></div>'),wdi_responsive.columnControl(e,1);e=d.attr("wdi-res").split("wdi_col_");if(d.find("#wdi_feed_item_example").remove(),2!==e.length)return i;e=parseInt(e[1]);if(e<=0)return i;e=d.width()/e-10;return e<=150?(i.image="thumbnail",i.video="low_bandwidth"):150<e&&e<=320?(i.image="low_resolution",i.video="low_resolution"):(i.image="standard_resolution",i.video="standard_resolution"),i},wdi_front.isJsonString=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},wdi_front.instagramRequest=function(i,d){var r=this,e=d.feed_users;if("string"==typeof e[i]&&"self"===e[i])d.instagram.getRecentLikedMedia({success:function(e){void 0!==e.meta&&void 0!==e.meta.error_type&&wdi_front.show_alert(!1,e,d),d.mediaRequestsDone=!0,0!=(e=r.checkMediaResponse(e,d))&&r.saveSelfUserData(e,d)}});else if("hashtag"==this.getInputType(e[i].username)){if(this.isJsonString(d.feed_row.feed_users))for(var t in json_feed_users=JSON.parse(d.feed_row.feed_users),json_feed_users)"#"!==json_feed_users[t].username.charAt(0)&&(user=json_feed_users[t]);d.instagram.getTagRecentMedia(this.stripHashtag(e[i].username),{feed_id:d.feed_row.id,user_id:user.id,user_name:user.username,success:function(e){if(void 0!==e.error&&"undefined"!=e.error.type||void 0!==e.meta&&1==e.meta.error)return d.dataLoaded=1,wdi_front.show_alert(!1,e,d),!1;d.mediaRequestsDone=!0,e=r.checkMediaResponse(e,d),d.dataLoaded=1,0!=e&&r.saveUserData(e,d.feed_users[i],d)}},null,d.feed_row.hashtag_top_recent,0)}else"user"==this.getInputType(e[i].username)&&d.instagram.getUserMedia({feed_id:d.feed_row.id,user_id:e[i].id,user_name:e[i].username,success:function(e){if(void 0!==e.meta&&1==typeof e.meta.error)return d.dataLoaded=1,wdi_front.show_alert(!1,e,d),!1;d.mediaRequestsDone=!0,d.dataLoaded=1,0!=(e=r.checkMediaResponse(e,d))?r.saveUserData(e,d.feed_users[i],d):wdi_front.allImagesLoaded(d)}},"",0)},wdi_front.isHashtag=function(e){return"#"===e[0]},wdi_front.saveUserData=function(e,i,d){e.user_id=i.id,e.username=i.username,"#"===e.user_id[0]&&(e.data=wdi_front.appendRequestHashtag(e.data,e.user_id)),d.usersData.push(e),d.currentResponseLength=wdi_front.getArrayContentLength(d.usersData,"data"),d.allResponseLength+=d.currentResponseLength,d.dataCount==d.usersData.length&&(d.currentResponseLength<d.feed_row.number_of_photos&&!wdi_front.userHasNoPhoto(d)?wdi_front.loadMore("initial-keep",d):(wdi_front.displayFeed(d),wdi_front.applyFilters(d),wdi_front.activeUsersCount(d)||"load_more_btn"==d.feed_row.feed_display_view&&((d=jQuery("#wdi_feed_"+d.feed_row.wdi_feed_counter)).find(".wdi_load_more").addClass("wdi_hidden"),d.find(".wdi_spinner").addClass("wdi_hidden"))))},wdi_front.saveSelfUserData=function(e,i){e.user_id="",e.username="",i.usersData.push(e),i.currentResponseLength=wdi_front.getArrayContentLength(i.usersData,"data"),i.allResponseLength+=i.currentResponseLength,i.dataCount==i.usersData.length&&(i.currentResponseLength<i.feed_row.number_of_photos&&!wdi_front.userHasNoPhoto(i)?wdi_front.loadMore("initial-keep",i):(wdi_front.displayFeed(i),wdi_front.applyFilters(i),wdi_front.activeUsersCount(i)||"load_more_btn"==i.feed_row.feed_display_view&&((i=jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter)).find(".wdi_load_more").addClass("wdi_hidden"),i.find(".wdi_spinner").addClass("wdi_hidden"))))},wdi_front.userHasNoPhoto=function(e,i){var d=0,r=e.usersData;void 0!==i&&(r=i);for(var t=0;t<r.length;t++)void 0===r[t].pagination&&(r[t].pagination=[]),"liked"===e.feed_row.liked_feed?void 0===r[t].pagination.next_max_like_id&&d++:void 0===r[t].pagination.next_max_id&&d++;return d==r.length?1:0},wdi_front.appendRequestHashtag=function(e,i){for(var d=0;d<e.length;d++)e[d].wdi_hashtag=i;return e},wdi_front.displayFeed=function(e,i){void 0===i&&(i=1);for(var d=0;d<e.usersData.length;d++)e.dataStorageList=e.usersData[d].data,e.dataStorage[d]=e.usersData[d].data;var r=e.feed_row.number_of_photos,t=e.feed_row.load_more_number,a=0,o=r,r="";"pagination"==e.feed_row.feed_display_view?(1<e.allResponseLength&&jQuery("#wdi_pagination").removeClass("wdi_hidden"),e.feed_row.number_of_photos=e.allResponseLength,"image_browser"==e.feed_row.feed_type?e.paginator=parseInt(e.feed_row.number_of_photos):e.paginator=Math.ceil(parseInt(e.feed_row.number_of_photos)/parseInt(t)),r=(o=1===i?(a=0,"image_browser"==e.feed_row.feed_type?1:t):"image_browser"==e.feed_row.feed_type?(a=i-1)+1:(a=(i-1)*t)+t,e.dataStorageList.slice(a,o))):void 0!==e.already_loaded_count?(a=parseInt(e.already_loaded_count),o=e.already_loaded_count+parseInt(t),r=e.dataStorageList.slice(a,o),e.already_loaded_count+=r.length):(r=e.dataStorageList.slice(a,o),e.already_loaded_count=r.length),e.parsedData=wdi_front.parseLighboxData(e,!0),"masonry"==e.feed_row.feed_type&&wdi_front.masonryDisplayFeedItems(r,e),"thumbnails"!=e.feed_row.feed_type&&"blog_style"!=e.feed_row.feed_type&&"image_browser"!=e.feed_row.feed_type||wdi_front.displayFeedItems(r,e),"pagination"==e.feed_row.feed_display_view&&e.currentPage<e.paginator&&jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter).find("#wdi_last_page").removeClass("wdi_disabled"),wdi_front.updateUsersImages(e)},wdi_front.updateUsersImages=function(i){jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter).find(".wdi_single_user .wdi_user_img_wrap img").each(function(){if((jQuery(this).attr("src")==wdi_url.plugin_url+"images/missing.png"||""==jQuery(this).attr("src"))&&"liked"!=i.feed_row.liked_feed)for(var e=0;e<i.usersData.length;e++)i.usersData[e].username==jQuery(this).parent().parent().find("h3").text()&&0!=i.usersData[e].data.length&&jQuery(this).attr("src",i.usersData[e].data[0].images.thumbnail.url)})},wdi_front.checkLoaded=function(e){var i=e.feed_row.wdi_feed_counter,d=jQuery("#wdi_feed_"+i);e.dataStorageList.length>e.already_loaded_count?d.find(".wdi_load_more").removeClass("wdi_hidden"):d.find(".wdi_load_more").addClass("wdi_hidden"),d.find(".wdi_spinner").addClass("wdi_hidden"),setTimeout(function(){d.find(".wdi_ajax_loading").addClass("wdi_hidden"),d.find(".wdi_page_loading").addClass("wdi_hidden"),d.find(".wdi_front_overlay").addClass("wdi_hidden")},500)},wdi_front.masonryDisplayFeedItems=function(e,i){var d=[],r=[];if(0!=jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length){jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" .wdi_masonry_column").each(function(){1==i.feed_row.resort_after_load_more&&(jQuery(this).html(""),i.imageIndex=0),1==i.customFilterChanged&&(jQuery(this).html(""),i.imageIndex=0),"pagination"==i.feed_row.feed_display_view?d.push(0):d.push(jQuery(this).height()),r.push(jQuery(this))}),1==i.customFilterChanged&&(i.customFilterChanged=!1);for(var t,a,o,n=0;n<e.length;n++)"object"==typeof e[n].videos&&null==e[n].videos.standard_resolution||(i.displayedData.push(e[n]),t="",void 0!==e[n].wdi_hashtag&&(t=e[n].wdi_hashtag),a="image"==e[n].type?wdi_front.getPhotoTemplate(i,t):e[n].hasOwnProperty("videos")||"video"==e[n].type?wdi_front.getVideoTemplate(i,t):wdi_front.getSliderTemplate(i,t),o=e[n],t=a(wdi_front.createObject(o,i)),a=wdi_front.array_min(d),o=wdi_front.getImageResolution(e[n]),r[a.index].html(r[a.index].html()+t),d[a.index]+=r[a.index].width()*o,i.imageIndex++,"pagination"==i.feed_row.feed_display_view&&((n+1)%i.feed_row.pagination_per_page_number==0?i.resIndex+=i.freeSpaces+1:i.resIndex++));i.wdi_loadedImages=0;var s=!1;i.wdi_load_count=n;var _=i.feed_row.wdi_feed_counter;jQuery("#wdi_feed_"+_+" .wdi_img").on("load",function(){i.wdi_loadedImages++,!1===s&&(wdi_responsive.columnControl(i,1),s=!0)});wdi_front.checkLoaded(i),1==i.paginatorNextFlag&&wdi_front.updatePagination(i,"next"),i.infiniteScrollFlag=!1}},wdi_front.getImageResolution=function(e){var i;return e="image"===e.type?(i=e.images.standard_resolution.height,e.images.standard_resolution.width):"video"===e.type?(i=e.videos.standard_resolution.height,e.videos.standard_resolution.width):(i=(e.carousel_media[0].images||e.carousel_media[0].videos).standard_resolution.height,(e.carousel_media[0].images||e.carousel_media[0].videos).standard_resolution.width),i/e},wdi_front.getDataLength=function(e,i){var d=0;if(void 0===i)for(var r=0;r<e.dataStorage.length;r++)d+=e.dataStorage[r].length;else for(r=0;r<i.length;r++)d+=i[r].length;return d},wdi_front.getArrayContentLength=function(e,i){for(var d=0,r=0;r<e.length;r++)"finished"!=e[r].finished&&void 0===e[r].error&&(d+=e[r][i].length);return d},wdi_front.displayFeedItems=function(e,i){if(0!=jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length){for(var d,r,t,a=i.feed_row.wdi_feed_counter,o=jQuery("#wdi_feed_"+a+" .wdi_feed_wrapper"),n=0;n<e.length;n++){if(void 0===e[n])return;"object"==typeof e[n].videos&&null==e[n].videos.standard_resolution||(t="",void 0!==e[n].wdi_hashtag&&(t=e[n].wdi_hashtag),d="image"==e[n].type?wdi_front.getPhotoTemplate(i,t):e[n].hasOwnProperty("videos")?wdi_front.getVideoTemplate(i,t):wdi_front.getSliderTemplate(i,t),r=e[n],t="",void 0!==(r=wdi_front.createObject(r,i))&&(t=d(r)),o.html(o.html()+t),i.imageIndex++,"pagination"==i.feed_row.feed_display_view&&((n+1)%i.feed_row.pagination_per_page_number==0?i.resIndex+=i.freeSpaces+1:i.resIndex++))}wdi_front.checkLoaded(i)}},wdi_front.checkFeedFinished=function(e){for(var i=0;i<e.usersData.length;i++)if(void 0===e.usersData[i].finished)return!1;return!0},wdi_front.createObject=function(e,i){var d=null!=e.caption?e.caption.text:"&nbsp";switch(e.type){case"image":var r=e.images[i.feedImageResolution].url,t=void 0,a=e.hasOwnProperty("thumbnail")?e.thumbnail:wdi_url.plugin_url+"images/missing.png";break;case"video":r=void 0,t=e.hasOwnProperty("videos")?e.videos[i.feedVideoResolution].url:wdi_url.plugin_url+"images/video_missing.png",a=e.hasOwnProperty("thumbnail")?e.thumbnail:wdi_url.plugin_url+"images/video_missing.png";break;case"carousel":if(0===e.carousel_media.length)r=wdi_url.plugin_url+"images/missing.png",t=void 0,a=wdi_url.plugin_url+"images/missing.png";else switch(e.carousel_media[0].type){case"image":r=e.carousel_media[0].images[i.feedImageResolution].url,t=void 0,a=e.hasOwnProperty("thumbnail")?e.thumbnail:wdi_url.plugin_url+"images/missing.png";break;case"video":r=void 0,t=e.carousel_media[0].videos[i.feedVideoResolution].url,a=e.hasOwnProperty("thumbnail")?e.thumbnail:wdi_url.plugin_url+"images/video_missing.png";break;default:r=wdi_url.plugin_url+"images/missing.png",t=void 0,a=wdi_url.plugin_url+"images/missing.png"}break;default:r=wdi_url.plugin_url+"images/missing.png",t=void 0,a=wdi_url.plugin_url+"images/missing.png"}var o,n=i.imageIndex,s="square";(_="image"===e.type?(o=e.images.standard_resolution.height,e.images.standard_resolution.width):"video"===e.type?(o=e.videos.standard_resolution.height,e.videos.standard_resolution.width):(o=(e.carousel_media[0].images||e.carousel_media[0].videos).standard_resolution.height,(e.carousel_media[0].images||e.carousel_media[0].videos).standard_resolution.width))<o?s="portrait":o<_&&(s="landscape");var _=e.user.username;return""===_&&(_="no_user"),{id:e.id,thumb_url:a,caption:wdi_front.escape_tags(d),image_url:r,likes:void 0!==e.likes.count?e.likes.count:e.likes,comments:void 0!==e.comments.count?e.comments.count:e.comments,wdi_index:n,wdi_res_index:i.resIndex,wdi_media_user:_,link:e.link,video_url:t,wdi_username:_,wdi_shape:s}},wdi_front.getPhotoTemplate=function(e,i){var d="",r="",t="",a="tenweb-i-arrows-out",o="";"blog_style"!=e.feed_row.feed_type&&"image_browser"!=e.feed_row.feed_type||(a=""),"1"==e.feed_row.show_username_on_thumb&&e.data.length&&""!==e.data[0].user.username&&(o='<span class="wdi_media_user">@<%= wdi_username%></span>'),1==e.feed_row.show_full_description&&"masonry"==e.feed_row.feed_type&&(d+=" wdi_full_caption");var n="";switch("blog_style"!==e.feed_row.feed_type&&(n="masonry"==e.feed_row.feed_type?"wdi_responsive.showMasonryCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");":"wdi_responsive.showCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");"),e.feed_row.feed_item_onclick){case"lightbox":r="onclick=wdi_feed_"+e.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":r="onclick=\"window.open ('<%= link%>','_blank')\"",t="wdi_hover_off",a="";break;case"custom_redirect":r="onclick=\"window.open ('"+e.feed_row.redirect_url+"','_self')\"",t="wdi_hover_off",a="";break;case"none":t="wdi_cursor_off wdi_hover_off",a=r=""}var s='<div class="wdi_feed_item '+d+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> wdi_type="image" id="wdi_'+e.feed_row.wdi_feed_counter+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img <%= wdi_shape == \'square\' ? \'wdi_shape_square\' : (wdi_shape == \'portrait\' ? \'wdi_shape_portrait\' : (wdi_shape == \'landscape\' ? \'wdi_shape_landscape\' : \'wdi_shape_square\') ) %>"><img class="wdi_img" src="<%=thumb_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+t+'" >'+o+'<div class="wdi_thumb_icon" '+r+' style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="tenweb-i '+a+'"></i></div></div></div></div></div></div>',d=e.imageIndex;return"1"!==e.feed_row.show_likes&&"1"!==e.feed_row.show_comments&&"1"!==e.feed_row.show_description||(s+='<div class="wdi_photo_meta">',o=void 0!==e.dataStorageList[d]&&void 0!==e.dataStorageList[d].likes&&void 0!==e.dataStorageList[d].likes.count?e.dataStorageList[d].likes.count:0,"1"===e.feed_row.show_likes&&0!==o&&(s+='<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>'),d=void 0!==e.dataStorageList[d]&&void 0!==e.dataStorageList[d].comments&&void 0!==e.dataStorageList[d].comments.count?e.dataStorageList[d].comments.count:0,"1"===e.feed_row.show_comments&&0!==d&&(s+='<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>'),s+='<div class="wdi_clear"></div>',"1"===e.feed_row.show_description&&(s+='<div class="wdi_photo_title" onclick='+n+" ><%=caption%></div>"),s+="</div>"),s+="</div>",_.template(s)},wdi_front.getSliderTemplate=function(e,i){var d="",r="",t="",a="tenweb-i-clone",o="";"blog_style"!=e.feed_row.feed_type&&"image_browser"!=e.feed_row.feed_type||(a=""),"1"==e.feed_row.show_username_on_thumb&&e.data.length&&""!==e.data[0].user.username&&(o='<span class="wdi_media_user">@<%= wdi_username%></span>'),1==e.feed_row.show_full_description&&"masonry"==e.feed_row.feed_type&&(d+=" wdi_full_caption");var n="";switch("blog_style"!==e.feed_row.feed_type&&(n="masonry"==e.feed_row.feed_type?"wdi_responsive.showMasonryCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");":"wdi_responsive.showCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");"),e.feed_row.feed_item_onclick){case"lightbox":r="onclick=wdi_feed_"+e.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":r="onclick=\"window.open ('<%= link%>','_blank')\"",t="wdi_hover_off",a="tenweb-i-clone";break;case"custom_redirect":r="onclick=\"window.open ('"+e.feed_row.redirect_url+"','_self')\"",t="wdi_hover_off",a="";break;case"none":t="wdi_cursor_off wdi_hover_off",a=r=""}var s='<div class="wdi_feed_item '+d+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> wdi_type="slideshow" id="wdi_'+e.feed_row.wdi_feed_counter+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img <%= wdi_shape == \'square\' ? \'wdi_shape_square\' : (wdi_shape == \'portrait\' ? \'wdi_shape_portrait\' : (wdi_shape == \'landscape\' ? \'wdi_shape_landscape\' : \'wdi_shape_square\') ) %>"><img class="wdi_img" src="<%=thumb_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+t+'" >'+o+'<div class="wdi_thumb_icon" '+r+' style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="tenweb-i '+a+'"></i></div></div></div></div></div></div>',d=e.imageIndex;return"1"!==e.feed_row.show_likes&&"1"!==e.feed_row.show_comments&&"1"!==e.feed_row.show_description||(s+='<div class="wdi_photo_meta">',o=void 0!==e.dataStorageList[d]&&void 0!==e.dataStorageList[d].likes&&void 0!==e.dataStorageList[d].likes.count?e.dataStorageList[d].likes.count:e.dataStorageList[d].likes,"1"===e.feed_row.show_likes&&0!==o&&(s+='<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>'),d=void 0!==e.dataStorageList[d].comments.count?e.dataStorageList[d].comments.count:e.dataStorageList[d].comments,"1"===e.feed_row.show_comments&&0!==d&&(s+='<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>'),s+='<div class="wdi_clear"></div>',"1"===e.feed_row.show_description&&(s+='<div class="wdi_photo_title" onclick='+n+" ><%=caption%></div>"),s+="</div>"),s+="</div>",_.template(s)},wdi_front.replaceToVideo=function(e,i,d){overlayHtml="<video style='width:auto !important; height:auto !important; max-width:100% !important; max-height:100% !important; margin:0 !important;' controls=''><source src='"+e+"' type='video/mp4'>Your browser does not support the video tag. </video>",jQuery("#wdi_feed_"+d+' [wdi_index="'+i+'"] .wdi_photo_wrap_inner').html(overlayHtml),jQuery("#wdi_feed_"+d+' [wdi_index="'+i+'"] .wdi_photo_wrap_inner video').get(0).play()},wdi_front.getVideoTemplate=function(e,i){var d="",r="tenweb-i-play",t="",a="",o="";"1"==e.feed_row.show_username_on_thumb&&e.data.length&&""!==e.data[0].user.username&&(o='<span class="wdi_media_user">@<%= wdi_username%></span>'),1==e.feed_row.show_full_description&&"masonry"==e.feed_row.feed_type&&(d+=" wdi_full_caption");var n="";switch("blog_style"!==e.feed_row.feed_type&&(n="masonry"==e.feed_row.feed_type?"wdi_responsive.showMasonryCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");":"wdi_responsive.showCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");"),e.feed_row.feed_item_onclick){case"lightbox":t="onclick=wdi_feed_"+e.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":t="onclick=\"window.open ('<%= link%>','_blank')\"",a="wdi_hover_off",r="tenweb-i-play";break;case"custom_redirect":t="onclick=\"window.open ('"+e.feed_row.redirect_url+"','_self')\"",a="wdi_hover_off",r="";break;case"none":a="wdi_cursor_off wdi_hover_off",r="","blog_style"!=e.feed_row.feed_type&&"image_browser"!=e.feed_row.feed_type||(t="onclick=wdi_front.replaceToVideo('<%= video_url%>','<%= wdi_index%>',"+e.feed_row.wdi_feed_counter+")",a="",r="tenweb-i-play")}var s='<div class="wdi_feed_item '+d+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> wdi_type="image" id="wdi_'+e.feed_row.wdi_feed_counter+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img <%= wdi_shape == \'square\' ? \'wdi_shape_square\' : (wdi_shape == \'portrait\' ? \'wdi_shape_portrait\' : (wdi_shape == \'landscape\' ? \'wdi_shape_landscape\' : \'wdi_shape_square\') ) %>"><img class="wdi_img" src="<%=thumb_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+a+'" '+t+">"+o+'<div class="wdi_thumb_icon" style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="tenweb-i '+r+'"></i></div></div></div></div></div></div>',d=e.imageIndex;return"1"!==e.feed_row.show_likes&&"1"!==e.feed_row.show_comments&&"1"!==e.feed_row.show_description||(s+='<div class="wdi_photo_meta">',o=void 0!==e.dataStorageList[d]&&void 0!==e.dataStorageList[d].likes&&void 0!==e.dataStorageList[d].likes.count?e.dataStorageList[d].likes.count:e.dataStorageList[d].likes,"1"===e.feed_row.show_likes&&0!==o&&(s+='<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>'),d=void 0!==e.dataStorageList[d].comments.count?e.dataStorageList[d].comments.count:e.dataStorageList[d].comments,"1"===e.feed_row.show_comments&&0!==d&&(s+='<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>'),s+='<div class="wdi_clear"></div>',"1"===e.feed_row.show_description&&(s+='<div class="wdi_photo_title" onclick='+n+" ><%=caption%></div>"),s+="</div>"),s+="</div>",_.template(s)},wdi_front.bindEvents=function(e){0!=jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length&&("load_more_btn"==e.feed_row.feed_display_view&&jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_load_more_container").on(wdi_front.clickOrTouch,function(){jQuery(document).find("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_load_more").addClass("wdi_hidden"),jQuery(document).find("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_spinner").removeClass("wdi_hidden"),setTimeout(function(){wdi_front.loadMore(jQuery(this).find(".wdi_load_more_wrap"),e)},1e3)}),"pagination"==e.feed_row.feed_display_view&&(jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" #wdi_next").on(wdi_front.clickOrTouch,function(){parseInt(jQuery("#wdi_current_page").text())+1>e.paginator||(e.currentPage=parseInt(jQuery("#wdi_current_page").text())+1,wdi_front.changePage(jQuery(this),e))}),jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" #wdi_prev").on(wdi_front.clickOrTouch,function(){parseInt(jQuery("#wdi_current_page").text())-1<=0||(e.currentPage=parseInt(jQuery("#wdi_current_page").text())-1,wdi_front.changePage(jQuery(this),e))}),jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" #wdi_last_page").on(wdi_front.clickOrTouch,function(){e.currentPage=e.paginator,wdi_front.changePage(jQuery(this),e)}),jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" #wdi_first_page").on(wdi_front.clickOrTouch,function(){e.currentPage=1,wdi_front.changePage(jQuery(this),e)}),e.paginatorNextFlag=!1),"infinite_scroll"==e.feed_row.feed_display_view&&(jQuery(window).on("scroll",function(){wdi_front.infiniteScroll(e)}),e.infiniteScrollFlag=!1))},wdi_front.infiniteScroll=function(e){jQuery(window).scrollTop()+jQuery(window).height()-100>=jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" #wdi_infinite_scroll").offset().top&&(e.dataStorageList.length>e.already_loaded_count||void 0===e.already_loaded_count?(e.infiniteScrollFlag=!0,wdi_front.loadMore(jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" #wdi_infinite_scroll"),e)):wdi_front.allImagesLoaded(e))},wdi_front.changePage=function(e,i){new_page_number=i.currentPage,1<new_page_number?jQuery("#wdi_first_page").removeClass("wdi_disabled"):1===new_page_number&&jQuery("#wdi_first_page").addClass("wdi_disabled"),new_page_number==parseInt(i.paginator)?jQuery("#wdi_last_page").addClass("wdi_disabled"):new_page_number<parseInt(i.paginator)&&jQuery("#wdi_last_page").removeClass("wdi_disabled"),("masonry"==i.feed_row.feed_type?e.parent().parent().parent().find(".wdi_feed_wrapper .wdi_masonry_column"):e.parent().parent().parent().find(".wdi_feed_wrapper")).empty(),e.parent().find("#wdi_current_page").empty().text(new_page_number);e=e.closest(".wdi_feed_container");e.parents(".wdi_feed_main_container").find(".wdi_front_overlay").removeClass("wdi_hidden"),e.parents(".wdi_feed_main_container").find(".wdi_page_loading").removeClass("wdi_hidden"),wdi_front.displayFeed(i,new_page_number)},wdi_front.updatePagination=function(e,i,d){var r="#wdi_feed_"+e.feed_row.wdi_feed_counter;switch(jQuery(r+' [wdi_page="'+e.currentPage+'"]').each(function(){jQuery(this).removeClass("wdi_hidden")}),i){case"next":var d=e.currentPage-1;jQuery(r+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height()),jQuery(r+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")});break;case"prev":d=e.currentPage+1;jQuery(r+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height()),jQuery(r+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")});break;case"custom":(d=d)!=e.currentPage&&(jQuery(r+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height()),jQuery(r+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")}))}e.paginatorNextFlag=!1,jQuery(r+" .wdi_feed_wrapper").css("height","auto"),jQuery(r+" #wdi_current_page").text(e.currentPage)},wdi_front.loadMore=function(e,i){var d;if(""!=e&&void 0!==e&&"initial"!=e&&"initial-keep"!=e&&(d=window[e.parent().parent().parent().parent().attr("id")]),void 0!==i&&(d=i),wdi_front.ajaxLoader(d),this.isJsonString(d.feed_row.feed_users))for(var r in json_feed_users=JSON.parse(d.feed_row.feed_users),json_feed_users)iuser=json_feed_users[r],"#"!==json_feed_users[r].username.charAt(0)&&(iuser=json_feed_users[r]);"masonry"===d.feed_row.feed_type&&"pagination"==d.feed_row.feed_display_view&&jQuery("#wdi_feed_"+wdi_front.feed_counter+" .wdi_full_caption").each(function(){jQuery(this).find(".wdi_photo_title").trigger(wdi_front.clickOrTouch)}),d.loadMoreDataCount=d.feed_users.length,wdi_front.displayFeed(d)},wdi_front.loadMoreRequest=function(e,i,d,r){d.mediaRequestsDone&&""!=i&&d.usersData},wdi_front.checkForLoadMoreDone=function(e,i){var d,r=e.feed_row.load_more_number,t=e.feed_row.number_of_photos;0==e.loadMoreDataCount&&(e.temproraryUsersData=wdi_front.mergeData(e.temproraryUsersData,e.usersData),d=wdi_front.getArrayContentLength(e.temproraryUsersData,"data"),"initial-keep"==i&&(i="initial"),"initial"==i?d<t&&!wdi_front.userHasNoPhoto(e,e.temproraryUsersData)&&e.instagramRequestCounter<=e.maxConditionalFiltersRequestCount?wdi_front.loadMore("initial",e):(e.usersData=e.temproraryUsersData,wdi_front.displayFeed(e),wdi_front.applyFilters(e),e.temproraryUsersData=[]):d<r&&!wdi_front.userHasNoPhoto(e,e.temproraryUsersData)&&e.instagramRequestCounter<=e.maxConditionalFiltersRequestCount?wdi_front.loadMore(void 0,e):(e.usersData=e.temproraryUsersData,wdi_front.activeUsersCount(e)&&(wdi_front.displayFeed(e,r),wdi_front.applyFilters(e),e.temproraryUsersData=[])))},wdi_front.allDataHasFinished=function(e){for(var i=0,d=0;d<e.dataStorageRaw.length;d++)""==e.usersData[d].pagination.next_url&&(i++,e.usersData[d].finished="finished");return i==e.dataStorageRaw.length&&(jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_load_more").remove(),!0)},wdi_front.mergeData=function(e,i){for(var d=0;d<i.length;d++)void 0!==e[d]?"finished"!=i[d].finished&&(void 0===e[d].pagination.next_max_id&&void 0===e[d].pagination.next_max_like_id||(e[d].data=e[d].data.concat(i[d].data),e[d].pagination=i[d].pagination,e[d].user_id=i[d].user_id,e[d].username=i[d].username,e[d].meta=i[d].meta)):e.push(i[d]);return e},wdi_front.brokenImageHandler=function(e){return!0},wdi_front.ajaxLoader=function(e){var i,d=e.feed_row.wdi_feed_counter,d=jQuery(document).find("#wdi_feed_"+d);return"load_more_btn"==e.feed_row.feed_display_view&&(d.find(".wdi_load_more").addClass("wdi_hidden"),d.find(".wdi_spinner").removeClass("wdi_hidden")),"infinite_scroll"==e.feed_row.feed_display_view&&(0==d.find(".wdi_ajax_loading").length?(i=jQuery('<div class="wdi_ajax_loading"><div><div><img class="wdi_load_more_spinner" src="'+wdi_url.plugin_url+'images/ajax_loader.png"></div></div></div>'),d.find(".wdi_feed_container").append(i)):i=d.find(".wdi_ajax_loading"),i.removeClass("wdi_hidden")),1},wdi_front.allImagesLoaded=function(e){wdi_front.getDataLength(e);e.mediaRequestsDone||jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").remove("wdi_nomedia"),0==e.allResponseLength&&1===e.dataLoaded&&jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").append("<p class='wdi_nomedia'>"+wdi_front_messages.feed_nomedia+"</p>");var i=e.feed_row.wdi_feed_counter,i=jQuery("#wdi_feed_"+i);"load_more_btn"==e.feed_row.feed_display_view&&(parseInt(e.allResponseLength)>parseInt(e.feed_row.number_of_photos)&&i.find(".wdi_load_more").removeClass("wdi_hidden"),i.find(".wdi_spinner").addClass("wdi_hidden")),"infinite_scroll"==e.feed_row.feed_display_view&&jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_ajax_loading").addClass("wdi_hidden")},wdi_front.show=function(e,i){var d,r,t=i.feed_row.wdi_feed_counter,a=jQuery("#wdi_feed_"+t+" .wdi_feed_container");"header"===e&&(d={feed_thumb:i.feed_row.feed_thumb,feed_name:i.feed_row.feed_name},r=wdi_front.getHeaderTemplate()(d),d=a.find(".wdi_feed_header").html(),a.find(".wdi_feed_header").html(d+r))},wdi_front.getUserTemplate=function(e,i){var d=e.dataCount,r="#"===i[0]?"//instagram.com/explore/tags/"+i.substr(1,i.length):"//instagram.com/"+i,t="onclick='"+('window.open("'+r+'","_blank")')+"'",r='<div class="wdi_single_user" user_index="<%=user_index%>"><div class="wdi_header_user_text <%=hashtagClass%>"><div class="wdi_user_img_wrap"><img onerror="wdi_front.brokenImageHandler(this);" src="<%= user_img_url%>">';return 1<d&&(r+='<div title="'+wdi_front_messages.filter_title+'" class="wdi_filter_overlay"><div class="wdi_filter_icon"><span onclick="wdi_front.addFilter(<%=user_index%>,<%=feed_counter%>);" class="tenweb-i tenweb-i-filter"></span></div></div>'),r+="</div>",r+="<h3 "+t+"><%= user_name%></h3>","#"!==i[0]?("1"==e.feed_row.follow_on_instagram_btn&&(r+='<div class="wdi_user_controls"><div class="wdi_follow_btn" onclick="window.open(\'//instagram.com/<%= user_name%>\',\'_blank\')"><span> '+wdi_front_messages.follow+"</span></div></div>"),r+='<div class="wdi_media_info"><p class="wdi_posts"><span class="tenweb-i tenweb-i-camera-retro"></span><%= counts.media%></p><p class="wdi_followers"><span class="tenweb-i tenweb-i-user"></span><%= counts.followed_by%></p></div>'):r+='<div class="wdi_user_controls"></div><div class="wdi_media_info"><p class="wdi_posts"><span class="tenweb-i tenweb-i-camera-retro"></span><%= counts.media%></p><p class="wdi_followers"><span></span></p></div>',r+='<div class="wdi_clear"></div>',1==d&&"#"!==i[0]&&"1"==e.feed_row.display_user_info&&(r+='<div class="wdi_bio"><%= bio%></div>',r+='<div class="wdi_website"><a target="_blank" href="<%= website_url%>" ><%= website%></a></div>'),r+="</div></div>",_.template(r)},wdi_front.getHeaderTemplate=function(){return _.template('<div class="wdi_header_wrapper"><div class="wdi_header_img_wrap"><img src="<%=feed_thumb%>"></div><div class="wdi_header_text"><%=feed_name%></div><div class="wdi_clear"></div>')},wdi_front.addFilter=function(e,i){var d=window["wdi_feed_"+i],i=d.dataCount;if(!(i<2)&&0==d.nowLoadingImages){i=jQuery("#wdi_feed_"+d.feed_row.wdi_feed_counter+'_users [user_index="'+e+'"]');i.find(".wdi_filter_overlay").toggleClass("wdi_filter_active_bg"),i.find(".wdi_header_user_text h3").toggleClass("wdi_filter_active_col"),i.find(".wdi_media_info").toggleClass("wdi_filter_active_col"),i.find(".wdi_follow_btn").toggleClass("wdi_filter_active_col"),d.customFilterChanged=!0,0==d.userSortFlags[e].flag?d.userSortFlags[e].flag=!0:d.userSortFlags[e].flag=!1;for(var r=0,t=0;t<d.userSortFlags.length;t++)1==d.userSortFlags[t].flag&&r++;"pagination"==d.feed_row.feed_display_view&&(d.resIndex=0),0!=r?wdi_front.filterData(d):d.customFilteredData=d.dataStorageList,wdi_front.displayFeed(d),"pagination"==d.feed_row.feed_display_view&&(d.paginator=Math.ceil(d.imageIndex/parseInt(d.feed_row.pagination_per_page_number)),d.currentPage=d.paginator,wdi_front.updatePagination(d,"custom",1),jQuery("#wdi_first_page").removeClass("wdi_disabled"),jQuery("#wdi_last_page").addClass("wdi_disabled"))}},wdi_front.filterData=function(e){var i=e.userSortFlags;e.customFilteredData=[];for(var d=0;d<e.dataStorageList.length;d++)for(var r=0;r<i.length;r++)(void 0!==e.dataStorageList[d].user.id&&e.dataStorageList[d].user.id==i[r].id||e.dataStorageList[d].wdi_hashtag==i[r].name)&&1==i[r].flag&&e.customFilteredData.push(e.dataStorageList[d])},wdi_front.applyFilters=function(e){for(var i=0;i<e.userSortFlags.length;i++)1==e.userSortFlags[i].flag&&(jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+'[user_index="'+i+'"]'),wdi_front.addFilter(i,e.feed_row.wdi_feed_counter),wdi_front.addFilter(i,e.feed_row.wdi_feed_counter))},wdi_front.getImgCount=function(e){for(var i=e.dataStorage,d=0,r=0;r<i.length;r++)d+=i[r].length;return d},wdi_front.parseLighboxData=function(e,i){for(var d,r,t,a,o=e.dataStorage,n=[],s=[],_=0;_<o.length;_++)for(var w=0;w<o[_].length;w++)n.push(o[_][w]);for(_=0;_<n.length;_++)void 0!==n[_]&&(r=void 0!==n[_]&&void 0!==n[_].media_url?n[_].media_url:wdi_url.plugin_url+"images/video_missing.png",r=n[_].thumbnail,void 0!==n[_]&&void 0===n[_].media_url&&("carousel"!==n[_].type||(void 0!==(a=n[_].carousel_media[0])&&void 0!==a.images||void 0!==a&&void 0!==a.videos)&&(r=a.thumbnail)),a=void(t=0)!==n[_].comments.count?n[_].comments.count:n[_].comments,void 0!==n[_]&&void 0!==a&&(t=a),d={alt:"",avg_rating:"",comment_count:t,date:wdi_front.convertUnixDate(n[_].created_time),description:wdi_front.getDescription(void 0!==n[_].caption&&null!==n[_].caption?wdi_front.escape_tags(n[_].caption.text):""),filename:wdi_front.getFileName(n[_]),filetype:wdi_front.getFileType(n[_]),hit_count:"0",id:n[_].id,image_url:n[_].link,number:0,rate:"",rate_count:"0",username:void 0!==n[_].user?n[_].user.username:"",profile_picture:void 0!==n[_].user?n[_].user.profile_picture:"",thumb_url:r,comments_data:void 0!==n[_].comments?n[_].comments.data:"",images:n[_].images||n[_].videos,carousel_media:void 0!==n[_].carousel_media?n[_].carousel_media:null},s.push(d));return s},wdi_front.convertUnixDate=function(e){var i=new Date(e).getTime()/1e3,e=new Date(0);e.setUTCSeconds(i);i=e.getFullYear()+"-"+(e.getMonth()+1)+"-"+e.getDate();return i+=" "+e.getHours()+":"+e.getMinutes()},wdi_front.getDescription=function(e){return e=e.replace(/\r?\n|\r/g," ")},wdi_front.getFileName=function(e){if(void 0!==e){var i=e.link;if("video"===e.type&&e.hasOwnProperty("videos")&&null!=e.videos.standard_resolution)return e.videos.standard_resolution.url;if(void 0===i)return"";i=i.split("/");return i[i.length-2]}},wdi_front.getFileType=function(e){return"video"==e.type&&e.hasOwnProperty("videos")?"EMBED_OEMBED_INSTAGRAM_VIDEO":"carousel"==e.type&&e.hasOwnProperty("carousel_media")?"EMBED_OEMBED_INSTAGRAM_CAROUSEL":"EMBED_OEMBED_INSTAGRAM_IMAGE"},wdi_front.array_max=function(e){for(var i=e[0],d=0,r=1;r<e.length;r++)i<e[r]&&(i=e[r],d=r);return{value:i,index:d}},wdi_front.array_min=function(e){for(var i=e[0],d=0,r=1;r<e.length;r++)i>e[r]&&(i=e[r],d=r);return{value:i,index:d}},wdi_front.activeUsersCount=function(e){for(var i=0,d=0;d<e.usersData.length;d++)"finished"!=e.usersData[d].finished&&i++;return i},wdi_front.checkMediaResponse=function(e,i){return""==e||void 0===e||null==e||void 0!==e.error?(errorMessage=wdi_front_messages.connection_error,wdi_front.show_alert(errorMessage,e,i),!1):""!=e&&void 0!==e&&null!=e&&void 0!==e.meta&&200!=e.meta.code?(errorMessage=e.meta.error_message,wdi_front.show_alert(errorMessage,e,i),!1):e},wdi_front.stripHashtag=function(e){return"#"!==e[0]?e:e.substr(1,e.length)},wdi_front.getInputType=function(e){switch(e[0]){case"#":return"hashtag";case"%":return"location";default:return"user"}},wdi_front.regexpTestCaption=function(e,i){var d=!1,r=!1,t=i.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&"),i=new RegExp("(?:^|\\s)"+t+"(?:^|\\s)"),a=new RegExp("(?:^|\\s)"+t,"g");for(null!=i.exec(e)&&(d=!0);null!=(match=a.exec(e));)r=!0;return 1==d||1==r},wdi_front.replaceNewLines=function(e){var i,d="vUkCJvN2ps3t",r=[];for(e=e.replace(/\r?\n|\r/g,d),i=new RegExp(d,"g");null!=(match=i.exec(e));)r.push(match.index);for(var t=e.split(d),a=0,o=0;o<t.length;o++)""==t[o]?a++:a=0,0<a&&(t.splice(o,1),a--,o--);return e=t.join(" ")},wdi_front.isEmptyObject=function(e){for(var i in e)if(e.hasOwnProperty(i))return!1;return!0},wdi_front.isEmpty=function(e){return!e||0===e.length};var WDIFeed=function(e){this.data=e.data,this.dataCount=e.dataCount,this.feed_row=e.feed_row,this.usersData=e.usersData,(_this=this).set_images_loading_flag=function(e){window.addEventListener("load",function(){e.nowLoadingImages=!1})},this.set_images_loading_flag(_this)};function wdi_extractHostname(e){return void 0===e||""===e?"":e.replace(/(^\w+:|^)\/\//,"")}WDIFeed.prototype.mediaExists=function(e,i){for(var d=0;d<i.length;d++)if(e.id==i[d].id)return!0;return!1},WDIFeed.prototype.getIdFromUrl=function(e){for(var i=e.split("/"),d=!1,r=0;r<i.length;r++)if("p"==i[r]&&void 0!==i[r+1]){d=i[r+1];break}return d},WDIFeed.prototype.avoidDuplicateMedia=function(e){var i=e.data,d=[];void 0===i&&(i=[]);for(var r=0;r<i.length;r++)this.mediaExists(i[r],this.dataStorageList)||this.mediaExists(i[r],d)||this.mediaExists(i[r],this.conditionalFilterBuffer)||d.push(i[r]);return this.conditionalFilterBuffer=this.conditionalFilterBuffer.concat(d),{data:d,meta:e.meta,pagination:e.pagination}},WDIFeed.prototype.storeRawData=function(e,i){var r=this;if("object"==typeof this[i]&&"number"==typeof this[i].length)for(var d=0;d<e.length;d++){var t="";wdi_front.isHashtag(e[d].user_id)?void 0!==e[d].pagination.cursors&&(t=e[d].pagination.cursors.after):"liked"==r.feed_row.liked_feed?void 0===(t=e[d].pagination.next_max_like_id)&&(t=""):(null==e[d].pagination&&(e[d].pagination=[]),void 0===(t=e[d].pagination.next_max_id)&&(t="")),void 0===this[i][d]?this[i].push({data:e[d].data,index:0,locked:!1,hash_id:t,usersDataFinished:!1,userId:e[d].user_id,length:function(){return this.data.length-this.index},getData:function(e){var i=this.data.slice(this.index,this.index+e);if(this.index+=Math.min(e,this.length()),this.index==this.data.length&&1==this.locked&&0==this.usersDataFinished)for(var d=0;d<r.usersData.length;d++)if(r.usersData[d].user_id==this.userId){this.usersDataFinished=!0;break}return i}}):0==this[i][d].locked&&(t!=this[i][d].hash_id?(this[i][d].data=this[i][d].data.concat(e[d].data),this[i][d].hash_id=t):this[i][d].locked=!0)}},wdi_front.updateUsersIfNecessary=function(o){for(var n=o.feed_users,e=!1,i=0;i<n.length;i++)"#"!=n[i].username.substr(0,1)?""!=n[i].id&&"username"!=n[i].id||(e=!0,o.instagram.searchForUsersByName(n[i].username,{success:function(e){if(void 0!==e.meta&&void 0!==e.meta.error_type&&wdi_front.show_alert(!1,e,o),200==e.meta.code&&0<e.data.length){for(var i=!1,d=0;d<e.data.length;d++)if(e.data[d].username==e.args.username){i=!0;break}if(i)for(var r=0;r<n.length;r++)e.data[d].username==n[r].username&&(n[r].id=e.data[d].id)}for(var t=!1,a=0;a<n.length;a++)if(""==n[a].id||"username"==n[a].id){t=!0;break}t||(o.feed_row.feed_users=JSON.stringify(n),wdi_front.init(o))},username:n[i].username})):n[i].id=n[i].username;return e},void 0!==wdi_ajax.ajax_response?jQuery(document).one("ajaxStop",function(){"not_declared"!=wdi_front.type&&(wdi_front.clickOrTouch=wdi_front.detectEvent(),wdi_front.globalInit())}):jQuery(document).ready(function(){"not_declared"!=wdi_front.type&&(wdi_front.clickOrTouch=wdi_front.detectEvent(),wdi_front.globalInit())}),jQuery(document).ready(function(){setTimeout(function(){"1"===wdi_front_messages.show_alerts&&"I"!==jQuery(".wdi_check_fontawesome .tenweb-i-instagram").prop("tagName")&&console.log("Font Awesome is not loaded properly. Please ask for support https://wordpress.org/support/plugin/wd-instagram-feed/")},2e3)});
1
+ "undefined"==typeof wdi_front&&(wdi_front={type:"not_declared"});var wdi_error_show=!(wdi_front.detectEvent=function(){var e="click";return/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase())&&(e="touchend"),e}),wdi_error_init=!1;function wdi_baseName(e){var i=e.substr(e.lastIndexOf("/"));return e.replace(i,"")}wdi_front.escape_tags=function(e){return void 0===e&&(e=""),e=e.toString().replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;").replace(/"/g,"&#34;")},wdi_front.show_alert=function(e,i,d){var r,t;void 0!==(d=jQuery("#wdi_feed_"+d.feed_row.wdi_feed_counter))&&(wdi_error_show=!0,d.find(".wdi_spinner").remove(),r=d.find(".wdi_js_error"),t=d.find(".wdi_token_error"),0!=i&&(void 0!==i.meta&&1==i.meta.error&&"OAuthException"===i.meta.error_type||void 0!==i.error&&"OAuthException"===i.error.type)?(d.find(".wdi_single_user").remove(),t.removeClass("wdi_hidden"),"1"!=wdi_front_messages.wdi_token_error_flag&&jQuery.ajax({type:"POST",url:wdi_url.ajax_url,dataType:"json",data:{action:"wdi_token_flag",wdi_token_flag_nonce:wdi_front_messages.wdi_token_flag_nonce},success:function(e){}})):void 0!==i.error&&void 0!==i.error.message&&(r.html(i.error.message),d.find(".wdi_single_user").remove(),r.removeClass("wdi_js_error"),r.addClass("wdi_js_error_no_animate"),jQuery(".wdi_js_error_no_animate").show()),wdi_front_messages.show_alerts||console.log("%c"+e,"color:#cc0000;")),wdi_error_show=!0},wdi_front.globalInit=function(){var e=wdi_front.feed_counter,i=0;void 0!==wdi_ajax.ajax_response&&(i=wdi_feed_counter_init.wdi_feed_counter_init);for(var d,r=i;r<=e;r++)0!==jQuery("#wdi_feed_"+r).length&&((d=new WDIFeed(window["wdi_feed_"+r])).instagram=new WDIInstagram,d.instagram.filterArguments={feed:d},d.instagram.addToken(d.feed_row.access_token),wdi_front.access_token=d.feed_row.access_token,d.dataLoaded=0,d.dataStorageRaw=[],d.dataStorage=[],d.dataStorageList=[],d.allResponseLength=0,d.currentResponseLength=0,d.temproraryUsersData=[],d.removedUsers=0,d.nowLoadingImages=!0,d.imageIndex=0,d.resIndex=0,d.currentPage=1,d.currentPageLoadMore=0,d.userSortFlags=[],d.customFilterChanged=!1,d.maxConditionalFiltersRequestCount=10,d.instagramRequestCounter=0,d.mediaRequestsDone=!1,d.conditionalFilterBuffer=[],d.stopInfiniteScrollFlag=!1,"masonry"==d.feed_row.feed_type&&(d.displayedData=[]),"pagination"==d.feed_row.feed_display_view?(d.feed_row.resort_after_load_more=0,"image_browser"!=d.feed_row.feed_type?(d.feed_row.load_more_number=parseInt(d.feed_row.pagination_per_page_number),d.feed_row.number_of_photos=d.allResponseLength):(d.feed_row.number_of_photos=1+parseInt(d.feed_row.image_browser_preload_number),d.feed_row.load_more_number=parseInt(d.feed_row.image_browser_load_number)),d.freeSpaces=(Math.floor(d.feed_row.pagination_per_page_number/d.feed_row.number_of_columns)+1)*d.feed_row.number_of_columns-d.feed_row.pagination_per_page_number):d.freeSpaces=0,d.galleryBox=function(e){wdi_spider_createpopup(wdi_url.ajax_url+"?gallery_id="+this.feed_row.id+"&image_id="+e,this.feed_row.wdi_feed_counter,this.feed_row.lightbox_width,this.feed_row.lightbox_height,1,"testpopup",5,this,e)},wdi_responsive.columnControl(d),"masonry"==d.feed_row.feed_type&&jQuery(window).trigger("resize"),wdi_front.bindEvents(d),window["wdi_feed_"+r]=d,wdi_front.init(d))},wdi_front.init=function(e){if(jQuery(".wdi_js_error").hide(),e.photoCounter=e.feed_row.number_of_photos,"liked"==e.feed_row.liked_feed)e.feed_users=["self"];else{if(!wdi_front.isJsonString(e.feed_row.feed_users))return void wdi_front.show_alert(wdi_front_messages.invalid_users_format,!1,e);e.feed_users=JSON.parse(e.feed_row.feed_users)}var i=[],d=[],r=[];void 0!==window.wdi_all_tags&&(i=window.wdi_all_tags);for(var t=0;t<e.feed_users.length;t++)"#"===e.feed_users[t].username[0]&&void 0!==e.feed_users[t].tag_id?(i[e.feed_users[t].tag_id]=e.feed_users[t],r[t]=e.feed_users[t]):d[0]=e.feed_users[t];window.wdi_all_tags=i,e.feed_users=void 0===r||wdi_front.isEmpty(r)?d:r;var a=wdi_front.getFeedItemResolution(e);e.feedImageResolution=a.image,e.feedVideoResolution=a.video,e.dataCount=e.feed_users.length;for(var o=0;o<e.dataCount;o++)wdi_front.instagramRequest(o,e);0<e.feed_row.number_of_photos&&wdi_front.ajaxLoader(e),"1"===e.feed_row.display_header&&wdi_front.show("header",e),"1"===e.feed_row.show_usernames&&wdi_front.show("users",e)},wdi_front.getFeedItemResolution=function(e){var i={image:"standard_resolution",video:"standard_resolution"};if("thumbnail"===e.feed_row.feed_resolution)return{image:"thumbnail",video:"low_bandwidth"};if("low"===e.feed_row.feed_resolution)return{image:"low_resolution",video:"low_resolution"};if("standard"===e.feed_row.feed_resolution)return{image:"standard_resolution",video:"standard_resolution"};var d=jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter).find(".wdi_feed_wrapper");d.append('<div class="wdi_feed_item" id="wdi_feed_item_example"></div>'),wdi_responsive.columnControl(e,1);e=d.attr("wdi-res").split("wdi_col_");if(d.find("#wdi_feed_item_example").remove(),2!==e.length)return i;e=parseInt(e[1]);if(e<=0)return i;e=d.width()/e-10;return e<=150?(i.image="thumbnail",i.video="low_bandwidth"):150<e&&e<=320?(i.image="low_resolution",i.video="low_resolution"):(i.image="standard_resolution",i.video="standard_resolution"),i},wdi_front.isJsonString=function(e){try{JSON.parse(e)}catch(e){return!1}return!0},wdi_front.instagramRequest=function(i,d){var r=this,e=d.feed_users;if("string"==typeof e[i]&&"self"===e[i])d.instagram.getRecentLikedMedia({success:function(e){void 0!==e.meta&&void 0!==e.meta.error_type&&wdi_front.show_alert(!1,e,d),d.mediaRequestsDone=!0,0!=(e=r.checkMediaResponse(e,d))&&r.saveSelfUserData(e,d)}});else if("hashtag"==this.getInputType(e[i].username)){if(this.isJsonString(d.feed_row.feed_users))for(var t in json_feed_users=JSON.parse(d.feed_row.feed_users),json_feed_users)"#"!==json_feed_users[t].username.charAt(0)&&(user=json_feed_users[t]);d.instagram.getTagRecentMedia(this.stripHashtag(e[i].username),{feed_id:d.feed_row.id,user_id:user.id,user_name:user.username,success:function(e){if(void 0!==e.error&&"undefined"!=e.error.type||void 0!==e.meta&&1==e.meta.error)return d.dataLoaded=1,wdi_front.show_alert(!1,e,d),!1;d.mediaRequestsDone=!0,e=r.checkMediaResponse(e,d),d.dataLoaded=1,0!=e&&r.saveUserData(e,d.feed_users[i],d)}},null,d.feed_row.hashtag_top_recent,0)}else"user"==this.getInputType(e[i].username)&&d.instagram.getUserMedia({feed_id:d.feed_row.id,user_id:e[i].id,user_name:e[i].username,success:function(e){if(void 0!==e.meta&&1==typeof e.meta.error)return d.dataLoaded=1,wdi_front.show_alert(!1,e,d),!1;d.mediaRequestsDone=!0,d.dataLoaded=1,0!=(e=r.checkMediaResponse(e,d))?r.saveUserData(e,d.feed_users[i],d):wdi_front.allImagesLoaded(d)}},"",0)},wdi_front.isHashtag=function(e){return"#"===e[0]},wdi_front.saveUserData=function(e,i,d){e.user_id=i.id,e.username=i.username,"#"===e.user_id[0]&&(e.data=wdi_front.appendRequestHashtag(e.data,e.user_id)),d.usersData.push(e),d.currentResponseLength=wdi_front.getArrayContentLength(d.usersData,"data"),d.allResponseLength+=d.currentResponseLength,d.dataCount==d.usersData.length&&(d.currentResponseLength<d.feed_row.number_of_photos&&!wdi_front.userHasNoPhoto(d)?wdi_front.loadMore("initial-keep",d):(wdi_front.displayFeed(d),wdi_front.applyFilters(d),wdi_front.activeUsersCount(d)||"load_more_btn"==d.feed_row.feed_display_view&&((d=jQuery("#wdi_feed_"+d.feed_row.wdi_feed_counter)).find(".wdi_load_more").addClass("wdi_hidden"),d.find(".wdi_spinner").addClass("wdi_hidden"))))},wdi_front.saveSelfUserData=function(e,i){e.user_id="",e.username="",i.usersData.push(e),i.currentResponseLength=wdi_front.getArrayContentLength(i.usersData,"data"),i.allResponseLength+=i.currentResponseLength,i.dataCount==i.usersData.length&&(i.currentResponseLength<i.feed_row.number_of_photos&&!wdi_front.userHasNoPhoto(i)?wdi_front.loadMore("initial-keep",i):(wdi_front.displayFeed(i),wdi_front.applyFilters(i),wdi_front.activeUsersCount(i)||"load_more_btn"==i.feed_row.feed_display_view&&((i=jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter)).find(".wdi_load_more").addClass("wdi_hidden"),i.find(".wdi_spinner").addClass("wdi_hidden"))))},wdi_front.userHasNoPhoto=function(e,i){var d=0,r=e.usersData;void 0!==i&&(r=i);for(var t=0;t<r.length;t++)void 0===r[t].pagination&&(r[t].pagination=[]),"liked"===e.feed_row.liked_feed?void 0===r[t].pagination.next_max_like_id&&d++:void 0===r[t].pagination.next_max_id&&d++;return d==r.length?1:0},wdi_front.appendRequestHashtag=function(e,i){for(var d=0;d<e.length;d++)e[d].wdi_hashtag=i;return e},wdi_front.displayFeed=function(e,i){void 0===i&&(i=1);for(var d=0;d<e.usersData.length;d++)e.dataStorageList=e.usersData[d].data,e.dataStorage[d]=e.usersData[d].data;var r=e.feed_row.number_of_photos,t=e.feed_row.load_more_number,a=0,o=r,r="";"pagination"==e.feed_row.feed_display_view?(1<e.allResponseLength&&jQuery(".wdi_pagination").removeClass("wdi_hidden"),e.feed_row.number_of_photos=e.allResponseLength,"image_browser"==e.feed_row.feed_type?e.paginator=parseInt(e.feed_row.number_of_photos):e.paginator=Math.ceil(parseInt(e.feed_row.number_of_photos)/parseInt(t)),r=(o=1===i?(a=0,"image_browser"==e.feed_row.feed_type?1:t):"image_browser"==e.feed_row.feed_type?(a=i-1)+1:(a=(i-1)*t)+t,e.dataStorageList.slice(a,o))):void 0!==e.already_loaded_count?(a=parseInt(e.already_loaded_count),o=e.already_loaded_count+parseInt(t),r=e.dataStorageList.slice(a,o),e.already_loaded_count+=r.length):(r=e.dataStorageList.slice(a,o),e.already_loaded_count=r.length),e.parsedData=wdi_front.parseLighboxData(e,!0),"masonry"==e.feed_row.feed_type&&wdi_front.masonryDisplayFeedItems(r,e),"thumbnails"!=e.feed_row.feed_type&&"blog_style"!=e.feed_row.feed_type&&"image_browser"!=e.feed_row.feed_type||wdi_front.displayFeedItems(r,e),"pagination"==e.feed_row.feed_display_view&&e.currentPage<e.paginator&&jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter).find("#wdi_last_page").removeClass("wdi_disabled"),wdi_front.updateUsersImages(e)},wdi_front.updateUsersImages=function(i){jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter).find(".wdi_single_user .wdi_user_img_wrap img").each(function(){if((jQuery(this).attr("src")==wdi_url.plugin_url+"images/missing.png"||""==jQuery(this).attr("src"))&&"liked"!=i.feed_row.liked_feed)for(var e=0;e<i.usersData.length;e++)i.usersData[e].username==jQuery(this).parent().parent().find("h3").text()&&0!=i.usersData[e].data.length&&jQuery(this).attr("src",i.usersData[e].data[0].images.thumbnail.url)})},wdi_front.checkLoaded=function(e){var i=e.feed_row.wdi_feed_counter,d=jQuery("#wdi_feed_"+i);e.dataStorageList.length>e.already_loaded_count?d.find(".wdi_load_more").removeClass("wdi_hidden"):d.find(".wdi_load_more").addClass("wdi_hidden"),d.find(".wdi_spinner").addClass("wdi_hidden"),setTimeout(function(){d.find(".wdi_ajax_loading").addClass("wdi_hidden"),d.find(".wdi_page_loading").addClass("wdi_hidden"),d.find(".wdi_front_overlay").addClass("wdi_hidden")},500)},wdi_front.masonryDisplayFeedItems=function(e,i){var d=[],r=[];if(0!=jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length){jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" .wdi_masonry_column").each(function(){1==i.feed_row.resort_after_load_more&&(jQuery(this).html(""),i.imageIndex=0),1==i.customFilterChanged&&(jQuery(this).html(""),i.imageIndex=0),"pagination"==i.feed_row.feed_display_view?d.push(0):d.push(jQuery(this).height()),r.push(jQuery(this))}),1==i.customFilterChanged&&(i.customFilterChanged=!1);for(var t,a,o,n=0;n<e.length;n++)"object"==typeof e[n].videos&&null==e[n].videos.standard_resolution||(i.displayedData.push(e[n]),t="",void 0!==e[n].wdi_hashtag&&(t=e[n].wdi_hashtag),a="image"==e[n].type?wdi_front.getPhotoTemplate(i,t):e[n].hasOwnProperty("videos")||"video"==e[n].type?wdi_front.getVideoTemplate(i,t):wdi_front.getSliderTemplate(i,t),o=e[n],t=a(wdi_front.createObject(o,i)),a=wdi_front.array_min(d),o=wdi_front.getImageResolution(e[n]),r[a.index].html(r[a.index].html()+t),d[a.index]+=r[a.index].width()*o,i.imageIndex++,"pagination"==i.feed_row.feed_display_view&&((n+1)%i.feed_row.pagination_per_page_number==0?i.resIndex+=i.freeSpaces+1:i.resIndex++));i.wdi_loadedImages=0;var s=!1;i.wdi_load_count=n;var _=i.feed_row.wdi_feed_counter;jQuery("#wdi_feed_"+_+" .wdi_img").on("load",function(){i.wdi_loadedImages++,!1===s&&(wdi_responsive.columnControl(i,1),s=!0)});wdi_front.checkLoaded(i),1==i.paginatorNextFlag&&wdi_front.updatePagination(i,"next"),i.infiniteScrollFlag=!1}},wdi_front.getImageResolution=function(e){var i;return e="image"===e.type?(i=e.images.standard_resolution.height,e.images.standard_resolution.width):"video"===e.type?(i=e.videos.standard_resolution.height,e.videos.standard_resolution.width):(i=(e.carousel_media[0].images||e.carousel_media[0].videos).standard_resolution.height,(e.carousel_media[0].images||e.carousel_media[0].videos).standard_resolution.width),i/e},wdi_front.getDataLength=function(e,i){var d=0;if(void 0===i)for(var r=0;r<e.dataStorage.length;r++)d+=e.dataStorage[r].length;else for(r=0;r<i.length;r++)d+=i[r].length;return d},wdi_front.getArrayContentLength=function(e,i){for(var d=0,r=0;r<e.length;r++)"finished"!=e[r].finished&&void 0===e[r].error&&(d+=e[r][i].length);return d},wdi_front.displayFeedItems=function(e,i){if(0!=jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length){for(var d,r,t,a=i.feed_row.wdi_feed_counter,o=jQuery("#wdi_feed_"+a+" .wdi_feed_wrapper"),n=0;n<e.length;n++){if(void 0===e[n])return;"object"==typeof e[n].videos&&null==e[n].videos.standard_resolution||(t="",void 0!==e[n].wdi_hashtag&&(t=e[n].wdi_hashtag),d="image"==e[n].type?wdi_front.getPhotoTemplate(i,t):e[n].hasOwnProperty("videos")?wdi_front.getVideoTemplate(i,t):wdi_front.getSliderTemplate(i,t),r=e[n],t="",void 0!==(r=wdi_front.createObject(r,i))&&(t=d(r)),o.html(o.html()+t),i.imageIndex++,"pagination"==i.feed_row.feed_display_view&&((n+1)%i.feed_row.pagination_per_page_number==0?i.resIndex+=i.freeSpaces+1:i.resIndex++))}wdi_front.checkLoaded(i)}},wdi_front.checkFeedFinished=function(e){for(var i=0;i<e.usersData.length;i++)if(void 0===e.usersData[i].finished)return!1;return!0},wdi_front.createObject=function(e,i){var d=null!=e.caption?e.caption.text:"&nbsp";switch(e.type){case"image":var r=e.images[i.feedImageResolution].url,t=void 0,a=e.hasOwnProperty("thumbnail")?e.thumbnail:wdi_url.plugin_url+"images/missing.png";break;case"video":r=void 0,t=e.hasOwnProperty("videos")?e.videos[i.feedVideoResolution].url:wdi_url.plugin_url+"images/video_missing.png",a=e.hasOwnProperty("thumbnail")?e.thumbnail:wdi_url.plugin_url+"images/video_missing.png";break;case"carousel":if(0===e.carousel_media.length)r=wdi_url.plugin_url+"images/missing.png",t=void 0,a=wdi_url.plugin_url+"images/missing.png";else switch(e.carousel_media[0].type){case"image":r=e.carousel_media[0].images[i.feedImageResolution].url,t=void 0,a=e.hasOwnProperty("thumbnail")?e.thumbnail:wdi_url.plugin_url+"images/missing.png";break;case"video":r=void 0,t=e.carousel_media[0].videos[i.feedVideoResolution].url,a=e.hasOwnProperty("thumbnail")?e.thumbnail:wdi_url.plugin_url+"images/video_missing.png";break;default:r=wdi_url.plugin_url+"images/missing.png",t=void 0,a=wdi_url.plugin_url+"images/missing.png"}break;default:r=wdi_url.plugin_url+"images/missing.png",t=void 0,a=wdi_url.plugin_url+"images/missing.png"}var o,n=i.imageIndex,s="square";(_="image"===e.type?(o=e.images.standard_resolution.height,e.images.standard_resolution.width):"video"===e.type?(o=e.videos.standard_resolution.height,e.videos.standard_resolution.width):(o=(e.carousel_media[0].images||e.carousel_media[0].videos).standard_resolution.height,(e.carousel_media[0].images||e.carousel_media[0].videos).standard_resolution.width))<o?s="portrait":o<_&&(s="landscape");var _=e.user.username;return""===_&&(_="no_user"),{id:e.id,thumb_url:a,caption:wdi_front.escape_tags(d),image_url:r,likes:void 0!==e.likes.count?e.likes.count:e.likes,comments:void 0!==e.comments.count?e.comments.count:e.comments,wdi_index:n,wdi_res_index:i.resIndex,wdi_media_user:_,link:e.link,video_url:t,wdi_username:_,wdi_shape:s}},wdi_front.getPhotoTemplate=function(e,i){var d="",r="",t="",a="tenweb-i-arrows-out",o="";"blog_style"!=e.feed_row.feed_type&&"image_browser"!=e.feed_row.feed_type||(a=""),"1"==e.feed_row.show_username_on_thumb&&e.data.length&&""!==e.data[0].user.username&&(o='<span class="wdi_media_user">@<%= wdi_username%></span>'),1==e.feed_row.show_full_description&&"masonry"==e.feed_row.feed_type&&(d+=" wdi_full_caption");var n="";switch("blog_style"!==e.feed_row.feed_type&&(n="masonry"==e.feed_row.feed_type?"wdi_responsive.showMasonryCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");":"wdi_responsive.showCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");"),e.feed_row.feed_item_onclick){case"lightbox":r="onclick=wdi_feed_"+e.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":r="onclick=\"window.open ('<%= link%>','_blank')\"",t="wdi_hover_off",a="";break;case"custom_redirect":r="onclick=\"window.open ('"+e.feed_row.redirect_url+"','_self')\"",t="wdi_hover_off",a="";break;case"none":t="wdi_cursor_off wdi_hover_off",a=r=""}var s='<div class="wdi_feed_item '+d+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> wdi_type="image" id="wdi_'+e.feed_row.wdi_feed_counter+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img <%= wdi_shape == \'square\' ? \'wdi_shape_square\' : (wdi_shape == \'portrait\' ? \'wdi_shape_portrait\' : (wdi_shape == \'landscape\' ? \'wdi_shape_landscape\' : \'wdi_shape_square\') ) %>"><img class="wdi_img" src="<%=thumb_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+t+'" >'+o+'<div class="wdi_thumb_icon" '+r+' style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="tenweb-i '+a+'"></i></div></div></div></div></div></div>',w=e.imageIndex;return"1"!==e.feed_row.show_likes&&"1"!==e.feed_row.show_comments&&"1"!==e.feed_row.show_description||(s+='<div class="wdi_photo_meta">',void(o=d=0)!==e.dataStorageList[w]&&(void 0!==e.dataStorageList[w].likes&&(d=void 0!==e.dataStorageList[w].likes.count?e.dataStorageList[w].likes.count:e.dataStorageList[w].likes),void 0!==e.dataStorageList[w].comments&&(o=void 0!==e.dataStorageList[w].comments.count?e.dataStorageList[w].comments.count:e.dataStorageList[w].comments)),"1"===e.feed_row.show_likes&&0!==d&&(s+='<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>'),"1"===e.feed_row.show_comments&&0!==o&&(s+='<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>'),s+='<div class="wdi_clear"></div>',"1"===e.feed_row.show_description&&(s+='<div class="wdi_photo_title" onclick='+n+" ><%=caption%></div>"),s+="</div>"),s+="</div>",_.template(s)},wdi_front.getSliderTemplate=function(e,i){var d="",r="",t="",a="tenweb-i-clone",o="";"blog_style"!=e.feed_row.feed_type&&"image_browser"!=e.feed_row.feed_type||(a=""),"1"==e.feed_row.show_username_on_thumb&&e.data.length&&""!==e.data[0].user.username&&(o='<span class="wdi_media_user">@<%= wdi_username%></span>'),1==e.feed_row.show_full_description&&"masonry"==e.feed_row.feed_type&&(d+=" wdi_full_caption");var n="";switch("blog_style"!==e.feed_row.feed_type&&(n="masonry"==e.feed_row.feed_type?"wdi_responsive.showMasonryCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");":"wdi_responsive.showCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");"),e.feed_row.feed_item_onclick){case"lightbox":r="onclick=wdi_feed_"+e.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":r="onclick=\"window.open ('<%= link%>','_blank')\"",t="wdi_hover_off",a="tenweb-i-clone";break;case"custom_redirect":r="onclick=\"window.open ('"+e.feed_row.redirect_url+"','_self')\"",t="wdi_hover_off",a="";break;case"none":t="wdi_cursor_off wdi_hover_off",a=r=""}var s='<div class="wdi_feed_item '+d+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> wdi_type="slideshow" id="wdi_'+e.feed_row.wdi_feed_counter+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img <%= wdi_shape == \'square\' ? \'wdi_shape_square\' : (wdi_shape == \'portrait\' ? \'wdi_shape_portrait\' : (wdi_shape == \'landscape\' ? \'wdi_shape_landscape\' : \'wdi_shape_square\') ) %>"><img class="wdi_img" src="<%=thumb_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+t+'" >'+o+'<div class="wdi_thumb_icon" '+r+' style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="tenweb-i '+a+'"></i></div></div></div></div></div></div>',w=e.imageIndex;return"1"!==e.feed_row.show_likes&&"1"!==e.feed_row.show_comments&&"1"!==e.feed_row.show_description||(s+='<div class="wdi_photo_meta">',void(o=d=0)!==e.dataStorageList[w]&&(void 0!==e.dataStorageList[w].likes&&(d=void 0!==e.dataStorageList[w].likes.count?e.dataStorageList[w].likes.count:e.dataStorageList[w].likes),void 0!==e.dataStorageList[w].comments&&(o=void 0!==e.dataStorageList[w].comments.count?e.dataStorageList[w].comments.count:e.dataStorageList[w].comments)),"1"===e.feed_row.show_likes&&0!==d&&(s+='<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>'),"1"===e.feed_row.show_comments&&0!==o&&(s+='<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>'),s+='<div class="wdi_clear"></div>',"1"===e.feed_row.show_description&&(s+='<div class="wdi_photo_title" onclick='+n+" ><%=caption%></div>"),s+="</div>"),s+="</div>",_.template(s)},wdi_front.getVideoTemplate=function(e,i){var d="",r="tenweb-i-play",t="",a="",o="";"1"==e.feed_row.show_username_on_thumb&&e.data.length&&""!==e.data[0].user.username&&(o='<span class="wdi_media_user">@<%= wdi_username%></span>'),1==e.feed_row.show_full_description&&"masonry"==e.feed_row.feed_type&&(d+=" wdi_full_caption");var n="";switch("blog_style"!==e.feed_row.feed_type&&(n="masonry"==e.feed_row.feed_type?"wdi_responsive.showMasonryCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");":"wdi_responsive.showCaption(jQuery(this),"+e.feed_row.wdi_feed_counter+");"),e.feed_row.feed_item_onclick){case"lightbox":t="onclick=wdi_feed_"+e.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":t="onclick=\"window.open ('<%= link%>','_blank')\"",a="wdi_hover_off",r="tenweb-i-play";break;case"custom_redirect":t="onclick=\"window.open ('"+e.feed_row.redirect_url+"','_self')\"",a="wdi_hover_off",r="";break;case"none":a="wdi_cursor_off wdi_hover_off",r="","blog_style"!=e.feed_row.feed_type&&"image_browser"!=e.feed_row.feed_type||(t="onclick=wdi_front.replaceToVideo('<%= video_url%>','<%= wdi_index%>',"+e.feed_row.wdi_feed_counter+")",a="",r="tenweb-i-play")}var s='<div class="wdi_feed_item '+d+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> wdi_type="image" id="wdi_'+e.feed_row.wdi_feed_counter+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img <%= wdi_shape == \'square\' ? \'wdi_shape_square\' : (wdi_shape == \'portrait\' ? \'wdi_shape_portrait\' : (wdi_shape == \'landscape\' ? \'wdi_shape_landscape\' : \'wdi_shape_square\') ) %>"><img class="wdi_img" src="<%=thumb_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+a+'" '+t+">"+o+'<div class="wdi_thumb_icon" style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="tenweb-i '+r+'"></i></div></div></div></div></div></div>',w=e.imageIndex;return"1"!==e.feed_row.show_likes&&"1"!==e.feed_row.show_comments&&"1"!==e.feed_row.show_description||(s+='<div class="wdi_photo_meta">',void(o=d=0)!==e.dataStorageList[w]&&(void 0!==e.dataStorageList[w].likes&&(d=void 0!==e.dataStorageList[w].likes.count?e.dataStorageList[w].likes.count:e.dataStorageList[w].likes),void 0!==e.dataStorageList[w].comments&&(o=void 0!==e.dataStorageList[w].comments.count?e.dataStorageList[w].comments.count:e.dataStorageList[w].comments)),"1"===e.feed_row.show_likes&&0!==d&&(s+='<div class="wdi_thumb_likes"><i class="tenweb-i tenweb-i-heart-o">&nbsp;<%= likes%></i></div>'),"1"===e.feed_row.show_comments&&0!==o&&(s+='<div class="wdi_thumb_comments"><i class="tenweb-i tenweb-i-comment-square">&nbsp;<%= comments%></i></div>'),s+='<div class="wdi_clear"></div>',"1"===e.feed_row.show_description&&(s+='<div class="wdi_photo_title" onclick='+n+" ><%=caption%></div>"),s+="</div>"),s+="</div>",_.template(s)},wdi_front.replaceToVideo=function(e,i,d){overlayHtml="<video style='width:auto !important; height:auto !important; max-width:100% !important; max-height:100% !important; margin:0 !important;' controls=''><source src='"+e+"' type='video/mp4'>Your browser does not support the video tag. </video>",jQuery("#wdi_feed_"+d+' [wdi_index="'+i+'"] .wdi_photo_wrap_inner').html(overlayHtml),jQuery("#wdi_feed_"+d+' [wdi_index="'+i+'"] .wdi_photo_wrap_inner video').get(0).play()},wdi_front.bindEvents=function(i){0!=jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length&&("load_more_btn"==i.feed_row.feed_display_view&&jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" .wdi_load_more_container").on(wdi_front.clickOrTouch,function(){jQuery(document).find("#wdi_feed_"+i.feed_row.wdi_feed_counter+" .wdi_load_more").addClass("wdi_hidden"),jQuery(document).find("#wdi_feed_"+i.feed_row.wdi_feed_counter+" .wdi_spinner").removeClass("wdi_hidden"),setTimeout(function(){wdi_front.loadMore(jQuery(this).find(".wdi_load_more_wrap"),i)},1e3)}),"pagination"==i.feed_row.feed_display_view&&(jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" #wdi_next").on(wdi_front.clickOrTouch,function(){var e=parseInt(jQuery(this).parents(".wdi_pagination_container").find("#wdi_current_page").text())+1;parseInt(e)>i.paginator||(i.currentPage=parseInt(e),wdi_front.changePage(jQuery(this),i))}),jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" #wdi_prev").on(wdi_front.clickOrTouch,function(){var e=parseInt(jQuery(this).parents(".wdi_pagination_container").find("#wdi_current_page").text())-1;parseInt(e)<=0||(i.currentPage=parseInt(e),wdi_front.changePage(jQuery(this),i))}),jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" #wdi_last_page").on(wdi_front.clickOrTouch,function(){i.currentPage=i.paginator,wdi_front.changePage(jQuery(this),i)}),jQuery("#wdi_feed_"+i.feed_row.wdi_feed_counter+" #wdi_first_page").on(wdi_front.clickOrTouch,function(){i.currentPage=1,wdi_front.changePage(jQuery(this),i)}),i.paginatorNextFlag=!1),"infinite_scroll"==i.feed_row.feed_display_view&&(jQuery(window).on("scroll",function(){wdi_front.infiniteScroll(i)}),i.infiniteScrollFlag=!1))},wdi_front.infiniteScroll=function(e){jQuery(window).scrollTop()+jQuery(window).height()-100>=jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" #wdi_infinite_scroll").offset().top&&(e.dataStorageList.length>e.already_loaded_count||void 0===e.already_loaded_count?(e.infiniteScrollFlag=!0,wdi_front.loadMore(jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" #wdi_infinite_scroll"),e)):wdi_front.allImagesLoaded(e))},wdi_front.changePage=function(e,i){new_page_number=i.currentPage,1<new_page_number?e.parents(".wdi_pagination").find("#wdi_first_page").removeClass("wdi_disabled"):1===new_page_number&&e.parents(".wdi_pagination").find("#wdi_first_page").addClass("wdi_disabled"),new_page_number==parseInt(i.paginator)?e.parents(".wdi_pagination").find("#wdi_last_page").addClass("wdi_disabled"):new_page_number<parseInt(i.paginator)&&e.parents(".wdi_pagination").find("#wdi_last_page").removeClass("wdi_disabled"),("masonry"==i.feed_row.feed_type?e.parent().parent().parent().find(".wdi_feed_wrapper .wdi_masonry_column"):e.parent().parent().parent().find(".wdi_feed_wrapper")).empty(),e.parent().find("#wdi_current_page").empty().text(new_page_number);e=e.closest(".wdi_feed_container");e.parents(".wdi_feed_main_container").find(".wdi_front_overlay").removeClass("wdi_hidden"),e.parents(".wdi_feed_main_container").find(".wdi_page_loading").removeClass("wdi_hidden"),wdi_front.displayFeed(i,new_page_number)},wdi_front.updatePagination=function(e,i,d){var r="#wdi_feed_"+e.feed_row.wdi_feed_counter;switch(jQuery(r+' [wdi_page="'+e.currentPage+'"]').each(function(){jQuery(this).removeClass("wdi_hidden")}),i){case"next":var d=e.currentPage-1;jQuery(r+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height()),jQuery(r+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")});break;case"prev":d=e.currentPage+1;jQuery(r+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height()),jQuery(r+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")});break;case"custom":(d=d)!=e.currentPage&&(jQuery(r+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height()),jQuery(r+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")}))}e.paginatorNextFlag=!1,jQuery(r+" .wdi_feed_wrapper").css("height","auto"),jQuery(r+" #wdi_current_page").text(e.currentPage)},wdi_front.loadMore=function(e,i){var d;if(""!=e&&void 0!==e&&"initial"!=e&&"initial-keep"!=e&&(d=window[e.parent().parent().parent().parent().attr("id")]),void 0!==i&&(d=i),wdi_front.ajaxLoader(d),this.isJsonString(d.feed_row.feed_users))for(var r in json_feed_users=JSON.parse(d.feed_row.feed_users),json_feed_users)iuser=json_feed_users[r],"#"!==json_feed_users[r].username.charAt(0)&&(iuser=json_feed_users[r]);"masonry"===d.feed_row.feed_type&&"pagination"==d.feed_row.feed_display_view&&jQuery("#wdi_feed_"+wdi_front.feed_counter+" .wdi_full_caption").each(function(){jQuery(this).find(".wdi_photo_title").trigger(wdi_front.clickOrTouch)}),d.loadMoreDataCount=d.feed_users.length,wdi_front.displayFeed(d)},wdi_front.loadMoreRequest=function(e,i,d,r){d.mediaRequestsDone&&""!=i&&d.usersData},wdi_front.checkForLoadMoreDone=function(e,i){var d,r=e.feed_row.load_more_number,t=e.feed_row.number_of_photos;0==e.loadMoreDataCount&&(e.temproraryUsersData=wdi_front.mergeData(e.temproraryUsersData,e.usersData),d=wdi_front.getArrayContentLength(e.temproraryUsersData,"data"),"initial-keep"==i&&(i="initial"),"initial"==i?d<t&&!wdi_front.userHasNoPhoto(e,e.temproraryUsersData)&&e.instagramRequestCounter<=e.maxConditionalFiltersRequestCount?wdi_front.loadMore("initial",e):(e.usersData=e.temproraryUsersData,wdi_front.displayFeed(e),wdi_front.applyFilters(e),e.temproraryUsersData=[]):d<r&&!wdi_front.userHasNoPhoto(e,e.temproraryUsersData)&&e.instagramRequestCounter<=e.maxConditionalFiltersRequestCount?wdi_front.loadMore(void 0,e):(e.usersData=e.temproraryUsersData,wdi_front.activeUsersCount(e)&&(wdi_front.displayFeed(e,r),wdi_front.applyFilters(e),e.temproraryUsersData=[])))},wdi_front.allDataHasFinished=function(e){for(var i=0,d=0;d<e.dataStorageRaw.length;d++)""==e.usersData[d].pagination.next_url&&(i++,e.usersData[d].finished="finished");return i==e.dataStorageRaw.length&&(jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_load_more").remove(),!0)},wdi_front.mergeData=function(e,i){for(var d=0;d<i.length;d++)void 0!==e[d]?"finished"!=i[d].finished&&(void 0===e[d].pagination.next_max_id&&void 0===e[d].pagination.next_max_like_id||(e[d].data=e[d].data.concat(i[d].data),e[d].pagination=i[d].pagination,e[d].user_id=i[d].user_id,e[d].username=i[d].username,e[d].meta=i[d].meta)):e.push(i[d]);return e},wdi_front.brokenImageHandler=function(e){return!0},wdi_front.ajaxLoader=function(e){var i,d=e.feed_row.wdi_feed_counter,d=jQuery(document).find("#wdi_feed_"+d);return"load_more_btn"==e.feed_row.feed_display_view&&(d.find(".wdi_load_more").addClass("wdi_hidden"),d.find(".wdi_spinner").removeClass("wdi_hidden")),"infinite_scroll"==e.feed_row.feed_display_view&&(0==d.find(".wdi_ajax_loading").length?(i=jQuery('<div class="wdi_ajax_loading"><div><div><img class="wdi_load_more_spinner" src="'+wdi_url.plugin_url+'images/ajax_loader.png"></div></div></div>'),d.find(".wdi_feed_container").append(i)):i=d.find(".wdi_ajax_loading"),i.removeClass("wdi_hidden")),1},wdi_front.allImagesLoaded=function(e){wdi_front.getDataLength(e);e.mediaRequestsDone||jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").remove("wdi_nomedia"),0==e.allResponseLength&&1===e.dataLoaded&&jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").append("<p class='wdi_nomedia'>"+wdi_front_messages.feed_nomedia+"</p>");var i=e.feed_row.wdi_feed_counter,i=jQuery("#wdi_feed_"+i);"load_more_btn"==e.feed_row.feed_display_view&&(parseInt(e.allResponseLength)>parseInt(e.feed_row.number_of_photos)&&i.find(".wdi_load_more").removeClass("wdi_hidden"),i.find(".wdi_spinner").addClass("wdi_hidden")),"infinite_scroll"==e.feed_row.feed_display_view&&jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+" .wdi_ajax_loading").addClass("wdi_hidden")},wdi_front.show=function(e,i){var d,r,t=i.feed_row.wdi_feed_counter,a=jQuery("#wdi_feed_"+t+" .wdi_feed_container");"header"===e&&(d={feed_thumb:i.feed_row.feed_thumb,feed_name:i.feed_row.feed_name},r=wdi_front.getHeaderTemplate()(d),d=a.find(".wdi_feed_header").html(),a.find(".wdi_feed_header").html(d+r))},wdi_front.getUserTemplate=function(e,i){var d=e.dataCount,r="#"===i[0]?"//instagram.com/explore/tags/"+i.substr(1,i.length):"//instagram.com/"+i,t="onclick='"+('window.open("'+r+'","_blank")')+"'",r='<div class="wdi_single_user" user_index="<%=user_index%>"><div class="wdi_header_user_text <%=hashtagClass%>"><div class="wdi_user_img_wrap"><img onerror="wdi_front.brokenImageHandler(this);" src="<%= user_img_url%>">';return 1<d&&(r+='<div title="'+wdi_front_messages.filter_title+'" class="wdi_filter_overlay"><div class="wdi_filter_icon"><span onclick="wdi_front.addFilter(<%=user_index%>,<%=feed_counter%>);" class="tenweb-i tenweb-i-filter"></span></div></div>'),r+="</div>",r+="<h3 "+t+"><%= user_name%></h3>","#"!==i[0]?("1"==e.feed_row.follow_on_instagram_btn&&(r+='<div class="wdi_user_controls"><div class="wdi_follow_btn" onclick="window.open(\'//instagram.com/<%= user_name%>\',\'_blank\')"><span> '+wdi_front_messages.follow+"</span></div></div>"),r+='<div class="wdi_media_info"><p class="wdi_posts"><span class="tenweb-i tenweb-i-camera-retro"></span><%= counts.media%></p><p class="wdi_followers"><span class="tenweb-i tenweb-i-user"></span><%= counts.followed_by%></p></div>'):r+='<div class="wdi_user_controls"></div><div class="wdi_media_info"><p class="wdi_posts"><span class="tenweb-i tenweb-i-camera-retro"></span><%= counts.media%></p><p class="wdi_followers"><span></span></p></div>',r+='<div class="wdi_clear"></div>',1==d&&"#"!==i[0]&&"1"==e.feed_row.display_user_info&&(r+='<div class="wdi_bio"><%= bio%></div>',r+='<div class="wdi_website"><a target="_blank" href="<%= website_url%>" ><%= website%></a></div>'),r+="</div></div>",_.template(r)},wdi_front.getHeaderTemplate=function(){return _.template('<div class="wdi_header_wrapper"><div class="wdi_header_img_wrap"><img src="<%=feed_thumb%>"></div><div class="wdi_header_text"><%=feed_name%></div><div class="wdi_clear"></div>')},wdi_front.addFilter=function(e,i){var d=window["wdi_feed_"+i],i=d.dataCount;if(!(i<2)&&0==d.nowLoadingImages){i=jQuery("#wdi_feed_"+d.feed_row.wdi_feed_counter+'_users [user_index="'+e+'"]');i.find(".wdi_filter_overlay").toggleClass("wdi_filter_active_bg"),i.find(".wdi_header_user_text h3").toggleClass("wdi_filter_active_col"),i.find(".wdi_media_info").toggleClass("wdi_filter_active_col"),i.find(".wdi_follow_btn").toggleClass("wdi_filter_active_col"),d.customFilterChanged=!0,0==d.userSortFlags[e].flag?d.userSortFlags[e].flag=!0:d.userSortFlags[e].flag=!1;for(var r=0,t=0;t<d.userSortFlags.length;t++)1==d.userSortFlags[t].flag&&r++;"pagination"==d.feed_row.feed_display_view&&(d.resIndex=0),0!=r?wdi_front.filterData(d):d.customFilteredData=d.dataStorageList,wdi_front.displayFeed(d),"pagination"==d.feed_row.feed_display_view&&(d.paginator=Math.ceil(d.imageIndex/parseInt(d.feed_row.pagination_per_page_number)),d.currentPage=d.paginator,wdi_front.updatePagination(d,"custom",1),jQuery("#wdi_first_page").removeClass("wdi_disabled"),jQuery("#wdi_last_page").addClass("wdi_disabled"))}},wdi_front.filterData=function(e){var i=e.userSortFlags;e.customFilteredData=[];for(var d=0;d<e.dataStorageList.length;d++)for(var r=0;r<i.length;r++)(void 0!==e.dataStorageList[d].user.id&&e.dataStorageList[d].user.id==i[r].id||e.dataStorageList[d].wdi_hashtag==i[r].name)&&1==i[r].flag&&e.customFilteredData.push(e.dataStorageList[d])},wdi_front.applyFilters=function(e){for(var i=0;i<e.userSortFlags.length;i++)1==e.userSortFlags[i].flag&&(jQuery("#wdi_feed_"+e.feed_row.wdi_feed_counter+'[user_index="'+i+'"]'),wdi_front.addFilter(i,e.feed_row.wdi_feed_counter),wdi_front.addFilter(i,e.feed_row.wdi_feed_counter))},wdi_front.getImgCount=function(e){for(var i=e.dataStorage,d=0,r=0;r<i.length;r++)d+=i[r].length;return d},wdi_front.parseLighboxData=function(e,i){for(var d,r,t,a,o=e.dataStorage,n=[],s=[],_=0;_<o.length;_++)for(var w=0;w<o[_].length;w++)n.push(o[_][w]);for(_=0;_<n.length;_++)void 0!==n[_]&&(r=void 0!==n[_]&&void 0!==n[_].media_url?n[_].media_url:wdi_url.plugin_url+"images/video_missing.png",r=n[_].thumbnail,void 0!==n[_]&&void 0===n[_].media_url&&("carousel"!==n[_].type||(void 0!==(a=n[_].carousel_media[0])&&void 0!==a.images||void 0!==a&&void 0!==a.videos)&&(r=a.thumbnail)),a=void(t=0)!==n[_].comments.count?n[_].comments.count:n[_].comments,void 0!==n[_]&&void 0!==a&&(t=a),d={alt:"",avg_rating:"",comment_count:t,date:wdi_front.convertUnixDate(n[_].created_time),description:wdi_front.getDescription(void 0!==n[_].caption&&null!==n[_].caption?wdi_front.escape_tags(n[_].caption.text):""),filename:wdi_front.getFileName(n[_]),filetype:wdi_front.getFileType(n[_]),hit_count:"0",id:n[_].id,image_url:n[_].link,number:0,rate:"",rate_count:"0",username:void 0!==n[_].user?n[_].user.username:"",profile_picture:void 0!==n[_].user?n[_].user.profile_picture:"",thumb_url:r,comments_data:void 0!==n[_].comments?n[_].comments.data:"",images:n[_].images||n[_].videos,carousel_media:void 0!==n[_].carousel_media?n[_].carousel_media:null},s.push(d));return s},wdi_front.convertUnixDate=function(e){var i=new Date(e).getTime()/1e3,e=new Date(0);e.setUTCSeconds(i);i=e.getFullYear()+"-"+(e.getMonth()+1)+"-"+e.getDate();return i+=" "+e.getHours()+":"+e.getMinutes()},wdi_front.getDescription=function(e){return e=e.replace(/\r?\n|\r/g," ")},wdi_front.getFileName=function(e){if(void 0!==e){var i=e.link;if("video"===e.type&&e.hasOwnProperty("videos")&&null!=e.videos.standard_resolution)return e.videos.standard_resolution.url;if(void 0===i)return"";i=i.split("/");return i[i.length-2]}},wdi_front.getFileType=function(e){return"video"==e.type&&e.hasOwnProperty("videos")?"EMBED_OEMBED_INSTAGRAM_VIDEO":"carousel"==e.type&&e.hasOwnProperty("carousel_media")?"EMBED_OEMBED_INSTAGRAM_CAROUSEL":"EMBED_OEMBED_INSTAGRAM_IMAGE"},wdi_front.array_max=function(e){for(var i=e[0],d=0,r=1;r<e.length;r++)i<e[r]&&(i=e[r],d=r);return{value:i,index:d}},wdi_front.array_min=function(e){for(var i=e[0],d=0,r=1;r<e.length;r++)i>e[r]&&(i=e[r],d=r);return{value:i,index:d}},wdi_front.activeUsersCount=function(e){for(var i=0,d=0;d<e.usersData.length;d++)"finished"!=e.usersData[d].finished&&i++;return i},wdi_front.checkMediaResponse=function(e,i){return""==e||void 0===e||null==e||void 0!==e.error?(errorMessage=wdi_front_messages.connection_error,wdi_front.show_alert(errorMessage,e,i),!1):""!=e&&void 0!==e&&null!=e&&void 0!==e.meta&&200!=e.meta.code?(errorMessage=e.meta.error_message,wdi_front.show_alert(errorMessage,e,i),!1):e},wdi_front.stripHashtag=function(e){return"#"!==e[0]?e:e.substr(1,e.length)},wdi_front.getInputType=function(e){switch(e[0]){case"#":return"hashtag";case"%":return"location";default:return"user"}},wdi_front.regexpTestCaption=function(e,i){var d=!1,r=!1,t=i.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&"),i=new RegExp("(?:^|\\s)"+t+"(?:^|\\s)"),a=new RegExp("(?:^|\\s)"+t,"g");for(null!=i.exec(e)&&(d=!0);null!=(match=a.exec(e));)r=!0;return 1==d||1==r},wdi_front.replaceNewLines=function(e){var i,d="vUkCJvN2ps3t",r=[];for(e=e.replace(/\r?\n|\r/g,d),i=new RegExp(d,"g");null!=(match=i.exec(e));)r.push(match.index);for(var t=e.split(d),a=0,o=0;o<t.length;o++)""==t[o]?a++:a=0,0<a&&(t.splice(o,1),a--,o--);return e=t.join(" ")},wdi_front.isEmptyObject=function(e){for(var i in e)if(e.hasOwnProperty(i))return!1;return!0},wdi_front.isEmpty=function(e){return!e||0===e.length};var WDIFeed=function(e){this.data=e.data,this.dataCount=e.dataCount,this.feed_row=e.feed_row,this.usersData=e.usersData,(_this=this).set_images_loading_flag=function(e){window.addEventListener("load",function(){e.nowLoadingImages=!1})},this.set_images_loading_flag(_this)};function wdi_extractHostname(e){return void 0===e||""===e?"":e.replace(/(^\w+:|^)\/\//,"")}WDIFeed.prototype.mediaExists=function(e,i){for(var d=0;d<i.length;d++)if(e.id==i[d].id)return!0;return!1},WDIFeed.prototype.getIdFromUrl=function(e){for(var i=e.split("/"),d=!1,r=0;r<i.length;r++)if("p"==i[r]&&void 0!==i[r+1]){d=i[r+1];break}return d},WDIFeed.prototype.avoidDuplicateMedia=function(e){var i=e.data,d=[];void 0===i&&(i=[]);for(var r=0;r<i.length;r++)this.mediaExists(i[r],this.dataStorageList)||this.mediaExists(i[r],d)||this.mediaExists(i[r],this.conditionalFilterBuffer)||d.push(i[r]);return this.conditionalFilterBuffer=this.conditionalFilterBuffer.concat(d),{data:d,meta:e.meta,pagination:e.pagination}},WDIFeed.prototype.storeRawData=function(e,i){var r=this;if("object"==typeof this[i]&&"number"==typeof this[i].length)for(var d=0;d<e.length;d++){var t="";wdi_front.isHashtag(e[d].user_id)?void 0!==e[d].pagination.cursors&&(t=e[d].pagination.cursors.after):"liked"==r.feed_row.liked_feed?void 0===(t=e[d].pagination.next_max_like_id)&&(t=""):(null==e[d].pagination&&(e[d].pagination=[]),void 0===(t=e[d].pagination.next_max_id)&&(t="")),void 0===this[i][d]?this[i].push({data:e[d].data,index:0,locked:!1,hash_id:t,usersDataFinished:!1,userId:e[d].user_id,length:function(){return this.data.length-this.index},getData:function(e){var i=this.data.slice(this.index,this.index+e);if(this.index+=Math.min(e,this.length()),this.index==this.data.length&&1==this.locked&&0==this.usersDataFinished)for(var d=0;d<r.usersData.length;d++)if(r.usersData[d].user_id==this.userId){this.usersDataFinished=!0;break}return i}}):0==this[i][d].locked&&(t!=this[i][d].hash_id?(this[i][d].data=this[i][d].data.concat(e[d].data),this[i][d].hash_id=t):this[i][d].locked=!0)}},wdi_front.updateUsersIfNecessary=function(o){for(var n=o.feed_users,e=!1,i=0;i<n.length;i++)"#"!=n[i].username.substr(0,1)?""!=n[i].id&&"username"!=n[i].id||(e=!0,o.instagram.searchForUsersByName(n[i].username,{success:function(e){if(void 0!==e.meta&&void 0!==e.meta.error_type&&wdi_front.show_alert(!1,e,o),200==e.meta.code&&0<e.data.length){for(var i=!1,d=0;d<e.data.length;d++)if(e.data[d].username==e.args.username){i=!0;break}if(i)for(var r=0;r<n.length;r++)e.data[d].username==n[r].username&&(n[r].id=e.data[d].id)}for(var t=!1,a=0;a<n.length;a++)if(""==n[a].id||"username"==n[a].id){t=!0;break}t||(o.feed_row.feed_users=JSON.stringify(n),wdi_front.init(o))},username:n[i].username})):n[i].id=n[i].username;return e},void 0!==wdi_ajax.ajax_response?jQuery(document).one("ajaxStop",function(){"not_declared"!=wdi_front.type&&(wdi_front.clickOrTouch=wdi_front.detectEvent(),wdi_front.globalInit())}):jQuery(document).ready(function(){"not_declared"!=wdi_front.type&&(wdi_front.clickOrTouch=wdi_front.detectEvent(),wdi_front.globalInit())}),jQuery(document).ready(function(){setTimeout(function(){"1"===wdi_front_messages.show_alerts&&"I"!==jQuery(".wdi_check_fontawesome .tenweb-i-instagram").prop("tagName")&&console.log("Font Awesome is not loaded properly. Please ask for support https://wordpress.org/support/plugin/wd-instagram-feed/")},2e3)});
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: custom instagram feed, feed, instagram, hashtag, Instagram feed, instagram
4
  Requires at least: 3.9
5
  Requires PHP: 5.2
6
  Tested up to: 5.8
7
- Stable tag: 1.4.22
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -505,6 +505,13 @@ Please make sure you don't have any important information before you proceed.
505
  10Web Social Photo Feed for Instagram plugin uses Instagram API on website front end. You have to authorize the plugin via sign in to get data from Instagram on your behalf. The plugin does not send any user’s data to Instagram. All the data received from Instagram via API is cached in WordPress database for some short customizable period to provide front end optimization. You can delete or update cached data. Instagram saves some cookies in browsers of website visitors via API data. These cookies are mostly used for security purposes. They are regulated under terms of Instagram’s privacy policy https://instagram.com/legal/privacy. The plugin asks for your consent to collect site administrator’s email address and site URL to offer customer support, deals and discounts on premium products and more.
506
 
507
  == Changelog ==
 
 
 
 
 
 
 
508
  = 1.4.22 =
509
  Fixed: XSS vulnerabilities on settings page.
510
  Fixed: Disable pagination during page load.
4
  Requires at least: 3.9
5
  Requires PHP: 5.2
6
  Tested up to: 5.8
7
+ Stable tag: 1.4.23
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
505
  10Web Social Photo Feed for Instagram plugin uses Instagram API on website front end. You have to authorize the plugin via sign in to get data from Instagram on your behalf. The plugin does not send any user’s data to Instagram. All the data received from Instagram via API is cached in WordPress database for some short customizable period to provide front end optimization. You can delete or update cached data. Instagram saves some cookies in browsers of website visitors via API data. These cookies are mostly used for security purposes. They are regulated under terms of Instagram’s privacy policy https://instagram.com/legal/privacy. The plugin asks for your consent to collect site administrator’s email address and site URL to offer customer support, deals and discounts on premium products and more.
506
 
507
  == Changelog ==
508
+ = 1.4.23 =
509
+ Improved: Cache logic.
510
+ Fixed: Share to Twitter.
511
+ Fixed: XSS vulnerabilities on widget title.
512
+ Fixed: Pagination.
513
+ Fixed: Show error message if "hashtag" is not found.
514
+
515
  = 1.4.22 =
516
  Fixed: XSS vulnerabilities on settings page.
517
  Fixed: Disable pagination during page load.
wd-instagram-feed.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: 10Web Social Photo Feed
4
  * Plugin URI: https://10web.io/plugins/wordpress-instagram-feed/?utm_source=instagram_feed&utm_medium=free_plugin
5
  * Description: 10Web Social Photo Feed is a user-friendly tool for displaying user or hashtag-based feeds on your website. You can create feeds with one of the available layouts. It allows displaying image metadata, open up images in lightbox, download them and even share in social networking websites.
6
- * Version: 1.4.22
7
  * Author: 10Web
8
  * Author URI: https://10Web.io/plugins/?utm_source=instagram_feed&utm_medium=free_plugin
9
  * License: GPLv2 or later
@@ -311,27 +311,21 @@ function wdi_privacy_policy() {
311
  );
312
  }
313
 
314
- /* Add new interval option */
315
- add_filter( 'cron_schedules', 'wdi_add_cron_interval' );
316
- function wdi_add_cron_interval( $schedules ) {
317
- $wdi_options = wdi_get_options();
318
- $schedules['wdi_interval'] = array(
319
- 'interval' => intval($wdi_options["wdi_transient_time"])*60, // time in seconds
320
- );
321
- return $schedules;
322
- }
323
-
324
- if ( ! wp_next_scheduled ( 'wdi_cache_cron' ) ) {
325
- wp_schedule_event( time(), 'wdi_interval', 'wdi_cache_cron' );
326
- }
327
-
328
- add_action( 'wdi_cache_cron', 'wdi_run_cache_cron' );
329
  function wdi_run_cache_cron() {
330
- require_once(WDI_DIR . '/framework/WDILibrary.php');
331
- WDILibrary::refresh_instagram_access_token();
332
- require_once ("framework/WDICache.php");
333
- $WDICache = new WDICache();
334
- $WDICache->reset_cache();
 
 
 
 
 
 
 
 
335
  }
336
 
337
  add_filter('wdi_sanitize_options', 'wdi_create_sample_feed');
3
  * Plugin Name: 10Web Social Photo Feed
4
  * Plugin URI: https://10web.io/plugins/wordpress-instagram-feed/?utm_source=instagram_feed&utm_medium=free_plugin
5
  * Description: 10Web Social Photo Feed is a user-friendly tool for displaying user or hashtag-based feeds on your website. You can create feeds with one of the available layouts. It allows displaying image metadata, open up images in lightbox, download them and even share in social networking websites.
6
+ * Version: 1.4.23
7
  * Author: 10Web
8
  * Author URI: https://10Web.io/plugins/?utm_source=instagram_feed&utm_medium=free_plugin
9
  * License: GPLv2 or later
311
  );
312
  }
313
 
314
+ add_action( 'init', 'wdi_run_cache_cron' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  function wdi_run_cache_cron() {
316
+ $cache_time = get_option('wdi_current_cache_time');
317
+ $now_time = current_time('timestamp',1);
318
+ $wdi_options = get_option("wdi_instagram_options");
319
+ $interval = intval($wdi_options["wdi_transient_time"])*60;
320
+ $next_run_time = intval( $cache_time + $interval );
321
+ if ( $cache_time === false || $next_run_time <= $now_time ) {
322
+ update_option('wdi_current_cache_time', $now_time, 1);
323
+ require_once(WDI_DIR . '/framework/WDILibrary.php');
324
+ WDILibrary::refresh_instagram_access_token();
325
+ require_once("framework/WDICache.php");
326
+ $WDICache = new WDICache();
327
+ $WDICache->reset_cache();
328
+ }
329
  }
330
 
331
  add_filter('wdi_sanitize_options', 'wdi_create_sample_feed');