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

Version Description

  • You don't need to hit the "Organize" button each time you drag media files now, once you click on it you get into "Organize mode" until you click on the "Cancel" button + when you upload new media files you can select the folder in advance + fixed the hidden div thanks @nubess
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.1.5
Comparing to
See all releases

Code changes from version 2.1.4 to 2.1.5

assets/css/design.css CHANGED
@@ -254,6 +254,9 @@ button#wcp-save-folder {
254
  background: #dfdfdf;
255
  cursor: pointer;
256
  }
 
 
 
257
  .add-new-folder {
258
  text-decoration: none;
259
  display: block;
@@ -513,6 +516,18 @@ td.wcp_move.column-wcp_move {
513
  .ui-draggable-dragging {
514
  z-index: 1051 !important;
515
  }
 
 
 
 
 
 
 
 
 
 
 
 
516
  span.wcp-item {
517
  display: none;
518
  }
@@ -525,17 +540,6 @@ span.wcp-item {
525
  border: solid 1px #fff;
526
  position: relative;
527
  }
528
- .wcp-hover-list {
529
- background: #008ec2 !important;
530
- color: #fff;
531
- position: relative;
532
- }
533
- .wcp-hover-list a {
534
- color: #fff;
535
- }
536
- .wcp-hover-list span.total-count {
537
- color: #000;
538
- }
539
  .tree-structure .folder-view {
540
  display: block;
541
  border: 1px solid #dadce0;
@@ -865,6 +869,68 @@ button.button.organize-button:hover, button.button.organize-button:focus {
865
  color: #ffffff;
866
  border: solid 1px #bc0f50;
867
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
868
  @media screen and (max-width: 1300px) {
869
  .tree-structure li {
870
  width: 20%;
254
  background: #dfdfdf;
255
  cursor: pointer;
256
  }
257
+ body.no-hover-css .wcp-container .route .title:hover {
258
+ background: transparent;
259
+ }
260
  .add-new-folder {
261
  text-decoration: none;
262
  display: block;
516
  .ui-draggable-dragging {
517
  z-index: 1051 !important;
518
  }
519
+
520
+ .wcp-hover-list {
521
+ background: #008ec2 !important;
522
+ color: #fff;
523
+ position: relative;
524
+ }
525
+ .wcp-hover-list a {
526
+ color: #fff;
527
+ }
528
+ .wcp-hover-list span.total-count {
529
+ color: #000;
530
+ }
531
  span.wcp-item {
532
  display: none;
533
  }
540
  border: solid 1px #fff;
541
  position: relative;
542
  }
 
 
 
 
 
 
 
 
 
 
 
543
  .tree-structure .folder-view {
544
  display: block;
545
  border: 1px solid #dadce0;
869
  color: #ffffff;
870
  border: solid 1px #bc0f50;
871
  }
872
+ .tree-structure-content ul {
873
+ margin: 0;
874
+ padding: 0;
875
+ }
876
+ .tree-structure-content {
877
+ padding: 10px 20px 10px;
878
+ background: #fff;
879
+ margin: 10px 0 15px;
880
+ border-radius: 4px;
881
+ -moz-border-radius: 4px;
882
+ -webkit-border-radius: 4px;
883
+ border: solid 1px #cccccc;
884
+ }
885
+ .tree-structure-content .tree-structure {
886
+ height: 55px;
887
+ overflow: hidden;
888
+ transition: 0.1s;
889
+ -webkit-transition: 0.1s;
890
+ -moz-transition: 0.1s;
891
+ }
892
+ .tree-structure-content.active .tree-structure {
893
+ height: auto;
894
+ }
895
+ .folders-toggle-button {
896
+ height: 15px;
897
+ text-align: center;
898
+ position: relative;
899
+ }
900
+ .folders-toggle-button span {
901
+ background: #F51366;
902
+ color: #fff;
903
+ height: 20px;
904
+ width: 30px;
905
+ text-align: center;
906
+ display: block;
907
+ margin: 0 auto;
908
+ position: absolute;
909
+ left: 0;
910
+ right: 0;
911
+ bottom: -10px;
912
+ cursor: pointer;
913
+ font-family: dashicons;
914
+ font-size: 20px;
915
+ line-height: 20px;
916
+ }
917
+ .folders-toggle-button span:after {
918
+ content: "\f347";
919
+ }
920
+ .tree-structure-content.active .folders-toggle-button span:after {
921
+ content: "\f343";
922
+ }
923
+ span.media-info-message {
924
+ vertical-align: middle;
925
+ line-height: 50px;
926
+ font-weight: bold;
927
+ color: #f51366;
928
+ padding: 0 0 0 20px;
929
+ display: none !important;;
930
+ }
931
+ span.media-info-message.active {
932
+ display: inline-block !important;
933
+ }
934
  @media screen and (max-width: 1300px) {
935
  .tree-structure li {
936
  width: 20%;
assets/css/media.css CHANGED
@@ -4,7 +4,7 @@
4
  }
5
  .media-modal-content .media-frame select.attachment-filters {
6
  width: auto;
7
- max-width: 135px;
8
  }
9
  #media-attachment-taxonomy-filter {
10
  border: solid 1px #FF5983;
4
  }
5
  .media-modal-content .media-frame select.attachment-filters {
6
  width: auto;
7
+ max-width: 150px;
8
  }
9
  #media-attachment-taxonomy-filter {
10
  border: solid 1px #FF5983;
assets/js/custom.js CHANGED
@@ -291,16 +291,17 @@ jQuery(document).ready(function(){
291
  selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
292
  return jQuery("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
293
  },
294
- start: function (event, ui) {
295
-
296
  },
297
  cursor: "move",
298
  cursorAt: {
299
  left: 0,
300
  top: 0
301
  },
302
- stop: function (event, ui) {
303
  jQuery(".selected-items").remove();
 
304
  }
305
  });
306
  jQuery(this).draggable("disable");
@@ -567,9 +568,11 @@ jQuery(document).ready(function(){
567
  cursor: "move",
568
  start: function( event, ui){
569
  jQuery(this).closest("td").addClass("wcp-draggable");
 
570
  },
571
  stop: function( event, ui ) {
572
  jQuery(this).closest("td").removeClass("wcp-draggable");
 
573
  }
574
  });
575
  });
@@ -579,7 +582,13 @@ jQuery(document).ready(function(){
579
  revert: "invalid",
580
  containment: "document",
581
  helper: "clone",
582
- cursor: "move"
 
 
 
 
 
 
583
  });
584
 
585
  jQuery("h3.title").livequery(function(){
@@ -1047,15 +1056,12 @@ function calcWidth(obj){
1047
 
1048
  }
1049
 
1050
-
1051
  /* code for sticky menu for media screen*/
1052
 
1053
  if(wcp_settings.post_type == "attachment") {
1054
-
1055
-
1056
-
1057
  jQuery(window).load(function() {
1058
  jQuery("button.button.media-button.select-mode-toggle-button").after("<button class='button organize-button'>Organize</button>");
 
1059
  if(jQuery(".wcp-custom-form").length) {
1060
  if (wp.Uploader !== undefined) {
1061
  wp.Uploader.queue.on('reset', function () {
@@ -1069,6 +1075,24 @@ if(wcp_settings.post_type == "attachment") {
1069
  }
1070
  });
1071
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1072
  });
1073
 
1074
  function resetMediaData(loadData) {
@@ -1114,10 +1138,62 @@ if(wcp_settings.post_type == "attachment") {
1114
  setMediaBoxWidth();
1115
  });
1116
 
 
 
 
 
1117
  jQuery(document).on("click", ".button.organize-button", function(){
 
 
 
 
 
1118
  jQuery("button.button.media-button.select-mode-toggle-button").trigger("click");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1119
  });
1120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1121
  function setStickyHeaderForMedia() {
1122
  if(!jQuery(".media-position").length) {
1123
  jQuery(".media-frame-content .media-toolbar").before("<div class='media-position'></div>")
291
  selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
292
  return jQuery("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
293
  },
294
+ start: function( event, ui){
295
+ jQuery("body").addClass("no-hover-css");
296
  },
297
  cursor: "move",
298
  cursorAt: {
299
  left: 0,
300
  top: 0
301
  },
302
+ stop: function( event, ui ) {
303
  jQuery(".selected-items").remove();
304
+ jQuery("body").removeClass("no-hover-css");
305
  }
306
  });
307
  jQuery(this).draggable("disable");
568
  cursor: "move",
569
  start: function( event, ui){
570
  jQuery(this).closest("td").addClass("wcp-draggable");
571
+ jQuery("body").addClass("no-hover-css");
572
  },
573
  stop: function( event, ui ) {
574
  jQuery(this).closest("td").removeClass("wcp-draggable");
575
+ jQuery("body").removeClass("no-hover-css");
576
  }
577
  });
578
  });
582
  revert: "invalid",
583
  containment: "document",
584
  helper: "clone",
585
+ cursor: "move",
586
+ start: function( event, ui){
587
+ jQuery("body").addClass("no-hover-css");
588
+ },
589
+ stop: function( event, ui ) {
590
+ jQuery("body").removeClass("no-hover-css");
591
+ }
592
  });
593
 
594
  jQuery("h3.title").livequery(function(){
1056
 
1057
  }
1058
 
 
1059
  /* code for sticky menu for media screen*/
1060
 
1061
  if(wcp_settings.post_type == "attachment") {
 
 
 
1062
  jQuery(window).load(function() {
1063
  jQuery("button.button.media-button.select-mode-toggle-button").after("<button class='button organize-button'>Organize</button>");
1064
+ jQuery(".media-toolbar-secondary").append("<span class='media-info-message'>Drag and drop your media files to the relevant folders</span>");
1065
  if(jQuery(".wcp-custom-form").length) {
1066
  if (wp.Uploader !== undefined) {
1067
  wp.Uploader.queue.on('reset', function () {
1075
  }
1076
  });
1077
  }
1078
+ setTimeout(function(){
1079
+ docReferrar = document.referrer;
1080
+ if(docReferrar.indexOf("wp-admin/upload.php") != -1) {
1081
+ mediaMode = getCookie("media-select-mode");
1082
+ if (mediaMode === "on") {
1083
+ jQuery("button.button.media-button.select-mode-toggle-button").trigger("click");
1084
+ jQuery(".attachments-browser li.attachment").draggable("enable");
1085
+
1086
+ if (jQuery(".media-frame").hasClass("mode-select")) {
1087
+ jQuery(".media-info-message").addClass("active");
1088
+ } else {
1089
+ jQuery(".media-info-message").removeClass("active");
1090
+ }
1091
+ }
1092
+ } else {
1093
+ eraseCookie("media-select-mode");
1094
+ }
1095
+ }, 1000)
1096
  });
1097
 
1098
  function resetMediaData(loadData) {
1138
  setMediaBoxWidth();
1139
  });
1140
 
1141
+ jQuery(document).ready(function(){
1142
+
1143
+ });
1144
+
1145
  jQuery(document).on("click", ".button.organize-button", function(){
1146
+ if(!jQuery(".media-frame").hasClass("mode-select")) {
1147
+ setCookie("media-select-mode", "on", 7);
1148
+ } else {
1149
+ eraseCookie("media-select-mode");
1150
+ }
1151
  jQuery("button.button.media-button.select-mode-toggle-button").trigger("click");
1152
+ if(jQuery(".media-frame").hasClass("mode-select")) {
1153
+ jQuery(".media-info-message").addClass("active");
1154
+ } else {
1155
+ jQuery(".media-info-message").removeClass("active");
1156
+ }
1157
+ });
1158
+
1159
+ jQuery(document).on("click", ".select-mode-toggle-button", function(){
1160
+ setTimeout(function() {
1161
+ if(!jQuery(".media-frame").hasClass("mode-select")) {
1162
+ setCookie("media-select-mode", "off", -1);
1163
+ }
1164
+ if(jQuery(".media-frame").hasClass("mode-select")) {
1165
+ jQuery(".media-info-message").addClass("active");
1166
+ } else {
1167
+ jQuery(".media-info-message").removeClass("active");
1168
+ }
1169
+ }, 10);
1170
  });
1171
 
1172
+ function setCookie(name,value,days) {
1173
+ var expires = "";
1174
+ if (days) {
1175
+ var date = new Date();
1176
+ date.setTime(date.getTime() + (days*24*60*60*1000));
1177
+ expires = "; expires=" + date.toUTCString();
1178
+ }
1179
+ document.cookie = name + "=" + (value || "") + expires + "; path=/";
1180
+ }
1181
+ function getCookie(name) {
1182
+ var nameEQ = name + "=";
1183
+ var ca = document.cookie.split(';');
1184
+ for(var i=0;i < ca.length;i++) {
1185
+ var c = ca[i];
1186
+ while (c.charAt(0)==' ') c = c.substring(1,c.length);
1187
+ if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
1188
+ }
1189
+ return null;
1190
+ }
1191
+
1192
+
1193
+ function eraseCookie(name) {
1194
+ document.cookie = name+'=; Max-Age=-99999999;';
1195
+ }
1196
+
1197
  function setStickyHeaderForMedia() {
1198
  if(!jQuery(".media-position").length) {
1199
  jQuery(".media-frame-content .media-toolbar").before("<div class='media-position'></div>")
assets/js/media.js CHANGED
@@ -90,4 +90,37 @@
90
  };
91
  }())
92
  });
