WD Instagram Feed – Instagram Gallery - Version 1.4.21

Version Description

Fixed: Connecting to the Business account.

Download this release

Release Info

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

Code changes from version 1.4.20 to 1.4.21

admin/models/feeds.php CHANGED
@@ -116,7 +116,7 @@ class Feeds_model_wdi {
116
  'popup_enable_info' => '1',
117
  'popup_info_always_show' => '0',
118
  'popup_info_full_width' => '0',
119
- 'popup_enable_comment' => '1', // @ToDo API Changes 2020 (change to 0)
120
  'popup_enable_fullsize_image' => '1',
121
  'popup_enable_download' => '0',
122
  'popup_enable_share_buttons' => '1',
116
  'popup_enable_info' => '1',
117
  'popup_info_always_show' => '0',
118
  'popup_info_full_width' => '0',
119
+ 'popup_enable_comment' => '1', // @ToDo API v10.0 In the case of 'Personal' need to 0
120
  'popup_enable_fullsize_image' => '1',
121
  'popup_enable_download' => '0',
122
  'popup_enable_share_buttons' => '1',
admin/views/feeds.php CHANGED
@@ -242,7 +242,7 @@ class Feeds_view_wdi {
242
  }
243
  }
244
 
245
- public function getFormElements($current_id = ''){
246
  global $wdi_options;
247
  if ( !empty($wdi_options['wdi_authenticated_users_list']) ) {
248
  $authenticated_users_list = json_decode($wdi_options['wdi_authenticated_users_list'], TRUE);
@@ -514,7 +514,21 @@ class Feeds_view_wdi {
514
  'popup_enable_info' => array('name' => 'popup_enable_info', 'title' => __('Enable Caption Control', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => 'Yes', '0' => 'No'), 'tooltip' => '', 'attr' => array(array('name' => 'tab', 'value' => 'lightbox_settings'))),
515
  'popup_enable_fullscreen' => array('name' => 'popup_enable_fullscreen', 'title' => __('Show Fullscreen Control Button', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => __('Yes', 'wd-instagram-feed'), '0' => __('No', 'wd-instagram-feed')), 'tooltip' => '', 'attr' => array(array('name' => 'tab', 'value' => 'lightbox_settings'))),
516
  /* @ToDo API Changes 2020*/
517
- 'popup_enable_comment' => array('name' => 'popup_enable_comment', 'title' => __('Enable Comments Control', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => __('Yes', 'wd-instagram-feed'), '0' => __('No', 'wd-instagram-feed')), 'tooltip' => '', 'attr' => array( array('name' => 'tab', 'value' => 'lightbox_settings'))),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
  'popup_enable_fullsize_image' => array('name' => 'popup_enable_fullsize_image', 'title' => __('Add Link to Instagram Post', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => __('Yes', 'wd-instagram-feed'), '0' => __('No', 'wd-instagram-feed')), 'tooltip' => '', 'attr' => array(array('name' => 'tab', 'value' => 'lightbox_settings'))),
519
  'popup_enable_download' => array('name' => 'popup_enable_download', 'title' => __('Enable Download Button', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => __('Yes', 'wd-instagram-feed'), '0' => __('No', 'wd-instagram-feed')), 'tooltip' => '', 'attr' => array(array('name' => 'tab', 'value' => 'lightbox_settings'))),
520
  'popup_enable_share_buttons' => array('name' => 'popup_enable_share_buttons', 'title' => __('Show Share Buttons', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => __('Yes', 'wd-instagram-feed'), '0' => __('No', 'wd-instagram-feed')), 'tooltip' => '', 'attr' => array(array('name' => 'tab', 'value' => 'lightbox_settings'))),
242
  }
243
  }
244
 
245
+ public function getFormElements( $current_id = '' ) {
246
  global $wdi_options;
247
  if ( !empty($wdi_options['wdi_authenticated_users_list']) ) {
248
  $authenticated_users_list = json_decode($wdi_options['wdi_authenticated_users_list'], TRUE);
514
  'popup_enable_info' => array('name' => 'popup_enable_info', 'title' => __('Enable Caption Control', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => 'Yes', '0' => 'No'), 'tooltip' => '', 'attr' => array(array('name' => 'tab', 'value' => 'lightbox_settings'))),
515
  'popup_enable_fullscreen' => array('name' => 'popup_enable_fullscreen', 'title' => __('Show Fullscreen Control Button', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => __('Yes', 'wd-instagram-feed'), '0' => __('No', 'wd-instagram-feed')), 'tooltip' => '', 'attr' => array(array('name' => 'tab', 'value' => 'lightbox_settings'))),
516
  /* @ToDo API Changes 2020*/
517
+ 'popup_enable_comment' => array(
518
+ 'name' => 'popup_enable_comment',
519
+ 'title' => __('Enable Comments Control', 'wd-instagram-feed'),
520
+ 'type' => 'radio',
521
+ 'valid_options' => array(
522
+ '1' => __('Yes', 'wd-instagram-feed'),
523
+ '0' => __('No', 'wd-instagram-feed')
524
+ ),
525
+ 'tooltip' => '',
526
+ 'attr' => array(
527
+ array(
528
+ 'name' => 'tab',
529
+ 'value' => 'lightbox_settings')
530
+ )
531
+ ),
532
  'popup_enable_fullsize_image' => array('name' => 'popup_enable_fullsize_image', 'title' => __('Add Link to Instagram Post', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => __('Yes', 'wd-instagram-feed'), '0' => __('No', 'wd-instagram-feed')), 'tooltip' => '', 'attr' => array(array('name' => 'tab', 'value' => 'lightbox_settings'))),
533
  'popup_enable_download' => array('name' => 'popup_enable_download', 'title' => __('Enable Download Button', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => __('Yes', 'wd-instagram-feed'), '0' => __('No', 'wd-instagram-feed')), 'tooltip' => '', 'attr' => array(array('name' => 'tab', 'value' => 'lightbox_settings'))),
534
  'popup_enable_share_buttons' => array('name' => 'popup_enable_share_buttons', 'title' => __('Show Share Buttons', 'wd-instagram-feed'), 'type' => 'radio', 'valid_options' => array('1' => __('Yes', 'wd-instagram-feed'), '0' => __('No', 'wd-instagram-feed')), 'tooltip' => '', 'attr' => array(array('name' => 'tab', 'value' => 'lightbox_settings'))),
config.php CHANGED
@@ -3,7 +3,7 @@ if ( !defined('ABSPATH') ) {
3
  exit;
4
  }
5
 
6
- define('WDI_VERSION', '1.4.20');
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.21');
7
  define('WDI_IS_FREE', TRUE);
8
  define('WDI_PREFIX', 'wdi');
9
  define('WDI_DIR', WP_PLUGIN_DIR . "/" . plugin_basename(dirname(__FILE__)));
css/wdi_frontend.css CHANGED
@@ -430,6 +430,7 @@ div[id^="wdi_container"] p {
430
  .wdi_layout_th .wdi_feed_container {
431
  min-width: 160px;
432
  margin: 0 auto;
 
433
  }
434
 
435
  .wdi_layout_th .wdi_feed_wrapper {
430
  .wdi_layout_th .wdi_feed_container {
431
  min-width: 160px;
432
  margin: 0 auto;
433
+
434
  }
435
 
436
  .wdi_layout_th .wdi_feed_wrapper {
framework/WDIInstagram.php CHANGED
@@ -416,7 +416,6 @@ class WDIInstagram {
416
  );
417
  }
418
  array_push($carousel_media, $child_media);
419
-
420
  }
421
  }
422
  }
416
  );
417
  }
