Version Description
Folders is much faster and smoother now. We've also fixed a media library resolution bug for Mac+Safari
Download this release
Release Info
Developer | galdub |
Plugin | Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager |
Version | 2.2.5 |
Comparing to | |
See all releases |
Code changes from version 2.2.4 to 2.2.5
- assets/css/design.css +12 -1
- assets/js/custom.js +249 -101
- assets/js/media.js +32 -1
- folders.php +2 -2
- includes/folders.class.php +102 -20
- includes/form.class.php +7 -1
- readme.txt +4 -1
assets/css/design.css
CHANGED
@@ -1053,7 +1053,18 @@ span.media-info-message.active {
|
|
1053 |
display: block;
|
1054 |
}
|
1055 |
|
1056 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1057 |
@media screen and (max-width: 1300px) {
|
1058 |
.tree-structure li {
|
1059 |
width: 20%;
|
1053 |
display: block;
|
1054 |
}
|
1055 |
|
1056 |
+
.sticky-menu #adminmenuwrap {
|
1057 |
+
position: relative !important;
|
1058 |
+
}
|
1059 |
+
span.folder-loader-ajax {
|
1060 |
+
float: right;
|
1061 |
+
margin: 0px 8px 0 0;
|
1062 |
+
line-height: 30px;
|
1063 |
+
display:none;
|
1064 |
+
}
|
1065 |
+
.folder-loader-ajax.active {
|
1066 |
+
display: inline-block;
|
1067 |
+
}
|
1068 |
@media screen and (max-width: 1300px) {
|
1069 |
.tree-structure li {
|
1070 |
width: 20%;
|
assets/js/custom.js
CHANGED
@@ -9,11 +9,14 @@ var folderLimitation = 10;
|
|
9 |
var nonce = "";
|
10 |
var folderId = 0;
|
11 |
var fID = 0;
|
|
|
|
|
|
|
12 |
|
13 |
var listFolderString = "<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'>" +
|
14 |
"<div class='folder-item is-folder' data-id='__folder_id__'>" +
|
15 |
"<a title='__folder_name__' id='folder_view___folder_id__'" +
|
16 |
-
"class='folder-view __append_class__'" +
|
17 |
"data-id='__folder_id__'>" +
|
18 |
"<span class='folder item-name'><span id='wcp_folder_text___folder_id__'" +
|
19 |
"class='folder-title'>__folder_name__</span></span>" +
|
@@ -63,6 +66,9 @@ jQuery(document).ready(function(){
|
|
63 |
add_menu_to_list();
|
64 |
jQuery(".folder-popup-form").hide();
|
65 |
jQuery(".folder-popup-form").removeClass("disabled");
|
|
|
|
|
|
|
66 |
} else {
|
67 |
jQuery(".folder-popup-form").hide();
|
68 |
jQuery(".folder-popup-form").removeClass("disabled");
|
@@ -102,6 +108,9 @@ jQuery(document).ready(function(){
|
|
102 |
add_menu_to_list();
|
103 |
jQuery(".folder-popup-form").hide();
|
104 |
jQuery(".folder-popup-form").removeClass("disabled");
|
|
|
|
|
|
|
105 |
} else {
|
106 |
jQuery(".folder-popup-form").hide();
|
107 |
jQuery(".folder-popup-form").removeClass("disabled");
|
@@ -136,6 +145,11 @@ jQuery(document).ready(function(){
|
|
136 |
add_menu_to_list()
|
137 |
jQuery(".folder-popup-form").hide();
|
138 |
jQuery(".folder-popup-form").removeClass("disabled");
|
|
|
|
|
|
|
|
|
|
|
139 |
} else {
|
140 |
jQuery(".folder-popup-form").hide();
|
141 |
jQuery(".folder-popup-form").removeClass("disabled");
|
@@ -165,7 +179,6 @@ function addFolder() {
|
|
165 |
jQuery("#add-update-folder-name").focus();
|
166 |
}
|
167 |
|
168 |
-
|
169 |
function updateFolder() {
|
170 |
folderName = jQuery.trim(jQuery("#wcp_folder_"+fileFolderID+" > h3 > .title-text").text());
|
171 |
parentID = jQuery("#wcp_folder_"+fileFolderID).closest("li.route").data("folder-id");
|
@@ -188,6 +201,60 @@ function removeFolderFromID() {
|
|
188 |
jQuery("#confirm-remove-folder").show();
|
189 |
}
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
function add_menu_to_list() {
|
192 |
folderId = 0;
|
193 |
if(jQuery(".active-term").length) {
|
@@ -231,9 +298,29 @@ jQuery(document).ready(function(){
|
|
231 |
|
232 |
jQuery(document).on("click", "h3.title", function(e) {
|
233 |
e.stopPropagation();
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
});
|
236 |
|
|
|
237 |
jQuery(".tree-structure a").livequery(function(){
|
238 |
jQuery(this).click(function(){
|
239 |
fID = jQuery(this).data("id");
|
@@ -241,37 +328,53 @@ jQuery(document).ready(function(){
|
|
241 |
});
|
242 |
});
|
243 |
|
244 |
-
jQuery(".wcp-parent > span").click(function(){
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
});
|
247 |
-
jQuery("h3.title").livequery(function
|
248 |
jQuery(this).droppable({
|
249 |
accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
|
250 |
hoverClass: 'wcp-drop-hover',
|
251 |
classes: {
|
252 |
"ui-droppable-active": "ui-state-highlight"
|
253 |
},
|
254 |
-
drop: function
|
255 |
folderID = jQuery(this).closest("li.route").data('folder-id');
|
256 |
-
if (ui.draggable.hasClass('wcp-move-multiple')) {
|
257 |
-
if
|
258 |
chkStr = "";
|
259 |
-
jQuery(".wp-list-table input:checked").each(function
|
260 |
-
chkStr += jQuery(this).val()
|
261 |
});
|
262 |
-
nonce = jQuery.trim(jQuery("#wcp_folder_"
|
263 |
jQuery.ajax({
|
264 |
url: wcp_settings.ajax_url,
|
265 |
-
data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+
|
266 |
method: 'post',
|
267 |
success: function (res) {
|
268 |
res = jQuery.parseJSON(res);
|
269 |
if(res.status == "1") {
|
270 |
-
window.location.reload();
|
|
|
271 |
} else {
|
272 |
jQuery(".folder-popup-form").hide();
|
273 |
jQuery(".folder-popup-form").removeClass("disabled");
|
274 |
-
jQuery("#error-folder-popup-message").html(
|
275 |
jQuery("#error-folder-popup").show()
|
276 |
}
|
277 |
}
|
@@ -282,16 +385,17 @@ jQuery(document).ready(function(){
|
|
282 |
nonce = jQuery.trim(jQuery("#wcp_folder_"+folderID).data("nonce"));
|
283 |
jQuery.ajax({
|
284 |
url: wcp_settings.ajax_url,
|
285 |
-
data: "post_id=" + postID + "&type=" + wcp_settings.post_type + "&action=wcp_change_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+
|
286 |
method: 'post',
|
287 |
success: function (res) {
|
288 |
res = jQuery.parseJSON(res);
|
289 |
if(res.status == "1") {
|
290 |
-
window.location.reload();
|
|
|
291 |
} else {
|
292 |
jQuery(".folder-popup-form").hide();
|
293 |
jQuery(".folder-popup-form").removeClass("disabled");
|
294 |
-
jQuery("#error-folder-popup-message").html(
|
295 |
jQuery("#error-folder-popup").show()
|
296 |
}
|
297 |
}
|
@@ -305,12 +409,14 @@ jQuery(document).ready(function(){
|
|
305 |
chkStr += jQuery(this).data("id") + ",";
|
306 |
});
|
307 |
}
|
|
|
308 |
jQuery.ajax({
|
309 |
url: wcp_settings.ajax_url,
|
310 |
-
data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+
|
311 |
method: 'post',
|
312 |
success: function (res) {
|
313 |
-
window.location.reload();
|
|
|
314 |
}
|
315 |
});
|
316 |
}
|
@@ -341,7 +447,6 @@ jQuery(document).ready(function(){
|
|
341 |
jQuery("body").removeClass("no-hover-css");
|
342 |
}
|
343 |
});
|
344 |
-
// jQuery(this).draggable("disable");
|
345 |
});
|
346 |
|
347 |
jQuery(".media-button").livequery(function () {
|
@@ -355,11 +460,42 @@ jQuery(document).ready(function(){
|
|
355 |
});
|
356 |
|
357 |
jQuery(".header-posts").click(function(){
|
358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
});
|
360 |
|
361 |
jQuery(".un-categorised-items").click(function(){
|
362 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
});
|
364 |
|
365 |
jQuery(".un-categorised-items").livequery(function () {
|
@@ -380,10 +516,11 @@ jQuery(document).ready(function(){
|
|
380 |
});
|
381 |
jQuery.ajax({
|
382 |
url: wcp_settings.ajax_url,
|
383 |
-
data: "post_id=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+
|
384 |
method: 'post',
|
385 |
success: function (res) {
|
386 |
-
window.location.reload();
|
|
|
387 |
}
|
388 |
});
|
389 |
}
|
@@ -391,10 +528,11 @@ jQuery(document).ready(function(){
|
|
391 |
postID = ui.draggable[0].attributes['data-id'].nodeValue;
|
392 |
jQuery.ajax({
|
393 |
url: wcp_settings.ajax_url,
|
394 |
-
data: "post_id=" + postID + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+
|
395 |
method: 'post',
|
396 |
success: function (res) {
|
397 |
-
window.location.reload();
|
|
|
398 |
}
|
399 |
});
|
400 |
} else if (ui.draggable.hasClass('attachment')) {
|
@@ -405,12 +543,14 @@ jQuery(document).ready(function(){
|
|
405 |
chkStr += jQuery(this).data("id") + ",";
|
406 |
});
|
407 |
}
|
|
|
408 |
jQuery.ajax({
|
409 |
url: wcp_settings.ajax_url,
|
410 |
-
data: "post_id=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+
|
411 |
method: 'post',
|
412 |
success: function (res) {
|
413 |
-
window.location.reload();
|
|
|
414 |
}
|
415 |
});
|
416 |
}
|
@@ -459,63 +599,66 @@ jQuery(document).ready(function(){
|
|
459 |
});
|
460 |
|
461 |
//if(wcp_settings.can_manage_folder == "1") {
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
jQuery.ajax({
|
479 |
-
url: wcp_settings.ajax_url,
|
480 |
-
data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce=" + nonce,
|
481 |
-
method: 'post',
|
482 |
-
success: function (res) {
|
483 |
-
window.location.reload();
|
484 |
-
}
|
485 |
-
});
|
486 |
-
}
|
487 |
-
} else if (ui.draggable.hasClass('wcp-move-file')) {
|
488 |
-
postID = ui.draggable[0].attributes['data-id'].nodeValue;
|
489 |
-
nonce = jQuery.trim(jQuery("#wcp_folder_" + folderID).data("nonce"));
|
490 |
jQuery.ajax({
|
491 |
url: wcp_settings.ajax_url,
|
492 |
-
data: "
|
493 |
method: 'post',
|
494 |
success: function (res) {
|
495 |
-
window.location.reload();
|
|
|
496 |
}
|
497 |
});
|
498 |
-
}
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
|
|
|
|
|
|
506 |
}
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
|
|
514 |
});
|
515 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
}
|
517 |
-
}
|
518 |
});
|
|
|
519 |
//}
|
520 |
|
521 |
jQuery("#expand-collapse-list").click(function(e){
|
@@ -636,11 +779,11 @@ jQuery(document).ready(function(){
|
|
636 |
jQuery(".dynamic-menu").remove();
|
637 |
jQuery(".active-menu").removeClass("active-menu");
|
638 |
menuHtml = "<div class='dynamic-menu'><ul>" +
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
jQuery(this).after(menuHtml);
|
645 |
jQuery(this).parents("li.route").addClass("active-menu");
|
646 |
return false;
|
@@ -781,6 +924,7 @@ jQuery(document).ready(function(){
|
|
781 |
jQuery("#wcp_folder_parent").html(res.options);
|
782 |
jQuery(".form-loader-count").css("width", "0");
|
783 |
add_menu_to_list();
|
|
|
784 |
} else {
|
785 |
jQuery(".folder-popup-form").hide();
|
786 |
jQuery(".folder-popup-form").removeClass("disabled");
|
@@ -799,29 +943,29 @@ jQuery(document).ready(function(){
|
|
799 |
jQuery(this).closest("li.route").find("ul.ui-sortable:first-child > li").slideDown();
|
800 |
parentId = jQuery(this).closest("li.route").data("folder-id");
|
801 |
thisId = ui.item.context.attributes['data-folder-id'].nodeValue;
|
802 |
-
if
|
803 |
parentId = 0;
|
804 |
}
|
805 |
orderString = "";
|
806 |
-
if
|
807 |
-
jQuery("#wcp_folder_"
|
808 |
-
orderString += jQuery(this).data("folder-id")
|
809 |
});
|
810 |
-
} else if
|
811 |
-
jQuery("#custom-menu > ul.space > li").each(function
|
812 |
-
orderString += jQuery(this).data("folder-id")
|
813 |
});
|
814 |
}
|
815 |
-
jQuery(".form-loader-count").css("width",
|
816 |
-
nonce = jQuery.trim(jQuery("#wcp_folder_"
|
817 |
jQuery.ajax({
|
818 |
url: wcp_settings.ajax_url,
|
819 |
-
data: "term_id=" + thisId + "&action=wcp_update_parent_information&parent_id=" + parentId
|
820 |
method: 'post',
|
821 |
success: function (res) {
|
822 |
-
jQuery(".form-loader-count").css("width",
|
823 |
res = jQuery.parseJSON(res);
|
824 |
-
if
|
825 |
jQuery(".folder-popup-form").hide();
|
826 |
jQuery(".folder-popup-form").removeClass("disabled");
|
827 |
jQuery("#error-folder-popup-message").html(res.message);
|
@@ -843,11 +987,11 @@ jQuery(document).ready(function(){
|
|
843 |
jQuery(".dynamic-menu").remove();
|
844 |
jQuery(".active-menu").removeClass("active-menu");
|
845 |
menuHtml = "<div class='dynamic-menu'><ul>" +
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
jQuery(this).closest("h3.title").after(menuHtml);
|
852 |
jQuery(this).parents("li.route").addClass("active-menu");
|
853 |
});
|
@@ -1003,7 +1147,7 @@ if(wcp_settings.post_type == "attachment") {
|
|
1003 |
jQuery(document).ajaxComplete(function(ev, jqXHR, settings) {
|
1004 |
var actionName = settings.data;
|
1005 |
if (typeof actionName != "undefined") {
|
1006 |
-
if (actionName.indexOf("action=delete-post&id=") == 0) {
|
1007 |
resetMediaData(0);
|
1008 |
}
|
1009 |
}
|
@@ -1026,13 +1170,13 @@ if(wcp_settings.post_type == "attachment") {
|
|
1026 |
} else {
|
1027 |
eraseCookie("media-select-mode");
|
1028 |
}
|
1029 |
-
}, 1000)
|
1030 |
});
|
1031 |
|
1032 |
function resetMediaData(loadData) {
|
1033 |
jQuery.ajax({
|
1034 |
url: wcp_settings.ajax_url,
|
1035 |
-
data: "type=" + wcp_settings.post_type + "&action=wcp_get_default_list",
|
1036 |
method: 'post',
|
1037 |
success: function (res) {
|
1038 |
res = jQuery.parseJSON(res);
|
@@ -1051,13 +1195,17 @@ if(wcp_settings.post_type == "attachment") {
|
|
1051 |
}
|
1052 |
}
|
1053 |
if(res.taxonomies.length) {
|
|
|
1054 |
var selectedDD = jQuery("#media-attachment-taxonomy-filter");
|
1055 |
selectedDD.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>");
|
1056 |
for(i=0; i<res.taxonomies.length; i++) {
|
1057 |
-
selectedDD.append("<option value='"+i+"'>"+res.taxonomies[i].name+" ("+res.taxonomies[i].count+")</option>");
|
1058 |
}
|
1059 |
selectedDD.val(selectedVal);
|
1060 |
}
|
|
|
|
|
|
|
1061 |
}
|
1062 |
});
|
1063 |
}
|
9 |
var nonce = "";
|
10 |
var folderId = 0;
|
11 |
var fID = 0;
|
12 |
+
var folderCurrentURL = wcp_settings.page_url;
|
13 |
+
var activeRecordID = "";
|
14 |
+
var folderIDs = "";
|
15 |
|
16 |
var listFolderString = "<li class='grid-view' data-id='__folder_id__' id='folder___folder_id__'>" +
|
17 |
"<div class='folder-item is-folder' data-id='__folder_id__'>" +
|
18 |
"<a title='__folder_name__' id='folder_view___folder_id__'" +
|
19 |
+
"class='folder-view __append_class__ has-new-folder'" +
|
20 |
"data-id='__folder_id__'>" +
|
21 |
"<span class='folder item-name'><span id='wcp_folder_text___folder_id__'" +
|
22 |
"class='folder-title'>__folder_name__</span></span>" +
|
66 |
add_menu_to_list();
|
67 |
jQuery(".folder-popup-form").hide();
|
68 |
jQuery(".folder-popup-form").removeClass("disabled");
|
69 |
+
if(jQuery("#media-attachment-taxonomy-filter").length) {
|
70 |
+
resetMediaData(0)
|
71 |
+
}
|
72 |
} else {
|
73 |
jQuery(".folder-popup-form").hide();
|
74 |
jQuery(".folder-popup-form").removeClass("disabled");
|
108 |
add_menu_to_list();
|
109 |
jQuery(".folder-popup-form").hide();
|
110 |
jQuery(".folder-popup-form").removeClass("disabled");
|
111 |
+
if(jQuery("#media-attachment-taxonomy-filter").length) {
|
112 |
+
resetMediaData(0)
|
113 |
+
}
|
114 |
} else {
|
115 |
jQuery(".folder-popup-form").hide();
|
116 |
jQuery(".folder-popup-form").removeClass("disabled");
|
145 |
add_menu_to_list()
|
146 |
jQuery(".folder-popup-form").hide();
|
147 |
jQuery(".folder-popup-form").removeClass("disabled");
|
148 |
+
resetMediaAndPosts();
|
149 |
+
|
150 |
+
if(activeRecordID == fileFolderID) {
|
151 |
+
jQuery(".header-posts").trigger("click");
|
152 |
+
}
|
153 |
} else {
|
154 |
jQuery(".folder-popup-form").hide();
|
155 |
jQuery(".folder-popup-form").removeClass("disabled");
|
179 |
jQuery("#add-update-folder-name").focus();
|
180 |
}
|
181 |
|
|
|
182 |
function updateFolder() {
|
183 |
folderName = jQuery.trim(jQuery("#wcp_folder_"+fileFolderID+" > h3 > .title-text").text());
|
184 |
parentID = jQuery("#wcp_folder_"+fileFolderID).closest("li.route").data("folder-id");
|
201 |
jQuery("#confirm-remove-folder").show();
|
202 |
}
|
203 |
|
204 |
+
function resetMediaAndPosts() {
|
205 |
+
if(folderIDs != "" && (jQuery("#custom-menu li.active-item").length > 0 || activeRecordID == "-1")) {
|
206 |
+
if(jQuery("#media-attachment-taxonomy-filter").length) {
|
207 |
+
folderIDs = folderIDs.split(",");
|
208 |
+
for (var i = 0; i < folderIDs.length; i++) {
|
209 |
+
if(folderIDs[i] != "") {
|
210 |
+
jQuery(".attachments-browser li[data-id='"+folderIDs[i]+"']").remove();
|
211 |
+
}
|
212 |
+
}
|
213 |
+
}
|
214 |
+
folderIDs = "";
|
215 |
+
}
|
216 |
+
if(jQuery("#media-attachment-taxonomy-filter").length) {
|
217 |
+
resetMediaData(0);
|
218 |
+
} else {
|
219 |
+
jQuery.ajax({
|
220 |
+
url: wcp_settings.ajax_url,
|
221 |
+
data: "type=" + wcp_settings.post_type + "&action=get_folders_default_list",
|
222 |
+
method: 'post',
|
223 |
+
success: function (res) {
|
224 |
+
res = jQuery.parseJSON(res);
|
225 |
+
jQuery("#custom-menu > ul#space_0").html(res.data);
|
226 |
+
jQuery(".header-posts .total-count").text(res.total_items);
|
227 |
+
jQuery(".un-categorised-items .total-count").text(res.empty_items);
|
228 |
+
}
|
229 |
+
});
|
230 |
+
jQuery(".folder-loader-ajax").addClass("active");
|
231 |
+
jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", false, function (res) {
|
232 |
+
jQuery(".folder-loader-ajax").removeClass("active");
|
233 |
+
if (!jQuery(".tree-structure").length) {
|
234 |
+
jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
|
235 |
+
}
|
236 |
+
add_active_item_to_list();
|
237 |
+
});
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
+
function add_active_item_to_list() {
|
242 |
+
folderId = 0;
|
243 |
+
if(jQuery(".active-item").length) {
|
244 |
+
folderId = jQuery(".active-item").data("folder-id");
|
245 |
+
}
|
246 |
+
jQuery(".tree-structure ul").html("");
|
247 |
+
jQuery("#space_"+folderId).children().each(function(){
|
248 |
+
fID = jQuery(this).data("folder-id");
|
249 |
+
fName = jQuery(this).find("h3.title:first .title-text").text()
|
250 |
+
liHtml = listFolderString.replace(/__folder_id__/g,fID);
|
251 |
+
liHtml = liHtml.replace(/__folder_name__/g,fName);
|
252 |
+
selectedClass = jQuery(this).hasClass("is-high")?"is-high":"";
|
253 |
+
liHtml = liHtml.replace(/__append_class__/g,selectedClass);
|
254 |
+
jQuery(".tree-structure ul").append(liHtml);
|
255 |
+
});
|
256 |
+
}
|
257 |
+
|
258 |
function add_menu_to_list() {
|
259 |
folderId = 0;
|
260 |
if(jQuery(".active-term").length) {
|
298 |
|
299 |
jQuery(document).on("click", "h3.title", function(e) {
|
300 |
e.stopPropagation();
|
301 |
+
activeRecordID = jQuery(this).closest("li.route").data("folder-id");
|
302 |
+
if(!jQuery("#media-attachment-taxonomy-filter").length) {
|
303 |
+
folderCurrentURL = wcp_settings.page_url + jQuery(this).closest("li.route").data("slug");
|
304 |
+
jQuery(".folder-loader-ajax").addClass("active");
|
305 |
+
jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
|
306 |
+
jQuery(".folder-loader-ajax").removeClass("active");
|
307 |
+
if (!jQuery(".tree-structure").length) {
|
308 |
+
jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
|
309 |
+
}
|
310 |
+
add_active_item_to_list();
|
311 |
+
});
|
312 |
+
} else {
|
313 |
+
var thisIndex = jQuery(this).closest("li.route").data("folder-id");
|
314 |
+
jQuery("#media-attachment-taxonomy-filter").val(thisIndex);
|
315 |
+
jQuery("#media-attachment-taxonomy-filter").trigger("change");
|
316 |
+
if(jQuery(this).hasClass("is-new-item")) {
|
317 |
+
thisSlug = jQuery(this).closest("li.route").data("slug");
|
318 |
+
alert("23412");
|
319 |
+
}
|
320 |
+
}
|
321 |
});
|
322 |
|
323 |
+
|
324 |
jQuery(".tree-structure a").livequery(function(){
|
325 |
jQuery(this).click(function(){
|
326 |
fID = jQuery(this).data("id");
|
328 |
});
|
329 |
});
|
330 |
|
331 |
+
jQuery(".wcp-parent > span").click(function(e){
|
332 |
+
activeRecordID = "";
|
333 |
+
jQuery(".wcp-container .route").removeClass("active-item");
|
334 |
+
if(!jQuery("#media-attachment-taxonomy-filter").length) {
|
335 |
+
folderCurrentURL = wcp_settings.page_url;
|
336 |
+
jQuery(".folder-loader-ajax").addClass("active");
|
337 |
+
jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
|
338 |
+
jQuery(".folder-loader-ajax").removeClass("active");
|
339 |
+
if (!jQuery(".tree-structure").length) {
|
340 |
+
jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
|
341 |
+
}
|
342 |
+
add_active_item_to_list();
|
343 |
+
});
|
344 |
+
} else {
|
345 |
+
jQuery("#media-attachment-taxonomy-filter").val("all");
|
346 |
+
jQuery("#media-attachment-taxonomy-filter").trigger("change");
|
347 |
+
}
|
348 |
});
|
349 |
+
jQuery("h3.title").livequery(function(){
|
350 |
jQuery(this).droppable({
|
351 |
accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
|
352 |
hoverClass: 'wcp-drop-hover',
|
353 |
classes: {
|
354 |
"ui-droppable-active": "ui-state-highlight"
|
355 |
},
|
356 |
+
drop: function( event, ui ) {
|
357 |
folderID = jQuery(this).closest("li.route").data('folder-id');
|
358 |
+
if ( ui.draggable.hasClass( 'wcp-move-multiple' ) ) {
|
359 |
+
if(jQuery(".wp-list-table input:checked").length) {
|
360 |
chkStr = "";
|
361 |
+
jQuery(".wp-list-table input:checked").each(function(){
|
362 |
+
chkStr += jQuery(this).val()+",";
|
363 |
});
|
364 |
+
nonce = jQuery.trim(jQuery("#wcp_folder_"+folderID).data("nonce"));
|
365 |
jQuery.ajax({
|
366 |
url: wcp_settings.ajax_url,
|
367 |
+
data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
|
368 |
method: 'post',
|
369 |
success: function (res) {
|
370 |
res = jQuery.parseJSON(res);
|
371 |
if(res.status == "1") {
|
372 |
+
// window.location.reload();
|
373 |
+
resetMediaAndPosts();
|
374 |
} else {
|
375 |
jQuery(".folder-popup-form").hide();
|
376 |
jQuery(".folder-popup-form").removeClass("disabled");
|
377 |
+
jQuery("#error-folder-popup-message").html(res.message);
|
378 |
jQuery("#error-folder-popup").show()
|
379 |
}
|
380 |
}
|
385 |
nonce = jQuery.trim(jQuery("#wcp_folder_"+folderID).data("nonce"));
|
386 |
jQuery.ajax({
|
387 |
url: wcp_settings.ajax_url,
|
388 |
+
data: "post_id=" + postID + "&type=" + wcp_settings.post_type + "&action=wcp_change_post_folder&folder_id=" + folderID+"&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
|
389 |
method: 'post',
|
390 |
success: function (res) {
|
391 |
res = jQuery.parseJSON(res);
|
392 |
if(res.status == "1") {
|
393 |
+
// window.location.reload();
|
394 |
+
resetMediaAndPosts();
|
395 |
} else {
|
396 |
jQuery(".folder-popup-form").hide();
|
397 |
jQuery(".folder-popup-form").removeClass("disabled");
|
398 |
+
jQuery("#error-folder-popup-message").html(res.message);
|
399 |
jQuery("#error-folder-popup").show()
|
400 |
}
|
401 |
}
|
409 |
chkStr += jQuery(this).data("id") + ",";
|
410 |
});
|
411 |
}
|
412 |
+
folderIDs = chkStr;
|
413 |
jQuery.ajax({
|
414 |
url: wcp_settings.ajax_url,
|
415 |
+
data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce="+nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
|
416 |
method: 'post',
|
417 |
success: function (res) {
|
418 |
+
// window.location.reload();
|
419 |
+
resetMediaAndPosts();
|
420 |
}
|
421 |
});
|
422 |
}
|
447 |
jQuery("body").removeClass("no-hover-css");
|
448 |
}
|
449 |
});
|
|
|
450 |
});
|
451 |
|
452 |
jQuery(".media-button").livequery(function () {
|
460 |
});
|
461 |
|
462 |
jQuery(".header-posts").click(function(){
|
463 |
+
activeRecordID = "";
|
464 |
+
jQuery(".wcp-container .route").removeClass("active-item");
|
465 |
+
if(!jQuery("#media-attachment-taxonomy-filter").length) {
|
466 |
+
folderCurrentURL = wcp_settings.page_url;
|
467 |
+
jQuery(".folder-loader-ajax").addClass("active");
|
468 |
+
jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
|
469 |
+
jQuery(".folder-loader-ajax").removeClass("active");
|
470 |
+
if (!jQuery(".tree-structure").length) {
|
471 |
+
jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
|
472 |
+
}
|
473 |
+
add_active_item_to_list();
|
474 |
+
});
|
475 |
+
} else {
|
476 |
+
activeRecordID = "";
|
477 |
+
jQuery("#media-attachment-taxonomy-filter").val("all");
|
478 |
+
jQuery("#media-attachment-taxonomy-filter").trigger("change");
|
479 |
+
}
|
480 |
});
|
481 |
|
482 |
jQuery(".un-categorised-items").click(function(){
|
483 |
+
activeRecordID = "-1";
|
484 |
+
jQuery(".wcp-container .route").removeClass("active-item");
|
485 |
+
if(!jQuery("#media-attachment-taxonomy-filter").length) {
|
486 |
+
folderCurrentURL = wcp_settings.page_url+"-1";
|
487 |
+
jQuery(".folder-loader-ajax").addClass("active");
|
488 |
+
jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
|
489 |
+
jQuery(".folder-loader-ajax").removeClass("active");
|
490 |
+
if (!jQuery(".tree-structure").length) {
|
491 |
+
jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
|
492 |
+
}
|
493 |
+
add_active_item_to_list();
|
494 |
+
});
|
495 |
+
} else {
|
496 |
+
jQuery("#media-attachment-taxonomy-filter").val("unassigned");
|
497 |
+
jQuery("#media-attachment-taxonomy-filter").trigger("change");
|
498 |
+
}
|
499 |
});
|
500 |
|
501 |
jQuery(".un-categorised-items").livequery(function () {
|
516 |
});
|
517 |
jQuery.ajax({
|
518 |
url: wcp_settings.ajax_url,
|
519 |
+
data: "post_id=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
|
520 |
method: 'post',
|
521 |
success: function (res) {
|
522 |
+
//window.location.reload();
|
523 |
+
resetMediaAndPosts();
|
524 |
}
|
525 |
});
|
526 |
}
|
528 |
postID = ui.draggable[0].attributes['data-id'].nodeValue;
|
529 |
jQuery.ajax({
|
530 |
url: wcp_settings.ajax_url,
|
531 |
+
data: "post_id=" + postID + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
|
532 |
method: 'post',
|
533 |
success: function (res) {
|
534 |
+
//window.location.reload();
|
535 |
+
resetMediaAndPosts();
|
536 |
}
|
537 |
});
|
538 |
} else if (ui.draggable.hasClass('attachment')) {
|
543 |
chkStr += jQuery(this).data("id") + ",";
|
544 |
});
|
545 |
}
|
546 |
+
folderIDs = chkStr;
|
547 |
jQuery.ajax({
|
548 |
url: wcp_settings.ajax_url,
|
549 |
+
data: "post_id=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_remove_post_folder&folder_id=" + folderID + "&nonce=" + nonce+"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
|
550 |
method: 'post',
|
551 |
success: function (res) {
|
552 |
+
// window.location.reload();
|
553 |
+
resetMediaAndPosts();
|
554 |
}
|
555 |
});
|
556 |
}
|
599 |
});
|
600 |
|
601 |
//if(wcp_settings.can_manage_folder == "1") {
|
602 |
+
jQuery(".tree-structure .folder-item").livequery(function () {
|
603 |
+
jQuery(this).droppable({
|
604 |
+
accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
|
605 |
+
hoverClass: 'wcp-drop-hover-list',
|
606 |
+
classes: {
|
607 |
+
"ui-droppable-active": "ui-state-highlight"
|
608 |
+
},
|
609 |
+
drop: function (event, ui) {
|
610 |
+
folderID = jQuery(this).data('id');
|
611 |
+
if (ui.draggable.hasClass('wcp-move-multiple')) {
|
612 |
+
nonce = jQuery.trim(jQuery("#wcp_folder_" + folderID).data("nonce"));
|
613 |
+
if (jQuery(".wp-list-table input:checked").length) {
|
614 |
+
chkStr = "";
|
615 |
+
jQuery(".wp-list-table input:checked").each(function () {
|
616 |
+
chkStr += jQuery(this).val() + ",";
|
617 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
618 |
jQuery.ajax({
|
619 |
url: wcp_settings.ajax_url,
|
620 |
+
data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce=" + nonce + "&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
|
621 |
method: 'post',
|
622 |
success: function (res) {
|
623 |
+
//window.location.reload();
|
624 |
+
resetMediaAndPosts();
|
625 |
}
|
626 |
});
|
627 |
+
}
|
628 |
+
} else if (ui.draggable.hasClass('wcp-move-file')) {
|
629 |
+
postID = ui.draggable[0].attributes['data-id'].nodeValue;
|
630 |
+
nonce = jQuery.trim(jQuery("#wcp_folder_" + folderID).data("nonce"));
|
631 |
+
jQuery.ajax({
|
632 |
+
url: wcp_settings.ajax_url,
|
633 |
+
data: "post_id=" + postID + "&type=" + wcp_settings.post_type + "&action=wcp_change_post_folder&folder_id=" + folderID + "&nonce=" + nonce +"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
|
634 |
+
method: 'post',
|
635 |
+
success: function (res) {
|
636 |
+
//window.location.reload();
|
637 |
+
resetMediaAndPosts();
|
638 |
}
|
639 |
+
});
|
640 |
+
} else if (ui.draggable.hasClass('attachment')) {
|
641 |
+
chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
|
642 |
+
nonce = jQuery.trim(jQuery("#wcp_folder_" + folderID).data("nonce"));
|
643 |
+
if (jQuery(".attachments-browser li.attachment.selected").length > 1) {
|
644 |
+
chkStr = "";
|
645 |
+
jQuery(".attachments-browser li.attachment.selected").each(function () {
|
646 |
+
chkStr += jQuery(this).data("id") + ",";
|
647 |
});
|
648 |
}
|
649 |
+
jQuery.ajax({
|
650 |
+
url: wcp_settings.ajax_url,
|
651 |
+
data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce=" + nonce +"&status="+wcp_settings.taxonomy_status+"&taxonomy="+activeRecordID,
|
652 |
+
method: 'post',
|
653 |
+
success: function (res) {
|
654 |
+
//window.location.reload();
|
655 |
+
resetMediaAndPosts();
|
656 |
+
}
|
657 |
+
});
|
658 |
}
|
659 |
+
}
|
660 |
});
|
661 |
+
});
|
662 |
//}
|
663 |
|
664 |
jQuery("#expand-collapse-list").click(function(e){
|
779 |
jQuery(".dynamic-menu").remove();
|
780 |
jQuery(".active-menu").removeClass("active-menu");
|
781 |
menuHtml = "<div class='dynamic-menu'><ul>" +
|
782 |
+
"<li class='new-folder'><a href='javascript:;'><span class='folder-icon-create_new_folder'></span> New Folder</a></li>" +
|
783 |
+
"<li class='rename-folder'><a href='javascript:;'><span class='folder-icon-border_color'><span class='path1'></span><span class='path2'></span></span> Rename</a></li>" +
|
784 |
+
"<li class='mark-folder'><a href='javascript:;'><span class='folder-icon-star_rate'></span>" + ((isHigh) ? " Remove Star" : "Add a Star") + "</a></li>" +
|
785 |
+
"<li class='remove-folder'><a href='javascript:;'><span class='folder-icon-delete'></span> Delete</a></li>" +
|
786 |
+
"</ul></div>";
|
787 |
jQuery(this).after(menuHtml);
|
788 |
jQuery(this).parents("li.route").addClass("active-menu");
|
789 |
return false;
|
924 |
jQuery("#wcp_folder_parent").html(res.options);
|
925 |
jQuery(".form-loader-count").css("width", "0");
|
926 |
add_menu_to_list();
|
927 |
+
resetMediaAndPosts();
|
928 |
} else {
|
929 |
jQuery(".folder-popup-form").hide();
|
930 |
jQuery(".folder-popup-form").removeClass("disabled");
|
943 |
jQuery(this).closest("li.route").find("ul.ui-sortable:first-child > li").slideDown();
|
944 |
parentId = jQuery(this).closest("li.route").data("folder-id");
|
945 |
thisId = ui.item.context.attributes['data-folder-id'].nodeValue;
|
946 |
+
if(parentId == undefined) {
|
947 |
parentId = 0;
|
948 |
}
|
949 |
orderString = "";
|
950 |
+
if(jQuery("#wcp_folder_"+parentId+" .ui-sortable li").length) {
|
951 |
+
jQuery("#wcp_folder_"+parentId+" .ui-sortable li").each(function(){
|
952 |
+
orderString += jQuery(this).data("folder-id")+",";
|
953 |
});
|
954 |
+
} else if(parentId == 0) {
|
955 |
+
jQuery("#custom-menu > ul.space > li").each(function(){
|
956 |
+
orderString += jQuery(this).data("folder-id")+",";
|
957 |
});
|
958 |
}
|
959 |
+
jQuery(".form-loader-count").css("width","100%");
|
960 |
+
nonce = jQuery.trim(jQuery("#wcp_folder_"+thisId).data("nonce"));
|
961 |
jQuery.ajax({
|
962 |
url: wcp_settings.ajax_url,
|
963 |
+
data: "term_id=" + thisId + "&action=wcp_update_parent_information&parent_id=" + parentId+"&type=" + wcp_settings.post_type+"&nonce="+nonce,
|
964 |
method: 'post',
|
965 |
success: function (res) {
|
966 |
+
jQuery(".form-loader-count").css("width","0%");
|
967 |
res = jQuery.parseJSON(res);
|
968 |
+
if(res.status == 0) {
|
969 |
jQuery(".folder-popup-form").hide();
|
970 |
jQuery(".folder-popup-form").removeClass("disabled");
|
971 |
jQuery("#error-folder-popup-message").html(res.message);
|
987 |
jQuery(".dynamic-menu").remove();
|
988 |
jQuery(".active-menu").removeClass("active-menu");
|
989 |
menuHtml = "<div class='dynamic-menu'><ul>" +
|
990 |
+
"<li class='new-folder'><a href='javascript:;'><span class='folder-icon-create_new_folder'></span> New Folder</a></li>" +
|
991 |
+
"<li class='rename-folder'><a href='javascript:;'><span class='folder-icon-border_color'><span class='path1'></span><span class='path2'></span></span> Rename</a></li>" +
|
992 |
+
"<li class='mark-folder'><a href='javascript:;'><span class='folder-icon-star_rate'></span>" + ((isHigh) ? " Remove Star" : "Add a Star") + "</a></li>" +
|
993 |
+
"<li class='remove-folder'><a href='javascript:;'><span class='folder-icon-delete'></span> Delete</a></li>" +
|
994 |
+
"</ul></div>";
|
995 |
jQuery(this).closest("h3.title").after(menuHtml);
|
996 |
jQuery(this).parents("li.route").addClass("active-menu");
|
997 |
});
|
1147 |
jQuery(document).ajaxComplete(function(ev, jqXHR, settings) {
|
1148 |
var actionName = settings.data;
|
1149 |
if (typeof actionName != "undefined") {
|
1150 |
+
if (actionName.length && actionName.indexOf("action=delete-post&id=") == 0) {
|
1151 |
resetMediaData(0);
|
1152 |
}
|
1153 |
}
|
1170 |
} else {
|
1171 |
eraseCookie("media-select-mode");
|
1172 |
}
|
1173 |
+
}, 1000);
|
1174 |
});
|
1175 |
|
1176 |
function resetMediaData(loadData) {
|
1177 |
jQuery.ajax({
|
1178 |
url: wcp_settings.ajax_url,
|
1179 |
+
data: "type=" + wcp_settings.post_type + "&action=wcp_get_default_list&active_id="+activeRecordID,
|
1180 |
method: 'post',
|
1181 |
success: function (res) {
|
1182 |
res = jQuery.parseJSON(res);
|
1195 |
}
|
1196 |
}
|
1197 |
if(res.taxonomies.length) {
|
1198 |
+
folders_media_options.terms = res.taxonomies;
|
1199 |
var selectedDD = jQuery("#media-attachment-taxonomy-filter");
|
1200 |
selectedDD.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>");
|
1201 |
for(i=0; i<res.taxonomies.length; i++) {
|
1202 |
+
selectedDD.append("<option value='"+res.taxonomies[i].term_id+"'>"+res.taxonomies[i].name+" ("+res.taxonomies[i].count+")</option>");
|
1203 |
}
|
1204 |
selectedDD.val(selectedVal);
|
1205 |
}
|
1206 |
+
if(activeRecordID != "") {
|
1207 |
+
jQuery("#wcp_folder_"+activeRecordID).addClass("active-item");
|
1208 |
+
}
|
1209 |
}
|
1210 |
});
|
1211 |
}
|
assets/js/media.js
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
createFilters: function() {
|
5 |
var filters = {};
|
6 |
_.each(folders_media_options.terms || {}, function(term, index) {
|
7 |
-
filters[
|
8 |
text: term.name + ' (' + term.count + ')',
|
9 |
props: {
|
10 |
'media_folder': term.slug
|
@@ -25,7 +25,38 @@
|
|
25 |
},
|
26 |
priority: 10
|
27 |
};
|
|
|
28 |
this.filters = filters;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
});
|
31 |
|
4 |
createFilters: function() {
|
5 |
var filters = {};
|
6 |
_.each(folders_media_options.terms || {}, function(term, index) {
|
7 |
+
filters[term.term_id] = {
|
8 |
text: term.name + ' (' + term.count + ')',
|
9 |
props: {
|
10 |
'media_folder': term.slug
|
25 |
},
|
26 |
priority: 10
|
27 |
};
|
28 |
+
console.log(filters);
|
29 |
this.filters = filters;
|
30 |
+
},
|
31 |
+
change: function() {
|
32 |
+
var filters = {};
|
33 |
+
_.each(folders_media_options.terms || {}, function(term, index) {
|
34 |
+
filters[term.term_id] = {
|
35 |
+
text: term.name + ' (' + term.count + ')',
|
36 |
+
props: {
|
37 |
+
'media_folder': term.slug
|
38 |
+
}
|
39 |
+
};
|
40 |
+
});
|
41 |
+
filters.all = {
|
42 |
+
text: 'Select a folder >>',
|
43 |
+
props: {
|
44 |
+
'media_folder': ''
|
45 |
+
},
|
46 |
+
priority: 10
|
47 |
+
};
|
48 |
+
filters.unassigned = {
|
49 |
+
text: '(Unassigned)',
|
50 |
+
props: {
|
51 |
+
'media_folder': "-1"
|
52 |
+
},
|
53 |
+
priority: 10
|
54 |
+
};
|
55 |
+
this.filters = filters;
|
56 |
+
var filter = this.filters[ this.el.value ];
|
57 |
+
if ( filter ) {
|
58 |
+
this.model.set( filter.props );
|
59 |
+
}
|
60 |
}
|
61 |
});
|
62 |
|
folders.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: Folders
|
4 |
* Description: Arrange media, pages, custom post types and posts into folders
|
5 |
-
* Version: 2.2.
|
6 |
* Author: Premio
|
7 |
* Author URI: https://premio.io/downloads/folders/
|
8 |
*/
|
@@ -15,7 +15,7 @@ define('WCP_FOLDER', 'folders');
|
|
15 |
define('WCP_FOLDER_VAR', 'folders_settings');
|
16 |
define("WCP_DS", DIRECTORY_SEPARATOR);
|
17 |
define('WCP_FOLDER_URL',plugin_dir_url(__FILE__));
|
18 |
-
define('WCP_FOLDER_VERSION',"2.2.
|
19 |
|
20 |
include_once plugin_dir_path(__FILE__)."includes/folders.class.php";
|
21 |
register_activation_hook( __FILE__, array( 'WCP_Folders', 'activate' ) );
|
2 |
/**
|
3 |
* Plugin Name: Folders
|
4 |
* Description: Arrange media, pages, custom post types and posts into folders
|
5 |
+
* Version: 2.2.5
|
6 |
* Author: Premio
|
7 |
* Author URI: https://premio.io/downloads/folders/
|
8 |
*/
|
15 |
define('WCP_FOLDER_VAR', 'folders_settings');
|
16 |
define("WCP_DS", DIRECTORY_SEPARATOR);
|
17 |
define('WCP_FOLDER_URL',plugin_dir_url(__FILE__));
|
18 |
+
define('WCP_FOLDER_VERSION',"2.2.5");
|
19 |
|
20 |
include_once plugin_dir_path(__FILE__)."includes/folders.class.php";
|
21 |
register_activation_hook( __FILE__, array( 'WCP_Folders', 'activate' ) );
|
includes/folders.class.php
CHANGED
@@ -61,6 +61,8 @@ class WCP_Folders
|
|
61 |
add_action( 'wp_ajax_wcp_folder_send_message_to_owner', array( $this, 'wcp_folder_send_message_to_owner' ) );
|
62 |
/* Get default list */
|
63 |
add_action( 'wp_ajax_wcp_get_default_list', array( $this, 'wcp_get_default_list' ) );
|
|
|
|
|
64 |
/* Auto select folder for new page, post */
|
65 |
add_action('new_to_auto-draft', array($this, 'new_to_auto_draft'), 10);
|
66 |
/* for media */
|
@@ -313,6 +315,34 @@ class WCP_Folders
|
|
313 |
die;
|
314 |
}
|
315 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
function save_media_terms( $post_id ) {
|
317 |
if ( wp_is_post_revision( $post_id ) ) {
|
318 |
return;
|
@@ -400,28 +430,74 @@ class WCP_Folders
|
|
400 |
}
|
401 |
|
402 |
public function get_terms_hierarchical( $taxonomy ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
$terms = get_terms( array(
|
404 |
'taxonomy' => $taxonomy,
|
405 |
'hide_empty' => false,
|
406 |
'parent' => 0,
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
$hierarchical_terms = array();
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
$hierarchical_terms[] = $term;
|
420 |
-
$hierarchical_terms = self::add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $term->term_id, 1);
|
421 |
-
}
|
422 |
-
}
|
423 |
}
|
|
|
|
|
424 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
425 |
return $hierarchical_terms;
|
426 |
}
|
427 |
|
@@ -896,10 +972,15 @@ class WCP_Folders
|
|
896 |
$taxonomy = self::sanitize_options($postData['taxonomy']);
|
897 |
}
|
898 |
if (is_array($postArray)) {
|
|
|
899 |
foreach ($postArray as $post) {
|
900 |
-
$
|
901 |
-
if(!empty($
|
902 |
-
|
|
|
|
|
|
|
|
|
903 |
}
|
904 |
wp_set_post_terms($post, $folderID, $post_type, $status);
|
905 |
}
|
@@ -961,7 +1042,7 @@ class WCP_Folders
|
|
961 |
$terms = get_the_terms($postID, $folder_post_type);
|
962 |
if (!empty($terms)) {
|
963 |
foreach ($terms as $term) {
|
964 |
-
|
965 |
wp_remove_object_terms($postID, $term->term_id, $folder_post_type);
|
966 |
}
|
967 |
}
|
@@ -1394,10 +1475,11 @@ class WCP_Folders
|
|
1394 |
$rename_nonce = wp_create_nonce('wcp_folder_rename_term_'.$result['term_id']);
|
1395 |
$highlight_nonce = wp_create_nonce('wcp_folder_highlight_term_'.$result['term_id']);
|
1396 |
$term_nonce = wp_create_nonce('wcp_folder_term_'.$result['term_id']);
|
1397 |
-
$string = "<li data-nonce='{$term_nonce}' data-star='{$highlight_nonce}' data-rename='{$rename_nonce}' data-delete='{$delete_nonce}' data-slug='{$result['term_id']}' class='ui-state-default route' id='wcp_folder_{$result['term_id']}' data-folder-id='{$result['term_id']}'><h3 class='title' id='title_{$result['term_id']}'><span class='title-text'>{$postData['name']}</span> <span class='update-inline-record'></span><span class='star-icon'></span> </h3><span class='nav-icon'><i class='wcp-icon folder-icon-arrow_right'></i></span><span class='ui-icon'><i class='wcp-icon folder-icon-folder'></i></span> <ul class='space' id='space_{$result['term_id']}'>";
|
1398 |
$string .= "</ul></li>";
|
1399 |
$response['term_data'] = $string;
|
1400 |
$response['parent_id'] = $parent;
|
|
|
1401 |
|
1402 |
$is_active = 1;
|
1403 |
$folders = -1;
|
61 |
add_action( 'wp_ajax_wcp_folder_send_message_to_owner', array( $this, 'wcp_folder_send_message_to_owner' ) );
|
62 |
/* Get default list */
|
63 |
add_action( 'wp_ajax_wcp_get_default_list', array( $this, 'wcp_get_default_list' ) );
|
64 |
+
/* Get default list */
|
65 |
+
add_action( 'wp_ajax_get_folders_default_list', array( $this, 'get_folders_default_list' ) );
|
66 |
/* Auto select folder for new page, post */
|
67 |
add_action('new_to_auto-draft', array($this, 'new_to_auto_draft'), 10);
|
68 |
/* for media */
|
315 |
die;
|
316 |
}
|
317 |
|
318 |
+
function get_folders_default_list() {
|
319 |
+
$postData = filter_input_array(INPUT_POST);
|
320 |
+
|
321 |
+
$post_type = $postData['type'];
|
322 |
+
|
323 |
+
if($post_type != 'attachment') {
|
324 |
+
$total_posts = self::get_total_posts($post_type);
|
325 |
+
} else {
|
326 |
+
$total_posts = wp_count_posts($post_type)->inherit;
|
327 |
+
}
|
328 |
+
|
329 |
+
$empty_items = self::get_total_empty_posts($post_type);
|
330 |
+
|
331 |
+
$post_type = self::get_custom_post_type($post_type);
|
332 |
+
|
333 |
+
$terms_data = WCP_Tree::get_full_tree_data($post_type);
|
334 |
+
|
335 |
+
$response = array(
|
336 |
+
'status' => 1,
|
337 |
+
'data' => $terms_data,
|
338 |
+
'total_items' => $total_posts,
|
339 |
+
'empty_items' => $empty_items
|
340 |
+
);
|
341 |
+
echo json_encode($response);
|
342 |
+
die;
|
343 |
+
|
344 |
+
}
|
345 |
+
|
346 |
function save_media_terms( $post_id ) {
|
347 |
if ( wp_is_post_revision( $post_id ) ) {
|
348 |
return;
|
430 |
}
|
431 |
|
432 |
public function get_terms_hierarchical( $taxonomy ) {
|
433 |
+
// $terms = get_terms( array(
|
434 |
+
// 'taxonomy' => $taxonomy,
|
435 |
+
// 'hide_empty' => false,
|
436 |
+
// 'parent' => 0,
|
437 |
+
// 'orderby' => 'meta_value_num',
|
438 |
+
// 'order' => 'ASC',
|
439 |
+
// 'update_count_callback' => '_update_generic_term_count',
|
440 |
+
// 'meta_query' => [[
|
441 |
+
// 'key' => 'wcp_custom_order',
|
442 |
+
// 'type' => 'NUMERIC',
|
443 |
+
// ]]
|
444 |
+
// ) );
|
445 |
+
//
|
446 |
+
// if ( empty( $terms ) ) {
|
447 |
+
// return false;
|
448 |
+
// }
|
449 |
+
//
|
450 |
+
// $hierarchy = _get_term_hierarchy( $taxonomy );
|
451 |
+
//
|
452 |
+
// $hierarchical_terms = array();
|
453 |
+
// if(!empty($terms)) {
|
454 |
+
// foreach ($terms as $term) {
|
455 |
+
// if(isset($term->term_id)) {
|
456 |
+
// $hierarchical_terms[] = $term;
|
457 |
+
// $hierarchical_terms = self::add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $term->term_id, 1);
|
458 |
+
// }
|
459 |
+
// }
|
460 |
+
// }
|
461 |
+
//
|
462 |
+
// return $hierarchical_terms;
|
463 |
$terms = get_terms( array(
|
464 |
'taxonomy' => $taxonomy,
|
465 |
'hide_empty' => false,
|
466 |
'parent' => 0,
|
467 |
+
'orderby' => 'meta_value_num',
|
468 |
+
'order' => 'ASC',
|
469 |
+
'update_count_callback' => '_update_generic_term_count',
|
470 |
+
'meta_query' => [[
|
471 |
+
'key' => 'wcp_custom_order',
|
472 |
+
'type' => 'NUMERIC',
|
473 |
+
]]
|
474 |
+
));
|
475 |
$hierarchical_terms = array();
|
476 |
+
foreach ($terms as $term) {
|
477 |
+
$hierarchical_terms[] = $term;
|
478 |
+
$hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, "-");
|
|
|
|
|
|
|
|
|
479 |
}
|
480 |
+
return $hierarchical_terms;
|
481 |
+
}
|
482 |
|
483 |
+
public static function get_child_terms($taxonomy, $hierarchical_terms, $term_id, $separator = "-") {
|
484 |
+
$terms = get_terms( array(
|
485 |
+
'taxonomy' => $taxonomy,
|
486 |
+
'hide_empty' => false,
|
487 |
+
'parent' => $term_id,
|
488 |
+
'orderby' => 'meta_value_num',
|
489 |
+
'order' => 'ASC',
|
490 |
+
'update_count_callback' => '_update_generic_term_count',
|
491 |
+
'meta_query' => [[
|
492 |
+
'key' => 'wcp_custom_order',
|
493 |
+
'type' => 'NUMERIC',
|
494 |
+
]]
|
495 |
+
));
|
496 |
+
foreach ($terms as $term) {
|
497 |
+
$term->name = $separator." ".$term->name;
|
498 |
+
$hierarchical_terms[] = $term;
|
499 |
+
$hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, $separator."-");
|
500 |
+
}
|
501 |
return $hierarchical_terms;
|
502 |
}
|
503 |
|
972 |
$taxonomy = self::sanitize_options($postData['taxonomy']);
|
973 |
}
|
974 |
if (is_array($postArray)) {
|
975 |
+
$post_type = self::get_custom_post_type($type);
|
976 |
foreach ($postArray as $post) {
|
977 |
+
$terms = get_the_terms($post, $post_type);
|
978 |
+
if (!empty($terms)) {
|
979 |
+
foreach ($terms as $term) {
|
980 |
+
if(!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
|
981 |
+
wp_remove_object_terms($post, $term->term_id, $post_type);
|
982 |
+
}
|
983 |
+
}
|
984 |
}
|
985 |
wp_set_post_terms($post, $folderID, $post_type, $status);
|
986 |
}
|
1042 |
$terms = get_the_terms($postID, $folder_post_type);
|
1043 |
if (!empty($terms)) {
|
1044 |
foreach ($terms as $term) {
|
1045 |
+
if(!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
|
1046 |
wp_remove_object_terms($postID, $term->term_id, $folder_post_type);
|
1047 |
}
|
1048 |
}
|
1475 |
$rename_nonce = wp_create_nonce('wcp_folder_rename_term_'.$result['term_id']);
|
1476 |
$highlight_nonce = wp_create_nonce('wcp_folder_highlight_term_'.$result['term_id']);
|
1477 |
$term_nonce = wp_create_nonce('wcp_folder_term_'.$result['term_id']);
|
1478 |
+
$string = "<li data-nonce='{$term_nonce}' data-star='{$highlight_nonce}' data-rename='{$rename_nonce}' data-delete='{$delete_nonce}' data-slug='{$result['term_id']}' class='ui-state-default route new-folders' id='wcp_folder_{$result['term_id']}' data-folder-id='{$result['term_id']}'><h3 class='title is-new-item' id='title_{$result['term_id']}'><span class='title-text'>{$postData['name']}</span> <span class='update-inline-record'></span><span class='star-icon'></span> </h3><span class='nav-icon'><i class='wcp-icon folder-icon-arrow_right'></i></span><span class='ui-icon'><i class='wcp-icon folder-icon-folder'></i></span> <ul class='space' id='space_{$result['term_id']}'>";
|
1479 |
$string .= "</ul></li>";
|
1480 |
$response['term_data'] = $string;
|
1481 |
$response['parent_id'] = $parent;
|
1482 |
+
$response['term_id'] = $result['term_id'];
|
1483 |
|
1484 |
$is_active = 1;
|
1485 |
$folders = -1;
|
includes/form.class.php
CHANGED
@@ -12,7 +12,13 @@ class WCP_Forms {
|
|
12 |
<div class="wcp-custom-form">
|
13 |
<div class="form-title">
|
14 |
<?php esc_html_e("Folders", WCP_FOLDER) ?>
|
15 |
-
<a href="javascript:;" class="add-new-folder" id="add-new-folder"
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
<div class="clear"></div>
|
17 |
</div>
|
18 |
<div class="form-options">
|
12 |
<div class="wcp-custom-form">
|
13 |
<div class="form-title">
|
14 |
<?php esc_html_e("Folders", WCP_FOLDER) ?>
|
15 |
+
<a href="javascript:;" class="add-new-folder" id="add-new-folder">
|
16 |
+
<span class="folder-icon-create_new_folder"></span>
|
17 |
+
<span><?php esc_html_e("New Folder", WCP_FOLDER) ?></span>
|
18 |
+
</a>
|
19 |
+
<span class="folder-loader-ajax">
|
20 |
+
<img src="<?php echo esc_url(admin_url('/images/spinner.gif')); ?>" alt="">
|
21 |
+
</span>
|
22 |
<div class="clear"></div>
|
23 |
</div>
|
24 |
<div class="form-options">
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: galdub, tomeraharon, premio
|
|
3 |
Tags: folder, folders, organize, pages folders, media library, posts folders, media folders, subfolders, file manager, directories
|
4 |
Requires at least: 3.0.0
|
5 |
Tested up to: 5.2
|
6 |
-
Stable tag: 2.2.
|
7 |
Plugin URI: https://premio.io/downloads/folders/
|
8 |
|
9 |
Folders is a WordPress plugin that will help you quickly organize and manage all of your Pages, Posts and Media library files in folders.
|
@@ -133,6 +133,9 @@ A live demo for the Folders plugin is available at <a href="https://demo.premio.
|
|
133 |
|
134 |
== Changelog ==
|
135 |
|
|
|
|
|
|
|
136 |
= 2.2.4 =
|
137 |
Class variable folder fixes
|
138 |
|
3 |
Tags: folder, folders, organize, pages folders, media library, posts folders, media folders, subfolders, file manager, directories
|
4 |
Requires at least: 3.0.0
|
5 |
Tested up to: 5.2
|
6 |
+
Stable tag: 2.2.5
|
7 |
Plugin URI: https://premio.io/downloads/folders/
|
8 |
|
9 |
Folders is a WordPress plugin that will help you quickly organize and manage all of your Pages, Posts and Media library files in folders.
|
133 |
|
134 |
== Changelog ==
|
135 |
|
136 |
+
= 2.2.5 =
|
137 |
+
Folders is much faster and smoother now. We've also fixed a media library resolution bug for Mac+Safari
|
138 |
+
|
139 |
= 2.2.4 =
|
140 |
Class variable folder fixes
|
141 |
|