93
- })(jQuery, _);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  };
91
  }())
92
  });
93
+ })(jQuery, _);
94
+
95
+ var selectedFolderMediaId = -1;
96
+
97
+ jQuery(document).on("change", ".folder_for_media", function(){
98
+ selectedFolderMediaId = $(this).val();
99
+ });
100
+
101
+
102
+ var wp = window.wp;
103
+ //Upload on page Media Library (upload.php)
104
+ if (typeof wp !== 'undefined' && typeof wp.Uploader === 'function') {
105
+ jQuery.extend(wp.Uploader.prototype, {
106
+ progress: function () {
107
+ },
108
+ init: function () {
109
+ if (this.uploader) {
110
+ this.uploader.bind('FileFiltered', function (up, file) {
111
+ });
112
+ this.uploader.bind('BeforeUpload', function (uploader, file) {
113
+ var folder_id = selectedFolderMediaId;
114
+ var params = uploader.settings.multipart_params;
115
+ folder_id = parseInt(folder_id);
116
+ if (folder_id > 0) {
117
+ params.folder_for_media = folder_id;
118
+ }
119
+ });
120
+ this.uploader.bind('UploadComplete', function (up, files) {
121
+ selectedFolderMediaId = -1;
122
+ });
123
+ }
124
+ }
125
+ });
126
+ }
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.1.4
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.1.3");
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.1.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.1.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
@@ -91,6 +91,137 @@ class WCP_Folders
91
 