418
  array_push($carousel_media, $child_media);
 
419
  }
420
  }
421
  }
framework/WDILibrary.php CHANGED
@@ -228,7 +228,7 @@ class WDILibrary {
228
  break;
229
  }
230
  case 26: {
231
- $message = __('Could not get Instagram business pages. Either do not have any Facebook page or your token does not have manage_pages permission. Try to remove \'10Web Hashtag Feed Plugin\' app and reconnect it.', 'wd-instagram-feed');
232
  $type = 'error';
233
  break;
234
  }
@@ -1140,7 +1140,7 @@ class WDILibrary {
1140
  'basic_app_id' => '734781953985462',
1141
  'graph_authorize_url' => 'https://www.facebook.com/dialog/oauth/',
1142
  'basic_authorize_url' => 'https://api.instagram.com/oauth/authorize/',
1143
- 'graph_scope' => 'instagram_basic',
1144
  'basic_scope' => 'user_profile,user_media',
1145
  'basic_response_type' => 'code',
1146
 
228
  break;
229
  }
230
  case 26: {
231
+ $message = __('No business pages were selected. Please uninstall the \'10Web Hashtag Feed\' app from \'Facebook > Settings > Security and login > Business integrations or Apps and websites\' section and reinstall. Then choose the business page/s and re-connect.', 'wd-instagram-feed');
232
  $type = 'error';
233
  break;
234
  }
1140
  'basic_app_id' => '734781953985462',
1141
  'graph_authorize_url' => 'https://www.facebook.com/dialog/oauth/',
1142
  'basic_authorize_url' => 'https://api.instagram.com/oauth/authorize/',
