PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 2.8.2
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v2.8.2
3.1.9 3.1.8 3.1.7 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 trunk 1.3.7 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9 2.9.1 2.9.2
folders / includes / folders.class.php
folders / includes Last commit date
class-affiliate.php 4 years ago class-polylang.php 4 years ago class-review-box.php 4 years ago class-upgrade-box.php 4 years ago class-wpml.php 4 years ago folders.class.php 4 years ago form.class.php 4 years ago media.replace.php 4 years ago plugin.updates.php 4 years ago plugins.class.php 4 years ago tree.class.php 4 years ago
folders.class.php
4902 lines
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');
373 $errorCounter++;
374 } else if (!isset($postData['type']) || empty($postData['type'])) {
375 $response['message'] = esc_html__("Your request is not valid", 'folders');
376 $errorCounter++;
377 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
378 $response['message'] = esc_html__("Your request is not valid", 'folders');
379 $errorCounter++;
380 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
381 $response['message'] = esc_html__("You have not permission to update width", 'folders');
382 $errorCounter++;
383 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
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;
440 } else if (!isset($postData['post_type']) || empty($postData['type'])) {
441 $response['message'] = esc_html__("Your request is not valid", 'folders');
442 $error = 1;
443 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
444 $response['message'] = esc_html__("Your request is not valid", 'folders');
445 $error = 1;
446 } else if ($postData['post_type'] == "page" && !current_user_can("edit_pages")) {
447 $response['message'] = esc_html__("You have not permission to update width", 'folders');
448 $error = 1;
449 } else if ($postData['post_type'] != "page" && !current_user_can("edit_posts")) {
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);
492 if ($folder == "_folder") {
493 $isForFolders = 1;
494 }
495 }
496 }
497 }
498
499 if($isForFolders) {
500 global $wpdb;
501 if (!is_array($terms) && count($terms) < 1) {
502 return $terms;
503 }
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;
523 if (isset($trash_folders[$term->term_taxonomy_id])) {
524 $trash_count = $trash_folders[$term->term_taxonomy_id];
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";
532 } else if ($taxonomy == "folder") {
533 $post_type = "page";
534 } else if ($taxonomy == "media_folder") {
535 $post_type = "attachment";
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);
555 } else {
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 ?>
643 <script>
644 window.location = '<?php echo admin_url("upload.php?post_type=attachment")."&media_folder=".esc_attr($last_status) ?>';
645 </script>
646 <?php
647 exit;
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;
674 }
675 }
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])) {
683 ?>
684 <script>
685 window.location = '<?php echo admin_url("upload.php?post_type=attachment")."&media_folder=".esc_attr($default_folders[$typenow]) ?>';
686 </script>
687 <?php
688 exit;
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')) {
717 $status = filter_input(INPUT_POST, 'status');
718 $email = filter_input(INPUT_POST, 'email');
719 update_option("folder_update_message", 2);
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',
727 'email' => $email,
728 ];
729
730 // Signup Email for Chaty
731 $apiResponse = wp_safe_remote_post($apiURL, ['body' => $apiParams, 'timeout' => 15, 'sslverify' => true]);
732
733 if (is_wp_error($apiResponse)) {
734 wp_safe_remote_post($apiURL, ['body' => $apiParams, 'timeout' => 15, 'sslverify' => false]);
735 }
736
737 $response['status'] = 1;
738 }
739 }//end if
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');
827 $errorCounter++;
828 } else if (!isset($postData['type']) || empty($postData['type'])) {
829 $response['message'] = esc_html__("Your request is not valid", 'folders');
830 $errorCounter++;
831 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
832 $response['message'] = esc_html__("Your request is not valid", 'folders');
833 $errorCounter++;
834 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
835 $response['message'] = esc_html__("You have not permission to update width", 'folders');
836 $errorCounter++;
837 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
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++;
871 } else if (!isset($postData['type']) || empty($postData['type'])) {
872 $response['message'] = esc_html__("Your request is not valid", 'folders');
873 $errorCounter++;
874 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
875 $response['message'] = esc_html__("Your request is not valid", 'folders');
876 $errorCounter++;
877 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
878 $response['message'] = esc_html__("You have not permission to update width", 'folders');
879 $errorCounter++;
880 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
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++;
965 } else if (!isset($postData['type']) || empty($postData['type'])) {
966 $response['message'] = esc_html__("Your request is not valid", 'folders');
967 $errorCounter++;
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
1071 $post_type = $postData['type'];
1072
1073 $ttpsts = $this->get_ttlpst($post_type);
1074
1075 $empty_items = self::get_tempt_posts($post_type);
1076
1077 $post_type = self::get_custom_post_type($post_type);
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'];
1095
1096 $ttpsts = $this->get_ttlpst($post_type);
1097
1098 $empty_items = self::get_tempt_posts($post_type);
1099
1100 $post_type = self::get_custom_post_type($post_type);
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 (
1169 SELECT 1
1170 FROM {$term_table}
1171 INNER JOIN {$term_taxonomy_table}
1172 ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id
1173 WHERE {$term_taxonomy_table}.taxonomy = '%s'
1174 AND {$term_table}.object_id = {$post_table}.ID
1175 )
1176 ) AND {$post_table}.post_type = '%s' AND (({$post_table}.post_status = 'publish' OR {$post_table}.post_status = 'future' OR {$post_table}.post_status = 'draft' OR {$post_table}.post_status = 'private'))";
1177 } else {
1178 $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND (
1179 NOT EXISTS (
1180 SELECT 1
1181 FROM {$term_table}
1182 INNER JOIN {$term_taxonomy_table}
1183 ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id
1184 WHERE {$term_taxonomy_table}.taxonomy = '%s'
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 ?>
1231 <script>
1232 window.location = '<?php echo admin_url("upload.php?post_type=attachment")."&media_folder=".esc_attr($last_status) ?>';
1233 </script>
1234 <?php
1235 exit;
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;
1248 }
1249 }
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])) {
1257 ?>
1258 <script>
1259 window.location = '<?php echo admin_url("upload.php?post_type=attachment")."&media_folder=".esc_attr($default_folders[$typenow]) ?>';
1260 </script>
1261 <?php
1262 exit;
1263 }
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;
1650 }
1651
1652 if ($view_name != 'bar') {
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'])) {
1825 $response['message'] = esc_html__("Your request is not valid", 'folders');
1826 $errorCounter++;
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);
1971 foreach ($folders as $folder) {
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++;
1993 } else if (!isset($postData['type']) || empty($postData['type'])) {
1994 $response['message'] = esc_html__("Your request is not valid", 'folders');
1995 $errorCounter++;
1996 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1997 $response['message'] = esc_html__("Your request is not valid", 'folders');
1998 $errorCounter++;
1999 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
2000 $response['message'] = esc_html__("You have not permission to update width", 'folders');
2001 $errorCounter++;
2002 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
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');
2176 } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
2177 $errorCounter++;
2178 $response['message'] = esc_html__("Your request is not valid", 'folders');
2179 } else if (!isset($postData['type']) || empty($postData['type'])) {
2180 $errorCounter++;
2181 $response['message'] = esc_html__("Your request is not valid", 'folders');
2182 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2183 $response['message'] = esc_html__("Your request is not valid", 'folders');
2184 $errorCounter++;
2185 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
2186 $response['message'] = esc_html__("You have not permission to update folder", 'folders');
2187 $errorCounter++;
2188 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
2189 $response['message'] = esc_html__("You have not permission to update folder", '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++;
2239 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
2240 $errorCounter++;
2241 $response['message'] = esc_html__("Your request is not valid", 'folders');
2242 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2243 $response['message'] = esc_html__("Your request is not valid", '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;
2258 } else {
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++;
2282 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
2283 $errorCounter++;
2284 $response['message'] = esc_html__("Your request is not valid", 'folders');
2285 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2286 $response['message'] = esc_html__("Your request is not valid", '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;
2301 } else {
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++;
2325 } else if (!isset($postData['term_ids']) || empty($postData['term_ids'])) {
2326 $errorCounter++;
2327 $response['message'] = esc_html__("Your request is not valid", 'folders');
2328 } else if (!isset($postData['type']) || empty($postData['type'])) {
2329 $errorCounter++;
2330 $response['message'] = esc_html__("Your request is not valid", 'folders');
2331 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2332 $response['message'] = esc_html__("Your request is not valid", '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++;
2385 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
2386 $response['message'] = esc_html__("Your request is not valid", 'folders');
2387 $errorCounter++;
2388 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2389 $response['message'] = esc_html__("Unable to create folder, Your request is not valid", '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++;
2425 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
2426 $response['message'] = esc_html__("Your request is not valid", 'folders');
2427 $errorCounter++;
2428 } else if (!isset($postData['type']) || empty($postData['type'])) {
2429 $response['message'] = esc_html__("Your request is not valid", 'folders');
2430 $errorCounter++;
2431 } else if (!isset($postData['parent_id'])) {
2432 $response['message'] = esc_html__("Your request is not valid", 'folders');
2433 $errorCounter++;
2434 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2435 $response['message'] = esc_html__("Your request is not valid", '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++;
2471 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2472 $response['message'] = esc_html__("Your request is not valid", 'folders');
2473 $errorCounter++;
2474 } else if (!current_user_can("manage_categories")) {
2475 $response['message'] = esc_html__("Your request is not valid", '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');
2511 $errorCounter++;
2512 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
2513 $error = esc_html__("Your request is not valid", 'folders');
2514 $errorCounter++;
2515 } else if (!isset($postData['type']) || empty($postData['type'])) {
2516 $error = esc_html__("Your request is not valid", 'folders');
2517 $errorCounter++;
2518 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2519 $response['message'] = esc_html__("Your request is not valid", '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++;
2567 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
2568 $error = esc_html__("Your request is not valid", 'folders');
2569 $errorCounter++;
2570 } else if (!isset($postData['type']) || empty($postData['type'])) {
2571 $error = esc_html__("Your request is not valid", 'folders');
2572 $errorCounter++;
2573 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2574 $error = esc_html__("Unable to delete folder, Your request is not valid", '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++;
2631 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
2632 $error = esc_html__("Unable to rename folder, Your request is not valid", 'folders');
2633 $errorCounter++;
2634 } else if (!isset($postData['name']) || empty($postData['name'])) {
2635 $error = esc_html__("Folder name can no be empty", 'folders');
2636 $errorCounter++;
2637 } else if (!isset($postData['type']) || empty($postData['type'])) {
2638 $error = esc_html__("Your request is not valid", 'folders');
2639 $errorCounter++;
2640 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2641 $error = esc_html__("Unable to rename folder, Your request is not valid", '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('À', 'Á', 'Â', 'Ã', 'Ä', '�
2683 ', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', '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', '?', '?', '?', '?', '?', '?');
2684 $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');
2685 return strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), str_replace($a, $b, $str)));
2686 }
2687
2688 public static function sanitize_options($value, $type = "") {
2689 $value = stripslashes($value);
2690 if($type == "int") {
2691 $value = filter_var($value, FILTER_SANITIZE_NUMBER_INT);
2692 } else if($type == "email") {
2693 $value = filter_var($value, FILTER_SANITIZE_EMAIL);
2694 } else {
2695 $value = filter_var($value, FILTER_SANITIZE_STRING);
2696 }
2697 return $value;
2698 }
2699
2700 public function wcp_add_new_folder()
2701 {
2702 $response = array();
2703 $response['status'] = 0;
2704 $response['error'] = 0;
2705 $response['login'] = 1;
2706 $response['data'] = array();
2707 $response['message'] = "";
2708 $response['message2'] = "";
2709 $postData = $_REQUEST;
2710 $errorCounter = 0;
2711 $error= "";
2712 if (!current_user_can("manage_categories")) {
2713 $error = esc_html__("You have not permission to add folder", 'folders');
2714 $errorCounter++;
2715 } else if (!isset($postData['name']) || empty($postData['name'])) {
2716 $error = esc_html__("Folder name can no be empty", 'folders');
2717 $errorCounter++;
2718 } else if (!isset($postData['type']) || empty($postData['type'])) {
2719 $error = esc_html__("Your request is not valid", 'folders');
2720 $errorCounter++;
2721 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2722 $response['login'] = 0;
2723 $error = esc_html__("Unable to create folder, Your request is not valid", 'folders');
2724 $errorCounter++;
2725 } else {
2726 $type = self::sanitize_options($postData['type']);
2727 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
2728 $response['login'] = 0;
2729 $error = esc_html__("Unable to create folder, Your request is not valid", 'folders');
2730 $errorCounter++;
2731 }
2732 }
2733 if ($errorCounter == 0) {
2734 $parent = isset($postData['parent_id']) && !empty($postData['parent_id']) ? $postData['parent_id'] : 0;
2735 $parent_menu = isset($postData['parent_menu']) && !empty($postData['parent_menu']) ? $postData['parent_menu'] : 0;
2736 $parent_ids = isset($postData['parent_ids']) && !empty($postData['parent_ids']) ? $postData['parent_ids'] : 0;
2737 $parent = self::sanitize_options($parent);
2738 $type = self::sanitize_options($postData['type']);
2739 $folder_type = self::get_custom_post_type($type);
2740 $term_name = self::sanitize_options($postData['name']);
2741 $term = term_exists($term_name, $folder_type, $parent);
2742 $term_id = 0;
2743 if (!(0 !== $term && null !== $term)) {
2744 $folders = $postData['name'];
2745 $folders = explode(",", $folders);
2746 $foldersArray = array();
2747 $order = isset($postData['order']) ? $postData['order'] : 0;
2748 $order = self::sanitize_options($order);
2749
2750 $is_active = 1;
2751 $total_folders = -1;
2752
2753 if(!$is_active) {
2754 if (($total_folders + count($folders)) > 10) {
2755 $response['status'] = -1;
2756 echo json_encode($response);
2757 wp_die();
2758 }
2759 }
2760 foreach ($folders as $key => $folder) {
2761 $folder = trim($folder);
2762 $slug = self::create_slug_from_string($folder) . "-" . time();
2763
2764 $result = wp_insert_term(
2765 urldecode($folder), // the term
2766 $folder_type, // the taxonomy
2767 array(
2768 'parent' => $parent,
2769 'slug' => $slug
2770 )
2771 );
2772 if (!empty($result)) {
2773 $term_id = $result['term_id'];
2774 $total_folders++;
2775 $response['id'] = $result['term_id'];
2776 $response['status'] = 1;
2777 $term = get_term($result['term_id'], $folder_type);
2778 $order = $order + $key;
2779 $term_nonce = wp_create_nonce('wcp_folder_term_' . $term->term_id);
2780
2781 $folder_item = array();
2782 $folder_item['parent_id'] = $parent;
2783 $folder_item['slug'] = $term->slug;
2784 $folder_item['nonce'] = $term_nonce;
2785 $folder_item['term_id'] = $result['term_id'];
2786 $folder_item['title'] = $folder;
2787 $folder_item['parent_id'] = empty($postData['parent_id']) ? "0" : $postData['parent_id'];
2788 $folder_item['is_sticky'] = 0;
2789 $folder_item['is_high'] = 0;
2790
2791 update_term_meta($result['term_id'], "wcp_custom_order", $order);
2792 if ($parent != 0) {
2793 update_term_meta($parent, "is_active", 1);
2794 }
2795
2796 if (isset($postData['is_duplicate']) && $postData['is_duplicate'] == true) {
2797 if (isset($postData['duplicate_from']) && !empty($postData['duplicate_from'])) {
2798 $term_id = $postData['duplicate_from'];
2799
2800 $term_data = get_term($term_id, $folder_type);
2801 if (!empty($term_data)) {
2802 $is_sticky = get_term_meta($term_id, "is_folder_sticky", true);
2803
2804 if ($is_sticky == 1) {
2805 add_term_meta($term->term_id, "is_folder_sticky", 1);
2806 $folder_item['is_sticky'] = 1;
2807 }
2808
2809 $status = get_term_meta($term_id, "is_highlighted", true);
2810 if ($status == 1) {
2811 add_term_meta($term->term_id, "is_highlighted", 1);
2812 $folder_item['is_high'] = 1;
2813 }
2814
2815 $postArray = get_posts(
2816 array(
2817 'posts_per_page' => -1,
2818 'post_type' => $type,
2819 'tax_query' => array(
2820 array(
2821 'taxonomy' => $folder_type,
2822 'field' => 'term_id',
2823 'terms' => $term_id,
2824 )
2825 )
2826 )
2827 );
2828 if (!empty($postArray)) {
2829 foreach ($postArray as $p) {
2830 wp_set_post_terms($p->ID, $term->term_id, $folder_type, true);
2831 }
2832 }
2833 }
2834 }
2835 }
2836
2837 if($parent_menu && !empty($parent_ids)) {
2838 $order = isset($postData['order']) ? $postData['order'] : 0;
2839 $parent_ids = trim($parent_ids, ",");
2840 $parent_ids = explode(",", $parent_ids);
2841 $folder_order = 0;
2842 $parents = "";
2843 if(is_array($parent_ids) && count($parent_ids)>0) {
2844 foreach ($parent_ids as $key=>$value) {
2845 if($value != "#") {
2846 delete_term_meta($value, "wcp_custom_order");
2847 add_term_meta( $value, "wcp_custom_order", $folder_order );
2848 } else if(!empty($term_id)) {
2849 delete_term_meta($term_id, "wcp_custom_order");
2850 add_term_meta( $term_id, "wcp_custom_order", $folder_order );
2851 }
2852 $folder_order++;
2853 }
2854 }
2855 }
2856
2857 $foldersArray[] = $folder_item;
2858 }
2859
2860 if (!empty($foldersArray)) {
2861 $response['is_key_active'] = $is_active;
2862 $response['folders'] = $total_folders;
2863 $response['parent_id'] = empty($parent) ? "#" : $parent;
2864
2865 $response['status'] = 1;
2866 $response['data'] = $foldersArray;
2867 }
2868 }
2869 } else {
2870 $response['error'] = 1;
2871 $response['message'] = esc_html__("Folder name already exists", 'folders');
2872 }
2873 } else {
2874 $response['error'] = 1;
2875 $response['message'] = $error;
2876 }
2877 echo json_encode($response);
2878 wp_die();
2879 }
2880
2881 public function is_for_this_post_type($post_type)
2882 {
2883 $post_types = get_option('folders_settings');
2884 $post_types = is_array($post_types)?$post_types:array();
2885 return in_array($post_type, $post_types);
2886 }
2887
2888 public function is_active_for_screen()
2889 {
2890 global $typenow, $current_screen;
2891
2892 $postData = filter_input_array(INPUT_POST);
2893
2894 global $current_screen;
2895
2896 if (self::is_for_this_post_type($typenow) && ('edit' == $current_screen->base || 'upload' == $current_screen->base)) {
2897 return true;
2898 }
2899
2900 $post_types = get_option('folders_settings');
2901 $post_types = is_array($post_types)?$post_types:array();
2902
2903 if(empty($typenow) && (isset($current_screen->base) && 'upload' == $current_screen->base)) {
2904 $typenow = "attachment";
2905 if (self::is_for_this_post_type($typenow)) {
2906 return true;
2907 }
2908 }
2909 return false;
2910 }
2911
2912 public function is_add_update_screen()
2913 {
2914 global $current_screen;
2915 $current_type = $current_screen->base;
2916 $action = $current_screen->action;
2917 $post_types = get_option('folders_settings');
2918 $post_types = is_array($post_types)?$post_types:array();
2919 global $typenow;
2920 if (in_array($current_type, $post_types) && in_array($action, array("add", ""))) {
2921 $license_data = self::get_license_key_data();
2922
2923 $is_active = 1;
2924 $folders = -1;
2925 $response['folders'] = $folders;
2926 $response['is_key_active'] = $is_active;
2927 }
2928 }
2929
2930 public static function get_custom_post_type($post_type)
2931 {
2932 if ($post_type == "post") {
2933 return "post_folder";
2934 } else if ($post_type == "page") {
2935 return "folder";
2936 } else if ($post_type == "attachment") {
2937 return "media_folder";
2938 }
2939 return $post_type . '_folder';
2940 }
2941
2942 public function admin_footer()
2943 {
2944 if (self::is_active_for_screen()) {
2945 global $typenow;
2946
2947 self::set_default_values_if_not_exists();
2948
2949 $ttpsts = self::get_ttlpst($typenow);
2950
2951 $ttemp = self::get_tempt_posts($typenow);
2952
2953 $folder_type = self::get_custom_post_type($typenow);
2954 /* Do not change: Free/Pro Class name change */
2955 $tree_data = WCP_Tree::get_full_tree_data($folder_type);
2956 $terms_data = $tree_data['string'];
2957 $sticky_string = $tree_data['sticky_string'];
2958 $terms_html = WCP_Tree::get_option_data_for_select($folder_type);
2959 $form_html = WCP_Forms::get_form_html($terms_html);
2960 include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "admin-content.php";
2961 }
2962
2963 global $pagenow;
2964 if ( 'plugins.php' !== $pagenow ) {
2965
2966 } else {
2967 if (current_user_can('manage_options')) {
2968 include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "folder-deactivate-form.php";
2969 }
2970 }
2971 }
2972
2973 public function get_ttlpst($post_type = "")
2974 {
2975 global $typenow;
2976 if (empty($post_type)) {
2977 $post_type = $typenow;
2978 }
2979 $item_count = null;
2980 if(has_filter("premio_folder_all_categorized_items")) {
2981 $item_count = apply_filters("premio_folder_all_categorized_items", $post_type);
2982 }
2983 if($item_count === null) {
2984 if ($post_type == "attachment") {
2985 $item_count = wp_count_posts($post_type)->inherit;
2986 } else {
2987 $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;
2988 }
2989 }
2990 return $item_count;
2991 }
2992
2993 public function autoload()
2994 {
2995 $files = array(
2996 'WCP_Tree_View' => WCP_DS . "includes" . WCP_DS . "tree.class.php",
2997 'WCP_Form_View' => WCP_DS . "includes" . WCP_DS . "form.class.php",
2998 'WCP_Folder_WPML' => WCP_DS . "includes" . WCP_DS . "class-wpml.php",
2999 'WCP_Folder_PolyLang' => WCP_DS . "includes" . WCP_DS . "class-polylang.php",
3000 );
3001
3002 foreach ($files as $file) {
3003 if (file_exists(dirname(dirname(__FILE__)) . $file)) {
3004 include_once dirname(dirname(__FILE__)) . $file;
3005 }
3006 }
3007 }
3008
3009 public function create_folder_terms()
3010 {
3011 $options = get_option('folders_settings');
3012 $options = is_array($options)?$options:array();
3013 $old_plugin_status = 0;
3014 $posts = array();
3015 if (!empty($options)) {
3016 foreach ($options as $option) {
3017 if (!(strpos($option, 'folder4') === false) && $old_plugin_status == 0) {
3018 $old_plugin_status = 1;
3019 }
3020 if (in_array($option, array("page", "post", "attachment"))) {
3021 $posts[] = str_replace("folder4", "", $option);
3022 } else {
3023 $posts[] = $option;
3024 }
3025 }
3026 if(!empty($posts)) {
3027 update_option('folders_settings', $posts);
3028 }
3029 }
3030 if ($old_plugin_status == 1) {
3031 update_option("folders_show_in_menu", "on");
3032 $old_plugin_var = get_option("folder_old_plugin_status");
3033 if (empty($old_plugin_var) || $old_plugin_var == null) {
3034 update_option("folder_old_plugin_status", "1");
3035 }
3036 }
3037 $posts = get_option('folders_settings');
3038 if (!empty($posts)) {
3039 foreach ($posts as $post_type) {
3040 $labels = array(
3041 'name' => esc_html__('Folders', 'folders'),
3042 'singular_name' => esc_html__('Folder', 'folders'),
3043 'all_items' => esc_html__('All Folders', 'folders'),
3044 'edit_item' => esc_html__('Edit Folder', 'folders'),
3045 'update_item' => esc_html__('Update Folder', 'folders'),
3046 'add_new_item' => esc_html__('Add New Folder', 'folders'),
3047 'new_item_name' => esc_html__('Add folder name', 'folders'),
3048 'menu_name' => esc_html__('Folders', 'folders'),
3049 'search_items' => esc_html__('Search Folders', 'folders'),
3050 'parent_item' => esc_html__('Parent Folder', 'folders'),
3051 );
3052
3053 $args = array(
3054 'label' => esc_html__('Folder', 'folders'),
3055 'labels' => $labels,
3056 'show_tagcloud' => false,
3057 'hierarchical' => true,
3058 'public' => false,
3059 'show_ui' => true,
3060 'show_in_menu' => false,
3061 'show_in_rest' => true,
3062 'show_admin_column' => true,
3063 'update_count_callback' => '_update_post_term_count',
3064 // 'update_count_callback' => '_update_generic_term_count',
3065 'query_var' => true,
3066 'rewrite' => false,
3067 'capabilities' => array(
3068 'manage_terms' => 'manage_categories',
3069 'edit_terms' => 'manage_categories',
3070 'delete_terms' => 'manage_categories',
3071 'assign_terms' => 'manage_categories'
3072 )
3073 );
3074
3075 $folder_post_type = self::get_custom_post_type($post_type);
3076
3077 register_taxonomy(
3078 $folder_post_type,
3079 $post_type,
3080 $args
3081 );
3082 }
3083 }
3084
3085 $postData = filter_input_array(INPUT_POST);
3086
3087 if(current_user_can("manage_categories") && isset($postData['folder_nonce'])) {
3088 if(wp_verify_nonce($postData['folder_nonce'], "folder_settings")) {
3089 if (isset($postData['folders_show_in_menu']) && !empty($postData['folders_show_in_menu'])) {
3090 $show_menu = "off";
3091 if ($postData['folders_show_in_menu'] == "on") {
3092 $show_menu = "on";
3093 }
3094 update_option("folders_show_in_menu", $show_menu);
3095 }
3096
3097 if (isset($postData['folders_settings1'])) {
3098 $posts = array();
3099 if (isset($postData['folders_settings']) && is_array($postData['folders_settings'])) {
3100 foreach ($postData['folders_settings'] as $key => $val) {
3101 $posts[] = $val;
3102 }
3103 }
3104 update_option("folders_settings", $posts);
3105 }
3106
3107 if (isset($_POST['folders_settings1'])) {
3108 $posts = array();
3109 if (isset($_POST['default_folders']) && is_array($_POST['default_folders'])) {
3110 foreach ($_POST['default_folders'] as $key => $val) {
3111 $posts[$key] = $val;
3112 }
3113 }
3114 update_option("default_folders", $posts);
3115 }
3116
3117 if (isset($_POST['customize_folders'])) {
3118 $posts = array();
3119 if (isset($_POST['customize_folders']) && is_array($_POST['customize_folders'])) {
3120 foreach ($_POST['customize_folders'] as $key => $val) {
3121 $posts[$key] = $val;
3122 }
3123 }
3124 update_option("customize_folders", $posts);
3125 }
3126
3127 $setting_page = $this->getFolderSettingsURL();
3128 if(!empty($setting_page)) {
3129 $page = isset($_POST['tab_page'])?$_POST['tab_page']:"";
3130 $type = filter_input(INPUT_GET, 'setting_page', FILTER_SANITIZE_STRING);
3131 $type = empty($type)?"":"&setting_page=".$type;
3132 $setting_page = $setting_page.$type;
3133 if(!empty($page)) {
3134 $setting_page .= "&setting_page=".$page;
3135 }
3136 wp_redirect($setting_page."&note=1");
3137 exit;
3138 } else if(isset($_POST['folder_page']) && !empty($_POST['folder_page'])) {
3139 wp_redirect($_POST['folder_page']);
3140 exit;
3141 }
3142 }
3143 }
3144
3145 // $old_version = get_option("folder_old_plugin_status");
3146 // if($old_version !== false && $old_version == 1) {
3147 // $tlfs = get_option("folder_old_plugin_folder_status");
3148 // if($tlfs === false) {
3149 // $total = self::ttl_fldrs();
3150 // if($total <= 10) {
3151 // $total = 10;
3152 // };
3153 // update_option("folder_old_plugin_folder_status", $total);
3154 // self::$folders = $total;
3155 // } else {
3156 // self::$folders = $tlfs;
3157 // }
3158 // }
3159 //
3160 // $tlfs = get_option("folder_old_plugin_folder_status");
3161 // if($tlfs === false) {
3162 // self::$folders = 10;
3163 // } else {
3164 // self::$folders = $tlfs;
3165 // }
3166 }
3167
3168 function searchForId($id, $menu)
3169 {
3170 if ($menu) {
3171 foreach ($menu as $key => $val) {
3172 if (array_key_exists(2, $val)) {
3173 $stripVal = explode('=', $val[2]);
3174 }
3175 if (array_key_exists(1, $stripVal)) {
3176 $stripVal = $stripVal[1];
3177 }
3178 if ($stripVal === $id) {
3179 return $key;
3180 }
3181 }
3182 }
3183 }
3184
3185 function create_menu_for_folders()
3186 {
3187 global $menu;
3188 self::check_and_set_post_type();
3189
3190 $folder_types = get_option("folders_settings");
3191 if (empty($folder_types)) {
3192 return;
3193 }
3194
3195 foreach ($folder_types as $type) {
3196 $itemKey = self::searchForId($type, $menu);
3197 switch (true) {
3198 case ($type == 'attachment'):
3199 $itemKey = 10;
3200 $edit = 'upload.php';
3201 break;
3202 case ($type === 'post'):
3203 $edit = 'edit.php';
3204 $itemKey = 5;
3205 break;
3206 default:
3207 $edit = 'edit.php';
3208 break;
3209 }
3210
3211 $folder = $type == 'attachment' ? 'media' : $type;
3212 $upper = $type == 'attachment' ? 'Media' : ucwords(str_replace(array('-', '_'), ' ', $type));
3213 if ($type == 'page') {
3214 $tax_slug = 'folder';
3215 } else {
3216 $tax_slug = $folder . '_folder';
3217 }
3218
3219
3220 $hide_empty = true;
3221 if ($type == 'attachment') {
3222 $hide_empty = false;
3223 add_menu_page('Media Folders', 'Media Folders', 'publish_pages', "{$edit}?post_type=attachment&media_folder=", false, 'dashicons-portfolio', "{$itemKey}.5");
3224 } else {
3225 add_menu_page($upper . ' Folders', "{$upper} Folders", 'publish_pages', "{$edit}?post_type={$type}&type=folder", false, 'dashicons-portfolio', "{$itemKey}.5");
3226 }
3227
3228 $terms = get_terms($tax_slug, array(
3229 'hide_empty' => $hide_empty,
3230 'parent' => 0,
3231 'orderby' => 'meta_value_num',
3232 'order' => 'ASC',
3233 'hierarchical' => false,
3234 'meta_query' => [[
3235 'key' => 'wcp_custom_order',
3236 'type' => 'NUMERIC',
3237 ]]
3238 )
3239 );
3240
3241 if ($terms) {
3242 foreach ($terms as $term) {
3243 if(isset($term->trash_count) && !empty($term->trash_count)) {
3244 if ($type == 'attachment') {
3245 add_submenu_page("{$edit}?type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type=attachment&media_folder={$term->slug}", false);
3246 } else {
3247 add_submenu_page("{$edit}?post_type={$type}&type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type={$type}&{$tax_slug}={$term->slug}", false);
3248 }
3249 }
3250 }
3251 }
3252 }
3253 }
3254
3255 function folders_admin_styles($page)
3256 {
3257 if (self::is_active_for_screen()) {
3258 wp_enqueue_style('wcp-folders-fa', plugin_dir_url(dirname(__FILE__)) . 'assets/css/folder-icon.css', array(), WCP_FOLDER_VERSION);
3259 wp_enqueue_style('wcp-folders-admin', plugin_dir_url(dirname(__FILE__)) . 'assets/css/design.min.css', array(), WCP_FOLDER_VERSION);
3260 wp_enqueue_style('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)) . 'assets/css/jstree.min.css', array(), WCP_FOLDER_VERSION);
3261 wp_enqueue_style('wcp-folders-mcustomscrollbar', WCP_FOLDER_URL . 'assets/css/jquery.mcustomscrollbar.min.css', array(),WCP_FOLDER_VERSION);
3262 wp_enqueue_style('wcp-folders-css', plugin_dir_url(dirname(__FILE__)) . 'assets/css/folders.css', array(), WCP_FOLDER_VERSION);
3263 }
3264 if($page == "media_page_folders-media-cleaning") {
3265 wp_enqueue_style('wcp-folders-media', plugin_dir_url(dirname(__FILE__)) . 'assets/css/media-clean.css', array(), WCP_FOLDER_VERSION);
3266 }
3267 wp_register_style('wcp-css-handle', false);
3268 wp_enqueue_style('wcp-css-handle');
3269 $css = "
3270 .wcp-folder-upgrade-button {color: #FF5983; font-weight: bold; display: inline-block;border: solid 1px #FF5983;border-radius: 4px;padding: 0 5px;}
3271 ";
3272 if (self::is_active_for_screen()) {
3273 global $typenow;
3274 $width = get_option("wcp_dynamic_width_for_" . $typenow);
3275 $width = esc_attr($width);
3276 $width = intval($width);
3277 $width = empty($width)||!is_numeric($width)?280:$width;
3278 if($width > 1200) {
3279 $width = 280;
3280 }
3281 $width = intval($width);
3282 $display_status = "wcp_dynamic_display_status_" . $typenow;
3283 $display_status = get_option($display_status);
3284 if($display_status != "hide") {
3285 if (!empty($width) && is_numeric($width)) {
3286 if (function_exists('is_rtl') && is_rtl()) {
3287 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:" . ($width + 20) . "px}";
3288 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}";
3289 } else {
3290 $css .= "body.wp-admin #wpcontent {padding-left:" . ($width + 20) . "px}";
3291 }
3292 }
3293 } else {
3294 if (function_exists('is_rtl') && is_rtl()) {
3295 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:20px}";
3296 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}";
3297 } else {
3298 $css .= "body.wp-admin #wpcontent {padding-left:20px}";
3299 }
3300 }
3301 if (!empty($width) && is_numeric($width)) {
3302 if($width > 1200) {
3303 $width = 280;
3304 }
3305 $width = intval($width);
3306 $css .= ".wcp-content {width: {$width}px}";
3307 }
3308 global $typenow;
3309 $post_type = self::get_custom_post_type($typenow);
3310 $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; }}";
3311 }
3312 wp_add_inline_style('wcp-css-handle', $css);
3313
3314 if (self::is_active_for_screen()) {
3315 global $typenow;
3316 add_filter('views_edit-' . $typenow, array($this, 'wcp_check_for_child_folders'));
3317 }
3318 }
3319
3320 function wcp_check_for_child_folders($content)
3321 {
3322 $termId = 0;
3323 global $typenow;
3324 $post_type = self::get_custom_post_type($typenow);
3325 if (isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
3326 $term = $_GET[$post_type];
3327 $term = get_term_by("slug", $term, $post_type);
3328 if (!empty($term)) {
3329 $termId = $term->term_id;
3330 }
3331 }
3332 $terms = get_terms($post_type, array(
3333 'hide_empty' => false,
3334 'parent' => $termId,
3335 'orderby' => 'meta_value_num',
3336 'order' => 'ASC',
3337 'hierarchical' => false,
3338 'update_count_callback' => '_update_generic_term_count',
3339 'meta_query' => [[
3340 'key' => 'wcp_custom_order',
3341 'type' => 'NUMERIC',
3342 ]]
3343 ));
3344 $optionName = "wcp_folder_display_status_" . $typenow;
3345 $optionValue = get_option($optionName);
3346 $class = (!empty($optionValue) && $optionValue == "hide")?"":"active";
3347 $customize_folders = get_option('customize_folders');
3348 $show_in_page = isset($customize_folders['show_in_page'])?$customize_folders['show_in_page']:"hide";
3349 if(empty($show_in_page)) {
3350 $show_in_page = "hide";
3351 }
3352 if($show_in_page == "show") {
3353 echo '<div class="tree-structure-content ' . $class . '"><div class="tree-structure" id="list-folder-' . $termId . '" data-id="' . $termId . '">';
3354 echo '<ul>';
3355 foreach ($terms as $term) {
3356 $status = get_term_meta($term->term_id, "is_highlighted", true);
3357 ?>
3358 <li class="grid-view" data-id="<?php echo esc_attr($term->term_id) ?>" id="folder_<?php echo esc_attr($term->term_id) ?>">
3359 <div class="folder-item is-folder" data-id="<?php echo esc_attr($term->term_id) ?>">
3360 <a title='<?php echo esc_attr($term->name) ?>' id="folder_view_<?php echo esc_attr($term->term_id) ?>"
3361 class="folder-view <?php echo ($status == 1) ? "is-high" : "" ?>"
3362 data-id="<?php echo esc_attr($term->term_id) ?>">
3363 <span class="folder item-name"><span id="wcp_folder_text_<?php echo esc_attr($term->term_id) ?>"
3364 class="folder-title"><?php echo esc_attr($term->name) ?></span></span>
3365 <!--<span class="folder-option"></span>-->
3366 </a>
3367 </div>
3368 </li>
3369 <?php
3370 }
3371 echo '</ul>';
3372 echo '<div class="clear clearfix"></div>';
3373 echo '</div>';
3374 echo '<div class="folders-toggle-button"><span></span></div>';
3375 echo '</div>';
3376 }
3377 if(!empty($content) && is_array($content)) {
3378 echo '<ul class="subsubsub">';
3379 foreach($content as $k=>$v) {
3380 echo "<li class='{$k}'>{$v}</li>";
3381 }
3382 echo '</ul>';
3383 }
3384 }
3385
3386 function folders_admin_scripts($hook)
3387 {
3388 if (self::is_active_for_screen()) {
3389
3390 remove_filter("terms_clauses", "TO_apply_order_filter");
3391
3392 global $typenow;
3393 /* Free/Pro Version change */
3394 wp_dequeue_script("jquery-jstree");
3395 wp_enqueue_script('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)) . 'assets/js/jstree.min.js', array('jquery'), WCP_FOLDER_VERSION);
3396 wp_enqueue_script('wcp-folders-mcustomscrollbar', plugin_dir_url(dirname(__FILE__)) . 'assets/js/jquery.mcustomscrollbar.min.js', array(), WCP_FOLDER_VERSION);
3397 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);
3398 wp_enqueue_script('wcp-jquery-touch', plugin_dir_url(dirname(__FILE__)) . 'assets/js/jquery.ui.touch-punch.min.js', array('jquery'), WCP_FOLDER_VERSION);
3399
3400 $post_type = self::get_custom_post_type($typenow);
3401
3402 if ($typenow == "attachment") {
3403 $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
3404 } else {
3405 $admin_url = admin_url("edit.php?post_type=" . $typenow);
3406 if (isset($_GET['s']) && !empty($_GET['s'])) {
3407 $admin_url .= "&s=" . $_GET['s'];
3408 }
3409 $admin_url .= "&{$post_type}=";
3410 }
3411
3412 $current_url = $admin_url;
3413 if(isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
3414 $current_url .= $_GET[$post_type];
3415 }
3416
3417
3418 $is_active = 1;
3419 $folders = -1;
3420 /* For free: upgrade URL, for Pro: Register Key URL */
3421 $register_url = $this->getFoldersUpgradeURL();
3422
3423 $is_rtl = 0;
3424 if ( function_exists( 'is_rtl' ) && is_rtl() ) {
3425 $is_rtl = 1;
3426 }
3427
3428 $can_manage_folder = current_user_can("manage_categories")?1:0;
3429 $width = get_option("wcp_dynamic_width_for_" . $typenow);
3430 $width = intval($width);
3431 $width = empty($width)||!is_numeric($width)?280:$width;
3432 if($width > 1200) {
3433 $width = 280;
3434 }
3435 $post_type = self::get_custom_post_type($typenow);
3436 $taxonomy_status = 0;
3437 $selected_taxonomy = "";
3438 if(!isset($_GET[$post_type]) || empty($_GET[$post_type])) {
3439 $taxonomy_status = 1;
3440 } else if(isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
3441 $selected_taxonomy = $_GET[$post_type];
3442
3443 $term = get_term_by('slug', $selected_taxonomy, $post_type);
3444 if (!empty($term) && is_object($term)) {
3445 $selected_taxonomy = $term->term_id;
3446 } else {
3447 $selected_taxonomy = "";
3448 $selected_taxonomy = "";
3449 }
3450 }
3451 $customize_folders = get_option('customize_folders');
3452 $show_in_page = isset($customize_folders['show_in_page'])?$customize_folders['show_in_page']:"hide";
3453 if(empty($show_in_page)) {
3454 $show_in_page = "hide";
3455 }
3456 $taxonomies = self::get_terms_hierarchical($post_type);
3457 $use_folder_undo = !isset($customize_folders['use_folder_undo'])?"yes":$customize_folders['use_folder_undo'];
3458 $defaultTimeout = !isset($customize_folders['default_timeout'])?5:intval($customize_folders['default_timeout']);
3459 if(empty($defaultTimeout) || !is_numeric($defaultTimeout) || $defaultTimeout < 0) {
3460 $defaultTimeout = 5;
3461 }
3462 $defaultTimeout = $defaultTimeout*1000;
3463
3464 $folder_settings = array();
3465 foreach($taxonomies as $taxonomy) {
3466 $is_sticky = get_term_meta($taxonomy->term_id, "is_folder_sticky", true);
3467 $is_high = get_term_meta($taxonomy->term_id, "is_highlighted", true);
3468 $folder_settings[] = array(
3469 'folder_id' => $taxonomy->term_id,
3470 'is_sticky' => intval($is_sticky),
3471 'is_high' => intval($is_high),
3472 'nonce' => wp_create_nonce('wcp_folder_term_'.$taxonomy->term_id),
3473 'is_deleted' => 0,
3474 'slug' => $taxonomy->slug,
3475 'folder_count' => intval($taxonomy->trash_count)
3476 );
3477 }
3478
3479
3480
3481 $default_folders = get_option("default_folders");
3482 $default_folder = "";
3483 if(isset($default_folders["attachment"])) {
3484 $default_folder = $default_folders["attachment"];
3485 }
3486 $use_shortcuts = !isset($customize_folders['use_shortcuts'])?"yes":$customize_folders['use_shortcuts'];
3487
3488 $response['terms'] = $taxonomies;
3489 $currentPage = (isset($_GET['paged']) && !empty($_GET['paged']) && is_numeric($_GET['paged']) && $_GET['paged'] > 0)?$_GET['paged']:1;
3490 $hasStars = self::check_for_setting("has_stars", "general");
3491 $hasChild = self::check_for_setting("has_child", "general");
3492 $hasChild = empty($hasChild)?0:1;
3493 $hasStars = empty($hasStars)?0:1;
3494 wp_localize_script('wcp-folders-custom', 'wcp_settings', array(
3495 'ajax_url' => admin_url('admin-ajax.php'),
3496 'upgrade_url' => $this->getFoldersUpgradeURL(),
3497 'post_type' => $typenow,
3498 'page_url' => $admin_url,
3499 'current_url' => $current_url,
3500 'ajax_image' => plugin_dir_url(dirname(__FILE__)) . "assets/images/ajax-loader.gif",
3501 'is_key_active' => $is_active,
3502 'folders' => $folders,
3503 'register_url' => $register_url,
3504 'isRTL' => $is_rtl,
3505 'nonce' => wp_create_nonce('wcp_folder_nonce_'.$typenow),
3506 'can_manage_folder' => $can_manage_folder,
3507 'folder_width' => $width,
3508 'taxonomy_status' => $taxonomy_status,
3509 'selected_taxonomy' => $selected_taxonomy,
3510 'show_in_page' => $show_in_page,
3511 'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png',
3512 'taxonomies' => $taxonomies,
3513 'folder_settings' => $folder_settings,
3514 'hasStars' => $hasStars,
3515 'hasChildren' => $hasChild,
3516 'currentPage' => $currentPage,
3517 'useFolderUndo' => $use_folder_undo,
3518 'defaultTimeout' => $defaultTimeout,
3519 'default_folder' => $default_folder,
3520 'use_shortcuts' => $use_shortcuts
3521 ));
3522 } else {
3523 self::is_add_update_screen();
3524 }
3525
3526 if($hook == "media-new.php") {
3527 if(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
3528 wp_enqueue_style( 'folders-media', WCP_FOLDER_URL . 'assets/css/new-media.css' );
3529 $is_active = 1;
3530 $folders = -1;
3531
3532 $hasStars = self::check_for_setting("has_stars", "general");
3533 $hasChild = self::check_for_setting("has_child", "general");
3534 $hasChild = empty($hasChild)?0:1;
3535 $hasStars = empty($hasStars)?0:1;
3536
3537 wp_enqueue_script('wcp-folders-add-new-media', plugin_dir_url(dirname(__FILE__)) . 'assets/js/new-media.js', array('jquery'), WCP_FOLDER_VERSION);
3538 wp_localize_script( 'wcp-folders-add-new-media', 'folders_media_options', array(
3539 'terms' => self::get_terms_hierarchical('media_folder'),
3540 'taxonomy' => get_taxonomy('media_folder'),
3541 'ajax_url' => admin_url("admin-ajax.php"),
3542 'activate_url' => $this->getFoldersUpgradeURL(),
3543 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
3544 'is_key_active' => $is_active,
3545 'folders' => $folders,
3546 'hasStars' => $hasStars,
3547 'hasChildren' => $hasChild
3548 ));
3549 }
3550 }
3551 }
3552
3553 public function plugin_action_links($links)
3554 {
3555 array_unshift($links, '<a href="' . admin_url("admin.php?page=wcp_folders_settings") . '" >' . esc_html__('Settings', 'folders') . '</a>');
3556 $links['need_help'] = '<a target="_blank" href="https://premio.io/help/folders/?utm_source=pluginspage" >'.__( 'Need help?', 'folders').'</a>';
3557
3558 /* PRO link for only for FREE*/
3559 $links['pro'] = '<a class="wcp-folder-upgrade-button" href="'.$this->getFoldersUpgradeURL().'" >'.__( 'Upgrade', 'folders').'</a>';
3560 return $links;
3561 }
3562
3563 public static function get_instance()
3564 {
3565 if (empty(self::$instance)) {
3566 /* Do not change Class name here */
3567 self::$instance = new WCP_Folders();
3568 }
3569 return self::$instance;
3570 }
3571
3572 public function check_and_set_post_type() {
3573 $options = get_option('folders_settings');
3574 $old_plugin_status = 0;
3575 $post_array = array();
3576 if (!empty($options) && is_array($options)) {
3577 foreach ($options as $key=>$val) {
3578 if (!(strpos($key, 'folders4') === false) && $old_plugin_status == 0) {
3579 $old_plugin_status = 1;
3580 }
3581 if (in_array($key, array("folders4page", "folders4post", "folders4attachment"))) {
3582 $post_array[] = str_replace("folders4", "", $key);
3583 }
3584 }
3585 } else {
3586 $post_array = array("page", "post", "attachment");
3587 }
3588 if ($old_plugin_status == 1) {
3589 update_option("folders_show_in_menu", "on");
3590 $old_plugin_var = get_option("folder_old_plugin_status");
3591 if (empty($old_plugin_var) || $old_plugin_var == null) {
3592 update_option("folder_old_plugin_status", "1");
3593 }
3594 update_option('folders_settings', $post_array);
3595 self::set_default_values_if_not_exists();
3596 }
3597 if (!empty($post_array) && get_option('folders_settings') === false) {
3598 update_option('folders_settings', $post_array);
3599 update_option("folders_show_in_menu", "off");
3600 }
3601 }
3602
3603 public static function activate()
3604 {
3605 premio_folders_plugin_check_for_setting();
3606 $folder_setting = get_option("folders_settings");
3607 if($folder_setting === false) {
3608 add_option("wcp_folder_version_267", 1);
3609 }
3610 update_option("folders_show_in_menu", "off");
3611 $option = get_option("folder_redirect_status");
3612 if($option === false) {
3613 add_option("folder_intro_box", "show");
3614 }
3615 update_option("folder_redirect_status", 1);
3616 }
3617
3618 public static function deactivate() {
3619 $customize_folders = get_option('customize_folders');
3620 $DS = DIRECTORY_SEPARATOR;
3621 $dirName = ABSPATH . "wp-content{$DS}plugins{$DS}folders-pro{$DS}";
3622 $is_pro = get_option("folders_pro_is_in_process");
3623 if(!is_dir($dirName) && $is_pro === false && isset($customize_folders['remove_folders_when_removed']) && $customize_folders['remove_folders_when_removed'] == "on") {
3624 self::$folders = 0;
3625 self::remove_folder_by_taxonomy("media_folder");
3626 self::remove_folder_by_taxonomy("folder");
3627 self::remove_folder_by_taxonomy("post_folder");
3628 $post_types = get_post_types(array(), 'objects');
3629 $post_array = array("page", "post", "attachment");
3630 foreach ($post_types as $post_type) {
3631 if (!in_array($post_type->name, $post_array)) {
3632 self::remove_folder_by_taxonomy($post_type->name . '_folder');
3633 }
3634 }
3635 delete_option('customize_folders');
3636 delete_option('default_folders');
3637 delete_option('folders_show_in_menu');
3638 delete_option('folder_redirect_status');
3639 delete_option('folders_settings');
3640 delete_option('premio_folder_options');
3641 delete_option('folders_settings_updated');
3642 }
3643 }
3644
3645 function folders_register_settings()
3646 {
3647 register_setting('folders_settings', 'folders_settings1', 'folders_settings_validate');
3648 register_setting('default_folders', 'default_folders');
3649 register_setting('customize_folders', 'customize_folders');
3650
3651 self::check_and_set_post_type();
3652
3653 $getData = filter_input_array(INPUT_GET);
3654 if(isset($getData['hide_menu']) && $getData['hide_menu'] == "scan-files" && isset($getData['nonce'])) {
3655 if(current_user_can('manage_options')) {
3656 $nonce = $getData['nonce'];
3657 if(wp_verify_nonce($nonce, "folders-scan-files")) {
3658 $customize_folders = get_option('customize_folders');
3659 $customize_folders['folders_media_cleaning'] = "no";
3660 update_option("customize_folders", $customize_folders);
3661 wp_redirect(admin_url("upload.php"));
3662 exit;
3663 }
3664 }
3665 }
3666
3667 $option = get_option("folder_redirect_status");
3668 if ($option == 1) {
3669 update_option("folder_redirect_status", 2);
3670 wp_redirect(admin_url("admin.php?page=wcp_folders_settings"));
3671 exit;
3672 }
3673 }
3674
3675 function getFoldersUpgradeURL() {
3676 $customize_folders = get_option("customize_folders");
3677 if(isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
3678 return admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
3679 } else {
3680 return admin_url("admin.php?page=folders-upgrade-to-pro");
3681 }
3682 }
3683
3684 function getFolderSettingsURL() {
3685 $customize_folders = get_option("customize_folders");
3686 if(isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
3687 return admin_url("options-general.php?page=wcp_folders_settings");
3688 } else {
3689 return admin_url("admin.php?page=wcp_folders_settings");
3690 }
3691 }
3692
3693 function isFoldersInSettings() {
3694 $customize_folders = get_option("customize_folders");
3695 if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
3696 return true;
3697 }
3698 return false;
3699 }
3700
3701 function wcp_manage_columns_head($defaults, $d = "")
3702 {
3703 global $typenow;
3704 $type = $typenow;
3705 if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
3706 $type = self::sanitize_options($_REQUEST['post_type']);
3707 }
3708
3709 $options = get_option("folders_settings");
3710 if (is_array($options) && in_array($type, $options)) {
3711 $columns = array(
3712 '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>',
3713 ) + $defaults;
3714 return $columns;
3715 }
3716 return $defaults;
3717 }
3718
3719 function wcp_manage_columns_content($column_name, $post_ID)
3720 {
3721 $postIDs = self::$postIds;
3722 if(!is_array($postIDs)) {
3723 $postIDs = array();
3724 }
3725 if(!in_array($post_ID, $postIDs)) {
3726 $postIDs[] = $post_ID;
3727 self::$postIds = $postIDs;
3728 global $typenow;
3729 $type = $typenow;
3730 if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
3731 $type = self::sanitize_options($_REQUEST['post_type']);
3732 }
3733
3734 $options = get_option("folders_settings");
3735 if (is_array($options) && in_array($type, $options)) {
3736 if ($column_name == 'wcp_move') {
3737 $title = get_the_title();
3738 if (strlen($title) > 20) {
3739 $title = substr($title, 0, 20) . "...";
3740 }
3741 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>";
3742 }
3743 }
3744 }
3745 }
3746
3747 function taxonomy_archive_exclude_children($query)
3748 {
3749 $options = get_option("folders_settings");
3750 if (!empty($options)) {
3751 $taxonomy_slugs = array();
3752 foreach ($options as $option) {
3753 $taxonomy_slugs[] = self::get_custom_post_type($option);
3754 }
3755 if (!empty($taxonomy_slugs)) {
3756 $i = 0;
3757 foreach ($query->tax_query->queries as $tax_query_item) {
3758 if (empty($taxonomy_slugs) || (isset($tax_query_item['taxonomy']) && in_array($tax_query_item['taxonomy'], $taxonomy_slugs))) {
3759 $query->tax_query->queries[$i]['include_children'] = 0;
3760 }
3761 }
3762 }
3763 }
3764 }
3765
3766 public function admin_menu() {
3767 $customize_folders = get_option("customize_folders");
3768 if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
3769 add_options_page(
3770 esc_html__('Folders Settings', 'folders'),
3771 esc_html__('Folders Settings', 'folders'),
3772 'manage_options',
3773 'wcp_folders_settings',
3774 array($this, 'wcp_folders_settings')
3775 );
3776 } else {
3777 $menu_slug = 'wcp_folders_settings';
3778
3779 // Add menu item for settings page
3780 $page_title = esc_html__('Folders', 'folders');
3781 $menu_title = esc_html__('Folders Settings', 'folders');
3782 $capability = 'manage_options';
3783 $callback = array($this, "wcp_folders_settings");
3784 $icon_url = 'dashicons-category';
3785 $position = 99;
3786 add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $position);
3787
3788 $getData = filter_input_array(INPUT_GET);
3789 if(isset($getData['hide_folder_recommended_plugin']) && isset($getData['nonce'])) {
3790 if(current_user_can('manage_options')) {
3791 $nonce = $getData['nonce'];
3792 if(wp_verify_nonce($nonce, "folder_recommended_plugin")) {
3793 update_option('hide_folder_recommended_plugin',"1");
3794 }
3795 }
3796 }
3797
3798 $recommended_plugin = get_option("hide_folder_recommended_plugin");
3799 if($recommended_plugin === false) {
3800 add_submenu_page(
3801 $menu_slug,
3802 esc_html__('Recommended Plugins', 'folders'),
3803 esc_html__('Recommended Plugins', 'folders'),
3804 'manage_options',
3805 'recommended-folder-plugins',
3806 array($this, 'recommended_plugins')
3807 );
3808 }
3809
3810 /* Do not Change Free/Pro Change for menu */
3811 add_submenu_page(
3812 $menu_slug,
3813 esc_html__('Upgrade to Pro', 'folders'),
3814 esc_html__('Upgrade to Pro', 'folders'),
3815 'manage_options',
3816 'folders-upgrade-to-pro',
3817 array($this, 'wcp_folders_upgrade_or_register')
3818 );
3819
3820 /* Add menu for media cleaning */
3821 $show_in_page = !isset($customize_folders['folders_media_cleaning'])?"yes":$customize_folders['folders_media_cleaning'];
3822
3823 if($show_in_page == "yes") {
3824 add_submenu_page(
3825 "upload.php",
3826 esc_html__('Media Cleaning', 'folders'),
3827 esc_html__('Media Cleaning', 'folders'),
3828 'manage_options',
3829 'folders-media-cleaning',
3830 array($this, 'wcp_folders_media_cleaning')
3831 );
3832 }
3833 }
3834
3835 self::check_and_set_post_type();
3836
3837 $show_menu = get_option("folders_show_in_menu", true);
3838 if ($show_menu == "on") {
3839 self::create_menu_for_folders();
3840 }
3841 }
3842
3843 public function wcp_folders_media_cleaning() {
3844 include_once dirname(dirname(__FILE__)) . "/templates/admin/media-cleaning.php";
3845 }
3846
3847 public function recommended_plugins() {
3848 include_once dirname(dirname(__FILE__)) . "/templates/admin/recommended-plugins.php";
3849 }
3850
3851 public function wcp_folders_upgrade_or_register()
3852 {
3853 self::set_default_values_if_not_exists();
3854 include_once dirname(dirname(__FILE__)) . "/templates/admin/upgrade-to-pro.php";
3855 }
3856
3857 public function wcp_folders_settings()
3858 {
3859 self::set_default_values_if_not_exists();
3860 /* Only in Free, Get Folders update confirmation popup */
3861 $is_shown = get_option("folder_update_message");
3862 if($is_shown === false) {
3863 include_once dirname(dirname(__FILE__)) . "/templates/admin/update.php";
3864 } else {
3865 $options = get_option('folders_settings');
3866 $options = (empty($options) || !is_array($options)) ? array() : $options;
3867 $post_types = get_post_types(array('public' => true), 'objects');
3868 $terms_data = array();
3869 foreach ($post_types as $post_type) {
3870 if (in_array($post_type->name, $options)) {
3871 $term = $post_type->name;
3872 $term = self::get_custom_post_type($term);
3873 $categories = self::get_terms_hierarchical($term);
3874 $terms_data[$post_type->name] = $categories;
3875 } else {
3876 $terms_data[$post_type->name] = array();
3877 }
3878 }
3879 $fonts = self::get_font_list();
3880
3881 $plugins = new WCP_Folder_Plugins();
3882 $plugin_info = $plugins->get_plugin_information();
3883 $is_plugin_exists = $plugins->is_exists;
3884 $settingURL = $this->getFolderSettingsURL();
3885 $setting_page = isset($_GET['setting_page'])?$_GET['setting_page']:"folder-settings";
3886 $setting_page = in_array($setting_page, array("folder-settings", "customize-folders", "folders-import", "upgrade-to-pro", "folders-by-user"))?$setting_page:"folder-settings";
3887 $isInSettings = $this->isFoldersInSettings();
3888
3889 include_once dirname(dirname(__FILE__)) . "/templates/admin/general-settings.php";
3890
3891 $option = get_option("folder_intro_box");
3892 if($option == "show") {
3893 include_once dirname(dirname(__FILE__)) . "/templates/admin/folder-popup.php";
3894 }
3895 }
3896 }
3897
3898 public static function get_font_list(){
3899 return array(
3900 // System fonts.
3901 'Default' => 'Default',
3902 "System Stack" => 'Default',
3903 'Arial' => 'Default',
3904 'Tahoma' => 'Default',
3905 'Verdana' => 'Default',
3906 'Helvetica' => 'Default',
3907 'Times New Roman' => 'Default',
3908 'Trebuchet MS' => 'Default',
3909 'Georgia' => 'Default',
3910
3911 // Google Fonts (last update: 23/10/2018).
3912 'ABeeZee' => 'Google Fonts',
3913 'Abel' => 'Google Fonts',
3914 'Abhaya Libre' => 'Google Fonts',
3915 'Abril Fatface' => 'Google Fonts',
3916 'Aclonica' => 'Google Fonts',
3917 'Acme' => 'Google Fonts',
3918 'Actor' => 'Google Fonts',
3919 'Adamina' => 'Google Fonts',
3920 'Advent Pro' => 'Google Fonts',
3921 'Aguafina Script' => 'Google Fonts',
3922 'Akronim' => 'Google Fonts',
3923 'Aladin' => 'Google Fonts',
3924 'Aldrich' => 'Google Fonts',
3925 'Alef' => 'Google Fonts',
3926 'Alef Hebrew' => 'Google Fonts', // Hack for Google Early Access.
3927 'Alegreya' => 'Google Fonts',
3928 'Alegreya SC' => 'Google Fonts',
3929 'Alegreya Sans' => 'Google Fonts',
3930 'Alegreya Sans SC' => 'Google Fonts',
3931 'Alex Brush' => 'Google Fonts',
3932 'Alfa Slab One' => 'Google Fonts',
3933 'Alice' => 'Google Fonts',
3934 'Alike' => 'Google Fonts',
3935 'Alike Angular' => 'Google Fonts',
3936 'Allan' => 'Google Fonts',
3937 'Allerta' => 'Google Fonts',
3938 'Allerta Stencil' => 'Google Fonts',
3939 'Allura' => 'Google Fonts',
3940 'Almendra' => 'Google Fonts',
3941 'Almendra Display' => 'Google Fonts',
3942 'Almendra SC' => 'Google Fonts',
3943 'Amarante' => 'Google Fonts',
3944 'Amaranth' => 'Google Fonts',
3945 'Amatic SC' => 'Google Fonts',
3946 'Amethysta' => 'Google Fonts',
3947 'Amiko' => 'Google Fonts',
3948 'Amiri' => 'Google Fonts',
3949 'Amita' => 'Google Fonts',
3950 'Anaheim' => 'Google Fonts',
3951 'Andada' => 'Google Fonts',
3952 'Andika' => 'Google Fonts',
3953 'Angkor' => 'Google Fonts',
3954 'Annie Use Your Telescope' => 'Google Fonts',
3955 'Anonymous Pro' => 'Google Fonts',
3956 'Antic' => 'Google Fonts',
3957 'Antic Didone' => 'Google Fonts',
3958 'Antic Slab' => 'Google Fonts',
3959 'Anton' => 'Google Fonts',
3960 'Arapey' => 'Google Fonts',
3961 'Arbutus' => 'Google Fonts',
3962 'Arbutus Slab' => 'Google Fonts',
3963 'Architects Daughter' => 'Google Fonts',
3964 'Archivo' => 'Google Fonts',
3965 'Archivo Black' => 'Google Fonts',
3966 'Archivo Narrow' => 'Google Fonts',
3967 'Aref Ruqaa' => 'Google Fonts',
3968 'Arima Madurai' => 'Google Fonts',
3969 'Arimo' => 'Google Fonts',
3970 'Arizonia' => 'Google Fonts',
3971 'Armata' => 'Google Fonts',
3972 'Arsenal' => 'Google Fonts',
3973 'Artifika' => 'Google Fonts',
3974 'Arvo' => 'Google Fonts',
3975 'Arya' => 'Google Fonts',
3976 'Asap' => 'Google Fonts',
3977 'Asap Condensed' => 'Google Fonts',
3978 'Asar' => 'Google Fonts',
3979 'Asset' => 'Google Fonts',
3980 'Assistant' => 'Google Fonts',
3981 'Astloch' => 'Google Fonts',
3982 'Asul' => 'Google Fonts',
3983 'Athiti' => 'Google Fonts',
3984 'Atma' => 'Google Fonts',
3985 'Atomic Age' => 'Google Fonts',
3986 'Aubrey' => 'Google Fonts',
3987 'Audiowide' => 'Google Fonts',
3988 'Autour One' => 'Google Fonts',
3989 'Average' => 'Google Fonts',
3990 'Average Sans' => 'Google Fonts',
3991 'Averia Gruesa Libre' => 'Google Fonts',
3992 'Averia Libre' => 'Google Fonts',
3993 'Averia Sans Libre' => 'Google Fonts',
3994 'Averia Serif Libre' => 'Google Fonts',
3995 'Bad Script' => 'Google Fonts',
3996 'Bahiana' => 'Google Fonts',
3997 'Bai Jamjuree' => 'Google Fonts',
3998 'Baloo' => 'Google Fonts',
3999 'Baloo Bhai' => 'Google Fonts',
4000 'Baloo Bhaijaan' => 'Google Fonts',
4001 'Baloo Bhaina' => 'Google Fonts',
4002 'Baloo Chettan' => 'Google Fonts',
4003 'Baloo Da' => 'Google Fonts',
4004 'Baloo Paaji' => 'Google Fonts',
4005 'Baloo Tamma' => 'Google Fonts',
4006 'Baloo Tammudu' => 'Google Fonts',
4007 'Baloo Thambi' => 'Google Fonts',
4008 'Balthazar' => 'Google Fonts',
4009 'Bangers' => 'Google Fonts',
4010 'Barlow' => 'Google Fonts',
4011 'Barlow Condensed' => 'Google Fonts',
4012 'Barlow Semi Condensed' => 'Google Fonts',
4013 'Barrio' => 'Google Fonts',
4014 'Basic' => 'Google Fonts',
4015 'Battambang' => 'Google Fonts',
4016 'Baumans' => 'Google Fonts',
4017 'Bayon' => 'Google Fonts',
4018 'Belgrano' => 'Google Fonts',
4019 'Bellefair' => 'Google Fonts',
4020 'Belleza' => 'Google Fonts',
4021 'BenchNine' => 'Google Fonts',
4022 'Bentham' => 'Google Fonts',
4023 'Berkshire Swash' => 'Google Fonts',
4024 'Bevan' => 'Google Fonts',
4025 'Bigelow Rules' => 'Google Fonts',
4026 'Bigshot One' => 'Google Fonts',
4027 'Bilbo' => 'Google Fonts',
4028 'Bilbo Swash Caps' => 'Google Fonts',
4029 'BioRhyme' => 'Google Fonts',
4030 'BioRhyme Expanded' => 'Google Fonts',
4031 'Biryani' => 'Google Fonts',
4032 'Bitter' => 'Google Fonts',
4033 'Black And White Picture' => 'Google Fonts',
4034 'Black Han Sans' => 'Google Fonts',
4035 'Black Ops One' => 'Google Fonts',
4036 'Bokor' => 'Google Fonts',
4037 'Bonbon' => 'Google Fonts',
4038 'Boogaloo' => 'Google Fonts',
4039 'Bowlby One' => 'Google Fonts',
4040 'Bowlby One SC' => 'Google Fonts',
4041 'Brawler' => 'Google Fonts',
4042 'Bree Serif' => 'Google Fonts',
4043 'Bubblegum Sans' => 'Google Fonts',
4044 'Bubbler One' => 'Google Fonts',
4045 'Buda' => 'Google Fonts',
4046 'Buenard' => 'Google Fonts',
4047 'Bungee' => 'Google Fonts',
4048 'Bungee Hairline' => 'Google Fonts',
4049 'Bungee Inline' => 'Google Fonts',
4050 'Bungee Outline' => 'Google Fonts',
4051 'Bungee Shade' => 'Google Fonts',
4052 'Butcherman' => 'Google Fonts',
4053 'Butterfly Kids' => 'Google Fonts',
4054 'Cabin' => 'Google Fonts',
4055 'Cabin Condensed' => 'Google Fonts',
4056 'Cabin Sketch' => 'Google Fonts',
4057 'Caesar Dressing' => 'Google Fonts',
4058 'Cagliostro' => 'Google Fonts',
4059 'Cairo' => 'Google Fonts',
4060 'Calligraffitti' => 'Google Fonts',
4061 'Cambay' => 'Google Fonts',
4062 'Cambo' => 'Google Fonts',
4063 'Candal' => 'Google Fonts',
4064 'Cantarell' => 'Google Fonts',
4065 'Cantata One' => 'Google Fonts',
4066 'Cantora One' => 'Google Fonts',
4067 'Capriola' => 'Google Fonts',
4068 'Cardo' => 'Google Fonts',
4069 'Carme' => 'Google Fonts',
4070 'Carrois Gothic' => 'Google Fonts',
4071 'Carrois Gothic SC' => 'Google Fonts',
4072 'Carter One' => 'Google Fonts',
4073 'Catamaran' => 'Google Fonts',
4074 'Caudex' => 'Google Fonts',
4075 'Caveat' => 'Google Fonts',
4076 'Caveat Brush' => 'Google Fonts',
4077 'Cedarville Cursive' => 'Google Fonts',
4078 'Ceviche One' => 'Google Fonts',
4079 'Chakra Petch' => 'Google Fonts',
4080 'Changa' => 'Google Fonts',
4081 'Changa One' => 'Google Fonts',
4082 'Chango' => 'Google Fonts',
4083 'Charmonman' => 'Google Fonts',
4084 'Chathura' => 'Google Fonts',
4085 'Chau Philomene One' => 'Google Fonts',
4086 'Chela One' => 'Google Fonts',
4087 'Chelsea Market' => 'Google Fonts',
4088 'Chenla' => 'Google Fonts',
4089 'Cherry Cream Soda' => 'Google Fonts',
4090 'Cherry Swash' => 'Google Fonts',
4091 'Chewy' => 'Google Fonts',
4092 'Chicle' => 'Google Fonts',
4093 'Chivo' => 'Google Fonts',
4094 'Chonburi' => 'Google Fonts',
4095 'Cinzel' => 'Google Fonts',
4096 'Cinzel Decorative' => 'Google Fonts',
4097 'Clicker Script' => 'Google Fonts',
4098 'Coda' => 'Google Fonts',
4099 'Coda Caption' => 'Google Fonts',
4100 'Codystar' => 'Google Fonts',
4101 'Coiny' => 'Google Fonts',
4102 'Combo' => 'Google Fonts',
4103 'Comfortaa' => 'Google Fonts',
4104 'Coming Soon' => 'Google Fonts',
4105 'Concert One' => 'Google Fonts',
4106 'Condiment' => 'Google Fonts',
4107 'Content' => 'Google Fonts',
4108 'Contrail One' => 'Google Fonts',
4109 'Convergence' => 'Google Fonts',
4110 'Cookie' => 'Google Fonts',
4111 'Copse' => 'Google Fonts',
4112 'Corben' => 'Google Fonts',
4113 'Cormorant' => 'Google Fonts',
4114 'Cormorant Garamond' => 'Google Fonts',
4115 'Cormorant Infant' => 'Google Fonts',
4116 'Cormorant SC' => 'Google Fonts',
4117 'Cormorant Unicase' => 'Google Fonts',
4118 'Cormorant Upright' => 'Google Fonts',
4119 'Courgette' => 'Google Fonts',
4120 'Cousine' => 'Google Fonts',
4121 'Coustard' => 'Google Fonts',
4122 'Covered By Your Grace' => 'Google Fonts',
4123 'Crafty Girls' => 'Google Fonts',
4124 'Creepster' => 'Google Fonts',
4125 'Crete Round' => 'Google Fonts',
4126 'Crimson Text' => 'Google Fonts',
4127 'Croissant One' => 'Google Fonts',
4128 'Crushed' => 'Google Fonts',
4129 'Cuprum' => 'Google Fonts',
4130 'Cute Font' => 'Google Fonts',
4131 'Cutive' => 'Google Fonts',
4132 'Cutive Mono' => 'Google Fonts',
4133 'Damion' => 'Google Fonts',
4134 'Dancing Script' => 'Google Fonts',
4135 'Dangrek' => 'Google Fonts',
4136 'David Libre' => 'Google Fonts',
4137 'Dawning of a New Day' => 'Google Fonts',
4138 'Days One' => 'Google Fonts',
4139 'Dekko' => 'Google Fonts',
4140 'Delius' => 'Google Fonts',
4141 'Delius Swash Caps' => 'Google Fonts',
4142 'Delius Unicase' => 'Google Fonts',
4143 'Della Respira' => 'Google Fonts',
4144 'Denk One' => 'Google Fonts',
4145 'Devonshire' => 'Google Fonts',
4146 'Dhurjati' => 'Google Fonts',
4147 'Didact Gothic' => 'Google Fonts',
4148 'Diplomata' => 'Google Fonts',
4149 'Diplomata SC' => 'Google Fonts',
4150 'Do Hyeon' => 'Google Fonts',
4151 'Dokdo' => 'Google Fonts',
4152 'Domine' => 'Google Fonts',
4153 'Donegal One' => 'Google Fonts',
4154 'Doppio One' => 'Google Fonts',
4155 'Dorsa' => 'Google Fonts',
4156 'Dosis' => 'Google Fonts',
4157 'Dr Sugiyama' => 'Google Fonts',
4158 'Droid Arabic Kufi' => 'Google Fonts', // Hack for Google Early Access.
4159 'Droid Arabic Naskh' => 'Google Fonts', // Hack for Google Early Access.
4160 'Duru Sans' => 'Google Fonts',
4161 'Dynalight' => 'Google Fonts',
4162 'EB Garamond' => 'Google Fonts',
4163 'Eagle Lake' => 'Google Fonts',
4164 'East Sea Dokdo' => 'Google Fonts',
4165 'Eater' => 'Google Fonts',
4166 'Economica' => 'Google Fonts',
4167 'Eczar' => 'Google Fonts',
4168 'El Messiri' => 'Google Fonts',
4169 'Electrolize' => 'Google Fonts',
4170 'Elsie' => 'Google Fonts',
4171 'Elsie Swash Caps' => 'Google Fonts',
4172 'Emblema One' => 'Google Fonts',
4173 'Emilys Candy' => 'Google Fonts',
4174 'Encode Sans' => 'Google Fonts',
4175 'Encode Sans Condensed' => 'Google Fonts',
4176 'Encode Sans Expanded' => 'Google Fonts',
4177 'Encode Sans Semi Condensed' => 'Google Fonts',
4178 'Encode Sans Semi Expanded' => 'Google Fonts',
4179 'Engagement' => 'Google Fonts',
4180 'Englebert' => 'Google Fonts',
4181 'Enriqueta' => 'Google Fonts',
4182 'Erica One' => 'Google Fonts',
4183 'Esteban' => 'Google Fonts',
4184 'Euphoria Script' => 'Google Fonts',
4185 'Ewert' => 'Google Fonts',
4186 'Exo' => 'Google Fonts',
4187 'Exo 2' => 'Google Fonts',
4188 'Expletus Sans' => 'Google Fonts',
4189 'Fahkwang' => 'Google Fonts',
4190 'Fanwood Text' => 'Google Fonts',
4191 'Farsan' => 'Google Fonts',
4192 'Fascinate' => 'Google Fonts',
4193 'Fascinate Inline' => 'Google Fonts',
4194 'Faster One' => 'Google Fonts',
4195 'Fasthand' => 'Google Fonts',
4196 'Fauna One' => 'Google Fonts',
4197 'Faustina' => 'Google Fonts',
4198 'Federant' => 'Google Fonts',
4199 'Federo' => 'Google Fonts',
4200 'Felipa' => 'Google Fonts',
4201 'Fenix' => 'Google Fonts',
4202 'Finger Paint' => 'Google Fonts',
4203 'Fira Mono' => 'Google Fonts',
4204 'Fira Sans' => 'Google Fonts',
4205 'Fira Sans Condensed' => 'Google Fonts',
4206 'Fira Sans Extra Condensed' => 'Google Fonts',
4207 'Fjalla One' => 'Google Fonts',
4208 'Fjord One' => 'Google Fonts',
4209 'Flamenco' => 'Google Fonts',
4210 'Flavors' => 'Google Fonts',
4211 'Fondamento' => 'Google Fonts',
4212 'Fontdiner Swanky' => 'Google Fonts',
4213 'Forum' => 'Google Fonts',
4214 'Francois One' => 'Google Fonts',
4215 'Frank Ruhl Libre' => 'Google Fonts',
4216 'Freckle Face' => 'Google Fonts',
4217 'Fredericka the Great' => 'Google Fonts',
4218 'Fredoka One' => 'Google Fonts',
4219 'Freehand' => 'Google Fonts',
4220 'Fresca' => 'Google Fonts',
4221 'Frijole' => 'Google Fonts',
4222 'Fruktur' => 'Google Fonts',
4223 'Fugaz One' => 'Google Fonts',
4224 'GFS Didot' => 'Google Fonts',
4225 'GFS Neohellenic' => 'Google Fonts',
4226 'Gabriela' => 'Google Fonts',
4227 'Gaegu' => 'Google Fonts',
4228 'Gafata' => 'Google Fonts',
4229 'Galada' => 'Google Fonts',
4230 'Galdeano' => 'Google Fonts',
4231 'Galindo' => 'Google Fonts',
4232 'Gamja Flower' => 'Google Fonts',
4233 'Gentium Basic' => 'Google Fonts',
4234 'Gentium Book Basic' => 'Google Fonts',
4235 'Geo' => 'Google Fonts',
4236 'Geostar' => 'Google Fonts',
4237 'Geostar Fill' => 'Google Fonts',
4238 'Germania One' => 'Google Fonts',
4239 'Gidugu' => 'Google Fonts',
4240 'Gilda Display' => 'Google Fonts',
4241 'Give You Glory' => 'Google Fonts',
4242 'Glass Antiqua' => 'Google Fonts',
4243 'Glegoo' => 'Google Fonts',
4244 'Gloria Hallelujah' => 'Google Fonts',
4245 'Goblin One' => 'Google Fonts',
4246 'Gochi Hand' => 'Google Fonts',
4247 'Gorditas' => 'Google Fonts',
4248 'Gothic A1' => 'Google Fonts',
4249 'Goudy Bookletter 1911' => 'Google Fonts',
4250 'Graduate' => 'Google Fonts',
4251 'Grand Hotel' => 'Google Fonts',
4252 'Gravitas One' => 'Google Fonts',
4253 'Great Vibes' => 'Google Fonts',
4254 'Griffy' => 'Google Fonts',
4255 'Gruppo' => 'Google Fonts',
4256 'Gudea' => 'Google Fonts',
4257 'Gugi' => 'Google Fonts',
4258 'Gurajada' => 'Google Fonts',
4259 'Habibi' => 'Google Fonts',
4260 'Halant' => 'Google Fonts',
4261 'Hammersmith One' => 'Google Fonts',
4262 'Hanalei' => 'Google Fonts',
4263 'Hanalei Fill' => 'Google Fonts',
4264 'Handlee' => 'Google Fonts',
4265 'Hanuman' => 'Google Fonts',
4266 'Happy Monkey' => 'Google Fonts',
4267 'Harmattan' => 'Google Fonts',
4268 'Headland One' => 'Google Fonts',
4269 'Heebo' => 'Google Fonts',
4270 'Henny Penny' => 'Google Fonts',
4271 'Herr Von Muellerhoff' => 'Google Fonts',
4272 'Hi Melody' => 'Google Fonts',
4273 'Hind' => 'Google Fonts',
4274 'Hind Guntur' => 'Google Fonts',
4275 'Hind Madurai' => 'Google Fonts',
4276 'Hind Siliguri' => 'Google Fonts',
4277 'Hind Vadodara' => 'Google Fonts',
4278 'Holtwood One SC' => 'Google Fonts',
4279 'Homemade Apple' => 'Google Fonts',
4280 'Homenaje' => 'Google Fonts',
4281 'IBM Plex Mono' => 'Google Fonts',
4282 'IBM Plex Sans' => 'Google Fonts',
4283 'IBM Plex Sans Condensed' => 'Google Fonts',
4284 'IBM Plex Serif' => 'Google Fonts',
4285 'IM Fell DW Pica' => 'Google Fonts',
4286 'IM Fell DW Pica SC' => 'Google Fonts',
4287 'IM Fell Double Pica' => 'Google Fonts',
4288 'IM Fell Double Pica SC' => 'Google Fonts',
4289 'IM Fell English' => 'Google Fonts',
4290 'IM Fell English SC' => 'Google Fonts',
4291 'IM Fell French Canon' => 'Google Fonts',
4292 'IM Fell French Canon SC' => 'Google Fonts',
4293 'IM Fell Great Primer' => 'Google Fonts',
4294 'IM Fell Great Primer SC' => 'Google Fonts',
4295 'Iceberg' => 'Google Fonts',
4296 'Iceland' => 'Google Fonts',
4297 'Imprima' => 'Google Fonts',
4298 'Inconsolata' => 'Google Fonts',
4299 'Inder' => 'Google Fonts',
4300 'Indie Flower' => 'Google Fonts',
4301 'Inika' => 'Google Fonts',
4302 'Inknut Antiqua' => 'Google Fonts',
4303 'Irish Grover' => 'Google Fonts',
4304 'Istok Web' => 'Google Fonts',
4305 'Italiana' => 'Google Fonts',
4306 'Italianno' => 'Google Fonts',
4307 'Itim' => 'Google Fonts',
4308 'Jacques Francois' => 'Google Fonts',
4309 'Jacques Francois Shadow' => 'Google Fonts',
4310 'Jaldi' => 'Google Fonts',
4311 'Jim Nightshade' => 'Google Fonts',
4312 'Jockey One' => 'Google Fonts',
4313 'Jolly Lodger' => 'Google Fonts',
4314 'Jomhuria' => 'Google Fonts',
4315 'Josefin Sans' => 'Google Fonts',
4316 'Josefin Slab' => 'Google Fonts',
4317 'Joti One' => 'Google Fonts',
4318 'Jua' => 'Google Fonts',
4319 'Judson' => 'Google Fonts',
4320 'Julee' => 'Google Fonts',
4321 'Julius Sans One' => 'Google Fonts',
4322 'Junge' => 'Google Fonts',
4323 'Jura' => 'Google Fonts',
4324 'Just Another Hand' => 'Google Fonts',
4325 'Just Me Again Down Here' => 'Google Fonts',
4326 'K2D' => 'Google Fonts',
4327 'Kadwa' => 'Google Fonts',
4328 'Kalam' => 'Google Fonts',
4329 'Kameron' => 'Google Fonts',
4330 'Kanit' => 'Google Fonts',
4331 'Kantumruy' => 'Google Fonts',
4332 'Karla' => 'Google Fonts',
4333 'Karma' => 'Google Fonts',
4334 'Katibeh' => 'Google Fonts',
4335 'Kaushan Script' => 'Google Fonts',
4336 'Kavivanar' => 'Google Fonts',
4337 'Kavoon' => 'Google Fonts',
4338 'Kdam Thmor' => 'Google Fonts',
4339 'Keania One' => 'Google Fonts',
4340 'Kelly Slab' => 'Google Fonts',
4341 'Kenia' => 'Google Fonts',
4342 'Khand' => 'Google Fonts',
4343 'Khmer' => 'Google Fonts',
4344 'Khula' => 'Google Fonts',
4345 'Kirang Haerang' => 'Google Fonts',
4346 'Kite One' => 'Google Fonts',
4347 'Knewave' => 'Google Fonts',
4348 'KoHo' => 'Google Fonts',
4349 'Kodchasan' => 'Google Fonts',
4350 'Kosugi' => 'Google Fonts',
4351 'Kosugi Maru' => 'Google Fonts',
4352 'Kotta One' => 'Google Fonts',
4353 'Koulen' => 'Google Fonts',
4354 'Kranky' => 'Google Fonts',
4355 'Kreon' => 'Google Fonts',
4356 'Kristi' => 'Google Fonts',
4357 'Krona One' => 'Google Fonts',
4358 'Krub' => 'Google Fonts',
4359 'Kumar One' => 'Google Fonts',
4360 'Kumar One Outline' => 'Google Fonts',
4361 'Kurale' => 'Google Fonts',
4362 'La Belle Aurore' => 'Google Fonts',
4363 'Laila' => 'Google Fonts',
4364 'Lakki Reddy' => 'Google Fonts',
4365 'Lalezar' => 'Google Fonts',
4366 'Lancelot' => 'Google Fonts',
4367 'Lateef' => 'Google Fonts',
4368 'Lato' => 'Google Fonts',
4369 'League Script' => 'Google Fonts',
4370 'Leckerli One' => 'Google Fonts',
4371 'Ledger' => 'Google Fonts',
4372 'Lekton' => 'Google Fonts',
4373 'Lemon' => 'Google Fonts',
4374 'Lemonada' => 'Google Fonts',
4375 'Libre Barcode 128' => 'Google Fonts',
4376 'Libre Barcode 128 Text' => 'Google Fonts',
4377 'Libre Barcode 39' => 'Google Fonts',
4378 'Libre Barcode 39 Extended' => 'Google Fonts',
4379 'Libre Barcode 39 Extended Text' => 'Google Fonts',
4380 'Libre Barcode 39 Text' => 'Google Fonts',
4381 'Libre Baskerville' => 'Google Fonts',
4382 'Libre Franklin' => 'Google Fonts',
4383 'Life Savers' => 'Google Fonts',
4384 'Lilita One' => 'Google Fonts',
4385 'Lily Script One' => 'Google Fonts',
4386 'Limelight' => 'Google Fonts',
4387 'Linden Hill' => 'Google Fonts',
4388 'Lobster' => 'Google Fonts',
4389 'Lobster Two' => 'Google Fonts',
4390 'Londrina Outline' => 'Google Fonts',
4391 'Londrina Shadow' => 'Google Fonts',
4392 'Londrina Sketch' => 'Google Fonts',
4393 'Londrina Solid' => 'Google Fonts',
4394 'Lora' => 'Google Fonts',
4395 'Love Ya Like A Sister' => 'Google Fonts',
4396 'Loved by the King' => 'Google Fonts',
4397 'Lovers Quarrel' => 'Google Fonts',
4398 'Luckiest Guy' => 'Google Fonts',
4399 'Lusitana' => 'Google Fonts',
4400 'Lustria' => 'Google Fonts',
4401 'M PLUS 1p' => 'Google Fonts',
4402 'M PLUS Rounded 1c' => 'Google Fonts',
4403 'Macondo' => 'Google Fonts',
4404 'Macondo Swash Caps' => 'Google Fonts',
4405 'Mada' => 'Google Fonts',
4406 'Magra' => 'Google Fonts',
4407 'Maiden Orange' => 'Google Fonts',
4408 'Maitree' => 'Google Fonts',
4409 'Mako' => 'Google Fonts',
4410 'Mali' => 'Google Fonts',
4411 'Mallanna' => 'Google Fonts',
4412 'Mandali' => 'Google Fonts',
4413 'Manuale' => 'Google Fonts',
4414 'Marcellus' => 'Google Fonts',
4415 'Marcellus SC' => 'Google Fonts',
4416 'Marck Script' => 'Google Fonts',
4417 'Margarine' => 'Google Fonts',
4418 'Markazi Text' => 'Google Fonts',
4419 'Marko One' => 'Google Fonts',
4420 'Marmelad' => 'Google Fonts',
4421 'Martel' => 'Google Fonts',
4422 'Martel Sans' => 'Google Fonts',
4423 'Marvel' => 'Google Fonts',
4424 'Mate' => 'Google Fonts',
4425 'Mate SC' => 'Google Fonts',
4426 'Maven Pro' => 'Google Fonts',
4427 'McLaren' => 'Google Fonts',
4428 'Meddon' => 'Google Fonts',
4429 'MedievalSharp' => 'Google Fonts',
4430 'Medula One' => 'Google Fonts',
4431 'Meera Inimai' => 'Google Fonts',
4432 'Megrim' => 'Google Fonts',
4433 'Meie Script' => 'Google Fonts',
4434 'Merienda' => 'Google Fonts',
4435 'Merienda One' => 'Google Fonts',
4436 'Merriweather' => 'Google Fonts',
4437 'Merriweather Sans' => 'Google Fonts',
4438 'Metal' => 'Google Fonts',
4439 'Metal Mania' => 'Google Fonts',
4440 'Metamorphous' => 'Google Fonts',
4441 'Metrophobic' => 'Google Fonts',
4442 'Michroma' => 'Google Fonts',
4443 'Milonga' => 'Google Fonts',
4444 'Miltonian' => 'Google Fonts',
4445 'Miltonian Tattoo' => 'Google Fonts',
4446 'Mina' => 'Google Fonts',
4447 'Miniver' => 'Google Fonts',
4448 'Miriam Libre' => 'Google Fonts',
4449 'Mirza' => 'Google Fonts',
4450 'Miss Fajardose' => 'Google Fonts',
4451 'Mitr' => 'Google Fonts',
4452 'Modak' => 'Google Fonts',
4453 'Modern Antiqua' => 'Google Fonts',
4454 'Mogra' => 'Google Fonts',
4455 'Molengo' => 'Google Fonts',
4456 'Molle' => 'Google Fonts',
4457 'Monda' => 'Google Fonts',
4458 'Monofett' => 'Google Fonts',
4459 'Monoton' => 'Google Fonts',
4460 'Monsieur La Doulaise' => 'Google Fonts',
4461 'Montaga' => 'Google Fonts',
4462 'Montez' => 'Google Fonts',
4463 'Montserrat' => 'Google Fonts',
4464 'Montserrat Alternates' => 'Google Fonts',
4465 'Montserrat Subrayada' => 'Google Fonts',
4466 'Moul' => 'Google Fonts',
4467 'Moulpali' => 'Google Fonts',
4468 'Mountains of Christmas' => 'Google Fonts',
4469 'Mouse Memoirs' => 'Google Fonts',
4470 'Mr Bedfort' => 'Google Fonts',
4471 'Mr Dafoe' => 'Google Fonts',
4472 'Mr De Haviland' => 'Google Fonts',
4473 'Mrs Saint Delafield' => 'Google Fonts',
4474 'Mrs Sheppards' => 'Google Fonts',
4475 'Mukta' => 'Google Fonts',
4476 'Mukta Mahee' => 'Google Fonts',
4477 'Mukta Malar' => 'Google Fonts',
4478 'Mukta Vaani' => 'Google Fonts',
4479 'Muli' => 'Google Fonts',
4480 'Mystery Quest' => 'Google Fonts',
4481 'NTR' => 'Google Fonts',
4482 'Nanum Brush Script' => 'Google Fonts',
4483 'Nanum Gothic' => 'Google Fonts',
4484 'Nanum Gothic Coding' => 'Google Fonts',
4485 'Nanum Myeongjo' => 'Google Fonts',
4486 'Nanum Pen Script' => 'Google Fonts',
4487 'Neucha' => 'Google Fonts',
4488 'Neuton' => 'Google Fonts',
4489 'New Rocker' => 'Google Fonts',
4490 'News Cycle' => 'Google Fonts',
4491 'Niconne' => 'Google Fonts',
4492 'Niramit' => 'Google Fonts',
4493 'Nixie One' => 'Google Fonts',
4494 'Nobile' => 'Google Fonts',
4495 'Nokora' => 'Google Fonts',
4496 'Norican' => 'Google Fonts',
4497 'Nosifer' => 'Google Fonts',
4498 'Notable' => 'Google Fonts',
4499 'Nothing You Could Do' => 'Google Fonts',
4500 'Noticia Text' => 'Google Fonts',
4501 'Noto Kufi Arabic' => 'Google Fonts', // Hack for Google Early Access.
4502 'Noto Naskh Arabic' => 'Google Fonts', // Hack for Google Early Access.
4503 'Noto Sans' => 'Google Fonts',
4504 'Noto Sans Hebrew' => 'Google Fonts', // Hack for Google Early Access.
4505 'Noto Sans JP' => 'Google Fonts',
4506 'Noto Sans KR' => 'Google Fonts',
4507 'Noto Serif' => 'Google Fonts',
4508 'Noto Serif JP' => 'Google Fonts',
4509 'Noto Serif KR' => 'Google Fonts',
4510 'Nova Cut' => 'Google Fonts',
4511 'Nova Flat' => 'Google Fonts',
4512 'Nova Mono' => 'Google Fonts',
4513 'Nova Oval' => 'Google Fonts',
4514 'Nova Round' => 'Google Fonts',
4515 'Nova Script' => 'Google Fonts',
4516 'Nova Slim' => 'Google Fonts',
4517 'Nova Square' => 'Google Fonts',
4518 'Numans' => 'Google Fonts',
4519 'Nunito' => 'Google Fonts',
4520 'Nunito Sans' => 'Google Fonts',
4521 'Odor Mean Chey' => 'Google Fonts',
4522 'Offside' => 'Google Fonts',
4523 'Old Standard TT' => 'Google Fonts',
4524 'Oldenburg' => 'Google Fonts',
4525 'Oleo Script' => 'Google Fonts',
4526 'Oleo Script Swash Caps' => 'Google Fonts',
4527 'Open Sans' => 'Google Fonts',
4528 'Open Sans Condensed' => 'Google Fonts',
4529 'Open Sans Hebrew' => 'Google Fonts', // Hack for Google Early Access.
4530 'Open Sans Hebrew Condensed' => 'Google Fonts', // Hack for Google Early Access.
4531 'Oranienbaum' => 'Google Fonts',
4532 'Orbitron' => 'Google Fonts',
4533 'Oregano' => 'Google Fonts',
4534 'Orienta' => 'Google Fonts',
4535 'Original Surfer' => 'Google Fonts',
4536 'Oswald' => 'Google Fonts',
4537 'Over the Rainbow' => 'Google Fonts',
4538 'Overlock' => 'Google Fonts',
4539 'Overlock SC' => 'Google Fonts',
4540 'Overpass' => 'Google Fonts',
4541 'Overpass Mono' => 'Google Fonts',
4542 'Ovo' => 'Google Fonts',
4543 'Oxygen' => 'Google Fonts',
4544 'Oxygen Mono' => 'Google Fonts',
4545 'PT Mono' => 'Google Fonts',
4546 'PT Sans' => 'Google Fonts',
4547 'PT Sans Caption' => 'Google Fonts',
4548 'PT Sans Narrow' => 'Google Fonts',
4549 'PT Serif' => 'Google Fonts',
4550 'PT Serif Caption' => 'Google Fonts',
4551 'Pacifico' => 'Google Fonts',
4552 'Padauk' => 'Google Fonts',
4553 'Palanquin' => 'Google Fonts',
4554 'Palanquin Dark' => 'Google Fonts',
4555 'Pangolin' => 'Google Fonts',
4556 'Paprika' => 'Google Fonts',
4557 'Parisienne' => 'Google Fonts',
4558 'Passero One' => 'Google Fonts',
4559 'Passion One' => 'Google Fonts',
4560 'Pathway Gothic One' => 'Google Fonts',
4561 'Patrick Hand' => 'Google Fonts',
4562 'Patrick Hand SC' => 'Google Fonts',
4563 'Pattaya' => 'Google Fonts',
4564 'Patua One' => 'Google Fonts',
4565 'Pavanam' => 'Google Fonts',
4566 'Paytone One' => 'Google Fonts',
4567 'Peddana' => 'Google Fonts',
4568 'Peralta' => 'Google Fonts',
4569 'Permanent Marker' => 'Google Fonts',
4570 'Petit Formal Script' => 'Google Fonts',
4571 'Petrona' => 'Google Fonts',
4572 'Philosopher' => 'Google Fonts',
4573 'Piedra' => 'Google Fonts',
4574 'Pinyon Script' => 'Google Fonts',
4575 'Pirata One' => 'Google Fonts',
4576 'Plaster' => 'Google Fonts',
4577 'Play' => 'Google Fonts',
4578 'Playball' => 'Google Fonts',
4579 'Playfair Display' => 'Google Fonts',
4580 'Playfair Display SC' => 'Google Fonts',
4581 'Podkova' => 'Google Fonts',
4582 'Poiret One' => 'Google Fonts',
4583 'Poller One' => 'Google Fonts',
4584 'Poly' => 'Google Fonts',
4585 'Pompiere' => 'Google Fonts',
4586 'Pontano Sans' => 'Google Fonts',
4587 'Poor Story' => 'Google Fonts',
4588 'Poppins' => 'Google Fonts',
4589 'Port Lligat Sans' => 'Google Fonts',
4590 'Port Lligat Slab' => 'Google Fonts',
4591 'Pragati Narrow' => 'Google Fonts',
4592 'Prata' => 'Google Fonts',
4593 'Preahvihear' => 'Google Fonts',
4594 'Press Start 2P' => 'Google Fonts',
4595 'Pridi' => 'Google Fonts',
4596 'Princess Sofia' => 'Google Fonts',
4597 'Prociono' => 'Google Fonts',
4598 'Prompt' => 'Google Fonts',
4599 'Prosto One' => 'Google Fonts',
4600 'Proza Libre' => 'Google Fonts',
4601 'Puritan' => 'Google Fonts',
4602 'Purple Purse' => 'Google Fonts',
4603 'Quando' => 'Google Fonts',
4604 'Quantico' => 'Google Fonts',
4605 'Quattrocento' => 'Google Fonts',
4606 'Quattrocento Sans' => 'Google Fonts',
4607 'Questrial' => 'Google Fonts',
4608 'Quicksand' => 'Google Fonts',
4609 'Quintessential' => 'Google Fonts',
4610 'Qwigley' => 'Google Fonts',
4611 'Racing Sans One' => 'Google Fonts',
4612 'Radley' => 'Google Fonts',
4613 'Rajdhani' => 'Google Fonts',
4614 'Rakkas' => 'Google Fonts',
4615 'Raleway' => 'Google Fonts',
4616 'Raleway Dots' => 'Google Fonts',
4617 'Ramabhadra' => 'Google Fonts',
4618 'Ramaraja' => 'Google Fonts',
4619 'Rambla' => 'Google Fonts',
4620 'Rammetto One' => 'Google Fonts',
4621 'Ranchers' => 'Google Fonts',
4622 'Rancho' => 'Google Fonts',
4623 'Ranga' => 'Google Fonts',
4624 'Rasa' => 'Google Fonts',
4625 'Rationale' => 'Google Fonts',
4626 'Ravi Prakash' => 'Google Fonts',
4627 'Redressed' => 'Google Fonts',
4628 'Reem Kufi' => 'Google Fonts',
4629 'Reenie Beanie' => 'Google Fonts',
4630 'Revalia' => 'Google Fonts',
4631 'Rhodium Libre' => 'Google Fonts',
4632 'Ribeye' => 'Google Fonts',
4633 'Ribeye Marrow' => 'Google Fonts',
4634 'Righteous' => 'Google Fonts',
4635 'Risque' => 'Google Fonts',
4636 'Roboto' => 'Google Fonts',
4637 'Roboto Condensed' => 'Google Fonts',
4638 'Roboto Mono' => 'Google Fonts',
4639 'Roboto Slab' => 'Google Fonts',
4640 'Rochester' => 'Google Fonts',
4641 'Rock Salt' => 'Google Fonts',
4642 'Rokkitt' => 'Google Fonts',
4643 'Romanesco' => 'Google Fonts',
4644 'Ropa Sans' => 'Google Fonts',
4645 'Rosario' => 'Google Fonts',
4646 'Rosarivo' => 'Google Fonts',
4647 'Rouge Script' => 'Google Fonts',
4648 'Rozha One' => 'Google Fonts',
4649 'Rubik' => 'Google Fonts',
4650 'Rubik Mono One' => 'Google Fonts',
4651 'Ruda' => 'Google Fonts',
4652 'Rufina' => 'Google Fonts',
4653 'Ruge Boogie' => 'Google Fonts',
4654 'Ruluko' => 'Google Fonts',
4655 'Rum Raisin' => 'Google Fonts',
4656 'Ruslan Display' => 'Google Fonts',
4657 'Russo One' => 'Google Fonts',
4658 'Ruthie' => 'Google Fonts',
4659 'Rye' => 'Google Fonts',
4660 'Sacramento' => 'Google Fonts',
4661 'Sahitya' => 'Google Fonts',
4662 'Sail' => 'Google Fonts',
4663 'Saira' => 'Google Fonts',
4664 'Saira Condensed' => 'Google Fonts',
4665 'Saira Extra Condensed' => 'Google Fonts',
4666 'Saira Semi Condensed' => 'Google Fonts',
4667 'Salsa' => 'Google Fonts',
4668 'Sanchez' => 'Google Fonts',
4669 'Sancreek' => 'Google Fonts',
4670 'Sansita' => 'Google Fonts',
4671 'Sarala' => 'Google Fonts',
4672 'Sarina' => 'Google Fonts',
4673 'Sarpanch' => 'Google Fonts',
4674 'Satisfy' => 'Google Fonts',
4675 'Sawarabi Gothic' => 'Google Fonts',
4676 'Sawarabi Mincho' => 'Google Fonts',
4677 'Scada' => 'Google Fonts',
4678 'Scheherazade' => 'Google Fonts',
4679 'Schoolbell' => 'Google Fonts',
4680 'Scope One' => 'Google Fonts',
4681 'Seaweed Script' => 'Google Fonts',
4682 'Secular One' => 'Google Fonts',
4683 'Sedgwick Ave' => 'Google Fonts',
4684 'Sedgwick Ave Display' => 'Google Fonts',
4685 'Sevillana' => 'Google Fonts',
4686 'Seymour One' => 'Google Fonts',
4687 'Shadows Into Light' => 'Google Fonts',
4688 'Shadows Into Light Two' => 'Google Fonts',
4689 'Shanti' => 'Google Fonts',
4690 'Share' => 'Google Fonts',
4691 'Share Tech' => 'Google Fonts',
4692 'Share Tech Mono' => 'Google Fonts',
4693 'Shojumaru' => 'Google Fonts',
4694 'Short Stack' => 'Google Fonts',
4695 'Shrikhand' => 'Google Fonts',
4696 'Siemreap' => 'Google Fonts',
4697 'Sigmar One' => 'Google Fonts',
4698 'Signika' => 'Google Fonts',
4699 'Signika Negative' => 'Google Fonts',
4700 'Simonetta' => 'Google Fonts',
4701 'Sintony' => 'Google Fonts',
4702 'Sirin Stencil' => 'Google Fonts',
4703 'Six Caps' => 'Google Fonts',
4704 'Skranji' => 'Google Fonts',
4705 'Slabo 13px' => 'Google Fonts',
4706 'Slabo 27px' => 'Google Fonts',
4707 'Slackey' => 'Google Fonts',
4708 'Smokum' => 'Google Fonts',
4709 'Smythe' => 'Google Fonts',
4710 'Sniglet' => 'Google Fonts',
4711 'Snippet' => 'Google Fonts',
4712 'Snowburst One' => 'Google Fonts',
4713 'Sofadi One' => 'Google Fonts',
4714 'Sofia' => 'Google Fonts',
4715 'Song Myung' => 'Google Fonts',
4716 'Sonsie One' => 'Google Fonts',
4717 'Sorts Mill Goudy' => 'Google Fonts',
4718 'Source Code Pro' => 'Google Fonts',
4719 'Source Sans Pro' => 'Google Fonts',
4720 'Source Serif Pro' => 'Google Fonts',
4721 'Space Mono' => 'Google Fonts',
4722 'Special Elite' => 'Google Fonts',
4723 'Spectral' => 'Google Fonts',
4724 'Spectral SC' => 'Google Fonts',
4725 'Spicy Rice' => 'Google Fonts',
4726 'Spinnaker' => 'Google Fonts',
4727 'Spirax' => 'Google Fonts',
4728 'Squada One' => 'Google Fonts',
4729 'Sree Krushnadevaraya' => 'Google Fonts',
4730 'Sriracha' => 'Google Fonts',
4731 'Srisakdi' => 'Google Fonts',
4732 'Stalemate' => 'Google Fonts',
4733 'Stalinist One' => 'Google Fonts',
4734 'Stardos Stencil' => 'Google Fonts',
4735 'Stint Ultra Condensed' => 'Google Fonts',
4736 'Stint Ultra Expanded' => 'Google Fonts',
4737 'Stoke' => 'Google Fonts',
4738 'Strait' => 'Google Fonts',
4739 'Stylish' => 'Google Fonts',
4740 'Sue Ellen Francisco' => 'Google Fonts',
4741 'Suez One' => 'Google Fonts',
4742 'Sumana' => 'Google Fonts',
4743 'Sunflower' => 'Google Fonts',
4744 'Sunshiney' => 'Google Fonts',
4745 'Supermercado One' => 'Google Fonts',
4746 'Sura' => 'Google Fonts',
4747 'Suranna' => 'Google Fonts',
4748 'Suravaram' => 'Google Fonts',
4749 'Suwannaphum' => 'Google Fonts',
4750 'Swanky and Moo Moo' => 'Google Fonts',
4751 'Syncopate' => 'Google Fonts',
4752 'Tajawal' => 'Google Fonts',
4753 'Tangerine' => 'Google Fonts',
4754 'Taprom' => 'Google Fonts',
4755 'Tauri' => 'Google Fonts',
4756 'Taviraj' => 'Google Fonts',
4757 'Teko' => 'Google Fonts',
4758 'Telex' => 'Google Fonts',
4759 'Tenali Ramakrishna' => 'Google Fonts',
4760 'Tenor Sans' => 'Google Fonts',
4761 'Text Me One' => 'Google Fonts',
4762 'The Girl Next Door' => 'Google Fonts',
4763 'Tienne' => 'Google Fonts',
4764 'Tillana' => 'Google Fonts',
4765 'Timmana' => 'Google Fonts',
4766 'Tinos' => 'Google Fonts',
4767 'Titan One' => 'Google Fonts',
4768 'Titillium Web' => 'Google Fonts',
4769 'Trade Winds' => 'Google Fonts',
4770 'Trirong' => 'Google Fonts',
4771 'Trocchi' => 'Google Fonts',
4772 'Trochut' => 'Google Fonts',
4773 'Trykker' => 'Google Fonts',
4774 'Tulpen One' => 'Google Fonts',
4775 'Ubuntu' => 'Google Fonts',
4776 'Ubuntu Condensed' => 'Google Fonts',
4777 'Ubuntu Mono' => 'Google Fonts',
4778 'Ultra' => 'Google Fonts',
4779 'Uncial Antiqua' => 'Google Fonts',
4780 'Underdog' => 'Google Fonts',
4781 'Unica One' => 'Google Fonts',
4782 'UnifrakturCook' => 'Google Fonts',
4783 'UnifrakturMaguntia' => 'Google Fonts',
4784 'Unkempt' => 'Google Fonts',
4785 'Unlock' => 'Google Fonts',
4786 'Unna' => 'Google Fonts',
4787 'VT323' => 'Google Fonts',
4788 'Vampiro One' => 'Google Fonts',
4789 'Varela' => 'Google Fonts',
4790 'Varela Round' => 'Google Fonts',
4791 'Vast Shadow' => 'Google Fonts',
4792 'Vesper Libre' => 'Google Fonts',
4793 'Vibur' => 'Google Fonts',
4794 'Vidaloka' => 'Google Fonts',
4795 'Viga' => 'Google Fonts',
4796 'Voces' => 'Google Fonts',
4797 'Volkhov' => 'Google Fonts',
4798 'Vollkorn' => 'Google Fonts',
4799 'Vollkorn SC' => 'Google Fonts',
4800 'Voltaire' => 'Google Fonts',
4801 'Waiting for the Sunrise' => 'Google Fonts',
4802 'Wallpoet' => 'Google Fonts',
4803 'Walter Turncoat' => 'Google Fonts',
4804 'Warnes' => 'Google Fonts',
4805 'Wellfleet' => 'Google Fonts',
4806 'Wendy One' => 'Google Fonts',
4807 'Wire One' => 'Google Fonts',
4808 'Work Sans' => 'Google Fonts',
4809 'Yanone Kaffeesatz' => 'Google Fonts',
4810 'Yantramanav' => 'Google Fonts',
4811 'Yatra One' => 'Google Fonts',
4812 'Yellowtail' => 'Google Fonts',
4813 'Yeon Sung' => 'Google Fonts',
4814 'Yeseva One' => 'Google Fonts',
4815 'Yesteryear' => 'Google Fonts',
4816 'Yrsa' => 'Google Fonts',
4817 'Zeyada' => 'Google Fonts',
4818 'Zilla Slab' => 'Google Fonts',
4819 'Zilla Slab Highlight' => 'Google Fonts',
4820 );
4821 }
4822
4823 public function set_default_values_if_not_exists()
4824 {
4825 if(is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
4826 $options = get_option('folders_settings');
4827 $options = empty($options) || !is_array($options) ? array() : $options;
4828 foreach ($options as $option) {
4829 $post_type = self::get_custom_post_type($option);
4830 $terms = get_terms($post_type, array(
4831 'hide_empty' => false,
4832 'meta_query' => array(
4833 array(
4834 'key' => 'wcp_custom_order',
4835 'compare' => 'NOT EXISTS'
4836 )
4837 )
4838 )
4839 );
4840 if (!empty($terms)) {
4841 foreach ($terms as $term) {
4842 $order = get_term_meta($term->term_id, "wcp_custom_order", true);
4843 if (empty($order) || $order == null) {
4844 update_term_meta($term->term_id, "wcp_custom_order", "1");
4845 }
4846 }
4847 }
4848 }
4849 }
4850 }
4851
4852 /* Free and Pro major changes */
4853 public function premio_hide_child_popup() {
4854 if(isset($_REQUEST['post_type']) && isset($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'wcp_folder_nonce_'.$_REQUEST['post_type'])) {
4855 $status = (isset($_REQUEST['status']) && $_REQUEST['status'] == 1)?1:0;
4856 if($status) {
4857 add_option("premio_hide_child_popup", 1);
4858 } else {
4859 delete_option("premio_hide_child_popup");
4860 }
4861 }
4862 echo esc_attr("1");
4863 die;
4864 }
4865
4866 public function folder_update_popup_status() {
4867 if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'folder_update_popup_status')) {
4868 update_option("folder_intro_box", "hide");
4869 }
4870 echo esc_attr("1");
4871 die;
4872 }
4873
4874 public function update_folders_import_status() {
4875 if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'folders_import_3rd_party_data')) {
4876 update_option("folder_redirect_status", "3");
4877 }
4878 echo esc_attr("1");
4879 die;
4880 }
4881
4882 public function check_has_valid_key()
4883 {
4884 /* Free/Pro: checking for key, for Free return 0, for Pro check for Key */
4885 return 0;
4886 }
4887
4888 public function get_license_key_information($licenseKey)
4889 {
4890 return array();
4891 }
4892
4893 public function get_license_key_data($licenseKey = '')
4894 {
4895 return array();
4896 }
4897
4898 public function check_for_license_key()
4899 {
4900 return false;
4901 }
4902 }