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

Version Description

  • Some exciting updates including: select relevant folders when you add media, keep your media library toolbar sticky when you organize you media, we support custom posts now, security fixes, bug fixes 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.1.1
Comparing to
See all releases

Code changes from version 2.0.5 to 2.1.1

assets/css/design.css CHANGED
@@ -28,7 +28,7 @@
28
 
29
  .wcp-container .route span {
30
  position: absolute;
31
- top: 0;
32
  left: 0;
33
  z-index: 10;
34
  width: 20px;
@@ -44,14 +44,14 @@
44
  margin: 0;
45
  padding: 0;
46
  padding-top: 0px;
47
- height: 24px;
48
  width: 200px;
49
  text-indent: 30px;
50
  background: transparent;
51
  border-radius: 0px;
52
  box-shadow: none;
53
  font-size: 14px;
54
- line-height: 24px;
55
  border-radius: 4px;
56
  -webkit-border-radius: 4px;
57
  -moz-border-radius: 4px;
@@ -70,8 +70,8 @@
70
  padding: 0;
71
  margin-left: 20px;
72
  width: 30px;
73
- top: 25px;
74
- padding-bottom: 25px;
75
  height: 100%;
76
  z-index: 1;
77
  }
@@ -135,8 +135,7 @@ html[dir="rtl"] body.wp-admin #wpcontent {
135
  padding-right: 320px;
136
  }
137
  .wcp-container {
138
- padding: 20px;
139
- /* overflow: hidden;*/
140
  }
141
  .form-title {
142
  font-size: 23px;
@@ -228,6 +227,7 @@ button#wcp-save-folder {
228
  font-size: 18px;
229
  cursor: move;
230
  left: 5px;
 
231
  }
