Version Description
WordPress 5.8 compatibility
Download this release
Release Info
Developer | galdub |
Plugin | Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager |
Version | 2.7.1 |
Comparing to | |
See all releases |
Code changes from version 2.7 to 2.7.1
- assets/js/folders.js +5 -3
- assets/js/folders.min.js +1 -1
- assets/js/page-post-media.js +7 -6
- assets/js/page-post-media.min.js +1 -1
- folders.php +3 -3
- includes/folders.class.php +26 -21
- readme.txt +6 -3
assets/js/folders.js
CHANGED
@@ -467,7 +467,7 @@
|
|
467 |
var wp1 = parent.wp;
|
468 |
if(wp1.media != undefined) {
|
469 |
wp1.media.frame.setState('insert');
|
470 |
-
if (wp1.media.frame.content.get() !== null) {
|
471 |
wp1.media.frame.content.get().collection.props.set({ignore: (+new Date())});
|
472 |
wp1.media.frame.content.get().options.selection.reset();
|
473 |
} else {
|
@@ -1143,7 +1143,9 @@
|
|
1143 |
});
|
1144 |
|
1145 |
$(document).on("change", "#media-attachment-taxonomy-filter", function(e){
|
1146 |
-
$("#js-tree-menu").jstree
|
|
|
|
|
1147 |
$(".active-item").removeClass("active-item");
|
1148 |
if($(this).val() == "all") {
|
1149 |
$(".all-posts").addClass("active-item");
|
@@ -2511,7 +2513,7 @@
|
|
2511 |
var wp1 = parent.wp;
|
2512 |
if(wp1.media != undefined) {
|
2513 |
wp1.media.frame.setState('insert');
|
2514 |
-
if (wp1.media.frame.content.get() !== null) {
|
2515 |
wp1.media.frame.content.get().collection.props.set({ignore: (+new Date())});
|
2516 |
wp1.media.frame.content.get().options.selection.reset();
|
2517 |
} else {
|
467 |
var wp1 = parent.wp;
|
468 |
if(wp1.media != undefined) {
|
469 |
wp1.media.frame.setState('insert');
|
470 |
+
if (wp1.media.frame.content.get() !== null && typeof(wp1.media.frame.content.get().collection) != "undefined") {
|
471 |
wp1.media.frame.content.get().collection.props.set({ignore: (+new Date())});
|
472 |
wp1.media.frame.content.get().options.selection.reset();
|
473 |
} else {
|
1143 |
});
|
1144 |
|
1145 |
$(document).on("change", "#media-attachment-taxonomy-filter", function(e){
|
1146 |
+
if($("#js-tree-menu").hasClass("jstree")) {
|
1147 |
+
$("#js-tree-menu").jstree(true).deselect_all();
|
1148 |
+
}
|
1149 |
$(".active-item").removeClass("active-item");
|
1150 |
if($(this).val() == "all") {
|
1151 |
$(".all-posts").addClass("active-item");
|
2513 |
var wp1 = parent.wp;
|
2514 |
if(wp1.media != undefined) {
|
2515 |
wp1.media.frame.setState('insert');
|
2516 |
+
if (wp1.media.frame.content.get() !== null && typeof(wp1.media.frame.content.get().collection) != "undefined") {
|
2517 |
wp1.media.frame.content.get().collection.props.set({ignore: (+new Date())});
|
2518 |
wp1.media.frame.content.get().options.selection.reset();
|
2519 |
} else {
|
assets/js/folders.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e,t){var s,o,a,n,r,l,d="#js-tree-menu",c="",p=!1,u=!1,m=0,f=0,h=0,g=0,_=!1,v="",w=[],b=wcp_settings.page_url,y=[],k="<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'><div class='folder-item is-folder' data-id='__folder_id__'><a title='__folder_name__' id='folder_view___folder_id__'class='folder-view __append_class__ has-new-folder'data-id='__folder_id__'><span class='folder item-name'><span id='wcp_folder_text___folder_id__'class='folder-title'>__folder_name__</span></span></a></div></li>",j=null,x=null,C=1;function I(){"yes"==wcp_settings.useFolderUndo&&(e("#do-undo").addClass("active"),e(".undo-folder-action").removeClass("disabled"),setTimeout(function(){e("#do-undo").removeClass("active"),e(".undo-folder-action").addClass("disabled")},parseInt(wcp_settings.defaultTimeout)))}function S(){e(".cut-folder-action, .copy-folder-action, .paste-folder-action, .delete-folder-action").addClass("disabled"),e("#js-tree-menu .jstree-anchor.jstree-clicked").length&&e(".delete-folder-action").removeClass("disabled"),e("#menu-checkbox").is(":checked")&&e("#js-tree-menu input.checkbox:checked").length>0&&e(".delete-folder-action").removeClass("disabled")}function D(){S(),e(".wcp-move-file:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:"clone",cursor:"move",start:function(t,s){e(this).closest("td").addClass("wcp-draggable"),e("body").addClass("no-hover-css")},stop:function(t,s){e(this).closest("td").removeClass("wcp-draggable"),e("body").removeClass("no-hover-css")}}),e(".wcp-move-multiple:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:function(t,s){return e(".selected-items").remove(),selectedItems=e("#the-list th input:checked").length,selectedItems>0?(selectedItems=0==selectedItems||1==selectedItems?"1 Item":selectedItems+" Items",e("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")):e("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>")},start:function(t,s){e("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(t,s){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}}),e(".jstree-anchor:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){folderID=e(this).closest("li.jstree-node").attr("id"),o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),s=P(folderID,"nonce"),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(I(),H()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(I(),H()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),v=chkStr,e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){I(),H()}}))}}),e(".un-categorised-items:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){folderID=-1,s=wcp_settings.nonce,o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),Q(chkStr)):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,chkStr=postID+",",e(".wp-list-table input:checked").each(function(){postID!=e(this).val()&&(chkStr+=e(this).val()+",")}),Q(chkStr)):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),v=chkStr,Q(chkStr))}}),e(".attachments-browser li.attachment:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:function(t,s){return e(".selected-items").remove(),selectedItems=e(".attachments-browser li.attachment.selected").length,selectedItems=0==selectedItems||1==selectedItems?"1 Item":selectedItems+" Items",e("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")},start:function(t,s){e("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(t,s){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}}),e(".tree-structure .folder-item:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){e("body").removeClass("no-hover-css"),folderID=e(this).data("id"),o.draggable.hasClass("wcp-move-multiple")?(s=P(folderID,"nonce"),e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){I(),H(),Y()}}))):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){I(),H(),Y()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){I(),H(),Y()}}))}}),e(".sticky-folders li a:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){folderID=e(this).closest("li").data("folder-id"),o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),s=P(folderID,"nonce"),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(I(),H(),Y()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(I(),H(),Y()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),v=chkStr,e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){I(),H(),Y()}}))}}),B()}function P(e,t){if(w.length>0)for(i=0;i<w.length;i++)if(parseInt(w[i].folder_id)==parseInt(e))return w[i][t];return""}function T(e){if(w.length>0)for(i=0;i<w.length;i++)if(parseInt(w[i].folder_id)==parseInt(e))return i;return null}function H(){if(e(".media-toolbar").hasClass("media-toolbar-mode-select")&&e("ul.attachments li.selected").length&&(e("ul.attachments li.selected").trigger("click"),e(".select-mode-toggle-button").trigger("click")),""!=v&&(e("#js-tree-menu a.jstree-clicked").length>0||"-1"==c)){if(e("#media-attachment-taxonomy-filter").length){v=v.split(",");for(var t=0;t<v.length;t++)""!=v[t]&&e(".attachments-browser li[data-id='"+v[t]+"']").remove()}v=""}e("#media-attachment-taxonomy-filter").length?Z(0):(e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=get_folders_default_list",method:"post",success:function(t){t=e.parseJSON(t),e(".header-posts .total-count").text(t.total_items),e(".un-categorised-items .total-count").text(t.empty_items),y=t.taxonomies,B()}}),e(".folder-loader-ajax").addClass("active"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(b+"&paged="+C+" #posts-filter",function(){var t={Title:"",Url:b+"&paged="+C};history.pushState(t,t.Title,t.Url),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U(),N()}):e("#wpbody").load(b+"&paged="+C+" #wpbody-content",!1,function(t){var s={Title:"",Url:b+"&paged="+C};history.pushState(s,s.Title,s.Url),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U()}))}function N(){U(),e(".form-loader-count").css("width","0"),"object"==typeof inlineEditPost&&(inlineEditPost.init(),e("#the-list").on("click",".editinline",function(){e(this).attr("aria-expanded","true"),inlineEditPost.edit(this)}),e(document).on("click",".inline-edit-save .save",function(){var t=e(this).closest("tr").attr("id");t=(t=t.replace("edit-","")).replace("post-",""),inlineEditPost.save(t)}),e(document).on("click",".inline-edit-save .cancel",function(){var t=e(this).closest("tr").attr("id");t=(t=t.replace("edit-","")).replace("post-",""),inlineEditPost.revert(t)})),"attachment"==wcp_settings.post_type&&(e(".move-to-folder-top").length||e("#bulk-action-selector-top").append("<option class='move-to-folder-top' value='move_to_folder'>Move to Folder</option>"),e(".move-to-folder-bottom").length||e("#bulk-action-selector-bottom").append("<option class='move-to-folder-bottom' value='move_to_folder'>Move to Folder</option>"))}function U(){if(w.length&&e("li.jstree-node").each(function(){folderPostId=T(e(this).attr("id")),null!=folderPostId&&(1==w[folderPostId].is_high?e(this).addClass("is-high"):e(this).removeClass("is-high"),1==w[folderPostId].is_sticky?e(this).addClass("is-sticky"):e(this).removeClass("is-sticky"))}),folderId=0,e(".tree-structure ul").html(""),folderStatus=!0,e(".jstree-clicked").length&&(folderID=e(".jstree-clicked").closest(".jstree-node").attr("id"),e(".jstree-node[id='"+folderID+"'] > ul.jstree-children > li.jstree-node").length?(folderStatus=!1,e(".jstree-node[id='"+folderID+"'] > ul.jstree-children > li.jstree-node").each(function(){fID=e(this).attr("id"),fName=e.trim(e("#js-tree-menu").jstree(!0).get_node(fID).text),liHtml=k.replace(/__folder_id__/g,fID),liHtml=liHtml.replace(/__folder_name__/g,fName),selectedClass=e(this).hasClass("is-high")?"is-high":"",liHtml=liHtml.replace(/__append_class__/g,selectedClass),e(".tree-structure ul").append(liHtml)})):e(".jstree-node[id='"+folderID+"']").closest("ul").hasClass("jstree-container-ul")||(folderStatus=!1)),folderStatus&&e("#js-tree-menu > ul > li.jstree-node").each(function(){fID=e(this).attr("id"),fName=e.trim(e("#js-tree-menu").jstree(!0).get_node(fID).text),liHtml=k.replace(/__folder_id__/g,fID),liHtml=liHtml.replace(/__folder_name__/g,fName),selectedClass=e(this).hasClass("is-high")?"is-high":"",liHtml=liHtml.replace(/__append_class__/g,selectedClass),e(".tree-structure ul").append(liHtml)}),V(),"attachment"==wcp_settings.post_type&&(e(".move-to-folder-top").length||e("#bulk-action-selector-top").append("<option class='move-to-folder-top' value='move_to_folder'>Move to Folder</option>"),e(".move-to-folder-bottom").length||e("#bulk-action-selector-bottom").append("<option class='move-to-folder-bottom' value='move_to_folder'>Move to Folder</option>")),e(".sticky-folders .active-item").removeClass("active-item"),e("#js-tree-menu li.jstree-node.active-item").length){var t=e("#js-tree-menu li.jstree-node.active-item").data("folder-id");e(".sticky-folders .sticky-folder-"+t+" a").addClass("active-item")}D()}function O(){contentHeight=e(window).height()-e("#wpadminbar").height()-e(".sticky-wcp-custom-form").height()-30;var t=0;if(e("#custom-scroll-menu").hasClass("mCustomScrollbar")){var s=e("#custom-scroll-menu"),o=s.find(".mCSB_dragger"),a=s.find(".mCSB_container").height();t=o.position().top/(s.height()-o.height())*(a-s.height()),e("#custom-scroll-menu").mCustomScrollbar("destroy")}e("#custom-scroll-menu").mCustomScrollbar({axis:"y",scrollButtons:{enable:!1},setHeight:contentHeight,theme:"3d",scrollbarPosition:"inside",scrollInertia:500,mouseWheelPixels:60}),0!=t&&e("#custom-scroll-menu").mCustomScrollbar("scrollTo",t+"px",{scrollInertia:0})}function z(){U()}function J(){if(0==o&&a>=10)return e("#folder-limitation-message").html("You've reached the 10 folder limitation!"),e("#no-more-folder-credit").show(),!1;e("#add-update-folder-title").text("Add a new folder"),e("#save-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#add-update-folder-name").val(""),u&&(m=f,e("#add-update-folder-name").val(e.trim(e("#js-tree-menu").jstree(!0).get_node(f).text)+" #2"),f=e("#"+f+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?e("#"+f+"_anchor").closest(".jstree-node").parent().parent().attr("id"):0),e("#add-update-folder").removeClass("disabled"),e("#add-update-folder").show(),e("#add-update-folder-name").focus(),e(".dynamic-menu").remove()}function F(){folderName=e.trim(e("#js-tree-menu").jstree(!0).get_node(f).text),parentID=e("#wcp_folder_"+f).closest("li.jstree-node").data("folder-id"),parentID==t&&(parentID=0),e("#update-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#update-folder-item-name").val(folderName),e("#update-folder-item").removeClass("disabled"),e("#update-folder-item").show(),e("#update-folder-item-name").focus(),e(".dynamic-menu").remove()}function R(t){var s="Are you sure you want to delete the selected folder?",o="Items in the folder will not be deleted.";if(_=!1,1==t&&e("#menu-checkbox").is(":checked")){if(_=!0,0==e("#js-tree-menu input.checkbox:checked").length)return e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html("Please select at least one folder to delete"),void e("#error-folder-popup").show();e("#js-tree-menu input.checkbox:checked").length>1&&(s="Are you sure you want to delete the selected folders?",o="Items in the selected folders will not be deleted.")}e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#remove-folder-item").text("Yes, Delete it!"),e("#remove-folder-message").text(s),e("#remove-folder-notice").text(o),e("#confirm-remove-folder").show(),e("#remove-folder-item").focus()}function A(){e(d).jstree({core:{cache:!1,animation:0,max_depth:r?"-1":1,check_callback:function(t,s,o,a,n){if(e("*").removeClass("drag-bot").removeClass("drag-in").removeClass("drag-up"),("move_node"===t||"copy_node"===t)&&n&&n.dnd)switch(n.pos){case"a":n.origin.get_node(n.ref,!0).addClass("drag-bot"),nodeId=e(".drag-bot").attr("id"),e("#jstree-dnd").text("Below "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"i":if(!r&&e("#do_not_show_again").is(":checked"))return!1;n.origin.get_node(n.ref,!0).addClass("drag-in"),nodeId=e(".drag-in").attr("id"),e("#jstree-dnd").text("Inside "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"b":n.origin.get_node(n.ref,!0).addClass("drag-up"),nodeId=e(".drag-up").attr("id"),e("#jstree-dnd").text("Above "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;default:e("#jstree-dnd").text(e("#jstree-dnd").data("txt"))}return!0}},data:{cache:!1},select_node:!1,search:{show_only_matches:!0,case_sensitive:!1,fuzzy:!1},plugins:["dnd","search","contextmenu"],contextmenu:{select_node:0,show_at_node:0,items:function(){return{}}}}).bind("ready.jstree",function(){e("#js-tree-menu .jstree-node").each(function(){var t=parseInt(e(this).data("count"));t>0&&e(".jstree-node[id='"+e(this).attr("id")+"'] > a span.premio-folder-count").text(t)}),""!=c&&0!=c&&e(".jstree-node[id='"+c+"']").length&&(e("#js-tree-menu").jstree("select_node",c),e(".sticky-folders .sticky-folder-"+c+" a").length&&e(".sticky-folders .sticky-folder-"+c+" a").addClass("active-item")),e(".ajax-preloader").hide(),e(".js-tree-data").show(),O(),W(),e(".sticky-folders ul > li").length>0&&e(".sticky-folders").addClass("active"),U(),D(),S()}).bind("after_open.jstree",function(){D()}).bind("open_all.jstree",function(){D()}).bind("create_node.jstree",function(){D()}).bind("delete_node.jstree",function(){D()}).bind("close_all.jstree",function(){D()}).bind("after_close.jstree",function(){D()}).bind("move_node.jstree",function(t,s){if(!r){var o=s.old_position;if("#"!=s.parent)return e("#js-tree-menu").jstree("move_node","#"+s.node.id,"#",o),e("#sub-drag-folder-popup").show(),!1}"#"!=s.node.parent&&jQuery("#js-tree-menu").jstree("open_node",s.node.parent),folderMoveId=s.node.id,orderString="",e("#js-tree-menu .jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){"undefined"!=e(this).attr("id")&&(orderString+=e(this).attr("id")+",")}),e("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?parentID=e("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().attr("id"):parentID=0,""!=orderString&&(e(".form-loader-count").css("width","100%"),e.ajax({url:wcp_settings.ajax_url,data:"term_ids="+orderString+"&action=wcp_save_folder_order&type="+wcp_settings.post_type+"&nonce="+wcp_settings.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#wcp_folder_parent").html(t.options),e(".form-loader-count").css("width","0"),H(),Y(),B(),D()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))})}function E(){var t=e.trim(e("#folder-search").val());e("#js-tree-menu").jstree("search",t)}function M(t){e.ajax({url:wcp_settings.ajax_url,type:"post",data:"action=save_folder_last_status&post_type="+wcp_settings.post_type+"&post_id="+t+"&nonce="+wcp_settings.nonce,cache:!1,async:!1,success:function(){}})}function L(){setTimeout(function(){if(currentStatus=!0,e("#js-tree-menu .jstree-node.jstree-leaf").length==e("#js-tree-menu .jstree-node").length)e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand"),e("#expand-collapse-list .text").text("Expand");else{var t=e("#js-tree-menu .jstree-node.jstree-closed").length+e("#js-tree-menu .jstree-node.jstree-open").length;e("#js-tree-menu .jstree-node.jstree-closed").length==t?(e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand"),e("#expand-collapse-list .text").text("Expand")):(e("#expand-collapse-list").addClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Collapse"),e("#expand-collapse-list .text").text("Collapse"))}},500),D()}function V(){0==e(".tree-structure-content .tree-structure li").length?e(".tree-structure-content").hide():(e(".tree-structure-content").show(),oldHeight=e(".tree-structure-content .tree-structure").height(),e(".tree-structure-content .tree-structure").height("auto"),e(".tree-structure-content .tree-structure").height()>56?e(".folders-toggle-button").show():e(".folders-toggle-button").hide(),newHeight=e(".tree-structure-content .tree-structure").height(),e(".tree-structure-content .tree-structure").attr("data-height",newHeight),e(".tree-structure-content").hasClass("active")?(e(".tree-structure-content .tree-structure").height(newHeight),e(".tree-structure-content .tree-structure").attr("data-height",newHeight)):e(".tree-structure-content .tree-structure").height(oldHeight))}function Y(){e(".folder-loader-ajax").addClass("active"),e(".folder-loader-ajax img").removeClass("active"),e(".folder-loader-ajax svg#successAnimation").addClass("active").addClass("animated"),setTimeout(function(){e(".folder-loader-ajax").removeClass("active"),e(".folder-loader-ajax img").addClass("active"),e(".folder-loader-ajax svg#successAnimation").removeClass("active").removeClass("animated")},2e3)}function W(){e(".sticky-folders > ul").html("");var t="";if(e("#js-tree-menu li.jstree-node.is-sticky").each(function(){var s=e(this).attr("id"),o=e.trim(e("#js-tree-menu").jstree(!0).get_node(s).text),a=e("li.jstree-node[id='"+s+"'] > a span.premio-folder-count").text(),n=e("li.jstree-node[id='"+s+"']").hasClass("is-high")?" is-high ":"";t+="<li data-folder-id='"+s+"' class='sticky-fldr "+n+" sticky-folder-"+s+"'><a href='javascript:;'><span class='folder-title'>"+o+"</span><span class='folder-actions'><span class='update-inline-record'><i class='pfolder-edit-folder'></i></span><span class='star-icon'><i class='pfolder-star'></i></span><span class='premio-folder-count'>"+a+"</span></span></a></li>"}),e(".sticky-folders > ul").html(t),e(".jstree-anchor.jstree-clicked").length){var s=e(".jstree-anchor.jstree-clicked").closest("li.jstree-node").attr("id");e(".sticky-folders .sticky-folder-"+s+" a").addClass("active-item")}e(".sticky-folders > ul > li").length>0?e(".sticky-folders").addClass("active"):e(".sticky-folders").removeClass("active"),O()}function B(){if(e("#media-attachment-taxonomy-filter").length&&(e("#media-attachment-taxonomy-filter").each(function(){wcp_settings.terms=y;var t=e(this);currentDDVal=e(this).val(),t.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>"),lastFolderData=y;for(var s=0;s<y.length;s++)t.append("<option value='"+y[s].term_id+"'>"+y[s].name+" ("+y[s].trash_count+")</option>");t.val(currentDDVal).trigger("change")}),e("select.folder_for_media").length)){var t=e("select.folder_for_media").val();e("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var s=0;s<y.length;s++)e("select.folder_for_media option:last-child").before("<option value='"+y[s].term_id+"'>"+y[s].name+"</option>");""!=t&&e(".folder_for_media").val(t)}for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),s=0;s<y.length;s++)0!=parseInt(y[s].trash_count)&&(e(".jstree-node[id='"+y[s].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(y[s].trash_count),e(".sticky-folder-"+y[s].term_id+" .premio-folder-count").text(y[s].trash_count));if(e(".media-select-folder").length){for(e(".media-select-folder").html("<option value=''>Select Folder</option><option value='-1'>(Unassigned)</option>"),s=0;s<y.length;s++)e(".media-select-folder").append("<option value='"+y[s].term_id+"'>"+y[s].name+" ("+y[s].trash_count+")</option>");e(".media-select-folder").val("")}""!=c&&e("#wcp_folder_"+c).addClass("active-item"),p&&(e("#title_"+f).trigger("click"),p=!1)}function q(){e("#bulk-action-selector-top, #bulk-action-selector-bottom").val("-1"),0==e(".wp-list-table tbody input[type='checkbox']:checked").length?alert("Please select items to move in folder"):(e("#bulk-move-folder").show(),e("#bulk-select").html("<option value=''>Loading...</option>"),e(".move-to-folder").attr("disabled",!0),e("#move-to-folder").prop("disabled",!0),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_get_default_list&active_id="+c,method:"post",success:function(t){if(t=e.parseJSON(t),e("#bulk-select").html("<option value=''>Select Folder</option><option value='-1'>(Unassigned)</option>"),e(".move-to-folder").prop("disabled",!1),e("#move-to-folder").prop("disabled",!1),1==t.status){var s=t.taxonomies;for(i=0;i<s.length;i++)e("#bulk-select").append("<option value='"+s[i].term_id+"'>"+s[i].name+"</option>")}}}))}function Q(t){""==c||0==c?(s=wcp_settings.nonce,e.ajax({url:wcp_settings.ajax_url,data:"post_id="+t+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+-1+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){H(),I()}})):e.ajax({url:wcp_settings.ajax_url,data:{post_id:t,action:"premio_check_for_other_folders",active_folder:c,type:wcp_settings.post_type,folder_id:-1,nonce:wcp_settings.nonce,status:wcp_settings.taxonomy_status,taxonomy:c},method:"post",success:function(t){-1==(t=e.parseJSON(t)).status?(e("#unassigned_folders").val(t.data.post_id),e("#confirm-your-change").show()):(H(),I())}})}if(e(document).ready(function(){if(e("body").hasClass("jetpack-connected")&&!e("body").hasClass("mobile")&&!e("body").hasClass("folded")&&e("#adminmenuwrap").length){var l=parseInt(e("#adminmenuwrap").width());"rtl"==e("html").prop("dir")?e(".wcp-content").css("right",l):e(".wcp-content").css("left",l)}e(document).on("click","#collapse-button",function(){setTimeout(function(){if(e("body").hasClass("jetpack-connected")&&!e("body").hasClass("mobile")&&!e("body").hasClass("folded")&&e("#adminmenuwrap").length){var t=parseInt(e("#adminmenuwrap").width());"rtl"==e("html").prop("dir")?e(".wcp-content").css("right",t):e(".wcp-content").css("left",t)}},50)}),y=wcp_settings.taxonomies,o=parseInt(wcp_settings.is_key_active),a=parseInt(wcp_settings.folders),c=parseInt(wcp_settings.selected_taxonomy),n=parseInt(wcp_settings.hasStars),r=parseInt(wcp_settings.hasChildren),C=parseInt(wcp_settings.currentPage),w=wcp_settings.folder_settings,e(document).on("click",".folder-settings-btn > a",function(t){t.stopPropagation(),e(".folder-settings-btn").toggleClass("active")}),e(document).on("click","body,html",function(){e(".folder-settings-btn").removeClass("active")}),e(document).on("click",".folder-setting-menu",function(e){e.stopPropagation()}),A(),O();var d="1"==wcp_settings.isRTL||1==wcp_settings.isRTL?"w":"e";e(".wcp-content").resizable({resizeHeight:!1,handles:d,minWidth:100,maxWidth:500,resize:function(t,s){var o=s.size.width;for(o<=275?e(".plugin-button").addClass("d-block"):e(".plugin-button").removeClass("d-block"),o<=225&&(o=225),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",o+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",o+20+"px"),newWidth=o-40,cssString="",classString="",i=0;i<=15;i++)classString+=" .space > .jstree-node >",currentWidth=newWidth-(13+20*i),cssString+="#js-tree-menu > "+classString+" .title { width: "+currentWidth+"px !important; } ",cssString+="#js-tree-menu > "+classString+" .dynamic-menu { left: "+(currentWidth-190)+"px !important; } ";e("#wcp-custom-style").html("<style>"+cssString+"</style>"),s.size.width<=185?(folderStatus="hide",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").addClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").removeClass("active"),e("#wcp-content").addClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right","20px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left","20px")):e("#wcp-content").hasClass("hide-folders-area")&&(folderStatus="show",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").removeClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").addClass("active"),e("#wcp-content").addClass("no-transition"),e("#wcp-content").removeClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(wcp_settings.folder_width)+20+"px"),setTimeout(function(){e("#wcp-content").removeClass("no-transition")},250))},stop:function(t,o){var a=o.size.width;o.size.width<=275?e(".plugin-button").addClass("d-block"):e(".plugin-button").removeClass("d-block"),a<=225&&(a=225),o.size.width<=185?(folderStatus="hide",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").addClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").removeClass("active"),e("#wcp-content").addClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right","20px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left","20px"),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_folder_display_status&status="+folderStatus+"&nonce="+s,method:"post",success:function(e){}})):e("#wcp-content").hasClass("hide-folders-area")&&(folderStatus="show",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").removeClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").addClass("active"),e("#wcp-content").addClass("no-transition"),e("#wcp-content").removeClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(wcp_settings.folder_width)+20+"px"),setTimeout(function(){e("#wcp-content").removeClass("no-transition")},250)),s=wcp_settings.nonce,wcp_settings.folder_width=o.size.width,e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_post_width&width="+a+"&nonce="+s,method:"post",success:function(e){}}),o.size.width<=225&&(e(".wcp-content").width(225),wcp_settings.folder_width=225)}}),e(document).on("contextmenu",".jstree-anchor",function(t){return j=t.pageX,x=t.pageY,e(this).find("span.folder-inline-edit").trigger("click"),!1}),e(document).on("click",".folder-actions span.folder-inline-edit",function(s){var o;(s.stopImmediatePropagation(),s.stopPropagation(),0!=wcp_settings.can_manage_folder)&&(isHigh=e(this).closest("li.jstree-node").hasClass("is-high"),isSticky=e(this).closest("li.jstree-node").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu' data-id='"+e(this).closest("li").prop("id")+"'><ul>",menuHtml+="<li class='new-main-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>",menuHtml+=r?"<li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>":"<li class='new-folder-pro'><a target='_blank' href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Sub-folder (Pro)</a></li>",menuHtml+="<li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span>Rename</a></li><li class='default-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-active-icon'></i></span>Open this folder by default (Pro)</a></li><li class='sticky-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li>",menuHtml+=n?"<li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star":"Add a Star")+"</a></li>":"<li class='mark-folder-pro'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star (Pro)":"Add a Star (Pro)")+"</a></li>",menuHtml+="<li class='lock-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='dashicons dashicons-lock'></span>Lock Folder (Pro)</a></li><li class='duplicate-folder-pro'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-clone'></i></span>Duplicate folder (Pro)</a></li>",hasPosts=parseInt(e(this).closest("a.jstree-anchor").find(".premio-folder-count").text()),"attachment"==wcp_settings.post_type&&hasPosts&&(menuHtml+="<li target='_blank' class='download-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span>Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span>Delete</a></li></ul></div>",e("body").append(menuHtml),s.pageX==t||s.pageY==t?(e(".dynamic-menu").css("left",j),e(".dynamic-menu").css("top",x-10),o=x):(e(".dynamic-menu").css("left",s.pageX),e(".dynamic-menu").css("top",s.pageY),o=s.pageY),e(this).parents("li.jstree-node").addClass("active-menu"),o+e(".dynamic-menu").height()>e(window).height()&&e(".dynamic-menu").css("margin-top",e(window).height()-(o+e(".dynamic-menu").height())))}),e(document).on("click",".sticky-folders .sticky-fldr > a",function(t){t.stopPropagation();var s=e(this).closest("li").data("folder-id");e(".jstree-node[id='"+s+"']").length&&(e(".jstree-clicked").removeClass("jstree-clicked"),e(".active-item").removeClass("active-item"),e("#js-tree-menu").jstree("select_node",c),e(".jstree-node[id='"+s+"'] > a.jstree-anchor").trigger("click"),e(".jstree-node[id='"+s+"'] > a.jstree-anchor").addClass("jstree-clicked"),e(".sticky-folders .sticky-folder-"+s+" a").addClass("active-item"))}),e(document).on("contextmenu",".sticky-folders li .sticky-fldr > a",function(t){return e(this).find("span.update-inline-record").trigger("click"),!1}),e(document).on("click",".tree-structure a",function(t){t.stopPropagation();var s=e(this).data("id");e(".jstree-node[id='"+s+"']").length&&(e(".jstree-clicked").removeClass("jstree-clicked"),e(".active-item").removeClass("active-item"),e("#js-tree-menu").jstree("select_node",c),e(".jstree-node[id='"+s+"'] > a.jstree-anchor").trigger("click"),e(".jstree-node[id='"+s+"'] > a.jstree-anchor").addClass("jstree-clicked"),e(".sticky-folders .sticky-folder-"+s+" a").addClass("active-item"))}),e(document).on("click",".update-inline-record",function(s){var o;(s.stopImmediatePropagation(),s.stopPropagation(),0!=wcp_settings.can_manage_folder)&&(isHigh=e(this).closest("li.sticky-fldr").hasClass("is-high"),isSticky=e(this).closest("li.sticky-fldr").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu' data-id='"+e(this).closest("li").data("folder-id")+"'><ul>",menuHtml+="<li class='new-main-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>",menuHtml+=r?"<li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>":"<li class='new-folder-pro'><a target='_blank' href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Sub-folder (Pro)</a></li>",menuHtml+="<li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span>Rename</a></li><li class='default-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-active-icon'></i></span>Open this folder by default (Pro)</a></li><li class='sticky-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li>",menuHtml+=n?"<li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star":"Add a Star")+"</a></li>":"<li class='mark-folder-pro'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star (Pro)":"Add a Star (Pro)")+"</a></li>",menuHtml+="<li class='lock-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='dashicons dashicons-lock'></span>Lock Folder (Pro)</a></li><li class='duplicate-folder-pro'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-clone'></i></span>Duplicate folder (Pro)</a></li>",hasPosts=parseInt(e(this).closest("li.jstree-node").find("h3.title:first > .total-count").text()),"attachment"==wcp_settings.post_type&&hasPosts&&(menuHtml+="<li class='download-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span>Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span> Delete</a></li></ul></div>",e("body").append(menuHtml),s.pageX==t||s.pageY==t?(e(".dynamic-menu").css("left",j),e(".dynamic-menu").css("top",x-10),o=x):(e(".dynamic-menu").css("left",s.pageX),e(".dynamic-menu").css("top",s.pageY),o=s.pageY),o+e(".dynamic-menu").height()>e(window).height()&&e(".dynamic-menu").css("margin-top",e(window).height()-(o+e(".dynamic-menu").height())))}),e(document).on("click",".dynamic-menu",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click",".new-folder-pro",function(t){t.preventDefault(),e(".dynamic-menu").remove(),e("#sub-folder-popup").show()}),e(document).on("click",".close-popup-button a",function(){e(".folder-popup-form").hide()}),e(document).on("click","body, html",function(){e(".dynamic-menu").remove()}),e(".wcp-hide-show-buttons .toggle-buttons").on("click",function(){var t="show";e(this).hasClass("hide-folders")&&(t="hide"),e(".wcp-hide-show-buttons .toggle-buttons").toggleClass("active"),s=wcp_settings.nonce,"show"==t?(e("#wcp-content").addClass("no-transition"),e("#wcp-content").removeClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(wcp_settings.folder_width)+20+"px"),setTimeout(function(){e("#wcp-content").removeClass("no-transition")},250)):(e("#wcp-content").addClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right","20px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left","20px")),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_folder_display_status&status="+t+"&nonce="+s,method:"post",success:function(e){}})}),D(),e(document).ajaxComplete(function(e,s,o){o.data!=t&&""!=o.data&&-1!=o.data.indexOf("action=query-attachments")&&D()}),e(document).on("click",".undo-button, .undo-folder-action:not(.disabled)",function(){e("#do-undo").removeClass("active"),"yes"==wcp_settings.useFolderUndo&&e.ajax({url:wcp_settings.ajax_url,type:"post",data:{post_type:wcp_settings.post_type,nonce:wcp_settings.nonce,action:"wcp_undo_folder_changes"},success:function(s){if(e("#undo-done").addClass("active"),setTimeout(function(){e("#undo-done").removeClass("active")},2500),e("#media-attachment-taxonomy-filter").length){var o=parent.wp;o.media!=t&&(o.media.frame.setState("insert"),null!==o.media.frame.content.get()?(o.media.frame.content.get().collection.props.set({ignore:+new Date}),o.media.frame.content.get().options.selection.reset()):o.media.frame.library.props.set({ignore:+new Date}))}H()}})}),e(document).on("click",".close-undo-box",function(t){t.preventDefault(),e("#do-undo").removeClass("active")})}),e(window).on("resize",function(){O()}),e(window).scroll(function(){}),e(document).ready(function(){e(document).on("click","#add-new-folder",function(){e("#js-tree-menu a.jstree-clicked").length?(f=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),r||e("#pro-notice").removeClass("hide-it")):(f=0,e("#pro-notice").addClass("hide-it")),p=!1,J()}),e(document).on("mouseover",".folders-action-menu",function(){e("body").addClass("add-folder-zindex")}).on("mouseleave",".folders-action-menu",function(){e("body").removeClass("add-folder-zindex")}),e(document).on("change","#media-attachment-taxonomy-filter",function(t){e("#js-tree-menu").jstree(!0).deselect_all(),e(".active-item").removeClass("active-item"),"all"==e(this).val()?e(".all-posts").addClass("active-item"):"unassigned"==e(this).val()?e(".un-categorised-items").addClass("active-item"):e("#js-tree-menu").jstree("select_node",e(this).val())}),e(document).on("click",".new-folder",function(){f=e(this).closest(".dynamic-menu").data("id"),p=!1,h=0,J()}),e(document).on("click",".new-main-folder",function(){h=1,f=e(this).closest(".dynamic-menu").data("id"),p=!1,J()}),e(document).on("click",".duplicate-folder",function(t){t.stopPropagation(),h=0,f=e(this).closest(".dynamic-menu").data("id"),e(".dynamic-menu").remove(),p=!1,u=!0,J(),z()}),e(document).on("submit","#save-folder-form",function(t){if(t.stopPropagation(),t.preventDefault(),folderNameDynamic=e.trim(e("#add-update-folder-name").val()),""==e.trim(folderNameDynamic))e(".folder-form-errors").addClass("active"),e("#add-update-folder-name").focus();else{e("#save-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#add-update-folder").addClass("disabled");var s=f;p&&(s=0),r||(s=0);var n="";0==s?(g=e("#js-tree-menu > ul > li.jstree-node").length,h&&(g=jQuery("#js-tree-menu > ul > li[id='"+f+"']").index(),jQuery("#js-tree-menu > ul > li").each(function(e){n+=jQuery(this).attr("id")+",",e==g&&(n+="#,")}),g+=1)):g=e("#js-tree-menu > ul > li.jstree-node[id='"+s+"'] > ul.jstree-children > li").length+1,e.ajax({url:wcp_settings.ajax_url,data:{parent_id:s,type:wcp_settings.post_type,action:"wcp_add_new_folder",nonce:wcp_settings.nonce,term_id:s,order:g,name:folderNameDynamic,is_duplicate:u,duplicate_from:m,parent_ids:n,parent_menu:h},method:"post",success:function(t){if(result=e.parseJSON(t),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),-1==result.status)e("#no-more-folder-credit").show();else if("1"==result.status){if(o=parseInt(result.is_key_active),a=parseInt(result.folders),e("#current-folder").text(a),e("#ttl-fldr").text(10),L(),z(),result.data.length)for(var s=0;s<result.data.length;s++){var n={folder_id:result.data[s].term_id,folder_count:0,is_sticky:result.data[s].is_sticky,is_high:result.data[s].is_high,nonce:result.data[s].nonce,slug:result.data[s].slug,is_deleted:0};w.push(n),h?e("#js-tree-menu").jstree().create_node("#",{id:result.data[s].term_id,text:" "+result.data[s].title},g,function(){e(".jstree-node[id='"+result.data[s].term_id+"']").attr("data-nonce",result.data[s].nonce),e(".jstree-node[id='"+result.data[s].term_id+"']").attr("data-slug",result.data[s].slug)}):e("#js-tree-menu").jstree().create_node(result.parent_id,{id:result.data[s].term_id,text:" "+result.data[s].title},"last",function(){e(".jstree-node[id='"+result.data[s].term_id+"']").attr("data-nonce",result.data[s].nonce),e(".jstree-node[id='"+result.data[s].term_id+"']").attr("data-slug",result.data[s].slug)}),h=0}Y(),W(),e("#media-attachment-taxonomy-filter").length&&(f=result.term_id,Z(0))}else e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show()}})}return!1})}),e(document).ready(function(){e("#inline-update").on("click",function(){e("#js-tree-menu a.jstree-clicked").length&&(f=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),F())}),e(document).on("click",".rename-folder",function(t){t.stopPropagation(),f=e(this).closest(".dynamic-menu").data("id"),F(),e(".dynamic-menu").remove()}),e(document).on("click",".form-cancel-btn",function(){e(".folder-popup-form").hide()}),e(document).on("click",".folder-popup-form",function(t){e(".folder-popup-form").hide()}),e(document).on("click",".popup-form-content",function(e){e.stopPropagation()}),e(document).on("submit","#update-folder-form",function(o){return o.stopPropagation(),o.preventDefault(),folderNameDynamic=e("#update-folder-item-name").val(),""==e.trim(folderNameDynamic)?(e(".folder-form-errors").addClass("active"),e("#update-folder-item-name").focus()):(e("#update-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#update-folder-item").addClass("disabled"),s=P(f,"nonce"),parentID=e(".jstree-node[id='"+f+"']").closest("li.jstree-node").attr("id"),parentID==t&&(parentID=0),e.ajax({url:wcp_settings.ajax_url,data:{parent_id:parentID,type:wcp_settings.post_type,action:"wcp_update_folder",nonce:s,term_id:f,order:g,name:folderNameDynamic},method:"post",success:function(t){result=e.parseJSON(t),"1"==result.status?(e("#js-tree-menu").jstree("rename_node",result.id," "+result.term_title),folderPostId=T(result.id),null!=folderPostId&&(w[folderPostId].nonce=result.nonce,w[folderPostId].slug=result.slug),z(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),Y(),e("#media-attachment-taxonomy-filter").length&&Z(0)):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show())}})),!1})}),e(document).ready(function(){e(document).on("click","#inline-remove, .delete-folder-action:not(.disabled)",function(){e("#js-tree-menu a.jstree-clicked").length?(f=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),R(1),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")):e("#menu-checkbox").is(":checked")&&(e(".dynamic-menu").remove(),R(1))}),e(document).on("click","#menu-checkbox",function(){e(this).is(":checked")?(e("#js-tree-menu").addClass("show-folder-checkbox"),e("#menu-checkbox").prop("checked",!0)):(e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox"),e("#menu-checkbox").prop("checked",!1))}),e(document).on("click","#menu-checkbox",function(){e(this).is(":checked")?(e("#menu-checkbox").prop("checked",!0),e("#js-tree-menu").addClass("show-folder-checkbox")):(e("#menu-checkbox").prop("checked",!1),e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox"))}),e(document).on("click",".folder-checkbox, .input-checkbox",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click",".remove-folder",function(){folderID=e(this).closest("li.jstree-node").data("id"),f=e(this).closest(".dynamic-menu").data("id"),R(0),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")}),e(document).on("click","#remove-folder-item",function(t){t.stopPropagation(),e(".folder-popup-form").addClass("disabled"),e("#remove-folder-item").html('<span class="dashicons dashicons-update"></span>'),s=P(f,"nonce"),_?function(){if(e("#menu-checkbox").is(":checked")&&e("#js-tree-menu input.checkbox:checked").length>0){var t="";e("#js-tree-menu input.checkbox:checked").each(function(){t+=e(this).closest("li.jstree-node").attr("id")+",",e(this).closest("li.jstree-node").hasClass("jstree-clicked")&&!0}),e(".form-loader-count").css("width","100%"),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_remove_muliple_folder&term_id="+t+"&nonce="+wcp_settings.nonce,method:"post",success:function(t){if(t=e.parseJSON(t),e(".form-loader-count").css("width","0px"),"1"==t.status){for(o=parseInt(t.is_key_active),a=parseInt(t.folders),e("#current-folder").text(a),i=0;i<t.term_ids.length;i++)e("#js-tree-menu").jstree().delete_node(t.term_ids[i]);e("#ttl-fldr").text(10),Y(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),H(),W(),Y(),e("#js-tree-menu li.jstree-node").removeClass("has-sub-tree"),e("#js-tree-menu li.jstree-node").each(function(){e(this).find("ul.ui-sortable li").length?e(this).addClass("has-sub-tree"):e(this).removeClass("active")}),e("#wcp_folder_"+c).length||(e(".header-posts a").trigger("click"),c=0)}else window.location.reload();e("#menu-checkbox").attr("checked",!1),e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox")}})}}():e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_remove_folder&term_id="+f+"&nonce="+s,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#js-tree-menu").jstree().delete_node(f),o=parseInt(t.is_key_active),a=parseInt(t.folders),e("#current-folder").text(a),e("#ttl-fldr").text(10),e(".sticky-folders .sticky-folder-"+f).remove(),z(),Y(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),H(),W(),c==f&&e(".header-posts").trigger("click")):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})})}),e(document).ready(function(){e(document).on("click",".mark-folder",function(t){t.stopPropagation(),folderID=e(this).closest(".dynamic-menu").data("id"),s=P(folderID,"nonce"),e(".form-loader-count").css("width","100%"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),e.ajax({url:wcp_settings.ajax_url,data:"term_id="+folderID+"&type="+wcp_settings.post_type+"&action=wcp_mark_un_mark_folder&nonce="+s,method:"post",cache:!1,success:function(t){t=e.parseJSON(t),e(".form-loader-count").css("width","0%"),"1"==t.status?(folderPostId=T(t.id),"1"==t.marked?(e("li.jstree-node[id='"+t.id+"']").addClass("is-high"),e(".sticky-folder-"+t.id).addClass("is-high"),null!=folderPostId&&(w[folderPostId].is_high=1)):(e("li.jstree-node[id='"+t.id+"']").removeClass("is-high"),e(".sticky-folder-"+t.id).removeClass("is-high"),null!=folderPostId&&(w[folderPostId].is_high=0)),z(),Y()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})})}),e(document).ready(function(){e(document).on("click",".jstree-node .jstree-icon",function(){folderID=e(this).closest("li.jstree-node").attr("id"),e("li.jstree-node[id='"+folderID+"']").hasClass("jstree-open")?folderStatus=1:folderStatus=0,e(".form-loader-count").css("width","100%"),s=P(folderID,"nonce"),L(),e.ajax({url:wcp_settings.ajax_url,data:"is_active="+folderStatus+"&action=save_wcp_folder_state&term_id="+folderID+"&nonce="+s,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=e.parseJSON(t)).status||(e("#wcp_folder_"+folderID).hasClass("active")?(e("#wcp_folder_"+folderID).removeClass("active"),e("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideUp(),folderStatus=0):(e("#wcp_folder_"+folderID).addClass("active"),e("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideDown(),folderStatus=1),Y())}})})}),e(document).ready(function(){e(document).on("click","a.jstree-anchor",function(t){if(C=1,t.stopPropagation(),e(".un-categorised-items").removeClass("active-item"),e(".header-posts a").removeClass("active-item"),e("active-item").removeClass("active-item"),c=e(this).closest("li.jstree-node").attr("id"),f=e(this).closest("li.jstree-node").attr("id"),e(".sticky-folders .sticky-folder-"+c+" a").addClass("active-item"),e("#media-attachment-taxonomy-filter").length){var s=e(this).closest("li.jstree-node").attr("id");e("#media-attachment-taxonomy-filter").val(s),e("#media-attachment-taxonomy-filter").trigger("change"),thisSlug=P(s,"slug"),b=wcp_settings.page_url+thisSlug+"&paged="+C;var o={Title:thisSlug,Url:b};history.pushState(o,o.Title,o.Url),M(thisSlug),e(".custom-media-select").removeClass("active")}else{var a=P(c,"slug");b=wcp_settings.page_url+a+"&paged="+C,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(b+" #posts-filter",function(){var t={Title:a,Url:b};history.pushState(t,t.Title,t.Url),M(a),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),N()}):e("#wpbody").load(b+" #wpbody-content",function(){var t={Title:a,Url:b};history.pushState(t,t.Title,t.Url),M(a),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),N()})}U(),e(".sticky-folders .sticky-folder-"+c+" a").addClass("active-item")}),e(document).on("click","#js-tree-menu input.checkbox",function(){S()}),e(".header-posts").on("click",function(){if(c="",e(".wcp-container .route").removeClass("active-item"),e(".un-categorised-items").removeClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(".header-posts a").addClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e("#media-attachment-taxonomy-filter").length){c="",e("#media-attachment-taxonomy-filter").val("all"),e("#media-attachment-taxonomy-filter").trigger("change");var t={Title:"",Url:wcp_settings.page_url};history.pushState(t,t.Title,t.Url),M("all"),U()}else C=1,b=wcp_settings.page_url+"&paged="+C,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(b+" #posts-filter",function(){var t={Title:"",Url:b};history.pushState(t,t.Title,t.Url),M("all"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U(),N()}):e("#wpbody").load(b+" #wpbody-content",function(){var t={Title:"",Url:b};history.pushState(t,t.Title,t.Url),M("all"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U(),N()});S()}),e(".un-categorised-items").on("click",function(){if(c="-1",e(".wcp-container .route").removeClass("active-item"),e(".header-posts a").removeClass("active-item"),e(".un-categorised-items").addClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e("#media-attachment-taxonomy-filter").length){e("#media-attachment-taxonomy-filter").val("unassigned"),e("#media-attachment-taxonomy-filter").trigger("change");var t={Title:"",Url:wcp_settings.page_url+"-1"};history.pushState(t,t.Title,t.Url),M("-1"),U()}else C=1,b=wcp_settings.page_url+"-1&paged="+C,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(b+" #posts-filter",function(){var t={Title:"",Url:b};history.pushState(t,t.Title,t.Url),M("-1"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U(),N()}):e("#wpbody").load(b+" #wpbody-content",function(){var t={Title:"",Url:b};history.pushState(t,t.Title,t.Url),M("-1"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U(),N()});S()}),e("#expand-collapse-list").on("click",function(t){t.stopPropagation(),statusType=0,e(this).hasClass("all-open")?(e(this).removeClass("all-open"),statusType=0,e(this).attr("data-folder-tooltip","Expand"),e("#js-tree-menu").jstree("close_all"),e("#expand-collapse-list .text").text("Expand")):(e(this).addClass("all-open"),statusType=1,e(this).attr("data-folder-tooltip","Collapse"),e("#js-tree-menu").jstree("open_all"),e("#expand-collapse-list .text").text("Collapse")),v="",e("#js-tree-menu .jstree-node:not(.jstree-leaf)").each(function(){v+=e(this).attr("id")+","}),""!=v&&(e(".form-loader-count").css("width","100%"),s=wcp_settings.nonce,e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_all_status&status="+statusType+"&folders="+v+"&nonce="+s,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=e.parseJSON(t)).status&&(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))}),L()}),e(document).ready(function(){e(document).on("click","body, html",function(){e(".folder-order").removeClass("active")}),e(document).on("click","#sort-order-list",function(t){t.stopPropagation(),e(".folder-order").toggleClass("active")}),e(document).on("click",".folder-sort-menu a:not(.pro-feature)",function(t){t.stopPropagation(),t.preventDefault(),e(".form-loader-count").css("width","100%"),e(".folder-order").removeClass("active"),lastOrderStatus=e(this).attr("data-sort"),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_folders_by_order&nonce="+wcp_settings.nonce+"&order="+e(this).attr("data-sort"),method:"post",success:function(t){1==(t=e.parseJSON(t)).status&&(e("#js-tree-menu").jstree().destroy(),e("#js-tree-menu").append("<ul></ul>"),e("#js-tree-menu ul").html(t.data),A(),y=t.terms,B()),e(".form-loader-count").css("width","0"),U()}})})}),e(document).ready(function(){e(document).on("keyup","#folder-search",function(){E()}),e(document).on("change","#folder-search",function(){E()}),e(document).on("blur","#folder-search",function(){E()}),e(document).on("click","#do_not_show_again",function(){var t=e(this).is(":checked")?1:0;e.ajax({url:wcp_settings.ajax_url,type:"post",data:{action:"premio_hide_child_popup",status:t,nonce:wcp_settings.nonce,post_type:wcp_settings.post_type}})})}),e(document).ready(function(){e(document).on("click",".folders-toggle-button",function(){dbStatus="show",e(".tree-structure-content").hasClass("active")?(e(".tree-structure-content .tree-structure").animate({height:"40px"},100,function(){e(".tree-structure-content").removeClass("active")}),dbStatus="hide"):(newHeight=parseInt(e(".tree-structure-content .tree-structure").attr("data-height")),e(".tree-structure-content .tree-structure").animate({height:newHeight},100,function(){e(".tree-structure-content").addClass("active")})),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_hide_folders&status="+dbStatus+"&nonce="+wcp_settings.nonce,method:"post",success:function(e){}})})}),e(document).ready(function(){e(document).on("click","#remove-from-all-folders:not(.disabled), #remove-from-current-folder:not(.disabled)",function(){e("#remove-from-all-folders, #remove-from-current-folder").addClass("disabled");var t="all";e(this).hasClass("remove-from-current-folder")&&(t="current"),e("#confirm-your-change").hide(),e.ajax({url:wcp_settings.ajax_url,data:{post_id:e("#unassigned_folders").val(),action:"wcp_remove_post_folder",active_folder:c,type:wcp_settings.post_type,folder_id:-1,nonce:wcp_settings.nonce,status:wcp_settings.taxonomy_status,taxonomy:c,remove_from:t},method:"post",success:function(t){e("#remove-from-all-folders, #remove-from-current-folder").removeClass("disabled"),Y(),H(),I()}})}),e(document).on("click",".thumbnail-hover-box a",function(t){return t.stopPropagation(),t.stopImmediatePropagation(),t.preventDefault(),window.open(e(this).prop("href"),"_blank"),wp.media.frame.close(),!1}),e(document).on("click","#doaction",function(t){return"move_to_folder"==e("#bulk-action-selector-top").val()?(q(),!1):"edit"==e("#bulk-action-selector-top").val()&&"object"==typeof inlineEditPost?(inlineEditPost.setBulk(),!1):void 0}),e(document).on("click","#doaction2",function(t){return"move_to_folder"==e("#bulk-action-selector-bottom").val()?(q(),!1):"edit"==e("#bulk-action-selector-bottom").val()&&"object"==typeof inlineEditPost?(inlineEditPost.setBulk(),!1):void 0}),e(document).on("submit","#bulk-folder-form",function(t){t.stopPropagation(),t.preventDefault(),""!=e("#bulk-select").val()&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),""!=e("#bulk-select").val()&&("-1"==e("#bulk-select").val()?e.ajax({url:wcp_settings.ajax_url,data:"post_id="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+e(this).val()+"&nonce="+wcp_settings.nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){e("#bulk-move-folder").hide(),H(),Y()}}):(s=P(e("#bulk-select").val(),"nonce"),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+e("#bulk-select").val()+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){t=e.parseJSON(t),e("#bulk-move-folder").hide(),"1"==t.status?(H(),Y()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}}))))})}),"attachment"==wcp_settings.post_type){e(document).ready(function(){"show"==wcp_settings.show_in_page&&e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div><div class="folders-toggle-button"><span></span></div></div>'),z(),V()});var X=null;function Z(s){X=e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_get_default_list&active_id="+c,method:"post",beforeSend:function(){null!=X&&X.abort()},success:function(o){if(o=e.parseJSON(o),e(".header-posts .total-count").text(o.total_items),e(".un-categorised-items .total-count").text(o.empty_items),selectedVal=e("#media-attachment-taxonomy-filter").val(),"all"!=selectedVal&&1==s){var a=parent.wp;a.media!=t&&(a.media.frame.setState("insert"),null!==a.media.frame.content.get()?(a.media.frame.content.get().collection.props.set({ignore:+new Date}),a.media.frame.content.get().options.selection.reset()):a.media.frame.library.props.set({ignore:+new Date}))}y=o.taxonomies,B(),""!=c&&e("#wcp_folder_"+c).addClass("active-item"),p&&(e("#title_"+f).trigger("click"),p=!1)}})}function G(){e(".media-frame-content .media-toolbar").width(e(".media-frame-content").width()-20)}function K(e,t,s){var o="";if(s){var a=new Date;a.setTime(a.getTime()+24*s*60*60*1e3),o="; expires="+a.toUTCString()}document.cookie=e+"="+(t||"")+o+"; path=/"}function $(e){document.cookie=e+"=; Max-Age=-99999999;"}G(),e(window).resize(function(){G()}),e(document).on("click",".button.organize-button",function(){e(".media-frame").hasClass("mode-select")?$("media-select-mode"):K("media-select-mode","on",7),e("button.button.media-button.select-mode-toggle-button").trigger("click"),e(".media-frame").hasClass("mode-select")?(e(".media-info-message").addClass("active"),e(".select-all-item-btn").addClass("active")):(e(".media-info-message, .custom-media-select").removeClass("active"),e(".select-all-item-btn").removeClass("active"))}),e(document).on("click",".select-mode-toggle-button",function(){setTimeout(function(){e(".media-frame").hasClass("mode-select")||K("media-select-mode","off",-1),e(".media-frame").hasClass("mode-select")?(e(".media-info-message").addClass("active"),e(".select-all-item-btn").addClass("active")):(e(".media-info-message, .custom-media-select").removeClass("active"),e(".select-all-item-btn").removeClass("active"))},10)}),e(document).on("click",".select-all-item-btn",function(){e("ul.attachments li:not(.selected)").trigger("click")}),e(document).on("change",".folder_for_media",function(){"add-folder"==e(this).val()&&(f=0,p=!0,J())}),e(window).scroll(function(){})}else;function ee(){e("button.button.media-button.select-mode-toggle-button").length&&(clearInterval(l),e("button.button.media-button.select-mode-toggle-button").after("<button class='button organize-button'>Bulk Organize</button>"),e(".media-toolbar-secondary").append("<span class='media-info-message'>Drag and drop your media files to the relevant folders</span>"),e(".delete-selected-button").before("<button type='button' class='button button-primary select-all-item-btn'>Select All</button>"),e(".media-toolbar-secondary").after("<div class='custom-media-select'>Move Selected files to: <select class='media-select-folder'></select></div>"),e(".media-toolbar").append("<div style='clear:both;'></div><div class='media-folder-loader'><span>Uploading files</span> <span id='current_upload_files'></span>/<span id='total_upload_files'></span><div class='folder-progress'><div class='folder-meter orange-bg'><span></span></div></div></div>"),e(".wcp-custom-form").length&&(wp.Uploader!==t&&wp.Uploader.queue.on("reset",function(){Z(1)}),e(document).ajaxComplete(function(e,t,s){actionName=s.data,"undefined"!=typeof actionName&&actionName.length&&0==actionName.indexOf("action=delete-post&id=")&&Z(0)})),setTimeout(function(){docReferrar=document.referrer,-1!=docReferrar.indexOf("wp-admin/upload.php")?(mediaMode=function(e){for(var t=e+"=",s=document.cookie.split(";"),o=0;o<s.length;o++){for(var a=s[o];" "==a.charAt(0);)a=a.substring(1,a.length);if(0==a.indexOf(t))return a.substring(t.length,a.length)}return null}("media-select-mode"),"on"==mediaMode&&(e("button.button.media-button.select-mode-toggle-button").trigger("click"),e(".media-frame").hasClass("mode-select")?e(".media-info-message").addClass("active"):e(".media-info-message, .custom-media-select").removeClass("active"))):$("media-select-mode"),Z(1)},1e3))}e(document).ready(function(){"attachment"==wcp_settings.post_type&&e("#tmpl-media-frame").length&&(l=setInterval(function(){ee()},1e3)),e(document).on("click",".attachments-browser ul.attachments .thumbnail",function(){"attachment"==wcp_settings.post_type&&e(".media-toolbar").hasClass("media-toolbar-mode-select")&&(0==e("ul.attachments li.selected").length?e(".custom-media-select").removeClass("active"):e(".custom-media-select").addClass("active"))}),e(document).on("change",".media-select-folder",function(){if("attachment"==wcp_settings.post_type&&""!=e(this).val()){var t="";e(".attachments-browser li.attachment.selected").each(function(){t+=e(this).attr("data-id")+","}),"-1"==e(this).val()?e.ajax({url:wcp_settings.ajax_url,data:"post_id="+t+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+e(this).val()+"&nonce="+wcp_settings.nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){0!=f&&f!=e(".media-select-folder").val()&&e("ul.attachments li.selected").remove(),H(),Y()}}):(s=P(e(this).val(),"nonce"),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+t+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+e(this).val()+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){t=e.parseJSON(t),e("#bulk-move-folder").hide(),"1"==t.status?(0!=f&&f!=e(".media-select-folder").val()&&e("ul.attachments li.selected").remove(),H(),Y()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}}))}})})});
|
1 |
+
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e,t){var s,o,a,n,r,l,d="#js-tree-menu",c="",p=!1,u=!1,m=0,f=0,h=0,g=0,_=!1,v="",w=[],b=wcp_settings.page_url,y=[],k="<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'><div class='folder-item is-folder' data-id='__folder_id__'><a title='__folder_name__' id='folder_view___folder_id__'class='folder-view __append_class__ has-new-folder'data-id='__folder_id__'><span class='folder item-name'><span id='wcp_folder_text___folder_id__'class='folder-title'>__folder_name__</span></span></a></div></li>",j=null,x=null,C=1;function I(){"yes"==wcp_settings.useFolderUndo&&(e("#do-undo").addClass("active"),e(".undo-folder-action").removeClass("disabled"),setTimeout(function(){e("#do-undo").removeClass("active"),e(".undo-folder-action").addClass("disabled")},parseInt(wcp_settings.defaultTimeout)))}function S(){e(".cut-folder-action, .copy-folder-action, .paste-folder-action, .delete-folder-action").addClass("disabled"),e("#js-tree-menu .jstree-anchor.jstree-clicked").length&&e(".delete-folder-action").removeClass("disabled"),e("#menu-checkbox").is(":checked")&&e("#js-tree-menu input.checkbox:checked").length>0&&e(".delete-folder-action").removeClass("disabled")}function D(){S(),e(".wcp-move-file:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:"clone",cursor:"move",start:function(t,s){e(this).closest("td").addClass("wcp-draggable"),e("body").addClass("no-hover-css")},stop:function(t,s){e(this).closest("td").removeClass("wcp-draggable"),e("body").removeClass("no-hover-css")}}),e(".wcp-move-multiple:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:function(t,s){return e(".selected-items").remove(),selectedItems=e("#the-list th input:checked").length,selectedItems>0?(selectedItems=0==selectedItems||1==selectedItems?"1 Item":selectedItems+" Items",e("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")):e("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>")},start:function(t,s){e("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(t,s){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}}),e(".jstree-anchor:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){folderID=e(this).closest("li.jstree-node").attr("id"),o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),s=P(folderID,"nonce"),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(I(),H()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(I(),H()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),v=chkStr,e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){I(),H()}}))}}),e(".un-categorised-items:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){folderID=-1,s=wcp_settings.nonce,o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),Q(chkStr)):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,chkStr=postID+",",e(".wp-list-table input:checked").each(function(){postID!=e(this).val()&&(chkStr+=e(this).val()+",")}),Q(chkStr)):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),v=chkStr,Q(chkStr))}}),e(".attachments-browser li.attachment:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:function(t,s){return e(".selected-items").remove(),selectedItems=e(".attachments-browser li.attachment.selected").length,selectedItems=0==selectedItems||1==selectedItems?"1 Item":selectedItems+" Items",e("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")},start:function(t,s){e("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(t,s){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}}),e(".tree-structure .folder-item:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){e("body").removeClass("no-hover-css"),folderID=e(this).data("id"),o.draggable.hasClass("wcp-move-multiple")?(s=P(folderID,"nonce"),e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){I(),H(),Y()}}))):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){I(),H(),Y()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){I(),H(),Y()}}))}}),e(".sticky-folders li a:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){folderID=e(this).closest("li").data("folder-id"),o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),s=P(folderID,"nonce"),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(I(),H(),Y()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(I(),H(),Y()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,s=P(folderID,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),v=chkStr,e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+folderID+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){I(),H(),Y()}}))}}),B()}function P(e,t){if(w.length>0)for(i=0;i<w.length;i++)if(parseInt(w[i].folder_id)==parseInt(e))return w[i][t];return""}function T(e){if(w.length>0)for(i=0;i<w.length;i++)if(parseInt(w[i].folder_id)==parseInt(e))return i;return null}function H(){if(e(".media-toolbar").hasClass("media-toolbar-mode-select")&&e("ul.attachments li.selected").length&&(e("ul.attachments li.selected").trigger("click"),e(".select-mode-toggle-button").trigger("click")),""!=v&&(e("#js-tree-menu a.jstree-clicked").length>0||"-1"==c)){if(e("#media-attachment-taxonomy-filter").length){v=v.split(",");for(var t=0;t<v.length;t++)""!=v[t]&&e(".attachments-browser li[data-id='"+v[t]+"']").remove()}v=""}e("#media-attachment-taxonomy-filter").length?Z(0):(e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=get_folders_default_list",method:"post",success:function(t){t=e.parseJSON(t),e(".header-posts .total-count").text(t.total_items),e(".un-categorised-items .total-count").text(t.empty_items),y=t.taxonomies,B()}}),e(".folder-loader-ajax").addClass("active"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(b+"&paged="+C+" #posts-filter",function(){var t={Title:"",Url:b+"&paged="+C};history.pushState(t,t.Title,t.Url),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U(),N()}):e("#wpbody").load(b+"&paged="+C+" #wpbody-content",!1,function(t){var s={Title:"",Url:b+"&paged="+C};history.pushState(s,s.Title,s.Url),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U()}))}function N(){U(),e(".form-loader-count").css("width","0"),"object"==typeof inlineEditPost&&(inlineEditPost.init(),e("#the-list").on("click",".editinline",function(){e(this).attr("aria-expanded","true"),inlineEditPost.edit(this)}),e(document).on("click",".inline-edit-save .save",function(){var t=e(this).closest("tr").attr("id");t=(t=t.replace("edit-","")).replace("post-",""),inlineEditPost.save(t)}),e(document).on("click",".inline-edit-save .cancel",function(){var t=e(this).closest("tr").attr("id");t=(t=t.replace("edit-","")).replace("post-",""),inlineEditPost.revert(t)})),"attachment"==wcp_settings.post_type&&(e(".move-to-folder-top").length||e("#bulk-action-selector-top").append("<option class='move-to-folder-top' value='move_to_folder'>Move to Folder</option>"),e(".move-to-folder-bottom").length||e("#bulk-action-selector-bottom").append("<option class='move-to-folder-bottom' value='move_to_folder'>Move to Folder</option>"))}function U(){if(w.length&&e("li.jstree-node").each(function(){folderPostId=T(e(this).attr("id")),null!=folderPostId&&(1==w[folderPostId].is_high?e(this).addClass("is-high"):e(this).removeClass("is-high"),1==w[folderPostId].is_sticky?e(this).addClass("is-sticky"):e(this).removeClass("is-sticky"))}),folderId=0,e(".tree-structure ul").html(""),folderStatus=!0,e(".jstree-clicked").length&&(folderID=e(".jstree-clicked").closest(".jstree-node").attr("id"),e(".jstree-node[id='"+folderID+"'] > ul.jstree-children > li.jstree-node").length?(folderStatus=!1,e(".jstree-node[id='"+folderID+"'] > ul.jstree-children > li.jstree-node").each(function(){fID=e(this).attr("id"),fName=e.trim(e("#js-tree-menu").jstree(!0).get_node(fID).text),liHtml=k.replace(/__folder_id__/g,fID),liHtml=liHtml.replace(/__folder_name__/g,fName),selectedClass=e(this).hasClass("is-high")?"is-high":"",liHtml=liHtml.replace(/__append_class__/g,selectedClass),e(".tree-structure ul").append(liHtml)})):e(".jstree-node[id='"+folderID+"']").closest("ul").hasClass("jstree-container-ul")||(folderStatus=!1)),folderStatus&&e("#js-tree-menu > ul > li.jstree-node").each(function(){fID=e(this).attr("id"),fName=e.trim(e("#js-tree-menu").jstree(!0).get_node(fID).text),liHtml=k.replace(/__folder_id__/g,fID),liHtml=liHtml.replace(/__folder_name__/g,fName),selectedClass=e(this).hasClass("is-high")?"is-high":"",liHtml=liHtml.replace(/__append_class__/g,selectedClass),e(".tree-structure ul").append(liHtml)}),V(),"attachment"==wcp_settings.post_type&&(e(".move-to-folder-top").length||e("#bulk-action-selector-top").append("<option class='move-to-folder-top' value='move_to_folder'>Move to Folder</option>"),e(".move-to-folder-bottom").length||e("#bulk-action-selector-bottom").append("<option class='move-to-folder-bottom' value='move_to_folder'>Move to Folder</option>")),e(".sticky-folders .active-item").removeClass("active-item"),e("#js-tree-menu li.jstree-node.active-item").length){var t=e("#js-tree-menu li.jstree-node.active-item").data("folder-id");e(".sticky-folders .sticky-folder-"+t+" a").addClass("active-item")}D()}function O(){contentHeight=e(window).height()-e("#wpadminbar").height()-e(".sticky-wcp-custom-form").height()-30;var t=0;if(e("#custom-scroll-menu").hasClass("mCustomScrollbar")){var s=e("#custom-scroll-menu"),o=s.find(".mCSB_dragger"),a=s.find(".mCSB_container").height();t=o.position().top/(s.height()-o.height())*(a-s.height()),e("#custom-scroll-menu").mCustomScrollbar("destroy")}e("#custom-scroll-menu").mCustomScrollbar({axis:"y",scrollButtons:{enable:!1},setHeight:contentHeight,theme:"3d",scrollbarPosition:"inside",scrollInertia:500,mouseWheelPixels:60}),0!=t&&e("#custom-scroll-menu").mCustomScrollbar("scrollTo",t+"px",{scrollInertia:0})}function z(){U()}function J(){if(0==o&&a>=10)return e("#folder-limitation-message").html("You've reached the 10 folder limitation!"),e("#no-more-folder-credit").show(),!1;e("#add-update-folder-title").text("Add a new folder"),e("#save-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#add-update-folder-name").val(""),u&&(m=f,e("#add-update-folder-name").val(e.trim(e("#js-tree-menu").jstree(!0).get_node(f).text)+" #2"),f=e("#"+f+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?e("#"+f+"_anchor").closest(".jstree-node").parent().parent().attr("id"):0),e("#add-update-folder").removeClass("disabled"),e("#add-update-folder").show(),e("#add-update-folder-name").focus(),e(".dynamic-menu").remove()}function F(){folderName=e.trim(e("#js-tree-menu").jstree(!0).get_node(f).text),parentID=e("#wcp_folder_"+f).closest("li.jstree-node").data("folder-id"),parentID==t&&(parentID=0),e("#update-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#update-folder-item-name").val(folderName),e("#update-folder-item").removeClass("disabled"),e("#update-folder-item").show(),e("#update-folder-item-name").focus(),e(".dynamic-menu").remove()}function R(t){var s="Are you sure you want to delete the selected folder?",o="Items in the folder will not be deleted.";if(_=!1,1==t&&e("#menu-checkbox").is(":checked")){if(_=!0,0==e("#js-tree-menu input.checkbox:checked").length)return e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html("Please select at least one folder to delete"),void e("#error-folder-popup").show();e("#js-tree-menu input.checkbox:checked").length>1&&(s="Are you sure you want to delete the selected folders?",o="Items in the selected folders will not be deleted.")}e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#remove-folder-item").text("Yes, Delete it!"),e("#remove-folder-message").text(s),e("#remove-folder-notice").text(o),e("#confirm-remove-folder").show(),e("#remove-folder-item").focus()}function A(){e(d).jstree({core:{cache:!1,animation:0,max_depth:r?"-1":1,check_callback:function(t,s,o,a,n){if(e("*").removeClass("drag-bot").removeClass("drag-in").removeClass("drag-up"),("move_node"===t||"copy_node"===t)&&n&&n.dnd)switch(n.pos){case"a":n.origin.get_node(n.ref,!0).addClass("drag-bot"),nodeId=e(".drag-bot").attr("id"),e("#jstree-dnd").text("Below "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"i":if(!r&&e("#do_not_show_again").is(":checked"))return!1;n.origin.get_node(n.ref,!0).addClass("drag-in"),nodeId=e(".drag-in").attr("id"),e("#jstree-dnd").text("Inside "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"b":n.origin.get_node(n.ref,!0).addClass("drag-up"),nodeId=e(".drag-up").attr("id"),e("#jstree-dnd").text("Above "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;default:e("#jstree-dnd").text(e("#jstree-dnd").data("txt"))}return!0}},data:{cache:!1},select_node:!1,search:{show_only_matches:!0,case_sensitive:!1,fuzzy:!1},plugins:["dnd","search","contextmenu"],contextmenu:{select_node:0,show_at_node:0,items:function(){return{}}}}).bind("ready.jstree",function(){e("#js-tree-menu .jstree-node").each(function(){var t=parseInt(e(this).data("count"));t>0&&e(".jstree-node[id='"+e(this).attr("id")+"'] > a span.premio-folder-count").text(t)}),""!=c&&0!=c&&e(".jstree-node[id='"+c+"']").length&&(e("#js-tree-menu").jstree("select_node",c),e(".sticky-folders .sticky-folder-"+c+" a").length&&e(".sticky-folders .sticky-folder-"+c+" a").addClass("active-item")),e(".ajax-preloader").hide(),e(".js-tree-data").show(),O(),W(),e(".sticky-folders ul > li").length>0&&e(".sticky-folders").addClass("active"),U(),D(),S()}).bind("after_open.jstree",function(){D()}).bind("open_all.jstree",function(){D()}).bind("create_node.jstree",function(){D()}).bind("delete_node.jstree",function(){D()}).bind("close_all.jstree",function(){D()}).bind("after_close.jstree",function(){D()}).bind("move_node.jstree",function(t,s){if(!r){var o=s.old_position;if("#"!=s.parent)return e("#js-tree-menu").jstree("move_node","#"+s.node.id,"#",o),e("#sub-drag-folder-popup").show(),!1}"#"!=s.node.parent&&jQuery("#js-tree-menu").jstree("open_node",s.node.parent),folderMoveId=s.node.id,orderString="",e("#js-tree-menu .jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){"undefined"!=e(this).attr("id")&&(orderString+=e(this).attr("id")+",")}),e("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?parentID=e("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().attr("id"):parentID=0,""!=orderString&&(e(".form-loader-count").css("width","100%"),e.ajax({url:wcp_settings.ajax_url,data:"term_ids="+orderString+"&action=wcp_save_folder_order&type="+wcp_settings.post_type+"&nonce="+wcp_settings.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#wcp_folder_parent").html(t.options),e(".form-loader-count").css("width","0"),H(),Y(),B(),D()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))})}function E(){var t=e.trim(e("#folder-search").val());e("#js-tree-menu").jstree("search",t)}function M(t){e.ajax({url:wcp_settings.ajax_url,type:"post",data:"action=save_folder_last_status&post_type="+wcp_settings.post_type+"&post_id="+t+"&nonce="+wcp_settings.nonce,cache:!1,async:!1,success:function(){}})}function L(){setTimeout(function(){if(currentStatus=!0,e("#js-tree-menu .jstree-node.jstree-leaf").length==e("#js-tree-menu .jstree-node").length)e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand"),e("#expand-collapse-list .text").text("Expand");else{var t=e("#js-tree-menu .jstree-node.jstree-closed").length+e("#js-tree-menu .jstree-node.jstree-open").length;e("#js-tree-menu .jstree-node.jstree-closed").length==t?(e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand"),e("#expand-collapse-list .text").text("Expand")):(e("#expand-collapse-list").addClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Collapse"),e("#expand-collapse-list .text").text("Collapse"))}},500),D()}function V(){0==e(".tree-structure-content .tree-structure li").length?e(".tree-structure-content").hide():(e(".tree-structure-content").show(),oldHeight=e(".tree-structure-content .tree-structure").height(),e(".tree-structure-content .tree-structure").height("auto"),e(".tree-structure-content .tree-structure").height()>56?e(".folders-toggle-button").show():e(".folders-toggle-button").hide(),newHeight=e(".tree-structure-content .tree-structure").height(),e(".tree-structure-content .tree-structure").attr("data-height",newHeight),e(".tree-structure-content").hasClass("active")?(e(".tree-structure-content .tree-structure").height(newHeight),e(".tree-structure-content .tree-structure").attr("data-height",newHeight)):e(".tree-structure-content .tree-structure").height(oldHeight))}function Y(){e(".folder-loader-ajax").addClass("active"),e(".folder-loader-ajax img").removeClass("active"),e(".folder-loader-ajax svg#successAnimation").addClass("active").addClass("animated"),setTimeout(function(){e(".folder-loader-ajax").removeClass("active"),e(".folder-loader-ajax img").addClass("active"),e(".folder-loader-ajax svg#successAnimation").removeClass("active").removeClass("animated")},2e3)}function W(){e(".sticky-folders > ul").html("");var t="";if(e("#js-tree-menu li.jstree-node.is-sticky").each(function(){var s=e(this).attr("id"),o=e.trim(e("#js-tree-menu").jstree(!0).get_node(s).text),a=e("li.jstree-node[id='"+s+"'] > a span.premio-folder-count").text(),n=e("li.jstree-node[id='"+s+"']").hasClass("is-high")?" is-high ":"";t+="<li data-folder-id='"+s+"' class='sticky-fldr "+n+" sticky-folder-"+s+"'><a href='javascript:;'><span class='folder-title'>"+o+"</span><span class='folder-actions'><span class='update-inline-record'><i class='pfolder-edit-folder'></i></span><span class='star-icon'><i class='pfolder-star'></i></span><span class='premio-folder-count'>"+a+"</span></span></a></li>"}),e(".sticky-folders > ul").html(t),e(".jstree-anchor.jstree-clicked").length){var s=e(".jstree-anchor.jstree-clicked").closest("li.jstree-node").attr("id");e(".sticky-folders .sticky-folder-"+s+" a").addClass("active-item")}e(".sticky-folders > ul > li").length>0?e(".sticky-folders").addClass("active"):e(".sticky-folders").removeClass("active"),O()}function B(){if(e("#media-attachment-taxonomy-filter").length&&(e("#media-attachment-taxonomy-filter").each(function(){wcp_settings.terms=y;var t=e(this);currentDDVal=e(this).val(),t.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>"),lastFolderData=y;for(var s=0;s<y.length;s++)t.append("<option value='"+y[s].term_id+"'>"+y[s].name+" ("+y[s].trash_count+")</option>");t.val(currentDDVal).trigger("change")}),e("select.folder_for_media").length)){var t=e("select.folder_for_media").val();e("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var s=0;s<y.length;s++)e("select.folder_for_media option:last-child").before("<option value='"+y[s].term_id+"'>"+y[s].name+"</option>");""!=t&&e(".folder_for_media").val(t)}for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),s=0;s<y.length;s++)0!=parseInt(y[s].trash_count)&&(e(".jstree-node[id='"+y[s].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(y[s].trash_count),e(".sticky-folder-"+y[s].term_id+" .premio-folder-count").text(y[s].trash_count));if(e(".media-select-folder").length){for(e(".media-select-folder").html("<option value=''>Select Folder</option><option value='-1'>(Unassigned)</option>"),s=0;s<y.length;s++)e(".media-select-folder").append("<option value='"+y[s].term_id+"'>"+y[s].name+" ("+y[s].trash_count+")</option>");e(".media-select-folder").val("")}""!=c&&e("#wcp_folder_"+c).addClass("active-item"),p&&(e("#title_"+f).trigger("click"),p=!1)}function q(){e("#bulk-action-selector-top, #bulk-action-selector-bottom").val("-1"),0==e(".wp-list-table tbody input[type='checkbox']:checked").length?alert("Please select items to move in folder"):(e("#bulk-move-folder").show(),e("#bulk-select").html("<option value=''>Loading...</option>"),e(".move-to-folder").attr("disabled",!0),e("#move-to-folder").prop("disabled",!0),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_get_default_list&active_id="+c,method:"post",success:function(t){if(t=e.parseJSON(t),e("#bulk-select").html("<option value=''>Select Folder</option><option value='-1'>(Unassigned)</option>"),e(".move-to-folder").prop("disabled",!1),e("#move-to-folder").prop("disabled",!1),1==t.status){var s=t.taxonomies;for(i=0;i<s.length;i++)e("#bulk-select").append("<option value='"+s[i].term_id+"'>"+s[i].name+"</option>")}}}))}function Q(t){""==c||0==c?(s=wcp_settings.nonce,e.ajax({url:wcp_settings.ajax_url,data:"post_id="+t+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+-1+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(e){H(),I()}})):e.ajax({url:wcp_settings.ajax_url,data:{post_id:t,action:"premio_check_for_other_folders",active_folder:c,type:wcp_settings.post_type,folder_id:-1,nonce:wcp_settings.nonce,status:wcp_settings.taxonomy_status,taxonomy:c},method:"post",success:function(t){-1==(t=e.parseJSON(t)).status?(e("#unassigned_folders").val(t.data.post_id),e("#confirm-your-change").show()):(H(),I())}})}if(e(document).ready(function(){if(e("body").hasClass("jetpack-connected")&&!e("body").hasClass("mobile")&&!e("body").hasClass("folded")&&e("#adminmenuwrap").length){var l=parseInt(e("#adminmenuwrap").width());"rtl"==e("html").prop("dir")?e(".wcp-content").css("right",l):e(".wcp-content").css("left",l)}e(document).on("click","#collapse-button",function(){setTimeout(function(){if(e("body").hasClass("jetpack-connected")&&!e("body").hasClass("mobile")&&!e("body").hasClass("folded")&&e("#adminmenuwrap").length){var t=parseInt(e("#adminmenuwrap").width());"rtl"==e("html").prop("dir")?e(".wcp-content").css("right",t):e(".wcp-content").css("left",t)}},50)}),y=wcp_settings.taxonomies,o=parseInt(wcp_settings.is_key_active),a=parseInt(wcp_settings.folders),c=parseInt(wcp_settings.selected_taxonomy),n=parseInt(wcp_settings.hasStars),r=parseInt(wcp_settings.hasChildren),C=parseInt(wcp_settings.currentPage),w=wcp_settings.folder_settings,e(document).on("click",".folder-settings-btn > a",function(t){t.stopPropagation(),e(".folder-settings-btn").toggleClass("active")}),e(document).on("click","body,html",function(){e(".folder-settings-btn").removeClass("active")}),e(document).on("click",".folder-setting-menu",function(e){e.stopPropagation()}),A(),O();var d="1"==wcp_settings.isRTL||1==wcp_settings.isRTL?"w":"e";e(".wcp-content").resizable({resizeHeight:!1,handles:d,minWidth:100,maxWidth:500,resize:function(t,s){var o=s.size.width;for(o<=275?e(".plugin-button").addClass("d-block"):e(".plugin-button").removeClass("d-block"),o<=225&&(o=225),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",o+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",o+20+"px"),newWidth=o-40,cssString="",classString="",i=0;i<=15;i++)classString+=" .space > .jstree-node >",currentWidth=newWidth-(13+20*i),cssString+="#js-tree-menu > "+classString+" .title { width: "+currentWidth+"px !important; } ",cssString+="#js-tree-menu > "+classString+" .dynamic-menu { left: "+(currentWidth-190)+"px !important; } ";e("#wcp-custom-style").html("<style>"+cssString+"</style>"),s.size.width<=185?(folderStatus="hide",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").addClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").removeClass("active"),e("#wcp-content").addClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right","20px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left","20px")):e("#wcp-content").hasClass("hide-folders-area")&&(folderStatus="show",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").removeClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").addClass("active"),e("#wcp-content").addClass("no-transition"),e("#wcp-content").removeClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(wcp_settings.folder_width)+20+"px"),setTimeout(function(){e("#wcp-content").removeClass("no-transition")},250))},stop:function(t,o){var a=o.size.width;o.size.width<=275?e(".plugin-button").addClass("d-block"):e(".plugin-button").removeClass("d-block"),a<=225&&(a=225),o.size.width<=185?(folderStatus="hide",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").addClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").removeClass("active"),e("#wcp-content").addClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right","20px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left","20px"),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_folder_display_status&status="+folderStatus+"&nonce="+s,method:"post",success:function(e){}})):e("#wcp-content").hasClass("hide-folders-area")&&(folderStatus="show",e(".wcp-hide-show-buttons .toggle-buttons.show-folders").removeClass("active"),e(".wcp-hide-show-buttons .toggle-buttons.hide-folders").addClass("active"),e("#wcp-content").addClass("no-transition"),e("#wcp-content").removeClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(wcp_settings.folder_width)+20+"px"),setTimeout(function(){e("#wcp-content").removeClass("no-transition")},250)),s=wcp_settings.nonce,wcp_settings.folder_width=o.size.width,e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_post_width&width="+a+"&nonce="+s,method:"post",success:function(e){}}),o.size.width<=225&&(e(".wcp-content").width(225),wcp_settings.folder_width=225)}}),e(document).on("contextmenu",".jstree-anchor",function(t){return j=t.pageX,x=t.pageY,e(this).find("span.folder-inline-edit").trigger("click"),!1}),e(document).on("click",".folder-actions span.folder-inline-edit",function(s){var o;(s.stopImmediatePropagation(),s.stopPropagation(),0!=wcp_settings.can_manage_folder)&&(isHigh=e(this).closest("li.jstree-node").hasClass("is-high"),isSticky=e(this).closest("li.jstree-node").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu' data-id='"+e(this).closest("li").prop("id")+"'><ul>",menuHtml+="<li class='new-main-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>",menuHtml+=r?"<li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>":"<li class='new-folder-pro'><a target='_blank' href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Sub-folder (Pro)</a></li>",menuHtml+="<li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span>Rename</a></li><li class='default-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-active-icon'></i></span>Open this folder by default (Pro)</a></li><li class='sticky-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li>",menuHtml+=n?"<li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star":"Add a Star")+"</a></li>":"<li class='mark-folder-pro'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star (Pro)":"Add a Star (Pro)")+"</a></li>",menuHtml+="<li class='lock-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='dashicons dashicons-lock'></span>Lock Folder (Pro)</a></li><li class='duplicate-folder-pro'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-clone'></i></span>Duplicate folder (Pro)</a></li>",hasPosts=parseInt(e(this).closest("a.jstree-anchor").find(".premio-folder-count").text()),"attachment"==wcp_settings.post_type&&hasPosts&&(menuHtml+="<li target='_blank' class='download-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span>Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span>Delete</a></li></ul></div>",e("body").append(menuHtml),s.pageX==t||s.pageY==t?(e(".dynamic-menu").css("left",j),e(".dynamic-menu").css("top",x-10),o=x):(e(".dynamic-menu").css("left",s.pageX),e(".dynamic-menu").css("top",s.pageY),o=s.pageY),e(this).parents("li.jstree-node").addClass("active-menu"),o+e(".dynamic-menu").height()>e(window).height()&&e(".dynamic-menu").css("margin-top",e(window).height()-(o+e(".dynamic-menu").height())))}),e(document).on("click",".sticky-folders .sticky-fldr > a",function(t){t.stopPropagation();var s=e(this).closest("li").data("folder-id");e(".jstree-node[id='"+s+"']").length&&(e(".jstree-clicked").removeClass("jstree-clicked"),e(".active-item").removeClass("active-item"),e("#js-tree-menu").jstree("select_node",c),e(".jstree-node[id='"+s+"'] > a.jstree-anchor").trigger("click"),e(".jstree-node[id='"+s+"'] > a.jstree-anchor").addClass("jstree-clicked"),e(".sticky-folders .sticky-folder-"+s+" a").addClass("active-item"))}),e(document).on("contextmenu",".sticky-folders li .sticky-fldr > a",function(t){return e(this).find("span.update-inline-record").trigger("click"),!1}),e(document).on("click",".tree-structure a",function(t){t.stopPropagation();var s=e(this).data("id");e(".jstree-node[id='"+s+"']").length&&(e(".jstree-clicked").removeClass("jstree-clicked"),e(".active-item").removeClass("active-item"),e("#js-tree-menu").jstree("select_node",c),e(".jstree-node[id='"+s+"'] > a.jstree-anchor").trigger("click"),e(".jstree-node[id='"+s+"'] > a.jstree-anchor").addClass("jstree-clicked"),e(".sticky-folders .sticky-folder-"+s+" a").addClass("active-item"))}),e(document).on("click",".update-inline-record",function(s){var o;(s.stopImmediatePropagation(),s.stopPropagation(),0!=wcp_settings.can_manage_folder)&&(isHigh=e(this).closest("li.sticky-fldr").hasClass("is-high"),isSticky=e(this).closest("li.sticky-fldr").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu' data-id='"+e(this).closest("li").data("folder-id")+"'><ul>",menuHtml+="<li class='new-main-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>",menuHtml+=r?"<li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>":"<li class='new-folder-pro'><a target='_blank' href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Sub-folder (Pro)</a></li>",menuHtml+="<li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span>Rename</a></li><li class='default-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-active-icon'></i></span>Open this folder by default (Pro)</a></li><li class='sticky-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li>",menuHtml+=n?"<li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star":"Add a Star")+"</a></li>":"<li class='mark-folder-pro'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star (Pro)":"Add a Star (Pro)")+"</a></li>",menuHtml+="<li class='lock-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class='dashicons dashicons-lock'></span>Lock Folder (Pro)</a></li><li class='duplicate-folder-pro'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-clone'></i></span>Duplicate folder (Pro)</a></li>",hasPosts=parseInt(e(this).closest("li.jstree-node").find("h3.title:first > .total-count").text()),"attachment"==wcp_settings.post_type&&hasPosts&&(menuHtml+="<li class='download-folder'><a target='_blank' href='"+wcp_settings.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span>Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span> Delete</a></li></ul></div>",e("body").append(menuHtml),s.pageX==t||s.pageY==t?(e(".dynamic-menu").css("left",j),e(".dynamic-menu").css("top",x-10),o=x):(e(".dynamic-menu").css("left",s.pageX),e(".dynamic-menu").css("top",s.pageY),o=s.pageY),o+e(".dynamic-menu").height()>e(window).height()&&e(".dynamic-menu").css("margin-top",e(window).height()-(o+e(".dynamic-menu").height())))}),e(document).on("click",".dynamic-menu",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click",".new-folder-pro",function(t){t.preventDefault(),e(".dynamic-menu").remove(),e("#sub-folder-popup").show()}),e(document).on("click",".close-popup-button a",function(){e(".folder-popup-form").hide()}),e(document).on("click","body, html",function(){e(".dynamic-menu").remove()}),e(".wcp-hide-show-buttons .toggle-buttons").on("click",function(){var t="show";e(this).hasClass("hide-folders")&&(t="hide"),e(".wcp-hide-show-buttons .toggle-buttons").toggleClass("active"),s=wcp_settings.nonce,"show"==t?(e("#wcp-content").addClass("no-transition"),e("#wcp-content").removeClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right",parseInt(wcp_settings.folder_width)+20+"px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left",parseInt(wcp_settings.folder_width)+20+"px"),setTimeout(function(){e("#wcp-content").removeClass("no-transition")},250)):(e("#wcp-content").addClass("hide-folders-area"),"1"==wcp_settings.isRTL?(e("#wpcontent").css("padding-right","20px"),e("#wpcontent").css("padding-left","0px")):e("#wpcontent").css("padding-left","20px")),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_folder_display_status&status="+t+"&nonce="+s,method:"post",success:function(e){}})}),D(),e(document).ajaxComplete(function(e,s,o){o.data!=t&&""!=o.data&&-1!=o.data.indexOf("action=query-attachments")&&D()}),e(document).on("click",".undo-button, .undo-folder-action:not(.disabled)",function(){e("#do-undo").removeClass("active"),"yes"==wcp_settings.useFolderUndo&&e.ajax({url:wcp_settings.ajax_url,type:"post",data:{post_type:wcp_settings.post_type,nonce:wcp_settings.nonce,action:"wcp_undo_folder_changes"},success:function(s){if(e("#undo-done").addClass("active"),setTimeout(function(){e("#undo-done").removeClass("active")},2500),e("#media-attachment-taxonomy-filter").length){var o=parent.wp;o.media!=t&&(o.media.frame.setState("insert"),null!==o.media.frame.content.get()&&void 0!==o.media.frame.content.get().collection?(o.media.frame.content.get().collection.props.set({ignore:+new Date}),o.media.frame.content.get().options.selection.reset()):o.media.frame.library.props.set({ignore:+new Date}))}H()}})}),e(document).on("click",".close-undo-box",function(t){t.preventDefault(),e("#do-undo").removeClass("active")})}),e(window).on("resize",function(){O()}),e(window).scroll(function(){}),e(document).ready(function(){e(document).on("click","#add-new-folder",function(){e("#js-tree-menu a.jstree-clicked").length?(f=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),r||e("#pro-notice").removeClass("hide-it")):(f=0,e("#pro-notice").addClass("hide-it")),p=!1,J()}),e(document).on("mouseover",".folders-action-menu",function(){e("body").addClass("add-folder-zindex")}).on("mouseleave",".folders-action-menu",function(){e("body").removeClass("add-folder-zindex")}),e(document).on("change","#media-attachment-taxonomy-filter",function(t){e("#js-tree-menu").hasClass("jstree")&&e("#js-tree-menu").jstree(!0).deselect_all(),e(".active-item").removeClass("active-item"),"all"==e(this).val()?e(".all-posts").addClass("active-item"):"unassigned"==e(this).val()?e(".un-categorised-items").addClass("active-item"):e("#js-tree-menu").jstree("select_node",e(this).val())}),e(document).on("click",".new-folder",function(){f=e(this).closest(".dynamic-menu").data("id"),p=!1,h=0,J()}),e(document).on("click",".new-main-folder",function(){h=1,f=e(this).closest(".dynamic-menu").data("id"),p=!1,J()}),e(document).on("click",".duplicate-folder",function(t){t.stopPropagation(),h=0,f=e(this).closest(".dynamic-menu").data("id"),e(".dynamic-menu").remove(),p=!1,u=!0,J(),z()}),e(document).on("submit","#save-folder-form",function(t){if(t.stopPropagation(),t.preventDefault(),folderNameDynamic=e.trim(e("#add-update-folder-name").val()),""==e.trim(folderNameDynamic))e(".folder-form-errors").addClass("active"),e("#add-update-folder-name").focus();else{e("#save-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#add-update-folder").addClass("disabled");var s=f;p&&(s=0),r||(s=0);var n="";0==s?(g=e("#js-tree-menu > ul > li.jstree-node").length,h&&(g=jQuery("#js-tree-menu > ul > li[id='"+f+"']").index(),jQuery("#js-tree-menu > ul > li").each(function(e){n+=jQuery(this).attr("id")+",",e==g&&(n+="#,")}),g+=1)):g=e("#js-tree-menu > ul > li.jstree-node[id='"+s+"'] > ul.jstree-children > li").length+1,e.ajax({url:wcp_settings.ajax_url,data:{parent_id:s,type:wcp_settings.post_type,action:"wcp_add_new_folder",nonce:wcp_settings.nonce,term_id:s,order:g,name:folderNameDynamic,is_duplicate:u,duplicate_from:m,parent_ids:n,parent_menu:h},method:"post",success:function(t){if(result=e.parseJSON(t),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),-1==result.status)e("#no-more-folder-credit").show();else if("1"==result.status){if(o=parseInt(result.is_key_active),a=parseInt(result.folders),e("#current-folder").text(a),e("#ttl-fldr").text(10),L(),z(),result.data.length)for(var s=0;s<result.data.length;s++){var n={folder_id:result.data[s].term_id,folder_count:0,is_sticky:result.data[s].is_sticky,is_high:result.data[s].is_high,nonce:result.data[s].nonce,slug:result.data[s].slug,is_deleted:0};w.push(n),h?e("#js-tree-menu").jstree().create_node("#",{id:result.data[s].term_id,text:" "+result.data[s].title},g,function(){e(".jstree-node[id='"+result.data[s].term_id+"']").attr("data-nonce",result.data[s].nonce),e(".jstree-node[id='"+result.data[s].term_id+"']").attr("data-slug",result.data[s].slug)}):e("#js-tree-menu").jstree().create_node(result.parent_id,{id:result.data[s].term_id,text:" "+result.data[s].title},"last",function(){e(".jstree-node[id='"+result.data[s].term_id+"']").attr("data-nonce",result.data[s].nonce),e(".jstree-node[id='"+result.data[s].term_id+"']").attr("data-slug",result.data[s].slug)}),h=0}Y(),W(),e("#media-attachment-taxonomy-filter").length&&(f=result.term_id,Z(0))}else e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show()}})}return!1})}),e(document).ready(function(){e("#inline-update").on("click",function(){e("#js-tree-menu a.jstree-clicked").length&&(f=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),F())}),e(document).on("click",".rename-folder",function(t){t.stopPropagation(),f=e(this).closest(".dynamic-menu").data("id"),F(),e(".dynamic-menu").remove()}),e(document).on("click",".form-cancel-btn",function(){e(".folder-popup-form").hide()}),e(document).on("click",".folder-popup-form",function(t){e(".folder-popup-form").hide()}),e(document).on("click",".popup-form-content",function(e){e.stopPropagation()}),e(document).on("submit","#update-folder-form",function(o){return o.stopPropagation(),o.preventDefault(),folderNameDynamic=e("#update-folder-item-name").val(),""==e.trim(folderNameDynamic)?(e(".folder-form-errors").addClass("active"),e("#update-folder-item-name").focus()):(e("#update-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#update-folder-item").addClass("disabled"),s=P(f,"nonce"),parentID=e(".jstree-node[id='"+f+"']").closest("li.jstree-node").attr("id"),parentID==t&&(parentID=0),e.ajax({url:wcp_settings.ajax_url,data:{parent_id:parentID,type:wcp_settings.post_type,action:"wcp_update_folder",nonce:s,term_id:f,order:g,name:folderNameDynamic},method:"post",success:function(t){result=e.parseJSON(t),"1"==result.status?(e("#js-tree-menu").jstree("rename_node",result.id," "+result.term_title),folderPostId=T(result.id),null!=folderPostId&&(w[folderPostId].nonce=result.nonce,w[folderPostId].slug=result.slug),z(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),Y(),e("#media-attachment-taxonomy-filter").length&&Z(0)):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show())}})),!1})}),e(document).ready(function(){e(document).on("click","#inline-remove, .delete-folder-action:not(.disabled)",function(){e("#js-tree-menu a.jstree-clicked").length?(f=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),R(1),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")):e("#menu-checkbox").is(":checked")&&(e(".dynamic-menu").remove(),R(1))}),e(document).on("click","#menu-checkbox",function(){e(this).is(":checked")?(e("#js-tree-menu").addClass("show-folder-checkbox"),e("#menu-checkbox").prop("checked",!0)):(e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox"),e("#menu-checkbox").prop("checked",!1))}),e(document).on("click","#menu-checkbox",function(){e(this).is(":checked")?(e("#menu-checkbox").prop("checked",!0),e("#js-tree-menu").addClass("show-folder-checkbox")):(e("#menu-checkbox").prop("checked",!1),e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox"))}),e(document).on("click",".folder-checkbox, .input-checkbox",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click",".remove-folder",function(){folderID=e(this).closest("li.jstree-node").data("id"),f=e(this).closest(".dynamic-menu").data("id"),R(0),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")}),e(document).on("click","#remove-folder-item",function(t){t.stopPropagation(),e(".folder-popup-form").addClass("disabled"),e("#remove-folder-item").html('<span class="dashicons dashicons-update"></span>'),s=P(f,"nonce"),_?function(){if(e("#menu-checkbox").is(":checked")&&e("#js-tree-menu input.checkbox:checked").length>0){var t="";e("#js-tree-menu input.checkbox:checked").each(function(){t+=e(this).closest("li.jstree-node").attr("id")+",",e(this).closest("li.jstree-node").hasClass("jstree-clicked")&&!0}),e(".form-loader-count").css("width","100%"),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_remove_muliple_folder&term_id="+t+"&nonce="+wcp_settings.nonce,method:"post",success:function(t){if(t=e.parseJSON(t),e(".form-loader-count").css("width","0px"),"1"==t.status){for(o=parseInt(t.is_key_active),a=parseInt(t.folders),e("#current-folder").text(a),i=0;i<t.term_ids.length;i++)e("#js-tree-menu").jstree().delete_node(t.term_ids[i]);e("#ttl-fldr").text(10),Y(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),H(),W(),Y(),e("#js-tree-menu li.jstree-node").removeClass("has-sub-tree"),e("#js-tree-menu li.jstree-node").each(function(){e(this).find("ul.ui-sortable li").length?e(this).addClass("has-sub-tree"):e(this).removeClass("active")}),e("#wcp_folder_"+c).length||(e(".header-posts a").trigger("click"),c=0)}else window.location.reload();e("#menu-checkbox").attr("checked",!1),e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox")}})}}():e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_remove_folder&term_id="+f+"&nonce="+s,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#js-tree-menu").jstree().delete_node(f),o=parseInt(t.is_key_active),a=parseInt(t.folders),e("#current-folder").text(a),e("#ttl-fldr").text(10),e(".sticky-folders .sticky-folder-"+f).remove(),z(),Y(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),H(),W(),c==f&&e(".header-posts").trigger("click")):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})})}),e(document).ready(function(){e(document).on("click",".mark-folder",function(t){t.stopPropagation(),folderID=e(this).closest(".dynamic-menu").data("id"),s=P(folderID,"nonce"),e(".form-loader-count").css("width","100%"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),e.ajax({url:wcp_settings.ajax_url,data:"term_id="+folderID+"&type="+wcp_settings.post_type+"&action=wcp_mark_un_mark_folder&nonce="+s,method:"post",cache:!1,success:function(t){t=e.parseJSON(t),e(".form-loader-count").css("width","0%"),"1"==t.status?(folderPostId=T(t.id),"1"==t.marked?(e("li.jstree-node[id='"+t.id+"']").addClass("is-high"),e(".sticky-folder-"+t.id).addClass("is-high"),null!=folderPostId&&(w[folderPostId].is_high=1)):(e("li.jstree-node[id='"+t.id+"']").removeClass("is-high"),e(".sticky-folder-"+t.id).removeClass("is-high"),null!=folderPostId&&(w[folderPostId].is_high=0)),z(),Y()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})})}),e(document).ready(function(){e(document).on("click",".jstree-node .jstree-icon",function(){folderID=e(this).closest("li.jstree-node").attr("id"),e("li.jstree-node[id='"+folderID+"']").hasClass("jstree-open")?folderStatus=1:folderStatus=0,e(".form-loader-count").css("width","100%"),s=P(folderID,"nonce"),L(),e.ajax({url:wcp_settings.ajax_url,data:"is_active="+folderStatus+"&action=save_wcp_folder_state&term_id="+folderID+"&nonce="+s,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=e.parseJSON(t)).status||(e("#wcp_folder_"+folderID).hasClass("active")?(e("#wcp_folder_"+folderID).removeClass("active"),e("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideUp(),folderStatus=0):(e("#wcp_folder_"+folderID).addClass("active"),e("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideDown(),folderStatus=1),Y())}})})}),e(document).ready(function(){e(document).on("click","a.jstree-anchor",function(t){if(C=1,t.stopPropagation(),e(".un-categorised-items").removeClass("active-item"),e(".header-posts a").removeClass("active-item"),e("active-item").removeClass("active-item"),c=e(this).closest("li.jstree-node").attr("id"),f=e(this).closest("li.jstree-node").attr("id"),e(".sticky-folders .sticky-folder-"+c+" a").addClass("active-item"),e("#media-attachment-taxonomy-filter").length){var s=e(this).closest("li.jstree-node").attr("id");e("#media-attachment-taxonomy-filter").val(s),e("#media-attachment-taxonomy-filter").trigger("change"),thisSlug=P(s,"slug"),b=wcp_settings.page_url+thisSlug+"&paged="+C;var o={Title:thisSlug,Url:b};history.pushState(o,o.Title,o.Url),M(thisSlug),e(".custom-media-select").removeClass("active")}else{var a=P(c,"slug");b=wcp_settings.page_url+a+"&paged="+C,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(b+" #posts-filter",function(){var t={Title:a,Url:b};history.pushState(t,t.Title,t.Url),M(a),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),N()}):e("#wpbody").load(b+" #wpbody-content",function(){var t={Title:a,Url:b};history.pushState(t,t.Title,t.Url),M(a),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),N()})}U(),e(".sticky-folders .sticky-folder-"+c+" a").addClass("active-item")}),e(document).on("click","#js-tree-menu input.checkbox",function(){S()}),e(".header-posts").on("click",function(){if(c="",e(".wcp-container .route").removeClass("active-item"),e(".un-categorised-items").removeClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(".header-posts a").addClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e("#media-attachment-taxonomy-filter").length){c="",e("#media-attachment-taxonomy-filter").val("all"),e("#media-attachment-taxonomy-filter").trigger("change");var t={Title:"",Url:wcp_settings.page_url};history.pushState(t,t.Title,t.Url),M("all"),U()}else C=1,b=wcp_settings.page_url+"&paged="+C,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(b+" #posts-filter",function(){var t={Title:"",Url:b};history.pushState(t,t.Title,t.Url),M("all"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U(),N()}):e("#wpbody").load(b+" #wpbody-content",function(){var t={Title:"",Url:b};history.pushState(t,t.Title,t.Url),M("all"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U(),N()});S()}),e(".un-categorised-items").on("click",function(){if(c="-1",e(".wcp-container .route").removeClass("active-item"),e(".header-posts a").removeClass("active-item"),e(".un-categorised-items").addClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e("#media-attachment-taxonomy-filter").length){e("#media-attachment-taxonomy-filter").val("unassigned"),e("#media-attachment-taxonomy-filter").trigger("change");var t={Title:"",Url:wcp_settings.page_url+"-1"};history.pushState(t,t.Title,t.Url),M("-1"),U()}else C=1,b=wcp_settings.page_url+"-1&paged="+C,e(".form-loader-count").css("width","100%"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(b+" #posts-filter",function(){var t={Title:"",Url:b};history.pushState(t,t.Title,t.Url),M("-1"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U(),N()}):e("#wpbody").load(b+" #wpbody-content",function(){var t={Title:"",Url:b};history.pushState(t,t.Title,t.Url),M("-1"),"show"!=wcp_settings.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),U(),N()});S()}),e("#expand-collapse-list").on("click",function(t){t.stopPropagation(),statusType=0,e(this).hasClass("all-open")?(e(this).removeClass("all-open"),statusType=0,e(this).attr("data-folder-tooltip","Expand"),e("#js-tree-menu").jstree("close_all"),e("#expand-collapse-list .text").text("Expand")):(e(this).addClass("all-open"),statusType=1,e(this).attr("data-folder-tooltip","Collapse"),e("#js-tree-menu").jstree("open_all"),e("#expand-collapse-list .text").text("Collapse")),v="",e("#js-tree-menu .jstree-node:not(.jstree-leaf)").each(function(){v+=e(this).attr("id")+","}),""!=v&&(e(".form-loader-count").css("width","100%"),s=wcp_settings.nonce,e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_change_all_status&status="+statusType+"&folders="+v+"&nonce="+s,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=e.parseJSON(t)).status&&(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))}),L()}),e(document).ready(function(){e(document).on("click","body, html",function(){e(".folder-order").removeClass("active")}),e(document).on("click","#sort-order-list",function(t){t.stopPropagation(),e(".folder-order").toggleClass("active")}),e(document).on("click",".folder-sort-menu a:not(.pro-feature)",function(t){t.stopPropagation(),t.preventDefault(),e(".form-loader-count").css("width","100%"),e(".folder-order").removeClass("active"),lastOrderStatus=e(this).attr("data-sort"),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_folders_by_order&nonce="+wcp_settings.nonce+"&order="+e(this).attr("data-sort"),method:"post",success:function(t){1==(t=e.parseJSON(t)).status&&(e("#js-tree-menu").jstree().destroy(),e("#js-tree-menu").append("<ul></ul>"),e("#js-tree-menu ul").html(t.data),A(),y=t.terms,B()),e(".form-loader-count").css("width","0"),U()}})})}),e(document).ready(function(){e(document).on("keyup","#folder-search",function(){E()}),e(document).on("change","#folder-search",function(){E()}),e(document).on("blur","#folder-search",function(){E()}),e(document).on("click","#do_not_show_again",function(){var t=e(this).is(":checked")?1:0;e.ajax({url:wcp_settings.ajax_url,type:"post",data:{action:"premio_hide_child_popup",status:t,nonce:wcp_settings.nonce,post_type:wcp_settings.post_type}})})}),e(document).ready(function(){e(document).on("click",".folders-toggle-button",function(){dbStatus="show",e(".tree-structure-content").hasClass("active")?(e(".tree-structure-content .tree-structure").animate({height:"40px"},100,function(){e(".tree-structure-content").removeClass("active")}),dbStatus="hide"):(newHeight=parseInt(e(".tree-structure-content .tree-structure").attr("data-height")),e(".tree-structure-content .tree-structure").animate({height:newHeight},100,function(){e(".tree-structure-content").addClass("active")})),e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_hide_folders&status="+dbStatus+"&nonce="+wcp_settings.nonce,method:"post",success:function(e){}})})}),e(document).ready(function(){e(document).on("click","#remove-from-all-folders:not(.disabled), #remove-from-current-folder:not(.disabled)",function(){e("#remove-from-all-folders, #remove-from-current-folder").addClass("disabled");var t="all";e(this).hasClass("remove-from-current-folder")&&(t="current"),e("#confirm-your-change").hide(),e.ajax({url:wcp_settings.ajax_url,data:{post_id:e("#unassigned_folders").val(),action:"wcp_remove_post_folder",active_folder:c,type:wcp_settings.post_type,folder_id:-1,nonce:wcp_settings.nonce,status:wcp_settings.taxonomy_status,taxonomy:c,remove_from:t},method:"post",success:function(t){e("#remove-from-all-folders, #remove-from-current-folder").removeClass("disabled"),Y(),H(),I()}})}),e(document).on("click",".thumbnail-hover-box a",function(t){return t.stopPropagation(),t.stopImmediatePropagation(),t.preventDefault(),window.open(e(this).prop("href"),"_blank"),wp.media.frame.close(),!1}),e(document).on("click","#doaction",function(t){return"move_to_folder"==e("#bulk-action-selector-top").val()?(q(),!1):"edit"==e("#bulk-action-selector-top").val()&&"object"==typeof inlineEditPost?(inlineEditPost.setBulk(),!1):void 0}),e(document).on("click","#doaction2",function(t){return"move_to_folder"==e("#bulk-action-selector-bottom").val()?(q(),!1):"edit"==e("#bulk-action-selector-bottom").val()&&"object"==typeof inlineEditPost?(inlineEditPost.setBulk(),!1):void 0}),e(document).on("submit","#bulk-folder-form",function(t){t.stopPropagation(),t.preventDefault(),""!=e("#bulk-select").val()&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),""!=e("#bulk-select").val()&&("-1"==e("#bulk-select").val()?e.ajax({url:wcp_settings.ajax_url,data:"post_id="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+e(this).val()+"&nonce="+wcp_settings.nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){e("#bulk-move-folder").hide(),H(),Y()}}):(s=P(e("#bulk-select").val(),"nonce"),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+chkStr+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+e("#bulk-select").val()+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){t=e.parseJSON(t),e("#bulk-move-folder").hide(),"1"==t.status?(H(),Y()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}}))))})}),"attachment"==wcp_settings.post_type){e(document).ready(function(){"show"==wcp_settings.show_in_page&&e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div><div class="folders-toggle-button"><span></span></div></div>'),z(),V()});var X=null;function Z(s){X=e.ajax({url:wcp_settings.ajax_url,data:"type="+wcp_settings.post_type+"&action=wcp_get_default_list&active_id="+c,method:"post",beforeSend:function(){null!=X&&X.abort()},success:function(o){if(o=e.parseJSON(o),e(".header-posts .total-count").text(o.total_items),e(".un-categorised-items .total-count").text(o.empty_items),selectedVal=e("#media-attachment-taxonomy-filter").val(),"all"!=selectedVal&&1==s){var a=parent.wp;a.media!=t&&(a.media.frame.setState("insert"),null!==a.media.frame.content.get()&&void 0!==a.media.frame.content.get().collection?(a.media.frame.content.get().collection.props.set({ignore:+new Date}),a.media.frame.content.get().options.selection.reset()):a.media.frame.library.props.set({ignore:+new Date}))}y=o.taxonomies,B(),""!=c&&e("#wcp_folder_"+c).addClass("active-item"),p&&(e("#title_"+f).trigger("click"),p=!1)}})}function G(){e(".media-frame-content .media-toolbar").width(e(".media-frame-content").width()-20)}function K(e,t,s){var o="";if(s){var a=new Date;a.setTime(a.getTime()+24*s*60*60*1e3),o="; expires="+a.toUTCString()}document.cookie=e+"="+(t||"")+o+"; path=/"}function $(e){document.cookie=e+"=; Max-Age=-99999999;"}G(),e(window).resize(function(){G()}),e(document).on("click",".button.organize-button",function(){e(".media-frame").hasClass("mode-select")?$("media-select-mode"):K("media-select-mode","on",7),e("button.button.media-button.select-mode-toggle-button").trigger("click"),e(".media-frame").hasClass("mode-select")?(e(".media-info-message").addClass("active"),e(".select-all-item-btn").addClass("active")):(e(".media-info-message, .custom-media-select").removeClass("active"),e(".select-all-item-btn").removeClass("active"))}),e(document).on("click",".select-mode-toggle-button",function(){setTimeout(function(){e(".media-frame").hasClass("mode-select")||K("media-select-mode","off",-1),e(".media-frame").hasClass("mode-select")?(e(".media-info-message").addClass("active"),e(".select-all-item-btn").addClass("active")):(e(".media-info-message, .custom-media-select").removeClass("active"),e(".select-all-item-btn").removeClass("active"))},10)}),e(document).on("click",".select-all-item-btn",function(){e("ul.attachments li:not(.selected)").trigger("click")}),e(document).on("change",".folder_for_media",function(){"add-folder"==e(this).val()&&(f=0,p=!0,J())}),e(window).scroll(function(){})}else;function ee(){e("button.button.media-button.select-mode-toggle-button").length&&(clearInterval(l),e("button.button.media-button.select-mode-toggle-button").after("<button class='button organize-button'>Bulk Organize</button>"),e(".media-toolbar-secondary").append("<span class='media-info-message'>Drag and drop your media files to the relevant folders</span>"),e(".delete-selected-button").before("<button type='button' class='button button-primary select-all-item-btn'>Select All</button>"),e(".media-toolbar-secondary").after("<div class='custom-media-select'>Move Selected files to: <select class='media-select-folder'></select></div>"),e(".media-toolbar").append("<div style='clear:both;'></div><div class='media-folder-loader'><span>Uploading files</span> <span id='current_upload_files'></span>/<span id='total_upload_files'></span><div class='folder-progress'><div class='folder-meter orange-bg'><span></span></div></div></div>"),e(".wcp-custom-form").length&&(wp.Uploader!==t&&wp.Uploader.queue.on("reset",function(){Z(1)}),e(document).ajaxComplete(function(e,t,s){actionName=s.data,"undefined"!=typeof actionName&&actionName.length&&0==actionName.indexOf("action=delete-post&id=")&&Z(0)})),setTimeout(function(){docReferrar=document.referrer,-1!=docReferrar.indexOf("wp-admin/upload.php")?(mediaMode=function(e){for(var t=e+"=",s=document.cookie.split(";"),o=0;o<s.length;o++){for(var a=s[o];" "==a.charAt(0);)a=a.substring(1,a.length);if(0==a.indexOf(t))return a.substring(t.length,a.length)}return null}("media-select-mode"),"on"==mediaMode&&(e("button.button.media-button.select-mode-toggle-button").trigger("click"),e(".media-frame").hasClass("mode-select")?e(".media-info-message").addClass("active"):e(".media-info-message, .custom-media-select").removeClass("active"))):$("media-select-mode"),Z(1)},1e3))}e(document).ready(function(){"attachment"==wcp_settings.post_type&&e("#tmpl-media-frame").length&&(l=setInterval(function(){ee()},1e3)),e(document).on("click",".attachments-browser ul.attachments .thumbnail",function(){"attachment"==wcp_settings.post_type&&e(".media-toolbar").hasClass("media-toolbar-mode-select")&&(0==e("ul.attachments li.selected").length?e(".custom-media-select").removeClass("active"):e(".custom-media-select").addClass("active"))}),e(document).on("change",".media-select-folder",function(){if("attachment"==wcp_settings.post_type&&""!=e(this).val()){var t="";e(".attachments-browser li.attachment.selected").each(function(){t+=e(this).attr("data-id")+","}),"-1"==e(this).val()?e.ajax({url:wcp_settings.ajax_url,data:"post_id="+t+"&type="+wcp_settings.post_type+"&action=wcp_remove_post_folder&folder_id="+e(this).val()+"&nonce="+wcp_settings.nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){0!=f&&f!=e(".media-select-folder").val()&&e("ul.attachments li.selected").remove(),H(),Y()}}):(s=P(e(this).val(),"nonce"),e.ajax({url:wcp_settings.ajax_url,data:"post_ids="+t+"&type="+wcp_settings.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+e(this).val()+"&nonce="+s+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+c,method:"post",success:function(t){t=e.parseJSON(t),e("#bulk-move-folder").hide(),"1"==t.status?(0!=f&&f!=e(".media-select-folder").val()&&e("ul.attachments li.selected").remove(),H(),Y()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}}))}})})});
|
assets/js/page-post-media.js
CHANGED
@@ -61,7 +61,7 @@
|
|
61 |
var totalItems = folders_media_options.terms.length;
|
62 |
_.each(folders_media_options.terms || {}, function(term, index) {
|
63 |
filters[term.term_id] = {
|
64 |
-
text: term.name + ' (' + term.
|
65 |
props: {
|
66 |
'media_folder': term.slug
|
67 |
}
|
@@ -250,7 +250,7 @@
|
|
250 |
}, 1250);
|
251 |
|
252 |
resetDDCounter();
|
253 |
-
if(typeof wp_media.media.frame !== "undefined" && wp_media.media.frame.content.get() !== null) {
|
254 |
folderSelectedAttachmentID = [];
|
255 |
if($(".folder-modal ul.attachments li.selected").length) {
|
256 |
$(".folder-modal ul.attachments li.selected").each(function(){
|
@@ -415,7 +415,6 @@
|
|
415 |
setDragAndDropElements();
|
416 |
}
|
417 |
if(folderSelectedAttachmentID.length > 0) {
|
418 |
-
console.log(folderSelectedAttachmentID);
|
419 |
for(var i=0; i<folderSelectedAttachmentID.length; i++) {
|
420 |
if (jQuery(".folder-modal ul.attachments li[data-id='" + folderSelectedAttachmentID[i] + "']").length && !jQuery(".folder-modal ul.attachments li[data-id='" + folderSelectedAttachmentID[i] + "']").hasClass("selected")) {
|
421 |
var e = jQuery.Event("click");
|
@@ -1042,7 +1041,9 @@
|
|
1042 |
});
|
1043 |
|
1044 |
$(document).on("change", "#media-attachment-taxonomy-filter", function(e){
|
1045 |
-
$("#js-tree-menu").jstree
|
|
|
|
|
1046 |
$(".active-item").removeClass("active-item");
|
1047 |
if($(this).val() == "all") {
|
1048 |
$(".all-posts").addClass("active-item");
|
@@ -1191,7 +1192,7 @@
|
|
1191 |
var wp1 = parent.wp;
|
1192 |
if(wp1.media != undefined) {
|
1193 |
wp1.media.frame.setState('insert');
|
1194 |
-
if (wp1.media.frame.content.get() !== null) {
|
1195 |
wp1.media.frame.content.get().collection.props.set({ignore: (+new Date())});
|
1196 |
wp1.media.frame.content.get().options.selection.reset();
|
1197 |
} else {
|
@@ -2086,7 +2087,7 @@
|
|
2086 |
var wp1 = parent.wp;
|
2087 |
if(wp1.media != undefined) {
|
2088 |
wp1.media.frame.setState('insert');
|
2089 |
-
if (wp1.media.frame.content.get() !== null) {
|
2090 |
wp1.media.frame.content.get().collection.props.set({ignore: (+new Date())});
|
2091 |
wp1.media.frame.content.get().options.selection.reset();
|
2092 |
} else {
|
61 |
var totalItems = folders_media_options.terms.length;
|
62 |
_.each(folders_media_options.terms || {}, function(term, index) {
|
63 |
filters[term.term_id] = {
|
64 |
+
text: term.name + ' (' + term.trash_count + ')',
|
65 |
props: {
|
66 |
'media_folder': term.slug
|
67 |
}
|
250 |
}, 1250);
|
251 |
|
252 |
resetDDCounter();
|
253 |
+
if(typeof wp_media.media.frame !== "undefined" && wp_media.media.frame.content.get() !== null && typeof(wp_media.media.frame.content.get().collection) != "undefined") {
|
254 |
folderSelectedAttachmentID = [];
|
255 |
if($(".folder-modal ul.attachments li.selected").length) {
|
256 |
$(".folder-modal ul.attachments li.selected").each(function(){
|
415 |
setDragAndDropElements();
|
416 |
}
|
417 |
if(folderSelectedAttachmentID.length > 0) {
|
|
|
418 |
for(var i=0; i<folderSelectedAttachmentID.length; i++) {
|
419 |
if (jQuery(".folder-modal ul.attachments li[data-id='" + folderSelectedAttachmentID[i] + "']").length && !jQuery(".folder-modal ul.attachments li[data-id='" + folderSelectedAttachmentID[i] + "']").hasClass("selected")) {
|
420 |
var e = jQuery.Event("click");
|
1041 |
});
|
1042 |
|
1043 |
$(document).on("change", "#media-attachment-taxonomy-filter", function(e){
|
1044 |
+
if($("#js-tree-menu").hasClass("jstree")) {
|
1045 |
+
$("#js-tree-menu").jstree(true).deselect_all();
|
1046 |
+
}
|
1047 |
$(".active-item").removeClass("active-item");
|
1048 |
if($(this).val() == "all") {
|
1049 |
$(".all-posts").addClass("active-item");
|
1192 |
var wp1 = parent.wp;
|
1193 |
if(wp1.media != undefined) {
|
1194 |
wp1.media.frame.setState('insert');
|
1195 |
+
if (wp1.media.frame.content.get() !== null && typeof(wp1.media.frame.content.get().collection) != "undefined") {
|
1196 |
wp1.media.frame.content.get().collection.props.set({ignore: (+new Date())});
|
1197 |
wp1.media.frame.content.get().options.selection.reset();
|
1198 |
} else {
|
2087 |
var wp1 = parent.wp;
|
2088 |
if(wp1.media != undefined) {
|
2089 |
wp1.media.frame.setState('insert');
|
2090 |
+
if (wp1.media.frame.content.get() !== null && typeof(wp1.media.frame.content.get().collection) != "undefined") {
|
2091 |
wp1.media.frame.content.get().collection.props.set({ignore: (+new Date())});
|
2092 |
wp1.media.frame.content.get().options.selection.reset();
|
2093 |
} else {
|
assets/js/page-post-media.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e,t){var o,a,s=[],r=".folder-modal #js-tree-menu",d=[],l=-1,n=0,c=0,m="",p=-1,u=0,f="",h=folders_media_options.page_url,v="",g="",y=!1,j=!1,k=!1,b=!1,w=0,x=0,C=[],S=null,I=null,P=wp.media.view.AttachmentFilters.extend({id:"media-attachment-taxonomy-filter",createFilters:function(){var e={};folders_media_options.terms.length;_.each(folders_media_options.terms||{},function(t,o){e[t.term_id]={text:t.name+" ("+t.count+")",props:{media_folder:t.slug}}}),e.all={text:"All Folders",props:{media_folder:""},priority:10},e.unassigned={text:"(Unassigned)",props:{media_folder:"-1"},priority:10},this.filters=e},change:function(){var e={};_.each(folders_media_options.terms||{},function(t,o){e[t.term_id]={text:t.name+" ("+t.count+")",props:{media_folder:t.slug}}}),e.all={text:"Select a folder >>",props:{media_folder:""},priority:10},e.unassigned={text:"(Unassigned)",props:{media_folder:"-1"},priority:10},this.filters=e;var t=this.filters[this.el.value];t&&this.model.set(t.props)}}),D=0,H=0,N=wp.media.view.AttachmentsBrowser;wp.media.view.AttachmentsBrowser=wp.media.view.AttachmentsBrowser.extend({createToolbar:function(){N.prototype.createToolbar.call(this),this.toolbar.set("MediaLibraryOrganizerTaxonomyFilter",new P({controller:this.controller,model:this.collection.props,priority:-75}).render())}});var A,O=wp.media.model.Query;_.extend(O,{get:(A=[],function(e,t){var o,a={},s=O.orderby,r=O.defaultProps;return delete e.query,delete e.cache,_.defaults(e,r),_.each(["include","exclude"],function(t){e[t]&&!_.isArray(e[t])&&(e[t]=[e[t]])}),_.each(e,function(e,t){_.isNull(e)||(a[O.propmap[t]||t]=e)}),_.defaults(a,O.defaultArgs),a.orderby=s.valuemap[e.orderby]||e.orderby,A=[],o||(o=new O([],_.extend(t||{},{props:e,args:a})),A.push(o)),o})});var Q=window.wp;void 0!==Q&&"function"==typeof Q.Uploader&&(Q.media.view.Modal.prototype.on("open",function(){s=[],setTimeout(function(){e("#media-attachment-taxonomy-filter").length&&("all"==e("#media-attachment-taxonomy-filter").val()&&(e("#media-attachment-taxonomy-filter option:gt(1)").remove(),_.each(folders_media_options.terms,function(t,o){e("#media-attachment-taxonomy-filter").append("<option value='"+t.term_id+"'>"+t.name+" ("+t.trash_count+")</option>")})),e("#wcp-content").length||e(".editor-post-featured-image").length&&e(".attachment-filters").val("all").trigger("change"))},100)}),Q.media.view.Modal.prototype.on("close",function(){s=[]}),e.extend(Q.Uploader.prototype,{progress:function(){},init:function(){this.uploader&&(this.uploader.bind("FileFiltered",function(t,o){D++,e(".folder-meter").css("width","0%"),e(".media-folder-loader").show(),e("#total_upload_files").text(D)}),this.uploader.bind("BeforeUpload",function(t,o){var a=l,s=t.settings.multipart_params;if((a=parseInt(a))>0&&(s.folder_for_media=a),H<D){e(".media-folder-loader").show();var r=H/D*100;e(".folder-meter").css("width",r+"%")}H++,e("#current_upload_files").text(H)}),this.uploader.bind("UploadComplete",function(e,t){l=-1}),this.uploader.bind("UploadComplete",function(t,o){var a=window.wp;e(".folder-meter").css("width","100%"),setTimeout(function(){e(".media-folder-loader").hide(),e(".folder-meter").css("width","0%"),D=0,H=0},1250),function(){e("#media-attachment-taxonomy-filter").val();F=e.ajax({url:folders_media_options.ajax_url,data:"type=attachment&action=wcp_get_default_list&active_id=0",method:"post",beforeSend:function(){null!=F&&F.abort()},success:function(t){var t=e.parseJSON(t);C=t.taxonomies,Z(),z()}})}(),void 0!==a.media.frame&&null!==a.media.frame.content.get()&&(s=[],e(".folder-modal ul.attachments li.selected").length&&e(".folder-modal ul.attachments li.selected").each(function(){s.push(e(this).data("id"))}),a.media.frame.content.get().collection.props.set({ignore:+new Date}),a.media.frame.content.get().options.selection.reset())}))}}));var F,T=window.wp;if(void 0!==T&&"function"==typeof T.Uploader){var U=window.wp.media,J=U.view.Modal;U.view.Modal=U.view.Modal.extend({className:"folder-modal",initialize:function(){J.prototype.initialize.apply(this,arguments)},open:function(){J.prototype.open.apply(this,arguments)&&(e(".folder-modal").length||e(".supports-drag-drop").length&&e(".supports-drag-drop").each(function(){"block"!=e(this).css("display")&&"inline-block"!=e(this).css("display")||e(this).addClass("folder-modal")}),e(".folder-modal").length?(e(".folder-custom-menu").remove(),e(".folder-modal .media-frame-tab-panel").removeClass("has-folder-menu"),e(".folder-modal .media-frame").hasClass("hide-menu")?e(".folder-custom-menu").length||(e(".folder-modal .media-frame-tab-panel").before("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>"),e(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url+" #wcp-content-resize",function(){ee(),X(),Y()})):e(".folder-custom-menu").length||(e(".folder-modal .media-frame-menu").addClass("has-folder-menu"),e(".folder-modal .media-frame-menu .media-menu").append("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>"),e(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url+" #wcp-content-resize",function(){ee(),X(),Y()})),e(".folder-form-data").remove(),e(".media-frame-tab-panel:first").before("<div class='folder-form-data'></div>"),e(".folder-form-data").load(folders_media_options.media_page_url+" #folder-add-update-content",function(){})):setTimeout(function(){-1!=l&&e("#media-attachment-taxonomy-filter").each(function(){e(this).val(l),e(this).trigger("change")})},1e3))},close:function(){J.prototype.close.apply(this,arguments),e(".folder-modal").removeClass("folder-modal")}})}function M(){"yes"==folders_media_options.useFolderUndo&&(e("#do-undo").addClass("active"),e(".undo-folder-action").removeClass("disabled"),setTimeout(function(){e("#do-undo").removeClass("active"),e(".undo-folder-action").addClass("disabled")},parseInt(folders_media_options.defaultTimeout)))}function V(){e(".cut-folder-action, .copy-folder-action, .paste-folder-action, .delete-folder-action").addClass("disabled"),e("#js-tree-menu .jstree-anchor.jstree-clicked").length&&e(".delete-folder-action").removeClass("disabled"),(e("#menu-checkbox").is(":checked")||e("#menu-checkbox").is(":checked"))&&e("#js-tree-menu input.checkbox:checked").length>0&&e(".delete-folder-action").removeClass("disabled")}function z(){e(".jstree-anchor:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){n=e(this).closest("li.jstree-node").attr("id"),o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),f=E(n,"nonce"),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(M(),L()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,f=E(n,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(M(),L()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,f=E(n,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),g=chkStr,e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(e){M(),L(),oe()}}))}}),e(".media-frame:not(.hide-router) .attachments-browser li.attachment:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:function(t,o){e(".selected-items").remove();var a=e(".media-frame:not(.hide-router) .attachments-browser li.attachment.selected").length;return e("<div class='selected-items'><span class='total-post-count'>"+(a=0==a||1==a?"1 Item":a+" Items")+" Selected</span></div>")},start:function(t,o){e("body").addClass("no-hover-css")},cursor:"move",appendTo:".media-modal",cursorAt:{left:0,top:0},stop:function(t,o){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}}),e(".un-categorised-items").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){n=-1,f=folders_media_options.nonce,o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),B(chkStr)):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,chkStr=postID+",",e(".wp-list-table input:checked").each(function(){postID!=e(this).val()&&(chkStr+=e(this).val()+",")}),B(chkStr)):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),g=chkStr,B(chkStr))}}),e(".tree-structure .folder-item:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){e("body").removeClass("no-hover-css"),n=e(this).data("id"),o.draggable.hasClass("wcp-move-multiple")?(f=E(n,"nonce"),e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(e){M(),L(),oe()}}))):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,f=E(n,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(e){M(),L(),oe()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,f=E(n,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(e){M(),L(),oe()}}))}}),e(".wcp-move-file:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:"clone",cursor:"move",start:function(t,o){e(this).closest("td").addClass("wcp-draggable"),e("body").addClass("no-hover-css")},stop:function(t,o){e(this).closest("td").removeClass("wcp-draggable"),e("body").removeClass("no-hover-css")}}),e(".wcp-move-multiple:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:function(t,o){return e(".selected-items").remove(),selectedItems=e("#the-list th input:checked").length,selectedItems>0?(selectedItems=0==selectedItems||1==selectedItems?"1 Item":selectedItems+" Items",e("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")):e("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>")},start:function(t,o){e("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(t,o){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}})}function Y(){e(r).jstree({core:{cache:!1,animation:0,max_depth:a?"-1":1,check_callback:function(t,o,s,r,d){if(e("*").removeClass("drag-bot").removeClass("drag-in").removeClass("drag-up"),("move_node"===t||"copy_node"===t)&&d&&d.dnd)switch(d.pos){case"a":d.origin.get_node(d.ref,!0).addClass("drag-bot"),nodeId=e(".drag-bot").attr("id"),e("#jstree-dnd").text("Below "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"i":if(!a&&e("#do_not_show_again").is(":checked"))return!1;d.origin.get_node(d.ref,!0).addClass("drag-in"),nodeId=e(".drag-in").attr("id"),e("#jstree-dnd").text("Inside "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"b":d.origin.get_node(d.ref,!0).addClass("drag-up"),nodeId=e(".drag-up").attr("id"),e("#jstree-dnd").text("Above "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;default:e("#jstree-dnd").text(e("#jstree-dnd").data("txt"))}return!0}},data:{cache:!1},select_node:!1,search:{show_only_matches:!0,case_sensitive:!1,fuzzy:!1},plugins:["dnd","search","contextmenu"],contextmenu:{select_node:0,show_at_node:0,items:function(){return{}}}}).bind("ready.jstree",function(){!function(){e("#js-tree-menu .jstree-node").each(function(){var t=parseInt(e(this).data("count"));t>0&&e(".jstree-node[id='"+e(this).attr("id")+"'] > a span.premio-folder-count").text(t)}),""!=v&&0!=v&&e(".jstree-node[id='"+v+"']").length&&(e("#js-tree-menu").jstree("select_node",v),e(".sticky-folders .sticky-folder-"+v+" a").length&&e(".sticky-folders .sticky-folder-"+v+" a").addClass("active-item"));e(".ajax-preloader").hide(),e(".js-tree-data").show(),X(),q(),e(".sticky-folders ul > li").length>0&&e(".sticky-folders").addClass("active")}(),z()}).bind("after_open.jstree",function(){z()}).bind("open_all.jstree",function(){z()}).bind("create_node.jstree",function(){z()}).bind("delete_node.jstree",function(){z()}).bind("close_all.jstree",function(){z()}).bind("after_close.jstree",function(){z()}).bind("move_node.jstree",function(t,o){if(!a){var s=o.old_position;if("#"!=o.parent)return e("#js-tree-menu").jstree("move_node","#"+o.node.id,"#",s),e("#sub-drag-folder-popup").show(),!1}"#"!=o.node.parent&&jQuery("#js-tree-menu").jstree("open_node",o.node.parent),folderMoveId=o.node.id,orderString="",e(".folder-modal .jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){"undefined"!=e(this).attr("id")&&(orderString+=e(this).attr("id")+",")}),e(".folder-modal #"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?parentID=e("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().attr("id"):parentID=0,""!=orderString&&(e(".form-loader-count").css("width","100%"),e.ajax({url:folders_media_options.ajax_url,data:"term_ids="+orderString+"&action=wcp_save_folder_order&type="+folders_media_options.post_type+"&nonce="+folders_media_options.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#wcp_folder_parent").html(t.options),e(".form-loader-count").css("width","0"),L(),oe(),Z(),z()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))}),z()}function B(t){e(".folder-modal #js-tree-menu .jstree-anchor.jstree-clicked").length?(v=e(".folder-modal #js-tree-menu .jstree-anchor.jstree-clicked").closest(".jstree-node").attr("id"),e.ajax({url:folders_media_options.ajax_url,data:{post_id:t,action:"premio_check_for_other_folders",active_folder:v,type:folders_media_options.post_type,folder_id:-1,nonce:folders_media_options.nonce,status:folders_media_options.taxonomy_status,taxonomy:v},method:"post",success:function(t){-1==(t=e.parseJSON(t)).status?(e("#unassigned_folders").val(t.data.post_id),e("#confirm-your-change").show()):(L(),M())}})):(f=folders_media_options.nonce,e.ajax({url:folders_media_options.ajax_url,data:"post_id="+t+"&type="+folders_media_options.post_type+"&action=wcp_remove_post_folder&folder_id="+-1+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(e){L(),M()}}))}function E(e,t){if(d.length>0)for(i=0;i<d.length;i++)if(parseInt(d[i].folder_id)==parseInt(e))return d[i][t];return""}function R(e){if(d.length>0)for(i=0;i<d.length;i++)if(parseInt(d[i].folder_id)==parseInt(e))return i;return null}function q(){e(".sticky-folders > ul").html("");var t="";if(e("#js-tree-menu li.jstree-node.is-sticky").each(function(){var o=e(this).attr("id"),a=e.trim(e("#js-tree-menu").jstree(!0).get_node(o).text),s=(e("#"+o+"_anchor .premio-folder-count").text(),e("li.jstree-node[id='"+o+"']").hasClass("is-high")?" is-high ":"");t+="<li data-folder-id='"+o+"' class='sticky-fldr "+s+" sticky-folder-"+o+"'><a href='javascript:;'><span class='folder-title'>"+a+"</span><span class='folder-actions'><span class='update-inline-record'><i class='pfolder-edit-folder'></i></span><span class='star-icon'><i class='pfolder-star'></i></span><span class='premio-folder-count'></span></span></a></li>"}),e(".sticky-folders > ul").html(t),e(".jstree-anchor.jstree-clicked").length){var o=e(".jstree-anchor.jstree-clicked").closest("li.jstree-node").attr("id");e(".sticky-folders .sticky-folder-"+o+" a").addClass("active-item")}e(".sticky-folders > ul > li").length>0?e(".sticky-folders").addClass("active"):e(".sticky-folders").removeClass("active"),X()}function X(){var t=0;if(e("#custom-scroll-menu").hasClass("mCustomScrollbar")){var o=jQuery("#custom-scroll-menu"),a=o.find(".mCSB_dragger"),s=o.find(".mCSB_container").height();t=a.position().top/(o.height()-a.height())*(s-o.height()),e("#custom-scroll-menu").mCustomScrollbar("destroy")}var r=jQuery(".folder-modal .media-modal-content").height()-e(".folder-modal .sticky-wcp-custom-form").height()-40;e(".folder-modal #custom-scroll-menu").closest(".media-frame-menu").length&&jQuery(".folder-custom-menu").length&&jQuery(".media-frame-menu").length&&(r=jQuery(".folder-modal .media-modal-content").height()-e(".folder-modal .sticky-wcp-custom-form").height()-jQuery(".folder-custom-menu").offset().top+jQuery(".media-frame-menu").offset().top-40),r<0&&(r=350),e("#custom-scroll-menu").mCustomScrollbar({axis:"y",scrollButtons:{enable:!0},setHeight:r,theme:"3d",scrollbarPosition:"inside",scrollInertia:500,mouseWheelPixels:60}),0!=t&&jQuery("#custom-scroll-menu").mCustomScrollbar("scrollTo",t+"px",{scrollInertia:0})}function L(){if(e(".media-toolbar").hasClass("media-toolbar-mode-select")&&e("ul.attachments li.selected").length&&(e("ul.attachments li.selected").trigger("click"),e(".select-mode-toggle-button").trigger("click")),""!=g&&(e("#js-tree-menu a.jstree-clicked").length>0||"-1"==v)){if(e("#media-attachment-taxonomy-filter").length){g=g.split(",");for(var t=0;t<g.length;t++)""!=g[t]&&e(".attachments-browser li[data-id='"+g[t]+"']").remove()}g=""}e("#media-attachment-taxonomy-filter").length?te(0):(e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=get_folders_default_list",method:"post",success:function(t){t=e.parseJSON(t),e(".header-posts .total-count").text(t.total_items),e(".un-categorised-items .total-count").text(t.empty_items),C=t.taxonomies,Z(),z()}}),e(".folder-loader-ajax").addClass("active"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(h+" #posts-filter",function(){var t={Title:"",Url:h};history.pushState(t,t.Title,t.Url),"show"!=folders_media_options.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),triggerInlineUpdate()}):e("#wpbody").load(h+" #wpbody-content",!1,function(t){var o={Title:"",Url:h};history.pushState(o,o.Title,o.Url),"show"!=folders_media_options.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>')}))}function Z(){if(e("#media-attachment-taxonomy-filter").length&&(e("#media-attachment-taxonomy-filter").each(function(){folders_media_options.terms=C;var t=e(this);currentDDVal=e(this).val(),t.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>"),C;for(var o=0;o<C.length;o++)t.append("<option value='"+C[o].term_id+"'>"+C[o].name+" ("+C[o].trash_count+")</option>");t.val(currentDDVal).trigger("change")}),e("select.folder_for_media").length)){var t=e("select.folder_for_media").val();e("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var o=0;o<C.length;o++)e("select.folder_for_media option:last-child").before("<option value='"+C[o].term_id+"'>"+C[o].name+"</option>");""!=t&&e(".folder_for_media").val(t)}for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),o=0;o<C.length;o++)0!=parseInt(C[o].trash_count)&&(e(".jstree-node[id='"+C[o].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(C[o].trash_count),e(".sticky-folder-"+C[o].term_id+" .premio-folder-count").text(C[o].trash_count));""!=v&&e("#wcp_folder_"+v).addClass("active-item"),j&&(e("#title_"+c).trigger("click"),j=!1)}function K(){var t=e.trim(e("#folder-search").val());e("#js-tree-menu").jstree("search",t)}function W(t){var o="Are you sure you want to delete the selected folder?",a="Items in the folder will not be deleted.";if(y=!1,1==t&&e("#menu-checkbox").is(":checked")){if(y=!0,0==e("#js-tree-menu input.checkbox:checked").length)return e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html("Please select at least one folder to delete"),void e("#error-folder-popup").show();e("#js-tree-menu input.checkbox:checked").length>1&&(o="Are you sure you want to delete the selected folders?",a="Items in the selected folders will not be deleted.")}e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#remove-folder-item").text("Yes, Delete it!"),e("#remove-folder-message").text(o),e("#remove-folder-notice").text(a),e("#confirm-remove-folder").show(),e("#remove-folder-item").focus()}function G(){folderName=e.trim(e("#js-tree-menu").jstree(!0).get_node(c).text),parentID=e("#wcp_folder_"+c).closest("li.jstree-node").data("folder-id"),parentID==t&&(parentID=0),e("#update-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#update-folder-item-name").val(folderName),e("#update-folder-item").removeClass("disabled"),e("#update-folder-item").show(),e("#update-folder-item-name").focus(),e(".dynamic-menu").remove()}function $(){if(0==u&&p>=10)return e("#folder-limitation-message").html("You've reached the 10 folder limitation!"),e("#no-more-folder-credit").show(),!1;e("#add-update-folder-title").text("Add new folder"),e("#save-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#add-update-folder-name").val(""),k&&(w=c,e("#add-update-folder-name").val(e.trim(e("#js-tree-menu").jstree(!0).get_node(c).text)+" #2"),c=e("#"+c+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?e("#"+c+"_anchor").closest(".jstree-node").parent().parent().attr("id"):0),e("#add-update-folder").removeClass("disabled"),e("#add-update-folder").show(),e("#add-update-folder-name").focus(),e(".dynamic-menu").remove()}function ee(){setTimeout(function(){if(e("#js-tree-menu .jstree-node.jstree-leaf").length==e("#js-tree-menu .jstree-node").length)e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand");else{var t=e("#js-tree-menu .jstree-node.jstree-closed").length+e("#js-tree-menu .jstree-node.jstree-open").length;e("#js-tree-menu .jstree-node.jstree-closed").length==t?(e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand")):(e("#expand-collapse-list").addClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Collapse"))}},500),z()}function te(o){F=e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_get_default_list&active_id="+v,method:"post",beforeSend:function(){null!=F&&F.abort()},success:function(a){if(a=e.parseJSON(a),e(".header-posts .total-count").text(a.total_items),e(".un-categorised-items .total-count").text(a.empty_items),selectedVal=e("#media-attachment-taxonomy-filter").val(),"all"!=selectedVal&&1==o){var s=parent.wp;s.media!=t&&(s.media.frame.setState("insert"),null!==s.media.frame.content.get()?(s.media.frame.content.get().collection.props.set({ignore:+new Date}),s.media.frame.content.get().options.selection.reset()):s.media.frame.library.props.set({ignore:+new Date}))}C=a.taxonomies,Z(),z()}})}function oe(){e(".folder-loader-ajax").addClass("active"),e(".folder-loader-ajax img").removeClass("active"),e(".folder-loader-ajax svg#successAnimation").addClass("active").addClass("animated"),setTimeout(function(){e(".folder-loader-ajax").removeClass("active"),e(".folder-loader-ajax img").addClass("active"),e(".folder-loader-ajax svg#successAnimation").removeClass("active").removeClass("animated")},2e3),z()}e(document).ready(function(){e(document).on("click",".folder-settings-btn > a",function(t){t.stopPropagation(),e(".folder-settings-btn").toggleClass("active")}),e(document).on("click","body,html",function(){e(".folder-settings-btn").removeClass("active")}),e(document).on("click",".folder-setting-menu",function(e){e.stopPropagation()}),e(document).on("click","#remove-from-all-folders:not(.disabled), #remove-from-current-folder:not(.disabled)",function(){e("#remove-from-all-folders, #remove-from-current-folder").addClass("disabled");var t="all";e(this).hasClass("remove-from-current-folder")&&(t="current"),e("#confirm-your-change").hide(),e.ajax({url:folders_media_options.ajax_url,data:{post_id:e("#unassigned_folders").val(),action:"wcp_remove_post_folder",active_folder:v,type:folders_media_options.post_type,folder_id:-1,nonce:folders_media_options.nonce,status:folders_media_options.taxonomy_status,taxonomy:v,remove_from:t},method:"post",success:function(t){e("#remove-from-all-folders, #remove-from-current-folder").removeClass("disabled"),oe(),L(),M()}})}),o=parseInt(folders_media_options.hasStars),a=parseInt(folders_media_options.hasChildren),e(document).on("click",".thumbnail-hover-box a",function(t){return t.stopPropagation(),t.stopImmediatePropagation(),t.preventDefault(),window.open(e(this).prop("href"),"_blank"),!1}),e(document).ajaxComplete(function(e,o,a){if(a.data!=t&&""!=a.data&&-1!=a.data.indexOf("action=query-attachments")&&z(),s.length>0){console.log(s);for(var r=0;r<s.length;r++)if(jQuery(".folder-modal ul.attachments li[data-id='"+s[r]+"']").length&&!jQuery(".folder-modal ul.attachments li[data-id='"+s[r]+"']").hasClass("selected")){var d=jQuery.Event("click");d.ctrlKey=!0,jQuery(".folder-modal ul.attachments li[data-id='"+s[r]+"']").trigger(d)}}}),C=folders_media_options.terms,u=parseInt(folders_media_options.is_key_active),p=parseInt(folders_media_options.folders),d=folders_media_options.folder_settings,e(document).on("click",".header-posts a.all-posts",function(t){c=0,v="",l="all",e(".active-item").removeClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e(this).addClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(this).closest(".media-frame").find("#media-attachment-taxonomy-filter").val("all").trigger("change"),e(this).closest(".media-frame").find(".folder_for_media").val("all").trigger("change"),V()}),e(document).on("click",".un-categorised-items",function(t){c=0,v="",l="unassigned",e(".active-item").removeClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e(this).addClass("active-item"),e(this).closest(".media-frame").find("#media-attachment-taxonomy-filter").val("unassigned").trigger("change"),e(this).closest(".media-frame").find(".folder_for_media").val("-1").trigger("change"),V()}),e(document).on("click","a.jstree-anchor",function(t){var o,a=e(this).closest("li.jstree-node").attr("id");l=c=a,e(this).closest(".folder-modal").find(".active-item").removeClass("active-item"),e(this).closest(".folder-modal").find("#media-attachment-taxonomy-filter").val(a),e(this).closest(".folder-modal").find("#media-attachment-taxonomy-filter").trigger("change"),thisSlug=E(a,"slug"),o=thisSlug,e.ajax({url:folders_media_options.ajax_url,type:"post",data:"action=save_folder_last_status&post_type="+folders_media_options.post_type+"&post_id="+o+"&nonce="+folders_media_options.nonce,cache:!1,async:!1,success:function(){}}),e(".custom-media-select").removeClass("active"),V()}),e(document).on("change",".folder_for_media",function(){"add-folder"!=e(this).val()&&null!=e(this).val()?l=e(this).val():"add-folder"==e(this).val()&&(l=-1)}),e(document).on("click",".new-folder-pro",function(t){t.preventDefault(),e(".dynamic-menu").remove(),e("#sub-folder-popup").show()}),e(document).on("click",".close-popup-button a",function(){e(".folder-popup-form").hide()}),e(document).on("click",".update-inline-record",function(s){var r;(s.stopImmediatePropagation(),s.stopPropagation(),0!=folders_media_options.can_manage_folder)&&(isHigh=e(this).closest("li.sticky-fldr").hasClass("is-high"),isSticky=e(this).closest("li.sticky-fldr").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu' data-id='"+e(this).closest("li").data("folder-id")+"'><ul>",menuHtml+="<li class='new-main-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>",menuHtml+=a?"<li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>":"<li class='new-folder-pro'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Sub-folder (Pro)</a></li>",menuHtml+="<li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span>Rename</a></li><li class='default-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-active-icon'></i></span>Open this folder by default (Pro)</a></li><li class='sticky-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li>",menuHtml+=o?"<li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star":"Add a Star")+"</a></li>":"<li class='mark-folder-pro'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star (Pro)":"Add a Star (Pro)")+"</a></li>",menuHtml+="<li class='lock-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='dashicons dashicons-lock'></span>Lock Folder (Pro)</a></li><li class='duplicate-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-clone'></i></span>Duplicate folder (Pro)</a></li>",hasPosts=parseInt(e(this).closest("li.jstree-node").find("h3.title:first > .total-count").text()),"attachment"==folders_media_options.post_type&&hasPosts&&(menuHtml+="<li class='download-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span>Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span>Delete</a></li></ul></div>",e("body").append(menuHtml),s.pageX==t||s.pageY==t?(e(".dynamic-menu").css("left",S),e(".dynamic-menu").css("top",I-10),r=I):(e(".dynamic-menu").css("left",s.pageX),e(".dynamic-menu").css("top",s.pageY),r=s.pageY),r+e(".dynamic-menu").height()>e(window).height()&&e(".dynamic-menu").css("margin-top",e(window).height()-(r+e(".dynamic-menu").height())))}),e(document).on("click","body, html",function(t){e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),e(".folder-order").removeClass("active")}),e(document).on("click",".dynamic-menu, .folder-order",function(e){e.stopPropagation()}),e(document).on("contextmenu",".jstree-anchor",function(t){return S=t.pageX,I=t.pageY,e(this).find("span.folder-inline-edit").trigger("click"),!1}),e(document).on("click",".folder-actions span.folder-inline-edit",function(s){var r;(s.stopImmediatePropagation(),s.stopPropagation(),0!=folders_media_options.can_manage_folder)&&(isHigh=e(this).closest("li.jstree-node").hasClass("is-high"),isSticky=e(this).closest("li.jstree-node").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu' data-id='"+e(this).closest("li").prop("id")+"'><ul>",menuHtml+="<li class='new-main-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>",menuHtml+=a?"<li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>":"<li class='new-folder-pro'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Sub-folder (Pro)</a></li>",menuHtml+="<li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span>Rename</a></li><li class='default-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-active-icon'></i></span>Open this folder by default (Pro)</a></li><li class='sticky-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li>",menuHtml+=o?"<li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star":"Add a Star")+"</a></li>":"<li class='mark-folder-pro'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star (Pro)":"Add a Star (Pro)")+"</a></li>",menuHtml+="<li class='lock-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='dashicons dashicons-lock'></span>Lock Folder (Pro)</a></li><li class='duplicate-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-clone'></i></span>Duplicate folder (Pro)</a></li>",hasPosts=parseInt(e(this).closest("a.jstree-anchor").find(".premio-folder-count").text()),"attachment"==folders_media_options.post_type&&hasPosts&&(menuHtml+="<li class='download-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span>Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span>Delete</a></li></ul></div>",e("body").append(menuHtml),e(this).parents("li.jstree-node").addClass("active-menu"),s.pageX==t||s.pageY==t?(e(".dynamic-menu").css("left",S),e(".dynamic-menu").css("top",I-10),r=I):(e(".dynamic-menu").css("left",s.pageX),e(".dynamic-menu").css("top",s.pageY),r=s.pageY),r+e(".dynamic-menu").height()>e(window).height()&&e(".dynamic-menu").css("margin-top",e(window).height()-(r+e(".dynamic-menu").height())))}),e(document).on("click",".dynamic-menu",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click","body, html",function(){e(".dynamic-menu").remove()}),e(document).on("click",".new-folder",function(t){t.stopPropagation(),c=e(this).closest(".dynamic-menu").data("id"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),j=!1,k=!1,$()}),e(document).on("click",".new-main-folder",function(){b=1,c=e(this).closest(".dynamic-menu").data("id"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),j=!1,k=!1,$()}),e(document).on("click","#add-new-folder",function(t){e("#js-tree-menu a.jstree-clicked").length?(c=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),a||e("#pro-notice").removeClass("hide-it")):(c=0,e("#pro-notice").addClass("hide-it")),j=!1,$()}),e(document).on("submit","#save-folder-form",function(t){if(t.stopPropagation(),t.preventDefault(),m=e("#add-update-folder-name").val(),""==e.trim(m))e(".folder-form-errors").addClass("active"),e("#add-update-folder-name").focus();else{e("#save-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#add-update-folder").addClass("disabled");var o=c;j&&(o=0),a||(o=0);var s="";0==o?(x=e("#js-tree-menu > ul > li.jstree-node").length,b&&(x=jQuery("#js-tree-menu > ul > li[id='"+c+"']").index(),jQuery("#js-tree-menu > ul > li").each(function(e){s+=jQuery(this).attr("id")+",",e==x&&(s+="#,")}),x+=1)):x=e("#js-tree-menu > ul > li.jstree-node[id='"+o+"'] > ul.jstree-children > li").length+1,e.ajax({url:folders_media_options.ajax_url,data:{parent_id:o,type:folders_media_options.post_type,action:"wcp_add_new_folder",nonce:folders_media_options.nonce,term_id:o,order:x,name:m,is_duplicate:k,duplicate_from:w,parent_ids:s,parent_menu:b},method:"post",success:function(t){if(result=e.parseJSON(t),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),-1==result.status)e("#no-more-folder-credit").show();else if("1"==result.status){if(u=parseInt(result.is_key_active),p=parseInt(result.folders),e("#current-folder").text(p),e("#ttl-fldr").text(10),ee(),result.data.length)for(var o=0;o<result.data.length;o++){var a={folder_id:result.data[o].term_id,folder_count:0,is_sticky:result.data[o].is_sticky,is_high:result.data[o].is_high,nonce:result.data[o].nonce,slug:result.data[o].slug,is_deleted:0};d.push(a),b?e("#js-tree-menu").jstree().create_node("#",{id:result.data[o].term_id,text:" "+result.data[o].title},x,function(){e(".jstree-node[id='"+result.data[o].term_id+"']").attr("data-nonce",result.data[o].nonce),e(".jstree-node[id='"+result.data[o].term_id+"']").attr("data-slug",result.data[o].slug)}):e("#js-tree-menu").jstree().create_node(result.parent_id,{id:result.data[o].term_id,text:" "+result.data[o].title},"last",function(){e(".jstree-node[id='"+result.data[o].term_id+"']").attr("data-nonce",result.data[o].nonce),e(".jstree-node[id='"+result.data[o].term_id+"']").attr("data-slug",result.data[o].slug)}),b=0}oe(),q(),c=result.term_id,te(0)}else e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show()}})}return!1}),e(document).on("click",".form-cancel-btn",function(){e(".folder-popup-form").hide()}),e(document).on("click",".folder-popup-form",function(t){e(".folder-popup-form").hide()}),e(document).on("click",".popup-form-content",function(e){e.stopPropagation()}),document.onkeydown=function(t){("key"in(t=t||window.event)?"Escape"===t.key||"Esc"===t.key:27===t.keyCode)&&e(".folder-popup-form").hide()},e(document).on("click",".rename-folder",function(t){t.stopPropagation(),c=e(this).closest(".dynamic-menu").data("id"),G(),e(".dynamic-menu").remove()}),e(document).on("click","#inline-update",function(t){e("#js-tree-menu a.jstree-clicked").length&&(c=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),G())}),e(document).on("submit","#update-folder-form",function(o){return o.stopPropagation(),o.preventDefault(),m=e("#update-folder-item-name").val(),""==e.trim(m)?(e(".folder-form-errors").addClass("active"),e("#update-folder-item-name").focus()):(e("#update-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#update-folder-item").addClass("disabled"),f=E(c,"nonce"),parentID=e(".jstree-node[id='"+c+"']").closest("li.jstree-node").attr("id"),parentID==t&&(parentID=0),e.ajax({url:folders_media_options.ajax_url,data:{parent_id:parentID,type:folders_media_options.post_type,action:"wcp_update_folder",nonce:f,term_id:c,order:x,name:m},method:"post",success:function(t){result=e.parseJSON(t),"1"==result.status?(e("#js-tree-menu").jstree("rename_node",result.id," "+result.term_title),folderPostId=R(result.id),null!=folderPostId&&(d[folderPostId].nonce=result.nonce,d[folderPostId].slug=result.slug),e(".folder-popup-form").hide(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),oe(),e("#media-attachment-taxonomy-filter").length&&te(0)):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show())}})),!1}),e(document).on("click",".mark-folder",function(t){t.stopPropagation(),n=e(this).closest(".dynamic-menu").data("id"),f=E(n,"nonce"),e(".form-loader-count").css("width","100%"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),e.ajax({url:folders_media_options.ajax_url,data:"term_id="+n+"&type="+folders_media_options.post_type+"&action=wcp_mark_un_mark_folder&nonce="+f,method:"post",cache:!1,success:function(t){t=e.parseJSON(t),e(".form-loader-count").css("width","0%"),"1"==t.status?(folderPostId=R(t.id),"1"==t.marked?(e("li.jstree-node[id='"+t.id+"']").addClass("is-high"),e(".sticky-folder-"+t.id).addClass("is-high"),null!=folderPostId&&(d[folderPostId].is_high=1)):(e("li.jstree-node[id='"+t.id+"']").removeClass("is-high"),e(".sticky-folder-"+t.id).removeClass("is-high"),null!=folderPostId&&(d[folderPostId].is_high=0)),oe()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})}),e(document).on("click",".duplicate-folder",function(t){t.stopPropagation(),c=e(this).closest(".dynamic-menu").data("id"),e(".dynamic-menu").remove(),j=!1,k=!0,$()}),e(document).on("click",".remove-folder",function(){n=e(this).closest(".dynamic-menu").data("id"),c=e(this).closest(".dynamic-menu").data("id"),W(0),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")}),e(document).on("click","#remove-folder-item",function(t){t.stopPropagation(),e(".folder-popup-form").addClass("disabled"),e("#remove-folder-item").html('<span class="dashicons dashicons-update"></span>'),f=E(c,"nonce"),y?function(){if(e("#menu-checkbox").is(":checked")&&e("#js-tree-menu input.checkbox:checked").length>0){var t="";e("#js-tree-menu input.checkbox:checked").each(function(){t+=e(this).closest("li.jstree-node").attr("id")+",",e(this).closest("li.jstree-node").hasClass("jstree-clicked")&&!0}),e(".form-loader-count").css("width","100%"),e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_remove_muliple_folder&term_id="+t+"&nonce="+folders_media_options.nonce,method:"post",success:function(t){if(t=e.parseJSON(t),e(".form-loader-count").css("width","0px"),"1"==t.status){for(u=parseInt(t.is_key_active),p=parseInt(t.folders),e("#current-folder").text(p),i=0;i<t.term_ids.length;i++)e(".folder-modal #js-tree-menu").jstree().delete_node(t.term_ids[i]);e("#ttl-fldr").text(10),oe(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),L(),q(),oe(),e(".folder-modal #wcp_folder_"+v).length||(e(".header-posts a").trigger("click"),v=0)}else window.location.reload();e("#menu-checkbox").attr("checked",!1),e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox")}})}}():e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_remove_folder&term_id="+c+"&nonce="+f,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#js-tree-menu").jstree().delete_node(c),u=parseInt(t.is_key_active),p=parseInt(t.folders),e("#current-folder").text(p),e("#ttl-fldr").text(10),e(".sticky-folders .sticky-folder-"+c).remove(),oe(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),L(),q(),v==c&&e(".header-posts").trigger("click")):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})}),e(document).on("click","#sort-order-list",function(t){t.stopPropagation(),e(".folder-order").toggleClass("active")}),e(document).on("click","#expand-collapse-list",function(t){t.stopPropagation();var o=0;e(this).hasClass("all-open")?(e(this).removeClass("all-open"),o=0,e(this).attr("data-folder-tooltip","Expand"),e("#js-tree-menu").jstree("close_all")):(e(this).addClass("all-open"),o=1,e(this).attr("data-folder-tooltip","Collapse"),e("#js-tree-menu").jstree("open_all")),g="",e("#js-tree-menu .jstree-node:not(.jstree-leaf)").each(function(){g+=e(this).attr("id")+","}),""!=g&&(e(".form-loader-count").css("width","100%"),f=folders_media_options.nonce,e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_change_all_status&status="+o+"&folders="+g+"&nonce="+f,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=e.parseJSON(t)).status&&(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))}),e(document).on("click",".folder-sort-menu a:not(.pro-feature)",function(t){t.stopPropagation(),t.preventDefault(),e(".form-loader-count").css("width","100%"),e(".folder-order").removeClass("active"),e(this).attr("data-sort"),e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_folders_by_order&nonce="+folders_media_options.nonce+"&order="+e(this).attr("data-sort"),method:"post",success:function(t){1==(t=e.parseJSON(t)).status&&(e("#js-tree-menu").jstree().destroy(),e("#js-tree-menu").append("<ul></ul>"),e("#js-tree-menu ul").html(t.data),C=t.terms,Z(),Y()),e(".form-loader-count").css("width","0")}})}),e(document).on("change","#media-attachment-taxonomy-filter",function(t){e("#js-tree-menu").jstree(!0).deselect_all(),e(".active-item").removeClass("active-item"),"all"==e(this).val()?e(".all-posts").addClass("active-item"):"unassigned"==e(this).val()?e(".un-categorised-items").addClass("active-item"):e("#js-tree-menu").jstree("select_node",e(this).val())}),e(document).on("click",".jstree-node .jstree-icon",function(){n=e(this).closest("li.jstree-node").attr("id"),e("li.jstree-node[id='"+n+"']").hasClass("jstree-open")?folderStatus=1:folderStatus=0,e(".form-loader-count").css("width","100%"),f=E(n,"nonce"),ee(),e.ajax({url:folders_media_options.ajax_url,data:"is_active="+folderStatus+"&action=save_wcp_folder_state&term_id="+n+"&nonce="+f,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=e.parseJSON(t)).status||(e("#wcp_folder_"+n).hasClass("active")?(e("#wcp_folder_"+n).removeClass("active"),e("#wcp_folder_"+n).find("ul.ui-sortable:first-child > li").slideUp(),folderStatus=0):(e("#wcp_folder_"+n).addClass("active"),e("#wcp_folder_"+n).find("ul.ui-sortable:first-child > li").slideDown(),folderStatus=1),oe())}})}),e(document).on("keyup","#folder-search",function(){K()}),e(document).on("change","#folder-search",function(){K()}),e(document).on("blur","#folder-search",function(){K()}),e(document).on("click","#do_not_show_again",function(){var t=e(this).is(":checked")?1:0;e.ajax({url:folders_media_options.ajax_url,type:"post",data:{action:"premio_hide_child_popup",status:t,nonce:folders_media_options.nonce,post_type:folders_media_options.post_type}})}),e(document).on("click","#menu-checkbox",function(){e(this).is(":checked")?(e("#js-tree-menu").addClass("show-folder-checkbox"),e("#menu-checkbox").prop("checked",!0)):(e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox"),e("#menu-checkbox").prop("checked",!1))}),e(document).on("click","#menu-checkbox",function(){e(this).is(":checked")?(e("#menu-checkbox").prop("checked",!0),e("#js-tree-menu").addClass("show-folder-checkbox")):(e("#menu-checkbox").prop("checked",!1),e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox"))}),e(document).on("click",".folder-checkbox, .input-checkbox",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click","#inline-remove, .delete-folder-action:not(.disabled)",function(){e("#js-tree-menu a.jstree-clicked").length?(c=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),W(1),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")):e("#menu-checkbox").is(":checked")&&(e(".dynamic-menu").remove(),W(1))}),e(document).on("change",".folder_for_media",function(){"add-folder"==e(this).val()&&(j=!0,e("#add-new-folder").trigger("click"))}),e(document).on("click","#js-tree-menu input.checkbox",function(){V()}),z(),e(document).on("click",".undo-button, .undo-folder-action:not(.disabled)",function(){e("#do-undo").removeClass("active"),"yes"==folders_media_options.useFolderUndo&&e.ajax({url:folders_media_options.ajax_url,type:"post",data:{post_type:folders_media_options.post_type,nonce:folders_media_options.nonce,action:"wcp_undo_folder_changes"},success:function(o){if(e("#undo-done").addClass("active"),setTimeout(function(){e("#undo-done").removeClass("active")},2500),e("#media-attachment-taxonomy-filter").length){var a=parent.wp;a.media!=t&&(a.media.frame.setState("insert"),null!==a.media.frame.content.get()?(a.media.frame.content.get().collection.props.set({ignore:+new Date}),a.media.frame.content.get().options.selection.reset()):a.media.frame.library.props.set({ignore:+new Date}))}L()}})}),e(document).on("click",".close-undo-box",function(t){t.preventDefault(),e("#do-undo").removeClass("active")})})});
|
1 |
+
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"undefined"!=typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e,t){var o,a,s=[],r=".folder-modal #js-tree-menu",d=[],l=-1,n=0,c=0,m="",p=-1,u=0,f="",h=folders_media_options.page_url,v="",g="",y=!1,j=!1,k=!1,b=!1,w=0,x=0,C=[],S=null,I=null,P=wp.media.view.AttachmentFilters.extend({id:"media-attachment-taxonomy-filter",createFilters:function(){var e={};folders_media_options.terms.length;_.each(folders_media_options.terms||{},function(t,o){e[t.term_id]={text:t.name+" ("+t.trash_count+")",props:{media_folder:t.slug}}}),e.all={text:"All Folders",props:{media_folder:""},priority:10},e.unassigned={text:"(Unassigned)",props:{media_folder:"-1"},priority:10},this.filters=e},change:function(){var e={};_.each(folders_media_options.terms||{},function(t,o){e[t.term_id]={text:t.name+" ("+t.count+")",props:{media_folder:t.slug}}}),e.all={text:"Select a folder >>",props:{media_folder:""},priority:10},e.unassigned={text:"(Unassigned)",props:{media_folder:"-1"},priority:10},this.filters=e;var t=this.filters[this.el.value];t&&this.model.set(t.props)}}),D=0,H=0,N=wp.media.view.AttachmentsBrowser;wp.media.view.AttachmentsBrowser=wp.media.view.AttachmentsBrowser.extend({createToolbar:function(){N.prototype.createToolbar.call(this),this.toolbar.set("MediaLibraryOrganizerTaxonomyFilter",new P({controller:this.controller,model:this.collection.props,priority:-75}).render())}});var A,O=wp.media.model.Query;_.extend(O,{get:(A=[],function(e,t){var o,a={},s=O.orderby,r=O.defaultProps;return delete e.query,delete e.cache,_.defaults(e,r),_.each(["include","exclude"],function(t){e[t]&&!_.isArray(e[t])&&(e[t]=[e[t]])}),_.each(e,function(e,t){_.isNull(e)||(a[O.propmap[t]||t]=e)}),_.defaults(a,O.defaultArgs),a.orderby=s.valuemap[e.orderby]||e.orderby,A=[],o||(o=new O([],_.extend(t||{},{props:e,args:a})),A.push(o)),o})});var Q=window.wp;void 0!==Q&&"function"==typeof Q.Uploader&&(Q.media.view.Modal.prototype.on("open",function(){s=[],setTimeout(function(){e("#media-attachment-taxonomy-filter").length&&("all"==e("#media-attachment-taxonomy-filter").val()&&(e("#media-attachment-taxonomy-filter option:gt(1)").remove(),_.each(folders_media_options.terms,function(t,o){e("#media-attachment-taxonomy-filter").append("<option value='"+t.term_id+"'>"+t.name+" ("+t.trash_count+")</option>")})),e("#wcp-content").length||e(".editor-post-featured-image").length&&e(".attachment-filters").val("all").trigger("change"))},100)}),Q.media.view.Modal.prototype.on("close",function(){s=[]}),e.extend(Q.Uploader.prototype,{progress:function(){},init:function(){this.uploader&&(this.uploader.bind("FileFiltered",function(t,o){D++,e(".folder-meter").css("width","0%"),e(".media-folder-loader").show(),e("#total_upload_files").text(D)}),this.uploader.bind("BeforeUpload",function(t,o){var a=l,s=t.settings.multipart_params;if((a=parseInt(a))>0&&(s.folder_for_media=a),H<D){e(".media-folder-loader").show();var r=H/D*100;e(".folder-meter").css("width",r+"%")}H++,e("#current_upload_files").text(H)}),this.uploader.bind("UploadComplete",function(e,t){l=-1}),this.uploader.bind("UploadComplete",function(t,o){var a=window.wp;e(".folder-meter").css("width","100%"),setTimeout(function(){e(".media-folder-loader").hide(),e(".folder-meter").css("width","0%"),D=0,H=0},1250),function(){e("#media-attachment-taxonomy-filter").val();F=e.ajax({url:folders_media_options.ajax_url,data:"type=attachment&action=wcp_get_default_list&active_id=0",method:"post",beforeSend:function(){null!=F&&F.abort()},success:function(t){var t=e.parseJSON(t);C=t.taxonomies,Z(),z()}})}(),void 0!==a.media.frame&&null!==a.media.frame.content.get()&&void 0!==a.media.frame.content.get().collection&&(s=[],e(".folder-modal ul.attachments li.selected").length&&e(".folder-modal ul.attachments li.selected").each(function(){s.push(e(this).data("id"))}),a.media.frame.content.get().collection.props.set({ignore:+new Date}),a.media.frame.content.get().options.selection.reset())}))}}));var F,T=window.wp;if(void 0!==T&&"function"==typeof T.Uploader){var U=window.wp.media,J=U.view.Modal;U.view.Modal=U.view.Modal.extend({className:"folder-modal",initialize:function(){J.prototype.initialize.apply(this,arguments)},open:function(){J.prototype.open.apply(this,arguments)&&(e(".folder-modal").length||e(".supports-drag-drop").length&&e(".supports-drag-drop").each(function(){"block"!=e(this).css("display")&&"inline-block"!=e(this).css("display")||e(this).addClass("folder-modal")}),e(".folder-modal").length?(e(".folder-custom-menu").remove(),e(".folder-modal .media-frame-tab-panel").removeClass("has-folder-menu"),e(".folder-modal .media-frame").hasClass("hide-menu")?e(".folder-custom-menu").length||(e(".folder-modal .media-frame-tab-panel").before("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>"),e(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url+" #wcp-content-resize",function(){ee(),X(),Y()})):e(".folder-custom-menu").length||(e(".folder-modal .media-frame-menu").addClass("has-folder-menu"),e(".folder-modal .media-frame-menu .media-menu").append("<div class='folder-custom-menu'><div class='folder-menu-content'><div class='cssload-container'><div class='cssload-tube-tunnel'></div></div></div></div>"),e(".folder-modal .folder-menu-content").load(folders_media_options.media_page_url+" #wcp-content-resize",function(){ee(),X(),Y()})),e(".folder-form-data").remove(),e(".media-frame-tab-panel:first").before("<div class='folder-form-data'></div>"),e(".folder-form-data").load(folders_media_options.media_page_url+" #folder-add-update-content",function(){})):setTimeout(function(){-1!=l&&e("#media-attachment-taxonomy-filter").each(function(){e(this).val(l),e(this).trigger("change")})},1e3))},close:function(){J.prototype.close.apply(this,arguments),e(".folder-modal").removeClass("folder-modal")}})}function M(){"yes"==folders_media_options.useFolderUndo&&(e("#do-undo").addClass("active"),e(".undo-folder-action").removeClass("disabled"),setTimeout(function(){e("#do-undo").removeClass("active"),e(".undo-folder-action").addClass("disabled")},parseInt(folders_media_options.defaultTimeout)))}function V(){e(".cut-folder-action, .copy-folder-action, .paste-folder-action, .delete-folder-action").addClass("disabled"),e("#js-tree-menu .jstree-anchor.jstree-clicked").length&&e(".delete-folder-action").removeClass("disabled"),(e("#menu-checkbox").is(":checked")||e("#menu-checkbox").is(":checked"))&&e("#js-tree-menu input.checkbox:checked").length>0&&e(".delete-folder-action").removeClass("disabled")}function z(){e(".jstree-anchor:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){n=e(this).closest("li.jstree-node").attr("id"),o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),f=E(n,"nonce"),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(M(),L()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,f=E(n,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(M(),L()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,f=E(n,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),g=chkStr,e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(e){M(),L(),oe()}}))}}),e(".media-frame:not(.hide-router) .attachments-browser li.attachment:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:function(t,o){e(".selected-items").remove();var a=e(".media-frame:not(.hide-router) .attachments-browser li.attachment.selected").length;return e("<div class='selected-items'><span class='total-post-count'>"+(a=0==a||1==a?"1 Item":a+" Items")+" Selected</span></div>")},start:function(t,o){e("body").addClass("no-hover-css")},cursor:"move",appendTo:".media-modal",cursorAt:{left:0,top:0},stop:function(t,o){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}}),e(".un-categorised-items").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){n=-1,f=folders_media_options.nonce,o.draggable.hasClass("wcp-move-multiple")?e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),B(chkStr)):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,chkStr=postID+",",e(".wp-list-table input:checked").each(function(){postID!=e(this).val()&&(chkStr+=e(this).val()+",")}),B(chkStr)):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),g=chkStr,B(chkStr))}}),e(".tree-structure .folder-item:not(.ui-droppable)").droppable({accept:".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",hoverClass:"wcp-drop-hover-list",classes:{"ui-droppable-active":"ui-state-highlight"},drop:function(t,o){e("body").removeClass("no-hover-css"),n=e(this).data("id"),o.draggable.hasClass("wcp-move-multiple")?(f=E(n,"nonce"),e(".wp-list-table input:checked").length&&(chkStr="",e(".wp-list-table input:checked").each(function(){chkStr+=e(this).val()+","}),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(e){M(),L(),oe()}}))):o.draggable.hasClass("wcp-move-file")?(postID=o.draggable[0].attributes["data-id"].nodeValue,f=E(n,"nonce"),chkStr=postID+",",e(".wp-list-table input:checked").each(function(){e(this).val()!=postID&&(chkStr+=e(this).val()+",")}),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(e){M(),L(),oe()}})):o.draggable.hasClass("attachment")&&(chkStr=o.draggable[0].attributes["data-id"].nodeValue,f=E(n,"nonce"),e(".attachments-browser li.attachment.selected").length>1&&(chkStr="",e(".attachments-browser li.attachment.selected").each(function(){chkStr+=e(this).data("id")+","})),e.ajax({url:folders_media_options.ajax_url,data:"post_ids="+chkStr+"&type="+folders_media_options.post_type+"&action=wcp_change_multiple_post_folder&folder_id="+n+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(e){M(),L(),oe()}}))}}),e(".wcp-move-file:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:"clone",cursor:"move",start:function(t,o){e(this).closest("td").addClass("wcp-draggable"),e("body").addClass("no-hover-css")},stop:function(t,o){e(this).closest("td").removeClass("wcp-draggable"),e("body").removeClass("no-hover-css")}}),e(".wcp-move-multiple:not(.ui-draggable)").draggable({revert:"invalid",containment:"document",helper:function(t,o){return e(".selected-items").remove(),selectedItems=e("#the-list th input:checked").length,selectedItems>0?(selectedItems=0==selectedItems||1==selectedItems?"1 Item":selectedItems+" Items",e("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>")):e("<div class='selected-items'><span class='total-post-count'>Select Items to move</span></div>")},start:function(t,o){e("body").addClass("no-hover-css")},cursor:"move",cursorAt:{left:0,top:0},stop:function(t,o){e(".selected-items").remove(),e("body").removeClass("no-hover-css")}})}function Y(){e(r).jstree({core:{cache:!1,animation:0,max_depth:a?"-1":1,check_callback:function(t,o,s,r,d){if(e("*").removeClass("drag-bot").removeClass("drag-in").removeClass("drag-up"),("move_node"===t||"copy_node"===t)&&d&&d.dnd)switch(d.pos){case"a":d.origin.get_node(d.ref,!0).addClass("drag-bot"),nodeId=e(".drag-bot").attr("id"),e("#jstree-dnd").text("Below "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"i":if(!a&&e("#do_not_show_again").is(":checked"))return!1;d.origin.get_node(d.ref,!0).addClass("drag-in"),nodeId=e(".drag-in").attr("id"),e("#jstree-dnd").text("Inside "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;case"b":d.origin.get_node(d.ref,!0).addClass("drag-up"),nodeId=e(".drag-up").attr("id"),e("#jstree-dnd").text("Above "+e.trim(e("#js-tree-menu").jstree(!0).get_node(nodeId).text));break;default:e("#jstree-dnd").text(e("#jstree-dnd").data("txt"))}return!0}},data:{cache:!1},select_node:!1,search:{show_only_matches:!0,case_sensitive:!1,fuzzy:!1},plugins:["dnd","search","contextmenu"],contextmenu:{select_node:0,show_at_node:0,items:function(){return{}}}}).bind("ready.jstree",function(){!function(){e("#js-tree-menu .jstree-node").each(function(){var t=parseInt(e(this).data("count"));t>0&&e(".jstree-node[id='"+e(this).attr("id")+"'] > a span.premio-folder-count").text(t)}),""!=v&&0!=v&&e(".jstree-node[id='"+v+"']").length&&(e("#js-tree-menu").jstree("select_node",v),e(".sticky-folders .sticky-folder-"+v+" a").length&&e(".sticky-folders .sticky-folder-"+v+" a").addClass("active-item"));e(".ajax-preloader").hide(),e(".js-tree-data").show(),X(),q(),e(".sticky-folders ul > li").length>0&&e(".sticky-folders").addClass("active")}(),z()}).bind("after_open.jstree",function(){z()}).bind("open_all.jstree",function(){z()}).bind("create_node.jstree",function(){z()}).bind("delete_node.jstree",function(){z()}).bind("close_all.jstree",function(){z()}).bind("after_close.jstree",function(){z()}).bind("move_node.jstree",function(t,o){if(!a){var s=o.old_position;if("#"!=o.parent)return e("#js-tree-menu").jstree("move_node","#"+o.node.id,"#",s),e("#sub-drag-folder-popup").show(),!1}"#"!=o.node.parent&&jQuery("#js-tree-menu").jstree("open_node",o.node.parent),folderMoveId=o.node.id,orderString="",e(".folder-modal .jstree-node[id='"+folderMoveId+"']").closest("ul").children().each(function(){"undefined"!=e(this).attr("id")&&(orderString+=e(this).attr("id")+",")}),e(".folder-modal #"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?parentID=e("#"+folderMoveId+"_anchor").closest(".jstree-node").parent().parent().attr("id"):parentID=0,""!=orderString&&(e(".form-loader-count").css("width","100%"),e.ajax({url:folders_media_options.ajax_url,data:"term_ids="+orderString+"&action=wcp_save_folder_order&type="+folders_media_options.post_type+"&nonce="+folders_media_options.nonce+"&term_id="+folderMoveId+"&parent_id="+parentID,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#wcp_folder_parent").html(t.options),e(".form-loader-count").css("width","0"),L(),oe(),Z(),z()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))}),z()}function B(t){e(".folder-modal #js-tree-menu .jstree-anchor.jstree-clicked").length?(v=e(".folder-modal #js-tree-menu .jstree-anchor.jstree-clicked").closest(".jstree-node").attr("id"),e.ajax({url:folders_media_options.ajax_url,data:{post_id:t,action:"premio_check_for_other_folders",active_folder:v,type:folders_media_options.post_type,folder_id:-1,nonce:folders_media_options.nonce,status:folders_media_options.taxonomy_status,taxonomy:v},method:"post",success:function(t){-1==(t=e.parseJSON(t)).status?(e("#unassigned_folders").val(t.data.post_id),e("#confirm-your-change").show()):(L(),M())}})):(f=folders_media_options.nonce,e.ajax({url:folders_media_options.ajax_url,data:"post_id="+t+"&type="+folders_media_options.post_type+"&action=wcp_remove_post_folder&folder_id="+-1+"&nonce="+f+"&status="+folders_media_options.taxonomy_status+"&taxonomy="+v,method:"post",success:function(e){L(),M()}}))}function E(e,t){if(d.length>0)for(i=0;i<d.length;i++)if(parseInt(d[i].folder_id)==parseInt(e))return d[i][t];return""}function R(e){if(d.length>0)for(i=0;i<d.length;i++)if(parseInt(d[i].folder_id)==parseInt(e))return i;return null}function q(){e(".sticky-folders > ul").html("");var t="";if(e("#js-tree-menu li.jstree-node.is-sticky").each(function(){var o=e(this).attr("id"),a=e.trim(e("#js-tree-menu").jstree(!0).get_node(o).text),s=(e("#"+o+"_anchor .premio-folder-count").text(),e("li.jstree-node[id='"+o+"']").hasClass("is-high")?" is-high ":"");t+="<li data-folder-id='"+o+"' class='sticky-fldr "+s+" sticky-folder-"+o+"'><a href='javascript:;'><span class='folder-title'>"+a+"</span><span class='folder-actions'><span class='update-inline-record'><i class='pfolder-edit-folder'></i></span><span class='star-icon'><i class='pfolder-star'></i></span><span class='premio-folder-count'></span></span></a></li>"}),e(".sticky-folders > ul").html(t),e(".jstree-anchor.jstree-clicked").length){var o=e(".jstree-anchor.jstree-clicked").closest("li.jstree-node").attr("id");e(".sticky-folders .sticky-folder-"+o+" a").addClass("active-item")}e(".sticky-folders > ul > li").length>0?e(".sticky-folders").addClass("active"):e(".sticky-folders").removeClass("active"),X()}function X(){var t=0;if(e("#custom-scroll-menu").hasClass("mCustomScrollbar")){var o=jQuery("#custom-scroll-menu"),a=o.find(".mCSB_dragger"),s=o.find(".mCSB_container").height();t=a.position().top/(o.height()-a.height())*(s-o.height()),e("#custom-scroll-menu").mCustomScrollbar("destroy")}var r=jQuery(".folder-modal .media-modal-content").height()-e(".folder-modal .sticky-wcp-custom-form").height()-40;e(".folder-modal #custom-scroll-menu").closest(".media-frame-menu").length&&jQuery(".folder-custom-menu").length&&jQuery(".media-frame-menu").length&&(r=jQuery(".folder-modal .media-modal-content").height()-e(".folder-modal .sticky-wcp-custom-form").height()-jQuery(".folder-custom-menu").offset().top+jQuery(".media-frame-menu").offset().top-40),r<0&&(r=350),e("#custom-scroll-menu").mCustomScrollbar({axis:"y",scrollButtons:{enable:!0},setHeight:r,theme:"3d",scrollbarPosition:"inside",scrollInertia:500,mouseWheelPixels:60}),0!=t&&jQuery("#custom-scroll-menu").mCustomScrollbar("scrollTo",t+"px",{scrollInertia:0})}function L(){if(e(".media-toolbar").hasClass("media-toolbar-mode-select")&&e("ul.attachments li.selected").length&&(e("ul.attachments li.selected").trigger("click"),e(".select-mode-toggle-button").trigger("click")),""!=g&&(e("#js-tree-menu a.jstree-clicked").length>0||"-1"==v)){if(e("#media-attachment-taxonomy-filter").length){g=g.split(",");for(var t=0;t<g.length;t++)""!=g[t]&&e(".attachments-browser li[data-id='"+g[t]+"']").remove()}g=""}e("#media-attachment-taxonomy-filter").length?te(0):(e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=get_folders_default_list",method:"post",success:function(t){t=e.parseJSON(t),e(".header-posts .total-count").text(t.total_items),e(".un-categorised-items .total-count").text(t.empty_items),C=t.taxonomies,Z(),z()}}),e(".folder-loader-ajax").addClass("active"),e("#folder-posts-filter").length?e("#folder-posts-filter").load(h+" #posts-filter",function(){var t={Title:"",Url:h};history.pushState(t,t.Title,t.Url),"show"!=folders_media_options.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>'),triggerInlineUpdate()}):e("#wpbody").load(h+" #wpbody-content",!1,function(t){var o={Title:"",Url:h};history.pushState(o,o.Title,o.Url),"show"!=folders_media_options.show_in_page||e(".tree-structure").length||e(".wp-header-end").before('<div class="tree-structure-content"><div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div></div>')}))}function Z(){if(e("#media-attachment-taxonomy-filter").length&&(e("#media-attachment-taxonomy-filter").each(function(){folders_media_options.terms=C;var t=e(this);currentDDVal=e(this).val(),t.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>"),C;for(var o=0;o<C.length;o++)t.append("<option value='"+C[o].term_id+"'>"+C[o].name+" ("+C[o].trash_count+")</option>");t.val(currentDDVal).trigger("change")}),e("select.folder_for_media").length)){var t=e("select.folder_for_media").val();e("select.folder_for_media option:not(:first-child):not(:last-child)").remove();for(var o=0;o<C.length;o++)e("select.folder_for_media option:last-child").before("<option value='"+C[o].term_id+"'>"+C[o].name+"</option>");""!=t&&e(".folder_for_media").val(t)}for(e("span.premio-folder-count").text(""),e(".folder-count").text(""),o=0;o<C.length;o++)0!=parseInt(C[o].trash_count)&&(e(".jstree-node[id='"+C[o].term_id+"'] > a.jstree-anchor span.premio-folder-count").text(C[o].trash_count),e(".sticky-folder-"+C[o].term_id+" .premio-folder-count").text(C[o].trash_count));""!=v&&e("#wcp_folder_"+v).addClass("active-item"),j&&(e("#title_"+c).trigger("click"),j=!1)}function K(){var t=e.trim(e("#folder-search").val());e("#js-tree-menu").jstree("search",t)}function W(t){var o="Are you sure you want to delete the selected folder?",a="Items in the folder will not be deleted.";if(y=!1,1==t&&e("#menu-checkbox").is(":checked")){if(y=!0,0==e("#js-tree-menu input.checkbox:checked").length)return e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html("Please select at least one folder to delete"),void e("#error-folder-popup").show();e("#js-tree-menu input.checkbox:checked").length>1&&(o="Are you sure you want to delete the selected folders?",a="Items in the selected folders will not be deleted.")}e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#remove-folder-item").text("Yes, Delete it!"),e("#remove-folder-message").text(o),e("#remove-folder-notice").text(a),e("#confirm-remove-folder").show(),e("#remove-folder-item").focus()}function G(){folderName=e.trim(e("#js-tree-menu").jstree(!0).get_node(c).text),parentID=e("#wcp_folder_"+c).closest("li.jstree-node").data("folder-id"),parentID==t&&(parentID=0),e("#update-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#update-folder-item-name").val(folderName),e("#update-folder-item").removeClass("disabled"),e("#update-folder-item").show(),e("#update-folder-item-name").focus(),e(".dynamic-menu").remove()}function $(){if(0==u&&p>=10)return e("#folder-limitation-message").html("You've reached the 10 folder limitation!"),e("#no-more-folder-credit").show(),!1;e("#add-update-folder-title").text("Add new folder"),e("#save-folder-data").text("Submit"),e(".folder-form-errors").removeClass("active"),e("#add-update-folder-name").val(""),k&&(w=c,e("#add-update-folder-name").val(e.trim(e("#js-tree-menu").jstree(!0).get_node(c).text)+" #2"),c=e("#"+c+"_anchor").closest(".jstree-node").parent().parent().hasClass("jstree-node")?e("#"+c+"_anchor").closest(".jstree-node").parent().parent().attr("id"):0),e("#add-update-folder").removeClass("disabled"),e("#add-update-folder").show(),e("#add-update-folder-name").focus(),e(".dynamic-menu").remove()}function ee(){setTimeout(function(){if(e("#js-tree-menu .jstree-node.jstree-leaf").length==e("#js-tree-menu .jstree-node").length)e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand");else{var t=e("#js-tree-menu .jstree-node.jstree-closed").length+e("#js-tree-menu .jstree-node.jstree-open").length;e("#js-tree-menu .jstree-node.jstree-closed").length==t?(e("#expand-collapse-list").removeClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Expand")):(e("#expand-collapse-list").addClass("all-open"),e("#expand-collapse-list").attr("data-folder-tooltip","Collapse"))}},500),z()}function te(o){F=e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_get_default_list&active_id="+v,method:"post",beforeSend:function(){null!=F&&F.abort()},success:function(a){if(a=e.parseJSON(a),e(".header-posts .total-count").text(a.total_items),e(".un-categorised-items .total-count").text(a.empty_items),selectedVal=e("#media-attachment-taxonomy-filter").val(),"all"!=selectedVal&&1==o){var s=parent.wp;s.media!=t&&(s.media.frame.setState("insert"),null!==s.media.frame.content.get()&&void 0!==s.media.frame.content.get().collection?(s.media.frame.content.get().collection.props.set({ignore:+new Date}),s.media.frame.content.get().options.selection.reset()):s.media.frame.library.props.set({ignore:+new Date}))}C=a.taxonomies,Z(),z()}})}function oe(){e(".folder-loader-ajax").addClass("active"),e(".folder-loader-ajax img").removeClass("active"),e(".folder-loader-ajax svg#successAnimation").addClass("active").addClass("animated"),setTimeout(function(){e(".folder-loader-ajax").removeClass("active"),e(".folder-loader-ajax img").addClass("active"),e(".folder-loader-ajax svg#successAnimation").removeClass("active").removeClass("animated")},2e3),z()}e(document).ready(function(){e(document).on("click",".folder-settings-btn > a",function(t){t.stopPropagation(),e(".folder-settings-btn").toggleClass("active")}),e(document).on("click","body,html",function(){e(".folder-settings-btn").removeClass("active")}),e(document).on("click",".folder-setting-menu",function(e){e.stopPropagation()}),e(document).on("click","#remove-from-all-folders:not(.disabled), #remove-from-current-folder:not(.disabled)",function(){e("#remove-from-all-folders, #remove-from-current-folder").addClass("disabled");var t="all";e(this).hasClass("remove-from-current-folder")&&(t="current"),e("#confirm-your-change").hide(),e.ajax({url:folders_media_options.ajax_url,data:{post_id:e("#unassigned_folders").val(),action:"wcp_remove_post_folder",active_folder:v,type:folders_media_options.post_type,folder_id:-1,nonce:folders_media_options.nonce,status:folders_media_options.taxonomy_status,taxonomy:v,remove_from:t},method:"post",success:function(t){e("#remove-from-all-folders, #remove-from-current-folder").removeClass("disabled"),oe(),L(),M()}})}),o=parseInt(folders_media_options.hasStars),a=parseInt(folders_media_options.hasChildren),e(document).on("click",".thumbnail-hover-box a",function(t){return t.stopPropagation(),t.stopImmediatePropagation(),t.preventDefault(),window.open(e(this).prop("href"),"_blank"),!1}),e(document).ajaxComplete(function(e,o,a){if(a.data!=t&&""!=a.data&&-1!=a.data.indexOf("action=query-attachments")&&z(),s.length>0)for(var r=0;r<s.length;r++)if(jQuery(".folder-modal ul.attachments li[data-id='"+s[r]+"']").length&&!jQuery(".folder-modal ul.attachments li[data-id='"+s[r]+"']").hasClass("selected")){var d=jQuery.Event("click");d.ctrlKey=!0,jQuery(".folder-modal ul.attachments li[data-id='"+s[r]+"']").trigger(d)}}),C=folders_media_options.terms,u=parseInt(folders_media_options.is_key_active),p=parseInt(folders_media_options.folders),d=folders_media_options.folder_settings,e(document).on("click",".header-posts a.all-posts",function(t){c=0,v="",l="all",e(".active-item").removeClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e(this).addClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(this).closest(".media-frame").find("#media-attachment-taxonomy-filter").val("all").trigger("change"),e(this).closest(".media-frame").find(".folder_for_media").val("all").trigger("change"),V()}),e(document).on("click",".un-categorised-items",function(t){c=0,v="",l="unassigned",e(".active-item").removeClass("active-item"),e(".sticky-folders .active-item").removeClass("active-item"),e(".jstree-clicked").removeClass("jstree-clicked"),e(this).addClass("active-item"),e(this).closest(".media-frame").find("#media-attachment-taxonomy-filter").val("unassigned").trigger("change"),e(this).closest(".media-frame").find(".folder_for_media").val("-1").trigger("change"),V()}),e(document).on("click","a.jstree-anchor",function(t){var o,a=e(this).closest("li.jstree-node").attr("id");l=c=a,e(this).closest(".folder-modal").find(".active-item").removeClass("active-item"),e(this).closest(".folder-modal").find("#media-attachment-taxonomy-filter").val(a),e(this).closest(".folder-modal").find("#media-attachment-taxonomy-filter").trigger("change"),thisSlug=E(a,"slug"),o=thisSlug,e.ajax({url:folders_media_options.ajax_url,type:"post",data:"action=save_folder_last_status&post_type="+folders_media_options.post_type+"&post_id="+o+"&nonce="+folders_media_options.nonce,cache:!1,async:!1,success:function(){}}),e(".custom-media-select").removeClass("active"),V()}),e(document).on("change",".folder_for_media",function(){"add-folder"!=e(this).val()&&null!=e(this).val()?l=e(this).val():"add-folder"==e(this).val()&&(l=-1)}),e(document).on("click",".new-folder-pro",function(t){t.preventDefault(),e(".dynamic-menu").remove(),e("#sub-folder-popup").show()}),e(document).on("click",".close-popup-button a",function(){e(".folder-popup-form").hide()}),e(document).on("click",".update-inline-record",function(s){var r;(s.stopImmediatePropagation(),s.stopPropagation(),0!=folders_media_options.can_manage_folder)&&(isHigh=e(this).closest("li.sticky-fldr").hasClass("is-high"),isSticky=e(this).closest("li.sticky-fldr").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu' data-id='"+e(this).closest("li").data("folder-id")+"'><ul>",menuHtml+="<li class='new-main-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>",menuHtml+=a?"<li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>":"<li class='new-folder-pro'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Sub-folder (Pro)</a></li>",menuHtml+="<li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span>Rename</a></li><li class='default-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-active-icon'></i></span>Open this folder by default (Pro)</a></li><li class='sticky-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li>",menuHtml+=o?"<li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star":"Add a Star")+"</a></li>":"<li class='mark-folder-pro'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star (Pro)":"Add a Star (Pro)")+"</a></li>",menuHtml+="<li class='lock-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='dashicons dashicons-lock'></span>Lock Folder (Pro)</a></li><li class='duplicate-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-clone'></i></span>Duplicate folder (Pro)</a></li>",hasPosts=parseInt(e(this).closest("li.jstree-node").find("h3.title:first > .total-count").text()),"attachment"==folders_media_options.post_type&&hasPosts&&(menuHtml+="<li class='download-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span>Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span>Delete</a></li></ul></div>",e("body").append(menuHtml),s.pageX==t||s.pageY==t?(e(".dynamic-menu").css("left",S),e(".dynamic-menu").css("top",I-10),r=I):(e(".dynamic-menu").css("left",s.pageX),e(".dynamic-menu").css("top",s.pageY),r=s.pageY),r+e(".dynamic-menu").height()>e(window).height()&&e(".dynamic-menu").css("margin-top",e(window).height()-(r+e(".dynamic-menu").height())))}),e(document).on("click","body, html",function(t){e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),e(".folder-order").removeClass("active")}),e(document).on("click",".dynamic-menu, .folder-order",function(e){e.stopPropagation()}),e(document).on("contextmenu",".jstree-anchor",function(t){return S=t.pageX,I=t.pageY,e(this).find("span.folder-inline-edit").trigger("click"),!1}),e(document).on("click",".folder-actions span.folder-inline-edit",function(s){var r;(s.stopImmediatePropagation(),s.stopPropagation(),0!=folders_media_options.can_manage_folder)&&(isHigh=e(this).closest("li.jstree-node").hasClass("is-high"),isSticky=e(this).closest("li.jstree-node").hasClass("is-sticky"),isStickyClass=!!isSticky,e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),menuHtml="<div class='dynamic-menu' data-id='"+e(this).closest("li").prop("id")+"'><ul>",menuHtml+="<li class='new-main-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>",menuHtml+=a?"<li class='new-folder'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Folder</a></li>":"<li class='new-folder-pro'><a href='javascript:;'><span class=''><i class='pfolder-add-folder'></i></span>New Sub-folder (Pro)</a></li>",menuHtml+="<li class='rename-folder'><a href='javascript:;'><span class=''><i class='pfolder-edit'></i></span>Rename</a></li><li class='default-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-active-icon'></i></span>Open this folder by default (Pro)</a></li><li class='sticky-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='sticky-pin'><i class='pfolder-pin'></i></span>Sticky Folder (Pro)</a></li>",menuHtml+=o?"<li class='mark-folder'><a href='javascript:;'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star":"Add a Star")+"</a></li>":"<li class='mark-folder-pro'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-star'></i></span>"+(isHigh?"Remove Star (Pro)":"Add a Star (Pro)")+"</a></li>",menuHtml+="<li class='lock-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class='dashicons dashicons-lock'></span>Lock Folder (Pro)</a></li><li class='duplicate-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-clone'></i></span>Duplicate folder (Pro)</a></li>",hasPosts=parseInt(e(this).closest("a.jstree-anchor").find(".premio-folder-count").text()),"attachment"==folders_media_options.post_type&&hasPosts&&(menuHtml+="<li class='download-folder'><a target='_blank' href='"+folders_media_options.upgrade_url+"'><span class=''><i class='pfolder-zip-file'></i></span>Download Zip (Pro)</a></li>"),menuHtml+="<li class='remove-folder'><a href='javascript:;'><span class=''><i class='pfolder-remove'></i></span>Delete</a></li></ul></div>",e("body").append(menuHtml),e(this).parents("li.jstree-node").addClass("active-menu"),s.pageX==t||s.pageY==t?(e(".dynamic-menu").css("left",S),e(".dynamic-menu").css("top",I-10),r=I):(e(".dynamic-menu").css("left",s.pageX),e(".dynamic-menu").css("top",s.pageY),r=s.pageY),r+e(".dynamic-menu").height()>e(window).height()&&e(".dynamic-menu").css("margin-top",e(window).height()-(r+e(".dynamic-menu").height())))}),e(document).on("click",".dynamic-menu",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click","body, html",function(){e(".dynamic-menu").remove()}),e(document).on("click",".new-folder",function(t){t.stopPropagation(),c=e(this).closest(".dynamic-menu").data("id"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),j=!1,k=!1,$()}),e(document).on("click",".new-main-folder",function(){b=1,c=e(this).closest(".dynamic-menu").data("id"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),j=!1,k=!1,$()}),e(document).on("click","#add-new-folder",function(t){e("#js-tree-menu a.jstree-clicked").length?(c=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),a||e("#pro-notice").removeClass("hide-it")):(c=0,e("#pro-notice").addClass("hide-it")),j=!1,$()}),e(document).on("submit","#save-folder-form",function(t){if(t.stopPropagation(),t.preventDefault(),m=e("#add-update-folder-name").val(),""==e.trim(m))e(".folder-form-errors").addClass("active"),e("#add-update-folder-name").focus();else{e("#save-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#add-update-folder").addClass("disabled");var o=c;j&&(o=0),a||(o=0);var s="";0==o?(x=e("#js-tree-menu > ul > li.jstree-node").length,b&&(x=jQuery("#js-tree-menu > ul > li[id='"+c+"']").index(),jQuery("#js-tree-menu > ul > li").each(function(e){s+=jQuery(this).attr("id")+",",e==x&&(s+="#,")}),x+=1)):x=e("#js-tree-menu > ul > li.jstree-node[id='"+o+"'] > ul.jstree-children > li").length+1,e.ajax({url:folders_media_options.ajax_url,data:{parent_id:o,type:folders_media_options.post_type,action:"wcp_add_new_folder",nonce:folders_media_options.nonce,term_id:o,order:x,name:m,is_duplicate:k,duplicate_from:w,parent_ids:s,parent_menu:b},method:"post",success:function(t){if(result=e.parseJSON(t),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),-1==result.status)e("#no-more-folder-credit").show();else if("1"==result.status){if(u=parseInt(result.is_key_active),p=parseInt(result.folders),e("#current-folder").text(p),e("#ttl-fldr").text(10),ee(),result.data.length)for(var o=0;o<result.data.length;o++){var a={folder_id:result.data[o].term_id,folder_count:0,is_sticky:result.data[o].is_sticky,is_high:result.data[o].is_high,nonce:result.data[o].nonce,slug:result.data[o].slug,is_deleted:0};d.push(a),b?e("#js-tree-menu").jstree().create_node("#",{id:result.data[o].term_id,text:" "+result.data[o].title},x,function(){e(".jstree-node[id='"+result.data[o].term_id+"']").attr("data-nonce",result.data[o].nonce),e(".jstree-node[id='"+result.data[o].term_id+"']").attr("data-slug",result.data[o].slug)}):e("#js-tree-menu").jstree().create_node(result.parent_id,{id:result.data[o].term_id,text:" "+result.data[o].title},"last",function(){e(".jstree-node[id='"+result.data[o].term_id+"']").attr("data-nonce",result.data[o].nonce),e(".jstree-node[id='"+result.data[o].term_id+"']").attr("data-slug",result.data[o].slug)}),b=0}oe(),q(),c=result.term_id,te(0)}else e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show()}})}return!1}),e(document).on("click",".form-cancel-btn",function(){e(".folder-popup-form").hide()}),e(document).on("click",".folder-popup-form",function(t){e(".folder-popup-form").hide()}),e(document).on("click",".popup-form-content",function(e){e.stopPropagation()}),document.onkeydown=function(t){("key"in(t=t||window.event)?"Escape"===t.key||"Esc"===t.key:27===t.keyCode)&&e(".folder-popup-form").hide()},e(document).on("click",".rename-folder",function(t){t.stopPropagation(),c=e(this).closest(".dynamic-menu").data("id"),G(),e(".dynamic-menu").remove()}),e(document).on("click","#inline-update",function(t){e("#js-tree-menu a.jstree-clicked").length&&(c=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),G())}),e(document).on("submit","#update-folder-form",function(o){return o.stopPropagation(),o.preventDefault(),m=e("#update-folder-item-name").val(),""==e.trim(m)?(e(".folder-form-errors").addClass("active"),e("#update-folder-item-name").focus()):(e("#update-folder-data").html('<span class="dashicons dashicons-update"></span>'),e("#update-folder-item").addClass("disabled"),f=E(c,"nonce"),parentID=e(".jstree-node[id='"+c+"']").closest("li.jstree-node").attr("id"),parentID==t&&(parentID=0),e.ajax({url:folders_media_options.ajax_url,data:{parent_id:parentID,type:folders_media_options.post_type,action:"wcp_update_folder",nonce:f,term_id:c,order:x,name:m},method:"post",success:function(t){result=e.parseJSON(t),"1"==result.status?(e("#js-tree-menu").jstree("rename_node",result.id," "+result.term_title),folderPostId=R(result.id),null!=folderPostId&&(d[folderPostId].nonce=result.nonce,d[folderPostId].slug=result.slug),e(".folder-popup-form").hide(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),oe(),e("#media-attachment-taxonomy-filter").length&&te(0)):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(result.message),e("#error-folder-popup").show())}})),!1}),e(document).on("click",".mark-folder",function(t){t.stopPropagation(),n=e(this).closest(".dynamic-menu").data("id"),f=E(n,"nonce"),e(".form-loader-count").css("width","100%"),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu"),e.ajax({url:folders_media_options.ajax_url,data:"term_id="+n+"&type="+folders_media_options.post_type+"&action=wcp_mark_un_mark_folder&nonce="+f,method:"post",cache:!1,success:function(t){t=e.parseJSON(t),e(".form-loader-count").css("width","0%"),"1"==t.status?(folderPostId=R(t.id),"1"==t.marked?(e("li.jstree-node[id='"+t.id+"']").addClass("is-high"),e(".sticky-folder-"+t.id).addClass("is-high"),null!=folderPostId&&(d[folderPostId].is_high=1)):(e("li.jstree-node[id='"+t.id+"']").removeClass("is-high"),e(".sticky-folder-"+t.id).removeClass("is-high"),null!=folderPostId&&(d[folderPostId].is_high=0)),oe()):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})}),e(document).on("click",".duplicate-folder",function(t){t.stopPropagation(),c=e(this).closest(".dynamic-menu").data("id"),e(".dynamic-menu").remove(),j=!1,k=!0,$()}),e(document).on("click",".remove-folder",function(){n=e(this).closest(".dynamic-menu").data("id"),c=e(this).closest(".dynamic-menu").data("id"),W(0),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")}),e(document).on("click","#remove-folder-item",function(t){t.stopPropagation(),e(".folder-popup-form").addClass("disabled"),e("#remove-folder-item").html('<span class="dashicons dashicons-update"></span>'),f=E(c,"nonce"),y?function(){if(e("#menu-checkbox").is(":checked")&&e("#js-tree-menu input.checkbox:checked").length>0){var t="";e("#js-tree-menu input.checkbox:checked").each(function(){t+=e(this).closest("li.jstree-node").attr("id")+",",e(this).closest("li.jstree-node").hasClass("jstree-clicked")&&!0}),e(".form-loader-count").css("width","100%"),e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_remove_muliple_folder&term_id="+t+"&nonce="+folders_media_options.nonce,method:"post",success:function(t){if(t=e.parseJSON(t),e(".form-loader-count").css("width","0px"),"1"==t.status){for(u=parseInt(t.is_key_active),p=parseInt(t.folders),e("#current-folder").text(p),i=0;i<t.term_ids.length;i++)e(".folder-modal #js-tree-menu").jstree().delete_node(t.term_ids[i]);e("#ttl-fldr").text(10),oe(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),L(),q(),oe(),e(".folder-modal #wcp_folder_"+v).length||(e(".header-posts a").trigger("click"),v=0)}else window.location.reload();e("#menu-checkbox").attr("checked",!1),e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox")}})}}():e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_remove_folder&term_id="+c+"&nonce="+f,method:"post",success:function(t){"1"==(t=e.parseJSON(t)).status?(e("#js-tree-menu").jstree().delete_node(c),u=parseInt(t.is_key_active),p=parseInt(t.folders),e("#current-folder").text(p),e("#ttl-fldr").text(10),e(".sticky-folders .sticky-folder-"+c).remove(),oe(),e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),L(),q(),v==c&&e(".header-posts").trigger("click")):(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show())}})}),e(document).on("click","#sort-order-list",function(t){t.stopPropagation(),e(".folder-order").toggleClass("active")}),e(document).on("click","#expand-collapse-list",function(t){t.stopPropagation();var o=0;e(this).hasClass("all-open")?(e(this).removeClass("all-open"),o=0,e(this).attr("data-folder-tooltip","Expand"),e("#js-tree-menu").jstree("close_all")):(e(this).addClass("all-open"),o=1,e(this).attr("data-folder-tooltip","Collapse"),e("#js-tree-menu").jstree("open_all")),g="",e("#js-tree-menu .jstree-node:not(.jstree-leaf)").each(function(){g+=e(this).attr("id")+","}),""!=g&&(e(".form-loader-count").css("width","100%"),f=folders_media_options.nonce,e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_change_all_status&status="+o+"&folders="+g+"&nonce="+f,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=e.parseJSON(t)).status&&(e(".folder-popup-form").hide(),e(".folder-popup-form").removeClass("disabled"),e("#error-folder-popup-message").html(t.message),e("#error-folder-popup").show(),window.location.reload(!0))}}))}),e(document).on("click",".folder-sort-menu a:not(.pro-feature)",function(t){t.stopPropagation(),t.preventDefault(),e(".form-loader-count").css("width","100%"),e(".folder-order").removeClass("active"),e(this).attr("data-sort"),e.ajax({url:folders_media_options.ajax_url,data:"type="+folders_media_options.post_type+"&action=wcp_folders_by_order&nonce="+folders_media_options.nonce+"&order="+e(this).attr("data-sort"),method:"post",success:function(t){1==(t=e.parseJSON(t)).status&&(e("#js-tree-menu").jstree().destroy(),e("#js-tree-menu").append("<ul></ul>"),e("#js-tree-menu ul").html(t.data),C=t.terms,Z(),Y()),e(".form-loader-count").css("width","0")}})}),e(document).on("change","#media-attachment-taxonomy-filter",function(t){e("#js-tree-menu").hasClass("jstree")&&e("#js-tree-menu").jstree(!0).deselect_all(),e(".active-item").removeClass("active-item"),"all"==e(this).val()?e(".all-posts").addClass("active-item"):"unassigned"==e(this).val()?e(".un-categorised-items").addClass("active-item"):e("#js-tree-menu").jstree("select_node",e(this).val())}),e(document).on("click",".jstree-node .jstree-icon",function(){n=e(this).closest("li.jstree-node").attr("id"),e("li.jstree-node[id='"+n+"']").hasClass("jstree-open")?folderStatus=1:folderStatus=0,e(".form-loader-count").css("width","100%"),f=E(n,"nonce"),ee(),e.ajax({url:folders_media_options.ajax_url,data:"is_active="+folderStatus+"&action=save_wcp_folder_state&term_id="+n+"&nonce="+f,method:"post",success:function(t){e(".form-loader-count").css("width","0"),"0"==(t=e.parseJSON(t)).status||(e("#wcp_folder_"+n).hasClass("active")?(e("#wcp_folder_"+n).removeClass("active"),e("#wcp_folder_"+n).find("ul.ui-sortable:first-child > li").slideUp(),folderStatus=0):(e("#wcp_folder_"+n).addClass("active"),e("#wcp_folder_"+n).find("ul.ui-sortable:first-child > li").slideDown(),folderStatus=1),oe())}})}),e(document).on("keyup","#folder-search",function(){K()}),e(document).on("change","#folder-search",function(){K()}),e(document).on("blur","#folder-search",function(){K()}),e(document).on("click","#do_not_show_again",function(){var t=e(this).is(":checked")?1:0;e.ajax({url:folders_media_options.ajax_url,type:"post",data:{action:"premio_hide_child_popup",status:t,nonce:folders_media_options.nonce,post_type:folders_media_options.post_type}})}),e(document).on("click","#menu-checkbox",function(){e(this).is(":checked")?(e("#js-tree-menu").addClass("show-folder-checkbox"),e("#menu-checkbox").prop("checked",!0)):(e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox"),e("#menu-checkbox").prop("checked",!1))}),e(document).on("click","#menu-checkbox",function(){e(this).is(":checked")?(e("#menu-checkbox").prop("checked",!0),e("#js-tree-menu").addClass("show-folder-checkbox")):(e("#menu-checkbox").prop("checked",!1),e("#js-tree-menu input.checkbox").attr("checked",!1),e("#js-tree-menu").removeClass("show-folder-checkbox"))}),e(document).on("click",".folder-checkbox, .input-checkbox",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),e(document).on("click","#inline-remove, .delete-folder-action:not(.disabled)",function(){e("#js-tree-menu a.jstree-clicked").length?(c=e("#js-tree-menu a.jstree-clicked").closest("li.jstree-node").attr("id"),W(1),e(".dynamic-menu").remove(),e(".active-menu").removeClass("active-menu")):e("#menu-checkbox").is(":checked")&&(e(".dynamic-menu").remove(),W(1))}),e(document).on("change",".folder_for_media",function(){"add-folder"==e(this).val()&&(j=!0,e("#add-new-folder").trigger("click"))}),e(document).on("click","#js-tree-menu input.checkbox",function(){V()}),z(),e(document).on("click",".undo-button, .undo-folder-action:not(.disabled)",function(){e("#do-undo").removeClass("active"),"yes"==folders_media_options.useFolderUndo&&e.ajax({url:folders_media_options.ajax_url,type:"post",data:{post_type:folders_media_options.post_type,nonce:folders_media_options.nonce,action:"wcp_undo_folder_changes"},success:function(o){if(e("#undo-done").addClass("active"),setTimeout(function(){e("#undo-done").removeClass("active")},2500),e("#media-attachment-taxonomy-filter").length){var a=parent.wp;a.media!=t&&(a.media.frame.setState("insert"),null!==a.media.frame.content.get()&&void 0!==a.media.frame.content.get().collection?(a.media.frame.content.get().collection.props.set({ignore:+new Date}),a.media.frame.content.get().options.selection.reset()):a.media.frame.library.props.set({ignore:+new Date}))}L()}})}),e(document).on("click",".close-undo-box",function(t){t.preventDefault(),e("#do-undo").removeClass("active")})})});
|
folders.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Folders
|
4 |
-
* Description:
|
5 |
-
* Version: 2.7
|
6 |
* Author: Premio
|
7 |
* Author URI: https://premio.io/downloads/folders/
|
8 |
* Text Domain: folders
|
@@ -24,7 +24,7 @@ if(!defined("WCP_FOLDER_URL")) {
|
|
24 |
define('WCP_FOLDER_URL', plugin_dir_url(__FILE__));
|
25 |
}
|
26 |
if(!defined("WCP_FOLDER_VERSION")) {
|
27 |
-
define('WCP_FOLDER_VERSION', "2.7");
|
28 |
}
|
29 |
|
30 |
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Folders
|
4 |
+
* Description: Organize your Media library, Pages, and Posts into folders. You can easily drag and drop items into directories and change the folders tree view.
|
5 |
+
* Version: 2.7.1
|
6 |
* Author: Premio
|
7 |
* Author URI: https://premio.io/downloads/folders/
|
8 |
* Text Domain: folders
|
24 |
define('WCP_FOLDER_URL', plugin_dir_url(__FILE__));
|
25 |
}
|
26 |
if(!defined("WCP_FOLDER_VERSION")) {
|
27 |
+
define('WCP_FOLDER_VERSION', "2.7.1");
|
28 |
}
|
29 |
|
30 |
|
includes/folders.class.php
CHANGED
@@ -431,7 +431,7 @@ class WCP_Folders
|
|
431 |
}
|
432 |
}
|
433 |
foreach ($terms as $key=>$term ) {
|
434 |
-
if(isset($term->
|
435 |
$trash_count = null;
|
436 |
if(isset($trash_folders[$term->term_taxonomy_id])) {
|
437 |
$trash_count = $trash_folders[$term->term_taxonomy_id];
|
@@ -457,7 +457,7 @@ class WCP_Folders
|
|
457 |
}
|
458 |
|
459 |
if ($trash_count === null) {
|
460 |
-
|
461 |
$query = "SELECT COUNT(DISTINCT(p.ID))
|
462 |
FROM {$post_table} p
|
463 |
JOIN {$term_table} rl ON p.ID = rl.object_id
|
@@ -479,6 +479,7 @@ class WCP_Folders
|
|
479 |
}
|
480 |
|
481 |
if(!empty($terms) && $initial_trash_folders != $trash_folders) {
|
|
|
482 |
set_transient("premio_folders_without_trash", $trash_folders, 3*DAY_IN_SECONDS);
|
483 |
}
|
484 |
return $terms;
|
@@ -665,8 +666,8 @@ class WCP_Folders
|
|
665 |
$initial_trash_folders = array();
|
666 |
}
|
667 |
|
668 |
-
if(isset($trash_folders[$
|
669 |
-
unset($trash_folders[$
|
670 |
}
|
671 |
|
672 |
if($initial_trash_folders != $trash_folders) {
|
@@ -903,8 +904,8 @@ class WCP_Folders
|
|
903 |
);
|
904 |
if(!empty($terms) && count($terms)>0) {
|
905 |
foreach($terms as $term) {
|
906 |
-
if(isset($term->
|
907 |
-
unset($trash_folders[$term->
|
908 |
}
|
909 |
}
|
910 |
}
|
@@ -1447,8 +1448,9 @@ class WCP_Folders
|
|
1447 |
}
|
1448 |
|
1449 |
foreach($term_ids as $term_id) {
|
1450 |
-
|
1451 |
-
|
|
|
1452 |
}
|
1453 |
}
|
1454 |
|
@@ -1468,8 +1470,9 @@ class WCP_Folders
|
|
1468 |
}
|
1469 |
|
1470 |
foreach($term_ids as $term_id) {
|
1471 |
-
|
1472 |
-
|
|
|
1473 |
}
|
1474 |
}
|
1475 |
|
@@ -1974,8 +1977,8 @@ class WCP_Folders
|
|
1974 |
if(isset($postData['taxonomy'])) {
|
1975 |
$taxonomy = self::sanitize_options($postData['taxonomy']);
|
1976 |
}
|
|
|
1977 |
if (is_array($postArray)) {
|
1978 |
-
$post_type = self::get_custom_post_type($type);
|
1979 |
foreach ($postArray as $post) {
|
1980 |
$terms = get_the_terms($post, $post_type);
|
1981 |
$post_terms = array(
|
@@ -1983,16 +1986,16 @@ class WCP_Folders
|
|
1983 |
'terms' => $terms
|
1984 |
);
|
1985 |
foreach($post_terms as $term) {
|
1986 |
-
if(isset($trash_folders[$term->
|
1987 |
-
unset($trash_folders[$term->
|
1988 |
}
|
1989 |
}
|
1990 |
$folderUndoSettings[] = $post_terms;
|
1991 |
if (!empty($terms)) {
|
1992 |
foreach ($terms as $term) {
|
1993 |
if(!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
|
1994 |
-
if(isset($trash_folders[$term->
|
1995 |
-
unset($trash_folders[$term->
|
1996 |
}
|
1997 |
wp_remove_object_terms($post, $term->term_id, $post_type);
|
1998 |
}
|
@@ -2005,11 +2008,13 @@ class WCP_Folders
|
|
2005 |
delete_transient("folder_undo_settings");
|
2006 |
set_transient("folder_undo_settings", $folderUndoSettings, DAY_IN_SECONDS);
|
2007 |
|
2008 |
-
|
2009 |
-
|
|
|
2010 |
}
|
2011 |
|
2012 |
if($initial_trash_folders != $trash_folders) {
|
|
|
2013 |
set_transient("premio_folders_without_trash", $trash_folders, 3*DAY_IN_SECONDS);
|
2014 |
}
|
2015 |
}
|
@@ -2053,16 +2058,16 @@ class WCP_Folders
|
|
2053 |
if (!empty($terms)) {
|
2054 |
foreach ($terms as $term) {
|
2055 |
wp_remove_object_terms($item['post_id'], $term->term_id, $post_type);
|
2056 |
-
if(isset($trash_folders[$term->
|
2057 |
-
unset($trash_folders[$term->
|
2058 |
}
|
2059 |
}
|
2060 |
}
|
2061 |
if(!empty($item['terms']) && is_array($item['terms'])) {
|
2062 |
foreach($item['terms'] as $term) {
|
2063 |
wp_set_post_terms($item['post_id'], $term->term_id, $post_type, true);
|
2064 |
-
if(isset($trash_folders[$term->
|
2065 |
-
unset($trash_folders[$term->
|
2066 |
}
|
2067 |
}
|
2068 |
}
|
431 |
}
|
432 |
}
|
433 |
foreach ($terms as $key=>$term ) {
|
434 |
+
if(isset($term->term_taxonomy_id) && isset($term->taxonomy) && !empty($term->taxonomy) && in_array($term->taxonomy, $option_array)) {
|
435 |
$trash_count = null;
|
436 |
if(isset($trash_folders[$term->term_taxonomy_id])) {
|
437 |
$trash_count = $trash_folders[$term->term_taxonomy_id];
|
457 |
}
|
458 |
|
459 |
if ($trash_count === null) {
|
460 |
+
//$result = $wpdb->get_var("SELECT COUNT(*) FROM {$post_table} p JOIN {$term_table} rl ON p.ID = rl.object_id WHERE rl.term_taxonomy_id = '{$term->term_taxonomy_id}' AND p.post_status != 'trash' LIMIT 1");
|
461 |
$query = "SELECT COUNT(DISTINCT(p.ID))
|
462 |
FROM {$post_table} p
|
463 |
JOIN {$term_table} rl ON p.ID = rl.object_id
|
479 |
}
|
480 |
|
481 |
if(!empty($terms) && $initial_trash_folders != $trash_folders) {
|
482 |
+
delete_transient("premio_folders_without_trash");
|
483 |
set_transient("premio_folders_without_trash", $trash_folders, 3*DAY_IN_SECONDS);
|
484 |
}
|
485 |
return $terms;
|
666 |
$initial_trash_folders = array();
|
667 |
}
|
668 |
|
669 |
+
if(isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
|
670 |
+
unset($trash_folders[$term->term_taxonomy_id]);
|
671 |
}
|
672 |
|
673 |
if($initial_trash_folders != $trash_folders) {
|
904 |
);
|
905 |
if(!empty($terms) && count($terms)>0) {
|
906 |
foreach($terms as $term) {
|
907 |
+
if(isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
|
908 |
+
unset($trash_folders[$term->term_taxonomy_id]);
|
909 |
}
|
910 |
}
|
911 |
}
|
1448 |
}
|
1449 |
|
1450 |
foreach($term_ids as $term_id) {
|
1451 |
+
$term = get_term($term_id, $taxonomy);
|
1452 |
+
if(isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
|
1453 |
+
unset($trash_folders[$term->term_taxonomy_id]);
|
1454 |
}
|
1455 |
}
|
1456 |
|
1470 |
}
|
1471 |
|
1472 |
foreach($term_ids as $term_id) {
|
1473 |
+
$term = get_term($term_id, $taxonomy);
|
1474 |
+
if(isset($term->term_taxonomy_id) && isset($trash_folders[$term_id])) {
|
1475 |
+
unset($trash_folders[$term->term_taxonomy_id]);
|
1476 |
}
|
1477 |
}
|
1478 |
|
1977 |
if(isset($postData['taxonomy'])) {
|
1978 |
$taxonomy = self::sanitize_options($postData['taxonomy']);
|
1979 |
}
|
1980 |
+
$post_type = self::get_custom_post_type($type);
|
1981 |
if (is_array($postArray)) {
|
|
|
1982 |
foreach ($postArray as $post) {
|
1983 |
$terms = get_the_terms($post, $post_type);
|
1984 |
$post_terms = array(
|
1986 |
'terms' => $terms
|
1987 |
);
|
1988 |
foreach($post_terms as $term) {
|
1989 |
+
if(isset($trash_folders[$term->term_taxonomy_id])) {
|
1990 |
+
unset($trash_folders[$term->term_taxonomy_id]);
|
1991 |
}
|
1992 |
}
|
1993 |
$folderUndoSettings[] = $post_terms;
|
1994 |
if (!empty($terms)) {
|
1995 |
foreach ($terms as $term) {
|
1996 |
if(!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
|
1997 |
+
if(isset($trash_folders[$term->term_taxonomy_id])) {
|
1998 |
+
unset($trash_folders[$term->term_taxonomy_id]);
|
1999 |
}
|
2000 |
wp_remove_object_terms($post, $term->term_id, $post_type);
|
2001 |
}
|
2008 |
delete_transient("folder_undo_settings");
|
2009 |
set_transient("folder_undo_settings", $folderUndoSettings, DAY_IN_SECONDS);
|
2010 |
|
2011 |
+
$term = get_term($folderID, $post_type);
|
2012 |
+
if(isset($term->term_taxonomy_id) && isset($trash_folders[$folderID])) {
|
2013 |
+
unset($trash_folders[$term->term_taxonomy_id]);
|
2014 |
}
|
2015 |
|
2016 |
if($initial_trash_folders != $trash_folders) {
|
2017 |
+
delete_transient("premio_folders_without_trash");
|
2018 |
set_transient("premio_folders_without_trash", $trash_folders, 3*DAY_IN_SECONDS);
|
2019 |
}
|
2020 |
}
|
2058 |
if (!empty($terms)) {
|
2059 |
foreach ($terms as $term) {
|
2060 |
wp_remove_object_terms($item['post_id'], $term->term_id, $post_type);
|
2061 |
+
if(isset($trash_folders[$term->term_taxonomy_id])) {
|
2062 |
+
unset($trash_folders[$term->term_taxonomy_id]);
|
2063 |
}
|
2064 |
}
|
2065 |
}
|
2066 |
if(!empty($item['terms']) && is_array($item['terms'])) {
|
2067 |
foreach($item['terms'] as $term) {
|
2068 |
wp_set_post_terms($item['post_id'], $term->term_id, $post_type, true);
|
2069 |
+
if(isset($trash_folders[$term->term_taxonomy_id])) {
|
2070 |
+
unset($trash_folders[$term->term_taxonomy_id]);
|
2071 |
}
|
2072 |
}
|
2073 |
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: galdub, tomeraharon, premio
|
3 |
Tags: folder, folders, replace media, pages folders, media library, posts folders, media folders, media replace, file manager, directories, media library folders, media library folder
|
4 |
Requires at least: 3.0.0
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag: 2.7
|
7 |
Plugin URI: https://premio.io/downloads/folders/
|
8 |
|
9 |
Folders is a WordPress plugin that will help you quickly create unlimited folders and organize and manage your Media Library files, Pages & Posts in folders
|
@@ -28,7 +28,7 @@ There are several ways professionals are using the Folders file manager plugin t
|
|
28 |
* Media replace: replace media files with other files. Whenever you replace media, the change will reflect throughout your website on all your pages, posts, etc.
|
29 |
|
30 |
|
31 |
-
<strong>Note:</strong> adding a page/post/image into a folder will not change its URL.
|
32 |
|
33 |
= Live Demo =
|
34 |
A live demo for the Folders plugin is available at <a href="https://demo.premio.io/folders/?utm_source=wordpressorg" target="_blank" title="Premio.io demo site">Premio's demo site</a>.
|
@@ -196,6 +196,9 @@ A live demo for the Folders plugin is available at <a href="https://demo.premio.
|
|
196 |
|
197 |
== Changelog ==
|
198 |
|
|
|
|
|
|
|
199 |
= 2.7 =
|
200 |
UI & performance improvements. We've also fixed some bugs
|
201 |
|
2 |
Contributors: galdub, tomeraharon, premio
|
3 |
Tags: folder, folders, replace media, pages folders, media library, posts folders, media folders, media replace, file manager, directories, media library folders, media library folder
|
4 |
Requires at least: 3.0.0
|
5 |
+
Tested up to: 5.8
|
6 |
+
Stable tag: 2.7.1
|
7 |
Plugin URI: https://premio.io/downloads/folders/
|
8 |
|
9 |
Folders is a WordPress plugin that will help you quickly create unlimited folders and organize and manage your Media Library files, Pages & Posts in folders
|
28 |
* Media replace: replace media files with other files. Whenever you replace media, the change will reflect throughout your website on all your pages, posts, etc.
|
29 |
|
30 |
|
31 |
+
<strong>Note:</strong> adding a page/post/image into a folder will not change its URL. Folders plugin creates virtual folders, it doesn't create actual folders in your server or WordPress installation.
|
32 |
|
33 |
= Live Demo =
|
34 |
A live demo for the Folders plugin is available at <a href="https://demo.premio.io/folders/?utm_source=wordpressorg" target="_blank" title="Premio.io demo site">Premio's demo site</a>.
|
196 |
|
197 |
== Changelog ==
|
198 |
|
199 |
+
= 2.7.1 =
|
200 |
+
WordPress 5.8 compatibility
|
201 |
+
|
202 |
= 2.7 =
|
203 |
UI & performance improvements. We've also fixed some bugs
|
204 |
|