92
  /* to filter un assigned items*/
93
  add_filter('pre_get_posts', array($this, 'filter_record_list'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
 
96
  public function wcp_remove_post_folder() {
@@ -235,12 +366,12 @@ class WCP_Folders
235
  }
236
 
237
  public function output_backbone_view_filters() {
238
- wp_enqueue_script( 'folders-media', WCP_FOLDER_URL.'assets/js/media.js', array( 'media-editor', 'media-views' ), false, true );
239
  wp_localize_script( 'folders-media', 'folders_media_options', array(
240
  'terms' => self::get_terms_hierarchical('media_folder'),
241
  'taxonomy' => get_taxonomy('media_folder')
242
  ));
243
- wp_enqueue_style( 'folders-media', WCP_FOLDER_URL . 'assets/css/media.css' );
244
  }
245
 
246
  public function get_terms_hierarchical( $taxonomy ) {
@@ -639,49 +770,6 @@ class WCP_Folders
639
  die;
640
  }
641
 
642
- public function wcp_change_folder_display_status()
643
- {
644
- $response = array();
645
- $response['status'] = 0;
646
- $response['error'] = 0;
647
- $response['data'] = array();
648
- $response['message'] = "";
649
- $postData = $_POST;
650
- $errorCounter = 0;
651
- if (!isset($postData['status']) || empty($postData['status'])) {
652
- $response['message'] = __("Your request is not valid", WCP_FOLDER);
653
- $errorCounter++;
654
- } else if (!isset($postData['type']) || empty($postData['type'])) {
655
- $response['message'] = __("Your request is not valid", WCP_FOLDER);
656
- $errorCounter++;
657
- } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
658
- $response['message'] = __("Your request is not valid", WCP_FOLDER);
659
- $errorCounter++;
660
- } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
661
- $response['message'] = __("You have not permission to update width", WCP_FOLDER);
662
- $errorCounter++;
663
- } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
664
- $response['message'] = __("You have not permission to update width", WCP_FOLDER);
665
- $errorCounter++;
666
- } else {
667
- $type = self::sanitize_options($postData['type']);
668
- $nonce = self::sanitize_options($postData['nonce']);
669
- if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
670
- $response['message'] = __("Your request is not valid", WCP_FOLDER);
671
- $errorCounter++;
672
- }
673
- }
674
- if ($errorCounter == 0) {
675
- $type = self::sanitize_options($postData['type']);
676
- $width = self::sanitize_options($postData['status']);
677
- $optionName = "wcp_dynamic_display_status_" . $type;
678
- update_option($optionName, $width);
679
- $response['status'] = 1;
680
- }
681
- echo json_encode($response);
682
- die;
683
- }
684
-
685
  public function wcp_change_post_width()