232
  .route.active-item > span.ui-icon {
233
  background: #008ec2;
@@ -376,8 +376,8 @@ span.total-count {
376
  width: auto;
377
  background: #fff;
378
  display: block;
379
- margin: 3px;
380
- color: #23282d;
381
  line-height: 16px;
382
  height: 16px;
383
  }
@@ -577,6 +577,7 @@ span.wcp-item {
577
  width: auto;
578
  display: inline-block;
579
  font-size: 16px;
 
580
  }
581
  .ui-resizable-handle.ui-resizable-e {
582
  position: absolute;
@@ -614,7 +615,7 @@ div#custom-menu {
614
  }
615
  .wcp-container .route span.star-icon {
616
  position: relative;
617
- top: auto;
618
  left: auto;
619
  float: right;
620
  font-family: 'folder-icon' !important;
@@ -625,10 +626,10 @@ div#custom-menu {
625
  .wcp-container .route span.update-inline-record {
626
  position: relative;
627
  left: auto;
628
- top: auto;
629
  float: right;
630
  width: 0px;
631
- height: 18px;
632
  font-family: 'folder-icon' !important;
633
  font-size: 16px;
634
  overflow: hidden;
@@ -769,6 +770,45 @@ span.upgrade-message a.pink, span.upgrade-message span.pink {
769
  text-decoration: none;
770
  font-weight: bold;
771
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
772
  @media screen and (max-width: 1300px) {
773
  .tree-structure li {
774
  width: 20%;
28
 
29
  .wcp-container .route span {
30
  position: absolute;
31
+ top: 2px;
32
  left: 0;
33
  z-index: 10;
34
  width: 20px;
44
  margin: 0;
45
  padding: 0;
46
  padding-top: 0px;
47
+ height: 30px;
48
  width: 200px;
49
  text-indent: 30px;
50
  background: transparent;
51
  border-radius: 0px;
52
  box-shadow: none;
53
  font-size: 14px;
54
+ line-height: 26px;
55
  border-radius: 4px;
56
  -webkit-border-radius: 4px;
57
  -moz-border-radius: 4px;
70
  padding: 0;
71
  margin-left: 20px;
72
  width: 30px;
73
+ top: 30px;
74
+ padding-bottom: 30px;
75
  height: 100%;
76
  z-index: 1;
77
  }
135
  padding-right: 320px;
136
  }
137
  .wcp-container {
138
+ padding: 20px 20px 20px 16px;
 
139
  }
140
  .form-title {
141
  font-size: 23px;
227
  font-size: 18px;
228
  cursor: move;
229
  left: 5px;
230
+ top: 2px;
231
  }
232
  .route.active-item > span.ui-icon {
233
  background: #008ec2;
376
  width: auto;
377
  background: #fff;
378
  display: block;
379
+ margin: 6px 3px 3px 3px;
380
+ color: #23282d !important;
381
  line-height: 16px;
382
  height: 16px;
383
  }
577
  width: auto;
578
  display: inline-block;
579
  font-size: 16px;
580
+ line-height: 30px;
581
  }
582
  .ui-resizable-handle.ui-resizable-e {
583
  position: absolute;
615
  }
616
  .wcp-container .route span.star-icon {
617
  position: relative;
618
+ top: 2px;
619
  left: auto;
620
  float: right;
621
  font-family: 'folder-icon' !important;
626
  .wcp-container .route span.update-inline-record {
627
  position: relative;
628
  left: auto;
629
+ top: 2px;
630
  float: right;
631
  width: 0px;
632
+ height: 22px;
633
  font-family: 'folder-icon' !important;
634
  font-size: 16px;
635
  overflow: hidden;
770
  text-decoration: none;
771
  font-weight: bold;
772
  }
773
+
774
+ .media-toolbar.sticky-media {
775
+ position: fixed;
776
+ top: 32px;
777
+ right: 18px !important;
778
+ left: auto;
779
+ }
780
+
781
+ .media-position {
782
+ width: 1px;
783
+ height: 1px;
784
+ }
785
+ .media-frame.mode-grid .media-toolbar {
786
+ margin: 0 !important;
787
+ }
788
+ .button-disabled {
789
+ cursor: no-drop;
790
+ pointer-events: none;
791
+ }
792
+ button.button.organize-button {
793
+ vertical-align: middle;
794
+ text-decoration: none;
795
+ display: inline-block;
796
+ font-size: 14px;
797
+ padding: 4px 10px;
798
+ background: #F51366;
799
+ color: #fff;
800
+ border: solid 1px #F51366;
801
+ border-radius: 3px;
802
+ line-height: 14px;
803
+ -webkit-box-shadow: 0 3px 5px -3px #333333;
804
+ -moz-box-shadow: 0 3px 5px -3px #333333;
805
+ box-shadow: 0 3px 5px -3px #333333;
806
+ }
807
+ button.button.organize-button:hover, button.button.organize-button:focus {
808
+ background: #bc0f50;
809
+ color: #ffffff;
810
+ border: solid 1px #bc0f50;
811
+ }
812
  @media screen and (max-width: 1300px) {
813
  .tree-structure li {
814
  width: 20%;
assets/css/media.css ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ .media-modal-content .attachments-browser .media-toolbar-secondary {
2
+ max-width: 66%;
3
+ width: 66%;
4
+ }
5
+ .media-modal-content .media-frame select.attachment-filters {
6
+ width: auto;
7
+ max-width: 150px;
8
+ }
assets/images/owner.png ADDED
Binary file
assets/js/custom.js CHANGED
@@ -36,7 +36,7 @@ function addFolder() {
36
  return false;
37
  }
38
  folderOrder = jQuery("#space_"+fileFolderID+" > li").length+1;
39
- ajaxURL = wcp_settings.ajax_url+"?parent_id=" + fileFolderID + "&type=" + wcp_settings.post_type + "&action=wcp_add_new_folder&term_id=" + fileFolderID + "&order=" + folderOrder+"&name=";
40
  Swal({
41
  title: 'Add Folder',
42
  input: 'text',
@@ -98,7 +98,8 @@ function updateFolder() {
98
  if(parentID == undefined) {
99
  parentID = 0;
100
  }
101
- ajaxURL = wcp_settings.ajax_url+"?parent_id=" + parentID + "&type=" + wcp_settings.post_type + "&action=wcp_update_folder&term_id=" + fileFolderID + "&name=";
 
102
  Swal({
103
  title: 'Update Folder',
104
  input: 'text',
@@ -166,6 +167,10 @@ function add_menu_to_list() {
166
 
167
  jQuery(document).ready(function(){
168
 
 
 
 
 
169
  isKeyActive = parseInt(wcp_settings.is_key_active);
170
  totalFolders = parseInt(wcp_settings.folders);
171
 
@@ -176,10 +181,6 @@ jQuery(document).ready(function(){
176
  }
177
 
178
  calcWidth(jQuery('#title_0'));
179
- window.onresize = function(event) {
180
- console.log("window resized");
181
-
182
- };
183
 
184
  jQuery("#cancel-button").click(function(){
185
  jQuery(".wcp-form-data").hide();
@@ -201,52 +202,72 @@ jQuery(document).ready(function(){
201
  jQuery(".wcp-parent > span").click(function(){
202
  window.location = wcp_settings.page_url
203
  });
204
-
205
- jQuery("h3.title").livequery(function(){
206
  jQuery(this).droppable({
207
  accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
208
  hoverClass: 'wcp-drop-hover',
209
  classes: {
210
  "ui-droppable-active": "ui-state-highlight"
211
  },
212
- drop: function( event, ui ) {
213
  folderID = jQuery(this).closest("li.route").data('folder-id');
214
- if ( ui.draggable.hasClass( 'wcp-move-multiple' ) ) {
215
- if(jQuery(".wp-list-table input:checked").length) {
216
  chkStr = "";
217
- jQuery(".wp-list-table input:checked").each(function(){
218
- chkStr += jQuery(this).val()+",";
219
  });
 
220
  jQuery.ajax({
221
  url: wcp_settings.ajax_url,
222
- data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID,
223
  method: 'post',
224
  success: function (res) {
225
- window.location.reload();
 
 
 
 
 
 
 
 
 
226
  }
227
  });
228
  }
229
- } else if( ui.draggable.hasClass( 'wcp-move-file' ) ){
230
  postID = ui.draggable[0].attributes['data-id'].nodeValue;
 
231
  jQuery.ajax({
232
  url: wcp_settings.ajax_url,
233
- data: "post_id=" + postID + "&type=" + wcp_settings.post_type + "&action=wcp_change_post_folder&folder_id=" + folderID,
234
  method: 'post',
235
  success: function (res) {
236
- window.location.reload();
 
 
 
 
 
 
 
 
 
237
  }
238
  });
239
- } else if( ui.draggable.hasClass( 'attachment' ) ){
240
  chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
241
- if(jQuery(".attachments-browser li.attachment.selected").length > 1) {
 
242
  chkStr = "";
243
- jQuery(".attachments-browser li.attachment.selected").each(function(){
244
- chkStr += jQuery(this).data("id")+",";
245
  });
246
  }
247
  jQuery.ajax({
248
  url: wcp_settings.ajax_url,
249
- data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID,
250
  method: 'post',
251
  success: function (res) {
252
  window.location.reload();
@@ -257,17 +278,17 @@ jQuery(document).ready(function(){
257
  });
258
  });
259
 
260
- jQuery(".attachments-browser li.attachment").livequery(function(){
261
  jQuery(this).draggable({
262
  revert: "invalid",
263
  containment: "document",
264
- helper: function(event, ui){
265
  jQuery(".selected-items").remove();
266
  selectedItems = jQuery(".attachments-browser li.attachment.selected").length;
267
- selectedItems = (selectedItems == 0 || selectedItems == 1)?"1 Item":selectedItems+" Items";
268
- return jQuery("<div class='selected-items'><span class='total-post-count'>"+selectedItems+" Selected</span></div>");
269
  },
270
- start: function( event, ui){
271
 
272
  },
273
  cursor: "move",
@@ -275,22 +296,20 @@ jQuery(document).ready(function(){
275
  left: 0,
276
  top: 0
277
  },
278
- stop: function( event, ui ) {
279
  jQuery(".selected-items").remove();
280
  }
281
  });
282
  jQuery(this).draggable("disable");
283
  });
284
 
285
- jQuery(".media-button").livequery(function(){
286
- jQuery(this).click(function() {
287
-
288
- if(jQuery(".delete-selected-button").hasClass("hidden")) {
289
- jQuery(".attachments-browser li.attachment").draggable( "disable" );
290
  } else {
291
- jQuery(".attachments-browser li.attachment").draggable( "enable" );
292
  }
293
-
294
  });
295
  });
296
 
@@ -298,61 +317,65 @@ jQuery(document).ready(function(){
298
  window.location = wcp_settings.page_url;
299
  });
300
 
301
- jQuery(".tree-structure .folder-item").livequery(function(){
302
- jQuery(this).droppable({
303
- accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
304
- hoverClass: 'wcp-drop-hover-list',
305
- classes: {
306
- "ui-droppable-active": "ui-state-highlight"
307
- },
308
- drop: function( event, ui ) {
309
- console.log(ui);
310
- folderID = jQuery(this).data('id');
311
- if ( ui.draggable.hasClass( 'wcp-move-multiple' ) ) {
312
- if(jQuery(".wp-list-table input:checked").length) {
313
- chkStr = "";
314
- jQuery(".wp-list-table input:checked").each(function(){
315
- chkStr += jQuery(this).val()+",";
316
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  jQuery.ajax({
318
  url: wcp_settings.ajax_url,
319
- data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID,
320
  method: 'post',
321
  success: function (res) {
322
  window.location.reload();
323
  }
324
  });
325
- }
326
- } else if ( ui.draggable.hasClass( 'wcp-move-file' ) ) {
327
- postID = ui.draggable[0].attributes['data-id'].nodeValue;
328
- jQuery.ajax({
329
- url: wcp_settings.ajax_url,
330
- data: "post_id=" + postID + "&type=" + wcp_settings.post_type + "&action=wcp_change_post_folder&folder_id=" + folderID,
331
- method: 'post',
332
- success: function (res) {
333
- window.location.reload();
334
  }
335
- });
336
- } else if( ui.draggable.hasClass( 'attachment' ) ){
337
- chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
338
- if(jQuery(".attachments-browser li.attachment.selected").length > 1) {
339
- chkStr = "";
340
- jQuery(".attachments-browser li.attachment.selected").each(function(){
341
- chkStr += jQuery(this).data("id")+",";
342
  });
343
  }
344
- jQuery.ajax({
345
- url: wcp_settings.ajax_url,
346
- data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID,
347
- method: 'post',
348
- success: function (res) {
349
- window.location.reload();
350
- }
351
- });
352
  }
353
- }
354
  });
355
- });
356
 
357
  jQuery("#expand-collapse-list").click(function(e){
358
  e.stopPropagation();
@@ -372,13 +395,23 @@ jQuery(document).ready(function(){
372
  });
373
  if(folderIDs != "") {
374
  jQuery(".form-loader-count").css("width","100%");
 
375
  jQuery.ajax({
376
  url: wcp_settings.ajax_url,
377
- data: "type=" + wcp_settings.post_type + "&action=wcp_change_all_status&status=" + statusType + "&folders="+folderIDs,
378
  method: 'post',
379
  success: function (res) {
380
  jQuery(".form-loader-count").css("width","0");
381
  add_menu_to_list();
 
 
 
 
 
 
 
 
 
382
  }
383
  });
384
  }
@@ -404,16 +437,18 @@ jQuery(document).ready(function(){
404
  classString += " .space > .route >";
405
  currentWidth = newWidth - (13+(20*i));
406
  cssString += "#custom-menu > "+classString+" .title { width: "+currentWidth+"px !important; } ";
 
407
  }
408
  jQuery("#wcp-custom-style").html("<style>"+cssString+"</style>");
409
  },
410
  stop: function( e, ui ) {
 
411
  jQuery.ajax({
412
  url: wcp_settings.ajax_url,
413
- data: "type=" + wcp_settings.post_type + "&action=wcp_change_post_width&width=" + ui.size.width,
414
  method: 'post',
415
  success: function (res) {
416
-
417
  }
418
  });
419
  }
@@ -444,6 +479,9 @@ jQuery(document).ready(function(){
444
  jQuery("h3.title").livequery(function(){
445
  jQuery(this).on("contextmenu",function(e) {
446
  e.preventDefault();
 
 
 
447
  isHigh = jQuery(this).closest("li.route").hasClass("is-high");
448
  jQuery(".dynamic-menu").remove();
449
  jQuery(".active-menu").removeClass("active-menu");
@@ -483,14 +521,15 @@ jQuery(document).ready(function(){
483
  jQuery(this).click(function(e){
484
  e.stopPropagation();
485
  folderID = jQuery(this).closest("li.route").data("folder-id");
486
- //console.log("folderID :"+ folderID);
487
  jQuery(".form-loader-count").css("width","100%");
488
  jQuery(".dynamic-menu").remove();
489
  jQuery(".active-menu").removeClass("active-menu");
490
  jQuery.ajax({
491
  url: wcp_settings.ajax_url,
492
- data: "term_id=" + folderID + "&type=" + wcp_settings.post_type + "&action=wcp_mark_un_mark_folder",
493
  method: 'post',
 
494
  success: function (res) {
495
  res = jQuery.parseJSON(res);
496
  jQuery(".form-loader-count").css("width","0%");
@@ -500,8 +539,14 @@ jQuery(document).ready(function(){
500
  } else {
501
  jQuery("#wcp_folder_"+res.id).removeClass("is-high");
502
  }
 
 
 
 
 
 
 
503
  }
504
- add_menu_to_list();
505
  }
506
  });
507
  });
@@ -554,6 +599,7 @@ jQuery(document).ready(function(){
554
  fileFolderID = jQuery("#custom-menu li.active-item").data("folder-id");
555
  jQuery(".dynamic-menu").remove();
556
  jQuery(".active-menu").removeClass("active-menu");
 
557
  Swal.fire({
558
  url: wcp_settings.ajax_url,
559
  title: 'Are you sure you want to delete the selected folder?',
@@ -572,16 +618,16 @@ jQuery(document).ready(function(){
572
  });
573
  jQuery.ajax({
574
  url: wcp_settings.ajax_url,
575
- data: "type=" + wcp_settings.post_type + "&action=wcp_remove_folder&term_id=" + fileFolderID,
576
  method: 'post',
577
  success: function (res) {
578
- Swal.fire(
579
- 'Deleted!',
580
- 'Your folder has been deleted.',
581
- 'success'
582
- );
583
  res = jQuery.parseJSON(res);
584
  if (res.status == '1') {
 
 
 
 
 
585
  jQuery("#wcp_folder_"+fileFolderID).remove();
586
  jQuery("#folder_"+fileFolderID).remove();
587
  isKeyActive = parseInt(res.is_key_active);
@@ -592,6 +638,12 @@ jQuery(document).ready(function(){
592
  }
593
  jQuery("#total-folder").text(folderLimitation);
594
  add_menu_to_list();
 
 
 
 
 
 
595
  }
596
  }
597
  });
@@ -600,73 +652,92 @@ jQuery(document).ready(function(){
600
  }
601
  });
602
 
603
- jQuery('.space').livequery(function(){
604
- jQuery(this).sortable({
605
- placeholder: "ui-state-highlight",
606
- connectWith:'.space',
607
- tolerance:'intersect',
608
- over:function(event,ui){
 
609
 
610
- },
611
- update: function( event, ui ) {
612
- thisId = ui.item.context.attributes['data-folder-id'].nodeValue;
613
- orderString = "";
614
- jQuery(this).children().each(function(){
615
- if(jQuery(this).hasClass("route")) {
616
- orderString += jQuery(this).data("folder-id")+",";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
617
  }
618
- });
619
- if(orderString != "") {
620
- jQuery(".form-loader-count").css("width","100%");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
  jQuery.ajax({
622
  url: wcp_settings.ajax_url,
623
- data: "term_ids=" + orderString + "&action=wcp_save_folder_order&&type=" + wcp_settings.post_type,
624
  method: 'post',
625
  success: function (res) {
 
626
  res = jQuery.parseJSON(res);
627
- if (res.status == '1') {
628
- jQuery("#wcp_folder_parent").html(res.options);
629
- jQuery(".form-loader-count").css("width","0");
 
 
 
 
630
  add_menu_to_list();
631
  }
632
  }
633
  });
634
  }
635
- },
636
- receive:function(event, ui){
637
- calcWidth(jQuery(this).siblings('.title'));
638
- check_for_sub_menu();
639
- jQuery(this).closest("li.route").addClass("active");
640
- jQuery(this).closest("li.route").find("ul.ui-sortable:first-child > li").slideDown();
641
- parentId = jQuery(this).closest("li.route").data("folder-id");
642
- thisId = ui.item.context.attributes['data-folder-id'].nodeValue;
643
- if(parentId == undefined) {
644
- parentId = 0;
645
- }
646
- orderString = "";
647
- if(jQuery("#wcp_folder_"+parentId+" .ui-sortable li").length) {
648
- jQuery("#wcp_folder_"+parentId+" .ui-sortable li").each(function(){
649
- orderString += jQuery(this).data("folder-id")+",";
650
- });
651
- } else if(parentId == 0) {
652
- jQuery("#custom-menu > ul.space > li").each(function(){
653
- orderString += jQuery(this).data("folder-id")+",";
654
- });
655
- }
656
- jQuery(".form-loader-count").css("width","100%");
657
- jQuery.ajax({
658
- url: wcp_settings.ajax_url,
659
- data: "term_id=" + thisId + "&action=wcp_update_parent_information&parent_id=" + parentId+"&type=" + wcp_settings.post_type,
660
- method: 'post',
661
- success: function (res) {
662
- jQuery(".form-loader-count").css("width","0%");
663
- add_menu_to_list();
664
- }
665
- });
666
- }
667
  });
668
- jQuery(this).disableSelection();
669
- });
670
  jQuery(".update-inline-record").livequery(function(){
671
  jQuery(this).click(function(e){
672
  e.stopPropagation();
@@ -687,25 +758,40 @@ jQuery(document).ready(function(){
687
  //jQuery(".has-sub-tree:first").addClass("active");
688
  jQuery(".nav-icon").livequery(function(){
689
  jQuery(this).click(function(){
690
- if(jQuery(this).closest("li.route").hasClass("active")) {
691
- jQuery(this).closest("li.route").removeClass("active");
692
- jQuery(this).closest("li.route").find("ul.ui-sortable:first-child > li").slideUp();
693
  folderStatus = 0;
694
  } else {
695
- jQuery(this).closest("li.route").addClass("active");
696
- jQuery(this).closest("li.route").find("ul.ui-sortable:first-child > li").slideDown();
697
  folderStatus = 1;
698
  }
699
- folderID = jQuery(this).closest("li.route").data("folder-id");
700
  jQuery(".form-loader-count").css("width","100%");
 
701
  checkForExpandCollapse();
702
  jQuery.ajax({
703
  url: wcp_settings.ajax_url,
704
- data: "is_active=" + folderStatus + "&action=save_wcp_folder_state&term_id=" + folderID,
705
  method: 'post',
706
  success: function (res) {
707
  jQuery(".form-loader-count").css("width","0");
708
- add_menu_to_list();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
709
  }
710
  });
711
  });
@@ -723,6 +809,7 @@ jQuery(document).ready(function(){
723
  fileFolderID = folderID;
724
  jQuery(".dynamic-menu").remove();
725
  jQuery(".active-menu").removeClass("active-menu");
 
726
  Swal.fire({
727
  url: wcp_settings.ajax_url,
728
  title: 'Are you sure you want to delete the selected folder?',
@@ -741,16 +828,16 @@ jQuery(document).ready(function(){
741
  });
742
  jQuery.ajax({
743
  url: wcp_settings.ajax_url,
744
- data: "type=" + wcp_settings.post_type + "&action=wcp_remove_folder&term_id=" + folderID,
745
  method: 'post',
746
  success: function (res) {
747
- Swal.fire(
748
- 'Deleted!',
749
- 'Your folder has been deleted.',
750
- 'success'
751
- );
752
  res = jQuery.parseJSON(res);
753
  if (res.status == '1') {
 
 
 
 
 
754
  jQuery("#wcp_folder_"+fileFolderID).remove();
755
  jQuery("#folder_"+fileFolderID).remove();
756
  isKeyActive = parseInt(res.is_key_active);
@@ -761,6 +848,12 @@ jQuery(document).ready(function(){
761
  }
762
  jQuery("#total-folder").text(folderLimitation);
763
  add_menu_to_list();
 
 
 
 
 
 
764
  }
765
  }
766
  });
@@ -783,10 +876,18 @@ jQuery(document).ready(function(){
783
  add_menu_to_list();
784
  jQuery.ajax({
785
  url: wcp_settings.ajax_url,
786
- data: "type=" + wcp_settings.post_type + "&action=wcp_save_parent_data&is_active=" + autoStatus,
787
  method: 'post',
788
  success: function (res) {
789
  jQuery(".form-loader-count").css("width","0%");
 
 
 
 
 
 
 
 
790
  }
791
  });
792
  });
@@ -838,4 +939,100 @@ function calcWidth(obj){
838
  calcWidth(element);
839
  });
840
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
841
  }
36
  return false;
37
  }
38
  folderOrder = jQuery("#space_"+fileFolderID+" > li").length+1;
39
+ ajaxURL = wcp_settings.ajax_url+"?parent_id=" + fileFolderID + "&type=" + wcp_settings.post_type + "&action=wcp_add_new_folder&nonce=" + wcp_settings.nonce + "&term_id=" + fileFolderID + "&order=" + folderOrder+"&name=";
40
  Swal({
41
  title: 'Add Folder',
42
  input: 'text',
98
  if(parentID == undefined) {
99
  parentID = 0;
100
  }
101
+ nonce = jQuery.trim(jQuery("#wcp_folder_"+fileFolderID).data("rename"));
102
+ ajaxURL = wcp_settings.ajax_url+"?parent_id=" + parentID + "&nonce=" + nonce + "&type=" + wcp_settings.post_type + "&action=wcp_update_folder&term_id=" + fileFolderID + "&name=";
103
  Swal({
104
  title: 'Update Folder',
105
  input: 'text',
167
 
168
  jQuery(document).ready(function(){
169
 
170
+ if(wcp_settings.can_manage_folder == "0") {
171
+ jQuery(".wcp-custom-form a:not(.pink)").addClass("button-disabled");
172
+ }
173
+
174
  isKeyActive = parseInt(wcp_settings.is_key_active);
175
  totalFolders = parseInt(wcp_settings.folders);
176
 
181
  }
182
 
183
  calcWidth(jQuery('#title_0'));
 
 
 
 
184
 
185
  jQuery("#cancel-button").click(function(){
186
  jQuery(".wcp-form-data").hide();
202
  jQuery(".wcp-parent > span").click(function(){
203
  window.location = wcp_settings.page_url
204
  });
205
+ jQuery("h3.title").livequery(function () {
 
206
  jQuery(this).droppable({
207
  accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
208
  hoverClass: 'wcp-drop-hover',
209
  classes: {
210
  "ui-droppable-active": "ui-state-highlight"
211
  },
212
+ drop: function (event, ui) {
213
  folderID = jQuery(this).closest("li.route").data('folder-id');
214
+ if (ui.draggable.hasClass('wcp-move-multiple')) {
215
+ if (jQuery(".wp-list-table input:checked").length) {
216
  chkStr = "";
217
+ jQuery(".wp-list-table input:checked").each(function () {
218
+ chkStr += jQuery(this).val() + ",";
219
  });
220
+ nonce = jQuery.trim(jQuery("#wcp_folder_" + folderID).data("nonce"));
221
  jQuery.ajax({
222
  url: wcp_settings.ajax_url,
223
+ data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce=" + nonce,
224
  method: 'post',
225
  success: function (res) {
226
+ res = jQuery.parseJSON(res);
227
+ if (res.status == "1") {
228
+ window.location.reload();
229
+ } else {
230
+ Swal.fire(
231
+ '',
232
+ res.message,
233
+ 'error'
234
+ );
235
+ }
236
  }
237
  });
238
  }
239
+ } else if (ui.draggable.hasClass('wcp-move-file')) {
240
  postID = ui.draggable[0].attributes['data-id'].nodeValue;
241
+ nonce = jQuery.trim(jQuery("#wcp_folder_" + folderID).data("nonce"));
242
  jQuery.ajax({
243
  url: wcp_settings.ajax_url,
244
+ data: "post_id=" + postID + "&type=" + wcp_settings.post_type + "&action=wcp_change_post_folder&folder_id=" + folderID + "&nonce=" + nonce,
245
  method: 'post',
246
  success: function (res) {
247
+ res = jQuery.parseJSON(res);
248
+ if (res.status == "1") {
249
+ window.location.reload();
250
+ } else {
251
+ Swal.fire(
252
+ '',
253
+ res.message,
254
+ 'error'
255
+ );
256
+ }
257
  }
258
  });
259
+ } else if (ui.draggable.hasClass('attachment')) {
260
  chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
261
+ nonce = jQuery.trim(jQuery("#wcp_folder_" + folderID).data("nonce"));
262
+ if (jQuery(".attachments-browser li.attachment.selected").length > 1) {
263
  chkStr = "";
264
+ jQuery(".attachments-browser li.attachment.selected").each(function () {
265
+ chkStr += jQuery(this).data("id") + ",";
266
  });
267
  }
268
  jQuery.ajax({
269
  url: wcp_settings.ajax_url,
270
+ data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce=" + nonce,
271
  method: 'post',
272
  success: function (res) {
273
  window.location.reload();
278
  });
279
  });
280
 
281
+ jQuery(".attachments-browser li.attachment").livequery(function () {
282
  jQuery(this).draggable({
283
  revert: "invalid",
284
  containment: "document",
285
+ helper: function (event, ui) {
286
  jQuery(".selected-items").remove();
287
  selectedItems = jQuery(".attachments-browser li.attachment.selected").length;
288
+ selectedItems = (selectedItems == 0 || selectedItems == 1) ? "1 Item" : selectedItems + " Items";
289
+ return jQuery("<div class='selected-items'><span class='total-post-count'>" + selectedItems + " Selected</span></div>");
290
  },
291
+ start: function (event, ui) {
292
 
293
  },
294
  cursor: "move",
296
  left: 0,
297
  top: 0
298
  },
299
+ stop: function (event, ui) {
300
  jQuery(".selected-items").remove();
301
  }
302
  });
303
  jQuery(this).draggable("disable");
304
  });
305
 
306
+ jQuery(".media-button").livequery(function () {
307
+ jQuery(this).click(function () {
308
+ if (jQuery(".delete-selected-button").hasClass("hidden")) {
309
+ jQuery(".attachments-browser li.attachment").draggable("disable");
 
310
  } else {
311
+ jQuery(".attachments-browser li.attachment").draggable("enable");
312
  }
 
313
  });
314
  });
315
 
317
  window.location = wcp_settings.page_url;
318
  });
319
 
320
+ //if(wcp_settings.can_manage_folder == "1") {
321
+ jQuery(".tree-structure .folder-item").livequery(function () {
322
+ jQuery(this).droppable({
323
+ accept: ".wcp-move-file, .wcp-move-multiple, .attachments-browser li.attachment",
324
+ hoverClass: 'wcp-drop-hover-list',
325
+ classes: {
326
+ "ui-droppable-active": "ui-state-highlight"
327
+ },
328
+ drop: function (event, ui) {
329
+ folderID = jQuery(this).data('id');
330
+ if (ui.draggable.hasClass('wcp-move-multiple')) {
331
+ nonce = jQuery.trim(jQuery("#wcp_folder_" + folderID).data("nonce"));
332
+ if (jQuery(".wp-list-table input:checked").length) {
333
+ chkStr = "";
334
+ jQuery(".wp-list-table input:checked").each(function () {
335
+ chkStr += jQuery(this).val() + ",";
336
+ });
337
+ jQuery.ajax({
338
+ url: wcp_settings.ajax_url,
339
+ data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce=" + nonce,
340
+ method: 'post',
341
+ success: function (res) {
342
+ window.location.reload();
343
+ }
344
+ });
345
+ }
346
+ } else if (ui.draggable.hasClass('wcp-move-file')) {
347
+ postID = ui.draggable[0].attributes['data-id'].nodeValue;
348
+ nonce = jQuery.trim(jQuery("#wcp_folder_" + folderID).data("nonce"));
349
  jQuery.ajax({
350
  url: wcp_settings.ajax_url,
351
+ data: "post_id=" + postID + "&type=" + wcp_settings.post_type + "&action=wcp_change_post_folder&folder_id=" + folderID + "&nonce=" + nonce,
352
  method: 'post',
353
  success: function (res) {
354
  window.location.reload();
355
  }
356
  });
357
+ } else if (ui.draggable.hasClass('attachment')) {
358
+ chkStr = ui.draggable[0].attributes['data-id'].nodeValue;
359
+ nonce = jQuery.trim(jQuery("#wcp_folder_" + folderID).data("nonce"));
360
+ if (jQuery(".attachments-browser li.attachment.selected").length > 1) {
361
+ chkStr = "";
362
+ jQuery(".attachments-browser li.attachment.selected").each(function () {
363
+ chkStr += jQuery(this).data("id") + ",";
364
+ });
 
365
  }
366
+ jQuery.ajax({
367
+ url: wcp_settings.ajax_url,
368
+ data: "post_ids=" + chkStr + "&type=" + wcp_settings.post_type + "&action=wcp_change_multiple_post_folder&folder_id=" + folderID + "&nonce=" + nonce,
369
+ method: 'post',
370
+ success: function (res) {
371
+ window.location.reload();
372
+ }
373
  });
374
  }
 
 
 
 
 
 
 
 
375
  }
376
+ });
377
  });
378
+ //}
379
 
380
  jQuery("#expand-collapse-list").click(function(e){
381
  e.stopPropagation();
395
  });
396
  if(folderIDs != "") {
397
  jQuery(".form-loader-count").css("width","100%");
398
+ nonce = wcp_settings.nonce;
399
  jQuery.ajax({
400
  url: wcp_settings.ajax_url,
401
+ data: "type=" + wcp_settings.post_type + "&action=wcp_change_all_status&status=" + statusType + "&folders="+folderIDs+"&nonce="+nonce,
402
  method: 'post',
403
  success: function (res) {
404
  jQuery(".form-loader-count").css("width","0");
405
  add_menu_to_list();
406
+ res = jQuery.parseJSON(res);
407
+ if(res.status == "0") {
408
+ Swal.fire(
409
+ '',
410
+ res.message,
411
+ 'error'
412
+ );
413
+ window.location.reload(true);
414
+ }
415
  }
416
  });
417
  }
437
  classString += " .space > .route >";
438
  currentWidth = newWidth - (13+(20*i));
439
  cssString += "#custom-menu > "+classString+" .title { width: "+currentWidth+"px !important; } ";
440
+ setStickyHeaderForMedia();
441
  }
442
  jQuery("#wcp-custom-style").html("<style>"+cssString+"</style>");
443
  },
444
  stop: function( e, ui ) {
445
+ nonce = wcp_settings.nonce;
446
  jQuery.ajax({
447
  url: wcp_settings.ajax_url,
448
+ data: "type=" + wcp_settings.post_type + "&action=wcp_change_post_width&width=" + ui.size.width+"&nonce="+nonce,
449
  method: 'post',
450
  success: function (res) {
451
+ setStickyHeaderForMedia();
452
  }
453
  });
454
  }
479
  jQuery("h3.title").livequery(function(){
480
  jQuery(this).on("contextmenu",function(e) {
481
  e.preventDefault();
482
+ if(wcp_settings.can_manage_folder == 0) {
483
+ return;
484
+ }
485
  isHigh = jQuery(this).closest("li.route").hasClass("is-high");
486
  jQuery(".dynamic-menu").remove();
487
  jQuery(".active-menu").removeClass("active-menu");
521
  jQuery(this).click(function(e){
522
  e.stopPropagation();
523
  folderID = jQuery(this).closest("li.route").data("folder-id");
524
+ nonce = jQuery.trim(jQuery("#wcp_folder_"+folderID).data("star"));
525
  jQuery(".form-loader-count").css("width","100%");
526
  jQuery(".dynamic-menu").remove();
527
  jQuery(".active-menu").removeClass("active-menu");
528
  jQuery.ajax({
529
  url: wcp_settings.ajax_url,
530
+ data: "term_id=" + folderID + "&type=" + wcp_settings.post_type + "&action=wcp_mark_un_mark_folder&nonce="+nonce,
531
  method: 'post',
532
+ cache: false,
533
  success: function (res) {
534
  res = jQuery.parseJSON(res);
535
  jQuery(".form-loader-count").css("width","0%");
539
  } else {
540
  jQuery("#wcp_folder_"+res.id).removeClass("is-high");
541
  }
542
+ add_menu_to_list();
543
+ } else {
544
+ Swal.fire(
545
+ '',
546
+ res.message,
547
+ 'error'
548
+ );
549
  }
 
550
  }
551
  });
552
  });
599
  fileFolderID = jQuery("#custom-menu li.active-item").data("folder-id");
600
  jQuery(".dynamic-menu").remove();
601
  jQuery(".active-menu").removeClass("active-menu");
602
+ nonce = jQuery.trim(jQuery("#wcp_folder_"+fileFolderID).data("delete"));
603
  Swal.fire({
604
  url: wcp_settings.ajax_url,
605
  title: 'Are you sure you want to delete the selected folder?',
618
  });
619
  jQuery.ajax({
620
  url: wcp_settings.ajax_url,
621
+ data: "type=" + wcp_settings.post_type + "&action=wcp_remove_folder&term_id=" + fileFolderID+"&nonce="+nonce,
622
  method: 'post',
623
  success: function (res) {
 
 
 
 
 
624
  res = jQuery.parseJSON(res);
625
  if (res.status == '1') {
626
+ Swal.fire(
627
+ 'Deleted!',
628
+ 'Your folder has been deleted.',
629
+ 'success'
630
+ );
631
  jQuery("#wcp_folder_"+fileFolderID).remove();
632
  jQuery("#folder_"+fileFolderID).remove();
633
  isKeyActive = parseInt(res.is_key_active);
638
  }
639
  jQuery("#total-folder").text(folderLimitation);
640
  add_menu_to_list();
641
+ } else {
642
+ Swal.fire(
643
+ '',
644
+ res.message,
645
+ 'error'
646
+ );
647
  }
648
  }
649
  });
652
  }
653
  });
654
 
655
+ if(wcp_settings.can_manage_folder == "1") {
656
+ jQuery('.space').livequery(function () {
657
+ jQuery(this).sortable({
658
+ placeholder: "ui-state-highlight",
659
+ connectWith: '.space',
660
+ tolerance: 'intersect',
661
+ over: function (event, ui) {
662
 
663
+ },
664
+ update: function (event, ui) {
665
+ thisId = ui.item.context.attributes['data-folder-id'].nodeValue;
666
+ orderString = "";
667
+ jQuery(this).children().each(function () {
668
+ if (jQuery(this).hasClass("route")) {
669
+ orderString += jQuery(this).data("folder-id") + ",";
670
+ }
671
+ });
672
+ if (orderString != "") {
673
+ jQuery(".form-loader-count").css("width", "100%");
674
+ jQuery.ajax({
675
+ url: wcp_settings.ajax_url,
676
+ data: "term_ids=" + orderString + "&action=wcp_save_folder_order&type=" + wcp_settings.post_type + "&nonce=" + wcp_settings.nonce,
677
+ method: 'post',
678
+ success: function (res) {
679
+ res = jQuery.parseJSON(res);
680
+ if (res.status == '1') {
681
+ jQuery("#wcp_folder_parent").html(res.options);
682
+ jQuery(".form-loader-count").css("width", "0");
683
+ add_menu_to_list();
684
+ } else {
685
+ Swal.fire(
686
+ '',
687
+ res.message,
688
+ 'error'
689
+ );
690
+ window.location.reload(true);
691
+ }
692
+ }
693
+ });
694
  }
695
+ },
696
+ receive: function (event, ui) {
697
+ calcWidth(jQuery(this).siblings('.title'));
698
+ check_for_sub_menu();
699
+ jQuery(this).closest("li.route").addClass("active");
700
+ jQuery(this).closest("li.route").find("ul.ui-sortable:first-child > li").slideDown();
701
+ parentId = jQuery(this).closest("li.route").data("folder-id");
702
+ thisId = ui.item.context.attributes['data-folder-id'].nodeValue;
703
+ if (parentId == undefined) {
704
+ parentId = 0;
705
+ }
706
+ orderString = "";
707
+ if (jQuery("#wcp_folder_" + parentId + " .ui-sortable li").length) {
708
+ jQuery("#wcp_folder_" + parentId + " .ui-sortable li").each(function () {
709
+ orderString += jQuery(this).data("folder-id") + ",";
710
+ });
711
+ } else if (parentId == 0) {
712
+ jQuery("#custom-menu > ul.space > li").each(function () {
713
+ orderString += jQuery(this).data("folder-id") + ",";
714
+ });
715
+ }
716
+ jQuery(".form-loader-count").css("width", "100%");
717
+ nonce = jQuery.trim(jQuery("#wcp_folder_" + thisId).data("nonce"));
718
  jQuery.ajax({
719
  url: wcp_settings.ajax_url,
720
+ data: "term_id=" + thisId + "&action=wcp_update_parent_information&parent_id=" + parentId + "&type=" + wcp_settings.post_type + "&nonce=" + nonce,
721
  method: 'post',
722
  success: function (res) {
723
+ jQuery(".form-loader-count").css("width", "0%");
724
  res = jQuery.parseJSON(res);
725
+ if (res.status == 0) {
726
+ Swal.fire(
727
+ '',
728
+ res.message,
729
+ 'error'
730
+ );
731
+ } else {
732
  add_menu_to_list();
733
  }
734
  }
735
  });
736
  }
737
+ });
738
+ jQuery(this).disableSelection();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
739
  });
740
+ }
 
741
  jQuery(".update-inline-record").livequery(function(){
742
  jQuery(this).click(function(e){
743
  e.stopPropagation();
758
  //jQuery(".has-sub-tree:first").addClass("active");
759
  jQuery(".nav-icon").livequery(function(){
760
  jQuery(this).click(function(){
761
+ folderID = jQuery(this).closest("li.route").data("folder-id");
762
+ if(jQuery("#wcp_folder_"+folderID).hasClass("active")) {
 
763
  folderStatus = 0;
764
  } else {
 
 
765
  folderStatus = 1;
766
  }
 
767
  jQuery(".form-loader-count").css("width","100%");
768
+ nonce = jQuery.trim(jQuery("#wcp_folder_"+folderID).data("nonce"));
769
  checkForExpandCollapse();
770
  jQuery.ajax({
771
  url: wcp_settings.ajax_url,
772
+ data: "is_active=" + folderStatus + "&action=save_wcp_folder_state&term_id=" + folderID+"&nonce="+nonce,
773
  method: 'post',
774
  success: function (res) {
775
  jQuery(".form-loader-count").css("width","0");
776
+ res = jQuery.parseJSON(res);
777
+ if(res.status == "0") {
778
+ Swal.fire(
779
+ '',
780
+ res.message,
781
+ 'error'
782
+ );
783
+ } else {
784
+ if(jQuery("#wcp_folder_"+folderID).hasClass("active")) {
785
+ jQuery("#wcp_folder_"+folderID).removeClass("active");
786
+ jQuery("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideUp();
787
+ folderStatus = 0;
788
+ } else {
789
+ jQuery("#wcp_folder_"+folderID).addClass("active");
790
+ jQuery("#wcp_folder_"+folderID).find("ul.ui-sortable:first-child > li").slideDown();
791
+ folderStatus = 1;
792
+ }
793
+ add_menu_to_list();
794
+ }
795
  }
796
  });
797
  });
809
  fileFolderID = folderID;
810
  jQuery(".dynamic-menu").remove();
811
  jQuery(".active-menu").removeClass("active-menu");
812
+ nonce = jQuery.trim(jQuery("#wcp_folder_"+fileFolderID).data("delete"));
813
  Swal.fire({
814
  url: wcp_settings.ajax_url,
815
  title: 'Are you sure you want to delete the selected folder?',
828
  });
829
  jQuery.ajax({
830
  url: wcp_settings.ajax_url,
831
+ data: "type=" + wcp_settings.post_type + "&action=wcp_remove_folder&term_id=" + folderID+"&nonce="+nonce,
832
  method: 'post',
833
  success: function (res) {
 
 
 
 
 
834
  res = jQuery.parseJSON(res);
835
  if (res.status == '1') {
836
+ Swal.fire(
837
+ 'Deleted!',
838
+ 'Your folder has been deleted.',
839
+ 'success'
840
+ );
841
  jQuery("#wcp_folder_"+fileFolderID).remove();
842
  jQuery("#folder_"+fileFolderID).remove();
843
  isKeyActive = parseInt(res.is_key_active);
848
  }
849
  jQuery("#total-folder").text(folderLimitation);
850
  add_menu_to_list();
851
+ } else {
852
+ Swal.fire(
853
+ '',
854
+ res.message,
855
+ 'error'
856
+ );
857
  }
858
  }
859
  });
876
  add_menu_to_list();
877
  jQuery.ajax({
878
  url: wcp_settings.ajax_url,
879
+ data: "type=" + wcp_settings.post_type + "&action=wcp_save_parent_data&is_active=" + autoStatus+"&nonce="+wcp_settings.nonce,
880
  method: 'post',
881
  success: function (res) {
882
  jQuery(".form-loader-count").css("width","0%");
883
+ res = jQuery.parseJSON(res);
884
+ if (res.status == '1') {
885
+ Swal.fire(
886
+ '',
887
+ res.message,
888
+ 'error'
889
+ );
890
+ }
891
  }
892
  });
893
  });
939
  calcWidth(element);
940
  });
941
 
942
+ }
943
+
944
+
945
+ /* code for sticky menu for media screen*/
946
+
947
+ if(wcp_settings.post_type == "attachment") {
948
+
949
+
950
+
951
+ jQuery(window).load(function() {
952
+ jQuery("button.button.media-button.select-mode-toggle-button").after("<button class='button organize-button'>Organize</button>");
953
+ if(jQuery(".wcp-custom-form").length) {
954
+ if (wp.Uploader !== undefined) {
955
+ wp.Uploader.queue.on('reset', function () {
956
+ resetMediaData(1);
957
+ });
958
+ }
959
+ jQuery(document).ajaxComplete(function(ev, jqXHR, settings) {
960
+ actionName = settings.data;
961
+ if(actionName.indexOf("action=delete-post&id=") == 0) {
962
+ resetMediaData(0);
963
+ }
964
+ });
965
+ }
966
+ });
967
+
968
+ function resetMediaData(loadData) {
969
+ jQuery.ajax({
970
+ url: wcp_settings.ajax_url,
971
+ data: "type=" + wcp_settings.post_type + "&action=wcp_get_default_list",
972
+ method: 'post',
973
+ success: function (res) {
974
+ res = jQuery.parseJSON(res);
975
+ jQuery("#custom-menu > ul#space_0").html(res.data);
976
+ jQuery(".header-posts .total-count").text(res.total_items);
977
+ selectedVal = jQuery("#media-attachment-taxonomy-filter").val();
978
+ if(selectedVal != "all" && loadData == 1) {
979
+ var wp1 = parent.wp;
980
+ wp1.media.frame.setState('insert');
981
+ if (wp1.media.frame.content.get() !== null) {
982
+ wp1.media.frame.content.get().collection.props.set({ignore: (+new Date())});
983
+ wp1.media.frame.content.get().options.selection.reset();
984
+ } else {
985
+ wp1.media.frame.library.props.set({ignore: (+new Date())});
986
+ }
987
+ }
988
+ if(res.taxonomies.length) {
989
+ var selectedDD = jQuery("#media-attachment-taxonomy-filter");
990
+ selectedDD.html("<option value='all'>All Folders</option><option value='unassigned'>(Unassigned)</option>");
991
+ for(i=0; i<res.taxonomies.length; i++) {
992
+ selectedDD.append("<option value='"+i+"'>"+res.taxonomies[i].name+" ("+res.taxonomies[i].count+")</option>");
993
+ }
994
+ selectedDD.val(selectedVal);
995
+ }
996
+ }
997
+ });
998
+ }
999
+
1000
+ function setMediaBoxWidth() {
1001
+ jQuery(".media-frame-content .media-toolbar").width(jQuery(".media-frame-content").width() - 20);
1002
+ }
1003
+
1004
+ setMediaBoxWidth();
1005
+
1006
+ jQuery(window).resize(function(){
1007
+ setMediaBoxWidth();
1008
+ });
1009
+
1010
+ jQuery(document).on("click", ".button.organize-button", function(){
1011
+ jQuery("button.button.media-button.select-mode-toggle-button").trigger("click");
1012
+ });
1013
+
1014
+ function setStickyHeaderForMedia() {
1015
+ if(!jQuery(".media-position").length) {
1016
+ jQuery(".media-frame-content .media-toolbar").before("<div class='media-position'></div>")
1017
+ }
1018
+
1019
+ if(jQuery(".media-position").length) {
1020
+ setMediaBoxWidth();
1021
+
1022
+ thisPosition = jQuery(".media-position").offset().top - jQuery(window).scrollTop();
1023
+ if(thisPosition <= 32) {
1024
+ jQuery(".media-frame-content .media-toolbar").addClass("sticky-media");
1025
+ jQuery(".media-position").height(jQuery(".media-frame-content .media-toolbar").outerHeight());
1026
+ } else {
1027
+ jQuery(".media-frame-content .media-toolbar").removeClass("sticky-media");
1028
+ jQuery(".media-position").height(1);
1029
+ }
1030
+ }
1031
+ }
1032
+
1033
+ jQuery(window).scroll(function(){
1034
+ setStickyHeaderForMedia()
1035
+ });
1036
+ } else {
1037
+ function setStickyHeaderForMedia() {}
1038
  }
assets/js/media.js ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function() {
2
+ var MediaLibraryOrganizerTaxonomyFilter = wp.media.view.AttachmentFilters.extend({
3
+ id: 'media-attachment-taxonomy-filter',
4
+ createFilters: function() {
5
+ var filters = {};
6
+ _.each(folders_media_options.terms || {}, function(term, index) {
7
+ filters[index] = {
8
+ text: term.name + ' (' + term.count + ')',
9
+ props: {
10
+ 'media_folder': term.slug
11
+ }
12
+ };
13
+ });
14
+ filters.all = {
15
+ text: 'All Folders',
16
+ props: {
17
+ 'media_folder': ''
18
+ },
19
+ priority: 10
20
+ };
21
+ filters.unassigned = {
22
+ text: '(Unassigned)',
23
+ props: {
24
+ 'media_folder': "-1"
25
+ },
26
+ priority: 10
27
+ };
28
+ this.filters = filters;
29
+ }
30
+ });
31
+
32
+ var AttachmentsBrowser = wp.media.view.AttachmentsBrowser;
33
+ wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend({
34
+ createToolbar: function() {
35
+ AttachmentsBrowser.prototype.createToolbar.call(this);
36
+ this.toolbar.set('MediaLibraryOrganizerTaxonomyFilter', new MediaLibraryOrganizerTaxonomyFilter({
37
+ controller: this.controller,
38
+ model: this.collection.props,
39
+ priority: -75
40
+ }).render());
41
+ }
42
+ });
43
+
44
+ var Query = wp.media.model.Query;
45
+ _.extend(Query, {
46
+ get: (function() {
47
+ var queries = [];
48
+ return function(props, options) {
49
+ var args = {},
50
+ orderby = Query.orderby,
51
+ defaults = Query.defaultProps,
52
+ query,
53
+ cache = false; // Always disable query
54
+ delete props.query;
55
+ delete props.cache;
56
+ _.defaults(props, defaults);
57
+
58
+ _.each(['include', 'exclude'], function(prop) {
59
+ if (props[prop] && !_.isArray(props[prop])) {
60
+ props[prop] = [props[prop]];
61
+ }
62
+ });
63
+ _.each(props, function(value, prop) {
64
+ if (_.isNull(value)) {
65
+ return;
66
+ }
67
+ args[Query.propmap[prop] || prop] = value;
68
+ });
69
+ _.defaults(args, Query.defaultArgs);
70
+ args.orderby = orderby.valuemap[props.orderby] || props.orderby;
71
+ // Disable query caching
72
+ cache = false;
73
+ // Search the query cache for a matching query.
74
+ if (cache) {
75
+ query = _.find(queries, function(query) {
76
+ return _.isEqual(query.args, args);
77
+ });
78
+ } else {
79
+ queries = [];
80
+ }
81
+ // Otherwise, create a new query and add it to the cache.
82
+ if (!query) {
83
+ query = new Query([], _.extend(options || {}, {
84
+ props: props,
85
+ args: args
86
+ }));
87
+ queries.push(query);
88
+ }
89
+ return query;
90
+ };
91
+ }())
92
+ });
93
+ })(jQuery, _);
folders.php CHANGED
@@ -2,17 +2,20 @@
2
  /**
3
  * Plugin Name: Folders
4
  * Description: Arrange media, pages, custom post types and posts into folders
5
- * Version: 2.0.5
6
  * Author: Premio
7
  * Author URI: https://premio.io/downloads/folders/
8
  */
9
 
 
 
10
  define('WCP_FOLDERS_PLUGIN_FILE', __FILE__ );
11
  define('WCP_FOLDERS_PLUGIN_BASE', plugin_basename(WCP_FOLDERS_PLUGIN_FILE ) );
12
  define('WCP_FOLDER', 'folders');
13
  define('WCP_FOLDER_VAR', 'folders_settings');
14
  define("WCP_DS", DIRECTORY_SEPARATOR);
15
  define('WCP_FOLDER_URL',plugin_dir_url(__FILE__));
 
16
 
17
  include_once plugin_dir_path(__FILE__)."includes/folders.class.php";
18
  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.1
6
  * Author: Premio
7
  * Author URI: https://premio.io/downloads/folders/
8
  */
9
 
10
+ defined('ABSPATH') or die('Nope, not accessing this');
11
+
12
  define('WCP_FOLDERS_PLUGIN_FILE', __FILE__ );
13
  define('WCP_FOLDERS_PLUGIN_BASE', plugin_basename(WCP_FOLDERS_PLUGIN_FILE ) );
14
  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.1");
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
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  class WCP_Folders
4
  {
5
 
@@ -11,7 +13,7 @@ class WCP_Folders
11
 
12
  public $total_folders = 0;
13
 
14
- private function __construct()
15
  {
16
  spl_autoload_register(array($this, 'autoload'));
17
  add_action('init', array($this, 'create_folder_terms'), 15);
@@ -24,69 +26,437 @@ class WCP_Folders
24
  add_action('parse_tax_query', array($this, 'taxonomy_archive_exclude_children'));
25
 
26
  /* Save Data */
27
- add_action('wp_ajax_nopriv_wcp_add_new_folder', array($this, 'wcp_add_new_folder'));
28
  add_action('wp_ajax_wcp_add_new_folder', array($this, 'wcp_add_new_folder'));
29
 
30
  /* Update Data */
31
- add_action('wp_ajax_nopriv_wcp_update_folder', array($this, 'wcp_update_folder'));
32
  add_action('wp_ajax_wcp_update_folder', array($this, 'wcp_update_folder'));
33
 
34
  /* Remove Data */
35
- add_action('wp_ajax_nopriv_wcp_remove_folder', array($this, 'wcp_remove_folder'));
36
  add_action('wp_ajax_wcp_remove_folder', array($this, 'wcp_remove_folder'));
37
 
38
  /* Save State Data */
39
- add_action('wp_ajax_nopriv_save_wcp_folder_state', array($this, 'save_wcp_folder_state'));
40
  add_action('wp_ajax_save_wcp_folder_state', array($this, 'save_wcp_folder_state'));
41
 
42
  /* Save State Data */
43
- add_action('wp_ajax_nopriv_wcp_save_parent_data', array($this, 'wcp_save_parent_data'));
44
  add_action('wp_ajax_wcp_save_parent_data', array($this, 'wcp_save_parent_data'));
45
 
46
  /* Update Parent Data */
47
- add_action('wp_ajax_nopriv_wcp_update_parent_information', array($this, 'wcp_update_parent_information'));
48
  add_action('wp_ajax_wcp_update_parent_information', array($this, 'wcp_update_parent_information'));
49
 
50
  /* Update Parent Data */
51
- add_action('wp_ajax_nopriv_wcp_save_folder_order', array($this, 'wcp_save_folder_order'));
52
  add_action('wp_ajax_wcp_save_folder_order', array($this, 'wcp_save_folder_order'));
53
 
54
  /* Update Parent Data */
55
- add_action('wp_ajax_nopriv_wcp_mark_un_mark_folder', array($this, 'wcp_mark_un_mark_folder'));
56
  add_action('wp_ajax_wcp_mark_un_mark_folder', array($this, 'wcp_mark_un_mark_folder'));
57
 
58
  /* Update Parent Data */
59
- add_action('wp_ajax_nopriv_wcp_change_post_folder', array($this, 'wcp_change_post_folder'));
60
  add_action('wp_ajax_wcp_change_post_folder', array($this, 'wcp_change_post_folder'));
61
 
62
  /* Update Parent Data */
63
- add_action('wp_ajax_nopriv_wcp_change_multiple_post_folder', array($this, 'wcp_change_multiple_post_folder'));
64
  add_action('wp_ajax_wcp_change_multiple_post_folder', array($this, 'wcp_change_multiple_post_folder'));
65
 
66
  /* Update width Data */
67
- add_action('wp_ajax_nopriv_wcp_change_post_width', array($this, 'wcp_change_post_width'));
68
  add_action('wp_ajax_wcp_change_post_width', array($this, 'wcp_change_post_width'));
69
 
70
  /* Update width Data */
71
- add_action('wp_ajax_nopriv_wcp_change_all_status', array($this, 'wcp_change_all_status'));
72
  add_action('wp_ajax_wcp_change_all_status', array($this, 'wcp_change_all_status'));
73
 
74
- /* Update width Data */
75
- add_action('wp_ajax_nopriv_wcp_folder_activate_key', array($this, 'wcp_folder_activate_key'));
76
- add_action('wp_ajax_wcp_folder_activate_key', array($this, 'wcp_folder_activate_key'));
77
 
78
- add_action('admin_notices', array($this, 'wcp_admin_notice'));
 
79
 
80
- self::$folders = 10;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  public function check_has_valid_key()
85
  {
86
  return 0;
87
  }
88
 
89
- public function total_term_folders()
90
  {
91
  $post_types = get_option(WCP_FOLDER_VAR);
92
  $post_types = is_array($post_types)?$post_types:array();
@@ -98,11 +468,6 @@ class WCP_Folders
98
  return $total;
99
  }
100
 
101
- public function wcp_admin_notice()
102
- {
103
-
104
- }
105
-
106
  public function get_license_key_information($licenseKey)
107
  {
108
  return array();
@@ -142,14 +507,39 @@ class WCP_Folders
142
  $response['data'] = array();
143
  $response['message'] = "";
144
  $postData = $_POST;
145
- if (isset($postData['folders']) && !empty($postData['folders'])) {
146
- $status = (isset($postData['status']) && $postData['status'] == 1) ? 1 : 0;
147
- $folders = $postData['folders'];
148
- $folders = trim($folders, ",");
149
- $folders = explode(",", $folders);
150
- foreach ($folders as $folder) {
151
- update_term_meta($folder, "is_active", $status);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  }
 
153
  }
154
  echo json_encode($response);
155
  die;
@@ -163,9 +553,35 @@ class WCP_Folders
163
  $response['data'] = array();
164
  $response['message'] = "";
165
  $postData = $_POST;
166
- if (isset($postData['width']) && isset($postData['type'])) {
167
- $optionName = "wcp_dynamic_width_for_" . $postData['type'];
168
- update_option($optionName, $postData['width']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  $response['status'] = 1;
170
  }
171
  echo json_encode($response);
@@ -180,14 +596,41 @@ class WCP_Folders
180
  $response['data'] = array();
181
  $response['message'] = "";
182
  $postData = $_POST;
183
- if (isset($postData['post_ids']) && isset($postData['folder_id'])) {
184
- $postID = $postData['post_ids'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  $postID = trim($postID, ",");
186
- $folderID = $postData['folder_id'];
 
187
  $postArray = explode(",", $postID);
188
  if (is_array($postArray)) {
189
  foreach ($postArray as $post) {
190
- $post_type = self::get_custom_post_type($postData['type']);
191
  wp_set_post_terms($post, $folderID, $post_type, false);
192
  }
193
  }
@@ -205,10 +648,37 @@ class WCP_Folders
205
  $response['data'] = array();
206
  $response['message'] = "";
207
  $postData = $_POST;
208
- if (isset($postData['post_id']) && isset($postData['folder_id'])) {
209
- $postID = $postData['post_id'];
210
- $folderID = $postData['folder_id'];
211
- $folder_post_type = self::get_custom_post_type($postData['type']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  $terms = get_the_terms($postID, $folder_post_type);
213
  if (!empty($terms)) {
214
  foreach ($terms as $term) {
@@ -230,14 +700,31 @@ class WCP_Folders
230
  $response['data'] = array();
231
  $response['message'] = "";
232
  $postData = $_POST;
233
- $status = 0;
234
- if (isset($postData['term_id'])) {
235
- $status = get_term_meta($postData['term_id'], "is_highlighted", true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  if ($status == 1) {
237
- update_term_meta($postData['term_id'], "is_highlighted", 0);
238
  $status = 0;
239
  } else {
240
- update_term_meta($postData['term_id'], "is_highlighted", 1);
241
  $status = 1;
242
  }
243
  $response['marked'] = $status;
@@ -256,8 +743,29 @@ class WCP_Folders
256
  $response['data'] = array();
257
  $response['message'] = "";
258
  $postData = $_POST;
259
- if (isset($postData['term_ids'])) {
260
- $termIds = $postData['term_ids'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  $termIds = trim($termIds, ",");
262
  $termArray = explode(",", $termIds);
263
  $order = 1;
@@ -268,8 +776,9 @@ class WCP_Folders
268
  }
269
  }
270
  $response['status'] = 1;
271
- $folder_type = self::get_custom_post_type($postData['type']);
272
  $response['options'] = WCP_Tree::get_option_data_for_select($folder_type);
 
273
  }
274
  echo json_encode($response);
275
  die;
@@ -283,11 +792,32 @@ class WCP_Folders
283
  $response['data'] = array();
284
  $response['message'] = "";
285
  $postData = $_POST;
286
- if (isset($postData['term_id'])) {
287
- if (isset($postData['is_active']) && $postData['is_active'] == 1) {
288
- update_term_meta($postData['term_id'], "is_active", 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  } else {
290
- update_term_meta($postData['term_id'], "is_active", 0);
291
  }
292
  }
293
  echo json_encode($response);
@@ -302,12 +832,39 @@ class WCP_Folders
302
  $response['data'] = array();
303
  $response['message'] = "";
304
  $postData = $_POST;
305
- if (isset($postData['type']) && isset($postData['term_id']) && isset($postData['parent_id'])) {
306
- $folder_type = self::get_custom_post_type($postData['type']);
307
- wp_update_term($postData['term_id'], $folder_type, array(
308
- 'parent' => $postData['parent_id']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  ));
310
- update_term_meta($postData['parent_id'], "is_active", 1);
 
311
  }
312
  echo json_encode($response);
313
  die;
@@ -321,10 +878,27 @@ class WCP_Folders
321
  $response['data'] = array();
322
  $response['message'] = "";
323
  $postData = $_POST;
324
- if (isset($postData['type'])) {
325
- $postType = $postData['type'];
326
- $optionName = $postType . "_parent_status";
327
- if (isset($postData['is_active']) && $postData['is_active'] == 1) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  update_option($optionName, 1);
329
  } else {
330
  update_option($optionName, 0);
@@ -343,16 +917,29 @@ class WCP_Folders
343
  $response['message'] = "";
344
  $postData = $_POST;
345
  $errorCounter = 0;
346
- if (!isset($postData['term_id']) || empty($postData['term_id'])) {
347
- $error = "Invalid request";
 
 
 
348
  $errorCounter++;
349
  } else if (!isset($postData['type']) || empty($postData['type'])) {
350
- $error = "Invalid request";
 
 
 
351
  $errorCounter++;
 
 
 
 
 
 
352
  }
353
  if ($errorCounter == 0) {
354
- // $fol
355
- self::remove_folder_child_items($postData['term_id'], $postData['type']);
 
356
  $response['status'] = 1;
357
  $is_active = 1;
358
  $folders = -1;
@@ -397,23 +984,38 @@ class WCP_Folders
397
  $response['message'] = "";
398
  $postData = $_REQUEST;
399
  $errorCounter = 0;
400
- if (!isset($postData['name']) || empty($postData['name'])) {
401
- $error = "Folder name can no be empty";
 
 
 
 
 
 
402
  $errorCounter++;
403
  } else if (!isset($postData['type']) || empty($postData['type'])) {
404
- $error = "Invalid request";
405
  $errorCounter++;
 
 
 
 
 
 
 
 
 
406
  }
407
  if ($errorCounter == 0) {
408
- $folder_type = self::get_custom_post_type($postData['type']);
409
- $parent = isset($postData['parent_id']) && !empty($postData['parent_id']) ? $postData['parent_id'] : 0;
410
- $term = term_exists($postData['name'], $folder_type, $parent);
411
- //if (!(0 !== $term && null !== $term )) {
412
  $result = wp_update_term(
413
- $postData['term_id'], // the term
414
- $folder_type, // the taxonomy
415
  array(
416
- 'name' => $postData['name'],
417
  )
418
  );
419
  if (!empty($result)) {
@@ -421,11 +1023,8 @@ class WCP_Folders
421
  $response['status'] = 1;
422
  $response['term_title'] = $postData['name'];
423
  } else {
424
- $response['message'] = "Error during server request";
425
  }
426
- // } else {
427
- // $response['message'] = "Folder name already exists";
428
- // }
429
  } else {
430
  $response['error'] = 1;
431
  $response['message'] = $error;
@@ -441,26 +1040,56 @@ class WCP_Folders
441
  return strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), str_replace($a, $b, $str)));
442
  }
443
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  public function wcp_add_new_folder()
445
  {
446
  $response = array();
447
  $response['status'] = 0;
448
  $response['error'] = 0;
 
449
  $response['data'] = array();
450
  $response['message'] = "";
451
  $postData = $_REQUEST;
452
  $errorCounter = 0;
453
- if (!isset($postData['name']) || empty($postData['name'])) {
454
- $error = "Folder name can no be empty";
 
 
 
455
  $errorCounter++;
456
  } else if (!isset($postData['type']) || empty($postData['type'])) {
457
- $error = "Invalid request";
458
  $errorCounter++;
 
 
 
 
 
 
 
 
 
 
 
459
  }
460
  if ($errorCounter == 0) {
461
  $parent = isset($postData['parent_id']) && !empty($postData['parent_id']) ? $postData['parent_id'] : 0;
462
- $folder_type = self::get_custom_post_type($postData['type']);
463
- $term = term_exists($postData['name'], $folder_type, $parent);
 
 
 
464
  if (!(0 !== $term && null !== $term)) {
465
  $slug = self::create_slug_from_string($postData['name']) . "-" . time();
466
  $result = wp_insert_term(
@@ -475,11 +1104,16 @@ class WCP_Folders
475
  $response['id'] = $result['term_id'];
476
  $response['status'] = 1;
477
  $order = isset($postData['order']) ? $postData['order'] : 0;
 
478
  update_term_meta($result['term_id'], "wcp_custom_order", $order);
479
  if ($parent != 0) {
480
  update_term_meta($parent, "is_active", 1);
481
  }
482
- $string = "<li 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']}'>";
 
 
 
 
483
  $string .= "</ul></li>";
484
  $response['term_data'] = $string;
485
  $response['parent_id'] = $parent;
@@ -493,11 +1127,11 @@ class WCP_Folders
493
  $response['is_key_active'] = $is_active;
494
  $response['folders'] = $folders;
495
  } else {
496
- $response['message'] = "Error during server request";
497
  }
498
  } else {
499
  $response['error'] = 1;
500
- $response['message'] = "Folder name already exists";
501
  }
502
  } else {
503
  $response['error'] = 1;
@@ -559,27 +1193,10 @@ class WCP_Folders
559
  }
560
  $response['folders'] = $folders;
561
  $response['is_key_active'] = $is_active;
562
-
563
- wp_register_script('wcp-folders-inner', plugin_dir_url(dirname(__FILE__)) . 'assets/js/inner.js');
564
-
565
- $is_rtl = 0;
566
- if ( function_exists( 'is_rtl' ) && is_rtl() ) {
567
- $is_rtl = 1;
568
- }
569
-
570
- wp_localize_script('wcp-folders-inner', 'wcp_inner_settings', array(
571
- 'ajax_url' => admin_url('admin-ajax.php'),
572
- 'post_type' => $typenow,
573
- 'ajax_image' => plugin_dir_url(dirname(__FILE__)) . "assets/images/ajax-loader.gif",
574
- 'is_valid' => $is_active,
575
- 'folders' => $folders,
576
- 'isRTL' => $is_rtl
577
- ));
578
- wp_enqueue_script('wcp-folders-inner');
579
  }
580
  }
581
 
582
- public function get_custom_post_type($post_type)
583
  {
584
  if ($post_type == "post") {
585
  return "post_folder";
@@ -593,6 +1210,7 @@ class WCP_Folders
593
 
594
  public function admin_footer()
595
  {
 
596
  if (self::is_active_for_screen()) {
597
  global $typenow;
598
 
@@ -604,6 +1222,13 @@ class WCP_Folders
604
  $form_html = WCP_Forms::get_form_html($terms_html);
605
  include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "admin-content.php";
606
  }
 
 
 
 
 
 
 
607
  }
608
 
609
  public function get_total_posts($post_type = "")
@@ -646,6 +1271,8 @@ class WCP_Folders
646
  }
647
  if (in_array($option, array("page", "post", "attachment"))) {
648
  $posts[] = str_replace("folder4", "", $option);
 
 
649
  }
650
  }
651
  if(!empty($posts)) {
@@ -700,23 +1327,24 @@ class WCP_Folders
700
  }
701
  }
702
 
703
-
704
- if (isset($_POST['folders_show_in_menu']) && !empty($_POST['folders_show_in_menu'])) {
705
- $show_menu = "off";
706
- if($_POST['folders_show_in_menu'] == "on") {
707
- $show_menu = "on";
 
 
708
  }
709
- update_option("folders_show_in_menu", $show_menu);
710
- }
711
 
712
- if(isset($_POST['folders_settings1'])) {
713
- $posts = array();
714
- if(isset($_POST['folders_settings']) && is_array($_POST['folders_settings'])) {
715
- foreach($_POST['folders_settings'] as $key=>$val) {
716
- $posts[] = $val;
 
717
  }
 
718
  }
719
- update_option("folders_settings", $posts);
720
  }
721
 
722
  $old_version = get_option("folder_old_plugin_status");
@@ -840,7 +1468,8 @@ class WCP_Folders
840
  if (self::is_active_for_screen()) {
841
  global $typenow;
842
  $width = get_option("wcp_dynamic_width_for_" . $typenow);
843
- if (!empty($width)) {
 
844
  $css .= ".wcp-content{width:{$width}px}";
845
  if ( function_exists( 'is_rtl' ) && is_rtl() ) {
846
  $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:" . ($width + 20) . "px}";
@@ -857,9 +1486,10 @@ class WCP_Folders
857
  global $typenow;
858
  add_filter('views_edit-' . $typenow, array($this, 'wcp_check_for_child_folders'));
859
  }
 
860
  }
861
 
862
- function wcp_check_for_child_folders()
863
  {
864
  $termId = 0;
865
  global $typenow;
@@ -904,6 +1534,13 @@ class WCP_Folders
904
  echo '</ul>';
905
  echo '<div class="clear clearfix"></div>';
906
  echo '</div>';
 
 
 
 
 
 
 
907
  }
908
 
909
  function folders_admin_scripts()
@@ -937,6 +1574,7 @@ class WCP_Folders
937
  $is_rtl = 1;
938
  }
939
 
 
940
  wp_localize_script('wcp-folders-custom', 'wcp_settings', array(
941
  'ajax_url' => admin_url('admin-ajax.php'),
942
  'post_type' => $typenow,
@@ -945,8 +1583,11 @@ class WCP_Folders
945
  'is_key_active' => $is_active,
946
  'folders' => $folders,
947
  'register_url' => $register_url,
948
- 'isRTL' => $is_rtl
 
 
949
  ));
 
950
  wp_enqueue_script('wcp-folders-alert');
951
  wp_enqueue_script('wcp-folders-custom');
952
 
@@ -1038,8 +1679,8 @@ class WCP_Folders
1038
 
1039
  foreach ($options as $option) {
1040
  if ($option != "post" && $option != "page" && $option != "attachment") {
1041
- add_filter('manage_edit-' . $option . '_columns', 'wcp_manage_columns_head');
1042
- add_action('manage_' . $option . '_posts_custom_column', 'my_manage_movie_columns', 10, 2);
1043
  }
1044
  }
1045
 
@@ -1051,7 +1692,7 @@ class WCP_Folders
1051
  }
1052
  }
1053
 
1054
- function wcp_manage_columns_head($defaults)
1055
  {
1056
  global $typenow;
1057
  $options = get_option("folders_settings");
@@ -1088,11 +1729,10 @@ class WCP_Folders
1088
  $taxonomy_slugs[] = self::get_custom_post_type($option);
1089
  }
1090
  if (!empty($taxonomy_slugs)) {
1091
- if ($query->is_main_query() && is_tax($taxonomy_slugs)) {
1092
- foreach ($query->tax_query->queries as &$tax_query_item) {
1093
- if (empty($taxonomy_slugs) || in_array($tax_query_item['taxonomy'], $taxonomy_slugs)) {
1094
- $tax_query_item['include_children'] = 0;
1095
- }
1096
  }
1097
  }
1098
  }
1
  <?php
2
 
3
+ defined('ABSPATH') or die('Nope, not accessing this');
4
+
5
  class WCP_Folders
6
  {
7
 
13
 
14
  public $total_folders = 0;
15
 
16
+ public function __construct()
17
  {
18
  spl_autoload_register(array($this, 'autoload'));
19
  add_action('init', array($this, 'create_folder_terms'), 15);
26
  add_action('parse_tax_query', array($this, 'taxonomy_archive_exclude_children'));
27
 
28
  /* Save Data */
 
29
  add_action('wp_ajax_wcp_add_new_folder', array($this, 'wcp_add_new_folder'));
30
 
31
  /* Update Data */
 
32
  add_action('wp_ajax_wcp_update_folder', array($this, 'wcp_update_folder'));
33
 
34
  /* Remove Data */
 
35
  add_action('wp_ajax_wcp_remove_folder', array($this, 'wcp_remove_folder'));
36
 
37
  /* Save State Data */
 
38
  add_action('wp_ajax_save_wcp_folder_state', array($this, 'save_wcp_folder_state'));
39
 
40
  /* Save State Data */
 
41
  add_action('wp_ajax_wcp_save_parent_data', array($this, 'wcp_save_parent_data'));
42
 
43
  /* Update Parent Data */
 
44
  add_action('wp_ajax_wcp_update_parent_information', array($this, 'wcp_update_parent_information'));
45
 
46
  /* Update Parent Data */
 
47
  add_action('wp_ajax_wcp_save_folder_order', array($this, 'wcp_save_folder_order'));
48
 
49
  /* Update Parent Data */
 
50
  add_action('wp_ajax_wcp_mark_un_mark_folder', array($this, 'wcp_mark_un_mark_folder'));
51
 
52
  /* Update Parent Data */
 
53
  add_action('wp_ajax_wcp_change_post_folder', array($this, 'wcp_change_post_folder'));
54
 
55
  /* Update Parent Data */
 
56
  add_action('wp_ajax_wcp_change_multiple_post_folder', array($this, 'wcp_change_multiple_post_folder'));
57
 
58
  /* Update width Data */
 
59
  add_action('wp_ajax_wcp_change_post_width', array($this, 'wcp_change_post_width'));
60
 
61
  /* Update width Data */
 
62
  add_action('wp_ajax_wcp_change_all_status', array($this, 'wcp_change_all_status'));
63
 
64
+ self::$folders = 10;
 
 
65
 
66
+ /* Send message on plugin deactivate */
67
+ add_action( 'wp_ajax_folder_plugin_deactivate', array( $this, 'folder_plugin_deactivate' ) );
68
 
69
+ /* Send message on owner */
70
+ add_action( 'wp_ajax_wcp_folder_send_message_to_owner', array( $this, 'wcp_folder_send_message_to_owner' ) );
71
+
72
+ /* Get default list */
73
+ add_action( 'wp_ajax_wcp_get_default_list', array( $this, 'wcp_get_default_list' ) );
74
+
75
+ /* Auto select folder for new page, post */
76
+ add_action('new_to_auto-draft', array($this, 'new_to_auto_draft'), 10);
77
+
78
+ /* for media */
79
+ add_action('restrict_manage_posts', array($this, 'output_list_table_filters'), 10, 2);
80
+ add_filter('pre_get_posts', array($this, 'filter_attachments_list'));
81
+ add_action('wp_enqueue_media', array($this, 'output_backbone_view_filters'));
82
+ add_filter('ajax_query_attachments_args', array($this, 'filter_attachments_grid'));
83
+ add_filter('add_attachment', array($this, 'save_media_terms'));
84
  }
85
 
86
+ public function wcp_get_default_list() {
87
+ $post_type = 'attachment';
88
+
89
+ $total_posts = wp_count_posts($post_type)->inherit;;
90
+
91
+ $post_type = self::get_custom_post_type($post_type);
92
+ $terms_data = WCP_Tree::get_full_tree_data($post_type);
93
+ $taxonomies = self::get_terms_hierarchical('media_folder');
94
+
95
+ $response = array(
96
+ 'status' => 1,
97
+ 'data' => $terms_data,
98
+ 'total_items' => $total_posts,
99
+ 'taxonomies' => $taxonomies
100
+ );
101
+ echo json_encode($response);
102
+ die;
103
+ }
104
+
105
+ function save_media_terms( $post_id ) {
106
+ if ( wp_is_post_revision( $post_id ) ) {
107
+ return;
108
+ }
109
+ $post = get_post($post_id);
110
+ if($post->post_type !== 'attachment') {
111
+ return;
112
+ }
113
+ $post_type = self::get_custom_post_type('attachment');
114
+ $selected_folder = get_option("selected_{$post_type}_folder");
115
+ if($selected_folder != null && !empty($selected_folder)) {
116
+ $terms = get_term($selected_folder);
117
+ if(!empty($terms) && isset($terms->term_id)) {
118
+ wp_set_post_terms($post_id, $terms->term_id, $post_type, false);
119
+ }
120
+ }
121
+ }
122
+
123
+ public function filter_attachments_grid( $args ) {
124
+ $taxonomy = 'media_folder';
125
+ if ( ! isset( $args[ $taxonomy ] ) ) {
126
+ return $args;
127
+ }
128
+ $term = sanitize_text_field( $args[ $taxonomy ] );
129
+ if ( $term != "-1" ) {
130
+ return $args;
131
+ }
132
+ unset( $args[ $taxonomy ] );
133
+ $args['tax_query'] = array(
134
+ array(
135
+ 'taxonomy' => $taxonomy,
136
+ 'operator' => 'NOT EXISTS',
137
+ ),
138
+ );
139
+ $args = apply_filters( 'media_library_organizer_media_filter_attachments_grid', $args );
140
+ return $args;
141
+ }
142
+
143
+ public function output_backbone_view_filters() {
144
+ wp_enqueue_script( 'folders-media', WCP_FOLDER_URL.'assets/js/media.js', array( 'media-editor', 'media-views' ), false, true );
145
+ wp_localize_script( 'folders-media', 'folders_media_options', array(
146
+ 'terms' => self::get_terms_hierarchical('media_folder'),
147
+ 'taxonomy' => get_taxonomy('media_folder')
148
+ ));
149
+ wp_enqueue_style( 'folders-media', WCP_FOLDER_URL . 'assets/css/media.css' );
150
+ }
151
+
152
+ public function get_terms_hierarchical( $taxonomy ) {
153
+ $terms = get_terms( array(
154
+ 'taxonomy' => $taxonomy,
155
+ 'hide_empty' => false,
156
+ 'parent' => 0,
157
+ ) );
158
+
159
+ if ( empty( $terms ) ) {
160
+ return false;
161
+ }
162
+
163
+ $hierarchy = _get_term_hierarchy( $taxonomy );
164
+
165
+ $hierarchical_terms = array();
166
+ foreach ( $terms as $term ) {
167
+ $hierarchical_terms[] = $term;
168
+ $hierarchical_terms = self::add_child_terms_recursive( $taxonomy, $hierarchical_terms, $hierarchy, $term->term_id, 1 );
169
+ }
170
+
171
+ return $hierarchical_terms;
172
+ }
173
+
174
+ private function add_child_terms_recursive( $taxonomy, $hierarchical_terms, $hierarchy, $current_term_id, $current_depth ) {
175
+
176
+ if ( ! isset( $hierarchy[ $current_term_id ] ) ) {
177
+ return $hierarchical_terms;
178
+ }
179
+
180
+ foreach ( $hierarchy[ $current_term_id ] as $child_term_id ) {
181
+
182
+ $child_term = get_term( $child_term_id, $taxonomy );
183
+
184
+ $child_term->name = str_pad( '', $current_depth, '-', STR_PAD_LEFT ) . ' ' . $child_term->name;
185
+
186
+ $hierarchical_terms[] = $child_term;
187
+
188
+ $hierarchical_terms = self::add_child_terms_recursive( $taxonomy, $hierarchical_terms, $hierarchy, $child_term_id, ( $current_depth + 1 ) );
189
+ }
190
+
191
+ return $hierarchical_terms;
192
+ }
193
+
194
+ public function filter_attachments_list( $query ) {
195
+
196
+ if ( ! isset( $query->query['post_type'] ) ) {
197
+ return $query;
198
+ }
199
+
200
+ if ( is_array( $query->query['post_type'] ) && ! in_array( 'attachment', $query->query['post_type'] ) ) {
201
+ return $query;
202
+ }
203
+ if ( ! is_array( $query->query['post_type'] ) && strpos( $query->query['post_type'], 'attachment' ) === false ) {
204
+ return $query;
205
+ }
206
+
207
+ if ( ! isset( $_REQUEST['media_folder'] ) ) {
208
+ return $query;
209
+ }
210
+
211
+ $term = sanitize_text_field( $_REQUEST['media_folder'] );
212
+ if ( $term != "-1" ) {
213
+ return $query;
214
+ }
215
+
216
+ unset( $query->query_vars['media_folder'] );
217
+
218
+ $tax_query = array(
219
+ 'taxonomy' => 'media_folder',
220
+ 'operator' => 'NOT EXISTS',
221
+ );
222
+
223
+ $query->set( 'tax_query', array( $tax_query ) );
224
+ $query->tax_query = new WP_Tax_Query( array( $tax_query ) );
225
+
226
+ $query = apply_filters( 'media_library_organizer_media_filter_attachments', $query, $_REQUEST );
227
+
228
+ return $query;
229
+
230
+ }
231
+
232
+ public function output_list_table_filters( $post_type, $view_name )
233
+ {
234
+ if ($post_type != 'attachment') {
235
+ return;
236
+ }
237
+
238
+ if ($view_name != 'bar') {
239
+ return;
240
+ }
241
+
242
+ $current_term = false;
243
+ if ( isset( $_REQUEST['media_folder'] ) ) {
244
+ $current_term = sanitize_text_field($_REQUEST['media_folder']);
245
+ }
246
+
247
+ wp_dropdown_categories( array(
248
+ 'show_option_all' => __( 'All Folders', WCP_FOLDER ),
249
+ 'show_option_none' => __( '(Unassigned)', WCP_FOLDER ),
250
+ 'option_none_value' => -1,
251
+ 'orderby' => 'name',
252
+ 'order' => 'ASC',
253
+ 'show_count' => true,
254
+ 'hide_empty' => false,
255
+ 'echo' => true,
256
+ 'selected' => $current_term,
257
+ 'hierarchical' => true,
258
+ 'name' => 'media_folder',
259
+ 'id' => '',
260
+ 'class' => '',
261
+ 'taxonomy' => 'media_folder',
262
+ 'value_field' => 'slug',
263
+ ) );
264
+
265
+ }
266
+
267
+
268
+ function new_to_auto_draft($post) {
269
+
270
+ $post_type = $post->post_type;
271
+
272
+ if(self::is_for_this_post_type($post_type)) {
273
+
274
+ $post_type = self::get_custom_post_type($post_type);
275
+ $selected_folder = get_option("selected_{$post_type}_folder");
276
+
277
+ if($selected_folder != null && !empty($selected_folder)) {
278
+ $terms = get_term($selected_folder);
279
+ if(!empty($terms) && isset($terms->slug)) {
280
+ wp_set_object_terms($post->ID, $terms->slug, $post_type );
281
+ }
282
+
283
+ }
284
+ }
285
+ }
286
+
287
+ public function wcp_folder_send_message_to_owner() {
288
+ $response = array();
289
+ $response['status'] = 0;
290
+ $response['error'] = 0;
291
+ $response['errors'] = array();
292
+ $response['message'] = "";
293
+ $errorArray = [];
294
+ $errorMessage = __("%s is required", WCP_FOLDER);
295
+ $postData = $_POST;
296
+ if(!isset($postData['textarea_text']) || trim($postData['textarea_text']) == "") {
297
+ $error = array(
298
+ "key" => "textarea_text",
299
+ "message" => __("Please enter your message",WCP_FOLDER)
300
+ );
301
+ $errorArray[] = $error;
302
+ }
303
+ if(!isset($postData['user_email']) || trim($postData['user_email']) == "") {
304
+ $error = array(
305
+ "key" => "user_email",
306
+ "message" => sprintf($errorMessage,__("Email",WCP_FOLDER))
307
+ );
308
+ $errorArray[] = $error;
309
+ } else if(!filter_var($postData['user_email'], FILTER_VALIDATE_EMAIL)) {
310
+ $error = array(
311
+ 'key' => "user_email",
312
+ "message" => "Email is not valid"
313
+ );
314
+ $errorArray[] = $error;
315
+ }
316
+ if(empty($errorArray)) {
317
+ if(!isset($postData['folder_help_nonce']) || trim($postData['folder_help_nonce']) == "") {
318
+ $error = array(
319
+ "key" => "nonce",
320
+ "message" => __("Your request is not valid", WCP_FOLDER)
321
+ );
322
+ $errorArray[] = $error;
323
+ } else {
324
+ if(!wp_verify_nonce($postData['folder_help_nonce'], 'wcp_folder_help_nonce')) {
325
+ $error = array(
326
+ "key" => "nonce",
327
+ "message" => __("Your request is not valid", WCP_FOLDER)
328
+ );
329
+ $errorArray[] = $error;
330
+ }
331
+ }
332
+ }
333
+ if(empty($errorArray)) {
334
+ global $current_user;
335
+ $text_message = self::sanitize_options($postData['textarea_text']);
336
+ $email = self::sanitize_options($postData['user_email'],"email");
337
+ $domain = site_url();
338
+ $user_name = $current_user->first_name." ".$current_user->last_name;
339
+ $subject = "Folder request: ".$domain;
340
+ $headers = "MIME-Version: 1.0\r\n";
341
+ $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
342
+ $headers .= 'From: '.$user_name.' <'.$email.'>'.PHP_EOL ;
343
+ $headers .= 'Reply-To: '.$user_name.' <'.$email.'>'.PHP_EOL ;
344
+ $headers .= 'X-Mailer: PHP/' . phpversion();
345
+ ob_start();
346
+ ?>
347
+ <table border="0" cellspacing="0" cellpadding="5">
348
+ <tr>
349
+ <th>Domain</th>
350
+ <td><?php echo $domain ?></td>
351
+ </tr>
352
+ <tr>
353
+ <th>Email</th>
354
+ <td><?php echo $email ?></td>
355
+ </tr>
356
+ <tr>
357
+ <th>Message</th>
358
+ <td><?php echo nl2br($text_message) ?></td>
359
+ </tr>
360
+ </table>
361
+ <?php
362
+ $message = ob_get_clean();
363
+ $to = "contact+fromwp@premio.io";
364
+ $status = wp_mail($to, $subject, $message, $headers);
365
+ if($status) {
366
+ $response['status'] = 1;
367
+ } else {
368
+ $response['status'] = 0;
369
+ $response['message'] = "Not able to send mail";
370
+ }
371
+ } else {
372
+ $response['error'] = 1;
373
+ $response['errors'] = $errorArray;
374
+ }
375
+ echo json_encode($response);
376
+ }
377
+
378
+ public function folder_plugin_deactivate() {
379
+ global $current_user;
380
+ $postData = $_POST;
381
+ $errorCounter = 0;
382
+ $response = array();
383
+ $response['status'] = 0;
384
+ $response['message'] = "";
385
+ $response['valid'] = 1;
386
+ if(!isset($postData['reason']) || empty($postData['reason'])) {
387
+ $errorCounter++;
388
+ $response['message'] = "Please provide reason";
389
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
390
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
391
+ $errorCounter++;
392
+ $response['valid'] = 0;
393
+ } else {
394
+ $nonce = self::sanitize_options($postData['nonce']);
395
+ if(!wp_verify_nonce($nonce, 'wcp_folder_deactivate_nonce')) {
396
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
397
+ $errorCounter++;
398
+ $response['valid'] = 0;
399
+ }
400
+ }
401
+ if($errorCounter == 0) {
402
+ $reason = $postData['reason'];
403
+ $email = get_option( 'admin_email' );
404
+ $domain = site_url();
405
+ $user_name = $current_user->first_name." ".$current_user->last_name;
406
+ $subject = "Folders was removed from {$domain}";
407
+ $headers = "MIME-Version: 1.0\r\n";
408
+ $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
409
+ $headers .= 'From: '.$user_name.' <'.$email.'>'.PHP_EOL ;
410
+ $headers .= 'Reply-To: '.$user_name.' <'.$email.'>'.PHP_EOL ;
411
+ $headers .= 'X-Mailer: PHP/' . phpversion();
412
+ ob_start();
413
+ ?>
414
+ <table border="0" cellspacing="0" cellpadding="5">
415
+ <tr>
416
+ <th>Plugin</th>
417
+ <td>Folders</td>
418
+ </tr>
419
+ <tr>
420
+ <th>Plugin Version</th>
421
+ <td><?php echo WCP_FOLDER_VERSION ?></td>
422
+ </tr>
423
+ <tr>
424
+ <th>Domain</th>
425
+ <td><?php echo $domain ?></td>
426
+ </tr>
427
+ <tr>
428
+ <th>Email</th>
429
+ <td><?php echo $email ?></td>
430
+ </tr>
431
+ <tr>
432
+ <th>Comment</th>
433
+ <td><?php echo nl2br($reason) ?></td>
434
+ </tr>
435
+ <tr>
436
+ <th>WordPress Version</th>
437
+ <td><?php echo get_bloginfo('version') ?></td>
438
+ </tr>
439
+ <tr>
440
+ <th>PHP Version</th>
441
+ <td><?php echo PHP_VERSION ?></td>
442
+ </tr>
443
+ </table>
444
+ <?php
445
+ $content = ob_get_clean();
446
+ $to = "contact+removed@premio.io";
447
+ wp_mail($to, $subject, $content, $headers);
448
+ $response['status'] = 1;
449
+ }
450
+ echo json_encode($response);
451
+ die;
452
+ }
453
 
454
  public function check_has_valid_key()
455
  {
456
  return 0;
457
  }
458
 
459
+ public static function total_term_folders()
460
  {
461
  $post_types = get_option(WCP_FOLDER_VAR);
462
  $post_types = is_array($post_types)?$post_types:array();
468
  return $total;
469
  }
470
 
 
 
 
 
 
471
  public function get_license_key_information($licenseKey)
472
  {
473
  return array();
507
  $response['data'] = array();
508
  $response['message'] = "";
509
  $postData = $_POST;
510
+ $errorCounter = 0;
511
+ if (!isset($postData['type']) || empty($postData['type'])) {
512
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
513
+ $errorCounter++;
514
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
515
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
516
+ $errorCounter++;
517
+ } else if (!current_user_can("manage_categories") || ($postData['type'] == "page" && !current_user_can("edit_pages"))) {
518
+ $response['message'] = __("You have not permission to update width", WCP_FOLDER);
519
+ $errorCounter++;
520
+ } else if (!current_user_can("manage_categories") || ($postData['type'] != "page" && !current_user_can("edit_posts"))) {
521
+ $response['message'] = __("You have not permission to update width", WCP_FOLDER);
522
+ $errorCounter++;
523
+ } else {
524
+ $type = self::sanitize_options($postData['type']);
525
+ $nonce = self::sanitize_options($postData['nonce']);
526
+ if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
527
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
528
+ $errorCounter++;
529
+ }
530
+ }
531
+ if ($errorCounter == 0) {
532
+ if (isset($postData['folders']) || !empty($postData['folders'])) {
533
+ $status = isset($postData['status']) ? $postData['status'] : 0;
534
+ $status = self::sanitize_options($status);
535
+ $folders = self::sanitize_options($postData['folders']);
536
+ $folders = trim($folders, ",");
537
+ $folders = explode(",", $folders);
538
+ foreach ($folders as $folder) {
539
+ update_term_meta($folder, "is_active", $status);
540
+ }
541
  }
542
+ $response['status'] = 1;
543
  }
544
  echo json_encode($response);
545
  die;
553
  $response['data'] = array();
554
  $response['message'] = "";
555
  $postData = $_POST;
556
+ $errorCounter = 0;
557
+ if (!isset($postData['width']) || empty($postData['width'])) {
558
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
559
+ $errorCounter++;
560
+ } else if (!isset($postData['type']) || empty($postData['type'])) {
561
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
562
+ $errorCounter++;
563
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
564
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
565
+ $errorCounter++;
566
+ } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
567
+ $response['message'] = __("You have not permission to update width", WCP_FOLDER);
568
+ $errorCounter++;
569
+ } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
570
+ $response['message'] = __("You have not permission to update width", WCP_FOLDER);
571
+ $errorCounter++;
572
+ } else {
573
+ $type = self::sanitize_options($postData['type']);
574
+ $nonce = self::sanitize_options($postData['nonce']);
575
+ if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
576
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
577
+ $errorCounter++;
578
+ }
579
+ }
580
+ if ($errorCounter == 0) {
581
+ $type = self::sanitize_options($postData['type']);
582
+ $width = self::sanitize_options($postData['width'], "int");
583
+ $optionName = "wcp_dynamic_width_for_" . $type;
584
+ update_option($optionName, $width);
585
  $response['status'] = 1;
586
  }
587
  echo json_encode($response);
596
  $response['data'] = array();
597
  $response['message'] = "";
598
  $postData = $_POST;
599
+ $errorCounter = 0;
600
+ if (!isset($postData['post_ids']) || empty($postData['post_ids'])) {
601
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
602
+ $errorCounter++;
603
+ } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
604
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
605
+ $errorCounter++;
606
+ } else if (!isset($postData['type']) || empty($postData['type'])) {
607
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
608
+ $errorCounter++;
609
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
610
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
611
+ $errorCounter++;
612
+ } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
613
+ $response['message'] = __("You have not permission to update folder", WCP_FOLDER);
614
+ $errorCounter++;
615
+ } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
616
+ $response['message'] = __("You have not permission to update folder", WCP_FOLDER);
617
+ $errorCounter++;
618
+ } else {
619
+ $folder_id = self::sanitize_options($postData['folder_id']);
620
+ if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$folder_id)) {
621
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
622
+ $errorCounter++;
623
+ }
624
+ }
625
+ if ($errorCounter == 0) {
626
+ $postID = self::sanitize_options($postData['post_ids']);
627
  $postID = trim($postID, ",");
628
+ $folderID = self::sanitize_options($postData['folder_id']);
629
+ $type = self::sanitize_options($postData['type']);
630
  $postArray = explode(",", $postID);
631
  if (is_array($postArray)) {
632
  foreach ($postArray as $post) {
633
+ $post_type = self::get_custom_post_type($type);
634
  wp_set_post_terms($post, $folderID, $post_type, false);
635
  }
636
  }
648
  $response['data'] = array();
649
  $response['message'] = "";
650
  $postData = $_POST;
651
+ $errorCounter = 0;
652
+ if (!isset($postData['post_id']) || empty($postData['post_id'])) {
653
+ $errorCounter++;
654
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
655
+ } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
656
+ $errorCounter++;
657
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
658
+ } else if (!isset($postData['type']) || empty($postData['type'])) {
659
+ $errorCounter++;
660
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
661
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
662
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
663
+ $errorCounter++;
664
+ } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
665
+ $response['message'] = __("You have not permission to update folder", WCP_FOLDER);
666
+ $errorCounter++;
667
+ } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
668
+ $response['message'] = __("You have not permission to update folder", WCP_FOLDER);
669
+ $errorCounter++;
670
+ } else {
671
+ $term_id = self::sanitize_options($postData['folder_id']);
672
+ if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
673
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
674
+ $errorCounter++;
675
+ }
676
+ }
677
+ if ($errorCounter == 0) {
678
+ $postID = self::sanitize_options($postData['post_id']);
679
+ $folderID = self::sanitize_options($postData['folder_id']);
680
+ $type = self::sanitize_options($postData['type']);
681
+ $folder_post_type = self::get_custom_post_type($type);
682
  $terms = get_the_terms($postID, $folder_post_type);
683
  if (!empty($terms)) {
684
  foreach ($terms as $term) {
700
  $response['data'] = array();
701
  $response['message'] = "";
702
  $postData = $_POST;
703
+ $errorCounter = 0;
704
+ if (!current_user_can("manage_categories")) {
705
+ $response['message'] = __("You have not permission to update folder", WCP_FOLDER);
706
+ $errorCounter++;
707
+ } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
708
+ $errorCounter++;
709
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
710
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
711
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
712
+ $errorCounter++;
713
+ } else {
714
+ $term_id = self::sanitize_options($postData['term_id']);
715
+ if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_highlight_term_'.$term_id)) {
716
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
717
+ $errorCounter++;
718
+ }
719
+ }
720
+ if ($errorCounter == 0) {
721
+ $term_id = self::sanitize_options($postData['term_id']);
722
+ $status = get_term_meta($term_id, "is_highlighted", true);
723
  if ($status == 1) {
724
+ update_term_meta($term_id, "is_highlighted", 0);
725
  $status = 0;
726
  } else {
727
+ update_term_meta($term_id, "is_highlighted", 1);
728
  $status = 1;
729
  }
730
  $response['marked'] = $status;
743
  $response['data'] = array();
744
  $response['message'] = "";
745
  $postData = $_POST;
746
+ $errorCounter = 0;
747
+ if (!current_user_can("manage_categories")) {
748
+ $response['message'] = __("You have not permission to update folder order", WCP_FOLDER);
749
+ $errorCounter++;
750
+ } else if (!isset($postData['term_ids']) || empty($postData['term_ids'])) {
751
+ $errorCounter++;
752
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
753
+ } else if (!isset($postData['type']) || empty($postData['type'])) {
754
+ $errorCounter++;
755
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
756
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
757
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
758
+ $errorCounter++;
759
+ } else {
760
+ $type = self::sanitize_options($postData['type']);
761
+ if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
762
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
763
+ $errorCounter++;
764
+ }
765
+ }
766
+ if ($errorCounter == 0) {
767
+ $termIds = self::sanitize_options(($postData['term_ids']));
768
+ $type = self::sanitize_options($postData['type']);
769
  $termIds = trim($termIds, ",");
770
  $termArray = explode(",", $termIds);
771
  $order = 1;
776
  }
777
  }
778
  $response['status'] = 1;
779
+ $folder_type = self::get_custom_post_type($type);
780
  $response['options'] = WCP_Tree::get_option_data_for_select($folder_type);
781
+
782
  }
783
  echo json_encode($response);
784
  die;
792
  $response['data'] = array();
793
  $response['message'] = "";
794
  $postData = $_POST;
795
+ $errorCounter = 0;
796
+ if (!current_user_can("manage_categories")) {
797
+ $response['message'] = __("You have not permission to update folder", WCP_FOLDER);
798
+ $errorCounter++;
799
+ } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
800
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
801
+ $errorCounter++;
802
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
803
+ $response['message'] = "Unable to create folder, Your request is not valid";
804
+ $errorCounter++;
805
+ } else {
806
+ $term_id = self::sanitize_options($postData['term_id']);
807
+ if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
808
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
809
+ $errorCounter++;
810
+ }
811
+ }
812
+ if ($errorCounter == 0) {
813
+ $response['status'] = 1;
814
+ $term_id = self::sanitize_options($postData['term_id']);
815
+ $is_active = isset($postData['is_active'])?$postData['is_active']:0;
816
+ $is_active = self::sanitize_options($is_active);
817
+ if ($is_active == 1) {
818
+ update_term_meta($term_id, "is_active", 1);
819
  } else {
820
+ update_term_meta($term_id, "is_active", 0);
821
  }
822
  }
823
  echo json_encode($response);
832
  $response['data'] = array();
833
  $response['message'] = "";
834
  $postData = $_POST;
835
+ $errorCounter = 0;
836
+ if (!current_user_can("manage_categories")) {
837
+ $response['message'] = __("You have not permission to update folder", WCP_FOLDER);
838
+ $errorCounter++;
839
+ } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
840
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
841
+ $errorCounter++;
842
+ } else if (!isset($postData['type']) || empty($postData['type'])) {
843
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
844
+ $errorCounter++;
845
+ } else if (!isset($postData['parent_id'])) {
846
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
847
+ $errorCounter++;
848
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
849
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
850
+ $errorCounter++;
851
+ } else {
852
+ $term_id = self::sanitize_options($postData['term_id']);
853
+ if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
854
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
855
+ $errorCounter++;
856
+ }
857
+ }
858
+ if($errorCounter == 0) {
859
+ $term_id = self::sanitize_options($postData['term_id']);
860
+ $parent_id = self::sanitize_options($postData['parent_id']);
861
+ $type = self::sanitize_options($postData['type']);
862
+ $folder_type = self::get_custom_post_type($type);
863
+ wp_update_term($term_id, $folder_type, array(
864
+ 'parent' => $parent_id
865
  ));
866
+ update_term_meta($parent_id, "is_active", 1);
867
+ $response['status'] = 1;
868
  }
869
  echo json_encode($response);
870
  die;
878
  $response['data'] = array();
879
  $response['message'] = "";
880
  $postData = $_POST;
881
+ $errorCounter = 0;
882
+ if (!isset($postData['type']) || empty($postData['type'])) {
883
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
884
+ $errorCounter++;
885
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
886
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
887
+ $errorCounter++;
888
+ } else {
889
+ $type = self::sanitize_options($postData['type']);
890
+ if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
891
+ $response['message'] = __("Your request is not valid", WCP_FOLDER);
892
+ $errorCounter++;
893
+ }
894
+ }
895
+ if ($errorCounter == 0) {
896
+ $type = self::sanitize_options($postData['type']);
897
+ $optionName = $type . "_parent_status";
898
+ $response['status'] = 1;
899
+ $is_active = isset($postData['is_active'])?$postData['is_active']:0;
900
+ $is_active = self::sanitize_options($is_active);
901
+ if ($is_active == 1) {
902
  update_option($optionName, 1);
903
  } else {
904
  update_option($optionName, 0);
917
  $response['message'] = "";
918
  $postData = $_POST;
919
  $errorCounter = 0;
920
+ if (!current_user_can("manage_categories")) {
921
+ $error = __("You have not permission to remove folder", WCP_FOLDER);
922
+ $errorCounter++;
923
+ } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
924
+ $error = __("Your request is not valid", WCP_FOLDER);
925
  $errorCounter++;
926
  } else if (!isset($postData['type']) || empty($postData['type'])) {
927
+ $error = __("Your request is not valid", WCP_FOLDER);
928
+ $errorCounter++;
929
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
930
+ $error = "Unable to delete folder, Your request is not valid";
931
  $errorCounter++;
932
+ } else {
933
+ $term_id = self::sanitize_options($postData['term_id']);
934
+ if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_delete_term_'.$term_id)) {
935
+ $error = "Unable to delete folder, Your request is not valid";
936
+ $errorCounter++;
937
+ }
938
  }
939
  if ($errorCounter == 0) {
940
+ $term_id = self::sanitize_options($postData['term_id']);
941
+ $type = self::sanitize_options($postData['type']);
942
+ self::remove_folder_child_items($term_id, $type);
943
  $response['status'] = 1;
944
  $is_active = 1;
945
  $folders = -1;
984
  $response['message'] = "";
985
  $postData = $_REQUEST;
986
  $errorCounter = 0;
987
+ if (!current_user_can("manage_categories")) {
988
+ $error = __("You have not permission to update folder", WCP_FOLDER);
989
+ $errorCounter++;
990
+ } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
991
+ $error = __("Unable to rename folder, Your request is not valid", WCP_FOLDER);
992
+ $errorCounter++;
993
+ } else if (!isset($postData['name']) || empty($postData['name'])) {
994
+ $error = __("Folder name can no be empty", WCP_FOLDER);
995
  $errorCounter++;
996
  } else if (!isset($postData['type']) || empty($postData['type'])) {
997
+ $error = __("Your request is not valid", WCP_FOLDER);
998
  $errorCounter++;
999
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1000
+ $error = __("Unable to rename folder, Your request is not valid", WCP_FOLDER);
1001
+ $errorCounter++;
1002
+ } else {
1003
+ $term_id = self::sanitize_options($postData['term_id']);
1004
+ if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_rename_term_'.$term_id)) {
1005
+ $error = _("Unable to rename folder, Your request is not valid", WCP_FOLDER);
1006
+ $errorCounter++;
1007
+ }
1008
  }
1009
  if ($errorCounter == 0) {
1010
+ $type = self::sanitize_options($postData['type']);
1011
+ $folder_type = self::get_custom_post_type($type);
1012
+ $name = self::sanitize_options($postData['name']);
1013
+ $term_id = self::sanitize_options($postData['term_id']);
1014
  $result = wp_update_term(
1015
+ $term_id,
1016
+ $folder_type,
1017
  array(
1018
+ 'name' => $name,
1019
  )
1020
  );
1021
  if (!empty($result)) {
1023
  $response['status'] = 1;
1024
  $response['term_title'] = $postData['name'];
1025
  } else {
1026
+ $response['message'] = __("Unable to rename folder", WCP_FOLDER);
1027
  }
 
 
 
1028
  } else {
1029
  $response['error'] = 1;
1030
  $response['message'] = $error;
1040
  return strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), str_replace($a, $b, $str)));
1041
  }
1042
 
1043
+ public static function sanitize_options($value, $type = "") {
1044
+ $value = stripslashes($value);
1045
+ if($type == "int") {
1046
+ $value = filter_var($value, FILTER_SANITIZE_NUMBER_INT);
1047
+ } else if($type == "email") {
1048
+ $value = sanitize_email($value);
1049
+ } else {
1050
+ $value = sanitize_text_field($value);
1051
+ }
1052
+ return $value;
1053
+ }
1054
+
1055
  public function wcp_add_new_folder()
1056
  {
1057
  $response = array();
1058
  $response['status'] = 0;
1059
  $response['error'] = 0;
1060
+ $response['login'] = 1;
1061
  $response['data'] = array();
1062
  $response['message'] = "";
1063
  $postData = $_REQUEST;
1064
  $errorCounter = 0;
1065
+ if (!current_user_can("manage_categories")) {
1066
+ $error = __("You have not permission to add folder", WCP_FOLDER);
1067
+ $errorCounter++;
1068
+ } else if (!isset($postData['name']) || empty($postData['name'])) {
1069
+ $error = __("Folder name can no be empty", WCP_FOLDER);
1070
  $errorCounter++;
1071
  } else if (!isset($postData['type']) || empty($postData['type'])) {
1072
+ $error = __("Your request is not valid", WCP_FOLDER);
1073
  $errorCounter++;
1074
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1075
+ $response['login'] = 0;
1076
+ $error = __("Unable to create folder, Your request is not valid", WCP_FOLDER);
1077
+ $errorCounter++;
1078
+ } else {
1079
+ $type = self::sanitize_options($postData['type']);
1080
+ if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
1081
+ $response['login'] = 0;
1082
+ $error = __("Unable to create folder, Your request is not valid", WCP_FOLDER);
1083
+ $errorCounter++;
1084
+ }
1085
  }
1086
  if ($errorCounter == 0) {
1087
  $parent = isset($postData['parent_id']) && !empty($postData['parent_id']) ? $postData['parent_id'] : 0;
1088
+ $parent = self::sanitize_options($parent);
1089
+ $type = self::sanitize_options($postData['type']);
1090
+ $folder_type = self::get_custom_post_type($type);
1091
+ $term_name = self::sanitize_options($postData['name']);
1092
+ $term = term_exists($term_name, $folder_type, $parent);
1093
  if (!(0 !== $term && null !== $term)) {
1094
  $slug = self::create_slug_from_string($postData['name']) . "-" . time();
1095
  $result = wp_insert_term(
1104
  $response['id'] = $result['term_id'];
1105
  $response['status'] = 1;
1106
  $order = isset($postData['order']) ? $postData['order'] : 0;
1107
+ $order = self::sanitize_options($order);
1108
  update_term_meta($result['term_id'], "wcp_custom_order", $order);
1109
  if ($parent != 0) {
1110
  update_term_meta($parent, "is_active", 1);
1111
  }
1112
+ $delete_nonce = wp_create_nonce('wcp_folder_delete_term_'.$result['term_id']);
1113
+ $rename_nonce = wp_create_nonce('wcp_folder_rename_term_'.$result['term_id']);
1114
+ $highlight_nonce = wp_create_nonce('wcp_folder_highlight_term_'.$result['term_id']);
1115
+ $term_nonce = wp_create_nonce('wcp_folder_term_'.$result['term_id']);
1116
+ $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']}'>";
1117
  $string .= "</ul></li>";
1118
  $response['term_data'] = $string;
1119
  $response['parent_id'] = $parent;
1127
  $response['is_key_active'] = $is_active;
1128
  $response['folders'] = $folders;
1129
  } else {
1130
+ $response['message'] = __("Error during server request", WCP_FOLDER);
1131
  }
1132
  } else {
1133
  $response['error'] = 1;
1134
+ $response['message'] = __("Folder name already exists", WCP_FOLDER);
1135
  }
1136
  } else {
1137
  $response['error'] = 1;
1193
  }
1194
  $response['folders'] = $folders;
1195
  $response['is_key_active'] = $is_active;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1196
  }
1197
  }
1198
 
1199
+ public static function get_custom_post_type($post_type)
1200
  {
1201
  if ($post_type == "post") {
1202
  return "post_folder";
1210
 
1211
  public function admin_footer()
1212
  {
1213
+
1214
  if (self::is_active_for_screen()) {
1215
  global $typenow;
1216
 
1222
  $form_html = WCP_Forms::get_form_html($terms_html);
1223
  include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "admin-content.php";
1224
  }
1225
+
1226
+ global $pagenow;
1227
+ if ( 'plugins.php' !== $pagenow ) {
1228
+
1229
+ } else {
1230
+ include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "folder-deactivate-form.php";
1231
+ }
1232
  }
1233
 
1234
  public function get_total_posts($post_type = "")
1271
  }
1272
  if (in_array($option, array("page", "post", "attachment"))) {
1273
  $posts[] = str_replace("folder4", "", $option);
1274
+ } else {
1275
+ $posts[] = $option;
1276
  }
1277
  }
1278
  if(!empty($posts)) {
1327
  }
1328
  }
1329
 
1330
+ if(current_user_can("manage_categories")) {
1331
+ if (isset($_POST['folders_show_in_menu']) && !empty($_POST['folders_show_in_menu'])) {
1332
+ $show_menu = "off";
1333
+ if ($_POST['folders_show_in_menu'] == "on") {
1334
+ $show_menu = "on";
1335
+ }
1336
+ update_option("folders_show_in_menu", $show_menu);
1337
  }
 
 
1338
 
1339
+ if (isset($_POST['folders_settings1'])) {
1340
+ $posts = array();
1341
+ if (isset($_POST['folders_settings']) && is_array($_POST['folders_settings'])) {
1342
+ foreach ($_POST['folders_settings'] as $key => $val) {
1343
+ $posts[] = $val;
1344
+ }
1345
  }
1346
+ update_option("folders_settings", $posts);
1347
  }
 
1348
  }
1349
 
1350
  $old_version = get_option("folder_old_plugin_status");
1468
  if (self::is_active_for_screen()) {
1469
  global $typenow;
1470
  $width = get_option("wcp_dynamic_width_for_" . $typenow);
1471
+ $width = esc_attr($width);
1472
+ if (!empty($width) && is_numeric($width)) {
1473
  $css .= ".wcp-content{width:{$width}px}";
1474
  if ( function_exists( 'is_rtl' ) && is_rtl() ) {
1475
  $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:" . ($width + 20) . "px}";
1486
  global $typenow;
1487
  add_filter('views_edit-' . $typenow, array($this, 'wcp_check_for_child_folders'));
1488
  }
1489
+
1490
  }
1491
 
1492
+ function wcp_check_for_child_folders($content)
1493
  {
1494
  $termId = 0;
1495
  global $typenow;
1534
  echo '</ul>';
1535
  echo '<div class="clear clearfix"></div>';
1536
  echo '</div>';
1537
+ if(!empty($content) && is_array($content)) {
1538
+ echo '<ul class="subsubsub">';
1539
+ foreach($content as $k=>$v) {
1540
+ echo "<li class='{$k}'>{$v}</li>";
1541
+ }
1542
+ echo '</ul>';
1543
+ }
1544
  }
1545
 
1546
  function folders_admin_scripts()
1574
  $is_rtl = 1;
1575
  }
1576
 
1577
+ $can_manage_folder = current_user_can("manage_categories")?1:0;
1578
  wp_localize_script('wcp-folders-custom', 'wcp_settings', array(
1579
  'ajax_url' => admin_url('admin-ajax.php'),
1580
  'post_type' => $typenow,
1583
  'is_key_active' => $is_active,
1584
  'folders' => $folders,
1585
  'register_url' => $register_url,
1586
+ 'isRTL' => $is_rtl,
1587
+ 'nonce' => wp_create_nonce('wcp_folder_nonce_'.$typenow),
1588
+ 'can_manage_folder' => $can_manage_folder
1589
  ));
1590
+
1591
  wp_enqueue_script('wcp-folders-alert');
1592
  wp_enqueue_script('wcp-folders-custom');
1593
 
1679
 
1680
  foreach ($options as $option) {
1681
  if ($option != "post" && $option != "page" && $option != "attachment") {
1682
+ add_filter('manage_media_columns', array($this, 'wcp_manage_columns_head'));
1683
+ add_action('manage_media_custom_column', array($this, 'wcp_manage_columns_content'), 10, 2);
1684
  }
1685
  }
1686
 
1692
  }
1693
  }
1694
 
1695
+ function wcp_manage_columns_head($defaults, $d = "")
1696
  {
1697
  global $typenow;
1698
  $options = get_option("folders_settings");
1729
  $taxonomy_slugs[] = self::get_custom_post_type($option);
1730
  }
1731
  if (!empty($taxonomy_slugs)) {
1732
+ $i = 0;
1733
+ foreach ($query->tax_query->queries as $tax_query_item) {
1734
+ if (empty($taxonomy_slugs) || (isset($tax_query_item['taxonomy']) && in_array($tax_query_item['taxonomy'], $taxonomy_slugs))) {
1735
+ $query->tax_query->queries[$i]['include_children'] = 0;
 
1736
  }
1737
  }
1738
  }
includes/form.class.php CHANGED
@@ -1,10 +1,13 @@
1
  <?php
 
 
 
2
  class WCP_Forms {
3
  public function __construct() {
4
  parent::__construct();
5
  }
6
 
7
- public function get_form_html($option_data = "") {
8
  ob_start();
9
  ?>
10
  <div class="wcp-custom-form">
1
  <?php
2
+
3
+ defined('ABSPATH') or die('Nope, not accessing this');
4
+
5
  class WCP_Forms {
6
  public function __construct() {
7
  parent::__construct();
8
  }
9
 
10
+ public static function get_form_html($option_data = "") {
11
  ob_start();
12
  ?>
13
  <div class="wcp-custom-form">
includes/plugin.updates.php CHANGED
@@ -1,5 +1,7 @@
1
  <?php
2
 
 
 
3
  // Exit if accessed directly
4
  if ( ! defined( 'ABSPATH' ) ) exit;
5
 
1
  <?php
2
 
3
+ defined('ABSPATH') or die('Nope, not accessing this');
4
+
5
  // Exit if accessed directly
6
  if ( ! defined( 'ABSPATH' ) ) exit;
7
 
includes/tree.class.php CHANGED
@@ -1,15 +1,20 @@
1
  <?php
 
2
  class WCP_Tree {
3
  public function __construct() {
4
  parent::__construct();
5
  }
6
 
7
- public function get_full_tree_data($post_type) {
 
 
 
 
8
  $string = self::get_folder_category_data($post_type, 0, 0);
9
  return $string['string'];
10
  }
11
 
12
- public function get_folder_category_data($post_type, $parent = 0, $parentStatus = 0) {
13
  // echo "<pre>"; print_r($post_type); die;
14
  $terms = get_terms( $post_type, array(
15
  'hide_empty' => false,
@@ -25,6 +30,7 @@ class WCP_Tree {
25
  ));
26
  $string = "";
27
  $child = 0;
 
28
  if(!empty($terms)) {
29
  $child = count($terms);
30
  foreach($terms as $term) {
@@ -34,13 +40,31 @@ class WCP_Tree {
34
  $class .= ($return['child'])>0?" has-sub-tree":"";
35
  if($post_type == "attachment") {
36
  $class .= (isset($_GET['term']) && $_GET['term'] == $term->slug)?" active-item active-term":"";
 
 
 
 
 
 
 
37
  } else {
38
  $class .= (isset($_GET[$post_type]) && $_GET[$post_type] == $term->slug)?" active-item active-term":"";
 
 
 
 
 
 
 
39
  }
40
  $status = get_term_meta($term->term_id, "is_highlighted", true);
41
  $class .= ($status == 1)?" is-high":"";
42
  $count = ($term->count != 0)?"<span class='total-count'>{$term->count}</span>":"";
43
- $string .= "<li data-slug='{$term->slug}' class='ui-state-default route {$class}' id='wcp_folder_{$term->term_id}' data-folder-id='{$term->term_id}'><h3 class='title' title='{$term->name}' id='title_{$term->term_id}'><span class='title-text'>{$term->name}</span> <span class='update-inline-record'></span> {$count} <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_{$term->term_id}'>";
 
 
 
 
44
  $string .= $return['string'];
45
  $string .= "</ul></li>";
46
  }
@@ -51,13 +75,13 @@ class WCP_Tree {
51
  );
52
  }
53
 
54
- public function get_option_data_for_select($post_type) {
55
  $string = "<option value='0'>Parent Folder</option>";
56
  $string .= self::get_folder_option_data($post_type, 0, '&nbsp;&nbsp;');
57
  return $string;
58
  }
59
 
60
- public function get_folder_option_data($post_type, $parent = 0, $space) {
61
  $terms = get_terms( $post_type, array(
62
  'hide_empty' => false,
63
  'parent' => $parent,
1
  <?php
2
+ defined('ABSPATH') or die('Nope, not accessing this');
3
  class WCP_Tree {
4
  public function __construct() {
5
  parent::__construct();
6
  }
7
 
8
+ public static function get_full_tree_data($post_type) {
9
+ $isAjax = (!empty( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) == 'xmlhttprequest')?1:0;
10
+ if(isset($_GET[$post_type]) || ! $isAjax) {
11
+ update_option("selected_" . $post_type . "_folder", "");
12
+ }
13
  $string = self::get_folder_category_data($post_type, 0, 0);
14
  return $string['string'];
15
  }
16
 
17
+ public static function get_folder_category_data($post_type, $parent = 0, $parentStatus = 0) {
18
  // echo "<pre>"; print_r($post_type); die;
19
  $terms = get_terms( $post_type, array(
20
  'hide_empty' => false,
30
  ));
31
  $string = "";
32
  $child = 0;
33
+ $isAjax = (!empty( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) == 'xmlhttprequest')?1:0;
34
  if(!empty($terms)) {
35
  $child = count($terms);
36
  foreach($terms as $term) {
40
  $class .= ($return['child'])>0?" has-sub-tree":"";
41
  if($post_type == "attachment") {
42
  $class .= (isset($_GET['term']) && $_GET['term'] == $term->slug)?" active-item active-term":"";
43
+ if(isset($_GET[$post_type]) && $_GET[$post_type] == $term->slug) {
44
+ update_option("selected_".$post_type."_folder", $term->term_id);
45
+ }
46
+ if(!isset($_GET[$post_type]) && $isAjax) {
47
+ $termId = get_option("selected_".$post_type."_folder");
48
+ $class .= ($termId == $term->term_id)?" active-item active-term":"";
49
+ }
50
  } else {
51
  $class .= (isset($_GET[$post_type]) && $_GET[$post_type] == $term->slug)?" active-item active-term":"";
52
+ if(isset($_GET[$post_type]) && $_GET[$post_type] == $term->slug) {
53
+ update_option("selected_" . $post_type . "_folder", $term->term_id);
54
+ }
55
+ if(!isset($_GET[$post_type]) && $isAjax) {
56
+ $termId = get_option("selected_".$post_type."_folder");
57
+ $class .= ($termId == $term->term_id)?" active-item active-term":"";
58
+ }
59
  }
60
  $status = get_term_meta($term->term_id, "is_highlighted", true);
61
  $class .= ($status == 1)?" is-high":"";
62
  $count = ($term->count != 0)?"<span class='total-count'>{$term->count}</span>":"";
63
+ $delete_nonce = wp_create_nonce('wcp_folder_delete_term_'.$term->term_id);
64
+ $rename_nonce = wp_create_nonce('wcp_folder_rename_term_'.$term->term_id);
65
+ $highlight_nonce = wp_create_nonce('wcp_folder_highlight_term_'.$term->term_id);
66
+ $term_nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
67
+ $string .= "<li data-nonce='{$term_nonce}' data-star='{$highlight_nonce}' data-rename='{$rename_nonce}' data-delete='{$delete_nonce}' data-slug='{$term->slug}' class='ui-state-default route {$class}' id='wcp_folder_{$term->term_id}' data-folder-id='{$term->term_id}'><h3 class='title' title='{$term->name}' id='title_{$term->term_id}'><span class='title-text'>{$term->name}</span> <span class='update-inline-record'></span> {$count} <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_{$term->term_id}'>";
68
  $string .= $return['string'];
69
  $string .= "</ul></li>";
70
  }
75
  );
76
  }
77
 
78
+ public static function get_option_data_for_select($post_type) {
79
  $string = "<option value='0'>Parent Folder</option>";
80
  $string .= self::get_folder_option_data($post_type, 0, '&nbsp;&nbsp;');
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,
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.0.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.
@@ -42,12 +42,14 @@ E-Commerce businesses: Quickly upload new products and descriptions and then pla
42
 
43
  * Create new folders
44
  * Create and organize subfolders
45
- * Drag and drop pages, posts, and media
 
46
  * Drag and drop folders, change order, and hierarchy
47
  * Bulk select images and media files and drag them to any folder
48
- * Rename folders
 
49
  * Add stars to important directories
50
- * Simultaneously assign and organize media, pages, and posts while adding them to directories
51
  * Place content in multiple folders at once
52
  * Easily see subfolders within each file
53
  * Resize folders menu
@@ -107,6 +109,9 @@ Just follow our <a href="https://premio.io/wordpress-premio-pro-version-installa
107
 
108
  == Changelog ==
109
 
 
 
 
110
  = 2.0.5 =
111
  * Upgrade page change
112
 
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.1
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.
42
 
43
  * Create new folders
44
  * Create and organize subfolders
45
+ * Drag and drop pages, posts, and media library
46
+ * Select specific folders when you add media to your pages, posts or any other post type.
47
  * Drag and drop folders, change order, and hierarchy
48
  * Bulk select images and media files and drag them to any folder
49
+ * Rename folders
50
+ * Sticky toolbar for the media library so you can navigate and organize your folders with ease
51
  * Add stars to important directories
52
+ * Simultaneously assign and organize media, pages, posts, templates and custom posts while adding them to directories
53
  * Place content in multiple folders at once
54
  * Easily see subfolders within each file
55
  * Resize folders menu
109
 
110
  == Changelog ==
111
 
112
+ = 2.1.1 =
113
+ * Some exciting updates including: select relevant folders when you add media, keep your media library toolbar sticky when you organize you media, we support custom posts now, security fixes, bug fixes and more!
114
+
115
  = 2.0.5 =
116
  * Upgrade page change
117
 
templates/admin/admin-content.php CHANGED
@@ -1,9 +1,12 @@
 
 
 
1
  <style>
2
  .ui-state-highlight {
3
  background: transparent;
4
  border: dashed 1px #0073AA;
5
- width:150px;
6
- height: 25px !important;
7
  }
8
  <?php
9
  $string = "";
1
+ <?php
2
+ defined('ABSPATH') or die('Nope, not accessing this');
3
+ ?>
4
  <style>
5
  .ui-state-highlight {
6
  background: transparent;
7
  border: dashed 1px #0073AA;
8
+ width:180px;
9
+ height: 30px !important;
10
  }
11
  <?php
12
  $string = "";
templates/admin/folder-deactivate-form.php ADDED
@@ -0,0 +1,415 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined('ABSPATH') or die('Nope, not accessing this');
3
+ ?>
4
+ <style>
5
+ .folder-hidden {
6
+ overflow: hidden;
7
+ }
8
+
9
+ .folder-popup-overlay .folder-internal-message {
10
+ margin: 3px 0 3px 22px;
11
+ display: none;
12
+ }
13
+
14
+ .folder-reason-input {
15
+ margin: 3px 0 3px 22px;
16
+ display: none;
17
+ }
18
+
19
+ .folder-reason-input input[type="text"] {
20
+ width: 100%;
21
+ display: block;
22
+ }
23
+
24
+ .folder-popup-overlay {
25
+ background: rgba(0, 0, 0, .8);
26
+ position: fixed;
27
+ top: 0;
28
+ left: 0;
29
+ height: 100%;
30
+ width: 100%;
31
+ z-index: 1000;
32
+ overflow: auto;
33
+ visibility: hidden;
34
+ opacity: 0;
35
+ transition: opacity 0.3s ease-in-out :
36
+ }
37
+
38
+ .folder-popup-overlay.folder-active {
39
+ opacity: 1;
40
+ visibility: visible;
41
+ }
42
+
43
+ .folder-serveypanel {
44
+ width: 600px;
45
+ background: #fff;
46
+ margin: 65px auto 0;
47
+ }
48
+
49
+ .folder-popup-header {
50
+ background: #f1f1f1;
51
+ padding: 20px;
52
+ border-bottom: 1px solid #ccc;
53
+ }
54
+
55
+ .folder-popup-header h2 {
56
+ margin: 0;
57
+ }
58
+
59
+ .folder-popup-body {
60
+ padding: 10px 20px;
61
+ }
62
+
63
+ .folder-popup-footer {
64
+ background: #f9f3f3;
65
+ padding: 10px 20px;
66
+ border-top: 1px solid #ccc;
67
+ }
68
+
69
+ .folder-popup-footer:after {
70
+ content: "";
71
+ display: table;
72
+ clear: both;
73
+ }
74
+
75
+ .action-btns {
76
+ float: right;
77
+ }
78
+
79
+ .folder-anonymous {
80
+ display: none;
81
+ }
82
+
83
+ .attention, .error-message {
84
+ color: red;
85
+ font-weight: 600;
86
+ display: none;
87
+ }
88
+
89
+ .folder-spinner {
90
+ display: none;
91
+ }
92
+
93
+ .folder-spinner img {
94
+ margin-top: 3px;
95
+ }
96
+
97
+ .folder-hidden-input {
98
+ padding: 10px 0 0;
99
+ display: none;
100
+ }
101
+
102
+ .folder-hidden-input input[type='text'] {
103
+ padding: 0 10px;
104
+ width: 100%;
105
+ height: 26px;
106
+ line-height: 26px;
107
+ }
108
+
109
+ .folder-hidden-input textarea {
110
+ padding: 10px;
111
+ width: 100%;
112
+ }
113
+
114
+ span.folder-error-message {
115
+ color: #dd0000;
116
+ font-weight: 600;
117
+ }
118
+
119
+ .form-control textarea {
120
+ width: 100%;
121
+ height: 100px;
122
+ margin-bottom: 10px;
123
+ }
124
+
125
+
126
+ .folder-help-btn {
127
+ position: fixed;
128
+ right: 20px;
129
+ bottom: 20px;
130
+ z-index: 1001
131
+ }
132
+
133
+ .folder-help-btn a {
134
+ display: block;
135
+ border: 3px solid #FFF;
136
+ width: 50px;
137
+ height: 50px;
138
+ -webkit-border-radius: 50%;
139
+ -moz-border-radius: 50%;
140
+ border-radius: 50%;
141
+ position: relative
142
+ }
143
+
144
+ .folder-help-btn a img {
145
+ width: 100%;
146
+ height: auto;
147
+ display: block;
148
+ -webkit-border-radius: 50%;
149
+ -moz-border-radius: 50%;
150
+ border-radius: 50%
151
+ }
152
+
153
+ .folder-help-form {
154
+ position: fixed;
155
+ right: 85px;
156
+ border: 1px solid #e9edf0;
157
+ bottom: 25px;
158
+ background: #fff;
159
+ -webkit-border-radius: 10px;
160
+ -moz-border-radius: 10px;
161
+ border-radius: 10px;
162
+ width: 320px;
163
+ z-index: 1001;
164
+ direction: ltr;
165
+ opacity: 0;
166
+ transition: .4s;
167
+ -webkit-transition: .4s;
168
+ -moz-transition: .4s
169
+ }
170
+
171
+ .folder-help-form.active {
172
+ opacity: 1;
173
+ pointer-events: inherit
174
+ }
175
+
176
+ .folder-help-header {
177
+ background: #f4f4f4;
178
+ border-bottom: solid 1px #e9edf0;
179
+ padding: 5px 20px;
180
+ -webkit-border-radius: 10px;
181
+ -moz-border-radius: 10px;
182
+ border-radius: 10px 10px 0 0;
183
+ font-size: 16px;
184
+ text-align: right
185
+ }
186
+
187
+ .folder-help-header b {
188
+ float: left
189
+ }
190
+
191
+ .folder-help-content {
192
+ margin-bottom: 10px;
193
+ padding: 20px 20px 10px
194
+ }
195
+
196
+ .folder-help-form p {
197
+ margin: 0 0 1em
198
+ }
199
+
200
+ .folder-form-field {
201
+ margin-bottom: 10px
202
+ }
203
+
204
+ .folder-form-field input, .folder-form-field textarea {
205
+ -webkit-border-radius: 5px;
206
+ -moz-border-radius: 5px;
207
+ border-radius: 5px;
208
+ padding: 5px;
209
+ width: 100%;
210
+ box-sizing: border-box;
211
+ border: 1px solid #c5c5c5
212
+ }
213
+
214
+ .folder-form-field textarea {
215
+ height: 70px
216
+ }
217
+
218
+ .folder-help-button {
219
+ border: none;
220
+ padding: 8px 0;
221
+ width: 100%;
222
+ background: #ff6624;
223
+ color: #fff;
224
+ border-radius: 18px
225
+ }
226
+
227
+ .folder-help-form .error-message {
228
+ font-weight: 400;
229
+ font-size: 14px;
230
+ display: block;
231
+ }
232
+
233
+ .folder-help-form input.input-error, .folder-help-form textarea.input-error {
234
+ border-color: #dc3232
235
+ }
236
+
237
+ .folder-help-btn span.tooltiptext {
238
+ position: absolute;
239
+ background: #000;
240
+ font-size: 12px;
241
+ color: #fff;
242
+ top: -35px;
243
+ width: 140%;
244
+ text-align: center;
245
+ left: -20%;
246
+ border-radius: 5px;
247
+ direction: ltr
248
+ }
249
+
250
+ p.error-p, p.success-p {
251
+ margin: 0;
252
+ font-size: 14px;
253
+ text-align: center
254
+ }
255
+
256
+ .folder-help-btn span.tooltiptext:after {
257
+ bottom: -20px;
258
+ content: "";
259
+ transform: translateX(-50%);
260
+ height: 10px;
261
+ width: 0px;
262
+ border-width: 10px 5px 0;
263
+ border-style: solid;
264
+ border-color: #000 transparent transparent;
265
+ left: 50%;
266
+ position: absolute
267
+ }
268
+ .folder-help-btn {
269
+ display: none;
270
+ }
271
+
272
+ p.success-p {
273
+ color: green
274
+ }
275
+
276
+ p.error-p {
277
+ color: #dc3232
278
+ }
279
+
280
+ html[dir=rtl] .folder-help-btn {
281
+ left: 20px;
282
+ right: auto
283
+ }
284
+
285
+ html[dir=rtl] .folder-help-form {
286
+ left: 85px;
287
+ right: auto
288
+ }
289
+ .folder-popup-body h3 {
290
+ line-height: 24px;
291
+ }
292
+ </style>
293
+
294
+ <div class="folder-popup-overlay">
295
+ <div class="folder-serveypanel">
296
+ <form action="#" method="post" id="folder-deactivate-form">
297
+ <div class="folder-popup-header">
298
+ <h2><?php _e('Quick feedback about Folders', WCP_FOLDER); ?> 🙏</h2>
299
+ </div>
300
+ <div class="folder-popup-body">
301
+ <h3><?php _e('Your feedback will help us improve the product, please tell us why did you decide to deactivate Folders :)', WCP_FOLDER); ?></h3>
302
+ <div class="form-control">
303
+ <label></label>
304
+ <textarea placeholder="<?php echo _e("Your comment", WCP_FOLDER) ?>" id="folder-comment"></textarea>
305
+ </div>
306
+ <?php _e("Having any problem with the Folders plugins? <a class='folder-deactivate-button' href='javascript:;'>Click here</a> to contact our support now", WCP_FOLDER) ?>
307
+ </div>
308
+ <div class="folder-popup-footer">
309
+ <label class="folder-anonymous"><input type="checkbox"/><?php _e('Anonymous feedback', WCP_FOLDER); ?>
310
+ </label>
311
+ <input type="button" class="button button-secondary button-skip folder-popup-skip-feedback"
312
+ value="Skip &amp; Deactivate">
313
+
314
+ <div class="action-btns">
315
+ <span class="folder-spinner"><img src="<?php echo admin_url('/images/spinner.gif'); ?>"
316
+ alt=""></span>
317
+ <input type="submit" class="button button-secondary button-deactivate folder-popup-allow-deactivate"
318
+ value="Submit &amp; Deactivate" disabled="disabled">
319
+ <a href="#"
320
+ class="button button-primary folder-popup-button-close"><?php _e('Cancel', WCP_FOLDER); ?></a>
321
+
322
+ </div>
323
+ </div>
324
+ </form>
325
+ </div>
326
+ </div>
327
+
328
+
329
+ <script>
330
+ (function ($) {
331
+
332
+ $(function () {
333
+
334
+ $(document).on("click", ".folder-deactivate-button", function(e){
335
+ e.stopPropagation();
336
+ jQuery(".folder-popup-button-close").trigger("click");
337
+ jQuery(".folder-help-btn").toggle();
338
+ jQuery(".folder-help-form").toggleClass("active");
339
+ jQuery("#user_email").focus();
340
+ });
341
+
342
+ var folderPluginSlug = 'folders';
343
+ // Code to fire when the DOM is ready.
344
+
345
+ $(document).on('click', 'tr[data-slug="' + folderPluginSlug + '"] .deactivate', function (e) {
346
+ e.preventDefault();
347
+
348
+ $('.folder-popup-overlay').addClass('folder-active');
349
+ $('body').addClass('folder-hidden');
350
+ });
351
+ $(document).on('click', '.folder-popup-button-close', function () {
352
+ close_popup();
353
+ });
354
+ $(document).on('click', ".folder-serveypanel,tr[data-slug='" + folderPluginSlug + "'] .deactivate", function (e) {
355
+ e.stopPropagation();
356
+ });
357
+
358
+ $(document).click(function () {
359
+ close_popup();
360
+ });
361
+ $(document).on("keyup", "#folder-comment", function(){
362
+ if($.trim($(this).val()) == "") {
363
+ $(".folder-popup-allow-deactivate").attr("disabled", true);
364
+ } else {
365
+ $(".folder-popup-allow-deactivate").attr("disabled", false);
366
+ }
367
+ });
368
+ $(document).on('submit', '#folder-deactivate-form', function (event) {
369
+ event.preventDefault();
370
+
371
+ var _reason = jQuery('#folder-comment').val();
372
+
373
+ $.ajax({
374
+ url: ajaxurl,
375
+ type: 'POST',
376
+ data: {
377
+ action: 'folder_plugin_deactivate',
378
+ reason: _reason,
379
+ nonce: '<?php echo wp_create_nonce('wcp_folder_deactivate_nonce') ?>'
380
+ },
381
+ beforeSend: function () {
382
+ $(".folder-spinner").show();
383
+ $(".folder-popup-allow-deactivate").attr("disabled", "disabled");
384
+ }
385
+ }).done(function (res) {
386
+ console.log(res);
387
+ res = jQuery.parseJSON(res);
388
+ if(res.valid == "0") {
389
+ alert(res.message);
390
+ window.location.reload(true);
391
+ } else {
392
+ $(".folder-spinner").hide();
393
+ $(".folder-popup-allow-deactivate").removeAttr("disabled");
394
+ window.location.href = $("tr[data-slug='" + folderPluginSlug + "'] .deactivate a").attr('href');
395
+ }
396
+ });
397
+ });
398
+
399
+ $('.folder-popup-skip-feedback').on('click', function (e) {
400
+ window.location.href = $("tr[data-slug='" + folderPluginSlug + "'] .deactivate a").attr('href');
401
+ })
402
+
403
+ function close_popup() {
404
+ $('.folder-popup-overlay').removeClass('folder-active');
405
+ $('#folder-deactivate-form').trigger("reset");
406
+ $(".folder-popup-allow-deactivate").attr('disabled', 'disabled');
407
+ $(".folder-reason-input").hide();
408
+ $('body').removeClass('folder-hidden');
409
+ $('.message.error-message').hide();
410
+ }
411
+ });
412
+
413
+ })(jQuery); // This invokes the function above and allows us to use '$' in place of 'jQuery' in our code.
414
+ </script>
415
+ <?php include_once dirname(__FILE__)."/help.php" ?>
templates/admin/general-settings.php CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  <style>
2
  span.upgrade-message {
3
  padding: 5px 10px;
@@ -23,10 +26,11 @@
23
  </style>
24
  <div class="wrap">
25
  <h1><?php _e( 'Folders Settings', WCP_FOLDER ); ?></h1>
26
- <form action="options.php" method="post" id="setting-form"><?php
 
27
  settings_fields( 'folders_settings' );
28
- do_settings_sections( __FILE__ );
29
  $options = get_option('folders_settings');
 
30
  ?>
31
  <table class="form-table">
32
  <?php
@@ -46,7 +50,16 @@
46
  </td>
47
  </tr>
48
  <?php
49
- } endforeach; ?>
 
 
 
 
 
 
 
 
 
50
  <tr>
51
  <th>
52
  <label for="folders_<?php echo $post_type->name; ?>" ><?php echo __( 'Show Folders in Menu:', WCP_FOLDER ); ?></label>
1
+ <?php
2
+ defined('ABSPATH') or die('Nope, not accessing this');
3
+ ?>
4
  <style>
5
  span.upgrade-message {
6
  padding: 5px 10px;
26
  </style>
27
  <div class="wrap">
28
  <h1><?php _e( 'Folders Settings', WCP_FOLDER ); ?></h1>
29
+ <form action="options.php" method="post" id="setting-form">
30
+ <?php
31
  settings_fields( 'folders_settings' );
 
32
  $options = get_option('folders_settings');
33
+ do_settings_sections( __FILE__ );
34
  ?>
35
  <table class="form-table">
36
  <?php
50
  </td>
51
  </tr>
52
  <?php
53
+ } else { ?>
54
+ <tr>
55
+ <th>
56
+ <label for="folders_<?php echo $post_type->name; ?>" ><?php echo __( 'Use folders with:', WCP_FOLDER )." ".$post_type->label; ?></label>
57
+ </th>
58
+ <td>
59
+ <input type="checkbox" id="folders_<?php echo $post_type->name; ?>" name="folders_settings[]" value="<?php echo $post_type->name; ?>"<?php if ( in_array( $post_type->name, $options ) ) echo ' checked="checked"'; ?>/>
60
+ </td>
61
+ </tr>
62
+ <?php } endforeach; ?>
63
  <tr>
64
  <th>
65
  <label for="folders_<?php echo $post_type->name; ?>" ><?php echo __( 'Show Folders in Menu:', WCP_FOLDER ); ?></label>
templates/admin/help.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined('ABSPATH') or die('Nope, not accessing this');
3
+ ?>
4
+ <div class="folder-help-form">
5
+ <form action="<?php echo admin_url( 'admin-ajax.php' ) ?>" method="post" id="folder-help-form">
6
+ <div class="folder-help-header">
7
+ <b>Gal Dubinski</b> Co-Founder at Premio
8
+ </div>
9
+ <div class="folder-help-content">
10
+ <p><?php echo __("Hello! Are you experiencing any problems with Folders? Please let me know :)", WCP_FOLDER) ?></p>
11
+ <div class="folder-form-field">
12
+ <input type="text" name="user_email" id="user_email" placeholder="<?php echo __("Email", WCP_FOLDER) ?>">
13
+ </div>
14
+ <div class="folder-form-field">
15
+ <textarea type="text" name="textarea_text" id="textarea_text" placeholder="<?php echo __("How can I help you?", WCP_FOLDER) ?>"></textarea>
16
+ </div>
17
+ <div class="form-button">
18
+ <button type="submit" class="folder-help-button" ><?php echo __("Chat") ?></button>
19
+ <input type="hidden" name="action" value="wcp_folder_send_message_to_owner" >
20
+ <input type="hidden" id="folder_help_nonce" name="folder_help_nonce" value="<?php echo wp_create_nonce('wcp_folder_help_nonce') ?>" >
21
+ </div>
22
+ </div>
23
+ </form>
24
+ </div>
25
+ <div class="folder-help-btn">
26
+ <a class="folder-help-tooltip" href="javascript:;"><img src="<?php echo WCP_FOLDER_URL ?>assets/images/owner.png" alt="<?php echo __("Need help?", WCP_FOLDER) ?>" /></a>
27
+ </div>
28
+ <script>
29
+ jQuery(document).ready(function(){
30
+ jQuery("#folder-help-form").submit(function(){
31
+ jQuery(".folder-help-button").attr("disabled",true);
32
+ jQuery(".folder-help-button").text("<?php echo __("Sending Request...") ?>");
33
+ formData = jQuery(this).serialize();
34
+ jQuery.ajax({
35
+ url: "<?php echo admin_url( 'admin-ajax.php' ) ?>",
36
+ data: formData,
37
+ type: "post",
38
+ success: function(responseText){
39
+ jQuery("#folder-help-form").find(".error-message").remove();
40
+ jQuery("#folder-help-form").find(".input-error").removeClass("input-error");
41
+ responseText = responseText.slice(0, - 1);
42
+ responseArray = jQuery.parseJSON(responseText);
43
+ if(responseArray.error == 1) {
44
+ jQuery(".folder-help-button").attr("disabled",false);
45
+ jQuery(".folder-help-button").text("<?php echo __("Chat", WCP_FOLDER) ?>");
46
+ for(i=0;i<responseArray.errors.length;i++) {
47
+ jQuery("#"+responseArray.errors[i]['key']).addClass("input-error");
48
+ jQuery("#"+responseArray.errors[i]['key']).after('<span class="error-message">'+responseArray.errors[i]['message']+'</span>');
49
+ }
50
+ } else if(responseArray.status == 1) {
51
+ jQuery(".folder-help-button").text("<?php echo __("Done!", WCP_FOLDER) ?>");
52
+ setTimeout(function(){
53
+ jQuery(".folder-help-header").remove();
54
+ jQuery(".folder-help-content").html("<p class='success-p'><?php echo __("Your message is sent successfully.", WCP_FOLDER) ?></p>");
55
+ },1000);
56
+ } else if(responseArray.status == 0) {
57
+ jQuery(".folder-help-content").html("<p class='error-p'><?php echo __("There is some problem in sending request. Please send us mail on <a href='mailto:contact@premio.io'>contact@premio.io</a>", WCP_FOLDER) ?></p>");
58
+ }
59
+ }
60
+ });
61
+ return false;
62
+ });
63
+ jQuery(".folder-help-tooltip").click(function(e){
64
+ e.stopPropagation();
65
+ jQuery(".folder-help-btn").toggle();
66
+ jQuery(".folder-help-form").toggleClass("active");
67
+
68
+ });
69
+ jQuery(".folder-help-form").click(function(e){
70
+ e.stopPropagation();
71
+ });
72
+ jQuery("body").click(function(){
73
+ jQuery(".folder-help-form").removeClass("active");
74
+ if(jQuery(".folder-help-form").hasClass("active")) {
75
+ jQuery(".folder-help-btn").show();
76
+ } else {
77
+ jQuery(".folder-help-btn").hide();
78
+ }
79
+ });
80
+ });
81
+ </script>
templates/admin/upgrade-to-pro.php CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  <link href="<?php echo WCP_FOLDER_URL ?>assets/css/admin-setting.css" type="text/css" rel="stylesheet" />
2
  <div class="wrap">
3
  <div class="key-table">
1
+ <?php
2
+ defined('ABSPATH') or die('Nope, not accessing this');
3
+ ?>
4
  <link href="<?php echo WCP_FOLDER_URL ?>assets/css/admin-setting.css" type="text/css" rel="stylesheet" />
5
  <div class="wrap">
6
  <div class="key-table">