1143
+ 'graph_scope' => 'instagram_basic,pages_show_list,pages_read_engagement',
1144
  'basic_scope' => 'user_profile,user_media',
1145
  'basic_response_type' => 'code',
1146
 
frontend/controllers/WDIControllerGalleryBox.php CHANGED
@@ -21,7 +21,6 @@ class WDIControllerGalleryBox {
21
 
22
  require_once WDI_DIR . "/frontend/views/WDIViewGalleryBox.php";
23
  $view = new WDIViewGalleryBox($model);
24
-
25
  $view->display();
26
  }
27
  }
21
 
22
  require_once WDI_DIR . "/frontend/views/WDIViewGalleryBox.php";
23
  $view = new WDIViewGalleryBox($model);
 
24
  $view->display();
25
  }
26
  }
frontend/views/WDIViewGalleryBox.php CHANGED
@@ -9,19 +9,40 @@ class WDIViewGalleryBox {
9
  }
10
 
11
  public function display() {
12
- global $WD_WDI_UPLOAD_DIR;
13
  global $wp;
 
 
 
 
14
  require_once(WDI_DIR . '/framework/WDILibraryEmbed.php');
15
 
16
- //////////////////////////////////////////////////////////////////
17
  $feed_id = WDILibrary::get('feed_id', 0, 'intval', 'POST');
18
  $current_feed = $this->model->get_feed_row_data( $feed_id );
19
- $is_hashtag = false;
20
- if(isset($current_feed["feed_users"]) && !empty($current_feed["feed_users"])){
21
- foreach (json_decode($current_feed['feed_users']) as $user) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  $first_char = mb_substr($user->id, 0, 1);
23
- if($first_char === "#"){
24
- $is_hashtag = true;
25
  }
26
  }
27
  }
@@ -75,7 +96,6 @@ class WDIViewGalleryBox {
75
  $image_filmstrip_height = 0;
76
  $image_filmstrip_width = 0;
77
  }
78
-
79
  $slideshow_interval = (isset($current_feed['popup_interval']) ? (int) $current_feed['popup_interval'] : 5);
80
  $enable_image_ctrl_btn = (isset($current_feed['popup_enable_ctrl_btn']) ? esc_html($current_feed['popup_enable_ctrl_btn']) : 0);
81
  $enable_comment_social = (isset($current_feed['popup_enable_comment']) ? esc_html($current_feed['popup_enable_comment']) : 0);
