Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager - Version 2.4.3

Version Description

Small bugs fixed including: folder filtering bugs (trash, draft etc), WooCommerce products duplicate bug, quick edit in folders, Media Library Assistant compatibility and more

Download this release

Release Info

Developer galdub
Plugin Icon wp plugin Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager
Version 2.4.3
Comparing to
See all releases

Code changes from version 2.4.2 to 2.4.3

assets/css/design.css CHANGED
@@ -1450,6 +1450,7 @@ select#media-attachment-taxonomy-filter {
1450
  .media-folder-loader > span {
1451
  font-weight: bold;
1452
  }
 
1453
  @media screen and (max-width: 1300px) {
1454
  .tree-structure li {
1455
  width: 20%;
1450
  .media-folder-loader > span {
1451
  font-weight: bold;
1452
  }
1453
+
1454
  @media screen and (max-width: 1300px) {
1455
  .tree-structure li {
1456
  width: 20%;
assets/js/custom.js CHANGED
@@ -3,9 +3,8 @@ var folderID = 0;
3
  var fileAddUpdateStatus = "add";
4
  var fileFolderID = 0;
5
  var folderNameDynamic = "";
6
- var totalFolders = -1;
7
  var isKeyActive = 0;
8
- var folderLimitation = 10;
9
  var nonce = "";
10
  var folderId = 0;
11
  var fID = 0;
@@ -98,12 +97,9 @@ jQuery(document).ready(function(){
98
  jQuery("#space_" + result.parent_id).append(result.term_data);
99
  jQuery("#wcp_folder_" + result.parent_id).addClass("active has-sub-tree");
100
  isKeyActive = parseInt(result.is_key_active);
101
- totalFolders = parseInt(result.folders);
102
- jQuery("#current-folder").text(totalFolders);
103
- if (totalFolders > folderLimitation) {
104
- folderLimitation = totalFolders;
105
- }
106
- jQuery("#total-folder").text(folderLimitation);
107
  checkForExpandCollapse();
108
  add_menu_to_list();
109
  jQuery(".folder-popup-form").hide();
@@ -239,12 +235,9 @@ jQuery(document).ready(function(){
239
  jQuery("#wcp_folder_" + fileFolderID).remove();
240
  jQuery("#folder_" + fileFolderID).remove();
241
  isKeyActive = parseInt(res.is_key_active);
242
- totalFolders = parseInt(res.folders);
243
- jQuery("#current-folder").text(totalFolders);
244
- if (totalFolders > folderLimitation) {
245
- folderLimitation = totalFolders;
246
- }
247
- jQuery("#total-folder").text(folderLimitation);
248
  add_menu_to_list();
249
  ajaxAnimation();
250
  jQuery(".folder-popup-form").hide();
@@ -315,18 +308,14 @@ function removeMultipleFolderItems() {
315
  jQuery(".form-loader-count").css("width", "0px");
316
  if (res.status == '1') {
317
  isKeyActive = parseInt(res.is_key_active);
318
- totalFolders = parseInt(res.folders);
319
- jQuery("#current-folder").text(totalFolders);
320
- if (totalFolders > folderLimitation) {
321
- folderLimitation = totalFolders;
322
- }
323
-
324
  jQuery("#custom-menu input.checkbox:checked").each(function(){
325
  jQuery("#wcp_folder_"+jQuery(this).val()).closest("li.route").remove();
326
  jQuery("#space"+jQuery(this).val()).remove();
327
  });
328
 
329
- jQuery("#total-folder").text(folderLimitation);
330
  // add_menu_to_list();
331
  ajaxAnimation();
332
  jQuery(".folder-popup-form").hide();
@@ -359,17 +348,22 @@ function triggerInlineUpdate() {
359
  jQuery(".form-loader-count").css("width", "0");
360
  if(typeof inlineEditPost == "object") {
361
 
362
- inlineEditPost.init();
363
 
364
- jQuery("#the-list").on("click",".editinline",function(){jQuery(this).attr("aria-expanded","true"),inlineEditPost.edit(this)});
 
 
 
365
  jQuery(document).on("click", ".inline-edit-save .save", function(){
366
  var thisID = jQuery(this).closest("tr").attr("id");
367
  thisID = thisID.replace("edit-","");
 
368
  inlineEditPost.save(thisID);
369
  });
370
  jQuery(document).on("click", ".inline-edit-save .cancel", function(){
371
  var thisID = jQuery(this).closest("tr").attr("id");
372
  thisID = thisID.replace("edit-","");
 
373
  inlineEditPost.revert(thisID);
374
  });
375
  }
@@ -389,8 +383,8 @@ function ajaxAnimation() {
389
  }
390
 
391
  function addFolder() {
392
- if(isKeyActive == 0 && totalFolders >= folderLimitation) {
393
- jQuery("#folder-limitation-message").html("You've reached the "+totalFolders+" folder limitation!");
394
  jQuery("#no-more-folder-credit").show();
395
  return false;
396
  }
@@ -439,13 +433,6 @@ function removeFolderFromID(popup_type) {
439
  removeMessage = "Are you sure you want to delete the selected folders?";
440
  removeNotice = "Items in the selected folders will not be deleted.";
441
  }
442
-
443
- // var totalItems = 0;
444
- // jQuery("#custom-menu input.checkbox:checked").each(function(){
445
- // if(jQuery(this).closest("h3.title").find(".total-count").length) {
446
- // totalItems += parseInt(jQuery(this).closest("h3.title").find(".total-count").text());
447
- // }
448
- // });
449
  }
450
  }
451
  }
@@ -504,14 +491,24 @@ function resetMediaAndPosts() {
504
  }
505
  });
506
  jQuery(".folder-loader-ajax").addClass("active");
507
- jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", false, function (res) {
508
- if (!jQuery(".tree-structure").length) {
509
- jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
510
- }
511
- add_active_item_to_list();
512
- add_menu_to_list();
513
- // triggerInlineUpdate();
514
- });
 
 
 
 
 
 
 
 
 
 
515
  }
516
  }
517
 
@@ -625,7 +622,7 @@ jQuery(document).ready(function(){
625
  }
626
 
627
  isKeyActive = parseInt(wcp_settings.is_key_active);
628
- totalFolders = parseInt(wcp_settings.folders);
629
 
630
  if(wcp_settings.post_type == "attachment") {
631
  jQuery(".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>');
@@ -650,13 +647,21 @@ jQuery(document).ready(function(){
650
  if(!jQuery("#media-attachment-taxonomy-filter").length) {
651
  folderCurrentURL = wcp_settings.page_url + jQuery(this).closest("li.route").data("slug");
652
  jQuery(".form-loader-count").css("width", "100%");
653
- jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
654
- if (!jQuery(".tree-structure").length) {
655
- jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
656
- }
657
- //add_menu_to_list();
658
- triggerInlineUpdate();
659
- });
 
 
 
 
 
 
 
 
660
  } else {
661
  var thisIndex = jQuery(this).closest("li.route").data("folder-id");
662
  jQuery("#media-attachment-taxonomy-filter").val(thisIndex);
@@ -684,14 +689,21 @@ jQuery(document).ready(function(){
684
  if(!jQuery("#media-attachment-taxonomy-filter").length) {
685
  folderCurrentURL = wcp_settings.page_url;
686
  jQuery(".form-loader-count").css("width", "100%");
687
- jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
688
-
689
- if (!jQuery(".tree-structure").length) {
690
- jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
691
- }
692
-
693
- triggerInlineUpdate();
694
- });
 
 
 
 
 
 
 
695
  } else {
696
  jQuery("#media-attachment-taxonomy-filter").val("all");
697
  jQuery("#media-attachment-taxonomy-filter").trigger("change");
@@ -827,14 +839,23 @@ jQuery(document).ready(function(){
827
  if(!jQuery("#media-attachment-taxonomy-filter").length) {
828
  folderCurrentURL = wcp_settings.page_url;
829
  jQuery(".form-loader-count").css("width", "100%");
830
- jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
831
-
832
- if (!jQuery(".tree-structure").length) {
833
- jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
834
- }
835
- add_active_item_to_list();
836
- triggerInlineUpdate();
837
- });
 
 
 
 
 
 
 
 
 
838
  } else {
839
  activeRecordID = "";
840
  jQuery("#media-attachment-taxonomy-filter").val("all");
@@ -851,14 +872,23 @@ jQuery(document).ready(function(){
851
  if(!jQuery("#media-attachment-taxonomy-filter").length) {
852
  folderCurrentURL = wcp_settings.page_url+"-1";
853
  jQuery(".form-loader-count").css("width", "100%");
854
- jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
855
-
856
- if (!jQuery(".tree-structure").length) {
857
- jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
858
- }
859
- add_active_item_to_list();
860
- triggerInlineUpdate();
861
- });
 
 
 
 
 
 
 
 
 
862
  } else {
863
  jQuery("#media-attachment-taxonomy-filter").val("unassigned");
864
  jQuery("#media-attachment-taxonomy-filter").trigger("change");
@@ -1611,6 +1641,12 @@ function calcWidth(obj){
1611
 
1612
  }
1613
 
 
 
 
 
 
 
1614
  /* code for sticky menu for media screen*/
1615
 
1616
  if(wcp_settings.post_type == "attachment") {
@@ -1672,7 +1708,6 @@ if(wcp_settings.post_type == "attachment") {
1672
  jQuery(".attachments-browser li.attachment.selected").each(function(){
1673
  checkStr += jQuery(this).attr("data-id")+",";
1674
  });
1675
- console.log(checkStr);
1676
  if(jQuery(this).val() == "-1") {
1677
  jQuery.ajax({
1678
  url: wcp_settings.ajax_url,
3
  var fileAddUpdateStatus = "add";
4
  var fileFolderID = 0;
5
  var folderNameDynamic = "";
6
+ var n_o_file = -1;
7
  var isKeyActive = 0;
 
8
  var nonce = "";
9
  var folderId = 0;
10
  var fID = 0;
97
  jQuery("#space_" + result.parent_id).append(result.term_data);
98
  jQuery("#wcp_folder_" + result.parent_id).addClass("active has-sub-tree");
99
  isKeyActive = parseInt(result.is_key_active);
100
+ n_o_file = parseInt(result.folders);
101
+ jQuery("#current-folder").text(n_o_file);
102
+ jQuery("#ttl-fldr").text((4*4)-(2*2)-2);
 
 
 
103
  checkForExpandCollapse();
104
  add_menu_to_list();
105
  jQuery(".folder-popup-form").hide();
235
  jQuery("#wcp_folder_" + fileFolderID).remove();
236
  jQuery("#folder_" + fileFolderID).remove();
237
  isKeyActive = parseInt(res.is_key_active);
238
+ n_o_file = parseInt(res.folders);
239
+ jQuery("#current-folder").text(n_o_file);
240
+ jQuery("#ttl-fldr").text((3*3)+(4/(2*2)));
 
 
 
241
  add_menu_to_list();
242
  ajaxAnimation();
243
  jQuery(".folder-popup-form").hide();
308
  jQuery(".form-loader-count").css("width", "0px");
309
  if (res.status == '1') {
310
  isKeyActive = parseInt(res.is_key_active);
311
+ n_o_file = parseInt(res.folders);
312
+ jQuery("#current-folder").text(n_o_file);
 
 
 
 
313
  jQuery("#custom-menu input.checkbox:checked").each(function(){
314
  jQuery("#wcp_folder_"+jQuery(this).val()).closest("li.route").remove();
315
  jQuery("#space"+jQuery(this).val()).remove();
316
  });
317
 
318
+ jQuery("#ttl-fldr").text((4*2)+(4/2));
319
  // add_menu_to_list();
320
  ajaxAnimation();
321
  jQuery(".folder-popup-form").hide();
348
  jQuery(".form-loader-count").css("width", "0");
349
  if(typeof inlineEditPost == "object") {
350
 
351
+ //inlineEditPost.init();
352
 
353
+ jQuery("#the-list").on("click",".editinline",function(){
354
+ jQuery(this).attr("aria-expanded","true");
355
+ inlineEditPost.edit(this);
356
+ });
357
  jQuery(document).on("click", ".inline-edit-save .save", function(){
358
  var thisID = jQuery(this).closest("tr").attr("id");
359
  thisID = thisID.replace("edit-","");
360
+ thisID = thisID.replace("post-","");
361
  inlineEditPost.save(thisID);
362
  });
363
  jQuery(document).on("click", ".inline-edit-save .cancel", function(){
364
  var thisID = jQuery(this).closest("tr").attr("id");
365
  thisID = thisID.replace("edit-","");
366
+ thisID = thisID.replace("post-","");
367
  inlineEditPost.revert(thisID);
368
  });
369
  }
383
  }
384
 
385
  function addFolder() {
386
+ if(isKeyActive == 0 && n_o_file >= ((4*4)-(3*3)+(4/4)+(8/(2*2)))) {
387
+ jQuery("#folder-limitation-message").html("You've "+"reached the "+((4*4)-(2*2)-2)+" folder limitation!");
388
  jQuery("#no-more-folder-credit").show();
389
  return false;
390
  }
433
  removeMessage = "Are you sure you want to delete the selected folders?";
434
  removeNotice = "Items in the selected folders will not be deleted.";
435
  }
 
 
 
 
 
 
 
436
  }
437
  }
438
  }
491
  }
492
  });
493
  jQuery(".folder-loader-ajax").addClass("active");
494
+ if(jQuery("#folder-posts-filter").length) {
495
+ jQuery("#folder-posts-filter").load(folderCurrentURL + " #posts-filter", function () {
496
+ if (!jQuery(".tree-structure").length) {
497
+ jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
498
+ }
499
+ add_active_item_to_list();
500
+ triggerInlineUpdate();
501
+ });
502
+ } else {
503
+ jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", false, function (res) {
504
+ if (!jQuery(".tree-structure").length) {
505
+ jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
506
+ }
507
+ add_active_item_to_list();
508
+ add_menu_to_list();
509
+ // triggerInlineUpdate();
510
+ });
511
+ }
512
  }
513
  }
514
 
622
  }
623
 
624
  isKeyActive = parseInt(wcp_settings.is_key_active);
625
+ n_o_file = parseInt(wcp_settings.folders);
626
 
627
  if(wcp_settings.post_type == "attachment") {
628
  jQuery(".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>');
647
  if(!jQuery("#media-attachment-taxonomy-filter").length) {
648
  folderCurrentURL = wcp_settings.page_url + jQuery(this).closest("li.route").data("slug");
649
  jQuery(".form-loader-count").css("width", "100%");
650
+ if(jQuery("#folder-posts-filter").length) {
651
+ jQuery("#folder-posts-filter").load(folderCurrentURL + " #posts-filter", function () {
652
+ if (!jQuery(".tree-structure").length) {
653
+ jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
654
+ }
655
+ triggerInlineUpdate();
656
+ });
657
+ } else {
658
+ jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
659
+ if (!jQuery(".tree-structure").length) {
660
+ jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
661
+ }
662
+ triggerInlineUpdate();
663
+ });
664
+ }
665
  } else {
666
  var thisIndex = jQuery(this).closest("li.route").data("folder-id");
667
  jQuery("#media-attachment-taxonomy-filter").val(thisIndex);
689
  if(!jQuery("#media-attachment-taxonomy-filter").length) {
690
  folderCurrentURL = wcp_settings.page_url;
691
  jQuery(".form-loader-count").css("width", "100%");
692
+ if(jQuery("#folder-posts-filter").length) {
693
+ jQuery("#folder-posts-filter").load(folderCurrentURL + " #posts-filter", function () {
694
+ if (!jQuery(".tree-structure").length) {
695
+ jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
696
+ }
697
+ triggerInlineUpdate();
698
+ });
699
+ } else {
700
+ jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
701
+ if (!jQuery(".tree-structure").length) {
702
+ jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
703
+ }
704
+ triggerInlineUpdate();
705
+ });
706
+ }
707
  } else {
708
  jQuery("#media-attachment-taxonomy-filter").val("all");
709
  jQuery("#media-attachment-taxonomy-filter").trigger("change");
839
  if(!jQuery("#media-attachment-taxonomy-filter").length) {
840
  folderCurrentURL = wcp_settings.page_url;
841
  jQuery(".form-loader-count").css("width", "100%");
842
+ if(jQuery("#folder-posts-filter").length) {
843
+ jQuery("#folder-posts-filter").load(folderCurrentURL + " #posts-filter", function () {
844
+ if (!jQuery(".tree-structure").length) {
845
+ jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
846
+ }
847
+ add_active_item_to_list();
848
+ triggerInlineUpdate();
849
+ });
850
+ } else {
851
+ jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
852
+ if (!jQuery(".tree-structure").length) {
853
+ jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
854
+ }
855
+ add_active_item_to_list();
856
+ triggerInlineUpdate();
857
+ });
858
+ }
859
  } else {
860
  activeRecordID = "";
861
  jQuery("#media-attachment-taxonomy-filter").val("all");
872
  if(!jQuery("#media-attachment-taxonomy-filter").length) {
873
  folderCurrentURL = wcp_settings.page_url+"-1";
874
  jQuery(".form-loader-count").css("width", "100%");
875
+ if(jQuery("#folder-posts-filter").length) {
876
+ jQuery("#folder-posts-filter").load(folderCurrentURL + " #posts-filter", function () {
877
+ if (!jQuery(".tree-structure").length) {
878
+ jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
879
+ }
880
+ add_active_item_to_list();
881
+ triggerInlineUpdate();
882
+ });
883
+ } else {
884
+ jQuery("#wpbody").load(folderCurrentURL + " #wpbody-content", function () {
885
+ if (!jQuery(".tree-structure").length) {
886
+ jQuery(".wp-header-end").before('<div class="tree-structure"><ul></ul><div class="clear clearfix"></div></div>');
887
+ }
888
+ add_active_item_to_list();
889
+ triggerInlineUpdate();
890
+ });
891
+ }
892
  } else {
893
  jQuery("#media-attachment-taxonomy-filter").val("unassigned");
894
  jQuery("#media-attachment-taxonomy-filter").trigger("change");
1641
 
1642
  }
1643
 
1644
+
1645
+ jQuery(window).load(function() {
1646
+ if(jQuery("#posts-filter").length) {
1647
+ jQuery("#posts-filter").wrap("<div id='folder-posts-filter'></div>");
1648
+ }
1649
+ });
1650
  /* code for sticky menu for media screen*/
1651
 
1652
  if(wcp_settings.post_type == "attachment") {
1708
  jQuery(".attachments-browser li.attachment.selected").each(function(){
1709
  checkStr += jQuery(this).attr("data-id")+",";
1710
  });
 
1711
  if(jQuery(this).val() == "-1") {
1712
  jQuery.ajax({
1713
  url: wcp_settings.ajax_url,
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.4.2
6
  * Author: Premio
7
  * Author URI: https://premio.io/downloads/folders/
8
  * Text Domain: folders
@@ -16,7 +16,7 @@ if(!defined("WCP_FOLDERS_PLUGIN_FILE")) {
16
  }
17
  if(!defined("WCP_FOLDERS_PLUGIN_BASE")) {
18
  define('WCP_FOLDERS_PLUGIN_BASE', plugin_basename(WCP_FOLDERS_PLUGIN_FILE));
19
- }
20
  if(!defined("WCP_FOLDER")) {
21
  define('WCP_FOLDER', 'folders');
22
  }
@@ -30,7 +30,7 @@ if(!defined("WCP_FOLDER_URL")) {
30
  define('WCP_FOLDER_URL', plugin_dir_url(__FILE__));
31
  }
32
  if(!defined("WCP_FOLDER_VERSION")) {
33
- define('WCP_FOLDER_VERSION', "2.4.2");
34
  }
35
 
36
  include_once plugin_dir_path(__FILE__)."includes/folders.class.php";
2
  /**
3
  * Plugin Name: Folders
4
  * Description: Arrange media, pages, custom post types and posts into folders
5
+ * Version: 2.4.3
6
  * Author: Premio
7
  * Author URI: https://premio.io/downloads/folders/
8
  * Text Domain: folders
16
  }
17
  if(!defined("WCP_FOLDERS_PLUGIN_BASE")) {
18
  define('WCP_FOLDERS_PLUGIN_BASE', plugin_basename(WCP_FOLDERS_PLUGIN_FILE));
19
+ }
20
  if(!defined("WCP_FOLDER")) {
21
  define('WCP_FOLDER', 'folders');
22
  }
30
  define('WCP_FOLDER_URL', plugin_dir_url(__FILE__));
31
  }
32
  if(!defined("WCP_FOLDER_VERSION")) {
33
+ define('WCP_FOLDER_VERSION', "2.4.3");
34
  }
35
 
36
  include_once plugin_dir_path(__FILE__)."includes/folders.class.php";
includes/folders.class.php CHANGED
@@ -10,7 +10,7 @@ class WCP_Folders
10
 
11
  private static $folders;
12
 
13
- public $total_folders = 0;
14
 
15
  private static $postIds;
16
 
@@ -133,6 +133,27 @@ class WCP_Folders
133
  add_action( 'plugins_loaded', array( $this, 'folders_text' ) );
134
 
135
  add_filter('get_terms', array( $this, 'get_terms_filter_without_trash'), 10, 3);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
137
 
138
  public function get_terms_filter_without_trash($terms, $taxonomies, $args) {
@@ -185,7 +206,8 @@ class WCP_Folders
185
  $isAjax = (defined('DOING_AJAX') && DOING_AJAX)?1:0;
186
  $options = get_option('folders_settings');
187
  $options = (empty($options) || !is_array($options))?array():$options;
188
- if(!$isAjax && in_array($typenow, $options) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) {
 
189
 
190
  $default_folders = get_option('default_folders');
191
  $default_folders = (empty($default_folders) || !is_array($default_folders))?array():$default_folders;
@@ -297,7 +319,7 @@ class WCP_Folders
297
  <p class="attachments-category"><?php esc_html_e("First select the folder, and the upload the files", WCP_FOLDER) ?><br/></p>
298
  <p>
299
  <select name="folder_for_media" class="folder_for_media">
300
- <option value="-1">- <?php esc_html_e('Uncategorized', WCP_FOLDER) ?></option>
301
  <?php echo $options ?>
302
  <?php if($typenow == "attachment" && isset($current_screen->base) && $current_screen->base == "upload") {?>
303
  <option value="add-folder"><?php esc_html_e('+ Create a New Folder', WCP_FOLDER) ?></option>
@@ -480,9 +502,9 @@ class WCP_Folders
480
 
481
  $post_type = $postData['type'];
482
 
483
- $total_posts = wp_count_posts($post_type)->inherit;
484
 
485
- $empty_items = self::get_total_empty_posts($post_type);
486
 
487
  $post_type = self::get_custom_post_type($post_type);
488
 
@@ -490,7 +512,7 @@ class WCP_Folders
490
 
491
  $response = array(
492
  'status' => 1,
493
- 'total_items' => $total_posts,
494
  'taxonomies' => $taxonomies,
495
  'empty_items' => $empty_items
496
  );
@@ -504,12 +526,12 @@ class WCP_Folders
504
  $post_type = $postData['type'];
505
 
506
  if($post_type != 'attachment') {
507
- $total_posts = self::get_total_posts($post_type);
508
  } else {
509
- $total_posts = wp_count_posts($post_type)->inherit;
510
  }
511
 
512
- $empty_items = self::get_total_empty_posts($post_type);
513
 
514
  $post_type = self::get_custom_post_type($post_type);
515
 
@@ -517,7 +539,7 @@ class WCP_Folders
517
 
518
  $response = array(
519
  'status' => 1,
520
- 'total_items' => $total_posts,
521
  'empty_items' => $empty_items,
522
  'taxonomies' => $taxonomies
523
  );
@@ -564,7 +586,7 @@ class WCP_Folders
564
  return $args;
565
  }
566
 
567
- public function get_total_empty_posts($post_type = "")
568
  {
569
  global $wpdb;
570
 
@@ -572,7 +594,6 @@ class WCP_Folders
572
  $term_table = $wpdb->prefix."term_relationships";
573
  $term_taxonomy_table = $wpdb->prefix."term_taxonomy";
574
  $taxonomy = self::get_custom_post_type($post_type);
575
-
576
  if ($post_type != "attachment") {
577
  $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND (
578
  NOT EXISTS (
@@ -599,10 +620,10 @@ class WCP_Folders
599
 
600
  $query = $wpdb->prepare($query, $taxonomy, $post_type);
601
 
602
- $total_records = $wpdb->get_var($query);
603
 
604
- if(!empty($total_records)) {
605
- return $total_records;
606
  } else {
607
  return 0;
608
  }
@@ -1032,7 +1053,7 @@ class WCP_Folders
1032
  wp_die();
1033
  }
1034
 
1035
- public static function total_term_folders()
1036
  {
1037
  $post_types = get_option(WCP_FOLDER_VAR);
1038
  $post_types = is_array($post_types)?$post_types:array();
@@ -1533,7 +1554,7 @@ class WCP_Folders
1533
  $response['status'] = 1;
1534
  if (!self::check_has_valid_key()) {
1535
  $is_active = 0;
1536
- $folders = self::total_term_folders();
1537
  }
1538
  $response['folders'] = $folders;
1539
  $response['is_key_active'] = $is_active;
@@ -1582,7 +1603,7 @@ class WCP_Folders
1582
  $folders = -1;
1583
  if (!self::check_has_valid_key()) {
1584
  $is_active = 0;
1585
- $folders = self::total_term_folders();
1586
  }
1587
  $response['folders'] = $folders;
1588
  $response['is_key_active'] = $is_active;
@@ -1761,7 +1782,7 @@ class WCP_Folders
1761
  $folders = -1;
1762
  if (!self::check_has_valid_key()) {
1763
  $is_active = 0;
1764
- $folders = self::total_term_folders();
1765
  }
1766
  $response['is_key_active'] = $is_active;
1767
  $response['folders'] = $folders;
@@ -1830,7 +1851,7 @@ class WCP_Folders
1830
  $folders = -1;
1831
  if (!self::check_has_valid_key()) {
1832
  $is_active = 0;
1833
- $folders = self::total_term_folders();
1834
  }
1835
  $response['folders'] = $folders;
1836
  $response['is_key_active'] = $is_active;
@@ -1856,9 +1877,9 @@ class WCP_Folders
1856
 
1857
  self::set_default_values_if_not_exists();
1858
 
1859
- $total_posts = self::get_total_posts($typenow);
1860
 
1861
- $total_empty = self::get_total_empty_posts($typenow);
1862
 
1863
  $folder_type = self::get_custom_post_type($typenow);
1864
  /* Do not change: Free/Pro Class name change */
@@ -1876,7 +1897,7 @@ class WCP_Folders
1876
  }
1877
  }
1878
 
1879
- public function get_total_posts($post_type = "")
1880
  {
1881
  global $typenow;
1882
  if ($post_type == "") {
@@ -2016,24 +2037,24 @@ class WCP_Folders
2016
 
2017
  $old_version = get_option("folder_old_plugin_status");
2018
  if($old_version !== false && $old_version == 1) {
2019
- $total_folders = get_option("folder_old_plugin_folder_status");
2020
- if($total_folders === false) {
2021
- $total = self::total_term_folders();
2022
  if($total <= 10) {
2023
  $total = 10;
2024
  };
2025
  update_option("folder_old_plugin_folder_status", $total);
2026
  self::$folders = $total;
2027
  } else {
2028
- self::$folders = $total_folders;
2029
  }
2030
  }
2031
 
2032
- $total_folders = get_option("folder_old_plugin_folder_status");
2033
- if($total_folders === false) {
2034
  self::$folders = 10;
2035
  } else {
2036
- self::$folders = $total_folders;
2037
  }
2038
  }
2039
 
@@ -2247,7 +2268,7 @@ class WCP_Folders
2247
  $folders = -1;
2248
  if (!self::check_has_valid_key()) {
2249
  $is_active = 0;
2250
- $folders = self::total_term_folders();
2251
  }
2252
  /* For free: upgrade URL, for Pro: Register Key URL */
2253
  $register_url = admin_url("admin.php?page=wcp_folders_upgrade");
@@ -2348,9 +2369,9 @@ class WCP_Folders
2348
  update_option("folder_redirect_status", 1);
2349
  }
2350
 
2351
- public static function get_total_term_folders()
2352
  {
2353
- return self::total_term_folders();
2354
  }
2355
 
2356
  function folders_register_settings()
10
 
11
  private static $folders;
12
 
13
+ public $tlfs = 0;
14
 
15
  private static $postIds;
16
 
133
  add_action( 'plugins_loaded', array( $this, 'folders_text' ) );
134
 
135
  add_filter('get_terms', array( $this, 'get_terms_filter_without_trash'), 10, 3);
136
+
137
+ add_filter('mla_media_modal_query_final_terms', array( $this, 'media_modal_query_final_terms'), 10, 3);
138
+ }
139
+
140
+ public function media_modal_query_final_terms($request) {
141
+ if(isset($_REQUEST['action']) && $_REQUEST['action'] == "mla-query-attachments") {
142
+ $query = isset($_REQUEST['query'])?$_REQUEST['query']:array();
143
+ if(isset($query['media_folder']) && !empty($query['media_folder'])) {
144
+ if($query['media_folder'] == -1) {
145
+ $tax_query = array(
146
+ 'taxonomy' => 'media_folder',
147
+ 'operator' => 'NOT EXISTS',
148
+ );
149
+ $request['tax_query'] = array( $tax_query );
150
+ $request = apply_filters( 'media_library_organizer_media_filter_attachments', $request, $_REQUEST );
151
+ } else {
152
+ $request['media_folder'] = $query['media_folder'];
153
+ }
154
+ }
155
+ }
156
+ return $request;
157
  }
158
 
159
  public function get_terms_filter_without_trash($terms, $taxonomies, $args) {
206
  $isAjax = (defined('DOING_AJAX') && DOING_AJAX)?1:0;
207
  $options = get_option('folders_settings');
208
  $options = (empty($options) || !is_array($options))?array():$options;
209
+ $post_status = filter_input(INPUT_GET, 'post_status', FILTER_SANITIZE_STRING);
210
+ if(empty($post_status) && !$isAjax && in_array($typenow, $options) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) {
211
 
212
  $default_folders = get_option('default_folders');
213
  $default_folders = (empty($default_folders) || !is_array($default_folders))?array():$default_folders;
319
  <p class="attachments-category"><?php esc_html_e("First select the folder, and the upload the files", WCP_FOLDER) ?><br/></p>
320
  <p>
321
  <select name="folder_for_media" class="folder_for_media">
322
+ <option value="-1">- <?php esc_html_e('Unassigned', WCP_FOLDER) ?></option>
323
  <?php echo $options ?>
324
  <?php if($typenow == "attachment" && isset($current_screen->base) && $current_screen->base == "upload") {?>
325
  <option value="add-folder"><?php esc_html_e('+ Create a New Folder', WCP_FOLDER) ?></option>
502
 
503
  $post_type = $postData['type'];
504
 
505
+ $ttpsts = wp_count_posts($post_type)->inherit;
506
 
507
+ $empty_items = self::get_tempt_posts($post_type);
508
 
509
  $post_type = self::get_custom_post_type($post_type);
510
 
512
 
513
  $response = array(
514
  'status' => 1,
515
+ 'total_items' => $ttpsts,
516
  'taxonomies' => $taxonomies,
517
  'empty_items' => $empty_items
518
  );
526
  $post_type = $postData['type'];
527
 
528
  if($post_type != 'attachment') {
529
+ $ttpsts = self::get_ttlpst($post_type);
530
  } else {
531
+ $ttpsts = wp_count_posts($post_type)->inherit;
532
  }
533
 
534
+ $empty_items = self::get_tempt_posts($post_type);
535
 
536
  $post_type = self::get_custom_post_type($post_type);
537
 
539
 
540
  $response = array(
541
  'status' => 1,
542
+ 'total_items' => $ttpsts,
543
  'empty_items' => $empty_items,
544
  'taxonomies' => $taxonomies
545
  );
586
  return $args;
587
  }
588
 
589
+ public function get_tempt_posts($post_type = "")
590
  {
591
  global $wpdb;
592
 
594
  $term_table = $wpdb->prefix."term_relationships";
595
  $term_taxonomy_table = $wpdb->prefix."term_taxonomy";
596
  $taxonomy = self::get_custom_post_type($post_type);
 
597
  if ($post_type != "attachment") {
598
  $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND (
599
  NOT EXISTS (
620
 
621
  $query = $wpdb->prepare($query, $taxonomy, $post_type);
622
 
623
+ $tlrcds = $wpdb->get_var($query);
624
 
625
+ if(!empty($tlrcds)) {
626
+ return $tlrcds;
627
  } else {
628
  return 0;
629
  }
1053
  wp_die();
1054
  }
1055
 
1056
+ public static function ttl_fldrs()
1057
  {
1058
  $post_types = get_option(WCP_FOLDER_VAR);
1059
  $post_types = is_array($post_types)?$post_types:array();
1554
  $response['status'] = 1;
1555
  if (!self::check_has_valid_key()) {
1556
  $is_active = 0;
1557
+ $folders = self::ttl_fldrs();
1558
  }
1559
  $response['folders'] = $folders;
1560
  $response['is_key_active'] = $is_active;
1603
  $folders = -1;
1604
  if (!self::check_has_valid_key()) {
1605
  $is_active = 0;
1606
+ $folders = self::ttl_fldrs();
1607
  }
1608
  $response['folders'] = $folders;
1609
  $response['is_key_active'] = $is_active;
1782
  $folders = -1;
1783
  if (!self::check_has_valid_key()) {
1784
  $is_active = 0;
1785
+ $folders = self::ttl_fldrs();
1786
  }
1787
  $response['is_key_active'] = $is_active;
1788
  $response['folders'] = $folders;
1851
  $folders = -1;
1852
  if (!self::check_has_valid_key()) {
1853
  $is_active = 0;
1854
+ $folders = self::ttl_fldrs();
1855
  }
1856
  $response['folders'] = $folders;
1857
  $response['is_key_active'] = $is_active;
1877
 
1878
  self::set_default_values_if_not_exists();
1879
 
1880
+ $ttpsts = self::get_ttlpst($typenow);
1881
 
1882
+ $ttemp = self::get_tempt_posts($typenow);
1883
 
1884
  $folder_type = self::get_custom_post_type($typenow);
1885
  /* Do not change: Free/Pro Class name change */
1897
  }
1898
  }
1899
 
1900
+ public function get_ttlpst($post_type = "")
1901
  {
1902
  global $typenow;
1903
  if ($post_type == "") {
2037
 
2038
  $old_version = get_option("folder_old_plugin_status");
2039
  if($old_version !== false && $old_version == 1) {
2040
+ $tlfs = get_option("folder_old_plugin_folder_status");
2041
+ if($tlfs === false) {
2042
+ $total = self::ttl_fldrs();
2043
  if($total <= 10) {
2044
  $total = 10;
2045
  };
2046
  update_option("folder_old_plugin_folder_status", $total);
2047
  self::$folders = $total;
2048
  } else {
2049
+ self::$folders = $tlfs;
2050
  }
2051
  }
2052
 
2053
+ $tlfs = get_option("folder_old_plugin_folder_status");
2054
+ if($tlfs === false) {
2055
  self::$folders = 10;
2056
  } else {
2057
+ self::$folders = $tlfs;
2058
  }
2059
  }
2060
 
2268
  $folders = -1;
2269
  if (!self::check_has_valid_key()) {
2270
  $is_active = 0;
2271
+ $folders = self::ttl_fldrs();
2272
  }
2273
  /* For free: upgrade URL, for Pro: Register Key URL */
2274
  $register_url = admin_url("admin.php?page=wcp_folders_upgrade");
2369
  update_option("folder_redirect_status", 1);
2370
  }
2371
 
2372
+ public static function get_ttl_fldrs()
2373
  {
2374
+ return self::ttl_fldrs();
2375
  }
2376
 
2377
  function folders_register_settings()
includes/form.class.php CHANGED
@@ -40,19 +40,16 @@ class WCP_Forms {
40
  </ul>
41
  <div class="upgrade-message">
42
  <?php
43
- $total_folders = get_option("folder_old_plugin_folder_status");
44
- if($total_folders == false || $total_folders < 10) {
45
- $total_folders = 10;
46
  }
47
- $total = WCP_Folders::get_total_term_folders();
48
- if($total > $total_folders) {
49
- $total_folders = $total;
50
  }
51
  ?>
52
- <span class="upgrade-message">You have used <span class='pink' id='current-folder'><?php echo esc_attr($total) ?></span>/<span id='total-folder'><?php echo esc_attr($total_folders) ?></span> Folders. <a class="pink" href="<?php echo esc_url(admin_url("admin.php?page=wcp_folders_upgrade")) ?>"><?php esc_html_e("Upgrade", WCP_FOLDER) ?></a></span>
53
- <script>
54
- folderLimitation = <?php echo esc_attr($total_folders); ?>;
55
- </script>
56
  </div>
57
  </div>
58
  <div class="form-loader">
40
  </ul>
41
  <div class="upgrade-message">
42
  <?php
43
+ $tlfs = get_option("folder_old_plugin_folder_status");
44
+ if($tlfs == false || $tlfs < 10) {
45
+ $tlfs = 10;
46
  }
47
+ $total = WCP_Folders::get_ttl_fldrs();
48
+ if($total > $tlfs) {
49
+ $tlfs = $total;
50
  }
51
  ?>
52
+ <span class="upgrade-message">You have used <span class='pink' id='current-folder'><?php echo esc_attr($total) ?></span>/<span id='ttl-fldr'><?php echo esc_attr($tlfs) ?></span> Folders. <a class="pink" href="<?php echo esc_url(admin_url("admin.php?page=wcp_folders_upgrade")) ?>"><?php esc_html_e("Upgrade", WCP_FOLDER) ?></a></span>
 
 
 
53
  </div>
54
  </div>
55
  <div class="form-loader">
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.3
6
- Stable tag: 2.4.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.
@@ -143,6 +143,9 @@ A live demo for the Folders plugin is available at <a href="https://demo.premio.
143
 
144
  == Changelog ==
145
 
 
 
 
146
  = 2.4.2 =
147
  Added a progress bar when you upload files to the media library folders. You can now track how many files were uploaded in real time. We've also fixed a default folders bug.
148
 
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.3
6
+ Stable tag: 2.4.3
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.
143
 
144
  == Changelog ==
145
 
146
+ = 2.4.3 =
147
+ Small bugs fixed including: folder filtering bugs (trash, draft etc), WooCommerce products duplicate bug, quick edit in folders, Media Library Assistant compatibility and more
148
+
149
  = 2.4.2 =
150
  Added a progress bar when you upload files to the media library folders. You can now track how many files were uploaded in real time. We've also fixed a default folders bug.
151
 
templates/admin/admin-content.php CHANGED
@@ -122,10 +122,10 @@ if(!empty($post_type)) {
122
  <div class="sticky-wcp-custom-form">
123
  <?php echo $form_html ?>
124
  <div class="header-posts">
125
- <a href="javascript:;" class="all-posts <?php echo esc_attr($active_all_class) ?>"><span class="wcp-icon folder-icon-insert_drive_file"></span> <?php esc_attr_e("All ".$title, WCP_FOLDER ) ?> <span class="total-count"><?php echo $total_posts ?></span></a>
126
  </div>
127
  <div class="un-categorised-items <?php echo esc_attr($active) ?>">
128
- <a href="javascript:;" class="un-categorized-posts"><?php esc_attr_e("Unassigned ".$title, WCP_FOLDER) ?> <span class="total-count total-empty"><?php echo $total_empty ?></span> </a>
129
  </div>
130
  </div>
131
  <div id="custom-scroll-menu">
122
  <div class="sticky-wcp-custom-form">
123
  <?php echo $form_html ?>
124
  <div class="header-posts">
125
+ <a href="javascript:;" class="all-posts <?php echo esc_attr($active_all_class) ?>"><span class="wcp-icon folder-icon-insert_drive_file"></span> <?php esc_attr_e("All ".$title, WCP_FOLDER ) ?> <span class="total-count"><?php echo $ttpsts ?></span></a>
126
  </div>
127
  <div class="un-categorised-items <?php echo esc_attr($active) ?>">
128
+ <a href="javascript:;" class="un-categorized-posts"><?php esc_attr_e("Unassigned ".$title, WCP_FOLDER) ?> <span class="total-count total-empty"><?php echo $ttemp ?></span> </a>
129
  </div>
130
  </div>
131
  <div id="custom-scroll-menu">
templates/admin/general-settings.php CHANGED
@@ -183,16 +183,16 @@ defined('ABSPATH') or wp_die('Nope, not accessing this');
183
  <tr>
184
  <td colspan="2" style="padding: 10px 0">
185
  <?php
186
- $total_folders = get_option("folder_old_plugin_folder_status");
187
- if($total_folders == false || $total_folders < 10) {
188
- $total_folders = 10;
189
  }
190
- $total = WCP_Folders::get_total_term_folders();
191
- if($total > $total_folders) {
192
- $total_folders = $total;
193
  }
194
  ?>
195
- <span class="upgrade-message">You have used <span class='pink'><?php echo esc_attr($total) ?></span>/<?php echo esc_attr($total_folders) ?> Folders. <a class="pink" href="<?php echo esc_url(admin_url("admin.php?page=wcp_folders_upgrade")) ?>"><?php esc_html_e("Upgrade", WCP_FOLDER) ?></a></span>
196
  </td>
197
  </tr>
198
 
183
  <tr>
184
  <td colspan="2" style="padding: 10px 0">
185
  <?php
186
+ $tlfs = get_option("folder_old_plugin_folder_status");
187
+ if($tlfs == false || $tlfs < 10) {
188
+ $tlfs = 10;
189
  }
190
+ $total = WCP_Folders::get_ttl_fldrs();
191
+ if($total > $tlfs) {
192
+ $tlfs = $total;
193
  }
194
  ?>
195
+ <span class="upgrade-message">You have used <span class='pink'><?php echo esc_attr($total) ?></span>/<?php echo esc_attr($tlfs) ?> Folders. <a class="pink" href="<?php echo esc_url(admin_url("admin.php?page=wcp_folders_upgrade")) ?>"><?php esc_html_e("Upgrade", WCP_FOLDER) ?></a></span>
196
  </td>
197
  </tr>
198