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

Version Description

Infrastructure improvements

Download this release

Release Info

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

Code changes from version 2.8.3 to 2.8.4

folders.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Folders
4
  * Description: Organize your Media library, Pages, and Posts into folders. You can easily drag and drop items into directories and change the folders tree view.
5
- * Version: 2.8.3
6
  * Author: Premio
7
  * Author URI: https://premio.io/downloads/folders/
8
  * Text Domain: folders
@@ -24,7 +24,7 @@ if(!defined("WCP_FOLDER_URL")) {
24
  define('WCP_FOLDER_URL', plugin_dir_url(__FILE__));
25
  }
26
  if(!defined("WCP_FOLDER_VERSION")) {
27
- define('WCP_FOLDER_VERSION', "2.8.3");
28
  }
29
 
30
 
@@ -147,7 +147,7 @@ if(!function_exists('premio_folders_plugin_check_for_setting')) {
147
  $post_array = array("page", "post", "attachment");
148
  foreach ( $post_types as $post_type ) {
149
  if(!in_array($post_type->name, $post_array)) {
150
- $eCondition .= "OR $wpdb->term_taxonomy.taxonomy = '{$post_type->name}_folder'";
151
  }
152
  }
153
  $eCondition .= ")";
2
  /**
3
  * Plugin Name: Folders
4
  * Description: Organize your Media library, Pages, and Posts into folders. You can easily drag and drop items into directories and change the folders tree view.
5
+ * Version: 2.8.4
6
  * Author: Premio
7
  * Author URI: https://premio.io/downloads/folders/
8
  * Text Domain: folders
24
  define('WCP_FOLDER_URL', plugin_dir_url(__FILE__));
25
  }
26
  if(!defined("WCP_FOLDER_VERSION")) {
27
+ define('WCP_FOLDER_VERSION', "2.8.4");
28
  }
29
 
30
 
147
  $post_array = array("page", "post", "attachment");
148
  foreach ( $post_types as $post_type ) {
149
  if(!in_array($post_type->name, $post_array)) {
150
+ $eCondition .= "OR $wpdb->term_taxonomy.taxonomy = '".esc_attr($post_type->name)."_folder'";
151
  }
152
  }
153
  $eCondition .= ")";
includes/class-affiliate.php CHANGED
@@ -1,52 +1,111 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
- class Folder_affiliate_program {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- public $plugin_name = "Folders";
6
 
7
- public $plugin_slug = "folders";
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- public function __construct() {
10
- add_action("wp_ajax_".$this->plugin_slug."_affiliate_program", array($this, "affiliate_program"));
11
 
12
- add_action('admin_notices', array($this, 'admin_notices'));
13
- }
14
 
15
- public function affiliate_program() {
 
 
 
 
 
 
 
 
 
16
  if (current_user_can('manage_options')) {
17
- $nonce = filter_input(INPUT_POST, 'nonce', FILTER_SANITIZE_STRING);
18
- $days = filter_input(INPUT_POST, 'days', FILTER_SANITIZE_STRING);
19
- if (!empty($nonce) && wp_verify_nonce($nonce, $this->plugin_slug . "_affiliate_program")) {
20
  if ($days == -1) {
21
- add_option($this->plugin_slug . "_hide_affiliate_box", "1");
22
  } else {
23
- $date = date("Y-m-d", strtotime("+" . $days . " days"));
24
- update_option($this->plugin_slug . "_show_affiliate_box_after", $date);
25
  }
26
  }
 
27
  die;
28
  }
29
- }
30
 
31
- public function admin_notices() {
 
 
 
 
 
 
 
 
 
 
 
32
  if (current_user_can('manage_options')) {
33
- $is_hidden = get_option($this->plugin_slug."_hide_affiliate_box");
34
- if($is_hidden !== false) {
35
  return;
36
  }
37
- $date_to_show = get_option($this->plugin_slug."_show_affiliate_box_after");
38
- if($date_to_show === false || empty($date_to_show)) {
 
39
  $date = date("Y-m-d", strtotime("+5 days"));
40
- update_option($this->plugin_slug."_show_affiliate_box_after", $date);
41
  return;
42
  }
 
43
  $current_date = date("Y-m-d");
44
- if($current_date < $date_to_show) {
45
  return;
46
  }
47
  ?>
48
  <style>
49
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-affiliate p a {
50
  display: inline-block;
51
  float: right;
52
  text-decoration: none;
@@ -55,20 +114,20 @@ class Folder_affiliate_program {
55
  right: 12px;
56
  top: 12px;
57
  }
58
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-affiliate p a:hover, .<?php echo esc_attr($this->plugin_slug) ?>-premio-affiliate p a:focus {
59
  color: #333333;
60
  }
61
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-affiliate .button span {
62
  display: inline-block;
63
  line-height: 27px;
64
  font-size: 16px;
65
  }
66
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-affiliate {
67
  padding: 1px 100px 12px 12px;
68
  margin: 15px 15px 2px;
69
  position: relative;
70
  }
71
- .<?php echo esc_attr($this->plugin_slug) ?>-affiliate-popup {
72
  position: fixed;
73
  width: 100%;
74
  height: 100%;
@@ -78,7 +137,7 @@ class Folder_affiliate_program {
78
  left: 0;
79
  display: none;
80
  }
81
- .<?php echo esc_attr($this->plugin_slug) ?>-affiliate-popup-content {
82
  background: #ffffff;
83
  padding: 20px;
84
  position: absolute;
@@ -92,23 +151,23 @@ class Folder_affiliate_program {
92
  -moz-border-radius: 5px;
93
  border-radius: 5px;
94
  }
95
- .<?php echo esc_attr($this->plugin_slug) ?>-affiliate-title {
96
  padding: 0 0 10px 0;
97
  font-weight: bold;
98
  }
99
- .<?php echo esc_attr($this->plugin_slug) ?>-affiliate-options a {
100
  display: block;
101
  margin: 5px 0 5px 0;
102
  color: #333;
103
  text-decoration: none;
104
  }
105
- .<?php echo esc_attr($this->plugin_slug) ?>-affiliate-options a.dismiss {
106
  color: #999;
107
  }
108
- .<?php echo esc_attr($this->plugin_slug) ?>-affiliate-options a:hover, .affiliate-options a:focus {
109
  color: #0073aa;
110
  }
111
- button.<?php echo esc_attr($this->plugin_slug) ?>-close-affiliate-popup {
112
  position: absolute;
113
  top: 5px;
114
  right: 0;
@@ -116,7 +175,7 @@ class Folder_affiliate_program {
116
  background: transparent;
117
  cursor: pointer;
118
  }
119
- a.button.button-primary.<?php echo esc_attr($this->plugin_slug) ?>-affiliate-btn {
120
  font-size: 14px;
121
  background: #F51366;
122
  color: #fff;
@@ -129,16 +188,16 @@ class Folder_affiliate_program {
129
  text-shadow: none;
130
  }
131
  </style>
132
- <div class="notice notice-info chaty-notice <?php echo esc_attr($this->plugin_slug) ?>-premio-affiliate <?php echo esc_attr($this->plugin_slug) ?>-premio-affiliate">
133
- <p>Hi there, you've been using <?php echo esc_attr($this->plugin_name) ?> for a while now. Do you know that <b><?php echo esc_attr($this->plugin_name) ?></b> has an affiliate program? Join now and get <b>25% lifetime commission</b> <a href="javascript:;" class="dismiss-btn"><span class="dashicons dashicons-no-alt"></span> Dismiss</a></p>
134
  <div class="clear clearfix"></div>
135
- <a class="button button-primary <?php echo esc_attr($this->plugin_slug) ?>-affiliate-btn" target="_blank" href="https://premio.io/affiliates/?utm_source=inapp&plugin=folders&domain=<?php echo esc_url($_SERVER['HTTP_HOST']) ?>">Tell me more <span class="dashicons dashicons-arrow-right-alt"></span></a>
136
  </div>
137
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-affiliate-popup">
138
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-affiliate-popup-content">
139
- <button class="<?php echo esc_attr($this->plugin_slug) ?>-close-affiliate-popup"><span class="dashicons dashicons-no-alt"></span></button>
140
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-affiliate-title">Would you like us to remind you about this later?</div>
141
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-affiliate-options">
142
  <a href="javascript:;" data-days="3">Remind me in 3 days</a>
143
  <a href="javascript:;" data-days="10">Remind me in 10 days</a>
144
  <a href="javascript:;" data-days="-1" class="dismiss">Don't remind me about this</a>
@@ -147,30 +206,34 @@ class Folder_affiliate_program {
147
  </div>
148
  <script>
149
  jQuery(document).ready(function(){
150
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug) ?>-premio-affiliate p a.dismiss-btn", function(){
151
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-affiliate-popup").show();
152
  });
153
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug) ?>-close-affiliate-popup", function(){
154
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-affiliate-popup").hide();
155
  });
156
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug) ?>-affiliate-options a", function(){
157
  var dataDays = jQuery(this).attr("data-days");
158
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-affiliate-popup").hide();
159
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-premio-affiliate").hide();
160
  jQuery.ajax({
161
  url: "<?php echo admin_url("admin-ajax.php") ?>",
162
- data: "action=<?php echo esc_attr($this->plugin_slug) ?>_affiliate_program&days="+dataDays+"&nonce=<?php echo esc_attr(wp_create_nonce($this->plugin_slug."_affiliate_program")) ?>",
163
  type: "post",
164
  success: function() {
165
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-affiliate-popup").remove();
166
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-premio-affiliate").remove();
167
  }
168
  });
169
  });
170
  });
171
  </script>
172
  <?php
173
- }
174
- }
175
- }
176
- $Folder_affiliate_program = new Folder_affiliate_program();
 
 
 
 
1
  <?php
2
+ /**
3
+ * Class Folders affiliate program
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ class Folder_affiliate_program
14
+ {
15
+
16
+ /**
17
+ * The Name of this plugin.
18
+ *
19
+ * @var string $pluginName The Name of this plugin.
20
+ * @since 1.0.0
21
+ * @access public
22
+ */
23
+ public $pluginName = "Folders";
24
+
25
+ /**
26
+ * The Slug of this plugin.
27
+ *
28
+ * @var string $pluginSlug The Slug of this plugin.
29
+ * @since 1.0.0
30
+ * @access public
31
+ */
32
+ public $pluginSlug = "folders";
33
 
 
34
 
35
+ /**
36
+ * Define the core functionality of the plugin.
37
+ *
38
+ * Set the plugin name and the plugin version that can be used throughout the plugin.
39
+ * Load the dependencies, define the locale, and set the hooks for the admin area and
40
+ * the public-facing side of the site.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct()
45
+ {
46
+ add_action("wp_ajax_".$this->pluginSlug."_affiliate_program", [$this, "affiliate_program"]);
47
 
48
+ add_action('admin_notices', [$this, 'admin_notices']);
 
49
 
50
+ }//end __construct()
 
51
 
52
+
53
+ /**
54
+ * Updates settings for Affiliate Box
55
+ *
56
+ * @since 1.0.0
57
+ * @access public
58
+ * @return status
59
+ */
60
+ public function affiliate_program()
61
+ {
62
  if (current_user_can('manage_options')) {
63
+ $nonce = filter_input(INPUT_POST, 'nonce');
64
+ $days = filter_input(INPUT_POST, 'days');
65
+ if (!empty($nonce) && wp_verify_nonce($nonce, $this->pluginSlug."_affiliate_program")) {
66
  if ($days == -1) {
67
+ add_option($this->pluginSlug."_hide_affiliate_box", "1");
68
  } else {
69
+ $date = date("Y-m-d", strtotime("+".$days." days"));
70
+ update_option($this->pluginSlug."_show_affiliate_box_after", $date);
71
  }
72
  }
73
+
74
  die;
75
  }
 
76
 
77
+ }//end affiliate_program()
78
+
79
+
80
+ /**
81
+ * Display Affiliate box
82
+ *
83
+ * @since 1.0.0
84
+ * @access public
85
+ * @return html
86
+ */
87
+ public function admin_notices()
88
+ {
89
  if (current_user_can('manage_options')) {
90
+ $is_hidden = get_option($this->pluginSlug."_hide_affiliate_box");
91
+ if ($is_hidden !== false) {
92
  return;
93
  }
94
+
95
+ $date_to_show = get_option($this->pluginSlug."_show_affiliate_box_after");
96
+ if ($date_to_show === false || empty($date_to_show)) {
97
  $date = date("Y-m-d", strtotime("+5 days"));
98
+ update_option($this->pluginSlug."_show_affiliate_box_after", $date);
99
  return;
100
  }
101
+
102
  $current_date = date("Y-m-d");
103
+ if ($current_date < $date_to_show) {
104
  return;
105
  }
106
  ?>
107
  <style>
108
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate p a {
109
  display: inline-block;
110
  float: right;
111
  text-decoration: none;
114
  right: 12px;
115
  top: 12px;
116
  }
117
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate p a:hover, .<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate p a:focus {
118
  color: #333333;
119
  }
120
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate .button span {
121
  display: inline-block;
122
  line-height: 27px;
123
  font-size: 16px;
124
  }
125
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate {
126
  padding: 1px 100px 12px 12px;
127
  margin: 15px 15px 2px;
128
  position: relative;
129
  }
130
+ .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup {
131
  position: fixed;
132
  width: 100%;
133
  height: 100%;
137
  left: 0;
138
  display: none;
139
  }
140
+ .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup-content {
141
  background: #ffffff;
142
  padding: 20px;
143
  position: absolute;
151
  -moz-border-radius: 5px;
152
  border-radius: 5px;
153
  }
154
+ .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-title {
155
  padding: 0 0 10px 0;
156
  font-weight: bold;
157
  }
158
+ .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-options a {
159
  display: block;
160
  margin: 5px 0 5px 0;
161
  color: #333;
162
  text-decoration: none;
163
  }
164
+ .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-options a.dismiss {
165
  color: #999;
166
  }
167
+ .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-options a:hover, .affiliate-options a:focus {
168
  color: #0073aa;
169
  }
170
+ button.<?php echo esc_attr($this->pluginSlug) ?>-close-affiliate-popup {
171
  position: absolute;
172
  top: 5px;
173
  right: 0;
175
  background: transparent;
176
  cursor: pointer;
177
  }
178
+ a.button.button-primary.<?php echo esc_attr($this->pluginSlug) ?>-affiliate-btn {
179
  font-size: 14px;
180
  background: #F51366;
181
  color: #fff;
188
  text-shadow: none;
189
  }
190
  </style>
191
+ <div class="notice notice-info chaty-notice <?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate <?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate">
192
+ <p>Hi there, you've been using <?php echo esc_attr($this->pluginName) ?> for a while now. Do you know that <b><?php echo esc_attr($this->pluginName) ?></b> has an affiliate program? Join now and get <b>25% lifetime commission</b> <a href="javascript:;" class="dismiss-btn"><span class="dashicons dashicons-no-alt"></span> Dismiss</a></p>
193
  <div class="clear clearfix"></div>
194
+ <a class="button button-primary <?php echo esc_attr($this->pluginSlug) ?>-affiliate-btn" target="_blank" href="https://premio.io/affiliates/?utm_source=inapp&plugin=folders&domain=<?php echo esc_url($_SERVER['HTTP_HOST']) ?>">Tell me more <span class="dashicons dashicons-arrow-right-alt"></span></a>
195
  </div>
196
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup">
197
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup-content">
198
+ <button class="<?php echo esc_attr($this->pluginSlug) ?>-close-affiliate-popup"><span class="dashicons dashicons-no-alt"></span></button>
199
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-affiliate-title">Would you like us to remind you about this later?</div>
200
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-affiliate-options">
201
  <a href="javascript:;" data-days="3">Remind me in 3 days</a>
202
  <a href="javascript:;" data-days="10">Remind me in 10 days</a>
203
  <a href="javascript:;" data-days="-1" class="dismiss">Don't remind me about this</a>
206
  </div>
207
  <script>
208
  jQuery(document).ready(function(){
209
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate p a.dismiss-btn", function(){
210
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup").show();
211
  });
212
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-close-affiliate-popup", function(){
213
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup").hide();
214
  });
215
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-affiliate-options a", function(){
216
  var dataDays = jQuery(this).attr("data-days");
217
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup").hide();
218
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate").hide();
219
  jQuery.ajax({
220
  url: "<?php echo admin_url("admin-ajax.php") ?>",
221
+ data: "action=<?php echo esc_attr($this->pluginSlug) ?>_affiliate_program&days="+dataDays+"&nonce=<?php echo esc_attr(wp_create_nonce($this->pluginSlug."_affiliate_program")) ?>",
222
  type: "post",
223
  success: function() {
224
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup").remove();
225
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate").remove();
226
  }
227
  });
228
  });
229
  });
230
  </script>
231
  <?php
232
+ }//end if
233
+
234
+ }//end admin_notices()
235
+
236
+
237
+ }//end class
238
+
239
+ $Folder_affiliate_program = new Folder_affiliate_program();
includes/class-polylang.php CHANGED
@@ -1,46 +1,107 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
- class WCP_Folder_PolyLang {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  private $active;
5
- private $pl_term_taxonomy_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  private $total;
7
- private $table_filebird_polylang;
8
- public $delete_process_id;
9
 
 
 
 
 
 
 
 
 
 
 
10
  public function __construct()
11
  {
12
  $this->active = false;
13
- $this->total = 0;
14
  $this->delete_process_id = null;
15
- add_action("admin_init", array($this, 'init'));
16
- }
 
17
 
18
 
 
 
 
 
 
 
 
19
  public function init()
20
  {
21
  global $wpdb, $polylang;
22
  $this->active = function_exists("pll_get_post_translations");
23
 
24
  if ($this->active) {
25
- if (isset($polylang->curlang) && is_object($polylang->curlang))
26
- {
27
- $this->pl_term_taxonomy_id = $polylang->curlang->term_taxonomy_id;
28
 
29
- add_filter('premio_folder_item_in_taxonomy', array($this, 'items_in_taxonomy'), 10, 2);
30
- add_filter('premio_folder_un_categorized_items', array($this, 'un_categorized_items'), 10, 2);
31
- add_filter('premio_folder_all_categorized_items', array($this, 'all_categorized_items'), 10, 2);
32
  }
33
  }
34
- }
35
 
36
- public function set_total($post_type){
 
 
 
 
 
 
 
 
 
 
 
37
  if ($this->active) {
38
  $where = "posts.post_status = 'inherit' OR posts.post_status = 'private'";
39
- if($post_type != 'attachment') {
40
  $where = "post_status != 'trash'";
41
  }
 
42
  global $wpdb;
43
- $query = "SELECT COUNT(tmp.ID) FROM
44
  (
45
  SELECT posts.ID
46
  FROM {$wpdb->posts} AS posts
@@ -48,84 +109,123 @@ class WCP_Folder_PolyLang {
48
  ON posts.ID = trs.object_id
49
  LEFT JOIN {$wpdb->postmeta} AS postmeta
50
  ON (posts.ID = postmeta.post_id AND postmeta.meta_key = '_wp_attached_file')
51
- WHERE posts.post_type = '{$post_type}'
52
- AND trs.term_taxonomy_id IN ({$this->pl_term_taxonomy_id})
53
  AND ({$where})
54
  GROUP BY posts.ID
55
  ) as tmp";
56
- $this->total = (int)$wpdb->get_var($query);
57
- }
58
- }
 
 
 
59
 
60
- public function items_in_taxonomy($term_id, $arg = array()) {
 
 
 
 
 
 
 
 
61
  if ($this->active) {
62
  $post_type = isset($arg['post_type']) ? $arg['post_type'] : "";
63
- $taxonomy = isset($arg['taxonomy']) ? $arg['taxonomy'] : "";
64
- $where = "posts.post_status = 'inherit' OR posts.post_status = 'private'";
65
- if($post_type != 'attachment') {
66
  $where = "post_status != 'trash'";
67
  }
 
68
  global $wpdb;
69
- $term_taxonomy_id = get_term_by('id', (int)$term_id, $taxonomy, OBJECT)->term_taxonomy_id;
70
- $query = "SELECT COUNT(tmp.ID) FROM
71
- (
72
  SELECT posts.ID FROM {$wpdb->posts} AS posts
73
  LEFT JOIN {$wpdb->term_relationships} AS tr1
74
  ON (posts.ID = tr1.object_id)
75
  INNER JOIN {$wpdb->term_relationships} AS tr2
76
- ON (posts.ID = tr2.object_id and tr2.term_taxonomy_id IN ($term_taxonomy_id))
77
  LEFT JOIN {$wpdb->postmeta} AS postmeta ON ( posts.ID = postmeta.post_id AND postmeta.meta_key = '_wp_attached_file' )
78
- WHERE (tr1.term_taxonomy_id IN ({$this->pl_term_taxonomy_id}))
79
- AND posts.post_type = '{$post_type}'
80
  AND (({$where}))
81
  GROUP BY posts.ID
82
- ) as tmp
83
- ";
84
- $counter = (int)$wpdb->get_var($query);
85
  return $counter ? $counter : 0;
86
- }
 
87
  return null;
88
- }
89
 
90
- public function un_categorized_items($post_type, $taxonomy) {
 
 
 
 
 
 
 
 
 
 
 
91
  if ($this->active) {
92
  global $wpdb;
93
  $where = "posts.post_status = 'inherit' OR posts.post_status = 'private'";
94
- if($post_type != 'attachment') {
95
  $where = "post_status != 'trash'";
96
  }
97
- $query = "SELECT COUNT(tmp.ID) FROM
 
98
  (
99
  SELECT posts.ID
100
  FROM {$wpdb->posts} AS posts
101
  INNER JOIN {$wpdb->term_relationships} AS tr1
102
- ON posts.ID = tr1.object_id AND tr1.term_taxonomy_id IN ({$this->pl_term_taxonomy_id})
103
  INNER JOIN {$wpdb->term_relationships} AS tr2
104
  ON (tr2.object_id = posts.ID)
105
  JOIN {$wpdb->term_taxonomy} as tx
106
- ON tx.term_taxonomy_id = tr2.term_taxonomy_id AND tx.taxonomy = '{$taxonomy}'
107
-
108
- WHERE posts.post_type = '{$post_type}'
109
  AND ({$where})
110
  GROUP BY posts.ID
111
  ) as tmp";
112
- $fileInFolder = (int)$wpdb->get_var($query);
113
- $fileInFolder = !($fileInFolder)?0:$fileInFolder;
 
114
  $this->set_total($post_type);
115
- return $this->total - $fileInFolder;
116
- }
 
117
  return null;
118
- }
119
 
120
- public function all_categorized_items($post_type) {
 
 
 
 
 
 
 
 
 
 
 
121
  if ($this->active) {
122
  $this->set_total($post_type);
123
  return $this->total;
124
  }
 
125
  return null;
126
- }
127
- }
128
- if(class_exists('WCP_Folder_PolyLang')) {
129
- $WCP_Folder_PolyLang = new WCP_Folder_PolyLang();
130
 
131
- }
 
 
 
 
 
 
 
1
  <?php
2
+ /**
3
+ * Class Folders PolyLang
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ class WCP_Folder_PolyLang
14
+ {
15
+
16
+ /**
17
+ * The Name of this plugin.
18
+ *
19
+ * @var string $active Checking for Plugin is active or not
20
+ * @since 1.0.0
21
+ * @access public
22
+ */
23
  private $active;
24
+
25
+ /**
26
+ * The Name of this plugin.
27
+ *
28
+ * @var string $poly_lang_term_taxonomy_id Poly Lang taxonomy id
29
+ * @since 1.0.0
30
+ * @access public
31
+ */
32
+ private $poly_lang_term_taxonomy_id;
33
+
34
+ /**
35
+ * The Name of this plugin.
36
+ *
37
+ * @var string $total total posts in taxonomy
38
+ * @since 1.0.0
39
+ * @access public
40
+ */
41
  private $total;
 
 
42
 
43
+
44
+ /**
45
+ * Define the core functionality of the plugin.
46
+ *
47
+ * Set the plugin name and the plugin version that can be used throughout the plugin.
48
+ * Load the dependencies, define the locale, and set the hooks for the admin area and
49
+ * the public-facing side of the site.
50
+ *
51
+ * @since 1.0.0
52
+ */
53
  public function __construct()
54
  {
55
  $this->active = false;
56
+ $this->total = 0;
57
  $this->delete_process_id = null;
58
+ add_action("admin_init", [$this, 'init']);
59
+
60
+ }//end __construct()
61
 
62
 
63
+ /**
64
+ * Filters the taxonomy data
65
+ *
66
+ * @since 1.0.0
67
+ * @access public
68
+ * @return
69
+ */
70
  public function init()
71
  {
72
  global $wpdb, $polylang;
73
  $this->active = function_exists("pll_get_post_translations");
74
 
75
  if ($this->active) {
76
+ if (isset($polylang->curlang) && is_object($polylang->curlang)) {
77
+ $this->poly_lang_term_taxonomy_id = $polylang->curlang->term_taxonomy_id;
 
78
 
79
+ add_filter('premio_folder_item_in_taxonomy', [$this, 'items_in_taxonomy'], 10, 2);
80
+ add_filter('premio_folder_un_categorized_items', [$this, 'un_categorized_items'], 10, 2);
81
+ add_filter('premio_folder_all_categorized_items', [$this, 'all_categorized_items'], 10, 2);
82
  }
83
  }
 
84
 
85
+ }//end init()
86
+
87
+
88
+ /**
89
+ * Get total number on taxonomies used in Polylang
90
+ *
91
+ * @since 1.0.0
92
+ * @access public
93
+ * @return $total
94
+ */
95
+ public function set_total($post_type)
96
+ {
97
  if ($this->active) {
98
  $where = "posts.post_status = 'inherit' OR posts.post_status = 'private'";
99
+ if ($post_type != 'attachment') {
100
  $where = "post_status != 'trash'";
101
  }
102
+
103
  global $wpdb;
104
+ $query = "SELECT COUNT(tmp.ID) FROM
105
  (
106
  SELECT posts.ID
107
  FROM {$wpdb->posts} AS posts
109
  ON posts.ID = trs.object_id
110
  LEFT JOIN {$wpdb->postmeta} AS postmeta
111
  ON (posts.ID = postmeta.post_id AND postmeta.meta_key = '_wp_attached_file')
112
+ WHERE posts.post_type = '%s'
113
+ AND trs.term_taxonomy_id IN (%s)
114
  AND ({$where})
115
  GROUP BY posts.ID
116
  ) as tmp";
117
+ $query = $wpdb->prepare($query, [$post_type, $this->poly_lang_term_taxonomy_id]);
118
+ $this->total = (int) $wpdb->get_var($query);
119
+ }//end if
120
+
121
+ }//end set_total()
122
+
123
 
124
+ /**
125
+ * Check the items in taxonomies
126
+ *
127
+ * @since 1.0.0
128
+ * @access public
129
+ * @return $counter
130
+ */
131
+ public function items_in_taxonomy($term_id, $arg=[])
132
+ {
133
  if ($this->active) {
134
  $post_type = isset($arg['post_type']) ? $arg['post_type'] : "";
135
+ $taxonomy = isset($arg['taxonomy']) ? $arg['taxonomy'] : "";
136
+ $where = "posts.post_status = 'inherit' OR posts.post_status = 'private'";
137
+ if ($post_type != 'attachment') {
138
  $where = "post_status != 'trash'";
139
  }
140
+
141
  global $wpdb;
142
+ $term_taxonomy_id = get_term_by('id', (int) $term_id, $taxonomy, OBJECT)->term_taxonomy_id;
143
+ $query = "SELECT COUNT(tmp.ID) FROM
144
+ (
145
  SELECT posts.ID FROM {$wpdb->posts} AS posts
146
  LEFT JOIN {$wpdb->term_relationships} AS tr1
147
  ON (posts.ID = tr1.object_id)
148
  INNER JOIN {$wpdb->term_relationships} AS tr2
149
+ ON (posts.ID = tr2.object_id and tr2.term_taxonomy_id IN (%s))
150
  LEFT JOIN {$wpdb->postmeta} AS postmeta ON ( posts.ID = postmeta.post_id AND postmeta.meta_key = '_wp_attached_file' )
151
+ WHERE (tr1.term_taxonomy_id IN (%s))
152
+ AND posts.post_type = '%s'
153
  AND (({$where}))
154
  GROUP BY posts.ID
155
+ ) as tmp";
156
+ $query = $wpdb->prepare($query, [$term_taxonomy_id, $this->poly_lang_term_taxonomy_id, $post_type]);
157
+ $counter = (int) $wpdb->get_var($query);
158
  return $counter ? $counter : 0;
159
+ }//end if
160
+
161
  return null;
 
162
 
163
+ }//end items_in_taxonomy()
164
+
165
+
166
+ /**
167
+ * Check the items in uncategorized taxonomies
168
+ *
169
+ * @since 1.0.0
170
+ * @access public
171
+ * @return $counter
172
+ */
173
+ public function un_categorized_items($post_type, $taxonomy)
174
+ {
175
  if ($this->active) {
176
  global $wpdb;
177
  $where = "posts.post_status = 'inherit' OR posts.post_status = 'private'";
178
+ if ($post_type != 'attachment') {
179
  $where = "post_status != 'trash'";
180
  }
181
+
182
+ $query = "SELECT COUNT(tmp.ID) FROM
183
  (
184
  SELECT posts.ID
185
  FROM {$wpdb->posts} AS posts
186
  INNER JOIN {$wpdb->term_relationships} AS tr1
187
+ ON posts.ID = tr1.object_id AND tr1.term_taxonomy_id IN (%s)
188
  INNER JOIN {$wpdb->term_relationships} AS tr2
189
  ON (tr2.object_id = posts.ID)
190
  JOIN {$wpdb->term_taxonomy} as tx
191
+ ON tx.term_taxonomy_id = tr2.term_taxonomy_id AND tx.taxonomy = '%s'
192
+ WHERE posts.post_type = '%s'
 
193
  AND ({$where})
194
  GROUP BY posts.ID
195
  ) as tmp";
196
+ $query = $wpdb->prepare($query, [$this->poly_lang_term_taxonomy_id, $taxonomy, $post_type]);
197
+ $fileInFolder = (int) $wpdb->get_var($query);
198
+ $fileInFolder = !($fileInFolder) ? 0 : $fileInFolder;
199
  $this->set_total($post_type);
200
+ return ($this->total - $fileInFolder);
201
+ }//end if
202
+
203
  return null;
 
204
 
205
+ }//end un_categorized_items()
206
+
207
+
208
+ /**
209
+ * Check the items in taxonomies
210
+ *
211
+ * @since 1.0.0
212
+ * @access public
213
+ * @return $counter
214
+ */
215
+ public function all_categorized_items($post_type)
216
+ {
217
  if ($this->active) {
218
  $this->set_total($post_type);
219
  return $this->total;
220
  }
221
+
222
  return null;
 
 
 
 
223
 
224
+ }//end all_categorized_items()
225
+
226
+
227
+ }//end class
228
+
229
+ if (class_exists('WCP_Folder_PolyLang')) {
230
+ $WCP_Folder_PolyLang = new WCP_Folder_PolyLang();
231
+ }
includes/class-review-box.php CHANGED
@@ -1,58 +1,117 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
2
  <?php
3
- class folders_review_box {
4
-
5
- public $plugin_name = "Folders";
6
-
7
- public $plugin_slug = "folders";
8
-
9
- public function __construct() {
10
-
11
- add_action("wp_ajax_".$this->plugin_slug."_review_box", array($this, "form_review_box"));
12
-
13
- add_action('admin_notices', array($this, 'admin_notices'));
14
- }
15
 
16
- public function form_review_box() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  if (current_user_can('manage_options')) {
18
- $nonce = filter_input(INPUT_POST, 'nonce', FILTER_SANITIZE_STRING);
19
- $days = filter_input(INPUT_POST, 'days', FILTER_SANITIZE_STRING);
20
- if (!empty($nonce) && wp_verify_nonce($nonce, $this->plugin_slug . "_review_box")) {
21
  if ($days == -1) {
22
- add_option($this->plugin_slug . "_hide_review_box", "1");
23
  } else {
24
- $date = date("Y-m-d", strtotime("+" . $days . " days"));
25
- update_option($this->plugin_slug . "_show_review_box_after", $date);
26
  }
27
  }
 
28
  die;
29
  }
30
- }
31
 
32
- public function admin_notices() {
 
 
 
 
 
 
 
 
 
 
 
33
  if (current_user_can('manage_options')) {
34
- $is_hidden = get_option($this->plugin_slug . "_hide_review_box");
35
- if ($is_hidden !== false) {
36
  return;
37
  }
38
- $current_count = get_option($this->plugin_slug . "_show_review_box_after");
39
- if ($current_count === false) {
 
40
  $date = date("Y-m-d", strtotime("+14 days"));
41
- add_option($this->plugin_slug . "_show_review_box_after", $date);
42
  return;
43
- } else if ($current_count < 35) {
44
  return;
45
  }
46
- $date_to_show = get_option($this->plugin_slug . "_show_review_box_after");
47
- if ($date_to_show !== false) {
48
- $current_date = date("Y-m-d");
49
- if ($current_date < $date_to_show) {
 
50
  return;
51
  }
52
  }
53
  ?>
54
  <style>
55
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box p a {
56
  display: inline-block;
57
  float: right;
58
  text-decoration: none;
@@ -62,17 +121,17 @@ class folders_review_box {
62
  top: 12px;
63
  }
64
 
65
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box p a:hover, .<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box p a:focus {
66
  color: #333333;
67
  }
68
 
69
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box .button span {
70
  display: inline-block;
71
  line-height: 27px;
72
  font-size: 16px;
73
  }
74
 
75
- .<?php echo esc_attr($this->plugin_slug) ?>-review-box-popup {
76
  position: fixed;
77
  width: 100%;
78
  height: 100%;
@@ -83,7 +142,7 @@ class folders_review_box {
83
  display: none;
84
  }
85
 
86
- .<?php echo esc_attr($this->plugin_slug) ?>-review-box-popup-content {
87
  background: #ffffff;
88
  padding: 20px;
89
  position: absolute;
@@ -99,27 +158,27 @@ class folders_review_box {
99
  :;
100
  }
101
 
102
- .<?php echo esc_attr($this->plugin_slug) ?>-review-box-title {
103
  padding: 0 0 10px 0;
104
  font-weight: bold;
105
  }
106
 
107
- .<?php echo esc_attr($this->plugin_slug) ?>-review-box-options a {
108
  display: block;
109
  margin: 5px 0 5px 0;
110
  color: #333;
111
  text-decoration: none;
112
  }
113
 
114
- .<?php echo esc_attr($this->plugin_slug) ?>-review-box-options a.dismiss {
115
  color: #999;
116
  }
117
 
118
- .<?php echo esc_attr($this->plugin_slug) ?>-review-box-options a:hover, .affiliate-options a:focus {
119
  color: #0073aa;
120
  }
121
 
122
- button.<?php echo esc_attr($this->plugin_slug) ?>-close-review-box-popup {
123
  position: absolute;
124
  top: 5px;
125
  right: 0;
@@ -128,7 +187,7 @@ class folders_review_box {
128
  cursor: pointer;
129
  }
130
 
131
- a.button.button-primary.<?php echo esc_attr($this->plugin_slug) ?>-review-box-btn {
132
  font-size: 14px;
133
  background: #F51366;
134
  color: #fff;
@@ -156,14 +215,14 @@ class folders_review_box {
156
  text-decoration: underline;
157
  }
158
 
159
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box p {
160
  display: inline-block;
161
  line-height: 30px;
162
  vertical-align: middle;
163
  padding: 0 10px 0 0;
164
  }
165
 
166
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box p img {
167
  width: 30px;
168
  height: 30px;
169
  display: inline-block;
@@ -222,91 +281,95 @@ class folders_review_box {
222
  }
223
  </style>
224
  <div
225
- class="notice notice-info premio-notice <?php echo esc_attr($this->plugin_slug) ?>-premio-review-box <?php echo esc_attr($this->plugin_slug) ?>-premio-review-box">
226
- <div class="review-box-default" id="default-review-box-<?php echo esc_attr($this->plugin_slug) ?>">
227
  <p>
228
- <?php printf(esc_html__("Hi there, it seems like %s is bringing you some value, and that's pretty awesome! Can you please show us some love and rate %s on WordPress? It'll only take 2 minutes of your time, and will really help us spread the word - %s, %s"), "<b>".$this->plugin_name."</b>", $this->plugin_name, "<b>Gal Dubinski</b>", "Co-founder") ?>
229
- <img width="30px" src="<?php echo esc_url(plugin_dir_url(__FILE__) . "../assets/images/premio-owner.jpg") ?>"/>
230
- <a href="javascript:;" class="dismiss-btn <?php echo esc_attr($this->plugin_slug) ?>-premio-review-dismiss-btn"><span class="dashicons dashicons-no-alt"></span></a>
231
  </p>
232
 
233
  <div class="clear clearfix"></div>
234
  <ul>
235
- <li><a class="<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box-hide-btn" href="https://wordpress.org/support/plugin/folders/reviews/?filter=5" target="_blank"><?php esc_html_e("I'd love to help :) ",'folders')?></a></li>
236
- <li><a class="<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box-future-btn" href="javascript:;"><?php esc_html_e("Not this time ",'folders')?></a></li>
237
- <li><a class="<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box-hide-btn" href="javascript:;"><?php esc_html_e("I've already rated you ",'folders')?></a></li>
238
  </ul>
239
  </div>
240
- <div class="review-thanks-box" id="review-thanks-<?php echo esc_attr($this->plugin_slug) ?>">
241
- <button class="<?php echo esc_attr($this->plugin_slug) ?>-close-thanks-btn review-thanks-btn"><span class="dashicons dashicons-no-alt"></span></button>
242
  <div class="review-thanks-img">
243
- <img width="30px" src="<?php echo esc_url(plugin_dir_url(__FILE__) . "/images/thanks.gif") ?>"/>
244
  </div>
245
  <div class="review-thanks-msg">
246
- <div class="thanks-msg-title"><?php esc_html_e("You are awesome ",'folders')?> &#128591;</div>
247
- <div class="thanks-msg-desc"><?php esc_html_e("Thanks for your support, We really appreciate it!",'folders')?></div>
248
- <div class="thanks-msg-footer"><?php esc_html_e("Premio team ",'folders')?></div>
249
  </div>
250
  <div class="clear clearfix"></div>
251
  </div>
252
  </div>
253
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-review-box-popup">
254
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-review-box-popup-content">
255
- <button class="<?php echo esc_attr($this->plugin_slug) ?>-close-review-box-popup"><span class="dashicons dashicons-no-alt"></span></button>
256
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-review-box-title">
257
- <?php esc_html_e("Would you like us to remind you about this later?",'folders')?>
258
  </div>
259
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-review-box-options">
260
- <a href="javascript:;" data-days="3"><?php esc_html_e("Remind me in 3 days ",'folders')?></a>
261
- <a href="javascript:;" data-days="10"><?php esc_html_e("Remind me in 10 days ",'folders')?></a>
262
- <a href="javascript:;" data-days="-1" class="dismiss"><?php esc_html_e("Don't remind me about this ",'folders')?></a>
263
  </div>
264
  </div>
265
  </div>
266
  <script>
267
  jQuery(document).on('ready', function () {
268
  jQuery("body").addClass("has-premio-box");
269
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug) ?>-premio-review-dismiss-btn, .<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box-future-btn", function () {
270
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-review-box-popup").show();
271
  });
272
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug) ?>-close-review-box-popup", function () {
273
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-review-box-popup").hide();
274
  });
275
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug) ?>-close-thanks-btn", function () {
276
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-review-box-popup").remove();
277
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box").remove();
278
  });
279
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug)?>-premio-review-box-hide-btn", function () {
280
- jQuery("#default-review-box-<?php echo esc_attr($this->plugin_slug) ?>").hide();
281
- jQuery("#review-thanks-<?php echo esc_attr($this->plugin_slug) ?>").show();
282
  jQuery.ajax({
283
  url: "<?php echo admin_url("admin-ajax.php") ?>",
284
- data: "action=<?php echo esc_attr($this->plugin_slug) ?>_review_box&days=-1&nonce=<?php echo esc_attr(wp_create_nonce($this->plugin_slug."_review_box")) ?>",
285
  type: "post",
286
  success: function () {
287
 
288
  }
289
  });
290
  });
291
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug) ?>-review-box-options a", function () {
292
  var dataDays = jQuery(this).attr("data-days");
293
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-review-box-popup").remove();
294
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-premio-review-box").remove();
295
  jQuery("body").removeClass("has-premio-box");
296
  jQuery.ajax({
297
  url: "<?php echo admin_url("admin-ajax.php") ?>",
298
- data: "action=<?php echo esc_attr($this->plugin_slug) ?>_review_box&days=" + dataDays + "&nonce=<?php echo esc_attr(wp_create_nonce($this->plugin_slug."_review_box")) ?>",
299
  type: "post",
300
  success: function () {
301
- jQuery(".<?php echo esc_attr($this->plugin_slug)?>-review-box-popup").remove();
302
- jQuery(".<?php echo esc_attr($this->plugin_slug)?>-premio-review-box").remove();
303
  }
304
  });
305
  });
306
  });
307
  </script>
308
  <?php
309
- }
310
- }
311
- }
312
- $folders_review_box = new folders_review_box();
 
 
 
 
 
1
  <?php
2
+ /**
3
+ * Class Folders Review
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
 
 
12
 
13
+ class folders_review_box
14
+ {
15
+
16
+ /**
17
+ * The Name of this plugin.
18
+ *
19
+ * @var string $pluginName The Name of this plugin.
20
+ * @since 1.0.0
21
+ * @access public
22
+ */
23
+ public $pluginName = "Folders";
24
+
25
+ /**
26
+ * The Slug of this plugin.
27
+ *
28
+ * @var string $pluginSlug The Slug of this plugin.
29
+ * @since 1.0.0
30
+ * @access public
31
+ */
32
+ public $pluginSlug = "folders";
33
+
34
+
35
+ /**
36
+ * Define the core functionality of the plugin.
37
+ *
38
+ * Set the plugin name and the plugin version that can be used throughout the plugin.
39
+ * Load the dependencies, define the locale, and set the hooks for the admin area and
40
+ * the public-facing side of the site.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct()
45
+ {
46
+
47
+ add_action("wp_ajax_".$this->pluginSlug."_review_box", [$this, "form_review_box"]);
48
+
49
+ add_action('admin_notices', [$this, 'admin_notices']);
50
+
51
+ }//end __construct()
52
+
53
+
54
+ /**
55
+ * Updates settings for Review Box
56
+ *
57
+ * @since 1.0.0
58
+ * @access public
59
+ * @return status
60
+ */
61
+ public function form_review_box()
62
+ {
63
  if (current_user_can('manage_options')) {
64
+ $nonce = filter_input(INPUT_POST, 'nonce');
65
+ $days = filter_input(INPUT_POST, 'days');
66
+ if (!empty($nonce) && wp_verify_nonce($nonce, $this->pluginSlug."_review_box")) {
67
  if ($days == -1) {
68
+ add_option($this->pluginSlug."_hide_review_box", "1");
69
  } else {
70
+ $date = date("Y-m-d", strtotime("+".$days." days"));
71
+ update_option($this->pluginSlug."_show_review_box_after", $date);
72
  }
73
  }
74
+
75
  die;
76
  }
 
77
 
78
+ }//end form_review_box()
79
+
80
+
81
+ /**
82
+ * Display Review Box
83
+ *
84
+ * @since 1.0.0
85
+ * @access public
86
+ * @return html
87
+ */
88
+ public function admin_notices()
89
+ {
90
  if (current_user_can('manage_options')) {
91
+ $isHidden = get_option($this->pluginSlug."_hide_review_box");
92
+ if ($isHidden !== false) {
93
  return;
94
  }
95
+
96
+ $currentCount = get_option($this->pluginSlug."_show_review_box_after");
97
+ if ($currentCount === false) {
98
  $date = date("Y-m-d", strtotime("+14 days"));
99
+ add_option($this->pluginSlug."_show_review_box_after", $date);
100
  return;
101
+ } else if ($currentCount < 35) {
102
  return;
103
  }
104
+
105
+ $dateToShow = get_option($this->pluginSlug."_show_review_box_after");
106
+ if ($dateToShow !== false) {
107
+ $currentDate = date("Y-m-d");
108
+ if ($currentDate < $dateToShow) {
109
  return;
110
  }
111
  }
112
  ?>
113
  <style>
114
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box p a {
115
  display: inline-block;
116
  float: right;
117
  text-decoration: none;
121
  top: 12px;
122
  }
123
 
124
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box p a:hover, .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box p a:focus {
125
  color: #333333;
126
  }
127
 
128
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box .button span {
129
  display: inline-block;
130
  line-height: 27px;
131
  font-size: 16px;
132
  }
133
 
134
+ .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup {
135
  position: fixed;
136
  width: 100%;
137
  height: 100%;
142
  display: none;
143
  }
144
 
145
+ .<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup-content {
146
  background: #ffffff;
147
  padding: 20px;
148
  position: absolute;
158
  :;
159
  }
160
 
161
+ .<?php echo esc_attr($this->pluginSlug) ?>-review-box-title {
162
  padding: 0 0 10px 0;
163
  font-weight: bold;
164
  }
165
 
166
+ .<?php echo esc_attr($this->pluginSlug) ?>-review-box-options a {
167
  display: block;
168
  margin: 5px 0 5px 0;
169
  color: #333;
170
  text-decoration: none;
171
  }
172
 
173
+ .<?php echo esc_attr($this->pluginSlug) ?>-review-box-options a.dismiss {
174
  color: #999;
175
  }
176
 
177
+ .<?php echo esc_attr($this->pluginSlug) ?>-review-box-options a:hover, .affiliate-options a:focus {
178
  color: #0073aa;
179
  }
180
 
181
+ button.<?php echo esc_attr($this->pluginSlug) ?>-close-review-box-popup {
182
  position: absolute;
183
  top: 5px;
184
  right: 0;
187
  cursor: pointer;
188
  }
189
 
190
+ a.button.button-primary.<?php echo esc_attr($this->pluginSlug) ?>-review-box-btn {
191
  font-size: 14px;
192
  background: #F51366;
193
  color: #fff;
215
  text-decoration: underline;
216
  }
217
 
218
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box p {
219
  display: inline-block;
220
  line-height: 30px;
221
  vertical-align: middle;
222
  padding: 0 10px 0 0;
223
  }
224
 
225
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box p img {
226
  width: 30px;
227
  height: 30px;
228
  display: inline-block;
281
  }
282
  </style>
283
  <div
284
+ class="notice notice-info premio-notice <?php echo esc_attr($this->pluginSlug) ?>-premio-review-box <?php echo esc_attr($this->pluginSlug) ?>-premio-review-box">
285
+ <div class="review-box-default" id="default-review-box-<?php echo esc_attr($this->pluginSlug) ?>">
286
  <p>
287
+ <?php printf(esc_html__("Hi there, it seems like %s is bringing you some value, and that's pretty awesome! Can you please show us some love and rate %s on WordPress? It'll only take 2 minutes of your time, and will really help us spread the word - %s, %s"), "<b>".esc_attr($this->pluginName)."</b>", esc_attr($this->pluginName), "<b>Gal Dubinski</b>", "Co-founder") ?>
288
+ <img width="30px" src="<?php echo esc_url(plugin_dir_url(__FILE__)."../assets/images/premio-owner.jpg") ?>"/>
289
+ <a href="javascript:;" class="dismiss-btn <?php echo esc_attr($this->pluginSlug) ?>-premio-review-dismiss-btn"><span class="dashicons dashicons-no-alt"></span></a>
290
  </p>
291
 
292
  <div class="clear clearfix"></div>
293
  <ul>
294
+ <li><a class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box-hide-btn" href="https://wordpress.org/support/plugin/folders/reviews/?filter=5" target="_blank"><?php esc_html_e("I'd love to help :) ", 'folders')?></a></li>
295
+ <li><a class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box-future-btn" href="javascript:;"><?php esc_html_e("Not this time ", 'folders')?></a></li>
296
+ <li><a class="<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box-hide-btn" href="javascript:;"><?php esc_html_e("I've already rated you ", 'folders')?></a></li>
297
  </ul>
298
  </div>
299
+ <div class="review-thanks-box" id="review-thanks-<?php echo esc_attr($this->pluginSlug) ?>">
300
+ <button class="<?php echo esc_attr($this->pluginSlug) ?>-close-thanks-btn review-thanks-btn"><span class="dashicons dashicons-no-alt"></span></button>
301
  <div class="review-thanks-img">
302
+ <img width="30px" src="<?php echo esc_url(plugin_dir_url(__FILE__)."/images/thanks.gif") ?>"/>
303
  </div>
304
  <div class="review-thanks-msg">
305
+ <div class="thanks-msg-title"><?php esc_html_e("You are awesome ", 'folders')?> &#128591;</div>
306
+ <div class="thanks-msg-desc"><?php esc_html_e("Thanks for your support, We really appreciate it!", 'folders')?></div>
307
+ <div class="thanks-msg-footer"><?php esc_html_e("Premio team ", 'folders')?></div>
308
  </div>
309
  <div class="clear clearfix"></div>
310
  </div>
311
  </div>
312
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup">
313
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup-content">
314
+ <button class="<?php echo esc_attr($this->pluginSlug) ?>-close-review-box-popup"><span class="dashicons dashicons-no-alt"></span></button>
315
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-title">
316
+ <?php esc_html_e("Would you like us to remind you about this later?", 'folders')?>
317
  </div>
318
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-review-box-options">
319
+ <a href="javascript:;" data-days="3"><?php esc_html_e("Remind me in 3 days ", 'folders')?></a>
320
+ <a href="javascript:;" data-days="10"><?php esc_html_e("Remind me in 10 days ", 'folders')?></a>
321
+ <a href="javascript:;" data-days="-1" class="dismiss"><?php esc_html_e("Don't remind me about this ", 'folders')?></a>
322
  </div>
323
  </div>
324
  </div>
325
  <script>
326
  jQuery(document).on('ready', function () {
327
  jQuery("body").addClass("has-premio-box");
328
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-premio-review-dismiss-btn, .<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box-future-btn", function () {
329
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup").show();
330
  });
331
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-close-review-box-popup", function () {
332
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup").hide();
333
  });
334
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-close-thanks-btn", function () {
335
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup").remove();
336
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box").remove();
337
  });
338
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug)?>-premio-review-box-hide-btn", function () {
339
+ jQuery("#default-review-box-<?php echo esc_attr($this->pluginSlug) ?>").hide();
340
+ jQuery("#review-thanks-<?php echo esc_attr($this->pluginSlug) ?>").show();
341
  jQuery.ajax({
342
  url: "<?php echo admin_url("admin-ajax.php") ?>",
343
+ data: "action=<?php echo esc_attr($this->pluginSlug) ?>_review_box&days=-1&nonce=<?php echo esc_attr(wp_create_nonce($this->pluginSlug."_review_box")) ?>",
344
  type: "post",
345
  success: function () {
346
 
347
  }
348
  });
349
  });
350
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-review-box-options a", function () {
351
  var dataDays = jQuery(this).attr("data-days");
352
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-review-box-popup").remove();
353
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-premio-review-box").remove();
354
  jQuery("body").removeClass("has-premio-box");
355
  jQuery.ajax({
356
  url: "<?php echo admin_url("admin-ajax.php") ?>",
357
+ data: "action=<?php echo esc_attr($this->pluginSlug) ?>_review_box&days=" + dataDays + "&nonce=<?php echo esc_attr(wp_create_nonce($this->pluginSlug."_review_box")) ?>",
358
  type: "post",
359
  success: function () {
360
+ jQuery(".<?php echo esc_attr($this->pluginSlug)?>-review-box-popup").remove();
361
+ jQuery(".<?php echo esc_attr($this->pluginSlug)?>-premio-review-box").remove();
362
  }
363
  });
364
  });
365
  });
366
  </script>
367
  <?php
368
+ }//end if
369
+
370
+ }//end admin_notices()
371
+
372
+
373
+ }//end class
374
+
375
+ $folders_review_box = new folders_review_box();
includes/class-upgrade-box.php CHANGED
@@ -1,55 +1,116 @@
1
  <?php
2
- if (!defined('ABSPATH')) {exit;}
3
- class Folders_upgrade_box {
4
- public $plugin_name = "Folders";
5
- public $plugin_slug = "folders";
 
 
6
 
7
- public function __construct() {
8
- add_action("wp_ajax_".$this->plugin_slug."_upgrade_hide_box", array($this, "upgrade_to_pro"));
9
- add_action('admin_notices', array($this, 'admin_notices'));
10
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- public function upgrade_to_pro() {
 
 
 
 
 
 
 
 
 
 
 
13
  $nonce = filter_input(INPUT_POST, 'nonce');
14
- $days = filter_input(INPUT_POST, 'days');
15
- if(!empty($nonce) && wp_verify_nonce($nonce, $this->plugin_slug."_upgrade_box")) {
16
- if($days == -1) {
17
- add_option($this->plugin_slug."_hide_upgrade_box", "1");
18
  } else {
19
  $date = date("Y-m-d", strtotime("+".$days." days"));
20
- update_option($this->plugin_slug."_show_upgrade_box_after", $date);
21
  }
22
  }
 
23
  die;
24
- }
25
 
26
- public function admin_notices() {
27
- $is_hidden = get_option($this->plugin_slug."_hide_upgrade_box");
28
- if($is_hidden !== false) {
 
 
 
 
 
 
 
 
 
 
 
29
  return;
30
  }
31
- $current_count = get_option($this->plugin_slug."_show_upgrade_box_after");
32
- if($current_count === false) {
 
33
  $date = date("Y-m-d", strtotime("+15 days"));
34
- add_option($this->plugin_slug."_show_upgrade_box_after", $date);
35
  return;
36
- } else if($current_count < 35) {
37
  return;
38
  }
39
- $date_to_show = get_option($this->plugin_slug."_show_upgrade_box_after");
40
- if($date_to_show !== false) {
41
- $current_date = date("Y-m-d");
42
- if($current_date < $date_to_show) {
 
43
  return;
44
  }
45
  }
46
  ?>
47
  <style>
48
- .<?php echo esc_attr($this->plugin_slug) ?>-tab-integration-action{
49
  padding: 0 10px;
50
  float: right;
51
  }
52
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box .<?php echo esc_attr($this->plugin_slug) ?>-tab-integration-action a {
53
  display: inline-block;
54
  float: right;
55
  text-decoration: none;
@@ -66,10 +127,10 @@ class Folders_upgrade_box {
66
  text-align: center;
67
  line-height: 25px;
68
  }
69
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box .<?php echo esc_attr($this->plugin_slug) ?>-tab-integration-action a:hover{
70
  background-color:#fff
71
  }
72
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box p a {
73
  display: inline-block;
74
  float: right;
75
  text-decoration: none;
@@ -78,15 +139,15 @@ class Folders_upgrade_box {
78
  right: 12px;
79
  top: 12px;
80
  }
81
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box p a:hover, .<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box p a:focus {
82
  color: #333333;
83
  }
84
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box .button span {
85
  display: inline-block;
86
  line-height: 27px;
87
  font-size: 16px;
88
  }
89
- .<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-popup {
90
  position: fixed;
91
  width: 100%;
92
  height: 100%;
@@ -96,7 +157,7 @@ class Folders_upgrade_box {
96
  left: 0;
97
  display: none;
98
  }
99
- .<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-popup-content {
100
  background: #ffffff;
101
  padding: 20px;
102
  position: absolute;
@@ -110,23 +171,23 @@ class Folders_upgrade_box {
110
  -moz-border-radius: 5px;
111
  border-radius: 5px;: ;
112
  }
113
- .<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-title {
114
  padding: 0 0 10px 0;
115
  font-weight: bold;
116
  }
117
- .<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-options a {
118
  display: block;
119
  margin: 5px 0 5px 0;
120
  color: #333;
121
  text-decoration: none;
122
  }
123
- .<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-options a.dismiss {
124
  color: #999;
125
  }
126
- .<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-options a:hover, .affiliate-options a:focus {
127
  color: #0073aa;
128
  }
129
- button.<?php echo esc_attr($this->plugin_slug) ?>-close-upgrade-box-popup {
130
  position: absolute;
131
  top: 5px;
132
  right: 0;
@@ -134,7 +195,7 @@ class Folders_upgrade_box {
134
  background: transparent;
135
  cursor: pointer;
136
  }
137
- a.button.button-primary.<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-btn {
138
  font-size: 14px;
139
  background: #F51366;
140
  color: #fff;
@@ -158,13 +219,13 @@ class Folders_upgrade_box {
158
  font-size: 14px;
159
  text-decoration: underline;
160
  }
161
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box p {
162
  line-height: 30px;
163
  vertical-align: middle;
164
  padding: 0 10px 0 0;
165
  font-size: 14px;
166
  }
167
- .<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box p img {
168
  width: 30px;
169
  height: 30px;
170
  display: inline-block;
@@ -215,83 +276,87 @@ class Folders_upgrade_box {
215
  </style>
216
  <?php
217
  $customize_folders = get_option("customize_folders");
218
- if(isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
219
  $upgradeURL = admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
220
  } else {
221
  $upgradeURL = admin_url("admin.php?page=folders-upgrade-to-pro");
222
  }
223
  ?>
224
- <div class="notice notice-info premio-notice <?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box <?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box">
225
- <div class="upgrade-box-default" id="default-upgrade-box-<?php echo esc_attr($this->plugin_slug) ?>">
226
  <p>
227
- <?php printf(esc_html__("%s to experience more exclusive features like dynamic folders, subfolders, access restriction & more", 'folders'), "<b>".esc_html__("Upgrade to ",'folders')." ".$this->plugin_name." Pro</b>") ?>
228
- <span class="<?php echo esc_attr($this->plugin_slug) ?>-tab-integration-action">
229
- <a class="upgradenow-box-btn" data-days="-1" href="<?php echo esc_url($upgradeURL); ?>" target="_blank" ><?php esc_html_e("Upgrade now", 'folders'); ?></a>
230
- </span>
231
- <a href="javascript:;" class="dismiss-btn <?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-dismiss-btn"><span class="dashicons dashicons-no-alt"></span></a>
232
  </p>
233
  <div class="clear clearfix"></div>
234
  </div>
235
  </div>
236
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-popup">
237
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-popup-content">
238
- <button class="<?php echo esc_attr($this->plugin_slug) ?>-close-upgrade-box-popup"><span class="dashicons dashicons-no-alt"></span></button>
239
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-title"> <?php esc_html_e("Would you like us to remind you about this later? ",'folders')?></div>
240
- <div class="<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-options">
241
- <a href="javascript:;" data-days="7"> <?php esc_html_e("Remind me in 7 days ",'folders')?></a>
242
- <a href="javascript:;" data-days="30"> <?php esc_html_e("Remind me in 30 days",'folders')?></a>
243
- <a href="javascript:;" data-days="-1" class="dismiss"> <?php esc_html_e("Don't remind me about this ",'folders')?></a>
244
  </div>
245
  </div>
246
  </div>
247
  <script>
248
  jQuery(document).ready(function(){
249
  jQuery("body").addClass("has-premio-box");
250
-
251
- jQuery(document).on("click",".upgradenow-box-btn",function(){
252
- jQuery(".notice.notice-info.premio-notice").hide();
253
-
254
- var dataDays = jQuery(this).attr("data-days");
255
-
256
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-popup").remove();
257
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box").remove();
258
  jQuery("body").removeClass("has-premio-box");
259
 
260
- jQuery.ajax({
261
  url: "<?php echo admin_url("admin-ajax.php") ?>",
262
- data: "action=<?php echo esc_attr($this->plugin_slug) ?>_upgrade_box&days="+dataDays+"&nonce=<?php echo esc_attr(wp_create_nonce($this->plugin_slug."_upgrade_box")) ?>",
263
  type: "post",
264
  success: function() {
265
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-popup").remove();
266
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box").remove();
267
  }
268
  });
269
- });
270
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-dismiss-btn, .<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box-future-btn", function(){
271
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-popup").show();
272
  });
273
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug) ?>-close-upgrade-box-popup", function(){
274
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-popup").hide();
 
 
 
275
  });
276
 
277
- jQuery(document).on("click", ".<?php echo esc_attr($this->plugin_slug)?>-upgrade-box-options a", function(){
278
  var dataDays = jQuery(this).attr("data-days");
279
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-popup").remove();
280
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box").remove();
281
  jQuery("body").removeClass("has-premio-box");
282
  jQuery.ajax({
283
  url: "<?php echo admin_url("admin-ajax.php") ?>",
284
- data: "action=<?php echo esc_attr($this->plugin_slug) ?>_upgrade_hide_box&days="+dataDays+"&nonce=<?php echo esc_attr(wp_create_nonce($this->plugin_slug."_upgrade_box")) ?>",
285
  type: "post",
286
  success: function() {
287
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-upgrade-box-popup").remove();
288
- jQuery(".<?php echo esc_attr($this->plugin_slug) ?>-premio-upgrade-box").remove();
289
  }
290
  });
291
  });
292
  });
293
  </script>
294
  <?php
295
- }
296
- }
297
- $Folders_upgrade_box = new Folders_upgrade_box();
 
 
 
 
1
  <?php
2
+ /**
3
+ * Class Folders Upgrade Box
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
 
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ class Folders_upgrade_box
14
+ {
15
+
16
+ /**
17
+ * The Name of this plugin.
18
+ *
19
+ * @var string $pluginName The Name of this plugin.
20
+ * @since 1.0.0
21
+ * @access public
22
+ */
23
+ public $pluginName = "Folders";
24
+
25
+ /**
26
+ * The Slug of this plugin.
27
+ *
28
+ * @var string $pluginSlug The Slug of this plugin.
29
+ * @since 1.0.0
30
+ * @access public
31
+ */
32
+ public $pluginSlug = "folders";
33
+
34
+
35
+ /**
36
+ * Define the core functionality of the plugin.
37
+ *
38
+ * Set the plugin name and the plugin version that can be used throughout the plugin.
39
+ * Load the dependencies, define the locale, and set the hooks for the admin area and
40
+ * the public-facing side of the site.
41
+ *
42
+ * @since 1.0.0
43
+ */
44
+ public function __construct()
45
+ {
46
+ add_action("wp_ajax_".$this->pluginSlug."_upgrade_hide_box", [$this, "upgrade_to_pro"]);
47
+ add_action('admin_notices', [$this, 'admin_notices']);
48
 
49
+ }//end __construct()
50
+
51
+
52
+ /**
53
+ * Updates settings for Upgrade Box
54
+ *
55
+ * @since 1.0.0
56
+ * @access public
57
+ * @return status
58
+ */
59
+ public function upgrade_to_pro()
60
+ {
61
  $nonce = filter_input(INPUT_POST, 'nonce');
62
+ $days = filter_input(INPUT_POST, 'days');
63
+ if (!empty($nonce) && wp_verify_nonce($nonce, $this->pluginSlug."_upgrade_box")) {
64
+ if ($days == -1) {
65
+ add_option($this->pluginSlug."_hide_upgrade_box", "1");
66
  } else {
67
  $date = date("Y-m-d", strtotime("+".$days." days"));
68
+ update_option($this->pluginSlug."_show_upgrade_box_after", $date);
69
  }
70
  }
71
+
72
  die;
 
73
 
74
+ }//end upgrade_to_pro()
75
+
76
+
77
+ /**
78
+ * Display Review Box
79
+ *
80
+ * @since 1.0.0
81
+ * @access public
82
+ * @return html
83
+ */
84
+ public function admin_notices()
85
+ {
86
+ $isHidden = get_option($this->pluginSlug."_hide_upgrade_box");
87
+ if ($isHidden !== false) {
88
  return;
89
  }
90
+
91
+ $currentCount = get_option($this->pluginSlug."_show_upgrade_box_after");
92
+ if ($currentCount === false) {
93
  $date = date("Y-m-d", strtotime("+15 days"));
94
+ add_option($this->pluginSlug."_show_upgrade_box_after", $date);
95
  return;
96
+ } else if ($currentCount < 35) {
97
  return;
98
  }
99
+
100
+ $dateToShow = get_option($this->pluginSlug."_show_upgrade_box_after");
101
+ if ($dateToShow !== false) {
102
+ $currentDate = date("Y-m-d");
103
+ if ($currentDate < $dateToShow) {
104
  return;
105
  }
106
  }
107
  ?>
108
  <style>
109
+ .<?php echo esc_attr($this->pluginSlug) ?>-tab-integration-action{
110
  padding: 0 10px;
111
  float: right;
112
  }
113
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box .<?php echo esc_attr($this->pluginSlug) ?>-tab-integration-action a {
114
  display: inline-block;
115
  float: right;
116
  text-decoration: none;
127
  text-align: center;
128
  line-height: 25px;
129
  }
130
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box .<?php echo esc_attr($this->pluginSlug) ?>-tab-integration-action a:hover{
131
  background-color:#fff
132
  }
133
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box p a {
134
  display: inline-block;
135
  float: right;
136
  text-decoration: none;
139
  right: 12px;
140
  top: 12px;
141
  }
142
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box p a:hover, .<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box p a:focus {
143
  color: #333333;
144
  }
145
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box .button span {
146
  display: inline-block;
147
  line-height: 27px;
148
  font-size: 16px;
149
  }
150
+ .<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-popup {
151
  position: fixed;
152
  width: 100%;
153
  height: 100%;
157
  left: 0;
158
  display: none;
159
  }
160
+ .<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-popup-content {
161
  background: #ffffff;
162
  padding: 20px;
163
  position: absolute;
171
  -moz-border-radius: 5px;
172
  border-radius: 5px;: ;
173
  }
174
+ .<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-title {
175
  padding: 0 0 10px 0;
176
  font-weight: bold;
177
  }
178
+ .<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-options a {
179
  display: block;
180
  margin: 5px 0 5px 0;
181
  color: #333;
182
  text-decoration: none;
183
  }
184
+ .<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-options a.dismiss {
185
  color: #999;
186
  }
187
+ .<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-options a:hover, .affiliate-options a:focus {
188
  color: #0073aa;
189
  }
190
+ button.<?php echo esc_attr($this->pluginSlug) ?>-close-upgrade-box-popup {
191
  position: absolute;
192
  top: 5px;
193
  right: 0;
195
  background: transparent;
196
  cursor: pointer;
197
  }
198
+ a.button.button-primary.<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-btn {
199
  font-size: 14px;
200
  background: #F51366;
201
  color: #fff;
219
  font-size: 14px;
220
  text-decoration: underline;
221
  }
222
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box p {
223
  line-height: 30px;
224
  vertical-align: middle;
225
  padding: 0 10px 0 0;
226
  font-size: 14px;
227
  }
228
+ .<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box p img {
229
  width: 30px;
230
  height: 30px;
231
  display: inline-block;
276
  </style>
277
  <?php
278
  $customize_folders = get_option("customize_folders");
279
+ if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
280
  $upgradeURL = admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
281
  } else {
282
  $upgradeURL = admin_url("admin.php?page=folders-upgrade-to-pro");
283
  }
284
  ?>
285
+ <div class="notice notice-info premio-notice <?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box <?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box">
286
+ <div class="upgrade-box-default" id="default-upgrade-box-<?php echo esc_attr($this->pluginSlug) ?>">
287
  <p>
288
+ <?php printf(esc_html__("%s to experience more exclusive features like dynamic folders, subfolders, access restriction & more", 'folders'), "<b>".esc_html__("Upgrade to ", 'folders')." ".esc_attr($this->pluginName)." Pro</b>") ?>
289
+ <span class="<?php echo esc_attr($this->pluginSlug) ?>-tab-integration-action">
290
+ <a class="upgradenow-box-btn" data-days="-1" href="<?php echo esc_url($upgradeURL); ?>" target="_blank" ><?php esc_html_e("Upgrade now", 'folders'); ?></a>
291
+ </span>
292
+ <a href="javascript:;" class="dismiss-btn <?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-dismiss-btn"><span class="dashicons dashicons-no-alt"></span></a>
293
  </p>
294
  <div class="clear clearfix"></div>
295
  </div>
296
  </div>
297
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-popup">
298
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-popup-content">
299
+ <button class="<?php echo esc_attr($this->pluginSlug) ?>-close-upgrade-box-popup"><span class="dashicons dashicons-no-alt"></span></button>
300
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-title"> <?php esc_html_e("Would you like us to remind you about this later? ", 'folders')?></div>
301
+ <div class="<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-options">
302
+ <a href="javascript:;" data-days="7"> <?php esc_html_e("Remind me in 7 days ", 'folders')?></a>
303
+ <a href="javascript:;" data-days="30"> <?php esc_html_e("Remind me in 30 days", 'folders')?></a>
304
+ <a href="javascript:;" data-days="-1" class="dismiss"> <?php esc_html_e("Don't remind me about this ", 'folders')?></a>
305
  </div>
306
  </div>
307
  </div>
308
  <script>
309
  jQuery(document).ready(function(){
310
  jQuery("body").addClass("has-premio-box");
311
+
312
+ jQuery(document).on("click",".upgradenow-box-btn",function(){
313
+ jQuery(".notice.notice-info.premio-notice").hide();
314
+
315
+ var dataDays = jQuery(this).attr("data-days");
316
+
317
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-popup").remove();
318
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box").remove();
319
  jQuery("body").removeClass("has-premio-box");
320
 
321
+ jQuery.ajax({
322
  url: "<?php echo admin_url("admin-ajax.php") ?>",
323
+ data: "action=<?php echo esc_attr($this->pluginSlug) ?>_upgrade_box&days="+dataDays+"&nonce=<?php echo esc_attr(wp_create_nonce($this->pluginSlug."_upgrade_box")) ?>",
324
  type: "post",
325
  success: function() {
326
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-popup").remove();
327
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box").remove();
328
  }
329
  });
 
 
 
330
  });
331
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-dismiss-btn, .<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box-future-btn", function(){
332
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-popup").show();
333
+ });
334
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-close-upgrade-box-popup", function(){
335
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-popup").hide();
336
  });
337
 
338
+ jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug)?>-upgrade-box-options a", function(){
339
  var dataDays = jQuery(this).attr("data-days");
340
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-popup").remove();
341
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box").remove();
342
  jQuery("body").removeClass("has-premio-box");
343
  jQuery.ajax({
344
  url: "<?php echo admin_url("admin-ajax.php") ?>",
345
+ data: "action=<?php echo esc_attr($this->pluginSlug) ?>_upgrade_hide_box&days="+dataDays+"&nonce=<?php echo esc_attr(wp_create_nonce($this->pluginSlug."_upgrade_box")) ?>",
346
  type: "post",
347
  success: function() {
348
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-upgrade-box-popup").remove();
349
+ jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-premio-upgrade-box").remove();
350
  }
351
  });
352
  });
353
  });
354
  </script>
355
  <?php
356
+
357
+ }//end admin_notices()
358
+
359
+
360
+ }//end class
361
+
362
+ $Folders_upgrade_box = new Folders_upgrade_box();
includes/class-wpml.php CHANGED
@@ -1,118 +1,259 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
- class WCP_Folder_WPML {
4
- private $is_wpml_active;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  private $total;
 
 
 
 
 
 
 
 
6
  private $lang;
7
- private $table_icl_translations;
8
 
9
- protected $post_translations;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  private $sitepress;
 
 
 
 
 
 
 
 
11
  private $settings;
12
 
 
 
 
 
 
 
 
 
 
 
13
  public function __construct()
14
  {
15
- $this->is_wpml_active = false;
16
- $this->total = 0;
17
- add_action("admin_init", array($this, 'init'));
18
- }
 
 
19
 
 
 
 
 
 
 
 
20
  public function init()
21
  {
22
  global $sitepress, $wpdb;
23
- $is_wpml_active = $sitepress !== null && get_class($sitepress) === "SitePress";
24
 
25
- if ($is_wpml_active) {
26
- $settings = $sitepress->get_setting('custom_posts_sync_option', array());
27
  if ($sitepress->get_current_language() !== 'all') {
28
- $this->is_wpml_active = true;
29
- $this->settings = $settings;
30
- $this->lang = $sitepress->get_current_language();
31
- $this->table_icl_translations = $wpdb->prefix . 'icl_translations';
32
  }
33
- $this->sitepress = $sitepress;
34
- $this->post_translations = $sitepress->post_translations();
 
35
  }
36
 
37
- if ($this->is_wpml_active) {
38
- add_filter('premio_folder_item_in_taxonomy', array($this, 'items_in_taxonomy'), 10, 2);
39
- add_filter('premio_folder_un_categorized_items', array($this, 'un_categorized_items'), 10, 2);
40
- add_filter('premio_folder_all_categorized_items', array($this, 'all_categorized_items'), 10, 2);
41
  }
42
- }
43
 
44
- public function set_total($post_type){
45
- if($this->is_wpml_active && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
 
 
 
 
 
 
 
 
 
 
 
46
  global $wpdb;
47
  $query = "SELECT COUNT(DISTINCT(p.id))
48
- FROM {$this->table_icl_translations} AS wpmlt
49
  INNER JOIN {$wpdb->posts} AS p ON p.id = wpmlt.element_id
50
- WHERE wpmlt.element_type = 'post_{$post_type}'
51
- AND wpmlt.language_code = '{$this->lang}'";
52
- if($post_type == 'attachment') {
53
  $query .= " AND (p.post_status = 'inherit' OR p.post_status = 'private')";
54
  } else {
55
  $query .= " AND p.post_status != 'trash'";
56
  }
57
- $this->total = (int)$wpdb->get_var($query);
 
 
58
  }
59
- }
60
 
61
- public function items_in_taxonomy($term_id, $arg = array()) {
62
- $post_type = isset($arg['post_type'])?$arg['post_type']:"";
63
- $taxonomy = isset($arg['taxonomy'])?$arg['taxonomy']:"";
64
- if($this->is_wpml_active && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
 
 
 
 
 
 
 
 
 
 
 
65
  global $wpdb;
66
- $term_taxonomy_id = get_term_by('id', (int)$term_id, $taxonomy, OBJECT)->term_taxonomy_id;
67
- $join = "INNER JOIN {$wpdb->term_relationships} AS term_rela ON term_rela.object_id = wpmlt.element_id";
68
- $where = "wpmlt.element_type = 'post_{$post_type}' AND term_rela.term_taxonomy_id = {$term_taxonomy_id} AND wpmlt.language_code = '{$this->lang}'";
69
- $query = "SELECT wpmlt.element_id FROM {$this->table_icl_translations} AS wpmlt " . $join . " WHERE " . $where;
70
- $all_ids = $wpdb->get_col($query);
71
- $counter = 0;
 
 
 
72
  if (count($all_ids) > 0) {
73
- if($post_type == 'attachment') {
74
- $query = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE `ID` IN (" . implode(',', $all_ids) . ") AND (post_status = 'inherit' OR post_status = 'private')";
 
75
  $counter = $wpdb->get_var($query);
76
  } else {
77
- $query = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE `ID` IN (" . implode(',', $all_ids) . ") AND post_status != 'trash'";
 
78
  $counter = $wpdb->get_var($query);
79
  }
80
  }
 
81
  return !empty($counter) ? $counter : 0;
82
- }
 
83
  return null;
84
- }
85
 
86
- public function un_categorized_items($post_type, $taxonomy) {
87
 
88
- if($this->is_wpml_active && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
89
 
 
 
 
 
 
 
 
 
 
 
 
90
  global $wpdb;
91
- $query = "SELECT COUNT(DISTINCT(tmp_table.ID))
92
- FROM (SELECT * FROM {$this->table_icl_translations} as wpmlt
93
  INNER JOIN {$wpdb->posts} as p on p.id = wpmlt.element_id
94
- WHERE wpmlt.element_type = 'post_{$post_type}'
95
- and wpmlt.language_code = '{$this->lang}') as tmp_table
96
  JOIN {$wpdb->term_relationships} as term_relationships on tmp_table.element_id = term_relationships.object_id
97
  JOIN {$wpdb->term_taxonomy} as term_taxonomy on term_relationships.term_taxonomy_id = term_taxonomy.term_taxonomy_id
98
- WHERE taxonomy = '{$taxonomy}'";
99
- $fileInFolder = (int)$wpdb->get_var($query);
 
100
 
101
  $this->set_total($post_type);
102
 
103
- return $this->total - $fileInFolder;
104
  }
 
105
  return null;
106
- }
107
 
108
- public function all_categorized_items($post_type) {
109
- if($this->is_wpml_active && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
 
 
 
 
 
 
 
 
 
 
 
110
  $this->set_total($post_type);
111
  return $this->total;
112
  }
 
113
  return null;
114
- }
115
- }
116
- if(class_exists('WCP_Folder_WPML')) {
 
 
 
 
117
  $folder_WPML = new WCP_Folder_WPML();
118
- }
1
  <?php
2
+ /**
3
+ * Class Folders WPML
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ class WCP_Folder_WPML
14
+ {
15
+
16
+ /**
17
+ * The Name of this plugin.
18
+ *
19
+ * @var string $isWPMLActive The Name of this plugin.
20
+ * @since 1.0.0
21
+ * @access private
22
+ */
23
+ private $isWPMLActive;
24
+
25
+ /**
26
+ * The Name of this plugin.
27
+ *
28
+ * @var string $total Total number of taxonomies
29
+ * @since 1.0.0
30
+ * @access private
31
+ */
32
  private $total;
33
+
34
+ /**
35
+ * The Name of this plugin.
36
+ *
37
+ * @var string $lang Current Selected language
38
+ * @since 1.0.0
39
+ * @access private
40
+ */
41
  private $lang;
 
42
 
43
+ /**
44
+ * The Name of this plugin.
45
+ *
46
+ * @var string $tableIclTranslations WPML translation table
47
+ * @since 1.0.0
48
+ * @access private
49
+ */
50
+ private $tableIclTranslations;
51
+
52
+ /**
53
+ * The Name of this plugin.
54
+ *
55
+ * @var string $tableIclTranslations WPML translated post
56
+ * @since 1.0.0
57
+ * @access protected
58
+ */
59
+ protected $postTranslations;
60
+
61
+ /**
62
+ * The Name of this plugin.
63
+ *
64
+ * @var string $sitepress sitepress
65
+ * @since 1.0.0
66
+ * @access protected
67
+ */
68
  private $sitepress;
69
+
70
+ /**
71
+ * The Name of this plugin.
72
+ *
73
+ * @var string $sitepress WPML Settings
74
+ * @since 1.0.0
75
+ * @access protected
76
+ */
77
  private $settings;
78
 
79
+
80
+ /**
81
+ * Define the core functionality of the plugin.
82
+ *
83
+ * Set the WPML installation status and settings.
84
+ * Load the dependencies, define the locale, and set the hooks for the admin area and
85
+ * the public-facing side of the site.
86
+ *
87
+ * @since 1.0.0
88
+ */
89
  public function __construct()
90
  {
91
+ $this->isWPMLActive = false;
92
+ $this->total = 0;
93
+ add_action("admin_init", [$this, 'init']);
94
+
95
+ }//end __construct()
96
+
97
 
98
+ /**
99
+ * Check for the WPML settings and status
100
+ *
101
+ * @since 1.0.0
102
+ * @access public
103
+ * @return $isWPMLActive
104
+ */
105
  public function init()
106
  {
107
  global $sitepress, $wpdb;
108
+ $isWPMLActive = $sitepress !== null && get_class($sitepress) === "SitePress";
109
 
110
+ if ($isWPMLActive) {
111
+ $settings = $sitepress->get_setting('custom_posts_sync_option', []);
112
  if ($sitepress->get_current_language() !== 'all') {
113
+ $this->isWPMLActive = true;
114
+ $this->settings = $settings;
115
+ $this->lang = $sitepress->get_current_language();
116
+ $this->tableIclTranslations = $wpdb->prefix.'icl_translations';
117
  }
118
+
119
+ $this->sitepress = $sitepress;
120
+ $this->postTranslations = $sitepress->postTranslations();
121
  }
122
 
123
+ if ($this->isWPMLActive) {
124
+ add_filter('premio_folder_item_in_taxonomy', [$this, 'items_in_taxonomy'], 10, 2);
125
+ add_filter('premio_folder_un_categorized_items', [$this, 'un_categorized_items'], 10, 2);
126
+ add_filter('premio_folder_all_categorized_items', [$this, 'all_categorized_items'], 10, 2);
127
  }
 
128
 
129
+ }//end init()
130
+
131
+
132
+ /**
133
+ * Get the total taxonomies used in WPML
134
+ *
135
+ * @since 1.0.0
136
+ * @access public
137
+ * @return $total
138
+ */
139
+ public function set_total($post_type)
140
+ {
141
+ if ($this->isWPMLActive && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
142
  global $wpdb;
143
  $query = "SELECT COUNT(DISTINCT(p.id))
144
+ FROM {$this->tableIclTranslations} AS wpmlt
145
  INNER JOIN {$wpdb->posts} AS p ON p.id = wpmlt.element_id
146
+ WHERE wpmlt.element_type = 'post_".esc_attr($post_type)."'
147
+ AND wpmlt.language_code = '%s'";
148
+ if ($post_type == 'attachment') {
149
  $query .= " AND (p.post_status = 'inherit' OR p.post_status = 'private')";
150
  } else {
151
  $query .= " AND p.post_status != 'trash'";
152
  }
153
+
154
+ $query = $wpdb->prepare($query, [$this->lang]);
155
+ $this->total = (int) $wpdb->get_var($query);
156
  }
 
157
 
158
+ }//end set_total()
159
+
160
+
161
+ /**
162
+ * To get the items in taxonomies
163
+ *
164
+ * @since 1.0.0
165
+ * @access public
166
+ * @return $total
167
+ */
168
+ public function items_in_taxonomy($term_id, $arg=[])
169
+ {
170
+ $post_type = isset($arg['post_type']) ? $arg['post_type'] : "";
171
+ $taxonomy = isset($arg['taxonomy']) ? $arg['taxonomy'] : "";
172
+ if ($this->isWPMLActive && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
173
  global $wpdb;
174
+ $term_taxonomy_id = get_term_by('id', (int) $term_id, $taxonomy, OBJECT)->term_taxonomy_id;
175
+ $query = "SELECT wpmlt.element_id FROM {$this->tableIclTranslations} AS wpmlt
176
+ INNER JOIN {$wpdb->term_relationships} AS term_rela ON term_rela.object_id = wpmlt.element_id
177
+ WHERE wpmlt.element_type = 'post_".esc_attr($post_type)."'
178
+ AND term_rela.term_taxonomy_id = '%s'
179
+ AND wpmlt.language_code = '%s'";
180
+ $query = $wpdb->prepare($query, [$term_taxonomy_id, $this->lang]);
181
+ $all_ids = $wpdb->get_col($query);
182
+ $counter = 0;
183
  if (count($all_ids) > 0) {
184
+ if ($post_type == 'attachment') {
185
+ $query = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE `ID` IN (%s) AND (post_status = 'inherit' OR post_status = 'private')";
186
+ $query = $wpdb->prepare($query, [implode(',', $all_ids)]);
187
  $counter = $wpdb->get_var($query);
188
  } else {
189
+ $query = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE `ID` IN (%s) AND post_status != 'trash'";
190
+ $query = $wpdb->prepare($query, [implode(',', $all_ids)]);
191
  $counter = $wpdb->get_var($query);
192
  }
193
  }
194
+
195
  return !empty($counter) ? $counter : 0;
196
+ }//end if
197
+
198
  return null;
 
199
 
200
+ }//end items_in_taxonomy()
201
 
 
202
 
203
+ /**
204
+ * To get the items in taxonomies in uncategorized
205
+ *
206
+ * @since 1.0.0
207
+ * @access public
208
+ * @return $total
209
+ */
210
+ public function un_categorized_items($post_type, $taxonomy)
211
+ {
212
+
213
+ if ($this->isWPMLActive && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
214
  global $wpdb;
215
+ $query = "SELECT COUNT(DISTINCT(tmp_table.ID))
216
+ FROM (SELECT * FROM {$this->tableIclTranslations} as wpmlt
217
  INNER JOIN {$wpdb->posts} as p on p.id = wpmlt.element_id
218
+ WHERE wpmlt.element_type = 'post_.".esc_attr($post_type)."'
219
+ and wpmlt.language_code = '%s') as tmp_table
220
  JOIN {$wpdb->term_relationships} as term_relationships on tmp_table.element_id = term_relationships.object_id
221
  JOIN {$wpdb->term_taxonomy} as term_taxonomy on term_relationships.term_taxonomy_id = term_taxonomy.term_taxonomy_id
222
+ WHERE taxonomy = '%s'";
223
+ $query = $wpdb->prepare($query, [$this->lang, $taxonomy]);
224
+ $fileInFolder = (int) $wpdb->get_var($query);
225
 
226
  $this->set_total($post_type);
227
 
228
+ return ($this->total - $fileInFolder);
229
  }
230
+
231
  return null;
 
232
 
233
+ }//end un_categorized_items()
234
+
235
+
236
+ /**
237
+ * To get the items in taxonomies in all categories
238
+ *
239
+ * @since 1.0.0
240
+ * @access public
241
+ * @return $total
242
+ */
243
+ public function all_categorized_items($post_type)
244
+ {
245
+ if ($this->isWPMLActive && isset($this->settings[$post_type]) && $this->settings[$post_type]) {
246
  $this->set_total($post_type);
247
  return $this->total;
248
  }
249
+
250
  return null;
251
+
252
+ }//end all_categorized_items()
253
+
254
+
255
+ }//end class
256
+
257
+ if (class_exists('WCP_Folder_WPML')) {
258
  $folder_WPML = new WCP_Folder_WPML();
259
+ }
includes/folders.class.php CHANGED
@@ -1,372 +1,538 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
- /* Free/Pro Class name change */
 
 
 
 
 
 
 
 
 
 
4
  class WCP_Folders
5
  {
6
 
 
 
 
 
 
 
 
7
  private static $instance;
8
 
 
 
 
 
 
 
 
9
  private static $license_key_data = null;
10
 
 
 
 
 
 
 
 
11
  private static $folders;
12
 
 
 
 
 
 
 
 
13
  public $tlfs = 0;
14
 
 
 
 
 
 
 
 
15
  private static $postIds;
16
 
 
 
 
 
 
 
 
17
  private static $folderSettings = false;
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  public function __construct()
20
  {
21
 
22
-
23
- spl_autoload_register(array($this, 'autoload'));
24
- add_action('init', array($this, 'create_folder_terms'), 15);
25
- add_action('admin_init', array($this, 'folders_register_settings'));
26
- add_action('admin_menu', array($this, 'admin_menu'), 10000);
27
- add_action('admin_enqueue_scripts', array($this, 'folders_admin_styles'));
28
- add_action('admin_enqueue_scripts', array($this, 'folders_admin_scripts'));
29
- add_filter('plugin_action_links_' . WCP_FOLDERS_PLUGIN_BASE, [$this, 'plugin_action_links']);
30
- add_action('admin_footer', array($this, 'admin_footer'));
31
-
32
- /* check for polygon media */
33
- // $polylang_options = get_option("polylang");
34
- // if(is_array($polylang_options) && isset($polylang_options['media_support']) && $polylang_options['media_support'] == 1) {
35
- // $polylang_options['media_support'] = 0;
36
- // update_option("polylang", $polylang_options);
37
- // }
38
-
39
- $old_status = get_option("wcp_folder_version_267");
40
-
41
- add_action('parse_tax_query', array($this, 'taxonomy_archive_exclude_children'));
42
- add_action('admin_footer', array($this, 'admin_footer_for_media'));
43
-
44
- /* Save Data */
45
- add_action('wp_ajax_wcp_add_new_folder', array($this, 'wcp_add_new_folder'));
46
- /* Update Data */
47
- add_action('wp_ajax_wcp_update_folder', array($this, 'wcp_update_folder'));
48
- /* Remove Data */
49
- add_action('wp_ajax_wcp_remove_folder', array($this, 'wcp_remove_folder'));
50
- /* Remove Multple Folder */
51
- add_action('wp_ajax_wcp_remove_muliple_folder', array($this, 'remove_muliple_folder'));
52
- /* Save State Data */
53
- add_action('wp_ajax_save_wcp_folder_state', array($this, 'save_wcp_folder_state'));
54
- /* Save State Data */
55
- add_action('wp_ajax_wcp_save_parent_data', array($this, 'wcp_save_parent_data'));
56
- /* Update Parent Data */
57
- add_action('wp_ajax_wcp_update_parent_information', array($this, 'wcp_update_parent_information'));
58
- /* Update Parent Data */
59
- add_action('wp_ajax_wcp_save_folder_order', array($this, 'wcp_save_folder_order'));
60
- /* Update Parent Data */
61
- add_action('wp_ajax_wcp_mark_un_mark_folder', array($this, 'wcp_mark_un_mark_folder'));
62
- /* Update Parent Data */
63
- add_action('wp_ajax_wcp_make_sticky_folder', array($this, 'wcp_make_sticky_folder'));
64
- /* Update Parent Data */
65
- add_action('wp_ajax_wcp_change_post_folder', array($this, 'wcp_change_post_folder'));
66
- /* Update Parent Data */
67
- add_action('wp_ajax_wcp_change_multiple_post_folder', array($this, 'wcp_change_multiple_post_folder'));
68
- /* Update width Data */
69
- add_action('wp_ajax_wcp_change_post_width', array($this, 'wcp_change_post_width'));
70
- /* Update width Data */
71
- add_action('wp_ajax_wcp_change_folder_display_status', array($this, 'wcp_change_folder_display_status'));
72
- /* Update width Data */
73
- add_action('wp_ajax_wcp_change_all_status', array($this, 'wcp_change_all_status'));
74
- /* Update width Data */
75
- add_action('wp_ajax_save_folder_last_status', array($this, 'save_folder_last_status'));
76
- /* Update width Data */
77
- add_action('wp_ajax_wcp_folders_by_order', array($this, 'wcp_folders_by_order'));
78
- /* Update width Data */
79
- add_action('wp_ajax_wcp_remove_all_folders_data', array($this, 'remove_all_folders_data'));
80
- /* Update folders Status */
81
- add_action('wp_ajax_wcp_update_folders_uninstall_status', array($this, 'update_folders_uninstall_status'));
82
- /* Undo Functionality */
83
- add_action('wp_ajax_wcp_undo_folder_changes', array($this, 'wcp_undo_folder_changes'));
84
  self::$folders = 10;
85
 
86
- /* Send message on plugin deactivate */
87
- add_action( 'wp_ajax_folder_plugin_deactivate', array( $this, 'folder_plugin_deactivate' ) );
88
- /* Update Parent Data */
89
- add_action('wp_ajax_wcp_remove_post_folder', array($this, 'wcp_remove_post_folder'));
90
- /* Send message on owner */
91
- add_action( 'wp_ajax_wcp_folder_send_message_to_owner', array( $this, 'wcp_folder_send_message_to_owner' ) );
92
- /* Get default list */
93
- add_action('wp_ajax_premio_check_for_other_folders', array($this, 'premio_check_for_other_folders'));
94
- /* Send message on owner */
95
- add_action( 'wp_ajax_wcp_get_default_list', array( $this, 'wcp_get_default_list' ) );
96
- /* Get default list */
97
- add_action( 'wp_ajax_get_folders_default_list', array( $this, 'get_folders_default_list' ) );
98
- /* Auto select folder for new page, post */
99
- add_action('new_to_auto-draft', array($this, 'new_to_auto_draft'), 10);
100
- /* for media */
101
- add_action('restrict_manage_posts', array($this, 'output_list_table_filters'), 10, 2);
102
- add_filter('pre_get_posts', array($this, 'filter_attachments_list'));
103
- add_action('wp_enqueue_media', array($this, 'output_backbone_view_filters'));
104
- add_filter('ajax_query_attachments_args', array($this, 'filter_attachments_grid'));
105
- add_filter('add_attachment', array($this, 'save_media_terms'));
106
-
107
- /* to filter un assigned items*/
108
- add_filter('pre_get_posts', array($this, 'filter_record_list'));
109
- add_filter('pre-upload-ui', array($this, 'show_dropdown_on_media_screen'));
110
- add_action('add_attachment', array($this, 'add_attachment_category'));
111
 
112
  $options = get_option("folders_settings");
113
 
114
- $options = is_array($options)?$options:array();
115
 
116
  if (in_array("post", $options)) {
117
- add_filter('manage_posts_columns', array($this, 'wcp_manage_columns_head'));
118
- add_action('manage_posts_custom_column', array($this, 'wcp_manage_columns_content'), 10, 2);
119
- add_filter( 'bulk_actions-edit-post', array($this, 'custom_bulk_action' ));
120
  }
121
 
122
  if (in_array("page", $options)) {
123
- add_filter('manage_page_posts_columns', array($this, 'wcp_manage_columns_head'));
124
- add_action('manage_page_posts_custom_column', array($this, 'wcp_manage_columns_content'), 10, 2);
125
- add_filter( 'bulk_actions-edit-page', array($this, 'custom_bulk_action' ));
126
  }
127
 
128
  if (in_array("attachment", $options)) {
129
- add_filter('manage_media_columns', array($this, 'wcp_manage_columns_head'));
130
- add_action('manage_media_custom_column', array($this, 'wcp_manage_columns_content'), 10, 2);
131
- //add_filter('bulk_actions-edit-media', array($this, 'custom_bulk_action' ));
132
  }
133
 
134
  foreach ($options as $option) {
135
  if ($option != "post" && $option != "page" && $option != "attachment") {
136
- add_filter('manage_edit-'.$option.'_columns', array($this, 'wcp_manage_columns_head'), 99999);
137
- add_action('manage_'.$option.'_posts_custom_column', array($this, 'wcp_manage_columns_content'), 2, 2);
138
- add_filter( 'bulk_actions-edit-'.$option, array($this, 'custom_bulk_action' ));
139
  }
140
  }
141
 
142
- /* check for default folders */
143
- add_filter('pre_get_posts', array($this, 'check_for_default_folders'));
144
 
145
- add_action("wp_ajax_folder_update_status", array($this, 'folder_update_status'));
146
 
147
- /* load language files */
148
- add_action( 'plugins_loaded', array( $this, 'folders_text' ) );
149
 
150
- add_action("wp_ajax_folder_update_popup_status", array($this, 'folder_update_popup_status'));
151
 
152
- add_action("wp_ajax_premio_hide_child_popup", array($this, 'premio_hide_child_popup'));
153
 
154
- add_action("wp_ajax_wcp_update_folders_import_status", array($this, 'update_folders_import_status'));
155
 
156
- add_filter('get_terms', array( $this, 'get_terms_filter_without_trash'), 10, 3);
157
 
158
- add_filter('mla_media_modal_query_final_terms', array( $this, 'media_modal_query_final_terms'), 10, 3);
159
 
160
- /* reset count when post/page updated */
161
- add_action( 'deleted_term_relationships', array($this, 'update_folder_term_relationships'), 10, 3 );
162
 
163
- add_action( 'added_term_relationship', array($this, 'update_folder_new_term_relationships'), 10, 3 );
164
 
165
- add_action( 'set_object_terms', array($this, 'set_object_terms_for_folders'), 10, 6);
166
 
167
  /*
168
  * To Remove Attachment
169
  * */
170
 
171
- add_action( 'wp_trash_post', array($this, "wcp_delete_post"));
172
- add_action( 'before_delete_post', array($this, "wcp_delete_post"));
173
 
174
  /*
175
  * Hide Folder CTA
176
  * */
177
- add_action( 'wp_ajax_hide_folders_cta', array($this, 'hide_folders_cta'));
178
- }
179
 
180
- public function hide_folders_cta() {
181
- $response = array();
182
- $response['status'] = 0;
183
- $response['error'] = 0;
184
- $response['data'] = array();
 
 
 
 
 
 
 
 
 
 
 
185
  $response['message'] = "";
186
- $postData = filter_input_array(INPUT_POST);
187
- $errorCounter = 0;
188
  if (!isset($postData['nonce']) || empty($postData['nonce'])) {
189
- $response['message'] = esc_html__("Your request is not valid", 'folders');
190
  $errorCounter++;
191
  } else {
192
  $nonce = self::sanitize_options($postData['nonce']);
193
- if(!wp_verify_nonce($nonce, 'hide_folders_cta')) {
194
- $response['message'] = esc_html__("Your request is not valid", 'folders');
195
  $errorCounter++;
196
  }
197
  }
198
- if($errorCounter == 0) {
 
199
  $response['status'] = 1;
200
  add_option("hide_folders_cta", "yes");
201
  }
202
- echo json_encode($response); die;
203
- }
204
 
205
- public function wcp_delete_post($postID) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  delete_transient("premio_folders_without_trash");
207
- }
208
 
209
- public function set_object_terms_for_folders($object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids) {
210
- if(!empty($object_id)) {
 
 
 
 
 
 
 
 
 
 
 
211
  $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
212
- if(!empty($tt_ids) && is_array($tt_ids)) {
213
- foreach($tt_ids as $term_id) {
214
  $term = get_term($term_id, $taxonomy);
215
- if(isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
216
  unset($trash_folders[$term->term_taxonomy_id]);
217
  }
218
  }
219
  }
220
 
221
- if(!empty($old_tt_ids) && is_array($old_tt_ids)) {
222
- foreach($old_tt_ids as $term_id) {
223
  $term = get_term($term_id, $taxonomy);
224
- if(isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
225
  unset($trash_folders[$term->term_taxonomy_id]);
226
  }
227
  }
228
  }
229
 
230
- if($initial_trash_folders != $trash_folders) {
231
  delete_transient("premio_folders_without_trash");
232
- set_transient("premio_folders_without_trash", $trash_folders, 3*DAY_IN_SECONDS);
233
  }
234
- }
235
- }
 
236
 
237
- public static function check_for_setting($key, $setting, $default = "") {
238
- if(self::$folderSettings === false) {
 
 
 
 
 
 
 
 
 
239
  $options = get_option("premio_folder_options");
240
- if($options === false || !is_array($options)) {
241
- $options = array();
242
  }
243
- self::$folderSettings = $options;
 
244
  }
245
- if($setting == "folders_settings") {
246
- if(isset(self::$folderSettings[ $setting ]) && is_array(self::$folderSettings[ $setting ])) {
247
- return in_array($key, self::$folderSettings[ $setting ]);
 
248
  }
249
  } else {
250
- if ( isset( self::$folderSettings[ $setting ][ $key ] ) ) {
251
- return self::$folderSettings[ $setting ][ $key ];
252
- }
253
  }
254
- return false;
255
- }
256
 
257
- public function update_folders_uninstall_status() {
258
- $response = array();
259
- $response['status'] = 0;
260
- $response['error'] = 0;
261
- $response['data'] = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  $response['message'] = "";
263
- $postData = filter_input_array(INPUT_POST);
264
- $errorCounter = 0;
265
 
266
  if (!isset($postData['nonce']) || empty($postData['nonce'])) {
267
  $response['message'] = esc_html__("Your request is not valid", 'folders');
268
  $errorCounter++;
269
  } else {
270
  $nonce = self::sanitize_options($postData['nonce']);
271
- if(!wp_verify_nonce($nonce, 'wcp_folders_uninstall_status')) {
272
  $response['message'] = esc_html__("Your request is not valid", 'folders');
273
  $errorCounter++;
274
  }
275
  }
 
276
  if ($errorCounter == 0) {
277
- $status = isset($postData['status'])?$postData['status']:"";
278
- $status = ($status == "on")?"on":"off";
279
  $customize_folders = get_option('customize_folders');
280
  $customize_folders['remove_folders_when_removed'] = $status;
281
  update_option("customize_folders", $customize_folders);
282
  $response['status'] = 1;
283
  }
284
- echo json_encode($response); die;
285
- }
286
 
287
- public function remove_all_folders_data() {
288
- $response = array();
289
- $response['status'] = 0;
290
- $response['error'] = 0;
291
- $response['data'] = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  $response['message'] = "";
293
- $postData = filter_input_array(INPUT_POST);
294
- $errorCounter = 0;
295
 
296
  if (!isset($postData['nonce']) || empty($postData['nonce'])) {
297
  $response['message'] = esc_html__("Your request is not valid", 'folders');
298
  $errorCounter++;
299
  } else {
300
- $type = self::sanitize_options($postData['type']);
301
  $nonce = self::sanitize_options($postData['nonce']);
302
- if(!wp_verify_nonce($nonce, 'remove_folders_data')) {
303
  $response['message'] = esc_html__("Your request is not valid", 'folders');
304
  $errorCounter++;
305
  }
306
  }
 
307
  if ($errorCounter == 0) {
308
  self::$folders = 0;
309
  self::remove_folder_by_taxonomy("media_folder");
310
  self::remove_folder_by_taxonomy("folder");
311
  self::remove_folder_by_taxonomy("post_folder");
312
- $post_types = get_post_types( array( ), 'objects' );
313
- $post_array = array("page", "post", "attachment");
314
- foreach ( $post_types as $post_type ) {
315
- if(!in_array($post_type->name, $post_array)){
316
- self::remove_folder_by_taxonomy($post_type->name . '_folder');
 
 
 
 
317
  }
318
  }
 
319
  delete_option('default_folders');
320
  $response['status'] = 1;
321
- $response['data'] = array(
322
- 'items' => self::$folders
323
- );
324
- }
325
- echo json_encode($response); die;
326
- }
 
 
 
327
 
328
- public static function remove_folder_by_taxonomy($taxonomy) {
 
 
 
 
 
 
 
 
 
329
  global $wpdb;
330
- $folders = $wpdb->get_results(
331
- "SELECT * FROM " . $wpdb->term_taxonomy . "
332
- LEFT JOIN " . $wpdb->terms . "
333
- ON " . $wpdb->term_taxonomy . ".term_id = " . $wpdb->terms . ".term_id
334
- WHERE " . $wpdb->term_taxonomy . ".taxonomy = '" . $taxonomy . "'
335
- ORDER BY parent ASC"
336
- );
337
- $folders = array_values( $folders );
338
- foreach ( $folders as $folder ) {
339
- $term_id = intval( $folder->term_id );
340
- if ( $term_id ) {
341
- $wpdb->delete( $wpdb->prefix . 'term_relationships', ['term_taxonomy_id' => $term_id] );
342
- $wpdb->delete( $wpdb->prefix . 'term_taxonomy', ['term_id' => $term_id] );
343
- $wpdb->delete( $wpdb->prefix . 'terms', ['term_id' => $term_id] );
344
- $wpdb->delete( $wpdb->prefix . 'termmeta', ['term_id' => $term_id] );
345
  self::$folders++;
346
  }
347
  }
348
- }
349
 
350
- public static function hexToRgb($hex, $alpha = false) {
 
 
 
 
 
 
 
 
 
 
 
351
  $hex = str_replace('#', '', $hex);
352
  $length = strlen($hex);
353
  $rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
354
  $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
355
  $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
356
- if ( $alpha ) {
357
  $rgb['a'] = $alpha;
358
  }
 
359
  return $rgb;
360
- }
361
 
362
- public function wcp_folders_by_order(){
363
- $response = array();
364
- $response['status'] = 0;
365
- $response['error'] = 0;
366
- $response['data'] = array();
 
 
 
 
 
 
 
 
 
 
 
367
  $response['message'] = "";
368
- $postData = filter_input_array(INPUT_POST);
369
- $errorCounter = 0;
370
 
371
  if (!isset($postData['order']) || empty($postData['order'])) {
372
  $response['message'] = esc_html__("Your request is not valid", 'folders');
@@ -384,56 +550,70 @@ class WCP_Folders
384
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
385
  $errorCounter++;
386
  } else {
387
- $type = self::sanitize_options($postData['type']);
388
  $nonce = self::sanitize_options($postData['nonce']);
389
- if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
390
  $response['message'] = esc_html__("Your request is not valid", 'folders');
391
  $errorCounter++;
392
  }
393
- }
 
394
  if ($errorCounter == 0) {
395
  $response['status'] = 1;
396
 
397
  $order_field = $postData['order'];
398
 
399
  $order_by = "";
400
- $order = "ASC";
401
 
402
- if($order_field == "a-z" || $order_field == "z-a") {
403
  $order_by = 'title';
404
- if($order_field == "z-a") {
405
  $order = "DESC";
406
  }
407
- } else if($order_field == "n-o" || $order_field == "o-n") {
408
  $order_by = 'ID';
409
- if($order_field == "o-n") {
410
  $order = "ASC";
411
  } else {
412
  $order = "DESC";
413
  }
414
  }
415
 
416
- if(empty($order_by)) {
417
  $order = "";
418
  }
419
 
420
  $folder_type = self::get_custom_post_type($postData['type']);
421
- /* Do not change: Free/Pro Class name change */
422
  $tree_data = WCP_Tree::get_full_tree_data($folder_type, $order_by, $order);
423
 
424
  $response['data'] = $tree_data['string'];
425
- $taxonomies = array();
426
- if($postData['type'] == "attachment") {
427
  $taxonomies = self::get_terms_hierarchical($folder_type);
428
  }
 
429
  $response['terms'] = $taxonomies;
430
- }
431
- echo json_encode($response); die;
432
- }
 
 
 
433
 
434
- public function save_folder_last_status(){
 
 
 
 
 
 
 
 
 
435
  $postData = filter_input_array(INPUT_POST);
436
- $error = 0;
437
  if (!isset($postData['post_id']) || empty($postData['post_id'])) {
438
  $response['message'] = esc_html__("Your request is not valid", 'folders');
439
  $error = 1;
@@ -450,42 +630,64 @@ class WCP_Folders
450
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
451
  $error = 1;
452
  }
453
- if($error == 0) {
454
- $post_type = filter_input(INPUT_POST, 'post_type', FILTER_SANITIZE_STRING);
455
- $post_id = filter_input(INPUT_POST, 'post_id', FILTER_SANITIZE_STRING);
 
456
  if (!empty($post_type) && !empty($post_id)) {
457
- delete_option("last_folder_status_for" . $post_type);
458
- add_option("last_folder_status_for" . $post_type, $post_id);
459
  }
460
  }
461
- }
462
 
 
 
 
 
 
 
 
 
 
 
463
  public function media_modal_query_final_terms($request)
464
  {
465
- if (isset($_REQUEST['action']) && $_REQUEST['action'] == "mla-query-attachments") {
466
- $query = isset($_REQUEST['query']) ? $_REQUEST['query'] : array();
 
467
  if (isset($query['media_folder']) && !empty($query['media_folder'])) {
468
  if ($query['media_folder'] == -1) {
469
- $tax_query = array(
470
  'taxonomy' => 'media_folder',
471
  'operator' => 'NOT EXISTS',
472
- );
473
- $request['tax_query'] = array($tax_query);
474
  $request = apply_filters('media_library_organizer_media_filter_attachments', $request, $_REQUEST);
475
  } else {
476
  $request['media_folder'] = $query['media_folder'];
477
  }
478
  }
479
  }
 
480
  return $request;
481
- }
482
 
483
- public function get_terms_filter_without_trash($terms, $taxonomies, $args) {
 
 
 
 
 
 
 
 
 
 
 
484
 
485
  $isForFolders = 0;
486
- if(!empty($taxonomies) && is_array($taxonomies) && count($taxonomies)){
487
  foreach ($taxonomies as $taxonomy) {
488
- if (in_array($taxonomy, array("media_folder", "folder", "post_folder"))) {
489
  $isForFolders = 1;
490
  } else {
491
  $folder = substr($taxonomy, -7);
@@ -496,7 +698,7 @@ class WCP_Folders
496
  }
497
  }
498
 
499
- if($isForFolders) {
500
  global $wpdb;
501
  if (!is_array($terms) && count($terms) < 1) {
502
  return $terms;
@@ -504,19 +706,20 @@ class WCP_Folders
504
 
505
  $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
506
  if ($trash_folders === false) {
507
- $trash_folders = array();
508
- $initial_trash_folders = array();
509
  }
510
 
511
- $post_table = $wpdb->prefix . "posts";
512
- $term_table = $wpdb->prefix . "term_relationships";
513
- $options = get_option('folders_settings');
514
- $option_array = array();
515
  if (!empty($options)) {
516
  foreach ($options as $option) {
517
  $option_array[] = self::get_custom_post_type($option);
518
  }
519
  }
 
520
  foreach ($terms as $key => $term) {
521
  if (isset($term->term_taxonomy_id) && isset($term->taxonomy) && !empty($term->taxonomy) && in_array($term->taxonomy, $option_array)) {
522
  $trash_count = null;
@@ -525,7 +728,7 @@ class WCP_Folders
525
  } else {
526
  if (has_filter("premio_folder_item_in_taxonomy")) {
527
  $post_type = "";
528
- $taxonomy = $term->taxonomy;
529
 
530
  if ($taxonomy == "post_folder") {
531
  $post_type = "post";
@@ -536,19 +739,20 @@ class WCP_Folders
536
  } else {
537
  $post_type = trim($taxonomy, "'_folder'");
538
  }
539
- $arg = array(
 
540
  'post_type' => $post_type,
541
- 'taxonomy' => $taxonomy,
542
- );
543
  $trash_count = apply_filters("premio_folder_item_in_taxonomy", $term->term_id, $arg);
544
  }
545
 
546
  if ($trash_count === null) {
547
- //$result = $wpdb->get_var("SELECT COUNT(*) FROM {$post_table} p JOIN {$term_table} rl ON p.ID = rl.object_id WHERE rl.term_taxonomy_id = '{$term->term_taxonomy_id}' AND p.post_status != 'trash' LIMIT 1");
548
- $query = "SELECT COUNT(DISTINCT(p.ID))
549
  FROM {$post_table} p
550
  JOIN {$term_table} rl ON p.ID = rl.object_id
551
- WHERE rl.term_taxonomy_id = '{$term->term_taxonomy_id}' AND p.post_status != 'trash' LIMIT 1";
 
552
  $result = $wpdb->get_var($query);
553
  if (intval($result) > 0) {
554
  $trash_count = intval($result);
@@ -556,87 +760,136 @@ class WCP_Folders
556
  $trash_count = 0;
557
  }
558
  }
559
- }
 
560
  if ($trash_count === null) {
561
  $trash_count = 0;
562
  }
 
563
  $terms[$key]->trash_count = $trash_count;
564
  $trash_folders[$term->term_taxonomy_id] = $trash_count;
565
- }
566
- }
567
 
568
  if (!empty($terms) && $initial_trash_folders != $trash_folders) {
569
  delete_transient("premio_folders_without_trash");
570
- set_transient("premio_folders_without_trash", $trash_folders, 3 * DAY_IN_SECONDS);
571
  }
572
- }
573
- return $terms;
574
- }
 
 
575
 
576
- public function custom_bulk_action($bulk_actions) {
577
- $bulk_actions['move_to_folder'] = __( 'Move to Folder', 'email_to_eric');
 
 
 
 
 
 
 
 
 
578
  return $bulk_actions;
579
- }
580
 
581
- public function folders_text() {
582
- load_plugin_textdomain("folders", FALSE, dirname(plugin_basename(__FILE__)).'/languages/');
583
- }
 
 
 
 
 
 
 
 
 
 
 
 
584
 
585
- public function admin_footer_for_media(){
586
- echo "<style>";
 
 
 
 
 
 
 
 
587
  $customize_folders = get_option('customize_folders');
588
- if(isset($customize_folders['dropdown_color']) && !empty($customize_folders['dropdown_color'])) {
589
  ?>
590
- #media-attachment-taxonomy-filter, .post-upload-ui .folder_for_media, select.media-select-folder { border-color: <?php echo esc_attr($customize_folders['dropdown_color']) ?>; color: <?php echo esc_attr($customize_folders['dropdown_color']) ?> }
591
- .folder_for_media option {color:#000000;}
 
 
 
 
 
 
592
  .folder_for_media option:first-child {
593
- font-weight: bold;
594
  }
 
595
  <?php
596
  }
597
- echo "</style>";
598
- }
599
 
600
- public function check_for_default_folders() {
 
 
 
 
 
 
 
 
 
 
 
601
  global $typenow, $current_screen;
602
- $isAjax = (defined('DOING_AJAX') && DOING_AJAX)?1:0;
603
- $options = get_option('folders_settings');
604
- $options = (empty($options) || !is_array($options))?array():$options;
605
- $post_status = filter_input(INPUT_GET, 'post_status', FILTER_SANITIZE_STRING);
606
  $last_status = get_option("last_folder_status_for".$typenow);
607
- if(empty($post_status) && !$isAjax && (in_array($typenow, $options) || !empty($last_status)) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) {
608
-
609
  $requests = filter_input_array(INPUT_GET);
610
- $requests = empty($requests)||!is_array($requests)?array():$requests;
611
 
612
  if ($typenow == "attachment") {
613
- if(count($requests) > 0) {
614
  return;
615
  }
616
  } else if ($typenow == "post") {
617
- if(count($requests) > 0) {
618
  return;
619
  }
620
  } else {
621
- if(count($requests) > 1) {
622
  return;
623
  }
624
  }
625
 
626
- if(!empty($last_status)) {
627
  $status = 1;
628
- if($last_status != "-1" && $last_status != "all") {
629
  $type = self::get_custom_post_type($typenow);
630
  $term = get_term_by('slug', $last_status, $type);
631
  if (empty($term) || !is_object($term)) {
632
  $status = 0;
633
  }
634
  }
 
635
  delete_option("last_folder_status_for".$typenow);
636
- if($last_status == "all") {
637
  $last_status = "";
638
  }
639
- if($status) {
 
640
  if ($typenow == "attachment") {
641
  if (!isset($_REQUEST['media_folder'])) {
642
  ?>
@@ -648,26 +901,26 @@ class WCP_Folders
648
  }
649
  } else {
650
  $post_type = self::get_custom_post_type($typenow);
651
- $admin_url = admin_url("edit.php?post_type=" . $typenow);
652
  if (!isset($_REQUEST[$post_type])) {
653
  ?>
654
  <script>
655
- window.location = '<?php echo admin_url("edit.php?post_type=".$typenow)."&".esc_attr($post_type)."=".esc_attr($last_status) ?>';
656
  </script>
657
  <?php
658
  exit;
659
  }
660
- }
661
- }
662
- }
663
 
664
  $default_folders = get_option('default_folders');
665
- $default_folders = (empty($default_folders) || !is_array($default_folders))?array():$default_folders;
666
 
667
  $status = 1;
668
- if(isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
669
  $type = self::get_custom_post_type($typenow);
670
- if($default_folders[$typenow] != -1) {
671
  $term = get_term_by('slug', $default_folders[$typenow], $type);
672
  if (empty($term) || !is_object($term)) {
673
  $status = 0;
@@ -676,7 +929,8 @@ class WCP_Folders
676
  } else {
677
  $status = 0;
678
  }
679
- if($status) {
 
680
  if ($typenow == "attachment") {
681
  if (!isset($_REQUEST['media_folder'])) {
682
  if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
@@ -689,28 +943,41 @@ class WCP_Folders
689
  }
690
  }
691
  } else {
692
- $search = "";
693
- if (isset($_GET['s']) && !empty($_GET['s'])) {
694
- $search = esc_attr($_GET['s']);
 
 
695
  }
 
696
  $post_type = self::get_custom_post_type($typenow);
697
  if (!isset($_REQUEST[$post_type])) {
698
  if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
699
  ?>
700
  <script>
701
- window.location = '<?php echo admin_url("edit.php?post_type=".$typenow)."&".esc_attr($post_type)."=".esc_attr($default_folders[$typenow])."&s=".esc_attr($search) ?>';
702
  </script>
703
  <?php
704
  exit;
705
  }
706
  }
707
- }
708
- }
709
- }
710
- }
 
 
711
 
712
- public function folder_update_status() {
713
- $response = [];
 
 
 
 
 
 
 
 
714
  $response['status'] = 0;
715
  $nonce = filter_input(INPUT_POST, 'nonce');
716
  if (!empty($nonce) && wp_verify_nonce($nonce, 'folder_update_status')) {
@@ -720,7 +987,7 @@ class WCP_Folders
720
  if ($status == 1) {
721
  $email = sanitize_email($email);
722
 
723
- $apiURL = "https://premioapps.com/premio/signup/index.php?plugin=folders&email=".$email;
724
 
725
  $apiParams = [
726
  'plugin' => 'folders',
@@ -740,87 +1007,120 @@ class WCP_Folders
740
 
741
  echo json_encode($response);
742
  die;
743
- }
744
 
 
 
 
 
 
 
 
 
 
 
745
  public function add_attachment_category($post_ID)
746
  {
747
- if(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
748
- $folder_id = isset($_REQUEST["folder_for_media"]) ? $_REQUEST["folder_for_media"] : null;
 
 
 
 
749
  if ($folder_id !== null) {
750
- $folder_id = (int)$folder_id;
751
  $folder_id = self::sanitize_options($folder_id, "int");
752
  if ($folder_id > 0) {
753
  $post_type = self::get_custom_post_type("attachment");
754
- $term = get_term($folder_id);
755
- if(!empty($term) && isset($term->slug)) {
756
- wp_set_object_terms($post_ID, $term->slug, $post_type );
757
-
758
- $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
759
- if($trash_folders === false) {
760
- $trash_folders = array();
761
- $initial_trash_folders = array();
762
- }
763
-
764
- if(isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
765
- unset($trash_folders[$term->term_taxonomy_id]);
766
- }
767
-
768
- if($initial_trash_folders != $trash_folders) {
769
- delete_transient("premio_folders_without_trash");
770
- set_transient("premio_folders_without_trash", $trash_folders, 3*DAY_IN_SECONDS);
771
- }
772
  }
773
- }
774
- }
775
- }
776
- }
 
 
777
 
778
- public function show_dropdown_on_media_screen() {
779
- if(self::is_for_this_post_type('attachment')) {
 
 
 
 
 
 
 
 
780
  $post_type = self::get_custom_post_type('attachment');
781
  global $typenow, $current_screen;
782
- /* Free/Pro Class name change */
783
- if(!class_exists('WCP_Tree')) {
784
- $files = array(
785
- 'WCP_Tree' => WCP_DS . "includes" . WCP_DS . "tree.class.php"
786
- );
787
 
788
  foreach ($files as $file) {
789
- if (file_exists(dirname(dirname(__FILE__)) . $file)) {
790
- include_once dirname(dirname(__FILE__)) . $file;
791
  }
792
  }
793
  }
794
- /* Free/Pro Class name change */
 
795
  $options = WCP_Tree::get_folder_option_data($post_type);?>
796
  <p class="attachments-category"><?php esc_html_e("Select a folder (Optional)", 'folders'); ?></p>
797
  <p class="attachments-category"><?php esc_html_e("First select the folder, and then upload the files", 'folders'); ?><br/></p>
798
  <p>
799
  <?php
800
- $request = $_SERVER['REQUEST_URI'];
801
  $request = strpos($request, "post.php");
802
  ?>
803
  <select name="folder_for_media" class="folder_for_media">
804
  <option value="-1">- <?php esc_html_e('Unassigned', 'folders'); ?></option>
805
- <?php echo $options ?>
806
- <?php if(($typenow == "attachment" && isset($current_screen->base) && $current_screen->base == "upload") || ($request !== false) || self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {?>
807
  <option value="add-folder"><?php esc_html_e('+ Create a New Folder', 'folders'); ?></option>
808
  <?php } ?>
809
  </select>
810
  </p>
811
  <?php
812
- }
813
- }
 
 
814
 
 
 
 
 
 
 
 
815
  public function wcp_hide_folders()
816
  {
817
- $response = array();
818
- $response['status'] = 0;
819
- $response['error'] = 0;
820
- $response['data'] = array();
821
  $response['message'] = "";
822
- $postData = filter_input_array(INPUT_POST);
823
- $errorCounter = 0;
824
 
825
  if (!isset($postData['status']) || empty($postData['status'])) {
826
  $response['message'] = esc_html__("Your request is not valid", 'folders');
@@ -838,33 +1138,44 @@ class WCP_Folders
838
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
839
  $errorCounter++;
840
  } else {
841
- $type = self::sanitize_options($postData['type']);
842
  $nonce = self::sanitize_options($postData['nonce']);
843
- if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
844
  $response['message'] = esc_html__("Your request is not valid", 'folders');
845
  $errorCounter++;
846
  }
847
- }
 
848
  if ($errorCounter == 0) {
849
- $type = self::sanitize_options($postData['type']);
850
- $status = self::sanitize_options($postData['status']);
851
- $optionName = "wcp_folder_display_status_" . $type;
852
  update_option($optionName, $status);
853
  $response['status'] = 1;
854
  }
 
855
  echo json_encode($response);
856
  wp_die();
857
- }
858
 
 
 
 
 
 
 
 
 
 
 
859
  public function wcp_change_folder_display_status()
860
  {
861
- $response = array();
862
- $response['status'] = 0;
863
- $response['error'] = 0;
864
- $response['data'] = array();
865
  $response['message'] = "";
866
- $postData = filter_input_array(INPUT_POST);
867
- $errorCounter = 0;
868
  if (!isset($postData['status']) || empty($postData['status'])) {
869
  $response['message'] = esc_html__("Your request is not valid", 'folders');
870
  $errorCounter++;
@@ -881,84 +1192,44 @@ class WCP_Folders
881
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
882
  $errorCounter++;
883
  } else {
884
- $type = self::sanitize_options($postData['type']);
885
  $nonce = self::sanitize_options($postData['nonce']);
886
- if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
887
  $response['message'] = esc_html__("Your request is not valid", 'folders');
888
  $errorCounter++;
889
  }
890
- }
 
891
  if ($errorCounter == 0) {
892
- $type = self::sanitize_options($postData['type']);
893
- $width = self::sanitize_options($postData['status']);
894
- $optionName = "wcp_dynamic_display_status_" . $type;
895
  update_option($optionName, $width);
896
  $response['status'] = 1;
897
  }
 
898
  echo json_encode($response);
899
  wp_die();
900
- }
901
-
902
- public function premio_check_for_other_folders() {
903
- $response = array();
904
- $response['status'] = 0;
905
- $response['error'] = 0;
906
- $response['data'] = array();
907
- $response['message'] = "";
908
- $postData = filter_input_array(INPUT_POST);
909
- $errorCounter = 0;
910
- if (!isset($postData['post_id']) || empty($postData['post_id'])) {
911
- $response['message'] = esc_html__("Your request is not valid", 'folders');
912
- $errorCounter++;
913
- } else if (!isset($postData['type']) || empty($postData['type'])) {
914
- $response['message'] = esc_html__("Your request is not valid", 'folders');
915
- $errorCounter++;
916
- } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
917
- $response['message'] = esc_html__("Your request is not valid", 'folders');
918
- $errorCounter++;
919
- } else if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['type'])) {
920
- $response['message'] = esc_html__("Your request is not valid", 'folders');
921
- $errorCounter++;
922
- } else if(!current_user_can("manage_categories")) {
923
- $response['message'] = esc_html__("Your request is not valid", 'folders');
924
- $errorCounter++;
925
- }
926
- if ($errorCounter == 0) {
927
- $folderUndoSettings = array();
928
- $type = self::sanitize_options($postData['type']);
929
- $post_id = self::sanitize_options($postData['post_id']);
930
-
931
- $post_id = explode(",", $post_id);
932
-
933
- $taxonomy = self::get_custom_post_type($type);
934
-
935
- foreach ($post_id as $id) {
936
- $terms = get_the_terms($id, $taxonomy);
937
- if(!empty($terms) && is_array($terms)) {
938
- foreach($terms as $term) {
939
- if($term->term_id != $postData['taxonomy']) {
940
- $response['status'] = -1;
941
- $response['data']['post_id'] = $postData['post_id'];
942
- echo json_encode($response);
943
- wp_die();
944
- }
945
- }
946
- }
947
- }
948
- $this->wcp_remove_post_folder();
949
- }
950
- echo json_encode($response);
951
- wp_die();
952
- }
953
-
954
- public function wcp_remove_post_folder() {
955
- $response = array();
956
- $response['status'] = 0;
957
- $response['error'] = 0;
958
- $response['data'] = array();
959
  $response['message'] = "";
960
- $postData = filter_input_array(INPUT_POST);
961
- $errorCounter = 0;
962
  if (!isset($postData['post_id']) || empty($postData['post_id'])) {
963
  $response['message'] = esc_html__("Your request is not valid", 'folders');
964
  $errorCounter++;
@@ -968,103 +1239,193 @@ class WCP_Folders
968
  } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
969
  $response['message'] = esc_html__("Your request is not valid", 'folders');
970
  $errorCounter++;
971
- } else if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['type'])) {
972
  $response['message'] = esc_html__("Your request is not valid", 'folders');
973
  $errorCounter++;
974
- } else if(!current_user_can("manage_categories")) {
975
  $response['message'] = esc_html__("Your request is not valid", 'folders');
976
  $errorCounter++;
977
  }
 
978
  if ($errorCounter == 0) {
979
- $folderUndoSettings = array();
980
- $type = self::sanitize_options($postData['type']);
981
  $post_id = self::sanitize_options($postData['post_id']);
982
 
983
  $post_id = explode(",", $post_id);
984
 
985
  $taxonomy = self::get_custom_post_type($type);
986
 
987
- $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
988
- if($trash_folders === false) {
989
- $trash_folders = array();
990
- $initial_trash_folders = array();
991
- }
992
-
993
- foreach($post_id as $id) {
994
- if(!empty($id) && is_numeric($id) && $id > 0) {
995
- $terms = get_the_terms($id, $taxonomy);
996
- $post_terms = array(
997
- 'post_id' => $id,
998
- 'terms' => $terms
999
- );
1000
- if(!empty($terms) && count($terms)>0) {
1001
- foreach($terms as $term) {
1002
- if(isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
1003
- unset($trash_folders[$term->term_taxonomy_id]);
1004
- }
1005
- }
1006
- }
1007
- $folderUndoSettings[] = $post_terms;
1008
- if(isset($postData['remove_from']) && $postData['remove_from'] == "current" && isset($postData['remove_from']) && $postData['remove_from'] == "current" && isset($postData['active_folder']) && is_numeric($postData['active_folder'])) {
1009
- wp_remove_object_terms($id, intval($postData['active_folder']), $taxonomy);
1010
- } else {
1011
- wp_delete_object_term_relationships($id, $taxonomy);
1012
- }
1013
  }
1014
  }
1015
- delete_transient("folder_undo_settings");
1016
- set_transient("folder_undo_settings", $folderUndoSettings, DAY_IN_SECONDS);
1017
 
1018
- if($initial_trash_folders != $trash_folders) {
1019
- delete_transient("premio_folders_without_trash");
1020
- set_transient("premio_folders_without_trash", $trash_folders, 3*DAY_IN_SECONDS);
1021
- }
1022
- $response['status'] = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1023
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1024
  echo json_encode($response);
1025
  wp_die();
1026
- }
1027
 
1028
- public function filter_record_list($query) {
 
 
 
 
 
 
 
 
 
 
 
1029
  global $typenow;
1030
 
1031
- if($typenow == "attachment") {
1032
  return;
1033
  }
1034
 
1035
- if(!self::is_for_this_post_type($typenow)) {
1036
  return $query;
1037
  }
1038
 
1039
  $taxonomy = self::get_custom_post_type($typenow);
1040
 
1041
- if ( ! isset( $query->query['post_type'] ) ) {
1042
  return $query;
1043
  }
1044
 
1045
- if ( ! isset( $_REQUEST[$taxonomy] ) ) {
1046
  return $query;
1047
  }
1048
 
1049
- $term = sanitize_text_field( $_REQUEST[$taxonomy] );
1050
- if ( $term != "-1" ) {
1051
  return $query;
1052
  }
1053
 
1054
- unset( $query->query_vars[$taxonomy] );
1055
 
1056
- $tax_query = array(
1057
- 'taxonomy' => $taxonomy,
1058
- 'operator' => 'NOT EXISTS',
1059
- );
1060
 
1061
- $query->set( 'tax_query', array( $tax_query ) );
1062
- $query->tax_query = new WP_Tax_Query( array( $tax_query ) );
1063
 
1064
  return $query;
1065
- }
1066
 
1067
- public function wcp_get_default_list() {
 
 
 
 
 
 
 
 
 
 
 
1068
 
1069
  $postData = filter_input_array(INPUT_POST);
1070
 
@@ -1078,17 +1439,27 @@ class WCP_Folders
1078
 
1079
  $taxonomies = self::get_terms_hierarchical($post_type);
1080
 
1081
- $response = array(
1082
- 'status' => 1,
1083
  'total_items' => $ttpsts,
1084
- 'taxonomies' => $taxonomies,
1085
- 'empty_items' => $empty_items
1086
- );
1087
  echo json_encode($response);
1088
  wp_die();
1089
- }
1090
 
1091
- function get_folders_default_list() {
 
 
 
 
 
 
 
 
 
 
 
1092
  $postData = filter_input_array(INPUT_POST);
1093
 
1094
  $post_type = $postData['type'];
@@ -1101,68 +1472,101 @@ class WCP_Folders
1101
 
1102
  $taxonomies = self::get_terms_hierarchical($post_type);
1103
 
1104
- $response = array(
1105
- 'status' => 1,
1106
  'total_items' => $ttpsts,
1107
  'empty_items' => $empty_items,
1108
- 'taxonomies' => $taxonomies
1109
- );
1110
  echo json_encode($response);
1111
  die;
1112
 
1113
- }
 
1114
 
1115
- function save_media_terms( $post_id ) {
1116
- if ( wp_is_post_revision( $post_id ) ) {
 
 
 
 
 
 
 
 
1117
  return;
1118
  }
 
1119
  $post = get_post($post_id);
1120
- if($post->post_type !== 'attachment') {
1121
  return;
1122
  }
1123
- $post_type = self::get_custom_post_type('attachment');
1124
- $selected_folder = get_option("selected_{$post_type}_folder");
1125
- if($selected_folder != null && !empty($selected_folder)) {
 
1126
  $terms = get_term($selected_folder);
1127
- if(!empty($terms) && isset($terms->term_id)) {
1128
  wp_set_post_terms($post_id, $terms->term_id, $post_type, false);
1129
  }
1130
  }
1131
- }
1132
 
1133
- public function filter_attachments_grid( $args ) {
 
 
 
 
 
 
 
 
 
 
 
1134
  $taxonomy = 'media_folder';
1135
- if ( ! isset( $args[ $taxonomy ] ) ) {
1136
  return $args;
1137
  }
1138
- $term = sanitize_text_field( $args[ $taxonomy ] );
1139
- if ( $term != "-1" ) {
 
1140
  return $args;
1141
  }
1142
- unset( $args[ $taxonomy ] );
1143
- $args['tax_query'] = array(
1144
- array(
1145
- 'taxonomy' => $taxonomy,
1146
- 'operator' => 'NOT EXISTS',
1147
- ),
1148
- );
1149
- $args = apply_filters( 'media_library_organizer_media_filter_attachments_grid', $args );
 
1150
  return $args;
1151
- }
1152
 
1153
- public function get_tempt_posts($post_type = "")
 
 
 
 
 
 
 
 
 
 
1154
  {
1155
  global $wpdb;
1156
 
1157
- $post_table = $wpdb->prefix."posts";
1158
- $term_table = $wpdb->prefix."term_relationships";
1159
  $term_taxonomy_table = $wpdb->prefix."term_taxonomy";
1160
- $taxonomy = self::get_custom_post_type($post_type);
1161
  $tlrcds = null;
1162
- if(has_filter("premio_folder_un_categorized_items")) {
1163
  $tlrcds = apply_filters("premio_folder_un_categorized_items", $post_type, $taxonomy);
1164
  }
1165
- if($tlrcds === null) {
 
1166
  if ($post_type != "attachment") {
1167
  $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND (
1168
  NOT EXISTS (
@@ -1185,46 +1589,76 @@ class WCP_Folders
1185
  AND {$term_table}.object_id = {$post_table}.ID
1186
  )
1187
  ) AND {$post_table}.post_type = '%s' AND {$post_table}.post_status = 'inherit'";
1188
- }
1189
 
1190
  $query = $wpdb->prepare($query, $taxonomy, $post_type);
1191
 
1192
  $tlrcds = $wpdb->get_var($query);
1193
- }
1194
 
1195
- if(!empty($tlrcds)) {
1196
  return $tlrcds;
1197
  } else {
1198
  return 0;
1199
  }
1200
- }
1201
 
1202
- public function output_backbone_view_filters() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1203
 
1204
  global $typenow, $current_screen;
1205
- $isAjax = (defined('DOING_AJAX') && DOING_AJAX)?1:0;
1206
- $options = get_option('folders_settings');
1207
- $options = (empty($options) || !is_array($options))?array():$options;
1208
  $last_status = get_option("last_folder_status_for".$typenow);
1209
- if(!$isAjax && (in_array($typenow, $options) || !empty($last_status)) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) {
1210
-
1211
  $default_folders = get_option('default_folders');
1212
- $default_folders = (empty($default_folders) || !is_array($default_folders))?array():$default_folders;
1213
 
1214
- if(!empty($last_status)) {
1215
  $status = 1;
1216
- if($last_status != "-1" && $last_status != "all") {
1217
  $type = self::get_custom_post_type($typenow);
1218
  $term = get_term_by('slug', $last_status, $type);
1219
  if (empty($term) || !is_object($term)) {
1220
  $status = 0;
1221
  }
1222
  }
 
1223
  delete_option("last_folder_status_for".$typenow);
1224
- if($last_status == "all") {
1225
  $last_status = "";
1226
  }
1227
- if($status) {
 
1228
  if ($typenow == "attachment") {
1229
  if (!isset($_REQUEST['media_folder'])) {
1230
  ?>
@@ -1236,12 +1670,12 @@ class WCP_Folders
1236
  }
1237
  }
1238
  }
1239
- }
1240
 
1241
  $status = 1;
1242
- if(isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
1243
  $type = self::get_custom_post_type($typenow);
1244
- if($default_folders[$typenow] != -1) {
1245
  $term = get_term_by('slug', $default_folders[$typenow], $type);
1246
  if (empty($term) || !is_object($term)) {
1247
  $status = 0;
@@ -1250,7 +1684,8 @@ class WCP_Folders
1250
  } else {
1251
  $status = 0;
1252
  }
1253
- if($status) {
 
1254
  if ($typenow == "attachment") {
1255
  if (!isset($_REQUEST['media_folder'])) {
1256
  if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
@@ -1264,386 +1699,451 @@ class WCP_Folders
1264
  }
1265
  }
1266
  }
1267
- }
1268
 
1269
- if(!(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media'))) {
1270
  return;
1271
  }
1272
 
1273
  if ($typenow == "attachment") {
1274
- /* Free/Pro URL Change */
1275
  global $typenow;
1276
  $is_active = 1;
1277
- $folders = -1;
1278
-
1279
- $hasStars = self::check_for_setting("has_stars", "general");
1280
- $hasChild = self::check_for_setting("has_child", "general");
1281
- $hasChild = empty($hasChild)?0:1;
1282
- $hasStars = empty($hasStars)?0:1;
1283
- /* Free/Pro URL Change */
1284
- wp_enqueue_script( 'folders-media', WCP_FOLDER_URL.'assets/js/media.js', array( 'media-editor', 'media-views' ), WCP_FOLDER_VERSION, true );
1285
- wp_localize_script( 'folders-media', 'folders_media_options', array(
1286
- 'terms' => self::get_terms_hierarchical('media_folder'),
1287
- 'taxonomy' => get_taxonomy('media_folder'),
1288
- 'ajax_url' => admin_url("admin-ajax.php"),
1289
- 'activate_url' => $this->getFoldersUpgradeURL(),
1290
- 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
1291
- 'is_key_active' => $is_active,
1292
- 'hasStars' => $hasStars,
1293
- 'hasChildren' => $hasChild
1294
- ));
1295
- /* Free/Pro URL Change */
1296
- wp_enqueue_style( 'folders-media', WCP_FOLDER_URL . 'assets/css/media.css' , array(), WCP_FOLDER_VERSION);
1297
- } else if(!self::is_active_for_screen() && self::is_for_this_post_type('attachment')) {
1298
- /* Free/Pro URL Change */
 
 
 
 
1299
  global $typenow;
1300
  global $current_screen;
1301
- // echo "<pre>"; print_r($current_screen); die;
1302
- if(!isset($current_screen->base) || $current_screen->base != "plugins") {
1303
  $is_active = 1;
1304
- $folders = -1;
1305
 
1306
  remove_filter("terms_clauses", "TO_apply_order_filter");
1307
 
1308
- /* Free/Pro URL Change */
1309
  $is_rtl = 0;
1310
  if (function_exists('is_rtl') && is_rtl()) {
1311
  $is_rtl = 1;
1312
  }
 
1313
  $can_manage_folder = current_user_can("manage_categories") ? 1 : 0;
1314
- $width = 275;
1315
  $taxonomy_status = 0;
1316
  $selected_taxonomy = "";
1317
- $show_in_page = false;
1318
- $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
1319
 
1320
  $taxonomies = self::get_terms_hierarchical('media_folder');
1321
 
1322
- $folder_settings = array();
1323
- foreach($taxonomies as $taxonomy) {
1324
- $is_sticky = get_term_meta($taxonomy->term_id, "is_folder_sticky", true);
1325
- $is_high = get_term_meta($taxonomy->term_id, "is_highlighted", true);
1326
- $folder_settings[] = array(
1327
- 'folder_id' => $taxonomy->term_id,
1328
- 'is_sticky' => intval($is_sticky),
1329
- 'is_high' => intval($is_high),
1330
- 'nonce' => wp_create_nonce('wcp_folder_term_'.$taxonomy->term_id),
1331
- 'is_deleted' => 0,
1332
- 'slug' => $taxonomy->slug,
1333
- 'folder_count' => intval($taxonomy->trash_count)
1334
- );
1335
  }
1336
 
1337
- $hasStars = self::check_for_setting("has_stars", "general");
1338
- $hasChild = self::check_for_setting("has_child", "general");
1339
- $hasChild = empty($hasChild)?0:1;
1340
- $hasStars = empty($hasStars)?0:1;
1341
 
1342
- $customize_folders = get_option('customize_folders');
1343
- $use_folder_undo = !isset($customize_folders['use_folder_undo'])?"yes":$customize_folders['use_folder_undo'];
1344
- $defaultTimeout = !isset($customize_folders['default_timeout'])?5:intval($customize_folders['default_timeout']);
1345
- if(empty($defaultTimeout) || !is_numeric($defaultTimeout) || $defaultTimeout < 0) {
1346
- $defaultTimeout = 5;
1347
- }
1348
- $defaultTimeout = $defaultTimeout*1000;
 
1349
 
1350
  $default_folders = get_option("default_folders");
1351
- $default_folder = "";
1352
- if(isset($default_folders["attachment"])) {
1353
  $default_folder = $default_folders["attachment"];
1354
  }
1355
- $use_shortcuts = !isset($customize_folders['use_shortcuts'])?"yes":$customize_folders['use_shortcuts'];
1356
-
1357
- wp_dequeue_script("jquery-jstree"); // CMS Tree Page View Conflict
1358
- wp_enqueue_script('folders-tree', WCP_FOLDER_URL . 'assets/js/jstree.min.js', array(), WCP_FOLDER_VERSION);
1359
- wp_enqueue_script('wcp-folders-mcustomscrollbar', WCP_FOLDER_URL . 'assets/js/jquery.mcustomscrollbar.min.js', array(), WCP_FOLDER_VERSION);
1360
- wp_enqueue_script('wcp-folders-media', WCP_FOLDER_URL . 'assets/js/page-post-media.min.js', array('jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION, true);
1361
- wp_enqueue_script('wcp-jquery-touch', plugin_dir_url(dirname(__FILE__)) . 'assets/js/jquery.ui.touch-punch.min.js', array('jquery'), WCP_FOLDER_VERSION);
1362
- wp_localize_script('wcp-folders-media', 'folders_media_options', array(
1363
- 'terms' => $taxonomies,
1364
- 'taxonomy' => get_taxonomy('media_folder'),
1365
- 'ajax_url' => admin_url("admin-ajax.php"),
1366
- 'media_page_url' => admin_url("upload.php?media_folder="),
1367
- 'activate_url' => $this->getFoldersUpgradeURL(),
1368
- 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
1369
- 'is_key_active' => $is_active,
1370
- 'folders' => $folders,
1371
- 'upgrade_url' => $this->getFoldersUpgradeURL(),
1372
- 'post_type' => 'attachment',
1373
- 'page_url' => $admin_url,
1374
- 'current_url' => "",
1375
- 'ajax_image' => plugin_dir_url(dirname(__FILE__)) . "assets/images/ajax-loader.gif",
1376
- 'register_url' => "",
1377
- 'isRTL' => $is_rtl,
1378
- 'can_manage_folder' => $can_manage_folder,
1379
- 'folder_width' => $width,
1380
- 'taxonomy_status' => $taxonomy_status,
1381
- 'selected_taxonomy' => $selected_taxonomy,
1382
- 'show_in_page' => $show_in_page,
1383
- 'svg_file' => WCP_FOLDER_URL . 'assets/images/pin.png',
1384
- 'folder_settings' => $folder_settings,
1385
- 'hasStars' => $hasStars,
1386
- 'hasChildren' => $hasChild,
1387
- 'useFolderUndo' => $use_folder_undo,
1388
- 'defaultTimeout' => $defaultTimeout,
1389
- 'default_folder' => $default_folder,
1390
- 'use_shortcuts' => $use_shortcuts
1391
- ));
1392
- /* Free/Pro URL Change */
1393
- wp_enqueue_style('folders-jstree', WCP_FOLDER_URL . 'assets/css/jstree.min.css', array(), WCP_FOLDER_VERSION);
1394
- wp_enqueue_style('wcp-folders-mcustomscrollbar', WCP_FOLDER_URL . 'assets/css/jquery.mcustomscrollbar.min.css', array(),WCP_FOLDER_VERSION);
1395
- wp_enqueue_style('folder-folders', WCP_FOLDER_URL . 'assets/css/folders.min.css', array(), WCP_FOLDER_VERSION);
1396
- wp_enqueue_style('folders-media', WCP_FOLDER_URL . 'assets/css/page-post-media.min.css', array(), WCP_FOLDER_VERSION);
1397
- wp_enqueue_style('folder-icon', WCP_FOLDER_URL . 'assets/css/folder-icon.css', array(), WCP_FOLDER_VERSION);
1398
- $width = 275;
1399
- $string = "";
 
 
 
 
 
 
1400
  $css_text = "";
1401
  $customize_folders = get_option('customize_folders');
1402
  if (!isset($customize_folders['new_folder_color']) || empty($customize_folders['new_folder_color'])) {
1403
- $customize_folders['new_folder_color'] = "#FA166B";
1404
  }
1405
- $css_text .= ".media-frame a.add-new-folder { background-color: " . esc_attr($customize_folders['new_folder_color']) . "; border-color: " . esc_attr($customize_folders['new_folder_color']) . "}";
1406
- $css_text .= ".wcp-hide-show-buttons .toggle-buttons { background-color: " . esc_attr($customize_folders['new_folder_color']) . "; }";
1407
- $css_text .= ".folders-toggle-button span { background-color: " . esc_attr($customize_folders['new_folder_color']) . "; }";
1408
- $css_text .= ".ui-resizable-handle.ui-resizable-e:before, .ui-resizable-handle.ui-resizable-w:before {border-color: " . esc_attr($customize_folders['new_folder_color']) . " !important}";
 
1409
 
1410
  if (!isset($customize_folders['folder_bg_color']) || empty($customize_folders['folder_bg_color'])) {
1411
- $customize_folders['folder_bg_color'] = "#FA166B";
1412
  }
1413
- $rgbColor = self::hexToRgb($customize_folders['folder_bg_color']);
1414
- $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked), body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked):hover { background: rgba(".$rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08) !important; color: #333333;}";
1415
- $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked, body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked:not(.jstree-clicked):focus, #custom-scroll-menu .jstree-clicked, #custom-scroll-menu .jstree-clicked:hover { background: ".$customize_folders['folder_bg_color']." !important; color: #ffffff !important; }";
1416
- $css_text .= "#custom-scroll-menu .jstree-hovered.wcp-drop-hover, #custom-scroll-menu .jstree-hovered.wcp-drop-hover:hover, #custom-scroll-menu .jstree-clicked.wcp-drop-hover, #custom-scroll-menu .jstree-clicked.wcp-drop-hover:hover, body #custom-scroll-menu *.drag-in >, body #custom-scroll-menu *.drag-in > a:hover { background: ".$customize_folders['folder_bg_color']." !important; color: #ffffff !important; }";
1417
- $css_text .= ".drag-bot > a { border-bottom: solid 2px ".$customize_folders['folder_bg_color']."}";
1418
- $css_text .= ".drag-up > a { border-top: solid 2px ".$customize_folders['folder_bg_color']."}";
1419
- $css_text .= "body:not(.no-hover-css) #custom-scroll-menu *.drag-in > a.jstree-hovered, body:not(.no-hover-css) #custom-scroll-menu *.drag-in > a.jstree-hovered:hover {background: ".$customize_folders['folder_bg_color']." !important; color: #fff !important;}";
1420
- $css_text .= ".orange-bg > span, .jstree-clicked, .header-posts a.active-item, .un-categorised-items.active-item, .sticky-folders ul li a.active-item { background-color: " . esc_attr($customize_folders['folder_bg_color']) . " !important; color: #ffffff !important; }";
 
1421
  $css_text .= "body:not(.no-hover-css) .wcp-container .route .title:hover, body:not(.no-hover-css) .header-posts a:hover, body:not(.no-hover-css) .un-categorised-items:hover, body:not(.no-hover-css) .sticky-folders ul li a:hover { background: rgba(".esc_attr($rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08")."); color: #333333;}";
1422
- //$css_text .= "body:not(.no-hover-css) .wcp-container .route .title:hover, .header-posts a:hover, .un-categorised-items.active-item, .un-categorised-items:hover, .sticky-folders ul li a:hover {background: rgba(" . esc_attr($rgbColor['r'] . "," . $rgbColor['g'] . "," . $rgbColor['b'] . ", 0.08") . "); color:#444444;}";
1423
- $css_text .= ".wcp-drop-hover {background-color: " . esc_attr($customize_folders['folder_bg_color']) . " !important; color: #ffffff; }";
1424
- $css_text .= "#custom-menu .route .nav-icon .wcp-icon {color: " . esc_attr($customize_folders['folder_bg_color']) . " !important;}";
1425
- $css_text .= ".mCS-3d.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar {background-color: " . esc_attr($customize_folders['folder_bg_color']) . " !important;}";
1426
- $css_text .= "body:not(.no-hover-css) .jstree-hovered {background: rgba(" . esc_attr($rgbColor['r'] . "," . $rgbColor['g'] . "," . $rgbColor['b'] . ", 0.08") . ") }";
1427
- $css_text .= ".jstree-default .jstree-clicked { background-color:" . esc_attr($customize_folders['folder_bg_color']) . "}";
1428
- $css_text .= ".jstree-node.drag-in > a.jstree-anchor.jstree-hovered { background-color: " . esc_attr($customize_folders['folder_bg_color']) . "; color: #ffffff; }";
1429
- $css_text .= "#custom-scroll-menu .jstree-hovered:not(.jstree-clicked) .pfolder-folder-close { color: " . esc_attr($customize_folders['folder_bg_color']) . "; }";
1430
 
1431
  if (!isset($customize_folders['bulk_organize_button_color']) || empty($customize_folders['bulk_organize_button_color'])) {
1432
- $customize_folders['bulk_organize_button_color'] = "#FA166B";
1433
  }
1434
- $css_text .= "button.button.organize-button { background-color: " . esc_attr($customize_folders['bulk_organize_button_color']) . "; border-color: " . esc_attr($customize_folders['bulk_organize_button_color']) . "; }";
1435
- $css_text .= "button.button.organize-button:hover { background-color: " . esc_attr($customize_folders['bulk_organize_button_color']) . "; border-color: " . esc_attr($customize_folders['bulk_organize_button_color']) . "; }";
 
1436
 
1437
  $font_family = "";
1438
  if (isset($customize_folders['folder_font']) && !empty($customize_folders['folder_font'])) {
1439
  $folder_fonts = self::get_font_list();
1440
- $font_family = $customize_folders['folder_font'];
1441
  if (isset($folder_fonts[$font_family])) {
1442
- $css_text .= ".wcp-container, .folder-popup-form { font-family: " . esc_attr($font_family) . " !important; }";
1443
  }
 
1444
  if ($folder_fonts[$font_family] == "Default") {
1445
  $font_family = "";
1446
  }
1447
  }
 
1448
  if (isset($customize_folders['folder_size']) && !empty($customize_folders['folder_size'])) {
1449
- $css_text .= ".wcp-container .route span.title-text, .header-posts a, .un-categorised-items a, .sticky-title { font-size: " . esc_attr($customize_folders['folder_size']) . "px; }";
1450
  }
 
1451
  if (!empty($font_family)) {
1452
- wp_enqueue_style('custom-google-fonts', 'https://fonts.googleapis.com/css?family=' . urlencode($font_family), false);
1453
  }
 
1454
  wp_add_inline_style('folders-media', $css_text);
1455
- }
1456
- }
1457
- }
1458
-
1459
- public function get_terms_hierarchical( $taxonomy ) {
1460
- // $terms = get_terms( array(
1461
- // 'taxonomy' => $taxonomy,
1462
- // 'hide_empty' => false,
1463
- // 'parent' => 0,
1464
- // 'orderby' => 'meta_value_num',
1465
- // 'order' => 'ASC',
1466
- // 'update_count_callback' => '_update_generic_term_count',
1467
- // 'meta_query' => [[
1468
- // 'key' => 'wcp_custom_order',
1469
- // 'type' => 'NUMERIC',
1470
- // ]]
1471
- // ) );
1472
- //
1473
- // if ( empty( $terms ) ) {
1474
- // return false;
1475
- // }
1476
- //
1477
- // $hierarchy = _get_term_hierarchy( $taxonomy );
1478
- //
1479
- // $hierarchical_terms = array();
1480
- // if(!empty($terms)) {
1481
- // foreach ($terms as $term) {
1482
- // if(isset($term->term_id)) {
1483
- // $hierarchical_terms[] = $term;
1484
- // $hierarchical_terms = self::add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $term->term_id, 1);
1485
- // }
1486
- // }
1487
- // }
1488
- //
1489
- // return $hierarchical_terms;
1490
- $terms = get_terms( array(
1491
- 'taxonomy' => $taxonomy,
1492
- 'hide_empty' => false,
1493
- 'parent' => 0,
1494
- 'orderby' => 'meta_value_num',
1495
- 'order' => 'ASC',
1496
- 'hierarchical' => false,
1497
- 'update_count_callback' => '_update_generic_term_count',
1498
- 'meta_query' => [[
1499
- 'key' => 'wcp_custom_order',
1500
- 'type' => 'NUMERIC',
1501
- ]]
1502
- ));
1503
- $hierarchical_terms = array();
1504
- if(!empty($terms)) {
1505
  foreach ($terms as $term) {
1506
- if(!empty($term) && isset($term->term_id)) {
1507
- $term->term_name = $term->name;
1508
  $hierarchical_terms[] = $term;
1509
- $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, "-");
1510
  }
1511
  }
1512
  }
 
1513
  return $hierarchical_terms;
1514
- }
1515
-
1516
- public static function get_child_terms($taxonomy, $hierarchical_terms, $term_id, $separator = "-") {
1517
- $terms = get_terms( array(
1518
- 'taxonomy' => $taxonomy,
1519
- 'hide_empty' => false,
1520
- 'parent' => $term_id,
1521
- 'orderby' => 'meta_value_num',
1522
- 'order' => 'ASC',
1523
- 'hierarchical' => false,
1524
- 'update_count_callback' => '_update_generic_term_count',
1525
- 'meta_query' => [[
1526
- 'key' => 'wcp_custom_order',
1527
- 'type' => 'NUMERIC',
1528
- ]]
1529
- ));
1530
- if(!empty($terms)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1531
  foreach ($terms as $term) {
1532
- if(isset($term->name)) {
1533
- $term->name = $separator . " " . $term->name;
1534
- $term->term_name = trim($term->name, "-");
1535
  $hierarchical_terms[] = $term;
1536
- $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, $separator . "-");
1537
  }
1538
  }
1539
  }
1540
 
1541
  return $hierarchical_terms;
1542
- }
1543
 
1544
- public function update_folder_new_term_relationships($object_id = "", $term_ids = array(), $taxonomy = "") {
1545
- if(is_array($term_ids) && !empty($term_ids)) {
1546
- $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
1547
- if($trash_folders === false) {
1548
- $trash_folders = array();
1549
- $initial_trash_folders = array();
1550
- }
 
 
 
 
 
 
 
 
 
 
 
1551
 
1552
- foreach($term_ids as $term_id) {
1553
  $term = get_term($term_id, $taxonomy);
1554
- if(isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
1555
- unset($trash_folders[$term->term_taxonomy_id]);
1556
- }
1557
- }
1558
-
1559
- if($initial_trash_folders != $trash_folders) {
1560
- delete_transient("premio_folders_without_trash");
1561
- set_transient("premio_folders_without_trash", $trash_folders, 3*DAY_IN_SECONDS);
1562
- }
1563
- }
1564
- }
1565
-
1566
- public function update_folder_term_relationships($object_id = "", $term_ids = array(), $taxonomy = "") {
1567
- if(is_array($term_ids) && !empty($term_ids)) {
1568
- $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
1569
- if($trash_folders === false) {
1570
- $trash_folders = array();
1571
- $initial_trash_folders = array();
1572
- }
1573
-
1574
- foreach($term_ids as $term_id) {
 
 
 
 
 
 
 
 
 
 
1575
  $term = get_term($term_id, $taxonomy);
1576
- if(isset($term->term_taxonomy_id) && isset($trash_folders[$term_id])) {
1577
- unset($trash_folders[$term->term_taxonomy_id]);
1578
- }
1579
- }
 
 
 
 
 
 
1580
 
1581
- if($initial_trash_folders != $trash_folders) {
1582
- delete_transient("premio_folders_without_trash");
1583
- set_transient("premio_folders_without_trash", $trash_folders, 3*DAY_IN_SECONDS);
1584
- }
1585
- }
1586
- }
1587
 
1588
- private function add_child_terms_recursive( $taxonomy, $hierarchical_terms, $hierarchy, $current_term_id, $current_depth ) {
1589
 
1590
- if ( ! isset( $hierarchy[ $current_term_id ] ) ) {
 
 
 
 
 
 
 
 
 
 
1591
  return $hierarchical_terms;
1592
  }
1593
 
1594
- foreach ( $hierarchy[ $current_term_id ] as $child_term_id ) {
1595
-
1596
- $child_term = get_term( $child_term_id, $taxonomy );
1597
 
1598
- $child_term->name = str_pad( '', $current_depth, '-', STR_PAD_LEFT ) . ' ' . $child_term->name;
1599
 
1600
  $hierarchical_terms[] = $child_term;
1601
 
1602
- $hierarchical_terms = self::add_child_terms_recursive( $taxonomy, $hierarchical_terms, $hierarchy, $child_term_id, ( $current_depth + 1 ) );
1603
  }
1604
 
1605
  return $hierarchical_terms;
1606
- }
1607
 
1608
- public function filter_attachments_list( $query ) {
 
 
 
 
 
 
 
 
 
 
 
1609
 
1610
- if ( ! isset( $query->query['post_type'] ) ) {
1611
  return $query;
1612
  }
1613
 
1614
- if ( is_array( $query->query['post_type'] ) && ! in_array( 'attachment', $query->query['post_type'] ) ) {
1615
  return $query;
1616
  }
1617
- if ( ! is_array( $query->query['post_type'] ) && strpos( $query->query['post_type'], 'attachment' ) === false ) {
 
1618
  return $query;
1619
  }
1620
 
1621
- if ( ! isset( $_REQUEST['media_folder'] ) ) {
1622
  return $query;
1623
  }
1624
 
1625
  $term = sanitize_text_field(wp_unslash($_REQUEST['media_folder']));
1626
- if ( $term != "-1" ) {
1627
  return $query;
1628
  }
1629
 
1630
- unset( $query->query_vars['media_folder'] );
1631
 
1632
- $tax_query = array(
1633
- 'taxonomy' => 'media_folder',
1634
- 'operator' => 'NOT EXISTS',
1635
- );
1636
 
1637
- $query->set( 'tax_query', array( $tax_query ) );
1638
- $query->tax_query = new WP_Tax_Query( array( $tax_query ) );
1639
 
1640
- $query = apply_filters( 'media_library_organizer_media_filter_attachments', $query, $_REQUEST );
1641
 
1642
  return $query;
1643
 
1644
- }
 
1645
 
1646
- public function output_list_table_filters( $post_type, $view_name )
 
 
 
 
 
 
 
1647
  {
1648
  if ($post_type != 'attachment') {
1649
  return;
@@ -1653,172 +2153,206 @@ class WCP_Folders
1653
  return;
1654
  }
1655
 
1656
- if(!self::is_for_this_post_type('attachment')) {
1657
  return;
1658
  }
1659
 
1660
  $current_term = false;
1661
- if ( isset( $_REQUEST['media_folder'] ) ) {
1662
  $current_term = sanitize_text_field($_REQUEST['media_folder']);
1663
  }
1664
 
1665
- wp_dropdown_categories( array(
1666
- 'show_option_all' => esc_html__( 'All Folders', 'folders'),
1667
- 'show_option_none' => esc_html__( '(Unassigned)', 'folders'),
1668
- 'option_none_value' => -1,
1669
- 'orderby' => 'meta_value_num',
1670
- 'order' => 'ASC',
1671
- 'show_count' => true,
1672
- 'hide_empty' => false,
1673
- 'update_count_callback' => '_update_generic_term_count',
1674
- 'echo' => true,
1675
- 'selected' => $current_term,
1676
- 'hierarchical' => true,
1677
- 'name' => 'media_folder',
1678
- 'id' => '',
1679
- 'class' => '',
1680
- 'taxonomy' => 'media_folder',
1681
- 'value_field' => 'slug',
1682
- 'meta_query' => [[
1683
- 'key' => 'wcp_custom_order',
1684
- 'type' => 'NUMERIC',
1685
- ]]
1686
- ) );
1687
-
1688
- }
1689
-
1690
-
1691
- function new_to_auto_draft($post) {
1692
 
1693
- $post_type = $post->post_type;
1694
 
1695
- if(self::is_for_this_post_type($post_type) && !isset($_REQUEST["folder_for_media"])) {
1696
 
1697
- $post_type = self::get_custom_post_type($post_type);
1698
- $selected_folder = get_option("selected_{$post_type}_folder");
 
 
 
 
 
 
 
 
 
 
 
 
 
1699
 
1700
- if($selected_folder != null && !empty($selected_folder)) {
1701
  $terms = get_term($selected_folder);
1702
- if(!empty($terms) && isset($terms->slug)) {
1703
- wp_set_object_terms($post->ID, $terms->slug, $post_type );
1704
  }
1705
-
1706
  }
1707
  }
1708
- }
1709
 
1710
- public function wcp_folder_send_message_to_owner() {
 
 
 
 
 
 
 
 
 
 
 
1711
  if (current_user_can('manage_options')) {
1712
- $response = array();
1713
- $response['status'] = 0;
1714
- $response['error'] = 0;
1715
- $response['errors'] = array();
1716
  $response['message'] = "";
1717
- $errorArray = [];
1718
- $errorMessage = esc_html__("%s is required", 'folders');
1719
- $postData = filter_input_array(INPUT_POST);
1720
  if (!isset($postData['textarea_text']) || trim($postData['textarea_text']) == "") {
1721
- $error = array(
1722
- "key" => "textarea_text",
1723
- "message" => esc_html__("Please enter your message", 'folders')
1724
- );
1725
  $errorArray[] = $error;
1726
  }
 
1727
  if (!isset($postData['user_email']) || trim($postData['user_email']) == "") {
1728
- $error = array(
1729
- "key" => "user_email",
1730
- "message" => sprintf($errorMessage, __("Email", 'folders'))
1731
- );
1732
  $errorArray[] = $error;
1733
  } else if (!filter_var($postData['user_email'], FILTER_VALIDATE_EMAIL)) {
1734
- $error = array(
1735
- 'key' => "user_email",
1736
- "message" => "Email is not valid"
1737
- );
1738
  $errorArray[] = $error;
1739
  }
 
1740
  if (empty($errorArray)) {
1741
  if (!isset($postData['folder_help_nonce']) || trim($postData['folder_help_nonce']) == "") {
1742
- $error = array(
1743
- "key" => "nonce",
1744
- "message" => esc_html__("Your request is not valid", 'folders')
1745
- );
1746
  $errorArray[] = $error;
1747
  } else {
1748
  if (!wp_verify_nonce($postData['folder_help_nonce'], 'wcp_folder_help_nonce')) {
1749
- $error = array(
1750
- "key" => "nonce",
1751
- "message" => esc_html__("Your request is not valid", 'folders')
1752
- );
1753
  $errorArray[] = $error;
1754
  }
1755
  }
1756
  }
 
1757
  if (empty($errorArray)) {
1758
  $text_message = self::sanitize_options($postData['textarea_text']);
1759
- $email = self::sanitize_options($postData['user_email'], "email");
1760
- $domain = site_url();
1761
  $current_user = wp_get_current_user();
1762
- $user_name = $current_user->first_name . " " . $current_user->last_name;
1763
-
1764
- $response['status'] = 1;
1765
-
1766
- /* sending message to Crisp */
1767
- $post_message = array();
1768
-
1769
- $message_data = array();
1770
- $message_data['key'] = "Plugin";
1771
- $message_data['value'] = "Folders";
1772
- $post_message[] = $message_data;
1773
-
1774
- $message_data = array();
1775
- $message_data['key'] = "Domain";
1776
- $message_data['value'] = $domain;
1777
- $post_message[] = $message_data;
1778
-
1779
- $message_data = array();
1780
- $message_data['key'] = "Email";
1781
- $message_data['value'] = $email;
1782
- $post_message[] = $message_data;
1783
-
1784
- $message_data = array();
1785
- $message_data['key'] = "Message";
1786
- $message_data['value'] = $text_message;
1787
- $post_message[] = $message_data;
1788
-
1789
- $api_params = array(
1790
- 'domain' => $domain,
1791
- 'email' => $email,
1792
- 'url' => site_url(),
1793
- 'name' => $user_name,
1794
- 'message' => $post_message,
1795
- 'plugin' => "Folders",
1796
- 'type' => "Need Help",
1797
- );
1798
-
1799
- /* Sending message to Crisp API */
1800
- $crisp_response = wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", array('body' => $api_params, 'timeout' => 15, 'sslverify' => true));
1801
-
1802
- if (is_wp_error($crisp_response)) {
1803
- wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", array('body' => $api_params, 'timeout' => 15, 'sslverify' => false));
1804
- }
1805
  } else {
1806
- $response['error'] = 1;
1807
  $response['errors'] = $errorArray;
1808
- }
 
1809
  echo json_encode($response);
1810
- }
1811
- }
 
1812
 
1813
- public function folder_plugin_deactivate() {
 
 
 
 
 
 
 
 
 
1814
  if (current_user_can('manage_options')) {
1815
- $postData = filter_input_array(INPUT_POST);
1816
- $errorCounter = 0;
1817
- $response = array();
1818
- $response['status'] = 0;
1819
  $response['message'] = "";
1820
- $response['valid'] = 1;
1821
- if(!isset($postData['reason']) || empty($postData['reason'])) {
1822
  $errorCounter++;
1823
  $response['message'] = "Please provide reason";
1824
  } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
@@ -1827,144 +2361,178 @@ class WCP_Folders
1827
  $response['valid'] = 0;
1828
  } else {
1829
  $nonce = self::sanitize_options($postData['nonce']);
1830
- if(!wp_verify_nonce($nonce, 'wcp_folder_deactivate_nonce')) {
1831
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1832
  $errorCounter++;
1833
  $response['valid'] = 0;
1834
  }
1835
  }
1836
- if($errorCounter == 0) {
 
1837
  $reason = $postData['reason'];
1838
- $email = "none@none.none";
1839
  if (isset($postData['email_id']) && !empty($postData['email_id']) && filter_var($postData['email_id'], FILTER_VALIDATE_EMAIL)) {
1840
  $email = $postData['email_id'];
1841
  }
1842
- $domain = site_url();
1843
- $current_user = wp_get_current_user();
1844
- $user_name = $current_user->first_name." ".$current_user->last_name;
 
1845
 
1846
  $response['status'] = 1;
1847
 
1848
- /* sending message to Crisp */
1849
- $post_message = array();
1850
-
1851
- $message_data = array();
1852
- $message_data['key'] = "Plugin";
1853
- $message_data['value'] = "Folders";
1854
- $post_message[] = $message_data;
1855
-
1856
- $message_data = array();
1857
- $message_data['key'] = "Plugin Version";
1858
- $message_data['value'] = WCP_FOLDER_VERSION;
1859
- $post_message[] = $message_data;
1860
-
1861
- $message_data = array();
1862
- $message_data['key'] = "Domain";
1863
- $message_data['value'] = $domain;
1864
- $post_message[] = $message_data;
1865
-
1866
- $message_data = array();
1867
- $message_data['key'] = "Email";
1868
- $message_data['value'] = $email;
1869
- $post_message[] = $message_data;
1870
-
1871
- $message_data = array();
1872
- $message_data['key'] = "WordPress Version";
1873
- $message_data['value'] = esc_attr(get_bloginfo('version'));
1874
- $post_message[] = $message_data;
1875
-
1876
- $message_data = array();
1877
- $message_data['key'] = "PHP Version";
1878
- $message_data['value'] = PHP_VERSION;
1879
- $post_message[] = $message_data;
1880
-
1881
- $message_data = array();
1882
- $message_data['key'] = "Message";
1883
- $message_data['value'] = $reason;
1884
- $post_message[] = $message_data;
1885
-
1886
- $api_params = array(
1887
- 'domain' => $domain,
1888
- 'email' => $email,
1889
- 'url' => site_url(),
1890
- 'name' => $user_name,
1891
- 'message' => $post_message,
1892
- 'plugin' => "Folders",
1893
- 'type' => "Uninstall",
1894
- );
1895
-
1896
- /* Sending message to Crisp API */
1897
- $crisp_response = wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", array('body' => $api_params, 'timeout' => 15, 'sslverify' => true));
1898
-
1899
- if (is_wp_error($crisp_response)) {
1900
- wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", array('body' => $api_params, 'timeout' => 15, 'sslverify' => false));
1901
- }
1902
- }
 
1903
  echo json_encode($response);
1904
  wp_die();
1905
- }
1906
- }
 
 
1907
 
1908
- public static function ttl_fldrs() {
 
 
 
 
 
 
 
 
1909
  $post_types = get_option('folders_settings');
1910
- $post_types = is_array($post_types) ? $post_types : array();
1911
- $total = 0;
1912
  foreach ($post_types as $post_type) {
1913
  $post_type = self::get_custom_post_type($post_type);
1914
- $total += wp_count_terms($post_type);
1915
  }
 
1916
  return $total;
1917
- }
1918
 
 
 
 
 
 
 
 
 
 
 
1919
  public function wcp_remove_post_item()
1920
  {
1921
- $response = array();
1922
- $response['status'] = 0;
1923
- $response['error'] = 0;
1924
- $response['data'] = array();
1925
  $response['message'] = "";
1926
- $postData = filter_input_array(INPUT_POST);
1927
  if (isset($postData['post_id']) && !empty($postData['post_id'])) {
1928
  wp_delete_post($postData['post_id']);
1929
  $response['status'] = 1;
1930
  }
 
1931
  echo json_encode($response);
1932
  wp_die();
1933
- }
1934
 
 
 
 
 
 
 
 
 
 
 
1935
  public function wcp_change_all_status()
1936
  {
1937
- $response = array();
1938
- $response['status'] = 0;
1939
- $response['error'] = 0;
1940
- $response['data'] = array();
1941
  $response['message'] = "";
1942
- $postData = filter_input_array(INPUT_POST);
1943
- $errorCounter = 0;
1944
  if (!isset($postData['type']) || empty($postData['type'])) {
1945
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1946
  $errorCounter++;
1947
  } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1948
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1949
  $errorCounter++;
1950
- } else if (!current_user_can("manage_categories") || ($postData['type'] == "page" && !current_user_can("edit_pages"))) {
1951
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
1952
  $errorCounter++;
1953
  } else if (!current_user_can("manage_categories") || ($postData['type'] != "page" && !current_user_can("edit_posts"))) {
1954
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
1955
  $errorCounter++;
1956
  } else {
1957
- $type = self::sanitize_options($postData['type']);
1958
  $nonce = self::sanitize_options($postData['nonce']);
1959
- if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
1960
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1961
  $errorCounter++;
1962
  }
1963
  }
 
1964
  if ($errorCounter == 0) {
1965
  if (isset($postData['folders']) || !empty($postData['folders'])) {
1966
- $status = isset($postData['status']) ? $postData['status'] : 0;
1967
- $status = self::sanitize_options($status);
1968
  $folders = self::sanitize_options($postData['folders']);
1969
  $folders = trim($folders, ",");
1970
  $folders = explode(",", $folders);
@@ -1972,21 +2540,32 @@ class WCP_Folders
1972
  update_term_meta($folder, "is_active", $status);
1973
  }
1974
  }
 
1975
  $response['status'] = 1;
1976
  }
 
1977
  echo json_encode($response);
1978
  wp_die();
1979
- }
1980
 
 
 
 
 
 
 
 
 
 
 
1981
  public function wcp_change_post_width()
1982
  {
1983
- $response = array();
1984
- $response['status'] = 0;
1985
- $response['error'] = 0;
1986
- $response['data'] = array();
1987
  $response['message'] = "";
1988
- $postData = filter_input_array(INPUT_POST);
1989
- $errorCounter = 0;
1990
  if (!isset($postData['width']) || empty($postData['width'])) {
1991
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1992
  $errorCounter++;
@@ -2003,173 +2582,213 @@ class WCP_Folders
2003
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
2004
  $errorCounter++;
2005
  } else {
2006
- $type = self::sanitize_options($postData['type']);
2007
  $nonce = self::sanitize_options($postData['nonce']);
2008
- if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
2009
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2010
  $errorCounter++;
2011
  }
2012
- }
 
2013
  if ($errorCounter == 0) {
2014
- $type = self::sanitize_options($postData['type']);
2015
- $width = self::sanitize_options($postData['width'], "int");
2016
- $optionName = "wcp_dynamic_width_for_" . $type;
2017
  update_option($optionName, $width);
2018
  $response['status'] = 1;
2019
  }
 
2020
  echo json_encode($response);
2021
  wp_die();
2022
- }
2023
 
 
 
 
 
 
 
 
 
 
 
2024
  public function wcp_change_multiple_post_folder()
2025
  {
2026
- $response = array();
2027
- $response['status'] = 0;
2028
- $response['error'] = 0;
2029
- $response['data'] = array();
2030
  $response['message'] = "";
2031
- $postData = filter_input_array(INPUT_POST);
2032
- $errorCounter = 0;
2033
  if (!isset($postData['post_ids']) || empty($postData['post_ids'])) {
2034
- $response['message'] = esc_html__("Your request is not valid", 'folders');
2035
  $errorCounter++;
2036
  } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
2037
- $response['message'] = esc_html__("Your request is not valid", 'folders');
2038
  $errorCounter++;
2039
  } else if (!isset($postData['type']) || empty($postData['type'])) {
2040
- $response['message'] = esc_html__("Your request is not valid", 'folders');
2041
  $errorCounter++;
2042
  } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2043
- $response['message'] = esc_html__("Your request is not valid", 'folders');
2044
  $errorCounter++;
2045
  } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
2046
- $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2047
  $errorCounter++;
2048
  } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
2049
- $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2050
  $errorCounter++;
2051
  } else {
2052
  $folder_id = self::sanitize_options($postData['folder_id']);
2053
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$folder_id)) {
2054
- $response['message'] = esc_html__("Your request is not valid", 'folders');
2055
  $errorCounter++;
2056
  }
2057
- }
 
2058
  if ($errorCounter == 0) {
2059
- $folderUndoSettings = array();
2060
- $postID = self::sanitize_options($postData['post_ids']);
2061
- $postID = trim($postID, ",");
2062
- $folderID = self::sanitize_options($postData['folder_id']);
2063
- $type = self::sanitize_options($postData['type']);
2064
  $postArray = explode(",", $postID);
2065
- $status = 0;
2066
- if(isset($postData['status'])) {
2067
  $status = self::sanitize_options($postData['status']);
2068
  }
 
2069
  $status = true;
2070
 
2071
  $taxonomy = "";
2072
- if(isset($postData['taxonomy'])) {
2073
  $taxonomy = self::sanitize_options($postData['taxonomy']);
2074
  }
 
2075
  if (is_array($postArray)) {
2076
  $post_type = self::get_custom_post_type($type);
2077
  foreach ($postArray as $post) {
2078
- $terms = get_the_terms($post, $post_type);
2079
- $post_terms = array(
2080
  'post_id' => $post,
2081
- 'terms' => $terms
2082
- );
2083
  $folderUndoSettings[] = $post_terms;
2084
  if (!empty($terms)) {
2085
  foreach ($terms as $term) {
2086
- if(!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
2087
  wp_remove_object_terms($post, $term->term_id, $post_type);
2088
  }
2089
  }
2090
  }
 
2091
  wp_set_post_terms($post, $folderID, $post_type, $status);
2092
  }
2093
  }
 
2094
  $response['status'] = 1;
2095
  delete_transient("folder_undo_settings");
2096
  delete_transient("premio_folders_without_trash");
2097
  set_transient("folder_undo_settings", $folderUndoSettings, DAY_IN_SECONDS);
2098
- }
 
2099
  echo json_encode($response);
2100
  wp_die();
2101
- }
2102
-
2103
- public function wcp_undo_folder_changes() {
2104
- $response = array();
2105
- $response['status'] = 0;
2106
- $response['error'] = 0;
2107
- $response['data'] = array();
2108
- $response['message'] = "";
2109
- $postData = filter_input_array(INPUT_POST);
2110
- $errorCounter = 0;
2111
- if (!isset($postData['post_type']) || empty($postData['post_type'])) {
2112
- $response['message'] = esc_html__("Your request is not valid", 'folders');
2113
- $errorCounter++;
2114
- } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2115
- $response['message'] = esc_html__("Your request is not valid", 'folders');
2116
- $errorCounter++;
2117
- } else {
2118
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['post_type'])) {
2119
- $response['message'] = esc_html__("Your request is not valid", 'folders');
2120
- $errorCounter++;
2121
- }
2122
- }
2123
- if ($errorCounter == 0) {
2124
- $response['status'] = 1;
2125
- $folder_undo_settings = get_transient("folder_undo_settings");
2126
- $type = self::sanitize_options($postData['post_type']);
2127
- $post_type = self::get_custom_post_type($type);
2128
- if(!empty($folder_undo_settings) && is_array($folder_undo_settings)) {
2129
- $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
2130
- if($trash_folders === false) {
2131
- $trash_folders = array();
2132
- $initial_trash_folders = array();
2133
- }
2134
- foreach($folder_undo_settings as $item) {
2135
- $terms = get_the_terms($item['post_id'], $post_type);
2136
- if (!empty($terms)) {
2137
- foreach ($terms as $term) {
2138
- wp_remove_object_terms($item['post_id'], $term->term_id, $post_type);
2139
- if(isset($trash_folders[$term->term_taxonomy_id])) {
2140
- unset($trash_folders[$term->term_taxonomy_id]);
2141
- }
2142
- }
2143
- }
2144
- if(!empty($item['terms']) && is_array($item['terms'])) {
2145
- foreach($item['terms'] as $term) {
2146
- wp_set_post_terms($item['post_id'], $term->term_id, $post_type, true);
2147
- if(isset($trash_folders[$term->term_taxonomy_id])) {
2148
- unset($trash_folders[$term->term_taxonomy_id]);
2149
- }
2150
- }
2151
- }
2152
- }
2153
-
2154
- if(!empty($terms) && $initial_trash_folders != $trash_folders) {
2155
- delete_transient("premio_folders_without_trash");
2156
- set_transient("premio_folders_without_trash", $trash_folders, 3*DAY_IN_SECONDS);
2157
- }
2158
- }
2159
- }
2160
- echo json_encode($response);
2161
- die;
2162
- }
2163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2164
  public function wcp_change_post_folder()
2165
  {
2166
- $response = array();
2167
- $response['status'] = 0;
2168
- $response['error'] = 0;
2169
- $response['data'] = array();
2170
  $response['message'] = "";
2171
- $postData = filter_input_array(INPUT_POST);
2172
- $errorCounter = 0;
2173
  if (!isset($postData['post_id']) || empty($postData['post_id'])) {
2174
  $errorCounter++;
2175
  $response['message'] = esc_html__("Your request is not valid", 'folders');
@@ -2190,49 +2809,63 @@ class WCP_Folders
2190
  $errorCounter++;
2191
  } else {
2192
  $term_id = self::sanitize_options($postData['folder_id']);
2193
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2194
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2195
  $errorCounter++;
2196
  }
2197
- }
 
2198
  if ($errorCounter == 0) {
2199
- $postID = self::sanitize_options($postData['post_id']);
2200
  $folderID = self::sanitize_options($postData['folder_id']);
2201
- $type = self::sanitize_options($postData['type']);
2202
  $folder_post_type = self::get_custom_post_type($type);
2203
- $status = 0;
2204
- if(isset($postData['status'])) {
2205
  $status = self::sanitize_options($postData['status']);
2206
  }
2207
- $status = ($status == 1)?true:false;
 
2208
  $taxonomy = "";
2209
- if(isset($postData['taxonomy'])) {
2210
  $taxonomy = self::sanitize_options($postData['taxonomy']);
2211
  }
 
2212
  $terms = get_the_terms($postID, $folder_post_type);
2213
  if (!empty($terms)) {
2214
  foreach ($terms as $term) {
2215
- if(!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
2216
  wp_remove_object_terms($postID, $term->term_id, $folder_post_type);
2217
  }
2218
  }
2219
  }
 
2220
  wp_set_post_terms($postID, $folderID, $folder_post_type, true);
2221
  $response['status'] = 1;
2222
- }
 
2223
  echo json_encode($response);
2224
  wp_die();
2225
- }
2226
 
 
 
 
 
 
 
 
 
 
 
2227
  public function wcp_mark_un_mark_folder()
2228
  {
2229
- $response = array();
2230
- $response['status'] = 0;
2231
- $response['error'] = 0;
2232
- $response['data'] = array();
2233
  $response['message'] = "";
2234
- $postData = filter_input_array(INPUT_POST);
2235
- $errorCounter = 0;
2236
  if (!current_user_can("manage_categories")) {
2237
  $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2238
  $errorCounter++;
@@ -2244,14 +2877,15 @@ class WCP_Folders
2244
  $errorCounter++;
2245
  } else {
2246
  $term_id = self::sanitize_options($postData['term_id']);
2247
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2248
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2249
  $errorCounter++;
2250
  }
2251
  }
 
2252
  if ($errorCounter == 0) {
2253
  $term_id = self::sanitize_options($postData['term_id']);
2254
- $status = get_term_meta($term_id, "is_highlighted", true);
2255
  if ($status == 1) {
2256
  update_term_meta($term_id, "is_highlighted", 0);
2257
  $status = 0;
@@ -2259,23 +2893,34 @@ class WCP_Folders
2259
  update_term_meta($term_id, "is_highlighted", 1);
2260
  $status = 1;
2261
  }
 
2262
  $response['marked'] = $status;
2263
- $response['id'] = $postData['term_id'];
2264
  $response['status'] = 1;
2265
  }
 
2266
  echo json_encode($response);
2267
  wp_die();
2268
- }
2269
 
 
 
 
 
 
 
 
 
 
 
2270
  public function wcp_make_sticky_folder()
2271
  {
2272
- $response = array();
2273
- $response['status'] = 0;
2274
- $response['error'] = 0;
2275
- $response['data'] = array();
2276
  $response['message'] = "";
2277
- $postData = filter_input_array(INPUT_POST);
2278
- $errorCounter = 0;
2279
  if (!current_user_can("manage_categories")) {
2280
  $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2281
  $errorCounter++;
@@ -2287,14 +2932,15 @@ class WCP_Folders
2287
  $errorCounter++;
2288
  } else {
2289
  $term_id = self::sanitize_options($postData['term_id']);
2290
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2291
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2292
  $errorCounter++;
2293
  }
2294
  }
 
2295
  if ($errorCounter == 0) {
2296
  $term_id = self::sanitize_options($postData['term_id']);
2297
- $status = get_term_meta($term_id, "is_folder_sticky", true);
2298
  if ($status == 1) {
2299
  update_term_meta($term_id, "is_folder_sticky", 0);
2300
  $status = 0;
@@ -2302,23 +2948,34 @@ class WCP_Folders
2302
  update_term_meta($term_id, "is_folder_sticky", 1);
2303
  $status = 1;
2304
  }
 
2305
  $response['is_folder_sticky'] = $status;
2306
- $response['id'] = $postData['term_id'];
2307
  $response['status'] = 1;
2308
  }
 
2309
  echo json_encode($response);
2310
  wp_die();
2311
- }
2312
 
 
 
 
 
 
 
 
 
 
 
2313
  public function wcp_save_folder_order()
2314
  {
2315
- $response = array();
2316
- $response['status'] = 0;
2317
- $response['error'] = 0;
2318
- $response['data'] = array();
2319
  $response['message'] = "";
2320
- $postData = filter_input_array(INPUT_POST);
2321
- $errorCounter = 0;
2322
  if (!current_user_can("manage_categories")) {
2323
  $response['message'] = esc_html__("You have not permission to update folder order", 'folders');
2324
  $errorCounter++;
@@ -2333,52 +2990,67 @@ class WCP_Folders
2333
  $errorCounter++;
2334
  } else {
2335
  $type = self::sanitize_options($postData['type']);
2336
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
2337
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2338
  $errorCounter++;
2339
  }
2340
  }
 
2341
  if ($errorCounter == 0) {
2342
- $termIds = self::sanitize_options(($postData['term_ids']));
2343
- $type = self::sanitize_options($postData['type']);
2344
- $termIds = trim($termIds, ",");
2345
  $termArray = explode(",", $termIds);
2346
- $order = 1;
2347
  foreach ($termArray as $term) {
2348
  if (!empty($term)) {
2349
  update_term_meta($term, "wcp_custom_order", $order);
2350
  $order++;
2351
  }
2352
  }
2353
- $term_id = self::sanitize_options($postData['term_id']);
2354
- $parent_id = self::sanitize_options($postData['parent_id']);
2355
- $type = self::sanitize_options($postData['type']);
 
2356
  $folder_type = self::get_custom_post_type($type);
2357
- wp_update_term($term_id, $folder_type, array(
2358
- 'parent' => $parent_id
2359
- ));
 
 
2360
 
2361
- if($parent_id != "#" || !empty($parent_id)) {
2362
- update_term_meta($parent_id, "is_active", 1);
2363
  }
 
2364
  $response['status'] = 1;
2365
- $folder_type = self::get_custom_post_type($type);
2366
- /* Free/Pro Class name change */
2367
  $response['options'] = WCP_Tree::get_option_data_for_select($folder_type);
2368
- }
 
2369
  echo json_encode($response);
2370
  wp_die();
2371
- }
2372
 
 
 
 
 
 
 
 
 
 
 
2373
  public function save_wcp_folder_state()
2374
  {
2375
- $response = array();
2376
- $response['status'] = 0;
2377
- $response['error'] = 0;
2378
- $response['data'] = array();
2379
  $response['message'] = "";
2380
- $postData = filter_input_array(INPUT_POST);
2381
- $errorCounter = 0;
2382
  if (!current_user_can("manage_categories")) {
2383
  $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2384
  $errorCounter++;
@@ -2390,35 +3062,46 @@ class WCP_Folders
2390
  $errorCounter++;
2391
  } else {
2392
  $term_id = self::sanitize_options($postData['term_id']);
2393
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2394
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2395
  $errorCounter++;
2396
  }
2397
  }
 
2398
  if ($errorCounter == 0) {
2399
  $response['status'] = 1;
2400
- $term_id = self::sanitize_options($postData['term_id']);
2401
- $is_active = isset($postData['is_active'])?$postData['is_active']:0;
2402
- $is_active = self::sanitize_options($is_active);
2403
  if ($is_active == 1) {
2404
  update_term_meta($term_id, "is_active", 1);
2405
  } else {
2406
  update_term_meta($term_id, "is_active", 0);
2407
  }
2408
  }
 
2409
  echo json_encode($response);
2410
  wp_die();
2411
- }
2412
 
 
 
 
 
 
 
 
 
 
 
2413
  public function wcp_update_parent_information()
2414
  {
2415
- $response = array();
2416
- $response['status'] = 0;
2417
- $response['error'] = 0;
2418
- $response['data'] = array();
2419
  $response['message'] = "";
2420
- $postData = filter_input_array(INPUT_POST);
2421
- $errorCounter = 0;
2422
  if (!current_user_can("manage_categories")) {
2423
  $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2424
  $errorCounter++;
@@ -2436,35 +3119,48 @@ class WCP_Folders
2436
  $errorCounter++;
2437
  } else {
2438
  $term_id = self::sanitize_options($postData['term_id']);
2439
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2440
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2441
  $errorCounter++;
2442
  }
2443
- }
2444
- if($errorCounter == 0) {
2445
- $term_id = self::sanitize_options($postData['term_id']);
2446
- $parent_id = self::sanitize_options($postData['parent_id']);
2447
- $type = self::sanitize_options($postData['type']);
 
2448
  $folder_type = self::get_custom_post_type($type);
2449
- wp_update_term($term_id, $folder_type, array(
2450
- 'parent' => $parent_id
2451
- ));
 
 
2452
  update_term_meta($parent_id, "is_active", 1);
2453
  $response['status'] = 1;
2454
  }
 
2455
  echo json_encode($response);
2456
  wp_die();
2457
- }
2458
 
 
 
 
 
 
 
 
 
 
 
2459
  public function wcp_save_parent_data()
2460
  {
2461
- $response = array();
2462
- $response['status'] = 0;
2463
- $response['error'] = 0;
2464
- $response['data'] = array();
2465
  $response['message'] = "";
2466
- $postData = filter_input_array(INPUT_POST);
2467
- $errorCounter = 0;
2468
  if (!isset($postData['type']) || empty($postData['type'])) {
2469
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2470
  $errorCounter++;
@@ -2476,35 +3172,47 @@ class WCP_Folders
2476
  $errorCounter++;
2477
  } else {
2478
  $type = self::sanitize_options($postData['type']);
2479
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
2480
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2481
  $errorCounter++;
2482
  }
2483
  }
 
2484
  if ($errorCounter == 0) {
2485
- $type = self::sanitize_options($postData['type']);
2486
- $optionName = $type . "_parent_status";
2487
  $response['status'] = 1;
2488
- $is_active = isset($postData['is_active'])?$postData['is_active']:0;
2489
- $is_active = self::sanitize_options($is_active);
2490
  if ($is_active == 1) {
2491
  update_option($optionName, 1);
2492
  } else {
2493
  update_option($optionName, 0);
2494
  }
2495
  }
 
2496
  echo json_encode($response);
2497
  wp_die();
2498
- }
2499
 
2500
- public function remove_muliple_folder(){
2501
- $response = array();
2502
- $response['status'] = 0;
2503
- $response['error'] = 0;
2504
- $response['data'] = array();
 
 
 
 
 
 
 
 
 
 
 
2505
  $response['message'] = "";
2506
- $postData = filter_input_array(INPUT_POST);
2507
- $errorCounter = 0;
2508
  $error = "";
2509
  if (!current_user_can("manage_categories")) {
2510
  $error = esc_html__("You have not permission to remove folder", 'folders');
@@ -2520,47 +3228,60 @@ class WCP_Folders
2520
  $errorCounter++;
2521
  } else {
2522
  $type = self::sanitize_options($postData['type']);
2523
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
2524
  $error = esc_html__("Your request is not valid", 'folders');
2525
  $errorCounter++;
2526
  }
2527
  }
 
2528
  if ($errorCounter == 0) {
2529
  $term_id = self::sanitize_options($postData['term_id']);
2530
- $type = self::sanitize_options($postData['type']);
2531
- $response['term_ids'] = array();
2532
- if(!empty($term_id)) {
2533
- $term_id = trim($term_id,",");
2534
  $term_ids = explode(",", $term_id);
2535
- if(is_array($term_ids) && count($term_ids) > 0) {
2536
  foreach ($term_ids as $term) {
2537
  self::remove_folder_child_items($term, $type);
2538
  }
 
2539
  $response['term_ids'] = $term_ids;
2540
  }
2541
  }
2542
- $is_active = 1;
2543
- $folders = -1;
 
2544
  $response['status'] = 1;
2545
- $response['folders'] = $folders;
2546
  $response['is_key_active'] = $is_active;
2547
  } else {
2548
- $response['error'] = 1;
2549
  $response['message'] = $error;
2550
- }
 
2551
  echo json_encode($response);
2552
  wp_die();
2553
- }
2554
 
 
 
 
 
 
 
 
 
 
 
2555
  public function wcp_remove_folder()
2556
  {
2557
- $response = array();
2558
- $response['status'] = 0;
2559
- $response['error'] = 0;
2560
- $response['data'] = array();
2561
  $response['message'] = "";
2562
- $postData = filter_input_array(INPUT_POST);
2563
- $errorCounter = 0;
2564
  if (!current_user_can("manage_categories")) {
2565
  $error = esc_html__("You have not permission to remove folder", 'folders');
2566
  $errorCounter++;
@@ -2575,56 +3296,80 @@ class WCP_Folders
2575
  $errorCounter++;
2576
  } else {
2577
  $term_id = self::sanitize_options($postData['term_id']);
2578
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2579
  $error = esc_html__("Unable to delete folder, Your request is not valid", 'folders');
2580
  $errorCounter++;
2581
  }
2582
  }
 
2583
  if ($errorCounter == 0) {
2584
  $term_id = self::sanitize_options($postData['term_id']);
2585
- $type = self::sanitize_options($postData['type']);
2586
  self::remove_folder_child_items($term_id, $type);
2587
  $response['status'] = 1;
2588
- $is_active = 1;
2589
- $folders = -1;
2590
- $response['folders'] = $folders;
2591
- $response['term_id'] = $term_id;
2592
  $response['is_key_active'] = $is_active;
2593
  } else {
2594
- $response['error'] = 1;
2595
  $response['message'] = $error;
2596
  }
 
2597
  echo json_encode($response);
2598
  wp_die();
2599
- }
2600
 
 
 
 
 
 
 
 
 
 
 
2601
  public function remove_folder_child_items($term_id, $post_type)
2602
  {
2603
  $folder_type = self::get_custom_post_type($post_type);
2604
- $terms = get_terms($folder_type, array(
2605
- 'hide_empty' => false,
2606
- 'parent' => $term_id
2607
- ));
 
 
 
2608
 
2609
  if (!empty($terms)) {
2610
  foreach ($terms as $term) {
2611
  self::remove_folder_child_items($term->term_id, $post_type);
2612
  }
 
2613
  wp_delete_term($term_id, $folder_type);
2614
  } else {
2615
  wp_delete_term($term_id, $folder_type);
2616
  }
2617
- }
2618
 
 
 
 
 
 
 
 
 
 
 
2619
  public function wcp_update_folder()
2620
  {
2621
- $response = array();
2622
- $response['status'] = 0;
2623
- $response['error'] = 0;
2624
- $response['data'] = array();
2625
  $response['message'] = "";
2626
- $postData = $_REQUEST;
2627
- $errorCounter = 0;
2628
  if (!current_user_can("manage_categories")) {
2629
  $error = esc_html__("You have not permission to update folder", 'folders');
2630
  $errorCounter++;
@@ -2642,72 +3387,525 @@ class WCP_Folders
2642
  $errorCounter++;
2643
  } else {
2644
  $term_id = self::sanitize_options($postData['term_id']);
2645
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2646
  $error = esc_html__("Unable to rename folder, Your request is not valid", 'folders');
2647
  $errorCounter++;
2648
  }
2649
- }
 
2650
  if ($errorCounter == 0) {
2651
- $type = self::sanitize_options($postData['type']);
2652
  $folder_type = self::get_custom_post_type($type);
2653
- $name = self::sanitize_options($postData['name']);
2654
- $term_id = self::sanitize_options($postData['term_id']);
2655
- $result = wp_update_term(
2656
  $term_id,
2657
  $folder_type,
2658
- array(
2659
- 'name' => $name,
2660
- )
2661
  );
2662
  if (!empty($result)) {
2663
- $term_nonce = wp_create_nonce('wcp_folder_term_'.$result['term_id']);
2664
- $response['id'] = $result['term_id'];
2665
- $response['slug'] = $result['slug'];
2666
  $response['status'] = 1;
2667
  $response['term_title'] = $postData['name'];
2668
- $response['nonce'] = $term_nonce;
2669
  } else {
2670
  $response['message'] = esc_html__("Unable to rename folder", 'folders');
2671
  }
2672
  } else {
2673
- $response['error'] = 1;
2674
  $response['message'] = $error;
2675
- }
 
2676
  echo json_encode($response);
2677
  wp_die();
2678
- }
2679
 
 
 
 
 
 
 
 
 
 
 
2680
  public function create_slug_from_string($str)
2681
  {
2682
- $a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'Ð', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', '?', '?', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', '?', '?', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', '?', 'O', 'o', 'O', 'o', 'O', 'o', 'Œ', 'œ', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'Š', 'š', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Ÿ', 'Z', 'z', 'Z', 'z', 'Ž', 'ž', '?', 'ƒ', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', '?', '?', '?', '?', '?', '?');
2683
- $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
2684
- return strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), str_replace($a, $b, $str)));
2685
- }
2686
-
2687
- public static function sanitize_options($value, $type = "") {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2688
  $value = stripslashes($value);
2689
- if($type == "int") {
2690
  $value = filter_var($value, FILTER_SANITIZE_NUMBER_INT);
2691
- } else if($type == "email") {
2692
  $value = filter_var($value, FILTER_SANITIZE_EMAIL);
2693
  } else {
2694
- $value = filter_var($value, FILTER_SANITIZE_STRING);
2695
  }
 
2696
  return $value;
2697
- }
2698
 
 
 
 
 
 
 
 
 
 
 
2699
  public function wcp_add_new_folder()
2700
  {
2701
- $response = array();
2702
- $response['status'] = 0;
2703
- $response['error'] = 0;
2704
- $response['login'] = 1;
2705
- $response['data'] = array();
2706
  $response['message'] = "";
2707
  $response['message2'] = "";
2708
- $postData = $_REQUEST;
2709
  $errorCounter = 0;
2710
- $error= "";
2711
  if (!current_user_can("manage_categories")) {
2712
  $error = esc_html__("You have not permission to add folder", 'folders');
2713
  $errorCounter++;
@@ -2723,69 +3921,73 @@ class WCP_Folders
2723
  $errorCounter++;
2724
  } else {
2725
  $type = self::sanitize_options($postData['type']);
2726
- if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
2727
  $response['login'] = 0;
2728
  $error = esc_html__("Unable to create folder, Your request is not valid", 'folders');
2729
  $errorCounter++;
2730
  }
2731
- }
 
2732
  if ($errorCounter == 0) {
2733
- $parent = isset($postData['parent_id']) && !empty($postData['parent_id']) ? $postData['parent_id'] : 0;
2734
  $parent_menu = isset($postData['parent_menu']) && !empty($postData['parent_menu']) ? $postData['parent_menu'] : 0;
2735
- $parent_ids = isset($postData['parent_ids']) && !empty($postData['parent_ids']) ? $postData['parent_ids'] : 0;
2736
- $parent = self::sanitize_options($parent);
2737
- $type = self::sanitize_options($postData['type']);
2738
  $folder_type = self::get_custom_post_type($type);
2739
- $term_name = self::sanitize_options($postData['name']);
2740
- $term = term_exists($term_name, $folder_type, $parent);
2741
- $term_id = 0;
2742
  if (!(0 !== $term && null !== $term)) {
2743
- $folders = $postData['name'];
2744
- $folders = explode(",", $folders);
2745
- $foldersArray = array();
2746
- $order = isset($postData['order']) ? $postData['order'] : 0;
2747
- $order = self::sanitize_options($order);
2748
 
2749
- $is_active = 1;
2750
  $total_folders = -1;
2751
 
2752
- if(!$is_active) {
2753
  if (($total_folders + count($folders)) > 10) {
2754
  $response['status'] = -1;
2755
  echo json_encode($response);
2756
  wp_die();
2757
  }
2758
  }
 
2759
  foreach ($folders as $key => $folder) {
2760
  $folder = trim($folder);
2761
- $slug = self::create_slug_from_string($folder) . "-" . time();
2762
 
2763
  $result = wp_insert_term(
2764
- urldecode($folder), // the term
2765
- $folder_type, // the taxonomy
2766
- array(
 
 
2767
  'parent' => $parent,
2768
- 'slug' => $slug
2769
- )
2770
  );
2771
  if (!empty($result)) {
2772
- $term_id = $result['term_id'];
2773
  $total_folders++;
2774
- $response['id'] = $result['term_id'];
2775
  $response['status'] = 1;
2776
- $term = get_term($result['term_id'], $folder_type);
2777
- $order = $order + $key;
2778
- $term_nonce = wp_create_nonce('wcp_folder_term_' . $term->term_id);
2779
 
2780
- $folder_item = array();
2781
  $folder_item['parent_id'] = $parent;
2782
- $folder_item['slug'] = $term->slug;
2783
- $folder_item['nonce'] = $term_nonce;
2784
- $folder_item['term_id'] = $result['term_id'];
2785
- $folder_item['title'] = $folder;
2786
  $folder_item['parent_id'] = empty($postData['parent_id']) ? "0" : $postData['parent_id'];
2787
  $folder_item['is_sticky'] = 0;
2788
- $folder_item['is_high'] = 0;
2789
 
2790
  update_term_meta($result['term_id'], "wcp_custom_order", $order);
2791
  if ($parent != 0) {
@@ -2812,78 +4014,98 @@ class WCP_Folders
2812
  }
2813
 
2814
  $postArray = get_posts(
2815
- array(
2816
  'posts_per_page' => -1,
2817
- 'post_type' => $type,
2818
- 'tax_query' => array(
2819
- array(
2820
  'taxonomy' => $folder_type,
2821
- 'field' => 'term_id',
2822
- 'terms' => $term_id,
2823
- )
2824
- )
2825
- )
2826
  );
2827
  if (!empty($postArray)) {
2828
  foreach ($postArray as $p) {
2829
  wp_set_post_terms($p->ID, $term->term_id, $folder_type, true);
2830
  }
2831
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2832
  }
2833
  }
2834
  }
2835
 
2836
- if($parent_menu && !empty($parent_ids)) {
2837
- $order = isset($postData['order']) ? $postData['order'] : 0;
2838
- $parent_ids = trim($parent_ids, ",");
2839
- $parent_ids = explode(",", $parent_ids);
2840
- $folder_order = 0;
2841
- $parents = "";
2842
- if(is_array($parent_ids) && count($parent_ids)>0) {
2843
- foreach ($parent_ids as $key=>$value) {
2844
- if($value != "#") {
2845
- delete_term_meta($value, "wcp_custom_order");
2846
- add_term_meta( $value, "wcp_custom_order", $folder_order );
2847
- } else if(!empty($term_id)) {
2848
- delete_term_meta($term_id, "wcp_custom_order");
2849
- add_term_meta( $term_id, "wcp_custom_order", $folder_order );
2850
- }
2851
- $folder_order++;
2852
- }
2853
- }
2854
- }
2855
-
2856
  $foldersArray[] = $folder_item;
2857
- }
2858
 
2859
  if (!empty($foldersArray)) {
2860
  $response['is_key_active'] = $is_active;
2861
- $response['folders'] = $total_folders;
2862
- $response['parent_id'] = empty($parent) ? "#" : $parent;
2863
 
2864
  $response['status'] = 1;
2865
- $response['data'] = $foldersArray;
2866
  }
2867
- }
2868
  } else {
2869
- $response['error'] = 1;
2870
  $response['message'] = esc_html__("Folder name already exists", 'folders');
2871
- }
2872
  } else {
2873
- $response['error'] = 1;
2874
  $response['message'] = $error;
2875
- }
 
2876
  echo json_encode($response);
2877
  wp_die();
2878
- }
2879
 
 
 
 
 
 
 
 
 
 
 
2880
  public function is_for_this_post_type($post_type)
2881
  {
2882
  $post_types = get_option('folders_settings');
2883
- $post_types = is_array($post_types)?$post_types:array();
2884
  return in_array($post_type, $post_types);
2885
- }
2886
 
 
 
 
 
 
 
 
 
 
 
2887
  public function is_active_for_screen()
2888
  {
2889
  global $typenow, $current_screen;
@@ -2897,35 +4119,54 @@ class WCP_Folders
2897
  }
2898
 
2899
  $post_types = get_option('folders_settings');
2900
- $post_types = is_array($post_types)?$post_types:array();
2901
 
2902
- if(empty($typenow) && (isset($current_screen->base) && 'upload' == $current_screen->base)) {
2903
  $typenow = "attachment";
2904
  if (self::is_for_this_post_type($typenow)) {
2905
  return true;
2906
  }
2907
  }
 
2908
  return false;
2909
- }
2910
 
 
 
 
 
 
 
 
 
 
 
2911
  public function is_add_update_screen()
2912
  {
2913
  global $current_screen;
2914
  $current_type = $current_screen->base;
2915
- $action = $current_screen->action;
2916
- $post_types = get_option('folders_settings');
2917
- $post_types = is_array($post_types)?$post_types:array();
2918
  global $typenow;
2919
- if (in_array($current_type, $post_types) && in_array($action, array("add", ""))) {
2920
  $license_data = self::get_license_key_data();
2921
 
2922
  $is_active = 1;
2923
- $folders = -1;
2924
- $response['folders'] = $folders;
2925
  $response['is_key_active'] = $is_active;
2926
  }
2927
- }
2928
 
 
 
 
 
 
 
 
 
 
 
2929
  public static function get_custom_post_type($post_type)
2930
  {
2931
  if ($post_type == "post") {
@@ -2935,9 +4176,19 @@ class WCP_Folders
2935
  } else if ($post_type == "attachment") {
2936
  return "media_folder";
2937
  }
2938
- return $post_type . '_folder';
2939
- }
2940
 
 
 
 
 
 
 
 
 
 
 
 
 
2941
  public function admin_footer()
2942
  {
2943
  if (self::is_active_for_screen()) {
@@ -2950,82 +4201,114 @@ class WCP_Folders
2950
  $ttemp = self::get_tempt_posts($typenow);
2951
 
2952
  $folder_type = self::get_custom_post_type($typenow);
2953
- /* Do not change: Free/Pro Class name change */
2954
- $tree_data = WCP_Tree::get_full_tree_data($folder_type);
2955
- $terms_data = $tree_data['string'];
2956
  $sticky_string = $tree_data['sticky_string'];
2957
- $terms_html = WCP_Tree::get_option_data_for_select($folder_type);
2958
- $form_html = WCP_Forms::get_form_html($terms_html);
2959
- include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "admin-content.php";
2960
  }
2961
 
2962
  global $pagenow;
2963
- if ( 'plugins.php' !== $pagenow ) {
2964
-
2965
  } else {
2966
  if (current_user_can('manage_options')) {
2967
- include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "folder-deactivate-form.php";
2968
  }
2969
  }
2970
- }
2971
 
2972
- public function get_ttlpst($post_type = "")
 
 
 
 
 
 
 
 
 
 
2973
  {
2974
  global $typenow;
2975
  if (empty($post_type)) {
2976
  $post_type = $typenow;
2977
  }
 
2978
  $item_count = null;
2979
- if(has_filter("premio_folder_all_categorized_items")) {
2980
  $item_count = apply_filters("premio_folder_all_categorized_items", $post_type);
2981
  }
2982
- if($item_count === null) {
 
2983
  if ($post_type == "attachment") {
2984
  $item_count = wp_count_posts($post_type)->inherit;
2985
  } else {
2986
- $item_count = wp_count_posts($post_type)->publish + wp_count_posts($post_type)->draft + wp_count_posts($post_type)->future + wp_count_posts($post_type)->private;
2987
  }
2988
  }
 
2989
  return $item_count;
2990
- }
2991
 
 
 
 
 
 
 
 
 
 
 
2992
  public function autoload()
2993
  {
2994
- $files = array(
2995
- 'WCP_Tree_View' => WCP_DS . "includes" . WCP_DS . "tree.class.php",
2996
- 'WCP_Form_View' => WCP_DS . "includes" . WCP_DS . "form.class.php",
2997
- 'WCP_Folder_WPML' => WCP_DS . "includes" . WCP_DS . "class-wpml.php",
2998
- 'WCP_Folder_PolyLang' => WCP_DS . "includes" . WCP_DS . "class-polylang.php",
2999
- );
3000
 
3001
  foreach ($files as $file) {
3002
- if (file_exists(dirname(dirname(__FILE__)) . $file)) {
3003
- include_once dirname(dirname(__FILE__)) . $file;
3004
  }
3005
  }
3006
- }
3007
 
 
 
 
 
 
 
 
 
 
 
3008
  public function create_folder_terms()
3009
  {
3010
- $options = get_option('folders_settings');
3011
- $options = is_array($options)?$options:array();
3012
  $old_plugin_status = 0;
3013
- $posts = array();
3014
  if (!empty($options)) {
3015
  foreach ($options as $option) {
3016
  if (!(strpos($option, 'folder4') === false) && $old_plugin_status == 0) {
3017
  $old_plugin_status = 1;
3018
  }
3019
- if (in_array($option, array("page", "post", "attachment"))) {
 
3020
  $posts[] = str_replace("folder4", "", $option);
3021
  } else {
3022
  $posts[] = $option;
3023
  }
3024
  }
3025
- if(!empty($posts)) {
 
3026
  update_option('folders_settings', $posts);
3027
  }
3028
  }
 
3029
  if ($old_plugin_status == 1) {
3030
  update_option("folders_show_in_menu", "on");
3031
  $old_plugin_var = get_option("folder_old_plugin_status");
@@ -3033,43 +4316,44 @@ class WCP_Folders
3033
  update_option("folder_old_plugin_status", "1");
3034
  }
3035
  }
 
3036
  $posts = get_option('folders_settings');
3037
  if (!empty($posts)) {
3038
  foreach ($posts as $post_type) {
3039
- $labels = array(
3040
- 'name' => esc_html__('Folders', 'folders'),
3041
  'singular_name' => esc_html__('Folder', 'folders'),
3042
- 'all_items' => esc_html__('All Folders', 'folders'),
3043
- 'edit_item' => esc_html__('Edit Folder', 'folders'),
3044
- 'update_item' => esc_html__('Update Folder', 'folders'),
3045
- 'add_new_item' => esc_html__('Add New Folder', 'folders'),
3046
  'new_item_name' => esc_html__('Add folder name', 'folders'),
3047
- 'menu_name' => esc_html__('Folders', 'folders'),
3048
- 'search_items' => esc_html__('Search Folders', 'folders'),
3049
- 'parent_item' => esc_html__('Parent Folder', 'folders'),
3050
- );
3051
 
3052
- $args = array(
3053
- 'label' => esc_html__('Folder', 'folders'),
3054
- 'labels' => $labels,
3055
- 'show_tagcloud' => false,
3056
- 'hierarchical' => true,
3057
- 'public' => false,
3058
- 'show_ui' => true,
3059
- 'show_in_menu' => false,
3060
- 'show_in_rest' => true,
3061
- 'show_admin_column' => true,
3062
  'update_count_callback' => '_update_post_term_count',
3063
- // 'update_count_callback' => '_update_generic_term_count',
3064
- 'query_var' => true,
3065
- 'rewrite' => false,
3066
- 'capabilities' => array(
3067
  'manage_terms' => 'manage_categories',
3068
  'edit_terms' => 'manage_categories',
3069
  'delete_terms' => 'manage_categories',
3070
- 'assign_terms' => 'manage_categories'
3071
- )
3072
- );
3073
 
3074
  $folder_post_type = self::get_custom_post_type($post_type);
3075
 
@@ -3078,92 +4362,111 @@ class WCP_Folders
3078
  $post_type,
3079
  $args
3080
  );
3081
- }
3082
- }
3083
 
3084
  $postData = filter_input_array(INPUT_POST);
3085
 
3086
- if(current_user_can("manage_categories") && isset($postData['folder_nonce'])) {
3087
- if(wp_verify_nonce($postData['folder_nonce'], "folder_settings")) {
3088
  if (isset($postData['folders_show_in_menu']) && !empty($postData['folders_show_in_menu'])) {
3089
  $show_menu = "off";
3090
  if ($postData['folders_show_in_menu'] == "on") {
3091
  $show_menu = "on";
3092
  }
 
3093
  update_option("folders_show_in_menu", $show_menu);
3094
  }
3095
 
3096
  if (isset($postData['folders_settings1'])) {
3097
- $posts = array();
3098
  if (isset($postData['folders_settings']) && is_array($postData['folders_settings'])) {
3099
  foreach ($postData['folders_settings'] as $key => $val) {
3100
  $posts[] = $val;
3101
  }
3102
  }
 
3103
  update_option("folders_settings", $posts);
3104
  }
3105
 
3106
- if (isset($_POST['folders_settings1'])) {
3107
- $posts = array();
3108
- if (isset($_POST['default_folders']) && is_array($_POST['default_folders'])) {
3109
- foreach ($_POST['default_folders'] as $key => $val) {
 
 
3110
  $posts[$key] = $val;
3111
  }
3112
  }
 
3113
  update_option("default_folders", $posts);
3114
  }
3115
 
3116
- if (isset($_POST['customize_folders'])) {
3117
- $posts = array();
3118
- if (isset($_POST['customize_folders']) && is_array($_POST['customize_folders'])) {
3119
- foreach ($_POST['customize_folders'] as $key => $val) {
3120
  $posts[$key] = $val;
3121
  }
3122
  }
 
3123
  update_option("customize_folders", $posts);
3124
  }
3125
 
3126
- $setting_page = $this->getFolderSettingsURL();
3127
- if(!empty($setting_page)) {
3128
- $page = isset($_POST['tab_page'])?$_POST['tab_page']:"";
3129
- $type = filter_input(INPUT_GET, 'setting_page', FILTER_SANITIZE_STRING);
3130
- $type = empty($type)?"":"&setting_page=".$type;
3131
- $setting_page = $setting_page.$type;
3132
- if(!empty($page)) {
3133
- $setting_page .= "&setting_page=".$page;
3134
- }
3135
- wp_redirect($setting_page."&note=1");
3136
- exit;
3137
- } else if(isset($_POST['folder_page']) && !empty($_POST['folder_page'])) {
3138
- wp_redirect($_POST['folder_page']);
3139
- exit;
3140
- }
3141
- }
3142
- }
3143
 
3144
- // $old_version = get_option("folder_old_plugin_status");
3145
- // if($old_version !== false && $old_version == 1) {
3146
- // $tlfs = get_option("folder_old_plugin_folder_status");
3147
- // if($tlfs === false) {
3148
- // $total = self::ttl_fldrs();
3149
- // if($total <= 10) {
3150
- // $total = 10;
3151
- // };
3152
- // update_option("folder_old_plugin_folder_status", $total);
3153
- // self::$folders = $total;
3154
- // } else {
3155
- // self::$folders = $tlfs;
3156
- // }
3157
- // }
3158
- //
3159
- // $tlfs = get_option("folder_old_plugin_folder_status");
3160
- // if($tlfs === false) {
3161
- // self::$folders = 10;
3162
- // } else {
3163
- // self::$folders = $tlfs;
3164
- // }
3165
- }
3166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3167
  function searchForId($id, $menu)
3168
  {
3169
  if ($menu) {
@@ -3171,16 +4474,26 @@ class WCP_Folders
3171
  if (array_key_exists(2, $val)) {
3172
  $stripVal = explode('=', $val[2]);
3173
  }
 
3174
  if (array_key_exists(1, $stripVal)) {
3175
  $stripVal = $stripVal[1];
3176
  }
 
3177
  if ($stripVal === $id) {
3178
  return $key;
3179
  }
3180
  }
3181
  }
3182
- }
3183
 
 
 
 
 
 
 
 
 
 
3184
  function create_menu_for_folders()
3185
  {
3186
  global $menu;
@@ -3194,52 +4507,55 @@ class WCP_Folders
3194
  foreach ($folder_types as $type) {
3195
  $itemKey = self::searchForId($type, $menu);
3196
  switch (true) {
3197
- case ($type == 'attachment'):
3198
- $itemKey = 10;
3199
- $edit = 'upload.php';
3200
- break;
3201
- case ($type === 'post'):
3202
- $edit = 'edit.php';
3203
- $itemKey = 5;
3204
- break;
3205
- default:
3206
- $edit = 'edit.php';
3207
- break;
3208
  }
3209
 
3210
  $folder = $type == 'attachment' ? 'media' : $type;
3211
- $upper = $type == 'attachment' ? 'Media' : ucwords(str_replace(array('-', '_'), ' ', $type));
3212
  if ($type == 'page') {
3213
  $tax_slug = 'folder';
3214
  } else {
3215
- $tax_slug = $folder . '_folder';
3216
  }
3217
 
3218
-
3219
  $hide_empty = true;
3220
  if ($type == 'attachment') {
3221
  $hide_empty = false;
3222
  add_menu_page('Media Folders', 'Media Folders', 'publish_pages', "{$edit}?post_type=attachment&media_folder=", false, 'dashicons-portfolio', "{$itemKey}.5");
3223
  } else {
3224
- add_menu_page($upper . ' Folders', "{$upper} Folders", 'publish_pages', "{$edit}?post_type={$type}&type=folder", false, 'dashicons-portfolio', "{$itemKey}.5");
3225
  }
3226
 
3227
- $terms = get_terms($tax_slug, array(
3228
- 'hide_empty' => $hide_empty,
3229
- 'parent' => 0,
3230
- 'orderby' => 'meta_value_num',
3231
- 'order' => 'ASC',
 
 
3232
  'hierarchical' => false,
3233
- 'meta_query' => [[
3234
- 'key' => 'wcp_custom_order',
3235
- 'type' => 'NUMERIC',
3236
- ]]
3237
- )
 
 
3238
  );
3239
 
3240
  if ($terms) {
3241
  foreach ($terms as $term) {
3242
- if(isset($term->trash_count) && !empty($term->trash_count)) {
3243
  if ($type == 'attachment') {
3244
  add_submenu_page("{$edit}?type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type=attachment&media_folder={$term->slug}", false);
3245
  } else {
@@ -3248,21 +4564,44 @@ class WCP_Folders
3248
  }
3249
  }
3250
  }
3251
- }
3252
- }
3253
 
 
 
 
 
 
 
 
 
 
3254
  function folders_admin_styles($page)
3255
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
3256
  if (self::is_active_for_screen()) {
3257
- wp_enqueue_style('wcp-folders-fa', plugin_dir_url(dirname(__FILE__)) . 'assets/css/folder-icon.css', array(), WCP_FOLDER_VERSION);
3258
- wp_enqueue_style('wcp-folders-admin', plugin_dir_url(dirname(__FILE__)) . 'assets/css/design.min.css', array(), WCP_FOLDER_VERSION);
3259
- wp_enqueue_style('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)) . 'assets/css/jstree.min.css', array(), WCP_FOLDER_VERSION);
3260
- wp_enqueue_style('wcp-folders-mcustomscrollbar', WCP_FOLDER_URL . 'assets/css/jquery.mcustomscrollbar.min.css', array(),WCP_FOLDER_VERSION);
3261
- wp_enqueue_style('wcp-folders-css', plugin_dir_url(dirname(__FILE__)) . 'assets/css/folders.css', array(), WCP_FOLDER_VERSION);
3262
  }
3263
- if($page == "media_page_folders-media-cleaning") {
3264
- wp_enqueue_style('wcp-folders-media', plugin_dir_url(dirname(__FILE__)) . 'assets/css/media-clean.css', array(), WCP_FOLDER_VERSION);
 
3265
  }
 
3266
  wp_register_style('wcp-css-handle', false);
3267
  wp_enqueue_style('wcp-css-handle');
3268
  $css = "
@@ -3270,23 +4609,24 @@ class WCP_Folders
3270
  ";
3271
  if (self::is_active_for_screen()) {
3272
  global $typenow;
3273
- $width = get_option("wcp_dynamic_width_for_" . $typenow);
3274
  $width = esc_attr($width);
3275
  $width = intval($width);
3276
- $width = empty($width)||!is_numeric($width)?280:$width;
3277
- if($width > 1200) {
3278
  $width = 280;
3279
  }
3280
- $width = intval($width);
3281
- $display_status = "wcp_dynamic_display_status_" . $typenow;
 
3282
  $display_status = get_option($display_status);
3283
- if($display_status != "hide") {
3284
  if (!empty($width) && is_numeric($width)) {
3285
  if (function_exists('is_rtl') && is_rtl()) {
3286
- $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:" . ($width + 20) . "px}";
3287
  $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}";
3288
  } else {
3289
- $css .= "body.wp-admin #wpcontent {padding-left:" . ($width + 20) . "px}";
3290
  }
3291
  }
3292
  } else {
@@ -3297,350 +4637,479 @@ class WCP_Folders
3297
  $css .= "body.wp-admin #wpcontent {padding-left:20px}";
3298
  }
3299
  }
 
3300
  if (!empty($width) && is_numeric($width)) {
3301
- if($width > 1200) {
3302
  $width = 280;
3303
  }
 
3304
  $width = intval($width);
3305
- $css .= ".wcp-content {width: {$width}px}";
3306
  }
 
3307
  global $typenow;
3308
  $post_type = self::get_custom_post_type($typenow);
3309
- $css .= "body:not(.woocommerce-page) .wp-list-table th#taxonomy-{$post_type} { width: 130px !important; } @media screen and (max-width: 1180px) { body:not(.woocommerce-page) .wp-list-table th#taxonomy-{$post_type} { width: 90px !important; }} @media screen and (max-width: 960px) { body:not(.woocommerce-page) .wp-list-table th#taxonomy-{$post_type} { width: auto !important; }}";
3310
- }
 
3311
  wp_add_inline_style('wcp-css-handle', $css);
3312
 
3313
  if (self::is_active_for_screen()) {
3314
  global $typenow;
3315
- add_filter('views_edit-' . $typenow, array($this, 'wcp_check_for_child_folders'));
3316
  }
3317
- }
3318
 
 
 
 
 
 
 
 
 
 
 
3319
  function wcp_check_for_child_folders($content)
3320
  {
3321
  $termId = 0;
3322
  global $typenow;
3323
  $post_type = self::get_custom_post_type($typenow);
3324
- if (isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
3325
- $term = $_GET[$post_type];
3326
  $term = get_term_by("slug", $term, $post_type);
3327
  if (!empty($term)) {
3328
  $termId = $term->term_id;
3329
  }
3330
  }
3331
- $terms = get_terms($post_type, array(
3332
- 'hide_empty' => false,
3333
- 'parent' => $termId,
3334
- 'orderby' => 'meta_value_num',
3335
- 'order' => 'ASC',
3336
- 'hierarchical' => false,
3337
- 'update_count_callback' => '_update_generic_term_count',
3338
- 'meta_query' => [[
3339
- 'key' => 'wcp_custom_order',
3340
- 'type' => 'NUMERIC',
3341
- ]]
3342
- ));
3343
- $optionName = "wcp_folder_display_status_" . $typenow;
 
 
 
 
 
 
3344
  $optionValue = get_option($optionName);
3345
- $class = (!empty($optionValue) && $optionValue == "hide")?"":"active";
3346
  $customize_folders = get_option('customize_folders');
3347
- $show_in_page = isset($customize_folders['show_in_page'])?$customize_folders['show_in_page']:"hide";
3348
- if(empty($show_in_page)) {
3349
  $show_in_page = "hide";
3350
  }
3351
- if($show_in_page == "show") {
3352
- echo '<div class="tree-structure-content ' . $class . '"><div class="tree-structure" id="list-folder-' . $termId . '" data-id="' . $termId . '">';
 
3353
  echo '<ul>';
3354
  foreach ($terms as $term) {
3355
  $status = get_term_meta($term->term_id, "is_highlighted", true);
3356
  ?>
3357
  <li class="grid-view" data-id="<?php echo esc_attr($term->term_id) ?>" id="folder_<?php echo esc_attr($term->term_id) ?>">
3358
  <div class="folder-item is-folder" data-id="<?php echo esc_attr($term->term_id) ?>">
3359
- <a title='<?php echo esc_attr($term->name) ?>' id="folder_view_<?php echo esc_attr($term->term_id) ?>"
3360
- class="folder-view <?php echo ($status == 1) ? "is-high" : "" ?>"
3361
- data-id="<?php echo esc_attr($term->term_id) ?>">
3362
- <span class="folder item-name"><span id="wcp_folder_text_<?php echo esc_attr($term->term_id) ?>"
3363
- class="folder-title"><?php echo esc_attr($term->name) ?></span></span>
3364
- <!--<span class="folder-option"></span>-->
3365
  </a>
3366
  </div>
3367
  </li>
3368
- <?php
3369
  }
 
3370
  echo '</ul>';
3371
  echo '<div class="clear clearfix"></div>';
3372
  echo '</div>';
3373
  echo '<div class="folders-toggle-button"><span></span></div>';
3374
  echo '</div>';
3375
- }
3376
- if(!empty($content) && is_array($content)) {
 
 
 
 
 
 
 
 
 
 
 
 
3377
  echo '<ul class="subsubsub">';
3378
- foreach($content as $k=>$v) {
3379
- echo "<li class='{$k}'>{$v}</li>";
3380
  }
 
3381
  echo '</ul>';
3382
  }
3383
- }
3384
 
 
 
 
 
 
 
 
 
 
 
3385
  function folders_admin_scripts($hook)
3386
  {
3387
- if (self::is_active_for_screen()) {
 
 
 
 
 
 
3388
 
 
3389
  remove_filter("terms_clauses", "TO_apply_order_filter");
3390
 
3391
  global $typenow;
3392
- /* Free/Pro Version change */
3393
  wp_dequeue_script("jquery-jstree");
3394
- wp_enqueue_script('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)) . 'assets/js/jstree.min.js', array('jquery'), WCP_FOLDER_VERSION);
3395
- wp_enqueue_script('wcp-folders-mcustomscrollbar', plugin_dir_url(dirname(__FILE__)) . 'assets/js/jquery.mcustomscrollbar.min.js', array(), WCP_FOLDER_VERSION);
3396
- wp_enqueue_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)) . 'assets/js/folders.min.js', array('jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION);
3397
- wp_enqueue_script('wcp-jquery-touch', plugin_dir_url(dirname(__FILE__)) . 'assets/js/jquery.ui.touch-punch.min.js', array('jquery'), WCP_FOLDER_VERSION);
3398
 
3399
  $post_type = self::get_custom_post_type($typenow);
3400
 
3401
  if ($typenow == "attachment") {
3402
  $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
3403
  } else {
3404
- $admin_url = admin_url("edit.php?post_type=" . $typenow);
3405
- if (isset($_GET['s']) && !empty($_GET['s'])) {
3406
- $admin_url .= "&s=" . $_GET['s'];
 
3407
  }
3408
- $admin_url .= "&{$post_type}=";
 
3409
  }
3410
 
3411
  $current_url = $admin_url;
3412
- if(isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
3413
- $current_url .= $_GET[$post_type];
 
3414
  }
3415
 
3416
-
3417
  $is_active = 1;
3418
- $folders = -1;
3419
- /* For free: upgrade URL, for Pro: Register Key URL */
3420
  $register_url = $this->getFoldersUpgradeURL();
3421
 
3422
  $is_rtl = 0;
3423
- if ( function_exists( 'is_rtl' ) && is_rtl() ) {
3424
  $is_rtl = 1;
3425
  }
3426
 
3427
- $can_manage_folder = current_user_can("manage_categories")?1:0;
3428
- $width = get_option("wcp_dynamic_width_for_" . $typenow);
3429
  $width = intval($width);
3430
- $width = empty($width)||!is_numeric($width)?280:$width;
3431
- if($width > 1200) {
3432
  $width = 280;
3433
  }
3434
- $post_type = self::get_custom_post_type($typenow);
3435
- $taxonomy_status = 0;
 
3436
  $selected_taxonomy = "";
3437
- if(!isset($_GET[$post_type]) || empty($_GET[$post_type])) {
 
3438
  $taxonomy_status = 1;
3439
- } else if(isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
3440
- $selected_taxonomy = $_GET[$post_type];
3441
 
3442
  $term = get_term_by('slug', $selected_taxonomy, $post_type);
3443
  if (!empty($term) && is_object($term)) {
3444
  $selected_taxonomy = $term->term_id;
3445
  } else {
3446
  $selected_taxonomy = "";
3447
- $selected_taxonomy = "";
3448
  }
3449
  }
 
3450
  $customize_folders = get_option('customize_folders');
3451
- $show_in_page = isset($customize_folders['show_in_page'])?$customize_folders['show_in_page']:"hide";
3452
- if(empty($show_in_page)) {
3453
- $show_in_page = "hide";
3454
- }
3455
- $taxonomies = self::get_terms_hierarchical($post_type);
3456
- $use_folder_undo = !isset($customize_folders['use_folder_undo'])?"yes":$customize_folders['use_folder_undo'];
3457
- $defaultTimeout = !isset($customize_folders['default_timeout'])?5:intval($customize_folders['default_timeout']);
3458
- if(empty($defaultTimeout) || !is_numeric($defaultTimeout) || $defaultTimeout < 0) {
3459
- $defaultTimeout = 5;
3460
- }
3461
- $defaultTimeout = $defaultTimeout*1000;
3462
-
3463
- $folder_settings = array();
3464
- foreach($taxonomies as $taxonomy) {
3465
- $is_sticky = get_term_meta($taxonomy->term_id, "is_folder_sticky", true);
3466
- $is_high = get_term_meta($taxonomy->term_id, "is_highlighted", true);
3467
- $folder_settings[] = array(
3468
- 'folder_id' => $taxonomy->term_id,
3469
- 'is_sticky' => intval($is_sticky),
3470
- 'is_high' => intval($is_high),
3471
- 'nonce' => wp_create_nonce('wcp_folder_term_'.$taxonomy->term_id),
3472
- 'is_deleted' => 0,
3473
- 'slug' => $taxonomy->slug,
3474
- 'folder_count' => intval($taxonomy->trash_count)
3475
- );
3476
  }
3477
 
 
3478
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3479
 
3480
  $default_folders = get_option("default_folders");
3481
- $default_folder = "";
3482
- if(isset($default_folders["attachment"])) {
3483
  $default_folder = $default_folders["attachment"];
3484
  }
3485
- $use_shortcuts = !isset($customize_folders['use_shortcuts'])?"yes":$customize_folders['use_shortcuts'];
3486
 
3487
- $response['terms'] = $taxonomies;
3488
- $currentPage = (isset($_GET['paged']) && !empty($_GET['paged']) && is_numeric($_GET['paged']) && $_GET['paged'] > 0)?$_GET['paged']:1;
3489
- $hasStars = self::check_for_setting("has_stars", "general");
3490
- $hasChild = self::check_for_setting("has_child", "general");
3491
- $hasChild = empty($hasChild)?0:1;
3492
- $hasStars = empty($hasStars)?0:1;
3493
- wp_localize_script('wcp-folders-custom', 'wcp_settings', array(
3494
- 'ajax_url' => admin_url('admin-ajax.php'),
3495
- 'upgrade_url' => $this->getFoldersUpgradeURL(),
3496
- 'post_type' => $typenow,
3497
- 'page_url' => $admin_url,
3498
- 'current_url' => $current_url,
3499
- 'ajax_image' => plugin_dir_url(dirname(__FILE__)) . "assets/images/ajax-loader.gif",
3500
- 'is_key_active' => $is_active,
3501
- 'folders' => $folders,
3502
- 'register_url' => $register_url,
3503
- 'isRTL' => $is_rtl,
3504
- 'nonce' => wp_create_nonce('wcp_folder_nonce_'.$typenow),
3505
- 'can_manage_folder' => $can_manage_folder,
3506
- 'folder_width' => $width,
3507
- 'taxonomy_status' => $taxonomy_status,
3508
- 'selected_taxonomy' => $selected_taxonomy,
3509
- 'show_in_page' => $show_in_page,
3510
- 'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png',
3511
- 'taxonomies' => $taxonomies,
3512
- 'folder_settings' => $folder_settings,
3513
- 'hasStars' => $hasStars,
3514
- 'hasChildren' => $hasChild,
3515
- 'currentPage' => $currentPage,
3516
- 'useFolderUndo' => $use_folder_undo,
3517
- 'defaultTimeout' => $defaultTimeout,
3518
- 'default_folder' => $default_folder,
3519
- 'use_shortcuts' => $use_shortcuts
3520
- ));
 
 
 
 
 
 
 
 
 
3521
  } else {
3522
  self::is_add_update_screen();
3523
- }
3524
 
3525
- if($hook == "media-new.php") {
3526
- if(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
3527
- wp_enqueue_style( 'folders-media', WCP_FOLDER_URL . 'assets/css/new-media.css' );
3528
  $is_active = 1;
3529
- $folders = -1;
3530
-
3531
- $hasStars = self::check_for_setting("has_stars", "general");
3532
- $hasChild = self::check_for_setting("has_child", "general");
3533
- $hasChild = empty($hasChild)?0:1;
3534
- $hasStars = empty($hasStars)?0:1;
3535
-
3536
- wp_enqueue_script('wcp-folders-add-new-media', plugin_dir_url(dirname(__FILE__)) . 'assets/js/new-media.js', array('jquery'), WCP_FOLDER_VERSION);
3537
- wp_localize_script( 'wcp-folders-add-new-media', 'folders_media_options', array(
3538
- 'terms' => self::get_terms_hierarchical('media_folder'),
3539
- 'taxonomy' => get_taxonomy('media_folder'),
3540
- 'ajax_url' => admin_url("admin-ajax.php"),
3541
- 'activate_url' => $this->getFoldersUpgradeURL(),
3542
- 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
3543
- 'is_key_active' => $is_active,
3544
- 'folders' => $folders,
3545
- 'hasStars' => $hasStars,
3546
- 'hasChildren' => $hasChild
3547
- ));
3548
- }
3549
- }
3550
- }
 
 
 
 
 
3551
 
 
 
 
 
 
 
 
3552
  public function plugin_action_links($links)
3553
  {
3554
- array_unshift($links, '<a href="' . admin_url("admin.php?page=wcp_folders_settings") . '" >' . esc_html__('Settings', 'folders') . '</a>');
3555
- $links['need_help'] = '<a target="_blank" href="https://premio.io/help/folders/?utm_source=pluginspage" >'.__( 'Need help?', 'folders').'</a>';
3556
 
3557
- /* PRO link for only for FREE*/
3558
- $links['pro'] = '<a class="wcp-folder-upgrade-button" href="'.$this->getFoldersUpgradeURL().'" >'.__( 'Upgrade', 'folders').'</a>';
3559
  return $links;
3560
- }
3561
 
 
 
 
 
 
 
 
 
 
 
3562
  public static function get_instance()
3563
  {
3564
  if (empty(self::$instance)) {
3565
- /* Do not change Class name here */
3566
  self::$instance = new WCP_Folders();
3567
  }
 
3568
  return self::$instance;
3569
- }
3570
 
3571
- public function check_and_set_post_type() {
3572
- $options = get_option('folders_settings');
 
 
 
 
 
 
 
 
 
 
3573
  $old_plugin_status = 0;
3574
- $post_array = array();
3575
  if (!empty($options) && is_array($options)) {
3576
- foreach ($options as $key=>$val) {
3577
  if (!(strpos($key, 'folders4') === false) && $old_plugin_status == 0) {
3578
  $old_plugin_status = 1;
3579
  }
3580
- if (in_array($key, array("folders4page", "folders4post", "folders4attachment"))) {
 
3581
  $post_array[] = str_replace("folders4", "", $key);
3582
  }
3583
  }
3584
  } else {
3585
- $post_array = array("page", "post", "attachment");
 
 
 
 
3586
  }
 
3587
  if ($old_plugin_status == 1) {
3588
  update_option("folders_show_in_menu", "on");
3589
  $old_plugin_var = get_option("folder_old_plugin_status");
3590
  if (empty($old_plugin_var) || $old_plugin_var == null) {
3591
  update_option("folder_old_plugin_status", "1");
3592
  }
 
3593
  update_option('folders_settings', $post_array);
3594
  self::set_default_values_if_not_exists();
3595
  }
 
3596
  if (!empty($post_array) && get_option('folders_settings') === false) {
3597
  update_option('folders_settings', $post_array);
3598
  update_option("folders_show_in_menu", "off");
3599
  }
3600
- }
3601
 
 
 
 
 
 
 
 
 
 
3602
  public static function activate()
3603
  {
3604
- premio_folders_plugin_check_for_setting();
3605
  $folder_setting = get_option("folders_settings");
3606
- if($folder_setting === false) {
3607
  add_option("wcp_folder_version_267", 1);
3608
  }
 
3609
  update_option("folders_show_in_menu", "off");
3610
  $option = get_option("folder_redirect_status");
3611
- if($option === false) {
3612
  add_option("folder_intro_box", "show");
3613
  }
 
3614
  update_option("folder_redirect_status", 1);
3615
- }
3616
-
3617
- public static function deactivate() {
3618
- $customize_folders = get_option('customize_folders');
3619
- $DS = DIRECTORY_SEPARATOR;
3620
- $dirName = ABSPATH . "wp-content{$DS}plugins{$DS}folders-pro{$DS}";
3621
- $is_pro = get_option("folders_pro_is_in_process");
3622
- if(!is_dir($dirName) && $is_pro === false && isset($customize_folders['remove_folders_when_removed']) && $customize_folders['remove_folders_when_removed'] == "on") {
3623
- self::$folders = 0;
3624
- self::remove_folder_by_taxonomy("media_folder");
3625
- self::remove_folder_by_taxonomy("folder");
3626
- self::remove_folder_by_taxonomy("post_folder");
3627
- $post_types = get_post_types(array(), 'objects');
3628
- $post_array = array("page", "post", "attachment");
3629
- foreach ($post_types as $post_type) {
3630
- if (!in_array($post_type->name, $post_array)) {
3631
- self::remove_folder_by_taxonomy($post_type->name . '_folder');
3632
- }
3633
- }
3634
- delete_option('customize_folders');
3635
- delete_option('default_folders');
3636
- delete_option('folders_show_in_menu');
3637
- delete_option('folder_redirect_status');
3638
- delete_option('folders_settings');
3639
- delete_option('premio_folder_options');
3640
- delete_option('folders_settings_updated');
3641
- }
3642
- }
3643
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3644
  function folders_register_settings()
3645
  {
3646
  register_setting('folders_settings', 'folders_settings1', 'folders_settings_validate');
@@ -3650,10 +5119,10 @@ class WCP_Folders
3650
  self::check_and_set_post_type();
3651
 
3652
  $getData = filter_input_array(INPUT_GET);
3653
- if(isset($getData['hide_menu']) && $getData['hide_menu'] == "scan-files" && isset($getData['nonce'])) {
3654
- if(current_user_can('manage_options')) {
3655
  $nonce = $getData['nonce'];
3656
- if(wp_verify_nonce($nonce, "folders-scan-files")) {
3657
  $customize_folders = get_option('customize_folders');
3658
  $customize_folders['folders_media_cleaning'] = "no";
3659
  update_option("customize_folders", $customize_folders);
@@ -3669,65 +5138,119 @@ class WCP_Folders
3669
  wp_redirect(admin_url("admin.php?page=wcp_folders_settings"));
3670
  exit;
3671
  }
3672
- }
3673
 
3674
- function getFoldersUpgradeURL() {
 
 
 
 
 
 
 
 
 
 
 
3675
  $customize_folders = get_option("customize_folders");
3676
- if(isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
3677
  return admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
3678
  } else {
3679
  return admin_url("admin.php?page=folders-upgrade-to-pro");
3680
  }
3681
- }
3682
 
3683
- function getFolderSettingsURL() {
 
 
 
 
 
 
 
 
 
 
 
3684
  $customize_folders = get_option("customize_folders");
3685
- if(isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
3686
  return admin_url("options-general.php?page=wcp_folders_settings");
3687
  } else {
3688
  return admin_url("admin.php?page=wcp_folders_settings");
3689
  }
3690
- }
3691
 
3692
- function isFoldersInSettings() {
 
 
 
 
 
 
 
 
 
 
3693
  $customize_folders = get_option("customize_folders");
3694
  if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
3695
  return true;
3696
  }
 
3697
  return false;
3698
- }
3699
 
3700
- function wcp_manage_columns_head($defaults, $d = "")
 
 
 
 
 
 
 
 
 
 
3701
  {
3702
  global $typenow;
3703
- $type = $typenow;
3704
- if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
3705
- $type = self::sanitize_options($_REQUEST['post_type']);
 
 
3706
  }
3707
 
3708
  $options = get_option("folders_settings");
3709
  if (is_array($options) && in_array($type, $options)) {
3710
- $columns = array(
3711
- 'wcp_move' => '<div class="wcp-move-multiple wcp-col" title="' . esc_html__('Move selected items', 'folders') . '"><span class="dashicons dashicons-move"></span><div class="wcp-items"></div></div>',
3712
- ) + $defaults;
3713
  return $columns;
3714
  }
 
3715
  return $defaults;
3716
- }
3717
 
 
 
 
 
 
 
 
 
 
 
3718
  function wcp_manage_columns_content($column_name, $post_ID)
3719
  {
3720
  $postIDs = self::$postIds;
3721
- if(!is_array($postIDs)) {
3722
- $postIDs = array();
3723
  }
3724
- if(!in_array($post_ID, $postIDs)) {
3725
- $postIDs[] = $post_ID;
 
3726
  self::$postIds = $postIDs;
3727
  global $typenow;
3728
- $type = $typenow;
3729
- if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
3730
- $type = self::sanitize_options($_REQUEST['post_type']);
 
 
3731
  }
3732
 
3733
  $options = get_option("folders_settings");
@@ -3735,22 +5258,33 @@ class WCP_Folders
3735
  if ($column_name == 'wcp_move') {
3736
  $title = get_the_title();
3737
  if (strlen($title) > 20) {
3738
- $title = substr($title, 0, 20) . "...";
3739
  }
3740
- echo "<div class='wcp-move-file' data-id='{$post_ID}'><span class='wcp-move dashicons dashicons-move' data-id='{$post_ID}'></span><span class='wcp-item' data-object-id='{$post_ID}'>" . $title . "</span></div>";
 
3741
  }
3742
  }
3743
- }
3744
- }
3745
 
 
 
 
 
 
 
 
 
 
 
3746
  function taxonomy_archive_exclude_children($query)
3747
  {
3748
  $options = get_option("folders_settings");
3749
  if (!empty($options)) {
3750
- $taxonomy_slugs = array();
3751
  foreach ($options as $option) {
3752
  $taxonomy_slugs[] = self::get_custom_post_type($option);
3753
  }
 
3754
  if (!empty($taxonomy_slugs)) {
3755
  $i = 0;
3756
  foreach ($query->tax_query->queries as $tax_query_item) {
@@ -3760,9 +5294,18 @@ class WCP_Folders
3760
  }
3761
  }
3762
  }
3763
- }
3764
 
3765
- public function admin_menu() {
 
 
 
 
 
 
 
 
 
 
3766
  $customize_folders = get_option("customize_folders");
3767
  if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
3768
  add_options_page(
@@ -3770,7 +5313,10 @@ class WCP_Folders
3770
  esc_html__('Folders Settings', 'folders'),
3771
  'manage_options',
3772
  'wcp_folders_settings',
3773
- array($this, 'wcp_folders_settings')
 
 
 
3774
  );
3775
  } else {
3776
  $menu_slug = 'wcp_folders_settings';
@@ -3779,57 +5325,69 @@ class WCP_Folders
3779
  $page_title = esc_html__('Folders', 'folders');
3780
  $menu_title = esc_html__('Folders Settings', 'folders');
3781
  $capability = 'manage_options';
3782
- $callback = array($this, "wcp_folders_settings");
3783
- $icon_url = 'dashicons-category';
3784
- $position = 99;
 
 
 
3785
  add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $position);
3786
 
3787
  $getData = filter_input_array(INPUT_GET);
3788
- if(isset($getData['hide_folder_recommended_plugin']) && isset($getData['nonce'])) {
3789
- if(current_user_can('manage_options')) {
3790
  $nonce = $getData['nonce'];
3791
- if(wp_verify_nonce($nonce, "folder_recommended_plugin")) {
3792
- update_option('hide_folder_recommended_plugin',"1");
3793
  }
3794
  }
3795
  }
3796
 
3797
  $recommended_plugin = get_option("hide_folder_recommended_plugin");
3798
- if($recommended_plugin === false) {
3799
  add_submenu_page(
3800
  $menu_slug,
3801
  esc_html__('Recommended Plugins', 'folders'),
3802
  esc_html__('Recommended Plugins', 'folders'),
3803
  'manage_options',
3804
  'recommended-folder-plugins',
3805
- array($this, 'recommended_plugins')
 
 
 
3806
  );
3807
  }
3808
 
3809
- /* Do not Change Free/Pro Change for menu */
3810
  add_submenu_page(
3811
  $menu_slug,
3812
  esc_html__('Upgrade to Pro', 'folders'),
3813
  esc_html__('Upgrade to Pro', 'folders'),
3814
  'manage_options',
3815
  'folders-upgrade-to-pro',
3816
- array($this, 'wcp_folders_upgrade_or_register')
 
 
 
3817
  );
3818
 
3819
- /* Add menu for media cleaning */
3820
- $show_in_page = !isset($customize_folders['folders_media_cleaning'])?"yes":$customize_folders['folders_media_cleaning'];
3821
 
3822
- if($show_in_page == "yes") {
3823
  add_submenu_page(
3824
  "upload.php",
3825
  esc_html__('Media Cleaning', 'folders'),
3826
  esc_html__('Media Cleaning', 'folders'),
3827
  'manage_options',
3828
  'folders-media-cleaning',
3829
- array($this, 'wcp_folders_media_cleaning')
 
 
 
3830
  );
3831
  }
3832
- }
3833
 
3834
  self::check_and_set_post_type();
3835
 
@@ -3837,1004 +5395,1076 @@ class WCP_Folders
3837
  if ($show_menu == "on") {
3838
  self::create_menu_for_folders();
3839
  }
3840
- }
3841
 
3842
- public function wcp_folders_media_cleaning() {
3843
- include_once dirname(dirname(__FILE__)) . "/templates/admin/media-cleaning.php";
3844
- }
 
 
 
 
 
 
 
 
 
 
 
 
3845
 
3846
- public function recommended_plugins() {
3847
- include_once dirname(dirname(__FILE__)) . "/templates/admin/recommended-plugins.php";
3848
- }
3849
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3850
  public function wcp_folders_upgrade_or_register()
3851
  {
3852
  self::set_default_values_if_not_exists();
3853
- include_once dirname(dirname(__FILE__)) . "/templates/admin/upgrade-to-pro.php";
3854
- }
3855
 
 
 
 
 
 
 
 
 
 
 
3856
  public function wcp_folders_settings()
3857
  {
3858
  self::set_default_values_if_not_exists();
3859
- /* Only in Free, Get Folders update confirmation popup */
3860
  $is_shown = get_option("folder_update_message");
3861
- if($is_shown === false) {
3862
- include_once dirname(dirname(__FILE__)) . "/templates/admin/update.php";
3863
  } else {
3864
- $options = get_option('folders_settings');
3865
- $options = (empty($options) || !is_array($options)) ? array() : $options;
3866
- $post_types = get_post_types(array('public' => true), 'objects');
3867
- $terms_data = array();
3868
  foreach ($post_types as $post_type) {
3869
  if (in_array($post_type->name, $options)) {
3870
- $term = $post_type->name;
3871
- $term = self::get_custom_post_type($term);
3872
  $categories = self::get_terms_hierarchical($term);
3873
  $terms_data[$post_type->name] = $categories;
3874
  } else {
3875
- $terms_data[$post_type->name] = array();
3876
  }
3877
  }
 
3878
  $fonts = self::get_font_list();
3879
 
3880
- $plugins = new WCP_Folder_Plugins();
3881
- $plugin_info = $plugins->get_plugin_information();
3882
  $is_plugin_exists = $plugins->is_exists;
3883
- $settingURL = $this->getFolderSettingsURL();
3884
- $setting_page = isset($_GET['setting_page'])?$_GET['setting_page']:"folder-settings";
3885
- $setting_page = in_array($setting_page, array("folder-settings", "customize-folders", "folders-import", "upgrade-to-pro", "folders-by-user"))?$setting_page:"folder-settings";
 
 
 
 
3886
  $isInSettings = $this->isFoldersInSettings();
3887
 
3888
- include_once dirname(dirname(__FILE__)) . "/templates/admin/general-settings.php";
3889
 
3890
  $option = get_option("folder_intro_box");
3891
- if($option == "show") {
3892
- include_once dirname(dirname(__FILE__)) . "/templates/admin/folder-popup.php";
3893
  }
3894
- }
3895
- }
3896
 
3897
- public static function get_font_list(){
3898
- return array(
 
 
 
 
 
 
 
 
 
 
 
3899
  // System fonts.
3900
- 'Default' => 'Default',
3901
- "System Stack" => 'Default',
3902
- 'Arial' => 'Default',
3903
- 'Tahoma' => 'Default',
3904
- 'Verdana' => 'Default',
3905
- 'Helvetica' => 'Default',
3906
- 'Times New Roman' => 'Default',
3907
- 'Trebuchet MS' => 'Default',
3908
- 'Georgia' => 'Default',
3909
 
3910
  // Google Fonts (last update: 23/10/2018).
3911
- 'ABeeZee' => 'Google Fonts',
3912
- 'Abel' => 'Google Fonts',
3913
- 'Abhaya Libre' => 'Google Fonts',
3914
- 'Abril Fatface' => 'Google Fonts',
3915
- 'Aclonica' => 'Google Fonts',
3916
- 'Acme' => 'Google Fonts',
3917
- 'Actor' => 'Google Fonts',
3918
- 'Adamina' => 'Google Fonts',
3919
- 'Advent Pro' => 'Google Fonts',
3920
- 'Aguafina Script' => 'Google Fonts',
3921
- 'Akronim' => 'Google Fonts',
3922
- 'Aladin' => 'Google Fonts',
3923
- 'Aldrich' => 'Google Fonts',
3924
- 'Alef' => 'Google Fonts',
3925
- 'Alef Hebrew' => 'Google Fonts', // Hack for Google Early Access.
3926
- 'Alegreya' => 'Google Fonts',
3927
- 'Alegreya SC' => 'Google Fonts',
3928
- 'Alegreya Sans' => 'Google Fonts',
3929
- 'Alegreya Sans SC' => 'Google Fonts',
3930
- 'Alex Brush' => 'Google Fonts',
3931
- 'Alfa Slab One' => 'Google Fonts',
3932
- 'Alice' => 'Google Fonts',
3933
- 'Alike' => 'Google Fonts',
3934
- 'Alike Angular' => 'Google Fonts',
3935
- 'Allan' => 'Google Fonts',
3936
- 'Allerta' => 'Google Fonts',
3937
- 'Allerta Stencil' => 'Google Fonts',
3938
- 'Allura' => 'Google Fonts',
3939
- 'Almendra' => 'Google Fonts',
3940
- 'Almendra Display' => 'Google Fonts',
3941
- 'Almendra SC' => 'Google Fonts',
3942
- 'Amarante' => 'Google Fonts',
3943
- 'Amaranth' => 'Google Fonts',
3944
- 'Amatic SC' => 'Google Fonts',
3945
- 'Amethysta' => 'Google Fonts',
3946
- 'Amiko' => 'Google Fonts',
3947
- 'Amiri' => 'Google Fonts',
3948
- 'Amita' => 'Google Fonts',
3949
- 'Anaheim' => 'Google Fonts',
3950
- 'Andada' => 'Google Fonts',
3951
- 'Andika' => 'Google Fonts',
3952
- 'Angkor' => 'Google Fonts',
3953
- 'Annie Use Your Telescope' => 'Google Fonts',
3954
- 'Anonymous Pro' => 'Google Fonts',
3955
- 'Antic' => 'Google Fonts',
3956
- 'Antic Didone' => 'Google Fonts',
3957
- 'Antic Slab' => 'Google Fonts',
3958
- 'Anton' => 'Google Fonts',
3959
- 'Arapey' => 'Google Fonts',
3960
- 'Arbutus' => 'Google Fonts',
3961
- 'Arbutus Slab' => 'Google Fonts',
3962
- 'Architects Daughter' => 'Google Fonts',
3963
- 'Archivo' => 'Google Fonts',
3964
- 'Archivo Black' => 'Google Fonts',
3965
- 'Archivo Narrow' => 'Google Fonts',
3966
- 'Aref Ruqaa' => 'Google Fonts',
3967
- 'Arima Madurai' => 'Google Fonts',
3968
- 'Arimo' => 'Google Fonts',
3969
- 'Arizonia' => 'Google Fonts',
3970
- 'Armata' => 'Google Fonts',
3971
- 'Arsenal' => 'Google Fonts',
3972
- 'Artifika' => 'Google Fonts',
3973
- 'Arvo' => 'Google Fonts',
3974
- 'Arya' => 'Google Fonts',
3975
- 'Asap' => 'Google Fonts',
3976
- 'Asap Condensed' => 'Google Fonts',
3977
- 'Asar' => 'Google Fonts',
3978
- 'Asset' => 'Google Fonts',
3979
- 'Assistant' => 'Google Fonts',
3980
- 'Astloch' => 'Google Fonts',
3981
- 'Asul' => 'Google Fonts',
3982
- 'Athiti' => 'Google Fonts',
3983
- 'Atma' => 'Google Fonts',
3984
- 'Atomic Age' => 'Google Fonts',
3985
- 'Aubrey' => 'Google Fonts',
3986
- 'Audiowide' => 'Google Fonts',
3987
- 'Autour One' => 'Google Fonts',
3988
- 'Average' => 'Google Fonts',
3989
- 'Average Sans' => 'Google Fonts',
3990
- 'Averia Gruesa Libre' => 'Google Fonts',
3991
- 'Averia Libre' => 'Google Fonts',
3992
- 'Averia Sans Libre' => 'Google Fonts',
3993
- 'Averia Serif Libre' => 'Google Fonts',
3994
- 'Bad Script' => 'Google Fonts',
3995
- 'Bahiana' => 'Google Fonts',
3996
- 'Bai Jamjuree' => 'Google Fonts',
3997
- 'Baloo' => 'Google Fonts',
3998
- 'Baloo Bhai' => 'Google Fonts',
3999
- 'Baloo Bhaijaan' => 'Google Fonts',
4000
- 'Baloo Bhaina' => 'Google Fonts',
4001
- 'Baloo Chettan' => 'Google Fonts',
4002
- 'Baloo Da' => 'Google Fonts',
4003
- 'Baloo Paaji' => 'Google Fonts',
4004
- 'Baloo Tamma' => 'Google Fonts',
4005
- 'Baloo Tammudu' => 'Google Fonts',
4006
- 'Baloo Thambi' => 'Google Fonts',
4007
- 'Balthazar' => 'Google Fonts',
4008
- 'Bangers' => 'Google Fonts',
4009
- 'Barlow' => 'Google Fonts',
4010
- 'Barlow Condensed' => 'Google Fonts',
4011
- 'Barlow Semi Condensed' => 'Google Fonts',
4012
- 'Barrio' => 'Google Fonts',
4013
- 'Basic' => 'Google Fonts',
4014
- 'Battambang' => 'Google Fonts',
4015
- 'Baumans' => 'Google Fonts',
4016
- 'Bayon' => 'Google Fonts',
4017
- 'Belgrano' => 'Google Fonts',
4018
- 'Bellefair' => 'Google Fonts',
4019
- 'Belleza' => 'Google Fonts',
4020
- 'BenchNine' => 'Google Fonts',
4021
- 'Bentham' => 'Google Fonts',
4022
- 'Berkshire Swash' => 'Google Fonts',
4023
- 'Bevan' => 'Google Fonts',
4024
- 'Bigelow Rules' => 'Google Fonts',
4025
- 'Bigshot One' => 'Google Fonts',
4026
- 'Bilbo' => 'Google Fonts',
4027
- 'Bilbo Swash Caps' => 'Google Fonts',
4028
- 'BioRhyme' => 'Google Fonts',
4029
- 'BioRhyme Expanded' => 'Google Fonts',
4030
- 'Biryani' => 'Google Fonts',
4031
- 'Bitter' => 'Google Fonts',
4032
- 'Black And White Picture' => 'Google Fonts',
4033
- 'Black Han Sans' => 'Google Fonts',
4034
- 'Black Ops One' => 'Google Fonts',
4035
- 'Bokor' => 'Google Fonts',
4036
- 'Bonbon' => 'Google Fonts',
4037
- 'Boogaloo' => 'Google Fonts',
4038
- 'Bowlby One' => 'Google Fonts',
4039
- 'Bowlby One SC' => 'Google Fonts',
4040
- 'Brawler' => 'Google Fonts',
4041
- 'Bree Serif' => 'Google Fonts',
4042
- 'Bubblegum Sans' => 'Google Fonts',
4043
- 'Bubbler One' => 'Google Fonts',
4044
- 'Buda' => 'Google Fonts',
4045
- 'Buenard' => 'Google Fonts',
4046
- 'Bungee' => 'Google Fonts',
4047
- 'Bungee Hairline' => 'Google Fonts',
4048
- 'Bungee Inline' => 'Google Fonts',
4049
- 'Bungee Outline' => 'Google Fonts',
4050
- 'Bungee Shade' => 'Google Fonts',
4051
- 'Butcherman' => 'Google Fonts',
4052
- 'Butterfly Kids' => 'Google Fonts',
4053
- 'Cabin' => 'Google Fonts',
4054
- 'Cabin Condensed' => 'Google Fonts',
4055
- 'Cabin Sketch' => 'Google Fonts',
4056
- 'Caesar Dressing' => 'Google Fonts',
4057
- 'Cagliostro' => 'Google Fonts',
4058
- 'Cairo' => 'Google Fonts',
4059
- 'Calligraffitti' => 'Google Fonts',
4060
- 'Cambay' => 'Google Fonts',
4061
- 'Cambo' => 'Google Fonts',
4062
- 'Candal' => 'Google Fonts',
4063
- 'Cantarell' => 'Google Fonts',
4064
- 'Cantata One' => 'Google Fonts',
4065
- 'Cantora One' => 'Google Fonts',
4066
- 'Capriola' => 'Google Fonts',
4067
- 'Cardo' => 'Google Fonts',
4068
- 'Carme' => 'Google Fonts',
4069
- 'Carrois Gothic' => 'Google Fonts',
4070
- 'Carrois Gothic SC' => 'Google Fonts',
4071
- 'Carter One' => 'Google Fonts',
4072
- 'Catamaran' => 'Google Fonts',
4073
- 'Caudex' => 'Google Fonts',
4074
- 'Caveat' => 'Google Fonts',
4075
- 'Caveat Brush' => 'Google Fonts',
4076
- 'Cedarville Cursive' => 'Google Fonts',
4077
- 'Ceviche One' => 'Google Fonts',
4078
- 'Chakra Petch' => 'Google Fonts',
4079
- 'Changa' => 'Google Fonts',
4080
- 'Changa One' => 'Google Fonts',
4081
- 'Chango' => 'Google Fonts',
4082
- 'Charmonman' => 'Google Fonts',
4083
- 'Chathura' => 'Google Fonts',
4084
- 'Chau Philomene One' => 'Google Fonts',
4085
- 'Chela One' => 'Google Fonts',
4086
- 'Chelsea Market' => 'Google Fonts',
4087
- 'Chenla' => 'Google Fonts',
4088
- 'Cherry Cream Soda' => 'Google Fonts',
4089
- 'Cherry Swash' => 'Google Fonts',
4090
- 'Chewy' => 'Google Fonts',
4091
- 'Chicle' => 'Google Fonts',
4092
- 'Chivo' => 'Google Fonts',
4093
- 'Chonburi' => 'Google Fonts',
4094
- 'Cinzel' => 'Google Fonts',
4095
- 'Cinzel Decorative' => 'Google Fonts',
4096
- 'Clicker Script' => 'Google Fonts',
4097
- 'Coda' => 'Google Fonts',
4098
- 'Coda Caption' => 'Google Fonts',
4099
- 'Codystar' => 'Google Fonts',
4100
- 'Coiny' => 'Google Fonts',
4101
- 'Combo' => 'Google Fonts',
4102
- 'Comfortaa' => 'Google Fonts',
4103
- 'Coming Soon' => 'Google Fonts',
4104
- 'Concert One' => 'Google Fonts',
4105
- 'Condiment' => 'Google Fonts',
4106
- 'Content' => 'Google Fonts',
4107
- 'Contrail One' => 'Google Fonts',
4108
- 'Convergence' => 'Google Fonts',
4109
- 'Cookie' => 'Google Fonts',
4110
- 'Copse' => 'Google Fonts',
4111
- 'Corben' => 'Google Fonts',
4112
- 'Cormorant' => 'Google Fonts',
4113
- 'Cormorant Garamond' => 'Google Fonts',
4114
- 'Cormorant Infant' => 'Google Fonts',
4115
- 'Cormorant SC' => 'Google Fonts',
4116
- 'Cormorant Unicase' => 'Google Fonts',
4117
- 'Cormorant Upright' => 'Google Fonts',
4118
- 'Courgette' => 'Google Fonts',
4119
- 'Cousine' => 'Google Fonts',
4120
- 'Coustard' => 'Google Fonts',
4121
- 'Covered By Your Grace' => 'Google Fonts',
4122
- 'Crafty Girls' => 'Google Fonts',
4123
- 'Creepster' => 'Google Fonts',
4124
- 'Crete Round' => 'Google Fonts',
4125
- 'Crimson Text' => 'Google Fonts',
4126
- 'Croissant One' => 'Google Fonts',
4127
- 'Crushed' => 'Google Fonts',
4128
- 'Cuprum' => 'Google Fonts',
4129
- 'Cute Font' => 'Google Fonts',
4130
- 'Cutive' => 'Google Fonts',
4131
- 'Cutive Mono' => 'Google Fonts',
4132
- 'Damion' => 'Google Fonts',
4133
- 'Dancing Script' => 'Google Fonts',
4134
- 'Dangrek' => 'Google Fonts',
4135
- 'David Libre' => 'Google Fonts',
4136
- 'Dawning of a New Day' => 'Google Fonts',
4137
- 'Days One' => 'Google Fonts',
4138
- 'Dekko' => 'Google Fonts',
4139
- 'Delius' => 'Google Fonts',
4140
- 'Delius Swash Caps' => 'Google Fonts',
4141
- 'Delius Unicase' => 'Google Fonts',
4142
- 'Della Respira' => 'Google Fonts',
4143
- 'Denk One' => 'Google Fonts',
4144
- 'Devonshire' => 'Google Fonts',
4145
- 'Dhurjati' => 'Google Fonts',
4146
- 'Didact Gothic' => 'Google Fonts',
4147
- 'Diplomata' => 'Google Fonts',
4148
- 'Diplomata SC' => 'Google Fonts',
4149
- 'Do Hyeon' => 'Google Fonts',
4150
- 'Dokdo' => 'Google Fonts',
4151
- 'Domine' => 'Google Fonts',
4152
- 'Donegal One' => 'Google Fonts',
4153
- 'Doppio One' => 'Google Fonts',
4154
- 'Dorsa' => 'Google Fonts',
4155
- 'Dosis' => 'Google Fonts',
4156
- 'Dr Sugiyama' => 'Google Fonts',
4157
- 'Droid Arabic Kufi' => 'Google Fonts', // Hack for Google Early Access.
4158
- 'Droid Arabic Naskh' => 'Google Fonts', // Hack for Google Early Access.
4159
- 'Duru Sans' => 'Google Fonts',
4160
- 'Dynalight' => 'Google Fonts',
4161
- 'EB Garamond' => 'Google Fonts',
4162
- 'Eagle Lake' => 'Google Fonts',
4163
- 'East Sea Dokdo' => 'Google Fonts',
4164
- 'Eater' => 'Google Fonts',
4165
- 'Economica' => 'Google Fonts',
4166
- 'Eczar' => 'Google Fonts',
4167
- 'El Messiri' => 'Google Fonts',
4168
- 'Electrolize' => 'Google Fonts',
4169
- 'Elsie' => 'Google Fonts',
4170
- 'Elsie Swash Caps' => 'Google Fonts',
4171
- 'Emblema One' => 'Google Fonts',
4172
- 'Emilys Candy' => 'Google Fonts',
4173
- 'Encode Sans' => 'Google Fonts',
4174
- 'Encode Sans Condensed' => 'Google Fonts',
4175
- 'Encode Sans Expanded' => 'Google Fonts',
4176
- 'Encode Sans Semi Condensed' => 'Google Fonts',
4177
- 'Encode Sans Semi Expanded' => 'Google Fonts',
4178
- 'Engagement' => 'Google Fonts',
4179
- 'Englebert' => 'Google Fonts',
4180
- 'Enriqueta' => 'Google Fonts',
4181
- 'Erica One' => 'Google Fonts',
4182
- 'Esteban' => 'Google Fonts',
4183
- 'Euphoria Script' => 'Google Fonts',
4184
- 'Ewert' => 'Google Fonts',
4185
- 'Exo' => 'Google Fonts',
4186
- 'Exo 2' => 'Google Fonts',
4187
- 'Expletus Sans' => 'Google Fonts',
4188
- 'Fahkwang' => 'Google Fonts',
4189
- 'Fanwood Text' => 'Google Fonts',
4190
- 'Farsan' => 'Google Fonts',
4191
- 'Fascinate' => 'Google Fonts',
4192
- 'Fascinate Inline' => 'Google Fonts',
4193
- 'Faster One' => 'Google Fonts',
4194
- 'Fasthand' => 'Google Fonts',
4195
- 'Fauna One' => 'Google Fonts',
4196
- 'Faustina' => 'Google Fonts',
4197
- 'Federant' => 'Google Fonts',
4198
- 'Federo' => 'Google Fonts',
4199
- 'Felipa' => 'Google Fonts',
4200
- 'Fenix' => 'Google Fonts',
4201
- 'Finger Paint' => 'Google Fonts',
4202
- 'Fira Mono' => 'Google Fonts',
4203
- 'Fira Sans' => 'Google Fonts',
4204
- 'Fira Sans Condensed' => 'Google Fonts',
4205
- 'Fira Sans Extra Condensed' => 'Google Fonts',
4206
- 'Fjalla One' => 'Google Fonts',
4207
- 'Fjord One' => 'Google Fonts',
4208
- 'Flamenco' => 'Google Fonts',
4209
- 'Flavors' => 'Google Fonts',
4210
- 'Fondamento' => 'Google Fonts',
4211
- 'Fontdiner Swanky' => 'Google Fonts',
4212
- 'Forum' => 'Google Fonts',
4213
- 'Francois One' => 'Google Fonts',
4214
- 'Frank Ruhl Libre' => 'Google Fonts',
4215
- 'Freckle Face' => 'Google Fonts',
4216
- 'Fredericka the Great' => 'Google Fonts',
4217
- 'Fredoka One' => 'Google Fonts',
4218
- 'Freehand' => 'Google Fonts',
4219
- 'Fresca' => 'Google Fonts',
4220
- 'Frijole' => 'Google Fonts',
4221
- 'Fruktur' => 'Google Fonts',
4222
- 'Fugaz One' => 'Google Fonts',
4223
- 'GFS Didot' => 'Google Fonts',
4224
- 'GFS Neohellenic' => 'Google Fonts',
4225
- 'Gabriela' => 'Google Fonts',
4226
- 'Gaegu' => 'Google Fonts',
4227
- 'Gafata' => 'Google Fonts',
4228
- 'Galada' => 'Google Fonts',
4229
- 'Galdeano' => 'Google Fonts',
4230
- 'Galindo' => 'Google Fonts',
4231
- 'Gamja Flower' => 'Google Fonts',
4232
- 'Gentium Basic' => 'Google Fonts',
4233
- 'Gentium Book Basic' => 'Google Fonts',
4234
- 'Geo' => 'Google Fonts',
4235
- 'Geostar' => 'Google Fonts',
4236
- 'Geostar Fill' => 'Google Fonts',
4237
- 'Germania One' => 'Google Fonts',
4238
- 'Gidugu' => 'Google Fonts',
4239
- 'Gilda Display' => 'Google Fonts',
4240
- 'Give You Glory' => 'Google Fonts',
4241
- 'Glass Antiqua' => 'Google Fonts',
4242
- 'Glegoo' => 'Google Fonts',
4243
- 'Gloria Hallelujah' => 'Google Fonts',
4244
- 'Goblin One' => 'Google Fonts',
4245
- 'Gochi Hand' => 'Google Fonts',
4246
- 'Gorditas' => 'Google Fonts',
4247
- 'Gothic A1' => 'Google Fonts',
4248
- 'Goudy Bookletter 1911' => 'Google Fonts',
4249
- 'Graduate' => 'Google Fonts',
4250
- 'Grand Hotel' => 'Google Fonts',
4251
- 'Gravitas One' => 'Google Fonts',
4252
- 'Great Vibes' => 'Google Fonts',
4253
- 'Griffy' => 'Google Fonts',
4254
- 'Gruppo' => 'Google Fonts',
4255
- 'Gudea' => 'Google Fonts',
4256
- 'Gugi' => 'Google Fonts',
4257
- 'Gurajada' => 'Google Fonts',
4258
- 'Habibi' => 'Google Fonts',
4259
- 'Halant' => 'Google Fonts',
4260
- 'Hammersmith One' => 'Google Fonts',
4261
- 'Hanalei' => 'Google Fonts',
4262
- 'Hanalei Fill' => 'Google Fonts',
4263
- 'Handlee' => 'Google Fonts',
4264
- 'Hanuman' => 'Google Fonts',
4265
- 'Happy Monkey' => 'Google Fonts',
4266
- 'Harmattan' => 'Google Fonts',
4267
- 'Headland One' => 'Google Fonts',
4268
- 'Heebo' => 'Google Fonts',
4269
- 'Henny Penny' => 'Google Fonts',
4270
- 'Herr Von Muellerhoff' => 'Google Fonts',
4271
- 'Hi Melody' => 'Google Fonts',
4272
- 'Hind' => 'Google Fonts',
4273
- 'Hind Guntur' => 'Google Fonts',
4274
- 'Hind Madurai' => 'Google Fonts',
4275
- 'Hind Siliguri' => 'Google Fonts',
4276
- 'Hind Vadodara' => 'Google Fonts',
4277
- 'Holtwood One SC' => 'Google Fonts',
4278
- 'Homemade Apple' => 'Google Fonts',
4279
- 'Homenaje' => 'Google Fonts',
4280
- 'IBM Plex Mono' => 'Google Fonts',
4281
- 'IBM Plex Sans' => 'Google Fonts',
4282
- 'IBM Plex Sans Condensed' => 'Google Fonts',
4283
- 'IBM Plex Serif' => 'Google Fonts',
4284
- 'IM Fell DW Pica' => 'Google Fonts',
4285
- 'IM Fell DW Pica SC' => 'Google Fonts',
4286
- 'IM Fell Double Pica' => 'Google Fonts',
4287
- 'IM Fell Double Pica SC' => 'Google Fonts',
4288
- 'IM Fell English' => 'Google Fonts',
4289
- 'IM Fell English SC' => 'Google Fonts',
4290
- 'IM Fell French Canon' => 'Google Fonts',
4291
- 'IM Fell French Canon SC' => 'Google Fonts',
4292
- 'IM Fell Great Primer' => 'Google Fonts',
4293
- 'IM Fell Great Primer SC' => 'Google Fonts',
4294
- 'Iceberg' => 'Google Fonts',
4295
- 'Iceland' => 'Google Fonts',
4296
- 'Imprima' => 'Google Fonts',
4297
- 'Inconsolata' => 'Google Fonts',
4298
- 'Inder' => 'Google Fonts',
4299
- 'Indie Flower' => 'Google Fonts',
4300
- 'Inika' => 'Google Fonts',
4301
- 'Inknut Antiqua' => 'Google Fonts',
4302
- 'Irish Grover' => 'Google Fonts',
4303
- 'Istok Web' => 'Google Fonts',
4304
- 'Italiana' => 'Google Fonts',
4305
- 'Italianno' => 'Google Fonts',
4306
- 'Itim' => 'Google Fonts',
4307
- 'Jacques Francois' => 'Google Fonts',
4308
- 'Jacques Francois Shadow' => 'Google Fonts',
4309
- 'Jaldi' => 'Google Fonts',
4310
- 'Jim Nightshade' => 'Google Fonts',
4311
- 'Jockey One' => 'Google Fonts',
4312
- 'Jolly Lodger' => 'Google Fonts',
4313
- 'Jomhuria' => 'Google Fonts',
4314
- 'Josefin Sans' => 'Google Fonts',
4315
- 'Josefin Slab' => 'Google Fonts',
4316
- 'Joti One' => 'Google Fonts',
4317
- 'Jua' => 'Google Fonts',
4318
- 'Judson' => 'Google Fonts',
4319
- 'Julee' => 'Google Fonts',
4320
- 'Julius Sans One' => 'Google Fonts',
4321
- 'Junge' => 'Google Fonts',
4322
- 'Jura' => 'Google Fonts',
4323
- 'Just Another Hand' => 'Google Fonts',
4324
- 'Just Me Again Down Here' => 'Google Fonts',
4325
- 'K2D' => 'Google Fonts',
4326
- 'Kadwa' => 'Google Fonts',
4327
- 'Kalam' => 'Google Fonts',
4328
- 'Kameron' => 'Google Fonts',
4329
- 'Kanit' => 'Google Fonts',
4330
- 'Kantumruy' => 'Google Fonts',
4331
- 'Karla' => 'Google Fonts',
4332
- 'Karma' => 'Google Fonts',
4333
- 'Katibeh' => 'Google Fonts',
4334
- 'Kaushan Script' => 'Google Fonts',
4335
- 'Kavivanar' => 'Google Fonts',
4336
- 'Kavoon' => 'Google Fonts',
4337
- 'Kdam Thmor' => 'Google Fonts',
4338
- 'Keania One' => 'Google Fonts',
4339
- 'Kelly Slab' => 'Google Fonts',
4340
- 'Kenia' => 'Google Fonts',
4341
- 'Khand' => 'Google Fonts',
4342
- 'Khmer' => 'Google Fonts',
4343
- 'Khula' => 'Google Fonts',
4344
- 'Kirang Haerang' => 'Google Fonts',
4345
- 'Kite One' => 'Google Fonts',
4346
- 'Knewave' => 'Google Fonts',
4347
- 'KoHo' => 'Google Fonts',
4348
- 'Kodchasan' => 'Google Fonts',
4349
- 'Kosugi' => 'Google Fonts',
4350
- 'Kosugi Maru' => 'Google Fonts',
4351
- 'Kotta One' => 'Google Fonts',
4352
- 'Koulen' => 'Google Fonts',
4353
- 'Kranky' => 'Google Fonts',
4354
- 'Kreon' => 'Google Fonts',
4355
- 'Kristi' => 'Google Fonts',
4356
- 'Krona One' => 'Google Fonts',
4357
- 'Krub' => 'Google Fonts',
4358
- 'Kumar One' => 'Google Fonts',
4359
- 'Kumar One Outline' => 'Google Fonts',
4360
- 'Kurale' => 'Google Fonts',
4361
- 'La Belle Aurore' => 'Google Fonts',
4362
- 'Laila' => 'Google Fonts',
4363
- 'Lakki Reddy' => 'Google Fonts',
4364
- 'Lalezar' => 'Google Fonts',
4365
- 'Lancelot' => 'Google Fonts',
4366
- 'Lateef' => 'Google Fonts',
4367
- 'Lato' => 'Google Fonts',
4368
- 'League Script' => 'Google Fonts',
4369
- 'Leckerli One' => 'Google Fonts',
4370
- 'Ledger' => 'Google Fonts',
4371
- 'Lekton' => 'Google Fonts',
4372
- 'Lemon' => 'Google Fonts',
4373
- 'Lemonada' => 'Google Fonts',
4374
- 'Libre Barcode 128' => 'Google Fonts',
4375
- 'Libre Barcode 128 Text' => 'Google Fonts',
4376
- 'Libre Barcode 39' => 'Google Fonts',
4377
- 'Libre Barcode 39 Extended' => 'Google Fonts',
 
 
 
4378
  'Libre Barcode 39 Extended Text' => 'Google Fonts',
4379
- 'Libre Barcode 39 Text' => 'Google Fonts',
4380
- 'Libre Baskerville' => 'Google Fonts',
4381
- 'Libre Franklin' => 'Google Fonts',
4382
- 'Life Savers' => 'Google Fonts',
4383
- 'Lilita One' => 'Google Fonts',
4384
- 'Lily Script One' => 'Google Fonts',
4385
- 'Limelight' => 'Google Fonts',
4386
- 'Linden Hill' => 'Google Fonts',
4387
- 'Lobster' => 'Google Fonts',
4388
- 'Lobster Two' => 'Google Fonts',
4389
- 'Londrina Outline' => 'Google Fonts',
4390
- 'Londrina Shadow' => 'Google Fonts',
4391
- 'Londrina Sketch' => 'Google Fonts',
4392
- 'Londrina Solid' => 'Google Fonts',
4393
- 'Lora' => 'Google Fonts',
4394
- 'Love Ya Like A Sister' => 'Google Fonts',
4395
- 'Loved by the King' => 'Google Fonts',
4396
- 'Lovers Quarrel' => 'Google Fonts',
4397
- 'Luckiest Guy' => 'Google Fonts',
4398
- 'Lusitana' => 'Google Fonts',
4399
- 'Lustria' => 'Google Fonts',
4400
- 'M PLUS 1p' => 'Google Fonts',
4401
- 'M PLUS Rounded 1c' => 'Google Fonts',
4402
- 'Macondo' => 'Google Fonts',
4403
- 'Macondo Swash Caps' => 'Google Fonts',
4404
- 'Mada' => 'Google Fonts',
4405
- 'Magra' => 'Google Fonts',
4406
- 'Maiden Orange' => 'Google Fonts',
4407
- 'Maitree' => 'Google Fonts',
4408
- 'Mako' => 'Google Fonts',
4409
- 'Mali' => 'Google Fonts',
4410
- 'Mallanna' => 'Google Fonts',
4411
- 'Mandali' => 'Google Fonts',
4412
- 'Manuale' => 'Google Fonts',
4413
- 'Marcellus' => 'Google Fonts',
4414
- 'Marcellus SC' => 'Google Fonts',
4415
- 'Marck Script' => 'Google Fonts',
4416
- 'Margarine' => 'Google Fonts',
4417
- 'Markazi Text' => 'Google Fonts',
4418
- 'Marko One' => 'Google Fonts',
4419
- 'Marmelad' => 'Google Fonts',
4420
- 'Martel' => 'Google Fonts',
4421
- 'Martel Sans' => 'Google Fonts',
4422
- 'Marvel' => 'Google Fonts',
4423
- 'Mate' => 'Google Fonts',
4424
- 'Mate SC' => 'Google Fonts',
4425
- 'Maven Pro' => 'Google Fonts',
4426
- 'McLaren' => 'Google Fonts',
4427
- 'Meddon' => 'Google Fonts',
4428
- 'MedievalSharp' => 'Google Fonts',
4429
- 'Medula One' => 'Google Fonts',
4430
- 'Meera Inimai' => 'Google Fonts',
4431
- 'Megrim' => 'Google Fonts',
4432
- 'Meie Script' => 'Google Fonts',
4433
- 'Merienda' => 'Google Fonts',
4434
- 'Merienda One' => 'Google Fonts',
4435
- 'Merriweather' => 'Google Fonts',
4436
- 'Merriweather Sans' => 'Google Fonts',
4437
- 'Metal' => 'Google Fonts',
4438
- 'Metal Mania' => 'Google Fonts',
4439
- 'Metamorphous' => 'Google Fonts',
4440
- 'Metrophobic' => 'Google Fonts',
4441
- 'Michroma' => 'Google Fonts',
4442
- 'Milonga' => 'Google Fonts',
4443
- 'Miltonian' => 'Google Fonts',
4444
- 'Miltonian Tattoo' => 'Google Fonts',
4445
- 'Mina' => 'Google Fonts',
4446
- 'Miniver' => 'Google Fonts',
4447
- 'Miriam Libre' => 'Google Fonts',
4448
- 'Mirza' => 'Google Fonts',
4449
- 'Miss Fajardose' => 'Google Fonts',
4450
- 'Mitr' => 'Google Fonts',
4451
- 'Modak' => 'Google Fonts',
4452
- 'Modern Antiqua' => 'Google Fonts',
4453
- 'Mogra' => 'Google Fonts',
4454
- 'Molengo' => 'Google Fonts',
4455
- 'Molle' => 'Google Fonts',
4456
- 'Monda' => 'Google Fonts',
4457
- 'Monofett' => 'Google Fonts',
4458
- 'Monoton' => 'Google Fonts',
4459
- 'Monsieur La Doulaise' => 'Google Fonts',
4460
- 'Montaga' => 'Google Fonts',
4461
- 'Montez' => 'Google Fonts',
4462
- 'Montserrat' => 'Google Fonts',
4463
- 'Montserrat Alternates' => 'Google Fonts',
4464
- 'Montserrat Subrayada' => 'Google Fonts',
4465
- 'Moul' => 'Google Fonts',
4466
- 'Moulpali' => 'Google Fonts',
4467
- 'Mountains of Christmas' => 'Google Fonts',
4468
- 'Mouse Memoirs' => 'Google Fonts',
4469
- 'Mr Bedfort' => 'Google Fonts',
4470
- 'Mr Dafoe' => 'Google Fonts',
4471
- 'Mr De Haviland' => 'Google Fonts',
4472
- 'Mrs Saint Delafield' => 'Google Fonts',
4473
- 'Mrs Sheppards' => 'Google Fonts',
4474
- 'Mukta' => 'Google Fonts',
4475
- 'Mukta Mahee' => 'Google Fonts',
4476
- 'Mukta Malar' => 'Google Fonts',
4477
- 'Mukta Vaani' => 'Google Fonts',
4478
- 'Muli' => 'Google Fonts',
4479
- 'Mystery Quest' => 'Google Fonts',
4480
- 'NTR' => 'Google Fonts',
4481
- 'Nanum Brush Script' => 'Google Fonts',
4482
- 'Nanum Gothic' => 'Google Fonts',
4483
- 'Nanum Gothic Coding' => 'Google Fonts',
4484
- 'Nanum Myeongjo' => 'Google Fonts',
4485
- 'Nanum Pen Script' => 'Google Fonts',
4486
- 'Neucha' => 'Google Fonts',
4487
- 'Neuton' => 'Google Fonts',
4488
- 'New Rocker' => 'Google Fonts',
4489
- 'News Cycle' => 'Google Fonts',
4490
- 'Niconne' => 'Google Fonts',
4491
- 'Niramit' => 'Google Fonts',
4492
- 'Nixie One' => 'Google Fonts',
4493
- 'Nobile' => 'Google Fonts',
4494
- 'Nokora' => 'Google Fonts',
4495
- 'Norican' => 'Google Fonts',
4496
- 'Nosifer' => 'Google Fonts',
4497
- 'Notable' => 'Google Fonts',
4498
- 'Nothing You Could Do' => 'Google Fonts',
4499
- 'Noticia Text' => 'Google Fonts',
4500
- 'Noto Kufi Arabic' => 'Google Fonts', // Hack for Google Early Access.
4501
- 'Noto Naskh Arabic' => 'Google Fonts', // Hack for Google Early Access.
4502
- 'Noto Sans' => 'Google Fonts',
4503
- 'Noto Sans Hebrew' => 'Google Fonts', // Hack for Google Early Access.
4504
- 'Noto Sans JP' => 'Google Fonts',
4505
- 'Noto Sans KR' => 'Google Fonts',
4506
- 'Noto Serif' => 'Google Fonts',
4507
- 'Noto Serif JP' => 'Google Fonts',
4508
- 'Noto Serif KR' => 'Google Fonts',
4509
- 'Nova Cut' => 'Google Fonts',
4510
- 'Nova Flat' => 'Google Fonts',
4511
- 'Nova Mono' => 'Google Fonts',
4512
- 'Nova Oval' => 'Google Fonts',
4513
- 'Nova Round' => 'Google Fonts',
4514
- 'Nova Script' => 'Google Fonts',
4515
- 'Nova Slim' => 'Google Fonts',
4516
- 'Nova Square' => 'Google Fonts',
4517
- 'Numans' => 'Google Fonts',
4518
- 'Nunito' => 'Google Fonts',
4519
- 'Nunito Sans' => 'Google Fonts',
4520
- 'Odor Mean Chey' => 'Google Fonts',
4521
- 'Offside' => 'Google Fonts',
4522
- 'Old Standard TT' => 'Google Fonts',
4523
- 'Oldenburg' => 'Google Fonts',
4524
- 'Oleo Script' => 'Google Fonts',
4525
- 'Oleo Script Swash Caps' => 'Google Fonts',
4526
- 'Open Sans' => 'Google Fonts',
4527
- 'Open Sans Condensed' => 'Google Fonts',
4528
- 'Open Sans Hebrew' => 'Google Fonts', // Hack for Google Early Access.
4529
- 'Open Sans Hebrew Condensed' => 'Google Fonts', // Hack for Google Early Access.
4530
- 'Oranienbaum' => 'Google Fonts',
4531
- 'Orbitron' => 'Google Fonts',
4532
- 'Oregano' => 'Google Fonts',
4533
- 'Orienta' => 'Google Fonts',
4534
- 'Original Surfer' => 'Google Fonts',
4535
- 'Oswald' => 'Google Fonts',
4536
- 'Over the Rainbow' => 'Google Fonts',
4537
- 'Overlock' => 'Google Fonts',
4538
- 'Overlock SC' => 'Google Fonts',
4539
- 'Overpass' => 'Google Fonts',
4540
- 'Overpass Mono' => 'Google Fonts',
4541
- 'Ovo' => 'Google Fonts',
4542
- 'Oxygen' => 'Google Fonts',
4543
- 'Oxygen Mono' => 'Google Fonts',
4544
- 'PT Mono' => 'Google Fonts',
4545
- 'PT Sans' => 'Google Fonts',
4546
- 'PT Sans Caption' => 'Google Fonts',
4547
- 'PT Sans Narrow' => 'Google Fonts',
4548
- 'PT Serif' => 'Google Fonts',
4549
- 'PT Serif Caption' => 'Google Fonts',
4550
- 'Pacifico' => 'Google Fonts',
4551
- 'Padauk' => 'Google Fonts',
4552
- 'Palanquin' => 'Google Fonts',
4553
- 'Palanquin Dark' => 'Google Fonts',
4554
- 'Pangolin' => 'Google Fonts',
4555
- 'Paprika' => 'Google Fonts',
4556
- 'Parisienne' => 'Google Fonts',
4557
- 'Passero One' => 'Google Fonts',
4558
- 'Passion One' => 'Google Fonts',
4559
- 'Pathway Gothic One' => 'Google Fonts',
4560
- 'Patrick Hand' => 'Google Fonts',
4561
- 'Patrick Hand SC' => 'Google Fonts',
4562
- 'Pattaya' => 'Google Fonts',
4563
- 'Patua One' => 'Google Fonts',
4564
- 'Pavanam' => 'Google Fonts',
4565
- 'Paytone One' => 'Google Fonts',
4566
- 'Peddana' => 'Google Fonts',
4567
- 'Peralta' => 'Google Fonts',
4568
- 'Permanent Marker' => 'Google Fonts',
4569
- 'Petit Formal Script' => 'Google Fonts',
4570
- 'Petrona' => 'Google Fonts',
4571
- 'Philosopher' => 'Google Fonts',
4572
- 'Piedra' => 'Google Fonts',
4573
- 'Pinyon Script' => 'Google Fonts',
4574
- 'Pirata One' => 'Google Fonts',
4575
- 'Plaster' => 'Google Fonts',
4576
- 'Play' => 'Google Fonts',
4577
- 'Playball' => 'Google Fonts',
4578
- 'Playfair Display' => 'Google Fonts',
4579
- 'Playfair Display SC' => 'Google Fonts',
4580
- 'Podkova' => 'Google Fonts',
4581
- 'Poiret One' => 'Google Fonts',
4582
- 'Poller One' => 'Google Fonts',
4583
- 'Poly' => 'Google Fonts',
4584
- 'Pompiere' => 'Google Fonts',
4585
- 'Pontano Sans' => 'Google Fonts',
4586
- 'Poor Story' => 'Google Fonts',
4587
- 'Poppins' => 'Google Fonts',
4588
- 'Port Lligat Sans' => 'Google Fonts',
4589
- 'Port Lligat Slab' => 'Google Fonts',
4590
- 'Pragati Narrow' => 'Google Fonts',
4591
- 'Prata' => 'Google Fonts',
4592
- 'Preahvihear' => 'Google Fonts',
4593
- 'Press Start 2P' => 'Google Fonts',
4594
- 'Pridi' => 'Google Fonts',
4595
- 'Princess Sofia' => 'Google Fonts',
4596
- 'Prociono' => 'Google Fonts',
4597
- 'Prompt' => 'Google Fonts',
4598
- 'Prosto One' => 'Google Fonts',
4599
- 'Proza Libre' => 'Google Fonts',
4600
- 'Puritan' => 'Google Fonts',
4601
- 'Purple Purse' => 'Google Fonts',
4602
- 'Quando' => 'Google Fonts',
4603
- 'Quantico' => 'Google Fonts',
4604
- 'Quattrocento' => 'Google Fonts',
4605
- 'Quattrocento Sans' => 'Google Fonts',
4606
- 'Questrial' => 'Google Fonts',
4607
- 'Quicksand' => 'Google Fonts',
4608
- 'Quintessential' => 'Google Fonts',
4609
- 'Qwigley' => 'Google Fonts',
4610
- 'Racing Sans One' => 'Google Fonts',
4611
- 'Radley' => 'Google Fonts',
4612
- 'Rajdhani' => 'Google Fonts',
4613
- 'Rakkas' => 'Google Fonts',
4614
- 'Raleway' => 'Google Fonts',
4615
- 'Raleway Dots' => 'Google Fonts',
4616
- 'Ramabhadra' => 'Google Fonts',
4617
- 'Ramaraja' => 'Google Fonts',
4618
- 'Rambla' => 'Google Fonts',
4619
- 'Rammetto One' => 'Google Fonts',
4620
- 'Ranchers' => 'Google Fonts',
4621
- 'Rancho' => 'Google Fonts',
4622
- 'Ranga' => 'Google Fonts',
4623
- 'Rasa' => 'Google Fonts',
4624
- 'Rationale' => 'Google Fonts',
4625
- 'Ravi Prakash' => 'Google Fonts',
4626
- 'Redressed' => 'Google Fonts',
4627
- 'Reem Kufi' => 'Google Fonts',
4628
- 'Reenie Beanie' => 'Google Fonts',
4629
- 'Revalia' => 'Google Fonts',
4630
- 'Rhodium Libre' => 'Google Fonts',
4631
- 'Ribeye' => 'Google Fonts',
4632
- 'Ribeye Marrow' => 'Google Fonts',
4633
- 'Righteous' => 'Google Fonts',
4634
- 'Risque' => 'Google Fonts',
4635
- 'Roboto' => 'Google Fonts',
4636
- 'Roboto Condensed' => 'Google Fonts',
4637
- 'Roboto Mono' => 'Google Fonts',
4638
- 'Roboto Slab' => 'Google Fonts',
4639
- 'Rochester' => 'Google Fonts',
4640
- 'Rock Salt' => 'Google Fonts',
4641
- 'Rokkitt' => 'Google Fonts',
4642
- 'Romanesco' => 'Google Fonts',
4643
- 'Ropa Sans' => 'Google Fonts',
4644
- 'Rosario' => 'Google Fonts',
4645
- 'Rosarivo' => 'Google Fonts',
4646
- 'Rouge Script' => 'Google Fonts',
4647
- 'Rozha One' => 'Google Fonts',
4648
- 'Rubik' => 'Google Fonts',
4649
- 'Rubik Mono One' => 'Google Fonts',
4650
- 'Ruda' => 'Google Fonts',
4651
- 'Rufina' => 'Google Fonts',
4652
- 'Ruge Boogie' => 'Google Fonts',
4653
- 'Ruluko' => 'Google Fonts',
4654
- 'Rum Raisin' => 'Google Fonts',
4655
- 'Ruslan Display' => 'Google Fonts',
4656
- 'Russo One' => 'Google Fonts',
4657
- 'Ruthie' => 'Google Fonts',
4658
- 'Rye' => 'Google Fonts',
4659
- 'Sacramento' => 'Google Fonts',
4660
- 'Sahitya' => 'Google Fonts',
4661
- 'Sail' => 'Google Fonts',
4662
- 'Saira' => 'Google Fonts',
4663
- 'Saira Condensed' => 'Google Fonts',
4664
- 'Saira Extra Condensed' => 'Google Fonts',
4665
- 'Saira Semi Condensed' => 'Google Fonts',
4666
- 'Salsa' => 'Google Fonts',
4667
- 'Sanchez' => 'Google Fonts',
4668
- 'Sancreek' => 'Google Fonts',
4669
- 'Sansita' => 'Google Fonts',
4670
- 'Sarala' => 'Google Fonts',
4671
- 'Sarina' => 'Google Fonts',
4672
- 'Sarpanch' => 'Google Fonts',
4673
- 'Satisfy' => 'Google Fonts',
4674
- 'Sawarabi Gothic' => 'Google Fonts',
4675
- 'Sawarabi Mincho' => 'Google Fonts',
4676
- 'Scada' => 'Google Fonts',
4677
- 'Scheherazade' => 'Google Fonts',
4678
- 'Schoolbell' => 'Google Fonts',
4679
- 'Scope One' => 'Google Fonts',
4680
- 'Seaweed Script' => 'Google Fonts',
4681
- 'Secular One' => 'Google Fonts',
4682
- 'Sedgwick Ave' => 'Google Fonts',
4683
- 'Sedgwick Ave Display' => 'Google Fonts',
4684
- 'Sevillana' => 'Google Fonts',
4685
- 'Seymour One' => 'Google Fonts',
4686
- 'Shadows Into Light' => 'Google Fonts',
4687
- 'Shadows Into Light Two' => 'Google Fonts',
4688
- 'Shanti' => 'Google Fonts',
4689
- 'Share' => 'Google Fonts',
4690
- 'Share Tech' => 'Google Fonts',
4691
- 'Share Tech Mono' => 'Google Fonts',
4692
- 'Shojumaru' => 'Google Fonts',
4693
- 'Short Stack' => 'Google Fonts',
4694
- 'Shrikhand' => 'Google Fonts',
4695
- 'Siemreap' => 'Google Fonts',
4696
- 'Sigmar One' => 'Google Fonts',
4697
- 'Signika' => 'Google Fonts',
4698
- 'Signika Negative' => 'Google Fonts',
4699
- 'Simonetta' => 'Google Fonts',
4700
- 'Sintony' => 'Google Fonts',
4701
- 'Sirin Stencil' => 'Google Fonts',
4702
- 'Six Caps' => 'Google Fonts',
4703
- 'Skranji' => 'Google Fonts',
4704
- 'Slabo 13px' => 'Google Fonts',
4705
- 'Slabo 27px' => 'Google Fonts',
4706
- 'Slackey' => 'Google Fonts',
4707
- 'Smokum' => 'Google Fonts',
4708
- 'Smythe' => 'Google Fonts',
4709
- 'Sniglet' => 'Google Fonts',
4710
- 'Snippet' => 'Google Fonts',
4711
- 'Snowburst One' => 'Google Fonts',
4712
- 'Sofadi One' => 'Google Fonts',
4713
- 'Sofia' => 'Google Fonts',
4714
- 'Song Myung' => 'Google Fonts',
4715
- 'Sonsie One' => 'Google Fonts',
4716
- 'Sorts Mill Goudy' => 'Google Fonts',
4717
- 'Source Code Pro' => 'Google Fonts',
4718
- 'Source Sans Pro' => 'Google Fonts',
4719
- 'Source Serif Pro' => 'Google Fonts',
4720
- 'Space Mono' => 'Google Fonts',
4721
- 'Special Elite' => 'Google Fonts',
4722
- 'Spectral' => 'Google Fonts',
4723
- 'Spectral SC' => 'Google Fonts',
4724
- 'Spicy Rice' => 'Google Fonts',
4725
- 'Spinnaker' => 'Google Fonts',
4726
- 'Spirax' => 'Google Fonts',
4727
- 'Squada One' => 'Google Fonts',
4728
- 'Sree Krushnadevaraya' => 'Google Fonts',
4729
- 'Sriracha' => 'Google Fonts',
4730
- 'Srisakdi' => 'Google Fonts',
4731
- 'Stalemate' => 'Google Fonts',
4732
- 'Stalinist One' => 'Google Fonts',
4733
- 'Stardos Stencil' => 'Google Fonts',
4734
- 'Stint Ultra Condensed' => 'Google Fonts',
4735
- 'Stint Ultra Expanded' => 'Google Fonts',
4736
- 'Stoke' => 'Google Fonts',
4737
- 'Strait' => 'Google Fonts',
4738
- 'Stylish' => 'Google Fonts',
4739
- 'Sue Ellen Francisco' => 'Google Fonts',
4740
- 'Suez One' => 'Google Fonts',
4741
- 'Sumana' => 'Google Fonts',
4742
- 'Sunflower' => 'Google Fonts',
4743
- 'Sunshiney' => 'Google Fonts',
4744
- 'Supermercado One' => 'Google Fonts',
4745
- 'Sura' => 'Google Fonts',
4746
- 'Suranna' => 'Google Fonts',
4747
- 'Suravaram' => 'Google Fonts',
4748
- 'Suwannaphum' => 'Google Fonts',
4749
- 'Swanky and Moo Moo' => 'Google Fonts',
4750
- 'Syncopate' => 'Google Fonts',
4751
- 'Tajawal' => 'Google Fonts',
4752
- 'Tangerine' => 'Google Fonts',
4753
- 'Taprom' => 'Google Fonts',
4754
- 'Tauri' => 'Google Fonts',
4755
- 'Taviraj' => 'Google Fonts',
4756
- 'Teko' => 'Google Fonts',
4757
- 'Telex' => 'Google Fonts',
4758
- 'Tenali Ramakrishna' => 'Google Fonts',
4759
- 'Tenor Sans' => 'Google Fonts',
4760
- 'Text Me One' => 'Google Fonts',
4761
- 'The Girl Next Door' => 'Google Fonts',
4762
- 'Tienne' => 'Google Fonts',
4763
- 'Tillana' => 'Google Fonts',
4764
- 'Timmana' => 'Google Fonts',
4765
- 'Tinos' => 'Google Fonts',
4766
- 'Titan One' => 'Google Fonts',
4767
- 'Titillium Web' => 'Google Fonts',
4768
- 'Trade Winds' => 'Google Fonts',
4769
- 'Trirong' => 'Google Fonts',
4770
- 'Trocchi' => 'Google Fonts',
4771
- 'Trochut' => 'Google Fonts',
4772
- 'Trykker' => 'Google Fonts',
4773
- 'Tulpen One' => 'Google Fonts',
4774
- 'Ubuntu' => 'Google Fonts',
4775
- 'Ubuntu Condensed' => 'Google Fonts',
4776
- 'Ubuntu Mono' => 'Google Fonts',
4777
- 'Ultra' => 'Google Fonts',
4778
- 'Uncial Antiqua' => 'Google Fonts',
4779
- 'Underdog' => 'Google Fonts',
4780
- 'Unica One' => 'Google Fonts',
4781
- 'UnifrakturCook' => 'Google Fonts',
4782
- 'UnifrakturMaguntia' => 'Google Fonts',
4783
- 'Unkempt' => 'Google Fonts',
4784
- 'Unlock' => 'Google Fonts',
4785
- 'Unna' => 'Google Fonts',
4786
- 'VT323' => 'Google Fonts',
4787
- 'Vampiro One' => 'Google Fonts',
4788
- 'Varela' => 'Google Fonts',
4789
- 'Varela Round' => 'Google Fonts',
4790
- 'Vast Shadow' => 'Google Fonts',
4791
- 'Vesper Libre' => 'Google Fonts',
4792
- 'Vibur' => 'Google Fonts',
4793
- 'Vidaloka' => 'Google Fonts',
4794
- 'Viga' => 'Google Fonts',
4795
- 'Voces' => 'Google Fonts',
4796
- 'Volkhov' => 'Google Fonts',
4797
- 'Vollkorn' => 'Google Fonts',
4798
- 'Vollkorn SC' => 'Google Fonts',
4799
- 'Voltaire' => 'Google Fonts',
4800
- 'Waiting for the Sunrise' => 'Google Fonts',
4801
- 'Wallpoet' => 'Google Fonts',
4802
- 'Walter Turncoat' => 'Google Fonts',
4803
- 'Warnes' => 'Google Fonts',
4804
- 'Wellfleet' => 'Google Fonts',
4805
- 'Wendy One' => 'Google Fonts',
4806
- 'Wire One' => 'Google Fonts',
4807
- 'Work Sans' => 'Google Fonts',
4808
- 'Yanone Kaffeesatz' => 'Google Fonts',
4809
- 'Yantramanav' => 'Google Fonts',
4810
- 'Yatra One' => 'Google Fonts',
4811
- 'Yellowtail' => 'Google Fonts',
4812
- 'Yeon Sung' => 'Google Fonts',
4813
- 'Yeseva One' => 'Google Fonts',
4814
- 'Yesteryear' => 'Google Fonts',
4815
- 'Yrsa' => 'Google Fonts',
4816
- 'Zeyada' => 'Google Fonts',
4817
- 'Zilla Slab' => 'Google Fonts',
4818
- 'Zilla Slab Highlight' => 'Google Fonts',
4819
- );
4820
- }
4821
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4822
  public function set_default_values_if_not_exists()
4823
  {
4824
- if(is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
4825
  $options = get_option('folders_settings');
4826
- $options = empty($options) || !is_array($options) ? array() : $options;
4827
  foreach ($options as $option) {
4828
  $post_type = self::get_custom_post_type($option);
4829
- $terms = get_terms($post_type, array(
 
 
4830
  'hide_empty' => false,
4831
- 'meta_query' => array(
4832
- array(
4833
- 'key' => 'wcp_custom_order',
4834
- 'compare' => 'NOT EXISTS'
4835
- )
4836
- )
4837
- )
4838
  );
4839
  if (!empty($terms)) {
4840
  foreach ($terms as $term) {
@@ -4844,58 +6474,131 @@ class WCP_Folders
4844
  }
4845
  }
4846
  }
4847
- }
4848
- }
4849
- }
 
 
4850
 
4851
- /* Free and Pro major changes */
4852
- public function premio_hide_child_popup() {
4853
- if(isset($_REQUEST['post_type']) && isset($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'wcp_folder_nonce_'.$_REQUEST['post_type'])) {
4854
- $status = (isset($_REQUEST['status']) && $_REQUEST['status'] == 1)?1:0;
4855
- if($status) {
 
 
 
 
 
 
 
 
 
 
 
 
4856
  add_option("premio_hide_child_popup", 1);
4857
  } else {
4858
  delete_option("premio_hide_child_popup");
4859
  }
4860
  }
 
4861
  echo esc_attr("1");
4862
  die;
4863
- }
4864
 
4865
- public function folder_update_popup_status() {
4866
- if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'folder_update_popup_status')) {
 
 
 
 
 
 
 
 
 
 
 
4867
  update_option("folder_intro_box", "hide");
4868
  }
 
4869
  echo esc_attr("1");
4870
  die;
4871
- }
4872
 
4873
- public function update_folders_import_status() {
4874
- if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'folders_import_3rd_party_data')) {
 
 
 
 
 
 
 
 
 
 
 
4875
  update_option("folder_redirect_status", "3");
4876
  }
 
4877
  echo esc_attr("1");
4878
  die;
4879
- }
4880
 
 
 
 
 
 
 
 
 
 
4881
  public function check_has_valid_key()
4882
  {
4883
- /* Free/Pro: checking for key, for Free return 0, for Pro check for Key */
4884
  return 0;
4885
- }
4886
 
 
 
 
 
 
 
 
 
 
4887
  public function get_license_key_information($licenseKey)
4888
  {
4889
- return array();
4890
- }
4891
 
4892
- public function get_license_key_data($licenseKey = '')
 
 
 
 
 
 
 
 
 
4893
  {
4894
- return array();
4895
- }
 
 
4896
 
 
 
 
 
 
 
4897
  public function check_for_license_key()
4898
  {
4899
  return false;
4900
- }
4901
- }
 
 
 
 
1
  <?php
2
+ /**
3
+ * Class Folders Main
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ // Free/Pro Class name change
14
  class WCP_Folders
15
  {
16
 
17
+ /**
18
+ * Instance of Class
19
+ *
20
+ * @var object $instance Instance of Class
21
+ * @since 1.0.0
22
+ * @access public
23
+ */
24
  private static $instance;
25
 
26
+ /**
27
+ * License key data
28
+ *
29
+ * @var array $license_key_data License key data
30
+ * @since 1.0.0
31
+ * @access public
32
+ */
33
  private static $license_key_data = null;
34
 
35
+ /**
36
+ * Folders data
37
+ *
38
+ * @var object $folders Folders data
39
+ * @since 1.0.0
40
+ * @access public
41
+ */
42
  private static $folders;
43
 
44
+ /**
45
+ * Total number of folders
46
+ *
47
+ * @var integer $tlfs total number of folders
48
+ * @since 1.0.0
49
+ * @access public
50
+ */
51
  public $tlfs = 0;
52
 
53
+ /**
54
+ * Collection on post ids
55
+ *
56
+ * @var array $postIds collection on post ids
57
+ * @since 1.0.0
58
+ * @access public
59
+ */
60
  private static $postIds;
61
 
62
+ /**
63
+ * Folders Settings
64
+ *
65
+ * @var array $folderSettings Folders Settings
66
+ * @since 1.0.0
67
+ * @access public
68
+ */
69
  private static $folderSettings = false;
70
 
71
+
72
+ /**
73
+ * Define the core functionality of the import data functionality.
74
+ *
75
+ * Add/Update folders settings
76
+ * Add/Update/Remove/List of folders
77
+ * Add/Update/Remove/List posts to folders
78
+ * Mark/Unmark folders
79
+ * Make Sticky/Unsticky folders
80
+ * Add content to folders
81
+ * Update folder sidebar width
82
+ * Filter taxonomies for folders
83
+ * Show drag buttons to post/page table
84
+ *
85
+ * @since 1.0.0
86
+ */
87
  public function __construct()
88
  {
89
 
90
+ spl_autoload_register([$this, 'autoload']);
91
+ add_action('init', [$this, 'create_folder_terms'], 15);
92
+ add_action('admin_init', [$this, 'folders_register_settings']);
93
+ add_action('admin_menu', [$this, 'admin_menu'], 10000);
94
+ add_action('admin_enqueue_scripts', [$this, 'folders_admin_styles']);
95
+ add_action('admin_enqueue_scripts', [$this, 'folders_admin_scripts']);
96
+ add_filter('plugin_action_links_'.WCP_FOLDERS_PLUGIN_BASE, [$this, 'plugin_action_links']);
97
+ add_action('admin_footer', [$this, 'admin_footer']);
98
+
99
+ add_action('parse_tax_query', [$this, 'taxonomy_archive_exclude_children']);
100
+ add_action('admin_footer', [$this, 'admin_footer_for_media']);
101
+
102
+ // Save Data
103
+ add_action('wp_ajax_wcp_add_new_folder', [$this, 'wcp_add_new_folder']);
104
+ // Update Data
105
+ add_action('wp_ajax_wcp_update_folder', [$this, 'wcp_update_folder']);
106
+ // Remove Data
107
+ add_action('wp_ajax_wcp_remove_folder', [$this, 'wcp_remove_folder']);
108
+ // Remove Multple Folder
109
+ add_action('wp_ajax_wcp_remove_muliple_folder', [$this, 'remove_muliple_folder']);
110
+ // Save State Data
111
+ add_action('wp_ajax_save_wcp_folder_state', [$this, 'save_wcp_folder_state']);
112
+ // Save State Data
113
+ add_action('wp_ajax_wcp_save_parent_data', [$this, 'wcp_save_parent_data']);
114
+ // Update Parent Data
115
+ add_action('wp_ajax_wcp_update_parent_information', [$this, 'wcp_update_parent_information']);
116
+ // Update Parent Data
117
+ add_action('wp_ajax_wcp_save_folder_order', [$this, 'wcp_save_folder_order']);
118
+ // Update Parent Data
119
+ add_action('wp_ajax_wcp_mark_un_mark_folder', [$this, 'wcp_mark_un_mark_folder']);
120
+ // Update Parent Data
121
+ add_action('wp_ajax_wcp_make_sticky_folder', [$this, 'wcp_make_sticky_folder']);
122
+ // Update Parent Data
123
+ add_action('wp_ajax_wcp_change_post_folder', [$this, 'wcp_change_post_folder']);
124
+ // Update Parent Data
125
+ add_action('wp_ajax_wcp_change_multiple_post_folder', [$this, 'wcp_change_multiple_post_folder']);
126
+ // Update width Data
127
+ add_action('wp_ajax_wcp_change_post_width', [$this, 'wcp_change_post_width']);
128
+ // Update width Data
129
+ add_action('wp_ajax_wcp_change_folder_display_status', [$this, 'wcp_change_folder_display_status']);
130
+ // Update width Data
131
+ add_action('wp_ajax_wcp_change_all_status', [$this, 'wcp_change_all_status']);
132
+ // Update width Data
133
+ add_action('wp_ajax_save_folder_last_status', [$this, 'save_folder_last_status']);
134
+ // Update width Data
135
+ add_action('wp_ajax_wcp_folders_by_order', [$this, 'wcp_folders_by_order']);
136
+ // Update width Data
137
+ add_action('wp_ajax_wcp_remove_all_folders_data', [$this, 'remove_all_folders_data']);
138
+ // Update folders Status
139
+ add_action('wp_ajax_wcp_update_folders_uninstall_status', [$this, 'update_folders_uninstall_status']);
140
+ // Undo Functionality
141
+ add_action('wp_ajax_wcp_undo_folder_changes', [$this, 'wcp_undo_folder_changes']);
 
 
 
 
 
 
 
 
 
 
142
  self::$folders = 10;
143
 
144
+ // Send message on plugin deactivate
145
+ add_action('wp_ajax_folder_plugin_deactivate', [ $this, 'folder_plugin_deactivate' ]);
146
+ // Update Parent Data
147
+ add_action('wp_ajax_wcp_remove_post_folder', [$this, 'wcp_remove_post_folder']);
148
+ // Send message on owner
149
+ add_action('wp_ajax_wcp_folder_send_message_to_owner', [ $this, 'wcp_folder_send_message_to_owner' ]);
150
+ // Get default list
151
+ add_action('wp_ajax_premio_check_for_other_folders', [$this, 'premio_check_for_other_folders']);
152
+ // Send message on owner
153
+ add_action('wp_ajax_wcp_get_default_list', [ $this, 'wcp_get_default_list' ]);
154
+ // Get default list
155
+ add_action('wp_ajax_get_folders_default_list', [ $this, 'get_folders_default_list' ]);
156
+ // Auto select folder for new page, post
157
+ add_action('new_to_auto-draft', [$this, 'new_to_auto_draft'], 10);
158
+ // for media
159
+ add_action('restrict_manage_posts', [$this, 'output_list_table_filters'], 10, 2);
160
+ add_filter('pre_get_posts', [$this, 'filter_attachments_list']);
161
+ add_action('wp_enqueue_media', [$this, 'output_backbone_view_filters']);
162
+ add_filter('ajax_query_attachments_args', [$this, 'filter_attachments_grid']);
163
+ add_filter('add_attachment', [$this, 'save_media_terms']);
164
+
165
+ // to filter un assigned items
166
+ add_filter('pre_get_posts', [$this, 'filter_record_list']);
167
+ add_filter('pre-upload-ui', [$this, 'show_dropdown_on_media_screen']);
168
+ add_action('add_attachment', [$this, 'add_attachment_category']);
169
 
170
  $options = get_option("folders_settings");
171
 
172
+ $options = is_array($options) ? $options : [];
173
 
174
  if (in_array("post", $options)) {
175
+ add_filter('manage_posts_columns', [$this, 'wcp_manage_columns_head']);
176
+ add_action('manage_posts_custom_column', [$this, 'wcp_manage_columns_content'], 10, 2);
177
+ add_filter('bulk_actions-edit-post', [$this, 'custom_bulk_action' ]);
178
  }
179
 
180
  if (in_array("page", $options)) {
181
+ add_filter('manage_page_posts_columns', [$this, 'wcp_manage_columns_head']);
182
+ add_action('manage_page_posts_custom_column', [$this, 'wcp_manage_columns_content'], 10, 2);
183
+ add_filter('bulk_actions-edit-page', [$this, 'custom_bulk_action' ]);
184
  }
185
 
186
  if (in_array("attachment", $options)) {
187
+ add_filter('manage_media_columns', [$this, 'wcp_manage_columns_head']);
188
+ add_action('manage_media_custom_column', [$this, 'wcp_manage_columns_content'], 10, 2);
189
+ // add_filter('bulk_actions-edit-media', array($this, 'custom_bulk_action' ));
190
  }
191
 
192
  foreach ($options as $option) {
193
  if ($option != "post" && $option != "page" && $option != "attachment") {
194
+ add_filter('manage_edit-'.$option.'_columns', [$this, 'wcp_manage_columns_head'], 99999);
195
+ add_action('manage_'.$option.'_posts_custom_column', [$this, 'wcp_manage_columns_content'], 2, 2);
196
+ add_filter('bulk_actions-edit-'.$option, [$this, 'custom_bulk_action' ]);
197
  }
198
  }
199
 
200
+ // check for default folders
201
+ add_filter('pre_get_posts', [$this, 'check_for_default_folders']);
202
 
203
+ add_action("wp_ajax_folder_update_status", [$this, 'folder_update_status']);
204
 
205
+ // load language files
206
+ add_action('plugins_loaded', [ $this, 'folders_text' ]);
207
 
208
+ add_action("wp_ajax_folder_update_popup_status", [$this, 'folder_update_popup_status']);
209
 
210
+ add_action("wp_ajax_premio_hide_child_popup", [$this, 'premio_hide_child_popup']);
211
 
212
+ add_action("wp_ajax_wcp_update_folders_import_status", [$this, 'update_folders_import_status']);
213
 
214
+ add_filter('get_terms', [ $this, 'get_terms_filter_without_trash'], 10, 3);
215
 
216
+ add_filter('mla_media_modal_query_final_terms', [ $this, 'media_modal_query_final_terms'], 10, 3);
217
 
218
+ // reset count when post/page updated
219
+ add_action('deleted_term_relationships', [$this, 'update_folder_term_relationships'], 10, 3);
220
 
221
+ add_action('added_term_relationship', [$this, 'update_folder_new_term_relationships'], 10, 3);
222
 
223
+ add_action('set_object_terms', [$this, 'set_object_terms_for_folders'], 10, 6);
224
 
225
  /*
226
  * To Remove Attachment
227
  * */
228
 
229
+ add_action('wp_trash_post', [$this, "wcp_delete_post"]);
230
+ add_action('before_delete_post', [$this, "wcp_delete_post"]);
231
 
232
  /*
233
  * Hide Folder CTA
234
  * */
235
+ add_action('wp_ajax_hide_folders_cta', [$this, 'hide_folders_cta']);
 
236
 
237
+ }//end __construct()
238
+
239
+
240
+ /**
241
+ * Hide CTA button text
242
+ *
243
+ * @since 1.0.0
244
+ * @access public
245
+ * @return $response
246
+ */
247
+ public function hide_folders_cta()
248
+ {
249
+ $response = [];
250
+ $response['status'] = 0;
251
+ $response['error'] = 0;
252
+ $response['data'] = [];
253
  $response['message'] = "";
254
+ $postData = filter_input_array(INPUT_POST);
255
+ $errorCounter = 0;
256
  if (!isset($postData['nonce']) || empty($postData['nonce'])) {
257
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
258
  $errorCounter++;
259
  } else {
260
  $nonce = self::sanitize_options($postData['nonce']);
261
+ if (!wp_verify_nonce($nonce, 'hide_folders_cta')) {
262
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
263
  $errorCounter++;
264
  }
265
  }
266
+
267
+ if ($errorCounter == 0) {
268
  $response['status'] = 1;
269
  add_option("hide_folders_cta", "yes");
270
  }
 
 
271
 
272
+ echo json_encode($response);
273
+ die;
274
+
275
+ }//end hide_folders_cta()
276
+
277
+
278
+ /**
279
+ * Delete post hook, clear data on post delete
280
+ *
281
+ * @since 1.0.0
282
+ * @access public
283
+ * @return $status
284
+ */
285
+ public function wcp_delete_post($postID)
286
+ {
287
  delete_transient("premio_folders_without_trash");
 
288
 
289
+ }//end wcp_delete_post()
290
+
291
+
292
+ /**
293
+ * Set folders data for post/page ids
294
+ *
295
+ * @since 1.0.0
296
+ * @access public
297
+ * @return $post
298
+ */
299
+ public function set_object_terms_for_folders($object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids)
300
+ {
301
+ if (!empty($object_id)) {
302
  $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
303
+ if (!empty($tt_ids) && is_array($tt_ids)) {
304
+ foreach ($tt_ids as $term_id) {
305
  $term = get_term($term_id, $taxonomy);
306
+ if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
307
  unset($trash_folders[$term->term_taxonomy_id]);
308
  }
309
  }
310
  }
311
 
312
+ if (!empty($old_tt_ids) && is_array($old_tt_ids)) {
313
+ foreach ($old_tt_ids as $term_id) {
314
  $term = get_term($term_id, $taxonomy);
315
+ if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
316
  unset($trash_folders[$term->term_taxonomy_id]);
317
  }
318
  }
319
  }
320
 
321
+ if ($initial_trash_folders != $trash_folders) {
322
  delete_transient("premio_folders_without_trash");
323
+ set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
324
  }
325
+ }//end if
326
+
327
+ }//end set_object_terms_for_folders()
328
 
329
+
330
+ /**
331
+ * Check for folders settings
332
+ *
333
+ * @since 1.0.0
334
+ * @access public
335
+ * @return $options
336
+ */
337
+ public static function check_for_setting($key, $setting, $default="")
338
+ {
339
+ if (self::$folderSettings === false) {
340
  $options = get_option("premio_folder_options");
341
+ if ($options === false || !is_array($options)) {
342
+ $options = [];
343
  }
344
+
345
+ self::$folderSettings = $options;
346
  }
347
+
348
+ if ($setting == "folders_settings") {
349
+ if (isset(self::$folderSettings[$setting]) && is_array(self::$folderSettings[$setting])) {
350
+ return in_array($key, self::$folderSettings[$setting]);
351
  }
352
  } else {
353
+ if (isset(self::$folderSettings[$setting][$key])) {
354
+ return self::$folderSettings[$setting][$key];
355
+ }
356
  }
 
 
357
 
358
+ return false;
359
+
360
+ }//end check_for_setting()
361
+
362
+
363
+ /**
364
+ * Send message to owner on Uninstall
365
+ *
366
+ * @since 1.0.0
367
+ * @access public
368
+ * @return $response
369
+ */
370
+ public function update_folders_uninstall_status()
371
+ {
372
+ $response = [];
373
+ $response['status'] = 0;
374
+ $response['error'] = 0;
375
+ $response['data'] = [];
376
  $response['message'] = "";
377
+ $postData = filter_input_array(INPUT_POST);
378
+ $errorCounter = 0;
379
 
380
  if (!isset($postData['nonce']) || empty($postData['nonce'])) {
381
  $response['message'] = esc_html__("Your request is not valid", 'folders');
382
  $errorCounter++;
383
  } else {
384
  $nonce = self::sanitize_options($postData['nonce']);
385
+ if (!wp_verify_nonce($nonce, 'wcp_folders_uninstall_status')) {
386
  $response['message'] = esc_html__("Your request is not valid", 'folders');
387
  $errorCounter++;
388
  }
389
  }
390
+
391
  if ($errorCounter == 0) {
392
+ $status = isset($postData['status']) ? $postData['status'] : "";
393
+ $status = ($status == "on") ? "on" : "off";
394
  $customize_folders = get_option('customize_folders');
395
  $customize_folders['remove_folders_when_removed'] = $status;
396
  update_option("customize_folders", $customize_folders);
397
  $response['status'] = 1;
398
  }
 
 
399
 
400
+ echo json_encode($response);
401
+ die;
402
+
403
+ }//end update_folders_uninstall_status()
404
+
405
+
406
+ /**
407
+ * Remove folders data
408
+ *
409
+ * @since 1.0.0
410
+ * @access public
411
+ * @return $response
412
+ */
413
+ public function remove_all_folders_data()
414
+ {
415
+ $response = [];
416
+ $response['status'] = 0;
417
+ $response['error'] = 0;
418
+ $response['data'] = [];
419
  $response['message'] = "";
420
+ $postData = filter_input_array(INPUT_POST);
421
+ $errorCounter = 0;
422
 
423
  if (!isset($postData['nonce']) || empty($postData['nonce'])) {
424
  $response['message'] = esc_html__("Your request is not valid", 'folders');
425
  $errorCounter++;
426
  } else {
427
+ $type = self::sanitize_options($postData['type']);
428
  $nonce = self::sanitize_options($postData['nonce']);
429
+ if (!wp_verify_nonce($nonce, 'remove_folders_data')) {
430
  $response['message'] = esc_html__("Your request is not valid", 'folders');
431
  $errorCounter++;
432
  }
433
  }
434
+
435
  if ($errorCounter == 0) {
436
  self::$folders = 0;
437
  self::remove_folder_by_taxonomy("media_folder");
438
  self::remove_folder_by_taxonomy("folder");
439
  self::remove_folder_by_taxonomy("post_folder");
440
+ $post_types = get_post_types([], 'objects');
441
+ $post_array = [
442
+ "page",
443
+ "post",
444
+ "attachment",
445
+ ];
446
+ foreach ($post_types as $post_type) {
447
+ if (!in_array($post_type->name, $post_array)) {
448
+ self::remove_folder_by_taxonomy($post_type->name.'_folder');
449
  }
450
  }
451
+
452
  delete_option('default_folders');
453
  $response['status'] = 1;
454
+ $response['data'] = [
455
+ 'items' => self::$folders,
456
+ ];
457
+ }//end if
458
+
459
+ echo json_encode($response);
460
+ die;
461
+
462
+ }//end remove_all_folders_data()
463
 
464
+
465
+ /**
466
+ * Remove folders from poge/post
467
+ *
468
+ * @since 1.0.0
469
+ * @access public
470
+ * @return $folders
471
+ */
472
+ public static function remove_folder_by_taxonomy($taxonomy)
473
+ {
474
  global $wpdb;
475
+ $query = "SELECT * FROM ".$wpdb->term_taxonomy."
476
+ LEFT JOIN ".$wpdb->terms."
477
+ ON ".$wpdb->term_taxonomy.".term_id = ".$wpdb->terms.".term_id
478
+ WHERE ".$wpdb->term_taxonomy.".taxonomy = '%d'
479
+ ORDER BY parent ASC";
480
+ $query = $wpdb->prepare($query, $taxonomy);
481
+ $folders = $wpdb->get_results($query);
482
+ $folders = array_values($folders);
483
+ foreach ($folders as $folder) {
484
+ $term_id = intval($folder->term_id);
485
+ if ($term_id) {
486
+ $wpdb->delete($wpdb->prefix.'term_relationships', ['term_taxonomy_id' => $term_id]);
487
+ $wpdb->delete($wpdb->prefix.'term_taxonomy', ['term_id' => $term_id]);
488
+ $wpdb->delete($wpdb->prefix.'terms', ['term_id' => $term_id]);
489
+ $wpdb->delete($wpdb->prefix.'termmeta', ['term_id' => $term_id]);
490
  self::$folders++;
491
  }
492
  }
 
493
 
494
+ }//end remove_folder_by_taxonomy()
495
+
496
+
497
+ /**
498
+ * Convent Hex color code to RGB code
499
+ *
500
+ * @since 1.0.0
501
+ * @access public
502
+ * @return $rgb
503
+ */
504
+ public static function hexToRgb($hex, $alpha=false)
505
+ {
506
  $hex = str_replace('#', '', $hex);
507
  $length = strlen($hex);
508
  $rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
509
  $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
510
  $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
511
+ if ($alpha) {
512
  $rgb['a'] = $alpha;
513
  }
514
+
515
  return $rgb;
 
516
 
517
+ }//end hexToRgb()
518
+
519
+
520
+ /**
521
+ * Get folders by folder order
522
+ *
523
+ * @since 1.0.0
524
+ * @access public
525
+ * @return $folders
526
+ */
527
+ public function wcp_folders_by_order()
528
+ {
529
+ $response = [];
530
+ $response['status'] = 0;
531
+ $response['error'] = 0;
532
+ $response['data'] = [];
533
  $response['message'] = "";
534
+ $postData = filter_input_array(INPUT_POST);
535
+ $errorCounter = 0;
536
 
537
  if (!isset($postData['order']) || empty($postData['order'])) {
538
  $response['message'] = esc_html__("Your request is not valid", 'folders');
550
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
551
  $errorCounter++;
552
  } else {
553
+ $type = self::sanitize_options($postData['type']);
554
  $nonce = self::sanitize_options($postData['nonce']);
555
+ if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
556
  $response['message'] = esc_html__("Your request is not valid", 'folders');
557
  $errorCounter++;
558
  }
559
+ }//end if
560
+
561
  if ($errorCounter == 0) {
562
  $response['status'] = 1;
563
 
564
  $order_field = $postData['order'];
565
 
566
  $order_by = "";
567
+ $order = "ASC";
568
 
569
+ if ($order_field == "a-z" || $order_field == "z-a") {
570
  $order_by = 'title';
571
+ if ($order_field == "z-a") {
572
  $order = "DESC";
573
  }
574
+ } else if ($order_field == "n-o" || $order_field == "o-n") {
575
  $order_by = 'ID';
576
+ if ($order_field == "o-n") {
577
  $order = "ASC";
578
  } else {
579
  $order = "DESC";
580
  }
581
  }
582
 
583
+ if (empty($order_by)) {
584
  $order = "";
585
  }
586
 
587
  $folder_type = self::get_custom_post_type($postData['type']);
588
+ // Do not change: Free/Pro Class name change
589
  $tree_data = WCP_Tree::get_full_tree_data($folder_type, $order_by, $order);
590
 
591
  $response['data'] = $tree_data['string'];
592
+ $taxonomies = [];
593
+ if ($postData['type'] == "attachment") {
594
  $taxonomies = self::get_terms_hierarchical($folder_type);
595
  }
596
+
597
  $response['terms'] = $taxonomies;
598
+ }//end if
599
+
600
+ echo json_encode($response);
601
+ die;
602
+
603
+ }//end wcp_folders_by_order()
604
 
605
+
606
+ /**
607
+ * Save selected post for page/post/media
608
+ *
609
+ * @since 1.0.0
610
+ * @access public
611
+ * @return $folders
612
+ */
613
+ public function save_folder_last_status()
614
+ {
615
  $postData = filter_input_array(INPUT_POST);
616
+ $error = 0;
617
  if (!isset($postData['post_id']) || empty($postData['post_id'])) {
618
  $response['message'] = esc_html__("Your request is not valid", 'folders');
619
  $error = 1;
630
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
631
  $error = 1;
632
  }
633
+
634
+ if ($error == 0) {
635
+ $post_type = filter_input(INPUT_POST, 'post_type');
636
+ $post_id = filter_input(INPUT_POST, 'post_id');
637
  if (!empty($post_type) && !empty($post_id)) {
638
+ delete_option("last_folder_status_for".$post_type);
639
+ add_option("last_folder_status_for".$post_type, $post_id);
640
  }
641
  }
 
642
 
643
+ }//end save_folder_last_status()
644
+
645
+
646
+ /**
647
+ * Save selected post for page/post/media
648
+ *
649
+ * @since 1.0.0
650
+ * @access public
651
+ * @return $folders
652
+ */
653
  public function media_modal_query_final_terms($request)
654
  {
655
+ $action = $this->getRequestVar("action");
656
+ if ($action == "mla-query-attachments") {
657
+ $query = $this->getRequestVar("query");
658
  if (isset($query['media_folder']) && !empty($query['media_folder'])) {
659
  if ($query['media_folder'] == -1) {
660
+ $tax_query = [
661
  'taxonomy' => 'media_folder',
662
  'operator' => 'NOT EXISTS',
663
+ ];
664
+ $request['tax_query'] = [$tax_query];
665
  $request = apply_filters('media_library_organizer_media_filter_attachments', $request, $_REQUEST);
666
  } else {
667
  $request['media_folder'] = $query['media_folder'];
668
  }
669
  }
670
  }
671
+
672
  return $request;
 
673
 
674
+ }//end media_modal_query_final_terms()
675
+
676
+
677
+ /**
678
+ * Get folder items without trash
679
+ *
680
+ * @since 1.0.0
681
+ * @access public
682
+ * @return $folders
683
+ */
684
+ public function get_terms_filter_without_trash($terms, $taxonomies, $args)
685
+ {
686
 
687
  $isForFolders = 0;
688
+ if (!empty($taxonomies) && is_array($taxonomies) && count($taxonomies)) {
689
  foreach ($taxonomies as $taxonomy) {
690
+ if (in_array($taxonomy, ["media_folder", "folder", "post_folder"])) {
691
  $isForFolders = 1;
692
  } else {
693
  $folder = substr($taxonomy, -7);
698
  }
699
  }
700
 
701
+ if ($isForFolders) {
702
  global $wpdb;
703
  if (!is_array($terms) && count($terms) < 1) {
704
  return $terms;
706
 
707
  $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
708
  if ($trash_folders === false) {
709
+ $trash_folders = [];
710
+ $initial_trash_folders = [];
711
  }
712
 
713
+ $post_table = $wpdb->prefix."posts";
714
+ $term_table = $wpdb->prefix."term_relationships";
715
+ $options = get_option('folders_settings');
716
+ $option_array = [];
717
  if (!empty($options)) {
718
  foreach ($options as $option) {
719
  $option_array[] = self::get_custom_post_type($option);
720
  }
721
  }
722
+
723
  foreach ($terms as $key => $term) {
724
  if (isset($term->term_taxonomy_id) && isset($term->taxonomy) && !empty($term->taxonomy) && in_array($term->taxonomy, $option_array)) {
725
  $trash_count = null;
728
  } else {
729
  if (has_filter("premio_folder_item_in_taxonomy")) {
730
  $post_type = "";
731
+ $taxonomy = $term->taxonomy;
732
 
733
  if ($taxonomy == "post_folder") {
734
  $post_type = "post";
739
  } else {
740
  $post_type = trim($taxonomy, "'_folder'");
741
  }
742
+
743
+ $arg = [
744
  'post_type' => $post_type,
745
+ 'taxonomy' => $taxonomy,
746
+ ];
747
  $trash_count = apply_filters("premio_folder_item_in_taxonomy", $term->term_id, $arg);
748
  }
749
 
750
  if ($trash_count === null) {
751
+ $query = "SELECT COUNT(DISTINCT(p.ID))
 
752
  FROM {$post_table} p
753
  JOIN {$term_table} rl ON p.ID = rl.object_id
754
+ WHERE rl.term_taxonomy_id = '%d' AND p.post_status != 'trash' LIMIT 1";
755
+ $query = $wpdb->prepare($query, $term->term_taxonomy_id);
756
  $result = $wpdb->get_var($query);
757
  if (intval($result) > 0) {
758
  $trash_count = intval($result);
760
  $trash_count = 0;
761
  }
762
  }
763
+ }//end if
764
+
765
  if ($trash_count === null) {
766
  $trash_count = 0;
767
  }
768
+
769
  $terms[$key]->trash_count = $trash_count;
770
  $trash_folders[$term->term_taxonomy_id] = $trash_count;
771
+ }//end if
772
+ }//end foreach
773
 
774
  if (!empty($terms) && $initial_trash_folders != $trash_folders) {
775
  delete_transient("premio_folders_without_trash");
776
+ set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
777
  }
778
+ }//end if
779
+
780
+ return $terms;
781
+
782
+ }//end get_terms_filter_without_trash()
783
 
784
+
785
+ /**
786
+ * Add Checkbox to page/post lists
787
+ *
788
+ * @since 1.0.0
789
+ * @access public
790
+ * @return $folders
791
+ */
792
+ public function custom_bulk_action($bulk_actions)
793
+ {
794
+ $bulk_actions['move_to_folder'] = __('Move to Folder', 'email_to_eric');
795
  return $bulk_actions;
 
796
 
797
+ }//end custom_bulk_action()
798
+
799
+
800
+ /**
801
+ * Folders domain for language translation
802
+ *
803
+ * @since 1.0.0
804
+ * @access public
805
+ * @return $folders
806
+ */
807
+ public function folders_text()
808
+ {
809
+ load_plugin_textdomain("folders", false, dirname(plugin_basename(__FILE__)).'/languages/');
810
+
811
+ }//end folders_text()
812
 
813
+
814
+ /**
815
+ * Add custom CSS to footer for media button
816
+ *
817
+ * @since 1.0.0
818
+ * @access public
819
+ * @return $folders
820
+ */
821
+ public function admin_footer_for_media()
822
+ {
823
  $customize_folders = get_option('customize_folders');
824
+ if (isset($customize_folders['dropdown_color']) && !empty($customize_folders['dropdown_color'])) {
825
  ?>
826
+ <style>
827
+ #media-attachment-taxonomy-filter, .post-upload-ui .folder_for_media, select.media-select-folder {
828
+ border-color: <?php echo esc_attr($customize_folders['dropdown_color']) ?>;
829
+ color: <?php echo esc_attr($customize_folders['dropdown_color']) ?>
830
+ }
831
+ .folder_for_media option {
832
+ color:#000000;
833
+ }
834
  .folder_for_media option:first-child {
835
+ font-weight: bold;
836
  }
837
+ </style>
838
  <?php
839
  }
 
 
840
 
841
+ }//end admin_footer_for_media()
842
+
843
+
844
+ /**
845
+ * Check for default page/post/media folder on load
846
+ *
847
+ * @since 1.0.0
848
+ * @access public
849
+ * @return $folders
850
+ */
851
+ public function check_for_default_folders()
852
+ {
853
  global $typenow, $current_screen;
854
+ $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0;
855
+ $options = get_option('folders_settings');
856
+ $options = (empty($options) || !is_array($options)) ? [] : $options;
857
+ $post_status = filter_input(INPUT_GET, 'post_status');
858
  $last_status = get_option("last_folder_status_for".$typenow);
859
+ if (empty($post_status) && !$isAjax && (in_array($typenow, $options) || !empty($last_status)) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) {
 
860
  $requests = filter_input_array(INPUT_GET);
861
+ $requests = empty($requests)||!is_array($requests) ? [] : $requests;
862
 
863
  if ($typenow == "attachment") {
864
+ if (count($requests) > 0) {
865
  return;
866
  }
867
  } else if ($typenow == "post") {
868
+ if (count($requests) > 0) {
869
  return;
870
  }
871
  } else {
872
+ if (count($requests) > 1) {
873
  return;
874
  }
875
  }
876
 
877
+ if (!empty($last_status)) {
878
  $status = 1;
879
+ if ($last_status != "-1" && $last_status != "all") {
880
  $type = self::get_custom_post_type($typenow);
881
  $term = get_term_by('slug', $last_status, $type);
882
  if (empty($term) || !is_object($term)) {
883
  $status = 0;
884
  }
885
  }
886
+
887
  delete_option("last_folder_status_for".$typenow);
888
+ if ($last_status == "all") {
889
  $last_status = "";
890
  }
891
+
892
+ if ($status) {
893
  if ($typenow == "attachment") {
894
  if (!isset($_REQUEST['media_folder'])) {
895
  ?>
901
  }
902
  } else {
903
  $post_type = self::get_custom_post_type($typenow);
904
+ $admin_url = admin_url("edit.php?post_type=".$typenow);
905
  if (!isset($_REQUEST[$post_type])) {
906
  ?>
907
  <script>
908
+ window.location = '<?php echo admin_url("edit.php?post_type=".esc_attr($typenow))."&".esc_attr($post_type)."=".esc_attr($last_status) ?>';
909
  </script>
910
  <?php
911
  exit;
912
  }
913
+ }//end if
914
+ }//end if
915
+ }//end if
916
 
917
  $default_folders = get_option('default_folders');
918
+ $default_folders = (empty($default_folders) || !is_array($default_folders)) ? [] : $default_folders;
919
 
920
  $status = 1;
921
+ if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
922
  $type = self::get_custom_post_type($typenow);
923
+ if ($default_folders[$typenow] != -1) {
924
  $term = get_term_by('slug', $default_folders[$typenow], $type);
925
  if (empty($term) || !is_object($term)) {
926
  $status = 0;
929
  } else {
930
  $status = 0;
931
  }
932
+
933
+ if ($status) {
934
  if ($typenow == "attachment") {
935
  if (!isset($_REQUEST['media_folder'])) {
936
  if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
943
  }
944
  }
945
  } else {
946
+ $search = filter_input(INPUT_GET, "s");
947
+ if (!empty($search)) {
948
+ $search = esc_attr($search);
949
+ } else {
950
+ $search = "";
951
  }
952
+
953
  $post_type = self::get_custom_post_type($typenow);
954
  if (!isset($_REQUEST[$post_type])) {
955
  if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
956
  ?>
957
  <script>
958
+ window.location = '<?php echo admin_url("edit.php?post_type=".esc_attr($typenow))."&".esc_attr($post_type)."=".esc_attr($default_folders[$typenow])."&s=".esc_attr($search) ?>';
959
  </script>
960
  <?php
961
  exit;
962
  }
963
  }
964
+ }//end if
965
+ }//end if
966
+ }//end if
967
+
968
+ }//end check_for_default_folders()
969
+
970
 
971
+ /**
972
+ * Signup for folders news
973
+ *
974
+ * @since 1.0.0
975
+ * @access public
976
+ * @return $folders
977
+ */
978
+ public function folder_update_status()
979
+ {
980
+ $response = [];
981
  $response['status'] = 0;
982
  $nonce = filter_input(INPUT_POST, 'nonce');
983
  if (!empty($nonce) && wp_verify_nonce($nonce, 'folder_update_status')) {
987
  if ($status == 1) {
988
  $email = sanitize_email($email);
989
 
990
+ $apiURL = "https://premioapps.com/premio/signup/index.php?plugin=folders&email=".esc_attr($email);
991
 
992
  $apiParams = [
993
  'plugin' => 'folders',
1007
 
1008
  echo json_encode($response);
1009
  die;
 
1010
 
1011
+ }//end folder_update_status()
1012
+
1013
+
1014
+ /**
1015
+ * Add category to media
1016
+ *
1017
+ * @since 1.0.0
1018
+ * @access public
1019
+ * @return $folders
1020
+ */
1021
  public function add_attachment_category($post_ID)
1022
  {
1023
+ if (self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
1024
+ $folder_id = null;
1025
+ if (isset($_REQUEST["folder_for_media"])) {
1026
+ $folder_id = $this->getRequestVar("folder_for_media");
1027
+ }
1028
+
1029
  if ($folder_id !== null) {
1030
+ $folder_id = (int) $folder_id;
1031
  $folder_id = self::sanitize_options($folder_id, "int");
1032
  if ($folder_id > 0) {
1033
  $post_type = self::get_custom_post_type("attachment");
1034
+ $term = get_term($folder_id);
1035
+ if (!empty($term) && isset($term->slug)) {
1036
+ wp_set_object_terms($post_ID, $term->slug, $post_type);
1037
+
1038
+ $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
1039
+ if ($trash_folders === false) {
1040
+ $trash_folders = [];
1041
+ $initial_trash_folders = [];
1042
+ }
1043
+
1044
+ if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
1045
+ unset($trash_folders[$term->term_taxonomy_id]);
1046
+ }
1047
+
1048
+ if ($initial_trash_folders != $trash_folders) {
1049
+ delete_transient("premio_folders_without_trash");
1050
+ set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
1051
+ }
1052
  }
1053
+ }//end if
1054
+ }//end if
1055
+ }//end if
1056
+
1057
+ }//end add_attachment_category()
1058
+
1059
 
1060
+ /**
1061
+ * Get Dropdown data for media popup
1062
+ *
1063
+ * @since 1.0.0
1064
+ * @access public
1065
+ * @return $folders
1066
+ */
1067
+ public function show_dropdown_on_media_screen()
1068
+ {
1069
+ if (self::is_for_this_post_type('attachment')) {
1070
  $post_type = self::get_custom_post_type('attachment');
1071
  global $typenow, $current_screen;
1072
+ // Free/Pro Class name change
1073
+ if (!class_exists('WCP_Tree')) {
1074
+ $files = [
1075
+ 'WCP_Tree' => WCP_DS."includes".WCP_DS."tree.class.php",
1076
+ ];
1077
 
1078
  foreach ($files as $file) {
1079
+ if (file_exists(dirname(dirname(__FILE__)).$file)) {
1080
+ include_once dirname(dirname(__FILE__)).$file;
1081
  }
1082
  }
1083
  }
1084
+
1085
+ // Free/Pro Class name change
1086
  $options = WCP_Tree::get_folder_option_data($post_type);?>
1087
  <p class="attachments-category"><?php esc_html_e("Select a folder (Optional)", 'folders'); ?></p>
1088
  <p class="attachments-category"><?php esc_html_e("First select the folder, and then upload the files", 'folders'); ?><br/></p>
1089
  <p>
1090
  <?php
1091
+ $request = sanitize_text_field($_SERVER['REQUEST_URI']);
1092
  $request = strpos($request, "post.php");
1093
  ?>
1094
  <select name="folder_for_media" class="folder_for_media">
1095
  <option value="-1">- <?php esc_html_e('Unassigned', 'folders'); ?></option>
1096
+ <?php echo ($options) ?>
1097
+ <?php if (($typenow == "attachment" && isset($current_screen->base) && $current_screen->base == "upload") || ($request !== false) || self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {?>
1098
  <option value="add-folder"><?php esc_html_e('+ Create a New Folder', 'folders'); ?></option>
1099
  <?php } ?>
1100
  </select>
1101
  </p>
1102
  <?php
1103
+ }//end if
1104
+
1105
+ }//end show_dropdown_on_media_screen()
1106
+
1107
 
1108
+ /**
1109
+ * Hide folders
1110
+ *
1111
+ * @since 1.0.0
1112
+ * @access public
1113
+ * @return $folders
1114
+ */
1115
  public function wcp_hide_folders()
1116
  {
1117
+ $response = [];
1118
+ $response['status'] = 0;
1119
+ $response['error'] = 0;
1120
+ $response['data'] = [];
1121
  $response['message'] = "";
1122
+ $postData = filter_input_array(INPUT_POST);
1123
+ $errorCounter = 0;
1124
 
1125
  if (!isset($postData['status']) || empty($postData['status'])) {
1126
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1138
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
1139
  $errorCounter++;
1140
  } else {
1141
+ $type = self::sanitize_options($postData['type']);
1142
  $nonce = self::sanitize_options($postData['nonce']);
1143
+ if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
1144
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1145
  $errorCounter++;
1146
  }
1147
+ }//end if
1148
+
1149
  if ($errorCounter == 0) {
1150
+ $type = self::sanitize_options($postData['type']);
1151
+ $status = self::sanitize_options($postData['status']);
1152
+ $optionName = "wcp_folder_display_status_".$type;
1153
  update_option($optionName, $status);
1154
  $response['status'] = 1;
1155
  }
1156
+
1157
  echo json_encode($response);
1158
  wp_die();
 
1159
 
1160
+ }//end wcp_hide_folders()
1161
+
1162
+
1163
+ /**
1164
+ * Change status for folders
1165
+ *
1166
+ * @since 1.0.0
1167
+ * @access public
1168
+ * @return $folders
1169
+ */
1170
  public function wcp_change_folder_display_status()
1171
  {
1172
+ $response = [];
1173
+ $response['status'] = 0;
1174
+ $response['error'] = 0;
1175
+ $response['data'] = [];
1176
  $response['message'] = "";
1177
+ $postData = filter_input_array(INPUT_POST);
1178
+ $errorCounter = 0;
1179
  if (!isset($postData['status']) || empty($postData['status'])) {
1180
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1181
  $errorCounter++;
1192
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
1193
  $errorCounter++;
1194
  } else {
1195
+ $type = self::sanitize_options($postData['type']);
1196
  $nonce = self::sanitize_options($postData['nonce']);
1197
+ if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
1198
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1199
  $errorCounter++;
1200
  }
1201
+ }//end if
1202
+
1203
  if ($errorCounter == 0) {
1204
+ $type = self::sanitize_options($postData['type']);
1205
+ $width = self::sanitize_options($postData['status']);
1206
+ $optionName = "wcp_dynamic_display_status_".$type;
1207
  update_option($optionName, $width);
1208
  $response['status'] = 1;
1209
  }
1210
+
1211
  echo json_encode($response);
1212
  wp_die();
1213
+
1214
+ }//end wcp_change_folder_display_status()
1215
+
1216
+
1217
+ /**
1218
+ * Check for folders for page/post/media id
1219
+ *
1220
+ * @since 1.0.0
1221
+ * @access public
1222
+ * @return $folders
1223
+ */
1224
+ public function premio_check_for_other_folders()
1225
+ {
1226
+ $response = [];
1227
+ $response['status'] = 0;
1228
+ $response['error'] = 0;
1229
+ $response['data'] = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1230
  $response['message'] = "";
1231
+ $postData = filter_input_array(INPUT_POST);
1232
+ $errorCounter = 0;
1233
  if (!isset($postData['post_id']) || empty($postData['post_id'])) {
1234
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1235
  $errorCounter++;
1239
  } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1240
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1241
  $errorCounter++;
1242
+ } else if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['type'])) {
1243
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1244
  $errorCounter++;
1245
+ } else if (!current_user_can("manage_categories")) {
1246
  $response['message'] = esc_html__("Your request is not valid", 'folders');
1247
  $errorCounter++;
1248
  }
1249
+
1250
  if ($errorCounter == 0) {
1251
+ $folderUndoSettings = [];
1252
+ $type = self::sanitize_options($postData['type']);
1253
  $post_id = self::sanitize_options($postData['post_id']);
1254
 
1255
  $post_id = explode(",", $post_id);
1256
 
1257
  $taxonomy = self::get_custom_post_type($type);
1258
 
1259
+ foreach ($post_id as $id) {
1260
+ $terms = get_the_terms($id, $taxonomy);
1261
+ if (!empty($terms) && is_array($terms)) {
1262
+ foreach ($terms as $term) {
1263
+ if ($term->term_id != $postData['taxonomy']) {
1264
+ $response['status'] = -1;
1265
+ $response['data']['post_id'] = $postData['post_id'];
1266
+ echo json_encode($response);
1267
+ wp_die();
1268
+ }
1269
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1270
  }
1271
  }
 
 
1272
 
1273
+ $this->wcp_remove_post_folder();
1274
+ }//end if
1275
+
1276
+ echo json_encode($response);
1277
+ wp_die();
1278
+
1279
+ }//end premio_check_for_other_folders()
1280
+
1281
+
1282
+ /**
1283
+ * Remove Folder
1284
+ *
1285
+ * @since 1.0.0
1286
+ * @access public
1287
+ * @return $folders
1288
+ */
1289
+ public function wcp_remove_post_folder()
1290
+ {
1291
+ $response = [];
1292
+ $response['status'] = 0;
1293
+ $response['error'] = 0;
1294
+ $response['data'] = [];
1295
+ $response['message'] = "";
1296
+ $postData = filter_input_array(INPUT_POST);
1297
+ $errorCounter = 0;
1298
+ if (!isset($postData['post_id']) || empty($postData['post_id'])) {
1299
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
1300
+ $errorCounter++;
1301
+ } else if (!isset($postData['type']) || empty($postData['type'])) {
1302
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
1303
+ $errorCounter++;
1304
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1305
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
1306
+ $errorCounter++;
1307
+ } else if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['type'])) {
1308
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
1309
+ $errorCounter++;
1310
+ } else if (!current_user_can("manage_categories")) {
1311
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
1312
+ $errorCounter++;
1313
  }
1314
+
1315
+ if ($errorCounter == 0) {
1316
+ $folderUndoSettings = [];
1317
+ $type = self::sanitize_options($postData['type']);
1318
+ $post_id = self::sanitize_options($postData['post_id']);
1319
+
1320
+ $post_id = explode(",", $post_id);
1321
+
1322
+ $taxonomy = self::get_custom_post_type($type);
1323
+
1324
+ $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
1325
+ if ($trash_folders === false) {
1326
+ $trash_folders = [];
1327
+ $initial_trash_folders = [];
1328
+ }
1329
+
1330
+ foreach ($post_id as $id) {
1331
+ if (!empty($id) && is_numeric($id) && $id > 0) {
1332
+ $terms = get_the_terms($id, $taxonomy);
1333
+ $post_terms = [
1334
+ 'post_id' => $id,
1335
+ 'terms' => $terms,
1336
+ ];
1337
+ if (!empty($terms) && count($terms) > 0) {
1338
+ foreach ($terms as $term) {
1339
+ if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
1340
+ unset($trash_folders[$term->term_taxonomy_id]);
1341
+ }
1342
+ }
1343
+ }
1344
+
1345
+ $folderUndoSettings[] = $post_terms;
1346
+ if (isset($postData['remove_from']) && $postData['remove_from'] == "current" && isset($postData['remove_from']) && $postData['remove_from'] == "current" && isset($postData['active_folder']) && is_numeric($postData['active_folder'])) {
1347
+ wp_remove_object_terms($id, intval($postData['active_folder']), $taxonomy);
1348
+ } else {
1349
+ wp_delete_object_term_relationships($id, $taxonomy);
1350
+ }
1351
+ }//end if
1352
+ }//end foreach
1353
+
1354
+ delete_transient("folder_undo_settings");
1355
+ set_transient("folder_undo_settings", $folderUndoSettings, DAY_IN_SECONDS);
1356
+
1357
+ if ($initial_trash_folders != $trash_folders) {
1358
+ delete_transient("premio_folders_without_trash");
1359
+ set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
1360
+ }
1361
+
1362
+ $response['status'] = 1;
1363
+ }//end if
1364
+
1365
  echo json_encode($response);
1366
  wp_die();
 
1367
 
1368
+ }//end wcp_remove_post_folder()
1369
+
1370
+
1371
+ /**
1372
+ * Filter records by selected categories
1373
+ *
1374
+ * @since 1.0.0
1375
+ * @access public
1376
+ * @return $folders
1377
+ */
1378
+ public function filter_record_list($query)
1379
+ {
1380
  global $typenow;
1381
 
1382
+ if ($typenow == "attachment") {
1383
  return;
1384
  }
1385
 
1386
+ if (!self::is_for_this_post_type($typenow)) {
1387
  return $query;
1388
  }
1389
 
1390
  $taxonomy = self::get_custom_post_type($typenow);
1391
 
1392
+ if (! isset($query->query['post_type'])) {
1393
  return $query;
1394
  }
1395
 
1396
+ if (! isset($_REQUEST[$taxonomy])) {
1397
  return $query;
1398
  }
1399
 
1400
+ $term = sanitize_text_field($_REQUEST[$taxonomy]);
1401
+ if ($term != "-1") {
1402
  return $query;
1403
  }
1404
 
1405
+ unset($query->query_vars[$taxonomy]);
1406
 
1407
+ $tax_query = [
1408
+ 'taxonomy' => $taxonomy,
1409
+ 'operator' => 'NOT EXISTS',
1410
+ ];
1411
 
1412
+ $query->set('tax_query', [ $tax_query ]);
1413
+ $query->tax_query = new WP_Tax_Query([ $tax_query ]);
1414
 
1415
  return $query;
 
1416
 
1417
+ }//end filter_record_list()
1418
+
1419
+
1420
+ /**
1421
+ * Get folders list
1422
+ *
1423
+ * @since 1.0.0
1424
+ * @access public
1425
+ * @return $folders
1426
+ */
1427
+ public function wcp_get_default_list()
1428
+ {
1429
 
1430
  $postData = filter_input_array(INPUT_POST);
1431
 
1439
 
1440
  $taxonomies = self::get_terms_hierarchical($post_type);
1441
 
1442
+ $response = [
1443
+ 'status' => 1,
1444
  'total_items' => $ttpsts,
1445
+ 'taxonomies' => $taxonomies,
1446
+ 'empty_items' => $empty_items,
1447
+ ];
1448
  echo json_encode($response);
1449
  wp_die();
 
1450
 
1451
+ }//end wcp_get_default_list()
1452
+
1453
+
1454
+ /**
1455
+ * Get folders list
1456
+ *
1457
+ * @since 1.0.0
1458
+ * @access public
1459
+ * @return $folders
1460
+ */
1461
+ function get_folders_default_list()
1462
+ {
1463
  $postData = filter_input_array(INPUT_POST);
1464
 
1465
  $post_type = $postData['type'];
1472
 
1473
  $taxonomies = self::get_terms_hierarchical($post_type);
1474
 
1475
+ $response = [
1476
+ 'status' => 1,
1477
  'total_items' => $ttpsts,
1478
  'empty_items' => $empty_items,
1479
+ 'taxonomies' => $taxonomies,
1480
+ ];
1481
  echo json_encode($response);
1482
  die;
1483
 
1484
+ }//end get_folders_default_list()
1485
+
1486
 
1487
+ /**
1488
+ * Save folders data for page/post id
1489
+ *
1490
+ * @since 1.0.0
1491
+ * @access public
1492
+ * @return $folders
1493
+ */
1494
+ function save_media_terms($post_id)
1495
+ {
1496
+ if (wp_is_post_revision($post_id)) {
1497
  return;
1498
  }
1499
+
1500
  $post = get_post($post_id);
1501
+ if ($post->post_type !== 'attachment') {
1502
  return;
1503
  }
1504
+
1505
+ $post_type = self::get_custom_post_type('attachment');
1506
+ $selected_folder = get_option("selected_".esc_attr($post_type)."_folder");
1507
+ if ($selected_folder != null && !empty($selected_folder)) {
1508
  $terms = get_term($selected_folder);
1509
+ if (!empty($terms) && isset($terms->term_id)) {
1510
  wp_set_post_terms($post_id, $terms->term_id, $post_type, false);
1511
  }
1512
  }
 
1513
 
1514
+ }//end save_media_terms()
1515
+
1516
+
1517
+ /**
1518
+ * Filter attachment data by folder
1519
+ *
1520
+ * @since 1.0.0
1521
+ * @access public
1522
+ * @return $folders
1523
+ */
1524
+ public function filter_attachments_grid($args)
1525
+ {
1526
  $taxonomy = 'media_folder';
1527
+ if (! isset($args[$taxonomy])) {
1528
  return $args;
1529
  }
1530
+
1531
+ $term = sanitize_text_field($args[$taxonomy]);
1532
+ if ($term != "-1") {
1533
  return $args;
1534
  }
1535
+
1536
+ unset($args[$taxonomy]);
1537
+ $args['tax_query'] = [
1538
+ [
1539
+ 'taxonomy' => $taxonomy,
1540
+ 'operator' => 'NOT EXISTS',
1541
+ ],
1542
+ ];
1543
+ $args = apply_filters('media_library_organizer_media_filter_attachments_grid', $args);
1544
  return $args;
 
1545
 
1546
+ }//end filter_attachments_grid()
1547
+
1548
+
1549
+ /**
1550
+ * Get unassigned page, post, media
1551
+ *
1552
+ * @since 1.0.0
1553
+ * @access public
1554
+ * @return $folders
1555
+ */
1556
+ public function get_tempt_posts($post_type="")
1557
  {
1558
  global $wpdb;
1559
 
1560
+ $post_table = $wpdb->prefix."posts";
1561
+ $term_table = $wpdb->prefix."term_relationships";
1562
  $term_taxonomy_table = $wpdb->prefix."term_taxonomy";
1563
+ $taxonomy = self::get_custom_post_type($post_type);
1564
  $tlrcds = null;
1565
+ if (has_filter("premio_folder_un_categorized_items")) {
1566
  $tlrcds = apply_filters("premio_folder_un_categorized_items", $post_type, $taxonomy);
1567
  }
1568
+
1569
+ if ($tlrcds === null) {
1570
  if ($post_type != "attachment") {
1571
  $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND (
1572
  NOT EXISTS (
1589
  AND {$term_table}.object_id = {$post_table}.ID
1590
  )
1591
  ) AND {$post_table}.post_type = '%s' AND {$post_table}.post_status = 'inherit'";
1592
+ }//end if
1593
 
1594
  $query = $wpdb->prepare($query, $taxonomy, $post_type);
1595
 
1596
  $tlrcds = $wpdb->get_var($query);
1597
+ }//end if
1598
 
1599
+ if (!empty($tlrcds)) {
1600
  return $tlrcds;
1601
  } else {
1602
  return 0;
1603
  }
 
1604
 
1605
+ }//end get_tempt_posts()
1606
+
1607
+
1608
+ /**
1609
+ * Filter input data
1610
+ *
1611
+ * @since 1.0.0
1612
+ * @access public
1613
+ * @return $folders
1614
+ */
1615
+ public function getRequestVar($var)
1616
+ {
1617
+ $response = filter_input(INPUT_POST, $var);
1618
+ if (empty($response)) {
1619
+ $response = filter_input(INPUT_GET, $var);
1620
+ }
1621
+
1622
+ return $response;
1623
+
1624
+ }//end getRequestVar()
1625
+
1626
+
1627
+ /**
1628
+ * Redirect to default folder
1629
+ *
1630
+ * @since 1.0.0
1631
+ * @access public
1632
+ * @return $folders
1633
+ */
1634
+ public function output_backbone_view_filters()
1635
+ {
1636
 
1637
  global $typenow, $current_screen;
1638
+ $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0;
1639
+ $options = get_option('folders_settings');
1640
+ $options = (empty($options) || !is_array($options)) ? [] : $options;
1641
  $last_status = get_option("last_folder_status_for".$typenow);
1642
+ if (!$isAjax && (in_array($typenow, $options) || !empty($last_status)) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) {
 
1643
  $default_folders = get_option('default_folders');
1644
+ $default_folders = (empty($default_folders) || !is_array($default_folders)) ? [] : $default_folders;
1645
 
1646
+ if (!empty($last_status)) {
1647
  $status = 1;
1648
+ if ($last_status != "-1" && $last_status != "all") {
1649
  $type = self::get_custom_post_type($typenow);
1650
  $term = get_term_by('slug', $last_status, $type);
1651
  if (empty($term) || !is_object($term)) {
1652
  $status = 0;
1653
  }
1654
  }
1655
+
1656
  delete_option("last_folder_status_for".$typenow);
1657
+ if ($last_status == "all") {
1658
  $last_status = "";
1659
  }
1660
+
1661
+ if ($status) {
1662
  if ($typenow == "attachment") {
1663
  if (!isset($_REQUEST['media_folder'])) {
1664
  ?>
1670
  }
1671
  }
1672
  }
1673
+ }//end if
1674
 
1675
  $status = 1;
1676
+ if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
1677
  $type = self::get_custom_post_type($typenow);
1678
+ if ($default_folders[$typenow] != -1) {
1679
  $term = get_term_by('slug', $default_folders[$typenow], $type);
1680
  if (empty($term) || !is_object($term)) {
1681
  $status = 0;
1684
  } else {
1685
  $status = 0;
1686
  }
1687
+
1688
+ if ($status) {
1689
  if ($typenow == "attachment") {
1690
  if (!isset($_REQUEST['media_folder'])) {
1691
  if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
1699
  }
1700
  }
1701
  }
1702
+ }//end if
1703
 
1704
+ if (!(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media'))) {
1705
  return;
1706
  }
1707
 
1708
  if ($typenow == "attachment") {
1709
+ // Free/Pro URL Change
1710
  global $typenow;
1711
  $is_active = 1;
1712
+ $folders = -1;
1713
+
1714
+ $hasStars = self::check_for_setting("has_stars", "general");
1715
+ $hasChild = self::check_for_setting("has_child", "general");
1716
+ $hasChild = empty($hasChild) ? 0 : 1;
1717
+ $hasStars = empty($hasStars) ? 0 : 1;
1718
+ // Free/Pro URL Change
1719
+ wp_enqueue_script('folders-media', WCP_FOLDER_URL.'assets/js/media.js', [ 'media-editor', 'media-views' ], WCP_FOLDER_VERSION, true);
1720
+ wp_localize_script(
1721
+ 'folders-media',
1722
+ 'folders_media_options',
1723
+ [
1724
+ 'terms' => self::get_terms_hierarchical('media_folder'),
1725
+ 'taxonomy' => get_taxonomy('media_folder'),
1726
+ 'ajax_url' => admin_url("admin-ajax.php"),
1727
+ 'activate_url' => $this->getFoldersUpgradeURL(),
1728
+ 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
1729
+ 'is_key_active' => $is_active,
1730
+ 'hasStars' => $hasStars,
1731
+ 'hasChildren' => $hasChild,
1732
+ ]
1733
+ );
1734
+ // Free/Pro URL Change
1735
+ wp_enqueue_style('folders-media', WCP_FOLDER_URL.'assets/css/media.css', [], WCP_FOLDER_VERSION);
1736
+ } else if (!self::is_active_for_screen() && self::is_for_this_post_type('attachment')) {
1737
+ // Free/Pro URL Change
1738
  global $typenow;
1739
  global $current_screen;
1740
+ // echo "<pre>"; print_r($current_screen); die;
1741
+ if (!isset($current_screen->base) || $current_screen->base != "plugins") {
1742
  $is_active = 1;
1743
+ $folders = -1;
1744
 
1745
  remove_filter("terms_clauses", "TO_apply_order_filter");
1746
 
1747
+ // Free/Pro URL Change
1748
  $is_rtl = 0;
1749
  if (function_exists('is_rtl') && is_rtl()) {
1750
  $is_rtl = 1;
1751
  }
1752
+
1753
  $can_manage_folder = current_user_can("manage_categories") ? 1 : 0;
1754
+ $width = 275;
1755
  $taxonomy_status = 0;
1756
  $selected_taxonomy = "";
1757
+ $show_in_page = false;
1758
+ $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
1759
 
1760
  $taxonomies = self::get_terms_hierarchical('media_folder');
1761
 
1762
+ $folder_settings = [];
1763
+ foreach ($taxonomies as $taxonomy) {
1764
+ $is_sticky = get_term_meta($taxonomy->term_id, "is_folder_sticky", true);
1765
+ $is_high = get_term_meta($taxonomy->term_id, "is_highlighted", true);
1766
+ $folder_settings[] = [
1767
+ 'folder_id' => $taxonomy->term_id,
1768
+ 'is_sticky' => intval($is_sticky),
1769
+ 'is_high' => intval($is_high),
1770
+ 'nonce' => wp_create_nonce('wcp_folder_term_'.$taxonomy->term_id),
1771
+ 'is_deleted' => 0,
1772
+ 'slug' => $taxonomy->slug,
1773
+ 'folder_count' => intval($taxonomy->trash_count),
1774
+ ];
1775
  }
1776
 
1777
+ $hasStars = self::check_for_setting("has_stars", "general");
1778
+ $hasChild = self::check_for_setting("has_child", "general");
1779
+ $hasChild = empty($hasChild) ? 0 : 1;
1780
+ $hasStars = empty($hasStars) ? 0 : 1;
1781
 
1782
+ $customize_folders = get_option('customize_folders');
1783
+ $use_folder_undo = !isset($customize_folders['use_folder_undo']) ? "yes" : $customize_folders['use_folder_undo'];
1784
+ $defaultTimeout = !isset($customize_folders['default_timeout']) ? 5 : intval($customize_folders['default_timeout']);
1785
+ if (empty($defaultTimeout) || !is_numeric($defaultTimeout) || $defaultTimeout < 0) {
1786
+ $defaultTimeout = 5;
1787
+ }
1788
+
1789
+ $defaultTimeout = ($defaultTimeout * 1000);
1790
 
1791
  $default_folders = get_option("default_folders");
1792
+ $default_folder = "";
1793
+ if (isset($default_folders["attachment"])) {
1794
  $default_folder = $default_folders["attachment"];
1795
  }
1796
+
1797
+ $use_shortcuts = !isset($customize_folders['use_shortcuts']) ? "yes" : $customize_folders['use_shortcuts'];
1798
+
1799
+ wp_dequeue_script("jquery-jstree");
1800
+ // CMS Tree Page View Conflict
1801
+ wp_enqueue_script('folders-tree', WCP_FOLDER_URL.'assets/js/jstree.min.js', [], WCP_FOLDER_VERSION);
1802
+ wp_enqueue_script('wcp-folders-mcustomscrollbar', WCP_FOLDER_URL.'assets/js/jquery.mcustomscrollbar.min.js', [], WCP_FOLDER_VERSION);
1803
+ wp_enqueue_script('wcp-folders-media', WCP_FOLDER_URL.'assets/js/page-post-media.min.js', ['jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'], WCP_FOLDER_VERSION, true);
1804
+ wp_enqueue_script('wcp-jquery-touch', plugin_dir_url(dirname(__FILE__)).'assets/js/jquery.ui.touch-punch.min.js', ['jquery'], WCP_FOLDER_VERSION);
1805
+ wp_localize_script(
1806
+ 'wcp-folders-media',
1807
+ 'folders_media_options',
1808
+ [
1809
+ 'terms' => $taxonomies,
1810
+ 'taxonomy' => get_taxonomy('media_folder'),
1811
+ 'ajax_url' => admin_url("admin-ajax.php"),
1812
+ 'media_page_url' => admin_url("upload.php?media_folder="),
1813
+ 'activate_url' => $this->getFoldersUpgradeURL(),
1814
+ 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
1815
+ 'is_key_active' => $is_active,
1816
+ 'folders' => $folders,
1817
+ 'upgrade_url' => $this->getFoldersUpgradeURL(),
1818
+ 'post_type' => 'attachment',
1819
+ 'page_url' => $admin_url,
1820
+ 'current_url' => "",
1821
+ 'ajax_image' => plugin_dir_url(dirname(__FILE__))."assets/images/ajax-loader.gif",
1822
+ 'register_url' => "",
1823
+ 'isRTL' => $is_rtl,
1824
+ 'can_manage_folder' => $can_manage_folder,
1825
+ 'folder_width' => $width,
1826
+ 'taxonomy_status' => $taxonomy_status,
1827
+ 'selected_taxonomy' => $selected_taxonomy,
1828
+ 'show_in_page' => $show_in_page,
1829
+ 'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png',
1830
+ 'folder_settings' => $folder_settings,
1831
+ 'hasStars' => $hasStars,
1832
+ 'hasChildren' => $hasChild,
1833
+ 'useFolderUndo' => $use_folder_undo,
1834
+ 'defaultTimeout' => $defaultTimeout,
1835
+ 'default_folder' => $default_folder,
1836
+ 'use_shortcuts' => $use_shortcuts,
1837
+ ]
1838
+ );
1839
+ // Free/Pro URL Change
1840
+ wp_enqueue_style('folders-jstree', WCP_FOLDER_URL.'assets/css/jstree.min.css', [], WCP_FOLDER_VERSION);
1841
+ wp_enqueue_style('wcp-folders-mcustomscrollbar', WCP_FOLDER_URL.'assets/css/jquery.mcustomscrollbar.min.css', [], WCP_FOLDER_VERSION);
1842
+ wp_enqueue_style('folder-folders', WCP_FOLDER_URL.'assets/css/folders.min.css', [], WCP_FOLDER_VERSION);
1843
+ wp_enqueue_style('folders-media', WCP_FOLDER_URL.'assets/css/page-post-media.min.css', [], WCP_FOLDER_VERSION);
1844
+ wp_enqueue_style('folder-icon', WCP_FOLDER_URL.'assets/css/folder-icon.css', [], WCP_FOLDER_VERSION);
1845
+ $width = 275;
1846
+ $string = "";
1847
  $css_text = "";
1848
  $customize_folders = get_option('customize_folders');
1849
  if (!isset($customize_folders['new_folder_color']) || empty($customize_folders['new_folder_color'])) {
1850
+ $customize_folders['new_folder_color'] = "#FA166B";
1851
  }
1852
+
1853
+ $css_text .= ".media-frame a.add-new-folder { background-color: ".esc_attr($customize_folders['new_folder_color'])."; border-color: ".esc_attr($customize_folders['new_folder_color'])."}";
1854
+ $css_text .= ".wcp-hide-show-buttons .toggle-buttons { background-color: ".esc_attr($customize_folders['new_folder_color'])."; }";
1855
+ $css_text .= ".folders-toggle-button span { background-color: ".esc_attr($customize_folders['new_folder_color'])."; }";
1856
+ $css_text .= ".ui-resizable-handle.ui-resizable-e:before, .ui-resizable-handle.ui-resizable-w:before {border-color: ".esc_attr($customize_folders['new_folder_color'])." !important}";
1857
 
1858
  if (!isset($customize_folders['folder_bg_color']) || empty($customize_folders['folder_bg_color'])) {
1859
+ $customize_folders['folder_bg_color'] = "#FA166B";
1860
  }
1861
+
1862
+ $rgbColor = self::hexToRgb($customize_folders['folder_bg_color']);
1863
+ $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked), body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked):hover { background: rgba(".esc_attr($rgbColor['r']).",".esc_attr($rgbColor['g']).",".esc_attr($rgbColor['b']).", 0.08) !important; color: #333333;}";
1864
+ $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked, body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked:not(.jstree-clicked):focus, #custom-scroll-menu .jstree-clicked, #custom-scroll-menu .jstree-clicked:hover { background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff !important; }";
1865
+ $css_text .= "#custom-scroll-menu .jstree-hovered.wcp-drop-hover, #custom-scroll-menu .jstree-hovered.wcp-drop-hover:hover, #custom-scroll-menu .jstree-clicked.wcp-drop-hover, #custom-scroll-menu .jstree-clicked.wcp-drop-hover:hover, body #custom-scroll-menu *.drag-in >, body #custom-scroll-menu *.drag-in > a:hover { background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff !important; }";
1866
+ $css_text .= ".drag-bot > a { border-bottom: solid 2px ".esc_attr($customize_folders['folder_bg_color'])."}";
1867
+ $css_text .= ".drag-up > a { border-top: solid 2px ".esc_attr($customize_folders['folder_bg_color'])."}";
1868
+ $css_text .= "body:not(.no-hover-css) #custom-scroll-menu *.drag-in > a.jstree-hovered, body:not(.no-hover-css) #custom-scroll-menu *.drag-in > a.jstree-hovered:hover {background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #fff !important;}";
1869
+ $css_text .= ".orange-bg > span, .jstree-clicked, .header-posts a.active-item, .un-categorised-items.active-item, .sticky-folders ul li a.active-item { background-color: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff !important; }";
1870
  $css_text .= "body:not(.no-hover-css) .wcp-container .route .title:hover, body:not(.no-hover-css) .header-posts a:hover, body:not(.no-hover-css) .un-categorised-items:hover, body:not(.no-hover-css) .sticky-folders ul li a:hover { background: rgba(".esc_attr($rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08")."); color: #333333;}";
1871
+ $css_text .= ".wcp-drop-hover {background-color: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff; }";
1872
+ $css_text .= "#custom-menu .route .nav-icon .wcp-icon {color: ".esc_attr($customize_folders['folder_bg_color'])." !important;}";
1873
+ $css_text .= ".mCS-3d.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar {background-color: ".esc_attr($customize_folders['folder_bg_color'])." !important;}";
1874
+ $css_text .= "body:not(.no-hover-css) .jstree-hovered {background: rgba(".esc_attr($rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08").") }";
1875
+ $css_text .= ".jstree-default .jstree-clicked { background-color:".esc_attr($customize_folders['folder_bg_color'])."}";
1876
+ $css_text .= ".jstree-node.drag-in > a.jstree-anchor.jstree-hovered { background-color: ".esc_attr($customize_folders['folder_bg_color'])."; color: #ffffff; }";
1877
+ $css_text .= "#custom-scroll-menu .jstree-hovered:not(.jstree-clicked) .pfolder-folder-close { color: ".esc_attr($customize_folders['folder_bg_color'])."; }";
 
1878
 
1879
  if (!isset($customize_folders['bulk_organize_button_color']) || empty($customize_folders['bulk_organize_button_color'])) {
1880
+ $customize_folders['bulk_organize_button_color'] = "#FA166B";
1881
  }
1882
+
1883
+ $css_text .= "button.button.organize-button { background-color: ".esc_attr($customize_folders['bulk_organize_button_color'])."; border-color: ".esc_attr($customize_folders['bulk_organize_button_color'])."; }";
1884
+ $css_text .= "button.button.organize-button:hover { background-color: ".esc_attr($customize_folders['bulk_organize_button_color'])."; border-color: ".esc_attr($customize_folders['bulk_organize_button_color'])."; }";
1885
 
1886
  $font_family = "";
1887
  if (isset($customize_folders['folder_font']) && !empty($customize_folders['folder_font'])) {
1888
  $folder_fonts = self::get_font_list();
1889
+ $font_family = $customize_folders['folder_font'];
1890
  if (isset($folder_fonts[$font_family])) {
1891
+ $css_text .= ".wcp-container, .folder-popup-form { font-family: ".esc_attr($font_family)." !important; }";
1892
  }
1893
+
1894
  if ($folder_fonts[$font_family] == "Default") {
1895
  $font_family = "";
1896
  }
1897
  }
1898
+
1899
  if (isset($customize_folders['folder_size']) && !empty($customize_folders['folder_size'])) {
1900
+ $css_text .= ".wcp-container .route span.title-text, .header-posts a, .un-categorised-items a, .sticky-title { font-size: ".esc_attr($customize_folders['folder_size'])."px; }";
1901
  }
1902
+
1903
  if (!empty($font_family)) {
1904
+ wp_enqueue_style('custom-google-fonts', 'https://fonts.googleapis.com/css?family='.urlencode($font_family), false);
1905
  }
1906
+
1907
  wp_add_inline_style('folders-media', $css_text);
1908
+ }//end if
1909
+ }//end if
1910
+
1911
+ }//end output_backbone_view_filters()
1912
+
1913
+
1914
+ /**
1915
+ * Get folders by hierarchy
1916
+ *
1917
+ * @since 1.0.0
1918
+ * @access public
1919
+ * @return $folders
1920
+ */
1921
+ public function get_terms_hierarchical($taxonomy)
1922
+ {
1923
+ $terms = get_terms(
1924
+ [
1925
+ 'taxonomy' => $taxonomy,
1926
+ 'hide_empty' => false,
1927
+ 'parent' => 0,
1928
+ 'orderby' => 'meta_value_num',
1929
+ 'order' => 'ASC',
1930
+ 'hierarchical' => false,
1931
+ 'update_count_callback' => '_update_generic_term_count',
1932
+ 'meta_query' => [
1933
+ [
1934
+ 'key' => 'wcp_custom_order',
1935
+ 'type' => 'NUMERIC',
1936
+ ],
1937
+ ],
1938
+ ]
1939
+ );
1940
+ $hierarchical_terms = [];
1941
+ if (!empty($terms)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1942
  foreach ($terms as $term) {
1943
+ if (!empty($term) && isset($term->term_id)) {
1944
+ $term->term_name = $term->name;
1945
  $hierarchical_terms[] = $term;
1946
+ $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, "-");
1947
  }
1948
  }
1949
  }
1950
+
1951
  return $hierarchical_terms;
1952
+
1953
+ }//end get_terms_hierarchical()
1954
+
1955
+
1956
+ /**
1957
+ * Get Child folders
1958
+ *
1959
+ * @since 1.0.0
1960
+ * @access public
1961
+ * @return $folders
1962
+ */
1963
+ public static function get_child_terms($taxonomy, $hierarchical_terms, $term_id, $separator="-")
1964
+ {
1965
+ $terms = get_terms(
1966
+ [
1967
+ 'taxonomy' => $taxonomy,
1968
+ 'hide_empty' => false,
1969
+ 'parent' => $term_id,
1970
+ 'orderby' => 'meta_value_num',
1971
+ 'order' => 'ASC',
1972
+ 'hierarchical' => false,
1973
+ 'update_count_callback' => '_update_generic_term_count',
1974
+ 'meta_query' => [
1975
+ [
1976
+ 'key' => 'wcp_custom_order',
1977
+ 'type' => 'NUMERIC',
1978
+ ],
1979
+ ],
1980
+ ]
1981
+ );
1982
+ if (!empty($terms)) {
1983
  foreach ($terms as $term) {
1984
+ if (isset($term->name)) {
1985
+ $term->name = $separator." ".$term->name;
1986
+ $term->term_name = trim($term->name, "-");
1987
  $hierarchical_terms[] = $term;
1988
+ $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, $separator."-");
1989
  }
1990
  }
1991
  }
1992
 
1993
  return $hierarchical_terms;
 
1994
 
1995
+ }//end get_child_terms()
1996
+
1997
+
1998
+ /**
1999
+ * Update folders data for page, post, media
2000
+ *
2001
+ * @since 1.0.0
2002
+ * @access public
2003
+ * @return $folders
2004
+ */
2005
+ public function update_folder_new_term_relationships($object_id="", $term_ids=[], $taxonomy="")
2006
+ {
2007
+ if (is_array($term_ids) && !empty($term_ids)) {
2008
+ $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
2009
+ if ($trash_folders === false) {
2010
+ $trash_folders = [];
2011
+ $initial_trash_folders = [];
2012
+ }
2013
 
2014
+ foreach ($term_ids as $term_id) {
2015
  $term = get_term($term_id, $taxonomy);
2016
+ if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
2017
+ unset($trash_folders[$term->term_taxonomy_id]);
2018
+ }
2019
+ }
2020
+
2021
+ if ($initial_trash_folders != $trash_folders) {
2022
+ delete_transient("premio_folders_without_trash");
2023
+ set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
2024
+ }
2025
+ }
2026
+
2027
+ }//end update_folder_new_term_relationships()
2028
+
2029
+
2030
+ /**
2031
+ * Update folders data for page, post, media
2032
+ *
2033
+ * @since 1.0.0
2034
+ * @access public
2035
+ * @return $folders
2036
+ */
2037
+ public function update_folder_term_relationships($object_id="", $term_ids=[], $taxonomy="")
2038
+ {
2039
+ if (is_array($term_ids) && !empty($term_ids)) {
2040
+ $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
2041
+ if ($trash_folders === false) {
2042
+ $trash_folders = [];
2043
+ $initial_trash_folders = [];
2044
+ }
2045
+
2046
+ foreach ($term_ids as $term_id) {
2047
  $term = get_term($term_id, $taxonomy);
2048
+ if (isset($term->term_taxonomy_id) && isset($trash_folders[$term_id])) {
2049
+ unset($trash_folders[$term->term_taxonomy_id]);
2050
+ }
2051
+ }
2052
+
2053
+ if ($initial_trash_folders != $trash_folders) {
2054
+ delete_transient("premio_folders_without_trash");
2055
+ set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
2056
+ }
2057
+ }
2058
 
2059
+ }//end update_folder_term_relationships()
 
 
 
 
 
2060
 
 
2061
 
2062
+ /**
2063
+ * Get child folders
2064
+ *
2065
+ * @since 1.0.0
2066
+ * @access public
2067
+ * @return $folders
2068
+ */
2069
+ private function add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $current_term_id, $current_depth)
2070
+ {
2071
+
2072
+ if (! isset($hierarchy[$current_term_id])) {
2073
  return $hierarchical_terms;
2074
  }
2075
 
2076
+ foreach ($hierarchy[$current_term_id] as $child_term_id) {
2077
+ $child_term = get_term($child_term_id, $taxonomy);
 
2078
 
2079
+ $child_term->name = str_pad('', $current_depth, '-', STR_PAD_LEFT).' '.$child_term->name;
2080
 
2081
  $hierarchical_terms[] = $child_term;
2082
 
2083
+ $hierarchical_terms = self::add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $child_term_id, ( $current_depth + 1 ));
2084
  }
2085
 
2086
  return $hierarchical_terms;
 
2087
 
2088
+ }//end add_child_terms_recursive()
2089
+
2090
+
2091
+ /**
2092
+ * Filter data for attachments
2093
+ *
2094
+ * @since 1.0.0
2095
+ * @access public
2096
+ * @return $folders
2097
+ */
2098
+ public function filter_attachments_list($query)
2099
+ {
2100
 
2101
+ if (! isset($query->query['post_type'])) {
2102
  return $query;
2103
  }
2104
 
2105
+ if (is_array($query->query['post_type']) && ! in_array('attachment', $query->query['post_type'])) {
2106
  return $query;
2107
  }
2108
+
2109
+ if (! is_array($query->query['post_type']) && strpos($query->query['post_type'], 'attachment') === false) {
2110
  return $query;
2111
  }
2112
 
2113
+ if (! isset($_REQUEST['media_folder'])) {
2114
  return $query;
2115
  }
2116
 
2117
  $term = sanitize_text_field(wp_unslash($_REQUEST['media_folder']));
2118
+ if ($term != "-1") {
2119
  return $query;
2120
  }
2121
 
2122
+ unset($query->query_vars['media_folder']);
2123
 
2124
+ $tax_query = [
2125
+ 'taxonomy' => 'media_folder',
2126
+ 'operator' => 'NOT EXISTS',
2127
+ ];
2128
 
2129
+ $query->set('tax_query', [ $tax_query ]);
2130
+ $query->tax_query = new WP_Tax_Query([ $tax_query ]);
2131
 
2132
+ $query = apply_filters('media_library_organizer_media_filter_attachments', $query, $_REQUEST);
2133
 
2134
  return $query;
2135
 
2136
+ }//end filter_attachments_list()
2137
+
2138
 
2139
+ /**
2140
+ * Filter data for attachments
2141
+ *
2142
+ * @since 1.0.0
2143
+ * @access public
2144
+ * @return $folders
2145
+ */
2146
+ public function output_list_table_filters($post_type, $view_name)
2147
  {
2148
  if ($post_type != 'attachment') {
2149
  return;
2153
  return;
2154
  }
2155
 
2156
+ if (!self::is_for_this_post_type('attachment')) {
2157
  return;
2158
  }
2159
 
2160
  $current_term = false;
2161
+ if (isset($_REQUEST['media_folder'])) {
2162
  $current_term = sanitize_text_field($_REQUEST['media_folder']);
2163
  }
2164
 
2165
+ wp_dropdown_categories(
2166
+ [
2167
+ 'show_option_all' => esc_html__('All Folders', 'folders'),
2168
+ 'show_option_none' => esc_html__('(Unassigned)', 'folders'),
2169
+ 'option_none_value' => -1,
2170
+ 'orderby' => 'meta_value_num',
2171
+ 'order' => 'ASC',
2172
+ 'show_count' => true,
2173
+ 'hide_empty' => false,
2174
+ 'update_count_callback' => '_update_generic_term_count',
2175
+ 'echo' => true,
2176
+ 'selected' => $current_term,
2177
+ 'hierarchical' => true,
2178
+ 'name' => 'media_folder',
2179
+ 'id' => '',
2180
+ 'class' => '',
2181
+ 'taxonomy' => 'media_folder',
2182
+ 'value_field' => 'slug',
2183
+ 'meta_query' => [
2184
+ [
2185
+ 'key' => 'wcp_custom_order',
2186
+ 'type' => 'NUMERIC',
2187
+ ],
2188
+ ],
2189
+ ]
2190
+ );
 
2191
 
2192
+ }//end output_list_table_filters()
2193
 
 
2194
 
2195
+ /**
2196
+ * Update folder relationship with page, post, media
2197
+ *
2198
+ * @since 1.0.0
2199
+ * @access public
2200
+ * @return $folders
2201
+ */
2202
+ function new_to_auto_draft($post)
2203
+ {
2204
+
2205
+ $post_type = $post->post_type;
2206
+
2207
+ if (self::is_for_this_post_type($post_type) && !isset($_REQUEST["folder_for_media"])) {
2208
+ $post_type = self::get_custom_post_type($post_type);
2209
+ $selected_folder = get_option("selected_".esc_attr($post_type)."_folder");
2210
 
2211
+ if ($selected_folder != null && !empty($selected_folder)) {
2212
  $terms = get_term($selected_folder);
2213
+ if (!empty($terms) && isset($terms->slug)) {
2214
+ wp_set_object_terms($post->ID, $terms->slug, $post_type);
2215
  }
 
2216
  }
2217
  }
 
2218
 
2219
+ }//end new_to_auto_draft()
2220
+
2221
+
2222
+ /**
2223
+ * Send message to owner for Help
2224
+ *
2225
+ * @since 1.0.0
2226
+ * @access public
2227
+ * @return $response
2228
+ */
2229
+ public function wcp_folder_send_message_to_owner()
2230
+ {
2231
  if (current_user_can('manage_options')) {
2232
+ $response = [];
2233
+ $response['status'] = 0;
2234
+ $response['error'] = 0;
2235
+ $response['errors'] = [];
2236
  $response['message'] = "";
2237
+ $errorArray = [];
2238
+ $errorMessage = esc_html__("%s is required", 'folders');
2239
+ $postData = filter_input_array(INPUT_POST);
2240
  if (!isset($postData['textarea_text']) || trim($postData['textarea_text']) == "") {
2241
+ $error = [
2242
+ "key" => "textarea_text",
2243
+ "message" => esc_html__("Please enter your message", 'folders'),
2244
+ ];
2245
  $errorArray[] = $error;
2246
  }
2247
+
2248
  if (!isset($postData['user_email']) || trim($postData['user_email']) == "") {
2249
+ $error = [
2250
+ "key" => "user_email",
2251
+ "message" => sprintf($errorMessage, __("Email", 'folders')),
2252
+ ];
2253
  $errorArray[] = $error;
2254
  } else if (!filter_var($postData['user_email'], FILTER_VALIDATE_EMAIL)) {
2255
+ $error = [
2256
+ 'key' => "user_email",
2257
+ "message" => "Email is not valid",
2258
+ ];
2259
  $errorArray[] = $error;
2260
  }
2261
+
2262
  if (empty($errorArray)) {
2263
  if (!isset($postData['folder_help_nonce']) || trim($postData['folder_help_nonce']) == "") {
2264
+ $error = [
2265
+ "key" => "nonce",
2266
+ "message" => esc_html__("Your request is not valid", 'folders'),
2267
+ ];
2268
  $errorArray[] = $error;
2269
  } else {
2270
  if (!wp_verify_nonce($postData['folder_help_nonce'], 'wcp_folder_help_nonce')) {
2271
+ $error = [
2272
+ "key" => "nonce",
2273
+ "message" => esc_html__("Your request is not valid", 'folders'),
2274
+ ];
2275
  $errorArray[] = $error;
2276
  }
2277
  }
2278
  }
2279
+
2280
  if (empty($errorArray)) {
2281
  $text_message = self::sanitize_options($postData['textarea_text']);
2282
+ $email = self::sanitize_options($postData['user_email'], "email");
2283
+ $domain = site_url();
2284
  $current_user = wp_get_current_user();
2285
+ $user_name = $current_user->first_name." ".$current_user->last_name;
2286
+
2287
+ $response['status'] = 1;
2288
+
2289
+ // sending message to Crisp
2290
+ $post_message = [];
2291
+
2292
+ $message_data = [];
2293
+ $message_data['key'] = "Plugin";
2294
+ $message_data['value'] = "Folders";
2295
+ $post_message[] = $message_data;
2296
+
2297
+ $message_data = [];
2298
+ $message_data['key'] = "Domain";
2299
+ $message_data['value'] = $domain;
2300
+ $post_message[] = $message_data;
2301
+
2302
+ $message_data = [];
2303
+ $message_data['key'] = "Email";
2304
+ $message_data['value'] = $email;
2305
+ $post_message[] = $message_data;
2306
+
2307
+ $message_data = [];
2308
+ $message_data['key'] = "Message";
2309
+ $message_data['value'] = $text_message;
2310
+ $post_message[] = $message_data;
2311
+
2312
+ $api_params = [
2313
+ 'domain' => $domain,
2314
+ 'email' => $email,
2315
+ 'url' => site_url(),
2316
+ 'name' => $user_name,
2317
+ 'message' => $post_message,
2318
+ 'plugin' => "Folders",
2319
+ 'type' => "Need Help",
2320
+ ];
2321
+
2322
+ // Sending message to Crisp API
2323
+ $crisp_response = wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => true]);
2324
+
2325
+ if (is_wp_error($crisp_response)) {
2326
+ wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => false]);
2327
+ }
2328
  } else {
2329
+ $response['error'] = 1;
2330
  $response['errors'] = $errorArray;
2331
+ }//end if
2332
+
2333
  echo json_encode($response);
2334
+ }//end if
2335
+
2336
+ }//end wcp_folder_send_message_to_owner()
2337
 
2338
+
2339
+ /**
2340
+ * Send message to owner when folder is deactivated
2341
+ *
2342
+ * @since 1.0.0
2343
+ * @access public
2344
+ * @return $response
2345
+ */
2346
+ public function folder_plugin_deactivate()
2347
+ {
2348
  if (current_user_can('manage_options')) {
2349
+ $postData = filter_input_array(INPUT_POST);
2350
+ $errorCounter = 0;
2351
+ $response = [];
2352
+ $response['status'] = 0;
2353
  $response['message'] = "";
2354
+ $response['valid'] = 1;
2355
+ if (!isset($postData['reason']) || empty($postData['reason'])) {
2356
  $errorCounter++;
2357
  $response['message'] = "Please provide reason";
2358
  } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2361
  $response['valid'] = 0;
2362
  } else {
2363
  $nonce = self::sanitize_options($postData['nonce']);
2364
+ if (!wp_verify_nonce($nonce, 'wcp_folder_deactivate_nonce')) {
2365
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2366
  $errorCounter++;
2367
  $response['valid'] = 0;
2368
  }
2369
  }
2370
+
2371
+ if ($errorCounter == 0) {
2372
  $reason = $postData['reason'];
2373
+ $email = "none@none.none";
2374
  if (isset($postData['email_id']) && !empty($postData['email_id']) && filter_var($postData['email_id'], FILTER_VALIDATE_EMAIL)) {
2375
  $email = $postData['email_id'];
2376
  }
2377
+
2378
+ $domain = site_url();
2379
+ $current_user = wp_get_current_user();
2380
+ $user_name = $current_user->first_name." ".$current_user->last_name;
2381
 
2382
  $response['status'] = 1;
2383
 
2384
+ // sending message to Crisp
2385
+ $post_message = [];
2386
+
2387
+ $message_data = [];
2388
+ $message_data['key'] = "Plugin";
2389
+ $message_data['value'] = "Folders";
2390
+ $post_message[] = $message_data;
2391
+
2392
+ $message_data = [];
2393
+ $message_data['key'] = "Plugin Version";
2394
+ $message_data['value'] = WCP_FOLDER_VERSION;
2395
+ $post_message[] = $message_data;
2396
+
2397
+ $message_data = [];
2398
+ $message_data['key'] = "Domain";
2399
+ $message_data['value'] = $domain;
2400
+ $post_message[] = $message_data;
2401
+
2402
+ $message_data = [];
2403
+ $message_data['key'] = "Email";
2404
+ $message_data['value'] = $email;
2405
+ $post_message[] = $message_data;
2406
+
2407
+ $message_data = [];
2408
+ $message_data['key'] = "WordPress Version";
2409
+ $message_data['value'] = esc_attr(get_bloginfo('version'));
2410
+ $post_message[] = $message_data;
2411
+
2412
+ $message_data = [];
2413
+ $message_data['key'] = "PHP Version";
2414
+ $message_data['value'] = PHP_VERSION;
2415
+ $post_message[] = $message_data;
2416
+
2417
+ $message_data = [];
2418
+ $message_data['key'] = "Message";
2419
+ $message_data['value'] = $reason;
2420
+ $post_message[] = $message_data;
2421
+
2422
+ $api_params = [
2423
+ 'domain' => $domain,
2424
+ 'email' => $email,
2425
+ 'url' => site_url(),
2426
+ 'name' => $user_name,
2427
+ 'message' => $post_message,
2428
+ 'plugin' => "Folders",
2429
+ 'type' => "Uninstall",
2430
+ ];
2431
+
2432
+ // Sending message to Crisp API
2433
+ $crisp_response = wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => true]);
2434
+
2435
+ if (is_wp_error($crisp_response)) {
2436
+ wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => false]);
2437
+ }
2438
+ }//end if
2439
+
2440
  echo json_encode($response);
2441
  wp_die();
2442
+ }//end if
2443
+
2444
+ }//end folder_plugin_deactivate()
2445
+
2446
 
2447
+ /**
2448
+ * Returns total folders
2449
+ *
2450
+ * @since 1.0.0
2451
+ * @access public
2452
+ * @return $total
2453
+ */
2454
+ public static function ttl_fldrs()
2455
+ {
2456
  $post_types = get_option('folders_settings');
2457
+ $post_types = is_array($post_types) ? $post_types : [];
2458
+ $total = 0;
2459
  foreach ($post_types as $post_type) {
2460
  $post_type = self::get_custom_post_type($post_type);
2461
+ $total += wp_count_terms($post_type);
2462
  }
2463
+
2464
  return $total;
 
2465
 
2466
+ }//end ttl_fldrs()
2467
+
2468
+
2469
+ /**
2470
+ * Remove post
2471
+ *
2472
+ * @since 1.0.0
2473
+ * @access public
2474
+ * @return $response
2475
+ */
2476
  public function wcp_remove_post_item()
2477
  {
2478
+ $response = [];
2479
+ $response['status'] = 0;
2480
+ $response['error'] = 0;
2481
+ $response['data'] = [];
2482
  $response['message'] = "";
2483
+ $postData = filter_input_array(INPUT_POST);
2484
  if (isset($postData['post_id']) && !empty($postData['post_id'])) {
2485
  wp_delete_post($postData['post_id']);
2486
  $response['status'] = 1;
2487
  }
2488
+
2489
  echo json_encode($response);
2490
  wp_die();
 
2491
 
2492
+ }//end wcp_remove_post_item()
2493
+
2494
+
2495
+ /**
2496
+ * Mark all folders
2497
+ *
2498
+ * @since 1.0.0
2499
+ * @access public
2500
+ * @return $response
2501
+ */
2502
  public function wcp_change_all_status()
2503
  {
2504
+ $response = [];
2505
+ $response['status'] = 0;
2506
+ $response['error'] = 0;
2507
+ $response['data'] = [];
2508
  $response['message'] = "";
2509
+ $postData = filter_input_array(INPUT_POST);
2510
+ $errorCounter = 0;
2511
  if (!isset($postData['type']) || empty($postData['type'])) {
2512
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2513
  $errorCounter++;
2514
  } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2515
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2516
  $errorCounter++;
2517
+ } else if (!current_user_can("manage_categories") || ($postData['type'] == "page" && !current_user_can("edit_pages"))) {
2518
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
2519
  $errorCounter++;
2520
  } else if (!current_user_can("manage_categories") || ($postData['type'] != "page" && !current_user_can("edit_posts"))) {
2521
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
2522
  $errorCounter++;
2523
  } else {
2524
+ $type = self::sanitize_options($postData['type']);
2525
  $nonce = self::sanitize_options($postData['nonce']);
2526
+ if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
2527
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2528
  $errorCounter++;
2529
  }
2530
  }
2531
+
2532
  if ($errorCounter == 0) {
2533
  if (isset($postData['folders']) || !empty($postData['folders'])) {
2534
+ $status = isset($postData['status']) ? $postData['status'] : 0;
2535
+ $status = self::sanitize_options($status);
2536
  $folders = self::sanitize_options($postData['folders']);
2537
  $folders = trim($folders, ",");
2538
  $folders = explode(",", $folders);
2540
  update_term_meta($folder, "is_active", $status);
2541
  }
2542
  }
2543
+
2544
  $response['status'] = 1;
2545
  }
2546
+
2547
  echo json_encode($response);
2548
  wp_die();
 
2549
 
2550
+ }//end wcp_change_all_status()
2551
+
2552
+
2553
+ /**
2554
+ * Change folder width
2555
+ *
2556
+ * @since 1.0.0
2557
+ * @access public
2558
+ * @return $response
2559
+ */
2560
  public function wcp_change_post_width()
2561
  {
2562
+ $response = [];
2563
+ $response['status'] = 0;
2564
+ $response['error'] = 0;
2565
+ $response['data'] = [];
2566
  $response['message'] = "";
2567
+ $postData = filter_input_array(INPUT_POST);
2568
+ $errorCounter = 0;
2569
  if (!isset($postData['width']) || empty($postData['width'])) {
2570
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2571
  $errorCounter++;
2582
  $response['message'] = esc_html__("You have not permission to update width", 'folders');
2583
  $errorCounter++;
2584
  } else {
2585
+ $type = self::sanitize_options($postData['type']);
2586
  $nonce = self::sanitize_options($postData['nonce']);
2587
+ if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
2588
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2589
  $errorCounter++;
2590
  }
2591
+ }//end if
2592
+
2593
  if ($errorCounter == 0) {
2594
+ $type = self::sanitize_options($postData['type']);
2595
+ $width = self::sanitize_options($postData['width'], "int");
2596
+ $optionName = "wcp_dynamic_width_for_".$type;
2597
  update_option($optionName, $width);
2598
  $response['status'] = 1;
2599
  }
2600
+
2601
  echo json_encode($response);
2602
  wp_die();
 
2603
 
2604
+ }//end wcp_change_post_width()
2605
+
2606
+
2607
+ /**
2608
+ * Assign folder to multiple posts, pages, attachments
2609
+ *
2610
+ * @since 1.0.0
2611
+ * @access public
2612
+ * @return $response
2613
+ */
2614
  public function wcp_change_multiple_post_folder()
2615
  {
2616
+ $response = [];
2617
+ $response['status'] = 0;
2618
+ $response['error'] = 0;
2619
+ $response['data'] = [];
2620
  $response['message'] = "";
2621
+ $postData = filter_input_array(INPUT_POST);
2622
+ $errorCounter = 0;
2623
  if (!isset($postData['post_ids']) || empty($postData['post_ids'])) {
2624
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
2625
  $errorCounter++;
2626
  } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
2627
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
2628
  $errorCounter++;
2629
  } else if (!isset($postData['type']) || empty($postData['type'])) {
2630
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
2631
  $errorCounter++;
2632
  } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2633
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
2634
  $errorCounter++;
2635
  } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
2636
+ $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2637
  $errorCounter++;
2638
  } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
2639
+ $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2640
  $errorCounter++;
2641
  } else {
2642
  $folder_id = self::sanitize_options($postData['folder_id']);
2643
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$folder_id)) {
2644
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
2645
  $errorCounter++;
2646
  }
2647
+ }//end if
2648
+
2649
  if ($errorCounter == 0) {
2650
+ $folderUndoSettings = [];
2651
+ $postID = self::sanitize_options($postData['post_ids']);
2652
+ $postID = trim($postID, ",");
2653
+ $folderID = self::sanitize_options($postData['folder_id']);
2654
+ $type = self::sanitize_options($postData['type']);
2655
  $postArray = explode(",", $postID);
2656
+ $status = 0;
2657
+ if (isset($postData['status'])) {
2658
  $status = self::sanitize_options($postData['status']);
2659
  }
2660
+
2661
  $status = true;
2662
 
2663
  $taxonomy = "";
2664
+ if (isset($postData['taxonomy'])) {
2665
  $taxonomy = self::sanitize_options($postData['taxonomy']);
2666
  }
2667
+
2668
  if (is_array($postArray)) {
2669
  $post_type = self::get_custom_post_type($type);
2670
  foreach ($postArray as $post) {
2671
+ $terms = get_the_terms($post, $post_type);
2672
+ $post_terms = [
2673
  'post_id' => $post,
2674
+ 'terms' => $terms,
2675
+ ];
2676
  $folderUndoSettings[] = $post_terms;
2677
  if (!empty($terms)) {
2678
  foreach ($terms as $term) {
2679
+ if (!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
2680
  wp_remove_object_terms($post, $term->term_id, $post_type);
2681
  }
2682
  }
2683
  }
2684
+
2685
  wp_set_post_terms($post, $folderID, $post_type, $status);
2686
  }
2687
  }
2688
+
2689
  $response['status'] = 1;
2690
  delete_transient("folder_undo_settings");
2691
  delete_transient("premio_folders_without_trash");
2692
  set_transient("folder_undo_settings", $folderUndoSettings, DAY_IN_SECONDS);
2693
+ }//end if
2694
+
2695
  echo json_encode($response);
2696
  wp_die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2697
 
2698
+ }//end wcp_change_multiple_post_folder()
2699
+
2700
+
2701
+ /**
2702
+ * Undo folder changes
2703
+ *
2704
+ * @since 1.0.0
2705
+ * @access public
2706
+ * @return $response
2707
+ */
2708
+ public function wcp_undo_folder_changes()
2709
+ {
2710
+ $response = [];
2711
+ $response['status'] = 0;
2712
+ $response['error'] = 0;
2713
+ $response['data'] = [];
2714
+ $response['message'] = "";
2715
+ $postData = filter_input_array(INPUT_POST);
2716
+ $errorCounter = 0;
2717
+ if (!isset($postData['post_type']) || empty($postData['post_type'])) {
2718
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
2719
+ $errorCounter++;
2720
+ } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2721
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
2722
+ $errorCounter++;
2723
+ } else {
2724
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['post_type'])) {
2725
+ $response['message'] = esc_html__("Your request is not valid", 'folders');
2726
+ $errorCounter++;
2727
+ }
2728
+ }
2729
+
2730
+ if ($errorCounter == 0) {
2731
+ $response['status'] = 1;
2732
+ $folder_undo_settings = get_transient("folder_undo_settings");
2733
+ $type = self::sanitize_options($postData['post_type']);
2734
+ $post_type = self::get_custom_post_type($type);
2735
+ if (!empty($folder_undo_settings) && is_array($folder_undo_settings)) {
2736
+ $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
2737
+ if ($trash_folders === false) {
2738
+ $trash_folders = [];
2739
+ $initial_trash_folders = [];
2740
+ }
2741
+
2742
+ foreach ($folder_undo_settings as $item) {
2743
+ $terms = get_the_terms($item['post_id'], $post_type);
2744
+ if (!empty($terms)) {
2745
+ foreach ($terms as $term) {
2746
+ wp_remove_object_terms($item['post_id'], $term->term_id, $post_type);
2747
+ if (isset($trash_folders[$term->term_taxonomy_id])) {
2748
+ unset($trash_folders[$term->term_taxonomy_id]);
2749
+ }
2750
+ }
2751
+ }
2752
+
2753
+ if (!empty($item['terms']) && is_array($item['terms'])) {
2754
+ foreach ($item['terms'] as $term) {
2755
+ wp_set_post_terms($item['post_id'], $term->term_id, $post_type, true);
2756
+ if (isset($trash_folders[$term->term_taxonomy_id])) {
2757
+ unset($trash_folders[$term->term_taxonomy_id]);
2758
+ }
2759
+ }
2760
+ }
2761
+ }
2762
+
2763
+ if (!empty($terms) && $initial_trash_folders != $trash_folders) {
2764
+ delete_transient("premio_folders_without_trash");
2765
+ set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
2766
+ }
2767
+ }//end if
2768
+ }//end if
2769
+
2770
+ echo json_encode($response);
2771
+ die;
2772
+
2773
+ }//end wcp_undo_folder_changes()
2774
+
2775
+
2776
+ /**
2777
+ * Change post, page, attachment folder
2778
+ *
2779
+ * @since 1.0.0
2780
+ * @access public
2781
+ * @return $response
2782
+ */
2783
  public function wcp_change_post_folder()
2784
  {
2785
+ $response = [];
2786
+ $response['status'] = 0;
2787
+ $response['error'] = 0;
2788
+ $response['data'] = [];
2789
  $response['message'] = "";
2790
+ $postData = filter_input_array(INPUT_POST);
2791
+ $errorCounter = 0;
2792
  if (!isset($postData['post_id']) || empty($postData['post_id'])) {
2793
  $errorCounter++;
2794
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2809
  $errorCounter++;
2810
  } else {
2811
  $term_id = self::sanitize_options($postData['folder_id']);
2812
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2813
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2814
  $errorCounter++;
2815
  }
2816
+ }//end if
2817
+
2818
  if ($errorCounter == 0) {
2819
+ $postID = self::sanitize_options($postData['post_id']);
2820
  $folderID = self::sanitize_options($postData['folder_id']);
2821
+ $type = self::sanitize_options($postData['type']);
2822
  $folder_post_type = self::get_custom_post_type($type);
2823
+ $status = 0;
2824
+ if (isset($postData['status'])) {
2825
  $status = self::sanitize_options($postData['status']);
2826
  }
2827
+
2828
+ $status = ($status == 1) ? true : false;
2829
  $taxonomy = "";
2830
+ if (isset($postData['taxonomy'])) {
2831
  $taxonomy = self::sanitize_options($postData['taxonomy']);
2832
  }
2833
+
2834
  $terms = get_the_terms($postID, $folder_post_type);
2835
  if (!empty($terms)) {
2836
  foreach ($terms as $term) {
2837
+ if (!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
2838
  wp_remove_object_terms($postID, $term->term_id, $folder_post_type);
2839
  }
2840
  }
2841
  }
2842
+
2843
  wp_set_post_terms($postID, $folderID, $folder_post_type, true);
2844
  $response['status'] = 1;
2845
+ }//end if
2846
+
2847
  echo json_encode($response);
2848
  wp_die();
 
2849
 
2850
+ }//end wcp_change_post_folder()
2851
+
2852
+
2853
+ /**
2854
+ * Mark/Unmark folder
2855
+ *
2856
+ * @since 1.0.0
2857
+ * @access public
2858
+ * @return $response
2859
+ */
2860
  public function wcp_mark_un_mark_folder()
2861
  {
2862
+ $response = [];
2863
+ $response['status'] = 0;
2864
+ $response['error'] = 0;
2865
+ $response['data'] = [];
2866
  $response['message'] = "";
2867
+ $postData = filter_input_array(INPUT_POST);
2868
+ $errorCounter = 0;
2869
  if (!current_user_can("manage_categories")) {
2870
  $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2871
  $errorCounter++;
2877
  $errorCounter++;
2878
  } else {
2879
  $term_id = self::sanitize_options($postData['term_id']);
2880
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2881
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2882
  $errorCounter++;
2883
  }
2884
  }
2885
+
2886
  if ($errorCounter == 0) {
2887
  $term_id = self::sanitize_options($postData['term_id']);
2888
+ $status = get_term_meta($term_id, "is_highlighted", true);
2889
  if ($status == 1) {
2890
  update_term_meta($term_id, "is_highlighted", 0);
2891
  $status = 0;
2893
  update_term_meta($term_id, "is_highlighted", 1);
2894
  $status = 1;
2895
  }
2896
+
2897
  $response['marked'] = $status;
2898
+ $response['id'] = $postData['term_id'];
2899
  $response['status'] = 1;
2900
  }
2901
+
2902
  echo json_encode($response);
2903
  wp_die();
 
2904
 
2905
+ }//end wcp_mark_un_mark_folder()
2906
+
2907
+
2908
+ /**
2909
+ * Make folder Sticky
2910
+ *
2911
+ * @since 1.0.0
2912
+ * @access public
2913
+ * @return $response
2914
+ */
2915
  public function wcp_make_sticky_folder()
2916
  {
2917
+ $response = [];
2918
+ $response['status'] = 0;
2919
+ $response['error'] = 0;
2920
+ $response['data'] = [];
2921
  $response['message'] = "";
2922
+ $postData = filter_input_array(INPUT_POST);
2923
+ $errorCounter = 0;
2924
  if (!current_user_can("manage_categories")) {
2925
  $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2926
  $errorCounter++;
2932
  $errorCounter++;
2933
  } else {
2934
  $term_id = self::sanitize_options($postData['term_id']);
2935
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2936
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2937
  $errorCounter++;
2938
  }
2939
  }
2940
+
2941
  if ($errorCounter == 0) {
2942
  $term_id = self::sanitize_options($postData['term_id']);
2943
+ $status = get_term_meta($term_id, "is_folder_sticky", true);
2944
  if ($status == 1) {
2945
  update_term_meta($term_id, "is_folder_sticky", 0);
2946
  $status = 0;
2948
  update_term_meta($term_id, "is_folder_sticky", 1);
2949
  $status = 1;
2950
  }
2951
+
2952
  $response['is_folder_sticky'] = $status;
2953
+ $response['id'] = $postData['term_id'];
2954
  $response['status'] = 1;
2955
  }
2956
+
2957
  echo json_encode($response);
2958
  wp_die();
 
2959
 
2960
+ }//end wcp_make_sticky_folder()
2961
+
2962
+
2963
+ /**
2964
+ * Save folder order
2965
+ *
2966
+ * @since 1.0.0
2967
+ * @access public
2968
+ * @return $response
2969
+ */
2970
  public function wcp_save_folder_order()
2971
  {
2972
+ $response = [];
2973
+ $response['status'] = 0;
2974
+ $response['error'] = 0;
2975
+ $response['data'] = [];
2976
  $response['message'] = "";
2977
+ $postData = filter_input_array(INPUT_POST);
2978
+ $errorCounter = 0;
2979
  if (!current_user_can("manage_categories")) {
2980
  $response['message'] = esc_html__("You have not permission to update folder order", 'folders');
2981
  $errorCounter++;
2990
  $errorCounter++;
2991
  } else {
2992
  $type = self::sanitize_options($postData['type']);
2993
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
2994
  $response['message'] = esc_html__("Your request is not valid", 'folders');
2995
  $errorCounter++;
2996
  }
2997
  }
2998
+
2999
  if ($errorCounter == 0) {
3000
+ $termIds = self::sanitize_options(($postData['term_ids']));
3001
+ $type = self::sanitize_options($postData['type']);
3002
+ $termIds = trim($termIds, ",");
3003
  $termArray = explode(",", $termIds);
3004
+ $order = 1;
3005
  foreach ($termArray as $term) {
3006
  if (!empty($term)) {
3007
  update_term_meta($term, "wcp_custom_order", $order);
3008
  $order++;
3009
  }
3010
  }
3011
+
3012
+ $term_id = self::sanitize_options($postData['term_id']);
3013
+ $parent_id = self::sanitize_options($postData['parent_id']);
3014
+ $type = self::sanitize_options($postData['type']);
3015
  $folder_type = self::get_custom_post_type($type);
3016
+ wp_update_term(
3017
+ $term_id,
3018
+ $folder_type,
3019
+ ['parent' => $parent_id]
3020
+ );
3021
 
3022
+ if ($parent_id != "#" || !empty($parent_id)) {
3023
+ update_term_meta($parent_id, "is_active", 1);
3024
  }
3025
+
3026
  $response['status'] = 1;
3027
+ $folder_type = self::get_custom_post_type($type);
3028
+ // Free/Pro Class name change
3029
  $response['options'] = WCP_Tree::get_option_data_for_select($folder_type);
3030
+ }//end if
3031
+
3032
  echo json_encode($response);
3033
  wp_die();
 
3034
 
3035
+ }//end wcp_save_folder_order()
3036
+
3037
+
3038
+ /**
3039
+ * Make folder State open/closed
3040
+ *
3041
+ * @since 1.0.0
3042
+ * @access public
3043
+ * @return $response
3044
+ */
3045
  public function save_wcp_folder_state()
3046
  {
3047
+ $response = [];
3048
+ $response['status'] = 0;
3049
+ $response['error'] = 0;
3050
+ $response['data'] = [];
3051
  $response['message'] = "";
3052
+ $postData = filter_input_array(INPUT_POST);
3053
+ $errorCounter = 0;
3054
  if (!current_user_can("manage_categories")) {
3055
  $response['message'] = esc_html__("You have not permission to update folder", 'folders');
3056
  $errorCounter++;
3062
  $errorCounter++;
3063
  } else {
3064
  $term_id = self::sanitize_options($postData['term_id']);
3065
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3066
  $response['message'] = esc_html__("Your request is not valid", 'folders');
3067
  $errorCounter++;
3068
  }
3069
  }
3070
+
3071
  if ($errorCounter == 0) {
3072
  $response['status'] = 1;
3073
+ $term_id = self::sanitize_options($postData['term_id']);
3074
+ $is_active = isset($postData['is_active']) ? $postData['is_active'] : 0;
3075
+ $is_active = self::sanitize_options($is_active);
3076
  if ($is_active == 1) {
3077
  update_term_meta($term_id, "is_active", 1);
3078
  } else {
3079
  update_term_meta($term_id, "is_active", 0);
3080
  }
3081
  }
3082
+
3083
  echo json_encode($response);
3084
  wp_die();
 
3085
 
3086
+ }//end save_wcp_folder_state()
3087
+
3088
+
3089
+ /**
3090
+ * Save parent folder information with order
3091
+ *
3092
+ * @since 1.0.0
3093
+ * @access public
3094
+ * @return $response
3095
+ */
3096
  public function wcp_update_parent_information()
3097
  {
3098
+ $response = [];
3099
+ $response['status'] = 0;
3100
+ $response['error'] = 0;
3101
+ $response['data'] = [];
3102
  $response['message'] = "";
3103
+ $postData = filter_input_array(INPUT_POST);
3104
+ $errorCounter = 0;
3105
  if (!current_user_can("manage_categories")) {
3106
  $response['message'] = esc_html__("You have not permission to update folder", 'folders');
3107
  $errorCounter++;
3119
  $errorCounter++;
3120
  } else {
3121
  $term_id = self::sanitize_options($postData['term_id']);
3122
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3123
  $response['message'] = esc_html__("Your request is not valid", 'folders');
3124
  $errorCounter++;
3125
  }
3126
+ }//end if
3127
+
3128
+ if ($errorCounter == 0) {
3129
+ $term_id = self::sanitize_options($postData['term_id']);
3130
+ $parent_id = self::sanitize_options($postData['parent_id']);
3131
+ $type = self::sanitize_options($postData['type']);
3132
  $folder_type = self::get_custom_post_type($type);
3133
+ wp_update_term(
3134
+ $term_id,
3135
+ $folder_type,
3136
+ ['parent' => $parent_id]
3137
+ );
3138
  update_term_meta($parent_id, "is_active", 1);
3139
  $response['status'] = 1;
3140
  }
3141
+
3142
  echo json_encode($response);
3143
  wp_die();
 
3144
 
3145
+ }//end wcp_update_parent_information()
3146
+
3147
+
3148
+ /**
3149
+ * Save parent folder data
3150
+ *
3151
+ * @since 1.0.0
3152
+ * @access public
3153
+ * @return $response
3154
+ */
3155
  public function wcp_save_parent_data()
3156
  {
3157
+ $response = [];
3158
+ $response['status'] = 0;
3159
+ $response['error'] = 0;
3160
+ $response['data'] = [];
3161
  $response['message'] = "";
3162
+ $postData = filter_input_array(INPUT_POST);
3163
+ $errorCounter = 0;
3164
  if (!isset($postData['type']) || empty($postData['type'])) {
3165
  $response['message'] = esc_html__("Your request is not valid", 'folders');
3166
  $errorCounter++;
3172
  $errorCounter++;
3173
  } else {
3174
  $type = self::sanitize_options($postData['type']);
3175
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
3176
  $response['message'] = esc_html__("Your request is not valid", 'folders');
3177
  $errorCounter++;
3178
  }
3179
  }
3180
+
3181
  if ($errorCounter == 0) {
3182
+ $type = self::sanitize_options($postData['type']);
3183
+ $optionName = $type."_parent_status";
3184
  $response['status'] = 1;
3185
+ $is_active = isset($postData['is_active']) ? $postData['is_active'] : 0;
3186
+ $is_active = self::sanitize_options($is_active);
3187
  if ($is_active == 1) {
3188
  update_option($optionName, 1);
3189
  } else {
3190
  update_option($optionName, 0);
3191
  }
3192
  }
3193
+
3194
  echo json_encode($response);
3195
  wp_die();
 
3196
 
3197
+ }//end wcp_save_parent_data()
3198
+
3199
+
3200
+ /**
3201
+ * Remove multiple folders
3202
+ *
3203
+ * @since 1.0.0
3204
+ * @access public
3205
+ * @return $response
3206
+ */
3207
+ public function remove_muliple_folder()
3208
+ {
3209
+ $response = [];
3210
+ $response['status'] = 0;
3211
+ $response['error'] = 0;
3212
+ $response['data'] = [];
3213
  $response['message'] = "";
3214
+ $postData = filter_input_array(INPUT_POST);
3215
+ $errorCounter = 0;
3216
  $error = "";
3217
  if (!current_user_can("manage_categories")) {
3218
  $error = esc_html__("You have not permission to remove folder", 'folders');
3228
  $errorCounter++;
3229
  } else {
3230
  $type = self::sanitize_options($postData['type']);
3231
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
3232
  $error = esc_html__("Your request is not valid", 'folders');
3233
  $errorCounter++;
3234
  }
3235
  }
3236
+
3237
  if ($errorCounter == 0) {
3238
  $term_id = self::sanitize_options($postData['term_id']);
3239
+ $type = self::sanitize_options($postData['type']);
3240
+ $response['term_ids'] = [];
3241
+ if (!empty($term_id)) {
3242
+ $term_id = trim($term_id, ",");
3243
  $term_ids = explode(",", $term_id);
3244
+ if (is_array($term_ids) && count($term_ids) > 0) {
3245
  foreach ($term_ids as $term) {
3246
  self::remove_folder_child_items($term, $type);
3247
  }
3248
+
3249
  $response['term_ids'] = $term_ids;
3250
  }
3251
  }
3252
+
3253
+ $is_active = 1;
3254
+ $folders = -1;
3255
  $response['status'] = 1;
3256
+ $response['folders'] = $folders;
3257
  $response['is_key_active'] = $is_active;
3258
  } else {
3259
+ $response['error'] = 1;
3260
  $response['message'] = $error;
3261
+ }//end if
3262
+
3263
  echo json_encode($response);
3264
  wp_die();
 
3265
 
3266
+ }//end remove_muliple_folder()
3267
+
3268
+
3269
+ /**
3270
+ * Remove folder
3271
+ *
3272
+ * @since 1.0.0
3273
+ * @access public
3274
+ * @return $response
3275
+ */
3276
  public function wcp_remove_folder()
3277
  {
3278
+ $response = [];
3279
+ $response['status'] = 0;
3280
+ $response['error'] = 0;
3281
+ $response['data'] = [];
3282
  $response['message'] = "";
3283
+ $postData = filter_input_array(INPUT_POST);
3284
+ $errorCounter = 0;
3285
  if (!current_user_can("manage_categories")) {
3286
  $error = esc_html__("You have not permission to remove folder", 'folders');
3287
  $errorCounter++;
3296
  $errorCounter++;
3297
  } else {
3298
  $term_id = self::sanitize_options($postData['term_id']);
3299
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3300
  $error = esc_html__("Unable to delete folder, Your request is not valid", 'folders');
3301
  $errorCounter++;
3302
  }
3303
  }
3304
+
3305
  if ($errorCounter == 0) {
3306
  $term_id = self::sanitize_options($postData['term_id']);
3307
+ $type = self::sanitize_options($postData['type']);
3308
  self::remove_folder_child_items($term_id, $type);
3309
  $response['status'] = 1;
3310
+ $is_active = 1;
3311
+ $folders = -1;
3312
+ $response['folders'] = $folders;
3313
+ $response['term_id'] = $term_id;
3314
  $response['is_key_active'] = $is_active;
3315
  } else {
3316
+ $response['error'] = 1;
3317
  $response['message'] = $error;
3318
  }
3319
+
3320
  echo json_encode($response);
3321
  wp_die();
 
3322
 
3323
+ }//end wcp_remove_folder()
3324
+
3325
+
3326
+ /**
3327
+ * Remove folders for page, post, attachment
3328
+ *
3329
+ * @since 1.0.0
3330
+ * @access public
3331
+ * @return $response
3332
+ */
3333
  public function remove_folder_child_items($term_id, $post_type)
3334
  {
3335
  $folder_type = self::get_custom_post_type($post_type);
3336
+ $terms = get_terms(
3337
+ $folder_type,
3338
+ [
3339
+ 'hide_empty' => false,
3340
+ 'parent' => $term_id,
3341
+ ]
3342
+ );
3343
 
3344
  if (!empty($terms)) {
3345
  foreach ($terms as $term) {
3346
  self::remove_folder_child_items($term->term_id, $post_type);
3347
  }
3348
+
3349
  wp_delete_term($term_id, $folder_type);
3350
  } else {
3351
  wp_delete_term($term_id, $folder_type);
3352
  }
 
3353
 
3354
+ }//end remove_folder_child_items()
3355
+
3356
+
3357
+ /**
3358
+ * Update Folder
3359
+ *
3360
+ * @since 1.0.0
3361
+ * @access public
3362
+ * @return $response
3363
+ */
3364
  public function wcp_update_folder()
3365
  {
3366
+ $response = [];
3367
+ $response['status'] = 0;
3368
+ $response['error'] = 0;
3369
+ $response['data'] = [];
3370
  $response['message'] = "";
3371
+ $postData = filter_input_array(INPUT_POST);
3372
+ $errorCounter = 0;
3373
  if (!current_user_can("manage_categories")) {
3374
  $error = esc_html__("You have not permission to update folder", 'folders');
3375
  $errorCounter++;
3387
  $errorCounter++;
3388
  } else {
3389
  $term_id = self::sanitize_options($postData['term_id']);
3390
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3391
  $error = esc_html__("Unable to rename folder, Your request is not valid", 'folders');
3392
  $errorCounter++;
3393
  }
3394
+ }//end if
3395
+
3396
  if ($errorCounter == 0) {
3397
+ $type = self::sanitize_options($postData['type']);
3398
  $folder_type = self::get_custom_post_type($type);
3399
+ $name = self::sanitize_options($postData['name']);
3400
+ $term_id = self::sanitize_options($postData['term_id']);
3401
+ $result = wp_update_term(
3402
  $term_id,
3403
  $folder_type,
3404
+ ['name' => $name]
 
 
3405
  );
3406
  if (!empty($result)) {
3407
+ $term_nonce = wp_create_nonce('wcp_folder_term_'.$result['term_id']);
3408
+ $response['id'] = $result['term_id'];
3409
+ $response['slug'] = $result['slug'];
3410
  $response['status'] = 1;
3411
  $response['term_title'] = $postData['name'];
3412
+ $response['nonce'] = $term_nonce;
3413
  } else {
3414
  $response['message'] = esc_html__("Unable to rename folder", 'folders');
3415
  }
3416
  } else {
3417
+ $response['error'] = 1;
3418
  $response['message'] = $error;
3419
+ }//end if
3420
+
3421
  echo json_encode($response);
3422
  wp_die();
 
3423
 
3424
+ }//end wcp_update_folder()
3425
+
3426
+
3427
+ /**
3428
+ * Create slug from string
3429
+ *
3430
+ * @since 1.0.0
3431
+ * @access public
3432
+ * @return $slug
3433
+ */
3434
  public function create_slug_from_string($str)
3435
  {
3436
+ $a = [
3437
+ 'À',
3438
+ 'Á',
3439
+ 'Â',
3440
+ 'Ã',
3441
+ 'Ä',
3442
+ 'Å',
3443
+ 'Æ',
3444
+ 'Ç',
3445
+ 'È',
3446
+ 'É',
3447
+ 'Ê',
3448
+ 'Ë',
3449
+ 'Ì',
3450
+ 'Í',
3451
+ 'Î',
3452
+ 'Ï',
3453
+ 'Ð',
3454
+ 'Ñ',
3455
+ 'Ò',
3456
+ 'Ó',
3457
+ 'Ô',
3458
+ 'Õ',
3459
+ 'Ö',
3460
+ 'Ø',
3461
+ 'Ù',
3462
+ 'Ú',
3463
+ 'Û',
3464
+ 'Ü',
3465
+ 'Ý',
3466
+ 'ß',
3467
+ 'à',
3468
+ 'á',
3469
+ 'â',
3470
+ 'ã',
3471
+ 'ä',
3472
+ 'å',
3473
+ 'æ',
3474
+ 'ç',
3475
+ 'è',
3476
+ 'é',
3477
+ 'ê',
3478
+ 'ë',
3479
+ 'ì',
3480
+ 'í',
3481
+ 'î',
3482
+ 'ï',
3483
+ 'ñ',
3484
+ 'ò',
3485
+ 'ó',
3486
+ 'ô',
3487
+ 'õ',
3488
+ 'ö',
3489
+ 'ø',
3490
+ 'ù',
3491
+ 'ú',
3492
+ 'û',
3493
+ 'ü',
3494
+ 'ý',
3495
+ 'ÿ',
3496
+ 'A',
3497
+ 'a',
3498
+ 'A',
3499
+ 'a',
3500
+ 'A',
3501
+ 'a',
3502
+ 'C',
3503
+ 'c',
3504
+ 'C',
3505
+ 'c',
3506
+ 'C',
3507
+ 'c',
3508
+ 'C',
3509
+ 'c',
3510
+ 'D',
3511
+ 'd',
3512
+ 'Ð',
3513
+ 'd',
3514
+ 'E',
3515
+ 'e',
3516
+ 'E',
3517
+ 'e',
3518
+ 'E',
3519
+ 'e',
3520
+ 'E',
3521
+ 'e',
3522
+ 'E',
3523
+ 'e',
3524
+ 'G',
3525
+ 'g',
3526
+ 'G',
3527
+ 'g',
3528
+ 'G',
3529
+ 'g',
3530
+ 'G',
3531
+ 'g',
3532
+ 'H',
3533
+ 'h',
3534
+ 'H',
3535
+ 'h',
3536
+ 'I',
3537
+ 'i',
3538
+ 'I',
3539
+ 'i',
3540
+ 'I',
3541
+ 'i',
3542
+ 'I',
3543
+ 'i',
3544
+ 'I',
3545
+ 'i',
3546
+ '?',
3547
+ '?',
3548
+ 'J',
3549
+ 'j',
3550
+ 'K',
3551
+ 'k',
3552
+ 'L',
3553
+ 'l',
3554
+ 'L',
3555
+ 'l',
3556
+ 'L',
3557
+ 'l',
3558
+ '?',
3559
+ '?',
3560
+ 'L',
3561
+ 'l',
3562
+ 'N',
3563
+ 'n',
3564
+ 'N',
3565
+ 'n',
3566
+ 'N',
3567
+ 'n',
3568
+ '?',
3569
+ 'O',
3570
+ 'o',
3571
+ 'O',
3572
+ 'o',
3573
+ 'O',
3574
+ 'o',
3575
+ 'Œ',
3576
+ 'œ',
3577
+ 'R',
3578
+ 'r',
3579
+ 'R',
3580
+ 'r',
3581
+ 'R',
3582
+ 'r',
3583
+ 'S',
3584
+ 's',
3585
+ 'S',
3586
+ 's',
3587
+ 'S',
3588
+ 's',
3589
+ 'Š',
3590
+ 'š',
3591
+ 'T',
3592
+ 't',
3593
+ 'T',
3594
+ 't',
3595
+ 'T',
3596
+ 't',
3597
+ 'U',
3598
+ 'u',
3599
+ 'U',
3600
+ 'u',
3601
+ 'U',
3602
+ 'u',
3603
+ 'U',
3604
+ 'u',
3605
+ 'U',
3606
+ 'u',
3607
+ 'U',
3608
+ 'u',
3609
+ 'W',
3610
+ 'w',
3611
+ 'Y',
3612
+ 'y',
3613
+ 'Ÿ',
3614
+ 'Z',
3615
+ 'z',
3616
+ 'Z',
3617
+ 'z',
3618
+ 'Ž',
3619
+ 'ž',
3620
+ '?',
3621
+ 'ƒ',
3622
+ 'O',
3623
+ 'o',
3624
+ 'U',
3625
+ 'u',
3626
+ 'A',
3627
+ 'a',
3628
+ 'I',
3629
+ 'i',
3630
+ 'O',
3631
+ 'o',
3632
+ 'U',
3633
+ 'u',
3634
+ 'U',
3635
+ 'u',
3636
+ 'U',
3637
+ 'u',
3638
+ 'U',
3639
+ 'u',
3640
+ 'U',
3641
+ 'u',
3642
+ '?',
3643
+ '?',
3644
+ '?',
3645
+ '?',
3646
+ '?',
3647
+ '?',
3648
+ ];
3649
+ $b = [
3650
+ 'A',
3651
+ 'A',
3652
+ 'A',
3653
+ 'A',
3654
+ 'A',
3655
+ 'A',
3656
+ 'AE',
3657
+ 'C',
3658
+ 'E',
3659
+ 'E',
3660
+ 'E',
3661
+ 'E',
3662
+ 'I',
3663
+ 'I',
3664
+ 'I',
3665
+ 'I',
3666
+ 'D',
3667
+ 'N',
3668
+ 'O',
3669
+ 'O',
3670
+ 'O',
3671
+ 'O',
3672
+ 'O',
3673
+ 'O',
3674
+ 'U',
3675
+ 'U',
3676
+ 'U',
3677
+ 'U',
3678
+ 'Y',
3679
+ 's',
3680
+ 'a',
3681
+ 'a',
3682
+ 'a',
3683
+ 'a',
3684
+ 'a',
3685
+ 'a',
3686
+ 'ae',
3687
+ 'c',
3688
+ 'e',
3689
+ 'e',
3690
+ 'e',
3691
+ 'e',
3692
+ 'i',
3693
+ 'i',
3694
+ 'i',
3695
+ 'i',
3696
+ 'n',
3697
+ 'o',
3698
+ 'o',
3699
+ 'o',
3700
+ 'o',
3701
+ 'o',
3702
+ 'o',
3703
+ 'u',
3704
+ 'u',
3705
+ 'u',
3706
+ 'u',
3707
+ 'y',
3708
+ 'y',
3709
+ 'A',
3710
+ 'a',
3711
+ 'A',
3712
+ 'a',
3713
+ 'A',
3714
+ 'a',
3715
+ 'C',
3716
+ 'c',
3717
+ 'C',
3718
+ 'c',
3719
+ 'C',
3720
+ 'c',
3721
+ 'C',
3722
+ 'c',
3723
+ 'D',
3724
+ 'd',
3725
+ 'D',
3726
+ 'd',
3727
+ 'E',
3728
+ 'e',
3729
+ 'E',
3730
+ 'e',
3731
+ 'E',
3732
+ 'e',
3733
+ 'E',
3734
+ 'e',
3735
+ 'E',
3736
+ 'e',
3737
+ 'G',
3738
+ 'g',
3739
+ 'G',
3740
+ 'g',
3741
+ 'G',
3742
+ 'g',
3743
+ 'G',
3744
+ 'g',
3745
+ 'H',
3746
+ 'h',
3747
+ 'H',
3748
+ 'h',
3749
+ 'I',
3750
+ 'i',
3751
+ 'I',
3752
+ 'i',
3753
+ 'I',
3754
+ 'i',
3755
+ 'I',
3756
+ 'i',
3757
+ 'I',
3758
+ 'i',
3759
+ 'IJ',
3760
+ 'ij',
3761
+ 'J',
3762
+ 'j',
3763
+ 'K',
3764
+ 'k',
3765
+ 'L',
3766
+ 'l',
3767
+ 'L',
3768
+ 'l',
3769
+ 'L',
3770
+ 'l',
3771
+ 'L',
3772
+ 'l',
3773
+ 'l',
3774
+ 'l',
3775
+ 'N',
3776
+ 'n',
3777
+ 'N',
3778
+ 'n',
3779
+ 'N',
3780
+ 'n',
3781
+ 'n',
3782
+ 'O',
3783
+ 'o',
3784
+ 'O',
3785
+ 'o',
3786
+ 'O',
3787
+ 'o',
3788
+ 'OE',
3789
+ 'oe',
3790
+ 'R',
3791
+ 'r',
3792
+ 'R',
3793
+ 'r',
3794
+ 'R',
3795
+ 'r',
3796
+ 'S',
3797
+ 's',
3798
+ 'S',
3799
+ 's',
3800
+ 'S',
3801
+ 's',
3802
+ 'S',
3803
+ 's',
3804
+ 'T',
3805
+ 't',
3806
+ 'T',
3807
+ 't',
3808
+ 'T',
3809
+ 't',
3810
+ 'U',
3811
+ 'u',
3812
+ 'U',
3813
+ 'u',
3814
+ 'U',
3815
+ 'u',
3816
+ 'U',
3817
+ 'u',
3818
+ 'U',
3819
+ 'u',
3820
+ 'U',
3821
+ 'u',
3822
+ 'W',
3823
+ 'w',
3824
+ 'Y',
3825
+ 'y',
3826
+ 'Y',
3827
+ 'Z',
3828
+ 'z',
3829
+ 'Z',
3830
+ 'z',
3831
+ 'Z',
3832
+ 'z',
3833
+ 's',
3834
+ 'f',
3835
+ 'O',
3836
+ 'o',
3837
+ 'U',
3838
+ 'u',
3839
+ 'A',
3840
+ 'a',
3841
+ 'I',
3842
+ 'i',
3843
+ 'O',
3844
+ 'o',
3845
+ 'U',
3846
+ 'u',
3847
+ 'U',
3848
+ 'u',
3849
+ 'U',
3850
+ 'u',
3851
+ 'U',
3852
+ 'u',
3853
+ 'U',
3854
+ 'u',
3855
+ 'A',
3856
+ 'a',
3857
+ 'AE',
3858
+ 'ae',
3859
+ 'O',
3860
+ 'o',
3861
+ ];
3862
+ return strtolower(preg_replace(['/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'], ['', '-', ''], str_replace($a, $b, $str)));
3863
+
3864
+ }//end create_slug_from_string()
3865
+
3866
+
3867
+ /**
3868
+ * Sanitize input options
3869
+ *
3870
+ * @since 1.0.0
3871
+ * @access public
3872
+ * @return $value
3873
+ */
3874
+ public static function sanitize_options($value, $type="")
3875
+ {
3876
  $value = stripslashes($value);
3877
+ if ($type == "int") {
3878
  $value = filter_var($value, FILTER_SANITIZE_NUMBER_INT);
3879
+ } else if ($type == "email") {
3880
  $value = filter_var($value, FILTER_SANITIZE_EMAIL);
3881
  } else {
3882
+ $value = filter_var($value);
3883
  }
3884
+
3885
  return $value;
 
3886
 
3887
+ }//end sanitize_options()
3888
+
3889
+
3890
+ /**
3891
+ * Add new folder
3892
+ *
3893
+ * @since 1.0.0
3894
+ * @access public
3895
+ * @return $response
3896
+ */
3897
  public function wcp_add_new_folder()
3898
  {
3899
+ $response = [];
3900
+ $response['status'] = 0;
3901
+ $response['error'] = 0;
3902
+ $response['login'] = 1;
3903
+ $response['data'] = [];
3904
  $response['message'] = "";
3905
  $response['message2'] = "";
3906
+ $postData = filter_input_array(INPUT_POST);
3907
  $errorCounter = 0;
3908
+ $error = "";
3909
  if (!current_user_can("manage_categories")) {
3910
  $error = esc_html__("You have not permission to add folder", 'folders');
3911
  $errorCounter++;
3921
  $errorCounter++;
3922
  } else {
3923
  $type = self::sanitize_options($postData['type']);
3924
+ if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
3925
  $response['login'] = 0;
3926
  $error = esc_html__("Unable to create folder, Your request is not valid", 'folders');
3927
  $errorCounter++;
3928
  }
3929
+ }//end if
3930
+
3931
  if ($errorCounter == 0) {
3932
+ $parent = isset($postData['parent_id']) && !empty($postData['parent_id']) ? $postData['parent_id'] : 0;
3933
  $parent_menu = isset($postData['parent_menu']) && !empty($postData['parent_menu']) ? $postData['parent_menu'] : 0;
3934
+ $parent_ids = isset($postData['parent_ids']) && !empty($postData['parent_ids']) ? $postData['parent_ids'] : 0;
3935
+ $parent = self::sanitize_options($parent);
3936
+ $type = self::sanitize_options($postData['type']);
3937
  $folder_type = self::get_custom_post_type($type);
3938
+ $term_name = self::sanitize_options($postData['name']);
3939
+ $term = term_exists($term_name, $folder_type, $parent);
3940
+ $term_id = 0;
3941
  if (!(0 !== $term && null !== $term)) {
3942
+ $folders = $postData['name'];
3943
+ $folders = explode(",", $folders);
3944
+ $foldersArray = [];
3945
+ $order = isset($postData['order']) ? $postData['order'] : 0;
3946
+ $order = self::sanitize_options($order);
3947
 
3948
+ $is_active = 1;
3949
  $total_folders = -1;
3950
 
3951
+ if (!$is_active) {
3952
  if (($total_folders + count($folders)) > 10) {
3953
  $response['status'] = -1;
3954
  echo json_encode($response);
3955
  wp_die();
3956
  }
3957
  }
3958
+
3959
  foreach ($folders as $key => $folder) {
3960
  $folder = trim($folder);
3961
+ $slug = self::create_slug_from_string($folder)."-".time();
3962
 
3963
  $result = wp_insert_term(
3964
+ urldecode($folder),
3965
+ // the term
3966
+ $folder_type,
3967
+ // the taxonomy
3968
+ [
3969
  'parent' => $parent,
3970
+ 'slug' => $slug,
3971
+ ]
3972
  );
3973
  if (!empty($result)) {
3974
+ $term_id = $result['term_id'];
3975
  $total_folders++;
3976
+ $response['id'] = $result['term_id'];
3977
  $response['status'] = 1;
3978
+ $term = get_term($result['term_id'], $folder_type);
3979
+ $order = ($order + $key);
3980
+ $term_nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
3981
 
3982
+ $folder_item = [];
3983
  $folder_item['parent_id'] = $parent;
3984
+ $folder_item['slug'] = $term->slug;
3985
+ $folder_item['nonce'] = $term_nonce;
3986
+ $folder_item['term_id'] = $result['term_id'];
3987
+ $folder_item['title'] = $folder;
3988
  $folder_item['parent_id'] = empty($postData['parent_id']) ? "0" : $postData['parent_id'];
3989
  $folder_item['is_sticky'] = 0;
3990
+ $folder_item['is_high'] = 0;
3991
 
3992
  update_term_meta($result['term_id'], "wcp_custom_order", $order);
3993
  if ($parent != 0) {
4014
  }
4015
 
4016
  $postArray = get_posts(
4017
+ [
4018
  'posts_per_page' => -1,
4019
+ 'post_type' => $type,
4020
+ 'tax_query' => [
4021
+ [
4022
  'taxonomy' => $folder_type,
4023
+ 'field' => 'term_id',
4024
+ 'terms' => $term_id,
4025
+ ],
4026
+ ],
4027
+ ]
4028
  );
4029
  if (!empty($postArray)) {
4030
  foreach ($postArray as $p) {
4031
  wp_set_post_terms($p->ID, $term->term_id, $folder_type, true);
4032
  }
4033
  }
4034
+ }//end if
4035
+ }//end if
4036
+ }//end if
4037
+
4038
+ if ($parent_menu && !empty($parent_ids)) {
4039
+ $order = isset($postData['order']) ? $postData['order'] : 0;
4040
+ $parent_ids = trim($parent_ids, ",");
4041
+ $parent_ids = explode(",", $parent_ids);
4042
+ $folder_order = 0;
4043
+ $parents = "";
4044
+ if (is_array($parent_ids) && count($parent_ids) > 0) {
4045
+ foreach ($parent_ids as $key => $value) {
4046
+ if ($value != "#") {
4047
+ delete_term_meta($value, "wcp_custom_order");
4048
+ add_term_meta($value, "wcp_custom_order", $folder_order);
4049
+ } else if (!empty($term_id)) {
4050
+ delete_term_meta($term_id, "wcp_custom_order");
4051
+ add_term_meta($term_id, "wcp_custom_order", $folder_order);
4052
+ }
4053
+
4054
+ $folder_order++;
4055
  }
4056
  }
4057
  }
4058
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4059
  $foldersArray[] = $folder_item;
4060
+ }//end if
4061
 
4062
  if (!empty($foldersArray)) {
4063
  $response['is_key_active'] = $is_active;
4064
+ $response['folders'] = $total_folders;
4065
+ $response['parent_id'] = empty($parent) ? "#" : $parent;
4066
 
4067
  $response['status'] = 1;
4068
+ $response['data'] = $foldersArray;
4069
  }
4070
+ }//end foreach
4071
  } else {
4072
+ $response['error'] = 1;
4073
  $response['message'] = esc_html__("Folder name already exists", 'folders');
4074
+ }//end if
4075
  } else {
4076
+ $response['error'] = 1;
4077
  $response['message'] = $error;
4078
+ }//end if
4079
+
4080
  echo json_encode($response);
4081
  wp_die();
 
4082
 
4083
+ }//end wcp_add_new_folder()
4084
+
4085
+
4086
+ /**
4087
+ * Check is folder active for post, page, attachment
4088
+ *
4089
+ * @since 1.0.0
4090
+ * @access public
4091
+ * @return $post_type
4092
+ */
4093
  public function is_for_this_post_type($post_type)
4094
  {
4095
  $post_types = get_option('folders_settings');
4096
+ $post_types = is_array($post_types) ? $post_types : [];
4097
  return in_array($post_type, $post_types);
 
4098
 
4099
+ }//end is_for_this_post_type()
4100
+
4101
+
4102
+ /**
4103
+ * Check is folder active for current screen
4104
+ *
4105
+ * @since 1.0.0
4106
+ * @access public
4107
+ * @return $status
4108
+ */
4109
  public function is_active_for_screen()
4110
  {
4111
  global $typenow, $current_screen;
4119
  }
4120
 
4121
  $post_types = get_option('folders_settings');
4122
+ $post_types = is_array($post_types) ? $post_types : [];
4123
 
4124
+ if (empty($typenow) && (isset($current_screen->base) && 'upload' == $current_screen->base)) {
4125
  $typenow = "attachment";
4126
  if (self::is_for_this_post_type($typenow)) {
4127
  return true;
4128
  }
4129
  }
4130
+
4131
  return false;
 
4132
 
4133
+ }//end is_active_for_screen()
4134
+
4135
+
4136
+ /**
4137
+ * Check is post update screen
4138
+ *
4139
+ * @since 1.0.0
4140
+ * @access public
4141
+ * @return $status
4142
+ */
4143
  public function is_add_update_screen()
4144
  {
4145
  global $current_screen;
4146
  $current_type = $current_screen->base;
4147
+ $action = $current_screen->action;
4148
+ $post_types = get_option('folders_settings');
4149
+ $post_types = is_array($post_types) ? $post_types : [];
4150
  global $typenow;
4151
+ if (in_array($current_type, $post_types) && in_array($action, ["add", ""])) {
4152
  $license_data = self::get_license_key_data();
4153
 
4154
  $is_active = 1;
4155
+ $folders = -1;
4156
+ $response['folders'] = $folders;
4157
  $response['is_key_active'] = $is_active;
4158
  }
 
4159
 
4160
+ }//end is_add_update_screen()
4161
+
4162
+
4163
+ /**
4164
+ * Get folder type for page, post, attachment
4165
+ *
4166
+ * @since 1.0.0
4167
+ * @access public
4168
+ * @return $status
4169
+ */
4170
  public static function get_custom_post_type($post_type)
4171
  {
4172
  if ($post_type == "post") {
4176
  } else if ($post_type == "attachment") {
4177
  return "media_folder";
4178
  }
 
 
4179
 
4180
+ return $post_type.'_folder';
4181
+
4182
+ }//end get_custom_post_type()
4183
+
4184
+
4185
+ /**
4186
+ * Add folders data to footer
4187
+ *
4188
+ * @since 1.0.0
4189
+ * @access public
4190
+ * @return $html
4191
+ */
4192
  public function admin_footer()
4193
  {
4194
  if (self::is_active_for_screen()) {
4201
  $ttemp = self::get_tempt_posts($typenow);
4202
 
4203
  $folder_type = self::get_custom_post_type($typenow);
4204
+ // Do not change: Free/Pro Class name change
4205
+ $tree_data = WCP_Tree::get_full_tree_data($folder_type);
4206
+ $terms_data = $tree_data['string'];
4207
  $sticky_string = $tree_data['sticky_string'];
4208
+ $terms_html = WCP_Tree::get_option_data_for_select($folder_type);
4209
+ $form_html = WCP_Forms::get_form_html($terms_html);
4210
+ include_once dirname(dirname(__FILE__)).WCP_DS."/templates".WCP_DS."admin".WCP_DS."admin-content.php";
4211
  }
4212
 
4213
  global $pagenow;
4214
+ if ('plugins.php' !== $pagenow) {
 
4215
  } else {
4216
  if (current_user_can('manage_options')) {
4217
+ include_once dirname(dirname(__FILE__)).WCP_DS."/templates".WCP_DS."admin".WCP_DS."folder-deactivate-form.php";
4218
  }
4219
  }
 
4220
 
4221
+ }//end admin_footer()
4222
+
4223
+
4224
+ /**
4225
+ * Get total posts
4226
+ *
4227
+ * @since 1.0.0
4228
+ * @access public
4229
+ * @return $item_count
4230
+ */
4231
+ public function get_ttlpst($post_type="")
4232
  {
4233
  global $typenow;
4234
  if (empty($post_type)) {
4235
  $post_type = $typenow;
4236
  }
4237
+
4238
  $item_count = null;
4239
+ if (has_filter("premio_folder_all_categorized_items")) {
4240
  $item_count = apply_filters("premio_folder_all_categorized_items", $post_type);
4241
  }
4242
+
4243
+ if ($item_count === null) {
4244
  if ($post_type == "attachment") {
4245
  $item_count = wp_count_posts($post_type)->inherit;
4246
  } else {
4247
+ $item_count = (wp_count_posts($post_type)->publish + wp_count_posts($post_type)->draft + wp_count_posts($post_type)->future + wp_count_posts($post_type)->private);
4248
  }
4249
  }
4250
+
4251
  return $item_count;
 
4252
 
4253
+ }//end get_ttlpst()
4254
+
4255
+
4256
+ /**
4257
+ * Autoload folders librarires
4258
+ *
4259
+ * @since 1.0.0
4260
+ * @access public
4261
+ * @return $files
4262
+ */
4263
  public function autoload()
4264
  {
4265
+ $files = [
4266
+ 'WCP_Tree_View' => WCP_DS."includes".WCP_DS."tree.class.php",
4267
+ 'WCP_Form_View' => WCP_DS."includes".WCP_DS."form.class.php",
4268
+ 'WCP_Folder_WPML' => WCP_DS."includes".WCP_DS."class-wpml.php",
4269
+ 'WCP_Folder_PolyLang' => WCP_DS."includes".WCP_DS."class-polylang.php",
4270
+ ];
4271
 
4272
  foreach ($files as $file) {
4273
+ if (file_exists(dirname(dirname(__FILE__)).$file)) {
4274
+ include_once dirname(dirname(__FILE__)).$file;
4275
  }
4276
  }
 
4277
 
4278
+ }//end autoload()
4279
+
4280
+
4281
+ /**
4282
+ * Create folder taxonomies
4283
+ *
4284
+ * @since 1.0.0
4285
+ * @access public
4286
+ * @return $taxonomies
4287
+ */
4288
  public function create_folder_terms()
4289
  {
4290
+ $options = get_option('folders_settings');
4291
+ $options = is_array($options) ? $options : [];
4292
  $old_plugin_status = 0;
4293
+ $posts = [];
4294
  if (!empty($options)) {
4295
  foreach ($options as $option) {
4296
  if (!(strpos($option, 'folder4') === false) && $old_plugin_status == 0) {
4297
  $old_plugin_status = 1;
4298
  }
4299
+
4300
+ if (in_array($option, ["page", "post", "attachment"])) {
4301
  $posts[] = str_replace("folder4", "", $option);
4302
  } else {
4303
  $posts[] = $option;
4304
  }
4305
  }
4306
+
4307
+ if (!empty($posts)) {
4308
  update_option('folders_settings', $posts);
4309
  }
4310
  }
4311
+
4312
  if ($old_plugin_status == 1) {
4313
  update_option("folders_show_in_menu", "on");
4314
  $old_plugin_var = get_option("folder_old_plugin_status");
4316
  update_option("folder_old_plugin_status", "1");
4317
  }
4318
  }
4319
+
4320
  $posts = get_option('folders_settings');
4321
  if (!empty($posts)) {
4322
  foreach ($posts as $post_type) {
4323
+ $labels = [
4324
+ 'name' => esc_html__('Folders', 'folders'),
4325
  'singular_name' => esc_html__('Folder', 'folders'),
4326
+ 'all_items' => esc_html__('All Folders', 'folders'),
4327
+ 'edit_item' => esc_html__('Edit Folder', 'folders'),
4328
+ 'update_item' => esc_html__('Update Folder', 'folders'),
4329
+ 'add_new_item' => esc_html__('Add New Folder', 'folders'),
4330
  'new_item_name' => esc_html__('Add folder name', 'folders'),
4331
+ 'menu_name' => esc_html__('Folders', 'folders'),
4332
+ 'search_items' => esc_html__('Search Folders', 'folders'),
4333
+ 'parent_item' => esc_html__('Parent Folder', 'folders'),
4334
+ ];
4335
 
4336
+ $args = [
4337
+ 'label' => esc_html__('Folder', 'folders'),
4338
+ 'labels' => $labels,
4339
+ 'show_tagcloud' => false,
4340
+ 'hierarchical' => true,
4341
+ 'public' => false,
4342
+ 'show_ui' => true,
4343
+ 'show_in_menu' => false,
4344
+ 'show_in_rest' => true,
4345
+ 'show_admin_column' => true,
4346
  'update_count_callback' => '_update_post_term_count',
4347
+ // 'update_count_callback' => '_update_generic_term_count',
4348
+ 'query_var' => true,
4349
+ 'rewrite' => false,
4350
+ 'capabilities' => [
4351
  'manage_terms' => 'manage_categories',
4352
  'edit_terms' => 'manage_categories',
4353
  'delete_terms' => 'manage_categories',
4354
+ 'assign_terms' => 'manage_categories',
4355
+ ],
4356
+ ];
4357
 
4358
  $folder_post_type = self::get_custom_post_type($post_type);
4359
 
4362
  $post_type,
4363
  $args
4364
  );
4365
+ }//end foreach
4366
+ }//end if
4367
 
4368
  $postData = filter_input_array(INPUT_POST);
4369
 
4370
+ if (current_user_can("manage_categories") && isset($postData['folder_nonce'])) {
4371
+ if (wp_verify_nonce($postData['folder_nonce'], "folder_settings")) {
4372
  if (isset($postData['folders_show_in_menu']) && !empty($postData['folders_show_in_menu'])) {
4373
  $show_menu = "off";
4374
  if ($postData['folders_show_in_menu'] == "on") {
4375
  $show_menu = "on";
4376
  }
4377
+
4378
  update_option("folders_show_in_menu", $show_menu);
4379
  }
4380
 
4381
  if (isset($postData['folders_settings1'])) {
4382
+ $posts = [];
4383
  if (isset($postData['folders_settings']) && is_array($postData['folders_settings'])) {
4384
  foreach ($postData['folders_settings'] as $key => $val) {
4385
  $posts[] = $val;
4386
  }
4387
  }
4388
+
4389
  update_option("folders_settings", $posts);
4390
  }
4391
 
4392
+ $postData = filter_input_array(INPUT_POST);
4393
+
4394
+ if (isset($postData['folders_settings1'])) {
4395
+ $posts = [];
4396
+ if (isset($postData['default_folders']) && is_array($postData['default_folders'])) {
4397
+ foreach ($postData['default_folders'] as $key => $val) {
4398
  $posts[$key] = $val;
4399
  }
4400
  }
4401
+
4402
  update_option("default_folders", $posts);
4403
  }
4404
 
4405
+ if (isset($postData['customize_folders'])) {
4406
+ $posts = [];
4407
+ if (isset($postData['customize_folders']) && is_array($postData['customize_folders'])) {
4408
+ foreach ($postData['customize_folders'] as $key => $val) {
4409
  $posts[$key] = $val;
4410
  }
4411
  }
4412
+
4413
  update_option("customize_folders", $posts);
4414
  }
4415
 
4416
+ $setting_page = $this->getFolderSettingsURL();
4417
+ if (!empty($setting_page)) {
4418
+ $page = filter_input(INPUT_POST, 'tab_page');
4419
+ $type = filter_input(INPUT_GET, 'setting_page');
4420
+ $type = empty($type) ? "" : "&setting_page=".esc_attr($type);
4421
+ $setting_page = $setting_page.$type;
4422
+ if (!empty($page)) {
4423
+ $setting_page .= "&setting_page=".esc_attr($page);
4424
+ }
 
 
 
 
 
 
 
 
4425
 
4426
+ wp_redirect($setting_page."&note=1");
4427
+ exit;
4428
+ } else {
4429
+ $folder_page = filter_input(INPUT_POST, 'folder_page');
4430
+ if (!empty($folder_page)) {
4431
+ wp_redirect($folder_page);
4432
+ exit;
4433
+ }
4434
+ }
4435
+ }//end if
4436
+ }//end if
 
 
 
 
 
 
 
 
 
 
 
4437
 
4438
+ // $old_version = get_option("folder_old_plugin_status");
4439
+ // if($old_version !== false && $old_version == 1) {
4440
+ // $tlfs = get_option("folder_old_plugin_folder_status");
4441
+ // if($tlfs === false) {
4442
+ // $total = self::ttl_fldrs();
4443
+ // if($total <= 10) {
4444
+ // $total = 10;
4445
+ // };
4446
+ // update_option("folder_old_plugin_folder_status", $total);
4447
+ // self::$folders = $total;
4448
+ // } else {
4449
+ // self::$folders = $tlfs;
4450
+ // }
4451
+ // }
4452
+ //
4453
+ // $tlfs = get_option("folder_old_plugin_folder_status");
4454
+ // if($tlfs === false) {
4455
+ // self::$folders = 10;
4456
+ // } else {
4457
+ // self::$folders = $tlfs;
4458
+ // }
4459
+
4460
+ }//end create_folder_terms()
4461
+
4462
+
4463
+ /**
4464
+ * Search for data from list
4465
+ *
4466
+ * @since 1.0.0
4467
+ * @access public
4468
+ * @return $key
4469
+ */
4470
  function searchForId($id, $menu)
4471
  {
4472
  if ($menu) {
4474
  if (array_key_exists(2, $val)) {
4475
  $stripVal = explode('=', $val[2]);
4476
  }
4477
+
4478
  if (array_key_exists(1, $stripVal)) {
4479
  $stripVal = $stripVal[1];
4480
  }
4481
+
4482
  if ($stripVal === $id) {
4483
  return $key;
4484
  }
4485
  }
4486
  }
 
4487
 
4488
+ }//end searchForId()
4489
+
4490
+
4491
+ /**
4492
+ * Create setting menu for folders
4493
+ *
4494
+ * @since 1.0.0
4495
+ * @access public
4496
+ */
4497
  function create_menu_for_folders()
4498
  {
4499
  global $menu;
4507
  foreach ($folder_types as $type) {
4508
  $itemKey = self::searchForId($type, $menu);
4509
  switch (true) {
4510
+ case ($type == 'attachment'):
4511
+ $itemKey = 10;
4512
+ $edit = 'upload.php';
4513
+ break;
4514
+ case ($type === 'post'):
4515
+ $edit = 'edit.php';
4516
+ $itemKey = 5;
4517
+ break;
4518
+ default:
4519
+ $edit = 'edit.php';
4520
+ break;
4521
  }
4522
 
4523
  $folder = $type == 'attachment' ? 'media' : $type;
4524
+ $upper = $type == 'attachment' ? 'Media' : ucwords(str_replace(['-', '_'], ' ', $type));
4525
  if ($type == 'page') {
4526
  $tax_slug = 'folder';
4527
  } else {
4528
+ $tax_slug = $folder.'_folder';
4529
  }
4530
 
 
4531
  $hide_empty = true;
4532
  if ($type == 'attachment') {
4533
  $hide_empty = false;
4534
  add_menu_page('Media Folders', 'Media Folders', 'publish_pages', "{$edit}?post_type=attachment&media_folder=", false, 'dashicons-portfolio', "{$itemKey}.5");
4535
  } else {
4536
+ add_menu_page($upper.' Folders', "{$upper} Folders", 'publish_pages', "{$edit}?post_type={$type}&type=folder", false, 'dashicons-portfolio', "{$itemKey}.5");
4537
  }
4538
 
4539
+ $terms = get_terms(
4540
+ $tax_slug,
4541
+ [
4542
+ 'hide_empty' => $hide_empty,
4543
+ 'parent' => 0,
4544
+ 'orderby' => 'meta_value_num',
4545
+ 'order' => 'ASC',
4546
  'hierarchical' => false,
4547
+ 'meta_query' => [
4548
+ [
4549
+ 'key' => 'wcp_custom_order',
4550
+ 'type' => 'NUMERIC',
4551
+ ],
4552
+ ],
4553
+ ]
4554
  );
4555
 
4556
  if ($terms) {
4557
  foreach ($terms as $term) {
4558
+ if (isset($term->trash_count) && !empty($term->trash_count)) {
4559
  if ($type == 'attachment') {
4560
  add_submenu_page("{$edit}?type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type=attachment&media_folder={$term->slug}", false);
4561
  } else {
4564
  }
4565
  }
4566
  }
4567
+ }//end foreach
 
4568
 
4569
+ }//end create_menu_for_folders()
4570
+
4571
+
4572
+ /**
4573
+ * Add Folder Styles
4574
+ *
4575
+ * @since 1.0.0
4576
+ * @access public
4577
+ */
4578
  function folders_admin_styles($page)
4579
  {
4580
+ if ($page == "toplevel_page_wcp_folders_settings" || $page == "settings_page_wcp_folders_settings") {
4581
+ wp_enqueue_style('folder-settings', plugin_dir_url(dirname(__FILE__)).'assets/css/settings.css', [], WCP_FOLDER_VERSION);
4582
+ wp_enqueue_style('folders-icon', plugin_dir_url(dirname(__FILE__)).'assets/css/folder-icon.css', [], WCP_FOLDER_VERSION);
4583
+ wp_enqueue_style('folders-spectrum', plugin_dir_url(dirname(__FILE__)).'assets/css/spectrum.min.css', [], WCP_FOLDER_VERSION);
4584
+ }
4585
+
4586
+ if ($page == "folders-settings_page_folders-upgrade-to-pro" || $page == "toplevel_page_wcp_folders_settings" || $page == "settings_page_wcp_folders_settings" || ($page == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == "upgrade-to-pro")) {
4587
+ wp_enqueue_style('wcp-select2', plugin_dir_url(dirname(__FILE__)).'assets/css/select2.min.css', [], WCP_FOLDER_VERSION);
4588
+ if ($page == "folders-settings_page_folders-upgrade-to-pro" || ($page == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == "upgrade-to-pro")) {
4589
+ wp_enqueue_style('wcp-admin-setting', plugin_dir_url(dirname(__FILE__)).'assets/css/admin-setting.css', [], WCP_FOLDER_VERSION);
4590
+ }
4591
+ }
4592
+
4593
  if (self::is_active_for_screen()) {
4594
+ wp_enqueue_style('wcp-folders-fa', plugin_dir_url(dirname(__FILE__)).'assets/css/folder-icon.css', [], WCP_FOLDER_VERSION);
4595
+ wp_enqueue_style('wcp-folders-admin', plugin_dir_url(dirname(__FILE__)).'assets/css/design.min.css', [], WCP_FOLDER_VERSION);
4596
+ wp_enqueue_style('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)).'assets/css/jstree.min.css', [], WCP_FOLDER_VERSION);
4597
+ wp_enqueue_style('wcp-folders-mcustomscrollbar', WCP_FOLDER_URL.'assets/css/jquery.mcustomscrollbar.min.css', [], WCP_FOLDER_VERSION);
4598
+ wp_enqueue_style('wcp-folders-css', plugin_dir_url(dirname(__FILE__)).'assets/css/folders.css', [], WCP_FOLDER_VERSION);
4599
  }
4600
+
4601
+ if ($page == "media_page_folders-media-cleaning") {
4602
+ wp_enqueue_style('wcp-folders-media', plugin_dir_url(dirname(__FILE__)).'assets/css/media-clean.css', [], WCP_FOLDER_VERSION);
4603
  }
4604
+
4605
  wp_register_style('wcp-css-handle', false);
4606
  wp_enqueue_style('wcp-css-handle');
4607
  $css = "
4609
  ";
4610
  if (self::is_active_for_screen()) {
4611
  global $typenow;
4612
+ $width = get_option("wcp_dynamic_width_for_".$typenow);
4613
  $width = esc_attr($width);
4614
  $width = intval($width);
4615
+ $width = empty($width)||!is_numeric($width) ? 280 : $width;
4616
+ if ($width > 1200) {
4617
  $width = 280;
4618
  }
4619
+
4620
+ $width = intval($width);
4621
+ $display_status = "wcp_dynamic_display_status_".$typenow;
4622
  $display_status = get_option($display_status);
4623
+ if ($display_status != "hide") {
4624
  if (!empty($width) && is_numeric($width)) {
4625
  if (function_exists('is_rtl') && is_rtl()) {
4626
+ $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:".($width + 20)."px}";
4627
  $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}";
4628
  } else {
4629
+ $css .= "body.wp-admin #wpcontent {padding-left:".($width + 20)."px}";
4630
  }
4631
  }
4632
  } else {
4637
  $css .= "body.wp-admin #wpcontent {padding-left:20px}";
4638
  }
4639
  }
4640
+
4641
  if (!empty($width) && is_numeric($width)) {
4642
+ if ($width > 1200) {
4643
  $width = 280;
4644
  }
4645
+
4646
  $width = intval($width);
4647
+ $css .= ".wcp-content {width: ".esc_attr($width)."px}";
4648
  }
4649
+
4650
  global $typenow;
4651
  $post_type = self::get_custom_post_type($typenow);
4652
+ $css .= "body:not(.woocommerce-page) .wp-list-table th#taxonomy-".esc_attr($post_type)." { width: 130px !important; } @media screen and (max-width: 1180px) { body:not(.woocommerce-page) .wp-list-table th#taxonomy-".esc_attr($post_type)." { width: 90px !important; }} @media screen and (max-width: 960px) { body:not(.woocommerce-page) .wp-list-table th#taxonomy-".esc_attr($post_type)." { width: auto !important; }}";
4653
+ }//end if
4654
+
4655
  wp_add_inline_style('wcp-css-handle', $css);
4656
 
4657
  if (self::is_active_for_screen()) {
4658
  global $typenow;
4659
+ add_filter('views_edit-'.$typenow, [$this, 'wcp_check_for_child_folders']);
4660
  }
 
4661
 
4662
+ }//end folders_admin_styles()
4663
+
4664
+
4665
+ /**
4666
+ * Get Child folder information
4667
+ *
4668
+ * @since 1.0.0
4669
+ * @access public
4670
+ * @return $folders
4671
+ */
4672
  function wcp_check_for_child_folders($content)
4673
  {
4674
  $termId = 0;
4675
  global $typenow;
4676
  $post_type = self::get_custom_post_type($typenow);
4677
+ $term = filter_input(INPUT_GET, $post_type);
4678
+ if (!empty($term)) {
4679
  $term = get_term_by("slug", $term, $post_type);
4680
  if (!empty($term)) {
4681
  $termId = $term->term_id;
4682
  }
4683
  }
4684
+
4685
+ $terms = get_terms(
4686
+ $post_type,
4687
+ [
4688
+ 'hide_empty' => false,
4689
+ 'parent' => $termId,
4690
+ 'orderby' => 'meta_value_num',
4691
+ 'order' => 'ASC',
4692
+ 'hierarchical' => false,
4693
+ 'update_count_callback' => '_update_generic_term_count',
4694
+ 'meta_query' => [
4695
+ [
4696
+ 'key' => 'wcp_custom_order',
4697
+ 'type' => 'NUMERIC',
4698
+ ],
4699
+ ],
4700
+ ]
4701
+ );
4702
+ $optionName = "wcp_folder_display_status_".$typenow;
4703
  $optionValue = get_option($optionName);
4704
+ $class = (!empty($optionValue) && $optionValue == "hide") ? "" : "active";
4705
  $customize_folders = get_option('customize_folders');
4706
+ $show_in_page = isset($customize_folders['show_in_page']) ? $customize_folders['show_in_page'] : "hide";
4707
+ if (empty($show_in_page)) {
4708
  $show_in_page = "hide";
4709
  }
4710
+
4711
+ if ($show_in_page == "show") {
4712
+ echo '<div class="tree-structure-content '.$class.'"><div class="tree-structure" id="list-folder-'.$termId.'" data-id="'.$termId.'">';
4713
  echo '<ul>';
4714
  foreach ($terms as $term) {
4715
  $status = get_term_meta($term->term_id, "is_highlighted", true);
4716
  ?>
4717
  <li class="grid-view" data-id="<?php echo esc_attr($term->term_id) ?>" id="folder_<?php echo esc_attr($term->term_id) ?>">
4718
  <div class="folder-item is-folder" data-id="<?php echo esc_attr($term->term_id) ?>">
4719
+ <a title='<?php echo esc_attr($term->name) ?>' id="folder_view_<?php echo esc_attr($term->term_id) ?>" class="folder-view <?php echo ($status == 1) ? "is-high" : "" ?>" data-id="<?php echo esc_attr($term->term_id) ?>">
4720
+ <span class="folder item-name"><span id="wcp_folder_text_<?php echo esc_attr($term->term_id) ?>" class="folder-title"><?php echo esc_attr($term->name) ?></span></span>
 
 
 
 
4721
  </a>
4722
  </div>
4723
  </li>
4724
+ <?php
4725
  }
4726
+
4727
  echo '</ul>';
4728
  echo '<div class="clear clearfix"></div>';
4729
  echo '</div>';
4730
  echo '<div class="folders-toggle-button"><span></span></div>';
4731
  echo '</div>';
4732
+ }//end if
4733
+
4734
+ $allowedTags = [
4735
+ 'a' => [
4736
+ 'href' => [],
4737
+ 'title' => [],
4738
+ 'target' => [],
4739
+ ],
4740
+ "span" => [
4741
+ 'class' => []
4742
+ ]
4743
+ ];
4744
+
4745
+ if (!empty($content) && is_array($content)) {
4746
  echo '<ul class="subsubsub">';
4747
+ foreach ($content as $k => $v) {
4748
+ echo "<li class='".esc_attr($k)."'>".wp_kses($v, $allowedTags)."</li>";
4749
  }
4750
+
4751
  echo '</ul>';
4752
  }
 
4753
 
4754
+ }//end wcp_check_for_child_folders()
4755
+
4756
+
4757
+ /**
4758
+ * Add Folder Scripts to admin
4759
+ *
4760
+ * @since 1.0.0
4761
+ * @access public
4762
+ * @return $folders
4763
+ */
4764
  function folders_admin_scripts($hook)
4765
  {
4766
+ if ($hook == "toplevel_page_wcp_folders_settings" || $hook == "settings_page_wcp_folders_settings") {
4767
+ wp_enqueue_script('folders-spectrum', plugin_dir_url(dirname(__FILE__)).'assets/js/spectrum.min.js', ['jquery'], WCP_FOLDER_VERSION);
4768
+ }
4769
+
4770
+ if ($hook == "folders-settings_page_folders-upgrade-to-pro" || $hook == "toplevel_page_wcp_folders_settings" || $hook == "settings_page_wcp_folders_settings" || ($hook == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == "upgrade-to-pro")) {
4771
+ wp_enqueue_script('folders-select2', plugin_dir_url(dirname(__FILE__)).'assets/js/select2.min.js', ['jquery'], WCP_FOLDER_VERSION);
4772
+ }
4773
 
4774
+ if (self::is_active_for_screen()) {
4775
  remove_filter("terms_clauses", "TO_apply_order_filter");
4776
 
4777
  global $typenow;
4778
+ // Free/Pro Version change
4779
  wp_dequeue_script("jquery-jstree");
4780
+ wp_enqueue_script('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)).'assets/js/jstree.min.js', ['jquery'], WCP_FOLDER_VERSION);
4781
+ wp_enqueue_script('wcp-folders-mcustomscrollbar', plugin_dir_url(dirname(__FILE__)).'assets/js/jquery.mcustomscrollbar.min.js', [], WCP_FOLDER_VERSION);
4782
+ wp_enqueue_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)).'assets/js/folders.min.js', ['jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'], WCP_FOLDER_VERSION);
4783
+ wp_enqueue_script('wcp-jquery-touch', plugin_dir_url(dirname(__FILE__)).'assets/js/jquery.ui.touch-punch.min.js', ['jquery'], WCP_FOLDER_VERSION);
4784
 
4785
  $post_type = self::get_custom_post_type($typenow);
4786
 
4787
  if ($typenow == "attachment") {
4788
  $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
4789
  } else {
4790
+ $admin_url = admin_url("edit.php?post_type=".$typenow);
4791
+ $search = filter_input(INPUT_GET, "s");
4792
+ if (!empty($search)) {
4793
+ $admin_url .= "&s=".esc_attr($search);
4794
  }
4795
+
4796
+ $admin_url .= "&".esc_attr($post_type)."=";
4797
  }
4798
 
4799
  $current_url = $admin_url;
4800
+ $post_value = filter_input(INPUT_GET, $post_type);
4801
+ if (!empty($post_value)) {
4802
+ $current_url .= esc_attr($post_value);
4803
  }
4804
 
 
4805
  $is_active = 1;
4806
+ $folders = -1;
4807
+ // For free: upgrade URL, for Pro: Register Key URL
4808
  $register_url = $this->getFoldersUpgradeURL();
4809
 
4810
  $is_rtl = 0;
4811
+ if (function_exists('is_rtl') && is_rtl()) {
4812
  $is_rtl = 1;
4813
  }
4814
 
4815
+ $can_manage_folder = current_user_can("manage_categories") ? 1 : 0;
4816
+ $width = get_option("wcp_dynamic_width_for_".$typenow);
4817
  $width = intval($width);
4818
+ $width = empty($width)||!is_numeric($width) ? 280 : $width;
4819
+ if ($width > 1200) {
4820
  $width = 280;
4821
  }
4822
+
4823
+ $post_type = self::get_custom_post_type($typenow);
4824
+ $taxonomy_status = 0;
4825
  $selected_taxonomy = "";
4826
+ $post_value = filter_input(INPUT_GET, $post_type);
4827
+ if (empty($post_value)) {
4828
  $taxonomy_status = 1;
4829
+ } else {
4830
+ $selected_taxonomy = esc_attr($post_value);
4831
 
4832
  $term = get_term_by('slug', $selected_taxonomy, $post_type);
4833
  if (!empty($term) && is_object($term)) {
4834
  $selected_taxonomy = $term->term_id;
4835
  } else {
4836
  $selected_taxonomy = "";
 
4837
  }
4838
  }
4839
+
4840
  $customize_folders = get_option('customize_folders');
4841
+ $show_in_page = isset($customize_folders['show_in_page']) ? $customize_folders['show_in_page'] : "hide";
4842
+ if (empty($show_in_page)) {
4843
+ $show_in_page = "hide";
4844
+ }
4845
+
4846
+ $taxonomies = self::get_terms_hierarchical($post_type);
4847
+ $use_folder_undo = !isset($customize_folders['use_folder_undo']) ? "yes" : $customize_folders['use_folder_undo'];
4848
+ $defaultTimeout = !isset($customize_folders['default_timeout']) ? 5 : intval($customize_folders['default_timeout']);
4849
+ if (empty($defaultTimeout) || !is_numeric($defaultTimeout) || $defaultTimeout < 0) {
4850
+ $defaultTimeout = 5;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4851
  }
4852
 
4853
+ $defaultTimeout = ($defaultTimeout * 1000);
4854
 
4855
+ $folder_settings = [];
4856
+ foreach ($taxonomies as $taxonomy) {
4857
+ $is_sticky = get_term_meta($taxonomy->term_id, "is_folder_sticky", true);
4858
+ $is_high = get_term_meta($taxonomy->term_id, "is_highlighted", true);
4859
+ $folder_settings[] = [
4860
+ 'folder_id' => $taxonomy->term_id,
4861
+ 'is_sticky' => intval($is_sticky),
4862
+ 'is_high' => intval($is_high),
4863
+ 'nonce' => wp_create_nonce('wcp_folder_term_'.$taxonomy->term_id),
4864
+ 'is_deleted' => 0,
4865
+ 'slug' => $taxonomy->slug,
4866
+ 'folder_count' => intval($taxonomy->trash_count),
4867
+ ];
4868
+ }
4869
 
4870
  $default_folders = get_option("default_folders");
4871
+ $default_folder = "";
4872
+ if (isset($default_folders["attachment"])) {
4873
  $default_folder = $default_folders["attachment"];
4874
  }
 
4875
 
4876
+ $use_shortcuts = !isset($customize_folders['use_shortcuts']) ? "yes" : $customize_folders['use_shortcuts'];
4877
+
4878
+ $currentPage = filter_input(INPUT_GET, 'paged');
4879
+ if (!empty($currentPage)) {
4880
+ $currentPage = intval($currentPage);
4881
+ }
4882
+
4883
+ $hasStars = self::check_for_setting("has_stars", "general");
4884
+ $hasChild = self::check_for_setting("has_child", "general");
4885
+ $hasChild = empty($hasChild) ? 0 : 1;
4886
+ $hasStars = empty($hasStars) ? 0 : 1;
4887
+ wp_localize_script(
4888
+ 'wcp-folders-custom',
4889
+ 'wcp_settings',
4890
+ [
4891
+ 'ajax_url' => admin_url('admin-ajax.php'),
4892
+ 'upgrade_url' => $this->getFoldersUpgradeURL(),
4893
+ 'post_type' => $typenow,
4894
+ 'page_url' => $admin_url,
4895
+ 'current_url' => $current_url,
4896
+ 'ajax_image' => plugin_dir_url(dirname(__FILE__))."assets/images/ajax-loader.gif",
4897
+ 'is_key_active' => $is_active,
4898
+ 'folders' => $folders,
4899
+ 'register_url' => $register_url,
4900
+ 'isRTL' => $is_rtl,
4901
+ 'nonce' => wp_create_nonce('wcp_folder_nonce_'.$typenow),
4902
+ 'can_manage_folder' => $can_manage_folder,
4903
+ 'folder_width' => $width,
4904
+ 'taxonomy_status' => $taxonomy_status,
4905
+ 'selected_taxonomy' => $selected_taxonomy,
4906
+ 'show_in_page' => $show_in_page,
4907
+ 'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png',
4908
+ 'taxonomies' => $taxonomies,
4909
+ 'folder_settings' => $folder_settings,
4910
+ 'hasStars' => $hasStars,
4911
+ 'hasChildren' => $hasChild,
4912
+ 'currentPage' => $currentPage,
4913
+ 'useFolderUndo' => $use_folder_undo,
4914
+ 'defaultTimeout' => $defaultTimeout,
4915
+ 'default_folder' => $default_folder,
4916
+ 'use_shortcuts' => $use_shortcuts,
4917
+ ]
4918
+ );
4919
  } else {
4920
  self::is_add_update_screen();
4921
+ }//end if
4922
 
4923
+ if ($hook == "media-new.php") {
4924
+ if (self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
4925
+ wp_enqueue_style('folders-media', WCP_FOLDER_URL.'assets/css/new-media.css');
4926
  $is_active = 1;
4927
+ $folders = -1;
4928
+
4929
+ $hasStars = self::check_for_setting("has_stars", "general");
4930
+ $hasChild = self::check_for_setting("has_child", "general");
4931
+ $hasChild = empty($hasChild) ? 0 : 1;
4932
+ $hasStars = empty($hasStars) ? 0 : 1;
4933
+
4934
+ wp_enqueue_script('wcp-folders-add-new-media', plugin_dir_url(dirname(__FILE__)).'assets/js/new-media.js', ['jquery'], WCP_FOLDER_VERSION);
4935
+ wp_localize_script(
4936
+ 'wcp-folders-add-new-media',
4937
+ 'folders_media_options',
4938
+ [
4939
+ 'terms' => self::get_terms_hierarchical('media_folder'),
4940
+ 'taxonomy' => get_taxonomy('media_folder'),
4941
+ 'ajax_url' => admin_url("admin-ajax.php"),
4942
+ 'activate_url' => $this->getFoldersUpgradeURL(),
4943
+ 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
4944
+ 'is_key_active' => $is_active,
4945
+ 'folders' => $folders,
4946
+ 'hasStars' => $hasStars,
4947
+ 'hasChildren' => $hasChild,
4948
+ ]
4949
+ );
4950
+ }//end if
4951
+ }//end if
4952
+
4953
+ }//end folders_admin_scripts()
4954
 
4955
+
4956
+ /**
4957
+ * Redirect to folders settings page on Plugin activation
4958
+ *
4959
+ * @since 1.0.0
4960
+ * @access public
4961
+ */
4962
  public function plugin_action_links($links)
4963
  {
4964
+ array_unshift($links, '<a href="'.admin_url("admin.php?page=wcp_folders_settings").'" >'.esc_html__('Settings', 'folders').'</a>');
4965
+ $links['need_help'] = '<a target="_blank" href="https://premio.io/help/folders/?utm_source=pluginspage" >'.__('Need help?', 'folders').'</a>';
4966
 
4967
+ // PRO link for only for FREE
4968
+ $links['pro'] = '<a class="wcp-folder-upgrade-button" href="'.$this->getFoldersUpgradeURL().'" >'.__('Upgrade', 'folders').'</a>';
4969
  return $links;
 
4970
 
4971
+ }//end plugin_action_links()
4972
+
4973
+
4974
+ /**
4975
+ * Create instance of Folder class
4976
+ *
4977
+ * @since 1.0.0
4978
+ * @access public
4979
+ * @return $folders
4980
+ */
4981
  public static function get_instance()
4982
  {
4983
  if (empty(self::$instance)) {
4984
+ // Do not change Class name here
4985
  self::$instance = new WCP_Folders();
4986
  }
4987
+
4988
  return self::$instance;
 
4989
 
4990
+ }//end get_instance()
4991
+
4992
+
4993
+ /**
4994
+ * Will check for empty folder order
4995
+ *
4996
+ * @since 1.0.0
4997
+ * @access public
4998
+ */
4999
+ public function check_and_set_post_type()
5000
+ {
5001
+ $options = get_option('folders_settings');
5002
  $old_plugin_status = 0;
5003
+ $post_array = [];
5004
  if (!empty($options) && is_array($options)) {
5005
+ foreach ($options as $key => $val) {
5006
  if (!(strpos($key, 'folders4') === false) && $old_plugin_status == 0) {
5007
  $old_plugin_status = 1;
5008
  }
5009
+
5010
+ if (in_array($key, ["folders4page", "folders4post", "folders4attachment"])) {
5011
  $post_array[] = str_replace("folders4", "", $key);
5012
  }
5013
  }
5014
  } else {
5015
+ $post_array = [
5016
+ "page",
5017
+ "post",
5018
+ "attachment",
5019
+ ];
5020
  }
5021
+
5022
  if ($old_plugin_status == 1) {
5023
  update_option("folders_show_in_menu", "on");
5024
  $old_plugin_var = get_option("folder_old_plugin_status");
5025
  if (empty($old_plugin_var) || $old_plugin_var == null) {
5026
  update_option("folder_old_plugin_status", "1");
5027
  }
5028
+
5029
  update_option('folders_settings', $post_array);
5030
  self::set_default_values_if_not_exists();
5031
  }
5032
+
5033
  if (!empty($post_array) && get_option('folders_settings') === false) {
5034
  update_option('folders_settings', $post_array);
5035
  update_option("folders_show_in_menu", "off");
5036
  }
 
5037
 
5038
+ }//end check_and_set_post_type()
5039
+
5040
+
5041
+ /**
5042
+ * Migrate data for old versions
5043
+ *
5044
+ * @since 1.0.0
5045
+ * @access public
5046
+ */
5047
  public static function activate()
5048
  {
5049
+ premio_folders_plugin_check_for_setting();
5050
  $folder_setting = get_option("folders_settings");
5051
+ if ($folder_setting === false) {
5052
  add_option("wcp_folder_version_267", 1);
5053
  }
5054
+
5055
  update_option("folders_show_in_menu", "off");
5056
  $option = get_option("folder_redirect_status");
5057
+ if ($option === false) {
5058
  add_option("folder_intro_box", "show");
5059
  }
5060
+
5061
  update_option("folder_redirect_status", 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5062
 
5063
+ }//end activate()
5064
+
5065
+
5066
+ /**
5067
+ * Remove folder data on deactivation
5068
+ *
5069
+ * @since 1.0.0
5070
+ * @access public
5071
+ */
5072
+ public static function deactivate()
5073
+ {
5074
+ $customize_folders = get_option('customize_folders');
5075
+ $DS = DIRECTORY_SEPARATOR;
5076
+ $dirName = ABSPATH."wp-content{$DS}plugins{$DS}folders-pro{$DS}";
5077
+ $is_pro = get_option("folders_pro_is_in_process");
5078
+ if (!is_dir($dirName) && $is_pro === false && isset($customize_folders['remove_folders_when_removed']) && $customize_folders['remove_folders_when_removed'] == "on") {
5079
+ self::$folders = 0;
5080
+ self::remove_folder_by_taxonomy("media_folder");
5081
+ self::remove_folder_by_taxonomy("folder");
5082
+ self::remove_folder_by_taxonomy("post_folder");
5083
+ $post_types = get_post_types([], 'objects');
5084
+ $post_array = [
5085
+ "page",
5086
+ "post",
5087
+ "attachment",
5088
+ ];
5089
+ foreach ($post_types as $post_type) {
5090
+ if (!in_array($post_type->name, $post_array)) {
5091
+ self::remove_folder_by_taxonomy($post_type->name.'_folder');
5092
+ }
5093
+ }
5094
+
5095
+ delete_option('customize_folders');
5096
+ delete_option('default_folders');
5097
+ delete_option('folders_show_in_menu');
5098
+ delete_option('folder_redirect_status');
5099
+ delete_option('folders_settings');
5100
+ delete_option('premio_folder_options');
5101
+ delete_option('folders_settings_updated');
5102
+ }//end if
5103
+
5104
+ }//end deactivate()
5105
+
5106
+
5107
+ /**
5108
+ * Register folder settings
5109
+ *
5110
+ * @since 1.0.0
5111
+ * @access public
5112
+ */
5113
  function folders_register_settings()
5114
  {
5115
  register_setting('folders_settings', 'folders_settings1', 'folders_settings_validate');
5119
  self::check_and_set_post_type();
5120
 
5121
  $getData = filter_input_array(INPUT_GET);
5122
+ if (isset($getData['hide_menu']) && $getData['hide_menu'] == "scan-files" && isset($getData['nonce'])) {
5123
+ if (current_user_can('manage_options')) {
5124
  $nonce = $getData['nonce'];
5125
+ if (wp_verify_nonce($nonce, "folders-scan-files")) {
5126
  $customize_folders = get_option('customize_folders');
5127
  $customize_folders['folders_media_cleaning'] = "no";
5128
  update_option("customize_folders", $customize_folders);
5138
  wp_redirect(admin_url("admin.php?page=wcp_folders_settings"));
5139
  exit;
5140
  }
 
5141
 
5142
+ }//end folders_register_settings()
5143
+
5144
+
5145
+ /**
5146
+ * Folders upgrade URL
5147
+ *
5148
+ * @since 1.0.0
5149
+ * @access public
5150
+ * @return $url
5151
+ */
5152
+ function getFoldersUpgradeURL()
5153
+ {
5154
  $customize_folders = get_option("customize_folders");
5155
+ if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
5156
  return admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
5157
  } else {
5158
  return admin_url("admin.php?page=folders-upgrade-to-pro");
5159
  }
 
5160
 
5161
+ }//end getFoldersUpgradeURL()
5162
+
5163
+
5164
+ /**
5165
+ * Returns folders settings URL
5166
+ *
5167
+ * @since 1.0.0
5168
+ * @access public
5169
+ * @return $url
5170
+ */
5171
+ function getFolderSettingsURL()
5172
+ {
5173
  $customize_folders = get_option("customize_folders");
5174
+ if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
5175
  return admin_url("options-general.php?page=wcp_folders_settings");
5176
  } else {
5177
  return admin_url("admin.php?page=wcp_folders_settings");
5178
  }
 
5179
 
5180
+ }//end getFolderSettingsURL()
5181
+
5182
+
5183
+ /**
5184
+ * Checking folders setting is inside wordpress setting menu
5185
+ *
5186
+ * @since 1.0.0
5187
+ * @access public
5188
+ */
5189
+ function isFoldersInSettings()
5190
+ {
5191
  $customize_folders = get_option("customize_folders");
5192
  if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
5193
  return true;
5194
  }
5195
+
5196
  return false;
 
5197
 
5198
+ }//end isFoldersInSettings()
5199
+
5200
+
5201
+ /**
5202
+ * Add Checkbox to table head for page, post, attachments
5203
+ *
5204
+ * @since 1.0.0
5205
+ * @access public
5206
+ * @return $defaults
5207
+ */
5208
+ function wcp_manage_columns_head($defaults, $d="")
5209
  {
5210
  global $typenow;
5211
+ $type = $typenow;
5212
+ $action = $this->getRequestVar("action");
5213
+ if ($action == 'inline-save') {
5214
+ $post_type = $this->getRequestVar('post_type');
5215
+ $type = self::sanitize_options($post_type);
5216
  }
5217
 
5218
  $options = get_option("folders_settings");
5219
  if (is_array($options) && in_array($type, $options)) {
5220
+ $columns = ([
5221
+ 'wcp_move' => '<div class="wcp-move-multiple wcp-col" title="'.esc_html__('Move selected items', 'folders').'"><span class="dashicons dashicons-move"></span><div class="wcp-items"></div></div>',
5222
+ ] + $defaults);
5223
  return $columns;
5224
  }
5225
+
5226
  return $defaults;
 
5227
 
5228
+ }//end wcp_manage_columns_head()
5229
+
5230
+
5231
+ /**
5232
+ * Add Checkbox to table body content for page, post, attachments
5233
+ *
5234
+ * @since 1.0.0
5235
+ * @access public
5236
+ * @return $column_name
5237
+ */
5238
  function wcp_manage_columns_content($column_name, $post_ID)
5239
  {
5240
  $postIDs = self::$postIds;
5241
+ if (!is_array($postIDs)) {
5242
+ $postIDs = [];
5243
  }
5244
+
5245
+ if (!in_array($post_ID, $postIDs)) {
5246
+ $postIDs[] = $post_ID;
5247
  self::$postIds = $postIDs;
5248
  global $typenow;
5249
+ $type = $typenow;
5250
+ $action = $this->getRequestVar('action');
5251
+ if ($action == 'inline-save') {
5252
+ $post_type = $this->getRequestVar('post_type');
5253
+ $type = self::sanitize_options($post_type);
5254
  }
5255
 
5256
  $options = get_option("folders_settings");
5258
  if ($column_name == 'wcp_move') {
5259
  $title = get_the_title();
5260
  if (strlen($title) > 20) {
5261
+ $title = substr($title, 0, 20)."...";
5262
  }
5263
+
5264
+ echo "<div class='wcp-move-file' data-id='".esc_attr($post_ID)."'><span class='wcp-move dashicons dashicons-move' data-id='".esc_attr($post_ID)."'></span><span class='wcp-item' data-object-id='".esc_attr($post_ID)."'>".esc_attr($title)."</span></div>";
5265
  }
5266
  }
5267
+ }//end if
 
5268
 
5269
+ }//end wcp_manage_columns_content()
5270
+
5271
+
5272
+ /**
5273
+ * Exclude empty folders
5274
+ *
5275
+ * @since 1.0.0
5276
+ * @access public
5277
+ * @return $query
5278
+ */
5279
  function taxonomy_archive_exclude_children($query)
5280
  {
5281
  $options = get_option("folders_settings");
5282
  if (!empty($options)) {
5283
+ $taxonomy_slugs = [];
5284
  foreach ($options as $option) {
5285
  $taxonomy_slugs[] = self::get_custom_post_type($option);
5286
  }
5287
+
5288
  if (!empty($taxonomy_slugs)) {
5289
  $i = 0;
5290
  foreach ($query->tax_query->queries as $tax_query_item) {
5294
  }
5295
  }
5296
  }
 
5297
 
5298
+ }//end taxonomy_archive_exclude_children()
5299
+
5300
+
5301
+ /**
5302
+ * Add folder settins to WP menu
5303
+ *
5304
+ * @since 1.0.0
5305
+ * @access public
5306
+ */
5307
+ public function admin_menu()
5308
+ {
5309
  $customize_folders = get_option("customize_folders");
5310
  if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
5311
  add_options_page(
5313
  esc_html__('Folders Settings', 'folders'),
5314
  'manage_options',
5315
  'wcp_folders_settings',
5316
+ [
5317
+ $this,
5318
+ 'wcp_folders_settings',
5319
+ ]
5320
  );
5321
  } else {
5322
  $menu_slug = 'wcp_folders_settings';
5325
  $page_title = esc_html__('Folders', 'folders');
5326
  $menu_title = esc_html__('Folders Settings', 'folders');
5327
  $capability = 'manage_options';
5328
+ $callback = [
5329
+ $this,
5330
+ "wcp_folders_settings",
5331
+ ];
5332
+ $icon_url = 'dashicons-category';
5333
+ $position = 99;
5334
  add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $position);
5335
 
5336
  $getData = filter_input_array(INPUT_GET);
5337
+ if (isset($getData['hide_folder_recommended_plugin']) && isset($getData['nonce'])) {
5338
+ if (current_user_can('manage_options')) {
5339
  $nonce = $getData['nonce'];
5340
+ if (wp_verify_nonce($nonce, "folder_recommended_plugin")) {
5341
+ update_option('hide_folder_recommended_plugin', "1");
5342
  }
5343
  }
5344
  }
5345
 
5346
  $recommended_plugin = get_option("hide_folder_recommended_plugin");
5347
+ if ($recommended_plugin === false) {
5348
  add_submenu_page(
5349
  $menu_slug,
5350
  esc_html__('Recommended Plugins', 'folders'),
5351
  esc_html__('Recommended Plugins', 'folders'),
5352
  'manage_options',
5353
  'recommended-folder-plugins',
5354
+ [
5355
+ $this,
5356
+ 'recommended_plugins',
5357
+ ]
5358
  );
5359
  }
5360
 
5361
+ // Do not Change Free/Pro Change for menu
5362
  add_submenu_page(
5363
  $menu_slug,
5364
  esc_html__('Upgrade to Pro', 'folders'),
5365
  esc_html__('Upgrade to Pro', 'folders'),
5366
  'manage_options',
5367
  'folders-upgrade-to-pro',
5368
+ [
5369
+ $this,
5370
+ 'wcp_folders_upgrade_or_register',
5371
+ ]
5372
  );
5373
 
5374
+ // Add menu for media cleaning
5375
+ $show_in_page = !isset($customize_folders['folders_media_cleaning']) ? "yes" : $customize_folders['folders_media_cleaning'];
5376
 
5377
+ if ($show_in_page == "yes") {
5378
  add_submenu_page(
5379
  "upload.php",
5380
  esc_html__('Media Cleaning', 'folders'),
5381
  esc_html__('Media Cleaning', 'folders'),
5382
  'manage_options',
5383
  'folders-media-cleaning',
5384
+ [
5385
+ $this,
5386
+ 'wcp_folders_media_cleaning',
5387
+ ]
5388
  );
5389
  }
5390
+ }//end if
5391
 
5392
  self::check_and_set_post_type();
5393
 
5395
  if ($show_menu == "on") {
5396
  self::create_menu_for_folders();
5397
  }
 
5398
 
5399
+ }//end admin_menu()
5400
+
5401
+
5402
+ /**
5403
+ * Media Cleaner Page
5404
+ *
5405
+ * @since 1.0.0
5406
+ * @access public
5407
+ * @return $html
5408
+ */
5409
+ public function wcp_folders_media_cleaning()
5410
+ {
5411
+ include_once dirname(dirname(__FILE__))."/templates/admin/media-cleaning.php";
5412
+
5413
+ }//end wcp_folders_media_cleaning()
5414
 
 
 
 
5415
 
5416
+ /**
5417
+ * Recommended plugins Page
5418
+ *
5419
+ * @since 1.0.0
5420
+ * @access public
5421
+ * @return $html
5422
+ */
5423
+ public function recommended_plugins()
5424
+ {
5425
+ include_once dirname(dirname(__FILE__))."/templates/admin/recommended-plugins.php";
5426
+
5427
+ }//end recommended_plugins()
5428
+
5429
+
5430
+ /**
5431
+ * Folders Upgrade Page
5432
+ *
5433
+ * @since 1.0.0
5434
+ * @access public
5435
+ * @return $html
5436
+ */
5437
  public function wcp_folders_upgrade_or_register()
5438
  {
5439
  self::set_default_values_if_not_exists();
5440
+ include_once dirname(dirname(__FILE__))."/templates/admin/upgrade-to-pro.php";
 
5441
 
5442
+ }//end wcp_folders_upgrade_or_register()
5443
+
5444
+
5445
+ /**
5446
+ * Folders Settings Page
5447
+ *
5448
+ * @since 1.0.0
5449
+ * @access public
5450
+ * @return $html
5451
+ */
5452
  public function wcp_folders_settings()
5453
  {
5454
  self::set_default_values_if_not_exists();
5455
+ // Only in Free, Get Folders update confirmation popup
5456
  $is_shown = get_option("folder_update_message");
5457
+ if ($is_shown === false) {
5458
+ include_once dirname(dirname(__FILE__))."/templates/admin/update.php";
5459
  } else {
5460
+ $options = get_option('folders_settings');
5461
+ $options = (empty($options) || !is_array($options)) ? [] : $options;
5462
+ $post_types = get_post_types(['public' => true], 'objects');
5463
+ $terms_data = [];
5464
  foreach ($post_types as $post_type) {
5465
  if (in_array($post_type->name, $options)) {
5466
+ $term = $post_type->name;
5467
+ $term = self::get_custom_post_type($term);
5468
  $categories = self::get_terms_hierarchical($term);
5469
  $terms_data[$post_type->name] = $categories;
5470
  } else {
5471
+ $terms_data[$post_type->name] = [];
5472
  }
5473
  }
5474
+
5475
  $fonts = self::get_font_list();
5476
 
5477
+ $plugins = new WCP_Folder_Plugins();
5478
+ $plugin_info = $plugins->get_plugin_information();
5479
  $is_plugin_exists = $plugins->is_exists;
5480
+ $settingURL = $this->getFolderSettingsURL();
5481
+ $setting_page = filter_input(INPUT_GET, 'setting_page');
5482
+ if (empty($setting_page)) {
5483
+ $setting_page = "folder-settings";
5484
+ }
5485
+
5486
+ $setting_page = in_array($setting_page, ["folder-settings", "customize-folders", "folders-import", "upgrade-to-pro", "folders-by-user"]) ? $setting_page : "folder-settings";
5487
  $isInSettings = $this->isFoldersInSettings();
5488
 
5489
+ include_once dirname(dirname(__FILE__))."/templates/admin/general-settings.php";
5490
 
5491
  $option = get_option("folder_intro_box");
5492
+ if ($option == "show") {
5493
+ include_once dirname(dirname(__FILE__))."/templates/admin/folder-popup.php";
5494
  }
5495
+ }//end if
 
5496
 
5497
+ }//end wcp_folders_settings()
5498
+
5499
+
5500
+ /**
5501
+ * Font List
5502
+ *
5503
+ * @since 1.0.0
5504
+ * @access public
5505
+ * @return $fonts
5506
+ */
5507
+ public static function get_font_list()
5508
+ {
5509
+ return [
5510
  // System fonts.
5511
+ 'Default' => 'Default',
5512
+ "System Stack" => 'Default',
5513
+ 'Arial' => 'Default',
5514
+ 'Tahoma' => 'Default',
5515
+ 'Verdana' => 'Default',
5516
+ 'Helvetica' => 'Default',
5517
+ 'Times New Roman' => 'Default',
5518
+ 'Trebuchet MS' => 'Default',
5519
+ 'Georgia' => 'Default',
5520
 
5521
  // Google Fonts (last update: 23/10/2018).
5522
+ 'ABeeZee' => 'Google Fonts',
5523
+ 'Abel' => 'Google Fonts',
5524
+ 'Abhaya Libre' => 'Google Fonts',
5525
+ 'Abril Fatface' => 'Google Fonts',
5526
+ 'Aclonica' => 'Google Fonts',
5527
+ 'Acme' => 'Google Fonts',
5528
+ 'Actor' => 'Google Fonts',
5529
+ 'Adamina' => 'Google Fonts',
5530
+ 'Advent Pro' => 'Google Fonts',
5531
+ 'Aguafina Script' => 'Google Fonts',
5532
+ 'Akronim' => 'Google Fonts',
5533
+ 'Aladin' => 'Google Fonts',
5534
+ 'Aldrich' => 'Google Fonts',
5535
+ 'Alef' => 'Google Fonts',
5536
+ 'Alef Hebrew' => 'Google Fonts',
5537
+ // Hack for Google Early Access.
5538
+ 'Alegreya' => 'Google Fonts',
5539
+ 'Alegreya SC' => 'Google Fonts',
5540
+ 'Alegreya Sans' => 'Google Fonts',
5541
+ 'Alegreya Sans SC' => 'Google Fonts',
5542
+ 'Alex Brush' => 'Google Fonts',
5543
+ 'Alfa Slab One' => 'Google Fonts',
5544
+ 'Alice' => 'Google Fonts',
5545
+ 'Alike' => 'Google Fonts',
5546
+ 'Alike Angular' => 'Google Fonts',
5547
+ 'Allan' => 'Google Fonts',
5548
+ 'Allerta' => 'Google Fonts',
5549
+ 'Allerta Stencil' => 'Google Fonts',
5550
+ 'Allura' => 'Google Fonts',
5551
+ 'Almendra' => 'Google Fonts',
5552
+ 'Almendra Display' => 'Google Fonts',
5553
+ 'Almendra SC' => 'Google Fonts',
5554
+ 'Amarante' => 'Google Fonts',
5555
+ 'Amaranth' => 'Google Fonts',
5556
+ 'Amatic SC' => 'Google Fonts',
5557
+ 'Amethysta' => 'Google Fonts',
5558
+ 'Amiko' => 'Google Fonts',
5559
+ 'Amiri' => 'Google Fonts',
5560
+ 'Amita' => 'Google Fonts',
5561
+ 'Anaheim' => 'Google Fonts',
5562
+ 'Andada' => 'Google Fonts',
5563
+ 'Andika' => 'Google Fonts',
5564
+ 'Angkor' => 'Google Fonts',
5565
+ 'Annie Use Your Telescope' => 'Google Fonts',
5566
+ 'Anonymous Pro' => 'Google Fonts',
5567
+ 'Antic' => 'Google Fonts',
5568
+ 'Antic Didone' => 'Google Fonts',
5569
+ 'Antic Slab' => 'Google Fonts',
5570
+ 'Anton' => 'Google Fonts',
5571
+ 'Arapey' => 'Google Fonts',
5572
+ 'Arbutus' => 'Google Fonts',
5573
+ 'Arbutus Slab' => 'Google Fonts',
5574
+ 'Architects Daughter' => 'Google Fonts',
5575
+ 'Archivo' => 'Google Fonts',
5576
+ 'Archivo Black' => 'Google Fonts',
5577
+ 'Archivo Narrow' => 'Google Fonts',
5578
+ 'Aref Ruqaa' => 'Google Fonts',
5579
+ 'Arima Madurai' => 'Google Fonts',
5580
+ 'Arimo' => 'Google Fonts',
5581
+ 'Arizonia' => 'Google Fonts',
5582
+ 'Armata' => 'Google Fonts',
5583
+ 'Arsenal' => 'Google Fonts',
5584
+ 'Artifika' => 'Google Fonts',
5585
+ 'Arvo' => 'Google Fonts',
5586
+ 'Arya' => 'Google Fonts',
5587
+ 'Asap' => 'Google Fonts',
5588
+ 'Asap Condensed' => 'Google Fonts',
5589
+ 'Asar' => 'Google Fonts',
5590
+ 'Asset' => 'Google Fonts',
5591
+ 'Assistant' => 'Google Fonts',
5592
+ 'Astloch' => 'Google Fonts',
5593
+ 'Asul' => 'Google Fonts',
5594
+ 'Athiti' => 'Google Fonts',
5595
+ 'Atma' => 'Google Fonts',
5596
+ 'Atomic Age' => 'Google Fonts',
5597
+ 'Aubrey' => 'Google Fonts',
5598
+ 'Audiowide' => 'Google Fonts',
5599
+ 'Autour One' => 'Google Fonts',
5600
+ 'Average' => 'Google Fonts',
5601
+ 'Average Sans' => 'Google Fonts',
5602
+ 'Averia Gruesa Libre' => 'Google Fonts',
5603
+ 'Averia Libre' => 'Google Fonts',
5604
+ 'Averia Sans Libre' => 'Google Fonts',
5605
+ 'Averia Serif Libre' => 'Google Fonts',
5606
+ 'Bad Script' => 'Google Fonts',
5607
+ 'Bahiana' => 'Google Fonts',
5608
+ 'Bai Jamjuree' => 'Google Fonts',
5609
+ 'Baloo' => 'Google Fonts',
5610
+ 'Baloo Bhai' => 'Google Fonts',
5611
+ 'Baloo Bhaijaan' => 'Google Fonts',
5612
+ 'Baloo Bhaina' => 'Google Fonts',
5613
+ 'Baloo Chettan' => 'Google Fonts',
5614
+ 'Baloo Da' => 'Google Fonts',
5615
+ 'Baloo Paaji' => 'Google Fonts',
5616
+ 'Baloo Tamma' => 'Google Fonts',
5617
+ 'Baloo Tammudu' => 'Google Fonts',
5618
+ 'Baloo Thambi' => 'Google Fonts',
5619
+ 'Balthazar' => 'Google Fonts',
5620
+ 'Bangers' => 'Google Fonts',
5621
+ 'Barlow' => 'Google Fonts',
5622
+ 'Barlow Condensed' => 'Google Fonts',
5623
+ 'Barlow Semi Condensed' => 'Google Fonts',
5624
+ 'Barrio' => 'Google Fonts',
5625
+ 'Basic' => 'Google Fonts',
5626
+ 'Battambang' => 'Google Fonts',
5627
+ 'Baumans' => 'Google Fonts',
5628
+ 'Bayon' => 'Google Fonts',
5629
+ 'Belgrano' => 'Google Fonts',
5630
+ 'Bellefair' => 'Google Fonts',
5631
+ 'Belleza' => 'Google Fonts',
5632
+ 'BenchNine' => 'Google Fonts',
5633
+ 'Bentham' => 'Google Fonts',
5634
+ 'Berkshire Swash' => 'Google Fonts',
5635
+ 'Bevan' => 'Google Fonts',
5636
+ 'Bigelow Rules' => 'Google Fonts',
5637
+ 'Bigshot One' => 'Google Fonts',
5638
+ 'Bilbo' => 'Google Fonts',
5639
+ 'Bilbo Swash Caps' => 'Google Fonts',
5640
+ 'BioRhyme' => 'Google Fonts',
5641
+ 'BioRhyme Expanded' => 'Google Fonts',
5642
+ 'Biryani' => 'Google Fonts',
5643
+ 'Bitter' => 'Google Fonts',
5644
+ 'Black And White Picture' => 'Google Fonts',
5645
+ 'Black Han Sans' => 'Google Fonts',
5646
+ 'Black Ops One' => 'Google Fonts',
5647
+ 'Bokor' => 'Google Fonts',
5648
+ 'Bonbon' => 'Google Fonts',
5649
+ 'Boogaloo' => 'Google Fonts',
5650
+ 'Bowlby One' => 'Google Fonts',
5651
+ 'Bowlby One SC' => 'Google Fonts',
5652
+ 'Brawler' => 'Google Fonts',
5653
+ 'Bree Serif' => 'Google Fonts',
5654
+ 'Bubblegum Sans' => 'Google Fonts',
5655
+ 'Bubbler One' => 'Google Fonts',
5656
+ 'Buda' => 'Google Fonts',
5657
+ 'Buenard' => 'Google Fonts',
5658
+ 'Bungee' => 'Google Fonts',
5659
+ 'Bungee Hairline' => 'Google Fonts',
5660
+ 'Bungee Inline' => 'Google Fonts',
5661
+ 'Bungee Outline' => 'Google Fonts',
5662
+ 'Bungee Shade' => 'Google Fonts',
5663
+ 'Butcherman' => 'Google Fonts',
5664
+ 'Butterfly Kids' => 'Google Fonts',
5665
+ 'Cabin' => 'Google Fonts',
5666
+ 'Cabin Condensed' => 'Google Fonts',
5667
+ 'Cabin Sketch' => 'Google Fonts',
5668
+ 'Caesar Dressing' => 'Google Fonts',
5669
+ 'Cagliostro' => 'Google Fonts',
5670
+ 'Cairo' => 'Google Fonts',
5671
+ 'Calligraffitti' => 'Google Fonts',
5672
+ 'Cambay' => 'Google Fonts',
5673
+ 'Cambo' => 'Google Fonts',
5674
+ 'Candal' => 'Google Fonts',
5675
+ 'Cantarell' => 'Google Fonts',
5676
+ 'Cantata One' => 'Google Fonts',
5677
+ 'Cantora One' => 'Google Fonts',
5678
+ 'Capriola' => 'Google Fonts',
5679
+ 'Cardo' => 'Google Fonts',
5680
+ 'Carme' => 'Google Fonts',
5681
+ 'Carrois Gothic' => 'Google Fonts',
5682
+ 'Carrois Gothic SC' => 'Google Fonts',
5683
+ 'Carter One' => 'Google Fonts',
5684
+ 'Catamaran' => 'Google Fonts',
5685
+ 'Caudex' => 'Google Fonts',
5686
+ 'Caveat' => 'Google Fonts',
5687
+ 'Caveat Brush' => 'Google Fonts',
5688
+ 'Cedarville Cursive' => 'Google Fonts',
5689
+ 'Ceviche One' => 'Google Fonts',
5690
+ 'Chakra Petch' => 'Google Fonts',
5691
+ 'Changa' => 'Google Fonts',
5692
+ 'Changa One' => 'Google Fonts',
5693
+ 'Chango' => 'Google Fonts',
5694
+ 'Charmonman' => 'Google Fonts',
5695
+ 'Chathura' => 'Google Fonts',
5696
+ 'Chau Philomene One' => 'Google Fonts',
5697
+ 'Chela One' => 'Google Fonts',
5698
+ 'Chelsea Market' => 'Google Fonts',
5699
+ 'Chenla' => 'Google Fonts',
5700
+ 'Cherry Cream Soda' => 'Google Fonts',
5701
+ 'Cherry Swash' => 'Google Fonts',
5702
+ 'Chewy' => 'Google Fonts',
5703
+ 'Chicle' => 'Google Fonts',
5704
+ 'Chivo' => 'Google Fonts',
5705
+ 'Chonburi' => 'Google Fonts',
5706
+ 'Cinzel' => 'Google Fonts',
5707
+ 'Cinzel Decorative' => 'Google Fonts',
5708
+ 'Clicker Script' => 'Google Fonts',
5709
+ 'Coda' => 'Google Fonts',
5710
+ 'Coda Caption' => 'Google Fonts',
5711
+ 'Codystar' => 'Google Fonts',
5712
+ 'Coiny' => 'Google Fonts',
5713
+ 'Combo' => 'Google Fonts',
5714
+ 'Comfortaa' => 'Google Fonts',
5715
+ 'Coming Soon' => 'Google Fonts',
5716
+ 'Concert One' => 'Google Fonts',
5717
+ 'Condiment' => 'Google Fonts',
5718
+ 'Content' => 'Google Fonts',
5719
+ 'Contrail One' => 'Google Fonts',
5720
+ 'Convergence' => 'Google Fonts',
5721
+ 'Cookie' => 'Google Fonts',
5722
+ 'Copse' => 'Google Fonts',
5723
+ 'Corben' => 'Google Fonts',
5724
+ 'Cormorant' => 'Google Fonts',
5725
+ 'Cormorant Garamond' => 'Google Fonts',
5726
+ 'Cormorant Infant' => 'Google Fonts',
5727
+ 'Cormorant SC' => 'Google Fonts',
5728
+ 'Cormorant Unicase' => 'Google Fonts',
5729
+ 'Cormorant Upright' => 'Google Fonts',
5730
+ 'Courgette' => 'Google Fonts',
5731
+ 'Cousine' => 'Google Fonts',
5732
+ 'Coustard' => 'Google Fonts',
5733
+ 'Covered By Your Grace' => 'Google Fonts',
5734
+ 'Crafty Girls' => 'Google Fonts',
5735
+ 'Creepster' => 'Google Fonts',
5736
+ 'Crete Round' => 'Google Fonts',
5737
+ 'Crimson Text' => 'Google Fonts',
5738
+ 'Croissant One' => 'Google Fonts',
5739
+ 'Crushed' => 'Google Fonts',
5740
+ 'Cuprum' => 'Google Fonts',
5741
+ 'Cute Font' => 'Google Fonts',
5742
+ 'Cutive' => 'Google Fonts',
5743
+ 'Cutive Mono' => 'Google Fonts',
5744
+ 'Damion' => 'Google Fonts',
5745
+ 'Dancing Script' => 'Google Fonts',
5746
+ 'Dangrek' => 'Google Fonts',
5747
+ 'David Libre' => 'Google Fonts',
5748
+ 'Dawning of a New Day' => 'Google Fonts',
5749
+ 'Days One' => 'Google Fonts',
5750
+ 'Dekko' => 'Google Fonts',
5751
+ 'Delius' => 'Google Fonts',
5752
+ 'Delius Swash Caps' => 'Google Fonts',
5753
+ 'Delius Unicase' => 'Google Fonts',
5754
+ 'Della Respira' => 'Google Fonts',
5755
+ 'Denk One' => 'Google Fonts',
5756
+ 'Devonshire' => 'Google Fonts',
5757
+ 'Dhurjati' => 'Google Fonts',
5758
+ 'Didact Gothic' => 'Google Fonts',
5759
+ 'Diplomata' => 'Google Fonts',
5760
+ 'Diplomata SC' => 'Google Fonts',
5761
+ 'Do Hyeon' => 'Google Fonts',
5762
+ 'Dokdo' => 'Google Fonts',
5763
+ 'Domine' => 'Google Fonts',
5764
+ 'Donegal One' => 'Google Fonts',
5765
+ 'Doppio One' => 'Google Fonts',
5766
+ 'Dorsa' => 'Google Fonts',
5767
+ 'Dosis' => 'Google Fonts',
5768
+ 'Dr Sugiyama' => 'Google Fonts',
5769
+ 'Droid Arabic Kufi' => 'Google Fonts',
5770
+ // Hack for Google Early Access.
5771
+ 'Droid Arabic Naskh' => 'Google Fonts',
5772
+ // Hack for Google Early Access.
5773
+ 'Duru Sans' => 'Google Fonts',
5774
+ 'Dynalight' => 'Google Fonts',
5775
+ 'EB Garamond' => 'Google Fonts',
5776
+ 'Eagle Lake' => 'Google Fonts',
5777
+ 'East Sea Dokdo' => 'Google Fonts',
5778
+ 'Eater' => 'Google Fonts',
5779
+ 'Economica' => 'Google Fonts',
5780
+ 'Eczar' => 'Google Fonts',
5781
+ 'El Messiri' => 'Google Fonts',
5782
+ 'Electrolize' => 'Google Fonts',
5783
+ 'Elsie' => 'Google Fonts',
5784
+ 'Elsie Swash Caps' => 'Google Fonts',
5785
+ 'Emblema One' => 'Google Fonts',
5786
+ 'Emilys Candy' => 'Google Fonts',
5787
+ 'Encode Sans' => 'Google Fonts',
5788
+ 'Encode Sans Condensed' => 'Google Fonts',
5789
+ 'Encode Sans Expanded' => 'Google Fonts',
5790
+ 'Encode Sans Semi Condensed' => 'Google Fonts',
5791
+ 'Encode Sans Semi Expanded' => 'Google Fonts',
5792
+ 'Engagement' => 'Google Fonts',
5793
+ 'Englebert' => 'Google Fonts',
5794
+ 'Enriqueta' => 'Google Fonts',
5795
+ 'Erica One' => 'Google Fonts',
5796
+ 'Esteban' => 'Google Fonts',
5797
+ 'Euphoria Script' => 'Google Fonts',
5798
+ 'Ewert' => 'Google Fonts',
5799
+ 'Exo' => 'Google Fonts',
5800
+ 'Exo 2' => 'Google Fonts',
5801
+ 'Expletus Sans' => 'Google Fonts',
5802
+ 'Fahkwang' => 'Google Fonts',
5803
+ 'Fanwood Text' => 'Google Fonts',
5804
+ 'Farsan' => 'Google Fonts',
5805
+ 'Fascinate' => 'Google Fonts',
5806
+ 'Fascinate Inline' => 'Google Fonts',
5807
+ 'Faster One' => 'Google Fonts',
5808
+ 'Fasthand' => 'Google Fonts',
5809
+ 'Fauna One' => 'Google Fonts',
5810
+ 'Faustina' => 'Google Fonts',
5811
+ 'Federant' => 'Google Fonts',
5812
+ 'Federo' => 'Google Fonts',
5813
+ 'Felipa' => 'Google Fonts',
5814
+ 'Fenix' => 'Google Fonts',
5815
+ 'Finger Paint' => 'Google Fonts',
5816
+ 'Fira Mono' => 'Google Fonts',
5817
+ 'Fira Sans' => 'Google Fonts',
5818
+ 'Fira Sans Condensed' => 'Google Fonts',
5819
+ 'Fira Sans Extra Condensed' => 'Google Fonts',
5820
+ 'Fjalla One' => 'Google Fonts',
5821
+ 'Fjord One' => 'Google Fonts',
5822
+ 'Flamenco' => 'Google Fonts',
5823
+ 'Flavors' => 'Google Fonts',
5824
+ 'Fondamento' => 'Google Fonts',
5825
+ 'Fontdiner Swanky' => 'Google Fonts',
5826
+ 'Forum' => 'Google Fonts',
5827
+ 'Francois One' => 'Google Fonts',
5828
+ 'Frank Ruhl Libre' => 'Google Fonts',
5829
+ 'Freckle Face' => 'Google Fonts',
5830
+ 'Fredericka the Great' => 'Google Fonts',
5831
+ 'Fredoka One' => 'Google Fonts',
5832
+ 'Freehand' => 'Google Fonts',
5833
+ 'Fresca' => 'Google Fonts',
5834
+ 'Frijole' => 'Google Fonts',
5835
+ 'Fruktur' => 'Google Fonts',
5836
+ 'Fugaz One' => 'Google Fonts',
5837
+ 'GFS Didot' => 'Google Fonts',
5838
+ 'GFS Neohellenic' => 'Google Fonts',
5839
+ 'Gabriela' => 'Google Fonts',
5840
+ 'Gaegu' => 'Google Fonts',
5841
+ 'Gafata' => 'Google Fonts',
5842
+ 'Galada' => 'Google Fonts',
5843
+ 'Galdeano' => 'Google Fonts',
5844
+ 'Galindo' => 'Google Fonts',
5845
+ 'Gamja Flower' => 'Google Fonts',
5846
+ 'Gentium Basic' => 'Google Fonts',
5847
+ 'Gentium Book Basic' => 'Google Fonts',
5848
+ 'Geo' => 'Google Fonts',
5849
+ 'Geostar' => 'Google Fonts',
5850
+ 'Geostar Fill' => 'Google Fonts',
5851
+ 'Germania One' => 'Google Fonts',
5852
+ 'Gidugu' => 'Google Fonts',
5853
+ 'Gilda Display' => 'Google Fonts',
5854
+ 'Give You Glory' => 'Google Fonts',
5855
+ 'Glass Antiqua' => 'Google Fonts',
5856
+ 'Glegoo' => 'Google Fonts',
5857
+ 'Gloria Hallelujah' => 'Google Fonts',
5858
+ 'Goblin One' => 'Google Fonts',
5859
+ 'Gochi Hand' => 'Google Fonts',
5860
+ 'Gorditas' => 'Google Fonts',
5861
+ 'Gothic A1' => 'Google Fonts',
5862
+ 'Goudy Bookletter 1911' => 'Google Fonts',
5863
+ 'Graduate' => 'Google Fonts',
5864
+ 'Grand Hotel' => 'Google Fonts',
5865
+ 'Gravitas One' => 'Google Fonts',
5866
+ 'Great Vibes' => 'Google Fonts',
5867
+ 'Griffy' => 'Google Fonts',
5868
+ 'Gruppo' => 'Google Fonts',
5869
+ 'Gudea' => 'Google Fonts',
5870
+ 'Gugi' => 'Google Fonts',
5871
+ 'Gurajada' => 'Google Fonts',
5872
+ 'Habibi' => 'Google Fonts',
5873
+ 'Halant' => 'Google Fonts',
5874
+ 'Hammersmith One' => 'Google Fonts',
5875
+ 'Hanalei' => 'Google Fonts',
5876
+ 'Hanalei Fill' => 'Google Fonts',
5877
+ 'Handlee' => 'Google Fonts',
5878
+ 'Hanuman' => 'Google Fonts',
5879
+ 'Happy Monkey' => 'Google Fonts',
5880
+ 'Harmattan' => 'Google Fonts',
5881
+ 'Headland One' => 'Google Fonts',
5882
+ 'Heebo' => 'Google Fonts',
5883
+ 'Henny Penny' => 'Google Fonts',
5884
+ 'Herr Von Muellerhoff' => 'Google Fonts',
5885
+ 'Hi Melody' => 'Google Fonts',
5886
+ 'Hind' => 'Google Fonts',
5887
+ 'Hind Guntur' => 'Google Fonts',
5888
+ 'Hind Madurai' => 'Google Fonts',
5889
+ 'Hind Siliguri' => 'Google Fonts',
5890
+ 'Hind Vadodara' => 'Google Fonts',
5891
+ 'Holtwood One SC' => 'Google Fonts',
5892
+ 'Homemade Apple' => 'Google Fonts',
5893
+ 'Homenaje' => 'Google Fonts',
5894
+ 'IBM Plex Mono' => 'Google Fonts',
5895
+ 'IBM Plex Sans' => 'Google Fonts',
5896
+ 'IBM Plex Sans Condensed' => 'Google Fonts',
5897
+ 'IBM Plex Serif' => 'Google Fonts',
5898
+ 'IM Fell DW Pica' => 'Google Fonts',
5899
+ 'IM Fell DW Pica SC' => 'Google Fonts',
5900
+ 'IM Fell Double Pica' => 'Google Fonts',
5901
+ 'IM Fell Double Pica SC' => 'Google Fonts',
5902
+ 'IM Fell English' => 'Google Fonts',
5903
+ 'IM Fell English SC' => 'Google Fonts',
5904
+ 'IM Fell French Canon' => 'Google Fonts',
5905
+ 'IM Fell French Canon SC' => 'Google Fonts',
5906
+ 'IM Fell Great Primer' => 'Google Fonts',
5907
+ 'IM Fell Great Primer SC' => 'Google Fonts',
5908
+ 'Iceberg' => 'Google Fonts',
5909
+ 'Iceland' => 'Google Fonts',
5910
+ 'Imprima' => 'Google Fonts',
5911
+ 'Inconsolata' => 'Google Fonts',
5912
+ 'Inder' => 'Google Fonts',
5913
+ 'Indie Flower' => 'Google Fonts',
5914
+ 'Inika' => 'Google Fonts',
5915
+ 'Inknut Antiqua' => 'Google Fonts',
5916
+ 'Irish Grover' => 'Google Fonts',
5917
+ 'Istok Web' => 'Google Fonts',
5918
+ 'Italiana' => 'Google Fonts',
5919
+ 'Italianno' => 'Google Fonts',
5920
+ 'Itim' => 'Google Fonts',
5921
+ 'Jacques Francois' => 'Google Fonts',
5922
+ 'Jacques Francois Shadow' => 'Google Fonts',
5923
+ 'Jaldi' => 'Google Fonts',
5924
+ 'Jim Nightshade' => 'Google Fonts',
5925
+ 'Jockey One' => 'Google Fonts',
5926
+ 'Jolly Lodger' => 'Google Fonts',
5927
+ 'Jomhuria' => 'Google Fonts',
5928
+ 'Josefin Sans' => 'Google Fonts',
5929
+ 'Josefin Slab' => 'Google Fonts',
5930
+ 'Joti One' => 'Google Fonts',
5931
+ 'Jua' => 'Google Fonts',
5932
+ 'Judson' => 'Google Fonts',
5933
+ 'Julee' => 'Google Fonts',
5934
+ 'Julius Sans One' => 'Google Fonts',
5935
+ 'Junge' => 'Google Fonts',
5936
+ 'Jura' => 'Google Fonts',
5937
+ 'Just Another Hand' => 'Google Fonts',
5938
+ 'Just Me Again Down Here' => 'Google Fonts',
5939
+ 'K2D' => 'Google Fonts',
5940
+ 'Kadwa' => 'Google Fonts',
5941
+ 'Kalam' => 'Google Fonts',
5942
+ 'Kameron' => 'Google Fonts',
5943
+ 'Kanit' => 'Google Fonts',
5944
+ 'Kantumruy' => 'Google Fonts',
5945
+ 'Karla' => 'Google Fonts',
5946
+ 'Karma' => 'Google Fonts',
5947
+ 'Katibeh' => 'Google Fonts',
5948
+ 'Kaushan Script' => 'Google Fonts',
5949
+ 'Kavivanar' => 'Google Fonts',
5950
+ 'Kavoon' => 'Google Fonts',
5951
+ 'Kdam Thmor' => 'Google Fonts',
5952
+ 'Keania One' => 'Google Fonts',
5953
+ 'Kelly Slab' => 'Google Fonts',
5954
+ 'Kenia' => 'Google Fonts',
5955
+ 'Khand' => 'Google Fonts',
5956
+ 'Khmer' => 'Google Fonts',
5957
+ 'Khula' => 'Google Fonts',
5958
+ 'Kirang Haerang' => 'Google Fonts',
5959
+ 'Kite One' => 'Google Fonts',
5960
+ 'Knewave' => 'Google Fonts',
5961
+ 'KoHo' => 'Google Fonts',
5962
+ 'Kodchasan' => 'Google Fonts',
5963
+ 'Kosugi' => 'Google Fonts',
5964
+ 'Kosugi Maru' => 'Google Fonts',
5965
+ 'Kotta One' => 'Google Fonts',
5966
+ 'Koulen' => 'Google Fonts',
5967
+ 'Kranky' => 'Google Fonts',
5968
+ 'Kreon' => 'Google Fonts',
5969
+ 'Kristi' => 'Google Fonts',
5970
+ 'Krona One' => 'Google Fonts',
5971
+ 'Krub' => 'Google Fonts',
5972
+ 'Kumar One' => 'Google Fonts',
5973
+ 'Kumar One Outline' => 'Google Fonts',
5974
+ 'Kurale' => 'Google Fonts',
5975
+ 'La Belle Aurore' => 'Google Fonts',
5976
+ 'Laila' => 'Google Fonts',
5977
+ 'Lakki Reddy' => 'Google Fonts',
5978
+ 'Lalezar' => 'Google Fonts',
5979
+ 'Lancelot' => 'Google Fonts',
5980
+ 'Lateef' => 'Google Fonts',
5981
+ 'Lato' => 'Google Fonts',
5982
+ 'League Script' => 'Google Fonts',
5983
+ 'Leckerli One' => 'Google Fonts',
5984
+ 'Ledger' => 'Google Fonts',
5985
+ 'Lekton' => 'Google Fonts',
5986
+ 'Lemon' => 'Google Fonts',
5987
+ 'Lemonada' => 'Google Fonts',
5988
+ 'Libre Barcode 128' => 'Google Fonts',
5989
+ 'Libre Barcode 128 Text' => 'Google Fonts',
5990
+ 'Libre Barcode 39' => 'Google Fonts',
5991
+ 'Libre Barcode 39 Extended' => 'Google Fonts',
5992
  'Libre Barcode 39 Extended Text' => 'Google Fonts',
5993
+ 'Libre Barcode 39 Text' => 'Google Fonts',
5994
+ 'Libre Baskerville' => 'Google Fonts',
5995
+ 'Libre Franklin' => 'Google Fonts',
5996
+ 'Life Savers' => 'Google Fonts',
5997
+ 'Lilita One' => 'Google Fonts',
5998
+ 'Lily Script One' => 'Google Fonts',
5999
+ 'Limelight' => 'Google Fonts',
6000
+ 'Linden Hill' => 'Google Fonts',
6001
+ 'Lobster' => 'Google Fonts',
6002
+ 'Lobster Two' => 'Google Fonts',
6003
+ 'Londrina Outline' => 'Google Fonts',
6004
+ 'Londrina Shadow' => 'Google Fonts',
6005
+ 'Londrina Sketch' => 'Google Fonts',
6006
+ 'Londrina Solid' => 'Google Fonts',
6007
+ 'Lora' => 'Google Fonts',
6008
+ 'Love Ya Like A Sister' => 'Google Fonts',
6009
+ 'Loved by the King' => 'Google Fonts',
6010
+ 'Lovers Quarrel' => 'Google Fonts',
6011
+ 'Luckiest Guy' => 'Google Fonts',
6012
+ 'Lusitana' => 'Google Fonts',
6013
+ 'Lustria' => 'Google Fonts',
6014
+ 'M PLUS 1p' => 'Google Fonts',
6015
+ 'M PLUS Rounded 1c' => 'Google Fonts',
6016
+ 'Macondo' => 'Google Fonts',
6017
+ 'Macondo Swash Caps' => 'Google Fonts',
6018
+ 'Mada' => 'Google Fonts',
6019
+ 'Magra' => 'Google Fonts',
6020
+ 'Maiden Orange' => 'Google Fonts',
6021
+ 'Maitree' => 'Google Fonts',
6022
+ 'Mako' => 'Google Fonts',
6023
+ 'Mali' => 'Google Fonts',
6024
+ 'Mallanna' => 'Google Fonts',
6025
+ 'Mandali' => 'Google Fonts',
6026
+ 'Manuale' => 'Google Fonts',
6027
+ 'Marcellus' => 'Google Fonts',
6028
+ 'Marcellus SC' => 'Google Fonts',
6029
+ 'Marck Script' => 'Google Fonts',
6030
+ 'Margarine' => 'Google Fonts',
6031
+ 'Markazi Text' => 'Google Fonts',
6032
+ 'Marko One' => 'Google Fonts',
6033
+ 'Marmelad' => 'Google Fonts',
6034
+ 'Martel' => 'Google Fonts',
6035
+ 'Martel Sans' => 'Google Fonts',
6036
+ 'Marvel' => 'Google Fonts',
6037
+ 'Mate' => 'Google Fonts',
6038
+ 'Mate SC' => 'Google Fonts',
6039
+ 'Maven Pro' => 'Google Fonts',
6040
+ 'McLaren' => 'Google Fonts',
6041
+ 'Meddon' => 'Google Fonts',
6042
+ 'MedievalSharp' => 'Google Fonts',
6043
+ 'Medula One' => 'Google Fonts',
6044
+ 'Meera Inimai' => 'Google Fonts',
6045
+ 'Megrim' => 'Google Fonts',
6046
+ 'Meie Script' => 'Google Fonts',
6047
+ 'Merienda' => 'Google Fonts',
6048
+ 'Merienda One' => 'Google Fonts',
6049
+ 'Merriweather' => 'Google Fonts',
6050
+ 'Merriweather Sans' => 'Google Fonts',
6051
+ 'Metal' => 'Google Fonts',
6052
+ 'Metal Mania' => 'Google Fonts',
6053
+ 'Metamorphous' => 'Google Fonts',
6054
+ 'Metrophobic' => 'Google Fonts',
6055
+ 'Michroma' => 'Google Fonts',
6056
+ 'Milonga' => 'Google Fonts',
6057
+ 'Miltonian' => 'Google Fonts',
6058
+ 'Miltonian Tattoo' => 'Google Fonts',
6059
+ 'Mina' => 'Google Fonts',
6060
+ 'Miniver' => 'Google Fonts',
6061
+ 'Miriam Libre' => 'Google Fonts',
6062
+ 'Mirza' => 'Google Fonts',
6063
+ 'Miss Fajardose' => 'Google Fonts',
6064
+ 'Mitr' => 'Google Fonts',
6065
+ 'Modak' => 'Google Fonts',
6066
+ 'Modern Antiqua' => 'Google Fonts',
6067
+ 'Mogra' => 'Google Fonts',
6068
+ 'Molengo' => 'Google Fonts',
6069
+ 'Molle' => 'Google Fonts',
6070
+ 'Monda' => 'Google Fonts',
6071
+ 'Monofett' => 'Google Fonts',
6072
+ 'Monoton' => 'Google Fonts',
6073
+ 'Monsieur La Doulaise' => 'Google Fonts',
6074
+ 'Montaga' => 'Google Fonts',
6075
+ 'Montez' => 'Google Fonts',
6076
+ 'Montserrat' => 'Google Fonts',
6077
+ 'Montserrat Alternates' => 'Google Fonts',
6078
+ 'Montserrat Subrayada' => 'Google Fonts',
6079
+ 'Moul' => 'Google Fonts',
6080
+ 'Moulpali' => 'Google Fonts',
6081
+ 'Mountains of Christmas' => 'Google Fonts',
6082
+ 'Mouse Memoirs' => 'Google Fonts',
6083
+ 'Mr Bedfort' => 'Google Fonts',
6084
+ 'Mr Dafoe' => 'Google Fonts',
6085
+ 'Mr De Haviland' => 'Google Fonts',
6086
+ 'Mrs Saint Delafield' => 'Google Fonts',
6087
+ 'Mrs Sheppards' => 'Google Fonts',
6088
+ 'Mukta' => 'Google Fonts',
6089
+ 'Mukta Mahee' => 'Google Fonts',
6090
+ 'Mukta Malar' => 'Google Fonts',
6091
+ 'Mukta Vaani' => 'Google Fonts',
6092
+ 'Muli' => 'Google Fonts',
6093
+ 'Mystery Quest' => 'Google Fonts',
6094
+ 'NTR' => 'Google Fonts',
6095
+ 'Nanum Brush Script' => 'Google Fonts',
6096
+ 'Nanum Gothic' => 'Google Fonts',
6097
+ 'Nanum Gothic Coding' => 'Google Fonts',
6098
+ 'Nanum Myeongjo' => 'Google Fonts',
6099
+ 'Nanum Pen Script' => 'Google Fonts',
6100
+ 'Neucha' => 'Google Fonts',
6101
+ 'Neuton' => 'Google Fonts',
6102
+ 'New Rocker' => 'Google Fonts',
6103
+ 'News Cycle' => 'Google Fonts',
6104
+ 'Niconne' => 'Google Fonts',
6105
+ 'Niramit' => 'Google Fonts',
6106
+ 'Nixie One' => 'Google Fonts',
6107
+ 'Nobile' => 'Google Fonts',
6108
+ 'Nokora' => 'Google Fonts',
6109
+ 'Norican' => 'Google Fonts',
6110
+ 'Nosifer' => 'Google Fonts',
6111
+ 'Notable' => 'Google Fonts',
6112
+ 'Nothing You Could Do' => 'Google Fonts',
6113
+ 'Noticia Text' => 'Google Fonts',
6114
+ 'Noto Kufi Arabic' => 'Google Fonts',
6115
+ // Hack for Google Early Access.
6116
+ 'Noto Naskh Arabic' => 'Google Fonts',
6117
+ // Hack for Google Early Access.
6118
+ 'Noto Sans' => 'Google Fonts',
6119
+ 'Noto Sans Hebrew' => 'Google Fonts',
6120
+ // Hack for Google Early Access.
6121
+ 'Noto Sans JP' => 'Google Fonts',
6122
+ 'Noto Sans KR' => 'Google Fonts',
6123
+ 'Noto Serif' => 'Google Fonts',
6124
+ 'Noto Serif JP' => 'Google Fonts',
6125
+ 'Noto Serif KR' => 'Google Fonts',
6126
+ 'Nova Cut' => 'Google Fonts',
6127
+ 'Nova Flat' => 'Google Fonts',
6128
+ 'Nova Mono' => 'Google Fonts',
6129
+ 'Nova Oval' => 'Google Fonts',
6130
+ 'Nova Round' => 'Google Fonts',
6131
+ 'Nova Script' => 'Google Fonts',
6132
+ 'Nova Slim' => 'Google Fonts',
6133
+ 'Nova Square' => 'Google Fonts',
6134
+ 'Numans' => 'Google Fonts',
6135
+ 'Nunito' => 'Google Fonts',
6136
+ 'Nunito Sans' => 'Google Fonts',
6137
+ 'Odor Mean Chey' => 'Google Fonts',
6138
+ 'Offside' => 'Google Fonts',
6139
+ 'Old Standard TT' => 'Google Fonts',
6140
+ 'Oldenburg' => 'Google Fonts',
6141
+ 'Oleo Script' => 'Google Fonts',
6142
+ 'Oleo Script Swash Caps' => 'Google Fonts',
6143
+ 'Open Sans' => 'Google Fonts',
6144
+ 'Open Sans Condensed' => 'Google Fonts',
6145
+ 'Open Sans Hebrew' => 'Google Fonts',
6146
+ // Hack for Google Early Access.
6147
+ 'Open Sans Hebrew Condensed' => 'Google Fonts',
6148
+ // Hack for Google Early Access.
6149
+ 'Oranienbaum' => 'Google Fonts',
6150
+ 'Orbitron' => 'Google Fonts',
6151
+ 'Oregano' => 'Google Fonts',
6152
+ 'Orienta' => 'Google Fonts',
6153
+ 'Original Surfer' => 'Google Fonts',
6154
+ 'Oswald' => 'Google Fonts',
6155
+ 'Over the Rainbow' => 'Google Fonts',
6156
+ 'Overlock' => 'Google Fonts',
6157
+ 'Overlock SC' => 'Google Fonts',
6158
+ 'Overpass' => 'Google Fonts',
6159
+ 'Overpass Mono' => 'Google Fonts',
6160
+ 'Ovo' => 'Google Fonts',
6161
+ 'Oxygen' => 'Google Fonts',
6162
+ 'Oxygen Mono' => 'Google Fonts',
6163
+ 'PT Mono' => 'Google Fonts',
6164
+ 'PT Sans' => 'Google Fonts',
6165
+ 'PT Sans Caption' => 'Google Fonts',
6166
+ 'PT Sans Narrow' => 'Google Fonts',
6167
+ 'PT Serif' => 'Google Fonts',
6168
+ 'PT Serif Caption' => 'Google Fonts',
6169
+ 'Pacifico' => 'Google Fonts',
6170
+ 'Padauk' => 'Google Fonts',
6171
+ 'Palanquin' => 'Google Fonts',
6172
+ 'Palanquin Dark' => 'Google Fonts',
6173
+ 'Pangolin' => 'Google Fonts',
6174
+ 'Paprika' => 'Google Fonts',
6175
+ 'Parisienne' => 'Google Fonts',
6176
+ 'Passero One' => 'Google Fonts',
6177
+ 'Passion One' => 'Google Fonts',
6178
+ 'Pathway Gothic One' => 'Google Fonts',
6179
+ 'Patrick Hand' => 'Google Fonts',
6180
+ 'Patrick Hand SC' => 'Google Fonts',
6181
+ 'Pattaya' => 'Google Fonts',
6182
+ 'Patua One' => 'Google Fonts',
6183
+ 'Pavanam' => 'Google Fonts',
6184
+ 'Paytone One' => 'Google Fonts',
6185
+ 'Peddana' => 'Google Fonts',
6186
+ 'Peralta' => 'Google Fonts',
6187
+ 'Permanent Marker' => 'Google Fonts',
6188
+ 'Petit Formal Script' => 'Google Fonts',
6189
+ 'Petrona' => 'Google Fonts',
6190
+ 'Philosopher' => 'Google Fonts',
6191
+ 'Piedra' => 'Google Fonts',
6192
+ 'Pinyon Script' => 'Google Fonts',
6193
+ 'Pirata One' => 'Google Fonts',
6194
+ 'Plaster' => 'Google Fonts',
6195
+ 'Play' => 'Google Fonts',
6196
+ 'Playball' => 'Google Fonts',
6197
+ 'Playfair Display' => 'Google Fonts',
6198
+ 'Playfair Display SC' => 'Google Fonts',
6199
+ 'Podkova' => 'Google Fonts',
6200
+ 'Poiret One' => 'Google Fonts',
6201
+ 'Poller One' => 'Google Fonts',
6202
+ 'Poly' => 'Google Fonts',
6203
+ 'Pompiere' => 'Google Fonts',
6204
+ 'Pontano Sans' => 'Google Fonts',
6205
+ 'Poor Story' => 'Google Fonts',
6206
+ 'Poppins' => 'Google Fonts',
6207
+ 'Port Lligat Sans' => 'Google Fonts',
6208
+ 'Port Lligat Slab' => 'Google Fonts',
6209
+ 'Pragati Narrow' => 'Google Fonts',
6210
+ 'Prata' => 'Google Fonts',
6211
+ 'Preahvihear' => 'Google Fonts',
6212
+ 'Press Start 2P' => 'Google Fonts',
6213
+ 'Pridi' => 'Google Fonts',
6214
+ 'Princess Sofia' => 'Google Fonts',
6215
+ 'Prociono' => 'Google Fonts',
6216
+ 'Prompt' => 'Google Fonts',
6217
+ 'Prosto One' => 'Google Fonts',
6218
+ 'Proza Libre' => 'Google Fonts',
6219
+ 'Puritan' => 'Google Fonts',
6220
+ 'Purple Purse' => 'Google Fonts',
6221
+ 'Quando' => 'Google Fonts',
6222
+ 'Quantico' => 'Google Fonts',
6223
+ 'Quattrocento' => 'Google Fonts',
6224
+ 'Quattrocento Sans' => 'Google Fonts',
6225
+ 'Questrial' => 'Google Fonts',
6226
+ 'Quicksand' => 'Google Fonts',
6227
+ 'Quintessential' => 'Google Fonts',
6228
+ 'Qwigley' => 'Google Fonts',
6229
+ 'Racing Sans One' => 'Google Fonts',
6230
+ 'Radley' => 'Google Fonts',
6231
+ 'Rajdhani' => 'Google Fonts',
6232
+ 'Rakkas' => 'Google Fonts',
6233
+ 'Raleway' => 'Google Fonts',
6234
+ 'Raleway Dots' => 'Google Fonts',
6235
+ 'Ramabhadra' => 'Google Fonts',
6236
+ 'Ramaraja' => 'Google Fonts',
6237
+ 'Rambla' => 'Google Fonts',
6238
+ 'Rammetto One' => 'Google Fonts',
6239
+ 'Ranchers' => 'Google Fonts',
6240
+ 'Rancho' => 'Google Fonts',
6241
+ 'Ranga' => 'Google Fonts',
6242
+ 'Rasa' => 'Google Fonts',
6243
+ 'Rationale' => 'Google Fonts',
6244
+ 'Ravi Prakash' => 'Google Fonts',
6245
+ 'Redressed' => 'Google Fonts',
6246
+ 'Reem Kufi' => 'Google Fonts',
6247
+ 'Reenie Beanie' => 'Google Fonts',
6248
+ 'Revalia' => 'Google Fonts',
6249
+ 'Rhodium Libre' => 'Google Fonts',
6250
+ 'Ribeye' => 'Google Fonts',
6251
+ 'Ribeye Marrow' => 'Google Fonts',
6252
+ 'Righteous' => 'Google Fonts',
6253
+ 'Risque' => 'Google Fonts',
6254
+ 'Roboto' => 'Google Fonts',
6255
+ 'Roboto Condensed' => 'Google Fonts',
6256
+ 'Roboto Mono' => 'Google Fonts',
6257
+ 'Roboto Slab' => 'Google Fonts',
6258
+ 'Rochester' => 'Google Fonts',
6259
+ 'Rock Salt' => 'Google Fonts',
6260
+ 'Rokkitt' => 'Google Fonts',
6261
+ 'Romanesco' => 'Google Fonts',
6262
+ 'Ropa Sans' => 'Google Fonts',
6263
+ 'Rosario' => 'Google Fonts',
6264
+ 'Rosarivo' => 'Google Fonts',
6265
+ 'Rouge Script' => 'Google Fonts',
6266
+ 'Rozha One' => 'Google Fonts',
6267
+ 'Rubik' => 'Google Fonts',
6268
+ 'Rubik Mono One' => 'Google Fonts',
6269
+ 'Ruda' => 'Google Fonts',
6270
+ 'Rufina' => 'Google Fonts',
6271
+ 'Ruge Boogie' => 'Google Fonts',
6272
+ 'Ruluko' => 'Google Fonts',
6273
+ 'Rum Raisin' => 'Google Fonts',
6274
+ 'Ruslan Display' => 'Google Fonts',
6275
+ 'Russo One' => 'Google Fonts',
6276
+ 'Ruthie' => 'Google Fonts',
6277
+ 'Rye' => 'Google Fonts',
6278
+ 'Sacramento' => 'Google Fonts',
6279
+ 'Sahitya' => 'Google Fonts',
6280
+ 'Sail' => 'Google Fonts',
6281
+ 'Saira' => 'Google Fonts',
6282
+ 'Saira Condensed' => 'Google Fonts',
6283
+ 'Saira Extra Condensed' => 'Google Fonts',
6284
+ 'Saira Semi Condensed' => 'Google Fonts',
6285
+ 'Salsa' => 'Google Fonts',
6286
+ 'Sanchez' => 'Google Fonts',
6287
+ 'Sancreek' => 'Google Fonts',
6288
+ 'Sansita' => 'Google Fonts',
6289
+ 'Sarala' => 'Google Fonts',
6290
+ 'Sarina' => 'Google Fonts',
6291
+ 'Sarpanch' => 'Google Fonts',
6292
+ 'Satisfy' => 'Google Fonts',
6293
+ 'Sawarabi Gothic' => 'Google Fonts',
6294
+ 'Sawarabi Mincho' => 'Google Fonts',
6295
+ 'Scada' => 'Google Fonts',
6296
+ 'Scheherazade' => 'Google Fonts',
6297
+ 'Schoolbell' => 'Google Fonts',
6298
+ 'Scope One' => 'Google Fonts',
6299
+ 'Seaweed Script' => 'Google Fonts',
6300
+ 'Secular One' => 'Google Fonts',
6301
+ 'Sedgwick Ave' => 'Google Fonts',
6302
+ 'Sedgwick Ave Display' => 'Google Fonts',
6303
+ 'Sevillana' => 'Google Fonts',
6304
+ 'Seymour One' => 'Google Fonts',
6305
+ 'Shadows Into Light' => 'Google Fonts',
6306
+ 'Shadows Into Light Two' => 'Google Fonts',
6307
+ 'Shanti' => 'Google Fonts',
6308
+ 'Share' => 'Google Fonts',
6309
+ 'Share Tech' => 'Google Fonts',
6310
+ 'Share Tech Mono' => 'Google Fonts',
6311
+ 'Shojumaru' => 'Google Fonts',
6312
+ 'Short Stack' => 'Google Fonts',
6313
+ 'Shrikhand' => 'Google Fonts',
6314
+ 'Siemreap' => 'Google Fonts',
6315
+ 'Sigmar One' => 'Google Fonts',
6316
+ 'Signika' => 'Google Fonts',
6317
+ 'Signika Negative' => 'Google Fonts',
6318
+ 'Simonetta' => 'Google Fonts',
6319
+ 'Sintony' => 'Google Fonts',
6320
+ 'Sirin Stencil' => 'Google Fonts',
6321
+ 'Six Caps' => 'Google Fonts',
6322
+ 'Skranji' => 'Google Fonts',
6323
+ 'Slabo 13px' => 'Google Fonts',
6324
+ 'Slabo 27px' => 'Google Fonts',
6325
+ 'Slackey' => 'Google Fonts',
6326
+ 'Smokum' => 'Google Fonts',
6327
+ 'Smythe' => 'Google Fonts',
6328
+ 'Sniglet' => 'Google Fonts',
6329
+ 'Snippet' => 'Google Fonts',
6330
+ 'Snowburst One' => 'Google Fonts',
6331
+ 'Sofadi One' => 'Google Fonts',
6332
+ 'Sofia' => 'Google Fonts',
6333
+ 'Song Myung' => 'Google Fonts',
6334
+ 'Sonsie One' => 'Google Fonts',
6335
+ 'Sorts Mill Goudy' => 'Google Fonts',
6336
+ 'Source Code Pro' => 'Google Fonts',
6337
+ 'Source Sans Pro' => 'Google Fonts',
6338
+ 'Source Serif Pro' => 'Google Fonts',
6339
+ 'Space Mono' => 'Google Fonts',
6340
+ 'Special Elite' => 'Google Fonts',
6341
+ 'Spectral' => 'Google Fonts',
6342
+ 'Spectral SC' => 'Google Fonts',
6343
+ 'Spicy Rice' => 'Google Fonts',
6344
+ 'Spinnaker' => 'Google Fonts',
6345
+ 'Spirax' => 'Google Fonts',
6346
+ 'Squada One' => 'Google Fonts',
6347
+ 'Sree Krushnadevaraya' => 'Google Fonts',
6348
+ 'Sriracha' => 'Google Fonts',
6349
+ 'Srisakdi' => 'Google Fonts',
6350
+ 'Stalemate' => 'Google Fonts',
6351
+ 'Stalinist One' => 'Google Fonts',
6352
+ 'Stardos Stencil' => 'Google Fonts',
6353
+ 'Stint Ultra Condensed' => 'Google Fonts',
6354
+ 'Stint Ultra Expanded' => 'Google Fonts',
6355
+ 'Stoke' => 'Google Fonts',
6356
+ 'Strait' => 'Google Fonts',
6357
+ 'Stylish' => 'Google Fonts',
6358
+ 'Sue Ellen Francisco' => 'Google Fonts',
6359
+ 'Suez One' => 'Google Fonts',
6360
+ 'Sumana' => 'Google Fonts',
6361
+ 'Sunflower' => 'Google Fonts',
6362
+ 'Sunshiney' => 'Google Fonts',
6363
+ 'Supermercado One' => 'Google Fonts',
6364
+ 'Sura' => 'Google Fonts',
6365
+ 'Suranna' => 'Google Fonts',
6366
+ 'Suravaram' => 'Google Fonts',
6367
+ 'Suwannaphum' => 'Google Fonts',
6368
+ 'Swanky and Moo Moo' => 'Google Fonts',
6369
+ 'Syncopate' => 'Google Fonts',
6370
+ 'Tajawal' => 'Google Fonts',
6371
+ 'Tangerine' => 'Google Fonts',
6372
+ 'Taprom' => 'Google Fonts',
6373
+ 'Tauri' => 'Google Fonts',
6374
+ 'Taviraj' => 'Google Fonts',
6375
+ 'Teko' => 'Google Fonts',
6376
+ 'Telex' => 'Google Fonts',
6377
+ 'Tenali Ramakrishna' => 'Google Fonts',
6378
+ 'Tenor Sans' => 'Google Fonts',
6379
+ 'Text Me One' => 'Google Fonts',
6380
+ 'The Girl Next Door' => 'Google Fonts',
6381
+ 'Tienne' => 'Google Fonts',
6382
+ 'Tillana' => 'Google Fonts',
6383
+ 'Timmana' => 'Google Fonts',
6384
+ 'Tinos' => 'Google Fonts',
6385
+ 'Titan One' => 'Google Fonts',
6386
+ 'Titillium Web' => 'Google Fonts',
6387
+ 'Trade Winds' => 'Google Fonts',
6388
+ 'Trirong' => 'Google Fonts',
6389
+ 'Trocchi' => 'Google Fonts',
6390
+ 'Trochut' => 'Google Fonts',
6391
+ 'Trykker' => 'Google Fonts',
6392
+ 'Tulpen One' => 'Google Fonts',
6393
+ 'Ubuntu' => 'Google Fonts',
6394
+ 'Ubuntu Condensed' => 'Google Fonts',
6395
+ 'Ubuntu Mono' => 'Google Fonts',
6396
+ 'Ultra' => 'Google Fonts',
6397
+ 'Uncial Antiqua' => 'Google Fonts',
6398
+ 'Underdog' => 'Google Fonts',
6399
+ 'Unica One' => 'Google Fonts',
6400
+ 'UnifrakturCook' => 'Google Fonts',
6401
+ 'UnifrakturMaguntia' => 'Google Fonts',
6402
+ 'Unkempt' => 'Google Fonts',
6403
+ 'Unlock' => 'Google Fonts',
6404
+ 'Unna' => 'Google Fonts',
6405
+ 'VT323' => 'Google Fonts',
6406
+ 'Vampiro One' => 'Google Fonts',
6407
+ 'Varela' => 'Google Fonts',
6408
+ 'Varela Round' => 'Google Fonts',
6409
+ 'Vast Shadow' => 'Google Fonts',
6410
+ 'Vesper Libre' => 'Google Fonts',
6411
+ 'Vibur' => 'Google Fonts',
6412
+ 'Vidaloka' => 'Google Fonts',
6413
+ 'Viga' => 'Google Fonts',
6414
+ 'Voces' => 'Google Fonts',
6415
+ 'Volkhov' => 'Google Fonts',
6416
+ 'Vollkorn' => 'Google Fonts',
6417
+ 'Vollkorn SC' => 'Google Fonts',
6418
+ 'Voltaire' => 'Google Fonts',
6419
+ 'Waiting for the Sunrise' => 'Google Fonts',
6420
+ 'Wallpoet' => 'Google Fonts',
6421
+ 'Walter Turncoat' => 'Google Fonts',
6422
+ 'Warnes' => 'Google Fonts',
6423
+ 'Wellfleet' => 'Google Fonts',
6424
+ 'Wendy One' => 'Google Fonts',
6425
+ 'Wire One' => 'Google Fonts',
6426
+ 'Work Sans' => 'Google Fonts',
6427
+ 'Yanone Kaffeesatz' => 'Google Fonts',
6428
+ 'Yantramanav' => 'Google Fonts',
6429
+ 'Yatra One' => 'Google Fonts',
6430
+ 'Yellowtail' => 'Google Fonts',
6431
+ 'Yeon Sung' => 'Google Fonts',
6432
+ 'Yeseva One' => 'Google Fonts',
6433
+ 'Yesteryear' => 'Google Fonts',
6434
+ 'Yrsa' => 'Google Fonts',
6435
+ 'Zeyada' => 'Google Fonts',
6436
+ 'Zilla Slab' => 'Google Fonts',
6437
+ 'Zilla Slab Highlight' => 'Google Fonts',
6438
+ ];
6439
+
6440
+ }//end get_font_list()
6441
+
6442
+
6443
+ /**
6444
+ * Set Default folder order if not exists
6445
+ *
6446
+ * @since 1.0.0
6447
+ * @access public
6448
+ * @return $fonts
6449
+ */
6450
  public function set_default_values_if_not_exists()
6451
  {
6452
+ if (is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
6453
  $options = get_option('folders_settings');
6454
+ $options = empty($options) || !is_array($options) ? [] : $options;
6455
  foreach ($options as $option) {
6456
  $post_type = self::get_custom_post_type($option);
6457
+ $terms = get_terms(
6458
+ $post_type,
6459
+ [
6460
  'hide_empty' => false,
6461
+ 'meta_query' => [
6462
+ [
6463
+ 'key' => 'wcp_custom_order',
6464
+ 'compare' => 'NOT EXISTS',
6465
+ ],
6466
+ ],
6467
+ ]
6468
  );
6469
  if (!empty($terms)) {
6470
  foreach ($terms as $term) {
6474
  }
6475
  }
6476
  }
6477
+ }//end foreach
6478
+ }//end if
6479
+
6480
+ }//end set_default_values_if_not_exists()
6481
+
6482
 
6483
+ // Free and Pro major changes
6484
+
6485
+
6486
+ /**
6487
+ * Hide Folder intro Popup
6488
+ *
6489
+ * @since 1.0.0
6490
+ * @access public
6491
+ */
6492
+ public function premio_hide_child_popup()
6493
+ {
6494
+ $post_type = $this->getRequestVar('post_type');
6495
+ $nonce = $this->getRequestVar('nonce');
6496
+ if (!empty($post_type) && wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$post_type)) {
6497
+ $status = $this->getRequestVar('status');
6498
+ $status = ($status == 1) ? 1 : 0;
6499
+ if ($status) {
6500
  add_option("premio_hide_child_popup", 1);
6501
  } else {
6502
  delete_option("premio_hide_child_popup");
6503
  }
6504
  }
6505
+
6506
  echo esc_attr("1");
6507
  die;
 
6508
 
6509
+ }//end premio_hide_child_popup()
6510
+
6511
+
6512
+ /**
6513
+ * Hide Folder intro Popup
6514
+ *
6515
+ * @since 1.0.0
6516
+ * @access public
6517
+ */
6518
+ public function folder_update_popup_status()
6519
+ {
6520
+ $nonce = $this->getRequestVar('nonce');
6521
+ if (!empty($nonce) && wp_verify_nonce($nonce, 'folder_update_popup_status')) {
6522
  update_option("folder_intro_box", "hide");
6523
  }
6524
+
6525
  echo esc_attr("1");
6526
  die;
 
6527
 
6528
+ }//end folder_update_popup_status()
6529
+
6530
+
6531
+ /**
6532
+ * Hide Folder import Popup
6533
+ *
6534
+ * @since 1.0.0
6535
+ * @access public
6536
+ */
6537
+ public function update_folders_import_status()
6538
+ {
6539
+ $nonce = $this->getRequestVar('nonce');
6540
+ if (!empty($nonce) && wp_verify_nonce($nonce, 'folders_import_3rd_party_data')) {
6541
  update_option("folder_redirect_status", "3");
6542
  }
6543
+
6544
  echo esc_attr("1");
6545
  die;
 
6546
 
6547
+ }//end update_folders_import_status()
6548
+
6549
+
6550
+ /**
6551
+ * Check folders has valid key
6552
+ *
6553
+ * @since 1.0.0
6554
+ * @access public
6555
+ */
6556
  public function check_has_valid_key()
6557
  {
6558
+ // Free/Pro: checking for key, for Free return 0, for Pro check for Key
6559
  return 0;
 
6560
 
6561
+ }//end check_has_valid_key()
6562
+
6563
+
6564
+ /**
6565
+ * Get license information
6566
+ *
6567
+ * @since 1.0.0
6568
+ * @access public
6569
+ */
6570
  public function get_license_key_information($licenseKey)
6571
  {
6572
+ return [];
 
6573
 
6574
+ }//end get_license_key_information()
6575
+
6576
+
6577
+ /**
6578
+ * Get license key data
6579
+ *
6580
+ * @since 1.0.0
6581
+ * @access public
6582
+ */
6583
+ public function get_license_key_data($licenseKey='')
6584
  {
6585
+ return [];
6586
+
6587
+ }//end get_license_key_data()
6588
+
6589
 
6590
+ /**
6591
+ * Check for license key data
6592
+ *
6593
+ * @since 1.0.0
6594
+ * @access public
6595
+ */
6596
  public function check_for_license_key()
6597
  {
6598
  return false;
6599
+
6600
+ }//end check_for_license_key()
6601
+
6602
+
6603
+ }//end class
6604
+
includes/form.class.php CHANGED
@@ -1,30 +1,56 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
- class WCP_Forms {
4
- public function __construct() {
 
 
 
5
 
6
- }
 
 
7
 
8
- public static function get_form_html($option_data = "") {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  ob_start();
10
- $customize_folders = get_option('customize_folders');
11
- $show_in_page = !isset($customize_folders['use_shortcuts'])?"yes":$customize_folders['use_shortcuts'];
12
- ?>
13
 
14
- <?php
15
- $customize_folders = get_option("customize_folders");
16
- if(isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
17
- $upgradeURL = admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
18
- } else {
19
- $upgradeURL = admin_url("admin.php?page=folders-upgrade-to-pro");
20
- }
21
 
22
- $is_old = false;
23
- $old_status = get_option("wcp_folder_version_267");
24
- if($old_status === false) {
25
- //$is_old = true;
26
- }
27
- ?>
28
  <div class="wcp-custom-form">
29
  <div class="form-title">
30
  <div class="plugin-title">
@@ -38,7 +64,7 @@ class WCP_Forms {
38
  </span>
39
  </div>
40
  <div class="plugin-button">
41
- <?php if($show_in_page == "yes") { ?>
42
  <a href="#" class="view-shortcodes folder-tooltip" data-folder-tooltip="<?php esc_html_e("Press Ctrl+K to view keyboard shortcuts", 'folders'); ?>"><svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" /></svg></a>
43
  <?php } ?>
44
  <a href="javascript:;" class="add-new-folder" id="add-new-folder">
@@ -58,7 +84,7 @@ class WCP_Forms {
58
  <li>
59
  <a href="javascript:;" id="inline-remove"><span class="icon pfolder-remove"></span> <span class="text"><?php /*esc_html_e("Delete", 'folders'); */?></span> </a>
60
  </li>-->
61
- <?php if($is_old) { ?>
62
  <li>
63
  <a href="javascript:;" class="expand-collapse folder-tooltip" id="expand-collapse-list" data-folder-tooltip="<?php esc_html_e("Expand", 'folders'); ?>">
64
  <span class="icon pfolder-arrow-down"></span><!-- <span class="text"><?php /*esc_html_e("Expand", 'folders'); */?></span>-->
@@ -79,11 +105,11 @@ class WCP_Forms {
79
  <a data-folder-tooltip="Sort Folders" href="javascript:;" id="sort-order-list" class="sort-folder-order folder-tooltip">
80
  <span class="icon pfolder-arrow-sort"></span><!-- <span class="text"><?php /*esc_html_e("Sort", 'folders'); */?></span>-->
81
  </a>
82
- <div class="folder-sort-menu <?php echo ($is_old)?"":"is-pro" ?>">
83
  <ul>
84
  <li><a data-sort="a-z" href="#"><?php esc_html_e("A → Z", 'folders'); ?></a></li>
85
  <li><a data-sort="z-a" href="#"><?php esc_html_e("Z → A", 'folders'); ?></a></li>
86
- <?php if($is_old) { ?>
87
  <li><a data-sort="n-o" href="#"><?php esc_html_e("Sort by newest", 'folders'); ?></a></li>
88
  <li><a data-sort="o-n" href="#"><?php esc_html_e("Sort by oldest", 'folders'); ?></a></li>
89
  <?php } else { ?>
@@ -107,5 +133,9 @@ class WCP_Forms {
107
  </div>
108
  <?php
109
  return ob_get_clean();
110
- }
111
- }
 
 
 
 
1
  <?php
2
+ /**
3
+ * Class Folders Forms
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
 
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
 
13
+ class WCP_Forms
14
+ {
15
+
16
+
17
+ /**
18
+ * Define the core functionality of the plugin.
19
+ *
20
+ * @since 1.0.0
21
+ */
22
+ public function __construct()
23
+ {
24
+
25
+ }//end __construct()
26
+
27
+
28
+ /**
29
+ * Return form HTML data
30
+ *
31
+ * @since 1.0.0
32
+ * @access public
33
+ * @return $isWPMLActive
34
+ */
35
+ public static function get_form_html($option_data="")
36
+ {
37
  ob_start();
38
+ $customizeFolders = get_option('customize_folders');
39
+ $showInPage = !isset($customizeFolders['use_shortcuts']) ? "yes" : $customizeFolders['use_shortcuts'];
 
40
 
41
+ $customizeFolders = get_option("customize_folders");
42
+ if (isset($customizeFolders['show_folder_in_settings']) && $customizeFolders['show_folder_in_settings'] == "yes") {
43
+ $upgradeURL = admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
44
+ } else {
45
+ $upgradeURL = admin_url("admin.php?page=folders-upgrade-to-pro");
46
+ }
 
47
 
48
+ $isOld = false;
49
+ $oldStatus = get_option("wcp_folder_version_267");
50
+ if ($oldStatus === false) {
51
+ // $isOld = true;
52
+ }
53
+ ?>
54
  <div class="wcp-custom-form">
55
  <div class="form-title">
56
  <div class="plugin-title">
64
  </span>
65
  </div>
66
  <div class="plugin-button">
67
+ <?php if ($showInPage == "yes") { ?>
68
  <a href="#" class="view-shortcodes folder-tooltip" data-folder-tooltip="<?php esc_html_e("Press Ctrl+K to view keyboard shortcuts", 'folders'); ?>"><svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" /></svg></a>
69
  <?php } ?>
70
  <a href="javascript:;" class="add-new-folder" id="add-new-folder">
84
  <li>
85
  <a href="javascript:;" id="inline-remove"><span class="icon pfolder-remove"></span> <span class="text"><?php /*esc_html_e("Delete", 'folders'); */?></span> </a>
86
  </li>-->
87
+ <?php if ($isOld) { ?>
88
  <li>
89
  <a href="javascript:;" class="expand-collapse folder-tooltip" id="expand-collapse-list" data-folder-tooltip="<?php esc_html_e("Expand", 'folders'); ?>">
90
  <span class="icon pfolder-arrow-down"></span><!-- <span class="text"><?php /*esc_html_e("Expand", 'folders'); */?></span>-->
105
  <a data-folder-tooltip="Sort Folders" href="javascript:;" id="sort-order-list" class="sort-folder-order folder-tooltip">
106
  <span class="icon pfolder-arrow-sort"></span><!-- <span class="text"><?php /*esc_html_e("Sort", 'folders'); */?></span>-->
107
  </a>
108
+ <div class="folder-sort-menu <?php echo ($isOld) ? "" : "is-pro" ?>">
109
  <ul>
110
  <li><a data-sort="a-z" href="#"><?php esc_html_e("A → Z", 'folders'); ?></a></li>
111
  <li><a data-sort="z-a" href="#"><?php esc_html_e("Z → A", 'folders'); ?></a></li>
112
+ <?php if ($isOld) { ?>
113
  <li><a data-sort="n-o" href="#"><?php esc_html_e("Sort by newest", 'folders'); ?></a></li>
114
  <li><a data-sort="o-n" href="#"><?php esc_html_e("Sort by oldest", 'folders'); ?></a></li>
115
  <?php } else { ?>
133
  </div>
134
  <?php
135
  return ob_get_clean();
136
+
137
+ }//end get_form_html()
138
+
139
+
140
+ }//end class
141
+
includes/media.replace.php CHANGED
@@ -1,984 +1,1196 @@
1
- <?php
2
- /**
3
- * Class Folders Replace Media
4
- *
5
- * @author : Premio <contact@premio.io>
6
- * @license : GPL2
7
- * */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) exit;
10
-
11
- class folders_replace_media {
12
-
13
- public $button_color;
14
-
15
- public $is_enabled = false;
16
-
17
- public $upgradeLink;
18
-
19
- function __construct() {
20
-
21
- $customize_folders = get_option('customize_folders');
22
-
23
- $this->button_color = isset($customize_folders['media_replace_button'])?$customize_folders['media_replace_button']:"#FA166B";
24
-
25
- $this->is_enabled = isset($customize_folders['folders_enable_replace_media'])?$customize_folders['folders_enable_replace_media']:"yes";
26
-
27
- $this->is_enabled = ($this->is_enabled == "yes")?true:false;
28
-
29
- if($this->is_enabled) {
30
-
31
- add_action('admin_menu', array($this, 'admin_menu'));
32
-
33
- add_filter('media_row_actions', array($this, 'add_media_action'), 10, 2);
34
-
35
- add_action('add_meta_boxes', function () {
36
- add_meta_box('folders-replace-box', esc_html__('Replace Media', 'folders'), array($this, 'replace_meta_box'), 'attachment', 'side', 'low');
37
- });
38
- add_filter('attachment_fields_to_edit', array($this, 'attachment_editor'), 10, 2);
39
-
40
- add_action('admin_enqueue_scripts', array($this, 'folders_admin_css_and_js'));
41
-
42
- add_action('admin_init', array($this, 'handle_folders_file_upload'));
43
- }
44
-
45
- $customize_folders = get_option("customize_folders");
46
- if(isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
47
- $this->upgradeLink = admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
48
- } else {
49
- $this->upgradeLink = admin_url("admin.php?page=folders-upgrade-to-pro");
50
- }
51
-
52
- /* to replace file name */
53
- add_action('add_meta_boxes', function () {
54
- add_meta_box('folders-replace-file-name', esc_html__('Change file name', 'folders'), array($this, 'change_file_name_box'), 'attachment', 'side', 'core');
55
- });
56
-
57
- add_filter('attachment_fields_to_edit', array($this, 'attachment_replace_name_with_title'), 10, 2);
58
-
59
- add_action('admin_head', array($this, 'premio_replace_file_CSS'));
60
-
61
- add_action('wp_enqueue_media', array($this, 'replace_media_file_script'));
62
-
63
- add_action('admin_notices', array($this, 'admin_notices'));
64
- }
65
-
66
- /**
67
- * Add admin notice
68
- *
69
- * @since 2.6.3
70
- * @access public
71
- *
72
- */
73
- public function admin_notices() {
74
- if(isset($_REQUEST['premio_message']) && $_REQUEST['premio_message'] == "success") { ?>
75
- <div class="notice notice-success is-dismissible">
76
- <p><b><?php esc_html_e( 'File successfully replaced', 'folders' ); ?></b></p>
77
- <p><?php esc_html_e( 'The file has been successfully replaced using the file replacement feature', 'folders' ); ?></p>
78
- </div>
79
-
80
- <style>
81
- .folders-undo-notification {
82
- position: fixed;
83
- right: -500px;
84
- bottom: 25px;
85
- width: 280px;
86
- background: #fff;
87
- padding: 15px;
88
- -webkit-box-shadow: 0 3px 6px -4px rgb(0 0 0 / 12%), 0 6px 16px 0 rgb(0 0 0 / 8%), 0 9px 28px 8px rgb(0 0 0 / 5%);
89
- box-shadow: 0 3px 6px -4px rgb(0 0 0 / 12%), 0 6px 16px 0 rgb(0 0 0 / 8%), 0 9px 28px 8px rgb(0 0 0 / 5%);
90
- transition: all .25s linear;
91
- z-index: 250010;
92
- }
93
- .folders-undo-body {
94
- position: relative;
95
- font-size: 13px;
96
- padding: 0 0 5px 0;
97
- }
98
- .close-undo-box {
99
- position: absolute;
100
- right: -10px;
101
- top: 0;
102
- width: 16px;
103
- height: 16px;
104
- transition: all .25s linear;
105
- }
106
- .close-undo-box span {
107
- display: block;
108
- position: relative;
109
- width: 16px;
110
- height: 16px;
111
- transition: all .2s linear;
112
- }
113
- .close-undo-box span:after, .close-undo-box span:before {
114
- content: "";
115
- position: absolute;
116
- width: 12px;
117
- height: 2px;
118
- background-color: #333;
119
- display: block;
120
- border-radius: 2px;
121
- transform: rotate(45deg);
122
- top: 7px;
123
- left: 2px;
124
- }
125
- .close-undo-box span:after {
126
- transform: rotate(-45deg);
127
- }
128
- .folders-undo-header {
129
- font-weight: 500;
130
- font-size: 14px;
131
- padding: 0 0 3px 0;
132
- color: #014737;
133
- }
134
- .folders-undo-notification.success {
135
- border-left: solid 3px #70C6A3;
136
- }
137
- html[dir="rtl"] .folders-undo-notification {
138
- right: auto;
139
- left: -500px
140
- }
141
- html[dir="rtl"] .folders-undo-notification.active {
142
- left: 25px;
143
- }
144
- html[dir="rtl"] .folders-undo-notification.success {
145
- border-left: none;
146
- border-right: solid 3px #70C6A3;
147
- }
148
- html[dir="rtl"] .close-undo-box {
149
- right: auto;
150
- left: -10px;
151
- }
152
- </style>
153
- <div class="folders-undo-notification success" id="media-success">
154
- <div class="folders-undo-body">
155
- <a href="javascript:;" class="close-undo-box"><span></span></a>
156
- <div class="folders-undo-header"><?php esc_html_e( 'File successfully replaced', 'folders' ); ?></div>
157
- <div class="folders-undo-body" style="padding:0"><?php esc_html_e( 'The file has been successfully replaced using the file replacement feature', 'folders' ); ?></div>
158
- </div>
159
- </div>
160
- <script>
161
- jQuery(document).ready(function(){
162
- jQuery("#media-success").addClass("active");
163
- setTimeout(function(){
164
- jQuery("#media-success").removeClass("active");
165
- }, 5000);
166
-
167
- jQuery(document).on("click", ".close-undo-box", function(){
168
- jQuery("#media-success").removeClass("active");
169
- });
170
- });
171
- </script>
172
- <?php }
173
- }
174
-
175
- /**
176
- * Add Metabox to replace file name with title
177
- *
178
- * @since 2.6.3
179
- * @access public
180
- *
181
- */
182
- public function change_file_name_box($post) { ?>
183
- <p class="upgrade-bottom">
184
- <label for="change_file_name"><input disabled type="checkbox" id="change_file_name" name="premio_change_file_name" value="yes"> <?php esc_html_e("Change file name according to title", "folders") ?></label>
185
- </p>
186
- <div class="upgrade-box">
187
- <a href="<?php echo esc_url($this->upgradeLink) ?>" target="_blank"><?php esc_html_e("Upgrade to Pro", "folders"); ?></a>
188
- </div>
189
- <?php
190
- }
191
-
192
- /**
193
- * Add Js and CSS files for replace file name with title
194
- *
195
- * @since 2.6.3
196
- * @access public
197
- *
198
- */
199
- public function replace_media_file_script() {
200
- wp_enqueue_script('folders-replace-media', WCP_FOLDER_URL . 'assets/js/replace-file-name.js', array('jquery'), WCP_FOLDER_VERSION, true);
201
- wp_localize_script('folders-replace-media', 'replace_media_options', array(
202
- 'ajax_url' => admin_url("admin-ajax.php"),
203
- ));
204
- }
205
-
206
- public function premio_replace_file_CSS() {
207
- echo '<style>
208
- .compat-field-replace_file_name th.label {display: none;}
209
- .compat-field-replace_file_name td.field {width: 100%; border-top: solid 1px #c0c0c0; padding:10px 0 0 0;margin: 0;float: none;}
210
- .compat-field-replace_file_name td.field label {width: 100%; display: block;padding:0 0 10px 0;}
211
- .compat-field-replace_file_name td.field label input[type="checkbox"] {margin: 0 4px 0 2px;}
212
- .compat-field-replace_file_name td.field a.update-name-with-title {display: none;}
213
- .compat-field-replace_file_name td.field a.update-name-with-title.show {display: inline-block;}
214
-
215
- .compat-field-folders th.label {width: 100%; text-align: left; padding: 0 0 10px 0; margin: 0; border-top: solid 1px #c0c0c0;float: none;}
216
- .compat-field-folders th.label .alignleft {float: none; text-align: left; font-weight: bold;}
217
- .compat-field-folders th.label br {display: none;}
218
- .compat-field-folders td.field {width: 100%; padding: 0; margin: 0;float: none;}
219
- .folders-undo-notification{position:fixed;right:-500px;bottom:25px;width:280px;background:#fff;padding:15px;-webkit-box-shadow:0 3px 6px -4px rgb(0 0 0 / 12%),0 6px 16px 0 rgb(0 0 0 / 8%),0 9px 28px 8px rgb(0 0 0 / 5%);box-shadow:0 3px 6px -4px rgb(0 0 0 / 12%),0 6px 16px 0 rgb(0 0 0 / 8%),0 9px 28px 8px rgb(0 0 0 / 5%);transition:all .25s linear;z-index:250010}.folders-undo-notification.active{right:25px}.folders-undo-header{font-weight:500;font-size:14px;padding:0 0 3px 0}.folders-undo-body{font-size:13px;padding:0 0 5px 0}.folders-undo-footer{text-align:right;padding:5px 0 0 0}.folders-undo-footer .undo-button{background:#1da1f4;border:none;color:#fff;padding:3px 10px;font-size:12px;border-radius:2px;cursor:pointer}.folders-undo-body{position:relative}.close-undo-box{position:absolute;right:-10px;top:0;width:16px;height:16px;transition:all .25s linear}.close-undo-box:hover{transform:rotate(180deg)}.close-undo-box span{display:block;position:relative;width:16px;height:16px;transition:all .2s linear}.close-undo-box span:after,.close-undo-box span:before{content:"";position:absolute;width:12px;height:2px;background-color:#333;display:block;border-radius:2px;transform:rotate(45deg);top:7px;left:2px}.close-undo-box span:after{transform:rotate(-45deg)}
220
- .folders-undo-notification.no .folders-undo-header { color: #dd0000; }
221
- .folders-undo-notification.yes .folders-undo-header { color: #014737; }
222
- .update-name-with-title .spinner {display: none; visibility: visible; margin-right: 0;}
223
- .update-name-with-title.in-progress .spinner {display: inline-block;}
224
-
225
- #folders-replace-file-name .inside {position: relative;padding:0;margin:0}
226
- #folders-replace-file-name .inside p {padding: 1em; margin: 0;}
227
- #folders-replace-file-name .upgrade-box {position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.3); z-index: 1;display: none;}
228
- #folders-replace-file-name:hover .upgrade-box { display: block; }
229
- #folders-replace-file-name:hover p {filter: blur(1.2px);}
230
- #folders-replace-file-name:hover .upgrade-box a {display: inline-block; position: absolute; left: 0; right: 0; width: 100px; margin: 0 auto; top: 50%; padding: 5px 10px; text-decoration: none; background: #fa166b; color: #fff; border-radius: 4px; text-align: center; margin-top: -14px;}
231
- </style>';
232
- }
233
-
234
- /**
235
- * Replace file name with title
236
- *
237
- * @since 2.6.3
238
- * @access public
239
- *
240
- */
241
- public function attachment_replace_name_with_title($formFields, $post)
242
- {
243
- $screen = null;
244
- if (function_exists('get_current_screen'))
245
- {
246
- $screen = get_current_screen();
247
-
248
- if(! is_null($screen) && $screen->id == 'attachment') // hide on edit attachment screen.
249
- return $formFields;
250
- }
251
-
252
- $formFields["replace_file_name"] = array(
253
- "label" => esc_html__("Replace media", "folders"),
254
- "input" => "html",
255
- "html" => "<label for='attachment_title_{$post->ID}' data-post='{$post->ID}' data-nonce='".wp_create_nonce('change_attachment_title_'.$post->ID)."'><input id='attachment_title_{$post->ID}' type='checkbox' class='folder-replace-checkbox' value='{$post->ID}'>".esc_html__("Update file name with title")."</label><a href='".$this->upgradeLink."' target='_blank' style='background: {$this->button_color}; border-color: {$this->button_color}; color:#ffffff' type='button' class='button update-name-with-title' >".esc_html__("Upgrade to Pro", "folders")."</a>",
256
- "helps" => ""
257
- );
258
-
259
- return $formFields;
260
- }
261
-
262
- /**
263
- * Add Js and CSS files for replace file screen
264
- *
265
- * @since 2.6.3
266
- * @access public
267
- *
268
- */
269
- public function folders_admin_css_and_js($page) {
270
- if($page == "media_page_folders-replace-media" || $page == "admin_page_folders-replace-media") {
271
- wp_enqueue_style('folders-media', plugin_dir_url(dirname(__FILE__)) . 'assets/css/replace-media.css', array(), WCP_FOLDER_VERSION);
272
- wp_enqueue_script('folders-media', plugin_dir_url(dirname(__FILE__)) . 'assets/js/replace-media.js', array(), WCP_FOLDER_VERSION);
273
- }
274
- }
275
-
276
- /**
277
- * Add file replace menu in admin
278
- *
279
- * @since 2.6.3
280
- * @access public
281
- * @return $string
282
- *
283
- */
284
- public function admin_menu() {
285
- add_submenu_page(null,
286
- esc_html__("Replace media", "folders"),
287
- esc_html__("Replace media", "folders"),
288
- 'upload_files',
289
- 'folders-replace-media',
290
- array($this, 'folders_replace_media')
291
- );
292
- }
293
-
294
- /**
295
- * Add file replacement screen
296
- *
297
- * @since 2.6.3
298
- * @access public
299
- * @return $string
300
- *
301
- */
302
- public function folders_replace_media() {
303
- global $plugin_page;
304
- $action = isset($_GET['action']) ? sanitize_text_field($_GET['action']) : '';
305
- $attachment_id = isset($_GET['attachment_id']) ? sanitize_text_field($_GET['attachment_id']) : '';
306
- $nonce = isset($_GET['nonce']) ? sanitize_text_field($_GET['nonce']) : '';
307
- if (!wp_verify_nonce($nonce, "folders-replace-media-".$attachment_id)) {
308
- echo 'Invalid Nonce';
309
- exit;
310
- }
311
- $attachment = get_post($attachment_id);
312
- if(empty($attachment) || !isset($attachment->guid)) {
313
- echo 'Invalid URL';
314
- exit;
315
- }
316
- $guid = $attachment->guid;
317
- $guid = explode(".", $guid);
318
- if($guid == $attachment->guid) {
319
- echo 'Invalid URL';
320
- exit;
321
- }
322
- $form_action = $this->getMediaReplaceURL($attachment_id);
323
- include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "media-replace.php";
324
- }
325
-
326
- /**
327
- * Add action for file replacement
328
- *
329
- * @since 2.6.3
330
- * @access public
331
- * @return $actions
332
- *
333
- */
334
- public function add_media_action($actions, $post) {
335
- if(!$this->is_enabled) {
336
- return array_merge($actions);
337
- }
338
- if (wp_attachment_is('image', $post->ID)) {
339
- $link = $this->getMediaReplaceURL( $post->ID );
340
-
341
- $newaction['replace_media'] = '<a style="color: ' . $this->button_color . '" href="' . $link . '" rel="permalink">' . esc_html__( "Replace media", "folders" ) . '</a>';
342
-
343
- return array_merge( $actions, $newaction );
344
- } else {
345
- $link = $this->getMediaReplaceURL( $post->ID );
346
-
347
- $newaction['replace_media'] = '<a style="color: ' . $this->button_color . '" target="_blank" href="' . $this->upgradeLink . '" rel="permalink">' . esc_html__( "Replace Media 🔑", "folders" ) . '</a>';
348
-
349
- return array_merge( $actions, $newaction );
350
- }
351
- return $actions;
352
- }
353
-
354
- /**
355
- * Get URL for file Replacement
356
- *
357
- * @since 2.6.3
358
- * @access public
359
- * @return $url
360
- *
361
- */
362
- public function getMediaReplaceURL($attach_id) {
363
- $url = admin_url( "upload.php");
364
- $url = add_query_arg(array(
365
- 'page' => 'folders-replace-media',
366
- 'action' => 'folders_replace_media',
367
- 'attachment_id' => $attach_id,
368
- 'nonce' => wp_create_nonce("folders-replace-media-".$attach_id)
369
- ), $url);
370
-
371
- return $url;
372
- }
373
-
374
- /**
375
- * Get file size
376
- *
377
- * @since 2.6.3
378
- * @access public
379
- * @return $size
380
- *
381
- */
382
- public function replace_meta_box($post) {
383
- if (wp_attachment_is('image', $post->ID)) {
384
- $link = $this->getMediaReplaceURL($post->ID);
385
- echo "<p><a style='background: {$this->button_color}; border-color: {$this->button_color}; color:#ffffff' href='" . $link . "' class='button-secondary'>" . esc_html__( "Upload a new file", "folders" ) . "</a></p><p>" . esc_html__( "Click on the button to replace the file with another file", "folders" ) . "</p>";
386
- } else {
387
- echo "<p><a style='color: {$this->button_color}; font-weight: 500' target='_blank' href='" . $this->upgradeLink . "' >" . esc_html__( "Upgrade to Pro", "folders" ) . "</a> ".esc_html__( "to replace any kind of files while uploading including pdf/svg/docx/etc & more.", "folders" ) . "</p>";
388
- }
389
- }
390
-
391
- /**
392
- * Get file size
393
- *
394
- * @since 2.6.3
395
- * @access public
396
- * @return $size
397
- *
398
- */
399
- public function attachment_editor($formFields, $post)
400
- {
401
- $screen = null;
402
- if (function_exists('get_current_screen'))
403
- {
404
- $screen = get_current_screen();
405
-
406
- if(! is_null($screen) && $screen->id == 'attachment') // hide on edit attachment screen.
407
- return $formFields;
408
- }
409
- if (wp_attachment_is('image', $post->ID)) {
410
- $link = $this->getMediaReplaceURL( $post->ID );
411
- $formFields["folders"] = array(
412
- "label" => esc_html__( "Replace media", "folders" ),
413
- "input" => "html",
414
- "html" => "<a style='background: {$this->button_color}; border-color: {$this->button_color}; color:#ffffff' href='" . $link . "' class='button-secondary'>" . esc_html__( "Upload a new file", "folders" ) . "</a>",
415
- "helps" => esc_html__( "Click on the button to replace the file with another file", "folders" )
416
- );
417
- } else {
418
- $formFields["folders"] = array(
419
- "label" => esc_html__( "Replace media", "folders" ),
420
- "input" => "html",
421
- "html" => "<div style='border: solid 1px #c0c0c0; padding: 10px; border-radius: 2px; background: #ececec;'><a style='color: {$this->button_color}; font-weight: 500' target='_blank' href='" . $this->upgradeLink . "' >" . esc_html__( "Upgrade to Pro", "folders" ) . "</a> ".esc_html__( "to replace media files other than images", "folders" ) . "</div>",
422
- "helps" => esc_html__( "Click on the button to replace the file with another file", "folders" )
423
- );
424
- }
425
-
426
- return $formFields;
427
- }
428
-
429
- /**
430
- * Get file size
431
- *
432
- * @since 2.6.3
433
- * @access public
434
- * @return $size
435
- *
436
- */
437
- public function getFileSize($attachment_id) {
438
- $size = filesize( get_attached_file( $attachment_id ));
439
- if($size > 1000000) {
440
- $size = ($size/1000000);
441
- return number_format((float)$size, 2, ".", ",")." MB";
442
- } else if($size > 1000) {
443
- $size = ($size/1000);
444
- return number_format((float)$size, 2, ".", ",")." KB";
445
- }
446
- return $size." B";
447
- }
448
-
449
- public $old_file_ext;
450
- public $old_file_path;
451
- public $old_file_url;
452
- public $new_file_path;
453
- public $new_file_url;
454
-
455
- public $new_file_name;
456
-
457
- public $current_upload_data;
458
-
459
- public $mode = "rename-file";
460
-
461
- public $old_image_meta;
462
- public $new_image_meta;
463
- public $upload_dir;
464
-
465
- public $is_old_image = 0;
466
- public $is_new_image = 0;
467
- public $attachment_id;
468
-
469
-
470
- /**
471
- * Upload file and Replace it
472
- *
473
- * @since 2.6.3
474
- * @access public
475
- *
476
- */
477
- public function handle_folders_file_upload() {
478
- global $wpdb;
479
- if(isset($_FILES['new_media_file'])) {
480
- if($_FILES['new_media_file']['error'] == 0) {
481
- $attachment_id = isset($_GET['attachment_id']) ? sanitize_text_field($_GET['attachment_id']) : '';
482
- $nonce = isset($_GET['nonce']) ? sanitize_text_field($_GET['nonce']) : '';
483
- if (!wp_verify_nonce($nonce, "folders-replace-media-" . $attachment_id)) {
484
- return;
485
- }
486
- $attachment = get_post($attachment_id);
487
- if (empty($attachment) || !isset($attachment->guid)) {
488
- return;
489
- }
490
- $attachment_url = $attachment->guid;
491
- $url = wp_get_attachment_url($attachment_id);
492
- if(!empty($url)) {
493
- $attachment_url = $url;
494
- }
495
- $guid = explode(".", $attachment_url);
496
- $guid = array_pop($guid);
497
- if ($guid == $attachment->guid) {
498
- return;
499
- }
500
-
501
- $replacement_option = isset($_REQUEST['replacement_option'])?$_REQUEST['replacement_option']:"replace_only_file";
502
-
503
- $this->attachment_id = $attachment_id;
504
-
505
- $file = $_FILES['new_media_file'];
506
- $file_name = $file['name'];
507
- $file_ext = explode(".", $file_name);
508
- $file_ext = array_pop($file_ext);
509
-
510
- if (wp_attachment_is('image', $attachment_id)) {
511
- $this->is_old_image = 1;
512
- }
513
- $this->old_file_url = $attachment_url;
514
- $this->old_image_meta = wp_get_attachment_metadata($attachment_id);
515
-
516
- $new_file = $file['tmp_name'];
517
-
518
- $file_parts = pathinfo($attachment_url);
519
-
520
- $db_file_name = $file_parts['basename'];
521
- $db_file_array = explode(".", $db_file_name);
522
- array_pop($db_file_array);
523
- $db_file_name = implode(".", $db_file_array).".";
524
- $db_file_name .= $file_ext;
525
-
526
- $wp_upload_path = wp_get_upload_dir();
527
-
528
- $base_path = $old_path = $wp_upload_path['basedir'].DIRECTORY_SEPARATOR;
529
- $baseurl = $old_url = $wp_upload_path['baseurl']."/";
530
-
531
- $post_upload = "";
532
-
533
- $wp_attached_file = get_post_meta($attachment_id, "_wp_attached_file", true);
534
- if($wp_attached_file !== false) {
535
- $old_file_name = explode("/", $wp_attached_file);
536
- array_pop($old_file_name);
537
-
538
- if(count($old_file_name) > 0) {
539
- $old_path .= implode(DIRECTORY_SEPARATOR, $old_file_name);
540
- $old_url .= implode("/", $old_file_name);
541
- }
542
-
543
- if($replacement_option == "replace_file_with_name" && isset($_REQUEST['new_folder_option']) && $_REQUEST['new_folder_option'] && isset($_REQUEST['new_folder_path']) && !empty($_REQUEST['new_folder_path'])) {
544
- $baseurl .= $_REQUEST['new_folder_path'];
545
- $base_path .= str_replace("/", DIRECTORY_SEPARATOR, $_REQUEST['new_folder_path']);
546
-
547
- $post_upload = $_REQUEST['new_folder_path'];
548
- } else if(count($old_file_name) > 0) {
549
- $baseurl .= implode(DIRECTORY_SEPARATOR, $old_file_name);
550
- $base_path .= implode("/", $old_file_name);
551
-
552
- $post_upload = implode("/", $old_file_name);
553
- }
554
- }
555
-
556
- $upload_dir = array();
557
- $upload_dir['path'] = $base_path;
558
- $upload_dir['old_path'] = $old_path;
559
- $upload_dir['url'] = $baseurl;
560
- $upload_dir['old_url'] = $old_url;
561
-
562
- $this->upload_dir = $upload_dir;
563
-
564
- $this->old_file_path = $old_path . "/" . $file_parts['basename'];
565
-
566
- if (!is_dir($base_path)) {
567
- mkdir($base_path, 755, true);
568
- }
569
-
570
- if (is_dir($base_path)) {
571
-
572
- $file_array = explode(".", $file['name']);
573
- $file_ext = array_pop($file_array);
574
- $new_file_name = sanitize_title(implode(".", $file_array)).".".$file_ext;
575
- if($replacement_option == "replace_only_file") {
576
- $new_file_name = $db_file_name;
577
- }
578
-
579
- if(strtolower($new_file_name) != strtolower($file_parts['basename'])) {
580
- $new_file_name = $this->checkForFileName($new_file_name, $base_path . DIRECTORY_SEPARATOR);
581
- }
582
-
583
- $this->new_file_path = $base_path . DIRECTORY_SEPARATOR . $new_file_name;
584
-
585
- $status = move_uploaded_file($new_file, $this->new_file_path);
586
-
587
- $this->new_file_url = trim($baseurl, "/")."/".$new_file_name;
588
-
589
- if ($status) {
590
- $old_file_path = str_replace(array("/",DIRECTORY_SEPARATOR), array("", ""), $this->old_file_path);
591
- $new_file_path = str_replace(array("/",DIRECTORY_SEPARATOR), array("", ""), $this->new_file_path);
592
- if($old_file_path != $new_file_path) {
593
- if(file_exists($this->old_file_path)) {
594
- @unlink($this->old_file_path);
595
- }
596
- }
597
-
598
- update_attached_file($attachment->ID, $this->new_file_url);
599
-
600
- $update_array = array();
601
- $update_array['ID'] = $attachment->ID;
602
- $update_array['guid'] = $this->new_file_url; //wp_get_attachment_url($this->post_id);
603
- $update_array['post_mime_type'] = $file['type'];
604
-
605
- $current_date = date("Y-m-d H:i:s");
606
- $current_date_gmt = date_i18n("Y-m-d H:i:s", strtotime($current_date));
607
- if(isset($_REQUEST['date_options']) && !empty($_REQUEST['date_options'])) {
608
- if($_REQUEST['date_options'] == "replace_date") {
609
- $update_array['post_date'] = $current_date;
610
- $update_array['post_date_gmt'] = $current_date_gmt;
611
- } else if($_REQUEST['date_options'] == "custom_date") {
612
- $custom_date = $_POST['custom_date'];
613
- $custom_hour = str_pad($_POST['custom_date_hour'],2,0, STR_PAD_LEFT);
614
- $custom_minute = str_pad($_POST['custom_date_min'], 2, 0, STR_PAD_LEFT);
615
- $custom_date = date("Y-m-d H:i:s", strtotime($custom_date." {$custom_hour}:{$custom_minute}"));
616
- if($custom_date !== false) {
617
- $datetime = date("Y-m-d H:i:s", strtotime($custom_date));
618
- $datetime_gmt = date_i18n("Y-m-d H:i:s", strtotime($datetime));
619
- $update_array['post_date'] = $datetime;
620
- $update_array['post_date_gmt'] = $datetime_gmt;
621
- }
622
- }
623
- }
624
- $update_array['post_modified'] = $current_date;
625
- $update_array['post_modified_gmt'] = $current_date_gmt;
626
- $post_id = \wp_update_post($update_array, true);
627
-
628
- update_post_meta( $attachment_id, '_wp_attached_file', trim(trim($post_upload, "/")."/".$new_file_name ), "/");
629
-
630
- // update post doesn't update GUID on updates.
631
- $wpdb->update($wpdb->posts, array('guid' => $this->new_file_url), array('ID' => $attachment->ID));
632
-
633
- $this->removeThumbImages();
634
-
635
- $metadata = wp_generate_attachment_metadata($attachment->ID, $this->new_file_path);
636
- wp_update_attachment_metadata($attachment->ID, $metadata);
637
-
638
- $this->new_image_meta = wp_get_attachment_metadata($attachment_id);
639
-
640
- // update_post_meta( $attachment_id, '_wp_attached_file', trim(trim($post_upload, "/")."/".$new_file_name ), "/");
641
-
642
- $this->searchAndReplace();
643
- wp_redirect(admin_url("post.php?post=" . $attachment_id . "&action=edit&premio_message=success&image_update=1"));
644
- exit;
645
- } else {
646
- wp_die("Error during uploading file");
647
- }
648
-
649
- } else {
650
- wp_die("Permission issue, Unable to create directory");
651
- }
652
- }
653
- }
654
- }
655
-
656
- /**
657
- * Check for filename
658
- *
659
- * @since 2.6.3
660
- * @access public
661
- *
662
- */
663
- public function checkForFileName($fileName, $filePath, $postFix = 0) {
664
- $new_file_name = $fileName;
665
- if(!empty($postFix)) {
666
- $file_array = explode(".", $fileName);
667
- $file_ext = array_pop($file_array);
668
- $new_file_name = implode(".", $file_array)."-".$postFix.".".$file_ext;
669
- }
670
- if(!file_exists($filePath.$new_file_name)) {
671
- return $new_file_name;
672
- }
673
- return $this->checkForFileName($fileName, $filePath, ($postFix+1));
674
- }
675
-
676
- public $replace_items = array();
677
-
678
-
679
- /**
680
- * Check and Remove Thumb image in wp-content
681
- *
682
- * @since 2.6.3
683
- * @access public
684
- *
685
- */
686
- public function removeThumbImages() {
687
- if(!empty($this->old_image_meta) && isset($this->old_image_meta['sizes']) && !empty($this->upload_dir) && isset($this->upload_dir['path'])) {
688
- $path = $this->upload_dir['path'].DIRECTORY_SEPARATOR;
689
- foreach ($this->old_image_meta['sizes'] as $image) {
690
- if(file_exists($path.$image['file'])) {
691
- @unlink($path . $image['file']);
692
- }
693
- }
694
- }
695
- }
696
-
697
- /**
698
- * Search and Replace files in Database
699
- *
700
- * @since 2.6.3
701
- * @access public
702
- * @return $string
703
- *
704
- */
705
- public function searchAndReplace() {
706
- if (wp_attachment_is('image', $this->attachment_id)) {
707
- $this->is_new_image = 1;
708
- }
709
- if($this->old_file_url != $this->new_file_url) {
710
- $replace = array(
711
- 'search' => $this->old_file_url,
712
- 'replace' => $this->new_file_url,
713
- );
714
- $this->replace_items[] = $replace;
715
- }
716
-
717
- $base_url = $this->upload_dir['url'];
718
- $base_url = trim($base_url, "/")."/";
719
- $new_url = $this->new_file_url;
720
-
721
- if(isset($this->old_image_meta['sizes']) && !empty($this->old_image_meta['sizes'])) {
722
- if(!isset($this->new_image_meta['sizes']) || empty($this->new_image_meta['sizes'])) {
723
- foreach ($this->old_image_meta['sizes'] as $key=>$image) {
724
- $replace = array(
725
- 'search' => $base_url.$image['file'],
726
- 'replace' => $new_url,
727
- );
728
- $this->replace_items[] = $replace;
729
- }
730
- } else if(isset($this->new_image_meta['sizes']) && !empty($this->new_image_meta['sizes'])) {
731
- $new_size = $this->new_image_meta['sizes'];
732
- foreach ($this->old_image_meta['sizes'] as $key=>$image) {
733
- $new_replace_url = $new_url;
734
- if(isset($new_size[$key])) {
735
- $new_replace_url = $base_url.$new_size[$key]['file'];
736
- }
737
- $replace = array(
738
- 'search' => $base_url.$image['file'],
739
- 'replace' => $new_replace_url,
740
- );
741
- $this->replace_items[] = $replace;
742
- }
743
- }
744
- }
745
-
746
- if(!empty($this->replace_items)) {
747
- $replace_items = array();
748
- foreach($this->replace_items as $args) {
749
- if($args['search'] != $args['replace']) {
750
- $replace_items[] = $args;
751
- }
752
- }
753
- $this->replace_items = $replace_items;
754
- $this->replaceURL();
755
- }
756
- }
757
-
758
- /**
759
- * Replace URL in Database tables
760
- *
761
- * @since 2.6.3
762
- * @access public
763
- * @return $string
764
- *
765
- */
766
- function replaceURL() {
767
- /* check in post content */
768
- $this->checkInPostContent();
769
-
770
- /* check in options */
771
- $this->checkInOptions();
772
-
773
- /* check in meta */
774
- $this->checkInMetaData();
775
-
776
- if(function_exists('folders_clear_all_caches')) {
777
- folders_clear_all_caches();
778
- }
779
- }
780
-
781
- /**
782
- * Checking image URLs in Post Content
783
- *
784
- * @since 2.6.3
785
- * @access public
786
- * @return $string
787
- *
788
- */
789
- function checkInPostContent() {
790
- global $wpdb;
791
- $post_table = $wpdb->prefix."posts";
792
- if(!empty($this->replace_items)) {
793
- $query = "SELECT ID, post_content FROM {$post_table} WHERE post_content LIKE %s";
794
- $update_query = "UPDATE {$post_table} SET post_content = %s WHERE ID = %d";
795
- foreach ($this->replace_items as $args) {
796
- if($args['search'] != $args['replace']) {
797
- $sql_query = $wpdb->prepare($query, "%".$args['search']."%");
798
- $results = $wpdb->get_results($sql_query, ARRAY_A );
799
- if(!empty($results)) {
800
- foreach ($results AS $row) {
801
- $content = $this->findAndReplaceContent($row['post_content'], $args['search'], $args['replace']);
802
- $update_post_query = $wpdb->prepare($update_query, $content, $row['ID']);
803
- $result = $wpdb->query($update_post_query);
804
- }
805
- }
806
- }
807
- }
808
- }
809
- }
810
-
811
- /**
812
- * Checking image URLs in MetaData
813
- *
814
- * @since 2.6.3
815
- * @access public
816
- * @return $string
817
- *
818
- */
819
- function checkInOptions() {
820
- global $wpdb;
821
- $post_table = $wpdb->prefix."options";
822
- if(!empty($this->replace_items)) {
823
- $query = "SELECT option_id, option_value FROM {$post_table} WHERE option_value LIKE %s";
824
- $update_query = "UPDATE {$post_table} SET option_value = %s WHERE option_id = %d";
825
- foreach ($this->replace_items as $args) {
826
- if($args['search'] != $args['replace']) {
827
- $sql_query = $wpdb->prepare($query, "%".$args['search']."%");
828
- $results = $wpdb->get_results($sql_query, ARRAY_A );
829
- if(!empty($results)) {
830
- foreach ($results AS $row) {
831
- $content = $this->findAndReplaceContent($row['post_content'], $args['search'], $args['replace']);
832
- $update_post_query = $wpdb->prepare($update_query, $content, $row['ID']);
833
- $result = $wpdb->query($update_post_query);
834
- }
835
- }
836
- }
837
- }
838
- }
839
- }
840
-
841
- /**
842
- * Checking image URLs in MetaData
843
- *
844
- * @since 2.6.3
845
- * @access public
846
- * @return $string
847
- *
848
- */
849
- function checkInMetaData() {
850
- $tables = array(
851
- array(
852
- 'table_name' => 'usermeta',
853
- 'primary_key' => 'umeta_id',
854
- 'search_key' => 'meta_value'
855
- ),
856
- array(
857
- 'table_name' => 'termmeta',
858
- 'primary_key' => 'meta_id',
859
- 'search_key' => 'meta_value'
860
- ),
861
- array(
862
- 'table_name' => 'postmeta',
863
- 'primary_key' => 'meta_id',
864
- 'search_key' => 'meta_value'
865
- ),
866
- array(
867
- 'table_name' => 'commentmeta',
868
- 'primary_key' => 'meta_id',
869
- 'search_key' => 'meta_value'
870
- )
871
- );
872
- global $wpdb;
873
- foreach ($tables as $table) {
874
- $post_table = $wpdb->prefix . $table['table_name'];
875
- if (!empty($this->replace_items)) {
876
- $query = "SELECT {$table['primary_key']}, {$table['search_key']} FROM {$post_table} WHERE {$table['search_key']} LIKE %s";
877
- $update_query = "UPDATE {$post_table} SET {$table['search_key']} = %s WHERE {$table['primary_key']} = %d";
878
- foreach ($this->replace_items as $args) {
879
- if ($args['search'] != $args['replace']) {
880
- $sql_query = $wpdb->prepare($query, "%" . $args['search'] . "%");
881
- $results = $wpdb->get_results($sql_query, ARRAY_A);
882
- if (!empty($results)) {
883
- foreach ($results as $row) {
884
- $content = $this->findAndReplaceContent($row[$table['search_key']], $args['search'], $args['replace']);
885
- $update_post_query = $wpdb->prepare($update_query, $content, $row[$table['primary_key']]);
886
- $result = $wpdb->query($update_post_query);
887
- }
888
- }
889
- }
890
- }
891
- }
892
- }
893
- }
894
-
895
- /**
896
- * Checking for Array Key
897
- *
898
- * @since 2.6.3
899
- * @access public
900
- * @return $json
901
- * Forked from Enable Media Replace
902
- *
903
- */
904
- function findAndReplaceContent($content, $search, $replace, $depth = false) {
905
- $content = maybe_unserialize($content);
906
-
907
- // Checking for JSON Data
908
- $isJson = $this->isJSON($content);
909
- if ($isJson) {
910
- $content = json_decode($content);
911
- }
912
-
913
- // Replace content if content is String
914
- if (is_string($content)) {
915
- $content = str_replace($search, $replace, $content);
916
- }
917
- else if(is_wp_error($content)) { // Return if error in data
918
-
919
- }
920
- else if(is_array($content)) { // Replace content if content is Array
921
- foreach($content as $index => $value) {
922
- $content[$index] = $this->findAndReplaceContent($value, $search, $replace, true);
923
- if (is_string($index)) {
924
- $index_replaced = $this->findAndReplaceContent($index, $search, $replace, true);
925
- if ($index_replaced !== $index)
926
- $content = $this->changeArrayKey($content, array($index => $index_replaced));
927
- }
928
- }
929
- }
930
- else if(is_object($content)) { // Replace content if content is Object
931
- foreach($content as $key => $value) {
932
- $content->{$key} = $this->findAndReplaceContent($value, $search, $replace, true);
933
- }
934
- }
935
-
936
- if ($isJson && $depth === false) {
937
- $content = json_encode($content, JSON_UNESCAPED_SLASHES);
938
- }
939
- else if($depth === false && (is_array($content) || is_object($content))) {
940
- $content = maybe_serialize($content);
941
- }
942
-
943
- return $content;
944
- }
945
-
946
- /**
947
- * Checking for Array Key
948
- *
949
- * @since 2.6.3
950
- * @access public
951
- * @return $json
952
- *
953
- */
954
- function changeArrayKey($array, $set) {
955
- if (is_array($array) && is_array($set)) {
956
- $newArray = array();
957
- foreach ($array as $k => $v) {
958
- $key = array_key_exists( $k, $set) ? $set[$k] : $k;
959
- $newArray[$key] = is_array($v) ? $this->changeArrayKey($v, $set) : $v;
960
- }
961
- return $newArray;
962
- }
963
- return $array;
964
- }
965
-
966
- /**
967
- * Check if it is JSON or not
968
- *
969
- * @since 2.6.3
970
- * @access public
971
- * Forked from Enable Media Replace
972
- * @return $json
973
- *
974
- */
975
- function isJSON($content)
976
- {
977
- if (is_array($content) || is_object($content))
978
- return false;
979
-
980
- $json = json_decode($content);
981
- return $json && $json != $content;
982
- }
983
- }
984
- $folders_replace_media = new folders_replace_media();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Folders Replace Media
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ class folders_replace_media
14
+ {
15
+
16
+ /**
17
+ * Button Color
18
+ *
19
+ * @var string $buttonColor Replacement Button Color
20
+ * @since 1.0.0
21
+ * @access public
22
+ */
23
+ public $buttonColor;
24
+
25
+ /**
26
+ * Is Replacement functionality enabled or not
27
+ *
28
+ * @var string $isEnabled Replacement Functionality Status
29
+ * @since 1.0.0
30
+ * @access public
31
+ */
32
+ public $isEnabled = false;
33
+
34
+ /**
35
+ * Folders Upgrade Link
36
+ *
37
+ * @var string $upgradeLink Upgrade Link
38
+ * @since 1.0.0
39
+ * @access public
40
+ */
41
+ public $upgradeLink;
42
+
43
+ /**
44
+ * Old file path
45
+ *
46
+ * @var string $oldFilePath Old File Path
47
+ * @since 1.0.0
48
+ * @access public
49
+ */
50
+ public $oldFilePath;
51
+
52
+ /**
53
+ * Old file URL
54
+ *
55
+ * @var string $oldFilePath Old File URL
56
+ * @since 1.0.0
57
+ * @access public
58
+ */
59
+ public $oldFileURL;
60
+
61
+ /**
62
+ * New file Path
63
+ *
64
+ * @var string $newFilePath New File Path
65
+ * @since 1.0.0
66
+ * @access public
67
+ */
68
+ public $newFilePath;
69
+
70
+ /**
71
+ * New file URL
72
+ *
73
+ * @var string $newFilePath New File URL
74
+ * @since 1.0.0
75
+ * @access public
76
+ */
77
+ public $newFileURL;
78
+
79
+ /**
80
+ * Mode for file Replacement
81
+ *
82
+ * @var string $mode New File URL
83
+ * @since 1.0.0
84
+ * @access public
85
+ */
86
+ public $mode = "rename-file";
87
+
88
+ /**
89
+ * Old image Meta Array
90
+ *
91
+ * @var array $oldImageMeta Old image Meta Array
92
+ * @since 1.0.0
93
+ * @access public
94
+ */
95
+ public $oldImageMeta;
96
+
97
+ /**
98
+ * New image Meta Array
99
+ *
100
+ * @var array $newImageMeta New image Meta Array
101
+ * @since 1.0.0
102
+ * @access public
103
+ */
104
+ public $newImageMeta;
105
+
106
+ /**
107
+ * WordPress Upload Dir Path
108
+ *
109
+ * @var string $uploadDir WordPress Upload Dir Path
110
+ * @since 1.0.0
111
+ * @access public
112
+ */
113
+ public $uploadDir;
114
+
115
+ /**
116
+ * Check if old file is image
117
+ *
118
+ * @var string $isOldImage Old file status
119
+ * @since 1.0.0
120
+ * @access public
121
+ */
122
+ public $isOldImage = 0;
123
+
124
+ /**
125
+ * Check if uploaded file is image
126
+ *
127
+ * @var string $isNewImage New file status
128
+ * @since 1.0.0
129
+ * @access public
130
+ */
131
+ public $isNewImage = 0;
132
+
133
+ /**
134
+ * Attachment ID for Replacement file
135
+ *
136
+ * @var string $attachment_id Attachment ID
137
+ * @since 1.0.0
138
+ * @access public
139
+ */
140
+ public $attachment_id;
141
+
142
+ /**
143
+ * Collection of Replacement Items
144
+ *
145
+ * @var array $replaceItems Replacement Items
146
+ * @since 1.0.0
147
+ * @access public
148
+ */
149
+ public $replaceItems = [];
150
+
151
+
152
+ /**
153
+ * Define the core functionality of the replacement functionality.
154
+ *
155
+ * Set Button Color
156
+ * Check for Functionality is enabled or not
157
+ * Show Replacement form, Success message
158
+ *
159
+ * @since 1.0.0
160
+ */
161
+ function __construct()
162
+ {
163
+
164
+ $customizeFolders = get_option('customize_folders');
165
+
166
+ $this->buttonColor = isset($customizeFolders['media_replace_button']) ? $customizeFolders['media_replace_button'] : "#FA166B";
167
+
168
+ $this->isEnabled = isset($customizeFolders['folders_enable_replace_media']) ? $customizeFolders['folders_enable_replace_media'] : "yes";
169
+
170
+ $this->isEnabled = ($this->isEnabled == "yes") ? true : false;
171
+
172
+ if ($this->isEnabled) {
173
+ add_action('admin_menu', [$this, 'admin_menu']);
174
+
175
+ add_filter('media_row_actions', [$this, 'add_media_action'], 10, 2);
176
+
177
+ add_action(
178
+ 'add_meta_boxes',
179
+ function () {
180
+ add_meta_box('folders-replace-box', esc_html__('Replace Media', 'folders'), [$this, 'replace_meta_box'], 'attachment', 'side', 'low');
181
+ }
182
+ );
183
+ add_filter('attachment_fields_to_edit', [$this, 'attachment_editor'], 10, 2);
184
+
185
+ add_action('admin_enqueue_scripts', [$this, 'folders_admin_css_and_js']);
186
+
187
+ add_action('admin_init', [$this, 'handle_folders_file_upload']);
188
+ }
189
+
190
+ $customizeFolders = get_option("customize_folders");
191
+ if (isset($customizeFolders['show_folder_in_settings']) && $customizeFolders['show_folder_in_settings'] == "yes") {
192
+ $this->upgradeLink = admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
193
+ } else {
194
+ $this->upgradeLink = admin_url("admin.php?page=folders-upgrade-to-pro");
195
+ }
196
+
197
+ // to replace file name
198
+ add_action(
199
+ 'add_meta_boxes',
200
+ function () {
201
+ add_meta_box('folders-replace-file-name', esc_html__('Change file name', 'folders'), [$this, 'change_file_name_box'], 'attachment', 'side', 'core');
202
+ }
203
+ );
204
+
205
+ add_filter('attachment_fields_to_edit', [$this, 'attachment_replace_name_with_title'], 10, 2);
206
+
207
+ add_action('admin_head', [$this, 'premio_replace_file_CSS']);
208
+
209
+ add_action('wp_enqueue_media', [$this, 'replace_media_file_script']);
210
+
211
+ add_action('admin_notices', [$this, 'admin_notices']);
212
+
213
+ }//end __construct()
214
+
215
+
216
+ /**
217
+ * Add admin notice
218
+ *
219
+ * @since 2.6.3
220
+ * @access public
221
+ */
222
+ public function admin_notices()
223
+ {
224
+ if (isset($_REQUEST['premio_message']) && $_REQUEST['premio_message'] == "success") { ?>
225
+ <div class="notice notice-success is-dismissible">
226
+ <p><b><?php esc_html_e('File successfully replaced', 'folders'); ?></b></p>
227
+ <p><?php esc_html_e('The file has been successfully replaced using the file replacement feature', 'folders'); ?></p>
228
+ </div>
229
+
230
+ <style>
231
+ .folders-undo-notification {
232
+ position: fixed;
233
+ right: -500px;
234
+ bottom: 25px;
235
+ width: 280px;
236
+ background: #fff;
237
+ padding: 15px;
238
+ -webkit-box-shadow: 0 3px 6px -4px rgb(0 0 0 / 12%), 0 6px 16px 0 rgb(0 0 0 / 8%), 0 9px 28px 8px rgb(0 0 0 / 5%);
239
+ box-shadow: 0 3px 6px -4px rgb(0 0 0 / 12%), 0 6px 16px 0 rgb(0 0 0 / 8%), 0 9px 28px 8px rgb(0 0 0 / 5%);
240
+ transition: all .25s linear;
241
+ z-index: 250010;
242
+ }
243
+ .folders-undo-body {
244
+ position: relative;
245
+ font-size: 13px;
246
+ padding: 0 0 5px 0;
247
+ }
248
+ .close-undo-box {
249
+ position: absolute;
250
+ right: -10px;
251
+ top: 0;
252
+ width: 16px;
253
+ height: 16px;
254
+ transition: all .25s linear;
255
+ }
256
+ .close-undo-box span {
257
+ display: block;
258
+ position: relative;
259
+ width: 16px;
260
+ height: 16px;
261
+ transition: all .2s linear;
262
+ }
263
+ .close-undo-box span:after, .close-undo-box span:before {
264
+ content: "";
265
+ position: absolute;
266
+ width: 12px;
267
+ height: 2px;
268
+ background-color: #333;
269
+ display: block;
270
+ border-radius: 2px;
271
+ transform: rotate(45deg);
272
+ top: 7px;
273
+ left: 2px;
274
+ }
275
+ .close-undo-box span:after {
276
+ transform: rotate(-45deg);
277
+ }
278
+ .folders-undo-header {
279
+ font-weight: 500;
280
+ font-size: 14px;
281
+ padding: 0 0 3px 0;
282
+ color: #014737;
283
+ }
284
+ .folders-undo-notification.success {
285
+ border-left: solid 3px #70C6A3;
286
+ }
287
+ html[dir="rtl"] .folders-undo-notification {
288
+ right: auto;
289
+ left: -500px
290
+ }
291
+ html[dir="rtl"] .folders-undo-notification.active {
292
+ left: 25px;
293
+ }
294
+ html[dir="rtl"] .folders-undo-notification.success {
295
+ border-left: none;
296
+ border-right: solid 3px #70C6A3;
297
+ }
298
+ html[dir="rtl"] .close-undo-box {
299
+ right: auto;
300
+ left: -10px;
301
+ }
302
+ </style>
303
+ <div class="folders-undo-notification success" id="media-success">
304
+ <div class="folders-undo-body">
305
+ <a href="javascript:;" class="close-undo-box"><span></span></a>
306
+ <div class="folders-undo-header"><?php esc_html_e('File successfully replaced', 'folders'); ?></div>
307
+ <div class="folders-undo-body" style="padding:0"><?php esc_html_e('The file has been successfully replaced using the file replacement feature', 'folders'); ?></div>
308
+ </div>
309
+ </div>
310
+ <script>
311
+ jQuery(document).ready(function(){
312
+ jQuery("#media-success").addClass("active");
313
+ setTimeout(function(){
314
+ jQuery("#media-success").removeClass("active");
315
+ }, 5000);
316
+
317
+ jQuery(document).on("click", ".close-undo-box", function(){
318
+ jQuery("#media-success").removeClass("active");
319
+ });
320
+ });
321
+ </script>
322
+ <?php }//end if
323
+
324
+ }//end admin_notices()
325
+
326
+
327
+ /**
328
+ * Add Metabox to replace file name with title
329
+ *
330
+ * @since 2.6.3
331
+ * @access public
332
+ */
333
+ public function change_file_name_box($post)
334
+ {
335
+ ?>
336
+ <p class="upgrade-bottom">
337
+ <label for="change_file_name"><input disabled type="checkbox" id="change_file_name" name="premio_change_file_name" value="yes"> <?php esc_html_e("Change file name according to title", "folders") ?></label>
338
+ </p>
339
+ <div class="upgrade-box">
340
+ <a href="<?php echo esc_url($this->upgradeLink) ?>" target="_blank"><?php esc_html_e("Upgrade to Pro", "folders"); ?></a>
341
+ </div>
342
+ <?php
343
+
344
+ }//end change_file_name_box()
345
+
346
+
347
+ /**
348
+ * Add Js and CSS files for replace file name with title
349
+ *
350
+ * @since 2.6.3
351
+ * @access public
352
+ */
353
+ public function replace_media_file_script()
354
+ {
355
+ wp_enqueue_script('folders-replace-media', WCP_FOLDER_URL.'assets/js/replace-file-name.js', ['jquery'], WCP_FOLDER_VERSION, true);
356
+ wp_localize_script(
357
+ 'folders-replace-media',
358
+ 'replace_media_options',
359
+ [
360
+ 'ajax_url' => admin_url("admin-ajax.php"),
361
+ ]
362
+ );
363
+
364
+ }//end replace_media_file_script()
365
+
366
+
367
+ /**
368
+ * Add inline CSS code for file replacement
369
+ *
370
+ * @since 2.6.3
371
+ * @access public
372
+ */
373
+ public function premio_replace_file_CSS()
374
+ {
375
+ ?>
376
+ <style>
377
+ .compat-field-replace_file_name th.label {display: none;}
378
+ .compat-field-replace_file_name td.field {width: 100%; border-top: solid 1px #c0c0c0; padding:10px 0 0 0;margin: 0;float: none;}
379
+ .compat-field-replace_file_name td.field label {width: 100%; display: block;padding:0 0 10px 0;}
380
+ .compat-field-replace_file_name td.field label input[type="checkbox"] {margin: 0 4px 0 2px;}
381
+ .compat-field-replace_file_name td.field a.update-name-with-title {display: none;}
382
+ .compat-field-replace_file_name td.field a.update-name-with-title.show {display: inline-block;}
383
+
384
+ .compat-field-folders th.label {width: 100%; text-align: left; padding: 0 0 10px 0; margin: 0; border-top: solid 1px #c0c0c0;float: none;}
385
+ .compat-field-folders th.label .alignleft {float: none; text-align: left; font-weight: bold;}
386
+ .compat-field-folders th.label br {display: none;}
387
+ .compat-field-folders td.field {width: 100%; padding: 0; margin: 0;float: none;}
388
+ .folders-undo-notification{position:fixed;right:-500px;bottom:25px;width:280px;background:#fff;padding:15px;-webkit-box-shadow:0 3px 6px -4px rgb(0 0 0 / 12%),0 6px 16px 0 rgb(0 0 0 / 8%),0 9px 28px 8px rgb(0 0 0 / 5%);box-shadow:0 3px 6px -4px rgb(0 0 0 / 12%),0 6px 16px 0 rgb(0 0 0 / 8%),0 9px 28px 8px rgb(0 0 0 / 5%);transition:all .25s linear;z-index:250010}.folders-undo-notification.active{right:25px}.folders-undo-header{font-weight:500;font-size:14px;padding:0 0 3px 0}.folders-undo-body{font-size:13px;padding:0 0 5px 0}.folders-undo-footer{text-align:right;padding:5px 0 0 0}.folders-undo-footer .undo-button{background:#1da1f4;border:none;color:#fff;padding:3px 10px;font-size:12px;border-radius:2px;cursor:pointer}.folders-undo-body{position:relative}.close-undo-box{position:absolute;right:-10px;top:0;width:16px;height:16px;transition:all .25s linear}.close-undo-box:hover{transform:rotate(180deg)}.close-undo-box span{display:block;position:relative;width:16px;height:16px;transition:all .2s linear}.close-undo-box span:after,.close-undo-box span:before{content:"";position:absolute;width:12px;height:2px;background-color:#333;display:block;border-radius:2px;transform:rotate(45deg);top:7px;left:2px}.close-undo-box span:after{transform:rotate(-45deg)}
389
+ .folders-undo-notification.no .folders-undo-header { color: #dd0000; }
390
+ .folders-undo-notification.yes .folders-undo-header { color: #014737; }
391
+ .update-name-with-title .spinner {display: none; visibility: visible; margin-right: 0;}
392
+ .update-name-with-title.in-progress .spinner {display: inline-block;}
393
+
394
+ #folders-replace-file-name .inside {position: relative;padding:0;margin:0}
395
+ #folders-replace-file-name .inside p {padding: 1em; margin: 0;}
396
+ #folders-replace-file-name .upgrade-box {position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.3); z-index: 1;display: none;}
397
+ #folders-replace-file-name:hover .upgrade-box { display: block; }
398
+ #folders-replace-file-name:hover p {filter: blur(1.2px);}
399
+ #folders-replace-file-name:hover .upgrade-box a {display: inline-block; position: absolute; left: 0; right: 0; width: 100px; margin: 0 auto; top: 50%; padding: 5px 10px; text-decoration: none; background: #fa166b; color: #fff; border-radius: 4px; text-align: center; margin-top: -14px;}
400
+ </style> <?php
401
+
402
+ }//end premio_replace_file_CSS()
403
+
404
+
405
+ /**
406
+ * Replace file name with title
407
+ *
408
+ * @since 2.6.3
409
+ * @access public
410
+ */
411
+ public function attachment_replace_name_with_title($formFields, $post)
412
+ {
413
+ $screen = null;
414
+ if (function_exists('get_current_screen')) {
415
+ $screen = get_current_screen();
416
+
417
+ if (! is_null($screen) && $screen->id == 'attachment') {
418
+ // hide on edit attachment screen.
419
+ return $formFields;
420
+ }
421
+ }
422
+
423
+ $formFields["replace_file_name"] = [
424
+ "label" => esc_html__("Replace media", "folders"),
425
+ "input" => "html",
426
+ "html" => "<label for='attachment_title_".esc_attr($post->ID)."' data-post='".esc_attr($post->ID)."' data-nonce='".wp_create_nonce('change_attachment_title_'.$post->ID)."'><input id='attachment_title_".esc_attr($post->ID)."' type='checkbox' class='folder-replace-checkbox' value='".esc_attr($post->ID)."'>".esc_html__("Update file name with title")."</label><a href='".$this->upgradeLink."' target='_blank' style='background: ".esc_attr($this->buttonColor)."; border-color: ".esc_attr($this->buttonColor)."; color:#ffffff' type='button' class='button update-name-with-title' >".esc_html__("Upgrade to Pro", "folders")."</a>",
427
+ "helps" => "",
428
+ ];
429
+
430
+ return $formFields;
431
+
432
+ }//end attachment_replace_name_with_title()
433
+
434
+
435
+ /**
436
+ * Add Js and CSS files for replace file screen
437
+ *
438
+ * @since 2.6.3
439
+ * @access public
440
+ */
441
+ public function folders_admin_css_and_js($page)
442
+ {
443
+ if ($page == "media_page_folders-replace-media" || $page == "admin_page_folders-replace-media") {
444
+ wp_enqueue_style('folders-media', plugin_dir_url(dirname(__FILE__)).'assets/css/replace-media.css', [], WCP_FOLDER_VERSION);
445
+ wp_enqueue_script('folders-media', plugin_dir_url(dirname(__FILE__)).'assets/js/replace-media.js', [], WCP_FOLDER_VERSION);
446
+ }
447
+
448
+ }//end folders_admin_css_and_js()
449
+
450
+
451
+ /**
452
+ * Add file replace menu in admin
453
+ *
454
+ * @since 2.6.3
455
+ * @access public
456
+ * @return $string
457
+ */
458
+ public function admin_menu()
459
+ {
460
+ add_submenu_page(
461
+ null,
462
+ esc_html__("Replace media", "folders"),
463
+ esc_html__("Replace media", "folders"),
464
+ 'upload_files',
465
+ 'folders-replace-media',
466
+ [
467
+ $this,
468
+ 'folders_replace_media',
469
+ ]
470
+ );
471
+
472
+ }//end admin_menu()
473
+
474
+
475
+ /**
476
+ * Add file replacement screen
477
+ *
478
+ * @since 2.6.3
479
+ * @access public
480
+ * @return $string
481
+ */
482
+ public function folders_replace_media()
483
+ {
484
+ global $plugin_page;
485
+ $action = isset($_GET['action']) ? sanitize_text_field($_GET['action']) : '';
486
+ $attachment_id = isset($_GET['attachment_id']) ? sanitize_text_field($_GET['attachment_id']) : '';
487
+ $nonce = isset($_GET['nonce']) ? sanitize_text_field($_GET['nonce']) : '';
488
+ if (!wp_verify_nonce($nonce, "folders-replace-media-".$attachment_id)) {
489
+ echo 'Invalid Nonce';
490
+ exit;
491
+ }
492
+
493
+ $attachment = get_post($attachment_id);
494
+ if (empty($attachment) || !isset($attachment->guid)) {
495
+ echo 'Invalid URL';
496
+ exit;
497
+ }
498
+
499
+ $guid = $attachment->guid;
500
+ $guid = explode(".", $guid);
501
+ if ($guid == $attachment->guid) {
502
+ echo 'Invalid URL';
503
+ exit;
504
+ }
505
+
506
+ $form_action = $this->getMediaReplaceURL($attachment_id);
507
+ include_once dirname(dirname(__FILE__)).WCP_DS."/templates".WCP_DS."admin".WCP_DS."media-replace.php";
508
+
509
+ }//end folders_replace_media()
510
+
511
+
512
+ /**
513
+ * Add action for file replacement
514
+ *
515
+ * @since 2.6.3
516
+ * @access public
517
+ * @return $actions
518
+ */
519
+ public function add_media_action($actions, $post)
520
+ {
521
+ if (!$this->isEnabled) {
522
+ return array_merge($actions);
523
+ }
524
+
525
+ if (wp_attachment_is('image', $post->ID)) {
526
+ $link = $this->getMediaReplaceURL($post->ID);
527
+
528
+ $newaction['replace_media'] = '<a style="color: '.esc_attr($this->buttonColor).'" href="'.esc_url($link).'" rel="permalink">'.esc_html__("Replace media", "folders").'</a>';
529
+
530
+ return array_merge($actions, $newaction);
531
+ } else {
532
+ $link = $this->getMediaReplaceURL($post->ID);
533
+
534
+ $newaction['replace_media'] = '<a style="color: '.esc_attr($this->buttonColor).'" target="_blank" href="'.esc_url($this->upgradeLink).'" rel="permalink">'.esc_html__("Replace Media 🔑", "folders").'</a>';
535
+
536
+ return array_merge($actions, $newaction);
537
+ }
538
+
539
+ return $actions;
540
+
541
+ }//end add_media_action()
542
+
543
+
544
+ /**
545
+ * Get URL for file Replacement
546
+ *
547
+ * @since 2.6.3
548
+ * @access public
549
+ * @return $url
550
+ */
551
+ public function getMediaReplaceURL($attach_id)
552
+ {
553
+ $url = admin_url("upload.php");
554
+ $url = add_query_arg(
555
+ [
556
+ 'page' => 'folders-replace-media',
557
+ 'action' => 'folders_replace_media',
558
+ 'attachment_id' => $attach_id,
559
+ 'nonce' => wp_create_nonce("folders-replace-media-".$attach_id),
560
+ ],
561
+ $url
562
+ );
563
+
564
+ return $url;
565
+
566
+ }//end getMediaReplaceURL()
567
+
568
+
569
+ /**
570
+ * Get file size
571
+ *
572
+ * @since 2.6.3
573
+ * @access public
574
+ * @return $size
575
+ */
576
+ public function replace_meta_box($post)
577
+ {
578
+ if (wp_attachment_is('image', $post->ID)) {
579
+ $link = $this->getMediaReplaceURL($post->ID); ?>
580
+ <p><a style='background: <?php echo esc_attr($this->buttonColor) ?>; border-color: <?php echo esc_attr($this->buttonColor) ?>; color:#ffffff' href='<?php echo esc_url($link) ?>' class='button-secondary'><?php esc_html_e("Upload a new file", "folders") ?></a></p><p><?php esc_html_e("Click on the button to replace the file with another file", "folders") ?></p>
581
+ <?php } else { ?>
582
+ <p><a style='color: <?php echo esc_attr($this->buttonColor) ?>; font-weight: 500' target='_blank' href='<?php echo esc_url($this->upgradeLink) ?>' ><?php esc_html_e("Upgrade to Pro", "folders") ?></a><?php esc_html_e("to replace any kind of files while uploading including pdf/svg/docx/etc & more.", "folders") ?></p>
583
+ <?php }
584
+
585
+ }//end replace_meta_box()
586
+
587
+
588
+ /**
589
+ * Get file size
590
+ *
591
+ * @since 2.6.3
592
+ * @access public
593
+ * @return $size
594
+ */
595
+ public function attachment_editor($formFields, $post)
596
+ {
597
+ $screen = null;
598
+ if (function_exists('get_current_screen')) {
599
+ $screen = get_current_screen();
600
+
601
+ if (! is_null($screen) && $screen->id == 'attachment') {
602
+ // hide on edit attachment screen.
603
+ return $formFields;
604
+ }
605
+ }
606
+
607
+ if (wp_attachment_is('image', $post->ID)) {
608
+ $link = $this->getMediaReplaceURL($post->ID);
609
+ $formFields["folders"] = [
610
+ "label" => esc_html__("Replace media", "folders"),
611
+ "input" => "html",
612
+ "html" => "<a style='background: ".esc_attr($this->buttonColor)."; border-color: ".esc_attr($this->buttonColor)."; color:#ffffff' href='".esc_url($link)."' class='button-secondary'>".esc_html__("Upload a new file", "folders")."</a>",
613
+ "helps" => esc_html__("Click on the button to replace the file with another file", "folders"),
614
+ ];
615
+ } else {
616
+ $formFields["folders"] = [
617
+ "label" => esc_html__("Replace media", "folders"),
618
+ "input" => "html",
619
+ "html" => "<div style='border: solid 1px #c0c0c0; padding: 10px; border-radius: 2px; background: #ececec;'><a style='color: ".esc_attr($this->buttonColor)."; font-weight: 500' target='_blank' href='".esc_url($this->upgradeLink)."' >".esc_html__("Upgrade to Pro", "folders")."</a> ".esc_html__("to replace media files other than images", "folders")."</div>",
620
+ "helps" => esc_html__("Click on the button to replace the file with another file", "folders"),
621
+ ];
622
+ }
623
+
624
+ return $formFields;
625
+
626
+ }//end attachment_editor()
627
+
628
+
629
+ /**
630
+ * Get file size
631
+ *
632
+ * @since 2.6.3
633
+ * @access public
634
+ * @return $size
635
+ */
636
+ public function getFileSize($attachment_id)
637
+ {
638
+ $size = filesize(get_attached_file($attachment_id));
639
+ if ($size > 1000000) {
640
+ $size = ($size / 1000000);
641
+ return number_format((float) $size, 2, ".", ",")." MB";
642
+ } else if ($size > 1000) {
643
+ $size = ($size / 1000);
644
+ return number_format((float) $size, 2, ".", ",")." KB";
645
+ }
646
+
647
+ return $size." B";
648
+
649
+ }//end getFileSize()
650
+
651
+
652
+ /**
653
+ * Upload file and Replace it
654
+ *
655
+ * @since 2.6.3
656
+ * @access public
657
+ */
658
+ public function handle_folders_file_upload()
659
+ {
660
+ global $wpdb;
661
+ if (isset($_FILES['new_media_file'])) {
662
+ if ($_FILES['new_media_file']['error'] == 0) {
663
+ $attachment_id = sanitize_text_field(filter_input(INPUT_GET, "attachment_id"));
664
+ $nonce = sanitize_text_field(filter_input(INPUT_GET, "nonce"));
665
+ if (!wp_verify_nonce($nonce, "folders-replace-media-".$attachment_id)) {
666
+ return;
667
+ }
668
+
669
+ $attachment = get_post($attachment_id);
670
+ if (empty($attachment) || !isset($attachment->guid)) {
671
+ return;
672
+ }
673
+
674
+ $attachment_url = $attachment->guid;
675
+ $url = wp_get_attachment_url($attachment_id);
676
+ if (!empty($url)) {
677
+ $attachment_url = $url;
678
+ }
679
+
680
+ $guid = explode(".", $attachment_url);
681
+ $guid = array_pop($guid);
682
+ if ($guid == $attachment->guid) {
683
+ return;
684
+ }
685
+
686
+ $replacement_option = isset($_REQUEST['replacement_option']) ? sanitize_text_field($_REQUEST['replacement_option']) : "replace_only_file";
687
+
688
+ $this->attachment_id = $attachment_id;
689
+
690
+ $file = $_FILES['new_media_file'];
691
+ $file_name = $file['name'];
692
+ $file_ext = explode(".", $file_name);
693
+ $file_ext = array_pop($file_ext);
694
+
695
+ if (wp_attachment_is('image', $attachment_id)) {
696
+ $this->isOldImage = 1;
697
+ }
698
+
699
+ $this->oldFileURL = $attachment_url;
700
+ $this->oldImageMeta = wp_get_attachment_metadata($attachment_id);
701
+
702
+ $new_file = $file['tmp_name'];
703
+
704
+ $file_parts = pathinfo($attachment_url);
705
+
706
+ $db_file_name = $file_parts['basename'];
707
+ $db_file_array = explode(".", $db_file_name);
708
+ array_pop($db_file_array);
709
+ $db_file_name = implode(".", $db_file_array).".";
710
+ $db_file_name .= $file_ext;
711
+
712
+ $wp_upload_path = wp_get_upload_dir();
713
+
714
+ $base_path = $old_path = $wp_upload_path['basedir'].DIRECTORY_SEPARATOR;
715
+ $baseurl = $old_url = $wp_upload_path['baseurl']."/";
716
+
717
+ $post_upload = "";
718
+
719
+ $wp_attached_file = get_post_meta($attachment_id, "_wp_attached_file", true);
720
+ if ($wp_attached_file !== false) {
721
+ $old_file_name = explode("/", $wp_attached_file);
722
+ array_pop($old_file_name);
723
+
724
+ if (count($old_file_name) > 0) {
725
+ $old_path .= implode(DIRECTORY_SEPARATOR, $old_file_name);
726
+ $old_url .= implode("/", $old_file_name);
727
+ }
728
+
729
+ if ($replacement_option == "replace_file_with_name" && isset($_REQUEST['new_folder_option']) && $_REQUEST['new_folder_option'] && isset($_REQUEST['new_folder_path']) && !empty($_REQUEST['new_folder_path'])) {
730
+ $baseurl .= sanitize_text_field($_REQUEST['new_folder_path']);
731
+ $base_path .= str_replace("/", DIRECTORY_SEPARATOR, sanitize_text_field($_REQUEST['new_folder_path']));
732
+ $post_upload = sanitize_text_field($_REQUEST['new_folder_path']);
733
+ } else if (count($old_file_name) > 0) {
734
+ $baseurl .= implode(DIRECTORY_SEPARATOR, $old_file_name);
735
+ $base_path .= implode("/", $old_file_name);
736
+ $post_upload = implode("/", $old_file_name);
737
+ }
738
+ }
739
+
740
+ $uploadDir = [];
741
+ $uploadDir['path'] = $base_path;
742
+ $uploadDir['old_path'] = $old_path;
743
+ $uploadDir['url'] = $baseurl;
744
+ $uploadDir['old_url'] = $old_url;
745
+
746
+ $this->uploadDir = $uploadDir;
747
+
748
+ $this->oldFilePath = $old_path."/".$file_parts['basename'];
749
+
750
+ if (!is_dir($base_path)) {
751
+ mkdir($base_path, 755, true);
752
+ }
753
+
754
+ if (is_dir($base_path)) {
755
+ $file_array = explode(".", $file['name']);
756
+ $file_ext = array_pop($file_array);
757
+ $new_file_name = sanitize_title(implode(".", $file_array)).".".$file_ext;
758
+ if ($replacement_option == "replace_only_file") {
759
+ $new_file_name = $db_file_name;
760
+ }
761
+
762
+ if (strtolower($new_file_name) != strtolower($file_parts['basename'])) {
763
+ $new_file_name = $this->checkForFileName($new_file_name, $base_path.DIRECTORY_SEPARATOR);
764
+ }
765
+
766
+ $this->newFilePath = $base_path.DIRECTORY_SEPARATOR.$new_file_name;
767
+
768
+ $status = move_uploaded_file($new_file, $this->newFilePath);
769
+
770
+ $this->newFileURL = trim($baseurl, "/")."/".$new_file_name;
771
+
772
+ if ($status) {
773
+ $oldFilePath = str_replace(["/", DIRECTORY_SEPARATOR], ["", ""], $this->oldFilePath);
774
+ $newFilePath = str_replace(["/", DIRECTORY_SEPARATOR], ["", ""], $this->newFilePath);
775
+ if ($oldFilePath != $newFilePath) {
776
+ if (file_exists($this->oldFilePath)) {
777
+ @unlink($this->oldFilePath);
778
+ }
779
+ }
780
+
781
+ update_attached_file($attachment->ID, $this->newFileURL);
782
+
783
+ $update_array = [];
784
+ $update_array['ID'] = $attachment->ID;
785
+ $update_array['guid'] = $this->newFileURL;
786
+ // wp_get_attachment_url($this->post_id);
787
+ $update_array['post_mime_type'] = $file['type'];
788
+
789
+ $current_date = date("Y-m-d H:i:s");
790
+ $current_date_gmt = date_i18n("Y-m-d H:i:s", strtotime($current_date));
791
+ if (isset($_REQUEST['date_options']) && !empty($_REQUEST['date_options'])) {
792
+ if ($_REQUEST['date_options'] == "replace_date") {
793
+ $update_array['post_date'] = $current_date;
794
+ $update_array['post_date_gmt'] = $current_date_gmt;
795
+ } else if ($_REQUEST['date_options'] == "custom_date") {
796
+ $custom_date = filter_input(INPUT_POST, "custom_date");
797
+ $custom_date_hour = filter_input(INPUT_POST, "custom_date_hour");
798
+ $custom_hour = str_pad($custom_date_hour, 2, 0, STR_PAD_LEFT);
799
+ $custom_date_min = filter_input(INPUT_POST, "custom_date_min");
800
+ $custom_minute = str_pad($custom_date_min, 2, 0, STR_PAD_LEFT);
801
+ $custom_date = date("Y-m-d H:i:s", strtotime($custom_date." ".$custom_hour.":".$custom_minute));
802
+ if ($custom_date !== false) {
803
+ $datetime = date("Y-m-d H:i:s", strtotime($custom_date));
804
+ $datetime_gmt = date_i18n("Y-m-d H:i:s", strtotime($datetime));
805
+ $update_array['post_date'] = $datetime;
806
+ $update_array['post_date_gmt'] = $datetime_gmt;
807
+ }
808
+ }
809
+ }
810
+
811
+ $update_array['post_modified'] = $current_date;
812
+ $update_array['post_modified_gmt'] = $current_date_gmt;
813
+ $post_id = \wp_update_post($update_array, true);
814
+
815
+ update_post_meta($attachment_id, '_wp_attached_file', trim(trim($post_upload, "/")."/".$new_file_name, "/"));
816
+
817
+ // update post doesn't update GUID on updates.
818
+ $wpdb->update($wpdb->posts, ['guid' => $this->newFileURL], ['ID' => $attachment->ID]);
819
+
820
+ $this->removeThumbImages();
821
+
822
+ $metadata = wp_generate_attachment_metadata($attachment->ID, $this->newFilePath);
823
+ wp_update_attachment_metadata($attachment->ID, $metadata);
824
+
825
+ $this->newImageMeta = wp_get_attachment_metadata($attachment_id);
826
+
827
+ // update_post_meta( $attachment_id, '_wp_attached_file', trim(trim($post_upload, "/")."/".$new_file_name ), "/");
828
+ $this->searchAndReplace();
829
+ wp_redirect(admin_url("post.php?post=".esc_attr($attachment_id)."&action=edit&premio_message=success&image_update=1"));
830
+ exit;
831
+ } else {
832
+ wp_die("Error during uploading file");
833
+ }//end if
834
+ } else {
835
+ wp_die("Permission issue, Unable to create directory");
836
+ }//end if
837
+ }//end if
838
+ }//end if
839
+
840
+ }//end handle_folders_file_upload()
841
+
842
+
843
+ /**
844
+ * Check for filename
845
+ *
846
+ * @since 2.6.3
847
+ * @access public
848
+ */
849
+ public function checkForFileName($fileName, $filePath, $postFix=0)
850
+ {
851
+ $new_file_name = $fileName;
852
+ if (!empty($postFix)) {
853
+ $file_array = explode(".", $fileName);
854
+ $file_ext = array_pop($file_array);
855
+ $new_file_name = implode(".", $file_array)."-".$postFix.".".$file_ext;
856
+ }
857
+
858
+ if (!file_exists($filePath.$new_file_name)) {
859
+ return $new_file_name;
860
+ }
861
+
862
+ return $this->checkForFileName($fileName, $filePath, ($postFix + 1));
863
+
864
+ }//end checkForFileName()
865
+
866
+
867
+ /**
868
+ * Check and Remove Thumb image in wp-content
869
+ *
870
+ * @since 2.6.3
871
+ * @access public
872
+ */
873
+ public function removeThumbImages()
874
+ {
875
+ if (!empty($this->oldImageMeta) && isset($this->oldImageMeta['sizes']) && !empty($this->uploadDir) && isset($this->uploadDir['path'])) {
876
+ $path = $this->uploadDir['path'].DIRECTORY_SEPARATOR;
877
+ foreach ($this->oldImageMeta['sizes'] as $image) {
878
+ if (file_exists($path.$image['file'])) {
879
+ @unlink($path.$image['file']);
880
+ }
881
+ }
882
+ }
883
+
884
+ }//end removeThumbImages()
885
+
886
+
887
+ /**
888
+ * Search and Replace files in Database
889
+ *
890
+ * @since 2.6.3
891
+ * @access public
892
+ * @return $string
893
+ */
894
+ public function searchAndReplace()
895
+ {
896
+ if (wp_attachment_is('image', $this->attachment_id)) {
897
+ $this->isNewImage = 1;
898
+ }
899
+
900
+ if ($this->oldFileURL != $this->newFileURL) {
901
+ $replace = [
902
+ 'search' => $this->oldFileURL,
903
+ 'replace' => $this->newFileURL,
904
+ ];
905
+ $this->replaceItems[] = $replace;
906
+ }
907
+
908
+ $base_url = $this->uploadDir['url'];
909
+ $base_url = trim($base_url, "/")."/";
910
+ $new_url = $this->newFileURL;
911
+
912
+ if (isset($this->oldImageMeta['sizes']) && !empty($this->oldImageMeta['sizes'])) {
913
+ if (!isset($this->newImageMeta['sizes']) || empty($this->newImageMeta['sizes'])) {
914
+ foreach ($this->oldImageMeta['sizes'] as $key => $image) {
915
+ $replace = [
916
+ 'search' => $base_url.$image['file'],
917
+ 'replace' => $new_url,
918
+ ];
919
+ $this->replaceItems[] = $replace;
920
+ }
921
+ } else if (isset($this->newImageMeta['sizes']) && !empty($this->newImageMeta['sizes'])) {
922
+ $new_size = $this->newImageMeta['sizes'];
923
+ foreach ($this->oldImageMeta['sizes'] as $key => $image) {
924
+ $new_replace_url = $new_url;
925
+ if (isset($new_size[$key])) {
926
+ $new_replace_url = $base_url.$new_size[$key]['file'];
927
+ }
928
+
929
+ $replace = [
930
+ 'search' => $base_url.$image['file'],
931
+ 'replace' => $new_replace_url,
932
+ ];
933
+ $this->replaceItems[] = $replace;
934
+ }
935
+ }//end if
936
+ }//end if
937
+
938
+ if (!empty($this->replaceItems)) {
939
+ $replaceItems = [];
940
+ foreach ($this->replaceItems as $args) {
941
+ if ($args['search'] != $args['replace']) {
942
+ $replaceItems[] = $args;
943
+ }
944
+ }
945
+
946
+ $this->replaceItems = $replaceItems;
947
+ $this->replaceURL();
948
+ }
949
+
950
+ }//end searchAndReplace()
951
+
952
+
953
+ /**
954
+ * Replace URL in Database tables
955
+ *
956
+ * @since 2.6.3
957
+ * @access public
958
+ * @return $string
959
+ */
960
+ function replaceURL()
961
+ {
962
+ // check in post content
963
+ $this->checkInPostContent();
964
+
965
+ // check in options
966
+ $this->checkInOptions();
967
+
968
+ // check in meta
969
+ $this->checkInMetaData();
970
+
971
+ if (function_exists('folders_clear_all_caches')) {
972
+ folders_clear_all_caches();
973
+ }
974
+
975
+ }//end replaceURL()
976
+
977
+
978
+ /**
979
+ * Checking image URLs in Post Content
980
+ *
981
+ * @since 2.6.3
982
+ * @access public
983
+ * @return $string
984
+ */
985
+ function checkInPostContent()
986
+ {
987
+ global $wpdb;
988
+ $post_table = $wpdb->prefix."posts";
989
+ if (!empty($this->replaceItems)) {
990
+ $query = "SELECT ID, post_content FROM ".$post_table." WHERE post_content LIKE %s";
991
+ $update_query = "UPDATE ".$post_table." SET post_content = %s WHERE ID = %d";
992
+ foreach ($this->replaceItems as $args) {
993
+ if ($args['search'] != $args['replace']) {
994
+ $sql_query = $wpdb->prepare($query, "%".$args['search']."%");
995
+ $results = $wpdb->get_results($sql_query, ARRAY_A);
996
+ if (!empty($results)) {
997
+ foreach ($results as $row) {
998
+ $content = $this->findAndReplaceContent($row['post_content'], $args['search'], $args['replace']);
999
+ $update_post_query = $wpdb->prepare($update_query, $content, $row['ID']);
1000
+ $result = $wpdb->query($update_post_query);
1001
+ }
1002
+ }
1003
+ }
1004
+ }
1005
+ }
1006
+
1007
+ }//end checkInPostContent()
1008
+
1009
+
1010
+ /**
1011
+ * Checking image URLs in MetaData
1012
+ *
1013
+ * @since 2.6.3
1014
+ * @access public
1015
+ * @return $string
1016
+ */
1017
+ function checkInOptions()
1018
+ {
1019
+ global $wpdb;
1020
+ $post_table = $wpdb->prefix."options";
1021
+ if (!empty($this->replaceItems)) {
1022
+ $query = "SELECT option_id, option_value FROM ".$post_table." WHERE option_value LIKE %s";
1023
+ $update_query = "UPDATE ".$post_table." SET option_value = %s WHERE option_id = %d";
1024
+ foreach ($this->replaceItems as $args) {
1025
+ if ($args['search'] != $args['replace']) {
1026
+ $sql_query = $wpdb->prepare($query, "%".$args['search']."%");
1027
+ $results = $wpdb->get_results($sql_query, ARRAY_A);
1028
+ if (!empty($results)) {
1029
+ foreach ($results as $row) {
1030
+ $content = $this->findAndReplaceContent($row['post_content'], $args['search'], $args['replace']);
1031
+ $update_post_query = $wpdb->prepare($update_query, $content, $row['ID']);
1032
+ $result = $wpdb->query($update_post_query);
1033
+ }
1034
+ }
1035
+ }
1036
+ }
1037
+ }
1038
+
1039
+ }//end checkInOptions()
1040
+
1041
+
1042
+ /**
1043
+ * Checking image URLs in MetaData
1044
+ *
1045
+ * @since 2.6.3
1046
+ * @access public
1047
+ * @return $string
1048
+ */
1049
+ function checkInMetaData()
1050
+ {
1051
+ $tables = [
1052
+ [
1053
+ 'table_name' => 'usermeta',
1054
+ 'primary_key' => 'umeta_id',
1055
+ 'search_key' => 'meta_value',
1056
+ ],
1057
+ [
1058
+ 'table_name' => 'termmeta',
1059
+ 'primary_key' => 'meta_id',
1060
+ 'search_key' => 'meta_value',
1061
+ ],
1062
+ [
1063
+ 'table_name' => 'postmeta',
1064
+ 'primary_key' => 'meta_id',
1065
+ 'search_key' => 'meta_value',
1066
+ ],
1067
+ [
1068
+ 'table_name' => 'commentmeta',
1069
+ 'primary_key' => 'meta_id',
1070
+ 'search_key' => 'meta_value',
1071
+ ],
1072
+ ];
1073
+ global $wpdb;
1074
+ foreach ($tables as $table) {
1075
+ $post_table = $wpdb->prefix.$table['table_name'];
1076
+ if (!empty($this->replaceItems)) {
1077
+ $query = "SELECT ".esc_attr($table['primary_key']).", ".esc_attr($table['search_key'])." FROM ".esc_attr($post_table)." WHERE ".esc_attr($table['search_key'])." LIKE %s";
1078
+ $update_query = "UPDATE ".$post_table." SET ".esc_attr($table['search_key'])." = %s WHERE ".esc_attr($table['primary_key'])." = %d";
1079
+ foreach ($this->replaceItems as $args) {
1080
+ if ($args['search'] != $args['replace']) {
1081
+ $sql_query = $wpdb->prepare($query, "%".$args['search']."%");
1082
+ $results = $wpdb->get_results($sql_query, ARRAY_A);
1083
+ if (!empty($results)) {
1084
+ foreach ($results as $row) {
1085
+ $content = $this->findAndReplaceContent($row[$table['search_key']], $args['search'], $args['replace']);
1086
+ $update_post_query = $wpdb->prepare($update_query, $content, $row[$table['primary_key']]);
1087
+ $result = $wpdb->query($update_post_query);
1088
+ }
1089
+ }
1090
+ }
1091
+ }
1092
+ }
1093
+ }
1094
+
1095
+ }//end checkInMetaData()
1096
+
1097
+
1098
+ /**
1099
+ * Checking for Array Key
1100
+ *
1101
+ * @since 2.6.3
1102
+ * @access public
1103
+ * @return $json
1104
+ * Forked from Enable Media Replace
1105
+ */
1106
+ function findAndReplaceContent($content, $search, $replace, $depth=false)
1107
+ {
1108
+ $content = maybe_unserialize($content);
1109
+
1110
+ // Checking for JSON Data
1111
+ $isJson = $this->isJSON($content);
1112
+ if ($isJson) {
1113
+ $content = json_decode($content);
1114
+ }
1115
+
1116
+ // Replace content if content is String
1117
+ if (is_string($content)) {
1118
+ $content = str_replace($search, $replace, $content);
1119
+ } else if (is_wp_error($content)) {
1120
+ // Return if error in data
1121
+ } else if (is_array($content)) {
1122
+ // Replace content if content is Array
1123
+ foreach ($content as $index => $value) {
1124
+ $content[$index] = $this->findAndReplaceContent($value, $search, $replace, true);
1125
+ if (is_string($index)) {
1126
+ $index_replaced = $this->findAndReplaceContent($index, $search, $replace, true);
1127
+ if ($index_replaced !== $index) {
1128
+ $content = $this->changeArrayKey($content, [$index => $index_replaced]);
1129
+ }
1130
+ }
1131
+ }
1132
+ } else if (is_object($content)) {
1133
+ // Replace content if content is Object
1134
+ foreach ($content as $key => $value) {
1135
+ $content->{$key} = $this->findAndReplaceContent($value, $search, $replace, true);
1136
+ }
1137
+ }//end if
1138
+
1139
+ if ($isJson && $depth === false) {
1140
+ $content = json_encode($content, JSON_UNESCAPED_SLASHES);
1141
+ } else if ($depth === false && (is_array($content) || is_object($content))) {
1142
+ $content = maybe_serialize($content);
1143
+ }
1144
+
1145
+ return $content;
1146
+
1147
+ }//end findAndReplaceContent()
1148
+
1149
+
1150
+ /**
1151
+ * Checking for Array Key
1152
+ *
1153
+ * @since 2.6.3
1154
+ * @access public
1155
+ * @return $json
1156
+ */
1157
+ function changeArrayKey($array, $set)
1158
+ {
1159
+ if (is_array($array) && is_array($set)) {
1160
+ $newArray = [];
1161
+ foreach ($array as $k => $v) {
1162
+ $key = array_key_exists($k, $set) ? $set[$k] : $k;
1163
+ $newArray[$key] = is_array($v) ? $this->changeArrayKey($v, $set) : $v;
1164
+ }
1165
+
1166
+ return $newArray;
1167
+ }
1168
+
1169
+ return $array;
1170
+
1171
+ }//end changeArrayKey()
1172
+
1173
+
1174
+ /**
1175
+ * Check if it is JSON or not
1176
+ *
1177
+ * @since 2.6.3
1178
+ * @access public
1179
+ * Forked from Enable Media Replace
1180
+ * @return $json
1181
+ */
1182
+ function isJSON($content)
1183
+ {
1184
+ if (is_array($content) || is_object($content)) {
1185
+ return false;
1186
+ }
1187
+
1188
+ $json = json_decode($content);
1189
+ return $json && $json != $content;
1190
+
1191
+ }//end isJSON()
1192
+
1193
+
1194
+ }//end class
1195
+
1196
+ $folders_replace_media = new folders_replace_media();
includes/plugin.updates.php DELETED
@@ -1,565 +0,0 @@
1
- <?php
2
-
3
- if ( ! defined( 'ABSPATH' ) ) exit;
4
-
5
- // Exit if accessed directly
6
-
7
- /**
8
- * Allows plugins to use their own update API.
9
- *
10
- * @author Easy Digital Downloads
11
- * @version 1.6.17
12
- */
13
- class Folder_Plugin_Updater {
14
-
15
- private $api_url = '';
16
- private $api_data = array();
17
- private $name = '';
18
- private $slug = '';
19
- private $version = '';
20
- private $wp_override = false;
21
- private $cache_key = '';
22
-
23
- private $health_check_timeout = 5;
24
-
25
- /**
26
- * Class constructor.
27
- *
28
- * @uses plugin_basename()
29
- * @uses hook()
30
- *
31
- * @param string $_api_url The URL pointing to the custom API endpoint.
32
- * @param string $_plugin_file Path to the plugin file.
33
- * @param array $_api_data Optional data to send with API calls.
34
- */
35
- public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
36
-
37
- global $edd_plugin_data;
38
-
39
- $this->api_url = trailingslashit( $_api_url );
40
- $this->api_data = $_api_data;
41
- $this->name = plugin_basename( $_plugin_file );
42
- $this->slug = basename( $_plugin_file, '.php' );
43
- $this->version = $_api_data['version'];
44
- $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
45
- $this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
46
- $this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
47
-
48
- $edd_plugin_data[ $this->slug ] = $this->api_data;
49
-
50
- /**
51
- * Fires after the $edd_plugin_data is setup.
52
- *
53
- * @since x.x.x
54
- *
55
- * @param array $edd_plugin_data Array of EDD SL plugin data.
56
- */
57
- do_action( 'post_edd_sl_plugin_updater_setup', $edd_plugin_data );
58
-
59
- // Set up hooks.
60
- $this->init();
61
-
62
- }
63
-
64
- /**
65
- * Set up WordPress filters to hook into WP's update process.
66
- *
67
- * @uses add_filter()
68
- *
69
- * @return void
70
- */
71
- public function init() {
72
-
73
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
74
- add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
75
- remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
76
- add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
77
- add_action( 'admin_init', array( $this, 'show_changelog' ) );
78
-
79
- }
80
-
81
- /**
82
- * Check for Updates at the defined API endpoint and modify the update array.
83
- *
84
- * This function dives into the update API just when WordPress creates its update array,
85
- * then adds a custom API call and injects the custom plugin data retrieved from the API.
86
- * It is reassembled from parts of the native WordPress plugin update code.
87
- * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
88
- *
89
- * @uses api_request()
90
- *
91
- * @param array $_transient_data Update array build by WordPress.
92
- * @return array Modified update array with custom plugin data.
93
- */
94
- public function check_update( $_transient_data ) {
95
-
96
- global $pagenow;
97
-
98
- if ( ! is_object( $_transient_data ) ) {
99
- $_transient_data = new stdClass;
100
- }
101
-
102
- if ( 'plugins.php' == $pagenow && is_multisite() ) {
103
- return $_transient_data;
104
- }
105
-
106
- if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
107
- return $_transient_data;
108
- }
109
-
110
- $version_info = $this->get_cached_version_info();
111
-
112
- if ( false === $version_info ) {
113
- $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
114
-
115
- $this->set_version_info_cache( $version_info );
116
-
117
- }
118
-
119
- if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
120
-
121
- if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
122
-
123
- $_transient_data->response[ $this->name ] = $version_info;
124
-
125
- }
126
-
127
- $_transient_data->last_checked = time();
128
- $_transient_data->checked[ $this->name ] = $this->version;
129
-
130
- }
131
-
132
- return $_transient_data;
133
- }
134
-
135
- /**
136
- * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
137
- *
138
- * @param string $file
139
- * @param array $plugin
140
- */
141
- public function show_update_notification( $file, $plugin ) {
142
-
143
- if ( is_network_admin() ) {
144
- return;
145
- }
146
-
147
- if( ! current_user_can( 'update_plugins' ) ) {
148
- return;
149
- }
150
-
151
- if( ! is_multisite() ) {
152
- return;
153
- }
154
-
155
- if ( $this->name != $file ) {
156
- return;
157
- }
158
-
159
- // Remove our filter on the site transient
160
- remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
161
-
162
- $update_cache = get_site_transient( 'update_plugins' );
163
-
164
- $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
165
-
166
- if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
167
-
168
- $version_info = $this->get_cached_version_info();
169
-
170
- if ( false === $version_info ) {
171
- $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
172
-
173
- // Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
174
- if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
175
- $version_info->banners = $this->convert_object_to_array( $version_info->banners );
176
- }
177
-
178
- if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) {
179
- $version_info->sections = $this->convert_object_to_array( $version_info->sections );
180
- }
181
-
182
- if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) {
183
- $version_info->icons = $this->convert_object_to_array( $version_info->icons );
184
- }
185
-
186
- $this->set_version_info_cache( $version_info );
187
- }
188
-
189
- if ( ! is_object( $version_info ) ) {
190
- return;
191
- }
192
-
193
- if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
194
-
195
- $update_cache->response[ $this->name ] = $version_info;
196
-
197
- }
198
-
199
- $update_cache->last_checked = time();
200
- $update_cache->checked[ $this->name ] = $this->version;
201
-
202
- set_site_transient( 'update_plugins', $update_cache );
203
-
204
- } else {
205
-
206
- $version_info = $update_cache->response[ $this->name ];
207
-
208
- }
209
-
210
- // Restore our filter
211
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
212
-
213
- if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
214
-
215
- // build a plugin list row, with update notification
216
- # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
217
- ?>
218
- <tr class="plugin-update-tr" id="<?php echo esc_attr($this->slug) ?>-update" data-slug="<?php echo esc_attr($this->slug) ?>" data-plugin="<?php echo esc_attr($this->slug) ?>/' . $file . '">
219
- <td colspan="3" class="plugin-update colspanchange">
220
- <div class="update-message notice inline notice-warning notice-alt">
221
- <?php
222
- $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
223
-
224
- if ( empty( $version_info->download_link ) ) {
225
- printf(
226
- __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
227
- esc_html( $version_info->name ),
228
- '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
229
- esc_html( $version_info->new_version ),
230
- '</a>'
231
- );
232
- } else {
233
- printf(
234
- __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
235
- esc_html( $version_info->name ),
236
- '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
237
- esc_html( $version_info->new_version ),
238
- '</a>',
239
- '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
240
- '</a>'
241
- );
242
- }
243
-
244
- do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
245
-
246
- echo '</div></td></tr>';
247
- }
248
- }
249
-
250
- /**
251
- * Updates information on the "View version x.x details" page with custom data.
252
- *
253
- * @uses api_request()
254
- *
255
- * @param mixed $_data
256
- * @param string $_action
257
- * @param object $_args
258
- * @return object $_data
259
- */
260
- public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
261
-
262
- if ( $_action != 'plugin_information' ) {
263
-
264
- return $_data;
265
-
266
- }
267
-
268
- if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
269
-
270
- return $_data;
271
-
272
- }
273
-
274
- $to_send = array(
275
- 'slug' => $this->slug,
276
- 'is_ssl' => is_ssl(),
277
- 'fields' => array(
278
- 'banners' => array(),
279
- 'reviews' => false,
280
- 'icons' => array(),
281
- )
282
- );
283
-
284
- $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
285
-
286
- // Get the transient where we store the api request for this plugin for 24 hours
287
- $edd_api_request_transient = $this->get_cached_version_info( $cache_key );
288
-
289
- //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
290
- if ( empty( $edd_api_request_transient ) ) {
291
-
292
- $api_response = $this->api_request( 'plugin_information', $to_send );
293
-
294
- // Expires in 3 hours
295
- $this->set_version_info_cache( $api_response, $cache_key );
296
-
297
- if ( false !== $api_response ) {
298
- $_data = $api_response;
299
- }
300
-
301
- } else {
302
- $_data = $edd_api_request_transient;
303
- }
304
-
305
- // Convert sections into an associative array, since we're getting an object, but Core expects an array.
306
- if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
307
- $_data->sections = $this->convert_object_to_array( $_data->sections );
308
- }
309
-
310
- // Convert banners into an associative array, since we're getting an object, but Core expects an array.
311
- if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
312
- $_data->banners = $this->convert_object_to_array( $_data->banners );
313
- }
314
-
315
- // Convert icons into an associative array, since we're getting an object, but Core expects an array.
316
- if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) {
317
- $_data->icons = $this->convert_object_to_array( $_data->icons );
318
- }
319
-
320
- return $_data;
321
- }
322
-
323
- /**
324
- * Convert some objects to arrays when injecting data into the update API
325
- *
326
- * Some data like sections, banners, and icons are expected to be an associative array, however due to the JSON
327
- * decoding, they are objects. This method allows us to pass in the object and return an associative array.
328
- *
329
- * @since 3.6.5
330
- *
331
- * @param stdClass $data
332
- *
333
- * @return array
334
- */
335
- private function convert_object_to_array( $data ) {
336
- $new_data = array();
337
- foreach ( $data as $key => $value ) {
338
- $new_data[ $key ] = $value;
339
- }
340
-
341
- return $new_data;
342
- }
343
-
344
- /**
345
- * Disable SSL verification in order to prevent download update failures
346
- *
347
- * @param array $args
348
- * @param string $url
349
- * @return object $array
350
- */
351
- public function http_request_args( $args, $url ) {
352
-
353
- $verify_ssl = $this->verify_ssl();
354
- if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
355
- $args['sslverify'] = $verify_ssl;
356
- }
357
- return $args;
358
-
359
- }
360
-
361
- /**
362
- * Calls the API and, if successfull, returns the object delivered by the API.
363
- *
364
- * @uses get_bloginfo()
365
- * @uses wp_remote_post()
366
- * @uses is_wp_error()
367
- *
368
- * @param string $_action The requested action.
369
- * @param array $_data Parameters for the API action.
370
- * @return false|object
371
- */
372
- private function api_request( $_action, $_data ) {
373
-
374
- global $wp_version, $edd_plugin_url_available;
375
-
376
- // Do a quick status check on this domain if we haven't already checked it.
377
- $store_hash = md5( $this->api_url );
378
- if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
379
- $test_url_parts = parse_url( $this->api_url );
380
-
381
- $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
382
- $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
383
- $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : '';
384
-
385
- if ( empty( $host ) ) {
386
- $edd_plugin_url_available[ $store_hash ] = false;
387
- } else {
388
- $test_url = $scheme . '://' . $host . $port;
389
- $response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => true ) );
390
- $edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
391
- }
392
- }
393
-
394
- if ( false === $edd_plugin_url_available[ $store_hash ] ) {
395
- return;
396
- }
397
-
398
- $data = array_merge( $this->api_data, $_data );
399
-
400
- if ( $data['slug'] != $this->slug ) {
401
- return;
402
- }
403
-
404
- if( $this->api_url == trailingslashit ( home_url() ) ) {
405
- return false; // Don't allow a plugin to ping itself
406
- }
407
-
408
- $api_params = array(
409
- 'edd_action' => 'get_version',
410
- 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
411
- 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
412
- 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
413
- 'version' => isset( $data['version'] ) ? $data['version'] : false,
414
- 'slug' => $data['slug'],
415
- 'author' => $data['author'],
416
- 'url' => home_url(),
417
- 'beta' => ! empty( $data['beta'] ),
418
- );
419
-
420
- $verify_ssl = $this->verify_ssl();
421
- $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
422
-
423
- if ( ! is_wp_error( $request ) ) {
424
- $request = json_decode( wp_remote_retrieve_body( $request ) );
425
- }
426
-
427
- if ( $request && isset( $request->sections ) ) {
428
- $request->sections = maybe_unserialize( $request->sections );
429
- } else {
430
- $request = false;
431
- }
432
-
433
- if ( $request && isset( $request->banners ) ) {
434
- $request->banners = maybe_unserialize( $request->banners );
435
- }
436
-
437
- if ( $request && isset( $request->icons ) ) {
438
- $request->icons = maybe_unserialize( $request->icons );
439
- }
440
-
441
- if( ! empty( $request->sections ) ) {
442
- foreach( $request->sections as $key => $section ) {
443
- $request->$key = (array) $section;
444
- }
445
- }
446
-
447
- return $request;
448
- }
449
-
450
- public function show_changelog() {
451
-
452
- global $edd_plugin_data;
453
-
454
- if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
455
- return;
456
- }
457
-
458
- if( empty( $_REQUEST['plugin'] ) ) {
459
- return;
460
- }
461
-
462
- if( empty( $_REQUEST['slug'] ) ) {
463
- return;
464
- }
465
-
466
- if( ! current_user_can( 'update_plugins' ) ) {
467
- wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
468
- }
469
-
470
- $data = $edd_plugin_data[ $_REQUEST['slug'] ];
471
- $beta = ! empty( $data['beta'] ) ? true : false;
472
- $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
473
- $version_info = $this->get_cached_version_info( $cache_key );
474
-
475
- if( false === $version_info ) {
476
-
477
- $api_params = array(
478
- 'edd_action' => 'get_version',
479
- 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
480
- 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
481
- 'slug' => $_REQUEST['slug'],
482
- 'author' => $data['author'],
483
- 'url' => home_url(),
484
- 'beta' => ! empty( $data['beta'] )
485
- );
486
-
487
- $verify_ssl = $this->verify_ssl();
488
- $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
489
-
490
- if ( ! is_wp_error( $request ) ) {
491
- $version_info = json_decode( wp_remote_retrieve_body( $request ) );
492
- }
493
-
494
-
495
- if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
496
- $version_info->sections = maybe_unserialize( $version_info->sections );
497
- } else {
498
- $version_info = false;
499
- }
500
-
501
- if( ! empty( $version_info ) ) {
502
- foreach( $version_info->sections as $key => $section ) {
503
- $version_info->$key = (array) $section;
504
- }
505
- }
506
-
507
- $this->set_version_info_cache( $version_info, $cache_key );
508
-
509
- }
510
-
511
- if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
512
- echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
513
- }
514
-
515
- exit;
516
- }
517
-
518
- public function get_cached_version_info( $cache_key = '' ) {
519
-
520
- if( empty( $cache_key ) ) {
521
- $cache_key = $this->cache_key;
522
- }
523
-
524
- $cache = get_option( $cache_key );
525
-
526
- if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
527
- return false; // Cache is expired
528
- }
529
-
530
- // We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
531
- $cache['value'] = json_decode( $cache['value'] );
532
- if ( ! empty( $cache['value']->icons ) ) {
533
- $cache['value']->icons = (array) $cache['value']->icons;
534
- }
535
-
536
- return $cache['value'];
537
-
538
- }
539
-
540
- public function set_version_info_cache( $value = '', $cache_key = '' ) {
541
-
542
- if( empty( $cache_key ) ) {
543
- $cache_key = $this->cache_key;
544
- }
545
-
546
- $data = array(
547
- 'timeout' => strtotime( '+3 hours', time() ),
548
- 'value' => json_encode( $value )
549
- );
550
-
551
- update_option( $cache_key, $data, 'no' );
552
-
553
- }
554
-
555
- /**
556
- * Returns if the SSL of the store should be verified.
557
- *
558
- * @since 1.6.13
559
- * @return bool
560
- */
561
- private function verify_ssl() {
562
- return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
563
- }
564
-
565
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/plugins.class.php CHANGED
@@ -1,111 +1,173 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
- /* Free/Pro Class name change */
4
- class WCP_Folder_Plugins {
5
-
6
- public $plugins = array();
7
- public $post_types = array();
8
- public $is_exists = 0;
9
-
10
- public function __construct() {
11
-
12
- /* Import plugin data */
13
- add_action( 'wp_ajax_wcp_import_plugin_folders_data', array($this, 'import_plugin_folders_data'));
14
- add_action( 'wp_ajax_wcp_remove_plugin_folders_data', array($this, 'remove_plugin_folders_data'));
15
- }
16
-
17
 
18
- public function remove_plugin_folders_data(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  global $wpdb;
20
  $postData = filter_input_array(INPUT_POST);
21
 
22
- $plugin = isset($postData['plugin']) ? $postData['plugin'] : "";
23
- $nonce = isset($postData['nonce']) ? $postData['nonce'] : "";
24
- $response = array();
25
- $response['status'] = 0;
26
- $response['message'] = esc_html__("Invalid request", "folders");
27
- $response['data'] = array();
28
  $response['data']['plugin'] = $plugin;
29
- if (wp_verify_nonce($nonce, "import_data_from_" . $plugin)) {
30
  $this->get_plugin_information();
31
- $folders = isset($this->plugins[$plugin]['folders']) ? $this->plugins[$plugin]['folders'] : array();
32
- $attachments = isset($this->plugins[$plugin]['attachments']) ? $this->plugins[$plugin]['attachments'] : array();
33
 
34
- if($plugin != 'filebird' && $plugin != 'real-media-library') {
35
  $deleted = [];
36
 
37
- foreach ( $folders as $folder ) {
38
- $term_id = intval( $folder->term_id );
39
 
40
- if ( $term_id ) {
41
- $deleted[$term_id]['term_relationships'] = $wpdb->delete( $wpdb->prefix . 'term_relationships', ['term_taxonomy_id' => $term_id] );
42
- $deleted[$term_id]['term_taxonomy'] = $wpdb->delete( $wpdb->prefix . 'term_taxonomy', ['term_id' => $term_id] );
43
- $deleted[$term_id]['terms'] = $wpdb->delete( $wpdb->prefix . 'terms', ['term_id' => $term_id] );
44
 
45
- if ( $plugin === 'folders' ) {
46
- $deleted[$term_id]['termmeta'] = $wpdb->delete( $wpdb->prefix . 'termmeta', ['term_id' => $term_id] );
47
  }
48
  }
49
  }
50
  } else {
51
-
52
- if ( count( $folders ) ) {
53
- if ( $plugin === 'filebird' ) {
54
- $wpdb->query( 'DELETE FROM ' . $wpdb->prefix . 'fbv' );
55
  }
56
 
57
- if ( $plugin === 'real-media-library' ) {
58
- $wpdb->query( 'DELETE FROM ' . $wpdb->prefix . 'realmedialibrary' );
59
 
60
- $wpdb->query( 'DELETE FROM ' . $wpdb->prefix . 'realmedialibrary_meta' );
61
  }
62
  }
63
 
64
- if ( count( $attachments ) ) {
65
- if ( $plugin === 'filebird' ) {
66
- $wpdb->query( 'DELETE FROM ' . $wpdb->prefix . 'fbv_attachment_folder' );
67
  }
68
 
69
- if ( $plugin === 'real-media-library' ) {
70
- $wpdb->query( 'DELETE FROM ' . $wpdb->prefix . 'realmedialibrary_posts' );
71
  }
72
  }
73
- }
 
74
  $response['status'] = 1;
 
75
 
76
- }
77
  echo json_encode($response);
78
  exit;
79
- }
80
 
81
- public function import_plugin_folders_data() {
 
 
 
 
 
 
 
 
 
 
 
82
  $postData = filter_input_array(INPUT_POST);
83
 
84
- $plugin = isset($postData['plugin']) ?$postData['plugin']:"";
85
- $nonce = isset($postData['nonce']) ?$postData['nonce']:"";
86
- $response = array();
87
- $response['status'] = 0;
88
- $response['message'] = esc_html__("Invalid request", "folders");
89
- $response['data'] = array();
90
  $response['data']['plugin'] = $plugin;
91
- if(wp_verify_nonce($nonce, "import_data_from_".$plugin)) {
92
  $this->get_plugin_information();
93
- $folders = isset($this->plugins[$plugin]['folders']) ? $this->plugins[$plugin]['folders'] : array();
94
- $attachments = isset($this->plugins[$plugin]['attachments']) ? $this->plugins[$plugin]['attachments'] : array();
95
 
96
- $categoryByID = array();
97
- $foldersImported = array();
98
- $attachmentsImported = array();
99
-
100
- if($plugin != 'filebird' && $plugin != 'real-media-library') {
101
 
 
102
  foreach ($folders as $folder) {
103
  $folder_id = $folder->term_id;
104
- $parent = intval($folder->parent);
105
 
106
  $taxonomy = 'media_folder';
107
 
108
- foreach ($this->post_types as $post_type) {
109
  if (strpos($folder->taxonomy, $post_type) !== false) {
110
  if ($post_type == "post") {
111
  $taxonomy = "post_folder";
@@ -114,7 +176,7 @@ class WCP_Folder_Plugins {
114
  } else if ($post_type == "attachment") {
115
  $taxonomy = "media_folder";
116
  } else {
117
- $taxonomy = $post_type . '_folder';
118
  }
119
  }
120
  }
@@ -129,25 +191,26 @@ class WCP_Folder_Plugins {
129
  continue;
130
  }
131
 
132
- $arg = array(
133
- 'hide_empty' => false,
134
- 'parent' => $parent,
135
- 'hierarchical' => false,
136
  'update_count_callback' => '_update_generic_term_count',
137
- );
138
- $terms = get_terms( $taxonomy, $arg);
139
  $position = count($terms);
140
 
141
- if($plugin == 'mediamatic' || $plugin == 'happyfiles') {
142
  $meta_key = "";
143
- if($plugin == 'mediamatic') {
144
  $meta_key = "folder_position";
145
- } else if($plugin == 'happyfiles') {
146
  $meta_key = "happyfiles_position";
147
  }
148
- if(!empty($meta_key)) {
 
149
  $folder_position = get_term_meta($new_term['term_id'], $meta_key, true);
150
- if(empty($folder_position)) {
151
  $position = intval($folder_position);
152
  }
153
  }
@@ -159,15 +222,15 @@ class WCP_Folder_Plugins {
159
 
160
  $categoryByID[$folder_id] = [
161
  'term_id' => $new_term['term_id'],
162
- 'parent' => $parent,
163
- 'name' => $folder->name,
164
  ];
165
- }
166
 
167
  // STEP: Assign plugin categories to HF categories
168
  foreach ($attachments as $attachment) {
169
  $hf_category_id = isset($categoryByID[$attachment->term_taxonomy_id]['term_id']) ? intval($categoryByID[$attachment->term_taxonomy_id]['term_id']) : 0;
170
- $attachment_id = isset($attachment->object_id) ? intval($attachment->object_id) : 0;
171
 
172
  if (!$hf_category_id || !$attachment_id) {
173
  continue;
@@ -182,10 +245,10 @@ class WCP_Folder_Plugins {
182
  } else if ($post_type == "attachment") {
183
  $taxonomy = "media_folder";
184
  } else {
185
- $taxonomy = $post_type . '_folder';
186
  }
187
 
188
- $term_ids = wp_get_object_terms($attachment_id, $taxonomy, ['fields' => 'ids']);
189
  $term_ids[] = $hf_category_id;
190
 
191
  $term_set = wp_set_object_terms($attachment_id, $term_ids, $taxonomy);
@@ -195,39 +258,38 @@ class WCP_Folder_Plugins {
195
  }
196
 
197
  $attachmentsImported[] = [
198
- 'cat_id' => $hf_category_id,
199
  'term_ids' => $term_ids,
200
- 'set' => $term_set,
201
  ];
202
- }
203
  } else {
204
- foreach ( $folders as $folder ) {
205
- $parent = intval( $folder->parent );
206
  $parentID = 0;
207
 
208
- if ( $parent && isset( $categoryByID[$parent]['term_id'] ) ) {
209
  $parentID = $categoryByID[$parent]['term_id'];
210
  }
211
 
212
- $new_term = wp_insert_term( $folder->name, "media_folder", ['parent' => $parentID] );
213
 
214
- if ( is_wp_error( $new_term ) ) {
215
  continue;
216
  }
217
 
218
  $taxonomy = 'media_folder';
219
 
220
- $arg = array(
221
- 'hide_empty' => false,
222
- 'parent' => $parentID,
223
- 'hierarchical' => false,
224
  'update_count_callback' => '_update_generic_term_count',
225
- );
226
- $terms = get_terms( $taxonomy, $arg);
227
  $position = count($terms);
228
 
229
-
230
- update_term_meta( $new_term['term_id'], 'wcp_custom_order', intval( $position ) );
231
 
232
  $foldersImported[] = $new_term;
233
 
@@ -236,22 +298,22 @@ class WCP_Folder_Plugins {
236
  'parent' => $parent,
237
  'term_id' => $new_term['term_id'],
238
  ];
239
- }
240
 
241
- foreach ( $attachments as $attachment ) {
242
- $hf_category_id = isset( $categoryByID[$attachment->folder_id]['term_id'] ) ? intval( $categoryByID[$attachment->folder_id]['term_id'] ) : 0;
243
- $attachment_id = isset( $attachment->attachment_id ) ? intval( $attachment->attachment_id ) : 0;
244
 
245
- if ( ! $hf_category_id || ! $attachment_id ) {
246
  continue;
247
  }
248
 
249
- $term_ids = wp_get_object_terms( $attachment_id, "media_folder", ['fields' => 'ids'] );
250
  $term_ids[] = $hf_category_id;
251
 
252
- $term_set = wp_set_object_terms( $attachment_id, $term_ids, "media_folder" );
253
 
254
- if ( is_wp_error( $term_set ) ) {
255
  continue;
256
  }
257
 
@@ -260,282 +322,343 @@ class WCP_Folder_Plugins {
260
  'term_ids' => $term_ids,
261
  'set' => $term_set,
262
  ];
263
- }
264
- }
265
 
266
- $response['status'] = 1;
267
  $response['data']['imported'] = count($foldersImported);
268
  $response['data']['attachments'] = count($attachmentsImported);
269
- $response['data']['plugin'] = $plugin;
270
- $response['message'] = sprintf(esc_html__( '%s folders imported and %s attachments categorized.', 'folders'), count($foldersImported), count($attachmentsImported));
271
- }
 
272
  echo json_encode($response);
273
  exit;
274
- }
275
 
276
- public function get_plugin_information() {
 
 
 
 
 
 
 
 
 
 
 
277
  $this->get_other_plugins_data();
278
  return $this->plugins;
279
- }
280
 
281
- public function get_other_plugins_data() {
282
- if(!empty($this->plugins)) {
 
 
 
 
 
 
 
 
 
 
 
283
  return $this->plugins;
284
  }
285
- $this->plugins = array(
 
286
  // FileBird
287
- 'filebird' => array(
288
- 'name' => 'FileBird (v4)',
289
- 'taxonomy' => 'filebird', // has custom DB table
290
- 'folders' => array(),
291
- 'attachments' => array(),
292
- 'total_folders' => 0,
293
  'total_attachments' => 0,
294
- 'is_exists' => 0
295
- ),
296
- 'enhanced-media-library' => array(
297
  // Enhanced Media Library
298
- 'name' => 'Enhanced Media Library',
299
- 'taxonomy' => 'media_category',
300
- 'folders' => array(),
301
- 'attachments' => array(),
302
- 'total_folders' => 0,
303
  'total_attachments' => 0,
304
- 'is_exists' => 0
305
- ),
306
- 'wicked-folders' => array(
307
  // Enhanced Media Library
308
- 'name' => 'Wicked Folders',
309
- 'taxonomy' => 'wf_attachment_folders',
310
- 'folders' => array(),
311
- 'attachments' => array(),
312
- 'total_folders' => 0,
313
  'total_attachments' => 0,
314
- 'is_exists' => 0
315
- ),
316
- 'real-media-library' => array(
317
  // Real Media Library
318
- 'name' => 'Real Media Library (by DevOwl)',
319
- 'taxonomy' => 'rml', // has custom DB table
320
- 'folders' => array(),
321
- 'attachments' => array(),
322
- 'total_folders' => 0,
 
323
  'total_attachments' => 0,
324
- 'is_exists' => 0
325
- ),
326
- 'wp-media-folder' => array(
327
  // Real Media Library
328
- 'name' => 'WP Media Folder (by JoomUnited)',
329
- 'taxonomy' => 'wpmf-category',
330
- 'folders' => array(),
331
- 'attachments' => array(),
332
- 'total_folders' => 0,
333
  'total_attachments' => 0,
334
- 'is_exists' => 0
335
- ),
336
- 'mediamatic' => array(
337
  // Mediamatic
338
- 'name' => 'WordPress Media Library Folders | Mediamatic',
339
- 'taxonomy' => 'mediamatic_wpfolder',
340
- 'folders' => array(),
341
- 'attachments' => array(),
342
- 'total_folders' => 0,
343
  'total_attachments' => 0,
344
- 'is_exists' => 0
345
- ),
346
- 'happyfiles' => array(
347
  // HappyFiles
348
- 'name' => 'HappyFiles',
349
- 'taxonomy' => 'happyfiles_category',
350
- 'folders' => array(),
351
- 'attachments' => array(),
352
- 'total_folders' => 0,
353
  'total_attachments' => 0,
354
- 'is_exists' => 0
355
- )
356
- );
357
- $post_types = get_post_types(array());
358
- $this->post_types = array_keys($post_types);
359
 
360
- foreach ($this->plugins as $slug => $plugin_data ) {
361
  $taxonomy = $plugin_data['taxonomy'];
362
 
363
- if ( $slug === 'wicked-folders' ) {
364
  // Run for all registered post types
365
  $folders = [];
366
 
367
- foreach ( $this->post_types as $post_type ) {
368
- $wicked_folders = $this->get_plugin_folders( 'wf_' . $post_type . '_folders', $slug );
369
 
370
- if ( is_array( $wicked_folders ) ) {
371
- $folders = array_merge( $folders, $wicked_folders );
372
  }
373
  }
 
 
374
  }
375
 
376
- else {
377
- $folders = $this->get_plugin_folders( $taxonomy, $slug );
378
- }
379
-
380
- if ( in_array( $taxonomy, ['filebird', 'rml'] ) ) {
381
- $folders = is_array( $folders ) && count( $folders ) ? $this->map_plugin_folders( $taxonomy, $folders ) : [];
382
  }
383
 
384
  $this->plugins[$slug]['folders'] = $folders;
385
 
386
- $attachments = is_array( $folders ) && count( $folders ) ? $this->get_plugin_attachments( $taxonomy, $folders ) : [];
387
 
388
- if ( in_array( $taxonomy, ['filebird', 'rml'] ) ) {
389
- $attachments = $this->map_plugin_attachments( $taxonomy, $attachments );
390
  }
391
 
392
  $this->plugins[$slug]['attachments'] = $attachments;
393
- }
394
 
395
- foreach ($this->plugins as $key=>$plugin) {
396
- $folders = isset($plugin['folders'])&&is_array($plugin['folders'])?$plugin['folders']:array();
397
  $this->plugins[$key]['total_folders'] = count($folders);
398
 
399
- $attachments = isset($plugin['attachments'])&&is_array($plugin['attachments'])?$plugin['attachments']:array();
400
  $this->plugins[$key]['total_attachments'] = count($attachments);
401
 
402
- if(count($folders) > 0 || count($attachments)>0) {
403
- $this->plugins[$key]['is_exists'] = 1;
404
- $this->is_exists = 1;
405
  }
406
  }
407
- }
408
 
409
- public function get_plugin_folders( $taxonomy, $slug ) {
 
 
 
 
 
 
 
 
 
 
 
410
  global $wpdb;
411
 
412
  // FileBird has its own db table
413
- if ( $taxonomy === 'filebird' ) {
414
- $filebird_folders_table = $wpdb->prefix . 'fbv';
415
 
416
  // Get FileBird folders (order by 'parent' to create parent categories first)
417
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$filebird_folders_table'") == $filebird_folders_table ) {
418
- return $wpdb->get_results( "SELECT * FROM $filebird_folders_table ORDER BY parent ASC" );
419
  }
420
  }
421
 
422
  // Real Media Library has its own db table
423
- else if ( $taxonomy === 'rml' ) {
424
- $rml_folders_table = $wpdb->prefix . 'realmedialibrary';
425
 
426
  // Get FileBird folders (order by 'parent' to create parent categories first)
427
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$rml_folders_table'") == $rml_folders_table ) {
428
- return $wpdb->get_results( "SELECT * FROM $rml_folders_table ORDER BY parent ASC" );
429
  }
430
  }
431
 
432
  // Default: Plugins with custom taxonomy terms
433
  else {
434
- $folders = $wpdb->get_results(
435
- "SELECT * FROM " . $wpdb->term_taxonomy . "
436
- LEFT JOIN " . $wpdb->terms . "
437
- ON " . $wpdb->term_taxonomy . ".term_id = " . $wpdb->terms . ".term_id
438
- WHERE " . $wpdb->term_taxonomy . ".taxonomy = '" . $taxonomy . "'
439
- ORDER BY parent ASC"
440
- );
441
 
442
  // WP Media Folder (JoomUnited): Remove root folder
443
- if ( $slug === 'wp-media-folder' ) {
444
- foreach ( $folders as $index => $folder ) {
445
- if ( $folder->slug === 'wp-media-folder-root' ) {
446
- unset( $folders[$index] );
447
  }
448
  }
449
  }
450
 
451
- return array_values( $folders );
452
  }
453
- }
454
 
455
- public function map_plugin_folders( $taxonomy, $folders ) {
456
- $mapped_folders = [];
457
 
458
- foreach ( $folders as $folder ) {
459
 
 
 
 
 
 
 
 
 
 
 
 
 
460
  // FileBird, Real Media Library
461
- if ( $taxonomy === 'filebird' || $taxonomy === 'rml' ) {
462
  $folder_object = new \stdClass();
463
 
464
- $folder_object->name = $folder->name;
465
- $folder_object->id = intval( $folder->id );
466
- $folder_object->parent = intval( $folder->parent );
467
- $folder_object->position = intval( $folder->ord );
468
 
469
  $mapped_folders[] = $folder_object;
470
  }
471
-
472
  }
473
 
474
  return $mapped_folders;
475
- }
476
 
477
- public function map_plugin_attachments( $taxonomy, $attachments ) {
478
- $mapped_attachments = [];
479
 
480
- foreach ( $attachments as $folder ) {
481
 
 
 
 
 
 
 
 
 
 
 
 
 
482
  // FileBird
483
- if ( $taxonomy === 'filebird' ) {
484
  $folder_object = new \stdClass();
485
 
486
- $folder_object->folder_id = intval( $folder->folder_id );
487
- $folder_object->attachment_id = intval( $folder->attachment_id );
488
 
489
  $mapped_attachments[] = $folder_object;
490
  }
491
 
492
  // Real Media Library
493
- if ( $taxonomy === 'rml' ) {
494
  $folder_object = new \stdClass();
495
 
496
- $folder_object->folder_id = intval( $folder->fid );
497
- $folder_object->attachment_id = intval( $folder->attachment );
498
 
499
  $mapped_attachments[] = $folder_object;
500
  }
501
-
502
- }
503
 
504
  return $mapped_attachments;
505
- }
506
 
507
- public function get_plugin_attachments( $taxonomy, $folders ) {
 
 
 
 
 
 
 
 
 
 
 
508
  global $wpdb;
509
 
510
  // FileBird has its own db table
511
- if ( $taxonomy === 'filebird' ) {
512
- $filebird_attachments_table = $wpdb->prefix . 'fbv_attachment_folder';
513
 
514
  // Get FileBird attachments (order by 'folder_id')
515
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$filebird_attachments_table'") == $filebird_attachments_table ) {
516
- return $wpdb->get_results( "SELECT * FROM $filebird_attachments_table ORDER BY folder_id ASC" );
517
  }
518
  }
519
 
520
  // Real Media Library has its own db table
521
- else if ( $taxonomy === 'rml' ) {
522
- $rml_attachments_table = $wpdb->prefix . 'realmedialibrary_posts';
523
 
524
  // Get FileBird folders (order by 'parent' to create parent categories first)
525
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$rml_attachments_table'") == $rml_attachments_table ) {
526
- return $wpdb->get_results( "SELECT * FROM $rml_attachments_table ORDER BY fid ASC" );
527
  }
528
  }
529
 
530
  // Default: Plugins with custom taxonomy terms
531
  else {
532
- return $wpdb->get_results(
533
- "SELECT " . $wpdb->term_relationships . ".object_id,
534
- " . $wpdb->term_relationships . ".term_taxonomy_id
535
- FROM " . $wpdb->term_relationships . "
536
- WHERE " . $wpdb->term_relationships . ".term_taxonomy_id IN (" . implode( ',', array_column( $folders, 'term_id' ) ) . ")"
537
- );
538
  }
539
- }
540
- }
541
- $WCP_Folder_Plugins = new WCP_Folder_Plugins();
 
 
 
 
1
  <?php
2
+ /**
3
+ * Class Folders Plugins import/export
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
 
 
 
 
 
12
 
13
+ // Free/Pro Class name change
14
+ class WCP_Folder_Plugins
15
+ {
16
+
17
+ /**
18
+ * Collection of Plugins to import Data
19
+ *
20
+ * @var array $plugins Collection of Plugins
21
+ * @since 1.0.0
22
+ * @access public
23
+ */
24
+ public $plugins = [];
25
+
26
+ /**
27
+ * Collection of Post types to Import
28
+ *
29
+ * @var array $postTypes Post types to import
30
+ * @since 1.0.0
31
+ * @access public
32
+ */
33
+ public $postTypes = [];
34
+
35
+ /**
36
+ * Check is there any data to import
37
+ *
38
+ * @var integer $isExists 0/1
39
+ * @since 1.0.0
40
+ * @access public
41
+ */
42
+ public $isExists = 0;
43
+
44
+
45
+ /**
46
+ * Define the core functionality of the import data functionality.
47
+ *
48
+ * Import data from other plugins
49
+ * Remove data from other plugins
50
+ *
51
+ * @since 1.0.0
52
+ */
53
+ public function __construct()
54
+ {
55
+
56
+ // Import plugin data
57
+ add_action('wp_ajax_wcp_import_plugin_folders_data', [$this, 'import_plugin_folders_data']);
58
+ add_action('wp_ajax_wcp_remove_plugin_folders_data', [$this, 'remove_plugin_folders_data']);
59
+
60
+ }//end __construct()
61
+
62
+
63
+ /**
64
+ * Remove data from other plugins
65
+ *
66
+ * @since 1.0.0
67
+ * @access public
68
+ * @return $response
69
+ */
70
+ public function remove_plugin_folders_data()
71
+ {
72
  global $wpdb;
73
  $postData = filter_input_array(INPUT_POST);
74
 
75
+ $plugin = isset($postData['plugin']) ? sanitize_text_field($postData['plugin']) : "";
76
+ $nonce = isset($postData['nonce']) ? sanitize_text_field($postData['nonce']) : "";
77
+ $response = [];
78
+ $response['status'] = 0;
79
+ $response['message'] = esc_html__("Invalid request", "folders");
80
+ $response['data'] = [];
81
  $response['data']['plugin'] = $plugin;
82
+ if (wp_verify_nonce($nonce, "import_data_from_".$plugin)) {
83
  $this->get_plugin_information();
84
+ $folders = isset($this->plugins[$plugin]['folders']) ? $this->plugins[$plugin]['folders'] : [];
85
+ $attachments = isset($this->plugins[$plugin]['attachments']) ? $this->plugins[$plugin]['attachments'] : [];
86
 
87
+ if ($plugin != 'filebird' && $plugin != 'real-media-library') {
88
  $deleted = [];
89
 
90
+ foreach ($folders as $folder) {
91
+ $term_id = intval($folder->term_id);
92
 
93
+ if ($term_id) {
94
+ $deleted[$term_id]['term_relationships'] = $wpdb->delete($wpdb->prefix.'term_relationships', ['term_taxonomy_id' => $term_id]);
95
+ $deleted[$term_id]['term_taxonomy'] = $wpdb->delete($wpdb->prefix.'term_taxonomy', ['term_id' => $term_id]);
96
+ $deleted[$term_id]['terms'] = $wpdb->delete($wpdb->prefix.'terms', ['term_id' => $term_id]);
97
 
98
+ if ($plugin === 'folders') {
99
+ $deleted[$term_id]['termmeta'] = $wpdb->delete($wpdb->prefix.'termmeta', ['term_id' => $term_id]);
100
  }
101
  }
102
  }
103
  } else {
104
+ if (count($folders)) {
105
+ if ($plugin === 'filebird') {
106
+ $wpdb->query('DELETE FROM '.$wpdb->prefix.'fbv');
 
107
  }
108
 
109
+ if ($plugin === 'real-media-library') {
110
+ $wpdb->query('DELETE FROM '.$wpdb->prefix.'realmedialibrary');
111
 
112
+ $wpdb->query('DELETE FROM '.$wpdb->prefix.'realmedialibrary_meta');
113
  }
114
  }
115
 
116
+ if (count($attachments)) {
117
+ if ($plugin === 'filebird') {
118
+ $wpdb->query('DELETE FROM '.$wpdb->prefix.'fbv_attachment_folder');
119
  }
120
 
121
+ if ($plugin === 'real-media-library') {
122
+ $wpdb->query('DELETE FROM '.$wpdb->prefix.'realmedialibrary_posts');
123
  }
124
  }
125
+ }//end if
126
+
127
  $response['status'] = 1;
128
+ }//end if
129
 
 
130
  echo json_encode($response);
131
  exit;
 
132
 
133
+ }//end remove_plugin_folders_data()
134
+
135
+
136
+ /**
137
+ * Import data from other plugins
138
+ *
139
+ * @since 1.0.0
140
+ * @access public
141
+ * @return $response
142
+ */
143
+ public function import_plugin_folders_data()
144
+ {
145
  $postData = filter_input_array(INPUT_POST);
146
 
147
+ $plugin = isset($postData['plugin']) ? sanitize_text_field($postData['plugin']) : "";
148
+ $nonce = isset($postData['nonce']) ? sanitize_text_field($postData['nonce']) : "";
149
+ $response = [];
150
+ $response['status'] = 0;
151
+ $response['message'] = esc_html__("Invalid request", "folders");
152
+ $response['data'] = [];
153
  $response['data']['plugin'] = $plugin;
154
+ if (wp_verify_nonce($nonce, "import_data_from_".$plugin)) {
155
  $this->get_plugin_information();
156
+ $folders = isset($this->plugins[$plugin]['folders']) ? $this->plugins[$plugin]['folders'] : [];
157
+ $attachments = isset($this->plugins[$plugin]['attachments']) ? $this->plugins[$plugin]['attachments'] : [];
158
 
159
+ $categoryByID = [];
160
+ $foldersImported = [];
161
+ $attachmentsImported = [];
 
 
162
 
163
+ if ($plugin != 'filebird' && $plugin != 'real-media-library') {
164
  foreach ($folders as $folder) {
165
  $folder_id = $folder->term_id;
166
+ $parent = intval($folder->parent);
167
 
168
  $taxonomy = 'media_folder';
169
 
170
+ foreach ($this->postTypes as $post_type) {
171
  if (strpos($folder->taxonomy, $post_type) !== false) {
172
  if ($post_type == "post") {
173
  $taxonomy = "post_folder";
176
  } else if ($post_type == "attachment") {
177
  $taxonomy = "media_folder";
178
  } else {
179
+ $taxonomy = $post_type.'_folder';
180
  }
181
  }
182
  }
191
  continue;
192
  }
193
 
194
+ $arg = [
195
+ 'hide_empty' => false,
196
+ 'parent' => $parent,
197
+ 'hierarchical' => false,
198
  'update_count_callback' => '_update_generic_term_count',
199
+ ];
200
+ $terms = get_terms($taxonomy, $arg);
201
  $position = count($terms);
202
 
203
+ if ($plugin == 'mediamatic' || $plugin == 'happyfiles') {
204
  $meta_key = "";
205
+ if ($plugin == 'mediamatic') {
206
  $meta_key = "folder_position";
207
+ } else if ($plugin == 'happyfiles') {
208
  $meta_key = "happyfiles_position";
209
  }
210
+
211
+ if (!empty($meta_key)) {
212
  $folder_position = get_term_meta($new_term['term_id'], $meta_key, true);
213
+ if (empty($folder_position)) {
214
  $position = intval($folder_position);
215
  }
216
  }
222
 
223
  $categoryByID[$folder_id] = [
224
  'term_id' => $new_term['term_id'],
225
+ 'parent' => $parent,
226
+ 'name' => $folder->name,
227
  ];
228
+ }//end foreach
229
 
230
  // STEP: Assign plugin categories to HF categories
231
  foreach ($attachments as $attachment) {
232
  $hf_category_id = isset($categoryByID[$attachment->term_taxonomy_id]['term_id']) ? intval($categoryByID[$attachment->term_taxonomy_id]['term_id']) : 0;
233
+ $attachment_id = isset($attachment->object_id) ? intval($attachment->object_id) : 0;
234
 
235
  if (!$hf_category_id || !$attachment_id) {
236
  continue;
245
  } else if ($post_type == "attachment") {
246
  $taxonomy = "media_folder";
247
  } else {
248
+ $taxonomy = $post_type.'_folder';
249
  }
250
 
251
+ $term_ids = wp_get_object_terms($attachment_id, $taxonomy, ['fields' => 'ids']);
252
  $term_ids[] = $hf_category_id;
253
 
254
  $term_set = wp_set_object_terms($attachment_id, $term_ids, $taxonomy);
258
  }
259
 
260
  $attachmentsImported[] = [
261
+ 'cat_id' => $hf_category_id,
262
  'term_ids' => $term_ids,
263
+ 'set' => $term_set,
264
  ];
265
+ }//end foreach
266
  } else {
267
+ foreach ($folders as $folder) {
268
+ $parent = intval($folder->parent);
269
  $parentID = 0;
270
 
271
+ if ($parent && isset($categoryByID[$parent]['term_id'])) {
272
  $parentID = $categoryByID[$parent]['term_id'];
273
  }
274
 
275
+ $new_term = wp_insert_term($folder->name, "media_folder", ['parent' => $parentID]);
276
 
277
+ if (is_wp_error($new_term)) {
278
  continue;
279
  }
280
 
281
  $taxonomy = 'media_folder';
282
 
283
+ $arg = [
284
+ 'hide_empty' => false,
285
+ 'parent' => $parentID,
286
+ 'hierarchical' => false,
287
  'update_count_callback' => '_update_generic_term_count',
288
+ ];
289
+ $terms = get_terms($taxonomy, $arg);
290
  $position = count($terms);
291
 
292
+ update_term_meta($new_term['term_id'], 'wcp_custom_order', intval($position));
 
293
 
294
  $foldersImported[] = $new_term;
295
 
298
  'parent' => $parent,
299
  'term_id' => $new_term['term_id'],
300
  ];
301
+ }//end foreach
302
 
303
+ foreach ($attachments as $attachment) {
304
+ $hf_category_id = isset($categoryByID[$attachment->folder_id]['term_id']) ? intval($categoryByID[$attachment->folder_id]['term_id']) : 0;
305
+ $attachment_id = isset($attachment->attachment_id) ? intval($attachment->attachment_id) : 0;
306
 
307
+ if (! $hf_category_id || ! $attachment_id) {
308
  continue;
309
  }
310
 
311
+ $term_ids = wp_get_object_terms($attachment_id, "media_folder", ['fields' => 'ids']);
312
  $term_ids[] = $hf_category_id;
313
 
314
+ $term_set = wp_set_object_terms($attachment_id, $term_ids, "media_folder");
315
 
316
+ if (is_wp_error($term_set)) {
317
  continue;
318
  }
319
 
322
  'term_ids' => $term_ids,
323
  'set' => $term_set,
324
  ];
325
+ }//end foreach
326
+ }//end if
327
 
328
+ $response['status'] = 1;
329
  $response['data']['imported'] = count($foldersImported);
330
  $response['data']['attachments'] = count($attachmentsImported);
331
+ $response['data']['plugin'] = $plugin;
332
+ $response['message'] = sprintf(esc_html__('%s folders imported and %s attachments categorized.', 'folders'), count($foldersImported), count($attachmentsImported));
333
+ }//end if
334
+
335
  echo json_encode($response);
336
  exit;
 
337
 
338
+ }//end import_plugin_folders_data()
339
+
340
+
341
+ /**
342
+ * Get installed Plugins list
343
+ *
344
+ * @since 1.0.0
345
+ * @access public
346
+ * @return $plugins
347
+ */
348
+ public function get_plugin_information()
349
+ {
350
  $this->get_other_plugins_data();
351
  return $this->plugins;
 
352
 
353
+ }//end get_plugin_information()
354
+
355
+
356
+ /**
357
+ * Get installed Plugins list to Import data
358
+ *
359
+ * @since 1.0.0
360
+ * @access public
361
+ * @return $plugins
362
+ */
363
+ public function get_other_plugins_data()
364
+ {
365
+ if (!empty($this->plugins)) {
366
  return $this->plugins;
367
  }
368
+
369
+ $this->plugins = [
370
  // FileBird
371
+ 'filebird' => [
372
+ 'name' => 'FileBird (v4)',
373
+ 'taxonomy' => 'filebird',
374
+ 'folders' => [],
375
+ 'attachments' => [],
376
+ 'total_folders' => 0,
377
  'total_attachments' => 0,
378
+ 'isExists' => 0,
379
+ ],
380
+ 'enhanced-media-library' => [
381
  // Enhanced Media Library
382
+ 'name' => 'Enhanced Media Library',
383
+ 'taxonomy' => 'media_category',
384
+ 'folders' => [],
385
+ 'attachments' => [],
386
+ 'total_folders' => 0,
387
  'total_attachments' => 0,
388
+ 'isExists' => 0,
389
+ ],
390
+ 'wicked-folders' => [
391
  // Enhanced Media Library
392
+ 'name' => 'Wicked Folders',
393
+ 'taxonomy' => 'wf_attachment_folders',
394
+ 'folders' => [],
395
+ 'attachments' => [],
396
+ 'total_folders' => 0,
397
  'total_attachments' => 0,
398
+ 'isExists' => 0,
399
+ ],
400
+ 'real-media-library' => [
401
  // Real Media Library
402
+ 'name' => 'Real Media Library (by DevOwl)',
403
+ 'taxonomy' => 'rml',
404
+ // has custom DB table
405
+ 'folders' => [],
406
+ 'attachments' => [],
407
+ 'total_folders' => 0,
408
  'total_attachments' => 0,
409
+ 'isExists' => 0,
410
+ ],
411
+ 'wp-media-folder' => [
412
  // Real Media Library
413
+ 'name' => 'WP Media Folder (by JoomUnited)',
414
+ 'taxonomy' => 'wpmf-category',
415
+ 'folders' => [],
416
+ 'attachments' => [],
417
+ 'total_folders' => 0,
418
  'total_attachments' => 0,
419
+ 'isExists' => 0,
420
+ ],
421
+ 'mediamatic' => [
422
  // Mediamatic
423
+ 'name' => 'WordPress Media Library Folders | Mediamatic',
424
+ 'taxonomy' => 'mediamatic_wpfolder',
425
+ 'folders' => [],
426
+ 'attachments' => [],
427
+ 'total_folders' => 0,
428
  'total_attachments' => 0,
429
+ 'isExists' => 0,
430
+ ],
431
+ 'happyfiles' => [
432
  // HappyFiles
433
+ 'name' => 'HappyFiles',
434
+ 'taxonomy' => 'happyfiles_category',
435
+ 'folders' => [],
436
+ 'attachments' => [],
437
+ 'total_folders' => 0,
438
  'total_attachments' => 0,
439
+ 'isExists' => 0,
440
+ ],
441
+ ];
442
+ $postTypes = get_post_types([]);
443
+ $this->postTypes = array_keys($postTypes);
444
 
445
+ foreach ($this->plugins as $slug => $plugin_data) {
446
  $taxonomy = $plugin_data['taxonomy'];
447
 
448
+ if ($slug === 'wicked-folders') {
449
  // Run for all registered post types
450
  $folders = [];
451
 
452
+ foreach ($this->postTypes as $post_type) {
453
+ $wicked_folders = $this->get_plugin_folders('wf_'.$post_type.'_folders', $slug);
454
 
455
+ if (is_array($wicked_folders)) {
456
+ $folders = array_merge($folders, $wicked_folders);
457
  }
458
  }
459
+ } else {
460
+ $folders = $this->get_plugin_folders($taxonomy, $slug);
461
  }
462
 
463
+ if (in_array($taxonomy, ['filebird', 'rml'])) {
464
+ $folders = is_array($folders) && count($folders) ? $this->map_plugin_folders($taxonomy, $folders) : [];
 
 
 
 
465
  }
466
 
467
  $this->plugins[$slug]['folders'] = $folders;
468
 
469
+ $attachments = is_array($folders) && count($folders) ? $this->get_plugin_attachments($taxonomy, $folders) : [];
470
 
471
+ if (in_array($taxonomy, ['filebird', 'rml'])) {
472
+ $attachments = $this->map_plugin_attachments($taxonomy, $attachments);
473
  }
474
 
475
  $this->plugins[$slug]['attachments'] = $attachments;
476
+ }//end foreach
477
 
478
+ foreach ($this->plugins as $key => $plugin) {
479
+ $folders = isset($plugin['folders'])&&is_array($plugin['folders']) ? $plugin['folders'] : [];
480
  $this->plugins[$key]['total_folders'] = count($folders);
481
 
482
+ $attachments = isset($plugin['attachments'])&&is_array($plugin['attachments']) ? $plugin['attachments'] : [];
483
  $this->plugins[$key]['total_attachments'] = count($attachments);
484
 
485
+ if (count($folders) > 0 || count($attachments) > 0) {
486
+ $this->plugins[$key]['isExists'] = 1;
487
+ $this->isExists = 1;
488
  }
489
  }
 
490
 
491
+ }//end get_other_plugins_data()
492
+
493
+
494
+ /**
495
+ * Get Folders Data From Imported Plugins
496
+ *
497
+ * @since 1.0.0
498
+ * @access public
499
+ * @return $taxonomy
500
+ */
501
+ public function get_plugin_folders($taxonomy, $slug)
502
+ {
503
  global $wpdb;
504
 
505
  // FileBird has its own db table
506
+ if ($taxonomy === 'filebird') {
507
+ $filebird_folders_table = $wpdb->prefix.'fbv';
508
 
509
  // Get FileBird folders (order by 'parent' to create parent categories first)
510
+ if ($wpdb->get_var("SHOW TABLES LIKE '$filebird_folders_table'") == $filebird_folders_table) {
511
+ return $wpdb->get_results("SELECT * FROM $filebird_folders_table ORDER BY parent ASC");
512
  }
513
  }
514
 
515
  // Real Media Library has its own db table
516
+ else if ($taxonomy === 'rml') {
517
+ $rml_folders_table = $wpdb->prefix.'realmedialibrary';
518
 
519
  // Get FileBird folders (order by 'parent' to create parent categories first)
520
+ if ($wpdb->get_var("SHOW TABLES LIKE '$rml_folders_table'") == $rml_folders_table) {
521
+ return $wpdb->get_results("SELECT * FROM $rml_folders_table ORDER BY parent ASC");
522
  }
523
  }
524
 
525
  // Default: Plugins with custom taxonomy terms
526
  else {
527
+ $query = "SELECT * FROM ".$wpdb->term_taxonomy."
528
+ LEFT JOIN ".$wpdb->terms."
529
+ ON ".$wpdb->term_taxonomy.".term_id = ".$wpdb->terms.".term_id
530
+ WHERE ".$wpdb->term_taxonomy.".taxonomy = '%d'
531
+ ORDER BY parent ASC";
532
+ $query = $wpdb->prepare($query, $taxonomy);
533
+ $folders = $wpdb->get_results($query);
534
 
535
  // WP Media Folder (JoomUnited): Remove root folder
536
+ if ($slug === 'wp-media-folder') {
537
+ foreach ($folders as $index => $folder) {
538
+ if ($folder->slug === 'wp-media-folder-root') {
539
+ unset($folders[$index]);
540
  }
541
  }
542
  }
543
 
544
+ return array_values($folders);
545
  }
 
546
 
547
+ }//end get_plugin_folders()
 
548
 
 
549
 
550
+ /**
551
+ * Get Folders Data From Imported Plugins
552
+ *
553
+ * @since 1.0.0
554
+ * @access public
555
+ * @return $taxonomy
556
+ */
557
+ public function map_plugin_folders($taxonomy, $folders)
558
+ {
559
+ $mapped_folders = [];
560
+
561
+ foreach ($folders as $folder) {
562
  // FileBird, Real Media Library
563
+ if ($taxonomy === 'filebird' || $taxonomy === 'rml') {
564
  $folder_object = new \stdClass();
565
 
566
+ $folder_object->name = $folder->name;
567
+ $folder_object->id = intval($folder->id);
568
+ $folder_object->parent = intval($folder->parent);
569
+ $folder_object->position = intval($folder->ord);
570
 
571
  $mapped_folders[] = $folder_object;
572
  }
 
573
  }
574
 
575
  return $mapped_folders;
 
576
 
577
+ }//end map_plugin_folders()
 
578
 
 
579
 
580
+ /**
581
+ * Save Folders and it's attachment Data From Imported Plugins
582
+ *
583
+ * @since 1.0.0
584
+ * @access public
585
+ * @return $files
586
+ */
587
+ public function map_plugin_attachments($taxonomy, $attachments)
588
+ {
589
+ $mapped_attachments = [];
590
+
591
+ foreach ($attachments as $folder) {
592
  // FileBird
593
+ if ($taxonomy === 'filebird') {
594
  $folder_object = new \stdClass();
595
 
596
+ $folder_object->folder_id = intval($folder->folder_id);
597
+ $folder_object->attachment_id = intval($folder->attachment_id);
598
 
599
  $mapped_attachments[] = $folder_object;
600
  }
601
 
602
  // Real Media Library
603
+ if ($taxonomy === 'rml') {
604
  $folder_object = new \stdClass();
605
 
606
+ $folder_object->folder_id = intval($folder->fid);
607
+ $folder_object->attachment_id = intval($folder->attachment);
608
 
609
  $mapped_attachments[] = $folder_object;
610
  }
611
+ }//end foreach
 
612
 
613
  return $mapped_attachments;
 
614
 
615
+ }//end map_plugin_attachments()
616
+
617
+
618
+ /**
619
+ * Get Folders and it's attachment Data From Imported Plugins
620
+ *
621
+ * @since 1.0.0
622
+ * @access public
623
+ * @return $files
624
+ */
625
+ public function get_plugin_attachments($taxonomy, $folders)
626
+ {
627
  global $wpdb;
628
 
629
  // FileBird has its own db table
630
+ if ($taxonomy === 'filebird') {
631
+ $filebird_attachments_table = $wpdb->prefix.'fbv_attachment_folder';
632
 
633
  // Get FileBird attachments (order by 'folder_id')
634
+ if ($wpdb->get_var("SHOW TABLES LIKE '$filebird_attachments_table'") == $filebird_attachments_table) {
635
+ return $wpdb->get_results("SELECT * FROM $filebird_attachments_table ORDER BY folder_id ASC");
636
  }
637
  }
638
 
639
  // Real Media Library has its own db table
640
+ else if ($taxonomy === 'rml') {
641
+ $rml_attachments_table = $wpdb->prefix.'realmedialibrary_posts';
642
 
643
  // Get FileBird folders (order by 'parent' to create parent categories first)
644
+ if ($wpdb->get_var("SHOW TABLES LIKE '$rml_attachments_table'") == $rml_attachments_table) {
645
+ return $wpdb->get_results("SELECT * FROM $rml_attachments_table ORDER BY fid ASC");
646
  }
647
  }
648
 
649
  // Default: Plugins with custom taxonomy terms
650
  else {
651
+ $query = "SELECT ".$wpdb->term_relationships.".object_id,
652
+ ".$wpdb->term_relationships.".term_taxonomy_id
653
+ FROM ".$wpdb->term_relationships."
654
+ WHERE ".$wpdb->term_relationships.".term_taxonomy_id IN (%s)";
655
+ $query = $wpdb->prepare($query, implode(',', array_column($folders, 'term_id')));
656
+ return $wpdb->get_results($query);
657
  }
658
+
659
+ }//end get_plugin_attachments()
660
+
661
+
662
+ }//end class
663
+
664
+ $WCP_Folder_Plugins = new WCP_Folder_Plugins();
includes/tree.class.php CHANGED
@@ -1,172 +1,208 @@
1
  <?php
2
- if(!defined('ABSPATH')) exit;
3
- class WCP_Tree {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- public function __construct() {
6
 
7
- }
8
 
9
- public static function get_full_tree_data($post_type, $order_by = "", $order = "") {
10
- $isAjax = (defined('DOING_AJAX') && DOING_AJAX)?1:0;
11
- $type = filter_input(INPUT_GET, $post_type, FILTER_SANITIZE_STRING);
12
- if((isset($type) && !empty($type)) || ! $isAjax) {
13
- update_option("selected_" . $post_type . "_folder", "");
14
- }
15
- return self::get_folder_category_data($post_type, 0, 0, $order_by, $order);
16
- }
17
 
18
- public static function get_folder_category_data($post_type, $parent = 0, $parentStatus = 0, $order_by = "", $order = "") {
 
 
 
 
 
 
 
 
19
 
20
- $arg = array(
21
- 'hide_empty' => false,
22
- 'parent' => $parent,
23
- 'hierarchical' => false,
24
  'update_count_callback' => '_update_generic_term_count',
25
- );
26
- if(!empty($order_by) && !empty($order)) {
27
- $arg['orderby'] = $order_by;
28
- $arg['order'] = $order;
29
  } else {
30
- $arg['orderby'] = 'meta_value_num';
31
- $arg['order'] = 'ASC';
32
- $arg['meta_query'] = [[
33
- 'key' => 'wcp_custom_order',
34
- 'type' => 'NUMERIC',
35
- ]];
 
 
36
  }
37
 
38
- $terms = get_terms( $post_type, $arg);
39
 
40
- $string = "";
41
  $sticky_string = "";
42
- $child = 0;
43
- $isAjax = (defined('DOING_AJAX') && DOING_AJAX)?1:0;
44
- if(!empty($terms)) {
45
  $child = count($terms);
46
- foreach($terms as $key=>$term) {
47
-
48
- if(!empty($order_by) && !empty($order)) {
49
- update_term_meta($term->term_id, "wcp_custom_order", ($key+1));
50
  }
51
 
52
- $is_sticky = get_term_meta($term->term_id, "is_folder_sticky", true);
53
-
54
  $status = get_term_meta($term->term_id, "is_active", true);
55
- $return = self::get_folder_category_data($post_type, $term->term_id, $status, $order_by, $order);
56
- $class = ($status == 1 && $return['child']>0)?"active":"";
57
- $class .= ($return['child'])>0?" has-sub-tree":"";
58
- $term_var = filter_input(INPUT_GET, "term", FILTER_SANITIZE_STRING);
59
- $type = filter_input(INPUT_GET, $post_type, FILTER_SANITIZE_STRING);
60
- if($post_type == "attachment") {
61
- $class .= (isset($term_var) && $term_var == $term->slug)?" active-item active-term":"";
62
- if(isset($type) && $type == $term->slug) {
63
- update_option("selected_".$post_type."_folder", $term->term_id);
64
  }
65
- if(!isset($type) && $isAjax) {
66
- $termId = get_option("selected_".$post_type."_folder");
67
- $class .= ($termId == $term->term_id)?" active-item active-term":"";
68
  }
69
  } else {
70
- $class .= (isset($type) && $type == $term->slug)?" active-item active-term":"";
71
- if(isset($type) && $type == $term->slug) {
72
- update_option("selected_" . $post_type . "_folder", $term->term_id);
73
  }
74
- if(!isset($type) && $isAjax) {
75
- $termId = get_option("selected_".$post_type."_folder");
76
- $class .= ($termId == $term->term_id)?" active-item active-term":"";
77
  }
78
  }
79
- $status = get_term_meta($term->term_id, "is_highlighted", true);
80
- $class .= ($status == 1)?" is-high":"";
81
- $sticky_class = ($status == 1)?"is-high":"";
82
- $count = ($term->trash_count != 0)?$term->trash_count:0;
83
- if($is_sticky == 1) {
84
- $class .= " is-sticky";
85
- }
86
-
87
- $count_sticky = ($term->trash_count != 0)?"<span class='folder-count'>{$term->trash_count}</span>":"";
88
 
89
- if($is_sticky == 1) {
90
- //$sticky_string .= "<li data-folder-id='{$term->term_id}' class='sticky-fldr {$sticky_class} sticky-folder-{$term->term_id}'><a href='javascript:;'><span class='folder-title'>{$term->name}</span>{$count_sticky}<span class='update-inline-record'><i class='pfolder-edit-folder'></i></span><span class='star-icon'><i class='pfolder-star'></i></span></a></li>";
91
- }
92
 
93
- /* Free/Pro URL Change*/
94
- // $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 wcp_folder_{$term->term_id} {$class}' id='wcp_folder_{$term->term_id}' data-folder-id='{$term->term_id}'>";
95
- // $string .= "<h3 class='title' title='{$term->name}' id='title_{$term->term_id}'>";
96
- // $string .= "<span class='ui-icon'>";
97
- // $string .= "<i class='wcp-icon pfolder-folder-close'></i>";
98
- // $string .= "<input type='checkbox' class='checkbox' value='{$term->term_id}' />";
99
- // $string .= "</span>";
100
- // $string .= "<span class='title-text'>{$term->name}</span>";
101
- // $string .= "{$count} <span class='update-inline-record'><i class='pfolder-edit-folder'></i></span> <span class='star-icon'><i class='pfolder-star'></i></span>";
102
- // $string .= "<span class='folder-sticky-icon'><i class='pfolder-pin'></i></span>";
103
- // //$string .= "<span class='move-folder-icon' ><i class='pfolder-move'></i></span>";
104
- // $string .= "</h3>";
105
- // $string .= "<span class='nav-icon'><i class='wcp-icon pfolder-arrow-down'></i></span>";
106
- // $string .= "<ul class='space' id='space_{$term->term_id}'>";
107
- // $string .= $return['string'];
108
- // $string .= "</ul></li>";
109
-
110
- // $parent = (empty($parent))?"#":$parent;
111
- $nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
112
  $is_sticky = get_term_meta($term->term_id, "is_folder_sticky", true);
113
- $status = get_term_meta($term->term_id, "is_highlighted", true);
114
  $is_active = get_term_meta($term->term_id, "is_active", true);
115
- $class = "";
116
- if($is_sticky == 1) {
117
  $class .= " is-sticky";
118
  }
119
- if($status == 1) {
 
120
  $class .= " is-high";
121
  }
122
- if($is_active == 1) {
 
123
  $class .= " jstree-open";
124
  }
125
 
126
- $string .= "<li id='{$term->term_id}' class='{$class}' data-slug='{$term->slug}' data-nonce='{$nonce}' data-folder='{$term->term_id}' data-child='{$child}' data-count='{$count}' data-parent='{$parent}'>
127
- {$term->name}
128
- <ul>{$return['string']}</ul>
129
  </li>";
130
 
131
  $sticky_string .= $return['sticky_string'];
132
- }
133
- }
134
- return array(
135
- 'string' =>$string,
136
- 'sticky_string' =>$sticky_string,
137
- 'child' => $child
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  );
139
- }
140
 
141
- public static function get_option_data_for_select($post_type) {
142
- $string = "<option value='0'>Parent Folder</option>";
143
- $string .= self::get_folder_option_data($post_type, 0, '');
144
- return $string;
145
- }
146
-
147
- public static function get_folder_option_data($post_type, $parent = 0, $space = "") {
148
- $terms = get_terms( $post_type, array(
149
- 'hide_empty' => false,
150
- 'parent' => $parent,
151
- 'orderby' => 'meta_value_num',
152
- 'order' => 'ASC',
153
- 'hierarchical' => false,
154
- 'meta_query' => [[
155
- 'key' => 'wcp_custom_order',
156
- 'type' => 'NUMERIC',
157
- ]]
158
- ) );
159
-
160
- $selected_term = get_option("selected_" . $post_type . "_folder");
161
 
162
  $string = "";
163
- if(!empty($terms)) {
164
- foreach($terms as $term) {
165
- $selected = ($selected_term == $term->term_id)?"selected":"";
166
- $string .= "<option {$selected} value='{$term->term_id}'>{$space}{$term->name}</option>";
167
- $string .= self::get_folder_option_data($post_type, $term->term_id, trim($space)."- ");
168
  }
169
  }
 
170
  return $string;
171
- }
172
- }
 
 
 
1
  <?php
2
+ /**
3
+ * Class Folders Tree
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ class WCP_Tree
14
+ {
15
+
16
+
17
+ /**
18
+ * Define the core functionality to shoe taxonomies
19
+ *
20
+ * @since 1.0.0
21
+ */
22
+ public function __construct()
23
+ {
24
+
25
+ }//end __construct()
26
+
27
+
28
+ /**
29
+ * Get tree data into taxonomies (Root Folder)
30
+ *
31
+ * @since 1.0.0
32
+ * @access public
33
+ * @return $categories
34
+ */
35
+ public static function get_full_tree_data($postType, $orderBy="", $order="")
36
+ {
37
+ $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0;
38
+ $type = filter_input(INPUT_GET, $postType, FILTER_SANITIZE_STRING);
39
+ if ((isset($type) && !empty($type)) || ! $isAjax) {
40
+ update_option("selected_".$postType."_folder", "");
41
+ }
42
 
43
+ return self::get_folder_category_data($postType, 0, 0, $orderBy, $order);
44
 
45
+ }//end get_full_tree_data()
46
 
 
 
 
 
 
 
 
 
47
 
48
+ /**
49
+ * Get tree data into taxonomies (Child Folder)
50
+ *
51
+ * @since 1.0.0
52
+ * @access public
53
+ * @return $categories
54
+ */
55
+ public static function get_folder_category_data($postType, $parent=0, $parentStatus=0, $orderBy="", $order="")
56
+ {
57
 
58
+ $arg = [
59
+ 'hide_empty' => false,
60
+ 'parent' => $parent,
61
+ 'hierarchical' => false,
62
  'update_count_callback' => '_update_generic_term_count',
63
+ ];
64
+ if (!empty($orderBy) && !empty($order)) {
65
+ $arg['orderby'] = $orderBy;
66
+ $arg['order'] = $order;
67
  } else {
68
+ $arg['orderby'] = 'meta_value_num';
69
+ $arg['order'] = 'ASC';
70
+ $arg['meta_query'] = [
71
+ [
72
+ 'key' => 'wcp_custom_order',
73
+ 'type' => 'NUMERIC',
74
+ ],
75
+ ];
76
  }
77
 
78
+ $terms = get_terms($postType, $arg);
79
 
80
+ $string = "";
81
  $sticky_string = "";
82
+ $child = 0;
83
+ $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0;
84
+ if (!empty($terms)) {
85
  $child = count($terms);
86
+ foreach ($terms as $key => $term) {
87
+ if (!empty($orderBy) && !empty($order)) {
88
+ update_term_meta($term->term_id, "wcp_custom_order", ($key + 1));
 
89
  }
90
 
 
 
91
  $status = get_term_meta($term->term_id, "is_active", true);
92
+ $return = self::get_folder_category_data($postType, $term->term_id, $status, $orderBy, $order);
93
+ $type = filter_input(INPUT_GET, $postType, FILTER_SANITIZE_STRING);
94
+ if ($postType == "attachment") {
95
+ if (isset($type) && $type == $term->slug) {
96
+ update_option("selected_".$postType."_folder", $term->term_id);
 
 
 
 
97
  }
98
+
99
+ if (!isset($type) && $isAjax) {
100
+ $termId = get_option("selected_".$postType."_folder");
101
  }
102
  } else {
103
+ if (isset($type) && $type == $term->slug) {
104
+ update_option("selected_".$postType."_folder", $term->term_id);
 
105
  }
106
+
107
+ if (!isset($type) && $isAjax) {
108
+ $termId = get_option("selected_".$postType."_folder");
109
  }
110
  }
 
 
 
 
 
 
 
 
 
111
 
112
+ $count = ($term->trash_count != 0) ? $term->trash_count : 0;
 
 
113
 
114
+ // Free/Pro URL Change
115
+ $nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  $is_sticky = get_term_meta($term->term_id, "is_folder_sticky", true);
117
+ $status = get_term_meta($term->term_id, "is_highlighted", true);
118
  $is_active = get_term_meta($term->term_id, "is_active", true);
119
+ $class = "";
120
+ if ($is_sticky == 1) {
121
  $class .= " is-sticky";
122
  }
123
+
124
+ if ($status == 1) {
125
  $class .= " is-high";
126
  }
127
+
128
+ if ($is_active == 1) {
129
  $class .= " jstree-open";
130
  }
131
 
132
+ $string .= "<li id='".esc_attr($term->term_id)."' class='".esc_attr($class)."' data-slug='".esc_attr($term->slug)."' data-nonce='".esc_attr($nonce)."' data-folder='".esc_attr($term->term_id)."' data-child='".esc_attr($child)."' data-count='".esc_attr($count)."' data-parent='".esc_attr($parent)."'>
133
+ ".esc_attr($term->name)."
134
+ <ul>".esc_attr($return['string'])."</ul>
135
  </li>";
136
 
137
  $sticky_string .= $return['sticky_string'];
138
+ }//end foreach
139
+ }//end if
140
+
141
+ return [
142
+ 'string' => $string,
143
+ 'sticky_string' => $sticky_string,
144
+ 'child' => $child,
145
+ ];
146
+
147
+ }//end get_folder_category_data()
148
+
149
+
150
+ /**
151
+ * Get option data into taxonomies (Parent Folder)
152
+ *
153
+ * @since 1.0.0
154
+ * @access public
155
+ * @return $categories
156
+ */
157
+ public static function get_option_data_for_select($postType)
158
+ {
159
+ $string = "<option value='0'>Parent Folder</option>";
160
+ $string .= self::get_folder_option_data($postType, 0, '');
161
+ return $string;
162
+
163
+ }//end get_option_data_for_select()
164
+
165
+
166
+ /**
167
+ * Get option data into taxonomies (Child Folder)
168
+ *
169
+ * @since 1.0.0
170
+ * @access public
171
+ * @return $categories
172
+ */
173
+ public static function get_folder_option_data($postType, $parent=0, $space="")
174
+ {
175
+ $terms = get_terms(
176
+ $postType,
177
+ [
178
+ 'hide_empty' => false,
179
+ 'parent' => $parent,
180
+ 'orderby' => 'meta_value_num',
181
+ 'order' => 'ASC',
182
+ 'hierarchical' => false,
183
+ 'meta_query' => [
184
+ [
185
+ 'key' => 'wcp_custom_order',
186
+ 'type' => 'NUMERIC',
187
+ ],
188
+ ],
189
+ ]
190
  );
 
191
 
192
+ $selected_term = get_option("selected_".$postType."_folder");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  $string = "";
195
+ if (!empty($terms)) {
196
+ foreach ($terms as $term) {
197
+ $selected = ($selected_term == $term->term_id) ? "selected" : "";
198
+ $string .= "<option ".esc_attr($selected)." value='".esc_attr($term->term_id)."'>".esc_attr($space).esc_attr($term->name)."</option>";
199
+ $string .= self::get_folder_option_data($postType, $term->term_id, trim($space)."- ");
200
  }
201
  }
202
+
203
  return $string;
204
+
205
+ }//end get_folder_option_data()
206
+
207
+
208
+ }//end class
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: galdub, tomeraharon, premio
3
  Tags: folder, folders, replace media, pages folders, media library, posts folders, media folders, media replace, file manager, directories, media library folders, media library folder
4
  Requires at least: 3.0.0
5
  Tested up to: 6.0
6
- Stable tag: 2.8.3
7
  Plugin URI: https://premio.io/downloads/folders/
8
 
9
  Folders is a WordPress plugin that will help you quickly create unlimited folders and organize and manage your Media Library files, Pages & Posts in folders
@@ -199,6 +199,9 @@ A live demo for the Folders plugin is available at <a href="https://demo.premio.
199
 
200
  == Changelog ==
201
 
 
 
 
202
  = 2.8.3 =
203
  Texts changed
204
 
3
  Tags: folder, folders, replace media, pages folders, media library, posts folders, media folders, media replace, file manager, directories, media library folders, media library folder
4
  Requires at least: 3.0.0
5
  Tested up to: 6.0
6
+ Stable tag: 2.8.4
7
  Plugin URI: https://premio.io/downloads/folders/
8
 
9
  Folders is a WordPress plugin that will help you quickly create unlimited folders and organize and manage your Media Library files, Pages & Posts in folders
199
 
200
  == Changelog ==
201
 
202
+ = 2.8.4 =
203
+ Infrastructure improvements
204
+
205
  = 2.8.3 =
206
  Texts changed
207
 
templates/admin/admin-content.php CHANGED
@@ -1,56 +1,71 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
 
 
 
 
 
 
 
 
3
  ?>
4
  <style>
5
  <?php
6
  $string = "";
7
  global $typenow;
8
- $width = get_option("wcp_dynamic_width_for_" . $typenow);
9
  $width = intval($width);
10
- if($width == null || empty($width) || $width > 1200) {
11
  $width = 280;
12
  }
13
- $width = $width - 40;
 
14
  $customize_folders = get_option('customize_folders');
15
  ?>
16
  </style>
17
  <style>
18
  <?php
19
  $font_family = "";
20
- if(isset($customize_folders['folder_font']) && !empty($customize_folders['folder_font'])) {
21
- $font_family = $customize_folders['folder_font'];
22
  $folder_fonts = self::get_font_list();
23
- if(isset($folder_fonts[$font_family])) {
24
- if($font_family == "System Stack") {
25
  $font_family = "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif";
26
  }
27
  ?>
28
  .wcp-container, .folder-popup-form, .dynamic-menu { font-family: <?php echo esc_attr($font_family) ?>; }
29
- <?php
30
- }
31
- if($font_family == "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif") {
32
- $font_family = "System Stack";
33
- }
34
- if($folder_fonts[$font_family] == "Default") {
35
- $font_family = "";
36
- }
 
 
37
  }
38
- if(!isset($customize_folders['new_folder_color']) || empty($customize_folders['new_folder_color'])) {
39
- $customize_folders['new_folder_color'] = "#f51366";
 
40
  }
41
  ?>
42
  .add-new-folder { background-color: <?php echo esc_attr($customize_folders['new_folder_color']) ?>; border-color: <?php echo esc_attr($customize_folders['new_folder_color']) ?> }
43
  .wcp-hide-show-buttons .toggle-buttons { background-color: <?php echo esc_attr($customize_folders['new_folder_color']) ?>; }
44
  .folders-toggle-button span { background-color: <?php echo esc_attr($customize_folders['new_folder_color']) ?>; }
45
  .ui-resizable-handle.ui-resizable-e:before, .ui-resizable-handle.ui-resizable-w:before {border-color: <?php echo esc_attr($customize_folders['new_folder_color']) ?>;}
46
- <?php if(!isset($customize_folders['bulk_organize_button_color']) || empty($customize_folders['bulk_organize_button_color'])) {
47
  $customize_folders['bulk_organize_button_color'] = "#f51366";
48
  } ?>
49
  button.button.organize-button { background-color: <?php echo esc_attr($customize_folders['bulk_organize_button_color']) ?>; border-color: <?php echo esc_attr($customize_folders['bulk_organize_button_color']) ?>; }
50
  button.button.organize-button:hover { background-color: <?php echo esc_attr($customize_folders['bulk_organize_button_color']) ?>; border-color: <?php echo esc_attr($customize_folders['bulk_organize_button_color']) ?>; }
51
- <?php if(!isset($customize_folders['folder_bg_color']) || empty($customize_folders['folder_bg_color'])) {
52
  $customize_folders['folder_bg_color'] = "#f51366";
53
  }
 
54
  $rgbColor = self::hexToRgb($customize_folders['folder_bg_color']); ?>
55
  body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked), body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked):hover, .dynamic-menu a.active, .dynamic-menu a:hover, .folder-setting-menu li a:hover { background: rgba(<?php echo esc_attr($rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08") ?>) !important; color: #333333;}
56
  body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked, body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked:not(.jstree-clicked):focus, #custom-scroll-menu .jstree-clicked, #custom-scroll-menu .jstree-clicked:hover { background: <?php echo esc_attr($customize_folders['folder_bg_color']) ?> !important; color: #ffffff !important; }
@@ -85,9 +100,9 @@ body:not(.no-hover-css) .wcp-container .route .title:hover, body:not(.no-hover-c
85
  .jstree-node.drag-in > a.jstree-anchor.jstree-hovered { background-color: <?php echo esc_attr($customize_folders['folder_bg_color']) ?> !important; color: #ffffff; }
86
  <?php
87
 
88
- if(isset($customize_folders['folder_size']) && !empty($customize_folders['folder_size'])) {
89
- if($customize_folders['folder_size'] == "custom") {
90
- $customize_folders['folder_size'] = ! isset( $customize_folders['folder_custom_font_size'] ) || empty( $customize_folders['folder_custom_font_size'] ) ? "16" : $customize_folders['folder_custom_font_size'];
91
  }
92
  ?>
93
  .wcp-container .route span.title-text, .header-posts a, .un-categorised-items a, .sticky-title, .sticky-folders > ul > li > a, .jstree-default .jstree-anchor { font-size: <?php echo esc_attr($customize_folders['folder_size']) ?>px; }
@@ -95,51 +110,57 @@ if(isset($customize_folders['folder_size']) && !empty($customize_folders['folder
95
  }
96
  ?>
97
  </style>
98
- <?php if(!empty($font_family)) {
99
- wp_enqueue_style( 'custom-google-fonts', 'https://fonts.googleapis.com/css?family='.urlencode($font_family), false );
100
  } ?>
101
  <div id="media-css">
102
 
103
  </div>
104
  <?php
105
  $optionName = $typenow."_parent_status";
106
- $status = get_option($optionName);
107
  global $typenow;
108
  $title = ucfirst($typenow);
109
- if($typenow == "page") {
110
  $title = "Pages";
111
- } else if($typenow == "post") {
112
  $title = "Posts";
113
- } else if($typenow == "attachment") {
114
  $title = "Files";
115
  } else {
116
- $post_type = $typenow;
117
- $post_types = get_post_types( array( "name" => $post_type), 'objects' );
118
- if(!empty($post_types) && is_array($post_types) && isset($post_types[$post_type]) && isset($post_types[$post_type]->label)) {
119
  $title = $post_types[$post_type]->label;
120
  }
121
  }
122
- $display_status = "wcp_dynamic_display_status_" . $typenow;
 
123
  $display_status = get_option($display_status);
124
- $class_name = isset($display_status) && $display_status == "hide"?"hide-folders-area":"";
125
- $active_class = (isset($display_status) && $display_status == "hide")?"":"active";
126
- $active_class_2 = (isset($display_status) && $display_status == "hide")?"active":"";
127
 
128
- /* Do not change here, Free/Pro Class name */
129
- $post_type = WCP_Folders::get_custom_post_type($typenow);
130
- $active = "";
131
  $active_all_class = "";
132
- if(!empty($post_type)) {
133
- if(isset($_REQUEST[$post_type]) && $_REQUEST[$post_type] == -1) {
 
 
 
 
 
134
  $active = "active-item";
135
  }
136
 
137
- if(!isset($_REQUEST[$post_type]) || $_REQUEST[$post_type] == "") {
138
  $active_all_class = "active-item";
139
  }
140
  }
141
  ?>
142
- <div id="wcp-content" class="<?php echo esc_attr(isset($display_status) && $display_status == "hide"?"hide-folders-area":"") ?>" >
143
  <div id="wcp-content-resize">
144
  <div class="wcp-content">
145
  <div class="wcp-hide-show-buttons">
@@ -148,7 +169,7 @@ if(!empty($post_type)) {
148
  </div>
149
  <div class='wcp-container'>
150
  <div class="sticky-wcp-custom-form">
151
- <?php echo $form_html ?>
152
  <div class="top-settings">
153
  <div class="folder-search-form">
154
  <div class="form-search-input">
@@ -158,10 +179,10 @@ if(!empty($post_type)) {
158
  </div>
159
  <div class="folder-separator"></div>
160
  <div class="header-posts">
161
- <a href="javascript:;" class="all-posts <?php echo esc_attr($active_all_class) ?>"><?php esc_attr_e("All ".$title, 'folders'); ?> <span class="total-count"><?php echo esc_attr($ttpsts) ?></span></a>
162
  </div>
163
  <div class="un-categorised-items <?php echo esc_attr($active) ?>">
164
- <a href="javascript:;" class="un-categorized-posts"><?php esc_attr_e("Unassigned ".$title, 'folders'); ?> <span class="total-count total-empty"><?php echo esc_attr($ttemp) ?></span> </a>
165
  </div>
166
  <div class="folder-separator-2"></div>
167
  <div class="folders-action-menu">
@@ -211,10 +232,10 @@ if(!empty($post_type)) {
211
  </div>
212
  </div>
213
  <div class="js-tree-data">
214
- <div id="js-tree-menu" class="<?php echo ($status==1)?"active":"" ?>">
215
  <!--<div class="wcp-parent" id="title0"><i class="fa fa-folder-o"></i> All Folders</div>-->
216
  <ul class='space first-space' id='space_0'>
217
- <?php echo $terms_data; ?>
218
  </ul>
219
  </div>
220
  </div>
@@ -252,7 +273,7 @@ if(!empty($post_type)) {
252
  <?php esc_html_e("Pro tip", "folders") ?>
253
  </span>
254
  <div class="pro-notice">
255
- <?php printf( esc_html__("%sUpgrade to Pro%s to create subfolders (with 20+ amazing features) & premium support 🎉", "folders"), '<a class="inline-button" target="_blank" href="'.esc_url($this->getFoldersUpgradeURL()).'">', "</a>"); ?>
256
  </div>
257
  </div>
258
  <div class="folder-form-buttons">
@@ -327,7 +348,7 @@ if(!empty($post_type)) {
327
  </div>
328
  <div class="folder-form-buttons">
329
  <a href="javascript:;" class="form-cancel-btn"><?php esc_html_e("Cancel", "folders") ?></a>
330
- <a href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" target="_blank" class="form-submit-btn"><?php esc_html_e("Activate License Key", "folders") ?></a>
331
  </div>
332
  </div>
333
  </div>
@@ -376,13 +397,13 @@ if(!empty($post_type)) {
376
  <a class="" href="javascript:;"><span></span></a>
377
  </div>
378
  <div class="add-update-folder-title">
379
- <?php esc_html_e("Sub-folders is a pro feature", "folders") ?>
380
  </div>
381
  <div class="folder-form-message" style="padding: 25px 0 15px;" >
382
- <?php esc_html_e("Hey, it looks like you want to create sub-folders on Folders. Sub-folders is a premium feature. Upgrade to Pro to create, access and organize your files with sub-folders.", "folders") ?>
383
  </div>
384
  <div class="folder-form-message" style="padding: 0 10px 25px;" >
385
- <?php esc_html_e("You can still create unlimited folders in the free version.", "folders") ?>
386
  </div>
387
  <div class="checkbox-content">
388
  <?php $check_status = get_option("premio_hide_child_popup"); ?>
@@ -403,7 +424,7 @@ if(!empty($post_type)) {
403
  <a class="" href="javascript:;"><span></span></a>
404
  </div>
405
  <div class="add-update-folder-title">
406
- <?php esc_html_e("Confirm your change", "folders") ?>
407
  </div>
408
  <div class="folder-form-message" style="padding: 25px 10px;" >
409
  Hey, it looks like you want to move the file to "Unassigned Files." Do you want to move the file from the current folder only or from all the folders where the file exists?
@@ -438,7 +459,7 @@ if(!empty($post_type)) {
438
  <?php esc_html_e("Pro tip", "folders") ?>
439
  </span>
440
  <div class="pro-notice">
441
- <?php printf( esc_html__("%sUpgrade to Pro%s to create subfolders (with 20+ amazing features) & premium support 🎉", "folders"), '<a class="inline-button" target="_blank" href="'.esc_url($this->getFoldersUpgradeURL()).'">', "</a>"); ?>
442
  </div>
443
  </div>
444
  </div>
1
  <?php
2
+ /**
3
+ * Admin form folder settings
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
  ?>
14
  <style>
15
  <?php
16
  $string = "";
17
  global $typenow;
18
+ $width = get_option("wcp_dynamic_width_for_".$typenow);
19
  $width = intval($width);
20
+ if ($width == null || empty($width) || $width > 1200) {
21
  $width = 280;
22
  }
23
+
24
+ $width = ($width - 40);
25
  $customize_folders = get_option('customize_folders');
26
  ?>
27
  </style>
28
  <style>
29
  <?php
30
  $font_family = "";
31
+ if (isset($customize_folders['folder_font']) && !empty($customize_folders['folder_font'])) {
32
+ $font_family = $customize_folders['folder_font'];
33
  $folder_fonts = self::get_font_list();
34
+ if (isset($folder_fonts[$font_family])) {
35
+ if ($font_family == "System Stack") {
36
  $font_family = "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif";
37
  }
38
  ?>
39
  .wcp-container, .folder-popup-form, .dynamic-menu { font-family: <?php echo esc_attr($font_family) ?>; }
40
+ <?php
41
+ }
42
+
43
+ if ($font_family == "-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif") {
44
+ $font_family = "System Stack";
45
+ }
46
+
47
+ if ($folder_fonts[$font_family] == "Default") {
48
+ $font_family = "";
49
+ }
50
  }
51
+
52
+ if (!isset($customize_folders['new_folder_color']) || empty($customize_folders['new_folder_color'])) {
53
+ $customize_folders['new_folder_color'] = "#f51366";
54
  }
55
  ?>
56
  .add-new-folder { background-color: <?php echo esc_attr($customize_folders['new_folder_color']) ?>; border-color: <?php echo esc_attr($customize_folders['new_folder_color']) ?> }
57
  .wcp-hide-show-buttons .toggle-buttons { background-color: <?php echo esc_attr($customize_folders['new_folder_color']) ?>; }
58
  .folders-toggle-button span { background-color: <?php echo esc_attr($customize_folders['new_folder_color']) ?>; }
59
  .ui-resizable-handle.ui-resizable-e:before, .ui-resizable-handle.ui-resizable-w:before {border-color: <?php echo esc_attr($customize_folders['new_folder_color']) ?>;}
60
+ <?php if (!isset($customize_folders['bulk_organize_button_color']) || empty($customize_folders['bulk_organize_button_color'])) {
61
  $customize_folders['bulk_organize_button_color'] = "#f51366";
62
  } ?>
63
  button.button.organize-button { background-color: <?php echo esc_attr($customize_folders['bulk_organize_button_color']) ?>; border-color: <?php echo esc_attr($customize_folders['bulk_organize_button_color']) ?>; }
64
  button.button.organize-button:hover { background-color: <?php echo esc_attr($customize_folders['bulk_organize_button_color']) ?>; border-color: <?php echo esc_attr($customize_folders['bulk_organize_button_color']) ?>; }
65
+ <?php if (!isset($customize_folders['folder_bg_color']) || empty($customize_folders['folder_bg_color'])) {
66
  $customize_folders['folder_bg_color'] = "#f51366";
67
  }
68
+
69
  $rgbColor = self::hexToRgb($customize_folders['folder_bg_color']); ?>
70
  body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked), body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked):hover, .dynamic-menu a.active, .dynamic-menu a:hover, .folder-setting-menu li a:hover { background: rgba(<?php echo esc_attr($rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08") ?>) !important; color: #333333;}
71
  body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked, body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked:not(.jstree-clicked):focus, #custom-scroll-menu .jstree-clicked, #custom-scroll-menu .jstree-clicked:hover { background: <?php echo esc_attr($customize_folders['folder_bg_color']) ?> !important; color: #ffffff !important; }
100
  .jstree-node.drag-in > a.jstree-anchor.jstree-hovered { background-color: <?php echo esc_attr($customize_folders['folder_bg_color']) ?> !important; color: #ffffff; }
101
  <?php
102
 
103
+ if (isset($customize_folders['folder_size']) && !empty($customize_folders['folder_size'])) {
104
+ if ($customize_folders['folder_size'] == "custom") {
105
+ $customize_folders['folder_size'] = ! isset($customize_folders['folder_custom_font_size']) || empty($customize_folders['folder_custom_font_size']) ? "16" : $customize_folders['folder_custom_font_size'];
106
  }
107
  ?>
108
  .wcp-container .route span.title-text, .header-posts a, .un-categorised-items a, .sticky-title, .sticky-folders > ul > li > a, .jstree-default .jstree-anchor { font-size: <?php echo esc_attr($customize_folders['folder_size']) ?>px; }
110
  }
111
  ?>
112
  </style>
113
+ <?php if (!empty($font_family)) {
114
+ wp_enqueue_style('custom-google-fonts', 'https://fonts.googleapis.com/css?family='.urlencode($font_family), false);
115
  } ?>
116
  <div id="media-css">
117
 
118
  </div>
119
  <?php
120
  $optionName = $typenow."_parent_status";
121
+ $status = get_option($optionName);
122
  global $typenow;
123
  $title = ucfirst($typenow);
124
+ if ($typenow == "page") {
125
  $title = "Pages";
126
+ } else if ($typenow == "post") {
127
  $title = "Posts";
128
+ } else if ($typenow == "attachment") {
129
  $title = "Files";
130
  } else {
131
+ $post_type = $typenow;
132
+ $post_types = get_post_types([ "name" => $post_type], 'objects');
133
+ if (!empty($post_types) && is_array($post_types) && isset($post_types[$post_type]) && isset($post_types[$post_type]->label)) {
134
  $title = $post_types[$post_type]->label;
135
  }
136
  }
137
+
138
+ $display_status = "wcp_dynamic_display_status_".$typenow;
139
  $display_status = get_option($display_status);
140
+ $class_name = isset($display_status) && $display_status == "hide" ? "hide-folders-area" : "";
141
+ $active_class = (isset($display_status) && $display_status == "hide") ? "" : "active";
142
+ $active_class_2 = (isset($display_status) && $display_status == "hide") ? "active" : "";
143
 
144
+ // Do not change here, Free/Pro Class name
145
+ $post_type = WCP_Folders::get_custom_post_type($typenow);
146
+ $active = "";
147
  $active_all_class = "";
148
+ if (!empty($post_type)) {
149
+ $activeItem = filter_input(INPUT_POST, $post_type);
150
+ if (empty($activeItem)) {
151
+ $activeItem = filter_input(INPUT_GET, $post_type);
152
+ }
153
+
154
+ if ($activeItem == -1) {
155
  $active = "active-item";
156
  }
157
 
158
+ if (empty($activeItem) || $activeItem == "") {
159
  $active_all_class = "active-item";
160
  }
161
  }
162
  ?>
163
+ <div id="wcp-content" class="<?php echo esc_attr(isset($display_status) && $display_status == "hide" ? "hide-folders-area" : "") ?>" >
164
  <div id="wcp-content-resize">
165
  <div class="wcp-content">
166
  <div class="wcp-hide-show-buttons">
169
  </div>
170
  <div class='wcp-container'>
171
  <div class="sticky-wcp-custom-form">
172
+ <?php echo ($form_html) ?>
173
  <div class="top-settings">
174
  <div class="folder-search-form">
175
  <div class="form-search-input">
179
  </div>
180
  <div class="folder-separator"></div>
181
  <div class="header-posts">
182
+ <a href="javascript:;" class="all-posts <?php echo esc_attr($active_all_class) ?>"><?php echo esc_attr("All ".$title); ?> <span class="total-count"><?php echo esc_attr($ttpsts) ?></span></a>
183
  </div>
184
  <div class="un-categorised-items <?php echo esc_attr($active) ?>">
185
+ <a href="javascript:;" class="un-categorized-posts"><?php echo esc_attr("Unassigned ".$title); ?> <span class="total-count total-empty"><?php echo esc_attr($ttemp) ?></span> </a>
186
  </div>
187
  <div class="folder-separator-2"></div>
188
  <div class="folders-action-menu">
232
  </div>
233
  </div>
234
  <div class="js-tree-data">
235
+ <div id="js-tree-menu" class="<?php echo ($status == 1) ? "active" : "" ?>">
236
  <!--<div class="wcp-parent" id="title0"><i class="fa fa-folder-o"></i> All Folders</div>-->
237
  <ul class='space first-space' id='space_0'>
238
+ <?php echo ($terms_data); ?>
239
  </ul>
240
  </div>
241
  </div>
273
  <?php esc_html_e("Pro tip", "folders") ?>
274
  </span>
275
  <div class="pro-notice">
276
+ <?php printf(esc_html__("%sUpgrade to Pro%s to create subfolders (with 20+ amazing features) & premium support 🎉", "folders"), '<a class="inline-button" target="_blank" href="'.esc_url($this->getFoldersUpgradeURL()).'">', "</a>"); ?>
277
  </div>
278
  </div>
279
  <div class="folder-form-buttons">
348
  </div>
349
  <div class="folder-form-buttons">
350
  <a href="javascript:;" class="form-cancel-btn"><?php esc_html_e("Cancel", "folders") ?></a>
351
+ <a href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" target="_blank" class="form-submit-btn"><?php esc_html_e("Upgrade to Pro", "folders") ?></a>
352
  </div>
353
  </div>
354
  </div>
397
  <a class="" href="javascript:;"><span></span></a>
398
  </div>
399
  <div class="add-update-folder-title">
400
+ <?php esc_html_e("Sub-folders is a pro feature", "folders") ?>
401
  </div>
402
  <div class="folder-form-message" style="padding: 25px 0 15px;" >
403
+ <?php esc_html_e("Hey, it looks like you want to create sub-folders on Folders. Sub-folders is a premium feature. Upgrade to Pro to create, access and organize your files with sub-folders.", "folders") ?>
404
  </div>
405
  <div class="folder-form-message" style="padding: 0 10px 25px;" >
406
+ <?php esc_html_e("You can still create unlimited folders in the free version.", "folders") ?>
407
  </div>
408
  <div class="checkbox-content">
409
  <?php $check_status = get_option("premio_hide_child_popup"); ?>
424
  <a class="" href="javascript:;"><span></span></a>
425
  </div>
426
  <div class="add-update-folder-title">
427
+ <?php esc_html_e("Confirm your change", "folders") ?>
428
  </div>
429
  <div class="folder-form-message" style="padding: 25px 10px;" >
430
  Hey, it looks like you want to move the file to "Unassigned Files." Do you want to move the file from the current folder only or from all the folders where the file exists?
459
  <?php esc_html_e("Pro tip", "folders") ?>
460
  </span>
461
  <div class="pro-notice">
462
+ <?php printf(esc_html__("%sUpgrade to Pro%s to create subfolders (with 20+ amazing features) & premium support 🎉", "folders"), '<a class="inline-button" target="_blank" href="'.esc_url($this->getFoldersUpgradeURL()).'">', "</a>"); ?>
463
  </div>
464
  </div>
465
  </div>
templates/admin/folder-deactivate-form.php CHANGED
@@ -1,5 +1,15 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
 
 
 
 
 
 
 
 
3
  ?>
4
  <style>
5
  .folder-hidden{overflow:hidden}.folder-popup-overlay .folder-internal-message{margin:3px 0 3px 22px;display:none}.folder-reason-input{margin:3px 0 3px 22px;display:none}.folder-reason-input input[type=text]{width:100%;display:block}.folder-popup-overlay{background:rgba(0,0,0,.8);position:fixed;top:0;left:0;height:100%;width:100%;z-index:1000;overflow:auto;visibility:hidden;opacity:0;transition:opacity .3s ease-in-out :}.folder-popup-overlay.folder-active{opacity:1;visibility:visible}.folder-serveypanel{width:600px;background:#fff;margin:65px auto 0}.folder-popup-header{background:#f1f1f1;padding:20px;border-bottom:1px solid #ccc}.folder-popup-header h2{margin:0}.folder-popup-body{padding:10px 20px}.folder-popup-footer{background:#f9f3f3;padding:10px 20px;border-top:1px solid #ccc}.folder-popup-footer:after{content:"";display:table;clear:both}.action-btns{float:right}.folder-anonymous{display:none}.attention,.error-message{color:red;font-weight:600;display:none}.folder-spinner{display:none}.folder-spinner img{margin-top:3px}.folder-hidden-input{padding:10px 0 0;display:none}.folder-hidden-input input[type=text]{padding:0 10px;width:100%;height:26px;line-height:26px}.folder-hidden-input textarea{padding:10px;width:100%;height:100px;margin:0 0 10px 0}span.folder-error-message{color:#d00;font-weight:600}.form-control textarea{width:100%;height:100px;margin-bottom:10px}td.plugin-title {display: table-cell;}
@@ -14,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
14
  <div class="folder-popup-body">
15
  <h3><?php esc_html_e('Your feedback will help us improve the product, please tell us why did you decide to deactivate Folders :)', 'folders'); ?></h3>
16
  <div class="form-control">
17
- <input type="email" value="<?php echo get_option( 'admin_email' ) ?>" placeholder="<?php echo _e("Email address", 'folders'); ?>" id="folder-deactivate-email_id">
18
  </div>
19
  <div class="form-control">
20
  <label></label>
@@ -122,4 +132,4 @@ if ( ! defined( 'ABSPATH' ) ) exit;
122
 
123
  })(jQuery); // This invokes the function above and allows us to use '$' in place of 'jQuery' in our code.
124
  </script>
125
- <?php include_once dirname(__FILE__)."/help.php" ?>
1
  <?php
2
+ /**
3
+ * Admin folders deactiavte form
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
  ?>
14
  <style>
15
  .folder-hidden{overflow:hidden}.folder-popup-overlay .folder-internal-message{margin:3px 0 3px 22px;display:none}.folder-reason-input{margin:3px 0 3px 22px;display:none}.folder-reason-input input[type=text]{width:100%;display:block}.folder-popup-overlay{background:rgba(0,0,0,.8);position:fixed;top:0;left:0;height:100%;width:100%;z-index:1000;overflow:auto;visibility:hidden;opacity:0;transition:opacity .3s ease-in-out :}.folder-popup-overlay.folder-active{opacity:1;visibility:visible}.folder-serveypanel{width:600px;background:#fff;margin:65px auto 0}.folder-popup-header{background:#f1f1f1;padding:20px;border-bottom:1px solid #ccc}.folder-popup-header h2{margin:0}.folder-popup-body{padding:10px 20px}.folder-popup-footer{background:#f9f3f3;padding:10px 20px;border-top:1px solid #ccc}.folder-popup-footer:after{content:"";display:table;clear:both}.action-btns{float:right}.folder-anonymous{display:none}.attention,.error-message{color:red;font-weight:600;display:none}.folder-spinner{display:none}.folder-spinner img{margin-top:3px}.folder-hidden-input{padding:10px 0 0;display:none}.folder-hidden-input input[type=text]{padding:0 10px;width:100%;height:26px;line-height:26px}.folder-hidden-input textarea{padding:10px;width:100%;height:100px;margin:0 0 10px 0}span.folder-error-message{color:#d00;font-weight:600}.form-control textarea{width:100%;height:100px;margin-bottom:10px}td.plugin-title {display: table-cell;}
24
  <div class="folder-popup-body">
25
  <h3><?php esc_html_e('Your feedback will help us improve the product, please tell us why did you decide to deactivate Folders :)', 'folders'); ?></h3>
26
  <div class="form-control">
27
+ <input type="email" value="<?php echo get_option('admin_email') ?>" placeholder="<?php echo _e("Email address", 'folders'); ?>" id="folder-deactivate-email_id">
28
  </div>
29
  <div class="form-control">
30
  <label></label>
132
 
133
  })(jQuery); // This invokes the function above and allows us to use '$' in place of 'jQuery' in our code.
134
  </script>
135
+ <?php require_once dirname(__FILE__)."/help.php";
templates/admin/folder-popup.php CHANGED
@@ -1,4 +1,15 @@
1
- <?php if(!defined('ABSPATH')) exit; ?>
 
 
 
 
 
 
 
 
 
 
 
2
  <div class="folder-popup" id="folder-intro-popup">
3
  <div class="folder-popup-box">
4
  <div class="folder-popup-header">
@@ -74,4 +85,4 @@
74
  e.stopPropagation();
75
  });
76
  });
77
- </script>
1
+ <?php
2
+ /**
3
+ * Admin folders popup data
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (!defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+ ?>
13
  <div class="folder-popup" id="folder-intro-popup">
14
  <div class="folder-popup-box">
15
  <div class="folder-popup-header">
85
  e.stopPropagation();
86
  });
87
  });
88
+ </script>
templates/admin/general-settings.php CHANGED
@@ -1,17 +1,18 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
 
 
 
 
 
 
 
3
  ?>
4
  <!-- do not change here, Free/Pro URL Change -->
5
- <link rel='stylesheet' href='<?php echo WCP_FOLDER_URL ?>assets/css/settings.css?ver=<?php echo WCP_FOLDER_VERSION ?>' type='text/css' media='all' />
6
- <link rel='stylesheet' href='<?php echo WCP_FOLDER_URL ?>assets/css/folder-icon.css?ver=<?php echo WCP_FOLDER_VERSION ?>' type='text/css' media='all' />
7
- <link rel='stylesheet' href='<?php echo WCP_FOLDER_URL ?>assets/css/spectrum.min.css?ver=<?php echo WCP_FOLDER_VERSION ?>' type='text/css' media='all' />
8
- <?php if($setting_page == "folder-settings") { ?>
9
- <link rel='stylesheet' href='<?php echo WCP_FOLDER_URL ?>assets/css/select2.min.css?ver=<?php echo WCP_FOLDER_VERSION ?>' type='text/css' media='all' />
10
- <script type="text/javascript" src='<?php echo WCP_FOLDER_URL ?>assets/js/select2.min.js?ver=<?php echo WCP_FOLDER_VERSION ?>' ></script>
11
- <?php } ?>
12
- <script src="<?php echo WCP_FOLDER_URL ?>assets/js/spectrum.min.js"></script>
13
  <style>
14
- <?php if ( function_exists( 'is_rtl' ) && is_rtl() ) { ?>
15
  #setting-form {
16
  float: right;
17
  }
@@ -36,7 +37,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
36
  var removeTitle = "<?php esc_html_e("Are you sure?", "folders"); ?>";
37
  var removeDesc = "<?php esc_html_e("You're about to delete %plugin%'s folders. Are you sure you'd like to proceed?", "folders"); ?>";
38
  $(document).ready(function(){
39
- <?php if($setting_page == "folder-settings") { ?>
40
  $(".select2-box").select2();
41
  <?php } ?>
42
  $(document).on("click",".form-cancel-btn, .close-popup-button, .folder-popup-form",function(){
@@ -191,15 +192,16 @@ if ( ! defined( 'ABSPATH' ) ) exit;
191
  success: function(res) {
192
  <?php
193
  $redirectURL = $this->getFolderSettingsURL();
194
- if(!empty($redirectURL)) {
195
- $page = isset($_POST['tab_page'])?$_POST['tab_page']:"";
196
- $type = filter_input(INPUT_GET, 'setting_page', FILTER_SANITIZE_STRING);
197
- $type = empty($type)?"":"&setting_page=".$type;
198
  $redirectURL = $redirectURL.$type;
199
- if(!empty($page)) {
200
- $redirectURL .= "&setting_page=".$page;
201
  }
202
  }
 
203
  $redirectURL = $redirectURL."&note=2";
204
  ?>
205
  window.location = "<?php echo esc_url($redirectURL) ?>";
@@ -215,11 +217,6 @@ if ( ! defined( 'ABSPATH' ) ) exit;
215
  $("#remove-folders-data-button").prop("disabled", true);
216
  }
217
  });
218
- /*$(document).on("click", "#remove-folders-data-button", function(e){
219
- e.preventDefault();
220
- $(".folder-popup-form").hide();
221
- $("#remove-confirmation-box").show();
222
- });*/
223
  $(document).on("click", "#import-folder-button", function(e){
224
  importPluginData();
225
  });
@@ -450,108 +447,110 @@ if ( ! defined( 'ABSPATH' ) ) exit;
450
 
451
  </div>
452
  <?php
453
- /* Check website is hosted on wp.org or not */
454
- delete_option("is_web_hosted_on_wp");
455
  $wp_status = get_option("is_web_hosted_on_wp");
456
- if($wp_status === false) {
457
  $site_url = site_url("/");
458
- $domain = parse_url($site_url);
459
 
460
- $options = array (
461
- 'http' =>
462
- array (
463
- 'ignore_errors' => true,
464
- ),
465
- );
466
 
467
  $webLink = $domain['host'];
468
 
469
- $context = stream_context_create( $options );
470
- $response = file_get_contents(
471
  'https://public-api.wordpress.com/rest/v1/sites/'.$webLink,
472
  false,
473
  $context
474
  );
475
- $response = json_decode( $response, true );
476
 
477
- if(!empty($response) && is_array($response)) {
478
- if(isset($response['ID']) && !empty($response['ID'])) {
479
  add_option("is_web_hosted_on_wp", "yes");
480
  $wp_status = "yes";
481
  }
482
  }
483
- }
484
- if($wp_status === false) {
485
- if(!function_exists("get_current_user_id")) {
 
486
  add_option("is_web_hosted_on_wp", "yes");
487
  $wp_status = "yes";
488
  }
489
  }
490
- if($wp_status === false) {
 
491
  add_option("is_web_hosted_on_wp", "no");
492
  }
 
493
  $show_media_popup = false;
494
- if($wp_status == "yes") {
495
- delete_option("is_wp_media_popup_shown");
496
  $popup_shown = get_option("is_wp_media_popup_shown");
497
- if($popup_shown === false) {
498
  $show_media_popup = true;
499
  add_option("is_wp_media_popup_shown", 1);
500
  } else {
501
- if(!is_numeric($popup_shown)) {
502
  $popup_shown = 1;
503
  }
 
504
  $popup_shown++;
505
- if($popup_shown < 4) {
506
  $show_media_popup = true;
507
  }
 
508
  update_option("is_wp_media_popup_shown", $popup_shown);
509
  }
510
  }
511
- //var_dump($show_media_popup); die;
512
  ?>
513
  <div class="wrap">
514
- <h1><?php esc_html_e( 'Folders Settings', 'folders'); ?></h1>
515
  <?php
516
  settings_fields('folders_settings');
517
  settings_fields('default_folders');
518
  settings_fields('customize_folders');
519
- $options = get_option('folders_settings');
520
- $default_folders = get_option('default_folders');
521
  $customize_folders = get_option('customize_folders');
522
- $default_folders = (empty($default_folders) || !is_array($default_folders))?array():$default_folders;
523
- do_settings_sections( __FILE__ );
524
  delete_transient("premio_folders_without_trash");
 
525
  ?>
526
- <?php if(isset($_GET['note']) && $_GET['note'] == 1) { ?>
527
  <div class="folder-notification notice notice-success is-dismissible">
528
  <div class="folder-notification-title"><?php esc_html_e("Changes Saved", "folders") ?></div>
529
  <div class="folder-notification-note"><?php esc_html_e("Your changes have been saved.", "folders") ?></div>
530
  </div>
531
- <?php } if(isset($_GET['note']) && $_GET['note'] == 2) {?>
532
  <div class="folder-notification notice notice-error is-dismissible">
533
  <div class="folder-notification-title"><?php esc_html_e("Folders Deleted", "folders") ?></div>
534
  <div class="folder-notification-note"><?php esc_html_e("All folders has been successfully deleted.", "folders") ?></div>
535
  </div>
536
  <?php } ?>
537
- <?php if($setting_page!="license-key") { ?>
538
  <form action="options.php" method="post" id="setting-form">
539
  <input type="hidden" name="tab_page" value="<?php echo esc_attr($setting_page) ?>">
540
  <?php } ?>
541
  <div class="folders-tabs">
542
  <div class="folder-tab-menu">
543
  <ul>
544
- <li><a class="<?php echo esc_attr(($setting_page=="folder-settings")?"active":"") ?>" href="<?php echo esc_url($settingURL."&setting_page=folder-settings") ?>"><?php esc_html_e( 'Folders Settings', 'folders'); ?></a></li>
545
- <li><a class="<?php echo esc_attr(($setting_page=="folders-by-user")?"active":"") ?>" href="<?php echo esc_url($settingURL."&setting_page=folders-by-user") ?>"><?php esc_html_e( 'User Restrictions', 'folders'); ?></a></li>
546
- <li><a class="<?php echo esc_attr(($setting_page=="customize-folders")?"active":"") ?>" href="<?php echo esc_url($settingURL."&setting_page=customize-folders") ?>"><?php esc_html_e( 'Customize Folders', 'folders'); ?></a></li>
547
- <li><a class="<?php echo esc_attr(($setting_page=="folders-import")?"active":"") ?>" href="<?php echo esc_url($settingURL."&setting_page=folders-import") ?>"><?php esc_html_e( 'Tools', 'folders'); ?></a></li>
548
- <?php if($isInSettings) { ?>
549
- <li><a class="<?php echo esc_attr(($setting_page=="upgrade-to-pro")?"active":"") ?>" href="<?php echo esc_url($settingURL."&setting_page=upgrade-to-pro") ?>"><?php esc_html_e( 'Upgrade to Pro', 'folders'); ?></a></li>
550
  <?php } ?>
551
  </ul>
552
  </div>
553
  <div class="folder-tab-content">
554
- <div class="tab-content <?php echo esc_attr(($setting_page=="folder-settings")?"active":"") ?>" id="folder-settings">
 
555
  <div class="accordion-content no-bp">
556
  <div class="accordion-left">
557
  <table class="form-table">
@@ -559,13 +558,12 @@ if($wp_status == "yes") {
559
  <?php
560
  $post_types = get_post_types( array( ), 'objects' );
561
  $post_array = array("page", "post", "attachment");
562
- foreach ( $post_types as $post_type ) : ?>
563
- <?php
564
  if ( ! $post_type->show_ui) continue;
565
  $is_checked = !in_array( $post_type->name, $options )?"hide-option":"";
566
  $selected_id = (isset($default_folders[$post_type->name]))?$default_folders[$post_type->name]:"all";
567
- $is_exists = WCP_Folders::check_for_setting($post_type->name, "default_folders");
568
- $is_customized = WCP_Folders::check_for_setting($post_type->name, "folders_settings");
569
  if(in_array($post_type->name, $post_array) || $is_customized === true){
570
  ?>
571
  <tr>
@@ -589,10 +587,10 @@ if($wp_status == "yes") {
589
  if(isset($terms_data[$post_type->name]) && !empty($terms_data[$post_type->name])) {
590
  foreach ($terms_data[$post_type->name] as $term) {
591
  if(empty($is_exists) || $is_exists === false) {
592
- echo "<option class='pro-select-item' value='folders-pro'>" . esc_attr( $term->name ). " (Pro) 🔑</option>";
593
  } else {
594
- $selected = ( $selected_id == $term->slug ) ? "selected" : "";
595
- echo "<option " . esc_attr( $selected ) . " value='" . esc_attr( $term->slug ) . "'>" . esc_attr( $term->name ) . "</option>";
596
  }
597
  }
598
  } ?>
@@ -601,7 +599,7 @@ if($wp_status == "yes") {
601
  </tr>
602
  <?php
603
  } else {
604
- $show_media_details = "off";
605
  ?>
606
  <tr>
607
  <td style="padding: 15px 10px 15px 0px" colspan="4">
@@ -618,9 +616,9 @@ if($wp_status == "yes") {
618
  </td>
619
  </tr>
620
  <?php }
621
- endforeach; ?>
622
  <?php
623
- $show_in_page = !isset($customize_folders['use_shortcuts'])?"yes":$customize_folders['use_shortcuts'];
624
  ?>
625
  <tr>
626
  <td class="no-padding">
@@ -631,7 +629,7 @@ if($wp_status == "yes") {
631
  </label>
632
  </td>
633
  <td colspan="3">
634
- <label for="use_shortcuts" ><?php esc_html_e( 'Use keyboard shortcuts to navigate faster', 'folders'); ?> <a href="#" class="view-shortcodes">(<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" /></svg> <?php esc_html_e( 'View shortcuts', 'folders'); ?>)</a>
635
  </td>
636
  </tr>
637
  <tr>
@@ -657,9 +655,9 @@ if($wp_status == "yes") {
657
  </a>
658
  </td>
659
  </tr>
660
- <?php
661
- $show_in_page = !isset($customize_folders['use_folder_undo'])?"yes":$customize_folders['use_folder_undo'];
662
- ?>
663
  <tr>
664
  <td class="no-padding">
665
  <input type="hidden" name="customize_folders[use_folder_undo]" value="no">
@@ -669,15 +667,15 @@ if($wp_status == "yes") {
669
  </label>
670
  </td>
671
  <td colspan="3">
672
- <label for="use_folder_undo" ><?php esc_html_e( 'Use folders with Undo action after performing tasks', 'folders'); ?> <span class="recommanded">Recommended</span></label>
673
  </td>
674
  </tr>
675
- <?php
676
- $default_timeout = !isset($customize_folders['default_timeout'])?"5":$customize_folders['default_timeout'];
677
- ?>
678
- <tr class="timeout-settings <?php echo ($show_in_page == "yes")?"active":"" ?>">
679
  <td style="padding: 10px 0;" colspan="4">
680
- <label for="default_timeout" ><?php esc_html_e( 'Default timeout', 'folders'); ?></label>
681
  <div class="seconds-box">
682
  <input type="number" class="seconds-input" name="customize_folders[default_timeout]" value="<?php echo esc_attr($default_timeout) ?>" />
683
  </div>
@@ -686,22 +684,22 @@ if($wp_status == "yes") {
686
 
687
  <tr>
688
  <td style="padding: 15px 10px 15px 0px" colspan="4">
689
- <?php $replace_media_title = "off"; ?>
690
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
691
  <label for="" class="custom-checkbox send-user-to-pro">
692
  <input disabled type="checkbox" class="sr-only" id="enable_media_trash" value="off">
693
  <span></span>
694
  </label>
695
  <label for="" class="send-user-to-pro">
696
- <?php esc_html_e("Move files to trash by default before deleting", "folders"); ?>
697
  <span class="folder-tooltip" data-title="<?php esc_html_e("When enabled, files will be moved to trash to prevent mistakes, and then you can delete permanently from the trash", "folders") ?>"><span class="dashicons dashicons-editor-help"></span></span></label>
698
- <button type="button" class="upgrade-link" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>"><?php esc_html_e("Upgrade to Pro", 'folders') ?></button>
699
  </label>
700
  </a>
701
  </td>
702
  </tr>
703
  <?php
704
- $show_in_page = !isset($customize_folders['folders_media_cleaning'])?"yes":$customize_folders['folders_media_cleaning'];
705
  ?>
706
  <tr>
707
  <td style="padding: 15px 10px 15px 0px" colspan="4">
@@ -724,7 +722,7 @@ if($wp_status == "yes") {
724
  <td style="padding: 15px 10px 15px 0px" colspan="4">
725
  <input type="hidden" name="folders_settings1" value="folders">
726
  <?php
727
- $show_media_details = !isset($customize_folders['show_media_details'])?"on":$customize_folders['show_media_details'];
728
  $show_media_details = "off";
729
  ?>
730
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
@@ -752,51 +750,56 @@ if($wp_status == "yes") {
752
  <div class="">
753
  <div class="">
754
  <?php
755
- $media_settings = array(
756
- 'image_title' => array(
757
- "title" => esc_html__("Title", "folders"),
758
  "default" => "on",
759
- ),
760
- 'image_alt_text' => array(
761
- "title" => esc_html__("Alternative Text", "folders"),
762
  "default" => "off",
763
- ),
764
- 'image_file_url' => array(
765
- "title" => esc_html__("File URL", "folders"),
766
  "default" => "off",
767
- ),
768
- 'image_dimensions' => array(
769
- "title" => esc_html__("Dimensions", "folders"),
770
  "default" => "on",
771
- ),
772
- 'image_size' => array(
773
- "title" => esc_html__("Size", "folders"),
774
  "default" => "off",
775
- ),
776
- 'image_file_name' => array(
777
- "title" => esc_html__("Filename", "folders"),
778
  "default" => "off",
779
- ),
780
- 'image_type' => array(
781
- "title" => esc_html__("Type", "folders"),
782
  "default" => "on",
783
- ),
784
- 'image_date' => array(
785
- "title" => esc_html__("Date", "folders"),
786
  "default" => "on",
787
- ),
788
- 'image_uploaded_by' => array(
789
- "title" => esc_html__("Uploaded by", "folders"),
790
  "default" => "off",
791
- )
792
- );
793
- $media_col_settings = isset($customize_folders['media_col_settings']) && is_array($customize_folders['media_col_settings'])?$customize_folders['media_col_settings']:array("image_title","image_dimensions","image_type","image_date");
 
 
 
 
 
794
  ?>
795
  <input type="hidden" name="customize_folders[media_col_settings][]" value="all">
796
  <div class="media-setting-box active send-user-to-pro" >
797
  <div class="normal-box">
798
  <select disabled multiple="multiple" name="customize_folders[media_col_settings][]" class="select2-box">
799
- <?php foreach($media_settings as $key=>$media) {
800
  $selected = $media['default'];
801
  ?>
802
  <option <?php selected($selected, "on") ?> value="<?php echo esc_attr($key) ?>"><?php echo esc_attr($media['title']) ?></option>
@@ -812,7 +815,7 @@ if($wp_status == "yes") {
812
  </td>
813
  </tr>
814
  <?php
815
- $show_in_page = !isset($customize_folders['folders_enable_replace_media'])?"yes":$customize_folders['folders_enable_replace_media'];
816
  ?>
817
  <tr>
818
  <td class="no-padding">
@@ -823,7 +826,7 @@ if($wp_status == "yes") {
823
  </label>
824
  </td>
825
  <td colspan="3" class="enable-replace-media">
826
- <label for="folders_enable_replace_media" ><?php esc_html_e( 'Enable Replace Media', 'folders'); ?>
827
  <span class="html-tooltip no-position top">
828
  <span class="dashicons dashicons-editor-help"></span>
829
  <span class="tooltip-text top" style="">
@@ -836,7 +839,7 @@ if($wp_status == "yes") {
836
  </td>
837
  </tr>
838
  <?php
839
- $show_in_page = !isset($customize_folders['show_folder_in_settings'])?"no":$customize_folders['show_folder_in_settings'];
840
  ?>
841
  <tr>
842
  <td class="no-padding">
@@ -847,10 +850,10 @@ if($wp_status == "yes") {
847
  </label>
848
  </td>
849
  <td colspan="3">
850
- <label for="show_folder_in_settings" ><?php esc_html_e( 'Place the Folders settings page nested under "Settings"', 'folders'); ?></label>
851
  </td>
852
  </tr>
853
- <?php $val = get_option("folders_show_in_menu"); ?>
854
  <input type="hidden" name="folders_show_in_menu" value="off" />
855
  <tr>
856
  <td width="20" class="no-padding">
@@ -860,19 +863,19 @@ if($wp_status == "yes") {
860
  </label>
861
  </td>
862
  <td colspan="3">
863
- <label for="folders_show_in_menu" ><?php esc_html_e( 'Show the folders also in WordPress menu', 'folders'); ?></label>
864
  </td>
865
  </tr>
866
  <tr>
867
  <td style="padding: 15px 10px 15px 0px" colspan="4">
868
- <?php $replace_media_title = "off"; ?>
869
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
870
  <label for="" class="custom-checkbox send-user-to-pro">
871
  <input disabled type="checkbox" class="sr-only" name="customize_folders[replace_media_title]" id="replace_media_title" value="on" <?php checked($replace_media_title, "on") ?>>
872
  <span></span>
873
  </label>
874
  <label for="" class="send-user-to-pro">
875
- <?php esc_html_e("Auto Rename file based on title", "folders"); ?>
876
  <span class="folder-tooltip" data-title="<?php esc_html_e("Replace the actual file name of media files with the title from the WordPress editor.", "folders") ?>"><span class="dashicons dashicons-editor-help"></span></span></label>
877
  <button type="button" class="upgrade-link" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>"><?php esc_html_e("Upgrade to Pro", 'folders') ?></button>
878
  </label>
@@ -883,7 +886,6 @@ if($wp_status == "yes") {
883
  </tboby>
884
  </table>
885
  <input type="hidden" name="customize_folders[show_media_details]" value="off">
886
-
887
  </div>
888
  <div class="accordion-right">
889
  <div class="premio-help">
@@ -896,7 +898,7 @@ if($wp_status == "yes") {
896
  </div>
897
  </a>
898
  </div>
899
- <?php if($wp_status == "yes") { ?>
900
  <div class="premio-help">
901
  <div class="premio-help-btn wp-folder-user">
902
  <div class="folder-help-icon"><span class="dashicons dashicons-wordpress"></span></div>
@@ -912,17 +914,18 @@ if($wp_status == "yes") {
912
  </div>
913
  </div>
914
  </div>
915
- <div class="tab-content <?php echo esc_attr(($setting_page=="customize-folders")?"active":"") ?>" id="customize-folders">
 
916
  <div class="accordion-content">
917
  <div class="accordion-left">
918
  <table class="form-table">
919
  <?php
920
- $colors = array(
921
- "#FA166B",
922
- "#0073AA",
923
- "#484848"
924
- );
925
- $color = !isset($customize_folders['new_folder_color'])||empty($customize_folders['new_folder_color'])?"#FA166B":$customize_folders['new_folder_color'];
926
  $setting_color = WCP_Folders::check_for_setting("new_folder_color", "customize_folders");
927
  ?>
928
  <tr>
@@ -933,18 +936,18 @@ if($wp_status == "yes") {
933
  </td>
934
  <td>
935
  <ul class="color-list">
936
- <?php $field_name = "new_folder_color"; foreach ($colors as $key=>$value) { ?>
937
  <li>
938
- <label class="color-checkbox <?php echo ($color == $value)?"active":"" ?>" for="<?php echo esc_attr($field_name)."-".$key ?>">
939
- <input type="radio" id="<?php echo esc_attr($field_name)."-".$key ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($value) ?>" <?php checked($color, $value) ?> />
940
  <span style="background: <?php echo esc_attr($value) ?>"></span>
941
  </label>
942
  </li>
943
  <?php } $key = 3; ?>
944
- <?php if($setting_color !== false && $setting_color != "#FA166B") { ?>
945
  <li>
946
- <label class="color-checkbox <?php echo ($color == $setting_color)?"active":"" ?>" for="<?php echo esc_attr($field_name)."-".$key ?>">
947
- <input type="radio" id="<?php echo esc_attr($field_name)."-".$key ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($setting_color) ?>" <?php checked($color, $setting_color) ?> />
948
  <span style="background: <?php echo esc_attr($setting_color) ?>"></span>
949
  </label>
950
  </li>
@@ -962,7 +965,7 @@ if($wp_status == "yes") {
962
  </td>
963
  </tr>
964
  <?php
965
- $color = !isset($customize_folders['bulk_organize_button_color'])||empty($customize_folders['bulk_organize_button_color'])?"#FA166B":$customize_folders['bulk_organize_button_color'];
966
  $setting_color = WCP_Folders::check_for_setting("bulk_organize_button_color", "customize_folders");
967
  ?>
968
  <tr>
@@ -973,18 +976,18 @@ if($wp_status == "yes") {
973
  </td>
974
  <td>
975
  <ul class="color-list">
976
- <?php $field_name = "bulk_organize_button_color"; foreach ($colors as $key=>$value) { ?>
977
  <li>
978
- <label class="color-checkbox <?php echo ($color == $value)?"active":"" ?>" for="<?php echo esc_attr($field_name)."-".$key ?>">
979
- <input type="radio" id="<?php echo esc_attr($field_name)."-".$key ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($value) ?>" <?php checked($color, $value) ?> />
980
  <span style="background: <?php echo esc_attr($value) ?>"></span>
981
  </label>
982
  </li>
983
  <?php } $key = 3; ?>
984
- <?php if($setting_color !== false && $setting_color != "#FA166B") { ?>
985
  <li>
986
- <label class="color-checkbox <?php echo ($color == $setting_color)?"active":"" ?>" for="<?php echo esc_attr($field_name)."-".$key ?>">
987
- <input type="radio" id="<?php echo esc_attr($field_name)."-".$key ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($setting_color) ?>" <?php checked($color, $setting_color) ?> />
988
  <span style="background: <?php echo esc_attr($setting_color) ?>"></span>
989
  </label>
990
  </li>
@@ -999,7 +1002,7 @@ if($wp_status == "yes") {
999
  </td>
1000
  </tr>
1001
  <?php
1002
- $color = !isset($customize_folders['media_replace_button'])||empty($customize_folders['media_replace_button'])?"#FA166B":$customize_folders['media_replace_button'];
1003
  $setting_color = WCP_Folders::check_for_setting("media_replace_button", "customize_folders");
1004
  ?>
1005
  <tr>
@@ -1010,18 +1013,18 @@ if($wp_status == "yes") {
1010
  </td>
1011
  <td>
1012
  <ul class="color-list">
1013
- <?php $field_name = "media_replace_button"; foreach ($colors as $key=>$value) { ?>
1014
  <li>
1015
- <label class="color-checkbox <?php echo ($color == $value)?"active":"" ?>" for="<?php echo esc_attr($field_name)."-".$key ?>">
1016
- <input type="radio" id="<?php echo esc_attr($field_name)."-".$key ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($value) ?>" <?php checked($color, $value) ?> />
1017
  <span style="background: <?php echo esc_attr($value) ?>"></span>
1018
  </label>
1019
  </li>
1020
  <?php } $key = 3; ?>
1021
- <?php if($setting_color !== false && $setting_color != "#FA166B") { ?>
1022
  <li>
1023
- <label class="color-checkbox <?php echo ($color == $setting_color)?"active":"" ?>" for="<?php echo esc_attr($field_name)."-".$key ?>">
1024
- <input type="radio" id="<?php echo esc_attr($field_name)."-".$key ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($setting_color) ?>" <?php checked($color, $setting_color) ?> />
1025
  <span style="background: <?php echo esc_attr($setting_color) ?>"></span>
1026
  </label>
1027
  </li>
@@ -1036,7 +1039,7 @@ if($wp_status == "yes") {
1036
  </td>
1037
  </tr>
1038
  <?php
1039
- $color = !isset($customize_folders['dropdown_color'])||empty($customize_folders['dropdown_color'])?"#484848":$customize_folders['dropdown_color'];
1040
  $setting_color = WCP_Folders::check_for_setting("dropdown_color", "customize_folders");
1041
  ?>
1042
  <tr>
@@ -1047,18 +1050,18 @@ if($wp_status == "yes") {
1047
  </td>
1048
  <td>
1049
  <ul class="color-list">
1050
- <?php $field_name = "dropdown_color"; foreach ($colors as $key=>$value) { ?>
1051
  <li>
1052
- <label class="color-checkbox <?php echo ($color == $value)?"active":"" ?>" for="<?php echo esc_attr($field_name)."-".$key ?>">
1053
- <input type="radio" id="<?php echo esc_attr($field_name)."-".$key ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($value) ?>" <?php checked($color, $value) ?> />
1054
  <span style="background: <?php echo esc_attr($value) ?>"></span>
1055
  </label>
1056
  </li>
1057
  <?php } $key = 3; ?>
1058
- <?php if($setting_color !== false && $setting_color != "#484848") { ?>
1059
  <li>
1060
- <label class="color-checkbox <?php echo ($color == $setting_color)?"active":"" ?>" for="<?php echo esc_attr($field_name)."-".$key ?>">
1061
- <input type="radio" id="<?php echo esc_attr($field_name)."-".$key ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($setting_color) ?>" <?php checked($color, $setting_color) ?> />
1062
  <span style="background: <?php echo esc_attr($setting_color) ?>"></span>
1063
  </label>
1064
  </li>
@@ -1073,7 +1076,7 @@ if($wp_status == "yes") {
1073
  </td>
1074
  </tr>
1075
  <?php
1076
- $color = !isset($customize_folders['folder_bg_color'])||empty($customize_folders['folder_bg_color'])?"#FA166B":$customize_folders['folder_bg_color'];
1077
  $setting_color = WCP_Folders::check_for_setting("folder_bg_color", "customize_folders");
1078
  ?>
1079
  <tr>
@@ -1084,18 +1087,18 @@ if($wp_status == "yes") {
1084
  </td>
1085
  <td>
1086
  <ul class="color-list">
1087
- <?php $field_name = "folder_bg_color"; foreach ($colors as $key=>$value) { ?>
1088
  <li>
1089
- <label class="color-checkbox <?php echo ($color == $value)?"active":"" ?>" for="<?php echo esc_attr($field_name)."-".$key ?>">
1090
- <input type="radio" id="<?php echo esc_attr($field_name)."-".$key ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($value) ?>" <?php checked($color, $value) ?> />
1091
  <span style="background: <?php echo esc_attr($value) ?>"></span>
1092
  </label>
1093
  </li>
1094
  <?php } $key = 3; ?>
1095
- <?php if($setting_color !== false && $setting_color != "#FA166B") { ?>
1096
  <li>
1097
- <label class="color-checkbox <?php echo ($color == $setting_color)?"active":"" ?>" for="<?php echo esc_attr($field_name)."-".$key ?>">
1098
- <input type="radio" id="<?php echo esc_attr($field_name)."-".$key ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($setting_color) ?>" <?php checked($color, $setting_color) ?> />
1099
  <span style="background: <?php echo esc_attr($setting_color) ?>"></span>
1100
  </label>
1101
  </li>
@@ -1110,36 +1113,38 @@ if($wp_status == "yes") {
1110
  </td>
1111
  </tr>
1112
  <?php
1113
- $font = !isset($customize_folders['folder_font'])||empty($customize_folders['folder_font'])?"":$customize_folders['folder_font'];
1114
  $setting_font = WCP_Folders::check_for_setting("folder_font", "customize_folders");
1115
- $index = 0;
1116
  ?>
1117
  <tr>
1118
  <td class="no-padding">
1119
  <label for="folder_font" >
1120
- <?php if($setting_font !== false && $setting_font != "" && !in_array($setting_font, array("Arial","Tahoma","Verdana","Helvetica","Times New Roman","Trebuchet MS","Georgia", "System Stack"))) {
1121
- esc_html_e("Folders font", 'folders');
1122
- } else { ?>
1123
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
1124
- <?php esc_html_e( 'Folders font', 'folders'); ?> <button type="button" class="upgrade-link" ><?php esc_html_e("Upgrade to Pro", 'folders'); ?></button>
1125
  </a>
1126
- <?php } ?>
1127
  </label>
1128
  </td>
1129
  <td colspan="2">
1130
  <select name="customize_folders[folder_font]" id="folder_font" >
1131
  <?php $group = '';
1132
- foreach ($fonts as $key => $value):
1133
  $title = $key;
1134
- if($index == 0) {
1135
  $key = "";
1136
  }
 
1137
  $index++;
1138
  if ($value != $group) {
1139
- echo '<optgroup label="' . $value . '">';
1140
  $group = $value;
1141
  }
1142
- if(($setting_font !== false && $setting_font != "" && !in_array($setting_font, array("Arial","Tahoma","Verdana","Helvetica","Times New Roman","Trebuchet MS","Georgia"))) || $value != "Google Fonts" ) { ?>
 
1143
  <option value="<?php echo esc_attr($key); ?>" <?php selected($font, $key); ?>><?php echo esc_attr($title); ?></option>
1144
  <?php } else { ?>
1145
  <option class="pro-select-item" value="folders-pro"><?php echo esc_attr($title); ?> (Pro) 🔑</option>
@@ -1149,15 +1154,15 @@ if($wp_status == "yes") {
1149
  </td>
1150
  </tr>
1151
  <?php
1152
- $size = ! isset( $customize_folders['folder_size'] ) || empty( $customize_folders['folder_size'] ) ? "16" : $customize_folders['folder_size'];
1153
  $folder_size = WCP_Folders::check_for_setting("folder_size", "customize_folders");
1154
  ?>
1155
  <tr>
1156
  <td class="no-padding">
1157
  <label for="folder_size" >
1158
- <?php if($folder_size === false || intval($folder_size) === 16) { ?>
1159
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
1160
- <?php esc_html_e( 'Folders size', 'folders'); ?> <button type="button" class="upgrade-link" ><?php esc_html_e("Upgrade to Pro", 'folders'); ?></button>
1161
  </a>
1162
  <?php } else { ?>
1163
  <?php esc_html_e("Folders size", 'folders'); ?>
@@ -1166,50 +1171,50 @@ if($wp_status == "yes") {
1166
  </td>
1167
  <td colspan="2">
1168
  <?php
1169
- if($folder_size === false || intval($folder_size) == 16) {
1170
- $sizes = array(
1171
- "folders-pro" => "Small (Pro) 🔑",
1172
- "16" => "Medium",
1173
- "folders-pro-item" => "Large (Pro) 🔑",
1174
- "folders-item-pro" => "Custom (Pro) 🔑"
1175
- );
1176
- $size = 16;
1177
  } else {
1178
- $sizes = array(
1179
- "12" => "Small",
1180
- "16" => "Medium",
1181
- "20" => "Large"
1182
- );
1183
  }
1184
  ?>
1185
  <select name="customize_folders[folder_size]" id="folder_size" >
1186
  <?php
1187
- foreach ($sizes as $key=>$value) {
1188
- $selected = ($key == $size)?"selected":"";
1189
- echo "<option ".$selected." value='".$key."'>".$value."</option>";
1190
  }
1191
  ?>
1192
  </select>
1193
  </td>
1194
  </tr>
1195
  <?php
1196
- $show_in_page = isset($customize_folders['show_in_page'])?$customize_folders['show_in_page']:"hide";
1197
- $show_folder = WCP_Folders::check_for_setting("show_in_page", "customize_folders");
1198
- if(empty($show_in_page)) {
1199
  $show_in_page = "hide";
1200
  }
1201
  ?>
1202
  <tr>
1203
  <td colspan="3" style="padding: 15px 20px 15px 0">
1204
  <input type="hidden" name="customize_folders[show_in_page]" value="hide">
1205
- <?php if($show_folder === false || $show_folder === "hide") { ?>
1206
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
1207
  <label for="" class="custom-checkbox send-user-to-pro">
1208
  <input disabled type="checkbox" class="sr-only" name="customize_folders[show_in_page]" id="show_in_page" value="on" <?php checked($show_in_page, "show") ?>>
1209
  <span></span>
1210
  </label>
1211
  <label for="" class="send-user-to-pro">
1212
- <?php esc_html_e("Show Folders in upper position", "folders"); ?>
1213
  <button type="button" class="upgrade-link" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>"><?php esc_html_e("Upgrade to Pro", 'folders'); ?></button>
1214
  </label>
1215
  </a>
@@ -1233,7 +1238,7 @@ if($wp_status == "yes") {
1233
  <div class="preview-box">
1234
  <div class="wcp-custom-form">
1235
  <div class="form-title">
1236
- <?php esc_html_e("Folders", 'folders'); ?>
1237
  <a href="javascript:;" class="add-new-folder" id="add-new-folder">
1238
  <span class="create_new_folder"><i class="pfolder-add-folder"></i></span>
1239
  <span><?php esc_html_e("New Folder", 'folders'); ?></span>
@@ -1295,25 +1300,26 @@ if($wp_status == "yes") {
1295
  <?php submit_button(); ?>
1296
  </div>
1297
  </div>
1298
- <div class="tab-content <?php echo esc_attr(($setting_page=="folders-import")?"active":"") ?>" id="folder-import">
 
1299
  <?php
1300
- $remove_folders_when_removed = !isset($customize_folders['remove_folders_when_removed'])?"off":$customize_folders['remove_folders_when_removed'];
1301
  ?>
1302
  <input type="hidden" name="customize_folders[remove_folders_when_removed]" value="off" />
1303
  <div class="folder-danger-zone">
1304
  <table class="import-export-table">
1305
- <?php if($is_plugin_exists) { ?>
1306
- <tr class="has-other-plugins">
1307
- <td>
1308
- <span class="folder-info"><span class="dashicons dashicons-admin-generic"></span> <?php esc_html_e("Export/Import", "folders"); ?></span>
1309
- <span class="folder-text"><span><?php esc_html_e("External folders found.", "folders"); ?></span> <?php esc_html_e("Click import to start importing external folders.", "folders"); ?></span>
1310
- </td>
1311
- <td class="last-td">
1312
- <a href="#" class="import-folders-button"><?php esc_html_e("Import", "folders"); ?></a>
1313
- </td>
1314
- </tr>
1315
  <?php } ?>
1316
- <tr class="no-more-plugins <?php echo (!$is_plugin_exists)?"active":"" ?>">
1317
  <td>
1318
  <span class="folder-info"><span class="dashicons dashicons-admin-generic"></span> <?php esc_html_e("Export/Import", "folders"); ?></span>
1319
  <span class="folder-text"><?php esc_html_e("Couldn't detect any external folders that can be imported. Please contact us if you have external folders that were not detected", "folders"); ?></span>
@@ -1351,18 +1357,19 @@ if($wp_status == "yes") {
1351
  </table>
1352
  </div>
1353
  </div>
1354
- <div class="tab-content <?php echo esc_attr(($setting_page=="upgrade-to-pro")?"active":"") ?>">
1355
- <?php if($setting_page=="upgrade-to-pro") { ?>
1356
- <style>#wpwrap { background: #f0f0f1 !important; }</style>
1357
  <?php include_once "upgrade-table.php"; ?>
1358
  <?php } ?>
1359
  </div>
1360
- <div class="tab-content <?php echo esc_attr(($setting_page=="folders-by-user")?"active":"") ?>" id="folders-by-user">
1361
- <?php
1362
- $folders_by_users = !isset($customize_folders['folders_by_users'])?"off":$customize_folders['folders_by_users'];
1363
- $dynamic_folders_for_admin_only = !isset($customize_folders['dynamic_folders_for_admin_only'])?"off":$customize_folders['dynamic_folders_for_admin_only'];
1364
- ?>
1365
- <?php if($setting_page=="folders-by-user") { ?>
 
1366
  <div class="folders-by-user">
1367
  <div class="send-user-to-pro">
1368
  <div class="normal-box">
@@ -1418,17 +1425,19 @@ if($wp_status == "yes") {
1418
  </a>
1419
  </div>
1420
  </div>
1421
- <?php } ?>
 
1422
  </div>
 
1423
  </div>
1424
  </div>
1425
  <?php
1426
  ?>
1427
  <input type="hidden" name="folder_nonce" value="<?php echo wp_create_nonce("folder_settings") ?>">
1428
- <input type="hidden" name="folder_page" value="<?php echo $_SERVER['REQUEST_URI'] ?>">
1429
- <?php if($setting_page!="upgrade-to-pro") { ?>
1430
  </form>
1431
- <?php } ?>
1432
  </div>
1433
 
1434
  <div class="folder-popup-form" id="import-plugin-data">
@@ -1447,7 +1456,8 @@ if($wp_status == "yes") {
1447
  </div>
1448
  </div>
1449
 
1450
- <?php //if($plugin['is_exists']) { ?>
 
1451
  <div class="folder-popup-form" id="import-folders-popup">
1452
  <div class="popup-form-content">
1453
  <div class="popup-content">
@@ -1459,18 +1469,18 @@ if($wp_status == "yes") {
1459
  <div class="import-folder-table">
1460
  <table>
1461
  <tbody>
1462
- <?php foreach ($plugin_info as $slug=>$plugin) { ?>
1463
- <?php if($plugin['is_exists']) { ?>
1464
  <tr class="other-plugins-<?php echo esc_attr__($slug) ?>" data-plugin="<?php echo esc_attr__($slug) ?>" data-nonce="<?php echo wp_create_nonce("import_data_from_".$slug) ?>" data-folders="<?php echo esc_attr($plugin['total_folders']) ?>" data-attachments="<?php echo esc_attr($plugin['total_attachments']) ?>">
1465
  <th class="plugin-name"><?php echo esc_attr__($plugin['name']) ?></th>
1466
  <td>
1467
- <span class="import-message"><?php printf(esc_html__("%s folder%s and %s attachment%s", "folders"), "<b>".$plugin['total_folders']."</b>", ($plugin['total_folders']>1)?esc_html__("s"):"" ,"<b>".$plugin['total_attachments']."</b>", ($plugin['total_attachments']>1)?esc_html__("s"):"") ?></span>
1468
  <button type="button" class="button button-primary import-folder-data in-popup"><?php esc_html_e("Import", "folders"); ?> <span class="spinner"></span></button>
1469
  <button type="button" class="button button-secondary remove-folder-data in-popup"><?php esc_html_e("Delete plugin data", "folders"); ?> <span class="spinner"></span></button>
1470
  </td>
1471
  </tr>
1472
- <?php } ?>
1473
- <?php } ?>
1474
  </tbody>
1475
  </table>
1476
  </div>
@@ -1482,7 +1492,8 @@ if($wp_status == "yes") {
1482
  </div>
1483
  </div>
1484
  </div>
1485
- <?php //} ?>
 
1486
 
1487
  <div class="folder-popup-form" id="remove-plugin-data">
1488
  <div class="popup-form-content">
@@ -1543,7 +1554,7 @@ if($wp_status == "yes") {
1543
  </div>
1544
 
1545
  <?php
1546
- if($wp_status == "yes" && $show_media_popup) {
1547
  add_option("is_wp_media_popup_shown", "yes");
1548
  ?>
1549
  <div class="folder-popup-form" id="wordpress-popup">
@@ -1566,11 +1577,12 @@ if($wp_status == "yes" && $show_media_popup) {
1566
  </div>
1567
  </div>
1568
  </div>
1569
- <?php } ?>
 
1570
 
1571
  <?php
1572
  $option = get_option("folder_intro_box");
1573
- if(($option == "show" || get_option("folder_redirect_status") == 2) && $is_plugin_exists) { ?>
1574
  <div class="folder-popup-form" id="import-third-party-plugin-data" style="display: block" ?>
1575
  <div class="popup-form-content">
1576
  <div class="popup-content">
@@ -1583,13 +1595,13 @@ if(($option == "show" || get_option("folder_redirect_status") == 2) && $is_plugi
1583
  <div class="import-folder-table">
1584
  <table>
1585
  <tbody>
1586
- <?php foreach ($plugin_info as $slug=>$plugin) {
1587
- if($plugin['is_exists']) { ?>
1588
  <tr class="other-plugins-<?php echo esc_attr__($slug) ?>" data-plugin="<?php echo esc_attr__($slug) ?>" data-nonce="<?php echo wp_create_nonce("import_data_from_".$slug) ?>" data-folders="<?php echo esc_attr($plugin['total_folders']) ?>" data-attachments="<?php echo esc_attr($plugin['total_attachments']) ?>">
1589
  <th class="plugin-name"><?php echo esc_attr__($plugin['name']) ?></th>
1590
  <td>
1591
  <button type="button" class="button button-primary import-folder-data in-popup"><?php esc_html_e("Import", "folders"); ?> <span class="spinner"></span></button>
1592
- <span class="import-message"><?php printf(esc_html__("%s folder%s and %s attachment%s", "folders"), "<b>".$plugin['total_folders']."</b>", ($plugin['total_folders']>1)?esc_html__("s"):"" ,"<b>".$plugin['total_attachments']."</b>", ($plugin['total_attachments']>1)?esc_html__("s"):"") ?></span>
1593
  </td>
1594
  </tr>
1595
  <?php }
@@ -1606,10 +1618,12 @@ if(($option == "show" || get_option("folder_redirect_status") == 2) && $is_plugi
1606
  </div>
1607
  </div>
1608
  <?php
1609
- if($option != "show") {
1610
  update_option("folder_redirect_status", 3);
1611
  }
1612
- } ?>
 
 
1613
  <div class="folder-popup-form" id="no-more-folder-credit">
1614
  <div class="popup-form-content">
1615
  <div class="popup-content">
@@ -1617,10 +1631,10 @@ if(($option == "show" || get_option("folder_redirect_status") == 2) && $is_plugi
1617
  <a class="" href="javascript:;"><span></span></a>
1618
  </div>
1619
  <div class="add-update-folder-title" id="folder-limitation-message">
1620
- <?php esc_html_e("You've reached the 10 folder limitation!", 'folders'); ?>
1621
  </div>
1622
  <div class="folder-form-message">
1623
- <?php esc_html_e("Unlock unlimited amount of folders by upgrading to one of our pro plans.", 'folders'); ?>
1624
  </div>
1625
  <div class="folder-form-buttons">
1626
  <a href="javascript:;" class="form-cancel-btn"><?php esc_html_e("Cancel", 'folders'); ?></a>
@@ -1629,9 +1643,7 @@ if(($option == "show" || get_option("folder_redirect_status") == 2) && $is_plugi
1629
  </div>
1630
  </div>
1631
  </div>
1632
- <?php include_once "help.php" ?>
1633
-
1634
-
1635
 
1636
  <div class="folder-popup-form" id="keyboard-shortcut">
1637
  <div class="popup-form-content">
@@ -1699,5 +1711,3 @@ if(($option == "show" || get_option("folder_redirect_status") == 2) && $is_plugi
1699
  </div>
1700
  </div>
1701
  </div>
1702
-
1703
-
1
  <?php
2
+ /**
3
+ * Admin folders settings
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
  ?>
13
  <!-- do not change here, Free/Pro URL Change -->
 
 
 
 
 
 
 
 
14
  <style>
15
+ <?php if (function_exists('is_rtl') && is_rtl()) { ?>
16
  #setting-form {
17
  float: right;
18
  }
37
  var removeTitle = "<?php esc_html_e("Are you sure?", "folders"); ?>";
38
  var removeDesc = "<?php esc_html_e("You're about to delete %plugin%'s folders. Are you sure you'd like to proceed?", "folders"); ?>";
39
  $(document).ready(function(){
40
+ <?php if ($setting_page == "folder-settings") { ?>
41
  $(".select2-box").select2();
42
  <?php } ?>
43
  $(document).on("click",".form-cancel-btn, .close-popup-button, .folder-popup-form",function(){
192
  success: function(res) {
193
  <?php
194
  $redirectURL = $this->getFolderSettingsURL();
195
+ if (!empty($redirectURL)) {
196
+ $page = filter_input(INPUT_POST, 'tab_page');
197
+ $type = filter_input(INPUT_GET, 'setting_page');
198
+ $type = empty($type) ? "" : "&setting_page=".esc_attr($type);
199
  $redirectURL = $redirectURL.$type;
200
+ if (!empty($page)) {
201
+ $redirectURL .= "&setting_page=".esc_attr($page);
202
  }
203
  }
204
+
205
  $redirectURL = $redirectURL."&note=2";
206
  ?>
207
  window.location = "<?php echo esc_url($redirectURL) ?>";
217
  $("#remove-folders-data-button").prop("disabled", true);
218
  }
219
  });
 
 
 
 
 
220
  $(document).on("click", "#import-folder-button", function(e){
221
  importPluginData();
222
  });
447
 
448
  </div>
449
  <?php
450
+ // Check website is hosted on wp.org or not
 
451
  $wp_status = get_option("is_web_hosted_on_wp");
452
+ if ($wp_status === false) {
453
  $site_url = site_url("/");
454
+ $domain = parse_url($site_url);
455
 
456
+ $options = [
457
+ 'http' => ['ignore_errors' => true],
458
+ ];
 
 
 
459
 
460
  $webLink = $domain['host'];
461
 
462
+ $context = stream_context_create($options);
463
+ $response = @file_get_contents(
464
  'https://public-api.wordpress.com/rest/v1/sites/'.$webLink,
465
  false,
466
  $context
467
  );
468
+ $response = json_decode($response, true);
469
 
470
+ if (!empty($response) && is_array($response)) {
471
+ if (isset($response['ID']) && !empty($response['ID'])) {
472
  add_option("is_web_hosted_on_wp", "yes");
473
  $wp_status = "yes";
474
  }
475
  }
476
+ }//end if
477
+
478
+ if ($wp_status === false) {
479
+ if (!function_exists("get_current_user_id")) {
480
  add_option("is_web_hosted_on_wp", "yes");
481
  $wp_status = "yes";
482
  }
483
  }
484
+
485
+ if ($wp_status === false) {
486
  add_option("is_web_hosted_on_wp", "no");
487
  }
488
+
489
  $show_media_popup = false;
490
+ if ($wp_status == "yes") {
 
491
  $popup_shown = get_option("is_wp_media_popup_shown");
492
+ if ($popup_shown === false) {
493
  $show_media_popup = true;
494
  add_option("is_wp_media_popup_shown", 1);
495
  } else {
496
+ if (!is_numeric($popup_shown)) {
497
  $popup_shown = 1;
498
  }
499
+
500
  $popup_shown++;
501
+ if ($popup_shown < 4) {
502
  $show_media_popup = true;
503
  }
504
+
505
  update_option("is_wp_media_popup_shown", $popup_shown);
506
  }
507
  }
508
+
509
  ?>
510
  <div class="wrap">
511
+ <h1><?php esc_html_e('Folders Settings', 'folders'); ?></h1>
512
  <?php
513
  settings_fields('folders_settings');
514
  settings_fields('default_folders');
515
  settings_fields('customize_folders');
516
+ $options = get_option('folders_settings');
517
+ $default_folders = get_option('default_folders');
518
  $customize_folders = get_option('customize_folders');
519
+ $default_folders = (empty($default_folders) || !is_array($default_folders)) ? [] : $default_folders;
520
+ do_settings_sections(__FILE__);
521
  delete_transient("premio_folders_without_trash");
522
+ $note = filter_input(INPUT_GET, "note");
523
  ?>
524
+ <?php if ($note == 1) { ?>
525
  <div class="folder-notification notice notice-success is-dismissible">
526
  <div class="folder-notification-title"><?php esc_html_e("Changes Saved", "folders") ?></div>
527
  <div class="folder-notification-note"><?php esc_html_e("Your changes have been saved.", "folders") ?></div>
528
  </div>
529
+ <?php } else if ($note == 2) {?>
530
  <div class="folder-notification notice notice-error is-dismissible">
531
  <div class="folder-notification-title"><?php esc_html_e("Folders Deleted", "folders") ?></div>
532
  <div class="folder-notification-note"><?php esc_html_e("All folders has been successfully deleted.", "folders") ?></div>
533
  </div>
534
  <?php } ?>
535
+ <?php if ($setting_page != "license-key") { ?>
536
  <form action="options.php" method="post" id="setting-form">
537
  <input type="hidden" name="tab_page" value="<?php echo esc_attr($setting_page) ?>">
538
  <?php } ?>
539
  <div class="folders-tabs">
540
  <div class="folder-tab-menu">
541
  <ul>
542
+ <li><a class="<?php echo esc_attr(($setting_page == "folder-settings") ? "active" : "") ?>" href="<?php echo esc_url($settingURL."&setting_page=folder-settings") ?>"><?php esc_html_e('Folders Settings', 'folders'); ?></a></li>
543
+ <li><a class="<?php echo esc_attr(($setting_page == "folders-by-user") ? "active" : "") ?>" href="<?php echo esc_url($settingURL."&setting_page=folders-by-user") ?>"><?php esc_html_e('User Restrictions', 'folders'); ?></a></li>
544
+ <li><a class="<?php echo esc_attr(($setting_page == "customize-folders") ? "active" : "") ?>" href="<?php echo esc_url($settingURL."&setting_page=customize-folders") ?>"><?php esc_html_e('Customize Folders', 'folders'); ?></a></li>
545
+ <li><a class="<?php echo esc_attr(($setting_page == "folders-import") ? "active" : "") ?>" href="<?php echo esc_url($settingURL."&setting_page=folders-import") ?>"><?php esc_html_e('Tools', 'folders'); ?></a></li>
546
+ <?php if ($isInSettings) { ?>
547
+ <li><a class="<?php echo esc_attr(($setting_page == "upgrade-to-pro") ? "active" : "") ?>" href="<?php echo esc_url($settingURL."&setting_page=upgrade-to-pro") ?>"><?php esc_html_e('Upgrade to Pro', 'folders'); ?></a></li>
548
  <?php } ?>
549
  </ul>
550
  </div>
551
  <div class="folder-tab-content">
552
+
553
+ <div class="tab-content <?php echo esc_attr(($setting_page == "folder-settings") ? "active" : "") ?>" id="folder-settings">
554
  <div class="accordion-content no-bp">
555
  <div class="accordion-left">
556
  <table class="form-table">
558
  <?php
559
  $post_types = get_post_types( array( ), 'objects' );
560
  $post_array = array("page", "post", "attachment");
561
+ foreach ( $post_types as $post_type ) {
 
562
  if ( ! $post_type->show_ui) continue;
563
  $is_checked = !in_array( $post_type->name, $options )?"hide-option":"";
564
  $selected_id = (isset($default_folders[$post_type->name]))?$default_folders[$post_type->name]:"all";
565
+ $is_exists = WCP_Folders::check_for_setting($post_type->name, "default_folders");
566
+ $is_customized = WCP_Folders::check_for_setting($post_type->name, "folders_settings");
567
  if(in_array($post_type->name, $post_array) || $is_customized === true){
568
  ?>
569
  <tr>
587
  if(isset($terms_data[$post_type->name]) && !empty($terms_data[$post_type->name])) {
588
  foreach ($terms_data[$post_type->name] as $term) {
589
  if(empty($is_exists) || $is_exists === false) {
590
+ echo "<option class='pro-select-item' value='folders-pro'>" . esc_attr( $term->name ). " (Pro) 🔑</option>";
591
  } else {
592
+ $selected = ( $selected_id == $term->slug ) ? "selected" : "";
593
+ echo "<option " . esc_attr( $selected ) . " value='" . esc_attr( $term->slug ) . "'>" . esc_attr( $term->name ) . "</option>";
594
  }
595
  }
596
  } ?>
599
  </tr>
600
  <?php
601
  } else {
602
+ $show_media_details = "off";
603
  ?>
604
  <tr>
605
  <td style="padding: 15px 10px 15px 0px" colspan="4">
616
  </td>
617
  </tr>
618
  <?php }
619
+ } ?>
620
  <?php
621
+ $show_in_page = !isset($customize_folders['use_shortcuts']) ? "yes" : $customize_folders['use_shortcuts'];
622
  ?>
623
  <tr>
624
  <td class="no-padding">
629
  </label>
630
  </td>
631
  <td colspan="3">
632
+ <label for="use_shortcuts" ><?php esc_html_e('Use keyboard shortcuts to navigate faster', 'folders'); ?> <a href="#" class="view-shortcodes">(<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z" /></svg> <?php esc_html_e('View shortcuts', 'folders'); ?>)</a>
633
  </td>
634
  </tr>
635
  <tr>
655
  </a>
656
  </td>
657
  </tr>
658
+ <?php
659
+ $show_in_page = !isset($customize_folders['use_folder_undo']) ? "yes" : $customize_folders['use_folder_undo'];
660
+ ?>
661
  <tr>
662
  <td class="no-padding">
663
  <input type="hidden" name="customize_folders[use_folder_undo]" value="no">
667
  </label>
668
  </td>
669
  <td colspan="3">
670
+ <label for="use_folder_undo" ><?php esc_html_e('Use folders with Undo action after performing tasks', 'folders'); ?> <span class="recommanded">Recommended</span></label>
671
  </td>
672
  </tr>
673
+ <?php
674
+ $default_timeout = !isset($customize_folders['default_timeout']) ? "5" : $customize_folders['default_timeout'];
675
+ ?>
676
+ <tr class="timeout-settings <?php echo ($show_in_page == "yes") ? "active" : "" ?>">
677
  <td style="padding: 10px 0;" colspan="4">
678
+ <label for="default_timeout" ><?php esc_html_e('Default timeout', 'folders'); ?></label>
679
  <div class="seconds-box">
680
  <input type="number" class="seconds-input" name="customize_folders[default_timeout]" value="<?php echo esc_attr($default_timeout) ?>" />
681
  </div>
684
 
685
  <tr>
686
  <td style="padding: 15px 10px 15px 0px" colspan="4">
687
+ <?php $replace_media_title = "off"; ?>
688
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
689
  <label for="" class="custom-checkbox send-user-to-pro">
690
  <input disabled type="checkbox" class="sr-only" id="enable_media_trash" value="off">
691
  <span></span>
692
  </label>
693
  <label for="" class="send-user-to-pro">
694
+ <?php esc_html_e("Move files to trash by default before deleting", "folders"); ?>
695
  <span class="folder-tooltip" data-title="<?php esc_html_e("When enabled, files will be moved to trash to prevent mistakes, and then you can delete permanently from the trash", "folders") ?>"><span class="dashicons dashicons-editor-help"></span></span></label>
696
+ <button type="button" class="upgrade-link" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>"><?php esc_html_e("Upgrade to Pro", 'folders') ?></button>
697
  </label>
698
  </a>
699
  </td>
700
  </tr>
701
  <?php
702
+ $show_in_page = !isset($customize_folders['folders_media_cleaning']) ? "yes" : $customize_folders['folders_media_cleaning'];
703
  ?>
704
  <tr>
705
  <td style="padding: 15px 10px 15px 0px" colspan="4">
722
  <td style="padding: 15px 10px 15px 0px" colspan="4">
723
  <input type="hidden" name="folders_settings1" value="folders">
724
  <?php
725
+ $show_media_details = !isset($customize_folders['show_media_details']) ? "on" : $customize_folders['show_media_details'];
726
  $show_media_details = "off";
727
  ?>
728
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
750
  <div class="">
751
  <div class="">
752
  <?php
753
+ $media_settings = [
754
+ 'image_title' => [
755
+ "title" => esc_html__("Title", "folders"),
756
  "default" => "on",
757
+ ],
758
+ 'image_alt_text' => [
759
+ "title" => esc_html__("Alternative Text", "folders"),
760
  "default" => "off",
761
+ ],
762
+ 'image_file_url' => [
763
+ "title" => esc_html__("File URL", "folders"),
764
  "default" => "off",
765
+ ],
766
+ 'image_dimensions' => [
767
+ "title" => esc_html__("Dimensions", "folders"),
768
  "default" => "on",
769
+ ],
770
+ 'image_size' => [
771
+ "title" => esc_html__("Size", "folders"),
772
  "default" => "off",
773
+ ],
774
+ 'image_file_name' => [
775
+ "title" => esc_html__("Filename", "folders"),
776
  "default" => "off",
777
+ ],
778
+ 'image_type' => [
779
+ "title" => esc_html__("Type", "folders"),
780
  "default" => "on",
781
+ ],
782
+ 'image_date' => [
783
+ "title" => esc_html__("Date", "folders"),
784
  "default" => "on",
785
+ ],
786
+ 'image_uploaded_by' => [
787
+ "title" => esc_html__("Uploaded by", "folders"),
788
  "default" => "off",
789
+ ],
790
+ ];
791
+ $media_col_settings = isset($customize_folders['media_col_settings']) && is_array($customize_folders['media_col_settings']) ? $customize_folders['media_col_settings'] : [
792
+ "image_title",
793
+ "image_dimensions",
794
+ "image_type",
795
+ "image_date",
796
+ ];
797
  ?>
798
  <input type="hidden" name="customize_folders[media_col_settings][]" value="all">
799
  <div class="media-setting-box active send-user-to-pro" >
800
  <div class="normal-box">
801
  <select disabled multiple="multiple" name="customize_folders[media_col_settings][]" class="select2-box">
802
+ <?php foreach ($media_settings as $key => $media) {
803
  $selected = $media['default'];
804
  ?>
805
  <option <?php selected($selected, "on") ?> value="<?php echo esc_attr($key) ?>"><?php echo esc_attr($media['title']) ?></option>
815
  </td>
816
  </tr>
817
  <?php
818
+ $show_in_page = !isset($customize_folders['folders_enable_replace_media']) ? "yes" : $customize_folders['folders_enable_replace_media'];
819
  ?>
820
  <tr>
821
  <td class="no-padding">
826
  </label>
827
  </td>
828
  <td colspan="3" class="enable-replace-media">
829
+ <label for="folders_enable_replace_media" ><?php esc_html_e('Enable Replace Media', 'folders'); ?>
830
  <span class="html-tooltip no-position top">
831
  <span class="dashicons dashicons-editor-help"></span>
832
  <span class="tooltip-text top" style="">
839
  </td>
840
  </tr>
841
  <?php
842
+ $show_in_page = !isset($customize_folders['show_folder_in_settings']) ? "no" : $customize_folders['show_folder_in_settings'];
843
  ?>
844
  <tr>
845
  <td class="no-padding">
850
  </label>
851
  </td>
852
  <td colspan="3">
853
+ <label for="show_folder_in_settings" ><?php esc_html_e('Place the Folders settings page nested under "Settings"', 'folders'); ?></label>
854
  </td>
855
  </tr>
856
+ <?php $val = get_option("folders_show_in_menu"); ?>
857
  <input type="hidden" name="folders_show_in_menu" value="off" />
858
  <tr>
859
  <td width="20" class="no-padding">
863
  </label>
864
  </td>
865
  <td colspan="3">
866
+ <label for="folders_show_in_menu" ><?php esc_html_e('Show the folders also in WordPress menu', 'folders'); ?></label>
867
  </td>
868
  </tr>
869
  <tr>
870
  <td style="padding: 15px 10px 15px 0px" colspan="4">
871
+ <?php $replace_media_title = "off"; ?>
872
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
873
  <label for="" class="custom-checkbox send-user-to-pro">
874
  <input disabled type="checkbox" class="sr-only" name="customize_folders[replace_media_title]" id="replace_media_title" value="on" <?php checked($replace_media_title, "on") ?>>
875
  <span></span>
876
  </label>
877
  <label for="" class="send-user-to-pro">
878
+ <?php esc_html_e("Auto Rename file based on title", "folders"); ?>
879
  <span class="folder-tooltip" data-title="<?php esc_html_e("Replace the actual file name of media files with the title from the WordPress editor.", "folders") ?>"><span class="dashicons dashicons-editor-help"></span></span></label>
880
  <button type="button" class="upgrade-link" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>"><?php esc_html_e("Upgrade to Pro", 'folders') ?></button>
881
  </label>
886
  </tboby>
887
  </table>
888
  <input type="hidden" name="customize_folders[show_media_details]" value="off">
 
889
  </div>
890
  <div class="accordion-right">
891
  <div class="premio-help">
898
  </div>
899
  </a>
900
  </div>
901
+ <?php if ($wp_status == "yes") { ?>
902
  <div class="premio-help">
903
  <div class="premio-help-btn wp-folder-user">
904
  <div class="folder-help-icon"><span class="dashicons dashicons-wordpress"></span></div>
914
  </div>
915
  </div>
916
  </div>
917
+
918
+ <div class="tab-content <?php echo esc_attr(($setting_page == "customize-folders") ? "active" : "") ?>" id="customize-folders">
919
  <div class="accordion-content">
920
  <div class="accordion-left">
921
  <table class="form-table">
922
  <?php
923
+ $colors = [
924
+ "#FA166B",
925
+ "#0073AA",
926
+ "#484848",
927
+ ];
928
+ $color = !isset($customize_folders['new_folder_color'])||empty($customize_folders['new_folder_color']) ? "#FA166B" : $customize_folders['new_folder_color'];
929
  $setting_color = WCP_Folders::check_for_setting("new_folder_color", "customize_folders");
930
  ?>
931
  <tr>
936
  </td>
937
  <td>
938
  <ul class="color-list">
939
+ <?php $field_name = "new_folder_color"; foreach ($colors as $key => $value) { ?>
940
  <li>
941
+ <label class="color-checkbox <?php echo ($color == $value) ? "active" : "" ?>" for="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>">
942
+ <input type="radio" id="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($value) ?>" <?php checked($color, $value) ?> />
943
  <span style="background: <?php echo esc_attr($value) ?>"></span>
944
  </label>
945
  </li>
946
  <?php } $key = 3; ?>
947
+ <?php if ($setting_color !== false && $setting_color != "#FA166B") { ?>
948
  <li>
949
+ <label class="color-checkbox <?php echo ($color == $setting_color) ? "active" : "" ?>" for="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>">
950
+ <input type="radio" id="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($setting_color) ?>" <?php checked($color, $setting_color) ?> />
951
  <span style="background: <?php echo esc_attr($setting_color) ?>"></span>
952
  </label>
953
  </li>
965
  </td>
966
  </tr>
967
  <?php
968
+ $color = !isset($customize_folders['bulk_organize_button_color'])||empty($customize_folders['bulk_organize_button_color']) ? "#FA166B" : $customize_folders['bulk_organize_button_color'];
969
  $setting_color = WCP_Folders::check_for_setting("bulk_organize_button_color", "customize_folders");
970
  ?>
971
  <tr>
976
  </td>
977
  <td>
978
  <ul class="color-list">
979
+ <?php $field_name = "bulk_organize_button_color"; foreach ($colors as $key => $value) { ?>
980
  <li>
981
+ <label class="color-checkbox <?php echo ($color == $value) ? "active" : "" ?>" for="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>">
982
+ <input type="radio" id="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($value) ?>" <?php checked($color, $value) ?> />
983
  <span style="background: <?php echo esc_attr($value) ?>"></span>
984
  </label>
985
  </li>
986
  <?php } $key = 3; ?>
987
+ <?php if ($setting_color !== false && $setting_color != "#FA166B") { ?>
988
  <li>
989
+ <label class="color-checkbox <?php echo ($color == $setting_color) ? "active" : "" ?>" for="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>">
990
+ <input type="radio" id="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($setting_color) ?>" <?php checked($color, $setting_color) ?> />
991
  <span style="background: <?php echo esc_attr($setting_color) ?>"></span>
992
  </label>
993
  </li>
1002
  </td>
1003
  </tr>
1004
  <?php
1005
+ $color = !isset($customize_folders['media_replace_button'])||empty($customize_folders['media_replace_button']) ? "#FA166B" : $customize_folders['media_replace_button'];
1006
  $setting_color = WCP_Folders::check_for_setting("media_replace_button", "customize_folders");
1007
  ?>
1008
  <tr>
1013
  </td>
1014
  <td>
1015
  <ul class="color-list">
1016
+ <?php $field_name = "media_replace_button"; foreach ($colors as $key => $value) { ?>
1017
  <li>
1018
+ <label class="color-checkbox <?php echo ($color == $value) ? "active" : "" ?>" for="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>">
1019
+ <input type="radio" id="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($value) ?>" <?php checked($color, $value) ?> />
1020
  <span style="background: <?php echo esc_attr($value) ?>"></span>
1021
  </label>
1022
  </li>
1023
  <?php } $key = 3; ?>
1024
+ <?php if ($setting_color !== false && $setting_color != "#FA166B") { ?>
1025
  <li>
1026
+ <label class="color-checkbox <?php echo ($color == $setting_color) ? "active" : "" ?>" for="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>">
1027
+ <input type="radio" id="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($setting_color) ?>" <?php checked($color, $setting_color) ?> />
1028
  <span style="background: <?php echo esc_attr($setting_color) ?>"></span>
1029
  </label>
1030
  </li>
1039
  </td>
1040
  </tr>
1041
  <?php
1042
+ $color = !isset($customize_folders['dropdown_color'])||empty($customize_folders['dropdown_color']) ? "#484848" : $customize_folders['dropdown_color'];
1043
  $setting_color = WCP_Folders::check_for_setting("dropdown_color", "customize_folders");
1044
  ?>
1045
  <tr>
1050
  </td>
1051
  <td>
1052
  <ul class="color-list">
1053
+ <?php $field_name = "dropdown_color"; foreach ($colors as $key => $value) { ?>
1054
  <li>
1055
+ <label class="color-checkbox <?php echo ($color == $value) ? "active" : "" ?>" for="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>">
1056
+ <input type="radio" id="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($value) ?>" <?php checked($color, $value) ?> />
1057
  <span style="background: <?php echo esc_attr($value) ?>"></span>
1058
  </label>
1059
  </li>
1060
  <?php } $key = 3; ?>
1061
+ <?php if ($setting_color !== false && $setting_color != "#484848") { ?>
1062
  <li>
1063
+ <label class="color-checkbox <?php echo ($color == $setting_color) ? "active" : "" ?>" for="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>">
1064
+ <input type="radio" id="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($setting_color) ?>" <?php checked($color, $setting_color) ?> />
1065
  <span style="background: <?php echo esc_attr($setting_color) ?>"></span>
1066
  </label>
1067
  </li>
1076
  </td>
1077
  </tr>
1078
  <?php
1079
+ $color = !isset($customize_folders['folder_bg_color'])||empty($customize_folders['folder_bg_color']) ? "#FA166B" : $customize_folders['folder_bg_color'];
1080
  $setting_color = WCP_Folders::check_for_setting("folder_bg_color", "customize_folders");
1081
  ?>
1082
  <tr>
1087
  </td>
1088
  <td>
1089
  <ul class="color-list">
1090
+ <?php $field_name = "folder_bg_color"; foreach ($colors as $key => $value) { ?>
1091
  <li>
1092
+ <label class="color-checkbox <?php echo ($color == $value) ? "active" : "" ?>" for="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>">
1093
+ <input type="radio" id="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($value) ?>" <?php checked($color, $value) ?> />
1094
  <span style="background: <?php echo esc_attr($value) ?>"></span>
1095
  </label>
1096
  </li>
1097
  <?php } $key = 3; ?>
1098
+ <?php if ($setting_color !== false && $setting_color != "#FA166B") { ?>
1099
  <li>
1100
+ <label class="color-checkbox <?php echo ($color == $setting_color) ? "active" : "" ?>" for="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>">
1101
+ <input type="radio" id="<?php echo esc_attr($field_name)."-".esc_attr($key) ?>" name="customize_folders[<?php echo esc_attr($field_name) ?>]" class="sr-only checkbox-color" value="<?php echo esc_attr($setting_color) ?>" <?php checked($color, $setting_color) ?> />
1102
  <span style="background: <?php echo esc_attr($setting_color) ?>"></span>
1103
  </label>
1104
  </li>
1113
  </td>
1114
  </tr>
1115
  <?php
1116
+ $font = !isset($customize_folders['folder_font'])||empty($customize_folders['folder_font']) ? "" : $customize_folders['folder_font'];
1117
  $setting_font = WCP_Folders::check_for_setting("folder_font", "customize_folders");
1118
+ $index = 0;
1119
  ?>
1120
  <tr>
1121
  <td class="no-padding">
1122
  <label for="folder_font" >
1123
+ <?php if ($setting_font !== false && $setting_font != "" && !in_array($setting_font, ["Arial", "Tahoma", "Verdana", "Helvetica", "Times New Roman", "Trebuchet MS", "Georgia", "System Stack"])) {
1124
+ esc_html_e("Folders font", 'folders');
1125
+ } else { ?>
1126
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
1127
+ <?php esc_html_e('Folders font', 'folders'); ?> <button type="button" class="upgrade-link" ><?php esc_html_e("Upgrade to Pro", 'folders'); ?></button>
1128
  </a>
1129
+ <?php } ?>
1130
  </label>
1131
  </td>
1132
  <td colspan="2">
1133
  <select name="customize_folders[folder_font]" id="folder_font" >
1134
  <?php $group = '';
1135
+ foreach ($fonts as $key => $value) :
1136
  $title = $key;
1137
+ if ($index == 0) {
1138
  $key = "";
1139
  }
1140
+
1141
  $index++;
1142
  if ($value != $group) {
1143
+ echo '<optgroup label="'.esc_attr($value).'">';
1144
  $group = $value;
1145
  }
1146
+
1147
+ if (($setting_font !== false && $setting_font != "" && !in_array($setting_font, ["Arial", "Tahoma", "Verdana", "Helvetica", "Times New Roman", "Trebuchet MS", "Georgia"])) || $value != "Google Fonts") { ?>
1148
  <option value="<?php echo esc_attr($key); ?>" <?php selected($font, $key); ?>><?php echo esc_attr($title); ?></option>
1149
  <?php } else { ?>
1150
  <option class="pro-select-item" value="folders-pro"><?php echo esc_attr($title); ?> (Pro) 🔑</option>
1154
  </td>
1155
  </tr>
1156
  <?php
1157
+ $size = ! isset($customize_folders['folder_size']) || empty($customize_folders['folder_size']) ? "16" : $customize_folders['folder_size'];
1158
  $folder_size = WCP_Folders::check_for_setting("folder_size", "customize_folders");
1159
  ?>
1160
  <tr>
1161
  <td class="no-padding">
1162
  <label for="folder_size" >
1163
+ <?php if ($folder_size === false || intval($folder_size) === 16) { ?>
1164
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
1165
+ <?php esc_html_e('Folders size', 'folders'); ?> <button type="button" class="upgrade-link" ><?php esc_html_e("Upgrade to Pro", 'folders'); ?></button>
1166
  </a>
1167
  <?php } else { ?>
1168
  <?php esc_html_e("Folders size", 'folders'); ?>
1171
  </td>
1172
  <td colspan="2">
1173
  <?php
1174
+ if ($folder_size === false || intval($folder_size) == 16) {
1175
+ $sizes = [
1176
+ "folders-pro" => "Small (Pro) 🔑",
1177
+ "16" => "Medium",
1178
+ "folders-pro-item" => "Large (Pro) 🔑",
1179
+ "folders-item-pro" => "Custom (Pro) 🔑",
1180
+ ];
1181
+ $size = 16;
1182
  } else {
1183
+ $sizes = [
1184
+ "12" => "Small",
1185
+ "16" => "Medium",
1186
+ "20" => "Large",
1187
+ ];
1188
  }
1189
  ?>
1190
  <select name="customize_folders[folder_size]" id="folder_size" >
1191
  <?php
1192
+ foreach ($sizes as $key => $value) {
1193
+ $selected = ($key == $size) ? "selected" : "";
1194
+ echo "<option ".esc_attr($selected)." value='".esc_attr($key)."'>".esc_attr($value)."</option>";
1195
  }
1196
  ?>
1197
  </select>
1198
  </td>
1199
  </tr>
1200
  <?php
1201
+ $show_in_page = isset($customize_folders['show_in_page']) ? $customize_folders['show_in_page'] : "hide";
1202
+ $show_folder = WCP_Folders::check_for_setting("show_in_page", "customize_folders");
1203
+ if (empty($show_in_page)) {
1204
  $show_in_page = "hide";
1205
  }
1206
  ?>
1207
  <tr>
1208
  <td colspan="3" style="padding: 15px 20px 15px 0">
1209
  <input type="hidden" name="customize_folders[show_in_page]" value="hide">
1210
+ <?php if ($show_folder === false || $show_folder === "hide") { ?>
1211
  <a class="upgrade-box-link" target="_blank" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" >
1212
  <label for="" class="custom-checkbox send-user-to-pro">
1213
  <input disabled type="checkbox" class="sr-only" name="customize_folders[show_in_page]" id="show_in_page" value="on" <?php checked($show_in_page, "show") ?>>
1214
  <span></span>
1215
  </label>
1216
  <label for="" class="send-user-to-pro">
1217
+ <?php esc_html_e("Show Folders in upper position", "folders"); ?>
1218
  <button type="button" class="upgrade-link" href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>"><?php esc_html_e("Upgrade to Pro", 'folders'); ?></button>
1219
  </label>
1220
  </a>
1238
  <div class="preview-box">
1239
  <div class="wcp-custom-form">
1240
  <div class="form-title">
1241
+ <?php esc_html_e("Folders", 'folders'); ?>
1242
  <a href="javascript:;" class="add-new-folder" id="add-new-folder">
1243
  <span class="create_new_folder"><i class="pfolder-add-folder"></i></span>
1244
  <span><?php esc_html_e("New Folder", 'folders'); ?></span>
1300
  <?php submit_button(); ?>
1301
  </div>
1302
  </div>
1303
+
1304
+ <div class="tab-content <?php echo esc_attr(($setting_page == "folders-import") ? "active" : "") ?>" id="folder-import">
1305
  <?php
1306
+ $remove_folders_when_removed = !isset($customize_folders['remove_folders_when_removed']) ? "off" : $customize_folders['remove_folders_when_removed'];
1307
  ?>
1308
  <input type="hidden" name="customize_folders[remove_folders_when_removed]" value="off" />
1309
  <div class="folder-danger-zone">
1310
  <table class="import-export-table">
1311
+ <?php if ($is_plugin_exists) { ?>
1312
+ <tr class="has-other-plugins">
1313
+ <td>
1314
+ <span class="folder-info"><span class="dashicons dashicons-admin-generic"></span> <?php esc_html_e("Export/Import", "folders"); ?></span>
1315
+ <span class="folder-text"><span><?php esc_html_e("External folders found.", "folders"); ?></span> <?php esc_html_e("Click import to start importing external folders.", "folders"); ?></span>
1316
+ </td>
1317
+ <td class="last-td">
1318
+ <a href="#" class="import-folders-button"><?php esc_html_e("Import", "folders"); ?></a>
1319
+ </td>
1320
+ </tr>
1321
  <?php } ?>
1322
+ <tr class="no-more-plugins <?php echo (!$is_plugin_exists) ? "active" : "" ?>">
1323
  <td>
1324
  <span class="folder-info"><span class="dashicons dashicons-admin-generic"></span> <?php esc_html_e("Export/Import", "folders"); ?></span>
1325
  <span class="folder-text"><?php esc_html_e("Couldn't detect any external folders that can be imported. Please contact us if you have external folders that were not detected", "folders"); ?></span>
1357
  </table>
1358
  </div>
1359
  </div>
1360
+
1361
+ <div class="tab-content <?php echo esc_attr(($setting_page == "upgrade-to-pro") ? "active" : "") ?>">
1362
+ <?php if ($setting_page == "upgrade-to-pro") { ?>
1363
  <?php include_once "upgrade-table.php"; ?>
1364
  <?php } ?>
1365
  </div>
1366
+
1367
+ <div class="tab-content <?php echo esc_attr(($setting_page == "folders-by-user") ? "active" : "") ?>" id="folders-by-user">
1368
+ <?php
1369
+ $folders_by_users = !isset($customize_folders['folders_by_users']) ? "off" : $customize_folders['folders_by_users'];
1370
+ $dynamic_folders_for_admin_only = !isset($customize_folders['dynamic_folders_for_admin_only']) ? "off" : $customize_folders['dynamic_folders_for_admin_only'];
1371
+ ?>
1372
+ <?php if ($setting_page == "folders-by-user") { ?>
1373
  <div class="folders-by-user">
1374
  <div class="send-user-to-pro">
1375
  <div class="normal-box">
1425
  </a>
1426
  </div>
1427
  </div>
1428
+ <?php }//end if
1429
+ ?>
1430
  </div>
1431
+
1432
  </div>
1433
  </div>
1434
  <?php
1435
  ?>
1436
  <input type="hidden" name="folder_nonce" value="<?php echo wp_create_nonce("folder_settings") ?>">
1437
+ <input type="hidden" name="folder_page" value="<?php echo filter_input(INPUT_SERVER, "REQUEST_URI") ?>">
1438
+ <?php if ($setting_page != "upgrade-to-pro") { ?>
1439
  </form>
1440
+ <?php } ?>
1441
  </div>
1442
 
1443
  <div class="folder-popup-form" id="import-plugin-data">
1456
  </div>
1457
  </div>
1458
 
1459
+ <?php
1460
+ // if($plugin['is_exists']) { ?>
1461
  <div class="folder-popup-form" id="import-folders-popup">
1462
  <div class="popup-form-content">
1463
  <div class="popup-content">
1469
  <div class="import-folder-table">
1470
  <table>
1471
  <tbody>
1472
+ <?php foreach ($plugin_info as $slug => $plugin) { ?>
1473
+ <?php if ($plugin['is_exists']) { ?>
1474
  <tr class="other-plugins-<?php echo esc_attr__($slug) ?>" data-plugin="<?php echo esc_attr__($slug) ?>" data-nonce="<?php echo wp_create_nonce("import_data_from_".$slug) ?>" data-folders="<?php echo esc_attr($plugin['total_folders']) ?>" data-attachments="<?php echo esc_attr($plugin['total_attachments']) ?>">
1475
  <th class="plugin-name"><?php echo esc_attr__($plugin['name']) ?></th>
1476
  <td>
1477
+ <span class="import-message"><?php printf(esc_html__("%s folder%s and %s attachment%s", "folders"), "<b>".esc_attr($plugin['total_folders'])."</b>", ($plugin['total_folders'] > 1) ? esc_html__("s") : "", "<b>".esc_attr($plugin['total_attachments'])."</b>", ($plugin['total_attachments'] > 1) ? esc_html__("s") : "") ?></span>
1478
  <button type="button" class="button button-primary import-folder-data in-popup"><?php esc_html_e("Import", "folders"); ?> <span class="spinner"></span></button>
1479
  <button type="button" class="button button-secondary remove-folder-data in-popup"><?php esc_html_e("Delete plugin data", "folders"); ?> <span class="spinner"></span></button>
1480
  </td>
1481
  </tr>
1482
+ <?php } ?>
1483
+ <?php } ?>
1484
  </tbody>
1485
  </table>
1486
  </div>
1492
  </div>
1493
  </div>
1494
  </div>
1495
+ <?php
1496
+ // } ?>
1497
 
1498
  <div class="folder-popup-form" id="remove-plugin-data">
1499
  <div class="popup-form-content">
1554
  </div>
1555
 
1556
  <?php
1557
+ if ($wp_status == "yes" && $show_media_popup) {
1558
  add_option("is_wp_media_popup_shown", "yes");
1559
  ?>
1560
  <div class="folder-popup-form" id="wordpress-popup">
1577
  </div>
1578
  </div>
1579
  </div>
1580
+ <?php }//end if
1581
+ ?>
1582
 
1583
  <?php
1584
  $option = get_option("folder_intro_box");
1585
+ if (($option == "show" || get_option("folder_redirect_status") == 2) && $is_plugin_exists) { ?>
1586
  <div class="folder-popup-form" id="import-third-party-plugin-data" style="display: block" ?>
1587
  <div class="popup-form-content">
1588
  <div class="popup-content">
1595
  <div class="import-folder-table">
1596
  <table>
1597
  <tbody>
1598
+ <?php foreach ($plugin_info as $slug => $plugin) {
1599
+ if ($plugin['is_exists']) { ?>
1600
  <tr class="other-plugins-<?php echo esc_attr__($slug) ?>" data-plugin="<?php echo esc_attr__($slug) ?>" data-nonce="<?php echo wp_create_nonce("import_data_from_".$slug) ?>" data-folders="<?php echo esc_attr($plugin['total_folders']) ?>" data-attachments="<?php echo esc_attr($plugin['total_attachments']) ?>">
1601
  <th class="plugin-name"><?php echo esc_attr__($plugin['name']) ?></th>
1602
  <td>
1603
  <button type="button" class="button button-primary import-folder-data in-popup"><?php esc_html_e("Import", "folders"); ?> <span class="spinner"></span></button>
1604
+ <span class="import-message"><?php printf(esc_html__("%s folder%s and %s attachment%s", "folders"), "<b>".esc_attr($plugin['total_folders'])."</b>", ($plugin['total_folders'] > 1) ? esc_html__("s") : "", "<b>".esc_attr($plugin['total_attachments'])."</b>", ($plugin['total_attachments'] > 1) ? esc_html__("s") : "") ?></span>
1605
  </td>
1606
  </tr>
1607
  <?php }
1618
  </div>
1619
  </div>
1620
  <?php
1621
+ if ($option != "show") {
1622
  update_option("folder_redirect_status", 3);
1623
  }
1624
+ }//end if
1625
+ ?>
1626
+
1627
  <div class="folder-popup-form" id="no-more-folder-credit">
1628
  <div class="popup-form-content">
1629
  <div class="popup-content">
1631
  <a class="" href="javascript:;"><span></span></a>
1632
  </div>
1633
  <div class="add-update-folder-title" id="folder-limitation-message">
1634
+ <?php esc_html_e("You've reached the 10 folder limitation!", 'folders'); ?>
1635
  </div>
1636
  <div class="folder-form-message">
1637
+ <?php esc_html_e("Unlock unlimited amount of folders by upgrading to one of our pro plans.", 'folders'); ?>
1638
  </div>
1639
  <div class="folder-form-buttons">
1640
  <a href="javascript:;" class="form-cancel-btn"><?php esc_html_e("Cancel", 'folders'); ?></a>
1643
  </div>
1644
  </div>
1645
  </div>
1646
+ <?php require_once "help.php" ?>
 
 
1647
 
1648
  <div class="folder-popup-form" id="keyboard-shortcut">
1649
  <div class="popup-form-content">
1711
  </div>
1712
  </div>
1713
  </div>
 
 
templates/admin/help.php CHANGED
@@ -1,11 +1,20 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
 
 
 
 
 
 
 
3
  ?>
4
  <style>
5
  .folder-help-btn,.folder-help-form{position:fixed;z-index:1001;display:none}.folders-help .folder-help-btn{display:block!important}.folder-help-btn{right:20px;bottom:20px}.folder-help-btn a{display:block;border:3px solid #fff;width:50px;height:50px;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;position:relative}.folder-help-btn a img{width:100%;height:auto;display:block;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%}.folder-help-form{right:85px;border:1px solid #e9edf0;bottom:25px;background:#fff;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;width:320px;direction:ltr;opacity:0;transition:.4s;-webkit-transition:.4s;-moz-transition:.4s}.folder-help-form.active{opacity:1;pointer-events:inherit;display:block}.folder-help-header{background:#f4f4f4;border-bottom:1px solid #e9edf0;padding:5px 20px;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px 10px 0 0;font-size:16px;text-align:right}.folder-help-header b{float:left}.folder-help-content{margin-bottom:10px;padding:20px 20px 10px}.folder-help-form p{margin:0 0 1em}.folder-form-field{margin-bottom:10px}.folder-form-field input,.folder-form-field textarea{-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;padding:5px;width:100%;box-sizing:border-box;border:1px solid #c5c5c5}.folder-form-field textarea{width:100%;height:100px;margin-bottom:0}.folder-help-button{border:none;padding:8px 0;width:100%;background:#ff6624;color:#fff;border-radius:18px;cursor:pointer}.folder-help-form .error-message{font-weight:400;font-size:14px;display:block}.folder-help-form input.input-error,.folder-help-form textarea.input-error{border-color:#dc3232}.folder-help-btn span.tooltiptext{position:absolute;background:#000;font-size:12px;color:#fff;top:-35px;width:140%;text-align:center;left:-20%;border-radius:5px;direction:ltr}p.error-p,p.success-p{margin:0;font-size:14px;text-align:center}.folder-help-btn span.tooltiptext:after{bottom:-20px;content:"";transform:translateX(-50%);height:10px;width:0;border-width:10px 5px 0;border-style:solid;border-color:#000 transparent transparent;left:50%;position:absolute}p.success-p{color:green}p.error-p{color:#dc3232}html[dir=rtl] .folder-help-btn{left:20px;right:auto}html[dir=rtl] .folder-help-form{left:85px;right:auto}.folder-popup-body h3{line-height:24px}.folder-popup-overlay .form-control input{width:100%;margin:0 0 15px}body.plugins-php .tooltiptext{display:none}.help-form-footer{text-align:center}.help-form-footer p{margin:0;padding:0}.help-form-footer p+p{margin:0;padding:10px 0}
6
  </style>
7
  <div class="folder-help-form">
8
- <form action="<?php echo esc_url(admin_url( 'admin-ajax.php' )) ?>" method="post" id="folder-help-form">
9
  <div class="folder-help-header">
10
  <b>Gal Dubinski</b> Co-Founder at Premio
11
  </div>
@@ -34,7 +43,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
34
  <a class="folder-help-tooltip" href="javascript:;"><img src="<?php echo esc_url(WCP_FOLDER_URL."assets/images/owner.jpg") ?>" alt="<?php esc_html_e("Need help?", 'folders'); ?>" /></a>
35
  <?php
36
  $option = get_option("hide_folders_cta");
37
- if($option !== "yes") { ?>
38
  <span class="tooltiptext">Need help?</span>
39
  <?php } ?>
40
  </div>
@@ -45,7 +54,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
45
  jQuery(".folder-help-button").text("<?php esc_html_e("Sending Request...") ?>");
46
  formData = jQuery(this).serialize();
47
  jQuery.ajax({
48
- url: "<?php echo esc_url(admin_url( 'admin-ajax.php' )) ?>",
49
  data: formData,
50
  type: "post",
51
  success: function(responseText){
@@ -106,4 +115,4 @@ if ( ! defined( 'ABSPATH' ) ) exit;
106
  }
107
  });
108
  });
109
- </script>
1
  <?php
2
+ /**
3
+ * Admin folders help
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
  ?>
13
  <style>
14
  .folder-help-btn,.folder-help-form{position:fixed;z-index:1001;display:none}.folders-help .folder-help-btn{display:block!important}.folder-help-btn{right:20px;bottom:20px}.folder-help-btn a{display:block;border:3px solid #fff;width:50px;height:50px;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%;position:relative}.folder-help-btn a img{width:100%;height:auto;display:block;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%}.folder-help-form{right:85px;border:1px solid #e9edf0;bottom:25px;background:#fff;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;width:320px;direction:ltr;opacity:0;transition:.4s;-webkit-transition:.4s;-moz-transition:.4s}.folder-help-form.active{opacity:1;pointer-events:inherit;display:block}.folder-help-header{background:#f4f4f4;border-bottom:1px solid #e9edf0;padding:5px 20px;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px 10px 0 0;font-size:16px;text-align:right}.folder-help-header b{float:left}.folder-help-content{margin-bottom:10px;padding:20px 20px 10px}.folder-help-form p{margin:0 0 1em}.folder-form-field{margin-bottom:10px}.folder-form-field input,.folder-form-field textarea{-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;padding:5px;width:100%;box-sizing:border-box;border:1px solid #c5c5c5}.folder-form-field textarea{width:100%;height:100px;margin-bottom:0}.folder-help-button{border:none;padding:8px 0;width:100%;background:#ff6624;color:#fff;border-radius:18px;cursor:pointer}.folder-help-form .error-message{font-weight:400;font-size:14px;display:block}.folder-help-form input.input-error,.folder-help-form textarea.input-error{border-color:#dc3232}.folder-help-btn span.tooltiptext{position:absolute;background:#000;font-size:12px;color:#fff;top:-35px;width:140%;text-align:center;left:-20%;border-radius:5px;direction:ltr}p.error-p,p.success-p{margin:0;font-size:14px;text-align:center}.folder-help-btn span.tooltiptext:after{bottom:-20px;content:"";transform:translateX(-50%);height:10px;width:0;border-width:10px 5px 0;border-style:solid;border-color:#000 transparent transparent;left:50%;position:absolute}p.success-p{color:green}p.error-p{color:#dc3232}html[dir=rtl] .folder-help-btn{left:20px;right:auto}html[dir=rtl] .folder-help-form{left:85px;right:auto}.folder-popup-body h3{line-height:24px}.folder-popup-overlay .form-control input{width:100%;margin:0 0 15px}body.plugins-php .tooltiptext{display:none}.help-form-footer{text-align:center}.help-form-footer p{margin:0;padding:0}.help-form-footer p+p{margin:0;padding:10px 0}
15
  </style>
16
  <div class="folder-help-form">
17
+ <form action="<?php echo esc_url(admin_url('admin-ajax.php')) ?>" method="post" id="folder-help-form">
18
  <div class="folder-help-header">
19
  <b>Gal Dubinski</b> Co-Founder at Premio
20
  </div>
43
  <a class="folder-help-tooltip" href="javascript:;"><img src="<?php echo esc_url(WCP_FOLDER_URL."assets/images/owner.jpg") ?>" alt="<?php esc_html_e("Need help?", 'folders'); ?>" /></a>
44
  <?php
45
  $option = get_option("hide_folders_cta");
46
+ if ($option !== "yes") { ?>
47
  <span class="tooltiptext">Need help?</span>
48
  <?php } ?>
49
  </div>
54
  jQuery(".folder-help-button").text("<?php esc_html_e("Sending Request...") ?>");
55
  formData = jQuery(this).serialize();
56
  jQuery.ajax({
57
+ url: "<?php echo esc_url(admin_url('admin-ajax.php')) ?>",
58
  data: formData,
59
  type: "post",
60
  success: function(responseText){
115
  }
116
  });
117
  });
118
+ </script>
templates/admin/media-cleaning.php CHANGED
@@ -1,7 +1,18 @@
 
 
 
 
 
 
 
1
 
 
 
 
 
2
  <div class="media-clean-box-content">
3
  <div class="media-clean-box-title">
4
- <?php esc_html_e("Scan for unused media","folders") ?>
5
  </div>
6
  <div class="media-clean-box-border"></div>
7
  <div class="m-top">
@@ -9,11 +20,11 @@
9
  <lottie-player src="<?php echo WCP_FOLDER_URL."assets/js/lottie-player.json" ?>" background="transparent" speed="1" style="width: 300px; height: 300px; margin: 0 auto" loop autoplay></lottie-player>
10
  </div>
11
  <div class="media-clean-box-desc">
12
- <?php esc_html_e("Find unused media files which aren't used in your website. An internal trash allows you to make sure everything works properly before deleting the media entries (and files) permanently.","folders") ?>
13
  </div>
14
  <div class="m-bottom">
15
  <a href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" class="media-clean-box-button">
16
- <?php esc_html_e("Upgrade to Folders Pro","folders") ?>
17
  <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
18
  <path fill-rule="evenodd" clip-rule="evenodd" d="M10 18C14.4183 18 18 14.4183 18 10C18 5.58172 14.4183 2 10 2C5.58172 2 2 5.58172 2 10C2 14.4183 5.58172 18 10 18ZM9.5547 7.16795C9.24784 6.96338 8.8533 6.94431 8.52814 7.11833C8.20298 7.29235 8 7.63121 8 8V12C8 12.3688 8.20298 12.7077 8.52814 12.8817C8.8533 13.0557 9.24784 13.0366 9.5547 12.8321L12.5547 10.8321C12.8329 10.6466 13 10.3344 13 10C13 9.66565 12.8329 9.35342 12.5547 9.16795L9.5547 7.16795Z" />
19
  </svg>
@@ -22,4 +33,4 @@
22
  <div class="skip-scan-btn">
23
  <a href="<?php echo admin_url("upload.php?hide_menu=scan-files&nonce=".wp_create_nonce("folders-scan-files")) ?>"><?php esc_html_e("Hide this page from the menu", "folders"); ?></a>
24
  </div>
25
- </div>
1
+ <?php
2
+ /**
3
+ * Admin folders Scan Media
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
 
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+ ?>
13
  <div class="media-clean-box-content">
14
  <div class="media-clean-box-title">
15
+ <?php esc_html_e("Scan for unused media", "folders") ?>
16
  </div>
17
  <div class="media-clean-box-border"></div>
18
  <div class="m-top">
20
  <lottie-player src="<?php echo WCP_FOLDER_URL."assets/js/lottie-player.json" ?>" background="transparent" speed="1" style="width: 300px; height: 300px; margin: 0 auto" loop autoplay></lottie-player>
21
  </div>
22
  <div class="media-clean-box-desc">
23
+ <?php esc_html_e("Find unused media files which aren't used in your website. An internal trash allows you to make sure everything works properly before deleting the media entries (and files) permanently.", "folders") ?>
24
  </div>
25
  <div class="m-bottom">
26
  <a href="<?php echo esc_url($this->getFoldersUpgradeURL()) ?>" class="media-clean-box-button">
27
+ <?php esc_html_e("Upgrade to Folders Pro", "folders") ?>
28
  <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
29
  <path fill-rule="evenodd" clip-rule="evenodd" d="M10 18C14.4183 18 18 14.4183 18 10C18 5.58172 14.4183 2 10 2C5.58172 2 2 5.58172 2 10C2 14.4183 5.58172 18 10 18ZM9.5547 7.16795C9.24784 6.96338 8.8533 6.94431 8.52814 7.11833C8.20298 7.29235 8 7.63121 8 8V12C8 12.3688 8.20298 12.7077 8.52814 12.8817C8.8533 13.0557 9.24784 13.0366 9.5547 12.8321L12.5547 10.8321C12.8329 10.6466 13 10.3344 13 10C13 9.66565 12.8329 9.35342 12.5547 9.16795L9.5547 7.16795Z" />
30
  </svg>
33
  <div class="skip-scan-btn">
34
  <a href="<?php echo admin_url("upload.php?hide_menu=scan-files&nonce=".wp_create_nonce("folders-scan-files")) ?>"><?php esc_html_e("Hide this page from the menu", "folders"); ?></a>
35
  </div>
36
+ </div>
templates/admin/media-replace.php CHANGED
@@ -1,170 +1,185 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
3
-
4
- if (!current_user_can('upload_files'))
5
- wp_die(esc_html__('You do not have permission to upload files.', 'enable-media-replace'));
6
-
7
- global $wpdb;
8
-
9
- $attachment_id = intval($_GET['attachment_id']);
10
- $attachment = get_post($attachment_id);
11
-
12
- $size = 0;
13
- if(isset($attachment->guid)) {
14
- $size = $this->getFileSize($attachment_id);
15
- }
16
- //$url = wp_get_attachment_url($attachment_id); die;
17
- $guid = $attachment->guid;
18
- $url = wp_get_attachment_url($attachment_id);
19
- if(!empty($url)) {
20
- $guid = $url;
21
- }
22
- $guid = explode(".", $guid);
23
- $ext = array_pop($guid);
24
- $image_meta = wp_get_attachment_metadata($attachment_id);
25
- $thumb = wp_get_attachment_image_src($attachment_id, 'thumbnail');
26
- $source_type = get_post_mime_type($attachment_id);
27
- $url = "";
28
- if(isset($thumb[0])) {
29
- $url = $thumb[0];
30
- }
31
- $file_parts = pathinfo($attachment->guid);
32
- $file_name = $file_parts['basename'];
33
-
34
- $customize_folders = get_option("customize_folders");
35
- if(isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
36
- $upgradeURL = admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
37
- } else {
38
- $upgradeURL = admin_url("admin.php?page=folders-upgrade-to-pro");
39
- }
40
- $current_date = date_i18n('d/M/Y H:i', strtotime($attachment->post_date) )
41
-
42
- /*
43
- * Forked from Enable Media Replace
44
- *
45
- * */
46
- ?>
47
- <div class="wrap">
48
- <h2><?php esc_html_e("Replace Media", "folders"); ?></h2>
49
- <form enctype="multipart/form-data" method="POST" action="">
50
- <div class="replace-media-page">
51
- <p><b><?php esc_html_e("Current File", "folders") ?></b>: <?php echo esc_attr($file_name) ?></p>
52
- <p><?php esc_html_e("Upload a new file instead of the current one", "folders") ?></p>
53
- <p><?php printf(__('Maximum file size: <strong>%s</strong>', 'enable-media-replace'), size_format(wp_max_upload_size())) ?></p>
54
- <input type="hidden" name="attachment_id" value="<?php echo esc_attr__($attachment_id) ?>"/>
55
- <input type="hidden" name="ext" id="file_ext" value="<?php echo esc_attr__($ext) ?>"/>
56
- <div class="upload-media-box">
57
-
58
- </div>
59
- <div class="">
60
- <div class="current-image-box">
61
- <div class="file-option"><?php esc_html_e("Current File", "folders") ?></div>
62
- <div class="preview-box">
63
- <?php if (wp_attachment_is('image', $attachment_id)) { ?>
64
- <?php if(!empty($url)) { ?>
65
- <img src="<?php echo esc_url($url) ?>" />
66
- <span class="image-size"><?php echo esc_attr($image_meta['width']." PX x ".$image_meta['height'])." PX" ?></span>
67
- <?php } ?>
68
- <?php } else { ?>
69
- <span class="dashicons dashicons-media-document"></span>
70
- <?php } ?>
71
- </div>
72
- <?php if(!empty($size)) { ?>
73
- <div class="file-size"><a target="_blank" href="<?php echo esc_url($upgradeURL) ?>"><?php esc_html_e("Upgrade to Pro", "folders") ?></a> <?php esc_html_e("to compare file size", "folders") ?></div>
74
- <?php } ?>
75
- </div>
76
- <div class="new-image-box">
77
- <div class="file-option"><?php esc_html_e("New File", "folders") ?></div>
78
- <div class="preview-box">
79
- <div class="container" >
80
- <div class="container" >
81
- <input type="file" name="new_media_file" id="media_file">
82
-
83
- <!-- Drag and Drop container-->
84
- <div class="upload-area" id="upload-file">
85
- <div class="drag-and-drop-title">
86
- <span><?php echo esc_html_e("Click here to upload file", "folders") ?></span>
87
- </div>
88
- <div class="upgrade-btn-box">
89
- <a target="_blank" href="<?php echo esc_url($upgradeURL) ?>"><?php esc_html_e("Upgrade to Pro", "folders") ?></a>
90
- </div>
91
- </div>
92
- </div>
93
- </div>
94
- </div>
95
- <div class="file-size hide-it"><a target="_blank" href="<?php echo esc_url($upgradeURL) ?>"><?php esc_html_e("Upgrade to Pro", "folders") ?></a> <?php esc_html_e("to compare file size", "folders") ?></div>
96
- </div>
97
- <div class="clearfix"></div>
98
- </div>
99
-
100
- <div class="file-type warning replace-message">
101
- <?php esc_html_e("Replacement file is not the same filetype. This might cause unexpected issues", "folders"); ?>
102
- </div>
103
-
104
- <div class="media-bottom-box pro">
105
- <div class="media-bottom-pro">
106
- <div class="media-bottom-box-left">
107
- <div class="media-setting">
108
- <div class="media-title"><?php esc_html_e("Replace Files", "folders") ?></div>
109
- <div class="media-form">
110
- <div class="media-option">
111
- <label for="replace_only_file"><input type="radio" checked name="replacement_option" value="replace_only_file" id="replace_only_file" /> <?php esc_html_e("Replace File Only", "folders") ?></label>
112
- </div>
113
- <div class="media-note">
114
- <?php printf(esc_html__("%s Please upload a file with the same extension (jpg, jpeg, png etc). The file name will remain the same as the file being replaced.", "folders"), "<b>".esc_html__("Note:", "folders")."</b>" ); ?>
115
- </div>
116
- <div class="media-option">
117
- <label for="replace_file_with_name"><input type="radio" name="replacement_option" value="replace_file_with_name" id="replace_file_with_name" /> <?php esc_html_e("Replace File and Update URLs with New File name", "folders") ?></label>
118
- </div>
119
- <div class="media-note">
120
- <?php printf(esc_html__("%s After selecting this option, the new file name will be retained, and all the URLs pointing to the current file will be revised to the new file. If the file URL has been shared on external web pages, the links may not work.", "folders"), "<b>".esc_html__("Warning:", "folders")."</b>"); ?>
121
- </div>
122
- </div>
123
- </div>
124
- </div>
125
- <div class="media-bottom-box-right">
126
- <div class="media-setting">
127
- <div class="media-title"><?php esc_html_e("File Date", "folders") ?></div>
128
- <div class="media-form">
129
- <div class="media-note">
130
- <?php esc_html_e("After swapping the old file with the new one:", "folders"); ?>
131
- </div>
132
- <ul>
133
- <li>
134
- <label for="replace_date"><input type="radio" name="date_options" value="replace_date" id="replace_date" /> <?php esc_html_e("Set the date of upload of the new file", "folders") ?></label>
135
- </li>
136
- <li>
137
- <label for="keep_date"><input type="radio" checked name="date_options" value="keep_date" id="keep_date" /> <?php esc_html_e("Keep the old file's date of the upload", "folders") ?> <small>(<?php echo esc_attr($current_date) ?>)</small></label>
138
- </li>
139
- <li>
140
- <label for="select_custom_date"><input type="radio" name="date_options" value="custom_date" id="select_custom_date" /> <?php esc_html_e("Set a date", "folders") ?></label>
141
- </li>
142
- </ul>
143
- <div class="custom-date" id="custom-date">
144
- <label for="custom_date"><?php esc_html_e("Custom date", "folders"); ?></label>
145
- <span class="inline"><input type="text" class="media-date" name="custom_date" value="<?php echo date("F j, Y") ?>" id="custom_date"></span><span class="inline-block">@</span><span class="inline"><input type="text" name="custom_date_hour" class="media-time" value="<?php echo date("m") ?>" id="custom_date_hour"></span><span class="inline-block">:</span><span class="inline"><input type="text" class="media-time" name="custom_date_min" value="<?php echo date("i") ?>" id="custom_date_min"></span>
146
- </div>
147
- <div class="custom-date" id="custom-path">
148
- <input type="hidden" name="new_folder_option" value="0">
149
- <label for="new_folder_option"><input type="checkbox" id="new_folder_option" name="new_folder_option" value="1"><?php esc_html_e("Put new Upload in Updated Folder", "folders"); ?></label>
150
- <span class="inline"><input type="text" class="media-date" name="new_folder_path" value="<?php echo date("Y/m") ?>" id="new_folder_path"></span>
151
- </div>
152
- </div>
153
- </div>
154
- </div>
155
- <div class="clear"></div>
156
- </div>
157
- <div class="media-bottom-pro-button">
158
- <div class="pro-button">
159
- <a target="_blank" href="<?php echo esc_url($upgradeURL) ?>"><?php esc_html_e("Upgrade to Pro", "folders") ?></a>
160
- </div>
161
- </div>
162
- </div>
163
-
164
- <div class="replace-media-buttons">
165
- <button type="submit" class="button button-primary" disabled><?php echo esc_html_e("Replace File", "folders") ?></button>
166
- <button type="button" class="button button-secondary" onclick="history.back();"><?php echo esc_html_e("Cancel", "folders") ?></button>
167
- </div>
168
- </div>
169
- </form>
170
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin media replace settings
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ if (!current_user_can('upload_files')) {
14
+ wp_die(esc_html__('You do not have permission to upload files.', 'enable-media-replace'));
15
+ }
16
+
17
+ global $wpdb;
18
+
19
+
20
+ $attachment_id = intval(filter_input(INPUT_GET, 'attachment_id'));
21
+ $attachment = get_post($attachment_id);
22
+
23
+ $size = 0;
24
+ if (isset($attachment->guid)) {
25
+ $size = $this->getFileSize($attachment_id);
26
+ }
27
+
28
+ // $url = wp_get_attachment_url($attachment_id); die;
29
+ $guid = $attachment->guid;
30
+ $url = wp_get_attachment_url($attachment_id);
31
+ if (!empty($url)) {
32
+ $guid = $url;
33
+ }
34
+
35
+ $guid = explode(".", $guid);
36
+ $ext = array_pop($guid);
37
+ $image_meta = wp_get_attachment_metadata($attachment_id);
38
+ $thumb = wp_get_attachment_image_src($attachment_id, 'thumbnail');
39
+ $source_type = get_post_mime_type($attachment_id);
40
+ $url = "";
41
+ if (isset($thumb[0])) {
42
+ $url = $thumb[0];
43
+ }
44
+
45
+ $file_parts = pathinfo($attachment->guid);
46
+ $file_name = $file_parts['basename'];
47
+
48
+ $customize_folders = get_option("customize_folders");
49
+ if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
50
+ $upgradeURL = admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
51
+ } else {
52
+ $upgradeURL = admin_url("admin.php?page=folders-upgrade-to-pro");
53
+ }
54
+
55
+ $current_date = date_i18n('d/M/Y H:i', strtotime($attachment->post_date))
56
+
57
+ /*
58
+ * Forked from Enable Media Replace
59
+ *
60
+ * */
61
+ ?>
62
+ <div class="wrap">
63
+ <h2><?php esc_html_e("Replace Media", "folders"); ?></h2>
64
+ <form enctype="multipart/form-data" method="POST" action="<?php echo esc_url($form_action) ?>">
65
+ <div class="replace-media-page">
66
+ <p><b><?php esc_html_e("Current File", "folders") ?></b>: <?php echo esc_attr($file_name) ?></p>
67
+ <p><?php esc_html_e("Upload a new file instead of the current one", "folders") ?></p>
68
+ <p><?php printf(__('Maximum file size: <strong>%s</strong>', 'enable-media-replace'), size_format(wp_max_upload_size())) ?></p>
69
+ <input type="hidden" name="attachment_id" value="<?php echo esc_attr__($attachment_id) ?>"/>
70
+ <input type="hidden" name="ext" id="file_ext" value="<?php echo esc_attr__($ext) ?>"/>
71
+ <div class="upload-media-box">
72
+
73
+ </div>
74
+ <div class="">
75
+ <div class="current-image-box">
76
+ <div class="file-option"><?php esc_html_e("Current File", "folders") ?></div>
77
+ <div class="preview-box">
78
+ <?php if (wp_attachment_is('image', $attachment_id)) { ?>
79
+ <?php if (!empty($url)) { ?>
80
+ <img src="<?php echo esc_url($url) ?>" />
81
+ <span class="image-size"><?php echo esc_attr($image_meta['width']." PX x ".$image_meta['height'])." PX" ?></span>
82
+ <?php } ?>
83
+ <?php } else { ?>
84
+ <span class="dashicons dashicons-media-document"></span>
85
+ <?php } ?>
86
+ </div>
87
+ <?php if (!empty($size)) { ?>
88
+ <div class="file-size"><a target="_blank" href="<?php echo esc_url($upgradeURL) ?>"><?php esc_html_e("Upgrade to Pro", "folders") ?></a> <?php esc_html_e("to compare file size", "folders") ?></div>
89
+ <?php } ?>
90
+ </div>
91
+ <div class="new-image-box">
92
+ <div class="file-option"><?php esc_html_e("New File", "folders") ?></div>
93
+ <div class="preview-box">
94
+ <div class="container" >
95
+ <div class="container" >
96
+ <input type="file" name="new_media_file" id="media_file">
97
+
98
+ <!-- Drag and Drop container-->
99
+ <div class="upload-area" id="upload-file">
100
+ <div class="drag-and-drop-title">
101
+ <span><?php echo esc_html_e("Click here to upload file", "folders") ?></span>
102
+ </div>
103
+ <div class="upgrade-btn-box">
104
+ <a target="_blank" href="<?php echo esc_url($upgradeURL) ?>"><?php esc_html_e("Upgrade to Pro", "folders") ?></a>
105
+ </div>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ </div>
110
+ <div class="file-size hide-it"><a target="_blank" href="<?php echo esc_url($upgradeURL) ?>"><?php esc_html_e("Upgrade to Pro", "folders") ?></a> <?php esc_html_e("to compare file size", "folders") ?></div>
111
+ </div>
112
+ <div class="clearfix"></div>
113
+ </div>
114
+
115
+ <div class="file-type warning replace-message">
116
+ <?php esc_html_e("Replacement file is not the same filetype. This might cause unexpected issues", "folders"); ?>
117
+ </div>
118
+
119
+ <div class="media-bottom-box pro">
120
+ <div class="media-bottom-pro">
121
+ <div class="media-bottom-box-left">
122
+ <div class="media-setting">
123
+ <div class="media-title"><?php esc_html_e("Replace Files", "folders") ?></div>
124
+ <div class="media-form">
125
+ <div class="media-option">
126
+ <label for="replace_only_file"><input type="radio" checked name="replacement_option" value="replace_only_file" id="replace_only_file" /> <?php esc_html_e("Replace File Only", "folders") ?></label>
127
+ </div>
128
+ <div class="media-note">
129
+ <?php printf(esc_html__("%s Please upload a file with the same extension (jpg, jpeg, png etc). The file name will remain the same as the file being replaced.", "folders"), "<b>".esc_html__("Note:", "folders")."</b>"); ?>
130
+ </div>
131
+ <div class="media-option">
132
+ <label for="replace_file_with_name"><input type="radio" name="replacement_option" value="replace_file_with_name" id="replace_file_with_name" /> <?php esc_html_e("Replace File and Update URLs with New File name", "folders") ?></label>
133
+ </div>
134
+ <div class="media-note">
135
+ <?php printf(esc_html__("%s After selecting this option, the new file name will be retained, and all the URLs pointing to the current file will be revised to the new file. If the file URL has been shared on external web pages, the links may not work.", "folders"), "<b>".esc_html__("Warning:", "folders")."</b>"); ?>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ </div>
140
+ <div class="media-bottom-box-right">
141
+ <div class="media-setting">
142
+ <div class="media-title"><?php esc_html_e("File Date", "folders") ?></div>
143
+ <div class="media-form">
144
+ <div class="media-note">
145
+ <?php esc_html_e("After swapping the old file with the new one:", "folders"); ?>
146
+ </div>
147
+ <ul>
148
+ <li>
149
+ <label for="replace_date"><input type="radio" name="date_options" value="replace_date" id="replace_date" /> <?php esc_html_e("Set the date of upload of the new file", "folders") ?></label>
150
+ </li>
151
+ <li>
152
+ <label for="keep_date"><input type="radio" checked name="date_options" value="keep_date" id="keep_date" /> <?php esc_html_e("Keep the old file's date of the upload", "folders") ?> <small>(<?php echo esc_attr($current_date) ?>)</small></label>
153
+ </li>
154
+ <li>
155
+ <label for="select_custom_date"><input type="radio" name="date_options" value="custom_date" id="select_custom_date" /> <?php esc_html_e("Set a date", "folders") ?></label>
156
+ </li>
157
+ </ul>
158
+ <div class="custom-date" id="custom-date">
159
+ <label for="custom_date"><?php esc_html_e("Custom date", "folders"); ?></label>
160
+ <span class="inline"><input type="text" class="media-date" name="custom_date" value="<?php echo date("F j, Y") ?>" id="custom_date"></span><span class="inline-block">@</span><span class="inline"><input type="text" name="custom_date_hour" class="media-time" value="<?php echo date("m") ?>" id="custom_date_hour"></span><span class="inline-block">:</span><span class="inline"><input type="text" class="media-time" name="custom_date_min" value="<?php echo date("i") ?>" id="custom_date_min"></span>
161
+ </div>
162
+ <div class="custom-date" id="custom-path">
163
+ <input type="hidden" name="new_folder_option" value="0">
164
+ <label for="new_folder_option"><input type="checkbox" id="new_folder_option" name="new_folder_option" value="1"><?php esc_html_e("Put new Upload in Updated Folder", "folders"); ?></label>
165
+ <span class="inline"><input type="text" class="media-date" name="new_folder_path" value="<?php echo date("Y/m") ?>" id="new_folder_path"></span>
166
+ </div>
167
+ </div>
168
+ </div>
169
+ </div>
170
+ <div class="clear"></div>
171
+ </div>
172
+ <div class="media-bottom-pro-button">
173
+ <div class="pro-button">
174
+ <a target="_blank" href="<?php echo esc_url($upgradeURL) ?>"><?php esc_html_e("Upgrade to Pro", "folders") ?></a>
175
+ </div>
176
+ </div>
177
+ </div>
178
+
179
+ <div class="replace-media-buttons">
180
+ <button type="submit" class="button button-primary" disabled><?php echo esc_html_e("Replace File", "folders") ?></button>
181
+ <button type="button" class="button button-secondary" onclick="history.back();"><?php echo esc_html_e("Cancel", "folders") ?></button>
182
+ </div>
183
+ </div>
184
+ </form>
185
+ </div>
templates/admin/recommended-plugins.php CHANGED
@@ -1,3 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
  <style>
2
  a.hide-recommended-btn {
3
  background: #1da1f4;
@@ -51,91 +63,95 @@
51
  }
52
  </style>
53
  <?php
54
- wp_enqueue_style( 'wp-jquery-ui-dialog' );
55
- wp_enqueue_script( 'jquery-ui-dialog' );
56
  // You may comment this out IF you're sure the function exists.
57
- require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
58
  remove_all_filters('plugins_api');
59
- $plugins_allowedtags = array(
60
- 'a' => array(
61
- 'href' => array(),
62
- 'title' => array(),
63
- 'target' => array(),
64
- ),
65
- 'abbr' => array( 'title' => array() ),
66
- 'acronym' => array( 'title' => array() ),
67
- 'code' => array(),
68
- 'pre' => array(),
69
- 'em' => array(),
70
- 'strong' => array(),
71
- 'ul' => array(),
72
- 'ol' => array(),
73
- 'li' => array(),
74
- 'p' => array(),
75
- 'br' => array(),
76
- );
77
-
78
- $recommended_plugins = array();
79
- /* Poptin Plugins */
80
  $args = [
81
- 'slug' => 'poptin',
82
  'fields' => [
83
  'short_description' => true,
84
- 'icons' => true,
85
- 'reviews' => false, // excludes all reviews
 
86
  ],
87
  ];
88
- $data = plugins_api( 'plugin_information', $args );
89
- if ( $data && ! is_wp_error( $data ) ) {
90
- $recommended_plugins['poptin'] = $data;
91
  $recommended_plugins['poptin']->name = 'Poptin: Beautiful Pop Ups and Embedded Inline Contact Forms for Your Website';
92
  $recommended_plugins['poptin']->short_description = 'Pop ups and contact forms builder for your website. Get more sales, leads, and subscribers with beautiful popups & inline forms templates, no coding skills required';
93
  }
94
 
95
- /* Chaty Plugins */
96
  $args = [
97
- 'slug' => 'chaty',
98
  'fields' => [
99
  'short_description' => true,
100
- 'icons' => true,
101
- 'reviews' => false, // excludes all reviews
 
102
  ],
103
  ];
104
- $data = plugins_api( 'plugin_information', $args );
105
- if ( $data && ! is_wp_error( $data ) ) {
106
- $recommended_plugins['chaty'] = $data;
107
  $recommended_plugins['chaty']->name = 'Chaty: WhatsApp, Facebook Messenger, and Many Other Chat Buttons For Your Website';
108
  $recommended_plugins['chaty']->short_description = 'Let your visitors contact you via Facebook Messenger, Whatsapp, Telegram, Viber, Email, Phone call, SMS and more with customizable chat & call buttons';
109
  }
110
 
111
- /* mystickyelements Plugins */
112
  $args = [
113
- 'slug' => 'mystickyelements',
114
  'fields' => [
115
  'short_description' => true,
116
- 'icons' => true,
117
- 'reviews' => false, // excludes all reviews
 
118
  ],
119
  ];
120
- $data = plugins_api( 'plugin_information', $args );
121
- if ( $data && ! is_wp_error( $data ) ) {
122
- $recommended_plugins['mystickyelements'] = $data;
123
  $recommended_plugins['mystickyelements']->name = 'All-in-one Floating Contact Form, Call, Chat, and 50+ Social Icon Tabs – My Sticky Elements';
124
  $recommended_plugins['mystickyelements']->short_description = 'Add floating form and tabs on any side of your website to help your visitors contact you and easily find your Facebook page, YouTube channel, open hours';
125
  }
126
 
127
- /* Stars Ttestimonials Plugins */
128
  $args = [
129
- 'slug' => 'stars-testimonials-with-slider-and-masonry-grid',
130
  'fields' => [
131
  'short_description' => true,
132
- 'icons' => true,
133
- 'reviews' => false, // excludes all reviews
 
134
  ],
135
  ];
136
- $data = plugins_api( 'plugin_information', $args );
137
- if ( $data && ! is_wp_error( $data ) ) {
138
- $recommended_plugins['stars-testimonials'] = $data;
139
  $recommended_plugins['stars-testimonials']->name = 'Stars Testimonials: Responsive Testimonials, Social Proof, and Customer Reviews';
140
  $recommended_plugins['stars-testimonials']->short_description = 'Simple but yet powerful testimonial WordPress plugin for your website. Display responsive website testimonials and customer reviews with ease and increase conversion rate';
141
  }
@@ -152,171 +168,171 @@ if ( $data && ! is_wp_error( $data ) ) {
152
  <div class="wp-list-table widefat plugin-install">
153
  <div class="the-list">
154
  <?php
155
- foreach ( (array) $recommended_plugins as $plugin ) {
156
- if ( is_object( $plugin ) ) {
157
  $plugin = (array) $plugin;
158
  }
159
 
160
  // Display the group heading if there is one.
161
- if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) {
162
- if ( isset( $this->groups[ $plugin['group'] ] ) ) {
163
- $group_name = $this->groups[ $plugin['group'] ];
164
- if ( isset( $plugins_group_titles[ $group_name ] ) ) {
165
- $group_name = $plugins_group_titles[ $group_name ];
166
  }
167
  } else {
168
  $group_name = $plugin['group'];
169
  }
170
 
171
  // Starting a new group, close off the divs of the last one.
172
- if ( ! empty( $group ) ) {
173
  echo '</div></div>';
174
  }
175
 
176
- echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>';
177
  // Needs an extra wrapping div for nth-child selectors to work.
178
  echo '<div class="plugin-items">';
179
 
180
  $group = $plugin['group'];
181
- }
182
- $title = wp_kses( $plugin['name'], $plugins_allowedtags );
 
183
 
184
  // Remove any HTML from the description.
185
- $description = strip_tags( $plugin['short_description'] );
186
- $version = wp_kses( $plugin['version'], $plugins_allowedtags );
187
 
188
- $name = strip_tags( $title . ' ' . $version );
189
 
190
- $author = wp_kses( $plugin['author'], $plugins_allowedtags );
191
- if ( ! empty( $author ) ) {
192
- /* translators: %s: Plugin author. */
193
- $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>';
194
  }
195
 
196
- $requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null;
197
- $requires_wp = isset( $plugin['requires'] ) ? $plugin['requires'] : null;
198
-
199
- $compatible_php = is_php_version_compatible( $requires_php );
200
- $compatible_wp = is_wp_version_compatible( $requires_wp );
201
- $tested_wp = ( empty( $plugin['tested'] ) || version_compare( get_bloginfo( 'version' ), $plugin['tested'], '<=' ) );
202
-
203
- $action_links = array();
204
-
205
- if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
206
- $status = install_plugin_install_status( $plugin );
207
-
208
- switch ( $status['status'] ) {
209
- case 'install':
210
- if ( $status['url'] ) {
211
- if ( $compatible_php && $compatible_wp ) {
212
- $action_links[] = sprintf(
213
- '<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
214
- esc_attr( $plugin['slug'] ),
215
- esc_url( $status['url'] ),
216
- /* translators: %s: Plugin name and version. */
217
- esc_attr( sprintf( _x( 'Install %s now', 'plugin' ), $name ) ),
218
- esc_attr( $name ),
219
- __( 'Install Now' )
220
- );
221
- } else {
222
- $action_links[] = sprintf(
223
- '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
224
- _x( 'Cannot Install', 'plugin' )
225
- );
226
- }
227
- }
228
- break;
229
-
230
- case 'update_available':
231
- if ( $status['url'] ) {
232
- if ( $compatible_php && $compatible_wp ) {
233
- $action_links[] = sprintf(
234
- '<a class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
235
- esc_attr( $status['file'] ),
236
- esc_attr( $plugin['slug'] ),
237
- esc_url( $status['url'] ),
238
- /* translators: %s: Plugin name and version. */
239
- esc_attr( sprintf( _x( 'Update %s now', 'plugin' ), $name ) ),
240
- esc_attr( $name ),
241
- __( 'Update Now' )
242
- );
243
- } else {
244
- $action_links[] = sprintf(
245
- '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
246
- _x( 'Cannot Update', 'plugin' )
247
- );
248
- }
249
- }
250
- break;
251
 
252
- case 'latest_installed':
253
- case 'newer_installed':
254
- if ( is_plugin_active( $status['file'] ) ) {
 
 
 
 
255
  $action_links[] = sprintf(
256
- '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
257
- _x( 'Active', 'plugin' )
 
 
 
 
 
258
  );
259
- } elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) {
260
- $button_text = __( 'Activate' );
261
- /* translators: %s: Plugin name. */
262
- $button_label = _x( 'Activate %s', 'plugin' );
263
- $activate_url = add_query_arg(
264
- array(
265
- '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
266
- 'action' => 'activate',
267
- 'plugin' => $status['file'],
268
- ),
269
- network_admin_url( 'plugins.php' )
270
  );
 
 
 
271
 
272
- if ( is_network_admin() ) {
273
- $button_text = __( 'Network Activate' );
274
- /* translators: %s: Plugin name. */
275
- $button_label = _x( 'Network Activate %s', 'plugin' );
276
- $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
277
- }
278
-
279
  $action_links[] = sprintf(
280
- '<a href="%1$s" class="button activate-now" aria-label="%2$s">%3$s</a>',
281
- esc_url( $activate_url ),
282
- esc_attr( sprintf( $button_label, $plugin['name'] ) ),
283
- $button_text
 
 
 
 
284
  );
285
  } else {
286
  $action_links[] = sprintf(
287
  '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
288
- _x( 'Installed', 'plugin' )
289
  );
290
  }
291
- break;
292
- }
293
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
 
295
  $details_link = self_admin_url(
296
- 'plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin['slug'] .
297
- '&amp;TB_iframe=true&amp;width=600&amp;height=550'
298
  );
299
 
300
  $action_links[] = sprintf(
301
  '<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
302
- esc_url( $details_link ),
303
- /* translators: %s: Plugin name and version. */
304
- esc_attr( sprintf( __( 'More information about %s' ), $name ) ),
305
- esc_attr( $name ),
306
- __( 'More Details' )
307
  );
308
 
309
- if ( ! empty( $plugin['icons']['svg'] ) ) {
310
  $plugin_icon_url = $plugin['icons']['svg'];
311
- } elseif ( ! empty( $plugin['icons']['2x'] ) ) {
312
  $plugin_icon_url = $plugin['icons']['2x'];
313
- } elseif ( ! empty( $plugin['icons']['1x'] ) ) {
314
  $plugin_icon_url = $plugin['icons']['1x'];
315
  } else {
316
  $plugin_icon_url = $plugin['icons']['default'];
317
  }
318
 
319
- /**
320
  * Filters the install action links for a plugin.
321
  *
322
  * @since 2.7.0
@@ -324,139 +340,142 @@ if ( $data && ! is_wp_error( $data ) ) {
324
  * @param string[] $action_links An array of plugin action links. Defaults are links to Details and Install Now.
325
  * @param array $plugin The plugin currently being listed.
326
  */
327
- $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin );
328
 
329
- $last_updated_timestamp = strtotime( $plugin['last_updated'] );
330
  ?>
331
- <div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>">
332
  <?php
333
- if ( ! $compatible_php || ! $compatible_wp ) {
334
  echo '<div class="notice inline notice-error notice-alt"><p>';
335
- if ( ! $compatible_php && ! $compatible_wp ) {
336
- _e( 'This plugin doesn&#8217;t work with your versions of WordPress and PHP.' );
337
- if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
338
  printf(
339
- /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
340
- ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
341
- self_admin_url( 'update-core.php' ),
342
- esc_url( wp_get_update_php_url() )
343
  );
344
- wp_update_php_annotation( '</p><p><em>', '</em>' );
345
- } elseif ( current_user_can( 'update_core' ) ) {
346
  printf(
347
- /* translators: %s: URL to WordPress Updates screen. */
348
- ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
349
- self_admin_url( 'update-core.php' )
350
  );
351
- } elseif ( current_user_can( 'update_php' ) ) {
352
  printf(
353
- /* translators: %s: URL to Update PHP page. */
354
- ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
355
- esc_url( wp_get_update_php_url() )
356
  );
357
- wp_update_php_annotation( '</p><p><em>', '</em>' );
358
- }
359
- } elseif ( ! $compatible_wp ) {
360
- _e( 'This plugin doesn&#8217;t work with your version of WordPress.' );
361
- if ( current_user_can( 'update_core' ) ) {
362
  printf(
363
- /* translators: %s: URL to WordPress Updates screen. */
364
- ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
365
- self_admin_url( 'update-core.php' )
366
  );
367
  }
368
- } elseif ( ! $compatible_php ) {
369
- _e( 'This plugin doesn&#8217;t work with your version of PHP.' );
370
- if ( current_user_can( 'update_php' ) ) {
371
  printf(
372
- /* translators: %s: URL to Update PHP page. */
373
- ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
374
- esc_url( wp_get_update_php_url() )
375
  );
376
- wp_update_php_annotation( '</p><p><em>', '</em>' );
377
  }
378
- }
 
379
  echo '</p></div>';
380
- }
381
  ?>
382
  <div class="plugin-card-top">
383
  <div class="name column-name">
384
  <h3>
385
- <a href="<?php echo esc_url( $details_link ); ?>" class="thickbox open-plugin-details-modal">
386
- <?php echo $title; ?>
387
- <img src="<?php echo esc_attr( $plugin_icon_url ); ?>" class="plugin-icon" alt="" />
388
  </a>
389
  </h3>
390
  </div>
391
  <div class="action-links">
392
  <?php
393
- if ( $action_links ) {
394
- echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>';
395
  }
396
  ?>
397
  </div>
398
  <div class="desc column-description">
399
- <p><?php echo $description; ?></p>
400
- <p class="authors"><?php echo $author; ?></p>
401
  </div>
402
  </div>
403
  <div class="plugin-card-bottom">
404
  <div class="vers column-rating">
405
  <?php
406
  wp_star_rating(
407
- array(
408
  'rating' => $plugin['rating'],
409
  'type' => 'percent',
410
  'number' => $plugin['num_ratings'],
411
- )
412
  );
413
  ?>
414
- <span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span>
415
  </div>
416
  <div class="column-updated">
417
- <strong><?php _e( 'Last Updated:' ); ?></strong>
418
  <?php
419
- /* translators: %s: Human-readable time difference. */
420
- printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) );
421
  ?>
422
  </div>
423
  <div class="column-downloaded">
424
  <?php
425
- if ( $plugin['active_installs'] >= 1000000 ) {
426
- $active_installs_millions = floor( $plugin['active_installs'] / 1000000 );
427
  $active_installs_text = sprintf(
428
- /* translators: %s: Number of millions. */
429
- _nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations' ),
430
- number_format_i18n( $active_installs_millions )
431
  );
432
- } elseif ( 0 == $plugin['active_installs'] ) {
433
- $active_installs_text = _x( 'Less Than 10', 'Active plugin installations' );
434
  } else {
435
- $active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+';
436
  }
437
- /* translators: %s: Number of installations. */
438
- printf( __( '%s Active Installations' ), $active_installs_text );
 
439
  ?>
440
  </div>
441
  <div class="column-compatibility">
442
  <?php
443
- if ( ! $tested_wp ) {
444
- echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>';
445
- } elseif ( ! $compatible_wp ) {
446
- echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>';
447
  } else {
448
- echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>';
449
  }
450
  ?>
451
  </div>
452
  </div>
453
  </div>
454
  <?php
455
- } ?>
 
456
  </div>
457
  </div>
458
- <div id="hide-recommeded-plugins" style="display:none;" title="<?php _e('Are you sure?','mystickyelements');?>">
459
- <p><?php _e( "If you hide the recommended plugins page from your menu, it won't appear there again. Are you sure you'd like to do it?", 'mystickyelements');?></p>
460
  </div>
461
 
462
  </div>
1
+ <?php
2
+ /**
3
+ * Premio.io Recommended Plugins
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+ ?>
13
  <style>
14
  a.hide-recommended-btn {
15
  background: #1da1f4;
63
  }
64
  </style>
65
  <?php
66
+ wp_enqueue_style('wp-jquery-ui-dialog');
67
+ wp_enqueue_script('jquery-ui-dialog');
68
  // You may comment this out IF you're sure the function exists.
69
+ require_once ABSPATH.'wp-admin/includes/plugin-install.php';
70
  remove_all_filters('plugins_api');
71
+ $plugins_allowedtags = [
72
+ 'a' => [
73
+ 'href' => [],
74
+ 'title' => [],
75
+ 'target' => [],
76
+ ],
77
+ 'abbr' => [ 'title' => [] ],
78
+ 'acronym' => [ 'title' => [] ],
79
+ 'code' => [],
80
+ 'pre' => [],
81
+ 'em' => [],
82
+ 'strong' => [],
83
+ 'ul' => [],
84
+ 'ol' => [],
85
+ 'li' => [],
86
+ 'p' => [],
87
+ 'br' => [],
88
+ ];
89
+
90
+ $recommended_plugins = [];
91
+ // Poptin Plugins
92
  $args = [
93
+ 'slug' => 'poptin',
94
  'fields' => [
95
  'short_description' => true,
96
+ 'icons' => true,
97
+ 'reviews' => false,
98
+ // excludes all reviews
99
  ],
100
  ];
101
+ $data = plugins_api('plugin_information', $args);
102
+ if ($data && ! is_wp_error($data)) {
103
+ $recommended_plugins['poptin'] = $data;
104
  $recommended_plugins['poptin']->name = 'Poptin: Beautiful Pop Ups and Embedded Inline Contact Forms for Your Website';
105
  $recommended_plugins['poptin']->short_description = 'Pop ups and contact forms builder for your website. Get more sales, leads, and subscribers with beautiful popups & inline forms templates, no coding skills required';
106
  }
107
 
108
+ // Chaty Plugins
109
  $args = [
110
+ 'slug' => 'chaty',
111
  'fields' => [
112
  'short_description' => true,
113
+ 'icons' => true,
114
+ 'reviews' => false,
115
+ // excludes all reviews
116
  ],
117
  ];
118
+ $data = plugins_api('plugin_information', $args);
119
+ if ($data && ! is_wp_error($data)) {
120
+ $recommended_plugins['chaty'] = $data;
121
  $recommended_plugins['chaty']->name = 'Chaty: WhatsApp, Facebook Messenger, and Many Other Chat Buttons For Your Website';
122
  $recommended_plugins['chaty']->short_description = 'Let your visitors contact you via Facebook Messenger, Whatsapp, Telegram, Viber, Email, Phone call, SMS and more with customizable chat & call buttons';
123
  }
124
 
125
+ // mystickyelements Plugins
126
  $args = [
127
+ 'slug' => 'mystickyelements',
128
  'fields' => [
129
  'short_description' => true,
130
+ 'icons' => true,
131
+ 'reviews' => false,
132
+ // excludes all reviews
133
  ],
134
  ];
135
+ $data = plugins_api('plugin_information', $args);
136
+ if ($data && ! is_wp_error($data)) {
137
+ $recommended_plugins['mystickyelements'] = $data;
138
  $recommended_plugins['mystickyelements']->name = 'All-in-one Floating Contact Form, Call, Chat, and 50+ Social Icon Tabs – My Sticky Elements';
139
  $recommended_plugins['mystickyelements']->short_description = 'Add floating form and tabs on any side of your website to help your visitors contact you and easily find your Facebook page, YouTube channel, open hours';
140
  }
141
 
142
+ // Stars Ttestimonials Plugins
143
  $args = [
144
+ 'slug' => 'stars-testimonials-with-slider-and-masonry-grid',
145
  'fields' => [
146
  'short_description' => true,
147
+ 'icons' => true,
148
+ 'reviews' => false,
149
+ // excludes all reviews
150
  ],
151
  ];
152
+ $data = plugins_api('plugin_information', $args);
153
+ if ($data && ! is_wp_error($data)) {
154
+ $recommended_plugins['stars-testimonials'] = $data;
155
  $recommended_plugins['stars-testimonials']->name = 'Stars Testimonials: Responsive Testimonials, Social Proof, and Customer Reviews';
156
  $recommended_plugins['stars-testimonials']->short_description = 'Simple but yet powerful testimonial WordPress plugin for your website. Display responsive website testimonials and customer reviews with ease and increase conversion rate';
157
  }
168
  <div class="wp-list-table widefat plugin-install">
169
  <div class="the-list">
170
  <?php
171
+ foreach ((array) $recommended_plugins as $plugin) {
172
+ if (is_object($plugin)) {
173
  $plugin = (array) $plugin;
174
  }
175
 
176
  // Display the group heading if there is one.
177
+ if (isset($plugin['group']) && $plugin['group'] != $group) {
178
+ if (isset($this->groups[$plugin['group']])) {
179
+ $group_name = $this->groups[$plugin['group']];
180
+ if (isset($plugins_group_titles[$group_name])) {
181
+ $group_name = $plugins_group_titles[$group_name];
182
  }
183
  } else {
184
  $group_name = $plugin['group'];
185
  }
186
 
187
  // Starting a new group, close off the divs of the last one.
188
+ if (! empty($group)) {
189
  echo '</div></div>';
190
  }
191
 
192
+ echo '<div class="plugin-group"><h3>'.esc_html($group_name).'</h3>';
193
  // Needs an extra wrapping div for nth-child selectors to work.
194
  echo '<div class="plugin-items">';
195
 
196
  $group = $plugin['group'];
197
+ }//end if
198
+
199
+ $title = wp_kses($plugin['name'], $plugins_allowedtags);
200
 
201
  // Remove any HTML from the description.
202
+ $description = strip_tags($plugin['short_description']);
203
+ $version = wp_kses($plugin['version'], $plugins_allowedtags);
204
 
205
+ $name = strip_tags($title.' '.$version);
206
 
207
+ $author = wp_kses($plugin['author'], $plugins_allowedtags);
208
+ if (! empty($author)) {
209
+ // translators: %s: Plugin author.
210
+ $author = ' <cite>'.sprintf(__('By %s'), $author).'</cite>';
211
  }
212
 
213
+ $requires_php = isset($plugin['requires_php']) ? $plugin['requires_php'] : null;
214
+ $requires_wp = isset($plugin['requires']) ? $plugin['requires'] : null;
215
+
216
+ $compatible_php = is_php_version_compatible($requires_php);
217
+ $compatible_wp = is_wp_version_compatible($requires_wp);
218
+ $tested_wp = ( empty($plugin['tested']) || version_compare(get_bloginfo('version'), $plugin['tested'], '<=') );
219
+
220
+ $action_links = [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
 
222
+ if (current_user_can('install_plugins') || current_user_can('update_plugins')) {
223
+ $status = install_plugin_install_status($plugin);
224
+
225
+ switch ($status['status']) {
226
+ case 'install':
227
+ if ($status['url']) {
228
+ if ($compatible_php && $compatible_wp) {
229
  $action_links[] = sprintf(
230
+ '<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
231
+ esc_attr($plugin['slug']),
232
+ esc_url($status['url']),
233
+ // translators: %s: Plugin name and version.
234
+ esc_attr(sprintf(_x('Install %s now', 'plugin'), $name)),
235
+ esc_attr($name),
236
+ __('Install Now')
237
  );
238
+ } else {
239
+ $action_links[] = sprintf(
240
+ '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
241
+ _x('Cannot Install', 'plugin')
 
 
 
 
 
 
 
242
  );
243
+ }
244
+ }
245
+ break;
246
 
247
+ case 'update_available':
248
+ if ($status['url']) {
249
+ if ($compatible_php && $compatible_wp) {
 
 
 
 
250
  $action_links[] = sprintf(
251
+ '<a class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
252
+ esc_attr($status['file']),
253
+ esc_attr($plugin['slug']),
254
+ esc_url($status['url']),
255
+ // translators: %s: Plugin name and version.
256
+ esc_attr(sprintf(_x('Update %s now', 'plugin'), $name)),
257
+ esc_attr($name),
258
+ __('Update Now')
259
  );
260
  } else {
261
  $action_links[] = sprintf(
262
  '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
263
+ _x('Cannot Update', 'plugin')
264
  );
265
  }
266
+ }
267
+ break;
268
+
269
+ case 'latest_installed':
270
+ case 'newer_installed':
271
+ if (is_plugin_active($status['file'])) {
272
+ $action_links[] = sprintf(
273
+ '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
274
+ _x('Active', 'plugin')
275
+ );
276
+ } else if (current_user_can('activate_plugin', $status['file'])) {
277
+ $button_text = __('Activate');
278
+ // translators: %s: Plugin name.
279
+ $button_label = _x('Activate %s', 'plugin');
280
+ $activate_url = add_query_arg(
281
+ [
282
+ '_wpnonce' => wp_create_nonce('activate-plugin_'.$status['file']),
283
+ 'action' => 'activate',
284
+ 'plugin' => $status['file'],
285
+ ],
286
+ network_admin_url('plugins.php')
287
+ );
288
+
289
+ if (is_network_admin()) {
290
+ $button_text = __('Network Activate');
291
+ // translators: %s: Plugin name.
292
+ $button_label = _x('Network Activate %s', 'plugin');
293
+ $activate_url = add_query_arg([ 'networkwide' => 1 ], $activate_url);
294
+ }
295
+
296
+ $action_links[] = sprintf(
297
+ '<a href="%1$s" class="button activate-now" aria-label="%2$s">%3$s</a>',
298
+ esc_url($activate_url),
299
+ esc_attr(sprintf($button_label, $plugin['name'])),
300
+ $button_text
301
+ );
302
+ } else {
303
+ $action_links[] = sprintf(
304
+ '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
305
+ _x('Installed', 'plugin')
306
+ );
307
+ }//end if
308
+ break;
309
+ }//end switch
310
+ }//end if
311
 
312
  $details_link = self_admin_url(
313
+ 'plugin-install.php?tab=plugin-information&amp;plugin='.$plugin['slug'].'&amp;TB_iframe=true&amp;width=600&amp;height=550'
 
314
  );
315
 
316
  $action_links[] = sprintf(
317
  '<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
318
+ esc_url($details_link),
319
+ // translators: %s: Plugin name and version.
320
+ esc_attr(sprintf(__('More information about %s'), $name)),
321
+ esc_attr($name),
322
+ __('More Details')
323
  );
324
 
325
+ if (! empty($plugin['icons']['svg'])) {
326
  $plugin_icon_url = $plugin['icons']['svg'];
327
+ } else if (! empty($plugin['icons']['2x'])) {
328
  $plugin_icon_url = $plugin['icons']['2x'];
329
+ } else if (! empty($plugin['icons']['1x'])) {
330
  $plugin_icon_url = $plugin['icons']['1x'];
331
  } else {
332
  $plugin_icon_url = $plugin['icons']['default'];
333
  }
334
 
335
+ /*
336
  * Filters the install action links for a plugin.
337
  *
338
  * @since 2.7.0
340
  * @param string[] $action_links An array of plugin action links. Defaults are links to Details and Install Now.
341
  * @param array $plugin The plugin currently being listed.
342
  */
343
+ $action_links = apply_filters('plugin_install_action_links', $action_links, $plugin);
344
 
345
+ $last_updated_timestamp = strtotime($plugin['last_updated']);
346
  ?>
347
+ <div class="plugin-card plugin-card-<?php echo sanitize_html_class($plugin['slug']); ?>">
348
  <?php
349
+ if (! $compatible_php || ! $compatible_wp) {
350
  echo '<div class="notice inline notice-error notice-alt"><p>';
351
+ if (! $compatible_php && ! $compatible_wp) {
352
+ _e('This plugin doesn&#8217;t work with your versions of WordPress and PHP.');
353
+ if (current_user_can('update_core') && current_user_can('update_php')) {
354
  printf(
355
+ // translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page.
356
+ ' '.__('<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.'),
357
+ self_admin_url('update-core.php'),
358
+ esc_url(wp_get_update_php_url())
359
  );
360
+ wp_update_php_annotation('</p><p><em>', '</em>');
361
+ } else if (current_user_can('update_core')) {
362
  printf(
363
+ // translators: %s: URL to WordPress Updates screen.
364
+ ' '.__('<a href="%s">Please update WordPress</a>.'),
365
+ self_admin_url('update-core.php')
366
  );
367
+ } else if (current_user_can('update_php')) {
368
  printf(
369
+ // translators: %s: URL to Update PHP page.
370
+ ' '.__('<a href="%s">Learn more about updating PHP</a>.'),
371
+ esc_url(wp_get_update_php_url())
372
  );
373
+ wp_update_php_annotation('</p><p><em>', '</em>');
374
+ }//end if
375
+ } else if (! $compatible_wp) {
376
+ _e('This plugin doesn&#8217;t work with your version of WordPress.');
377
+ if (current_user_can('update_core')) {
378
  printf(
379
+ // translators: %s: URL to WordPress Updates screen.
380
+ ' '.__('<a href="%s">Please update WordPress</a>.'),
381
+ self_admin_url('update-core.php')
382
  );
383
  }
384
+ } else if (! $compatible_php) {
385
+ _e('This plugin doesn&#8217;t work with your version of PHP.');
386
+ if (current_user_can('update_php')) {
387
  printf(
388
+ // translators: %s: URL to Update PHP page.
389
+ ' '.__('<a href="%s">Learn more about updating PHP</a>.'),
390
+ esc_url(wp_get_update_php_url())
391
  );
392
+ wp_update_php_annotation('</p><p><em>', '</em>');
393
  }
394
+ }//end if
395
+
396
  echo '</p></div>';
397
+ }//end if
398
  ?>
399
  <div class="plugin-card-top">
400
  <div class="name column-name">
401
  <h3>
402
+ <a href="<?php echo esc_url($details_link); ?>" class="thickbox open-plugin-details-modal">
403
+ <?php echo esc_attr($title); ?>
404
+ <img src="<?php echo esc_attr($plugin_icon_url); ?>" class="plugin-icon" alt="" />
405
  </a>
406
  </h3>
407
  </div>
408
  <div class="action-links">
409
  <?php
410
+ if ($action_links) {
411
+ echo '<ul class="plugin-action-buttons"><li>'.implode('</li><li>', $action_links).'</li></ul>';
412
  }
413
  ?>
414
  </div>
415
  <div class="desc column-description">
416
+ <p><?php echo esc_attr($description); ?></p>
417
+ <p class="authors"><?php echo wp_kses($author, $plugins_allowedtags); ?></p>
418
  </div>
419
  </div>
420
  <div class="plugin-card-bottom">
421
  <div class="vers column-rating">
422
  <?php
423
  wp_star_rating(
424
+ [
425
  'rating' => $plugin['rating'],
426
  'type' => 'percent',
427
  'number' => $plugin['num_ratings'],
428
+ ]
429
  );
430
  ?>
431
+ <span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n($plugin['num_ratings']); ?>)</span>
432
  </div>
433
  <div class="column-updated">
434
+ <strong><?php _e('Last Updated:'); ?></strong>
435
  <?php
436
+ // translators: %s: Human-readable time difference.
437
+ printf(__('%s ago'), human_time_diff($last_updated_timestamp));
438
  ?>
439
  </div>
440
  <div class="column-downloaded">
441
  <?php
442
+ if ($plugin['active_installs'] >= 1000000) {
443
+ $active_installs_millions = floor(($plugin['active_installs'] / 1000000));
444
  $active_installs_text = sprintf(
445
+ // translators: %s: Number of millions.
446
+ _nx('%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations'),
447
+ number_format_i18n($active_installs_millions)
448
  );
449
+ } else if (0 == $plugin['active_installs']) {
450
+ $active_installs_text = _x('Less Than 10', 'Active plugin installations');
451
  } else {
452
+ $active_installs_text = number_format_i18n($plugin['active_installs']).'+';
453
  }
454
+
455
+ // translators: %s: Number of installations.
456
+ printf(__('%s Active Installations'), $active_installs_text);
457
  ?>
458
  </div>
459
  <div class="column-compatibility">
460
  <?php
461
+ if (! $tested_wp) {
462
+ echo '<span class="compatibility-untested">'.__('Untested with your version of WordPress').'</span>';
463
+ } else if (! $compatible_wp) {
464
+ echo '<span class="compatibility-incompatible">'.__('<strong>Incompatible</strong> with your version of WordPress').'</span>';
465
  } else {
466
+ echo '<span class="compatibility-compatible">'.__('<strong>Compatible</strong> with your version of WordPress').'</span>';
467
  }
468
  ?>
469
  </div>
470
  </div>
471
  </div>
472
  <?php
473
+ }//end foreach
474
+ ?>
475
  </div>
476
  </div>
477
+ <div id="hide-recommeded-plugins" style="display:none;" title="<?php _e('Are you sure?', 'mystickyelements');?>">
478
+ <p><?php _e("If you hide the recommended plugins page from your menu, it won't appear there again. Are you sure you'd like to do it?", 'mystickyelements');?></p>
479
  </div>
480
 
481
  </div>
templates/admin/upgrade-table.php CHANGED
@@ -1,8 +1,18 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
2
- $pro_url = "https://go.premio.io/?edd_action=add_to_cart&download_id=687&edd_options[price_id]=";
 
 
 
 
 
 
 
 
 
 
 
3
  ?>
4
- <link href="<?php echo esc_url(WCP_FOLDER_URL."assets/css/select2.min.css?ver=".WCP_FOLDER_VERSION) ?>" type="text/css" rel="stylesheet" />
5
- <link href="<?php echo esc_url(WCP_FOLDER_URL."assets/css/admin-setting.css?ver=".WCP_FOLDER_VERSION) ?>" type="text/css" rel="stylesheet" />
6
  <div class="modal-upgrade upgrade-block" id="folder-modal">
7
  <div class="easy-modal-inner">
8
  <div class="container">
@@ -80,12 +90,12 @@ $pro_url = "https://go.premio.io/?edd_action=add_to_cart&download_id=687&edd_opt
80
  <div class="price-table-bottom">
81
  <div class="custom-dd">
82
  <select class="multiple-options">
83
- <option data-option="1_year" data-header="Renewals for 25% off" data-price="39" value="<?php echo $pro_url ?>22">Updates &amp; support for 1 year</option>
84
- <option data-option="2_year" data-header="For 2 years" data-price="59" value="<?php echo $pro_url ?>23">Updates &amp; support for 2 years</option>
85
- <option data-option="lifetime" data-header="For lifetime" data-price="119" value="<?php echo $pro_url ?>24">Updates &amp; support for lifetime</option>
86
  </select>
87
  </div>
88
- <a class="cart-link" target="_blank" href="<?php echo $pro_url ?>22">Buy now</a>
89
  </div>
90
  <div class="bottom-position"></div>
91
  </div>
@@ -141,9 +151,9 @@ $pro_url = "https://go.premio.io/?edd_action=add_to_cart&download_id=687&edd_opt
141
  <div class="price-table-bottom">
142
  <div class="custom-dd">
143
  <select class="multiple-options">
144
- <option data-option="1_year" data-header="Renewals for 25% off" data-price="89" value="<?php echo $pro_url ?>25">Updates &amp; support for 1 year</option>
145
- <option data-option="2_year" data-header="For 2 years" data-price="139" value="<?php echo $pro_url ?>26">Updates &amp; support for 2 years</option>
146
- <option data-option="lifetime" data-header="For lifetime" data-price="229" value="<?php echo $pro_url ?>27">Updates &amp; support for lifetime</option>
147
  </select>
148
  </div>
149
  <a class="cart-link" target="_blank" href="https://go.premio.io/?edd_action=add_to_cart&amp;download_id=687&amp;edd_options%5Bprice_id%5D=25">Buy now</a>
@@ -209,9 +219,9 @@ $pro_url = "https://go.premio.io/?edd_action=add_to_cart&download_id=687&edd_opt
209
  <div class="price-table-bottom">
210
  <div class="custom-dd">
211
  <select class="multiple-options has-multiple-websites">
212
- <option data-option="1_year" data-header="Renewals for 25% off" data-price="149" value="<?php echo $pro_url ?>28">Updates &amp; support for 1 year</option>
213
- <option data-option="2_year" data-header="For 2 years" data-price="229" value="<?php echo $pro_url ?>29">Updates &amp; support for 2 years</option>
214
- <option data-option="lifetime" data-header="For lifetime" data-price="389" value="<?php echo $pro_url ?>30">Updates &amp; support for lifetime</option>
215
  </select>
216
  </div>
217
  <a class="cart-link" target="_blank" href="https://go.premio.io/?edd_action=add_to_cart&amp;download_id=687&amp;edd_options%5Bprice_id%5D=28">Buy now</a>
@@ -247,7 +257,6 @@ $pro_url = "https://go.premio.io/?edd_action=add_to_cart&download_id=687&edd_opt
247
  </div>
248
  </div>
249
  </div>
250
- <script src="<?php echo esc_url(WCP_FOLDER_URL."assets/js/select2.min.js?ver=".WCP_FOLDER_VERSION) ?>" type="text/javascript" ></script>
251
  <script>
252
  (function (factory) {
253
  "use strict";
@@ -429,4 +438,4 @@ $pro_url = "https://go.premio.io/?edd_action=add_to_cart&download_id=687&edd_opt
429
  }
430
  }
431
  }));
432
- </script>
1
+ <?php
2
+ /**
3
+ * Folders Upgrade to Pro
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ $proURL = "https://go.premio.io/?edd_action=add_to_cart&download_id=687&edd_options[price_id]=";
14
  ?>
15
+
 
16
  <div class="modal-upgrade upgrade-block" id="folder-modal">
17
  <div class="easy-modal-inner">
18
  <div class="container">
90
  <div class="price-table-bottom">
91
  <div class="custom-dd">
92
  <select class="multiple-options">
93
+ <option data-option="1_year" data-header="Renewals for 25% off" data-price="39" value="<?php echo esc_url($proURL) ?>22">Updates &amp; support for 1 year</option>
94
+ <option data-option="2_year" data-header="For 2 years" data-price="59" value="<?php echo esc_url($proURL) ?>23">Updates &amp; support for 2 years</option>
95
+ <option data-option="lifetime" data-header="For lifetime" data-price="119" value="<?php echo esc_url($proURL) ?>24">Updates &amp; support for lifetime</option>
96
  </select>
97
  </div>
98
+ <a class="cart-link" target="_blank" href="<?php echo esc_url($proURL) ?>22">Buy now</a>
99
  </div>
100
  <div class="bottom-position"></div>
101
  </div>
151
  <div class="price-table-bottom">
152
  <div class="custom-dd">
153
  <select class="multiple-options">
154
+ <option data-option="1_year" data-header="Renewals for 25% off" data-price="89" value="<?php echo esc_url($proURL) ?>25">Updates &amp; support for 1 year</option>
155
+ <option data-option="2_year" data-header="For 2 years" data-price="139" value="<?php echo esc_url($proURL) ?>26">Updates &amp; support for 2 years</option>
156
+ <option data-option="lifetime" data-header="For lifetime" data-price="229" value="<?php echo esc_url($proURL) ?>27">Updates &amp; support for lifetime</option>
157
  </select>
158
  </div>
159
  <a class="cart-link" target="_blank" href="https://go.premio.io/?edd_action=add_to_cart&amp;download_id=687&amp;edd_options%5Bprice_id%5D=25">Buy now</a>
219
  <div class="price-table-bottom">
220
  <div class="custom-dd">
221
  <select class="multiple-options has-multiple-websites">
222
+ <option data-option="1_year" data-header="Renewals for 25% off" data-price="149" value="<?php echo esc_url($proURL) ?>28">Updates &amp; support for 1 year</option>
223
+ <option data-option="2_year" data-header="For 2 years" data-price="229" value="<?php echo esc_url($proURL) ?>29">Updates &amp; support for 2 years</option>
224
+ <option data-option="lifetime" data-header="For lifetime" data-price="389" value="<?php echo esc_url($proURL) ?>30">Updates &amp; support for lifetime</option>
225
  </select>
226
  </div>
227
  <a class="cart-link" target="_blank" href="https://go.premio.io/?edd_action=add_to_cart&amp;download_id=687&amp;edd_options%5Bprice_id%5D=28">Buy now</a>
257
  </div>
258
  </div>
259
  </div>
 
260
  <script>
261
  (function (factory) {
262
  "use strict";
438
  }
439
  }
440
  }));
441
+ </script>
templates/admin/upgrade-to-pro.php CHANGED
@@ -1,8 +1,19 @@
1
- <?php if ( ! defined( 'ABSPATH' ) ) exit;
2
- $pro_url = "https://go.premio.io/?edd_action=add_to_cart&download_id=687&edd_options[price_id]=";
 
 
 
 
 
 
 
 
 
 
 
3
  ?>
4
  <div class="wrap">
5
  <div class="key-table">
6
- <?php include_once "upgrade-table.php" ?>
7
  </div>
8
- </div>
1
+ <?php
2
+ /**
3
+ * Folders Upgrade to Pro
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
+ if (! defined('ABSPATH')) {
10
+ exit;
11
+ }
12
+
13
+ $proURL = "https://go.premio.io/?edd_action=add_to_cart&download_id=687&edd_options[price_id]=";
14
  ?>
15
  <div class="wrap">
16
  <div class="key-table">
17
+ <?php require_once "upgrade-table.php" ?>
18
  </div>
19
+ </div>