686
  {
687
  $response = array();
@@ -1640,9 +1728,9 @@ class WCP_Folders
1640
  function folders_admin_styles()
1641
  {
1642
  if (self::is_active_for_screen()) {
1643
- wp_register_style('wcp-folders-fa', plugin_dir_url(dirname(__FILE__)) . 'assets/css/folder-icon.css');
1644
  wp_enqueue_style('wcp-folders-fa');
1645
- wp_register_style('wcp-folders-admin', plugin_dir_url(dirname(__FILE__)) . 'assets/css/design.css');
1646
  wp_enqueue_style('wcp-folders-admin');
1647
  }
1648
  wp_register_style('wcp-css-handle', false);
@@ -1742,8 +1830,8 @@ class WCP_Folders
1742
  {
1743
  if (self::is_active_for_screen()) {
1744
  global $typenow;
1745
- wp_register_script('wcp-folders-alert', plugin_dir_url(dirname(__FILE__)) . 'assets/js/sweetalert.all.min.js');
1746
- wp_register_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)) . 'assets/js/custom.js', array('jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'));
1747
 
1748
  if ($typenow == "attachment") {
1749
  $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
@@ -1870,6 +1958,8 @@ class WCP_Folders
1870
 
1871
  $options = get_option("folders_settings");
1872
 
 
 
1873
  if (in_array("post", $options)) {
1874
  add_filter('manage_posts_columns', array($this, 'wcp_manage_columns_head'));
1875
  add_action('manage_posts_custom_column', array($this, 'wcp_manage_columns_content'), 10, 2);
91
 
92
  /* to filter un assigned items*/
93
  add_filter('pre_get_posts', array($this, 'filter_record_list'));
94
+
95
+ /**/
96
+ add_filter('pre-upload-ui', array($this, 'show_dropdown_on_media_screen'));
97
+
98
+ add_action('add_attachment', array($this, 'add_attachment_category'));
99
+ }
100
+
101
+ public function add_attachment_category($post_ID)
102
+ {
103
+ if(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
104
+ $folder_id = isset($_REQUEST["folder_for_media"]) ? $_REQUEST["folder_for_media"] : null;
105
+ if (!is_null($folder_id)) {
106
+ $folder_id = (int)$folder_id;
107
+ $folder_id = self::sanitize_options($folder_id, "int");
108
+ if ($folder_id > 0) {
109
+ $post_type = self::get_custom_post_type("attachment");
110
+ $term = get_term($folder_id);
111
+ if(!empty($term) && isset($term->slug)) {
112
+ wp_set_object_terms($post_ID, $term->slug, $post_type );
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+
119
+ public function show_dropdown_on_media_screen() {
120
+ if(self::is_for_this_post_type('attachment')) {
121
+ $post_type = self::get_custom_post_type('attachment');
122
+ if(!class_exists('WCP_Tree')) {
123
+ $files = array(
124
+ 'WCP_Tree' => WCP_DS . "includes" . WCP_DS . "tree.class.php"
125
+ );
126
+
127
+ foreach ($files as $file) {
128
+ if (file_exists(dirname(dirname(__FILE__)) . $file)) {
129
+ include_once dirname(dirname(__FILE__)) . $file;
130
+ }
131
+ }
132
+ }
133
+ $options = WCP_Tree::get_folder_option_data($post_type);;
134
+ echo '<p class="attachments-category">'.esc_html__("Select a folder (Optional)", WCP_FOLDER).'<br/></p>
135
+ <p>
136
+ <select name="folder_for_media" class="folder_for_media"><option value="-1">- '.esc_html__('Uncategorized', WCP_FOLDER).'</option>'.$options.'</select>
137
+ </p>';
138
+ }
139
+ }
140
+
141
+ public function wcp_hide_folders()
142
+ {
143
+ $response = array();
144
+ $response['status'] = 0;
145
+ $response['error'] = 0;
146
+ $response['data'] = array();
147
+ $response['message'] = "";
148
+ $postData = $_POST;
149
+ $errorCounter = 0;
150
+ if (!isset($postData['status']) || empty($postData['status'])) {
151
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
152
+ $errorCounter++;
153
+ } else if (!isset($postData['type']) || empty($postData['type'])) {
154
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
155
+ $errorCounter++;
156
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
157
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
158
+ $errorCounter++;
159
+ } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
160
+ $response['message'] = __("You have not permission to update width", WCP_FOLDER);
161
+ $errorCounter++;
162
+ } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
163
+ $response['message'] = __("You have not permission to update width", WCP_FOLDER);
164
+ $errorCounter++;
165
+ } else {
166
+ $type = self::sanitize_options($postData['type']);
167
+ $nonce = self::sanitize_options($postData['nonce']);
168
+ if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
169
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
170
+ $errorCounter++;
171
+ }
172
+ }
173
+ if ($errorCounter == 0) {
174
+ $type = self::sanitize_options($postData['type']);
175
+ $status = self::sanitize_options($postData['status']);
176
+ $optionName = "wcp_folder_display_status_" . $type;
177
+ update_option($optionName, $status);
178
+ $response['status'] = 1;
179
+ }
180
+ echo json_encode($response);
181
+ die;
182
+ }
183
+
184
+ public function wcp_change_folder_display_status()
185
+ {
186
+ $response = array();
187
+ $response['status'] = 0;
188
+ $response['error'] = 0;
189
+ $response['data'] = array();
190
+ $response['message'] = "";
191
+ $postData = $_POST;
192
+ $errorCounter = 0;
193
+ if (!isset($postData['status']) || empty($postData['status'])) {
194
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
195
+ $errorCounter++;
196
+ } else if (!isset($postData['type']) || empty($postData['type'])) {
197
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
198
+ $errorCounter++;
199
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
200
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
201
+ $errorCounter++;
202
+ } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
203
+ $response['message'] = __("You have not permission to update width", WCP_FOLDER);
204
+ $errorCounter++;
205
+ } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
206
+ $response['message'] = __("You have not permission to update width", WCP_FOLDER);
207
+ $errorCounter++;
208
+ } else {
209
+ $type = self::sanitize_options($postData['type']);
210
+ $nonce = self::sanitize_options($postData['nonce']);
211
+ if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
212
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
213
+ $errorCounter++;
214
+ }
215
+ }
216
+ if ($errorCounter == 0) {
217
+ $type = self::sanitize_options($postData['type']);
218
+ $width = self::sanitize_options($postData['status']);
219
+ $optionName = "wcp_dynamic_display_status_" . $type;
220
+ update_option($optionName, $width);
221
+ $response['status'] = 1;
222
+ }
223
+ echo json_encode($response);
224
+ die;
225
  }
226
 
227
  public function wcp_remove_post_folder() {
366
  }
367
 
368
  public function output_backbone_view_filters() {
369
+ wp_enqueue_script( 'folders-media', WCP_FOLDER_URL.'assets/js/media.js', array( 'media-editor', 'media-views' ), WCP_FOLDER_VERSION, true );
370
  wp_localize_script( 'folders-media', 'folders_media_options', array(
371
  'terms' => self::get_terms_hierarchical('media_folder'),
372
  'taxonomy' => get_taxonomy('media_folder')
373
  ));
374
+ wp_enqueue_style( 'folders-media', WCP_FOLDER_URL . 'assets/css/media.css' , array(), WCP_FOLDER_VERSION);
375
  }
376
 
377
  public function get_terms_hierarchical( $taxonomy ) {
770
  die;
771
  }
772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
773
  public function wcp_change_post_width()
774
  {
775
  $response = array();
1728
  function folders_admin_styles()
1729
  {
1730
  if (self::is_active_for_screen()) {
1731
+ wp_register_style('wcp-folders-fa', plugin_dir_url(dirname(__FILE__)) . 'assets/css/folder-icon.css', array(), WCP_FOLDER_VERSION);
1732
  wp_enqueue_style('wcp-folders-fa');
1733
+ wp_register_style('wcp-folders-admin', plugin_dir_url(dirname(__FILE__)) . 'assets/css/design.css', array(), WCP_FOLDER_VERSION);
1734
  wp_enqueue_style('wcp-folders-admin');
1735
  }
1736
  wp_register_style('wcp-css-handle', false);
1830
  {
1831
  if (self::is_active_for_screen()) {
1832
  global $typenow;
1833
+ wp_register_script('wcp-folders-alert', plugin_dir_url(dirname(__FILE__)) . 'assets/js/sweetalert.all.min.js', array(), WCP_FOLDER_VERSION);
1834
+ wp_register_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)) . 'assets/js/custom.js', array('jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION);
1835
 
1836
  if ($typenow == "attachment") {
1837
  $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
1958
 
1959
  $options = get_option("folders_settings");
1960
 
1961
+ $options = is_array($options)?$options:array();
1962
+
1963
  if (in_array("post", $options)) {
1964
  add_filter('manage_posts_columns', array($this, 'wcp_manage_columns_head'));
1965
  add_action('manage_posts_custom_column', array($this, 'wcp_manage_columns_content'), 10, 2);
includes/tree.class.php CHANGED
@@ -81,7 +81,7 @@ class WCP_Tree {
81
  return $string;
82
  }
83
 
84
- public static function get_folder_option_data($post_type, $parent = 0, $space) {
85
  $terms = get_terms( $post_type, array(
86
  'hide_empty' => false,
87
  'parent' => $parent,
@@ -94,10 +94,14 @@ class WCP_Tree {
94
  ]]
95
  ) );
96
 
 
 
 
97
  $string = "";
98
  if(!empty($terms)) {
99
  foreach($terms as $term) {
100
- $string .= "<option value='{$term->term_id}'>{$space}{$term->name}</option>";
 
101
  $string .= self::get_folder_option_data($post_type, $term->term_id, $space."&nbsp&nbsp");
102
  }
103
  }
81
  return $string;
82
  }
83
 
84
+ public static function get_folder_option_data($post_type, $parent = 0, $space = "") {
85
  $terms = get_terms( $post_type, array(
86
  'hide_empty' => false,
87
  'parent' => $parent,
94
  ]]
95
  ) );
96
 
97
+ $selected_term = get_option("selected_" . $post_type . "_folder");
98
+
99
+
100
  $string = "";
101
  if(!empty($terms)) {
102
  foreach($terms as $term) {
103
+ $selected = ($selected_term == $term->term_id)?"selected":"";
104
+ $string .= "<option {$selected} value='{$term->term_id}'>{$space}{$term->name}</option>";
105
  $string .= self::get_folder_option_data($post_type, $term->term_id, $space."&nbsp&nbsp");
106
  }
107
  }
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.1.4
7
  Plugin URI: https://premio.io/downloads/folders/
8
 
9
  Folders is a FREE WordPress plugin that will help you quickly organize and manage all of your Pages, Posts and Media library files in folders.
@@ -127,6 +127,9 @@ A live demo for the Folders plugin is available at <a href="https://demo.premio.
127
 
128
  == Changelog ==
129
 
 
 
 
130
  = 2.1.4 =
131
  * Move one media file/post/page/custom post to more than one folder + quick edit bug fix :)
132
 
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.1.5
7
  Plugin URI: https://premio.io/downloads/folders/
8
 
9
  Folders is a FREE WordPress plugin that will help you quickly organize and manage all of your Pages, Posts and Media library files in folders.
127
 
128
  == Changelog ==
129
 
130
+ = 2.1.5 =
131
+ * You don't need to hit the "Organize" button each time you drag media files now, once you click on it you get into "Organize mode" until you click on the "Cancel" button + when you upload new media files you can select the folder in advance + fixed the hidden div thanks @nubess
132
+
133
  = 2.1.4 =
134
  * Move one media file/post/page/custom post to more than one folder + quick edit bug fix :)
135