@@ -325,7 +345,6 @@ class WDIViewGalleryBox {
325
  ?>
326
 
327
  </script>
328
-
329
  <?php
330
  if (!$image_id_exist) {
331
  echo WDILibrary::message(__('The image has been deleted.', "wd-instagram-feed"), 'error');
@@ -351,65 +370,68 @@ class WDIViewGalleryBox {
351
  $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;
352
  ?>
353
  <div class="wdi_ctrl_btn_container">
354
- <?php
355
  if ($option_row->show_image_counts) {
356
  ?>
357
- <span class="wdi_image_count_container wdi_ctrl_btn">
358
- <span class="wdi_image_count"><?php echo $current_image_key + 1; ?></span> /
359
- <span><?php echo $image_rows_count; ?></span>
360
- </span>
361
  <?php
362
  }
363
- ?>
364
  <i title="<?php echo __('Play', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_play_pause tenweb-i tenweb-i-play"></i>
365
- <?php if ($enable_image_fullscreen) {
366
- if (!$open_with_fullscreen) {
367
- ?>
368
- <i title="<?php echo __('Maximize', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_resize-full tenweb-i tenweb-i-expand "></i>
369
  <?php
370
- }
371
- ?>
372
- <i title="<?php echo __('Fullscreen', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_fullscreen tenweb-i tenweb-i-arrows-out"></i>
373
- <?php } if ($popup_enable_info) { ?>
374
- <i title="<?php echo __('Show Caption', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_info tenweb-i tenweb-i-info-circle"></i>
 
 
 
 
 
 
 
 
375
  <?php }
376
- // @TօDօ API Changes 2020
377
- if ( $enable_comment_social && !$is_hashtag ) { ?>
378
- <i title="<?php echo __('Show comments', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_comment tenweb-i tenweb-i-comment-square"></i>
379
- <?php } if ($popup_enable_rate) { ?>
380
- <i title="<?php echo __('Show rating', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_rate tenweb-i tenweb-i-star"></i>
381
  <?php }
382
  $is_embed = preg_match('/EMBED/', $current_filetype) == 1 ? TRUE : FALSE;
383
  $share_image_url = urlencode( $is_embed ? $current_thumb_url : site_url() . '/' . $WD_WDI_UPLOAD_DIR . $current_image_url);
384
  if ($enable_image_facebook) {
385
  ?>
386
- <a id="wdi_facebook_a" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($share_url); ?>" target="_blank" title="<?php echo __('Share on Facebook', "wd-instagram-feed"); ?>">
387
- <i title="<?php echo __('Share on Facebook', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_facebook tenweb-i tenweb-i-facebook-square"></i>
388
- </a>
389
  <?php
390
  }
391
  if ($enable_image_twitter) {
392
  ?>
393
- <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"); ?>">
394
- <i title="<?php echo __('Share on Twitter', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_twitter tenweb-i tenweb-i-twitter-square"></i>
395
- </a>
396
  <?php
397
  }
398
  if ($enable_image_pinterest) {
399
  ?>
400
- <a id="wdi_pinterest_a" href="http://pinterest.com/pin/create/button/?s=100&url=<?php echo urlencode($share_url); ?>&media=<?php echo $share_image_url; ?>&description=<?php echo $current_image_description; ?>" target="_blank" title="<?php echo __('Share on Pinterest', "wd-instagram-feed"); ?>">
401
- <i title="<?php echo __('Share on Pinterest', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_pinterest tenweb-i tenweb-i-pinterest-square"></i>
402
- </a>
403
  <?php
404
  }
405
  if ($enable_image_tumblr) {
406
  ?>
407
- <a id="wdi_tumblr_a" href="https://www.tumblr.com/share/photo?source=<?php echo $share_image_url; ?>&caption=<?php echo urlencode($current_image_alt); ?>&clickthru=<?php echo urlencode($share_url); ?>" target="_blank" title="<?php echo __('Share on Tumblr', "wd-instagram-feed"); ?>">
408
- <i title="<?php echo __('Share on Tumblr', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_tumblr tenweb-i tenweb-i-tumblr-square"></i>
409
- </a>
410
  <?php
411
  }
412
-
413
  if ($enable_share_buttons) {
414
  ?>
415
  <span class="wdi_share_btns_container">
@@ -422,12 +444,8 @@ class WDIViewGalleryBox {
422
  </p>
423
  <i class="wdi_share_caret " style="display:none;"></i>
424
  </span>
425
-
426
-
427
  <?php
428
  }
429
-
430
-
431
  if ($option_row->popup_enable_fullsize_image) {
432
  ?>
433
  <a id="wdi_fullsize_image" href="<?php echo !$is_embed ? site_url() . '/' . $WD_WDI_UPLOAD_DIR . $current_image_url : $current_image_url; ?>" target="_blank">
@@ -453,8 +471,6 @@ class WDIViewGalleryBox {
453
  if(preg_match('/VIDEO/',$current_filetype) == 1){
454
  $download_href = $current_filename;
455
  }
456
-
457
-
458
  $style = 'inline-block';
459
  }
460
  ?>
@@ -468,13 +484,11 @@ class WDIViewGalleryBox {
468
  <div class="wdi_toggle_container">
469
  <i class="wdi_toggle_btn tenweb-i <?php echo (($theme_row->lightbox_ctrl_btn_pos == 'top') ? 'tenweb-i-angle-up' : 'tenweb-i-angle-down'); ?>"></i>
470
  </div>
471
-
472
  <?php } ?>
473
  </div>
474
  <?php
475
  }
476
- $current_pos = 0;
477
-
478
  if($enable_image_filmstrip) {
479
  $current_pos = $current_image_index * (($filmstrip_direction == 'horizontal' ? $image_filmstrip_width : $image_filmstrip_height) + $filmstrip_thumb_margin_hor);
480
  $current_key = $current_image_index;
@@ -501,7 +515,6 @@ class WDIViewGalleryBox {
501
  </span>
502
  </div>
503
  </div>
504
-
505
  <div class="wdi_slide_container">
506
  <div class="wdi_slide_bg">
507
  <div class="wdi_slider">
@@ -1699,7 +1712,7 @@ class WDIViewGalleryBox {
1699
  jQuery(".wdi_popup_image").removeAttr("width");
1700
  jQuery(".wdi_popup_image").removeAttr("height");
1701
 
1702
- //if info is displayed by defult then double trigger
1703
  //info click for displaying it with proper scrollbar
1704
  if(<?php echo $popup_info_always_show?>){
1705
  setTimeout(function(){
9
  }
10
 
11
  public function display() {
 
12
  global $wp;
13
+ global $wdi_options;
14
+ global $WD_WDI_UPLOAD_DIR;
15
+ $wdi_options = get_option(WDI_OPT);
16
+
17
  require_once(WDI_DIR . '/framework/WDILibraryEmbed.php');
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) ) {
24
+ foreach ( $feed_users as $user ) {
25
+ if ( empty($user['tag_id']) ) {
26
+ $current_feed['username'] = $user['username'];
27
+ break;
28
+ }
29
+ }
30
+ }
31
+ }
32
+ if ( !empty($wdi_options['wdi_authenticated_users_list']) ) {
33
+ $authenticated_users = json_decode($wdi_options['wdi_authenticated_users_list'], TRUE);
34
+ if ( !empty($authenticated_users[$current_feed['username']]) ) {
35
+ $ig_user = $authenticated_users[$current_feed['username']];
36
+ $user_feed_header_args['user'] = $ig_user;
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
  }
96
  $image_filmstrip_height = 0;
97
  $image_filmstrip_width = 0;
98
  }
 
99
  $slideshow_interval = (isset($current_feed['popup_interval']) ? (int) $current_feed['popup_interval'] : 5);
100
  $enable_image_ctrl_btn = (isset($current_feed['popup_enable_ctrl_btn']) ? esc_html($current_feed['popup_enable_ctrl_btn']) : 0);
101
  $enable_comment_social = (isset($current_feed['popup_enable_comment']) ? esc_html($current_feed['popup_enable_comment']) : 0);
345
  ?>
346
 
347
  </script>
 
348
  <?php
349
  if (!$image_id_exist) {
350
  echo WDILibrary::message(__('The image has been deleted.', "wd-instagram-feed"), 'error');
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
374
  if ($option_row->show_image_counts) {
375
  ?>
376
+ <span class="wdi_image_count_container wdi_ctrl_btn">
377
+ <span class="wdi_image_count"><?php echo $current_image_key + 1; ?></span> /
378
+ <span><?php echo $image_rows_count; ?></span>
379
+ </span>
380
  <?php
381
  }
382
+ ?>
383
  <i title="<?php echo __('Play', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_play_pause tenweb-i tenweb-i-play"></i>
 
 
 
 
384
  <?php
385
+ if ($enable_image_fullscreen) {
386
+ if (!$open_with_fullscreen) {
387
+ ?>
388
+ <i title="<?php echo __('Maximize', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_resize-full tenweb-i tenweb-i-expand "></i>
389
+ <?php
390
+ }
391
+ ?>
392
+ <i title="<?php echo __('Fullscreen', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_fullscreen tenweb-i tenweb-i-arrows-out"></i>
393
+ <?php
394
+ }
395
+ if ($popup_enable_info) {
396
+ ?>
397
+ <i title="<?php echo __('Show Caption', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_info tenweb-i tenweb-i-info-circle"></i>
398
  <?php }
399
+ if ( $enable_comment_social && $business && !$is_hashtag ) { ?>
400
+ <i title="<?php echo __('Show comments', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_comment tenweb-i tenweb-i-comment-square"></i>
401
+ <?php }
402
+ if ($popup_enable_rate) { ?>
403
+ <i title="<?php echo __('Show rating', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_rate tenweb-i tenweb-i-star"></i>
404
  <?php }
405
  $is_embed = preg_match('/EMBED/', $current_filetype) == 1 ? TRUE : FALSE;
406
  $share_image_url = urlencode( $is_embed ? $current_thumb_url : site_url() . '/' . $WD_WDI_UPLOAD_DIR . $current_image_url);
407
  if ($enable_image_facebook) {
408
  ?>
409
+ <a id="wdi_facebook_a" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($share_url); ?>" target="_blank" title="<?php echo __('Share on Facebook', "wd-instagram-feed"); ?>">
410
+ <i title="<?php echo __('Share on Facebook', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_facebook tenweb-i tenweb-i-facebook-square"></i>
411
+ </a>
412
  <?php
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
420
  }
421
  if ($enable_image_pinterest) {
422
  ?>
423
+ <a id="wdi_pinterest_a" href="http://pinterest.com/pin/create/button/?s=100&url=<?php echo urlencode($share_url); ?>&media=<?php echo $share_image_url; ?>&description=<?php echo $current_image_description; ?>" target="_blank" title="<?php echo __('Share on Pinterest', "wd-instagram-feed"); ?>">
424
+ <i title="<?php echo __('Share on Pinterest', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_pinterest tenweb-i tenweb-i-pinterest-square"></i>
425
+ </a>
426
  <?php
427
  }
428
  if ($enable_image_tumblr) {
429
  ?>
430
+ <a id="wdi_tumblr_a" href="https://www.tumblr.com/share/photo?source=<?php echo $share_image_url; ?>&caption=<?php echo urlencode($current_image_alt); ?>&clickthru=<?php echo urlencode($share_url); ?>" target="_blank" title="<?php echo __('Share on Tumblr', "wd-instagram-feed"); ?>">
431
+ <i title="<?php echo __('Share on Tumblr', "wd-instagram-feed"); ?>" class="wdi_ctrl_btn wdi_tumblr tenweb-i tenweb-i-tumblr-square"></i>
432
+ </a>
433
  <?php
434
  }
 
435
  if ($enable_share_buttons) {
436
  ?>
437
  <span class="wdi_share_btns_container">
444
  </p>
445
  <i class="wdi_share_caret " style="display:none;"></i>
446
  </span>
 
 
447
  <?php
448
  }
 
 
449
  if ($option_row->popup_enable_fullsize_image) {
450
  ?>
451
  <a id="wdi_fullsize_image" href="<?php echo !$is_embed ? site_url() . '/' . $WD_WDI_UPLOAD_DIR . $current_image_url : $current_image_url; ?>" target="_blank">
471
  if(preg_match('/VIDEO/',$current_filetype) == 1){
472
  $download_href = $current_filename;
473
  }
 
 
474
  $style = 'inline-block';
475
  }
476
  ?>
484
  <div class="wdi_toggle_container">
485
  <i class="wdi_toggle_btn tenweb-i <?php echo (($theme_row->lightbox_ctrl_btn_pos == 'top') ? 'tenweb-i-angle-up' : 'tenweb-i-angle-down'); ?>"></i>
486
  </div>
 
487
  <?php } ?>
488
  </div>
489
  <?php
490
  }
491
+ $current_pos = 0;
 
492
  if($enable_image_filmstrip) {
493
  $current_pos = $current_image_index * (($filmstrip_direction == 'horizontal' ? $image_filmstrip_width : $image_filmstrip_height) + $filmstrip_thumb_margin_hor);
494
  $current_key = $current_image_index;
515
  </span>
516
  </div>
517
  </div>
 
518
  <div class="wdi_slide_container">
519
  <div class="wdi_slide_bg">
520
  <div class="wdi_slider">
1712
  jQuery(".wdi_popup_image").removeAttr("width");
1713
  jQuery(".wdi_popup_image").removeAttr("height");
1714
 
1715
+ //if info is displayed by defult then double trigger
1716
  //info click for displaying it with proper scrollbar
1717
  if(<?php echo $popup_info_always_show?>){
1718
  setTimeout(function(){
js/wdi_admin.js CHANGED
@@ -325,65 +325,69 @@ wdi_controller.displayTypeMemory = {};
325
  /*
326
  * Switches between feeds admin page tabs
327
  */
328
- wdi_controller.switchFeedTabs = function(tabname, section) {
329
-
330
  //add tabname in hidden field
331
  jQuery('#wdi_refresh_tab').attr('value', tabname);
332
-
333
  //hiding options of other tabs
334
  jQuery('.wdi_tab').hide();
335
  jQuery('#' + tabname + '_tab').show();
336
-
 
 
 
 
 
337
  //hiding all display_type elements
338
  jQuery('.display_type').css('display', 'none');
339
  //showing only requested display_type tab elements
340
  jQuery('.display_type[tab="' + tabname + '"]').css('display', 'block');
341
-
342
- if(!jQuery('.display_type[tab="' + tabname + '"]').length){
343
  jQuery('.display_type_content').hide();
344
- } else {
 
345
  jQuery('.display_type_content').show();
346
  }
347
-
348
- //swap active tab class
349
- jQuery('.wdi_feed_tabs').filter('.wdi_feed_tab_active').each(function() {
350
  jQuery(this).removeClass('wdi_feed_tab_active');
351
  });
 
352
  jQuery('#wdi_' + tabname).addClass('wdi_feed_tab_active');
353
  var selectedSection = jQuery();
354
  var sectionSelectedFLag = false;
355
- if (section != undefined && section != '') {
356
  //check value which came from backend
357
  selectedSection = jQuery('.display_type #' + section).prop('checked', true);
358
  jQuery('#wdi_feed_type').attr('value', section);
359
  //sectionSelectedFLag = true;
360
  }
 
361
  //find the selected feed_type option
362
- if (!sectionSelectedFLag) {
363
  selectedSection = jQuery('.display_type[tab="' + tabname + '"] input[name="feed_type"]:checked');
364
- if (selectedSection.length != 0) {
365
  sectionSelectedFLag = true;
366
  }
367
  }
 
368
  //if there are no selected feed_type option then set default option
369
- if (!sectionSelectedFLag) {
370
  //make default section as selected
371
  selectedSection = jQuery('.display_type[tab="' + tabname + '"] #thumbnails');
372
- if (selectedSection.length != 0) {
373
  sectionSelectedFLag = true;
374
  selectedSection.prop('checked', true);
375
  jQuery('#wdi_feed_type').attr('value', 'thumbnails');
376
- };
377
-
378
  }
379
  //if under currect tab we have feed_type section then show it
380
- if (sectionSelectedFLag) {
381
  wdi_controller.displaySettingsSection(selectedSection);
382
  }
383
 
384
  // @ToDo free There is a difference in free!
385
  // if tabname is conditional filters then call tab interface updater
386
- if (tabname == 'conditional_filters') {
387
  wdi_controller.updateConditionalFiltersUi();
388
  }
389
  }
@@ -497,7 +501,6 @@ wdi_controller.bindSaveFeedEvent = function() {
497
  * @param {String} task [this is self explanatory]
498
  */
499
  wdi_controller.save_feed = function ( task ) {
500
-
501
  var feed_users = [],
502
  id,
503
  type,
@@ -555,7 +558,7 @@ wdi_controller.save_feed = function ( task ) {
555
  jQuery('#wdi_current_id').val(id);
556
  }
557
  jQuery('#task').attr('value', task);
558
- submit_ajax();
559
  }
560
 
561
  var comlete_redirect_url = '';
@@ -592,7 +595,6 @@ function submit_ajax() {
592
  });
593
  }
594
 
595
-
596
  /**
597
  * Takes user input as argument and makes an
598
  * instagram request for getting meta info such as username and user id
325
  /*
326
  * Switches between feeds admin page tabs
327
  */
328
+ wdi_controller.switchFeedTabs = function ( tabname, section ) {
 
329
  //add tabname in hidden field
330
  jQuery('#wdi_refresh_tab').attr('value', tabname);
 
331
  //hiding options of other tabs
332
  jQuery('.wdi_tab').hide();
333
  jQuery('#' + tabname + '_tab').show();
334
+ jQuery('.wdi_element_name_popup_enable_comment').hide();
335
+ var type = jQuery('#WDI_user_name option:selected').data('type');
336
+ if ( type === 'business' ) {
337
+ jQuery('.wdi_element_name_popup_enable_comment').show();
338
+ }
339
+
340
  //hiding all display_type elements
341
  jQuery('.display_type').css('display', 'none');
342
  //showing only requested display_type tab elements
343
  jQuery('.display_type[tab="' + tabname + '"]').css('display', 'block');
344
+ if ( !jQuery('.display_type[tab="' + tabname + '"]').length ) {
 
345
  jQuery('.display_type_content').hide();
346
+ }
347
+ else {
348
  jQuery('.display_type_content').show();
349
  }
350
+ //swap active tab class
351
+ jQuery('.wdi_feed_tabs').filter('.wdi_feed_tab_active').each(function () {
 
352
  jQuery(this).removeClass('wdi_feed_tab_active');
353
  });
354
+
355
  jQuery('#wdi_' + tabname).addClass('wdi_feed_tab_active');
356
  var selectedSection = jQuery();
357
  var sectionSelectedFLag = false;
358
+ if ( section != undefined && section != '' ) {
359
  //check value which came from backend
360
  selectedSection = jQuery('.display_type #' + section).prop('checked', true);
361
  jQuery('#wdi_feed_type').attr('value', section);
362
  //sectionSelectedFLag = true;
363
  }
364
+
365
  //find the selected feed_type option
366
+ if ( !sectionSelectedFLag ) {
367
  selectedSection = jQuery('.display_type[tab="' + tabname + '"] input[name="feed_type"]:checked');
368
+ if ( selectedSection.length != 0 ) {
369
  sectionSelectedFLag = true;
370
  }
371
  }
372
+
373
  //if there are no selected feed_type option then set default option
374
+ if ( !sectionSelectedFLag ) {
375
  //make default section as selected
376
  selectedSection = jQuery('.display_type[tab="' + tabname + '"] #thumbnails');
377
+ if ( selectedSection.length != 0 ) {
378
  sectionSelectedFLag = true;
379
  selectedSection.prop('checked', true);
380
  jQuery('#wdi_feed_type').attr('value', 'thumbnails');
381
+ }
 
382
  }
383
  //if under currect tab we have feed_type section then show it
384
+ if ( sectionSelectedFLag ) {
385
  wdi_controller.displaySettingsSection(selectedSection);
386
  }
387
 
388
  // @ToDo free There is a difference in free!
389
  // if tabname is conditional filters then call tab interface updater
390
+ if ( tabname == 'conditional_filters' ) {
391
  wdi_controller.updateConditionalFiltersUi();
392
  }
393
  }
501
  * @param {String} task [this is self explanatory]
502
  */
503
  wdi_controller.save_feed = function ( task ) {
 
504
  var feed_users = [],
505
  id,
506
  type,
558
  jQuery('#wdi_current_id').val(id);
559
  }
560
  jQuery('#task').attr('value', task);
561
+ submit_ajax();
562
  }
563
 
564
  var comlete_redirect_url = '';
595
  });
596
  }
597
 
 
598
  /**
599
  * Takes user input as argument and makes an
600
  * instagram request for getting meta info such as username and user id
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(".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({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};
js/wdi_frontend.js CHANGED
@@ -331,7 +331,7 @@ wdi_front.isJsonString = function (str) {
331
  wdi_front.instagramRequest = function (id, currentFeed) {
332
  var _this = this,
333
  feed_users = currentFeed.feed_users;
334
- if (typeof feed_users[id] === 'string' && feed_users[id] === 'self') { // self liked media
335
  currentFeed.instagram.getRecentLikedMedia({
336
  success: function (response) {
337
  if(typeof response.meta!= "undefined" && typeof response.meta.error_type != "undefined"){
@@ -797,7 +797,6 @@ wdi_front.masonryDisplayFeedItems = function (data, currentFeed) {
797
  * Calcuates image resolution
798
  */
799
  wdi_front.getImageResolution = function (data) {
800
-
801
  if ( data.type === 'image' ) {
802
  var originalHeight = data['images']['standard_resolution']['height'];
803
  var originalWidth = data['images']['standard_resolution']['width'];
331
  wdi_front.instagramRequest = function (id, currentFeed) {
332
  var _this = this,
333
  feed_users = currentFeed.feed_users;
334
+ if ( typeof feed_users[id] === 'string' && feed_users[id] === 'self' ) { // self liked media
335
  currentFeed.instagram.getRecentLikedMedia({
336
  success: function (response) {
337
  if(typeof response.meta!= "undefined" && typeof response.meta.error_type != "undefined"){
797
  * Calcuates image resolution
798
  */
799
  wdi_front.getImageResolution = function (data) {
 
800
  if ( data.type === 'image' ) {
801
  var originalHeight = data['images']['standard_resolution']['height'];
802
  var originalWidth = data['images']['standard_resolution']['width'];
js/wdi_instagram.js CHANGED
@@ -1026,8 +1026,8 @@ function WDIInstagram(args) {
1026
  *
1027
  */
1028
  this.set_cache_data = function ( comlete_redirect_url , user_name, feed_id, next_url, iter, frontend, tagname, tag_id, endpoint, args ) {
1029
- /* Check if call is frontend 0-backend, 1-frontend */
1030
- if( frontend === 0 ) {
1031
  if (user_name === '') {
1032
  user_name = jQuery("#WDI_user_name").val();
1033
  }
1026
  *
1027
  */
1028
  this.set_cache_data = function ( comlete_redirect_url , user_name, feed_id, next_url, iter, frontend, tagname, tag_id, endpoint, args ) {
1029
+ /* Check if call is frontend 0-backend, 1-frontend */
1030
+ if ( frontend === 0 ) {
1031
  if (user_name === '') {
1032
  user_name = jQuery("#WDI_user_name").val();
1033
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: webdorado,10web,progmastery
3
  Tags: custom instagram feed, feed, instagram, hashtag, Instagram feed, instagram gallery, instagram posts, Instagram images, Instagram photos, lightbox, photos,instagram account
4
  Requires at least: 3.9
5
  Requires PHP: 5.2
6
- Tested up to: 5.7
7
- Stable tag: 1.4.20
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -505,6 +505,9 @@ 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.20 =
509
  Fixed: Cache logic.
510
 
3
  Tags: custom instagram feed, feed, instagram, hashtag, Instagram feed, instagram gallery, instagram posts, Instagram images, Instagram photos, lightbox, photos,instagram account
4
  Requires at least: 3.9
5
  Requires PHP: 5.2
6
+ Tested up to: 5.8
7
+ Stable tag: 1.4.21
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.21 =
509
+ Fixed: Connecting to the Business account.
510
+
511
  = 1.4.20 =
512
  Fixed: Cache logic.
513
 
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.20
7
  * Author: 10Web
8
  * Author URI: https://10Web.io/plugins/?utm_source=instagram_feed&utm_medium=free_plugin
9
  * License: GPLv2 or later
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.21
7
  * Author: 10Web
8
  * Author URI: https://10Web.io/plugins/?utm_source=instagram_feed&utm_medium=free_plugin
9
  * License: GPLv2 or later