WD Instagram Feed – Instagram Gallery - Version 1.3.14

Version Description

New: Added contributor role in the option 'Minimal role to add and manage Feeds or Themes'.
Fixed: Conditional filters for hashtags.

Download this release

Release Info

Developer webdorado
Plugin Icon 128x128 WD Instagram Feed – Instagram Gallery
Version 1.3.14
Comparing to
See all releases

Code changes from version 1.3.13 to 1.3.14

admin-functions.php CHANGED
@@ -678,7 +678,7 @@ function wdi_get_settings(){
678
  'wdi_transient_time' => array('name'=>'wdi_transient_time','sanitize_type'=>'number','field_or_not'=>'','type'=>'input', 'input_type'=>'number', 'section'=>'wdi_customize_section', 'title'=>__('Check for new posts every (min)',"wd-instagram-feed"),'default'=>'' ,'value'=>60),
679
  'wdi_reset_cache' => array('name'=>'wdi_reset_cache','sanitize_type'=>'','field_or_not'=>'','type'=>'link_button', 'section'=>'wdi_customize_section', 'href'=>admin_url( 'admin.php?page=wdi_settings' ), 'title'=>__('Reset cache with Instagram data',"wd-instagram-feed"),'default'=>'', 'value'=>'Reset cache'),
680
  'wdi_authenticated_users_list' => array('name' => 'wdi_authenticated_users_list','sanitize_type'=>'users_list','input_size'=>'53','type'=>'users_list','default'=>'[]','field_or_not'=>'field','section'=>'wdi_customize_section','title'=>__('Multiple Instagram accounts ?',"wd-instagram-feed")),
681
- 'wdi_feeds_min_capability' => array('name' => 'wdi_feeds_min_capability', "sanitize_type" => "text", 'title' => __('Minimal role to add and manage Feeds or Themes', "wd-instagram-feed"), 'type' => 'select', 'field_or_not' => 'field', "default" => "manage_options", 'section' => 'wdi_customize_section', 'valid_options' => array('manage_options' => __('Administrator', 'wd-instagram-feed'), 'publish_posts' => __('Author', 'wd-instagram-feed'))),
682
  'wdi_custom_css' => array('name' => 'wdi_custom_css', 'sanitize_type' => 'css', 'type' => 'textarea', 'section' => 'wdi_customize_section', 'field_or_not' => 'field', 'default' => '', 'title' => __('Custom CSS', "wd-instagram-feed")),
683
  'wdi_custom_js' => array('name' => 'wdi_custom_js', 'sanitize_type' => 'css', 'type' => 'textarea', 'section' => 'wdi_customize_section', 'field_or_not' => 'field', 'default' => '', 'title' => __('Custom JavaScript', "wd-instagram-feed")),
684
  //'wdi_preserve_settings_when_remove'=>array('name'=>'wdi_preserve_settings_when_remove','field_or_not'=>'field','type'=>'checkbox','default'=>'1', 'section'=>'wdi_configure_section','title'=>__('Preserve Settings When Remove',"wd-instagram-feed")),
@@ -757,7 +757,13 @@ function wdi_get_create_feeds_cap()
757
  {
758
  global $wdi_options;
759
  $min_feeds_capability = isset($wdi_options['wdi_feeds_min_capability']) ? $wdi_options['wdi_feeds_min_capability'] : "manage_options";
760
- $min_feeds_capability = $min_feeds_capability == 'publish_posts' ? 'publish_posts' : "manage_options";
 
 
 
 
 
 
761
 
762
  return $min_feeds_capability;
763
  }
678
  'wdi_transient_time' => array('name'=>'wdi_transient_time','sanitize_type'=>'number','field_or_not'=>'','type'=>'input', 'input_type'=>'number', 'section'=>'wdi_customize_section', 'title'=>__('Check for new posts every (min)',"wd-instagram-feed"),'default'=>'' ,'value'=>60),
679
  'wdi_reset_cache' => array('name'=>'wdi_reset_cache','sanitize_type'=>'','field_or_not'=>'','type'=>'link_button', 'section'=>'wdi_customize_section', 'href'=>admin_url( 'admin.php?page=wdi_settings' ), 'title'=>__('Reset cache with Instagram data',"wd-instagram-feed"),'default'=>'', 'value'=>'Reset cache'),
680
  'wdi_authenticated_users_list' => array('name' => 'wdi_authenticated_users_list','sanitize_type'=>'users_list','input_size'=>'53','type'=>'users_list','default'=>'[]','field_or_not'=>'field','section'=>'wdi_customize_section','title'=>__('Multiple Instagram accounts ?',"wd-instagram-feed")),
681
+ 'wdi_feeds_min_capability' => array('name' => 'wdi_feeds_min_capability', "sanitize_type" => "text", 'title' => __('Minimal role to add and manage Feeds or Themes', "wd-instagram-feed"), 'type' => 'select', 'field_or_not' => 'field', "default" => "manage_options", 'section' => 'wdi_customize_section', 'valid_options' => array('manage_options' => __('Administrator', 'wd-instagram-feed'), 'publish_posts' => __('Author', 'wd-instagram-feed'), 'contributor'=>__('Contributor', 'wd-instagram-feed'))),
682
  'wdi_custom_css' => array('name' => 'wdi_custom_css', 'sanitize_type' => 'css', 'type' => 'textarea', 'section' => 'wdi_customize_section', 'field_or_not' => 'field', 'default' => '', 'title' => __('Custom CSS', "wd-instagram-feed")),
683
  'wdi_custom_js' => array('name' => 'wdi_custom_js', 'sanitize_type' => 'css', 'type' => 'textarea', 'section' => 'wdi_customize_section', 'field_or_not' => 'field', 'default' => '', 'title' => __('Custom JavaScript', "wd-instagram-feed")),
684
  //'wdi_preserve_settings_when_remove'=>array('name'=>'wdi_preserve_settings_when_remove','field_or_not'=>'field','type'=>'checkbox','default'=>'1', 'section'=>'wdi_configure_section','title'=>__('Preserve Settings When Remove',"wd-instagram-feed")),
757
  {
758
  global $wdi_options;
759
  $min_feeds_capability = isset($wdi_options['wdi_feeds_min_capability']) ? $wdi_options['wdi_feeds_min_capability'] : "manage_options";
760
+ if( $min_feeds_capability == 'publish_posts' ) {
761
+ $min_feeds_capability = 'publish_posts';
762
+ } else if( $min_feeds_capability == 'contributor' ) {
763
+ $min_feeds_capability = 'contributor';
764
+ } else {
765
+ $min_feeds_capability = 'manage_options';
766
+ }
767
 
768
  return $min_feeds_capability;
769
  }
changelog.txt CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  = 1.3.13 =
2
  New: Option to get hashtag top media
3
  Improved: Notices during Facebook login
1
+ = 1.3.14 =
2
+ New: Added contributor role in the option 'Minimal role to add and manage Feeds or Themes'.
3
+ Fixed: Conditional filters for hashtags.
4
+
5
  = 1.3.13 =
6
  New: Option to get hashtag top media
7
  Improved: Notices during Facebook login
elementor/elementor.php CHANGED
@@ -38,7 +38,7 @@ class WDIElementor {
38
  }
39
 
40
  public function register_widget_category($elements_manager){
41
- $elements_manager->add_category('tenweb-widgets', array(
42
  'title' => __('10WEB', 'tenweb-builder'),
43
  'icon' => 'fa fa-plug',
44
  ));
38
  }
39
 
40
  public function register_widget_category($elements_manager){
41
+ $elements_manager->add_category('tenweb-plugins-widgets', array(
42
  'title' => __('10WEB', 'tenweb-builder'),
43
  'icon' => 'fa fa-plug',
44
  ));
elementor/widget.php CHANGED
@@ -43,7 +43,7 @@ class WDIElementorWidget extends \Elementor\Widget_Base {
43
  * @return array Widget categories.
44
  */
45
  public function get_categories(){
46
- return ['tenweb-widgets'];
47
  }
48
 
49
  /**
43
  * @return array Widget categories.
44
  */
45
  public function get_categories(){
46
+ return ['tenweb-plugins-widgets'];
47
  }
48
 
49
  /**
js/wdi_frontend.js CHANGED
@@ -2357,10 +2357,24 @@ wdi_front.mergeData = function (array1, array2)
2357
  //broken image handling
2358
  wdi_front.brokenImageHandler = function (source)
2359
  {
2360
- source.src = wdi_url.plugin_url + "images/missing.png";
2361
- source.onerror = "";
2362
- return true;
 
 
 
 
 
 
2363
 
 
 
 
 
 
 
 
 
2364
  }
2365
 
2366
 
2357
  //broken image handling
2358
  wdi_front.brokenImageHandler = function (source)
2359
  {
2360
+ var url_params = source.src.split("/p/");
2361
+ if(typeof url_params[0] !== "undefined" && typeof url_params[1] !== "undefined" && url_params[0] !== "https://www.instagram.com"){
2362
+ var main_url = wdi_baseName(url_params[0]);
2363
+ var new_url = main_url+"/p/"+url_params[1];
2364
+ source.src = new_url;
2365
+ }else{
2366
+ source.src = wdi_url.plugin_url + "images/missing.png";
2367
+ }
2368
+
2369
 
2370
+ source.onerror = "";
2371
+ return true;
2372
+
2373
+ }
2374
+ function wdi_baseName(str)
2375
+ {
2376
+ var base = str.substr(str.lastIndexOf('/'));
2377
+ return str.replace(base, "");
2378
  }
2379
 
2380
 
js/wdi_frontend.min.js CHANGED
@@ -1 +1 @@
1
- if(typeof wdi_front=="undefined"){wdi_front={type:"not_declared"}}wdi_front.detectEvent=function(){var a=(/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));if(a){return"touchend"}else{return"click"}};var wdi_error_show=false;wdi_front.escape_tags=function(e){var b=/</g,c=/>/g,d=/'/g,a=/"/g;if(typeof e=="undefined"){e=""}e=e.toString().replace(b,"&lt;").replace(c,"&gt;").replace(d,"&#39;").replace(a,"&#34;");return e};wdi_front.show_alert=function(e,b,f){f=jQuery("#wdi_feed_"+f.feed_row.wdi_feed_counter);if(b.meta["code"]===400&&b.meta["error_type"]==="APINotAllowedError"){if(typeof b.wdi_current_feed_name!="undefined"){var a=b.wdi_current_feed_name;var d=f.find(".wdi_private_feed_names");d.html(a);f.find(".wdi_private_feed_error").removeClass("wdi_hidden")}f.find(".wdi_spinner").remove()}if(typeof f!="undefined"&&b.meta["error_type"]!="APINotAllowedError"){f.find(".wdi_spinner").remove();wdi_error_show=true;var c=f.find(".wdi_js_error");var g=f.find(".wdi_token_error");if(b!=false&&typeof b.meta!=undefined&&b.meta.error_type==="OAuthAccessTokenException"){g.removeClass("wdi_hidden");if(wdi_front_messages.wdi_token_error_flag!="1"){jQuery.ajax({type:"POST",url:wdi_url.ajax_url,dataType:"json",data:{action:"wdi_token_flag",wdi_token_flag_nonce:wdi_front_messages.wdi_token_flag_nonce},success:function(h){}})}}else{c.removeClass("wdi_js_error");c.addClass("wdi_js_error_no_animate");jQuery(".wdi_js_error_no_animate").show()}if(wdi_front_messages.show_alerts){}else{console.log("%c"+e,"color:#cc0000;")}}wdi_error_show=true};wdi_front.globalInit=function(){var a=wdi_front.feed_counter;if(typeof wdi_ajax.ajax_response!="undefined"){var c=wdi_feed_counter_init.wdi_feed_counter_init}else{var c=0}for(var b=c;b<=a;b++){if(jQuery("#wdi_feed_"+b).length===0){continue}var d=new WDIFeed(window["wdi_feed_"+b]);d.instagram=new WDIInstagram();d.instagram.filterArguments={feed:d};d.instagram.filters=[{where:"getUserRecentMedia",what:function(f,g,e){return g.feed.conditionalFilter(f,e)}},{where:"getTagRecentMedia",what:function(f,g,e){return g.feed.conditionalFilter(f,e)}},{where:"getRecentLikedMedia",what:function(f,g,e){return g.feed.conditionalFilter(f,e)}},{where:"requestByUrl",what:function(f,g,e){return g.feed.conditionalFilter(f,e)}}];d.instagram.addToken(d.feed_row["access_token"]);wdi_front.access_token=d.feed_row["access_token"];d.dataStorageRaw=[];d.dataStorage=[];d.dataStorageList=[];d.allResponseLength=0;d.currentResponseLength=0;d.temproraryUsersData=[];d.removedUsers=0;d.nowLoadingImages=true;d.imageIndex=0;d.resIndex=0;d.currentPage=1;d.userSortFlags=[];d.customFilterChanged=false;d.maxConditionalFiltersRequestCount=10;d.instagramRequestCounter=0;d.mediaRequestsDone=false;d.conditionalFilterBuffer=[];d.stopInfiniteScrollFlag=false;if(d.feed_row.feed_type=="masonry"){d.displayedData=[]}if(d.feed_row.feed_display_view=="pagination"){d.feed_row.resort_after_load_more=0;if(d.feed_row.feed_type!="image_browser"){d.feed_row.load_more_number=parseInt(d.feed_row.pagination_per_page_number);d.feed_row.number_of_photos=(1+parseInt(d.feed_row.pagination_preload_number))*d.feed_row.load_more_number}else{d.feed_row.number_of_photos=1+parseInt(d.feed_row.image_browser_preload_number);d.feed_row.load_more_number=parseInt(d.feed_row.image_browser_load_number)}d.freeSpaces=(Math.floor(d.feed_row.pagination_per_page_number/d.feed_row.number_of_columns)+1)*d.feed_row.number_of_columns-d.feed_row.pagination_per_page_number}else{d.freeSpaces=0}d.galleryBox=function(e){wdi_spider_createpopup(wdi_url.ajax_url+"?gallery_id="+this.feed_row.id+"&image_id="+e,this.feed_row.wdi_feed_counter,this.feed_row.lightbox_width,this.feed_row.lightbox_height,1,"testpopup",5,this,e)};wdi_responsive.columnControl(d);if(d.feed_row.feed_type=="masonry"){jQuery(window).trigger("resize")}wdi_front.bindEvents(d);window["wdi_feed_"+b]=d;wdi_front.init(d)}};wdi_front.init=function(d){jQuery(".wdi_js_error").hide();d.photoCounter=d.feed_row.number_of_photos;if(d.feed_row.liked_feed=="liked"){d.feed_users=["self"]}else{if(wdi_front.isJsonString(d.feed_row.feed_users)){d.feed_users=JSON.parse(d.feed_row.feed_users)}else{wdi_front.show_alert(wdi_front_messages.invalid_users_format,false,d);return}}var e=[];if(typeof window.wdi_all_tags!=="undefined"){e=window.wdi_all_tags}for(var a=0;a<d.feed_users.length;a++){if(d.feed_users[a].username[0]==="#"&&typeof d.feed_users[a].tag_id!=="undefined"){e[d.feed_users[a].tag_id]=d.feed_users[a]}}window.wdi_all_tags=e;d.dataCount=d.feed_users.length;var b=wdi_front.getFeedItemResolution(d);d.feedImageResolution=b.image;d.feedVideoResolution=b.video;for(var c=0;c<d.dataCount;c++){wdi_front.instagramRequest(c,d)}if(d.feed_row.number_of_photos>0){wdi_front.ajaxLoader(d)}if(d.feed_row["display_header"]==="1"){wdi_front.show("header",d)}if(d.feed_row["show_usernames"]==="1"){wdi_front.show("users",d)}};wdi_front.getFeedItemResolution=function(g){var d={image:"standard_resolution",video:"standard_resolution"};if(g.feed_row.feed_resolution==="thumbnail"){return{image:"thumbnail",video:"low_bandwidth"}}else{if(g.feed_row.feed_resolution==="low"){return{image:"low_resolution",video:"low_resolution"}}else{if(g.feed_row.feed_resolution==="standard"){return{image:"standard_resolution",video:"standard_resolution"}}}}var c=jQuery("#wdi_feed_"+g.feed_row.wdi_feed_counter).find(".wdi_feed_wrapper");c.append('<div class="wdi_feed_item" id="wdi_feed_item_example"></div>');wdi_responsive.columnControl(g,1);var b=c.attr("wdi-res").split("wdi_col_");c.find("#wdi_feed_item_example").remove();if(b.length!==2){return d}var a=parseInt(b[1]);if(a<=0){return d}var f=(c.width()/a)-10;var e=d;if(f<=150){e.image="thumbnail";e.video="low_bandwidth"}else{if(f>150&&f<=320){e.image="low_resolution";e.video="low_resolution"}else{e.image="standard_resolution";e.video="standard_resolution"}}return e};wdi_front.isJsonString=function(b){try{JSON.parse(b)}catch(a){return false}return true};wdi_front.instagramRequest=function(d,b){var a=b.feed_users,c=this;if(typeof a[d]==="string"&&a[d]==="self"){b.instagram.getRecentLikedMedia({success:function(e){if(typeof e.meta!="undefined"&&typeof e.meta.error_type!="undefined"){wdi_front.show_alert(false,e,b)}b.mediaRequestsDone=true;e=c.checkMediaResponse(e,b);if(e!=false){c.saveSelfUserData(e,b)}}})}else{if(this.getInputType(a[d]["username"])=="hashtag"){b.instagram.getTagRecentMedia(this.stripHashtag(a[d]["username"]),{success:function(e){if(typeof e.meta!="undefined"&&typeof e.meta.error_type!="undefined"){wdi_front.show_alert(false,e,b)}b.mediaRequestsDone=true;e=c.checkMediaResponse(e,b);if(e!=false){c.saveUserData(e,b.feed_users[d],b)}}},null,b.feed_row.hashtag_top_recent)}else{if(this.getInputType(a[d]["username"])=="user"){b.instagram.getSelfRecentMedia({success:function(e){if(typeof e.meta!="undefined"&&typeof e.meta.error_type!="undefined"){e.wdi_current_feed_name=a[d].username;wdi_front.show_alert(false,e,b)}b.mediaRequestsDone=true;e=c.checkMediaResponse(e,b);if(e!=false){c.saveUserData(e,b.feed_users[d],b)}}})}}}};wdi_front.isHashtag=function(a){return(a[0]==="#")};wdi_front.saveUserData=function(d,a,b){d.username=a.username;d.user_id=a.id;if(d.user_id[0]==="#"){d.data=wdi_front.appendRequestHashtag(d.data,d.user_id)}b.usersData.push(d);b.currentResponseLength=wdi_front.getArrayContentLength(b.usersData,"data");b.allResponseLength+=b.currentResponseLength;if(b.dataCount==b.usersData.length){if(b.currentResponseLength<b.feed_row.number_of_photos&&!wdi_front.userHasNoPhoto(b)){wdi_front.loadMore("initial-keep",b)}else{wdi_front.displayFeed(b);wdi_front.applyFilters(b);if(!wdi_front.activeUsersCount(b)){if(b.feed_row.feed_display_view=="load_more_btn"){var c=jQuery("#wdi_feed_"+b.feed_row.wdi_feed_counter);c.find(".wdi_load_more").addClass("wdi_hidden");c.find(".wdi_spinner").addClass("wdi_hidden")}}}}};wdi_front.saveSelfUserData=function(c,a){c.username="";c.user_id="";a.usersData.push(c);a.currentResponseLength=wdi_front.getArrayContentLength(a.usersData,"data");a.allResponseLength+=a.currentResponseLength;if(a.dataCount==a.usersData.length){if(a.currentResponseLength<a.feed_row.number_of_photos&&!wdi_front.userHasNoPhoto(a)){wdi_front.loadMore("initial-keep",a)}else{wdi_front.displayFeed(a);wdi_front.applyFilters(a);if(!wdi_front.activeUsersCount(a)){if(a.feed_row.feed_display_view=="load_more_btn"){var b=jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter);b.find(".wdi_load_more").addClass("wdi_hidden");b.find(".wdi_spinner").addClass("wdi_hidden")}}}}};wdi_front.userHasNoPhoto=function(c,e){var a=0;var d=c.usersData;if(typeof e!="undefined"){d=e}for(var b=0;b<d.length;b++){if(typeof d[b]["pagination"]=="undefined"){d[b]["pagination"]=[]}if(c.feed_row.liked_feed==="liked"){if(typeof d[b]["pagination"]["next_max_like_id"]=="undefined"){a++}}else{if(typeof d[b]["pagination"]["next_max_id"]=="undefined"){a++}}}if(a==d.length){return 1}else{return 0}};wdi_front.appendRequestHashtag=function(c,b){for(var a=0;a<c.length;a++){c[a]["wdi_hashtag"]=b}return c};wdi_front.displayFeed=function(c,b){if(c.customFilterChanged==false){var d=wdi_front.feedSort(c,b)}var a=c.customFilterChanged;if(c.customFilterChanged==true){var d=c.customFilteredData;c.parsedData=wdi_front.parseLighboxData(c,true)}if(c.feed_row.resort_after_load_more!="1"){if(c.customFilterChanged==false){c.dataStorageList=c.dataStorageList.concat(d)}}else{if(c.customFilterChanged==false){c.dataStorageList=d}}if(c.feed_row.feed_type=="masonry"){wdi_front.masonryDisplayFeedItems(d,c)}if(c.feed_row.feed_type=="thumbnails"||c.feed_row.feed_type=="blog_style"||c.feed_row.feed_type=="image_browser"){wdi_front.displayFeedItems(d,c)}var e=wdi_front.getDataLength(c);if(e<c.photoCounter&&!a&&c.instagramRequestCounter<=c.maxConditionalFiltersRequestCount&&!wdi_front.allDataHasFinished(c)){wdi_front.loadMore("",c)}else{wdi_front.allImagesLoaded(c)}if(c.instagramRequestCounter>c.maxConditionalFiltersRequestCount){wdi_front.allImagesLoaded(c);if(d.length==0){c.stopInfiniteScrollFlag=true}}if(c.feed_row.feed_display_view=="pagination"&&c.currentPage<c.paginator){jQuery("#wdi_feed_"+c.feed_row.wdi_feed_counter).find("#wdi_last_page").removeClass("wdi_disabled")}c.instagramRequestCounter=0;c.conditionalFilterBuffer=[];wdi_front.updateUsersImages(c)};wdi_front.updateUsersImages=function(a){var b=jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter).find(".wdi_single_user .wdi_user_img_wrap img");b.each(function(){if(jQuery(this).attr("src")==wdi_url.plugin_url+"images/missing.png"||jQuery(this).attr("src")==""){if(a.feed_row.liked_feed=="liked"){return}for(var c=0;c<a.usersData.length;c++){if(a.usersData[c]["username"]==jQuery(this).parent().parent().find("h3").text()){if(a.usersData[c]["data"].length!=0){jQuery(this).attr("src",a.usersData[c]["data"][0]["images"]["thumbnail"]["url"])}}}}})};wdi_front.masonryDisplayFeedItems=function(d,h){var b=[];var p=[];if(jQuery("#wdi_feed_"+h.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length==0){return}jQuery("#wdi_feed_"+h.feed_row.wdi_feed_counter+" .wdi_masonry_column").each(function(){if(h.feed_row.resort_after_load_more==1){jQuery(this).html("");h.imageIndex=0}if(h.customFilterChanged==true){jQuery(this).html("");h.imageIndex=0}if(h.feed_row.feed_display_view=="pagination"){b.push(0)}else{b.push(jQuery(this).height())}p.push(jQuery(this))});if(h.customFilterChanged==true){h.customFilterChanged=false}for(var e=0;e<d.length;e++){h.displayedData.push(d[e]);if(d[e]["type"]=="image"){var n=wdi_front.getPhotoTemplate(h)}else{if(d[e].hasOwnProperty("videos")||d[e]["type"]=="video"){var n=wdi_front.getVideoTemplate(h)}else{var n=wdi_front.getSliderTemplate(h)}}var g=d[e];var o=wdi_front.createObject(g,h);var f=n(o);var m=wdi_front.array_min(b);var l=wdi_front.getImageResolution(d[e]);p[m.index].html(p[m.index].html()+f);b[m.index]+=p[m.index].width()*l;h.imageIndex++;if(h.feed_row.feed_display_view=="pagination"){if((e+1)%h.feed_row.pagination_per_page_number===0){h.resIndex+=h.freeSpaces+1}else{h.resIndex++}}}h.wdi_loadedImages=0;var j=false;h.wdi_load_count=e;var a=h.feed_row.wdi_feed_counter;var k=jQuery("#wdi_feed_"+a+" img.wdi_img").on("load",function(){h.wdi_loadedImages++;c();if(j===false){wdi_responsive.columnControl(h,1);j=true}});c();function c(){if(h.wdi_load_count===h.wdi_loadedImages&&h.wdi_loadedImages!=0){h.loadedImages=0;h.wdi_load_count=0;wdi_front.allImagesLoaded(h)}}if(h.paginatorNextFlag==true){wdi_front.updatePagination(h,"next")}h.infiniteScrollFlag=false};wdi_front.getImageResolution=function(c){var d=c.images["standard_resolution"]["width"];var b=c.images["standard_resolution"]["height"];var a=b/d;return a};wdi_front.getDataLength=function(b,d){var c=0;if(typeof d==="undefined"){for(var a=0;a<b.dataStorage.length;a++){c+=b.dataStorage[a].length}}else{for(var a=0;a<d.length;a++){c+=d[a].length}}return c};wdi_front.getArrayContentLength=function(d,c){var b=0;for(var a=0;a<d.length;a++){if(d[a]["finished"]=="finished"){continue}b+=d[a][c].length}return b};wdi_front.displayFeedItems=function(d,j){if(jQuery("#wdi_feed_"+j.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length==0){return}var a=j.feed_row.wdi_feed_counter;var l=jQuery("#wdi_feed_"+a+" .wdi_feed_wrapper");if(j.feed_row.resort_after_load_more==="1"){l.html("");j.imageIndex=0}if(j.customFilterChanged==true){l.html("");j.imageIndex=0;j.customFilterChanged=false}var g=wdi_front.getImgCount(j)-d.length-1;if(j.feed_row.feed_display_view=="pagination"){var b=j.feed_row.load_more_number;if(j.feed_row.feed_type=="image_browser"){b=1}if(jQuery("#wdi_feed_"+j.feed_row.wdi_feed_counter+' [wdi_page="'+(j.currentPage-1)+'"]').length<b||d.length==0){j.currentPage=(--j.currentPage<=1)?1:j.currentPage}}for(var e=0;e<d.length;e++){if(d[e]["type"]=="image"){var m=wdi_front.getPhotoTemplate(j)}else{if(d[e].hasOwnProperty("videos")){var m=wdi_front.getVideoTemplate(j)}else{var m=wdi_front.getSliderTemplate(j)}}var h=d[e];var n=wdi_front.createObject(h,j);var f=m(n);l.html(l.html()+f);j.imageIndex++;if(j.feed_row.feed_display_view=="pagination"){if((e+1)%j.feed_row.pagination_per_page_number===0){j.resIndex+=j.freeSpaces+1}else{j.resIndex++}}}j.wdi_loadedImages=0;var k=false;j.wdi_load_count=e;var a=j.feed_row.wdi_feed_counter;var l=jQuery("#wdi_feed_"+a+" img.wdi_img").on("load",function(){j.wdi_loadedImages++;c();if(k===false){wdi_responsive.columnControl(j,1);k=true}});function c(){if(j.wdi_load_count===j.wdi_loadedImages&&j.wdi_loadedImages!=0){j.loadedImages=0;j.wdi_load_count=0;wdi_front.allImagesLoaded(j)}}if(j.paginatorNextFlag==true){wdi_front.updatePagination(j,"next")}j.infiniteScrollFlag=false};wdi_front.checkFeedFinished=function(b){for(var a=0;a<b.usersData.length;a++){if(typeof b.usersData[a]["finished"]=="undefined"){return false}}return true};wdi_front.sortingOperator=function(c,b){var a;switch(c){case"date":switch(b){case"asc":a=function(e,d){return(e.created_time>d.created_time)?1:-1};break;case"desc":a=function(e,d){return(e.created_time>d.created_time)?-1:1};break}break;case"likes":switch(b){case"asc":a=function(e,d){return(e.likes["count"]<d.likes["count"])?-1:1};break;case"desc":a=function(e,d){return(e.likes["count"]<d.likes["count"])?1:-1};break}break;case"comments":switch(b){case"asc":a=function(e,d){return(e.comments["count"]<d.comments["count"])?-1:1};break;case"desc":a=function(e,d){return(e.comments["count"]<d.comments["count"])?1:-1};break}break;case"random":a=function(e,d){var f=Math.random();return(f>0.5)?1:-1};break}return a};wdi_front.feedSort=function(e,b){var d=e.feed_row.sort_images_by;var c=e.feed_row.display_order;if(e.feed_row.resort_after_load_more==="1"){e.data=e.data.concat(wdi_front.smartPicker(e,b))}else{e.data=wdi_front.smartPicker(e,b)}var a=wdi_front.sortingOperator(d,c);e.data.sort(a);return e.data};wdi_front.smartPicker=function(l,c){var g=[];var a=0;var k=[];var f=Math.ceil(l.feed_row["number_of_photos"]/l.usersData.length);var b=parseInt(l.feed_row["number_of_photos"]);var n=0;if(c!=""&&typeof c!="undefined"&&c!=null){b=parseInt(c);f=Math.ceil(b/wdi_front.activeUsersCount(l))}var j=function(p,i){return(p.data.length>i.data.length)?1:-1};var e=function(p,i){return(p.length()>i.length())?1:-1};l.storeRawData(l.usersData,"dataStorageRaw");var o=l.dataStorageRaw.sort(e);var h=l.usersData.sort(j);for(var d=0;d<h.length;d++){n+=f;if(o[d].length()<=n){n-=o[d].length();g.push(o[d].getData(o[d].length()));a+=g[g.length-1].length}else{if(a+n>b){n=b-a}var m=[];if(l.auto_trigger===false){m=m.concat(o[d].getData(n))}else{if(m.length+wdi_front.getDataLength(l)+wdi_front.getDataLength(l,g)<l.feed_row["number_of_photos"]){m=m.concat(o[d].getData(n))}}n=0;a+=m.length;g.push(m)}}for(d=0;d<g.length;d++){if(typeof l.dataStorage[d]==="undefined"){l.dataStorage.push(g[d])}else{l.dataStorage[d]=l.dataStorage[d].concat(g[d])}}l.parsedData=wdi_front.parseLighboxData(l);for(d=0;d<g.length;d++){k=k.concat(g[d])}return k};wdi_front.createObject=function(e,h){var j=(e.caption!=null)?e.caption["text"]:"&nbsp";var i="";if(e.type=="video"){i=e.hasOwnProperty("videos")?e.videos[h.feedVideoResolution]["url"]:""}if(typeof e.images[h.feedImageResolution]=="undefined"){var f=wdi_url.plugin_url+"images/missing.png"}else{var f=e.images[h.feedImageResolution].url}var a=h.imageIndex;var b="square";var d=e.images["standard_resolution"]["height"];var g=e.images["standard_resolution"]["width"];if(d>g){b="portrait"}else{if(d<g){b="landscape"}}var c={id:e.id,caption:wdi_front.escape_tags(j),image_url:f,likes:e.likes["count"],comments:e.comments["count"],wdi_index:a,wdi_res_index:h.resIndex,wdi_media_user:e.user["username"],link:e.link,video_url:i,wdi_username:e.user["username"],wdi_shape:b};return c};wdi_front.setPage=function(c){var b=c.feed_row.feed_display_view;var e=c.feed_row.feed_type;if(b!="pagination"){return""}var a=c.imageIndex;if(e=="image_browser"){var d=1}else{var d=Math.abs(c.feed_row.pagination_per_page_number)}c.paginator=Math.ceil((a+1)/d);return c.paginator};wdi_front.getPhotoTemplate=function(g){var e=wdi_front.setPage(g);var j="";var k="";var l="";var d="";var m="fa-arrows-alt";var c="";if(g.feed_row.feed_type=="blog_style"||g.feed_row.feed_type=="image_browser"){m=""}if(e!=""){k='wdi_page="'+e+'"';sourceAttr="src"}else{sourceAttr="src"}if(e!=""&&e!=1){j="wdi_hidden"}if(g.feed_row.show_username_on_thumb=="1"){c='<span class="wdi_media_user">@<%= wdi_username%></span>'}if(g.feed_row.show_full_description==1&&g.feed_row.feed_type=="masonry"){j+=" wdi_full_caption"}var f="";if(g.feed_row.feed_type!=="blog_style"){if(g.feed_row.feed_type=="masonry"){f="wdi_responsive.showMasonryCaption(jQuery(this),"+g.feed_row.wdi_feed_counter+");"}else{f="wdi_responsive.showCaption(jQuery(this),"+g.feed_row.wdi_feed_counter+");"}}switch(g.feed_row.feed_item_onclick){case"lightbox":l="onclick=wdi_feed_"+g.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":l="onclick=\"window.open ('<%= link%>','_blank')\"";d="wdi_hover_off";m="";break;case"custom_redirect":l="onclick=\"window.open ('"+g.feed_row.redirect_url+"','_self')\"";d="wdi_hover_off";m="";break;case"none":l="";d="wdi_cursor_off wdi_hover_off";m=""}var h="<%= wdi_shape == 'square' ? 'wdi_shape_square' : (wdi_shape == 'portrait' ? 'wdi_shape_portrait' : (wdi_shape == 'landscape' ? 'wdi_shape_landscape' : 'wdi_shape_square') ) %>";var b=g.feed_row.wdi_feed_counter;var a='<div class="wdi_feed_item '+j+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> '+k+' wdi_type="image" id="wdi_'+b+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img '+h+'"><img class="wdi_img" '+sourceAttr+'="<%=image_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+d+'" >'+c+'<div class="wdi_thumb_icon" '+l+' style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="fa '+m+'"></i></div></div></div></div></div></div>';if(g.feed_row["show_likes"]==="1"||g.feed_row["show_comments"]==="1"||g.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_meta">';if(g.feed_row["show_likes"]==="1"){a+='<div class="wdi_thumb_likes"><i class="fa fa-heart-o">&nbsp;<%= likes%></i></div>'}if(g.feed_row["show_comments"]==="1"){a+='<div class="wdi_thumb_comments"><i class="fa fa-comment-o">&nbsp;<%= comments%></i></div>'}a+='<div class="wdi_clear"></div>';if(g.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_title" onclick='+f+" ><%=caption%></div>"}a+="</div>"}a+="</div>";var i=_.template(a);return i};wdi_front.getSliderTemplate=function(g){var e=wdi_front.setPage(g);var j="";var k="";var l="";var d="";var m="fa-clone";var c="";if(g.feed_row.feed_type=="blog_style"||g.feed_row.feed_type=="image_browser"){m=""}if(e!=""){k='wdi_page="'+e+'"';sourceAttr="src"}else{sourceAttr="src"}if(e!=""&&e!=1){j="wdi_hidden"}if(g.feed_row.show_username_on_thumb=="1"){c='<span class="wdi_media_user">@<%= wdi_username%></span>'}if(g.feed_row.show_full_description==1&&g.feed_row.feed_type=="masonry"){j+=" wdi_full_caption"}var f="";if(g.feed_row.feed_type!=="blog_style"){if(g.feed_row.feed_type=="masonry"){f="wdi_responsive.showMasonryCaption(jQuery(this),"+g.feed_row.wdi_feed_counter+");"}else{f="wdi_responsive.showCaption(jQuery(this),"+g.feed_row.wdi_feed_counter+");"}}switch(g.feed_row.feed_item_onclick){case"lightbox":l="onclick=wdi_feed_"+g.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":l="onclick=\"window.open ('<%= link%>','_blank')\"";d="wdi_hover_off";m="fa-clone";break;case"custom_redirect":l="onclick=\"window.open ('"+g.feed_row.redirect_url+"','_self')\"";d="wdi_hover_off";m="";break;case"none":l="";d="wdi_cursor_off wdi_hover_off";m=""}var h="<%= wdi_shape == 'square' ? 'wdi_shape_square' : (wdi_shape == 'portrait' ? 'wdi_shape_portrait' : (wdi_shape == 'landscape' ? 'wdi_shape_landscape' : 'wdi_shape_square') ) %>";var b=g.feed_row.wdi_feed_counter;var a='<div class="wdi_feed_item '+j+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> '+k+' wdi_type="slideshow" id="wdi_'+b+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img '+h+'"><img class="wdi_img" '+sourceAttr+'="<%=image_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+d+'" >'+c+'<div class="wdi_thumb_icon" '+l+' style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="fa '+m+'"></i></div></div></div></div></div></div>';if(g.feed_row["show_likes"]==="1"||g.feed_row["show_comments"]==="1"||g.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_meta">';if(g.feed_row["show_likes"]==="1"){a+='<div class="wdi_thumb_likes"><i class="fa fa-heart-o">&nbsp;<%= likes%></i></div>'}if(g.feed_row["show_comments"]==="1"){a+='<div class="wdi_thumb_comments"><i class="fa fa-comment-o">&nbsp;<%= comments%></i></div>'}a+='<div class="wdi_clear"></div>';if(g.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_title" onclick='+f+" ><%=caption%></div>"}a+="</div>"}a+="</div>";var i=_.template(a);return i};wdi_front.replaceToVideo=function(b,a,c){overlayHtml="<video style='width:auto !important; height:auto !important; max-width:100% !important; max-height:100% !important; margin:0 !important;' controls=''><source src='"+b+"' type='video/mp4'>Your browser does not support the video tag. </video>";jQuery("#wdi_feed_"+c+' [wdi_index="'+a+'"] .wdi_photo_wrap_inner').html(overlayHtml);jQuery("#wdi_feed_"+c+' [wdi_index="'+a+'"] .wdi_photo_wrap_inner video').get(0).play()};wdi_front.getVideoTemplate=function(h){var f=wdi_front.setPage(h);var k="";var l="";var n="fa-play";var m="";var d="";var e;var c="";if(f!=""){l='wdi_page="'+f+'"';e="src"}else{e="src"}if(f!=""&&f!=1){k="wdi_hidden"}if(h.feed_row.show_username_on_thumb=="1"){c='<span class="wdi_media_user">@<%= wdi_username%></span>'}if(h.feed_row.show_full_description==1&&h.feed_row.feed_type=="masonry"){k+=" wdi_full_caption"}var g="";if(h.feed_row.feed_type!=="blog_style"){if(h.feed_row.feed_type=="masonry"){g="wdi_responsive.showMasonryCaption(jQuery(this),"+h.feed_row.wdi_feed_counter+");"}else{g="wdi_responsive.showCaption(jQuery(this),"+h.feed_row.wdi_feed_counter+");"}}switch(h.feed_row.feed_item_onclick){case"lightbox":m="onclick=wdi_feed_"+h.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":m="onclick=\"window.open ('<%= link%>','_blank')\"";d="wdi_hover_off";n="fa-play";break;case"custom_redirect":m="onclick=\"window.open ('"+h.feed_row.redirect_url+"','_self')\"";d="wdi_hover_off";n="";break;case"none":d="wdi_cursor_off wdi_hover_off";n="";if(h.feed_row.feed_type=="blog_style"||h.feed_row.feed_type=="image_browser"){m="onclick=wdi_front.replaceToVideo('<%= video_url%>','<%= wdi_index%>',"+h.feed_row.wdi_feed_counter+")";d="";n="fa-play"}}var i="<%= wdi_shape == 'square' ? 'wdi_shape_square' : (wdi_shape == 'portrait' ? 'wdi_shape_portrait' : (wdi_shape == 'landscape' ? 'wdi_shape_landscape' : 'wdi_shape_square') ) %>";var b=h.feed_row.wdi_feed_counter;var a='<div class="wdi_feed_item '+k+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> '+l+' wdi_type="image" id="wdi_'+b+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img '+i+'"><img class="wdi_img" '+e+'="<%=image_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+d+'" '+m+">"+c+'<div class="wdi_thumb_icon" style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="fa '+n+'"></i></div></div></div></div></div></div>';if(h.feed_row["show_likes"]==="1"||h.feed_row["show_comments"]==="1"||h.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_meta">';if(h.feed_row["show_likes"]==="1"){a+='<div class="wdi_thumb_likes"><i class="fa fa-heart-o">&nbsp;<%= likes%></i></div>'}if(h.feed_row["show_comments"]==="1"){a+='<div class="wdi_thumb_comments"><i class="fa fa-comment-o">&nbsp;<%= comments%></i></div>'}a+='<div class="wdi_clear"></div>';if(h.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_title" onclick='+g+" ><%=caption%></div>"}a+="</div>"}a+="</div>";var j=_.template(a);return j};wdi_front.bindEvents=function(a){if(jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length==0){return}if(a.feed_row.feed_display_view=="load_more_btn"){jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" .wdi_load_more_container").on(wdi_front.clickOrTouch,function(){wdi_front.loadMore(jQuery(this).find(".wdi_load_more_wrap"))})}if(a.feed_row.feed_display_view=="pagination"){jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_next").on(wdi_front.clickOrTouch,function(){wdi_front.paginatorNext(jQuery(this),a)});jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_prev").on(wdi_front.clickOrTouch,function(){wdi_front.paginatorPrev(jQuery(this),a)});jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_last_page").on(wdi_front.clickOrTouch,function(){wdi_front.paginationLastPage(jQuery(this),a)});jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_first_page").on(wdi_front.clickOrTouch,function(){wdi_front.paginationFirstPage(jQuery(this),a)});a.paginatorNextFlag=false}if(a.feed_row.feed_display_view=="infinite_scroll"){jQuery(window).on("scroll",function(){wdi_front.infiniteScroll(a)});a.infiniteScrollFlag=false}};wdi_front.infiniteScroll=function(a){if((jQuery(window).scrollTop()+jQuery(window).height()-100)>=jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_infinite_scroll").offset().top){if(a.infiniteScrollFlag===false&&a.stopInfiniteScrollFlag==false){a.infiniteScrollFlag=true;wdi_front.loadMore(jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_infinite_scroll"),a)}else{if(a.stopInfiniteScrollFlag){wdi_front.allImagesLoaded(a)}}}};wdi_front.paginationFirstPage=function(b,c){if(c.paginator==1||c.currentPage==1){b.addClass("wdi_disabled");return}var d=c.currentPage;c.currentPage=1;wdi_front.updatePagination(c,"custom",d);var a=b.parent().find("#wdi_last_page");a.removeClass("wdi_disabled");b.addClass("wdi_disabled")};wdi_front.paginationLastPage=function(a,b){if(b.paginator==1||b.currentPage==b.paginator){return}var d=b.currentPage;b.currentPage=b.paginator;wdi_front.updatePagination(b,"custom",d);a.addClass("wdi_disabled");var c=a.parent().find("#wdi_first_page");c.removeClass("wdi_disabled")};wdi_front.paginatorNext=function(b,c){var a=b.parent().find("#wdi_last_page");var d=b.parent().find("#wdi_first_page");c.paginatorNextFlag=true;if(c.paginator==c.currentPage&&!wdi_front.checkFeedFinished(c)){c.currentPage++;var e=c.feed_row.number_of_photos;wdi_front.loadMore(b,c,e);a.addClass("wdi_disabled")}else{if(c.paginator>c.currentPage){c.currentPage++;wdi_front.updatePagination(c,"next");if(c.paginator>c.currentPage){a.removeClass("wdi_disabled")}else{a.addClass("wdi_disabled")}}}d.removeClass("wdi_disabled")};wdi_front.paginatorPrev=function(b,c){var a=b.parent().find("#wdi_last_page");var d=b.parent().find("#wdi_first_page");if(c.currentPage==1){d.addClass("wdi_disabled");return}c.currentPage--;wdi_front.updatePagination(c,"prev");a.removeClass("wdi_disabled");if(c.currentPage==1){d.addClass("wdi_disabled")}};wdi_front.updatePagination=function(b,a,d){var c="#wdi_feed_"+b.feed_row.wdi_feed_counter;jQuery(c+' [wdi_page="'+b.currentPage+'"]').each(function(){jQuery(this).removeClass("wdi_hidden")});switch(a){case"next":var d=b.currentPage-1;jQuery(c+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height());jQuery(c+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")});break;case"prev":var d=b.currentPage+1;jQuery(c+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height());jQuery(c+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")});break;case"custom":var d=d;if(d!=b.currentPage){jQuery(c+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height());jQuery(c+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")})}break}b.paginatorNextFlag=false;jQuery(c+" .wdi_feed_wrapper").css("height","auto");jQuery(c+" #wdi_current_page").text(b.currentPage)};wdi_front.loadMore=function(f,k){var b=0;if(f!=""&&typeof f!="undefined"&&f!="initial"&&f!="initial-keep"){var l=window[f.parent().parent().parent().parent().attr("id")]}if(typeof k!="undefined"){var l=k}var n=0,g=0;for(var e=0;e<l.userSortFlags.length;e++){if(l.userSortFlags[e].flag===true){n++;for(var d=0;d<l.usersData.length;d++){if(l.userSortFlags[e]["id"]===l.usersData[d]["user_id"]){if(l.usersData[d]["finished"]==="finished"){g++}}}}}if(n===g&&n!=0){return}if(f===""){l.auto_trigger=true}else{l.auto_trigger=false}wdi_front.ajaxLoader(l);if(l.feed_row.feed_type==="masonry"&&l.feed_row.feed_display_view=="pagination"){jQuery("#wdi_feed_"+wdi_front.feed_counter+" .wdi_full_caption").each(function(){jQuery(this).find(".wdi_photo_title").trigger(wdi_front.clickOrTouch)})}for(var e=0;e<l.usersData.length;e++){if(l.usersData[e]["finished"]==="finished"){b++}}if(b===l.usersData.length){wdi_front.allImagesLoaded(l);jQuery("#wdi_feed_"+l.feed_row["wdi_feed_counter"]+" .wdi_load_more").remove()}var h=l.usersData;l.loadMoreDataCount=l.feed_users.length;for(var e=0;e<h.length;e++){var m=h[e]["pagination"];var c={user_id:h[e]["user_id"],username:h[e]["username"]};if(m.next_url!=""&&m.next_url!=null&&typeof m.next_url!="undefined"){var a=m.next_url;wdi_front.loadMoreRequest(c,a,l,f)}else{if(f=="initial-keep"){l.temproraryUsersData[e]=l.usersData[e]}l.loadMoreDataCount--;wdi_front.checkForLoadMoreDone(l,f);continue}}};wdi_front.loadMoreRequest=function(b,a,e,d){if(!e.mediaRequestsDone){return}var f=e.usersData;var c="";var g=function(h){if(typeof h.meta!="undefined"&&typeof h.meta.error_type!="undefined"){wdi_front.show_alert(false,h,e)}if(h===""||typeof h=="undefined"||h==null){c=wdi_front_messages.network_error;e.loadMoreDataCount--;wdi_front.show_alert(c,h,e);return}if(h.meta["code"]!=200){c=h.meta["error_message"];e.loadMoreDataCount--;wdi_front.show_alert(c,h,e);return}h.user_id=b.user_id;h.username=b.username;for(var j=0;j<e.usersData.length;j++){if(h.user_id===e.usersData[j]["user_id"]){if(h.user_id[0]==="#"){h.data=wdi_front.appendRequestHashtag(h.data,h.user_id)}if(d=="initial-keep"){e.temproraryUsersData[j]=e.usersData[j]}e.usersData[j]=h;e.loadMoreDataCount--}}wdi_front.checkForLoadMoreDone(e,d)};if(b.username[0]!=="#"){e.instagram.requestByUrl(a,{success:g})}else{e.instagram.getTagRecentMedia(b.username,{success:g},a,e.feed_row.hashtag_top_recent)}};wdi_front.checkForLoadMoreDone=function(c,b){var a=c.feed_row.load_more_number;var e=c.feed_row.number_of_photos;if(c.loadMoreDataCount==0){c.temproraryUsersData=wdi_front.mergeData(c.temproraryUsersData,c.usersData);var d=wdi_front.getArrayContentLength(c.temproraryUsersData,"data");if(b=="initial-keep"){b="initial"}if(b=="initial"){if(d<e&&!wdi_front.userHasNoPhoto(c,c.temproraryUsersData)&&c.instagramRequestCounter<=c.maxConditionalFiltersRequestCount){wdi_front.loadMore("initial",c)}else{c.usersData=c.temproraryUsersData;wdi_front.displayFeed(c);wdi_front.applyFilters(c);c.temproraryUsersData=[]}}else{if(d<a&&!wdi_front.userHasNoPhoto(c,c.temproraryUsersData)&&c.instagramRequestCounter<=c.maxConditionalFiltersRequestCount){wdi_front.loadMore(undefined,c)}else{c.usersData=c.temproraryUsersData;if(!wdi_front.activeUsersCount(c)){return}wdi_front.displayFeed(c,a);wdi_front.applyFilters(c);c.temproraryUsersData=[]}}}};wdi_front.allDataHasFinished=function(b){var d=0;for(var a=0;a<b.dataStorageRaw.length;a++){if(b.dataStorageRaw[a].length()==0&&b.dataStorageRaw[a].locked==true){d++}}return(d==b.dataStorageRaw.length)};wdi_front.mergeData=function(c,b){for(var a=0;a<b.length;a++){if(typeof c[a]!="undefined"){if(b[a]["finished"]=="finished"){continue}if(typeof c[a]["pagination"]["next_max_id"]=="undefined"&&typeof c[a]["pagination"]["next_max_like_id"]=="undefined"){continue}c[a]["data"]=c[a]["data"].concat(b[a]["data"]);c[a]["pagination"]=b[a]["pagination"];c[a]["user_id"]=b[a]["user_id"];c[a]["username"]=b[a]["username"];c[a]["meta"]=b[a]["meta"]}else{c.push(b[a])}}return c};wdi_front.brokenImageHandler=function(a){a.src=wdi_url.plugin_url+"images/missing.png";a.onerror="";return true};wdi_front.ajaxLoader=function(a){var d=a.feed_row.wdi_feed_counter;var c=jQuery("#wdi_feed_"+d);if(a.feed_row.feed_display_view=="load_more_btn"){c.find(".wdi_load_more").addClass("wdi_hidden");c.find(".wdi_spinner").removeClass("wdi_hidden")}if(a.feed_row.feed_display_view=="infinite_scroll"){var b;if(c.find(".wdi_ajax_loading").length==0){b=jQuery('<div class="wdi_ajax_loading"><div><div><img class="wdi_load_more_spinner" src="'+wdi_url.plugin_url+'images/ajax_loader.png"></div></div></div>');c.append(b)}else{b=c.find(".wdi_ajax_loading")}b.removeClass("wdi_hidden")}};wdi_front.allImagesLoaded=function(a){var d=wdi_front.getDataLength(a);if(!a.mediaRequestsDone){jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").remove("wdi_nomedia")}if(d==0&&a.mediaRequestsDone&&(a.feed_row.conditional_filters.length==0||a.feed_row.conditional_filter_enable==0)){jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").append("<p class='wdi_nomedia'>"+wdi_front_messages.feed_nomedia+"</p>")}var c=a.feed_row.wdi_feed_counter;var b=jQuery("#wdi_feed_"+c);if(a.feed_row.feed_display_view=="load_more_btn"){b.find(".wdi_load_more").removeClass("wdi_hidden");b.find(".wdi_spinner").addClass("wdi_hidden")}if(a.feed_row.feed_display_view=="infinite_scroll"){jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" .wdi_ajax_loading").addClass("wdi_hidden")}b.trigger("wdi_feed_loaded")};wdi_front.show=function(b,c){var e=c.feed_row.wdi_feed_counter;var d=jQuery("#wdi_feed_"+e+" .wdi_feed_container");var g=this;switch(b){case"header":f();break;case"users":a(c);break}function f(){var i={feed_thumb:c.feed_row["feed_thumb"],feed_name:c.feed_row["feed_name"]};var k=wdi_front.getHeaderTemplate(),h=k(i),j=d.find(".wdi_feed_header").html();d.find(".wdi_feed_header").html(j+h)}function a(j){d.find(".wdi_feed_users").html("");var n=j.feed_users;var m=j.feed_row["access_token"];var h=0;j.headerUserinfo=[];k();function k(){if(j.headerUserinfo.length==n.length){l(j.headerUserinfo,j);return}var i=n[j.headerUserinfo.length];if(typeof i==="string"&&i==="self"){j.instagram.getSelfInfo({success:function(o){if(typeof o.meta!="undefined"&&typeof o.meta.error_type!="undefined"){wdi_front.show_alert(false,o,j)}o=g.checkMediaResponse(o,j);if(o!=false&&o.meta["code"]===400&&o.meta["error_type"]==="APINotAllowedError"){var p=null;j.headerUserinfo.push(p);h++;k()}if(o!=false&&o.meta["code"]===200){var p={id:o.data["id"],name:o.data["username"],url:o.data["profile_picture"],bio:wdi_front.escape_tags(o.data["bio"]),counts:o.data["counts"],website:wdi_front.escape_tags(o.data["website"]),full_name:wdi_front.escape_tags(o.data["full_name"])};j.headerUserinfo.push(p);h++;k()}},args:{ignoreFiltering:true}})}else{if(false&&g.getInputType(i.username)=="hashtag"){j.instagram.searchForTagsByName(g.stripHashtag(i.username),{success:function(o){if(typeof o.meta!="undefined"&&typeof o.meta.error_type!="undefined"){wdi_front.show_alert(false,o,j)}o=g.checkMediaResponse(o,j);if(o!=false){if(o.data.length==0){var p="";var q={media:""}}else{var p="";var q={media:o.data[0]["media_count"]}}var r={name:n[h]["username"],url:p,counts:q};h++;j.headerUserinfo.push(r);k()}},args:{ignoreFiltering:true}})}else{if(g.getInputType(i.username)=="user"){j.instagram.getSelfInfo({success:function(o){if(typeof o.meta!="undefined"&&typeof o.meta.error_type!="undefined"){wdi_front.show_alert(false,o,j)}o=g.checkMediaResponse(o,j);if(o!=false&&o.meta["code"]===400&&o.meta["error_type"]==="APINotAllowedError"){var p=null;j.headerUserinfo.push(p);h++;k()}if(o!=false&&o.meta["code"]===200){var p={id:o.data["id"],name:o.data["username"],url:o.data["profile_picture"],bio:wdi_front.escape_tags(o.data["bio"]),counts:o.data["counts"],website:wdi_front.escape_tags(o.data["website"]),full_name:wdi_front.escape_tags(o.data["full_name"])};j.headerUserinfo.push(p);h++;k()}},args:{ignoreFiltering:true}})}}}}function l(i,t){d.find(".wdi_feed_users").html("");for(var q=0;q<i.length;q++){if(i[q]===null){continue}var v={flag:false,id:i[q]["id"],name:i[q]["name"]};var p=(i[q]["name"][0]=="#")?"wdi_header_hashtag":"";var u=wdi_extractHostname(i[q]["website"]);var o={user_index:q,user_img_url:i[q]["url"],counts:i[q]["counts"],feed_counter:t.feed_row.wdi_feed_counter,user_name:i[q]["name"],bio:wdi_front.escape_tags(i[q]["bio"]),website:u,website_url:i[q]["website"],usersCount:t.feed_row.feed_users.length,hashtagClass:p};var x=wdi_front.getUserTemplate(t,i[q]["name"]),r=x(o),s=d.find(".wdi_feed_users").html();d.find(".wdi_feed_users").html(s+r);t.userSortFlags.push(v);var w=jQuery('<div class="wdi_clear"></div>')}d.find(".wdi_feed_users").append(w);wdi_front.updateUsersImages(t)}}};wdi_front.getUserTemplate=function(c,h){var a=c.dataCount,d,f,g;switch(h[0]){case"#":d="//instagram.com/explore/tags/"+h.substr(1,h.length);break;default:d="//instagram.com/"+h;break}g='window.open("'+d+'","_blank")';f="onclick='"+g+"'";var e='<div class="wdi_single_user" user_index="<%=user_index%>"><div class="wdi_header_user_text <%=hashtagClass%>"><div class="wdi_user_img_wrap"><img onerror="wdi_front.brokenImageHandler(this);" src="<%= user_img_url%>">';if(a>1){e+='<div title="'+wdi_front_messages.filter_title+'" class="wdi_filter_overlay"><div class="wdi_filter_icon"><span onclick="wdi_front.addFilter(<%=user_index%>,<%=feed_counter%>);" class="fa fa-filter"></span></div></div>'}e+="</div>";e+="<h3 "+f+"><%= user_name%></h3>";if(h[0]!=="#"){if(c.feed_row.follow_on_instagram_btn=="1"){e+='<div class="wdi_user_controls"><div class="wdi_follow_btn" onclick="window.open(\'//instagram.com/<%= user_name%>\',\'_blank\')"><span> '+wdi_front_messages.follow+"</span></div></div>"}e+='<div class="wdi_media_info"><p class="wdi_posts"><span class="fa fa-camera-retro"></span><%= counts.media%></p><p class="wdi_followers"><span class="fa fa-user"></span><%= counts.followed_by%></p></div>'}else{e+='<div class="wdi_user_controls"></div><div class="wdi_media_info"><p class="wdi_posts"><span class="fa fa-camera-retro"></span><%= counts.media%></p><p class="wdi_followers"><span></span></p></div>'}e+='<div class="wdi_clear"></div>';if(a==1&&h[0]!=="#"&&c.feed_row.display_user_info=="1"){e+='<div class="wdi_bio"><%= bio%></div>';e+='<div class="wdi_website"><a target="_blank" href="<%= website_url%>" ><%= website%></a></div>'}e+="</div></div>";var b=_.template(e);return b};wdi_front.getHeaderTemplate=function(){var b='<div class="wdi_header_wrapper"><div class="wdi_header_img_wrap"><img src="<%=feed_thumb%>"></div><div class="wdi_header_text"><%=feed_name%></div><div class="wdi_clear"></div>';var a=_.template(b);return a};wdi_front.addFilter=function(e,g){var f=window["wdi_feed_"+g];var d=f.dataCount;if(d<2){return}if(f.nowLoadingImages!=false){return}else{var c=jQuery("#wdi_feed_"+f.feed_row.wdi_feed_counter+'_users [user_index="'+e+'"]');c.find(".wdi_filter_overlay").toggleClass("wdi_filter_active_bg");c.find(".wdi_header_user_text h3").toggleClass("wdi_filter_active_col");c.find(".wdi_media_info").toggleClass("wdi_filter_active_col");c.find(".wdi_follow_btn").toggleClass("wdi_filter_active_col");f.customFilterChanged=true;if(f.userSortFlags[e]["flag"]==false){f.userSortFlags[e]["flag"]=true}else{f.userSortFlags[e]["flag"]=false}var a=0;for(var b=0;b<f.userSortFlags.length;b++){if(f.userSortFlags[b]["flag"]==true){a++}}if(f.feed_row.feed_display_view=="pagination"){f.resIndex=0}if(a!=0){wdi_front.filterData(f);wdi_front.displayFeed(f)}else{f.customFilteredData=f.dataStorageList;wdi_front.displayFeed(f)}if(f.feed_row.feed_display_view=="pagination"){f.paginator=Math.ceil((f.imageIndex)/parseInt(f.feed_row.pagination_per_page_number));f.currentPage=f.paginator;wdi_front.updatePagination(f,"custom",1);jQuery("#wdi_first_page").removeClass("wdi_disabled");jQuery("#wdi_last_page").addClass("wdi_disabled")}}};wdi_front.filterData=function(c){var d=c.userSortFlags;c.customFilteredData=[];for(var b=0;b<c.dataStorageList.length;b++){for(var a=0;a<d.length;a++){if(((typeof c.dataStorageList[b]["user"]["id"]!="undefined"&&c.dataStorageList[b]["user"]["id"]==d[a]["id"])||c.dataStorageList[b]["wdi_hashtag"]==d[a]["name"])&&d[a]["flag"]==true){c.customFilteredData.push(c.dataStorageList[b])}}}};wdi_front.applyFilters=function(c){for(var b=0;b<c.userSortFlags.length;b++){if(c.userSortFlags[b]["flag"]==true){var a=jQuery("#wdi_feed_"+c.feed_row.wdi_feed_counter+'[user_index="'+b+'"]');wdi_front.addFilter(b,c.feed_row.wdi_feed_counter);wdi_front.addFilter(b,c.feed_row.wdi_feed_counter)}}};wdi_front.getImgCount=function(b){var d=b.dataStorage;var c=0;for(var a=0;a<d.length;a++){c+=d[a].length}return c};wdi_front.parseLighboxData=function(k,m){var g=k.dataStorage;var l=k.feed_row.sort_images_by;var a=k.feed_row.display_order;var h=wdi_front.sortingOperator(l,a);var f=[];var b=[];var e={};if(m==true){f=k.customFilteredData}else{for(var d=0;d<g.length;d++){for(var c=0;c<g[d].length;c++){f.push(g[d][c])}}f.sort(h)}for(d=0;d<f.length;d++){e={alt:"",avg_rating:"",comment_count:f[d]["comments"]["count"],date:wdi_front.convertUnixDate(f[d]["created_time"]),description:wdi_front.getDescription((f[d]["caption"]!==null)?wdi_front.escape_tags(f[d]["caption"]["text"]):""),filename:wdi_front.getFileName(f[d]),filetype:wdi_front.getFileType(f[d]),hit_count:"0",id:f[d]["id"],image_url:f[d]["link"],number:0,rate:"",rate_count:"0",username:f[d]["user"]["username"],profile_picture:f[d]["user"]["profile_picture"],thumb_url:f[d]["link"]+"media/?size=t",comments_data:f[d]["comments"]["data"],images:f[d]["images"],carousel_media:(typeof f[d]["carousel_media"]!=="undefined")?f[d]["carousel_media"]:null};b.push(e)}return b};wdi_front.convertUnixDate=function(b){var c=parseInt(b);var a=new Date(0);a.setUTCSeconds(c);var d=a.getFullYear()+"-"+a.getMonth()+"-"+a.getDate();d+=" "+a.getHours()+":"+a.getMinutes();return d};wdi_front.getDescription=function(a){a=a.replace(/\r?\n|\r/g," ");return a};wdi_front.getFileName=function(d){var c=d.link;var b=d.type;if(b==="video"&&d.hasOwnProperty("videos")){return d.videos["standard_resolution"]["url"]}else{var a=c.split("/");return a[a.length-2]}};wdi_front.getFileType=function(a){if(a.type=="video"&&a.hasOwnProperty("videos")){return"EMBED_OEMBED_INSTAGRAM_VIDEO"}else{return"EMBED_OEMBED_INSTAGRAM_IMAGE"}};wdi_front.array_max=function(d){var a=d[0];var b=0;for(var c=1;c<d.length;c++){if(a<d[c]){a=d[c];b=c}}return{value:a,index:b}};wdi_front.array_min=function(d){var c=d[0];var a=0;for(var b=1;b<d.length;b++){if(c>d[b]){c=d[b];a=b}}return{value:c,index:a}};wdi_front.activeUsersCount=function(c){var a=0;for(var b=0;b<c.usersData.length;b++){if(c.usersData[b].finished!="finished"){a++}}return a};wdi_front.checkMediaResponse=function(a,b){if(a!=""&&typeof a!="undefined"&&a!=null&&a.meta["code"]===400&&a.meta["error_type"]==="APINotAllowedError"){return a}if(a==""||typeof a=="undefined"||a==null){errorMessage=wdi_front_messages.connection_error;wdi_front.show_alert(errorMessage,a,b);return false}if(a.meta["code"]!=200){errorMessage=a.meta["error_message"];wdi_front.show_alert(errorMessage,a,b);return false}return a};wdi_front.stripHashtag=function(a){switch(a[0]){case"#":return a.substr(1,a.length);break;default:return a;break}};wdi_front.getInputType=function(a){switch(a[0]){case"#":return"hashtag";break;case"%":return"location";break;default:return"user";break}};wdi_front.regexpTestCaption=function(h,e){var d=false,b=false,f=[],g=e.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&"),c=new RegExp("(?:^|\\s)"+g+"(?:^|\\s)"),a=new RegExp("(?:^|\\s)"+g,"g");if(c.exec(h)!=null){d=true}while((match=a.exec(h))!=null){if(match.index==h.length-e.length-1){b=true}}if(d==true||b==true){return true}else{return false}};wdi_front.replaceNewLines=function(c){var b="vUkCJvN2ps3t",a=[],g;c=c.replace(/\r?\n|\r/g,b);g=new RegExp(b,"g");while((match=g.exec(c))!=null){a.push(match.index)}var f=c.split(b);var e=0;for(var d=0;d<f.length;d++){if(f[d]==""){e++}else{e=0}if(e>0){f.splice(d,1);e--;d--}}c=f.join(" ");return c};wdi_front.isEmptyObject=function(a){for(var b in a){if(a.hasOwnProperty(b)){return false}}return true};var WDIFeed=function(a){this["data"]=a.data;this["dataCount"]=a.dataCount;this["feed_row"]=a.feed_row;this["usersData"]=a.usersData;_this=this;this.set_images_loading_flag=function(b){window.addEventListener("load",function(){b.nowLoadingImages=false})};this.set_images_loading_flag(_this)};WDIFeed.prototype.conditionalFilter=function(a,c){var d=this,b=d.feed_row.conditional_filter_type,e=d.feed_row.conditional_filters;if(c.ignoreFiltering==true){}else{a=this.avoidDuplicateMedia(a)}if(!wdi_front.isJsonString(e)){return a}else{e=JSON.parse(e);if(e.length==0){return a}}if(d.feed_row.conditional_filter_enable=="0"){return a}d.instagramRequestCounter++;switch(b){case"AND":a=this.applyANDLogic(a,e,d);break;case"OR":a=this.applyORLogic(a,e,d);break;case"NOR":a=this.applyNORLogic(a,e,d);break;default:break}return a};WDIFeed.prototype.applyANDLogic=function(a,d){var c=this;for(var b=0;b<d.length;b++){a=this.filterResponse(a,d[b])}return a};WDIFeed.prototype.applyORLogic=function(d,c){var h=this;var a=[],g,j=[],f,b;for(var e=0;e<c.length;e++){g=this.filterResponse(d,c[e]);a=a.concat(g.data);g={}}for(e=0;e<a.length;e++){b=a[e];if(!this.mediaExists(b,j)&&!this.mediaExists(b,h.dataStorageList)){j.push(b)}}f={data:j,meta:d.meta,pagination:d.pagination};return f};WDIFeed.prototype.applyNORLogic=function(c,h){var f=c,g=this,b=this.applyORLogic(c,h,g),d=[],a;for(var e=0;e<f.data.length;e++){if(!this.mediaExists(f.data[e],b.data)){d.push(f.data[e])}}a={data:d,meta:f.meta,pagination:f.pagination};return a};WDIFeed.prototype.mediaExists=function(b,c){for(var a=0;a<c.length;a++){if(b.id==c[a]["id"]){return true}}return false};WDIFeed.prototype.filterResponse=function(a,b){switch(b.filter_type){case"hashtag":return this.filterByHashtag(a,b);break;case"username":return this.filterByUsername(a,b);break;case"mention":return this.filterByMention(a,b);break;case"description":return this.filterByDescription(a,b);break;case"location":return this.filterByLocation(a,b);break;case"url":return this.filterByUrl(a,b);break}};WDIFeed.prototype.filterByHashtag=function(b,g){var d=[],f,h,a;for(var e=0;e<b.data.length;e++){h=b.data[e];for(var c=0;c<h.tags.length;c++){tag=h.tags[c];if(tag.toLowerCase()==g.filter_by.toLowerCase()){d.push(h)}}}a={data:d,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.filterByUsername=function(b,e){var c=[],f,a;for(var d=0;d<b.data.length;d++){f=b.data[d];if(f.user.username.toLowerCase()==e.filter_by.toLowerCase()){c.push(f)}}a={data:c,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.filterByMention=function(b,e){var c=[],f,g,a;for(var d=0;d<b.data.length;d++){f=b.data[d];if(f.caption!==null){g=f.caption["text"].toLowerCase();if(g.indexOf("@"+e.filter_by.toLowerCase())!=-1){c.push(f)}}}a={data:c,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.filterByDescription=function(c,f){var d=[],g,h,b;for(var e=0;e<c.data.length;e++){g=c.data[e];if(g.caption!==null){h=g.caption["text"].toLowerCase();h=wdi_front.replaceNewLines(h);var a=f.filter_by.toLowerCase();if(wdi_front.regexpTestCaption(h,a)){d.push(g)}}}b={data:d,meta:c.meta,pagination:c.pagination};return b};WDIFeed.prototype.filterByLocation=function(b,f){var c=[],g,e,a;for(var d=0;d<b.data.length;d++){g=b.data[d];if(g.location!==null){e=g.location["id"];if(e==f.filter_by){c.push(g)}}}a={data:c,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.filterByUrl=function(b,e){var c=[],g,h,a,f;e.filter_by=this.getIdFromUrl(e.filter_by);for(var d=0;d<b.data.length;d++){g=b.data[d];if(g.link!==null){h=this.getIdFromUrl(g.link);if(h==e.filter_by){c.push(g)}}}a={data:c,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.getIdFromUrl=function(a){var c=a.split("/"),d=false;for(var b=0;b<c.length;b++){if(c[b]=="p"){if(typeof c[b+1]!="undefined"){d=c[b+1];break}}}return d};WDIFeed.prototype.avoidDuplicateMedia=function(b){var e=b.data,d=[],a={};if(typeof e=="undefined"){e=[]}for(var c=0;c<e.length;c++){if(!this.mediaExists(e[c],this.dataStorageList)&&!this.mediaExists(e[c],d)&&!this.mediaExists(e[c],this.conditionalFilterBuffer)){d.push(e[c])}}this.conditionalFilterBuffer=this.conditionalFilterBuffer.concat(d);a={data:d,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.storeRawData=function(c,a){var e=this;if(typeof this[a]=="object"&&typeof this[a].length=="number"){for(var b=0;b<c.length;b++){var d="";if(wdi_front.isHashtag(c[b].user_id)){if(typeof c[b].pagination.cursors!=="undefined"){d=c[b].pagination.cursors.after}}else{if(e.feed_row.liked_feed=="liked"){d=c[b].pagination.next_max_like_id;if(typeof d=="undefined"){d=""}}else{if(c[b].pagination==null){c[b].pagination=[]}d=c[b].pagination.next_max_id;if(typeof d=="undefined"){d=""}}}if(typeof this[a][b]=="undefined"){this[a].push({data:c[b].data,index:0,locked:false,hash_id:d,usersDataFinished:false,userId:c[b].user_id,length:function(){return this.data.length-this.index},getData:function(g){var h=this.data.slice(this.index,this.index+g);this.index+=Math.min(g,this.length());if(this.index==this.data.length&&this.locked==true&&this.usersDataFinished==false){for(var f=0;f<e.usersData.length;f++){if(e.usersData[f]["user_id"]==this.userId){e.usersData[f].finished="finished";this.usersDataFinished=true;break}}}return h}})}else{if(this[a][b].locked==false){if(d!=this[a][b].hash_id){this[a][b].data=this[a][b].data.concat(c[b].data);this[a][b].hash_id=d}else{this[a][b].locked=true}}}}}};wdi_front.updateUsersIfNecessary=function(c){var d=c.feed_users;var a=false;for(var b=0;b<d.length;b++){if("#"==d[b].username.substr(0,1)){d[b].id=d[b].username;continue}if(""==d[b].id||"username"==d[b].id){a=true;c.instagram.searchForUsersByName(d[b].username,{success:function(i){if(typeof i.meta!="undefined"&&typeof i.meta.error_type!="undefined"){wdi_front.show_alert(false,i,c)}if(i.meta.code==200&&i.data.length>0){var l=false;for(var g=0;g<i.data.length;g++){if(i.data[g].username==i.args.username){l=true;break}}if(l){for(var h=0;h<d.length;h++){if(i.data[g].username==d[h].username){d[h].id=i.data[g].id}}}}var f=false;for(var e=0;e<d.length;e++){if(d[e].id==""||d[e].id=="username"){f=true;break}}if(!f){c.feed_row.feed_users=JSON.stringify(d);wdi_front.init(c)}},username:d[b].username})}}return a};if(typeof wdi_ajax.ajax_response!="undefined"){jQuery(document).one("ajaxStop",function(){if(wdi_front.type!="not_declared"){wdi_front.clickOrTouch=wdi_front.detectEvent();wdi_front.globalInit()}else{return}})}else{jQuery(document).ready(function(){if(wdi_front.type!="not_declared"){wdi_front.clickOrTouch=wdi_front.detectEvent();wdi_front.globalInit()}else{return}})}jQuery(document).ready(function(){setTimeout(function(){if(wdi_front_messages.show_alerts==="1"&&jQuery(".wdi_check_fontawesome .fa-instagram").prop("tagName")!=="I"){console.log("Font Awesome is not loaded properly. Please ask for support https://wordpress.org/support/plugin/wd-instagram-feed/")}},2000)});function wdi_extractHostname(b){if(typeof b==="undefined"||b===""){return""}var a=b.replace(/(^\w+:|^)\/\//,"");return a};
1
+ if(typeof wdi_front=="undefined"){wdi_front={type:"not_declared"}}wdi_front.detectEvent=function(){var a=(/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));if(a){return"touchend"}else{return"click"}};var wdi_error_show=false;wdi_front.escape_tags=function(e){var b=/</g,c=/>/g,d=/'/g,a=/"/g;if(typeof e=="undefined"){e=""}e=e.toString().replace(b,"&lt;").replace(c,"&gt;").replace(d,"&#39;").replace(a,"&#34;");return e};wdi_front.show_alert=function(e,b,f){f=jQuery("#wdi_feed_"+f.feed_row.wdi_feed_counter);if(b.meta["code"]===400&&b.meta["error_type"]==="APINotAllowedError"){if(typeof b.wdi_current_feed_name!="undefined"){var a=b.wdi_current_feed_name;var d=f.find(".wdi_private_feed_names");d.html(a);f.find(".wdi_private_feed_error").removeClass("wdi_hidden")}f.find(".wdi_spinner").remove()}if(typeof f!="undefined"&&b.meta["error_type"]!="APINotAllowedError"){f.find(".wdi_spinner").remove();wdi_error_show=true;var c=f.find(".wdi_js_error");var g=f.find(".wdi_token_error");if(b!=false&&typeof b.meta!=undefined&&b.meta.error_type==="OAuthAccessTokenException"){g.removeClass("wdi_hidden");if(wdi_front_messages.wdi_token_error_flag!="1"){jQuery.ajax({type:"POST",url:wdi_url.ajax_url,dataType:"json",data:{action:"wdi_token_flag",wdi_token_flag_nonce:wdi_front_messages.wdi_token_flag_nonce},success:function(h){}})}}else{c.removeClass("wdi_js_error");c.addClass("wdi_js_error_no_animate");jQuery(".wdi_js_error_no_animate").show()}if(wdi_front_messages.show_alerts){}else{console.log("%c"+e,"color:#cc0000;")}}wdi_error_show=true};wdi_front.globalInit=function(){var a=wdi_front.feed_counter;if(typeof wdi_ajax.ajax_response!="undefined"){var c=wdi_feed_counter_init.wdi_feed_counter_init}else{var c=0}for(var b=c;b<=a;b++){if(jQuery("#wdi_feed_"+b).length===0){continue}var d=new WDIFeed(window["wdi_feed_"+b]);d.instagram=new WDIInstagram();d.instagram.filterArguments={feed:d};d.instagram.filters=[{where:"getUserRecentMedia",what:function(f,g,e){return g.feed.conditionalFilter(f,e)}},{where:"getTagRecentMedia",what:function(f,g,e){return g.feed.conditionalFilter(f,e)}},{where:"getRecentLikedMedia",what:function(f,g,e){return g.feed.conditionalFilter(f,e)}},{where:"requestByUrl",what:function(f,g,e){return g.feed.conditionalFilter(f,e)}}];d.instagram.addToken(d.feed_row["access_token"]);wdi_front.access_token=d.feed_row["access_token"];d.dataStorageRaw=[];d.dataStorage=[];d.dataStorageList=[];d.allResponseLength=0;d.currentResponseLength=0;d.temproraryUsersData=[];d.removedUsers=0;d.nowLoadingImages=true;d.imageIndex=0;d.resIndex=0;d.currentPage=1;d.userSortFlags=[];d.customFilterChanged=false;d.maxConditionalFiltersRequestCount=10;d.instagramRequestCounter=0;d.mediaRequestsDone=false;d.conditionalFilterBuffer=[];d.stopInfiniteScrollFlag=false;if(d.feed_row.feed_type=="masonry"){d.displayedData=[]}if(d.feed_row.feed_display_view=="pagination"){d.feed_row.resort_after_load_more=0;if(d.feed_row.feed_type!="image_browser"){d.feed_row.load_more_number=parseInt(d.feed_row.pagination_per_page_number);d.feed_row.number_of_photos=(1+parseInt(d.feed_row.pagination_preload_number))*d.feed_row.load_more_number}else{d.feed_row.number_of_photos=1+parseInt(d.feed_row.image_browser_preload_number);d.feed_row.load_more_number=parseInt(d.feed_row.image_browser_load_number)}d.freeSpaces=(Math.floor(d.feed_row.pagination_per_page_number/d.feed_row.number_of_columns)+1)*d.feed_row.number_of_columns-d.feed_row.pagination_per_page_number}else{d.freeSpaces=0}d.galleryBox=function(e){wdi_spider_createpopup(wdi_url.ajax_url+"?gallery_id="+this.feed_row.id+"&image_id="+e,this.feed_row.wdi_feed_counter,this.feed_row.lightbox_width,this.feed_row.lightbox_height,1,"testpopup",5,this,e)};wdi_responsive.columnControl(d);if(d.feed_row.feed_type=="masonry"){jQuery(window).trigger("resize")}wdi_front.bindEvents(d);window["wdi_feed_"+b]=d;wdi_front.init(d)}};wdi_front.init=function(d){jQuery(".wdi_js_error").hide();d.photoCounter=d.feed_row.number_of_photos;if(d.feed_row.liked_feed=="liked"){d.feed_users=["self"]}else{if(wdi_front.isJsonString(d.feed_row.feed_users)){d.feed_users=JSON.parse(d.feed_row.feed_users)}else{wdi_front.show_alert(wdi_front_messages.invalid_users_format,false,d);return}}var e=[];if(typeof window.wdi_all_tags!=="undefined"){e=window.wdi_all_tags}for(var a=0;a<d.feed_users.length;a++){if(d.feed_users[a].username[0]==="#"&&typeof d.feed_users[a].tag_id!=="undefined"){e[d.feed_users[a].tag_id]=d.feed_users[a]}}window.wdi_all_tags=e;d.dataCount=d.feed_users.length;var b=wdi_front.getFeedItemResolution(d);d.feedImageResolution=b.image;d.feedVideoResolution=b.video;for(var c=0;c<d.dataCount;c++){wdi_front.instagramRequest(c,d)}if(d.feed_row.number_of_photos>0){wdi_front.ajaxLoader(d)}if(d.feed_row["display_header"]==="1"){wdi_front.show("header",d)}if(d.feed_row["show_usernames"]==="1"){wdi_front.show("users",d)}};wdi_front.getFeedItemResolution=function(g){var d={image:"standard_resolution",video:"standard_resolution"};if(g.feed_row.feed_resolution==="thumbnail"){return{image:"thumbnail",video:"low_bandwidth"}}else{if(g.feed_row.feed_resolution==="low"){return{image:"low_resolution",video:"low_resolution"}}else{if(g.feed_row.feed_resolution==="standard"){return{image:"standard_resolution",video:"standard_resolution"}}}}var c=jQuery("#wdi_feed_"+g.feed_row.wdi_feed_counter).find(".wdi_feed_wrapper");c.append('<div class="wdi_feed_item" id="wdi_feed_item_example"></div>');wdi_responsive.columnControl(g,1);var b=c.attr("wdi-res").split("wdi_col_");c.find("#wdi_feed_item_example").remove();if(b.length!==2){return d}var a=parseInt(b[1]);if(a<=0){return d}var f=(c.width()/a)-10;var e=d;if(f<=150){e.image="thumbnail";e.video="low_bandwidth"}else{if(f>150&&f<=320){e.image="low_resolution";e.video="low_resolution"}else{e.image="standard_resolution";e.video="standard_resolution"}}return e};wdi_front.isJsonString=function(b){try{JSON.parse(b)}catch(a){return false}return true};wdi_front.instagramRequest=function(d,b){var a=b.feed_users,c=this;if(typeof a[d]==="string"&&a[d]==="self"){b.instagram.getRecentLikedMedia({success:function(e){if(typeof e.meta!="undefined"&&typeof e.meta.error_type!="undefined"){wdi_front.show_alert(false,e,b)}b.mediaRequestsDone=true;e=c.checkMediaResponse(e,b);if(e!=false){c.saveSelfUserData(e,b)}}})}else{if(this.getInputType(a[d]["username"])=="hashtag"){b.instagram.getTagRecentMedia(this.stripHashtag(a[d]["username"]),{success:function(e){if(typeof e.meta!="undefined"&&typeof e.meta.error_type!="undefined"){wdi_front.show_alert(false,e,b)}b.mediaRequestsDone=true;e=c.checkMediaResponse(e,b);if(e!=false){c.saveUserData(e,b.feed_users[d],b)}}},null,b.feed_row.hashtag_top_recent)}else{if(this.getInputType(a[d]["username"])=="user"){b.instagram.getSelfRecentMedia({success:function(e){if(typeof e.meta!="undefined"&&typeof e.meta.error_type!="undefined"){e.wdi_current_feed_name=a[d].username;wdi_front.show_alert(false,e,b)}b.mediaRequestsDone=true;e=c.checkMediaResponse(e,b);if(e!=false){c.saveUserData(e,b.feed_users[d],b)}}})}}}};wdi_front.isHashtag=function(a){return(a[0]==="#")};wdi_front.saveUserData=function(d,a,b){d.username=a.username;d.user_id=a.id;if(d.user_id[0]==="#"){d.data=wdi_front.appendRequestHashtag(d.data,d.user_id)}b.usersData.push(d);b.currentResponseLength=wdi_front.getArrayContentLength(b.usersData,"data");b.allResponseLength+=b.currentResponseLength;if(b.dataCount==b.usersData.length){if(b.currentResponseLength<b.feed_row.number_of_photos&&!wdi_front.userHasNoPhoto(b)){wdi_front.loadMore("initial-keep",b)}else{wdi_front.displayFeed(b);wdi_front.applyFilters(b);if(!wdi_front.activeUsersCount(b)){if(b.feed_row.feed_display_view=="load_more_btn"){var c=jQuery("#wdi_feed_"+b.feed_row.wdi_feed_counter);c.find(".wdi_load_more").addClass("wdi_hidden");c.find(".wdi_spinner").addClass("wdi_hidden")}}}}};wdi_front.saveSelfUserData=function(c,a){c.username="";c.user_id="";a.usersData.push(c);a.currentResponseLength=wdi_front.getArrayContentLength(a.usersData,"data");a.allResponseLength+=a.currentResponseLength;if(a.dataCount==a.usersData.length){if(a.currentResponseLength<a.feed_row.number_of_photos&&!wdi_front.userHasNoPhoto(a)){wdi_front.loadMore("initial-keep",a)}else{wdi_front.displayFeed(a);wdi_front.applyFilters(a);if(!wdi_front.activeUsersCount(a)){if(a.feed_row.feed_display_view=="load_more_btn"){var b=jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter);b.find(".wdi_load_more").addClass("wdi_hidden");b.find(".wdi_spinner").addClass("wdi_hidden")}}}}};wdi_front.userHasNoPhoto=function(c,e){var a=0;var d=c.usersData;if(typeof e!="undefined"){d=e}for(var b=0;b<d.length;b++){if(typeof d[b]["pagination"]=="undefined"){d[b]["pagination"]=[]}if(c.feed_row.liked_feed==="liked"){if(typeof d[b]["pagination"]["next_max_like_id"]=="undefined"){a++}}else{if(typeof d[b]["pagination"]["next_max_id"]=="undefined"){a++}}}if(a==d.length){return 1}else{return 0}};wdi_front.appendRequestHashtag=function(c,b){for(var a=0;a<c.length;a++){c[a]["wdi_hashtag"]=b}return c};wdi_front.displayFeed=function(c,b){if(c.customFilterChanged==false){var d=wdi_front.feedSort(c,b)}var a=c.customFilterChanged;if(c.customFilterChanged==true){var d=c.customFilteredData;c.parsedData=wdi_front.parseLighboxData(c,true)}if(c.feed_row.resort_after_load_more!="1"){if(c.customFilterChanged==false){c.dataStorageList=c.dataStorageList.concat(d)}}else{if(c.customFilterChanged==false){c.dataStorageList=d}}if(c.feed_row.feed_type=="masonry"){wdi_front.masonryDisplayFeedItems(d,c)}if(c.feed_row.feed_type=="thumbnails"||c.feed_row.feed_type=="blog_style"||c.feed_row.feed_type=="image_browser"){wdi_front.displayFeedItems(d,c)}var e=wdi_front.getDataLength(c);if(e<c.photoCounter&&!a&&c.instagramRequestCounter<=c.maxConditionalFiltersRequestCount&&!wdi_front.allDataHasFinished(c)){wdi_front.loadMore("",c)}else{wdi_front.allImagesLoaded(c)}if(c.instagramRequestCounter>c.maxConditionalFiltersRequestCount){wdi_front.allImagesLoaded(c);if(d.length==0){c.stopInfiniteScrollFlag=true}}if(c.feed_row.feed_display_view=="pagination"&&c.currentPage<c.paginator){jQuery("#wdi_feed_"+c.feed_row.wdi_feed_counter).find("#wdi_last_page").removeClass("wdi_disabled")}c.instagramRequestCounter=0;c.conditionalFilterBuffer=[];wdi_front.updateUsersImages(c)};wdi_front.updateUsersImages=function(a){var b=jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter).find(".wdi_single_user .wdi_user_img_wrap img");b.each(function(){if(jQuery(this).attr("src")==wdi_url.plugin_url+"images/missing.png"||jQuery(this).attr("src")==""){if(a.feed_row.liked_feed=="liked"){return}for(var c=0;c<a.usersData.length;c++){if(a.usersData[c]["username"]==jQuery(this).parent().parent().find("h3").text()){if(a.usersData[c]["data"].length!=0){jQuery(this).attr("src",a.usersData[c]["data"][0]["images"]["thumbnail"]["url"])}}}}})};wdi_front.masonryDisplayFeedItems=function(d,h){var b=[];var p=[];if(jQuery("#wdi_feed_"+h.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length==0){return}jQuery("#wdi_feed_"+h.feed_row.wdi_feed_counter+" .wdi_masonry_column").each(function(){if(h.feed_row.resort_after_load_more==1){jQuery(this).html("");h.imageIndex=0}if(h.customFilterChanged==true){jQuery(this).html("");h.imageIndex=0}if(h.feed_row.feed_display_view=="pagination"){b.push(0)}else{b.push(jQuery(this).height())}p.push(jQuery(this))});if(h.customFilterChanged==true){h.customFilterChanged=false}for(var e=0;e<d.length;e++){h.displayedData.push(d[e]);if(d[e]["type"]=="image"){var n=wdi_front.getPhotoTemplate(h)}else{if(d[e].hasOwnProperty("videos")||d[e]["type"]=="video"){var n=wdi_front.getVideoTemplate(h)}else{var n=wdi_front.getSliderTemplate(h)}}var g=d[e];var o=wdi_front.createObject(g,h);var f=n(o);var m=wdi_front.array_min(b);var l=wdi_front.getImageResolution(d[e]);p[m.index].html(p[m.index].html()+f);b[m.index]+=p[m.index].width()*l;h.imageIndex++;if(h.feed_row.feed_display_view=="pagination"){if((e+1)%h.feed_row.pagination_per_page_number===0){h.resIndex+=h.freeSpaces+1}else{h.resIndex++}}}h.wdi_loadedImages=0;var j=false;h.wdi_load_count=e;var a=h.feed_row.wdi_feed_counter;var k=jQuery("#wdi_feed_"+a+" img.wdi_img").on("load",function(){h.wdi_loadedImages++;c();if(j===false){wdi_responsive.columnControl(h,1);j=true}});c();function c(){if(h.wdi_load_count===h.wdi_loadedImages&&h.wdi_loadedImages!=0){h.loadedImages=0;h.wdi_load_count=0;wdi_front.allImagesLoaded(h)}}if(h.paginatorNextFlag==true){wdi_front.updatePagination(h,"next")}h.infiniteScrollFlag=false};wdi_front.getImageResolution=function(c){var d=c.images["standard_resolution"]["width"];var b=c.images["standard_resolution"]["height"];var a=b/d;return a};wdi_front.getDataLength=function(b,d){var c=0;if(typeof d==="undefined"){for(var a=0;a<b.dataStorage.length;a++){c+=b.dataStorage[a].length}}else{for(var a=0;a<d.length;a++){c+=d[a].length}}return c};wdi_front.getArrayContentLength=function(d,c){var b=0;for(var a=0;a<d.length;a++){if(d[a]["finished"]=="finished"){continue}b+=d[a][c].length}return b};wdi_front.displayFeedItems=function(d,j){if(jQuery("#wdi_feed_"+j.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length==0){return}var a=j.feed_row.wdi_feed_counter;var l=jQuery("#wdi_feed_"+a+" .wdi_feed_wrapper");if(j.feed_row.resort_after_load_more==="1"){l.html("");j.imageIndex=0}if(j.customFilterChanged==true){l.html("");j.imageIndex=0;j.customFilterChanged=false}var g=wdi_front.getImgCount(j)-d.length-1;if(j.feed_row.feed_display_view=="pagination"){var b=j.feed_row.load_more_number;if(j.feed_row.feed_type=="image_browser"){b=1}if(jQuery("#wdi_feed_"+j.feed_row.wdi_feed_counter+' [wdi_page="'+(j.currentPage-1)+'"]').length<b||d.length==0){j.currentPage=(--j.currentPage<=1)?1:j.currentPage}}for(var e=0;e<d.length;e++){if(d[e]["type"]=="image"){var m=wdi_front.getPhotoTemplate(j)}else{if(d[e].hasOwnProperty("videos")){var m=wdi_front.getVideoTemplate(j)}else{var m=wdi_front.getSliderTemplate(j)}}var h=d[e];var n=wdi_front.createObject(h,j);var f=m(n);l.html(l.html()+f);j.imageIndex++;if(j.feed_row.feed_display_view=="pagination"){if((e+1)%j.feed_row.pagination_per_page_number===0){j.resIndex+=j.freeSpaces+1}else{j.resIndex++}}}j.wdi_loadedImages=0;var k=false;j.wdi_load_count=e;var a=j.feed_row.wdi_feed_counter;var l=jQuery("#wdi_feed_"+a+" img.wdi_img").on("load",function(){j.wdi_loadedImages++;c();if(k===false){wdi_responsive.columnControl(j,1);k=true}});function c(){if(j.wdi_load_count===j.wdi_loadedImages&&j.wdi_loadedImages!=0){j.loadedImages=0;j.wdi_load_count=0;wdi_front.allImagesLoaded(j)}}if(j.paginatorNextFlag==true){wdi_front.updatePagination(j,"next")}j.infiniteScrollFlag=false};wdi_front.checkFeedFinished=function(b){for(var a=0;a<b.usersData.length;a++){if(typeof b.usersData[a]["finished"]=="undefined"){return false}}return true};wdi_front.sortingOperator=function(c,b){var a;switch(c){case"date":switch(b){case"asc":a=function(e,d){return(e.created_time>d.created_time)?1:-1};break;case"desc":a=function(e,d){return(e.created_time>d.created_time)?-1:1};break}break;case"likes":switch(b){case"asc":a=function(e,d){return(e.likes["count"]<d.likes["count"])?-1:1};break;case"desc":a=function(e,d){return(e.likes["count"]<d.likes["count"])?1:-1};break}break;case"comments":switch(b){case"asc":a=function(e,d){return(e.comments["count"]<d.comments["count"])?-1:1};break;case"desc":a=function(e,d){return(e.comments["count"]<d.comments["count"])?1:-1};break}break;case"random":a=function(e,d){var f=Math.random();return(f>0.5)?1:-1};break}return a};wdi_front.feedSort=function(e,b){var d=e.feed_row.sort_images_by;var c=e.feed_row.display_order;if(e.feed_row.resort_after_load_more==="1"){e.data=e.data.concat(wdi_front.smartPicker(e,b))}else{e.data=wdi_front.smartPicker(e,b)}var a=wdi_front.sortingOperator(d,c);e.data.sort(a);return e.data};wdi_front.smartPicker=function(l,c){var g=[];var a=0;var k=[];var f=Math.ceil(l.feed_row["number_of_photos"]/l.usersData.length);var b=parseInt(l.feed_row["number_of_photos"]);var n=0;if(c!=""&&typeof c!="undefined"&&c!=null){b=parseInt(c);f=Math.ceil(b/wdi_front.activeUsersCount(l))}var j=function(p,i){return(p.data.length>i.data.length)?1:-1};var e=function(p,i){return(p.length()>i.length())?1:-1};l.storeRawData(l.usersData,"dataStorageRaw");var o=l.dataStorageRaw.sort(e);var h=l.usersData.sort(j);for(var d=0;d<h.length;d++){n+=f;if(o[d].length()<=n){n-=o[d].length();g.push(o[d].getData(o[d].length()));a+=g[g.length-1].length}else{if(a+n>b){n=b-a}var m=[];if(l.auto_trigger===false){m=m.concat(o[d].getData(n))}else{if(m.length+wdi_front.getDataLength(l)+wdi_front.getDataLength(l,g)<l.feed_row["number_of_photos"]){m=m.concat(o[d].getData(n))}}n=0;a+=m.length;g.push(m)}}for(d=0;d<g.length;d++){if(typeof l.dataStorage[d]==="undefined"){l.dataStorage.push(g[d])}else{l.dataStorage[d]=l.dataStorage[d].concat(g[d])}}l.parsedData=wdi_front.parseLighboxData(l);for(d=0;d<g.length;d++){k=k.concat(g[d])}return k};wdi_front.createObject=function(e,h){var j=(e.caption!=null)?e.caption["text"]:"&nbsp";var i="";if(e.type=="video"){i=e.hasOwnProperty("videos")?e.videos[h.feedVideoResolution]["url"]:""}if(typeof e.images[h.feedImageResolution]=="undefined"){var f=wdi_url.plugin_url+"images/missing.png"}else{var f=e.images[h.feedImageResolution].url}var a=h.imageIndex;var b="square";var d=e.images["standard_resolution"]["height"];var g=e.images["standard_resolution"]["width"];if(d>g){b="portrait"}else{if(d<g){b="landscape"}}var c={id:e.id,caption:wdi_front.escape_tags(j),image_url:f,likes:e.likes["count"],comments:e.comments["count"],wdi_index:a,wdi_res_index:h.resIndex,wdi_media_user:e.user["username"],link:e.link,video_url:i,wdi_username:e.user["username"],wdi_shape:b};return c};wdi_front.setPage=function(c){var b=c.feed_row.feed_display_view;var e=c.feed_row.feed_type;if(b!="pagination"){return""}var a=c.imageIndex;if(e=="image_browser"){var d=1}else{var d=Math.abs(c.feed_row.pagination_per_page_number)}c.paginator=Math.ceil((a+1)/d);return c.paginator};wdi_front.getPhotoTemplate=function(g){var e=wdi_front.setPage(g);var j="";var k="";var l="";var d="";var m="fa-arrows-alt";var c="";if(g.feed_row.feed_type=="blog_style"||g.feed_row.feed_type=="image_browser"){m=""}if(e!=""){k='wdi_page="'+e+'"';sourceAttr="src"}else{sourceAttr="src"}if(e!=""&&e!=1){j="wdi_hidden"}if(g.feed_row.show_username_on_thumb=="1"){c='<span class="wdi_media_user">@<%= wdi_username%></span>'}if(g.feed_row.show_full_description==1&&g.feed_row.feed_type=="masonry"){j+=" wdi_full_caption"}var f="";if(g.feed_row.feed_type!=="blog_style"){if(g.feed_row.feed_type=="masonry"){f="wdi_responsive.showMasonryCaption(jQuery(this),"+g.feed_row.wdi_feed_counter+");"}else{f="wdi_responsive.showCaption(jQuery(this),"+g.feed_row.wdi_feed_counter+");"}}switch(g.feed_row.feed_item_onclick){case"lightbox":l="onclick=wdi_feed_"+g.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":l="onclick=\"window.open ('<%= link%>','_blank')\"";d="wdi_hover_off";m="";break;case"custom_redirect":l="onclick=\"window.open ('"+g.feed_row.redirect_url+"','_self')\"";d="wdi_hover_off";m="";break;case"none":l="";d="wdi_cursor_off wdi_hover_off";m=""}var h="<%= wdi_shape == 'square' ? 'wdi_shape_square' : (wdi_shape == 'portrait' ? 'wdi_shape_portrait' : (wdi_shape == 'landscape' ? 'wdi_shape_landscape' : 'wdi_shape_square') ) %>";var b=g.feed_row.wdi_feed_counter;var a='<div class="wdi_feed_item '+j+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> '+k+' wdi_type="image" id="wdi_'+b+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img '+h+'"><img class="wdi_img" '+sourceAttr+'="<%=image_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+d+'" >'+c+'<div class="wdi_thumb_icon" '+l+' style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="fa '+m+'"></i></div></div></div></div></div></div>';if(g.feed_row["show_likes"]==="1"||g.feed_row["show_comments"]==="1"||g.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_meta">';if(g.feed_row["show_likes"]==="1"){a+='<div class="wdi_thumb_likes"><i class="fa fa-heart-o">&nbsp;<%= likes%></i></div>'}if(g.feed_row["show_comments"]==="1"){a+='<div class="wdi_thumb_comments"><i class="fa fa-comment-o">&nbsp;<%= comments%></i></div>'}a+='<div class="wdi_clear"></div>';if(g.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_title" onclick='+f+" ><%=caption%></div>"}a+="</div>"}a+="</div>";var i=_.template(a);return i};wdi_front.getSliderTemplate=function(g){var e=wdi_front.setPage(g);var j="";var k="";var l="";var d="";var m="fa-clone";var c="";if(g.feed_row.feed_type=="blog_style"||g.feed_row.feed_type=="image_browser"){m=""}if(e!=""){k='wdi_page="'+e+'"';sourceAttr="src"}else{sourceAttr="src"}if(e!=""&&e!=1){j="wdi_hidden"}if(g.feed_row.show_username_on_thumb=="1"){c='<span class="wdi_media_user">@<%= wdi_username%></span>'}if(g.feed_row.show_full_description==1&&g.feed_row.feed_type=="masonry"){j+=" wdi_full_caption"}var f="";if(g.feed_row.feed_type!=="blog_style"){if(g.feed_row.feed_type=="masonry"){f="wdi_responsive.showMasonryCaption(jQuery(this),"+g.feed_row.wdi_feed_counter+");"}else{f="wdi_responsive.showCaption(jQuery(this),"+g.feed_row.wdi_feed_counter+");"}}switch(g.feed_row.feed_item_onclick){case"lightbox":l="onclick=wdi_feed_"+g.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":l="onclick=\"window.open ('<%= link%>','_blank')\"";d="wdi_hover_off";m="fa-clone";break;case"custom_redirect":l="onclick=\"window.open ('"+g.feed_row.redirect_url+"','_self')\"";d="wdi_hover_off";m="";break;case"none":l="";d="wdi_cursor_off wdi_hover_off";m=""}var h="<%= wdi_shape == 'square' ? 'wdi_shape_square' : (wdi_shape == 'portrait' ? 'wdi_shape_portrait' : (wdi_shape == 'landscape' ? 'wdi_shape_landscape' : 'wdi_shape_square') ) %>";var b=g.feed_row.wdi_feed_counter;var a='<div class="wdi_feed_item '+j+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> '+k+' wdi_type="slideshow" id="wdi_'+b+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img '+h+'"><img class="wdi_img" '+sourceAttr+'="<%=image_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+d+'" >'+c+'<div class="wdi_thumb_icon" '+l+' style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="fa '+m+'"></i></div></div></div></div></div></div>';if(g.feed_row["show_likes"]==="1"||g.feed_row["show_comments"]==="1"||g.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_meta">';if(g.feed_row["show_likes"]==="1"){a+='<div class="wdi_thumb_likes"><i class="fa fa-heart-o">&nbsp;<%= likes%></i></div>'}if(g.feed_row["show_comments"]==="1"){a+='<div class="wdi_thumb_comments"><i class="fa fa-comment-o">&nbsp;<%= comments%></i></div>'}a+='<div class="wdi_clear"></div>';if(g.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_title" onclick='+f+" ><%=caption%></div>"}a+="</div>"}a+="</div>";var i=_.template(a);return i};wdi_front.replaceToVideo=function(b,a,c){overlayHtml="<video style='width:auto !important; height:auto !important; max-width:100% !important; max-height:100% !important; margin:0 !important;' controls=''><source src='"+b+"' type='video/mp4'>Your browser does not support the video tag. </video>";jQuery("#wdi_feed_"+c+' [wdi_index="'+a+'"] .wdi_photo_wrap_inner').html(overlayHtml);jQuery("#wdi_feed_"+c+' [wdi_index="'+a+'"] .wdi_photo_wrap_inner video').get(0).play()};wdi_front.getVideoTemplate=function(h){var f=wdi_front.setPage(h);var k="";var l="";var n="fa-play";var m="";var d="";var e;var c="";if(f!=""){l='wdi_page="'+f+'"';e="src"}else{e="src"}if(f!=""&&f!=1){k="wdi_hidden"}if(h.feed_row.show_username_on_thumb=="1"){c='<span class="wdi_media_user">@<%= wdi_username%></span>'}if(h.feed_row.show_full_description==1&&h.feed_row.feed_type=="masonry"){k+=" wdi_full_caption"}var g="";if(h.feed_row.feed_type!=="blog_style"){if(h.feed_row.feed_type=="masonry"){g="wdi_responsive.showMasonryCaption(jQuery(this),"+h.feed_row.wdi_feed_counter+");"}else{g="wdi_responsive.showCaption(jQuery(this),"+h.feed_row.wdi_feed_counter+");"}}switch(h.feed_row.feed_item_onclick){case"lightbox":m="onclick=wdi_feed_"+h.feed_row.wdi_feed_counter+".galleryBox('<%=id%>')";break;case"instagram":m="onclick=\"window.open ('<%= link%>','_blank')\"";d="wdi_hover_off";n="fa-play";break;case"custom_redirect":m="onclick=\"window.open ('"+h.feed_row.redirect_url+"','_self')\"";d="wdi_hover_off";n="";break;case"none":d="wdi_cursor_off wdi_hover_off";n="";if(h.feed_row.feed_type=="blog_style"||h.feed_row.feed_type=="image_browser"){m="onclick=wdi_front.replaceToVideo('<%= video_url%>','<%= wdi_index%>',"+h.feed_row.wdi_feed_counter+")";d="";n="fa-play"}}var i="<%= wdi_shape == 'square' ? 'wdi_shape_square' : (wdi_shape == 'portrait' ? 'wdi_shape_portrait' : (wdi_shape == 'landscape' ? 'wdi_shape_landscape' : 'wdi_shape_square') ) %>";var b=h.feed_row.wdi_feed_counter;var a='<div class="wdi_feed_item '+k+'" wdi_index=<%= wdi_index%> wdi_res_index=<%= wdi_res_index%> wdi_media_user=<%= wdi_media_user%> '+l+' wdi_type="image" id="wdi_'+b+'_<%=id%>"><div class="wdi_photo_wrap"><div class="wdi_photo_wrap_inner"><div class="wdi_photo_img '+i+'"><img class="wdi_img" '+e+'="<%=image_url%>" alt="feed_image" onerror="wdi_front.brokenImageHandler(this);"><div class="wdi_photo_overlay '+d+'" '+m+">"+c+'<div class="wdi_thumb_icon" style="display:table;width:100%;height:100%;"><div style="display:table-cell;vertical-align:middle;text-align:center;color:white;"><i class="fa '+n+'"></i></div></div></div></div></div></div>';if(h.feed_row["show_likes"]==="1"||h.feed_row["show_comments"]==="1"||h.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_meta">';if(h.feed_row["show_likes"]==="1"){a+='<div class="wdi_thumb_likes"><i class="fa fa-heart-o">&nbsp;<%= likes%></i></div>'}if(h.feed_row["show_comments"]==="1"){a+='<div class="wdi_thumb_comments"><i class="fa fa-comment-o">&nbsp;<%= comments%></i></div>'}a+='<div class="wdi_clear"></div>';if(h.feed_row["show_description"]==="1"){a+='<div class="wdi_photo_title" onclick='+g+" ><%=caption%></div>"}a+="</div>"}a+="</div>";var j=_.template(a);return j};wdi_front.bindEvents=function(a){if(jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").length==0){return}if(a.feed_row.feed_display_view=="load_more_btn"){jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" .wdi_load_more_container").on(wdi_front.clickOrTouch,function(){wdi_front.loadMore(jQuery(this).find(".wdi_load_more_wrap"))})}if(a.feed_row.feed_display_view=="pagination"){jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_next").on(wdi_front.clickOrTouch,function(){wdi_front.paginatorNext(jQuery(this),a)});jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_prev").on(wdi_front.clickOrTouch,function(){wdi_front.paginatorPrev(jQuery(this),a)});jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_last_page").on(wdi_front.clickOrTouch,function(){wdi_front.paginationLastPage(jQuery(this),a)});jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_first_page").on(wdi_front.clickOrTouch,function(){wdi_front.paginationFirstPage(jQuery(this),a)});a.paginatorNextFlag=false}if(a.feed_row.feed_display_view=="infinite_scroll"){jQuery(window).on("scroll",function(){wdi_front.infiniteScroll(a)});a.infiniteScrollFlag=false}};wdi_front.infiniteScroll=function(a){if((jQuery(window).scrollTop()+jQuery(window).height()-100)>=jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_infinite_scroll").offset().top){if(a.infiniteScrollFlag===false&&a.stopInfiniteScrollFlag==false){a.infiniteScrollFlag=true;wdi_front.loadMore(jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" #wdi_infinite_scroll"),a)}else{if(a.stopInfiniteScrollFlag){wdi_front.allImagesLoaded(a)}}}};wdi_front.paginationFirstPage=function(b,c){if(c.paginator==1||c.currentPage==1){b.addClass("wdi_disabled");return}var d=c.currentPage;c.currentPage=1;wdi_front.updatePagination(c,"custom",d);var a=b.parent().find("#wdi_last_page");a.removeClass("wdi_disabled");b.addClass("wdi_disabled")};wdi_front.paginationLastPage=function(a,b){if(b.paginator==1||b.currentPage==b.paginator){return}var d=b.currentPage;b.currentPage=b.paginator;wdi_front.updatePagination(b,"custom",d);a.addClass("wdi_disabled");var c=a.parent().find("#wdi_first_page");c.removeClass("wdi_disabled")};wdi_front.paginatorNext=function(b,c){var a=b.parent().find("#wdi_last_page");var d=b.parent().find("#wdi_first_page");c.paginatorNextFlag=true;if(c.paginator==c.currentPage&&!wdi_front.checkFeedFinished(c)){c.currentPage++;var e=c.feed_row.number_of_photos;wdi_front.loadMore(b,c,e);a.addClass("wdi_disabled")}else{if(c.paginator>c.currentPage){c.currentPage++;wdi_front.updatePagination(c,"next");if(c.paginator>c.currentPage){a.removeClass("wdi_disabled")}else{a.addClass("wdi_disabled")}}}d.removeClass("wdi_disabled")};wdi_front.paginatorPrev=function(b,c){var a=b.parent().find("#wdi_last_page");var d=b.parent().find("#wdi_first_page");if(c.currentPage==1){d.addClass("wdi_disabled");return}c.currentPage--;wdi_front.updatePagination(c,"prev");a.removeClass("wdi_disabled");if(c.currentPage==1){d.addClass("wdi_disabled")}};wdi_front.updatePagination=function(b,a,d){var c="#wdi_feed_"+b.feed_row.wdi_feed_counter;jQuery(c+' [wdi_page="'+b.currentPage+'"]').each(function(){jQuery(this).removeClass("wdi_hidden")});switch(a){case"next":var d=b.currentPage-1;jQuery(c+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height());jQuery(c+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")});break;case"prev":var d=b.currentPage+1;jQuery(c+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height());jQuery(c+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")});break;case"custom":var d=d;if(d!=b.currentPage){jQuery(c+" .wdi_feed_wrapper").height(jQuery(".wdi_feed_wrapper").height());jQuery(c+' [wdi_page="'+d+'"]').each(function(){jQuery(this).addClass("wdi_hidden")})}break}b.paginatorNextFlag=false;jQuery(c+" .wdi_feed_wrapper").css("height","auto");jQuery(c+" #wdi_current_page").text(b.currentPage)};wdi_front.loadMore=function(f,k){var b=0;if(f!=""&&typeof f!="undefined"&&f!="initial"&&f!="initial-keep"){var l=window[f.parent().parent().parent().parent().attr("id")]}if(typeof k!="undefined"){var l=k}var n=0,g=0;for(var e=0;e<l.userSortFlags.length;e++){if(l.userSortFlags[e].flag===true){n++;for(var d=0;d<l.usersData.length;d++){if(l.userSortFlags[e]["id"]===l.usersData[d]["user_id"]){if(l.usersData[d]["finished"]==="finished"){g++}}}}}if(n===g&&n!=0){return}if(f===""){l.auto_trigger=true}else{l.auto_trigger=false}wdi_front.ajaxLoader(l);if(l.feed_row.feed_type==="masonry"&&l.feed_row.feed_display_view=="pagination"){jQuery("#wdi_feed_"+wdi_front.feed_counter+" .wdi_full_caption").each(function(){jQuery(this).find(".wdi_photo_title").trigger(wdi_front.clickOrTouch)})}for(var e=0;e<l.usersData.length;e++){if(l.usersData[e]["finished"]==="finished"){b++}}if(b===l.usersData.length){wdi_front.allImagesLoaded(l);jQuery("#wdi_feed_"+l.feed_row["wdi_feed_counter"]+" .wdi_load_more").remove()}var h=l.usersData;l.loadMoreDataCount=l.feed_users.length;for(var e=0;e<h.length;e++){var m=h[e]["pagination"];var c={user_id:h[e]["user_id"],username:h[e]["username"]};if(m.next_url!=""&&m.next_url!=null&&typeof m.next_url!="undefined"){var a=m.next_url;wdi_front.loadMoreRequest(c,a,l,f)}else{if(f=="initial-keep"){l.temproraryUsersData[e]=l.usersData[e]}l.loadMoreDataCount--;wdi_front.checkForLoadMoreDone(l,f);continue}}};wdi_front.loadMoreRequest=function(b,a,e,d){if(!e.mediaRequestsDone){return}var f=e.usersData;var c="";var g=function(h){if(typeof h.meta!="undefined"&&typeof h.meta.error_type!="undefined"){wdi_front.show_alert(false,h,e)}if(h===""||typeof h=="undefined"||h==null){c=wdi_front_messages.network_error;e.loadMoreDataCount--;wdi_front.show_alert(c,h,e);return}if(h.meta["code"]!=200){c=h.meta["error_message"];e.loadMoreDataCount--;wdi_front.show_alert(c,h,e);return}h.user_id=b.user_id;h.username=b.username;for(var j=0;j<e.usersData.length;j++){if(h.user_id===e.usersData[j]["user_id"]){if(h.user_id[0]==="#"){h.data=wdi_front.appendRequestHashtag(h.data,h.user_id)}if(d=="initial-keep"){e.temproraryUsersData[j]=e.usersData[j]}e.usersData[j]=h;e.loadMoreDataCount--}}wdi_front.checkForLoadMoreDone(e,d)};if(b.username[0]!=="#"){e.instagram.requestByUrl(a,{success:g})}else{e.instagram.getTagRecentMedia(b.username,{success:g},a,e.feed_row.hashtag_top_recent)}};wdi_front.checkForLoadMoreDone=function(c,b){var a=c.feed_row.load_more_number;var e=c.feed_row.number_of_photos;if(c.loadMoreDataCount==0){c.temproraryUsersData=wdi_front.mergeData(c.temproraryUsersData,c.usersData);var d=wdi_front.getArrayContentLength(c.temproraryUsersData,"data");if(b=="initial-keep"){b="initial"}if(b=="initial"){if(d<e&&!wdi_front.userHasNoPhoto(c,c.temproraryUsersData)&&c.instagramRequestCounter<=c.maxConditionalFiltersRequestCount){wdi_front.loadMore("initial",c)}else{c.usersData=c.temproraryUsersData;wdi_front.displayFeed(c);wdi_front.applyFilters(c);c.temproraryUsersData=[]}}else{if(d<a&&!wdi_front.userHasNoPhoto(c,c.temproraryUsersData)&&c.instagramRequestCounter<=c.maxConditionalFiltersRequestCount){wdi_front.loadMore(undefined,c)}else{c.usersData=c.temproraryUsersData;if(!wdi_front.activeUsersCount(c)){return}wdi_front.displayFeed(c,a);wdi_front.applyFilters(c);c.temproraryUsersData=[]}}}};wdi_front.allDataHasFinished=function(b){var d=0;for(var a=0;a<b.dataStorageRaw.length;a++){if(b.dataStorageRaw[a].length()==0&&b.dataStorageRaw[a].locked==true){d++}}return(d==b.dataStorageRaw.length)};wdi_front.mergeData=function(c,b){for(var a=0;a<b.length;a++){if(typeof c[a]!="undefined"){if(b[a]["finished"]=="finished"){continue}if(typeof c[a]["pagination"]["next_max_id"]=="undefined"&&typeof c[a]["pagination"]["next_max_like_id"]=="undefined"){continue}c[a]["data"]=c[a]["data"].concat(b[a]["data"]);c[a]["pagination"]=b[a]["pagination"];c[a]["user_id"]=b[a]["user_id"];c[a]["username"]=b[a]["username"];c[a]["meta"]=b[a]["meta"]}else{c.push(b[a])}}return c};wdi_front.brokenImageHandler=function(d){var b=d.src.split("/p/");if(typeof b[0]!=="undefined"&&typeof b[1]!=="undefined"&&b[0]!=="https://www.instagram.com"){var a=wdi_baseName(b[0]);var c=a+"/p/"+b[1];d.src=c}else{d.src=wdi_url.plugin_url+"images/missing.png"}d.onerror="";return true};function wdi_baseName(b){var a=b.substr(b.lastIndexOf("/"));return b.replace(a,"")}wdi_front.ajaxLoader=function(a){var d=a.feed_row.wdi_feed_counter;var c=jQuery("#wdi_feed_"+d);if(a.feed_row.feed_display_view=="load_more_btn"){c.find(".wdi_load_more").addClass("wdi_hidden");c.find(".wdi_spinner").removeClass("wdi_hidden")}if(a.feed_row.feed_display_view=="infinite_scroll"){var b;if(c.find(".wdi_ajax_loading").length==0){b=jQuery('<div class="wdi_ajax_loading"><div><div><img class="wdi_load_more_spinner" src="'+wdi_url.plugin_url+'images/ajax_loader.png"></div></div></div>');c.append(b)}else{b=c.find(".wdi_ajax_loading")}b.removeClass("wdi_hidden")}};wdi_front.allImagesLoaded=function(a){var d=wdi_front.getDataLength(a);if(!a.mediaRequestsDone){jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").remove("wdi_nomedia")}if(d==0&&a.mediaRequestsDone&&(a.feed_row.conditional_filters.length==0||a.feed_row.conditional_filter_enable==0)){jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" .wdi_feed_wrapper").append("<p class='wdi_nomedia'>"+wdi_front_messages.feed_nomedia+"</p>")}var c=a.feed_row.wdi_feed_counter;var b=jQuery("#wdi_feed_"+c);if(a.feed_row.feed_display_view=="load_more_btn"){b.find(".wdi_load_more").removeClass("wdi_hidden");b.find(".wdi_spinner").addClass("wdi_hidden")}if(a.feed_row.feed_display_view=="infinite_scroll"){jQuery("#wdi_feed_"+a.feed_row.wdi_feed_counter+" .wdi_ajax_loading").addClass("wdi_hidden")}b.trigger("wdi_feed_loaded")};wdi_front.show=function(b,c){var e=c.feed_row.wdi_feed_counter;var d=jQuery("#wdi_feed_"+e+" .wdi_feed_container");var g=this;switch(b){case"header":f();break;case"users":a(c);break}function f(){var i={feed_thumb:c.feed_row["feed_thumb"],feed_name:c.feed_row["feed_name"]};var k=wdi_front.getHeaderTemplate(),h=k(i),j=d.find(".wdi_feed_header").html();d.find(".wdi_feed_header").html(j+h)}function a(j){d.find(".wdi_feed_users").html("");var n=j.feed_users;var m=j.feed_row["access_token"];var h=0;j.headerUserinfo=[];k();function k(){if(j.headerUserinfo.length==n.length){l(j.headerUserinfo,j);return}var i=n[j.headerUserinfo.length];if(typeof i==="string"&&i==="self"){j.instagram.getSelfInfo({success:function(o){if(typeof o.meta!="undefined"&&typeof o.meta.error_type!="undefined"){wdi_front.show_alert(false,o,j)}o=g.checkMediaResponse(o,j);if(o!=false&&o.meta["code"]===400&&o.meta["error_type"]==="APINotAllowedError"){var p=null;j.headerUserinfo.push(p);h++;k()}if(o!=false&&o.meta["code"]===200){var p={id:o.data["id"],name:o.data["username"],url:o.data["profile_picture"],bio:wdi_front.escape_tags(o.data["bio"]),counts:o.data["counts"],website:wdi_front.escape_tags(o.data["website"]),full_name:wdi_front.escape_tags(o.data["full_name"])};j.headerUserinfo.push(p);h++;k()}},args:{ignoreFiltering:true}})}else{if(false&&g.getInputType(i.username)=="hashtag"){j.instagram.searchForTagsByName(g.stripHashtag(i.username),{success:function(o){if(typeof o.meta!="undefined"&&typeof o.meta.error_type!="undefined"){wdi_front.show_alert(false,o,j)}o=g.checkMediaResponse(o,j);if(o!=false){if(o.data.length==0){var p="";var q={media:""}}else{var p="";var q={media:o.data[0]["media_count"]}}var r={name:n[h]["username"],url:p,counts:q};h++;j.headerUserinfo.push(r);k()}},args:{ignoreFiltering:true}})}else{if(g.getInputType(i.username)=="user"){j.instagram.getSelfInfo({success:function(o){if(typeof o.meta!="undefined"&&typeof o.meta.error_type!="undefined"){wdi_front.show_alert(false,o,j)}o=g.checkMediaResponse(o,j);if(o!=false&&o.meta["code"]===400&&o.meta["error_type"]==="APINotAllowedError"){var p=null;j.headerUserinfo.push(p);h++;k()}if(o!=false&&o.meta["code"]===200){var p={id:o.data["id"],name:o.data["username"],url:o.data["profile_picture"],bio:wdi_front.escape_tags(o.data["bio"]),counts:o.data["counts"],website:wdi_front.escape_tags(o.data["website"]),full_name:wdi_front.escape_tags(o.data["full_name"])};j.headerUserinfo.push(p);h++;k()}},args:{ignoreFiltering:true}})}}}}function l(i,t){d.find(".wdi_feed_users").html("");for(var q=0;q<i.length;q++){if(i[q]===null){continue}var v={flag:false,id:i[q]["id"],name:i[q]["name"]};var p=(i[q]["name"][0]=="#")?"wdi_header_hashtag":"";var u=wdi_extractHostname(i[q]["website"]);var o={user_index:q,user_img_url:i[q]["url"],counts:i[q]["counts"],feed_counter:t.feed_row.wdi_feed_counter,user_name:i[q]["name"],bio:wdi_front.escape_tags(i[q]["bio"]),website:u,website_url:i[q]["website"],usersCount:t.feed_row.feed_users.length,hashtagClass:p};var x=wdi_front.getUserTemplate(t,i[q]["name"]),r=x(o),s=d.find(".wdi_feed_users").html();d.find(".wdi_feed_users").html(s+r);t.userSortFlags.push(v);var w=jQuery('<div class="wdi_clear"></div>')}d.find(".wdi_feed_users").append(w);wdi_front.updateUsersImages(t)}}};wdi_front.getUserTemplate=function(c,h){var a=c.dataCount,d,f,g;switch(h[0]){case"#":d="//instagram.com/explore/tags/"+h.substr(1,h.length);break;default:d="//instagram.com/"+h;break}g='window.open("'+d+'","_blank")';f="onclick='"+g+"'";var e='<div class="wdi_single_user" user_index="<%=user_index%>"><div class="wdi_header_user_text <%=hashtagClass%>"><div class="wdi_user_img_wrap"><img onerror="wdi_front.brokenImageHandler(this);" src="<%= user_img_url%>">';if(a>1){e+='<div title="'+wdi_front_messages.filter_title+'" class="wdi_filter_overlay"><div class="wdi_filter_icon"><span onclick="wdi_front.addFilter(<%=user_index%>,<%=feed_counter%>);" class="fa fa-filter"></span></div></div>'}e+="</div>";e+="<h3 "+f+"><%= user_name%></h3>";if(h[0]!=="#"){if(c.feed_row.follow_on_instagram_btn=="1"){e+='<div class="wdi_user_controls"><div class="wdi_follow_btn" onclick="window.open(\'//instagram.com/<%= user_name%>\',\'_blank\')"><span> '+wdi_front_messages.follow+"</span></div></div>"}e+='<div class="wdi_media_info"><p class="wdi_posts"><span class="fa fa-camera-retro"></span><%= counts.media%></p><p class="wdi_followers"><span class="fa fa-user"></span><%= counts.followed_by%></p></div>'}else{e+='<div class="wdi_user_controls"></div><div class="wdi_media_info"><p class="wdi_posts"><span class="fa fa-camera-retro"></span><%= counts.media%></p><p class="wdi_followers"><span></span></p></div>'}e+='<div class="wdi_clear"></div>';if(a==1&&h[0]!=="#"&&c.feed_row.display_user_info=="1"){e+='<div class="wdi_bio"><%= bio%></div>';e+='<div class="wdi_website"><a target="_blank" href="<%= website_url%>" ><%= website%></a></div>'}e+="</div></div>";var b=_.template(e);return b};wdi_front.getHeaderTemplate=function(){var b='<div class="wdi_header_wrapper"><div class="wdi_header_img_wrap"><img src="<%=feed_thumb%>"></div><div class="wdi_header_text"><%=feed_name%></div><div class="wdi_clear"></div>';var a=_.template(b);return a};wdi_front.addFilter=function(e,g){var f=window["wdi_feed_"+g];var d=f.dataCount;if(d<2){return}if(f.nowLoadingImages!=false){return}else{var c=jQuery("#wdi_feed_"+f.feed_row.wdi_feed_counter+'_users [user_index="'+e+'"]');c.find(".wdi_filter_overlay").toggleClass("wdi_filter_active_bg");c.find(".wdi_header_user_text h3").toggleClass("wdi_filter_active_col");c.find(".wdi_media_info").toggleClass("wdi_filter_active_col");c.find(".wdi_follow_btn").toggleClass("wdi_filter_active_col");f.customFilterChanged=true;if(f.userSortFlags[e]["flag"]==false){f.userSortFlags[e]["flag"]=true}else{f.userSortFlags[e]["flag"]=false}var a=0;for(var b=0;b<f.userSortFlags.length;b++){if(f.userSortFlags[b]["flag"]==true){a++}}if(f.feed_row.feed_display_view=="pagination"){f.resIndex=0}if(a!=0){wdi_front.filterData(f);wdi_front.displayFeed(f)}else{f.customFilteredData=f.dataStorageList;wdi_front.displayFeed(f)}if(f.feed_row.feed_display_view=="pagination"){f.paginator=Math.ceil((f.imageIndex)/parseInt(f.feed_row.pagination_per_page_number));f.currentPage=f.paginator;wdi_front.updatePagination(f,"custom",1);jQuery("#wdi_first_page").removeClass("wdi_disabled");jQuery("#wdi_last_page").addClass("wdi_disabled")}}};wdi_front.filterData=function(c){var d=c.userSortFlags;c.customFilteredData=[];for(var b=0;b<c.dataStorageList.length;b++){for(var a=0;a<d.length;a++){if(((typeof c.dataStorageList[b]["user"]["id"]!="undefined"&&c.dataStorageList[b]["user"]["id"]==d[a]["id"])||c.dataStorageList[b]["wdi_hashtag"]==d[a]["name"])&&d[a]["flag"]==true){c.customFilteredData.push(c.dataStorageList[b])}}}};wdi_front.applyFilters=function(c){for(var b=0;b<c.userSortFlags.length;b++){if(c.userSortFlags[b]["flag"]==true){var a=jQuery("#wdi_feed_"+c.feed_row.wdi_feed_counter+'[user_index="'+b+'"]');wdi_front.addFilter(b,c.feed_row.wdi_feed_counter);wdi_front.addFilter(b,c.feed_row.wdi_feed_counter)}}};wdi_front.getImgCount=function(b){var d=b.dataStorage;var c=0;for(var a=0;a<d.length;a++){c+=d[a].length}return c};wdi_front.parseLighboxData=function(k,m){var g=k.dataStorage;var l=k.feed_row.sort_images_by;var a=k.feed_row.display_order;var h=wdi_front.sortingOperator(l,a);var f=[];var b=[];var e={};if(m==true){f=k.customFilteredData}else{for(var d=0;d<g.length;d++){for(var c=0;c<g[d].length;c++){f.push(g[d][c])}}f.sort(h)}for(d=0;d<f.length;d++){e={alt:"",avg_rating:"",comment_count:f[d]["comments"]["count"],date:wdi_front.convertUnixDate(f[d]["created_time"]),description:wdi_front.getDescription((f[d]["caption"]!==null)?wdi_front.escape_tags(f[d]["caption"]["text"]):""),filename:wdi_front.getFileName(f[d]),filetype:wdi_front.getFileType(f[d]),hit_count:"0",id:f[d]["id"],image_url:f[d]["link"],number:0,rate:"",rate_count:"0",username:f[d]["user"]["username"],profile_picture:f[d]["user"]["profile_picture"],thumb_url:f[d]["link"]+"media/?size=t",comments_data:f[d]["comments"]["data"],images:f[d]["images"],carousel_media:(typeof f[d]["carousel_media"]!=="undefined")?f[d]["carousel_media"]:null};b.push(e)}return b};wdi_front.convertUnixDate=function(b){var c=parseInt(b);var a=new Date(0);a.setUTCSeconds(c);var d=a.getFullYear()+"-"+a.getMonth()+"-"+a.getDate();d+=" "+a.getHours()+":"+a.getMinutes();return d};wdi_front.getDescription=function(a){a=a.replace(/\r?\n|\r/g," ");return a};wdi_front.getFileName=function(d){var c=d.link;var b=d.type;if(b==="video"&&d.hasOwnProperty("videos")){return d.videos["standard_resolution"]["url"]}else{var a=c.split("/");return a[a.length-2]}};wdi_front.getFileType=function(a){if(a.type=="video"&&a.hasOwnProperty("videos")){return"EMBED_OEMBED_INSTAGRAM_VIDEO"}else{return"EMBED_OEMBED_INSTAGRAM_IMAGE"}};wdi_front.array_max=function(d){var a=d[0];var b=0;for(var c=1;c<d.length;c++){if(a<d[c]){a=d[c];b=c}}return{value:a,index:b}};wdi_front.array_min=function(d){var c=d[0];var a=0;for(var b=1;b<d.length;b++){if(c>d[b]){c=d[b];a=b}}return{value:c,index:a}};wdi_front.activeUsersCount=function(c){var a=0;for(var b=0;b<c.usersData.length;b++){if(c.usersData[b].finished!="finished"){a++}}return a};wdi_front.checkMediaResponse=function(a,b){if(a!=""&&typeof a!="undefined"&&a!=null&&a.meta["code"]===400&&a.meta["error_type"]==="APINotAllowedError"){return a}if(a==""||typeof a=="undefined"||a==null){errorMessage=wdi_front_messages.connection_error;wdi_front.show_alert(errorMessage,a,b);return false}if(a.meta["code"]!=200){errorMessage=a.meta["error_message"];wdi_front.show_alert(errorMessage,a,b);return false}return a};wdi_front.stripHashtag=function(a){switch(a[0]){case"#":return a.substr(1,a.length);break;default:return a;break}};wdi_front.getInputType=function(a){switch(a[0]){case"#":return"hashtag";break;case"%":return"location";break;default:return"user";break}};wdi_front.regexpTestCaption=function(h,e){var d=false,b=false,f=[],g=e.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&"),c=new RegExp("(?:^|\\s)"+g+"(?:^|\\s)"),a=new RegExp("(?:^|\\s)"+g,"g");if(c.exec(h)!=null){d=true}while((match=a.exec(h))!=null){if(match.index==h.length-e.length-1){b=true}}if(d==true||b==true){return true}else{return false}};wdi_front.replaceNewLines=function(c){var b="vUkCJvN2ps3t",a=[],g;c=c.replace(/\r?\n|\r/g,b);g=new RegExp(b,"g");while((match=g.exec(c))!=null){a.push(match.index)}var f=c.split(b);var e=0;for(var d=0;d<f.length;d++){if(f[d]==""){e++}else{e=0}if(e>0){f.splice(d,1);e--;d--}}c=f.join(" ");return c};wdi_front.isEmptyObject=function(a){for(var b in a){if(a.hasOwnProperty(b)){return false}}return true};var WDIFeed=function(a){this["data"]=a.data;this["dataCount"]=a.dataCount;this["feed_row"]=a.feed_row;this["usersData"]=a.usersData;_this=this;this.set_images_loading_flag=function(b){window.addEventListener("load",function(){b.nowLoadingImages=false})};this.set_images_loading_flag(_this)};WDIFeed.prototype.conditionalFilter=function(a,c){var d=this,b=d.feed_row.conditional_filter_type,e=d.feed_row.conditional_filters;if(c.ignoreFiltering==true){}else{a=this.avoidDuplicateMedia(a)}if(!wdi_front.isJsonString(e)){return a}else{e=JSON.parse(e);if(e.length==0){return a}}if(d.feed_row.conditional_filter_enable=="0"){return a}d.instagramRequestCounter++;switch(b){case"AND":a=this.applyANDLogic(a,e,d);break;case"OR":a=this.applyORLogic(a,e,d);break;case"NOR":a=this.applyNORLogic(a,e,d);break;default:break}return a};WDIFeed.prototype.applyANDLogic=function(a,d){var c=this;for(var b=0;b<d.length;b++){a=this.filterResponse(a,d[b])}return a};WDIFeed.prototype.applyORLogic=function(d,c){var h=this;var a=[],g,j=[],f,b;for(var e=0;e<c.length;e++){g=this.filterResponse(d,c[e]);a=a.concat(g.data);g={}}for(e=0;e<a.length;e++){b=a[e];if(!this.mediaExists(b,j)&&!this.mediaExists(b,h.dataStorageList)){j.push(b)}}f={data:j,meta:d.meta,pagination:d.pagination};return f};WDIFeed.prototype.applyNORLogic=function(c,h){var f=c,g=this,b=this.applyORLogic(c,h,g),d=[],a;for(var e=0;e<f.data.length;e++){if(!this.mediaExists(f.data[e],b.data)){d.push(f.data[e])}}a={data:d,meta:f.meta,pagination:f.pagination};return a};WDIFeed.prototype.mediaExists=function(b,c){for(var a=0;a<c.length;a++){if(b.id==c[a]["id"]){return true}}return false};WDIFeed.prototype.filterResponse=function(a,b){switch(b.filter_type){case"hashtag":return this.filterByHashtag(a,b);break;case"username":return this.filterByUsername(a,b);break;case"mention":return this.filterByMention(a,b);break;case"description":return this.filterByDescription(a,b);break;case"location":return this.filterByLocation(a,b);break;case"url":return this.filterByUrl(a,b);break}};WDIFeed.prototype.filterByHashtag=function(b,g){var d=[],f,h,a;for(var e=0;e<b.data.length;e++){h=b.data[e];for(var c=0;c<h.tags.length;c++){tag=h.tags[c];if(tag.toLowerCase()==g.filter_by.toLowerCase()){d.push(h)}}}a={data:d,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.filterByUsername=function(b,e){var c=[],f,a;for(var d=0;d<b.data.length;d++){f=b.data[d];if(f.user.username.toLowerCase()==e.filter_by.toLowerCase()){c.push(f)}}a={data:c,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.filterByMention=function(b,e){var c=[],f,g,a;for(var d=0;d<b.data.length;d++){f=b.data[d];if(f.caption!==null){g=f.caption["text"].toLowerCase();if(g.indexOf("@"+e.filter_by.toLowerCase())!=-1){c.push(f)}}}a={data:c,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.filterByDescription=function(c,f){var d=[],g,h,b;for(var e=0;e<c.data.length;e++){g=c.data[e];if(g.caption!==null){h=g.caption["text"].toLowerCase();h=wdi_front.replaceNewLines(h);var a=f.filter_by.toLowerCase();if(wdi_front.regexpTestCaption(h,a)){d.push(g)}}}b={data:d,meta:c.meta,pagination:c.pagination};return b};WDIFeed.prototype.filterByLocation=function(b,f){var c=[],g,e,a;for(var d=0;d<b.data.length;d++){g=b.data[d];if(g.location!==null){e=g.location["id"];if(e==f.filter_by){c.push(g)}}}a={data:c,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.filterByUrl=function(b,e){var c=[],g,h,a,f;e.filter_by=this.getIdFromUrl(e.filter_by);for(var d=0;d<b.data.length;d++){g=b.data[d];if(g.link!==null){h=this.getIdFromUrl(g.link);if(h==e.filter_by){c.push(g)}}}a={data:c,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.getIdFromUrl=function(a){var c=a.split("/"),d=false;for(var b=0;b<c.length;b++){if(c[b]=="p"){if(typeof c[b+1]!="undefined"){d=c[b+1];break}}}return d};WDIFeed.prototype.avoidDuplicateMedia=function(b){var e=b.data,d=[],a={};if(typeof e=="undefined"){e=[]}for(var c=0;c<e.length;c++){if(!this.mediaExists(e[c],this.dataStorageList)&&!this.mediaExists(e[c],d)&&!this.mediaExists(e[c],this.conditionalFilterBuffer)){d.push(e[c])}}this.conditionalFilterBuffer=this.conditionalFilterBuffer.concat(d);a={data:d,meta:b.meta,pagination:b.pagination};return a};WDIFeed.prototype.storeRawData=function(c,a){var e=this;if(typeof this[a]=="object"&&typeof this[a].length=="number"){for(var b=0;b<c.length;b++){var d="";if(wdi_front.isHashtag(c[b].user_id)){if(typeof c[b].pagination.cursors!=="undefined"){d=c[b].pagination.cursors.after}}else{if(e.feed_row.liked_feed=="liked"){d=c[b].pagination.next_max_like_id;if(typeof d=="undefined"){d=""}}else{if(c[b].pagination==null){c[b].pagination=[]}d=c[b].pagination.next_max_id;if(typeof d=="undefined"){d=""}}}if(typeof this[a][b]=="undefined"){this[a].push({data:c[b].data,index:0,locked:false,hash_id:d,usersDataFinished:false,userId:c[b].user_id,length:function(){return this.data.length-this.index},getData:function(g){var h=this.data.slice(this.index,this.index+g);this.index+=Math.min(g,this.length());if(this.index==this.data.length&&this.locked==true&&this.usersDataFinished==false){for(var f=0;f<e.usersData.length;f++){if(e.usersData[f]["user_id"]==this.userId){e.usersData[f].finished="finished";this.usersDataFinished=true;break}}}return h}})}else{if(this[a][b].locked==false){if(d!=this[a][b].hash_id){this[a][b].data=this[a][b].data.concat(c[b].data);this[a][b].hash_id=d}else{this[a][b].locked=true}}}}}};wdi_front.updateUsersIfNecessary=function(c){var d=c.feed_users;var a=false;for(var b=0;b<d.length;b++){if("#"==d[b].username.substr(0,1)){d[b].id=d[b].username;continue}if(""==d[b].id||"username"==d[b].id){a=true;c.instagram.searchForUsersByName(d[b].username,{success:function(i){if(typeof i.meta!="undefined"&&typeof i.meta.error_type!="undefined"){wdi_front.show_alert(false,i,c)}if(i.meta.code==200&&i.data.length>0){var l=false;for(var g=0;g<i.data.length;g++){if(i.data[g].username==i.args.username){l=true;break}}if(l){for(var h=0;h<d.length;h++){if(i.data[g].username==d[h].username){d[h].id=i.data[g].id}}}}var f=false;for(var e=0;e<d.length;e++){if(d[e].id==""||d[e].id=="username"){f=true;break}}if(!f){c.feed_row.feed_users=JSON.stringify(d);wdi_front.init(c)}},username:d[b].username})}}return a};if(typeof wdi_ajax.ajax_response!="undefined"){jQuery(document).one("ajaxStop",function(){if(wdi_front.type!="not_declared"){wdi_front.clickOrTouch=wdi_front.detectEvent();wdi_front.globalInit()}else{return}})}else{jQuery(document).ready(function(){if(wdi_front.type!="not_declared"){wdi_front.clickOrTouch=wdi_front.detectEvent();wdi_front.globalInit()}else{return}})}jQuery(document).ready(function(){setTimeout(function(){if(wdi_front_messages.show_alerts==="1"&&jQuery(".wdi_check_fontawesome .fa-instagram").prop("tagName")!=="I"){console.log("Font Awesome is not loaded properly. Please ask for support https://wordpress.org/support/plugin/wd-instagram-feed/")}},2000)});function wdi_extractHostname(b){if(typeof b==="undefined"||b===""){return""}var a=b.replace(/(^\w+:|^)\/\//,"");return a};
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: custom instagram feed, feed, instagram, hashtag, Instagram feed, instagram
4
  Requires at least: 3.9
5
  Requires PHP: 5.2
6
  Tested up to: 5.1
7
- Stable tag: 1.3.13
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -537,6 +537,10 @@ Please make sure you don't have any important information before you proceed.
537
 
538
  == Changelog ==
539
 
 
 
 
 
540
  = 1.3.13 =
541
  New: Option to get hashtag top media
542
  Improved: Notices during Facebook Log in
4
  Requires at least: 3.9
5
  Requires PHP: 5.2
6
  Tested up to: 5.1
7
+ Stable tag: 1.3.14
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
537
 
538
  == Changelog ==
539
 
540
+ = 1.3.14 =
541
+ New: Added contributor role in the option 'Minimal role to add and manage Feeds or Themes'.
542
+ Fixed: Conditional filters for hashtags.
543
+
544
  = 1.3.13 =
545
  New: Option to get hashtag top media
546
  Improved: Notices during Facebook Log in
wd-instagram-feed.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Instagram Feed by 10Web
4
  Plugin URI: https://10web.io/plugins/wordpress-instagram-feed/
5
  Description: Instagram Feed by 10Web 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.3.13
7
  Author: 10Web
8
  Author URI: https://10Web.io
9
  License: GPLv2 or later
@@ -20,7 +20,7 @@ define("WDI_META", "_".WDI_VAR."_meta");
20
  //define("wdi",'wdi');
21
  define('WDI_FEED_TABLE','wdi_feeds');
22
  define('WDI_THEME_TABLE','wdi_themes');
23
- define('WDI_VERSION','1.3.13');
24
  define('WDI_IS_PRO','false');
25
  $wdi_minify = ((isset($_GET['wdi_no_minify']) && $_GET['wdi_no_minify'] == "true") ? false : true);
26
  define('WDI_MINIFY', $wdi_minify);
@@ -58,10 +58,13 @@ function wdi_save_user_access_token(){
58
 
59
  $token = $_GET['wdi_code'];
60
 
61
-
62
  $url = "https://graph.facebook.com/me/accounts?fields=instagram_business_account&limit=500&access_token=" . $token;
63
- $accounts = @file_get_contents($url);
64
- $accounts = json_decode($accounts, true);
 
 
 
65
 
66
  if(!is_array($accounts)) {
67
  //invalid access token
@@ -96,7 +99,7 @@ function wdi_save_user_access_token(){
96
  }
97
 
98
  function wdi_no_business_account_notice(){
99
- echo "<div class='notice notice-error'><p>Cannot find connected Instagram business page. Either you do not have Instagram business account or it is not connected to current Facebook user's page. <a href='https://help.10web.io/hc/en-us/articles/360021344111' target='_blank'>See more in documentation.</a> </p></div>";
100
  }
101
 
102
  function wdi_invalid_fb_token_notice(){
3
  Plugin Name: Instagram Feed by 10Web
4
  Plugin URI: https://10web.io/plugins/wordpress-instagram-feed/
5
  Description: Instagram Feed by 10Web 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.3.14
7
  Author: 10Web
8
  Author URI: https://10Web.io
9
  License: GPLv2 or later
20
  //define("wdi",'wdi');
21
  define('WDI_FEED_TABLE','wdi_feeds');
22
  define('WDI_THEME_TABLE','wdi_themes');
23
+ define('WDI_VERSION','1.3.14');
24
  define('WDI_IS_PRO','false');
25
  $wdi_minify = ((isset($_GET['wdi_no_minify']) && $_GET['wdi_no_minify'] == "true") ? false : true);
26
  define('WDI_MINIFY', $wdi_minify);
58
 
59
  $token = $_GET['wdi_code'];
60
 
61
+ $accounts = null;
62
  $url = "https://graph.facebook.com/me/accounts?fields=instagram_business_account&limit=500&access_token=" . $token;
63
+ $request = wp_remote_get($url);
64
+ if (!is_wp_error($request) || wp_remote_retrieve_response_code($request) === 200) {
65
+ $body = $request['body'];
66
+ $accounts = json_decode($body, true);
67
+ }
68
 
69
  if(!is_array($accounts)) {
70
  //invalid access token
99
  }
100
 
101
  function wdi_no_business_account_notice(){
102
+ echo "<div class='notice notice-error'><p>Cannot find connected Instagram business page. Either you do not have Instagram business account or it is not connected to current Facebook user's page. <a href='https://help.10web.io/hc/en-us/articles/360022629872' target='_blank'>See more in documentation.</a> </p></div>";
103
  }
104
 
105
  function wdi_invalid_fb_token_notice(){